diff --git a/engine/client/cl_frame.c b/engine/client/cl_frame.c index c97c678d..f483dd61 100644 --- a/engine/client/cl_frame.c +++ b/engine/client/cl_frame.c @@ -29,12 +29,10 @@ FRAME PARSING */ void CL_UpdateEntityFields( cl_entity_t *ent ) { - // FIXME: this very-very temporary stuffffffff - // make me lerping VectorCopy( ent->curstate.origin, ent->origin ); VectorCopy( ent->curstate.angles, ent->angles ); - ent->model = CM_ClipHandleToModel( ent->curstate.modelindex ); + ent->model = Mod_Handle( ent->curstate.modelindex ); ent->curstate.msg_time = cl.time; // apply scale to studiomodels and sprites only @@ -130,7 +128,7 @@ qboolean CL_AddVisibleEntity( cl_entity_t *ent, int entityType ) { model_t *mod; - mod = CM_ClipHandleToModel( ent->curstate.modelindex ); + mod = Mod_Handle( ent->curstate.modelindex ); if( !mod ) return false; // if entity is beam add it here @@ -366,20 +364,18 @@ void CL_DeltaEntity( sizebuf_t *msg, frame_t *frame, int newnum, entity_state_t if( newent ) Host_Error( "Cl_DeltaEntity: tried to release new entity\n" ); CL_KillDeadBeams( ent ); // release dead beams -/* +#if 0 + // this is for reference if( state->number == -1 ) - { Msg( "Entity %i was removed from server\n", newnum ); - } - else - { - Msg( "Entity %i was removed from delta-message\n", newnum ); - } -*/ -// FIXME: waiting for static entity implimentation -// if( state->number == -1 ) -// R_RemoveEfrags( ent ); + else Msg( "Entity %i was removed from delta-message\n", newnum ); +#endif +#if 0 + // waiting for static entity implimentation + if( state->number == -1 ) + R_RemoveEfrags( ent ); +#endif // entity was delta removed return; } diff --git a/engine/client/cl_game.c b/engine/client/cl_game.c index fe7224e7..09e36611 100644 --- a/engine/client/cl_game.c +++ b/engine/client/cl_game.c @@ -267,13 +267,13 @@ void CL_FadeAlpha( int starttime, int endtime, byte *alpha ) { int time, fade_time; - if( starttime == 0 ) + if( !starttime ) { *alpha = 255; return; } - time = (host.realtime * 1000) - starttime; // FIXME; convert it to float properly + time = (cl.time * 1000) - starttime; if( time >= endtime ) { @@ -2191,11 +2191,8 @@ pfnIsSpectateOnly */ static int pfnIsSpectateOnly( void ) { - cl_entity_t *pl = CL_GetLocalPlayer(); - - if( !pl ) return false; - - return pl->curstate.spectator; + // FIXME: check for proxie and dev_overview 2 + return 0; } /* @@ -2451,7 +2448,7 @@ pfnSetUpPlayerPrediction */ void pfnSetUpPlayerPrediction( int dopred, int bIncludeLocalClient ) { - // FIXME: implement + // TODO: implement } /* @@ -2553,7 +2550,7 @@ model_t *CL_LoadModel( const char *modelname, int *index ) if( !idx ) return NULL; if( index ) *index = idx; - return CM_ClipHandleToModel( idx ); + return Mod_Handle( idx ); } int CL_AddEntity( int entityType, cl_entity_t *pEnt ) @@ -2698,7 +2695,7 @@ PlayerInfo_SetValueForKey */ void PlayerInfo_SetValueForKey( const char *key, const char *value ) { - // FIXME: implement + // TODO: implement } /* @@ -2709,7 +2706,7 @@ pfnGetPlayerUniqueID */ qboolean pfnGetPlayerUniqueID( int iPlayer, char playerID[16] ) { - // FIXME: implement + // TODO: implement return false; } @@ -3112,7 +3109,7 @@ Demo_WriteBuffer */ static void Demo_WriteBuffer( int size, byte *buffer ) { - // FIXME: implement + // TODO: implement } /* @@ -3129,7 +3126,7 @@ NetAPI_InitNetworking */ void NetAPI_InitNetworking( void ) { - // FIXME: implement + // TODO: implement } /* @@ -3140,7 +3137,7 @@ NetAPI_InitNetworking */ void NetAPI_Status( net_status_t *status ) { - // FIXME: implement + // TODO: implement } /* @@ -3151,7 +3148,7 @@ NetAPI_SendRequest */ void NetAPI_SendRequest( int context, int request, int flags, double timeout, netadr_t *remote_address, net_api_response_func_t response ) { - // FIXME: implement + // TODO: implement } /* @@ -3162,7 +3159,7 @@ NetAPI_CancelRequest */ void NetAPI_CancelRequest( int context ) { - // FIXME: implement + // TODO: implement } /* @@ -3173,7 +3170,7 @@ NetAPI_CancelAllRequests */ void NetAPI_CancelAllRequests( void ) { - // FIXME: implement + // TODO: implement } /* @@ -3271,7 +3268,7 @@ Voice_EndVoiceTweakMode */ void Voice_EndVoiceTweakMode( void ) { - // FIXME: implement + // TODO: implement } /* @@ -3282,7 +3279,7 @@ Voice_SetControlFloat */ void Voice_SetControlFloat( VoiceTweakControl iControl, float value ) { - // FIXME: implement + // TODO: implement } /* @@ -3293,7 +3290,7 @@ Voice_GetControlFloat */ float Voice_GetControlFloat( VoiceTweakControl iControl ) { - // FIXME: implement + // TODO: implement return 1.0f; } diff --git a/engine/client/cl_main.c b/engine/client/cl_main.c index b261be9d..efd693cb 100644 --- a/engine/client/cl_main.c +++ b/engine/client/cl_main.c @@ -248,15 +248,10 @@ CL_CreateCmd usercmd_t CL_CreateCmd( void ) { usercmd_t cmd; - static double extramsec = 0; color24 color; int ms; - // send milliseconds of time to apply the move -// extramsec += ( cl.time - cl.oldtime ) * 1000; - extramsec += ( host.frametime * 1000 ); - ms = extramsec; - extramsec -= ms; // fractional part is left for next frame + ms = host.frametime * 1000; if( ms > 250 ) ms = 100; // time was unreasonable Mem_Set( &cmd, 0, sizeof( cmd )); @@ -284,9 +279,6 @@ usercmd_t CL_CreateCmd( void ) R_LightForPoint( cl.frame.local.client.origin, &color, false, 128.0f ); cmd.lightlevel = (color.r + color.g + color.b) / 3; - // random seed for predictable random values - cl.random_seed = Com_RandomLong( 0, 0x7fffffff ); // full range - // never let client.dll calc frametime for player // because is potential backdoor for cheating cmd.msec = ms; @@ -392,14 +384,14 @@ void CL_WritePacket( void ) { cl.validsequence = 0; } - + // send a userinfo update if needed if( userinfo->modified ) { BF_WriteByte( &cls.netchan.message, clc_userinfo ); BF_WriteString( &cls.netchan.message, Cvar_Userinfo( )); } - + if( send_command ) { int outgoing_sequence; @@ -442,16 +434,14 @@ void CL_WritePacket( void ) for( i = numcmds - 1; i >= 0; i-- ) { - cmdnumber = ( cls.netchan.outgoing_sequence - i ) & CL_UPDATE_MASK; + cmdnumber = ( outgoing_sequence - i ) & CL_UPDATE_MASK; to = cmdnumber; CL_WriteUsercmd( &buf, from, to ); from = to; if( BF_CheckOverflow( &buf )) - { Host_Error( "CL_Move, overflowed command buffer (%i bytes)\n", MAX_CMD_BUFFER ); - } } // calculate a checksum over the move commands @@ -1033,7 +1023,7 @@ void CL_PrepVideo( void ) // let the render dll load the map com.strncpy( mapname, cl.model_precache[1], MAX_STRING ); Mod_LoadWorld( mapname, &map_checksum ); - cl.worldmodel = CM_ClipHandleToModel( 1 ); // get world pointer + cl.worldmodel = Mod_Handle( 1 ); // get world pointer Cvar_SetFloat( "scr_loading", 25.0f ); SCR_RegisterShaders(); // update with new sequence @@ -1341,6 +1331,7 @@ void CL_Userinfo_f( void ) { Msg( "User info settings:\n" ); Info_Print( Cvar_Userinfo( )); + Msg( "Total %i symbols\n", com.strlen( Cvar_Userinfo( ))); } /* @@ -1439,6 +1430,7 @@ void CL_InitLocal( void ) Cvar_Get( "hud_scale", "0", CVAR_ARCHIVE|CVAR_LATCH, "scale hud at current resolution" ); Cvar_Get( "skin", "", CVAR_USERINFO, "player skin" ); // XDM 3.3 want this cvar + Cvar_Get( "spectator", "0", CVAR_USERINFO|CVAR_ARCHIVE, "1 is enable spectator mode" ); // server commands Cmd_AddCommand ("noclip", NULL, "enable or disable no clipping mode" ); @@ -1447,7 +1439,6 @@ void CL_InitLocal( void ) Cmd_AddCommand ("give", NULL, "give specified item or weapon" ); Cmd_AddCommand ("drop", NULL, "drop current/specified item or weapon" ); Cmd_AddCommand ("intermission", NULL, "go to intermission" ); - Cmd_AddCommand ("spectate", NULL, "enable spectator mode" ); Cmd_AddCommand ("gametitle", NULL, "show game logo" ); Cmd_AddCommand ("god", NULL, "enable godmode" ); Cmd_AddCommand ("fov", NULL, "set client field of view" ); @@ -1592,10 +1583,6 @@ void CL_Init( void ) cls.initialized = true; cl.maxclients = 1; // allow to drawing player in menu - - // g-cont. disable for now - Cvar_SetFloat( "cl_lw", 0 ); - Cvar_SetFloat( "cl_predict", 0 ); } @@ -1603,8 +1590,6 @@ void CL_Init( void ) =============== CL_Shutdown -FIXME: this is a callback from Sys_Quit and Host_Error. It would be better -to run quit through here before the final handoff to the sys code. =============== */ void CL_Shutdown( void ) diff --git a/engine/client/cl_menu.c b/engine/client/cl_menu.c index 3610149d..318c9f6f 100644 --- a/engine/client/cl_menu.c +++ b/engine/client/cl_menu.c @@ -613,7 +613,7 @@ static void pfnSetPlayerModel( cl_entity_t *ent, const char *path ) { Mod_RegisterModel( path, MAX_MODELS - 1 ); ent->curstate.modelindex = MAX_MODELS - 1; - ent->model = CM_ClipHandleToModel( MAX_MODELS - 1 ); + ent->model = Mod_Handle( MAX_MODELS - 1 ); } /* diff --git a/engine/client/cl_parse.c b/engine/client/cl_parse.c index d9c45aa2..1ebdc742 100644 --- a/engine/client/cl_parse.c +++ b/engine/client/cl_parse.c @@ -306,7 +306,7 @@ void CL_ParseDownload( sizebuf_t *msg ) if( !cls.download ) { - msg->iCurBit += size << 3; // FIXME!!! + msg->iCurBit += size << 3; MsgDev( D_ERROR, "failed to open %s\n", cls.downloadtempname ); CL_RequestNextDownload(); return; @@ -496,7 +496,7 @@ void CL_ParseStaticEntity( sizebuf_t *msg ) // R_AddEfrags( ent ); - // FIXME: allocate client entity, add new static... + // TODO: allocate client entity, add new static... MsgDev( D_ERROR, "Static entities are not implemented\n" ); } @@ -549,7 +549,7 @@ void CL_ParseReliableEvent( sizebuf_t *msg, int flags ) Mem_Set( &nullargs, 0, sizeof( nullargs )); event_index = BF_ReadWord( msg ); // read event index delay = BF_ReadWord( msg ) / 100.0f; // read event delay - MSG_ReadDeltaEvent( msg, &nullargs, &args ); // FIXME: zero-compressing + MSG_ReadDeltaEvent( msg, &nullargs, &args ); // TODO: delta-compressing CL_QueueEvent( flags, event_index, delay, &args ); } @@ -605,6 +605,14 @@ void CL_ParseServerData( sizebuf_t *msg ) clgame.maxEntities = BF_ReadWord( msg ); com.strncpy( clgame.mapname, BF_ReadString( msg ), MAX_STRING ); com.strncpy( clgame.maptitle, BF_ReadString( msg ), MAX_STRING ); + + if( cl.playernum & 128 ) + { + cl.spectator = true; + cl.playernum &= ~128; + } + else cl.spectator = false; + cl.refdef.viewentity = cl.playernum + 1; // always keep viewent an actual menu.globals->maxClients = cl.maxclients; @@ -694,7 +702,6 @@ void CL_ParseClientData( sizebuf_t *msg ) } } - cl.parsecount = i; // ack'd incoming messages. cl.parsecountmod = cl.parsecount & CL_UPDATE_MASK; // index into window. frame = &cl.frames[cl.parsecountmod]; // frame at index. @@ -702,7 +709,7 @@ void CL_ParseClientData( sizebuf_t *msg ) frame->time = cl.mtime[0]; // mark network received time frame->receivedtime = host.realtime; // time now that we are parsing. - // Fixme, do this after all packets read for this frame? + // do this after all packets read for this frame? cl.last_incoming_sequence = cls.netchan.incoming_sequence; to_cd = &frame->local.client; @@ -1263,7 +1270,7 @@ void CL_ParseServerMessage( sizebuf_t *msg ) case svc_print: i = BF_ReadByte( msg ); if( i == PRINT_CHAT ) // chat - S_StartLocalSound( "common/menu2.wav" ); // FIXME: INTRESOURCE + S_StartLocalSound( "common/menu2.wav" ); MsgDev( D_INFO, "^6%s\n", BF_ReadString( msg )); break; case svc_stufftext: diff --git a/engine/client/cl_pmove.c b/engine/client/cl_pmove.c index 8ee9f894..94fecd6e 100644 --- a/engine/client/cl_pmove.c +++ b/engine/client/cl_pmove.c @@ -8,6 +8,7 @@ #include "const.h" #include "cl_tent.h" #include "pm_local.h" +#include "particledef.h" void CL_ClearPhysEnts( void ) { @@ -19,12 +20,10 @@ void CL_ClearPhysEnts( void ) qboolean CL_CopyEntityToPhysEnt( physent_t *pe, cl_entity_t *ent ) { - model_t *mod = CM_ClipHandleToModel( ent->curstate.modelindex ); + model_t *mod = Mod_Handle( ent->curstate.modelindex ); - // NOTE: player never collide with sprites (even with solid sprites) - if( !mod || mod->type == mod_bad || mod->type == mod_sprite ) - return false; - + if( !mod ) return false; + pe->player = ent->player; if( pe->player ) @@ -65,10 +64,10 @@ qboolean CL_CopyEntityToPhysEnt( physent_t *pe, cl_entity_t *ent ) Mem_Copy( &pe->blending[0], &ent->curstate.blending[0], 2 * sizeof( byte )); pe->movetype = ent->curstate.movetype; - pe->takedamage = ( pe->player ) ? DAMAGE_AIM : DAMAGE_YES; // FIXME: this right + pe->takedamage = ( pe->player ) ? DAMAGE_AIM : DAMAGE_YES; pe->team = ent->curstate.team; pe->classnumber = ent->curstate.playerclass; - pe->blooddecal = 0; // FIXME: what i'm do write here ??? + pe->blooddecal = 0; // unused in GoldSrc // for mods pe->iuser1 = ent->curstate.iuser1; @@ -107,7 +106,17 @@ void CL_AddLinksToPmove( void ) check = CL_GetEntityByIndex( idx ); // don't add the world and clients here - if( !check || check == &clgame.entities[0] || check->player ) + if( !check || check == &clgame.entities[0] ) + continue; + + if( clgame.pmove->numvisent < MAX_PHYSENTS ) + { + pe = &clgame.pmove->visents[clgame.pmove->numvisent]; + if( CL_CopyEntityToPhysEnt( pe, check )) + clgame.pmove->numvisent++; + } + + if( check->player ) continue; // can't collide with zeroed hull @@ -116,23 +125,22 @@ void CL_AddLinksToPmove( void ) if( check->curstate.solid == SOLID_BSP || check->curstate.solid == SOLID_BBOX || check->curstate.solid == SOLID_SLIDEBOX ) { - if( clgame.pmove->numphysent == MAX_PHYSENTS ) - return; - - pe = &clgame.pmove->physents[clgame.pmove->numphysent]; - - if( CL_CopyEntityToPhysEnt( pe, check )) - clgame.pmove->numphysent++; + // reserve slots for all the clients + if( clgame.pmove->numphysent < ( MAX_PHYSENTS - cl.maxclients )) + { + pe = &clgame.pmove->physents[clgame.pmove->numphysent]; + if( CL_CopyEntityToPhysEnt( pe, check )) + clgame.pmove->numphysent++; + } } else if( check->curstate.solid == SOLID_NOT && check->curstate.skin != CONTENTS_NONE ) { - if( clgame.pmove->nummoveent >= MAX_MOVEENTS ) - continue; - - pe = &clgame.pmove->moveents[clgame.pmove->nummoveent]; - - if( CL_CopyEntityToPhysEnt( pe, check )) - clgame.pmove->nummoveent++; + if( clgame.pmove->nummoveent < MAX_MOVEENTS ) + { + pe = &clgame.pmove->moveents[clgame.pmove->nummoveent]; + if( CL_CopyEntityToPhysEnt( pe, check )) + clgame.pmove->nummoveent++; + } } } } @@ -158,7 +166,6 @@ void CL_SetSolidPlayers( int playernum ) if( !cl_solid_players->integer ) return; - // FIXME: create predicted_players array for( j = 0; j < cl.maxclients; j++ ) { // the player object never gets added @@ -175,6 +182,12 @@ void CL_SetSolidPlayers( int playernum ) } } +/* +============= +CL_TruePointContents + +============= +*/ int CL_TruePointContents( const vec3_t p ) { int i, contents; @@ -281,18 +294,23 @@ model_t *CL_GetWaterModel( const float *rgflPos ) static void pfnParticle( float *origin, int color, float life, int zpos, int zvel ) { - vec3_t dir; - + particle_t *p; + if( !origin ) { MsgDev( D_ERROR, "CL_StartParticle: NULL origin. Ignored\n" ); return; } - // FIXME: send lifetime too + p = CL_AllocParticle( NULL ); + if( !p ) return; - VectorSet( dir, 0.0f, 0.0f, ( zpos * zvel )); - CL_RunParticleEffect( origin, dir, color, 1 ); + p->die += life; + p->color = color; + p->type = pt_static; + + VectorCopy( origin, p->org ); + VectorSet( p->vel, 0.0f, 0.0f, ( zpos * zvel )); } static int pfnTestPlayerPosition( float *pos, pmtrace_t *ptrace ) @@ -309,10 +327,37 @@ static double Sys_FloatTime( void ) return Sys_DoubleTime(); } -static void pfnStuckTouch( int hitent, pmtrace_t *ptraceresult ) +static void pfnStuckTouch( int hitent, pmtrace_t *tr ) { - // empty for now - // FIXME: write some code + physent_t *pe; + float *mins, *maxs; + int i; + + ASSERT( hitent >= 0 && hitent < clgame.pmove->numphysent ); + pe = &clgame.pmove->physents[hitent]; + mins = clgame.pmove->player_mins[clgame.pmove->usehull]; + maxs = clgame.pmove->player_maxs[clgame.pmove->usehull]; + + if( !PM_TraceModel( pe, clgame.pmove->origin, mins, maxs, clgame.pmove->origin, tr, 0 )) + return; // not stuck + + tr->ent = hitent; + + for( i = 0; i < clgame.pmove->numtouch; i++ ) + { + if( clgame.pmove->touchindex[i].ent == tr->ent ) + break; + } + + if( i != clgame.pmove->numtouch ) return; + VectorCopy( clgame.pmove->velocity, tr->deltavelocity ); + + if( clgame.pmove->numtouch >= MAX_PHYSENTS ) + { + MsgDev( D_ERROR, "PM_StuckTouch: MAX_TOUCHENTS limit exceeded\n" ); + return; + } + clgame.pmove->touchindex[clgame.pmove->numtouch++] = *tr; } static int pfnPointContents( float *p, int *truecontents ) @@ -419,7 +464,7 @@ static byte *pfnCOM_LoadFile( const char *path, int usehunk, int *pLength ) static void pfnCOM_FreeFile( void *buffer ) { - Mem_Free( buffer ); + if( buffer ) Mem_Free( buffer ); } static void pfnPlaySound( int channel, const char *sample, float volume, float attenuation, int fFlags, int pitch ) @@ -543,21 +588,23 @@ void CL_SetSolidEntities( void ) if( !cl.frame.valid ) return; // setup physents - clgame.pmove->numvisent = 0; // FIXME: add visents for debugging + clgame.pmove->numvisent = 0; clgame.pmove->numphysent = 0; clgame.pmove->nummoveent = 0; CL_CopyEntityToPhysEnt( &clgame.pmove->physents[0], &clgame.entities[0] ); + clgame.pmove->visents[0] = clgame.pmove->physents[0]; clgame.pmove->numphysent = 1; // always have world + clgame.pmove->numvisent = 1; CL_AddLinksToPmove(); } -static void PM_SetupMove( playermove_t *pmove, clientdata_t *cd, entity_state_t *state, usercmd_t *ucmd ) +void CL_SetupPMove( playermove_t *pmove, clientdata_t *cd, entity_state_t *state, usercmd_t *ucmd ) { pmove->player_index = cl.playernum; pmove->multiplayer = (cl.maxclients > 1) ? true : false; - pmove->time = cl_time(); // probably never used + pmove->time = cl.time; // probably never used VectorCopy( cd->origin, pmove->origin ); VectorCopy( cl.refdef.cl_viewangles, pmove->angles ); VectorCopy( cl.refdef.cl_viewangles, pmove->oldangles ); @@ -583,7 +630,7 @@ static void PM_SetupMove( playermove_t *pmove, clientdata_t *cd, entity_state_t pmove->waterjumptime = cd->waterjumptime; pmove->dead = (cd->health <= 0.0f ) ? true : false; pmove->deadflag = cd->deadflag; - pmove->spectator = 0; // FIXME: implement + pmove->spectator = cl.spectator; pmove->movetype = state->movetype; pmove->onground = -1; // will be set by PM_ code pmove->waterlevel = cd->waterlevel; @@ -605,10 +652,4 @@ static void PM_SetupMove( playermove_t *pmove, clientdata_t *cd, entity_state_t pmove->cmd = *ucmd; // setup current cmds com.strncpy( pmove->physinfo, cd->physinfo, MAX_INFO_STRING ); -} - -static void PM_FinishMove( playermove_t *pmove, clientdata_t *cd, entity_state_t *state ) -{ - cd->waterjumptime = pmove->waterjumptime; - state->onground = pmove->onground; } \ No newline at end of file diff --git a/engine/client/cl_pred.c b/engine/client/cl_pred.c index ae7e50d6..33a1043c 100644 --- a/engine/client/cl_pred.c +++ b/engine/client/cl_pred.c @@ -29,11 +29,6 @@ qboolean CL_IsPredicted( void ) return true; } -void CL_PreRunCmd( cl_entity_t *clent, usercmd_t *ucmd ) -{ - clgame.pmove->runfuncs = (( clent->index - 1 ) == cl.playernum ) ? true : false; -} - /* =========== CL_PostRunCmd @@ -41,16 +36,14 @@ CL_PostRunCmd Done after running a player command. =========== */ -void CL_PostRunCmd( cl_entity_t *clent, usercmd_t *ucmd ) +void CL_PostRunCmd( usercmd_t *ucmd, int random_seed ) { local_state_t *from, *to; - if( !clent ) return; - from = &cl.frames[cl.delta_sequence & CL_UPDATE_MASK].local; to = &cl.frame.local; - clgame.dllFuncs.pfnPostRunCmd( from, to, ucmd, clgame.pmove->runfuncs, cl.time, cl.random_seed ); + clgame.dllFuncs.pfnPostRunCmd( from, to, ucmd, clgame.pmove->runfuncs, cl.time, random_seed ); } /* @@ -60,22 +53,18 @@ CL_CheckPredictionError */ void CL_CheckPredictionError( void ) { - int frame; - vec3_t delta; - cl_entity_t *player; - float flen; + int frame; + vec3_t delta; + float flen; if( !CL_IsPredicted( )) return; - player = CL_GetLocalPlayer(); - if( !player ) return; - // calculate the last usercmd_t we sent that the server has processed frame = cls.netchan.incoming_acknowledged; frame &= CL_UPDATE_MASK; // compare what the server returned with what we had predicted it to be - VectorSubtract( player->curstate.origin, cl.predicted_origins[frame], delta ); + VectorSubtract( cl.frame.local.client.origin, cl.predicted_origins[frame], delta ); // save the prediction error for interpolation flen = fabs( delta[0] ) + fabs( delta[1] ) + fabs( delta[2] ); @@ -88,7 +77,7 @@ void CL_CheckPredictionError( void ) else { if( cl_showmiss->integer && flen > 0.1f ) Msg( "prediction miss: %g\n", flen ); - VectorCopy( player->curstate.origin, cl.predicted_origins[frame] ); + VectorCopy( cl.frame.local.client.origin, cl.predicted_origins[frame] ); // save for error itnerpolation VectorCopy( delta, cl.prediction_error ); @@ -169,11 +158,12 @@ Sets cl.predicted_origin and cl.predicted_angles */ void CL_PredictMovement( void ) { - int frame = 0; - int ack, current; + int frame = 1; + int ack, outgoing_command; + int current_command; + int current_command_mod; cl_entity_t *player, *viewent; clientdata_t *cd; - usercmd_t *cmd; if( cls.state != ca_active ) return; if( cl.refdef.paused || cls.key_dest == key_menu ) return; @@ -195,59 +185,58 @@ void CL_PredictMovement( void ) // unpredicted pure angled values converted into axis AngleVectors( cl.refdef.cl_viewangles, cl.refdef.forward, cl.refdef.right, cl.refdef.up ); - if( 1 )//// disabled for now!!!!!!!!!!!!!!!!!!!!!!!!! ///////!CL_IsPredicted( )) + if( !CL_IsPredicted( )) { - cmd = cl.refdef.cmd; // use current command - // run commands even if client predicting is disabled - client expected it - CL_PreRunCmd( player, cmd ); + clgame.pmove->runfuncs = true; VectorCopy( cl.refdef.cl_viewangles, cl.predicted_angles ); VectorCopy( cd->view_ofs, cl.predicted_viewofs ); - CL_PostRunCmd( player, cmd ); + CL_PostRunCmd( cl.refdef.cmd, cls.netchan.outgoing_sequence ); return; } ack = cls.netchan.incoming_acknowledged; - current = cls.netchan.outgoing_sequence; + outgoing_command = cls.netchan.outgoing_sequence; + + ASSERT( cl.refdef.cmd != NULL ); - // if we are too far out of date, just freeze - if( current - ack >= CMD_BACKUP ) - { - if( cl_showmiss->value ) - MsgDev( D_ERROR, "CL_Predict: exceeded CMD_BACKUP\n" ); - return; - } -#if 0 // setup initial pmove state -// FIXME!!!!... -// VectorCopy( player->v.movedir, clgame.pmove->movedir ); - VectorCopy( cd->origin, clgame.pmove->origin ); - VectorCopy( cd->velocity, clgame.pmove->velocity ); - VectorCopy( player->curstate.basevelocity, clgame.pmove->basevelocity ); - clgame.pmove->flWaterJumpTime = cd->waterjumptime; - clgame.pmove->onground = (edict_t *)CL_GetEntityByIndex( player->curstate.onground ); - clgame.pmove->usehull = (player->curstate.flags & FL_DUCKING) ? 1 : 0; // reset hull - - // run frames - while( ++ack < current ) - { - frame = ack & CL_UPDATE_MASK; - cmd = &cl.cmds[frame]; + CL_SetupPMove( clgame.pmove, cd, &player->curstate, cl.refdef.cmd ); + clgame.pmove->runfuncs = false; - CL_PreRunCmd( player, cmd ); - CL_RunCmd( player, cmd ); - CL_PostRunCmd( player, cmd ); + while( 1 ) + { + // we've run too far forward + if( frame >= CL_UPDATE_BACKUP - 1 ) + break; + + // Incoming_acknowledged is the last usercmd the server acknowledged having acted upon + current_command = ack + frame; + current_command_mod = current_command & CL_UPDATE_MASK; + + // we've caught up to the current command. + if( current_command > outgoing_command ) + break; + + clgame.pmove->cmd = cl.cmds[frame]; + + // motor! + clgame.dllFuncs.pfnPlayerMove( clgame.pmove, false ); // run frames // save for debug checking - VectorCopy( clgame.pmove->origin, cl.predicted_origins[frame] ); + VectorCopy( clgame.pmove->origin, cl.predicted_origins[frame-1] ); + clgame.pmove->runfuncs = true; + + frame++; } + CL_PostRunCmd( cl.refdef.cmd, frame ); + // copy results out for rendering - VectorCopy( player->v.view_ofs, cl.predicted_viewofs ); + VectorCopy( clgame.pmove->view_ofs, cl.predicted_viewofs ); VectorCopy( clgame.pmove->origin, cl.predicted_origin ); VectorCopy( clgame.pmove->angles, cl.predicted_angles ); VectorCopy( clgame.pmove->velocity, cl.predicted_velocity ); -#endif -} +} \ No newline at end of file diff --git a/engine/client/cl_tent.c b/engine/client/cl_tent.c index 7004cec3..f7ef43bd 100644 --- a/engine/client/cl_tent.c +++ b/engine/client/cl_tent.c @@ -6,7 +6,6 @@ #include "common.h" #include "client.h" #include "r_efx.h" -#include "event_flags.h" #include "entity_types.h" #include "triangleapi.h" #include "cl_tent.h" @@ -430,7 +429,7 @@ void CL_FizzEffect( cl_entity_t *pent, int modelIndex, int density ) Mod_GetBounds( pent->curstate.modelindex, mins, maxs ); - maxHeight = ( maxs[2] - mins[2] ) * 0.5f; + maxHeight = maxs[2] - mins[2]; width = maxs[0] - mins[0]; depth = maxs[1] - mins[1]; speed = ( pent->curstate.rendercolor.r<<8 | pent->curstate.rendercolor.g ); @@ -455,7 +454,7 @@ void CL_FizzEffect( cl_entity_t *pent, int modelIndex, int density ) origin[0] = mins[0] + Com_RandomLong( 0, width - 1 ); origin[1] = mins[1] + Com_RandomLong( 0, depth - 1 ); origin[2] = mins[2]; - pTemp = CL_TempEntAlloc( origin, CM_ClipHandleToModel( modelIndex )); + pTemp = CL_TempEntAlloc( origin, Mod_Handle( modelIndex )); if ( !pTemp ) return; @@ -500,7 +499,7 @@ void CL_Bubbles( const vec3_t mins, const vec3_t maxs, float height, int modelIn origin[0] = Com_RandomLong( mins[0], maxs[0] ); origin[1] = Com_RandomLong( mins[1], maxs[1] ); origin[2] = Com_RandomLong( mins[2], maxs[2] ); - pTemp = CL_TempEntAlloc( origin, CM_ClipHandleToModel( modelIndex )); + pTemp = CL_TempEntAlloc( origin, Mod_Handle( modelIndex )); if( !pTemp ) return; pTemp->flags |= FTENT_SINEWAVE; @@ -546,7 +545,7 @@ void CL_BubbleTrail( const vec3_t start, const vec3_t end, float flWaterZ, int m { dist = Com_RandomFloat( 0, 1.0 ); VectorLerp( start, dist, end, origin ); - pTemp = CL_TempEntAlloc( origin, CM_ClipHandleToModel( modelIndex )); + pTemp = CL_TempEntAlloc( origin, Mod_Handle( modelIndex )); if( !pTemp ) return; pTemp->flags |= FTENT_SINEWAVE; @@ -601,7 +600,7 @@ void CL_AttachTentToPlayer( int client, int modelIndex, float zoffset, float lif VectorCopy( pClient->origin, position ); position[2] += zoffset; - pTemp = CL_TempEntAllocHigh( position, CM_ClipHandleToModel( modelIndex )); + pTemp = CL_TempEntAllocHigh( position, Mod_Handle( modelIndex )); if( !pTemp ) { @@ -709,7 +708,7 @@ void CL_RocketFlare( const vec3_t pos ) int nframeCount; modelIndex = CL_FindModelIndex( "sprites/animglow01.spr" ); - pmodel = CM_ClipHandleToModel( modelIndex ); + pmodel = Mod_Handle( modelIndex ); if( !pmodel ) return; Mod_GetFrames( modelIndex, &nframeCount ); @@ -751,7 +750,7 @@ void CL_MuzzleFlash( const vec3_t pos, int type ) Mod_GetFrames( modelIndex, &frameCount ); // must set position for right culling on render - pTemp = CL_TempEntAllocHigh( pos, CM_ClipHandleToModel( modelIndex )); + pTemp = CL_TempEntAllocHigh( pos, Mod_Handle( modelIndex )); if( !pTemp ) return; pTemp->entity.curstate.rendermode = kRenderTransAdd; pTemp->entity.curstate.renderamt = 255; @@ -791,7 +790,7 @@ void CL_BloodSprite( const vec3_t org, int colorIndex, int modelIndex, int model return; // Large, single blood sprite is a high-priority tent - if(( pTemp = CL_TempEntAllocHigh( org, CM_ClipHandleToModel( modelIndex ))) != NULL ) + if(( pTemp = CL_TempEntAllocHigh( org, Mod_Handle( modelIndex ))) != NULL ) { int i, frameCount; vec3_t offset, dir; @@ -826,7 +825,7 @@ void CL_BloodSprite( const vec3_t org, int colorIndex, int modelIndex, int model VectorMA( offset, Com_RandomFloat( -0.5f, 0.5f ) * size, right, offset ); VectorMA( offset, Com_RandomFloat( -0.5f, 0.5f ) * size, up, offset ); - pTemp = CL_TempEntAllocHigh( org, CM_ClipHandleToModel( modelIndex2 )); + pTemp = CL_TempEntAllocHigh( org, Mod_Handle( modelIndex2 )); if( !pTemp ) return; pTemp->flags = FTENT_SPRANIMATELOOP|FTENT_COLLIDEWORLD|FTENT_SLOWGRAVITY; @@ -892,7 +891,7 @@ void CL_BreakModel( const vec3_t pos, const vec3_t size, const vec3_t dir, float vecSpot[1] = pos[1] + Com_RandomFloat( -0.5f, 0.5f ) * size[1]; vecSpot[2] = pos[2] + Com_RandomFloat( -0.5f, 0.5f ) * size[2]; - pTemp = CL_TempEntAlloc( vecSpot, CM_ClipHandleToModel( modelIndex )); + pTemp = CL_TempEntAlloc( vecSpot, Mod_Handle( modelIndex )); if( !pTemp ) return; // keep track of break_type, so we know how to play sound on collision @@ -947,7 +946,7 @@ TEMPENTITY *CL_TempModel( const vec3_t pos, const vec3_t dir, const vec3_t angle // alloc a new tempent TEMPENTITY *pTemp; - pTemp = CL_TempEntAlloc( pos, CM_ClipHandleToModel( modelIndex )); + pTemp = CL_TempEntAlloc( pos, Mod_Handle( modelIndex )); if( !pTemp ) return NULL; // keep track of shell type @@ -997,7 +996,7 @@ TEMPENTITY *CL_DefaultSprite( const vec3_t pos, int spriteIndex, float framerate Mod_GetFrames( spriteIndex, &frameCount ); - pTemp = CL_TempEntAlloc( pos, CM_ClipHandleToModel( spriteIndex )); + pTemp = CL_TempEntAlloc( pos, Mod_Handle( spriteIndex )); if( !pTemp ) return NULL; pTemp->frameMax = frameCount - 1; @@ -1035,7 +1034,7 @@ TEMPENTITY *CL_TempSprite( const vec3_t pos, const vec3_t dir, float scale, int Mod_GetFrames( modelIndex, &frameCount ); - pTemp = CL_TempEntAlloc( pos, CM_ClipHandleToModel( modelIndex )); + pTemp = CL_TempEntAlloc( pos, Mod_Handle( modelIndex )); if( !pTemp ) return NULL; pTemp->frameMax = frameCount - 1; @@ -1159,7 +1158,7 @@ void CL_Spray( const vec3_t pos, const vec3_t dir, int modelIndex, int count, in vec3_t velocity; float scale; - pTemp = CL_TempEntAlloc( pos, CM_ClipHandleToModel( modelIndex )); + pTemp = CL_TempEntAlloc( pos, Mod_Handle( modelIndex )); if( !pTemp ) return; pTemp->entity.curstate.rendermode = renderMode; @@ -1226,7 +1225,7 @@ void CL_Sprite_Trail( int type, const vec3_t vecStart, const vec3_t vecEnd, int if( i == 0 ) VectorCopy( vecStart, vecPos ); else VectorMA( vecStart, ( i / ( nCount - 1.0f )), vecDelta, vecPos ); - pTemp = CL_TempEntAlloc( vecPos, CM_ClipHandleToModel( modelIndex )); + pTemp = CL_TempEntAlloc( vecPos, Mod_Handle( modelIndex )); if( !pTemp ) return; pTemp->flags |= FTENT_COLLIDEWORLD | FTENT_SPRCYCLE | FTENT_FADEOUT | FTENT_SLOWGRAVITY; @@ -1290,7 +1289,7 @@ void CL_FunnelSprite( const vec3_t pos, int spriteIndex, int flags ) } else { - pTemp = CL_TempEntAlloc( pos, CM_ClipHandleToModel( spriteIndex )); + pTemp = CL_TempEntAlloc( pos, Mod_Handle( spriteIndex )); pPart = NULL; } @@ -1366,7 +1365,7 @@ void CL_SparkEffect( const vec3_t pos, int count, int velocityMin, int velocityM model_t *pmodel; int i; - pmodel = CM_ClipHandleToModel( CL_FindModelIndex( "sprites/richo1.spr" )); + pmodel = Mod_Handle( CL_FindModelIndex( "sprites/richo1.spr" )); CL_RicochetSprite( pos, pmodel, 0.0f, Com_RandomFloat( 0.4f, 0.6f )); for( i = 0; i < Com_RandomLong( 1, count ); i++ ) @@ -1464,7 +1463,7 @@ void CL_Projectile( const vec3_t origin, const vec3_t velocity, int modelIndex, // alloc a new tempent TEMPENTITY *pTemp; - pTemp = CL_TempEntAlloc( origin, CM_ClipHandleToModel( modelIndex )); + pTemp = CL_TempEntAlloc( origin, Mod_Handle( modelIndex )); if( !pTemp ) return; VectorAngles( velocity, pTemp->entity.angles ); @@ -1497,7 +1496,7 @@ void CL_TempSphereModel( const vec3_t pos, float speed, float life, int count, i // create temp models for( i = 0; i < count; i++ ) { - pTemp = CL_TempEntAlloc( pos, CM_ClipHandleToModel( modelIndex )); + pTemp = CL_TempEntAlloc( pos, Mod_Handle( modelIndex )); if( !pTemp ) return; dir[0] = forward[0] + Com_RandomFloat( -0.3f, 0.3f ); @@ -1577,7 +1576,7 @@ Client version of shotgun shot */ void CL_MultiGunshot( const vec3_t org, const vec3_t dir, const vec3_t noise, int count, int decalCount, int *decalIndices ) { - // FIXME: implement + // TODO: implement } /* @@ -1589,7 +1588,7 @@ Makes a field of fire */ void CL_FireField( float *org, int radius, int modelIndex, int count, int flags, float life ) { - // FIXME: implement + // TODO: implement } /* @@ -1601,7 +1600,7 @@ Create a wallpuff */ void CL_Sprite_WallPuff( TEMPENTITY *pTemp, float scale ) { - // FIXME: implement + // TODO: implement } /* @@ -1613,7 +1612,16 @@ Unknown effect */ void CL_PlayerSprites( int client, int modelIndex, int count, int size ) { - // in GoldSrc any trying to create this effect will invoke immediately crash +#if 0 + // TODO: implement + MESSAGE_BEGIN( MSG_ONE, SVC_TEMPENTITY, g_vecZero, pev ); + WRITE_BYTE( TE_PLAYERSPRITES ); + WRITE_SHORT( ENTINDEX( ENT( pev ) ) ); + WRITE_SHORT( g_sModelIndexFire ); + WRITE_BYTE( 20 ); + WRITE_BYTE( 10 ); + MESSAGE_END( ); +#endif } /* @@ -1980,7 +1988,7 @@ void CL_ParseTempEntity( sizebuf_t *msg ) pos[2] = BF_ReadCoord( &buf ); scale = (float)(BF_ReadByte( &buf ) * 0.1f); modelIndex = CL_FindModelIndex( "sprites/richo1.spr" ); - CL_RicochetSprite( pos, CM_ClipHandleToModel( modelIndex ), 0.0f, scale ); + CL_RicochetSprite( pos, Mod_Handle( modelIndex ), 0.0f, scale ); CL_RicochetSound( pos ); break; case TE_PLAYERDECAL: @@ -2341,21 +2349,8 @@ void CL_UpadteFlashlight( cl_entity_t *pEnt ) VectorClear( view_ofs ); - // FIXME: grab viewheight from other place - view_ofs[2] = 28.0f; - - if( pEnt->player ) - { - if(( pEnt->index - 1 ) == cl.playernum ) - { - VectorCopy( cl.predicted_viewofs, view_ofs ); - } - else if( pEnt->curstate.usehull == 1 ) - { - // FIXME: grab ducked viewheight from other place - view_ofs[2] = 12.0f; - } - } + if(( pEnt->index - 1 ) == cl.playernum ) + VectorCopy( cl.predicted_viewofs, view_ofs ); VectorAdd( pEnt->origin, view_ofs, vecSrc ); VectorMA( vecSrc, FLASHLIGHT_DISTANCE, forward, vecEnd ); @@ -2366,7 +2361,7 @@ void CL_UpadteFlashlight( cl_entity_t *pEnt ) if( falloff < 250.0f ) falloff = 1.0f; else falloff = 250.0f / falloff; - falloff *= falloff; + falloff *= falloff; // update flashlight endpos dl = CL_AllocDlight( cl.playernum + 1 ); diff --git a/engine/client/cl_view.c b/engine/client/cl_view.c index 68e9f6e3..d3081ca1 100644 --- a/engine/client/cl_view.c +++ b/engine/client/cl_view.c @@ -36,7 +36,7 @@ void V_SetupRefDef( void ) VectorCopy( cl.frame.local.client.punchangle, cl.refdef.punchangle ); clgame.viewent.curstate.modelindex = cl.frame.local.client.viewmodel; - clgame.viewent.model = CM_ClipHandleToModel( clgame.viewent.curstate.modelindex ); + clgame.viewent.model = Mod_Handle( clgame.viewent.curstate.modelindex ); clgame.viewent.curstate.entityType = ET_NORMAL; clgame.viewent.index = cl.playernum + 1; @@ -52,8 +52,9 @@ void V_SetupRefDef( void ) cl.refdef.smoothing = cl_smooth->integer; cl.refdef.waterlevel = cl.frame.local.client.waterlevel; cl.refdef.onlyClientDraw = 0; // reset clientdraw - cl.refdef.viewsize = 120; // FIXME if you can + cl.refdef.viewsize = 120; // probably was 'scr_viewsize' or somewhat cl.refdef.hardware = true; // always true + cl.refdef.spectator = cl.spectator; cl.refdef.nextView = 0; // setup default viewport diff --git a/engine/client/client.h b/engine/client/client.h index 9ed7a6dc..8294445d 100644 --- a/engine/client/client.h +++ b/engine/client/client.h @@ -86,6 +86,7 @@ typedef struct qboolean force_send_usercmd; qboolean thirdperson; + qboolean spectator; // true for spectators uint checksum; // for catching cheater maps @@ -110,7 +111,6 @@ typedef struct event_state_t events; // predicting stuff - uint random_seed; // for predictable random values vec3_t predicted_origins[CMD_BACKUP]; // for debug comparing against server vec3_t predicted_origin; // generated by CL_PredictMovement vec3_t predicted_viewofs; @@ -628,6 +628,7 @@ int CL_TruePointContents( const vec3_t p ); int CL_PointContents( const vec3_t p ); int CL_WaterEntity( const float *rgflPos ); model_t *CL_GetWaterModel( const float *rgflPos ); +void CL_SetupPMove( playermove_t *pmove, clientdata_t *cd, entity_state_t *state, usercmd_t *ucmd ); // // cl_studio.c diff --git a/engine/client/gl_beams.c b/engine/client/gl_beams.c index cd7a7936..5500c9a2 100644 --- a/engine/client/gl_beams.c +++ b/engine/client/gl_beams.c @@ -173,7 +173,7 @@ static void CL_DrawSegs( int modelIndex, float frame, int rendermode, const vec3 if( !cl_draw_beams->integer ) return; - m_hSprite = R_GetSpriteTexture( CM_ClipHandleToModel( modelIndex ), frame ); + m_hSprite = R_GetSpriteTexture( Mod_Handle( modelIndex ), frame ); if( !m_hSprite || segments < 2 ) return; @@ -388,7 +388,7 @@ static void CL_DrawDisk( int modelIndex, float frame, int rendermode, const vec3 vec3_t point; int i; - m_hSprite = R_GetSpriteTexture( CM_ClipHandleToModel( modelIndex ), frame ); + m_hSprite = R_GetSpriteTexture( Mod_Handle( modelIndex ), frame ); if( !m_hSprite || segments < 2 ) return; @@ -459,7 +459,7 @@ static void CL_DrawCylinder( int modelIndex, float frame, int rendermode, const vec3_t point; int i; - m_hSprite = R_GetSpriteTexture( CM_ClipHandleToModel( modelIndex ), frame ); + m_hSprite = R_GetSpriteTexture( Mod_Handle( modelIndex ), frame ); if( !m_hSprite || segments < 2 ) return; @@ -534,7 +534,7 @@ void CL_DrawRing( int modelIndex, float frame, int rendermode, const vec3_t sour HSPRITE m_hSprite; vec3_t d; - m_hSprite = R_GetSpriteTexture( CM_ClipHandleToModel( modelIndex ), frame ); + m_hSprite = R_GetSpriteTexture( Mod_Handle( modelIndex ), frame ); if( !m_hSprite || segments < 2 ) return; @@ -740,7 +740,7 @@ static void DrawBeamFollow( int modelIndex, particle_t *pHead, int frame, int re HSPRITE m_hSprite; rgb_t nColor; - m_hSprite = R_GetSpriteTexture( CM_ClipHandleToModel( modelIndex ), frame ); + m_hSprite = R_GetSpriteTexture( Mod_Handle( modelIndex ), frame ); if( !m_hSprite ) return; diff --git a/engine/client/gl_decals.c b/engine/client/gl_decals.c index c1acf445..09c2979f 100644 --- a/engine/client/gl_decals.c +++ b/engine/client/gl_decals.c @@ -23,7 +23,6 @@ typedef struct vec2_t m_LMCoords; // lightmap texcoords for the decal. } decalvert_t; -// FIXME: move this out to the r_math.c ? typedef struct { qboolean (*pfnInside)( decalvert_t *pVert ); @@ -731,8 +730,8 @@ void R_DecalShoot( int textureIndex, int entityIndex, int modelIndex, vec3_t pos { ent = CL_GetEntityByIndex( entityIndex ); - if( modelIndex > 0 ) model = CM_ClipHandleToModel( modelIndex ); - else if( ent != NULL ) model = CM_ClipHandleToModel( ent->curstate.modelindex ); + if( modelIndex > 0 ) model = Mod_Handle( modelIndex ); + else if( ent != NULL ) model = Mod_Handle( ent->curstate.modelindex ); else { Msg( "ent = NULL, model = NULL on entity %i, model %i\n", entityIndex, modelIndex ); @@ -740,7 +739,7 @@ void R_DecalShoot( int textureIndex, int entityIndex, int modelIndex, vec3_t pos } } else if( modelIndex > 0 ) - model = CM_ClipHandleToModel( modelIndex ); + model = Mod_Handle( modelIndex ); else model = cl.worldmodel; if( !model || model->type != mod_brush ) @@ -800,7 +799,6 @@ void R_DecalShoot( int textureIndex, int entityIndex, int modelIndex, vec3_t pos if(( height >> 1 ) > decalInfo.m_Size ) decalInfo.m_Size = height >> 1; - // FIXME: grab scale from shader ? decalInfo.m_scale = 1.0f; // compute the decal dimensions in world space diff --git a/engine/client/gl_image.c b/engine/client/gl_image.c index 214dddc0..5172a080 100644 --- a/engine/client/gl_image.c +++ b/engine/client/gl_image.c @@ -800,7 +800,8 @@ static void GL_UploadTexture( rgbdata_t *pic, gltexture_t *tex, qboolean subImag buf = pic->buffer; bufend = pic->buffer + pic->size; offset = pic->width * pic->height * PFDesc( pic->type )->bpp; - // FIXME: probably this code relies when gl_compressed_textures is enabled + + // NOTE: probably this code relies when gl_compressed_textures is enabled texsize = tex->width * tex->height * samples; // determine some texTypes diff --git a/engine/client/gl_refrag.c b/engine/client/gl_refrag.c index 8102ca21..2f8868b6 100644 --- a/engine/client/gl_refrag.c +++ b/engine/client/gl_refrag.c @@ -157,7 +157,6 @@ void R_AddEfrags( cl_entity_t *ent ) ================ R_StoreEfrags -FIXME: a lot of this goes away with edge-based ================ */ void R_StoreEfrags( efrag_t **ppefrag ) diff --git a/engine/client/gl_rlight.c b/engine/client/gl_rlight.c index 9b70d56f..f1cc8216 100644 --- a/engine/client/gl_rlight.c +++ b/engine/client/gl_rlight.c @@ -454,7 +454,7 @@ void R_LightDir( const vec3_t origin, vec3_t lightDir, float radius ) } } - // FIXME: should we normalize final direction ? + // normalize final direction // VectorNormalize( lightDir ); } diff --git a/engine/client/gl_rmain.c b/engine/client/gl_rmain.c index dfd10392..b564073c 100644 --- a/engine/client/gl_rmain.c +++ b/engine/client/gl_rmain.c @@ -167,7 +167,7 @@ qboolean R_WorldToScreen( const vec3_t point, vec3_t screen ) void R_ScreenToWorld( const vec3_t screen, vec3_t point ) { - // FIXME: implement + // TODO: implement } /* @@ -832,7 +832,6 @@ void R_DrawEntitiesOnList( void ) clgame.dllFuncs.pfnDrawTransparentTriangles (); - // FIXME: allow to brush and sprite viewmodel ? R_DrawViewModel(); } diff --git a/engine/client/gl_rmisc.c b/engine/client/gl_rmisc.c index dc2af74d..fe1cc4c6 100644 --- a/engine/client/gl_rmisc.c +++ b/engine/client/gl_rmisc.c @@ -18,7 +18,6 @@ void R_NewMap( void ) R_SetupSky( cl.refdef.movevars->skyName ); // clear out efrags in case the level hasn't been reloaded - // FIXME: is this one short? for( i = 0; i < cl.worldmodel->numleafs; i++ ) cl.worldmodel->leafs[i].efrags = NULL; diff --git a/engine/client/gl_rpart.c b/engine/client/gl_rpart.c index 100495a8..aeb8aa20 100644 --- a/engine/client/gl_rpart.c +++ b/engine/client/gl_rpart.c @@ -23,7 +23,7 @@ PARTICLES MANAGEMENT #define NUMVERTEXNORMALS 162 #define SPARK_COLORCOUNT 9 -#define TRACER_WIDTH 0.5f // FIXME: tune this +#define TRACER_WIDTH 0.5f #define SIMSHIFT 10 // particle velocities @@ -1421,7 +1421,7 @@ void CL_SparkShower( const vec3_t org ) pos[1] = org[1] + Com_RandomFloat( -2.0f, 2.0f ); pos[2] = org[2] + Com_RandomFloat( -2.0f, 2.0f ); - pmodel = CM_ClipHandleToModel( CL_FindModelIndex( "sprites/richo1.spr" )); + pmodel = Mod_Handle( CL_FindModelIndex( "sprites/richo1.spr" )); CL_RicochetSprite( pos, pmodel, 0.0f, Com_RandomFloat( 0.4, 0.6f )); // create a 8 random spakle tracers diff --git a/engine/client/gl_rsurf.c b/engine/client/gl_rsurf.c index 75c12a32..88544f0c 100644 --- a/engine/client/gl_rsurf.c +++ b/engine/client/gl_rsurf.c @@ -998,7 +998,6 @@ void R_DrawBrushModel( cl_entity_t *e ) case kRenderTransTexture: case kRenderTransInverse: need_sort = true; - case kRenderTransAlpha: case kRenderGlow: pglColor4ub( 255, 255, 255, e->curstate.renderamt ); break; @@ -1007,7 +1006,8 @@ void R_DrawBrushModel( cl_entity_t *e ) pglColor4ub( e->curstate.rendercolor.r, e->curstate.rendercolor.g, e->curstate.rendercolor.b, e->curstate.renderamt ); break; - default: + case kRenderTransAlpha: + default: pglColor4ub( 255, 255, 255, 255 ); break; } @@ -1530,7 +1530,7 @@ void GL_BuildLightmaps( void ) for( i = 1; i < MAX_MODELS; i++ ) { - if(( m = CM_ClipHandleToModel( i )) == NULL ) + if(( m = Mod_Handle( i )) == NULL ) continue; if( m->name[0] == '*' || m->type != mod_brush ) @@ -1574,7 +1574,7 @@ void GL_BuildLightmaps( void ) r_lightmap.height = BLOCK_HEIGHT; r_lightmap.type = PF_RGBA_32; r_lightmap.size = r_lightmap.width * r_lightmap.height * 4; - r_lightmap.flags = IMAGE_HAS_COLOR; // FIXME: detecting grayscale lightmaps for quake1 + r_lightmap.flags = ( world.version == Q1BSP_VERSION ) ? 0 : IMAGE_HAS_COLOR; r_lightmap.buffer = (byte *)&r_lmState.lightmaps[r_lightmap.size*i]; tr.lightmapTextures[i] = GL_LoadTextureInternal( lmName, &r_lightmap, TF_FONT|TF_LIGHTMAP, false ); GL_SetTextureType( tr.lightmapTextures[i], TEX_LIGHTMAP ); diff --git a/engine/client/gl_studio.c b/engine/client/gl_studio.c index d1f4e898..ef7b371d 100644 --- a/engine/client/gl_studio.c +++ b/engine/client/gl_studio.c @@ -949,7 +949,6 @@ void R_StudioCalcRotations( cl_entity_t *e, float pos[][3], vec4_t *q, mstudiose if( pseqdesc->motiontype & STUDIO_Y ) pos[pseqdesc->motionbone][1] = 0.0f; if( pseqdesc->motiontype & STUDIO_Z ) pos[pseqdesc->motionbone][2] = 0.0f; - // FIXME: enable this ? Half-Life 2 get rid of this code s = 0 * ((1.0f - (f - (int)(f))) / (pseqdesc->numframes)) * e->curstate.framerate; if( pseqdesc->motiontype & STUDIO_LX ) pos[pseqdesc->motionbone][0] += s * pseqdesc->linearmovement[0]; @@ -1278,8 +1277,6 @@ static void R_StudioCalcAttachments( void ) VectorSubtract( localOrg, bonepos, forward ); // make forward VectorNormalizeFast( forward ); VectorAngles( forward, localAng ); - - // FIXME: store attachment angles } } @@ -1561,7 +1558,6 @@ void R_StudioLighting( float *lv, int bone, int flags, vec3_t normal ) =============== R_StudioSetupSkin -FIXME: this is correct ? =============== */ static void R_StudioSetupSkin( mstudiotexture_t *ptexture, int index ) @@ -1626,7 +1622,6 @@ static void R_StudioDrawPoints( void ) { R_StudioLighting( lv, *pnormbone, flags, (float *)pstudionorms ); - // FIXME: move this check out of the inner loop if(( flags & STUDIO_NF_CHROME ) || ( g_nFaceFlags & STUDIO_NF_CHROME )) R_StudioSetupChrome( g_chrome[(float (*)[3])lv - g_lightvalues], *pnormbone, (float *)pstudionorms ); } @@ -1719,7 +1714,7 @@ R_StudioDrawHulls */ static void R_StudioDrawHulls( void ) { - // FIXME: implement + // TODO: implement } /* @@ -1774,7 +1769,7 @@ R_StudioDrawBones */ static void R_StudioDrawBones( void ) { - // FIXME: implement + // TODO: implement } static void R_StudioDrawAttachments( void ) @@ -1830,7 +1825,7 @@ R_StudioSetRemapColors */ void R_StudioSetRemapColors( int top, int bottom ) { - // FIXME: implement + // TODO: implement } /* @@ -2038,7 +2033,7 @@ R_StudioSetChromeOrigin */ void R_StudioSetChromeOrigin( void ) { - // FIXME: implement + // TODO: implement } /* @@ -2066,7 +2061,7 @@ static void GL_StudioDrawShadow( void ) // this code is for HL compatibility. return; - // FIXME: implement + // TODO: implement MsgDev( D_INFO, "GL_StudioDrawShadow()\n" ); // just a debug } @@ -2417,7 +2412,7 @@ static int R_StudioDrawPlayer( int flags, entity_state_t *pplayer ) if( pplayer->weaponmodel ) { cl_entity_t saveent = *RI.currententity; - model_t *pweaponmodel = CM_ClipHandleToModel( pplayer->weaponmodel ); + model_t *pweaponmodel = Mod_Handle( pplayer->weaponmodel ); m_pStudioHeader = (studiohdr_t *)Mod_Extradata( pweaponmodel ); @@ -2788,7 +2783,7 @@ static engine_studio_api_t gStudioAPI = Mod_LoadCacheFile, Mod_ForName, Mod_Extradata, - CM_ClipHandleToModel, + Mod_Handle, pfnGetCurrentEntity, pfnPlayerInfo, R_StudioGetPlayerState, diff --git a/engine/client/gl_vidnt.c b/engine/client/gl_vidnt.c index dc88ade7..28baec7b 100644 --- a/engine/client/gl_vidnt.c +++ b/engine/client/gl_vidnt.c @@ -714,7 +714,7 @@ static int VID_ChoosePFD( PIXELFORMATDESCRIPTOR *pfd, int colorBits, int alphaBi pfd->dwVisibleMask = 0; pfd->dwDamageMask = 0; - // Count PFDs + // count PFDs if( glw_state.minidriver ) pixelFormat = pwglChoosePixelFormat( glw_state.hDC, pfd ); else pixelFormat = ChoosePixelFormat( glw_state.hDC, pfd ); @@ -1242,7 +1242,8 @@ qboolean R_Init_OpenGL( void ) Sys_LoadLibrary( NULL, &opengl_dll ); // load opengl32.dll if( !opengl_dll.link ) return false; - glw_state.minidriver = false; // FIXME: allow 3dfx drivers too + // TODO: allow 3dfx drivers too + glw_state.minidriver = false; return VID_SetMode(); } diff --git a/engine/common/cm_local.h b/engine/common/cm_local.h index c2f4db52..4c10cf4a 100644 --- a/engine/common/cm_local.h +++ b/engine/common/cm_local.h @@ -96,6 +96,6 @@ void Mod_AmbientLevels( const vec3_t p, byte *pvolumes ); byte *Mod_CompressVis( const byte *in, size_t *size ); byte *Mod_DecompressVis( const byte *in ); modtype_t Mod_GetType( int handle ); -model_t *CM_ClipHandleToModel( int handle ); +model_t *Mod_Handle( int handle ); #endif//CM_LOCAL_H \ No newline at end of file diff --git a/engine/common/console.c b/engine/common/console.c index 19bfa2ff..925d152b 100644 --- a/engine/common/console.c +++ b/engine/common/console.c @@ -644,12 +644,12 @@ void Con_Print( const char *txt ) void Con_NPrintf( int idx, char *fmt, ... ) { - // FIXME: implement + // TODO: implement } void Con_NXPrintf( con_nprint_t *info, char *fmt, ... ) { - // FIXME: imeplemnt + // TODO: imeplemnt } /* diff --git a/engine/common/engfuncs.c b/engine/common/engfuncs.c index dda78098..2abf180f 100644 --- a/engine/common/engfuncs.c +++ b/engine/common/engfuncs.c @@ -377,7 +377,7 @@ int pfnAddCommand( const char *cmd_name, xcommand_t func ) return 0; // NOTE: if( func == NULL ) cmd will be forwarded to a server - Cmd_AddCommand( cmd_name, func, "" ); + Cmd_AddCommand( cmd_name, func, "game command" ); return 1; } diff --git a/engine/common/host.c b/engine/common/host.c index 42ee01df..805296b5 100644 --- a/engine/common/host.c +++ b/engine/common/host.c @@ -315,35 +315,6 @@ void Host_EventLoop( void ) } } -/* -=================== -Host_RestartAmbientSounds - -Restarts the sounds to let demo writing them -=================== -*/ -void Host_RestartAmbientSounds( void ) -{ - soundlist_t soundInfo[100]; - int i, nSounds; - - if( !SV_Active( )) return; - - nSounds = S_GetCurrentStaticSounds( soundInfo, 100 ); - - for( i = 0; i < nSounds; i++) - { - if( soundInfo[i].looping && soundInfo[i].entnum != -1 ) - { - S_StopSound( soundInfo[i].entnum, CHAN_STATIC, soundInfo[i].name ); - - // FIXME: replace with SV_StartAmbientSound - SV_StartSound( pfnPEntityOfEntIndex( soundInfo[i].entnum ), CHAN_STATIC, - soundInfo[i].name, soundInfo[i].volume, soundInfo[i].attenuation, 0, soundInfo[i].pitch ); - } - } -} - /* =================== Host_FilterTime diff --git a/engine/common/input.c b/engine/common/input.c index 2a223043..16b56866 100644 --- a/engine/common/input.c +++ b/engine/common/input.c @@ -471,9 +471,9 @@ long IN_WndProc( void *hWnd, uint uMsg, uint wParam, long lParam ) else fActivate = true; // video sucessfully restarted wnd_caption = GetSystemMetrics( SM_CYCAPTION ) + WND_BORDER; - S_Activate( fActivate, host.hWnd ); - Key_ClearStates(); // FIXME!!! + S_Activate( fActivate, host.hWnd ); + Key_ClearStates(); VGui_SetBounds(); if( host.state == HOST_FRAME ) diff --git a/engine/common/model.c b/engine/common/model.c index b4cfecc9..49bfb42c 100644 --- a/engine/common/model.c +++ b/engine/common/model.c @@ -309,7 +309,6 @@ qboolean Mod_BoxVisible( const vec3_t mins, const vec3_t maxs, const byte *visbi if( !visbits || !mins || !maxs ) return true; - // FIXME: Could save a loop here by traversing the tree in this routine like the code above count = Mod_BoxLeafnums( mins, maxs, leafList, MAX_BOX_LEAFS, NULL ); for( i = 0; i < count; i++ ) @@ -1294,7 +1293,7 @@ void Mod_CalcPHS( void ) // NOTE: first leaf is skipped becuase is a outside leaf. Now all leafs have shift up by 1. // and last leaf (which equal worldmodel->numleafs) has no visdata! Add extra one leaf - // to avoid this situation. FIXME: this is need to be detail tested + // to avoid this situation. num = worldmodel->numleafs + 1; rowwords = (num + 31)>>5; rowbytes = rowwords * 4; @@ -1492,7 +1491,7 @@ static void Mod_LoadBrushModel( model_t *mod, const void *buffer ) loadmodel->numframes = 2; // regular and alternate animation - // set up the submodels (FIXME: this is confusing) + // set up the submodels for( i = 0; i < mod->numsubmodels; i++ ) { bm = &mod->submodels[i]; @@ -1761,7 +1760,7 @@ Mod_GetType */ modtype_t Mod_GetType( int handle ) { - model_t *mod = CM_ClipHandleToModel( handle ); + model_t *mod = Mod_Handle( handle ); if( !mod ) return mod_bad; return mod->type; @@ -1774,7 +1773,7 @@ Mod_GetFrames */ void Mod_GetFrames( int handle, int *numFrames ) { - model_t *mod = CM_ClipHandleToModel( handle ); + model_t *mod = Mod_Handle( handle ); if( !numFrames ) return; if( !mod ) @@ -1797,7 +1796,7 @@ void Mod_GetBounds( int handle, vec3_t mins, vec3_t maxs ) model_t *cmod; if( handle <= 0 ) return; - cmod = CM_ClipHandleToModel( handle ); + cmod = Mod_Handle( handle ); if( cmod ) { @@ -1903,16 +1902,15 @@ void *Mod_Extradata( model_t *mod ) /* ================== -CM_ClipHandleToModel +Mod_Handle -FIXME: rename to Mod_Handle ================== */ -model_t *CM_ClipHandleToModel( int handle ) +model_t *Mod_Handle( int handle ) { if( handle < 0 || handle > MAX_MODELS ) { - Host_Error( "CM_ClipHandleToModel: bad handle #%i\n", handle ); + Host_Error( "Mod_Handle: bad handle #%i\n", handle ); return NULL; } return com_models[handle]; diff --git a/engine/common/net_buffer.c b/engine/common/net_buffer.c index 0c891356..ac2e25b8 100644 --- a/engine/common/net_buffer.c +++ b/engine/common/net_buffer.c @@ -375,12 +375,6 @@ void BF_WriteBitVec3Normal( sizebuf_t *bf, const float *fa ) BF_WriteOneBit( bf, signbit ); } -void BF_WriteBitAngles( sizebuf_t *bf, const float *fa ) -{ - // FIXME: uses WriteBitAngle instead ? - BF_WriteBitVec3Coord( bf, fa ); -} - void BF_WriteChar( sizebuf_t *bf, int val ) { BF_WriteSBitLong( bf, val, sizeof( char ) << 3 ); diff --git a/engine/common/net_buffer.h b/engine/common/net_buffer.h index 97ab2155..c3068c47 100644 --- a/engine/common/net_buffer.h +++ b/engine/common/net_buffer.h @@ -69,7 +69,6 @@ void BF_WriteBitFloat( sizebuf_t *bf, float val ); void BF_WriteBitVec3Coord( sizebuf_t *bf, const float *fa ); void BF_WriteBitNormal( sizebuf_t *bf, float f ); void BF_WriteBitVec3Normal( sizebuf_t *bf, const float *fa ); -void BF_WriteBitAngles( sizebuf_t *bf, const float *fa ); // Byte-write functions void BF_WriteChar( sizebuf_t *bf, int val ); diff --git a/engine/common/pm_studio.c b/engine/common/pm_studio.c index 8717b090..83b542b2 100644 --- a/engine/common/pm_studio.c +++ b/engine/common/pm_studio.c @@ -91,7 +91,6 @@ static void PM_StudioSetUpTransform( physent_t *pe, qboolean allow_scale ) if( allow_scale && pe->fuser1 > 0.0f ) scale = pe->fuser1; - // FIXME: apply scale to studiomodels Matrix3x4_CreateFromEntity( pm_studiomatrix, ang, pe->origin, scale ); } @@ -101,7 +100,7 @@ StudioCalcBoneAdj ==================== */ -static void PM_StudioCalcBoneAdj( float dadt, float *adj, const byte *pcontroller1, const byte *pcontroller2 ) +static void PM_StudioCalcBoneAdj( float *adj, const byte *pcontroller ) { int i, j; float value; @@ -119,25 +118,14 @@ static void PM_StudioCalcBoneAdj( float dadt, float *adj, const byte *pcontrolle // check for 360% wrapping if( pbonecontroller[j].type & STUDIO_RLOOP ) { - if( abs( pcontroller1[i] - pcontroller2[i] ) > 128 ) - { - int a, b; - - a = (pcontroller1[j] + 128) % 256; - b = (pcontroller2[j] + 128) % 256; - value = ((a * dadt) + (b * (1 - dadt)) - 128) * (360.0/256.0) + pbonecontroller[j].start; - } - else - { - value = ((pcontroller1[i] * dadt + (pcontroller2[i]) * (1.0 - dadt))) * (360.0/256.0) + pbonecontroller[j].start; - } + value = pcontroller[i] * (360.0/256.0) + pbonecontroller[j].start; } else { - value = (pcontroller1[i] * dadt + pcontroller2[i] * (1.0 - dadt)) / 255.0; - if( value < 0 ) value = 0; - if( value > 1.0 ) value = 1.0; - value = (1.0 - value) * pbonecontroller[j].start + value * pbonecontroller[j].end; + value = pcontroller[i] / 255.0f; + if( value < 0.0f ) value = 0.0f; + if( value > 1.0f ) value = 1.0f; + value = (1.0f - value) * pbonecontroller[j].start + value * pbonecontroller[j].end; } } @@ -324,7 +312,7 @@ static void PM_StudioCalcRotations( physent_t *pe, float pos[][3], vec4_t *q, ms int i, frame; mstudiobone_t *pbone; float adj[MAXSTUDIOCONTROLLERS]; - float s, dadt = 1.0f; // noInterp + float s; if( f > pseqdesc->numframes - 1 ) f = 0; @@ -337,7 +325,7 @@ static void PM_StudioCalcRotations( physent_t *pe, float pos[][3], vec4_t *q, ms // add in programtic controllers pbone = (mstudiobone_t *)((byte *)pm_studiohdr + pm_studiohdr->boneindex); - PM_StudioCalcBoneAdj( dadt, adj, pe->controller, pe->controller ); + PM_StudioCalcBoneAdj( adj, pe->controller ); for( i = 0; i < pm_studiohdr->numbones; i++, pbone++, panim++ ) { @@ -499,12 +487,11 @@ static void PM_StudioSetupBones( physent_t *pe ) if( pseqdesc->numblends > 1 ) { float s; - float dadt = 1.0f; panim += pm_studiohdr->numbones; PM_StudioCalcRotations( pe, pos2, q2, pseqdesc, panim, f ); - s = (pe->blending[0] * dadt + pe->blending[0] * ( 1.0f - dadt )) / 255.0f; + s = (float)pe->blending[0] / 255.0f; PM_StudioSlerpBones( q, pos, q2, pos2, s ); @@ -516,10 +503,10 @@ static void PM_StudioSetupBones( physent_t *pe ) panim += pm_studiohdr->numbones; PM_StudioCalcRotations( pe, pos4, q4, pseqdesc, panim, f ); - s = ( pe->blending[0] * dadt + pe->blending[0] * ( 1.0f - dadt )) / 255.0f; + s = (float)pe->blending[0] / 255.0f; PM_StudioSlerpBones( q3, pos3, q4, pos4, s ); - s = ( pe->blending[1] * dadt + pe->blending[1] * ( 1.0f - dadt )) / 255.0f; + s = (float)pe->blending[1] / 255.0f; PM_StudioSlerpBones( q, pos, q3, pos3, s ); } } diff --git a/engine/common/protocol.h b/engine/common/protocol.h index 18308480..efec677e 100644 --- a/engine/common/protocol.h +++ b/engine/common/protocol.h @@ -67,10 +67,9 @@ #define clc_stringcmd 3 // [string] message #define clc_delta 4 // [byte] sequence number, requests delta compression of message #define clc_resourcelist 5 -#define clc_userinfo 6 // [[userinfo string] // FIXME: remove +#define clc_userinfo 6 // [[userinfo string] #define clc_fileconsistency 7 #define clc_voicedata 8 -#define clc_random_seed 9 // [long] random seed // FIXME: remove #define MAX_VISIBLE_PACKET 512 // 512 visible entities per frame (hl1 has 256) @@ -93,7 +92,6 @@ #define MAX_CUSTOM 1024 // max custom resources per level #define MAX_USER_MESSAGES 191 // another 63 messages reserved for engine routines - // FIXME: tune this #define MAX_DLIGHTS 32 // dynamic lights (rendered per one frame) #define MAX_ELIGHTS 64 // entity only point lights diff --git a/engine/common/vgui_int.cpp b/engine/common/vgui_int.cpp index 3f23f9fb..d34a128a 100644 --- a/engine/common/vgui_int.cpp +++ b/engine/common/vgui_int.cpp @@ -265,7 +265,6 @@ void VGui_ViewportPaintBackground( int extents[4] ) { if( !rootpanel ) return; - Msg( "ViewportPaintBackground()\n" ); Panel *pVPanel = surface->getPanel(); if( !pVPanel ) return; diff --git a/engine/server/server.h b/engine/server/server.h index 5c53cb49..70a5d453 100644 --- a/engine/server/server.h +++ b/engine/server/server.h @@ -156,6 +156,7 @@ typedef struct sv_client_s qboolean local_weapons; // enable weapon predicting qboolean lag_compensation; // enable lag compensation qboolean hltv_proxy; // this is spectator proxy (hltv) + qboolean spectator; // this is spectator (not a real client) netchan_t netchan; int chokecount; // number of messages rate supressed @@ -175,7 +176,6 @@ typedef struct sv_client_s qboolean fakeclient; // This client is a fake player controlled by the game DLL - int random_seed; // fpr predictable random values usercmd_t lastcmd; // for filling in big drops double last_cmdtime; @@ -502,7 +502,7 @@ void SV_PlaybackEventFull( int flags, const edict_t *pInvoker, word eventindex, void SV_PlaybackEvent( sizebuf_t *msg, event_info_t *info ); void SV_BaselineForEntity( edict_t *pEdict ); void SV_WriteEntityPatch( const char *filename ); -script_t *SV_GetEntityScript( const char *filename, int *flags ); +script_t *SV_ReadEntityScript( const char *filename, int *flags ); float SV_AngleMod( float ideal, float current, float speed ); void SV_SpawnEntities( const char *mapname, script_t *entities ); edict_t* SV_AllocPrivateData( edict_t *ent, string_t className ); @@ -547,11 +547,6 @@ void SV_StudioGetAttachment( edict_t *e, int iAttachment, float *org, float *ang trace_t SV_TraceHitbox( edict_t *ent, const vec3_t start, vec3_t mins, vec3_t maxs, const vec3_t end ); void SV_GetBonePosition( edict_t *e, int iBone, float *org, float *ang ); -// -// sv_pmove.c -// -qboolean SV_CopyEdictToPhysEnt( physent_t *pe, edict_t *ed, qboolean player_trace ); - // // sv_world.c // diff --git a/engine/server/sv_client.c b/engine/server/sv_client.c index 54286fec..4c7398c3 100644 --- a/engine/server/sv_client.c +++ b/engine/server/sv_client.c @@ -8,7 +8,7 @@ #include "server.h" #include "net_encode.h" -const char *clc_strings[10] = +const char *clc_strings[9] = { "clc_bad", "clc_nop", @@ -19,7 +19,6 @@ const char *clc_strings[10] = "clc_userinfo", "clc_fileconsistency", "clc_voicedata", - "clc_random_seed", }; typedef struct ucmd_s @@ -82,10 +81,11 @@ A connection request that did not come from the master */ void SV_DirectConnect( netadr_t from ) { - char physinfo[512]; + char *s, physinfo[512]; char userinfo[MAX_INFO_STRING]; sv_client_t temp, *cl, *newcl; edict_t *ent; + qboolean spectator = false; int i, edictnum; int qport, version; int count = 0; @@ -147,6 +147,15 @@ void SV_DirectConnect( netadr_t from ) newcl = &temp; Mem_Set( newcl, 0, sizeof( sv_client_t )); + // check for spectators + s = Info_ValueForKey( userinfo, "spectator" ); + + if( s && com.strcmp( s, "0" ) && sv_maxclients->integer > 1 ) + { + // FXIME: we can create listen server with spectator instead of client ? + spectator = true; + } + // if there is already a slot for this ip, reuse it for( i = 0, cl = svs.clients; i < sv_maxclients->integer; i++, cl++ ) { @@ -177,9 +186,9 @@ void SV_DirectConnect( netadr_t from ) return; } -gotnewcl: // build a new connection // accept the new client +gotnewcl: // this is the only place a sv_client_t is ever initialized if( sv_maxclients->integer == 1 ) // save physinfo for singleplayer com.strncpy( physinfo, newcl->physinfo, sizeof( physinfo )); @@ -197,6 +206,7 @@ gotnewcl: newcl->challenge = challenge; // save challenge for checksumming newcl->frames = (client_frame_t *)Z_Malloc( sizeof( client_frame_t ) * SV_UPDATE_BACKUP ); newcl->userid = g_userid++; // create unique userid + newcl->spectator = spectator; // get the game a chance to reject this connection or modify the userinfo if( !( SV_ClientConnect( ent, userinfo ))) @@ -361,7 +371,7 @@ void SV_DropClient( sv_client_t *drop ) } // let the game known about client state - if( drop->edict->v.flags & FL_SPECTATOR ) + if( drop->spectator ) svgame.dllFuncs.pfnSpectatorDisconnect( drop->edict ); else svgame.dllFuncs.pfnClientDisconnect( drop->edict ); @@ -868,7 +878,7 @@ void SV_PutClientInServer( edict_t *ent ) if( !sv.loadgame ) { - if( ent->v.flags & FL_SPECTATOR ) + if( client->spectator ) { svgame.globals->time = sv.time; svgame.dllFuncs.pfnSpectatorConnect( ent ); @@ -993,7 +1003,7 @@ void SV_New_f( sv_client_t *cl ) BF_WriteLong( &cl->netchan.message, PROTOCOL_VERSION ); BF_WriteLong( &cl->netchan.message, svs.spawncount ); BF_WriteLong( &cl->netchan.message, sv.checksum ); - BF_WriteByte( &cl->netchan.message, playernum ); + BF_WriteByte( &cl->netchan.message, playernum|( cl->spectator ? 128 : 0 )); BF_WriteByte( &cl->netchan.message, svgame.globals->maxClients ); BF_WriteWord( &cl->netchan.message, svgame.globals->maxEntities ); BF_WriteString( &cl->netchan.message, sv.name ); @@ -1490,7 +1500,7 @@ void SV_Pause_f( sv_client_t *cl ) return; } - if( cl->edict->v.flags & FL_SPECTATOR ) + if( cl->spectator ) { SV_ClientPrintf( cl, PRINT_HIGH, "Spectators can not pause.\n" ); return; @@ -1729,7 +1739,7 @@ void SV_ConnectionlessPacket( netadr_t from, sizebuf_t *msg ) /* ================== -SV_ReadClientMove +SV_ParseClientMove The message usually contains all the movement commands that were in the last three packets, so that the information @@ -1739,61 +1749,6 @@ On very fast clients, there may be multiple usercmd packed into each of the backup packets. ================== */ -static void SV_ReadClientMove( sv_client_t *cl, sizebuf_t *msg ) -{ - int key, size; - int checksum1, checksum2; - usercmd_t oldest, oldcmd, newcmd, nulcmd; - - key = BF_GetNumBytesRead( msg ); - checksum1 = BF_ReadByte( msg ); - - cl->packet_loss = SV_CalcPacketLoss( cl ); - - Mem_Set( &nulcmd, 0, sizeof( nulcmd )); - MSG_ReadDeltaUsercmd( msg, &nulcmd, &oldest ); - MSG_ReadDeltaUsercmd( msg, &oldest, &oldcmd ); - MSG_ReadDeltaUsercmd( msg, &oldcmd, &newcmd ); - - if( cl->state != cs_spawned ) - { - cl->delta_sequence = -1; - return; - } - - // if the checksum fails, ignore the rest of the packet - size = BF_GetNumBytesRead( msg ) - key - 1; - checksum2 = CRC32_Sequence( BF_GetData( msg ) + key + 1, size, cl->netchan.incoming_sequence ); - if( checksum2 != checksum1 ) - { - MsgDev( D_ERROR, "SV_UserMove: failed command checksum for %s (%d != %d)\n", cl->name, checksum2, checksum1 ); - return; - } - - if( !sv.paused ) - { - SV_PreRunCmd( cl, &newcmd, cl->random_seed ); // get random_seed from newcmd - - if( net_drop < 20 ) - { - while( net_drop > 2 ) - { - SV_RunCmd( cl, &cl->lastcmd, cl->random_seed ); - net_drop--; - } - - if( net_drop > 1 ) SV_RunCmd( cl, &oldest, cl->random_seed ); - if( net_drop > 0 ) SV_RunCmd( cl, &oldcmd, cl->random_seed ); - - } - SV_RunCmd( cl, &newcmd, cl->random_seed ); - SV_PostRunCmd( cl ); - } - - cl->lastcmd = newcmd; - cl->lastcmd.buttons = 0; // avoid multiple fires on lag -} - static void SV_ParseClientMove( sv_client_t *cl, sizebuf_t *msg ) { client_frame_t *frame; @@ -1984,7 +1939,6 @@ void SV_ExecuteClientMessage( sv_client_t *cl, sizebuf_t *msg ) case clc_move: if( move_issued ) return; // someone is trying to cheat... move_issued = true; -// SV_ReadClientMove( cl, msg ); SV_ParseClientMove( cl, msg ); break; case clc_stringcmd: @@ -1993,9 +1947,6 @@ void SV_ExecuteClientMessage( sv_client_t *cl, sizebuf_t *msg ) if( ++stringCmdCount < 8 ) SV_ExecuteClientCommand( cl, s ); if( cl->state == cs_zombie ) return; // disconnect command break; - case clc_random_seed: - cl->random_seed = BF_ReadUBitLong( msg, 32 ); - break; default: MsgDev( D_ERROR, "SV_ReadClientMessage: clc_bad\n" ); SV_DropClient( cl ); diff --git a/engine/server/sv_custom.c b/engine/server/sv_custom.c index 80fd4df7..2eddb78e 100644 --- a/engine/server/sv_custom.c +++ b/engine/server/sv_custom.c @@ -21,13 +21,13 @@ typedef struct int CustomDecal_Init( cachewad_t *wad, byte *data, int size, int playernum ) { - // FIXME: implement + // TODO: implement return 0; } void *CustomDecal_Validate( byte *data, int size ) { - // FIXME: implement + // TODO: implement return NULL; } diff --git a/engine/server/sv_frame.c b/engine/server/sv_frame.c index 51112dd5..3039d6ce 100644 --- a/engine/server/sv_frame.c +++ b/engine/server/sv_frame.c @@ -782,7 +782,7 @@ void SV_InactivateClients( void ) { if( !cl->state || !cl->edict ) continue; - if( !cl->edict || (cl->edict->v.flags & ( FL_FAKECLIENT|FL_SPECTATOR ))) + if( !cl->edict || (cl->edict->v.flags & FL_FAKECLIENT)) continue; if( svs.clients[i].state > cs_connected ) diff --git a/engine/server/sv_game.c b/engine/server/sv_game.c index 7b25c62f..e3397e87 100644 --- a/engine/server/sv_game.c +++ b/engine/server/sv_game.c @@ -475,7 +475,7 @@ void SV_WriteEntityPatch( const char *filename ) FS_Close( f ); } -script_t *SV_GetEntityScript( const char *filename, int *flags ) +script_t *SV_ReadEntityScript( const char *filename, int *flags ) { file_t *f; dheader_t *header; @@ -542,7 +542,7 @@ int SV_MapIsValid( const char *filename, const char *spawn_entity, const char *l script_t *ents = NULL; int flags = 0; - ents = SV_GetEntityScript( filename, &flags ); + ents = SV_ReadEntityScript( filename, &flags ); if( ents ) { @@ -742,7 +742,7 @@ void SV_PlaybackEvent( sizebuf_t *msg, event_info_t *info ) BF_WriteWord( msg, info->index ); // send event index BF_WriteWord( msg, (int)( info->fire_time * 100.0f )); // send event delay - MSG_WriteDeltaEvent( msg, &nullargs, &info->args ); // FIXME: zero-compressing + MSG_WriteDeltaEvent( msg, &nullargs, &info->args ); // TODO: delta-compressing } const char *SV_ClassName( const edict_t *e ) @@ -1950,7 +1950,7 @@ trace sphere instead of bbox */ void pfnTraceSphere( const float *v1, const float *v2, int fNoMonsters, float radius, edict_t *pentToSkip, TraceResult *ptr ) { - // FIXME: implement + // never was implemented in GoldSrc } /* @@ -1968,7 +1968,7 @@ static int pfnBoxVisible( const float *mins, const float *maxs, const byte *pset ============= pfnGetAimVector -FIXME: use speed for reduce aiming accuracy +NOTE: speed is unused ============= */ void pfnGetAimVector( edict_t* ent, float speed, float *rgflReturn ) @@ -2750,7 +2750,7 @@ static void *pfnGetModelPtr( edict_t *pEdict ) if( !SV_IsValidEdict( pEdict )) return NULL; - mod = CM_ClipHandleToModel( pEdict->v.modelindex ); + mod = Mod_Handle( pEdict->v.modelindex ); return Mod_Extradata( mod ); } @@ -3240,6 +3240,7 @@ void pfnRunPlayerMove( edict_t *pClient, const float *v_angle, float fmove, floa { sv_client_t *cl; usercmd_t cmd; + uint seed; if( sv.paused ) return; @@ -3261,10 +3262,10 @@ void pfnRunPlayerMove( edict_t *pClient, const float *v_angle, float fmove, floa cmd.impulse = impulse; cmd.msec = msec; - cl->random_seed = Com_RandomLong( 0, 0x7fffffff ); // full range + seed = Com_RandomLong( 0, 0x7fffffff ); // full range - SV_PreRunCmd( cl, &cmd, cl->random_seed ); - SV_RunCmd( cl, &cmd, cl->random_seed ); + SV_PreRunCmd( cl, &cmd, seed ); + SV_RunCmd( cl, &cmd, seed ); SV_PostRunCmd( cl ); cl->lastcmd = cmd; diff --git a/engine/server/sv_init.c b/engine/server/sv_init.c index 5bb04e7a..b8e334e3 100644 --- a/engine/server/sv_init.c +++ b/engine/server/sv_init.c @@ -148,7 +148,6 @@ int SV_GenericIndex( const char *name ) SV_EntityScript get entity script for current map -FIXME: merge with SV_GetEntityScript ================ */ script_t *SV_EntityScript( void ) @@ -462,7 +461,7 @@ qboolean SV_SpawnServer( const char *mapname, const char *startspot ) com.snprintf( sv.model_precache[1], sizeof( sv.model_precache[0] ), "maps/%s.bsp", sv.name ); Mod_LoadWorld( sv.model_precache[1], &sv.checksum ); - sv.worldmodel = CM_ClipHandleToModel( 1 ); // get world pointer + sv.worldmodel = Mod_Handle( 1 ); // get world pointer for( i = 1; i < sv.worldmodel->numsubmodels; i++ ) { diff --git a/engine/server/sv_pmove.c b/engine/server/sv_pmove.c index c421e14f..af791fff 100644 --- a/engine/server/sv_pmove.c +++ b/engine/server/sv_pmove.c @@ -23,17 +23,11 @@ void SV_CopyPmtraceToGlobal( pmtrace_t *trace ) svgame.globals->trace_hitgroup = trace->hitgroup; } -qboolean SV_CopyEdictToPhysEnt( physent_t *pe, edict_t *ed, qboolean player_trace ) +qboolean SV_CopyEdictToPhysEnt( physent_t *pe, edict_t *ed ) { - model_t *mod = CM_ClipHandleToModel( ed->v.modelindex ); + model_t *mod = Mod_Handle( ed->v.modelindex ); - // NOTE: player never collide with sprites (even with solid sprites) - if( !mod || mod->type == mod_bad || mod->type == mod_sprite ) - return false; - - // this is monsterclip brush, player ignore it - if( player_trace && mod->type == mod_brush && ed->v.flags & FL_MONSTERCLIP ) - return false; + if( !mod ) return false; pe->player = false; @@ -121,23 +115,48 @@ void SV_AddLinksToPmove( areanode_t *node, const vec3_t pmove_mins, const vec3_t next = l->next; check = EDICT_FROM_AREA( l ); - if( check == pl || check->v.owner == pl ) + if( check->v.groupinfo != 0 ) + { + if(( !svs.groupop && (check->v.groupinfo & pl->v.groupinfo ) == 0) || + ( svs.groupop == 1 && ( check->v.groupinfo & pl->v.groupinfo ) != 0 )) + continue; + } + + if( check->v.owner == pl || check->v.solid == SOLID_TRIGGER ) continue; // player or player's own missile - if( check->v.deadflag == DEAD_DEAD ) - continue; - - if( check->v.solid == SOLID_BSP || check->v.solid == SOLID_BBOX || check->v.solid == SOLID_SLIDEBOX ) + if( svgame.pmove->numvisent < MAX_PHYSENTS ) { - if( !BoundsIntersect( pmove_mins, pmove_maxs, check->v.absmin, check->v.absmax )) - continue; + pe = &svgame.pmove->visents[svgame.pmove->numvisent]; + if( SV_CopyEdictToPhysEnt( pe, check )) + svgame.pmove->numvisent++; + } - if( svgame.pmove->numphysent == MAX_PHYSENTS ) - return; + if( check->v.solid == SOLID_NOT && ( check->v.skin == 0 || check->v.modelindex == 0 )) + continue; + // ignore monsterclip brushes + if(( check->v.flags & FL_MONSTERCLIP ) && check->v.solid == SOLID_BSP ) + continue; + + if( check == pl ) continue; // himself + + if((( check->v.flags & FL_CLIENT ) && check->v.health <= 0 ) || check->v.deadflag == DEAD_DEAD ) + continue; // dead body + + if( check->v.mins[2] == 0 && check->v.maxs[2] == 1 ) + continue; + + if( VectorIsNull( check->v.size )) continue; + + if( !BoundsIntersect( pmove_mins, pmove_maxs, check->v.absmin, check->v.absmax )) + continue; + + if( svgame.pmove->numphysent < MAX_PHYSENTS ) + { pe = &svgame.pmove->physents[svgame.pmove->numphysent]; - if( SV_CopyEdictToPhysEnt( pe, check, true )) + if( SV_CopyEdictToPhysEnt( pe, check )) svgame.pmove->numphysent++; } } @@ -182,8 +201,7 @@ void SV_AddLaddersToPmove( areanode_t *node, const vec3_t pmove_mins, const vec3 return; pe = &svgame.pmove->moveents[svgame.pmove->nummoveent]; - - if( SV_CopyEdictToPhysEnt( pe, check, true )) + if( SV_CopyEdictToPhysEnt( pe, check )) svgame.pmove->nummoveent++; } @@ -368,7 +386,7 @@ static byte *pfnCOM_LoadFile( const char *path, int usehunk, int *pLength ) static void pfnCOM_FreeFile( void *buffer ) { - Mem_Free( buffer ); + if( buffer ) Mem_Free( buffer ); } static void pfnPlaySound( int channel, const char *sample, float volume, float attenuation, int fFlags, int pitch ) @@ -491,7 +509,7 @@ static void PM_CheckMovingGround( edict_t *ent, float frametime ) ent->v.flags &= ~FL_BASEVELOCITY; } -static void PM_SetupMove( playermove_t *pmove, edict_t *clent, usercmd_t *ucmd, const char *physinfo ) +static void SV_SetupPMove( playermove_t *pmove, edict_t *clent, usercmd_t *ucmd, const char *physinfo ) { vec3_t absmin, absmax; int i; @@ -526,7 +544,7 @@ static void PM_SetupMove( playermove_t *pmove, edict_t *clent, usercmd_t *ucmd, pmove->waterjumptime = clent->v.teleport_time; pmove->dead = (clent->v.health <= 0.0f ) ? true : false; pmove->deadflag = clent->v.deadflag; - pmove->spectator = 0; // FIXME: implement + pmove->spectator = 0; // spectator physic all execute on client pmove->movetype = clent->v.movetype; if( pmove->multiplayer ) pmove->onground = -1; pmove->waterlevel = clent->v.waterlevel; @@ -550,7 +568,7 @@ static void PM_SetupMove( playermove_t *pmove, edict_t *clent, usercmd_t *ucmd, com.strncpy( pmove->physinfo, physinfo, MAX_INFO_STRING ); // setup physents - pmove->numvisent = 0; // FIXME: add visents for debugging + pmove->numvisent = 0; pmove->numphysent = 0; pmove->nummoveent = 0; @@ -560,14 +578,16 @@ static void PM_SetupMove( playermove_t *pmove, edict_t *clent, usercmd_t *ucmd, absmax[i] = clent->v.origin[i] + 256; } - SV_CopyEdictToPhysEnt( &svgame.pmove->physents[0], &svgame.edicts[0], true ); + SV_CopyEdictToPhysEnt( &svgame.pmove->physents[0], &svgame.edicts[0] ); + svgame.pmove->visents[0] = svgame.pmove->physents[0]; svgame.pmove->numphysent = 1; // always have world + svgame.pmove->numvisent = 1; SV_AddLinksToPmove( sv_areanodes, absmin, absmax ); SV_AddLaddersToPmove( sv_areanodes, absmin, absmax ); } -static void PM_FinishMove( playermove_t *pmove, edict_t *clent ) +static void SV_FinishPMove( playermove_t *pmove, edict_t *clent ) { clent->v.teleport_time = pmove->waterjumptime; VectorCopy( pmove->angles, clent->v.v_angle ); @@ -818,7 +838,7 @@ void SV_SetupMoveInterpolant( sv_client_t *cl ) void SV_PreRunCmd( sv_client_t *cl, usercmd_t *ucmd, int random_seed ) { - svgame.pmove->runfuncs = true; // FIXME: check cl_lc ? + svgame.pmove->runfuncs = true; svgame.dllFuncs.pfnCmdStart( cl->edict, ucmd, random_seed ); } @@ -884,7 +904,7 @@ void SV_RunCmd( sv_client_t *cl, usercmd_t *ucmd, int random_seed ) SV_SetMinMaxSize( clent, svgame.pmove->player_mins[1], svgame.pmove->player_maxs[1] ); else SV_SetMinMaxSize( clent, svgame.pmove->player_mins[0], svgame.pmove->player_maxs[0] ); - if(!( clent->v.flags & FL_SPECTATOR )) + if( !cl->spectator ) { svgame.globals->time = sv.time + host.frametime; svgame.dllFuncs.pfnPlayerPreThink( clent ); @@ -899,15 +919,15 @@ void SV_RunCmd( sv_client_t *cl, usercmd_t *ucmd, int random_seed ) ucmd->msec = 0; // pause // setup playermove state - PM_SetupMove( svgame.pmove, clent, ucmd, cl->physinfo ); + SV_SetupPMove( svgame.pmove, clent, ucmd, cl->physinfo ); // motor! svgame.dllFuncs.pfnPM_Move( svgame.pmove, true ); // copy results back to client - PM_FinishMove( svgame.pmove, clent ); + SV_FinishPMove( svgame.pmove, clent ); - if(!( clent->v.flags & FL_SPECTATOR )) + if( !cl->spectator ) { int i; edict_t *touch; @@ -954,7 +974,7 @@ void SV_PostRunCmd( sv_client_t *cl ) svgame.pmove->runfuncs = false; // all next calls ignore footstep sounds // run post-think - if( clent->v.flags & FL_SPECTATOR ) + if( cl->spectator ) svgame.dllFuncs.pfnSpectatorThink( clent ); else svgame.dllFuncs.pfnPlayerPostThink( clent ); diff --git a/engine/server/sv_save.c b/engine/server/sv_save.c index e5f7af72..2463ab54 100644 --- a/engine/server/sv_save.c +++ b/engine/server/sv_save.c @@ -413,8 +413,6 @@ void ReapplyDecal( SAVERESTOREDATA *pSaveData, decallist_t *entry, qboolean adja { entityIndex = pfnIndexOfEdict( tr.ent ); if( entityIndex > 0 ) modelIndex = tr.ent->v.modelindex; - - // FIXME: probably some rotating or moving objects can't receive decal properly SV_CreateDecal( tr.endpos, decalIndex, entityIndex, modelIndex, flags ); } } diff --git a/engine/server/sv_studio.c b/engine/server/sv_studio.c index 87b8f15f..a612c53b 100644 --- a/engine/server/sv_studio.c +++ b/engine/server/sv_studio.c @@ -3,8 +3,6 @@ // sv_studio.c - server studio utilities //======================================================================= -// FIXME: these code needs to be some cleanup from lerping code - #include "common.h" #include "server.h" #include "studio.h" @@ -101,7 +99,7 @@ StudioCalcBoneAdj ==================== */ -static void SV_StudioCalcBoneAdj( float dadt, float *adj, const byte *pcontroller1, const byte *pcontroller2 ) +static void SV_StudioCalcBoneAdj( float *adj, const byte *pcontroller ) { int i, j; float value; @@ -119,22 +117,11 @@ static void SV_StudioCalcBoneAdj( float dadt, float *adj, const byte *pcontrolle // check for 360% wrapping if( pbonecontroller[j].type & STUDIO_RLOOP ) { - if( abs( pcontroller1[i] - pcontroller2[i] ) > 128 ) - { - int a, b; - - a = (pcontroller1[j] + 128) % 256; - b = (pcontroller2[j] + 128) % 256; - value = ((a * dadt) + (b * (1.0f - dadt)) - 128) * (360.0f / 256.0f) + pbonecontroller[j].start; - } - else - { - value = ((pcontroller1[i] * dadt + (pcontroller2[i]) * (1.0 - dadt))) * (360.0/256.0) + pbonecontroller[j].start; - } + value = pcontroller[i] * (360.0/256.0) + pbonecontroller[j].start; } else { - value = (pcontroller1[i] * dadt + pcontroller2[i] * (1.0f - dadt)) / 255.0f; + value = pcontroller[i] / 255.0f; if( value < 0.0f ) value = 0.0f; if( value > 1.0f ) value = 1.0f; value = (1.0f - value) * pbonecontroller[j].start + value * pbonecontroller[j].end; @@ -337,7 +324,7 @@ static void SV_StudioCalcRotations( const edict_t *ent, int boneused[], int numb // add in programtic controllers pbone = (mstudiobone_t *)((byte *)sv_studiohdr + sv_studiohdr->boneindex); - SV_StudioCalcBoneAdj( 1.0f, adj, pcontroller, pcontroller ); + SV_StudioCalcBoneAdj( adj, pcontroller ); for( j = numbones - 1; j >= 0; j-- ) { @@ -527,7 +514,6 @@ static void SV_StudioSetupBones( model_t *pModel, float frame, int sequence, con if( pseqdesc->numblends > 1 ) { float s; - float dadt = 1.0f; panim += sv_studiohdr->numbones; SV_StudioCalcRotations( pEdict, boneused, numbones, pcontroller, pos2, q2, pseqdesc, panim, f ); @@ -570,7 +556,7 @@ StudioSetupModel */ static qboolean SV_StudioSetupModel( edict_t *ent, int iBone ) { - model_t *mod = CM_ClipHandleToModel( ent->v.modelindex ); + model_t *mod = Mod_Handle( ent->v.modelindex ); void *hdr = Mod_Extradata( mod ); if( !hdr ) return false; @@ -821,9 +807,7 @@ static qboolean SV_StudioIntersect( edict_t *ent, const vec3_t start, vec3_t min { vec3_t trace_mins, trace_maxs; vec3_t anim_mins, anim_maxs; - model_t *mod = CM_ClipHandleToModel( ent->v.modelindex ); - - if( !mod ) return false; // FIXME: Xash 0.45 crash at this point (model == NULL) + model_t *mod = Mod_Handle( ent->v.modelindex ); // create the bounding box of the entire move World_MoveBounds( start, mins, maxs, end, trace_mins, trace_maxs ); @@ -933,7 +917,7 @@ void SV_StudioGetAttachment( edict_t *e, int iAttachment, float *org, float *ang vec3_t localOrg, localAng; void *hdr; - hdr = Mod_Extradata( CM_ClipHandleToModel( e->v.modelindex )); + hdr = Mod_Extradata( Mod_Handle( e->v.modelindex )); if( !hdr ) return; sv_studiohdr = (studiohdr_t *)hdr; diff --git a/engine/server/sv_world.c b/engine/server/sv_world.c index 986172d9..5706a488 100644 --- a/engine/server/sv_world.c +++ b/engine/server/sv_world.c @@ -112,7 +112,7 @@ hull_t *SV_HullForEntity( edict_t *ent, int hullNumber, vec3_t mins, vec3_t maxs vec3_t hullmins, hullmaxs; vec3_t size; - model = CM_ClipHandleToModel( ent->v.modelindex ); + model = Mod_Handle( ent->v.modelindex ); // decide which clipping hull to use, based on the size if( model && ( ent->v.solid == SOLID_BSP || ent->v.skin == CONTENTS_LADDER )) @@ -190,7 +190,7 @@ hull_t *SV_HullForEntity( edict_t *ent, int hullNumber, vec3_t mins, vec3_t maxs // hullNumber is force to use hull from brushmodel (even if solid == SOLID_NOT) if( hullNumber != -1 && Mod_GetType( ent->v.modelindex ) == mod_brush ) { - model = CM_ClipHandleToModel( ent->v.modelindex ); + model = Mod_Handle( ent->v.modelindex ); if( !model ) Host_Error( "SV_HullForEntity: using custom hull on bad bsp model\n" ); // TraceHull stuff @@ -229,7 +229,7 @@ hull_t *SV_HullForBsp( edict_t *ent, const vec3_t mins, const vec3_t maxs, float int i = 0, hullNumber = 0; // decide which clipping hull to use, based on the size - model = CM_ClipHandleToModel( ent->v.modelindex ); + model = Mod_Handle( ent->v.modelindex ); if( !model || model->type != mod_brush ) Host_Error( "Entity %i SOLID_BSP with a non bsp model %i\n", NUM_FOR_EDICT( ent ), model->type ); @@ -1049,7 +1049,7 @@ const char *SV_TraceTexture( edict_t *ent, const vec3_t start, const vec3_t end vec3_t start_l, end_l; vec3_t temp, offset; - bmodel = CM_ClipHandleToModel( ent->v.modelindex ); + bmodel = Mod_Handle( ent->v.modelindex ); if( !bmodel || bmodel->type != mod_brush ) return NULL; @@ -1176,7 +1176,7 @@ static void SV_ClipToLinks( areanode_t *node, moveclip_t *clip ) continue; // don't clip against owner } - model = CM_ClipHandleToModel( touch->v.modelindex ); + model = Mod_Handle( touch->v.modelindex ); bSimpleBox = (clip->flags & FMOVE_SIMPLEBOX) ? true : false; bSimpleBox = World_UseSimpleBox( bSimpleBox, touch->v.solid, clip->isPoint, model ); diff --git a/mainui/basemenu.cpp b/mainui/basemenu.cpp index 88342b64..24eb900a 100644 --- a/mainui/basemenu.cpp +++ b/mainui/basemenu.cpp @@ -733,7 +733,7 @@ void UI_CloseMenu( void ) memset( uiStatic.serverAddresses, 0, sizeof( uiStatic.serverAddresses )); memset( uiStatic.serverNames, 0, sizeof( uiStatic.serverNames )); - KEY_ClearStates (); +// KEY_ClearStates (); KEY_SetDest ( KEY_GAME ); } diff --git a/mainui/menu_playersetup.cpp b/mainui/menu_playersetup.cpp index 918e998b..6741d648 100644 --- a/mainui/menu_playersetup.cpp +++ b/mainui/menu_playersetup.cpp @@ -40,6 +40,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #define ID_TOPCOLOR 7 #define ID_BOTTOMCOLOR 8 #define ID_HIMODELS 9 +#define ID_SPECTATOR 10 #define MAX_PLAYERMODELS 100 @@ -64,6 +65,7 @@ typedef struct menuCheckBox_s hiModels; menuSlider_s topColor; menuSlider_s bottomColor; + menuCheckBox_s spectator; menuField_s name; menuSpinControl_s model; @@ -150,6 +152,9 @@ static void UI_PlayerSetup_GetConfig( void ) if( CVAR_GET_FLOAT( "cl_himodels" )) uiPlayerSetup.hiModels.enabled = 1; + + if( CVAR_GET_FLOAT( "spectator" )) + uiPlayerSetup.spectator.enabled = 1; } /* @@ -164,6 +169,7 @@ static void UI_PlayerSetup_SetConfig( void ) CVAR_SET_FLOAT( "topcolor", uiPlayerSetup.topColor.curValue * 255 ); CVAR_SET_FLOAT( "bottomcolor", uiPlayerSetup.bottomColor.curValue * 255 ); CVAR_SET_FLOAT( "cl_himodels", uiPlayerSetup.hiModels.enabled ); + CVAR_SET_FLOAT( "spectator", uiPlayerSetup.spectator.enabled ); } /* @@ -190,6 +196,7 @@ static void UI_PlayerSetup_UpdateConfig( void ) CVAR_SET_STRING( "model", uiPlayerSetup.currentModel ); CVAR_SET_FLOAT( "cl_himodels", uiPlayerSetup.hiModels.enabled ); + CVAR_SET_FLOAT( "spectator", uiPlayerSetup.spectator.enabled ); // IMPORTANT: always set default model becuase we need to have something valid here // if you wish draw your playermodel as normal studiomodel please change "models/player.mdl" to path @@ -209,6 +216,7 @@ static void UI_PlayerSetup_Callback( void *self, int event ) switch( item->id ) { case ID_HIMODELS: + case ID_SPECTATOR: if( event == QM_PRESSED ) ((menuCheckBox_s *)self)->focusPic = UI_CHECKBOX_PRESSED; else ((menuCheckBox_s *)self)->focusPic = UI_CHECKBOX_FOCUS; @@ -349,7 +357,7 @@ static void UI_PlayerSetup_Init( void ) uiPlayerSetup.topColor.generic.flags = QMF_PULSEIFFOCUS|QMF_DROPSHADOW; uiPlayerSetup.topColor.generic.name = "Top color"; uiPlayerSetup.topColor.generic.x = 350; - uiPlayerSetup.topColor.generic.y = 500; + uiPlayerSetup.topColor.generic.y = 550; uiPlayerSetup.topColor.generic.callback = UI_PlayerSetup_Callback; uiPlayerSetup.topColor.generic.statusText = "Set a player model top color"; uiPlayerSetup.topColor.minValue = 0.0; @@ -361,7 +369,7 @@ static void UI_PlayerSetup_Init( void ) uiPlayerSetup.bottomColor.generic.flags = QMF_PULSEIFFOCUS|QMF_DROPSHADOW; uiPlayerSetup.bottomColor.generic.name = "Bottom color"; uiPlayerSetup.bottomColor.generic.x = 350; - uiPlayerSetup.bottomColor.generic.y = 570; + uiPlayerSetup.bottomColor.generic.y = 620; uiPlayerSetup.bottomColor.generic.callback = UI_PlayerSetup_Callback; uiPlayerSetup.bottomColor.generic.statusText = "Set a player model bottom color"; uiPlayerSetup.bottomColor.minValue = 0.0; @@ -377,6 +385,15 @@ static void UI_PlayerSetup_Init( void ) uiPlayerSetup.hiModels.generic.callback = UI_PlayerSetup_Callback; uiPlayerSetup.hiModels.generic.statusText = "show hi-res models in multiplayer"; + uiPlayerSetup.spectator.generic.id = ID_SPECTATOR; + uiPlayerSetup.spectator.generic.type = QMTYPE_CHECKBOX; + uiPlayerSetup.spectator.generic.flags = QMF_HIGHLIGHTIFFOCUS|QMF_ACT_ONRELEASE|QMF_MOUSEONLY|QMF_DROPSHADOW; + uiPlayerSetup.spectator.generic.name = "Play as a spectator"; + uiPlayerSetup.spectator.generic.x = 72; + uiPlayerSetup.spectator.generic.y = 430; + uiPlayerSetup.spectator.generic.callback = UI_PlayerSetup_Callback; + uiPlayerSetup.spectator.generic.statusText = "enable spectator mode in multiplayer"; + UI_PlayerSetup_GetConfig(); UI_AddItem( &uiPlayerSetup.menu, (void *)&uiPlayerSetup.background ); @@ -389,6 +406,7 @@ static void UI_PlayerSetup_Init( void ) UI_AddItem( &uiPlayerSetup.menu, (void *)&uiPlayerSetup.topColor ); UI_AddItem( &uiPlayerSetup.menu, (void *)&uiPlayerSetup.bottomColor ); UI_AddItem( &uiPlayerSetup.menu, (void *)&uiPlayerSetup.hiModels ); + UI_AddItem( &uiPlayerSetup.menu, (void *)&uiPlayerSetup.spectator ); // setup render and actor uiPlayerSetup.refdef.fov_x = 40;