diff options
author | truebrain <truebrain@openttd.org> | 2009-01-13 00:10:58 +0000 |
---|---|---|
committer | truebrain <truebrain@openttd.org> | 2009-01-13 00:10:58 +0000 |
commit | e6883c5cc7dedad23dfcf7a303a7154520db7f5e (patch) | |
tree | 6f8cae96c393130678adbf0a04466fece890cd20 /src/ai/ai_config.cpp | |
parent | 2462e8dc9d7e3a5a76c96d3c0229019a48e9bfdd (diff) | |
download | openttd-e6883c5cc7dedad23dfcf7a303a7154520db7f5e.tar.xz |
(svn r15044) -Add [NoAI]: AIConfig::GetVersion(), to get the version of the current AI
Diffstat (limited to 'src/ai/ai_config.cpp')
-rw-r--r-- | src/ai/ai_config.cpp | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/ai/ai_config.cpp b/src/ai/ai_config.cpp index f5d22bdaa..b93bf76b4 100644 --- a/src/ai/ai_config.cpp +++ b/src/ai/ai_config.cpp @@ -14,6 +14,7 @@ void AIConfig::ChangeAI(const char *name) free((void *)this->name); this->name = (name == NULL) ? NULL : strdup(name); this->info = (name == NULL) ? NULL : AI::GetCompanyInfo(this->name); + this->version = (info == NULL) ? -1 : info->GetVersion(); for (SettingValueList::iterator it = this->settings.begin(); it != this->settings.end(); it++) { free((void*)(*it).first); @@ -21,12 +22,11 @@ void AIConfig::ChangeAI(const char *name) this->settings.clear(); } -AIConfig::AIConfig(const AIConfig *config) : - name(NULL), - info(NULL) +AIConfig::AIConfig(const AIConfig *config) { this->name = (config->name == NULL) ? NULL : strdup(config->name); this->info = config->info; + this->version = config->version; for (SettingValueList::const_iterator it = config->settings.begin(); it != config->settings.end(); it++) { this->settings[strdup((*it).first)] = (*it).second; @@ -96,6 +96,11 @@ const char *AIConfig::GetName() return this->name; } +int AIConfig::GetVersion() +{ + return this->version; +} + void AIConfig::StringToSettings(const char *value) { char *value_copy = strdup(value); |