STRG cooking bug fixes

This commit is contained in:
Jack Andersen 2017-01-26 16:22:52 -10:00
parent bcc524e084
commit 3a3298d48e
10 changed files with 47 additions and 30 deletions

View File

@ -95,7 +95,12 @@ static std::u16string::const_iterator CookTextureList(std::u16string& ret,
{
auto end = str.find(u',', it - str.begin());
if (end == std::u16string::npos)
Log.report(logvisor::Fatal, "Missing comma token while pasing font tag");
{
end = str.find(u';', it - str.begin());
if (end == std::u16string::npos)
Log.report(logvisor::Fatal,
"Missing comma/semicolon token while pasing font tag");
}
auto endIt = str.begin() + end + 1;
hecl::ProjectPath path =
UniqueIDBridge::MakePathFromString<UniqueID32>(
@ -234,20 +239,15 @@ static std::u16string CookString(const std::u16string& str)
{
ret.append(u"font=");
it += 5;
auto end = str.find(u',', it - str.begin());
if (end == std::u16string::npos)
Log.report(logvisor::Fatal, "Missing comma token while pasing font tag");
hecl::ProjectPath path =
UniqueIDBridge::MakePathFromString<UniqueID32>(
hecl::Char16ToUTF8(std::u16string(it, str.begin() + end + 1)));
ret.append(hecl::UTF8ToChar16(UniqueID32(path).toString()));
ret.push_back(u';');
auto scpos = str.find(u';', it - str.begin());
if (scpos == std::u16string::npos)
it = str.end();
else
it = str.begin() + scpos + 1;
Log.report(logvisor::Fatal, "Missing semicolon token while pasing font tag");
hecl::ProjectPath path =
UniqueIDBridge::MakePathFromString<UniqueID32>(
hecl::Char16ToUTF8(std::u16string(it, str.begin() + scpos)));
ret.append(hecl::UTF8ToChar16(UniqueID32(path).toString()));
ret.push_back(u';');
it = str.begin() + scpos + 1;
}
else
{
@ -336,6 +336,9 @@ void STRG::write(athena::io::IStreamWriter& writer) const
atUint32 strCount = STRG::count();
writer.writeUint32Big(strCount);
std::vector<std::u16string> strings;
strings.reserve(strCount * langs.size());
atUint32 offset = 0;
for (const std::pair<FourCC, std::vector<std::u16string>>& lang : langs)
{
@ -345,44 +348,52 @@ void STRG::write(athena::io::IStreamWriter& writer) const
atUint32 langStrCount = lang.second.size();
for (atUint32 s=0 ; s<strCount ; ++s)
{
atUint32 chCount = lang.second[s].size();
std::u16string str = CookString(lang.second[s]);
atUint32 chCount = str.size();
if (s < langStrCount)
offset += (chCount + 1) * 2;
else
offset += 1;
strings.push_back(std::move(str));
}
}
auto langIt = strings.cbegin();
for (const std::pair<FourCC, std::vector<std::u16string>>& lang : langs)
{
atUint32 langStrCount = lang.second.size();
atUint32 tableSz = strCount * 4;
auto strIt = langIt;
for (atUint32 s=0 ; s<strCount ; ++s)
{
if (s < langStrCount)
tableSz += (lang.second[s].size() + 1) * 2;
tableSz += ((strIt++)->size() + 1) * 2;
else
tableSz += 1;
}
writer.writeUint32Big(tableSz);
offset = strCount * 4;
strIt = langIt;
for (atUint32 s=0 ; s<strCount ; ++s)
{
writer.writeUint32Big(offset);
if (s < langStrCount)
offset += (lang.second[s].size() + 1) * 2;
offset += ((strIt++)->size() + 1) * 2;
else
offset += 1;
}
strIt = langIt;
for (atUint32 s=0 ; s<strCount ; ++s)
{
if (s < langStrCount)
writer.writeU16StringBig(CookString(lang.second[s]));
writer.writeU16StringBig(*strIt++);
else
writer.writeUByte(0);
}
langIt = strIt;
}
}
@ -399,7 +410,7 @@ size_t STRG::binarySize(size_t __isz) const
for (atUint32 s=0 ; s<strCount ; ++s)
{
if (s < langStrCount)
__isz += (lang.second[s].size() + 1) * 2;
__isz += (CookString(lang.second[s]).size() + 1) * 2;
else
__isz += 1;
}

View File

@ -62,7 +62,7 @@ struct STRG : ISTRG
{
STRG strg;
strg.read(rs);
athena::io::FileWriter writer(outPath.getAbsolutePath());
athena::io::TransactionalFileWriter writer(outPath.getAbsolutePath());
strg.toYAMLStream(writer);
return true;
}
@ -72,14 +72,14 @@ struct STRG : ISTRG
STRG strg;
athena::io::FileReader reader(inPath.getAbsolutePath());
strg.fromYAMLStream(reader);
athena::io::FileWriter ws(outPath.getAbsolutePath());
athena::io::TransactionalFileWriter ws(outPath.getAbsolutePath());
strg.write(ws);
return true;
}
static bool Cook(const STRG& strg, const hecl::ProjectPath& outPath)
{
athena::io::FileWriter ws(outPath.getAbsolutePath());
athena::io::TransactionalFileWriter ws(outPath.getAbsolutePath());
strg.write(ws);
return true;
}

View File

@ -68,7 +68,7 @@ struct STRG : ISTRG
{
STRG strg;
strg.read(rs);
athena::io::FileWriter writer(outPath.getAbsolutePath());
athena::io::TransactionalFileWriter writer(outPath.getAbsolutePath());
strg.toYAMLStream(writer);
return true;
}
@ -78,7 +78,7 @@ struct STRG : ISTRG
STRG strg;
athena::io::FileReader reader(inPath.getAbsolutePath());
strg.fromYAMLStream(reader);
athena::io::FileWriter ws(outPath.getAbsolutePath());
athena::io::TransactionalFileWriter ws(outPath.getAbsolutePath());
strg.write(ws);
return true;
}

View File

@ -67,7 +67,7 @@ struct STRG : ISTRG
static bool Extract(PAKEntryReadStream& rs, const hecl::ProjectPath& outPath)
{
std::unique_ptr<ISTRG> strg = LoadSTRG(rs);
athena::io::FileWriter writer(outPath.getAbsolutePath());
athena::io::TransactionalFileWriter writer(outPath.getAbsolutePath());
strg->toYAMLStream(writer);
return true;
}
@ -77,7 +77,7 @@ struct STRG : ISTRG
STRG strg;
athena::io::FileReader reader(inPath.getAbsolutePath());
strg.fromYAMLStream(reader);
athena::io::FileWriter ws(outPath.getAbsolutePath());
athena::io::TransactionalFileWriter ws(outPath.getAbsolutePath());
strg.write(ws);
return true;
}

