OpenTTD

game_config.cpp
Go to the documentation of this file.
1 /* $Id: game_config.cpp 26482 2014-04-23 20:13:33Z rubidium $ */
2
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 */
9
12 #include "../stdafx.h"
13 #include "../settings_type.h"
14 #include "game.hpp"
15 #include "game_config.hpp"
16 #include "game_info.hpp"
17
18 #include "../safeguards.h"
19
20 /* static */ GameConfig *GameConfig::GetConfig(ScriptSettingSource source)
21 {
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;
27 }
28 if (*config == NULL) *config = new GameConfig();
29 return *config;
30 }
31
32 class GameInfo *GameConfig::GetInfo() const
33 {
34 return static_cast<class GameInfo *>(ScriptConfig::GetInfo());
35 }
36
37 ScriptInfo *GameConfig::FindInfo(const char *name, int version, bool force_exact_match)
38 {
39 return static_cast<ScriptInfo *>(Game::FindInfo(name, version, force_exact_match));
40 }
41
42 bool GameConfig::ResetInfo(bool force_exact_match)
43 {
44 this->info = (ScriptInfo *)Game::FindInfo(this->name, force_exact_match ? this->version : -1, force_exact_match);
45 return this->info != NULL;
46 }
_settings_game
GameSettings _settings_game
Game settings of a running game or the scenario editor.
Definition: settings.cpp:77
game_config.hpp
GameConfig stores the configuration settings of every Game.
GameConfig::ResetInfo
bool ResetInfo(bool force_exact_match)
When ever the Game Scanner is reloaded, all infos become invalid.
Definition: game_config.cpp:42
GameConfig::GetConfig
static GameConfig * GetConfig(ScriptSettingSource source=SSS_DEFAULT)
Get the config of a company.
Definition: game_config.cpp:20
GameConfig
Definition: game_config.hpp:17
GameInfo
All static information from an Game like name, version, etc.
Definition: game_info.hpp:18
ScriptConfig::SSS_DEFAULT
Get the Script config from the current game mode.
Definition: script_config.hpp:105
ScriptConfig::GetInfo
class ScriptInfo * GetInfo() const
Get the ScriptInfo linked to this ScriptConfig.
Definition: script_config.cpp:67
Game::FindInfo
static class GameInfo * FindInfo(const char *name, int version, bool force_exact_match)
Wrapper function for GameScannerInfo::FindInfo.
Definition: game_core.cpp:241
GameConfig::FindInfo
ScriptInfo * FindInfo(const char *name, int version, bool force_exact_match)
This function should call back to the Scanner in charge of this Config, to find the ScriptInfo belong...
Definition: game_config.cpp:37
ScriptInfo
All static information from an Script like name, version, etc.
Definition: script_info.hpp:32
ScriptConfig::ScriptSettingSource
ScriptSettingSource
Where to get the config from, either default (depends on current game mode) or force either newgame o...
Definition: script_config.hpp:104
_settings_newgame
GameSettings _settings_newgame
Game settings for new games (updated from the intro screen).
Definition: settings.cpp:78
GameSettings::game_config
class GameConfig * game_config
settings for gamescript
Definition: settings_type.h:549
game_info.hpp
GameInfo keeps track of all information of an Game, like Author, Description, ... ...
ScriptConfig::version
int version
Version of the Script.
Definition: script_config.hpp:187
ScriptConfig::SSS_FORCE_NEWGAME
Get the newgame Script config.
Definition: script_config.hpp:106
game.hpp
Base functions for all Games.
ScriptConfig::info
class ScriptInfo * info
ScriptInfo object for related to this Script version.
Definition: script_config.hpp:188
ScriptConfig::name
const char * name
Name of the Script.
Definition: script_config.hpp:186