From 69c454a3faa84cb54f2328d0984ff0140e0f5818 Mon Sep 17 00:00:00 2001 From: momo5502 Date: Tue, 1 Nov 2016 20:04:06 +0100 Subject: [PATCH] Fix zm_prototype_sh --- src/Components/Modules/AssetHandler.cpp | 2 +- src/Components/Modules/Zones.cpp | 34 ++++++++++++++----------- src/Components/Modules/Zones.hpp | 1 + src/Game/Functions.cpp | 1 + src/Game/Functions.hpp | 3 +++ 5 files changed, 25 insertions(+), 16 deletions(-) diff --git a/src/Components/Modules/AssetHandler.cpp b/src/Components/Modules/AssetHandler.cpp index 12e2bc02..e5c2ae00 100644 --- a/src/Components/Modules/AssetHandler.cpp +++ b/src/Components/Modules/AssetHandler.cpp @@ -117,7 +117,7 @@ namespace Components void AssetHandler::ModifyAsset(Game::XAssetType type, Game::XAssetHeader asset, std::string name) { - if (type == Game::XAssetType::ASSET_TYPE_MATERIAL && (name == "wc/codo_ui_viewer_black_decal3" || name == "wc/codo_ui_viewer_black_decal2" || name == "wc/hint_arrows02")) + if (type == Game::XAssetType::ASSET_TYPE_MATERIAL && (name == "wc/codo_ui_viewer_black_decal3" || name == "wc/codo_ui_viewer_black_decal2" || name == "wc/hint_arrows01" || name == "wc/hint_arrows02")) { asset.material->sortKey = 0xE; } diff --git a/src/Components/Modules/Zones.cpp b/src/Components/Modules/Zones.cpp index cd21500b..b84dd801 100644 --- a/src/Components/Modules/Zones.cpp +++ b/src/Components/Modules/Zones.cpp @@ -237,14 +237,7 @@ namespace Components if (Zones::ZoneVersion >= 359) { - for (int i = 0, offset = 20; i < 4; ++i, offset += 4) - { - *Game::varXModelPtr = reinterpret_cast(varWeaponCompleteDef + offset); - Game::Load_XModelPtr(false); - } - - // 148 - for (int offset = 28; offset <= 56; offset += 4) + for (int offset = 20; offset <= 56; offset += 4) { *Game::varXModelPtr = reinterpret_cast(varWeaponCompleteDef + offset); Game::Load_XModelPtr(false); @@ -972,11 +965,13 @@ namespace Components bool Zones::LoadmenuDef_t(bool atStreamStart, char* buffer, int size) { - if (Zones::ZoneVersion < 359) size += 4; + if (Zones::ZoneVersion != 359) size += 4; bool result = Game::Load_Stream(atStreamStart, buffer, size); - std::memmove(buffer + 168, buffer + 172, (Zones::ZoneVersion < 359 ? 232 : 228)); - AssetHandler::Relocate(buffer + 172, buffer + 168, (Zones::ZoneVersion < 359 ? 232 : 228)); + std::memmove(buffer + 168, buffer + 172, (Zones::ZoneVersion != 359 ? 232 : 228)); + AssetHandler::Relocate(buffer + 172, buffer + 168, (Zones::ZoneVersion != 359 ? 232 : 228)); + + reinterpret_cast(buffer)->expressionData = nullptr; return result; } @@ -1283,6 +1278,16 @@ namespace Components return result; } + void Zones::LoadWindowImage(bool atStreamStart) + { + Game::Load_MaterialHandle(atStreamStart); + + if (Zones::Version() >= 360) + { + Game::Load_GfxImagePtr(atStreamStart); + } + } + void Zones::InstallPatches(int version) { AssetHandler::ClearRelocations(); @@ -1336,13 +1341,11 @@ namespace Components // Patch ExpressionSupportingData loading in menus if (Zones::Version() >= 359) { - Utils::Hook::Nop(0x41A590, 5); - Utils::Hook::Set(0x459833, 0xC3); + Utils::Hook::Set(0x4AF680, 0xC3); } else { - Utils::Hook(0x41A590, 0x4AF680, HOOK_CALL).Install()->Quick(); - Utils::Hook(0x459833, 0x4AF680, HOOK_JUMP).Install()->Quick(); + Utils::Hook::Set(0x4AF680, 0xA1); } if (patch) @@ -1489,6 +1492,7 @@ namespace Components }, HOOK_CALL); Utils::Hook(0x4597DD, Zones::LoadStatement, HOOK_CALL).Install()->Quick(); + Utils::Hook(0x471A39, Zones::LoadWindowImage, HOOK_JUMP).Install()->Quick(); #ifdef DEBUG // Easy dirty disk debugging diff --git a/src/Components/Modules/Zones.hpp b/src/Components/Modules/Zones.hpp index 7f0272c5..4d2807b5 100644 --- a/src/Components/Modules/Zones.hpp +++ b/src/Components/Modules/Zones.hpp @@ -74,5 +74,6 @@ namespace Components static bool LoadGfxWorld(bool atStreamStart, char* buffer, int size); static void Loadsunflare_t(bool atStreamStart); static bool LoadStatement(bool atStreamStart, char* buffer, int size); + static void LoadWindowImage(bool atStreamStart); }; } diff --git a/src/Game/Functions.cpp b/src/Game/Functions.cpp index 3e01e4d4..d0b66073 100644 --- a/src/Game/Functions.cpp +++ b/src/Game/Functions.cpp @@ -111,6 +111,7 @@ namespace Game Load_XStringCustom_t Load_XStringCustom = (Load_XStringCustom_t)0x4E0DD0; Load_FxEffectDefHandle_t Load_FxEffectDefHandle = (Load_FxEffectDefHandle_t)0x4D9B90; Load_FxElemDef_t Load_FxElemDef = (Load_FxElemDef_t)0x45AD90; + Load_GfxImagePtr_t Load_GfxImagePtr = (Load_GfxImagePtr_t)0x4C13D0; Load_Texture_t Load_Texture = (Load_Texture_t)0x51F4E0; Load_GfxTextureLoad_t Load_GfxTextureLoad = (Load_GfxTextureLoad_t)0x4D3210; Load_SndAliasCustom_t Load_SndAliasCustom = (Load_SndAliasCustom_t)0x49B6B0; diff --git a/src/Game/Functions.hpp b/src/Game/Functions.hpp index 88b40454..b74c33e9 100644 --- a/src/Game/Functions.hpp +++ b/src/Game/Functions.hpp @@ -266,6 +266,9 @@ namespace Game typedef void(__cdecl *Load_FxElemDef_t)(bool atStreamStart); extern Load_FxElemDef_t Load_FxElemDef; + typedef void(__cdecl *Load_GfxImagePtr_t)(bool atStreamStart); + extern Load_GfxImagePtr_t Load_GfxImagePtr; + typedef void(__cdecl *Load_GfxTextureLoad_t)(bool atStreamStart); extern Load_GfxTextureLoad_t Load_GfxTextureLoad;