29 Jun 2010

This commit is contained in:
g-cont 2010-06-29 00:00:00 +04:00 committed by Alibek Omarov
parent e048dd6518
commit 2170e82a7b
75 changed files with 1529 additions and 1466 deletions

View File

@ -65,7 +65,7 @@ static DLL_FUNCTIONS gFunctionTable =
ParmsChangeLevel, //pfnParmsChangeLevel
GetGameDescription, //pfnGetGameDescription Returns string describing current .dll game.
GetEntvarsDescirption, // pfnGetEntvarsDescirption engine uses this to lookup entvars table
DispatchFrame, // pfnPhysicsEntity
SpectatorConnect, //pfnSpectatorConnect Called when spectator joins server
SpectatorDisconnect, //pfnSpectatorDisconnect Called when spectator leaves the server
@ -78,13 +78,13 @@ static DLL_FUNCTIONS gFunctionTable =
PM_FindTextureType, // pfnPM_FindTextureType
SetupVisibility, // pfnSetupVisibility
DispatchFrame, // pfnPhysicsEntity
UpdateClientData, // pfnUpdateClientData
AddToFullPack, // pfnAddtoFullPack
EndFrame, // pfnEndFrame
CreateBaseline, // fpnCreateBaseline
RegisterEncoders, // pfnRegisterEncoders Callbacks for network encoding
UpdateEntityState, // pfnUpdateEntityState
GetWeaponData, // pfnGetWeaponData
CmdStart, // pfnCmdStart
CmdEnd, // pfnCmdEnd

View File

@ -79,9 +79,7 @@ extern void SaveReadFields( SAVERESTOREDATA *pSaveData, const char *pname, void
extern void SaveGlobalState( SAVERESTOREDATA *pSaveData );
extern void RestoreGlobalState( SAVERESTOREDATA *pSaveData );
extern void ResetGlobalState( void );
extern TYPEDESCRIPTION *GetEntvarsDescirption( int number );
extern int ServerClassifyEdict( edict_t *pentToClassify );
extern void UpdateEntityState( struct entity_state_s *to, edict_t *from, int baseline );
extern void OnFreeEntPrivateData( edict_s *pEdict );
extern int ShouldCollide( edict_t *pentTouched, edict_t *pentOther );

View File

@ -34,6 +34,7 @@
#include "gamerules.h"
#include "game.h"
#include "weapons.h"
#include "weaponinfo.h"
#include "usercmd.h"
#include "effects.h"
@ -707,10 +708,6 @@ void StartFrame( void )
}
}
void EndFrame( void )
{
}
void ClientPrecache( void )
{
// setup precaches always needed
@ -987,131 +984,6 @@ int ServerClassifyEdict( edict_t *pentToClassify )
return m_iNewClass;
}
void UpdateEntityState( entity_state_t *to, edict_t *from, int baseline )
{
int i;
if( !to || !from ) return;
CBaseEntity *pNet;
pNet = CBaseEntity::Instance( from );
if( !pNet ) return;
// setup some special edict flags (engine will clearing them after the current frame)
if( to->modelindex != pNet->pev->modelindex )
to->ed_flags |= ESF_NODELTA;
// always set nodelta's for baseline
if( baseline ) to->ed_flags |= ESF_NODELTA;
// copy progs values to state
to->solid = (solid_t)pNet->pev->solid;
to->origin = pNet->pev->origin;
to->angles = pNet->pev->angles;
to->modelindex = pNet->pev->modelindex;
to->health = pNet->pev->health;
to->skin = pNet->pev->skin; // studio model skin
to->body = pNet->pev->body; // studio model submodel
to->effects = pNet->pev->effects; // shared client and render flags
to->renderfx = pNet->pev->renderfx; // renderer flags
to->rendermode = pNet->pev->rendermode; // rendering mode
to->renderamt = pNet->pev->renderamt; // alpha value
to->animtime = (int)(1000.0 * pNet->pev->animtime) * 0.001; // sequence time
to->localtime = (int)(1000.0 * pNet->pev->ltime) * 0.001; // movement time
to->scale = pNet->pev->scale; // shared client and render flags
to->movetype = (movetype_t)pNet->pev->movetype;
to->frame = pNet->pev->frame; // any model current frame
to->framerate = pNet->pev->framerate;
to->mins = pNet->pev->mins;
to->maxs = pNet->pev->maxs;
to->flags = pNet->pev->flags;
to->rendercolor = pNet->pev->rendercolor;
to->oldorigin = pNet->pev->oldorigin;
to->colormap = pNet->pev->colormap; // attachments
if( pNet->pev->groundentity )
to->groundent = ENTINDEX( pNet->pev->groundentity );
else to->groundent = NULLENT_INDEX;
// translate attached entity
if( pNet->pev->aiment )
to->aiment = ENTINDEX( pNet->pev->aiment );
else to->aiment = NULLENT_INDEX;
// studio model sequence
if( pNet->pev->sequence != -1 ) to->sequence = pNet->pev->sequence;
for( i = 0; i < 16; i++ )
{
// copy blendings and bone ctrlrs
to->blending[i] = pNet->pev->blending[i];
to->controller[i] = pNet->pev->controller[i];
}
if( to->ed_type == ED_CLIENT )
{
if( pNet->pev->teleport_time )
{
to->ed_flags |= ESF_NO_PREDICTION;
to->ed_flags |= ESF_NODELTA;
pNet->pev->teleport_time = 0.0f;
}
if( pNet->pev->viewmodel )
to->viewmodel = MODEL_INDEX( STRING( pNet->pev->viewmodel ));
else to->viewmodel = 0;
if( pNet->pev->aiment )
to->aiment = ENTINDEX( pNet->pev->aiment );
else to->aiment = NULLENT_INDEX;
to->viewoffset = pNet->pev->view_ofs;
to->viewangles = pNet->pev->v_angle;
to->idealpitch = pNet->pev->idealpitch;
to->punch_angles = pNet->pev->punchangle;
to->velocity = pNet->pev->velocity;
to->basevelocity = pNet->pev->clbasevelocity;
to->iStepLeft = pNet->pev->iStepLeft;
to->flFallVelocity = pNet->pev->flFallVelocity;
// playermodel sequence, that will be playing on a client
if( pNet->pev->gaitsequence != -1 )
to->gaitsequence = pNet->pev->gaitsequence;
if( pNet->pev->weaponmodel != iStringNull )
to->weaponmodel = MODEL_INDEX( STRING( pNet->pev->weaponmodel ));
else to->weaponmodel = 0;
to->weapons = pNet->pev->weapons;
to->maxspeed = pNet->pev->maxspeed;
// clamp fov
if( pNet->pev->fov < 0.0 ) pNet->pev->fov = 0.0;
if( pNet->pev->fov > 160 ) pNet->pev->fov = 160;
to->fov = pNet->pev->fov;
}
else if( to->ed_type == ED_AMBIENT )
{
// add here specified fiels e.g for trigger_teleport wind sound etc
}
else if( to->ed_type == ED_MOVER || to->ed_type == ED_BSPBRUSH || to->ed_type == ED_PORTAL )
{
to->body = DirToBits( pNet->pev->movedir );
to->velocity = pNet->pev->velocity;
// this is conveyor - send speed to render for right texture scrolling
to->framerate = pNet->pev->speed;
}
else if( to->ed_type == ED_BEAM )
{
to->gaitsequence = pNet->pev->frags; // beam type
// translate StartBeamEntity
if( pNet->pev->owner )
to->owner = ENTINDEX( pNet->pev->owner );
else to->owner = NULLENT_INDEX;
}
}
////////////////////////////////////////////////////////
// PAS and PVS routines for client messaging
//
@ -1194,13 +1066,13 @@ player is 1 if the ent/e is a player and 0 otherwise
pSet is either the PAS or PVS that we previous set up. We can use it to ask the engine to filter the entity against the PAS or PVS.
we could also use the pas/ pvs that we set in SetupVisibility, if we wanted to. Caching the value is valid in that case, but still only for the current frame
*/
int AddToFullPack( edict_t *pView, edict_t *pHost, edict_t *pEdict, int hostflags, byte *pSet )
int AddToFullPack( entity_state_t *state, edict_t *pView, edict_t *pHost, edict_t *pEdict, int hostflags, byte *pSet )
{
if( FNullEnt( pEdict )) return 0; // never adding invalid entities
CBaseEntity *pEntity;
Vector delta; // for ambient sounds
// completely ignore dormant entity
if( pEdict->v.flags & FL_DORMANT )
return 0;
if( FNullEnt( pEdict ))
return 0; // never adding invalid entities
if( FNullEnt( pView )) pView = pHost; // pfnCustomView not set
@ -1210,6 +1082,18 @@ int AddToFullPack( edict_t *pView, edict_t *pHost, edict_t *pEdict, int hostflag
if( pViewEntity && pViewEntity->m_iClassType == ED_PORTAL )
bIsPortalPass = TRUE; // view from portal camera
pEntity = (CBaseEntity *)CBaseEntity::Instance( pEdict );
if( !pEntity ) return 0;
// NOTE: always add himslef to list
if( !bIsPortalPass && ( pHost == pEdict ))
goto addEntity;
// completely ignore dormant entity
if( pEdict->v.flags & FL_DORMANT )
return 0;
// don't send spectators to other players
if(( pEdict->v.flags & FL_SPECTATOR ) && ( pEdict != pHost ))
@ -1217,15 +1101,11 @@ int AddToFullPack( edict_t *pView, edict_t *pHost, edict_t *pEdict, int hostflag
return 0;
}
CBaseEntity *pEntity = (CBaseEntity *)CBaseEntity::Instance( pEdict );
if( !pEntity ) return 0;
// quick reject by type
switch( pEntity->m_iClassType )
{
case ED_SKYPORTAL:
return 1; // no additional check requires
goto addEntity; // no additional check requires
case ED_BEAM:
case ED_MOVER:
case ED_NORMAL:
@ -1238,8 +1118,6 @@ int AddToFullPack( edict_t *pView, edict_t *pHost, edict_t *pEdict, int hostflag
default: return 0; // skipped
}
Vector delta = g_vecZero; // for ambient sounds
// check for ambients distance
if( pEntity->m_iClassType == ED_AMBIENT )
{
@ -1253,6 +1131,7 @@ int AddToFullPack( edict_t *pView, edict_t *pHost, edict_t *pEdict, int hostflag
// precalc delta distance for sounds
delta = pView->v.origin - entorigin;
}
else delta = g_vecZero;
// check visibility
if ( !ENGINE_CHECK_PVS( pEdict, pSet ))
@ -1310,9 +1189,181 @@ int AddToFullPack( edict_t *pView, edict_t *pHost, edict_t *pEdict, int hostflag
}
UTIL_UnsetGroupTrace();
}
addEntity:
// setup some special edict flags (engine will clearing them after the current frame)
if( state->modelindex != pEntity->pev->modelindex || ( pEntity->pev->effects & EF_NOINTERP ))
state->ed_flags |= ESF_NODELTA;
// always keep an actual
state->number = pEdict->serialnumber;
// copy progs values to state
state->solid = (solid_t)pEntity->pev->solid;
state->origin = pEntity->pev->origin;
state->angles = pEntity->pev->angles;
state->modelindex = pEntity->pev->modelindex;
state->health = pEntity->pev->health;
state->skin = pEntity->pev->skin; // studio model skin
state->body = pEntity->pev->body; // studio model submodel
state->effects = pEntity->pev->effects; // shared client and render flags
state->renderfx = pEntity->pev->renderfx; // renderer flags
state->rendermode = pEntity->pev->rendermode; // rendering mode
state->renderamt = pEntity->pev->renderamt; // alpha value
state->animtime = (int)(1000.0 * pEntity->pev->animtime) * 0.001; // sequence time
state->localtime = (int)(1000.0 * pEntity->pev->ltime) * 0.001; // movement time
state->scale = pEntity->pev->scale; // shared client and render flags
state->movetype = (movetype_t)pEntity->pev->movetype;
state->frame = pEntity->pev->frame; // any model current frame
state->framerate = pEntity->pev->framerate;
state->mins = pEntity->pev->mins;
state->maxs = pEntity->pev->maxs;
state->flags = pEntity->pev->flags;
state->rendercolor = pEntity->pev->rendercolor;
state->oldorigin = pEntity->pev->oldorigin;
state->colormap = pEntity->pev->colormap; // attachments
if( pEntity->pev->groundentity )
state->groundent = ENTINDEX( pEntity->pev->groundentity );
else state->groundent = NULLENT_INDEX;
// translate attached entity
if( pEntity->pev->aiment )
state->aiment = ENTINDEX( pEntity->pev->aiment );
else state->aiment = NULLENT_INDEX;
// studio model sequence
if( pEntity->pev->sequence != -1 )
state->sequence = pEntity->pev->sequence;
for( int i = 0; i < 16; i++ )
{
// copy blendings and bone ctrlrs
state->blending[i] = pEntity->pev->blending[i];
state->controller[i] = pEntity->pev->controller[i];
}
if( state->ed_type == ED_CLIENT )
{
if( pEntity->pev->teleport_time )
{
state->ed_flags |= ESF_NO_PREDICTION;
state->ed_flags |= ESF_NODELTA;
pEntity->pev->teleport_time = 0.0f;
}
if( pEntity->pev->viewmodel )
state->viewmodel = MODEL_INDEX( STRING( pEntity->pev->viewmodel ));
else state->viewmodel = 0;
if( pEntity->pev->aiment )
state->aiment = ENTINDEX( pEntity->pev->aiment );
else state->aiment = NULLENT_INDEX;
state->viewoffset = pEntity->pev->view_ofs;
state->viewangles = pEntity->pev->v_angle;
state->idealpitch = pEntity->pev->idealpitch;
state->punch_angles = pEntity->pev->punchangle;
state->velocity = pEntity->pev->velocity;
state->basevelocity = pEntity->pev->clbasevelocity;
state->iStepLeft = pEntity->pev->iStepLeft;
state->flFallVelocity = pEntity->pev->flFallVelocity;
// playermodel sequence, that will be playing on a client
if( pEntity->pev->gaitsequence != -1 )
state->gaitsequence = pEntity->pev->gaitsequence;
if( pEntity->pev->weaponmodel != iStringNull )
state->weaponmodel = MODEL_INDEX( STRING( pEntity->pev->weaponmodel ));
else state->weaponmodel = 0;
state->weapons = pEntity->pev->weapons;
state->maxspeed = pEntity->pev->maxspeed;
// clamp fov
if( pEntity->pev->fov < 0.0 ) pEntity->pev->fov = 0.0;
if( pEntity->pev->fov > 160 ) pEntity->pev->fov = 160;
state->fov = pEntity->pev->fov;
}
else if( state->ed_type == ED_AMBIENT )
{
// add here specified fields e.g for trigger_teleport wind sound etc
}
else if( state->ed_type == ED_MOVER || state->ed_type == ED_BSPBRUSH || state->ed_type == ED_PORTAL )
{
state->body = DirToBits( pEntity->pev->movedir );
state->velocity = pEntity->pev->velocity;
// this is conveyor - send speed to render for right texture scrolling
state->framerate = pEntity->pev->speed;
}
else if( state->ed_type == ED_BEAM )
{
state->gaitsequence = pEntity->pev->frags; // beam type
// translate StartBeamEntity
if( pEntity->pev->owner )
state->owner = ENTINDEX( pEntity->pev->owner );
else state->owner = NULLENT_INDEX;
}
return 1;
}
/*
===================
CreateBaseline
Creates baselines used for network encoding, especially for player data since players are not spawned until connect time.
===================
*/
void CreateBaseline( entity_state_t *baseline, edict_t *entity, int playermodelindex )
{
// always set nodelta's for baseline
baseline->ed_flags |= ESF_NODELTA;
baseline->origin = entity->v.origin;
baseline->angles = entity->v.angles;
baseline->frame = entity->v.frame;
baseline->skin = (short)entity->v.skin;
// render information
baseline->rendermode = (byte)entity->v.rendermode;
baseline->renderamt = (byte)entity->v.renderamt;
baseline->rendercolor.x = (byte)entity->v.rendercolor.x;
baseline->rendercolor.y = (byte)entity->v.rendercolor.y;
baseline->rendercolor.z = (byte)entity->v.rendercolor.z;
baseline->renderfx = (byte)entity->v.renderfx;
baseline->mins = entity->v.mins;
baseline->maxs = entity->v.maxs;
if( baseline->ed_type == ED_CLIENT )
{
baseline->colormap = entity->serialnumber;
baseline->modelindex = playermodelindex; // "model" field from userinfo
baseline->friction = 1.0;
baseline->movetype = MOVETYPE_WALK;
baseline->scale = entity->v.scale;
baseline->solid = SOLID_SLIDEBOX;
baseline->framerate = 1.0;
baseline->gravity = 1.0;
}
else
{
baseline->colormap = 0;
baseline->modelindex = entity->v.modelindex;
baseline->movetype = (movetype_t)entity->v.movetype;
baseline->scale = entity->v.scale;
baseline->solid = (solid_t)entity->v.solid;
baseline->framerate = entity->v.framerate;
baseline->gravity = entity->v.gravity;
}
}
typedef struct
{
char name[32];
@ -1547,6 +1598,8 @@ void Custom_Encode( struct delta_s *pFields, const unsigned char *from, const un
RegisterEncoders
Allows game .dll to override network encoding of certain types of entities and tweak values, etc.
disabled for now, wait for Xash 0.8
=================
*/
void RegisterEncoders( void )
@ -1556,6 +1609,61 @@ void RegisterEncoders( void )
DELTA_ADDENCODER( "Player_Encode", Player_Encode );
}
/*
=================
GetWeaponData
Part of weapon predict system
disabled for now, wait for Xash 0.8
=================
*/
int GetWeaponData( struct edict_s *player, weapon_data_t *info )
{
memset( info, 0, 32 * sizeof( weapon_data_t ));
return 1;
}
/*
=================
UpdateClientData
Data sent to current client only
engine sets cd to 0 before calling.
=================
*/
void UpdateClientData( const edict_t *ent, int sendweapons, clientdata_t *cd )
{
cd->flags = ent->v.flags;
cd->health = ent->v.health;
cd->viewmodel = MODEL_INDEX( STRING( ent->v.viewmodel ) );
cd->waterlevel = ent->v.waterlevel;
cd->watertype = ent->v.watertype;
cd->weapons = ent->v.weapons;
// Vectors
cd->origin = ent->v.origin;
cd->velocity = ent->v.velocity;
cd->view_ofs = ent->v.view_ofs;
cd->punchangle = ent->v.punchangle;
cd->bInDuck = ent->v.bInDuck;
cd->flTimeStepSound = ent->v.flTimeStepSound;
cd->flDuckTime = ent->v.flDuckTime;
cd->flSwimTime = ent->v.flSwimTime;
cd->waterjumptime = ent->v.teleport_time;
strcpy( cd->physinfo, ENGINE_GETPHYSINFO( ent ) );
cd->maxspeed = ent->v.maxspeed;
cd->fov = ent->v.fov;
cd->weaponanim = ent->v.weaponanim;
cd->pushmsec = ent->v.pushmsec;
}
/*
=================
CmdStart

View File

@ -25,7 +25,6 @@ extern void ClientUserInfoChanged( edict_t *pEntity, char *infobuffer );
extern void ServerActivate( edict_t *pEdictList, int edictCount, int clientMax );
extern void ServerDeactivate( void );
extern void StartFrame( void );
extern void EndFrame( void );
extern void PlayerPostThink( edict_t *pEntity );
extern void PlayerPreThink( edict_t *pEntity );
extern void ParmsNewLevel( void );
@ -34,6 +33,7 @@ extern void RegisterEncoders( void );
extern void ClientPrecache( void );
extern const char *GetGameDescription( void );
extern int GetWeaponData( edict_t *player, struct weapon_data_s *info );
extern void SpectatorConnect ( edict_t *pEntity );
extern void SpectatorDisconnect ( edict_t *pEntity );
@ -42,7 +42,9 @@ extern void SpectatorThink ( edict_t *pEntity );
extern void Sys_Error( const char *error_string );
extern void SetupVisibility( edict_t *pViewEntity, edict_t *pClient, byte **pvs, byte **pas, int portal );
extern int AddToFullPack( edict_t *pView, edict_t *pHost, edict_t *pEdict, int hostflags, byte *pSet );
extern void UpdateClientData( const struct edict_s *ent, int sendweapons, struct clientdata_s *cd );
extern int AddToFullPack( entity_state_t *state, edict_t *pView, edict_t *pHost, edict_t *pEdict, int hostflags, byte *pSet );
extern void CreateBaseline( entity_state_t *baseline, edict_t *entity, int playermodelindex );
extern void CmdStart( const edict_t *player, const struct usercmd_s *cmd, unsigned int random_seed );
extern void CmdEnd ( const edict_t *player );

View File

@ -273,8 +273,8 @@ TYPEDESCRIPTION gEntvarsDescription[] =
DEFINE_ENTITY_FIELD( sequence, FIELD_INTEGER ),
DEFINE_ENTITY_FIELD( animtime, FIELD_TIME ),
DEFINE_ENTITY_FIELD( framerate, FIELD_FLOAT ),
DEFINE_ENTITY_FIELD( controller, FIELD_INTEGER ),
DEFINE_ENTITY_FIELD( blending, FIELD_INTEGER ),
DEFINE_ENTITY_FIELD_ARRAY( controller, FIELD_CHARACTER, 16 ),
DEFINE_ENTITY_FIELD_ARRAY( blending, FIELD_CHARACTER, 16 ),
DEFINE_ENTITY_FIELD( rendermode, FIELD_INTEGER ),
DEFINE_ENTITY_FIELD( renderamt, FIELD_FLOAT ),
@ -335,14 +335,6 @@ TYPEDESCRIPTION gEntvarsDescription[] =
#define ENTVARS_COUNT (sizeof(gEntvarsDescription)/sizeof(gEntvarsDescription[0]))
// used by engine for FindEntityByString and some other things
TYPEDESCRIPTION *GetEntvarsDescirption( int number )
{
if( number < 0 && number >= ENTVARS_COUNT )
return NULL;
return &gEntvarsDescription[number];
}
#ifdef DEBUG
edict_t *DBG_EntOfVars( const entvars_t *pev )
{

View File

@ -398,17 +398,17 @@ extern DLL_GLOBAL int g_Language;
#define PUSH_BLOCK_ONLY_X 1
#define PUSH_BLOCK_ONLY_Y 2
#define VEC_HULL_MIN Vector(-16, -16, -36)
#define VEC_HULL_MAX Vector( 16, 16, 36)
#define VEC_HULL_MIN gpGlobals->hullmins[0]
#define VEC_HULL_MAX gpGlobals->hullmaxs[0]
#define VEC_HUMAN_HULL_MIN Vector( -16, -16, 0 )
#define VEC_HUMAN_HULL_MAX Vector( 16, 16, 72 )
#define VEC_HUMAN_HULL_DUCK Vector( 16, 16, 36 )
#define VEC_VIEW Vector( 0, 0, 28 )
#define VEC_VIEW Vector( 0, 0, gpGlobals->viewheight[0] )
#define VEC_DUCK_HULL_MIN Vector(-16, -16, -18 )
#define VEC_DUCK_HULL_MAX Vector( 16, 16, 18)
#define VEC_DUCK_VIEW Vector( 0, 0, 12 )
#define VEC_DUCK_HULL_MIN gpGlobals->hullmins[1]
#define VEC_DUCK_HULL_MAX gpGlobals->hullmaxs[1]
#define VEC_DUCK_VIEW Vector( 0, 0, gpGlobals->viewheight[1] )
#define SVC_TEMPENTITY gmsgTempEntity
#define SVC_INTERMISSION gmsgIntermission

View File

@ -154,8 +154,26 @@ void TE_ParseExplosion( void )
if( !( flags & TE_EXPLFLAG_NODLIGHTS ))
{
g_pTempEnts->AllocDLight( pos2, 250, 250, 150, 200, 0.01f, 0 ); // big flash
g_pTempEnts->AllocDLight( pos2, 255, 190, 40, 150, 1.0f, DLIGHT_FADE );// red glow
dlight_t *dl;
// big flash
dl = g_engfuncs.pEfxAPI->CL_AllocDLight( 0 );
dl->origin = pos2;
dl->radius = 200;
dl->color[0] = dl->color[1] = 250;
dl->color[2] = 150;
dl->die = gpGlobals->time + 0.01f;
dl->decay = 800;
// red glow
dl = g_engfuncs.pEfxAPI->CL_AllocDLight( 0 );
dl->origin = pos2;
dl->radius = 150;
dl->color[0] = 255;
dl->color[1]= 190;
dl->color[2] = 40;
dl->die = gpGlobals->time + 1.0f;
dl->decay = 200;
}
}
@ -165,7 +183,7 @@ void TE_ParseExplosion( void )
char szDecal[32];
sprintf( szDecal, "{scorch%i", RANDOM_LONG( 1, 3 ));
g_pTempEnts->PlaceDecal( pos, 48.0f, szDecal );
g_pTempEnts->PlaceDecal( pos, NULLENT_INDEX, szDecal );
if( !( flags & TE_EXPLFLAG_NOSOUND ))
{
@ -367,6 +385,7 @@ void TE_ParseExplosion2( void )
{
Vector pos;
int colorIndex, numColors;
dlight_t *dl;
pos.x = READ_COORD();
pos.y = READ_COORD();
@ -376,7 +395,13 @@ void TE_ParseExplosion2( void )
numColors = READ_BYTE();
g_engfuncs.pEfxAPI->R_ParticleExplosion2( pos, colorIndex, numColors );
g_pTempEnts->AllocDLight( pos, 350, 0.5, DLIGHT_FADE );
dl = g_engfuncs.pEfxAPI->CL_AllocDLight( 0 );
dl->origin = pos;
dl->radius = 350;
dl->die = gpGlobals->time + 0.5f;
dl->decay = 300;
CL_PlaySound( "weapons/explode3.wav", 1.0f, pos );
}
@ -391,7 +416,6 @@ void TE_ParseBSPDecal( void )
{
Vector pos;
int decalIndex, entityIndex, modelIndex;
edict_t *pEntity;
pos.x = READ_COORD();
pos.y = READ_COORD();
@ -402,8 +426,7 @@ void TE_ParseBSPDecal( void )
if( entityIndex != NULLENT_INDEX )
modelIndex = READ_SHORT();
pEntity = GetEntityByIndex( entityIndex );
g_pTempEnts->PlaceDecal( pos, 5.0f, decalIndex );
g_pTempEnts->PlaceDecal( pos, entityIndex, decalIndex );
}
/*
@ -598,10 +621,12 @@ Creates a single source light
*/
void TE_ParseDynamicLight( int type )
{
Vector pos, color;
int flags, iAttachment = 0;
Vector pos;
int iAttachment = 0;
edict_t *pEnt = NULL;
float life, radius, decay;
byte r, g, b;
dlight_t *dl;
if( type == TE_ELIGHT )
{
@ -618,9 +643,9 @@ void TE_ParseDynamicLight( int type )
radius = (float)READ_COORD();
else radius = (float)(READ_BYTE() * 0.1f);
color.x = (float)READ_BYTE();
color.y = (float)READ_BYTE();
color.z = (float)READ_BYTE();
r = READ_BYTE();
g = READ_BYTE();
b = READ_BYTE();
life = (float)(READ_BYTE() * 0.1f);
@ -629,10 +654,21 @@ void TE_ParseDynamicLight( int type )
else decay = (float)(READ_BYTE() * 0.1f);
if( type == TE_ELIGHT )
flags = DLIGHT_ELIGHT;
else flags = 0;
{
dl = g_engfuncs.pEfxAPI->CL_AllocELight( 0 );
}
else
{
dl = g_engfuncs.pEfxAPI->CL_AllocDLight( 0 );
}
g_engfuncs.pEfxAPI->CL_AllocDLight( pos, color, radius, life, flags, 0 );
dl->origin = pos;
dl->radius = radius;
dl->decay = decay;
dl->color[0] = r;
dl->color[1] = g;
dl->color[2] = b;
dl->die = gpGlobals->time + life;
}
/*
@ -749,7 +785,6 @@ generic message for place static decal
void TE_ParseDecal( int type )
{
Vector pos;
edict_t *pEnt;
int decalIndex, entityIndex;
pos.x = READ_COORD();
@ -760,12 +795,12 @@ void TE_ParseDecal( int type )
if( type == TE_DECAL || type == TE_DECALHIGH )
{
entityIndex = READ_SHORT();
pEnt = GetEntityByIndex( entityIndex );
}
if( type == TE_DECALHIGH || type == TE_WORLDDECALHIGH )
decalIndex += 256;
g_pTempEnts->PlaceDecal( pos, 2.0f, decalIndex );
g_pTempEnts->PlaceDecal( pos, entityIndex, decalIndex );
}
/*
@ -858,20 +893,18 @@ void TE_ParseGunShotDecal( void )
Vector pos, dir;
int entityIndex, decalIndex;
char soundpath[32];
edict_t *pEnt;
float dummy;
pos.x = READ_COORD();
pos.y = READ_COORD();
pos.z = READ_COORD();
entityIndex = READ_SHORT();
pEnt = GetEntityByIndex( entityIndex );
decalIndex = READ_BYTE();
UTIL_GetForceDirection( pos, 2.0f, &dir, &dummy );
g_pParticles->BulletParticles( pos, dir );
g_pTempEnts->PlaceDecal( pos, 2.0f, decalIndex );
g_pTempEnts->PlaceDecal( pos, entityIndex, decalIndex );
if( RANDOM_LONG( 0, 32 ) <= 8 ) // 25% chanse
{
@ -960,11 +993,9 @@ void TE_ParsePlayerDecal( void )
entityIndex = READ_SHORT();
decalIndex = READ_BYTE();
// FIXME: get decal settings from the client
int iColor = 134;
HSPRITE hDecal = g_engfuncs.pEfxAPI->CL_DecalIndex( decalIndex );
g_engfuncs.pEfxAPI->R_ShootDecal( hDecal, NULL, pos, iColor, 90.0f, 5.0f );
edict_t *pEnt = GetEntityByIndex( entityIndex );
g_engfuncs.pEfxAPI->R_DecalShoot( hDecal, pEnt, pEnt->v.modelindex, pos, 0 );
}
/*

View File

@ -34,6 +34,7 @@ static HUD_FUNCTIONS gFunctionTable =
HUD_Init,
HUD_Redraw,
HUD_UpdateEntityVars,
HUD_UpdateClientVars,
HUD_UpdateOnRemove,
HUD_Reset,
HUD_StartFrame,
@ -344,6 +345,31 @@ void HUD_UpdateEntityVars( edict_t *ent, const entity_state_t *state, const enti
ent->v.pContainingEntity = ent;
}
/*
=========================
HUD_UpdateClientVars
The server sends us our origin with extra precision as part of the clientdata structure, not during the normal
playerstate update in entity_state_t. In order for these overrides to eventually get to the appropriate playerstate
structure, we need to copy them into the state structure at this point.
=========================
*/
void HUD_UpdateClientVars( entity_state_t *state, const clientdata_t *client )
{
// Copy origin
state->origin = client->origin;
// Spectator
state->iuser1 = client->iuser1;
state->iuser2 = client->iuser2;
// Duck prevention
state->iuser3 = client->iuser3;
// Fire prevention
state->iuser4 = client->iuser4;
}
int HUD_AddVisibleEntity( edict_t *pEnt, int ed_type )
{
float oldScale, oldRenderAmt;
@ -390,7 +416,7 @@ int HUD_AddVisibleEntity( edict_t *pEnt, int ed_type )
// add light effect
if ( pEnt->v.effects & EF_LIGHT )
{
g_pTempEnts->AllocDLight( pEnt->v.origin, 100, 100, 100, 200, 0.001f, 0 );
g_pTempEnts->AllocDLight( pEnt->v.origin, 100, 100, 100, 200, 0.001f );
g_pTempEnts->RocketFlare( pEnt->v.origin );
}
@ -403,7 +429,7 @@ int HUD_AddVisibleEntity( edict_t *pEnt, int ed_type )
}
else
{
g_pTempEnts->AllocDLight( pEnt->v.origin, RANDOM_LONG( 200, 230 ), 0.001f, 0 );
g_pTempEnts->AllocDLight( pEnt->v.origin, RANDOM_LONG( 200, 230 ), 0.001f );
}
}
@ -412,7 +438,7 @@ int HUD_AddVisibleEntity( edict_t *pEnt, int ed_type )
if ( pEnt->v.effects & EF_BRIGHTLIGHT && !( pEnt->v.effects & EF_NODRAW ))
{
Vector pos( pEnt->v.origin.x, pEnt->v.origin.y, pEnt->v.origin.z + 16 );
g_pTempEnts->AllocDLight( pos, RANDOM_LONG( 400, 430 ), 0.001f, 0 );
g_pTempEnts->AllocDLight( pos, RANDOM_LONG( 400, 430 ), 0.001f );
}
return result;

View File

@ -24,7 +24,7 @@
#define TEX_Load( x ) (*g_engfuncs.pTriAPI->LoadShader)( x, false )
#define SetCrosshair (*g_engfuncs.pfnSetCrosshair)
#define SendWeaponAnim (*g_engfuncs.pEventAPI->EV_WeaponAnim)
#define SendWeaponAnim (*g_engfuncs.pEventAPI->EV_WeaponAnimation)
#define GetModelType (*g_engfuncs.pEventAPI->EV_GetModelType)
#define GetModelFrames (*g_engfuncs.pEventAPI->EV_GetModFrames)
#define GetModelBounds (*g_engfuncs.pEventAPI->EV_GetModBounds)
@ -134,13 +134,13 @@ inline void CL_PlaySound( int iSound, float flVolume, Vector &pos, float pitch =
#define CL_AddTempEntity (*g_engfuncs.pEfxAPI->R_AddTempEntity)
#define CL_AddEntity (*g_engfuncs.pEfxAPI->R_AddEntity)
#define GET_ATTACHMENT (*g_engfuncs.pfnGetAttachment)
#define POINT_CONTENTS (*g_engfuncs.pfnPointContents)
#define POINT_CONTENTS( x ) (*g_engfuncs.pfnPointContents)( x, NULL )
#define TRACE_LINE (*g_engfuncs.pfnTraceLine)
#define TRACE_HULL (*g_engfuncs.pfnTraceHull)
#define ALLOC_STRING (*g_engfuncs.pfnAllocString)
#define STRING (*g_engfuncs.pfnGetString)
#define RANDOM_LONG (*g_engfuncs.pEventAPI->EV_RandomLong)
#define RANDOM_FLOAT (*g_engfuncs.pEventAPI->EV_RandomFloat)
#define RANDOM_LONG (*g_engfuncs.pfnRandomLong)
#define RANDOM_FLOAT (*g_engfuncs.pfnRandomFloat)
#define LOAD_FILE (*g_engfuncs.pfnLoadFile)
#define FILE_EXISTS (*g_engfuncs.pfnFileExists)
#define FREE_FILE (*g_engfuncs.pfnFreeFile)

View File

@ -33,22 +33,22 @@ extern "C"
//======================
void EV_HookEvents( void )
{
g_engfuncs.pEventAPI->EV_HookEvent( "evEjectBrass", EV_EjectBrass );
g_engfuncs.pEventAPI->EV_HookEvent( "evNull", EV_FireNull );
g_engfuncs.pEventAPI->EV_HookEvent( "evCrowbar", EV_FireCrowbar );
g_engfuncs.pEventAPI->EV_HookEvent( "evEmptySound", EV_PlayEmptySound );
g_engfuncs.pEventAPI->EV_HookEvent( "evGlock1", EV_FireGlock1 );
g_engfuncs.pEventAPI->EV_HookEvent( "evShotgun1", EV_FireShotGunSingle );
g_engfuncs.pEventAPI->EV_HookEvent( "evShotgun2", EV_FireShotGunDouble );
g_engfuncs.pEventAPI->EV_HookEvent( "evMP5", EV_FireMP5 );
g_engfuncs.pEventAPI->EV_HookEvent( "evPython", EV_FirePython );
g_engfuncs.pEventAPI->EV_HookEvent( "evGauss", EV_FireGauss );
g_engfuncs.pEventAPI->EV_HookEvent( "evGaussSpin", EV_SpinGauss );
g_engfuncs.pEventAPI->EV_HookEvent( "evEgonFire", EV_EgonFire );
g_engfuncs.pEventAPI->EV_HookEvent( "evEgonStop", EV_EgonStop );
g_engfuncs.pEventAPI->EV_HookEvent( "evTrain", EV_TrainPitchAdjust );
g_engfuncs.pEventAPI->EV_HookEvent( "evSnarkFire", EV_SnarkFire );
g_engfuncs.pEventAPI->EV_HookEvent( "evDecals", EV_Decals );
g_engfuncs.pfnHookEvent( "evEjectBrass", EV_EjectBrass );
g_engfuncs.pfnHookEvent( "evNull", EV_FireNull );
g_engfuncs.pfnHookEvent( "evCrowbar", EV_FireCrowbar );
g_engfuncs.pfnHookEvent( "evEmptySound", EV_PlayEmptySound );
g_engfuncs.pfnHookEvent( "evGlock1", EV_FireGlock1 );
g_engfuncs.pfnHookEvent( "evShotgun1", EV_FireShotGunSingle );
g_engfuncs.pfnHookEvent( "evShotgun2", EV_FireShotGunDouble );
g_engfuncs.pfnHookEvent( "evMP5", EV_FireMP5 );
g_engfuncs.pfnHookEvent( "evPython", EV_FirePython );
g_engfuncs.pfnHookEvent( "evGauss", EV_FireGauss );
g_engfuncs.pfnHookEvent( "evGaussSpin", EV_SpinGauss );
g_engfuncs.pfnHookEvent( "evEgonFire", EV_EgonFire );
g_engfuncs.pfnHookEvent( "evEgonStop", EV_EgonStop );
g_engfuncs.pfnHookEvent( "evTrain", EV_TrainPitchAdjust );
g_engfuncs.pfnHookEvent( "evSnarkFire", EV_SnarkFire );
g_engfuncs.pfnHookEvent( "evDecals", EV_Decals );
}
//=================
@ -192,7 +192,14 @@ void EV_UpadteFlashlight( edict_t *pEnt )
else vecPos = tr.vecEndPos;
// update flashlight endpos
g_engfuncs.pEfxAPI->CL_AllocDLight( vecPos, rgba, 96, 0.001f, 0, pEnt->serialnumber );
dlight_t *dl = g_engfuncs.pEfxAPI->CL_AllocDLight( pEnt->serialnumber );
dl->origin = vecPos;
dl->die = gpGlobals->time + 0.001f; // die on next frame
dl->color[0] = 255;
dl->color[1] = 255;
dl->color[2] = 255;
dl->radius = 96;
}
void HUD_CmdStart( const edict_t *player, int runfuncs )

View File

@ -269,7 +269,7 @@ void EV_HLDM_CrowbarDecalTrace( TraceResult *pTrace, char *decalName )
// only decal brush models such as the world etc.
if( decalName && decalName[0] && pEnt && ( pEnt->v.solid == SOLID_BSP || pEnt->v.movetype == MOVETYPE_PUSHSTEP ) )
{
g_pTempEnts->PlaceDecal( pTrace->vecEndPos, 2.0f, decalName );
g_pTempEnts->PlaceDecal( pTrace->vecEndPos, pEnt->serialnumber, decalName );
}
}
@ -306,7 +306,7 @@ void EV_HLDM_GunshotDecalTrace( TraceResult *pTrace, char *decalName )
// Only decal brush models such as the world etc.
if( decalName && decalName[0] && pEnt && ( pEnt->v.solid == SOLID_BSP || pEnt->v.movetype == MOVETYPE_PUSHSTEP ))
{
g_pTempEnts->PlaceDecal( pTrace->vecEndPos, 5.0f, decalName );
g_pTempEnts->PlaceDecal( pTrace->vecEndPos, pEnt->serialnumber, decalName );
g_pParticles->BulletParticles( pTrace->vecEndPos, Vector( 0, 0, -1 ));
}
}
@ -576,13 +576,13 @@ void EV_FireCrowbar( event_args_t *args )
switch(( g_iSwing++ ) % 3 )
{
case 0:
g_engfuncs.pEventAPI->EV_WeaponAnim( CROWBAR_ATTACK1MISS, args->iparam1, 1.0f );
g_engfuncs.pEventAPI->EV_WeaponAnimation( CROWBAR_ATTACK1MISS, args->iparam1, 1.0f );
break;
case 1:
g_engfuncs.pEventAPI->EV_WeaponAnim( CROWBAR_ATTACK2MISS, args->iparam1, 1.0f );
g_engfuncs.pEventAPI->EV_WeaponAnimation( CROWBAR_ATTACK2MISS, args->iparam1, 1.0f );
break;
case 2:
g_engfuncs.pEventAPI->EV_WeaponAnim( CROWBAR_ATTACK3MISS, args->iparam1, 1.0f );
g_engfuncs.pEventAPI->EV_WeaponAnimation( CROWBAR_ATTACK3MISS, args->iparam1, 1.0f );
break;
}
}
@ -598,13 +598,13 @@ void EV_FireCrowbar( event_args_t *args )
switch ((( g_iSwing++ ) % 2) + 1 )
{
case 0:
g_engfuncs.pEventAPI->EV_WeaponAnim ( CROWBAR_ATTACK1HIT, args->iparam1, 1.0f );
g_engfuncs.pEventAPI->EV_WeaponAnimation ( CROWBAR_ATTACK1HIT, args->iparam1, 1.0f );
break;
case 1:
g_engfuncs.pEventAPI->EV_WeaponAnim ( CROWBAR_ATTACK2HIT, args->iparam1, 1.0f );
g_engfuncs.pEventAPI->EV_WeaponAnimation ( CROWBAR_ATTACK2HIT, args->iparam1, 1.0f );
break;
case 2:
g_engfuncs.pEventAPI->EV_WeaponAnim ( CROWBAR_ATTACK3HIT, args->iparam1, 1.0f );
g_engfuncs.pEventAPI->EV_WeaponAnimation ( CROWBAR_ATTACK3HIT, args->iparam1, 1.0f );
break;
}
}
@ -688,7 +688,7 @@ void EV_FireGlock1( event_args_t *args )
if ( EV_IsLocal( idx ) )
{
edict_t *view = GetViewModel();
g_engfuncs.pEventAPI->EV_WeaponAnim( args->iparam2, args->iparam1, 1.0f );
g_engfuncs.pEventAPI->EV_WeaponAnimation( args->iparam2, args->iparam1, 1.0f );
EV_MuzzleFlash();
@ -765,7 +765,7 @@ void EV_FireMP5( event_args_t *args )
{
// Add muzzle flash to current weapon model
EV_MuzzleFlash();
g_engfuncs.pEventAPI->EV_WeaponAnim( animbase + RANDOM_LONG( 0, 2 ), body, 1.0f );
g_engfuncs.pEventAPI->EV_WeaponAnimation( animbase + RANDOM_LONG( 0, 2 ), body, 1.0f );
V_PunchAxis( 0, RANDOM_FLOAT( -2, 2 ) );
}
@ -824,7 +824,7 @@ void EV_FireShotGunDouble( event_args_t *args )
{
// Add muzzle flash to current weapon model
EV_MuzzleFlash();
g_engfuncs.pEventAPI->EV_WeaponAnim( args->iparam2, args->iparam1, 1.0f );
g_engfuncs.pEventAPI->EV_WeaponAnimation( args->iparam2, args->iparam1, 1.0f );
V_PunchAxis( 0, -10.0 );
}
@ -875,7 +875,7 @@ void EV_FireShotGunSingle( event_args_t *args )
{
// Add muzzle flash to current weapon model
EV_MuzzleFlash();
g_engfuncs.pEventAPI->EV_WeaponAnim( args->iparam2, args->iparam1, 1.0f );
g_engfuncs.pEventAPI->EV_WeaponAnimation( args->iparam2, args->iparam1, 1.0f );
V_PunchAxis( 0, -5.0 );
}
@ -928,7 +928,7 @@ void EV_FirePython( event_args_t *args )
// Add muzzle flash to current weapon model
EV_MuzzleFlash();
g_engfuncs.pEventAPI->EV_WeaponAnim( args->iparam2, args->iparam1, 1.0f );
g_engfuncs.pEventAPI->EV_WeaponAnimation( args->iparam2, args->iparam1, 1.0f );
V_PunchAxis( 0, -10.0 );
}
@ -1034,7 +1034,7 @@ void EV_FireGauss( event_args_t *args )
if ( EV_IsLocal( idx ) )
{
V_PunchAxis( 0, -2.0 );
g_engfuncs.pEventAPI->EV_WeaponAnim( GAUSS_FIRE2, args->iparam1, 1.0f );
g_engfuncs.pEventAPI->EV_WeaponAnimation( GAUSS_FIRE2, args->iparam1, 1.0f );
}
g_engfuncs.pEventAPI->EV_PlaySound( GetEntityByIndex( idx ), origin, CHAN_WEAPON, "weapons/gauss2.wav", 0.5 + flDamage * (1.0 / 400.0), ATTN_NORM, 0, 85 + RANDOM_LONG( 0, 0x1f ) );
@ -1252,7 +1252,7 @@ void EV_EgonFire( event_args_t *args )
}
// Only play the weapon anims if I shot it.
// if ( EV_IsLocal( idx ) ) g_engfuncs.pEventAPI->EV_WeaponAnim ( EGON_FIRECYCLE, args->iparam1, 1.0f );
// if ( EV_IsLocal( idx ) ) g_engfuncs.pEventAPI->EV_WeaponAnimation ( EGON_FIRECYCLE, args->iparam1, 1.0f );
if ( iStartup == 1 && EV_IsLocal( idx ) && !m_pBeam && !m_pNoise && cl_lw->integer )
{
@ -1387,7 +1387,7 @@ void EV_EgonStop( event_args_t *args )
m_pEndFlare = NULL;
}
g_engfuncs.pEventAPI->EV_WeaponAnim( EGON_FIRESTOP, args->iparam1, 1.0f );
g_engfuncs.pEventAPI->EV_WeaponAnimation( EGON_FIRESTOP, args->iparam1, 1.0f );
}
}
@ -1643,7 +1643,7 @@ void EV_SnarkFire( event_args_t *args )
// find space to drop the thing.
if ( tr.fAllSolid == 0 && tr.fStartSolid == 0 && tr.flFraction > 0.25f )
g_engfuncs.pEventAPI->EV_WeaponAnim ( SQUEAK_THROW, args->iparam1, 1.0f );
g_engfuncs.pEventAPI->EV_WeaponAnimation ( SQUEAK_THROW, args->iparam1, 1.0f );
}
//======================
// SQUEAK END

