16 Dec 2008

This commit is contained in:
g-cont 2008-12-16 00:00:00 +03:00 committed by Alibek Omarov
parent 73eaf4b5ab
commit 845de86ee5
72 changed files with 5825 additions and 3866 deletions

View File

@ -12,9 +12,11 @@ release.bat
launchers.bat
todo.log
public\
baserc\
cl_dll\
public\
physic\
sv_dll\
render\
vprogs\
vsound\

View File

@ -54,7 +54,8 @@ BSC32=bscmake.exe
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 /opt:nowin98
# ADD LINK32 msvcrt.lib /nologo /dll /profile /machine:I386 /nodefaultlib:"libc.lib" /opt:nowin98
# ADD LINK32 msvcrt.lib /nologo /dll /pdb:none /machine:I386 /nodefaultlib:"libc.lib" /opt:nowin98
# SUBTRACT LINK32 /profile /nodefaultlib
# Begin Custom Build
TargetDir=\Xash3D\src_main\temp\baserc\!release
InputPath=\Xash3D\src_main\temp\baserc\!release\baserc.dll
@ -79,7 +80,7 @@ SOURCE="$(InputPath)"
# PROP Ignore_Export_Lib 1
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "PLATFORM_EXPORTS" /YX /FD /GZ /c
# ADD CPP /nologo /MDd /W3 /Gm /Gi /GX /ZI /I "./" /I "../public" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /FR /FD /GZ /c
# ADD CPP /nologo /MDd /W3 /Gm /Gi /GX /ZI /Od /I "./" /I "../public" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /FR /FD /GZ /c
# SUBTRACT CPP /YX
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32

View File

@ -1008,10 +1008,10 @@ bool ParseMapEntity( void )
b->contents = CONTENTS_AREAPORTAL;
c_areaportals++;
mapent->areaportalnum = c_areaportals;
// set the portal number as "style"
com.sprintf (str, "%i", c_areaportals);
SetKeyValue (mapent, "style", str);
MoveBrushesToWorld (mapent);
// set the portal number as "skin"
com.sprintf( str, "%i", c_areaportals );
SetKeyValue( mapent, "skin", str );
MoveBrushesToWorld( mapent );
return true;
}

View File

@ -54,7 +54,8 @@ BSC32=bscmake.exe
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 /opt:nowin98
# ADD LINK32 msvcrt.lib /nologo /dll /profile /machine:I386 /nodefaultlib:"libc.lib" /opt:nowin98
# ADD LINK32 msvcrt.lib /nologo /dll /pdb:none /machine:I386 /nodefaultlib:"libc.lib" /opt:nowin98
# SUBTRACT LINK32 /profile
# Begin Custom Build
TargetDir=\Xash3D\src_main\temp\common\!release
InputPath=\Xash3D\src_main\temp\common\!release\common.dll
@ -79,7 +80,7 @@ SOURCE="$(InputPath)"
# PROP Ignore_Export_Lib 1
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "PLATFORM_EXPORTS" /YX /FD /GZ /c
# ADD CPP /nologo /MDd /W3 /Gm /Gi /GX /ZI /I "./" /I "../public" /I "./bsplib/" /I "./ripper" /I "./common" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /FR /FD /GZ /c
# ADD CPP /nologo /MDd /W3 /Gm /Gi /GX /ZI /Od /I "./" /I "../public" /I "./bsplib/" /I "./ripper" /I "./common" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /FR /FD /GZ /c
# SUBTRACT CPP /YX
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32

View File

@ -26,6 +26,9 @@ if errorlevel 1 set BUILD_ERROR=1
%MSDEV% render/render.dsp %CONFIG%"render - Win32 Debug" %build_target%
if errorlevel 1 set BUILD_ERROR=1
%MSDEV% sv_dll/server.dsp %CONFIG%"server - Win32 Debug" %build_target%
if errorlevel 1 set BUILD_ERROR=1
%MSDEV% vprogs/vprogs.dsp %CONFIG%"vprogs - Win32 Debug" %build_target%
if errorlevel 1 set BUILD_ERROR=1

View File

@ -34,7 +34,7 @@ void CL_WriteDemoHeader( const char *name )
{
char buf_data[MAX_MSGLEN];
entity_state_t *state, nullstate;
edict_t *ent;
pr_edict_t *ent;
sizebuf_t buf;
int i, len;

View File

@ -245,7 +245,7 @@ DECALS MANAGEMENT
==============================================================
*/
#define MAX_DECALS 2048
#define MAX_DECAL_MARKS 2048
#define DECAL_FADETIME (30 * 1000) // 30 seconds
#define DECAL_STAYTIME (120 * 1000) // 120 seconds
@ -263,7 +263,7 @@ typedef struct cdecal_s
static cdecal_t cl_activeDecals;
static cdecal_t *cl_freeDecals;
static cdecal_t cl_decalList[MAX_DECALS];
static cdecal_t cl_decalList[MAX_DECAL_MARKS];
/*
=================
@ -324,7 +324,7 @@ void CL_ClearDecals( void )
cl_activeDecals.prev = &cl_activeDecals;
cl_freeDecals = cl_decalList;
for( i = 0; i < MAX_DECALS - 1; i++ )
for( i = 0; i < MAX_DECAL_MARKS - 1; i++ )
cl_decalList[i].next = &cl_decalList[i+1];
}
@ -682,7 +682,7 @@ void CL_AddParticles( void )
if( p->flags & PARTICLE_BOUNCE )
{
edict_t *clent = PRVM_EDICT_NUM( cl.frame.ps.number );
pr_edict_t *clent = PRVM_EDICT_NUM( cl.frame.ps.number );
// bouncy particle
VectorSet(mins, -radius, -radius, -radius);

View File

@ -13,7 +13,7 @@ FRAME PARSING
=========================================================================
*/
void CL_UpdateEntityFileds( edict_t *ent )
void CL_UpdateEntityFileds( pr_edict_t *ent )
{
// copy state to progs
ent->progs.cl->classname = cl.edict_classnames[ent->priv.cl->current.classname];
@ -34,7 +34,7 @@ to the current frame
*/
void CL_DeltaEntity( sizebuf_t *msg, frame_t *frame, int newnum, entity_state_t *old, bool unchanged )
{
edict_t *ent;
pr_edict_t *ent;
entity_state_t *state;
ent = PRVM_EDICT_NUM( newnum );
@ -154,7 +154,7 @@ void CL_ParsePacketEntities( sizebuf_t *msg, frame_t *oldframe, frame_t *newfram
if( oldnum > newnum )
{
// delta from baseline
edict_t *ent = PRVM_EDICT_NUM( newnum );
pr_edict_t *ent = PRVM_EDICT_NUM( newnum );
CL_DeltaEntity( msg, newframe, newnum, &ent->priv.cl->baseline, false );
continue;
}
@ -188,7 +188,7 @@ CL_ParseFrame
void CL_ParseFrame( sizebuf_t *msg )
{
int cmd, len, idx;
edict_t *clent;
pr_edict_t *clent;
frame_t *old;
memset( &cl.frame, 0, sizeof(cl.frame));
@ -304,7 +304,7 @@ CL_AddPacketEntities
void CL_AddPacketEntities( frame_t *frame )
{
entity_state_t *s1;
edict_t *ent;
pr_edict_t *ent;
int pnum;
for( pnum = 0; pnum < frame->num_entities; pnum++ )
@ -324,7 +324,7 @@ CL_AddViewWeapon
*/
void CL_AddViewWeapon( entity_state_t *ps )
{
edict_t *view; // view model
pr_edict_t *view; // view model
// allow the gun to be completely removed
if( !cl_gun->value ) return;
@ -459,7 +459,7 @@ void CL_AddEntities( void )
void CL_GetEntitySoundSpatialization( int entnum, vec3_t origin, vec3_t velocity )
{
edict_t *ent;
pr_edict_t *ent;
cmodel_t *cmodel;
vec3_t midPoint;

View File

@ -328,12 +328,10 @@ void CL_BaseMove( usercmd_t *cmd )
// adjust for speed key / running
if( in_speed.state & 1 ^ cl_run->integer )
{
cmd->buttons &= ~BUTTON_WALKING;
cmd->forwardmove *= 2;
cmd->sidemove *= 2;
cmd->upmove *= 2;
}
else cmd->buttons |= BUTTON_WALKING;
}
void CL_ClampPitch (void)
@ -357,19 +355,19 @@ CL_CmdButtons
void CL_CmdButtons( usercmd_t *cmd )
{
if ( in_attack.state & 3 )
cmd->buttons |= BUTTON_ATTACK;
cmd->buttons |= IN_ATTACK;
in_attack.state &= ~2;
if ( in_attack2.state & 3 )
cmd->buttons |= BUTTON_ATTACK2;
cmd->buttons |= IN_ATTACK2;
in_attack2.state &= ~2;
if (in_use.state & 3)
cmd->buttons |= BUTTON_USE;
cmd->buttons |= IN_USE;
in_use.state &= ~2;
if( anykeydown && cls.key_dest == key_game)
cmd->buttons |= BUTTON_ANY;
if (in_speed.state & 3)
cmd->buttons |= IN_RUN;
}
/*

View File

@ -684,11 +684,11 @@ void CL_PrepSound( void )
{
int i, sndcount;
for( i = 1, sndcount = 0; i < MAX_SOUNDS && cl.configstrings[CS_SOUNDS+i][0]; i++ )
for( i = 0, sndcount = 0; i < MAX_SOUNDS && cl.configstrings[CS_SOUNDS+i][0]; i++ )
sndcount++; // total num sounds
S_BeginRegistration();
for( i = 1; i < MAX_SOUNDS && cl.configstrings[CS_SOUNDS+i][0]; i++ )
for( i = 0; i < MAX_SOUNDS && cl.configstrings[CS_SOUNDS+i][0]; i++ )
{
cl.sound_precache[i] = S_RegisterSound( cl.configstrings[CS_SOUNDS+i]);
Cvar_SetValue( "scr_loading", scr_loading->value + 5.0f/sndcount );
@ -737,6 +737,12 @@ void CL_PrepVideo( void )
SCR_UpdateScreen();
}
for( i = 0; i < MAX_DECALS && cl.configstrings[CS_DECALS+i][0]; i++ )
{
com.strncpy( name, cl.configstrings[CS_DECALS+i], MAX_STRING );
// FIXME: register shaders
}
// setup sky and free unneeded stuff
re->EndRegistration( cl.configstrings[CS_SKYNAME] );
Cvar_SetValue("scr_loading", 100.0f ); // all done

View File

@ -234,7 +234,7 @@ void CL_ParseBaseline( sizebuf_t *msg )
{
int newnum;
entity_state_t nullstate;
edict_t *ent;
pr_edict_t *ent;
CL_VM_Begin();
memset( &nullstate, 0, sizeof(nullstate));
@ -280,6 +280,14 @@ void CL_ParseConfigString( sizebuf_t *msg )
{
cl.sound_precache[i-CS_SOUNDS] = S_RegisterSound( cl.configstrings[i] );
}
else if( i >= CS_DECALS && i < CS_DECALS+MAX_DECALS && cl.video_prepped )
{
// FIXME: register decal shaders here
}
else if( i >= CS_USER_MESSAGES && i < CS_USER_MESSAGES+MAX_USER_MESSAGES )
{
// FIXME: register user message here
}
else if( i >= CS_CLASSNAMES && i < CS_CLASSNAMES+MAX_CLASSNAMES )
{
// prvm classnames for search by classname on client vm

View File

@ -67,13 +67,13 @@ void CL_CheckPredictionError (void)
CL_Trace
==================
*/
trace_t CL_Trace( const vec3_t start, const vec3_t mins, const vec3_t maxs, const vec3_t end, int type, edict_t *passedict, int contentsmask )
trace_t CL_Trace( const vec3_t start, const vec3_t mins, const vec3_t maxs, const vec3_t end, int type, pr_edict_t *passedict, int contentsmask )
{
vec3_t hullmins, hullmaxs;
int i, bodycontents;
int passedictprog;
bool pointtrace;
edict_t *traceowner, *touch;
pr_edict_t *traceowner, *touch;
trace_t trace;
vec3_t clipboxmins, clipboxmaxs; // bounding box of entire move area
vec3_t clipmins, clipmaxs; // size of the moving object
@ -83,7 +83,7 @@ trace_t CL_Trace( const vec3_t start, const vec3_t mins, const vec3_t maxs, cons
matrix4x4 matrix, imatrix; // matrices to transform into/out of other entity's space
cmodel_t *model; // model of other entity
int numtouchedicts = 0; // list of entities to test for collisions
edict_t *touchedicts[MAX_EDICTS];
pr_edict_t *touchedicts[MAX_EDICTS];
VectorCopy( start, clipstart );
VectorCopy( end, clipend );
@ -95,7 +95,8 @@ trace_t CL_Trace( const vec3_t start, const vec3_t mins, const vec3_t maxs, cons
// clip to world
pe->ClipToWorld( &cliptrace, cl.worldmodel, clipstart, clipmins, clipmaxs, clipend, contentsmask );
cliptrace.startstuck = cliptrace.startsolid;
if( cliptrace.startsolid || cliptrace.fraction < 1 ) cliptrace.ent = prog ? prog->edicts : NULL;
if( cliptrace.startsolid || cliptrace.fraction < 1 )
cliptrace.ent = prog ? (edict_t *)prog->edicts : NULL;
if( type == MOVE_WORLDONLY ) return cliptrace;
if( type == MOVE_MISSILE )
@ -178,7 +179,7 @@ trace_t CL_Trace( const vec3_t start, const vec3_t mins, const vec3_t maxs, cons
if((int)touch->progs.cl->flags & FL_MONSTER)
pe->ClipToGenericEntity(&trace, model, touch->progs.cl->mins, touch->progs.cl->maxs, bodycontents, matrix, imatrix, clipstart, clipmins2, clipmaxs2, clipend, contentsmask );
else pe->ClipToGenericEntity(&trace, model, touch->progs.cl->mins, touch->progs.cl->maxs, bodycontents, matrix, imatrix, clipstart, clipmins, clipmaxs, clipend, contentsmask );
pe->CombineTraces(&cliptrace, &trace, touch, touch->progs.cl->solid == SOLID_BSP );
pe->CombineTraces( &cliptrace, &trace, (edict_t *)touch, touch->progs.cl->solid == SOLID_BSP );
}
return cliptrace;
}

View File

@ -116,7 +116,7 @@ mathlib, debugger, and various misc helpers
void CL_BeginIncreaseEdicts( void )
{
int i;
edict_t *ent;
pr_edict_t *ent;
// links don't survive the transition, so unlink everything
for (i = 0, ent = prog->edicts; i < prog->max_edicts; i++, ent++)
@ -127,20 +127,20 @@ void CL_BeginIncreaseEdicts( void )
void CL_EndIncreaseEdicts( void )
{
int i;
edict_t *ent;
pr_edict_t *ent;
for (i = 0, ent = prog->edicts; i < prog->max_edicts; i++, ent++)
{
}
}
void CL_InitEdict( edict_t *e )
void CL_InitEdict( pr_edict_t *e )
{
e->priv.cl->serialnumber = PRVM_NUM_FOR_EDICT(e);
e->priv.cl->free = false;
}
void CL_FreeEdict( edict_t *ed )
void CL_FreeEdict( pr_edict_t *ed )
{
ed->priv.cl->freetime = cl.time * 0.001f;
ed->priv.cl->free = true;
@ -157,7 +157,7 @@ void CL_FreeEdict( edict_t *ed )
void CL_FreeEdicts( void )
{
int i;
edict_t *ent;
pr_edict_t *ent;
CL_VM_Begin();
for( i = 1; prog && i < prog->num_edicts; i++ )
@ -170,7 +170,7 @@ void CL_FreeEdicts( void )
void CL_CountEdicts( void )
{
edict_t *ent;
pr_edict_t *ent;
int i, active = 0, models = 0;
for (i = 0; i < prog->num_edicts; i++)
@ -199,7 +199,7 @@ void CL_VM_End( void )
PRVM_End;
}
bool CL_LoadEdict( edict_t *ent )
bool CL_LoadEdict( pr_edict_t *ent )
{
return true;
}

View File

@ -31,13 +31,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#define MAX_SERVERS 64
#define ColorIndex(c) (((c) - '0') & 7)
// button bits
#define BUTTON_ATTACK 1
#define BUTTON_ATTACK2 2
#define BUTTON_USE 4
#define BUTTON_WALKING 8
#define BUTTON_ANY 128 // any key whatsoever
//=============================================================================
typedef struct frame_s
{
@ -138,6 +131,7 @@ typedef struct
string_t edict_classnames[MAX_CLASSNAMES];
sound_t sound_precache[MAX_SOUNDS];
shader_t decal_shaders[MAX_DECALS];
} client_t;
extern client_t cl;
@ -452,7 +446,7 @@ void CL_InitClientProgs( void );
void CL_FreeClientProgs( void );
int CL_GetMaxClients( void );
void CL_DrawHUD( void );
edict_t *CL_GetEdict( int entnum );
pr_edict_t *CL_GetEdict( int entnum );
float *CL_FadeColor( float starttime, float endtime );
bool CL_ParseUserMessage( int svc_number );
void CL_FreeEdicts( void );
@ -538,7 +532,7 @@ void CL_PredictMove (void);
void CL_CheckPredictionError (void);
int CL_PointContents( const vec3_t point );
bool CL_AmbientLevel( const vec3_t point, float *volumes );
trace_t CL_Trace( const vec3_t s1, const vec3_t m1, const vec3_t m2, const vec3_t s2, int type, edict_t *ed, int mask );
trace_t CL_Trace(const vec3_t s1, const vec3_t m1, const vec3_t m2, const vec3_t s2, int type, pr_edict_t *e, int mask);
//
// cl_ents.c

View File

@ -116,16 +116,6 @@ CLIENT / SERVER SYSTEMS
==============================================================
*/
#define FL_CLIENT (1<<0) // this is client
#define FL_MONSTER (1<<1) // this is npc
#define FL_DEADMONSTER (1<<2) // dead npc or dead player
#define FL_WORLDBRUSH (1<<3) // Not moveable/removeable brush entity
#define FL_DORMANT (1<<4) // Entity is dormant, no updates to client
#define FL_FRAMETHINK (1<<5) // entity will be thinking every frame
#define FL_GRAPHED (1<<6) // worldgraph has this ent listed as something that blocks a conection
#define FL_FLOAT (1<<7) // this entity can be floating. FIXME: remove this ?
#define FL_TRACKTRAIN (1<<8) // old stuff...
// encoded bmodel mask
#define SOLID_BMODEL 0xffffff
@ -139,6 +129,13 @@ void SV_Shutdown( bool reconnect );
void SV_Frame( dword time );
void SV_PacketEvent( netadr_t from, sizebuf_t *msg );
// exports
void SV_Transform( edict_t *ed, const vec3_t origin, const matrix3x3 transform );
void SV_PlaySound( edict_t *ed, float volume, float pitch, const char *sample );
float *SV_GetModelVerts( edict_t *ent, int *numvertices );
void SV_PlayerMove( edict_t *ed );
bool SV_Active( void );
/*
==============================================================
@ -146,10 +143,12 @@ PRVM INTERACTIONS
==============================================================
*/
char *ED_NewString( const char *string, byte *mempool );
#define prog vm->prog // global callback to vprogs.dll
#define PRVM_EDICT_NUM( num ) _PRVM_EDICT_NUM( num, __FILE__, __LINE__ )
_inline edict_t *_PRVM_EDICT_NUM( int n, const char * file, const int line )
_inline pr_edict_t *_PRVM_EDICT_NUM( int n, const char * file, const int line )
{
if(!prog) Host_Error(" prog unset at (%s:%d)\n", file, line );
if((n >= 0) && (n < prog->max_edicts))
@ -163,7 +162,7 @@ _inline edict_t *_PRVM_EDICT_NUM( int n, const char * file, const int line )
#define PRVM_NAME (prog->name ? prog->name : "unnamed.dat")
#define PRVM_ERROR if( prog ) prog->error_cmd
#define PRVM_NUM_FOR_EDICT(e) ((int)((edict_t *)(e) - prog->edicts))
#define PRVM_NUM_FOR_EDICT(e) ((int)((pr_edict_t *)(e) - prog->edicts))
#define PRVM_NEXT_EDICT(e) ((e) + 1)
#define PRVM_EDICT_TO_PROG(e) (PRVM_NUM_FOR_EDICT(e))
#define PRVM_PROG_TO_EDICT(n) (PRVM_EDICT_NUM(n))
@ -185,7 +184,6 @@ _inline edict_t *_PRVM_EDICT_NUM( int n, const char * file, const int line )
// helper common functions
const char *VM_VarArgs( int start_arg );
bool VM_ValidateArgs( const char *builtin, int num_argc );
void VM_SetTraceGlobals( const trace_t *trace );
#define VM_ValidateString( str ) _VM_ValidateString( str, __FILE__, __LINE__ )
void _VM_ValidateString( const char *s, const char *filename, const int fileline );
void VM_Cmd_Init( void );
@ -223,6 +221,9 @@ void VM_Cmd_Reset( void );
#define PRVM_ED_FindGlobal vm->FindGlobal
#define PRVM_ED_FindFunction vm->FindFunction
edict_t *ED_Alloc( void );
void ED_Free( edict_t *e);
// builtins and other general functions
void VM_ConPrintf( void );
void VM_ConDPrintf( void );

36
engine/common/com_edict.c Normal file
View File

@ -0,0 +1,36 @@
//=======================================================================
// Copyright XashXT Group 2008 ©
// com_edict.c - generic edict manager
//=======================================================================
#include "common.h"
/*
=============
ED_NewString
FIXME: hashtable ?
=============
*/
char *ED_NewString( const char *string, byte *mempool )
{
char *data, *data_p;
int i, l;
l = com.strlen( string ) + 1;
data = Mem_Alloc( mempool, l );
data_p = data;
for( i = 0; i < l; i++ )
{
if( string[i] == '\\' && i < l - 1 )
{
i++;
if( string[i] == 'n' )
*data_p++ = '\n';
else *data_p++ = '\\';
}
else *data_p++ = string[i];
}
return data;
}

125
engine/common/com_library.h Normal file
View File

@ -0,0 +1,125 @@
//=======================================================================
// Copyright XashXT Group 2008 ©
// com_library.h - custom dlls loader
//=======================================================================
#ifndef COM_LIBRARY
#define COM_LIBRARY
#define DOS_SIGNATURE 0x5A4D // MZ
#define NT_SIGNATURE 0x00004550 // PE00
#define NUMBEROF_DIRECTORY_ENTRIES 16
typedef struct
{
// dos .exe header
word e_magic; // magic number
word e_cblp; // bytes on last page of file
word e_cp; // pages in file
word e_crlc; // relocations
word e_cparhdr; // size of header in paragraphs
word e_minalloc; // minimum extra paragraphs needed
word e_maxalloc; // maximum extra paragraphs needed
word e_ss; // initial (relative) SS value
word e_sp; // initial SP value
word e_csum; // checksum
word e_ip; // initial IP value
word e_cs; // initial (relative) CS value
word e_lfarlc; // file address of relocation table
word e_ovno; // overlay number
word e_res[4]; // reserved words
word e_oemid; // OEM identifier (for e_oeminfo)
word e_oeminfo; // OEM information; e_oemid specific
word e_res2[10]; // reserved words
long e_lfanew; // file address of new exe header
} DOS_HEADER;
typedef struct
{
// win .exe header
word Machine;
word NumberOfSections;
dword TimeDateStamp;
dword PointerToSymbolTable;
dword NumberOfSymbols;
word SizeOfOptionalHeader;
word Characteristics;
} PE_HEADER;
typedef struct
{
byte Name[8]; // dos name length
union
{
dword PhysicalAddress;
dword VirtualSize;
} Misc;
dword VirtualAddress;
dword SizeOfRawData;
dword PointerToRawData;
dword PointerToRelocations;
dword PointerToLinenumbers;
word NumberOfRelocations;
word NumberOfLinenumbers;
dword Characteristics;
} SECTION_HEADER;
typedef struct
{
dword VirtualAddress;
dword Size;
} DATA_DIRECTORY;
typedef struct
{
word Magic;
byte MajorLinkerVersion;
byte MinorLinkerVersion;
dword SizeOfCode;
dword SizeOfInitializedData;
dword SizeOfUninitializedData;
dword AddressOfEntryPoint;
dword BaseOfCode;
dword BaseOfData;
dword ImageBase;
dword SectionAlignment;
dword FileAlignment;
word MajorOperatingSystemVersion;
word MinorOperatingSystemVersion;
word MajorImageVersion;
word MinorImageVersion;
word MajorSubsystemVersion;
word MinorSubsystemVersion;
dword Win32VersionValue;
dword SizeOfImage;
dword SizeOfHeaders;
dword CheckSum;
word Subsystem;
word DllCharacteristics;
dword SizeOfStackReserve;
dword SizeOfStackCommit;
dword SizeOfHeapReserve;
dword SizeOfHeapCommit;
dword LoaderFlags;
dword NumberOfRvaAndSizes;
DATA_DIRECTORY DataDirectory[NUMBEROF_DIRECTORY_ENTRIES];
} OPTIONAL_HEADER;
typedef struct
{
dword Characteristics;
dword TimeDateStamp;
word MajorVersion;
word MinorVersion;
dword Name;
dword Base;
dword NumberOfFunctions;
dword NumberOfNames;
dword AddressOfFunctions; // RVA from base of image
dword AddressOfNames; // RVA from base of image
dword AddressOfNameOrdinals; // RVA from base of image
} EXPORT_DIRECTORY;
#endif//COM_LIBRARY

View File

@ -517,7 +517,7 @@ bool Cmd_CheckMapsList( void )
{
Com_ReadToken( ents, 0, &token );
Msg("read token: %s\n", token.string );
if(!com.strcmp( token.string, "info_player_deatchmatch" ))
if(!com.strcmp( token.string, "info_player_deathmatch" ))
num_spawnpoints++;
else if(!com.strcmp( token.string, "info_player_start" ))
num_spawnpoints++;

View File

@ -8,7 +8,6 @@
#include "mathlib.h"
#include "const.h"
#include "client.h"
#include "server.h"
/*
=======================================================================
@ -36,19 +35,6 @@ void _VM_ValidateString( const char *s, const char *filename, const int fileline
if( s[0] <= ' ' ) PRVM_ERROR( "%s: bad string (called at %s:%i)\n", PRVM_NAME, filename, fileline );
}
void VM_SetTraceGlobals( const trace_t *trace )
{
prog->globals.sv->trace_allsolid = trace->allsolid;
prog->globals.sv->trace_startsolid = trace->startsolid;
prog->globals.sv->trace_fraction = trace->fraction;
prog->globals.sv->trace_contents = trace->contents;
VectorCopy (trace->endpos, prog->globals.sv->trace_endpos);
VectorCopy (trace->plane.normal, prog->globals.sv->trace_plane_normal);
prog->globals.sv->trace_plane_dist = trace->plane.dist;
if( trace->ent ) prog->globals.sv->trace_ent = PRVM_EDICT_TO_PROG( trace->ent );
else prog->globals.sv->trace_ent = PRVM_EDICT_TO_PROG( prog->edicts ); // world
}
/*
=========
VM_VarArgs
@ -208,7 +194,7 @@ void Com_Error( ... )
*/
void VM_HostError( void )
{
edict_t *ed;
pr_edict_t *ed;
const char *s = VM_VarArgs( 0 );
Msg( "====== %s ERROR in %s:\n%s\n", PRVM_NAME, PRVM_GetString(prog->xfunction->s_name), s );
@ -229,7 +215,7 @@ void Ed_Error( ... )
*/
void VM_EdictError( void )
{
edict_t *ed;
pr_edict_t *ed;
const char *s = VM_VarArgs( 0 );
Msg( "======OBJECT ERROR======\n", PRVM_NAME, PRVM_GetString(prog->xfunction->s_name), s );
@ -836,7 +822,7 @@ entity spawn( void )
*/
void VM_SpawnEdict( void )
{
edict_t *ed;
pr_edict_t *ed;
prog->xfunction->builtinsprofile += 20;
ed = PRVM_ED_Alloc();
@ -852,7 +838,7 @@ void remove( entity ent )
*/
void VM_RemoveEdict( void )
{
edict_t *ed;
pr_edict_t *ed;
if(!VM_ValidateArgs( "remove", 1 ))
return;
@ -881,8 +867,8 @@ void nextent( entity ent )
*/
void VM_NextEdict( void )
{
edict_t *ent;
int i;
pr_edict_t *ent;
int i;
if( !VM_ValidateArgs( "nextent", 1 ))
return;
@ -915,7 +901,7 @@ void copyentity( entity src, entity dst )
*/
void VM_CopyEdict( void )
{
edict_t *in, *out;
pr_edict_t *in, *out;
if(!VM_ValidateArgs( "copyentity", 1 ))
return;
@ -936,7 +922,7 @@ void VM_FindEdict( void )
{
int e, f;
const char *s, *t;
edict_t *ed;
pr_edict_t *ed;
if(!VM_ValidateArgs( "find", 2 ))
return;
@ -971,9 +957,9 @@ entity findfloat(entity start, .float field, float match)
*/
void VM_FindField( void )
{
int e, f;
float s;
edict_t *ed;
int e, f;
float s;
pr_edict_t *ed;
if(!VM_ValidateArgs( "findfloat", 2 ))
return;

View File

@ -206,19 +206,19 @@ void Info_SetValueForKey (char *s, char *key, char *value)
*s = 0;
}
static void Cvar_LookupBitInfo(const char *name, const char *string, const char *info, void *unused)
static void Cvar_LookupBitInfo( const char *name, const char *string, const char *info, void *unused )
{
Info_SetValueForKey((char *)info, (char *)name, (char *)string);
Info_SetValueForKey( (char *)info, (char *)name, (char *)string );
}
char *Cvar_Userinfo (void)
char *Cvar_Userinfo( void )
{
sv_info[0] = 0; // clear previous calls
Cvar_LookupVars( CVAR_USERINFO, sv_info, NULL, Cvar_LookupBitInfo );
return sv_info;
}
char *Cvar_Serverinfo (void)
char *Cvar_Serverinfo( void )
{
sv_info[0] = 0; // clear previous calls
Cvar_LookupVars( CVAR_SERVERINFO, sv_info, NULL, Cvar_LookupBitInfo );

View File

@ -131,9 +131,11 @@ static const net_desc_t NWDesc[] =
#define CS_MODELS 16 // configstrings starts here
#define CS_SOUNDS (CS_MODELS+MAX_MODELS) // sound names
#define CS_CLASSNAMES (CS_SOUNDS+MAX_SOUNDS) // edicts classnames
#define CS_DECALS (CS_SOUNDS+MAX_SOUNDS) // server decal indexes
#define CS_CLASSNAMES (CS_DECALS+MAX_DECALS) // edicts classnames
#define CS_LIGHTSTYLES (CS_CLASSNAMES+MAX_CLASSNAMES) // lightstyle patterns
#define MAX_CONFIGSTRINGS (CS_LIGHTSTYLES+MAX_LIGHTSTYLES) // total count
#define CS_USER_MESSAGES (CS_LIGHTSTYLES+MAX_LIGHTSTYLES) // names of user messages
#define MAX_CONFIGSTRINGS (CS_USER_MESSAGES+MAX_USER_MESSAGES) // total count
// sound flags (get rid of this)
#define SND_VOL (1<<0) // a scaled byte

View File

@ -162,6 +162,10 @@ SOURCE=.\client\cl_view.c
# End Source File
# Begin Source File
SOURCE=.\common\com_edict.c
# End Source File
# Begin Source File
SOURCE=.\common\con_keys.c
# End Source File
# Begin Source File
@ -222,6 +226,10 @@ SOURCE=.\server\sv_frame.c
# End Source File
# Begin Source File
SOURCE=.\server\sv_game.c
# End Source File
# Begin Source File
SOURCE=.\server\sv_init.c
# End Source File
# Begin Source File

View File

@ -5,7 +5,6 @@
#include "common.h"
#include "input.h"
#include "server.h"
#include "client.h"
#define VID_NUM_MODES ( sizeof( vid_modes ) / sizeof( vid_modes[0] ))
@ -385,7 +384,7 @@ dword Host_EventLoop( void )
continue;
}
Mem_Copy( buf.data, (byte *)((netadr_t *)ev.data + 1), buf.cursize );
if ( svs.initialized ) SV_PacketEvent( ev_from, &buf );
if ( SV_Active()) SV_PacketEvent( ev_from, &buf );
else CL_PacketEvent( ev_from, &buf );
break;
default:

View File

@ -22,9 +22,12 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#define SERVER_H
#include "mathlib.h"
#include "sv_edict.h"
#include "svprog_def.h"
#include "svgame_api.h"
//=============================================================================
#define NUM_FOR_EDICT(e) ((int)((edict_t *)(e) - svg.edicts))
#define EDICT_NUM( num ) _EDICT_NUM( num, __FILE__, __LINE__ )
#define AREA_SOLID 1
#define AREA_TRIGGERS 2
@ -32,7 +35,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#define MAX_MASTERS 8 // max recipients for heartbeat packets
#define LATENCY_COUNTS 16
#define MAX_ENT_CLUSTERS 16
#define DF_NO_FRIENDLY_FIRE 0x00000001 // FIXME: move to server.dat
// classic quake flags
#define SPAWNFLAG_NOT_EASY 0x00000100
@ -40,21 +42,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#define SPAWNFLAG_NOT_HARD 0x00000400
#define SPAWNFLAG_NOT_DEATHMATCH 0x00000800
#define AI_FLY BIT(0) // monster is flying
#define AI_SWIM BIT(1) // swimming monster
#define AI_ONGROUND BIT(2) // monster is onground
#define AI_PARTIALONGROUND BIT(3) // monster is partially onground
#define AI_GODMODE BIT(4) // monster don't give damage at all
#define AI_NOTARGET BIT(5) // monster will no searching enemy's
#define AI_NOSTEP BIT(6) // Lazarus stuff
#define AI_DUCKED BIT(7) // monster (or player) is ducked
#define AI_JUMPING BIT(8) // monster (or player) is jumping
#define AI_FROZEN BIT(9) // stop moving, but continue thinking
#define AI_ACTOR BIT(10) // disable ai for actor
#define AI_DRIVER BIT(11) // npc or player driving vehcicle or train
#define AI_SPECTATOR BIT(12) // spectator mode for clients
#define AI_WATERJUMP BIT(13) // npc or player take out of water
typedef enum
{
ss_dead, // no map loaded
@ -155,16 +142,12 @@ typedef struct link_s
{
struct link_s *prev;
struct link_s *next;
int entnum; // PRVM_EDICT_NUM
int entnum; // NUM_FOR_EDICT
} link_t;
struct sv_edict_s
// sv_private_edict_t
struct ed_priv_s
{
// generic_edict_t (don't move these fields!)
bool free;
float freetime; // sv.time when the object was freed
// sv_private_edict_t
link_t area; // linked to a division node or leaf
struct sv_client_s *client; // filled for player ents
int clipmask; // trace info
@ -182,7 +165,6 @@ struct sv_edict_s
vec3_t moved_origin; // push old origin
vec3_t moved_angles; // push old angles
int serialnumber; // unical entity #id
int solid; // see entity_state_t for details
physbody_t *physbody; // ptr to phys body
@ -213,12 +195,37 @@ typedef struct
bool connected;
} challenge_t;
typedef struct
{
int msg_sizes[MAX_USER_MESSAGES]; // user messages bounds checker
int msg_leftsize; // left in bytes
int msg_index; // for debug messages
edict_t *edicts;
// library exports table
word *ordinals;
dword *funcs;
char *names[MAX_SYSPATH]; // max 1024 exports supported
int num_ordinals; // actual exports count
dword funcBase; // base offset
} game_static_t;
typedef struct
{
bool initialized; // sv_init has completed
dword realtime; // always increasing, no clamping, etc
dword timeleft;
dll_info_t *game; // pointer to server.dll
globalvars_t *globals; // server globals
DLL_FUNCTIONS dllFuncs; // dll exported funcs
byte *mempool; // edicts pool
byte *private; // server.dll private pool
byte *stringpool; // sv.strings pool
int msg_dest; // msg destination ( MSG_ONE, MSG_ALL etc )
edict_t *msg_ent;
vec3_t msg_org;
string mapcmd; // ie: *intro.cin+base
string comment; // map name, e.t.c.
@ -229,7 +236,6 @@ typedef struct
int next_client_entities; // next client_entity to use
entity_state_t *client_entities; // [num_client_entities]
entity_state_t *baselines; // [host.max_edicts]
func_t ClientMove; // qc client physic
int last_heartbeat;
@ -241,6 +247,7 @@ typedef struct
extern netadr_t master_adr[MAX_MASTERS]; // address of the master server
extern const char *ed_name[];
extern server_static_t svs; // persistant server info
extern game_static_t svg; // persistant game info
extern server_t sv; // local server
extern cvar_t *sv_paused;
@ -276,6 +283,8 @@ void SV_DropClient (sv_client_t *drop);
int SV_ModelIndex (const char *name);
int SV_SoundIndex (const char *name);
int SV_ClassIndex (const char *name);
int SV_DecalIndex (const char *name);
int SV_UserMessageIndex (const char *name);
void SV_WriteClientdataToMessage (sv_client_t *client, sizebuf_t *msg);
void SV_ExecuteUserCommand (char *s);
@ -294,14 +303,12 @@ void SV_Map( char *levelstring, char *savename );
void SV_SpawnServer( const char *server, const char *savename );
int SV_FindIndex (const char *name, int start, int end, bool create);
void SV_ClassifyEdict( edict_t *ent );
void SV_VM_Begin( void );
void SV_VM_End( void );
//
// sv_phys.c
//
void SV_Physics( void );
void SV_PlayerMove( sv_edict_t *ed );
void SV_PlayerMove( edict_t *ed );
void SV_DropToFloor( edict_t *ent );
void SV_CheckGround( edict_t *ent );
bool SV_UnstickEntity( edict_t *ent );
@ -314,8 +321,8 @@ bool SV_CheckBottom (edict_t *ent);
//
// sv_move.c
//
void SV_Transform( sv_edict_t *ed, const vec3_t origin, const matrix3x3 transform );
void SV_PlaySound( sv_edict_t *ed, float volume, float pitch, const char *sample );
void SV_Transform( edict_t *ed, const vec3_t origin, const matrix3x3 transform );
void SV_PlaySound( edict_t *ed, float volume, float pitch, const char *sample );
bool SV_movestep( edict_t *ent, vec3_t move, bool relink, bool noenemy, bool settrace );
//
@ -356,33 +363,45 @@ void SV_Error (char *error, ...);
//
// sv_game.c
//
void SV_InitServerProgs( void );
void SV_FreeServerProgs( void );
bool SV_LoadProgs( const char *name );
void SV_UnloadProgs( void );
void SV_InitEdict (edict_t *e);
void SV_ConfigString (int index, const char *val);
void SV_SetModel (edict_t *ent, const char *name);
void SV_CreatePhysBody( edict_t *ent );
void SV_SetPhysForce( edict_t *ent );
void SV_SetMassCentre( edict_t *ent);
void SV_CopyTraceToGlobal( trace_t *trace );
void SV_CopyTraceResult( TraceResult *out, trace_t trace );
float SV_AngleMod( float ideal, float current, float speed );
void SV_SpawnEntities( const char *mapname, script_t *entities );
_inline edict_t *_EDICT_NUM( int n, const char * file, const int line )
{
if((n >= 0) && (n < svs.globals->maxEntities))
return svg.edicts + n;
Host_Error( "EDICT_NUM: bad number %i (called at %s:%i)\n", n, file, line );
return NULL;
}
// for constant strings
#define STRING( offset ) (const char *)( svs.globals->pStringBase + (int)offset )
#define MAKE_STRING(str) ((int)str - (int)STRING( 0 ))
//
// sv_studio.c
//
cmodel_t *SV_GetModelPtr( edict_t *ent );
float *SV_GetModelVerts( sv_edict_t *ent, int *numvertices );
float *SV_GetModelVerts( edict_t *ent, int *numvertices );
int SV_StudioExtractBbox( dstudiohdr_t *phdr, int sequence, float *mins, float *maxs );
bool SV_CreateMeshBuffer( edict_t *in, cmodel_t *out );
//
// sv_spawn.c
//
void SV_SpawnEntities( const char *mapname, const char *entities );
void SV_StartParticle (vec3_t org, vec3_t dir, int color, int count);
void SV_FreeEdict (edict_t *ed);
void SV_InitEdict (edict_t *e);
edict_t *SV_Spawn (void);
void SV_StartParticle( const float *org, const float *dir, int color, int count );
void SV_FreeEdict( edict_t *ed );
edict_t *SV_AllocEdict( void );
bool SV_ClientConnect (edict_t *ent, char *userinfo);
void SV_TouchTriggers (edict_t *ent);

View File

@ -173,8 +173,8 @@ gotnewcl:
sv_client = newcl;
edictnum = (newcl - svs.clients) + 1;
ent = PRVM_EDICT_NUM( edictnum );
ent->priv.sv->client = newcl;
ent = EDICT_NUM( edictnum );
ent->pvEngineData->client = newcl;
newcl->edict = ent;
newcl->challenge = challenge; // save challenge for checksumming
@ -223,14 +223,12 @@ bool SV_ClientConnect( edict_t *ent, char *userinfo )
bool result = true;
// make sure we start with known default
ent->progs.sv->flags = 0;
ent->progs.sv->aiflags = 0;
ent->v.flags = 0;
ent->v.aiflags = 0;
MsgDev(D_NOTE, "SV_ClientConnect()\n");
prog->globals.sv->time = sv.time;
prog->globals.sv->pev = PRVM_EDICT_TO_PROG(ent);
PRVM_ExecuteProgram (prog->globals.sv->ClientConnect, "ClientConnect");
result = (int)PRVM_G_FLOAT(OFS_RETURN);
svs.globals->time = sv.time;
result = svs.dllFuncs.pfnClientConnect( ent, userinfo );
return result;
}
@ -250,15 +248,13 @@ void SV_DropClient( sv_client_t *drop )
if( drop->state == cs_zombie ) return; // already dropped
SV_VM_Begin();
// add the disconnect
MSG_WriteByte( &drop->netchan.message, svc_disconnect );
// let the game known about client state
prog->globals.sv->time = sv.time;
prog->globals.sv->pev = PRVM_EDICT_TO_PROG( drop->edict );
PRVM_ExecuteProgram( prog->globals.sv->ClientDisconnect, "ClientDisconnect" );
svs.globals->time = sv.time;
svs.dllFuncs.pfnClientDisconnect( drop->edict );
SV_FreeEdict( drop->edict );
if( drop->download ) drop->download = NULL;
@ -351,7 +347,7 @@ char *SV_StatusString( void )
cl = &svs.clients[i];
if( cl->state == cs_connected || cl->state == cs_spawned )
{
com.sprintf( player, "%i %i \"%s\"\n", (int)cl->edict->progs.sv->frags, cl->ping, cl->name );
com.sprintf( player, "%i %i \"%s\"\n", (int)cl->edict->v.frags, cl->ping, cl->name );
playerLength = com.strlen(player);
if( statusLength + playerLength >= sizeof(status))
break; // can't hold any more
@ -485,56 +481,53 @@ void SV_PutClientInServer( edict_t *ent )
edict_t *viewmodel;
int i;
index = PRVM_NUM_FOR_EDICT( ent ) - 1;
client = ent->priv.sv->client;
index = NUM_FOR_EDICT( ent ) - 1;
client = ent->pvEngineData->client;
prog->globals.sv->time = sv.time;
prog->globals.sv->pev = PRVM_EDICT_TO_PROG( ent );
ent->priv.sv->free = false;
(int)ent->progs.sv->flags &= ~FL_DEADMONSTER;
ent->priv.sv->s.ed_type = ED_CLIENT; // init edict type
svs.globals->time = sv.time;
ent->free = false;
ent->pvEngineData->s.ed_type = ED_CLIENT; // init edict type
if( !sv.loadgame )
{
// fisrt entering
PRVM_ExecuteProgram( prog->globals.sv->PutClientInServer, "PutClientInServer" );
ent->progs.sv->v_angle[ROLL] = 0; // cut off any camera rolling
ent->progs.sv->origin[2] += 1; // make sure off ground
svs.dllFuncs.pfnClientPutInServer( ent );
ent->v.v_angle[ROLL] = 0; // cut off any camera rolling
ent->v.origin[2] += 1; // make sure off ground
// create viewmodel
viewmodel = PRVM_ED_Alloc();
viewmodel->progs.sv->classname = PRVM_SetEngineString( "viewmodel" );
VectorCopy( ent->progs.sv->view_ofs, viewmodel->progs.sv->view_ofs );
VectorCopy( ent->progs.sv->origin, viewmodel->progs.sv->origin );
VectorCopy( ent->progs.sv->angles, viewmodel->progs.sv->angles );
viewmodel->progs.sv->model = ent->progs.sv->v_model;
viewmodel->progs.sv->movetype = MOVETYPE_FOLLOW;
viewmodel = SV_AllocEdict();
viewmodel->v.classname = MAKE_STRING( "viewmodel" );
VectorCopy( ent->v.view_ofs, viewmodel->v.view_ofs );
VectorCopy( ent->v.origin, viewmodel->v.origin );
VectorCopy( ent->v.angles, viewmodel->v.angles );
viewmodel->v.model = ent->v.viewmodel;
viewmodel->v.movetype = MOVETYPE_FOLLOW;
// make cross links for consistency
viewmodel->progs.sv->aiment = PRVM_NUM_FOR_EDICT( ent );
ent->progs.sv->aiment = PRVM_NUM_FOR_EDICT( viewmodel );
viewmodel->v.aiment = ent;
ent->v.aiment = viewmodel;
}
else
{
// restore viewmodel
viewmodel = PRVM_EDICT_NUM( ent->progs.sv->aiment );
viewmodel = ent->v.aiment;
}
ent->priv.sv->s.fov = 90; // FIXME: get from qc
ent->priv.sv->s.fov = bound(1, ent->priv.sv->s.fov, 160);
ent->priv.sv->s.health = ent->progs.sv->health;
ent->priv.sv->s.classname = SV_ClassIndex(PRVM_GetString( ent->progs.sv->classname ));
ent->priv.sv->s.pmodel.index = SV_ModelIndex(PRVM_GetString( ent->progs.sv->p_model));
VectorCopy( ent->progs.sv->origin, ent->priv.sv->s.origin );
VectorCopy( ent->progs.sv->v_angle, ent->priv.sv->s.viewangles );
for( i = 0; i < 3; i++ ) ent->priv.sv->s.delta_angles[i] = ANGLE2SHORT(ent->progs.sv->v_angle[i]);
viewmodel->priv.sv->s.ed_type = ED_VIEWMODEL; // set entity type
viewmodel->progs.sv->modelindex = SV_ModelIndex(PRVM_GetString(viewmodel->progs.sv->model));
viewmodel->priv.sv->s.classname = SV_ClassIndex(PRVM_GetString(viewmodel->progs.sv->classname));
ent->pvEngineData->s.fov = 90; // FIXME: get from qc
ent->pvEngineData->s.fov = bound(1, ent->pvEngineData->s.fov, 160);
ent->pvEngineData->s.health = ent->v.health;
ent->pvEngineData->s.classname = SV_ClassIndex( STRING( ent->v.classname ));
ent->pvEngineData->s.pmodel.index = SV_ModelIndex( STRING( ent->v.weaponmodel ));
VectorCopy( ent->v.origin, ent->pvEngineData->s.origin );
VectorCopy( ent->v.v_angle, ent->pvEngineData->s.viewangles );
for( i = 0; i < 3; i++ ) ent->pvEngineData->s.delta_angles[i] = ANGLE2SHORT(ent->v.v_angle[i]);
viewmodel->pvEngineData->s.ed_type = ED_VIEWMODEL; // set entity type
viewmodel->v.modelindex = SV_ModelIndex( STRING( viewmodel->v.model ));
viewmodel->pvEngineData->s.classname = SV_ClassIndex( STRING( viewmodel->v.classname ));
SV_LinkEdict( ent ); // m_pmatrix calculated here, so we need call this before pe->CreatePlayer
ent->priv.sv->physbody = pe->CreatePlayer( ent->priv.sv, SV_GetModelPtr( ent ), ent->progs.sv->origin, ent->progs.sv->m_pmatrix );
ent->pvEngineData->physbody = pe->CreatePlayer( ent, SV_GetModelPtr( ent ), ent->v.origin, ent->v.m_pmatrix );
}
/*
@ -576,8 +569,8 @@ void SV_New_f( sv_client_t *cl )
if( sv.state == ss_active )
{
// set up the entity for the client
ent = PRVM_EDICT_NUM( playernum + 1 );
ent->priv.sv->serialnumber = playernum + 1;
ent = EDICT_NUM( playernum + 1 );
ent->serialnumber = playernum + 1;
cl->edict = ent;
Mem_Set( &cl->lastcmd, 0, sizeof(cl->lastcmd));
@ -841,11 +834,9 @@ static void SV_UpdateUserinfo_f( sv_client_t *cl )
SV_UserinfoChanged( cl );
// call prog code to allow overrides
prog->globals.sv->pev = PRVM_EDICT_TO_PROG( cl->edict );
prog->globals.sv->time = sv.time;
prog->globals.sv->frametime = sv.frametime;
PRVM_G_INT(OFS_PARM0) = PRVM_SetEngineString( cl->userinfo );
PRVM_ExecuteProgram( prog->globals.sv->ClientUserInfoChanged, "ClientUserInfoChanged" );
svs.globals->time = sv.time;
svs.globals->frametime = sv.frametime;
svs.dllFuncs.pfnClientUserInfoChanged( cl->edict, cl->userinfo );
}
ucmd_t ucmds[] =
@ -884,10 +875,9 @@ void SV_ExecuteClientCommand( sv_client_t *cl, char *s )
if( !u->name && sv.state == ss_active )
{
// custom client commands
prog->globals.sv->pev = PRVM_EDICT_TO_PROG( cl->edict );
prog->globals.sv->time = sv.time;
prog->globals.sv->frametime = sv.frametime;
PRVM_ExecuteProgram( prog->globals.sv->ClientCommand, "ClientCommand" );
svs.globals->time = sv.time;
svs.globals->frametime = sv.frametime;
svs.dllFuncs.pfnClientCommand( cl->edict );
}
}
@ -959,7 +949,7 @@ void _MSG_Send( msgtype_t msg_type, vec3_t origin, edict_t *ent, const char *fil
// intentional fallthrough
case MSG_ONE:
if( ent == NULL ) return;
j = PRVM_NUM_FOR_EDICT( ent );
j = NUM_FOR_EDICT( ent );
if( j < 1 || j > numclients ) return;
current = svs.clients + (j - 1);
numclients = 1; // send to one
@ -981,7 +971,7 @@ void _MSG_Send( msgtype_t msg_type, vec3_t origin, edict_t *ent, const char *fil
{
area2 = pe->LeafArea( leafnum );
cluster = pe->LeafCluster( leafnum );
leafnum = pe->PointLeafnum( cl->edict->progs.sv->origin );
leafnum = pe->PointLeafnum( cl->edict->v.origin );
if(!pe->AreasConnected( area1, area2 )) continue;
if( mask && (!(mask[cluster>>3] & (1<<(cluster&7)))))
continue;
@ -1033,48 +1023,48 @@ void SV_ApplyClientMove( sv_client_t *cl, usercmd_t *cmd )
int i;
edict_t *ent = cl->edict;
// set the edict fields
ent->progs.sv->button0 = cmd->buttons & 1;
ent->progs.sv->button1 = (cmd->upmove < 0) ? 1 : 0;
ent->progs.sv->button2 = (cmd->upmove > 0) ? 1 : 0;
if( cmd->impulse ) ent->progs.sv->impulse = cmd->impulse;
ent->v.button = cmd->buttons; // initialize buttons
ent->v.button |= (cmd->upmove < 0) ? IN_DUCK : IN_JUMP;
ent->v.button |= (cmd->sidemove < 0) ? IN_MOVELEFT : IN_MOVERIGHT;
ent->v.button |= (cmd->forwardmove > 0) ? IN_FORWARD : IN_BACK;
if( cmd->impulse ) ent->v.impulse = cmd->impulse;
cmd->impulse = 0; // only send the impulse to qc once
// circularly clamp the angles with deltas
for( i = 0; i < 3; i++ )
{
temp = cmd->angles[i] + ent->priv.sv->s.delta_angles[i];
ent->priv.sv->s.viewangles[i] = SHORT2ANGLE( temp );
temp = cmd->angles[i] + ent->pvEngineData->s.delta_angles[i];
ent->pvEngineData->s.viewangles[i] = SHORT2ANGLE( temp );
}
// don't let the player look up or down more than 90 degrees
if( ent->priv.sv->s.viewangles[PITCH] > 89 && ent->priv.sv->s.viewangles[PITCH] < 180 )
ent->priv.sv->s.viewangles[PITCH] = 89;
else if( ent->priv.sv->s.viewangles[PITCH] < 271 && ent->priv.sv->s.viewangles[PITCH] >= 180 )
ent->priv.sv->s.viewangles[PITCH] = 271;
if( ent->pvEngineData->s.viewangles[PITCH] > 89 && ent->pvEngineData->s.viewangles[PITCH] < 180 )
ent->pvEngineData->s.viewangles[PITCH] = 89;
else if( ent->pvEngineData->s.viewangles[PITCH] < 271 && ent->pvEngineData->s.viewangles[PITCH] >= 180 )
ent->pvEngineData->s.viewangles[PITCH] = 271;
// test
if((int)ent->progs.sv->aiflags & AI_DUCKED )
if((int)ent->v.aiflags & AI_DUCKED )
{
cmd->forwardmove *= 0.333;
cmd->sidemove *= 0.333;
cmd->upmove *= 0.333;
}
VectorCopy( ent->priv.sv->s.viewangles, cl->edict->progs.sv->v_angle );
VectorCopy( ent->priv.sv->s.viewangles, cl->edict->progs.sv->angles );
VectorCopy( ent->progs.sv->view_ofs, cl->edict->priv.sv->s.viewoffset );
VectorCopy( ent->pvEngineData->s.viewangles, cl->edict->v.v_angle );
VectorCopy( ent->pvEngineData->s.viewangles, cl->edict->v.angles );
VectorCopy( ent->v.view_ofs, cl->edict->pvEngineData->s.viewoffset );
}
void SV_DropPunchAngle( sv_client_t *cl )
{
float len;
len = VectorNormalizeLength( cl->edict->progs.sv->punchangle );
len = VectorNormalizeLength( cl->edict->v.punchangle );
len -= 10 * sv.frametime;
if( len < 0 ) len = 0;
VectorScale( cl->edict->progs.sv->punchangle, len, cl->edict->progs.sv->punchangle );
VectorScale( cl->edict->v.punchangle, len, cl->edict->v.punchangle );
}
/*
@ -1090,13 +1080,13 @@ void SV_UserFriction( sv_client_t *cl )
vec3_t start, stop;
trace_t trace;
speed = sqrt(cl->edict->progs.sv->velocity[0] * cl->edict->progs.sv->velocity[0] + cl->edict->progs.sv->velocity[1] * cl->edict->progs.sv->velocity[1]);
speed = sqrt(cl->edict->v.velocity[0] * cl->edict->v.velocity[0] + cl->edict->v.velocity[1] * cl->edict->v.velocity[1]);
if( !speed ) return;
// if the leading edge is over a dropoff, increase friction
start[0] = stop[0] = cl->edict->progs.sv->origin[0] + cl->edict->progs.sv->velocity[0] / speed * 16;
start[1] = stop[1] = cl->edict->progs.sv->origin[1] + cl->edict->progs.sv->velocity[1] / speed * 16;
start[2] = cl->edict->progs.sv->origin[2] + cl->edict->progs.sv->mins[2];
start[0] = stop[0] = cl->edict->v.origin[0] + cl->edict->v.velocity[0] / speed * 16;
start[1] = stop[1] = cl->edict->v.origin[1] + cl->edict->v.velocity[1] / speed * 16;
start[2] = cl->edict->v.origin[2] + cl->edict->v.mins[2];
stop[2] = start[2] - 34;
trace = SV_Trace( start, vec3_origin, vec3_origin, stop, MOVE_NOMONSTERS, cl->edict, SV_ContentsMask( cl->edict ));
@ -1110,7 +1100,7 @@ void SV_UserFriction( sv_client_t *cl )
if( newspeed < 0 ) newspeed = 0;
else newspeed /= speed;
VectorScale( cl->edict->progs.sv->velocity, newspeed, cl->edict->progs.sv->velocity );
VectorScale( cl->edict->v.velocity, newspeed, cl->edict->v.velocity );
}
/*
@ -1151,12 +1141,12 @@ void SV_Accelerate( sv_client_t *cl )
float addspeed;
float accelspeed, currentspeed;
currentspeed = DotProduct( cl->edict->progs.sv->velocity, wishdir );
currentspeed = DotProduct( cl->edict->v.velocity, wishdir );
addspeed = wishspeed - currentspeed;
if( addspeed <= 0 ) return;
accelspeed = sv_accelerate->value * sv.frametime * wishspeed;
if( accelspeed > addspeed ) accelspeed = addspeed;
for( i = 0; i < 3; i++ ) cl->edict->progs.sv->velocity[i] += accelspeed * wishdir[i];
for( i = 0; i < 3; i++ ) cl->edict->v.velocity[i] += accelspeed * wishdir[i];
}
void SV_AirAccelerate( sv_client_t *cl, vec3_t wishveloc )
@ -1167,13 +1157,13 @@ void SV_AirAccelerate( sv_client_t *cl, vec3_t wishveloc )
wishspd = VectorNormalizeLength( wishveloc );
if( wishspd > 30 ) wishspd = 30;
currentspeed = DotProduct( cl->edict->progs.sv->velocity, wishveloc );
currentspeed = DotProduct( cl->edict->v.velocity, wishveloc );
addspeed = wishspd - currentspeed;
if( addspeed <= 0 ) return;
accelspeed = sv_accelerate->value * wishspeed * sv.frametime;
if( accelspeed > addspeed ) accelspeed = addspeed;
for( i = 0; i < 3; i++ ) cl->edict->progs.sv->velocity[i] += accelspeed * wishveloc[i];
for( i = 0; i < 3; i++ ) cl->edict->v.velocity[i] += accelspeed * wishveloc[i];
}
/*
@ -1191,7 +1181,7 @@ void SV_WaterMove( sv_client_t *cl, usercmd_t *cmd )
float accelspeed, temp;
// user intentions
AngleVectors( cl->edict->progs.sv->v_angle, forward, right, up );
AngleVectors( cl->edict->v.v_angle, forward, right, up );
for( i = 0; i < 3; i++ ) wishvel[i] = forward[i] * cmd->forwardmove + right[i] * cmd->sidemove;
@ -1209,13 +1199,13 @@ void SV_WaterMove( sv_client_t *cl, usercmd_t *cmd )
wishspeed *= 0.7;
// water friction
speed = VectorLength( cl->edict->progs.sv->velocity );
speed = VectorLength( cl->edict->v.velocity );
if( speed )
{
newspeed = speed - sv.frametime * speed * sv_friction->value;
if( newspeed < 0 ) newspeed = 0;
temp = newspeed / speed;
VectorScale( cl->edict->progs.sv->velocity, temp, cl->edict->progs.sv->velocity );
VectorScale( cl->edict->v.velocity, temp, cl->edict->v.velocity );
}
else newspeed = 0;
@ -1229,18 +1219,18 @@ void SV_WaterMove( sv_client_t *cl, usercmd_t *cmd )
accelspeed = sv_accelerate->value * wishspeed * sv.frametime;
if( accelspeed > addspeed ) accelspeed = addspeed;
for( i = 0; i < 3; i++ ) cl->edict->progs.sv->velocity[i] += accelspeed * wishvel[i];
for( i = 0; i < 3; i++ ) cl->edict->v.velocity[i] += accelspeed * wishvel[i];
}
void SV_WaterJump( sv_client_t *cl )
{
if (sv.time > cl->edict->progs.sv->teleport_time || !cl->edict->progs.sv->waterlevel )
if (sv.time > cl->edict->v.teleport_time || !cl->edict->v.waterlevel )
{
cl->edict->progs.sv->flags = (int)cl->edict->progs.sv->aiflags & ~AI_WATERJUMP;
cl->edict->progs.sv->teleport_time = 0;
cl->edict->v.flags = (int)cl->edict->v.aiflags & ~AI_WATERJUMP;
cl->edict->v.teleport_time = 0;
}
cl->edict->progs.sv->velocity[0] = cl->edict->progs.sv->movedir[0];
cl->edict->progs.sv->velocity[1] = cl->edict->progs.sv->movedir[1];
cl->edict->v.velocity[0] = cl->edict->v.movedir[0];
cl->edict->v.velocity[1] = cl->edict->v.movedir[1];
}
/*
@ -1256,19 +1246,19 @@ void SV_AirMove( sv_client_t *cl, usercmd_t *cmd )
float fmove, smove, temp;
wishvel[0] = wishvel[2] = 0;
wishvel[1] = cl->edict->progs.sv->angles[1];
wishvel[1] = cl->edict->v.angles[1];
AngleVectors( wishvel, forward, right, up );
fmove = cmd->forwardmove;
smove = cmd->sidemove;
// hack to not let you back into teleporter
if( sv.time < cl->edict->progs.sv->teleport_time && fmove < 0 )
if( sv.time < cl->edict->v.teleport_time && fmove < 0 )
fmove = 0;
for( i = 0; i < 3; i++ ) wishvel[i] = forward[i] * fmove + right[i] * smove;
if((int)cl->edict->progs.sv->movetype != MOVETYPE_WALK )
if((int)cl->edict->v.movetype != MOVETYPE_WALK )
wishvel[2] += cmd->upmove;
VectorCopy( wishvel, wishdir );
@ -1280,10 +1270,10 @@ void SV_AirMove( sv_client_t *cl, usercmd_t *cmd )
wishspeed = sv_maxspeed->value;
}
if( cl->edict->progs.sv->movetype == MOVETYPE_NOCLIP )
if( cl->edict->v.movetype == MOVETYPE_NOCLIP )
{
// noclip
VectorCopy( wishvel, cl->edict->progs.sv->velocity );
VectorCopy( wishvel, cl->edict->v.velocity );
}
else if( onground )
{
@ -1319,38 +1309,28 @@ void SV_ClientThink( sv_client_t *cl, usercmd_t *cmd )
// make sure the velocity is sane (not a NaN)
SV_CheckVelocity( cl->edict );
// LordHavoc: QuakeC replacement for SV_ClientThink (player movement)
/*if( svs.ClientMove )
{
prog->globals.sv->time = sv.time;
prog->globals.sv->pev = PRVM_EDICT_TO_PROG( cl->edict );
PRVM_ExecuteProgram( svs.ClientMove, "ClientMove" );
SV_CheckVelocity( cl->edict );
return;
}*/
if( cl->edict->progs.sv->movetype == MOVETYPE_NONE )
if( cl->edict->v.movetype == MOVETYPE_NONE )
return;
onground = (int)cl->edict->progs.sv->aiflags & AI_ONGROUND;
onground = (cl->edict->v.flags & FL_ONGROUND);
SV_DropPunchAngle( cl );
// if dead, behave differently
if( cl->edict->progs.sv->health <= 0 )
if( cl->edict->v.health <= 0 )
return;
// angles
// show 1/3 the pitch angle and all the roll angle
VectorAdd( cl->edict->progs.sv->v_angle, cl->edict->progs.sv->punchangle, v_angle );
cl->edict->progs.sv->angles[ROLL] = SV_CalcRoll( cl->edict->progs.sv->angles, cl->edict->progs.sv->velocity) * 4;
if( !cl->edict->progs.sv->fixangle )
VectorAdd( cl->edict->v.v_angle, cl->edict->v.punchangle, v_angle );
cl->edict->v.angles[ROLL] = SV_CalcRoll( cl->edict->v.angles, cl->edict->v.velocity) * 4;
if( !cl->edict->v.fixangle )
{
cl->edict->progs.sv->angles[PITCH] = -v_angle[PITCH]/3;
cl->edict->progs.sv->angles[YAW] = v_angle[YAW];
cl->edict->v.angles[PITCH] = -v_angle[PITCH]/3;
cl->edict->v.angles[YAW] = v_angle[YAW];
}
if((int)cl->edict->progs.sv->aiflags & AI_WATERJUMP )
if((int)cl->edict->v.aiflags & AI_WATERJUMP )
{
SV_WaterJump( cl );
SV_CheckVelocity( cl->edict );
@ -1358,7 +1338,7 @@ void SV_ClientThink( sv_client_t *cl, usercmd_t *cmd )
}
// walk
if((cl->edict->progs.sv->waterlevel >= 2) && (cl->edict->progs.sv->movetype != MOVETYPE_NOCLIP))
if((cl->edict->v.waterlevel >= 2) && (cl->edict->v.movetype != MOVETYPE_NOCLIP))
{
SV_WaterMove( cl, &cl->cmd );
SV_CheckVelocity( cl->edict );
@ -1367,8 +1347,8 @@ void SV_ClientThink( sv_client_t *cl, usercmd_t *cmd )
SV_AirMove( cl, &cl->cmd );
SV_CheckVelocity( cl->edict );
VectorCopy( cl->edict->progs.sv->origin, cl->edict->priv.sv->s.origin );
VectorCopy( cl->edict->progs.sv->velocity, cl->edict->priv.sv->s.velocity );
VectorCopy( cl->edict->v.origin, cl->edict->pvEngineData->s.origin );
VectorCopy( cl->edict->v.velocity, cl->edict->pvEngineData->s.velocity );
}
/*
@ -1427,8 +1407,8 @@ static void SV_UserMove( sv_client_t *cl, sizebuf_t *msg )
if( !sv_paused->value )
{
frametime[0] = sv.frametime;
frametime[1] = prog->globals.sv->frametime;
prog->globals.sv->frametime = sv.frametime = newcmd.msec * 0.001f;
frametime[1] = svs.globals->frametime;
svs.globals->frametime = sv.frametime = newcmd.msec * 0.001f;
net_drop = cl->netchan.dropped;
if( net_drop < 20 )
@ -1444,7 +1424,7 @@ static void SV_UserMove( sv_client_t *cl, sizebuf_t *msg )
SV_Physics_ClientMove( cl, &newcmd );
}
sv.frametime = frametime[0];
prog->globals.sv->frametime = frametime[1];
svs.globals->frametime = frametime[1];
cl->lastcmd = newcmd;
}

View File

@ -308,14 +308,14 @@ void SV_ChangeLevel_f( void )
savedFree = Z_Malloc(Host_MaxClients() * sizeof(bool));
for (i = 0, cl = svs.clients; i < Host_MaxClients(); i++, cl++)
{
savedFree[i] = cl->edict->priv.sv->free;
cl->edict->priv.sv->free = true;
savedFree[i] = cl->edict->free;
cl->edict->free = true;
}
SV_WriteSaveFile( "save0.bin" ); // autosave
// we must restore these for clients to transfer over correctly
for (i = 0, cl = svs.clients; i < Host_MaxClients(); i++, cl++)
cl->edict->priv.sv->free = savedFree[i];
Mem_Free(savedFree);
cl->edict->free = savedFree[i];
Mem_Free( savedFree );
}
SV_InitGame(); // reset previous state
@ -404,7 +404,7 @@ void SV_Status_f( void )
if( !cl->state ) continue;
Msg("%3i ", i);
Msg("%5i ", (int)cl->edict->progs.sv->frags );
Msg("%5i ", (int)cl->edict->v.frags );
if (cl->state == cs_connected) Msg("Connect");
else if (cl->state == cs_zombie) Msg ("Zombie ");

View File

@ -40,7 +40,7 @@ static int SV_EntityNumbers( const void *a, const void *b )
/*
=============================================================================
Copy PRVM values into entity state
Copy entvars into entity state
=============================================================================
*/
@ -50,88 +50,89 @@ void SV_UpdateEntityState( edict_t *ent )
int i;
// copy progs values to state
ent->priv.sv->s.number = ent->priv.sv->serialnumber;
ent->priv.sv->s.solid = ent->priv.sv->solid;
ent->pvEngineData->s.number = ent->serialnumber;
ent->pvEngineData->s.solid = ent->pvEngineData->solid;
VectorCopy (ent->progs.sv->origin, ent->priv.sv->s.origin);
VectorCopy (ent->progs.sv->angles, ent->priv.sv->s.angles);
ent->priv.sv->s.model.index = (int)ent->progs.sv->modelindex;
ent->priv.sv->s.health = ent->progs.sv->health;
ent->priv.sv->s.model.skin = (short)ent->progs.sv->skin; // studio model skin
ent->priv.sv->s.model.body = (byte)ent->progs.sv->body; // studio model submodel
ent->priv.sv->s.model.frame = ent->progs.sv->frame; // any model current frame
ent->priv.sv->s.model.gaitsequence = (int)ent->progs.sv->gaitsequence;// player sequence, that will be playing on client
ent->priv.sv->s.effects = (uint)ent->progs.sv->effects; // shared client and render flags
ent->priv.sv->s.renderfx = (int)ent->progs.sv->renderfx; // renderer flags
ent->priv.sv->s.rendermode = ent->progs.sv->rendermode; // rendering mode
ent->priv.sv->s.renderamt = ent->progs.sv->renderamt; // alpha value
ent->priv.sv->s.model.framerate = ent->progs.sv->framerate;
ent->priv.sv->s.model.animtime = (int)(1000.0 * ent->progs.sv->animtime) * 0.001; // sequence time
ent->priv.sv->s.aiment = ent->progs.sv->aiment; // viewmodel parent
ent->priv.sv->s.model.scale = ent->progs.sv->scale; // shared client and render flags
VectorCopy( ent->progs.sv->rendercolor, ent->priv.sv->s.rendercolor );
VectorCopy (ent->v.origin, ent->pvEngineData->s.origin);
VectorCopy (ent->v.angles, ent->pvEngineData->s.angles);
ent->pvEngineData->s.model.index = ent->v.modelindex;
ent->pvEngineData->s.health = ent->v.health;
ent->pvEngineData->s.model.skin = ent->v.skin; // studio model skin
ent->pvEngineData->s.model.body = ent->v.body; // studio model submodel
ent->pvEngineData->s.model.frame = ent->v.frame; // any model current frame
ent->pvEngineData->s.model.gaitsequence = ent->v.gaitsequence;// player sequence, that will be playing on client
ent->pvEngineData->s.effects = ent->v.effects; // shared client and render flags
ent->pvEngineData->s.renderfx = ent->v.renderfx; // renderer flags
ent->pvEngineData->s.rendermode = ent->v.rendermode; // rendering mode
ent->pvEngineData->s.renderamt = ent->v.renderamt; // alpha value
ent->pvEngineData->s.model.framerate = ent->v.framerate;
ent->pvEngineData->s.model.animtime = (int)(1000.0 * ent->v.animtime) * 0.001; // sequence time
ent->pvEngineData->s.aiment = NUM_FOR_EDICT( ent->v.aiment ); // viewmodel parent
ent->pvEngineData->s.model.scale = ent->v.scale; // shared client and render flags
VectorCopy( ent->v.rendercolor, ent->pvEngineData->s.rendercolor );
// studio model sequence
if( ent->progs.sv->sequence != -1 ) ent->priv.sv->s.model.sequence = ent->progs.sv->sequence;
if( ent->v.sequence != -1 ) ent->pvEngineData->s.model.sequence = ent->v.sequence;
for( i = 0; i < 16; i++ )
{
// copy blendings and bone ctrls
ent->priv.sv->s.model.blending[i] = ent->progs.sv->blending[i];
ent->priv.sv->s.model.controller[i] = ent->progs.sv->controller[i];
ent->pvEngineData->s.model.blending[i] = ent->v.blending[i];
ent->pvEngineData->s.model.controller[i] = ent->v.controller[i];
}
if( ent->priv.sv->s.ed_type != ED_VIEWMODEL )
ent->priv.sv->s.movetype = ent->progs.sv->movetype;
if( ent->pvEngineData->s.ed_type != ED_VIEWMODEL )
ent->pvEngineData->s.movetype = ent->v.movetype;
if( ent->priv.sv->s.ed_type == ED_MOVER || ent->priv.sv->s.ed_type == ED_BSPBRUSH )
if( ent->pvEngineData->s.ed_type == ED_MOVER || ent->pvEngineData->s.ed_type == ED_BSPBRUSH )
{
// these needs to right calculate direction of scroll texture
VectorCopy( ent->progs.sv->movedir, ent->priv.sv->s.velocity );
VectorCopy( ent->v.movedir, ent->pvEngineData->s.velocity );
}
if( ent->priv.sv->s.ed_type == ED_VIEWMODEL )
if( ent->pvEngineData->s.ed_type == ED_VIEWMODEL )
{
// copy v_model state from client to viemodel entity
client = PRVM_EDICT_NUM( ent->progs.sv->aiment );
client = ent->v.aiment;
// update both arrays, because viewmodel are hidden for qc-coders
ent->priv.sv->s.model.index = ent->progs.sv->modelindex = SV_ModelIndex(PRVM_GetString(client->progs.sv->v_model));
ent->priv.sv->s.model.frame = ent->progs.sv->frame = client->progs.sv->v_frame;
ent->priv.sv->s.model.body = ent->progs.sv->body = client->progs.sv->v_body;
ent->priv.sv->s.model.skin = ent->progs.sv->skin = client->progs.sv->v_skin;
ent->progs.sv->sequence = client->progs.sv->v_sequence;
if( ent->progs.sv->sequence != -1 ) ent->priv.sv->s.model.sequence = ent->progs.sv->sequence;
ent->priv.sv->s.model.colormap = ent->progs.sv->colormap = client->progs.sv->colormap;
ent->priv.sv->s.effects |= EF_MINLIGHT; // always have some light
ent->v.modelindex = SV_ModelIndex( STRING( client->v.viewmodel ));
ent->pvEngineData->s.model.index = ent->v.modelindex;
ent->pvEngineData->s.model.frame = ent->v.frame = client->v.weaponframe;
ent->pvEngineData->s.model.body = ent->v.body = client->v.weaponbody;
ent->pvEngineData->s.model.skin = ent->v.skin = client->v.weaponskin;
ent->v.sequence = client->v.weaponsequence;
if( ent->v.sequence != -1 ) ent->pvEngineData->s.model.sequence = ent->v.sequence;
ent->pvEngineData->s.model.colormap = ent->v.colormap = client->v.colormap;
ent->pvEngineData->s.effects |= EF_MINLIGHT; // always have some light
}
else if( ent->priv.sv->s.ed_type == ED_CLIENT )
else if( ent->pvEngineData->s.ed_type == ED_CLIENT )
{
if( ent->progs.sv->fixangle )
if( ent->v.fixangle )
{
// FIXME: set angles correctly
for( i = 0; i < 2; i++ )
ent->priv.sv->s.delta_angles[i] = ANGLE2SHORT( ent->priv.sv->s.angles[i] );
VectorClear( ent->priv.sv->s.angles );
VectorClear( ent->priv.sv->s.viewangles );
VectorClear( ent->progs.sv->v_angle );
ent->pvEngineData->s.delta_angles[i] = ANGLE2SHORT( ent->pvEngineData->s.angles[i] );
VectorClear( ent->pvEngineData->s.angles );
VectorClear( ent->pvEngineData->s.viewangles );
VectorClear( ent->v.v_angle );
// and clear fixangle for the next frame
ent->progs.sv->fixangle = 0;
ent->v.fixangle = 0;
}
}
else if( ent->priv.sv->s.ed_type == ED_AMBIENT )
else if( ent->pvEngineData->s.ed_type == ED_AMBIENT )
{
if( ent->progs.sv->solid == SOLID_TRIGGER )
if( ent->v.solid == SOLID_TRIGGER )
{
vec3_t midPoint;
// NOTE: no reason to compute this shit on the client - save bandwidth
VectorAverage( ent->progs.sv->mins, ent->progs.sv->maxs, midPoint );
VectorAdd( ent->priv.sv->s.origin, midPoint, ent->priv.sv->s.origin );
VectorAverage( ent->v.mins, ent->v.maxs, midPoint );
VectorAdd( ent->pvEngineData->s.origin, midPoint, ent->pvEngineData->s.origin );
}
}
else if( ent->priv.sv->s.ed_type == ED_MOVER )
else if( ent->pvEngineData->s.ed_type == ED_MOVER )
{
// FIXME: send mins\maxs for sound spatialization and entity prediction ?
}
@ -142,7 +143,7 @@ void SV_UpdateEntityState( edict_t *ent )
SV_AddEntToSnapshot
===============
*/
static void SV_AddEntToSnapshot( sv_edict_t *svent, edict_t *ent, sv_ents_t *ents )
static void SV_AddEntToSnapshot( ed_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;
@ -152,7 +153,7 @@ static void SV_AddEntToSnapshot( sv_edict_t *svent, edict_t *ent, sv_ents_t *ent
if( ents->num_entities == MAX_VISIBLE_PACKET ) return;
SV_UpdateEntityState( ent ); // copy entity state from progs
ents->entities[ents->num_entities] = svent->serialnumber;
ents->entities[ents->num_entities] = ent->serialnumber;
ents->num_entities++;
c_fullsend++; // debug counter
}
@ -237,7 +238,7 @@ static void SV_AddEntitiesToPacket( vec3_t origin, client_frame_t *frame, sv_ent
{
int l, e, i;
edict_t *ent;
sv_edict_t *svent;
ed_priv_t *svent;
int leafnum;
byte *clientphs;
byte *bitvector;
@ -260,35 +261,35 @@ static void SV_AddEntitiesToPacket( vec3_t origin, client_frame_t *frame, sv_ent
frame->areabits_size = pe->WriteAreaBits( frame->areabits, clientarea, portal );
clientphs = pe->ClusterPHS( clientcluster );
for( e = 1; e < prog->num_edicts; e++ )
for( e = 1; e < svs.globals->numEntities; e++ )
{
ent = PRVM_EDICT_NUM( e );
ent = EDICT_NUM( e );
force = false; // clear forceflag
// completely ignore dormant entity
if((int)ent->progs.sv->flags & FL_DORMANT )
if((int)ent->v.flags & FL_DORMANT )
continue;
// send viewmodel entity always
// NOTE: never apply LinkEdict to viewmodel entity, because
// we wan't see it in list of entities returned with SV_AreaEdicts
if( ent->priv.sv->s.ed_type == ED_VIEWMODEL )
if( ent->pvEngineData->s.ed_type == ED_VIEWMODEL )
force = true;
// NOTE: client index on client expected that entity will be valid
if( sv_newprotocol->integer && ent->priv.sv->s.ed_type == ED_CLIENT )
if( sv_newprotocol->integer && ent->pvEngineData->s.ed_type == ED_CLIENT )
force = true;
// never send entities that aren't linked in
if( !ent->priv.sv->linked && !force ) continue;
if( !ent->pvEngineData->linked && !force ) continue;
if( ent->priv.sv->serialnumber != e )
if( ent->serialnumber != e )
{
MsgDev( D_WARN, "fixing ent->priv.sv->serialnumber\n");
ent->priv.sv->serialnumber = e;
MsgDev( D_WARN, "fixing ent->pvEngineData->serialnumber\n");
ent->serialnumber = e;
}
svent = ent->priv.sv;
svent = ent->pvEngineData;
// quick reject by type
switch( svent->s.ed_type )
@ -307,11 +308,11 @@ static void SV_AddEntitiesToPacket( vec3_t origin, client_frame_t *frame, sv_ent
if( !force )
{
// ignore if not touching a PV leaf check area
if( !pe->AreasConnected( clientarea, ent->priv.sv->areanum ))
if( !pe->AreasConnected( clientarea, ent->pvEngineData->areanum ))
{
// doors can legally straddle two areas, so
// we may need to check another one
if( !pe->AreasConnected( clientarea, ent->priv.sv->areanum2 ))
if( !pe->AreasConnected( clientarea, ent->pvEngineData->areanum2 ))
continue; // blocked by a door
}
}
@ -340,20 +341,20 @@ static void SV_AddEntitiesToPacket( vec3_t origin, client_frame_t *frame, sv_ent
if( bitvector[l>>3] & (1<<(l & 7)))
break;
}
if( i == ent->priv.sv->num_clusters )
if( i == ent->pvEngineData->num_clusters )
continue; // not visible
}
}
if( ent->priv.sv->s.ed_type == ED_AMBIENT )
if( ent->pvEngineData->s.ed_type == ED_AMBIENT )
{
vec3_t delta, entorigin;
float len;
// don't send sounds if they will be attenuated away
if( VectorIsNull( ent->progs.sv->origin ))
VectorAverage( ent->progs.sv->mins, ent->progs.sv->maxs, entorigin );
else VectorCopy( ent->progs.sv->origin, entorigin );
if( VectorIsNull( ent->v.origin ))
VectorAverage( ent->v.mins, ent->v.maxs, entorigin );
else VectorCopy( ent->v.origin, entorigin );
VectorSubtract( origin, entorigin, delta );
len = VectorLength( delta );
@ -419,7 +420,7 @@ void SV_WriteFrameToClient( sv_client_t *cl, sizebuf_t *msg )
MSG_WriteData( msg, frame->areabits, frame->areabits_size );
// just send an client index
// it's safe, because PRVM_NUM_FOR_EDICT always equal ed->serialnumber,
// it's safe, because NUM_FOR_EDICT always equal ed->serialnumber,
// thats shared across network
if( sv_newprotocol->integer )
{
@ -472,22 +473,22 @@ void SV_BuildClientFrame( sv_client_t *cl )
// clear everything in this snapshot
frame_ents.num_entities = c_fullsend = 0;
Mem_Set( frame->areabits, 0, sizeof( frame->areabits ));
if( !clent->priv.sv->client ) return; // not in game yet
if( !clent->pvEngineData->client ) return; // not in game yet
// find the client's PVS
VectorCopy( clent->priv.sv->s.origin, org );
VectorAdd( org, clent->priv.sv->s.viewoffset, org );
VectorCopy( clent->pvEngineData->s.origin, org );
VectorAdd( org, clent->pvEngineData->s.viewoffset, org );
if( sv_newprotocol->integer )
{
// grab the current player index
frame->index = PRVM_NUM_FOR_EDICT( clent );
frame->index = NUM_FOR_EDICT( clent );
}
else
{
// grab the current player state
cl->edict->priv.sv->framenum = sv.net_framenum;
frame->ps = clent->priv.sv->s;
cl->edict->pvEngineData->framenum = sv.net_framenum;
frame->ps = clent->pvEngineData->s;
}
// add all the entities directly visible to the eye, which
@ -506,11 +507,11 @@ void SV_BuildClientFrame( sv_client_t *cl )
for( i = 0; i < frame_ents.num_entities; i++ )
{
ent = PRVM_EDICT_NUM( frame_ents.entities[i] );
ent = EDICT_NUM( frame_ents.entities[i] );
// add it to the circular client_entities array
state = &svs.client_entities[svs.next_client_entities % svs.num_client_entities];
*state = ent->priv.sv->s;
*state = ent->pvEngineData->s;
svs.next_client_entities++;
// this should never hit, map should always be restarted first in SV_Frame

3202
engine/server/sv_game.c Normal file

File diff suppressed because it is too large Load Diff

View File

@ -22,6 +22,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "server.h"
server_static_t svs; // persistant server info
game_static_t svg; // persistant game info
server_t sv; // local server
/*
@ -62,19 +63,29 @@ int SV_FindIndex (const char *name, int start, int end, bool create)
}
int SV_ModelIndex (const char *name)
int SV_ModelIndex( const char *name )
{
return SV_FindIndex (name, CS_MODELS, MAX_MODELS, true);
return SV_FindIndex( name, CS_MODELS, MAX_MODELS, true );
}
int SV_SoundIndex (const char *name)
int SV_SoundIndex( const char *name )
{
return SV_FindIndex (name, CS_SOUNDS, MAX_SOUNDS, true);
return SV_FindIndex (name, CS_SOUNDS, MAX_SOUNDS, true );
}
int SV_UserMessageIndex( const char *name )
{
return SV_FindIndex (name, CS_USER_MESSAGES, MAX_USER_MESSAGES, true );
}
int SV_DecalIndex( const char *name )
{
return SV_FindIndex( name, CS_DECALS, MAX_DECALS, true );
}
int SV_ClassIndex( const char *name )
{
return SV_FindIndex (name, CS_CLASSNAMES, MAX_CLASSNAMES, true);
return SV_FindIndex( name, CS_CLASSNAMES, MAX_CLASSNAMES, true );
}
/*
================
@ -90,18 +101,18 @@ void SV_CreateBaseline( void )
edict_t *svent;
int entnum;
for( entnum = 1; entnum < prog->num_edicts ; entnum++ )
for( entnum = 1; entnum < svs.globals->numEntities; entnum++ )
{
svent = PRVM_EDICT_NUM( entnum );
if( svent->priv.sv->free ) continue;
if( !svent->progs.sv->modelindex && !svent->priv.sv->s.soundindex && !svent->progs.sv->effects )
svent = EDICT_NUM( entnum );
if( svent->free ) continue;
if( !svent->v.modelindex && !svent->pvEngineData->s.soundindex && !svent->v.effects )
continue;
svent->priv.sv->serialnumber = entnum;
svent->serialnumber = entnum;
// take current state as baseline
SV_UpdateEntityState( svent );
svs.baselines[entnum] = svent->priv.sv->s;
svs.baselines[entnum] = svent->pvEngineData->s;
}
}
@ -155,8 +166,6 @@ void SV_SpawnServer( const char *server, const char *savename )
MSG_Init( &sv.multicast, sv.multicast_buf, sizeof(sv.multicast_buf));
com.strcpy( sv.name, server );
SV_VM_Begin();
// leave slots at start for clients only
for( i = 0; i < Host_MaxClients(); i++ )
{
@ -198,7 +207,7 @@ void SV_SpawnServer( const char *server, const char *savename )
SV_CheckForSavegame( savename );
if( sv.loadgame ) SV_ReadLevelFile( savename );
else SV_SpawnEntities( sv.name, pe->GetEntityString());
else SV_SpawnEntities( sv.name, pe->GetEntityScript());
// run two frames to allow everything to settle
for( i = 0; i < 2; i++ )
@ -215,16 +224,15 @@ void SV_SpawnServer( const char *server, const char *savename )
SV_CreateBaseline();
// classify edicts for quick network sorting
for( i = 0; i < prog->num_edicts; i++ )
for( i = 0; i < svs.globals->numEntities; i++ )
{
edict_t *ent = PRVM_EDICT_NUM( i );
edict_t *ent = EDICT_NUM( i );
SV_ClassifyEdict( ent );
}
// set serverinfo variable
Cvar_FullSet( "mapname", sv.name, CVAR_SERVERINFO|CVAR_INIT );
pe->EndRegistration(); // free unused models
SV_VM_End();
}
/*
@ -299,16 +307,21 @@ void SV_InitGame( void )
NET_StringToAdr( idmaster, &master_adr[0] );
// init game
SV_InitServerProgs();
SV_VM_Begin();
if(!SV_LoadProgs( "server" ))
{
Host_Error( "SV_InitGame: can't initialize server.dll\n" );
}
for( i = 0; i < Host_MaxClients(); i++ )
{
ent = PRVM_EDICT_NUM( i + 1 );
ent->priv.sv->serialnumber = i + 1;
ent = EDICT_NUM( i + 1 );
ent->serialnumber = i + 1;
svs.clients[i].edict = ent;
Mem_Set (&svs.clients[i].lastcmd, 0, sizeof(svs.clients[i].lastcmd));
Mem_Set( &svs.clients[i].lastcmd, 0, sizeof( svs.clients[i].lastcmd ));
}
SV_VM_End();
}
bool SV_Active( void )
{
return svs.initialized;
}

View File

@ -71,7 +71,7 @@ void SV_CalcPings( void )
else cl->ping = total / count;
// let the game dll know about the ping
cl->edict->priv.sv->client->ping = cl->ping;
cl->edict->pvEngineData->client->ping = cl->ping;
}
}
@ -88,8 +88,6 @@ void SV_PacketEvent( netadr_t from, sizebuf_t *msg )
if( !svs.initialized ) return;
SV_VM_Begin();
// check for connectionless packet (0xffffffff) first
if( msg->cursize >= 4 && *(int *)msg->data == -1 )
{
@ -127,7 +125,6 @@ void SV_PacketEvent( netadr_t from, sizebuf_t *msg )
break;
}
if( i != Host_MaxClients()) return;
SV_VM_End();
}
/*
@ -238,9 +235,6 @@ void SV_Frame( dword time )
return;
}
// setup the VM frame
SV_VM_Begin();
// update ping based on the last known frame from all clients
SV_CalcPings ();
@ -252,9 +246,6 @@ void SV_Frame( dword time )
// send a heartbeat to the master if needed
Master_Heartbeat ();
// end the server VM frame
SV_VM_End();
}
//============================================================================
@ -337,7 +328,7 @@ void Master_Shutdown (void)
===============
SV_Init
Only called at xash.exe startup, not for each game
Only called at startup, not for each game
===============
*/
void SV_Init( void )
@ -438,19 +429,19 @@ void SV_Shutdown( bool reconnect )
if( !svs.initialized ) return;
MsgDev( D_INFO, "SV_Shutdown: %s\n", host.finalmsg );
if( svs.clients ) SV_FinalMessage( host.finalmsg, reconnect);
if( svs.clients ) SV_FinalMessage( host.finalmsg, reconnect );
Master_Shutdown();
SV_FreeServerProgs();
SV_UnloadProgs();
// free current level
memset( &sv, 0, sizeof( sv ));
Mem_Set( &sv, 0, sizeof( sv ));
Host_SetServerState( sv.state );
// free server static data
if( svs.clients ) Mem_Free( svs.clients );
if( svs.baselines ) Mem_Free( svs.baselines );
if( svs.client_entities ) Mem_Free( svs.client_entities );
memset( &svs, 0, sizeof( svs ));
Mem_Set( &svs, 0, sizeof( svs ));
}

View File

@ -25,8 +25,8 @@ bool SV_CheckBottom( edict_t *ent )
trace_t trace;
int x, y;
VectorAdd (ent->progs.sv->origin, ent->progs.sv->mins, mins);
VectorAdd (ent->progs.sv->origin, ent->progs.sv->maxs, maxs);
VectorAdd (ent->v.origin, ent->v.mins, mins);
VectorAdd (ent->v.origin, ent->v.maxs, maxs);
// if all of the points under the corners are solid world, don't bother
// with the tougher checks
@ -96,40 +96,40 @@ bool SV_movestep( edict_t *ent, vec3_t move, bool relink, bool noenemy, bool set
int i;
// try the move
VectorCopy (ent->progs.sv->origin, oldorg);
VectorAdd (ent->progs.sv->origin, move, neworg);
VectorCopy (ent->v.origin, oldorg);
VectorAdd (ent->v.origin, move, neworg);
// flying monsters don't step up
if((int)ent->progs.sv->aiflags & (AI_SWIM|AI_FLY))
if((int)ent->v.aiflags & (AI_SWIM|AI_FLY))
{
// try one move with vertical motion, then one without
for( i = 0; i < 2; i++ )
{
VectorAdd( ent->progs.sv->origin, move, neworg );
if( noenemy ) enemy = prog->edicts;
VectorAdd( ent->v.origin, move, neworg );
if( noenemy ) enemy = svg.edicts;
else
{
enemy = PRVM_PROG_TO_EDICT( ent->progs.sv->enemy );
if( i == 0 && enemy != prog->edicts )
enemy = ent->v.enemy;
if( i == 0 && enemy != svg.edicts )
{
dz = ent->progs.sv->origin[2] - PRVM_PROG_TO_EDICT(ent->progs.sv->enemy)->progs.sv->origin[2];
dz = ent->v.origin[2] - ent->v.enemy->v.origin[2];
if( dz > 40 ) neworg[2] -= 8;
if( dz < 30 ) neworg[2] += 8;
}
}
trace = SV_Trace( ent->progs.sv->origin, ent->progs.sv->mins, ent->progs.sv->maxs, neworg, MOVE_NORMAL, ent, SV_ContentsMask(ent));
trace = SV_Trace( ent->v.origin, ent->v.mins, ent->v.maxs, neworg, MOVE_NORMAL, ent, SV_ContentsMask(ent));
if( trace.fraction == 1 )
{
VectorCopy( trace.endpos, traceendpos );
if(((int)ent->progs.sv->aiflags & AI_SWIM) && !(SV_PointContents(traceendpos) & MASK_WATER))
if(((int)ent->v.aiflags & AI_SWIM) && !(SV_PointContents(traceendpos) & MASK_WATER))
return false; // swim monster left water
VectorCopy( traceendpos, ent->progs.sv->origin );
VectorCopy( traceendpos, ent->v.origin );
if( relink ) SV_LinkEdict( ent );
return true;
}
if( enemy == prog->edicts ) break;
if( enemy == svg.edicts ) break;
}
return false;
}
@ -139,47 +139,47 @@ bool SV_movestep( edict_t *ent, vec3_t move, bool relink, bool noenemy, bool set
VectorCopy( neworg, end );
end[2] -= sv_stepheight->value * 2;
trace = SV_Trace( neworg, ent->progs.sv->mins, ent->progs.sv->maxs, end, MOVE_NORMAL, ent, SV_ContentsMask(ent));
trace = SV_Trace( neworg, ent->v.mins, ent->v.maxs, end, MOVE_NORMAL, ent, SV_ContentsMask(ent));
if( trace.startsolid )
{
neworg[2] -= sv_stepheight->value;
trace = SV_Trace( neworg, ent->progs.sv->mins, ent->progs.sv->maxs, end, MOVE_NORMAL, ent, SV_ContentsMask(ent));
trace = SV_Trace( neworg, ent->v.mins, ent->v.maxs, end, MOVE_NORMAL, ent, SV_ContentsMask(ent));
if( trace.startsolid ) return false;
}
if( trace.fraction == 1 )
{
// if monster had the ground pulled out, go ahead and fall
if((int)ent->progs.sv->aiflags & AI_PARTIALONGROUND )
if( ent->v.flags & FL_PARTIALONGROUND )
{
VectorAdd( ent->progs.sv->origin, move, ent->progs.sv->origin );
VectorAdd( ent->v.origin, move, ent->v.origin );
if (relink) SV_LinkEdict( ent );
ent->progs.sv->aiflags = (int)ent->progs.sv->aiflags & ~AI_ONGROUND;
ent->v.flags &= ~FL_ONGROUND;
return true;
}
return false; // walked off an edge
}
// check point traces down for dangling corners
VectorCopy( trace.endpos, ent->progs.sv->origin );
VectorCopy( trace.endpos, ent->v.origin );
if(!SV_CheckBottom( ent ))
{
if((int)ent->progs.sv->aiflags & AI_PARTIALONGROUND )
if( ent->v.flags & FL_PARTIALONGROUND )
{
// entity had floor mostly pulled out from underneath it
// and is trying to correct
if( relink ) SV_LinkEdict( ent );
return true;
}
VectorCopy( oldorg, ent->progs.sv->origin );
VectorCopy( oldorg, ent->v.origin );
return false;
}
if((int)ent->progs.sv->aiflags & AI_PARTIALONGROUND )
ent->progs.sv->flags = (int)ent->progs.sv->flags & ~AI_PARTIALONGROUND;
if( ent->v.flags & FL_PARTIALONGROUND )
ent->v.flags &= ~FL_PARTIALONGROUND;
ent->progs.sv->groundentity = PRVM_EDICT_TO_PROG( trace.ent );
ent->v.groundentity = trace.ent;
// the move is ok
if( relink ) SV_LinkEdict( ent );
@ -203,23 +203,23 @@ bool SV_StepDirection( edict_t *ent, float yaw, float dist )
vec3_t move, oldorigin;
float delta, current;
ent->progs.sv->ideal_yaw = yaw;
current = anglemod( ent->progs.sv->angles[1] );
ent->progs.sv->angles[1] = SV_AngleMod( ent->progs.sv->ideal_yaw, current, ent->progs.sv->yaw_speed );
ent->v.ideal_yaw = yaw;
current = anglemod( ent->v.angles[1] );
ent->v.angles[1] = SV_AngleMod( ent->v.ideal_yaw, current, ent->v.yaw_speed );
yaw = yaw * M_PI*2 / 360;
move[0] = cos(yaw)*dist;
move[1] = sin(yaw)*dist;
move[2] = 0;
VectorCopy( ent->progs.sv->origin, oldorigin );
VectorCopy( ent->v.origin, oldorigin );
if(SV_movestep( ent, move, false, false, false ))
{
delta = ent->progs.sv->angles[YAW] - ent->progs.sv->ideal_yaw;
delta = ent->v.angles[YAW] - ent->v.ideal_yaw;
if( delta > 45 && delta < 315 )
{
// not turned far enough, so don't take the step
VectorCopy( oldorigin, ent->progs.sv->origin );
VectorCopy( oldorigin, ent->v.origin );
}
SV_LinkEdict( ent );
return true;
@ -237,11 +237,9 @@ SV_FixCheckBottom
*/
void SV_FixCheckBottom( edict_t *ent )
{
ent->progs.sv->flags = (int)ent->progs.sv->aiflags | AI_PARTIALONGROUND;
ent->v.flags |= FL_PARTIALONGROUND;
}
/*
================
SV_NewChaseDir
@ -253,11 +251,11 @@ void SV_NewChaseDir( edict_t *actor, edict_t *enemy, float dist )
float deltax, deltay;
float d[3], tdir, olddir, turnaround;
olddir = anglemod((int)(actor->progs.sv->ideal_yaw/45) * 45);
olddir = anglemod((int)(actor->v.ideal_yaw/45) * 45);
turnaround = anglemod( olddir - 180 );
deltax = enemy->progs.sv->origin[0] - actor->progs.sv->origin[0];
deltay = enemy->progs.sv->origin[1] - actor->progs.sv->origin[1];
deltax = enemy->v.origin[0] - actor->v.origin[0];
deltay = enemy->v.origin[1] - actor->v.origin[1];
if( deltax > 10 ) d[1]= 0;
else if( deltax < -10 ) d[1] = 180;
else d[1] = -1;
@ -310,7 +308,7 @@ void SV_NewChaseDir( edict_t *actor, edict_t *enemy, float dist )
if( turnaround != -1 && SV_StepDirection( actor, turnaround, dist ))
return;
actor->progs.sv->ideal_yaw = olddir; // can't move
actor->v.ideal_yaw = olddir; // can't move
// if a bridge was pulled out from underneath a monster, it may not have
// a valid standing position at all
@ -329,9 +327,9 @@ bool SV_CloseEnough( edict_t *ent, edict_t *goal, float dist )
for( i = 0; i < 3; i++ )
{
if( goal->progs.sv->absmin[i] > ent->progs.sv->absmax[i] + dist )
if( goal->v.absmin[i] > ent->v.absmax[i] + dist )
return false;
if( goal->progs.sv->absmax[i] < ent->progs.sv->absmin[i] - dist )
if( goal->v.absmax[i] < ent->v.absmin[i] - dist )
return false;
}
return true;
@ -343,52 +341,40 @@ SV_MoveToGoal
======================
*/
void SV_MoveToGoal( void )
bool SV_MoveToGoal( edict_t *ent, edict_t *goal, float dist )
{
edict_t *ent, *goal;
float dist;
if(!VM_ValidateArgs( "movetogoal", 1 ))
return;
ent = PRVM_PROG_TO_EDICT( prog->globals.sv->pev );
goal = PRVM_PROG_TO_EDICT( ent->progs.sv->goalentity );
dist = PRVM_G_FLOAT( OFS_PARM0 );
if(!((int)ent->progs.sv->aiflags & (AI_ONGROUND|AI_FLY|AI_SWIM)))
if(!(ent->v.aiflags & (AI_FLY|AI_SWIM)) && !(ent->v.flags & FL_ONGROUND))
{
PRVM_G_FLOAT(OFS_RETURN) = 0;
return;
return false;
}
// if the next step hits the enemy, return immediately
if(PRVM_PROG_TO_EDICT(ent->progs.sv->enemy) != prog->edicts && SV_CloseEnough( ent, goal, dist))
return;
if( ent->v.enemy != svg.edicts && SV_CloseEnough( ent, goal, dist ))
return false;
// bump around...
if(( rand() & 3) == 1 || !SV_StepDirection( ent, ent->progs.sv->ideal_yaw, dist ))
if(( rand() & 3) == 1 || !SV_StepDirection( ent, ent->v.ideal_yaw, dist ))
{
SV_NewChaseDir( ent, goal, dist );
}
return true;
}
// g-cont: my stupid callbacks
cmodel_t *SV_GetModelPtr( edict_t *ent )
{
return pe->RegisterModel( sv.configstrings[CS_MODELS + (int)ent->progs.sv->modelindex] );
return pe->RegisterModel( sv.configstrings[CS_MODELS + (int)ent->v.modelindex] );
}
float *SV_GetModelVerts( sv_edict_t *ed, int *numvertices )
float *SV_GetModelVerts( edict_t *ent, int *numvertices )
{
cmodel_t *cmod;
edict_t *ent;
ent = PRVM_EDICT_NUM(ed->serialnumber);
cmod = pe->RegisterModel( sv.configstrings[CS_MODELS + (int)ent->progs.sv->modelindex] );
cmod = pe->RegisterModel( sv.configstrings[CS_MODELS + (int)ent->v.modelindex] );
if( cmod )
{
int i = (int)ent->progs.sv->body;
int i = (int)ent->v.body;
i = bound( 0, i, cmod->numbodies ); // make sure what body exist
if( cmod->col[i] )
@ -400,41 +386,39 @@ float *SV_GetModelVerts( sv_edict_t *ed, int *numvertices )
return NULL;
}
void SV_Transform( sv_edict_t *ed, const vec3_t origin, const matrix3x3 matrix )
void SV_Transform( edict_t *edict, const vec3_t origin, const matrix3x3 matrix )
{
edict_t *edict;
vec3_t angles;
if( !ed ) return;
edict = PRVM_EDICT_NUM( ed->serialnumber );
if( !edict ) return;
Matrix3x3_Transpose( edict->progs.sv->m_pmatrix, matrix );
Matrix3x3_Transpose( edict->v.m_pmatrix, matrix );
#if 0
edict->progs.sv->m_pmatrix[0][0] = matrix[0][0];
edict->progs.sv->m_pmatrix[0][1] = matrix[0][2];
edict->progs.sv->m_pmatrix[0][2] = matrix[0][1];
edict->progs.sv->m_pmatrix[1][0] = matrix[1][0];
edict->progs.sv->m_pmatrix[1][1] = matrix[1][2];
edict->progs.sv->m_pmatrix[1][2] = matrix[1][1];
edict->progs.sv->m_pmatrix[2][0] = matrix[2][0];
edict->progs.sv->m_pmatrix[2][1] = matrix[2][2];
edict->progs.sv->m_pmatrix[2][2] = matrix[2][1];
edict->v.m_pmatrix[0][0] = matrix[0][0];
edict->v.m_pmatrix[0][1] = matrix[0][2];
edict->v.m_pmatrix[0][2] = matrix[0][1];
edict->v.m_pmatrix[1][0] = matrix[1][0];
edict->v.m_pmatrix[1][1] = matrix[1][2];
edict->v.m_pmatrix[1][2] = matrix[1][1];
edict->v.m_pmatrix[2][0] = matrix[2][0];
edict->v.m_pmatrix[2][1] = matrix[2][2];
edict->v.m_pmatrix[2][2] = matrix[2][1];
Matrix3x3_ConcatRotate( edict->progs.sv->m_pmatrix, -90, 1, 0, 0 );
Matrix3x3_ConcatRotate( edict->progs.sv->m_pmatrix, 180, 0, 1, 0 );
Matrix3x3_ConcatRotate( edict->progs.sv->m_pmatrix, 90, 0, 0, 1 );
Matrix3x3_ToAngles( edict->progs.sv->m_pmatrix, angles );
Matrix3x3_ConcatRotate( edict->v.m_pmatrix, -90, 1, 0, 0 );
Matrix3x3_ConcatRotate( edict->v.m_pmatrix, 180, 0, 1, 0 );
Matrix3x3_ConcatRotate( edict->v.m_pmatrix, 90, 0, 0, 1 );
Matrix3x3_ToAngles( edict->v.m_pmatrix, angles );
#endif
VectorCopy( origin, edict->progs.sv->origin );
VectorCopy( origin, edict->v.origin );
MatrixAngles( edict->progs.sv->m_pmatrix, angles );
edict->progs.sv->angles[0] = angles[0];
edict->progs.sv->angles[1] = angles[1];
edict->progs.sv->angles[2] = angles[2];
MatrixAngles( edict->v.m_pmatrix, angles );
edict->v.angles[0] = angles[0];
edict->v.angles[1] = angles[1];
edict->v.angles[2] = angles[2];
// refresh force and torque
pe->GetForce( ed->physbody, edict->progs.sv->velocity, edict->progs.sv->avelocity, edict->progs.sv->force, edict->progs.sv->torque );
pe->GetMassCentre( ed->physbody, edict->progs.sv->m_pcentre );
pe->GetForce( edict->pvEngineData->physbody, edict->v.velocity, edict->v.avelocity, edict->v.force, edict->v.torque );
pe->GetMassCentre( edict->pvEngineData->physbody, edict->v.m_pcentre );
}
/*
@ -445,53 +429,43 @@ grab user cmd from player state
send it to transform callback
==============
*/
void SV_PlayerMove( sv_edict_t *ed )
void SV_PlayerMove( edict_t *player )
{
pmove_t pm;
sv_client_t *client;
edict_t *player;
client = ed->client;
player = PRVM_PROG_TO_EDICT( ed->serialnumber );
client = player->pvEngineData->client;
memset( &pm, 0, sizeof(pm) );
if( player->progs.sv->movetype == MOVETYPE_NOCLIP )
player->priv.sv->s.pm_type = PM_SPECTATOR;
else player->priv.sv->s.pm_type = PM_NORMAL;
player->priv.sv->s.gravity = sv_gravity->value;
if( player->v.movetype == MOVETYPE_NOCLIP )
player->pvEngineData->s.pm_type = PM_SPECTATOR;
else player->pvEngineData->s.pm_type = PM_NORMAL;
player->pvEngineData->s.gravity = sv_gravity->value;
if( player->progs.sv->teleport_time )
player->priv.sv->s.pm_flags |= PMF_TIME_TELEPORT;
else player->priv.sv->s.pm_flags &= ~PMF_TIME_TELEPORT;
if( player->v.teleport_time )
player->pvEngineData->s.pm_flags |= PMF_TIME_TELEPORT;
else player->pvEngineData->s.pm_flags &= ~PMF_TIME_TELEPORT;
pm.ps = player->priv.sv->s;
pm.ps = player->pvEngineData->s;
pm.cmd = client->lastcmd;
pm.body = ed->physbody; // member body ptr
pm.body = player->pvEngineData->physbody; // member body ptr
VectorCopy( player->progs.sv->origin, pm.ps.origin );
VectorCopy( player->progs.sv->velocity, pm.ps.velocity );
VectorCopy( player->v.origin, pm.ps.origin );
VectorCopy( player->v.velocity, pm.ps.velocity );
pe->PlayerMove( &pm, false ); // server move
// save results of pmove
player->priv.sv->s = pm.ps;
player->pvEngineData->s = pm.ps;
VectorCopy(pm.ps.origin, player->progs.sv->origin);
VectorCopy(pm.ps.velocity, player->progs.sv->velocity);
VectorCopy(pm.mins, player->progs.sv->mins);
VectorCopy(pm.maxs, player->progs.sv->maxs);
VectorCopy(pm.ps.viewangles, player->priv.sv->s.viewangles );
VectorCopy(pm.ps.origin, player->v.origin);
VectorCopy(pm.ps.velocity, player->v.velocity);
VectorCopy(pm.mins, player->v.mins);
VectorCopy(pm.maxs, player->v.maxs);
VectorCopy(pm.ps.viewangles, player->pvEngineData->s.viewangles );
}
void SV_PlaySound( sv_edict_t *ed, float volume, float pitch, const char *sample )
void SV_PlaySound( edict_t *ed, float volume, float pitch, const char *sample )
{
if( !ed ) ed = prog->edicts->priv.sv;
PRVM_G_INT(OFS_PARM0) = ed->serialnumber;
PRVM_G_FLOAT(OFS_PARM1) = CHAN_AUTO;
PRVM_G_INT(OFS_PARM2) = PRVM_SetEngineString( sample );
PRVM_G_FLOAT(OFS_PARM3) = volume;
PRVM_G_FLOAT(OFS_PARM4) = ATTN_NORM;
PRVM_G_FLOAT(OFS_PARM5) = bound( 1, pitch * PITCH_NORM, 255 );
PRVM_ExecuteProgram( prog->globals.sv->EmitSound, "EmitSound" );
// FIXME: send sound
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -8,7 +8,7 @@ SV_StartParticle
Make sure the event gets sent to all clients
==================
*/
void SV_StartParticle( vec3_t org, vec3_t dir, int color, int count )
void SV_StartParticle( const float *org, const float *dir, int color, int count )
{
MsgDev( D_ERROR, "SV_StartParticle: implement me\n");
}

View File

@ -15,7 +15,7 @@ ENTITY AREA CHECKING
FIXME: this use of "area" is different from the bsp file use
===============================================================================
*/
#define EDICT_FROM_AREA( l ) PRVM_EDICT_NUM( l->entnum )
#define EDICT_FROM_AREA( l ) EDICT_NUM( l->entnum )
#define MAX_TOTAL_ENT_LEAFS 128
#define AREA_NODES 32
#define AREA_DEPTH 4
@ -105,7 +105,7 @@ void SV_InsertLinkBefore( link_t *l, link_t *before, edict_t *ent )
l->prev = before->prev;
l->prev->next = l;
l->next->prev = l;
l->entnum = PRVM_NUM_FOR_EDICT(ent);
l->entnum = NUM_FOR_EDICT( ent );
}
/*
@ -176,17 +176,17 @@ sorting edict by type
*/
void SV_ClassifyEdict( edict_t *ent )
{
sv_edict_t *sv_ent;
ed_priv_t *sv_ent;
const char *classname;
sv_ent = ent->priv.sv;
sv_ent = ent->pvEngineData;
if( sv_ent->s.ed_type != ED_SPAWNED )
return;
// null state ?
if( !sv_ent->s.number ) SV_UpdateEntityState( ent );
classname = PRVM_GetString( ent->progs.sv->classname );
classname = STRING( ent->v.classname );
if( !com.strnicmp( "worldspawn", classname, 10 ))
{
@ -194,28 +194,28 @@ void SV_ClassifyEdict( edict_t *ent )
return;
}
// first pass: determine type by explicit parms
if( ent->progs.sv->solid == SOLID_TRIGGER )
if( ent->v.solid == SOLID_TRIGGER )
{
if( sv_ent->s.soundindex )
sv_ent->s.ed_type = ED_AMBIENT; // e.g. trigger_teleport
else sv_ent->s.ed_type = ED_TRIGGER; // never sending to client
}
else if( ent->progs.sv->movetype == MOVETYPE_PHYSIC )
else if( ent->v.movetype == MOVETYPE_PHYSIC )
sv_ent->s.ed_type = ED_RIGIDBODY;
else if( ent->progs.sv->solid == SOLID_BSP || VectorIsNull( ent->progs.sv->origin ))
else if( ent->v.solid == SOLID_BSP || VectorIsNull( ent->v.origin ))
{
if( ent->progs.sv->movetype == MOVETYPE_CONVEYOR )
if( ent->v.movetype == MOVETYPE_CONVEYOR )
sv_ent->s.ed_type = ED_MOVER;
else if((int)ent->progs.sv->flags & FL_WORLDBRUSH )
else if((int)ent->v.flags & FL_WORLDBRUSH )
sv_ent->s.ed_type = ED_BSPBRUSH;
else if( ent->progs.sv->movetype == MOVETYPE_PUSH )
else if( ent->v.movetype == MOVETYPE_PUSH )
sv_ent->s.ed_type = ED_MOVER;
else if( ent->progs.sv->movetype == MOVETYPE_NONE )
else if( ent->v.movetype == MOVETYPE_NONE )
sv_ent->s.ed_type = ED_BSPBRUSH;
}
else if((int)ent->progs.sv->flags & FL_MONSTER )
else if((int)ent->v.flags & FL_MONSTER )
sv_ent->s.ed_type = ED_MONSTER;
else if((int)ent->progs.sv->flags & FL_CLIENT )
else if((int)ent->v.flags & FL_CLIENT )
sv_ent->s.ed_type = ED_CLIENT;
else if( !sv_ent->s.model.index && !sv_ent->s.aiment )
{
@ -232,7 +232,7 @@ void SV_ClassifyEdict( edict_t *ent )
}
// or leave unclassified, wait for next SV_LinkEdict...
// Msg( "%s: <%s>\n", PRVM_GetString( ent->progs.sv->classname ), ed_name[sv_ent->s.ed_type] );
// Msg( "%s: <%s>\n", STRING( ent->v.classname ), ed_name[sv_ent->s.ed_type] );
}
/*
@ -243,10 +243,10 @@ SV_UnlinkEdict
void SV_UnlinkEdict( edict_t *ent )
{
// not linked in anywhere
if( !ent->priv.sv->area.prev ) return;
if( !ent->pvEngineData->area.prev ) return;
SV_RemoveLink( &ent->priv.sv->area );
ent->priv.sv->area.prev = ent->priv.sv->area.next = NULL;
SV_RemoveLink( &ent->pvEngineData->area );
ent->pvEngineData->area.prev = ent->pvEngineData->area.next = NULL;
}
/*
@ -263,71 +263,71 @@ void SV_LinkEdict( edict_t *ent )
int i, j, k;
int area;
int topnode;
sv_edict_t *sv_ent;
ed_priv_t *sv_ent;
sv_ent = ent->priv.sv;
sv_ent = ent->pvEngineData;
if( sv_ent->area.prev ) SV_UnlinkEdict( ent ); // unlink from old position
if( ent == prog->edicts ) return; // don't add the world
if( sv_ent->free ) return;
if( ent == svg.edicts ) return; // don't add the world
if( ent->free ) return;
// trying to classify unclassified edicts
if( sv.state == ss_active && sv_ent->s.ed_type == ED_SPAWNED )
SV_ClassifyEdict( ent );
// set the size
VectorSubtract( ent->progs.sv->maxs, ent->progs.sv->mins, ent->progs.sv->size );
VectorSubtract( ent->v.maxs, ent->v.mins, ent->v.size );
if( ent->progs.sv->solid == SOLID_BSP )
if( ent->v.solid == SOLID_BSP )
{
// a solid_bbox will never create this value
sv_ent->solid = SOLID_BMODEL;
}
else if(( int )ent->progs.sv->contents & ( CONTENTS_SOLID|CONTENTS_BODY ))
else if(( int )ent->v.contents & ( CONTENTS_SOLID|CONTENTS_BODY ))
{
// encode the size into the entity_state for client prediction
// assume that x/y are equal and symetric
i = ent->progs.sv->maxs[0];
i = ent->v.maxs[0];
i = bound( 1, i, 255 );
// z is not symetric
j = (-ent->progs.sv->mins[2]);
j = (-ent->v.mins[2]);
j = bound( 1, j, 255 );
// and z maxs can be negative...
k = (ent->progs.sv->maxs[2] + 32);
k = (ent->v.maxs[2] + 32);
k = bound( 1, k, 255 );
sv_ent->solid = (k<<16)|(j<<8)|i;
}
else sv_ent->solid = 0;
// set the abs box
if( ent->progs.sv->solid == SOLID_BSP && !VectorIsNull( ent->progs.sv->angles ))
if( ent->v.solid == SOLID_BSP && !VectorIsNull( ent->v.angles ))
{
// expand for rotation
int i;
float max = RadiusFromBounds( ent->progs.sv->mins, ent->progs.sv->maxs );
float max = RadiusFromBounds( ent->v.mins, ent->v.maxs );
for( i = 0; i < 3; i++ )
{
ent->progs.sv->absmin[i] = ent->progs.sv->origin[i] - max;
ent->progs.sv->absmax[i] = ent->progs.sv->origin[i] + max;
ent->v.absmin[i] = ent->v.origin[i] - max;
ent->v.absmax[i] = ent->v.origin[i] + max;
}
}
else
{ // normal
VectorAdd( ent->progs.sv->origin, ent->progs.sv->mins, ent->progs.sv->absmin );
VectorAdd( ent->progs.sv->origin, ent->progs.sv->maxs, ent->progs.sv->absmax );
VectorAdd( ent->v.origin, ent->v.mins, ent->v.absmin );
VectorAdd( ent->v.origin, ent->v.maxs, ent->v.absmax );
}
// because movement is clipped an epsilon away from an actual edge,
// we must fully check even when bounding boxes don't quite touch
ent->progs.sv->absmin[0] -= 1;
ent->progs.sv->absmin[1] -= 1;
ent->progs.sv->absmin[2] -= 1;
ent->progs.sv->absmax[0] += 1;
ent->progs.sv->absmax[1] += 1;
ent->progs.sv->absmax[2] += 1;
ent->v.absmin[0] -= 1;
ent->v.absmin[1] -= 1;
ent->v.absmin[2] -= 1;
ent->v.absmax[0] += 1;
ent->v.absmax[1] += 1;
ent->v.absmax[2] += 1;
// link to PVS leafs
sv_ent->num_clusters = 0;
@ -335,7 +335,7 @@ void SV_LinkEdict( edict_t *ent )
sv_ent->areanum2 = 0;
// get all leafs, including solids
num_leafs = pe->BoxLeafnums( ent->progs.sv->absmin, ent->progs.sv->absmax, leafs, MAX_TOTAL_ENT_LEAFS, &topnode );
num_leafs = pe->BoxLeafnums( ent->v.absmin, ent->v.absmax, leafs, MAX_TOTAL_ENT_LEAFS, &topnode );
// if none of the leafs were inside the map, the
// entity is outside the world and can be considered unlinked
@ -354,7 +354,7 @@ void SV_LinkEdict( edict_t *ent )
{
if( sv_ent->areanum2 && sv_ent->areanum2 != area && sv.state == ss_loading )
{
float *v = ent->progs.sv->absmin;
float *v = ent->v.absmin;
MsgDev( D_WARN, "SV_LinkEdict: object touching 3 areas at %f %f %f\n", v[0], v[1], v[2] );
}
sv_ent->areanum2 = area;
@ -394,16 +394,16 @@ void SV_LinkEdict( edict_t *ent )
}
}
ent->priv.sv->linkcount++;
ent->pvEngineData->linkcount++;
// update ambient sound here
if( ent->progs.sv->loopsound )
if( ent->v.ambient )
{
ent->priv.sv->s.soundindex = SV_SoundIndex( PRVM_GetString( ent->progs.sv->loopsound ));
ent->pvEngineData->s.soundindex = SV_SoundIndex( STRING( ent->v.ambient ));
}
// don't link not solid or rigid bodies
if( ent->progs.sv->solid == SOLID_NOT || ent->progs.sv->solid >= SOLID_BOX )
if( ent->v.solid == SOLID_NOT || ent->v.solid >= SOLID_BOX )
{
sv_ent->linked = true;
return;
@ -414,15 +414,15 @@ void SV_LinkEdict( edict_t *ent )
while( 1 )
{
if( node->axis == -1 ) break;
if( ent->progs.sv->absmin[node->axis] > node->dist )
if( ent->v.absmin[node->axis] > node->dist )
node = node->children[0];
else if( ent->progs.sv->absmax[node->axis] < node->dist )
else if( ent->v.absmax[node->axis] < node->dist )
node = node->children[1];
else break; // crosses the node
}
// link it in
if( ent->progs.sv->solid == SOLID_TRIGGER )
if( ent->v.solid == SOLID_TRIGGER )
SV_InsertLinkBefore( &sv_ent->area, &node->trigger_edicts, ent );
else SV_InsertLinkBefore (&sv_ent->area, &node->solid_edicts, ent );
sv_ent->linked = true;
@ -458,10 +458,10 @@ void SV_AreaEdicts_r( areanode_t *node, area_t *ap )
next = l->next;
check = EDICT_FROM_AREA( l );
if( check->progs.sv->solid == SOLID_NOT ) continue; // deactivated
if( check->progs.sv->absmin[0] > ap->maxs[0] || check->progs.sv->absmin[1] > ap->maxs[1]
|| check->progs.sv->absmin[2] > ap->maxs[2] || check->progs.sv->absmax[0] < ap->mins[0]
|| check->progs.sv->absmax[1] < ap->mins[1] || check->progs.sv->absmax[2] < ap->mins[2] )
if( check->v.solid == SOLID_NOT ) continue; // deactivated
if( check->v.absmin[0] > ap->maxs[0] || check->v.absmin[1] > ap->maxs[1]
|| check->v.absmin[2] > ap->maxs[2] || check->v.absmax[0] < ap->mins[0]
|| check->v.absmax[1] < ap->mins[1] || check->v.absmax[2] < ap->mins[2] )
continue; // not touching
if( ap->count == ap->maxcount )

View File

@ -119,17 +119,17 @@ static byte chktbl[1024] =
0x39, 0x4f, 0xdd, 0xe4, 0xb6, 0x19, 0x27, 0xfb, 0xb8, 0xf5, 0x32, 0x73, 0xe5, 0xcb, 0x32
};
void CRC_Init(word *crcvalue)
void CRC_Init( word *crcvalue )
{
*crcvalue = CRC_INIT_VALUE;
}
void CRC_ProcessByte(word *crcvalue, byte data)
void CRC_ProcessByte( word *crcvalue, byte data )
{
*crcvalue = (*crcvalue << 8) ^ crctable[(*crcvalue >> 8) ^ data];
}
word CRC_Block (byte *start, int count)
word CRC_Block( byte *start, int count )
{
word crc;

View File

@ -154,6 +154,7 @@ void Sys_GetStdAPI( void )
com.fread = FS_Read; // same as fread, can see trough pakfile
com.fprint = FS_Print; // printed message into file
com.fprintf = FS_Printf; // same as fprintf
com.fgetc = FS_Getc; // same as fgetc
com.fgets = FS_Gets; // like a fgets, but can return EOF
com.fseek = FS_Seek; // fseek, can seek in packfiles too
com.fremove = FS_Remove; // like remove

View File

@ -54,7 +54,7 @@ int Callback_ContactProcess( const NewtonMaterial* material, const NewtonContact
// this function is call after all contacts for this pairs is processed
void Callback_ContactEnd( const NewtonMaterial* material )
{
sv_edict_t *edict = (sv_edict_t *)NewtonBodyGetUserData( cms.touch_info.m_body0 );
edict_t *edict = (edict_t *)NewtonBodyGetUserData( cms.touch_info.m_body0 );
int id = NewtonBodyGetMaterialGroupID( cms.touch_info.m_body0 );
// if the max contact speed is larger than some minimum value. play a sound
@ -110,12 +110,12 @@ void Callback_ApplyForce_NoGravity( const NewtonBody* body )
void Callback_PmoveApplyForce( const NewtonBody* body )
{
// grab state and jump to CM_ServerMove
pi.ClientMove((sv_edict_t *)NewtonBodyGetUserData( body ));
pi.ClientMove((edict_t *)NewtonBodyGetUserData( body ));
}
void Callback_ApplyTransform( const NewtonBody* body, const float* src )
{
sv_edict_t *edict = (sv_edict_t *)NewtonBodyGetUserData( body );
edict_t *edict = (edict_t *)NewtonBodyGetUserData( body );
matrix4x4 tmp;
matrix3x3 dst;
vec3_t origin;

View File

@ -145,7 +145,7 @@ typedef struct clipmap_s
uint checksum; // map checksum
// shared copy of map (client - server)
char *entitystring;
script_t *entityscript;
cplane_t *planes; // 12 extra planes for box hull
cleaf_t *leafs; // 1 extra leaf for box hull
dleafbrush_t *leafbrushes;

View File

@ -77,7 +77,7 @@ void CM_FreeModel( cmodel_t *mod )
int CM_NumTextures( void ) { return cm.numshaders; }
int CM_NumClusters( void ) { return cm.numclusters; }
int CM_NumInlineModels( void ) { return cms.numbmodels; }
const char *CM_EntityString( void ) { return cm.entitystring; }
script_t *CM_EntityScript( void ) { return cm.entityscript; }
const char *CM_TexName( int index ) { return cm.shaders[index].name; }
/*
@ -619,9 +619,8 @@ void BSP_LoadEntityString( wfile_t *l )
byte *in;
in = WAD_Read( l, LUMP_ENTITIES, &filelen, TYPE_SCRIPT );
cm.entitystring = (byte *)Mem_Alloc( cmappool, filelen );
cm.entityscript = Com_OpenScript( LUMP_ENTITIES, in, filelen );
cm.checksum = LittleLong(Com_BlockChecksum( in, filelen ));
Mem_Copy( cm.entitystring, in, filelen );
}
/*
@ -935,7 +934,11 @@ void CM_FreeWorld( void )
cmodel_t *mod;
// free old stuff
if( cms.loaded ) Mem_EmptyPool( cmappool );
if( cms.loaded )
{
Com_CloseScript( cm.entityscript );
Mem_EmptyPool( cmappool );
}
Mem_Set( &cm, 0, sizeof( cm ));
for( i = 0, mod = cms.bmodels; i < cms.numbmodels; i++, mod++ )
@ -978,13 +981,16 @@ cmodel_t *CM_BeginRegistration( const char *name, bool clientload, uint *checksu
if(!com.strcmp( cm.name, name ) && cms.loaded )
{
// singleplayer mode: serever already loading map
// singleplayer mode: server already loading map
*checksum = cm.checksum;
if( !clientload )
{
// rebuild portals for server
Mem_Set( cms.portalopen, 0, sizeof( cms.portalopen ));
CM_FloodAreaConnections();
// and reset entity script
Com_ResetScript( cm.entityscript );
}
// still have the right version
return &cms.bmodels[0];

View File

@ -238,7 +238,7 @@ void CM_ClientMove( pmove_t *pmove )
}
physbody_t *Phys_CreatePlayer( sv_edict_t *ed, cmodel_t *mod, const vec3_t origin, const matrix3x3 matrix )
physbody_t *Phys_CreatePlayer( edict_t *ed, cmodel_t *mod, const vec3_t origin, const matrix3x3 matrix )
{
NewtonCollision *col, *hull;
NewtonBody *body;

View File

@ -8,7 +8,7 @@
#include "matrix_lib.h"
#include "cm_local.h"
physbody_t *Phys_CreateBody( sv_edict_t *ed, cmodel_t *mod, const vec3_t org, const matrix3x3 m, int solid, int move )
physbody_t *Phys_CreateBody( edict_t *ed, cmodel_t *mod, const vec3_t org, const matrix3x3 m, int solid, int move )
{
NewtonCollision *col;
NewtonBody *body;

View File

@ -54,7 +54,7 @@ byte *CM_FatPVS( const vec3_t org, bool portal );
int CM_NumClusters( void );
int CM_NumTextures( void );
int CM_NumInlineModels( void );
const char *CM_EntityString( void );
script_t *CM_EntityScript( void );
const char *CM_TexName( int index );
int CM_PointContents( const vec3_t p, cmodel_t *model );
int CM_TransformedPointContents( const vec3_t p, cmodel_t *model, const vec3_t origin, const vec3_t angles );

View File

@ -96,7 +96,7 @@ physic_exp_t DLLEXPORT *CreateAPI ( stdlib_api_t *input, physic_imp_t *engfuncs
Phys.NumClusters = CM_NumClusters;
Phys.NumTextures = CM_NumTextures;
Phys.NumBmodels = CM_NumInlineModels;
Phys.GetEntityString = CM_EntityString;
Phys.GetEntityScript = CM_EntityScript;
Phys.GetTextureName = CM_TexName;
Phys.ClipToGenericEntity = CM_CollisionClipToGenericEntity;
Phys.ClipToWorld = CM_CollisionClipToWorld;

View File

@ -90,7 +90,7 @@ BSC32=bscmake.exe
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
# ADD LINK32 user32.lib msvcrtd.lib newton.lib opengl32.lib /nologo /dll /debug /machine:I386 /nodefaultlib:"libc.lib" /pdbtype:sept /libpath:"../public/libs/"
# ADD LINK32 user32.lib msvcrtd.lib newton.lib opengl32.lib /nologo /dll /debug /machine:I386 /nodefaultlib:"libc.lib" /pdbtype:sept
# SUBTRACT LINK32 /nodefaultlib
# Begin Custom Build
TargetDir=\Xash3D\src_main\temp\physic\!debug

View File

@ -44,8 +44,8 @@ void Phys_Frame( float time );
//
// cm_rigidbody.c
//
physbody_t *Phys_CreateBody( sv_edict_t *ed, cmodel_t *mod, const vec3_t org, const matrix3x3 m, int solid, int move );
physbody_t *Phys_CreatePlayer( sv_edict_t *ed, cmodel_t *mod, const vec3_t origin, const matrix3x3 matrix );
physbody_t *Phys_CreateBody( edict_t *ed, cmodel_t *mod, const vec3_t org, const matrix3x3 m, int solid, int move );
physbody_t *Phys_CreatePlayer( edict_t *ed, cmodel_t *mod, const vec3_t origin, const matrix3x3 matrix );
void Phys_SetParameters( physbody_t *body, cmodel_t *mod, int material, float mass );
bool Phys_GetForce( physbody_t *body, vec3_t velocity, vec3_t avelocity, vec3_t force, vec3_t torque );
void Phys_SetForce( physbody_t *body, vec3_t velocity, vec3_t avelocity, vec3_t force, vec3_t torque );

View File

@ -5,9 +5,95 @@
#ifndef CONST_H
#define CONST_H
// euler angle order
#define PITCH 0
#define YAW 1
#define ROLL 2
#define VOL_NORM 1.0 // volume values
// pitch values
#define PITCH_LOW 95 // other values are possible - 0-255, where 255 is very high
#define PITCH_NORM 100 // non-pitch shifted
#define PITCH_HIGH 120
// attenuation values
#define ATTN_NONE 0
#define ATTN_NORM 0.8f
#define ATTN_IDLE 2.0f
#define ATTN_STATIC 1.25f
// channels
#define CHAN_AUTO 0
#define CHAN_WEAPON 1
#define CHAN_VOICE 2
#define CHAN_ITEM 3
#define CHAN_BODY 4
#define CHAN_STREAM 5 // allocate stream channel from the static or dynamic area
#define CHAN_STATIC 6 // allocate channel from the static area
// in buttons
#define IN_ATTACK (1<<0)
#define IN_JUMP (1<<1)
#define IN_DUCK (1<<2)
#define IN_FORWARD (1<<3)
#define IN_BACK (1<<4)
#define IN_USE (1<<5)
#define IN_CANCEL (1<<6)
#define IN_LEFT (1<<7)
#define IN_RIGHT (1<<8)
#define IN_MOVELEFT (1<<9)
#define IN_MOVERIGHT (1<<10)
#define IN_ATTACK2 (1<<11)
#define IN_RUN (1<<12)
#define IN_RELOAD (1<<13)
#define IN_ALT1 (1<<14)
#define IN_SCORE (1<<15) // Used by client.dll for when scoreboard is held down
// edict_t->spawnflags
#define SF_START_ON 0x1
// edict->flags
#define FL_CLIENT (1<<0)
#define FL_MONSTER (1<<1) // monster bit
#define FL_INWATER (1<<2)
#define FL_INTERMISSION (1<<3)
#define FL_ONGROUND (1<<2) // at rest / on the ground
#define FL_SKYENTITY (1<<5) // it's a env_sky entity
#define FL_WATERJUMP (1<<6) // player jumping out of water
#define FL_FLOAT (1<<7) // Apply floating force to this entity when in water
#define FL_GRAPHED (1<<8) // worldgraph has this ent listed as something that blocks a connection
#define FL_TANK (1<<9) // this is func tank
#define FL_ROCKET (1<<10) // this is rocket entity
#define FL_POINTENTITY (1<<11) // this is point entity
#define FL_PROXY (1<<12) // This is a spectator proxy
#define FL_FRAMETHINK (1<<13) // Brush model flag -- call think every frame regardless of nextthink - ltime (for constantly changing velocity/path)
#define FL_BASEVELOCITY (1<<14) // Base velocity has been applied this frame (used to convert base velocity into momentum)
#define FL_MONSTERCLIP (1<<15) // Only collide in with monsters who have FL_MONSTERCLIP set
#define FL_ONTRAIN (1<<16) // Player is _controlling_ a train, so movement commands should be ignored on client during prediction.
#define FL_WORLDBRUSH (1<<17) // Not moveable/removeable brush entity (really part of the world, but represented as an entity for transparency or something)
#define FL_SPECTATOR (1<<18) // This client is a spectator, don't run touch functions, etc.
#define FL_CUSTOMENTITY (1<<19) // This is a custom entity
#define FL_KILLME (1<<20) // This entity is marked for death -- This allows the engine to kill ents at the appropriate time
#define FL_DORMANT (1<<21) // Entity is dormant, no updates to client
#define FL_PARTIALONGROUND (1<<22) // not corners are valid
// edict->aiflags
#define AI_FLY (1<<0) // changes the SV_Movestep() behavior to not need to be on ground
#define AI_SWIM (1<<1) // same as AI_FLY but stay in water
#define AI_WATERJUMP (1<<2) // -- reserved --
#define AI_GODMODE (1<<4) // invulnerability npc or client
#define AI_NOTARGET (1<<5) // mark any npc as neytral
#define AI_NOSTEP (1<<6) // -- reserved --
#define AI_DUCKED (1<<7) // monster (or player) is ducked
#define AI_JUMPING (1<<8) // monster (or player) is jumping
#define AI_FROZEN (1<<9) // stop moving, but continue thinking (e.g. for thirdperson camera)
#define AI_ACTOR (1<<10) // npc that playing scriped_sequence
#define AI_DRIVER (1<<11) // npc or player driving vehcicle or train
#define AI_SPECTATOR (1<<12) // spectator mode for clients
// entity_state_t->effects
#define EF_BRIGHTFIELD (1<<0) // swirling cloud of particles
#define EF_MUZZLEFLASH (1<<1) // single frame ELIGHT on entity attachment 0
@ -18,9 +104,101 @@
#define EF_NODRAW (1<<6) // don't draw entity
#define EF_ROTATE (1<<7) // rotate bonus item
#define EF_MINLIGHT (1<<8) // allways have some light (viewmodel)
#define EF_LIGHT (1<<9) // dynamic light (rockets use)
// edict->deadflag values
#define DEAD_NO 0 // alive
#define DEAD_DYING 1 // playing death animation or still falling off of a ledge waiting to hit ground
#define DEAD_DEAD 2 // dead. lying still.
#define DEAD_RESPAWNABLE 3 // wait for respawn
#define DEAD_DISCARDBODY 4
#define DAMAGE_NO 0
#define DAMAGE_YES 1
#define DAMAGE_AIM 2
// engine edict types
typedef enum
{
ED_SPAWNED = 0, // this entity requris to set own type with SV_ClassifyEdict
ED_WORLDSPAWN, // this is a worldspawn
ED_STATIC, // this is a logic without model or entity with static model
ED_AMBIENT, // this is entity emitted ambient sounds only
ED_NORMAL, // normal entity with model (and\or) sound
ED_BSPBRUSH, // brush entity (a part of level)
ED_CLIENT, // this is a client entity
ED_MONSTER, // monster or bot (generic npc with AI)
ED_TEMPENTITY, // this edict will be removed on server when "lifetime" exceeds
ED_BEAM, // laser beam (needs to recalculate pvs and frustum)
ED_MOVER, // func_train, func_door and another bsp or mdl movers
ED_VIEWMODEL, // client or bot viewmodel (for spectating)
ED_ITEM, // holdable items
ED_RAGDOLL, // dead body with simulated ragdolls
ED_RIGIDBODY, // simulated physic
ED_TRIGGER, // just for sorting on a server
ED_PORTAL, // realtime display, portal or mirror brush or model
ED_MISSILE, // greande, rocket e.t.c
ED_DECAL, // render will be merge real coords and normal
ED_VEHICLE, // controllable vehicle
ED_MAXTYPES,
} edtype_t;
// edict movetype
typedef enum
{
MOVETYPE_NONE, // never moves
MOVETYPE_NOCLIP, // origin and angles change with no interaction
MOVETYPE_PUSH, // no clip to world, push on box contact
MOVETYPE_WALK, // gravity
MOVETYPE_STEP, // gravity, special edge handling
MOVETYPE_FLY,
MOVETYPE_TOSS, // gravity
MOVETYPE_BOUNCE,
MOVETYPE_FOLLOW, // attached models
MOVETYPE_CONVEYOR,
MOVETYPE_PUSHSTEP,
MOVETYPE_PHYSIC, // phys simulation
} movetype_t;
// edict collision modes
typedef enum
{
SOLID_NOT = 0, // no interaction with other objects
SOLID_TRIGGER, // only touch when inside, after moving
SOLID_BBOX, // touch on edge
SOLID_SLIDEBOX, //
SOLID_BSP, // bsp clip, touch on edge
SOLID_BOX, // physbox
SOLID_SPHERE, // sphere
SOLID_CYLINDER, // cylinder e.g. barrel
SOLID_MESH, // custom convex hull
} solid_t;
typedef enum
{
point_hull = 0,
human_hull = 1,
large_hull = 2,
head_hull = 3
};
// beam types, encoded as a byte
typedef enum
{
BEAM_POINTS = 0,
BEAM_ENTPOINT,
BEAM_ENTS,
BEAM_HOSE,
} kBeamType_t;
// lower bits encoded as kBeamType_t (max 8 types)
#define BEAM_FSINE (1<<3)
#define BEAM_FSOLID (1<<4)
#define BEAM_FSHADEIN (1<<5)
#define BEAM_FSHADEOUT (1<<6)
// rendering constants
enum
typedef enum
{
kRenderNormal, // src
kRenderTransColor, // c*a+dest*(1-a)
@ -30,12 +208,21 @@ enum
kRenderTransAdd, // src*a+dest
} kRenderMode_t;
enum
typedef enum
{
kRenderFxNone = 0,
// legacy stuff are not supported
kRenderFxNoDissipation = 14,
kRenderFxDistort, // Distort/scale/translate flicker
kRenderFxHologram, // kRenderFxDistort + distance fade
kRenderFxDeadPlayer, // kRenderAmt is the player index
kRenderFxExplode, // Scale up really big!
kRenderFxGlowShell, // Glowing Shell
kRenderFxNoReflect, // Don't reflecting in mirrors
kRenderFxClampMinScale, // Keep this sprite from getting very small (SPRITES only!)
kRenderFxAurora, // set particle trail for this entity
kRenderFxNoReflect, // don't reflecting in mirrors
} kRenderFx_t;
#endif//CONST_H

View File

@ -5,11 +5,15 @@
#ifndef ENGINE_API_H
#define ENGINE_API_H
#include "const.h"
//
// engine constant limits, touching networking protocol modify with precaution
//
#define MAX_DLIGHTS 128 // dynamic lights (per one frame)
#define MAX_LIGHTSTYLES 256 // can be blindly increased
#define MAX_LIGHTSTYLES 256 // can't be blindly increased
#define MAX_DECALS 256 // server decal indexes
#define MAX_USER_MESSAGES 200 // another 56 messages reserved for engine routines
#define MAX_CLASSNAMES 512 // maxcount of various edicts classnames
#define MAX_SOUNDS 512 // openal software limit
#define MAX_MODELS 4096 // total count of brush & studio various models per one map
@ -17,62 +21,6 @@
#define MAX_EDICTS 65535 // absolute limit that never be reached, (do not edit!)
#define MAX_VERTS_ON_POLY 10 // decal vertices
// engine edict types
typedef enum
{
ED_SPAWNED = 0, // this entity requris to set own type with SV_ClassifyEdict
ED_WORLDSPAWN, // this is a worldspawn
ED_STATIC, // this is a logic without model or entity with static model
ED_AMBIENT, // this is entity emitted ambient sounds only
ED_NORMAL, // normal entity with model (and\or) sound
ED_BSPBRUSH, // brush entity (a part of level)
ED_CLIENT, // this is a client entity
ED_MONSTER, // monster or bot (generic npc with AI)
ED_TEMPENTITY, // this edict will be removed on server when "lifetime" exceeds
ED_BEAM, // laser beam (needs to recalculate pvs and frustum)
ED_MOVER, // func_train, func_door and another bsp or mdl movers
ED_VIEWMODEL, // client or bot viewmodel (for spectating)
ED_ITEM, // holdable items
ED_RAGDOLL, // dead body with simulated ragdolls
ED_RIGIDBODY, // simulated physic
ED_TRIGGER, // just for sorting on a server
ED_PORTAL, // realtime display, portal or mirror brush or model
ED_MISSILE, // greande, rocket e.t.c
ED_DECAL, // render will be merge real coords and normal
ED_VEHICLE, // controllable vehicle
ED_MAXTYPES,
} edtype_t;
// edict movetype
typedef enum
{
MOVETYPE_NONE, // never moves
MOVETYPE_NOCLIP, // origin and angles change with no interaction
MOVETYPE_PUSH, // no clip to world, push on box contact
MOVETYPE_WALK, // gravity
MOVETYPE_STEP, // gravity, special edge handling
MOVETYPE_FLY,
MOVETYPE_TOSS, // gravity
MOVETYPE_BOUNCE,
MOVETYPE_FOLLOW, // attached models
MOVETYPE_CONVEYOR,
MOVETYPE_PUSHABLE,
MOVETYPE_PHYSIC, // phys simulation
} movetype_t;
// edict collision modes
typedef enum
{
SOLID_NOT = 0, // no interaction with other objects
SOLID_TRIGGER, // only touch when inside, after moving
SOLID_BBOX, // touch on edge
SOLID_BSP, // bsp clip, touch on edge
SOLID_BOX, // physbox
SOLID_SPHERE, // sphere
SOLID_CYLINDER, // cylinder e.g. barrel
SOLID_MESH, // custom convex hull
} solid_t;
// model_state_t communication (a part of network protocol)
typedef struct model_state_s
{

View File

@ -19,7 +19,10 @@
#define DLLEXPORT __declspec( dllexport )
// generic engine types
#ifndef __cplusplus
typedef enum { false, true } bool;
#endif
typedef unsigned char byte;
typedef unsigned short word;
typedef unsigned long dword;
@ -38,13 +41,11 @@ typedef vec_t matrix3x3[3][3];
typedef vec_t matrix4x4[4][4];
typedef char string[MAX_STRING];
typedef struct edict_s edict_t;
typedef struct sv_edict_s sv_edict_t;
typedef struct pr_edict_s pr_edict_t;
typedef struct cl_edict_s cl_edict_t;
typedef struct ui_edict_s ui_edict_t;
typedef struct sv_entvars_s sv_entvars_t;
typedef struct cl_entvars_s cl_entvars_t;
typedef struct ui_entvars_s ui_entvars_t;
typedef struct sv_globalvars_s sv_globalvars_t;
typedef struct cl_globalvars_s cl_globalvars_t;
typedef struct ui_globalvars_s ui_globalvars_t;
typedef struct physbody_s physbody_t;
@ -532,6 +533,7 @@ typedef struct stdilib_api_s
long (*fread)(file_t* file, void* buffer, size_t buffersize); // same as fread, can see trough pakfile
int (*fprint)(file_t* file, const char *msg); // printed message into file
int (*fprintf)(file_t* file, const char* format, ...); // same as fprintf
int (*fgetc)( file_t* file ); // same as fgetc
int (*fgets)(file_t* file, byte *string, size_t bufsize ); // like a fgets, but can return EOF
int (*fseek)(file_t* file, fs_offset_t offset, int whence); // fseek, can seek in packfiles too
bool (*fremove)( const char *path ); // remove sepcified file
@ -746,6 +748,7 @@ filesystem manager
#define FS_Print com.fprint
#define FS_Seek com.fseek
#define FS_Tell com.ftell
#define FS_Getc com.fgetc
#define FS_Gets com.fgets
#define FS_Delete com.fremove
#define FS_Gamedir com.GameInfo->gamedir

View File

@ -6,6 +6,7 @@
#define BASEMATH_H
#include <math.h>
#include "const.h"
#ifndef M_PI
#define M_PI (float)3.14159265358979323846
@ -15,11 +16,6 @@
#define M_PI2 (float)6.28318530717958647692
#endif
// euler angle order
#define PITCH 0
#define YAW 1
#define ROLL 2
#define METERS_PER_INCH 0.0254f
#define EQUAL_EPSILON 0.001f
#define STOP_EPSILON 0.1f

View File

@ -80,7 +80,7 @@ typedef struct physic_exp_s
int (*NumClusters)( void );
int (*NumTextures)( void );
int (*NumBmodels )( void );
const char *(*GetEntityString)( void );
script_t *(*GetEntityScript)( void );
const char *(*GetTextureName)( int index );
byte *(*ClusterPVS)( int cluster );
byte *(*ClusterPHS)( int cluster );
@ -101,8 +101,8 @@ typedef struct physic_exp_s
void (*PlayerMove)( pmove_t *pmove, bool clientmove );
// simple objects
physbody_t *(*CreateBody)( sv_edict_t *ed, cmodel_t *mod, const vec3_t org, const matrix3x3 m, int solid, int move );
physbody_t *(*CreatePlayer)( sv_edict_t *ed, cmodel_t *mod, const vec3_t origin, const matrix3x3 matrix );
physbody_t *(*CreateBody)( edict_t *ed, cmodel_t *mod, const vec3_t org, const matrix3x3 m, int solid, int move );
physbody_t *(*CreatePlayer)( edict_t *ed, cmodel_t *mod, const vec3_t origin, const matrix3x3 matrix );
void (*SetOrigin)( physbody_t *body, vec3_t origin );
void (*SetParameters)( physbody_t *body, cmodel_t *mod, int material, float mass );
@ -118,10 +118,10 @@ typedef struct physic_imp_s
// interface validator
size_t api_size; // must matched with sizeof(physic_imp_t)
void (*ClientMove)( sv_edict_t *ed );
void (*Transform)( sv_edict_t *ed, const vec3_t org, const matrix3x3 matrix );
void (*PlaySound)( sv_edict_t *ed, float volume, float pitch, const char *sample );
float *(*GetModelVerts)( sv_edict_t *ent, int *numvertices );
void (*ClientMove)( edict_t *ed );
void (*Transform)( edict_t *ed, const vec3_t org, const matrix3x3 matrix );
void (*PlaySound)( edict_t *ed, float volume, float pitch, const char *sample );
float *(*GetModelVerts)( edict_t *ent, int *numvertices );
} physic_imp_t;
#endif//PHYSIC_API_H

View File

@ -245,6 +245,13 @@ typedef enum
#define LUMP_AREAS "areas"
#define LUMP_AREAPORTALS "areaportals"
#define MAP_SINGLEPLAYER BIT(0)
#define MAP_DEATHMATCH BIT(1) // Classic DeathMatch
#define MAP_COOPERATIVE BIT(2) // Cooperative mode
#define MAP_TEAMPLAY_CTF BIT(3) // teamplay Capture The Flag
#define MAP_TEAMPLAY_DOM BIT(4) // teamplay dominate
#define MAP_LASTMANSTANDING BIT(5)
typedef enum
{
SURF_NONE = 0, // just a mask for source tabulation
@ -310,7 +317,8 @@ typedef struct
int ident;
int version;
char message[64]; // map message
int reserved[14]; // future expansions
int flags; // map flags
int reserved[13]; // future expansions
} dheader_t;
typedef struct

327
public/svgame_api.h Normal file
View File

@ -0,0 +1,327 @@
//=======================================================================
// Copyright XashXT Group 2008 ©
// svgame_api.h - entity interface between engine and svgame
//=======================================================================
#ifndef SVGAME_API_H
#define SVGAME_API_H
#define INTERFACE_VERSION 138
typedef enum
{
at_console = 1, // format: [msg]
at_warning, // format: Warning: [msg]
at_error, // format: Error: [msg]
at_loading, // print messages during loading
at_aiconsole, // same as at_console, but only shown if developer level is 5!
at_logged // server print to console ( only in multiplayer games ).
} ALERT_TYPE;
// Client_Printf modes
enum
{
print_console = 0,
print_center,
print_chat
};
enum
{
WALKMOVE_NORMAL = 0,
WALKMOVE_NOMONSTERS,
WALKMOVE_MISSILE,
WALKMOVE_WORLDONLY,
WALKMOVE_HITMODEL,
WALKMOVE_CHECKONLY,
};
#define at_debug at_console // FIXME: stupid Laurie stuff
// NOTE: engine trace struct not matched with svgame trace
typedef struct
{
bool fAllSolid; // if true, plane is not valid
bool fStartSolid; // if true, the initial point was in a solid area
bool fStartStuck; // if true, trace started from solid entity
float flFraction; // time completed, 1.0 = didn't hit anything
vec3_t vecEndPos; // final position
int iStartContents; // start pos conetnts
int iContents; // final pos contents
int iHitgroup; // 0 == generic, non zero is specific body part
float flPlaneDist; // planes distance
vec3_t vecPlaneNormal; // surface normal at impact
const char *pTexName; // texture name that we hitting (brushes and studiomodels)
edict_t *pHit; // entity the surface is on
} TraceResult;
// engine hands this to DLLs for functionality callbacks
typedef struct enginefuncs_s
{
// interface validator
int api_size; // must matched with sizeof( enginefuncs_t )
int (*pfnPrecacheModel)( const char* s );
int (*pfnPrecacheSound)( const char* s );
void (*pfnSetModel)( edict_t *e, const char *m );
int (*pfnModelIndex)( const char *m );
int (*pfnModelFrames)( int modelIndex );
void (*pfnSetSize)( edict_t *e, const float *rgflMin, const float *rgflMax );
void (*pfnChangeLevel)( const char* s1, const char* s2 );
float (*pfnVecToYaw)( const float *rgflVector );
void (*pfnVecToAngles)( const float *rgflVectorIn, float *rgflVectorOut );
void (*pfnMoveToOrigin)( edict_t *ent, const float *pflGoal, float dist, int iMoveType );
void (*pfnChangeYaw)( edict_t* ent );
void (*pfnChangePitch)( edict_t* ent );
edict_t* (*pfnFindEntityByString)( edict_t *pStartEdict, const char *pszField, const char *pszValue);
int (*pfnGetEntityIllum)( edict_t* pEnt );
edict_t* (*pfnFindEntityInSphere)( edict_t *pStartEdict, const float *org, float rad );
edict_t* (*pfnFindClientInPVS)( edict_t *pEdict );
edict_t* (*pfnFindClientInPHS)( edict_t *pEdict );
edict_t* (*pfnEntitiesInPVS)( edict_t *pplayer );
edict_t* (*pfnEntitiesInPHS)( edict_t *pplayer );
void (*pfnMakeVectors)( const float *rgflVector );
void (*pfnAngleVectors)( const float *rgflVector, float *forward, float *right, float *up );
edict_t* (*pfnCreateEntity)( void );
void (*pfnRemoveEntity)( edict_t* e );
edict_t* (*pfnCreateNamedEntity)( string_t className );
void (*pfnMakeStatic)( edict_t *ent );
int (*pfnEntIsOnFloor)( edict_t *e );
int (*pfnDropToFloor)( edict_t* e );
int (*pfnWalkMove)( edict_t *ent, float yaw, float dist, int iMode );
void (*pfnSetOrigin)( edict_t *e, const float *rgflOrigin );
void (*pfnSetAngles)( edict_t *e, const float *rgflAngles );
void (*pfnEmitSound)( edict_t *ent, int chan, const char *sample, float vol, float attn, int flags, int pitch );
void (*pfnEmitAmbientSound)( edict_t *ent, float *pos, const char *samp, float vol, float attn, int flags, int pitch );
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 );
void (*pfnTraceHull)( const float *v1, const float *v2, int fNoMonsters, int hullNumber, edict_t *pentToSkip, TraceResult *ptr );
void (*pfnTraceModel)( const float *v1, const float *v2, edict_t *pent, TraceResult *ptr );
const char *(*pfnTraceTexture)( edict_t *pTextureEntity, const float *v1, const float *v2 );
void (*pfnGetAimVector)( edict_t* ent, float speed, float *rgflReturn );
void (*pfnServerCommand)( const char* str );
void (*pfnServerExecute)( void );
void (*pfnClientCommand)( edict_t* pEdict, char* szFmt, ... );
void (*pfnParticleEffect)( const float *org, const float *dir, float color, float count );
void (*pfnLightStyle)( int style, char* val );
int (*pfnDecalIndex)( const char *name );
int (*pfnPointContents)( const float *rgflVector);
void (*pfnMessageBegin)( int msg_dest, int msg_type, const float *pOrigin, edict_t *ed );
void (*pfnMessageEnd)( void );
void (*pfnWriteByte)( int iValue );
void (*pfnWriteChar)( int iValue );
void (*pfnWriteShort)( int iValue );
void (*pfnWriteLong)( int iValue );
void (*pfnWriteAngle)( float flValue );
void (*pfnWriteCoord)( float flValue );
void (*pfnWriteString)( const char *sz );
void (*pfnWriteEntity)( int iValue );
void (*pfnCVarRegister)( const char *name, const char *value, int flags, const char *desc );
float (*pfnCVarGetFloat)( const char *szVarName );
const char* (*pfnCVarGetString)( const char *szVarName );
void (*pfnCVarSetFloat)( const char *szVarName, float flValue );
void (*pfnCVarSetString)( const char *szVarName, const char *szValue );
void (*pfnAlertMessage)( ALERT_TYPE level, char *szFmt, ... );
void* (*pfnPvAllocEntPrivateData)( edict_t *pEdict, long cb );
void (*pfnFreeEntPrivateData)( edict_t *pEdict );
string_t (*pfnAllocString)( const char *szValue );
edict_t* (*pfnPEntityOfEntOffset)( int iEntOffset );
int (*pfnEntOffsetOfPEntity)( const edict_t *pEdict );
int (*pfnIndexOfEdict)( const edict_t *pEdict );
edict_t* (*pfnPEntityOfEntIndex)( int iEntIndex );
edict_t* (*pfnFindEntityByVars)( entvars_t* pvars );
void* (*pfnGetModelPtr)( edict_t* pEdict );
int (*pfnRegUserMsg)( const char *pszName, int iSize );
void (*pfnAnimationAutomove)( const edict_t* pEdict, float flTime );
void (*pfnGetBonePosition)( const edict_t* pEdict, int iBone, float *rgflOrigin, float *rgflAngles );
dword (*pfnFunctionFromName)( const char *pName );
const char *(*pfnNameForFunction)( dword function );
void (*pfnClientPrintf)( edict_t* pEdict, int ptype, const char *szMsg );
void (*pfnServerPrint)( const char *szMsg );
void (*pfnAreaPortal)( edict_t *pEdict, bool enable );
const char *(*pfnCmd_Args)( void );
const char *(*pfnCmd_Argv)( int argc );
int (*pfnCmd_Argc)( void );
void (*pfnGetAttachment)( const edict_t *pEdict, int iAttachment, float *rgflOrigin, float *rgflAngles );
void (*pfnCRC_Init)( word *pulCRC );
void (*pfnCRC_ProcessBuffer)( word *pulCRC, void *p, int len );
word (*pfnCRC_Final)( word pulCRC );
long (*pfnRandomLong)( long lLow, long lHigh );
float (*pfnRandomFloat)( float flLow, float flHigh );
void (*pfnSetView)( const edict_t *pClient, const edict_t *pViewent );
void (*pfnCrosshairAngle)( const edict_t *pClient, float pitch, float yaw );
byte* (*pfnLoadFile)( const char *filename, int *pLength );
void (*pfnFreeFile)( void *buffer );
int (*pfnCompareFileTime)( const char *filename1, const char *filename2, int *iCompare );
void (*pfnGetGameDir)( char *szGetGameDir );
void (*pfnStaticDecal)( const float *origin, int decalIndex, int entityIndex, int modelIndex );
int (*pfnPrecacheGeneric)( const char* s );
int (*pfnIsDedicatedServer)( void ); // is this a dedicated server?
int (*pfnIsMapValid)( char *filename );
void (*pfnInfo_RemoveKey)( char *s, char *key );
char* (*pfnInfoKeyValue)( char *infobuffer, char *key );
void (*pfnSetKeyValue)( char *infobuffer, char *key, char *value );
char* (*pfnGetInfoKeyBuffer)( edict_t *e ); // passing in NULL gets the serverinfo
void (*pfnSetClientKeyValue)( int clientIndex, char *infobuffer, char *key, char *value );
void (*pfnSetSkybox)( const char *name );
void (*pfnPlayMusic)( const char *trackname, int flags ); // background track
void (*pfnDropClient)( int clientIndex ); // used for kick cheaters from server
} enginefuncs_t;
// passed to pfnKeyValue
typedef struct KeyValueData_s
{
char *szClassName; // in: entity classname
char *szKeyName; // in: name of key
char *szValue; // in: value of key
long fHandled; // out: DLL sets to true if key-value pair was understood
} KeyValueData;
typedef struct
{
char mapName[64];
char landmarkName[64];
edict_t *pentLandmark;
vec3_t vecLandmarkOrigin;
} LEVELLIST;
typedef struct
{
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; // bit mask of transitions that this entity is in the PVS of
string_t classname; // entity class name
} ENTITYTABLE;
#define FTYPEDESC_GLOBAL 0x0001 // This field is masked for global entity save/restore
#define MAX_LEVEL_CONNECTIONS 32 // These are encoded in the lower 16bits of ENTITYTABLE->flags
#define FENTTABLE_GLOBAL 0x10000000
#define FENTTABLE_MOVEABLE 0x20000000
#define FENTTABLE_REMOVED 0x40000000
#define FENTTABLE_PLAYER 0x80000000
typedef struct saverestore_s
{
char *pBaseData; // start of all entity save data
char *pCurrentData; // current buffer pointer for sequential access
int size; // current data size
int bufferSize; // total space for data
int tokenSize; // size of the linear list of tokens
int tokenCount; // number of elements in the pTokens table
char **pTokens; // hash table of entity strings (sparse)
int currentIndex; // holds a global entity table ID
int tableCount; // number of elements in the entity table
int connectionCount; // number of elements in the levelList[]
ENTITYTABLE *pTable; // array of ENTITYTABLE elements (1 for each entity)
LEVELLIST levelList[MAX_LEVEL_CONNECTIONS]; // list of connections from this level
// smooth transition
int fUseLandmark;
char szLandmarkName[64]; // landmark we'll spawn near in next level
vec3_t vecLandmarkOffset; // for landmark transitions
float time;
char szCurrentMap[64]; // To check global entities
} SAVERESTOREDATA;
typedef enum _fieldtypes
{
FIELD_FLOAT = 0, // any floating point value
FIELD_STRING, // a string ID (return from ALLOC_STRING)
FIELD_ENTITY, // an entity offset (EOFFSET)
FIELD_CLASSPTR, // CBaseEntity *
FIELD_EHANDLE, // entity handle
FIELD_EVARS, // EVARS *
FIELD_EDICT, // edict_t *, or edict_t * (same thing)
FIELD_VECTOR, // any vector
FIELD_POSITION_VECTOR, // a world coordinate (these are fixed up across level transitions automagically)
FIELD_POINTER, // arbitrary data pointer... to be removed, use an array of FIELD_CHARACTER
FIELD_INTEGER, // any integer or enum
FIELD_FUNCTION, // a class function pointer (Think, Use, etc)
FIELD_BOOLEAN, // boolean, implemented as an int, I may use this as a hint for compression
FIELD_SHORT, // 2 byte integer
FIELD_CHARACTER, // a byte
FIELD_TIME, // a floating point time (these are fixed up automatically too!)
FIELD_MODELNAME, // engine string that is a model name (needs precache)
FIELD_SOUNDNAME, // engine string that is a sound name (needs precache)
FIELD_RANGE, // Min and Max range for generate random value
FIELD_TYPECOUNT, // MUST BE LAST
} FIELDTYPE;
typedef struct
{
FIELDTYPE fieldType;
char *fieldName;
int fieldOffset;
short fieldSize;
short flags;
} TYPEDESCRIPTION;
#define offsetof( s, m ) (size_t)&(((s *)0)->m)
#define ARRAYSIZE( p ) (sizeof( p ) / sizeof( p[0] ))
#define _FIELD( type, name, fieldtype, count, flags ) { fieldtype, #name, offsetof( type, name ), count, flags }
#define DEFINE_FIELD( type, name, fieldtype ) _FIELD( type, name, fieldtype, 1, 0 )
#define DEFINE_ARRAY( type, name, fieldtype, count ) _FIELD( type, name, fieldtype, count, 0 )
#define DEFINE_ENTITY_FIELD( name, fieldtype ) _FIELD( entvars_t, name, fieldtype, 1, 0 )
#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 )
typedef struct
{
// interface validator
size_t api_size; // must matched with sizeof(DLL_FUNCTIONS)
// initialize/shutdown the game (one-time call after loading of game .dll )
void (*pfnGameInit)( void );
int (*pfnSpawn)( edict_t *pent );
void (*pfnThink)( edict_t *pent );
void (*pfnUse)( edict_t *pentUsed, edict_t *pentOther );
void (*pfnTouch)( edict_t *pentTouched, edict_t *pentOther );
void (*pfnBlocked)( edict_t *pentBlocked, edict_t *pentOther );
void (*pfnKeyValue)( edict_t *pentKeyvalue, KeyValueData *pkvd );
void (*pfnSave)( edict_t *pent, SAVERESTOREDATA *pSaveData );
int (*pfnRestore)( edict_t *pent, SAVERESTOREDATA *pSaveData, int globalEntity );
void (*pfnSetAbsBox)( edict_t *pent );
void (*pfnSaveWriteFields)( SAVERESTOREDATA*, const char*, void*, TYPEDESCRIPTION*, int );
void (*pfnSaveReadFields)( SAVERESTOREDATA*, const char*, void*, TYPEDESCRIPTION*, int );
void (*pfnSaveGlobalState)( SAVERESTOREDATA * );
void (*pfnRestoreGlobalState)( SAVERESTOREDATA * );
void (*pfnResetGlobalState)( void );
int (*pfnClientConnect)( edict_t *pEntity, const char *userinfo );
void (*pfnClientDisconnect)( edict_t *pEntity );
void (*pfnClientKill)( edict_t *pEntity );
void (*pfnClientPutInServer)( edict_t *pEntity );
void (*pfnClientCommand)( edict_t *pEntity );
void (*pfnClientUserInfoChanged)( edict_t *pEntity, char *infobuffer );
void (*pfnServerActivate)( edict_t *pEdictList, int edictCount, int clientMax );
void (*pfnServerDeactivate)( void );
void (*pfnPlayerPreThink)( edict_t *pEntity );
void (*pfnPlayerPostThink)( edict_t *pEntity );
void (*pfnStartFrame)( void );
void (*pfnParmsNewLevel)( void );
void (*pfnParmsChangeLevel)( void );
// returns string describing current .dll. E.g., TeamFotrress 2, Half-Life
const char *(*pfnGetGameDescription)( void );
// notify game .dll that engine is going to shut down. Allows mod authors to set a breakpoint.
void (*pfnHostError)( const char *error_string );
} DLL_FUNCTIONS;
// TODO: create single func
// typedef DLL_FUNCTIONS *(*GetEntityAPI)( enginefuncs_t* engfuncs, globalvars_t *pGlobals );
// set pointer to globals, returns export of dll_functions and use CreateAPI as base offset
typedef void (*GIVEFNPTRSTODLL)( enginefuncs_t* engfuncs, globalvars_t *pGlobals );
typedef int (*APIFUNCTION)( DLL_FUNCTIONS *pFunctionTable, int interfaceVersion );
typedef void (*LINK_ENTITY_FUNC)( entvars_t *pev );
#endif//SVGAME_API_H

204
public/svprog_def.h Normal file
View File

@ -0,0 +1,204 @@
//=======================================================================
// Copyright XashXT Group 2008 ©
// svprog_def.h - engine <-> svgame communications
//=======================================================================
#ifndef SVDEFS_API_H
#define SVDEFS_API_H
typedef struct ed_priv_s ed_priv_t; // engine private data
typedef struct edict_s edict_t;
typedef struct globalvars_s
{
float time;
float frametime;
string_t mapname;
string_t startspot;
vec3_t spotOffset; // landmark offset
bool deathmatch;
bool coop;
bool teamplay;
int serverflags;
int maxClients;
int numClients; // actual clients count
int maxEntities;
int numEntities; // actual ents count
vec3_t v_forward;
vec3_t v_right;
vec3_t v_up;
bool trace_allsolid;
bool trace_startsolid;
bool trace_startstuck;
float trace_fraction;
vec3_t trace_endpos;
vec3_t trace_plane_normal;
float trace_plane_dist;
int trace_start_contents;
int trace_contents;
int trace_hitgroup;
const char *trace_texture; // texture name that we hitting (brushes and studiomodels)
edict_t *trace_ent;
int total_secrets;
int found_secrets; // number of secrets found
int total_monsters;
int killed_monsters; // number of monsters killed
const char *pStringBase; // stringtable base offset
void *pSaveData; // savedata base offset
} globalvars_t;
// NOT FINALIZED!
typedef struct entvars_s
{
string_t classname;
string_t globalname;
edict_t *chain; // entity pointer when linked into a linked list
vec3_t origin;
vec3_t angles; // model angles
int modelindex;
vec3_t oldorigin; // interpolated values
vec3_t oldangles;
vec3_t m_pmatrix[3]; // rotational matrix
vec3_t m_pcentre[3]; // physical centre of mass
vec3_t velocity;
vec3_t avelocity; // angle velocity (degrees per second)
vec3_t basevelocity;
vec3_t movedir;
vec3_t force; // linear physical impulse vector
vec3_t torque; // angular physical impulse vector
string_t model;
string_t weaponmodel; // monster or player weaponmodel
vec3_t absmin; // bbox max translated to world coord
vec3_t absmax; // bbox max translated to world coord
vec3_t mins; // local bbox min
vec3_t maxs; // local bbox max
vec3_t size; // maxs - mins
float mass; // physobject mass
float ltime;
float nextthink;
int movetype;
int solid;
int skin; //
int body; // sub-model selection for studiomodels
int effects;
float gravity; // % of "normal" gravity
float friction; // inverse elasticity of MOVETYPE_BOUNCE
int sequence; // animation sequence
float frame; // % playback position in animation sequences (0..255)
float animtime; // world time when frame was set
float framerate; // animation playback rate (-8x to 8x)
float controller[16]; // bone controller setting (0..255)
float blending[16]; // blending amount between sub-sequences (0..255)
float scale; // model rendering scale (0..255)
int waterlevel;
int watertype;
int contents;
float idealpitch;
float pitch_speed;
float ideal_yaw;
float yaw_speed;
int rendermode;
float renderamt;
vec3_t rendercolor;
int renderfx;
float health;
float frags;
int weapons; // bit mask for available weapons
float takedamage;
int deadflag;
vec3_t view_ofs; // eye position
int button;
int impulse;
edict_t *dmg_inflictor;
edict_t *enemy;
edict_t *aiment; // entity pointer when MOVETYPE_FOLLOW
edict_t *owner;
edict_t *groundentity;
int spawnflags; // spwanflags are used only during level loading
int aiflags; // monsters and player flags
int phflags; // physic state flags
int flags; // generic flags that can be send to client
// player specific only
vec3_t punchangle; // auto-decaying view angle adjustment
vec3_t v_angle; // viewing angle (player only)
int fixangle; // 0 - nothing, 1 - force view angles, 2 - add avelocity
string_t viewmodel; // player's viewmodel
float weaponframe; // viewmodel frame
int weaponsequence;
int weaponbody; // viewmodel body
int weaponskin; // viewmodel skin
int gaitsequence; // movement animation sequence for player (0 for none)
short colormap; // lowbyte topcolor, highbyte bottomcolor
int playerclass;
int team; // for teamplay
int weaponanim;
float max_health;
float teleport_time;
int armortype;
float armorvalue;
string_t target;
string_t targetname;
string_t netname;
string_t message;
float dmg_take;
float dmg_save;
float dmgtime;
float dmg;
string_t noise;
string_t noise1;
string_t noise2;
string_t noise3;
string_t ambient;
float speed;
float air_finished;
float pain_finished;
float radsuit_finished;
edict_t *pContainingEntity; // ptr to class for consistency
} entvars_t;
// FIXME: make pvEngineData as generic ptr for both types (client and server are valid, entvars are shared)
struct edict_s
{
bool free;
float freetime; // sv.time when the object was freed
int serialnumber;
ed_priv_t *pvEngineData; // alloced, freed and used by engine only
void *pvServerData; // alloced and freed by engine, used by DLLs
entvars_t v; // C exported fields from progs (network relative)
// other fields from progs come immediately after
};
#endif//SVDEFS_API_H

View File

@ -1,11 +0,0 @@
//=======================================================================
// Copyright XashXT Group 2007 ©
// mathlib.h - base math functions
//=======================================================================
#ifndef VECTOR_LIB_H
#define VECTOR_LIB_H
#include "mathlib.h" //FIXME
#endif//VECTOR_LIB_H

View File

@ -32,21 +32,19 @@ enum
};
typedef void (*prvm_builtin_t)( void );
typedef struct edict_state_s
typedef struct vm_edict_s
{
bool free;
float freetime;
} vm_edict_t;
struct edict_s
struct pr_edict_s
{
// engine-private fields (stored in dynamically resized array)
union
{
void *vp; // generic edict
vm_edict_t *ed; // vm edict state
sv_edict_t *sv; // sv edict state
cl_edict_t *cl; // cl edict state
vm_edict_t *ui; // ui edict state
} priv;
@ -55,7 +53,6 @@ struct edict_s
union
{
void *vp; // generic entvars
sv_entvars_t *sv; // server entvars
cl_entvars_t *cl; // client entvars
ui_entvars_t *ui; // uimenu entvars
} progs;
@ -107,7 +104,6 @@ typedef struct prvm_prog_s
union
{
float *gp;
sv_globalvars_t *sv;
cl_globalvars_t *cl;
ui_globalvars_t *ui;
} globals;
@ -138,7 +134,7 @@ typedef struct prvm_prog_s
int max_edicts;
int limit_edicts;
int reserved_edicts;
edict_t *edicts;
pr_edict_t *edicts;
void *edictsfields;
void *edictprivate;
int edictprivate_size;
@ -154,12 +150,12 @@ typedef struct prvm_prog_s
// function pointers
void (*begin_increase_edicts)(void);
void (*end_increase_edicts)(void);
void (*init_edict)(edict_t *edict);
void (*free_edict)(edict_t *ed);
void (*init_edict)(pr_edict_t *edict);
void (*free_edict)(pr_edict_t *ed);
void (*count_edicts)(void);
bool (*load_edict)(edict_t *ent); // initialize edict for first loading
void (*restore_edict)(edict_t *ent); // restore edict from savegame or changelevel
void (*keyvalue_edict)(edict_t *ent, const char *key, const char *value ); // KeyValueData
bool (*load_edict)(pr_edict_t *ent); // initialize edict for first loading
void (*restore_edict)(pr_edict_t *ent); // restore edict from savegame or changelevel
void (*keyvalue_edict)(pr_edict_t *ent, const char *key, const char *value );
void (*init_cmd)(void);
void (*reset_cmd)(void);
void (*error_cmd)(const char *format, ...);
@ -180,14 +176,14 @@ typedef struct vprogs_exp_s
void ( *Update )( dword time ); // refreshing compile, exec some programs e.t.c
// edict operations
edict_t *(*AllocEdict)( void );
void (*FreeEdict)( edict_t *ed );
void (*PrintEdict)( edict_t *ed );
pr_edict_t *(*AllocEdict)( void );
void (*FreeEdict)( pr_edict_t *ed );
void (*PrintEdict)( pr_edict_t *ed );
// savegame stuff
void (*WriteGlobals)( void *buffer, void *ptr, setpair_t callback );
void (*ReadGlobals)( int s_table, dkeyvalue_t *globals, int count );
void (*WriteEdict)( edict_t *ed, void *buffer, void *ptr, setpair_t callback );
void (*WriteEdict)( pr_edict_t *ed, void *buffer, void *ptr, setpair_t callback );
void (*ReadEdict)( int s_table, int ednum, dkeyvalue_t *fields, int numpairs );
// load ents description

View File

@ -5,33 +5,9 @@
#ifndef VSOUND_API_H
#define VSOUND_API_H
// sound channels
typedef enum
{
CHAN_AUTO = 0,
CHAN_WEAPON,
CHAN_VOICE,
CHAN_ITEM,
CHAN_BODY,
CHAN_ANNOUNCER, // announcer
// snd flags
CHAN_NO_PHS_ADD = 8, // send to all clients, not just ones in PHS (ATTN 0 will also do this)
CHAN_RELIABLE = 16, // send by reliable message, not datagram
} snd_channel_t;
// sound attenuation values
typedef enum
{
ATTN_NONE = 0, // full volume the entire level
ATTN_NORM,
ATTN_IDLE,
ATTN_STATIC, // diminish very rapidly with distance
} snd_attenuation_t;
#define PITCH_LOW 95 // other values are possible - 0-255, where 255 is very high
#define PITCH_NORM 100 // non-pitch shifted
#define PITCH_HIGH 120
// snd internal flags (lower bits are used for snd channels)
#define CHAN_NO_PHS_ADD (1<<3) // send to all clients, not just ones in PHS (ATTN 0 will also do this)
#define CHAN_RELIABLE (1<<4) // send by reliable message, not datagram
/*
==============================================================================

View File

@ -5,7 +5,7 @@
#include "r_local.h"
#include "byteorder.h"
#include "vector_lib.h"
#include "mathlib.h"
#include "const.h"
static rgbdata_t *R_LoadImage( script_t *script, const char *name, const byte *buf, size_t size, int *samples, texFlags_t *flags );

View File

@ -91,7 +91,7 @@ BSC32=bscmake.exe
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /debug /machine:I386
# ADD LINK32 msvcrtd.lib user32.lib gdi32.lib /nologo /subsystem:windows /dll /debug /machine:I386 /nodefaultlib:"msvcrt.lib" /pdbtype:sept /libpath:"../public/libs/"
# ADD LINK32 msvcrtd.lib user32.lib gdi32.lib /nologo /subsystem:windows /dll /debug /machine:I386 /nodefaultlib:"msvcrt.lib" /pdbtype:sept
# SUBTRACT LINK32 /profile /incremental:no /map
# Begin Custom Build
TargetDir=\Xash3D\src_main\temp\render\!debug

38
sv_dll/cbase.h Normal file
View File

@ -0,0 +1,38 @@
//=======================================================================
// Copyright (C) XashXT Group 2006
// stdafx.h
//=======================================================================
#ifndef CBASE_H
#define CBASE_H
class CBaseEntity;
class CBaseLogic;
class CBaseBrush;
class CBaseAnimating;
class CBaseMonster;
class CBasePlayerWeapon;
class CSquadMonster;
class CBaseMonster;
class CCineMonster;
class CBasePlayer;
class CSound;
#include "hierarchy.h"
#include "globals.h"
#include "utils.h"
#include "saverestore.h"
#include "schedule.h"
#include "qfiles_ref.h"
#include "defaults.h"
#include "monsterevent.h"
#include "baseentity.h"
#include "baselogic.h"
#include "basesprite.h"
#include "baseinfo.h"
#include "baseanimating.h"
#include "baseitem.h"
#include "basebrush.h"
#include "basemonster.h"
#include "baseworld.h"
#endif //CBASE_H

0
sv_dll/legacy.cpp Normal file
View File

5
sv_dll/server.def Normal file
View File

@ -0,0 +1,5 @@
LIBRARY server
EXPORTS
GiveFnptrsToDll @1
SECTIONS
.data READ WRITE

572
sv_dll/server.dsp Normal file
View File

@ -0,0 +1,572 @@
# Microsoft Developer Studio Project File - Name="server" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 6.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
CFG=server - Win32 Release
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
!MESSAGE use the Export Makefile command and run
!MESSAGE
!MESSAGE NMAKE /f "server.mak".
!MESSAGE
!MESSAGE You can specify a configuration when running NMAKE
!MESSAGE by defining the macro CFG on the command line. For example:
!MESSAGE
!MESSAGE NMAKE /f "server.mak" CFG="server - Win32 Release"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "server - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
!MESSAGE "server - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
!MESSAGE
# Begin Project
# PROP AllowPerConfigDependencies 0
# PROP Scc_ProjName ""$/GoldSrc/server", ELEBAAAA"
# PROP Scc_LocalPath "."
CPP=cl.exe
MTL=midl.exe
RSC=rc.exe
!IF "$(CFG)" == "server - Win32 Release"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir ".\Release"
# PROP BASE Intermediate_Dir ".\Release"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "..\temp\server\!release"
# PROP Intermediate_Dir "..\temp\server\!release"
# PROP Ignore_Export_Lib 1
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /YX /c
# ADD CPP /nologo /GB /MD /W3 /O2 /I "./" /I "./ents" /I "./game" /I "./global" /I "./monsters" /I "../public" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /FD /c
# SUBTRACT CPP /Fr /YX
# ADD BASE MTL /nologo /D "NDEBUG" /win32
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x409 /d "NDEBUG"
# ADD RSC /l 0x409 /d "NDEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /machine:I386
# ADD LINK32 msvcrt.lib /nologo /subsystem:windows /dll /pdb:none /machine:I386 /nodefaultlib:"libc.lib" /def:".\server.def" /libpath:"..\common\libs"
# SUBTRACT LINK32 /profile /map /debug /nodefaultlib
# Begin Custom Build - Performing Custom Build Step on $(InputPath)
TargetDir=\Xash3D\src_main\temp\server\!release
InputPath=\Xash3D\src_main\temp\server\!release\server.dll
SOURCE="$(InputPath)"
"D:\Xash3D\xash\bin\server.dll" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
copy $(TargetDir)\server.dll "D:\Xash3D\xash\bin\server.dll"
# End Custom Build
!ELSEIF "$(CFG)" == "server - Win32 Debug"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "server___Win32_Debug"
# PROP BASE Intermediate_Dir "server___Win32_Debug"
# PROP BASE Ignore_Export_Lib 1
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "..\temp\server\!debug"
# PROP Intermediate_Dir "..\temp\server\!debug"
# PROP Ignore_Export_Lib 1
# PROP Target_Dir ""
# ADD BASE CPP /nologo /G5 /MT /W3 /O2 /I "..\server" /I "..\common\engine" /I "..\common" /I "..\server\ents" /I "..\server\global" /I "..\server\weapons" /I "..\server\game" /I "..\server\monsters" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /YX /FD /c
# SUBTRACT BASE CPP /Fr
# ADD CPP /nologo /GB /MDd /W3 /Gm /Gi /GX /ZI /Od /I "./" /I "./ents" /I "./game" /I "./global" /I "./monsters" /I "../public" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /FR /FD /c
# SUBTRACT CPP /u /YX
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x409 /d "NDEBUG"
# ADD RSC /l 0x409 /d "NDEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /subsystem:windows /dll /incremental:yes /machine:I386 /nodefaultlib:"libc" /def:".\server.def" /libpath:"..\common\libs"
# SUBTRACT BASE LINK32 /profile /map /debug
# ADD LINK32 msvcrtd.lib /nologo /subsystem:windows /dll /incremental:yes /debug /machine:I386 /nodefaultlib:"libc.lib" /def:".\server.def" /pdbtype:sept
# SUBTRACT LINK32 /profile /map
# Begin Custom Build - Performing Custom Build Step on $(InputPath)
TargetDir=\Xash3D\src_main\temp\server\!debug
InputPath=\Xash3D\src_main\temp\server\!debug\server.dll
SOURCE="$(InputPath)"
"D:\Xash3D\xash\bin\server.dll" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
copy $(TargetDir)\server.dll "D:\Xash3D\xash\bin\server.dll"
# End Custom Build
!ENDIF
# Begin Target
# Name "server - Win32 Release"
# Name "server - Win32 Debug"
# Begin Group "Source Files"
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat;for;f90"
# Begin Source File
SOURCE=.\monsters\ai_sound.cpp
# End Source File
# Begin Source File
SOURCE=.\monsters\animating.cpp
# End Source File
# Begin Source File
SOURCE=.\monsters\animation.cpp
# End Source File
# Begin Source File
SOURCE=.\monsters\apache.cpp
# End Source File
# Begin Source File
SOURCE=.\monsters\barnacle.cpp
# End Source File
# Begin Source File
SOURCE=.\monsters\barney.cpp
# End Source File
# Begin Source File
SOURCE=.\ents\basebrush.cpp
# End Source File
# Begin Source File
SOURCE=.\ents\baseentity.cpp
# End Source File
# Begin Source File
SOURCE=.\ents\basefunc.cpp
# End Source File
# Begin Source File
SOURCE=.\ents\basefx.cpp
# End Source File
# Begin Source File
SOURCE=.\ents\baseinfo.cpp
# End Source File
# Begin Source File
SOURCE=.\ents\baseitem.cpp
# End Source File
# Begin Source File
SOURCE=.\ents\baselogic.cpp
# End Source File
# Begin Source File
SOURCE=.\monsters\basemonster.cpp
# End Source File
# Begin Source File
SOURCE=.\ents\basemover.cpp
# End Source File
# Begin Source File
SOURCE=.\ents\baseother.cpp
# End Source File
# Begin Source File
SOURCE=.\ents\basepath.cpp
# End Source File
# Begin Source File
SOURCE=.\ents\baserockets.cpp
# End Source File
# Begin Source File
SOURCE=.\ents\basetank.cpp
# End Source File
# Begin Source File
SOURCE=.\ents\basetrigger.cpp
# End Source File
# Begin Source File
SOURCE=.\ents\baseutil.cpp
# End Source File
# Begin Source File
SOURCE=.\ents\baseweapon.cpp
# End Source File
# Begin Source File
SOURCE=.\ents\baseworld.cpp
# End Source File
# Begin Source File
SOURCE=.\global\client.cpp
# End Source File
# Begin Source File
SOURCE=.\monsters\combat.cpp
# End Source File
# Begin Source File
SOURCE=.\global\decals.cpp
# End Source File
# Begin Source File
SOURCE=.\monsters\defaultai.cpp
# End Source File
# Begin Source File
SOURCE=.\global\dll_int.cpp
# End Source File
# Begin Source File
SOURCE=.\monsters\flyingmonster.cpp
# End Source File
# Begin Source File
SOURCE=.\game\game.cpp
# End Source File
# Begin Source File
SOURCE=.\game\gamerules.cpp
# End Source File
# Begin Source File
SOURCE=.\monsters\generic.cpp
# End Source File
# Begin Source File
SOURCE=.\global\globals.cpp
# End Source File
# Begin Source File
SOURCE=.\monsters\gman.cpp
# End Source File
# Begin Source File
SOURCE=.\monsters\hassassin.cpp
# End Source File
# Begin Source File
SOURCE=.\monsters\headcrab.cpp
# End Source File
# Begin Source File
SOURCE=.\monsters\hgrunt.cpp
# End Source File
# Begin Source File
SOURCE=.\monsters\leech.cpp
# End Source File
# Begin Source File
SOURCE=.\legacy.cpp
# End Source File
# Begin Source File
SOURCE=.\game\lights.cpp
# End Source File
# Begin Source File
SOURCE=.\game\multiplay_gamerules.cpp
# End Source File
# Begin Source File
SOURCE=.\monsters\nodes.cpp
# End Source File
# Begin Source File
SOURCE=.\monsters\osprey.cpp
# End Source File
# Begin Source File
SOURCE=.\global\parent.cpp
# End Source File
# Begin Source File
SOURCE=.\monsters\player.cpp
# End Source File
# Begin Source File
SOURCE=.\monsters\rat.cpp
# End Source File
# Begin Source File
SOURCE=.\monsters\roach.cpp
# End Source File
# Begin Source File
SOURCE=.\global\saverestore.cpp
# End Source File
# Begin Source File
SOURCE=.\monsters\scientist.cpp
# End Source File
# Begin Source File
SOURCE=.\monsters\scripted.cpp
# End Source File
# Begin Source File
SOURCE=.\global\sfx.cpp
# End Source File
# Begin Source File
SOURCE=.\game\singleplay_gamerules.cpp
# End Source File
# Begin Source File
SOURCE=.\game\sound.cpp
# End Source File
# Begin Source File
SOURCE=.\monsters\squadmonster.cpp
# End Source File
# Begin Source File
SOURCE=.\monsters\talkmonster.cpp
# End Source File
# Begin Source File
SOURCE=.\game\teamplay_gamerules.cpp
# End Source File
# Begin Source File
SOURCE=.\monsters\turret.cpp
# End Source File
# Begin Source File
SOURCE=.\global\utils.cpp
# End Source File
# Begin Source File
SOURCE=.\weapon_generic.cpp
# End Source File
# Begin Source File
SOURCE=.\monsters\zombie.cpp
# End Source File
# End Group
# Begin Group "Header Files"
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;cnt;rtf;gif;jpg;jpeg;jpe"
# Begin Source File
SOURCE=.\monsters\activity.h
# End Source File
# Begin Source File
SOURCE=.\monsters\activitymap.h
# End Source File
# Begin Source File
SOURCE=.\monsters\animation.h
# End Source File
# Begin Source File
SOURCE=.\monsters\baseanimating.h
# End Source File
# Begin Source File
SOURCE=.\ents\basebeams.h
# End Source File
# Begin Source File
SOURCE=.\ents\basebrush.h
# End Source File
# Begin Source File
SOURCE=.\ents\baseentity.h
# End Source File
# Begin Source File
SOURCE=.\ents\baseinfo.h
# End Source File
# Begin Source File
SOURCE=.\ents\baseitem.h
# End Source File
# Begin Source File
SOURCE=.\ents\baselogic.h
# End Source File
# Begin Source File
SOURCE=.\monsters\basemonster.h
# End Source File
# Begin Source File
SOURCE=.\ents\basemover.h
# End Source File
# Begin Source File
SOURCE=.\ents\baserockets.h
# End Source File
# Begin Source File
SOURCE=.\ents\basesprite.h
# End Source File
# Begin Source File
SOURCE=.\ents\basetank.h
# End Source File
# Begin Source File
SOURCE=.\ents\baseweapon.h
# End Source File
# Begin Source File
SOURCE=.\ents\baseworld.h
# End Source File
# Begin Source File
SOURCE=.\global\bullets.h
# End Source File
# Begin Source File
SOURCE=.\cbase.h
# End Source File
# Begin Source File
SOURCE=.\global\cdll_dll.h
# End Source File
# Begin Source File
SOURCE=.\global\client.h
# End Source File
# Begin Source File
SOURCE=.\monsters\damage.h
# End Source File
# Begin Source File
SOURCE=.\global\decals.h
# End Source File
# Begin Source File
SOURCE=.\monsters\defaultai.h
# End Source File
# Begin Source File
SOURCE=.\global\defaults.h
# End Source File
# Begin Source File
SOURCE=.\global\enginecallback.h
# End Source File
# Begin Source File
SOURCE=.\global\extdll.h
# End Source File
# Begin Source File
SOURCE=.\monsters\flyingmonster.h
# End Source File
# Begin Source File
SOURCE=.\game\game.h
# End Source File
# Begin Source File
SOURCE=.\game\gamerules.h
# End Source File
# Begin Source File
SOURCE=.\global\globals.h
# End Source File
# Begin Source File
SOURCE=.\global\hierarchy.h
# End Source File
# Begin Source File
SOURCE=.\monsters\monsterevent.h
# End Source File
# Begin Source File
SOURCE=.\monsters\monsters.h
# End Source File
# Begin Source File
SOURCE=.\monsters\nodes.h
# End Source File
# Begin Source File
SOURCE=.\global\plane.h
# End Source File
# Begin Source File
SOURCE=.\monsters\player.h
# End Source File
# Begin Source File
SOURCE=.\global\saverestore.h
# End Source File
# Begin Source File
SOURCE=.\monsters\schedule.h
# End Source File
# Begin Source File
SOURCE=.\monsters\scripted.h
# End Source File
# Begin Source File
SOURCE=.\monsters\scriptevent.h
# End Source File
# Begin Source File
SOURCE=.\global\sfx.h
# End Source File
# Begin Source File
SOURCE=.\global\shake.h
# End Source File
# Begin Source File
SOURCE=.\global\soundent.h
# End Source File
# Begin Source File
SOURCE=.\game\spectator.h
# End Source File
# Begin Source File
SOURCE=.\monsters\squad.h
# End Source File
# Begin Source File
SOURCE=.\monsters\squadmonster.h
# End Source File
# Begin Source File
SOURCE=.\monsters\talkmonster.h
# End Source File
# Begin Source File
SOURCE=.\global\te_temp.h
# End Source File
# Begin Source File
SOURCE=.\game\teamplay_gamerules.h
# End Source File
# Begin Source File
SOURCE=.\global\utils.h
# End Source File
# Begin Source File
SOURCE=.\global\vector.h
# End Source File
# End Group
# End Target
# End Project

16
sv_dll/server.plg Normal file
View File

@ -0,0 +1,16 @@
<html>
<body>
<pre>
<h1>Build Log</h1>
<h3>
--------------------Configuration: server - Win32 Debug--------------------
</h3>
<h3>Command Lines</h3>
<h3>Results</h3>
server.dll - 0 error(s), 0 warning(s)
</pre>
</body>
</html>

68
sv_dll/weapon_generic.cpp Normal file
View File

@ -0,0 +1,68 @@
//=======================================================================
// Copyright (C) Shambler Team 2006
// weapons.cpp - player weapon baseclass
//=======================================================================
#include "extdll.h"
#include "utils.h"
#include "cbase.h"
#include "baseweapon.h"
LINK_ENTITY_TO_CLASS( weapon_m249, CBasePlayerWeapon );
LINK_ENTITY_TO_CLASS( weapon_crossbow, CBasePlayerWeapon );
LINK_ENTITY_TO_CLASS( weapon_crowbar, CBasePlayerWeapon );
LINK_ENTITY_TO_CLASS( weapon_redeemer, CBasePlayerWeapon );
LINK_ENTITY_TO_CLASS( weapon_eagle, CBasePlayerWeapon );
LINK_ENTITY_TO_CLASS( weapon_glock, CBasePlayerWeapon );
LINK_ENTITY_TO_CLASS( weapon_mp5, CBasePlayerWeapon );
LINK_ENTITY_TO_CLASS( weapon_shotgun, CBasePlayerWeapon );
LINK_ENTITY_TO_CLASS( weapon_m40a1, CBasePlayerWeapon );
LINK_ENTITY_TO_CLASS( weapon_handgrenade, CBasePlayerWeapon );
LINK_ENTITY_TO_CLASS( weapon_debug, CBasePlayerWeapon );
LINK_ENTITY_TO_CLASS( weapon_rpg, CBasePlayerWeapon );
//***********************************************************
// world_items
//***********************************************************
class CWorldItem : public CBaseEntity
{
public:
void KeyValue(KeyValueData *pkvd );
void Spawn( void );
};
LINK_ENTITY_TO_CLASS(world_items, CWorldItem);
void CWorldItem::KeyValue(KeyValueData *pkvd)
{
if (FStrEq(pkvd->szKeyName, "type"))
{
pev->impulse = atoi(pkvd->szValue);
pkvd->fHandled = TRUE;
}
else CBaseEntity::KeyValue( pkvd );
}
void CWorldItem::Spawn( void )
{
CBaseEntity *pEntity = NULL;
switch (pev->impulse)
{
case 44: //ITEM_BATTERY:
pEntity = CBaseEntity::Create( "item_battery", pev->origin, pev->angles );
break;
case 45: //ITEM_SUIT:
pEntity = CBaseEntity::Create( "item_suit", pev->origin, pev->angles );
break;
}
if (!pEntity) Msg( "unable to create world_item %d\n", pev->impulse );
else
{
pEntity->pev->target = pev->target;
pEntity->pev->targetname = pev->targetname;
pEntity->pev->spawnflags = pev->spawnflags;
}
REMOVE_ENTITY(edict());
}

View File

@ -18,7 +18,11 @@ fopen
Beta 13.12.08
0. èìïëåìåíòàöèÿ server.dll, client.dll
0. подключить sv_dll к проекту
entity_state_t невидима для пользователя
edict_t - существует только на сервере

View File

@ -11,7 +11,7 @@ sizebuf_t vm_tempstringsbuf;
int prvm_type_size[8] = {1, sizeof(string_t)/4,1,3,1,1, sizeof(func_t)/4, sizeof(void *)/4};
ddef_t *PRVM_ED_FieldAtOfs(int ofs);
bool PRVM_ED_ParseEpair(edict_t *ent, ddef_t *key, const char *s);
bool PRVM_ED_ParseEpair(pr_edict_t *ent, ddef_t *key, const char *s);
//============================================================================
// mempool handling
@ -34,7 +34,7 @@ void PRVM_MEM_Alloc(void)
vm.prog->edictprivate_size = max(vm.prog->edictprivate_size, (int)sizeof(vm_edict_t));
// alloc edicts
vm.prog->edicts = (edict_t *)Mem_Alloc(vm.prog->progs_mempool, vm.prog->limit_edicts * sizeof(edict_t));
vm.prog->edicts = (pr_edict_t *)Mem_Alloc(vm.prog->progs_mempool, vm.prog->limit_edicts * sizeof(pr_edict_t));
// alloc edict private space
vm.prog->edictprivate = Mem_Alloc(vm.prog->progs_mempool, vm.prog->max_edicts * vm.prog->edictprivate_size);
@ -177,7 +177,7 @@ PRVM_ED_ClearEdict
Sets everything to NULL
=================
*/
void PRVM_ED_ClearEdict (edict_t *e)
void PRVM_ED_ClearEdict (pr_edict_t *e)
{
Mem_Set (e->progs.vp, 0, vm.prog->progs->entityfields * 4);
e->priv.ed->free = false;
@ -197,10 +197,10 @@ instead of being removed and recreated, which can cause interpolated
angles and bad trails.
=================
*/
edict_t *PRVM_ED_Alloc (void)
pr_edict_t *PRVM_ED_Alloc (void)
{
int i;
edict_t *e;
pr_edict_t *e;
// the client qc dont need maxclients
// thus it doesnt need to use svs.maxclients
@ -240,7 +240,7 @@ Marks the edict as free
FIXME: walk all entities and NULL out references to this entity
=================
*/
void PRVM_ED_Free (edict_t *ed)
void PRVM_ED_Free (pr_edict_t *ed)
{
// dont delete the null entity (world) or reserved edicts
if(PRVM_NUM_FOR_EDICT(ed) <= vm.prog->reserved_edicts )
@ -546,7 +546,7 @@ For debugging
*/
// LordHavoc: optimized this to print out much more quickly (tempstring)
// LordHavoc: changed to print out every 4096 characters (incase there are a lot of fields to print)
void PRVM_ED_Print(edict_t *ed)
void PRVM_ED_Print(pr_edict_t *ed)
{
size_t l;
ddef_t *d;
@ -620,7 +620,7 @@ PRVM_ED_Write
For savegames
=============
*/
void PRVM_ED_Write( edict_t *ed, void *buffer, void *numpairs, setpair_t callback )
void PRVM_ED_Write( pr_edict_t *ed, void *buffer, void *numpairs, setpair_t callback )
{
ddef_t *d;
int *v;
@ -666,7 +666,7 @@ void PRVM_ED_Read( int s_table, int entnum, dkeyvalue_t *fields, int numpairs )
{
const char *keyname, *value;
ddef_t *key;
edict_t *ent;
pr_edict_t *ent;
int i;
if( entnum >= vm.prog->limit_edicts ) Host_Error( "PRVM_ED_Read: too many edicts in save file\n" );
@ -777,7 +777,7 @@ For debugging
void PRVM_ED_Count_f( void )
{
int i;
edict_t *ent;
pr_edict_t *ent;
int active;
if(Cmd_Argc() != 2)
@ -883,7 +883,7 @@ Can parse either fields or globals
returns false if error
=============
*/
bool PRVM_ED_ParseEpair( edict_t *ent, ddef_t *key, const char *s )
bool PRVM_ED_ParseEpair( pr_edict_t *ent, ddef_t *key, const char *s )
{
int i, l;
char *new_p;
@ -976,7 +976,7 @@ Console command to set a field of a specified edict
*/
void PRVM_ED_EdictSet_f(void)
{
edict_t *ed;
pr_edict_t *ed;
ddef_t *key;
if(Cmd_Argc() != 5)
@ -1010,7 +1010,7 @@ ed should be a properly initialized empty edict.
Used for initial level load and for savegames.
====================
*/
const char *PRVM_ED_ParseEdict( const char *data, edict_t *ent )
const char *PRVM_ED_ParseEdict( const char *data, pr_edict_t *ent )
{
ddef_t *key;
bool init, newline, anglehack;
@ -1113,7 +1113,7 @@ to call PRVM_ED_CallSpawnFunctions () to let the objects initialize themselves.
*/
void PRVM_ED_LoadFromFile( const char *data )
{
edict_t *ent;
pr_edict_t *ent;
int parsed, inhibited, spawned, died;
mfunction_t *func;
@ -1421,7 +1421,7 @@ void PRVM_LoadProgs( const char *filename )
((int *)vm.prog->globals.gp)[i] = LittleLong (((int *)vm.prog->globals.gp)[i]);
// moved edict_size calculation down here, below field adding code
// LordHavoc: this no longer includes the edict_t header
// LordHavoc: this no longer includes the pr_edict_t header
vm.prog->edict_size = vm.prog->progs->entityfields * 4;
vm.prog->edictareasize = vm.prog->edict_size * vm.prog->limit_edicts;
@ -1602,7 +1602,7 @@ void PRVM_Fields_f (void)
int *counts;
char tempstring[MAX_MSGLEN], tempstring2[260];
const char *name;
edict_t *ed;
pr_edict_t *ed;
ddef_t *d;
int *v;
@ -1876,7 +1876,7 @@ void _PRVM_FreeAll(const char *filename, int fileline)
}
// LordHavoc: turned PRVM_EDICT_NUM into a #define for speed reasons
edict_t *PRVM_EDICT_NUM_ERROR(int n, char *filename, int fileline)
pr_edict_t *PRVM_EDICT_NUM_ERROR(int n, char *filename, int fileline)
{
PRVM_ERROR ("PRVM_EDICT_NUM: %s: bad number %i (called at %s:%i)", PRVM_NAME, n, filename, fileline);
return NULL;

View File

@ -539,7 +539,7 @@ void PRVM_ExecuteProgram( func_t fnum, const char *name, const char *file, const
{
dstatement_t *st, *startst;
mfunction_t *f, *newf;
edict_t *ed;
pr_edict_t *ed;
prvm_eval_t *ptr, *_switch;
int switchtype, exitdepth;
int i, jumpcount, cachedpr_trace;

View File

@ -54,7 +54,8 @@ BSC32=bscmake.exe
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 /opt:nowin98
# ADD LINK32 msvcrt.lib /nologo /dll /profile /machine:I386 /nodefaultlib:"libc.lib" /opt:nowin98
# ADD LINK32 msvcrt.lib /nologo /dll /pdb:none /machine:I386 /nodefaultlib:"libc.lib" /opt:nowin98
# SUBTRACT LINK32 /profile
# Begin Custom Build
TargetDir=\Xash3D\src_main\temp\vprogs\!release
InputPath=\Xash3D\src_main\temp\vprogs\!release\vprogs.dll
@ -79,7 +80,7 @@ SOURCE="$(InputPath)"
# PROP Ignore_Export_Lib 1
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "PLATFORM_EXPORTS" /YX /FD /GZ /c
# ADD CPP /nologo /MDd /W3 /Gm /Gi /GX /ZI /I "./" /I "../public" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /FR /FD /GZ /c
# ADD CPP /nologo /MDd /W3 /Gm /Gi /GX /ZI /Od /I "./" /I "../public" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /FR /FD /GZ /c
# SUBTRACT CPP /YX
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32

View File

@ -359,25 +359,25 @@ func_t PRVM_ED_FindFunctionOffset(const char *function);
void PRVM_MEM_IncreaseEdicts(void);
edict_t *PRVM_ED_Alloc (void);
void PRVM_ED_Free (edict_t *ed);
void PRVM_ED_ClearEdict (edict_t *e);
pr_edict_t *PRVM_ED_Alloc (void);
void PRVM_ED_Free (pr_edict_t *ed);
void PRVM_ED_ClearEdict (pr_edict_t *e);
ddef_t *PRVM_ED_GlobalAtOfs( int ofs );
void PRVM_PrintFunctionStatements (const char *name);
void PRVM_ED_Print(edict_t *ed);
void PRVM_ED_Write( edict_t *ed, void *buffer, void *ptr, setpair_t callback );
void PRVM_ED_Print(pr_edict_t *ed);
void PRVM_ED_Write( pr_edict_t *ed, void *buffer, void *ptr, setpair_t callback );
void PRVM_ED_Read( int s_table, int ednum, dkeyvalue_t *fields, int numpairs );
const char *PRVM_ED_ParseEdict (const char *data, edict_t *ent);
const char *PRVM_ED_ParseEdict (const char *data, pr_edict_t *ent);
char *PRVM_ValueString( etype_t type, prvm_eval_t *val );
void PRVM_ED_WriteGlobals( void *buffer, void *ptr, setpair_t callback );
void PRVM_ED_ReadGlobals( int s_table, dkeyvalue_t *globals, int numpairs );
void PRVM_ED_LoadFromFile( const char *data );
edict_t *PRVM_EDICT_NUM_ERROR(int n, char *filename, int fileline);
pr_edict_t *PRVM_EDICT_NUM_ERROR(int n, char *filename, int fileline);
#define PRVM_EDICT_NUM(n) (((n) >= 0 && (n) < vm.prog->max_edicts) ? vm.prog->edicts + (n) : PRVM_EDICT_NUM_ERROR(n, __FILE__, __LINE__))
#define PRVM_EDICT_NUM_UNSIGNED(n) (((n) < vm.prog->max_edicts) ? vm.prog->edicts + (n) : PRVM_EDICT_NUM_ERROR(n, __FILE__, __LINE__))
#define PRVM_NUM_FOR_EDICT(e) ((int)((edict_t *)(e) - vm.prog->edicts))
#define PRVM_NUM_FOR_EDICT(e) ((int)((pr_edict_t *)(e) - vm.prog->edicts))
#define PRVM_NEXT_EDICT(e) ((e) + 1)
#define PRVM_EDICT_TO_PROG(e) (PRVM_NUM_FOR_EDICT(e))
#define PRVM_PROG_TO_EDICT(n) (PRVM_EDICT_NUM(n))

View File

@ -54,7 +54,8 @@ BSC32=bscmake.exe
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 /opt:nowin98
# ADD LINK32 libogg.lib vorbis.lib /nologo /dll /profile /machine:I386 /nodefaultlib:"libcmt.lib" /opt:nowin98
# ADD LINK32 libogg.lib vorbis.lib /nologo /dll /pdb:none /machine:I386 /nodefaultlib:"libcmt.lib" /opt:nowin98
# SUBTRACT LINK32 /profile
# Begin Custom Build
TargetDir=\Xash3D\src_main\temp\vsound\!release
InputPath=\Xash3D\src_main\temp\vsound\!release\vsound.dll
@ -79,7 +80,7 @@ SOURCE="$(InputPath)"
# PROP Ignore_Export_Lib 1
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "PLATFORM_EXPORTS" /YX /FD /GZ /c
# ADD CPP /nologo /MDd /W3 /Gm /Gi /GX /ZI /I "./" /I "../public" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /FR /FD /GZ /c
# ADD CPP /nologo /MDd /W3 /Gm /Gi /GX /ZI /Od /I "./" /I "../public" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /FR /FD /GZ /c
# SUBTRACT CPP /YX
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
@ -113,6 +114,10 @@ SOURCE="$(InputPath)"
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
# Begin Source File
SOURCE=.\s_export.c
# End Source File
# Begin Source File
SOURCE=.\s_load.c
# End Source File
# Begin Source File
@ -127,10 +132,6 @@ SOURCE=.\s_openal.c
SOURCE=.\s_stream.c
# End Source File
# Begin Source File
SOURCE=.\s_export.c
# End Source File
# End Group
# Begin Group "Header Files"

View File

@ -63,6 +63,18 @@ Package=<4>
###############################################################################
Project: "server"=".\sv_dll\server.dsp" - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
}}}
###############################################################################
Project: "render"=".\render\render.dsp" - Package Owner=<4>
Package=<5>