04 Jul 2008

This commit is contained in:
g-cont 2008-07-04 00:00:00 +04:00 committed by Alibek Omarov
parent 388c9c67fb
commit a4d53368fd
36 changed files with 308 additions and 286 deletions

View File

@ -51,8 +51,8 @@ typedef struct
bool looping, holdAtEnd, dirty, silent;
file_t *iFile;
e_status status;
float startTime;
float lastTime;
dword startTime;
dword lastTime;
long tfps;
long RoQPlayed;
long ROQSize;
@ -945,7 +945,7 @@ static void RoQInterrupt( void )
// new frame is ready
redump:
switch(cinTable.roq_id)
switch( cinTable.roq_id )
{
case ROQ_QUAD_VQ:
if ((cinTable.numQuads&1))
@ -986,7 +986,7 @@ redump:
case ZA_SOUND_STEREO:
if (!cinTable.silent)
{
if (cinTable.numQuads == -1)
if( cinTable.numQuads == -1 )
{
//S_Update();
}
@ -1132,14 +1132,14 @@ Fetch and decompress the pending frame
e_status CIN_RunCinematic( void )
{
float start = 0;
float thisTime = 0;
dword thisTime = 0;
if(cinTable.status == FMV_EOF) return FMV_EOF;
if ( cls.state != ca_cinematic ) return cinTable.status;
thisTime = cls.realtime;
cinTable.tfps = ((((cls.realtime) - cinTable.startTime) * cinTable.roqFPS / 100) / 0.01);
cinTable.tfps = ((((cls.realtime) - cinTable.startTime) * 3)/100);
start = cinTable.startTime;
while((cinTable.tfps != cinTable.numQuads) && (cinTable.status == FMV_PLAY))
@ -1147,7 +1147,7 @@ e_status CIN_RunCinematic( void )
RoQInterrupt();
if (start != cinTable.startTime)
{
cinTable.tfps = ((((cls.realtime) - cinTable.startTime) * cinTable.roqFPS / 100)/0.01);
cinTable.tfps = ((((cls.realtime) - cinTable.startTime) * 3)/100);
start = cinTable.startTime;
}
}

View File

@ -140,13 +140,13 @@ SCR_TimeRefresh_f
void SCR_TimeRefresh_f( void )
{
int i;
float start, stop;
int start, stop;
float time;
if ( cls.state != ca_active )
return;
start = Sys_DoubleTime();
start = Sys_Milliseconds();
if( Cmd_Argc() == 2 )
{
@ -171,7 +171,7 @@ void SCR_TimeRefresh_f( void )
}
}
stop = Sys_DoubleTime();
time = stop - start;
stop = Sys_Milliseconds();
time = (stop - start) / 1000.0;
Msg( "%f seconds (%f fps)\n", time, 128 / time );
}

View File

@ -12,7 +12,7 @@ cvar_t *con_speed;
vec4_t console_color = {1.0, 1.0, 1.0, 1.0};
int g_console_field_width = 78;
#define NUM_CON_TIMES 5 // need for 4 lines
#define NUM_CON_TIMES 4 // need for 4 lines
#define CON_TEXTSIZE MAX_INPUTLINE * 8 // 128 kb buffer
#define DEFAULT_CONSOLE_WIDTH 78
@ -34,7 +34,7 @@ typedef struct
float finalFrac; // 0.0 to 1.0 lines of console to display
int vislines; // in scanlines
float times[NUM_CON_TIMES]; // cls.realtime time the line was generated for transparent notify lines
dword times[NUM_CON_TIMES]; // cls.realtime time the line was generated for transparent notify lines
vec4_t color;
} console_t;
@ -55,17 +55,16 @@ void Con_ToggleConsole_f (void)
Con_ClearNotify();
if (cls.key_dest == key_console)
if( cls.key_dest == key_console )
{
UI_HideMenu();
Cvar_SetValue("paused", 0 );
}
else
{
UI_HideMenu();
cls.key_dest = key_console;
if(Cvar_VariableValue ("maxclients") == 1 && Host_ServerState())
if(Cvar_VariableValue ("maxclients") == 1 && Host_ServerState())
Cvar_SetValue("paused", 1 );
}
}
@ -117,7 +116,7 @@ void Con_ClearNotify( void )
int i;
for( i = 0; i < NUM_CON_TIMES; i++ )
con.times[i] = 0.0f;
con.times[i] = 0;
}
@ -250,7 +249,7 @@ void Con_Linefeed( bool skipnotify )
// mark time for transparent overlay
if (con.current >= 0)
{
if( skipnotify ) con.times[con.current % NUM_CON_TIMES] = 0.0f;
if( skipnotify ) con.times[con.current % NUM_CON_TIMES] = 0;
else con.times[con.current % NUM_CON_TIMES] = cls.realtime;
}
@ -336,7 +335,7 @@ void Con_Print( const char *txt )
{
prev = con.current % NUM_CON_TIMES - 1;
if ( prev < 0 ) prev = NUM_CON_TIMES - 1;
con.times[prev] = 0.0f;
con.times[prev] = 0;
}
else con.times[con.current % NUM_CON_TIMES] = cls.realtime;
}
@ -382,7 +381,7 @@ void Con_DrawNotify( void )
int x, v = 0;
short *text;
int i;
float time;
int time;
int skip;
int currentColor;
@ -393,9 +392,9 @@ void Con_DrawNotify( void )
{
if( i < 0 ) continue;
time = con.times[i % NUM_CON_TIMES];
if( time == 0.0f ) continue;
if( time == 0 ) continue;
time = cls.realtime - time;
if( time > con_notifytime->value ) continue;
if( time > con_notifytime->value * 1000 ) continue;
text = con.text + (i % con.totallines) * con.linewidth;
for( x = 0; x < con.linewidth; x++)
@ -468,7 +467,7 @@ void Con_DrawSolidConsole (float frac)
// draw current time
re->SetColor(g_color_table[ColorIndex(COLOR_YELLOW)]);
com.snprintf( curtime, MAX_QPATH, "%s ", timestamp( TIME_TIME_ONLY));
i = strlen( curtime );
i = com.strlen( curtime );
for (x = 0; x < i; x++)
SCR_DrawSmallChar(scr_width->integer - ( i - x ) * SMALLCHAR_WIDTH, (lines - (SMALLCHAR_HEIGHT+SMALLCHAR_HEIGHT/2)), curtime[x]);
re->SetColor(NULL);
@ -628,6 +627,7 @@ void Con_Close( void )
Con_ClearNotify();
con.finalFrac = 0; // none visible
con.displayFrac = 0;
Cvar_SetValue( "paused", 0 );
}
bool Con_Active( void )

View File

@ -205,7 +205,7 @@ void CL_ReadDemoMessage( void )
return;
}
cl.time = cls.realtime;
//cl.time = cls.realtime;//CHECK VALID
buf.readcount = 0;
CL_ParseServerMessage( &buf );
}

View File

@ -279,7 +279,6 @@ void CL_ParsePlayerstate( sizebuf_t *msg, frame_t *oldframe, frame_t *newframe )
flags = MSG_ReadLong(msg);//four bytes
// parse the pmove_state_t
if (flags & PS_M_TYPE) state->pm_type = MSG_ReadByte (msg);
if (flags & PS_M_ORIGIN) MSG_ReadPos32(msg, state->origin );
if (flags & PS_M_VELOCITY) MSG_ReadPos32(msg, state->velocity );
if (flags & PS_M_TIME) state->pm_time = MSG_ReadByte (msg);
@ -386,7 +385,7 @@ void CL_ParseFrame( sizebuf_t *msg )
memset( &cl.frame, 0, sizeof(cl.frame));
cl.frame.serverframe = MSG_ReadLong (msg);
cl.frame.deltaframe = MSG_ReadLong (msg);
cl.frame.servertime = cl.frame.serverframe * host_frametime->value;
cl.frame.servertime = cl.frame.serverframe * 100;
cl.surpressCount = MSG_ReadByte (msg);
// If the frame is delta compressed from data that we
@ -422,8 +421,8 @@ void CL_ParseFrame( sizebuf_t *msg )
// clamp time
if( cl.time > cl.frame.servertime ) cl.time = cl.frame.servertime;
else if( cl.time < cl.frame.servertime - host_frametime->value )
cl.time = cl.frame.servertime - host_frametime->value;
else if( cl.time < cl.frame.servertime - 100 )
cl.time = cl.frame.servertime - 100;
// read areabits
len = MSG_ReadByte( msg );
@ -449,7 +448,7 @@ void CL_ParseFrame( sizebuf_t *msg )
cls.state = ca_active;
cl.force_refdef = true;
// getting a valid frame message ends the connection process
VectorCopy( cl.frame.playerstate.origin, cl.predicted_origin );
VectorScale( cl.frame.playerstate.origin, CL_COORD_FRAC, cl.predicted_origin );
VectorCopy( cl.frame.playerstate.viewangles, cl.predicted_angles );
}
CL_CheckPredictionError();
@ -626,6 +625,27 @@ void CL_CalcViewValues( void )
frame_t *oldframe;
player_state_t *ps, *ops;
// clamp time
if( cl.time > cl.frame.servertime )
{
if( cl_showclamp->value )
Msg ("high clamp %i\n", cl.time - cl.frame.servertime);
cl.time = cl.frame.servertime;
cl.lerpfrac = 1.0f;
}
else if (cl.time < cl.frame.servertime - 100 )
{
if (cl_showclamp->value)
Msg ("low clamp %i\n", cl.frame.servertime - host_frametime->value - cl.time);
cl.time = cl.frame.servertime - 100;
cl.lerpfrac = 0.0f;
}
else
{
cl.lerpfrac = 1.0 - (cl.frame.servertime - cl.time) * 0.01f;
//Msg("cl.lerpfrac %g\n", cl.lerpfrac );
}
// find the previous frame to interpolate from
ps = &cl.frame.playerstate;
i = (cl.frame.serverframe - 1) & UPDATE_MASK;
@ -644,7 +664,7 @@ void CL_CalcViewValues( void )
if((cl_predict->value) && !(cl.frame.playerstate.pm_flags & PMF_NO_PREDICTION))
{
// use predicted values
float delta;
int delta;
backlerp = 1.0 - lerp;
for( i = 0; i < 3; i++ )
@ -655,13 +675,12 @@ void CL_CalcViewValues( void )
// smooth out stair climbing
delta = cls.realtime - cl.predicted_step_time;
if( delta < host_frametime->value )
cl.refdef.vieworg[2] -= cl.predicted_step * (host_frametime->value - delta) * 0.01f;
if( delta < 100 ) cl.refdef.vieworg[2] -= cl.predicted_step * (100 - delta) * 0.01f;
}
else
{ // just use interpolated values
for( i = 0; i < 3; i++ )
cl.refdef.vieworg[i] = LerpView( ops->origin[i], ps->origin[i], ops->viewoffset[i], ps->viewoffset[i], lerp );
cl.refdef.vieworg[i] = LerpView( ops->origin[i] * CL_COORD_FRAC, ps->origin[i] * CL_COORD_FRAC, ops->viewoffset[i], ps->viewoffset[i], lerp );
}
// if not running a demo or on a locked frame, add the local angle movement
@ -704,22 +723,6 @@ void CL_AddEntities( void )
if( cls.state != ca_active )
return;
if( cl.time > cl.frame.servertime )
{
if( cl_showclamp->value )
Msg ("high clamp %i\n", cl.time - cl.frame.servertime);
cl.time = cl.frame.servertime;
cl.lerpfrac = 1.0;
}
else if (cl.time < cl.frame.servertime - host_frametime->value)
{
if (cl_showclamp->value)
Msg ("low clamp %i\n", cl.frame.servertime - host_frametime->value - cl.time);
cl.time = cl.frame.servertime - host_frametime->value;
cl.lerpfrac = 0;
}
else cl.lerpfrac = 1.0 - (cl.frame.servertime - cl.time) * host_frametime->value;
CL_CalcViewValues();
CL_AddPacketEntities( &cl.frame );
CL_AddParticles();

View File

@ -38,7 +38,7 @@ typedef struct
} clightstyle_t;
clightstyle_t cl_lightstyle[MAX_LIGHTSTYLES];
static float lastofs;
static int lastofs;
/*
================
@ -58,11 +58,11 @@ CL_RunLightStyles
*/
void CL_RunLightStyles (void)
{
float ofs;
int ofs;
clightstyle_t *ls;
int i;
ofs = cl.time * 10;
ofs = cl.time / 100;
if( ofs == lastofs ) return;
lastofs = ofs;
@ -74,7 +74,7 @@ void CL_RunLightStyles (void)
continue;
}
if( ls->length == 1 ) ls->value[0] = ls->value[1] = ls->value[2] = ls->map[0];
else ls->value[0] = ls->value[1] = ls->value[2] = ls->map[(int)fmod( ofs, ls->length)];
else ls->value[0] = ls->value[1] = ls->value[2] = ls->map[ofs%ls->length];
}
}
@ -335,7 +335,7 @@ void CL_TeleportSplash( vec3_t org )
p->next = active_particles;
active_particles = p;
p->time = cl.time + RANDOM_FLOAT( 0.02f, 0.2f );
p->time = cl.time + RANDOM_FLOAT( 200, 2000 );
p->color = 0xdb;
dir[0] = j * 8;

View File

