From aa3d4df98c34c238a24dc7aa6466a98ae8e9dbe3 Mon Sep 17 00:00:00 2001 From: g-cont Date: Sat, 27 Dec 2008 00:00:00 +0300 Subject: [PATCH] 27 Dec 2008 --- client/client.plg | 16 - client/global/dll_int.cpp | 19 +- client/global/enginecallback.h | 1 + client/global/tempents.cpp | 74 +--- client/hud/hud.cpp | 14 +- client/hud/hud.h | 3 +- client/hud/hud_iface.h | 13 +- client/hud/hud_msg.cpp | 17 +- client/hud/hud_utils.cpp | 108 ++++++ debug.bat | 3 +- engine/client/cl_demo.c | 9 +- engine/client/cl_effects.c | 4 +- engine/client/cl_frame.c | 70 ++-- engine/client/cl_game.c | 225 +++++++---- engine/client/cl_input.c | 6 +- engine/client/cl_main.c | 8 +- engine/client/cl_parse.c | 11 +- engine/client/cl_progs.c | 96 ----- engine/client/cl_scrn.c | 69 +++- engine/client/cl_view.c | 22 +- engine/client/client.h | 74 ++-- engine/common.h | 8 - engine/common/engfuncs.c | 33 +- engine/common/net_msg.h | 4 +- engine/host.c | 2 +- engine/server/server.h | 59 +-- engine/server/sv_client.c | 81 ++-- engine/server/sv_cmds.c | 16 +- engine/server/sv_frame.c | 120 +++--- engine/server/sv_game.c | 548 +++++++++++++++------------ engine/server/sv_init.c | 21 +- engine/server/sv_main.c | 15 +- engine/server/sv_move.c | 24 +- engine/server/sv_phys.c | 190 +++++----- engine/server/sv_progs.c | 28 +- engine/server/sv_world.c | 18 +- public/clgame_api.h | 16 +- public/const.h | 34 +- public/entity_def.h | 22 +- public/render_api.h | 27 +- public/svgame_api.h | 1 - release.bat | 1 + render/gl_backend.c | 6 +- render/r_backend.h | 2 +- render/r_bloom.c | 20 +- render/r_draw.c | 16 +- render/r_image.c | 8 +- render/r_local.h | 8 +- render/r_main.c | 6 +- server/ents/baseentity.cpp | 2 +- server/ents/basefunc.cpp | 6 +- server/ents/basefx.cpp | 2 +- server/ents/baseinfo.cpp | 3 +- server/ents/baseitem.cpp | 8 +- server/ents/baseother.cpp | 3 +- server/ents/baserockets.cpp | 3 +- server/ents/baseweapon.cpp | 15 +- server/game/game.cpp | 2 + server/game/gamerules.cpp | 2 - server/game/multiplay_gamerules.cpp | 29 +- server/game/singleplay_gamerules.cpp | 3 - server/game/sound.cpp | 2 +- server/game/teamplay_gamerules.cpp | 23 +- server/global/client.cpp | 198 ++++------ server/global/client.h | 114 +++--- server/global/enginecallback.h | 3 +- server/global/sfx.cpp | 17 +- server/global/shake.h | 5 - server/global/utils.cpp | 38 +- server/global/utils.h | 7 +- server/monsters/apache.cpp | 21 +- server/monsters/barney.cpp | 26 +- server/monsters/basemonster.cpp | 21 +- server/monsters/combat.cpp | 3 +- server/monsters/hgrunt.cpp | 49 +-- server/monsters/nodes.cpp | 13 +- server/monsters/osprey.cpp | 21 +- server/monsters/player.cpp | 84 ++-- server/monsters/player.h | 8 +- server/monsters/turret.cpp | 5 +- todo.log | 10 +- 81 files changed, 1498 insertions(+), 1444 deletions(-) delete mode 100644 client/client.plg diff --git a/client/client.plg b/client/client.plg deleted file mode 100644 index 33666b63..00000000 --- a/client/client.plg +++ /dev/null @@ -1,16 +0,0 @@ - - -
-

Build Log

-

---------------------Configuration: client - Win32 Debug-------------------- -

-

Command Lines

- - - -

Results

