Some more zone experiments and json11 submodule.

This commit is contained in:
momo5502 2016-01-05 14:39:04 +01:00
parent 4c26a72cd8
commit 852c88c3b5
6 changed files with 102 additions and 9 deletions

3
.gitmodules vendored
View File

@ -6,3 +6,6 @@
path = deps/zlib path = deps/zlib
url = https://github.com/madler/zlib.git url = https://github.com/madler/zlib.git
branch = master branch = master
[submodule "deps/json11"]
path = deps/json11
url = https://github.com/dropbox/json11.git

1
deps/json11 vendored Submodule

@ -0,0 +1 @@
Subproject commit a6a661e9240e0018b6be0f67a9e9ca2a6be2626f

View File

@ -87,8 +87,8 @@ workspace "iw4x"
pchsource "src/STDInclude.cpp" -- real path pchsource "src/STDInclude.cpp" -- real path
-- Dependency on zlib -- Dependency on zlib
links { "zlib" } links { "zlib", "json11" }
includedirs { "./deps/zlib" } includedirs { "./deps/zlib", "./deps/json11" }
-- Virtual paths -- Virtual paths
if not _OPTIONS["no-new-structure"] then if not _OPTIONS["no-new-structure"] then
@ -142,3 +142,23 @@ workspace "iw4x"
configuration "*Static" configuration "*Static"
kind "StaticLib" kind "StaticLib"
removedefines { "ZLIB_DLL" } 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"

View File

@ -17,9 +17,6 @@ namespace Components
info.name = "dlc2_ui_mp"; info.name = "dlc2_ui_mp";
data.push_back(info); data.push_back(info);
//info.name = "penis";
//data.push_back(info);
Game::DB_LoadXAssets(data.data(), data.size(), sync); Game::DB_LoadXAssets(data.data(), data.size(), sync);
} }

View File

@ -20,7 +20,10 @@ namespace Components
buffer.append((char*)&header, sizeof(header)); buffer.append((char*)&header, sizeof(header));
std::string zoneBuffer; std::string zoneBuffer;
zoneBuffer.resize(sizeof(XFile));
XFile file;
ZeroMemory(&file, sizeof(file));
zoneBuffer.append((char*)&file, sizeof(file));
// Fill zone // Fill zone
XAssetList list; XAssetList list;
@ -29,12 +32,67 @@ namespace Components
list.stringList.count = 0; list.stringList.count = 0;
list.stringList.strings = 0; list.stringList.strings = 0;
list.assetCount = 2;
list.assets = (Game::XAsset*)0xFFFFFFFF;
zoneBuffer.append((char*)&list, sizeof(list)); 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(); XFile* zone = (XFile*)zoneBuffer.data();
ZeroMemory(zone, sizeof(XFile)); 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); auto compressedData = Utils::Compression::ZLib::Compress(zoneBuffer);
buffer.append(compressedData); buffer.append(compressedData);
@ -57,14 +115,24 @@ namespace Components
return Flags::HasFlag("zonebuilder"); return Flags::HasFlag("zonebuilder");
} }
void TestZoneLoading(Game::XZoneInfo *zoneInfo, unsigned int zoneCount, int sync)
{
std::vector<Game::XZoneInfo> data;
Utils::Merge(data, zoneInfo, zoneCount);
data.push_back({ "penis", zoneInfo->allocFlags, zoneInfo->freeFlags });
Game::DB_LoadXAssets(data.data(), data.size(), sync);
}
ZoneBuilder::ZoneBuilder() ZoneBuilder::ZoneBuilder()
{ {
if (ZoneBuilder::IsEnabled()) if (ZoneBuilder::IsEnabled())
{ {
auto data = Zone("").Build(); auto data = Zone("penis").Build();
FILE* fp; FILE* fp;
fopen_s(&fp, "penis.ff", "wb"); fopen_s(&fp, "zone/patch/penis.ff", "wb");
if (fp) if (fp)
{ {
@ -74,5 +142,7 @@ namespace Components
ExitProcess(0); ExitProcess(0);
} }
//Utils::Hook(0x60B4AC, TestZoneLoading, HOOK_CALL).Install()->Quick();
} }
} }

View File

@ -26,8 +26,10 @@
#include <chrono> #include <chrono>
#include <future> #include <future>
// Submodules
#define ZLIB_CONST #define ZLIB_CONST
#include <zlib.h> #include <zlib.h>
#include <json11.hpp>
#include "Utils\Utils.hpp" #include "Utils\Utils.hpp"
#include "Utils\WebIO.hpp" #include "Utils\WebIO.hpp"