From e8ab381e3f6112c5950bb16cf497ab7f56de3044 Mon Sep 17 00:00:00 2001 From: rubidium Date: Wed, 14 Jul 2010 19:29:13 +0000 Subject: [PATCH] (svn r20148) [1.0] -Backport from trunk: - Add [Debian]: Debug symbols package (r20129) - Change: Improve desync debugging and crash log data (r20138, r20136) - Fix: Ships were not marked as dirty when stopping inside a depot [FS#3880] (r20142) - Fix: Some windows ignored all hotkeys [FS#3902] (r20141, r20140, r20139) - Fix: Do not allow building a rail track to the water using a tree-tile [FS#3695] (r20110) - Fix: [NoAI] AITown::GetRating() returned wrong values [FS#3934] (r20103) --- bin/ai/regression/regression.txt | 6 +- os/debian/control | 10 ++ os/debian/patches/run-openttd-wrapper.patch | 7 +- os/debian/rules | 6 +- src/ai/api/ai_town.cpp | 22 +++- src/crashlog.cpp | 9 +- src/genworld_gui.cpp | 2 +- src/openttd.cpp | 112 +++++++++++--------- src/rail_cmd.cpp | 2 +- src/town_gui.cpp | 2 +- src/vehicle.cpp | 9 +- src/water.h | 12 +++ src/water_cmd.cpp | 12 +-- 13 files changed, 133 insertions(+), 78 deletions(-) diff --git a/bin/ai/regression/regression.txt b/bin/ai/regression/regression.txt index 4479e7788e..f78992a50b 100644 --- a/bin/ai/regression/regression.txt +++ b/bin/ai/regression/regression.txt @@ -8047,7 +8047,7 @@ ERROR: HasNext() is invalid as Begin() is never called GetPopulation(): 737 GetLocation(): 6446 GetHouseCount(): 26 - GetRating(): 5 + GetRating(): 6 Town 11 IsValidTown(): true GetName(): Fort Frindston @@ -8082,7 +8082,7 @@ ERROR: HasNext() is invalid as Begin() is never called GetPopulation(): 807 GetLocation(): 42338 GetHouseCount(): 33 - GetRating(): 5 + GetRating(): 6 Town 16 IsValidTown(): true GetName(): Kennville @@ -8117,7 +8117,7 @@ ERROR: HasNext() is invalid as Begin() is never called GetPopulation(): 437 GetLocation(): 22585 GetHouseCount(): 15 - GetRating(): 5 + GetRating(): 6 Town 21 IsValidTown(): true GetName(): Franinghead diff --git a/os/debian/control b/os/debian/control index 5c0801542b..d971a3899e 100644 --- a/os/debian/control +++ b/os/debian/control @@ -25,3 +25,13 @@ Description: reimplementation of Transport Tycoon Deluxe with enhancements package and optional sound files from the openttd-opensfx package (which is in non-free). Alternatively, OpenTTD can use the graphics files from the original Transport Tycoon Deluxe game (See README.Debian on how to set this up). + +Package: openttd-dbg +Architecture: any +Section: debug +Priority: extra +Depends: openttd (= ${binary:Version}), ${misc:Depends} +Description: debugging symbols for openttd + This package contains the debugging symbols for OpenTTD, the reimplementation + of the Micropose game "Transport Tycoon Deluxe" with lots of new features and + enhancements. diff --git a/os/debian/patches/run-openttd-wrapper.patch b/os/debian/patches/run-openttd-wrapper.patch index 1c81c78f42..ff8fc15aef 100644 --- a/os/debian/patches/run-openttd-wrapper.patch +++ b/os/debian/patches/run-openttd-wrapper.patch @@ -7,13 +7,14 @@ wrapper instead of the openttd binary directly. Index: media/openttd.desktop.in =================================================================== ---- a/media/openttd.desktop.in (revision 17228) +--- a/media/openttd.desktop.in (revision 20124) +++ b/media/openttd.desktop.in (working copy) -@@ -6,6 +6,6 @@ +@@ -5,7 +5,7 @@ + Version=1.1 Name=!!MENU_NAME!! - Comment=A clone of Transport Tycoon Deluxe Icon=openttd -Exec=!!TTD!! +Exec=/usr/share/games/openttd/openttd-wrapper Terminal=false Categories=!!MENU_GROUP!! + Comment=A clone of Transport Tycoon Deluxe diff --git a/os/debian/rules b/os/debian/rules index a34d520494..f2724f899e 100755 --- a/os/debian/rules +++ b/os/debian/rules @@ -17,7 +17,7 @@ endif # to be explicit about the dependencies, in case we're not running in a # clean build root. override_dh_auto_configure: - ./configure $(CROSS) --prefix-dir=/usr --install-dir=debian/openttd --without-allegro --with-zlib --with-sdl --with-png --with-freetype --with-fontconfig --with-icu --with-liblzo2 --without-iconv + ./configure $(CROSS) --prefix-dir=/usr --install-dir=debian/openttd --without-allegro --with-zlib --with-sdl --with-png --with-freetype --with-fontconfig --with-icu --with-liblzo2 --without-iconv --disable-strip CFLAGS="$(CFLAGS) -g" # Do some extra installation override_dh_auto_install: @@ -41,3 +41,7 @@ override_dh_auto_test: # target, while there isn't. override_dh_auto_clean: [ ! -f Makefile ] || $(MAKE) mrproper + +# We want to strip the debug informatiton into the -dbg package. +override_dh_strip: + dh_strip --dbg-package=openttd-dbg diff --git a/src/ai/api/ai_town.cpp b/src/ai/api/ai_town.cpp index 7f8dc30908..53c3dc92f2 100644 --- a/src/ai/api/ai_town.cpp +++ b/src/ai/api/ai_town.cpp @@ -14,6 +14,7 @@ #include "ai_cargo.hpp" #include "ai_error.hpp" #include "../../town.h" +#include "../../town_type.h" #include "../../strings_func.h" #include "../../company_func.h" #include "../../station_base.h" @@ -172,8 +173,25 @@ if (company == AICompany::COMPANY_INVALID) return TOWN_RATING_INVALID; const Town *t = ::Town::Get(town_id); - if (!HasBit(t->have_ratings, company)) return TOWN_RATING_NONE; - return max(TOWN_RATING_APPALLING, (TownRating)((t->ratings[company] / 200) + 3)); + if (!HasBit(t->have_ratings, company)) { + return TOWN_RATING_NONE; + } else if (t->ratings[company] <= RATING_APPALLING) { + return TOWN_RATING_APPALLING; + } else if (t->ratings[company] <= RATING_VERYPOOR) { + return TOWN_RATING_VERY_POOR; + } else if (t->ratings[company] <= RATING_POOR) { + return TOWN_RATING_POOR; + } else if (t->ratings[company] <= RATING_MEDIOCRE) { + return TOWN_RATING_MEDIOCRE; + } else if (t->ratings[company] <= RATING_GOOD) { + return TOWN_RATING_GOOD; + } else if (t->ratings[company] <= RATING_VERYGOOD) { + return TOWN_RATING_VERY_GOOD; + } else if (t->ratings[company] <= RATING_EXCELLENT) { + return TOWN_RATING_EXCELLENT; + } else { + return TOWN_RATING_OUTSTANDING; + } } /* static */ int AITown::GetAllowedNoise(TownID town_id) diff --git a/src/crashlog.cpp b/src/crashlog.cpp index 0cce6d0873..d77c7637d7 100644 --- a/src/crashlog.cpp +++ b/src/crashlog.cpp @@ -109,22 +109,25 @@ char *CrashLog::LogConfiguration(char *buffer, const char *last) const buffer += seprintf(buffer, last, "Configuration:\n" " Blitter: %s\n" - " Graphics set: %s\n" + " Graphics set: %s (%d)\n" " Language: %s\n" " Music driver: %s\n" - " Music set: %s\n" + " Music set: %s (%d)\n" " Network: %s\n" " Sound driver: %s\n" - " Sound set: %s\n" + " Sound set: %s (%d)\n" " Video driver: %s\n\n", BlitterFactoryBase::GetCurrentBlitter() == NULL ? "none" : BlitterFactoryBase::GetCurrentBlitter()->GetName(), BaseGraphics::GetUsedSet() == NULL ? "none" : BaseGraphics::GetUsedSet()->name, + BaseGraphics::GetUsedSet() == NULL ? -1 : BaseGraphics::GetUsedSet()->version, StrEmpty(_dynlang.curr_file) ? "none" : _dynlang.curr_file, _music_driver == NULL ? "none" : _music_driver->GetName(), BaseMusic::GetUsedSet() == NULL ? "none" : BaseMusic::GetUsedSet()->name, + BaseMusic::GetUsedSet() == NULL ? -1 : BaseMusic::GetUsedSet()->version, _networking ? (_network_server ? "server" : "client") : "no", _sound_driver == NULL ? "none" : _sound_driver->GetName(), BaseSounds::GetUsedSet() == NULL ? "none" : BaseSounds::GetUsedSet()->name, + BaseSounds::GetUsedSet() == NULL ? -1 : BaseSounds::GetUsedSet()->version, _video_driver == NULL ? "none" : _video_driver->GetName() ); diff --git a/src/genworld_gui.cpp b/src/genworld_gui.cpp index 5efbe7271f..0ed7a9bd0b 100644 --- a/src/genworld_gui.cpp +++ b/src/genworld_gui.cpp @@ -677,7 +677,7 @@ struct GenerateLandscapeWindow : public QueryStringBaseWindow { virtual EventState OnKeyPress(uint16 key, uint16 keycode) { - EventState state; + EventState state = ES_NOT_HANDLED; this->HandleEditBoxKey(GLAND_RANDOM_EDITBOX, key, keycode, state); /* the seed is unsigned, therefore atoi cannot be used. * As UINT32_MAX is a 'magic' value (use random seed) it diff --git a/src/openttd.cpp b/src/openttd.cpp index 0a5d047a15..928308d2db 100644 --- a/src/openttd.cpp +++ b/src/openttd.cpp @@ -1124,58 +1124,72 @@ static void CheckCaches() Vehicle *v; FOR_ALL_VEHICLES(v) { - if (v != v->First() || v->vehstatus & VS_CRASHED) continue; + if (v != v->First() || v->vehstatus & VS_CRASHED || !v->IsPrimaryVehicle()) continue; + + uint length = 0; + for (const Vehicle *u = v; u != NULL; u = u->Next()) length++; + + VehicleCache *veh_cache = CallocT(length); + TrainCache *tra_cache = CallocT(length); + RoadVehicleCache *roa_cache = CallocT(length); + AircraftCache *air_cache = CallocT(length); + + length = 0; + for (const Vehicle *u = v; u != NULL; u = u->Next()) { + veh_cache[length] = u->vcache; + switch (u->type) { + case VEH_TRAIN: + tra_cache[length] = Train::From(u)->tcache; + break; + case VEH_ROAD: + roa_cache[length] = RoadVehicle::From(u)->rcache; + break; + case VEH_AIRCRAFT: + air_cache[length] = Aircraft::From(u)->acache; + default: + break; + } + length++; + } switch (v->type) { - case VEH_ROAD: { - RoadVehicle *rv = RoadVehicle::From(v); - RoadVehicleCache cache; - memset(&cache, 0, sizeof(cache)); - cache = rv->rcache; - RoadVehUpdateCache(rv); - - if (memcmp(&cache, &rv->rcache, sizeof(RoadVehicleCache)) != 0) { - DEBUG(desync, 2, "cache mismatch: vehicle %i, company %i, unit number %i", v->index, (int)v->owner, v->unitnumber); - } - } break; - - case VEH_TRAIN: { - uint length = 0; - Train *t = Train::From(v); - for (Vehicle *u = t; u != NULL; u = u->Next()) length++; - - TrainCache *wagons = CallocT(length); - length = 0; - for (Train *u = t; u != NULL; u = u->Next()) wagons[length++] = u->tcache; - - t->ConsistChanged(true); - - length = 0; - for (Train *u = t; u != NULL; u = u->Next()) { - if (memcmp(&wagons[length], &u->tcache, sizeof(TrainCache)) != 0) { - DEBUG(desync, 2, "cache mismatch: vehicle %i, company %i, unit number %i, wagon %i", v->index, (int)v->owner, v->unitnumber, length); - } - length++; - } - - free(wagons); - } break; - - case VEH_AIRCRAFT: { - Aircraft *a = Aircraft::From(v); - AircraftCache cache; - memset(&cache, 0, sizeof(cache)); - cache = a->acache; - UpdateAircraftCache(a); - - if (memcmp(&cache, &a->acache, sizeof(AircraftCache)) != 0) { - DEBUG(desync, 2, "cache mismatch: vehicle %i, company %i, unit number %i", v->index, (int)v->owner, v->unitnumber); - } - } break; - - default: - break; + case VEH_TRAIN: Train::From(v)->ConsistChanged(true); break; + case VEH_ROAD: RoadVehUpdateCache(RoadVehicle::From(v)); break; + case VEH_AIRCRAFT: UpdateAircraftCache(Aircraft::From(v)); break; + default: break; } + + length = 0; + for (const Vehicle *u = v; u != NULL; u = u->Next()) { + if (memcmp(&veh_cache[length], &u->vcache, sizeof(VehicleCache)) != 0) { + DEBUG(desync, 2, "vehicle cache mismatch: type %i, vehicle %i, company %i, unit number %i, wagon %i", (int)v->type, v->index, (int)v->owner, v->unitnumber, length); + } + switch (u->type) { + case VEH_TRAIN: + if (memcmp(&tra_cache[length], &Train::From(u)->tcache, sizeof(TrainCache)) != 0) { + DEBUG(desync, 2, "train cache mismatch: vehicle %i, company %i, unit number %i, wagon %i", v->index, (int)v->owner, v->unitnumber, length); + } + break; + case VEH_ROAD: + if (memcmp(&tra_cache[length], &RoadVehicle::From(u)->rcache, sizeof(RoadVehicleCache)) != 0) { + DEBUG(desync, 2, "road vehicle cache mismatch: vehicle %i, company %i, unit number %i, wagon %i", v->index, (int)v->owner, v->unitnumber, length); + } + break; + case VEH_AIRCRAFT: + if (memcmp(&air_cache[length], &Aircraft::From(u)->acache, sizeof(AircraftCache)) != 0) { + DEBUG(desync, 2, "aircraft cache mismatch: vehicle %i, company %i, unit number %i", v->index, (int)v->owner, v->unitnumber); + } + break; + default: + break; + } + length++; + } + + free(veh_cache); + free(tra_cache); + free(roa_cache); + free(air_cache); } /* Check whether the caches are still valid */ diff --git a/src/rail_cmd.cpp b/src/rail_cmd.cpp index 7ed1d19ab0..96d64b2490 100644 --- a/src/rail_cmd.cpp +++ b/src/rail_cmd.cpp @@ -340,7 +340,7 @@ Foundation GetRailFoundation(Slope tileh, TrackBits bits) static CommandCost CheckRailSlope(Slope tileh, TrackBits rail_bits, TrackBits existing, TileIndex tile) { /* don't allow building on the lower side of a coast */ - if (IsTileType(tile, MP_WATER) || (IsTileType(tile, MP_RAILWAY) && (GetRailGroundType(tile) == RAIL_GROUND_WATER))) { + if (GetFloodingBehaviour(tile) != FLOOD_NONE) { if (!IsSteepSlope(tileh) && ((~_valid_tracks_on_leveled_foundation[tileh] & (rail_bits | existing)) != 0)) return_cmd_error(STR_ERROR_CAN_T_BUILD_ON_WATER); } diff --git a/src/town_gui.cpp b/src/town_gui.cpp index e80bca40a3..d453748b72 100644 --- a/src/town_gui.cpp +++ b/src/town_gui.cpp @@ -1188,7 +1188,7 @@ public: virtual EventState OnKeyPress(uint16 key, uint16 keycode) { - EventState state; + EventState state = ES_NOT_HANDLED; if (this->HandleEditBoxKey(TSEW_TOWNNAME_EDITBOX, key, keycode, state) == HEBR_CANCEL) { this->UnfocusFocusedWidget(); } diff --git a/src/vehicle.cpp b/src/vehicle.cpp index 22fa4e5a54..fde6355ea5 100644 --- a/src/vehicle.cpp +++ b/src/vehicle.cpp @@ -1011,11 +1011,14 @@ void VehicleEnterDepot(Vehicle *v) SetWindowClassesDirty(WC_ROADVEH_LIST); break; - case VEH_SHIP: + case VEH_SHIP: { SetWindowClassesDirty(WC_SHIPS_LIST); - Ship::From(v)->state = TRACK_BIT_DEPOT; - RecalcShipStuff(v); + Ship *ship = Ship::From(v); + ship->state = TRACK_BIT_DEPOT; + ship->UpdateViewport(true, true); + SetWindowDirty(WC_VEHICLE_DEPOT, v->tile); break; + } case VEH_AIRCRAFT: SetWindowClassesDirty(WC_AIRCRAFT_LIST); diff --git a/src/water.h b/src/water.h index 62cfc37e2c..db52600eeb 100644 --- a/src/water.h +++ b/src/water.h @@ -16,6 +16,18 @@ #include "company_type.h" #include "slope_type.h" +/** + * Describes the behaviour of a tile during flooding. + */ +enum FloodingBehaviour { + FLOOD_NONE, ///< The tile does not flood neighboured tiles. + FLOOD_ACTIVE, ///< The tile floods neighboured tiles. + FLOOD_PASSIVE, ///< The tile does not actively flood neighboured tiles, but it prevents them from drying up. + FLOOD_DRYUP, ///< The tile drys up if it is not constantly flooded from neighboured tiles. +}; + +FloodingBehaviour GetFloodingBehaviour(TileIndex tile); + void TileLoop_Water(TileIndex tile); bool FloodHalftile(TileIndex t); void DoFloodTile(TileIndex target); diff --git a/src/water_cmd.cpp b/src/water_cmd.cpp index ad6426edfc..cf1e6a938a 100644 --- a/src/water_cmd.cpp +++ b/src/water_cmd.cpp @@ -38,16 +38,6 @@ #include "table/sprites.h" #include "table/strings.h" -/** - * Describes the behaviour of a tile during flooding. - */ -enum FloodingBehaviour { - FLOOD_NONE, ///< The tile does not flood neighboured tiles. - FLOOD_ACTIVE, ///< The tile floods neighboured tiles. - FLOOD_PASSIVE, ///< The tile does not actively flood neighboured tiles, but it prevents them from drying up. - FLOOD_DRYUP, ///< The tile drys up if it is not constantly flooded from neighboured tiles. -}; - /** * Describes from which directions a specific slope can be flooded (if the tile is floodable at all). */ @@ -794,7 +784,7 @@ static void FloodVehicle(Vehicle *v) * * @return Behaviour of the tile */ -static FloodingBehaviour GetFloodingBehaviour(TileIndex tile) +FloodingBehaviour GetFloodingBehaviour(TileIndex tile) { /* FLOOD_ACTIVE: 'single-corner-raised'-coast, sea, sea-shipdepots, sea-buoys, sea-docks (water part), rail with flooded halftile, sea-water-industries, sea-oilrigs * FLOOD_DRYUP: coast with more than one corner raised, coast with rail-track, coast with trees