diff options
author | rubidium <rubidium@openttd.org> | 2010-07-31 09:36:09 +0000 |
---|---|---|
committer | rubidium <rubidium@openttd.org> | 2010-07-31 09:36:09 +0000 |
commit | f7794e313f993bbb8394bfc6c27f6cd00fc534a0 (patch) | |
tree | b47ce8754e0390f5b2769210ded01d440674d79d /src/newgrf_config.cpp | |
parent | 75c4a2d2fb4c400eb2eef6e1e1fa1bf3573c5be0 (diff) | |
download | openttd-f7794e313f993bbb8394bfc6c27f6cd00fc534a0.tar.xz |
(svn r20252) -Codechange: deduplicate logic for setting a suitable (initial) palette for NewGRFs
Diffstat (limited to 'src/newgrf_config.cpp')
-rw-r--r-- | src/newgrf_config.cpp | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/src/newgrf_config.cpp b/src/newgrf_config.cpp index d7769a394..9ce1962ce 100644 --- a/src/newgrf_config.cpp +++ b/src/newgrf_config.cpp @@ -85,6 +85,16 @@ const char *GRFConfig::GetDescription() const return GetGRFStringFromGRFText(this->info); } +/** + * Set the palette of this GRFConfig to something suitable. + * That is either the setting coming from the NewGRF or + * the globally used palette. + */ +void GRFConfig::SetSuitablePalette() +{ + this->windows_paletted = (_use_palette == PAL_WINDOWS); +} + GRFConfig *_all_grfs; GRFConfig *_grfconfig; GRFConfig *_grfconfig_newgame; @@ -133,8 +143,8 @@ GRFError::~GRFError() */ void UpdateNewGRFConfigPalette() { - for (GRFConfig *c = _grfconfig_newgame; c != NULL; c = c->next) c->windows_paletted = (_use_palette == PAL_WINDOWS); - for (GRFConfig *c = _grfconfig_static; c != NULL; c = c->next) c->windows_paletted = (_use_palette == PAL_WINDOWS); + for (GRFConfig *c = _grfconfig_newgame; c != NULL; c = c->next) c->SetSuitablePalette(); + for (GRFConfig *c = _grfconfig_static; c != NULL; c = c->next) c->SetSuitablePalette(); } /** Calculate the MD5 sum for a GRF, and store it in the config. @@ -191,7 +201,7 @@ bool FillGRFDetails(GRFConfig *config, bool is_static) if (HasBit(config->flags, GCF_UNSAFE)) return false; } - config->windows_paletted = (_use_palette == PAL_WINDOWS); + config->SetSuitablePalette(); return CalcGRFMD5Sum(config); } |