View File

@ -327,8 +327,14 @@ int CTempEnts::TE_Update( TEMPENTITY *pTemp )
if(( pTemp->flags & FTENT_FLICKER ) && m_iTempEntFrame == pTemp->m_nFlickerFrame )
{
float rgb[3] = { 1.0f, 0.47f, 0.0f };
g_engfuncs.pEfxAPI->CL_AllocDLight( pTemp->origin, rgb, 60, gpGlobals->time + 0.01f, 0, 0 );
dlight_t *dl = g_engfuncs.pEfxAPI->CL_AllocDLight( 0 );
dl->origin = pTemp->origin;
dl->radius = 60;
dl->color[0] = 255;
dl->color[1]= 120;
dl->color[2] = 0;
dl->die = gpGlobals->time + 0.01f;
}
if( pTemp->flags & FTENT_SMOKETRAIL )
@ -1488,41 +1494,53 @@ void CTempEnts::WeaponFlash( edict_t *pEnt, int iAttachment )
GET_ATTACHMENT( pEnt, iAttachment, pos, NULL );
if( pos == pEnt->v.origin ) return; // missing attachment
AllocDLight( pos, 255, 180, 64, 100, 0.05f, 0 );
AllocDLight( pos, 255, 180, 64, 100, 0.05f );
}
void CTempEnts::PlaceDecal( Vector pos, float scale, int decalIndex )
void CTempEnts::PlaceDecal( Vector pos, int entityIndex, int decalIndex )
{
HSPRITE hDecal;
edict_t *pEnt;
int modelIndex = 0;
pEnt = GetEntityByIndex( entityIndex );
if( pEnt && !pEnt->free ) modelIndex = pEnt->v.modelindex;
hDecal = g_engfuncs.pEfxAPI->CL_DecalIndex( decalIndex );
g_engfuncs.pEfxAPI->R_ShootDecal( hDecal, NULL, pos, 0, RANDOM_LONG( 0, 359 ), scale );
g_engfuncs.pEfxAPI->R_DecalShoot( hDecal, pEnt, modelIndex, pos, 0 );
}
void CTempEnts::PlaceDecal( Vector pos, float scale, const char *decalname )
void CTempEnts::PlaceDecal( Vector pos, int entityIndex, const char *decalname )
{
HSPRITE hDecal;
edict_t *pEnt;
int modelIndex = 0;
pEnt = GetEntityByIndex( entityIndex );
if( pEnt && !pEnt->free ) modelIndex = pEnt->v.modelindex;
hDecal = g_engfuncs.pEfxAPI->CL_DecalIndexFromName( decalname );
g_engfuncs.pEfxAPI->R_ShootDecal( hDecal, NULL, pos, 0, RANDOM_LONG( 0, 359 ), scale );
g_engfuncs.pEfxAPI->R_DecalShoot( hDecal, pEnt, modelIndex, pos, 0 );
}
void CTempEnts::AllocDLight( Vector pos, float r, float g, float b, float radius, float time, int flags )
void CTempEnts::AllocDLight( Vector pos, byte r, byte g, byte b, float radius, float time, float decay )
{
if( radius <= 0 ) return;
float rgb[3];
rgb[0] = r / 255.0f;
rgb[1] = r / 255.0f;
rgb[2] = r / 255.0f;
dlight_t *dl;
g_engfuncs.pEfxAPI->CL_AllocDLight( pos, rgb, radius, time, flags, 0 );
dl = g_engfuncs.pEfxAPI->CL_AllocDLight( 0 );
dl->origin = pos;
dl->die = gpGlobals->time + time;
dl->color[0] = r;
dl->color[1] = g;
dl->color[2] = b;
dl->radius = radius;
dl->decay = decay;
}
void CTempEnts::AllocDLight( Vector pos, float radius, float time, int flags )
void CTempEnts::AllocDLight( Vector pos, float radius, float time, float decay )
{
AllocDLight( pos, 255, 255, 255, radius, time, flags );
AllocDLight( pos, 255, 255, 255, radius, time, decay );
}
void CTempEnts::RocketTrail( Vector start, Vector end, int type )