-client.dll - 0 error(s), 0 warning(s) -
- - diff --git a/client/global/dll_int.cpp b/client/global/dll_int.cpp index 217cd332..de6ac20b 100644 --- a/client/global/dll_int.cpp +++ b/client/global/dll_int.cpp @@ -62,11 +62,22 @@ void HUD_Init( void ) gHUD.Init(); } -int HUD_Redraw( float flTime, int intermission ) +int HUD_Redraw( float flTime, int state ) { - gHUD.Redraw( flTime, intermission ); - DrawCrosshair(); - + switch( state ) + { + case CL_DISCONNECTED: + V_RenderSplash(); + break; + case CL_LOADING: + V_RenderPlaque(); + break; + case CL_ACTIVE: + gHUD.Redraw( flTime ); + DrawCrosshair(); + DrawPause(); + break; + } return 1; } diff --git a/client/global/enginecallback.h b/client/global/enginecallback.h index 460609f6..ba4b8f63 100644 --- a/client/global/enginecallback.h +++ b/client/global/enginecallback.h @@ -61,6 +61,7 @@ inline void CL_PlaySound( int iSound, float flVolume, Vector &pos ) #define GetClientTime (*g_engfuncs.pfnGetClientTime) #define GetMaxClients (*g_engfuncs.pfnGetMaxClients) #define GetViewModel (*g_engfuncs.pfnGetViewModel) +#define MAKE_LEVELSHOT (*g_engfuncs.pfnMakeLevelShot) #define POINT_CONTENTS (*g_engfuncs.pfnPointContents) #define TRACE_LINE (*g_engfuncs.pfnTraceLine) #define RANDOM_LONG (*g_engfuncs.pfnRandomLong) diff --git a/client/global/tempents.cpp b/client/global/tempents.cpp index 381271b6..557ffb66 100644 --- a/client/global/tempents.cpp +++ b/client/global/tempents.cpp @@ -10,92 +10,36 @@ void HUD_CreateEntities( void ) { } -//====================== -// DRAW BEAM EVENT -//====================== -void EV_DrawBeam( void ) -{ - // special effect for displacer - cl_entity_t *view = gEngfuncs.GetViewModel(); - - if( view != NULL ) - { - float life = 1.05; - int m_iBeam = gEngfuncs.pEventAPI->EV_FindModelIndex( "sprites/plasma.spr" ); - - gEngfuncs.pEfxAPI->R_BeamEnts(view->index | 0x1000, view->index | 0x2000, m_iBeam, life, 0.8, 0.5, 0.5, 0.6, 0, 10, 2, 10, 0); - gEngfuncs.pEfxAPI->R_BeamEnts(view->index | 0x1000, view->index | 0x3000, m_iBeam, life, 0.8, 0.5, 0.5, 0.6, 0, 10, 2, 10, 0); - gEngfuncs.pEfxAPI->R_BeamEnts(view->index | 0x1000, view->index | 0x4000, m_iBeam, life, 0.8, 0.5, 0.5, 0.6, 0, 10, 2, 10, 0); - } -} - -//====================== -// Eject Shell -//====================== -void EV_EjectShell( const dstudioevent_t *event, edict_t *entity ) -{ - vec3_t view_ofs, ShellOrigin, ShellVelocity, forward, right, up; - vec3_t origin = entity->origin; - vec3_t angles = entity->angles; - - float fR, fU; - - int shell = g_engfuncs.pEventAPI->EV_FindModelIndex (event->options); - g_engfuncs.pEventAPI->EV_LocalPlayerViewheight( view_ofs ); - origin.z = origin.z - view_ofs[2]; - - for(int j = 0; j < 3; j++ ) - { - if(angles[j] < -180) angles[j] += 360; - else if(angles[j] > 180) angles[j] -= 360; - } - angles.x = -angles.x; - AngleVectors( angles, forward, right, up ); - - fR = gEngfuncs.pfnRandomFloat( 50, 70 ); - fU = gEngfuncs.pfnRandomFloat( 100, 150 ); - - for (int i = 0; i < 3; i++ ) - { - ShellVelocity[i] = p_velocity[i] + right[i] * fR + up[i] * fU + forward[i] * 25; - ShellOrigin[i] = origin[i] + view_ofs[i] + up[i] * -12 + forward[i] * 20 + right[i] * 4; - } - EV_EjectBrass ( ShellOrigin, ShellVelocity, angles[ YAW ], shell, TE_BOUNCE_SHELL ); -} - void HUD_StudioEvent( const dstudioevent_t *event, edict_t *entity ) { switch( event->event ) { case 5001: - gEngfuncs.pEfxAPI->R_MuzzleFlash( (float *)&entity->attachment[0], atoi( event->options) ); + // MullzeFlash at attachment 0 break; case 5011: - gEngfuncs.pEfxAPI->R_MuzzleFlash( (float *)&entity->attachment[1], atoi( event->options) ); + // MullzeFlash at attachment 1 break; case 5021: - gEngfuncs.pEfxAPI->R_MuzzleFlash( (float *)&entity->attachment[2], atoi( event->options) ); + // MullzeFlash at attachment 2 break; case 5031: - gEngfuncs.pEfxAPI->R_MuzzleFlash( (float *)&entity->attachment[3], atoi( event->options) ); + // MullzeFlash at attachment 3 break; case 5002: - gEngfuncs.pEfxAPI->R_SparkEffect( (float *)&entity->attachment[0], atoi( event->options), -100, 100 ); + // SparkEffect at attachment 0 break; - // Client side sound case 5004: - gEngfuncs.pfnPlaySoundByNameAtLocation( (char *)event->options, 1.0, (float *)&entity->attachment[0] ); + // Client side sound break; - // Client side sound with random pitch case 5005: - gEngfuncs.pEventAPI->EV_PlaySound( entity->index, (float *)&entity->attachment[0], CHAN_WEAPON, (char *)event->options, gEngfuncs.pfnRandomFloat(0.7, 0.9), ATTN_NORM, 0, 85 + gEngfuncs.pfnRandomLong(0,0x1f) ); + // Client side sound with random pitch break; - // Special event for displacer case 5050: - EV_DrawBeam(); + // Special event for displacer break; case 5060: - EV_EjectShell( event, entity ); + // eject shellEV_EjectShell( event, entity ); break; default: break; diff --git a/client/hud/hud.cpp b/client/hud/hud.cpp index ee02a0ac..f36d0d88 100644 --- a/client/hud/hud.cpp +++ b/client/hud/hud.cpp @@ -6,10 +6,6 @@ #include "hud_iface.h" #include "hud.h" -extern float HUD_GetFOV( void ); -extern float v_idlescale; -float in_fov; - void CHud :: Init( void ) { InitMessages(); @@ -131,9 +127,8 @@ int CHud :: UpdateClientData( ref_params_t *cdata, float time ) Think(); - cdata->fov = m_iFOV; + cdata->fov_x = m_iFOV; cdata->iKeyBits = m_iKeyBits; - cdata->fov = m_iFOV; cdata->v_idlescale = m_iConcussionEffect; if( m_flMouseSensitivity ) @@ -142,7 +137,7 @@ int CHud :: UpdateClientData( ref_params_t *cdata, float time ) return 1; } -int CHud :: Redraw( float flTime, int intermission ) +int CHud :: Redraw( float flTime ) { m_fOldTime = m_flTime; // save time of previous redraw m_flTime = flTime; @@ -151,7 +146,8 @@ int CHud :: Redraw( float flTime, int intermission ) // clock was reset, reset delta if( m_flTimeDelta < 0 ) m_flTimeDelta = 0; - m_iIntermission = intermission; + // make levelshot if needed + MAKE_LEVELSHOT(); // draw screen fade before hud DrawScreenFade(); @@ -180,7 +176,7 @@ int CHud :: Redraw( float flTime, int intermission ) while( pList ) { - if( !intermission ) + if( !m_iIntermission ) { if(( pList->p->m_iFlags & HUD_ACTIVE ) && !(m_iHideHUDDisplay & HIDEHUD_ALL )) pList->p->Draw(flTime); diff --git a/client/hud/hud.h b/client/hud/hud.h index f0d53a1c..e883fe69 100644 --- a/client/hud/hud.h +++ b/client/hud/hud.h @@ -618,7 +618,7 @@ public: void Init( void ); void VidInit( void ); void Think( void ); - int Redraw( float flTime, int intermission ); + int Redraw( float flTime ); int UpdateClientData( ref_params_t *pparams, float time ); CHud() : m_pHudList(NULL) { } @@ -630,6 +630,7 @@ public: int _cdecl MsgFunc_ServerName( const char *pszName, int iSize, void *pbuf ); int _cdecl MsgFunc_ResetHUD( const char *pszName, int iSize, void *pbuf); int _cdecl MsgFunc_InitHUD( const char *pszName, int iSize, void *pbuf ); + int _cdecl MsgFunc_Intermission( const char *pszName, int iSize, void *pbuf ); int _cdecl MsgFunc_ViewMode( const char *pszName, int iSize, void *pbuf ); int _cdecl MsgFunc_SetFOV( const char *pszName, int iSize, void *pbuf ); int _cdecl MsgFunc_Concuss( const char *pszName, int iSize, void *pbuf ); diff --git a/client/hud/hud_iface.h b/client/hud/hud_iface.h index ad0e26e9..7a3cebdf 100644 --- a/client/hud/hud_iface.h +++ b/client/hud/hud_iface.h @@ -12,7 +12,7 @@ extern cl_enginefuncs_t g_engfuncs; extern int HUD_VidInit( void ); extern void HUD_Init( void ); -extern int HUD_Redraw( float flTime, int intermission ); +extern int HUD_Redraw( float flTime, int state ); extern int HUD_UpdateClientData( ref_params_t *parms, float flTime ); extern void HUD_Reset( void ); extern void HUD_Frame( double time ); @@ -62,6 +62,8 @@ typedef struct dllfunction_s gHUD.##y.UserCmd_##x( ); \ } +#define bound( min, num, max ) ((num) >= (min) ? ((num) < (max) ? (num) : (max)) : (min)) + inline void UnpackRGB( int &r, int &g, int &b, dword ulRGB ) { r = (ulRGB & 0xFF0000) >>16;\ @@ -140,8 +142,17 @@ extern void SPR_DrawHoles( int frame, int x, int y, int width, int height ); extern void SPR_DrawAdditive( int frame, int x, int y, const wrect_t *prc ); extern void SetCrosshair( HSPRITE hspr, wrect_t rc, int r, int g, int b ); extern void DrawCrosshair( void ); +extern void DrawPause( void ); extern void SetScreenFade( Vector fadeColor, float alpha, float duration, float holdTime, int fadeFlags ); extern void DrawScreenFade( void ); +extern void DrawImageBar( float percent, HSPRITE hImage, int w, int h ); +extern void DrawImageBar( float percent, HSPRITE hImage, int x, int y, int w, int h ); +extern void DrawGenericBar( float percent, int w, int h ); +extern void DrawGenericBar( float percent, int x, int y, int w, int h ); + +// from cl_view.c +extern void V_RenderSplash( void ); +extern void V_RenderPlaque( void ); // stdio stuff extern char *va( const char *format, ... ); diff --git a/client/hud/hud_msg.cpp b/client/hud/hud_msg.cpp index bad1e7c6..2dbd927b 100644 --- a/client/hud/hud_msg.cpp +++ b/client/hud/hud_msg.cpp @@ -39,12 +39,14 @@ DECLARE_HUDMESSAGE( AddScreen ); DECLARE_HUDMESSAGE( AddPortal ); DECLARE_HUDMESSAGE( ServerName ); DECLARE_HUDMESSAGE( ScreenShake ); +DECLARE_HUDMESSAGE( Intermission ); int CHud :: InitMessages( void ) { HOOK_MESSAGE( ResetHUD ); HOOK_MESSAGE( GameMode ); HOOK_MESSAGE( ServerName ); + HOOK_MESSAGE( Intermission ); HOOK_MESSAGE( InitHUD ); HOOK_MESSAGE( ViewMode ); HOOK_MESSAGE( SetFOV ); @@ -60,6 +62,7 @@ int CHud :: InitMessages( void ) HOOK_MESSAGE( AddMirror); HOOK_MESSAGE( AddScreen ); HOOK_MESSAGE( AddPortal ); + HOOK_MESSAGE( ScreenShake ); viewEntityIndex = 0; // trigger_viewset stuff viewFlags = 0; @@ -105,6 +108,8 @@ int CHud :: MsgFunc_ResetHUD(const char *pszName, int iSize, void *pbuf ) // reset concussion effect m_iConcussionEffect = 0; + m_iIntermission = 0; + // reset fog m_fStartDist = 0; m_fEndDist = 0; @@ -123,6 +128,7 @@ int CHud :: MsgFunc_InitHUD( const char *pszName, int iSize, void *pbuf ) m_fStartDist = 0; m_fEndDist = 0; m_iSkyMode = SKY_OFF; + m_iIntermission = 0; // prepare all hud data HUDLIST *pList = m_pHudList; @@ -136,7 +142,16 @@ int CHud :: MsgFunc_InitHUD( const char *pszName, int iSize, void *pbuf ) return 1; } -int CHud::MsgFunc_SetFOV( const char *pszName, int iSize, void *pbuf ) +int CHud :: MsgFunc_Intermission( const char *pszName, int iSize, void *pbuf ) +{ + BEGIN_READ( pszName, iSize, pbuf ); + m_iIntermission = 1; + END_READ(); + + return 1; +} + +int CHud::MsgFunc_SetFOV( const char *pszName, int iSize, void *pbuf ) { BEGIN_READ( pszName, iSize, pbuf ); diff --git a/client/hud/hud_utils.cpp b/client/hud/hud_utils.cpp index f24adf12..75bd11d3 100644 --- a/client/hud/hud_utils.cpp +++ b/client/hud/hud_utils.cpp @@ -162,6 +162,7 @@ typedef struct { // temp handle HSPRITE hSprite; + HSPRITE hPause; // pause pic // crosshair members HSPRITE hCrosshair; @@ -265,6 +266,113 @@ void DrawCrosshair( void ) DrawImage( ds.hCrosshair, x, y, ds.rcCrosshair.right, ds.rcCrosshair.bottom, 0 ); } +void DrawPause( void ) +{ + // pause image + if( !CVAR_GET_FLOAT( "paused" ) || !CVAR_GET_FLOAT( "scr_showpause" )) + return; + + if( !ds.hPause ) ds.hPause = LOAD_SHADER( "gfx/shell/m_pause" ); + DrawImage( ds.hPause, (SCREEN_WIDTH - 128) / 2, (SCREEN_HEIGHT - 32) / 2, 128, 32, 0 ); +} + +void DrawImageRectangle( HSPRITE hImage ) +{ + DrawImage( hImage, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0 ); +} + +void DrawImageBar( float percent, HSPRITE hImage, int w, int h ) +{ + DrawImageBar( percent, hImage, (SCREEN_WIDTH - w)/2, (SCREEN_HEIGHT - h)/2, w, h ); +} + +void DrawImageBar( float percent, HSPRITE hImage, int x, int y, int w, int h ) +{ + HSPRITE hFilled; + float progress; + int width1, width2, height; + + hFilled = LOAD_SHADER( "gfx/shell/fill_rect" ); + progress = bound( 0.0, percent * 0.01, 100.0 ); + + width2 = w * progress; + width1 = bound( 64.0, w, 512.0 ); + height = bound( 16.0, h, 64.0 ); + + DrawImage( hImage, x, y, width1, height, 0 ); // background + + SetColor( 1.0f, 1.0f, 1.0f, 0.5f ); + DrawImage( hFilled, x, y, width2, height, 0 ); // progress bar +} + +void DrawGenericBar( float percent, int w, int h ) +{ + DrawGenericBar( percent, (SCREEN_WIDTH - w)/2, (SCREEN_HEIGHT - h)/2, w, h ); +} + +void DrawGenericBar( float percent, int x, int y, int w, int h ) +{ + HSPRITE hFill, hBack; + float progress; + int width1, width2, height1, height2; + int width3, height3, pos_x, pos_y, pos2_x, pos2_y; + + hFill = LOAD_SHADER( "gfx/shell/bar_load" ); + hBack = LOAD_SHADER( "gfx/shell/bar_back" ); + progress = bound( 0.0f, percent * 0.01f, 100.0f ); + + // filling area size + width1 = bound( 64.0, w, 512.0 ); + height1 = bound( 16.0, h, 64.0 ); + + // background size + width2 = width1 - 2; + height2 = height1 - 2; + + // bar size + width3 = width2 * progress; + height3 = height2; + + pos_x = x; + pos_y = y; + pos2_x = x + 1; + pos2_y = y + 1; + + FillRGBA( pos_x, pos_y, width1, height1, 255, 255, 255, 255 ); + DrawImage( hBack, pos2_x, pos2_y, width2, height2, 0 ); + + SetColor( 1.0f, 1.0f, 1.0f, 0.5f ); + DrawImage( hFill, pos2_x, pos2_y, width3, height3, 0 ); +} + +// +// 27/12/08 moved here from cl_view.c +// +void V_RenderPlaque( void ) +{ + const char *levelshot; + HSPRITE hDownload; + + levelshot = CVAR_GET_STRING( "cl_levelshot_name" ); + if( !strcmp( levelshot, "" )) levelshot = ""; + + // logo that shows up while upload next level + DrawImageRectangle( LOAD_SHADER( levelshot )); + DrawImageBar( CVAR_GET_FLOAT( "scr_loading" ), LOAD_SHADER( "gfx/shell/m_loading" ), 128, 32 ); + + if( !CVAR_GET_FLOAT( "scr_download" )) return; + + // FIXME: replace with picture "m_download" + hDownload = LOAD_SHADER( "gfx/shell/m_loading" ); + + DrawImageBar( CVAR_GET_FLOAT( "scr_download" ), hDownload, (SCREEN_WIDTH-128)/2, 420, 128, 32 ); +} + +void V_RenderSplash( void ) +{ + DrawImageRectangle( LOAD_SHADER( "gfx/shell/splash" )); +} + void SetScreenFade( Vector fadeColor, float alpha, float duration, float holdTime, int fadeFlags ) { sf.fadeColor = fadeColor; diff --git a/debug.bat b/debug.bat index 332a7b48..bb29ac58 100644 --- a/debug.bat +++ b/debug.bat @@ -58,6 +58,7 @@ goto done rem //delete log files if exist baserc\baserc.plg del /f /q baserc\baserc.plg +if exist client\client.plg del /f /q client\client.plg if exist engine\engine.plg del /f /q engine\engine.plg if exist launch\launch.plg del /f /q launch\launch.plg if exist common\common.plg del /f /q common\common.plg @@ -71,5 +72,5 @@ if exist vsound\vsound.plg del /f /q vsound\vsound.plg echo Build succeeded! echo Please wait. Xash is now loading cd D:\Xash3D\ -quake.exe -game tmpQuArK -log -debug -dev 5 +map qctest +quake.exe -game tmpQuArK -log -debug -dev 3 +map qctest :done \ No newline at end of file diff --git a/engine/client/cl_demo.c b/engine/client/cl_demo.c index fd2210ed..300b6a58 100644 --- a/engine/client/cl_demo.c +++ b/engine/client/cl_demo.c @@ -84,10 +84,10 @@ void CL_WriteDemoHeader( const char *name ) // baselines Mem_Set( &nullstate, 0, sizeof( nullstate )); - for( i = 0; i < game.numEntities; i++ ) + for( i = 0; i < clgame.numEntities; i++ ) { ent = EDICT_NUM( i ); - state = &ent->pvEngineData->baseline; + state = &ent->pvClientData->baseline; if( !state->model.index ) continue; if( buf.cursize + 64 > buf.maxsize ) @@ -99,7 +99,7 @@ void CL_WriteDemoHeader( const char *name ) buf.cursize = 0; } MSG_WriteByte( &buf, svc_spawnbaseline ); - MSG_WriteDeltaEntity( &nullstate, &ent->pvEngineData->baseline, &buf, true, true ); + MSG_WriteDeltaEntity( &nullstate, &ent->pvClientData->baseline, &buf, true, true ); } MSG_WriteByte( &buf, svc_stufftext ); @@ -109,6 +109,9 @@ void CL_WriteDemoHeader( const char *name ) len = LittleLong( buf.cursize ); FS_Write( cls.demofile, &len, 4 ); FS_Write( cls.demofile, buf.data, buf.cursize ); + + // force client.dll update + Cmd_ExecuteString( "cmd fullupdate\n" ); } /* diff --git a/engine/client/cl_effects.c b/engine/client/cl_effects.c index ae6e8ccc..4d6e9e83 100644 --- a/engine/client/cl_effects.c +++ b/engine/client/cl_effects.c @@ -587,8 +587,8 @@ void CL_AddParticles( void ) if( !cl_particles->integer ) return; - if( EDICT_NUM( cl.frame.ps.number )->pvEngineData->current.gravity != 0 ) - gravity = EDICT_NUM( cl.frame.ps.number )->pvEngineData->current.gravity / 800.0; // FIXME: register CS_GRAVITY + if( EDICT_NUM( cl.frame.ps.number )->pvClientData->current.gravity != 0 ) + gravity = EDICT_NUM( cl.frame.ps.number )->pvClientData->current.gravity / 800.0; // FIXME: register CS_GRAVITY else gravity = 1.0f; for( p = cl_active_particles; p; p = next ) diff --git a/engine/client/cl_frame.c b/engine/client/cl_frame.c index e93886ad..ce3c208b 100644 --- a/engine/client/cl_frame.c +++ b/engine/client/cl_frame.c @@ -16,12 +16,12 @@ FRAME PARSING void CL_UpdateEntityFields( edict_t *ent ) { // copy state to progs - ent->v.classname = cl.edict_classnames[ent->pvEngineData->current.classname]; - ent->v.modelindex = ent->pvEngineData->current.model.index; - ent->v.ambient = ent->pvEngineData->current.soundindex; - ent->v.model = MAKE_STRING( cl.configstrings[CS_MODELS+ent->pvEngineData->current.model.index] ); - VectorCopy( ent->pvEngineData->current.origin, ent->v.origin ); - VectorCopy( ent->pvEngineData->current.angles, ent->v.angles ); + ent->v.classname = cl.edict_classnames[ent->pvClientData->current.classname]; + ent->v.modelindex = ent->pvClientData->current.model.index; + ent->v.ambient = ent->pvClientData->current.soundindex; + ent->v.model = MAKE_STRING( cl.configstrings[CS_MODELS+ent->pvClientData->current.model.index] ); + VectorCopy( ent->pvClientData->current.origin, ent->v.origin ); + VectorCopy( ent->pvClientData->current.angles, ent->v.angles ); } /* @@ -49,25 +49,25 @@ void CL_DeltaEntity( sizebuf_t *msg, frame_t *frame, int newnum, entity_state_t frame->num_entities++; // some data changes will force no lerping - if( state->model.index != ent->pvEngineData->current.model.index || state->pmodel.index != ent->pvEngineData->current.pmodel.index || state->model.body != ent->pvEngineData->current.model.body - || state->model.sequence != ent->pvEngineData->current.model.sequence || abs(state->origin[0] - ent->pvEngineData->current.origin[0]) > 512 - || abs(state->origin[1] - ent->pvEngineData->current.origin[1]) > 512 || abs(state->origin[2] - ent->pvEngineData->current.origin[2]) > 512 ) + if( state->model.index != ent->pvClientData->current.model.index || state->pmodel.index != ent->pvClientData->current.pmodel.index || state->model.body != ent->pvClientData->current.model.body + || state->model.sequence != ent->pvClientData->current.model.sequence || abs(state->origin[0] - ent->pvClientData->current.origin[0]) > 512 + || abs(state->origin[1] - ent->pvClientData->current.origin[1]) > 512 || abs(state->origin[2] - ent->pvClientData->current.origin[2]) > 512 ) { - ent->pvEngineData->serverframe = -99; + ent->pvClientData->serverframe = -99; } - if( ent->pvEngineData->serverframe != cl.frame.serverframe - 1 ) + if( ent->pvClientData->serverframe != cl.frame.serverframe - 1 ) { // duplicate the current state so lerping doesn't hurt anything - ent->pvEngineData->prev = *state; + ent->pvClientData->prev = *state; } else { // shuffle the last state to previous - ent->pvEngineData->prev = ent->pvEngineData->current; + ent->pvClientData->prev = ent->pvClientData->current; } - ent->pvEngineData->serverframe = cl.frame.serverframe; - ent->pvEngineData->current = *state; + ent->pvClientData->serverframe = cl.frame.serverframe; + ent->pvClientData->current = *state; // update prvm fields CL_UpdateEntityFields( ent ); @@ -155,7 +155,7 @@ void CL_ParsePacketEntities( sizebuf_t *msg, frame_t *oldframe, frame_t *newfram { // delta from baseline edict_t *ent = EDICT_NUM( newnum ); - CL_DeltaEntity( msg, newframe, newnum, &ent->pvEngineData->baseline, false ); + CL_DeltaEntity( msg, newframe, newnum, &ent->pvClientData->baseline, false ); continue; } @@ -263,8 +263,8 @@ void CL_ParseFrame( sizebuf_t *msg ) if( sv_newprotocol->integer ) { // now we can reading delta player state - if( old ) cl.frame.ps = MSG_ParseDeltaPlayer( &old->ps, &clent->pvEngineData->current ); - else cl.frame.ps = MSG_ParseDeltaPlayer( NULL, &clent->pvEngineData->current ); + if( old ) cl.frame.ps = MSG_ParseDeltaPlayer( &old->ps, &clent->pvClientData->current ); + else cl.frame.ps = MSG_ParseDeltaPlayer( NULL, &clent->pvClientData->current ); } // FIXME @@ -311,7 +311,7 @@ void CL_AddPacketEntities( frame_t *frame ) { s1 = &cl_parse_entities[(frame->parse_entities + pnum)&(MAX_PARSE_ENTITIES-1)]; ent = EDICT_NUM( s1->number ); - re->AddRefEntity( &ent->pvEngineData->current, &ent->pvEngineData->prev, cl.lerpfrac ); + re->AddRefEntity( &ent->pvClientData->current, &ent->pvClientData->prev, cl.refdef.lerpfrac ); } } @@ -331,11 +331,11 @@ void CL_AddViewWeapon( entity_state_t *ps ) if( ps->fov > 135 ) return; view = EDICT_NUM( ps->aiment ); - VectorCopy( cl.refdef.vieworg, view->pvEngineData->current.origin ); - VectorCopy( cl.refdef.viewangles, view->pvEngineData->current.angles ); - VectorCopy( cl.refdef.vieworg, view->pvEngineData->prev.origin ); - VectorCopy( cl.refdef.viewangles, view->pvEngineData->prev.angles ); - re->AddRefEntity( &view->pvEngineData->current, &view->pvEngineData->prev, cl.lerpfrac ); + VectorCopy( cl.refdef.vieworg, view->pvClientData->current.origin ); + VectorCopy( cl.refdef.viewangles, view->pvClientData->current.angles ); + VectorCopy( cl.refdef.vieworg, view->pvClientData->prev.origin ); + VectorCopy( cl.refdef.viewangles, view->pvClientData->prev.angles ); + re->AddRefEntity( &view->pvClientData->current, &view->pvClientData->prev, cl.refdef.lerpfrac ); } @@ -359,16 +359,16 @@ void CL_CalcViewValues( void ) if( cl_showclamp->value ) Msg ("high clamp %i\n", cl.time - cl.frame.servertime); cl.time = cl.frame.servertime; - cl.lerpfrac = 1.0f; + cl.refdef.lerpfrac = 1.0f; } else if (cl.time < cl.frame.servertime - Host_FrameTime()) { if (cl_showclamp->value) Msg( "low clamp %i\n", cl.frame.servertime - Host_FrameTime() - cl.time); cl.time = cl.frame.servertime - Host_FrameTime(); - cl.lerpfrac = 0.0f; + cl.refdef.lerpfrac = 0.0f; } - else cl.lerpfrac = 1.0 - (cl.frame.servertime - cl.time) * 0.01f; + else cl.refdef.lerpfrac = 1.0 - (cl.frame.servertime - cl.time) * 0.01f; // find the previous frame to interpolate from ps = &cl.frame.ps; @@ -381,7 +381,7 @@ void CL_CalcViewValues( void ) // see if the player entity was teleported this frame if( ps->pm_flags & PMF_TIME_TELEPORT ) ops = ps; // don't interpolate - lerp = cl.lerpfrac; + lerp = cl.refdef.lerpfrac; // calculate the origin if((cl_predict->value) && !(cl.frame.ps.pm_flags & PMF_NO_PREDICTION) && !cls.demoplayback ) @@ -393,7 +393,7 @@ void CL_CalcViewValues( void ) for( i = 0; i < 3; i++ ) { cl.refdef.vieworg[i] = cl.predicted_origin[i] + ops->viewoffset[i] - + cl.lerpfrac * (ps->viewoffset[i] - ops->viewoffset[i]) - backlerp * cl.prediction_error[i]; + + cl.refdef.lerpfrac * (ps->viewoffset[i] - ops->viewoffset[i]) - backlerp * cl.prediction_error[i]; } // smooth out stair climbing @@ -422,7 +422,7 @@ void CL_CalcViewValues( void ) for( i = 0; i < 3; i++ ) cl.refdef.viewangles[i] += LerpAngle( ops->punch_angles[i], ps->punch_angles[i], lerp ); - AngleVectors( cl.refdef.viewangles, cl.v_forward, cl.v_right, cl.v_up ); + AngleVectors( cl.refdef.viewangles, cl.refdef.forward, cl.refdef.right, cl.refdef.up ); // interpolate field of view cl.refdef.fov_x = ops->fov + lerp * ( ps->fov - ops->fov ); @@ -472,18 +472,18 @@ void CL_GetEntitySoundSpatialization( int entnum, vec3_t origin, vec3_t velocity ent = EDICT_NUM( entnum ); // calculate origin - origin[0] = ent->pvEngineData->prev.origin[0] + (ent->pvEngineData->current.origin[0] - ent->pvEngineData->prev.origin[0]) * cl.lerpfrac; - origin[1] = ent->pvEngineData->prev.origin[1] + (ent->pvEngineData->current.origin[1] - ent->pvEngineData->prev.origin[1]) * cl.lerpfrac; - origin[2] = ent->pvEngineData->prev.origin[2] + (ent->pvEngineData->current.origin[2] - ent->pvEngineData->prev.origin[2]) * cl.lerpfrac; + origin[0] = ent->pvClientData->prev.origin[0] + (ent->pvClientData->current.origin[0] - ent->pvClientData->prev.origin[0]) * cl.refdef.lerpfrac; + origin[1] = ent->pvClientData->prev.origin[1] + (ent->pvClientData->current.origin[1] - ent->pvClientData->prev.origin[1]) * cl.refdef.lerpfrac; + origin[2] = ent->pvClientData->prev.origin[2] + (ent->pvClientData->current.origin[2] - ent->pvClientData->prev.origin[2]) * cl.refdef.lerpfrac; // calculate velocity - VectorSubtract( ent->pvEngineData->current.origin, ent->pvEngineData->prev.origin, velocity); + VectorSubtract( ent->pvClientData->current.origin, ent->pvClientData->prev.origin, velocity); VectorScale(velocity, 10, velocity); // if a brush model, offset the origin if( VectorIsNull( origin )) { - cmodel = cl.models[ent->pvEngineData->current.model.index]; + cmodel = cl.models[ent->pvClientData->current.model.index]; if( !cmodel ) return; VectorAverage( cmodel->mins, cmodel->maxs, midPoint ); VectorAdd( origin, midPoint, origin ); diff --git a/engine/client/cl_game.c b/engine/client/cl_game.c index e4f184e6..227a82f0 100644 --- a/engine/client/cl_game.c +++ b/engine/client/cl_game.c @@ -19,7 +19,7 @@ Render callback for studio models */ entity_state_t *CL_GetEdictByIndex( int index ) { - return &EDICT_NUM( index )->pvEngineData->current; + return &EDICT_NUM( index )->pvClientData->current; } /* @@ -31,7 +31,7 @@ Render callback for studio models */ entity_state_t *CL_GetLocalPlayer( void ) { - return &EDICT_NUM( cl.playernum + 1 )->pvEngineData->current; + return &EDICT_NUM( cl.playernum + 1 )->pvClientData->current; } /* @@ -73,8 +73,9 @@ float *CL_FadeColor( float starttime, float endtime ) return color; } -void CL_DrawHUD( void ) +void CL_DrawHUD( int state ) { + cls.dllFuncs.pfnRedraw( cl.time * 0.001f, state ); } void CL_CopyTraceResult( TraceResult *out, trace_t trace ) @@ -98,84 +99,109 @@ void CL_CopyTraceResult( TraceResult *out, trace_t trace ) out->pHit = trace.ent; } -void CL_PrepUserMessage( char *pszName, const int svc_num ) +static void CL_CreateUserMessage( int lastnum, const char *szMsgName, int svc_num, int iSize, pfnUserMsgHook pfn ) +{ + user_message_t *msg; + + if( lastnum == clgame.numMessages ) + { + if( clgame.numMessages == MAX_USER_MESSAGES ) + { + MsgDev( D_ERROR, "CL_CreateUserMessage: user messages limit is out\n" ); + return; + } + clgame.numMessages++; + } + + msg = clgame.msg[lastnum]; + + // clear existing or allocate new one + if( msg ) Mem_Set( msg, 0, sizeof( *msg )); + else msg = clgame.msg[lastnum] = Mem_Alloc( cls.mempool, sizeof( *msg )); + + com.strncpy( msg->name, szMsgName, CS_SIZE ); + msg->number = svc_num; + msg->size = iSize; + msg->func = pfn; +} + +void CL_LinkUserMessage( char *pszName, const int svc_num ) { user_message_t *msg; char *end; + char msgName[CS_SIZE]; + int i, msgSize; if( !pszName || !*pszName ) return; // ignore blank names - if( game.numMessages == MAX_USER_MESSAGES ) - { - MsgDev( D_ERROR, "CL_PrepUserMessage: user messages limit is out\n" ); - return; - } - - // clear existing or allocate new one - msg = game.msg[game.numMessages]; - if( msg ) Mem_Set( msg, 0, sizeof( *msg )); - else msg = Mem_Alloc( cls.mempool, sizeof( *msg )); - - end = com.strchr( pszName, '@' ); + com.strncpy( msgName, pszName, CS_SIZE ); + end = com.strchr( msgName, '@' ); if( !end ) { - MsgDev( D_ERROR, "CL_PrepUserMessage: can't register message %s\n", pszName ); + MsgDev( D_ERROR, "CL_LinkUserMessage: can't register message %s\n", msgName ); return; } - msg->size = com.atoi( end + 1 ); - pszName[end-pszName] = '\0'; // remove size description from MsgName - msg->name = pszName; - msg->number = svc_num; - game.numMessages++; + msgSize = com.atoi( end + 1 ); + msgName[end-msgName] = '\0'; // remove size description from MsgName - // debug - Msg("name %s [%i][svc_%i]\n", msg->name, msg->size, msg->number ); + // search message by name to link with + for( i = 0; i < clgame.numMessages; i++ ) + { + msg = clgame.msg[i]; + if( !msg ) continue; + + if( !com.strcmp( msg->name, msgName )) + { + msg->number = svc_num; + msg->size = msgSize; + return; + } + } + + // create an empty message + CL_CreateUserMessage( i, msgName, svc_num, msgSize, NULL ); +} + +void CL_SortUserMessages( void ) +{ + // FIXME: implement } void CL_ParseUserMessage( sizebuf_t *net_buffer, int svc_num ) { user_message_t *msg; - int iSize; + int i, iSize; byte *pbuf; - + // NOTE: any user message parse on engine, not in client.dll - if( svc_num >= game.numMessages || !game.msg[svc_num] ) + if( svc_num >= clgame.numMessages ) { // unregister message can't be parsed Host_Error( "CL_ParseUserMessage: illegible server message %d\n", svc_num ); return; } - if( svc_num != game.msg[svc_num]->number ) + // search for svc_num + for( i = 0; i < clgame.numMessages; i++ ) { - int i; - - // search for right number - for( i = 0; i < game.numMessages; i++ ) - { - msg = game.msg[i]; - if( !msg || msg->number == svc_num ) - break; - } - - // throw warn - MsgDev( D_WARN, "CL_ParseUserMessage: wrong message num %i\n", svc_num ); - - if( i == game.numMessages || !msg ) - { - // this never happens - Host_Error( "CL_ParseUserMessage: illegible server message %d\n", svc_num ); - return; - } + msg = clgame.msg[i]; + if( !msg ) continue; + if( msg->number == svc_num ) + break; + } + + if( i == clgame.numMessages || !msg ) + { + // unregistered message ? + Host_Error( "CL_ParseUserMessage: illegible server message %d\n", svc_num ); + return; } - else msg = game.msg[svc_num]; iSize = msg->size; pbuf = NULL; - // message with variable sizes receive actual size as first byte - // FIXME: replace with short for support messages more than 255 bytes ? + // message with variable sizes receive an actual size as first byte if( iSize == -1 ) iSize = MSG_ReadByte( net_buffer ); if( iSize > 0 ) pbuf = Mem_Alloc( cls.private, iSize ); @@ -183,7 +209,7 @@ void CL_ParseUserMessage( sizebuf_t *net_buffer, int svc_num ) MSG_ReadData( net_buffer, pbuf, iSize ); if( msg->func ) msg->func( msg->name, iSize, pbuf ); - else MsgDev( D_WARN, "CL_ParseUserMessage: message %s doesn't have execute function\n", msg->name ); + else MsgDev( D_WARN, "CL_ParseUserMessage: %s not hooked\n", msg->name ); if( pbuf ) Mem_Free( pbuf ); } @@ -192,7 +218,7 @@ void CL_InitEdict( edict_t *pEdict ) Com_Assert( pEdict == NULL ); pEdict->v.pContainingEntity = pEdict; // make cross-links for consistency - pEdict->pvEngineData = (ed_priv_t *)Mem_Alloc( cls.mempool, sizeof( ed_priv_t )); + pEdict->pvClientData = (cl_priv_t *)Mem_Alloc( cls.mempool, sizeof( cl_priv_t )); pEdict->serialnumber = NUM_FOR_EDICT( pEdict ); // merged on first update pEdict->free = false; } @@ -205,10 +231,10 @@ void CL_FreeEdict( edict_t *pEdict ) // unlink from world // CL_UnlinkEdict( pEdict ); - if( pEdict->pvEngineData ) Mem_Free( pEdict->pvEngineData ); + if( pEdict->pvClientData ) Mem_Free( pEdict->pvClientData ); Mem_Set( &pEdict->v, 0, sizeof( entvars_t )); - pEdict->pvEngineData = NULL; + pEdict->pvClientData = NULL; // mark edict as freed pEdict->freetime = cl.time * 0.001f; @@ -221,7 +247,7 @@ edict_t *CL_AllocEdict( void ) edict_t *pEdict; int i; - for( i = 0; i < game.numEntities; i++ ) + for( i = 0; i < clgame.numEntities; i++ ) { pEdict = EDICT_NUM( i ); // the first couple seconds of server time can involve a lot of @@ -233,10 +259,10 @@ edict_t *CL_AllocEdict( void ) } } - if( i == game.maxEntities ) + if( i == clgame.maxEntities ) Host_Error( "CL_AllocEdict: no free edicts\n" ); - game.numEntities++; + clgame.numEntities++; pEdict = EDICT_NUM( i ); CL_InitEdict( pEdict ); @@ -248,12 +274,13 @@ void CL_FreeEdicts( void ) int i; edict_t *ent; - for( i = 0; game.numEntities; i++ ) + for( i = 0; i < clgame.numEntities; i++ ) { ent = EDICT_NUM( i ); if( ent->free ) continue; CL_FreeEdict( ent ); } + clgame.numEntities = 0; } /* @@ -284,6 +311,7 @@ static void pfnMemFree( void *mem, const char *filename, const int fileline ) { com.free( mem, filename, fileline ); } + /* ============= pfnLoadShader @@ -406,27 +434,30 @@ pfnHookUserMsg ============= */ -void pfnHookUserMsg( char *szMsgName, pfnUserMsgHook pfn ) +void pfnHookUserMsg( const char *szMsgName, pfnUserMsgHook pfn ) { user_message_t *msg; int i; // ignore blank names if( !szMsgName || !*szMsgName ) return; - for( i = 0; game.numMessages; i++ ) + + // duplicate call can change msgFunc + for( i = 0; i < clgame.numMessages; i++ ) { - msg = game.msg[i]; - if( !msg ) break; + msg = clgame.msg[i]; + if( !msg ) continue; if( !com.strcmp( szMsgName, msg->name )) { - // msg registration is complete - msg->func = pfn; + if( msg->func != pfn ) + msg->func = pfn; return; } } - MsgDev( D_ERROR, "CL_HookMessage: can't hook message %s\n", szMsgName ); + // allocate a new one + CL_CreateUserMessage( i, szMsgName, 0, 0, pfn ); } /* @@ -699,7 +730,7 @@ pfnGetEntityByIndex */ edict_t* pfnGetEntityByIndex( int idx ) { - if( idx < 0 || idx > game.numEntities ) + if( idx < 0 || idx > clgame.numEntities ) { MsgDev( D_ERROR, "CL_GetEntityByIndex: invalid entindex %i\n", idx ); return EDICT_NUM( 0 ); @@ -764,6 +795,24 @@ edict_t* pfnGetViewModel( void ) return EDICT_NUM( cl.playernum + 1 )->v.aiment; } +/* +============= +pfnMakeLevelShot + +force to make levelshot +============= +*/ +void pfnMakeLevelShot( void ) +{ + if( !cl.need_levelshot ) return; + + Con_ClearNotify(); + cl.need_levelshot = false; + + // make levelshot at nextframe() + Cbuf_ExecuteText( EXEC_APPEND, "levelshot\n" ); +} + /* ============= pfnPointContents @@ -795,6 +844,28 @@ static void pfnTraceLine( const float *v1, const float *v2, int fNoMonsters, edi CL_CopyTraceResult( ptr, trace ); } +/* +============= +CL_AllocString + +============= +*/ +string_t CL_AllocString( const char *szValue ) +{ + return StringTable_SetString( clgame.hStringTable, szValue ); +} + +/* +============= +CL_GetString + +============= +*/ +const char *CL_GetString( string_t iString ) +{ + return StringTable_GetString( clgame.hStringTable, iString ); +} + static triapi_t gTriApi = { sizeof( triapi_t ), @@ -837,7 +908,8 @@ static cl_enginefuncs_t gEngfuncs = pfnIsSpectateOnly, pfnGetClientTime, pfnGetMaxClients, - pfnGetViewModel, + pfnGetViewModel, + pfnMakeLevelShot, pfnPointContents, pfnTraceLine, pfnRandomLong, @@ -869,7 +941,7 @@ void CL_UnloadProgs( void ) // initialize game cls.dllFuncs.pfnShutdown(); - StringTable_Delete( game.hStringTable ); + StringTable_Delete( clgame.hStringTable ); Com_FreeLibrary( cls.game ); Mem_FreePool( &cls.mempool ); Mem_FreePool( &cls.private ); @@ -907,14 +979,17 @@ bool CL_LoadProgs( const char *name ) } // 65535 unique strings should be enough ... - game.hStringTable = StringTable_Create( "Client Strings", 0x10000 ); - StringTable_SetString( game.hStringTable, "" ); // make NULL string - game.maxEntities = host.max_edicts; // FIXME: must come from CS_MAXENTITIES - game.maxClients = Host_MaxClients(); - game.edicts = Mem_Alloc( cls.mempool, sizeof( edict_t ) * game.maxEntities ); - game.numMessages = 1; // message with index 0 it's svc_bad + clgame.hStringTable = StringTable_Create( "Client Strings", 0x10000 ); + StringTable_SetString( clgame.hStringTable, "" ); // make NULL string + clgame.maxEntities = host.max_edicts; // FIXME: must come from CS_MAXENTITIES + clgame.maxClients = Host_MaxClients(); + cls.edicts = Mem_Alloc( cls.mempool, sizeof( edict_t ) * clgame.maxEntities ); - for( i = 0, e = game.edicts; i < game.maxEntities; i++, e++ ) + // register svc_bad message + pfnHookUserMsg( "bad", NULL ); + CL_LinkUserMessage( "bad@0", svc_bad ); + + for( i = 0, e = EDICT_NUM( 0 ); i < clgame.maxEntities; i++, e++ ) e->free = true; // mark all edicts as freed // initialize game diff --git a/engine/client/cl_input.c b/engine/client/cl_input.c index 4a0941f0..4d0ad099 100644 --- a/engine/client/cl_input.c +++ b/engine/client/cl_input.c @@ -469,12 +469,12 @@ void CL_SendCmd( void ) } // begin a client move command - MSG_Init(&buf, data, sizeof(data)); - MSG_WriteByte (&buf, clc_move); + MSG_Init( &buf, data, sizeof( data )); + MSG_WriteByte( &buf, clc_move ); // save the position for a checksum byte checksumIndex = buf.cursize; - MSG_WriteByte (&buf, 0); + MSG_WriteByte( &buf, 0 ); // let the server know what the last frame we // got was, so the next message can be delta compressed diff --git a/engine/client/cl_main.c b/engine/client/cl_main.c index cb6f891c..cd33098d 100644 --- a/engine/client/cl_main.c +++ b/engine/client/cl_main.c @@ -67,6 +67,7 @@ cvar_t *fov; client_static_t cls; client_t cl; +clgame_static_t clgame; entity_state_t cl_parse_entities[MAX_PARSE_ENTITIES]; @@ -335,6 +336,8 @@ void CL_ClearState (void) CL_ClearEffects (); CL_FreeEdicts(); + cls.dllFuncs.pfnVidInit(); + // wipe the entire cl structure Mem_Set( &cl, 0, sizeof( cl )); MSG_Clear( &cls.netchan.message ); @@ -1037,7 +1040,7 @@ void CL_RequestNextDownload( void ) while( precache_tex < pe->NumTextures()) { com.sprintf( fn, "textures/%s.tga", pe->GetTextureName( precache_tex++ )); - if(!CL_CheckOrDownloadFile( fn )) return; // started a download + if( !CL_CheckOrDownloadFile( fn )) return; // started a download } } precache_check = TEXTURE_CNT + 999; @@ -1045,6 +1048,7 @@ void CL_RequestNextDownload( void ) CL_PrepSound(); CL_PrepVideo(); + CL_SortUserMessages(); if( cls.demoplayback ) return; // not really connected MSG_WriteByte( &cls.netchan.message, clc_stringcmd ); @@ -1220,7 +1224,7 @@ void CL_Frame( dword time ) SCR_UpdateScreen(); // update audio - S_Update( cl.playernum + 1, cl.refdef.vieworg, vec3_origin, cl.v_forward, cl.v_up ); + S_Update( cl.playernum + 1, cl.refdef.vieworg, vec3_origin, cl.refdef.forward, cl.refdef.up ); // advance local effects for next frame CL_RunDLights (); diff --git a/engine/client/cl_parse.c b/engine/client/cl_parse.c index c48a9f21..ce71066c 100644 --- a/engine/client/cl_parse.c +++ b/engine/client/cl_parse.c @@ -256,7 +256,7 @@ void CL_ParseServerData( sizebuf_t *msg ) if(!FS_FileExists( Cvar_VariableString( "cl_levelshot_name" ))) { Cvar_Set( "cl_levelshot_name", "" ); - cl.make_levelshot = true; // make levelshot + cl.need_levelshot = true; // make levelshot } // seperate the printfs so the server message can have a color Msg("\35\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\37\n"); @@ -281,10 +281,10 @@ void CL_ParseBaseline( sizebuf_t *msg ) newnum = MSG_ReadBits( msg, NET_WORD ); // increase edicts - while( newnum >= game.numEntities ) CL_AllocEdict(); + while( newnum >= clgame.numEntities ) CL_AllocEdict(); ent = EDICT_NUM( newnum ); - MSG_ReadDeltaEntity( msg, &nullstate, &ent->pvEngineData->baseline, newnum ); + MSG_ReadDeltaEntity( msg, &nullstate, &ent->pvClientData->baseline, newnum ); } /* @@ -325,7 +325,7 @@ void CL_ParseConfigString( sizebuf_t *msg ) } else if( i >= CS_USER_MESSAGES && i < CS_USER_MESSAGES+MAX_USER_MESSAGES ) { - CL_PrepUserMessage( cl.configstrings[i], i - CS_USER_MESSAGES ); + CL_LinkUserMessage( cl.configstrings[i], i - CS_USER_MESSAGES ); } else if( i >= CS_CLASSNAMES && i < CS_CLASSNAMES+MAX_CLASSNAMES ) { @@ -424,6 +424,9 @@ void CL_ParseServerMessage( sizebuf_t *msg ) case svc_setangle: CL_ParseSetAngle( msg ); break; + case svc_print: + Con_Print( va( "^6%s\n", MSG_ReadString( msg ))); + break; case svc_frame: CL_ParseFrame( msg ); break; diff --git a/engine/client/cl_progs.c b/engine/client/cl_progs.c index 7dfb5866..c86850ed 100644 --- a/engine/client/cl_progs.c +++ b/engine/client/cl_progs.c @@ -6,102 +6,6 @@ #include "common.h" #include "client.h" -/* -========= -PF_drawnet - -void DrawNet( vector pos, string image ) -========= -*/ -static void PF_drawnet( void ) -{ - float *pos; - shader_t shader; - - if(!VM_ValidateArgs( "DrawNet", 2 )) - return; - if(cls.netchan.outgoing_sequence - cls.netchan.incoming_acknowledged < CMD_BACKUP-1) - return; - - VM_ValidateString(PRVM_G_STRING(OFS_PARM1)); - pos = PRVM_G_VECTOR(OFS_PARM0); - shader = re->RegisterShader( PRVM_G_STRING(OFS_PARM1), SHADER_NOMIP ); - - SCR_DrawPic( pos[0], pos[1], -1, -1, shader ); -} - -/* -========= -PF_drawfps - -void DrawFPS( vector pos ) -========= -*/ -static void PF_drawfps( void ) -{ - float calc; - static double nexttime = 0, lasttime = 0; - static double framerate = 0; - static long framecount = 0; - double newtime; - bool red = false; // fps too low - char fpsstring[32]; - float *color, *pos; - - if(cls.state != ca_active) return; - if(!cl_showfps->integer) return; - if(!VM_ValidateArgs( "drawfps", 1 )) - return; - - newtime = Sys_DoubleTime(); - if( newtime >= nexttime ) - { - framerate = framecount / (newtime - lasttime); - lasttime = newtime; - nexttime = max(nexttime + 1, lasttime - 1); - framecount = 0; - } - framecount++; - calc = framerate; - pos = PRVM_G_VECTOR(OFS_PARM0); - - if ((red = (calc < 1.0f))) - { - com.snprintf(fpsstring, sizeof(fpsstring), "%4i spf", (int)(1.0f / calc + 0.5)); - color = g_color_table[1]; - } - else - { - com.snprintf(fpsstring, sizeof(fpsstring), "%4i fps", (int)(calc + 0.5)); - color = g_color_table[3]; - } - SCR_DrawBigStringColor(pos[0], pos[1], fpsstring, color ); -} - -/* -========= -PF_levelshot - -float HUD_MakeLevelShot( void ) -========= -*/ -static void PF_levelshot( void ) -{ - PRVM_G_FLOAT(OFS_RETURN) = 0; - if(!VM_ValidateArgs( "HUD_MakeLevelShot", 0 )) - return; - - if( cl.make_levelshot ) - { - Con_ClearNotify(); - cl.make_levelshot = false; - - // make levelshot at nextframe() - Cbuf_ExecuteText( EXEC_APPEND, "levelshot\n" ); - PRVM_G_FLOAT(OFS_RETURN) = 1; - } -} - /* ================= PF_findexplosionplane diff --git a/engine/client/cl_scrn.c b/engine/client/cl_scrn.c index 4648df96..1511bf20 100644 --- a/engine/client/cl_scrn.c +++ b/engine/client/cl_scrn.c @@ -6,7 +6,7 @@ #include "common.h" #include "client.h" -vrect_t scr_vrect; // position of render window on screen +int scr_rect[4]; // position of render window on screen cvar_t *scr_viewsize; cvar_t *scr_centertime; @@ -20,6 +20,7 @@ cvar_t *cl_testentities; cvar_t *cl_testlights; cvar_t *cl_levelshot_name; cvar_t *cl_envshot_size; +cvar_t *cl_neticon; cvar_t *cl_font; void SCR_TimeRefresh_f( void ); @@ -292,6 +293,61 @@ void SCR_StopCinematic( void ) S_StopAllSounds(); } +/* +============== +SCR_DrawNet +============== +*/ +void SCR_DrawNet( void ) +{ + if( cls.netchan.outgoing_sequence - cls.netchan.incoming_acknowledged < CMD_BACKUP-1 ) + return; + + SCR_DrawPic( scr_rect[0] + 64, scr_rect[1], 48, 48, cls.netIcon ); +} + +/* +============== +SCR_DrawFPS +============== +*/ +void SCR_DrawFPS( void ) +{ + float calc; + static double nexttime = 0, lasttime = 0; + static double framerate = 0; + static int framecount = 0; + double newtime; + bool red = false; // fps too low + char fpsstring[32]; + float *color; + + if( cls.state != ca_active ) return; + + newtime = Sys_DoubleTime(); + if (newtime >= nexttime) + { + framerate = framecount / (newtime - lasttime); + lasttime = newtime; + nexttime = max(nexttime + 1, lasttime - 1); + framecount = 0; + } + framecount++; + calc = framerate; + + if ((red = (calc < 1.0f))) + { + com.snprintf( fpsstring, sizeof( fpsstring ), "%4i spf", (int)(1.0f / calc + 0.5)); + color = g_color_table[1]; + } + else + { + com.snprintf( fpsstring, sizeof( fpsstring ), "%4i fps", (int)(calc + 0.5)); + color = g_color_table[3]; + } + SCR_DrawBigStringColor( SCREEN_WIDTH - 146, SCREEN_HEIGHT - 32, fpsstring, color ); +} + /* ================== SCR_UpdateScreen @@ -307,14 +363,16 @@ void SCR_UpdateScreen( void ) switch( cls.state ) { case ca_disconnected: + CL_DrawHUD( CL_DISCONNECTED ); + break; case ca_connecting: case ca_connected: - CL_DrawHUD(); + CL_DrawHUD( CL_LOADING ); break; case ca_active: V_CalcRect(); V_RenderView(); - CL_DrawHUD(); + CL_DrawHUD( CL_ACTIVE ); CL_DrawDemoRecording(); break; case ca_cinematic: @@ -324,7 +382,6 @@ void SCR_UpdateScreen( void ) Host_Error( "SCR_UpdateScreen: bad cls.state\n" ); break; } - V_PostRender(); } @@ -333,7 +390,8 @@ void SCR_RegisterShaders( void ) // register console images cls.consoleFont = re->RegisterShader( va( "gfx/fonts/%s", con_font->string ), SHADER_FONT ); cls.clientFont = re->RegisterShader( va( "gfx/fonts/%s", cl_font->string ), SHADER_FONT ); - cls.consoleBack = re->RegisterShader( "gfx/shell/conback", SHADER_NOMIP ); // hardcoded ... + cls.consoleBack = re->RegisterShader( "gfx/shell/conback", SHADER_NOMIP ); // FIXME: hardcoded ... + cls.netIcon = re->RegisterShader( cl_neticon->string, SHADER_NOMIP ); } /* @@ -352,6 +410,7 @@ void SCR_Init( void ) cl_testentities = Cvar_Get ("cl_testentities", "0", 0, "test client entities" ); cl_testlights = Cvar_Get ("cl_testlights", "0", 0, "test dynamic lights" ); cl_envshot_size = Cvar_Get( "cl_envshot_size", "256", CVAR_ARCHIVE, "envshot size of cube side" ); + cl_neticon = Cvar_Get( "cl_neticon", "gfx/shell/net", CVAR_ARCHIVE, "path to icon that displayed bad network connection" ); cl_font = Cvar_Get( "cl_font", "default", CVAR_ARCHIVE, "in-game messages font" ); // register our commands diff --git a/engine/client/cl_view.c b/engine/client/cl_view.c index 669c4462..ac073068 100644 --- a/engine/client/cl_view.c +++ b/engine/client/cl_view.c @@ -44,11 +44,11 @@ Sets scr_vrect, the coordinates of the rendered window */ void V_CalcRect( void ) { - scr_vrect.width = scr_width->integer; - scr_vrect.width &= ~7; - scr_vrect.height = scr_height->integer; - scr_vrect.height &= ~1; - scr_vrect.y = scr_vrect.x = 0; + scr_rect[2] = scr_width->integer; + scr_rect[2] &= ~7; + scr_rect[3] = scr_height->integer; + scr_rect[3] &= ~1; + scr_rect[0] = scr_rect[1] = 0; } /* @@ -73,7 +73,7 @@ void V_TestEntities( void ) f = 64 * (i/4) + 128; for( j = 0; j < 3; j++ ) - ent.origin[j] = cl.refdef.vieworg[j] + cl.v_forward[j] * f + cl.v_right[j] * r; + ent.origin[j] = cl.refdef.vieworg[j] + cl.refdef.forward[j] * f + cl.refdef.right[j] * r; ent.model.controller[0] = ent.model.controller[1] = 90.0f; ent.model.controller[2] = ent.model.controller[3] = 180.0f; @@ -104,7 +104,7 @@ void V_TestLights( void ) f = 64 * (i/4) + 128; for( j = 0; j < 3; j++ ) - dl.origin[j] = cl.refdef.vieworg[j] + cl.v_forward[j] * f + cl.v_right[j] * r; + dl.origin[j] = cl.refdef.vieworg[j] + cl.refdef.forward[j] * f + cl.refdef.right[j] * r; dl.color[0] = ((i%6)+1) & 1; dl.color[1] = (((i%6)+1) & 2)>>1; @@ -156,7 +156,7 @@ void V_RenderView( void ) // build a refresh entity list and calc cl.sim* // this also calls CL_CalcViewValues which loads - // v_forward, etc. + // refdef.forward, etc. CL_AddEntities (); if( cl_testentities->value ) V_TestEntities(); @@ -169,11 +169,11 @@ void V_RenderView( void ) cl.refdef.vieworg[1] += 1.0 / 32; cl.refdef.vieworg[2] += 1.0 / 32; - Mem_Copy( &cl.refdef.rect, &scr_vrect, sizeof( vrect_t )); + Mem_Copy( &cl.refdef.viewport, &scr_rect, sizeof( cl.refdef.viewport )); cl.refdef.areabits = cl.frame.areabits; cl.refdef.rdflags = cl.frame.ps.renderfx; - cl.refdef.fov_y = V_CalcFov( cl.refdef.fov_x, cl.refdef.rect.width, cl.refdef.rect.height ); + cl.refdef.fov_y = V_CalcFov( cl.refdef.fov_x, cl.refdef.viewport[2], cl.refdef.viewport[3] ); cl.refdef.time = cl.time * 0.001f; // cl.time for right lerping cl.refdef.oldtime = (cl.time * 0.001f) - 0.005; // frametime @@ -211,6 +211,8 @@ V_PostRender */ void V_PostRender( void ) { + SCR_DrawNet(); + SCR_DrawFPS(); UI_Draw(); Con_DrawConsole(); re->EndFrame(); diff --git a/engine/client/client.h b/engine/client/client.h index 485b7c5b..7205da66 100644 --- a/engine/client/client.h +++ b/engine/client/client.h @@ -32,8 +32,10 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #define MAX_SERVERS 64 #define ColorIndex(c) (((c) - '0') & 7) -#define NUM_FOR_EDICT(e) ((int)((edict_t *)(e) - game.edicts)) -#define EDICT_NUM( num ) _EDICT_NUM( num, __FILE__, __LINE__ ) +#define NUM_FOR_EDICT(e) ((int)((edict_t *)(e) - cls.edicts)) +#define EDICT_NUM( num ) CL_EDICT_NUM( num, __FILE__, __LINE__ ) +#define STRING( offset ) CL_GetString( offset ) +#define MAKE_STRING(str) CL_AllocString( str ) //============================================================================= typedef struct frame_s @@ -75,19 +77,19 @@ typedef struct int parse_entities; // index (not anded off) into cl_parse_entities[] - usercmd_t cmds[CMD_BACKUP]; // each mesage will send several old cmds int cmd_number; - int predicted_origins[CMD_BACKUP][3]; // for debug comparing against server + usercmd_t cmds[CMD_BACKUP]; // each mesage will send several old cmds + int predicted_origins[CMD_BACKUP][3];// for debug comparing against server - float predicted_step; // for stair up smoothing + float predicted_step; // for stair up smoothing uint predicted_step_time; - vec3_t predicted_origin; // generated by CL_PredictMovement + vec3_t predicted_origin; // generated by CL_PredictMovement vec3_t predicted_angles; vec3_t prediction_error; - frame_t frame; // received from server - int surpressCount; // number of messages rate supressed + frame_t frame; // received from server + int surpressCount; // number of messages rate supressed frame_t frames[UPDATE_BACKUP]; // mouse current position @@ -105,34 +107,26 @@ typedef struct dword time; // this is the time value that the client // is rendering at. always <= cls.realtime - float lerpfrac; // between oldframe and frame + ref_params_t refdef; // shared refdef - refdef_t refdef; - - vec3_t v_forward, v_right, v_left, v_up; // set when refdef.angles is set - - // centerprint stuff + // misc 2d drawing stuff int centerPrintTime; int centerPrintCharWidth; int centerPrintY; char centerPrint[1024]; int centerPrintLines; - - bool make_levelshot; + bool need_levelshot; // // server state information // - int servercount; // server identification for prespawns int playernum; + int servercount; // server identification for prespawns char configstrings[MAX_CONFIGSTRINGS][CS_SIZE]; - // // locally derived information from server state - // cmodel_t *models[MAX_MODELS]; cmodel_t *worldmodel; - string_t edict_classnames[MAX_CLASSNAMES]; sound_t sound_precache[MAX_SOUNDS]; shader_t decal_shaders[MAX_DECALS]; @@ -168,7 +162,7 @@ typedef enum } dltype_t; // download type // cl_private_edict_t -struct ed_priv_s +struct cl_priv_s { int serverframe; // if not current, this ent isn't in the frame @@ -199,7 +193,7 @@ typedef enum { key_game, key_console, key_message, key_menu } keydest_t; typedef struct { - const char *name; + char name[CS_SIZE]; int number; // svc_ number int size; // if size == -1, size come from first byte after svcnum pfnUserMsgHook func; // user-defined function @@ -212,13 +206,6 @@ typedef struct int maxEntities; user_message_t *msg[MAX_USER_MESSAGES]; int numMessages; // actual count of user messages - - union - { - edict_t *edicts; // acess by edict number - void *vp; // acess by offset in bytes - }; - int hStringTable; // stringtable handle } clgame_static_t; @@ -234,6 +221,12 @@ typedef struct byte *mempool; // edicts pool byte *private; // client.dll private pool + union + { + edict_t *edicts; // acess by edict number + void *vp; // acess by offset in bytes + }; + int framecount; dword realtime; // always increasing, no clamping, etc float frametime; // seconds since last frame @@ -249,6 +242,7 @@ typedef struct shader_t consoleFont; // current console font shader_t clientFont; // current client font shader_t consoleBack; // console background + shader_t netIcon; // netIcon displayed bad network connection file_t *download; // file transfer from server string downloadname; @@ -273,7 +267,7 @@ typedef struct } client_static_t; extern client_static_t cls; -extern clgame_static_t game; +extern clgame_static_t clgame; /* ============================================================== @@ -282,7 +276,7 @@ SCREEN CONSTS ============================================================== */ -extern vrect_t scr_vrect; // position of render window +extern int scr_rect[4]; // position of render window extern vec4_t g_color_table[8]; // @@ -304,6 +298,7 @@ extern cvar_t *cl_pitchspeed; extern cvar_t *cl_envshot_size; extern cvar_t *cl_run; extern cvar_t *cl_font; +extern cvar_t *cl_neticon; extern cvar_t *cl_anglespeedkey; @@ -460,7 +455,7 @@ void CL_Stop_f( void ); void CL_InitClientProgs( void ); void CL_FreeClientProgs( void ); int CL_GetMaxClients( void ); -void CL_DrawHUD( void ); +void CL_DrawHUD( int state ); edict_t *CL_GetEdict( int entnum ); float *CL_FadeColor( float starttime, float endtime ); void CL_FreeEdicts( void ); @@ -471,22 +466,23 @@ void CL_FreeEdicts( void ); void CL_UnloadProgs( void ); bool CL_LoadProgs( const char *name ); void CL_ParseUserMessage( sizebuf_t *msg, int svc_num ); -void CL_PrepUserMessage( char *pszName, const int svc_num ); +void CL_LinkUserMessage( char *pszName, const int svc_num ); +void CL_SortUserMessages( void ); edict_t *CL_AllocEdict( void ); void CL_FreeEdict( edict_t *pEdict ); -string_t pfnAllocString( const char *szValue ); -const char *pfnGetString( string_t iString ); +string_t CL_AllocString( const char *szValue ); +const char *CL_GetString( string_t iString ); void pfnGetGameDir( char *szGetGameDir ); long pfnRandomLong( long lLow, long lHigh ); float pfnRandomFloat( float flLow, float flHigh ); byte* pfnLoadFile( const char *filename, int *pLength ); void pfnFreeFile( void *buffer ); -_inline edict_t *_EDICT_NUM( int n, const char *file, const int line ) +_inline edict_t *CL_EDICT_NUM( int n, const char *file, const int line ) { - if((n >= 0) && (n < game.maxEntities)) - return game.edicts + n; - Host_Error( "EDICT_NUM: bad number %i (called at %s:%i)\n", n, file, line ); + if((n >= 0) && (n < clgame.maxEntities)) + return cls.edicts + n; + Host_Error( "CL_EDICT_NUM: bad number %i (called at %s:%i)\n", n, file, line ); return NULL; } diff --git a/engine/common.h b/engine/common.h index ba57cd31..9d0bc1e4 100644 --- a/engine/common.h +++ b/engine/common.h @@ -144,14 +144,6 @@ PRVM INTERACTIONS ============================================================== */ char *ED_NewString( const char *string, byte *mempool ); - -#define NUM_FOR_EDICT(e) ((int)((edict_t *)(e) - game.edicts)) -#define EDICT_NUM( num ) _EDICT_NUM( num, __FILE__, __LINE__ ) - -// for constant strings -#define STRING( offset ) pfnGetString( offset ) -#define MAKE_STRING(str) pfnAllocString( str ) - #define prog vm->prog // global callback to vprogs.dll #define PRVM_EDICT_NUM( num ) _PRVM_EDICT_NUM( num, __FILE__, __LINE__ ) diff --git a/engine/common/engfuncs.c b/engine/common/engfuncs.c index 1a460d90..f4d6d07c 100644 --- a/engine/common/engfuncs.c +++ b/engine/common/engfuncs.c @@ -9,28 +9,6 @@ #include "const.h" #include "client.h" -/* -============= -pfnAllocString - -============= -*/ -string_t pfnAllocString( const char *szValue ) -{ - return StringTable_SetString( game.hStringTable, szValue ); -} - -/* -============= -pfnGetString - -============= -*/ -const char *pfnGetString( string_t iString ) -{ - return StringTable_GetString( game.hStringTable, iString ); -} - /* ============= pfnLoadFile @@ -1333,9 +1311,8 @@ void VM_drawmodel( void ) { float *size, *pos, *origin, *angles; const char *modname; - vrect_t rect; - static refdef_t refdef; int sequence; + static ref_params_t refdef; entity_state_t ent; static float frame; @@ -1353,11 +1330,13 @@ void VM_drawmodel( void ) memset( &ent, 0, sizeof( ent )); SCR_AdjustSize( &pos[0], &pos[1], &size[0], &size[1] ); - rect.x = pos[0]; rect.y = pos[1]; rect.width = size[0]; rect.height = size[1]; - Mem_Copy( &refdef.rect, &rect, sizeof(vrect_t)); + refdef.viewport[0] = pos[0]; + refdef.viewport[1] = pos[1]; + refdef.viewport[2] = size[0]; + refdef.viewport[3] = size[1]; refdef.fov_x = 50; - refdef.fov_y = V_CalcFov( refdef.fov_x, refdef.rect.width, refdef.rect.height ); + refdef.fov_y = V_CalcFov( refdef.fov_x, refdef.viewport[2], refdef.viewport[3] ); refdef.time = cls.realtime * 0.001f; refdef.oldtime = refdef.time - 0.005; refdef.rdflags = RDF_NOWORLDMODEL; diff --git a/engine/common/net_msg.h b/engine/common/net_msg.h index a19ccc77..8d6cf8a8 100644 --- a/engine/common/net_msg.h +++ b/engine/common/net_msg.h @@ -43,9 +43,6 @@ enum svc_ops_e { // user messages svc_bad = 0, // don't send! - svc_temp_entity, // client effects - svc_print, // [byte] id [string] null terminated string - svc_centerprint, // [string] to put in center of the screen // engine messages svc_nop = 201, // end of user messages @@ -62,6 +59,7 @@ enum svc_ops_e svc_frame, // server frame svc_sound, // svc_setangle, // [short short short] set the view angle to this absolute value + svc_print, // [byte] id [string] null terminated string }; // client to server diff --git a/engine/host.c b/engine/host.c index 4921ee03..00ddcb15 100644 --- a/engine/host.c +++ b/engine/host.c @@ -585,7 +585,7 @@ void Host_InitCommon( int argc, char **argv ) newcom.error = Host_Error; // check developer mode - if(FS_GetParmFromCmdLine("-dev", dev_level )) + if(FS_GetParmFromCmdLine( "-dev", dev_level )) host.developer = com.atoi(dev_level); Host_InitEvents(); diff --git a/engine/server/server.h b/engine/server/server.h index 92932d78..ffa1a10e 100644 --- a/engine/server/server.h +++ b/engine/server/server.h @@ -39,6 +39,11 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #define SPAWNFLAG_NOT_HARD 0x00000400 #define SPAWNFLAG_NOT_DEATHMATCH 0x00000800 +#define NUM_FOR_EDICT(e) ((int)((edict_t *)(e) - svgame.edicts)) +#define EDICT_NUM( num ) SV_EDICT_NUM( num, __FILE__, __LINE__ ) +#define STRING( offset ) SV_GetString( offset ) +#define MAKE_STRING(str) SV_AllocString( str ) + typedef enum { ss_dead, // no map loaded @@ -112,7 +117,6 @@ typedef struct sv_client_s edict_t *edict; // EDICT_NUM(clientnum+1) char name[32]; // extracted from userinfo, high bits masked - int messagelevel; // for filtering printed messages // The datagram is written to by sound calls, prints, temp ents, etc. // It can be harmlessly overflowed. @@ -143,7 +147,7 @@ typedef struct link_s } link_t; // sv_private_edict_t -struct ed_priv_s +struct sv_priv_s { link_t area; // linked to a division node or leaf struct sv_client_s *client; // filled for player ents @@ -157,6 +161,7 @@ struct ed_priv_s bool forceupdate; // physic_push force update bool suspended; // suspended in air toss object bool linked; // passed through SV_LinkEdict + bool stuck; // entity stucked in brush vec3_t water_origin; // step old origin vec3_t moved_origin; // push old origin @@ -194,9 +199,16 @@ typedef struct typedef struct { + // user messages stuff int msg_sizes[MAX_USER_MESSAGES]; // user messages bounds checker - int msg_leftsize; // left in bytes + int msg_size_index; // write message size at this pos in sizebuf + int msg_realsize; // left in bytes int msg_index; // for debug messages + int msg_dest; // msg destination ( MSG_ONE, MSG_ALL etc ) + edict_t *msg_ent; + vec3_t msg_org; + + void *hInstance; // pointer to server.dll union { @@ -204,6 +216,11 @@ typedef struct void *vp; // acess by offset in bytes }; + globalvars_t *globals; // server globals + DLL_FUNCTIONS dllFuncs; // dll exported funcs + byte *mempool; // edicts pool + byte *private; // server.dll private pool + // library exports table word *ordinals; dword *funcs; @@ -220,16 +237,6 @@ typedef struct dword realtime; // always increasing, no clamping, etc float timeleft; // frametime * game_frames - void *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. @@ -251,8 +258,8 @@ 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 svgame_static_t game; // persistant game info extern server_t sv; // local server +extern svgame_static_t svgame; // persistant game info extern cvar_t *sv_paused; extern cvar_t *sv_noreload; // don't reload level state when reentering @@ -332,12 +339,11 @@ bool SV_movestep( edict_t *ent, vec3_t move, bool relink, bool noenemy, bool set // // sv_send.c // -void SV_SendClientMessages (void); +void SV_SendClientMessages( void ); void SV_AmbientSound( edict_t *entity, int soundindex, float volume, float attenuation ); -void SV_StartSound (vec3_t origin, edict_t *entity, int channel, int index, float vol, float attn, float timeofs); -void SV_ClientPrintf (sv_client_t *cl, int level, char *fmt, ...); -void SV_BroadcastPrintf (int level, char *fmt, ...); -void SV_BroadcastCommand (char *fmt, ...); +void SV_ClientPrintf( sv_client_t *cl, char *fmt, ... ); +void SV_BroadcastPrintf( char *fmt, ... ); +void SV_BroadcastCommand( char *fmt, ... ); // // sv_client.c @@ -367,8 +373,9 @@ void SV_Error (char *error, ...); // // sv_game.c // -bool SV_LoadProgs( const char *name ); +void SV_LoadProgs( const char *name ); void SV_UnloadProgs( void ); +void SV_FreeEdicts( void ); void SV_InitEdict( edict_t *pEdict ); void SV_ConfigString (int index, const char *val); void SV_SetModel (edict_t *ent, const char *name); @@ -379,19 +386,19 @@ 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 ); -string_t pfnAllocString( const char *szValue ); -const char *pfnGetString( string_t iString ); +string_t SV_AllocString( const char *szValue ); +const char *SV_GetString( string_t iString ); void pfnGetGameDir( char *szGetGameDir ); long pfnRandomLong( long lLow, long lHigh ); float pfnRandomFloat( float flLow, float flHigh ); byte* pfnLoadFile( const char *filename, int *pLength ); void pfnFreeFile( void *buffer ); -_inline edict_t *_EDICT_NUM( int n, const char * file, const int line ) +_inline edict_t *SV_EDICT_NUM( int n, const char * file, const int line ) { - if((n >= 0) && (n < svs.globals->maxEntities)) - return game.edicts + n; - Host_Error( "EDICT_NUM: bad number %i (called at %s:%i)\n", n, file, line ); + if((n >= 0) && (n < svgame.globals->maxEntities)) + return svgame.edicts + n; + Host_Error( "SV_EDICT_NUM: bad number %i (called at %s:%i)\n", n, file, line ); return NULL; } diff --git a/engine/server/sv_client.c b/engine/server/sv_client.c index 0161ab81..b481b77f 100644 --- a/engine/server/sv_client.c +++ b/engine/server/sv_client.c @@ -174,7 +174,7 @@ gotnewcl: edictnum = (newcl - svs.clients) + 1; ent = EDICT_NUM( edictnum ); - ent->pvEngineData->client = newcl; + ent->pvServerData->client = newcl; newcl->edict = ent; newcl->challenge = challenge; // save challenge for checksumming @@ -226,8 +226,8 @@ bool SV_ClientConnect( edict_t *ent, char *userinfo ) ent->v.flags = 0; MsgDev(D_NOTE, "SV_ClientConnect()\n"); - svs.globals->time = sv.time; - result = svs.dllFuncs.pfnClientConnect( ent, userinfo ); + svgame.globals->time = sv.time; + result = svgame.dllFuncs.pfnClientConnect( ent, userinfo ); return result; } @@ -251,8 +251,8 @@ void SV_DropClient( sv_client_t *drop ) MSG_WriteByte( &drop->netchan.message, svc_disconnect ); // let the game known about client state - svs.globals->time = sv.time; - svs.dllFuncs.pfnClientDisconnect( drop->edict ); + svgame.globals->time = sv.time; + svgame.dllFuncs.pfnClientDisconnect( drop->edict ); SV_FreeEdict( drop->edict ); if( drop->download ) drop->download = NULL; @@ -302,7 +302,6 @@ void SV_FlushRedirect( netadr_t adr, int dest, char *buf ) case RD_CLIENT: if( !sv_client ) return; // client not set MSG_WriteByte( &sv_client->netchan.message, svc_print ); - MSG_WriteByte( &sv_client->netchan.message, HUD_PRINTCONSOLE ); MSG_WriteString( &sv_client->netchan.message, buf ); break; case RD_NONE: @@ -479,31 +478,31 @@ void SV_PutClientInServer( edict_t *ent ) sv_client_t *client; index = NUM_FOR_EDICT( ent ) - 1; - client = ent->pvEngineData->client; + client = ent->pvServerData->client; - svs.globals->time = sv.time; + svgame.globals->time = sv.time; ent->free = false; - ent->pvEngineData->s.ed_type = ED_CLIENT; // init edict type + ent->pvServerData->s.ed_type = ED_CLIENT; // init edict type if( !sv.loadgame ) { // fisrt entering - svs.dllFuncs.pfnClientPutInServer( ent ); + svgame.dllFuncs.pfnClientPutInServer( ent ); ent->v.v_angle[ROLL] = 0; // cut off any camera rolling ent->v.origin[2] += 1; // make sure off ground } - 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]); + ent->pvServerData->s.fov = 90; // FIXME: get from qc + ent->pvServerData->s.fov = bound(1, ent->pvServerData->s.fov, 160); + ent->pvServerData->s.health = ent->v.health; + ent->pvServerData->s.classname = SV_ClassIndex( STRING( ent->v.classname )); + ent->pvServerData->s.pmodel.index = SV_ModelIndex( STRING( ent->v.weaponmodel )); + VectorCopy( ent->v.origin, ent->pvServerData->s.origin ); + VectorCopy( ent->v.v_angle, ent->pvServerData->s.viewangles ); + for( i = 0; i < 3; i++ ) ent->pvServerData->s.delta_angles[i] = ANGLE2SHORT(ent->v.v_angle[i]); SV_LinkEdict( ent ); // m_pmatrix calculated here, so we need call this before pe->CreatePlayer - ent->pvEngineData->physbody = pe->CreatePlayer( ent, SV_GetModelPtr( ent ), ent->v.origin, ent->v.m_pmatrix ); + ent->pvServerData->physbody = pe->CreatePlayer( ent, SV_GetModelPtr( ent ), ent->v.origin, ent->v.m_pmatrix ); } /* @@ -783,10 +782,6 @@ void SV_UserinfoChanged( sv_client_t *cl ) else cl->rate = 3000; } - // msg command - val = Info_ValueForKey( cl->userinfo, "msg" ); - if( com.strlen( val )) cl->messagelevel = com.atoi( val ); - // maintain the IP information // this is set in SV_DirectConnect ( directly on the server, not transmitted ), // may be lost when client updates it's userinfo the banning code relies on this being consistently present @@ -810,9 +805,9 @@ static void SV_UpdateUserinfo_f( sv_client_t *cl ) SV_UserinfoChanged( cl ); // call prog code to allow overrides - svs.globals->time = sv.time; - svs.globals->frametime = sv.frametime; - svs.dllFuncs.pfnClientUserInfoChanged( cl->edict, cl->userinfo ); + svgame.globals->time = sv.time; + svgame.globals->frametime = sv.frametime; + svgame.dllFuncs.pfnClientUserInfoChanged( cl->edict, cl->userinfo ); } ucmd_t ucmds[] = @@ -851,9 +846,9 @@ void SV_ExecuteClientCommand( sv_client_t *cl, char *s ) if( !u->name && sv.state == ss_active ) { // custom client commands - svs.globals->time = sv.time; - svs.globals->frametime = sv.frametime; - svs.dllFuncs.pfnClientCommand( cl->edict ); + svgame.globals->time = sv.time; + svgame.globals->frametime = sv.frametime; + svgame.dllFuncs.pfnClientCommand( cl->edict ); } } @@ -1012,15 +1007,15 @@ void SV_ApplyClientMove( sv_client_t *cl, usercmd_t *cmd ) // circularly clamp the angles with deltas for( i = 0; i < 3; i++ ) { - temp = cmd->angles[i] + ent->pvEngineData->s.delta_angles[i]; - ent->pvEngineData->s.viewangles[i] = SHORT2ANGLE( temp ); + temp = cmd->angles[i] + ent->pvServerData->s.delta_angles[i]; + ent->pvServerData->s.viewangles[i] = SHORT2ANGLE( temp ); } // don't let the player look up or down more than 90 degrees - 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; + if( ent->pvServerData->s.viewangles[PITCH] > 89 && ent->pvServerData->s.viewangles[PITCH] < 180 ) + ent->pvServerData->s.viewangles[PITCH] = 89; + else if( ent->pvServerData->s.viewangles[PITCH] < 271 && ent->pvServerData->s.viewangles[PITCH] >= 180 ) + ent->pvServerData->s.viewangles[PITCH] = 271; // test if( ent->v.flags & FL_DUCKING ) @@ -1030,9 +1025,9 @@ void SV_ApplyClientMove( sv_client_t *cl, usercmd_t *cmd ) cmd->upmove *= 0.333; } - 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 ); + VectorCopy( ent->pvServerData->s.viewangles, cl->edict->v.v_angle ); + VectorCopy( ent->pvServerData->s.viewangles, cl->edict->v.angles ); + VectorCopy( ent->v.view_ofs, cl->edict->pvServerData->s.viewoffset ); } void SV_DropPunchAngle( sv_client_t *cl ) @@ -1326,8 +1321,8 @@ void SV_ClientThink( sv_client_t *cl, usercmd_t *cmd ) SV_AirMove( cl, &cl->cmd ); SV_CheckVelocity( cl->edict ); - VectorCopy( cl->edict->v.origin, cl->edict->pvEngineData->s.origin ); - VectorCopy( cl->edict->v.velocity, cl->edict->pvEngineData->s.velocity ); + VectorCopy( cl->edict->v.origin, cl->edict->pvServerData->s.origin ); + VectorCopy( cl->edict->v.velocity, cl->edict->pvServerData->s.velocity ); } /* @@ -1386,8 +1381,8 @@ static void SV_UserMove( sv_client_t *cl, sizebuf_t *msg ) if( !sv_paused->value ) { frametime[0] = sv.frametime; - frametime[1] = svs.globals->frametime; - svs.globals->frametime = sv.frametime = newcmd.msec * 0.001f; + frametime[1] = svgame.globals->frametime; + svgame.globals->frametime = sv.frametime = newcmd.msec * 0.001f; net_drop = cl->netchan.dropped; if( net_drop < 20 ) @@ -1403,7 +1398,7 @@ static void SV_UserMove( sv_client_t *cl, sizebuf_t *msg ) SV_Physics_ClientMove( cl, &newcmd ); } sv.frametime = frametime[0]; - svs.globals->frametime = frametime[1]; + svgame.globals->frametime = frametime[1]; cl->lastcmd = newcmd; } diff --git a/engine/server/sv_cmds.c b/engine/server/sv_cmds.c index de02f584..ebdbc4c9 100644 --- a/engine/server/sv_cmds.c +++ b/engine/server/sv_cmds.c @@ -16,20 +16,16 @@ SV_ClientPrintf Sends text across to be displayed if the level passes ================= */ -void SV_ClientPrintf( sv_client_t *cl, int level, char *fmt, ... ) +void SV_ClientPrintf( sv_client_t *cl, char *fmt, ... ) { va_list argptr; char string[MAX_SYSPATH]; - if( level < cl->messagelevel ) - return; - va_start( argptr, fmt ); com.vsprintf( string, fmt, argptr ); va_end( argptr ); MSG_WriteByte( &cl->netchan.message, svc_print ); - MSG_WriteByte( &cl->netchan.message, level ); MSG_WriteString( &cl->netchan.message, string ); } @@ -40,7 +36,7 @@ SV_BroadcastPrintf Sends text to all active clients ================= */ -void SV_BroadcastPrintf( int level, char *fmt, ... ) +void SV_BroadcastPrintf( char *fmt, ... ) { char string[MAX_SYSPATH]; va_list argptr; @@ -55,10 +51,8 @@ void SV_BroadcastPrintf( int level, char *fmt, ... ) if( host.type == HOST_DEDICATED ) Msg( "%s", string ); for( i = 0, cl = svs.clients; i < Host_MaxClients(); i++, cl++ ) { - if( level < cl->messagelevel) continue; if( cl->state != cs_spawned ) continue; MSG_WriteByte( &cl->netchan.message, svc_print ); - MSG_WriteByte( &cl->netchan.message, level ); MSG_WriteString( &cl->netchan.message, string ); } } @@ -370,8 +364,8 @@ void SV_Kick_f( void ) } if(!SV_SetPlayer()) return; - SV_BroadcastPrintf( HUD_PRINTCONSOLE, "%s was kicked\n", sv_client->name ); - SV_ClientPrintf( sv_client, HUD_PRINTCONSOLE, "You were kicked from the game\n" ); + SV_BroadcastPrintf( "%s was kicked\n", sv_client->name ); + SV_ClientPrintf( sv_client, "You were kicked from the game\n" ); SV_DropClient( sv_client ); sv_client->lastmessage = svs.realtime; // min case there is a funny zombie } @@ -454,7 +448,7 @@ void SV_ConSay_f( void ) for (i = 0, client = svs.clients; i < Host_MaxClients(); i++, client++) { if( client->state != cs_spawned ) continue; - SV_ClientPrintf( client, HUD_PRINTTALK, "%s\n", text ); + SV_ClientPrintf( client, "%s\n", text ); } } diff --git a/engine/server/sv_frame.c b/engine/server/sv_frame.c index ca7f576d..11924da7 100644 --- a/engine/server/sv_frame.c +++ b/engine/server/sv_frame.c @@ -50,46 +50,46 @@ void SV_UpdateEntityState( edict_t *ent ) int i; // copy progs values to state - ent->pvEngineData->s.number = ent->serialnumber; - ent->pvEngineData->s.solid = ent->pvEngineData->solid; + ent->pvServerData->s.number = ent->serialnumber; + ent->pvServerData->s.solid = ent->pvServerData->solid; - 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.model.scale = ent->v.scale; // shared client and render flags - VectorCopy( ent->v.rendercolor, ent->pvEngineData->s.rendercolor ); + VectorCopy (ent->v.origin, ent->pvServerData->s.origin); + VectorCopy (ent->v.angles, ent->pvServerData->s.angles); + ent->pvServerData->s.model.index = ent->v.modelindex; + ent->pvServerData->s.health = ent->v.health; + ent->pvServerData->s.model.skin = ent->v.skin; // studio model skin + ent->pvServerData->s.model.body = ent->v.body; // studio model submodel + ent->pvServerData->s.model.frame = ent->v.frame; // any model current frame + ent->pvServerData->s.model.gaitsequence = ent->v.gaitsequence;// player sequence, that will be playing on client + ent->pvServerData->s.effects = ent->v.effects; // shared client and render flags + ent->pvServerData->s.renderfx = ent->v.renderfx; // renderer flags + ent->pvServerData->s.rendermode = ent->v.rendermode; // rendering mode + ent->pvServerData->s.renderamt = ent->v.renderamt; // alpha value + ent->pvServerData->s.model.framerate = ent->v.framerate; + ent->pvServerData->s.model.animtime = (int)(1000.0 * ent->v.animtime) * 0.001; // sequence time + ent->pvServerData->s.model.scale = ent->v.scale; // shared client and render flags + VectorCopy( ent->v.rendercolor, ent->pvServerData->s.rendercolor ); // studio model sequence - if( ent->v.sequence != -1 ) ent->pvEngineData->s.model.sequence = ent->v.sequence; + if( ent->v.sequence != -1 ) ent->pvServerData->s.model.sequence = ent->v.sequence; for( i = 0; i < 16; i++ ) { // copy blendings and bone ctrls - ent->pvEngineData->s.model.blending[i] = ent->v.blending[i]; - ent->pvEngineData->s.model.controller[i] = ent->v.controller[i]; + ent->pvServerData->s.model.blending[i] = ent->v.blending[i]; + ent->pvServerData->s.model.controller[i] = ent->v.controller[i]; } - if( ent->pvEngineData->s.ed_type != ED_VIEWMODEL ) - ent->pvEngineData->s.movetype = ent->v.movetype; + if( ent->pvServerData->s.ed_type != ED_VIEWMODEL ) + ent->pvServerData->s.movetype = ent->v.movetype; - if( ent->pvEngineData->s.ed_type == ED_MOVER || ent->pvEngineData->s.ed_type == ED_BSPBRUSH ) + if( ent->pvServerData->s.ed_type == ED_MOVER || ent->pvServerData->s.ed_type == ED_BSPBRUSH ) { // these needs to right calculate direction of scroll texture - VectorCopy( ent->v.movedir, ent->pvEngineData->s.velocity ); + VectorCopy( ent->v.movedir, ent->pvServerData->s.velocity ); } - if( ent->pvEngineData->s.ed_type == ED_VIEWMODEL ) + if( ent->pvServerData->s.ed_type == ED_VIEWMODEL ) { if( !ent->v.aiment ) return; // no aiment @@ -98,32 +98,32 @@ void SV_UpdateEntityState( edict_t *ent ) // update both arrays, because viewmodel are hidden for qc-coders ent->v.modelindex = SV_ModelIndex( STRING( client->v.viewmodel )); - ent->pvEngineData->s.aiment = NUM_FOR_EDICT( client ); // viewmodel parent - 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->pvServerData->s.aiment = NUM_FOR_EDICT( client ); // viewmodel parent + ent->pvServerData->s.model.index = ent->v.modelindex; + ent->pvServerData->s.model.frame = ent->v.frame = client->v.weaponframe; + ent->pvServerData->s.model.body = ent->v.body = client->v.weaponbody; + ent->pvServerData->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 + if( ent->v.sequence != -1 ) ent->pvServerData->s.model.sequence = ent->v.sequence; + ent->pvServerData->s.model.colormap = ent->v.colormap = client->v.colormap; + ent->pvServerData->s.effects |= EF_MINLIGHT; // always have some light } - else if( ent->pvEngineData->s.ed_type == ED_CLIENT ) + else if( ent->pvServerData->s.ed_type == ED_CLIENT ) { if( ent->v.fixangle ) { // FIXME: set angles correctly for( i = 0; i < 2; i++ ) - ent->pvEngineData->s.delta_angles[i] = ANGLE2SHORT( ent->pvEngineData->s.angles[i] ); - VectorClear( ent->pvEngineData->s.angles ); - VectorClear( ent->pvEngineData->s.viewangles ); + ent->pvServerData->s.delta_angles[i] = ANGLE2SHORT( ent->pvServerData->s.angles[i] ); + VectorClear( ent->pvServerData->s.angles ); + VectorClear( ent->pvServerData->s.viewangles ); VectorClear( ent->v.v_angle ); // and clear fixangle for the next frame ent->v.fixangle = 0; } } - else if( ent->pvEngineData->s.ed_type == ED_AMBIENT ) + else if( ent->pvServerData->s.ed_type == ED_AMBIENT ) { if( ent->v.solid == SOLID_TRIGGER ) { @@ -131,10 +131,10 @@ void SV_UpdateEntityState( edict_t *ent ) // NOTE: no reason to compute this shit on the client - save bandwidth VectorAverage( ent->v.mins, ent->v.maxs, midPoint ); - VectorAdd( ent->pvEngineData->s.origin, midPoint, ent->pvEngineData->s.origin ); + VectorAdd( ent->pvServerData->s.origin, midPoint, ent->pvServerData->s.origin ); } } - else if( ent->pvEngineData->s.ed_type == ED_MOVER ) + else if( ent->pvServerData->s.ed_type == ED_MOVER ) { // FIXME: send mins\maxs for sound spatialization and entity prediction ? } @@ -145,7 +145,7 @@ void SV_UpdateEntityState( edict_t *ent ) SV_AddEntToSnapshot =============== */ -static void SV_AddEntToSnapshot( ed_priv_t *svent, edict_t *ent, sv_ents_t *ents ) +static void SV_AddEntToSnapshot( sv_priv_t *svent, edict_t *ent, sv_ents_t *ents ) { // if we have already added this entity to this snapshot, don't add again if( svent->framenum == sv.net_framenum ) return; @@ -240,7 +240,7 @@ static void SV_AddEntitiesToPacket( vec3_t origin, client_frame_t *frame, sv_ent { int l, e, i; edict_t *ent; - ed_priv_t *svent; + sv_priv_t *svent; int leafnum; byte *clientphs; byte *bitvector; @@ -263,7 +263,7 @@ 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 < svs.globals->numEntities; e++ ) + for( e = 1; e < svgame.globals->numEntities; e++ ) { ent = EDICT_NUM( e ); if( ent->free ) continue; @@ -276,23 +276,23 @@ static void SV_AddEntitiesToPacket( vec3_t origin, client_frame_t *frame, sv_ent // 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->pvEngineData->s.ed_type == ED_VIEWMODEL ) + if( ent->pvServerData->s.ed_type == ED_VIEWMODEL ) force = true; // NOTE: client index on client expected that entity will be valid - if( sv_newprotocol->integer && ent->pvEngineData->s.ed_type == ED_CLIENT ) + if( sv_newprotocol->integer && ent->pvServerData->s.ed_type == ED_CLIENT ) force = true; // never send entities that aren't linked in - if( !ent->pvEngineData->linked && !force ) continue; + if( !ent->pvServerData->linked && !force ) continue; if( ent->serialnumber != e ) { - MsgDev( D_WARN, "fixing ent->pvEngineData->serialnumber\n"); + MsgDev( D_WARN, "fixing ent->pvServerData->serialnumber\n"); ent->serialnumber = e; } - svent = ent->pvEngineData; + svent = ent->pvServerData; // quick reject by type switch( svent->s.ed_type ) @@ -311,11 +311,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->pvEngineData->areanum )) + if( !pe->AreasConnected( clientarea, ent->pvServerData->areanum )) { // doors can legally straddle two areas, so // we may need to check another one - if( !pe->AreasConnected( clientarea, ent->pvEngineData->areanum2 )) + if( !pe->AreasConnected( clientarea, ent->pvServerData->areanum2 )) continue; // blocked by a door } } @@ -344,12 +344,12 @@ static void SV_AddEntitiesToPacket( vec3_t origin, client_frame_t *frame, sv_ent if( bitvector[l>>3] & (1<<(l & 7))) break; } - if( i == ent->pvEngineData->num_clusters ) + if( i == ent->pvServerData->num_clusters ) continue; // not visible } } - if( ent->pvEngineData->s.ed_type == ED_AMBIENT ) + if( ent->pvServerData->s.ed_type == ED_AMBIENT ) { vec3_t delta, entorigin; float len; @@ -476,11 +476,11 @@ 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->pvEngineData->client ) return; // not in game yet + if( !clent->pvServerData->client ) return; // not in game yet // find the client's PVS - VectorCopy( clent->pvEngineData->s.origin, org ); - VectorAdd( org, clent->pvEngineData->s.viewoffset, org ); + VectorCopy( clent->pvServerData->s.origin, org ); + VectorAdd( org, clent->pvServerData->s.viewoffset, org ); if( sv_newprotocol->integer ) { @@ -490,8 +490,8 @@ void SV_BuildClientFrame( sv_client_t *cl ) else { // grab the current player state - cl->edict->pvEngineData->framenum = sv.net_framenum; - frame->ps = clent->pvEngineData->s; + cl->edict->pvServerData->framenum = sv.net_framenum; + frame->ps = clent->pvServerData->s; } // add all the entities directly visible to the eye, which @@ -514,7 +514,7 @@ void SV_BuildClientFrame( sv_client_t *cl ) // add it to the circular client_entities array state = &svs.client_entities[svs.next_client_entities % svs.num_client_entities]; - *state = ent->pvEngineData->s; + *state = ent->pvServerData->s; svs.next_client_entities++; // this should never hit, map should always be restarted first in SV_Frame @@ -626,7 +626,7 @@ void SV_SendClientMessages( void ) { MSG_Clear( &cl->netchan.message ); MSG_Clear( &cl->datagram ); - SV_BroadcastPrintf( HUD_PRINTCONSOLE, "%s overflowed\n", cl->name ); + SV_BroadcastPrintf( "%s overflowed\n", cl->name ); SV_DropClient( cl ); } diff --git a/engine/server/sv_game.c b/engine/server/sv_game.c index 22c66f00..5e5c97b2 100644 --- a/engine/server/sv_game.c +++ b/engine/server/sv_game.c @@ -27,18 +27,18 @@ void Sys_FreeNameFuncGlobals( void ) { int i; - if( game.ordinals ) Mem_Free( game.ordinals ); - if( game.funcs) Mem_Free( game.funcs); + if( svgame.ordinals ) Mem_Free( svgame.ordinals ); + if( svgame.funcs) Mem_Free( svgame.funcs); - for( i = 0; i < game.num_ordinals; i++ ) + for( i = 0; i < svgame.num_ordinals; i++ ) { - if( game.names[i] ) - Mem_Free( game.names[i] ); + if( svgame.names[i] ) + Mem_Free( svgame.names[i] ); } - game.num_ordinals = 0; - game.ordinals = NULL; - game.funcs = NULL; + svgame.num_ordinals = 0; + svgame.ordinals = NULL; + svgame.funcs = NULL; } char *Sys_GetMSVCName( const char *in_name ) @@ -52,12 +52,12 @@ char *Sys_GetMSVCName( const char *in_name ) int len = pos - in_name; // strip off the leading '?' - out_name = com.stralloc( svs.private, in_name + 1, __FILE__, __LINE__ ); + out_name = com.stralloc( svgame.private, in_name + 1, __FILE__, __LINE__ ); out_name[len-1] = 0; // terminate string at the "@@" return out_name; } } - return com.stralloc( svs.private, in_name, __FILE__, __LINE__ ); + return com.stralloc( svgame.private, in_name, __FILE__, __LINE__ ); } bool Sys_LoadSymbols( const char *filename ) @@ -79,8 +79,8 @@ bool Sys_LoadSymbols( const char *filename ) dword *p_Names = NULL; int i, index; - for( i = 0; i < game.num_ordinals; i++ ) - game.names[i] = NULL; + for( i = 0; i < svgame.num_ordinals; i++ ) + svgame.names[i] = NULL; f = FS_Open( filename, "rb" ); if( !f ) @@ -189,9 +189,9 @@ bool Sys_LoadSymbols( const char *filename ) return false; } - game.num_ordinals = export_directory.NumberOfNames; // also number of ordinals + svgame.num_ordinals = export_directory.NumberOfNames; // also number of ordinals - if( game.num_ordinals > MAX_SYSPATH ) + if( svgame.num_ordinals > MAX_SYSPATH ) { MsgDev( D_ERROR, "Sys_LoadSymbols: %s too many exports\n", filename ); FS_Close( f ); @@ -207,9 +207,9 @@ bool Sys_LoadSymbols( const char *filename ) return false; } - game.ordinals = Z_Malloc( game.num_ordinals * sizeof( word )); + svgame.ordinals = Z_Malloc( svgame.num_ordinals * sizeof( word )); - if( FS_Read( f, game.ordinals, game.num_ordinals * sizeof( word )) != (game.num_ordinals * sizeof( word ))) + if( FS_Read( f, svgame.ordinals, svgame.num_ordinals * sizeof( word )) != (svgame.num_ordinals * sizeof( word ))) { Sys_FreeNameFuncGlobals(); MsgDev( D_ERROR, "Sys_LoadSymbols: %s error during reading ordinals table\n", filename ); @@ -225,9 +225,9 @@ bool Sys_LoadSymbols( const char *filename ) return false; } - game.funcs = Z_Malloc( game.num_ordinals * sizeof( dword )); + svgame.funcs = Z_Malloc( svgame.num_ordinals * sizeof( dword )); - if( FS_Read( f, game.funcs, game.num_ordinals * sizeof( dword )) != (game.num_ordinals * sizeof( dword ))) + if( FS_Read( f, svgame.funcs, svgame.num_ordinals * sizeof( dword )) != (svgame.num_ordinals * sizeof( dword ))) { Sys_FreeNameFuncGlobals(); MsgDev( D_ERROR, "Sys_LoadSymbols: %s error during reading export address section\n", filename ); @@ -245,9 +245,9 @@ bool Sys_LoadSymbols( const char *filename ) return false; } - p_Names = Z_Malloc( game.num_ordinals * sizeof( dword )); + p_Names = Z_Malloc( svgame.num_ordinals * sizeof( dword )); - if( FS_Read( f, p_Names, game.num_ordinals * sizeof( dword )) != (game.num_ordinals * sizeof( dword ))) + if( FS_Read( f, p_Names, svgame.num_ordinals * sizeof( dword )) != (svgame.num_ordinals * sizeof( dword ))) { Sys_FreeNameFuncGlobals(); if( p_Names ) Mem_Free( p_Names ); @@ -256,7 +256,7 @@ bool Sys_LoadSymbols( const char *filename ) return false; } - for( i = 0; i < game.num_ordinals; i++ ) + for( i = 0; i < svgame.num_ordinals; i++ ) { name_offset = p_Names[i] - edata_delta; @@ -265,13 +265,13 @@ bool Sys_LoadSymbols( const char *filename ) if( FS_Seek( f, name_offset, SEEK_SET ) != -1 ) { Sys_FsGetString( f, function_name ); - game.names[i] = Sys_GetMSVCName( function_name ); + svgame.names[i] = Sys_GetMSVCName( function_name ); } else break; } } - if( i != game.num_ordinals ) + if( i != svgame.num_ordinals ) { Sys_FreeNameFuncGlobals(); if( p_Names ) Mem_Free( p_Names ); @@ -281,15 +281,15 @@ bool Sys_LoadSymbols( const char *filename ) } FS_Close( f ); - for( i = 0; i < game.num_ordinals; i++ ) + for( i = 0; i < svgame.num_ordinals; i++ ) { - if( !com.strcmp( "GiveFnptrsToDll", game.names[i] )) + if( !com.strcmp( "GiveFnptrsToDll", svgame.names[i] )) { void *fn_offset; - index = game.ordinals[i]; - fn_offset = (void *)Com_GetProcAddress( svs.game, "GiveFnptrsToDll" ); - game.funcBase = (dword)(fn_offset) - game.funcs[index]; + index = svgame.ordinals[i]; + fn_offset = (void *)Com_GetProcAddress( svgame.hInstance, "GiveFnptrsToDll" ); + svgame.funcBase = (dword)(fn_offset) - svgame.funcs[index]; break; } } @@ -406,21 +406,21 @@ void SV_CopyTraceResult( TraceResult *out, trace_t trace ) void SV_CopyTraceToGlobal( trace_t *trace ) { - svs.globals->trace_allsolid = trace->allsolid; - svs.globals->trace_startsolid = trace->startsolid; - svs.globals->trace_startstuck = trace->startstuck; - svs.globals->trace_contents = trace->contents; - svs.globals->trace_start_contents = trace->startcontents; - svs.globals->trace_fraction = trace->fraction; - svs.globals->trace_plane_dist = trace->plane.dist; - svs.globals->trace_ent = trace->ent; - VectorCopy( trace->endpos, svs.globals->trace_endpos ); - VectorCopy( trace->plane.normal, svs.globals->trace_plane_normal ); + svgame.globals->trace_allsolid = trace->allsolid; + svgame.globals->trace_startsolid = trace->startsolid; + svgame.globals->trace_startstuck = trace->startstuck; + svgame.globals->trace_contents = trace->contents; + svgame.globals->trace_start_contents = trace->startcontents; + svgame.globals->trace_fraction = trace->fraction; + svgame.globals->trace_plane_dist = trace->plane.dist; + svgame.globals->trace_ent = trace->ent; + VectorCopy( trace->endpos, svgame.globals->trace_endpos ); + VectorCopy( trace->plane.normal, svgame.globals->trace_plane_normal ); if( trace->surface ) - svs.globals->trace_texture = trace->surface->name; - else svs.globals->trace_texture = NULL; - svs.globals->trace_hitgroup = trace->hitgroup; + svgame.globals->trace_texture = trace->surface->name; + else svgame.globals->trace_texture = NULL; + svgame.globals->trace_hitgroup = trace->hitgroup; } static trace_t SV_TraceToss( edict_t *tossent, edict_t *ignore) @@ -494,21 +494,21 @@ bool SV_CheckForPhysobject( edict_t *ent ) void SV_CreatePhysBody( edict_t *ent ) { if( !SV_CheckForPhysobject( ent )) return; - ent->pvEngineData->physbody = pe->CreateBody( ent, SV_GetModelPtr(ent), ent->v.origin, ent->v.m_pmatrix, ent->v.solid, ent->v.movetype ); + ent->pvServerData->physbody = pe->CreateBody( ent, SV_GetModelPtr(ent), ent->v.origin, ent->v.m_pmatrix, ent->v.solid, ent->v.movetype ); - pe->SetParameters( ent->pvEngineData->physbody, SV_GetModelPtr(ent), 0, ent->v.mass ); + pe->SetParameters( ent->pvServerData->physbody, SV_GetModelPtr(ent), 0, ent->v.mass ); } void SV_SetPhysForce( edict_t *ent ) { if( !SV_CheckForPhysobject( ent )) return; - pe->SetForce( ent->pvEngineData->physbody, ent->v.velocity, ent->v.avelocity, ent->v.force, ent->v.torque ); + pe->SetForce( ent->pvServerData->physbody, ent->v.velocity, ent->v.avelocity, ent->v.force, ent->v.torque ); } void SV_SetMassCentre( edict_t *ent ) { if( !SV_CheckForPhysobject( ent )) return; - pe->SetMassCentre( ent->pvEngineData->physbody, ent->v.m_pcentre ); + pe->SetMassCentre( ent->pvServerData->physbody, ent->v.m_pcentre ); } void SV_SetModel( edict_t *ent, const char *name ) @@ -622,12 +622,12 @@ bool SV_EntitiesIn( bool mode, vec3_t v1, vec3_t v2 ) void SV_InitEdict( edict_t *pEdict ) { Com_Assert( pEdict == NULL ); - Com_Assert( pEdict->pvServerData != NULL ); + Com_Assert( pEdict->pvPrivateData != NULL ); pEdict->v.pContainingEntity = pEdict; // make cross-links for consistency - pEdict->pvEngineData = (ed_priv_t *)Mem_Alloc( svs.mempool, sizeof( ed_priv_t )); - pEdict->pvServerData = NULL; // will be alloced later by pfnAllocPrivateData - pEdict->serialnumber = pEdict->pvEngineData->s.number = NUM_FOR_EDICT( pEdict ); + pEdict->pvServerData = (sv_priv_t *)Mem_Alloc( svgame.mempool, sizeof( sv_priv_t )); + pEdict->pvPrivateData = NULL; // will be alloced later by pfnAllocPrivateData + pEdict->serialnumber = pEdict->pvServerData->s.number = NUM_FOR_EDICT( pEdict ); pEdict->free = false; } @@ -638,14 +638,14 @@ void SV_FreeEdict( edict_t *pEdict ) // unlink from world SV_UnlinkEdict( pEdict ); - pe->RemoveBody( pEdict->pvEngineData->physbody ); + pe->RemoveBody( pEdict->pvServerData->physbody ); - if( pEdict->pvEngineData ) Mem_Free( pEdict->pvEngineData ); if( pEdict->pvServerData ) Mem_Free( pEdict->pvServerData ); + if( pEdict->pvPrivateData ) Mem_Free( pEdict->pvPrivateData ); Mem_Set( &pEdict->v, 0, sizeof( entvars_t )); - pEdict->pvEngineData = NULL; pEdict->pvServerData = NULL; + pEdict->pvPrivateData = NULL; // mark edict as freed pEdict->freetime = sv.time; @@ -659,7 +659,7 @@ edict_t *SV_AllocEdict( void ) edict_t *pEdict; int i; - for( i = svs.globals->maxClients + 1; i < svs.globals->numEntities; i++ ) + for( i = svgame.globals->maxClients + 1; i < svgame.globals->numEntities; i++ ) { pEdict = EDICT_NUM( i ); // the first couple seconds of server time can involve a lot of @@ -671,16 +671,34 @@ edict_t *SV_AllocEdict( void ) } } - if( i == svs.globals->maxEntities ) + if( i == svgame.globals->maxEntities ) Host_Error( "SV_AllocEdict: no free edicts\n" ); - svs.globals->numEntities++; + svgame.globals->numEntities++; pEdict = EDICT_NUM( i ); SV_InitEdict( pEdict ); return pEdict; } +void SV_FreeEdicts( void ) +{ + int i; + edict_t *ent; + + for( i = 0; i < svgame.globals->numEntities; i++ ) + { + ent = EDICT_NUM( i ); + if( ent->free ) continue; + SV_FreeEdict( ent ); + } + + // clear globals + svgame.globals->numEntities = 0; + svgame.globals->numClients = 0; + svgame.globals->mapname = 0; +} + /* ============ Save\Load gamestate @@ -738,7 +756,7 @@ void SV_WriteLocals( wfile_t *f ) vfile_t *h = VFS_Open( NULL, "wb" ); int i, numpairs = 0; - for( i = 0; i < svs.globals->numEntities; i++ ) + for( i = 0; i < svgame.globals->numEntities; i++ ) { numpairs = 0; // reset fields info PRVM_ED_Write( PRVM_EDICT_NUM( i ), &fields, &numpairs, SV_SetPair ); @@ -789,7 +807,7 @@ void SV_WriteSaveFile( const char *name ) return; } - MsgDev( D_INFO, "Saving game..." ); + MsgDev( D_INFO, "Saving svgame..." ); com.sprintf (comment, "%s - %s", sv.configstrings[CS_NAME], timestamp( TIME_FULL )); s_table = StringTable_Create( name, 0x10000 ); // 65535 unique strings @@ -897,7 +915,7 @@ void Sav_LoadLocals( wfile_t *l ) PRVM_ED_Read( s_table, entnum, fields, numpairs ); entnum++; } - svs.globals->numEntities = entnum; + svgame.globals->numEntities = entnum; } /* @@ -1002,7 +1020,7 @@ pfnMemAlloc */ static void *pfnMemAlloc( size_t cb, const char *filename, const int fileline ) { - return com.malloc( svs.private, cb, filename, fileline ); + return com.malloc( svgame.private, cb, filename, fileline ); } /* @@ -1046,7 +1064,7 @@ pfnSetModel */ void pfnSetModel( edict_t *e, const char *m ) { - if( e == game.edicts ) + if( e == EDICT_NUM( 0 )) { MsgDev( D_WARN, "SV_SetModel: can't modify world entity\n" ); return; @@ -1110,12 +1128,12 @@ pfnSetSize */ void pfnSetSize( edict_t *e, const float *rgflMin, const float *rgflMax ) { - if( !e || !e->pvServerData ) + if( !e || !e->pvPrivateData ) { MsgDev( D_ERROR, "SV_SetSize: entity not exist\n" ); return; } - else if( e == game.edicts ) + else if( e == EDICT_NUM( 0 )) { MsgDev( D_ERROR, "SV_SetSize: can't modify world entity\n" ); return; @@ -1238,7 +1256,7 @@ void pfnChangeYaw( edict_t* ent ) { float current; - if( ent == game.edicts ) + if( ent == EDICT_NUM( 0 )) { MsgDev( D_WARN, "SV_ChangeYaw: can't modify world entity\n" ); return; @@ -1263,7 +1281,7 @@ void pfnChangePitch( edict_t* ent ) { float current; - if( ent == game.edicts ) + if( ent == EDICT_NUM( 0 )) { MsgDev( D_WARN, "SV_ChangePitch: can't modify world entity\n" ); return; @@ -1290,8 +1308,7 @@ edict_t* pfnFindEntityByString( edict_t *pStartEdict, const char *pszField, cons edict_t *ed; const char *t; - if( !pStartEdict ) - e = NUM_FOR_EDICT( game.edicts ); + if( !pStartEdict ) e = 0; else e = NUM_FOR_EDICT( pStartEdict ); if( !pszValue ) pszValue = ""; @@ -1308,7 +1325,7 @@ edict_t* pfnFindEntityByString( edict_t *pStartEdict, const char *pszField, cons return pStartEdict; } - for( e++; e < svs.globals->numEntities; e++ ) + for( e++; e < svgame.globals->numEntities; e++ ) { ed = EDICT_NUM( e ); if( ed->free ) continue; @@ -1321,7 +1338,7 @@ edict_t* pfnFindEntityByString( edict_t *pStartEdict, const char *pszField, cons return ed; } } - return game.edicts; + return EDICT_NUM( 0 ); } /* @@ -1332,7 +1349,7 @@ pfnGetEntityIllum */ int pfnGetEntityIllum( edict_t* pEnt ) { - if( pEnt == game.edicts ) + if( pEnt == EDICT_NUM( 0 )) { MsgDev( D_WARN, "SV_GetEntityIllum: can't get light level at world entity\n" ); return 0; @@ -1363,7 +1380,7 @@ edict_t* pfnFindEntityInSphere( edict_t *pStartEdict, const float *org, float ra if( pStartEdict ) e = NUM_FOR_EDICT( pStartEdict ); - for( e++; e < svs.globals->numEntities; e++ ) + for( e++; e < svgame.globals->numEntities; e++ ) { ent = EDICT_NUM( e ); if( ent->free ) continue; @@ -1389,9 +1406,9 @@ edict_t* pfnFindClientInPVS( edict_t *pEdict ) edict_t *pClient; int i; - for( i = 1; i < svs.globals->maxClients; i++ ) + for( i = 1; i < svgame.globals->maxClients; i++ ) { - pClient = game.edicts + i; + pClient = EDICT_NUM( i ); if( pClient->free ) continue; if( SV_EntitiesIn( DVIS_PVS, pEdict->v.origin, pClient->v.origin )) { @@ -1414,9 +1431,9 @@ edict_t* pfnFindClientInPHS( edict_t *pEdict ) edict_t *pClient; int i; - for( i = 1; i < svs.globals->maxClients; i++ ) + for( i = 1; i < svgame.globals->maxClients; i++ ) { - pClient = game.edicts + i; + pClient = EDICT_NUM( i ); if( pClient->free ) continue; if( SV_EntitiesIn( DVIS_PHS, pEdict->v.origin, pClient->v.origin )) { @@ -1439,11 +1456,11 @@ edict_t* pfnEntitiesInPVS( edict_t *pplayer ) int i, numents; chain = NULL; - numents = svs.globals->numEntities; + numents = svgame.globals->numEntities; - for( i = svs.globals->maxClients; i < numents; i++ ) + for( i = svgame.globals->maxClients; i < numents; i++ ) { - pEdict = game.edicts + i; + pEdict = EDICT_NUM( i ); if( pEdict->free ) continue; if( SV_EntitiesIn( DVIS_PVS, pEdict->v.origin, pplayer->v.origin )) { @@ -1467,11 +1484,11 @@ edict_t* pfnEntitiesInPHS( edict_t *pplayer ) int i, numents; chain = NULL; - numents = svs.globals->numEntities; + numents = svgame.globals->numEntities; - for( i = svs.globals->maxClients; i < numents; i++ ) + for( i = svgame.globals->maxClients; i < numents; i++ ) { - pEdict = game.edicts + i; + pEdict = EDICT_NUM( i ); if( pEdict->free ) continue; if( SV_EntitiesIn( DVIS_PHS, pEdict->v.origin, pplayer->v.origin )) { @@ -1491,7 +1508,7 @@ pfnMakeVectors */ void pfnMakeVectors( const float *rgflVector ) { - AngleVectors( rgflVector, svs.globals->v_forward, svs.globals->v_right, svs.globals->v_up ); + AngleVectors( rgflVector, svgame.globals->v_forward, svgame.globals->v_right, svgame.globals->v_up ); } /* @@ -1516,9 +1533,9 @@ free edict private mem, unlink physics etc void pfnRemoveEntity( edict_t* e ) { // never free client or world entity - if( NUM_FOR_EDICT( e ) < svs.globals->maxClients ) + if( NUM_FOR_EDICT( e ) < svgame.globals->maxClients ) { - MsgDev( D_ERROR, "SV_RemoveEntity: can't delete %s\n", (e == game.edicts) ? "world" : "client" ); + MsgDev( D_ERROR, "SV_RemoveEntity: can't delete %s\n", (e == EDICT_NUM( 0 )) ? "world" : "client" ); return; } SV_FreeEdict( e ); @@ -1541,7 +1558,7 @@ edict_t* pfnCreateNamedEntity( string_t className ) pszClassName = STRING( className ); // also register classname to send for client - ed->pvEngineData->s.classname = SV_ClassIndex( pszClassName ); + ed->pvServerData->s.classname = SV_ClassIndex( pszClassName ); return ed; } @@ -1555,7 +1572,7 @@ disable entity updates to client */ void pfnMakeStatic( edict_t *ent ) { - ent->pvEngineData->s.ed_type = ED_STATIC; + ent->pvServerData->s.ed_type = ED_STATIC; } /* @@ -1582,7 +1599,7 @@ int pfnDropToFloor( edict_t* e ) trace_t trace; // ignore world silently - if( e == game.edicts ) return false; + if( e == EDICT_NUM( 0 )) return false; if( e->free ) { MsgDev( D_ERROR, "SV_DropToFloor: can't modify free entity\n" ); @@ -1622,7 +1639,7 @@ int pfnDropToFloor( edict_t* e ) e->v.groundentity = trace.ent; // if support is destroyed, keep suspended // (gross hack for floating items in various maps) - e->pvEngineData->suspended = true; + e->pvServerData->suspended = true; return true; } @@ -1641,7 +1658,7 @@ int pfnDropToFloor( edict_t* e ) e->v.groundentity = trace.ent; // if support is destroyed, keep suspended // (gross hack for floating items in various maps) - e->pvEngineData->suspended = true; + e->pvServerData->suspended = true; return true; } } @@ -1659,7 +1676,7 @@ int pfnWalkMove( edict_t *ent, float yaw, float dist, int iMode ) { vec3_t move; - if( ent == NULL || ent == game.edicts ) + if( ent == NULL || ent == EDICT_NUM( 0 )) return false; if( ent->free ) { @@ -1684,7 +1701,7 @@ pfnSetOrigin void pfnSetOrigin( edict_t *e, const float *rgflOrigin ) { // ignore world silently - if( e == game.edicts ) return; + if( e == EDICT_NUM( 0 )) return; if( e->free ) { MsgDev( D_ERROR, "SV_SetOrigin: can't modify free entity\n" ); @@ -1695,7 +1712,7 @@ void pfnSetOrigin( edict_t *e, const float *rgflOrigin ) return; // already there ? VectorCopy( rgflOrigin, e->v.origin ); - pe->SetOrigin( e->pvEngineData->physbody, e->v.origin ); + pe->SetOrigin( e->pvServerData->physbody, e->v.origin ); SV_LinkEdict( e ); } @@ -1707,7 +1724,7 @@ pfnSetAngles */ void pfnSetAngles( edict_t *e, const float *rgflAngles ) { - if( e == game.edicts ) return; + if( e == EDICT_NUM( 0 )) return; if( e->free ) { MsgDev( D_ERROR, "SV_SetAngles: can't modify free entity\n" ); @@ -1859,7 +1876,7 @@ void pfnTraceToss( edict_t* pent, edict_t* pentToIgnore, TraceResult *ptr ) { trace_t trace; - if( pent == game.edicts ) return; + if( pent == EDICT_NUM( 0 )) return; trace = SV_TraceToss( pent, pentToIgnore ); SV_CopyTraceResult( ptr, trace ); } @@ -1943,9 +1960,9 @@ void pfnGetAimVector( edict_t* ent, float speed, float *rgflReturn ) // these vairable defined in server.dll fNoFriendlyFire = Cvar_VariableValue( "mp_friendlyfire" ); - VectorCopy( svs.globals->v_forward, rgflReturn ); // assume failure if it returns early + VectorCopy( svgame.globals->v_forward, rgflReturn ); // assume failure if it returns early - if( ent == game.edicts ) return; + if( ent == EDICT_NUM( 0 )) return; if( ent->free ) { MsgDev( D_ERROR, "SV_GetAimVector: can't aiming at free entity\n" ); @@ -1956,13 +1973,13 @@ void pfnGetAimVector( edict_t* ent, float speed, float *rgflReturn ) start[2] += 20; // try sending a trace straight - VectorCopy( svs.globals->v_forward, dir ); + VectorCopy( svgame.globals->v_forward, dir ); VectorMA( start, 2048, dir, end ); tr = SV_Trace( start, vec3_origin, vec3_origin, end, MOVE_NORMAL, ent, -1 ); if( tr.ent && (tr.ent->v.takedamage == DAMAGE_AIM && fNoFriendlyFire || ent->v.team <= 0 || ent->v.team != tr.ent->v.team )) { - VectorCopy( svs.globals->v_forward, rgflReturn ); + VectorCopy( svgame.globals->v_forward, rgflReturn ); return; } @@ -1971,8 +1988,8 @@ void pfnGetAimVector( edict_t* ent, float speed, float *rgflReturn ) bestdist = 0.5f; bestent = NULL; - check = game.edicts + 1; // start at first client - for( i = 1; i < svs.globals->numEntities; i++, check++ ) + check = EDICT_NUM( 1 ); // start at first client + for( i = 1; i < svgame.globals->numEntities; i++, check++ ) { if( check->v.takedamage != DAMAGE_AIM ) continue; if( check == ent ) continue; @@ -1982,7 +1999,7 @@ void pfnGetAimVector( edict_t* ent, float speed, float *rgflReturn ) end[j] = check->v.origin[j] + 0.5 * (check->v.mins[j] + check->v.maxs[j]); VectorSubtract( end, start, dir ); VectorNormalize( dir ); - dist = DotProduct( dir, svs.globals->v_forward ); + dist = DotProduct( dir, svgame.globals->v_forward ); if( dist < bestdist ) continue; // to far to turn tr = SV_Trace( start, vec3_origin, vec3_origin, end, MOVE_NORMAL, ent, -1 ); if( tr.ent == check ) @@ -1996,8 +2013,8 @@ void pfnGetAimVector( edict_t* ent, float speed, float *rgflReturn ) if( bestent ) { VectorSubtract( bestent->v.origin, ent->v.origin, dir ); - dist = DotProduct( dir, svs.globals->v_forward ); - VectorScale( svs.globals->v_forward, dist, end ); + dist = DotProduct( dir, svgame.globals->v_forward ); + VectorScale( svgame.globals->v_forward, dist, end ); end[2] = dir[2]; VectorNormalize( end ); VectorCopy( end, rgflReturn ); @@ -2115,16 +2132,25 @@ void pfnMessageBegin( int msg_dest, int msg_type, const float *pOrigin, edict_t { // some users can send message with engine index // reduce number to avoid overflow problems or cheating - game.msg_index = bound( svc_bad, msg_type, svc_nop ); + svgame.msg_index = bound( svc_bad, msg_type, svc_nop ); - MSG_Begin( game.msg_index ); + MSG_Begin( svgame.msg_index ); // save message destination - if( pOrigin ) VectorCopy( pOrigin, svs.msg_org ); - else VectorClear( svs.msg_org ); - game.msg_leftsize = game.msg_sizes[msg_type]; - svs.msg_dest = msg_dest; - svs.msg_ent = ed; + if( pOrigin ) VectorCopy( pOrigin, svgame.msg_org ); + else VectorClear( svgame.msg_org ); + + if( svgame.msg_sizes[msg_type] == -1 ) + { + // variable sized messages sent size as first byte + svgame.msg_size_index = sv.multicast.cursize; + MSG_WriteByte( &sv.multicast, 0 ); // reserve space for now + } + else svgame.msg_size_index = -1; + + svgame.msg_realsize = 0; + svgame.msg_dest = msg_dest; + svgame.msg_ent = ed; } /* @@ -2135,22 +2161,45 @@ pfnMessageEnd */ void pfnMessageEnd( void ) { - MSG_Clear( &sv.multicast ); - return;// - - if( game.msg_leftsize != 0xFFFF && game.msg_leftsize != 0 ) - { - const char *name = sv.configstrings[CS_USER_MESSAGES + game.msg_index]; - int size = game.msg_sizes[game.msg_index]; - int realsize = size - game.msg_leftsize; + const char *name = "Unknown"; // error case - MsgDev( D_ERROR, "SV_Message: %s expected %i bytes, it written %i\n", name, size, realsize ); + if( svgame.msg_index >= 0 && svgame.msg_index < MAX_USER_MESSAGES ) + name = sv.configstrings[CS_USER_MESSAGES + svgame.msg_index]; + + if( svgame.msg_sizes[svgame.msg_index] != -1 ) + { + int expsize = svgame.msg_sizes[svgame.msg_index]; + int realsize = svgame.msg_realsize; + + // compare bounds + if( expsize != realsize ) + { + MsgDev( D_ERROR, "SV_Message: %s expected %i bytes, it written %i\n", name, expsize, realsize ); + MSG_Clear( &sv.multicast ); + return; + } + } + else if( svgame.msg_size_index != -1 ) + { + // variable sized message + if( svgame.msg_realsize >= 255 ) + { + MsgDev( D_ERROR, "SV_Message: %s too long (more than 255 bytes)\n", name ); + MSG_Clear( &sv.multicast ); + return; + } + sv.multicast.data[svgame.msg_size_index] = svgame.msg_realsize; + } + else + { + // this never happen + MsgDev( D_ERROR, "SV_Message: %s have encountered error\n", name ); MSG_Clear( &sv.multicast ); return; } - svs.msg_dest = bound( MSG_ONE, svs.msg_dest, MSG_PVS_R ); - MSG_Send( svs.msg_dest, svs.msg_org, svs.msg_ent ); + svgame.msg_dest = bound( MSG_ONE, svgame.msg_dest, MSG_PVS_R ); + MSG_Send( svgame.msg_dest, svgame.msg_org, svgame.msg_ent ); } /* @@ -2162,7 +2211,7 @@ pfnWriteByte void pfnWriteByte( int iValue ) { MSG_WriteByte( &sv.multicast, (int)iValue ); - if( game.msg_leftsize != 0xFFFF ) game.msg_leftsize--; + svgame.msg_realsize++; } /* @@ -2174,7 +2223,7 @@ pfnWriteChar void pfnWriteChar( int iValue ) { MSG_WriteChar( &sv.multicast, (int)iValue ); - if( game.msg_leftsize != 0xFFFF ) game.msg_leftsize--; + svgame.msg_realsize++; } /* @@ -2186,7 +2235,7 @@ pfnWriteShort void pfnWriteShort( int iValue ) { MSG_WriteShort( &sv.multicast, (int)iValue ); - if( game.msg_leftsize != 0xFFFF ) game.msg_leftsize -= 2; + svgame.msg_realsize += 2; } /* @@ -2198,7 +2247,7 @@ pfnWriteLong void pfnWriteLong( int iValue ) { MSG_WriteLong( &sv.multicast, (int)iValue ); - if( game.msg_leftsize != 0xFFFF ) game.msg_leftsize -= 4; + svgame.msg_realsize += 4; } /* @@ -2210,7 +2259,7 @@ pfnWriteAngle void pfnWriteAngle( float flValue ) { MSG_WriteAngle32( &sv.multicast, flValue ); - if( game.msg_leftsize != 0xFFFF ) game.msg_leftsize -= 4; + svgame.msg_realsize += 4; } /* @@ -2222,7 +2271,7 @@ pfnWriteCoord void pfnWriteCoord( float flValue ) { MSG_WriteCoord32( &sv.multicast, flValue ); - if( game.msg_leftsize != 0xFFFF ) game.msg_leftsize -= 4; + svgame.msg_realsize += 4; } /* @@ -2234,7 +2283,7 @@ pfnWriteFloat void pfnWriteFloat( float flValue ) { MSG_WriteFloat( &sv.multicast, flValue ); - if( game.msg_leftsize != 0xFFFF ) game.msg_leftsize -= 4; + svgame.msg_realsize += 4; } /* @@ -2251,9 +2300,8 @@ void pfnWriteString( const char *sz ) MSG_WriteString( &sv.multicast, sz ); total_size = sv.multicast.cursize - cur_size; - // some messages with constant strings can be marked as known sized - if( game.msg_leftsize != 0xFFFF ) - game.msg_leftsize -= total_size; + // some messages with constant string length can be marked as known sized + svgame.msg_realsize += total_size; } /* @@ -2264,10 +2312,10 @@ pfnWriteEntity */ void pfnWriteEntity( int iValue ) { - if( iValue < 0 || iValue > svs.globals->numEntities ) + if( iValue < 0 || iValue > svgame.globals->numEntities ) Host_Error( "MSG_WriteEntity: invalid entnumber %d\n", iValue ); MSG_WriteShort( &sv.multicast, iValue ); - if( game.msg_leftsize != 0xFFFF ) game.msg_leftsize -= 2; + svgame.msg_realsize += 2; } /* @@ -2356,9 +2404,9 @@ void *pfnPvAllocEntPrivateData( edict_t *pEdict, long cb ) Com_Assert( pEdict == NULL ); // to avoid multiple alloc - pEdict->pvServerData = (void *)Mem_Realloc( svs.private, pEdict->pvServerData, cb ); + pEdict->pvPrivateData = (void *)Mem_Realloc( svgame.private, pEdict->pvPrivateData, cb ); - return pEdict->pvServerData; + return pEdict->pvPrivateData; } /* @@ -2369,9 +2417,31 @@ pfnFreeEntPrivateData */ void pfnFreeEntPrivateData( edict_t *pEdict ) { - if( pEdict->pvServerData ) - Mem_Free( pEdict->pvServerData ); - pEdict->pvServerData = NULL; // freed + if( pEdict->pvPrivateData ) + Mem_Free( pEdict->pvPrivateData ); + pEdict->pvPrivateData = NULL; // freed +} + +/* +============= +SV_AllocString + +============= +*/ +string_t SV_AllocString( const char *szValue ) +{ + return StringTable_SetString( svgame.hStringTable, szValue ); +} + +/* +============= +SV_GetString + +============= +*/ +const char *SV_GetString( string_t iString ) +{ + return StringTable_GetString( svgame.hStringTable, iString ); } /* @@ -2382,7 +2452,7 @@ pfnPEntityOfEntOffset */ edict_t* pfnPEntityOfEntOffset( int iEntOffset ) { - return (&((edict_t*)game.vp)[iEntOffset]); + return (&((edict_t*)svgame.vp)[iEntOffset]); } /* @@ -2393,7 +2463,7 @@ pfnEntOffsetOfPEntity */ int pfnEntOffsetOfPEntity( const edict_t *pEdict ) { - return ((byte *)pEdict - (byte *)game.vp); + return ((byte *)pEdict - (byte *)svgame.vp); } /* @@ -2427,7 +2497,7 @@ slow linear brute force */ edict_t* pfnFindEntityByVars( entvars_t* pvars ) { - edict_t *e = game.edicts; + edict_t *e = EDICT_NUM( 0 ); int i; Msg("FindEntity by VARS()\n" ); @@ -2435,7 +2505,7 @@ edict_t* pfnFindEntityByVars( entvars_t* pvars ) // HACKHACK if( pvars ) return pvars->pContainingEntity; - for( i = 0; i < svs.globals->numEntities; i++, e++ ) + for( i = 0; i < svgame.globals->numEntities; i++, e++ ) { if( e->free ) continue; if( !memcmp( &e->v, pvars, sizeof( entvars_t ))) @@ -2483,9 +2553,7 @@ int pfnRegUserMsg( const char *pszName, int iSize ) // build message name, fmt: MsgName@size com.snprintf( msg_name, MAX_STRING, "%s@%i", pszName, iSize ); msg_index = SV_UserMessageIndex( msg_name ); - if( iSize == -1 ) - game.msg_sizes[msg_index] = 0xFFFF; - else game.msg_sizes[msg_index] = iSize; + svgame.msg_sizes[msg_index] = iSize; return msg_index; } @@ -2522,12 +2590,12 @@ dword pfnFunctionFromName( const char *pName ) { int i, index; - for( i = 0; i < game.num_ordinals; i++ ) + for( i = 0; i < svgame.num_ordinals; i++ ) { - if( !com.strcmp( pName, game.names[i] )) + if( !com.strcmp( pName, svgame.names[i] )) { - index = game.ordinals[i]; - return game.funcs[index] + game.funcBase; + index = svgame.ordinals[i]; + return svgame.funcs[index] + svgame.funcBase; } } @@ -2545,55 +2613,18 @@ const char *pfnNameForFunction( dword function ) { int i, index; - for( i = 0; i < game.num_ordinals; i++ ) + for( i = 0; i < svgame.num_ordinals; i++ ) { - index = game.ordinals[i]; + index = svgame.ordinals[i]; - if((function - game.funcBase) == game.funcs[index] ) - return game.names[i]; + if((function - svgame.funcBase) == svgame.funcs[index] ) + return svgame.names[i]; } // couldn't find the function address to return name return NULL; } -/* -============= -pfnClientPrintf - -============= -*/ -void pfnClientPrintf( edict_t* pEdict, int ptype, const char *szMsg ) -{ - sv_client_t *client; - int num; - - num = NUM_FOR_EDICT( pEdict ); - if( num < 1 || num > svs.globals->maxClients || svs.clients[num - 1].state != cs_spawned ) - { - MsgDev( D_WARN, "SV_ClientPrintf: tired print to a non-client!\n" ); - return; - } - client = svs.clients + num - 1; - - switch( ptype ) - { - case HUD_PRINTTALK: - case HUD_PRINTNOTIFY: // don't leave message in console history - case HUD_PRINTCONSOLE: - SV_ClientPrintf( client, ptype, (char *)szMsg ); - break; - case HUD_PRINTCENTER: - MSG_Begin( svc_centerprint ); - MSG_WriteString( &sv.multicast, szMsg ); - MSG_Send( MSG_ONE_R, NULL, pEdict ); - break; - default: - MsgDev( D_ERROR, "SV_ClientPrintf: invalid destination\n" ); - break; - } -} - /* ============= pfnServerPrint @@ -2607,7 +2638,7 @@ void pfnServerPrint( const char *szMsg ) // while loading in-progress we can sending message com.print( szMsg ); // only for local client } - else SV_BroadcastPrintf( HUD_PRINTCONSOLE, (char *)szMsg ); + else SV_BroadcastPrintf( "%s", szMsg ); } /* @@ -2619,7 +2650,7 @@ changes area portal state */ void pfnAreaPortal( edict_t *pEdict, bool enable ) { - if( pEdict == game.edicts ) return; + if( pEdict == EDICT_NUM( 0 )) return; if( pEdict->free ) { MsgDev( D_ERROR, "SV_AreaPortal: can't modify free entity\n" ); @@ -2855,8 +2886,8 @@ char *pfnGetInfoKeyBuffer( edict_t *e ) int index; index = NUM_FOR_EDICT( e ); - if( index > 0 && index < svs.globals->numClients ) - return e->pvEngineData->client->userinfo; + if( index > 0 && index < svgame.globals->numClients ) + return e->pvServerData->client->userinfo; return Cvar_Serverinfo(); // otherwise return ServerInfo } @@ -2868,7 +2899,7 @@ pfnSetClientKeyValue */ void pfnSetClientKeyValue( int clientIndex, char *infobuffer, char *key, char *value ) { - if( clientIndex > 0 && clientIndex < svs.globals->numClients ) + if( clientIndex > 0 && clientIndex < svgame.globals->numClients ) { sv_client_t *client = svs.clients + clientIndex; Info_SetValueForKey( client->userinfo, key, value ); @@ -2905,7 +2936,7 @@ pfnDropClient */ void pfnDropClient( int clientIndex ) { - if( clientIndex < 0 || clientIndex >= svs.globals->maxClients ) + if( clientIndex < 0 || clientIndex >= svgame.globals->maxClients ) { MsgDev( D_ERROR, "SV_DropClient: not a client\n" ); return; @@ -2988,8 +3019,8 @@ static enginefuncs_t gEngfuncs = pfnAlertMessage, pfnPvAllocEntPrivateData, pfnFreeEntPrivateData, - pfnAllocString, - pfnGetString, + SV_AllocString, + SV_GetString, pfnPEntityOfEntOffset, pfnEntOffsetOfPEntity, pfnIndexOfEdict, @@ -3001,7 +3032,6 @@ static enginefuncs_t gEngfuncs = pfnGetBonePosition, pfnFunctionFromName, pfnNameForFunction, - pfnClientPrintf, pfnServerPrint, pfnAreaPortal, pfnCmd_Args, @@ -3048,8 +3078,11 @@ bool SV_ParseEdict( script_t *script, edict_t *ent ) int i, numpairs = 0; const char *classname = NULL; LINK_ENTITY_FUNC SpawnEdict; + byte *tempstr; token_t token; + tempstr = Mem_AllocPool( "SV Temp Strings" ); + // go through all the dictionary pairs while( 1 ) { @@ -3074,8 +3107,8 @@ bool SV_ParseEdict( script_t *script, edict_t *ent ) // create keyvalue strings pkvd[numpairs].szClassName = (char *)classname; // unknown at this moment - pkvd[numpairs].szKeyName = ED_NewString( keyname, svs.stringpool ); - pkvd[numpairs].szValue = ED_NewString( token.string, svs.stringpool ); + pkvd[numpairs].szKeyName = com.stralloc( tempstr, keyname, __FILE__, __LINE__ ); + pkvd[numpairs].szValue = com.stralloc( tempstr, token.string, __FILE__, __LINE__ ); pkvd[numpairs].fHandled = false; if( !com.strcmp( keyname, "classname" ) && classname == NULL ) @@ -3084,16 +3117,17 @@ bool SV_ParseEdict( script_t *script, edict_t *ent ) } // allocate edict private memory (passed by dlls) - SpawnEdict = (LINK_ENTITY_FUNC)Com_GetProcAddress( svs.game, classname ); + SpawnEdict = (LINK_ENTITY_FUNC)Com_GetProcAddress( svgame.hInstance, classname ); if( !SpawnEdict ) { MsgDev( D_ERROR, "No spawn function for %s\n", classname ); + Mem_FreePool( &tempstr ); return false; } // apply edict classnames - ent->pvEngineData->s.classname = SV_ClassIndex( classname ); - ent->v.classname = pfnAllocString( classname ); + ent->pvServerData->s.classname = SV_ClassIndex( classname ); + ent->v.classname = MAKE_STRING( classname ); SpawnEdict( &ent->v ); @@ -3102,8 +3136,10 @@ bool SV_ParseEdict( script_t *script, edict_t *ent ) { if( pkvd[i].fHandled ) continue; pkvd[i].szClassName = (char *)classname; - svs.dllFuncs.pfnKeyValue( ent, &pkvd[i] ); + svgame.dllFuncs.pfnKeyValue( ent, &pkvd[i] ); } + Mem_FreePool( &tempstr ); + return true; } @@ -3147,7 +3183,7 @@ void SV_LoadFromFile( script_t *entities ) if( !SV_ParseEdict( entities, ent )) continue; - if( svs.dllFuncs.pfnSpawn( ent ) == -1 ) + if( svgame.dllFuncs.pfnSpawn( ent ) == -1 ) died++; else spawned++; } @@ -3171,43 +3207,49 @@ void SV_SpawnEntities( const char *mapname, script_t *entities ) ent = EDICT_NUM( 0 ); SV_InitEdict( ent ); - ent->v.model = pfnAllocString( sv.configstrings[CS_MODELS] ); + ent->v.model = MAKE_STRING( sv.configstrings[CS_MODELS] ); ent->v.modelindex = 1; // world model ent->v.solid = SOLID_BSP; ent->v.movetype = MOVETYPE_PUSH; ent->free = false; SV_ConfigString( CS_MAXCLIENTS, va("%i", Host_MaxClients())); - svs.globals->mapname = pfnAllocString( sv.name ); - svs.globals->time = sv.time; + svgame.globals->mapname = MAKE_STRING( sv.name ); + svgame.globals->time = sv.time; // spawn the rest of the entities on the map SV_LoadFromFile( entities ); // set client fields on player ents - for( i = 0; i < svs.globals->maxClients; i++ ) + for( i = 0; i < svgame.globals->maxClients; i++ ) { // setup all clients ent = EDICT_NUM( i + 1 ); SV_InitEdict( ent ); - ent->pvEngineData->client = svs.clients + i; - ent->pvEngineData->client->edict = ent; - svs.globals->numClients++; + ent->pvServerData->client = svs.clients + i; + ent->pvServerData->client->edict = ent; + svgame.globals->numClients++; } - Msg("Total %i entities spawned\n", svs.globals->numEntities ); + Msg("Total %i entities spawned\n", svgame.globals->numEntities ); } void SV_UnloadProgs( void ) { + if( svgame.hInstance ) + { + svgame.dllFuncs.pfnServerDeactivate(); + } + Sys_FreeNameFuncGlobals(); - StringTable_Delete( game.hStringTable ); - Com_FreeLibrary( svs.game ); - Mem_FreePool( &svs.mempool ); - Mem_FreePool( &svs.stringpool ); - Mem_FreePool( &svs.private ); + StringTable_Delete( svgame.hStringTable ); + Com_FreeLibrary( svgame.hInstance ); + Mem_FreePool( &svgame.mempool ); + Mem_FreePool( &svgame.private ); + + svgame.hInstance = NULL; } -bool SV_LoadProgs( const char *name ) +void SV_LoadProgs( const char *name ) { static APIFUNCTION GetEntityAPI; static GIVEFNPTRSTODLL GiveFnptrsToDll; @@ -3216,59 +3258,61 @@ bool SV_LoadProgs( const char *name ) edict_t *e; int i; - if( svs.game ) SV_UnloadProgs(); + if( svgame.hInstance ) SV_UnloadProgs(); // fill it in - svs.globals = &gpGlobals; + svgame.globals = &gpGlobals; com.snprintf( libname, MAX_STRING, "bin/%s.dll", name ); - svs.mempool = Mem_AllocPool( "Server Edicts Zone" ); - svs.stringpool = Mem_AllocPool( "Server Strings Zone" ); - svs.private = Mem_AllocPool( "Server Private Zone" ); + svgame.mempool = Mem_AllocPool( "Server Edicts Zone" ); + svgame.private = Mem_AllocPool( "Server Private Zone" ); - svs.game = Com_LoadLibrary( libname ); - if( !svs.game ) return false; - - GetEntityAPI = (APIFUNCTION)Com_GetProcAddress( svs.game, "GetEntityAPI" ); + svgame.hInstance = Com_LoadLibrary( libname ); + if( !svgame.hInstance ) + { + Host_Error( "SV_LoadProgs: can't initialize server.dll\n" ); + return; + } + GetEntityAPI = (APIFUNCTION)Com_GetProcAddress( svgame.hInstance, "GetEntityAPI" ); if( !GetEntityAPI ) { - MsgDev( D_ERROR, "SV_LoadProgs: failed to get address of GetEntityAPI proc\n" ); - return false; + Host_Error( "SV_LoadProgs: failed to get address of GetEntityAPI proc\n" ); + return; } - GiveFnptrsToDll = (GIVEFNPTRSTODLL)Com_GetProcAddress( svs.game, "GiveFnptrsToDll" ); + GiveFnptrsToDll = (GIVEFNPTRSTODLL)Com_GetProcAddress( svgame.hInstance, "GiveFnptrsToDll" ); if( !GiveFnptrsToDll ) { // can't find GiveFnptrsToDll! - MsgDev( D_ERROR, "SV_LoadProgs: failed to get address of GiveFnptrsToDll proc\n" ); - return false; + Host_Error( "SV_LoadProgs: failed to get address of GiveFnptrsToDll proc\n" ); + return; } if( !Sys_LoadSymbols( va( "bin/%s.dll", name ))) - return false; - - GiveFnptrsToDll( &gEngfuncs, svs.globals ); - - if( !GetEntityAPI( &svs.dllFuncs, INTERFACE_VERSION )) { - MsgDev( D_ERROR, "SV_LoadProgs: couldn't get entity API\n" ); - return false; + Host_Error( "SV_LoadProgs: can't loading export symbols\n" ); + return; + } + GiveFnptrsToDll( &gEngfuncs, svgame.globals ); + + if( !GetEntityAPI( &svgame.dllFuncs, INTERFACE_VERSION )) + { + Host_Error( "SV_LoadProgs: couldn't get entity API\n" ); + return; } // 65535 unique strings should be enough ... - game.hStringTable = StringTable_Create( "Game Strings", 0x10000 ); - StringTable_SetString( game.hStringTable, "" ); // make NULL string - svs.globals->maxEntities = host.max_edicts; - svs.globals->maxClients = Host_MaxClients(); - game.edicts = Mem_Alloc( svs.mempool, sizeof( edict_t ) * svs.globals->maxEntities ); - svs.globals->numEntities = svs.globals->maxClients + 1; // clients + world - svs.globals->numClients = 0; - for( i = 0, e = game.edicts; i < svs.globals->maxEntities; i++, e++ ) + svgame.hStringTable = StringTable_Create( "Game Strings", 0x10000 ); + StringTable_SetString( svgame.hStringTable, "" ); // make NULL string + svgame.globals->maxEntities = host.max_edicts; + svgame.globals->maxClients = Host_MaxClients(); + svgame.edicts = Mem_Alloc( svgame.mempool, sizeof( edict_t ) * svgame.globals->maxEntities ); + svgame.globals->numEntities = svgame.globals->maxClients + 1; // clients + world + svgame.globals->numClients = 0; + for( i = 0, e = svgame.edicts; i < svgame.globals->maxEntities; i++, e++ ) e->free = true; // mark all edicts as freed - // initialize game - svs.dllFuncs.pfnGameInit(); - - return true; + // all done, initialize game + svgame.dllFuncs.pfnGameInit(); } \ No newline at end of file diff --git a/engine/server/sv_init.c b/engine/server/sv_init.c index 53feeeb1..1d66829a 100644 --- a/engine/server/sv_init.c +++ b/engine/server/sv_init.c @@ -22,7 +22,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "server.h" server_static_t svs; // persistant server info -svgame_static_t game; // persistant game info +svgame_static_t svgame; // persistant game info server_t sv; // local server /* @@ -101,18 +101,18 @@ void SV_CreateBaseline( void ) edict_t *svent; int entnum; - for( entnum = 1; entnum < svs.globals->numEntities; entnum++ ) + for( entnum = 1; entnum < svgame.globals->numEntities; entnum++ ) { svent = EDICT_NUM( entnum ); if( svent->free ) continue; - if( !svent->v.modelindex && !svent->pvEngineData->s.soundindex && !svent->v.effects ) + if( !svent->v.modelindex && !svent->pvServerData->s.soundindex && !svent->v.effects ) continue; svent->serialnumber = entnum; // take current state as baseline SV_UpdateEntityState( svent ); - svs.baselines[entnum] = svent->pvEngineData->s; + svs.baselines[entnum] = svent->pvServerData->s; } } @@ -209,7 +209,7 @@ void SV_SpawnServer( const char *server, const char *savename ) if( sv.loadgame ) SV_ReadLevelFile( savename ); else SV_SpawnEntities( sv.name, pe->GetEntityScript()); - svs.dllFuncs.pfnServerActivate( game.edicts, svs.globals->numEntities, svs.globals->maxClients ); + svgame.dllFuncs.pfnServerActivate( EDICT_NUM( 0 ), svgame.globals->numEntities, svgame.globals->maxClients ); // run two frames to allow everything to settle for( i = 0; i < 2; i++ ) @@ -226,7 +226,7 @@ void SV_SpawnServer( const char *server, const char *savename ) SV_CreateBaseline(); // classify edicts for quick network sorting - for( i = 0; i < svs.globals->numEntities; i++ ) + for( i = 0; i < svgame.globals->numEntities; i++ ) { edict_t *ent = EDICT_NUM( i ); SV_ClassifyEdict( ent ); @@ -257,6 +257,9 @@ void SV_InitGame( void ) } else { + // init game after host error + if( !svgame.hInstance ) + SV_LoadProgs( "server" ); // make sure the client is down CL_Drop(); } @@ -308,12 +311,6 @@ void SV_InitGame( void ) com.sprintf( idmaster, "192.246.40.37:%i", PORT_MASTER ); NET_StringToAdr( idmaster, &master_adr[0] ); - // init game - if(!SV_LoadProgs( "server" )) - { - Host_Error( "SV_InitGame: can't initialize server.dll\n" ); - } - for( i = 0; i < Host_MaxClients(); i++ ) { ent = EDICT_NUM( i + 1 ); diff --git a/engine/server/sv_main.c b/engine/server/sv_main.c index 463a88c3..9c5d9300 100644 --- a/engine/server/sv_main.c +++ b/engine/server/sv_main.c @@ -71,7 +71,7 @@ void SV_CalcPings( void ) else cl->ping = total / count; // let the game dll know about the ping - cl->edict->pvEngineData->client->ping = cl->ping; + cl->edict->pvServerData->client->ping = cl->ping; } } @@ -164,7 +164,7 @@ void SV_CheckTimeouts( void ) } if(( cl->state == cs_connected || cl->state == cs_spawned) && cl->lastmessage < droppoint ) { - SV_BroadcastPrintf( HUD_PRINTCONSOLE, "%s timed out\n", cl->name ); + SV_BroadcastPrintf( "%s timed out\n", cl->name ); SV_DropClient( cl ); cl->state = cs_free; // don't bother with zombie state } @@ -375,6 +375,9 @@ void SV_Init( void ) public_server = Cvar_Get ("public", "0", 0, "change server type from private to public" ); sv_reconnect_limit = Cvar_Get ("sv_reconnect_limit", "3", CVAR_ARCHIVE, "max reconnect attempts" ); + + // init game + SV_LoadProgs( "server" ); } /* @@ -439,7 +442,13 @@ void SV_Shutdown( bool reconnect ) if( svs.clients ) SV_FinalMessage( host.finalmsg, reconnect ); Master_Shutdown(); - SV_UnloadProgs(); + if( reconnect ) + { + if( svgame.hInstance ) + svgame.dllFuncs.pfnServerDeactivate(); + SV_FreeEdicts(); + } + else SV_UnloadProgs(); // free current level Mem_Set( &sv, 0, sizeof( sv )); diff --git a/engine/server/sv_move.c b/engine/server/sv_move.c index 7cf9d95d..363449f6 100644 --- a/engine/server/sv_move.c +++ b/engine/server/sv_move.c @@ -417,8 +417,8 @@ void SV_Transform( edict_t *edict, const vec3_t origin, const matrix3x3 matrix ) edict->v.angles[2] = angles[2]; // refresh force and torque - 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 ); + pe->GetForce( edict->pvServerData->physbody, edict->v.velocity, edict->v.avelocity, edict->v.force, edict->v.torque ); + pe->GetMassCentre( edict->pvServerData->physbody, edict->v.m_pcentre ); } /* @@ -434,21 +434,21 @@ void SV_PlayerMove( edict_t *player ) pmove_t pm; sv_client_t *client; - client = player->pvEngineData->client; + client = player->pvServerData->client; memset( &pm, 0, sizeof(pm) ); 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; + player->pvServerData->s.pm_type = PM_SPECTATOR; + else player->pvServerData->s.pm_type = PM_NORMAL; + player->pvServerData->s.gravity = sv_gravity->value; if( player->v.teleport_time ) - player->pvEngineData->s.pm_flags |= PMF_TIME_TELEPORT; - else player->pvEngineData->s.pm_flags &= ~PMF_TIME_TELEPORT; + player->pvServerData->s.pm_flags |= PMF_TIME_TELEPORT; + else player->pvServerData->s.pm_flags &= ~PMF_TIME_TELEPORT; - pm.ps = player->pvEngineData->s; + pm.ps = player->pvServerData->s; pm.cmd = client->lastcmd; - pm.body = player->pvEngineData->physbody; // member body ptr + pm.body = player->pvServerData->physbody; // member body ptr VectorCopy( player->v.origin, pm.ps.origin ); VectorCopy( player->v.velocity, pm.ps.velocity ); @@ -456,13 +456,13 @@ void SV_PlayerMove( edict_t *player ) pe->PlayerMove( &pm, false ); // server move // save results of pmove - player->pvEngineData->s = pm.ps; + player->pvServerData->s = pm.ps; VectorCopy(pm.ps.origin, player->v.origin); VectorCopy(pm.ps.velocity, player->v.velocity); VectorCopy(pm.mins, player->v.mins); VectorCopy(pm.maxs, player->v.maxs); - VectorCopy(pm.ps.viewangles, player->pvEngineData->s.viewangles ); + VectorCopy(pm.ps.viewangles, player->pvServerData->s.viewangles ); } void SV_PlaySound( edict_t *ed, float volume, float pitch, const char *sample ) diff --git a/engine/server/sv_phys.c b/engine/server/sv_phys.c index ef343832..6a1a5dbd 100644 --- a/engine/server/sv_phys.c +++ b/engine/server/sv_phys.c @@ -4,7 +4,6 @@ //======================================================================= #include "common.h" -#include "render_api.h" #include "server.h" #include "matrix_lib.h" #include "const.h" @@ -254,7 +253,7 @@ void SV_CheckAllEnts( void ) // see if any solid entities are inside the final position check = EDICT_NUM( 1 ); - for( e = 1; e < svs.globals->numEntities; e++, check++ ) + for( e = 1; e < svgame.globals->numEntities; e++, check++ ) { if( check->free ) continue; switch( check->v.movetype ) @@ -324,18 +323,18 @@ bool SV_RunThink( edict_t *ent ) // don't let things stay in the past. // it is possible to start that way by a trigger with a local time. - if( ent->v.nextthink <= 0 || ent->v.nextthink > sv.time + svs.globals->frametime ) + if( ent->v.nextthink <= 0 || ent->v.nextthink > sv.time + svgame.globals->frametime ) return true; for( iterations = 0; iterations < 128 && !ent->free; iterations++ ) { - svs.globals->time = max( sv.time, ent->v.nextthink ); + svgame.globals->time = max( sv.time, ent->v.nextthink ); ent->v.nextthink = 0; - svs.dllFuncs.pfnThink( ent ); + svgame.dllFuncs.pfnThink( ent ); // mods often set nextthink to time to cause a think every frame, // we don't want to loop in that case, so exit if the new nextthink is // <= the time the qc was told, also exit if it is past the end of the frame - if( ent->v.nextthink <= svs.globals->time || ent->v.nextthink > sv.time + svs.globals->frametime ) + if( ent->v.nextthink <= svgame.globals->time || ent->v.nextthink > sv.time + svgame.globals->frametime ) break; } return !ent->free; @@ -354,19 +353,19 @@ void SV_Impact( edict_t *e1, trace_t *trace ) SV_CopyTraceToGlobal( trace ); - svs.globals->time = sv.time; + svgame.globals->time = sv.time; if( !e1->free && !e2->free && e1->v.solid != SOLID_NOT ) { - svs.dllFuncs.pfnTouch( e1, e2 ); + svgame.dllFuncs.pfnTouch( e1, e2 ); } if( !e1->free && !e2->free && e2->v.solid != SOLID_NOT ) { - VectorCopy( e2->v.origin, svs.globals->trace_endpos ); - VectorNegate( trace->plane.normal, svs.globals->trace_plane_normal ); - svs.globals->trace_plane_dist = -trace->plane.dist; - svs.globals->trace_ent = e1; - svs.dllFuncs.pfnTouch( e2, e1 ); + VectorCopy( e2->v.origin, svgame.globals->trace_endpos ); + VectorNegate( trace->plane.normal, svgame.globals->trace_plane_normal ); + svgame.globals->trace_plane_dist = -trace->plane.dist; + svgame.globals->trace_ent = e1; + svgame.dllFuncs.pfnTouch( e2, e1 ); } } @@ -393,8 +392,8 @@ void SV_TouchTriggers( edict_t *ent ) for( i = 0; i < num; i++ ) { if( touch[i]->free ) continue; - svs.globals->time = sv.time; - svs.dllFuncs.pfnTouch( touch[i], ent ); + svgame.globals->time = sv.time; + svgame.dllFuncs.pfnTouch( touch[i], ent ); } } @@ -593,9 +592,14 @@ SV_AddGravity */ void SV_AddGravity( edict_t *ent ) { + if( ent->pvServerData->stuck ) + { + VectorClear( ent->v.velocity ); + return; + } if( ent->v.gravity ) // gravity modifier - ent->v.velocity[2] -= sv_gravity->value * ent->v.gravity * svs.globals->frametime; - else ent->v.velocity[2] -= sv_gravity->value * svs.globals->frametime; + ent->v.velocity[2] -= sv_gravity->value * ent->v.gravity * svgame.globals->frametime; + else ent->v.velocity[2] -= sv_gravity->value * svgame.globals->frametime; } /* @@ -782,7 +786,7 @@ void SV_PushMove( edict_t *pusher, float movetime ) } // tell any MOVETYPE_STEP entity that it may need to check for water transitions - check->pvEngineData->forceupdate = true; + check->pvServerData->forceupdate = true; checkcontents = SV_ContentsMask( check ); // if the entity is standing on the pusher, it will definitely be moved @@ -810,8 +814,8 @@ void SV_PushMove( edict_t *pusher, float movetime ) } //Msg("- pushing %f %f %f\n", move[0], move[1], move[2]); - VectorCopy (check->v.origin, check->pvEngineData->moved_origin ); - VectorCopy (check->v.angles, check->pvEngineData->moved_angles ); + VectorCopy (check->v.origin, check->pvServerData->moved_origin ); + VectorCopy (check->v.angles, check->pvServerData->moved_angles ); moved_edicts[num_moved++] = NUM_FOR_EDICT( check ); // try moving the contacted entity @@ -835,8 +839,8 @@ void SV_PushMove( edict_t *pusher, float movetime ) vec3_t move2; pusher->v.solid = SOLID_NOT; VectorScale( move, 1.1f, move2 ); - VectorCopy( check->pvEngineData->moved_origin, check->v.origin ); - VectorCopy( check->pvEngineData->moved_angles, check->v.angles ); + VectorCopy( check->pvServerData->moved_origin, check->v.origin ); + VectorCopy( check->pvServerData->moved_angles, check->v.angles ); SV_PushEntity( check, move2, true ); pusher->v.solid = savesolid; pe->ClipToGenericEntity( &trace, pushermodel, pusher->v.mins, pusher->v.maxs, CONTENTS_BODY, pusherfinalmatrix, pusherfinalimatrix, check->v.origin, check->v.mins, check->v.maxs, check->v.origin, checkcontents ); @@ -845,8 +849,8 @@ void SV_PushMove( edict_t *pusher, float movetime ) // try moving the contacted entity a tiny bit less to account for precision errors pusher->v.solid = SOLID_NOT; VectorScale( move, 0.9, move2 ); - VectorCopy( check->pvEngineData->moved_origin, check->v.origin ); - VectorCopy( check->pvEngineData->moved_angles, check->v.angles ); + VectorCopy( check->pvServerData->moved_origin, check->v.origin ); + VectorCopy( check->pvServerData->moved_angles, check->v.angles ); SV_PushEntity( check, move2, true ); pusher->v.solid = savesolid; pe->ClipToGenericEntity( &trace, pushermodel, pusher->v.mins, pusher->v.maxs, CONTENTS_BODY, pusherfinalmatrix, pusherfinalimatrix, check->v.origin, check->v.mins, check->v.maxs, check->v.origin, checkcontents ); @@ -873,13 +877,13 @@ void SV_PushMove( edict_t *pusher, float movetime ) for( i = 0; i < num_moved; i++ ) { edict_t *ed = EDICT_NUM( moved_edicts[i] ); - VectorCopy( ed->pvEngineData->moved_origin, ed->v.origin ); - VectorCopy( ed->pvEngineData->moved_angles, ed->v.angles ); + VectorCopy( ed->pvServerData->moved_origin, ed->v.origin ); + VectorCopy( ed->pvServerData->moved_angles, ed->v.angles ); SV_LinkEdict( ed ); } // if the pusher has a "blocked" function, call it, otherwise just stay in place until the obstacle is gone - svs.dllFuncs.pfnBlocked( pusher, check ); + svgame.dllFuncs.pfnBlocked( pusher, check ); break; } } @@ -901,20 +905,20 @@ void SV_Physics_Pusher( edict_t *ent ) oldltime = ent->v.ltime; thinktime = ent->v.nextthink; - if( thinktime < ent->v.ltime + svs.globals->frametime ) + if( thinktime < ent->v.ltime + svgame.globals->frametime ) { movetime = thinktime - ent->v.ltime; if( movetime < 0 ) movetime = 0; } - else movetime = svs.globals->frametime; + else movetime = svgame.globals->frametime; // advances ent->v.ltime if not blocked if( movetime ) SV_PushMove( ent, movetime ); if( thinktime > oldltime && thinktime <= ent->v.ltime ) { ent->v.nextthink = 0; - svs.globals->time = sv.time; - svs.dllFuncs.pfnThink( ent ); + svgame.globals->time = sv.time; + svgame.dllFuncs.pfnThink( ent ); } } @@ -956,9 +960,10 @@ void SV_CheckStuck( edict_t *ent ) offset[1] += 1; offset[2] += 1; } - if(!SV_TestEntityPosition( ent, offset )) + if( !SV_TestEntityPosition( ent, offset )) { VectorCopy( ent->v.origin, ent->v.oldorigin ); + ent->pvServerData->stuck = false; return; } @@ -967,6 +972,7 @@ void SV_CheckStuck( edict_t *ent ) if(!SV_TestEntityPosition( ent, unstickoffsets + i)) { MsgDev( D_NOTE, "Unstuck player with offset %g %g %g.\n", unstickoffsets[i+0], unstickoffsets[i+1], unstickoffsets[i+2]); + ent->pvServerData->stuck = false; SV_LinkEdict( ent ); return; } @@ -976,10 +982,14 @@ void SV_CheckStuck( edict_t *ent ) if(!SV_TestEntityPosition( ent, offset )) { MsgDev( D_NOTE, "Unstuck player by restoring oldorigin.\n" ); + ent->pvServerData->stuck = false; SV_LinkEdict( ent ); return; } - MsgDev( D_ERROR, "Stuck player\n" ); + + if( !ent->pvServerData->stuck ) + MsgDev( D_ERROR, "Stuck player\n" ); // fire once + ent->pvServerData->stuck = true; } bool SV_UnstickEntity( edict_t *ent ) @@ -987,20 +997,26 @@ bool SV_UnstickEntity( edict_t *ent ) int i; // if not stuck in a bmodel, just return - if(!SV_TestEntityPosition( ent, vec3_origin )) + if( !SV_TestEntityPosition( ent, vec3_origin )) + { + ent->pvServerData->stuck = false; return true; + } for( i = 0; i < (int)(sizeof(unstickoffsets) / sizeof(unstickoffsets[0])); i += 3 ) { if(!SV_TestEntityPosition( ent, unstickoffsets + i )) { - MsgDev( D_INFO, "Unstuck entity \"%s\" with offset %g %g %g.\n", STRING( ent->v.classname ), unstickoffsets[i+0], unstickoffsets[i+1], unstickoffsets[i+2] ); + MsgDev( D_NOTE, "Unstuck entity \"%s\" with offset %g %g %g.\n", STRING( ent->v.classname ), unstickoffsets[i+0], unstickoffsets[i+1], unstickoffsets[i+2] ); + ent->pvServerData->stuck = false; SV_LinkEdict( ent ); return true; } } - MsgDev( D_INFO, "Stuck entity \"%s\".\n", STRING( ent->v.classname )); + if( !ent->pvServerData->stuck ) + MsgDev( D_ERROR, "Stuck entity \"%s\".\n", STRING( ent->v.classname )); + ent->pvServerData->stuck = true; return false; } @@ -1034,12 +1050,12 @@ bool SV_CheckWater( edict_t *ent ) if( SV_PointContents( point ) & MASK_WATER ) { ent->v.waterlevel = 3; - if( ent->pvEngineData->s.ed_type == ED_CLIENT ) + if( ent->pvServerData->s.ed_type == ED_CLIENT ) ent->v.renderfx |= RDF_UNDERWATER; } else { - if( ent->pvEngineData->s.ed_type == ED_CLIENT ) + if( ent->pvServerData->s.ed_type == ED_CLIENT ) ent->v.renderfx &= ~RDF_UNDERWATER; } } @@ -1087,7 +1103,7 @@ void SV_WalkMove( edict_t *ent ) trace_t downtrace; // if frametime is 0 (due to client sending the same timestamp twice), don't move - if( svs.globals->frametime <= 0 ) return; + if( svgame.globals->frametime <= 0 ) return; contentsmask = SV_ContentsMask( ent ); SV_CheckVelocity( ent ); @@ -1097,7 +1113,7 @@ void SV_WalkMove( edict_t *ent ) VectorCopy( ent->v.origin, start_origin ); VectorCopy( ent->v.velocity, start_velocity ); - clip = SV_FlyMove( ent, svs.globals->frametime, NULL, contentsmask ); + clip = SV_FlyMove( ent, svgame.globals->frametime, NULL, contentsmask ); // if the move did not hit the ground at any point, we're not on ground if(!(clip & 1)) ent->v.flags &= ~FL_ONGROUND; @@ -1144,7 +1160,7 @@ void SV_WalkMove( edict_t *ent ) // move forward ent->v.velocity[2] = 0; - clip = SV_FlyMove( ent, svs.globals->frametime, stepnormal, contentsmask ); + clip = SV_FlyMove( ent, svgame.globals->frametime, stepnormal, contentsmask ); ent->v.velocity[2] += start_velocity[2]; SV_CheckVelocity( ent ); @@ -1170,7 +1186,7 @@ void SV_WalkMove( edict_t *ent ) // move down VectorClear( downmove ); - downmove[2] = -sv_stepheight->value + start_velocity[2] * svs.globals->frametime; + downmove[2] = -sv_stepheight->value + start_velocity[2] * svgame.globals->frametime; downtrace = SV_PushEntity( ent, downmove, false ); // FIXME: don't link? if( downtrace.fraction < 1 && downtrace.plane.normal[2] > 0.7 ) @@ -1314,7 +1330,7 @@ void SV_Physics_Toss( edict_t *ent ) // we can trust FL_ONGROUND if groundentity is world because it never moves return; } - else if( ent->pvEngineData->suspended && ent->v.groundentity->free ) + else if( ent->pvServerData->suspended && ent->v.groundentity->free ) { // if ent was supported by a brush model on previous frame, // and groundentity is now freed, set groundentity to 0 (world) @@ -1323,7 +1339,7 @@ void SV_Physics_Toss( edict_t *ent ) return; } } - ent->pvEngineData->suspended = false; + ent->pvServerData->suspended = false; SV_CheckVelocity( ent ); @@ -1332,10 +1348,10 @@ void SV_Physics_Toss( edict_t *ent ) SV_AddGravity( ent ); // move angles - VectorMA( ent->v.angles, svs.globals->frametime, ent->v.avelocity, ent->v.angles ); + VectorMA( ent->v.angles, svgame.globals->frametime, ent->v.avelocity, ent->v.angles ); // move origin - VectorScale( ent->v.velocity, svs.globals->frametime, move ); + VectorScale( ent->v.velocity, svgame.globals->frametime, move ); trace = SV_PushEntity( ent, move, true ); if( ent->free ) return; @@ -1372,7 +1388,7 @@ void SV_Physics_Toss( edict_t *ent ) ent->v.flags |= FL_ONGROUND; ent->v.groundentity = trace.ent; if( trace.ent && trace.ent->v.solid == SOLID_BSP ) - ent->pvEngineData->suspended = true; + ent->pvServerData->suspended = true; VectorClear( ent->v.velocity ); VectorClear( ent->v.avelocity ); } @@ -1417,9 +1433,9 @@ void SV_Physics_Step( edict_t *ent ) ent->v.flags &= ~FL_ONGROUND; SV_AddGravity( ent ); SV_CheckVelocity( ent ); - SV_FlyMove( ent, svs.globals->frametime, NULL, SV_ContentsMask( ent )); + SV_FlyMove( ent, svgame.globals->frametime, NULL, SV_ContentsMask( ent )); SV_LinkEdict( ent ); - ent->pvEngineData->forceupdate = true; + ent->pvServerData->forceupdate = true; } } else @@ -1429,7 +1445,7 @@ void SV_Physics_Step( edict_t *ent ) SV_AddGravity( ent ); SV_CheckVelocity( ent ); - SV_FlyMove( ent, svs.globals->frametime, NULL, SV_ContentsMask( ent )); + SV_FlyMove( ent, svgame.globals->frametime, NULL, SV_ContentsMask( ent )); SV_LinkEdict( ent ); // just hit ground @@ -1438,17 +1454,17 @@ void SV_Physics_Step( edict_t *ent ) Msg("Landing crash\n"); //SV_StartSound(ent, 0, sv_sound_land.string, 255, 1); } - ent->pvEngineData->forceupdate = true; + ent->pvServerData->forceupdate = true; } } // regular thinking if(!SV_RunThink( ent )) return; - if( ent->pvEngineData->forceupdate || !VectorCompare( ent->v.origin, ent->pvEngineData->water_origin)) + if( ent->pvServerData->forceupdate || !VectorCompare( ent->v.origin, ent->pvServerData->water_origin)) { - ent->pvEngineData->forceupdate = false; - VectorCopy( ent->v.origin, ent->pvEngineData->water_origin ); + ent->pvServerData->forceupdate = false; + VectorCopy( ent->v.origin, ent->pvServerData->water_origin ); SV_CheckWaterTransition( ent ); } } @@ -1500,7 +1516,7 @@ void SV_Physics_Conveyor( edict_t *ent ) move[2] = v[2] * 0.1f; } VectorAdd( player->v.origin, move, end ); - tr = SV_Trace( player->v.origin, player->v.mins, player->v.maxs, end, MOVE_NORMAL, player, player->pvEngineData->clipmask ); + tr = SV_Trace( player->v.origin, player->v.mins, player->v.maxs, end, MOVE_NORMAL, player, player->pvServerData->clipmask ); VectorCopy( tr.endpos, player->v.origin ); SV_LinkEdict( player ); } @@ -1520,8 +1536,8 @@ void SV_Physics_Noclip( edict_t *ent ) if(SV_RunThink( ent )) { SV_CheckWater( ent ); - VectorMA( ent->v.angles, svs.globals->frametime, ent->v.avelocity, ent->v.angles ); - VectorMA( ent->v.origin, svs.globals->frametime, ent->v.velocity, ent->v.origin ); + VectorMA( ent->v.angles, svgame.globals->frametime, ent->v.avelocity, ent->v.angles ); + VectorMA( ent->v.origin, svgame.globals->frametime, ent->v.velocity, ent->v.origin ); } SV_LinkEdict( ent ); } @@ -1536,7 +1552,7 @@ Non moving objects can only think */ void SV_Physics_None( edict_t *ent ) { - if (ent->v.nextthink > 0 && ent->v.nextthink <= sv.time + svs.globals->frametime) + if (ent->v.nextthink > 0 && ent->v.nextthink <= sv.time + svgame.globals->frametime) SV_RunThink (ent); } @@ -1582,14 +1598,14 @@ static void SV_Physics_Entity( edict_t *ent ) SV_Physics_Conveyor( ent ); break; default: - svs.dllFuncs.pfnFrame( ent ); + svgame.dllFuncs.pfnFrame( ent ); break; } } void SV_Physics_ClientEntity( edict_t *ent ) { - sv_client_t *client = ent->pvEngineData->client; + sv_client_t *client = ent->pvServerData->client; if( !client ) return;//Host_Error( "SV_Physics_ClientEntity: tired to apply physic to a non-client entity\n" ); @@ -1609,8 +1625,8 @@ void SV_Physics_ClientEntity( edict_t *ent ) VectorClear( ent->v.velocity ); // call standard client pre-think - svs.globals->time = sv.time; - svs.dllFuncs.pfnPlayerPreThink( ent ); + svgame.globals->time = sv.time; + svgame.dllFuncs.pfnPlayerPreThink( ent ); SV_CheckVelocity( ent ); switch((int)ent->v.movetype ) @@ -1628,8 +1644,8 @@ void SV_Physics_ClientEntity( edict_t *ent ) case MOVETYPE_NOCLIP: SV_RunThink( ent ); SV_CheckWater( ent ); - VectorMA( ent->v.origin, svs.globals->frametime, ent->v.velocity, ent->v.origin ); - VectorMA( ent->v.angles, svs.globals->frametime, ent->v.avelocity, ent->v.angles ); + VectorMA( ent->v.origin, svgame.globals->frametime, ent->v.velocity, ent->v.origin ); + VectorMA( ent->v.angles, svgame.globals->frametime, ent->v.avelocity, ent->v.angles ); break; case MOVETYPE_STEP: SV_Physics_Step( ent ); @@ -1672,8 +1688,8 @@ void SV_Physics_ClientEntity( edict_t *ent ) SV_TouchTriggers( ent ); // call standard player post-think - svs.globals->time = sv.time; - svs.dllFuncs.pfnPlayerPostThink( ent ); + svgame.globals->time = sv.time; + svgame.dllFuncs.pfnPlayerPostThink( ent ); } void SV_Physics_ClientMove( sv_client_t *client, usercmd_t *cmd ) @@ -1681,14 +1697,14 @@ void SV_Physics_ClientMove( sv_client_t *client, usercmd_t *cmd ) edict_t *ent = client->edict; // call player physics, this needs the proper frametime - svs.globals->frametime = sv.frametime; + svgame.globals->frametime = sv.frametime; SV_ClientThink( client, cmd ); // call standard client pre-think, with frametime = 0 - svs.globals->time = sv.time; - svs.globals->frametime = 0; - svs.dllFuncs.pfnPlayerPreThink( ent ); - svs.globals->frametime = sv.frametime; + svgame.globals->time = sv.time; + svgame.globals->frametime = 0; + svgame.dllFuncs.pfnPlayerPreThink( ent ); + svgame.globals->frametime = sv.frametime; if( !sv_physics->integer ) { @@ -1708,8 +1724,8 @@ void SV_Physics_ClientMove( sv_client_t *client, usercmd_t *cmd ) break; case MOVETYPE_NOCLIP: SV_CheckWater( ent ); - VectorMA( ent->v.origin, svs.globals->frametime, ent->v.velocity, ent->v.origin ); - VectorMA( ent->v.angles, svs.globals->frametime, ent->v.avelocity, ent->v.angles ); + VectorMA( ent->v.origin, svgame.globals->frametime, ent->v.velocity, ent->v.origin ); + VectorMA( ent->v.angles, svgame.globals->frametime, ent->v.avelocity, ent->v.angles ); break; } SV_CheckVelocity( ent ); @@ -1722,10 +1738,10 @@ void SV_Physics_ClientMove( sv_client_t *client, usercmd_t *cmd ) SV_TouchTriggers( ent ); // call standard player post-think, with frametime = 0 - svs.globals->time = sv.time; - svs.globals->frametime = 0; - svs.dllFuncs.pfnPlayerPostThink( ent ); - svs.globals->frametime = sv.frametime; + svgame.globals->time = sv.time; + svgame.globals->frametime = 0; + svgame.dllFuncs.pfnPlayerPostThink( ent ); + svgame.globals->frametime = sv.frametime; } /* @@ -1740,12 +1756,12 @@ void SV_Physics( void ) edict_t *ent; // let the progs know that a new frame has started - svs.globals->time = sv.time; - svs.globals->frametime = sv.frametime; - svs.dllFuncs.pfnStartFrame(); + svgame.globals->time = sv.time; + svgame.globals->frametime = sv.frametime; + svgame.dllFuncs.pfnStartFrame(); // treat each object in turn - for( i = 1; i < svs.globals->numEntities; i++ ) + for( i = 1; i < svgame.globals->numEntities; i++ ) { ent = EDICT_NUM( i ); if( ent->free ) continue; @@ -1756,12 +1772,12 @@ void SV_Physics( void ) } // let everything in the world think and move - pe->Frame( svs.globals->frametime * 0.001f ); + pe->Frame( svgame.globals->frametime * 0.001f ); - svs.globals->time = sv.time; + svgame.globals->time = sv.time; // at end of frame kill all entities which supposed to it - for( i = svs.globals->maxClients + 1; i < svs.globals->numEntities; i++ ) + for( i = svgame.globals->maxClients + 1; i < svgame.globals->numEntities; i++ ) { ent = EDICT_NUM( i ); if( ent->free ) continue; @@ -1770,10 +1786,10 @@ void SV_Physics( void ) SV_FreeEdict( EDICT_NUM( i )); } - svs.dllFuncs.pfnEndFrame(); + svgame.dllFuncs.pfnEndFrame(); - // decrement svs.globals->numEntities if the highest number entities died - for( ; EDICT_NUM( svs.globals->numEntities - 1)->free; svs.globals->numEntities-- ); + // decrement svgame.globals->numEntities if the highest number entities died + for( ; EDICT_NUM( svgame.globals->numEntities - 1)->free; svgame.globals->numEntities-- ); if( !sv_playersonly->integer ) sv.time += sv.frametime; } \ No newline at end of file diff --git a/engine/server/sv_progs.c b/engine/server/sv_progs.c index 93af77ff..5a0dc445 100644 --- a/engine/server/sv_progs.c +++ b/engine/server/sv_progs.c @@ -9,32 +9,6 @@ #include "matrix_lib.h" #include "const.h" -void SV_BeginIncreaseEdicts( void ) -{ - int i; - edict_t *ent; - - // links don't survive the transition, so unlink everything - for( i = 0, ent = EDICT_NUM( 0 ); i < svs.globals->maxEntities; i++, ent++ ) - { - if( !ent->free ) SV_UnlinkEdict( EDICT_NUM( i )); // free old entity - Mem_Set( &ent->pvEngineData->clusternums, 0, sizeof( ent->pvEngineData->clusternums )); - } - SV_ClearWorld(); -} - -void SV_EndIncreaseEdicts(void) -{ - int i; - edict_t *ent; - - for( i = 0, ent = EDICT_NUM( 0 ); i < svs.globals->maxEntities; i++, ent++ ) - { - // link every entity except world - if( !ent->free ) SV_LinkEdict(ent); - } -} - void SV_RestoreEdict( edict_t *ent ) { // link it into the bsp tree @@ -44,5 +18,5 @@ void SV_RestoreEdict( edict_t *ent ) SV_SetMassCentre( ent ); // and mass force if( ent->v.ambient ) // restore loopsound - ent->pvEngineData->s.soundindex = SV_SoundIndex( STRING( ent->v.ambient )); + ent->pvServerData->s.soundindex = SV_SoundIndex( STRING( ent->v.ambient )); } \ No newline at end of file diff --git a/engine/server/sv_world.c b/engine/server/sv_world.c index 7acd371b..1504a13b 100644 --- a/engine/server/sv_world.c +++ b/engine/server/sv_world.c @@ -176,10 +176,10 @@ sorting edict by type */ void SV_ClassifyEdict( edict_t *ent ) { - ed_priv_t *sv_ent; + sv_priv_t *sv_ent; const char *classname; - sv_ent = ent->pvEngineData; + sv_ent = ent->pvServerData; if( !sv_ent || sv_ent->s.ed_type != ED_SPAWNED ) return; @@ -243,10 +243,10 @@ SV_UnlinkEdict void SV_UnlinkEdict( edict_t *ent ) { // not linked in anywhere - if( !ent->pvEngineData->area.prev ) return; + if( !ent->pvServerData->area.prev ) return; - SV_RemoveLink( &ent->pvEngineData->area ); - ent->pvEngineData->area.prev = ent->pvEngineData->area.next = NULL; + SV_RemoveLink( &ent->pvServerData->area ); + ent->pvServerData->area.prev = ent->pvServerData->area.next = NULL; } /* @@ -263,9 +263,9 @@ void SV_LinkEdict( edict_t *ent ) int i, j, k; int area; int topnode; - ed_priv_t *sv_ent; + sv_priv_t *sv_ent; - sv_ent = ent->pvEngineData; + sv_ent = ent->pvServerData; if( sv_ent->area.prev ) SV_UnlinkEdict( ent ); // unlink from old position if( ent == EDICT_NUM( 0 )) return; // don't add the world @@ -394,12 +394,12 @@ void SV_LinkEdict( edict_t *ent ) } } - ent->pvEngineData->linkcount++; + ent->pvServerData->linkcount++; // update ambient sound here if( ent->v.ambient ) { - ent->pvEngineData->s.soundindex = SV_SoundIndex( STRING( ent->v.ambient )); + ent->pvServerData->s.soundindex = SV_SoundIndex( STRING( ent->v.ambient )); } // don't link not solid or rigid bodies diff --git a/public/clgame_api.h b/public/clgame_api.h index af0213e2..a6324c05 100644 --- a/public/clgame_api.h +++ b/public/clgame_api.h @@ -98,17 +98,20 @@ typedef struct typedef struct ref_params_s { // output + int viewport[4]; // x, y, width, height vec3_t vieworg; vec3_t viewangles; - float fov; + float fov_x; + float fov_y; // fov_y = V_CalcFov( fov_x, viewport[2], viewport[3] ); vec3_t forward; vec3_t right; vec3_t up; float frametime; // client frametime - float lerpfrac; // interp value + float lerpfrac; // between oldframe and frame float time; // client time + float oldtime; // studio lerping // misc BOOL intermission; @@ -116,15 +119,19 @@ typedef struct ref_params_s BOOL demorecord; BOOL spectator; BOOL paused; + uint rdflags; // client view effects: RDF_UNDERWATER, RDF_MOTIONBLUR, etc qword iWeaponBits; // pev->weapon dword iKeyBits; // pev->button edict_t *onground; // pointer to onground entity + byte *areabits; // come from server, contains visible areas list int waterlevel; // input vec3_t velocity; vec3_t angles; // input viewangles vec3_t origin; // origin + viewheight = vieworg + vec3_t old_angles; // prev.state values to interpolate from + vec3_t old_origin; vec3_t viewheight; float idealpitch; @@ -164,7 +171,7 @@ typedef struct cl_enginefuncs_s // command handlers void (*pfnAddCommand)( const char *cmd_name, void (*function)(void), const char *cmd_desc ); - void (*pfnHookUserMsg)( char *szMsgName, pfnUserMsgHook pfn ); + void (*pfnHookUserMsg)( const char *szMsgName, pfnUserMsgHook pfn ); void (*pfnServerCmd)( const char *szCmdString ); void (*pfnClientCmd)( const char *szCmdString ); void (*pfnGetPlayerInfo)( int player_num, hud_player_info_t *pinfo ); @@ -195,6 +202,7 @@ typedef struct cl_enginefuncs_s float (*pfnGetClientTime)( void ); int (*pfnGetMaxClients)( void ); edict_t* (*pfnGetViewModel)( void ); + void (*pfnMakeLevelShot)( void ); // level shot will be created at next frame int (*pfnPointContents)( const float *rgflVector ); void (*pfnTraceLine)( const float *v1, const float *v2, int fNoMonsters, edict_t *pentToSkip, TraceResult *ptr ); @@ -217,7 +225,7 @@ typedef struct int (*pfnVidInit)( void ); void (*pfnInit)( void ); - int (*pfnRedraw)( float flTime, int intermission ); + int (*pfnRedraw)( float flTime, int state ); int (*pfnUpdateClientData)( ref_params_t *parms, float flTime ); void (*pfnReset)( void ); void (*pfnFrame)( double time ); diff --git a/public/const.h b/public/const.h index bcb1ccc3..d5952ab2 100644 --- a/public/const.h +++ b/public/const.h @@ -195,10 +195,10 @@ typedef enum } 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) +#define BEAM_FSINE (1<<3) +#define BEAM_FSOLID (1<<4) +#define BEAM_FSHADEIN (1<<5) +#define BEAM_FSHADEOUT (1<<6) // rendering constants typedef enum @@ -228,19 +228,29 @@ typedef enum kRenderFxNoReflect, // don't reflecting in mirrors } kRenderFx_t; +// player_state_t->renderfx +#define RDF_UNDERWATER (1<<0) // warp the screen as apropriate +#define RDF_NOWORLDMODEL (1<<1) // used for player configuration screen +#define RDF_BLOOM (1<<2) // light blooms + // all drawing is done to a 640*480 virtual screen size // and will be automatically scaled to the real resolution #define SCREEN_WIDTH 640 #define SCREEN_HEIGHT 480 -#define TINYCHAR_WIDTH (SMALLCHAR_WIDTH) -#define TINYCHAR_HEIGHT (SMALLCHAR_HEIGHT/2) -#define SMALLCHAR_WIDTH 8 -#define SMALLCHAR_HEIGHT 16 -#define BIGCHAR_WIDTH 16 -#define BIGCHAR_HEIGHT 24 -#define GIANTCHAR_WIDTH 32 -#define GIANTCHAR_HEIGHT 48 +// client screen state +#define CL_DISCONNECTED 1 // +#define CL_LOADING 2 // draw loading progress-bar +#define CL_ACTIVE 3 // draw normal hud + +#define TINYCHAR_WIDTH (SMALLCHAR_WIDTH) +#define TINYCHAR_HEIGHT (SMALLCHAR_HEIGHT/2) +#define SMALLCHAR_WIDTH 8 +#define SMALLCHAR_HEIGHT 16 +#define BIGCHAR_WIDTH 16 +#define BIGCHAR_HEIGHT 24 +#define GIANTCHAR_WIDTH 32 +#define GIANTCHAR_HEIGHT 48 #define HUD_PRINTNOTIFY 1 #define HUD_PRINTCONSOLE 2 diff --git a/public/entity_def.h b/public/entity_def.h index f477cf12..9a21e1f5 100644 --- a/public/entity_def.h +++ b/public/entity_def.h @@ -5,8 +5,9 @@ #ifndef ENTITY_DEF_H #define ENTITY_DEF_H -typedef struct ed_priv_s ed_priv_t; // engine private data -typedef struct edict_s edict_t; +typedef struct cl_priv_s cl_priv_t; // cl.engine private data +typedef struct sv_priv_s sv_priv_t; // sv.engine private data +typedef struct edict_s edict_t; // generic entity // TODO: move to CBaseEntity all fields which doesn't existing on client side // TODO: generic edict must have all fields as valid on client side too @@ -140,19 +141,20 @@ typedef struct entvars_s 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; + BOOL free; // shared parms float freetime; // sv.time when the object was freed - int serialnumber; + int serialnumber; // must match with entity num - ed_priv_t *pvEngineData; // alloced, freed and used by engine only - void *pvServerData; // alloced and freed by engine, used by DLLs + union + { + sv_priv_t *pvServerData; // alloced, freed and used by engine only + cl_priv_t *pvClientData; // alloced, freed and used by engine only + }; + + void *pvPrivateData; // 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//ENTITY_DEF_H \ No newline at end of file diff --git a/public/render_api.h b/public/render_api.h index 69609203..add55b8d 100644 --- a/public/render_api.h +++ b/public/render_api.h @@ -11,18 +11,6 @@ #define SHADER_NOMIP 2 // 2d images #define SHADER_GENERIC 3 // generic shader -// player_state_t->renderfx -#define RDF_UNDERWATER (1<<0) // warp the screen as apropriate -#define RDF_NOWORLDMODEL (1<<1) // used for player configuration screen -#define RDF_BLOOM (1<<2) // light blooms - -typedef struct vrect_s -{ - int x, y; - int width; - int height; -} vrect_t; - typedef struct { vec3_t point; @@ -36,19 +24,6 @@ typedef struct int numVerts; } decalFragment_t; -typedef struct -{ - vrect_t rect; // screen rectangle - float fov_x; // field of view by vertical - float fov_y; // field of view by horizontal - vec3_t vieworg; // client origin + viewoffset - vec3_t viewangles; // client angles - float time; // time is used to shaders auto animate - float oldtime; // oldtime using for lerping studio models - uint rdflags; // client view effects: RDF_UNDERWATER, RDF_MOTIONBLUR, etc - byte *areabits; // if not NULL, only areas with set bits will be drawn -} refdef_t; - /* ============================================================================== @@ -78,7 +53,7 @@ typedef struct render_exp_s void (*ClearScene)( void ); void (*BeginFrame)( void ); - void (*RenderFrame)( refdef_t *fd ); + void (*RenderFrame)( ref_params_t *fd ); void (*EndFrame)( void ); // misc utilities diff --git a/public/svgame_api.h b/public/svgame_api.h index 5c6e35fb..3dd3788f 100644 --- a/public/svgame_api.h +++ b/public/svgame_api.h @@ -162,7 +162,6 @@ typedef struct enginefuncs_s 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 ); diff --git a/release.bat b/release.bat index d2130fd3..b7416417 100644 --- a/release.bat +++ b/release.bat @@ -58,6 +58,7 @@ goto done rem //delete log files if exist baserc\baserc.plg del /f /q baserc\baserc.plg +if exist client\client.plg del /f /q client\client.plg if exist engine\engine.plg del /f /q engine\engine.plg if exist launch\launch.plg del /f /q launch\launch.plg if exist common\common.plg del /f /q common\common.plg diff --git a/render/gl_backend.c b/render/gl_backend.c index d7821f7b..647ec7a7 100644 --- a/render/gl_backend.c +++ b/render/gl_backend.c @@ -1041,9 +1041,9 @@ void GL_Setup3D( void ) int bits; if( gl_finish->integer ) pglFinish(); - x = r_refdef.rect.x; - y = r_height->integer - r_refdef.rect.height - r_refdef.rect.y; - w = r_refdef.rect.width; + x = r_refdef.viewport[0]; + y = r_height->integer - r_refdef.viewport[3] - r_refdef.viewport[1]; + w = r_refdef.viewport[2]; h = r_height->integer; // Set up viewport diff --git a/render/r_backend.h b/render/r_backend.h index 469783d7..4e196dfc 100644 --- a/render/r_backend.h +++ b/render/r_backend.h @@ -151,7 +151,7 @@ typedef struct int width; int height; - vrect_t viewport; + int viewport[4]; viewParms_t viewParms; ref_entity_t *CurrentEntity; diff --git a/render/r_bloom.c b/render/r_bloom.c index 3023298c..c6e03250 100644 --- a/render/r_bloom.c +++ b/render/r_bloom.c @@ -399,7 +399,7 @@ void R_Bloom_DownsampleView( void ) R_BloomBlend ================= */ -void R_BloomBlend( const refdef_t *fd ) +void R_BloomBlend( const ref_params_t *fd ) { if( !r_bloom->value ) return; if( screen_texture_width < BLOOM_SIZE || screen_texture_height < BLOOM_SIZE ) @@ -421,21 +421,21 @@ void R_BloomBlend( const refdef_t *fd ) pglColor4f( 1, 1, 1, 1 ); // set up current sizes - curView_x = fd->rect.x; - curView_y = fd->rect.y; - curView_width = fd->rect.width; - curView_height = fd->rect.height; - screenText_tcw = ((float)fd->rect.width / (float)screen_texture_width); - screenText_tch = ((float)fd->rect.height / (float)screen_texture_height); - if( fd->rect.height > fd->rect.width ) + curView_x = fd->viewport[0]; + curView_y = fd->viewport[1]; + curView_width = fd->viewport[2]; + curView_height = fd->viewport[3]; + screenText_tcw = ((float)fd->viewport[2] / (float)screen_texture_width); + screenText_tch = ((float)fd->viewport[3] / (float)screen_texture_height); + if( fd->viewport[3] > fd->viewport[2] ) { - sampleText_tcw = ((float)fd->rect.width / (float)fd->rect.height); + sampleText_tcw = ((float)fd->viewport[2] / (float)fd->viewport[3]); sampleText_tch = 1.0f; } else { sampleText_tcw = 1.0f; - sampleText_tch = ((float)fd->rect.height / (float)fd->rect.width); + sampleText_tch = ((float)fd->viewport[3] / (float)fd->viewport[2]); } sample_width = BLOOM_SIZE * sampleText_tcw; sample_height = BLOOM_SIZE * sampleText_tch; diff --git a/render/r_draw.c b/render/r_draw.c index cf92cf7c..81d895d9 100644 --- a/render/r_draw.c +++ b/render/r_draw.c @@ -15,13 +15,19 @@ this is needed by some client drawing functions void R_GetPicSize( int *w, int *h, shader_t handle ) { ref_shader_t *shader; - - if( handle >= 0 && handle < MAX_SHADERS && (shader = &r_shaders[handle])) + + if( !w && !h ) return; + + if( 0 ) //handle >= 0 && handle < MAX_SHADERS && (shader = &r_shaders[handle])) { - *w = (int)shader->stages[0]->bundles[0]->textures[0]->width; - *h = (int)shader->stages[0]->bundles[0]->textures[0]->height; + if( w ) *w = (int)shader->stages[0]->bundles[0]->textures[0]->width; + if( h ) *h = (int)shader->stages[0]->bundles[0]->textures[0]->height; + } + else + { + if( w ) *w = -1; + if( h ) *h = -1; } - else *w = *h = -1; } diff --git a/render/r_image.c b/render/r_image.c index ba032f85..a29ff671 100644 --- a/render/r_image.c +++ b/render/r_image.c @@ -3227,10 +3227,10 @@ bool VID_CubemapShot( const char *base, uint size, bool skyshot ) return false; // setup refdef - r_refdef.rect.x = 0; - r_refdef.rect.y = 0; - r_refdef.rect.width = size; - r_refdef.rect.height = size; + r_refdef.viewport[0] = 0; + r_refdef.viewport[1] = 0; + r_refdef.viewport[2] = size; + r_refdef.viewport[3] = size; r_refdef.fov_x = 90; r_refdef.fov_y = 90; diff --git a/render/r_local.h b/render/r_local.h index d5c6a220..048eadda 100644 --- a/render/r_local.h +++ b/render/r_local.h @@ -10,6 +10,8 @@ #include "launch_api.h" #include "qfiles_ref.h" #include "engine_api.h" +#include "entity_def.h" +#include "clgame_api.h" #include "render_api.h" #include "r_opengl.h" @@ -762,7 +764,7 @@ extern ref_entity_t *r_nullModels[MAX_ENTITIES]; extern int r_numNullModels; extern lightstyle_t r_lightStyles[MAX_LIGHTSTYLES]; -extern refdef_t r_refdef; +extern ref_params_t r_refdef; extern refstats_t r_stats; void R_DrawStudioModel( void ); @@ -793,10 +795,10 @@ void R_DrawSprite( void ); void R_DrawBeam( void ); void R_DrawParticle( void ); void R_DrawPoly( void ); -void R_RenderView( const refdef_t *fd ); +void R_RenderView( const ref_params_t *fd ); void R_AddShadowToList( ref_entity_t *entity ); void R_RenderShadows( void ); -void R_BloomBlend ( const refdef_t *fd ); +void R_BloomBlend ( const ref_params_t *fd ); void R_DrawSky( void ); void R_ClearSky( void ); void R_ClipSkySurface( surface_t *surf ); diff --git a/render/r_main.c b/render/r_main.c index 27b7841c..bf871738 100644 --- a/render/r_main.c +++ b/render/r_main.c @@ -38,7 +38,7 @@ int r_numPolys; polyVert_t r_polyVerts[MAX_POLY_VERTS]; int r_numPolyVerts; int r_numNullModels; -refdef_t r_refdef; +ref_params_t r_refdef; refstats_t r_stats; byte *r_framebuffer; // pause frame buffer float r_pause_alpha; @@ -869,7 +869,7 @@ static void R_SetMatrices( void ) R_RenderView ================= */ -void R_RenderView( const refdef_t *fd ) +void R_RenderView( const ref_params_t *fd ) { if( r_skipfrontend->integer ) return; @@ -1233,7 +1233,7 @@ bool R_AddPolyToScene( shader_t shader, int numVerts, const polyVert_t *verts ) R_RenderFrame ================= */ -void R_RenderFrame( refdef_t *rd ) +void R_RenderFrame( ref_params_t *rd ) { if( r_norefresh->integer ) return; diff --git a/server/ents/baseentity.cpp b/server/ents/baseentity.cpp index a7f2742e..c7c0759b 100644 --- a/server/ents/baseentity.cpp +++ b/server/ents/baseentity.cpp @@ -413,7 +413,7 @@ void CBaseEntity::FireBullets(ULONG cShots, Vector vecSrc, Vector vecDirShooting case BULLET_762: case BULLET_BUCKSHOT: default: - MESSAGE_BEGIN( MSG_PAS, SVC_TEMPENTITY, vecTracerSrc ); + MESSAGE_BEGIN( MSG_PAS, gmsg.TempEntity, vecTracerSrc ); WRITE_BYTE( TE_TRACER ); WRITE_COORD( vecTracerSrc.x ); WRITE_COORD( vecTracerSrc.y ); diff --git a/server/ents/basefunc.cpp b/server/ents/basefunc.cpp index f391ab8c..69461fc7 100644 --- a/server/ents/basefunc.cpp +++ b/server/ents/basefunc.cpp @@ -475,7 +475,7 @@ void CFuncMirror :: Spawn( void ) void CFuncMirror :: StartMessage( CBasePlayer *pPlayer ) { - MESSAGE_BEGIN( MSG_ONE, gmsgAddMirror, NULL, pPlayer->pev ); + MESSAGE_BEGIN( MSG_ONE, gmsg.AddMirror, NULL, pPlayer->pev ); WRITE_SHORT( entindex() ); MESSAGE_END(); } @@ -570,7 +570,7 @@ int CFuncMonitor :: ObjectCaps( void ) void CFuncMonitor::StartMessage( CBasePlayer *pPlayer ) { //send monitor index - MESSAGE_BEGIN( MSG_ONE, gmsgAddScreen, NULL, pPlayer->pev ); + MESSAGE_BEGIN( MSG_ONE, gmsg.AddScreen, NULL, pPlayer->pev ); WRITE_BYTE( entindex() ); MESSAGE_END(); ChangeCamera( pev->target ); @@ -668,7 +668,7 @@ void CFuncTeleport :: Spawn( void ) void CFuncTeleport::StartMessage( CBasePlayer *pPlayer ) { //send portal index - MESSAGE_BEGIN( MSG_ONE, gmsgAddPortal, NULL, pPlayer->pev ); + MESSAGE_BEGIN( MSG_ONE, gmsg.AddPortal, NULL, pPlayer->pev ); WRITE_BYTE( entindex() ); MESSAGE_END(); ChangeCamera( pev->target ); diff --git a/server/ents/basefx.cpp b/server/ents/basefx.cpp index d5a86b06..1edc29a3 100644 --- a/server/ents/basefx.cpp +++ b/server/ents/basefx.cpp @@ -117,7 +117,7 @@ void CEnvSky :: PostSpawn( void ) void CEnvSky :: StartMessage( CBasePlayer *pPlayer ) { pev->effects |= EF_NODRAW; - MESSAGE_BEGIN( MSG_ONE, gmsgSetSky, NULL, pPlayer->pev ); + MESSAGE_BEGIN( MSG_ONE, gmsg.SetSky, NULL, pPlayer->pev ); WRITE_BYTE( 1 ); // mode WRITE_COORD( pev->origin.x ); // view position WRITE_COORD( pev->origin.y ); diff --git a/server/ents/baseinfo.cpp b/server/ents/baseinfo.cpp index dbd16e57..3dc96e51 100644 --- a/server/ents/baseinfo.cpp +++ b/server/ents/baseinfo.cpp @@ -8,6 +8,7 @@ #include "utils.h" #include "cbase.h" #include "player.h" +#include "client.h" //======================================================================= // info_target (target entity) @@ -73,7 +74,7 @@ public: if(FStringNull(pev->targetname)) g_engfuncs.pfnStaticDecal( pev->origin, (int)pev->skin, entityIndex, modelIndex ); else { - MESSAGE_BEGIN( MSG_BROADCAST, SVC_TEMPENTITY); + MESSAGE_BEGIN( MSG_BROADCAST, gmsg.TempEntity ); WRITE_BYTE( TE_BSPDECAL ); WRITE_COORD( pev->origin.x ); WRITE_COORD( pev->origin.y ); diff --git a/server/ents/baseitem.cpp b/server/ents/baseitem.cpp index f59c4e41..f16b5107 100644 --- a/server/ents/baseitem.cpp +++ b/server/ents/baseitem.cpp @@ -9,12 +9,12 @@ #include "cbase.h" #include "saverestore.h" #include "baseweapon.h" +#include "client.h" #include "player.h" #include "gamerules.h" #include "defaults.h" extern int gEvilImpulse101; -extern int gmsgItemPickup; //*********************************************************** // main functions () @@ -56,10 +56,10 @@ void CItem::ItemTouch( CBaseEntity *pOther ) UTIL_FireTargets( pev->target, pOther, this, USE_TOGGLE ); SetTouch( NULL ); - if (IsItem() && gmsgItemPickup) + if (IsItem() && gmsg.ItemPickup) { //show icon for item - MESSAGE_BEGIN( MSG_ONE, gmsgItemPickup, NULL, pPlayer->pev ); + MESSAGE_BEGIN( MSG_ONE, gmsg.ItemPickup, NULL, pPlayer->pev ); WRITE_STRING( STRING(pev->classname) ); MESSAGE_END(); } @@ -178,7 +178,7 @@ class CGenericItem : public CItem EMIT_SOUND(ENT(pev), CHAN_ITEM, "weapons/glock/clip_in.wav", 1, ATTN_NORM); return TRUE; } - MESSAGE_BEGIN( MSG_ONE, gmsgItemPickup, NULL, pPlayer->pev ); + MESSAGE_BEGIN( MSG_ONE, gmsg.ItemPickup, NULL, pPlayer->pev ); WRITE_STRING( STRING(pev->classname) ); MESSAGE_END(); return FALSE; diff --git a/server/ents/baseother.cpp b/server/ents/baseother.cpp index afca77ef..e65a245d 100644 --- a/server/ents/baseother.cpp +++ b/server/ents/baseother.cpp @@ -7,6 +7,7 @@ #include "utils.h" #include "cbase.h" #include "player.h" +#include "client.h" //======================================================================= // sparkleent - explode post sparks @@ -146,7 +147,7 @@ void CSmokeEnt::Think( void ) Vector VecSrc = UTIL_RandomVector( pev->absmin, pev->absmax ); - MESSAGE_BEGIN( MSG_PVS, SVC_TEMPENTITY, VecSrc ); + MESSAGE_BEGIN( MSG_PVS, gmsg.TempEntity, VecSrc ); WRITE_BYTE( TE_SMOKE ); WRITE_COORD( VecSrc.x ); WRITE_COORD( VecSrc.y ); diff --git a/server/ents/baserockets.cpp b/server/ents/baserockets.cpp index 5275333f..8d70571d 100644 --- a/server/ents/baserockets.cpp +++ b/server/ents/baserockets.cpp @@ -9,6 +9,7 @@ #include "monsters.h" #include "baseweapon.h" #include "nodes.h" +#include "client.h" #include "soundent.h" #include "decals.h" #include "defaults.h" @@ -533,7 +534,7 @@ void CApacheHVR :: IgniteThink( void ) EMIT_SOUND( ENT(pev), CHAN_VOICE, "weapons/rocket1.wav", 1, 0.5 ); // rocket trail - MESSAGE_BEGIN( MSG_BROADCAST, SVC_TEMPENTITY ); + MESSAGE_BEGIN( MSG_BROADCAST, gmsg.TempEntity ); WRITE_BYTE( TE_BEAMFOLLOW ); WRITE_SHORT(entindex()); // entity WRITE_SHORT(m_iTrail ); // model diff --git a/server/ents/baseweapon.cpp b/server/ents/baseweapon.cpp index 914197fb..32d62d52 100644 --- a/server/ents/baseweapon.cpp +++ b/server/ents/baseweapon.cpp @@ -6,6 +6,7 @@ #include "extdll.h" #include "utils.h" #include "cbase.h" +#include "client.h" #include "player.h" #include "monsters.h" #include "baseweapon.h" @@ -18,8 +19,6 @@ extern int gEvilImpulse101; ItemInfo CBasePlayerWeapon::ItemInfoArray[MAX_WEAPONS]; AmmoInfo CBasePlayerWeapon::AmmoInfoArray[MAX_AMMO_SLOTS]; -extern int gmsgCurWeapon; -extern int gmsgWeapPickup; char NameItems[MAX_WEAPONS][29]; int ID[MAX_WEAPONS]; int GlobalID = 0; @@ -1587,7 +1586,7 @@ void CBasePlayerWeapon::ZoomUpdate( void ) } else if(m_iZoom > 1) m_iZoom = 3; - MESSAGE_BEGIN( MSG_ONE, gmsgZoomHUD, NULL, m_pPlayer->pev ); + MESSAGE_BEGIN( MSG_ONE, gmsg.ZoomHUD, NULL, m_pPlayer->pev ); WRITE_BYTE( m_iZoom ); MESSAGE_END(); } @@ -1601,7 +1600,7 @@ void CBasePlayerWeapon::ZoomReset( void ) m_flHoldTime = UTIL_WeaponTimeBase() + 0.5; m_pPlayer->m_iFOV = 90; m_iZoom = 0;//clear zoom - MESSAGE_BEGIN( MSG_ONE, gmsgZoomHUD, NULL, m_pPlayer->pev ); + MESSAGE_BEGIN( MSG_ONE, gmsg.ZoomHUD, NULL, m_pPlayer->pev ); WRITE_BYTE( m_iZoom ); MESSAGE_END(); m_pPlayer->UpdateClientData();//update client data manually @@ -1800,7 +1799,7 @@ int CBasePlayerWeapon::UpdateClientData( CBasePlayer *pPlayer ) if( m_iClientBody != m_iBody) { pev->body = (pev->body % NUM_HANDS) + NUM_HANDS * m_iBody; //calculate body - MESSAGE_BEGIN( MSG_ONE, gmsgSetBody, NULL, m_pPlayer->pev ); + MESSAGE_BEGIN( MSG_ONE, gmsg.SetBody, NULL, m_pPlayer->pev ); WRITE_BYTE( pev->body ); //weaponmodel body MESSAGE_END(); m_iClientBody = m_iBody;//synched @@ -1810,7 +1809,7 @@ int CBasePlayerWeapon::UpdateClientData( CBasePlayer *pPlayer ) if( m_iClientSkin != m_iSkin) { pev->skin = m_iSkin; //calculate skin - MESSAGE_BEGIN( MSG_ONE, gmsgSetSkin, NULL, m_pPlayer->pev ); + MESSAGE_BEGIN( MSG_ONE, gmsg.SetSkin, NULL, m_pPlayer->pev ); WRITE_BYTE( pev->skin ); //weaponmodel skin. MESSAGE_END(); m_iClientSkin = m_iSkin;//synched @@ -1839,7 +1838,7 @@ int CBasePlayerWeapon::UpdateClientData( CBasePlayer *pPlayer ) if ( bSend ) { - MESSAGE_BEGIN( MSG_ONE, gmsgCurWeapon, NULL, pPlayer->pev ); + MESSAGE_BEGIN( MSG_ONE, gmsg.CurWeapon, NULL, pPlayer->pev ); WRITE_BYTE( state ); WRITE_BYTE( m_iId ); WRITE_BYTE( m_iClip ); @@ -1912,7 +1911,7 @@ int CBasePlayerWeapon::AddToPlayer( CBasePlayer *pPlayer ) m_iSecondaryAmmoType = pPlayer->GetAmmoIndex( pszAmmo2() ); } - MESSAGE_BEGIN(MSG_ONE, gmsgWeapPickup, NULL, pPlayer->pev); + MESSAGE_BEGIN(MSG_ONE, gmsg.WeapPickup, NULL, pPlayer->pev); WRITE_BYTE(m_iId); MESSAGE_END(); diff --git a/server/game/game.cpp b/server/game/game.cpp index e609f437..f7b23a74 100644 --- a/server/game/game.cpp +++ b/server/game/game.cpp @@ -20,6 +20,8 @@ // This gets called one time when the game is initialied void GameDLLInit( void ) { + ALERT( at_console, "GameDLLInit();\n" ); + // register cvars here: CVAR_REGISTER( "sv_soundlist", "0", 0, "show server sound list" ); diff --git a/server/game/gamerules.cpp b/server/game/gamerules.cpp index e39ba126..ce099883 100644 --- a/server/game/gamerules.cpp +++ b/server/game/gamerules.cpp @@ -29,8 +29,6 @@ extern edict_t *EntSelectSpawnPoint( CBaseEntity *pPlayer ); DLL_GLOBAL CGameRules* g_pGameRules = NULL; extern DLL_GLOBAL BOOL g_fGameOver; -extern int gmsgDeathMsg; // client dll messages -extern int gmsgMOTD; int g_teamplay = 0; diff --git a/server/game/multiplay_gamerules.cpp b/server/game/multiplay_gamerules.cpp index 9211c6da..6b3e7328 100644 --- a/server/game/multiplay_gamerules.cpp +++ b/server/game/multiplay_gamerules.cpp @@ -20,6 +20,7 @@ #include "extdll.h" #include "utils.h" #include "cbase.h" +#include "client.h" #include "player.h" #include "baseweapon.h" #include "gamerules.h" @@ -29,11 +30,6 @@ extern DLL_GLOBAL CGameRules *g_pGameRules; extern DLL_GLOBAL BOOL g_fGameOver; -extern int gmsgDeathMsg; // client dll messages -extern int gmsgScoreInfo; -extern int gmsgMOTD; -extern int gmsgServerName; - extern int g_teamplay; #define ITEM_RESPAWN_TIME 30 @@ -321,12 +317,9 @@ BOOL CHalfLifeMultiplay :: ClientConnected( edict_t *pEntity, const char *userin return TRUE; } -extern int gmsgSayText; -extern int gmsgGameMode; - void CHalfLifeMultiplay :: UpdateGameMode( CBasePlayer *pPlayer ) { - MESSAGE_BEGIN( MSG_ONE, gmsgGameMode, NULL, pPlayer->edict() ); + MESSAGE_BEGIN( MSG_ONE, gmsg.GameMode, NULL, pPlayer->edict() ); WRITE_BYTE( 0 ); // game mode none MESSAGE_END(); } @@ -341,7 +334,7 @@ void CHalfLifeMultiplay :: InitHUD( CBasePlayer *pl ) // sending just one score makes the hud scoreboard active; otherwise // it is just disabled for single play - MESSAGE_BEGIN( MSG_ONE, gmsgScoreInfo, NULL, pl->edict() ); + MESSAGE_BEGIN( MSG_ONE, gmsg.ScoreInfo, NULL, pl->edict() ); WRITE_BYTE( ENTINDEX(pl->edict()) ); WRITE_SHORT( 0 ); WRITE_SHORT( 0 ); @@ -359,7 +352,7 @@ void CHalfLifeMultiplay :: InitHUD( CBasePlayer *pl ) if ( plr ) { - MESSAGE_BEGIN( MSG_ONE, gmsgScoreInfo, NULL, pl->edict() ); + MESSAGE_BEGIN( MSG_ONE, gmsg.ScoreInfo, NULL, pl->edict() ); WRITE_BYTE( i ); // client number WRITE_SHORT( plr->pev->frags ); WRITE_SHORT( plr->m_iDeaths ); @@ -371,7 +364,7 @@ void CHalfLifeMultiplay :: InitHUD( CBasePlayer *pl ) if ( g_fGameOver ) { - MESSAGE_BEGIN( MSG_ONE, SVC_INTERMISSION, NULL, pl->edict() ); + MESSAGE_BEGIN( MSG_ONE, gmsg.Intermission, NULL, pl->edict() ); MESSAGE_END(); } } @@ -525,7 +518,7 @@ void CHalfLifeMultiplay :: PlayerKilled( CBasePlayer *pVictim, entvars_t *pKille // update the scores // killed scores - MESSAGE_BEGIN( MSG_ALL, gmsgScoreInfo ); + MESSAGE_BEGIN( MSG_ALL, gmsg.ScoreInfo ); WRITE_BYTE( ENTINDEX(pVictim->edict()) ); WRITE_SHORT( pVictim->pev->frags ); WRITE_SHORT( pVictim->m_iDeaths ); @@ -539,7 +532,7 @@ void CHalfLifeMultiplay :: PlayerKilled( CBasePlayer *pVictim, entvars_t *pKille { CBasePlayer *PK = (CBasePlayer*)ep; - MESSAGE_BEGIN( MSG_ALL, gmsgScoreInfo ); + MESSAGE_BEGIN( MSG_ALL, gmsg.ScoreInfo ); WRITE_BYTE( ENTINDEX(PK->edict()) ); WRITE_SHORT( PK->pev->frags ); WRITE_SHORT( PK->m_iDeaths ); @@ -602,7 +595,7 @@ void CHalfLifeMultiplay::DeathNotice( CBasePlayer *pVictim, entvars_t *pKiller, else if ( strncmp( killer_weapon_name, "func_", 5 ) == 0 ) killer_weapon_name += 5; - MESSAGE_BEGIN( MSG_ALL, gmsgDeathMsg ); + MESSAGE_BEGIN( MSG_ALL, gmsg.DeathMsg ); WRITE_BYTE( killer_index ); // the killer WRITE_BYTE( ENTINDEX(pVictim->edict()) ); // the victim WRITE_STRING( killer_weapon_name ); // what they were killed by (should this be a string?) @@ -866,7 +859,7 @@ void CHalfLifeMultiplay :: GoToIntermission( void ) if ( g_fGameOver ) return; // intermission has already been triggered, so ignore. - MESSAGE_BEGIN(MSG_ALL, SVC_INTERMISSION); + MESSAGE_BEGIN( MSG_ALL, gmsg.Intermission ); MESSAGE_END(); // bounds check @@ -1306,7 +1299,7 @@ void CHalfLifeMultiplay :: SendMOTDToClient( edict_t *client ) char *aFileList = pFileList = (char*)LOAD_FILE ((char *)CVAR_GET_STRING( "motdfile" ), &length ); // send the server name - MESSAGE_BEGIN( MSG_ONE, gmsgServerName, NULL, client ); + MESSAGE_BEGIN( MSG_ONE, gmsg.ServerName, NULL, client ); WRITE_STRING( CVAR_GET_STRING("hostname") ); MESSAGE_END(); @@ -1333,7 +1326,7 @@ void CHalfLifeMultiplay :: SendMOTDToClient( edict_t *client ) else *pFileList = 0; - MESSAGE_BEGIN( MSG_ONE, gmsgMOTD, NULL, client ); + MESSAGE_BEGIN( MSG_ONE, gmsg.MOTD, NULL, client ); WRITE_BYTE( *pFileList ? FALSE : TRUE ); // FALSE means there is still more message to come WRITE_STRING( chunk ); MESSAGE_END(); diff --git a/server/game/singleplay_gamerules.cpp b/server/game/singleplay_gamerules.cpp index 3214ff72..2828d035 100644 --- a/server/game/singleplay_gamerules.cpp +++ b/server/game/singleplay_gamerules.cpp @@ -24,9 +24,6 @@ extern DLL_GLOBAL CGameRules *g_pGameRules; extern DLL_GLOBAL BOOL g_fGameOver; -extern int gmsgDeathMsg; // client dll messages -extern int gmsgScoreInfo; -extern int gmsgMOTD; //========================================================= //========================================================= diff --git a/server/game/sound.cpp b/server/game/sound.cpp index 2f18b5df..9e0e5af6 100644 --- a/server/game/sound.cpp +++ b/server/game/sound.cpp @@ -1907,7 +1907,7 @@ void CFMODAudio::Spawn( void ) void CFMODAudio::StartMessage( CBasePlayer *pPlayer ) { - MESSAGE_BEGIN( MSG_ONE, gmsgFsound, NULL, pPlayer->pev ); + MESSAGE_BEGIN( MSG_ONE, gmsg.Fsound, NULL, pPlayer->pev ); WRITE_STRING( STRING(pev->message)); WRITE_SHORT( pev->button );//position WRITE_SHORT( pev->impulse );//flags diff --git a/server/game/teamplay_gamerules.cpp b/server/game/teamplay_gamerules.cpp index 72b7fe91..81297a22 100644 --- a/server/game/teamplay_gamerules.cpp +++ b/server/game/teamplay_gamerules.cpp @@ -18,6 +18,7 @@ #include "extdll.h" #include "utils.h" #include "cbase.h" +#include "client.h" #include "player.h" #include "baseweapon.h" #include "gamerules.h" @@ -153,15 +154,9 @@ BOOL CHalfLifeTeamplay :: ClientCommand( CBasePlayer *pPlayer, const char *pcmd return FALSE; } -extern int gmsgGameMode; -extern int gmsgSayText; -extern int gmsgTeamInfo; -extern int gmsgTeamNames; -extern int gmsgScoreInfo; - void CHalfLifeTeamplay :: UpdateGameMode( CBasePlayer *pPlayer ) { - MESSAGE_BEGIN( MSG_ONE, gmsgGameMode, NULL, pPlayer->edict() ); + MESSAGE_BEGIN( MSG_ONE, gmsg.GameMode, NULL, pPlayer->edict() ); WRITE_BYTE( 1 ); // game mode teamplay MESSAGE_END(); } @@ -206,7 +201,7 @@ void CHalfLifeTeamplay::InitHUD( CBasePlayer *pPlayer ) CHalfLifeMultiplay::InitHUD( pPlayer ); // Send down the team names - MESSAGE_BEGIN( MSG_ONE, gmsgTeamNames, NULL, pPlayer->edict() ); + MESSAGE_BEGIN( MSG_ONE, gmsg.TeamNames, NULL, pPlayer->edict() ); WRITE_BYTE( num_teams ); for ( i = 0; i < num_teams; i++ ) { @@ -239,7 +234,7 @@ void CHalfLifeTeamplay::InitHUD( CBasePlayer *pPlayer ) CBaseEntity *plr = UTIL_PlayerByIndex( i ); if ( plr && IsValidTeam( plr->TeamID() ) ) { - MESSAGE_BEGIN( MSG_ONE, gmsgTeamInfo, NULL, pPlayer->edict() ); + MESSAGE_BEGIN( MSG_ONE, gmsg.TeamInfo, NULL, pPlayer->edict() ); WRITE_BYTE( plr->entindex() ); WRITE_STRING( plr->TeamID() ); MESSAGE_END(); @@ -282,12 +277,12 @@ void CHalfLifeTeamplay::ChangePlayerTeam( CBasePlayer *pPlayer, const char *pTea g_engfuncs.pfnSetClientKeyValue( clientIndex, g_engfuncs.pfnGetInfoKeyBuffer( pPlayer->edict() ), "team", pPlayer->m_szTeamName ); // notify everyone's HUD of the team change - MESSAGE_BEGIN( MSG_ALL, gmsgTeamInfo ); + MESSAGE_BEGIN( MSG_ALL, gmsg.TeamInfo ); WRITE_BYTE( clientIndex ); WRITE_STRING( pPlayer->m_szTeamName ); MESSAGE_END(); - MESSAGE_BEGIN( MSG_ALL, gmsgScoreInfo ); + MESSAGE_BEGIN( MSG_ALL, gmsg.ScoreInfo ); WRITE_BYTE( clientIndex ); WRITE_SHORT( pPlayer->pev->frags ); WRITE_SHORT( pPlayer->m_iDeaths ); @@ -342,8 +337,6 @@ void CHalfLifeTeamplay::ClientUserInfoChanged( CBasePlayer *pPlayer, char *infob RecountTeams( TRUE ); } -extern int gmsgDeathMsg; - //========================================================= // Deathnotice. //========================================================= @@ -360,7 +353,7 @@ void CHalfLifeTeamplay::DeathNotice( CBasePlayer *pVictim, entvars_t *pKiller, e { if ( (pk != pVictim) && (PlayerRelationship( pVictim, pk ) == GR_TEAMMATE) ) { - MESSAGE_BEGIN( MSG_ALL, gmsgDeathMsg ); + MESSAGE_BEGIN( MSG_ALL, gmsg.DeathMsg ); WRITE_BYTE( ENTINDEX(ENT(pKiller)) ); // the killer WRITE_BYTE( ENTINDEX(pVictim->edict()) ); // the victim WRITE_STRING( "teammate" ); // flag this as a teammate kill @@ -603,7 +596,7 @@ void CHalfLifeTeamplay::RecountTeams( bool bResendInfo ) { if ( plr && IsValidTeam( plr->TeamID() ) ) { - MESSAGE_BEGIN( MSG_ALL, gmsgTeamInfo, NULL ); + MESSAGE_BEGIN( MSG_ALL, gmsg.TeamInfo, NULL ); WRITE_BYTE( plr->entindex() ); WRITE_STRING( plr->TeamID() ); MESSAGE_END(); diff --git a/server/global/client.cpp b/server/global/client.cpp index 57d67e13..ad4c73c7 100644 --- a/server/global/client.cpp +++ b/server/global/client.cpp @@ -51,11 +51,9 @@ DLL_GLOBAL int g_serveractive = 0; BOOL MSGSended; BOOL NewLevel = FALSE; float MsgDelay; +user_messages_t gmsg; void LinkUserMessages( void ); char text[128]; -extern int gmsgSayText; -extern int gmsgHUDColor; -extern int gmsgCamData; // for trigger_viewset extern int g_teamplay; //messages affect only player @@ -66,60 +64,6 @@ typedef struct _SelAmmo BYTE Ammo2Type; BYTE Ammo2; } SelAmmo; -int gmsgShake = 0; -int gmsgFade = 0; -int gmsgSelAmmo = 0; -int gmsgFlashlight = 0; -int gmsgFlashBattery = 0; -int gmsgResetHUD = 0; -int gmsgInitHUD = 0; -int gmsgHUDColor = 0; -int gmsgCurWeapon = 0; -int gmsgHealth = 0; -int gmsgDamage = 0; -int gmsgBattery = 0; -int gmsgTrain = 0; -int gmsgWeaponList = 0; -int gmsgAmmoX = 0; -int gmsgDeathMsg = 0; -int gmsgScoreInfo = 0; -int gmsgTeamInfo = 0; -int gmsgTeamScore = 0; -int gmsgGameMode = 0; -int gmsgMOTD = 0; -int gmsgServerName = 0; -int gmsgAmmoPickup = 0; -int gmsgWeapPickup = 0; -int gmsgItemPickup = 0; -int gmsgHideWeapon = 0; -int gmsgSetCurWeap = 0; -int gmsgSayText = 0; -int gmsgTextMsg = 0; -int gmsgSetFOV = 0; -int gmsgShowMenu = 0; -int gmsgGeigerRange = 0; -int gmsgTeamNames = 0; -int gmsgStatusText = 0; -int gmsgStatusValue = 0; -int gmsgSetBody = 0; -int gmsgSetSkin = 0; -int gmsgZoomHUD = 0; -int gmsgWarHUD = 0; - -//entity messages -int gmsgHudText = 0; -int gmsgStatusIcon = 0; -int gmsgSetFog = 0; -int gmsgSetSky = 0; -int gmsgParticle = 0; -int gmsgBeams = 0; -int gmsgFsound = 0; -int gmsgShowGameTitle = 0; -int gmsgCamData; -int gmsgRainData = 0; -int gmsgAddMirror = 0; -int gmsgAddScreen = 0; -int gmsgAddPortal = 0; /* * used by kill command and disconnect command @@ -226,7 +170,7 @@ void ClientDisconnect( edict_t *pEntity ) char text[256]; sprintf( text, "- %s has left the game\n", STRING(pEntity->v.netname) ); - MESSAGE_BEGIN( MSG_ALL, gmsgSayText, NULL ); + MESSAGE_BEGIN( MSG_ALL, gmsg.SayText, NULL ); WRITE_BYTE( ENTINDEX(pEntity) ); WRITE_STRING( text ); MESSAGE_END(); @@ -432,7 +376,7 @@ void Host_Say( edict_t *pEntity, int teamonly ) if ( teamonly && g_pGameRules->PlayerRelationship(client, CBaseEntity::Instance(pEntity)) != GR_TEAMMATE ) continue; - MESSAGE_BEGIN( MSG_ONE, gmsgSayText, NULL, client->pev ); + MESSAGE_BEGIN( MSG_ONE, gmsg.SayText, NULL, client->pev ); WRITE_BYTE( ENTINDEX(pEntity) ); WRITE_STRING( text ); MESSAGE_END(); @@ -440,7 +384,7 @@ void Host_Say( edict_t *pEntity, int teamonly ) } // print to the sending client - MESSAGE_BEGIN( MSG_ONE, gmsgSayText, NULL, &pEntity->v ); + MESSAGE_BEGIN( MSG_ONE, gmsg.SayText, NULL, &pEntity->v ); WRITE_BYTE( ENTINDEX(pEntity) ); WRITE_STRING( text ); MESSAGE_END(); @@ -471,7 +415,7 @@ void ClientCommand( edict_t *pEntity ) const char *pstr; // Is the client spawned yet? - if( !pEntity->pvServerData ) + if( !pEntity->pvPrivateData ) return; entvars_t *pev = &pEntity->v; @@ -496,7 +440,7 @@ void ClientCommand( edict_t *pEntity ) int col = (atoi(CMD_ARGV(1)) & 255) << 16; col += (atoi(CMD_ARGV(2)) & 255) << 8; col += (atoi(CMD_ARGV(3)) & 255); - MESSAGE_BEGIN( MSG_ONE, gmsgHUDColor, NULL, &pEntity->v ); + MESSAGE_BEGIN( MSG_ONE, gmsg.HUDColor, NULL, &pEntity->v ); WRITE_LONG(col); MESSAGE_END(); } @@ -577,18 +521,18 @@ void ClientCommand( edict_t *pEntity ) if(IsMultiplayer()) g_pGameRules->EndMultiplayerGame(); //loading next map // FIXME: return to main menu here } - else if ( FStrEq(pcmd, "gametitle" ) ) + else if( FStrEq( pcmd, "gametitle" )) { - MESSAGE_BEGIN( MSG_ONE, gmsgShowGameTitle, NULL, ENT(pev) ); + MESSAGE_BEGIN( MSG_ONE, gmsg.ShowGameTitle, NULL, ENT( pev )); WRITE_BYTE( 0 ); MESSAGE_END(); } - else if ( FStrEq(pcmd, "intermission" ) ) + else if( FStrEq( pcmd, "intermission" )) { - MESSAGE_BEGIN(MSG_ONE, SVC_INTERMISSION, NULL, ENT(pev)); + MESSAGE_BEGIN( MSG_ONE, gmsg.Intermission, NULL, ENT( pev )); MESSAGE_END(); } - else if ( FStrEq(pcmd, "fullupdate" ) ) + else if( FStrEq( pcmd, "fullupdate" )) { GetClassPtr((CBasePlayer *)pev)->ForceClientDllUpdate(); } @@ -608,13 +552,13 @@ void ClientCommand( edict_t *pEntity ) } else if ( FStrEq(pcmd, "fov" ) ) { - if ( g_flWeaponCheat && CMD_ARGC() > 1) + if( g_flWeaponCheat && CMD_ARGC() > 1) { GetClassPtr((CBasePlayer *)pev)->m_iFOV = atoi( CMD_ARGV(1) ); } else { - CLIENT_PRINTF( pEntity, HUD_PRINTCONSOLE, UTIL_VarArgs( "\"fov\" is \"%d\"\n", (int)GetClassPtr((CBasePlayer *)pev)->m_iFOV ) ); + ClientPrint( &pEntity->v, HUD_PRINTCONSOLE, UTIL_VarArgs( "\"fov\" is \"%d\"\n", (int)GetClassPtr((CBasePlayer *)pev)->m_iFOV ) ); } } else if ( FStrEq(pcmd, "use" ) ) @@ -668,7 +612,7 @@ it gets sent into the rest of the engine. void ClientUserInfoChanged( edict_t *pEntity, char *infobuffer ) { // Is the client spawned yet? - if ( !pEntity->pvServerData ) + if ( !pEntity->pvPrivateData ) return; // msg everyone if someone changes their name, and it isn't the first time (changing no name to current name) @@ -692,7 +636,7 @@ void ClientUserInfoChanged( edict_t *pEntity, char *infobuffer ) char text[256]; sprintf( text, "* %s changed name to %s\n", STRING(pEntity->v.netname), g_engfuncs.pfnInfoKeyValue( infobuffer, "name" ) ); - MESSAGE_BEGIN( MSG_ALL, gmsgSayText, NULL ); + MESSAGE_BEGIN( MSG_ALL, gmsg.SayText, NULL ); WRITE_BYTE( ENTINDEX(pEntity) ); WRITE_STRING( text ); MESSAGE_END(); @@ -732,7 +676,7 @@ void ServerActivate( edict_t *pEdictList, int edictCount, int clientMax ) continue; // Clients aren't necessarily initialized until ClientPutInServer() - if ( i < clientMax || !pEdictList[i].pvServerData ) + if ( i < clientMax || !pEdictList[i].pvPrivateData ) continue; pClass = CBaseEntity::Instance( &pEdictList[i] ); @@ -1065,63 +1009,67 @@ const char *GetGameDescription() //======================================================================= void LinkUserMessages( void ) { - // Already taken care of? - if ( gmsgSelAmmo )return; + // already taken care of? + if( gmsg.SelAmmo ) return; + + memset( &gmsg, 0, sizeof( gmsg )); //messages affect only player - gmsgSelAmmo = REG_USER_MSG("SelAmmo", sizeof(SelAmmo)); - gmsgCurWeapon = REG_USER_MSG("CurWeapon", 3); - gmsgGeigerRange = REG_USER_MSG("Geiger", 1); - gmsgFlashlight = REG_USER_MSG("Flashlight", 2); - gmsgFlashBattery = REG_USER_MSG("FlashBat", 1); - gmsgHealth = REG_USER_MSG( "Health", 1 ); - gmsgDamage = REG_USER_MSG( "Damage", 12 ); - gmsgBattery = REG_USER_MSG( "Battery", 2); - gmsgTrain = REG_USER_MSG( "Train", 1); - gmsgSayText = REG_USER_MSG( "SayText", -1 ); - gmsgTextMsg = REG_USER_MSG( "TextMsg", -1 ); - gmsgWeaponList = REG_USER_MSG("WeaponList", -1); - gmsgResetHUD = REG_USER_MSG("ResetHUD", 1); - gmsgInitHUD = REG_USER_MSG("InitHUD", 0 ); - gmsgHUDColor = REG_USER_MSG( "HUDColor", 4 ); - gmsgDeathMsg = REG_USER_MSG( "DeathMsg", -1 ); - gmsgScoreInfo = REG_USER_MSG( "ScoreInfo", 9 ); - gmsgTeamInfo = REG_USER_MSG( "TeamInfo", -1 ); - gmsgTeamScore = REG_USER_MSG( "TeamScore", -1 ); - gmsgGameMode = REG_USER_MSG( "GameMode", 1 ); - gmsgMOTD = REG_USER_MSG( "MOTD", -1 ); - gmsgServerName = REG_USER_MSG( "ServerName", -1 ); - gmsgAmmoPickup = REG_USER_MSG( "AmmoPickup", 2 ); - gmsgWeapPickup = REG_USER_MSG( "WeapPickup", 1 ); - gmsgItemPickup = REG_USER_MSG( "ItemPickup", -1 ); - gmsgHideWeapon = REG_USER_MSG( "HideWeapon", 1 ); - gmsgSetFOV = REG_USER_MSG( "SetFOV", 1 ); - gmsgShowMenu = REG_USER_MSG( "ShowMenu", -1 ); - gmsgShake = REG_USER_MSG("ScreenShake", 13 ); - gmsgFade = REG_USER_MSG("ScreenFade", sizeof(ScreenFade)); - gmsgAmmoX = REG_USER_MSG("AmmoX", 2); - gmsgTeamNames = REG_USER_MSG( "TeamNames", -1 ); - gmsgStatusText = REG_USER_MSG("StatusText", -1); - gmsgStatusValue = REG_USER_MSG("StatusValue", 3); - gmsgSetBody = REG_USER_MSG("SetBody", 1); - gmsgSetSkin = REG_USER_MSG("SetSkin", 1); - gmsgZoomHUD = REG_USER_MSG("ZoomHUD", 1); - gmsgWarHUD = REG_USER_MSG("WarHUD", 1); + gmsg.SelAmmo = REG_USER_MSG("SelAmmo", sizeof(SelAmmo)); + gmsg.Intermission = REG_USER_MSG( "Intermission", 0 ); + gmsg.CurWeapon = REG_USER_MSG("CurWeapon", 3); + gmsg.GeigerRange = REG_USER_MSG("Geiger", 1); + gmsg.Flashlight = REG_USER_MSG("Flashlight", 2); + gmsg.FlashBattery = REG_USER_MSG("FlashBat", 1); + gmsg.Health = REG_USER_MSG( "Health", 1 ); + gmsg.Damage = REG_USER_MSG( "Damage", 18 ); + gmsg.Battery = REG_USER_MSG( "Battery", 2); + gmsg.Train = REG_USER_MSG( "Train", 1); + gmsg.SayText = REG_USER_MSG( "SayText", -1 ); + gmsg.TextMsg = REG_USER_MSG( "TextMsg", -1 ); + gmsg.WeaponList = REG_USER_MSG("WeaponList", -1); + gmsg.ResetHUD = REG_USER_MSG("ResetHUD", 1); + gmsg.InitHUD = REG_USER_MSG("InitHUD", 0 ); + gmsg.HUDColor = REG_USER_MSG( "HUDColor", 4 ); + gmsg.DeathMsg = REG_USER_MSG( "DeathMsg", -1 ); + gmsg.ScoreInfo = REG_USER_MSG( "ScoreInfo", 9 ); + gmsg.TeamInfo = REG_USER_MSG( "TeamInfo", -1 ); + gmsg.TeamScore = REG_USER_MSG( "TeamScore", -1 ); + gmsg.GameMode = REG_USER_MSG( "GameMode", 1 ); + gmsg.MOTD = REG_USER_MSG( "MOTD", -1 ); + gmsg.ServerName = REG_USER_MSG( "ServerName", -1 ); + gmsg.AmmoPickup = REG_USER_MSG( "AmmoPickup", 2 ); + gmsg.WeapPickup = REG_USER_MSG( "WeapPickup", 1 ); + gmsg.ItemPickup = REG_USER_MSG( "ItemPickup", -1 ); + gmsg.RoomType = REG_USER_MSG( "RoomType", 2 ); + gmsg.HideWeapon = REG_USER_MSG( "HideWeapon", 1 ); + gmsg.SetFOV = REG_USER_MSG( "SetFOV", 1 ); + gmsg.ShowMenu = REG_USER_MSG( "ShowMenu", -1 ); + gmsg.Shake = REG_USER_MSG("ScreenShake", 13 ); + gmsg.Fade = REG_USER_MSG("ScreenFade", sizeof(ScreenFade)); + gmsg.AmmoX = REG_USER_MSG("AmmoX", 2); + gmsg.TeamNames = REG_USER_MSG( "TeamNames", -1 ); + gmsg.StatusText = REG_USER_MSG("StatusText", -1); + gmsg.StatusValue = REG_USER_MSG("StatusValue", 3); + gmsg.SetBody = REG_USER_MSG("SetBody", 1); + gmsg.SetSkin = REG_USER_MSG("SetSkin", 1); + gmsg.ZoomHUD = REG_USER_MSG("ZoomHUD", 1); + gmsg.WarHUD = REG_USER_MSG("WarHUD", 1); //entity messages - gmsgStatusIcon = REG_USER_MSG("StatusIcon", -1); - gmsgCamData = REG_USER_MSG("CamData", -1); - gmsgFsound = REG_USER_MSG("Fsound", -1); - gmsgRainData = REG_USER_MSG("RainData", 16); - gmsgAddScreen = REG_USER_MSG( "AddScreen", 1); - gmsgAddPortal = REG_USER_MSG( "AddPortal", 1); - gmsgHudText = REG_USER_MSG( "HudText", -1 ); - gmsgShowGameTitle = REG_USER_MSG("GameTitle", 1); - gmsgSetFog = REG_USER_MSG("SetFog", 7 ); - gmsgSetSky = REG_USER_MSG( "SetSky", 7 ); - gmsgParticle = REG_USER_MSG( "Particle", -1); - gmsgBeams = REG_USER_MSG( "Beams", -1 ); - gmsgAddMirror = REG_USER_MSG( "AddMirror", 2); + gmsg.StatusIcon = REG_USER_MSG("StatusIcon", -1); + gmsg.CamData = REG_USER_MSG("CamData", -1); + gmsg.Fsound = REG_USER_MSG("Fsound", -1); + gmsg.RainData = REG_USER_MSG("RainData", 16); + gmsg.AddScreen = REG_USER_MSG( "AddScreen", 1); + gmsg.AddPortal = REG_USER_MSG( "AddPortal", 1); + gmsg.HudText = REG_USER_MSG( "HudText", -1 ); + gmsg.ShowGameTitle = REG_USER_MSG("GameTitle", 1); + gmsg.SetFog = REG_USER_MSG("SetFog", 7 ); + gmsg.SetSky = REG_USER_MSG( "SetSky", 7 ); + gmsg.Particle = REG_USER_MSG( "Particle", -1); + gmsg.Beams = REG_USER_MSG( "Beams", -1 ); + gmsg.AddMirror = REG_USER_MSG( "AddMirror", 2); } /* diff --git a/server/global/client.h b/server/global/client.h index d6999f4b..9ea8da89 100644 --- a/server/global/client.h +++ b/server/global/client.h @@ -59,62 +59,68 @@ extern int InconsistentFile( const edict_t *player, const char *filename, char extern int AllowLagCompensation( void ); extern int g_serveractive; -//messages affect only player -extern int gmsgShake; -extern int gmsgFade; -extern int gmsgSelAmmo; -extern int gmsgFlashlight; -extern int gmsgFlashBattery; -extern int gmsgResetHUD; -extern int gmsgInitHUD; -extern int gmsgHUDColor; -extern int gmsgCurWeapon; -extern int gmsgHealth; -extern int gmsgDamage; -extern int gmsgBattery; -extern int gmsgTrain; -extern int gmsgWeaponList; -extern int gmsgAmmoX; -extern int gmsgDeathMsg; -extern int gmsgScoreInfo; -extern int gmsgTeamInfo; -extern int gmsgTeamScore; -extern int gmsgGameMode; -extern int gmsgMOTD; -extern int gmsgServerName; -extern int gmsgAmmoPickup; -extern int gmsgWeapPickup; -extern int gmsgItemPickup; -extern int gmsgHideWeapon; -extern int gmsgSetCurWeap; -extern int gmsgSayText; -extern int gmsgSetFOV; -extern int gmsgShowMenu; -extern int gmsgGeigerRange; -extern int gmsgTeamNames; -extern int gmsgTextMsg; -extern int gmsgStatusText; -extern int gmsgStatusValue; -extern int gmsgSetBody; -extern int gmsgSetSkin; -extern int gmsgZoomHUD; -extern int gmsgWarHUD; +// messages affect only player +typedef struct user_messages_s +{ + int Shake; + int Fade; + int SelAmmo; + int Intermission; + int Flashlight; + int FlashBattery; + int ResetHUD; + int InitHUD; + int HUDColor; + int CurWeapon; + int Health; + int Damage; + int Battery; + int Train; + int WeaponList; + int AmmoX; + int DeathMsg; + int ScoreInfo; + int TeamInfo; + int TeamScore; + int GameMode; + int MOTD; + int ServerName; + int AmmoPickup; + int WeapPickup; + int ItemPickup; + int HideWeapon; + int RoomType; + int SayText; + int SetFOV; + int ShowMenu; + int GeigerRange; + int TeamNames; + int TextMsg; + int StatusText; + int StatusValue; + int SetBody; + int SetSkin; + int ZoomHUD; + int WarHUD; -//entity messages -extern int gmsgSetFog; -extern int gmsgStatusIcon; -extern int gmsgSetSky; -extern int gmsgParticle; -extern int gmsgFsound; -extern int gmsgCamData; -extern int gmsgRainData; -extern int gmsgHudText; -extern int gmsgShowGameTitle; -extern int gmsgAddScreen; -extern int gmsgAddMirror; -extern int gmsgAddPortal; -extern int gmsgBeams; + // entity messages + int TempEntity; // completely moved from engine to user dlls + int SetFog; + int StatusIcon; + int SetSky; + int Particle; + int Fsound; + int CamData; + int RainData; + int HudText; + int ShowGameTitle; + int AddScreen; + int AddMirror; + int AddPortal; + int Beams; +} user_messages_t; +extern user_messages_t gmsg; extern BOOL MSGSended; #endif // CLIENT_H \ No newline at end of file diff --git a/server/global/enginecallback.h b/server/global/enginecallback.h index e7b52368..1500f019 100644 --- a/server/global/enginecallback.h +++ b/server/global/enginecallback.h @@ -93,7 +93,7 @@ inline void MESSAGE_BEGIN( int msg_dest, int msg_type, const float *pOrigin = NU inline void *GET_PRIVATE( edict_t *pent ) { if ( pent ) - return pent->pvServerData; + return pent->pvPrivateData; return NULL; } @@ -116,7 +116,6 @@ inline void *GET_PRIVATE( edict_t *pent ) #define FUNCTION_FROM_NAME (*g_engfuncs.pfnFunctionFromName) #define NAME_FOR_FUNCTION (*g_engfuncs.pfnNameForFunction) #define TRACE_TEXTURE (*g_engfuncs.pfnTraceTexture) -#define CLIENT_PRINTF (*g_engfuncs.pfnClientPrintf) #define CMD_ARGS (*g_engfuncs.pfnCmd_Args) #define CMD_ARGC (*g_engfuncs.pfnCmd_Argc) #define CMD_ARGV (*g_engfuncs.pfnCmd_Argv) diff --git a/server/global/sfx.cpp b/server/global/sfx.cpp index 987f6e00..051948ee 100644 --- a/server/global/sfx.cpp +++ b/server/global/sfx.cpp @@ -5,10 +5,11 @@ //======================================================================= #include "sfx.h" +#include "client.h" void SFX_Explode( short model, Vector origin, float scale, int flags ) { - MESSAGE_BEGIN( MSG_PAS, SVC_TEMPENTITY, origin ); + MESSAGE_BEGIN( MSG_PAS, gmsg.TempEntity, origin ); WRITE_BYTE( TE_EXPLOSION ); // This makes a dynamic light and the explosion sprites/sound WRITE_COORD( origin.x ); // Send to PAS because of the sound WRITE_COORD( origin.y ); @@ -22,7 +23,7 @@ void SFX_Explode( short model, Vector origin, float scale, int flags ) void SFX_Trail( int entindex, short model, Vector color, float life ) { - MESSAGE_BEGIN( MSG_BROADCAST, SVC_TEMPENTITY ); + MESSAGE_BEGIN( MSG_BROADCAST, gmsg.TempEntity ); WRITE_BYTE( TE_BEAMFOLLOW ); WRITE_SHORT( entindex ); // entity WRITE_SHORT( model ); // model @@ -38,7 +39,7 @@ void SFX_Trail( int entindex, short model, Vector color, float life ) void SFX_MakeGibs( int shards, Vector pos, Vector size, Vector velocity, float time, int flags) { - MESSAGE_BEGIN( MSG_PVS, SVC_TEMPENTITY, pos ); + MESSAGE_BEGIN( MSG_PVS, gmsg.TempEntity, pos ); WRITE_BYTE( TE_BREAKMODEL); WRITE_COORD( pos.x ); // position WRITE_COORD( pos.y ); @@ -59,7 +60,7 @@ void SFX_MakeGibs( int shards, Vector pos, Vector size, Vector velocity, float t void SFX_EjectBrass ( const Vector &vecOrigin, const Vector &vecVelocity, float rotation, int model, int soundtype ) { - MESSAGE_BEGIN( MSG_PVS, SVC_TEMPENTITY, vecOrigin ); + MESSAGE_BEGIN( MSG_PVS, gmsg.TempEntity, vecOrigin ); WRITE_BYTE( TE_MODEL); WRITE_COORD( vecOrigin.x); WRITE_COORD( vecOrigin.y); @@ -76,7 +77,7 @@ void SFX_EjectBrass ( const Vector &vecOrigin, const Vector &vecVelocity, float void SFX_Decal( const Vector &vecOrigin, int decalIndex, int entityIndex, int modelIndex ) { - MESSAGE_BEGIN( MSG_BROADCAST, SVC_TEMPENTITY); + MESSAGE_BEGIN( MSG_BROADCAST, gmsg.TempEntity); WRITE_BYTE( TE_BSPDECAL ); WRITE_COORD( vecOrigin.x ); WRITE_COORD( vecOrigin.y ); @@ -89,7 +90,7 @@ void SFX_Decal( const Vector &vecOrigin, int decalIndex, int entityIndex, int mo void SFX_Light ( entvars_t *pev, float iTime, float decay, int attachment ) { - MESSAGE_BEGIN( MSG_PVS, SVC_TEMPENTITY, pev->origin ); + MESSAGE_BEGIN( MSG_PVS, gmsg.TempEntity, pev->origin ); WRITE_BYTE( TE_ELIGHT ); WRITE_SHORT( ENTINDEX( ENT(pev) ) + 0x1000 * attachment );// entity, attachment WRITE_COORD( pev->origin.x ); // X @@ -106,7 +107,7 @@ void SFX_Light ( entvars_t *pev, float iTime, float decay, int attachment ) void SFX_Zap ( entvars_t *pev, const Vector &vecSrc, const Vector &vecDest ) { - MESSAGE_BEGIN( MSG_BROADCAST, SVC_TEMPENTITY ); + MESSAGE_BEGIN( MSG_BROADCAST, gmsg.TempEntity ); WRITE_BYTE( TE_BEAMPOINTS); WRITE_COORD(vecSrc.x); WRITE_COORD(vecSrc.y); @@ -130,7 +131,7 @@ void SFX_Zap ( entvars_t *pev, const Vector &vecSrc, const Vector &vecDest ) void SFX_Ring ( entvars_t *pev, entvars_t *pev2 ) { - MESSAGE_BEGIN( MSG_BROADCAST, SVC_TEMPENTITY ); + MESSAGE_BEGIN( MSG_BROADCAST, gmsg.TempEntity ); WRITE_BYTE( TE_BEAMRING ); WRITE_SHORT( ENTINDEX(ENT(pev)) ); WRITE_SHORT( ENTINDEX(ENT(pev2)) ); diff --git a/server/global/shake.h b/server/global/shake.h index 6ebdf337..855cc4d3 100644 --- a/server/global/shake.h +++ b/server/global/shake.h @@ -17,17 +17,12 @@ // Screen / View effects -// screen shake -extern int gmsgShake; - // // Commands for the screen shake effect. // // Fade in/out -extern int gmsgFade; - // This structure is sent over the net to describe a screen fade event typedef struct { diff --git a/server/global/utils.cpp b/server/global/utils.cpp index 2dbab2c2..64ba0336 100644 --- a/server/global/utils.cpp +++ b/server/global/utils.cpp @@ -1180,7 +1180,7 @@ int UTIL_PrecacheAurora( const char *s ) void UTIL_SetAurora( CBaseEntity *pAttach, int aur, int attachment ) { - MESSAGE_BEGIN( MSG_ALL, gmsgParticle ); + MESSAGE_BEGIN( MSG_ALL, gmsg.Particle ); WRITE_BYTE( pAttach->entindex() ); WRITE_STRING( STRING(aur) ); MESSAGE_END(); @@ -1190,7 +1190,7 @@ void UTIL_SetAurora( CBaseEntity *pAttach, int aur, int attachment ) //======================================================================== void UTIL_SetBeams( char *szFile, CBaseEntity *pStart, CBaseEntity *pEnd ) { - MESSAGE_BEGIN( MSG_ALL, gmsgBeams ); + MESSAGE_BEGIN( MSG_ALL, gmsg.Beams ); WRITE_STRING( szFile ); WRITE_BYTE( pStart->entindex());//beam start entity WRITE_BYTE( pEnd->entindex() );//beam end entity @@ -2028,7 +2028,7 @@ void UTIL_ScreenShake( const Vector ¢er, float amplitude, float frequency, f { if ( eCommand == SHAKE_STOP ) localAmplitude = 0; - MESSAGE_BEGIN( MSG_ONE, gmsgShake, NULL, pPlayer->edict() ); + MESSAGE_BEGIN( MSG_ONE, gmsg.Shake, NULL, pPlayer->edict() ); WRITE_BYTE( eCommand ); // shake command (SHAKE_START, STOP, FREQUENCY, AMPLITUDE) WRITE_FLOAT( localAmplitude );// shake magnitude/amplitude WRITE_FLOAT( frequency ); // shake noise frequency @@ -2087,7 +2087,7 @@ void UTIL_HudMessage( CBaseEntity *pEntity, const hudtextparms_t &textparms, con if ( !pEntity || !pEntity->IsNetClient() ) return; - MESSAGE_BEGIN( MSG_ONE, SVC_TEMPENTITY, NULL, pEntity->edict() ); + MESSAGE_BEGIN( MSG_ONE, gmsg.TempEntity, NULL, pEntity->edict() ); WRITE_BYTE( TE_TEXTMESSAGE ); WRITE_BYTE( textparms.channel & 0xFF ); @@ -2137,12 +2137,10 @@ void UTIL_HudMessageAll( const hudtextparms_t &textparms, const char *pMessage ) UTIL_HudMessage( pPlayer, textparms, pMessage ); } } - -extern int gmsgTextMsg, gmsgSayText; void UTIL_ClientPrintAll( int msg_dest, const char *msg_name, const char *param1, const char *param2, const char *param3, const char *param4 ) { - MESSAGE_BEGIN( MSG_ALL, gmsgTextMsg ); + MESSAGE_BEGIN( MSG_ALL, gmsg.TextMsg ); WRITE_BYTE( msg_dest ); WRITE_STRING( msg_name ); @@ -2160,7 +2158,7 @@ void UTIL_ClientPrintAll( int msg_dest, const char *msg_name, const char *param1 void ClientPrint( entvars_t *client, int msg_dest, const char *msg_name, const char *param1, const char *param2, const char *param3, const char *param4 ) { - MESSAGE_BEGIN( MSG_ONE, gmsgTextMsg, NULL, client ); + MESSAGE_BEGIN( MSG_ONE, gmsg.TextMsg, NULL, client ); WRITE_BYTE( msg_dest ); WRITE_STRING( msg_name ); @@ -2181,7 +2179,7 @@ void UTIL_SayText( const char *pText, CBaseEntity *pEntity ) if ( !pEntity->IsNetClient() ) return; - MESSAGE_BEGIN( MSG_ONE, gmsgSayText, NULL, pEntity->edict() ); + MESSAGE_BEGIN( MSG_ONE, gmsg.SayText, NULL, pEntity->edict() ); WRITE_BYTE( pEntity->entindex() ); WRITE_STRING( pText ); MESSAGE_END(); @@ -2189,7 +2187,7 @@ void UTIL_SayText( const char *pText, CBaseEntity *pEntity ) void UTIL_SayTextAll( const char *pText, CBaseEntity *pEntity ) { - MESSAGE_BEGIN( MSG_ALL, gmsgSayText, NULL ); + MESSAGE_BEGIN( MSG_ALL, gmsg.SayText, NULL ); WRITE_BYTE( pEntity->entindex() ); WRITE_STRING( pText ); MESSAGE_END(); @@ -2229,7 +2227,7 @@ void UTIL_ShowMessage( const char *pString, CBaseEntity *pEntity ) if ( !pEntity || !pEntity->IsNetClient() ) return; - MESSAGE_BEGIN( MSG_ONE, gmsgHudText, NULL, pEntity->edict() ); + MESSAGE_BEGIN( MSG_ONE, gmsg.HudText, NULL, pEntity->edict() ); WRITE_STRING( pString ); MESSAGE_END(); } @@ -2479,7 +2477,7 @@ void UTIL_BloodStream( const Vector &origin, const Vector &direction, int color, return; - MESSAGE_BEGIN( MSG_PVS, SVC_TEMPENTITY, origin ); + MESSAGE_BEGIN( MSG_PVS, gmsg.TempEntity, origin ); WRITE_BYTE( TE_BLOODSTREAM ); WRITE_COORD( origin.x ); WRITE_COORD( origin.y ); @@ -2512,7 +2510,7 @@ void UTIL_BloodDrips( const Vector &origin, const Vector &direction, int color, if ( amount > 255 ) amount = 255; - MESSAGE_BEGIN( MSG_PVS, SVC_TEMPENTITY, origin ); + MESSAGE_BEGIN( MSG_PVS, gmsg.TempEntity, origin ); WRITE_BYTE( TE_BLOODSPRITE ); WRITE_COORD( origin.x); // pos WRITE_COORD( origin.y); @@ -2595,7 +2593,7 @@ void UTIL_DecalTrace( TraceResult *pTrace, int decalNumber ) } } - MESSAGE_BEGIN( MSG_BROADCAST, SVC_TEMPENTITY ); + MESSAGE_BEGIN( MSG_BROADCAST, gmsg.TempEntity ); WRITE_BYTE( message ); WRITE_COORD( pTrace->vecEndPos.x ); WRITE_COORD( pTrace->vecEndPos.y ); @@ -2634,7 +2632,7 @@ void UTIL_PlayerDecalTrace( TraceResult *pTrace, int playernum, int decalNumber, if (pTrace->flFraction == 1.0) return; - MESSAGE_BEGIN( MSG_BROADCAST, SVC_TEMPENTITY ); + MESSAGE_BEGIN( MSG_BROADCAST, gmsg.TempEntity ); WRITE_BYTE( TE_PLAYERDECAL ); WRITE_BYTE ( playernum ); WRITE_COORD( pTrace->vecEndPos.x ); @@ -2657,7 +2655,7 @@ void UTIL_GunshotDecalTrace( TraceResult *pTrace, int decalNumber ) if (pTrace->flFraction == 1.0) return; - MESSAGE_BEGIN( MSG_PAS, SVC_TEMPENTITY, pTrace->vecEndPos ); + MESSAGE_BEGIN( MSG_PAS, gmsg.TempEntity, pTrace->vecEndPos ); WRITE_BYTE( TE_GUNSHOTDECAL ); WRITE_COORD( pTrace->vecEndPos.x ); WRITE_COORD( pTrace->vecEndPos.y ); @@ -2670,7 +2668,7 @@ void UTIL_GunshotDecalTrace( TraceResult *pTrace, int decalNumber ) void UTIL_Sparks( const Vector &position ) { - MESSAGE_BEGIN( MSG_PVS, SVC_TEMPENTITY, position ); + MESSAGE_BEGIN( MSG_PVS, gmsg.TempEntity, position ); WRITE_BYTE( TE_SPARKS ); WRITE_COORD( position.x ); WRITE_COORD( position.y ); @@ -2693,7 +2691,7 @@ void UTIL_Explode( const Vector ¢er, edict_t *pOwner, int radius, int name ) void UTIL_Ricochet( const Vector &position, float scale ) { - MESSAGE_BEGIN( MSG_PVS, SVC_TEMPENTITY, position ); + MESSAGE_BEGIN( MSG_PVS, gmsg.TempEntity, position ); WRITE_BYTE( TE_ARMOR_RICOCHET ); WRITE_COORD( position.x ); WRITE_COORD( position.y ); @@ -2903,7 +2901,7 @@ void UTIL_Bubbles( Vector mins, Vector maxs, int count ) float flHeight = UTIL_WaterLevel( mid, mid.z, mid.z + 1024 ); flHeight = flHeight - mins.z; - MESSAGE_BEGIN( MSG_PAS, SVC_TEMPENTITY, mid ); + MESSAGE_BEGIN( MSG_PAS, gmsg.TempEntity, mid ); WRITE_BYTE( TE_BUBBLES ); WRITE_COORD( mins.x ); // mins WRITE_COORD( mins.y ); @@ -2937,7 +2935,7 @@ void UTIL_BubbleTrail( Vector from, Vector to, int count ) if (count > 255) count = 255; - MESSAGE_BEGIN( MSG_BROADCAST, SVC_TEMPENTITY ); + MESSAGE_BEGIN( MSG_BROADCAST, gmsg.TempEntity ); WRITE_BYTE( TE_BUBBLETRAIL ); WRITE_COORD( from.x ); // mins WRITE_COORD( from.y ); diff --git a/server/global/utils.h b/server/global/utils.h index 3ea7b23a..025050a7 100644 --- a/server/global/utils.h +++ b/server/global/utils.h @@ -490,12 +490,7 @@ extern DLL_GLOBAL int g_Language; #define VEC_DUCK_HULL_MAX Vector( 16, 16, 18) #define VEC_DUCK_VIEW Vector( 0, 0, 12 ) -#define SVC_TEMPENTITY 23 -#define SVC_INTERMISSION 30 -#define SVC_CDTRACK 32 -#define SVC_WEAPONANIM 35 -#define SVC_ROOMTYPE 37 -#define SVC_DIRECTOR 51 +#define SVC_WEAPONANIM 35 // FIMXE: get rid of this // camera flags #define CAMERA_ON 1 diff --git a/server/monsters/apache.cpp b/server/monsters/apache.cpp index 4f8b532d..d0161bdf 100644 --- a/server/monsters/apache.cpp +++ b/server/monsters/apache.cpp @@ -17,6 +17,7 @@ #include "extdll.h" #include "utils.h" #include "cbase.h" +#include "client.h" #include "monsters.h" #include "baseweapon.h" #include "nodes.h" @@ -233,7 +234,7 @@ void CApache :: DyingThink( void ) if (m_flNextRocket > gpGlobals->time ) { // random explosions - MESSAGE_BEGIN( MSG_PVS, SVC_TEMPENTITY, pev->origin ); + MESSAGE_BEGIN( MSG_PVS, gmsg.TempEntity, pev->origin ); WRITE_BYTE( TE_EXPLOSION); // This just makes a dynamic light now WRITE_COORD( pev->origin.x + RANDOM_FLOAT( -150, 150 )); WRITE_COORD( pev->origin.y + RANDOM_FLOAT( -150, 150 )); @@ -245,7 +246,7 @@ void CApache :: DyingThink( void ) MESSAGE_END(); // lots of smoke - MESSAGE_BEGIN( MSG_PVS, SVC_TEMPENTITY, pev->origin ); + MESSAGE_BEGIN( MSG_PVS, gmsg.TempEntity, pev->origin ); WRITE_BYTE( TE_SMOKE ); WRITE_COORD( pev->origin.x + RANDOM_FLOAT( -150, 150 )); WRITE_COORD( pev->origin.y + RANDOM_FLOAT( -150, 150 )); @@ -256,7 +257,7 @@ void CApache :: DyingThink( void ) MESSAGE_END(); Vector vecSpot = pev->origin + (pev->mins + pev->maxs) * 0.5; - MESSAGE_BEGIN( MSG_PVS, SVC_TEMPENTITY, vecSpot ); + MESSAGE_BEGIN( MSG_PVS, gmsg.TempEntity, vecSpot ); WRITE_BYTE( TE_BREAKMODEL); // position @@ -301,7 +302,7 @@ void CApache :: DyingThink( void ) Vector vecSpot = pev->origin + (pev->mins + pev->maxs) * 0.5; /* - MESSAGE_BEGIN( MSG_BROADCAST, SVC_TEMPENTITY ); + MESSAGE_BEGIN( MSG_BROADCAST, gmsg.TempEntity ); WRITE_BYTE( TE_EXPLOSION); // This just makes a dynamic light now WRITE_COORD( vecSpot.x ); WRITE_COORD( vecSpot.y ); @@ -313,7 +314,7 @@ void CApache :: DyingThink( void ) */ // fireball - MESSAGE_BEGIN( MSG_PVS, SVC_TEMPENTITY, vecSpot ); + MESSAGE_BEGIN( MSG_PVS, gmsg.TempEntity, vecSpot ); WRITE_BYTE( TE_SPRITE ); WRITE_COORD( vecSpot.x ); WRITE_COORD( vecSpot.y ); @@ -324,7 +325,7 @@ void CApache :: DyingThink( void ) MESSAGE_END(); // big smoke - MESSAGE_BEGIN( MSG_PVS, SVC_TEMPENTITY, vecSpot ); + MESSAGE_BEGIN( MSG_PVS, gmsg.TempEntity, vecSpot ); WRITE_BYTE( TE_SMOKE ); WRITE_COORD( vecSpot.x ); WRITE_COORD( vecSpot.y ); @@ -335,7 +336,7 @@ void CApache :: DyingThink( void ) MESSAGE_END(); // blast circle - MESSAGE_BEGIN( MSG_PVS, SVC_TEMPENTITY, pev->origin ); + MESSAGE_BEGIN( MSG_PVS, gmsg.TempEntity, pev->origin ); WRITE_BYTE( TE_BEAMCYLINDER ); WRITE_COORD( pev->origin.x); WRITE_COORD( pev->origin.y); @@ -375,7 +376,7 @@ void CApache :: DyingThink( void ) // gibs vecSpot = pev->origin + (pev->mins + pev->maxs) * 0.5; - MESSAGE_BEGIN( MSG_PVS, SVC_TEMPENTITY, vecSpot ); + MESSAGE_BEGIN( MSG_PVS, gmsg.TempEntity, vecSpot ); WRITE_BYTE( TE_BREAKMODEL); // position @@ -768,7 +769,7 @@ void CApache :: FireRocket( void ) case 4: break; } - MESSAGE_BEGIN( MSG_PVS, SVC_TEMPENTITY, vecSrc ); + MESSAGE_BEGIN( MSG_PVS, gmsg.TempEntity, vecSrc ); WRITE_BYTE( TE_SMOKE ); WRITE_COORD( vecSrc.x ); WRITE_COORD( vecSrc.y ); @@ -876,7 +877,7 @@ void CApache :: ShowDamage( void ) { if (m_iDoSmokePuff > 0 || RANDOM_LONG(0,99) > pev->health) { - MESSAGE_BEGIN( MSG_PVS, SVC_TEMPENTITY, pev->origin ); + MESSAGE_BEGIN( MSG_PVS, gmsg.TempEntity, pev->origin ); WRITE_BYTE( TE_SMOKE ); WRITE_COORD( pev->origin.x ); WRITE_COORD( pev->origin.y ); diff --git a/server/monsters/barney.cpp b/server/monsters/barney.cpp index 3dd91469..133f7d0a 100644 --- a/server/monsters/barney.cpp +++ b/server/monsters/barney.cpp @@ -20,6 +20,7 @@ #include "extdll.h" #include "utils.h" #include "cbase.h" +#include "client.h" #include "monsters.h" #include "talkmonster.h" #include "schedule.h" @@ -394,20 +395,19 @@ void CBarney :: BarneyFirePistol ( void ) m_cAmmoLoaded--;// take away a bullet! // Teh_Freak: World Lighting! - MESSAGE_BEGIN( MSG_BROADCAST, SVC_TEMPENTITY ); - WRITE_BYTE( TE_DLIGHT ); - WRITE_COORD( vecShootOrigin.x ); // origin - WRITE_COORD( vecShootOrigin.y ); - WRITE_COORD( vecShootOrigin.z ); - WRITE_BYTE( 16 ); // radius - WRITE_BYTE( 255 ); // R - WRITE_BYTE( 255 ); // G - WRITE_BYTE( 128 ); // B - WRITE_BYTE( 0 ); // life * 10 - WRITE_BYTE( 0 ); // decay - MESSAGE_END(); + MESSAGE_BEGIN( MSG_BROADCAST, gmsg.TempEntity ); + WRITE_BYTE( TE_DLIGHT ); + WRITE_COORD( vecShootOrigin.x ); // origin + WRITE_COORD( vecShootOrigin.y ); + WRITE_COORD( vecShootOrigin.z ); + WRITE_BYTE( 16 ); // radius + WRITE_BYTE( 255 ); // R + WRITE_BYTE( 255 ); // G + WRITE_BYTE( 128 ); // B + WRITE_BYTE( 0 ); // life * 10 + WRITE_BYTE( 0 ); // decay + MESSAGE_END(); // Teh_Freak: World Lighting! - } //========================================================= diff --git a/server/monsters/basemonster.cpp b/server/monsters/basemonster.cpp index 2cdc24c3..87bbc774 100644 --- a/server/monsters/basemonster.cpp +++ b/server/monsters/basemonster.cpp @@ -24,6 +24,7 @@ #include "utils.h" #include "cbase.h" #include "nodes.h" +#include "client.h" #include "monsters.h" #include "animation.h" #include "saverestore.h" @@ -748,7 +749,7 @@ void DrawRoute( entvars_t *pev, WayPoint_t *m_Route, int m_iRouteIndex, int r, i // UTIL_ParticleEffect ( m_Route[ m_iRouteIndex ].vecLocation, g_vecZero, 255, 25 ); - MESSAGE_BEGIN( MSG_BROADCAST, SVC_TEMPENTITY ); + MESSAGE_BEGIN( MSG_BROADCAST, gmsg.TempEntity ); WRITE_BYTE( TE_BEAMPOINTS); WRITE_COORD( pev->origin.x ); WRITE_COORD( pev->origin.y ); @@ -776,7 +777,7 @@ void DrawRoute( entvars_t *pev, WayPoint_t *m_Route, int m_iRouteIndex, int r, i break; - MESSAGE_BEGIN( MSG_BROADCAST, SVC_TEMPENTITY ); + MESSAGE_BEGIN( MSG_BROADCAST, gmsg.TempEntity ); WRITE_BYTE( TE_BEAMPOINTS ); WRITE_COORD( m_Route[ i ].vecLocation.x ); WRITE_COORD( m_Route[ i ].vecLocation.y ); @@ -1378,7 +1379,7 @@ int CBaseMonster :: CheckLocalMove ( const Vector &vecStart, const Vector &vecEn } /* // uncommenting this block will draw a line representing the nearest legal move. - WRITE_BYTE(MSG_BROADCAST, SVC_TEMPENTITY); + WRITE_BYTE(MSG_BROADCAST, gmsg.TempEntity); WRITE_BYTE(MSG_BROADCAST, TE_SHOWLINE); WRITE_COORD(MSG_BROADCAST, pev->origin.x); WRITE_COORD(MSG_BROADCAST, pev->origin.y); @@ -1556,7 +1557,7 @@ BOOL CBaseMonster :: BuildRoute ( const Vector &vecGoal, int iMoveFlag, CBaseEnt m_Route[ 1 ].iType = iMoveFlag | bits_MF_IS_GOAL; /* - WRITE_BYTE(MSG_BROADCAST, SVC_TEMPENTITY); + WRITE_BYTE(MSG_BROADCAST, gmsg.TempEntity); WRITE_BYTE(MSG_BROADCAST, TE_SHOWLINE); WRITE_COORD(MSG_BROADCAST, vecApex.x ); WRITE_COORD(MSG_BROADCAST, vecApex.y ); @@ -1667,7 +1668,7 @@ BOOL CBaseMonster :: FTriangulate ( const Vector &vecStart , const Vector &vecEn { // Debug, Draw the triangulation #if 0 - MESSAGE_BEGIN( MSG_BROADCAST, SVC_TEMPENTITY ); + MESSAGE_BEGIN( MSG_BROADCAST, gmsg.TempEntity ); WRITE_BYTE( TE_SHOWLINE); WRITE_COORD( pev->origin.x ); WRITE_COORD( pev->origin.y ); @@ -1677,7 +1678,7 @@ BOOL CBaseMonster :: FTriangulate ( const Vector &vecStart , const Vector &vecEn WRITE_COORD( vecRight.z ); MESSAGE_END(); - MESSAGE_BEGIN( MSG_BROADCAST, SVC_TEMPENTITY ); + MESSAGE_BEGIN( MSG_BROADCAST, gmsg.TempEntity ); WRITE_BYTE( TE_SHOWLINE ); WRITE_COORD( pev->origin.x ); WRITE_COORD( pev->origin.y ); @@ -1691,7 +1692,7 @@ BOOL CBaseMonster :: FTriangulate ( const Vector &vecStart , const Vector &vecEn #if 0 if (pev->movetype == MOVETYPE_FLY) { - MESSAGE_BEGIN( MSG_BROADCAST, SVC_TEMPENTITY ); + MESSAGE_BEGIN( MSG_BROADCAST, gmsg.TempEntity ); WRITE_BYTE( TE_SHOWLINE ); WRITE_COORD( pev->origin.x ); WRITE_COORD( pev->origin.y ); @@ -1701,7 +1702,7 @@ BOOL CBaseMonster :: FTriangulate ( const Vector &vecStart , const Vector &vecEn WRITE_COORD( vecTop.z ); MESSAGE_END(); - MESSAGE_BEGIN( MSG_BROADCAST, SVC_TEMPENTITY ); + MESSAGE_BEGIN( MSG_BROADCAST, gmsg.TempEntity ); WRITE_BYTE( TE_SHOWLINE ); WRITE_COORD( pev->origin.x ); WRITE_COORD( pev->origin.y ); @@ -2308,7 +2309,7 @@ BOOL CBaseMonster :: FindCover ( Vector vecThreat, Vector vecViewOffset, float f if ( FValidateCover ( node.m_vecOrigin ) && MoveToLocation( ACT_RUN, 0, node.m_vecOrigin ) ) { /* - MESSAGE_BEGIN( MSG_BROADCAST, SVC_TEMPENTITY ); + MESSAGE_BEGIN( MSG_BROADCAST, gmsg.TempEntity ); WRITE_BYTE( TE_SHOWLINE); WRITE_COORD( node.m_vecOrigin.x ); @@ -5264,7 +5265,7 @@ void CBaseMonster :: MakeDamageBloodDecal ( int cCount, float flNoise, TraceResu UTIL_TraceLine( ptr->vecEndPos, ptr->vecEndPos + vecTraceDir * 172, ignore_monsters, ENT(pev), &Bloodtr); /* - MESSAGE_BEGIN( MSG_BROADCAST, SVC_TEMPENTITY ); + MESSAGE_BEGIN( MSG_BROADCAST, gmsg.TempEntity ); WRITE_BYTE( TE_SHOWLINE); WRITE_COORD( ptr->vecEndPos.x ); WRITE_COORD( ptr->vecEndPos.y ); diff --git a/server/monsters/combat.cpp b/server/monsters/combat.cpp index 5ff4b989..a3295adb 100644 --- a/server/monsters/combat.cpp +++ b/server/monsters/combat.cpp @@ -23,6 +23,7 @@ #include "extdll.h" #include "utils.h" #include "cbase.h" +#include "client.h" #include "monsters.h" #include "soundent.h" #include "decals.h" @@ -140,7 +141,7 @@ void EjectBrass ( const Vector &vecOrigin, const Vector &vecVelocity, float rota { // FIX: when the player shoots, their gun isn't in the same position as it is on the model other players see. - MESSAGE_BEGIN( MSG_PVS, SVC_TEMPENTITY, vecOrigin ); + MESSAGE_BEGIN( MSG_PVS, gmsg.TempEntity, vecOrigin ); WRITE_BYTE( TE_MODEL); WRITE_COORD( vecOrigin.x); WRITE_COORD( vecOrigin.y); diff --git a/server/monsters/hgrunt.cpp b/server/monsters/hgrunt.cpp index a43ecf6c..5e9ba136 100644 --- a/server/monsters/hgrunt.cpp +++ b/server/monsters/hgrunt.cpp @@ -32,6 +32,7 @@ #include "plane.h" #include "utils.h" #include "cbase.h" +#include "client.h" #include "monsters.h" #include "schedule.h" #include "animation.h" @@ -811,18 +812,18 @@ void CHGrunt :: Shoot ( void ) SetBlending( 0, angDir.x ); // Teh_Freak: World Lighting! - MESSAGE_BEGIN( MSG_BROADCAST, SVC_TEMPENTITY ); - WRITE_BYTE( TE_DLIGHT ); - WRITE_COORD( vecShootOrigin.x ); // origin - WRITE_COORD( vecShootOrigin.y ); - WRITE_COORD( vecShootOrigin.z ); - WRITE_BYTE( 16 ); // radius - WRITE_BYTE( 255 ); // R - WRITE_BYTE( 255 ); // G - WRITE_BYTE( 128 ); // B - WRITE_BYTE( 0 ); // life * 10 - WRITE_BYTE( 0 ); // decay - MESSAGE_END(); + MESSAGE_BEGIN( MSG_BROADCAST, gmsg.TempEntity ); + WRITE_BYTE( TE_DLIGHT ); + WRITE_COORD( vecShootOrigin.x ); // origin + WRITE_COORD( vecShootOrigin.y ); + WRITE_COORD( vecShootOrigin.z ); + WRITE_BYTE( 16 ); // radius + WRITE_BYTE( 255 ); // R + WRITE_BYTE( 255 ); // G + WRITE_BYTE( 128 ); // B + WRITE_BYTE( 0 ); // life * 10 + WRITE_BYTE( 0 ); // decay + MESSAGE_END(); // Teh_Freak: World Lighting! } @@ -854,18 +855,18 @@ void CHGrunt :: Shotgun ( void ) SetBlending( 0, angDir.x ); // Teh_Freak: World Lighting! - MESSAGE_BEGIN( MSG_BROADCAST, SVC_TEMPENTITY ); - WRITE_BYTE( TE_DLIGHT ); - WRITE_COORD( vecShootOrigin.x ); // origin - WRITE_COORD( vecShootOrigin.y ); - WRITE_COORD( vecShootOrigin.z ); - WRITE_BYTE( 16 ); // radius - WRITE_BYTE( 255 ); // R - WRITE_BYTE( 255 ); // G - WRITE_BYTE( 128 ); // B - WRITE_BYTE( 0 ); // life * 10 - WRITE_BYTE( 0 ); // decay - MESSAGE_END(); + MESSAGE_BEGIN( MSG_BROADCAST, gmsg.TempEntity ); + WRITE_BYTE( TE_DLIGHT ); + WRITE_COORD( vecShootOrigin.x ); // origin + WRITE_COORD( vecShootOrigin.y ); + WRITE_COORD( vecShootOrigin.z ); + WRITE_BYTE( 16 ); // radius + WRITE_BYTE( 255 ); // R + WRITE_BYTE( 255 ); // G + WRITE_BYTE( 128 ); // B + WRITE_BYTE( 0 ); // life * 10 + WRITE_BYTE( 0 ); // decay + MESSAGE_END(); // Teh_Freak: World Lighting! } diff --git a/server/monsters/nodes.cpp b/server/monsters/nodes.cpp index 25c0cded..6085c5f9 100644 --- a/server/monsters/nodes.cpp +++ b/server/monsters/nodes.cpp @@ -22,6 +22,7 @@ #include "extdll.h" #include "utils.h" #include "cbase.h" +#include "client.h" #include "monsters.h" #include "nodes.h" #include "animation.h" @@ -415,7 +416,7 @@ int CGraph :: FindNearestLink ( const Vector &vecTestPoint, int *piNearestLink, /* if ( fSuccess ) { - WRITE_BYTE(MSG_BROADCAST, SVC_TEMPENTITY); + WRITE_BYTE(MSG_BROADCAST, gmsg.TempEntity); WRITE_BYTE(MSG_BROADCAST, TE_SHOWLINE); WRITE_COORD(MSG_BROADCAST, m_pNodes[ m_pLinkPool[ iNearestLink ].m_iSrcNode ].m_vecOrigin.x ); @@ -742,7 +743,7 @@ int CGraph :: FindShortestPath ( int *piPath, int iStart, int iDest, int iHull, for ( int i = 0 ; i < iNumPathNodes - 1 ; i++ ) { - MESSAGE_BEGIN( MSG_BROADCAST, SVC_TEMPENTITY ); + MESSAGE_BEGIN( MSG_BROADCAST, gmsg.TempEntity ); WRITE_BYTE( TE_SHOWLINE); WRITE_COORD( m_pNodes[ piPath[ i ] ].m_vecOrigin.x ); @@ -758,7 +759,7 @@ int CGraph :: FindShortestPath ( int *piPath, int iStart, int iDest, int iHull, #endif #if 0 // MAZE map - MESSAGE_BEGIN( MSG_BROADCAST, SVC_TEMPENTITY ); + MESSAGE_BEGIN( MSG_BROADCAST, gmsg.TempEntity ); WRITE_BYTE( TE_SHOWLINE); WRITE_COORD( m_pNodes[ 4 ].m_vecOrigin.x ); @@ -1111,7 +1112,7 @@ void CGraph :: ShowNodeConnections ( int iNode ) pLinkNode = &Node( NodeLink( iNode, i).m_iDestNode ); vecSpot = pLinkNode->m_vecOrigin; - MESSAGE_BEGIN( MSG_BROADCAST, SVC_TEMPENTITY ); + MESSAGE_BEGIN( MSG_BROADCAST, gmsg.TempEntity ); WRITE_BYTE( TE_SHOWLINE); WRITE_COORD( m_pNodes[ iNode ].m_vecOrigin.x ); @@ -2093,7 +2094,7 @@ void CTestHull :: PathFind ( void ) pNextNode = &WorldGraph.m_pNodes[ iPath [ i + 1 ] ]; - MESSAGE_BEGIN( MSG_BROADCAST, SVC_TEMPENTITY ); + MESSAGE_BEGIN( MSG_BROADCAST, gmsg.TempEntity ); WRITE_BYTE( TE_SHOWLINE); WRITE_COORD( pNode->m_vecOrigin.x ); @@ -3631,7 +3632,7 @@ void CNodeViewer :: DrawThink( void ) } extern short g_sModelIndexLaser; - MESSAGE_BEGIN( MSG_BROADCAST, SVC_TEMPENTITY ); + MESSAGE_BEGIN( MSG_BROADCAST, gmsg.TempEntity ); WRITE_BYTE( TE_BEAMPOINTS ); WRITE_COORD( WorldGraph.m_pNodes[ m_aFrom[m_iDraw] ].m_vecOrigin.x ); WRITE_COORD( WorldGraph.m_pNodes[ m_aFrom[m_iDraw] ].m_vecOrigin.y ); diff --git a/server/monsters/osprey.cpp b/server/monsters/osprey.cpp index cd297531..08f5b181 100644 --- a/server/monsters/osprey.cpp +++ b/server/monsters/osprey.cpp @@ -15,6 +15,7 @@ #include "extdll.h" #include "utils.h" #include "cbase.h" +#include "client.h" #include "monsters.h" #include "baseweapon.h" #include "nodes.h" @@ -573,7 +574,7 @@ void COsprey :: DyingThink( void ) Vector vecSpot = pev->origin + pev->velocity * 0.2; // random explosions - MESSAGE_BEGIN( MSG_PVS, SVC_TEMPENTITY, vecSpot ); + MESSAGE_BEGIN( MSG_PVS, gmsg.TempEntity, vecSpot ); WRITE_BYTE( TE_EXPLOSION); // This just makes a dynamic light now WRITE_COORD( vecSpot.x + RANDOM_FLOAT( -150, 150 )); WRITE_COORD( vecSpot.y + RANDOM_FLOAT( -150, 150 )); @@ -585,7 +586,7 @@ void COsprey :: DyingThink( void ) MESSAGE_END(); // lots of smoke - MESSAGE_BEGIN( MSG_PVS, SVC_TEMPENTITY, vecSpot ); + MESSAGE_BEGIN( MSG_PVS, gmsg.TempEntity, vecSpot ); WRITE_BYTE( TE_SMOKE ); WRITE_COORD( vecSpot.x + RANDOM_FLOAT( -150, 150 )); WRITE_COORD( vecSpot.y + RANDOM_FLOAT( -150, 150 )); @@ -597,7 +598,7 @@ void COsprey :: DyingThink( void ) vecSpot = pev->origin + (pev->mins + pev->maxs) * 0.5; - MESSAGE_BEGIN( MSG_PVS, SVC_TEMPENTITY, vecSpot ); + MESSAGE_BEGIN( MSG_PVS, gmsg.TempEntity, vecSpot ); WRITE_BYTE( TE_BREAKMODEL); // position @@ -644,7 +645,7 @@ void COsprey :: DyingThink( void ) Vector vecSpot = pev->origin + (pev->mins + pev->maxs) * 0.5; /* - MESSAGE_BEGIN( MSG_BROADCAST, SVC_TEMPENTITY ); + MESSAGE_BEGIN( MSG_BROADCAST, gmsg.TempEntity ); WRITE_BYTE( TE_EXPLOSION); // This just makes a dynamic light now WRITE_COORD( vecSpot.x ); WRITE_COORD( vecSpot.y ); @@ -656,7 +657,7 @@ void COsprey :: DyingThink( void ) */ // gibs - MESSAGE_BEGIN( MSG_PVS, SVC_TEMPENTITY, vecSpot ); + MESSAGE_BEGIN( MSG_PVS, gmsg.TempEntity, vecSpot ); WRITE_BYTE( TE_SPRITE ); WRITE_COORD( vecSpot.x ); WRITE_COORD( vecSpot.y ); @@ -667,7 +668,7 @@ void COsprey :: DyingThink( void ) MESSAGE_END(); /* - MESSAGE_BEGIN( MSG_BROADCAST, SVC_TEMPENTITY ); + MESSAGE_BEGIN( MSG_BROADCAST, gmsg.TempEntity ); WRITE_BYTE( TE_SMOKE ); WRITE_COORD( vecSpot.x ); WRITE_COORD( vecSpot.y ); @@ -679,7 +680,7 @@ void COsprey :: DyingThink( void ) */ // blast circle - MESSAGE_BEGIN( MSG_PAS, SVC_TEMPENTITY, pev->origin ); + MESSAGE_BEGIN( MSG_PAS, gmsg.TempEntity, pev->origin ); WRITE_BYTE( TE_BEAMCYLINDER ); WRITE_COORD( pev->origin.x); WRITE_COORD( pev->origin.y); @@ -706,7 +707,7 @@ void COsprey :: DyingThink( void ) // gibs vecSpot = pev->origin + (pev->mins + pev->maxs) * 0.5; - MESSAGE_BEGIN( MSG_PAS, SVC_TEMPENTITY, vecSpot ); + MESSAGE_BEGIN( MSG_PAS, gmsg.TempEntity, vecSpot ); WRITE_BYTE( TE_BREAKMODEL); // position @@ -751,7 +752,7 @@ void COsprey :: ShowDamage( void ) if (m_iDoLeftSmokePuff > 0 || RANDOM_LONG(0,99) > m_flLeftHealth) { Vector vecSrc = pev->origin + gpGlobals->v_right * -340; - MESSAGE_BEGIN( MSG_PVS, SVC_TEMPENTITY, vecSrc ); + MESSAGE_BEGIN( MSG_PVS, gmsg.TempEntity, vecSrc ); WRITE_BYTE( TE_SMOKE ); WRITE_COORD( vecSrc.x ); WRITE_COORD( vecSrc.y ); @@ -766,7 +767,7 @@ void COsprey :: ShowDamage( void ) if (m_iDoRightSmokePuff > 0 || RANDOM_LONG(0,99) > m_flRightHealth) { Vector vecSrc = pev->origin + gpGlobals->v_right * 340; - MESSAGE_BEGIN( MSG_PVS, SVC_TEMPENTITY, vecSrc ); + MESSAGE_BEGIN( MSG_PVS, gmsg.TempEntity, vecSrc ); WRITE_BYTE( TE_SMOKE ); WRITE_COORD( vecSrc.x ); WRITE_COORD( vecSrc.y ); diff --git a/server/monsters/player.cpp b/server/monsters/player.cpp index 076747ae..86e54ba1 100644 --- a/server/monsters/player.cpp +++ b/server/monsters/player.cpp @@ -821,7 +821,7 @@ void CBasePlayer::RemoveAllItems( BOOL removeSuit ) UpdateClientData(); // send Selected Weapon Message to our client - MESSAGE_BEGIN( MSG_ONE, gmsgCurWeapon, NULL, pev ); + MESSAGE_BEGIN( MSG_ONE, gmsg.CurWeapon, NULL, pev ); WRITE_BYTE(0); WRITE_BYTE(0); WRITE_BYTE(0); @@ -885,12 +885,12 @@ void CBasePlayer::Killed( entvars_t *pevAttacker, int iGib ) // send "health" update message to zero m_iClientHealth = 0; - MESSAGE_BEGIN( MSG_ONE, gmsgHealth, NULL, pev ); + MESSAGE_BEGIN( MSG_ONE, gmsg.Health, NULL, pev ); WRITE_BYTE( m_iClientHealth ); MESSAGE_END(); // Tell Ammo Hud that the player is dead - MESSAGE_BEGIN( MSG_ONE, gmsgCurWeapon, NULL, pev ); + MESSAGE_BEGIN( MSG_ONE, gmsg.CurWeapon, NULL, pev ); WRITE_BYTE(0); WRITE_BYTE(0XFF); WRITE_BYTE(0xFF); @@ -903,7 +903,7 @@ void CBasePlayer::Killed( entvars_t *pevAttacker, int iGib ) viewFlags = 0; viewNeedsUpdate = 1; - MESSAGE_BEGIN( MSG_ONE, gmsgSetFOV, NULL, pev ); + MESSAGE_BEGIN( MSG_ONE, gmsg.SetFOV, NULL, pev ); WRITE_BYTE(0); MESSAGE_END(); @@ -1313,7 +1313,7 @@ void CBasePlayer::PlayerDeathThink(void) } //disable redeemer HUD - MESSAGE_BEGIN( MSG_ONE, gmsgWarHUD, NULL, pev ); + MESSAGE_BEGIN( MSG_ONE, gmsg.WarHUD, NULL, pev ); WRITE_BYTE( 0 ); MESSAGE_END(); @@ -1790,7 +1790,7 @@ void CBasePlayer::AddPoints( int score, BOOL bAllowNegativeScore ) pev->frags += score; - MESSAGE_BEGIN( MSG_ALL, gmsgScoreInfo ); + MESSAGE_BEGIN( MSG_ALL, gmsg.ScoreInfo ); WRITE_BYTE( ENTINDEX(edict()) ); WRITE_SHORT( pev->frags ); WRITE_SHORT( m_iDeaths ); @@ -1875,7 +1875,7 @@ void CBasePlayer::UpdateStatusBar() if ( strcmp( sbuf0, m_SbarString0 ) ) { - MESSAGE_BEGIN( MSG_ONE, gmsgStatusText, NULL, pev ); + MESSAGE_BEGIN( MSG_ONE, gmsg.StatusText, NULL, pev ); WRITE_BYTE( 0 ); WRITE_STRING( sbuf0 ); MESSAGE_END(); @@ -1888,7 +1888,7 @@ void CBasePlayer::UpdateStatusBar() if ( strcmp( sbuf1, m_SbarString1 ) ) { - MESSAGE_BEGIN( MSG_ONE, gmsgStatusText, NULL, pev ); + MESSAGE_BEGIN( MSG_ONE, gmsg.StatusText, NULL, pev ); WRITE_BYTE( 1 ); WRITE_STRING( sbuf1 ); MESSAGE_END(); @@ -1904,7 +1904,7 @@ void CBasePlayer::UpdateStatusBar() { if ( newSBarState[i] != m_izSBarState[i] || bForceResend ) { - MESSAGE_BEGIN( MSG_ONE, gmsgStatusValue, NULL, pev ); + MESSAGE_BEGIN( MSG_ONE, gmsg.StatusValue, NULL, pev ); WRITE_BYTE( i ); WRITE_SHORT( newSBarState[i] ); MESSAGE_END(); @@ -2653,7 +2653,7 @@ void CBasePlayer :: UpdateGeigerCounter( void ) { m_igeigerRangePrev = range; - MESSAGE_BEGIN( MSG_ONE, gmsgGeigerRange, NULL, pev ); + MESSAGE_BEGIN( MSG_ONE, gmsg.GeigerRange, NULL, pev ); WRITE_BYTE( range ); MESSAGE_END(); } @@ -3760,7 +3760,7 @@ void CBasePlayer :: FlashlightTurnOn( void ) { EMIT_SOUND_DYN( ENT(pev), CHAN_WEAPON, SOUND_FLASHLIGHT_ON, 1.0, ATTN_NORM, 0, PITCH_NORM ); SetBits(pev->effects, EF_DIMLIGHT); - MESSAGE_BEGIN( MSG_ONE, gmsgFlashlight, NULL, pev ); + MESSAGE_BEGIN( MSG_ONE, gmsg.Flashlight, NULL, pev ); WRITE_BYTE(1); WRITE_BYTE(m_iFlashBattery); MESSAGE_END(); @@ -3775,7 +3775,7 @@ void CBasePlayer :: FlashlightTurnOff( void ) EMIT_SOUND_DYN( ENT(pev), CHAN_WEAPON, SOUND_FLASHLIGHT_OFF, 1.0, ATTN_NORM, 0, PITCH_NORM ); ClearBits(pev->effects, EF_DIMLIGHT); - MESSAGE_BEGIN( MSG_ONE, gmsgFlashlight, NULL, pev ); + MESSAGE_BEGIN( MSG_ONE, gmsg.Flashlight, NULL, pev ); WRITE_BYTE(0); WRITE_BYTE(m_iFlashBattery); MESSAGE_END(); @@ -3800,7 +3800,7 @@ void CBasePlayer :: ForceClientDllUpdate( void ) m_iTrain |= TRAIN_NEW; // Force new train message. m_fWeapon = FALSE; // Force weapon send m_fKnownItem = FALSE; // Force weaponinit messages. - m_fInitHUD = TRUE; // Force HUD gmsgResetHUD message + m_fInitHUD = TRUE; // Force HUD gmsg.ResetHUD message // Now force all the necessary messages // to be sent. @@ -4073,10 +4073,10 @@ int CBasePlayer :: GiveAmmo( int iCount, char *szName, int iMax ) m_rgAmmo[ i ] += iAdd; - if ( gmsgAmmoPickup )// make sure the ammo messages have been linked first + if ( gmsg.AmmoPickup )// make sure the ammo messages have been linked first { // Send the message that ammo has been picked up - MESSAGE_BEGIN( MSG_ONE, gmsgAmmoPickup, NULL, pev ); + MESSAGE_BEGIN( MSG_ONE, gmsg.AmmoPickup, NULL, pev ); WRITE_BYTE( GetAmmoIndex(szName) ); WRITE_BYTE( iAdd ); MESSAGE_END(); @@ -4190,7 +4190,7 @@ void CBasePlayer::SendAmmoUpdate(void) ASSERT( m_rgAmmo[i] < 255 ); // send "Ammo" update message - MESSAGE_BEGIN( MSG_ONE, gmsgAmmoX, NULL, pev ); + MESSAGE_BEGIN( MSG_ONE, gmsg.AmmoX, NULL, pev ); WRITE_BYTE( i ); WRITE_BYTE( max( min( m_rgAmmo[i], 254 ), 0 ) ); // clamp the value to one byte MESSAGE_END(); @@ -4220,13 +4220,13 @@ void CBasePlayer :: UpdateClientData( void ) m_fInitHUD = FALSE; gInitHUD = FALSE; - MESSAGE_BEGIN( MSG_ONE, gmsgResetHUD, NULL, pev ); + MESSAGE_BEGIN( MSG_ONE, gmsg.ResetHUD, NULL, pev ); WRITE_BYTE( 0 ); MESSAGE_END(); if ( !m_fGameHUDInitialized ) { - MESSAGE_BEGIN( MSG_ONE, gmsgInitHUD, NULL, pev ); + MESSAGE_BEGIN( MSG_ONE, gmsg.InitHUD, NULL, pev ); MESSAGE_END(); g_pGameRules->InitHUD( this ); @@ -4244,7 +4244,7 @@ void CBasePlayer :: UpdateClientData( void ) if ( m_iHideHUD != m_iClientHideHUD ) { - MESSAGE_BEGIN( MSG_ONE, gmsgHideWeapon, NULL, pev ); + MESSAGE_BEGIN( MSG_ONE, gmsg.HideWeapon, NULL, pev ); WRITE_BYTE( m_iHideHUD ); MESSAGE_END(); @@ -4253,7 +4253,7 @@ void CBasePlayer :: UpdateClientData( void ) if ( m_iFOV != m_iClientFOV ) { - MESSAGE_BEGIN( MSG_ONE, gmsgSetFOV, NULL, pev ); + MESSAGE_BEGIN( MSG_ONE, gmsg.SetFOV, NULL, pev ); WRITE_BYTE( m_iFOV ); MESSAGE_END(); @@ -4272,7 +4272,7 @@ void CBasePlayer :: UpdateClientData( void ) viewFlags = 0; //clear possibly ACTIVE flag } - MESSAGE_BEGIN(MSG_ONE, gmsgCamData, NULL, pev); + MESSAGE_BEGIN(MSG_ONE, gmsg.CamData, NULL, pev); WRITE_SHORT( indexToSend ); WRITE_SHORT( viewFlags ); MESSAGE_END(); @@ -4280,19 +4280,19 @@ void CBasePlayer :: UpdateClientData( void ) viewNeedsUpdate = 0; } - if( hearNeedsUpdate != 0) + if( hearNeedsUpdate != 0 ) { - //update dsp sound - MESSAGE_BEGIN( MSG_ONE, SVC_ROOMTYPE, NULL, pev ); + // update dsp sound + MESSAGE_BEGIN( MSG_ONE, gmsg.RoomType, NULL, pev ); WRITE_SHORT( m_iSndRoomtype ); MESSAGE_END(); hearNeedsUpdate = 0; } - if(fadeNeedsUpdate != 0) + if( fadeNeedsUpdate != 0 ) { - //update screenfade - MESSAGE_BEGIN( MSG_ONE, gmsgFade, NULL, pev ); + // update screenfade + MESSAGE_BEGIN( MSG_ONE, gmsg.Fade, NULL, pev ); WRITE_SHORT( FixedUnsigned16( m_iFadeTime, 1<<12 )); WRITE_SHORT( FixedUnsigned16( m_iFadeHold, 1<<12 )); WRITE_SHORT( m_iFadeFlags ); // fade flags @@ -4332,7 +4332,7 @@ void CBasePlayer :: UpdateClientData( void ) if(fogNeedsUpdate != 0) { //update fog - MESSAGE_BEGIN( MSG_ONE, gmsgSetFog, NULL, pev ); + MESSAGE_BEGIN( MSG_ONE, gmsg.SetFog, NULL, pev ); WRITE_BYTE ( m_FogColor.x ); WRITE_BYTE ( m_FogColor.y ); WRITE_BYTE ( m_FogColor.z ); @@ -4344,7 +4344,7 @@ void CBasePlayer :: UpdateClientData( void ) if( m_iWarHUD != m_iClientWarHUD ) { - MESSAGE_BEGIN( MSG_ONE, gmsgWarHUD, NULL, pev ); + MESSAGE_BEGIN( MSG_ONE, gmsg.WarHUD, NULL, pev ); WRITE_BYTE( m_iWarHUD );//make static screen MESSAGE_END(); m_iClientWarHUD = m_iWarHUD; @@ -4355,7 +4355,7 @@ void CBasePlayer :: UpdateClientData( void ) int iHealth = max( pev->health, 0 ); // make sure that no negative health values are sent // send "health" update message - MESSAGE_BEGIN( MSG_ONE, gmsgHealth, NULL, pev ); + MESSAGE_BEGIN( MSG_ONE, gmsg.Health, NULL, pev ); WRITE_BYTE( iHealth ); MESSAGE_END(); @@ -4367,9 +4367,9 @@ void CBasePlayer :: UpdateClientData( void ) { m_iClientBattery = pev->armorvalue; - ASSERT( gmsgBattery > 0 ); + ASSERT( gmsg.Battery > 0 ); // send "health" update message - MESSAGE_BEGIN( MSG_ONE, gmsgBattery, NULL, pev ); + MESSAGE_BEGIN( MSG_ONE, gmsg.Battery, NULL, pev ); WRITE_SHORT( (int)pev->armorvalue); MESSAGE_END(); } @@ -4391,7 +4391,7 @@ void CBasePlayer :: UpdateClientData( void ) // only send down damage type that have hud art int visibleDamageBits = m_bitsDamageType & DMG_SHOWNHUD; - MESSAGE_BEGIN( MSG_ONE, gmsgDamage, NULL, pev ); + MESSAGE_BEGIN( MSG_ONE, gmsg.Damage, NULL, pev ); WRITE_BYTE( pev->dmg_save ); WRITE_BYTE( pev->dmg_take ); WRITE_LONG( visibleDamageBits ); @@ -4431,7 +4431,7 @@ void CBasePlayer :: UpdateClientData( void ) else m_flFlashLightTime = 0; } - MESSAGE_BEGIN( MSG_ONE, gmsgFlashBattery, NULL, pev ); + MESSAGE_BEGIN( MSG_ONE, gmsg.FlashBattery, NULL, pev ); WRITE_BYTE(m_iFlashBattery); MESSAGE_END(); } @@ -4510,7 +4510,7 @@ void CBasePlayer :: UpdateClientData( void ) pFind = UTIL_FindEntityByClassname( pFind, "util_rainmodify" ); } - MESSAGE_BEGIN(MSG_ONE, gmsgRainData, NULL, pev); + MESSAGE_BEGIN(MSG_ONE, gmsg.RainData, NULL, pev); WRITE_SHORT(Rain_dripsPerSecond); WRITE_COORD(raindistance); WRITE_COORD(Rain_windX); @@ -4527,7 +4527,8 @@ void CBasePlayer :: UpdateClientData( void ) ALERT(at_aiconsole, "Sending disabling rain message\n"); } else - { // no rain on this map + { + // no rain on this map Rain_dripsPerSecond = 0; Rain_windX = 0; Rain_windY = 0; @@ -4540,10 +4541,7 @@ void CBasePlayer :: UpdateClientData( void ) Rain_ideal_randY = 0; Rain_endFade = 0; Rain_nextFadeUpdate = 0; - - ALERT(at_aiconsole, "Clearing rain data\n"); } - rainNeedsUpdate = 0; } @@ -4563,16 +4561,16 @@ void CBasePlayer :: UpdateClientData( void ) } else m_flFlashLightTime = 0; - MESSAGE_BEGIN( MSG_ONE, gmsgFlashBattery, NULL, pev ); + MESSAGE_BEGIN( MSG_ONE, gmsg.FlashBattery, NULL, pev ); WRITE_BYTE(m_iFlashBattery); MESSAGE_END(); } if (m_iTrain & TRAIN_NEW) { - ASSERT( gmsgTrain > 0 ); + ASSERT( gmsg.Train > 0 ); // send "health" update message - MESSAGE_BEGIN( MSG_ONE, gmsgTrain, NULL, pev ); + MESSAGE_BEGIN( MSG_ONE, gmsg.Train, NULL, pev ); WRITE_BYTE(m_iTrain & 0xF); MESSAGE_END(); @@ -4613,7 +4611,7 @@ void CBasePlayer :: UpdateClientData( void ) if (!II.pszName) pszName = "Empty"; else pszName = II.pszName; - MESSAGE_BEGIN( MSG_ONE, gmsgWeaponList, NULL, pev ); + MESSAGE_BEGIN( MSG_ONE, gmsg.WeaponList, NULL, pev ); WRITE_STRING(pszName); // string weapon name WRITE_BYTE(GetAmmoIndex(II.pszAmmo1)); // byte Ammo Type WRITE_BYTE(II.iMaxAmmo1); // byte Max Ammo 1 diff --git a/server/monsters/player.h b/server/monsters/player.h index baa55025..03e671dd 100644 --- a/server/monsters/player.h +++ b/server/monsters/player.h @@ -55,7 +55,7 @@ #define CSUITPLAYLIST 4 // max of 4 suit sentences queued up at any time #define SUIT_GROUP TRUE -#define SUIT_SENTENCE FALSE +#define SUIT_SENTENCE FALSE #define SUIT_REPEAT_OK 0 #define SUIT_NEXT_IN_30SEC 30 @@ -371,12 +371,6 @@ public: #define AUTOAIM_8DEGREES 0.1391731009601 #define AUTOAIM_10DEGREES 0.1736481776669 - -extern int gmsgHudText; -extern int gmsgSetBody; -extern int gmsgSetSkin; -extern int gmsgZoomHUD; -extern int gmsgWarHUD; extern BOOL gInitHUD; #endif // PLAYER_H diff --git a/server/monsters/turret.cpp b/server/monsters/turret.cpp index 9e49241b..ecf688e3 100644 --- a/server/monsters/turret.cpp +++ b/server/monsters/turret.cpp @@ -27,6 +27,7 @@ #include "extdll.h" #include "utils.h" #include "cbase.h" +#include "client.h" #include "monsters.h" #include "baseweapon.h" #include "basebeams.h" @@ -974,7 +975,7 @@ void CBaseTurret :: TurretDeath( void ) if (pev->dmgtime + RANDOM_FLOAT( 0, 2 ) > gpGlobals->time) { // lots of smoke - MESSAGE_BEGIN( MSG_BROADCAST, SVC_TEMPENTITY ); + MESSAGE_BEGIN( MSG_BROADCAST, gmsg.TempEntity ); WRITE_BYTE( TE_SMOKE ); WRITE_COORD( RANDOM_FLOAT( pev->absmin.x, pev->absmax.x ) ); WRITE_COORD( RANDOM_FLOAT( pev->absmin.y, pev->absmax.y ) ); @@ -1310,7 +1311,7 @@ void CSentry :: SentryDeath( void ) if (pev->dmgtime + RANDOM_FLOAT( 0, 2 ) > gpGlobals->time) { // lots of smoke - MESSAGE_BEGIN( MSG_BROADCAST, SVC_TEMPENTITY ); + MESSAGE_BEGIN( MSG_BROADCAST, gmsg.TempEntity ); WRITE_BYTE( TE_SMOKE ); WRITE_COORD( vecSrc.x + RANDOM_FLOAT( -16, 16 ) ); WRITE_COORD( vecSrc.y + RANDOM_FLOAT( -16, 16 ) ); diff --git a/todo.log b/todo.log index 0548912e..ce8be25f 100644 --- a/todo.log +++ b/todo.log @@ -25,13 +25,15 @@ Beta 13.12.08 4. release crash OK 5. timers set OK 6. AI_ -> FL_ OK -7. SVC_SOUND +7. SVC_SOUND OK +8. client.dll implementation OK +9. HookUserMessages OK +10.remove SVC_* in utils.h OK +11.Load server.dll and client.dll only once OK +12.v_refdef interactions entity_state_t невидима для пользователя -edict_t - существует только на сервере - - Список доступных рендереров: Что в них интересного 0. Q3Fusion (Mirrors, Portals)