mirror of https://github.com/OpenTTD/OpenTTD
(svn r22693) -Fix [FS#4691]: The override managers were not reset in some cases like creating a new scenario.
parent
793ec45a73
commit
c9e920f1eb
|
@ -14,6 +14,7 @@
|
||||||
#include "news_func.h"
|
#include "news_func.h"
|
||||||
#include "ai/ai.hpp"
|
#include "ai/ai.hpp"
|
||||||
#include "ai/ai_gui.hpp"
|
#include "ai/ai_gui.hpp"
|
||||||
|
#include "newgrf.h"
|
||||||
#include "newgrf_house.h"
|
#include "newgrf_house.h"
|
||||||
#include "group.h"
|
#include "group.h"
|
||||||
#include "economy_func.h"
|
#include "economy_func.h"
|
||||||
|
@ -70,6 +71,8 @@ void InitializeGame(uint size_x, uint size_y, bool reset_date, bool reset_settin
|
||||||
|
|
||||||
PoolBase::Clean(PT_NORMAL);
|
PoolBase::Clean(PT_NORMAL);
|
||||||
|
|
||||||
|
ResetPersistentNewGRFData();
|
||||||
|
|
||||||
InitializeSound();
|
InitializeSound();
|
||||||
InitializeMusic();
|
InitializeMusic();
|
||||||
|
|
||||||
|
|
|
@ -7432,6 +7432,20 @@ void ResetNewGRFData()
|
||||||
_spritegroup_pool.CleanPool();
|
_spritegroup_pool.CleanPool();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reset NewGRF data which is stored persistently in savegames.
|
||||||
|
*/
|
||||||
|
void ResetPersistentNewGRFData()
|
||||||
|
{
|
||||||
|
/* Reset override managers */
|
||||||
|
_engine_mngr.ResetToDefaultMapping();
|
||||||
|
_house_mngr.ResetMapping();
|
||||||
|
_industry_mngr.ResetMapping();
|
||||||
|
_industile_mngr.ResetMapping();
|
||||||
|
_airport_mngr.ResetMapping();
|
||||||
|
_airporttile_mngr.ResetMapping();
|
||||||
|
}
|
||||||
|
|
||||||
static void BuildCargoTranslationMap()
|
static void BuildCargoTranslationMap()
|
||||||
{
|
{
|
||||||
memset(_cur_grffile->cargo_map, 0xFF, sizeof(_cur_grffile->cargo_map));
|
memset(_cur_grffile->cargo_map, 0xFF, sizeof(_cur_grffile->cargo_map));
|
||||||
|
|
|
@ -162,6 +162,7 @@ void LoadNewGRFFile(struct GRFConfig *config, uint file_index, GrfLoadingStage s
|
||||||
void LoadNewGRF(uint load_index, uint file_index);
|
void LoadNewGRF(uint load_index, uint file_index);
|
||||||
void ReloadNewGRFData(); // in saveload/afterload.cpp
|
void ReloadNewGRFData(); // in saveload/afterload.cpp
|
||||||
void ResetNewGRFData();
|
void ResetNewGRFData();
|
||||||
|
void ResetPersistentNewGRFData();
|
||||||
|
|
||||||
void CDECL grfmsg(int severity, const char *str, ...) WARN_FORMAT(2, 3);
|
void CDECL grfmsg(int severity, const char *str, ...) WARN_FORMAT(2, 3);
|
||||||
|
|
||||||
|
|
|
@ -231,17 +231,6 @@ static void ParseResolution(Dimension *res, const char *s)
|
||||||
res->height = max(strtoul(t + 1, NULL, 0), 64UL);
|
res->height = max(strtoul(t + 1, NULL, 0), 64UL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void InitializeDynamicVariables()
|
|
||||||
{
|
|
||||||
/* Dynamic stuff needs to be initialized somewhere... */
|
|
||||||
_engine_mngr.ResetToDefaultMapping();
|
|
||||||
_house_mngr.ResetMapping();
|
|
||||||
_industry_mngr.ResetMapping();
|
|
||||||
_industile_mngr.ResetMapping();
|
|
||||||
_airport_mngr.ResetMapping();
|
|
||||||
_airporttile_mngr.ResetMapping();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Unitializes drivers, frees allocated memory, cleans pools, ...
|
* Unitializes drivers, frees allocated memory, cleans pools, ...
|
||||||
|
@ -553,9 +542,6 @@ int ttd_main(int argc, char *argv[])
|
||||||
/* initialize screenshot formats */
|
/* initialize screenshot formats */
|
||||||
InitializeScreenshotFormats();
|
InitializeScreenshotFormats();
|
||||||
|
|
||||||
/* initialize all variables that are allocated dynamically */
|
|
||||||
InitializeDynamicVariables();
|
|
||||||
|
|
||||||
/* Initialize FreeType */
|
/* Initialize FreeType */
|
||||||
InitFreeType();
|
InitFreeType();
|
||||||
|
|
||||||
|
@ -780,7 +766,6 @@ static void MakeNewGame(bool from_heightmap, bool reset_settings)
|
||||||
_game_mode = GM_NORMAL;
|
_game_mode = GM_NORMAL;
|
||||||
|
|
||||||
ResetGRFConfig(true);
|
ResetGRFConfig(true);
|
||||||
InitializeDynamicVariables();
|
|
||||||
|
|
||||||
GenerateWorldSetCallback(&MakeNewGameDone);
|
GenerateWorldSetCallback(&MakeNewGameDone);
|
||||||
GenerateWorld(from_heightmap ? GWM_HEIGHTMAP : GWM_NEWGAME, 1 << _settings_game.game_creation.map_x, 1 << _settings_game.game_creation.map_y, reset_settings);
|
GenerateWorld(from_heightmap ? GWM_HEIGHTMAP : GWM_NEWGAME, 1 << _settings_game.game_creation.map_x, 1 << _settings_game.game_creation.map_y, reset_settings);
|
||||||
|
|
|
@ -2557,8 +2557,6 @@ static SaveOrLoadResult DoLoad(LoadFilter *reader, bool load_check)
|
||||||
_next_offs = 0;
|
_next_offs = 0;
|
||||||
|
|
||||||
if (!load_check) {
|
if (!load_check) {
|
||||||
_engine_mngr.ResetToDefaultMapping();
|
|
||||||
|
|
||||||
/* Old maps were hardcoded to 256x256 and thus did not contain
|
/* Old maps were hardcoded to 256x256 and thus did not contain
|
||||||
* any mapsize information. Pre-initialize to 256x256 to not to
|
* any mapsize information. Pre-initialize to 256x256 to not to
|
||||||
* confuse old games */
|
* confuse old games */
|
||||||
|
@ -2662,7 +2660,6 @@ SaveOrLoadResult SaveOrLoad(const char *filename, int mode, Subdirectory sb, boo
|
||||||
|
|
||||||
/* Load a TTDLX or TTDPatch game */
|
/* Load a TTDLX or TTDPatch game */
|
||||||
if (mode == SL_OLD_LOAD) {
|
if (mode == SL_OLD_LOAD) {
|
||||||
_engine_mngr.ResetToDefaultMapping();
|
|
||||||
InitializeGame(256, 256, true, true); // set a mapsize of 256x256 for TTDPatch games or it might get confused
|
InitializeGame(256, 256, true, true); // set a mapsize of 256x256 for TTDPatch games or it might get confused
|
||||||
|
|
||||||
/* TTD/TTO savegames have no NewGRFs, TTDP savegame have them
|
/* TTD/TTO savegames have no NewGRFs, TTDP savegame have them
|
||||||
|
|
Loading…
Reference in New Issue