From a00371c8db9d3b944d901ea0468eb58fe51418a7 Mon Sep 17 00:00:00 2001 From: peter1138 Date: Tue, 29 Apr 2008 21:31:29 +0000 Subject: (svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist. --- src/openttd.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src/openttd.cpp') diff --git a/src/openttd.cpp b/src/openttd.cpp index 402d6276b..be999af16 100644 --- a/src/openttd.cpp +++ b/src/openttd.cpp @@ -305,6 +305,7 @@ static void UnInitializeGame() _Order_pool.CleanPool(); _Group_pool.CleanPool(); _CargoPacket_pool.CleanPool(); + _Engine_pool.CleanPool(); free((void*)_town_sort); free((void*)_industry_sort); @@ -1332,6 +1333,8 @@ static bool InitializeWindowsAndCaches() /* Recalculate */ Group *g; FOR_ALL_GROUPS(g) { + g->num_engines = CallocT(GetEnginePoolSize()); + const Vehicle *v; FOR_ALL_VEHICLES(v) { if (!IsEngineCountable(v)) continue; @@ -1354,6 +1357,9 @@ static bool InitializeWindowsAndCaches() * thus the MIN_YEAR (which is really nothing more than Zero, initialized value) test */ if (_file_to_saveload.filetype == FT_SCENARIO && players[i]->inaugurated_year != MIN_YEAR) players[i]->inaugurated_year = _cur_year; + + free(players[i]->num_engines); + players[i]->num_engines = CallocT(GetEnginePoolSize()); } FOR_ALL_VEHICLES(v) { @@ -1444,10 +1450,16 @@ bool AfterLoadGame() * must be done before loading sprites as some newgrfs check it */ SetDate(_date); + /* Force dynamic engines off when loading older savegames */ + if (CheckSavegameVersion(95)) _patches.dynamic_engines = 0; + /* Load the sprites */ GfxLoadSprites(); LoadStringWidthTable(); + /* Copy temporary data to Engine pool */ + CopyTempEngineData(); + /* Connect front and rear engines of multiheaded trains and converts * subtype to the new format */ if (CheckSavegameVersionOldStyle(17, 1)) ConvertOldMultiheadToNew(); -- cgit v1.2.3-54-g00ecf