View File

@ -51,10 +51,10 @@ public:
void PlaySound( TEMPENTITY *pTemp, float damp );
void TracerEffect( const Vector &start, const Vector &end );
void WeaponFlash( edict_t *pEnt, int iAttachment );
void PlaceDecal( Vector pos, float scale, int decalIndex );
void PlaceDecal( Vector pos, float scale, const char *decalname );
void AllocDLight( Vector pos, float r, float g, float b, float radius, float time, int flags );
void AllocDLight( Vector pos, float radius, float time, int flags );
void PlaceDecal( Vector pos, int entityIndex, int decalIndex );
void PlaceDecal( Vector pos, int entityIndex, const char *decalname );
void AllocDLight( Vector pos, byte r, byte g, byte b, float radius, float time, float decay = 0.0f );
void AllocDLight( Vector pos, float radius, float time, float decay = 0.0f );
void RocketTrail( Vector start, Vector end, int type );
// Data
private:

View File

@ -35,6 +35,7 @@ extern int HUD_VidInit( void );
extern void HUD_Init( void );
extern int HUD_Redraw( float flTime, int state );
extern void HUD_UpdateEntityVars( edict_t *out, const entity_state_t *s, const entity_state_t *p );
extern void HUD_UpdateClientVars( entity_state_t *state, const clientdata_t *client );
extern void HUD_UpdateOnRemove( edict_t *pEdict );
extern void HUD_Reset( void );
extern void HUD_StartFrame( void );

View File

@ -2,8 +2,8 @@
// Copyright XashXT Group 2010 ©
// bmodel_ref.h - BSP format included q1, hl1 support
//=======================================================================
#ifndef BMODEL_REF_H
#define BMODEL_REF_H
#ifndef BSPFILE_H
#define BSPFILE_H
/*
==============================================================================
@ -186,4 +186,4 @@ typedef struct
int lightofs; // start of [numstyles*surfsize] samples
} dface_t;
#endif//BMODEL_REF_H
#endif//BSPFILE_H

View File

@ -10,6 +10,7 @@
typedef int HSPRITE; // handle to a graphic
typedef struct tempent_s TEMPENTITY;
typedef struct dlight_s dlight_t;
typedef struct usercmd_s usercmd_t;
typedef struct particle_s particle_t;
typedef struct skyportal_s skyportal_t;
@ -86,10 +87,6 @@ typedef struct cl_globalvars_s
ref_params_t *pViewParms; // just for easy acess on client
float viewheight[PM_MAXHULLS]; // values from gameinfo.txt
vec3_t hullmins[PM_MAXHULLS];
vec3_t hullmaxs[PM_MAXHULLS];
int serverflags; // shared serverflags
int maxClients;
int windowState; // 0 - inactive (minimize, notfocus), 1 - active
@ -99,6 +96,11 @@ typedef struct cl_globalvars_s
const char *pStringBase; // actual only when sys_sharedstrings is 1
void *pSaveData; // (SAVERESTOREDATA *) pointer
// Xash3D specific
float viewheight[PM_MAXHULLS]; // values from gameinfo.txt
vec3_t hullmins[PM_MAXHULLS];
vec3_t hullmaxs[PM_MAXHULLS];
} cl_globalvars_t;
typedef struct cl_enginefuncs_s
@ -111,7 +113,7 @@ typedef struct cl_enginefuncs_s
void (*pfnSPR_Set)( HSPRITE hPic, int r, int g, int b, int a );
void (*pfnSPR_Draw)( int frame, int x, int y, int width, int height, const wrect_t *prc );
void (*pfnSPR_DrawHoles)( int frame, int x, int y, int width, int height, const wrect_t *prc );
void (*pfnSPR_DrawTrans)( int frame, int x, int y, int width, int height, const wrect_t *prc ); // Xash3D ext
void (*pfnSPR_DrawTrans)( int frame, int x, int y, int width, int height, const wrect_t *prc ); // kRenderTransColor
void (*pfnSPR_DrawAdditive)( int frame, int x, int y, int width, int height, const wrect_t *prc );
void (*pfnSPR_EnableScissor)( int x, int y, int width, int height );
void (*pfnSPR_DisableScissor)( void );
@ -183,10 +185,10 @@ typedef struct cl_enginefuncs_s
edict_t* (*pfnGetEntityByIndex)( int idx ); // matched with entity serialnumber
float (*pfnGetClientTime)( void ); // can use gpGlobals->time instead
int (*pfnIsSpectateOnly)( void ); // was V_CalcShake
int (*pfnGetAttachment)( const edict_t *pEdict, int iAttachment, float *rgflOrg, float *rgflAng ); // was V_ApplyShake
void (*pfnFadeClientVolume)( float fadePercent, float fadeOutSeconds, float holdTime, float fadeInSeconds ); // was V_CalcShake
int (*pfnGetAttachment)( const edict_t *pEdict, int iAttachment, float *rgflOrg, float *rgflAng ); // was V_ApplyShake
int (*pfnPointContents)( const float *rgflPos );
int (*pfnPointContents)( const float *rgflPos, int *truecontents );
edict_t* (*pfnWaterEntity)( const float *rgflPos );
void (*pfnTraceLine)( const float *v1, const float *v2, int fNoMonsters, edict_t *pentToSkip, TraceResult *ptr );
void (*pfnTraceToss)( edict_t* pent, edict_t* pentToIgnore, TraceResult *ptr ); // was CL_LoadModel
@ -206,7 +208,7 @@ typedef struct cl_enginefuncs_s
void* (*pfnLoadLibrary)( const char *name ); // was pfnGetGameDirectory
void* (*pfnGetProcAddress)( void *hInstance, const char *name ); // was pfnGetCvarPointer
void (*pfnFreeLibrary)( void *hInstance ); // was Key_LookupBinding
void (*pfnHostError)( const char *szFmt, ... ); // was pfnGetLevelName
void (*pfnHostError)( const char *szFmt, ... ); // was pfnGetLevelName (see gpGlobals->mapname)
int (*pfnFileExists)( const char *filename ); // was pfnGetScreenFade
void (*pfnGetGameDir)( char *szGetGameDir ); // was pfnSetScreenFade
@ -223,8 +225,8 @@ typedef struct cl_enginefuncs_s
struct efxapi_s *pEfxAPI;
struct event_api_s *pEventAPI;
// new interface starts here
int (*pfnIsInGame)( void ); // return false for menu, console, etc
int (*pfnIsSpectateOnly)( void );
int (*pfnIsInGame)( void ); // was LoadMapSprite, return false for menu, console, etc
} cl_enginefuncs_t;
@ -234,6 +236,7 @@ typedef struct
void (*pfnInit)( void );
int (*pfnRedraw)( float flTime, int state );
void (*pfnUpdateEntityVars)( edict_t *out, const struct entity_state_s *in1, const struct entity_state_s *in2 );
void (*pfnUpdateClientVars)( struct entity_state_s *state, const struct clientdata_s *client );
void (*pfnOnFreeEntPrivateData)( edict_t *pEnt ); // this is called on entity removed
void (*pfnReset)( void );
void (*pfnStartFrame)( void );

View File

@ -10,6 +10,8 @@
#define YAW 1
#define ROLL 2
#define LM_STYLES 4 // MAXLIGHTMAPS
// worldcraft predefined angles
#define ANGLE_UP -1
#define ANGLE_DOWN -2
@ -36,7 +38,7 @@
#define SND_CHANGE_PITCH (1<<1) // change sound pitch
#define SND_STOP (1<<2) // stop the sound
#define SND_SPAWNING (1<<3) // we're spawing, used in some cases for ambients
#define SND_DELAY (1<<4) // sound has an initial delay
#define SND_LOCALSOUND (1<<4) // not paused, not looped, for internal use
#define SND_STOP_LOOPING (1<<5) // stop all looping sounds on the entity.
#define SND_SPEAKER (1<<6) // being played again by a microphone through a speaker
@ -83,31 +85,6 @@
#define CONTENTS_GRAVITY_FLYFIELD -18
#define CONTENTS_FOG -19
// global deatchmatch dmflags
#define DF_NO_HEALTH (1<<0)
#define DF_NO_ITEMS (1<<1)
#define DF_WEAPONS_STAY (1<<2)
#define DF_NO_FALLING (1<<3)
#define DF_INSTANT_ITEMS (1<<4)
#define DF_SAME_LEVEL (1<<5)
#define DF_SKINTEAMS (1<<6)
#define DF_MODELTEAMS (1<<7)
#define DF_NO_FRIENDLY_FIRE (1<<8)
#define DF_SPAWN_FARTHEST (1<<9)
#define DF_FORCE_RESPAWN (1<<10)
#define DF_NO_ARMOR (1<<11)
#define DF_ALLOW_EXIT (1<<12)
#define DF_INFINITE_AMMO (1<<13)
#define DF_QUAD_DROP (1<<14)
#define DF_FIXED_FOV (1<<15)
#define DF_QUADFIRE_DROP (1<<16)
#define DF_NO_MINES (1<<17)
#define DF_NO_STACK_DOUBLE (1<<18)
#define DF_NO_NUKES (1<<19)
#define DF_NO_SPHERES (1<<20)
// common 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
@ -376,10 +353,6 @@ typedef enum
#define CL_PAUSED 3 // pause when active
#define CL_CHANGELEVEL 4 // draw 'loading' during changelevel
// built-in dlight flags
#define DLIGHT_FADE (1<<0) // fade dlight at end of lifetime
#define DLIGHT_ELIGHT (1<<1) // no world effect, studiomodel only
// renderer flags
#define RDF_NOWORLDMODEL (1<<0) // used for player configuration screen
#define RDF_PORTALINVIEW (1<<1) // cull entities using vis too because pvs\areabits are merged serverside

View File

@ -15,29 +15,41 @@ struct particle_s
ptype_t type;
};
struct dlight_s
{
vec3_t origin;
float radius;
byte color[3];
float die; // stop lighting after this time
float decay; // drop this each second
float minlight; // don't add when contributing less
int key;
bool dark; // subtracts light instead of adding
};
typedef struct efxapi_s
{
particle_t *(*R_AllocParticle)( void );
void (*R_BlobExplosion)( const float *org );
void (*R_EntityParticles)( edict_t *ent );
void (*R_LavaSplash)( const float *org );
void (*R_ParticleExplosion)( const float *org );
void (*R_ParticleExplosion2)( const float *org, int colorStart, int colorLength );
void (*R_RocketTrail)( const float *start, const float *end, int type );
void (*R_RunParticleEffect)( const float *org, const float *dir, int color, int count );
void (*R_TeleportSplash)( const float *org );
void (*R_GetPaletteColor)( int colorIndex, float *outColor );
int (*CL_DecalIndex)( int id );
int (*CL_DecalIndexFromName)( const char *szDecalName );
int (*R_ShootDecal)( HSPRITE hSpr, edict_t *pEnt, const float *pos, int color, float roll, float rad );
void (*CL_AllocDLight)( const float *org, float *rgb, float rad, float lifetime, int flags, int key );
void (*CL_AllocSLight)( const float *org, float *dir, float rad, float *cone, HSPRITE hLight, int key );
void (*R_LightForPoint)( const float *rgflOrigin, float *lightValue );
int (*CL_IsBoxVisible)( const float *mins, const float *maxs );
int (*R_CullBox)( const float *mins, const float *maxs );
int (*R_AddEntity)( edict_t *pEnt, int ed_type, HSPRITE customShader );
int (*R_AddTempEntity)( TEMPENTITY *pTemp, HSPRITE customShader );
void (*R_EnvShot)( const float *vieworg, const char *name, int skyshot );
particle_t* (*R_AllocParticle)( void );
void (*R_BlobExplosion)( const float *org );
void (*R_EntityParticles)( edict_t *ent );
void (*R_LavaSplash)( const float *org );
void (*R_ParticleExplosion)( const float *org );
void (*R_ParticleExplosion2)( const float *org, int colorStart, int colorLength );
void (*R_RocketTrail)( const float *start, const float *end, int type );
void (*R_RunParticleEffect)( const float *org, const float *dir, int color, int count );
void (*R_TeleportSplash)( const float *org );
void (*R_GetPaletteColor)( int colorIndex, float *outColor );
int (*CL_DecalIndex)( int id );
int (*CL_DecalIndexFromName)( const char *szDecalName );
void (*R_DecalShoot)( HSPRITE hDecal, edict_t *pEnt, int modelIndex, float *pos, int flags );
dlight_t* (*CL_AllocDLight)( int key );
dlight_t* (*CL_AllocELight)( int key );
void (*R_LightForPoint)( const float *rgflOrigin, float *lightValue );
int (*CL_IsBoxVisible)( const float *mins, const float *maxs );
int (*R_CullBox)( const float *mins, const float *maxs );
int (*R_AddEntity)( edict_t *pEnt, int ed_type, HSPRITE customShader );
int (*R_AddTempEntity)( TEMPENTITY *pTemp, HSPRITE customShader );
void (*R_EnvShot)( const float *vieworg, const char *name, int skyshot );
} efxapi_t;
#endif//EFFECTS_API_H

View File

@ -46,6 +46,7 @@ typedef struct entity_state_s
vec3_t angles; // entity angles, not viewangles
solid_t solid; // entity solid
movetype_t movetype; // entity movetype
float friction; // friction, for prediction.
int gravity; // gravity multiplier
int aiment; // attached entity
int owner; // projectiles owner
@ -91,6 +92,76 @@ typedef struct entity_state_s
float fov; // horizontal field of view
int iStepLeft; // synched footsteps
float flFallVelocity; // how fast we are falling
int weaponanim; // to see weapon animation of other players
// for mods
int iuser1;
int iuser2;
int iuser3;
int iuser4;
float fuser1;
float fuser2;
float fuser3;
float fuser4;
vec3_t vuser1;
vec3_t vuser2;
vec3_t vuser3;
vec3_t vuser4;
} entity_state_t;
typedef struct clientdata_s
{
vec3_t origin;
vec3_t velocity;
int viewmodel;
vec3_t punchangle;
int flags;
int waterlevel;
int watertype;
vec3_t view_ofs;
float health;
int bInDuck;
int weapons; // remove?
int flTimeStepSound;
int flDuckTime;
int flSwimTime;
int waterjumptime;
float maxspeed;
float fov;
int weaponanim;
int m_iId;
int ammo_shells;
int ammo_nails;
int ammo_cells;
int ammo_rockets;
float m_flNextAttack;
int tfstate;
int pushmsec;
int deadflag;
char physinfo[512]; // MAX_PHYSINFO_STRING
// for mods
int iuser1;
int iuser2;
int iuser3;
int iuser4;
float fuser1;
float fuser2;
float fuser3;
float fuser4;
vec3_t vuser1;
vec3_t vuser2;
vec3_t vuser3;
vec3_t vuser4;
} clientdata_t;
#endif//ENTITY_STATE_H

View File

@ -5,7 +5,7 @@
#ifndef EVENT_API_H
#define EVENT_API_H
#define EVENT_API_VERSION 1
#define EVENT_API_VERSION 2
#define FEV_NOTHOST (1<<0) // skip local host for event send.
#define FEV_RELIABLE (1<<1) // send the event reliably.
@ -39,22 +39,20 @@ typedef void (*pfnEventHook)( event_args_t *args );
typedef struct event_api_s
{
int version;
word (*EV_PrecacheEvent)( int type, const char* psz );
void (*EV_PlaybackEvent)( int flags, const edict_t *pInvoker, word eventindex, float delay, float *origin, float *angles, float fparam1, float fparam2, int iparam1, int iparam2, int bparam1, int bparam2 );
void (*EV_WeaponAnim)( int iAnim, int body, float framerate );
float (*EV_RandomFloat)( float flLow, float flHigh );
long (*EV_RandomLong)( long lLow, long lHigh );
void (*EV_HookEvent)( const char *name, pfnEventHook pfn );
void (*EV_KillEvents)( int entnum, const char *eventname );
void (*EV_PlaySound)( edict_t *ent, float *org, int chan, const char *samp, float vol, float attn, int flags, int pitch );
void (*EV_StopSound)( int ent, int channel, const char *sample );
int (*EV_FindModelIndex)( const char *model );
int (*EV_IsLocal)( int playernum );
void (*EV_LocalPlayerViewheight)( float *view_ofs );
void (*EV_StopAllSounds)( edict_t *ent, int entchannel );
modtype_t (*EV_GetModelType)( int modelIndex );
int (*EV_GetModFrames)( int modelIndex );
void (*EV_LocalPlayerViewheight)( float *view_ofs );
void (*EV_GetModBounds)( int modelIndex, float *mins, float *maxs );
int (*EV_GetModFrames)( int modelIndex );
void (*EV_WeaponAnimation)( int sequence, int body, float framerate );
word (*EV_PrecacheEvent)( int type, const char* psz );
void (*EV_PlaybackEvent)( int flags, const edict_t *pInvoker, word eventindex, float delay, float *origin, float *angles, float fparam1, float fparam2, int iparam1, int iparam2, int bparam1, int bparam2 );
const char *(*EV_TraceTexture)( edict_t *pTextureEntity, const float *v1, const float *v2 );
void (*EV_StopAllSounds)( edict_t *ent, int entchannel );
void (*EV_KillEvents)( int entnum, const char *eventname );
} event_api_t;
#endif//EVENT_API_H

View File

@ -53,6 +53,11 @@ typedef struct globalvars_s
void *pSaveData; // (SAVERESTOREDATA *) pointer
vec3_t vecLandmarkOffset;
// Xash3D specific
float viewheight[PM_MAXHULLS]; // values from gameinfo.txt
vec3_t hullmins[PM_MAXHULLS];
vec3_t hullmaxs[PM_MAXHULLS];
} globalvars_t;
// engine hands this to DLLs for functionality callbacks
@ -343,29 +348,29 @@ typedef struct
void (*pfnPlayerPostThink)( edict_t *pEntity );
void (*pfnStartFrame)( void );
int (*pfnCreate)( edict_t *pent, const char *szName ); // custom entity (was pfnParmsNewLevel)
int (*pfnCreate)( edict_t *pent, const char *szName ); // was pfnParmsNewLevel
void (*pfnParmsChangeLevel)( void );
// returns string describing current .dll. E.g., TeamFotrress 2, Half-Life
const char *(*pfnGetGameDescription)( void );
TYPEDESCRIPTION *(*pfnGetEntvarsDescirption)( int fieldnum ); // (was pfnPlayerCustomization)
int (*pfnPhysicsEntity)( edict_t *pEntity ); // was pfnPlayerCustomization
// Spectator funcs
void (*pfnSpectatorConnect)( edict_t *pEntity );
void (*pfnSpectatorDisconnect)( edict_t *pEntity );
void (*pfnSpectatorThink)( edict_t *pEntity );
int (*pfnClassifyEdict)( edict_t *pentToClassify ); // (was pfnSys_Error)
int (*pfnClassifyEdict)( edict_t *pentToClassify ); // was pfnSys_Error
void (*pfnPM_Move)( playermove_t *ppmove, int server );
void (*pfnPM_Init)( playermove_t *ppmove );
char (*pfnPM_FindTextureType)( const char *name );
void (*pfnSetupVisibility)( edict_t *pViewEntity, edict_t *pClient, byte **pvs, byte **pas, int portal );
int (*pfnPhysicsEntity)( edict_t *pEntity ); // was pfnUpdateClientData
int (*pfnAddToFullPack)( edict_t *pView, edict_t *pHost, edict_t *pEdict, int hostflags, byte *pSet );
void (*pfnEndFrame)( void ); // was pfnCreateBaseline
void (*pfnUpdateClientData)( const edict_t *ent, int sendweapons, struct clientdata_s *cd );
int (*pfnAddToFullPack)( struct entity_state_s *state, edict_t *pView, edict_t *pHost, edict_t *pEdict, int hostflags, byte *pSet );
void (*pfnCreateBaseline)( struct entity_state_s *baseline, edict_t *entity, int playermodelindex );
void (*pfnRegisterEncoders)( void );
void (*pfnUpdateEntityState)( struct entity_state_s *to, edict_t *from, int baseline ); // was pfnGetWeaponData
int (*pfnGetWeaponData)( edict_t *player, struct weapon_data_s *info );
void (*pfnCmdStart)( const edict_t *player, const usercmd_t *cmd, unsigned int random_seed );
void (*pfnCmdEnd)( const edict_t *player );

View File

@ -5,7 +5,7 @@
#ifndef TRIANGLE_API_H
#define TRIANGLE_API_H
#define TRI_API_VERSION 1
#define TRI_API_VERSION 2
typedef enum
{

39
common/weaponinfo.h Normal file
View File

@ -0,0 +1,39 @@
//=======================================================================
// Copyright XashXT Group 2010 ©
// weaponinfo.h - client weapondata for predicting
//=======================================================================
#ifndef WEAPONINFO_H
#define WEAPONINFO_H
// info about weapons player might have in his/her possession
typedef struct weapon_data_s
{
int m_iId;
int m_iClip;
float m_flNextPrimaryAttack;
float m_flNextSecondaryAttack;
float m_flTimeWeaponIdle;
int m_fInReload;
int m_fInSpecialReload;
float m_flNextReload;
float m_flPumpTime;
float m_fReloadTime;
float m_fAimedDamage;
float m_fNextAimBonus;
int m_fInZoom;
int m_iWeaponState;
int iuser1;
int iuser2;
int iuser3;
int iuser4;
float fuser1;
float fuser2;
float fuser3;
float fuser4;
} weapon_data_t;
#endif//WEAPONINFO_H

View File

@ -124,29 +124,20 @@ DLIGHT MANAGEMENT
==============================================================
*/
typedef struct
struct dlight_s
{
// these values common with dlight_t so don't move them
vec3_t origin;
union
{
vec3_t color; // dlight color
vec3_t angles; // spotlight angles
};
float intensity;
shader_t texture; // light image e.g. for flashlight
vec2_t cone; // spotlight cone
float radius;
byte color[3];
float die; // stop lighting after this time
float decay; // drop this each second
float minlight; // don't add when contributing less
int key;
bool dark; // subtracts light instead of adding
bool elight; // true when calls with CL_AllocElight
};
// cdlight_t private starts here
int key; // so entities can reuse same entry
float start; // stop lighting after this time
float end; // drop this each second
float radius; // radius (not an intensity)
bool fade;
bool free; // this light is unused at current time
} cdlight_t;
cdlight_t cl_dlights[MAX_DLIGHTS];
dlight_t cl_dlights[MAX_DLIGHTS];
/*
================
@ -164,10 +155,10 @@ CL_AllocDlight
===============
*/
cdlight_t *CL_AllocDlight( int key )
dlight_t *CL_AllocDlight( int key )
{
int i, time, index;
cdlight_t *dl;
dlight_t *dl;
int i;
// first look for an exact key match
if( key )
@ -183,32 +174,20 @@ cdlight_t *CL_AllocDlight( int key )
}
}
}
else
{
for( i = 0, dl = cl_dlights; i < MAX_DLIGHTS; i++, dl++ )
{
if( dl->free )
{
Mem_Set( dl, 0, sizeof( *dl ));
return dl;
}
}
}
// find the oldest light
time = cl.time;
index = 0;
// then look for anything else
for( i = 0, dl = cl_dlights; i < MAX_DLIGHTS; i++, dl++ )
{
if( dl->start < time )
if( dl->die < cl.time )
{
time = dl->start;
index = i;
Mem_Set( dl, 0, sizeof( *dl ));
dl->key = key;
return dl;
}
}
dl = &cl_dlights[index];
// otherwise grab first dlight
dl = &cl_dlights[0];
Mem_Set( dl, 0, sizeof( *dl ));
dl->key = key;
@ -217,41 +196,38 @@ cdlight_t *CL_AllocDlight( int key )
/*
===============
CL_AddDLight
CL_AllocElight
===============
*/
void CL_AddDLight( const float *org, const float *rgb, float radius, float time, int flags, int key )
dlight_t *CL_AllocElight( int key )
{
cdlight_t *dl;
if( radius <= 0 )
{
MsgDev( D_WARN, "CL_AddDLight: ignore light with radius <= 0\n" );
return;
}
dlight_t *dl;
dl = CL_AllocDlight( key );
dl->free = false;
dl->texture = -1; // dlight
dl->elight = true;
VectorCopy( org, dl->origin );
VectorCopy( rgb, dl->color );
dl->radius = radius;
dl->start = cl.time;
dl->end = dl->start + time;
dl->fade = (flags & DLIGHT_FADE) ? true : false;
return dl;
}
/*
===============
CL_AddSLight
CL_AddDlight
copy dlight to renderer
===============
*/
void CL_AddSLight( const float *org, float *dir, float rad, float *cone, HSPRITE hLight, int key )
bool CL_AddDlight( dlight_t *dl )
{
// FIXME: implement
int flags = 0;
bool add;
if( dl->dark ) flags |= DLIGHT_DARK;
if( dl->elight ) flags |= DLIGHT_ONLYENTS;
add = re->AddDLight( dl->origin, dl->color, dl->radius, flags );
return add;
}
/*
@ -262,26 +238,21 @@ CL_AddDLights
*/
void CL_AddDLights( void )
{
cdlight_t *dl;
dlight_t *dl;
float time;
int i;
time = cl.time - cl.oldtime;
for( i = 0, dl = cl_dlights; i < MAX_DLIGHTS; i++, dl++ )
{
if( dl->free ) continue;
if( cl.time >= dl->end )
{
dl->free = true;
if( dl->die < cl.time || !dl->radius )
continue;
}
dl->radius -= time * dl->decay;
if( dl->radius < 0 ) dl->radius = 0;
if( dl->fade )
{
dl->intensity = (float)(cl.time - dl->start) / (dl->end - dl->start);
dl->intensity = dl->radius * (1.0f - dl->intensity);
}
else dl->intensity = dl->radius; // const
re->AddDynLight( dl );
CL_AddDlight( dl );
}
}
@ -294,14 +265,13 @@ if cl_testlights is set, create 32 lights models
*/
void CL_TestLights( void )
{
int i, j;
float f, r;
cdlight_t dl;
edict_t *ed = CL_GetLocalPlayer();
int i, j;
float f, r;
dlight_t dl;
if( !cl_testlights->integer ) return;
Mem_Set( &dl, 0, sizeof( cdlight_t ));
Mem_Set( &dl, 0, sizeof( dlight_t ));
for( i = 0; i < bound( 1, cl_testlights->integer, MAX_DLIGHTS ); i++ )
{
@ -311,13 +281,12 @@ void CL_TestLights( void )
for( j = 0; j < 3; j++ )
dl.origin[j] = cl.refdef.vieworg[j] + cl.refdef.forward[j] * f + cl.refdef.right[j] * r;
dl.color[0] = ((i%6)+1) & 1;
dl.color[1] = (((i%6)+1) & 2)>>1;
dl.color[2] = (((i%6)+1) & 4)>>2;
dl.intensity = 200;
dl.texture = -1;
dl.color[0] = ((((i%6)+1) & 1)>>0) * 255;
dl.color[1] = ((((i%6)+1) & 2)>>1) * 255;
dl.color[2] = ((((i%6)+1) & 4)>>2) * 255;
dl.radius = 200;
if( !re->AddDynLight( &dl ))
if( !CL_AddDlight( &dl ))
break;
}
}
@ -1194,6 +1163,11 @@ void CL_AddDecals( void )
}
}
void CL_DecalShoot( HSPRITE hDecal, edict_t *pEnt, int modelIndex, float *pos, int flags )
{
CL_SpawnDecal( hDecal, pEnt, pos, 0, 90.0f, 5.0f );
}
/*
===============
CL_SpawnStaticDecal

View File

@ -1227,7 +1227,7 @@ pfnPlaySoundByName
*/
static void pfnPlaySoundByName( const char *szSound, float volume, int pitch, const float *org )
{
S_StartLocalSound( szSound, volume, pitch, org );
S_StartSound( org, cl.refdef.viewentity, CHAN_AUTO, S_RegisterSound( szSound ), volume, ATTN_NORM, pitch, 0 );
}
/*
@ -1417,8 +1417,7 @@ return interpolated angles from previous frame
*/
static void pfnGetViewAngles( float *angles )
{
if( angles == NULL ) return;
VectorCopy( cl.refdef.cl_viewangles, angles );
if( angles ) VectorCopy( cl.refdef.cl_viewangles, angles );
}
/*
@ -1430,8 +1429,7 @@ return interpolated angles from previous frame
*/
static void pfnSetViewAngles( float *angles )
{
if( angles == NULL ) return;
VectorCopy( angles, cl.refdef.cl_viewangles );
if( angles ) VectorCopy( angles, cl.refdef.cl_viewangles );
}
/*
@ -1573,7 +1571,7 @@ pfnPointContents
=============
*/
static int pfnPointContents( const float *rgflVector )
static int pfnPointContents( const float *rgflVector, int *truecont )
{
return CL_PointContents( rgflVector );
}
@ -2400,9 +2398,9 @@ static efxapi_t gEfxApi =
CL_GetPaletteColor,
pfnDecalIndex,
pfnDecalIndexFromName,
CL_SpawnDecal,
CL_AddDLight,
CL_AddSLight,
CL_DecalShoot,
CL_AllocDlight,
CL_AllocElight,
CL_LightForPoint,
CM_BoxVisible,
pfnCullBox,
@ -2414,22 +2412,20 @@ static efxapi_t gEfxApi =
static event_api_t gEventApi =
{
EVENT_API_VERSION,
pfnPrecacheEvent,
pfnPlaybackEvent,
pfnWeaponAnim,
pfnRandomFloat,
pfnRandomLong,
pfnHookEvent,
pfnKillEvents,
pfnPlaySound,
pfnStopSound,
pfnFindModelIndex,
pfnIsLocal,
pfnLocalPlayerViewheight,
pfnStopAllSounds,
pfnGetModelType,
pfnGetModFrames,
pfnLocalPlayerViewheight,
pfnGetModBounds,
pfnGetModFrames,
pfnWeaponAnim,
pfnPrecacheEvent,
pfnPlaybackEvent,
pfnTraceTexture,
pfnStopAllSounds,
pfnKillEvents,
};
// engine callbacks
@ -2487,11 +2483,11 @@ static cl_enginefuncs_t gEngfuncs =
pfnGetBonePosition,
CL_AllocString,
CL_GetString,
CL_GetLocalPlayer,
CL_GetLocalPlayer,
pfnGetViewModel,
CL_GetEdictByIndex,
pfnGetClientTime,
pfnIsSpectateOnly,
S_FadeClientVolume,
pfnGetAttachment,
pfnPointContents,
pfnWaterEntity,
@ -2521,6 +2517,7 @@ static cl_enginefuncs_t gEngfuncs =
&gTriApi,
&gEfxApi,
&gEventApi,
pfnIsSpectateOnly,
pfnIsInGame
};

