From 4a94fc6915fc9be1de9ab7dff4737fd8569a06c3 Mon Sep 17 00:00:00 2001 From: RektInator <7003455+RektInator@users.noreply.github.com> Date: Sun, 29 Nov 2020 13:36:13 +0100 Subject: [PATCH] fix build on latest VS version --- premake5.lua | 1 + src/CODO/Assets/StringTable.cpp | 2 +- src/CODO/CODO.cpp | 2 +- src/CODO/CODO.hpp | 2 +- src/IW3/IW3.cpp | 2 +- src/IW3/IW3.hpp | 2 +- src/IW4/IW4.cpp | 2 +- src/IW4/IW4.hpp | 2 +- src/IW5/Assets/AttachmentDef.cpp | 12 ++-- src/IW5/Assets/ComWorld.cpp | 2 +- src/IW5/Assets/LeaderBoardDef.cpp | 2 +- src/IW5/Assets/LightDef.cpp | 2 +- src/IW5/Assets/StructuredDataDef.hpp | 2 +- src/IW5/IW5.cpp | 2 +- src/IW5/IW5.hpp | 2 +- src/IW5/Structs.hpp | 100 --------------------------- src/ZoneTool/ZoneTool.cpp | 2 +- src/ZoneUtils/Linker.hpp | 2 +- src/ZoneUtils/ZoneUtils.hpp | 2 +- 19 files changed, 23 insertions(+), 122 deletions(-) diff --git a/premake5.lua b/premake5.lua index 0357a09..a4da8b1 100644 --- a/premake5.lua +++ b/premake5.lua @@ -45,6 +45,7 @@ workspace "zonetool" filter {} buildoptions "/std:c++latest" + buildoptions "/Zc:strictStrings-" systemversion "latest" symbols "On" editandcontinue "Off" diff --git a/src/CODO/Assets/StringTable.cpp b/src/CODO/Assets/StringTable.cpp index 94a50e1..632c012 100644 --- a/src/CODO/Assets/StringTable.cpp +++ b/src/CODO/Assets/StringTable.cpp @@ -31,7 +31,7 @@ namespace ZoneTool::CODO fread(buf.get(), len, 1, fp); fclose(fp); - std::vector rows = split(std::string(buf.get()), '\n'); + std::vector rows = split(buf.get(), '\n'); for (auto& row : rows) { diff --git a/src/CODO/CODO.cpp b/src/CODO/CODO.cpp index 330abdf..b23222f 100644 --- a/src/CODO/CODO.cpp +++ b/src/CODO/CODO.cpp @@ -76,7 +76,7 @@ namespace ZoneTool::CODO { } - bool Linker::is_valid_asset_type(std::string& type) + bool Linker::is_valid_asset_type(const std::string& type) { return this->type_to_int(type) >= 0; } diff --git a/src/CODO/CODO.hpp b/src/CODO/CODO.hpp index a4eb2a4..26af6a2 100644 --- a/src/CODO/CODO.hpp +++ b/src/CODO/CODO.hpp @@ -31,7 +31,7 @@ namespace ZoneTool::CODO std::shared_ptr alloc_buffer() override; void load_zone(const std::string& name) override; void unload_zones() override; - bool is_valid_asset_type(std::string& type) override; + bool is_valid_asset_type(const std::string& type) override; std::int32_t type_to_int(std::string type) override; std::string type_to_string(std::int32_t type) override; bool supports_building() override; diff --git a/src/IW3/IW3.cpp b/src/IW3/IW3.cpp index 57f36b1..cf38ea4 100644 --- a/src/IW3/IW3.cpp +++ b/src/IW3/IW3.cpp @@ -308,7 +308,7 @@ namespace ZoneTool { } - bool Linker::is_valid_asset_type(std::string& type) + bool Linker::is_valid_asset_type(const std::string& type) { return this->type_to_int(type) >= 0; } diff --git a/src/IW3/IW3.hpp b/src/IW3/IW3.hpp index 586aa4d..55ac226 100644 --- a/src/IW3/IW3.hpp +++ b/src/IW3/IW3.hpp @@ -50,7 +50,7 @@ namespace ZoneTool std::shared_ptr alloc_buffer() override; void load_zone(const std::string& name) override; void unload_zones() override; - bool is_valid_asset_type(std::string& type) override; + bool is_valid_asset_type(const std::string& type) override; std::int32_t type_to_int(std::string type) override; std::string type_to_string(std::int32_t type) override; bool supports_building() override; diff --git a/src/IW4/IW4.cpp b/src/IW4/IW4.cpp index e2d2345..23a3d83 100644 --- a/src/IW4/IW4.cpp +++ b/src/IW4/IW4.cpp @@ -814,7 +814,7 @@ char**>(0x00799278)[type]); { } - bool Linker::is_valid_asset_type(std::string& type) + bool Linker::is_valid_asset_type(const std::string& type) { return this->type_to_int(type) >= 0; } diff --git a/src/IW4/IW4.hpp b/src/IW4/IW4.hpp index 98c4180..b733634 100644 --- a/src/IW4/IW4.hpp +++ b/src/IW4/IW4.hpp @@ -30,7 +30,7 @@ namespace ZoneTool std::shared_ptr alloc_buffer() override; void load_zone(const std::string& name) override; void unload_zones() override; - bool is_valid_asset_type(std::string& type) override; + bool is_valid_asset_type(const std::string& type) override; std::int32_t type_to_int(std::string type) override; std::string type_to_string(std::int32_t type) override; bool supports_building() override; diff --git a/src/IW5/Assets/AttachmentDef.cpp b/src/IW5/Assets/AttachmentDef.cpp index 40d8b35..b304dc6 100644 --- a/src/IW5/Assets/AttachmentDef.cpp +++ b/src/IW5/Assets/AttachmentDef.cpp @@ -517,14 +517,14 @@ namespace ZoneTool void IAttachmentDef::dump(AttachmentDef* asset) { - Json& data = asset->ToJson(); + //const auto data = asset->ToJson(); - std::string path = "attachments\\mp\\"s + asset->szInternalName; - std::string json = data.dump(4); + //std::string path = "attachments\\mp\\"s + asset->szInternalName; + //std::string json = data.dump(4); - auto file = FileSystem::FileOpen(path, "w"s); - fwrite(json.data(), json.size(), 1, file); - FileSystem::FileClose(file); + //auto file = FileSystem::FileOpen(path, "w"s); + //fwrite(json.data(), json.size(), 1, file); + //FileSystem::FileClose(file); } } } diff --git a/src/IW5/Assets/ComWorld.cpp b/src/IW5/Assets/ComWorld.cpp index 17eb430..160905c 100644 --- a/src/IW5/Assets/ComWorld.cpp +++ b/src/IW5/Assets/ComWorld.cpp @@ -155,7 +155,7 @@ namespace ZoneTool void IComWorld::dump(ComWorld* asset, bool fromIW5) { - Json& data = asset->ToJson(fromIW5); + const auto data = asset->ToJson(fromIW5); std::string path = asset->name + ".comworld"s; std::string json = data.dump(4); diff --git a/src/IW5/Assets/LeaderBoardDef.cpp b/src/IW5/Assets/LeaderBoardDef.cpp index d21df2a..66848f1 100644 --- a/src/IW5/Assets/LeaderBoardDef.cpp +++ b/src/IW5/Assets/LeaderBoardDef.cpp @@ -79,7 +79,7 @@ namespace ZoneTool void ILeaderBoardDef::dump(LeaderBoardDef* asset) { - Json& data = asset->ToJson(); + const auto data = asset->ToJson(); std::string path = "leaderboards\\"s + asset->name; std::string json = data.dump(4); diff --git a/src/IW5/Assets/LightDef.cpp b/src/IW5/Assets/LightDef.cpp index 391bf5a..5ab5a9a 100644 --- a/src/IW5/Assets/LightDef.cpp +++ b/src/IW5/Assets/LightDef.cpp @@ -134,7 +134,7 @@ namespace ZoneTool void ILightDef::dump(GfxLightDef* asset) { - Json& data = asset->ToJson(); + const auto data = asset->ToJson(); std::string path = "lights/"s + asset->name + ".lightdef"s; std::string json = data.dump(4); diff --git a/src/IW5/Assets/StructuredDataDef.hpp b/src/IW5/Assets/StructuredDataDef.hpp index 142de66..59d3407 100644 --- a/src/IW5/Assets/StructuredDataDef.hpp +++ b/src/IW5/Assets/StructuredDataDef.hpp @@ -54,7 +54,7 @@ namespace ZoneTool void patchEnumWithMap(StructuredDataDefSet* data, enumType_s enumIndex, std::map map); - void IStructuredDataDef::manipulate(StructuredDataDefSet* data); + void manipulate(StructuredDataDefSet* data); public: IStructuredDataDef(); diff --git a/src/IW5/IW5.cpp b/src/IW5/IW5.cpp index 8d6cbee..aaf143c 100644 --- a/src/IW5/IW5.cpp +++ b/src/IW5/IW5.cpp @@ -107,7 +107,7 @@ namespace ZoneTool DB_LoadXAssets(&zone, 1, 1); } - bool Linker::is_valid_asset_type(std::string& type) + bool Linker::is_valid_asset_type(const std::string& type) { return this->type_to_int(type) >= 0; } diff --git a/src/IW5/IW5.hpp b/src/IW5/IW5.hpp index 3f78b3b..91d7230 100644 --- a/src/IW5/IW5.hpp +++ b/src/IW5/IW5.hpp @@ -35,7 +35,7 @@ namespace ZoneTool std::shared_ptr alloc_buffer() override; void load_zone(const std::string& name) override; void unload_zones() override; - bool is_valid_asset_type(std::string& type) override; + bool is_valid_asset_type(const std::string& type) override; std::int32_t type_to_int(std::string type) override; std::string type_to_string(std::int32_t type) override; bool supports_building() override; diff --git a/src/IW5/Structs.hpp b/src/IW5/Structs.hpp index e4aa42a..eb6bef8 100644 --- a/src/IW5/Structs.hpp +++ b/src/IW5/Structs.hpp @@ -4435,106 +4435,6 @@ namespace ZoneTool bool hideIronSightsWithThisAttachment; bool shareAmmoWithAlt; char pad[2]; - - void Parse(Json& data, ZoneMemory* mem) - { - JSON_PARSE_STRING(szInternalName); - JSON_PARSE_STRING(szDisplayName); - - JSON_PARSE_INT32(type); - JSON_PARSE_INT32(weaponType); - JSON_PARSE_INT32(weapClass); - - JSON_PARSE_FLOAT(ammunitionScale); - JSON_PARSE_FLOAT(damageScale); - JSON_PARSE_FLOAT(damageScaleMin); - JSON_PARSE_FLOAT(stateTimersScale); - JSON_PARSE_FLOAT(fireTimersScale); - JSON_PARSE_FLOAT(idleSettingsScale); - JSON_PARSE_FLOAT(adsSettingsScale); - JSON_PARSE_FLOAT(adsSettingsScaleMain); - JSON_PARSE_FLOAT(hipSpreadScale); - JSON_PARSE_FLOAT(gunKickScale); - JSON_PARSE_FLOAT(viewKickScale); - JSON_PARSE_FLOAT(viewCenterScale); - JSON_PARSE_FLOAT(loadIndex); - JSON_PARSE_FLOAT(hideIronSightsWithThisAttachment); - JSON_PARSE_FLOAT(shareAmmoWithAlt); - JSON_PARSE_FLOAT(viewKickScale); - JSON_PARSE_FLOAT(viewCenterScale); - - JSON_PARSE_STRUCT(ammogeneral, AttAmmoGeneral); - JSON_PARSE_STRUCT(sight, AttSight); - JSON_PARSE_STRUCT(reload, AttReload); - JSON_PARSE_STRUCT(addOns, AttAddOns); - JSON_PARSE_STRUCT(general, AttGeneral); - JSON_PARSE_STRUCT(ammunition, AttAmmunition); - JSON_PARSE_STRUCT(idleSettings, AttIdleSettings); - JSON_PARSE_STRUCT(damage, AttDamage); - JSON_PARSE_STRUCT(locationDamage, AttLocationDamage); - JSON_PARSE_STRUCT(scopeDriftSettings, AttScopeDriftSettings); - JSON_PARSE_STRUCT(adsSettings, AttADSSettings); - JSON_PARSE_STRUCT(adsSettingsMain, AttADSSettings); - JSON_PARSE_STRUCT(hipSpread, AttHipSpread); - JSON_PARSE_STRUCT(gunKick, AttGunKick); - JSON_PARSE_STRUCT(viewKick, AttViewKick); - JSON_PARSE_STRUCT(adsOverlay, AttADSOverlay); - JSON_PARSE_STRUCT(ui, AttUI); - JSON_PARSE_STRUCT(rumbles, AttRumbles); - JSON_PARSE_STRUCT(projectile, AttProjectile); - } - - Json ToJson() - { - Json data; - - JSON_STRING(szInternalName); - JSON_STRING(szDisplayName); - - JSON_FIELD(type); - JSON_FIELD(weaponType); - JSON_FIELD(weapClass); - - JSON_FIELD(ammunitionScale); - JSON_FIELD(damageScale); - JSON_FIELD(damageScaleMin); - JSON_FIELD(stateTimersScale); - JSON_FIELD(fireTimersScale); - JSON_FIELD(idleSettingsScale); - JSON_FIELD(adsSettingsScale); - JSON_FIELD(adsSettingsScaleMain); - JSON_FIELD(hipSpreadScale); - JSON_FIELD(gunKickScale); - JSON_FIELD(viewKickScale); - JSON_FIELD(viewCenterScale); - JSON_FIELD(loadIndex); - JSON_FIELD(hideIronSightsWithThisAttachment); - JSON_FIELD(shareAmmoWithAlt); - JSON_FIELD(viewKickScale); - JSON_FIELD(viewCenterScale); - - JSON_STRUCT(ammogeneral); - JSON_STRUCT(sight); - JSON_STRUCT(reload); - JSON_STRUCT(addOns); - JSON_STRUCT(general); - JSON_STRUCT(ammunition); - JSON_STRUCT(idleSettings); - JSON_STRUCT(damage); - JSON_STRUCT(locationDamage); - JSON_STRUCT(scopeDriftSettings); - JSON_STRUCT(adsSettings); - JSON_STRUCT(adsSettingsMain); - JSON_STRUCT(hipSpread); - JSON_STRUCT(gunKick); - JSON_STRUCT(viewKick); - JSON_STRUCT(adsOverlay); - JSON_STRUCT(ui); - JSON_STRUCT(rumbles); - JSON_STRUCT(projectile); - - return data; - } }; #pragma pack(push, 4) diff --git a/src/ZoneTool/ZoneTool.cpp b/src/ZoneTool/ZoneTool.cpp index 178c683..ff06e80 100644 --- a/src/ZoneTool/ZoneTool.cpp +++ b/src/ZoneTool/ZoneTool.cpp @@ -269,7 +269,7 @@ namespace ZoneTool { if (row->numOfFields_ >= 2) { - if (linker->is_valid_asset_type(std::string(row->fields_[0]))) + if (linker->is_valid_asset_type(row->fields_[0])) { try { diff --git a/src/ZoneUtils/Linker.hpp b/src/ZoneUtils/Linker.hpp index 7a00400..d9a21bc 100644 --- a/src/ZoneUtils/Linker.hpp +++ b/src/ZoneUtils/Linker.hpp @@ -26,7 +26,7 @@ namespace ZoneTool virtual void load_zone(const std::string& name) = 0; virtual void unload_zones() = 0; - virtual bool is_valid_asset_type(std::string& type) = 0; + virtual bool is_valid_asset_type(const std::string& type) = 0; virtual std::int32_t type_to_int(std::string type) = 0; virtual std::string type_to_string(std::int32_t type) = 0; diff --git a/src/ZoneUtils/ZoneUtils.hpp b/src/ZoneUtils/ZoneUtils.hpp index acaca4a..8bfe2fc 100644 --- a/src/ZoneUtils/ZoneUtils.hpp +++ b/src/ZoneUtils/ZoneUtils.hpp @@ -251,7 +251,7 @@ static std::vector split(const std::string& rawInput, const std::ve return strings; } -static std::vector split(std::string& str, char delimiter) +static std::vector split(const std::string& str, char delimiter) { return split(str, std::vector({delimiter})); }