Browse Source

Merge 4150 update. Fix some mistypings. Rename CL_IsQuakeCompatible to Host_IsQuakeCompatible, as it may be used in whole engine and even in dedicated builds. IN_RecalcCenter was not added, window center positions should be updated by backends.

pull/2/head
Alibek Omarov 7 years ago
parent
commit
2edbcb996d
  1. 2
      common/render_api.h
  2. 2
      contib/a1batross/xash3d.files
  3. 242
      engine/client/cl_debug.c
  4. 263
      engine/client/cl_demo.c
  5. 13
      engine/client/cl_frame.c
  6. 2
      engine/client/cl_game.c
  7. 36
      engine/client/cl_main.c
  8. 272
      engine/client/cl_parse.c
  9. 4
      engine/client/cl_pmove.c
  10. 1007
      engine/client/cl_qparse.c
  11. 1
      engine/client/cl_scrn.c
  12. 4
      engine/client/cl_tent.c
  13. 3
      engine/client/cl_video.c
  14. 33
      engine/client/client.h
  15. 31
      engine/client/gl_backend.c
  16. 2
      engine/client/gl_image.c
  17. 2
      engine/client/gl_local.h
  18. 6
      engine/client/gl_refrag.c
  19. 4
      engine/client/gl_rmain.c
  20. 5
      engine/client/gl_rmisc.c
  21. 25
      engine/client/gl_rsurf.c
  22. 4
      engine/client/gl_studio.c
  23. 20
      engine/client/s_main.c
  24. 3
      engine/client/vid_common.h
  25. 2
      engine/common/build.c
  26. 2
      engine/common/common.h
  27. 13
      engine/common/filesystem.c
  28. 23
      engine/common/host.c
  29. 8
      engine/common/mod_bmodel.c
  30. 4
      engine/common/net_buffer.c
  31. 30
      engine/common/net_encode.c
  32. 16
      engine/common/net_encode.h
  33. 61
      engine/common/protocol.h
  34. 8
      engine/common/soundlib/snd_mp3.c
  35. 16
      engine/platform/sdl/vid_sdl.c
  36. 25
      engine/server/server.h
  37. 5
      engine/server/sv_cmds.c
  38. 44
      engine/server/sv_frame.c
  39. 112
      engine/server/sv_game.c
  40. 17
      engine/server/sv_init.c
  41. 4
      engine/server/sv_main.c
  42. 67
      engine/server/sv_save.c

2
common/render_api.h

@ -40,7 +40,7 @@ GNU General Public License for more details. @@ -40,7 +40,7 @@ GNU General Public License for more details.
#define PARM_TEX_MIPCOUNT 15 // count of mipmaps (0 - autogenerated, 1 - disabled of mipmapping)
#define PARM_BSP2_SUPPORTED 16 // tell custom renderer what engine is support BSP2 in this build
#define PARM_SKY_SPHERE 17 // sky is quake sphere ?
//reserved
#define PARAM_GAMEPAUSED 18 // game is paused
#define PARM_MAP_HAS_DELUXE 19 // map has deluxedata
#define PARM_MAX_ENTITIES 20
#define PARM_WIDESCREEN 21

2
contib/a1batross/xash3d.files

@ -49,6 +49,7 @@ engine/client/avi/avi_win.c @@ -49,6 +49,7 @@ engine/client/avi/avi_win.c
engine/client/cl_cmds.c
engine/client/cl_custom.c
engine/client/cl_demo.c
engine/client/cl_debug.c
engine/client/cl_events.c
engine/client/cl_frame.c
engine/client/cl_game.c
@ -64,6 +65,7 @@ engine/client/cl_tent.c @@ -64,6 +65,7 @@ engine/client/cl_tent.c
engine/client/cl_tent.h
engine/client/cl_video.c
engine/client/cl_view.c
engine/client/cl_qparse.c
engine/client/client.h
engine/client/console.c
engine/client/gl_alias.c

242
engine/client/cl_debug.c

@ -0,0 +1,242 @@ @@ -0,0 +1,242 @@
/*
cl_debug.c - server message debugging
Copyright (C) 2018 Uncle Mike
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
*/
#include "common.h"
#include "client.h"
#include "net_encode.h"
#include "particledef.h"
#include "gl_local.h"
#include "cl_tent.h"
#include "shake.h"
#include "hltv.h"
#include "input.h"
#define MSG_COUNT 32 // last 32 messages parsed
#define MSG_MASK (MSG_COUNT - 1)
const char *svc_strings[svc_lastmsg+1] =
{
"svc_bad",
"svc_nop",
"svc_disconnect",
"svc_event",
"svc_changing",
"svc_setview",
"svc_sound",
"svc_time",
"svc_print",
"svc_stufftext",
"svc_setangle",
"svc_serverdata",
"svc_lightstyle",
"svc_updateuserinfo",
"svc_deltatable",
"svc_clientdata",
"svc_resource",
"svc_pings",
"svc_particle",
"svc_restoresound",
"svc_spawnstatic",
"svc_event_reliable",
"svc_spawnbaseline",
"svc_temp_entity",
"svc_setpause",
"svc_signonnum",
"svc_centerprint",
"svc_unused27",
"svc_unused28",
"svc_unused29",
"svc_intermission",
"svc_finale",
"svc_cdtrack",
"svc_restore",
"svc_cutscene",
"svc_weaponanim",
"svc_bspdecal",
"svc_roomtype",
"svc_addangle",
"svc_usermessage",
"svc_packetentities",
"svc_deltapacketentities",
"svc_choke",
"svc_resourcelist",
"svc_deltamovevars",
"svc_resourcerequest",
"svc_customization",
"svc_crosshairangle",
"svc_soundfade",
"svc_filetxferfailed",
"svc_hltv",
"svc_director",
"svc_voiceinit",
"svc_voicedata",
"svc_unused54",
"svc_unused55",
"svc_resourcelocation",
"svc_querycvarvalue",
"svc_querycvarvalue2",
};
typedef struct
{
int command;
int starting_offset;
int frame_number;
} oldcmd_t;
typedef struct
{
oldcmd_t oldcmd[MSG_COUNT];
int currentcmd;
qboolean parsing;
} msg_debug_t;
static msg_debug_t cls_message_debug;
const char *CL_MsgInfo( int cmd )
{
static string sz;
Q_strcpy( sz, "???" );
if( cmd >= 0 && cmd <= svc_lastmsg )
{
// get engine message name
Q_strncpy( sz, svc_strings[cmd], sizeof( sz ));
}
else if( cmd > svc_lastmsg && cmd <= ( svc_lastmsg + MAX_USER_MESSAGES ))
{
int i;
for( i = 0; i < MAX_USER_MESSAGES; i++ )
{
if( clgame.msg[i].number == cmd )
{
Q_strncpy( sz, clgame.msg[i].name, sizeof( sz ));
break;
}
}
}
return sz;
}
/*
=====================
CL_Parse_Debug
enable message debugging
=====================
*/
void CL_Parse_Debug( qboolean enable )
{
cls_message_debug.parsing = enable;
}
/*
=====================
CL_Parse_RecordCommand
record new message params into debug buffer
=====================
*/
void CL_Parse_RecordCommand( int cmd, int startoffset )
{
int slot;
if( cmd == svc_nop ) return;
slot = ( cls_message_debug.currentcmd++ & MSG_MASK );
cls_message_debug.oldcmd[slot].command = cmd;
cls_message_debug.oldcmd[slot].starting_offset = startoffset;
cls_message_debug.oldcmd[slot].frame_number = host.framecount;
}
/*
=====================
CL_ResetFrame
=====================
*/
void CL_ResetFrame( frame_t *frame )
{
memset( &frame->graphdata, 0, sizeof( netbandwidthgraph_t ));
frame->receivedtime = host.realtime;
frame->valid = true;
frame->choked = false;
frame->latency = 0.0;
frame->time = cl.mtime[0];
}
/*
=====================
CL_WriteErrorMessage
write net_message into buffer.dat for debugging
=====================
*/
static void CL_WriteErrorMessage( int current_count, sizebuf_t *msg )
{
const char *buffer_file = "buffer.dat";
file_t *fp;
fp = FS_Open( buffer_file, "wb", false );
if( !fp ) return;
FS_Write( fp, &cls.starting_count, sizeof( int ));
FS_Write( fp, &current_count, sizeof( int ));
FS_Write( fp, MSG_GetData( msg ), MSG_GetMaxBytes( msg ));
FS_Close( fp );
Con_Printf( "Wrote erroneous message to %s\n", buffer_file );
}
/*
=====================
CL_WriteMessageHistory
list last 32 messages for debugging net troubleshooting
=====================
*/
void CL_WriteMessageHistory( void )
{
oldcmd_t *old, *failcommand;
sizebuf_t *msg = &net_message;
int i, thecmd;
if( !cls.initialized || cls.state == ca_disconnected )
return;
if( !cls_message_debug.parsing )
return;
Con_Printf( "Last %i messages parsed.\n", MSG_COUNT );
// finish here
thecmd = cls_message_debug.currentcmd - 1;
thecmd -= ( MSG_COUNT - 1 ); // back up to here
for( i = 0; i < MSG_COUNT - 1; i++ )
{
thecmd &= MSG_MASK;
old = &cls_message_debug.oldcmd[thecmd];
Con_Printf( "%i %04i %s\n", old->frame_number, old->starting_offset, CL_MsgInfo( old->command ));
thecmd++;
}
failcommand = &cls_message_debug.oldcmd[thecmd];
Con_Printf( "BAD: %3i:%s\n", MSG_GetNumBytesRead( msg ) - 1, CL_MsgInfo( failcommand->command ));
if( host_developer.value >= DEV_EXTENDED )
CL_WriteErrorMessage( MSG_GetNumBytesRead( msg ) - 1, msg );
cls_message_debug.parsing = false;
}

263
engine/client/cl_demo.c

