Merge pull request #49 from lioncash/resource

CStringTable: Use std::array instead of std::vector
This commit is contained in:
Phillip Stephens 2019-09-01 11:06:15 -07:00 committed by GitHub
commit 12238e5c30
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 8 deletions

View File

@ -1,11 +1,17 @@
#include "CStringTable.hpp"
#include "CToken.hpp"
#include "Runtime/GuiSys/CStringTable.hpp"
#include <array>
#include "Runtime/CToken.hpp"
namespace urde {
const std::vector<FourCC> CStringTable::skLanguages = {FOURCC('ENGL'), FOURCC('FREN'), FOURCC('GERM'), FOURCC('SPAN'),
FOURCC('ITAL'), FOURCC('DUTC'), FOURCC('JAPN')};
namespace {
constexpr std::array languages{
FOURCC('ENGL'), FOURCC('FREN'), FOURCC('GERM'), FOURCC('SPAN'), FOURCC('ITAL'), FOURCC('DUTC'), FOURCC('JAPN'),
};
} // Anonymous namespace
FourCC CStringTable::mCurrentLanguage = CStringTable::skLanguages[0];
FourCC CStringTable::mCurrentLanguage = languages[0];
CStringTable::CStringTable(CInputStream& in) { LoadStringTable(in); }
@ -64,7 +70,7 @@ const char16_t* CStringTable::GetString(s32 str) const {
return reinterpret_cast<char16_t*>(x4_data.get() + off);
}
void CStringTable::SetLanguage(s32 lang) { mCurrentLanguage = skLanguages[lang]; }
void CStringTable::SetLanguage(s32 lang) { mCurrentLanguage = languages[lang]; }
CFactoryFnReturn FStringTableFactory(const SObjectTag&, CInputStream& in, const CVParamTransfer&,
CObjectReference* selfRef) {

View File

@ -5,10 +5,9 @@
namespace urde {
class CStringTable {
static const std::vector<FourCC> skLanguages;
static FourCC mCurrentLanguage;
u32 x0_stringCount = 0;
std::unique_ptr<u8[]> x4_data = 0;
std::unique_ptr<u8[]> x4_data;
u32 m_bufLen;
public: