1
0
Fork 0

Fixed the loading of owners with old constants

pull/12767/head
Andrii Dokhniak 2024-06-04 15:26:10 +02:00
parent 924c14b849
commit d46e49498f
18 changed files with 101 additions and 36 deletions

View File

@ -25,9 +25,9 @@ struct Station;
* - bits 0-15 town or industry number * - bits 0-15 town or industry number
* - bit 16 is set if it is an industry number (else it is a town number). * - bit 16 is set if it is an industry number (else it is a town number).
* - bits 19-23 Cargo type. * - bits 19-23 Cargo type.
* - bits 24-COMPANY_BIT_SIZE %Company number. * - bits 24 - 24 + COMPANY_BIT_SIZE %Company number.
*/ */
typedef uint64_t CargoMonitorID; ///< Type of the cargo monitor number. typedef uint32_t CargoMonitorID; ///< Type of the cargo monitor number.
/** Map type for storing and updating active cargo monitor numbers and their amounts. */ /** Map type for storing and updating active cargo monitor numbers and their amounts. */
typedef std::map<CargoMonitorID, OverflowSafeInt64> CargoMonitorMap; typedef std::map<CargoMonitorID, OverflowSafeInt64> CargoMonitorMap;
@ -49,7 +49,7 @@ enum CargoCompanyBits {
}; };
static_assert(CCB_COMPANY_LENGTH <= (1 << 30)); // This should never be a limiting factor static_assert(CCB_COMPANY_LENGTH <= (1 << 8));
static_assert(NUM_CARGO <= (1 << CCB_CARGO_TYPE_LENGTH)); static_assert(NUM_CARGO <= (1 << CCB_CARGO_TYPE_LENGTH));
static_assert(MAX_COMPANIES <= (1 << CCB_COMPANY_LENGTH)); static_assert(MAX_COMPANIES <= (1 << CCB_COMPANY_LENGTH));

View File

@ -41,6 +41,8 @@ enum Owner : uint8_t {
COMPANY_NEW_COMPANY = 0xF8, ///< The client wants a new company COMPANY_NEW_COMPANY = 0xF8, ///< The client wants a new company
COMPANY_SPECTATOR = 0xF9, ///< The client is spectating COMPANY_SPECTATOR = 0xF9, ///< The client is spectating
}; };
const uint8_t COMPANY_SIZE_BITS = 8; /// Size of the company id in bits const uint8_t COMPANY_SIZE_BITS = 8; /// Size of the company id in bits
static_assert(COMPANY_SIZE_BITS <= 10); /// 32bit m9 can only fit 3 owners of size 10 static_assert(COMPANY_SIZE_BITS <= 10); /// 32bit m9 can only fit 3 owners of size 10

View File

@ -10,7 +10,9 @@
#ifndef INDUSTRY_MAP_H #ifndef INDUSTRY_MAP_H
#define INDUSTRY_MAP_H #define INDUSTRY_MAP_H
#include "company_type.h"
#include "industrytype.h" #include "industrytype.h"
#include "tile_map.h"
#include "water_map.h" #include "water_map.h"
@ -100,7 +102,7 @@ inline void SetIndustryCompleted(Tile tile)
inline uint8_t GetIndustryConstructionStage(Tile tile) inline uint8_t GetIndustryConstructionStage(Tile tile)
{ {
assert(IsTileType(tile, MP_INDUSTRY)); assert(IsTileType(tile, MP_INDUSTRY));
return IsIndustryCompleted(tile) ? (uint8_t)INDUSTRY_COMPLETED : GB(tile.m1(), 0, 2); return IsIndustryCompleted(tile) ? (uint8_t)INDUSTRY_COMPLETED : GB(tile.m1(), 0, 2); // MYTODO: Figure this out, seams like it would read bits of the owner
} }
/** /**
@ -286,6 +288,8 @@ inline void MakeIndustry(Tile t, IndustryID index, IndustryGfx gfx, uint8_t rand
SetIndustryTriggers(t, 0); // rest of m6 SetIndustryTriggers(t, 0); // rest of m6
SetWaterClass(t, wc); SetWaterClass(t, wc);
t.m7() = 0; t.m7() = 0;
t.m8() = 0;
t.m9() = 0;
} }
#endif /* INDUSTRY_MAP_H */ #endif /* INDUSTRY_MAP_H */