View File

@ -1202,7 +1202,7 @@ void Host_ClientFrame( void )
SCR_UpdateScreen ();
// update audio
S_Update( &cl.refdef );
S_RenderFrame( &cl.refdef );
// advance local effects for next frame
CL_RunLightStyles ();

View File

@ -856,6 +856,8 @@ void CL_ParseServerMessage( sizebuf_t *msg )
case svc_changing:
cls.drawplaque = false;
Cmd_ExecuteString( "hud_changelevel\n" );
S_StopAllSounds();
// intentional fallthrough
case svc_reconnect:
if( cls.drawplaque )
Msg( "Server disconnected, reconnecting\n" );
@ -908,7 +910,7 @@ void CL_ParseServerMessage( sizebuf_t *msg )
case svc_print:
i = MSG_ReadByte( msg );
if( i == PRINT_CHAT ) // chat
S_StartLocalSound( "misc/talk.wav", 1.0f, 100, NULL );
S_StartLocalSound( "misc/talk.wav" ); // FIXME: INTRESOURCE
Con_Print( va( "^6%s\n", MSG_ReadString( msg )));
break;
case svc_centerprint:

View File

@ -442,7 +442,7 @@ void SCR_RegisterShaders( void )
// register console images
cls.consoleFont = re->RegisterShader( va( "gfx/fonts/%s", con_font->string ), SHADER_FONT );
cls.clientFont = re->RegisterShader( va( "gfx/fonts/%s", cl_font->string ), SHADER_FONT );
cls.netIcon = re->RegisterShader( "#net.png", SHADER_NOMIP ); // internal recource
cls.netIcon = re->RegisterShader( "#net.png", SHADER_NOMIP ); // FIXME: INTRESOURCE
cls.fillShader = re->RegisterShader( "*white", SHADER_FONT ); // used for FillRGBA
cls.particle = re->RegisterShader( "*particle", SHADER_FONT ); // Q1 particlefont

View File

