From d5b28a127d2cac5ce346972d6f1ebb2d7bb276e4 Mon Sep 17 00:00:00 2001 From: Silent Date: Sun, 23 Oct 2016 18:56:34 +0200 Subject: [PATCH] Nice compatibility measure to GetCurrentZoneLockedOrUnlocked --- SilentPatchSA/SilentPatchSA.cpp | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/SilentPatchSA/SilentPatchSA.cpp b/SilentPatchSA/SilentPatchSA.cpp index d2f90dd..0f4d65d 100644 --- a/SilentPatchSA/SilentPatchSA.cpp +++ b/SilentPatchSA/SilentPatchSA.cpp @@ -219,7 +219,6 @@ int& MoonSize = **AddressByVersion(0x713B0C, 0x71433C, 0x72F0AB); CZoneInfo*& pCurrZoneInfo = **AddressByVersion(0x58ADB1, 0x58B581, 0x407F93); CRGBA* HudColour = *AddressByVersion(0x58ADF6, 0x58B5C6, 0x440648); -unsigned char* ZonesVisited = *AddressByVersion(0x57216A, 0, 0x5870E8) - 9; // 1.01 fixed it! float& m_fDNBalanceParam = **AddressByVersion(0x4A9062, 0x4A90F2, 0x4B2512); RpLight*& pAmbient = **AddressByVersion(0x5BA53A, 0x735D11, 0x5D90F0); @@ -575,12 +574,19 @@ void StartNewMission_SCMFixes() // 1.01 kinda fixed it bool GetCurrentZoneLockedOrUnlocked(float fPosX, float fPosY) { - int Xindex = (fPosX+3000.0f) * (1.0f/600.0f); - int Yindex = (fPosY+3000.0f) * (1.0f/600.0f); + // Exploit RAII really bad + static const float GridXOffset = **AddressByVersion(0x572135+2, 0, 0 /*TODO*/), GridYOffset = **AddressByVersion(0x57214A+2, 0, 0 /*TODO*/); + static const float GridXSize = **AddressByVersion(0x57213B+2, 0, 0 /*TODO*/), GridYSize = **AddressByVersion(0x572153+2, 0, 0 /*TODO*/); + static const int GridXNum = (2.0f*GridXOffset) * GridXSize, GridYNum = (2.0f*GridYOffset) * GridYSize; + + static unsigned char* const ZonesVisited = *AddressByVersion(0x57216A, 0, 0x5870E8) - (GridYNum-1); // 1.01 fixed it! + + int Xindex = (fPosX+GridXOffset) * GridXSize; + int Yindex = (fPosY+GridYOffset) * GridYSize; // "Territories fix" - if ( (Xindex >= 0 && Xindex < 10) && (Yindex >= 0 && Yindex < 10) ) - return ZonesVisited[10*Xindex - Yindex + 9] != 0; + if ( (Xindex >= 0 && Xindex < GridXNum) && (Yindex >= 0 && Yindex < GridYNum) ) + return ZonesVisited[GridXNum*Xindex - Yindex + (GridYNum-1)] != 0; // Outside of map bounds return true;