Browse Source

Merge branch 'original'

pull/2/head
mittorn 7 years ago
parent
commit
926b909f3d
  1. 1
      common/const.h
  2. 78
      engine/client/cl_game.c
  3. 23
      engine/client/cl_main.c
  4. 3
      engine/client/gl_rmain.c
  5. 9
      engine/client/vid_common.c
  6. 6
      engine/common/cfgscript.c
  7. 1
      engine/common/common.h
  8. 5
      engine/common/con_utils.c
  9. 28
      engine/common/cvar.c
  10. 3
      engine/common/host.c
  11. 8
      engine/common/mod_bmodel.c
  12. 43
      engine/server/sv_client.c
  13. 29
      engine/server/sv_cmds.c

1
common/const.h

@ -733,6 +733,7 @@ typedef unsigned char byte; @@ -733,6 +733,7 @@ typedef unsigned char byte;
typedef unsigned short word;
#include "xash3d_types.h"
#define Q_isspace( ch ) (ch < 32 || ch > 255)
typedef struct
{

78
engine/client/cl_game.c

@ -3065,6 +3065,83 @@ char *pfnParseFile( char *data, char *token ) @@ -3065,6 +3065,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
@ -3777,7 +3854,6 @@ float Voice_GetControlFloat( VoiceTweakControl iControl ) @@ -3777,7 +3854,6 @@ float Voice_GetControlFloat( VoiceTweakControl iControl )
{
return 1.0f;
}
static void GAME_EXPORT VGui_ViewportPaintBackground( int extents[4] )
{
// stub

23
engine/client/cl_main.c

@ -27,6 +27,7 @@ GNU General Public License for more details. @@ -27,6 +27,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" );
@ -196,7 +197,7 @@ int CL_GetFragmentSize( void *unused ) @@ -196,7 +197,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 );
}
/*
@ -1059,11 +1060,12 @@ void CL_CheckForResend( void ) @@ -1059,11 +1060,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;
@ -1073,7 +1075,7 @@ void CL_CheckForResend( void ) @@ -1073,7 +1075,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 );
@ -1152,12 +1154,16 @@ void CL_Connect_f( void ) @@ -1152,12 +1154,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
@ -1765,8 +1771,9 @@ void CL_ConnectionlessPacket( netadr_t from, sizebuf_t *msg ) @@ -1765,8 +1771,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;
}
@ -1796,8 +1803,9 @@ void CL_ConnectionlessPacket( netadr_t from, sizebuf_t *msg ) @@ -1796,8 +1803,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;
}
@ -2567,6 +2575,7 @@ void CL_InitLocal( void ) @@ -2567,6 +2575,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" );

3
engine/client/gl_rmain.c

@ -1084,6 +1084,9 @@ void R_RenderFrame( const ref_viewpass_t *rvp ) @@ -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 )
{

9
engine/client/vid_common.c

@ -469,6 +469,12 @@ void GL_InitCommands( void ) @@ -469,6 +469,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();
@ -589,9 +595,6 @@ qboolean R_Init( void ) @@ -589,9 +595,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();

6
engine/common/cfgscript.c

@ -231,8 +231,6 @@ int CSCR_WriteGameCVars( file_t *cfg, const char *scriptfilename ) @@ -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 ) @@ -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++;
}

1
engine/common/common.h

@ -470,6 +470,7 @@ typedef struct host_parm_s @@ -470,6 +470,7 @@ typedef struct host_parm_s
float force_draw_version_time;
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

5
engine/common/con_utils.c

@ -879,8 +879,9 @@ with the archive flag set to true. @@ -879,8 +879,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 )

28
engine/common/cvar.c

@ -694,6 +694,13 @@ qboolean Cvar_Command( void ) @@ -694,6 +694,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;
@ -769,24 +776,6 @@ void Cvar_Toggle_f( void ) @@ -769,24 +776,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 <variable> <value>\n" );
return;
}
Cvar_Set( Cmd_Argv( 1 ), Cmd_Argv( 2 ));
}
/*
============
Cvar_SetGL_f
@ -895,8 +884,7 @@ void Cvar_Init( void ) @@ -895,8 +884,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" );

3
engine/common/host.c

@ -933,7 +933,6 @@ int EXPORT Host_Main( int argc, char **argv, const char *progname, int bChangeGa @@ -933,7 +933,6 @@ int EXPORT Host_Main( int argc, char **argv, const char *progname, int bChangeGa
}
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
@ -973,7 +972,7 @@ void EXPORT Host_Shutdown( void ) @@ -973,7 +972,7 @@ void EXPORT Host_Shutdown( void )
Host_WriteConfig();
#endif
SV_Shutdown( "" );
SV_Shutdown( "Server shutdown\n" );
CL_Shutdown();
Mod_Shutdown();

8
engine/common/mod_bmodel.c

@ -1352,6 +1352,7 @@ for embedded submodels @@ -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 ) @@ -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 ) @@ -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 )
{

43
engine/server/sv_client.c

@ -1164,7 +1164,7 @@ a deathmatch. @@ -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 ) @@ -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 ) @@ -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 ) @@ -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[] = @@ -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 },

29
engine/server/sv_cmds.c

@ -468,30 +468,6 @@ void SV_Kick_f( void ) @@ -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 ) @@ -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 @@ -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" );

Loading…
Cancel
Save