From f316efdd49a272c4edd73f95287181d84cfebc10 Mon Sep 17 00:00:00 2001 From: TFP-dev <72511827+TFP-dev@users.noreply.github.com> Date: Thu, 20 Oct 2022 16:35:41 +0200 Subject: [PATCH 1/3] Add engineReinitMarkers() --- Client/game_sa/C3DMarkersSA.cpp | 12 ++++++++++++ Client/game_sa/C3DMarkersSA.h | 1 + Client/mods/deathmatch/logic/CClientGame.cpp | 7 +++++++ Client/mods/deathmatch/logic/CClientGame.h | 1 + .../mods/deathmatch/logic/luadefs/CLuaEngineDefs.cpp | 7 +++++++ .../mods/deathmatch/logic/luadefs/CLuaEngineDefs.h | 1 + Client/sdk/game/C3DMarkers.h | 1 + 7 files changed, 30 insertions(+) diff --git a/Client/game_sa/C3DMarkersSA.cpp b/Client/game_sa/C3DMarkersSA.cpp index 92dfc6494d0..2da43e913bf 100644 --- a/Client/game_sa/C3DMarkersSA.cpp +++ b/Client/game_sa/C3DMarkersSA.cpp @@ -122,3 +122,15 @@ C3DMarker* C3DMarkersSA::FindMarker(DWORD Identifier) } return NULL; } + +void C3DMarkersSA::ReinitMarkers() +{ + typedef int(__cdecl * Function_ShutdownMarkers)(); + Function_ShutdownMarkers shutdownMarkers = (Function_ShutdownMarkers)(0x722710); + + typedef int(__cdecl * Function_InitMarkers)(); + Function_InitMarkers initMarkers = (Function_InitMarkers)(0x724E40); + + shutdownMarkers(); + initMarkers(); +} diff --git a/Client/game_sa/C3DMarkersSA.h b/Client/game_sa/C3DMarkersSA.h index 24a15b5641c..27a15c8ed85 100644 --- a/Client/game_sa/C3DMarkersSA.h +++ b/Client/game_sa/C3DMarkersSA.h @@ -43,4 +43,5 @@ class C3DMarkersSA : public C3DMarkers C3DMarker* CreateMarker(DWORD Identifier, e3DMarkerType dwType, CVector* vecPosition, FLOAT fSize, FLOAT fPulseFraction, BYTE r, BYTE g, BYTE b, BYTE a); C3DMarker* FindFreeMarker(); C3DMarker* FindMarker(DWORD Identifier); + void ReinitMarkers(); }; diff --git a/Client/mods/deathmatch/logic/CClientGame.cpp b/Client/mods/deathmatch/logic/CClientGame.cpp index 1e5a6e9fb37..0728af90d1f 100644 --- a/Client/mods/deathmatch/logic/CClientGame.cpp +++ b/Client/mods/deathmatch/logic/CClientGame.cpp @@ -5414,6 +5414,8 @@ void CClientGame::ResetMapInfo() pPlayerInfo->SetCamDrunkLevel(static_cast(0)); RestreamWorld(); + + ReinitMarkers(); } void CClientGame::SendPedWastedPacket(CClientPed* Ped, ElementID damagerID, unsigned char ucWeapon, unsigned char ucBodyPiece, AssocGroupId animGroup, @@ -6551,6 +6553,11 @@ void CClientGame::RestreamWorld() g_pGame->GetStreaming()->ReinitStreaming(); } +void CClientGame::ReinitMarkers() +{ + g_pGame->Get3DMarkers()->ReinitMarkers(); +} + void CClientGame::OnWindowFocusChange(bool state) { if (state == m_bFocused) diff --git a/Client/mods/deathmatch/logic/CClientGame.h b/Client/mods/deathmatch/logic/CClientGame.h index ef2468303d1..4071ccc7f22 100644 --- a/Client/mods/deathmatch/logic/CClientGame.h +++ b/Client/mods/deathmatch/logic/CClientGame.h @@ -440,6 +440,7 @@ class CClientGame bool TriggerBrowserRequestResultEvent(const std::unordered_set& newPages); void RestreamModel(unsigned short usModel); void RestreamWorld(); + void ReinitMarkers(); void OnWindowFocusChange(bool state); diff --git a/Client/mods/deathmatch/logic/luadefs/CLuaEngineDefs.cpp b/Client/mods/deathmatch/logic/luadefs/CLuaEngineDefs.cpp index 12f38327388..f98c710c6e5 100644 --- a/Client/mods/deathmatch/logic/luadefs/CLuaEngineDefs.cpp +++ b/Client/mods/deathmatch/logic/luadefs/CLuaEngineDefs.cpp @@ -63,6 +63,7 @@ void CLuaEngineDefs::LoadFunctions() {"engineRestreamWorld", ArgumentParser}, {"engineStreamingFreeUpMemory", ArgumentParser}, {"engineStreamingGetUsedMemory", ArgumentParser}, + {"engineReinitMarkers", ArgumentParser}, // CLuaCFunctions::AddFunction ( "engineReplaceMatchingAtomics", EngineReplaceMatchingAtomics ); // CLuaCFunctions::AddFunction ( "engineReplaceWheelAtomics", EngineReplaceWheelAtomics ); @@ -2058,3 +2059,9 @@ bool CLuaEngineDefs::EngineRestreamWorld(lua_State* const luaVM) g_pClientGame->RestreamWorld(); return true; } + +bool CLuaEngineDefs::EngineReinitMarkers(lua_State* const luaVM) +{ + g_pClientGame->ReinitMarkers(); + return true; +} diff --git a/Client/mods/deathmatch/logic/luadefs/CLuaEngineDefs.h b/Client/mods/deathmatch/logic/luadefs/CLuaEngineDefs.h index a0d83b10496..20fd03341d8 100644 --- a/Client/mods/deathmatch/logic/luadefs/CLuaEngineDefs.h +++ b/Client/mods/deathmatch/logic/luadefs/CLuaEngineDefs.h @@ -61,6 +61,7 @@ class CLuaEngineDefs : public CLuaDefs static bool EngineRestreamWorld(lua_State* const luaVM); static bool EngineSetModelVisibleTime(std::string strModelId, char cHourOn, char cHourOff); static std::variant> EngineGetModelVisibleTime(std::string strModelId); + static bool EngineReinitMarkers(lua_State* const luaVM); private: static void AddEngineColClass(lua_State* luaVM); diff --git a/Client/sdk/game/C3DMarkers.h b/Client/sdk/game/C3DMarkers.h index 48075380183..965678383eb 100644 --- a/Client/sdk/game/C3DMarkers.h +++ b/Client/sdk/game/C3DMarkers.h @@ -20,4 +20,5 @@ class C3DMarkers virtual C3DMarker* CreateMarker(DWORD Identifier, e3DMarkerType dwType, CVector* vecPosition, FLOAT fSize, FLOAT fPulseFraction, BYTE r, BYTE g, BYTE b, BYTE a) = 0; virtual C3DMarker* FindFreeMarker() = 0; + virtual void ReinitMarkers() = 0; }; From b27103187b850b9c3cdb3110c537d2542641adec Mon Sep 17 00:00:00 2001 From: TFP-dev <72511827+TFP-dev@users.noreply.github.com> Date: Mon, 24 Oct 2022 15:40:14 +0200 Subject: [PATCH 2/3] Use "using" insted of "typedef" in C3DMarkersSA::ReinitMarkers() --- Client/game_sa/C3DMarkersSA.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Client/game_sa/C3DMarkersSA.cpp b/Client/game_sa/C3DMarkersSA.cpp index 2da43e913bf..a7bccaa505b 100644 --- a/Client/game_sa/C3DMarkersSA.cpp +++ b/Client/game_sa/C3DMarkersSA.cpp @@ -125,11 +125,11 @@ C3DMarker* C3DMarkersSA::FindMarker(DWORD Identifier) void C3DMarkersSA::ReinitMarkers() { - typedef int(__cdecl * Function_ShutdownMarkers)(); - Function_ShutdownMarkers shutdownMarkers = (Function_ShutdownMarkers)(0x722710); + using Function_ShutdownMarkers = void(__cdecl *)(); + auto shutdownMarkers = reinterpret_cast(0x722710); - typedef int(__cdecl * Function_InitMarkers)(); - Function_InitMarkers initMarkers = (Function_InitMarkers)(0x724E40); + using Function_InitMarkers = void(__cdecl*)(); + auto initMarkers = reinterpret_cast(0x724E40); shutdownMarkers(); initMarkers(); From be7f16568f0f87c0c1c12cc88b56a1905797a8cc Mon Sep 17 00:00:00 2001 From: TFP-dev <72511827+TFP-dev@users.noreply.github.com> Date: Mon, 24 Oct 2022 17:05:07 +0200 Subject: [PATCH 3/3] Update "CLuaEngineDefs::EngineReinitMarkers" --- Client/mods/deathmatch/logic/luadefs/CLuaEngineDefs.cpp | 3 +-- Client/mods/deathmatch/logic/luadefs/CLuaEngineDefs.h | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/Client/mods/deathmatch/logic/luadefs/CLuaEngineDefs.cpp b/Client/mods/deathmatch/logic/luadefs/CLuaEngineDefs.cpp index f98c710c6e5..f9c47c4dc44 100644 --- a/Client/mods/deathmatch/logic/luadefs/CLuaEngineDefs.cpp +++ b/Client/mods/deathmatch/logic/luadefs/CLuaEngineDefs.cpp @@ -2060,8 +2060,7 @@ bool CLuaEngineDefs::EngineRestreamWorld(lua_State* const luaVM) return true; } -bool CLuaEngineDefs::EngineReinitMarkers(lua_State* const luaVM) +void CLuaEngineDefs::EngineReinitMarkers() { g_pClientGame->ReinitMarkers(); - return true; } diff --git a/Client/mods/deathmatch/logic/luadefs/CLuaEngineDefs.h b/Client/mods/deathmatch/logic/luadefs/CLuaEngineDefs.h index 20fd03341d8..cdc8ae028e8 100644 --- a/Client/mods/deathmatch/logic/luadefs/CLuaEngineDefs.h +++ b/Client/mods/deathmatch/logic/luadefs/CLuaEngineDefs.h @@ -61,7 +61,7 @@ class CLuaEngineDefs : public CLuaDefs static bool EngineRestreamWorld(lua_State* const luaVM); static bool EngineSetModelVisibleTime(std::string strModelId, char cHourOn, char cHourOff); static std::variant> EngineGetModelVisibleTime(std::string strModelId); - static bool EngineReinitMarkers(lua_State* const luaVM); + static void EngineReinitMarkers(); private: static void AddEngineColClass(lua_State* luaVM);