3 | --- src/saveload/ai_sl.cpp (revision 27582)
| 3 | --- src/ai/ai_scanner.cpp (revision 27582)
|
---|
4 | +++ src/saveload/ai_sl.cpp (working copy)
| 4 | +++ src/ai/ai_scanner.cpp (working copy)
|
---|
5 | @@ -83,7 +83,7 @@
| 5 | @@ -136,6 +136,20 @@
|
---|
6 | /* A random AI. */
| 6 | }
|
---|
7 | config->Change(NULL, -1, false, true);
| 7 | }
|
---|
8 | } else {
| 8 |
|
---|
9 | - config->Change(_ai_saveload_name, _ai_saveload_version, false, _ai_saveload_is_random);
| 9 | + /* If we didn't find a match AI, maybe the savegame included a version */
|
---|
10 | + config->Change(_ai_saveload_name, -1, true, _ai_saveload_is_random);
| 10 | + if (info == NULL && !force_exact_match && versionParam != -1) {
|
---|
11 | if (!config->HasScript()) {
| 11 | + char *e = strrchr(ai_name, '.');
|
---|
12 | /* No version of the AI available that can load the data. Try to load the
| 12 | + if (e == NULL) return NULL;
|
---|
13 | * latest version of the AI instead. */
| 13 | + *e = '\0';
|
---|
14 | Index: src/saveload/game_sl.cpp
| 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 |
|
---|
| | 26 | Index: src/game/game_scanner.cpp
|
---|
16 | --- src/saveload/game_sl.cpp (revision 27582)
| 28 | --- src/game/game_scanner.cpp (revision 27582)
|
---|
17 | +++ src/saveload/game_sl.cpp (working copy)
| 29 | +++ src/game/game_scanner.cpp (working copy)
|
---|
18 | @@ -75,7 +75,7 @@
| 30 | @@ -77,6 +77,20 @@
|
---|
19 | GameConfig *config = GameConfig::GetConfig(GameConfig::SSS_FORCE_GAME);
| 31 | }
|
---|
20 | if (StrEmpty(_game_saveload_name)) {
| 32 | }
|
---|
21 | } else {
| 33 |
|
---|
22 | - config->Change(_game_saveload_name, _game_saveload_version, false, _game_saveload_is_random);
| 34 | + /* If we didn't find a match Game script, maybe the savegame included a version */
|
---|
23 | + config->Change(_game_saveload_name, -1, true, _game_saveload_is_random);
| 35 | + if (info == NULL && !force_exact_match && versionParam != -1) {
|
---|
24 | if (!config->HasScript()) {
| 36 | + char *e = strrchr(game_name, '.');
|
---|
25 | /* No version of the GameScript available that can load the data. Try to load the
| 37 | + if (e == NULL) return NULL;
|
---|
26 | * latest version of the GameScript instead. */ | 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 | } |
---|