From db92c918b2739376da8b494dc92492655cd1072f Mon Sep 17 00:00:00 2001 From: mittorn Date: Fri, 20 Apr 2018 08:41:02 +0000 Subject: [PATCH] Apply Apr19 update --- common/const.h | 2 + engine/cdll_int.h | 33 ++++++++++ engine/client/cl_game.c | 121 +++++++++++++++++++++++++++++++++++++ engine/client/cl_main.c | 23 ++++--- engine/client/gl_rmain.c | 3 + engine/client/gl_vidnt.c | 12 ++-- engine/common/cfgscript.c | 6 +- engine/common/common.h | 1 + engine/common/con_utils.c | 5 +- engine/common/cvar.c | 28 +++------ engine/common/host.c | 3 +- engine/common/mod_bmodel.c | 8 ++- engine/server/sv_client.c | 43 +++++++++++-- engine/server/sv_cmds.c | 29 --------- 14 files changed, 240 insertions(+), 77 deletions(-) diff --git a/common/const.h b/common/const.h index 8e81df25..a33be36f 100644 --- a/common/const.h +++ b/common/const.h @@ -732,6 +732,8 @@ typedef int string_t; typedef unsigned char byte; typedef unsigned short word; +#define Q_isspace( ch ) (ch < 32 || ch > 255) + #undef true #undef false diff --git a/engine/cdll_int.h b/engine/cdll_int.h index 6b70f717..6de8c2cb 100644 --- a/engine/cdll_int.h +++ b/engine/cdll_int.h @@ -248,6 +248,39 @@ typedef struct cl_enginefuncs_s void (*pfnGetMousePos)( struct tagPOINT *ppt ); void (*pfnSetMousePos)( int x, int y ); void (*pfnSetMouseEnable)( qboolean fEnable ); + void (*pfnUnused1)( void ); + void (*pfnUnused2)( void ); + void (*pfnUnused3)( void ); + void (*pfnUnused4)( void ); + float (*pfnGetClientOldTime)( void ); + float (*pfnGetGravity)( void ); + struct model_s*(*pfnGetModelByIndex)( int index ); + void (*pfnUnused5)( void ); + void (*pfnUnused6)( void ); + void (*pfnUnused7)( void ); + void (*pfnUnused8)( void ); + void (*pfnUnused9)( void ); + void (*pfnUnused10)( void ); + void (*pfnUnused11)( void ); + void (*pfnUnused12)( void ); + const char*(*LocalPlayerInfo_ValueForKey)( const char* key ); + void (*pfnUnused13)( void ); + void (*pfnUnused14)( void ); + void (*pfnUnused15)( void ); + void (*pfnUnused16)( void ); + void (*Cvar_Set)( char *name, char *value ); + void (*pfnUnused17)( void ); + void (*pfnUnused18)( void ); + void (*pfnUnused19)( void ); + double (*pfnSys_FloatTime)( void ); + void (*pfnUnused20)( void ); + void (*pfnUnused21)( void ); + void (*pfnUnused22)( void ); + void (*pfnUnused23)( void ); + void (*pfnFillRGBABlend)( int x, int y, int width, int height, int r, int g, int b, int a ); + int (*pfnGetAppID)( void ); + void (*pfnUnused24)( void ); + void (*pfnUnused25)( void ); } cl_enginefunc_t; #define CLDLL_INTERFACE_VERSION 7 diff --git a/engine/client/cl_game.c b/engine/client/cl_game.c index b95871eb..441c51c2 100644 --- a/engine/client/cl_game.c +++ b/engine/client/cl_game.c @@ -2780,6 +2780,83 @@ char *pfnParseFile( char *data, char *token ) return out; } +/* +============= +pfnGetServerTime + +============= +*/ +float pfnGetClientOldTime( void ) +{ + return cl.oldtime; +} + +/* +============= +pfnGetGravity + +============= +*/ +float pfnGetGravity( void ) +{ + return clgame.movevars.gravity; +} + +/* +============= +LocalPlayerInfo_ValueForKey + +============= +*/ +const char *LocalPlayerInfo_ValueForKey( const char* key ) +{ + return Info_ValueForKey( cls.userinfo, key ); +} + +/* +============= +CL_FillRGBABlend + +============= +*/ +void CL_FillRGBABlend( int x, int y, int w, int h, int r, int g, int b, int a ) +{ + r = bound( 0, r, 255 ); + g = bound( 0, g, 255 ); + b = bound( 0, b, 255 ); + a = bound( 0, a, 255 ); + + SPR_AdjustSize( (float *)&x, (float *)&y, (float *)&w, (float *)&h ); + + pglDisable( GL_TEXTURE_2D ); + pglEnable( GL_BLEND ); + pglTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE ); + pglBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA ); + pglColor4f( r / 255.0f, g / 255.0f, b / 255.0f, a / 255.0f ); + + pglBegin( GL_QUADS ); + pglVertex2f( x, y ); + pglVertex2f( x + w, y ); + pglVertex2f( x + w, y + h ); + pglVertex2f( x, y + h ); + pglEnd (); + + pglColor3f( 1.0f, 1.0f, 1.0f ); + pglEnable( GL_TEXTURE_2D ); + pglDisable( GL_BLEND ); +} + +/* +============= +pfnGetAppID + +============= +*/ +int pfnGetAppID( void ) +{ + return 70; +} + /* ================= TriApi implementation @@ -3493,6 +3570,17 @@ float Voice_GetControlFloat( VoiceTweakControl iControl ) return 1.0f; } +/* +============= +pfnEngineStub + +extended iface stubs +============= +*/ +static void pfnEngineStub( void ) +{ +} + // shared between client and server triangleapi_t gTriApi = { @@ -3764,6 +3852,39 @@ static cl_enginefunc_t gEngfuncs = pfnGetMousePos, pfnSetMousePos, pfnSetMouseEnable, + pfnEngineStub, + pfnEngineStub, + pfnEngineStub, + pfnEngineStub, + pfnGetClientOldTime, + pfnGetGravity, + CL_ModelHandle, + pfnEngineStub, + pfnEngineStub, + pfnEngineStub, + pfnEngineStub, + pfnEngineStub, + pfnEngineStub, + pfnEngineStub, + pfnEngineStub, + LocalPlayerInfo_ValueForKey, + pfnEngineStub, + pfnEngineStub, + pfnEngineStub, + pfnEngineStub, + Cvar_Set, + pfnEngineStub, + pfnEngineStub, + pfnEngineStub, + Sys_DoubleTime, + pfnEngineStub, + pfnEngineStub, + pfnEngineStub, + pfnEngineStub, + CL_FillRGBABlend, + pfnGetAppID, + pfnEngineStub, + pfnEngineStub, }; void CL_UnloadProgs( void ) diff --git a/engine/client/cl_main.c b/engine/client/cl_main.c index 0bb84307..094f47c2 100644 --- a/engine/client/cl_main.c +++ b/engine/client/cl_main.c @@ -26,6 +26,7 @@ GNU General Public License for more details. #define MAX_CMD_BUFFER 8000 #define CONNECTION_PROBLEM_TIME 15.0 // 15 seconds #define CL_CONNECTION_RETRIES 10 +#define CL_TEST_RETRIES_NORESPONCE 2 #define CL_TEST_RETRIES 5 CVAR_DEFINE_AUTO( mp_decals, "300", FCVAR_ARCHIVE, "decals limit in multiplayer" ); @@ -194,7 +195,7 @@ int CL_GetFragmentSize( void *unused ) if( Netchan_IsLocal( &cls.netchan )) return FRAGMENT_LOCAL_SIZE; - return FRAGMENT_MAX_SIZE; + return bound( FRAGMENT_MIN_SIZE, cl_dlmax->value, FRAGMENT_MAX_SIZE ); } /* @@ -1089,11 +1090,12 @@ void CL_CheckForResend( void ) if( adr.port == 0 ) adr.port = MSG_BigShort( PORT_SERVER ); - if( cls.connect_retry == CL_TEST_RETRIES ) + if( cls.connect_retry == CL_TEST_RETRIES_NORESPONCE ) { // too many fails use default connection method + Msg( "hi-speed coonection is failed, use default method\n" ); Netchan_OutOfBandPrint( NS_CLIENT, adr, "getchallenge\n" ); - Cvar_SetValue( "cl_dlmax", FRAGMENT_MAX_SIZE ); + Cvar_SetValue( "cl_dlmax", FRAGMENT_MIN_SIZE ); cls.connect_time = host.realtime; cls.connect_retry++; return; @@ -1103,7 +1105,7 @@ void CL_CheckForResend( void ) cls.connect_time = host.realtime; // for retransmit requests cls.connect_retry++; - Con_Printf( "Connecting to %s...\n", cls.servername ); + Con_Printf( "Connecting to %s... [retry #%i]\n", cls.servername, cls.connect_retry ); if( cl_test_bandwidth.value ) Netchan_OutOfBandPrint( NS_CLIENT, adr, "bandwidth %i %i\n", PROTOCOL_VERSION, cls.max_fragment_size ); @@ -1182,12 +1184,16 @@ void CL_Connect_f( void ) Q_strncpy( server, Cmd_Argv( 1 ), sizeof( server )); // if running a local server, kill it and reissue -// if( SV_Active( )) Host_ShutdownServer(); + if( SV_Active( )) Host_ShutdownServer(); NET_Config( true ); // allow remote Con_Printf( "server %s\n", server ); CL_Disconnect(); + // TESTTEST: a see console during connection + UI_SetActiveMenu( false ); + Key_SetKeyDest( key_console ); + cls.state = ca_connecting; Q_strncpy( cls.servername, server, sizeof( cls.servername )); cls.connect_time = MAX_HEARTBEAT; // CL_CheckForResend() will fire immediately @@ -1794,8 +1800,9 @@ void CL_ConnectionlessPacket( netadr_t from, sizebuf_t *msg ) if( cls.connect_retry >= CL_TEST_RETRIES ) { // too many fails use default connection method + Msg( "hi-speed coonection is failed, use default method\n" ); Netchan_OutOfBandPrint( NS_CLIENT, from, "getchallenge\n" ); - Cvar_SetValue( "cl_dlmax", FRAGMENT_MAX_SIZE ); + Cvar_SetValue( "cl_dlmax", FRAGMENT_MIN_SIZE ); cls.connect_time = host.realtime; return; } @@ -1825,8 +1832,9 @@ void CL_ConnectionlessPacket( netadr_t from, sizebuf_t *msg ) if( cls.connect_retry >= CL_TEST_RETRIES ) { // too many fails use default connection method + Msg( "hi-speed coonection is failed, use default method\n" ); Netchan_OutOfBandPrint( NS_CLIENT, from, "getchallenge\n" ); - Cvar_SetValue( "cl_dlmax", FRAGMENT_MAX_SIZE ); + Cvar_SetValue( "cl_dlmax", FRAGMENT_MIN_SIZE ); cls.connect_time = host.realtime; return; } @@ -2595,6 +2603,7 @@ void CL_InitLocal( void ) Cmd_AddCommand ("give", NULL, "give specified item or weapon" ); Cmd_AddCommand ("drop", NULL, "drop current/specified item or weapon" ); Cmd_AddCommand ("gametitle", NULL, "show game logo" ); + Cmd_AddCommand( "kill", NULL, "die instantly" ); Cmd_AddCommand ("god", NULL, "enable godmode" ); Cmd_AddCommand ("fov", NULL, "set client field of view" ); Cmd_AddCommand ("log", NULL, "logging server events" ); diff --git a/engine/client/gl_rmain.c b/engine/client/gl_rmain.c index 6798128a..ab2de56f 100644 --- a/engine/client/gl_rmain.c +++ b/engine/client/gl_rmain.c @@ -1084,6 +1084,9 @@ void R_RenderFrame( const ref_viewpass_t *rvp ) if( gl_finish->value && RI.drawWorld ) pglFinish(); + if( glConfig.max_multisamples > 1 ) + pglEnable( GL_MULTISAMPLE_ARB ); + // completely override rendering if( clgame.drawFuncs.GL_RenderFrame != NULL ) { diff --git a/engine/client/gl_vidnt.c b/engine/client/gl_vidnt.c index 30cfbe6b..c1a7e6e4 100644 --- a/engine/client/gl_vidnt.c +++ b/engine/client/gl_vidnt.c @@ -1480,9 +1480,6 @@ static void GL_SetDefaults( void ) pglDepthFunc( GL_LEQUAL ); pglColor4f( 1.0f, 1.0f, 1.0f, 1.0f ); - if( glConfig.max_multisamples > 1 ) - pglEnable( GL_MULTISAMPLE_ARB ); - if( glState.stencilEnabled ) { pglDisable( GL_STENCIL_TEST ); @@ -1621,6 +1618,12 @@ void GL_InitCommands( void ) Cmd_AddCommand( "r_info", R_RenderInfo_f, "display renderer info" ); + // give initial OpenGL configuration + host.apply_opengl_config = true; + Cbuf_AddText( "exec opengl.cfg\n" ); + Cbuf_Execute(); + host.apply_opengl_config = false; + // apply actual video mode to window Cbuf_AddText( "exec video.cfg\n" ); Cbuf_Execute(); @@ -1826,9 +1829,6 @@ qboolean R_Init( void ) if( glw_state.initialized ) return true; - // give initial OpenGL configuration - Cbuf_AddText( "exec opengl.cfg\n" ); - GL_InitCommands(); GL_InitRandomTable(); GL_SetDefaultState(); diff --git a/engine/common/cfgscript.c b/engine/common/cfgscript.c index 92aee5a5..f61e5041 100644 --- a/engine/common/cfgscript.c +++ b/engine/common/cfgscript.c @@ -231,8 +231,6 @@ int CSCR_WriteGameCVars( file_t *cfg, const char *scriptfilename ) goto finish; } - FS_Printf( cfg, "// declared in %s:\n", scriptfilename ); - while( !CSCR_ExpectString( &state, "}", false, false )) { scrvardef_t var = { 0 }; @@ -245,8 +243,8 @@ int CSCR_WriteGameCVars( file_t *cfg, const char *scriptfilename ) { // cvars will be placed in game.cfg and restored on map start if( var.flags & FCVAR_USERINFO ) - FS_Printf( cfg, "// %s ( %s )\nsetu %s \"%s\"\n", var.desc, var.value, var.name, cvar->string ); - else FS_Printf( cfg, "// %s ( %s )\nset %s \"%s\"\n", var.desc, var.value, var.name, cvar->string ); + FS_Printf( cfg, "%s \"%s\"\n", var.name, cvar->string ); + else FS_Printf( cfg, "%s \"%s\"\n", var.name, cvar->string ); } count++; } diff --git a/engine/common/common.h b/engine/common/common.h index 71f2120c..fc64dd22 100644 --- a/engine/common/common.h +++ b/engine/common/common.h @@ -412,6 +412,7 @@ typedef struct host_parm_s qboolean force_draw_version; // used when fraps is loaded qboolean write_to_clipboard; // put image to clipboard instead of disk qboolean apply_game_config; // when true apply only to game cvars and ignore all other commands + qboolean apply_opengl_config;// when true apply only to opengl cvars and ignore all other commands qboolean config_executed; // a bit who indicated was config.cfg already executed e.g. from valve.rc int sv_cvars_restored; // count of restored server cvars qboolean crashed; // set to true if crashed diff --git a/engine/common/con_utils.c b/engine/common/con_utils.c index 61d5dd5f..624f22c1 100644 --- a/engine/common/con_utils.c +++ b/engine/common/con_utils.c @@ -875,8 +875,9 @@ with the archive flag set to true. */ static void Cmd_WriteOpenGLCvar( const char *name, const char *string, const char *desc, void *f ) { - if( !desc || !*desc ) return; // ignore cvars without description (fantom variables) - FS_Printf( f, "setgl %s \"%s\"\n", name, string ); + if( !COM_CheckString( desc )) + return; // ignore cvars without description (fantom variables) + FS_Printf( f, "%s \"%s\"\n", name, string ); } static void Cmd_WriteHelp(const char *name, const char *unused, const char *desc, void *f ) diff --git a/engine/common/cvar.c b/engine/common/cvar.c index 23a1010d..6aabfec8 100644 --- a/engine/common/cvar.c +++ b/engine/common/cvar.c @@ -681,6 +681,13 @@ qboolean Cvar_Command( void ) { convar_t *v; + // special case for setup opengl configuration + if( host.apply_opengl_config ) + { + Cvar_FullSet( Cmd_Argv( 0 ), Cmd_Argv( 1 ), FCVAR_GLCONFIG ); + return true; + } + // check variables v = Cvar_FindVar( Cmd_Argv( 0 )); if( !v ) return false; @@ -756,24 +763,6 @@ void Cvar_Toggle_f( void ) Cvar_Set( Cmd_Argv( 1 ), va( "%i", v )); } -/* -============ -Cvar_SetR_f - -keep for legacy configs -============ -*/ -void Cvar_SetR_f( void ) -{ - if( Cmd_Argc() != 3 ) - { - Con_Printf( S_USAGE "setr \n" ); - return; - } - - Cvar_Set( Cmd_Argv( 1 ), Cmd_Argv( 2 )); -} - /* ============ Cvar_SetGL_f @@ -882,8 +871,7 @@ void Cvar_Init( void ) cmd_scripting = Cvar_Get( "cmd_scripting", "0", FCVAR_ARCHIVE, "enable simple condition checking and variable operations" ); Cvar_RegisterVariable (&host_developer); // early registering for dev - Cmd_AddCommand( "setr", Cvar_SetR_f, "create or change the value of a renderinfo variable" ); - Cmd_AddCommand( "setgl", Cvar_SetGL_f, "create or change the value of a opengl variable" ); + Cmd_AddCommand( "setgl", Cvar_SetGL_f, "create or change the value of a opengl variable" ); // OBSOLETE Cmd_AddCommand( "toggle", Cvar_Toggle_f, "toggles a console variable's values (use for more info)" ); Cmd_AddCommand( "reset", Cvar_Reset_f, "reset any type variable to initial value" ); Cmd_AddCommand( "cvarlist", Cvar_List_f, "display all console variables beginning with the specified prefix" ); diff --git a/engine/common/host.c b/engine/common/host.c index eeed4be4..09bb626e 100644 --- a/engine/common/host.c +++ b/engine/common/host.c @@ -848,7 +848,6 @@ int EXPORT Host_Main( const char *progname, int bChangeGame, pfnChangeGame func } host.change_game = false; // done - Cmd_RemoveCommand( "setr" ); // remove potentially backdoor for change render settings Cmd_RemoveCommand( "setgl" ); Cbuf_ExecStuffCmds(); // execute stuffcmds (commandline) SCR_CheckStartupVids(); // must be last @@ -886,7 +885,7 @@ void EXPORT Host_Shutdown( void ) if( host.type == HOST_NORMAL ) Host_WriteConfig(); - SV_Shutdown( "" ); + SV_Shutdown( "Server shutdown\n" ); CL_Shutdown(); Mod_Shutdown(); diff --git a/engine/common/mod_bmodel.c b/engine/common/mod_bmodel.c index f7ca6fb6..ed85cc42 100644 --- a/engine/common/mod_bmodel.c +++ b/engine/common/mod_bmodel.c @@ -1352,6 +1352,7 @@ for embedded submodels */ static void Mod_SetupSubmodels( dbspmodel_t *bmod ) { + qboolean colored = false; byte *mempool; char *ents; model_t *mod; @@ -1360,6 +1361,8 @@ static void Mod_SetupSubmodels( dbspmodel_t *bmod ) ents = loadmodel->entities; mempool = loadmodel->mempool; + if( FBitSet( loadmodel->flags, MODEL_COLORED_LIGHTING )) + colored = true; mod = loadmodel; loadmodel->numframes = 2; // regular and alternate animation @@ -1384,7 +1387,10 @@ static void Mod_SetupSubmodels( dbspmodel_t *bmod ) mod->radius = RadiusFromBounds( mod->mins, mod->maxs ); mod->numleafs = bm->visleafs; -// mod->flags = 0; + mod->flags = 0; + + // this bit will be shared between all the submodels include worldmodel + if( colored ) SetBits( mod->flags, MODEL_COLORED_LIGHTING ); if( i != 0 ) { diff --git a/engine/server/sv_client.c b/engine/server/sv_client.c index d8e14ad8..8dbce5b5 100644 --- a/engine/server/sv_client.c +++ b/engine/server/sv_client.c @@ -1164,7 +1164,7 @@ a deathmatch. */ void SV_PutClientInServer( sv_client_t *cl ) { - static byte msg_buf[MAX_INIT_MSG]; + static byte msg_buf[0x20200]; // MAX_INIT_MSG + some space edict_t *ent = cl->edict; sizebuf_t msg; @@ -1215,6 +1215,9 @@ void SV_PutClientInServer( sv_client_t *cl ) if( Q_atoi( Info_ValueForKey( cl->userinfo, "hltv" ))) SetBits( cl->flags, FCL_HLTV_PROXY ); + // need to realloc private data for client + SV_InitEdict( ent ); + if( FBitSet( cl->flags, FCL_HLTV_PROXY )) SetBits( ent->v.flags, FL_PROXY ); else ent->v.flags = 0; @@ -1270,11 +1273,17 @@ void SV_PutClientInServer( sv_client_t *cl ) MSG_WriteByte( &msg, 1 ); if( MSG_CheckOverflow( &msg )) - Host_Error( "overflow\n" ); - - // send initialization data - Netchan_CreateFragments( &cl->netchan, &msg ); - Netchan_FragSend( &cl->netchan ); + { + if( svs.maxclients == 1 ) + Host_Error( "spawn player: overflowed\n" ); + else SV_DropClient( cl, false ); + } + else + { + // send initialization data + Netchan_CreateFragments( &cl->netchan, &msg ); + Netchan_FragSend( &cl->netchan ); + } } } @@ -1751,6 +1760,27 @@ static qboolean SV_Notarget_f( sv_client_t *cl ) return true; } +/* +================== +SV_Kill_f +================== +*/ +static qboolean SV_Kill_f( sv_client_t *cl ) +{ + if( !SV_IsValidEdict( cl->edict )) + return true; + + if( cl->edict->v.health <= 0.0f ) + { + SV_ClientPrintf( cl, "Can't suicide - already dead!\n"); + return true; + } + + svgame.dllFuncs.pfnClientKill( cl->edict ); + + return true; +} + /* ================== SV_SendRes_f @@ -1903,6 +1933,7 @@ ucmd_t ucmds[] = { { "new", SV_New_f }, { "god", SV_Godmode_f }, +{ "kill", SV_Kill_f }, { "begin", SV_Begin_f }, { "spawn", SV_Spawn_f }, { "pause", SV_Pause_f }, diff --git a/engine/server/sv_cmds.c b/engine/server/sv_cmds.c index 134c0be6..8027f58b 100644 --- a/engine/server/sv_cmds.c +++ b/engine/server/sv_cmds.c @@ -468,30 +468,6 @@ void SV_Kick_f( void ) SV_DropClient( cl, false ); } -/* -================== -SV_Kill_f -================== -*/ -void SV_Kill_f( void ) -{ - sv_client_t *cl; - - if(( cl = SV_SetPlayer( )) == NULL ) - return; - - if( !SV_IsValidEdict( cl->edict )) - return; - - if( cl->edict->v.health <= 0.0f ) - { - SV_ClientPrintf( cl, "Can't suicide - already dead!\n"); - return; - } - - svgame.dllFuncs.pfnClientKill( cl->edict ); -} - /* ================== SV_EntPatch_f @@ -833,7 +809,6 @@ void SV_InitOperatorCommands( void ) { Cmd_AddCommand( "heartbeat", SV_Heartbeat_f, "send a heartbeat to the master server" ); Cmd_AddCommand( "kick", SV_Kick_f, "kick a player off the server by number or name" ); - Cmd_AddCommand( "kill", SV_Kill_f, "die instantly" ); Cmd_AddCommand( "status", SV_Status_f, "print server status information" ); Cmd_AddCommand( "localinfo", SV_LocalInfo_f, "examine or change the localinfo string" ); Cmd_AddCommand( "serverinfo", SV_ServerInfo_f, "examine or change the serverinfo string" ); @@ -866,12 +841,8 @@ SV_KillOperatorCommands */ void SV_KillOperatorCommands( void ) { - Cvar_Reset( "public" ); - Cvar_Reset( "sv_lan" ); - Cmd_RemoveCommand( "heartbeat" ); Cmd_RemoveCommand( "kick" ); - Cmd_RemoveCommand( "kill" ); Cmd_RemoveCommand( "status" ); Cmd_RemoveCommand( "localinfo" ); Cmd_RemoveCommand( "serverinfo" );