Codechange: use std::string for script info/library finding
This commit is contained in:
@@ -91,9 +91,9 @@ public:
|
||||
/** Wrapper function for GameScanner::GetUniqueInfoList */
|
||||
static const ScriptInfoList *GetUniqueInfoList();
|
||||
/** Wrapper function for GameScannerInfo::FindInfo */
|
||||
static class GameInfo *FindInfo(const char *name, int version, bool force_exact_match);
|
||||
static class GameInfo *FindInfo(const std::string &name, int version, bool force_exact_match);
|
||||
/** Wrapper function for GameScanner::FindLibrary */
|
||||
static class GameLibrary *FindLibrary(const char *library, int version);
|
||||
static class GameLibrary *FindLibrary(const std::string &library, int version);
|
||||
|
||||
/**
|
||||
* Get the current active instance.
|
||||
|
@@ -32,7 +32,7 @@ class GameInfo *GameConfig::GetInfo() const
|
||||
return static_cast<class GameInfo *>(ScriptConfig::GetInfo());
|
||||
}
|
||||
|
||||
ScriptInfo *GameConfig::FindInfo(const char *name, int version, bool force_exact_match)
|
||||
ScriptInfo *GameConfig::FindInfo(const std::string &name, int version, bool force_exact_match)
|
||||
{
|
||||
return static_cast<ScriptInfo *>(Game::FindInfo(name, version, force_exact_match));
|
||||
}
|
||||
|
@@ -40,7 +40,7 @@ public:
|
||||
bool ResetInfo(bool force_exact_match);
|
||||
|
||||
protected:
|
||||
ScriptInfo *FindInfo(const char *name, int version, bool force_exact_match) override;
|
||||
ScriptInfo *FindInfo(const std::string &name, int version, bool force_exact_match) override;
|
||||
};
|
||||
|
||||
#endif /* GAME_CONFIG_HPP */
|
||||
|
@@ -239,12 +239,12 @@
|
||||
return Game::scanner_info->GetUniqueInfoList();
|
||||
}
|
||||
|
||||
/* static */ GameInfo *Game::FindInfo(const char *name, int version, bool force_exact_match)
|
||||
/* static */ GameInfo *Game::FindInfo(const std::string &name, int version, bool force_exact_match)
|
||||
{
|
||||
return Game::scanner_info->FindInfo(name, version, force_exact_match);
|
||||
}
|
||||
|
||||
/* static */ GameLibrary *Game::FindLibrary(const char *library, int version)
|
||||
/* static */ GameLibrary *Game::FindLibrary(const std::string &library, int version)
|
||||
{
|
||||
return Game::scanner_library->FindLibrary(library, version);
|
||||
}
|
||||
|
@@ -58,7 +58,7 @@ int GameInstance::GetSetting(const char *name)
|
||||
return GameConfig::GetConfig()->GetSetting(name);
|
||||
}
|
||||
|
||||
ScriptInfo *GameInstance::FindLibrary(const char *library, int version)
|
||||
ScriptInfo *GameInstance::FindLibrary(const std::string &library, int version)
|
||||
{
|
||||
return (ScriptInfo *)Game::FindLibrary(library, version);
|
||||
}
|
||||
|
@@ -24,7 +24,7 @@ public:
|
||||
void Initialize(class GameInfo *info);
|
||||
|
||||
int GetSetting(const char *name) override;
|
||||
ScriptInfo *FindLibrary(const char *library, int version) override;
|
||||
ScriptInfo *FindLibrary(const std::string &library, int version) override;
|
||||
|
||||
private:
|
||||
void RegisterAPI() override;
|
||||
|
@@ -33,10 +33,10 @@ void GameScannerInfo::RegisterAPI(class Squirrel *engine)
|
||||
GameInfo::RegisterAPI(engine);
|
||||
}
|
||||
|
||||
GameInfo *GameScannerInfo::FindInfo(const char *name, int version, bool force_exact_match)
|
||||
GameInfo *GameScannerInfo::FindInfo(const std::string &name, int version, bool force_exact_match)
|
||||
{
|
||||
if (this->info_list.size() == 0) return nullptr;
|
||||
if (name == nullptr) return nullptr;
|
||||
if (name.empty()) return nullptr;
|
||||
|
||||
if (version == -1) {
|
||||
/* We want to load the latest version of this Game script; so find it */
|
||||
@@ -86,7 +86,7 @@ void GameScannerLibrary::RegisterAPI(class Squirrel *engine)
|
||||
GameLibrary::RegisterAPI(engine);
|
||||
}
|
||||
|
||||
GameLibrary *GameScannerLibrary::FindLibrary(const char *library, int version)
|
||||
GameLibrary *GameScannerLibrary::FindLibrary(const std::string &library, int version)
|
||||
{
|
||||
/* Internally we store libraries as 'library.version' */
|
||||
std::string library_name = fmt::format("{}.{}", library, version);
|
||||
|
@@ -23,7 +23,7 @@ public:
|
||||
* @param force_exact_match Only match name+version, never latest.
|
||||
* @return nullptr if no match found, otherwise the game script that matched.
|
||||
*/
|
||||
class GameInfo *FindInfo(const char *name, int version, bool force_exact_match);
|
||||
class GameInfo *FindInfo(const std::string &name, int version, bool force_exact_match);
|
||||
|
||||
protected:
|
||||
std::string GetScriptName(ScriptInfo *info) override;
|
||||
@@ -44,7 +44,7 @@ public:
|
||||
* @param version The version the library should have.
|
||||
* @return The library if found, nullptr otherwise.
|
||||
*/
|
||||
class GameLibrary *FindLibrary(const char *library, int version);
|
||||
class GameLibrary *FindLibrary(const std::string &library, int version);
|
||||
|
||||
protected:
|
||||
std::string GetScriptName(ScriptInfo *info) override;
|
||||
|
Reference in New Issue
Block a user