Merge pull request #32 from lioncash/str

CGameInfo: Make file-scope strings non-allocating
This commit is contained in:
LC 2020-06-11 10:51:20 -04:00 committed by GitHub
commit 4f289193bb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 5 deletions

View File

@ -2,6 +2,9 @@
#include "CResourceStore.h"
#include <Common/FileUtil.h>
constexpr char gkGameInfoDir[] = "resources/gameinfo";
constexpr char gkGameInfoExt[] = "xml";
bool CGameInfo::LoadGameInfo(EGame Game)
{
Game = RoundGame(Game);
@ -86,3 +89,8 @@ TString CGameInfo::GetDefaultGameInfoPath(EGame Game)
TString GameName = GetGameShortName(Game);
return TString::Format("%s/%s/GameInfo%s.%s", *gDataDir, *gkGameInfoDir, *GameName, *gkGameInfoExt);
}
TString CGameInfo::GetExtension()
{
return gkGameInfoExt;
}

View File

@ -8,9 +8,6 @@
#include <Common/Serialization/XML.h>
#include <map>
const TString gkGameInfoDir = "resources/gameinfo";
const TString gkGameInfoExt = "xml";
//@todo merge this class into CGameTemplate
// they serve similar purposes, no real reason for them to be different classes
class CGameInfo
@ -50,14 +47,14 @@ public:
TString GetAreaName(const CAssetID& rkID) const;
// Accessors
inline EGame Game() const { return mGame; }
EGame Game() const { return mGame; }
// Static
static CGameInfo* GetGameInfo(EGame Game);
static EGame RoundGame(EGame Game);
static TString GetDefaultGameInfoPath(EGame Game);
inline static TString GetExtension() { return gkGameInfoExt; }
static TString GetExtension();
};
#endif // CGAMEINFO