View File

@ -240,7 +240,7 @@ inline Owner OldGetRoadOwner(Tile t, RoadTramType rtt)
/* Trams don't need OWNER_TOWN, and remapping OWNER_NONE /* Trams don't need OWNER_TOWN, and remapping OWNER_NONE
* to OWNER_TOWN makes it use one bit less */ * to OWNER_TOWN makes it use one bit less */
Owner o = (Owner)GB(t.m3(), 4, 4); Owner o = (Owner)GB(t.m3(), 4, 4);
return o == OWNER_TOWN ? OWNER_NONE : o; return o == OLD_OWNER_TOWN ? OLD_OWNER_NONE : o;
} }
/** /**
@ -284,7 +284,7 @@ inline void OldSetRoadOwner(Tile t, RoadTramType rtt, Owner o)
if (rtt == RTT_ROAD) { if (rtt == RTT_ROAD) {
SB(IsNormalRoadTile(t) ? t.m1() : t.m7(), 0, 5, o); SB(IsNormalRoadTile(t) ? t.m1() : t.m7(), 0, 5, o);
} else { } else {
SB(t.m3(), 4, 4, o == OWNER_NONE ? OWNER_TOWN : o); SB(t.m3(), 4, 4, o == OLD_OWNER_NONE ? OLD_OWNER_TOWN : o);
} }
} }

View File

@ -63,6 +63,8 @@
#include "../timer/timer_game_economy.h" #include "../timer/timer_game_economy.h"
#include "../timer/timer_game_tick.h" #include "../timer/timer_game_tick.h"
#include "company_type.h"
#include "road_map.h"
#include "saveload/saveload.h" #include "saveload/saveload.h"
#include "saveload_internal.h" #include "saveload_internal.h"
@ -454,8 +456,8 @@ static void FixOwnerOfRailTrack(Tile t)
if (IsLevelCrossingTile(t)) { if (IsLevelCrossingTile(t)) {
/* else change the crossing to normal road (road vehicles won't care) */ /* else change the crossing to normal road (road vehicles won't care) */
Owner road = GetRoadOwner(t, RTT_ROAD); Owner road = OldGetRoadOwner(t, RTT_ROAD);
Owner tram = GetRoadOwner(t, RTT_TRAM); Owner tram = OldGetRoadOwner(t, RTT_TRAM);
RoadBits bits = GetCrossingRoadBits(t); RoadBits bits = GetCrossingRoadBits(t);
bool hasroad = HasBit(t.m7(), 6); bool hasroad = HasBit(t.m7(), 6);
bool hastram = HasBit(t.m7(), 7); bool hastram = HasBit(t.m7(), 7);
@ -466,7 +468,7 @@ static void FixOwnerOfRailTrack(Tile t)
t.m3() = (hasroad ? bits : 0); t.m3() = (hasroad ? bits : 0);
t.m5() = (hastram ? bits : 0) | ROAD_TILE_NORMAL << 6; t.m5() = (hastram ? bits : 0) | ROAD_TILE_NORMAL << 6;
SB(t.m6(), 2, 4, 0); SB(t.m6(), 2, 4, 0);
SetRoadOwner(t, RTT_TRAM, tram); OldSetRoadOwner(t, RTT_TRAM, tram);
return; return;
} }
@ -1226,7 +1228,7 @@ bool AfterLoadGame()
t.m5() = (axis == AXIS_X ? ROAD_Y : ROAD_X) | ROAD_TILE_NORMAL << 6; t.m5() = (axis == AXIS_X ? ROAD_Y : ROAD_X) | ROAD_TILE_NORMAL << 6;
SB(t.m6(), 2, 4, 0); SB(t.m6(), 2, 4, 0);
t.m7() = 1 << 6; t.m7() = 1 << 6;
SetRoadOwner(t, RTT_TRAM, OWNER_NONE); OldSetRoadOwner(t, RTT_TRAM, OWNER_NONE);
} }
} else { } else {
if (GB(t.m5(), 3, 2) == 0) { if (GB(t.m5(), 3, 2) == 0) {
@ -1883,8 +1885,8 @@ bool AfterLoadGame()
/* works for all RoadTileType */ /* works for all RoadTileType */
for (RoadTramType rtt : _roadtramtypes) { for (RoadTramType rtt : _roadtramtypes) {
/* update even non-existing road types to update tile owner too */ /* update even non-existing road types to update tile owner too */
Owner o = GetRoadOwner(t, rtt); Owner o = OldGetRoadOwner(t, rtt);
if (o < OLD_MAX_COMPANIES && !Company::IsValidID(o)) SetRoadOwner(t, rtt, OWNER_NONE); if (o < OLD_MAX_COMPANIES && !Company::IsValidID(o)) OldSetRoadOwner(t, rtt, OWNER_NONE);
} }
if (IsLevelCrossing(t)) { if (IsLevelCrossing(t)) {
if (!Company::IsValidID(OldGetTileOwner(t))) FixOwnerOfRailTrack(t); if (!Company::IsValidID(OldGetTileOwner(t))) FixOwnerOfRailTrack(t);
@ -2411,7 +2413,6 @@ bool AfterLoadGame()
/* We need to properly number/name the depots. /* We need to properly number/name the depots.
* The first step is making sure none of the depots uses the * The first step is making sure none of the depots uses the
* 'default' names, after that we can assign the names. */ * 'default' names, after that we can assign the names. */
for (Depot *d : Depot::Iterate()) d->town_cn = UINT16_MAX;
for (Depot *d : Depot::Iterate()) MakeDefaultName(d); for (Depot *d : Depot::Iterate()) MakeDefaultName(d);
} }
@ -2846,8 +2847,8 @@ bool AfterLoadGame()
for (auto t : Map::Iterate()) { for (auto t : Map::Iterate()) {
if (!IsBayRoadStopTile(t)) continue; if (!IsBayRoadStopTile(t)) continue;
Owner o = OldGetTileOwner(t); Owner o = OldGetTileOwner(t);
SetRoadOwner(t, RTT_ROAD, o); OldSetRoadOwner(t, RTT_ROAD, o);
SetRoadOwner(t, RTT_TRAM, o); OldSetRoadOwner(t, RTT_TRAM, o);
} }
} }
@ -3268,10 +3269,22 @@ bool AfterLoadGame()
} }
if (IsSavegameVersionBefore(SLV_MORE_COMPANIES)) { if (IsSavegameVersionBefore(SLV_MORE_COMPANIES)) {
for (auto t : Map::Iterate()) { for (auto t : Map::Iterate()) {
if (IsValidTile(t) //SB(t.m9(), 0, COMPANY_SIZE_BITS, OWNER_NONE);
&& !IsTileType(t, MP_HOUSE) if (!IsValidTile(t)) {
continue;
}
if (!IsTileType(t, MP_HOUSE)
&& !IsTileType(t, MP_INDUSTRY)) { && !IsTileType(t, MP_INDUSTRY)) {
SetTileOwner(t, OldGetTileOwner(t)); Owner o =OldGetTileOwner(t) ;
o = ParseOldOwner(o);
SetTileOwner(t, o);
}
if (MayHaveRoad(t)) {
for (RoadTramType rtt : _roadtramtypes) {
Owner o = OldGetRoadOwner(t, rtt);
o = ParseOldOwner(o);
SetRoadOwner(t, rtt, o);
}
} }
} }
} }

View File

@ -24,7 +24,7 @@ struct TempStorage {
/** Description of the #TempStorage structure for the purpose of load and save. */ /** Description of the #TempStorage structure for the purpose of load and save. */
static const SaveLoad _cargomonitor_pair_desc[] = { static const SaveLoad _cargomonitor_pair_desc[] = {
SLE_VAR(TempStorage, number, SLE_UINT64), SLE_VAR(TempStorage, number, SLE_UINT32),
SLE_VAR(TempStorage, amount, SLE_UINT32), SLE_VAR(TempStorage, amount, SLE_UINT32),
}; };

View File

@ -523,7 +523,7 @@ struct PLYRChunkHandler : ChunkHandler {
SlObject(c, slt); SlObject(c, slt);
_company_colours[index] = c->colour; _company_colours[index] = c->colour;
if (IsSavegameVersionBefore(SLV_MORE_COMPANIES)) { if (IsSavegameVersionBefore(SLV_MORE_COMPANIES)) {
c->bankrupt_asked = owner_from_int(c->old_bankrupt_asked); c->bankrupt_asked = ParseOldCompMask(c->old_bankrupt_asked);
} }
} }
} }

View File

@ -120,9 +120,9 @@ struct ENGNChunkHandler : ChunkHandler {
e->preview_asked = MAX_UVALUE(CompanyMask); e->preview_asked = MAX_UVALUE(CompanyMask);
} }
if (IsSavegameVersionBefore(SLV_MORE_COMPANIES)) { if (IsSavegameVersionBefore(SLV_MORE_COMPANIES)) {
e->preview_asked = owner_from_int(e->old_preview_asked); e->preview_asked = ParseOldCompMask(e->old_preview_asked);
e->company_avail = owner_from_int(e->old_company_avail); e->company_avail = ParseOldCompMask(e->old_company_avail);
e->company_hidden = owner_from_int(e->old_company_hidden); e->company_hidden = ParseOldCompMask(e->old_company_hidden);
} }
} }
} }