@ -626,6 +626,74 @@ void CL_ReadDemoSequence( qboolean discard ) @@ -626,6 +626,74 @@ void CL_ReadDemoSequence( qboolean discard )
cls.netchan.last_reliable_sequence = last_reliable_sequence;
}
/*
=================
CL_DemoStartPlayback
=================
*/
void CL_DemoStartPlayback( int mode )
{
if( cls.changedemo )
{
S_StopAllSounds( true );
SCR_BeginLoadingPlaque( false );
CL_ClearState ();
CL_InitEdicts (); // re-arrange edicts
}
else
{
// NOTE: at this point demo is still valid
CL_Disconnect();
Host_ShutdownServer();
Con_FastClose();
UI_SetActiveMenu( false );
}
cls.demoplayback = mode;
cls.state = ca_connected;
cl.background = (cls.demonum != -1) ? true : false;
cls.spectator = false;
cls.signon = 0;
demo.starttime = CL_GetDemoPlaybackClock(); // for determining whether to read another message
Netchan_Setup( NS_CLIENT, &cls.netchan, net_from, Cvar_VariableInteger( "net_qport" ), NULL, CL_GetFragmentSize );
memset( demo.cmds, 0, sizeof( demo.cmds ));
demo.angle_position = 1;
demo.framecount = 0;
cls.lastoutgoingcommand = -1;
cls.nextcmdtime = host.realtime;
cl.last_command_ack = -1;
}
/*
=================
CL_PlayDemoQuake
=================
*/
void CL_PlayDemoQuake( const char *demoname )
{
int c, neg = false;
cls.demofile = FS_Open( demoname, "rb", true );
Q_strncpy( cls.demoname, demoname, sizeof( cls.demoname ));
Q_strncpy( gameui.globals->demoname, demoname, sizeof( gameui.globals->demoname ));
demo.header.host_fps = host_maxfps->value;
cls.forcetrack = 0;
while(( c = FS_Getc( cls.demofile )) != '\n' )
{
if( c == '-' ) neg = true;
else cls.forcetrack = cls.forcetrack * 10 + (c - '0');
}
if( neg ) cls.forcetrack = -cls.forcetrack;
CL_DemoStartPlayback( DEMO_QUAKE1 );
}
/*
=================
CL_DemoAborted
@ -735,6 +803,94 @@ qboolean CL_ReadRawNetworkData( byte *buffer, size_t *length ) @@ -735,6 +803,94 @@ qboolean CL_ReadRawNetworkData( byte *buffer, size_t *length )
return true;
}
/*
=================
CL_DemoReadMessageQuake
reads demo data and write it to client
=================
*/
qboolean CL_DemoReadMessageQuake( byte *buffer, size_t *length )
{
int msglen = 0;
demoangle_t *a;
*length = 0; // assume we fail
// decide if it is time to grab the next message
if( cls.signon == SIGNONS ) // allways grab until fully connected
{
if( cls.timedemo )
{
if( host.framecount == cls.td_lastframe )
return false; // already read this frame's message
cls.td_lastframe = host.framecount;
// if this is the second frame, grab the real td_starttime
// so the bogus time on the first frame doesn't count
if( host.framecount == cls.td_startframe + 1 )
cls.td_starttime = host.realtime;
}
else if( cl.time <= cl.mtime[0] )
{
// don't need another message yet
return false;
}
}
// get the next message
FS_Read( cls.demofile, &msglen, sizeof( int ));
FS_Read( cls.demofile, &cl.viewangles[0], sizeof( float ));
FS_Read( cls.demofile, &cl.viewangles[1], sizeof( float ));
FS_Read( cls.demofile, &cl.viewangles[2], sizeof( float ));
cls.netchan.incoming_sequence++;
// make sure what interp info contain angles from different frames
// or lerping will stop working
if( demo.lasttime != demo.timestamp )
{
// select entry into circular buffer
demo.angle_position = (demo.angle_position + 1) & ANGLE_MASK;
a = &demo.cmds[demo.angle_position];
// record update
a->starttime = demo.timestamp;
VectorCopy( cl.viewangles, a->viewangles );
demo.lasttime = demo.timestamp;
}
if( msglen < 0 )
{
MsgDev( D_ERROR, "Demo message length < 0\n" );
CL_DemoCompleted();
return false;
}
if( msglen > MAX_INIT_MSG )
{
MsgDev( D_ERROR, "Demo message %i > %i\n", msglen, MAX_INIT_MSG );
CL_DemoCompleted();
return false;
}
if( msglen > 0 )
{
if( FS_Read( cls.demofile, buffer, msglen ) != msglen )
{
MsgDev( D_ERROR, "Error reading demo message data\n" );
CL_DemoCompleted();
return false;
}
}
*length = msglen;
if( cls.state != ca_active )
Cbuf_Execute();
return true;
}
/*
=================
CL_DemoReadMessage
@ -765,6 +921,9 @@ qboolean CL_DemoReadMessage( byte *buffer, size_t *length ) @@ -765,6 +921,9 @@ qboolean CL_DemoReadMessage( byte *buffer, size_t *length )
return false; // paused
}
if( cls.demoplayback == DEMO_QUAKE1 )
return CL_DemoReadMessageQuake( buffer, length );
do
{
qboolean bSkipMessage = false;
@ -933,7 +1092,8 @@ void CL_DemoInterpolateAngles( void ) @@ -933,7 +1092,8 @@ void CL_DemoInterpolateAngles( void )
QuaternionSlerp( q2, q1, frac, q );
QuaternionAngle( q, cl.viewangles );
}
else VectorCopy( cl.cmd->viewangles, cl.viewangles );
else if( cls.demoplayback != DEMO_QUAKE1 )
VectorCopy( cl.cmd->viewangles, cl.viewangles );
}
/*
@ -976,7 +1136,8 @@ void CL_StopPlayback( void ) @@ -976,7 +1136,8 @@ void CL_StopPlayback( void )
cls.demofile = NULL;
cls.olddemonum = Q_max( -1, cls.demonum - 1 );
Mem_Free( demo.directory.entries );
if( demo.directory.entries != NULL )
Mem_Free( demo.directory.entries );
cls.td_lastframe = host.framecount;
demo.directory.numentries = 0;
demo.directory.entries = NULL;
@ -1110,6 +1271,35 @@ qboolean CL_NextDemo( void ) @@ -1110,6 +1271,35 @@ qboolean CL_NextDemo( void )
return true;
}
/*
==================
CL_CheckStartupDemos
queue demos loop after movie playing
==================
*/
void CL_CheckStartupDemos( void )
{
if( !cls.demos_pending )
return; // no demos in loop
if( cls.movienum != -1 )
return; // wait until movies finished
if( GameState->nextstate != STATE_RUNFRAME || cls.demoplayback )
{
// commandline override
cls.demos_pending = false;
cls.demonum = -1;
return;
}
// run demos loop in background mode
Cvar_SetValue( "v_dark", 1.0f );
cls.demonum = 0;
CL_NextDemo ();
}
/*
==================
CL_DemoGetName
@ -1230,8 +1420,9 @@ playdemo <demoname> @@ -1230,8 +1420,9 @@ playdemo <demoname>
*/
void CL_PlayDemo_f( void )
{
string filename;
string demoname;
char filename1[MAX_QPATH];
char filename2[MAX_QPATH];
char demoname[MAX_QPATH];
int i;
if( Cmd_Argc() != 2 )
@ -1251,17 +1442,24 @@ void CL_PlayDemo_f( void ) @@ -1251,17 +1442,24 @@ void CL_PlayDemo_f( void )
return;
}
Q_strncpy( demoname, Cmd_Argv( 1 ), sizeof( demoname ) - 1 );
Q_snprintf( filename, sizeof( filename ), "demos/%s.dem", demoname );
Q_strncpy( demoname, Cmd_Argv( 1 ), sizeof( demoname ));
COM_StripExtension( demoname );
Q_snprintf( filename1, sizeof( filename1 ), "%s.dem", demoname );
Q_snprintf( filename2, sizeof( filename2 ), "demos/%s.dem", demoname );
if( !FS_FileExists( filename, true ))
if( FS_FileExists( filename1, true ))
{
CL_PlayDemoQuake( filename1 );
return;
}
else if( !FS_FileExists( filename2, true ))
{
MsgDev( D_ERROR, "couldn't open %s\n", filename );
MsgDev( D_ERROR, "couldn't open %s\n", filename2 );
CL_DemoAborted();
return;
}
cls.demofile = FS_Open( filename, "rb", true );
cls.demofile = FS_Open( filename2, "rb", true );
Q_strncpy( cls.demoname, demoname, sizeof( cls.demoname ));
Q_strncpy( gameui.globals->demoname, demoname, sizeof( gameui.globals->demoname ));
@ -1270,7 +1468,7 @@ void CL_PlayDemo_f( void ) @@ -1270,7 +1468,7 @@ void CL_PlayDemo_f( void )
if( demo.header.id != IDEMOHEADER )
{
MsgDev( D_ERROR, "%s is not a demo file\n", filename );
MsgDev( D_ERROR, "%s is not a demo file\n", demoname );
CL_DemoAborted();
return;
}
@ -1297,24 +1495,6 @@ void CL_PlayDemo_f( void ) @@ -1297,24 +1495,6 @@ void CL_PlayDemo_f( void )
return;
}
if( cls.changedemo )
{
S_StopAllSounds( true );
SCR_BeginLoadingPlaque( false );
CL_ClearState ();
CL_InitEdicts (); // re-arrange edicts
}
else
{
// NOTE: at this point demo is still valid
CL_Disconnect();
Host_ShutdownServer();
Con_FastClose();
UI_SetActiveMenu( false );
}
// allocate demo entries
demo.directory.entries = Mem_Malloc( cls.mempool, sizeof( demoentry_t ) * demo.directory.numentries );
@ -1328,22 +1508,7 @@ void CL_PlayDemo_f( void ) @@ -1328,22 +1508,7 @@ void CL_PlayDemo_f( void )
FS_Seek( cls.demofile, demo.entry->offset, SEEK_SET );
cls.demoplayback = true;
cls.state = ca_connected;
cl.background = (cls.demonum != -1) ? true : false;
cls.spectator = false;
cls.signon = 0;
demo.starttime = CL_GetDemoPlaybackClock(); // for determining whether to read another message
Netchan_Setup( NS_CLIENT, &cls.netchan, net_from, Cvar_VariableInteger( "net_qport" ), NULL, CL_GetFragmentSize );
memset( demo.cmds, 0, sizeof( demo.cmds ));
demo.angle_position = 1;
demo.framecount = 0;
cls.lastoutgoingcommand = -1;
cls.nextcmdtime = host.realtime;
cl.last_command_ack = -1;
CL_DemoStartPlayback( DEMO_XASH3D );
// g-cont. is this need?
Q_strncpy( cls.servername, demoname, sizeof( cls.servername ));
@ -1402,15 +1567,7 @@ void CL_StartDemos_f( void ) @@ -1402,15 +1567,7 @@ void CL_StartDemos_f( void )
for( i = 1; i < c + 1; i++ )
Q_strncpy( cls.demos[i-1], Cmd_Argv( i ), sizeof( cls.demos[0] ));
if( !SV_Active() && !cls.demoplayback )
{
// run demos loop in background mode
Cvar_SetValue( "v_dark", 1.0f );
cls.demonum = 0;
CL_NextDemo ();
}
else cls.demonum = -1;
cls.demos_pending = true;
}
/*

13
engine/client/cl_frame.c

@ -603,13 +603,13 @@ void CL_FlushEntityPacket( sizebuf_t *msg ) @@ -603,13 +603,13 @@ void CL_FlushEntityPacket( sizebuf_t *msg )
// read it all, but ignore it
while( 1 )
{
newnum = MSG_ReadUBitLong( msg, MAX_VISIBLE_PACKET_BITS );
newnum = MSG_ReadUBitLong( msg, MAX_ENTITY_BITS );
if( newnum == LAST_EDICT ) break; // done
if( MSG_CheckOverflow( msg ))
Host_Error( "CL_FlushEntityPacket: overflow\n" );
MSG_ReadDeltaEntity( msg, &from, &to, newnum, CL_IsPlayerIndex( newnum ), cl.mtime[0] );
MSG_ReadDeltaEntity( msg, &from, &to, newnum, CL_IsPlayerIndex( newnum ) ? DELTA_PLAYER : DELTA_ENTITY, cl.mtime[0] );
}
}
@ -626,17 +626,18 @@ void CL_DeltaEntity( sizebuf_t *msg, frame_t *frame, int newnum, entity_state_t @@ -626,17 +626,18 @@ void CL_DeltaEntity( sizebuf_t *msg, frame_t *frame, int newnum, entity_state_t
entity_state_t *state;
qboolean newent = (old) ? false : true;
int pack = frame->num_entities;
qboolean player = CL_IsPlayerIndex( newnum );
int delta_type = DELTA_ENTITY;
qboolean alive = true;
// alloc next slot to store update
state = &cls.packet_entities[cls.next_client_entities % cls.num_client_entities];
if( CL_IsPlayerIndex( newnum )) delta_type = DELTA_PLAYER;
if(( newnum < 0 ) || ( newnum >= clgame.maxEntities ))
{
MsgDev( D_ERROR, "CL_DeltaEntity: invalid newnum: %d\n", newnum );
if( has_update )
MSG_ReadDeltaEntity( msg, old, state, newnum, player, cl.mtime[0] );
MSG_ReadDeltaEntity( msg, old, state, newnum, delta_type, cl.mtime[0] );
return;
}
@ -645,7 +646,7 @@ void CL_DeltaEntity( sizebuf_t *msg, frame_t *frame, int newnum, entity_state_t @@ -645,7 +646,7 @@ void CL_DeltaEntity( sizebuf_t *msg, frame_t *frame, int newnum, entity_state_t
if( newent ) old = &ent->baseline;
if( has_update )
alive = MSG_ReadDeltaEntity( msg, old, state, newnum, player, cl.mtime[0] );
alive = MSG_ReadDeltaEntity( msg, old, state, newnum, delta_type, cl.mtime[0] );
else memcpy( state, old, sizeof( entity_state_t ));
if( !alive )
@ -1074,7 +1075,7 @@ void CL_LinkPacketEntities( frame_t *frame ) @@ -1074,7 +1075,7 @@ void CL_LinkPacketEntities( frame_t *frame )
if( ent->curstate.rendermode == kRenderNormal )
{
// auto 'solid' faces
if( FBitSet( ent->model->flags, MODEL_TRANSPARENT ) && FBitSet( host.features, ENGINE_QUAKE_COMPATIBLE ))
if( FBitSet( ent->model->flags, MODEL_TRANSPARENT ) && Host_IsQuakeCompatible( ))
{
ent->curstate.rendermode = kRenderTransAlpha;
ent->curstate.renderamt = 255;

2
engine/client/cl_game.c

@ -1868,7 +1868,7 @@ int pfnDrawConsoleString( int x, int y, char *string ) @@ -1868,7 +1868,7 @@ int pfnDrawConsoleString( int x, int y, char *string )
int drawLen;
if( !COM_CheckString( string ))
return 0; // silent ignore
return 0; // silent ignore
Con_SetFont( con_fontsize->value );
clgame.ds.adjust_size = true;

36
engine/client/cl_main.c

@ -249,14 +249,31 @@ static float CL_LerpPoint( void ) @@ -249,14 +249,31 @@ static float CL_LerpPoint( void )
if( f == 0.0f || cls.timedemo )
{
cl.time = cl.mtime[0];
// g-cont. probably this is redundant
if( cls.demoplayback )
cl.oldtime = cl.mtime[0] - cl_clientframetime();
return 1.0f;
}
if( f > 0.1f )
{
// dropped packet, or start of demo
cl.mtime[1] = cl.mtime[0] - 0.1f;
f = 0.1f;
}
#if 1
frac = (cl.time - cl.mtime[1]) / f;
if( frac < 0.0f )
{
if( frac < -0.01 )
cl.time = cl.mtime[1];
frac = 0.0f;
}
else if( frac > 1.0f )
{
if( frac > 1.01 )
cl.time = cl.mtime[0];
frac = 1.0f;
}
#else
if( cl_interp->value > 0.001f )
{
// manual lerp value (goldsrc mode)
@ -267,7 +284,7 @@ static float CL_LerpPoint( void ) @@ -267,7 +284,7 @@ static float CL_LerpPoint( void )
// automatic lerp (classic mode)
frac = ( cl.time - cl.mtime[1] ) / f;
}
#endif
return frac;
}
@ -2003,7 +2020,10 @@ void CL_ReadNetMessage( void ) @@ -2003,7 +2020,10 @@ void CL_ReadNetMessage( void )
if( !cls.demoplayback && !Netchan_Process( &cls.netchan, &net_message ))
continue; // wasn't accepted for some reason
CL_ParseServerMessage( &net_message, true );
// run special handler for quake demos
if( cls.demoplayback == DEMO_QUAKE1 )
CL_ParseQuakeMessage( &net_message, true );
else CL_ParseServerMessage( &net_message, true );
cl.send_reply = true;
}
@ -2046,7 +2066,7 @@ void CL_ReadPackets( void ) @@ -2046,7 +2066,7 @@ void CL_ReadPackets( void )
// decide the simulation time
cl.oldtime = cl.time;
if( !cls.demoplayback && !cl.paused )
if( cls.demoplayback != DEMO_XASH3D && !cl.paused )
cl.time += host.frametime;
// demo time

272
engine/client/cl_parse.c

@ -23,200 +23,8 @@ GNU General Public License for more details. @@ -23,200 +23,8 @@ GNU General Public License for more details.
#include "hltv.h"
#include "input.h"
#define MSG_COUNT 32 // last 32 messages parsed
#define MSG_MASK (MSG_COUNT - 1)
int CL_UPDATE_BACKUP = SINGLEPLAYER_BACKUP;
const char *svc_strings[svc_lastmsg+1] =
{
"svc_bad",
"svc_nop",
"svc_disconnect",
"svc_event",
"svc_changing",
"svc_setview",
"svc_sound",
"svc_time",
"svc_print",
"svc_stufftext",
"svc_setangle",
"svc_serverdata",
"svc_lightstyle",
"svc_updateuserinfo",
"svc_deltatable",
"svc_clientdata",
"svc_resource",
"svc_pings",
"svc_particle",
"svc_restoresound",
"svc_spawnstatic",
"svc_event_reliable",
"svc_spawnbaseline",
"svc_temp_entity",
"svc_setpause",
"svc_signonnum",
"svc_centerprint",
"svc_unused27",
"svc_unused28",
"svc_unused29",
"svc_intermission",
"svc_finale",
"svc_cdtrack",
"svc_restore",
"svc_cutscene",
"svc_weaponanim",
"svc_bspdecal",
"svc_roomtype",
"svc_addangle",
"svc_usermessage",
"svc_packetentities",
"svc_deltapacketentities",
"svc_choke",
"svc_resourcelist",
"svc_deltamovevars",
"svc_resourcerequest",
"svc_customization",
"svc_crosshairangle",
"svc_soundfade",
"svc_filetxferfailed",
"svc_hltv",
"svc_director",
"svc_voiceinit",
"svc_voicedata",
"svc_unused54",
"svc_unused55",
"svc_resourcelocation",
"svc_querycvarvalue",
"svc_querycvarvalue2",
};
typedef struct
{
int command;
int starting_offset;
int frame_number;
} oldcmd_t;
typedef struct
{
oldcmd_t oldcmd[MSG_COUNT];
int currentcmd;
qboolean parsing;
} msg_debug_t;
static msg_debug_t cls_message_debug;
static int starting_count;
const char *CL_MsgInfo( int cmd )
{
static string sz;
Q_strcpy( sz, "???" );
if( cmd >= 0 && cmd <= svc_lastmsg )
{
// get engine message name
Q_strncpy( sz, svc_strings[cmd], sizeof( sz ));
}
else if( cmd > svc_lastmsg && cmd <= ( svc_lastmsg + MAX_USER_MESSAGES ))
{
int i;
for( i = 0; i < MAX_USER_MESSAGES; i++ )
{
if( clgame.msg[i].number == cmd )
{
Q_strncpy( sz, clgame.msg[i].name, sizeof( sz ));
break;
}
}
}
return sz;
}
/*
=====================
CL_Parse_RecordCommand
record new message params into debug buffer
=====================
*/
void CL_Parse_RecordCommand( int cmd, int startoffset )
{
int slot;
if( cmd == svc_nop ) return;
slot = ( cls_message_debug.currentcmd++ & MSG_MASK );
cls_message_debug.oldcmd[slot].command = cmd;
cls_message_debug.oldcmd[slot].starting_offset = startoffset;
cls_message_debug.oldcmd[slot].frame_number = host.framecount;
}
/*
=====================
CL_WriteErrorMessage
write net_message into buffer.dat for debugging
=====================
*/
void CL_WriteErrorMessage( int current_count, sizebuf_t *msg )
{
const char *buffer_file = "buffer.dat";
file_t *fp;
fp = FS_Open( buffer_file, "wb", false );
if( !fp ) return;
FS_Write( fp, &starting_count, sizeof( int ));
FS_Write( fp, &current_count, sizeof( int ));
FS_Write( fp, MSG_GetData( msg ), MSG_GetMaxBytes( msg ));
FS_Close( fp );
Con_Printf( "Wrote erroneous message to %s\n", buffer_file );
}
/*
=====================
CL_WriteMessageHistory
list last 32 messages for debugging net troubleshooting
=====================
*/
void CL_WriteMessageHistory( void )
{
oldcmd_t *old, *failcommand;
sizebuf_t *msg = &net_message;
int i, thecmd;
if( !cls.initialized || cls.state == ca_disconnected )
return;
if( !cls_message_debug.parsing )
return;
Con_Printf( "Last %i messages parsed.\n", MSG_COUNT );
// finish here
thecmd = cls_message_debug.currentcmd - 1;
thecmd -= ( MSG_COUNT - 1 ); // back up to here
for( i = 0; i < MSG_COUNT - 1; i++ )
{
thecmd &= MSG_MASK;
old = &cls_message_debug.oldcmd[thecmd];
Con_Printf( "%i %04i %s\n", old->frame_number, old->starting_offset, CL_MsgInfo( old->command ));
thecmd++;
}
failcommand = &cls_message_debug.oldcmd[thecmd];
Con_Printf( "BAD: %3i:%s\n", MSG_GetNumBytesRead( msg ) - 1, CL_MsgInfo( failcommand->command ));
if( host_developer.value >= DEV_EXTENDED )
CL_WriteErrorMessage( MSG_GetNumBytesRead( msg ) - 1, msg );
cls_message_debug.parsing = false;
}
/*
===============
CL_UserMsgStub
@ -387,6 +195,9 @@ void CL_ParseServerTime( sizebuf_t *msg ) @@ -387,6 +195,9 @@ void CL_ParseServerTime( sizebuf_t *msg )
cl.mtime[1] = cl.mtime[0];
cl.mtime[0] = MSG_ReadFloat( msg );
if( cls.demoplayback == DEMO_QUAKE1 )
return; // don't mess the time
if( cl.maxclients == 1 )
cl.time = cl.mtime[0];
@ -502,46 +313,27 @@ static client entity @@ -502,46 +313,27 @@ static client entity
*/
void CL_ParseStaticEntity( sizebuf_t *msg )
{
entity_state_t state;
int i, newnum;
entity_state_t from, to;
cl_entity_t *ent;
int i;
memset( &state, 0, sizeof( state ));
state.modelindex = MSG_ReadShort( msg );
state.sequence = MSG_ReadWord( msg );
state.frame = MSG_ReadWord( msg ) * (1.0f / 128.0f);
state.colormap = MSG_ReadWord( msg );
state.skin = MSG_ReadByte( msg );
state.body = MSG_ReadByte( msg );
state.scale = MSG_ReadCoord( msg );
MSG_ReadVec3Coord( msg, state.origin );
MSG_ReadVec3Angles( msg, state.angles );
state.rendermode = MSG_ReadByte( msg );
if( state.rendermode != kRenderNormal )
{
state.renderamt = MSG_ReadByte( msg );
state.rendercolor.r = MSG_ReadByte( msg );
state.rendercolor.g = MSG_ReadByte( msg );
state.rendercolor.b = MSG_ReadByte( msg );
state.renderfx = MSG_ReadByte( msg );
}
memset( &from, 0, sizeof( from ));
newnum = MSG_ReadUBitLong( msg, MAX_ENTITY_BITS );
MSG_ReadDeltaEntity( msg, &from, &to, 0, DELTA_STATIC, cl.mtime[0] );
i = clgame.numStatics;
if( i >= MAX_STATIC_ENTITIES )
{
MsgDev( D_ERROR, "CL_ParseStaticEntity: static entities limit exceeded!\n" );
Con_Printf( S_ERROR "MAX_STATIC_ENTITIES limit exceeded!\n" );
return;
}
ent = &clgame.static_entities[i];
clgame.numStatics++;
ent->index = 0; // ???
ent->baseline = state;
ent->curstate = state;
ent->prevstate = state;
// all states are same
ent->baseline = ent->curstate = ent->prevstate = to;
ent->index = 0; // static entities doesn't has the numbers
// statics may be respawned in game e.g. for demo recording
if( cls.state == ca_connected || cls.state == ca_validate )
@ -550,14 +342,14 @@ void CL_ParseStaticEntity( sizebuf_t *msg ) @@ -550,14 +342,14 @@ void CL_ParseStaticEntity( sizebuf_t *msg )
// setup the new static entity
VectorCopy( ent->curstate.origin, ent->origin );
VectorCopy( ent->curstate.angles, ent->angles );
ent->model = CL_ModelHandle( state.modelindex );
ent->model = CL_ModelHandle( to.modelindex );
ent->curstate.framerate = 1.0f;
CL_ResetLatchedVars( ent, true );
if( ent->curstate.rendermode == kRenderNormal && ent->model != NULL )
{
// auto 'solid' faces
if( FBitSet( ent->model->flags, MODEL_TRANSPARENT ) && FBitSet( host.features, ENGINE_QUAKE_COMPATIBLE ))
if( FBitSet( ent->model->flags, MODEL_TRANSPARENT ) && Host_IsQuakeCompatible( ))
{
ent->curstate.rendermode = kRenderTransAlpha;
ent->curstate.renderamt = 255;
@ -2187,21 +1979,6 @@ void CL_ParseUserMessage( sizebuf_t *msg, int svc_num ) @@ -2187,21 +1979,6 @@ void CL_ParseUserMessage( sizebuf_t *msg, int svc_num )
}
}
/*
=====================
CL_ResetFrame
=====================
*/
void CL_ResetFrame( frame_t *frame )
{
memset( &frame->graphdata, 0, sizeof( netbandwidthgraph_t ));
frame->receivedtime = host.realtime;
frame->valid = true;
frame->choked = false;
frame->latency = 0.0;
frame->time = cl.mtime[0];
}
/*
=====================================================================
@ -2222,8 +1999,8 @@ void CL_ParseServerMessage( sizebuf_t *msg, qboolean normal_message ) @@ -2222,8 +1999,8 @@ void CL_ParseServerMessage( sizebuf_t *msg, qboolean normal_message )
int cmd, param1, param2;
int old_background;
cls_message_debug.parsing = true; // begin parsing
starting_count = MSG_GetNumBytesRead( msg ); // updates each frame
cls.starting_count = MSG_GetNumBytesRead( msg ); // updates each frame
CL_Parse_Debug( true ); // begin parsing
if( normal_message )
{
@ -2257,6 +2034,8 @@ void CL_ParseServerMessage( sizebuf_t *msg, qboolean normal_message ) @@ -2257,6 +2034,8 @@ void CL_ParseServerMessage( sizebuf_t *msg, qboolean normal_message )
cmd = MSG_ReadServerCmd( msg );
// Msg( "%s\n", CL_MsgInfo( cmd ));
// record command for debugging spew on parse problem
CL_Parse_RecordCommand( cmd, bufStart );
@ -2284,7 +2063,7 @@ void CL_ParseServerMessage( sizebuf_t *msg, qboolean normal_message ) @@ -2284,7 +2063,7 @@ void CL_ParseServerMessage( sizebuf_t *msg, qboolean normal_message )
cls.changelevel = true;
S_StopAllSounds( true );
MsgDev( D_INFO, "Server changing, reconnecting\n" );
Con_Printf( "Server changing, reconnecting\n" );
if( cls.demoplayback )
{
@ -2295,7 +2074,7 @@ void CL_ParseServerMessage( sizebuf_t *msg, qboolean normal_message ) @@ -2295,7 +2074,7 @@ void CL_ParseServerMessage( sizebuf_t *msg, qboolean normal_message )
CL_ClearState ();
CL_InitEdicts (); // re-arrange edicts
}
else MsgDev( D_INFO, "Server disconnected, reconnecting\n" );
else Con_Printf( "Server disconnected, reconnecting\n" );
if( cls.demoplayback )
{
@ -2305,7 +2084,8 @@ void CL_ParseServerMessage( sizebuf_t *msg, qboolean normal_message ) @@ -2305,7 +2084,8 @@ void CL_ParseServerMessage( sizebuf_t *msg, qboolean normal_message )
else
{
// g-cont. local client skip the challenge
if( SV_Active()) cls.state = ca_disconnected;
if( SV_Active( ))
cls.state = ca_disconnected;
else cls.state = ca_connecting;
cl.background = old_background;
cls.connect_time = MAX_HEARTBEAT;
@ -2483,8 +2263,8 @@ void CL_ParseServerMessage( sizebuf_t *msg, qboolean normal_message ) @@ -2483,8 +2263,8 @@ void CL_ParseServerMessage( sizebuf_t *msg, qboolean normal_message )
}
}
cl.frames[cl.parsecountmod].graphdata.msgbytes += MSG_GetNumBytesRead( msg ) - starting_count;
cls_message_debug.parsing = false; // done
cl.frames[cl.parsecountmod].graphdata.msgbytes += MSG_GetNumBytesRead( msg ) - cls.starting_count;
CL_Parse_Debug( false ); // done
// we don't know if it is ok to save a demo message until
// after we have parsed the frame
@ -2492,11 +2272,11 @@ void CL_ParseServerMessage( sizebuf_t *msg, qboolean normal_message ) @@ -2492,11 +2272,11 @@ void CL_ParseServerMessage( sizebuf_t *msg, qboolean normal_message )
{
if( cls.demorecording && !cls.demowaiting )
{
CL_WriteDemoMessage( false, starting_count, msg );
CL_WriteDemoMessage( false, cls.starting_count, msg );
}
else if( cls.state != ca_active )
{
CL_WriteDemoMessage( true, starting_count, msg );
CL_WriteDemoMessage( true, cls.starting_count, msg );
}
}
}

4
engine/client/cl_pmove.c

@ -115,6 +115,10 @@ qboolean CL_IsPredicted( void ) @@ -115,6 +115,10 @@ qboolean CL_IsPredicted( void )
{
if( cl_nopred->value || cl.intermission )
return false;
// never predict the quake demos
if( cls.demoplayback == DEMO_QUAKE1 )
return false;
return true;
}

1007
engine/client/cl_qparse.c

File diff suppressed because it is too large Load Diff

1
engine/client/cl_scrn.c

@ -735,6 +735,7 @@ void SCR_Init( void ) @@ -735,6 +735,7 @@ void SCR_Init( void )
// register our commands
Cmd_AddCommand( "timerefresh", SCR_TimeRefresh_f, "turn quickly and print rendering statistcs" );
Cmd_AddCommand( "skyname", CL_SetSky_f, "set new skybox by basename" );
Cmd_AddCommand( "loadsky", CL_SetSky_f, "set new skybox by basename" );
Cmd_AddCommand( "viewpos", SCR_Viewpos_f, "prints current player origin" );
Cmd_AddCommand( "sizeup", SCR_SizeUp_f, "screen size up to 10 points" );
Cmd_AddCommand( "sizedown", SCR_SizeDown_f, "screen size down to 10 points" );

4
engine/client/cl_tent.c

@ -151,7 +151,7 @@ void CL_AddClientResources( void ) @@ -151,7 +151,7 @@ void CL_AddClientResources( void )
int i;
// don't request resources from localhost or in quake-compatibility mode
if( cl.maxclients <= 1 || FBitSet( host.features, ENGINE_QUAKE_COMPATIBLE ))
if( cl.maxclients <= 1 || Host_IsQuakeCompatible( ))
return;
// check sprites first
@ -2808,7 +2808,7 @@ void CL_AddEntityEffects( cl_entity_t *ent ) @@ -2808,7 +2808,7 @@ void CL_AddEntityEffects( cl_entity_t *ent )
if( FBitSet( ent->curstate.effects, EF_DIMLIGHT ))
{
if( ent->player && !FBitSet( host.features, ENGINE_QUAKE_COMPATIBLE ))
if( ent->player && !Host_IsQuakeCompatible( ))
{
CL_UpdateFlashlight( ent );
}

3
engine/client/cl_video.c

@ -48,6 +48,7 @@ qboolean SCR_NextMovie( void ) @@ -48,6 +48,7 @@ qboolean SCR_NextMovie( void )
{
S_StopAllSounds( true );
SCR_StopCinematic();
CL_CheckStartupDemos();
return false; // don't play movies
}
@ -56,6 +57,7 @@ qboolean SCR_NextMovie( void ) @@ -56,6 +57,7 @@ qboolean SCR_NextMovie( void )
S_StopAllSounds( true );
SCR_StopCinematic();
cls.movienum = -1;
CL_CheckStartupDemos();
return false;
}
@ -90,6 +92,7 @@ void SCR_CheckStartupVids( void ) @@ -90,6 +92,7 @@ void SCR_CheckStartupVids( void )
{
// don't run movies where we in developer-mode
cls.movienum = -1;
CL_CheckStartupDemos();
return;
}

33
engine/client/client.h

@ -53,6 +53,13 @@ GNU General Public License for more details. @@ -53,6 +53,13 @@ GNU General Public License for more details.
typedef int sound_t;
typedef enum
{
DEMO_INACTIVE = 0,
DEMO_XASH3D,
DEMO_QUAKE1
} demo_mode;
//=============================================================================
typedef struct netbandwithgraph_s
{
@ -595,6 +602,7 @@ typedef struct @@ -595,6 +602,7 @@ typedef struct
float packet_loss;
double packet_loss_recalc_time;
int starting_count; // message num readed bits
float nextcmdtime; // when can we send the next command packet?
int lastoutgoingcommand; // sequence number of last outgoing command
@ -603,6 +611,7 @@ typedef struct @@ -603,6 +611,7 @@ typedef struct
int td_lastframe; // to meter out one message a frame
int td_startframe; // host_framecount at start
double td_starttime; // realtime at second frame of timedemo
int forcetrack; // -1 = use normal cd track
// game images
int pauseIcon; // draw 'paused' when game in-pause
@ -632,7 +641,8 @@ typedef struct @@ -632,7 +641,8 @@ typedef struct
// demo loop control
int demonum; // -1 = don't play demos
int olddemonum; // restore playing
string demos[MAX_DEMOS]; // when not playing
char demos[MAX_DEMOS][MAX_QPATH]; // when not playing
qboolean demos_pending;
// movie playlist
int movienum;
@ -747,6 +757,15 @@ void CL_RemoveFromResourceList( resource_t *pResource ); @@ -747,6 +757,15 @@ void CL_RemoveFromResourceList( resource_t *pResource );
void CL_MoveToOnHandList( resource_t *pResource );
void CL_ClearResourceLists( void );
//
// cl_debug.c
//
void CL_Parse_Debug( qboolean enable );
void CL_Parse_RecordCommand( int cmd, int startoffset );
void CL_ResetFrame( frame_t *frame );
void CL_WriteMessageHistory( void );
const char *CL_MsgInfo( int cmd );
//
// cl_main.c
//
@ -774,8 +793,10 @@ void CL_WriteDemoMessage( qboolean startup, int start, sizebuf_t *msg ); @@ -774,8 +793,10 @@ void CL_WriteDemoMessage( qboolean startup, int start, sizebuf_t *msg );
void CL_WriteDemoUserMessage( const byte *buffer, size_t size );
qboolean CL_DemoReadMessage( byte *buffer, size_t *length );
void CL_DemoInterpolateAngles( void );
void CL_CheckStartupDemos( void );
void CL_WriteDemoJumpTime( void );
void CL_CloseDemoHeader( void );
void CL_DemoCompleted( void );
void CL_StopPlayback( void );
void CL_StopRecord( void );
void CL_PlayDemo_f( void );
@ -785,7 +806,6 @@ void CL_Demos_f( void ); @@ -785,7 +806,6 @@ void CL_Demos_f( void );
void CL_DeleteDemo_f( void );
void CL_Record_f( void );
void CL_Stop_f( void );
void CL_FreeDemo( void );
//
// cl_events.c
@ -858,6 +878,8 @@ void CL_StartResourceDownloading( const char *pszMessage, qboolean bCustom ); @@ -858,6 +878,8 @@ void CL_StartResourceDownloading( const char *pszMessage, qboolean bCustom );
qboolean CL_DispatchUserMessage( const char *pszName, int iSize, void *pbuf );
qboolean CL_RequestMissingResources( void );
void CL_RegisterResources ( sizebuf_t *msg );
void CL_ParseViewEntity( sizebuf_t *msg );
void CL_ParseServerTime( sizebuf_t *msg );
//
// cl_scrn.c
@ -919,6 +941,11 @@ void CL_PushPMStates( void ); @@ -919,6 +941,11 @@ void CL_PushPMStates( void );
void CL_PopPMStates( void );
void CL_SetUpPlayerPrediction( int dopred, int bIncludeLocalClient );
//
// cl_qparse.c
//
void CL_ParseQuakeMessage( sizebuf_t *msg, qboolean normal_message );
//
// cl_studio.c
//
@ -935,7 +962,7 @@ void CL_ResetLatchedVars( cl_entity_t *ent, qboolean full_reset ); @@ -935,7 +962,7 @@ void CL_ResetLatchedVars( cl_entity_t *ent, qboolean full_reset );
qboolean CL_GetEntitySpatialization( channel_t *ch );
qboolean CL_GetMovieSpatialization( rawchan_t *ch );
void CL_ComputePlayerOrigin( cl_entity_t *clent );
void CL_UpdateEntityFields( cl_entity_t *ent );
void CL_ProcessPacket( frame_t *frame );
void CL_MoveThirdpersonCamera( void );
qboolean CL_IsPlayerIndex( int idx );
void CL_SetIdealPitch( void );

31
engine/client/gl_backend.c

@ -43,6 +43,25 @@ qboolean R_SpeedsMessage( char *out, size_t size ) @@ -43,6 +43,25 @@ qboolean R_SpeedsMessage( char *out, size_t size )
return true;
}
/*
==============
R_Speeds_Printf
helper to print into r_speeds message
==============
*/
void R_Speeds_Printf( const char *msg, ... )
{
va_list argptr;
char text[2048];
va_start( argptr, msg );
Q_vsprintf( text, msg, argptr );
va_end( argptr );
Q_strncat( r_speeds_msg, text, sizeof( r_speeds_msg ));
}
/*
==============
GL_BackendStartFrame
@ -60,9 +79,17 @@ GL_BackendEndFrame @@ -60,9 +79,17 @@ GL_BackendEndFrame
*/
void GL_BackendEndFrame( void )
{
mleaf_t *curleaf;
if( r_speeds->value <= 0 || !RI.drawWorld )
return;
if( !RI.viewleaf )
curleaf = cl.worldmodel->leafs;
else curleaf = RI.viewleaf;
R_Speeds_Printf( "Renderer: ^1Engine^7\n\n" );
switch( (int)r_speeds->value )
{
case 1:
@ -70,8 +97,8 @@ void GL_BackendEndFrame( void ) @@ -70,8 +97,8 @@ void GL_BackendEndFrame( void )
r_stats.c_world_polys, r_stats.c_alias_polys, r_stats.c_studio_polys, r_stats.c_sprite_polys );
break;
case 2:
Q_snprintf( r_speeds_msg, sizeof( r_speeds_msg ), "visible leafs:\n%3i leafs\ncurrent leaf %3i",
r_stats.c_world_leafs, Mod_PointInLeaf( RI.pvsorigin, cl.worldmodel->nodes ) - cl.worldmodel->leafs );
R_Speeds_Printf( "visible leafs:\n%3i leafs\ncurrent leaf %3i\n", r_stats.c_world_leafs, curleaf - cl.worldmodel->leafs );
R_Speeds_Printf( "ReciusiveWorldNode: %3lf secs\nDrawTextureChains %lf\n", r_stats.t_world_node, r_stats.t_world_draw );
break;
case 3:
Q_snprintf( r_speeds_msg, sizeof( r_speeds_msg ), "%3i alias models drawn\n%3i studio models drawn\n%3i sprites drawn",

2
engine/client/gl_image.c

@ -883,7 +883,7 @@ byte *GL_ApplyFilter( const byte *source, int width, int height ) @@ -883,7 +883,7 @@ byte *GL_ApplyFilter( const byte *source, int width, int height )
byte *out = (byte *)source;
int i;
if( FBitSet( host.features, ENGINE_QUAKE_COMPATIBLE ) || glConfig.max_multisamples > 1 )
if( Host_IsQuakeCompatible() || glConfig.max_multisamples > 1 )
return in;
for( i = 0; source && i < width * height; i++, in += 4 )

2
engine/client/gl_local.h

@ -229,6 +229,8 @@ typedef struct @@ -229,6 +229,8 @@ typedef struct
uint c_particle_count;
uint c_client_ents; // entities that moved to client
double t_world_node;
double t_world_draw;
} ref_speeds_t;
extern ref_speeds_t r_stats;

6
engine/client/gl_refrag.c

@ -81,7 +81,6 @@ R_SplitEntityOnNode @@ -81,7 +81,6 @@ R_SplitEntityOnNode
static void R_SplitEntityOnNode( mnode_t *node )
{
efrag_t *ef;
mplane_t *splitplane;
mleaf_t *leaf;
int sides;
@ -100,7 +99,7 @@ static void R_SplitEntityOnNode( mnode_t *node ) @@ -100,7 +99,7 @@ static void R_SplitEntityOnNode( mnode_t *node )
ef = clgame.free_efrags;
if( !ef )
{
MsgDev( D_ERROR, "too many efrags!\n" );
Con_Printf( S_ERROR "too many efrags!\n" );
return; // no free fragments...
}
@ -120,8 +119,7 @@ static void R_SplitEntityOnNode( mnode_t *node ) @@ -120,8 +119,7 @@ static void R_SplitEntityOnNode( mnode_t *node )
}
// NODE_MIXED
splitplane = node->plane;
sides = BOX_ON_PLANE_SIDE( r_emins, r_emaxs, splitplane );
sides = BOX_ON_PLANE_SIDE( r_emins, r_emaxs, node->plane );
if( sides == 3 )
{

4
engine/client/gl_rmain.c

@ -658,7 +658,7 @@ static void R_CheckFog( void ) @@ -658,7 +658,7 @@ static void R_CheckFog( void )
int i, cnt, count;
// quake global fog
if( clgame.movevars.fog_settings != 0 && FBitSet( host.features, ENGINE_QUAKE_COMPATIBLE ))
if( clgame.movevars.fog_settings != 0 && Host_IsQuakeCompatible( ))
{
// quake-style global fog
RI.fogColor[0] = ((clgame.movevars.fog_settings & 0xFF000000) >> 24) / 255.0f;
@ -1210,6 +1210,8 @@ static int GL_RenderGetParm( int parm, int arg ) @@ -1210,6 +1210,8 @@ static int GL_RenderGetParm( int parm, int arg )
return tr.lightmapTextures[arg];
case PARM_SKY_SPHERE:
return FBitSet( world.flags, FWORLD_SKYSPHERE ) && !FBitSet( world.flags, FWORLD_CUSTOM_SKYBOX );
case PARAM_GAMEPAUSED:
return cl.paused;
case PARM_WIDESCREEN:
return glState.wideScreen;
case PARM_FULLSCREEN:

5
engine/client/gl_rmisc.c

@ -465,9 +465,12 @@ void R_NewMap( void ) @@ -465,9 +465,12 @@ void R_NewMap( void )
if( v_dark->value )
{
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 )
{
@ -475,7 +478,7 @@ void R_NewMap( void ) @@ -475,7 +478,7 @@ void R_NewMap( void )
sf->fadeEnd = title->holdtime + title->fadeout;
sf->fadeReset = title->fadeout;
}
else sf->fadeEnd = sf->fadeReset = 5.0f;
else sf->fadeEnd = sf->fadeReset = fadetime;
sf->fadeFlags = FFADE_IN;
sf->fader = sf->fadeg = sf->fadeb = 0;

25
engine/client/gl_rsurf.c

@ -1232,7 +1232,7 @@ void R_DrawTextureChains( void ) @@ -1232,7 +1232,7 @@ void R_DrawTextureChains( void )
if(( s->flags & SURF_DRAWTURB ) && clgame.movevars.wateralpha < 1.0f )
continue; // draw translucent water later
if( FBitSet( host.features, ENGINE_QUAKE_COMPATIBLE ) && FBitSet( s->flags, SURF_TRANSPARENT ))
if( Host_IsQuakeCompatible() && FBitSet( s->flags, SURF_TRANSPARENT ))
{
draw_alpha_surfaces = true;
continue; // draw transparent surfaces later
@ -1412,7 +1412,7 @@ void R_SetRenderMode( cl_entity_t *e ) @@ -1412,7 +1412,7 @@ void R_SetRenderMode( cl_entity_t *e )
case kRenderTransAlpha:
pglEnable( GL_ALPHA_TEST );
pglTexEnvf( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
if( FBitSet( host.features, ENGINE_QUAKE_COMPATIBLE ))
if( Host_IsQuakeCompatible( ))
{
pglBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
pglColor4f( 1.0f, 1.0f, 1.0f, tr.blend );
@ -1482,7 +1482,7 @@ void R_DrawBrushModel( cl_entity_t *e ) @@ -1482,7 +1482,7 @@ void R_DrawBrushModel( cl_entity_t *e )
if( rotated ) R_RotateForEntity( e );
else R_TranslateForEntity( e );
if( FBitSet( host.features, ENGINE_QUAKE_COMPATIBLE ) && FBitSet( clmodel->flags, MODEL_TRANSPARENT ))
if( Host_IsQuakeCompatible() && FBitSet( clmodel->flags, MODEL_TRANSPARENT ))
e->curstate.rendermode = kRenderTransAlpha;
e->visframe = tr.realframecount; // visible
@ -1515,7 +1515,7 @@ void R_DrawBrushModel( cl_entity_t *e ) @@ -1515,7 +1515,7 @@ void R_DrawBrushModel( cl_entity_t *e )
for( i = 0; i < clmodel->nummodelsurfaces; i++, psurf++ )
{
if( FBitSet( psurf->flags, SURF_DRAWTURB ) && !FBitSet( host.features, ENGINE_QUAKE_COMPATIBLE ))
if( FBitSet( psurf->flags, SURF_DRAWTURB ) && !Host_IsQuakeCompatible( ))
{
if( psurf->plane->type != PLANE_Z && !FBitSet( e->curstate.effects, EF_WATERSIDES ))
continue;
@ -1591,14 +1591,14 @@ void R_RecursiveWorldNode( mnode_t *node, uint clipflags ) @@ -1591,14 +1591,14 @@ void R_RecursiveWorldNode( mnode_t *node, uint clipflags )
mleaf_t *pleaf;
int c, side;
float dot;
loc0:
if( node->contents == CONTENTS_SOLID )
return; // hit a solid leaf
if( node->visframe != tr.visframecount )
return;
if( clipflags && !r_nocull->value )
if( clipflags && !CVAR_TO_BOOL( r_nocull ))
{
for( i = 0; i < 6; i++ )
{
@ -1667,7 +1667,8 @@ void R_RecursiveWorldNode( mnode_t *node, uint clipflags ) @@ -1667,7 +1667,8 @@ void R_RecursiveWorldNode( mnode_t *node, uint clipflags )
}
// recurse down the back side
R_RecursiveWorldNode( node->children[!side], clipflags );
node = node->children[!side];
goto loc0;
}
/*
@ -1864,6 +1865,8 @@ R_DrawWorld @@ -1864,6 +1865,8 @@ R_DrawWorld
*/
void R_DrawWorld( void )
{
double start, end;
// paranoia issues: when gl_renderer is "0" we need have something valid for currententity
// to prevent crashing until HeadShield drawing.
RI.currententity = clgame.entities;
@ -1884,10 +1887,15 @@ void R_DrawWorld( void ) @@ -1884,10 +1887,15 @@ void R_DrawWorld( void )
R_ClearSkyBox ();
start = Sys_DoubleTime();
if( RI.drawOrtho )
R_DrawWorldTopView( cl.worldmodel->nodes, RI.frustum.clipFlags );
else R_RecursiveWorldNode( cl.worldmodel->nodes, RI.frustum.clipFlags );
end = Sys_DoubleTime();
r_stats.t_world_node = end - start;
start = Sys_DoubleTime();
R_DrawTextureChains();
if( !CL_IsDevOverviewMode( ))
@ -1902,6 +1910,9 @@ void R_DrawWorld( void ) @@ -1902,6 +1910,9 @@ void R_DrawWorld( void )
R_DrawSkyBox();
}
end = Sys_DoubleTime();
r_stats.t_world_draw = end - start;
tr.num_draw_decals = 0;
skychain = NULL;

4
engine/client/gl_studio.c

@ -795,8 +795,8 @@ void R_StudioCalcBoneAdj( float dadt, float *adj, const byte *pcontroller1, cons @@ -795,8 +795,8 @@ void R_StudioCalcBoneAdj( float dadt, float *adj, const byte *pcontroller1, cons
{
if( abs( pcontroller1[i] - pcontroller2[i] ) > 128 )
{
int a = (pcontroller1[j] + 128) % 256;
int b = (pcontroller2[j] + 128) % 256;
int a = (pcontroller1[i] + 128) % 256;
int b = (pcontroller2[i] + 128) % 256;
value = (( a * dadt ) + ( b * ( 1.0f - dadt )) - 128) * (360.0f / 256.0f) + pbonecontroller[j].start;
}
else

20
engine/client/s_main.c

@ -1303,7 +1303,7 @@ int S_GetCurrentDynamicSounds( soundlist_t *pout, int size ) @@ -1303,7 +1303,7 @@ int S_GetCurrentDynamicSounds( soundlist_t *pout, int size )
looped = ( channels[i].use_loop && channels[i].sfx->cache->loopStart != -1 );
if( channels[i].entchannel == CHAN_STATIC && looped && !FBitSet( host.features, ENGINE_QUAKE_COMPATIBLE ))
if( channels[i].entchannel == CHAN_STATIC && looped && !Host_IsQuakeCompatible())
continue; // never serialize static looped sounds. It will be restoring in game code
if( channels[i].isSentence && channels[i].name[0] )
@ -2019,6 +2019,23 @@ void S_Play_f( void ) @@ -2019,6 +2019,23 @@ void S_Play_f( void )
S_StartLocalSound( Cmd_Argv( 1 ), VOL_NORM, false );
}
void S_Play2_f( void )
{
int i = 1;
if( Cmd_Argc() == 1 )
{
Con_Printf( S_USAGE "play <soundfile>\n" );
return;
}
while( i < Cmd_Argc( ))
{
S_StartLocalSound( Cmd_Argv( i ), VOL_NORM, true );
i++;
}
}
void S_PlayVol_f( void )
{
if( Cmd_Argc() == 1 )
@ -2187,6 +2204,7 @@ qboolean S_Init( void ) @@ -2187,6 +2204,7 @@ qboolean S_Init( void )
s_samplecount = Cvar_Get( "s_samplecount", "0", FCVAR_ARCHIVE, "sample count (0 for default value)" );
Cmd_AddCommand( "play", S_Play_f, "playing a specified sound file" );
Cmd_AddCommand( "play2", S_Play2_f, "playing a group of specified sound files" ); // nehahra stuff
Cmd_AddCommand( "playvol", S_PlayVol_f, "playing a specified sound file with specified volume" );
Cmd_AddCommand( "stopsound", S_StopSound_f, "stop all sounds" );
Cmd_AddCommand( "music", S_Music_f, "starting a background track" );

3
engine/client/vid_common.h

@ -2,6 +2,9 @@ @@ -2,6 +2,9 @@
#ifndef VID_COMMON
#define VID_COMMON
#define FCONTEXT_CORE_PROFILE BIT( 0 )
#define FCONTEXT_DEBUG_ARB BIT( 1 )
typedef struct vidmode_s
{
const char *desc;

2
engine/common/build.c

@ -48,7 +48,7 @@ int Q_buildnum( void ) @@ -48,7 +48,7 @@ int Q_buildnum( void )
return b;
#else
return 4143;
return 4150;
#endif
}

2
engine/common/common.h

@ -793,6 +793,7 @@ const char *Q_buildcommit( void ); @@ -793,6 +793,7 @@ const char *Q_buildcommit( void );
//
// host.c
//
qboolean Host_IsQuakeCompatible( void );
void EXPORT Host_Shutdown( void );
int Host_CompareFileTime( long ft1, long ft2 );
void Host_NewInstance( const char *name, const char *finalmsg );
@ -905,6 +906,7 @@ void pfnResetTutorMessageDecayData( void ); @@ -905,6 +906,7 @@ void pfnResetTutorMessageDecayData( void );
// con_utils.c
//
qboolean Cmd_AutocompleteName( const char *source, char *buffer, size_t bufsize );
void Con_CompleteCommand( field_t *field );
void Cmd_AutoComplete( char *complete_string );
void Cmd_AutoCompleteClear( void );

13
engine/common/filesystem.c

@ -2510,18 +2510,18 @@ dll_user_t *FS_FindLibrary( const char *dllname, qboolean directpath ) @@ -2510,18 +2510,18 @@ dll_user_t *FS_FindLibrary( const char *dllname, qboolean directpath )
COM_DefaultExtension( dllpath, "."OS_LIB_EXT ); // apply ext if forget
search = FS_FindFile( dllpath, &index, false );
if( !search )
if( !search && !directpath )
{
fs_ext_path = false;
if( directpath ) return NULL; // direct paths fails here
// trying check also 'bin' folder for indirect paths
Q_strncpy( dllpath, dllname, sizeof( dllpath ));
search = FS_FindFile( dllpath, &index, false );
if( !search ) return NULL; // unable to find
if( !search ) return NULL; // unable to find
}
// all done, create dll_user_t struct
// NOTE: for libraries we not fail even if search is NULL
// let the OS find library himself
hInst = Mem_Calloc( host.mempool, sizeof( dll_user_t ));
// save dllname for debug purposes
@ -2532,15 +2532,16 @@ dll_user_t *FS_FindLibrary( const char *dllname, qboolean directpath ) @@ -2532,15 +2532,16 @@ dll_user_t *FS_FindLibrary( const char *dllname, qboolean directpath )
hInst->encrypted = FS_CheckForCrypt( dllpath );
if( index < 0 && !hInst->encrypted )
if( index < 0 && !hInst->encrypted && search )
{
Q_snprintf( hInst->fullPath, sizeof( hInst->fullPath ), "%s%s", search->filename, dllpath );
hInst->custom_loader = false; // we can loading from disk and use normal debugging
}
else
{
// NOTE: if search is NULL let the OS found library himself
Q_strncpy( hInst->fullPath, dllpath, sizeof( hInst->fullPath ));
hInst->custom_loader = true; // loading from pack or wad - for release, debug don't working
hInst->custom_loader = (search) ? true : false;
}
fs_ext_path = false; // always reset direct paths

23
engine/common/host.c

@ -30,6 +30,8 @@ GNU General Public License for more details. @@ -30,6 +30,8 @@ GNU General Public License for more details.
#endif
#include <errno.h>
#include "common.h"
#include "base_cmd.h"
#include "client.h"
#include "netchan.h"
#include "protocol.h"
#include "mod_local.h"
@ -96,6 +98,27 @@ void Host_PrintEngineFeatures( void ) @@ -96,6 +98,27 @@ void Host_PrintEngineFeatures( void )
MsgDev( D_REPORT, "^3EXT:^7 Compensate quake bug enabled\n" );
}
/*
==============
Host_IsQuakeCompatible
==============
*/
qboolean Host_IsQuakeCompatible( void )
{
// feature set
if( FBitSet( host.features, ENGINE_QUAKE_COMPATIBLE ))
return true;
#ifndef XASH_DEDICATED
// quake demo playing
if( cls.demoplayback == DEMO_QUAKE1 )
return true;
#endif // XASH_DEDICATED
return false;
}
/*
================
Host_EndGame

8
engine/common/mod_bmodel.c

@ -1472,6 +1472,12 @@ static void Mod_LoadSubmodels( dbspmodel_t *bmod ) @@ -1472,6 +1472,12 @@ static void Mod_LoadSubmodels( dbspmodel_t *bmod )
{
for( j = 0; j < 3; j++ )
{
// reset empty bounds to prevent error
if( in->mins[j] == 999999.0f )
in->mins[j] = 0.0f;
if( in->maxs[j] == -999999.0f)
in->maxs[j] = 0.0f;
// spread the mins / maxs by a unit
out->mins[j] = in->mins[j] - 1.0f;
out->maxs[j] = in->maxs[j] + 1.0f;
@ -2194,7 +2200,7 @@ static void Mod_LoadSurfaces( dbspmodel_t *bmod ) @@ -2194,7 +2200,7 @@ static void Mod_LoadSurfaces( dbspmodel_t *bmod )
if(( tex->name[0] == '*' && Q_stricmp( tex->name, "*default" )) || tex->name[0] == '!' )
SetBits( out->flags, SURF_DRAWTURB|SURF_DRAWTILED );
if( !FBitSet( host.features, ENGINE_QUAKE_COMPATIBLE ))
if( !Host_IsQuakeCompatible( ))
{
if( !Q_strncmp( tex->name, "water", 5 ) || !Q_strnicmp( tex->name, "laser", 5 ))
SetBits( out->flags, SURF_DRAWTURB|SURF_DRAWTILED );

4
engine/common/net_buffer.c

@ -284,7 +284,7 @@ void MSG_WriteCoord( sizebuf_t *sb, float val ) @@ -284,7 +284,7 @@ void MSG_WriteCoord( sizebuf_t *sb, float val )
{
// g-cont. we loose precision here but keep old size of coord variable!
if( FBitSet( host.features, ENGINE_WRITE_LARGE_COORD ))
MSG_WriteShort( sb, (int)( val * 2.0f ));
MSG_WriteShort( sb, Q_rint( val ));
else MSG_WriteShort( sb, (int)( val * 8.0f ));
}
@ -598,7 +598,7 @@ float MSG_ReadCoord( sizebuf_t *sb ) @@ -598,7 +598,7 @@ float MSG_ReadCoord( sizebuf_t *sb )
{
// g-cont. we loose precision here but keep old size of coord variable!
if( FBitSet( host.features, ENGINE_WRITE_LARGE_COORD ))
return (float)(MSG_ReadShort( sb ) * ( 1.0f / 2.0f ));
return (float)(MSG_ReadShort( sb ));
return (float)(MSG_ReadShort( sb ) * ( 1.0f / 8.0f ));
}

30
engine/common/net_encode.c

@ -804,7 +804,7 @@ void Delta_Init( void ) @@ -804,7 +804,7 @@ void Delta_Init( void )
Delta_AddField( "movevars_t", "stepsize", DT_FLOAT|DT_SIGNED, 16, 16.0f, 1.0f );
Delta_AddField( "movevars_t", "maxvelocity", DT_FLOAT|DT_SIGNED, 16, 8.0f, 1.0f );
if( host.features & ENGINE_WRITE_LARGE_COORD )
if( FBitSet( host.features, ENGINE_WRITE_LARGE_COORD ))
Delta_AddField( "movevars_t", "zmax", DT_FLOAT|DT_SIGNED, 18, 1.0f, 1.0f );
else Delta_AddField( "movevars_t", "zmax", DT_FLOAT|DT_SIGNED, 16, 1.0f, 1.0f );
@ -1703,7 +1703,7 @@ If force is not set, then nothing at all will be generated if the entity is @@ -1703,7 +1703,7 @@ If force is not set, then nothing at all will be generated if the entity is
identical, under the assumption that the in-order delta code will catch it.
==================
*/
void MSG_WriteDeltaEntity( entity_state_t *from, entity_state_t *to, sizebuf_t *msg, qboolean force, qboolean player, float timebase, int baseline )
void MSG_WriteDeltaEntity( entity_state_t *from, entity_state_t *to, sizebuf_t *msg, qboolean force, int delta_type, float timebase, int baseline )
{
delta_info_t *dt = NULL;
delta_t *pField;
@ -1757,7 +1757,7 @@ void MSG_WriteDeltaEntity( entity_state_t *from, entity_state_t *to, sizebuf_t * @@ -1757,7 +1757,7 @@ void MSG_WriteDeltaEntity( entity_state_t *from, entity_state_t *to, sizebuf_t *
{
dt = Delta_FindStruct( "custom_entity_state_t" );
}
else if( player )
else if( delta_type == DELTA_PLAYER )
{
dt = Delta_FindStruct( "entity_state_player_t" );
}
@ -1771,8 +1771,17 @@ void MSG_WriteDeltaEntity( entity_state_t *from, entity_state_t *to, sizebuf_t * @@ -1771,8 +1771,17 @@ void MSG_WriteDeltaEntity( entity_state_t *from, entity_state_t *to, sizebuf_t *
pField = dt->pFields;
Assert( pField != NULL );
// activate fields and call custom encode func
Delta_CustomEncode( dt, from, to );
if( delta_type == DELTA_STATIC )
{
// static entities won't to be custom encoded
for( i = 0; i < dt->numFields; i++ )
dt->pFields[i].bInactive = false;
}
else
{
// activate fields and call custom encode func
Delta_CustomEncode( dt, from, to );
}
// process fields
for( i = 0; i < dt->numFields; i++, pField++ )
@ -1796,7 +1805,7 @@ If the delta removes the entity, entity_state_t->number will be set to MAX_EDICT @@ -1796,7 +1805,7 @@ If the delta removes the entity, entity_state_t->number will be set to MAX_EDICT
Can go from either a baseline or a previous packet_entity
==================
*/
qboolean MSG_ReadDeltaEntity( sizebuf_t *msg, entity_state_t *from, entity_state_t *to, int number, qboolean player, float timebase )
qboolean MSG_ReadDeltaEntity( sizebuf_t *msg, entity_state_t *from, entity_state_t *to, int number, int delta_type, float timebase )
{
#ifndef XASH_DEDICATED
delta_info_t *dt = NULL;
@ -1835,7 +1844,12 @@ qboolean MSG_ReadDeltaEntity( sizebuf_t *msg, entity_state_t *from, entity_state @@ -1835,7 +1844,12 @@ qboolean MSG_ReadDeltaEntity( sizebuf_t *msg, entity_state_t *from, entity_state
if( baseline_offset != 0 )
{
if( baseline_offset > 0 )
if( delta_type == DELTA_STATIC )
{
int backup = Q_max( 0, clgame.numStatics - abs( baseline_offset ));
from = &clgame.static_entities[backup].baseline;
}
else if( baseline_offset > 0 )
{
int backup = cls.next_client_entities - baseline_offset;
from = &cls.packet_entities[backup % cls.num_client_entities];
@ -1859,7 +1873,7 @@ qboolean MSG_ReadDeltaEntity( sizebuf_t *msg, entity_state_t *from, entity_state @@ -1859,7 +1873,7 @@ qboolean MSG_ReadDeltaEntity( sizebuf_t *msg, entity_state_t *from, entity_state
{
dt = Delta_FindStruct( "custom_entity_state_t" );
}
else if( player )
else if( delta_type == DELTA_PLAYER )
{
dt = Delta_FindStruct( "entity_state_player_t" );
}

16
engine/common/net_encode.h

@ -41,8 +41,16 @@ GNU General Public License for more details. @@ -41,8 +41,16 @@ GNU General Public License for more details.
enum
{
CUSTOM_NONE = 0,
CUSTOM_SERVER_ENCODE, // keyword "gamedll"
CUSTOM_CLIENT_ENCODE, // keyword "client"
CUSTOM_SERVER_ENCODE, // known as "gamedll"
CUSTOM_CLIENT_ENCODE, // known as "client"
};
// don't change order!
enum
{
DELTA_ENTITY = 0,
DELTA_PLAYER,
DELTA_STATIC,
};
// struct info (filled by engine)
@ -121,8 +129,8 @@ void MSG_WriteClientData( sizebuf_t *msg, clientdata_t *from, clientdata_t *to, @@ -121,8 +129,8 @@ void MSG_WriteClientData( sizebuf_t *msg, clientdata_t *from, clientdata_t *to,
void MSG_ReadClientData( sizebuf_t *msg, clientdata_t *from, clientdata_t *to, float timebase );
void MSG_WriteWeaponData( sizebuf_t *msg, weapon_data_t *from, weapon_data_t *to, float timebase, int index );
void MSG_ReadWeaponData( sizebuf_t *msg, weapon_data_t *from, weapon_data_t *to, float timebase );
void MSG_WriteDeltaEntity( entity_state_t *from, entity_state_t *to, sizebuf_t *msg, qboolean force, qboolean pl, float tbase, int bl );
qboolean MSG_ReadDeltaEntity( sizebuf_t *msg, entity_state_t *from, entity_state_t *to, int num, qboolean player, float timebase );
void MSG_WriteDeltaEntity( entity_state_t *from, entity_state_t *to, sizebuf_t *msg, qboolean force, int type, float tbase, int ofs );
qboolean MSG_ReadDeltaEntity( sizebuf_t *msg, entity_state_t *from, entity_state_t *to, int num, int type, float timebase );
int Delta_TestBaseline( entity_state_t *from, entity_state_t *to, qboolean player, float timebase );
#endif//NET_ENCODE_H

61
engine/common/protocol.h

@ -179,6 +179,67 @@ GNU General Public License for more details. @@ -179,6 +179,67 @@ GNU General Public License for more details.
#define FRAGMENT_MAX_SIZE 64000 // maximal fragment size
#define FRAGMENT_LOCAL_SIZE FRAGMENT_MAX_SIZE // local connection
// Quake1 Protocol
#define PROTOCOL_VERSION_QUAKE 15
// listed only unmatched ops
#define svc_updatestat 3 // [byte] [long] (svc_event)
#define svc_version 4 // [long] server version (svc_changing)
#define svc_updatename 13 // [byte] [string] (svc_updateuserinfo)
#define svc_updatefrags 14 // [byte] [short] (svc_deltatable)
#define svc_stopsound 16 // <see code> (svc_resource)
#define svc_updatecolors 17 // [byte] [byte] (svc_pings)
#define svc_damage 19 // (svc_restoresound)
#define svc_spawnbinary 21 // (svc_event_reliable)
#define svc_killedmonster 27
#define svc_foundsecret 28
#define svc_spawnstaticsound 29 // [coord3] [byte] samp [byte] vol [byte] aten
#define svc_sellscreen 33 // (svc_restore)
// Nehahra added
#define svc_showlmp 35 // [string] slotname [string] lmpfilename [coord] x [coord] y
#define svc_hidelmp 36 // [string] slotname
#define svc_skybox 37 // [string] skyname
#define svc_skyboxsize 50 // [coord] size (default is 4096)
#define svc_fog 51 // [byte] enable <optional past this point, only included if enable is true>
// [float] density [byte] red [byte] green [byte] blue
// if the high bit of the servercmd is set, the low bits are fast update flags:
#define U_MOREBITS (1<<0)
#define U_ORIGIN1 (1<<1)
#define U_ORIGIN2 (1<<2)
#define U_ORIGIN3 (1<<3)
#define U_ANGLE2 (1<<4)
#define U_NOLERP (1<<5) // don't interpolate movement
#define U_FRAME (1<<6)
#define U_SIGNAL (1<<7) // just differentiates from other updates
// svc_update can pass all of the fast update bits, plus more
#define U_ANGLE1 (1<<8)
#define U_ANGLE3 (1<<9)
#define U_MODEL (1<<10)
#define U_COLORMAP (1<<11)
#define U_SKIN (1<<12)
#define U_EFFECTS (1<<13)
#define U_LONGENTITY (1<<14)
#define U_TRANS (1<<15) // nehahra
// clientdata flags
#define SU_VIEWHEIGHT (1<<0)
#define SU_IDEALPITCH (1<<1)
#define SU_PUNCH1 (1<<2)
#define SU_PUNCH2 (1<<3)
#define SU_PUNCH3 (1<<4)
#define SU_VELOCITY1 (1<<5)
#define SU_VELOCITY2 (1<<6)
#define SU_VELOCITY3 (1<<7)
//define SU_AIMENT (1<<8) AVAILABLE BIT
#define SU_ITEMS (1<<9)
#define SU_ONGROUND (1<<10) // no data follows, the bit is it
#define SU_INWATER (1<<11) // no data follows, the bit is it
#define SU_WEAPONFRAME (1<<12)
#define SU_ARMOR (1<<13)
#define SU_WEAPON (1<<14)
extern const char *svc_strings[svc_lastmsg+1];
extern const char *clc_strings[clc_lastmsg+1];

8
engine/common/soundlib/snd_mp3.c

@ -58,7 +58,7 @@ qboolean Sound_LoadMPG( const char *name, const byte *buffer, size_t filesize ) @@ -58,7 +58,7 @@ qboolean Sound_LoadMPG( const char *name, const byte *buffer, size_t filesize )
size_t pos = 0;
size_t bytesWrite = 0;
char out[OUTBUF_SIZE];
size_t outsize;
size_t outsize, padsize;
int ret;
wavinfo_t sc;
@ -91,7 +91,8 @@ qboolean Sound_LoadMPG( const char *name, const byte *buffer, size_t filesize ) @@ -91,7 +91,8 @@ qboolean Sound_LoadMPG( const char *name, const byte *buffer, size_t filesize )
sound.width = 2; // always 16-bit PCM
sound.loopstart = -1;
sound.size = ( sound.channels * sound.rate * sound.width ) * ( sc.playtime / 1000 ); // in bytes
pos += FRAME_SIZE; // evaluate pos
padsize = sound.size % FRAME_SIZE;
pos += FRAME_SIZE; // evaluate pos
if( !sound.size )
{
@ -101,8 +102,9 @@ qboolean Sound_LoadMPG( const char *name, const byte *buffer, size_t filesize ) @@ -101,8 +102,9 @@ qboolean Sound_LoadMPG( const char *name, const byte *buffer, size_t filesize )
return false;
}
// add sentinel make sure we not overrun
sound.wav = (byte *)Mem_Calloc( host.soundpool, sound.size + padsize );
sound.type = WF_PCMDATA;
sound.wav = (byte *)Mem_Malloc( host.soundpool, sound.size );
// decompress mpg into pcm wav format
while( bytesWrite < sound.size )

16
engine/platform/sdl/vid_sdl.c

@ -24,6 +24,7 @@ GNU General Public License for more details. @@ -24,6 +24,7 @@ GNU General Public License for more details.
static vidmode_t *vidmodes = NULL;
static int num_vidmodes = 0;
static int context_flags = 0;
static dllfunc_t opengl_110funcs[] =
{
@ -737,13 +738,26 @@ static void GL_SetupAttributes( void ) @@ -737,13 +738,26 @@ static void GL_SetupAttributes( void )
SDL_GL_SetAttribute( SDL_GL_CONTEXT_MINOR_VERSION, 0 );
#endif
#elif !defined XASH_GL_STATIC
#else // GL1.x
#ifndef XASH_GL_STATIC
if( Sys_CheckParm( "-gldebug" ) )
{
MsgDev( D_NOTE, "Creating an extended GL context for debug...\n" );
SetBits( context_flags, FCONTEXT_DEBUG_ARB );
SDL_GL_SetAttribute( SDL_GL_CONTEXT_FLAGS, SDL_GL_CONTEXT_DEBUG_FLAG );
glw_state.extended = true;
}
#endif // XASH_GL_STATIC
if( Sys_CheckParm( "-glcore" ))
{
SetBits( context_flags, FCONTEXT_CORE_PROFILE );
SDL_GL_SetAttribute( SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE );
}
else
{
SDL_GL_SetAttribute( SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_COMPATIBILITY );
}
#endif // XASH_GLES
SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 );

25
engine/server/server.h

@ -113,24 +113,6 @@ typedef struct @@ -113,24 +113,6 @@ typedef struct
file_t *file;
} server_log_t;
// like as entity_state_t in Quake
typedef struct
{
char model[MAX_QPATH]; // name of static-entity model for right precache
vec3_t origin;
vec3_t angles;
short sequence;
short frame;
short colormap;
byte skin; // can't set contents! only real skin!
byte body;
float scale;
byte rendermode;
byte renderamt;
color24 rendercolor;
byte renderfx;
} sv_static_entity_t;
typedef struct server_s
{
sv_state_t state; // precache commands are only valid during load
@ -159,8 +141,6 @@ typedef struct server_s @@ -159,8 +141,6 @@ typedef struct server_s
char event_precache[MAX_EVENTS][MAX_QPATH];
byte model_precache_flags[MAX_MODELS];
model_t *models[MAX_MODELS];
sv_static_entity_t static_entities[MAX_STATIC_ENTITIES];
int num_static_entities;
// run local lightstyles to let SV_LightPoint grab the actual information
@ -386,6 +366,7 @@ typedef struct @@ -386,6 +366,7 @@ typedef struct
int next_client_entities; // next client_entity to use
entity_state_t *packet_entities; // [num_client_entities]
entity_state_t *baselines; // [GI->max_edicts]
entity_state_t *static_entities; // [MAX_STATIC_ENTITIES];
double last_heartbeat;
challenge_t challenges[MAX_CHALLENGES]; // to prevent invalid IPs from connecting
@ -575,6 +556,7 @@ void SV_RequestMissingResources( void ); @@ -575,6 +556,7 @@ void SV_RequestMissingResources( void );
// sv_frame.c
//
void SV_InactivateClients( void );
int SV_FindBestBaselineForStatic( int index, entity_state_t **baseline, entity_state_t *to );
void SV_WriteFrameToClient( sv_client_t *client, sizebuf_t *msg );
void SV_BuildClientFrame( sv_client_t *client );
void SV_SendMessagesToAll( void );
@ -611,8 +593,8 @@ const char *SV_GetString( string_t iString ); @@ -611,8 +593,8 @@ const char *SV_GetString( string_t iString );
sv_client_t *SV_ClientFromEdict( const edict_t *pEdict, qboolean spawned_only );
int SV_MapIsValid( const char *filename, const char *spawn_entity, const char *landmark_name );
void SV_StartSound( edict_t *ent, int chan, const char *sample, float vol, float attn, int flags, int pitch );
void SV_CreateStaticEntity( struct sizebuf_s *msg, sv_static_entity_t *ent );
edict_t *SV_FindGlobalEntity( string_t classname, string_t globalname );
qboolean SV_CreateStaticEntity( struct sizebuf_s *msg, int index );
void SV_SendUserReg( sizebuf_t *msg, sv_user_message_t *user );
edict_t* pfnPEntityOfEntIndex( int iEntIndex );
int pfnIndexOfEdict( const edict_t *pEdict );
@ -621,6 +603,7 @@ void SV_UpdateBaseVelocity( edict_t *ent ); @@ -621,6 +603,7 @@ void SV_UpdateBaseVelocity( edict_t *ent );
byte *pfnSetFatPVS( const float *org );
byte *pfnSetFatPAS( const float *org );
int pfnPrecacheModel( const char *s );
int pfnModelIndex( const char *m );
void pfnRemoveEntity( edict_t* e );
void SV_RestartAmbientSounds( void );
void SV_RestartDecals( void );

5
engine/server/sv_cmds.c

@ -75,7 +75,7 @@ void SV_BroadcastPrintf( sv_client_t *ignore, char *fmt, ... ) @@ -75,7 +75,7 @@ void SV_BroadcastPrintf( sv_client_t *ignore, char *fmt, ... )
if( Host_IsDedicated() )
{
// echo to console
Con_DPrintf( string );
Con_DPrintf( "%s", string );
}
}
@ -800,6 +800,7 @@ void SV_InitHostCommands( void ) @@ -800,6 +800,7 @@ void SV_InitHostCommands( void )
Cmd_AddCommand( "map_background", SV_MapBackground_f, "set background map" );
Cmd_AddCommand( "load", SV_Load_f, "load a saved game file" );
Cmd_AddCommand( "loadquick", SV_QuickLoad_f, "load a quick-saved game file" );
Cmd_AddCommand( "reload", SV_Reload_f, "continue from latest save or restart level" );
}
}
@ -818,7 +819,6 @@ void SV_InitOperatorCommands( void ) @@ -818,7 +819,6 @@ void SV_InitOperatorCommands( void )
Cmd_AddCommand( "clientinfo", SV_ClientInfo_f, "print user infostring (player num required)" );
Cmd_AddCommand( "playersonly", SV_PlayersOnly_f, "freezes time, except for players" );
Cmd_AddCommand( "restart", SV_Restart_f, "restarting current level" );
Cmd_AddCommand( "reload", SV_Reload_f, "continue from latest save or restart level" );
Cmd_AddCommand( "entpatch", SV_EntPatch_f, "write entity patch to allow external editing" );
Cmd_AddCommand( "edict_usage", SV_EdictUsage_f, "show info about edicts usage" );
Cmd_AddCommand( "entity_info", SV_EntityInfo_f, "show more info about edicts" );
@ -852,7 +852,6 @@ void SV_KillOperatorCommands( void ) @@ -852,7 +852,6 @@ void SV_KillOperatorCommands( void )
Cmd_RemoveCommand( "clientinfo" );
Cmd_RemoveCommand( "playersonly" );
Cmd_RemoveCommand( "restart" );
Cmd_RemoveCommand( "reload" );
Cmd_RemoveCommand( "entpatch" );
Cmd_RemoveCommand( "edict_usage" );
Cmd_RemoveCommand( "entity_info" );

44
engine/server/sv_frame.c

@ -172,6 +172,13 @@ Encode a client frame onto the network channel @@ -172,6 +172,13 @@ Encode a client frame onto the network channel
=============================================================================
*/
/*
=============
SV_FindBestBaseline
trying to deltas with previous entities
=============
*/
int SV_FindBestBaseline( sv_client_t *cl, int index, entity_state_t **baseline, entity_state_t *to, client_frame_t *frame, qboolean player )
{
int bestBitCount;
@ -205,6 +212,43 @@ int SV_FindBestBaseline( sv_client_t *cl, int index, entity_state_t **baseline, @@ -205,6 +212,43 @@ int SV_FindBestBaseline( sv_client_t *cl, int index, entity_state_t **baseline,
return index - bestfound;
}
/*
=============
SV_FindBestBaselineForStatic
trying to deltas with previous static entities
=============
*/
int SV_FindBestBaselineForStatic( int index, entity_state_t **baseline, entity_state_t *to )
{
int bestBitCount;
int i, bitCount;
int bestfound, j;
bestBitCount = j = Delta_TestBaseline( *baseline, to, false, sv.time );
bestfound = index;
// lookup backward for previous 64 states and try to interpret current delta as baseline
for( i = index - 1; bestBitCount > 0 && i >= 0 && ( index - i ) < ( MAX_CUSTOM_BASELINES - 1 ); i-- )
{
// don't worry about underflow in circular buffer
entity_state_t *test = &svs.static_entities[i];
bitCount = Delta_TestBaseline( test, to, false, sv.time );
if( bitCount < bestBitCount )
{
bestBitCount = bitCount;
bestfound = i;
}
}
// using delta from previous entity as baseline for current
if( index != bestfound )
*baseline = &svs.static_entities[bestfound];
return index - bestfound;
}
/*
=============
SV_EmitPacketEntities

112
engine/server/sv_game.c

@ -497,39 +497,47 @@ SV_CreateStaticEntity @@ -497,39 +497,47 @@ SV_CreateStaticEntity
NOTE: static entities only accepted when game is loading
=======================
*/
void SV_CreateStaticEntity( sizebuf_t *msg, sv_static_entity_t *ent )
qboolean SV_CreateStaticEntity( sizebuf_t *msg, int index )
{
int index;
entity_state_t nullstate, *baseline;
entity_state_t *state;
int offset;
if( index >= ( MAX_STATIC_ENTITIES - 1 ))
{
if( !sv.static_ents_overflow )
{
Con_Printf( S_WARN "MAX_STATIC_ENTITIES limit exceeded (%d)\n", MAX_STATIC_ENTITIES );
sv.static_ents_overflow = true;
}
sv.ignored_static_ents++; // continue overflowed entities
return false;
}
// this can happens if serialized map contain too many static entities...
if( MSG_GetNumBytesLeft( msg ) < 35 )
if( MSG_GetNumBytesLeft( msg ) < 50 )
{
sv.ignored_static_ents++;
return;
return false;
}
index = SV_ModelIndex( ent->model );
state = &svs.static_entities[index]; // allocate a new one
memset( &nullstate, 0, sizeof( nullstate ));
baseline = &nullstate;
// restore modelindex from modelname (already precached)
state->modelindex = pfnModelIndex( STRING( state->messagenum ));
state->entityType = ENTITY_NORMAL; // select delta-encode
state->number = 0;
// trying to compress with previous delta's
offset = SV_FindBestBaselineForStatic( index, &baseline, state );
MSG_BeginServerCmd( msg, svc_spawnstatic );
MSG_WriteShort( msg, index );
MSG_WriteWord( msg, ent->sequence );
MSG_WriteWord( msg, ent->frame );
MSG_WriteWord( msg, ent->colormap );
MSG_WriteByte( msg, ent->skin );
MSG_WriteByte( msg, ent->body );
MSG_WriteCoord( msg, ent->scale );
MSG_WriteVec3Coord( msg, ent->origin );
MSG_WriteVec3Angles( msg, ent->angles );
MSG_WriteByte( msg, ent->rendermode );
MSG_WriteDeltaEntity( baseline, state, msg, true, DELTA_STATIC, sv.time, offset );
if( ent->rendermode != kRenderNormal )
{
MSG_WriteByte( msg, ent->renderamt );
MSG_WriteByte( msg, ent->rendercolor.r );
MSG_WriteByte( msg, ent->rendercolor.g );
MSG_WriteByte( msg, ent->rendercolor.b );
MSG_WriteByte( msg, ent->renderfx );
}
return true;
}
/*
@ -541,18 +549,14 @@ Write all the static ents into demo @@ -541,18 +549,14 @@ Write all the static ents into demo
*/
void SV_RestartStaticEnts( void )
{
sv_static_entity_t *clent;
int i;
int i;
// remove all the static entities on the client
R_ClearStaticEntities();
// resend them again
for( i = 0; i < sv.num_static_entities; i++ )
{
clent = &sv.static_entities[i];
SV_CreateStaticEntity( &sv.reliable_datagram, clent );
}
SV_CreateStaticEntity( &sv.reliable_datagram, i );
}
/*
@ -1837,42 +1841,18 @@ move entity to client @@ -1837,42 +1841,18 @@ move entity to client
*/
static void pfnMakeStatic( edict_t *ent )
{
sv_static_entity_t *clent;
entity_state_t *state;
if( !SV_IsValidEdict( ent ))
return;
if( sv.num_static_entities >= MAX_STATIC_ENTITIES )
{
if( !sv.static_ents_overflow )
{
Con_Printf( S_WARN "MAX_STATIC_ENTITIES limit exceeded (%d)\n", MAX_STATIC_ENTITIES );
sv.static_ents_overflow = true;
}
sv.ignored_static_ents++; // continue overflowed entities
return;
}
clent = &sv.static_entities[sv.num_static_entities++];
Q_strncpy( clent->model, STRING( ent->v.model ), sizeof( clent->model ));
VectorCopy( ent->v.origin, clent->origin );
VectorCopy( ent->v.angles, clent->angles );
clent->sequence = ent->v.sequence;
clent->frame = ent->v.frame * 128;
clent->colormap = ent->v.colormap;
clent->skin = ent->v.skin;
clent->body = ent->v.body;
clent->scale = ent->v.scale;
clent->rendermode = ent->v.rendermode;
clent->renderamt = ent->v.renderamt;
clent->rendercolor.r = ent->v.rendercolor[0];
clent->rendercolor.g = ent->v.rendercolor[1];
clent->rendercolor.b = ent->v.rendercolor[2];
clent->renderfx = ent->v.renderfx;
// fill the entity state
state = &svs.static_entities[sv.num_static_entities]; // allocate a new one
svgame.dllFuncs.pfnCreateBaseline( false, NUM_FOR_EDICT( ent ), state, ent, 0, vec3_origin, vec3_origin );
state->messagenum = ent->v.model; // member modelname
SV_CreateStaticEntity( &sv.signon, clent );
if( SV_CreateStaticEntity( &sv.signon, sv.num_static_entities ))
sv.num_static_entities++;
// remove at end of the frame
SetBits( ent->v.flags, FL_KILLME );
@ -1988,31 +1968,31 @@ int SV_BuildSoundMsg( sizebuf_t *msg, edict_t *ent, int chan, const char *sample @@ -1988,31 +1968,31 @@ int SV_BuildSoundMsg( sizebuf_t *msg, edict_t *ent, int chan, const char *sample
if( vol < 0 || vol > 255 )
{
Con_Printf( S_ERROR "SV_StartSound: volume = %i\n", vol );
Con_Reportf( S_ERROR "SV_StartSound: volume = %i\n", vol );
vol = bound( 0, vol, 255 );
}
if( attn < 0.0f || attn > 4.0f )
{
Con_Printf( S_ERROR "SV_StartSound: attenuation %g must be in range 0-4\n", attn );
Con_Reportf( S_ERROR "SV_StartSound: attenuation %g must be in range 0-4\n", attn );
attn = bound( 0.0f, attn, 4.0f );
}
if( chan < 0 || chan > 7 )
{
Con_Printf( S_ERROR "SV_StartSound: channel must be in range 0-7\n" );
Con_Reportf( S_ERROR "SV_StartSound: channel must be in range 0-7\n" );
chan = bound( 0, chan, 7 );
}
if( pitch < 0 || pitch > 255 )
{
Con_Printf( S_ERROR "SV_StartSound: pitch = %i\n", pitch );
Con_Reportf( S_ERROR "SV_StartSound: pitch = %i\n", pitch );
pitch = bound( 0, pitch, 255 );
}
if( !COM_CheckString( sample ))
{
Con_Printf( S_ERROR "SV_StartSound: passed NULL sample\n" );
Con_Reportf( S_ERROR "SV_StartSound: passed NULL sample\n" );
return 0;
}
@ -4749,6 +4729,7 @@ void SV_UnloadProgs( void ) @@ -4749,6 +4729,7 @@ void SV_UnloadProgs( void )
Cvar_FullSet( "sv_background", "0", FCVAR_READ_ONLY );
// free entity baselines
Z_Free( svs.static_entities );
Z_Free( svs.baselines );
svs.baselines = NULL;
@ -4877,6 +4858,7 @@ qboolean SV_LoadProgs( const char *name ) @@ -4877,6 +4858,7 @@ qboolean SV_LoadProgs( const char *name )
svgame.globals->maxEntities = GI->max_edicts;
svgame.globals->maxClients = svs.maxclients;
svgame.edicts = Mem_Calloc( svgame.mempool, sizeof( edict_t ) * GI->max_edicts );
svs.static_entities = Z_Calloc( sizeof( entity_state_t ) * MAX_STATIC_ENTITIES );
svs.baselines = Z_Calloc( sizeof( entity_state_t ) * GI->max_edicts );
svgame.numEntities = svs.maxclients + 1; // clients + world

17
engine/server/sv_init.c

@ -379,7 +379,7 @@ void SV_CreateBaseline( void ) @@ -379,7 +379,7 @@ void SV_CreateBaseline( void )
{
entity_state_t nullstate, *base;
int playermodel;
qboolean player;
int delta_type;
int entnum;
if( FBitSet( host.features, ENGINE_QUAKE_COMPATIBLE ))
@ -397,13 +397,13 @@ void SV_CreateBaseline( void ) @@ -397,13 +397,13 @@ void SV_CreateBaseline( void )
if( entnum != 0 && entnum <= svs.maxclients )
{
player = true;
delta_type = DELTA_PLAYER;
}
else
{
if( !pEdict->v.modelindex )
continue; // invisible
player = false;
delta_type = DELTA_ENTITY;
}
// take current state as baseline
@ -416,7 +416,7 @@ void SV_CreateBaseline( void ) @@ -416,7 +416,7 @@ void SV_CreateBaseline( void )
base->entityType = ENTITY_BEAM;
else base->entityType = ENTITY_NORMAL;
svgame.dllFuncs.pfnCreateBaseline( player, entnum, base, pEdict, playermodel, host.player_mins[0], host.player_maxs[0] );
svgame.dllFuncs.pfnCreateBaseline( delta_type, entnum, base, pEdict, playermodel, host.player_mins[0], host.player_maxs[0] );
sv.last_valid_baseline = entnum;
}
@ -435,19 +435,19 @@ void SV_CreateBaseline( void ) @@ -435,19 +435,19 @@ void SV_CreateBaseline( void )
if( entnum != 0 && entnum <= svs.maxclients )
{
player = true;
delta_type = DELTA_PLAYER;
}
else
{
if( !pEdict->v.modelindex )
continue; // invisible
player = false;
delta_type = DELTA_ENTITY;
}
// take current state as baseline
base = &svs.baselines[entnum];
MSG_WriteDeltaEntity( &nullstate, base, &sv.signon, true, player, 1.0f, 0 );
MSG_WriteDeltaEntity( &nullstate, base, &sv.signon, true, delta_type, 1.0f, 0 );
}
MSG_WriteUBitLong( &sv.signon, LAST_EDICT, MAX_ENTITY_BITS ); // end of baselines
@ -456,7 +456,7 @@ void SV_CreateBaseline( void ) @@ -456,7 +456,7 @@ void SV_CreateBaseline( void )
for( entnum = 0; entnum < sv.num_instanced; entnum++ )
{
base = &sv.instanced[entnum].baseline;
MSG_WriteDeltaEntity( &nullstate, base, &sv.signon, true, false, 1.0f, 0 );
MSG_WriteDeltaEntity( &nullstate, base, &sv.signon, true, DELTA_ENTITY, 1.0f, 0 );
}
}
@ -785,6 +785,7 @@ qboolean SV_SpawnServer( const char *mapname, const char *startspot, qboolean ba @@ -785,6 +785,7 @@ qboolean SV_SpawnServer( const char *mapname, const char *startspot, qboolean ba
MSG_Init( &sv.spec_datagram, "Spectator Datagram", sv.spectator_buf, sizeof( sv.spectator_buf ));
// clearing all the baselines
memset( svs.static_entities, 0, sizeof( entity_state_t ) * MAX_STATIC_ENTITIES );
memset( svs.baselines, 0, sizeof( entity_state_t ) * GI->max_edicts );
// make cvars consistant

4
engine/server/sv_main.c

@ -158,7 +158,7 @@ void SV_UpdateMovevars( qboolean initialize ) @@ -158,7 +158,7 @@ void SV_UpdateMovevars( qboolean initialize )
if( sv_zmax.value < 256.0f ) Cvar_SetValue( "sv_zmax", 256.0f );
// clamp it right
if( host.features & ENGINE_WRITE_LARGE_COORD )
if( FBitSet( host.features, ENGINE_WRITE_LARGE_COORD ))
{
if( sv_zmax.value > 131070.0f )
Cvar_SetValue( "sv_zmax", 131070.0f );
@ -600,7 +600,7 @@ void Host_ServerFrame( void ) @@ -600,7 +600,7 @@ void Host_ServerFrame( void )
// if server is not active, do nothing
if( !svs.initialized ) return;
if( sv.simulating || sv.state != ss_active )
if( sv_fps.value != 0.0f && ( sv.simulating || sv.state != ss_active ))
sv.time_residual += host.frametime;
if( sv_fps.value == 0.0f )

67
engine/server/sv_save.c

@ -30,7 +30,7 @@ half-life implementation of saverestore system @@ -30,7 +30,7 @@ half-life implementation of saverestore system
#define SAVEFILE_HEADER (('V'<<24)+('L'<<16)+('A'<<8)+'V') // little-endian "VALV"
#define SAVEGAME_HEADER (('V'<<24)+('A'<<16)+('S'<<8)+'J') // little-endian "JSAV"
#define SAVEGAME_VERSION 0x0071 // Version 0.71 GoldSrc compatible
#define CLIENT_SAVEGAME_VERSION 0x0065 // Version 0.65
#define CLIENT_SAVEGAME_VERSION 0x0067 // Version 0.67
#define SAVE_HEAPSIZE 0x400000 // reserve 4Mb for now
#define SAVE_HASHSTRINGS 0xFFF // 4095 unique strings
@ -160,19 +160,40 @@ static TYPEDESCRIPTION gDecalEntry[] = @@ -160,19 +160,40 @@ static TYPEDESCRIPTION gDecalEntry[] =
static TYPEDESCRIPTION gStaticEntry[] =
{
DEFINE_ARRAY( sv_static_entity_t, model, FIELD_CHARACTER, 64 ),
DEFINE_FIELD( sv_static_entity_t, origin, FIELD_VECTOR ),
DEFINE_FIELD( sv_static_entity_t, angles, FIELD_VECTOR ),
DEFINE_FIELD( sv_static_entity_t, sequence, FIELD_SHORT ),
DEFINE_FIELD( sv_static_entity_t, frame, FIELD_SHORT ),
DEFINE_FIELD( sv_static_entity_t, colormap, FIELD_SHORT ),
DEFINE_FIELD( sv_static_entity_t, skin, FIELD_CHARACTER ),
DEFINE_FIELD( sv_static_entity_t, body, FIELD_CHARACTER ),
DEFINE_FIELD( sv_static_entity_t, scale, FIELD_FLOAT ),
DEFINE_FIELD( sv_static_entity_t, rendermode, FIELD_CHARACTER ),
DEFINE_FIELD( sv_static_entity_t, renderamt, FIELD_CHARACTER ),
DEFINE_ARRAY( sv_static_entity_t, rendercolor, FIELD_CHARACTER, sizeof( color24 )),
DEFINE_FIELD( sv_static_entity_t, renderfx, FIELD_CHARACTER ),
DEFINE_FIELD( entity_state_t, messagenum, FIELD_MODELNAME ), // HACKHACK: store model into messagenum
DEFINE_FIELD( entity_state_t, origin, FIELD_VECTOR ),
DEFINE_FIELD( entity_state_t, angles, FIELD_VECTOR ),
DEFINE_FIELD( entity_state_t, sequence, FIELD_INTEGER ),
DEFINE_FIELD( entity_state_t, frame, FIELD_FLOAT ),
DEFINE_FIELD( entity_state_t, colormap, FIELD_INTEGER ),
DEFINE_FIELD( entity_state_t, skin, FIELD_SHORT ),
DEFINE_FIELD( entity_state_t, body, FIELD_INTEGER ),
DEFINE_FIELD( entity_state_t, scale, FIELD_FLOAT ),
DEFINE_FIELD( entity_state_t, effects, FIELD_INTEGER ),
DEFINE_FIELD( entity_state_t, framerate, FIELD_FLOAT ),
DEFINE_FIELD( entity_state_t, mins, FIELD_VECTOR ),
DEFINE_FIELD( entity_state_t, maxs, FIELD_VECTOR ),
DEFINE_FIELD( entity_state_t, rendermode, FIELD_INTEGER ),
DEFINE_FIELD( entity_state_t, renderamt, FIELD_FLOAT ),
DEFINE_ARRAY( entity_state_t, rendercolor, FIELD_CHARACTER, sizeof( color24 )),
DEFINE_FIELD( entity_state_t, renderfx, FIELD_INTEGER ),
DEFINE_FIELD( entity_state_t, controller, FIELD_INTEGER ),
DEFINE_FIELD( entity_state_t, blending, FIELD_INTEGER ),
DEFINE_FIELD( entity_state_t, solid, FIELD_SHORT ),
DEFINE_FIELD( entity_state_t, animtime, FIELD_TIME ),
DEFINE_FIELD( entity_state_t, movetype, FIELD_INTEGER ),
DEFINE_FIELD( entity_state_t, vuser1, FIELD_VECTOR ),
DEFINE_FIELD( entity_state_t, vuser2, FIELD_VECTOR ),
DEFINE_FIELD( entity_state_t, vuser3, FIELD_VECTOR ),
DEFINE_FIELD( entity_state_t, vuser4, FIELD_VECTOR ),
DEFINE_FIELD( entity_state_t, iuser1, FIELD_INTEGER ),
DEFINE_FIELD( entity_state_t, iuser2, FIELD_INTEGER ),
DEFINE_FIELD( entity_state_t, iuser3, FIELD_INTEGER ),
DEFINE_FIELD( entity_state_t, iuser4, FIELD_INTEGER ),
DEFINE_FIELD( entity_state_t, fuser1, FIELD_FLOAT ),
DEFINE_FIELD( entity_state_t, fuser2, FIELD_FLOAT ),
DEFINE_FIELD( entity_state_t, fuser3, FIELD_FLOAT ),
DEFINE_FIELD( entity_state_t, fuser4, FIELD_FLOAT ),
};
static TYPEDESCRIPTION gSoundEntry[] =
@ -1147,7 +1168,7 @@ static void SaveClientState( SAVERESTOREDATA *pSaveData, const char *level, int @@ -1147,7 +1168,7 @@ static void SaveClientState( SAVERESTOREDATA *pSaveData, const char *level, int
// write client entities
for( i = 0; i < header.entityCount; i++ )
svgame.dllFuncs.pfnSaveWriteFields( pSaveData, "STATICENTITY", &sv.static_entities[i], gStaticEntry, ARRAYSIZE( gStaticEntry ));
svgame.dllFuncs.pfnSaveWriteFields( pSaveData, "STATICENTITY", &svs.static_entities[i], gStaticEntry, ARRAYSIZE( gStaticEntry ));
// write sounds
for( i = 0; i < header.soundCount; i++ )
@ -1190,7 +1211,6 @@ static void LoadClientState( SAVERESTOREDATA *pSaveData, const char *level, qboo @@ -1190,7 +1211,6 @@ static void LoadClientState( SAVERESTOREDATA *pSaveData, const char *level, qboo
int i, size, id, version;
sv_client_t *cl = svs.clients;
char name[MAX_QPATH];
sv_static_entity_t staticEntry;
soundlist_t soundEntry;
decallist_t decalEntry;
SAVE_CLIENT header;
@ -1250,22 +1270,19 @@ static void LoadClientState( SAVERESTOREDATA *pSaveData, const char *level, qboo @@ -1250,22 +1270,19 @@ static void LoadClientState( SAVERESTOREDATA *pSaveData, const char *level, qboo
// clear old entities
if( !adjacent )
{
memset( sv.static_entities, 0, sizeof( sv.static_entities ));
memset( svs.static_entities, 0, sizeof( entity_state_t ) * MAX_STATIC_ENTITIES );
sv.num_static_entities = 0;
}
// restore client entities
for( i = 0; i < header.entityCount; i++ )
{
svgame.dllFuncs.pfnSaveReadFields( pSaveData, "STATICENTITY", &staticEntry, gStaticEntry, ARRAYSIZE( gStaticEntry ));
id = sv.num_static_entities;
svgame.dllFuncs.pfnSaveReadFields( pSaveData, "STATICENTITY", &svs.static_entities[id], gStaticEntry, ARRAYSIZE( gStaticEntry ));
if( adjacent ) continue; // static entities won't loading from adjacent levels
if( i >= MAX_STATIC_ENTITIES )
continue; // silently overflowed
SV_CreateStaticEntity( &sv.signon, &staticEntry );
sv.static_entities[i] = staticEntry;
sv.num_static_entities++;
if( SV_CreateStaticEntity( &sv.signon, id ))
sv.num_static_entities++;
}
// restore sounds
@ -1560,7 +1577,7 @@ static int LoadGameState( char const *level, qboolean changelevel ) @@ -1560,7 +1577,7 @@ static int LoadGameState( char const *level, qboolean changelevel )
if( pent != NULL )
{
if( svgame.dllFuncs.pfnRestore( pent, pSaveData, false ) < 0 )
if( svgame.dllFuncs.pfnRestore( pent, pSaveData, 0 ) < 0 )
{
SetBits( pent->v.flags, FL_KILLME );
pTable->pent = NULL;

Loading…
Cancel
Save