summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorEddi-z <43699911+Eddi-z@users.noreply.github.com>2019-03-02 22:28:22 +0100
committerPeterN <peter@fuzzle.org>2019-03-02 21:28:22 +0000
commit8139b14e9c941433bce74e46a7330123cae4ae2b (patch)
treea5a79e214b04a72afbddfc764382d83020cd63a5 /src
parent5e403385431babbc7b3b976fb140fe990786c378 (diff)
downloadopenttd-8139b14e9c941433bce74e46a7330123cae4ae2b.tar.xz
Change: Synchronize introduction date and reliability randomness across vehicles with the same base introduction date (#7147)
Diffstat (limited to 'src')
-rw-r--r--src/engine.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/engine.cpp b/src/engine.cpp
index 9f500e1cd..d539a4852 100644
--- a/src/engine.cpp
+++ b/src/engine.cpp
@@ -652,7 +652,14 @@ void StartupOneEngine(Engine *e, Date aging_date)
/* Don't randomise the start-date in the first two years after gamestart to ensure availability
* of engines in early starting games.
* Note: TTDP uses fixed 1922 */
+ SavedRandomSeeds saved_seeds;
+ SaveRandomSeeds(&saved_seeds);
+ SetRandomSeed(_settings_game.game_creation.generation_seed ^
+ ei->base_intro ^
+ e->type ^
+ e->GetGRFID());
uint32 r = Random();
+
e->intro_date = ei->base_intro <= ConvertYMDToDate(_settings_game.game_creation.starting_year + 2, 0, 1) ? ei->base_intro : (Date)GB(r, 0, 9) + ei->base_intro;
if (e->intro_date <= _date) {
e->age = (aging_date - e->intro_date) >> 5;
@@ -672,6 +679,7 @@ void StartupOneEngine(Engine *e, Date aging_date)
e->reliability_spd_dec = ei->decay_speed << 2;
+ RestoreRandomSeeds(saved_seeds);
CalcEngineReliability(e);
/* prevent certain engines from ever appearing. */