View File

@ -54,6 +54,9 @@ struct GRPSChunkHandler : ChunkHandler {
SlObject(g, slt); SlObject(g, slt);
if (IsSavegameVersionBefore(SLV_189)) g->parent = INVALID_GROUP; if (IsSavegameVersionBefore(SLV_189)) g->parent = INVALID_GROUP;
if (IsSavegameVersionBefore(SLV_MORE_COMPANIES)) {
g->owner = ParseOldOwner(g->owner);
}
} }
} }
}; };

View File

@ -9,6 +9,7 @@
#include "../stdafx.h" #include "../stdafx.h"
#include "company_type.h"
#include "saveload.h" #include "saveload.h"
#include "compat/industry_sl_compat.h" #include "compat/industry_sl_compat.h"
@ -265,6 +266,12 @@ struct INDYChunkHandler : ChunkHandler {
} else if (IsSavegameVersionBefore(SLV_INDUSTRY_CARGO_REORGANISE)) { } else if (IsSavegameVersionBefore(SLV_INDUSTRY_CARGO_REORGANISE)) {
LoadMoveAcceptsProduced(i, INDUSTRY_NUM_INPUTS, INDUSTRY_NUM_OUTPUTS); LoadMoveAcceptsProduced(i, INDUSTRY_NUM_INPUTS, INDUSTRY_NUM_OUTPUTS);
} }
if (IsSavegameVersionBefore(SLV_MORE_COMPANIES)) {
i->owner = ParseOldOwner(i-> owner);
i->founder = ParseOldOwner(i-> founder);
i->exclusive_supplier = ParseOldOwner(i-> exclusive_supplier);
i->exclusive_consumer = ParseOldOwner(i-> exclusive_consumer);
}
Industry::IncIndustryTypeCount(i->type); Industry::IncIndustryTypeCount(i->type);
} }
} }

View File

@ -17,6 +17,7 @@
#include "../fios.h" #include "../fios.h"
#include "../safeguards.h" #include "../safeguards.h"
#include <iostream>
static uint32_t _map_dim_x; static uint32_t _map_dim_x;
static uint32_t _map_dim_y; static uint32_t _map_dim_y;
@ -362,7 +363,7 @@ struct MAP9ChunkHandler : ChunkHandler {
for (TileIndex i = 0; i != size;) { for (TileIndex i = 0; i != size;) {
SlCopy(buf.data(), MAP_SL_BUF_SIZE, SLE_UINT32); SlCopy(buf.data(), MAP_SL_BUF_SIZE, SLE_UINT32);
for (uint j = 0; j != MAP_SL_BUF_SIZE; j++) Tile(i++).m8() = buf[j]; for (uint j = 0; j != MAP_SL_BUF_SIZE; j++) Tile(i++).m9() = buf[j];
} }
} }
@ -371,9 +372,10 @@ struct MAP9ChunkHandler : ChunkHandler {
std::array<uint32_t, MAP_SL_BUF_SIZE> buf; std::array<uint32_t, MAP_SL_BUF_SIZE> buf;
uint size = Map::Size(); uint size = Map::Size();
std::cout<< "loading m9" << std::endl;
SlSetLength(static_cast<uint32_t>(size) * sizeof(uint32_t)); SlSetLength(static_cast<uint32_t>(size) * sizeof(uint32_t));
for (TileIndex i = 0; i != size;) { for (TileIndex i = 0; i != size;) {
for (uint j = 0; j != MAP_SL_BUF_SIZE; j++) buf[j] = Tile(i++).m8(); for (uint j = 0; j != MAP_SL_BUF_SIZE; j++) buf[j] = Tile(i++).m9();
SlCopy(buf.data(), MAP_SL_BUF_SIZE, SLE_UINT32); SlCopy(buf.data(), MAP_SL_BUF_SIZE, SLE_UINT32);
} }
} }
@ -390,7 +392,7 @@ static const MAP5ChunkHandler MAP5;
static const MAPEChunkHandler MAPE; static const MAPEChunkHandler MAPE;
static const MAP7ChunkHandler MAP7; static const MAP7ChunkHandler MAP7;
static const MAP8ChunkHandler MAP8; static const MAP8ChunkHandler MAP8;
static const MAP8ChunkHandler MAP9; static const MAP9ChunkHandler MAP9;
static const ChunkHandlerRef map_chunk_handlers[] = { static const ChunkHandlerRef map_chunk_handlers[] = {
MAPS, MAPS,
MAPT, MAPT,

View File

@ -60,6 +60,7 @@
#include "saveload_filter.h" #include "saveload_filter.h"
#include "../safeguards.h" #include "../safeguards.h"
#include <iostream>
extern const SaveLoadVersion SAVEGAME_VERSION = (SaveLoadVersion)(SL_MAX_VERSION - 1); ///< Current savegame version of OpenTTD. extern const SaveLoadVersion SAVEGAME_VERSION = (SaveLoadVersion)(SL_MAX_VERSION - 1); ///< Current savegame version of OpenTTD.
@ -1096,6 +1097,7 @@ static void SlArray(void *array, size_t length, VarType conv)
/* If the SLE_ARR changes size, a savegame bump is required /* If the SLE_ARR changes size, a savegame bump is required
* and the developer should have written conversion lines. * and the developer should have written conversion lines.
* Error out to make this more visible. */ * Error out to make this more visible. */
std::cout << "Corrupted array!!" << std::endl;
SlErrorCorrupt("Fixed-length array is of wrong length"); SlErrorCorrupt("Fixed-length array is of wrong length");
} }
} }
@ -1132,7 +1134,7 @@ CompanyMask bitset_from_bytes(const std::vector<uint8_t>& buf) {
} }
CompanyMask owner_from_int(uint16_t old_owner) { CompanyMask ParseOldCompMask(uint16_t old_owner) {
CompanyMask result; CompanyMask result;
for (int i = 0; i < 16; i++) { for (int i = 0; i < 16; i++) {
result[i] = GB(old_owner, i, 1) & 1; result[i] = GB(old_owner, i, 1) & 1;
@ -1140,6 +1142,17 @@ CompanyMask owner_from_int(uint16_t old_owner) {
return result; return result;
} }
Owner ParseOldOwner(Owner old) {
if (old == OLD_OWNER_NONE) {
old = OWNER_NONE;
} else if (old == OLD_OWNER_TOWN){
old = OWNER_TOWN;
} else if (old == OLD_OWNER_WATER) {
old = OWNER_WATER;
}
return old;
}
/** /**
* Save/Load the length of the bitset followed by the array of SL_VAR bits. * Save/Load the length of the bitset followed by the array of SL_VAR bits.
@ -1625,6 +1638,7 @@ size_t SlCalcObjMemberLength(const void *object, const SaveLoad &sld)
static bool SlObjectMember(void *object, const SaveLoad &sld) static bool SlObjectMember(void *object, const SaveLoad &sld)
{ {
std::cout <<"Object: "<< sld.name << std::endl;
if (!SlIsObjectValidInSavegame(sld)) return false; if (!SlIsObjectValidInSavegame(sld)) return false;
VarType conv = GB(sld.conv, 0, 8); VarType conv = GB(sld.conv, 0, 8);

View File

@ -1314,7 +1314,8 @@ void SlCopy(void *object, size_t length, VarType conv);
std::vector<SaveLoad> SlTableHeader(const SaveLoadTable &slt); std::vector<SaveLoad> SlTableHeader(const SaveLoadTable &slt);
std::vector<SaveLoad> SlCompatTableHeader(const SaveLoadTable &slt, const SaveLoadCompatTable &slct); std::vector<SaveLoad> SlCompatTableHeader(const SaveLoadTable &slt, const SaveLoadCompatTable &slct);
void SlObject(void *object, const SaveLoadTable &slt); void SlObject(void *object, const SaveLoadTable &slt);
CompanyMask owner_from_int(uint16_t old_owner); CompanyMask ParseOldCompMask(uint16_t old_owner);
Owner ParseOldOwner(Owner old);
bool SaveloadCrashWithMissingNewGRFs(); bool SaveloadCrashWithMissingNewGRFs();

View File

@ -9,6 +9,7 @@
#include "../stdafx.h" #include "../stdafx.h"
#include "company_type.h"
#include "saveload.h" #include "saveload.h"
#include "compat/signs_sl_compat.h" #include "compat/signs_sl_compat.h"
@ -65,6 +66,9 @@ struct SIGNChunkHandler : ChunkHandler {
if (IsSavegameVersionBefore(SLV_171) && si->owner == OLD_OWNER_NONE && _file_to_saveload.abstract_ftype == FT_SCENARIO) { if (IsSavegameVersionBefore(SLV_171) && si->owner == OLD_OWNER_NONE && _file_to_saveload.abstract_ftype == FT_SCENARIO) {
si->owner = OWNER_DEITY; si->owner = OWNER_DEITY;
} }
if (IsSavegameVersionBefore(SLV_MORE_COMPANIES)) {
si->owner = ParseOldOwner(si->owner);
}
} }
} }
}; };

View File

@ -502,6 +502,9 @@ struct STNSChunkHandler : ChunkHandler {
_waiting_acceptance = 0; _waiting_acceptance = 0;
SlObject(st, slt); SlObject(st, slt);
if (IsSavegameVersionBefore(SLV_MORE_COMPANIES)) {
st->owner = ParseOldOwner(st->owner);
}
} }
} }

View File

@ -224,9 +224,12 @@ SLE_CONDVARNAME(Town, old_have_ratings, "have_ratings", SLE_FILE_U8 |
SLE_CONDVARNAME(Town, old_have_ratings, "have_ratings", SLE_UINT16, SLV_104, SLV_MORE_COMPANIES), SLE_CONDVARNAME(Town, old_have_ratings, "have_ratings", SLE_UINT16, SLV_104, SLV_MORE_COMPANIES),
SLE_CONDARR(Town, ratings, SLE_INT16, 8, SL_MIN_VERSION, SLV_104), SLE_CONDARR(Town, ratings, SLE_INT16, 8, SL_MIN_VERSION, SLV_104),
SLE_CONDARR(Town, ratings, SLE_INT16, MAX_COMPANIES, SLV_104, SL_MAX_VERSION), SLE_CONDARR(Town, ratings, SLE_INT16, 15, SLV_104, SLV_MORE_COMPANIES),
SLE_CONDARR(Town, ratings, SLE_INT16, MAX_COMPANIES, SLV_MORE_COMPANIES, SL_MAX_VERSION),
SLE_CONDARR(Town, unwanted, SLE_INT8, 8, SLV_4, SLV_104), SLE_CONDARR(Town, unwanted, SLE_INT8, 8, SLV_4, SLV_104),
SLE_CONDARR(Town, unwanted, SLE_INT8, MAX_COMPANIES, SLV_104, SL_MAX_VERSION), SLE_CONDARR(Town, unwanted, SLE_INT8, 15, SLV_104, SLV_MORE_COMPANIES),
SLE_CONDARR(Town, unwanted, SLE_INT8, MAX_COMPANIES, SLV_MORE_COMPANIES, SL_MAX_VERSION),
/* Slots 0 and 2 are passengers and mail respectively for old saves. */ /* Slots 0 and 2 are passengers and mail respectively for old saves. */
SLE_CONDVARNAME(Town, supplied[0].old_max, "supplied[CT_PASSENGERS].old_max", SLE_FILE_U16 | SLE_VAR_U32, SL_MIN_VERSION, SLV_9), SLE_CONDVARNAME(Town, supplied[0].old_max, "supplied[CT_PASSENGERS].old_max", SLE_FILE_U16 | SLE_VAR_U32, SL_MIN_VERSION, SLV_9),
@ -310,8 +313,8 @@ struct CITYChunkHandler : ChunkHandler {
SlErrorCorrupt("Invalid town name generator"); SlErrorCorrupt("Invalid town name generator");
} }
if (IsSavegameVersionBefore(SLV_MORE_COMPANIES)) { if (IsSavegameVersionBefore(SLV_MORE_COMPANIES)) {
t->statues = owner_from_int(t->old_statues); t->statues = ParseOldCompMask(t->old_statues);
t->have_ratings = owner_from_int(t->old_have_ratings); t->have_ratings = ParseOldCompMask(t->old_have_ratings);
} }
} }
} }

View File

@ -405,6 +405,11 @@ void AfterLoadVehicles(bool part_of_load)
v->economy_age = v->age.base(); v->economy_age = v->age.base();
} }
} }
if (IsSavegameVersionBefore(SLV_MORE_COMPANIES)) {
for (Vehicle *v : Vehicle::Iterate()) {
v->owner = ParseOldOwner(v->owner);
}
}
} }
CheckValidVehicles(); CheckValidVehicles();

View File

@ -16,6 +16,7 @@
#include "../newgrf.h" #include "../newgrf.h"
#include "../timer/timer_game_calendar.h" #include "../timer/timer_game_calendar.h"
#include "saveload/saveload.h"
#include "table/strings.h" #include "table/strings.h"
#include "saveload_internal.h" #include "saveload_internal.h"
@ -200,6 +201,9 @@ struct CHKPChunkHandler : ChunkHandler {
wp->index = index; wp->index = index;
SlObject(wp, _old_waypoint_desc); SlObject(wp, _old_waypoint_desc);
if (IsSavegameVersionBefore(SLV_MORE_COMPANIES)) {
wp->owner = ParseOldOwner(wp->owner);
}
} }
} }