diff --git a/src/economy.cpp b/src/economy.cpp index b26fd2eb9d..48a9148951 100644 --- a/src/economy.cpp +++ b/src/economy.cpp @@ -2011,7 +2011,7 @@ static const SaveLoad _economy_desc[] = { SLE_CONDVAR(Economy, max_loan_unround, SLE_FILE_I32 | SLE_VAR_I64, 0, 64), SLE_CONDVAR(Economy, max_loan_unround, SLE_INT64, 65, SL_MAX_VERSION), SLE_CONDVAR(Economy, max_loan_unround_fract, SLE_UINT16, 70, SL_MAX_VERSION), - SLE_VAR(Economy, fluct, SLE_FILE_I16 | SLE_VAR_I32), + SLE_VAR(Economy, fluct, SLE_INT16), SLE_VAR(Economy, interest_rate, SLE_UINT8), SLE_VAR(Economy, infl_amount, SLE_UINT8), SLE_VAR(Economy, infl_amount_pr, SLE_UINT8), diff --git a/src/economy_type.h b/src/economy_type.h index 02b515ce43..1635e208b1 100644 --- a/src/economy_type.h +++ b/src/economy_type.h @@ -15,7 +15,7 @@ struct Economy { Money max_loan; ///< Maximum possible loan Money max_loan_unround; ///< Economy fluctuation status uint16 max_loan_unround_fract; ///< Fraction of the unrounded max loan - int fluct; + int16 fluct; byte interest_rate; ///< Interest byte infl_amount; ///< inflation amount byte infl_amount_pr; ///< "floating" portion of inflation diff --git a/src/elrail.cpp b/src/elrail.cpp index 7dd9eab0c6..f282be1f2c 100644 --- a/src/elrail.cpp +++ b/src/elrail.cpp @@ -502,10 +502,13 @@ int32 SettingsDisableElrail(int32 p1) } } - /* setup total power for trains */ + /* Fix the total power and acceleration for trains */ FOR_ALL_VEHICLES(v) { - /* power is cached only for front engines */ - if (v->type == VEH_TRAIN && IsFrontEngine(v)) TrainPowerChanged(v); + /* power and acceleration is cached only for front engines */ + if (v->type == VEH_TRAIN && IsFrontEngine(v)) { + TrainPowerChanged(v); + UpdateTrainAcceleration(v); + } } FOR_ALL_PLAYERS(p) p->avail_railtypes = GetPlayerRailtypes(p->index); diff --git a/src/oldloader.cpp b/src/oldloader.cpp index 8a7aa156dc..1facd54c4e 100644 --- a/src/oldloader.cpp +++ b/src/oldloader.cpp @@ -993,9 +993,13 @@ static bool LoadOldPlayer(LoadgameState *ls, int num) if (!LoadChunk(ls, p, player_chunk)) return false; + if (_old_string_id == 0) { + p->is_active = false; + return true; + } + p->name_1 = RemapOldStringID(_old_string_id); p->president_name_1 = RemapOldStringID(_old_string_id_2); - p->player_money = p->player_money; _players_ai[_current_player_id].tick = ai_tick; if (num == 0) { @@ -1540,7 +1544,7 @@ static const OldChunks main_chunk[] = { OCL_VAR ( OC_FILE_U32 | OC_VAR_I64, 1, &_economy.max_loan ), OCL_VAR ( OC_FILE_U32 | OC_VAR_I64, 1, &_economy.max_loan_unround ), - OCL_VAR ( OC_FILE_U16 | OC_VAR_U32, 1, &_economy.fluct ), + OCL_VAR ( OC_INT16, 1, &_economy.fluct ), OCL_VAR ( OC_UINT16, 1, &_disaster_delay ), diff --git a/src/openttd.cpp b/src/openttd.cpp index 845baf561f..3083893269 100644 --- a/src/openttd.cpp +++ b/src/openttd.cpp @@ -687,6 +687,8 @@ static void ShowScreenshotResult(bool b) static void MakeNewGameDone() { + SettingsDisableElrail(_patches.disable_elrails); + /* In a dedicated server, the server does not play */ if (_network_dedicated) { SetLocalPlayer(PLAYER_SPECTATOR); @@ -700,7 +702,6 @@ static void MakeNewGameDone() _current_player = _local_player; DoCommandP(0, (_patches.autorenew << 15 ) | (_patches.autorenew_months << 16) | 4, _patches.autorenew_money, NULL, CMD_SET_AUTOREPLACE); - SettingsDisableElrail(_patches.disable_elrails); SetDefaultRailGui(); #ifdef ENABLE_NETWORK diff --git a/src/players.cpp b/src/players.cpp index 6a7b935a8f..8b84c51149 100644 --- a/src/players.cpp +++ b/src/players.cpp @@ -1243,8 +1243,11 @@ static void Load_PLYR() _player_colors[index] = p->player_color; /* This is needed so an AI is attached to a loaded AI */ - if (p->is_ai && (!_networking || _network_server) && _ai.enabled) + if (p->is_ai && (!_networking || _network_server) && _ai.enabled) { + /* Clear the memory of the new AI, otherwise we might be doing wrong things. */ + memset(&_players_ainew[index], 0, sizeof(PlayerAiNew)); AI_StartNewAI(p->index); + } } } diff --git a/src/saveload.cpp b/src/saveload.cpp index 3634c82245..6b0c82dae7 100644 --- a/src/saveload.cpp +++ b/src/saveload.cpp @@ -620,10 +620,18 @@ void SlArray(void *array, uint length, VarType conv) /* NOTICE - handle some buggy stuff, in really old versions everything was saved * as a byte-type. So detect this, and adjust array size accordingly */ if (!_sl.save && _sl_version == 0) { + /* all arrays except difficulty settings */ if (conv == SLE_INT16 || conv == SLE_UINT16 || conv == SLE_STRINGID || conv == SLE_INT32 || conv == SLE_UINT32) { - length *= SlCalcConvFileLen(conv); - conv = SLE_INT8; + SlCopyBytes(array, length * SlCalcConvFileLen(conv)); + return; + } + /* used for conversion of Money 32bit->64bit */ + if (conv == (SLE_FILE_I32 | SLE_VAR_I64)) { + for (uint i = 0; i < length; i++) { + ((int64*)array)[i] = (int32)BSWAP32(SlReadUint32()); + } + return; } }