@ -29,8 +29,6 @@ cvar_t *m_filter; // mouse sensetivity
cvar_t *m_mouse;
uint frame_msec;
uint old_sys_frame_time;
int mouse_buttons;
int mouse_oldbuttonstate;
POINT cur_pos, old_pos;
@ -376,7 +374,7 @@ void KeyDown (kbutton_t *b)
// save timestamp
c = Cmd_Argv(2);
b->downtime = atoi(c);
b->downtime = com.atoi(c);
if (!b->downtime) b->downtime = host.cl_timer - 100;
b->state |= 1 + 2; // down + impulse down
@ -410,7 +408,7 @@ void KeyUp (kbutton_t *b)
// save timestamp
c = Cmd_Argv(2);
uptime = atoi(c);
uptime = com.atoi(c);
if (uptime) b->msec += uptime - b->downtime;
else b->msec += 10;
@ -652,7 +650,7 @@ usercmd_t CL_CreateCmd (void)
{
usercmd_t cmd;
frame_msec = host.cl_timer - old_sys_frame_time;
frame_msec = host.cl_timer - host.old_cl_timer;
if (frame_msec < 1) frame_msec = 1;
if (frame_msec > 200) frame_msec = 200;
@ -662,7 +660,7 @@ usercmd_t CL_CreateCmd (void)
CL_FinishMove (&cmd);
old_sys_frame_time = host.cl_timer;
host.old_cl_timer = host.cl_timer;
//cmd.impulse = cls.framecount;
@ -756,6 +754,7 @@ void CL_SendCmd (void)
usercmd_t *cmd, *oldcmd;
usercmd_t nullcmd;
int checksumIndex;
int curtime;
// build a command even if not connected
@ -763,6 +762,7 @@ void CL_SendCmd (void)
i = cls.netchan.outgoing_sequence & (CMD_BACKUP-1);
cmd = &cl.cmds[i];
cl.cmd_time[i] = cls.realtime; // for netgraph ping calculation
curtime = Sys_Milliseconds();
*cmd = CL_CreateCmd ();
@ -781,7 +781,7 @@ void CL_SendCmd (void)
if( cls.state == ca_connected)
{
if (cls.netchan.message.cursize || host.realtime - cls.netchan.last_sent > 1.0f )
if (cls.netchan.message.cursize || curtime - cls.netchan.last_sent > 1000 )
Netchan_Transmit (&cls.netchan, 0, buf.data);
return;
}

View File

@ -347,7 +347,7 @@ void Field_VariableSizeDraw( field_t *edit, int x, int y, int width, int size, b
// draw the cursor
if(!showCursor ) return;
if((int)( cls.realtime * 4.0f ) & 1 ) return; // off blink
if((int)(cls.realtime >> 8) & 1) return; // off blink
if( key_overstrikeMode ) cursorChar = 11;
else cursorChar = 95;

View File

@ -232,7 +232,7 @@ void CL_CheckForResend (void)
// resend if we haven't gotten a reply yet
if(cls.demoplayback || cls.state != ca_connecting)
return;
if(cls.realtime - cls.connect_time < 3.0f) return;
if(cls.realtime - cls.connect_time < 3000) return;
if(!NET_StringToAdr (cls.servername, &adr))
{
@ -510,7 +510,7 @@ void CL_Reconnect_f (void)
if (cls.state >= ca_connected)
{
CL_Disconnect();
cls.connect_time = cls.realtime - 1.5f;
cls.connect_time = cls.realtime - 1500;
}
else cls.connect_time = MAX_HEARTBEAT; // fire immediately
@ -673,7 +673,7 @@ bool CL_ParseServerStatus( char *adr, char *info )
server->playerstr = copystring( va("%i/%i", server->numplayers, server->maxplayers ));
// add the ping
server->ping = (int)(cls.realtime - cls.pingtime) * 1000.0f;
server->ping = cls.realtime - cls.pingtime;
server->pingstring = copystring( va("%ims", server->ping ));
server->statusPacket = true;
@ -858,11 +858,9 @@ void CL_ReadPackets (void)
//
if( cls.state >= ca_connected && !cls.demoplayback )
{
if( cls.realtime - cls.netchan.last_received > cl_timeout->value)
if( cls.realtime - cls.netchan.last_received > cl_timeout->value * 1000 )
{
cl.timeoutcount++; // timeoutcount saves debugger
if( cl.timeoutcount > 5 )
if( ++cl.timeoutcount > 5 ) // timeoutcount saves debugger
{
Msg ("\nServer connection timed out.\n");
CL_Disconnect ();
@ -1159,7 +1157,7 @@ CL_InitLocal
void CL_InitLocal (void)
{
cls.state = ca_disconnected;
cls.realtime = 1.0f;
cls.realtime = Sys_Milliseconds();
CL_InitInput();
// register our variables
@ -1402,31 +1400,32 @@ CL_Frame
==================
*/
void CL_Frame( float time )
void CL_Frame( dword time )
{
static float extratime;
static float lasttimecalled;
static dword extratime;
if( dedicated->integer ) return;
extratime += time;
if (cls.state == ca_connected && extratime < 0.01f)
if( cls.state == ca_connected && extratime < 100 )
return; // don't flood packets out while connecting
if (extratime < 1.0f / cl_maxfps->value)
if( extratime < 1000 / cl_maxfps->value)
return; // framerate is too high
// let the mouse activate or deactivate
CL_UpdateMouse();
// decide the simulation time
cls.frametime = extratime;
cl.time += extratime;
cls.realtime = host.realtime;
cls.realtime = Sys_Milliseconds();
cls.frametime = extratime * 0.001;
extratime = 0;
if( cls.frametime > (1.0 / 5)) cls.frametime = (1.0 / 5);
// if in the debugger last frame, don't timeout
if (time > 5.0f) cls.netchan.last_received = host.realtime;
if( time > 5000 ) cls.netchan.last_received = Sys_Milliseconds();
// setup the VM frame
CL_VM_Begin();

View File

@ -12,9 +12,9 @@
#define UI_MAX_EDICTS (1 << 12) // should be enough for a menu
bool ui_active = false;
static float credits_start_time;
static float credits_fade_time;
static float credits_show_time;
static dword credits_start_time;
static dword credits_fade_time;
static dword credits_show_time;
static const char **credits;
static char *creditsIndex[2048];
static char *creditsBuffer;
@ -27,7 +27,7 @@ void UI_VM_Begin( void )
PRVM_SetProg(PRVM_MENUPROG);
// set time
if( prog ) *prog->time = cls.realtime;
if( prog ) *prog->time = cls.realtime * 0.001f;
}
void UI_KeyEvent( int key )
@ -37,6 +37,7 @@ void UI_KeyEvent( int key )
// setup args
PRVM_G_FLOAT(OFS_PARM0) = key;
prog->globals.ui->time = cls.realtime * 0.001f;
PRVM_G_INT(OFS_PARM1) = PRVM_SetEngineString(ascii);
PRVM_ExecuteProgram (prog->globals.ui->m_keydown, "QC function m_keydown is missing");
@ -49,7 +50,7 @@ void UI_Draw( void )
return;
UI_VM_Begin();
prog->globals.ui->time = cls.realtime * 0.001f;
PRVM_ExecuteProgram (prog->globals.ui->m_draw, "QC function m_draw is missing");
UI_DrawCredits(); // display game credits
@ -64,7 +65,7 @@ void UI_DrawCredits( void )
if( !credits_active ) return;
y = SCREEN_HEIGHT - (( cls.realtime - credits_start_time ) * 32.0f );
y = SCREEN_HEIGHT - (( cls.realtime - credits_start_time ) / 40.0f );
// draw the credits
for ( i = 0; i < credit_numlines && credits[i]; i++, y += 20 )
@ -76,7 +77,7 @@ void UI_DrawCredits( void )
if((y < (SCREEN_HEIGHT - BIGCHAR_HEIGHT) / 2) && i == credit_numlines - 1)
{
if(!credits_fade_time) credits_fade_time = cls.realtime;
color = CL_FadeColor( credits_fade_time, credits_show_time );
color = CL_FadeColor( credits_fade_time * 0.001f, credits_show_time * 0.001f );
if( color ) SCR_DrawStringExt( x, (SCREEN_HEIGHT - BIGCHAR_HEIGHT)/2, 16, 16, credits[i], color, true );
}
else SCR_DrawStringExt( x, y, 16, 16, credits[i], white_color, false );
@ -95,6 +96,7 @@ void UI_ShowMenu( void )
UI_VM_Begin();
ui_active = true;
prog->globals.ui->time = cls.realtime * 0.001f;
PRVM_ExecuteProgram (prog->globals.ui->m_show, "QC function m_toggle is missing");
CL_VM_Begin(); // restore clvm state
}
@ -102,11 +104,12 @@ void UI_ShowMenu( void )
void UI_HideMenu( void )
{
cls.key_dest = key_game;
Cvar_Set( "paused", "0" );
Key_ClearStates();
UI_VM_Begin();
ui_active = false;
prog->globals.ui->time = cls.realtime;
prog->globals.ui->time = cls.realtime * 0.001f;
PRVM_ExecuteProgram (prog->globals.ui->m_hide, "QC function m_toggle is missing");
CL_VM_Begin(); // restore clvm state
}
@ -549,8 +552,8 @@ void PF_runcredits( void )
// run credits
credits_start_time = cls.realtime;
credits_show_time = bound(0.1f, (float)com.strlen(credits[credit_numlines - 1]), 12.0f );
credits_fade_time = 0.0f;
credits_show_time = bound( 100, com.strlen(credits[credit_numlines - 1]) * 1000, 12000 );
credits_fade_time = 0;
credits_active = true;
}
@ -737,7 +740,7 @@ void UI_Init( void )
prog->error_cmd = VM_Error;
PRVM_LoadProgs( GI->uimenu_prog, 0, NULL, UI_NUM_REQFIELDS, ui_reqfields );
*prog->time = cls.realtime;
*prog->time = cls.realtime * 0.001f;
PRVM_ExecuteProgram (prog->globals.ui->m_init, "QC function m_init is missing");
PRVM_End;

View File

@ -56,7 +56,7 @@ void CL_CheckPredictionError (void)
VectorCopy (cl.frame.playerstate.origin, cl.predicted_origins[frame]);
// save for error itnerpolation
VectorCopy( delta, cl.prediction_error );
VectorScale( delta, CL_COORD_FRAC, cl.prediction_error );
}
}
@ -178,14 +178,14 @@ Sets cl.predicted_origin and cl.predicted_angles
*/
void CL_PredictMovement (void)
{
int ack, current;
int frame;
int oldframe;
usercmd_t *cmd;
int ack, current;
int frame;
int oldframe;
usercmd_t *cmd;
pmove_t pm;
int i;
int step;
int oldz;
int i;
float step;
float oldz;
if(cls.state != ca_active) return;
if(cl_paused->value) return;
@ -235,12 +235,16 @@ void CL_PredictMovement (void)
}
oldframe = (ack-2) & (CMD_BACKUP-1);
oldz = cl.predicted_origins[oldframe][2];
step = pm.ps.origin[2] - oldz;
if (step > 63 && step < 160 )//&& (pm.ps.pm_flags & PMF_ON_GROUND))
//if( pm.ps.pm_flags & PMF_ON_GROUND )//FIXME
{
cl.predicted_step = step;
cl.predicted_step_time = cls.realtime - cls.frametime * 0.5f;
oldz = cl.predicted_origins[oldframe][2];
step = pm.ps.origin[2] - oldz;
if( step > 4 && step < 24 )
{
cl.predicted_step = step * CL_COORD_FRAC;
cl.predicted_step_time = cls.realtime - cls.frametime * 500;
}
}
// copy results out for rendering

View File

@ -34,7 +34,7 @@ float *CL_FadeColor( float starttime, float endtime )
float time, fade_time;
if( starttime == 0 ) return NULL;
time = cls.realtime - starttime;
time = (cls.realtime * 0.001f) - starttime;
if( time >= endtime ) return NULL;
// fade time is 1/4 of endtime
@ -57,7 +57,7 @@ void CL_DrawHUD( void )
// setup pparms
prog->globals.cl->health = cl.frame.playerstate.stats[STAT_HEALTH];
prog->globals.cl->maxclients = com.atoi(cl.configstrings[CS_MAXCLIENTS]);
prog->globals.cl->realtime = cls.realtime;
prog->globals.cl->realtime = cls.realtime * 0.001f;
prog->globals.cl->paused = cl_paused->integer;
// setup args
@ -72,7 +72,7 @@ bool CL_ParseUserMessage( int svc_number )
// setup pparms
prog->globals.cl->health = cl.frame.playerstate.stats[STAT_HEALTH];
prog->globals.cl->maxclients = com.atoi(cl.configstrings[CS_MAXCLIENTS]);
prog->globals.cl->realtime = cls.realtime;
prog->globals.cl->realtime = cls.realtime * 0.001f;
prog->globals.cl->paused = cl_paused->integer;
// setup args
@ -136,7 +136,7 @@ void CL_InitEdict( edict_t *e )
void CL_FreeEdict( edict_t *ed )
{
ed->priv.cl->freetime = cl.time;
ed->priv.cl->freetime = cl.time * 0.001f;
ed->priv.cl->free = true;
ed->progs.cl->model = 0;
@ -185,7 +185,7 @@ void CL_VM_Begin( void )
PRVM_Begin;
PRVM_SetProg( PRVM_CLIENTPROG );
if( prog ) *prog->time = cl.time;
if( prog ) *prog->time = cl.time * 0.001f;
}
void CL_VM_End( void )
@ -343,10 +343,10 @@ void PF_drawcenterprint( void )
if(!VM_ValidateArgs( "DrawCenterPrint", 0 ))
return;
color = CL_FadeColor( cl.centerPrintTime, scr_centertime->value );
color = CL_FadeColor( cl.centerPrintTime * 0.001f, scr_centertime->value );
if( !color )
{
cl.centerPrintTime = 0.0f;
cl.centerPrintTime = 0;
return;
}
@ -619,7 +619,7 @@ void CL_InitClientProgs( void )
}
// init some globals
prog->globals.cl->realtime = cls.realtime;
prog->globals.cl->realtime = cls.realtime * 0.001f;
prog->globals.cl->pev = 0;
prog->globals.cl->mapname = PRVM_SetEngineString( cls.servername );
prog->globals.cl->playernum = cl.playernum;
@ -633,7 +633,7 @@ void CL_FreeClientProgs( void )
{
CL_VM_Begin();
prog->globals.cl->realtime = cls.realtime;
prog->globals.cl->realtime = cls.realtime * 0.001f;
prog->globals.cl->pev = 0;
PRVM_ExecuteProgram(prog->globals.cl->HUD_Shutdown, "QC function HUD_Shutdown is missing");
PRVM_ResetProg();

View File

@ -247,6 +247,26 @@ void SCR_DrawSmallStringExt( int x, int y, const char *string, float *setColor,
re->SetColor( NULL );
}
/*
=================
SCR_DrawDemoRecording
=================
*/
void SCR_DrawDemoRecording( void )
{
char string[1024];
fs_offset_t pos;
uint w;
if( !cls.demorecording ) return;
pos = FS_Tell( cls.demofile );
com.sprintf( string, "RECORDING %s: %ik", cls.demoname, pos / 1024 );
w = com.strlen( string );
SCR_DrawBigStringColor((SCREEN_WIDTH - w)/2, SCREEN_HEIGHT/4, string, g_color_table[7] );
}
/*
==================
SCR_UpdateScreen
@ -275,6 +295,7 @@ void SCR_UpdateScreen( void )
V_CalcRect();
V_RenderView();
CL_DrawHUD();
SCR_DrawDemoRecording();
break;
default:
Host_Error("SCR_UpdateScreen: bad cls.state" );

View File

@ -436,7 +436,7 @@ void V_RenderView( void )
cl.refdef.width = scr_vrect.width;
cl.refdef.height = scr_vrect.height;
cl.refdef.fov_y = V_CalcFov (cl.refdef.fov_x, cl.refdef.width, cl.refdef.height);
cl.refdef.time = cls.realtime; // render use realtime now
cl.refdef.time = cl.time * 0.001f; // render use realtime now
cl.refdef.areabits = cl.frame.areabits;

View File

@ -35,7 +35,7 @@ typedef struct
{
bool valid; // cleared if delta parsing was invalid
int serverframe;
float servertime; // server time the message is valid for (in msec)
int servertime; // server time the message is valid for (in msec)
int deltaframe;
byte areabits[MAX_MAP_AREAS/8]; // portalarea visibility bits
player_state_t playerstate;
@ -85,11 +85,11 @@ typedef struct
usercmd_t cmd;
usercmd_t cmds[CMD_BACKUP]; // each mesage will send several old cmds
float cmd_time[CMD_BACKUP]; // time sent, for calculating pings
short predicted_origins[CMD_BACKUP][3]; // for debug comparing against server
dword cmd_time[CMD_BACKUP]; // time sent, for calculating pings
float predicted_origins[CMD_BACKUP][3]; // for debug comparing against server
float predicted_step; // for stair up smoothing
float predicted_step_time;
uint predicted_step_time;
vec3_t predicted_origin; // generated by CL_PredictMovement
vec3_t predicted_angles;
@ -106,7 +106,7 @@ typedef struct
// and teleport direction changes
vec3_t viewangles;
float time; // this is the time value that the client
dword time; // this is the time value that the client
// is rendering at. always <= cls.realtime
float lerpfrac; // between oldframe and frame
@ -115,7 +115,7 @@ typedef struct
vec3_t v_forward, v_right, v_left, v_up; // set when refdef.angles is set
// centerprint stuff
float centerPrintTime;
int centerPrintTime;
int centerPrintCharWidth;
int centerPrintY;
char centerPrint[1024];
@ -198,7 +198,7 @@ typedef struct
keydest_t key_dest;
int framecount;
float realtime; // always increasing, no clamping, etc
dword realtime; // always increasing, no clamping, etc
float frametime; // seconds since last frame
// connection information
@ -229,7 +229,7 @@ typedef struct
file_t *demofile;
serverinfo_t serverlist[MAX_SERVERS]; // servers to join
int numservers;
float pingtime; // servers timebase
int pingtime; // servers timebase
} client_static_t;
extern client_static_t cls;

View File

@ -54,9 +54,7 @@ void Sys_SendKeyEvents( void )
{
// grab frame time
host.sv_timer = Sys_GetKeyEvents();
host.cl_timer = host.realtime * 1000;
host.realtime = Sys_DoubleTime();
host.cl_timer = Sys_Milliseconds();
}
/*
@ -1282,7 +1280,7 @@ void VM_drawmodel( void )
refdef.height = size[1];
refdef.fov_x = 50;
refdef.fov_y = V_CalcFov( refdef.fov_x, refdef.width, refdef.height );
refdef.time = cls.realtime;
refdef.time = cls.realtime * 0.001f;
entity.model = re->RegisterModel( (char *)modname );
entity.flags = RF_FULLBRIGHT;

View File

@ -169,10 +169,9 @@ typedef struct host_parm_s
string finalmsg; // server shutdown final message
dword framecount; // global framecount
double realtime; // host realtime
float frametime; // frametime (default 0.1)
uint sv_timer; // SV_Input msg time
uint cl_timer; // CL_Input msg time
uint old_cl_timer; // save old msg time
HWND hWnd; // main window
@ -188,6 +187,7 @@ void Host_Main ( void );
void Host_Free ( void );
void Host_SetServerState( int state );
int Host_ServerState( void );
float Host_FrameTime( void );
void Host_AbortCurrentFrame( void );
// message functions
@ -210,11 +210,11 @@ CLIENT / SERVER SYSTEMS
*/
void CL_Init( void );
void CL_Shutdown( void );
void CL_Frame( float time );
void CL_Frame( dword time );
void SV_Init( void );
void SV_Shutdown( bool reconnect );
void SV_Frame( float time );
void SV_Frame( dword time );
/*
==============================================================
@ -409,7 +409,7 @@ void Sys_Error( const char *msg, ... );
void Sys_SendKeyEvents( void );
#define MAX_ENTNUMBER 99999 // for server and client parsing
#define MAX_HEARTBEAT -99999.0f // connection time
#define MAX_HEARTBEAT -99999 // connection time
// get rid of this

View File

@ -232,6 +232,16 @@ void Host_AbortCurrentFrame( void )
longjmp( host.abortframe, 1 );
}
/*
==================
Host_GetFrameTime
==================
*/
float Host_FrameTime( void )
{
return Cvar_VariableValue( "host_frametime" );
}
/*
==================
Host_GetServerState
@ -239,7 +249,7 @@ Host_GetServerState
*/
int Host_ServerState( void )
{
return host_serverstate->integer;
return (int)Cvar_VariableValue( "host_serverstate" );
}
/*
@ -307,14 +317,13 @@ void VID_Init( void )
Host_Frame
=================
*/
void Host_Frame( double time )
void Host_Frame( dword time )
{
char *s;
if(setjmp(host.abortframe)) return;
rand(); // keep the random time dependent
Sys_SendKeyEvents(); // get new key events
do
@ -568,7 +577,7 @@ void Host_Init (uint funcname, int argc, char **argv)
}
cm_paused = Cvar_Get("cm_paused", "0", 0, "physics module pause" );
host_frametime = Cvar_Get ("host_frametime", "0.01", 0, "host frametime" );
host_frametime = Cvar_Get ("host_frametime", "0.1", 0, "host frametime" );
host_serverstate = Cvar_Get ("host_serverstate", "0", 0, "displays current server state" );
timescale = Cvar_Get ("timescale", "1", 0, "physics world timescale" );
if(host.type == HOST_DEDICATED) dedicated = Cvar_Get ("dedicated", "1", CVAR_INIT, "currently server is in dedicated mode" );
@ -586,7 +595,6 @@ void Host_Init (uint funcname, int argc, char **argv)
SV_Init();
CL_Init();
Sys_DoubleTime(); // initialize timer
}
/*
@ -596,19 +604,22 @@ Host_Main
*/
void Host_Main( void )
{
static double time, oldtime, newtime;
static dword time, oldtime, newtime;
oldtime = host.realtime;
oldtime = Sys_Milliseconds(); // initialize timer
// main window message loop
while( host.type != HOST_OFFLINE )
{
oldtime = newtime;
newtime = Sys_DoubleTime();
time = newtime - oldtime;
do
{
newtime = Sys_Milliseconds();
time = newtime - oldtime;
} while( time < 1 );
// engine frame
Host_Frame( time );
oldtime = newtime;
}
}

View File

@ -157,7 +157,7 @@ void Netchan_Setup (netsrc_t sock, netchan_t *chan, netadr_t adr, int qport)
chan->sock = sock;
chan->remote_address = adr;
chan->qport = qport;
chan->last_received = host.realtime;
chan->last_received = Sys_Milliseconds();
chan->incoming_sequence = 0;
chan->outgoing_sequence = 1;
@ -243,7 +243,7 @@ void Netchan_Transmit (netchan_t *chan, int length, byte *data)
w2 = ( chan->incoming_sequence & ~(1<<31) ) | (chan->incoming_reliable_sequence<<31);
chan->outgoing_sequence++;
chan->last_sent = host.realtime;
chan->last_sent = Sys_Milliseconds();
MSG_WriteLong (&send, w1);
MSG_WriteLong (&send, w2);
@ -369,8 +369,7 @@ bool Netchan_Process (netchan_t *chan, sizebuf_t *msg)
}
// the message can now be read from the current message pointer
chan->last_received = host.realtime;
chan->last_received = Sys_Milliseconds();
return true;
}

