Merge branch 'openttd'
This commit is contained in:
@@ -547,11 +547,11 @@ static void StartScripts()
|
||||
|
||||
/* Start the AIs. */
|
||||
for (const Company *c : Company::Iterate()) {
|
||||
if (Company::IsValidAiID(c->index)) AI::StartNew(c->index, false);
|
||||
if (Company::IsValidAiID(c->index)) AI::StartNew(c->index);
|
||||
}
|
||||
|
||||
/* Start the GameScript. */
|
||||
Game::StartNew(false);
|
||||
Game::StartNew();
|
||||
|
||||
ShowScriptDebugWindowIfScriptError();
|
||||
}
|
||||
@@ -1771,6 +1771,11 @@ bool AfterLoadGame()
|
||||
if (!order->IsType(OT_GOTO_DEPOT)) continue;
|
||||
order->SetDepotActionType((OrderDepotActionFlags)(order->GetDepotActionType() >> 1));
|
||||
}
|
||||
|
||||
for (Vehicle *v : Vehicle::Iterate()) {
|
||||
if (!v->current_order.IsType(OT_GOTO_DEPOT)) continue;
|
||||
v->current_order.SetDepotActionType((OrderDepotActionFlags)(v->current_order.GetDepotActionType() >> 1));
|
||||
}
|
||||
}
|
||||
|
||||
/* The water class was moved/unified. */
|
||||
|
||||
@@ -258,9 +258,9 @@ const SaveLoadCompat _settings_sl_compat[] = {
|
||||
SLC_VAR("locale.units_volume"),
|
||||
SLC_VAR("locale.units_force"),
|
||||
SLC_VAR("locale.units_height"),
|
||||
SLC_NULL_STR(1, SLV_118, SLV_TABLE_CHUNKS),
|
||||
SLC_NULL_STR(1, SLV_118, SLV_TABLE_CHUNKS),
|
||||
SLC_NULL_STR(1, SLV_126, SLV_TABLE_CHUNKS),
|
||||
SLC_VAR("locale.digit_group_separator"),
|
||||
SLC_VAR("locale.digit_group_separator_currency"),
|
||||
SLC_VAR("locale.digit_decimal_separator"),
|
||||
};
|
||||
|
||||
#endif /* SAVELOAD_COMPAT_SETTINGS_H */
|
||||
|
||||
@@ -29,7 +29,6 @@
|
||||
extern TileIndex _cur_tileloop_tile;
|
||||
extern uint16_t _disaster_delay;
|
||||
extern byte _trees_tick_ctr;
|
||||
extern std::string _savegame_id;
|
||||
|
||||
/* Keep track of current game position */
|
||||
int _saved_scrollpos_x;
|
||||
@@ -98,7 +97,7 @@ static const SaveLoad _date_desc[] = {
|
||||
SLEG_VAR("company_tick_counter", _cur_company_tick_index, SLE_FILE_U8 | SLE_VAR_U32),
|
||||
SLEG_VAR("trees_tick_counter", _trees_tick_ctr, SLE_UINT8),
|
||||
SLEG_CONDVAR("pause_mode", _pause_mode, SLE_UINT8, SLV_4, SL_MAX_VERSION),
|
||||
SLEG_CONDSSTR("id", _savegame_id, SLE_STR, SLV_SAVEGAME_ID, SL_MAX_VERSION),
|
||||
SLEG_CONDSSTR("id", _game_session_stats.savegame_id, SLE_STR, SLV_SAVEGAME_ID, SL_MAX_VERSION),
|
||||
/* For older savegames, we load the current value as the "period"; afterload will set the "fired" and "elapsed". */
|
||||
SLEG_CONDVAR("next_competitor_start", _new_competitor_timeout.period, SLE_FILE_U16 | SLE_VAR_U32, SL_MIN_VERSION, SLV_109),
|
||||
SLEG_CONDVAR("next_competitor_start", _new_competitor_timeout.period, SLE_UINT32, SLV_109, SLV_AI_START_DATE),
|
||||
|
||||
@@ -2183,7 +2183,10 @@ struct FileReader : LoadFilter {
|
||||
/** Make sure everything is cleaned up. */
|
||||
~FileReader()
|
||||
{
|
||||
if (this->file != nullptr) fclose(this->file);
|
||||
if (this->file != nullptr) {
|
||||
_game_session_stats.savegame_size = ftell(this->file) - this->begin;
|
||||
fclose(this->file);
|
||||
}
|
||||
this->file = nullptr;
|
||||
}
|
||||
|
||||
@@ -2232,7 +2235,10 @@ struct FileWriter : SaveFilter {
|
||||
|
||||
void Finish() override
|
||||
{
|
||||
if (this->file != nullptr) fclose(this->file);
|
||||
if (this->file != nullptr) {
|
||||
_game_session_stats.savegame_size = ftell(this->file);
|
||||
fclose(this->file);
|
||||
}
|
||||
this->file = nullptr;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -377,7 +377,8 @@ enum SaveLoadVersion : uint16_t {
|
||||
SLV_MAX_LOAN_FOR_COMPANY, ///< 330 PR#11224 Separate max loan for each company.
|
||||
SLV_DEPOT_UNBUNCHING, ///< 331 PR#11945 Allow unbunching shared order vehicles at a depot.
|
||||
SLV_AI_LOCAL_CONFIG, ///< 332 PR#12003 Config of running AI is stored inside Company.
|
||||
SLV_SCRIPT_RANDOMIZER, ///< 333 PR#12063 Save script randomizers.
|
||||
SLV_SCRIPT_RANDOMIZER, ///< 333 PR#12063 v14.0-RC1 Save script randomizers.
|
||||
SLV_VEHICLE_ECONOMY_AGE, ///< 334 PR#12141 v14.0 Add vehicle age in economy year, for profit stats minimum age
|
||||
|
||||
SL_MAX_VERSION, ///< Highest possible saveload version
|
||||
};
|
||||
|
||||
@@ -188,10 +188,20 @@ struct PATSChunkHandler : ChunkHandler {
|
||||
|
||||
void Load() const override
|
||||
{
|
||||
/* Copy over default setting since some might not get loaded in
|
||||
* a networking environment. This ensures for example that the local
|
||||
* currency setting stays when joining a network-server */
|
||||
LoadSettings(this->GetSettingTable(), &_settings_game, _settings_sl_compat);
|
||||
const auto settings_table = this->GetSettingTable();
|
||||
|
||||
/* Reset all settings to their default, so any settings missing in the savegame
|
||||
* are their default, and not "value of last game". AfterLoad might still fix
|
||||
* up values to become non-default, depending on the saveload version. */
|
||||
for (auto &desc : settings_table) {
|
||||
const SettingDesc *sd = GetSettingDesc(desc);
|
||||
if (sd->flags & SF_NOT_IN_SAVE) continue;
|
||||
if ((sd->flags & SF_NO_NETWORK_SYNC) && _networking && !_network_server) continue;
|
||||
|
||||
sd->ResetToDefault(&_settings_game);
|
||||
}
|
||||
|
||||
LoadSettings(settings_table, &_settings_game, _settings_sl_compat);
|
||||
}
|
||||
|
||||
void LoadCheck(size_t) const override
|
||||
|
||||
@@ -398,6 +398,13 @@ void AfterLoadVehicles(bool part_of_load)
|
||||
v->timetable_start = GetStartTickFromDate(v->timetable_start);
|
||||
}
|
||||
}
|
||||
|
||||
if (IsSavegameVersionBefore(SLV_VEHICLE_ECONOMY_AGE)) {
|
||||
/* Set vehicle economy age based on calendar age. */
|
||||
for (Vehicle *v : Vehicle::Iterate()) {
|
||||
v->economy_age = v->age.base();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
CheckValidVehicles();
|
||||
@@ -517,6 +524,10 @@ void AfterLoadVehicles(bool part_of_load)
|
||||
default: break;
|
||||
}
|
||||
|
||||
if (part_of_load && v->unitnumber != 0) {
|
||||
Company::Get(v->owner)->freeunits[v->type].UseID(v->unitnumber);
|
||||
}
|
||||
|
||||
v->UpdateDeltaXY();
|
||||
v->coord.left = INVALID_COORD;
|
||||
v->sprite_cache.old_coord.left = INVALID_COORD;
|
||||
@@ -714,6 +725,7 @@ public:
|
||||
|
||||
SLE_CONDVAR(Vehicle, age, SLE_FILE_U16 | SLE_VAR_I32, SL_MIN_VERSION, SLV_31),
|
||||
SLE_CONDVAR(Vehicle, age, SLE_INT32, SLV_31, SL_MAX_VERSION),
|
||||
SLE_CONDVAR(Vehicle, economy_age, SLE_INT32, SLV_VEHICLE_ECONOMY_AGE, SL_MAX_VERSION),
|
||||
SLE_CONDVAR(Vehicle, max_age, SLE_FILE_U16 | SLE_VAR_I32, SL_MIN_VERSION, SLV_31),
|
||||
SLE_CONDVAR(Vehicle, max_age, SLE_INT32, SLV_31, SL_MAX_VERSION),
|
||||
SLE_CONDVAR(Vehicle, date_of_last_service, SLE_FILE_U16 | SLE_VAR_I32, SL_MIN_VERSION, SLV_31),
|
||||
|
||||
Reference in New Issue
Block a user