@ -158,6 +158,7 @@ bool V_PreRender( void )
clearScene = false;
re->BeginFrame( clearScene );
S_BeginFrame ();
if( oldState && !cls.drawplaque )
{

View File

@ -551,6 +551,8 @@ void CL_AddDecals( void );
void CL_ClearEffects( void );
void CL_TestLights( void );
void CL_TestEntities( void );
dlight_t *CL_AllocDlight( int key );
dlight_t *CL_AllocElight( int key );
particle_t *CL_AllocParticle( void );
void CL_EntityParticles( edict_t *ent );
void CL_LavaSplash( const vec3_t org );
@ -562,9 +564,7 @@ void CL_ParticleExplosion2( const vec3_t org, int colorStart, int colorLength );
void CL_GetPaletteColor( int colorIndex, vec3_t outColor );
void CL_FindExplosionPlane( const vec3_t origin, float radius, vec3_t result );
void CL_LightForPoint( const vec3_t point, vec3_t ambientLight );
int CL_SpawnDecal( HSPRITE m_hDecal, edict_t *pEnt, const vec3_t pos, int colorIndex, float roll, float scale );
void CL_AddDLight( const float *org, const float *rgb, float radius, float time, int flags, int key );
void CL_AddSLight( const float *org, float *dir, float rad, float *cone, HSPRITE hLight, int key );
void CL_DecalShoot( HSPRITE hDecal, edict_t *pEnt, int modelIndex, float *pos, int flags );
void CL_ParticleEffect( const vec3_t org, const vec3_t dir, int color, int count ); // q1 legacy
void CL_SpawnStaticDecal( vec3_t origin, int decalIndex, int entityIndex, int modelIndex );
void CL_QueueEvent( int flags, int index, float delay, event_args_t *args );

View File

@ -167,15 +167,20 @@ _inline bool CM_BoxVisible( const vec3_t mins, const vec3_t maxs )
#define S_StartBackgroundTrack if( se ) se->StartBackgroundTrack
#define S_StopBackgroundTrack if( se ) se->StopBackgroundTrack
#define S_RawSamples if( se ) se->StreamRawSamples
#define S_FadeClientVolume if( se ) se->FadeClientVolume
#define S_StopAllSounds if( se ) se->StopAllSounds
#define S_StopSound if( se ) se->StopSound
#define S_AddLoopingSound if( se ) se->AddLoopingSound
#define S_Activate if( se ) se->Activate
#define S_Update if( se ) se->RenderFrame
#define S_BeginFrame if( se ) se->BeginFrame
#define S_RenderFrame if( se ) se->RenderFrame
#define S_BeginRegistration if( se ) se->BeginRegistration
#define S_EndRegistration if( se ) se->EndRegistration
_inline void S_FadeClientVolume( float fadePercent, float fadeOutSeconds, float holdTime, float fadeInSeconds )
{
if( se ) se->FadeClientVolume( fadePercent, fadeOutSeconds, holdTime, fadeInSeconds );
}
_inline sound_t S_RegisterSound( const char *name )
{
if( !se ) return 0;

View File

@ -81,7 +81,7 @@ void ClearLink( link_t *l );
void World_MoveBounds( const vec3_t start, vec3_t mins, vec3_t maxs, const vec3_t end, vec3_t boxmins, vec3_t boxmaxs );
trace_t World_CombineTraces( trace_t *cliptrace, trace_t *trace, edict_t *touch );
#include "bmodel_ref.h"
#include "bspfile.h"
#include "pm_shared.h"
/*

View File

@ -7,7 +7,7 @@
#include "client.h"
#include "byteorder.h"
#include "const.h"
#include "bmodel_ref.h"
#include "bspfile.h"
/*
=======================================================================

View File

@ -63,6 +63,7 @@ static net_field_t ent_fields[] =
{ ES_FIELD(flags), NET_LONG, false }, // misc edict flags
{ ES_FIELD(movetype), NET_BYTE, false },
{ ES_FIELD(gravity), NET_SHORT, false }, // gravity multiplier
{ ES_FIELD(friction), NET_FLOAT, false }, // friction for prediction
{ ES_FIELD(aiment), NET_SHORT, false }, // entity index
{ ES_FIELD(owner), NET_SHORT, false }, // entity owner index
{ ES_FIELD(groundent), NET_SHORT, false }, // ground entity index, if FL_ONGROUND is set

View File

@ -373,7 +373,6 @@ void SV_Newgame_f( void );
//
void SV_WriteFrameToClient( sv_client_t *client, sizebuf_t *msg );
void SV_BuildClientFrame( sv_client_t *client );
void SV_UpdateEntityState( const edict_t *ent, bool baseline );
void SV_InactivateClients( void );
void SV_SendMessagesToAll( void );
@ -392,7 +391,7 @@ void SV_SetModel( edict_t *ent, const char *name );
void SV_CopyTraceToGlobal( trace_t *trace );
void SV_SetMinMaxSize( edict_t *e, const float *min, const float *max );
void SV_PlaybackEvent( sizebuf_t *msg, event_info_t *info );
void SV_BaselineForEntity( const edict_t *pEdict );
void SV_BaselineForEntity( edict_t *pEdict );
void SV_WriteEntityPatch( const char *filename );
script_t *SV_GetEntityScript( const char *filename );
float SV_AngleMod( float ideal, float current, float speed );

View File

@ -662,17 +662,13 @@ void SV_PutClientInServer( edict_t *ent )
}
else
{
// copy signon buffer
MSG_WriteData( &client->netchan.message, sv.signon.data, sv.signon.cursize );
// setup maxspeed and refresh physinfo
SV_SetClientMaxspeed( client, svgame.movevars.maxspeed );
if( sv_maxclients->integer > 1 )
ent->v.netname = MAKE_STRING(Info_ValueForKey( client->userinfo, "name" ));
else ent->v.netname = 0;
ent->v.view_ofs[2] = GI->viewheight[0];
else ent->v.netname = MAKE_STRING( "player" );
// fisrt entering
svgame.dllFuncs.pfnClientPutInServer( ent );
@ -697,6 +693,9 @@ void SV_PutClientInServer( edict_t *ent )
if( !( ent->v.flags & FL_FAKECLIENT ))
{
// copy signon buffer
MSG_WriteData( &client->netchan.message, sv.signon.data, sv.signon.cursize );
MSG_WriteByte( &client->netchan.message, svc_setview );
MSG_WriteWord( &client->netchan.message, NUM_FOR_EDICT( client->edict ));
MSG_Send( MSG_ONE, NULL, client->edict );
@ -1101,21 +1100,15 @@ void SV_UserinfoChanged( sv_client_t *cl, const char *userinfo )
if( SV_IsValidEdict( ent ))
{
if( sv_maxclients->integer > 1 )
{
const char *model = Info_ValueForKey( cl->userinfo, "model" );
const char *model = Info_ValueForKey( cl->userinfo, "model" );
// apply custom playermodel
if( com.strlen( model ) && com.stricmp( model, "player" ))
{
const char *path = va( "models/player/%s/%s.mdl", model, model );
CM_RegisterModel( path, SV_ModelIndex( path )); // register model
SV_SetModel( ent, path );
cl->modelindex = ent->v.modelindex;
}
else cl->modelindex = 0;
// apply custom playermodel
if( com.strlen( model ) && com.stricmp( model, "player" ))
{
const char *path = va( "models/player/%s/%s.mdl", model, model );
cl->modelindex = SV_ModelIndex( path );
CM_RegisterModel( path, cl->modelindex ); // upload model
}
else cl->modelindex = 0;
}
// call prog code to allow overrides

View File

@ -40,79 +40,6 @@ static int SV_EntityNumbers( const void *a, const void *b )
/*
=============================================================================
Copy entvars into entity state
=============================================================================
*/
void SV_UpdateEntityState( const edict_t *ent, bool baseline )
{
sv_client_t *client = SV_ClientFromEdict( ent, true );
if( !ent->pvServerData->s.classname )
ent->pvServerData->s.classname = SV_ClassIndex( STRING( ent->v.classname ));
if( client && !sv.paused )
{
SV_SetIdealPitch( client );
switch( ent->v.fixangle )
{
case 1:
MSG_WriteByte( &sv.multicast, svc_setangle );
MSG_WriteAngle32( &sv.multicast, ent->v.angles[0] );
MSG_WriteAngle32( &sv.multicast, ent->v.angles[1] );
MSG_DirectSend( MSG_ONE, vec3_origin, client->edict );
ent->pvServerData->s.ed_flags |= ESF_NO_PREDICTION;
break;
case 2:
MSG_WriteByte( &sv.multicast, svc_addangle );
MSG_WriteAngle32( &sv.multicast, client->addangle );
MSG_DirectSend( MSG_ONE, vec3_origin, client->edict );
client->addangle = 0;
break;
}
client->edict->v.fixangle = 0; // reset fixangle
if( client->modelindex )
{
// apply custom model if set
((edict_t *)ent)->v.modelindex = client->modelindex;
}
}
svgame.dllFuncs.pfnUpdateEntityState( &ent->pvServerData->s, (edict_t *)ent, baseline );
// always keep an actual
ent->pvServerData->s.number = ent->serialnumber;
}
/*
===============
SV_AddEntToSnapshot
===============
*/
static void SV_AddEntToSnapshot( sv_priv_t *svent, edict_t *ent, sv_ents_t *ents )
{
// if we have already added this entity to this snapshot, don't add again
if( svent->framenum == sv.net_framenum ) return;
svent->framenum = sv.net_framenum;
// if we are full, silently discard entities
if( ents->num_entities == MAX_VISIBLE_PACKET )
{
MsgDev( D_ERROR, "too many entities in visible packet list\n" );
return;
}
SV_UpdateEntityState( ent, false ); // copy entity state from progs
ents->entities[ents->num_entities] = ent->serialnumber;
ents->num_entities++;
c_fullsend++; // debug counter
}
/*
=============================================================================
Encode a client frame onto the network channel
=============================================================================
@ -140,16 +67,23 @@ void SV_EmitPacketEntities( client_frame_t *from, client_frame_t *to, sizebuf_t
oldent = NULL;
newindex = 0;
oldindex = 0;
while( newindex < to->num_entities || oldindex < from_num_entities )
{
if( newindex >= to->num_entities ) newnum = MAX_ENTNUMBER;
if( newindex >= to->num_entities )
{
newnum = MAX_ENTNUMBER;
}
else
{
newent = &svs.client_entities[(to->first_entity+newindex)%svs.num_client_entities];
newnum = newent->number;
}
if( oldindex >= from_num_entities ) oldnum = MAX_ENTNUMBER;
if( oldindex >= from_num_entities )
{
oldnum = MAX_ENTNUMBER;
}
else
{
oldent = &svs.client_entities[(from->first_entity+oldindex)%svs.num_client_entities];
@ -166,6 +100,7 @@ void SV_EmitPacketEntities( client_frame_t *from, client_frame_t *to, sizebuf_t
newindex++;
continue;
}
if( newnum < oldnum )
{
// this is a new entity, send it from the baseline
@ -173,6 +108,7 @@ void SV_EmitPacketEntities( client_frame_t *from, client_frame_t *to, sizebuf_t
newindex++;
continue;
}
if( newnum > oldnum )
{
// remove from message
@ -189,7 +125,6 @@ static void SV_AddEntitiesToPacket( edict_t *pViewEnt, edict_t *pClient, client_
edict_t *ent;
byte *pset;
bool fullvis = false;
bool force = false;
sv_client_t *cl;
int e;
@ -230,27 +165,28 @@ static void SV_AddEntitiesToPacket( edict_t *pViewEnt, edict_t *pClient, client_
if( ent->pvServerData->framenum == sv.net_framenum )
continue;
if( fullvis ) force = true;
else force = false; // clear forceflag
// NOTE: always add himslef to list
if( !portal && ( ent == pClient ))
force = true;
if( ent->v.flags & FL_PHS_FILTER )
pset = clientphs;
else pset = clientpvs;
if( !force )
// add entity to the net packet
if( svgame.dllFuncs.pfnAddToFullPack( &ent->pvServerData->s, pViewEnt, pClient, ent, sv.hostflags, pset ))
{
// run custom user filter
if( !svgame.dllFuncs.pfnAddToFullPack( pViewEnt, pClient, ent, sv.hostflags, pset ))
continue;
// to prevent adds it twice through portals
ent->pvServerData->framenum = sv.net_framenum;
// if we are full, silently discard entities
if( ents->num_entities < MAX_VISIBLE_PACKET )
{
ents->entities[ents->num_entities] = ent->serialnumber;
ents->num_entities++;
c_fullsend++; // debug counter
}
else MsgDev( D_ERROR, "too many entities in visible packet list\n" );
}
SV_AddEntToSnapshot( ent->pvServerData, ent, ents ); // add it
if( fullvis ) continue; // portal ents will be added anyway, ignore recursion
// if its a portal entity, add everything visible from its camera position
if( !portal )
{
@ -402,6 +338,27 @@ void SV_BuildClientFrame( sv_client_t *cl )
viewent = cl->pViewEntity;
sv.net_framenum++;
SV_SetIdealPitch( cl );
// update client fixangle
switch( clent->v.fixangle )
{
case 1:
MSG_WriteByte( &sv.multicast, svc_setangle );
MSG_WriteAngle32( &sv.multicast, clent->v.angles[0] );
MSG_WriteAngle32( &sv.multicast, clent->v.angles[1] );
MSG_DirectSend( MSG_ONE, vec3_origin, clent );
clent->pvServerData->s.ed_flags |= ESF_NO_PREDICTION;
break;
case 2:
MSG_WriteByte( &sv.multicast, svc_addangle );
MSG_WriteAngle32( &sv.multicast, cl->addangle );
MSG_DirectSend( MSG_ONE, vec3_origin, clent );
cl->addangle = 0;
break;
}
clent->v.fixangle = 0; // reset fixangle
// this is the frame we are creating
frame = &cl->frames[sv.framenum & SV_UPDATE_MASK];
frame->senttime = host.realtime; // save it for ping calc later

View File

@ -11,6 +11,46 @@
#include "pm_defs.h"
#include "const.h"
/*
=============
EntvarsDescription
entavrs table for FindEntityByString
=============
*/
#define ENTVARS_COUNT ( sizeof( gEntvarsDescription ) / sizeof( gEntvarsDescription[0] ))
static TYPEDESCRIPTION gEntvarsDescription[] =
{
DEFINE_ENTITY_FIELD( classname, FIELD_STRING ),
DEFINE_ENTITY_FIELD( globalname, FIELD_STRING ),
DEFINE_ENTITY_FIELD( model, FIELD_MODELNAME ),
DEFINE_ENTITY_FIELD( viewmodel, FIELD_MODELNAME ),
DEFINE_ENTITY_FIELD( weaponmodel, FIELD_MODELNAME ),
DEFINE_ENTITY_FIELD( target, FIELD_STRING ),
DEFINE_ENTITY_FIELD( targetname, FIELD_STRING ),
DEFINE_ENTITY_FIELD( netname, FIELD_STRING ),
DEFINE_ENTITY_FIELD( message, FIELD_STRING ),
DEFINE_ENTITY_FIELD( noise, FIELD_SOUNDNAME ),
DEFINE_ENTITY_FIELD( noise1, FIELD_SOUNDNAME ),
DEFINE_ENTITY_FIELD( noise2, FIELD_SOUNDNAME ),
DEFINE_ENTITY_FIELD( noise3, FIELD_SOUNDNAME ),
};
/*
=============
SV_GetEntvarsDescription
entavrs table for FindEntityByString
=============
*/
TYPEDESCRIPTION *SV_GetEntvarsDescirption( int number )
{
if( number < 0 && number >= ENTVARS_COUNT )
return NULL;
return &gEntvarsDescription[number];
}
void SV_SetMinMaxSize( edict_t *e, const float *min, const float *max )
{
int i;
@ -529,7 +569,7 @@ SV_BaselineForEntity
assume pEdict is valid
=========
*/
void SV_BaselineForEntity( const edict_t *pEdict )
void SV_BaselineForEntity( edict_t *pEdict )
{
sv_priv_t *sv_ent;
@ -539,24 +579,30 @@ void SV_BaselineForEntity( const edict_t *pEdict )
// update baseline for new entity
if( !sv_ent->s.number )
{
entity_state_t *base;
int modelindex;
sv_client_t *cl;
base = &sv_ent->s;
sv_ent->s.classname = SV_ClassIndex( STRING( pEdict->v.classname ));
sv_ent->s.number = pEdict->serialnumber;
if( pEdict->v.flags & FL_CLIENT && ( cl = SV_ClientFromEdict( pEdict, false )))
modelindex = cl->modelindex ? cl->modelindex : pEdict->v.modelindex;
else modelindex = pEdict->v.modelindex;
if( pEdict->v.modelindex || pEdict->v.effects )
{
// take current state as baseline
SV_UpdateEntityState( pEdict, true );
svs.baselines[pEdict->serialnumber] = *base;
svgame.dllFuncs.pfnCreateBaseline( &sv_ent->s, pEdict, modelindex );
svs.baselines[pEdict->serialnumber] = sv_ent->s;
}
if( sv.state == ss_active && ( base->modelindex || base->effects ))
if( sv.state == ss_active && ( sv_ent->s.modelindex || sv_ent->s.effects ))
{
entity_state_t nullstate;
Mem_Set( &nullstate, 0, sizeof( nullstate ));
MSG_WriteByte( &sv.multicast, svc_spawnbaseline );
MSG_WriteDeltaEntity( &nullstate, base, &sv.multicast, true, true );
MSG_WriteDeltaEntity( &nullstate, &sv_ent->s, &sv.multicast, true, true );
MSG_DirectSend( MSG_ALL, vec3_origin, NULL );
}
}
@ -880,18 +926,14 @@ pfnFindEntityByString
edict_t* pfnFindEntityByString( edict_t *pStartEdict, const char *pszField, const char *pszValue )
{
int index = 0, e = 0;
int m_iValue;
float m_flValue;
const float *m_vecValue;
vec3_t m_vecValue2;
edict_t *ed, *ed2;
TYPEDESCRIPTION *desc = NULL;
edict_t *ed;
const char *t;
if( pStartEdict ) e = NUM_FOR_EDICT( pStartEdict );
if( !pszValue || !*pszValue ) return svgame.edicts;
while(( desc = svgame.dllFuncs.pfnGetEntvarsDescirption( index++ )) != NULL )
while(( desc = SV_GetEntvarsDescirption( index++ )) != NULL )
{
if( !com.strcmp( pszField, desc->fieldName ))
break;
@ -899,7 +941,7 @@ edict_t* pfnFindEntityByString( edict_t *pStartEdict, const char *pszField, cons
if( desc == NULL )
{
MsgDev( D_ERROR, "SV_FindEntityByString: field %s not found\n", pszField );
MsgDev( D_ERROR, "SV_FindEntityByString: field %s not a string\n", pszField );
return svgame.edicts;
}
@ -918,38 +960,6 @@ edict_t* pfnFindEntityByString( edict_t *pStartEdict, const char *pszField, cons
if( !com.strcmp( t, pszValue ))
return ed;
break;
case FIELD_SHORT:
m_iValue = *(short *)&((byte *)&ed->v)[desc->fieldOffset];
if( m_iValue == com.atoi( pszValue ))
return ed;
break;
case FIELD_INTEGER:
case FIELD_BOOLEAN:
m_iValue = *(int *)&((byte *)&ed->v)[desc->fieldOffset];
if( m_iValue == com.atoi( pszValue ))
return ed;
break;
case FIELD_TIME:
case FIELD_FLOAT:
m_flValue = *(int *)&((byte *)&ed->v)[desc->fieldOffset];
if( m_flValue == com.atof( pszValue ))
return ed;
break;
case FIELD_VECTOR:
case FIELD_POSITION_VECTOR:
m_vecValue = (float *)&((byte *)&ed->v)[desc->fieldOffset];
if( !m_vecValue ) m_vecValue = vec3_origin;
com.atov( m_vecValue2, pszValue, 3 );
if( VectorCompare( m_vecValue, m_vecValue2 ))
return ed;
break;
case FIELD_EDICT:
// NOTE: string must be contain an edict number
ed2 = (edict_t *)&((byte *)&ed->v)[desc->fieldOffset];
if( !ed2 ) ed2 = svgame.edicts;
if( NUM_FOR_EDICT( ed2 ) == com.atoi( pszValue ))
return ed;
break;
}
}
return svgame.edicts;
@ -1353,7 +1363,6 @@ void SV_StartSound( edict_t *ent, int chan, const char *sample, float vol, float
return;
}
if( sv.state == ss_loading ) flags |= SND_SPAWNING;
if( vol != VOL_NORM ) flags |= SND_VOLUME;
if( attn != ATTN_NONE ) flags |= SND_ATTENUATION;
if( pitch != PITCH_NORM ) flags |= SND_PITCH;
@ -1371,7 +1380,7 @@ void SV_StartSound( edict_t *ent, int chan, const char *sample, float vol, float
{
if( chan == CHAN_STATIC )
msg_dest = MSG_ALL;
else msg_dest = MSG_PAS;
else msg_dest = MSG_PAS_R;
}
}
else
@ -1380,15 +1389,8 @@ void SV_StartSound( edict_t *ent, int chan, const char *sample, float vol, float
VectorAdd( origin, ent->v.origin, origin );
if( flags & SND_SPAWNING )
{
msg_dest = MSG_INIT;
}
else
{
if( chan == CHAN_STATIC )
msg_dest = MSG_ALL;
else msg_dest = MSG_PAS;
}
else msg_dest = MSG_PAS_R;
}
// always sending stop sound command
@ -1429,7 +1431,7 @@ pfnEmitAmbientSound
=================
*/
void pfnEmitAmbientSound( edict_t *ent, float *pos, const char *samp, float vol, float attn, int flags, int pitch )
void pfnEmitAmbientSound( edict_t *ent, float *pos, const char *sample, float vol, float attn, int flags, int pitch )
{
int number = 0, sound_idx;
int msg_dest = MSG_PAS_R;
@ -1454,7 +1456,7 @@ void pfnEmitAmbientSound( edict_t *ent, float *pos, const char *samp, float vol,
if( flags & SND_SPAWNING )
msg_dest = MSG_INIT;
else msg_dest = MSG_PAS;
else msg_dest = MSG_ALL;
// ultimate method for detect bsp models with invalid solidity (e.g. func_pushable)
if( SV_IsValidEdict( ent ))
@ -1479,9 +1481,17 @@ void pfnEmitAmbientSound( edict_t *ent, float *pos, const char *samp, float vol,
if( flags & SND_STOP ) msg_dest = MSG_ALL;
flags |= SND_FIXED_ORIGIN;
// precache_sound can be used twice: cache sounds when loading
// and return sound index when server is active
sound_idx = SV_SoundIndex( samp );
if( sample[0] == '!' && com.is_digit( sample + 1 ))
{
flags |= SND_SENTENCE;
sound_idx = com.atoi( sample + 1 );
}
else
{
// precache_sound can be used twice: cache sounds when loading
// and return sound index when server is active
sound_idx = SV_SoundIndex( sample );
}
MSG_Begin( svc_ambientsound );
MSG_WriteWord( &sv.multicast, flags );

View File

@ -555,7 +555,11 @@ void SV_InitClientMove( void )
VectorCopy( GI->client_maxs[3], svgame.pmove->player_maxs[1] );
for( i = 0; i < PM_MAXHULLS; i++ )
svgame.pmove->player_view[i] = GI->viewheight[i];
{
svgame.pmove->player_view[i] = svgame.globals->viewheight[i] = GI->viewheight[i];
VectorCopy( svgame.pmove->player_mins[i], svgame.globals->hullmins[i] );
VectorCopy( svgame.pmove->player_maxs[i], svgame.globals->hullmaxs[i] );
}
// common utilities
svgame.pmove->PM_Info_ValueForKey = Info_ValueForKey;

View File

@ -1847,6 +1847,4 @@ void SV_Physics( void )
if( svgame.globals->force_retouch > 0 )
svgame.globals->force_retouch = max( 0, svgame.globals->force_retouch - 1 );
svgame.dllFuncs.pfnEndFrame();
}

View File

@ -306,7 +306,7 @@ UI_StartSound
*/
void UI_StartSound( const char *sound )
{
S_StartLocalSound( sound, 1.0f, 100.0f, vec3_origin );
S_StartLocalSound( sound );
}
/*

View File

@ -12,7 +12,7 @@
#include "entity_def.h"
#include "physic_api.h"
#include "qfiles_ref.h"
#include "bmodel_ref.h"
#include "bspfile.h"
#include "trace_def.h"
extern physic_imp_t pi;

View File

@ -1,351 +0,0 @@
//=======================================================================
// temporare header to keep engine work
//=======================================================================
#ifndef BSPFILE_H
#define BSPFILE_H
/*
==============================================================================
BRUSH MODELS
.bsp contain level static geometry with including PVS, PHS, PHYS and lightning info
==============================================================================
*/
// header
#define Q3IDBSP_VERSION 46
#define RTCWBSP_VERSION 47
#define IGIDBSP_VERSION 48 // extended brushides
#define XRIDBSP_VERSION 48 // x-real bsp version (extended verts and lightgrid)
#define RFIDBSP_VERSION 1 // both raven bsp and qfusion bsp
#define IDBSPMODHEADER (('P'<<24)+('S'<<16)+('B'<<8)+'I') // little-endian "IBSP"
#define RBBSPMODHEADER (('P'<<24)+('S'<<16)+('B'<<8)+'R') // little-endian "RBSP"
#define QFBSPMODHEADER (('P'<<24)+('S'<<16)+('B'<<8)+'F') // little-endian "FBSP"
#define XRBSPMODHEADER (('P'<<24)+('S'<<16)+('B'<<8)+'X') // little-endian "XBSP"
// 32 bit limits
#define MAX_MAP_AREA_BYTES MAX_MAP_AREAS / 8 // bit vector of area visibility
#define MAX_MAP_AREAS 0x100 // don't increase this
#define MAX_MAP_FOGS 0x100
#define MAX_MAP_MODELS 0x2000 // mesh models and sprites too
#define MAX_MAP_AREAPORTALS 0x400
#define MAX_MAP_ENTITIES 0x2000
#define MAX_MAP_SHADERS 0x1000
#define MAX_MAP_TEXINFO 0x8000
#define MAX_MAP_BRUSHES 0x8000
#define MAX_MAP_PLANES 0x20000
#define MAX_MAP_NODES 0x20000
#define MAX_MAP_BRUSHSIDES 0x20000
#define MAX_MAP_LEAFS 0x20000
#define MAX_MAP_VERTS 0x80000
#define MAX_MAP_SURFACES 0x20000
#define MAX_MAP_LEAFFACES 0x20000
#define MAX_MAP_LEAFBRUSHES 0x40000
#define MAX_MAP_PORTALS 0x20000
#define MAX_MAP_INDICES 0x80000
#define MAX_MAP_ENTSTRING 0x80000
#define MAX_MAP_LIGHTING 0x800000
#define MAX_MAP_VISIBILITY 0x800000
#define MAX_MAP_COLLISION 0x800000
#define MAX_WORLD_COORD ( 128 * 1024 )
#define MIN_WORLD_COORD (-128 * 1024 )
#define WORLD_SIZE ( MAX_WORLD_COORD - MIN_WORLD_COORD )
#define MAX_SHADERPATH 64
#define MAX_BUILD_SIDES 512 // per one brush. (don't touch!)
#define LM_STYLES 4 // MAXLIGHTMAPS
#define MAX_LIGHT_STYLES 64
#define MAX_SWITCHED_LIGHTS 32
// lump names
typedef struct
{
int fileofs, filelen;
} lump_t;
#define LUMP_ENTITIES 0
#define LUMP_SHADERS 1
#define LUMP_PLANES 2
#define LUMP_NODES 3
#define LUMP_LEAFS 4
#define LUMP_LEAFSURFACES 5
#define LUMP_LEAFBRUSHES 6
#define LUMP_MODELS 7
#define LUMP_BRUSHES 8
#define LUMP_BRUSHSIDES 9
#define LUMP_VERTEXES 10
#define LUMP_ELEMENTS 11
#define LUMP_FOGS 12
#define LUMP_SURFACES 13
#define LUMP_LIGHTING 14
#define LUMP_LIGHTGRID 15
#define LUMP_VISIBILITY 16
#define LUMP_LIGHTARRAY 17 // RBSP extra lump to save space
#define HEADER_LUMPS 18 // 17 for IDBSP
typedef enum
{
SURF_NONE = 0, // just a mask for source tabulation
SURF_NODAMAGE = BIT(0), // never give falling damage
SURF_SLICK = BIT(1), // effects game physics
SURF_SKY = BIT(2), // don't draw, but add to skybox
SURF_LADDER = BIT(3), // this is ladder surface
SURF_NOIMPACT = BIT(4), // don't make missile explosions
SURF_NOMARKS = BIT(5), // don't leave missile marks
SURF_WARP = BIT(6), // turbulent water warping
SURF_NODRAW = BIT(7), // don't generate a drawsurface at all
SURF_HINT = BIT(8), // make a primary bsp splitter
SURF_SKIP = BIT(9), // completely ignore, allowing non-closed brushes
SURF_NOLIGHTMAP = BIT(10), // don't place lightmap for this surface
SURF_POINTLIGHT = BIT(11), // generate lighting info at vertexes
SURF_METALSTEPS = BIT(12), // REMOVE? clanking footsteps
SURF_NOSTEPS = BIT(13), // REMOVE? no footstep sounds
SURF_NONSOLID = BIT(14), // don't collide against curves with this set
SURF_LIGHTFILTER = BIT(15), // act as a light filter during q3map -light
SURF_ALPHASHADOW = BIT(16), // do per-pixel light shadow casting in q3map
SURF_NODLIGHT = BIT(17), // never add dynamic lights
SURF_DUST = BIT(18), // REMOVE? leave a dust trail when walking on this surface
} surfaceFlags_t;
// bsp contents
typedef enum
{
BASECONT_NONE = 0, // just a mask for source tabulation
BASECONT_SOLID = BIT(0), // an eye is never valid in a solid
// reserved
BASECONT_SKY = BIT(2),
BASECONT_LAVA = BIT(3),
BASECONT_SLIME = BIT(4),
BASECONT_WATER = BIT(5),
BASECONT_FOG = BIT(6),
// space for new user contents
BASECONT_AREAPORTAL = BIT(15),
BASECONT_PLAYERCLIP = BIT(16),
BASECONT_MONSTERCLIP = BIT(17),
BASECONT_CLIP = (BASECONT_PLAYERCLIP|BASECONT_MONSTERCLIP), // both type clip
BASECONT_TELEPORTER = BIT(18),
BASECONT_JUMPPAD = BIT(19),
BASECONT_CLUSTERPORTAL = BIT(20),
BASECONT_DONOTENTER = BIT(21),
BASECONT_ORIGIN = BIT(22), // removed before bsping an entity
BASECONT_BODY = BIT(23), // should never be on a brush, only in game
BASECONT_CORPSE = BIT(24), // dead corpse
BASECONT_DETAIL = BIT(25), // brushes not used for the bsp
BASECONT_STRUCTURAL = BIT(26), // brushes used for the bsp
BASECONT_TRANSLUCENT = BIT(27), // don't consume surface fragments inside
BASECONT_LADDER = BIT(28), // ladder volume
BASECONT_NODROP = BIT(29), // don't leave bodies or items (death fog, lava)
// content masks
MASK_SOLID = (BASECONT_SOLID|BASECONT_BODY),
MASK_PLAYERSOLID = (BASECONT_SOLID|BASECONT_PLAYERCLIP|BASECONT_BODY),
MASK_MONSTERSOLID = (BASECONT_SOLID|BASECONT_MONSTERCLIP|BASECONT_BODY),
MASK_DEADSOLID = (BASECONT_SOLID|BASECONT_PLAYERCLIP),
MASK_WATER = (BASECONT_WATER|BASECONT_LAVA|BASECONT_SLIME),
MASK_OPAQUE = (BASECONT_SOLID|BASECONT_SLIME|BASECONT_LAVA),
MASK_SHOT = (BASECONT_SOLID|BASECONT_BODY|BASECONT_CORPSE)
} contentType_t;
typedef enum
{
MST_BAD = 0,
MST_PLANAR,
MST_PATCH,
MST_TRISURF,
MST_FLARE,
MST_FOLIAGE
} bspSurfaceType_t;
typedef struct
{
int ident;
int version;
lump_t lumps[HEADER_LUMPS];
} dheader_t;
typedef struct
{
vec3_t mins;
vec3_t maxs;
int firstsurface; // submodels just draw faces
int numsurfaces; // without walking the bsp tree
int firstbrush; // physics stuff
int numbrushes;
} dmodel_t;
typedef struct
{
char name[64]; // shader name
int surfaceFlags; // surface flags (can be replaced)
int contentFlags; // texture contents (can be replaced)
} dshader_t;
typedef struct
{
vec3_t point;
vec2_t tex_st; // texture coords
vec2_t lm_st; // lightmap texture coords
vec3_t normal; // normal
byte color[4]; // color used for vertex lighting
} dvertexq_t; // IBSP
typedef struct
{
vec3_t point;
vec2_t tex_st;
vec2_t lm_st[LM_STYLES];
vec3_t normal;
byte color[LM_STYLES][4];
} dvertexr_t; // RBSP
typedef struct
{
vec3_t point;
vec2_t tex_st;
vec2_t lm_st;
vec3_t normal;
vec4_t paintcolor;
vec4_t lightcolor;
vec3_t lightdir;
} dvertexx_t; // XBSP
typedef struct
{
float normal[3];
float dist;
} dplane_t;
typedef struct
{
int planenum;
int children[2]; // negative numbers are -(leafs+1), not nodes
int mins[3]; // for frustum culling
int maxs[3];
} dnode_t;
typedef dword dleafface_t;
typedef dword dleafbrush_t;
typedef struct
{
int cluster;
int area;
int mins[3]; // for frustum culling
int maxs[3];
int firstleafsurface;
int numleafsurfaces;
int firstleafbrush;
int numleafbrushes;
} dleaf_t;
typedef struct
{
int planenum; // facing out of the leaf
int shadernum; // surface description
} dbrushsideq_t;
typedef struct
{
int planenum; // facing out of the leaf
int shadernum; // surface description
int surfacenum;
} dbrushsider_t;
typedef struct
{
int firstside;
int numsides;
int shadernum; // brush global shader (e.g. contents)
} dbrush_t;
typedef struct
{
char shader[64];
int brushnum;
int visibleside;
} dfog_t;
typedef struct
{
int numclusters;
int rowsize;
byte data[1]; // unbounded
} dvis_t;
typedef struct
{
byte ambient[3];
byte diffuse[3];
byte direction[2];
} dlightgridq_t; // IBSP
typedef struct
{
byte ambient[LM_STYLES][3];
byte diffuse[LM_STYLES][3];
byte styles[LM_STYLES];
byte direction[2];
} dlightgridr_t; // RBSP
typedef struct
{
float ambient[3];
float diffuse[3];
byte direction[2];
} dlightgridx_t; // XBSP
typedef struct
{
int shadernum;
int fognum;
int facetype;
int firstvert;
int numverts;
uint firstelem;
int numelems;
int lm_texnum; // lightmap info
int lm_offset[2];
int lm_size[2];
vec3_t origin; // MST_FLARE only
vec3_t mins;
vec3_t maxs; // MST_PATCH and MST_TRISURF only
vec3_t normal; // MST_PLANAR only
int patch_cp[2]; // patch control point dimensions
} dsurfaceq_t; // IBSP, XBSP
typedef struct
{
int shadernum;
int fognum;
int facetype;
int firstvert;
int numverts;
uint firstelem;
int numelems;
byte lightmapStyles[LM_STYLES];
byte vertexStyles[LM_STYLES];
int lm_texnum[LM_STYLES]; // lightmap info
int lm_offset[LM_STYLES][2];
int lm_size[2];
vec3_t origin; // FACETYPE_FLARE only
vec3_t mins;
vec3_t maxs; // FACETYPE_PATCH and FACETYPE_TRISURF only
vec3_t normal; // FACETYPE_PLANAR only
int patch_cp[2]; // patch control point dimensions
} dsurfacer_t; // RBSP
#endif//BSPFILE_H

View File

@ -14,6 +14,10 @@
#define SHADER_GENERIC 4 // generic shader
#define SHADER_DECAL 5
// dlight flags
#define DLIGHT_ONLYENTS BIT( 0 )
#define DLIGHT_DARK BIT( 1 )
// screenshot types
#define VID_SCREENSHOT 0
#define VID_LEVELSHOT 1
@ -161,7 +165,7 @@ typedef struct render_exp_s
// prepare frame to rendering
bool (*AddRefEntity)( edict_t *pRefEntity, int ed_type, shader_t customShader );
bool (*AddTmpEntity)( struct tempent_s *TempEnt, int ed_type, shader_t customShader );
bool (*AddDynLight)( const void *dlight );
bool (*AddDLight)( vec3_t pos, rgb_t color, float radius, int flags );
bool (*AddPolygon)( const poly_t *poly );
bool (*AddLightStyle)( int stylenum, vec3_t color );
void (*ClearScene)( void );

View File

@ -37,10 +37,10 @@ typedef struct vsound_exp_s
sound_t (*RegisterSound)( const char *name );
void (*EndRegistration)( void );
void (*StartLocalSound)( const char *name ); // menus
void (*StartSound)( const vec3_t pos, int ent, int chan, sound_t sfx, float vol, float attn, int pitch, int flags );
void (*StaticSound)( const vec3_t pos, int ent, int chan, sound_t sfx, float vol, float attn, int pitch, int flags );
void (*StreamRawSamples)( int samples, int rate, int width, int channels, const byte *data );
bool (*StartLocalSound)( const char *name, float volume, int pitch, const float *origin );
void (*FadeClientVolume)( float fadePercent, float fadeOutSeconds, float holdTime, float fadeInSeconds );
void (*StartBackgroundTrack)( const char *introTrack, const char *loopTrack );
void (*StopBackgroundTrack)( void );
@ -48,6 +48,7 @@ typedef struct vsound_exp_s
void (*StartStreaming)( void );
void (*StopStreaming)( void );
void (*BeginFrame)( void );
void (*RenderFrame)( ref_params_t *fd );
void (*StopSound)( int entnum, int channel, const char *soundname );
void (*StopAllSounds)( void );

View File

@ -37,6 +37,7 @@
#include "game.h"
#include "soundent.h"
#include "baseweapon.h"
#include "weaponinfo.h"
#include "defaults.h"
#include "decals.h"
#include "nodes.h"
@ -264,7 +265,6 @@ void ClientPutInServer( edict_t *pEntity )
// Reset interpolation during first frame
pPlayer->pev->effects |= EF_NOINTERP;
pPlayer->m_flViewHeight = pPlayer->pev->view_ofs.z; // keep viewheight an actual
g_startSuit = FALSE;
}
@ -1156,130 +1156,6 @@ int ServerClassifyEdict( edict_t *pentToClassify )
return m_iNewClass;
}
void UpdateEntityState( entity_state_t *to, edict_t *from, int baseline )
{
int i;
if( !to || !from ) return;
CBaseEntity *pNet;
pNet = CBaseEntity::Instance( from );
if( !pNet ) return;
// setup some special edict flags (engine will clearing them after the current frame)
if( to->modelindex != pNet->pev->modelindex )
to->ed_flags |= ESF_NODELTA;
// always set nodelta's for baseline
if( baseline ) to->ed_flags |= ESF_NODELTA;
// copy progs values to state
to->solid = (solid_t)pNet->pev->solid;
to->origin = pNet->pev->origin;
to->angles = pNet->pev->angles;
to->modelindex = pNet->pev->modelindex;
to->health = pNet->pev->health;
to->skin = pNet->pev->skin; // studio model skin
to->body = pNet->pev->body; // studio model submodel
to->effects = pNet->pev->effects; // shared client and render flags
to->renderfx = pNet->pev->renderfx; // renderer flags
to->rendermode = pNet->pev->rendermode; // rendering mode
to->renderamt = pNet->pev->renderamt; // alpha value
to->animtime = (int)(1000.0 * pNet->pev->animtime) * 0.001; // sequence time
to->localtime = (int)(1000.0 * pNet->pev->ltime) * 0.001; // movement time
to->scale = pNet->pev->scale; // shared client and render flags
to->movetype = (movetype_t)pNet->pev->movetype;
to->frame = pNet->pev->frame; // any model current frame
to->framerate = pNet->pev->framerate;
to->mins = pNet->pev->mins;
to->maxs = pNet->pev->maxs;
to->flags = pNet->pev->flags;
to->rendercolor = pNet->pev->rendercolor;
to->oldorigin = pNet->pev->oldorigin;
to->colormap = pNet->pev->colormap; // attachments
if( pNet->pev->groundentity )
to->groundent = ENTINDEX( pNet->pev->groundentity );
else to->groundent = NULLENT_INDEX;
// translate attached entity
if( pNet->pev->aiment )
to->aiment = ENTINDEX( pNet->pev->aiment );
else to->aiment = NULLENT_INDEX;
// studio model sequence
if( pNet->pev->sequence != -1 ) to->sequence = pNet->pev->sequence;
for( i = 0; i < 16; i++ )
{
// copy blendings and bone ctrlrs
to->blending[i] = pNet->pev->blending[i];
to->controller[i] = pNet->pev->controller[i];
}
if( to->ed_type == ED_CLIENT )
{
if( pNet->pev->teleport_time )
{
to->ed_flags |= ESF_NO_PREDICTION;
to->ed_flags |= ESF_NODELTA;
pNet->pev->teleport_time = 0.0f;
}
if( pNet->pev->viewmodel )
to->viewmodel = MODEL_INDEX( STRING( pNet->pev->viewmodel ));
else to->viewmodel = 0;
if( pNet->pev->aiment )
to->aiment = ENTINDEX( pNet->pev->aiment );
else to->aiment = NULLENT_INDEX;
to->viewoffset = pNet->pev->view_ofs;
to->viewangles = pNet->pev->v_angle;
to->idealpitch = pNet->pev->idealpitch;
to->punch_angles = pNet->pev->punchangle;
to->velocity = pNet->pev->velocity;
to->basevelocity = pNet->pev->clbasevelocity;
to->iStepLeft = pNet->pev->iStepLeft;
to->flFallVelocity = pNet->pev->flFallVelocity;
// playermodel sequence, that will be playing on a client
if( pNet->pev->gaitsequence != -1 )
to->gaitsequence = pNet->pev->gaitsequence;
if( pNet->pev->weaponmodel != iStringNull )
to->weaponmodel = MODEL_INDEX( STRING( pNet->pev->weaponmodel ));
else to->weaponmodel = 0;
to->weapons = pNet->pev->weapons;
to->maxspeed = pNet->pev->maxspeed;
// clamp fov
if( pNet->pev->fov < 0.0 ) pNet->pev->fov = 0.0;
if( pNet->pev->fov > 160 ) pNet->pev->fov = 160;
to->fov = pNet->pev->fov;
}
else if( to->ed_type == ED_AMBIENT )
{
}
else if( to->ed_type == ED_MOVER || to->ed_type == ED_BSPBRUSH || to->ed_type == ED_PORTAL )
{
to->body = DirToBits( pNet->pev->movedir );
to->velocity = pNet->pev->velocity;
// this is conveyor - send speed to render for right texture scrolling
to->framerate = pNet->pev->speed;
}
else if( to->ed_type == ED_BEAM )
{
to->gaitsequence = pNet->pev->frags; // beam type
// translate StartBeamEntity
if( pNet->pev->owner )
to->owner = ENTINDEX( pNet->pev->owner );
else to->owner = NULLENT_INDEX;
}
}
/*
=================
CmdStart
@ -1515,13 +1391,13 @@ player is 1 if the ent/e is a player and 0 otherwise
pSet is either the PAS or PVS that we previous set up. We can use it to ask the engine to filter the entity against the PAS or PVS.
we could also use the pas/ pvs that we set in SetupVisibility, if we wanted to. Caching the value is valid in that case, but still only for the current frame
*/
int AddToFullPack( edict_t *pView, edict_t *pHost, edict_t *pEdict, int hostflags, byte *pSet )
int AddToFullPack( entity_state_t *state, edict_t *pView, edict_t *pHost, edict_t *pEdict, int hostflags, byte *pSet )
{
if( FNullEnt( pEdict )) return 0; // never adding invalid entities
CBaseEntity *pEntity;
Vector delta; // for ambient sounds
// completely ignore dormant entity
if( pEdict->v.flags & FL_DORMANT )
return 0;
if( FNullEnt( pEdict ))
return 0; // never adding invalid entities
if( FNullEnt( pView )) pView = pHost; // pfnCustomView not set
@ -1531,6 +1407,18 @@ int AddToFullPack( edict_t *pView, edict_t *pHost, edict_t *pEdict, int hostflag
if( pViewEntity && pViewEntity->m_iClassType == ED_PORTAL )
bIsPortalPass = TRUE; // view from portal camera
pEntity = (CBaseEntity *)CBaseEntity::Instance( pEdict );
if( !pEntity ) return 0;
// NOTE: always add himslef to list
if( !bIsPortalPass && ( pHost == pEdict ))
goto addEntity;
// completely ignore dormant entity
if( pEdict->v.flags & FL_DORMANT )
return 0;
// don't send spectators to other players
if(( pEdict->v.flags & FL_SPECTATOR ) && ( pEdict != pHost ))
@ -1538,15 +1426,11 @@ int AddToFullPack( edict_t *pView, edict_t *pHost, edict_t *pEdict, int hostflag
return 0;
}
CBaseEntity *pEntity = (CBaseEntity *)CBaseEntity::Instance( pEdict );
if( !pEntity ) return 0;
// quick reject by type
switch( pEntity->m_iClassType )
{
case ED_SKYPORTAL:
return 1; // no additional check requires
goto addEntity; // no additional check requires
case ED_BEAM:
case ED_MOVER:
case ED_NORMAL:
@ -1559,15 +1443,6 @@ int AddToFullPack( edict_t *pView, edict_t *pHost, edict_t *pEdict, int hostflag
default: return 0; // skipped
}
if( bIsPortalPass && (pEdict->v.flags & FL_PROJECTILE) && pEdict->v.teleport_time )
{
// HACKHACK - add grenades, rockets and other things that passed teleport into portal PVS
// as potentially visible. This is only for single frame.
return 1;
}
Vector delta = g_vecZero; // for ambient sounds
// check for ambients distance
if( pEntity->m_iClassType == ED_AMBIENT )
{
@ -1581,6 +1456,7 @@ int AddToFullPack( edict_t *pView, edict_t *pHost, edict_t *pEdict, int hostflag
// precalc delta distance for sounds
delta = pView->v.origin - entorigin;
}
else delta = g_vecZero;
// check visibility
if ( !ENGINE_CHECK_PVS( pEdict, pSet ))
@ -1606,6 +1482,7 @@ int AddToFullPack( edict_t *pView, edict_t *pHost, edict_t *pEdict, int hostflag
// don't send entity to local client if the client says it's predicting the entity itself.
if( pEntity->pev->flags & FL_SKIPLOCALHOST )
{
if( bIsPortalPass ) return 0;
if(( hostflags & 1 ) && ( pEntity->pev->owner == pHost ))
return 0;
}
@ -1637,9 +1514,214 @@ int AddToFullPack( edict_t *pView, edict_t *pHost, edict_t *pEdict, int hostflag
}
UTIL_UnsetGroupTrace();
}
addEntity:
// setup some special edict flags (engine will clearing them after the current frame)
if( state->modelindex != pEntity->pev->modelindex || ( pEntity->pev->effects & EF_NOINTERP ))
state->ed_flags |= ESF_NODELTA;
// always keep an actual
state->number = pEdict->serialnumber;
// copy progs values to state
state->solid = (solid_t)pEntity->pev->solid;
state->origin = pEntity->pev->origin;
state->angles = pEntity->pev->angles;
state->modelindex = pEntity->pev->modelindex;
state->health = pEntity->pev->health;
state->skin = pEntity->pev->skin; // studio model skin
state->body = pEntity->pev->body; // studio model submodel
state->effects = pEntity->pev->effects; // shared client and render flags
state->renderfx = pEntity->pev->renderfx; // renderer flags
state->rendermode = pEntity->pev->rendermode; // rendering mode
state->renderamt = pEntity->pev->renderamt; // alpha value
state->animtime = (int)(1000.0 * pEntity->pev->animtime) * 0.001; // sequence time
state->localtime = (int)(1000.0 * pEntity->pev->ltime) * 0.001; // movement time
state->scale = pEntity->pev->scale; // shared client and render flags
state->movetype = (movetype_t)pEntity->pev->movetype;
state->frame = pEntity->pev->frame; // any model current frame
state->framerate = pEntity->pev->framerate;
state->mins = pEntity->pev->mins;
state->maxs = pEntity->pev->maxs;
state->flags = pEntity->pev->flags;
state->rendercolor = pEntity->pev->rendercolor;
state->oldorigin = pEntity->pev->oldorigin;
state->colormap = pEntity->pev->colormap; // attachments
if( pEntity->pev->groundentity )
state->groundent = ENTINDEX( pEntity->pev->groundentity );
else state->groundent = NULLENT_INDEX;
// translate attached entity
if( pEntity->pev->aiment )
state->aiment = ENTINDEX( pEntity->pev->aiment );
else state->aiment = NULLENT_INDEX;
// studio model sequence
if( pEntity->pev->sequence != -1 )
state->sequence = pEntity->pev->sequence;
for( int i = 0; i < 16; i++ )
{
// copy blendings and bone ctrlrs
state->blending[i] = pEntity->pev->blending[i];
state->controller[i] = pEntity->pev->controller[i];
}
if( state->ed_type == ED_CLIENT )
{
if( pEntity->pev->teleport_time )
{
state->ed_flags |= ESF_NO_PREDICTION;
state->ed_flags |= ESF_NODELTA;
pEntity->pev->teleport_time = 0.0f;
}
if( pEntity->pev->viewmodel )
state->viewmodel = MODEL_INDEX( STRING( pEntity->pev->viewmodel ));
else state->viewmodel = 0;
if( pEntity->pev->aiment )
state->aiment = ENTINDEX( pEntity->pev->aiment );
else state->aiment = NULLENT_INDEX;
state->viewoffset = pEntity->pev->view_ofs;
state->viewangles = pEntity->pev->v_angle;
state->idealpitch = pEntity->pev->idealpitch;
state->punch_angles = pEntity->pev->punchangle;
state->velocity = pEntity->pev->velocity;
state->basevelocity = pEntity->pev->clbasevelocity;
state->iStepLeft = pEntity->pev->iStepLeft;
state->flFallVelocity = pEntity->pev->flFallVelocity;
// playermodel sequence, that will be playing on a client
if( pEntity->pev->gaitsequence != -1 )
state->gaitsequence = pEntity->pev->gaitsequence;
if( pEntity->pev->weaponmodel != iStringNull )
state->weaponmodel = MODEL_INDEX( STRING( pEntity->pev->weaponmodel ));
else state->weaponmodel = 0;
state->weapons = pEntity->pev->weapons;
state->maxspeed = pEntity->pev->maxspeed;
// clamp fov
if( pEntity->pev->fov < 0.0 ) pEntity->pev->fov = 0.0;
if( pEntity->pev->fov > 160 ) pEntity->pev->fov = 160;
state->fov = pEntity->pev->fov;
}
else if( state->ed_type == ED_AMBIENT )
{
// add here specified fields e.g for trigger_teleport wind sound etc
}
else if( state->ed_type == ED_MOVER || state->ed_type == ED_BSPBRUSH || state->ed_type == ED_PORTAL )
{
state->body = DirToBits( pEntity->pev->movedir );
state->velocity = pEntity->pev->velocity;
// this is conveyor - send speed to render for right texture scrolling
state->framerate = pEntity->pev->speed;
}
else if( state->ed_type == ED_BEAM )
{
state->gaitsequence = pEntity->pev->frags; // beam type
// translate StartBeamEntity
if( pEntity->pev->owner )
state->owner = ENTINDEX( pEntity->pev->owner );
else state->owner = NULLENT_INDEX;
}
return 1;
}
/*
=================
UpdateClientData
Data sent to current client only
engine sets cd to 0 before calling.
=================
*/
void UpdateClientData( const edict_t *ent, int sendweapons, clientdata_t *cd )
{
cd->flags = ent->v.flags;
cd->health = ent->v.health;
cd->viewmodel = MODEL_INDEX( STRING( ent->v.viewmodel ) );
cd->waterlevel = ent->v.waterlevel;
cd->watertype = ent->v.watertype;
cd->weapons = ent->v.weapons;
// Vectors
cd->origin = ent->v.origin;
cd->velocity = ent->v.velocity;
cd->view_ofs = ent->v.view_ofs;
cd->punchangle = ent->v.punchangle;
cd->bInDuck = ent->v.bInDuck;
cd->flTimeStepSound = ent->v.flTimeStepSound;
cd->flDuckTime = ent->v.flDuckTime;
cd->flSwimTime = ent->v.flSwimTime;
cd->waterjumptime = ent->v.teleport_time;
strcpy( cd->physinfo, ENGINE_GETPHYSINFO( ent ) );
cd->maxspeed = ent->v.maxspeed;
cd->fov = ent->v.fov;
cd->weaponanim = ent->v.weaponanim;
cd->pushmsec = ent->v.pushmsec;
}
void CreateBaseline( entity_state_t *baseline, edict_t *entity, int playermodelindex )
{
// always set nodelta's for baseline
baseline->ed_flags |= ESF_NODELTA;
baseline->origin = entity->v.origin;
baseline->angles = entity->v.angles;
baseline->frame = entity->v.frame;
baseline->skin = (short)entity->v.skin;
// render information
baseline->rendermode = (byte)entity->v.rendermode;
baseline->renderamt = (byte)entity->v.renderamt;
baseline->rendercolor.x = (byte)entity->v.rendercolor.x;
baseline->rendercolor.y = (byte)entity->v.rendercolor.y;
baseline->rendercolor.z = (byte)entity->v.rendercolor.z;
baseline->renderfx = (byte)entity->v.renderfx;
baseline->mins = entity->v.mins;
baseline->maxs = entity->v.maxs;
if( baseline->ed_type == ED_CLIENT )
{
baseline->colormap = entity->serialnumber;
baseline->modelindex = playermodelindex; // "model" field from userinfo
baseline->friction = 1.0;
baseline->movetype = MOVETYPE_WALK;
baseline->scale = entity->v.scale;
baseline->solid = SOLID_SLIDEBOX;
baseline->framerate = 1.0;
baseline->gravity = 1.0;
}
else
{
baseline->colormap = 0;
baseline->modelindex = entity->v.modelindex;
baseline->movetype = (movetype_t)entity->v.movetype;
baseline->scale = entity->v.scale;
baseline->solid = (solid_t)entity->v.solid;
baseline->framerate = entity->v.framerate;
baseline->gravity = entity->v.gravity;
}
}
typedef struct
{
char name[32];
@ -1874,6 +1956,8 @@ void Custom_Encode( struct delta_s *pFields, const unsigned char *from, const un
RegisterEncoders
Allows game .dll to override network encoding of certain types of entities and tweak values, etc.
disabled for now, wait for Xash 0.8
=================
*/
void RegisterEncoders( void )
@ -1883,6 +1967,21 @@ void RegisterEncoders( void )
DELTA_ADDENCODER( "Player_Encode", Player_Encode );
}
/*
=================
GetWeaponData
Part of weapon predict system
disabled for now, wait for Xash 0.8
=================
*/
int GetWeaponData( struct edict_s *player, weapon_data_t *info )
{
memset( info, 0, 32 * sizeof( weapon_data_t ));
return 1;
}
//=======================================================================
// Link User Messages - register new client messages here
//=======================================================================

View File

@ -29,7 +29,6 @@ extern void ClientUserInfoChanged( edict_t *pEntity, char *infobuffer );
extern void ServerActivate( edict_t *pEdictList, int edictCount, int clientMax );
extern void ServerDeactivate( void );
extern void StartFrame( void );
extern void EndFrame( void );
extern void RegisterEncoders( void );
extern void PlayerPostThink( edict_t *pEntity );
extern void PlayerPreThink( edict_t *pEntity );
@ -43,7 +42,10 @@ extern void SpectatorDisconnect ( edict_t *pEntity );
extern void SpectatorThink ( edict_t *pEntity );
extern void SetupVisibility( edict_t *pViewEntity, edict_t *pClient, byte **pvs, byte **pas, int portal );
extern int AddToFullPack( edict_t *pView, edict_t *pHost, edict_t *pEdict, int hostflags, byte *pSet );
extern void UpdateClientData( const struct edict_s *ent, int sendweapons, struct clientdata_s *cd );
extern int AddToFullPack( entity_state_t *state, edict_t *pView, edict_t *pHost, edict_t *pEdict, int hostflags, byte *pSet );
extern void CreateBaseline( entity_state_t *baseline, edict_t *entity, int playermodelindex );
extern int GetWeaponData( edict_t *player, struct weapon_data_s *info );
extern void CmdStart( const edict_t *player, const usercmd_t *cmd, unsigned int random_seed );
extern void CmdEnd ( const edict_t *player );

View File

@ -70,8 +70,8 @@ static DLL_FUNCTIONS gFunctionTable =
DispatchCreate, // pfnCreate
BuildLevelList, // pfnParmsChangeLevel
GetGameDescription, // pfnGetGameDescription - returns string describing current .dll game.
GetEntvarsDescirption, // pfnGetEntvarsDescirption
GetGameDescription, //pfnGetGameDescription Returns string describing current .dll game.
DispatchFrame, // pfnPhysicsEntity
SpectatorConnect, // pfnSpectatorConnect
SpectatorDisconnect, // pfnSpectatorDisconnect
@ -83,14 +83,14 @@ static DLL_FUNCTIONS gFunctionTable =
PM_Init, // pfnPM_Init
PM_FindTextureType, // pfnPM_FindTextureType
SetupVisibility, // pfnSetupVisibility
DispatchFrame, // pfnPhysicsEntity
SetupVisibility, // pfnSetupVisibility
UpdateClientData, // pfnUpdateClientData
AddToFullPack, // pfnAddtoFullPack
EndFrame, // pfnEndFrame
CreateBaseline, // fpnCreateBaseline
RegisterEncoders, // pfnRegisterEncoders Callbacks for network encoding
UpdateEntityState, // pfnUpdateEntityState
GetWeaponData, // pfnGetWeaponData
CmdStart, // pfnCmdStart
CmdEnd, // pfnCmdEnd

View File

@ -41,9 +41,7 @@ extern void DispatchBlocked( edict_t *pentBlocked, edict_t *pentOther );
extern void DispatchSave( edict_t *pent, SAVERESTOREDATA *pSaveData );
extern int DispatchRestore( edict_t *pent, SAVERESTOREDATA *pSaveData, int globalEntity );
extern void DispatchObjectCollsionBox( edict_t *pent );
extern TYPEDESCRIPTION *GetEntvarsDescirption( int number );
extern int ServerClassifyEdict( edict_t *pentToClassify );
extern void UpdateEntityState( struct entity_state_s *to, edict_t *from, int baseline );
extern void SaveWriteFields( SAVERESTOREDATA *pSaveData, const char *pname, void *pBaseData, TYPEDESCRIPTION *pFields, int fieldCount );
extern void SaveReadFields( SAVERESTOREDATA *pSaveData, const char *pname, void *pBaseData, TYPEDESCRIPTION *pFields, int fieldCount );
extern void SaveGlobalState( SAVERESTOREDATA *pSaveData );

View File

@ -70,8 +70,8 @@ TYPEDESCRIPTION gEntvarsDescription[] =
DEFINE_ENTITY_FIELD( sequence, FIELD_INTEGER ),
DEFINE_ENTITY_FIELD( animtime, FIELD_TIME ),
DEFINE_ENTITY_FIELD( framerate, FIELD_FLOAT ),
DEFINE_ENTITY_FIELD( controller, FIELD_INTEGER ),
DEFINE_ENTITY_FIELD( blending, FIELD_INTEGER ),
DEFINE_ENTITY_FIELD_ARRAY( controller, FIELD_CHARACTER, 16 ),
DEFINE_ENTITY_FIELD_ARRAY( blending, FIELD_CHARACTER, 16 ),
DEFINE_ENTITY_FIELD( rendermode, FIELD_INTEGER ),
DEFINE_ENTITY_FIELD( renderamt, FIELD_FLOAT ),
@ -129,14 +129,6 @@ TYPEDESCRIPTION gEntvarsDescription[] =
DEFINE_ENTITY_FIELD( radsuit_finished, FIELD_TIME ),
};
// used by engine for FindEntityByString and some other things
TYPEDESCRIPTION *GetEntvarsDescirption( int number )
{
if( number < 0 && number >= ENTVARS_COUNT )
return NULL;
return &gEntvarsDescription[number];
}
// --------------------------------------------------------------
//
// CSave

View File

@ -571,17 +571,17 @@ extern DLL_GLOBAL int g_Language;
#define PUSH_BLOCK_ONLY_X 1
#define PUSH_BLOCK_ONLY_Y 2
#define VEC_HULL_MIN Vector(-16, -16, -36)
#define VEC_HULL_MAX Vector( 16, 16, 36)
#define VEC_HULL_MIN gpGlobals->hullmins[0]
#define VEC_HULL_MAX gpGlobals->hullmaxs[0]
#define VEC_HUMAN_HULL_MIN Vector( -16, -16, 0 )
#define VEC_HUMAN_HULL_MAX Vector( 16, 16, 72 )
#define VEC_HUMAN_HULL_DUCK Vector( 16, 16, 36 )
#define VEC_VIEW Vector( 0, 0, 28 )
#define VEC_VIEW Vector( 0, 0, gpGlobals->viewheight[0] )
#define VEC_DUCK_HULL_MIN Vector(-16, -16, -18 )
#define VEC_DUCK_HULL_MAX Vector( 16, 16, 18)
#define VEC_DUCK_VIEW Vector( 0, 0, 12 )
#define VEC_DUCK_HULL_MIN gpGlobals->hullmins[1]
#define VEC_DUCK_HULL_MAX gpGlobals->hullmaxs[1]
#define VEC_DUCK_VIEW Vector( 0, 0, gpGlobals->viewheight[1] )
// triggers
#define SF_TRIGGER_ALLOWMONSTERS 1// monsters allowed to fire this trigger

View File

@ -1326,8 +1326,6 @@ void CBasePlayer::PlayerDeathThink(void)
//ALERT(at_console, "Respawn\n");
respawn(pev, !(m_afPhysicsFlags & PFLAG_OBSERVER) ); // don't copy a corpse if we're in deathcam.
pev->view_ofs.z = m_flViewHeight; // restore viewheight on respawn
DontThink();
}
@ -2721,6 +2719,8 @@ void CBasePlayer::Spawn( void )
pev->renderfx = 0;
pev->rendercolor = g_vecZero;
pev->v_angle.z = 0; // cut off any camera rolling
pev->view_ofs = VEC_VIEW;
m_bitsHUDDamage = -1;
m_bitsDamageType = 0;
m_afPhysicsFlags = 0;

View File

@ -154,7 +154,6 @@ public:
float m_fDeadTime; // the time at which the player died (used in PlayerDeathThink())
float m_fAirFinished; // moved here from progdefs.h
float m_fPainFinished; // moved here from progdefs.h
float m_flViewHeight; // keep value from view_ofs.z that engine sets it when player first entering in multiplayer
BOOL m_fNoPlayerSound; // a debugging feature. Player makes no sound if this is true.
BOOL m_fLongJump; // does this player have the longjump module?

View File

@ -43,6 +43,7 @@ vsound_exp_t DLLEXPORT *CreateAPI( stdlib_api_t *input, vsound_imp_t *engfuncs )
snd.StartStreaming = S_StartStreaming;
snd.StopStreaming = S_StopStreaming;
snd.BeginFrame = S_BeginFrame;
snd.RenderFrame = S_Update;
snd.StopSound = S_StopSound;
snd.StopAllSounds = S_StopAllSounds;

View File

@ -683,13 +683,12 @@ S_StartLocalSound
menu sound
=================
*/
bool S_StartLocalSound( const char *name, float volume, int pitch, const float *origin )
void S_StartLocalSound( const char *name )
{
sound_t sfxHandle;
sfxHandle = S_RegisterSound( name );
S_StartSound( origin, al_state.clientnum, CHAN_AUTO, sfxHandle, volume, ATTN_NONE, pitch, SND_STOP_LOOPING );
return true;
S_StartSound( vec3_origin, al_state.clientnum, CHAN_AUTO, sfxHandle, VOL_NORM, ATTN_NONE, PITCH_NORM, SND_STOP_LOOPING );
}
/*
@ -858,6 +857,17 @@ void S_Update( ref_params_t *fd )
S_CheckForErrors();
}
/*
=================
S_BeginFrame
Starts a new rendering frame
=================
*/
void S_BeginFrame( void )
{
}
/*
=================
S_Activate
@ -883,10 +893,10 @@ void S_PlaySound_f( void )
{
if( Cmd_Argc() == 1 )
{
Msg( "Usage: playsound <soundfile>\n" );
Msg( "Usage: play <soundfile>\n" );
return;
}
S_StartLocalSound( Cmd_Argv( 1 ), 1.0f, PITCH_NORM, NULL );
S_StartLocalSound( Cmd_Argv( 1 ));
}
/*
@ -956,7 +966,7 @@ bool S_Init( void *hInst )
s_dopplerVelocity = Cvar_Get("s_dopplervelocity", "10976.0", CVAR_ARCHIVE, "doppler effect maxvelocity" );
s_room_type = Cvar_Get( "room_type", "0", 0, "dsp room type" );
Cmd_AddCommand( "playsound", S_PlaySound_f, "playing a specified sound file" );
Cmd_AddCommand( "play", S_PlaySound_f, "playing a specified sound file" );
Cmd_AddCommand( "stopsound", S_StopSound_f, "stop all sounds" );
Cmd_AddCommand( "music", S_Music_f, "starting a background track" );
Cmd_AddCommand( "s_info", S_SoundInfo_f, "print sound system information" );
@ -994,7 +1004,7 @@ S_Shutdown
void S_Shutdown( void )
{
Cmd_RemoveCommand( "playsound" );
Cmd_RemoveCommand( "play" );
Cmd_RemoveCommand( "stopsound" );
Cmd_RemoveCommand( "music" );
Cmd_RemoveCommand( "s_info" );

View File

@ -153,6 +153,7 @@ void S_Shutdown( void );
void S_Activate( bool active );
void S_SoundList_f( void );
bool S_CheckForErrors( void );
void S_BeginFrame( void );
void S_Update( ref_params_t *fd );
void S_StartSound( const vec3_t pos, int ent, int chan, sound_t sfx, float vol, float attn, int pitch, int flags );
void S_StaticSound( const vec3_t pos, int ent, int chan, sound_t handle, float fvol, float attn, int pitch, int flags );
@ -161,7 +162,7 @@ void S_StartBackgroundTrack( const char *intro, const char *loop );
channel_t *SND_PickStaticChannel( int entnum, sfx_t *sfx );
channel_t *SND_PickDynamicChannel( int entnum, int channel, sfx_t *sfx );
void S_FadeClientVolume( float fadePercent, float fadeOutSeconds, float holdTime, float fadeInSeconds );
int S_StartLocalSound( const char *name, float volume, int pitch, const float *org );
void S_StartLocalSound( const char *name );
sfx_t *S_GetSfxByHandle( sound_t handle );
void S_StopSound( int entnum, int channel, const char *soundname );
void S_StreamBackgroundTrack( void );

View File

@ -1233,6 +1233,8 @@ void SX_RoomFX( int endtime, int fFilter, int fTimefx )
int sampleCount;
int roomType;
if( !si.IsInGame()) return;
// return right away if fx processing is turned off
if( sxroom_off->value != 0.0f )
return;

View File

@ -42,6 +42,7 @@ vsound_exp_t DLLEXPORT *CreateAPI( stdlib_api_t *input, vsound_imp_t *engfuncs )
snd.StartStreaming = S_StartStreaming;
snd.StopStreaming = S_StopStreaming;
snd.BeginFrame = S_BeginFrame;
snd.RenderFrame = S_RenderFrame;
snd.StopSound = S_StopSound;
snd.StopAllSounds = S_StopAllSounds;

View File

@ -198,11 +198,12 @@ wavdata_t *S_LoadSound( sfx_t *sfx )
wavdata_t *sc;
if( !sfx ) return NULL;
if( sfx->name[0] == '*' ) return NULL;
if( sfx->cache ) return sfx->cache; // see if still in memory
// load it from disk
sc = FS_LoadSound( sfx->name, NULL, 0 );
if( sfx->name[0] == '*' )
sc = FS_LoadSound( sfx->name + 1, NULL, 0 );
else sc = FS_LoadSound( sfx->name, NULL, 0 );
if( !sc ) sc = S_CreateDefaultSound();

View File

@ -6,6 +6,8 @@
#include "sound.h"
#include "const.h"
#define SND_CLIP_DISTANCE 1000.0f
dma_t dma;
byte *sndpool;
static soundfade_t soundfade;
@ -460,7 +462,8 @@ void S_StartSound( const vec3_t pos, int ent, int chan, sound_t handle, float fv
VectorCopy( pos, target_chan->origin );
target_chan->staticsound = ( ent == 0 ) ? true : false;
target_chan->use_loop = (flags & SND_STOP_LOOPING) ? false : true;
target_chan->dist_mult = (attn / 1000.0f);
target_chan->localsound = (flags & SND_LOCALSOUND) ? true : false;
target_chan->dist_mult = (attn / SND_CLIP_DISTANCE);
target_chan->master_vol = vol;
target_chan->entnum = ent;
target_chan->entchannel = chan;
@ -618,8 +621,9 @@ void S_StaticSound( const vec3_t pos, int ent, int chan, sound_t handle, float f
// never update positions if source entity is 0
ch->staticsound = ( ent == 0 ) ? true : false;
ch->use_loop = (flags & SND_STOP_LOOPING) ? false : true;
ch->localsound = (flags & SND_LOCALSOUND) ? true : false;
ch->master_vol = vol;
ch->dist_mult = (attn / 1000.0f);
ch->dist_mult = (attn / SND_CLIP_DISTANCE);
ch->basePitch = pitch;
ch->entnum = ent;
ch->entchannel = chan;
@ -635,14 +639,13 @@ void S_StaticSound( const vec3_t pos, int ent, int chan, sound_t handle, float f
S_StartLocalSound
==================
*/
bool S_StartLocalSound( const char *name, float volume, int pitch, const float *org )
void S_StartLocalSound( const char *name )
{
sound_t sfxHandle;
int flags = (SND_LOCALSOUND|SND_STOP_LOOPING);
sfxHandle = S_RegisterSound( name );
S_StartSound( org, s_listener.entnum, CHAN_AUTO, sfxHandle, volume, ATTN_NONE, pitch, SND_STOP_LOOPING );
return true;
S_StartSound( NULL, s_listener.entnum, CHAN_AUTO, sfxHandle, VOL_NORM, ATTN_NONE, PITCH_NORM, flags );
}
/*
@ -674,20 +677,10 @@ stop all sounds for entity on a channel.
*/
void S_StopSound( int entnum, int channel, const char *soundname )
{
int i;
sfx_t *sfx;
for( i = 0; i < total_channels; i++ )
{
channel_t *ch = &channels[i];
if( !ch->sfx ) continue; // already freed
if( ch->entnum == entnum && ch->entchannel == channel )
{
if( soundname && com.strcmp( ch->sfx->name, soundname ))
continue;
S_FreeChannel( ch );
}
}
sfx = S_FindName( soundname, NULL );
S_AlterChannel( entnum, channel, sfx, 0, 0, SND_STOP );
}
/*
@ -744,6 +737,18 @@ void S_UpdateChannels( void )
SNDDMA_Submit();
}
/*
=================
S_BeginFrame
Starts a new rendering frame
=================
*/
void S_BeginFrame( void )
{
S_UpdateChannels ();
}
/*
============
S_RenderFrame
@ -756,33 +761,20 @@ void S_RenderFrame( ref_params_t *fd )
int i, total;
channel_t *ch;
if( !fd ) return;
if( !fd ) return; // too early
// if the loading plaque is up, clear everything
// out to make sure we aren't looping a dirty
// dma buffer while loading
if( fd->paused && !s_listener.paused )
{
S_ClearBuffer();
}
// update any client side sound fade
S_UpdateSoundFade();
if( s_listener.ingame ^ si.IsInGame())
{
// state changed, rebuild scaletable
s_volume->modified = true;
}
s_listener.entnum = fd->viewentity; // can be camera entity too
s_listener.frametime = fd->frametime;
s_listener.waterlevel = fd->waterlevel;
s_listener.ingame = si.IsInGame();
s_listener.paused = fd->paused;
if( s_listener.paused ) return;
VectorCopy( fd->simorg, s_listener.origin );
VectorCopy( fd->vieworg, s_listener.vieworg );
VectorCopy( fd->simvel, s_listener.velocity );
@ -835,7 +827,7 @@ void S_Play_f( void )
Msg( "Usage: playsound <soundfile>\n" );
return;
}
S_StartLocalSound( Cmd_Argv( 1 ), 1.0f, PITCH_NORM, NULL );
S_StartLocalSound( Cmd_Argv( 1 ));
}
/*
@ -892,9 +884,9 @@ bool S_Init( void *hInst )
s_volume = Cvar_Get( "volume", "0.7", CVAR_ARCHIVE, "sound volume" );
s_suitvolume = Cvar_Get( "suitvolume", "0.5", CVAR_ARCHIVE, "HEV suit volume" );
s_musicvolume = Cvar_Get("musicvolume", "1.0", CVAR_ARCHIVE, "background music volume" );
s_musicvolume = Cvar_Get( "musicvolume", "1.0", CVAR_ARCHIVE, "background music volume" );
s_khz = Cvar_Get( "s_khz", "22", CVAR_LATCH_AUDIO|CVAR_ARCHIVE, "output sound frequency" );
s_mixahead = Cvar_Get( "s_mixahead", "0.2", CVAR_ARCHIVE, "how much sound to mix ahead of time" );
s_mixahead = Cvar_Get( "s_mixahead", "0.1", 0, "how much sound to mix ahead of time" );
s_show = Cvar_Get( "s_show", "0", 0, "show playing sounds" );
s_primary = Cvar_Get( "s_primary", "0", CVAR_LATCH_AUDIO|CVAR_ARCHIVE, "use direct primary buffer" );
s_check_errors = Cvar_Get( "s_check_errors", "1", CVAR_ARCHIVE, "ignore audio engine errors" );
@ -930,7 +922,7 @@ bool S_Init( void *hInst )
// =======================================================================
void S_Shutdown( void )
{
Cmd_RemoveCommand( "playsound" );
Cmd_RemoveCommand( "play" );
Cmd_RemoveCommand( "stopsound" );
Cmd_RemoveCommand( "music" );
Cmd_RemoveCommand( "soundlist" );

View File

@ -5,7 +5,7 @@
#include "sound.h"
#define PAINTBUFFER_SIZE 2048
#define PAINTBUFFER_SIZE 512
portable_samplepair_t paintbuffer[PAINTBUFFER_SIZE];
int snd_scaletable[32][256];
int *snd_p, snd_linear_count, snd_vol;
@ -194,6 +194,10 @@ void S_MixAllChannels( int endtime, int end )
if( !ch->leftvol && !ch->rightvol )
continue;
// only local sounds can be playing in menus or on pause
if(( s_listener.paused || !s_listener.ingame ) && !ch->localsound )
continue;
sc = S_LoadSound( ch->sfx );
if( !sc ) continue;
@ -219,7 +223,7 @@ void S_MixAllChannels( int endtime, int end )
if( si.GetClientEdict( ch->entnum ) && ( ch->entchannel == CHAN_VOICE ))
{
// UNDONE: recode this as a member function of CAudioMixer
SND_MoveMouth8( ch, ch->sfx->cache, count );
SND_MoveMouth8( ch, sc, count );
}
// if at end of loop, restart
@ -227,8 +231,8 @@ void S_MixAllChannels( int endtime, int end )
{
if( ch->isSentence )
{
VOX_LoadNextWord( ch );
if( !ch->sfx ) break; // sentence is finished
sc = VOX_LoadNextWord( ch );
if( !sc ) break; // sentence is finished
}
else if( sc->loopStart >= 0 && ch->use_loop )
{
@ -238,7 +242,7 @@ void S_MixAllChannels( int endtime, int end )
else
{
// channel just stopped
ch->sfx = NULL;
S_FreeChannel( ch );
break;
}
}

View File

@ -369,7 +369,7 @@ void VOX_LoadFirstWord( channel_t *pchan, voxword_t *pwords )
VOX_LoadWord( pchan );
}
void VOX_LoadNextWord( channel_t *pchan )
wavdata_t *VOX_LoadNextWord( channel_t *pchan )
{
pchan->wordIndex++;
VOX_LoadWord( pchan );
@ -380,8 +380,11 @@ void VOX_LoadNextWord( channel_t *pchan )
pchan->sfx = pchan->words[pchan->wordIndex].sfx;
pchan->pos = pchan->currentWord.sample;
pchan->end = paintedtime + pchan->currentWord.forcedEndSample;
return pchan->currentWord.pData;
}
else S_FreeChannel( pchan ); // channel stopped
S_FreeChannel( pchan ); // channel stopped
return NULL;
}
// link all sounds in sentence, start playing first word.

View File

@ -88,6 +88,7 @@ typedef struct
float pitch; // real-time pitch after any modulation or shift by dynamic data
bool use_loop; // don't loop default and local sounds
bool staticsound; // use origin instead of fetching entnum's origin
bool localsound; // it's a local menu sound (not looped, not paused)
// sentence mixer
int wordIndex;
@ -179,6 +180,8 @@ void S_PrintDeviceName( void );
// s_main.c
//
void S_FreeChannel( channel_t *ch );
void S_BeginFrame( void );
// s_load.c
bool S_TestSoundChar( const char *pch, char c );
@ -202,7 +205,7 @@ void S_StaticSound( const vec3_t pos, int ent, int chan, sound_t handle, float f
channel_t *SND_PickDynamicChannel( int entnum, int channel, sfx_t *sfx );
channel_t *SND_PickStaticChannel( int entnum, sfx_t *sfx );
void S_FadeClientVolume( float fadePercent, float fadeOutSeconds, float holdTime, float fadeInSeconds );
int S_StartLocalSound( const char *name, float volume, int pitch, const float *org );
void S_StartLocalSound( const char *name );
sfx_t *S_GetSfxByHandle( sound_t handle );
void S_StopSound( int entnum, int channel, const char *soundname );
void S_RenderFrame( ref_params_t *fd );
@ -240,7 +243,7 @@ void VOX_Init( void );
void VOX_Shutdown( void );
void VOX_SetChanVol( channel_t *ch );
void VOX_LoadSound( channel_t *pchan, const char *psz );
void VOX_LoadNextWord( channel_t *pchan );
wavdata_t *VOX_LoadNextWord( channel_t *pchan );
void S_BeginRegistration( void );

View File

@ -68,7 +68,7 @@ static DLL_FUNCTIONS gFunctionTable =
BuildLevelList, // pfnParmsChangeLevel
GetGameDescription, // pfnGetGameDescription Returns string describing current .dll game.
GetEntvarsDescirption, // pfnGetEntvarsDescirption engine uses this to lookup entvars table
DispatchFrame, // pfnPhysicsEntity
SpectatorConnect, // pfnSpectatorConnect Called when spectator joins server
SpectatorDisconnect, // pfnSpectatorDisconnect Called when spectator leaves the server
@ -81,13 +81,13 @@ static DLL_FUNCTIONS gFunctionTable =
PM_FindTextureType, // pfnPM_FindTextureType
SetupVisibility, // pfnSetupVisibility
DispatchFrame, // pfnPhysicsEntity
UpdateClientData, // pfnUpdateClientData
AddToFullPack, // pfnAddtoFullPack
EndFrame, // pfnEndFrame
CreateBaseline, // fpnCreateBaseline
RegisterEncoders, // pfnRegisterEncoders Callbacks for network encoding
UpdateEntityState, // pfnUpdateEntityState
GetWeaponData, // pfnGetWeaponData
CmdStart, // pfnCmdStart
CmdEnd, // pfnCmdEnd

View File

@ -89,9 +89,7 @@ extern void SaveReadFields( SAVERESTOREDATA *pSaveData, const char *pname, void
extern void SaveGlobalState( SAVERESTOREDATA *pSaveData );
extern void RestoreGlobalState( SAVERESTOREDATA *pSaveData );
extern void ResetGlobalState( void );
extern TYPEDESCRIPTION *GetEntvarsDescirption( int number );
extern int ServerClassifyEdict( edict_t *pentToClassify );
extern void UpdateEntityState( struct entity_state_s *to, edict_t *from, int baseline );
extern void OnFreeEntPrivateData( edict_s *pEdict );
extern int ShouldCollide( edict_t *pentTouched, edict_t *pentOther );

View File

@ -36,6 +36,7 @@
#include "gamerules.h"
#include "game.h"
#include "weapons.h"
#include "weaponinfo.h"
#include "usercmd.h"
#include "movewith.h"
@ -1092,130 +1093,6 @@ int ServerClassifyEdict( edict_t *pentToClassify )
return m_iNewClass;
}
void UpdateEntityState( entity_state_t *to, edict_t *from, int baseline )
{
int i;
if( !to || !from ) return;
CBaseEntity *pNet;
pNet = CBaseEntity::Instance( from );
if( !pNet ) return;
// setup some special edict flags (engine will clearing them after the current frame)
if( to->modelindex != pNet->pev->modelindex )
to->ed_flags |= ESF_NODELTA;
// always set nodelta's for baseline
if( baseline ) to->ed_flags |= ESF_NODELTA;
// copy progs values to state
to->solid = (solid_t)pNet->pev->solid;
to->origin = pNet->pev->origin;
to->angles = pNet->pev->angles;
to->modelindex = pNet->pev->modelindex;
to->health = pNet->pev->health;
to->skin = pNet->pev->skin; // studio model skin
to->body = pNet->pev->body; // studio model submodel
to->effects = pNet->pev->effects; // shared client and render flags
to->renderfx = pNet->pev->renderfx; // renderer flags
to->rendermode = pNet->pev->rendermode; // rendering mode
to->renderamt = pNet->pev->renderamt; // alpha value
to->animtime = (int)(1000.0 * pNet->pev->animtime) * 0.001; // sequence time
to->localtime = (int)(1000.0 * pNet->pev->ltime) * 0.001; // movement time
to->scale = pNet->pev->scale; // shared client and render flags
to->movetype = (movetype_t)pNet->pev->movetype;
to->frame = pNet->pev->frame; // any model current frame
to->framerate = pNet->pev->framerate;
to->mins = pNet->pev->mins;
to->maxs = pNet->pev->maxs;
to->flags = pNet->pev->flags;
to->rendercolor = pNet->pev->rendercolor;
to->oldorigin = pNet->pev->oldorigin;
to->colormap = pNet->pev->colormap; // attachments
if( pNet->pev->groundentity )
to->groundent = ENTINDEX( pNet->pev->groundentity );
else to->groundent = NULLENT_INDEX;
// translate attached entity
if( pNet->pev->aiment )
to->aiment = ENTINDEX( pNet->pev->aiment );
else to->aiment = NULLENT_INDEX;
// studio model sequence
if( pNet->pev->sequence != -1 ) to->sequence = pNet->pev->sequence;
for( i = 0; i < 16; i++ )
{
// copy blendings and bone ctrlrs
to->blending[i] = pNet->pev->blending[i];
to->controller[i] = pNet->pev->controller[i];
}
if( to->ed_type == ED_CLIENT )
{
if( pNet->pev->teleport_time )
{
to->ed_flags |= ESF_NO_PREDICTION;
to->ed_flags |= ESF_NODELTA;
pNet->pev->teleport_time = 0.0f;
}
if( pNet->pev->viewmodel )
to->viewmodel = MODEL_INDEX( STRING( pNet->pev->viewmodel ));
else to->viewmodel = 0;
if( pNet->pev->aiment )
to->aiment = ENTINDEX( pNet->pev->aiment );
else to->aiment = NULLENT_INDEX;
to->viewoffset = pNet->pev->view_ofs;
to->viewangles = pNet->pev->v_angle;
to->idealpitch = pNet->pev->idealpitch;
to->punch_angles = pNet->pev->punchangle;
to->velocity = pNet->pev->velocity;
to->basevelocity = pNet->pev->clbasevelocity;
to->iStepLeft = pNet->pev->iStepLeft;
to->flFallVelocity = pNet->pev->flFallVelocity;
// playermodel sequence, that will be playing on a client
if( pNet->pev->gaitsequence != -1 )
to->gaitsequence = pNet->pev->gaitsequence;
if( pNet->pev->weaponmodel != iStringNull )
to->weaponmodel = MODEL_INDEX( STRING( pNet->pev->weaponmodel ));
else to->weaponmodel = 0;
to->weapons = pNet->pev->weapons;
to->maxspeed = pNet->pev->maxspeed;
// clamp fov
if( pNet->pev->fov < 0.0 ) pNet->pev->fov = 0.0;
if( pNet->pev->fov > 160 ) pNet->pev->fov = 160;
to->fov = pNet->pev->fov;
}
else if( to->ed_type == ED_AMBIENT )
{
}
else if( to->ed_type == ED_MOVER || to->ed_type == ED_BSPBRUSH || to->ed_type == ED_PORTAL )
{
to->body = DirToBits( pNet->pev->movedir );
to->velocity = pNet->pev->velocity;
// this is conveyor - send speed to render for right texture scrolling
to->framerate = pNet->pev->speed;
}
else if( to->ed_type == ED_BEAM )
{
to->gaitsequence = pNet->pev->frags; // beam type
// translate StartBeamEntity
if( pNet->pev->owner )
to->owner = ENTINDEX( pNet->pev->owner );
else to->owner = NULLENT_INDEX;
}
}
////////////////////////////////////////////////////////
// PAS and PVS routines for client messaging
//
@ -1315,13 +1192,13 @@ player is 1 if the ent/e is a player and 0 otherwise
pSet is either the PAS or PVS that we previous set up. We can use it to ask the engine to filter the entity against the PAS or PVS.
we could also use the pas/ pvs that we set in SetupVisibility, if we wanted to. Caching the value is valid in that case, but still only for the current frame
*/
int AddToFullPack( edict_t *pView, edict_t *pHost, edict_t *pEdict, int hostflags, byte *pSet )
int AddToFullPack( entity_state_t *state, edict_t *pView, edict_t *pHost, edict_t *pEdict, int hostflags, byte *pSet )
{
if( FNullEnt( pEdict )) return 0; // never adding invalid entities
CBaseEntity *pEntity;
Vector delta; // for ambient sounds
// completely ignore dormant entity
if( pEdict->v.flags & FL_DORMANT )
return 0;
if( FNullEnt( pEdict ))
return 0; // never adding invalid entities
if( FNullEnt( pView )) pView = pHost; // pfnCustomView not set
@ -1331,6 +1208,18 @@ int AddToFullPack( edict_t *pView, edict_t *pHost, edict_t *pEdict, int hostflag
if( pViewEntity && pViewEntity->m_iClassType == ED_PORTAL )
bIsPortalPass = TRUE; // view from portal camera
pEntity = (CBaseEntity *)CBaseEntity::Instance( pEdict );
if( !pEntity ) return 0;
// NOTE: always add himslef to list
if( !bIsPortalPass && ( pHost == pEdict ))
goto addEntity;
// completely ignore dormant entity
if( pEdict->v.flags & FL_DORMANT )
return 0;
// don't send spectators to other players
if(( pEdict->v.flags & FL_SPECTATOR ) && ( pEdict != pHost ))
@ -1338,15 +1227,11 @@ int AddToFullPack( edict_t *pView, edict_t *pHost, edict_t *pEdict, int hostflag
return 0;
}
CBaseEntity *pEntity = (CBaseEntity *)CBaseEntity::Instance( pEdict );
if( !pEntity ) return 0;
// quick reject by type
switch( pEntity->m_iClassType )
{
case ED_SKYPORTAL:
return 1; // no additional check requires
goto addEntity; // no additional check requires
case ED_BEAM:
case ED_MOVER:
case ED_NORMAL:
@ -1359,8 +1244,6 @@ int AddToFullPack( edict_t *pView, edict_t *pHost, edict_t *pEdict, int hostflag
default: return 0; // skipped
}
Vector delta = g_vecZero; // for ambient sounds
// check for ambients distance
if( pEntity->m_iClassType == ED_AMBIENT )
{
@ -1374,6 +1257,7 @@ int AddToFullPack( edict_t *pView, edict_t *pHost, edict_t *pEdict, int hostflag
// precalc delta distance for sounds
delta = pView->v.origin - entorigin;
}
else delta = g_vecZero;
// check visibility
if ( !ENGINE_CHECK_PVS( pEdict, pSet ))
@ -1431,9 +1315,181 @@ int AddToFullPack( edict_t *pView, edict_t *pHost, edict_t *pEdict, int hostflag
}
UTIL_UnsetGroupTrace();
}
addEntity:
// setup some special edict flags (engine will clearing them after the current frame)
if( state->modelindex != pEntity->pev->modelindex || ( pEntity->pev->effects & EF_NOINTERP ))
state->ed_flags |= ESF_NODELTA;
// always keep an actual
state->number = pEdict->serialnumber;
// copy progs values to state
state->solid = (solid_t)pEntity->pev->solid;
state->origin = pEntity->pev->origin;
state->angles = pEntity->pev->angles;
state->modelindex = pEntity->pev->modelindex;
state->health = pEntity->pev->health;
state->skin = pEntity->pev->skin; // studio model skin
state->body = pEntity->pev->body; // studio model submodel
state->effects = pEntity->pev->effects; // shared client and render flags
state->renderfx = pEntity->pev->renderfx; // renderer flags
state->rendermode = pEntity->pev->rendermode; // rendering mode
state->renderamt = pEntity->pev->renderamt; // alpha value
state->animtime = (int)(1000.0 * pEntity->pev->animtime) * 0.001; // sequence time
state->localtime = (int)(1000.0 * pEntity->pev->ltime) * 0.001; // movement time
state->scale = pEntity->pev->scale; // shared client and render flags
state->movetype = (movetype_t)pEntity->pev->movetype;
state->frame = pEntity->pev->frame; // any model current frame
state->framerate = pEntity->pev->framerate;
state->mins = pEntity->pev->mins;
state->maxs = pEntity->pev->maxs;
state->flags = pEntity->pev->flags;
state->rendercolor = pEntity->pev->rendercolor;
state->oldorigin = pEntity->pev->oldorigin;
state->colormap = pEntity->pev->colormap; // attachments
if( pEntity->pev->groundentity )
state->groundent = ENTINDEX( pEntity->pev->groundentity );
else state->groundent = NULLENT_INDEX;
// translate attached entity
if( pEntity->pev->aiment )
state->aiment = ENTINDEX( pEntity->pev->aiment );
else state->aiment = NULLENT_INDEX;
// studio model sequence
if( pEntity->pev->sequence != -1 )
state->sequence = pEntity->pev->sequence;
for( int i = 0; i < 16; i++ )
{
// copy blendings and bone ctrlrs
state->blending[i] = pEntity->pev->blending[i];
state->controller[i] = pEntity->pev->controller[i];
}
if( state->ed_type == ED_CLIENT )
{
if( pEntity->pev->teleport_time )
{
state->ed_flags |= ESF_NO_PREDICTION;
state->ed_flags |= ESF_NODELTA;
pEntity->pev->teleport_time = 0.0f;
}
if( pEntity->pev->viewmodel )
state->viewmodel = MODEL_INDEX( STRING( pEntity->pev->viewmodel ));
else state->viewmodel = 0;
if( pEntity->pev->aiment )
state->aiment = ENTINDEX( pEntity->pev->aiment );
else state->aiment = NULLENT_INDEX;
state->viewoffset = pEntity->pev->view_ofs;
state->viewangles = pEntity->pev->v_angle;
state->idealpitch = pEntity->pev->idealpitch;
state->punch_angles = pEntity->pev->punchangle;
state->velocity = pEntity->pev->velocity;
state->basevelocity = pEntity->pev->clbasevelocity;
state->iStepLeft = pEntity->pev->iStepLeft;
state->flFallVelocity = pEntity->pev->flFallVelocity;
// playermodel sequence, that will be playing on a client
if( pEntity->pev->gaitsequence != -1 )
state->gaitsequence = pEntity->pev->gaitsequence;
if( pEntity->pev->weaponmodel != iStringNull )
state->weaponmodel = MODEL_INDEX( STRING( pEntity->pev->weaponmodel ));
else state->weaponmodel = 0;
state->weapons = pEntity->pev->weapons;
state->maxspeed = pEntity->pev->maxspeed;
// clamp fov
if( pEntity->pev->fov < 0.0 ) pEntity->pev->fov = 0.0;
if( pEntity->pev->fov > 160 ) pEntity->pev->fov = 160;
state->fov = pEntity->pev->fov;
}
else if( state->ed_type == ED_AMBIENT )
{
// add here specified fields e.g for trigger_teleport wind sound etc
}
else if( state->ed_type == ED_MOVER || state->ed_type == ED_BSPBRUSH || state->ed_type == ED_PORTAL )
{
state->body = DirToBits( pEntity->pev->movedir );
state->velocity = pEntity->pev->velocity;
// this is conveyor - send speed to render for right texture scrolling
state->framerate = pEntity->pev->speed;
}
else if( state->ed_type == ED_BEAM )
{
state->gaitsequence = pEntity->pev->frags; // beam type
// translate StartBeamEntity
if( pEntity->pev->owner )
state->owner = ENTINDEX( pEntity->pev->owner );
else state->owner = NULLENT_INDEX;
}
return 1;
}
/*
===================
CreateBaseline
Creates baselines used for network encoding, especially for player data since players are not spawned until connect time.
===================
*/
void CreateBaseline( entity_state_t *baseline, edict_t *entity, int playermodelindex )
{
// always set nodelta's for baseline
baseline->ed_flags |= ESF_NODELTA;
baseline->origin = entity->v.origin;
baseline->angles = entity->v.angles;
baseline->frame = entity->v.frame;
baseline->skin = (short)entity->v.skin;
// render information
baseline->rendermode = (byte)entity->v.rendermode;
baseline->renderamt = (byte)entity->v.renderamt;
baseline->rendercolor.x = (byte)entity->v.rendercolor.x;
baseline->rendercolor.y = (byte)entity->v.rendercolor.y;
baseline->rendercolor.z = (byte)entity->v.rendercolor.z;
baseline->renderfx = (byte)entity->v.renderfx;
baseline->mins = entity->v.mins;
baseline->maxs = entity->v.maxs;
if( baseline->ed_type == ED_CLIENT )
{
baseline->colormap = entity->serialnumber;
baseline->modelindex = playermodelindex; // "model" field from userinfo
baseline->friction = 1.0;
baseline->movetype = MOVETYPE_WALK;
baseline->scale = entity->v.scale;
baseline->solid = SOLID_SLIDEBOX;
baseline->framerate = 1.0;
baseline->gravity = 1.0;
}
else
{
baseline->colormap = 0;
baseline->modelindex = entity->v.modelindex;
baseline->movetype = (movetype_t)entity->v.movetype;
baseline->scale = entity->v.scale;
baseline->solid = (solid_t)entity->v.solid;
baseline->framerate = entity->v.framerate;
baseline->gravity = entity->v.gravity;
}
}
typedef struct
{
char name[32];
@ -1668,6 +1724,8 @@ void Custom_Encode( struct delta_s *pFields, const unsigned char *from, const un
RegisterEncoders
Allows game .dll to override network encoding of certain types of entities and tweak values, etc.
disabled for now, wait for Xash 0.8
=================
*/
void RegisterEncoders( void )
@ -1677,6 +1735,61 @@ void RegisterEncoders( void )
DELTA_ADDENCODER( "Player_Encode", Player_Encode );
}
/*
=================
GetWeaponData
Part of weapon predict system
disabled for now, wait for Xash 0.8
=================
*/
int GetWeaponData( struct edict_s *player, weapon_data_t *info )
{
memset( info, 0, 32 * sizeof( weapon_data_t ));
return 1;
}
/*
=================
UpdateClientData
Data sent to current client only
engine sets cd to 0 before calling.
=================
*/
void UpdateClientData( const edict_t *ent, int sendweapons, clientdata_t *cd )
{
cd->flags = ent->v.flags;
cd->health = ent->v.health;
cd->viewmodel = MODEL_INDEX( STRING( ent->v.viewmodel ) );
cd->waterlevel = ent->v.waterlevel;
cd->watertype = ent->v.watertype;
cd->weapons = ent->v.weapons;
// Vectors
cd->origin = ent->v.origin;
cd->velocity = ent->v.velocity;
cd->view_ofs = ent->v.view_ofs;
cd->punchangle = ent->v.punchangle;
cd->bInDuck = ent->v.bInDuck;
cd->flTimeStepSound = ent->v.flTimeStepSound;
cd->flDuckTime = ent->v.flDuckTime;
cd->flSwimTime = ent->v.flSwimTime;
cd->waterjumptime = ent->v.teleport_time;
strcpy( cd->physinfo, ENGINE_GETPHYSINFO( ent ) );
cd->maxspeed = ent->v.maxspeed;
cd->fov = ent->v.fov;
cd->weaponanim = ent->v.weaponanim;
cd->pushmsec = ent->v.pushmsec;
}
/*
=================
CmdStart

View File

@ -29,7 +29,6 @@ extern void ClientUserInfoChanged( edict_t *pEntity, char *infobuffer );
extern void ServerActivate( edict_t *pEdictList, int edictCount, int clientMax );
extern void ServerDeactivate( void );
extern void StartFrame( void );
extern void EndFrame( void );
extern void PlayerPostThink( edict_t *pEntity );
extern void PlayerPreThink( edict_t *pEntity );
extern void BuildLevelList( void );
@ -38,6 +37,7 @@ extern void RegisterEncoders( void );
extern void ClientPrecache( void );
extern const char *GetGameDescription( void );
extern int GetWeaponData( edict_t *player, struct weapon_data_s *info );
extern void SpectatorConnect ( edict_t *pEntity );
extern void SpectatorDisconnect ( edict_t *pEntity );
@ -46,7 +46,9 @@ extern void SpectatorThink ( edict_t *pEntity );
extern void Sys_Error( const char *error_string );
extern void SetupVisibility( edict_t *pViewEntity, edict_t *pClient, byte **pvs, byte **pas, int portal );
extern int AddToFullPack( edict_t *pView, edict_t *pHost, edict_t *pEdict, int hostflags, byte *pSet );
extern void UpdateClientData( const struct edict_s *ent, int sendweapons, struct clientdata_s *cd );
extern int AddToFullPack( entity_state_t *state, edict_t *pView, edict_t *pHost, edict_t *pEdict, int hostflags, byte *pSet );
extern void CreateBaseline( entity_state_t *baseline, edict_t *entity, int playermodelindex );
extern void CmdStart( const edict_t *player, const struct usercmd_s *cmd, unsigned int random_seed );
extern void CmdEnd ( const edict_t *player );

View File

@ -477,8 +477,8 @@ TYPEDESCRIPTION gEntvarsDescription[] =
DEFINE_ENTITY_FIELD( sequence, FIELD_INTEGER ),
DEFINE_ENTITY_FIELD( animtime, FIELD_TIME ),
DEFINE_ENTITY_FIELD( framerate, FIELD_FLOAT ),
DEFINE_ENTITY_FIELD( controller, FIELD_INTEGER ),
DEFINE_ENTITY_FIELD( blending, FIELD_INTEGER ),
DEFINE_ENTITY_FIELD_ARRAY( controller, FIELD_CHARACTER, 16 ),
DEFINE_ENTITY_FIELD_ARRAY( blending, FIELD_CHARACTER, 16 ),
DEFINE_ENTITY_FIELD( rendermode, FIELD_INTEGER ),
DEFINE_ENTITY_FIELD( renderamt, FIELD_FLOAT ),
@ -539,14 +539,6 @@ TYPEDESCRIPTION gEntvarsDescription[] =
#define ENTVARS_COUNT (sizeof(gEntvarsDescription)/sizeof(gEntvarsDescription[0]))
// used by engine for FindEntityByString and some other things
TYPEDESCRIPTION *GetEntvarsDescirption( int number )
{
if( number < 0 && number >= ENTVARS_COUNT )
return NULL;
return &gEntvarsDescription[number];
}
#ifdef DEBUG
edict_t *DBG_EntOfVars( const entvars_t *pev )
{

View File

@ -495,17 +495,22 @@ extern DLL_GLOBAL int g_Language;
#define PUSH_BLOCK_ONLY_X 1
#define PUSH_BLOCK_ONLY_Y 2
#define VEC_HULL_MIN Vector(-16, -16, -36)
#define VEC_HULL_MAX Vector( 16, 16, 36)
#define VEC_HULL_MIN gpGlobals->hullmins[0]
#define VEC_HULL_MAX gpGlobals->hullmaxs[0]
#define VEC_HUMAN_HULL_MIN Vector( -16, -16, 0 )
#define VEC_HUMAN_HULL_MAX Vector( 16, 16, 72 )
#define VEC_HUMAN_HULL_DUCK Vector( 16, 16, 36 )
#define VEC_VIEW Vector( 0, 0, 28 )
#define VEC_VIEW Vector( 0, 0, gpGlobals->viewheight[0] )
#define VEC_DUCK_HULL_MIN Vector(-16, -16, -18 )
#define VEC_DUCK_HULL_MAX Vector( 16, 16, 18)
#define VEC_DUCK_VIEW Vector( 0, 0, 12 )
#define VEC_DUCK_HULL_MIN gpGlobals->hullmins[1]
#define VEC_DUCK_HULL_MAX gpGlobals->hullmaxs[1]
#define VEC_DUCK_VIEW Vector( 0, 0, gpGlobals->viewheight[1] )
#define SVC_TEMPENTITY gmsgTempEntity
#define SVC_INTERMISSION gmsgIntermission
#define SVC_WEAPONANIM gmsgWeaponAnim
#define SVC_ROOMTYPE gmsgRoomType
// camera flags
#define CAMERA_ON 1

View File

@ -20,37 +20,10 @@ fopen
1. Поддержка loop для ogg vorbis
2. переписать studiomdl для использования VFS
Xash 0.72 Stable 13.12.10
Xash 0.72 Beta 5.07.10
1. revision of all resources OK
2. fix sky changelevel bug OK
3. complete lights.shader
4. implement original half-life dll OK
5. revision monster moving OK
6. fix save\restore global state OK
7. rewrite WalkMove OK
8. tune UPDATE_BACKUP value for singleplayer OK
9. fix monsters interpolation OK
10.revision MOVETYPE_PUSH physic OK
11.rewrite EntitiesInPVS check OK
12.revision MOVETYPE_BOUNCE physic OK
13.revision MOVETYPE_COMPOUND physic OK
14.re-design sound library OK
15.move loding sounds into launch.dll OK
16.implement generic streaming background track OK
17.check bugs before snapshot OK
18.fix logic_switcher OK
19.implement botman's parabot dll
20.implement bsp 28,29,30 formats OK
21.revision of all resources OK
22.finalize server entity-culling OK
23.fix pas-building issues OK
24.remove all unused stuff in engine
25.regrouping resources in baserc
26.implement lighting in render OK
27.implement dlights OK
28.rework SV_PointContents OK
29.implement sound library
30.rewrite engine timer OK
31.fixup demos OK
32.game interface - new revision
1.game interface - new revision OK
2.clgame interface - new revision OK
3.entity_state - new revision OK
4.rework dlights OK
5.rework decals

View File

@ -72,9 +72,9 @@ R_AddSurfDlighbits
*/
uint R_AddSurfDlighbits( msurface_t *surf, uint dlightbits )
{
uint k, bit;
dlight_t *lt;
float dist;
uint k, bit;
ref_dlight_t *lt;
float dist;
for( k = 0, bit = 1, lt = r_dlights; k < r_numDlights; k++, bit <<= 1, lt++ )
{
@ -100,7 +100,7 @@ void R_AddDynamicLights( uint dlightbits, int state )
{
uint i, j, numTempElems;
bool cullAway;
const dlight_t *light;
const ref_dlight_t *light;
const ref_shader_t *shader;
vec3_t tvec, dlorigin, normal;
elem_t tempElemsArray[MAX_ARRAY_ELEMENTS];
@ -140,6 +140,9 @@ void R_AddDynamicLights( uint dlightbits, int state )
for( i = 0, light = r_dlights; i < r_numDlights; i++, light++ )
{
if( light->flags & DLIGHT_ONLYENTS )
continue;
if(!( dlightbits & ( 1<<i )))
continue; // not lit by this light
@ -259,7 +262,7 @@ void R_DrawCoronas( void )
{
uint i;
float dist;
dlight_t *light;
ref_dlight_t *light;
meshbuffer_t *mb;
trace_t tr;
@ -471,10 +474,10 @@ R_LightForPoint
*/
void R_LightForPoint( const vec3_t point, vec3_t ambientLight )
{
dlight_t *dl;
vec3_t end, dir;
float dist, add;
int lnum;
ref_dlight_t *dl;
vec3_t end, dir;
float dist, add;
int lnum;
// set to full bright if no light data
if( !r_worldbrushmodel || !r_worldbrushmodel->lightdata )
@ -515,10 +518,10 @@ R_LightDir
*/
void R_LightDir( const vec3_t origin, vec3_t lightDir, float radius )
{
dlight_t *dl;
vec3_t dir;
float dist;
int lnum;
ref_dlight_t *dl;
vec3_t dir;
float dist;
int lnum;
// get light direction from light grid
R_ReadLightGrid( origin, lightDir );
@ -665,11 +668,11 @@ dynamic:
// add dynamic lights
if( radius && r_dynamiclight->integer && r_numDlights )
{
uint lnum;
dlight_t *dl;
float dist, dist2, add;
vec3_t direction;
bool anyDlights = false;
uint lnum;
ref_dlight_t *dl;
float dist, dist2, add;
vec3_t direction;
bool anyDlights = false;
for( lnum = 0, dl = r_dlights; lnum < r_numDlights; lnum++, dl++ )
{
@ -731,12 +734,12 @@ R_LightForEntity
*/
void R_LightForEntity( ref_entity_t *e, byte *bArray )
{
dlight_t *dl;
vec3_t end, dir;
float add, dot, dist, intensity, radius;
vec3_t ambientLight, directedLight, lightDir;
float *cArray;
int i, l;
ref_dlight_t *dl;
vec3_t end, dir;
float add, dot, dist, intensity, radius;
vec3_t ambientLight, directedLight, lightDir;
float *cArray;
int i, l;
if(( e->flags & EF_FULLBRIGHT ) || r_fullbright->integer )
return;

View File

@ -143,7 +143,6 @@ enum
//===================================================================
#include "bmodel_ref.h"
#include "r_math.h"
#include "r_mesh.h"
#include "r_shader.h"
@ -184,21 +183,13 @@ enum
typedef struct
{
// these values common with dlight_t so don't move them
vec3_t origin;
union
{
vec3_t color; // dlight color
vec3_t angles; // spotlight angles
};
float intensity; // cdlight->radius
shader_t texture; // light image e.g. for flashlight
vec2_t cone; // spotlight cone
// dlight_t private starts here
vec3_t mins, maxs;
const ref_shader_t *shader;
} dlight_t;
vec3_t origin;
vec3_t color; // dlight color
float intensity; // cdlight->radius
vec3_t mins, maxs;
const ref_shader_t *shader;
int flags; // misc flags
} ref_dlight_t;
typedef struct
{
@ -328,7 +319,7 @@ extern uint r_numEntities;
extern ref_entity_t r_entities[MAX_ENTITIES];
extern uint r_numDlights;
extern dlight_t r_dlights[MAX_DLIGHTS];
extern ref_dlight_t r_dlights[MAX_DLIGHTS];
extern uint r_numPolys;
extern poly_t r_polys[MAX_POLYS];

View File

@ -69,7 +69,7 @@ ref_entity_t r_entities[MAX_ENTITIES];
ref_entity_t *r_worldent = &r_entities[0];
uint r_numDlights;
dlight_t r_dlights[MAX_DLIGHTS];
ref_dlight_t r_dlights[MAX_DLIGHTS];
uint r_numPolys;
poly_t r_polys[MAX_POLYS];
@ -637,13 +637,13 @@ R_PushCorona
*/
static void R_PushCorona( const meshbuffer_t *mb )
{
int i;
vec4_t color;
vec3_t origin, point;
dlight_t *light = r_dlights + ( -mb->infokey - 1 );
float radius = light->intensity, colorscale;
float up = radius, down = -radius, left = -radius, right = radius;
ref_shader_t *shader;
vec4_t color;
vec3_t origin, point;
ref_dlight_t *light = r_dlights + ( -mb->infokey - 1 );
float radius = light->intensity, colorscale;
float up = radius, down = -radius, left = -radius, right = radius;
ref_shader_t *shader;
int i;
VectorCopy( light->origin, origin );
@ -2654,22 +2654,20 @@ bool R_AddTeEntToScene( TEMPENTITY *pTempEntity, int ed_type, shader_t customSha
return true;
}
bool R_AddDynamicLight( const void *dlight )
bool R_AddDynamicLight( vec3_t pos, rgb_t color, float radius, int flags )
{
dlight_t *dl, *src = (dlight_t *)dlight;
ref_shader_t *shader;
ref_dlight_t *dl;
if(( r_numDlights >= MAX_DLIGHTS ) || (!src) || (src->intensity == 0) || ( VectorIsNull( src->color )))
if(( r_numDlights >= MAX_DLIGHTS ) || ( radius == 0.0f ))
return false;
if( src->texture < 0 || src->texture > MAX_SHADERS || !(shader = &r_shaders[src->texture])->name)
shader = NULL;
dl = &r_dlights[r_numDlights++];
VectorCopy( src->origin, dl->origin );
VectorCopy( src->color, dl->color );
Vector2Copy( src->cone, dl->cone );
dl->intensity = src->intensity * 0.5f;
dl->shader = shader;
VectorCopy( pos, dl->origin );
VectorScale( color, ( 1.0f / 255.0f ), dl->color );
dl->intensity = radius * 0.5f;
dl->flags = flags;
dl->shader = NULL;
R_LightBounds( dl->origin, dl->intensity, dl->mins, dl->maxs );
@ -2708,7 +2706,7 @@ render_exp_t DLLEXPORT *CreateAPI(stdlib_api_t *input, render_imp_t *engfuncs )
re.AddLightStyle = R_AddLightStyle;
re.AddRefEntity = R_AddEntityToScene;
re.AddTmpEntity = R_AddTeEntToScene;
re.AddDynLight = R_AddDynamicLight;
re.AddDLight = R_AddDynamicLight;
re.AddPolygon = R_AddPolyToScene;
re.ClearScene = R_ClearScene;

View File

@ -26,7 +26,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "mathlib.h"
#include "matrix_lib.h"
#include "byteorder.h"
#include "bmodel_ref.h"
#include "bspfile.h"
#define Mod_CopyString( m, str ) com.stralloc( (m)->mempool, str, __FILE__, __LINE__ )
#define MAX_SIDE_VERTS 256 // per one polygon

View File

@ -24,6 +24,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "r_local.h"
#include "mathlib.h"
#include "matrix_lib.h"
#include "bspfile.h"
static vec3_t modelorg; // relative to viewpoint
static vec3_t modelmins;