View File

@ -785,6 +785,12 @@ struct SpecMP1 : SpecBase
gui.read(reader);
WriteTweak(gui, out);
}
else if (!classStr.compare(DNAMP1::CTweakPlayerControl::DNAType()))
{
DNAMP1::CTweakPlayerControl pc;
pc.read(reader);
WriteTweak(pc, out);
}
else if (!classStr.compare(DNAMP1::CTweakBall::DNAType()))
{
DNAMP1::CTweakBall ball;

View File

@ -15,7 +15,7 @@ CGuiTextSupport::CGuiTextSupport(ResId fontId, const CGuiTextProperties& props,
const zeus::CColor& fontCol, const zeus::CColor& outlineCol,
const zeus::CColor& geomCol, s32 padX, s32 padY, CSimplePool* store)
: x14_props(props), x24_fontColor(fontCol), x28_outlineColor(outlineCol),
x2c_geometryColor(geomCol), x34_extentX(padX), x38_extentY(padY)
x2c_geometryColor(geomCol), x34_extentX(padX), x38_extentY(padY), x5c_fontId(fontId)
{
x2cc_font = store->GetObj({SBIG('FONT'), fontId});
}

View File

@ -90,7 +90,7 @@ class CGuiTextSupport
bool x50_typeEnable = false;
float x54_chFadeTime = 0.1f;
float x58_chRate = 10.0f;
ResId x5c_fontId;
ResId x5c_fontId = -1;
std::experimental::optional<CTextRenderBuffer> x60_renderBuf;
std::vector<CToken> x2bc_assets;
TLockedToken<CRasterFont> x2cc_font;

View File

@ -299,7 +299,7 @@ ResId CTextParser::GetAssetIdFromString(const char16_t* str)
u8 g = GetColorValue(str + 2);
u8 b = GetColorValue(str + 4);
u8 a = GetColorValue(str + 6);
return (r << 24) | (g << 16) | (b << 8) | a;
return ((r << 24) | (g << 16) | (b << 8) | a) & 0xffffffff;
}
TToken<CRasterFont> CTextParser::GetFont(const char16_t* str, int len)

View File

@ -13,7 +13,7 @@ namespace urde
{
using FourCC = hecl::FourCC;
using ResId = s64;
using ResId = u64;
struct SObjectTag
{

2
hecl

@ -1 +1 @@
Subproject commit 1a079c247e07d1b3c4ebc384db27274f56a5e1a2
Subproject commit b41ad1084bc649fada23b9bad61a02a943455552