Fixes incorrect link graph edge travel times with non-unity day length

Change vehicle last_loading_tick to be relative to _scaled_tick_counter
This commit is contained in:
Jonathan G Rennison
2022-12-11 00:06:09 +00:00
parent f4d775cad3
commit 5c2d5782a4
7 changed files with 27 additions and 8 deletions

View File

@@ -3817,7 +3817,11 @@ bool AfterLoadGame()
/* Use current order time to approximate last loading time */
if (IsSavegameVersionBefore(SLV_LAST_LOADING_TICK) && SlXvIsFeatureMissing(XSLFI_LAST_LOADING_TICK)) {
for (Vehicle *v : Vehicle::Iterate()) {
v->last_loading_tick = std::max(_tick_counter, static_cast<uint64>(v->current_order_time)) - v->current_order_time;
v->last_loading_tick = std::max(_scaled_tick_counter, static_cast<uint64>(v->current_order_time)) - v->current_order_time;
}
} else if (SlXvIsFeaturePresent(XSLFI_LAST_LOADING_TICK, 1, 1)) {
for (Vehicle *v : Vehicle::Iterate()) {
v->last_loading_tick *= _settings_game.economy.day_length_factor;
}
}

View File

@@ -180,7 +180,7 @@ const SlxiSubChunkInfo _sl_xv_sub_chunk_infos[] = {
{ XSLFI_SCRIPT_INT64, XSCF_NULL, 1, 1, "script_int64", nullptr, nullptr, nullptr },
{ XSLFI_U64_TICK_COUNTER, XSCF_NULL, 1, 1, "u64_tick_counter", nullptr, nullptr, nullptr },
{ XSLFI_LINKGRAPH_TRAVEL_TIME, XSCF_NULL, 1, 1, "linkgraph_travel_time", nullptr, nullptr, nullptr },
{ XSLFI_LAST_LOADING_TICK, XSCF_NULL, 1, 1, "last_loading_tick", nullptr, nullptr, nullptr },
{ XSLFI_LAST_LOADING_TICK, XSCF_NULL, 2, 2, "last_loading_tick", nullptr, nullptr, nullptr },
{ XSLFI_SCRIPT_LEAGUE_TABLES, XSCF_NULL, 1, 1, "script_league_tables", nullptr, nullptr, "LEAE,LEAT" },
{ XSLFI_NULL, XSCF_NULL, 0, 0, nullptr, nullptr, nullptr, nullptr },// This is the end marker
};