(svn r27763) -Update from Eints:
[openttd.git] / src / game / game_config.cpp
blob50cd5da4e0d38deca66e2dc730f8c3f0e2967653
1 /* $Id$ */
3 /*
4 * This file is part of OpenTTD.
5 * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
6 * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
7 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
8 */
10 /** @file game_config.cpp Implementation of GameConfig. */
12 #include "../stdafx.h"
13 #include "../settings_type.h"
14 #include "game.hpp"
15 #include "game_config.hpp"
16 #include "game_info.hpp"
18 #include "../safeguards.h"
20 /* static */ GameConfig *GameConfig::GetConfig(ScriptSettingSource source)
22 GameConfig **config;
23 if (source == SSS_FORCE_NEWGAME || (source == SSS_DEFAULT && _game_mode == GM_MENU)) {
24 config = &_settings_newgame.game_config;
25 } else {
26 config = &_settings_game.game_config;
28 if (*config == NULL) *config = new GameConfig();
29 return *config;
32 class GameInfo *GameConfig::GetInfo() const
34 return static_cast<class GameInfo *>(ScriptConfig::GetInfo());
37 ScriptInfo *GameConfig::FindInfo(const char *name, int version, bool force_exact_match)
39 return static_cast<ScriptInfo *>(Game::FindInfo(name, version, force_exact_match));
42 bool GameConfig::ResetInfo(bool force_exact_match)
44 this->info = (ScriptInfo *)Game::FindInfo(this->name, force_exact_match ? this->version : -1, force_exact_match);
45 return this->info != NULL;