06 Jan 2009

This commit is contained in:
g-cont 2009-01-06 00:00:00 +03:00 committed by Alibek Omarov
parent 0b8d2dbde0
commit 427370f67f
52 changed files with 542 additions and 429 deletions

View File

@ -81,9 +81,9 @@ int HUD_Redraw( float flTime, int state )
return 1;
}
int HUD_UpdateClientData( ref_params_t *parms, float flTime )
int HUD_UpdateClientData( client_data_t *cdata, float flTime )
{
return gHUD.UpdateClientData( parms, flTime );
return gHUD.UpdateClientData( cdata, flTime );
}
void HUD_Reset( void )

View File

@ -29,24 +29,24 @@
#define CMD_ARGV (*g_engfuncs.pfnCmdArgv)
#define ALERT (*g_engfuncs.pfnAlertMessage)
inline void CL_PlaySound( const char *szSound, float flVolume )
inline void CL_PlaySound( const char *szSound, float flVolume, float pitch = PITCH_NORM )
{
g_engfuncs.pfnPlaySoundByName( szSound, flVolume, NULL );
g_engfuncs.pfnPlaySoundByName( szSound, flVolume, pitch, NULL );
}
inline void CL_PlaySound( int iSound, float flVolume )
inline void CL_PlaySound( int iSound, float flVolume, float pitch = PITCH_NORM )
{
g_engfuncs.pfnPlaySoundByIndex( iSound, flVolume, NULL );
g_engfuncs.pfnPlaySoundByIndex( iSound, flVolume, pitch, NULL );
}
inline void CL_PlaySound( const char *szSound, float flVolume, Vector &pos )
inline void CL_PlaySound( const char *szSound, float flVolume, Vector &pos, float pitch = PITCH_NORM )
{
g_engfuncs.pfnPlaySoundByName( szSound, flVolume, pos );
g_engfuncs.pfnPlaySoundByName( szSound, flVolume, pitch, pos );
}
inline void CL_PlaySound( int iSound, float flVolume, Vector &pos )
inline void CL_PlaySound( int iSound, float flVolume, Vector &pos, float pitch = PITCH_NORM )
{
g_engfuncs.pfnPlaySoundByIndex( iSound, flVolume, pos );
g_engfuncs.pfnPlaySoundByIndex( iSound, flVolume, pitch, pos );
}
#define AngleVectors (*g_engfuncs.pfnAngleVectors)

View File

@ -12,6 +12,8 @@ void HUD_CreateEntities( void )
void HUD_StudioEvent( const dstudioevent_t *event, edict_t *entity )
{
float pitch;
switch( event->event )
{
case 5001:
@ -31,9 +33,12 @@ void HUD_StudioEvent( const dstudioevent_t *event, edict_t *entity )
break;
case 5004:
// Client side sound
CL_PlaySound( event->options, 1.0f, entity->v.attachment[0] );
break;
case 5005:
// Client side sound with random pitch
pitch = 85 + RANDOM_LONG( 0, 0x1F );
CL_PlaySound( event->options, RANDOM_FLOAT( 0.7f, 0.9f ), entity->v.attachment[0], pitch );
break;
case 5050:
// Special event for displacer

View File

@ -184,20 +184,20 @@ void CHud :: Think( void )
}
}
int CHud :: UpdateClientData( ref_params_t *cdata, float time )
int CHud :: UpdateClientData( client_data_t *cdata, float time )
{
memcpy( m_vecOrigin, cdata->origin, sizeof( vec3_t ));
memcpy( m_vecAngles, cdata->angles, sizeof( vec3_t ));
if( m_iWeaponBits != cdata->iWeaponBits )
ALERT( at_console, "WeaponBits: %i\n", cdata->iWeaponBits );
ALERT( at_console, "WeaponBits: %ld\n", cdata->iWeaponBits );
m_iKeyBits = cdata->iKeyBits;
m_iWeaponBits = cdata->iWeaponBits;
Think();
cdata->fov_x = m_flFOV;
cdata->fov = m_flFOV;
cdata->iKeyBits = m_iKeyBits;
cdata->v_idlescale = m_iConcussionEffect;
@ -212,6 +212,7 @@ int CHud :: Redraw( float flTime )
m_fOldTime = m_flTime; // save time of previous redraw
m_flTime = flTime;
m_flTimeDelta = (double)m_flTime - m_fOldTime;
static float m_flShotTime;
// clock was reset, reset delta
if( m_flTimeDelta < 0 ) m_flTimeDelta = 0;
@ -222,6 +223,16 @@ int CHud :: Redraw( float flTime )
// draw screen fade before hud
DrawScreenFade();
// take a screenshot if the client's got the cvar set
if( CVAR_GET_FLOAT( "hud_takesshots" ))
{
if( m_flTime > m_flShotTime )
{
CLIENT_COMMAND( "screenshot\n" );
m_flShotTime = m_flTime + 0.04f;
}
}
// redeemer hud stuff
if( m_Redeemer.m_iHudMode > 0 )
{

View File

@ -621,7 +621,7 @@ public:
void VidInit( void );
void Think( void );
int Redraw( float flTime );
int UpdateClientData( ref_params_t *pparams, float time );
int UpdateClientData( client_data_t *cdata, float time );
CHud() : m_pHudList(NULL) { }
~CHud(); // destructor, frees allocated memory
@ -662,7 +662,7 @@ public:
int iHeight;
} m_scrinfo;
int m_iWeaponBits;
int64 m_iWeaponBits;
int m_fPlayerDead;
int m_iIntermission;

View File

@ -394,6 +394,8 @@ void WeaponsResource :: SelectSlot( int iSlot, int fAdvance, int iDirection )
if( !(gHUD.m_iHideHUDDisplay & ITEM_SUIT ))
return;
if( !gHUD.m_iWeaponBits ) return;
WEAPON *p = NULL;
bool fastSwitch = CVAR_GET_FLOAT( "hud_fastswitch" ) != 0;

View File

@ -46,7 +46,7 @@ public:
}
///// WEAPON /////
int iOldWeaponBits;
int64 iOldWeaponBits;
WEAPON *GetWeapon( int iId ) { return &rgWeapons[iId]; }
void AddWeapon( WEAPON *wp )

View File

@ -13,7 +13,7 @@ extern cl_enginefuncs_t g_engfuncs;
extern int HUD_VidInit( void );
extern void HUD_Init( void );
extern int HUD_Redraw( float flTime, int state );
extern int HUD_UpdateClientData( ref_params_t *parms, float flTime );
extern int HUD_UpdateClientData( client_data_t *cdata, float flTime );
extern void HUD_Reset( void );
extern void HUD_Frame( double time );
extern void HUD_Shutdown( void );
@ -142,11 +142,12 @@ extern int READ_BYTE( void );
extern int READ_SHORT( void );
extern int READ_WORD( void );
extern int READ_LONG( void );
extern int64 READ_LONG64( void );
extern float READ_FLOAT( void );
extern double READ_DOUBLE( void );
extern char* READ_STRING( void );
extern float READ_COORD( void );
extern float READ_ANGLE( void );
extern float READ_ANGLE16( void );
extern void END_READ( void );
// drawing stuff

View File

@ -76,6 +76,7 @@ int CHud :: InitMessages( void )
CVAR_REGISTER( "zoom_sensitivity_ratio", "1.2", 0, "mouse sensitivity when zooming" );
CVAR_REGISTER( "default_fov", "90", 0, "default client fov" );
CVAR_REGISTER( "hud_draw", "1", CVAR_ARCHIVE, "hud drawing modes" );
CVAR_REGISTER( "hud_takesshots", "0", 0, "take screenshots at 30 fps" );
// UNDONE: replace all coord variables with float not int
// FIXME: remove jitter for moving objects (flashlight beam etc)

View File

@ -102,6 +102,24 @@ int READ_LONG( void )
return c;
}
int64 READ_LONG64( void )
{
int64 c;
if( gMsg.read + 8 > gMsg.size )
{
gMsg.badRead = true;
return -1;
}
c = gMsg.buf[gMsg.read]+(gMsg.buf[gMsg.read+1]<<8)
+(gMsg.buf[gMsg.read+2]<<16)+(gMsg.buf[gMsg.read+3]<<24)
+ (gMsg.buf[gMsg.read+4]<<32)+(gMsg.buf[gMsg.read+5]<<40)
+(gMsg.buf[gMsg.read+6]<<48)+(gMsg.buf[gMsg.read+7]<<56);
gMsg.read += 8;
return c;
}
float READ_FLOAT( void )
{
union { float f; int l; } dat;
@ -110,6 +128,14 @@ float READ_FLOAT( void )
return dat.f;
}
double READ_DOUBLE( void )
{
union { double f; int64 l; } dat;
dat.l = READ_LONG64();
return dat.f;
}
char* READ_STRING( void )
{
int l, c;
@ -146,11 +172,6 @@ float READ_COORD( void )
}
float READ_ANGLE( void )
{
return READ_FLOAT();
}
float READ_ANGLE16( void )
{
return (float)(READ_SHORT() * (360.0 / 65536));
}

View File

@ -5,6 +5,7 @@
#include <stdio.h> // sscanf support
#include "bsplib.h"
#include "entity_def.h"
#include "physic_api.h"
#include "byteorder.h"
#include "const.h"

View File

@ -4,6 +4,7 @@
//=======================================================================
#include "bsplib.h"
#include "entity_def.h"
#include "physic_api.h"
byte *checkermate_dds;

View File

