From a873aa3337b93d957aea0f7a78145d6e1c99f9e0 Mon Sep 17 00:00:00 2001 From: rubidium Date: Sun, 10 Jul 2011 20:25:59 +0000 Subject: [PATCH] (svn r22652) [1.1] -Backport from trunk: - Fix: [NewGRF] Implement variables 25 and 7F for railtypes (r22633) - Fix: [NewGRF] Additional text in fund industry window is NewGRF supplied and thus should have a default colour (r22631) - Fix: Also initialise _old_vds with newgame settings; TTD savegames do not contain these settings [FS#4622] (r22626) - Fix: Do not zero the orders of disaster vehicles when converting savegames [FS#4642] (r22625) --- src/industry_gui.cpp | 2 +- src/newgrf.cpp | 1 + src/newgrf_railtype.cpp | 10 +++++++--- src/openttd.cpp | 3 +++ src/rail.h | 5 +++++ src/saveload/vehicle_sl.cpp | 2 +- src/settings_internal.h | 2 -- src/settings_type.h | 3 +++ src/table/railtypes.h | 4 ++++ 9 files changed, 25 insertions(+), 7 deletions(-) diff --git a/src/industry_gui.cpp b/src/industry_gui.cpp index ab1cfe28fd..e519edd7f4 100644 --- a/src/industry_gui.cpp +++ b/src/industry_gui.cpp @@ -459,7 +459,7 @@ public: str = GetGRFStringID(indsp->grf_prop.grffile->grfid, 0xD000 + callback_res); // No. here's the new string if (str != STR_UNDEFINED) { PrepareTextRefStackUsage(6); - DrawStringMultiLine(left, right, y, bottom, str); + DrawStringMultiLine(left, right, y, bottom, str, TC_YELLOW); StopTextRefStackUsage(); } } diff --git a/src/newgrf.cpp b/src/newgrf.cpp index a252a8a1fd..86a3faaccc 100644 --- a/src/newgrf.cpp +++ b/src/newgrf.cpp @@ -4490,6 +4490,7 @@ static void RailTypeMapSpriteGroup(ByteReader *buf, uint8 idcount) if (railtypes[i] != INVALID_RAILTYPE) { RailtypeInfo *rti = &_railtypes[railtypes[i]]; + rti->grffile[ctype] = _cur_grffile; rti->group[ctype] = _cur_grffile->spritegroups[groupid]; } } diff --git a/src/newgrf_railtype.cpp b/src/newgrf_railtype.cpp index 6f38794b6b..11c52c95ce 100644 --- a/src/newgrf_railtype.cpp +++ b/src/newgrf_railtype.cpp @@ -67,7 +67,7 @@ static const SpriteGroup *RailTypeResolveReal(const ResolverObject *object, cons return NULL; } -static inline void NewRailTypeResolver(ResolverObject *res, TileIndex tile, TileContext context) +static inline void NewRailTypeResolver(ResolverObject *res, TileIndex tile, TileContext context, const GRFFile *grffile) { res->GetRandomBits = &RailTypeGetRandomBits; res->GetTriggers = &RailTypeGetTriggers; @@ -85,6 +85,8 @@ static inline void NewRailTypeResolver(ResolverObject *res, TileIndex tile, Tile res->trigger = 0; res->reseed = 0; res->count = 0; + + res->grffile = grffile; } SpriteID GetCustomRailSprite(const RailtypeInfo *rti, TileIndex tile, RailTypeSpriteGroup rtsg, TileContext context) @@ -96,7 +98,7 @@ SpriteID GetCustomRailSprite(const RailtypeInfo *rti, TileIndex tile, RailTypeSp const SpriteGroup *group; ResolverObject object; - NewRailTypeResolver(&object, tile, context); + NewRailTypeResolver(&object, tile, context, rti->grffile[rtsg]); group = SpriteGroup::Resolve(rti->group[rtsg], &object); if (group == NULL || group->GetNumResults() == 0) return 0; @@ -126,5 +128,7 @@ uint8 GetReverseRailTypeTranslation(RailType railtype, const GRFFile *grffile) */ void GetRailTypeResolver(ResolverObject *ro, uint index) { - NewRailTypeResolver(ro, index, TCX_NORMAL); + /* There is no unique GRFFile for the tile. Multiple GRFs can define different parts of the railtype. + * However, currently the NewGRF Debug GUI does not display variables depending on the GRF (like 0x7F) anyway. */ + NewRailTypeResolver(ro, index, TCX_NORMAL, NULL); } diff --git a/src/openttd.cpp b/src/openttd.cpp index c0780241cc..7af80a8c69 100644 --- a/src/openttd.cpp +++ b/src/openttd.cpp @@ -392,7 +392,10 @@ void MakeNewgameSettingsLive() } #endif /* ENABLE_AI */ + /* Copy newgame settings to active settings. + * Also initialise old settings needed for savegame conversion. */ _settings_game = _settings_newgame; + _old_vds = _settings_client.company.vehicle; #ifdef ENABLE_AI for (CompanyID c = COMPANY_FIRST; c < MAX_COMPANIES; c++) { diff --git a/src/rail.h b/src/rail.h index 067db79571..63dfa2e102 100644 --- a/src/rail.h +++ b/src/rail.h @@ -232,6 +232,11 @@ struct RailtypeInfo { */ byte sorting_order; + /** + * NewGRF providing the Action3 for the railtype. NULL if not available. + */ + const GRFFile *grffile[RTSG_END]; + /** * Sprite groups for resolving sprites */ diff --git a/src/saveload/vehicle_sl.cpp b/src/saveload/vehicle_sl.cpp index e3491152a0..d4eedd382e 100644 --- a/src/saveload/vehicle_sl.cpp +++ b/src/saveload/vehicle_sl.cpp @@ -334,7 +334,7 @@ void AfterLoadVehicles(bool part_of_load) if (IsSavegameVersionBefore(160)) { /* In some old savegames there might be some "crap" stored. */ FOR_ALL_VEHICLES(v) { - if (!v->IsPrimaryVehicle()) { + if (!v->IsPrimaryVehicle() && v->type != VEH_DISASTER) { v->current_order.Free(); v->unitnumber = 0; } diff --git a/src/settings_internal.h b/src/settings_internal.h index 035b636f76..93392ed34f 100644 --- a/src/settings_internal.h +++ b/src/settings_internal.h @@ -92,6 +92,4 @@ bool SetSettingValue(uint index, int32 value, bool force_newgame = false); bool SetSettingValue(uint index, const char *value, bool force_newgame = false); void SetCompanySetting(uint index, int32 value); -extern VehicleDefaultSettings _old_vds; - #endif /* SETTINGS_INTERNAL_H */ diff --git a/src/settings_type.h b/src/settings_type.h index 2556aaf54f..d6947c75bf 100644 --- a/src/settings_type.h +++ b/src/settings_type.h @@ -452,6 +452,9 @@ extern GameSettings _settings_game; /** The settings values that are used for new games and/or modified in config file. */ extern GameSettings _settings_newgame; +/** Old vehicle settings, which were game settings before, and are company settings now. (Needed for savegame conversion) */ +extern VehicleDefaultSettings _old_vds; + /** * Get the settings-object applicable for the current situation: the newgame settings * when we're in the main menu and otherwise the settings of the current game. diff --git a/src/table/railtypes.h b/src/table/railtypes.h index 191714028b..3fceb4ffe7 100644 --- a/src/table/railtypes.h +++ b/src/table/railtypes.h @@ -105,6 +105,7 @@ static const RailtypeInfo _original_railtypes[] = { 0 << 4 | 7, { NULL }, + { NULL }, }, /** Electrified railway */ @@ -197,6 +198,7 @@ static const RailtypeInfo _original_railtypes[] = { 1 << 4 | 7, { NULL }, + { NULL }, }, /** Monorail */ @@ -285,6 +287,7 @@ static const RailtypeInfo _original_railtypes[] = { 2 << 4 | 7, { NULL }, + { NULL }, }, /** Maglev */ @@ -373,6 +376,7 @@ static const RailtypeInfo _original_railtypes[] = { 3 << 4 | 7, { NULL }, + { NULL }, }, };