mirror of
https://github.com/JGRennison/OpenTTD-patches.git
synced 2024-11-16 00:12:51 +00:00
(svn r15044) -Add [NoAI]: AIConfig::GetVersion(), to get the version of the current AI
This commit is contained in:
parent
a2b24a8362
commit
27c0a4c801
@ -14,6 +14,7 @@ void AIConfig::ChangeAI(const char *name)
|
|||||||
free((void *)this->name);
|
free((void *)this->name);
|
||||||
this->name = (name == NULL) ? NULL : strdup(name);
|
this->name = (name == NULL) ? NULL : strdup(name);
|
||||||
this->info = (name == NULL) ? NULL : AI::GetCompanyInfo(this->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++) {
|
for (SettingValueList::iterator it = this->settings.begin(); it != this->settings.end(); it++) {
|
||||||
free((void*)(*it).first);
|
free((void*)(*it).first);
|
||||||
@ -21,12 +22,11 @@ void AIConfig::ChangeAI(const char *name)
|
|||||||
this->settings.clear();
|
this->settings.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
AIConfig::AIConfig(const AIConfig *config) :
|
AIConfig::AIConfig(const AIConfig *config)
|
||||||
name(NULL),
|
|
||||||
info(NULL)
|
|
||||||
{
|
{
|
||||||
this->name = (config->name == NULL) ? NULL : strdup(config->name);
|
this->name = (config->name == NULL) ? NULL : strdup(config->name);
|
||||||
this->info = config->info;
|
this->info = config->info;
|
||||||
|
this->version = config->version;
|
||||||
|
|
||||||
for (SettingValueList::const_iterator it = config->settings.begin(); it != config->settings.end(); it++) {
|
for (SettingValueList::const_iterator it = config->settings.begin(); it != config->settings.end(); it++) {
|
||||||
this->settings[strdup((*it).first)] = (*it).second;
|
this->settings[strdup((*it).first)] = (*it).second;
|
||||||
@ -96,6 +96,11 @@ const char *AIConfig::GetName()
|
|||||||
return this->name;
|
return this->name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int AIConfig::GetVersion()
|
||||||
|
{
|
||||||
|
return this->version;
|
||||||
|
}
|
||||||
|
|
||||||
void AIConfig::StringToSettings(const char *value)
|
void AIConfig::StringToSettings(const char *value)
|
||||||
{
|
{
|
||||||
char *value_copy = strdup(value);
|
char *value_copy = strdup(value);
|
||||||
|
@ -18,6 +18,7 @@ private:
|
|||||||
public:
|
public:
|
||||||
AIConfig() :
|
AIConfig() :
|
||||||
name(NULL),
|
name(NULL),
|
||||||
|
version(-1),
|
||||||
info(NULL)
|
info(NULL)
|
||||||
{}
|
{}
|
||||||
AIConfig(const AIConfig *config);
|
AIConfig(const AIConfig *config);
|
||||||
@ -70,6 +71,11 @@ public:
|
|||||||
*/
|
*/
|
||||||
const char *GetName();
|
const char *GetName();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the version of the AI.
|
||||||
|
*/
|
||||||
|
int GetVersion();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convert a string which is stored in the config file or savegames to
|
* Convert a string which is stored in the config file or savegames to
|
||||||
* custom settings of this AI.
|
* custom settings of this AI.
|
||||||
@ -84,6 +90,7 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
const char *name;
|
const char *name;
|
||||||
|
int version;
|
||||||
class AIInfo *info;
|
class AIInfo *info;
|
||||||
SettingValueList settings;
|
SettingValueList settings;
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user