@ -191,10 +191,16 @@ void CL_LevelShot_f( void )
{
string checkname;
if( !cl.need_levelshot )
{
Msg( "levelshot is not valid from the console\n" );
return;
}
// check for exist
com.sprintf( checkname, "media/background/%s.png", cl.configstrings[CS_NAME] );
if(!FS_FileExists( checkname )) re->ScrShot( checkname, true );
else Msg("levelshot for this map already created\nFirst remove old image if you wants do it again\n" );
if( !FS_FileExists( checkname )) re->ScrShot( checkname, true );
cl.need_levelshot = false; // done
}
/*

View File

@ -87,8 +87,9 @@ void CL_WriteDemoHeader( const char *name )
for( i = 0; i < clgame.numEntities; i++ )
{
ent = EDICT_NUM( i );
if( ent->free ) continue;
state = &ent->pvClientData->baseline;
if( !state->model.index ) continue;
if( !state->modelindex ) continue;
if( buf.cursize + 64 > buf.maxsize )
{

View File

@ -22,15 +22,15 @@ void CL_UpdateEntityFields( edict_t *ent )
// copy state to progs
ent->v.classname = cl.edict_classnames[ent->pvClientData->current.classname];
ent->v.modelindex = ent->pvClientData->current.model.index;
ent->v.weaponmodel = ent->pvClientData->current.pmodel.index;
ent->v.modelindex = ent->pvClientData->current.modelindex;
ent->v.weaponmodel = ent->pvClientData->current.weaponmodel;
ent->v.ambient = ent->pvClientData->current.soundindex;
ent->v.model = MAKE_STRING( cl.configstrings[CS_MODELS+ent->pvClientData->current.model.index] );
ent->v.frame = ent->pvClientData->current.model.frame;
ent->v.sequence = ent->pvClientData->current.model.sequence;
ent->v.gaitsequence = ent->pvClientData->current.model.gaitsequence;
ent->v.body = ent->pvClientData->current.model.body;
ent->v.skin = ent->pvClientData->current.model.skin;
ent->v.model = MAKE_STRING( cl.configstrings[CS_MODELS+ent->pvClientData->current.modelindex] );
ent->v.frame = ent->pvClientData->current.frame;
ent->v.sequence = ent->pvClientData->current.sequence;
ent->v.gaitsequence = ent->pvClientData->current.gaitsequence;
ent->v.body = ent->pvClientData->current.body;
ent->v.skin = ent->pvClientData->current.skin;
VectorCopy( ent->pvClientData->current.rendercolor, ent->v.rendercolor );
VectorCopy( ent->pvClientData->current.velocity, ent->v.velocity );
VectorCopy( ent->pvClientData->current.origin, ent->v.origin );
@ -39,23 +39,24 @@ void CL_UpdateEntityFields( edict_t *ent )
VectorCopy( ent->pvClientData->prev.angles, ent->v.oldangles );
VectorCopy( ent->pvClientData->current.mins, ent->v.mins );
VectorCopy( ent->pvClientData->current.maxs, ent->v.maxs );
ent->v.framerate = ent->pvClientData->current.model.framerate;
ent->v.colormap = ent->pvClientData->current.model.colormap;
ent->v.framerate = ent->pvClientData->current.framerate;
ent->v.colormap = ent->pvClientData->current.colormap;
ent->v.rendermode = ent->pvClientData->current.rendermode;
ent->v.renderamt = ent->pvClientData->current.renderamt;
ent->v.renderfx = ent->pvClientData->current.renderfx;
ent->v.scale = ent->pvClientData->current.model.scale;
ent->v.scale = ent->pvClientData->current.scale;
ent->v.weapons = ent->pvClientData->current.weapons;
ent->v.gravity = ent->pvClientData->current.gravity;
ent->v.health = ent->pvClientData->current.health;
ent->v.solid = ent->pvClientData->current.solidtype;
ent->v.solid = ent->pvClientData->current.solid;
ent->v.movetype = ent->pvClientData->current.movetype;
ent->v.flags = ent->pvClientData->current.flags;
if( ent->v.scale == 0.0f ) ent->v.scale = 1.0f;
for( i = 0; i < MAXSTUDIOBLENDS; i++ )
ent->v.blending[i] = ent->pvClientData->current.model.blending[i];
ent->v.blending[i] = ent->pvClientData->current.blending[i];
for( i = 0; i < MAXSTUDIOCONTROLLERS; i++ )
ent->v.controller[i] = ent->pvClientData->current.model.controller[i];
ent->v.controller[i] = ent->pvClientData->current.controller[i];
if( ent->pvClientData->current.aiment )
ent->v.aiment = EDICT_NUM( ent->pvClientData->current.aiment );
@ -93,9 +94,13 @@ void CL_DeltaEntity( sizebuf_t *msg, frame_t *frame, int newnum, entity_state_t
frame->num_entities++;
// some data changes will force no lerping
if( state->model.index != ent->pvClientData->current.model.index || state->pmodel.index != ent->pvClientData->current.pmodel.index || state->model.body != ent->pvClientData->current.model.body
|| state->model.sequence != ent->pvClientData->current.model.sequence || abs(state->origin[0] - ent->pvClientData->current.origin[0]) > 512
|| abs(state->origin[1] - ent->pvClientData->current.origin[1]) > 512 || abs(state->origin[2] - ent->pvClientData->current.origin[2]) > 512 )
if( state->modelindex != ent->pvClientData->current.modelindex
|| state->weaponmodel != ent->pvClientData->current.weaponmodel
|| state->body != ent->pvClientData->current.body
|| state->sequence != ent->pvClientData->current.sequence
|| abs( state->origin[0] - ent->pvClientData->current.origin[0] ) > 512
|| abs( state->origin[1] - ent->pvClientData->current.origin[1] ) > 512
|| abs(state->origin[2] - ent->pvClientData->current.origin[2]) > 512 )
{
ent->pvClientData->serverframe = -99;
}
@ -303,10 +308,6 @@ void CL_ParseFrame( sizebuf_t *msg )
if( old ) cl.frame.ps = MSG_ParseDeltaPlayer( &old->ps, &clent->pvClientData->current );
else cl.frame.ps = MSG_ParseDeltaPlayer( NULL, &clent->pvClientData->current );
// FIXME
if( cls.state == ca_cinematic || cls.demoplayback )
cl.frame.ps.pm_type = PM_FREEZE; // demo or movie playback
// save the frame off in the backup array for later delta comparisons
cl.frames[cl.frame.serverframe & UPDATE_MASK] = cl.frame;
@ -417,16 +418,18 @@ void CL_CalcViewValues( void )
oldframe = &cl.frame; // previous frame was dropped or invalid
ops = &oldframe->ps;
clent = EDICT_NUM( cl.playernum + 1 );
// see if the player entity was teleported this frame
if( ps->pm_flags & PMF_TIME_TELEPORT )
if( clent->v.teleport_time )
ops = ps; // don't interpolate
lerp = cl.refdef.lerpfrac;
// calculate the origin
if((cl_predict->value) && !(cl.frame.ps.pm_flags & PMF_NO_PREDICTION) && !cls.demoplayback )
if( cl_predict->integer && !cls.demoplayback )
{
// use predicted values
int delta;
int delta;
backlerp = 1.0 - lerp;
for( i = 0; i < 3; i++ )
@ -464,14 +467,10 @@ void CL_CalcViewValues( void )
AngleVectors( cl.refdef.viewangles, cl.refdef.forward, cl.refdef.right, cl.refdef.up );
// interpolate field of view
cl.refdef.fov_x = ops->fov + lerp * ( ps->fov - ops->fov );
clent = EDICT_NUM( cl.playernum + 1 );
cl.data.fov = ops->fov + lerp * ( ps->fov - ops->fov );
// add the weapon
CL_AddViewWeapon( ps );
cl.refdef.iWeaponBits = ps->weapons;
cls.dllFuncs.pfnUpdateClientData( &cl.refdef, (cl.time * 0.001f));
}
/*
@ -526,7 +525,7 @@ void CL_GetEntitySoundSpatialization( int entnum, vec3_t origin, vec3_t velocity
// if a brush model, offset the origin
if( VectorIsNull( origin ))
{
cmodel = cl.models[ent->pvClientData->current.model.index];
cmodel = cl.models[ent->pvClientData->current.modelindex];
if( !cmodel ) return;
VectorAverage( cmodel->mins, cmodel->maxs, midPoint );
VectorAdd( origin, midPoint, origin );

View File

@ -551,9 +551,9 @@ pfnPlaySoundByName
=============
*/
void pfnPlaySoundByName( const char *szSound, float volume, const float *org )
void pfnPlaySoundByName( const char *szSound, float volume, int pitch, const float *org )
{
S_StartLocalSound( szSound, volume, org );
S_StartLocalSound( szSound, volume, pitch, org );
}
/*
@ -562,7 +562,7 @@ pfnPlaySoundByIndex
=============
*/
void pfnPlaySoundByIndex( int iSound, float volume, const float *org )
void pfnPlaySoundByIndex( int iSound, float volume, int pitch, const float *org )
{
// make sure what we in-bounds
iSound = bound( 0, iSound, MAX_SOUNDS );
@ -572,7 +572,7 @@ void pfnPlaySoundByIndex( int iSound, float volume, const float *org )
MsgDev( D_ERROR, "CL_PlaySoundByIndex: invalid sound handle %i\n", iSound );
return;
}
S_StartSound( org, cl.playernum + 1, CHAN_AUTO, cl.sound_precache[iSound], volume, ATTN_NORM, PITCH_NORM );
S_StartSound( org, cl.playernum + 1, CHAN_AUTO, cl.sound_precache[iSound], volume, ATTN_NORM, pitch );
}
/*
@ -788,7 +788,6 @@ void pfnMakeLevelShot( void )
if( !cl.need_levelshot ) return;
Con_ClearNotify();
cl.need_levelshot = false;
// make levelshot at nextframe()
Cbuf_ExecuteText( EXEC_APPEND, "levelshot\n" );

View File

@ -30,11 +30,12 @@ cvar_t *ui_sensitivity;
cvar_t *m_filter; // mouse filtering
uint frame_msec;
int in_impulse;
int in_cancel;
kbutton_t in_left, in_right, in_forward, in_back;
kbutton_t in_lookup, in_lookdown, in_moveleft, in_moveright;
kbutton_t in_strafe, in_speed, in_use, in_attack, in_attack2;
kbutton_t in_up, in_down, in_reload;
kbutton_t in_up, in_down, in_reload, in_score;
/*
============================================================
@ -79,12 +80,14 @@ void CL_MouseMove( usercmd_t *cmd )
cl.mouse_x[cl.mouse_step] = 0;
cl.mouse_y[cl.mouse_step] = 0;
rate = sqrt( mx * mx + my * my ) / (float)frame_msec;
rate = com.sqrt( mx * mx + my * my ) / (float)frame_msec;
if( cls.key_dest != key_menu )
{
if( cl.frame.ps.health <= 0 ) return;
if( cl.mouse_sens == 0.0f ) cl.mouse_sens = 1.0f;
accel_sensitivity = cl_sensitivity->value + rate * cl_mouseaccel->value;
//accel_sensitivity *= cl.mouse_sens; // scale by fov
accel_sensitivity *= cl.mouse_sens; // scale by fov
mx *= accel_sensitivity;
my *= accel_sensitivity;
@ -259,13 +262,16 @@ void IN_SpeedUp(void) {IN_KeyUp(&in_speed);}
void IN_StrafeDown(void) {IN_KeyDown(&in_strafe);}
void IN_StrafeUp(void) {IN_KeyUp(&in_strafe);}
void IN_AttackDown(void) {IN_KeyDown(&in_attack);}
void IN_AttackUp(void) {IN_KeyUp(&in_attack);}
void IN_AttackUp(void) {IN_KeyUp(&in_attack); in_cancel = 0; }
void IN_Attack2Down(void) {IN_KeyDown(&in_attack2);}
void IN_Attack2Up(void) {IN_KeyUp(&in_attack2);}
void IN_UseDown (void) {IN_KeyDown(&in_use);}
void IN_UseUp (void) {IN_KeyUp(&in_use);}
void IN_ReloadDown(void) {IN_KeyDown(&in_reload);}
void IN_ReloadUp(void) {IN_KeyUp(&in_reload);}
void IN_ScoreDown(void) {IN_KeyDown(&in_score);}
void IN_ScoreUp(void) {IN_KeyUp(&in_score);}
void IN_Cancel(void) {in_cancel = true;}
void IN_Impulse (void) {in_impulse = com.atoi(Cmd_Argv(1));}
void IN_MLookDown( void ){Cvar_SetValue( "cl_mouselook", 1 );}
void IN_MLookUp( void ){ IN_CenterView(); Cvar_SetValue( "cl_mouselook", 0 );}
@ -283,6 +289,8 @@ Moves the local angle positions
void CL_AdjustAngles( void )
{
float speed;
if( cl.frame.ps.health <= 0 ) return;
if( in_speed.state & 1 )
speed = cls.frametime * cl_anglespeedkey->value;
@ -309,7 +317,7 @@ void CL_BaseMove( usercmd_t *cmd )
{
CL_AdjustAngles ();
memset (cmd, 0, sizeof(*cmd));
memset( cmd, 0, sizeof( *cmd ));
VectorCopy (cl.viewangles, cmd->angles);
if( in_strafe.state & 1 )
@ -376,8 +384,16 @@ void CL_CmdButtons( usercmd_t *cmd )
cmd->buttons |= IN_RELOAD;
in_reload.state &= ~2;
// save it for hud processing
cl.refdef.iKeyBits = cmd->buttons;
if( in_cancel )
cmd->buttons |= IN_CANCEL;
if( in_score.state & 3 )
cmd->buttons |= IN_SCORE;
in_score.state &= ~2;
// dead or in intermission? Shore scoreboard, too
if( cl.frame.ps.health <= 0 || cl.refdef.intermission )
cmd->buttons |= IN_SCORE;
}
/*
@ -397,13 +413,26 @@ void CL_FinishMove( usercmd_t *cmd )
CL_ClampPitch();
for( i = 0; i < 3; i++ )
cmd->angles[i] = ANGLE2SHORT(cl.viewangles[i]);
cmd->angles[i] = ANGLE2SHORT( cl.viewangles[i] );
cmd->impulse = in_impulse;
in_impulse = 0;
// FIXME: send the ambient light level for all! entities properly
cmd->lightlevel = (byte)cl_lightlevel->value;
// process commands with user dll's
cl.data.fov = cl.frame.ps.fov;
cl.data.iKeyBits = cmd->buttons;
cl.data.iWeaponBits = cl.frame.ps.weapons;
cl.data.mouse_sensitivity = cl.mouse_sens;
VectorCopy( cl.viewangles, cl.data.angles );
VectorCopy( cl.refdef.origin, cl.data.origin );
cls.dllFuncs.pfnUpdateClientData( &cl.data, ( cl.time * 0.001f ));
cmd->buttons = cl.data.iKeyBits;
cl.refdef.fov_x = cl.data.fov;
cl.mouse_sens = cl.data.mouse_sensitivity;
}
@ -574,7 +603,10 @@ void CL_InitInput( void )
Cmd_AddCommand ("-use", IN_UseUp, "stop using item" );
Cmd_AddCommand ("+reload", IN_ReloadDown, "reload current weapon" );
Cmd_AddCommand ("-reload", IN_ReloadUp, "continue reload weapon" );
Cmd_AddCommand ("+showscores", IN_ScoreDown, "show scores" );
Cmd_AddCommand ("-showscores", IN_ScoreUp, "hide scores" );
Cmd_AddCommand ("impulse", IN_Impulse, "send an impulse number to server (select weapon, use item, etc)");
Cmd_AddCommand ("cancelselect", IN_Cancel, "cancel selected item in menu");
Cmd_AddCommand ("+mlook", IN_MLookDown, "activate mouse looking mode, do not recenter view" );
Cmd_AddCommand ("-mlook", IN_MLookUp, "deactivate mouse looking mode" );
}
@ -617,9 +649,12 @@ void CL_ShutdownInput( void )
Cmd_RemoveCommand ("-attack" );
Cmd_RemoveCommand ("+attack2" );
Cmd_RemoveCommand ("-attack2" );
Cmd_RemoveCommand ("+reload" );
Cmd_RemoveCommand ("-reload" );
Cmd_RemoveCommand ("+use" );
Cmd_RemoveCommand ("-use" );
Cmd_RemoveCommand ("impulse" );
Cmd_RemoveCommand ("cancelselect" );
Cmd_RemoveCommand ("+mlook" );
Cmd_RemoveCommand ("-mlook" );
}

View File

@ -13,14 +13,13 @@
CL_CheckPredictionError
===================
*/
void CL_CheckPredictionError (void)
void CL_CheckPredictionError( void )
{
int frame;
int delta[3];
int len;
int frame;
int delta[3];
int len;
if (!cl_predict->value || (cl.frame.ps.pm_flags & PMF_NO_PREDICTION))
return;
if( !cl_predict->integer ) return;
// calculate the last usercmd_t we sent that the server has processed
frame = cls.netchan.incoming_acknowledged;
@ -266,22 +265,22 @@ void CL_PredictMovement (void)
int ack, current;
int frame;
int oldframe;
entvars_t pmove;
usercmd_t *cmd;
pmove_t pm;
int i;
float step;
float oldz;
if(cls.state != ca_active) return;
if(cl_paused->value) return;
if( cls.state != ca_active ) return;
if( cl_paused->value ) return;
if (!cl_predict->value || (cl.frame.ps.pm_flags & PMF_NO_PREDICTION))
pmove = EDICT_NUM( cl.playernum + 1 )->v;
if( !cl_predict->value || pmove.teleport_time )
{
// just set angles
for (i = 0; i < 3; i++)
{
cl.predicted_angles[i] = cl.viewangles[i] + SHORT2ANGLE(cl.frame.ps.delta_angles[i]);
}
for( i = 0; i < 3; i++ )
cl.predicted_angles[i] = cl.viewangles[i] + SHORT2ANGLE( cl.frame.ps.delta_angles[i] );
return;
}
@ -289,42 +288,35 @@ void CL_PredictMovement (void)
current = cls.netchan.outgoing_sequence;
// if we are too far out of date, just freeze
if (current - ack >= CMD_BACKUP)
if( current - ack >= CMD_BACKUP )
{
if (cl_showmiss->value)
Msg ("exceeded CMD_BACKUP\n");
if( cl_showmiss->value )
Msg( "exceeded CMD_BACKUP\n" );
return;
}
// copy current state to pmove
memset (&pm, 0, sizeof(pm));
pm.trace = CL_PMTrace;
pm.pointcontents = CL_PointContents;
pm.ps = cl.frame.ps;
// SCR_DebugGraph (current - ack - 1, COLOR_0);
frame = 0;
// run frames
while (++ack < current)
while( ++ack < current )
{
frame = ack & (CMD_BACKUP-1);
cmd = &cl.cmds[frame];
pm.cmd = *cmd;
pe->PlayerMove( &pm, true );
pe->PlayerMove( &pmove, cmd, NULL, true );
// save for debug checking
VectorCopy (pm.ps.origin, cl.predicted_origins[frame]);
VectorCopy( pmove.origin, cl.predicted_origins[frame] );
}
oldframe = (ack-2) & (CMD_BACKUP-1);
if( pm.ps.pm_flags & PMF_ON_GROUND )
if( pmove.flags & FL_ONGROUND )
{
oldz = cl.predicted_origins[oldframe][2];
step = pm.ps.origin[2] - oldz;
step = pmove.origin[2] - oldz;
if( step > 63 && step < 160 )
{
cl.predicted_step = step;
@ -333,6 +325,6 @@ void CL_PredictMovement (void)
}
// copy results out for rendering
VectorCopy( pm.ps.origin, cl.predicted_origin );
VectorCopy(pm.ps.viewangles, cl.predicted_angles);
VectorCopy( pmove.origin, cl.predicted_origin );
VectorCopy( pmove.v_angle, cl.predicted_angles );
}

View File

@ -324,6 +324,7 @@ void SCR_DrawFPS( void )
if( cls.state != ca_active ) return;
if( !cl_showfps->integer ) return;
if( cl.need_levelshot ) return;
newtime = Sys_DoubleTime();
if (newtime >= nexttime)

View File

@ -79,7 +79,7 @@ void V_TestEntities( void )
ent.serialnumber = cl.frame.ps.number;
ent.v.controller[0] = ent.v.controller[1] = 90.0f;
ent.v.controller[2] = ent.v.controller[3] = 180.0f;
ent.v.modelindex = cl.frame.ps.model.index;
ent.v.modelindex = cl.frame.ps.modelindex;
re->AddRefEntity( &ent, ED_NORMAL, 1.0f );
}
}

