From 697220bc165f0fca92d7572fe0c6c2309d6c03e8 Mon Sep 17 00:00:00 2001 From: lynconsix Date: Sat, 4 Jan 2025 17:00:12 -0200 Subject: [PATCH 1/3] Rename handlers and events for entity processing consistency --- Client/game_sa/CObjectSA.cpp | 2 +- Client/mods/deathmatch/logic/CClientGame.cpp | 14 ++-- Client/mods/deathmatch/logic/CClientGame.h | 4 +- Client/multiplayer_sa/CMultiplayerSA.cpp | 70 ++++++++++---------- Client/multiplayer_sa/CMultiplayerSA.h | 2 +- Client/sdk/multiplayer/CMultiplayer.h | 4 +- 6 files changed, 48 insertions(+), 48 deletions(-) diff --git a/Client/game_sa/CObjectSA.cpp b/Client/game_sa/CObjectSA.cpp index 83d2feef23..bd1041ccb0 100644 --- a/Client/game_sa/CObjectSA.cpp +++ b/Client/game_sa/CObjectSA.cpp @@ -44,7 +44,7 @@ static void _declspec(naked) HOOK_CCObject_PreRender() void CObjectSA::StaticSetHooks() { // Patch CObject::PreRender. We don't want the scaling code to execute - // We'll scale the object entity matrix after onClientPedsProcessed event + // We'll scale the object entity matrix after onClientEntitiesProcessed event // 5E - pop asi // 83 C4 10 - add esp, 0x10 // C3 - ret diff --git a/Client/mods/deathmatch/logic/CClientGame.cpp b/Client/mods/deathmatch/logic/CClientGame.cpp index b769ccd953..0518873162 100644 --- a/Client/mods/deathmatch/logic/CClientGame.cpp +++ b/Client/mods/deathmatch/logic/CClientGame.cpp @@ -276,7 +276,7 @@ CClientGame::CClientGame(bool bLocalPlay) : m_ServerInfo(new CServerInfo()) g_pMultiplayer->SetChokingHandler(CClientGame::StaticChokingHandler); g_pMultiplayer->SetPreWorldProcessHandler(CClientGame::StaticPreWorldProcessHandler); g_pMultiplayer->SetPostWorldProcessHandler(CClientGame::StaticPostWorldProcessHandler); - g_pMultiplayer->SetPostWorldProcessPedsAfterPreRenderHandler(CClientGame::StaticPostWorldProcessPedsAfterPreRenderHandler); + g_pMultiplayer->SetPostWorldProcessEntitiesAfterPreRenderHandler(CClientGame::StaticPostWorldProcessEntitiesAfterPreRenderHandler); g_pMultiplayer->SetPreFxRenderHandler(CClientGame::StaticPreFxRenderHandler); g_pMultiplayer->SetPostColorFilterRenderHandler(CClientGame::StaticPostColorFilterRenderHandler); g_pMultiplayer->SetPreHudRenderHandler(CClientGame::StaticPreHudRenderHandler); @@ -484,7 +484,7 @@ CClientGame::~CClientGame() g_pMultiplayer->SetChokingHandler(NULL); g_pMultiplayer->SetPreWorldProcessHandler(NULL); g_pMultiplayer->SetPostWorldProcessHandler(NULL); - g_pMultiplayer->SetPostWorldProcessPedsAfterPreRenderHandler(nullptr); + g_pMultiplayer->SetPostWorldProcessEntitiesAfterPreRenderHandler(nullptr); g_pMultiplayer->SetPreFxRenderHandler(NULL); g_pMultiplayer->SetPostColorFilterRenderHandler(nullptr); g_pMultiplayer->SetPreHudRenderHandler(NULL); @@ -2727,7 +2727,7 @@ void CClientGame::AddBuiltInEvents() // Game events m_Events.AddEvent("onClientPreRender", "", NULL, false); - m_Events.AddEvent("onClientPedsProcessed", "", NULL, false); + m_Events.AddEvent("onClientEntitiesProcessed", "", NULL, false); m_Events.AddEvent("onClientHUDRender", "", NULL, false); m_Events.AddEvent("onClientRender", "", NULL, false); m_Events.AddEvent("onClientMinimize", "", NULL, false); @@ -3612,9 +3612,9 @@ void CClientGame::StaticPostWorldProcessHandler() g_pClientGame->PostWorldProcessHandler(); } -void CClientGame::StaticPostWorldProcessPedsAfterPreRenderHandler() +void CClientGame::StaticPostWorldProcessEntitiesAfterPreRenderHandler() { - g_pClientGame->PostWorldProcessPedsAfterPreRenderHandler(); + g_pClientGame->PostWorldProcessEntitiesAfterPreRenderHandler(); } void CClientGame::StaticPreFxRenderHandler() @@ -3872,10 +3872,10 @@ void CClientGame::PostWorldProcessHandler() m_pRootEntity->CallEvent("onClientPreRender", Arguments, false); } -void CClientGame::PostWorldProcessPedsAfterPreRenderHandler() +void CClientGame::PostWorldProcessEntitiesAfterPreRenderHandler() { CLuaArguments Arguments; - m_pRootEntity->CallEvent("onClientPedsProcessed", Arguments, false); + m_pRootEntity->CallEvent("onClientEntitiesProcessed", Arguments, false); g_pClientGame->GetModelRenderer()->Update(); } diff --git a/Client/mods/deathmatch/logic/CClientGame.h b/Client/mods/deathmatch/logic/CClientGame.h index b5819d8ee2..0e9e79cc81 100644 --- a/Client/mods/deathmatch/logic/CClientGame.h +++ b/Client/mods/deathmatch/logic/CClientGame.h @@ -524,7 +524,7 @@ class CClientGame static bool StaticChokingHandler(unsigned char ucWeaponType); static void StaticPreWorldProcessHandler(); static void StaticPostWorldProcessHandler(); - static void StaticPostWorldProcessPedsAfterPreRenderHandler(); + static void StaticPostWorldProcessEntitiesAfterPreRenderHandler(); static void StaticPreFxRenderHandler(); static void StaticPostColorFilterRenderHandler(); static void StaticPreHudRenderHandler(); @@ -573,7 +573,7 @@ class CClientGame bool ChokingHandler(unsigned char ucWeaponType); void PreWorldProcessHandler(); void PostWorldProcessHandler(); - void PostWorldProcessPedsAfterPreRenderHandler(); + void PostWorldProcessEntitiesAfterPreRenderHandler(); void CAnimBlendAssocDestructorHandler(CAnimBlendAssociationSAInterface* pThis); CAnimBlendAssociationSAInterface* AddAnimationHandler(RpClump* pClump, AssocGroupId animGroup, AnimationId animID); CAnimBlendAssociationSAInterface* AddAnimationAndSyncHandler(RpClump* pClump, CAnimBlendAssociationSAInterface* pAnimAssocToSyncWith, diff --git a/Client/multiplayer_sa/CMultiplayerSA.cpp b/Client/multiplayer_sa/CMultiplayerSA.cpp index f0cd566133..95445f6dcd 100644 --- a/Client/multiplayer_sa/CMultiplayerSA.cpp +++ b/Client/multiplayer_sa/CMultiplayerSA.cpp @@ -388,37 +388,37 @@ static const std::array shadowAddr{ 0x73A48F // CWeapon::AddGunshell }; -PreContextSwitchHandler* m_pPreContextSwitchHandler = NULL; -PostContextSwitchHandler* m_pPostContextSwitchHandler = NULL; -PreWeaponFireHandler* m_pPreWeaponFireHandler = NULL; -PostWeaponFireHandler* m_pPostWeaponFireHandler = NULL; -BulletImpactHandler* m_pBulletImpactHandler = NULL; -BulletFireHandler* m_pBulletFireHandler = NULL; -DamageHandler* m_pDamageHandler = NULL; -DeathHandler* m_pDeathHandler = NULL; -FireHandler* m_pFireHandler = NULL; -ProjectileHandler* m_pProjectileHandler = NULL; -ProjectileStopHandler* m_pProjectileStopHandler = NULL; -ProcessCamHandler* m_pProcessCamHandler = NULL; -ChokingHandler* m_pChokingHandler = NULL; -ExplosionHandler* m_pExplosionHandler = NULL; -BreakTowLinkHandler* m_pBreakTowLinkHandler = NULL; -DrawRadarAreasHandler* m_pDrawRadarAreasHandler = NULL; -Render3DStuffHandler* m_pRender3DStuffHandler = NULL; -PreWorldProcessHandler* m_pPreWorldProcessHandler = NULL; -PostWorldProcessHandler* m_pPostWorldProcessHandler = NULL; -PostWorldProcessPedsAfterPreRenderHandler* m_postWorldProcessPedsAfterPreRenderHandler = nullptr; -IdleHandler* m_pIdleHandler = NULL; -PreFxRenderHandler* m_pPreFxRenderHandler = NULL; -PostColorFilterRenderHandler* m_pPostColorFilterRenderHandler = nullptr; -PreHudRenderHandler* m_pPreHudRenderHandler = NULL; -ProcessCollisionHandler* m_pProcessCollisionHandler = NULL; -HeliKillHandler* m_pHeliKillHandler = NULL; -ObjectDamageHandler* m_pObjectDamageHandler = NULL; -ObjectBreakHandler* m_pObjectBreakHandler = NULL; -FxSystemDestructionHandler* m_pFxSystemDestructionHandler = NULL; -DrivebyAnimationHandler* m_pDrivebyAnimationHandler = NULL; -AudioZoneRadioSwitchHandler* m_pAudioZoneRadioSwitchHandler = NULL; +PreContextSwitchHandler* m_pPreContextSwitchHandler = NULL; +PostContextSwitchHandler* m_pPostContextSwitchHandler = NULL; +PreWeaponFireHandler* m_pPreWeaponFireHandler = NULL; +PostWeaponFireHandler* m_pPostWeaponFireHandler = NULL; +BulletImpactHandler* m_pBulletImpactHandler = NULL; +BulletFireHandler* m_pBulletFireHandler = NULL; +DamageHandler* m_pDamageHandler = NULL; +DeathHandler* m_pDeathHandler = NULL; +FireHandler* m_pFireHandler = NULL; +ProjectileHandler* m_pProjectileHandler = NULL; +ProjectileStopHandler* m_pProjectileStopHandler = NULL; +ProcessCamHandler* m_pProcessCamHandler = NULL; +ChokingHandler* m_pChokingHandler = NULL; +ExplosionHandler* m_pExplosionHandler = NULL; +BreakTowLinkHandler* m_pBreakTowLinkHandler = NULL; +DrawRadarAreasHandler* m_pDrawRadarAreasHandler = NULL; +Render3DStuffHandler* m_pRender3DStuffHandler = NULL; +PreWorldProcessHandler* m_pPreWorldProcessHandler = NULL; +PostWorldProcessHandler* m_pPostWorldProcessHandler = NULL; +PostWorldProcessEntitiesAfterPreRenderHandler* m_postWorldProcessEntitiesAfterPreRenderHandler = nullptr; +IdleHandler* m_pIdleHandler = NULL; +PreFxRenderHandler* m_pPreFxRenderHandler = NULL; +PostColorFilterRenderHandler* m_pPostColorFilterRenderHandler = nullptr; +PreHudRenderHandler* m_pPreHudRenderHandler = NULL; +ProcessCollisionHandler* m_pProcessCollisionHandler = NULL; +HeliKillHandler* m_pHeliKillHandler = NULL; +ObjectDamageHandler* m_pObjectDamageHandler = NULL; +ObjectBreakHandler* m_pObjectBreakHandler = NULL; +FxSystemDestructionHandler* m_pFxSystemDestructionHandler = NULL; +DrivebyAnimationHandler* m_pDrivebyAnimationHandler = NULL; +AudioZoneRadioSwitchHandler* m_pAudioZoneRadioSwitchHandler = NULL; CEntitySAInterface* dwSavedPlayerPointer = 0; CEntitySAInterface* activeEntityForStreaming = 0; // the entity that the streaming system considers active @@ -2647,9 +2647,9 @@ void CMultiplayerSA::SetPostWorldProcessHandler(PostWorldProcessHandler* pHandle m_pPostWorldProcessHandler = pHandler; } -void CMultiplayerSA::SetPostWorldProcessPedsAfterPreRenderHandler(PostWorldProcessPedsAfterPreRenderHandler* pHandler) +void CMultiplayerSA::SetPostWorldProcessEntitiesAfterPreRenderHandler(PostWorldProcessEntitiesAfterPreRenderHandler* pHandler) { - m_postWorldProcessPedsAfterPreRenderHandler = pHandler; + m_postWorldProcessEntitiesAfterPreRenderHandler = pHandler; } void CMultiplayerSA::SetIdleHandler(IdleHandler* pHandler) @@ -7258,8 +7258,8 @@ void _declspec(naked) HOOK_CTaskSimpleSwim_ProcessSwimmingResistance() void PostCWorld_ProcessPedsAfterPreRender() { - if (m_postWorldProcessPedsAfterPreRenderHandler) - m_postWorldProcessPedsAfterPreRenderHandler(); + if (m_postWorldProcessEntitiesAfterPreRenderHandler) + m_postWorldProcessEntitiesAfterPreRenderHandler(); // Scale the object entities CPools* pools = pGameInterface->GetPools(); diff --git a/Client/multiplayer_sa/CMultiplayerSA.h b/Client/multiplayer_sa/CMultiplayerSA.h index 0dd642cb4b..32e3ff64d5 100644 --- a/Client/multiplayer_sa/CMultiplayerSA.h +++ b/Client/multiplayer_sa/CMultiplayerSA.h @@ -114,7 +114,7 @@ class CMultiplayerSA : public CMultiplayer void SetChokingHandler(ChokingHandler* pChokingHandler); void SetPreWorldProcessHandler(PreWorldProcessHandler* pHandler); void SetPostWorldProcessHandler(PostWorldProcessHandler* pHandler); - void SetPostWorldProcessPedsAfterPreRenderHandler(PostWorldProcessPedsAfterPreRenderHandler* pHandler); + void SetPostWorldProcessEntitiesAfterPreRenderHandler(PostWorldProcessEntitiesAfterPreRenderHandler* pHandler); void SetIdleHandler(IdleHandler* pHandler); void SetPreFxRenderHandler(PreFxRenderHandler* pHandler); void SetPostColorFilterRenderHandler(PostColorFilterRenderHandler* pHandler) override; diff --git a/Client/sdk/multiplayer/CMultiplayer.h b/Client/sdk/multiplayer/CMultiplayer.h index 33e349ea71..7eced76fce 100644 --- a/Client/sdk/multiplayer/CMultiplayer.h +++ b/Client/sdk/multiplayer/CMultiplayer.h @@ -99,7 +99,7 @@ typedef void(RenderHeliLightHandler)(); typedef bool(ChokingHandler)(unsigned char ucWeaponType); typedef void(PreWorldProcessHandler)(); typedef void(PostWorldProcessHandler)(); -typedef void(PostWorldProcessPedsAfterPreRenderHandler)(); +typedef void(PostWorldProcessEntitiesAfterPreRenderHandler)(); typedef void(IdleHandler)(); typedef void(PreFxRenderHandler)(); typedef void(PostColorFilterRenderHandler)(); @@ -230,7 +230,7 @@ class CMultiplayer virtual void SetProjectileStopHandler(ProjectileStopHandler* pProjectileHandler) = 0; virtual void SetPreWorldProcessHandler(PreWorldProcessHandler* pHandler) = 0; virtual void SetPostWorldProcessHandler(PostWorldProcessHandler* pHandler) = 0; - virtual void SetPostWorldProcessPedsAfterPreRenderHandler(PostWorldProcessPedsAfterPreRenderHandler* pHandler) = 0; + virtual void SetPostWorldProcessEntitiesAfterPreRenderHandler(PostWorldProcessEntitiesAfterPreRenderHandler* pHandler) = 0; virtual void SetIdleHandler(IdleHandler* pHandler) = 0; virtual void SetPreFxRenderHandler(PreFxRenderHandler* pHandler) = 0; virtual void SetPostColorFilterRenderHandler(PostColorFilterRenderHandler* pHandler) = 0; From 7bc617c4ab652930c6b193b28b61daaf95ba8b7f Mon Sep 17 00:00:00 2001 From: lynconsix Date: Tue, 7 Jan 2025 20:33:49 -0200 Subject: [PATCH 2/3] Rename event from onClientEntitiesProcessed to onClientPostUpdate and update related references --- Client/game_sa/CObjectSA.cpp | 2 +- Client/mods/deathmatch/logic/CClientGame.cpp | 10 ++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/Client/game_sa/CObjectSA.cpp b/Client/game_sa/CObjectSA.cpp index bd1041ccb0..6722429cd8 100644 --- a/Client/game_sa/CObjectSA.cpp +++ b/Client/game_sa/CObjectSA.cpp @@ -44,7 +44,7 @@ static void _declspec(naked) HOOK_CCObject_PreRender() void CObjectSA::StaticSetHooks() { // Patch CObject::PreRender. We don't want the scaling code to execute - // We'll scale the object entity matrix after onClientEntitiesProcessed event + // We'll scale the object entity matrix after onClientPostUpdate event // 5E - pop asi // 83 C4 10 - add esp, 0x10 // C3 - ret diff --git a/Client/mods/deathmatch/logic/CClientGame.cpp b/Client/mods/deathmatch/logic/CClientGame.cpp index 0518873162..bd15b3aabd 100644 --- a/Client/mods/deathmatch/logic/CClientGame.cpp +++ b/Client/mods/deathmatch/logic/CClientGame.cpp @@ -2727,7 +2727,7 @@ void CClientGame::AddBuiltInEvents() // Game events m_Events.AddEvent("onClientPreRender", "", NULL, false); - m_Events.AddEvent("onClientEntitiesProcessed", "", NULL, false); + m_Events.AddEvent("onClientPostUpdate", "", NULL, false); m_Events.AddEvent("onClientHUDRender", "", NULL, false); m_Events.AddEvent("onClientRender", "", NULL, false); m_Events.AddEvent("onClientMinimize", "", NULL, false); @@ -3875,8 +3875,14 @@ void CClientGame::PostWorldProcessHandler() void CClientGame::PostWorldProcessEntitiesAfterPreRenderHandler() { CLuaArguments Arguments; - m_pRootEntity->CallEvent("onClientEntitiesProcessed", Arguments, false); + if (m_pRootEntity->CallEvent("onClientPedsProcessed", Arguments, false)) + { + throw std::runtime_error("'onClientPedsProcessed' is no longer supported, renamed to 'onClientPostUpdate'"); + return; + } + + m_pRootEntity->CallEvent("onClientPostUpdate", Arguments, false); g_pClientGame->GetModelRenderer()->Update(); } From efa866a8562285e60d848f9c160c0ddfebb3c70d Mon Sep 17 00:00:00 2001 From: lynconsix Date: Wed, 8 Jan 2025 14:51:06 -0200 Subject: [PATCH 3/3] Fix --- Client/mods/deathmatch/logic/CClientGame.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Client/mods/deathmatch/logic/CClientGame.cpp b/Client/mods/deathmatch/logic/CClientGame.cpp index bd15b3aabd..f5f00c672a 100644 --- a/Client/mods/deathmatch/logic/CClientGame.cpp +++ b/Client/mods/deathmatch/logic/CClientGame.cpp @@ -3878,7 +3878,7 @@ void CClientGame::PostWorldProcessEntitiesAfterPreRenderHandler() if (m_pRootEntity->CallEvent("onClientPedsProcessed", Arguments, false)) { - throw std::runtime_error("'onClientPedsProcessed' is no longer supported, renamed to 'onClientPostUpdate'"); + CStaticFunctionDefinitions::AddEventHandler("onClientPedsProcessed", "onClientPostUpdate", "The 'onClientPedsProcessed' event is deprecated and has been renamed to 'onClientPostUpdate'."); return; }