game_config.cpp

Go to the documentation of this file.
00001 /* $Id$ */
00002 
00003 /*
00004  * This file is part of OpenTTD.
00005  * 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.
00006  * 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.
00007  * 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/>.
00008  */
00009 
00012 #include "../stdafx.h"
00013 #include "../settings_type.h"
00014 #include "../core/random_func.hpp"
00015 #include "game.hpp"
00016 #include "game_config.hpp"
00017 #include "game_info.hpp"
00018 
00019 /* static */ GameConfig *GameConfig::GetConfig(ScriptSettingSource source)
00020 {
00021   GameConfig **config;
00022   if (source == SSS_FORCE_NEWGAME || (source == SSS_DEFAULT && _game_mode == GM_MENU)) {
00023     config = &_settings_newgame.game_config;
00024   } else {
00025     config = &_settings_game.game_config;
00026   }
00027   if (*config == NULL) *config = new GameConfig();
00028   return *config;
00029 }
00030 
00031 class GameInfo *GameConfig::GetInfo() const
00032 {
00033   return static_cast<class GameInfo *>(ScriptConfig::GetInfo());
00034 }
00035 
00036 ScriptInfo *GameConfig::FindInfo(const char *name, int version, bool force_exact_match)
00037 {
00038   return static_cast<ScriptInfo *>(Game::FindInfo(name, version, force_exact_match));
00039 }
00040 
00041 bool GameConfig::ResetInfo(bool force_exact_match)
00042 {
00043   this->info = (ScriptInfo *)Game::FindInfo(this->name, force_exact_match ? this->version : -1, force_exact_match);
00044   return this->info != NULL;
00045 }