View File

@ -102,7 +102,7 @@ void _MSG_WriteUnterminatedString (sizebuf_t *sb, const char *s, const char *fil
void _MSG_WriteCoord16(sizebuf_t *sb, float f, const char *filename, int fileline)
{
_MSG_WriteShort(sb, (int)(f * 8.0f), filename, fileline );
_MSG_WriteShort(sb, (int)(f * SV_COORD_FRAC), filename, fileline );
}
void _MSG_WriteAngle16 (sizebuf_t *sb, float f, const char *filename, int fileline)
@ -439,7 +439,7 @@ char *MSG_ReadStringLine (sizebuf_t *msg_read)
float MSG_ReadCoord16(sizebuf_t *msg_read)
{
return MSG_ReadShort(msg_read) * 0.125f;
return MSG_ReadShort(msg_read) * CL_COORD_FRAC;
}
float MSG_ReadCoord32(sizebuf_t *msg_read)
@ -454,7 +454,7 @@ void MSG_ReadPos32(sizebuf_t *msg_read, vec3_t pos)
pos[2] = MSG_ReadFloat(msg_read);
}
void MSG_ReadPos16(sizebuf_t *msg_read, vec3_t pos)
void MSG_ReadPos16( sizebuf_t *msg_read, vec3_t pos )
{
pos[0] = MSG_ReadCoord16(msg_read);
pos[1] = MSG_ReadCoord16(msg_read);

View File

@ -338,8 +338,8 @@ typedef struct netchan_s
int dropped; // between last packet and previous
float last_received; // for timeouts
float last_sent; // for retransmits
int last_received; // for timeouts
int last_sent; // for retransmits
netadr_t remote_address;
int qport; // qport value to write when transmitting

View File

@ -64,15 +64,15 @@ typedef enum
} cl_state_t;
typedef struct
typedef struct server_s
{
sv_state_t state; // precache commands are only valid during load
bool loadgame; // client begins should reuse existing entity
float time; // always sv.framenum * 100 msec
int framenum;
float time; // always sv.framenum * 50 msec
float frametime;
int framenum;
char name[MAX_QPATH]; // map name, or cinematic name
cmodel_t *models[MAX_MODELS];
@ -85,7 +85,7 @@ typedef struct
sizebuf_t multicast;
byte multicast_buf[MAX_MSGLEN];
float lastchecktime;
int lastchecktime;
int lastcheck;
bool autosaved;
@ -98,7 +98,7 @@ typedef struct
player_state_t ps;
int num_entities;
int first_entity; // into the circular sv_packet_entities[]
float senttime; // for ping calculations
int senttime; // for ping calculations
} client_frame_t;
@ -136,8 +136,8 @@ typedef struct client_state_s
int downloadsize; // total bytes (can't use EOF because of paks)
int downloadcount; // bytes sent
float lastmessage; // sv.framenum when packet was last received
float lastconnect;
int lastmessage; // sv.framenum when packet was last received
int lastconnect;
int challenge; // challenge of this user, randomly generated
@ -163,14 +163,14 @@ typedef struct
{
netadr_t adr;
int challenge;
float time;
int time;
} challenge_t;
typedef struct
{
bool initialized; // sv_init has completed
float realtime; // always increasing, no clamping, etc
dword realtime; // always increasing, no clamping, etc
char mapcmd[MAX_TOKEN_CHARS]; // ie: *intro.cin+base
char comment[MAX_TOKEN_CHARS]; // map name, e.t.c.
@ -183,7 +183,7 @@ typedef struct
int next_client_entities; // next client_entity to use
entity_state_t *client_entities; // [num_client_entities]
float last_heartbeat;
int last_heartbeat;
challenge_t challenges[MAX_CHALLENGES]; // to prevent invalid IPs from connecting
} server_static_t;
@ -204,10 +204,10 @@ extern cvar_t *sv_noreload; // don't reload level state when reentering
extern cvar_t *sv_airaccelerate; // don't reload level state when reentering
extern cvar_t *sv_maxvelocity;
extern cvar_t *sv_gravity;
// development tool
extern cvar_t *sv_fps; // running server at
extern cvar_t *sv_enforcetime;
extern client_state_t *sv_client;
extern client_state_t *sv_client;
extern edict_t *sv_player;

