Index: src/ai/ai_scanner.cpp =================================================================== --- src/ai/ai_scanner.cpp (revision 27582) +++ src/ai/ai_scanner.cpp (working copy) @@ -136,6 +136,31 @@ } } + if (info == NULL && !force_exact_match && versionParam != -1) { + /* If we didn't find a match AI, maybe the user included a version */ + char *e = strrchr(ai_name, '.'); + if (e == NULL) return NULL; + *e = '\0'; + e++; + versionParam = atoi(e); + /* Try to find a direct 'name.version' match */ + char ai_name_tmp[1024]; + seprintf(ai_name_tmp, lastof(ai_name_tmp), "%s.%d", ai_name, versionParam); + strtolower(ai_name_tmp); + if (this->info_list.find(ai_name_tmp) != this->info_list.end()) return static_cast(this->info_list[ai_name_tmp]); + + /* See if there is a compatible AI which goes by that name, with the highest + * version which allows loading the requested version */ + ScriptInfoList::iterator it = this->info_list.begin(); + for (; it != this->info_list.end(); it++) { + AIInfo *i = static_cast((*it).second); + if (strcasecmp(ai_name, i->GetName()) == 0 && i->CanLoadFromVersion(versionParam) && (version == -1 || i->GetVersion() > version)) { + version = (*it).second->GetVersion(); + info = i; + } + } + } + return info; } Index: src/game/game_scanner.cpp =================================================================== --- src/game/game_scanner.cpp (revision 27582) +++ src/game/game_scanner.cpp (working copy) @@ -77,6 +77,31 @@ } } + if (info == NULL && !force_exact_match && versionParam != -1) { + /* If we didn't find a match Game script, maybe the user included a version */ + char *e = strrchr(game_name, '.'); + if (e == NULL) return NULL; + *e = '\0'; + e++; + versionParam = atoi(e); + /* Try to find a direct 'name.version' match */ + char game_name_tmp[1024]; + seprintf(game_name_tmp, lastof(game_name_tmp), "%s.%d", game_name, versionParam); + strtolower(game_name_tmp); + if (this->info_list.find(game_name_tmp) != this->info_list.end()) return static_cast(this->info_list[game_name_tmp]); + + /* See if there is a compatible Game script which goes by that name, with the highest + * version which allows loading the requested version */ + ScriptInfoList::iterator it = this->info_list.begin(); + for (; it != this->info_list.end(); it++) { + GameInfo *i = static_cast((*it).second); + if (strcasecmp(game_name, i->GetName()) == 0 && i->CanLoadFromVersion(versionParam) && (version == -1 || i->GetVersion() > version)) { + version = (*it).second->GetVersion(); + info = i; + } + } + } + return info; }