summaryrefslogtreecommitdiff
path: root/src/saveload
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2010-01-09 14:41:22 +0000
committerrubidium <rubidium@openttd.org>2010-01-09 14:41:22 +0000
commitf65f276d10e528ffe2581656cfa8066a20002995 (patch)
tree40c36e7a0eb0070dbb4cb04eda09480fee9d0bbf /src/saveload
parent7f6016031e8367c8ce53a4017e5dadd47dc1974e (diff)
downloadopenttd-f65f276d10e528ffe2581656cfa8066a20002995.tar.xz
(svn r18763) -Feature [FS#3095]: rerandomise AIs on reloading (via the debug window) when they were randomly chosen
Diffstat (limited to 'src/saveload')
-rw-r--r--src/saveload/ai_sl.cpp19
1 files changed, 11 insertions, 8 deletions
diff --git a/src/saveload/ai_sl.cpp b/src/saveload/ai_sl.cpp
index 95fd95575..a69f3da60 100644
--- a/src/saveload/ai_sl.cpp
+++ b/src/saveload/ai_sl.cpp
@@ -22,12 +22,14 @@
static char _ai_saveload_name[64];
static int _ai_saveload_version;
static char _ai_saveload_settings[1024];
+static bool _ai_saveload_is_random;
static const SaveLoad _ai_company[] = {
- SLEG_STR(_ai_saveload_name, SLE_STRB),
- SLEG_STR(_ai_saveload_settings, SLE_STRB),
- SLEG_CONDVAR(_ai_saveload_version, SLE_UINT32, 108, SL_MAX_VERSION),
- SLE_END()
+ SLEG_STR(_ai_saveload_name, SLE_STRB),
+ SLEG_STR(_ai_saveload_settings, SLE_STRB),
+ SLEG_CONDVAR(_ai_saveload_version, SLE_UINT32, 108, SL_MAX_VERSION),
+ SLEG_CONDVAR(_ai_saveload_is_random, SLE_BOOL, 136, SL_MAX_VERSION),
+ SLE_END()
};
static void SaveReal_AIPL(int *index_ptr)
@@ -44,6 +46,7 @@ static void SaveReal_AIPL(int *index_ptr)
_ai_saveload_version = -1;
}
+ _ai_saveload_is_random = config->IsRandomAI();
_ai_saveload_settings[0] = '\0';
config->SettingsToString(_ai_saveload_settings, lengthof(_ai_saveload_settings));
@@ -72,13 +75,13 @@ static void Load_AIPL()
AIConfig *config = AIConfig::GetConfig(index);
if (StrEmpty(_ai_saveload_name)) {
/* A random AI. */
- config->ChangeAI(NULL);
+ config->ChangeAI(NULL, -1, true);
} else {
- config->ChangeAI(_ai_saveload_name, _ai_saveload_version);
+ config->ChangeAI(_ai_saveload_name, _ai_saveload_version, _ai_saveload_is_random);
if (!config->HasAI()) {
/* 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);
+ config->ChangeAI(_ai_saveload_name, -1, _ai_saveload_is_random);
if (!config->HasAI()) {
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);
@@ -101,7 +104,7 @@ static void Load_AIPL()
/* Start the AI directly if it was active in the savegame */
if (Company::IsValidAiID(index)) {
- AI::StartNew(index);
+ AI::StartNew(index, false);
AI::Load(index, _ai_saveload_version);
}
}