View File

@ -371,7 +371,7 @@ void SV_Status_f( void )
Msg("%s", cl->name );
l = 16 - com.strlen(cl->name);
for (j = 0; j < l; j++) Msg (" ");
Msg ("%.5f ", svs.realtime - cl->lastmessage );
Msg ("%7i ", svs.realtime - cl->lastmessage );
s = NET_AdrToString ( cl->netchan.remote_address);
Msg ("%s", s);
l = 22 - strlen(s);

View File

@ -201,7 +201,6 @@ void SV_WritePlayerstateToClient (client_frame_t *from, client_frame_t *to, size
// write the pmove_state_t
if (pflags & PS_M_TYPE) MSG_WriteByte (msg, ps->pm_type);
if (pflags & PS_M_ORIGIN) MSG_WritePos32(msg, ps->origin);
if (pflags & PS_M_VELOCITY) MSG_WritePos32(msg, ps->velocity);
if (pflags & PS_M_TIME) MSG_WriteByte (msg, ps->pm_time);
@ -385,7 +384,7 @@ void SV_BuildClientFrame( client_state_t *client )
frame->senttime = svs.realtime; // save it for ping calc later
// find the client's PVS
VectorCopy( clent->priv.sv->client->ps.origin, org );
VectorScale( clent->priv.sv->client->ps.origin, CL_COORD_FRAC, org );
VectorAdd( org, clent->priv.sv->client->ps.viewoffset, org );
leafnum = pe->PointLeafnum (org);

View File

@ -11,6 +11,7 @@ netadr_t master_adr[MAX_MASTERS]; // address of group servers
client_state_t *sv_client; // current client
cvar_t *sv_paused;
cvar_t *sv_fps;
cvar_t *sv_enforcetime;
cvar_t *timeout; // seconds without any message
@ -31,8 +32,6 @@ cvar_t *sv_gravity;
cvar_t *sv_noreload; // don't reload level state when reentering
cvar_t *maxclients; // FIXME: rename sv_maxclients
cvar_t *sv_showclamp;
cvar_t *hostname;
cvar_t *public_server; // should heartbeats be sent
@ -231,10 +230,12 @@ void SVC_GetChallenge (void)
{
int i;
int oldest;
float oldestTime;
int oldestTime;
int curtime;
oldest = 0;
oldestTime = 2147483647.0f;
oldestTime = 0x7fffffff;
curtime = Sys_Milliseconds();
// see if we already have a challenge for this ip
for (i = 0 ; i < MAX_CHALLENGES ; i++)
@ -253,7 +254,7 @@ void SVC_GetChallenge (void)
// overwrite the oldest
svs.challenges[oldest].challenge = rand() & 0x7fff;
svs.challenges[oldest].adr = net_from;
svs.challenges[oldest].time = svs.realtime;
svs.challenges[oldest].time = curtime;
i = oldest;
}
@ -342,7 +343,7 @@ void SVC_DirectConnect( void )
if (cl->state == cs_free) continue;
if (NET_CompareBaseAdr (adr, cl->netchan.remote_address) && ( cl->netchan.qport == qport || adr.port == cl->netchan.remote_address.port))
{
if (!NET_IsLocalAddress (adr) && (svs.realtime - cl->lastconnect) < sv_reconnect_limit->value)
if (!NET_IsLocalAddress (adr) && (svs.realtime - cl->lastconnect) < sv_reconnect_limit->value * 1000 )
{
MsgDev( D_ERROR, "SVC_DirectConnect: %s:reconnect rejected : too soon\n", NET_AdrToString (adr));
return;
@ -619,7 +620,7 @@ void SV_ReadPackets (void)
}
break;
}
if (i != maxclients->value) continue;
if( i != maxclients->integer ) continue;
}
}
@ -643,8 +644,8 @@ void SV_CheckTimeouts (void)
float droppoint;
float zombiepoint;
droppoint = svs.realtime - timeout->value;
zombiepoint = svs.realtime - zombietime->value;
droppoint = svs.realtime - 1000 * timeout->value;
zombiepoint = svs.realtime - 1000 * zombietime->value;
for (i=0,cl=svs.clients ; i<maxclients->value ; i++,cl++)
{
@ -674,31 +675,27 @@ SV_RunGameFrame
*/
void SV_RunGameFrame (void)
{
if( sv_paused->integer && maxclients->integer == 1 )
return;
// we always need to bump framenum, even if we
// don't run the world, otherwise the delta
// compression can get confused when a client
// has the "current" frame
sv.framenum++;
sv.frametime = host_frametime->value; // 100 fps as default
sv.frametime = 0.1f;//const
sv.time = sv.framenum * sv.frametime;
// don't run if paused
if (!sv_paused->value || maxclients->value > 1)
if(!cm_paused->value)
pe->Frame( sv.frametime );//FIXME
SV_RunFrame ();
// never get more than one tic behind
if( sv.time * 1000 < svs.realtime )
{
if(!cm_paused->value)
pe->Frame( 0.1 );//FIXME
SV_RunFrame ();
// never get more than one tic behind
if (sv.time < svs.realtime)
{
if (sv_showclamp->value)
Msg ("sv highclamp\n");
svs.realtime = sv.time;
}
Msg ("sv highclamp\n");
svs.realtime = sv.time * 1000;
}
sv.time += sv.frametime;
}
/*
@ -707,11 +704,10 @@ SV_Frame
==================
*/
void SV_Frame (float time)
void SV_Frame( dword time )
{
// if server is not active, do nothing
if (!svs.initialized)
return;
if( !svs.initialized ) return;
svs.realtime += time;
@ -728,19 +724,17 @@ void SV_Frame (float time)
SV_ReadPackets ();
// move autonomous things around if enough time has passed
if( svs.realtime < sv.time )
if( svs.realtime < sv.time * 1000 )
{
// never let the time get too far off
if (sv.time - svs.realtime > sv.frametime)
if((sv.time * 1000) - svs.realtime > 100 )
{
if (sv_showclamp->value)
Msg ("sv lowclamp\n");
svs.realtime = sv.time - sv.frametime;
Msg ("sv lowclamp\n");
svs.realtime = (sv.time * 1000 ) - 100;
}
NET_Sleep((sv.time - svs.realtime) * 1000);
NET_Sleep( ( sv.time * 1000 )- svs.realtime );
SV_VM_End(); //end frame
return;
}
@ -790,7 +784,7 @@ void Master_Heartbeat (void)
// check for time wraparound
if (svs.last_heartbeat > svs.realtime) svs.last_heartbeat = svs.realtime;
if (svs.realtime - svs.last_heartbeat < HEARTBEAT_SECONDS)
if( svs.realtime - svs.last_heartbeat < HEARTBEAT_SECONDS * 1000 )
return; // not time to send yet
svs.last_heartbeat = svs.realtime;
@ -913,11 +907,12 @@ void SV_Init (void)
Cvar_Get ("fraglimit", "0", CVAR_SERVERINFO, "multiplayer fraglimit" );
Cvar_Get ("timelimit", "0", CVAR_SERVERINFO, "multiplayer timelimit" );
Cvar_Get ("protocol", va("%i", PROTOCOL_VERSION), CVAR_SERVERINFO|CVAR_INIT, "displays server protocol version" );
sv_fps = Cvar_Get( "sv_fps", "60", CVAR_ARCHIVE|CVAR_LATCH, "running server at" );
maxclients = Cvar_Get ("maxclients", "1", CVAR_SERVERINFO | CVAR_LATCH, "max count of clients for current game" );
hostname = Cvar_Get ("hostname", "unnamed", CVAR_SERVERINFO | CVAR_ARCHIVE, "host name" );
timeout = Cvar_Get ("timeout", "125", 0, "connection timeout" );
zombietime = Cvar_Get ("zombietime", "2", 0, "timeout for clients-zombie (who died but not respawned)" );
sv_showclamp = Cvar_Get ("showclamp", "0", 0, "show server clamping messages" );
sv_paused = Cvar_Get ("paused", "0", 0, "server pause" );
sv_enforcetime = Cvar_Get ("sv_enforcetime", "0", 0, "client enforce time" );
allow_download = Cvar_Get ("allow_download", "1", CVAR_ARCHIVE, "allow download resources" );

View File

@ -18,9 +18,9 @@ be accurate for client side prediction
*/
void SV_ClampCoord( vec3_t coord )
{
coord[0] -= floor(coord[0]);
coord[1] -= floor(coord[1]);
coord[2] -= floor(coord[2]);
coord[0] -= SV_COORD_FRAC * floor(coord[0] * CL_COORD_FRAC);
coord[1] -= SV_COORD_FRAC * floor(coord[1] * CL_COORD_FRAC);
coord[2] -= SV_COORD_FRAC * floor(coord[2] * CL_COORD_FRAC);
}
void SV_ClampAngle( vec3_t angle )
@ -632,8 +632,8 @@ bool SV_MoveStep (edict_t *ent, vec3_t move, bool relink)
if (i == 0 && enemy != prog->edicts)
{
dz = ent->progs.sv->origin[2] - PRVM_PROG_TO_EDICT(ent->progs.sv->enemy)->progs.sv->origin[2];
if (dz > 40) neworg[2] -= 8;
if (dz < 30) neworg[2] += 8;
if (dz > 40) neworg[2] -= SV_COORD_FRAC;
if (dz < 30) neworg[2] += SV_COORD_FRAC;
}
trace = SV_Trace(ent->progs.sv->origin, ent->progs.sv->mins, ent->progs.sv->maxs, neworg, ent, MASK_SOLID);
@ -1213,7 +1213,7 @@ void SV_WalkMove (edict_t *ent)
if (clip & 2)
{
// if move was not trying to move into the step, return
if (fabs(start_velocity[0]) < 0.125 && fabs(start_velocity[1]) < 0.125)
if (fabs(start_velocity[0]) < CL_COORD_FRAC && fabs(start_velocity[1]) < CL_COORD_FRAC)
return;
if (ent->progs.sv->movetype != MOVETYPE_FLY)
@ -1247,7 +1247,7 @@ void SV_WalkMove (edict_t *ent)
// check for stuckness, possibly due to the limited precision of floats
// in the clipping hulls
if (clip && fabs(originalmove_origin[1] - ent->progs.sv->origin[1]) < 0.125 && fabs(originalmove_origin[0] - ent->progs.sv->origin[0]) < 0.125)
if (clip && fabs(originalmove_origin[1] - ent->progs.sv->origin[1]) < CL_COORD_FRAC && fabs(originalmove_origin[0] - ent->progs.sv->origin[0]) < CL_COORD_FRAC)
{
//Msg("wall\n");
// stepping up didn't make any progress, revert to original move
@ -1267,7 +1267,7 @@ void SV_WalkMove (edict_t *ent)
if (clip & 2) SV_WallFriction (ent, stepnormal);
}
// skip out if stepdown is enabled, moving downward, not in water, and the move started onground and ended offground
else if (ent->progs.sv->waterlevel < 2 && start_velocity[2] < 0.125 && oldonground && !((int)ent->progs.sv->aiflags & AI_ONGROUND))
else if (ent->progs.sv->waterlevel < 2 && start_velocity[2] < CL_COORD_FRAC && oldonground && !((int)ent->progs.sv->aiflags & AI_ONGROUND))
return;
// move down

View File

@ -492,9 +492,10 @@ SV_SendClientMessages
void SV_SendClientMessages (void)
{
int i;
client_state_t *c;
client_state_t *c;
int msglen;
byte msgbuf[MAX_MSGLEN];
uint curtime = Sys_Milliseconds();
msglen = 0;
@ -525,8 +526,8 @@ void SV_SendClientMessages (void)
else
{
// just update reliable if needed
if (c->netchan.message.cursize || host.realtime - c->netchan.last_sent > 1.0f )
Netchan_Transmit (&c->netchan, 0, NULL);
if( c->netchan.message.cursize || curtime - c->netchan.last_sent > 1000 )
Netchan_Transmit( &c->netchan, 0, NULL );
}
}
}

View File

@ -49,7 +49,7 @@ void SV_PutClientInServer (edict_t *ent)
memset (&ent->priv.sv->client->ps, 0, sizeof(client->ps));
// info_player_start
VectorCopy( ent->progs.sv->origin, client->ps.origin );
VectorScale( ent->progs.sv->origin, SV_COORD_FRAC, client->ps.origin );
client->ps.fov = 90;
client->ps.fov = bound(1, client->ps.fov, 160);
@ -273,8 +273,8 @@ void ClientEndServerFrame (edict_t *ent)
// If it wasn't updated here, the view position would lag a frame
// behind the body position when pushed -- "sinking into plats"
//
VectorCopy(ent->progs.sv->origin, current_client->ps.origin );
VectorCopy(ent->progs.sv->velocity, current_client->ps.velocity );
VectorScale(ent->progs.sv->origin, SV_COORD_FRAC, current_client->ps.origin );
VectorScale(ent->progs.sv->velocity, SV_COORD_FRAC, current_client->ps.velocity );
AngleVectors (ent->priv.sv->client->ps.viewangles, forward, right, up);
//
@ -513,8 +513,8 @@ void ClientThink (edict_t *ent, usercmd_t *ucmd)
pm.ps = client->ps;
memcpy( &client->ucmd, ucmd, sizeof(usercmd_t));//IMPORTANT!!!
VectorCopy(ent->progs.sv->origin, pm.ps.origin );
VectorCopy(ent->progs.sv->velocity, pm.ps.velocity );
VectorScale(ent->progs.sv->origin, SV_COORD_FRAC, pm.ps.origin );
VectorScale(ent->progs.sv->velocity, SV_COORD_FRAC, pm.ps.velocity );
pm.cmd = *ucmd;
@ -527,8 +527,8 @@ void ClientThink (edict_t *ent, usercmd_t *ucmd)
// save results of pmove
client->ps = pm.ps;
VectorCopy(pm.ps.origin, ent->progs.sv->origin);
VectorCopy(pm.ps.velocity, ent->progs.sv->velocity);
VectorScale(pm.ps.origin, CL_COORD_FRAC, ent->progs.sv->origin);
VectorScale(pm.ps.velocity, CL_COORD_FRAC, ent->progs.sv->velocity);
VectorCopy(pm.mins, ent->progs.sv->mins);
VectorCopy(pm.maxs, ent->progs.sv->maxs);
VectorCopy(pm.ps.viewangles, client->ps.viewangles);

View File

@ -184,15 +184,15 @@ void SV_LinkEdict( edict_t *ent )
if (ent->progs.sv->solid == SOLID_BBOX && !((int)ent->progs.sv->flags & FL_DEADMONSTER))
{
// assume that x/y are equal and symetric
i = ent->progs.sv->maxs[0];
i = ent->progs.sv->maxs[0] / SV_COORD_FRAC;
i = bound( 1, i, 255 );
// z is not symetric
j = (-ent->progs.sv->mins[2]);
j = (-ent->progs.sv->mins[2]) / SV_COORD_FRAC;
j = bound( 1, j, 255 );
// and z maxs can be negative...
k = (ent->progs.sv->maxs[2] + 32);
k = (ent->progs.sv->maxs[2] + 32)/SV_COORD_FRAC;
k = bound( 1, k, 255 );
sv_ent->solid = (k<<16) | (j<<8) | i;
}

View File

@ -155,6 +155,7 @@ void Sys_GetStdAPI( void )
com.Com_FreeLibrary = Sys_FreeLibrary; // free library
com.Com_GetProcAddress = Sys_GetProcAddress; // gpa
com.Com_DoubleTime = Sys_DoubleTime; // hi-res timer
com.Com_Milliseconds = Sys_Milliseconds;
com.Com_RandomLong = Com_RandomLong;
com.Com_RandomFloat = Com_RandomFloat;
@ -676,76 +677,29 @@ Sys_DoubleTime
*/
double Sys_DoubleTime( void )
{
static int first = true;
static bool nohardware_timer = false;
static bool first = true;
static double oldtime = 0.0, curtime = 0.0;
static bool firsttimegettime = true;
double newtime;
// LordHavoc: note to people modifying this code,
// DWORD is specifically defined as an unsigned 32bit number,
// therefore the 65536.0 * 65536.0 is fine.
if (GI.cpunum > 1 || nohardware_timer)
if( firsttimegettime )
{
static int firsttimegettime = true;
// timeGetTime
// platform:
// Windows 95/98/ME/NT/2000/XP
// features:
// reasonable accuracy (millisecond)
// issues:
// wraps around every 47 days or so (but this is non-fatal to us,
// odd times are rejected, only causes a one frame stutter)
// make sure the timer is high precision, otherwise different versions of
// windows have varying accuracy
if (firsttimegettime)
{
timeBeginPeriod (1);
firsttimegettime = false;
}
newtime = (double)timeGetTime () * 0.001;
timeBeginPeriod (1);
firsttimegettime = false;
}
else
{
// QueryPerformanceCounter
// platform:
// Windows 95/98/ME/NT/2000/XP
// features:
// very accurate (CPU cycles)
// known issues:
// does not necessarily match realtime too well
// (tends to get faster and faster in win98)
// wraps around occasionally on some platforms
// (depends on CPU speed and probably other unknown factors)
double timescale;
LARGE_INTEGER PerformanceFreq;
LARGE_INTEGER PerformanceCount;
newtime = ( double )timeGetTime() * 0.001;
if (!QueryPerformanceFrequency (&PerformanceFreq))
{
Msg("No hardware timer available\n");
// fall back to timeGetTime
nohardware_timer = true;
return Sys_DoubleTime();
}
QueryPerformanceCounter (&PerformanceCount);
timescale = 1.0 / ((double) PerformanceFreq.LowPart + (double) PerformanceFreq.HighPart * 65536.0 * 65536.0);
newtime = ((double) PerformanceCount.LowPart + (double) PerformanceCount.HighPart * 65536.0 * 65536.0) * timescale;
}
if (first)
if( first )
{
first = false;
oldtime = newtime;
}
if (newtime < oldtime)
if( newtime < oldtime )
{
// warn if it's significant
if (newtime - oldtime < -0.01)
Msg("Plat_DoubleTime: time stepped backwards (went from %f to %f, difference %f)\n", oldtime, newtime, newtime - oldtime);
if( newtime - oldtime < -0.01 )
MsgDev( D_ERROR, "Sys_DoubleTime: time stepped backwards (went from %f to %f, difference %f)\n", oldtime, newtime, newtime - oldtime);
}
else curtime += newtime - oldtime;
oldtime = newtime;
@ -753,6 +707,26 @@ double Sys_DoubleTime( void )
return curtime;
}
/*
================
Sys_Milliseconds
================
*/
dword Sys_Milliseconds( void )
{
static dword timebase;
static bool firsttimegettime = true;
dword curtime;
if( firsttimegettime )
{
timebase = timeGetTime();
firsttimegettime = false;
}
curtime = timeGetTime() - timebase;
return curtime;
}
/*
================
Sys_GetClipboardData

View File

@ -115,6 +115,7 @@ uint Sys_SendKeyEvents( void );
void Sys_ParseCommandLine (LPSTR lpCmdLine);
void Sys_LookupInstance( void );
double Sys_DoubleTime( void );
dword Sys_Milliseconds( void );
char *Sys_GetClipboardData( void );
void Sys_Sleep( int msec );
void Sys_Init( void );

View File

@ -1495,9 +1495,9 @@ void Quake_PMove( pmove_t *pmove )
memset (&pml, 0, sizeof(pml));
// save old org in case we get stuck
VectorCopy( pm->ps.origin, pml.previous_origin );
VectorScale( pm->ps.origin, CL_COORD_FRAC, pml.previous_origin );
// save old velocity for crashlanding
VectorCopy( pm->ps.velocity, pml.previous_velocity );
VectorScale( pm->ps.velocity, CL_COORD_FRAC, pml.previous_velocity );
pml.frametime = pm->cmd.msec * 0.001;

View File

@ -230,7 +230,7 @@ typedef struct pmodel_state_s
{
int index; // client modelindex
int sequence; // studio animation sequence
int frame; // studio frame
float frame; // studio frame
} pmodel_state_t;
// player_state_t communication

View File

@ -17,7 +17,17 @@
#define M_PI (float)3.14159265358979323846
#endif
//#define USE_COORD_FRAC
// network precision coords factor
#ifdef USE_COORD_FRAC
#define SV_COORD_FRAC (8.0f / 1.0f)
#define CL_COORD_FRAC (1.0f / 8.0f)
#else
#define SV_COORD_FRAC 1.0f
#define CL_COORD_FRAC 1.0f
#endif
#define SV_ANGLE_FRAC (360.0f / 1.0f )
#define CL_ANGLE_FRAC (1.0f / 360.0f )
@ -194,12 +204,12 @@ _inline bool VectorCompare (const vec3_t v1, const vec3_t v2)
return true;
}
_inline bool VectorICompare (const short* v1, const short* v2)
_inline bool VectorICompare( const int* v1, const int* v2 )
{
int i;
for (i = 0; i < 3; i++ )
if (abs(v1[i] - v2[i]) > 0)
for( i = 0; i < 3; i++ )
if( abs(v1[i] - v2[i]) > 0)
return false;
return true;
}

View File

@ -149,6 +149,7 @@ typedef struct stdilib_api_s
bool (*Com_FreeLibrary)( dll_info_t *dll ); // free library
void*(*Com_GetProcAddress)( dll_info_t *dll, const char* name ); // gpa
double (*Com_DoubleTime)( void ); // hi-res timer
dword (*Com_Milliseconds)( void ); // hi-res timer
// random generator
long (*Com_RandomLong)( long lMin, long lMax ); // returns random integer
@ -362,6 +363,7 @@ misc utils
#define Sys_Break com.abort
#define Sys_ConsoleInput com.input
#define Sys_DoubleTime com.Com_DoubleTime
#define Sys_Milliseconds com.Com_Milliseconds
#define GetNumThreads com.Com_NumThreads
#define ThreadLock com.Com_ThreadLock
#define ThreadUnlock com.Com_ThreadUnlock

View File

@ -26,7 +26,9 @@ fopen
3. Упорядочить svc_ мессаги OK
4. Вырезать все клиентские эффекты OK
5. Создать cl_edict_s OK
6. Отладить новые клиентские энтити
6. Отладить новые клиентские энтити OK
7. August 2007-29 OK
8. Отладить демки
Физика игрока: