diff options
author | truebrain <truebrain@openttd.org> | 2011-12-19 20:56:59 +0000 |
---|---|---|
committer | truebrain <truebrain@openttd.org> | 2011-12-19 20:56:59 +0000 |
commit | 963802e9a7cb67f51cb7e6ffe9d33a02cfe93821 (patch) | |
tree | d8b2d5c1c2d90c7cb1a02403cea942ab52c2e501 /src/game/game_scanner.cpp | |
parent | 83f2785f54de1c31267c5586464c97fb39f95b5a (diff) | |
download | openttd-963802e9a7cb67f51cb7e6ffe9d33a02cfe93821.tar.xz |
(svn r23612) -Add: allow importing libraries in the same way as AI does, only with GS prefix (and in game/library)
Diffstat (limited to 'src/game/game_scanner.cpp')
-rw-r--r-- | src/game/game_scanner.cpp | 36 |
1 files changed, 31 insertions, 5 deletions
diff --git a/src/game/game_scanner.cpp b/src/game/game_scanner.cpp index 54b684c3e..056c1378a 100644 --- a/src/game/game_scanner.cpp +++ b/src/game/game_scanner.cpp @@ -21,11 +21,6 @@ #include "../script/api/script_controller.hpp" -GameScannerInfo::GameScannerInfo() : - ScriptScanner() -{ -} - void GameScannerInfo::Initialize() { ScriptScanner::Initialize("GSScanner"); @@ -87,3 +82,34 @@ GameInfo *GameScannerInfo::FindInfo(const char *nameParam, int versionParam, boo return info; } + + +void GameScannerLibrary::Initialize() +{ + ScriptScanner::Initialize("GSScanner"); +} + +void GameScannerLibrary::GetScriptName(ScriptInfo *info, char *name, int len) +{ + GameLibrary *library = static_cast<GameLibrary *>(info); + snprintf(name, len, "%s.%s", library->GetCategory(), library->GetInstanceName()); +} + +void GameScannerLibrary::RegisterAPI(class Squirrel *engine) +{ + GameLibrary::RegisterAPI(engine); +} + +GameLibrary *GameScannerLibrary::FindLibrary(const char *library, int version) +{ + /* Internally we store libraries as 'library.version' */ + char library_name[1024]; + snprintf(library_name, sizeof(library_name), "%s.%d", library, version); + strtolower(library_name); + + /* Check if the library + version exists */ + ScriptInfoList::iterator iter = this->info_list.find(library_name); + if (iter == this->info_list.end()) return NULL; + + return static_cast<GameLibrary *>((*iter).second); +} |