Loading

Revision differences

Old revision #puz8c3l3nNew revision #pxkc1qh0d
1Index: console_cmds.cpp  1Index: src/ai/ai_scanner.cpp
2===================================================================  2===================================================================  
3--- console_cmds.cpp    (revision 27582)  3--- src/ai/ai_scanner.cpp    (revision 27582)
4+++ console_cmds.cpp    (working copy)  4+++ src/ai/ai_scanner.cpp    (working copy)
5@@ -34,6 +34,7 @@  5@@ -136,6 +136,20 @@
6 #include "gamelog.h"    
7 #include "ai/ai.hpp"    
8 #include "ai/ai_config.hpp"    
9+#include "ai/ai_info.hpp"    
10 #include "newgrf.h"    
11 #include "console_func.h"    
12 #include "engine_base.h"    
13@@ -1171,6 +1172,9 @@    
14         if (!config->HasScript()) {    
15             IConsoleWarning("Failed to load the specified AI");    
16             return true;    
17+        } else {    
18+            AIInfo *info = config->GetInfo();    
19+            config->Change(info->GetName());    
20         }  6         }  
21         if (argc == 3) {  7     }
22             config->StringToSettings(argv[2]); 8 
   9+    /* If we didn't find a match AI, maybe the savegame included a version */
   10+    if (info == NULL && !force_exact_match && versionParam != -1) {
   11+        char *e = strrchr(ai_name, '.');
   12+        if (e == NULL) return NULL;
   13+        *e = '\0';
   14+        e++;
   15+        versionParam = atoi(e);
   16+        /* Try to find a direct 'name.version' match */
   17+        char ai_name_tmp[1024];
   18+        seprintf(ai_name_tmp, lastof(ai_name_tmp), "%s.%d", ai_name, versionParam);
   19+        strtolower(ai_name_tmp);
   20+        if (this->info_list.find(ai_name_tmp) != this->info_list.end()) return static_cast<AIInfo *>(this->info_list[ai_name_tmp]);
   21+    }
   22+
   23     return info;
   24 }
   25 
   26Index: src/game/game_scanner.cpp
   27===================================================================
   28--- src/game/game_scanner.cpp    (revision 27582)
   29+++ src/game/game_scanner.cpp    (working copy)
   30@@ -77,6 +77,20 @@
   31         }
   32     }
   33 
   34+    /* If we didn't find a match Game script, maybe the savegame included a version */
   35+    if (info == NULL && !force_exact_match && versionParam != -1) {
   36+        char *e = strrchr(game_name, '.');
   37+        if (e == NULL) return NULL;
   38+        *e = '\0';
   39+        e++;
   40+        versionParam = atoi(e);
   41+        /* Try to find a direct 'name.version' match */
   42+        char game_name_tmp[1024];
   43+        seprintf(game_name_tmp, lastof(game_name_tmp), "%s.%d", game_name, versionParam);
   44+        strtolower(game_name_tmp);
   45+        if (this->info_list.find(game_name_tmp) != this->info_list.end()) return static_cast<GameInfo *>(this->info_list[game_name_tmp]);
   46+    }
   47+
   48     return info;
   49 }