diff --git a/ZAPDTR/ZAPD/Main.cpp b/ZAPDTR/ZAPD/Main.cpp index a9f70eed583..45238bf7e65 100644 --- a/ZAPDTR/ZAPD/Main.cpp +++ b/ZAPDTR/ZAPD/Main.cpp @@ -330,7 +330,7 @@ int main(int argc, char* argv[]) auto start = std::chrono::steady_clock::now(); int fileListSize = fileList.size(); - Globals::Instance->singleThreaded = false; + //Globals::Instance->singleThreaded = false; for (int i = 0; i < fileListSize; i++) Globals::Instance->workerData[i] = new FileWorker(); diff --git a/ZAPDTR/ZAPD/ZFile.cpp b/ZAPDTR/ZAPD/ZFile.cpp index bb91cb8779c..880eda41429 100644 --- a/ZAPDTR/ZAPD/ZFile.cpp +++ b/ZAPDTR/ZAPD/ZFile.cpp @@ -801,9 +801,11 @@ void ZFile::GenerateSourceHeaderFiles() OutputFormatter formatter; formatter.Write("#pragma once\n"); + bool first = true; for (ZResource* res : resources) { - std::string resSrc = res->GetSourceOutputHeader(""); + std::string resSrc = res->GetSourceOutputHeader("", first); + first = false; formatter.Write(resSrc); if (resSrc != "") @@ -812,7 +814,7 @@ void ZFile::GenerateSourceHeaderFiles() for (auto& sym : symbolResources) { - formatter.Write(sym.second->GetSourceOutputHeader("")); + formatter.Write(sym.second->GetSourceOutputHeader("", first)); } formatter.Write(ProcessExterns()); diff --git a/ZAPDTR/ZAPD/ZResource.cpp b/ZAPDTR/ZAPD/ZResource.cpp index 391f54cf9b4..f054ac663cb 100644 --- a/ZAPDTR/ZAPD/ZResource.cpp +++ b/ZAPDTR/ZAPD/ZResource.cpp @@ -305,9 +305,13 @@ void ZResource::GetSourceOutputCode([[maybe_unused]] const std::string& prefix) } } -std::string ZResource::GetSourceOutputHeader([[maybe_unused]] const std::string& prefix) +std::string ZResource::GetSourceOutputHeader([[maybe_unused]] const std::string& prefix, bool first) { - static std::set myset; + static std::set totalset; + std::string s2 = name; + if (first) { + totalset.clear(); + } if (Globals::Instance->otrMode && genOTRDef) { std::string str = "";; @@ -348,11 +352,13 @@ std::string ZResource::GetSourceOutputHeader([[maybe_unused]] const std::string& else str += StringHelper::Sprintf("#define d%s \"__OTR__%s/%s\"", name.c_str(), outName.c_str(), nameStr.c_str()); - if (myset.find(name) == myset.end()) { + if (totalset.find(name) == totalset.end()) { +#ifdef _WIN32 + str += StringHelper::Sprintf("\nstatic const __declspec(align(2)) char %s[] = d%s;", name.c_str(), name.c_str()); +#else str += StringHelper::Sprintf("\nstatic const char %s[] __attribute__((aligned (2))) = d%s;", name.c_str(), name.c_str()); - myset.insert(name); - } else { - str += StringHelper::Sprintf("\nextern static const char %s[];", name.c_str()); +#endif + totalset.insert(name); } return str; diff --git a/ZAPDTR/ZAPD/ZResource.h b/ZAPDTR/ZAPD/ZResource.h index 8b1055a4bb5..637617f1d28 100644 --- a/ZAPDTR/ZAPD/ZResource.h +++ b/ZAPDTR/ZAPD/ZResource.h @@ -116,7 +116,7 @@ class ZResource [[nodiscard]] virtual std::string GetDefaultName(const std::string& prefix) const; virtual void GetSourceOutputCode(const std::string& prefix); - virtual std::string GetSourceOutputHeader(const std::string& prefix); + virtual std::string GetSourceOutputHeader(const std::string& prefix, bool first=true); virtual void CalcHash(); /** * Exports the resource to binary format diff --git a/ZAPDTR/ZAPD/ZString.cpp b/ZAPDTR/ZAPD/ZString.cpp index 965d4d6360d..b3fb9531a1e 100644 --- a/ZAPDTR/ZAPD/ZString.cpp +++ b/ZAPDTR/ZAPD/ZString.cpp @@ -48,7 +48,7 @@ std::string ZString::GetBodySourceCode() const return StringHelper::Sprintf("\t\"%s\"", strData.data()); } -std::string ZString::GetSourceOutputHeader([[maybe_unused]] const std::string& prefix) +std::string ZString::GetSourceOutputHeader([[maybe_unused]] const std::string& prefix, bool first) { return StringHelper::Sprintf("#define %s_macro \"%s\"", name.c_str(), strData.data()); } diff --git a/ZAPDTR/ZAPD/ZString.h b/ZAPDTR/ZAPD/ZString.h index 6c58ebdcb55..7e6d82f79b9 100644 --- a/ZAPDTR/ZAPD/ZString.h +++ b/ZAPDTR/ZAPD/ZString.h @@ -13,7 +13,7 @@ class ZString : public ZResource Declaration* DeclareVar(const std::string& prefix, const std::string& bodyStr) override; std::string GetBodySourceCode() const override; - std::string GetSourceOutputHeader(const std::string& prefix) override; + std::string GetSourceOutputHeader(const std::string& prefix, bool first = true) override; std::string GetSourceTypeName() const override; ZResourceType GetResourceType() const override; diff --git a/ZAPDTR/ZAPD/ZSymbol.cpp b/ZAPDTR/ZAPD/ZSymbol.cpp index eabfc2faaea..c6cd83eaaa4 100644 --- a/ZAPDTR/ZAPD/ZSymbol.cpp +++ b/ZAPDTR/ZAPD/ZSymbol.cpp @@ -74,7 +74,7 @@ size_t ZSymbol::GetRawDataSize() const return typeSize; } -std::string ZSymbol::GetSourceOutputHeader([[maybe_unused]] const std::string& prefix) +std::string ZSymbol::GetSourceOutputHeader([[maybe_unused]] const std::string& prefix, bool first) { if (isArray) { diff --git a/ZAPDTR/ZAPD/ZSymbol.h b/ZAPDTR/ZAPD/ZSymbol.h index 7cb14aa9b44..3f0d69cfa95 100644 --- a/ZAPDTR/ZAPD/ZSymbol.h +++ b/ZAPDTR/ZAPD/ZSymbol.h @@ -18,7 +18,7 @@ class ZSymbol : public ZResource Declaration* DeclareVar(const std::string& prefix, const std::string& bodyStr) override; - std::string GetSourceOutputHeader(const std::string& prefix) override; + std::string GetSourceOutputHeader(const std::string& prefix, bool first=true) override; std::string GetSourceTypeName() const override; ZResourceType GetResourceType() const override;