# 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 "game.hpp"
    00015 #include "game_config.hpp"
    00016 #include "game_info.hpp"
    00017
    00018 /* static */ GameConfig *GameConfig::GetConfig(ScriptSettingSource source)
    00019 {
    00020   GameConfig **config;
    00021   if (source == SSS_FORCE_NEWGAME || (source == SSS_DEFAULT && _game_mode == GM_MENU)) {
    00022     config = &_settings_newgame.game_config;
    00023   } else {
    00024     config = &_settings_game.game_config;
    00025   }
    00026   if (*config == NULL) *config = new GameConfig();
    00027   return *config;
    00028 }
    00029
    00030 class GameInfo *GameConfig::GetInfo() const
    00031 {
    00032   return static_cast<class GameInfo *>(ScriptConfig::GetInfo());
    00033 }
    00034
    00035 ScriptInfo *GameConfig::FindInfo(const char *name, int version, bool force_exact_match)
    00036 {
    00037   return static_cast<ScriptInfo *>(Game::FindInfo(name, version, force_exact_match));
    00038 }
    00039
    00040 bool GameConfig::ResetInfo(bool force_exact_match)
    00041 {
    00042   this->info = (ScriptInfo *)Game::FindInfo(this->name, force_exact_match ? this->version : -1, force_exact_match);
    00043   return this->info != NULL;
    00044 }