View File

@ -110,6 +110,7 @@ typedef struct
// is rendering at. always <= cls.realtime
ref_params_t refdef; // shared refdef
edict_t viewent; // viewmodel
client_data_t data; // hud data
// misc 2d drawing stuff
int centerPrintTime;
@ -191,7 +192,7 @@ typedef struct serverinfo_s
} serverinfo_t;
typedef enum { key_game, key_console, key_message, key_menu } keydest_t;
typedef enum { key_game, key_console, key_message, key_menu, key_gamemenu } keydest_t;
typedef struct
{
@ -492,7 +493,7 @@ _inline edict_t *CL_EDICT_NUM( int n, const char *file, const int line )
// if origin is NULL, the sound will be dynamically sourced from the entity
#define S_StartStreaming if( se ) se->StartStreaming
#define S_StartSound( a,b,c,d,e,f,g ) if( se ) se->StartSound( a, b, c, d, e, f, g, true );
#define S_StartLocalSound( a, b, c ) if( se ) se->StartLocalSound( a, b, c )
#define S_StartLocalSound( a,b,c,d ) if( se ) se->StartLocalSound( a, b, c, d )
#define S_StartBackgroundTrack if( se ) se->StartBackgroundTrack
#define S_StopBackgroundTrack if( se ) se->StopBackgroundTrack
#define S_RawSamples if( se ) se->StreamRawSamples

View File

@ -13,6 +13,7 @@
#include "launch_api.h"
#include "qfiles_ref.h"
#include "engine_api.h"
#include "entity_def.h"
#include "physic_api.h"
#include "vprogs_api.h"
#include "vsound_api.h"

View File

@ -42,7 +42,7 @@ keyname_t keynames[] =
{
{"TAB", K_TAB, "" },
{"ENTER", K_ENTER, "" },
{"ESCAPE", K_ESCAPE, "togglemenu" }, // hardcoded
{"ESCAPE", K_ESCAPE, "cancelselect" }, // hardcoded
{"SPACE", K_SPACE, "+moveup" },
{"BACKSPACE", K_BACKSPACE, "" },
{"UPARROW", K_UPARROW, "+forward" },
@ -661,7 +661,7 @@ void Key_Message( int key )
{
char buffer[MAX_SYSPATH];
if(key == K_ESCAPE)
if( key == K_ESCAPE )
{
cls.key_dest = key_game;
Field_Clear( &chatField );
@ -1094,25 +1094,27 @@ void Key_Event(int key, bool down, uint time)
}
// escape is always handled special
if ( key == K_ESCAPE && down )
if( key == K_ESCAPE && down )
{
switch( cls.key_dest )
{
case key_message:
Key_Message( key );
break;
return;
case key_game:
case key_console:
UI_ShowMenu();
break;
return;
case key_menu:
UI_KeyEvent( key );
return;
case key_gamemenu:
// passed to client dll's
break;
default:
MsgDev( D_ERROR, "Key_Event: bad cls.key_dest\n");
break;
return;
}
return;
}
// key up events only perform actions if the game key binding is
@ -1127,28 +1129,30 @@ void Key_Event(int key, bool down, uint time)
return;
}
if (!down) return; // other systems only care about key down events
if( !down ) return; // other systems only care about key down events
// distribute the key down event to the apropriate handler
if(cls.key_dest == key_message)
if( cls.key_dest == key_message )
{
Key_Message( key );
}
else if(cls.key_dest == key_menu)
else if( cls.key_dest == key_menu )
{
UI_KeyEvent( key );
}
else if(cls.key_dest == key_console)
else if( cls.key_dest == key_console )
{
Key_Console( key );
}
else if(cls.key_dest == key_game )
else if( cls.key_dest == key_game || cls.key_dest == key_gamemenu )
{
// send the bound action
cls.key_dest = key_game;
kb = keys[key].binding;
if( !kb )
{
if (key >= 200) Msg( "%s is unbound, use controls menu to set.\n", Key_KeynumToString(key));
if( key >= 200 )
Msg( "%s is unbound, use controls menu to set.\n", Key_KeynumToString( key ));
}
else if( kb[0] == '+' )
{
@ -1164,14 +1168,14 @@ void Key_Event(int key, bool down, uint time)
{
// button commands add keynum and time as parms so that multiple
// sources can be discriminated and subframe corrected
com.sprintf(cmd, "%s %i %i\n", button, key, time);
Cbuf_AddText(cmd);
com.sprintf( cmd, "%s %i %i\n", button, key, time );
Cbuf_AddText( cmd );
}
else
{
// down-only command
Cbuf_AddText(button);
Cbuf_AddText("\n");
Cbuf_AddText( button );
Cbuf_AddText( "\n" );
}
buttonPtr = button;
while ( (kb[i] <= ' ' || kb[i] == ';') && kb[i] != 0 ) i++;
@ -1182,9 +1186,13 @@ void Key_Event(int key, bool down, uint time)
}
else
{
// HACKHACK: handle user menus here
if( !com.strncmp( "slot", kb, 4 ))
cls.key_dest = key_gamemenu;
// down-only command
Cbuf_AddText (kb);
Cbuf_AddText ("\n");
Cbuf_AddText( kb );
Cbuf_AddText( "\n" );
}
}
}

View File

@ -899,7 +899,7 @@ void VM_localsound( void )
return;
s = PRVM_G_STRING( OFS_PARM0 );
S_StartLocalSound( s, 1.0f, NULL );
S_StartLocalSound( s, 1.0f, PITCH_NORM, NULL );
else
{
VM_Warning( "localsound: can't play %s!\n", s );

View File

@ -21,44 +21,39 @@ static net_field_t ent_fields[] =
{ ES_FIELD(velocity[0]), NET_FLOAT, false },
{ ES_FIELD(velocity[1]), NET_FLOAT, false },
{ ES_FIELD(velocity[2]), NET_FLOAT, false },
{ ES_FIELD(infotarget[0]), NET_FLOAT, false }, // beam endpoint, portal camera pos, etc
{ ES_FIELD(infotarget[1]), NET_FLOAT, false },
{ ES_FIELD(infotarget[2]), NET_FLOAT, false },
{ ES_FIELD(model.index), NET_WORD, false }, // 4096 models
{ ES_FIELD(model.colormap), NET_WORD, false }, // encoded as two shorts for top and bottom color
{ ES_FIELD(model.scale), NET_COLOR, false }, // 0-255 values
{ ES_FIELD(model.frame), NET_FLOAT, false }, // interpolate value
{ ES_FIELD(model.animtime), NET_FLOAT, false }, // auto-animating time
{ ES_FIELD(model.framerate), NET_FLOAT, false }, // custom framerate
{ ES_FIELD(model.sequence), NET_WORD, false }, // 1024 sequences
{ ES_FIELD(model.gaitsequence), NET_WORD, false }, // 1024 gaitsequences
{ ES_FIELD(model.skin), NET_CHAR, false }, // negative skins are contents
{ ES_FIELD(model.body), NET_BYTE, false }, // 255 bodies
{ ES_FIELD(pmodel.index), NET_WORD, false }, // 4096 models
{ ES_FIELD(pmodel.sequence), NET_WORD, false }, // 1024 sequences
{ ES_FIELD(pmodel.frame), NET_FLOAT, false }, // interpolate value
{ ES_FIELD(pmodel.body), NET_BYTE, false }, // 255 bodies
{ ES_FIELD(pmodel.skin), NET_BYTE, false }, // 255 skins
{ ES_FIELD(model.blending[0]), NET_COLOR, false },
{ ES_FIELD(model.blending[1]), NET_COLOR, false }, // stateflags_t #1 (4 bytes)
{ ES_FIELD(model.blending[2]), NET_COLOR, false },
{ ES_FIELD(model.blending[3]), NET_COLOR, false },
{ ES_FIELD(model.blending[4]), NET_COLOR, false },
{ ES_FIELD(model.blending[5]), NET_COLOR, false },
{ ES_FIELD(model.blending[6]), NET_COLOR, false },
{ ES_FIELD(model.blending[7]), NET_COLOR, false },
{ ES_FIELD(model.blending[8]), NET_COLOR, false },
{ ES_FIELD(model.blending[9]), NET_COLOR, false },
{ ES_FIELD(model.controller[0]), NET_COLOR, false }, // bone controllers #
{ ES_FIELD(model.controller[1]), NET_COLOR, false },
{ ES_FIELD(model.controller[2]), NET_COLOR, false },
{ ES_FIELD(model.controller[3]), NET_COLOR, false },
{ ES_FIELD(model.controller[4]), NET_COLOR, false },
{ ES_FIELD(model.controller[5]), NET_COLOR, false },
{ ES_FIELD(model.controller[6]), NET_COLOR, false },
{ ES_FIELD(model.controller[7]), NET_COLOR, false },
{ ES_FIELD(model.controller[8]), NET_COLOR, false },
{ ES_FIELD(solidtype), NET_BYTE, false },
{ ES_FIELD(modelindex), NET_WORD, false }, // 4096 models
{ ES_FIELD(colormap), NET_WORD, false }, // encoded as two shorts for top and bottom color
{ ES_FIELD(scale), NET_COLOR, false }, // 0-255 values
{ ES_FIELD(frame), NET_FLOAT, false }, // interpolate value
{ ES_FIELD(animtime), NET_FLOAT, false }, // auto-animating time
{ ES_FIELD(framerate), NET_FLOAT, false }, // custom framerate
{ ES_FIELD(sequence), NET_WORD, false }, // 1024 sequences
{ ES_FIELD(gaitsequence), NET_WORD, false }, // 1024 gaitsequences
{ ES_FIELD(skin), NET_CHAR, false }, // negative skins are contents
{ ES_FIELD(body), NET_BYTE, false }, // 255 bodies
{ ES_FIELD(weaponmodel), NET_WORD, false }, // 4096 models
{ ES_FIELD(blending[0]), NET_COLOR, false },
{ ES_FIELD(blending[1]), NET_COLOR, false }, // stateflags_t #1 (4 bytes)
{ ES_FIELD(blending[2]), NET_COLOR, false },
{ ES_FIELD(blending[3]), NET_COLOR, false },
{ ES_FIELD(blending[4]), NET_COLOR, false },
{ ES_FIELD(blending[5]), NET_COLOR, false },
{ ES_FIELD(blending[6]), NET_COLOR, false },
{ ES_FIELD(blending[7]), NET_COLOR, false },
{ ES_FIELD(blending[8]), NET_COLOR, false },
{ ES_FIELD(blending[9]), NET_COLOR, false },
{ ES_FIELD(controller[0]), NET_COLOR, false }, // bone controllers #
{ ES_FIELD(controller[1]), NET_COLOR, false },
{ ES_FIELD(controller[2]), NET_COLOR, false },
{ ES_FIELD(controller[3]), NET_COLOR, false },
{ ES_FIELD(controller[4]), NET_COLOR, false },
{ ES_FIELD(controller[5]), NET_COLOR, false },
{ ES_FIELD(controller[6]), NET_COLOR, false },
{ ES_FIELD(controller[7]), NET_COLOR, false },
{ ES_FIELD(controller[8]), NET_COLOR, false },
{ ES_FIELD(controller[9]), NET_COLOR, false },
{ ES_FIELD(solid), NET_BYTE, false },
{ ES_FIELD(flags), NET_LONG, false },
{ ES_FIELD(movetype), NET_BYTE, false },
{ ES_FIELD(gravity), NET_SHORT, false }, // gravity multiplier
{ ES_FIELD(aiment), NET_WORD, false }, // entity index
@ -76,8 +71,6 @@ static net_field_t ent_fields[] =
{ ES_FIELD(rendercolor[1]), NET_COLOR, false },
{ ES_FIELD(rendercolor[2]), NET_COLOR, false },
{ ES_FIELD(rendermode), NET_BYTE, false }, // render mode (legacy stuff)
{ ES_FIELD(pm_type), NET_BYTE, false }, // 16 player movetypes allowed
{ ES_FIELD(pm_flags), NET_WORD, false }, // 16 movetype flags allowed
{ ES_FIELD(delta_angles[0]), NET_FLOAT, false },
{ ES_FIELD(delta_angles[1]), NET_FLOAT, false },
{ ES_FIELD(delta_angles[2]), NET_FLOAT, false },
@ -90,12 +83,11 @@ static net_field_t ent_fields[] =
{ ES_FIELD(viewoffset[0]), NET_SCALE, false },
{ ES_FIELD(viewoffset[1]), NET_SCALE, false },
{ ES_FIELD(viewoffset[2]), NET_SCALE, false },
{ ES_FIELD(maxspeed), NET_WORD, false },
{ ES_FIELD(viewmodel), NET_WORD, false },
{ ES_FIELD(fov), NET_FLOAT, false }, // client horizontal field of view
{ ES_FIELD(weapons), NET_LONG, false }, // client weapon 0-32
{ ES_FIELD(weapons), NET_INT64, false }, // client weapon 0-32
{ ES_FIELD(health), NET_FLOAT, false }, // client health
// reserve for 10-11 fields without enlarge null_msg_size
// revision 4. reserve for 17 fields without enlarge null_msg_size
{ NULL }, // terminator
};
@ -218,7 +210,7 @@ MSG_WriteBits
write # of bytes
=======================
*/
void _MSG_WriteBits( sizebuf_t *msg, int value, const char *name, int net_type, const char *filename, const int fileline )
void _MSG_WriteBits( sizebuf_t *msg, int64 value, const char *name, int net_type, const char *filename, const int fileline )
{
union { long l; float f; } dat;
byte *buf;
@ -269,7 +261,19 @@ void _MSG_WriteBits( sizebuf_t *msg, int value, const char *name, int net_type,
buf = MSG_GetSpace( msg, 2 );
buf[0] = value & 0xff;
buf[1] = value>>8;
break;
break;
case NET_INT64:
case NET_DOUBLE:
buf = MSG_GetSpace( msg, 8 );
buf[0] = (value>>0 ) & 0xff;
buf[1] = (value>>8 ) & 0xff;
buf[2] = (value>>16) & 0xff;
buf[3] = (value>>24) & 0xff;
buf[4] = (value>>32) & 0xff;
buf[5] = (value>>40) & 0xff;
buf[6] = (value>>48) & 0xff;
buf[7] = (value>>56);
break;
default:
Host_Error( "MSG_WriteBits: bad net.type (called at %s:%i)\n", filename, fileline );
break;
@ -295,10 +299,10 @@ MSG_ReadBits
read # of bytes
=======================
*/
long _MSG_ReadBits( sizebuf_t *msg, int net_type, const char *filename, const int fileline )
int64 _MSG_ReadBits( sizebuf_t *msg, int net_type, const char *filename, const int fileline )
{
union { long l; float f; } dat;
long value = 0;
int64 value = 0;
switch( net_type )
{
@ -337,6 +341,11 @@ long _MSG_ReadBits( sizebuf_t *msg, int net_type, const char *filename, const in
value = SHORT2ANGLE( value );
msg->readcount += 2;
break;
case NET_INT64:
case NET_DOUBLE:
value = (int64)BuffLittleLong64(msg->data + msg->readcount);
msg->readcount += 8;
break;
default:
Host_Error( "MSG_ReadBits: bad net.type (called at %s:%i)\n", filename, fileline );
break;
@ -367,6 +376,13 @@ void _MSG_WriteFloat( sizebuf_t *sb, float f, const char *filename, int fileline
_MSG_WriteBits( sb, dat.l, NWDesc[NET_FLOAT].name, NET_FLOAT, filename, fileline );
}
void _MSG_WriteDouble( sizebuf_t *sb, double f, const char *filename, int fileline )
{
union { double f; int64 l; } dat;
dat.f = f;
_MSG_WriteBits( sb, dat.l, NWDesc[NET_DOUBLE].name, NET_DOUBLE, filename, fileline );
}
void _MSG_WriteString( sizebuf_t *sb, const char *s, const char *filename, int fileline )
{
if( !s ) _MSG_WriteData( sb, "", 1, filename, fileline );
@ -413,6 +429,13 @@ float MSG_ReadFloat( sizebuf_t *msg )
return dat.f;
}
double MSG_ReadDouble( sizebuf_t *msg )
{
union { double f; int64 l; } dat;
dat.l = MSG_ReadBits( msg, NET_DOUBLE );
return dat.f;
}
char *MSG_ReadString( sizebuf_t *msg )
{
static char string[MAX_SYSPATH];

View File

@ -18,6 +18,8 @@ enum net_types_e
NET_SCALE,
NET_COORD,
NET_COLOR,
NET_INT64,
NET_DOUBLE,
NET_TYPES,
};
@ -99,6 +101,8 @@ static const net_desc_t NWDesc[] =
{ NET_SCALE, "Scale", -128, 127 },
{ NET_COORD, "Coord", -262140, 262140 },
{ NET_COLOR, "Color", 0, 255 },
{ NET_INT64, "int64", 0, 0 }, // can't overflow
{ NET_DOUBLE, "Double", 0, 0 }, // can't overflow
};
/*
@ -108,12 +112,62 @@ static const net_desc_t NWDesc[] =
==========================================================
*/
// entity_state_t communication (a part of network protocol)
typedef struct entity_state_s
{
// engine specific
uint number; // edict index
edtype_t ed_type; // edict type
string_t classname; // edict classname
int soundindex; // looped ambient sound
// per-level limits
// physics information
vec3_t origin;
vec3_t angles; // entity angles, not viewangles
solid_t solid; // entity solid
movetype_t movetype; // entity movetype
int gravity; // gravity multiplier
int aiment; // attached entity
vec3_t mins; // not symmetric entity bbox
vec3_t maxs;
// model state
int modelindex; // general modelindex
int colormap; // change base color for some textures or sprite frames
float scale; // model or sprite scale, affects to physics too
float frame; // % playback position in animation sequences (0..255)
int skin; // skin for studiomodels
int body; // sub-model selection for studiomodels
float animtime; // auto-animating time
float framerate; // custom framerate, specified by QC
int sequence; // animation sequence (0 - 255)
float blending[16]; // studio animation blending
float controller[16]; // studio bone controllers
#define ES_FIELD(x) #x,(int)&((entity_state_t*)0)->x
#define CM_FIELD(x) #x,(int)&((usercmd_t*)0)->x
// flags
int flags; // v.flags
uint effects; // effect flags like q1 and hl1
int renderfx; // render effects same as hl1
float renderamt; // alpha value or like somewhat
vec3_t rendercolor; // hl1 legacy stuff, working, but not needed
int rendermode; // hl1 legacy stuff, working, but not needed
// client specific
vec3_t velocity; // player velocity
vec3_t delta_angles; // add to command angles to get view direction
vec3_t punch_angles; // add to view direction to get render angles
vec3_t viewangles; // already calculated view angles on server-side
vec3_t viewoffset; // viewoffset over ground
int gaitsequence; // client\nps\bot gaitsequence
int viewmodel; // contains viewmodel index
int weaponmodel; // contains weaponmodel index
float health; // client health (other parms can be send by custom messages)
int64 weapons; // weapon flags
float fov; // horizontal field of view
} entity_state_t;
#define ES_FIELD( x ) #x,(int)&((entity_state_t*)0)->x
#define CM_FIELD( x ) #x,(int)&((usercmd_t*)0)->x
// config strings are a general means of communication from
// the server to all connected clients.
@ -157,11 +211,12 @@ void MSG_Init( sizebuf_t *buf, byte *data, size_t length );
void MSG_Clear( sizebuf_t *buf );
void MSG_Print( sizebuf_t *msg, const char *data );
void MSG_Bitstream( sizebuf_t *buf, bool state );
void _MSG_WriteBits( sizebuf_t *msg, int value, const char *name, int bits, const char *filename, const int fileline );
long _MSG_ReadBits( sizebuf_t *msg, int bits, const char *filename, const int fileline );
void _MSG_WriteBits( sizebuf_t *msg, int64 value, const char *name, int bits, const char *filename, const int fileline );
int64 _MSG_ReadBits( sizebuf_t *msg, int bits, const char *filename, const int fileline );
void _MSG_Begin( int dest, const char *filename, int fileline );
void _MSG_WriteString( sizebuf_t *sb, const char *s, const char *filename, int fileline );
void _MSG_WriteFloat( sizebuf_t *sb, float f, const char *filename, int fileline );
void _MSG_WriteDouble( sizebuf_t *sb, double f, const char *filename, int fileline );
void _MSG_WritePos( sizebuf_t *sb, vec3_t pos, const char *filename, int fileline );
void _MSG_WriteData( sizebuf_t *sb, const void *data, size_t length, const char *filename, int fileline );
void _MSG_WriteDeltaUsercmd( sizebuf_t *sb, struct usercmd_s *from, struct usercmd_s *cmd, const char *filename, const int fileline );
@ -175,6 +230,7 @@ void _MSG_Send( msgtype_t to, vec3_t origin, edict_t *ent, const char *filename,
#define MSG_WriteWord(x,y) _MSG_WriteBits (x, y, NULL, NET_WORD, __FILE__, __LINE__)
#define MSG_WriteLong(x,y) _MSG_WriteBits (x, y, NULL, NET_LONG, __FILE__, __LINE__)
#define MSG_WriteFloat(x,y) _MSG_WriteFloat(x, y, __FILE__, __LINE__)
#define MSG_WriteDouble(x,y) _MSG_WriteDouble(x, y, __FILE__, __LINE__)
#define MSG_WriteString(x,y) _MSG_WriteString (x, y, __FILE__, __LINE__)
#define MSG_WriteCoord16(x, y) _MSG_WriteBits(x, y, NULL, NET_COORD, __FILE__, __LINE__)
#define MSG_WriteCoord32(x, y) _MSG_WriteBits(x, y, NULL, NET_FLOAT, __FILE__, __LINE__)
@ -198,6 +254,7 @@ void MSG_BeginReading (sizebuf_t *sb);
#define MSG_ReadAngle32( x ) _MSG_ReadBits( x, NET_FLOAT, __FILE__, __LINE__ )
float MSG_ReadFloat( sizebuf_t *msg );
char *MSG_ReadString( sizebuf_t *sb );
double MSG_ReadDouble( sizebuf_t *msg );
char *MSG_ReadStringLine( sizebuf_t *sb );
void MSG_ReadPos( sizebuf_t *sb, vec3_t pos );
void MSG_ReadData( sizebuf_t *sb, void *buffer, size_t size );

View File

@ -166,8 +166,6 @@ struct sv_priv_s
vec3_t water_origin; // step old origin
vec3_t moved_origin; // push old origin
vec3_t moved_angles; // push old angles
int solid; // see entity_state_t for details
physbody_t *physbody; // ptr to phys body
// baselines

View File

@ -496,7 +496,7 @@ void SV_PutClientInServer( edict_t *ent )
ent->pvServerData->s.fov = bound(1, ent->pvServerData->s.fov, 160);
ent->pvServerData->s.health = ent->v.health;
ent->pvServerData->s.classname = SV_ClassIndex( STRING( ent->v.classname ));
ent->pvServerData->s.pmodel.index = SV_ModelIndex( STRING( ent->v.weaponmodel ));
ent->pvServerData->s.weaponmodel = SV_ModelIndex( STRING( ent->v.weaponmodel ));
VectorCopy( ent->v.origin, ent->pvServerData->s.origin );
VectorCopy( ent->v.v_angle, ent->pvServerData->s.viewangles );
for( i = 0; i < 3; i++ ) ent->pvServerData->s.delta_angles[i] = ANGLE2SHORT(ent->v.v_angle[i]);
@ -633,7 +633,7 @@ void SV_Baselines_f( sv_client_t *cl )
while( cl->netchan.message.cursize < MAX_MSGLEN/2 && start < host.max_edicts )
{
base = &svs.baselines[start];
if( base->model.index || base->soundindex || base->effects )
if( base->modelindex || base->soundindex || base->effects )
{
MSG_WriteByte( &cl->netchan.message, svc_spawnbaseline );
MSG_WriteDeltaEntity( &nullstate, base, &cl->netchan.message, true, true );

View File

@ -50,36 +50,37 @@ void SV_UpdateEntityState( edict_t *ent )
// copy progs values to state
ent->pvServerData->s.number = ent->serialnumber;
ent->pvServerData->s.solid = ent->pvServerData->solid;
ent->pvServerData->s.solid = ent->v.solid;
if( !ent->pvServerData->s.classname )
ent->pvServerData->s.classname = SV_ClassIndex( STRING( ent->v.classname ));
VectorCopy (ent->v.origin, ent->pvServerData->s.origin);
VectorCopy (ent->v.angles, ent->pvServerData->s.angles);
ent->pvServerData->s.model.index = ent->v.modelindex;
ent->pvServerData->s.modelindex = ent->v.modelindex;
ent->pvServerData->s.health = ent->v.health;
ent->pvServerData->s.model.skin = ent->v.skin; // studio model skin
ent->pvServerData->s.model.body = ent->v.body; // studio model submodel
ent->pvServerData->s.skin = ent->v.skin; // studio model skin
ent->pvServerData->s.body = ent->v.body; // studio model submodel
ent->pvServerData->s.effects = ent->v.effects; // shared client and render flags
ent->pvServerData->s.renderfx = ent->v.renderfx; // renderer flags
ent->pvServerData->s.rendermode = ent->v.rendermode; // rendering mode
ent->pvServerData->s.renderamt = ent->v.renderamt; // alpha value
ent->pvServerData->s.model.animtime = (int)(1000.0 * ent->v.animtime) * 0.001; // sequence time
ent->pvServerData->s.model.scale = ent->v.scale; // shared client and render flags
ent->pvServerData->s.animtime = (int)(1000.0 * ent->v.animtime) * 0.001; // sequence time
ent->pvServerData->s.scale = ent->v.scale; // shared client and render flags
ent->pvServerData->s.movetype = ent->v.movetype;
ent->pvServerData->s.model.frame = ent->v.frame; // any model current frame
ent->pvServerData->s.model.framerate = ent->v.framerate;
ent->pvServerData->s.frame = ent->v.frame; // any model current frame
ent->pvServerData->s.framerate = ent->v.framerate;
ent->pvServerData->s.flags = ent->v.flags;
VectorCopy( ent->v.rendercolor, ent->pvServerData->s.rendercolor );
// studio model sequence
if( ent->v.sequence != -1 ) ent->pvServerData->s.model.sequence = ent->v.sequence;
if( ent->v.sequence != -1 ) ent->pvServerData->s.sequence = ent->v.sequence;
for( i = 0; i < 16; i++ )
{
// copy blendings and bone ctrls
ent->pvServerData->s.model.blending[i] = ent->v.blending[i];
ent->pvServerData->s.model.controller[i] = ent->v.controller[i];
// copy blendings and bone ctrlrs
ent->pvServerData->s.blending[i] = ent->v.blending[i];
ent->pvServerData->s.controller[i] = ent->v.controller[i];
}
if( ent->pvServerData->s.ed_type == ED_MOVER || ent->pvServerData->s.ed_type == ED_BSPBRUSH )
@ -111,7 +112,7 @@ void SV_UpdateEntityState( edict_t *ent )
else ent->pvServerData->s.aiment = 0;
// playermodel sequence, that will be playing on a client
ent->pvServerData->s.model.gaitsequence = ent->v.gaitsequence;
ent->pvServerData->s.gaitsequence = ent->v.gaitsequence;
ent->pvServerData->s.weapons = ent->v.weapons;
}
else if( ent->pvServerData->s.ed_type == ED_AMBIENT )
@ -355,7 +356,7 @@ static void SV_AddEntitiesToPacket( vec3_t origin, client_frame_t *frame, sv_ent
// if its a portal entity, add everything visible from its camera position
if( svent->s.ed_type == ED_PORTAL )
SV_AddEntitiesToPacket( svent->s.infotarget, frame, ents, true );
SV_AddEntitiesToPacket( svent->s.origin, frame, ents, true );
}
}

View File

@ -2299,6 +2299,30 @@ void pfnWriteFloat( float flValue )
svgame.msg_realsize += 4;
}
/*
=============
pfnWriteLong64
=============
*/
void pfnWriteLong64( int64 iValue )
{
_MSG_WriteBits( &sv.multicast, iValue, svgame.msg_name, NET_INT64, __FILE__, __LINE__ );
svgame.msg_realsize += 8;
}
/*
=============
pfnWriteDouble
=============
*/
void pfnWriteDouble( double flValue )
{
MSG_WriteFloat( &sv.multicast, flValue );
svgame.msg_realsize += 8;
}
/*
=============
pfnWriteString
@ -3024,6 +3048,8 @@ static enginefuncs_t gEngfuncs =
pfnWriteAngle,
pfnWriteCoord,
pfnWriteFloat,
pfnWriteLong64,
pfnWriteDouble,
pfnWriteString,
pfnWriteEntity,
pfnCVarRegister,

View File

@ -431,38 +431,25 @@ send it to transform callback
*/
void SV_PlayerMove( edict_t *player )
{
pmove_t pm;
entvars_t pmove;
sv_client_t *client;
physbody_t *body;
usercmd_t *cmd;
client = player->pvServerData->client;
memset( &pm, 0, sizeof(pm) );
if( player->v.movetype == MOVETYPE_NOCLIP )
player->pvServerData->s.pm_type = PM_SPECTATOR;
else player->pvServerData->s.pm_type = PM_NORMAL;
player->pvServerData->s.gravity = sv_gravity->value;
pmove = player->v;
cmd = &client->lastcmd;
body = player->pvServerData->physbody; // member body ptr
VectorCopy( player->pvServerData->s.delta_angles, pmove.delta_angles );
VectorCopy( player->pvServerData->s.viewangles, pmove.v_angle );
if( player->v.teleport_time )
player->pvServerData->s.pm_flags |= PMF_TIME_TELEPORT;
else player->pvServerData->s.pm_flags &= ~PMF_TIME_TELEPORT;
pe->PlayerMove( &pmove, cmd, body, false ); // server move
pm.ps = player->pvServerData->s;
pm.cmd = client->lastcmd;
pm.body = player->pvServerData->physbody; // member body ptr
VectorCopy( player->v.origin, pm.ps.origin );
VectorCopy( player->v.velocity, pm.ps.velocity );
pe->PlayerMove( &pm, false ); // server move
VectorCopy( pmove.v_angle, player->pvServerData->s.viewangles );
// save results of pmove
player->pvServerData->s = pm.ps;
VectorCopy(pm.ps.origin, player->v.origin);
VectorCopy(pm.ps.velocity, player->v.velocity);
VectorCopy(pm.mins, player->v.mins);
VectorCopy(pm.maxs, player->v.maxs);
VectorCopy(pm.ps.viewangles, player->pvServerData->s.viewangles );
player->v = pmove;
}
void SV_PlaySound( edict_t *ed, float volume, float pitch, const char *sample )

View File

@ -1772,7 +1772,7 @@ void SV_Physics( void )
}
// let everything in the world think and move
pe->Frame( svgame.globals->frametime * 0.001f );
pe->Frame( svgame.globals->frametime );
svgame.globals->time = sv.time;

View File

@ -221,7 +221,7 @@ void SV_ClassifyEdict( edict_t *ent )
sv_ent->s.ed_type = ED_MONSTER;
else if( ent->v.flags & FL_CLIENT )
sv_ent->s.ed_type = ED_CLIENT;
else if( !sv_ent->s.model.index && !sv_ent->s.aiment )
else if( !sv_ent->s.modelindex && !sv_ent->s.aiment )
{
if( sv_ent->s.soundindex )
sv_ent->s.ed_type = ED_AMBIENT;
@ -231,7 +231,7 @@ void SV_ClassifyEdict( edict_t *ent )
if( sv_ent->s.ed_type == ED_SPAWNED )
{
// mark as normal
if( sv_ent->s.model.index || sv_ent->s.soundindex )
if( sv_ent->s.modelindex || sv_ent->s.soundindex )
sv_ent->s.ed_type = ED_NORMAL;
}
@ -264,7 +264,7 @@ void SV_LinkEdict( edict_t *ent )
int leafs[MAX_TOTAL_ENT_LEAFS];
int clusters[MAX_TOTAL_ENT_LEAFS];
int num_leafs;
int i, j, k;
int i, j;
int area;
int topnode;
sv_priv_t *sv_ent;
@ -283,29 +283,6 @@ void SV_LinkEdict( edict_t *ent )
// set the size
VectorSubtract( ent->v.maxs, ent->v.mins, ent->v.size );
if( ent->v.solid == SOLID_BSP )
{
// a solid_bbox will never create this value
sv_ent->solid = SOLID_BMODEL;
}
else if(( int )ent->v.contents & ( CONTENTS_SOLID|CONTENTS_BODY ))
{
// encode the size into the entity_state for client prediction
// assume that x/y are equal and symetric
i = ent->v.maxs[0];
i = bound( 1, i, 255 );
// z is not symetric
j = (-ent->v.mins[2]);
j = bound( 1, j, 255 );
// and z maxs can be negative...
k = (ent->v.maxs[2] + 32);
k = bound( 1, k, 255 );
sv_ent->solid = (k<<16)|(j<<8)|i;
}
else sv_ent->solid = 0;
// set the abs box
svgame.dllFuncs.pfnSetAbsBox( ent );

View File

@ -3,10 +3,9 @@
// cpuinfo.c - get cpu information
//=======================================================================
#include "const.h"
#include "launch.h"
typedef signed __int64 int64;
// Processor Information:
typedef struct cpuinfo_s
{

View File

@ -22,6 +22,10 @@ matrix4x4 m_matrix;
// any differences when running on client or server
typedef struct
{
entvars_t *pev;
usercmd_t *cmd;
physbody_t *body;
vec3_t origin;
vec3_t velocity;
vec3_t previous_origin;
@ -45,8 +49,7 @@ typedef struct
} pml_t;
pmove_t *pm;
pml_t pml;
pml_t pml;
/*
================
@ -56,38 +59,38 @@ This can be used as another entry point when only the viewangles
are being updated isntead of a full move
================
*/
void CM_UpdateViewAngles( entity_state_t *ps, const usercmd_t *cmd )
void CM_UpdateViewAngles( entvars_t *pev, const usercmd_t *cmd )
{
short temp;
int i;
short temp;
int i;
if( ps->pm_type == PM_INTERMISSION )
if( pev->flags & FL_FROZEN )
{
return; // no view changes at all
}
if( ps->pm_type == PM_DEAD )
if( pev->health <= 0 )
{
return; // no view changes at all
}
if( pm->ps.pm_flags & PMF_TIME_TELEPORT)
if( pev->teleport_time )
{
ps->viewangles[YAW] = SHORT2ANGLE( pm->cmd.angles[YAW] - pm->ps.delta_angles[YAW] );
ps->viewangles[PITCH] = 0;
ps->viewangles[ROLL] = 0;
pev->v_angle[YAW] = SHORT2ANGLE( cmd->angles[YAW] - pev->delta_angles[YAW] );
pev->v_angle[PITCH] = 0;
pev->v_angle[ROLL] = 0;
}
// circularly clamp the angles with deltas
for( i = 0; i < 3; i++ )
{
temp = pm->cmd.angles[i] + pm->ps.delta_angles[i];
ps->viewangles[i] = SHORT2ANGLE(temp);
temp = cmd->angles[i] + pev->delta_angles[i];
pev->v_angle[i] = SHORT2ANGLE( temp );
}
// don't let the player look up or down more than 90 degrees
if( ps->viewangles[PITCH] > 89 && ps->viewangles[PITCH] < 180 )
ps->viewangles[PITCH] = 89;
else if( ps->viewangles[PITCH] < 271 && ps->viewangles[PITCH] >= 180 )
ps->viewangles[PITCH] = 271;
if( pev->v_angle[PITCH] > 89 && pev->v_angle[PITCH] < 180 )
pev->v_angle[PITCH] = 89;
else if( pev->v_angle[PITCH] < 271 && pev->v_angle[PITCH] >= 180 )
pev->v_angle[PITCH] = 271;
}
@ -96,8 +99,8 @@ void CM_CmdUpdateForce( void )
float fmove, smove;
int i;
fmove = pm->cmd.forwardmove;
smove = pm->cmd.sidemove;
fmove = pml.cmd->forwardmove;
smove = pml.cmd->sidemove;
// project moves down to flat plane
pml.forward[2] = pml.right[2] = 0;
@ -109,23 +112,25 @@ void CM_CmdUpdateForce( void )
ConvertDirectionToPhysic( pml.movedir );
if( pm->cmd.upmove > 0.0f )
if( pml.cmd->upmove > 0.0f )
{
m_jumpTimer = 4;
}
}
void CM_ServerMove( pmove_t *pmove )
void CM_ServerMove( entvars_t *pmove, usercmd_t *cmd, physbody_t *body )
{
float mass, Ixx, Iyy, Izz, dist, floor;
float deltaHeight, steerAngle, accelY, timestepInv;
vec3_t force, omega, torque, heading, velocity, step;
matrix4x4 matrix, collisionPadding, transpose;
pm = pmove;
pml.pev = pmove;
pml.body = body;
pml.cmd = cmd;
CM_UpdateViewAngles( &pm->ps, &pm->cmd );
AngleVectors( pm->ps.viewangles, pml.forward, pml.right, pml.up );
CM_UpdateViewAngles( pmove, cmd );
AngleVectors( pml.pev->v_angle, pml.forward, pml.right, pml.up );
CM_CmdUpdateForce(); // get movement direction
// Get the current world timestep
@ -133,16 +138,16 @@ void CM_ServerMove( pmove_t *pmove )
timestepInv = 1.0f / pml.frametime;
// get the character mass
NewtonBodyGetMassMatrix( pm->body, &mass, &Ixx, &Iyy, &Izz );
NewtonBodyGetMassMatrix( pml.body, &mass, &Ixx, &Iyy, &Izz );
// apply the gravity force, cheat a little with the character gravity
VectorSet( force, 0.0f, mass * -9.8f, 0.0f );
// Get the velocity vector
NewtonBodyGetVelocity( pm->body, &velocity[0] );
NewtonBodyGetVelocity( pml.body, &velocity[0] );
// determine if the character have to be snap to the ground
NewtonBodyGetMatrix( pm->body, &matrix[0][0] );
NewtonBodyGetMatrix( pml.body, &matrix[0][0] );
// if the floor is with in reach then the character must be snap to the ground
// the max allow distance for snapping i 0.25 of a meter
@ -161,7 +166,7 @@ void CM_ServerMove( pmove_t *pmove )
else if( m_jumpTimer == 4 )
{
vec3_t veloc = { 0.0f, 0.3f, 0.0f };
NewtonAddBodyImpulse( pm->body, &veloc[0], &matrix[3][0] );
NewtonAddBodyImpulse( pml.body, &veloc[0], &matrix[3][0] );
}
m_jumpTimer = m_jumpTimer ? m_jumpTimer - 1 : 0;
@ -178,7 +183,7 @@ void CM_ServerMove( pmove_t *pmove )
VectorSubtract( tmp1, tmp2, result );
VectorAdd( force, result, force );
NewtonBodySetForce( pm->body, &force[0] );
NewtonBodySetForce( pml.body, &force[0] );
VectorScale( force, pml.frametime / mass, tmp1 );
VectorAdd( tmp1, velocity, step );
@ -219,10 +224,10 @@ void CM_ServerMove( pmove_t *pmove )
steerAngle = asin( bound( -1.0f, pml.forward[2], 1.0f ));
// calculate the torque vector
NewtonBodyGetOmega( pm->body, &omega[0]);
NewtonBodyGetOmega( pml.body, &omega[0]);
VectorSet( torque, 0.0f, 0.5f * Iyy * (steerAngle * timestepInv - omega[1] ) * timestepInv, 0.0f );
NewtonBodySetTorque( pm->body, &torque[0] );
NewtonBodySetTorque( pml.body, &torque[0] );
// assume the character is on the air. this variable will be set to false if the contact detect
@ -233,7 +238,7 @@ void CM_ServerMove( pmove_t *pmove )
NewtonUpVectorSetPin( cms.upVector, &vec3_up[0] );
}
void CM_ClientMove( pmove_t *pmove )
void CM_ClientMove( entvars_t *pmove, usercmd_t *cmd, physbody_t *body )
{
}
@ -310,10 +315,10 @@ physbody_t *Phys_CreatePlayer( edict_t *ed, cmodel_t *mod, const vec3_t origin,
PMOVE ENTRY POINT
===============================================================================
*/
void CM_PlayerMove( pmove_t *pmove, bool clientmove )
void CM_PlayerMove( entvars_t *pmove, usercmd_t *cmd, physbody_t *body, bool clientmove )
{
if( !cm_physics_model->integer ) return;
if( clientmove ) CM_ClientMove( pmove );
else CM_ServerMove( pmove );
if( clientmove ) CM_ClientMove( pmove, cmd, body );
else CM_ServerMove( pmove, cmd, body );
}

View File

@ -74,9 +74,9 @@ void CM_ModelBounds( cmodel_t *model, vec3_t mins, vec3_t maxs );
float CM_FindFloor( vec3_t p0, float maxDist );
void CM_SetOrigin( physbody_t *body, vec3_t origin );
void CM_PlayerMove( pmove_t *pmove, bool clientmove );
void CM_ServerMove( pmove_t *pmove );
void CM_ClientMove( pmove_t *pmove );
void CM_PlayerMove( entvars_t *pmove, usercmd_t *cmd, physbody_t *body, bool clientmove );
void CM_ServerMove( entvars_t *pmove, usercmd_t *cmd, physbody_t *body );
void CM_ClientMove( entvars_t *pmove, usercmd_t *cmd, physbody_t *body );
void PolygonF_QuadForPlane( float *outpoints, float planenormalx, float planenormaly, float planenormalz, float planedist, float quadsize );
void PolygonD_QuadForPlane( double *outpoints, double planenormalx, double planenormaly, double planenormalz, double planedist, double quadsize );

View File

@ -9,6 +9,7 @@
#include <windows.h>
#include "launch_api.h"
#include "engine_api.h"
#include "entity_def.h"
#include "physic_api.h"
#include "qfiles_ref.h"

View File

@ -109,12 +109,12 @@ _inline double DoubleSwap( double swap )
#endif
// extract from buffer
_inline dword BuffBigLong( const byte *buf )
_inline unsigned long BuffBigLong( const byte *buf )
{
return (buf[0]<<24)|(buf[1]<<16)|(buf[2]<<8)|buf[3];
}
_inline word BuffBigShort( const byte *buf )
_inline unsigned short BuffBigShort( const byte *buf )
{
return (buf[0]<<8)|buf[1];
}
@ -129,12 +129,12 @@ _inline double BuffBigDouble( const byte *buf )
return (buf[0]<<64)|(buf[1]<<56)|(buf[2]<<40)|(buf[3]<<32)|(buf[4]<<24)|(buf[5]<<16)|(buf[6]<<8)|buf[7];
}
_inline dword BuffLittleLong( const byte *buf )
_inline unsigned long BuffLittleLong( const byte *buf )
{
return (buf[3]<<24)|(buf[2]<<16)|(buf[1]<<8)|buf[0];
}
_inline word BuffLittleShort( const byte *buf )
_inline unsigned short BuffLittleShort( const byte *buf )
{
return (buf[1]<<8)|buf[0];
}
@ -144,7 +144,7 @@ _inline float BuffLittleFloat( const byte *buf )
return BuffLittleLong( buf );
}
_inline double BuffLittleDouble( const byte *buf )
_inline signed __int64 BuffLittleLong64( const byte *buf )
{
return (buf[7]<<64)|(buf[6]<<56)|(buf[5]<<40)|(buf[4]<<32)|(buf[3]<<24)|(buf[2]<<16)|(buf[1]<<8)|buf[0];
}

View File

@ -78,6 +78,18 @@ typedef struct client_textmessage_s
const char *pMessage;
} client_textmessage_t;
typedef struct client_data_s
{
vec3_t origin;
vec3_t angles;
int iKeyBits; // Keyboard bits
int64 iWeaponBits; // came from pev->weapons
float fov; // field of view
float v_idlescale; // view shake/rotate
float mouse_sensitivity; // used for menus
} client_data_t;
// NOTE: engine trace struct not matched with clgame trace
typedef struct
{
@ -120,8 +132,6 @@ typedef struct ref_params_s
BOOL spectator;
BOOL paused;
uint rdflags; // client view effects: RDF_UNDERWATER, RDF_MOTIONBLUR, etc
int iWeaponBits; // pev->weapon
int iKeyBits; // pev->button
edict_t *onground; // pointer to onground entity
byte *areabits; // come from server, contains visible areas list
int waterlevel;
@ -135,8 +145,6 @@ typedef struct ref_params_s
vec3_t viewheight;
float idealpitch;
float v_idlescale; // used for concussion effect
float mouse_sensitivity;
int health;
vec3_t crosshairangle; // pfnCrosshairAngle values from server
@ -182,8 +190,8 @@ typedef struct cl_enginefuncs_s
void (*pfnAlertMessage)( ALERT_TYPE, char *szFmt, ... );
// sound handlers (NULL origin == play at current client origin)
void (*pfnPlaySoundByName)( const char *szSound, float volume, const float *org );
void (*pfnPlaySoundByIndex)( int iSound, float volume, const float *org );
void (*pfnPlaySoundByName)( const char *szSound, float volume, int pitch, const float *org );
void (*pfnPlaySoundByIndex)( int iSound, float volume, int pitch, const float *org );
// vector helpers
void (*pfnAngleVectors)( const float *rgflVector, float *forward, float *right, float *up );
@ -227,7 +235,7 @@ typedef struct
int (*pfnVidInit)( void );
void (*pfnInit)( void );
int (*pfnRedraw)( float flTime, int state );
int (*pfnUpdateClientData)( ref_params_t *parms, float flTime );
int (*pfnUpdateClientData)( client_data_t *cdata, float flTime );
void (*pfnReset)( void );
void (*pfnFrame)( double time );
void (*pfnShutdown)( void );

View File

@ -6,6 +6,7 @@
#define CONST_H
// shared typedefs
typedef signed __int64 int64;
typedef unsigned __int64 qword;
typedef unsigned long dword;
typedef unsigned int uint;
@ -58,10 +59,10 @@ typedef int shader_t;
#define IN_ALT1 (1<<14)
#define IN_SCORE (1<<15) // Used by client.dll for when scoreboard is held down
// edict_t->spawnflags
// pev->spawnflags
#define SF_START_ON 0x1
// edict->flags
// pev->flags
#define FL_FLY (1<<0) // changes the SV_Movestep() behavior to not need to be on ground
#define FL_SWIM (1<<1) // same as AI_FLY but stay in water
#define FL_CLIENT (1<<2)
@ -87,7 +88,7 @@ typedef int shader_t;
#define FL_DORMANT (1<<21) // Entity is dormant, no updates to client
#define FL_POINTENTITY (1<<22) // this is point entity
// entity_state_t->effects
// pev->effects
#define EF_BRIGHTFIELD (1<<0) // swirling cloud of particles
#define EF_MUZZLEFLASH (1<<1) // single frame ELIGHT on entity attachment 0
#define EF_BRIGHTLIGHT (1<<2) // DLIGHT centered at entity origin
@ -229,6 +230,11 @@ typedef enum
kRenderFxNoReflect, // don't reflecting in mirrors
} kRenderFx_t;
#define EVENT_SPECIFIC 0
#define EVENT_SCRIPTED 1000
#define EVENT_SHARED 2000
#define EVENT_CLIENT 5000 // less than this value it's a server-side studio events
// player_state_t->renderfx
#define RDF_UNDERWATER (1<<0) // warp the screen as apropriate
#define RDF_NOWORLDMODEL (1<<1) // used for player configuration screen
@ -265,7 +271,7 @@ typedef enum
// server.dll - client.dll definitions only
//
//=======================================================================
#define MAX_WEAPONS 32
#define MAX_WEAPONS 64 // special for Ghoul[BB] mod support
#define MAX_AMMO_SLOTS 32
#define HIDEHUD_WEAPONS BIT( 0 )

View File

@ -21,68 +21,6 @@
#define MAX_EDICTS 65535 // absolute limit that never be reached, (do not edit!)
#define MAX_VERTS_ON_POLY 10 // decal vertices
// model_state_t communication (a part of network protocol)
typedef struct model_state_s
{
int index; // server & client shared modelindex
int colormap; // change base color for some textures or sprite frames
float scale; // model or sprite scale, affects to physics too
float frame; // % playback position in animation sequences (0..255)
float animtime; // auto-animating time
float framerate; // custom framerate, specified by QC
int sequence; // animation sequence (0 - 255)
int gaitsequence; // client\nps\bot gaitsequence
int skin; // skin for studiomodels
int body; // sub-model selection for studiomodels
float blending[16]; // studio animation blending
float controller[16]; // studio bone controllers
} model_state_t;
// entity_state_t communication (a part of network protocol)
typedef struct entity_state_s
{
// engine specific
uint number; // edict index
edtype_t ed_type; // edict type
string_t classname; // edict classname
int soundindex; // looped ambient sound
// physics information
vec3_t origin;
vec3_t angles; // entity angles, not viewangles
vec3_t velocity; // player velocity
vec3_t infotarget; // portal camera, etc
model_state_t model; // general entity model
solid_t solidtype; // entity solidtype
movetype_t movetype; // entity movetype
int gravity; // gravity multiplier
int aiment; // attahced entity (not a physic attach, only rendering)
int solid; // using for symmetric bboxes
vec3_t mins; // not symmetric entity bbox
vec3_t maxs;
// render information
uint effects; // effect flags like q1 and hl1
int renderfx; // render effects same as hl1
float renderamt; // alpha value or like somewhat
vec3_t rendercolor; // hl1 legacy stuff, working, but not needed
int rendermode; // hl1 legacy stuff, working, but not needed
// client specific
int pm_type; // client movetype
int pm_flags; // ducked, jump_held, etc
vec3_t delta_angles; // add to command angles to get view direction
vec3_t punch_angles; // add to view direction to get render angles
vec3_t viewangles; // already calculated view angles on server-side
vec3_t viewoffset; // viewoffset over ground
int maxspeed; // sv_maxspeed will be duplicate on all clients
int viewmodel; // contains vmodel index
float health; // client health (other parms can be send by custom messages)
float fov; // horizontal field of view
int weapons; // weapon flags
model_state_t pmodel; // weaponmodel info
} entity_state_t;
// usercmd_t communication (a part of network protocol)
typedef struct usercmd_s
{
@ -197,7 +135,6 @@ typedef struct trace_s
edict_t *ent; // not set by CM_*() functions
} trace_t;
_inline void PlaneClassify( cplane_t *p )
{
// for optimized plane comparisons

View File

@ -79,7 +79,7 @@ typedef struct entvars_s
float health;
float frags;
int weapons; // bit mask for available weapons
int64 weapons; // bit mask for available weapons
float takedamage;
int deadflag;
@ -101,6 +101,7 @@ typedef struct entvars_s
// player specific only
vec3_t punchangle; // auto-decaying view angle adjustment
vec3_t v_angle; // viewing angle (player only)
vec3_t delta_angles; // viewangles - cmd.angles
int fixangle; // 0 - nothing, 1 - force view angles, 2 - add avelocity
string_t viewmodel; // player's viewmodel
int gaitsequence; // movement animation sequence for player (0 for none)

View File

@ -5,48 +5,6 @@
#ifndef PHYSIC_API_H
#define PHYSIC_API_H
// pmove_state_t is the information necessary for client side movement
#define PM_NORMAL 0 // can accelerate and turn
#define PM_SPECTATOR 1
#define PM_DEAD 2 // no acceleration or turning
#define PM_GIB 3 // different bounding box
#define PM_FREEZE 4
#define PM_INTERMISSION 5
#define PM_NOCLIP 6
// pmove->pm_flags
#define PMF_DUCKED 1
#define PMF_JUMP_HELD 2
#define PMF_ON_GROUND 4
#define PMF_TIME_WATERJUMP 8 // pm_time is waterjump
#define PMF_TIME_LAND 16 // pm_time is time before rejump
#define PMF_TIME_TELEPORT 32 // pm_time is non-moving time
#define PMF_NO_PREDICTION 64 // temporarily disables prediction (used for grappling hook)
#define PMF_ALL_TIMES (PMF_TIME_WATERJUMP|PMF_TIME_LAND|PMF_TIME_TELEPORT)
typedef struct pmove_s
{
entity_state_t ps; // state (in / out)
// command (in)
usercmd_t cmd;
physbody_t *body; // pointer to physobject
// results (out)
int numtouch;
edict_t *touchents[32]; // max touch
edict_t *groundentity;
vec3_t mins, maxs; // bounding box size
int watertype;
int waterlevel;
float xyspeed; // avoid to compute it twice
// callbacks to test the world
void (*trace)( vec3_t start, vec3_t mins, vec3_t maxs, vec3_t end, trace_t *tr );
int (*pointcontents)( vec3_t point );
} pmove_t;
/*
==============================================================================
@ -98,7 +56,7 @@ typedef struct physic_exp_s
void (*CombineTraces)( trace_t *cliptrace, const trace_t *trace, edict_t *touch, bool is_bmodel );
// player movement code
void (*PlayerMove)( pmove_t *pmove, bool clientmove );
void (*PlayerMove)( entvars_t *pmove, usercmd_t *cmd, physbody_t *body, bool clientmove );
// simple objects
physbody_t *(*CreateBody)( edict_t *ed, cmodel_t *mod, const vec3_t org, const matrix3x3 m, int solid, int move );

View File

@ -139,6 +139,8 @@ typedef struct enginefuncs_s
void (*pfnWriteAngle)( float flValue );
void (*pfnWriteCoord)( float flValue );
void (*pfnWriteFloat)( float flValue );
void (*pfnWriteLong64)( int64 iValue );
void (*pfnWriteDouble)( double flValue );
void (*pfnWriteString)( const char *sz );
void (*pfnWriteEntity)( int iValue );
void (*pfnCVarRegister)( const char *name, const char *value, int flags, const char *desc );

View File

@ -31,7 +31,7 @@ typedef struct vsound_exp_s
void (*StartSound)( const vec3_t pos, int ent, int chan, sound_t sfx, float vol, float attn, float pitch, bool loop );
void (*StreamRawSamples)( int samples, int rate, int width, int channels, const byte *data );
bool (*AddLoopingSound)( int entnum, sound_t handle, float volume, float attn );
bool (*StartLocalSound)( const char *name, float volume, const float *origin );
bool (*StartLocalSound)( const char *name, float volume, float pitch, const float *origin );
void (*StartBackgroundTrack)( const char *introTrack, const char *loopTrack );
void (*StopBackgroundTrack)( void );

View File

@ -369,6 +369,45 @@ void R_StudioResetSequenceInfo( ref_entity_t *ent, dstudiohdr_t *hdr )
ent->m_fSequenceFinished = FALSE;
}
int R_StudioGetEvent( dstudioevent_t *pcurrent, float flStart, float flEnd, int index )
{
dstudioseqdesc_t *pseqdesc;
dstudioevent_t *pevent;
int events = 0;
pseqdesc = (dstudioseqdesc_t *)((byte *)m_pStudioHeader + m_pStudioHeader->seqindex) + m_pCurrentEntity->sequence;
pevent = (dstudioevent_t *)((byte *)m_pStudioHeader + pseqdesc->eventindex);
if( pseqdesc->numevents == 0 || index > pseqdesc->numevents )
return 0;
if( pseqdesc->numframes > 1 )
{
flStart *= (pseqdesc->numframes - 1) / 256.0;
flEnd *= (pseqdesc->numframes - 1) / 256.0;
}
else
{
flStart = 0;
flEnd = 1.0;
}
for( ; index < pseqdesc->numevents; index++ )
{
// don't send server-side events to the client effects
if( pevent[index].event < EVENT_CLIENT )
continue;
if(( pevent[index].frame >= flStart && pevent[index].frame < flEnd )
|| ((pseqdesc->flags & STUDIO_LOOPING) && flEnd >= pseqdesc->numframes - 1 && pevent[index].frame < flEnd - pseqdesc->numframes + 1 ))
{
Mem_Copy( pcurrent, &pevent[index], sizeof( *pcurrent ));
return index + 1;
}
}
return 0;
}
/*
====================
StudioCalcBoneAdj
@ -389,7 +428,6 @@ void R_StudioCalcBoneAdj( float dadt, float *adj, const float *pcontroller1, con
if( i == STUDIO_MOUTH )
{
// FIXME: convert to float
// mouth hardcoded at controller 4
value = mouthopen / 64.0;
if (value > 1.0) value = 1.0;
@ -1729,6 +1767,7 @@ bool R_StudioDrawModel( int pass, int flags )
{
if( /*mirror_render ||*/ r_lefthand->value == 2 )
return 0;
flags |= STUDIO_EVENTS;
}
R_StudioSetupRender( pass );
@ -1762,16 +1801,20 @@ bool R_StudioDrawModel( int pass, int flags )
if( flags & STUDIO_EVENTS )
{
float flStart = m_pCurrentEntity->frame + m_pCurrentEntity->framerate;
float flEnd = m_pCurrentEntity->frame + m_pCurrentEntity->framerate * 1.5f;
edict_t *ent = ri.GetClientEdict( m_pCurrentEntity->index );
dstudioevent_t event;
int index = 0;
R_StudioCalcAttachments();
Mem_Set( &event, 0, sizeof( event ));
//FIXME:
//ri.StudioEvent( dstudioevent_t *event, ent );
if( m_pCurrentEntity->index > 0 )
// copy attachments into global entity array
Mem_Copy( ent->v.attachment, m_pCurrentEntity->attachment, sizeof( vec3_t ) * MAXSTUDIOATTACHMENTS );
while(( index = R_StudioGetEvent( &event, flStart, flEnd, index )) != 0 )
{
// copy attachments into global entity array
edict_t *ent = ri.GetClientEdict( m_pCurrentEntity->index );
Mem_Copy( ent->v.attachment, m_pCurrentEntity->attachment, sizeof(vec3_t) * MAXSTUDIOATTACHMENTS );
ri.StudioEvent( &event, ent );
}
}

View File

@ -19,7 +19,7 @@
extern int gEvilImpulse101;
ItemInfo CBasePlayerWeapon::ItemInfoArray[MAX_WEAPONS];
AmmoInfo CBasePlayerWeapon::AmmoInfoArray[MAX_AMMO_SLOTS];
char NameItems[MAX_WEAPONS][29];
char NameItems[MAX_WEAPONS][64];
int ID[MAX_WEAPONS];
int GlobalID = 0;
int g_iSwing;

View File

@ -81,6 +81,8 @@ inline void MESSAGE_BEGIN( int msg_dest, int msg_type, const float *pOrigin = NU
#define WRITE_ANGLE (*g_engfuncs.pfnWriteAngle)
#define WRITE_COORD (*g_engfuncs.pfnWriteCoord)
#define WRITE_FLOAT (*g_engfuncs.pfnWriteFloat)
#define WRITE_LONG64 (*g_engfuncs.pfnWriteLong64)
#define WRITE_DOUBLE (*g_engfuncs.pfnWriteDouble)
#define WRITE_STRING (*g_engfuncs.pfnWriteString)
#define WRITE_ENTITY (*g_engfuncs.pfnWriteEntity)
#define CVAR_REGISTER (*g_engfuncs.pfnCVarRegister)

View File

@ -21,11 +21,6 @@ typedef struct
char *options;
} MonsterEvent_t;
#define EVENT_SPECIFIC 0
#define EVENT_SCRIPTED 1000
#define EVENT_SHARED 2000
#define EVENT_CLIENT 5000
#define MONSTER_EVENT_BODYDROP_LIGHT 2001
#define MONSTER_EVENT_BODYDROP_HEAVY 2002

View File

@ -40,10 +40,11 @@ Beta 13.12.08
19.AddRefEntity uses edict_t instead entity state OK
20.render custom models OK
21.zoom_hud and warhead hud OK
22.entity_state_t revision 4
22.entity_state_t revision 4 OK
23.entvars_t revision 1
entity_state_t íåâèäèìà äëÿ ïîëüçîâàòåëÿ
24.UpdateClientData - move call to cl_input.c OK
25.wrote HUD_StudioEvents
16.register cmd->buttons OK
Ñïèñîê äîñòóïíûõ ðåíäåðåðîâ: ×òî â íèõ èíòåðåñíîãî

View File

@ -492,7 +492,7 @@ S_StartLocalSound
menu sound
=================
*/
bool S_StartLocalSound( const char *name, float volume, const float *origin )
bool S_StartLocalSound( const char *name, float volume, float pitch, const float *origin )
{
sound_t sfxHandle;
@ -500,7 +500,7 @@ bool S_StartLocalSound( const char *name, float volume, const float *origin )
return false;
sfxHandle = S_RegisterSound( name );
S_StartSound( origin, al_state.clientnum, CHAN_AUTO, sfxHandle, volume, ATTN_NONE, PITCH_NORM, false );
S_StartSound( origin, al_state.clientnum, CHAN_AUTO, sfxHandle, volume, ATTN_NONE, pitch, false );
return true;
}
@ -713,7 +713,7 @@ void S_PlaySound_f( void )
Msg( "Usage: playsound <soundfile>\n" );
return;
}
S_StartLocalSound( Cmd_Argv( 1 ), 1.0f, NULL );
S_StartLocalSound( Cmd_Argv( 1 ), 1.0f, PITCH_NORM, NULL );
}
/*

View File

@ -176,7 +176,7 @@ void S_StreamRawSamples( int samples, int rate, int width, int channels, const b
bool S_AddLoopingSound( int entnum, sound_t handle, float volume, float attn );
void S_StartBackgroundTrack( const char *intro, const char *loop );
channel_t *S_PickChannel( int entNum, int entChannel );
int S_StartLocalSound( const char *name, float volume, const float *org );
int S_StartLocalSound( const char *name, float volume, float pitch, const float *org );
sfx_t *S_GetSfxByHandle( sound_t handle );
void S_StreamBackgroundTrack( void );
void S_StopBackgroundTrack( void );