diff --git a/Client/game_sa/CHandlingManagerSA.cpp b/Client/game_sa/CHandlingManagerSA.cpp index 8bbfb348b1..cbf682d00b 100644 --- a/Client/game_sa/CHandlingManagerSA.cpp +++ b/Client/game_sa/CHandlingManagerSA.cpp @@ -103,20 +103,14 @@ __declspec(noinline) void DumpHandlingData(tHandlingDataSA* pData) static __declspec(naked) void Hook_Calculate() { - tHandlingDataSA* pData; - DWORD dwHandlingData; _asm { - mov eax, [esp+4] - mov dwHandlingData, eax - } - - pData = reinterpret_cast(dwHandlingData); - DumpHandlingData(pData); + mov eax, [esp+4] + push eax + call DumpHandlingData + add esp, 4 - _asm - { - ret 4 + ret 4 } } diff --git a/Client/game_sa/CTaskManagementSystemSA.cpp b/Client/game_sa/CTaskManagementSystemSA.cpp index 14fd05f85d..741c5d5979 100644 --- a/Client/game_sa/CTaskManagementSystemSA.cpp +++ b/Client/game_sa/CTaskManagementSystemSA.cpp @@ -265,20 +265,16 @@ __declspec(noinline) void OnMY_Task_Operator_Delete(CTaskSAInterface* pTaskInter void _declspec(naked) HOOK_CTask_Operator_Delete() { _asm - { - mov eax, [esp+4] - mov pTempTaskInterface, eax + { + mov eax, [esp+4] + mov pTempTaskInterface, eax pushad - } - - OnMY_Task_Operator_Delete(pTempTaskInterface); - - // Continue on our merry way.... - _asm - { + push pTempTaskInterface + call OnMY_Task_Operator_Delete popad + // Continue on our merry way.... mov eax, 0xB744A8 mov ecx, dword ptr [eax] mov eax, FUNC_CTask_Operator_Delete diff --git a/Client/game_sa/CWorldSA.cpp b/Client/game_sa/CWorldSA.cpp index a60e360464..3a77a0b701 100644 --- a/Client/game_sa/CWorldSA.cpp +++ b/Client/game_sa/CWorldSA.cpp @@ -91,43 +91,49 @@ DWORD CONTINUE_CWorld_FallenCars = 0x00565E8A; void _declspec(naked) HOOK_FallenPeds() { - if (pGame && pGame->IsUnderWorldWarpEnabled()) - { - _asm - { - sub esp, 2Ch - push ebx - mov ebx, ds:0B74490h - jmp CONTINUE_CWorld_FallenPeds - } - } - else + _asm { - _asm - { - ret - } + // if (pGame) + mov eax, pGame + test eax, eax + jz skip + + // if (pGame->IsUnderWorldWarpEnabled()) + call dword ptr [eax+80h] + test al, al + jz skip + + sub esp, 2Ch + push ebx + mov ebx, ds:0B74490h + jmp CONTINUE_CWorld_FallenPeds + + skip: + ret } } void _declspec(naked) HOOK_FallenCars() { - if (pGame && pGame->IsUnderWorldWarpEnabled()) - { - _asm - { - sub esp, 2Ch - push ebx - mov ebx, ds:0B74494h - jmp CONTINUE_CWorld_FallenCars - } - } - else + _asm { - _asm - { - ret - } + // if (pGame) + mov eax, pGame + test eax, eax + jz skip + + // if (pGame->IsUnderWorldWarpEnabled()) + call dword ptr [eax+80h] + test al, al + jz skip + + sub esp, 2Ch + push ebx + mov ebx, ds:0B74494h + jmp CONTINUE_CWorld_FallenCars + + skip: + ret } } diff --git a/Client/multiplayer_sa/CMultiplayerSA.cpp b/Client/multiplayer_sa/CMultiplayerSA.cpp index 1b21f79a23..e27f7f9bd5 100644 --- a/Client/multiplayer_sa/CMultiplayerSA.cpp +++ b/Client/multiplayer_sa/CMultiplayerSA.cpp @@ -2836,50 +2836,43 @@ void _declspec(naked) HOOK_CStreaming_Update_Caller() { // Store all registers pushad - } - // We're now in the streaming update - bInStreamingUpdate = true; + // We're now in the streaming update + mov bInStreamingUpdate, 1 + + // We have an active entity for streaming? + mov edi, activeEntityForStreaming + test edi, edi + jz skip - // We have an active entity for streaming? - if (activeEntityForStreaming) - { // Do something... - _asm - { - mov edi, FUNC_CPlayerInfoBase - mov ebx, [edi] - mov dwSavedPlayerPointer, ebx - mov ebx, activeEntityForStreaming - mov [edi], ebx - } - } + mov edi, FUNC_CPlayerInfoBase + mov ebx, [edi] + mov dwSavedPlayerPointer, ebx + mov ebx, activeEntityForStreaming + mov [edi], ebx - _asm - { + skip: mov edi, eax // Call FUNC_CStreaming_Update mov eax, FUNC_CStreaming_Update call eax - } - // We have an entity for streaming? - if (activeEntityForStreaming) - { - _asm - { - // ... - mov edi, FUNC_CPlayerInfoBase - mov ebx, dwSavedPlayerPointer - mov [edi], ebx - } - } + // We have an entity for streaming? + mov eax, activeEntityForStreaming + test eax, eax + jz skip2 + + // ... + mov edi, FUNC_CPlayerInfoBase + mov ebx, dwSavedPlayerPointer + mov [edi], ebx + + skip2: + // We're no longer in streaming update + mov bInStreamingUpdate, 0 - // We're no longer in streaming update - bInStreamingUpdate = false; - _asm - { // Restore registers popad @@ -2902,18 +2895,30 @@ void _declspec(naked) HOOK_CHud_Draw_Caller() mov edx, FUNC_CAudioEngine__DisplayRadioStationName call edx - } - if (!bSetCenterOfWorld) - { - _asm - { - mov edx, FUNC_CHud_Draw - call edx - } + movzx edx, bSetCenterOfWorld + test edx, edx + jnz skip + + mov edx, FUNC_CHud_Draw + call edx + + skip: + movzx edx, bHideRadar + test edx, edx + jnz skip2 + + mov edx, 0x58A330 + call edx + + skip2: + popad + + mov eax, HOOKPOS_CHud_Draw_Caller + add eax, 10 + jmp eax } - else - { + /*if ( activeEntityForStreaming ) { _asm @@ -2926,15 +2931,6 @@ void _declspec(naked) HOOK_CHud_Draw_Caller() } }*/ - if (!bHideRadar) - { - _asm - { - mov edx, 0x58A330 - call edx - } - } - /*if ( activeEntityForStreaming ) { _asm @@ -2944,16 +2940,6 @@ void _declspec(naked) HOOK_CHud_Draw_Caller() mov [edi], ebx } }*/ - } - - _asm - { - popad - - mov eax, HOOKPOS_CHud_Draw_Caller - add eax, 10 - jmp eax - } } void _declspec(naked) HOOK_FindPlayerCentreOfWorld() @@ -3050,48 +3036,37 @@ void _declspec(naked) HOOK_CRadar__DrawRadarGangOverlay() _asm { pushad - } + mov eax, m_pDrawRadarAreasHandler + test eax, eax + jz skip - if (m_pDrawRadarAreasHandler) m_pDrawRadarAreasHandler(); + call dword ptr [eax] - _asm - { + skip: popad retn } } -CVehicleSAInterface* towingVehicle; - void _declspec(naked) HOOK_Trailer_BreakTowLink() { _asm { - mov towingVehicle, ecx pushad - } + push ecx + call CallBreakTowLinkHandler + test al, al + jz skip - if (CallBreakTowLinkHandler(towingVehicle)) - { - _asm - { - popad - call dword ptr [edx+0xF8] - } - } - else - { - _asm - { - popad - } - } + popad + call dword ptr [edx+0xF8] - _asm - { - mov ecx, HOOKPOS_Trailer_BreakTowLink - add ecx, 6 - jmp ecx + skip: + popad + + mov ecx, HOOKPOS_Trailer_BreakTowLink + add ecx, 6 + jmp ecx } } @@ -3169,29 +3144,18 @@ void _declspec(naked) HOOK_CExplosion_AddExplosion() // Store registers for calling this handler pushad - } - // Call the explosion handler - if (!CallExplosionHandler()) - { - _asm - { - popad - retn // if they return false from the handler, they don't want the explosion to show - } - } - else - { - _asm - { - popad - } - } + call CallExplosionHandler + test al, al + jnz skip - _asm - { - noexplosionhandler: + popad + retn // if they return false from the handler, they don't want the explosion to show + skip: + popad + + noexplosionhandler: // Replaced code sub esp, 0x1C push ebx @@ -3242,25 +3206,19 @@ void _declspec(naked) HOOK_CTaskComplexJump__CreateSubTask() mov entityEdgeHeight, eax mov eax, pedPosition pushad - } - if (processGrab()) - { - _asm - { - popad - mov eax, 0x67DAD6 - jmp eax - } - } - else - { - _asm - { - popad - mov eax, 0x67DAD1 - jmp eax - } + call processGrab + test al, al + jz is_false + + popad + mov eax, 0x67DAD6 + jmp eax + + is_false: + popad + mov eax, 0x67DAD1 + jmp eax } } @@ -3268,6 +3226,7 @@ char* szCreateFxSystem_ExplosionType = 0; DWORD* pCreateFxSystem_Matrix = 0; DWORD* pNewCreateFxSystem_Matrix = 0; +static constexpr const char* explosionTypeString = "string"; void _declspec(naked) HOOK_FxManager_CreateFxSystem() { _asm @@ -3282,26 +3241,47 @@ void _declspec(naked) HOOK_FxManager_CreateFxSystem() // Store all the registers on the stack pushad - } - // If we got a matrix and it is an explosion type? - if (pCreateFxSystem_Matrix != 0 && strncmp(szCreateFxSystem_ExplosionType, "explosion", 9) == 0) - { + // If we got a matrix and it is an explosion type? + mov eax, pCreateFxSystem_Matrix + test eax, eax + jz not_explosion + + mov eax, szCreateFxSystem_ExplosionType + push 9 + push eax + push offset explosionTypeString + call strncmp + add esp, 12 + + test eax, eax + jnz not_explosion + // Copy the matrix so we don't crash if the owner of this matrix is deleted - pNewCreateFxSystem_Matrix = (DWORD*)malloc(64); - MemCpyFast(pNewCreateFxSystem_Matrix, pCreateFxSystem_Matrix, 64); + push 64 + call malloc + add esp, 4 + + mov pNewCreateFxSystem_Matrix, eax + push 64 + push pCreateFxSystem_Matrix + push pNewCreateFxSystem_Matrix + call MemCpyFast + add esp, 12 // Add it to the list over FxSystem matrices we've copied - AddFxSystemPointer(pNewCreateFxSystem_Matrix); - } - else - { + push pNewCreateFxSystem_Matrix + call AddFxSystemPointer + add esp, 4 + + jmp hook_end + + not_explosion: // Use the same pointer. This is not an explosion or it is 0. - pNewCreateFxSystem_Matrix = pCreateFxSystem_Matrix; - } + mov eax, pCreateFxSystem_Matrix + mov pNewCreateFxSystem_Matrix, eax - _asm - { + hook_end: // Restore the registers popad @@ -3331,27 +3311,25 @@ void _declspec(naked) HOOK_FxManager_DestroyFxSystem() // Store all the registers on the stack pushad - } - // Grab the matrix pointer in it - pDestroyFxSystem_Matrix = *((DWORD**)(dwDestroyFxSystem_Pointer + 12)); + mov eax, [eax+12] + mov pDestroyFxSystem_Matrix, eax - // Delete it if it's in our list - RemoveFxSystemPointer(pDestroyFxSystem_Matrix); + push pDestroyFxSystem_Matrix + call RemoveFxSystemPointer + add esp, 4 - _asm - { // Restore the registers popad // The original code we replaced - push ecx - push ebx - push edi - mov edi, [esp+10h] + push ecx + push ebx + push edi + mov edi, [esp+10h] // Jump back to the rest of the function we hooked - jmp RETURN_FxManager_DestroyFxSystem + jmp RETURN_FxManager_DestroyFxSystem } } @@ -3366,32 +3344,25 @@ bool CCam_ProcessFixed(class CCamSAInterface* pCamInterface) return false; } -CCamSAInterface* CCam_ProcessFixed_pCam; - void _declspec(naked) HOOK_CCam_ProcessFixed() { _asm { - mov CCam_ProcessFixed_pCam, ecx - } + pushad + push ecx + call CCam_ProcessFixed + test al, al + jnz skip - if (CCam_ProcessFixed(CCam_ProcessFixed_pCam)) - { - _asm - { - ret 10h - } - } - else - { - _asm - { - mov ecx, CCam_ProcessFixed_pCam - sub esp, 28h - push ebx - push ebp - jmp RETURN_CCam_ProcessFixed - } + popad + sub esp, 28h + push ebx + push ebp + jmp RETURN_CCam_ProcessFixed + + skip: + popad + ret 10h } } @@ -3400,11 +3371,13 @@ void _declspec(naked) HOOK_Render3DStuff() _asm { pushad - } - if (m_pRender3DStuffHandler) m_pRender3DStuffHandler(); + mov eax, m_pRender3DStuffHandler + test eax, eax + jz skip - _asm - { + call dword ptr [eax] + + skip: popad mov eax, FUNC_Render3DStuff jmp eax @@ -3445,24 +3418,19 @@ void _declspec(naked) HOOK_CTaskSimplePlayerOnFoot_ProcessPlayerWeapon() mov eax, [esp+4] mov pProcessPlayerWeaponPed, eax pushad - } - if (ProcessPlayerWeapon()) - { - _asm - { - popad - push 0FFFFFFFFh - push 846BCEh - jmp RETURN_CTaskSimplePlayerOnFoot_ProcessPlayerWeapon - } - } - else - { - _asm - { - popad - ret 4 - } + + call ProcessPlayerWeapon + test al, al + jz skip + + popad + push 0FFFFFFFFh + push 846BCEh + jmp RETURN_CTaskSimplePlayerOnFoot_ProcessPlayerWeapon + + skip: + popad + ret 4 } } @@ -3482,24 +3450,19 @@ void _declspec(naked) HOOK_CPed_IsPlayer() { mov pIsPlayerPed, ecx pushad - } - if (IsPlayer()) - { - _asm - { - popad - mov eax,dword ptr [ecx+598h] - jmp RETURN_CPed_IsPlayer - } - } - else - { - _asm - { - popad - xor al, al - ret - } + + call IsPlayer + test al, al + jz is_false + + popad + mov eax,dword ptr [ecx+598h] + jmp RETURN_CPed_IsPlayer + + is_false: + popad + xor al, al + ret } } @@ -3618,12 +3581,9 @@ void _declspec(naked) HOOK_CRunningScript_Process() _asm { pushad - } - - CRunningScript_Process(); + + call CRunningScript_Process - _asm - { popad retn } diff --git a/Client/multiplayer_sa/CMultiplayerSA_1.3.cpp b/Client/multiplayer_sa/CMultiplayerSA_1.3.cpp index fd47e12ba8..e0aa863155 100644 --- a/Client/multiplayer_sa/CMultiplayerSA_1.3.cpp +++ b/Client/multiplayer_sa/CMultiplayerSA_1.3.cpp @@ -342,12 +342,11 @@ void _declspec(naked) HOOK_CVehicle_ProcessStuff_TestSirenTypeSingle() mov dwSirenType, edx // Grab our siren vehicle mov pVehicleWithTheSiren, esi - } - // Call our Get siren type function which edits dwSirenType to our desired type - GetVehicleSirenType(); - _asm - { + + // Call our Get siren type function which edits dwSirenType to our desired type + call GetVehicleSirenType popad + // put our new siren type into edx or old one for default/no sirens mov edx, dwSirenType // Jump back to the original code @@ -573,42 +572,38 @@ void _declspec(naked) HOOK_CVehicle_ProcessStuff_PostPushSirenPositionSingle() mov pVehicleWithTheSiren, esi // Put edx into our position variable mov vecRelativeSirenPosition, edx - } - bPointLights = false; - // Call our main siren Process function - if (ProcessVehicleSirenPosition()) - { - _asm - { - popad - // push our siren position - push edx - push 0FFh - mov eax, dwBlue - push eax - mov eax, dwGreen - push eax - mov eax, dwRed - push eax - - // return back to SA - JMP RETN_CVehicle_ProcessStuff_PostPushSirenPositionSingle - } - } - else - { - _asm - { - popad - // push our siren position - push edx - push 0FFh - push 0FFh - push 0 - push 0 - // return back to SA - JMP RETN_CVehicle_ProcessStuff_PostPushSirenPositionSingle - } + + mov bPointLights, 0 + + // Call our main siren Process function + call ProcessVehicleSirenPosition + test al, al + jz notedit + + popad + // push our siren position + push edx + push 0FFh + mov eax, dwBlue + push eax + mov eax, dwGreen + push eax + mov eax, dwRed + push eax + + // return back to SA + JMP RETN_CVehicle_ProcessStuff_PostPushSirenPositionSingle + + notedit: + popad + // push our siren position + push edx + push 0FFh + push 0FFh + push 0 + push 0 + // return back to SA + JMP RETN_CVehicle_ProcessStuff_PostPushSirenPositionSingle } } @@ -637,12 +632,11 @@ void _declspec(naked) HOOK_CVehicle_ProcessStuff_TestSirenTypeDual() mov pVehicleWithTheSiren, esi // Store our post hook default siren type mov dwSirenTypePostHook, edi - } - // Do our test and edit dwSirenType2 appropriately - TestSirenTypeDualDefaultFix(); - _asm - { + + // Do our test and edit dwSirenType2 appropriately + call TestSirenTypeDualDefaultFix popad + // Move dwSirenType into edi mov edi, dwSirenType2 // Return back to SA @@ -665,49 +659,44 @@ void _declspec(naked) HOOK_CVehicle_ProcessStuff_PostPushSirenPositionDualRed() mov dwRed, ebp mov dwGreen, edx mov dwBlue, ecx - } - bPointLights = false; - // Call our main process siren function - if (ProcessVehicleSirenPosition()) - { - _asm - { - popad - // Push our position - push eax - // move our R,G,B components into registers - mov ebp, dwRed // Red - mov edx, dwGreen // Green - mov ecx, dwBlue // Blue - push 0FFh - // Push our R,G,B components (inverse order) - push ecx - push edx - push ebp - // Return control - JMP RETN_CVehicle_ProcessStuff_PostPushSirenPositionDual1 - } - } - else - { - _asm - { - popad - // Push our position - push eax - // Edit our components to get Alpha fixing working. - mov ebp, dwRed // Red - mov edx, dwGreen // Green - mov ecx, dwBlue // Blue - push 0FFh - // Push our R,G,B components (inverse order) - push ecx - push edx - push ebp - // Return control - JMP RETN_CVehicle_ProcessStuff_PostPushSirenPositionDual1 - } + mov bPointLights, 0 + + // Call our main process siren function + call ProcessVehicleSirenPosition + test al, al + jz notedit + + popad + // Push our position + push eax + // move our R,G,B components into registers + mov ebp, dwRed // Red + mov edx, dwGreen // Green + mov ecx, dwBlue // Blue + push 0FFh + // Push our R,G,B components (inverse order) + push ecx + push edx + push ebp + // Return control + JMP RETN_CVehicle_ProcessStuff_PostPushSirenPositionDual1 + + notedit: + popad + // Push our position + push eax + // Edit our components to get Alpha fixing working. + mov ebp, dwRed // Red + mov edx, dwGreen // Green + mov ecx, dwBlue // Blue + push 0FFh + // Push our R,G,B components (inverse order) + push ecx + push edx + push ebp + // Return control + JMP RETN_CVehicle_ProcessStuff_PostPushSirenPositionDual1 } } @@ -725,49 +714,44 @@ void _declspec(naked) HOOK_CVehicle_ProcessStuff_PostPushSirenPositionDualBlue() mov dwRed, ebp mov dwGreen, edx mov dwBlue, ecx - } - bPointLights = false; - // Call our main process siren function - if (ProcessVehicleSirenPosition()) - { - _asm - { - popad - // Push our position - push eax - // move our R,G,B components into registers - mov ecx, dwBlue // Blue - mov edx, dwGreen // Green - mov ebp, dwRed // Red - push 0FFh - // Push our R,G,B components (inverse order) - push ecx - push edx - push ebp - // Return control - JMP RETN_CVehicle_ProcessStuff_PostPushSirenPositionDual2 - } - } - else - { - _asm - { - popad - // Push our position - push eax - push 0FFh - // Edit our components to get Alpha fixing working. - mov ecx, dwBlue // Blue - mov edx, dwGreen // Green - mov ebp, dwRed // Red - // Push our R,G,B components (inverse order) - push ecx - push edx - push ebp - // Return control - JMP RETN_CVehicle_ProcessStuff_PostPushSirenPositionDual2 - } + mov bPointLights, 0 + + // Call our main process siren function + call ProcessVehicleSirenPosition + test al, al + jz notedit + + popad + // Push our position + push eax + // move our R,G,B components into registers + mov ecx, dwBlue // Blue + mov edx, dwGreen // Green + mov ebp, dwRed // Red + push 0FFh + // Push our R,G,B components (inverse order) + push ecx + push edx + push ebp + // Return control + JMP RETN_CVehicle_ProcessStuff_PostPushSirenPositionDual2 + + notedit: + popad + // Push our position + push eax + push 0FFh + // Edit our components to get Alpha fixing working. + mov ecx, dwBlue // Blue + mov edx, dwGreen // Green + mov ebp, dwRed // Red + // Push our R,G,B components (inverse order) + push ecx + push edx + push ebp + // Return control + JMP RETN_CVehicle_ProcessStuff_PostPushSirenPositionDual2 } } @@ -796,29 +780,20 @@ void _declspec(naked) HOOK_CVehicle_DoesVehicleUseSiren() pushad // Grab our vehicle interface mov pVehicleWithTheSiren, ecx - } - // Test our vehicle for sirens - if (TestVehicleForSiren()) - { - _asm - { - popad - // Move 1 into AL (true) - mov al, 1 - // Return - jmp RETN_CVehicleDoesVehicleUseSirenRetn - } - } - else - { - _asm - { - popad - // xor AL (false) - xor al, al - // Return - jmp RETN_CVehicleDoesVehicleUseSirenRetn - } + + // Test our vehicle for sirens + call TestVehicleForSiren + test al, al + jnz is_false + + popad + mov al, 1 + jmp RETN_CVehicleDoesVehicleUseSirenRetn + + is_false: + popad + xor al, al + jmp RETN_CVehicleDoesVehicleUseSirenRetn } } bool SirenCheckCameraPosition() @@ -848,30 +823,25 @@ void _declspec(naked) HOOK_CVehicle_ProcessStuff_TestCameraPosition() pushad // Grab our vehicle mov pVehicleWithTheSiren, esi - } - // Check if we disable or enable the 360 effect - if (SirenCheckCameraPosition()) - { - _asm - { - popad - // 360 effect - // Carry on - jmp RETN_CVehicle_ProcessStuff_TestCameraPosition - } - } - else - { - _asm - { - popad - // 180 effect - // Replaced code - fnstsw ax - test ah, 5 - // Carry on - jmp RETN_CVehicle_ProcessStuff_TestCameraPosition2 - } + + // Check if we disable or enable the 360 effect + call SirenCheckCameraPosition + test al, al + jnz effect_180 + + // 360 effect + // Carry on + popad + jmp RETN_CVehicle_ProcessStuff_TestCameraPosition + + // 180 effect + effect_180: + popad + // Replaced code + fnstsw ax + test ah, 5 + // Carry on + jmp RETN_CVehicle_ProcessStuff_TestCameraPosition2 } } bool DisableVehicleSiren() @@ -892,24 +862,18 @@ void _declspec(naked) HOOK_CVehicleAudio_ProcessSirenSound() _asm { pushad - } - if (DisableVehicleSiren()) - { - _asm - { - popad - mov dl, 0 - jmp RETN_CVehicleAudio_GetVehicleSirenType - } - } - else - { - _asm - { - popad - mov dl, [ecx+42Dh] - jmp RETN_CVehicleAudio_GetVehicleSirenType - } + call DisableVehicleSiren + test al, al + jz not_disable + + popad + mov dl, 0 + jmp RETN_CVehicleAudio_GetVehicleSirenType + + not_disable: + popad + mov dl, [ecx+42Dh] + jmp RETN_CVehicleAudio_GetVehicleSirenType } } DWORD CALL_CVehicleAudio_ProcessCarHorn = 0x5002C0; @@ -918,12 +882,7 @@ void _declspec(naked) HOOK_CVehicleAudio_ProcessSirenSound1() _asm { mov pVehicleWithTheSiren, edi - pushad - } - _asm - { - popad call CALL_CVehicleAudio_ProcessCarHorn jmp RETN_CVehicleAudio_ProcessSirenSound1 } @@ -933,12 +892,7 @@ void _declspec(naked) HOOK_CVehicleAudio_ProcessSirenSound2() _asm { mov pVehicleWithTheSiren, edi - pushad - } - _asm - { - popad call CALL_CVehicleAudio_ProcessCarHorn jmp RETN_CVehicleAudio_ProcessSirenSound2 } @@ -948,12 +902,7 @@ void _declspec(naked) HOOK_CVehicleAudio_ProcessSirenSound3() _asm { mov pVehicleWithTheSiren, edi - pushad - } - _asm - { - popad call CALL_CVehicleAudio_ProcessCarHorn jmp RETN_CVehicleAudio_ProcessSirenSound3 } @@ -968,50 +917,44 @@ void _declspec(naked) HOOK_CMotorBike_ProcessStuff_PushSirenPositionBlue() // Grab our siren position vector lea eax,[esp+0ECh] pushad - // Grab our vehicle interface + // Grab our vehicle interface mov pVehicleWithTheSiren, esi - // move our position vector pointer into our position variable + // move our position vector pointer into our position variable mov vecRelativeSirenPosition, eax - } - bPointLights = false; - // Call our main process siren function - if (ProcessVehicleSirenPosition()) - { - _asm - { - popad - // Push our position - push eax - // move our R,G,B components into registers then push them - push 0FFh - mov ebp, dwBlue - push ebp - mov ebp, dwGreen - push ebp - mov eax, dwRed - lea ecx, [esi+15h] - push eax - // Return control - JMP RETN_CMotorbike_ProcessStuff_PostPushSirenPositionDual1 - } - } - else - { - _asm - { - popad - // Push our position - push eax - push 0FFh - // Push our R,G,B components (inverse order) - push ebp - push ebp - lea ecx, [esi+15h] - push eax - // Return control - JMP RETN_CMotorbike_ProcessStuff_PostPushSirenPositionDual1 - } + mov bPointLights, 0 + + call ProcessVehicleSirenPosition + test al, al + jz not_edit + + popad + // Push our position + push eax + // move our R,G,B components into registers then push them + push 0FFh + mov ebp, dwBlue + push ebp + mov ebp, dwGreen + push ebp + mov eax, dwRed + lea ecx, [esi+15h] + push eax + // Return control + JMP RETN_CMotorbike_ProcessStuff_PostPushSirenPositionDual1 + + not_edit: + popad + // Push our position + push eax + push 0FFh + // Push our R,G,B components (inverse order) + push ebp + push ebp + lea ecx, [esi+15h] + push eax + // Return control + JMP RETN_CMotorbike_ProcessStuff_PostPushSirenPositionDual1 } } @@ -1024,49 +967,44 @@ void _declspec(naked) HOOK_CMotorBike_ProcessStuff_PushSirenPositionRed() mov pVehicleWithTheSiren, esi // move our position vector pointer into our position variable mov vecRelativeSirenPosition, edx - } - bPointLights = false; - // Call our main process siren function - if (ProcessVehicleSirenPosition()) - { - _asm - { - popad - // Push our position - push edx - // Grab our siren position vector - mov [esp+4Fh], al - sub bl, al - push 0FFh - // move our R,G,B components into registers then push them ( Use eax because it's reset after ) - mov eax, dwBlue - push eax - mov eax, dwGreen - push eax - mov eax, dwRed - push eax - // Return control - JMP RETN_CMotorBike_ProcessStuff_PushSirenPositionDualRed - } - } - else - { - _asm - { - popad - // Push our position - push edx - mov [esp+4Fh], al - sub bl, al - push 0FFh - // Push our R,G,B components (inverse order) - push eax - push 0 - push 0 - // Return control - JMP RETN_CMotorBike_ProcessStuff_PushSirenPositionDualRed - } + mov bPointLights, 0 + + // Call our main process siren function + call ProcessVehicleSirenPosition + test al, al + jz not_edit + + popad + // Push our position + push edx + // Grab our siren position vector + mov [esp+4Fh], al + sub bl, al + push 0FFh + // move our R,G,B components into registers then push them ( Use eax because it's reset after ) + mov eax, dwBlue + push eax + mov eax, dwGreen + push eax + mov eax, dwRed + push eax + // Return control + JMP RETN_CMotorBike_ProcessStuff_PushSirenPositionDualRed + + not_edit: + popad + // Push our position + push edx + mov [esp+4Fh], al + sub bl, al + push 0FFh + // Push our R,G,B components (inverse order) + push eax + push 0 + push 0 + // Return control + JMP RETN_CMotorBike_ProcessStuff_PushSirenPositionDualRed } } DWORD RETN_CMotorbike_ProcessStuff_TestVehicleModel2 = 0x6BD41B; @@ -1076,24 +1014,19 @@ void _declspec(naked) HOOK_CMotorbike_ProcessStuff_TestVehicleModel() { pushad mov pVehicleWithTheSiren, esi - } - if (TestVehicleForSiren()) - { - _asm - { - popad - cmp word ptr [esi+22h], 20Bh - jmp RETN_CMotorbike_ProcessStuff_TestVehicleModel2 - } - } - else - { - _asm - { - popad - cmp word ptr [esi+22h], 20Bh - jmp RETN_CMotorbike_ProcessStuff_TestVehicleModel - } + + call TestVehicleForSiren + test al, al + jz not_test + + popad + cmp word ptr [esi+22h], 20Bh + jmp RETN_CMotorbike_ProcessStuff_TestVehicleModel2 + + not_test: + popad + cmp word ptr [esi+22h], 20Bh + jmp RETN_CMotorbike_ProcessStuff_TestVehicleModel } } DWORD dwValue = 0x858B4C; @@ -1103,49 +1036,45 @@ void _declspec(naked) HOOK_CVehicle_ProcessStuff_PushRGBPointLights() { pushad mov esi, pVehicleWithTheSiren - } - bPointLights = true; - if (ProcessVehicleSirenPosition()) - { - _asm - { - popad - mov edx, dwBlue - mov eax, dwGreen - mov ecx, dwRed - mov [esp+30h], edx - fild dword ptr [esp+30h] - mov [esp+30h], eax - mov eax, [esp+44h] - fmul dword ptr ds:[0858B4Ch] - fstp dword ptr [esp+8] - fild dword ptr [esp+30h] - mov [esp+30h], ecx - mov ecx, [esp+48h] - fmul dword ptr ds:[0858B4Ch] - fstp dword ptr [esp+4] - fild dword ptr [esp+30h] - JMP RETN_CVehicle_ProcessStuff_PushRGBPointLights - } - } - else - { - _asm - { - popad - fild dword ptr [esp+30h] - mov [esp+30h], eax - mov eax, [esp+44h] - fmul dword ptr ds:[0858B4Ch] - fstp dword ptr [esp+8] - fild dword ptr [esp+30h] - mov [esp+30h], ecx - mov ecx, [esp+48h] - fmul dword ptr ds:[0858B4Ch] - fstp dword ptr [esp+4] - fild dword ptr [esp+30h] - JMP RETN_CVehicle_ProcessStuff_PushRGBPointLights - } + + mov bPointLights, 0 + + call ProcessVehicleSirenPosition + test al, al + jz is_false + + popad + mov edx, dwBlue + mov eax, dwGreen + mov ecx, dwRed + mov [esp+30h], edx + fild dword ptr [esp+30h] + mov [esp+30h], eax + mov eax, [esp+44h] + fmul dword ptr ds:[0858B4Ch] + fstp dword ptr [esp+8] + fild dword ptr [esp+30h] + mov [esp+30h], ecx + mov ecx, [esp+48h] + fmul dword ptr ds:[0858B4Ch] + fstp dword ptr [esp+4] + fild dword ptr [esp+30h] + JMP RETN_CVehicle_ProcessStuff_PushRGBPointLights + + is_false: + popad + fild dword ptr [esp+30h] + mov [esp+30h], eax + mov eax, [esp+44h] + fmul dword ptr ds:[0858B4Ch] + fstp dword ptr [esp+8] + fild dword ptr [esp+30h] + mov [esp+30h], ecx + mov ecx, [esp+48h] + fmul dword ptr ds:[0858B4Ch] + fstp dword ptr [esp+4] + fild dword ptr [esp+30h] + JMP RETN_CVehicle_ProcessStuff_PushRGBPointLights } } @@ -1155,27 +1084,22 @@ void _declspec(naked) HOOK_CVehicle_ProcessStuff_StartPointLightCode() { pushad mov pVehicleWithTheSiren, esi - } - if (DoesVehicleHaveSiren()) - { - _asm - { - popad - fld dword ptr [eax+28h] - mov edx, [ecx] - fadd st, st - jmp RETN_CVehicle_ProcessStuff_StartPointLightCode - } - } - else - { - _asm - { - popad - movzx eax, byte ptr [esp+88h] - mov [esp+50h], eax - jmp RETN_CVehicle_ProcessStuff_IgnorePointLightCode - } + + call DoesVehicleHaveSiren + test al, al + jz is_false + + popad + fld dword ptr [eax+28h] + mov edx, [ecx] + fadd st, st + jmp RETN_CVehicle_ProcessStuff_StartPointLightCode + + is_false: + popad + movzx eax, byte ptr [esp+88h] + mov [esp+50h], eax + jmp RETN_CVehicle_ProcessStuff_IgnorePointLightCode } } // Water Cannon Stuff @@ -1209,32 +1133,28 @@ void _declspec(naked) HOOK_CEventHitByWaterCannon() mov eax, [edx] mov pPedHitByWaterCannonInterface, esi mov pVehicleWithTheCannonMounted, eax - } - if (TriggerTheEvent()) - { - _asm - { - popad - // Cancel. - jmp RETURN_CWaterCannon_PushPeds_RETN_Cancel - } - } - else - { - _asm - { - popad - // Replaced code - push ebp - push ecx - lea ecx, [esp+0B0h] - // Call our function - call CALL_CEventHitByWaterCannon - // Go back to execution - jmp RETURN_CWaterCannon_PushPeds_RETN - } + + call TriggerTheEvent + test al, al + jz not_trigger + + popad + // Cancel. + jmp RETURN_CWaterCannon_PushPeds_RETN_Cancel + + not_trigger: + popad + // Replaced code + push ebp + push ecx + lea ecx, [esp+0B0h] + // Call our function + call CALL_CEventHitByWaterCannon + // Go back to execution + jmp RETURN_CWaterCannon_PushPeds_RETN } } + CPedSAInterface* pPedUsingJetpack; DWORD dwJetpackPedIntelligence = NULL; bool IsUsingJetPack() @@ -1279,22 +1199,17 @@ void _declspec(naked) HOOK_CTaskSimpleJetpack_ProcessInput() { mov pPedUsingJetpack, edi pushad - } - if (AllowJetPack()) - { - _asm - { - popad - jmp RETN_CTaskSimpleJetpack_ProcessInputEnable - } - } - else - { - _asm - { - popad - jmp RETN_CTaskSimpleJetpack_ProcessInputDisabled - } + + call AllowJetPack + test al, al + jz not_allowed + + popad + jmp RETN_CTaskSimpleJetpack_ProcessInputEnable + + not_allowed: + popad + jmp RETN_CTaskSimpleJetpack_ProcessInputDisabled } } @@ -1304,24 +1219,19 @@ void _declspec(naked) HOOK_CTaskSimplePlayerOnFoot_ProcessWeaponFire() { pushad mov pPedUsingJetpack, esi - } - if (AllowJetPack()) - { - _asm - { - popad - xor al, al - jmp RETN_CTaskSimplePlayerOnFoot_ProcessWeaponFire - } - } - else - { - _asm - { - popad - call RETN_CTaskSimplePlayerOnFoot_ProcessWeaponFire_Call - jmp RETN_CTaskSimplePlayerOnFoot_ProcessWeaponFire - } + + call AllowJetPack + test al, al + jz not_allowed + + popad + xor al, al + jmp RETN_CTaskSimplePlayerOnFoot_ProcessWeaponFire + + not_allowed: + popad + call RETN_CTaskSimplePlayerOnFoot_ProcessWeaponFire_Call + jmp RETN_CTaskSimplePlayerOnFoot_ProcessWeaponFire } } @@ -1349,20 +1259,19 @@ void _declspec(naked) HOOK_CWorld_RemoveFallenPeds() jp [RemoveFallenPeds_Cancel] pushad mov pFallingPedInterface, esi - } - if (CWorld_Remove_FallenPedsCheck()) - { - _asm - { - popad -RemoveFallenPeds_Cancel: - jmp RETURN_CWorld_RemoveFallenPeds_Cancel - } - } - _asm - { + + call CWorld_Remove_FallenPedsCheck + test al, al + jz is_false + + popad + + is_false: popad jmp RETURN_CWorld_RemoveFallenPeds_Cont + + RemoveFallenPeds_Cancel: + jmp RETURN_CWorld_RemoveFallenPeds_Cancel } } @@ -1394,24 +1303,22 @@ void _declspec(naked) HOOK_CWorld_RemoveFallenCars() { pushad mov pFallingVehicleInterface, esi - } - if (CWorld_Remove_FallenVehiclesCheck()) - { - _asm - { - popad - jmp RETURN_CWorld_RemoveFallenCars_Cancel - } - } - _asm - { + + call CWorld_Remove_FallenVehiclesCheck + test al, al + jz skip + + popad + jmp RETURN_CWorld_RemoveFallenCars_Cancel + + skip: popad mov eax, [esi + 14h] test eax, eax jz RemoveFallenCars_Cancel jmp RETURN_CWorld_RemoveFallenCars_Cont - RemoveFallenCars_Cancel: + RemoveFallenCars_Cancel: jmp HOOK_CWorld_RemoveFallenCars_Cont1 } } @@ -1462,12 +1369,11 @@ void _declspec(naked) HOOK_CVehicleModelInterface_SetClump() pushad mov pLoadingClump, eax mov pLoadingModelInfo, esi - } - // Init our supported upgrades structure for this model info - CVehicleModelInterface_SetClump(); - // Perform overwrite sequence and jump back - _asm - { + + // Init our supported upgrades structure for this model info + call CVehicleModelInterface_SetClump + // Perform overwrite sequence and jump back + popad push eax mov ecx, esi @@ -1486,11 +1392,8 @@ void _declspec(naked) HOOK_CBoat_ApplyDamage() test eax, 20h jz boatCanBeDamaged fst dword ptr [esi+4C0h] - } - -boatCanBeDamaged: - _asm - { + + boatCanBeDamaged: pop eax jmp RETURN_CBoat_ApplyDamage } @@ -1567,25 +1470,21 @@ void _declspec(naked) HOOK_CMultiplayerSA_ToggleTyreSmoke() { pushad mov pTyreSmokePed, ecx - } - if (!IsPlayerPedLocal()) - { - _asm - { - popad - jmp dwReturnIgnorePed - } - } + call IsPlayerPedLocal + test al, al + jnz skip - _asm - { + popad + jmp dwReturnIgnorePed + + skip: popad test eax, 20000h jnz ToggleTyreSmoke_Cancel jmp dwReturnAddressTyreSmoke - ToggleTyreSmoke_Cancel: + ToggleTyreSmoke_Cancel: jmp dwReturnIgnorePed } } @@ -1660,16 +1559,16 @@ void _declspec(naked) HOOK_CProjectile_FixExplosionLocation() { mov pExplosionEntity, esi pushad - } - UpdateExplosionLocation(); - _asm - { + + call UpdateExplosionLocation + popad mov eax, [esi+14h] test eax, eax jz skip add eax, 30h jmp RETURN_CProjectile_FixExplosionLocation + skip: lea eax, [esi+4] jmp RETURN_CProjectile_FixExplosionLocation diff --git a/Client/multiplayer_sa/CMultiplayerSA_VehicleCollision.cpp b/Client/multiplayer_sa/CMultiplayerSA_VehicleCollision.cpp index c17b2aa297..30f62d6ae9 100644 --- a/Client/multiplayer_sa/CMultiplayerSA_VehicleCollision.cpp +++ b/Client/multiplayer_sa/CMultiplayerSA_VehicleCollision.cpp @@ -64,12 +64,9 @@ static void _declspec(naked) HOOK_CAutomobile_ProcessControl_VehicleDamage() { pushad mov pCollisionVehicle, ecx - } - TriggerVehicleCollisionEvent(); + call TriggerVehicleCollisionEvent - _asm - { popad mov ecx, pCollisionVehicle mov esi, pCollisionVehicle @@ -97,12 +94,9 @@ static void _declspec(naked) HOOK_CBike_ProcessControl_VehicleDamage() { pushad mov pCollisionVehicle, ecx - } + + call TriggerVehicleCollisionEvent - TriggerVehicleCollisionEvent(); - - _asm - { popad mov ecx, pCollisionVehicle mov esi, pCollisionVehicle @@ -131,12 +125,9 @@ static void _declspec(naked) HOOK_CBoat_ProcessControl_VehicleDamage() { pushad mov pCollisionVehicle, ecx - } - - TriggerVehicleCollisionEvent(); + + call TriggerVehicleCollisionEvent - _asm - { popad mov ecx, pCollisionVehicle mov esi, pCollisionVehicle @@ -163,12 +154,9 @@ static void _declspec(naked) HOOK_CTrain_ProcessControl_VehicleDamage() { pushad mov pCollisionVehicle, esi - } - TriggerVehicleCollisionEvent(); + call TriggerVehicleCollisionEvent - _asm - { popad mov esi, pCollisionVehicle mov al, ds:[0BA6728h] diff --git a/Client/multiplayer_sa/multiplayer_keysync.cpp b/Client/multiplayer_sa/multiplayer_keysync.cpp index 5807350dbb..2e79ec91e9 100644 --- a/Client/multiplayer_sa/multiplayer_keysync.cpp +++ b/Client/multiplayer_sa/multiplayer_keysync.cpp @@ -15,9 +15,6 @@ extern CMultiplayerSA* pMultiplayer; -DWORD dwCurrentPlayerPed = 0; // stores the player ped temporarily during hooks -DWORD dwCurrentVehicle = 0; // stores the current vehicle during the hooks - DWORD dwParameter = 0; BOOL bRadioHackInstalled = FALSE; @@ -416,7 +413,7 @@ void SwitchContext(CPed* thePed) pGameInterface->OnPedContextChange(thePed); } -void SwitchContext(CPedSAInterface* ped) +static void SwitchContext_PedInterface(CPedSAInterface* ped) { SClientEntity* pPedClientEntity = pGameInterface->GetPools()->GetPed((DWORD*)ped); CPed* thePed = pPedClientEntity ? pPedClientEntity->pEntity : nullptr; @@ -482,7 +479,7 @@ void SwitchContext(CVehicle* pVehicle) } } -void SwitchContext(CVehicleSAInterface* pVehicleInterface) +static void SwitchContext_VehicleInterface(CVehicleSAInterface* pVehicleInterface) { // Grab the CVehicle for the given vehicle interface CPools* pPools = pGameInterface->GetPools(); @@ -507,8 +504,6 @@ VOID _declspec(naked) HOOK_CPlayerPed__ProcessControl() // Assumes no reentrancy _asm { - mov dwCurrentPlayerPed, ecx - // Save incase of abort mov PlayerPed__ProcessControl_Saved.eax, eax mov PlayerPed__ProcessControl_Saved.ecx, ecx @@ -518,24 +513,19 @@ VOID _declspec(naked) HOOK_CPlayerPed__ProcessControl() mov PlayerPed__ProcessControl_Saved.ebp, ebp mov PlayerPed__ProcessControl_Saved.esi, esi mov PlayerPed__ProcessControl_Saved.edi, edi - pushad - } - SwitchContext((CPedSAInterface*)dwCurrentPlayerPed); - - _asm - { - popad - mov edx, FUNC_CPlayerPed__ProcessControl - call edx pushad - } + push ecx + call SwitchContext_PedInterface + popad - ReturnContextToLocalPlayer(); + mov edx, FUNC_CPlayerPed__ProcessControl + call edx - _asm - { + pushad + call ReturnContextToLocalPlayer popad + retn } } @@ -554,12 +544,8 @@ void _declspec(naked) CPlayerPed__ProcessControl_Abort() mov esi, PlayerPed__ProcessControl_Saved.esi mov edi, PlayerPed__ProcessControl_Saved.edi pushad - } - - ReturnContextToLocalPlayer(); - _asm - { + call ReturnContextToLocalPlayer popad retn } @@ -571,25 +557,18 @@ VOID _declspec(naked) HOOK_CAutomobile__ProcessControl() { _asm { - mov dwCurrentVehicle, ecx pushad - } - - SwitchContext((CVehicleSAInterface*)dwCurrentVehicle); - - _asm - { + push ecx + call SwitchContext_VehicleInterface popad - mov edx, FUNC_CAutomobile__ProcessControl - call edx - pushad - } - ReturnContextToLocalPlayer(); + mov edx, FUNC_CAutomobile__ProcessControl + call edx - _asm - { + pushad + call ReturnContextToLocalPlayer popad + retn } } @@ -600,25 +579,18 @@ VOID _declspec(naked) HOOK_CMonsterTruck__ProcessControl() { _asm { - mov dwCurrentVehicle, ecx pushad - } - - SwitchContext((CVehicleSAInterface*)dwCurrentVehicle); - - _asm - { + push ecx + call SwitchContext_VehicleInterface popad - mov edx, FUNC_CMonsterTruck__ProcessControl - call edx - pushad - } - ReturnContextToLocalPlayer(); + mov edx, FUNC_CMonsterTruck__ProcessControl + call edx - _asm - { + pushad + call ReturnContextToLocalPlayer popad + retn } } @@ -629,25 +601,18 @@ VOID _declspec(naked) HOOK_CTrailer__ProcessControl() { _asm { - mov dwCurrentVehicle, ecx pushad - } - - SwitchContext((CVehicleSAInterface*)dwCurrentVehicle); - - _asm - { + push ecx + call SwitchContext_VehicleInterface popad - mov edx, FUNC_CTrailer__ProcessControl - call edx - pushad - } - ReturnContextToLocalPlayer(); + mov edx, FUNC_CTrailer__ProcessControl + call edx - _asm - { + pushad + call ReturnContextToLocalPlayer popad + retn } } @@ -658,25 +623,18 @@ VOID _declspec(naked) HOOK_CQuadBike__ProcessControl() { _asm { - mov dwCurrentVehicle, ecx pushad - } - - SwitchContext((CVehicleSAInterface*)dwCurrentVehicle); - - _asm - { + push ecx + call SwitchContext_VehicleInterface popad - mov edx, FUNC_CQuadBike__ProcessControl - call edx - pushad - } - ReturnContextToLocalPlayer(); + mov edx, FUNC_CQuadBike__ProcessControl + call edx - _asm - { + pushad + call ReturnContextToLocalPlayer popad + retn } } @@ -687,25 +645,18 @@ VOID _declspec(naked) HOOK_CPlane__ProcessControl() { _asm { - mov dwCurrentVehicle, ecx pushad - } - - SwitchContext((CVehicleSAInterface*)dwCurrentVehicle); - - _asm - { + push ecx + call SwitchContext_VehicleInterface popad - mov edx, FUNC_CPlane__ProcessControl - call edx - pushad - } - ReturnContextToLocalPlayer(); + mov edx, FUNC_CPlane__ProcessControl + call edx - _asm - { + pushad + call ReturnContextToLocalPlayer popad + retn } } @@ -716,25 +667,18 @@ VOID _declspec(naked) HOOK_CBmx__ProcessControl() { _asm { - mov dwCurrentVehicle, ecx pushad - } - - SwitchContext((CVehicleSAInterface*)dwCurrentVehicle); - - _asm - { + push ecx + call SwitchContext_VehicleInterface popad - mov edx, FUNC_CBmx__ProcessControl - call edx - pushad - } - ReturnContextToLocalPlayer(); + mov edx, FUNC_CBmx__ProcessControl + call edx - _asm - { + pushad + call ReturnContextToLocalPlayer popad + retn } } @@ -745,25 +689,18 @@ VOID _declspec(naked) HOOK_CTrain__ProcessControl() { _asm { - mov dwCurrentVehicle, ecx pushad - } - - SwitchContext((CVehicleSAInterface*)dwCurrentVehicle); - - _asm - { + push ecx + call SwitchContext_VehicleInterface popad - mov edx, FUNC_CTrain__ProcessControl - call edx - pushad - } - ReturnContextToLocalPlayer(); + mov edx, FUNC_CTrain__ProcessControl + call edx - _asm - { + pushad + call ReturnContextToLocalPlayer popad + retn } } @@ -774,25 +711,18 @@ VOID _declspec(naked) HOOK_CBoat__ProcessControl() { _asm { - mov dwCurrentVehicle, ecx pushad - } - - SwitchContext((CVehicleSAInterface*)dwCurrentVehicle); - - _asm - { + push ecx + call SwitchContext_VehicleInterface popad - mov edx, FUNC_CBoat__ProcessControl - call edx - pushad - } - ReturnContextToLocalPlayer(); + mov edx, FUNC_CBoat__ProcessControl + call edx - _asm - { + pushad + call ReturnContextToLocalPlayer popad + retn } } @@ -803,25 +733,18 @@ VOID _declspec(naked) HOOK_CBike__ProcessControl() { _asm { - mov dwCurrentVehicle, ecx pushad - } - - SwitchContext((CVehicleSAInterface*)dwCurrentVehicle); - - _asm - { + push ecx + call SwitchContext_VehicleInterface popad - mov edx, FUNC_CBike__ProcessControl - call edx - pushad - } - ReturnContextToLocalPlayer(); + mov edx, FUNC_CBike__ProcessControl + call edx - _asm - { + pushad + call ReturnContextToLocalPlayer popad + retn } } @@ -832,25 +755,18 @@ VOID _declspec(naked) HOOK_CHeli__ProcessControl() { _asm { - mov dwCurrentVehicle, ecx pushad - } - - SwitchContext((CVehicleSAInterface*)dwCurrentVehicle); - - _asm - { + push ecx + call SwitchContext_VehicleInterface popad - mov edx, FUNC_CHeli__ProcessControl - call edx - pushad - } - ReturnContextToLocalPlayer(); + mov edx, FUNC_CHeli__ProcessControl + call edx - _asm - { + pushad + call ReturnContextToLocalPlayer popad + retn } }