From aea12a25ef167b676937803e69e75a29ac5aebe7 Mon Sep 17 00:00:00 2001 From: momo5502 Date: Sun, 9 Oct 2016 12:34:06 +0200 Subject: [PATCH] Mirror map when dumped --- src/Components/Modules/AssetHandler.cpp | 26 ++++++++++++++++++ src/Components/Modules/Maps.cpp | 5 ++-- src/Components/Modules/Zones.cpp | 35 +++++++++++++++++++++++++ src/Game/Structs.hpp | 21 +++++++++++++++ 4 files changed, 84 insertions(+), 3 deletions(-) diff --git a/src/Components/Modules/AssetHandler.cpp b/src/Components/Modules/AssetHandler.cpp index 00eaa136..687483c4 100644 --- a/src/Components/Modules/AssetHandler.cpp +++ b/src/Components/Modules/AssetHandler.cpp @@ -132,6 +132,32 @@ namespace Components } } + if (type == 21) + { + //asset->gfxMap->dpvs.staticSurfaceCount = 0; +// +// for (unsigned int i = 0; i < asset->gfxMap->dpvs.staticSurfaceCount; ++i) +// { +// //OutputDebugStringA(Utils::String::VA("%i\n", asset->gfxMap->dpvs.sortedSurfIndex[i] & 0xFFFF)); +// asset->gfxMap->dpvs.sortedSurfIndex[i] = i; +// } +// OutputDebugStringA("\n"); + +// for (int i = 0; i < asset->gfxMap->unknown2; ++i) +// { +// if (i < (asset->gfxMap->unknown2 - 1)) +// { +// asset->gfxMap->dpvs.surfaceMaterials[i].packed = 0; +// } +// } + } + + if (type == 5 && Utils::String::StartsWith(name, "wc/")) + { + //asset->material->sortKey = rand() & 0xFF; + OutputDebugStringA(Utils::String::VA("%s: %X %s", FastFiles::Current().data(), asset->material->sortKey & 0xFF, asset->material->name)); + } + if (type == 5 && name == "wc/codo_ui_viewer_black_decal3"s) { asset->material->sortKey = 0xE; diff --git a/src/Components/Modules/Maps.cpp b/src/Components/Modules/Maps.cpp index 485e8f78..4631689b 100644 --- a/src/Components/Modules/Maps.cpp +++ b/src/Components/Modules/Maps.cpp @@ -202,10 +202,9 @@ namespace Components Logger::Print("Writing vertices...\n"); for (unsigned int i = 0; i < world->worldDraw.vertexCount; i++) { - // Y/Z need to be inverted - float x = world->worldDraw.vd.vertices[i].xyz[0]; + float x = world->worldDraw.vd.vertices[i].xyz[1]; float y = world->worldDraw.vd.vertices[i].xyz[2]; - float z = world->worldDraw.vd.vertices[i].xyz[1]; + float z = world->worldDraw.vd.vertices[i].xyz[0]; map.append(fmt::sprintf("v %.6f %.6f %.6f\n", x,y, z)); } diff --git a/src/Components/Modules/Zones.cpp b/src/Components/Modules/Zones.cpp index 88319978..2142856a 100644 --- a/src/Components/Modules/Zones.cpp +++ b/src/Components/Modules/Zones.cpp @@ -1083,6 +1083,9 @@ namespace Components image->depth = image359.depth; image->loaded = image359.loaded; image->name = image359.name; + + // Used for later stuff + image->pad = image359.pad3[1]; } else { @@ -1092,6 +1095,20 @@ namespace Components return result; } + Utils::Hook LoadTextureHook; + + int LoadTexture(Game::GfxImageLoadDef **loadDef, Game::GfxImage *image) + { + if (Zones::Version() >= 359 && (((image->pad & 1) && !(image->pad & 2)))) + { + image->loaded = 1; + image->texture = 0; + return 1; + } + + return Game::Load_Texture(loadDef, image); + } + bool Zones::LoadXAsset(bool atStreamStart, char* buffer, int size) { size /= 8; @@ -1303,6 +1320,8 @@ namespace Components Zones::LoadGfxWorldHook.Install(); Zones::Loadsunflare_tHook.Install(); + LoadTextureHook.Install(); + // menu stuff Utils::Hook::Nop(0x41A590, 5); } @@ -1314,6 +1333,8 @@ namespace Components Zones::LoadGfxWorldHook.Uninstall(); Zones::Loadsunflare_tHook.Uninstall(); + LoadTextureHook.Uninstall(); + Utils::Hook(0x41A590, 0x4AF680, HOOK_CALL).Install()->Quick(); } @@ -1355,14 +1376,26 @@ namespace Components Zones::LoadGfxWorldHook.Uninstall(); Zones::Loadsunflare_tHook.Uninstall(); + LoadTextureHook.Uninstall(); + Utils::Hook(0x41A590, 0x4AF680, HOOK_CALL).Install()->Quick(); } AntiCheat::EmptyHash(); } + int ___test() + { + return 0; + } + Zones::Zones() { +// Utils::Hook(0x525A90, ___test, HOOK_JUMP).Install()->Quick(); +// Utils::Hook(0x50C4F0, ___test, HOOK_JUMP).Install()->Quick(); +// Utils::Hook(0x514F90, ___test, HOOK_JUMP).Install()->Quick(); +// Utils::Hook(0x54A2E0, ___test, HOOK_JUMP).Install()->Quick(); + Zones::ZoneVersion = 0; // Ignore missing soundaliases for now @@ -1404,6 +1437,8 @@ namespace Components { ZeroMemory(*Game::varPathData, sizeof(Game::PathData)); }, HOOK_CALL); + + LoadTextureHook.Initialize(0x4D32BC, LoadTexture, HOOK_CALL); } Zones::~Zones() diff --git a/src/Game/Structs.hpp b/src/Game/Structs.hpp index 9015ed86..f3c34b47 100644 --- a/src/Game/Structs.hpp +++ b/src/Game/Structs.hpp @@ -237,6 +237,27 @@ namespace Game char* name; }; + struct GfxImage_new + { + GfxImageLoadDef* texture; + char mapType; + char semantic; + char category; + char flags; + int cardMemory; + char pad[8]; // ? + int dataLen1; + int dataLen2; + char pad2[4]; // ? + short height; + short width; + short depth; + char loaded; + char pad3[5]; + GfxImageLoadDef* storedTexture; + char* name; + }; + struct water_t { float floatTime;