From 0b2fc37d062f396ee9d3415e51022e7de4976e0f Mon Sep 17 00:00:00 2001 From: Silent Date: Sun, 29 May 2016 19:17:44 +0200 Subject: [PATCH] Reinit CCarCtrl fields (firetruck and ambulance generation) - III/VC --- SilentPatchIII/SilentPatchIII.cpp | 28 ++++++++++++++++++++++++++++ SilentPatchVC/SilentPatchVC.cpp | 29 +++++++++++++++++++++++++++++ 2 files changed, 57 insertions(+) diff --git a/SilentPatchIII/SilentPatchIII.cpp b/SilentPatchIII/SilentPatchIII.cpp index feb3f2a..01c5853 100644 --- a/SilentPatchIII/SilentPatchIII.cpp +++ b/SilentPatchIII/SilentPatchIII.cpp @@ -264,6 +264,16 @@ void NewFrameRender(int nEvent, void* pParam) RsEventHandler(nEvent, pParam); } +static signed int& LastTimeFireTruckCreated = **(int**)0x41D2E5; +static signed int& LastTimeAmbulanceCreated = **(int**)0x41D2F9; +static void (*orgCarCtrlReInit)(); +void CarCtrlReInit_SilentPatch() +{ + orgCarCtrlReInit(); + LastTimeFireTruckCreated = 0; + LastTimeAmbulanceCreated = 0; +} + static char aNoDesktopMode[64]; void Patch_III_10(const RECT& desktop) @@ -408,6 +418,12 @@ void Patch_III_10(const RECT& desktop) InjectHook(0x580BB0, GetMyDocumentsPath, PATCH_JUMP); + // Reinit CCarCtrl fields (firetruck and ambulance generation) + int pCarCtrlReInit = 0x48C4FB; + orgCarCtrlReInit = (void(*)())(*(int*)(pCarCtrlReInit+1) + pCarCtrlReInit + 5); + InjectHook(0x48C4FB, CarCtrlReInit_SilentPatch); + + // Adblocker #if DISABLE_FLA_DONATION_WINDOW if ( *(DWORD*)0x582749 != 0x006A026A ) @@ -547,6 +563,12 @@ void Patch_III_11(const RECT& desktop) // SHGetFolderPath on User Files InjectHook(0x580F00, GetMyDocumentsPath, PATCH_JUMP); + + + // Reinit CCarCtrl fields (firetruck and ambulance generation) + int pCarCtrlReInit = 0x48C5FB; + orgCarCtrlReInit = (void(*)())(*(int*)(pCarCtrlReInit+1) + pCarCtrlReInit + 5); + InjectHook(0x48C5FB, CarCtrlReInit_SilentPatch); } void Patch_III_Steam(const RECT& desktop) @@ -674,6 +696,12 @@ void Patch_III_Steam(const RECT& desktop) // SHGetFolderPath on User Files InjectHook(0x580E00, GetMyDocumentsPath, PATCH_JUMP); + + + // Reinit CCarCtrl fields (firetruck and ambulance generation) + int pCarCtrlReInit = 0x48C58B; + orgCarCtrlReInit = (void(*)())(*(int*)(pCarCtrlReInit+1) + pCarCtrlReInit + 5); + InjectHook(0x48C58B, CarCtrlReInit_SilentPatch); } BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) diff --git a/SilentPatchVC/SilentPatchVC.cpp b/SilentPatchVC/SilentPatchVC.cpp index dc0bafe..9a2f215 100644 --- a/SilentPatchVC/SilentPatchVC.cpp +++ b/SilentPatchVC/SilentPatchVC.cpp @@ -173,6 +173,17 @@ void NewFrameRender(int nEvent, void* pParam) RsEventHandler(nEvent, pParam); } + +static signed int& LastTimeFireTruckCreated = **AddressByVersion(0x429435, 0x429435, 0x429405); +static signed int& LastTimeAmbulanceCreated = **AddressByVersion(0x429449, 0x429449, 0x429419); +static void (*orgCarCtrlReInit)(); +void CarCtrlReInit_SilentPatch() +{ + orgCarCtrlReInit(); + LastTimeFireTruckCreated = 0; + LastTimeAmbulanceCreated = 0; +} + static char aNoDesktopMode[64]; void Patch_VC_10(const RECT& desktop) @@ -301,6 +312,12 @@ void Patch_VC_10(const RECT& desktop) Patch(0x5FDDDB, 0xC5); + // Reinit CCarCtrl fields (firetruck and ambulance generation) + int pCarCtrlReInit = 0x4A489B; + orgCarCtrlReInit = (void(*)())(*(int*)(pCarCtrlReInit+1) + pCarCtrlReInit + 5); + InjectHook(0x4A489B, CarCtrlReInit_SilentPatch); + + // Adblocker #if DISABLE_FLA_DONATION_WINDOW if ( *(DWORD*)0x5FFAE9 != 0x006A026A ) @@ -435,6 +452,12 @@ void Patch_VC_11(const RECT& desktop) // Corrected crime codes Patch(0x5FDDFB, 0xC5); + + + // Reinit CCarCtrl fields (firetruck and ambulance generation) + int pCarCtrlReInit = 0x4A48BB; + orgCarCtrlReInit = (void(*)())(*(int*)(pCarCtrlReInit+1) + pCarCtrlReInit + 5); + InjectHook(0x4A48BB, CarCtrlReInit_SilentPatch); } void Patch_VC_Steam(const RECT& desktop) @@ -560,6 +583,12 @@ void Patch_VC_Steam(const RECT& desktop) // Corrected crime codes Patch(0x5FDA3B, 0xC5); + + + // Reinit CCarCtrl fields (firetruck and ambulance generation) + int pCarCtrlReInit = 0x4A475B; + orgCarCtrlReInit = (void(*)())(*(int*)(pCarCtrlReInit+1) + pCarCtrlReInit + 5); + InjectHook(0x4A475B, CarCtrlReInit_SilentPatch); } void Patch_VC_JP()