diff --git a/.gitmodules b/.gitmodules index 2d3e5d47..be58e14f 100644 --- a/.gitmodules +++ b/.gitmodules @@ -6,3 +6,6 @@ path = deps/zlib url = https://github.com/madler/zlib.git branch = master +[submodule "deps/json11"] + path = deps/json11 + url = https://github.com/dropbox/json11.git diff --git a/deps/json11 b/deps/json11 new file mode 160000 index 00000000..a6a661e9 --- /dev/null +++ b/deps/json11 @@ -0,0 +1 @@ +Subproject commit a6a661e9240e0018b6be0f67a9e9ca2a6be2626f diff --git a/premake5.lua b/premake5.lua index 061f7601..039fcc29 100644 --- a/premake5.lua +++ b/premake5.lua @@ -87,8 +87,8 @@ workspace "iw4x" pchsource "src/STDInclude.cpp" -- real path -- Dependency on zlib - links { "zlib" } - includedirs { "./deps/zlib" } + links { "zlib", "json11" } + includedirs { "./deps/zlib", "./deps/json11" } -- Virtual paths if not _OPTIONS["no-new-structure"] then @@ -142,3 +142,23 @@ workspace "iw4x" configuration "*Static" kind "StaticLib" removedefines { "ZLIB_DLL" } + + + -- json11 + project "json11" + language "C++" + + files + { + "./deps/json11/*.cpp", + "./deps/json11/*.hpp" + } + + -- remove dropbox's testing code + removefiles { "./deps/json11/test.cpp" } + + -- not our code, ignore POSIX usage warnings for now + warnings "Off" + + -- always build as static lib, as json11 doesn't export anything + kind "StaticLib" diff --git a/src/Components/Modules/FastFiles.cpp b/src/Components/Modules/FastFiles.cpp index 5a525e17..0b75a025 100644 --- a/src/Components/Modules/FastFiles.cpp +++ b/src/Components/Modules/FastFiles.cpp @@ -17,9 +17,6 @@ namespace Components info.name = "dlc2_ui_mp"; data.push_back(info); - //info.name = "penis"; - //data.push_back(info); - Game::DB_LoadXAssets(data.data(), data.size(), sync); } diff --git a/src/Components/Modules/ZoneBuilder.cpp b/src/Components/Modules/ZoneBuilder.cpp index f4c9e6b9..c1b4cee8 100644 --- a/src/Components/Modules/ZoneBuilder.cpp +++ b/src/Components/Modules/ZoneBuilder.cpp @@ -20,7 +20,10 @@ namespace Components buffer.append((char*)&header, sizeof(header)); std::string zoneBuffer; - zoneBuffer.resize(sizeof(XFile)); + + XFile file; + ZeroMemory(&file, sizeof(file)); + zoneBuffer.append((char*)&file, sizeof(file)); // Fill zone XAssetList list; @@ -29,12 +32,67 @@ namespace Components list.stringList.count = 0; list.stringList.strings = 0; + list.assetCount = 2; + + list.assets = (Game::XAsset*)0xFFFFFFFF; + zoneBuffer.append((char*)&list, sizeof(list)); + // Crappy assetlist entry + DWORD type = Game::XAssetType::ASSET_TYPE_LOCALIZE; + zoneBuffer.append((char*)&type, sizeof(type)); + zoneBuffer.append((char*)&list.assets, sizeof(list.assets)); // Hue + + type = Game::XAssetType::ASSET_TYPE_RAWFILE; + zoneBuffer.append((char*)&type, sizeof(type)); + zoneBuffer.append((char*)&list.assets, sizeof(list.assets)); // Hue + + // Localized entry + zoneBuffer.append((char*)&list.assets, sizeof(list.assets)); // Hue + zoneBuffer.append((char*)&list.assets, sizeof(list.assets)); // Hue + zoneBuffer.append("MENU_PENIS"); + zoneBuffer.append("\0", 1); + + zoneBuffer.append("PENIS"); + zoneBuffer.append("\0", 1); + + // Obligatory rawfile + struct Rawfile + { + const char* name; + int sizeCompressed; + int sizeUnCompressed; + char * compressedData; + }; + + char* _data = "map mp_rust"; + + Rawfile data; + data.name = (char*)0xFFFFFFFF; + data.compressedData = (char*)0xFFFFFFFF; + data.sizeUnCompressed = 0; + data.sizeCompressed = strlen(_data) + 1; + + zoneBuffer.append((char*)&data, sizeof(data)); + + zoneBuffer.append("zob.cfg"); + zoneBuffer.append("\0", 1); + + zoneBuffer.append(_data); + zoneBuffer.append("\0", 1); + XFile* zone = (XFile*)zoneBuffer.data(); ZeroMemory(zone, sizeof(XFile)); - zone->size = zoneBuffer.size() - sizeof(XFile); + zone->size = zoneBuffer.size() - 40; + + zone->blockSize[3] = zoneBuffer.size() * 2; + zone->blockSize[0] = zoneBuffer.size() * 2; + +// for (int i = 0; i < 8; i++) +// { +// zone->blockSize[i] = zoneBuffer.size() * 2; +// } auto compressedData = Utils::Compression::ZLib::Compress(zoneBuffer); buffer.append(compressedData); @@ -57,14 +115,24 @@ namespace Components return Flags::HasFlag("zonebuilder"); } + void TestZoneLoading(Game::XZoneInfo *zoneInfo, unsigned int zoneCount, int sync) + { + std::vector data; + Utils::Merge(data, zoneInfo, zoneCount); + + data.push_back({ "penis", zoneInfo->allocFlags, zoneInfo->freeFlags }); + + Game::DB_LoadXAssets(data.data(), data.size(), sync); + } + ZoneBuilder::ZoneBuilder() { if (ZoneBuilder::IsEnabled()) { - auto data = Zone("").Build(); + auto data = Zone("penis").Build(); FILE* fp; - fopen_s(&fp, "penis.ff", "wb"); + fopen_s(&fp, "zone/patch/penis.ff", "wb"); if (fp) { @@ -74,5 +142,7 @@ namespace Components ExitProcess(0); } + + //Utils::Hook(0x60B4AC, TestZoneLoading, HOOK_CALL).Install()->Quick(); } } diff --git a/src/STDInclude.hpp b/src/STDInclude.hpp index ce9f3a85..4bbbe225 100644 --- a/src/STDInclude.hpp +++ b/src/STDInclude.hpp @@ -26,8 +26,10 @@ #include #include +// Submodules #define ZLIB_CONST #include +#include #include "Utils\Utils.hpp" #include "Utils\WebIO.hpp"