From cb3b16e2ececbe40000cabe86c9d5320b9c69049 Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Fri, 28 Apr 2023 16:52:22 +0300 Subject: [PATCH] engine: client: implement v_dark in engine, instead of making it ref-specific --- engine/client/cl_parse.c | 39 +++++++++++++++++++++++++++++++++++++++ ref/gl/gl_rmisc.c | 28 ---------------------------- 2 files changed, 39 insertions(+), 28 deletions(-) diff --git a/engine/client/cl_parse.c b/engine/client/cl_parse.c index bc507838..7471d80c 100644 --- a/engine/client/cl_parse.c +++ b/engine/client/cl_parse.c @@ -1543,6 +1543,42 @@ void CL_SendConsistencyInfo( sizebuf_t *msg ) MSG_WriteOneBit( msg, 0 ); } +/* +================== +CL_StartDark +================== +*/ +static void CL_StartDark( void ) +{ + if( Cvar_VariableValue( "v_dark" )) + { + screenfade_t *sf = &clgame.fade; + float fadetime = 5.0f; + client_textmessage_t *title; + + title = CL_TextMessageGet( "GAMETITLE" ); + if( Host_IsQuakeCompatible( )) + fadetime = 1.0f; + + if( title ) + { + // get settings from titles.txt + sf->fadeEnd = title->holdtime + title->fadeout; + sf->fadeReset = title->fadeout; + } + else sf->fadeEnd = sf->fadeReset = fadetime; + + sf->fadeFlags = FFADE_IN; + sf->fader = sf->fadeg = sf->fadeb = 0; + sf->fadealpha = 255; + sf->fadeSpeed = (float)sf->fadealpha / sf->fadeReset; + sf->fadeReset += cl.time; + sf->fadeEnd += sf->fadeReset; + + Cvar_SetValue( "v_dark", 0.0f ); + } +} + /* ================== CL_RegisterResources @@ -1592,6 +1628,9 @@ void CL_RegisterResources( sizebuf_t *msg ) // tell rendering system we have a new set of models. ref.dllFuncs.R_NewMap (); + // check if this map must start from dark screen + CL_StartDark (); + CL_SetupOverviewParams(); // release unused SpriteTextures diff --git a/ref/gl/gl_rmisc.c b/ref/gl/gl_rmisc.c index cc630573..9c5da914 100644 --- a/ref/gl/gl_rmisc.c +++ b/ref/gl/gl_rmisc.c @@ -124,34 +124,6 @@ void R_NewMap( void ) R_ParseDetailTextures( filepath ); } - if( gEngfuncs.pfnGetCvarFloat( "v_dark" )) - { - screenfade_t *sf = gEngfuncs.GetScreenFade(); - float fadetime = 5.0f; - client_textmessage_t *title; - - title = gEngfuncs.pfnTextMessageGet( "GAMETITLE" ); - if( ENGINE_GET_PARM( PARM_QUAKE_COMPATIBLE )) - fadetime = 1.0f; - - if( title ) - { - // get settings from titles.txt - sf->fadeEnd = title->holdtime + title->fadeout; - sf->fadeReset = title->fadeout; - } - else sf->fadeEnd = sf->fadeReset = fadetime; - - sf->fadeFlags = FFADE_IN; - sf->fader = sf->fadeg = sf->fadeb = 0; - sf->fadealpha = 255; - sf->fadeSpeed = (float)sf->fadealpha / sf->fadeReset; - sf->fadeReset += gpGlobals->time; - sf->fadeEnd += sf->fadeReset; - - gEngfuncs.Cvar_SetValue( "v_dark", 0.0f ); - } - // clear out efrags in case the level hasn't been reloaded for( i = 0; i < WORLDMODEL->numleafs; i++ ) WORLDMODEL->leafs[i+1].efrags = NULL;