12 #include "../stdafx.h" 
   13 #include "../company_base.h" 
   16 #include "../string_func.h" 
   18 #include "../ai/ai.hpp" 
   19 #include "../ai/ai_config.hpp" 
   20 #include "../network/network.h" 
   21 #include "../ai/ai_instance.hpp" 
   23 #include "../safeguards.h" 
   25 static char _ai_saveload_name[64];
 
   26 static int  _ai_saveload_version;
 
   27 static char _ai_saveload_settings[1024];
 
   28 static bool _ai_saveload_is_random;
 
   30 static const SaveLoad _ai_company[] = {
 
   31       SLEG_STR(_ai_saveload_name,        SLE_STRB),
 
   32       SLEG_STR(_ai_saveload_settings,    SLE_STRB),
 
   38 static void SaveReal_AIPL(
int *index_ptr)
 
   48     _ai_saveload_name[0] = 
'\0';
 
   49     _ai_saveload_version = -1;
 
   52   _ai_saveload_is_random = config->
IsRandom();
 
   53   _ai_saveload_settings[0] = 
'\0';
 
   61 static void Load_AIPL()
 
   72     _ai_saveload_is_random = 0;
 
   73     _ai_saveload_version = -1;
 
   84       config->
Change(NULL, -1, 
false, 
true);
 
   86       config->
Change(_ai_saveload_name, _ai_saveload_version, 
false, _ai_saveload_is_random);
 
   90         config->
Change(_ai_saveload_name, -1, 
false, _ai_saveload_is_random);
 
   92           if (strcmp(_ai_saveload_name, 
"%_dummy") != 0) {
 
   93             DEBUG(script, 0, 
"The savegame has an AI by the name '%s', version %d which is no longer available.", _ai_saveload_name, _ai_saveload_version);
 
   94             DEBUG(script, 0, 
"A random other AI will be loaded in its place.");
 
   96             DEBUG(script, 0, 
"The savegame had no AIs available at the time of saving.");
 
   97             DEBUG(script, 0, 
"A random available AI will be loaded now.");
 
  100           DEBUG(script, 0, 
"The savegame has an AI by the name '%s', version %d which is no longer available.", _ai_saveload_name, _ai_saveload_version);
 
  101           DEBUG(script, 0, 
"The latest version of that AI has been loaded instead, but it'll not get the savegame data as it's incompatible.");
 
  105         _ai_saveload_version = -1;
 
  114       AI::Load(index, _ai_saveload_version);
 
  119 static void Save_AIPL()
 
  128   { 
'AIPL', Save_AIPL, Load_AIPL, NULL, NULL, CH_ARRAY | 
CH_LAST},