Skip to content

Commit

Permalink
fix build on latest VS version
Browse files Browse the repository at this point in the history
  • Loading branch information
RektInator committed Nov 29, 2020
1 parent d02743a commit 4a94fc6
Show file tree
Hide file tree
Showing 19 changed files with 23 additions and 122 deletions.
1 change: 1 addition & 0 deletions premake5.lua
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ workspace "zonetool"
filter {}

buildoptions "/std:c++latest"
buildoptions "/Zc:strictStrings-"
systemversion "latest"
symbols "On"
editandcontinue "Off"
Expand Down
2 changes: 1 addition & 1 deletion src/CODO/Assets/StringTable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ namespace ZoneTool::CODO
fread(buf.get(), len, 1, fp);
fclose(fp);

std::vector<std::string> rows = split(std::string(buf.get()), '\n');
std::vector<std::string> rows = split(buf.get(), '\n');

for (auto& row : rows)
{
Expand Down
2 changes: 1 addition & 1 deletion src/CODO/CODO.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion src/CODO/CODO.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ namespace ZoneTool::CODO
std::shared_ptr<ZoneBuffer> 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;
Expand Down
2 changes: 1 addition & 1 deletion src/IW3/IW3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion src/IW3/IW3.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ namespace ZoneTool
std::shared_ptr<ZoneBuffer> 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;
Expand Down
2 changes: 1 addition & 1 deletion src/IW4/IW4.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion src/IW4/IW4.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ namespace ZoneTool
std::shared_ptr<ZoneBuffer> 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;
Expand Down
12 changes: 6 additions & 6 deletions src/IW5/Assets/AttachmentDef.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}
2 changes: 1 addition & 1 deletion src/IW5/Assets/ComWorld.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/IW5/Assets/LeaderBoardDef.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/IW5/Assets/LightDef.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/IW5/Assets/StructuredDataDef.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ namespace ZoneTool

void patchEnumWithMap(StructuredDataDefSet* data, enumType_s enumIndex, std::map<int, newEnumEntry*> map);

void IStructuredDataDef::manipulate(StructuredDataDefSet* data);
void manipulate(StructuredDataDefSet* data);

public:
IStructuredDataDef();
Expand Down
2 changes: 1 addition & 1 deletion src/IW5/IW5.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion src/IW5/IW5.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ namespace ZoneTool
std::shared_ptr<ZoneBuffer> 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;
Expand Down
100 changes: 0 additions & 100 deletions src/IW5/Structs.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion src/ZoneTool/ZoneTool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
2 changes: 1 addition & 1 deletion src/ZoneUtils/Linker.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion src/ZoneUtils/ZoneUtils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ static std::vector<std::string> split(const std::string& rawInput, const std::ve
return strings;
}

static std::vector<std::string> split(std::string& str, char delimiter)
static std::vector<std::string> split(const std::string& str, char delimiter)
{
return split(str, std::vector<char>({delimiter}));
}
Expand Down

0 comments on commit 4a94fc6

Please sign in to comment.