From 622d472b63a48c35ba7c1d73fcfcff6670cd7008 Mon Sep 17 00:00:00 2001 From: luttje <2738114+luttje@users.noreply.github.com> Date: Sat, 24 Aug 2024 16:43:00 +0200 Subject: [PATCH] Fix DrawOverlay happening outside scene render --- src/game/client/cdll_client_int.cpp | 2 +- src/game/client/viewrender.cpp | 14 +++++--------- src/game/shared/lrender.cpp | 11 ++++------- 3 files changed, 10 insertions(+), 17 deletions(-) diff --git a/src/game/client/cdll_client_int.cpp b/src/game/client/cdll_client_int.cpp index 859046bcd5..edf3546779 100644 --- a/src/game/client/cdll_client_int.cpp +++ b/src/game/client/cdll_client_int.cpp @@ -516,7 +516,7 @@ class CHLVoiceStatusHelper : public IVoiceStatusHelper LUA_CALL_HOOK_BEGIN( "GetPlayerTextColor", "Allows overriding the color of the player's name in the scoreboard." ); CBasePlayer::PushLuaInstanceSafe( L, entity ); // doc: player lua_pushcolor( L, color ); // doc: color (the color of the player's name in the scoreboard) - LUA_CALL_HOOK_END( 1, 1 ); // doc: color (return a replacement color to override the default color) + LUA_CALL_HOOK_END( 2, 1 ); // doc: color (return a replacement color to override the default color) if ( lua_iscolor( L, -1 ) ) { diff --git a/src/game/client/viewrender.cpp b/src/game/client/viewrender.cpp index 4509e6fb90..dd16992909 100644 --- a/src/game/client/viewrender.cpp +++ b/src/game/client/viewrender.cpp @@ -77,10 +77,6 @@ // Projective textures #include "C_Env_Projected_Texture.h" -#ifdef LUA_SDK -#include -#endif - // memdbgon must be the last include file in a .cpp file!!! #include "tier0/memdbgon.h" @@ -2362,6 +2358,11 @@ void CViewRender::RenderView( const CViewSetup &view, int nClearFlags, int whatT Render2DEffectsPostHUD( view ); +#ifdef LUA_SDK + LUA_CALL_HOOK_BEGIN( "DrawOverlay" ); + LUA_CALL_HOOK_END( 0, 0 ); +#endif + g_bRenderingView = false; // We can no longer use the 'current view' stuff set up in ViewDrawScene @@ -2372,11 +2373,6 @@ void CViewRender::RenderView( const CViewSetup &view, int nClearFlags, int whatT CDebugViewRender::GenerateOverdrawForTesting(); } -#ifdef LUA_SDK - LUA_CALL_HOOK_BEGIN( "DrawOverlay" ); - LUA_CALL_HOOK_END( 0, 0 ); -#endif - render->PopView( GetFrustum() ); g_WorldListCache.Flush(); } diff --git a/src/game/shared/lrender.cpp b/src/game/shared/lrender.cpp index 70520c9af0..f2eef127d7 100644 --- a/src/game/shared/lrender.cpp +++ b/src/game/shared/lrender.cpp @@ -27,9 +27,6 @@ LUA_REGISTRATION_INIT( Renders ); #ifdef CLIENT_DLL -// Frustrums for PushView2D and -3D functions -static Frustum renderFrustum3D; -static Frustum renderFrustum2D; // Minifaction and magnification filter stacks static CUtlStack< ShaderAPITextureHandle_t > filterTextureHandlesMinification; @@ -177,7 +174,7 @@ LUA_BINDING_BEGIN( Renders, PushView3D, "library", "Push a 3D view.", "client" ) viewSetup.zNear = zNear; viewSetup.zFar = zFar; - render->Push3DView( viewSetup, 0, NULL, renderFrustum3D ); + render->Push3DView( viewSetup, 0, NULL, view->GetFrustum() ); return 0; } @@ -185,7 +182,7 @@ LUA_BINDING_END() LUA_BINDING_BEGIN( Renders, PopView3D, "library", "Pop a 3D view.", "client" ) { - render->PopView( renderFrustum3D ); + render->PopView( view->GetFrustum() ); return 0; } LUA_BINDING_END() @@ -193,14 +190,14 @@ LUA_BINDING_END() LUA_BINDING_BEGIN( Renders, PushView2D, "library", "Push a 2D view.", "client" ) { CViewSetup viewSetup = *view->GetPlayerViewSetup(); - render->Push2DView( viewSetup, 0, NULL, renderFrustum2D ); + render->Push2DView( viewSetup, 0, NULL, view->GetFrustum() ); return 0; } LUA_BINDING_END() LUA_BINDING_BEGIN( Renders, PopView2D, "library", "Pop a 2D view.", "client" ) { - render->PopView( renderFrustum2D ); + render->PopView( view->GetFrustum() ); return 0; } LUA_BINDING_END()