diff --git a/VCS PC/Antennas.cpp b/VCS PC/Antennas.cpp index b897099..ea01f0b 100644 --- a/VCS PC/Antennas.cpp +++ b/VCS PC/Antennas.cpp @@ -3,6 +3,7 @@ #include "Timer.h" #include "Font.h" +#include "Vehicle.h" CAntenna CAntennas::aAntennas[NUM_ANTENNAS]; @@ -159,4 +160,9 @@ void CAntennas::Inject() // Replaces a nullsub CMovingThings::Render() Memory::InjectHook(0x53E184, Render); -} \ No newline at end of file +} + +static StaticPatcher Patcher([](){ + CAntennas::Inject(); + InjectMethod(0x6AAB8B, CAutomobile::RenderAntennas, PATCH_NOTHING); + }); \ No newline at end of file diff --git a/VCS PC/CCamera.h b/VCS PC/CCamera.h index 79ded4b..fe953fa 100644 --- a/VCS PC/CCamera.h +++ b/VCS PC/CCamera.h @@ -4,6 +4,8 @@ #include "General.h" #include "CCam.h" +#define CAMERA_FOV_REGULAR 55.0f + enum eCamMode { MODE_NONE = 0, diff --git a/VCS PC/Coronas.cpp b/VCS PC/Coronas.cpp index 141096c..52dc8d2 100644 --- a/VCS PC/Coronas.cpp +++ b/VCS PC/Coronas.cpp @@ -306,4 +306,8 @@ void CCoronas::Inject() Memory::InjectHook(0x6FC4D0, CCoronas::UpdateCoronaCoors, PATCH_JUMP); Memory::InjectHook(0x6FAAD9, CCoronas::Init, PATCH_JUMP); Memory::InjectHook(0x53C13B, CCoronas::Update); -} \ No newline at end of file +} + +static StaticPatcher Patcher([](){ + CCoronas::Inject(); + }); \ No newline at end of file diff --git a/VCS PC/Pad.cpp b/VCS PC/Pad.cpp index 66fc6db..4468a28 100644 --- a/VCS PC/Pad.cpp +++ b/VCS PC/Pad.cpp @@ -8,6 +8,9 @@ static CPad* const Pads = (CPad*)0xB73458; static CX360Pad* pXboxPad = nullptr; +static StaticPatcher Patcher([](){ + CPad::Inject(); }); + WRAPPER void CPad::UpdatePads() { EAXJMP(0x541DD0); } static void CapturePad(int nPadID) diff --git a/VCS PC/Radar.cpp b/VCS PC/Radar.cpp index d4f7f9f..02cccbf 100644 --- a/VCS PC/Radar.cpp +++ b/VCS PC/Radar.cpp @@ -252,4 +252,19 @@ void CRadar::Render3D(void*, void*, int nVerts) RwIm3DRenderIndexedPrimitive(rwPRIMTYPETRILIST, indices, nVerts); RwIm3DEnd(); -} \ No newline at end of file +} + +static void __declspec(naked) BlipAlphaHook() +{ + _asm + { + movzx edi, [esp+30h-24h] + push edi + push 586F39h + retn + } +} + +static StaticPatcher Patcher([](){ + //Memory::InjectHook(0x586F34, BlipAlphaHook, PATCH_JUMP); + }); \ No newline at end of file diff --git a/VCS PC/Rs.cpp b/VCS PC/Rs.cpp index 652c252..45cecc2 100644 --- a/VCS PC/Rs.cpp +++ b/VCS PC/Rs.cpp @@ -41,9 +41,6 @@ BOOL RsCameraBeginUpdate(RwCamera* pCamera) void CameraSize(RwCamera* camera, RwRect* rect, float fViewWindow, float fAspectRatio) { - float foo = fViewWindow; - float faa = fAspectRatio; - if ( !camera ) return; diff --git a/VCS PC/StaticPatcher.cpp b/VCS PC/StaticPatcher.cpp new file mode 100644 index 0000000..f48a19d --- /dev/null +++ b/VCS PC/StaticPatcher.cpp @@ -0,0 +1,23 @@ +#include "StdAfx.h" +#include "StaticPatcher.h" + +std::vector>* StaticPatcher::m_pFunctions; + +StaticPatcher::StaticPatcher(std::function pInitializer) +{ + if ( !m_pFunctions ) + m_pFunctions = new std::vector>; + + m_pFunctions->push_back(pInitializer); +} + +void StaticPatcher::Apply() +{ + if ( m_pFunctions ) + { + for ( auto it = m_pFunctions->cbegin(); it != m_pFunctions->cend(); it++ ) + (*it)(); + + delete m_pFunctions; + } +} \ No newline at end of file diff --git a/VCS PC/StaticPatcher.h b/VCS PC/StaticPatcher.h new file mode 100644 index 0000000..b360c89 --- /dev/null +++ b/VCS PC/StaticPatcher.h @@ -0,0 +1,15 @@ +#ifndef __STATICPATCHER +#define __STATICPATCHER + +class StaticPatcher +{ +private: + static std::vector>* m_pFunctions; + +public: + StaticPatcher(std::function pInitializer); + + static void Apply(); +}; + +#endif \ No newline at end of file diff --git a/VCS PC/StdAfx.h b/VCS PC/StdAfx.h index 57cc37a..9eaf164 100644 --- a/VCS PC/StdAfx.h +++ b/VCS PC/StdAfx.h @@ -142,6 +142,7 @@ void EnterAmazingScreenshotMode(bool bEnable); #include "CCRC32.h" #include "MemoryMgr.h" +#include "StaticPatcher.h" #include "Maths.h" #include "Rs.h" #include "WidescreenSupport.h" diff --git a/VCS PC/VCS PC.vcxproj b/VCS PC/VCS PC.vcxproj index c9f2820..2293325 100644 --- a/VCS PC/VCS PC.vcxproj +++ b/VCS PC/VCS PC.vcxproj @@ -360,7 +360,10 @@ popd - + + true + + @@ -447,6 +450,7 @@ popd + diff --git a/VCS PC/VCS PC.vcxproj.filters b/VCS PC/VCS PC.vcxproj.filters index fa0d0b9..06d5e82 100644 --- a/VCS PC/VCS PC.vcxproj.filters +++ b/VCS PC/VCS PC.vcxproj.filters @@ -231,6 +231,9 @@ Source Files + + Source Files + @@ -467,6 +470,9 @@ Header Files + + Header Files + diff --git a/VCS PC/VCSPC.cpp b/VCS PC/VCSPC.cpp index d8f8542..a1dbc62 100644 --- a/VCS PC/VCSPC.cpp +++ b/VCS PC/VCSPC.cpp @@ -704,6 +704,10 @@ extern "C" __declspec(dllexport) BOOL OnGameLaunch() PatchMenus(); AnimationStylesPatching(); UserFiles(); + + // Automatic patches + StaticPatcher::Apply(); + CreateThread(NULL, 0, ProcessEmergencyKey, 0, 0, 0); // DLC initialisation @@ -3415,7 +3419,7 @@ __forceinline void Main_Patches() Patch(0x495F78, func_069C); Patch(0x495F7C, func_069C); - //Patch(0x4111AE, "empire_perma"); + Patch(0x4111AE, "empire_perma"); InjectHook(0x53C215, CEmpireManager::Process); // Menu background @@ -4043,16 +4047,6 @@ __forceinline void Main_Patches() Patch(0x585E4D, 1.5f); // Peds Patch(0x585F8E, 1.0f); // Objects - // Coronas stored in a vector - CCoronas::Inject(); - - // Antennas - CAntennas::Inject(); - InjectMethod(0x6AAB8B, CAutomobile::RenderAntennas, PATCH_NOTHING); - - // Own pad - CPad::Inject(); - // Own BaseColors::BaseColors // TODO: Come up with something nicer? InjectMethod(0x84F1F5, CRGBA::BaseColors__Constructor, PATCH_NOTHING); @@ -4441,7 +4435,7 @@ void InjectDelayedPatches() CUpdateManager::Init(); // CDLCManager::InitialiseWithUpdater(); - SpeechInject(); + //SpeechInject(); #ifdef MAKE_CONSOLE if ( AllocConsole() )