17 Dec 2012

This commit is contained in:
g-cont 2012-12-17 00:00:00 +04:00 committed by Alibek Omarov
parent eaca5b484c
commit 9d7bcb1323
39 changed files with 403 additions and 947 deletions

View File

@ -17,7 +17,6 @@ cl_dll\
cl_dll\hl\
common\
dlls\
dlls\wpn_shared
game_shared\
game_launch\
engine\

View File

@ -28,7 +28,7 @@ BRUSH MODELS
// header
#define Q1BSP_VERSION 29 // quake1 regular version (beta is 28)
#define HLBSP_VERSION 30 // half-life regular version
#define XTBSP_VERSION 31 // extended lightmaps and clipnodes limit
#define XTBSP_VERSION 31 // extended lightmaps and expanded clipnodes limit
// worldcraft predefined angles
#define ANGLE_UP -1
@ -71,7 +71,7 @@ BRUSH MODELS
#define MAX_MAP_SURFEDGES 0x200000 // can be increased but not needed
#define MAX_MAP_TEXTURES 2048 // can be increased but not needed
#define MAX_MAP_MIPTEX 0x2000000 // 32 Mb internal textures data
#define MAX_MAP_LIGHTING 0x2000000 // 32 Mb lightmap raw data (can contain bumpdata too)
#define MAX_MAP_LIGHTING 0x2000000 // 32 Mb lightmap raw data (can contain deluxemaps)
#define MAX_MAP_VISIBILITY 0x800000 // 8 Mb visdata
// quake lump ordering
@ -93,8 +93,8 @@ BRUSH MODELS
#define HEADER_LUMPS 15
// version 31
#define LUMP_CLIPNODES2 15 // hull0 goes into LUMP_NODES, hull1 goes into LUMP_CLIPNODES
#define LUMP_CLIPNODES3 16 // , hull2 goes into LUMP_CLIPNODES2, hull3 goes into LUMP_CLIPNODES3
#define LUMP_CLIPNODES2 15 // hull0 goes into LUMP_NODES, hull1 goes into LUMP_CLIPNODES,
#define LUMP_CLIPNODES3 16 // hull2 goes into LUMP_CLIPNODES2, hull3 goes into LUMP_CLIPNODES3
// texture flags
#define TEX_SPECIAL BIT( 0 ) // sky or slime, no lightmap or 256 subdivision

View File

@ -133,7 +133,7 @@ struct decal_s
byte flags; // Decal flags FDECAL_*
short entityIndex; // Entity this is attached to
// Xash3D added
vec3_t position; // location of the decal center in world space.
vec3_t saxis; // direction of the s axis in world space
};

View File

@ -639,7 +639,7 @@
#define VOL_NORM 1.0
// plats
#define PLAT_LOW_TRIGGER 1
#define PLAT_LOW_TRIGGER 1
// Trains
#define SF_TRAIN_WAIT_RETRIGGER 1
@ -752,19 +752,6 @@ typedef struct
unsigned r, g, b, a;
} colorVec;
#ifdef _WIN32
#pragma pack( push, 2 )
#endif
typedef struct
{
unsigned short r, g, b, a;
} PackedColorVec;
#ifdef _WIN32
#pragma pack( pop )
#endif
typedef struct link_s
{
struct link_s *prev, *next;

View File

@ -20,16 +20,6 @@ typedef float vec_t;
typedef vec_t vec2_t[2];
typedef vec_t vec3_t[3];
typedef vec_t vec4_t[4]; // x,y,z,w
typedef vec_t vec5_t[5];
typedef short vec_s_t;
typedef vec_s_t vec3s_t[3];
typedef vec_s_t vec4s_t[4]; // x,y,z,w
typedef vec_s_t vec5s_t[5];
typedef int fixed4_t;
typedef int fixed8_t;
typedef int fixed16_t;
#ifndef M_PI
#define M_PI 3.14159265358979323846 // matches value in gcc v2 math.h
@ -64,61 +54,10 @@ void CrossProduct (const vec3_t v1, const vec3_t v2, vec3_t cross);
float VectorNormalize (vec3_t v); // returns vector length
void VectorInverse (vec3_t v);
void VectorScale (const vec3_t in, vec_t scale, vec3_t out);
int Q_log2(int val);
void R_ConcatRotations (float in1[3][3], float in2[3][3], float out[3][3]);
void R_ConcatTransforms (float in1[3][4], float in2[3][4], float out[3][4]);
// Here are some "manual" INLINE routines for doing floating point to integer conversions
extern short new_cw, old_cw;
typedef union DLONG {
int i[2];
double d;
float f;
} DLONG;
extern DLONG dlong;
#ifdef _WIN32
void __inline set_fpu_cw(void)
{
_asm
{ wait
fnstcw old_cw
wait
mov ax, word ptr old_cw
or ah, 0xc
mov word ptr new_cw,ax
fldcw new_cw
}
}
int __inline quick_ftol(float f)
{
_asm {
// Assumes that we are already in chop mode, and only need a 32-bit int
fld DWORD PTR f
fistp DWORD PTR dlong
}
return dlong.i[0];
}
void __inline restore_fpu_cw(void)
{
_asm fldcw old_cw
}
#else
#define set_fpu_cw() /* */
#define quick_ftol(f) ftol(f)
#define restore_fpu_cw() /* */
#endif
void FloorDivMod (double numer, double denom, int *quotient,
int *rem);
fixed16_t Invert24To16(fixed16_t val);
int GreatestCommonDivisor (int i1, int i2);
void AngleVectors (const vec3_t angles, vec3_t forward, vec3_t right, vec3_t up);
void AngleVectorsTranspose (const vec3_t angles, vec3_t forward, vec3_t right, vec3_t up);
#define AngleIVectors AngleVectorsTranspose
@ -131,7 +70,6 @@ void NormalizeAngles( vec3_t angles );
void InterpolateAngles( vec3_t start, vec3_t end, vec3_t output, float frac );
float AngleBetweenVectors( const vec3_t v1, const vec3_t v2 );
void VectorMatrix( vec3_t forward, vec3_t right, vec3_t up);
void VectorAngles( const vec3_t forward, vec3_t angles );
@ -140,8 +78,6 @@ int InvertMatrix( const float * m, float *out );
int BoxOnPlaneSide (vec3_t emins, vec3_t emaxs, struct mplane_s *plane);
float anglemod(float a);
#define BOX_ON_PLANE_SIDE(emins, emaxs, p) \
(((p)->type < 3)? \
( \

View File

@ -68,7 +68,7 @@ typedef struct ref_params_s
int nextView; // the renderer calls ClientDLL_CalcRefdef() and Renderview
// so long in cycles until this value is 0 (multiple views)
int onlyClientDraw; // if !=0 nothing is drawn by the engine except clientDraw functions
// Xash3D extension
float fov_x, fov_y; // actual fov can be overrided on nextView
} ref_params_t;

View File

@ -31,7 +31,7 @@ typedef enum
#define TRI_LINES 4
#define TRI_TRIANGLE_STRIP 5
#define TRI_QUAD_STRIP 6
#define TRI_POINTS 7
#define TRI_POINTS 7 // Xash3D added
typedef struct triangleapi_s
{

View File

@ -34,28 +34,6 @@ enum glock_e {
GLOCK_ADD_SILENCER
};
class CGlock : public CBasePlayerWeapon
{
public:
void Spawn( void );
void Precache( void );
int iItemSlot( void ) { return 2; }
int GetItemInfo(ItemInfo *p);
void PrimaryAttack( void );
void SecondaryAttack( void );
void GlockFire( float flSpread, float flCycleTime, BOOL fUseAutoAim );
BOOL Deploy( void );
void Reload( void );
void WeaponIdle( void );
private:
int m_iShell;
unsigned short m_usFireGlock1;
unsigned short m_usFireGlock2;
};
LINK_ENTITY_TO_CLASS( weapon_glock, CGlock );
LINK_ENTITY_TO_CLASS( weapon_9mmhandgun, CGlock );
@ -112,7 +90,7 @@ int CGlock::GetItemInfo(ItemInfo *p)
BOOL CGlock::Deploy( )
{
// pev->body = 1;
return DefaultDeploy( "models/v_9mmhandgun.mdl", "models/p_9mmhandgun.mdl", GLOCK_DRAW, "onehanded" );
return DefaultDeploy( "models/v_9mmhandgun.mdl", "models/p_9mmhandgun.mdl", GLOCK_DRAW, "onehanded", /*UseDecrement() ? 1 : 0*/ 0 );
}
void CGlock::SecondaryAttack( void )
@ -132,7 +110,7 @@ void CGlock::GlockFire( float flSpread , float flCycleTime, BOOL fUseAutoAim )
if (m_fFireOnEmpty)
{
PlayEmptySound();
m_flNextPrimaryAttack = gpGlobals->time + 0.2;
m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 0.2;
}
return;
@ -142,60 +120,28 @@ void CGlock::GlockFire( float flSpread , float flCycleTime, BOOL fUseAutoAim )
m_pPlayer->pev->effects = (int)(m_pPlayer->pev->effects) | EF_MUZZLEFLASH;
#if defined ( OLD_WEAPONS )
if (m_iClip != 0)
SendWeaponAnim( GLOCK_SHOOT );
else
SendWeaponAnim( GLOCK_SHOOT_EMPTY );
#endif
int flags;
if ( fUseAutoAim )
{
PLAYBACK_EVENT_FULL( 0, m_pPlayer->edict(), m_usFireGlock1, 0.0, (float *)&g_vecZero, (float *)&g_vecZero, 0.0, 0.0, 0, 0, ( m_iClip == 0 ) ? 1 : 0, 0 );
}
else
{
PLAYBACK_EVENT_FULL( 0, m_pPlayer->edict(), m_usFireGlock2, 0.0, (float *)&g_vecZero, (float *)&g_vecZero, 0.0, 0.0, 0, 0, ( m_iClip == 0 ) ? 1 : 0, 0 );
}
#if defined( CLIENT_WEAPONS )
flags = FEV_NOTHOST;
#else
flags = 0;
#endif
// player "shoot" animation
m_pPlayer->SetAnimation( PLAYER_ATTACK1 );
#if defined ( OLD_WEAPONS )
UTIL_MakeVectors( m_pPlayer->pev->v_angle + m_pPlayer->pev->punchangle );
Vector vecShellVelocity = m_pPlayer->pev->velocity
+ gpGlobals->v_right * RANDOM_FLOAT(50,70)
+ gpGlobals->v_up * RANDOM_FLOAT(100,150)
+ gpGlobals->v_forward * 25;
EjectBrass ( pev->origin + m_pPlayer->pev->view_ofs + gpGlobals->v_up * -12 + gpGlobals->v_forward * 32 + gpGlobals->v_right * 6 , vecShellVelocity, pev->angles.y, m_iShell, TE_BOUNCE_SHELL );
#endif
// silenced
if (pev->body == 1)
{
m_pPlayer->m_iWeaponVolume = QUIET_GUN_VOLUME;
m_pPlayer->m_iWeaponFlash = DIM_GUN_FLASH;
#if defined ( OLD_WEAPONS )
switch(RANDOM_LONG(0,1))
{
case 0:
EMIT_SOUND(ENT(m_pPlayer->pev), CHAN_WEAPON, "weapons/pl_gun1.wav", RANDOM_FLOAT(0.9, 1.0), ATTN_NORM);
break;
case 1:
EMIT_SOUND(ENT(m_pPlayer->pev), CHAN_WEAPON, "weapons/pl_gun2.wav", RANDOM_FLOAT(0.9, 1.0), ATTN_NORM);
break;
}
#endif
}
else
{
// non-silenced
m_pPlayer->m_iWeaponVolume = NORMAL_GUN_VOLUME;
m_pPlayer->m_iWeaponFlash = NORMAL_GUN_FLASH;
#if defined ( OLD_WEAPONS )
EMIT_SOUND_DYN(ENT(m_pPlayer->pev), CHAN_WEAPON, "weapons/pl_gun3.wav", RANDOM_FLOAT(0.92, 1.0), ATTN_NORM, 0, 98 + RANDOM_LONG(0,3));
#endif
}
Vector vecSrc = m_pPlayer->GetGunPosition( );
@ -210,24 +156,26 @@ void CGlock::GlockFire( float flSpread , float flCycleTime, BOOL fUseAutoAim )
vecAiming = gpGlobals->v_forward;
}
m_pPlayer->FireBullets( 1, vecSrc, vecAiming, Vector( flSpread, flSpread, flSpread ), 8192, BULLET_PLAYER_9MM, 0 );
Vector vecDir;
vecDir = m_pPlayer->FireBulletsPlayer( 1, vecSrc, vecAiming, Vector( flSpread, flSpread, flSpread ), 8192, BULLET_PLAYER_9MM, 0, 0, m_pPlayer->pev, m_pPlayer->random_seed );
m_flNextPrimaryAttack = m_flNextSecondaryAttack = gpGlobals->time + flCycleTime;
PLAYBACK_EVENT_FULL( flags, m_pPlayer->edict(), fUseAutoAim ? m_usFireGlock1 : m_usFireGlock2, 0.0, (float *)&g_vecZero, (float *)&g_vecZero, vecDir.x, vecDir.y, 0, 0, ( m_iClip == 0 ) ? 1 : 0, 0 );
m_flNextPrimaryAttack = m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + flCycleTime;
if (!m_iClip && m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0)
// HEV suit - indicate out of ammo condition
m_pPlayer->SetSuitUpdate("!HEV_AMO0", FALSE, 0);
m_flTimeWeaponIdle = gpGlobals->time + RANDOM_FLOAT ( 10, 15 );
#if defined ( OLD_WEAPONS )
m_pPlayer->pev->punchangle.x -= 2;
#endif
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + UTIL_SharedRandomFloat( m_pPlayer->random_seed, 10, 15 );
}
void CGlock::Reload( void )
{
if ( m_pPlayer->ammo_9mm <= 0 )
return;
int iResult;
if (m_iClip == 0)
@ -237,7 +185,7 @@ void CGlock::Reload( void )
if (iResult)
{
m_flTimeWeaponIdle = gpGlobals->time + RANDOM_FLOAT ( 10, 15 );
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + UTIL_SharedRandomFloat( m_pPlayer->random_seed, 10, 15 );
}
}
@ -249,30 +197,31 @@ void CGlock::WeaponIdle( void )
m_pPlayer->GetAutoaimVector( AUTOAIM_10DEGREES );
if (m_flTimeWeaponIdle > UTIL_WeaponTimeBase())
if ( m_flTimeWeaponIdle > UTIL_WeaponTimeBase() )
return;
// only idle if the slid isn't back
if (m_iClip != 0)
{
int iAnim;
float flRand = RANDOM_FLOAT(0, 1);
float flRand = UTIL_SharedRandomFloat( m_pPlayer->random_seed, 0.0, 1.0 );
if (flRand <= 0.3 + 0 * 0.75)
{
iAnim = GLOCK_IDLE3;
m_flTimeWeaponIdle = gpGlobals->time + 49.0 / 16;
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 49.0 / 16;
}
else if (flRand <= 0.6 + 0 * 0.875)
{
iAnim = GLOCK_IDLE1;
m_flTimeWeaponIdle = gpGlobals->time + 60.0 / 16.0;
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 60.0 / 16.0;
}
else
{
iAnim = GLOCK_IDLE2;
m_flTimeWeaponIdle = gpGlobals->time + 40.0 / 16.0;
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 40.0 / 16.0;
}
SendWeaponAnim( iAnim );
SendWeaponAnim( iAnim, 1 );
}
}

View File

@ -1,274 +0,0 @@
/***
*
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
*
* This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
* All Rights Reserved.
*
* Use, distribution, and modification of this source code and/or resulting
* object code is restricted to non-commercial enhancements to products from
* Valve LLC. All other use, distribution, or modification is prohibited
* without written permission from Valve LLC.
*
****/
#include "extdll.h"
#include "util.h"
#include "cbase.h"
#include "monsters.h"
#include "weapons.h"
#include "nodes.h"
#include "player.h"
enum glock_e {
GLOCK_IDLE1 = 0,
GLOCK_IDLE2,
GLOCK_IDLE3,
GLOCK_SHOOT,
GLOCK_SHOOT_EMPTY,
GLOCK_RELOAD,
GLOCK_RELOAD_NOT_EMPTY,
GLOCK_DRAW,
GLOCK_HOLSTER,
GLOCK_ADD_SILENCER
};
LINK_ENTITY_TO_CLASS( weapon_glock, CGlock );
LINK_ENTITY_TO_CLASS( weapon_9mmhandgun, CGlock );
void CGlock::Spawn( )
{
pev->classname = MAKE_STRING("weapon_9mmhandgun"); // hack to allow for old names
Precache( );
m_iId = WEAPON_GLOCK;
SET_MODEL(ENT(pev), "models/w_9mmhandgun.mdl");
m_iDefaultAmmo = GLOCK_DEFAULT_GIVE;
FallInit();// get ready to fall down.
}
void CGlock::Precache( void )
{
PRECACHE_MODEL("models/v_9mmhandgun.mdl");
PRECACHE_MODEL("models/w_9mmhandgun.mdl");
PRECACHE_MODEL("models/p_9mmhandgun.mdl");
m_iShell = PRECACHE_MODEL ("models/shell.mdl");// brass shell
PRECACHE_SOUND("items/9mmclip1.wav");
PRECACHE_SOUND("items/9mmclip2.wav");
PRECACHE_SOUND ("weapons/pl_gun1.wav");//silenced handgun
PRECACHE_SOUND ("weapons/pl_gun2.wav");//silenced handgun
PRECACHE_SOUND ("weapons/pl_gun3.wav");//handgun
m_usFireGlock1 = PRECACHE_EVENT( 1, "events/glock1.sc" );
m_usFireGlock2 = PRECACHE_EVENT( 1, "events/glock2.sc" );
}
int CGlock::GetItemInfo(ItemInfo *p)
{
p->pszName = STRING(pev->classname);
p->pszAmmo1 = "9mm";
p->iMaxAmmo1 = _9MM_MAX_CARRY;
p->pszAmmo2 = NULL;
p->iMaxAmmo2 = -1;
p->iMaxClip = GLOCK_MAX_CLIP;
p->iSlot = 1;
p->iPosition = 0;
p->iFlags = 0;
p->iId = m_iId = WEAPON_GLOCK;
p->iWeight = GLOCK_WEIGHT;
return 1;
}
BOOL CGlock::Deploy( )
{
// pev->body = 1;
return DefaultDeploy( "models/v_9mmhandgun.mdl", "models/p_9mmhandgun.mdl", GLOCK_DRAW, "onehanded", /*UseDecrement() ? 1 : 0*/ 0 );
}
void CGlock::SecondaryAttack( void )
{
GlockFire( 0.1, 0.2, FALSE );
}
void CGlock::PrimaryAttack( void )
{
GlockFire( 0.01, 0.3, TRUE );
}
void CGlock::GlockFire( float flSpread , float flCycleTime, BOOL fUseAutoAim )
{
if (m_iClip <= 0)
{
if (m_fFireOnEmpty)
{
PlayEmptySound();
m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 0.2;
}
return;
}
m_iClip--;
m_pPlayer->pev->effects = (int)(m_pPlayer->pev->effects) | EF_MUZZLEFLASH;
int flags;
#if defined( CLIENT_WEAPONS )
flags = FEV_NOTHOST;
#else
flags = 0;
#endif
// player "shoot" animation
m_pPlayer->SetAnimation( PLAYER_ATTACK1 );
// silenced
if (pev->body == 1)
{
m_pPlayer->m_iWeaponVolume = QUIET_GUN_VOLUME;
m_pPlayer->m_iWeaponFlash = DIM_GUN_FLASH;
}
else
{
// non-silenced
m_pPlayer->m_iWeaponVolume = NORMAL_GUN_VOLUME;
m_pPlayer->m_iWeaponFlash = NORMAL_GUN_FLASH;
}
Vector vecSrc = m_pPlayer->GetGunPosition( );
Vector vecAiming;
if ( fUseAutoAim )
{
vecAiming = m_pPlayer->GetAutoaimVector( AUTOAIM_10DEGREES );
}
else
{
vecAiming = gpGlobals->v_forward;
}
Vector vecDir;
vecDir = m_pPlayer->FireBulletsPlayer( 1, vecSrc, vecAiming, Vector( flSpread, flSpread, flSpread ), 8192, BULLET_PLAYER_9MM, 0, 0, m_pPlayer->pev, m_pPlayer->random_seed );
PLAYBACK_EVENT_FULL( flags, m_pPlayer->edict(), fUseAutoAim ? m_usFireGlock1 : m_usFireGlock2, 0.0, (float *)&g_vecZero, (float *)&g_vecZero, vecDir.x, vecDir.y, 0, 0, ( m_iClip == 0 ) ? 1 : 0, 0 );
m_flNextPrimaryAttack = m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + flCycleTime;
if (!m_iClip && m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0)
// HEV suit - indicate out of ammo condition
m_pPlayer->SetSuitUpdate("!HEV_AMO0", FALSE, 0);
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + UTIL_SharedRandomFloat( m_pPlayer->random_seed, 10, 15 );
}
void CGlock::Reload( void )
{
if ( m_pPlayer->ammo_9mm <= 0 )
return;
int iResult;
if (m_iClip == 0)
iResult = DefaultReload( 17, GLOCK_RELOAD, 1.5 );
else
iResult = DefaultReload( 17, GLOCK_RELOAD_NOT_EMPTY, 1.5 );
if (iResult)
{
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + UTIL_SharedRandomFloat( m_pPlayer->random_seed, 10, 15 );
}
}
void CGlock::WeaponIdle( void )
{
ResetEmptySound( );
m_pPlayer->GetAutoaimVector( AUTOAIM_10DEGREES );
if ( m_flTimeWeaponIdle > UTIL_WeaponTimeBase() )
return;
// only idle if the slid isn't back
if (m_iClip != 0)
{
int iAnim;
float flRand = UTIL_SharedRandomFloat( m_pPlayer->random_seed, 0.0, 1.0 );
if (flRand <= 0.3 + 0 * 0.75)
{
iAnim = GLOCK_IDLE3;
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 49.0 / 16;
}
else if (flRand <= 0.6 + 0 * 0.875)
{
iAnim = GLOCK_IDLE1;
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 60.0 / 16.0;
}
else
{
iAnim = GLOCK_IDLE2;
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 40.0 / 16.0;
}
SendWeaponAnim( iAnim, 1 );
}
}
class CGlockAmmo : public CBasePlayerAmmo
{
void Spawn( void )
{
Precache( );
SET_MODEL(ENT(pev), "models/w_9mmclip.mdl");
CBasePlayerAmmo::Spawn( );
}
void Precache( void )
{
PRECACHE_MODEL ("models/w_9mmclip.mdl");
PRECACHE_SOUND("items/9mmclip1.wav");
}
BOOL AddAmmo( CBaseEntity *pOther )
{
if (pOther->GiveAmmo( AMMO_GLOCKCLIP_GIVE, "9mm", _9MM_MAX_CARRY ) != -1)
{
EMIT_SOUND(ENT(pev), CHAN_ITEM, "items/9mmclip1.wav", 1, ATTN_NORM);
return TRUE;
}
return FALSE;
}
};
LINK_ENTITY_TO_CLASS( ammo_glockclip, CGlockAmmo );
LINK_ENTITY_TO_CLASS( ammo_9mmclip, CGlockAmmo );

View File

@ -323,51 +323,6 @@ typedef struct cl_enginefuncs_s
#define CLDLL_INTERFACE_VERSION 7
extern void ClientDLL_Init( void ); // from cdll_int.c
extern void ClientDLL_Shutdown( void );
extern void ClientDLL_HudInit( void );
extern void ClientDLL_HudVidInit( void );
extern void ClientDLL_UpdateClientData( void );
extern void ClientDLL_Frame( double time );
extern void ClientDLL_HudRedraw( int intermission );
extern void ClientDLL_MoveClient( struct playermove_s *ppmove );
extern void ClientDLL_ClientMoveInit( struct playermove_s *ppmove );
extern char ClientDLL_ClientTextureType( char *name );
extern void ClientDLL_CreateMove( float frametime, struct usercmd_s *cmd, int active );
extern void ClientDLL_ActivateMouse( void );
extern void ClientDLL_DeactivateMouse( void );
extern void ClientDLL_MouseEvent( int mstate );
extern void ClientDLL_ClearStates( void );
extern int ClientDLL_IsThirdPerson( void );
extern void ClientDLL_GetCameraOffsets( float *ofs );
extern int ClientDLL_GraphKeyDown( void );
extern struct kbutton_s *ClientDLL_FindKey( const char *name );
extern void ClientDLL_CAM_Think( void );
extern void ClientDLL_IN_Accumulate( void );
extern void ClientDLL_CalcRefdef( struct ref_params_s *pparams );
extern int ClientDLL_AddEntity( int type, struct cl_entity_s *ent );
extern void ClientDLL_CreateEntities( void );
extern void ClientDLL_DrawNormalTriangles( void );
extern void ClientDLL_DrawTransparentTriangles( void );
extern void ClientDLL_StudioEvent( const struct mstudioevent_s *event, const struct cl_entity_s *entity );
extern void ClientDLL_PostRunCmd( struct local_state_s *from, struct local_state_s *to, struct usercmd_s *cmd, int runfuncs, double time, unsigned int random_seed );
extern void ClientDLL_TxferLocalOverrides( struct entity_state_s *state, const struct clientdata_s *client );
extern void ClientDLL_ProcessPlayerState( struct entity_state_s *dst, const struct entity_state_s *src );
extern void ClientDLL_TxferPredictionData ( struct entity_state_s *ps, const struct entity_state_s *pps, struct clientdata_s *pcd, const struct clientdata_s *ppcd, struct weapon_data_s *wd, const struct weapon_data_s *pwd );
extern void ClientDLL_ReadDemoBuffer( int size, unsigned char *buffer );
extern int ClientDLL_ConnectionlessPacket( const struct netadr_s *net_from, const char *args, char *response_buffer, int *response_buffer_size );
extern int ClientDLL_GetHullBounds( int hullnumber, float *mins, float *maxs );
extern void ClientDLL_VGui_ConsolePrint(const char* text);
extern int ClientDLL_Key_Event( int down, int keynum, const char *pszCurrentBinding );
extern void ClientDLL_TempEntUpdate( double ft, double ct, double grav, struct tempent_s **ppFreeTE, struct tempent_s **ppActiveTE, int ( *addTEntity )( struct cl_entity_s *pEntity ), void ( *playTESound )( struct tempent_s *pTemp, float damp ) );
extern struct cl_entity_s *ClientDLL_GetUserEntity( int index );
extern void ClientDLL_VoiceStatus(int entindex, qboolean bTalking);
extern void ClientDLL_DirectorMessage( int iSize, void *pbuf );
#ifdef __cplusplus
}
#endif

View File

@ -1013,7 +1013,7 @@ void CL_LinkUserMessage( char *pszName, const int svc_num, int iSize )
Host_Error( "CL_LinkUserMessage: bad message name\n" );
if( svc_num < svc_lastmsg )
Host_Error( "CL_LinkUserMessage: tired to hook a system message \"%s\"\n", svc_strings[svc_num] );
Host_Error( "CL_LinkUserMessage: tried to hook a system message \"%s\"\n", svc_strings[svc_num] );
// see if already hooked
for( i = 0; i < MAX_USER_MESSAGES && clgame.msg[i].name[0]; i++ )

View File

@ -263,7 +263,7 @@ void CL_ParseSoundPacket( sizebuf_t *msg, qboolean is_ambient )
entnum = BF_ReadWord( msg );
// positioned in space
BF_ReadBitVec3Coord( msg, pos );
BF_ReadVec3Coord( msg, pos );
if( flags & SND_SENTENCE )
{
@ -331,9 +331,10 @@ void CL_ParseRestoreSoundPacket( sizebuf_t *msg )
entnum = BF_ReadWord( msg );
// positioned in space
BF_ReadBitVec3Coord( msg, pos );
BF_ReadVec3Coord( msg, pos );
wordIndex = BF_ReadByte( msg );
// 16 bytes here
BF_ReadBytes( msg, &samplePos, sizeof( samplePos ));
BF_ReadBytes( msg, &forcedEnd, sizeof( forcedEnd ));
@ -373,7 +374,7 @@ void CL_ParseParticles( sizebuf_t *msg )
int i, count, color;
float life;
BF_ReadBitVec3Coord( msg, org );
BF_ReadVec3Coord( msg, org );
for( i = 0; i < 3; i++ )
dir[i] = BF_ReadChar( msg ) * (1.0f / 16);
@ -424,7 +425,7 @@ void CL_ParseStaticEntity( sizebuf_t *msg )
for( i = 0; i < 3; i++ )
{
state.origin[i] = BF_ReadBitCoord( msg );
state.origin[i] = BF_ReadCoord( msg );
state.angles[i] = BF_ReadBitAngle( msg, 16 );
}
@ -482,7 +483,7 @@ void CL_ParseStaticDecal( sizebuf_t *msg )
int decalIndex, entityIndex, modelIndex;
int flags;
BF_ReadBitVec3Coord( msg, origin );
BF_ReadVec3Coord( msg, origin );
decalIndex = BF_ReadWord( msg );
entityIndex = BF_ReadShort( msg );
@ -1082,12 +1083,8 @@ void CL_ParseStudioDecal( sizebuf_t *msg )
int modelIndex = 0;
int flags;
pos[0] = BF_ReadCoord( msg );
pos[1] = BF_ReadCoord( msg );
pos[2] = BF_ReadCoord( msg );
start[0] = BF_ReadCoord( msg );
start[1] = BF_ReadCoord( msg );
start[2] = BF_ReadCoord( msg );
BF_ReadVec3Coord( msg, pos );
BF_ReadVec3Coord( msg, start );
decalIndex = BF_ReadShort( msg );
entityIndex = BF_ReadShort( msg );
flags = BF_ReadByte( msg );
@ -1109,7 +1106,7 @@ void CL_ParseStudioDecal( sizebuf_t *msg )
modelIndex = BF_ReadShort( msg );
}
if( clgame.drawFuncs.R_StudioDecalShoot )
if( clgame.drawFuncs.R_StudioDecalShoot != NULL )
{
int decalTexture = CL_DecalIndex( decalIndex );
cl_entity_t *ent = CL_GetEntityByIndex( entityIndex );

View File

@ -18,6 +18,7 @@ GNU General Public License for more details.
#include "gl_local.h"
#include "mod_local.h"
#include "entity_types.h"
#include "studio.h"
/*
===============================================================================
@ -150,10 +151,29 @@ void R_AddEfrags( cl_entity_t *ent )
lastlink = &ent->efrag;
r_pefragtopnode = NULL;
for( i = 0; i < 3; i++ )
// NOTE: can't copy these bounds directly into model->mins\model->maxs
// because all other code don't expected this
if( ent->model->type == mod_studio )
{
r_emins[i] = ent->origin[i] + ent->model->mins[i];
r_emaxs[i] = ent->origin[i] + ent->model->maxs[i];
studiohdr_t *phdr = (studiohdr_t *)Mod_Extradata( ent->model );
mstudioseqdesc_t *pseqdesc;
if( !phdr ) return;
pseqdesc = (mstudioseqdesc_t *)((byte *)phdr + phdr->seqindex);
for( i = 0; i < 3; i++ )
{
r_emins[i] = ent->origin[i] + pseqdesc[0].bbmin[i];
r_emaxs[i] = ent->origin[i] + pseqdesc[0].bbmax[i];
}
}
else
{
for( i = 0; i < 3; i++ )
{
r_emins[i] = ent->origin[i] + ent->model->mins[i];
r_emaxs[i] = ent->origin[i] + ent->model->maxs[i];
}
}
R_SplitEntityOnNode( cl.worldmodel->nodes );

View File

@ -1490,7 +1490,7 @@ void CL_TracerEffect( const vec3_t start, const vec3_t end )
/*
===============
CL_TracerEffect
CL_UserTracerParticle
===============
*/

View File

@ -3310,9 +3310,6 @@ static void R_StudioLoadTexture( model_t *mod, studiohdr_t *phdr, mstudiotexture
if( ptexture->flags & STUDIO_NF_TRANSPARENT )
flags |= (TF_CLAMP|TF_NOMIPMAP);
if( ptexture->flags & ( STUDIO_NF_NORMALMAP|STUDIO_NF_HEIGHTMAP ))
flags |= TF_NORMALMAP;
// store some textures for remapping
if( !Q_strnicmp( ptexture->name, "DM_Base", 7 ) || !Q_strnicmp( ptexture->name, "remap", 5 ))
{
@ -3509,20 +3506,9 @@ void Mod_LoadStudioModel( model_t *mod, const void *buffer, qboolean *loaded )
Q_memcpy( loadmodel->cache.data, buffer, phdr->length );
#endif
// setup bounding box
if( VectorIsNull( phdr->bbmin ) && VectorIsNull( phdr->bbmax ))
{
mstudioseqdesc_t *pseqdesc = (mstudioseqdesc_t *)((byte *)phdr + phdr->seqindex);
VectorCopy( phdr->bbmin, loadmodel->mins );
VectorCopy( phdr->bbmax, loadmodel->maxs );
// just to have something valid here
VectorCopy( pseqdesc[0].bbmin, loadmodel->mins );
VectorCopy( pseqdesc[0].bbmax, loadmodel->maxs );
}
else
{
VectorCopy( phdr->bbmin, loadmodel->mins );
VectorCopy( phdr->bbmax, loadmodel->maxs );
}
loadmodel->numframes = R_StudioBodyVariations( loadmodel );
loadmodel->radius = RadiusFromBounds( loadmodel->mins, loadmodel->maxs );
loadmodel->flags = phdr->flags; // copy header flags

View File

@ -610,6 +610,10 @@ qboolean Cmd_GetGamesList( const char *s, char *completedname, int length )
string gamedirs[MAX_MODS];
string matchbuf;
// stand-alone games doesn't have cmd "game"
if( !Cmd_Exists( "game" ))
return false;
// compare gamelist with current keyword
for( i = 0, numgamedirs = 0; i < SI.numgames; i++ )
{

View File

@ -220,9 +220,7 @@ convar_t *Cvar_Get( const char *var_name, const char *var_value, int flags, cons
// if we have a latched string, take that value now
if( var->latched_string )
{
char *s;
s = var->latched_string;
char *s = var->latched_string;
var->latched_string = NULL; // otherwise cvar_set2 would free it
Cvar_Set2( var_name, s, true );
Mem_Free( s );
@ -1128,7 +1126,7 @@ void Cvar_Latched_f( void )
/*
============
Cvar_Latched_f
Cvar_LatchedVideo_f
Now all latched video strings is valid
============

View File

@ -99,7 +99,7 @@ qboolean Image_LoadBMP( const char *name, const byte *buffer, size_t filesize )
if( bhdr.bitsPerPixel <= 8 )
{
// figure out how many entires are actually in the table
// figure out how many entries are actually in the table
if( bhdr.colors == 0 )
{
bhdr.colors = 256;

View File

@ -206,8 +206,6 @@ hull_t *Mod_HullForStudio( model_t *model, float frame, int sequence, vec3_t ang
mstudiobbox_t *phitbox;
int i, j;
ASSERT( numhitboxes );
if( mod_studiocache->integer )
{
bonecache = Mod_CheckStudioCache( model, frame, sequence, angles, origin, size, pcontroller, pblending );

View File

@ -291,37 +291,6 @@ void BF_WriteBitAngle( sizebuf_t *bf, float fAngle, int numbits )
BF_WriteUBitLong( bf, (uint)d, numbits );
}
void BF_WriteBitCoord( sizebuf_t *bf, const float f )
{
int signbit = ( f <= -COORD_RESOLUTION );
int fractval = abs(( int )( f * COORD_DENOMINATOR )) & ( COORD_DENOMINATOR - 1 );
int intval = (int)abs( f );
// Send the bit flags that indicate whether we have an integer part and/or a fraction part.
BF_WriteOneBit( bf, intval );
BF_WriteOneBit( bf, fractval );
if( intval || fractval )
{
// send the sign bit
BF_WriteOneBit( bf, signbit );
// send the integer if we have one.
if( intval )
{
// adjust the integers from [1..MAX_COORD_VALUE] to [0..MAX_COORD_VALUE-1]
intval--;
BF_WriteUBitLong( bf, (uint)intval, COORD_INTEGER_BITS );
}
// send the fraction if we have one
if( fractval )
{
BF_WriteUBitLong( bf, (uint)fractval, COORD_FRACTIONAL_BITS );
}
}
}
void BF_WriteCoord( sizebuf_t *bf, float val )
{
// g-cont. we loose precision here but keep old size of coord variable!
@ -330,6 +299,13 @@ void BF_WriteCoord( sizebuf_t *bf, float val )
else BF_WriteShort( bf, (int)( val * 8.0f ));
}
void BF_WriteVec3Coord( sizebuf_t *bf, const float *fa )
{
BF_WriteCoord( bf, fa[0] );
BF_WriteCoord( bf, fa[1] );
BF_WriteCoord( bf, fa[2] );
}
void BF_WriteBitFloat( sizebuf_t *bf, float val )
{
long intVal;
@ -341,57 +317,6 @@ void BF_WriteBitFloat( sizebuf_t *bf, float val )
BF_WriteUBitLong( bf, intVal, 32 );
}
void BF_WriteBitVec3Coord( sizebuf_t *bf, const float *fa )
{
int xflag, yflag, zflag;
xflag = ( fa[0] >= COORD_RESOLUTION ) || ( fa[0] <= -COORD_RESOLUTION );
yflag = ( fa[1] >= COORD_RESOLUTION ) || ( fa[1] <= -COORD_RESOLUTION );
zflag = ( fa[2] >= COORD_RESOLUTION ) || ( fa[2] <= -COORD_RESOLUTION );
BF_WriteOneBit( bf, xflag );
BF_WriteOneBit( bf, yflag );
BF_WriteOneBit( bf, zflag );
if( xflag ) BF_WriteBitCoord( bf, fa[0] );
if( yflag ) BF_WriteBitCoord( bf, fa[1] );
if( zflag ) BF_WriteBitCoord( bf, fa[2] );
}
void BF_WriteBitNormal( sizebuf_t *bf, float f )
{
int signbit = ( f <= -NORMAL_RESOLUTION );
uint fractval = abs(( int )(f * NORMAL_DENOMINATOR ));
if( fractval > NORMAL_DENOMINATOR )
fractval = NORMAL_DENOMINATOR;
// send the sign bit
BF_WriteOneBit( bf, signbit );
// send the fractional component
BF_WriteUBitLong( bf, fractval, NORMAL_FRACTIONAL_BITS );
}
void BF_WriteBitVec3Normal( sizebuf_t *bf, const float *fa )
{
int xflag, yflag;
int signbit;
xflag = ( fa[0] >= NORMAL_RESOLUTION ) || ( fa[0] <= -NORMAL_RESOLUTION );
yflag = ( fa[1] >= NORMAL_RESOLUTION ) || ( fa[1] <= -NORMAL_RESOLUTION );
BF_WriteOneBit( bf, xflag );
BF_WriteOneBit( bf, yflag );
if( xflag ) BF_WriteBitNormal( bf, fa[0] );
if( yflag ) BF_WriteBitNormal( bf, fa[1] );
// Write z sign bit
signbit = ( fa[2] <= -NORMAL_RESOLUTION );
BF_WriteOneBit( bf, signbit );
}
void BF_WriteChar( sizebuf_t *bf, int val )
{
BF_WriteSBitLong( bf, val, sizeof( char ) << 3 );
@ -604,103 +529,6 @@ uint BF_ReadBitLong( sizebuf_t *bf, int numbits, qboolean bSigned )
return BF_ReadUBitLong( bf, numbits );
}
// Basic Coordinate Routines (these contain bit-field size AND fixed point scaling constants)
float BF_ReadBitCoord( sizebuf_t *bf )
{
int intval = 0, fractval = 0, signbit = 0;
float value = 0.0;
// read the required integer and fraction flags
intval = BF_ReadOneBit( bf );
fractval = BF_ReadOneBit( bf );
// if we got either parse them, otherwise it's a zero.
if( intval || fractval )
{
// read the sign bit
signbit = BF_ReadOneBit( bf );
// if there's an integer, read it in
if( intval )
{
// adjust the integers from [0..MAX_COORD_VALUE-1] to [1..MAX_COORD_VALUE]
intval = BF_ReadUBitLong( bf, COORD_INTEGER_BITS ) + 1;
}
// if there's a fraction, read it in
if( fractval )
{
fractval = BF_ReadUBitLong( bf, COORD_FRACTIONAL_BITS );
}
// calculate the correct floating point value
value = intval + ((float)fractval * COORD_RESOLUTION );
// fixup the sign if negative.
if( signbit ) value = -value;
}
return value;
}
void BF_ReadBitVec3Coord( sizebuf_t *bf, vec3_t fa )
{
int xflag, yflag, zflag;
// This vector must be initialized! Otherwise, If any of the flags aren't set,
// the corresponding component will not be read and will be stack garbage.
fa[0] = fa[1] = fa[2] = 0.0f;
xflag = BF_ReadOneBit( bf );
yflag = BF_ReadOneBit( bf );
zflag = BF_ReadOneBit( bf );
if( xflag ) fa[0] = BF_ReadBitCoord( bf );
if( yflag ) fa[1] = BF_ReadBitCoord( bf );
if( zflag ) fa[2] = BF_ReadBitCoord( bf );
}
float BF_ReadBitNormal( sizebuf_t *bf )
{
// read the sign bit
int signbit = BF_ReadOneBit( bf );
// read the fractional part
uint fractval = BF_ReadUBitLong( bf, NORMAL_FRACTIONAL_BITS );
// calculate the correct floating point value
float value = (float)fractval * NORMAL_RESOLUTION;
// fixup the sign if negative.
if( signbit ) value = -value;
return value;
}
void BF_ReadBitVec3Normal( sizebuf_t *bf, vec3_t fa )
{
int xflag = BF_ReadOneBit( bf );
int yflag = BF_ReadOneBit( bf );
int znegative;
float fafafbfb;
if( xflag ) fa[0] = BF_ReadBitNormal( bf );
else fa[0] = 0.0f;
if( yflag ) fa[1] = BF_ReadBitNormal( bf );
else fa[1] = 0.0f;
// the first two imply the third (but not its sign)
znegative = BF_ReadOneBit( bf );
fafafbfb = fa[0] * fa[0] + fa[1] * fa[1];
if( fafafbfb < 1.0f )
fa[2] = sqrt( 1.0f - fafafbfb );
else fa[2] = 0.0f;
if( znegative ) fa[2] = -fa[2];
}
int BF_ReadChar( sizebuf_t *bf )
{
return BF_ReadSBitLong( bf, sizeof( char ) << 3 );
@ -729,6 +557,13 @@ float BF_ReadCoord( sizebuf_t *bf )
return (float)(BF_ReadShort( bf ) * ( 1.0f / 8.0f ));
}
void BF_ReadVec3Coord( sizebuf_t *bf, vec3_t fa )
{
fa[0] = BF_ReadCoord( bf );
fa[1] = BF_ReadCoord( bf );
fa[2] = BF_ReadCoord( bf );
}
long BF_ReadLong( sizebuf_t *bf )
{
return BF_ReadSBitLong( bf, sizeof( long ) << 3 );

View File

@ -76,11 +76,7 @@ void BF_WriteSBitLong( sizebuf_t *bf, int data, int numbits );
void BF_WriteBitLong( sizebuf_t *bf, uint data, int numbits, qboolean bSigned );
qboolean BF_WriteBits( sizebuf_t *bf, const void *pData, int nBits );
void BF_WriteBitAngle( sizebuf_t *bf, float fAngle, int numbits );
void BF_WriteBitCoord( sizebuf_t *bf, const float f );
void BF_WriteBitFloat( sizebuf_t *bf, float val );
void BF_WriteBitVec3Coord( sizebuf_t *bf, const float *fa );
void BF_WriteBitNormal( sizebuf_t *bf, float f );
void BF_WriteBitVec3Normal( sizebuf_t *bf, const float *fa );
// Byte-write functions
void BF_WriteChar( sizebuf_t *bf, int val );
@ -90,6 +86,7 @@ void BF_WriteWord( sizebuf_t *bf, int val );
void BF_WriteLong( sizebuf_t *bf, long val );
void BF_WriteCoord( sizebuf_t *bf, float val );
void BF_WriteFloat( sizebuf_t *bf, float val );
void BF_WriteVec3Coord( sizebuf_t *bf, const float *fa );
qboolean BF_WriteBytes( sizebuf_t *bf, const void *pBuf, int nBytes ); // same as MSG_WriteData
qboolean BF_WriteString( sizebuf_t *bf, const char *pStr ); // returns false if it overflows the buffer.
@ -114,10 +111,6 @@ float BF_ReadBitAngle( sizebuf_t *bf, int numbits );
int BF_ReadSBitLong( sizebuf_t *bf, int numbits );
uint BF_ReadUBitLong( sizebuf_t *bf, int numbits );
uint BF_ReadBitLong( sizebuf_t *bf, int numbits, qboolean bSigned );
float BF_ReadBitCoord( sizebuf_t *bf );
void BF_ReadBitVec3Coord( sizebuf_t *bf, vec3_t fa );
float BF_ReadBitNormal( sizebuf_t *bf );
void BF_ReadBitVec3Normal( sizebuf_t *bf, vec3_t fa );
// Byte-read functions
int BF_ReadChar( sizebuf_t *bf );
@ -127,6 +120,7 @@ int BF_ReadWord( sizebuf_t *bf );
long BF_ReadLong( sizebuf_t *bf );
float BF_ReadCoord( sizebuf_t *bf );
float BF_ReadFloat( sizebuf_t *bf );
void BF_ReadVec3Coord( sizebuf_t *bf, vec3_t fa );
qboolean BF_ReadBytes( sizebuf_t *bf, void *pOut, int nBytes );
char *BF_ReadStringExt( sizebuf_t *bf, qboolean bLine );

View File

@ -16,7 +16,7 @@ GNU General Public License for more details.
#ifndef PROTOCOL_H
#define PROTOCOL_H
#define PROTOCOL_VERSION 46
#define PROTOCOL_VERSION 47
// server to client
#define svc_bad 0 // immediately crash client when received
@ -110,9 +110,7 @@ GNU General Public License for more details.
#define MAX_EDICTS (1<<MAX_ENTITY_BITS)// 12 bits = 4096 edicts
#define MAX_CUSTOM 1024 // max custom resources per level
#define MAX_USER_MESSAGES 191 // another 63 messages reserved for engine routines
#define MAX_DLIGHTS 32 // dynamic lights (rendered per one frame)
#define MAX_ELIGHTS 64 // entity only point lights
#define MAX_LIGHTSTYLES 256 // a byte limit, don't modify
@ -127,7 +125,7 @@ GNU General Public License for more details.
#define SND_STOP (1<<5) // stop the sound
#define SND_CHANGE_VOL (1<<6) // change sound vol
#define SND_CHANGE_PITCH (1<<7) // change sound pitch
#define SND_SPAWNING (1<<8) // we're spawning, used in some cases for ambients
#define SND_SPAWNING (1<<8) // we're spawning, used in some cases for ambients (not sent across network)
// decal flags
#define FDECAL_PERMANENT 0x01 // This decal should not be removed in favor of any new decals
@ -142,28 +140,7 @@ GNU General Public License for more details.
#define NUM_BACKUP_COMMAND_BITS 4
#define MAX_BACKUP_COMMANDS (1 << NUM_BACKUP_COMMAND_BITS)
// world size
#define MAX_COORD_INTEGER (16384) // world half-size, modify with precaution
#define MIN_COORD_INTEGER (-MAX_COORD_INTEGER)
#define MAX_COORD_FRACTION ( 1.0 - ( 1.0 / 16.0 ))
#define MIN_COORD_FRACTION (-1.0 + ( 1.0 / 16.0 ))
// network precision
#define COORD_INTEGER_BITS 14
#define COORD_FRACTIONAL_BITS 5
#define COORD_DENOMINATOR ( 1 << ( COORD_FRACTIONAL_BITS ))
#define COORD_RESOLUTION (1.0 / ( COORD_DENOMINATOR ))
#define NORMAL_FRACTIONAL_BITS 11
#define NORMAL_DENOMINATOR (( 1 << ( NORMAL_FRACTIONAL_BITS )) - 1 )
#define NORMAL_RESOLUTION ( 1.0 / ( NORMAL_DENOMINATOR ))
// verify that coordsize.h and worldsize.h are consistently defined
#if( MAX_COORD_INTEGER != ( 1 << COORD_INTEGER_BITS ))
#error MAX_COORD_INTEGER does not match COORD_INTEGER_BITS
#endif
#define MAX_RESOURCES (MAX_MODELS+MAX_SOUNDS+MAX_CUSTOM+MAX_EVENTS)
#define MAX_RESOURCES (MAX_MODELS+MAX_SOUNDS+MAX_CUSTOM+MAX_EVENTS)
typedef struct
{

View File

@ -90,7 +90,6 @@ typedef struct
int fEnabled;
int fPlayLooping;
float cdvolume;
//BYTE remap[100];
int fCDRom;
int fPlayTrack;
} CDStatus;
@ -288,36 +287,32 @@ typedef struct KeyValueData_s
typedef struct
{
char mapName[32];
char landmarkName[32];
edict_t *pentLandmark;
vec3_t vecLandmarkOrigin;
char mapName[32];
char landmarkName[32];
edict_t *pentLandmark;
vec3_t vecLandmarkOrigin;
} LEVELLIST;
#define MAX_LEVEL_CONNECTIONS 16 // These are encoded in the lower 16bits of ENTITYTABLE->flags
typedef struct
{
int id; // Ordinal ID of this entity (used for entity <--> pointer conversions)
edict_t *pent; // Pointer to the in-game entity
int id; // Ordinal ID of this entity (used for entity <--> pointer conversions)
edict_t *pent; // Pointer to the in-game entity
int location; // Offset from the base data of this entity
int size; // Byte size of this entity's data
int flags; // This could be a short -- bit mask of transitions that this entity is in the PVS of
string_t classname; // entity class name
int location; // Offset from the base data of this entity
int size; // Byte size of this entity's data
int flags; // This could be a short -- bit mask of transitions that this entity is in the PVS of
string_t classname; // entity class name
} ENTITYTABLE;
#define MAX_LEVEL_CONNECTIONS 16 // These are encoded in the lower 16bits of ENTITYTABLE->flags
#define FENTTABLE_PLAYER 0x80000000
#define FENTTABLE_REMOVED 0x40000000
#define FENTTABLE_MOVEABLE 0x20000000
#define FENTTABLE_GLOBAL 0x10000000
typedef struct saverestore_s SAVERESTOREDATA;
#ifdef _WIN32
typedef
#endif
struct saverestore_s
typedef struct saverestore_s
{
char *pBaseData; // Start of all entity save data
char *pCurrentData; // Current buffer pointer for sequential access
@ -338,12 +333,7 @@ struct saverestore_s
vec3_t vecLandmarkOffset; // for landmark transitions
float time;
char szCurrentMapName[32]; // To check global entities
}
#ifdef _WIN32
SAVERESTOREDATA
#endif
;
} SAVERESTOREDATA;
typedef enum _fieldtypes
{
@ -380,8 +370,10 @@ typedef enum _fieldtypes
#define DEFINE_ENTITY_GLOBAL_FIELD(name,fieldtype) _FIELD(entvars_t, name, fieldtype, 1, FTYPEDESC_GLOBAL )
#define DEFINE_GLOBAL_FIELD(type,name,fieldtype) _FIELD(type, name, fieldtype, 1, FTYPEDESC_GLOBAL )
#define FTYPEDESC_GLOBAL 0x0001 // This field is masked for global entity save/restore
#define FTYPEDESC_GLOBAL 0x0001 // This field is masked for global entity save/restore
#define FTYPEDESC_SAVE 0x0002 // This field is saved to disk
#define FTYPEDESC_KEY 0x0004 // This field can be requested and written to by string name at load time
#define FTYPEDESC_FUNCTIONTABLE 0x0008 // This is a table entry for a member function pointer
typedef struct
{

View File

@ -90,7 +90,7 @@ typedef struct ui_enginefuncs_s
void (*pfnDrawLogo)( const char *filename, float x, float y, float width, float height );
int (*pfnGetLogoWidth)( void );
int (*pfnGetLogoHeight)( void );
float (*pfnGetLogoLength)( void );
float (*pfnGetLogoLength)( void ); // cinematic duration in seconds
// text message system
void (*pfnDrawCharacter)( int x, int y, int width, int height, int ch, int ulRGBA, HIMAGE hFont );
@ -142,7 +142,7 @@ typedef struct ui_enginefuncs_s
char **(*pfnGetFilesList)( const char *pattern, int *numFiles, int gamedironly ); // find in files
int (*pfnGetSaveComment)( const char *savename, char *comment );
int (*pfnGetDemoComment)( const char *demoname, char *comment );
int (*pfnCheckGameDll)( void ); // returns false if hl.dll is missed
int (*pfnCheckGameDll)( void ); // returns false if hl.dll is missed or invalid
char *(*pfnGetClipboardData)( void );
// engine launcher

View File

@ -94,6 +94,12 @@ typedef struct physics_interface_s
void (*pfnCreateEntitiesInTransitionList)( SAVERESTOREDATA*, int levelMask );
// called through save\restore process
void (*pfnCreateEntitiesInRestoreList)( SAVERESTOREDATA*, int createPlayers );
// allocate custom string (e.g. using user implementation of stringtable, not engine strings)
string_t (*pfnAllocString)( const char *szValue );
// make custom string (e.g. using user implementation of stringtable, not engine strings)
string_t (*pfnMakeString)( const char *szValue );
// read custom string (e.g. using user implementation of stringtable, not engine strings)
const char* (*pfnGetString)( string_t iString );
} physics_interface_t;
#endif//PHYSINT_H

View File

@ -50,7 +50,7 @@ extern int SV_UPDATE_BACKUP;
#define EDICT_NUM( num ) SV_EDICT_NUM( num, __FILE__, __LINE__ )
#define STRING( offset ) SV_GetString( offset )
#define ALLOC_STRING(str) SV_AllocString( str )
#define MAKE_STRING(str) (int)(str - svgame.globals->pStringBase)
#define MAKE_STRING(str) SV_MakeString( str )
#define MAX_PUSHED_ENTS 256
#define MAX_CAMERAS 32
@ -176,7 +176,7 @@ typedef struct
clientdata_t clientdata;
weapon_data_t weapondata[MAX_WEAPONS];
weapon_data_t oldweapondata[MAX_WEAPONS]; // g-cont. The fucking Cry Of Fear a corrupt memory after the weapondata!!!
weapon_data_t oldweapondata[MAX_WEAPONS]; // g-cont. The fucking Cry Of Fear a does corrupting memory after the weapondata!!!
int num_entities;
int first_entity; // into the circular sv_packet_entities[]
@ -185,6 +185,7 @@ typedef struct
typedef struct sv_client_s
{
cl_state_t state;
char name[32]; // extracted from userinfo, color string allowed
char userinfo[MAX_INFO_STRING]; // name, etc (received from client)
char physinfo[MAX_INFO_STRING]; // set on server (transmit to client)
@ -229,7 +230,6 @@ typedef struct sv_client_s
edict_t *edict; // EDICT_NUM(clientnum+1)
edict_t *pViewEntity; // svc_setview member
char name[32]; // extracted from userinfo, color string allowed
int messagelevel; // for filtering printed messages
edict_t *cameras[MAX_CAMERAS]; // list of portal cameras in player PVS
@ -315,13 +315,12 @@ typedef struct
int msg_realsize; // left in bytes
int msg_index; // for debug messages
int msg_dest; // msg destination ( MSG_ONE, MSG_ALL etc )
qboolean msg_started; // to avoid include messages
qboolean msg_system; // this is message with engine index
qboolean msg_started; // to avoid recursive included messages
edict_t *msg_ent; // user message member entity
vec3_t msg_org; // user message member origin
// catched user messages (nasty hack)
int gmsgHudText; // -1 if not catched
int gmsgHudText; // -1 if not catched (e.g. mod not registered this message)
void *hInstance; // pointer to game.dll
@ -339,15 +338,15 @@ typedef struct
sv_pushed_t pushed[MAX_PUSHED_ENTS]; // no reason to keep array for all edicts
// 256 it should be enough for any game situation
vec3_t player_mins[4]; // 4 hulls allowed
vec3_t player_maxs[4]; // 4 hulls allowed
vec3_t player_mins[MAX_MAP_HULLS]; // 4 hulls allowed
vec3_t player_maxs[MAX_MAP_HULLS]; // 4 hulls allowed
globalvars_t *globals; // server globals
DLL_FUNCTIONS dllFuncs; // dll exported funcs
NEW_DLL_FUNCTIONS dllFuncs2; // new dll exported funcs (can be NULL)
NEW_DLL_FUNCTIONS dllFuncs2; // new dll exported funcs (may be NULL)
physics_interface_t physFuncs; // physics interface functions (Xash3D extension)
byte *mempool; // server premamnent pool: edicts etc
byte *stringspool; // for shared strings
byte *stringspool; // for engine strings
SAVERESTOREDATA SaveData; // shared struct, used for save data
} svgame_static_t;
@ -365,7 +364,7 @@ typedef struct
// used to check late spawns
sv_client_t *clients; // [sv_maxclients->integer]
sv_client_t *currentPlayer; // current client who network message sending on
int currentPlayerNum; // for esay acess to some global arrays
int currentPlayerNum; // for easy acess to some global arrays
int num_client_entities; // sv_maxclients->integer*UPDATE_BACKUP*MAX_PACKET_ENTITIES
int next_client_entities; // next client_entity to use
entity_state_t *packet_entities; // [num_client_entities]
@ -380,6 +379,7 @@ typedef struct
extern server_static_t svs; // persistant server info
extern server_t sv; // local server
extern svgame_static_t svgame; // persistant game info
extern areanode_t sv_areanodes[]; // AABB dynamic tree
extern convar_t *sv_pausable; // allows pause in multiplayer
extern convar_t *sv_newunit;
@ -423,6 +423,10 @@ extern convar_t *sv_validate_changelevel;
extern convar_t *mp_consistency;
extern convar_t *public_server;
extern convar_t *physinfo;
extern convar_t *deathmatch;
extern convar_t *teamplay;
extern convar_t *skill;
extern convar_t *coop;
//===========================================================
//
@ -562,8 +566,9 @@ float SV_AngleMod( float ideal, float current, float speed );
void SV_SpawnEntities( const char *mapname, char *entities );
edict_t* SV_AllocPrivateData( edict_t *ent, string_t className );
string_t SV_AllocString( const char *szValue );
sv_client_t *SV_ClientFromEdict( const edict_t *pEdict, qboolean spawned_only );
string_t SV_MakeString( const char *szValue );
const char *SV_GetString( string_t iString );
sv_client_t *SV_ClientFromEdict( const edict_t *pEdict, qboolean spawned_only );
void SV_SetClientMaxspeed( sv_client_t *cl, float fNewMaxspeed );
int SV_MapIsValid( const char *filename, const char *spawn_entity, const char *landmark_name );
void SV_StartSound( edict_t *ent, int chan, const char *sample, float vol, float attn, int flags, int pitch );
@ -592,9 +597,9 @@ void SV_ClearSaveDir( void );
void SV_SaveGame( const char *pName );
qboolean SV_LoadGame( const char *pName );
void SV_ChangeLevel( qboolean loadfromsavedgame, const char *mapname, const char *start );
const char *SV_GetLatestSave( void );
int SV_LoadGameState( char const *level, qboolean createPlayers );
void SV_LoadAdjacentEnts( const char *pOldLevel, const char *pLandmarkName );
const char *SV_GetLatestSave( void );
void SV_InitSaveRestore( void );
//
@ -606,9 +611,6 @@ void SV_GetTrueMinMax( sv_client_t *cl, int edictnum, vec3_t mins, vec3_t maxs )
//
// sv_world.c
//
extern areanode_t sv_areanodes[];
void SV_ClearWorld( void );
void SV_UnlinkEdict( edict_t *ent );
qboolean SV_HeadnodeVisible( mnode_t *node, byte *visbits, int *lastleaf );

View File

@ -19,7 +19,7 @@ GNU General Public License for more details.
#include "net_encode.h"
#include "net_api.h"
const char *clc_strings[9] =
const char *clc_strings[11] =
{
"clc_bad",
"clc_nop",
@ -30,6 +30,8 @@ const char *clc_strings[9] =
"clc_userinfo",
"clc_fileconsistency",
"clc_voicedata",
"clc_requestcvarvalue",
"clc_requestcvarvalue2",
};
typedef struct ucmd_s
@ -57,11 +59,13 @@ void SV_GetChallenge( netadr_t from )
double oldestTime;
oldestTime = 0x7fffffff;
// see if we already have a challenge for this ip
for (i = 0; i < MAX_CHALLENGES; i++ )
for( i = 0; i < MAX_CHALLENGES; i++ )
{
if( !svs.challenges[i].connected && NET_CompareAdr( from, svs.challenges[i].adr ))
break;
if( svs.challenges[i].time < oldestTime )
{
oldestTime = svs.challenges[i].time;
@ -92,9 +96,9 @@ A connection request that did not come from the master
*/
void SV_DirectConnect( netadr_t from )
{
char physinfo[512];
char userinfo[MAX_INFO_STRING];
sv_client_t temp, *cl, *newcl;
char physinfo[512];
int i, edictnum;
int qport, version;
int count = 0;
@ -102,6 +106,7 @@ void SV_DirectConnect( netadr_t from )
edict_t *ent;
version = Q_atoi( Cmd_Argv( 1 ));
if( version != PROTOCOL_VERSION )
{
Netchan_OutOfBandPrint( NS_SERVER, from, "print\nServer uses protocol version %i.\n", PROTOCOL_VERSION );
@ -117,7 +122,9 @@ void SV_DirectConnect( netadr_t from )
// quick reject
for( i = 0, cl = svs.clients; i < sv_maxclients->integer; i++, cl++ )
{
if( cl->state == cs_free ) continue;
if( cl->state == cs_free )
continue;
if( NET_CompareBaseAdr( from, cl->netchan.remote_address ) && ( cl->netchan.qport == qport || from.port == cl->netchan.remote_address.port ))
{
if( !NET_IsLocalAddress( from ) && ( host.realtime - cl->lastconnect ) < sv_reconnect_limit->value )
@ -147,8 +154,8 @@ void SV_DirectConnect( netadr_t from )
return;
}
svs.challenges[i].connected = true;
MsgDev( D_NOTE, "Client %i connecting with challenge %p\n", i, challenge );
svs.challenges[i].connected = true;
}
// force the IP key/value pair so the game can filter based on ip
@ -160,7 +167,9 @@ void SV_DirectConnect( netadr_t from )
// if there is already a slot for this ip, reuse it
for( i = 0, cl = svs.clients; i < sv_maxclients->integer; i++, cl++ )
{
if( cl->state == cs_free ) continue;
if( cl->state == cs_free )
continue;
if( NET_CompareBaseAdr( from, cl->netchan.remote_address ) && ( cl->netchan.qport == qport || from.port == cl->netchan.remote_address.port ))
{
MsgDev( D_INFO, "%s:reconnect\n", NET_AdrToString( from ));
@ -171,7 +180,8 @@ void SV_DirectConnect( netadr_t from )
// find a client slot
newcl = NULL;
for( i = 0, cl = svs.clients; i < sv_maxclients->integer; i++, cl++)
for( i = 0, cl = svs.clients; i < sv_maxclients->integer; i++, cl++ )
{
if( cl->state == cs_free )
{
@ -183,7 +193,7 @@ void SV_DirectConnect( netadr_t from )
if( !newcl )
{
Netchan_OutOfBandPrint( NS_SERVER, from, "print\nServer is full.\n" );
MsgDev( D_INFO, "SV_DirectConnect: rejected a connection.\n");
MsgDev( D_INFO, "SV_DirectConnect: rejected a connection.\n" );
return;
}
@ -191,7 +201,8 @@ void SV_DirectConnect( netadr_t from )
// accept the new client
gotnewcl:
// this is the only place a sv_client_t is ever initialized
if( sv_maxclients->integer == 1 ) // save physinfo for singleplayer
if( sv_maxclients->integer == 1 ) // save physinfo for singleplayer
Q_strncpy( physinfo, newcl->physinfo, sizeof( physinfo ));
*newcl = temp;
@ -216,6 +227,7 @@ gotnewcl:
if( *Info_ValueForKey( userinfo, "rejmsg" ))
Netchan_OutOfBandPrint( NS_SERVER, from, "print\n%s\nConnection refused.\n", Info_ValueForKey( userinfo, "rejmsg" ));
else Netchan_OutOfBandPrint( NS_SERVER, from, "print\nConnection refused.\n" );
MsgDev( D_ERROR, "SV_DirectConnect: game rejected a connection.\n");
SV_DropClient( newcl );
return;
@ -241,6 +253,7 @@ gotnewcl:
// the server can hold, send a heartbeat to the master.
for( i = 0, cl = svs.clients; i < sv_maxclients->integer; i++, cl++ )
if( cl->state >= cs_connected ) count++;
if( count == 1 || count == sv_maxclients->integer )
svs.last_heartbeat = MAX_HEARTBEAT;
}
@ -291,8 +304,8 @@ edict_t *SV_FakeConnect( const char *netname )
// setup fake client params
Info_SetValueForKey( userinfo, "name", netname );
Info_SetValueForKey( userinfo, "model", "gordon" );
Info_SetValueForKey( userinfo, "topcolor", "1" );
Info_SetValueForKey( userinfo, "bottomcolor", "1" );
Info_SetValueForKey( userinfo, "topcolor", "0" );
Info_SetValueForKey( userinfo, "bottomcolor", "0" );
// force the IP key/value pair so the game can filter based on ip
Info_SetValueForKey( userinfo, "ip", "127.0.0.1" );
@ -300,6 +313,7 @@ edict_t *SV_FakeConnect( const char *netname )
// find a client slot
newcl = &temp;
Q_memset( newcl, 0, sizeof( sv_client_t ));
for( i = 0, cl = svs.clients; i < sv_maxclients->integer; i++, cl++ )
{
if( cl->state == cs_free )
@ -333,7 +347,6 @@ edict_t *SV_FakeConnect( const char *netname )
newcl->fakeclient = true;
newcl->delta_sequence = -1;
newcl->userid = g_userid++; // create unique userid
ent->v.flags |= FL_FAKECLIENT; // mark it as fakeclient
// get the game a chance to reject this connection or modify the userinfo
if( !SV_ClientConnect( ent, userinfo ))
@ -347,6 +360,7 @@ edict_t *SV_FakeConnect( const char *netname )
MsgDev( D_NOTE, "Bot %i connecting with challenge %p\n", i, -1 );
ent->v.flags |= FL_FAKECLIENT; // mark it as fakeclient
newcl->state = cs_spawned;
newcl->lastmessage = host.realtime; // don't timeout
newcl->lastconnect = host.realtime;
@ -518,6 +532,7 @@ char *SV_StatusString( void )
playerLength = Q_strlen( player );
if( statusLength + playerLength >= sizeof( status ))
break; // can't hold any more
Q_strcpy( status + statusLength, player );
statusLength += playerLength;
}
@ -632,6 +647,7 @@ void SV_Info( netadr_t from )
Info_SetValueForKey( string, "maxcl", va( "%i", sv_maxclients->integer ));
Info_SetValueForKey( string, "gamedir", GI->gamefolder );
}
Netchan_OutOfBandPrint( NS_SERVER, from, "info\n%s", string );
}
@ -720,6 +736,11 @@ void SV_Ping( netadr_t from )
Netchan_OutOfBandPrint( NS_SERVER, from, "ack" );
}
/*
================
Rcon_Validate
================
*/
qboolean Rcon_Validate( void )
{
if( !Q_strlen( rcon_password->string ))
@ -867,6 +888,12 @@ void SV_FullClientUpdate( sv_client_t *cl, sizebuf_t *msg )
else BF_WriteOneBit( msg, 0 );
}
/*
===================
SV_RefreshUserinfo
===================
*/
void SV_RefreshUserinfo( void )
{
int i;
@ -913,9 +940,16 @@ qboolean SV_ShouldUpdatePing( sv_client_t *cl )
cl->next_checkpingtime = host.realtime + 2.0;
return true;
}
return false;
}
/*
===================
SV_IsPlayerIndex
===================
*/
qboolean SV_IsPlayerIndex( int idx )
{
if( idx > 0 && idx <= sv_maxclients->integer )
@ -1169,7 +1203,7 @@ void SV_SendResourceList_f( sv_client_t *cl )
{
int index = 0;
int rescount = 0;
resourcelist_t reslist;
resourcelist_t reslist; // g-cont. what about stack???
size_t msg_size;
Q_memset( &reslist, 0, sizeof( resourcelist_t ));
@ -1844,7 +1878,7 @@ SV_SendRes_f
void SV_SendRes_f( sv_client_t *cl )
{
sizebuf_t msg;
byte buffer[65535];
byte buffer[65535]; // g-cont. what about stack??
if( cl->state != cs_connected )
{
@ -2140,7 +2174,7 @@ void SV_ParseCvarValue( sv_client_t *cl, sizebuf_t *msg )
{
const char *value = BF_ReadString( msg );
if( svgame.dllFuncs2.pfnCvarValue )
if( svgame.dllFuncs2.pfnCvarValue != NULL )
svgame.dllFuncs2.pfnCvarValue( cl->edict, value );
MsgDev( D_AICONSOLE, "Cvar query response: name:%s, value:%s\n", cl->name, value );
}
@ -2159,7 +2193,7 @@ void SV_ParseCvarValue2( sv_client_t *cl, sizebuf_t *msg )
Q_strcpy( name, BF_ReadString( msg ));
Q_strcpy( value, BF_ReadString( msg ));
if( svgame.dllFuncs2.pfnCvarValue2 )
if( svgame.dllFuncs2.pfnCvarValue2 != NULL )
svgame.dllFuncs2.pfnCvarValue2( cl->edict, requestID, name, value );
MsgDev( D_AICONSOLE, "Cvar query response: name:%s, request ID %d, cvar:%s, value:%s\n", cl->name, requestID, name, value );
}

View File

@ -109,6 +109,12 @@ qboolean SV_SetPlayer( void )
sv_client_t *cl;
int i, idnum;
if( !svs.clients )
{
Msg( "^3no server running.\n" );
return false;
}
if( sv_maxclients->integer == 1 || Cmd_Argc() < 2 )
{
// special case for local client
@ -120,7 +126,7 @@ qboolean SV_SetPlayer( void )
s = Cmd_Argv( 1 );
// numeric values are just slot numbers
if( s[0] >= '0' && s[0] <= '9' )
if( Q_isdigit( s ) || (s[0] == '-' && Q_isdigit( s + 1 )))
{
idnum = Q_atoi( s );
if( idnum < 0 || idnum >= sv_maxclients->integer )
@ -207,6 +213,10 @@ void SV_Map_f( void )
return;
}
// changing singleplayer to multiplayer or back. refresh the player count
if(( sv_maxclients->modified ) || ( deathmatch->modified ) || ( coop->modified ) || ( teamplay->modified ))
Host_ShutdownServer();
SCR_BeginLoadingPlaque( false );
sv.changelevel = false;
@ -499,7 +509,8 @@ restarts current level
*/
void SV_Restart_f( void )
{
if( sv.state != ss_active ) return;
if( sv.state != ss_active )
return;
// just sending console command
if( sv.background )
@ -512,6 +523,13 @@ void SV_Restart_f( void )
}
}
/*
==================
SV_Reload_f
continue from latest savedgame
==================
*/
void SV_Reload_f( void )
{
const char *save;
@ -521,6 +539,7 @@ void SV_Reload_f( void )
return;
save = SV_GetLatestSave();
if( save )
{
FS_FileBase( save, loadname );
@ -673,6 +692,12 @@ void SV_ConSay_f( void )
if( Cmd_Argc() < 2 ) return;
if( !svs.clients )
{
Msg( "^3no server running.\n" );
return;
}
Q_strncpy( text, "console: ", MAX_SYSPATH );
p = Cmd_Args();
@ -681,11 +706,14 @@ void SV_ConSay_f( void )
p++;
p[Q_strlen(p) - 1] = 0;
}
Q_strncat( text, p, MAX_SYSPATH );
for( i = 0, client = svs.clients; i < sv_maxclients->integer; i++, client++ )
{
if( client->state != cs_spawned ) continue;
if( client->state != cs_spawned )
continue;
SV_ClientPrintf( client, PRINT_CHAT, "%s\n", text );
}
}
@ -767,6 +795,12 @@ void SV_PlayersOnly_f( void )
else SV_BroadcastPrintf( D_INFO, "Freeze server physic\n" );
}
/*
===============
SV_EdictsInfo_f
===============
*/
void SV_EdictsInfo_f( void )
{
int active;
@ -783,6 +817,12 @@ void SV_EdictsInfo_f( void )
Msg( "%5i total\n", svgame.globals->maxEntities );
}
/*
===============
SV_EntityInfo_f
===============
*/
void SV_EntityInfo_f( void )
{
edict_t *ent;
@ -863,6 +903,11 @@ void SV_InitOperatorCommands( void )
}
}
/*
==================
SV_KillOperatorCommands
==================
*/
void SV_KillOperatorCommands( void )
{
Cmd_RemoveCommand( "heartbeat" );
@ -875,7 +920,7 @@ void SV_KillOperatorCommands( void )
Cmd_RemoveCommand( "map" );
Cmd_RemoveCommand( "newgame" );
Cmd_RemoveCommand( "endgame" );
Cmd_RemoveCommand( "killgame" );
Cmd_RemoveCommand( "hazardcourse" );
Cmd_RemoveCommand( "changelevel" );
Cmd_RemoveCommand( "restart" );
@ -887,7 +932,6 @@ void SV_KillOperatorCommands( void )
if( host.type == HOST_DEDICATED )
{
Cmd_RemoveCommand( "say" );
Cmd_RemoveCommand( "setmaster" );
Cmd_RemoveCommand( "killserver" );
}
else

View File

@ -71,7 +71,8 @@ static void SV_AddEntitiesToPacket( edict_t *pViewEnt, edict_t *pClient, client_
if( !sv.state ) return;
cl = SV_ClientFromEdict( pClient, true );
ASSERT( cl );
ASSERT( cl != NULL );
if( pClient && !( sv.hostflags & SVF_PORTALPASS ))
{
@ -658,7 +659,7 @@ void SV_UpdateToReliableMessages( void )
}
// 1% chanse for simulate random network bugs
if( sv.write_bad_message && Com_RandomLong( 0, 512 ) == 443 )
if( sv.write_bad_message && Com_RandomLong( 0, 512 ) == 404 )
{
// just for network debugging (send only for local client)
BF_WriteByte( &sv.datagram, svc_bad );
@ -867,7 +868,8 @@ void SV_InactivateClients( void )
// send a message to each connected client
for( i = 0, cl = svs.clients; i < sv_maxclients->integer; i++, cl++ )
{
if( !cl->state || !cl->edict ) continue;
if( !cl->state || !cl->edict )
continue;
if( !cl->edict || (cl->edict->v.flags & FL_FAKECLIENT))
continue;

View File

@ -77,14 +77,17 @@ TYPEDESCRIPTION *SV_GetEntvarsDescirption( int number )
void SV_SysError( const char *error_string )
{
if( svgame.hInstance ) svgame.dllFuncs.pfnSys_Error( error_string );
if( svgame.hInstance != NULL )
svgame.dllFuncs.pfnSys_Error( error_string );
}
void SV_SetMinMaxSize( edict_t *e, const float *min, const float *max )
{
int i;
if( !SV_IsValidEdict( e ) || !min || !max )
ASSERT( min != NULL && max != NULL );
if( !SV_IsValidEdict( e ))
return;
for( i = 0; i < 3; i++ )
@ -191,8 +194,6 @@ convert trace_t to TraceResult
*/
void SV_ConvertTrace( TraceResult *dst, trace_t *src )
{
ASSERT( src != NULL && dst != NULL );
dst->fAllSolid = src->allsolid;
dst->fStartSolid = src->startsolid;
dst->fInOpen = src->inopen;
@ -232,8 +233,8 @@ qboolean SV_CheckClientVisiblity( sv_client_t *cl, const byte *mask )
// -1 is because pvs rows are 1 based, not 0 based like leafs
leafnum = Mod_PointLeafnum( viewOrg ) - 1;
if( leafnum == -1 || (mask[leafnum>>3] & (1<<( leafnum & 7 ))))
return true; // visible from player view of camera view
#if 1
return true; // visible from player view or camera view
// now check all the portal cameras
for( i = 0; i < cl->num_cameras; i++ )
{
@ -247,7 +248,7 @@ qboolean SV_CheckClientVisiblity( sv_client_t *cl, const byte *mask )
if( leafnum == -1 || (mask[leafnum>>3] & (1<<( leafnum & 7 ))))
return true;
}
#endif
// not visible from any viewpoint
return false;
}
@ -323,7 +324,7 @@ qboolean SV_Send( int dest, const vec3_t origin, const edict_t *ent )
specproxy = reliable = true;
break;
default:
Host_Error( "SV_Multicast: bad dest: %i\n", dest );
Host_Error( "SV_Send: bad dest: %i\n", dest );
return false;
}
@ -371,9 +372,8 @@ NOTE: static decals only accepted when game is loading
*/
void SV_CreateDecal( const float *origin, int decalIndex, int entityIndex, int modelIndex, int flags )
{
if( sv.state != ss_loading ) return;
ASSERT( origin );
if( sv.state != ss_loading )
return;
// this can happens if serialized map contain 4096 static decals...
if(( BF_GetNumBytesWritten( &sv.signon ) + 20 ) >= BF_GetMaxBytes( &sv.signon ))
@ -381,7 +381,7 @@ void SV_CreateDecal( const float *origin, int decalIndex, int entityIndex, int m
// static decals are posters, it's always reliable
BF_WriteByte( &sv.signon, svc_bspdecal );
BF_WriteBitVec3Coord( &sv.signon, origin );
BF_WriteVec3Coord( &sv.signon, origin );
BF_WriteWord( &sv.signon, decalIndex );
BF_WriteShort( &sv.signon, entityIndex );
if( entityIndex > 0 )
@ -398,7 +398,8 @@ NOTE: static decals only accepted when game is loading
*/
void SV_CreateStudioDecal( const float *origin, const float *start, int decalIndex, int entityIndex, int modelIndex, int flags, modelstate_t *state )
{
if( sv.state != ss_loading ) return;
if( sv.state != ss_loading )
return;
// bad model or bad entity (e.g. changelevel)
if( !entityIndex || !modelIndex )
@ -413,12 +414,8 @@ void SV_CreateStudioDecal( const float *origin, const float *start, int decalInd
// static decals are posters, it's always reliable
BF_WriteByte( &sv.signon, svc_studiodecal );
BF_WriteCoord( &sv.signon, origin[0] );
BF_WriteCoord( &sv.signon, origin[1] );
BF_WriteCoord( &sv.signon, origin[2] );
BF_WriteCoord( &sv.signon, start[0] );
BF_WriteCoord( &sv.signon, start[1] );
BF_WriteCoord( &sv.signon, start[2] );
BF_WriteVec3Coord( &sv.signon, origin );
BF_WriteVec3Coord( &sv.signon, start );
BF_WriteWord( &sv.signon, decalIndex );
BF_WriteShort( &sv.signon, entityIndex );
BF_WriteByte( &sv.signon, flags );
@ -448,7 +445,7 @@ void SV_CreateStaticEntity( sv_static_entity_t *ent )
{
int index, i;
// this can happens if serialized map contain 4096 static decals...
// this can happens if serialized map contain too many static entities...
if(( BF_GetNumBytesWritten( &sv.signon ) + 64 ) >= BF_GetMaxBytes( &sv.signon ))
return;
@ -463,7 +460,7 @@ void SV_CreateStaticEntity( sv_static_entity_t *ent )
for( i = 0; i < 3; i++ )
{
BF_WriteBitCoord( &sv.signon, ent->origin[i] );
BF_WriteCoord( &sv.signon, ent->origin[i] );
BF_WriteBitAngle( &sv.signon, ent->angles[i], 16 );
}
@ -479,35 +476,6 @@ void SV_CreateStaticEntity( sv_static_entity_t *ent )
}
}
static qboolean SV_OriginIn( int mode, const vec3_t v1, const vec3_t v2 )
{
int leafnum;
mleaf_t *leaf;
byte *mask;
leaf = Mod_PointInLeaf( v1, sv.worldmodel->nodes );
switch( mode )
{
case DVIS_PVS:
mask = Mod_LeafPVS( leaf, sv.worldmodel );
break;
case DVIS_PHS:
mask = Mod_LeafPHS( leaf, sv.worldmodel );
break;
default:
// skip any checks
return true;
}
// -1 is because pvs rows are 1 based, not 0 based like leafs
leafnum = Mod_PointLeafnum( v2 ) - 1;
if( mask && leafnum != -1 && (!( mask[leafnum>>3] & (1<<( leafnum & 7 )))))
return false;
return true;
}
/*
=============================================================================
@ -548,8 +516,8 @@ static void SV_AddToFatPVS( const vec3_t org, int type, mnode_t *node )
}
d = PlaneDiff( org, node->plane );
if( d > 8 ) node = node->children[0];
else if( d < -8 ) node = node->children[1];
if( d > 8.0f ) node = node->children[0];
else if( d < -8.0f ) node = node->children[1];
else
{
// go down both
@ -568,11 +536,8 @@ check brush boxes in fat pvs
*/
static qboolean SV_BoxInPVS( const vec3_t org, const vec3_t absmin, const vec3_t absmax )
{
mleaf_t *leaf;
byte *vis;
leaf = Mod_PointInLeaf( org, sv.worldmodel->nodes );
vis = Mod_LeafPVS( leaf, sv.worldmodel );
mleaf_t *leaf = Mod_PointInLeaf( org, sv.worldmodel->nodes );
byte *vis = Mod_LeafPVS( leaf, sv.worldmodel );
if( !Mod_BoxVisible( absmin, absmax, vis ))
return false;
@ -588,11 +553,11 @@ Create entity patch for selected map
*/
void SV_WriteEntityPatch( const char *filename )
{
file_t *f;
dheader_t *header;
int ver = -1, lumpofs = 0, lumplen = 0;
byte buf[MAX_SYSPATH]; // 1 kb
qboolean result = false;
file_t *f;
f = FS_Open( va( "maps/%s.bsp", filename ), "rb", false );
if( !f ) return;
@ -635,6 +600,7 @@ void SV_WriteEntityPatch( const char *filename )
Msg( "Write 'maps/%s.ent'\n", filename );
Mem_Free( entities );
}
FS_Close( f );
}
@ -647,7 +613,6 @@ pfnMapIsValid use this
*/
char *SV_ReadEntityScript( const char *filename, int *flags )
{
file_t *f;
dheader_t *header;
char *ents = NULL;
string bspfilename, entfilename;
@ -655,8 +620,9 @@ char *SV_ReadEntityScript( const char *filename, int *flags )
byte buf[MAX_SYSPATH]; // 1 kb
qboolean result = false;
size_t ft1, ft2;
file_t *f;
ASSERT( flags != NULL );
*flags = 0;
Q_strncpy( bspfilename, va( "maps/%s.bsp", filename ), sizeof( entfilename ));
f = FS_Open( bspfilename, "rb", false );
@ -711,6 +677,7 @@ char *SV_ReadEntityScript( const char *filename, int *flags )
ents = (char *)Z_Malloc( lumplen + 1 );
FS_Read( f, ents, lumplen );
}
FS_Close( f ); // all done
return ents;
@ -780,8 +747,10 @@ int SV_MapIsValid( const char *filename, const char *spawn_entity, const char *l
}
}
}
Mem_Free( ents );
}
return flags;
}
@ -791,11 +760,12 @@ void SV_FreePrivateData( edict_t *pEdict )
return;
// NOTE: new interface can be missing
if( svgame.dllFuncs2.pfnOnFreeEntPrivateData )
if( svgame.dllFuncs2.pfnOnFreeEntPrivateData != NULL )
svgame.dllFuncs2.pfnOnFreeEntPrivateData( pEdict );
if( Mem_IsAllocatedExt( svgame.mempool, pEdict->pvPrivateData ))
Mem_Free( pEdict->pvPrivateData );
pEdict->pvPrivateData = NULL;
}
@ -824,7 +794,7 @@ void SV_FreeEdict( edict_t *pEdict )
// unlink from world
SV_UnlinkEdict( pEdict );
// never remove global entities from map
// never remove global entities from map (make dormant instead)
if( pEdict->v.globalname && sv.state == ss_active )
{
pEdict->v.solid = SOLID_NOT;
@ -903,6 +873,7 @@ edict_t* SV_AllocPrivateData( edict_t *ent, string_t className )
// allocate edict private memory (passed by dlls)
SpawnEdict = (LINK_ENTITY_FUNC)Com_GetProcAddress( svgame.hInstance, pszClassName );
if( !SpawnEdict )
{
// attempt to create custom entity (Xash3D extension)
@ -966,9 +937,7 @@ const char *SV_ClassName( const edict_t *e )
static qboolean SV_IsValidCmd( const char *pCmd )
{
size_t len;
len = Q_strlen( pCmd );
size_t len = Q_strlen( pCmd );
// valid commands all have a ';' or newline '\n' as their last character
if( len && ( pCmd[len-1] == '\n' || pCmd[len-1] == ';' ))
@ -978,13 +947,13 @@ static qboolean SV_IsValidCmd( const char *pCmd )
sv_client_t *SV_ClientFromEdict( const edict_t *pEdict, qboolean spawned_only )
{
sv_client_t *client;
int i;
int i;
if( !SV_IsValidEdict( pEdict ))
return NULL;
i = NUM_FOR_EDICT( pEdict ) - 1;
if( i < 0 || i >= sv_maxclients->integer )
return NULL;
@ -993,9 +962,8 @@ sv_client_t *SV_ClientFromEdict( const edict_t *pEdict, qboolean spawned_only )
if( svs.clients[i].state != cs_spawned )
return NULL;
}
client = svs.clients + i;
return client;
return (svs.clients + i);
}
/*
@ -1099,6 +1067,7 @@ void pfnSetModel( edict_t *e, const char *m )
MsgDev( D_WARN, "SV_SetModel: null name\n" );
return;
}
SV_SetModel( e, m );
}
@ -1120,8 +1089,8 @@ int pfnModelIndex( const char *m )
if( !Q_stricmp( sv.model_precache[i], m ))
return i;
}
MsgDev( D_ERROR, "SV_ModelIndex: %s not precached\n", m );
MsgDev( D_ERROR, "SV_ModelIndex: %s not precached\n", m );
return 0;
}
@ -1349,6 +1318,7 @@ int pfnGetEntityIllum( edict_t* pEnt )
MsgDev( D_WARN, "SV_GetEntityIllum: invalid entity %s\n", SV_ClassName( pEnt ));
return 0;
}
return SV_LightForEntity( pEnt );
}
@ -1356,7 +1326,7 @@ int pfnGetEntityIllum( edict_t* pEnt )
=================
pfnFindEntityInSphere
return NULL instead of world
return NULL instead of world!
=================
*/
edict_t *pfnFindEntityInSphere( edict_t *pStartEdict, const float *org, float flRadius )
@ -1383,6 +1353,7 @@ edict_t *pfnFindEntityInSphere( edict_t *pStartEdict, const float *org, float fl
continue;
distSquared = 0.0f;
for( j = 0; j < 3 && distSquared <= flRadius; j++ )
{
if( org[j] < ent->v.absmin[j] )
@ -1398,6 +1369,7 @@ edict_t *pfnFindEntityInSphere( edict_t *pStartEdict, const float *org, float fl
continue;
return ent;
}
return NULL;
}
@ -1432,11 +1404,11 @@ int SV_CheckClientPVS( int check, qboolean bMergePVS )
ent = EDICT_NUM( i );
if( i == check ) break; // didn't find anything else
if( i == check )
break; // didn't find anything else
if( ent->free ) continue;
if( !ent->pvPrivateData ) continue;
if( ent->v.flags & FL_NOTARGET ) continue;
if( ent->free || !ent->pvPrivateData || ( ent->v.flags & FL_NOTARGET ))
continue;
// anything that is a client, or has a client as an enemy
break;
@ -1510,6 +1482,7 @@ edict_t* pfnFindClientInPVS( edict_t *pEdict )
return svgame.edicts;
mod = Mod_Handle( pEdict->v.modelindex );
if( mod && mod->type == mod_brush && !( mod->flags & MODEL_HAS_ORIGIN ))
{
// handle PVS origin for bmodels
@ -1522,7 +1495,7 @@ edict_t* pfnFindClientInPVS( edict_t *pEdict )
}
if( pEdict->v.effects & EF_INVLIGHT )
view[2] -= 1.0f; // HACK for barnacle
view[2] -= 1.0f; // HACKHACK for barnacle
i = Mod_PointLeafnum( view ) - 1;
@ -1581,6 +1554,7 @@ edict_t *pfnEntitiesInPVS( edict_t *pview )
chain = pEdict;
}
}
return chain;
}
@ -1750,7 +1724,7 @@ int pfnWalkMove( edict_t *ent, float yaw, float dist, int iMode )
if(!( ent->v.flags & ( FL_FLY|FL_SWIM|FL_ONGROUND )))
return false;
yaw = yaw * M_PI * 2 / 360;
yaw = yaw * M_PI * 2.0f / 360.0f;
VectorSet( move, cos( yaw ) * dist, sin( yaw ) * dist, 0.0f );
switch( iMode )
@ -1845,6 +1819,8 @@ int SV_BuildSoundMsg( edict_t *ent, int chan, const char *samp, int vol, float a
}
else
{
// precache_sound can be used twice: cache sounds when loading
// and return sound index when server is active
sound_idx = SV_SoundIndex( samp );
}
@ -1875,7 +1851,7 @@ int SV_BuildSoundMsg( edict_t *ent, int chan, const char *samp, int vol, float a
if( flags & SND_PITCH ) BF_WriteByte( &sv.multicast, pitch );
BF_WriteWord( &sv.multicast, entityIndex );
BF_WriteBitVec3Coord( &sv.multicast, pos );
BF_WriteVec3Coord( &sv.multicast, pos );
return 1;
}
@ -1967,7 +1943,7 @@ void SV_StartSound( edict_t *ent, int chan, const char *sample, float vol, float
if( flags & SND_PITCH ) BF_WriteByte( &sv.multicast, pitch );
BF_WriteWord( &sv.multicast, entityIndex );
BF_WriteBitVec3Coord( &sv.multicast, origin );
BF_WriteVec3Coord( &sv.multicast, origin );
SV_Send( msg_dest, origin, NULL );
}
@ -2047,7 +2023,7 @@ void pfnEmitAmbientSound( edict_t *ent, float *pos, const char *sample, float vo
// plays from fixed position
BF_WriteWord( &sv.multicast, number );
BF_WriteBitVec3Coord( &sv.multicast, pos );
BF_WriteVec3Coord( &sv.multicast, pos );
SV_Send( msg_dest, pos, NULL );
}
@ -2075,6 +2051,8 @@ static void pfnTraceLine( const float *v1, const float *v2, int fNoMonsters, edi
{
trace_t trace;
if( !ptr ) return;
trace = SV_Move( v1, vec3_origin, vec3_origin, v2, fNoMonsters, pentToSkip );
SV_ConvertTrace( ptr, &trace );
}
@ -2089,6 +2067,8 @@ static void pfnTraceToss( edict_t* pent, edict_t* pentToIgnore, TraceResult *ptr
{
trace_t trace;
if( !ptr ) return;
if( !SV_IsValidEdict( pent ))
{
MsgDev( D_WARN, "SV_MoveToss: invalid entity %s\n", SV_ClassName( pent ));
@ -2328,8 +2308,7 @@ void pfnClientCommand( edict_t* pEdict, char* szFmt, ... )
return;
}
client = SV_ClientFromEdict( pEdict, true );
if( client == NULL )
if(( client = SV_ClientFromEdict( pEdict, true )) == NULL )
{
MsgDev( D_ERROR, "SV_ClientCommand: client is not spawned!\n" );
return;
@ -2369,11 +2348,11 @@ void pfnParticleEffect( const float *org, const float *dir, float color, float c
}
BF_WriteByte( &sv.datagram, svc_particle );
BF_WriteBitVec3Coord( &sv.datagram, org );
BF_WriteVec3Coord( &sv.datagram, org );
for( i = 0; i < 3; i++ )
{
v = bound( -128, dir[i] * 16, 127 );
v = bound( -128, dir[i] * 16.0f, 127 );
BF_WriteChar( &sv.datagram, v );
}
@ -2475,7 +2454,7 @@ void pfnMessageBegin( int msg_dest, int msg_num, const float *pOrigin, edict_t *
if( i == MAX_USER_MESSAGES )
{
Host_Error( "MessageBegin: tired to send unregistered message %i\n", msg_num );
Host_Error( "MessageBegin: tried to send unregistered message %i\n", msg_num );
return;
}
@ -2531,7 +2510,7 @@ void pfnMessageEnd( void )
if( svgame.msg_size_index != -1 )
{
// variable sized message
if( svgame.msg_realsize >= 255 )
if( svgame.msg_realsize > 255 )
{
MsgDev( D_ERROR, "SV_Message: %s too long (more than 255 bytes)\n", name );
BF_Clear( &sv.multicast );
@ -2544,14 +2523,15 @@ void pfnMessageEnd( void )
return;
}
}
sv.multicast.pData[svgame.msg_size_index] = svgame.msg_realsize;
}
else if( svgame.msg[svgame.msg_index].size != -1 )
{
int expsize = svgame.msg[svgame.msg_index].size;
int realsize = svgame.msg_realsize;
int expsize = svgame.msg[svgame.msg_index].size;
int realsize = svgame.msg_realsize;
// compare bounds
// compare sizes
if( expsize != realsize )
{
MsgDev( D_ERROR, "SV_Message: %s expected %i bytes, it written %i. Ignored.\n", name, expsize, realsize );
@ -2562,7 +2542,7 @@ void pfnMessageEnd( void )
else if( svgame.msg_size_index != -1 )
{
// variable sized message
if( svgame.msg_realsize >= 255 )
if( svgame.msg_realsize > 255 )
{
MsgDev( D_ERROR, "SV_Message: %s too long (more than 255 bytes)\n", name );
BF_Clear( &sv.multicast );
@ -2587,6 +2567,7 @@ void pfnMessageEnd( void )
if( !VectorIsNull( svgame.msg_org )) org = svgame.msg_org;
svgame.msg_dest = bound( MSG_BROADCAST, svgame.msg_dest, MSG_SPEC );
SV_Send( svgame.msg_dest, org, svgame.msg_ent );
}
@ -2876,10 +2857,28 @@ string_t SV_AllocString( const char *szValue )
{
const char *newString;
if( svgame.physFuncs.pfnAllocString != NULL )
return svgame.physFuncs.pfnAllocString( szValue );
newString = _copystring( svgame.stringspool, szValue, __FILE__, __LINE__ );
return newString - svgame.globals->pStringBase;
}
/*
=============
SV_MakeString
make constant string
=============
*/
string_t SV_MakeString( const char *szValue )
{
if( svgame.physFuncs.pfnMakeString != NULL )
return svgame.physFuncs.pfnMakeString( szValue );
return szValue - svgame.globals->pStringBase;
}
/*
=============
SV_GetString
@ -2888,6 +2887,8 @@ SV_GetString
*/
const char *SV_GetString( string_t iString )
{
if( svgame.physFuncs.pfnGetString != NULL )
return svgame.physFuncs.pfnGetString( iString );
return (svgame.globals->pStringBase + iString);
}
@ -3138,8 +3139,7 @@ void pfnClientPrintf( edict_t* pEdict, PRINT_TYPE ptype, const char *szMsg )
return;
}
client = SV_ClientFromEdict( pEdict, true );
if( client == NULL )
if(( client = SV_ClientFromEdict( pEdict, true )) == NULL )
{
MsgDev( D_ERROR, "SV_ClientPrintf: client is not spawned!\n" );
return;
@ -3189,6 +3189,7 @@ static void pfnGetAttachment( const edict_t *pEdict, int iAttachment, float *rgf
MsgDev( D_WARN, "SV_GetAttachment: invalid entity %s\n", SV_ClassName( pEdict ));
return;
}
Mod_StudioGetAttachment( pEdict, iAttachment, rgflOrigin, rgflAngles );
}
@ -3215,8 +3216,7 @@ void pfnCrosshairAngle( const edict_t *pClient, float pitch, float yaw )
{
sv_client_t *client;
client = SV_ClientFromEdict( pClient, true );
if( client == NULL )
if(( client = SV_ClientFromEdict( pClient, true )) == NULL )
{
MsgDev( D_ERROR, "SV_SetCrosshairAngle: invalid client!\n" );
return;
@ -3251,8 +3251,7 @@ void pfnSetView( const edict_t *pClient, const edict_t *pViewent )
return;
}
client = SV_ClientFromEdict( pClient, true );
if( !client )
if(( client = SV_ClientFromEdict( pClient, true )) == NULL )
{
MsgDev( D_ERROR, "PF_SetView: not a client!\n" );
return;
@ -3321,8 +3320,8 @@ pfnGetPlayerWONId
*/
uint pfnGetPlayerWONId( edict_t *e )
{
int i;
sv_client_t *cl;
int i;
if( sv.state != ss_active )
return -1;
@ -3335,6 +3334,7 @@ uint pfnGetPlayerWONId( edict_t *e )
if( cl->edict == e && cl->authentication_method == 0 )
return cl->WonID;
}
return -1;
}
@ -3370,10 +3370,9 @@ pfnFadeClientVolume
*/
void pfnFadeClientVolume( const edict_t *pEdict, int fadePercent, int fadeOutSeconds, int holdTime, int fadeInSeconds )
{
sv_client_t *cl;
sv_client_t *cl;
cl = SV_ClientFromEdict( pEdict, true );
if( !cl )
if(( cl = SV_ClientFromEdict( pEdict, true )) == NULL )
{
MsgDev( D_ERROR, "SV_FadeClientVolume: client is not spawned!\n" );
return;
@ -3397,10 +3396,10 @@ fakeclients can be changed speed to
*/
void pfnSetClientMaxspeed( const edict_t *pEdict, float fNewMaxspeed )
{
sv_client_t *cl;
sv_client_t *cl;
cl = SV_ClientFromEdict( pEdict, false ); // connected clients allowed
if( !cl )
// not spawned clients allowed
if(( cl = SV_ClientFromEdict( pEdict, false )) == NULL )
{
MsgDev( D_ERROR, "SV_SetClientMaxspeed: client is not active!\n" );
return;
@ -3492,12 +3491,13 @@ char *pfnGetInfoKeyBuffer( edict_t *e )
if( !SV_IsValidEdict( e ))
return Cvar_Serverinfo(); // otherwise return ServerInfo
cl = SV_ClientFromEdict( e, false ); // pfnUserInfoChanged passed
if( cl == NULL )
// pfnUserInfoChanged passed
if(( cl = SV_ClientFromEdict( e, false )) == NULL )
{
MsgDev( D_ERROR, "SV_GetClientUserinfo: client is not connected!\n" );
return Cvar_Serverinfo(); // otherwise return ServerInfo
}
return cl->userinfo;
}
@ -3513,6 +3513,7 @@ void pfnSetClientKeyValue( int clientIndex, char *infobuffer, char *key, char *v
if( clientIndex < 0 || clientIndex >= sv_maxclients->integer )
return;
if( svs.clients[clientIndex].state < cs_spawned || infobuffer == NULL )
return;
@ -3530,12 +3531,13 @@ const char *pfnGetPhysicsKeyValue( const edict_t *pClient, const char *key )
{
sv_client_t *cl;
cl = SV_ClientFromEdict( pClient, false ); // pfnUserInfoChanged passed
if( cl == NULL )
// pfnUserInfoChanged passed
if(( cl = SV_ClientFromEdict( pClient, false )) == NULL )
{
MsgDev( D_ERROR, "SV_GetClientPhysKey: client is not connected!\n" );
return "";
}
return Info_ValueForKey( cl->physinfo, key );
}
@ -3549,12 +3551,13 @@ void pfnSetPhysicsKeyValue( const edict_t *pClient, const char *key, const char
{
sv_client_t *cl;
cl = SV_ClientFromEdict( pClient, false ); // pfnUserInfoChanged passed
if( cl == NULL )
// pfnUserInfoChanged passed
if(( cl = SV_ClientFromEdict( pClient, false )) == NULL )
{
MsgDev( D_ERROR, "SV_SetClientPhysinfo: client is not connected!\n" );
return;
}
Info_SetValueForKey( cl->physinfo, key, value );
}
@ -3568,12 +3571,13 @@ const char *pfnGetPhysicsInfoString( const edict_t *pClient )
{
sv_client_t *cl;
cl = SV_ClientFromEdict( pClient, false ); // pfnUserInfoChanged passed
if( cl == NULL )
// pfnUserInfoChanged passed
if(( cl = SV_ClientFromEdict( pClient, false )) == NULL )
{
MsgDev( D_ERROR, "SV_GetClientPhysinfo: client is not connected!\n" );
return "";
}
return cl->physinfo;
}
@ -3883,6 +3887,7 @@ int pfnCheckVisibility( const edict_t *ent, byte *pset )
if( pset[ent->leafnums[i] >> 3] & (1 << (ent->leafnums[i] & 7 )))
return 1; // visible passed by leaf
}
return 0;
}
else
@ -3918,8 +3923,8 @@ int pfnCanSkipPlayer( const edict_t *player )
{
sv_client_t *cl;
cl = SV_ClientFromEdict( player, false );
if( !cl ) return false;
if(( cl = SV_ClientFromEdict( player, false )) == NULL )
return false;
return cl->local_weapons;
}
@ -3933,7 +3938,7 @@ pfnGetCurrentPlayer
int pfnGetCurrentPlayer( void )
{
if( svs.currentPlayer )
return svs.currentPlayer - svs.clients;
return (svs.currentPlayer - svs.clients);
return -1;
}
@ -4021,8 +4026,7 @@ void pfnGetPlayerStats( const edict_t *pClient, int *ping, int *packet_loss )
{
sv_client_t *cl;
cl = SV_ClientFromEdict( pClient, false );
if( cl == NULL )
if(( cl = SV_ClientFromEdict( pClient, false )) == NULL )
{
MsgDev( D_ERROR, "SV_GetPlayerStats: client is not connected!\n" );
return;
@ -4519,6 +4523,7 @@ qboolean SV_ParseEdict( char **pfile, edict_t *ent )
Mem_Free( pkvd[i].szKeyName );
Mem_Free( pkvd[i].szValue );
}
return true;
}
@ -4647,10 +4652,8 @@ void SV_UnloadProgs( void )
Mem_FreePool( &svgame.stringspool );
if( svgame.dllFuncs2.pfnGameShutdown )
{
if( svgame.dllFuncs2.pfnGameShutdown != NULL )
svgame.dllFuncs2.pfnGameShutdown ();
}
// now we can unload cvars
Cvar_FullSet( "host_gameloaded", "0", CVAR_INIT );
@ -4659,6 +4662,7 @@ void SV_UnloadProgs( void )
// must unlink all game cvars,
// before pointers on them will be lost...
Cmd_ExecuteString( "@unlink\n", src_command );
Cmd_Unlink( CMD_EXTDLL );
Com_FreeLibrary( svgame.hInstance );
Mem_FreePool( &svgame.mempool );
@ -4775,6 +4779,7 @@ qboolean SV_LoadProgs( const char *name )
svgame.globals->maxClients = sv_maxclients->integer;
svgame.edicts = Mem_Alloc( svgame.mempool, sizeof( edict_t ) * svgame.globals->maxEntities );
svgame.numEntities = svgame.globals->maxClients + 1; // clients + world
for( i = 0, e = svgame.edicts; i < svgame.globals->maxEntities; i++, e++ )
e->free = true; // mark all edicts as freed

View File

@ -466,8 +466,6 @@ qboolean SV_SpawnServer( const char *mapname, const char *startspot )
qboolean loadgame, paused;
qboolean background, changelevel;
Cmd_ExecuteString( "latch\n", src_command );
// save state
loadgame = sv.loadgame;
background = sv.background;
@ -476,6 +474,9 @@ qboolean SV_SpawnServer( const char *mapname, const char *startspot )
if( sv.state == ss_dead )
SV_InitGame(); // the game is just starting
else if( !sv_maxclients->modified )
Cmd_ExecuteString( "latch\n", src_command );
else MsgDev( D_ERROR, "SV_SpawnServer: while 'maxplayers' was modified.\n" );
if( !svs.initialized )
return false;
@ -596,6 +597,9 @@ void SV_InitGame( void )
CL_Drop();
}
// now apply latched commands
Cmd_ExecuteString( "latch\n", src_command );
if( Cvar_VariableValue( "coop" ) && Cvar_VariableValue ( "deathmatch" ) && Cvar_VariableValue( "teamplay" ))
{
MsgDev( D_WARN, "Deathmatch, Teamplay and Coop set, defaulting to Deathmatch\n");
@ -607,7 +611,7 @@ void SV_InitGame( void )
// so unless they explicity set coop, force it to deathmatch
if( host.type == HOST_DEDICATED )
{
if(!Cvar_VariableValue( "coop" ) && !Cvar_VariableValue( "teamplay" ))
if( !Cvar_VariableValue( "coop" ) && !Cvar_VariableValue( "teamplay" ))
Cvar_FullSet( "deathmatch", "1", CVAR_LATCH );
}

View File

@ -69,6 +69,10 @@ convar_t *mp_consistency;
convar_t *serverinfo;
convar_t *physinfo;
convar_t *clockwindow;
convar_t *deathmatch;
convar_t *teamplay;
convar_t *skill;
convar_t *coop;
// sky variables
convar_t *sv_skycolor_r;
@ -630,10 +634,10 @@ void SV_Init( void )
{
SV_InitOperatorCommands();
Cvar_Get ("skill", "1", CVAR_LATCH, "game skill level" );
Cvar_Get ("deathmatch", "0", CVAR_LATCH|CVAR_SERVERINFO, "displays deathmatch state" );
Cvar_Get ("teamplay", "0", CVAR_LATCH|CVAR_SERVERINFO, "displays teamplay state" );
Cvar_Get ("coop", "0", CVAR_LATCH|CVAR_SERVERINFO, "displays cooperative state" );
skill = Cvar_Get ("skill", "1", CVAR_LATCH, "game skill level" );
deathmatch = Cvar_Get ("deathmatch", "0", CVAR_LATCH|CVAR_SERVERINFO, "displays deathmatch state" );
teamplay = Cvar_Get ("teamplay", "0", CVAR_LATCH|CVAR_SERVERINFO, "displays teamplay state" );
coop = Cvar_Get ("coop", "0", CVAR_LATCH|CVAR_SERVERINFO, "displays cooperative state" );
Cvar_Get ("protocol", va( "%i", PROTOCOL_VERSION ), CVAR_INIT, "displays server protocol version" );
Cvar_Get ("defaultmap", "", CVAR_SERVERNOTIFY, "holds the multiplayer mapname" );
Cvar_Get ("showtriggers", "0", CVAR_LATCH, "debug cvar shows triggers" );

View File

@ -77,6 +77,12 @@ void SV_CheckAllEnts( void )
{
e = EDICT_NUM( i );
// DEBUG: check 'gamestate' for using by mods
if( e->v.gamestate != 0 )
{
MsgDev( D_INFO, "Entity %s[%i] uses gamestate %i\n", SV_ClassName( e ), NUM_FOR_EDICT( e ), e->v.gamestate );
}
if( e->free && e->pvPrivateData != NULL )
{
MsgDev( D_ERROR, "Freed entity %s (%i) has private data.\n", SV_ClassName( e ), i );

View File

@ -314,10 +314,10 @@ static void pfnParticle( float *origin, int color, float life, int zpos, int zve
}
BF_WriteByte( &sv.reliable_datagram, svc_particle );
BF_WriteBitVec3Coord( &sv.reliable_datagram, origin );
BF_WriteVec3Coord( &sv.reliable_datagram, origin );
BF_WriteChar( &sv.reliable_datagram, 0 ); // no x-vel
BF_WriteChar( &sv.reliable_datagram, 0 ); // no y-vel
v = bound( -128, (zpos * zvel) * 16, 127 );
v = bound( -128, (zpos * zvel) * 16.0f, 127 );
BF_WriteChar( &sv.reliable_datagram, v ); // write z-vel
BF_WriteByte( &sv.reliable_datagram, 1 );
BF_WriteByte( &sv.reliable_datagram, color );

View File

@ -558,7 +558,7 @@ void RestoreSound( soundlist_t *entry )
if( flags & SND_PITCH ) BF_WriteByte( &sv.signon, entry->pitch );
BF_WriteWord( &sv.signon, entry->entnum );
BF_WriteBitVec3Coord( &sv.signon, entry->origin );
BF_WriteVec3Coord( &sv.signon, entry->origin );
BF_WriteByte( &sv.signon, entry->wordIndex );
// send two doubles as raw-data

View File

@ -955,8 +955,6 @@ void SV_ClipMoveToEntity( edict_t *ent, const vec3_t start, vec3_t mins, vec3_t
qboolean rotated, transform_bbox;
matrix4x4 matrix;
ASSERT( trace );
Q_memset( trace, 0, sizeof( trace_t ));
VectorCopy( end, trace->endpos );
trace->fraction = 1.0f;
@ -1566,9 +1564,6 @@ void SV_SetLightStyle( int style, const char* s )
{
int j, k;
ASSERT( s );
ASSERT( style >= 0 && style < MAX_LIGHTSTYLES );
Q_strncpy( sv.lightstyles[style].pattern, s, sizeof( sv.lightstyles[0].pattern ));
j = Q_strlen( s );
@ -1594,7 +1589,10 @@ needs to get correct working SV_LightPoint
*/
const char *SV_GetLightStyle( int style )
{
ASSERT( style >= 0 && style < MAX_LIGHTSTYLES );
if( style < 0 ) style = 0;
if( style >= MAX_LIGHTSTYLES )
Host_Error( "SV_GetLightStyle: style: %i >= %d", style, MAX_LIGHTSTYLES );
return sv.lightstyles[style].pattern;
}

View File

@ -38,7 +38,7 @@ typedef enum
{
FRAME_SINGLE = 0,
FRAME_GROUP,
FRAME_ANGLED // Xash3D ext
FRAME_ANGLED // Xash3D ext
} frametype_t;
typedef enum

View File

@ -65,14 +65,12 @@ Studio models are position independent, so the cache manager can move them.
#define STUDIO_NF_CHROME 0x0002
#define STUDIO_NF_FULLBRIGHT 0x0004
#define STUDIO_NF_COLORMAP 0x0008 // can changed by colormap command
#define STUDIO_NF_BLENDED 0x0010 // rendering as semiblended
#define STUDIO_NF_BLENDED 0x0010 // rendering as semitransparent
#define STUDIO_NF_ADDITIVE 0x0020 // rendering with additive mode
#define STUDIO_NF_TRANSPARENT 0x0040 // use texture with alpha channel
#define STUDIO_NF_NORMALMAP 0x0080 // indexed normalmap
#define STUDIO_NF_HEIGHTMAP 0x0100 // heightmap that can be used for parallax or normalmap
#define STUDIO_NF_GLOSSMAP 0x0200 // glossmap
#define STUDIO_NF_DECALMAP 0x0400 // decalmap (currently unused)
#define STUDIO_NF_GLOWMAP 0x0800 // optional luma_texture
#define STUDIO_NF_BUMPMAP 0x0080 // heightmap that can be transformed into normalmap and heightmap
#define STUDIO_NF_GLOSSMAP 0x0100 // glossmap
#define STUDIO_NF_LUMATEXTURE 0x0200 // optional luma_texture
#define STUDIO_NF_QUAKESKIN 0x8000 // special hack for determine alias skins
// motion flags
@ -95,7 +93,7 @@ Studio models are position independent, so the cache manager can move them.
#define STUDIO_RLOOP 0x8000 // controller that wraps shortest distance
// bonecontroller types
#define STUDIO_MOUTH 4
#define STUDIO_MOUTH 4 // hardcoded
// sequence flags
#define STUDIO_LOOPING 0x0001
@ -345,7 +343,7 @@ typedef struct
int groupindex;
} mstudiomodel_t;
// vec3_t boundingbox[model][bone][2]; // complex intersection info
// vec3_t boundingbox[model][bone][2]; // complex intersection info
// meshes
typedef struct

View File

@ -25,4 +25,4 @@
#include <common.ver>
IDI_ICON1 ICON DISCARDABLE "game.ico"
IDI_ICON1 ICON DISCARDABLE "game.ico"