| Old revision #pxkc1qh0d | New revision #phjib9464 | ||
|---|---|---|---|
| 2 | =================================================================== | 2 | =================================================================== |
| 3 | --- src/ai/ai_scanner.cpp (revision 27582) | 3 | --- src/ai/ai_scanner.cpp (revision 27582) |
| 4 | +++ src/ai/ai_scanner.cpp (working copy) | 4 | +++ src/ai/ai_scanner.cpp (working copy) |
| 5 | @@ -136,6 +136, | 5 | @@ -136,6 +136,31 @@ |
| 6 | } | 6 | } |
| 7 | } | 7 | } |
| 8 | 8 | ||
| 9 | |||
| 10 | + if (info == NULL && !force_exact_match && versionParam != -1) { | 9 | + if (info == NULL && !force_exact_match && versionParam != -1) { |
| 10 | + /* If we didn't find a match AI, maybe the user included a version */ | ||
| 11 | + char *e = strrchr(ai_name, '.'); | 11 | + char *e = strrchr(ai_name, '.'); |
| 12 | + if (e == NULL) return NULL; | 12 | + if (e == NULL) return NULL; |
| 13 | + *e = '\0'; | 13 | + *e = '\0'; | … | … |
| 18 | + seprintf(ai_name_tmp, lastof(ai_name_tmp), "%s.%d", ai_name, versionParam); | 18 | + seprintf(ai_name_tmp, lastof(ai_name_tmp), "%s.%d", ai_name, versionParam); |
| 19 | + strtolower(ai_name_tmp); | 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]); | 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 | + /* See if there is a compatible AI which goes by that name, with the highest | ||
| 23 | + * version which allows loading the requested version */ | ||
| 24 | + ScriptInfoList::iterator it = this->info_list.begin(); | ||
| 25 | + for (; it != this->info_list.end(); it++) { | ||
| 26 | + AIInfo *i = static_cast<AIInfo *>((*it).second); | ||
| 27 | + if (strcasecmp(ai_name, i->GetName()) == 0 && i->CanLoadFromVersion(versionParam) && (version == -1 || i->GetVersion() > version)) { | ||
| 28 | + version = (*it).second->GetVersion(); | ||
| 29 | + info = i; | ||
| 30 | + } | ||
| 31 | + } | ||
| 21 | + } | 32 | + } |
| 22 | + | 33 | + |
| 23 | return info; | 34 | return info; | … | … |
| 27 | =================================================================== | 38 | =================================================================== |
| 28 | --- src/game/game_scanner.cpp (revision 27582) | 39 | --- src/game/game_scanner.cpp (revision 27582) |
| 29 | +++ src/game/game_scanner.cpp (working copy) | 40 | +++ src/game/game_scanner.cpp (working copy) |
| 30 | @@ -77,6 +77, | 30 | @@ -77,6 +77,31 @@ |
| 31 | } | 42 | } |
| 32 | } | 43 | } |
| 33 | 44 | ||
| 34 | |||
| 35 | + if (info == NULL && !force_exact_match && versionParam != -1) { | 45 | + if (info == NULL && !force_exact_match && versionParam != -1) { |
| 46 | + /* If we didn't find a match Game script, maybe the user included a version */ | ||
| 36 | + char *e = strrchr(game_name, '.'); | 47 | + char *e = strrchr(game_name, '.'); |
| 37 | + if (e == NULL) return NULL; | 48 | + if (e == NULL) return NULL; |
| 38 | + *e = '\0'; | 49 | + *e = '\0'; | … | … |
| 43 | + seprintf(game_name_tmp, lastof(game_name_tmp), "%s.%d", game_name, versionParam); | 54 | + seprintf(game_name_tmp, lastof(game_name_tmp), "%s.%d", game_name, versionParam); |
| 44 | + strtolower(game_name_tmp); | 55 | + 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]); | 56 | + if (this->info_list.find(game_name_tmp) != this->info_list.end()) return static_cast<GameInfo *>(this->info_list[game_name_tmp]); |
| 57 | + | ||
| 58 | + /* See if there is a compatible Game script which goes by that name, with the highest | ||
| 59 | + * version which allows loading the requested version */ | ||
| 60 | + ScriptInfoList::iterator it = this->info_list.begin(); | ||
| 61 | + for (; it != this->info_list.end(); it++) { | ||
| 62 | + GameInfo *i = static_cast<GameInfo *>((*it).second); | ||
| 63 | + if (strcasecmp(game_name, i->GetName()) == 0 && i->CanLoadFromVersion(versionParam) && (version == -1 || i->GetVersion() > version)) { | ||
| 64 | + version = (*it).second->GetVersion(); | ||
| 65 | + info = i; | ||
| 66 | + } | ||
| 67 | + } | ||
| 46 | + } | 68 | + } |
| 47 | + | 69 | + |
| 48 | return info; | 70 | return info; |