(svn r23364) -Codechange: refactor AIConfig, moving it mostly to Scriptconfig
This commit is contained in:
@@ -39,7 +39,7 @@ static void SaveReal_AIPL(int *index_ptr)
|
||||
CompanyID index = (CompanyID)*index_ptr;
|
||||
AIConfig *config = AIConfig::GetConfig(index);
|
||||
|
||||
if (config->HasAI()) {
|
||||
if (config->HasScript()) {
|
||||
ttd_strlcpy(_ai_saveload_name, config->GetName(), lengthof(_ai_saveload_name));
|
||||
_ai_saveload_version = config->GetVersion();
|
||||
} else {
|
||||
@@ -48,7 +48,7 @@ static void SaveReal_AIPL(int *index_ptr)
|
||||
_ai_saveload_version = -1;
|
||||
}
|
||||
|
||||
_ai_saveload_is_random = config->IsRandomAI();
|
||||
_ai_saveload_is_random = config->IsRandom();
|
||||
_ai_saveload_settings[0] = '\0';
|
||||
config->SettingsToString(_ai_saveload_settings, lengthof(_ai_saveload_settings));
|
||||
|
||||
@@ -61,7 +61,7 @@ static void Load_AIPL()
|
||||
{
|
||||
/* Free all current data */
|
||||
for (CompanyID c = COMPANY_FIRST; c < MAX_COMPANIES; c++) {
|
||||
AIConfig::GetConfig(c, AIConfig::AISS_FORCE_GAME)->ChangeAI(NULL);
|
||||
AIConfig::GetConfig(c, AIConfig::SSS_FORCE_GAME)->Change(NULL);
|
||||
}
|
||||
|
||||
CompanyID index;
|
||||
@@ -76,17 +76,17 @@ static void Load_AIPL()
|
||||
continue;
|
||||
}
|
||||
|
||||
AIConfig *config = AIConfig::GetConfig(index, AIConfig::AISS_FORCE_GAME);
|
||||
AIConfig *config = AIConfig::GetConfig(index, AIConfig::SSS_FORCE_GAME);
|
||||
if (StrEmpty(_ai_saveload_name)) {
|
||||
/* A random AI. */
|
||||
config->ChangeAI(NULL, -1, false, true);
|
||||
config->Change(NULL, -1, false, true);
|
||||
} else {
|
||||
config->ChangeAI(_ai_saveload_name, _ai_saveload_version, false, _ai_saveload_is_random);
|
||||
if (!config->HasAI()) {
|
||||
config->Change(_ai_saveload_name, _ai_saveload_version, false, _ai_saveload_is_random);
|
||||
if (!config->HasScript()) {
|
||||
/* No version of the AI available that can load the data. Try to load the
|
||||
* latest version of the AI instead. */
|
||||
config->ChangeAI(_ai_saveload_name, -1, false, _ai_saveload_is_random);
|
||||
if (!config->HasAI()) {
|
||||
config->Change(_ai_saveload_name, -1, false, _ai_saveload_is_random);
|
||||
if (!config->HasScript()) {
|
||||
if (strcmp(_ai_saveload_name, "%_dummy") != 0) {
|
||||
DEBUG(ai, 0, "The savegame has an AI by the name '%s', version %d which is no longer available.", _ai_saveload_name, _ai_saveload_version);
|
||||
DEBUG(ai, 0, "A random other AI will be loaded in its place.");
|
||||
|
Reference in New Issue
Block a user