23 Jan 2009

This commit is contained in:
g-cont 2009-01-23 00:00:00 +03:00 committed by Alibek Omarov
parent 539f54b707
commit 3e1ed3b432
68 changed files with 2392 additions and 1180 deletions

View File

@ -197,10 +197,6 @@ SOURCE=.\hud\hud_train.cpp
# End Source File
# Begin Source File
SOURCE=.\hud\hud_utils.cpp
# End Source File
# Begin Source File
SOURCE=.\hud\hud_warhead.cpp
# End Source File
# Begin Source File
@ -217,6 +213,10 @@ SOURCE=.\global\triapi.cpp
# End Source File
# Begin Source File
SOURCE=.\global\utils.cpp
# End Source File
# Begin Source File
SOURCE=.\global\view.cpp
# End Source File
# End Group
@ -249,7 +249,7 @@ SOURCE=.\hud\hud_health.h
# End Source File
# Begin Source File
SOURCE=.\hud\hud_iface.h
SOURCE=.\global\utils.h
# End Source File
# Begin Source File

View File

@ -4,7 +4,7 @@
//=======================================================================
#include "extdll.h"
#include "hud_iface.h"
#include "utils.h"
#include "hud.h"
cl_enginefuncs_t g_engfuncs;
@ -60,6 +60,8 @@ int HUD_VidInit( void )
void HUD_Init( void )
{
gHUD.Init();
V_Init();
}
int HUD_Redraw( float flTime, int state )

View File

@ -63,9 +63,13 @@ inline void CL_PlaySound( int iSound, float flVolume, Vector &pos, float pitch =
#define GetClientTime (*g_engfuncs.pfnGetClientTime)
#define GetMaxClients (*g_engfuncs.pfnGetMaxClients)
#define GetViewModel (*g_engfuncs.pfnGetViewModel)
#define GetModelPtr (*g_engfuncs.pfnGetModelPtr)
#define MAKE_LEVELSHOT (*g_engfuncs.pfnMakeLevelShot)
#define POINT_CONTENTS (*g_engfuncs.pfnPointContents)
#define TRACE_LINE (*g_engfuncs.pfnTraceLine)
#define TRACE_HULL (*g_engfuncs.pfnTraceHull)
#define ALLOC_STRING (*g_engfuncs.pfnAllocString)
#define STRING (*g_engfuncs.pfnGetString)
#define RANDOM_LONG (*g_engfuncs.pfnRandomLong)
#define RANDOM_FLOAT (*g_engfuncs.pfnRandomFloat)
#define LOAD_FILE (*g_engfuncs.pfnLoadFile)

View File

@ -4,7 +4,7 @@
//=======================================================================
#include "extdll.h"
#include "hud_iface.h"
#include "utils.h"
#include "studio_event.h"
#include "effects_api.h"
#include "te_message.h"

View File

@ -4,7 +4,7 @@
//=======================================================================
#include "extdll.h"
#include "hud_iface.h"
#include "utils.h"
void HUD_DrawNormalTriangles( void )
{

View File

@ -1,10 +1,10 @@
//=======================================================================
// Copyright XashXT Group 2008 ©
// hud_utils.cpp - client game utilities code
// utils.cpp - client game utilities code
//=======================================================================
#include "extdll.h"
#include "hud_iface.h"
#include "utils.h"
#include "hud.h"
// NOTE: modify these functions with caution

View File

@ -1,10 +1,10 @@
//=======================================================================
// Copyright XashXT Group 2008 ©
// hud_iface.h - client exported funcs
// utils.h - client utilities
//=======================================================================
#ifndef HUD_IFACE_H
#define HUD_IFACE_H
#ifndef UTILS_H
#define UTILS_H
extern cl_enginefuncs_t g_engfuncs;
@ -23,6 +23,9 @@ extern void HUD_CreateEntities( void );
extern void HUD_StudioEvent( const dstudioevent_t *event, edict_t *entity );
extern void HUD_ParseTempEntity( void );
extern void V_CalcRefdef( ref_params_t *parms );
extern void V_Init( void );
#define VIEWPORT_SIZE 512
typedef struct rect_s
{
@ -47,11 +50,7 @@ typedef struct dllfunction_s
void **funcvariable;
} dllfunction_t;
// cvar flags
#define CVAR_ARCHIVE BIT(0) // set to cause it to be saved to vars.rc
#define CVAR_USERINFO BIT(1) // added to userinfo when changed
#define CVAR_SERVERINFO BIT(2) // added to serverinfo when changed
#define CVAR_LATCH BIT(5)
#include "cvardef.h"
// macros to hook function calls into the HUD object
#define HOOK_MESSAGE( x ) (*g_engfuncs.pfnHookUserMsg)( #x, __MsgFunc_##x );
@ -99,6 +98,23 @@ inline void ScaleColors( int &r, int &g, int &b, int a )
b = (int)(b * x);
}
inline float LerpAngle( float a2, float a1, float frac )
{
if( a1 - a2 > 180 ) a1 -= 360;
if( a1 - a2 < -180 ) a1 += 360;
return a2 + frac * (a1 - a2);
}
inline float LerpView( float org1, float org2, float ofs1, float ofs2, float frac )
{
return org1 + ofs1 + frac * (org2 + ofs2 - (org1 + ofs1));
}
inline float LerpPoint( float oldpoint, float curpoint, float frac )
{
return oldpoint + frac * (curpoint - oldpoint);
}
inline int ConsoleStringLen( const char *string )
{
// console using fixed font size
@ -193,4 +209,4 @@ BOOL Sys_LoadLibrary( const char* dllname, dllhandle_t* handle, const dllfunctio
void* Sys_GetProcAddress( dllhandle_t handle, const char* name );
void Sys_UnloadLibrary( dllhandle_t* handle );
#endif//HUD_IFACE_H
#endif//UTILS_H

File diff suppressed because it is too large Load Diff

View File

@ -3,7 +3,7 @@
//=======================================================================
#include "extdll.h"
#include "hud_iface.h"
#include "utils.h"
#include "hud.h"
void CHud :: Init( void )
@ -270,7 +270,7 @@ int CHud :: Redraw( float flTime )
}
// custom view active, and flag "draw hud" isn't set
if(( viewFlags & 1 ) && !( viewFlags & 2 ))
if(( viewFlags & CAMERA_ON ) && !( viewFlags & DRAW_HUD ))
return 1;
if( CVAR_GET_FLOAT( "hud_draw" ))

View File

@ -19,7 +19,7 @@
//
#include "extdll.h"
#include "hud_iface.h"
#include "utils.h"
#include "hud.h"
#include "hud_ammohistory.h"
@ -259,7 +259,7 @@ int CHudAmmo::Init( void )
Reset();
CVAR_REGISTER( "hud_drawhistory_time", HISTORY_DRAW_TIME, 0, "weapons pickup history show time" );
CVAR_REGISTER( "hud_fastswitch", "0", CVAR_ARCHIVE, "controls whether or not weapons can be selected in one keypress" );
CVAR_REGISTER( "hud_fastswitch", "0", FCVAR_ARCHIVE, "controls whether or not weapons can be selected in one keypress" );
m_iFlags |= HUD_ACTIVE; //!!!

View File

@ -18,7 +18,7 @@
#include "extdll.h"
#include "hud_iface.h"
#include "utils.h"
#include "hud.h"
#include "hud_ammohistory.h"

View File

@ -19,7 +19,7 @@
//
#include "extdll.h"
#include "hud_iface.h"
#include "utils.h"
#include "hud.h"
DECLARE_MESSAGE( m_Battery, Battery )

View File

@ -16,7 +16,7 @@
// death notice
//
#include "extdll.h"
#include "hud_iface.h"
#include "utils.h"
#include "hud.h"
DECLARE_MESSAGE( m_DeathNotice, DeathMsg );

View File

@ -19,7 +19,7 @@
//
#include "extdll.h"
#include "hud_iface.h"
#include "utils.h"
#include "hud.h"
DECLARE_MESSAGE( m_Flash, FlashBat )

View File

@ -19,7 +19,7 @@
//
#include "extdll.h"
#include "hud_iface.h"
#include "utils.h"
#include "hud.h"
DECLARE_MESSAGE( m_Geiger, Geiger )

View File

@ -19,7 +19,7 @@
//
#include "extdll.h"
#include "hud_iface.h"
#include "utils.h"
#include "hud.h"
DECLARE_MESSAGE( m_Health, Health )

View File

@ -16,7 +16,7 @@
// status_icons.cpp
//
#include "extdll.h"
#include "hud_iface.h"
#include "utils.h"
#include "hud.h"
DECLARE_MESSAGE( m_StatusIcons, StatusIcon );

View File

@ -18,7 +18,7 @@
// generic menu handler
//
#include "extdll.h"
#include "hud_iface.h"
#include "utils.h"
#include "hud.h"
#define MAX_MENU_STRING 512

View File

@ -19,7 +19,7 @@
//
#include "extdll.h"
#include "hud_iface.h"
#include "utils.h"
#include "hud.h"
DECLARE_MESSAGE( m_Message, HudText )

View File

@ -18,7 +18,7 @@
//
#include "extdll.h"
#include "hud_iface.h"
#include "utils.h"
#include "hud.h"
DECLARE_MESSAGE( m_MOTD, MOTD );

View File

@ -16,7 +16,7 @@
// hud_msg.cpp
//
#include "extdll.h"
#include "hud_iface.h"
#include "utils.h"
#include "hud.h"
// CHud message handlers
@ -77,9 +77,9 @@ int CHud :: InitMessages( void )
CVAR_REGISTER( "zoom_sensitivity_ratio", "1.2", 0, "mouse sensitivity when zooming" );
CVAR_REGISTER( "default_fov", "90", 0, "default client fov" );
CVAR_REGISTER( "hud_draw", "1", CVAR_ARCHIVE, "hud drawing modes" );
CVAR_REGISTER( "hud_draw", "1", FCVAR_ARCHIVE, "hud drawing modes" );
CVAR_REGISTER( "hud_takesshots", "0", 0, "take screenshots at 30 fps" );
CVAR_REGISTER( "hud_scale", "0", CVAR_ARCHIVE|CVAR_LATCH, "scale hud at current resolution" );
CVAR_REGISTER( "hud_scale", "0", FCVAR_ARCHIVE|FCVAR_LATCH, "scale hud at current resolution" );
// clear any old HUD list
if( m_pHudList )

View File

@ -19,7 +19,7 @@
//
#include "extdll.h"
#include "hud_iface.h"
#include "utils.h"
#include "hud.h"
#define MAX_LINES 5

View File

@ -19,7 +19,7 @@
//
#include "extdll.h"
#include "hud_iface.h"
#include "utils.h"
#include "hud.h"
DECLARE_COMMAND( m_Scoreboard, ShowScores );

View File

@ -3,7 +3,7 @@
//=======================================================================
#include "extdll.h"
#include "hud_iface.h"
#include "utils.h"
#include "hud.h"
/*

View File

@ -20,7 +20,7 @@
//
#include "extdll.h"
#include "hud_iface.h"
#include "utils.h"
#include "hud.h"
DECLARE_MESSAGE( m_StatusBar, StatusText );
@ -37,7 +37,7 @@ int CHudStatusBar :: Init( void )
Reset();
CVAR_REGISTER( "hud_centerid", "0", CVAR_ARCHIVE, "disables center id" );
CVAR_REGISTER( "hud_centerid", "0", FCVAR_ARCHIVE, "disables center id" );
return 1;
}

View File

@ -21,7 +21,7 @@
//
#include "extdll.h"
#include "hud_iface.h"
#include "utils.h"
#include "hud.h"
DECLARE_MESSAGE( m_TextMessage, TextMsg );

View File

@ -19,7 +19,7 @@
//
#include "extdll.h"
#include "hud_iface.h"
#include "utils.h"
#include "hud.h"
DECLARE_MESSAGE( m_Train, Train )

View File

@ -5,7 +5,7 @@
//=======================================================================
#include "extdll.h"
#include "hud_iface.h"
#include "utils.h"
#include "hud.h"
#define GUIDE_S SPR_Width( m_hCrosshair, 0 )

View File

@ -5,7 +5,7 @@
#include "extdll.h"
#include "triangle_api.h"
#include "hud_iface.h"
#include "utils.h"
#include "hud.h"
void DrawQuad(float xmin, float ymin, float xmax, float ymax)

View File

@ -16,7 +16,9 @@ typedef int sound_t;
typedef int model_t;
typedef int string_t;
typedef int shader_t;
typedef struct cvar_s cvar_t;
typedef struct edict_s edict_t;
typedef struct movevars_s movevars_t;
typedef struct cl_priv_s cl_priv_t;
typedef struct sv_priv_s sv_priv_t;
typedef float vec_t;

View File

@ -67,7 +67,7 @@ typedef struct cl_enginefuncs_s
void (*pfnSetColor)( float r, float g, float b, float a );
// cvar handlers
void (*pfnRegisterVariable)( const char *szName, const char *szValue, int flags, const char *szDesc );
cvar_t* (*pfnRegisterVariable)( const char *szName, const char *szValue, int flags, const char *szDesc );
void (*pfnCvarSetString)( const char *szName, const char *szValue );
void (*pfnCvarSetValue)( const char *szName, float flValue );
float (*pfnGetCvarFloat)( const char *szName );
@ -108,6 +108,7 @@ typedef struct cl_enginefuncs_s
float (*pfnGetClientTime)( void );
int (*pfnGetMaxClients)( void );
edict_t* (*pfnGetViewModel)( void );
void* (*pfnGetModelPtr)( edict_t* pEdict );
void (*pfnMakeLevelShot)( void ); // level shot will be created at next frame
int (*pfnPointContents)( const float *rgflVector );
@ -157,7 +158,6 @@ typedef struct
void (*pfnCreateEntities)( void );
void (*pfnStudioEvent)( const dstudioevent_t *event, edict_t *entity );
void (*pfnCalcRefdef)( struct ref_params_s *parms );
} HUD_FUNCTIONS;
typedef int (*CLIENTAPI)( HUD_FUNCTIONS *pFunctionTable, cl_enginefuncs_t* pEngfuncsFromEngine );

29
common/cvardef.h Normal file
View File

@ -0,0 +1,29 @@
//=======================================================================
// Copyright XashXT Group 2008 ©
// cvardef.h - pointer to console variable
//=======================================================================
#ifndef CVARDEF_H
#define CVARDEF_H
// cvar flags
#define FCVAR_ARCHIVE BIT(0) // set to cause it to be saved to vars.rc
#define FCVAR_USERINFO BIT(1) // added to userinfo when changed
#define FCVAR_SERVERINFO BIT(2) // added to serverinfo when changed
#define FCVAR_LATCH BIT(3) // create latched cvar
/*
========================================================================
console variables
external and internal cvars struct have some differences
========================================================================
*/
struct cvar_s
{
char *name;
char *string; // normal string
float value; // com.atof( string )
int integer; // com.atoi( string )
bool modified; // set each time the cvar is changed
};
#endif//CVARDEF_H

View File

@ -33,4 +33,10 @@ enum ShakeCommand_t
#define FFADE_STAYOUT 0x0004 // ignores the duration, stays faded out until new ScreenFade message received
#define FFADE_CUSTOMVIEW 0x0008 // fading only at custom viewing (don't sending this to engine )
// camera flags
#define CAMERA_ON 1
#define DRAW_HUD 2
#define INVERSE_X 4
#define MONSTER_VIEW 8
#endif//GAME_SHARED_H

21
common/pm_movevars.h Normal file
View File

@ -0,0 +1,21 @@
//=======================================================================
// Copyright XashXT Group 2008 ©
// cvardef.h - pointer to console variable
//=======================================================================
#ifndef PM_MOVEVARS_H
#define PM_MOVEVARS_H
struct movevars_s
{
float gravity; // gravity for map
float maxvelocity; // maximum server velocity.
float rollangle; // client rollangle
float rollspeed; // cleint rollspeed
float maxspeed; // max allowed speed
float stepheight; // sv_stepheight
float accelerate; // acceleration factor
float airaccelerate; // same for when in open air
float friction; // sv_friction
};
#endif//PM_MOVEVARS_H

View File

@ -5,6 +5,15 @@
#ifndef REF_PARAMS_H
#define REF_PARAMS_H
// prev.state values to interpolate from
typedef struct latched_params_s
{
vec3_t origin;
vec3_t angles;
vec3_t viewheight;
vec3_t punchangle;
} latched_params_t;
typedef struct ref_params_s
{
// output
@ -23,32 +32,35 @@ typedef struct ref_params_s
float time; // client time
float oldtime; // studio lerping
movevars_t *movevars; // sv.movevars
latched_params_t prev;
// misc
BOOL intermission;
BOOL demoplayback;
BOOL demorecord;
BOOL spectator;
BOOL paused;
BOOL thirdperson; // thirdperson mode
BOOL predicting; // client movement predicting is running
int onlyClientDraw; // 1 - don't draw worldmodel
int nextView; // num V_RenderView passes
edict_t *onground; // pointer to onground entity
byte *areabits; // come from server, contains visible areas list
int waterlevel;
int smoothing;
// 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;
int health;
vec3_t crosshairangle; // pfnCrosshairAngle values from server
vec3_t punchangle; // recivied from server
edict_t *viewentity;
int clientnum;
int viewmodel; // viewmodel index
int num_entities;
int max_entities;
int max_clients;

View File

@ -118,7 +118,7 @@ typedef struct enginefuncs_s
void (*pfnWriteDouble)( double flValue );
void (*pfnWriteString)( const char *sz );
void (*pfnWriteEntity)( int iValue );
void (*pfnCVarRegister)( const char *name, const char *value, int flags, const char *desc );
cvar_t* (*pfnCVarRegister)( const char *name, const char *value, int flags, const char *desc );
float (*pfnCVarGetFloat)( const char *szVarName );
const char* (*pfnCVarGetString)( const char *szVarName );
void (*pfnCVarSetFloat)( const char *szVarName, float flValue );
@ -154,6 +154,13 @@ typedef struct enginefuncs_s
void (*pfnSetView)( const edict_t *pClient, const edict_t *pViewent );
void (*pfnCrosshairAngle)( const edict_t *pClient, float pitch, float yaw );
byte* (*pfnLoadFile)( const char *filename, int *pLength );
void *(*pfnFOpen)( const char* path, const char* mode );
int (*pfnFClose)( void *file );
long (*pfnFWrite)( void *file, const void* data, size_t datasize);
long (*pfnFRead)( void *file, void* buffer, size_t buffersize );
int (*pfnFGets)( void *file, byte *string, size_t bufsize );
int (*pfnFSeek)( void *file, long offset, int whence );
long (*pfnFTell)( void *file );
int (*pfnFileExists)( const char *filename );
int (*pfnCompareFileTime)( const char *filename1, const char *filename2, int *iCompare );
void (*pfnGetGameDir)( char *szGetGameDir );

View File

@ -22,6 +22,12 @@ typedef enum
TRI_LINES,
} TRI_DRAW;
typedef enum
{
TRI_SHADER = 0,
TRI_CLIP_PLANE,
} TRI_CAPS;
typedef struct triapi_s
{
size_t api_size; // must match with sizeof( triapi_t );
@ -31,6 +37,8 @@ typedef struct triapi_s
void (*Begin)( TRI_DRAW mode );
void (*End)( void );
void (*Enable)( int cap );
void (*Disable)( int cap );
void (*Vertex2f)( float x, float y );
void (*Vertex3f)( float x, float y, float z );
void (*Vertex2fv)( const float *v );

View File

@ -10,7 +10,11 @@
#include <stdlib.h>
#include <stdio.h>
#pragma warning(disable : 4244) // int or float down-conversion
#pragma warning( disable : 4244 ) // int or float down-conversion
#ifndef M_PI
#define M_PI (float)3.14159265358979323846
#endif
//=========================================================
// 2DVector - used for many pathfinding and many other
@ -152,6 +156,10 @@ public:
{
return(x*vOther.x+y*vOther.y+z*vOther.z);
}
vec_t Distance( Vector const &vOther) const
{
return sqrt((x - vOther.x) * (x - vOther.x) + (y - vOther.y) * (y - vOther.y) + (z - vOther.z) * (z - vOther.z));
}
Vector Cross(const Vector &vOther) const
{
return Vector(y*vOther.z - z*vOther.y, z*vOther.x - x*vOther.z, x*vOther.y - y*vOther.x);

View File

@ -72,5 +72,5 @@ if exist xtools\xtools.plg del /f /q xtools\xtools.plg
echo Build succeeded!
echo Please wait. Xash is now loading
cd D:\Xash3D\
quake.exe -game tmpQuArK -log -debug -dev 3 +map dm_knot
quake.exe -game tmpQuArK -log -debug -dev 3 +map qctest
:done

View File

@ -556,7 +556,7 @@ void CL_AddParticles( void )
if( !cl_particles->integer ) return;
if( EDICT_NUM( cl.frame.ps.number )->pvClientData->current.gravity != 0 )
gravity = EDICT_NUM( cl.frame.ps.number )->pvClientData->current.gravity / clgame.gravity;
gravity = EDICT_NUM( cl.frame.ps.number )->pvClientData->current.gravity / clgame.movevars.gravity;
else gravity = 1.0f;
for( p = cl_active_particles; p; p = next )
@ -783,6 +783,77 @@ bool pfnAddParticle( cparticle_t *src, HSPRITE shader, int flags )
return true;
}
/*
================
CL_TestEntities
if cl_testentities is set, create 32 player models
================
*/
void CL_TestEntities( void )
{
int i, j;
float f, r;
edict_t ent;
if( !cl_testentities->integer )
return;
Mem_Set( &ent, 0, sizeof( edict_t ));
V_ClearScene();
for( i = 0; i < 32; i++ )
{
r = 64 * ((i%4) - 1.5 );
f = 64 * (i/4) + 128;
for( j = 0; j < 3; j++ )
ent.v.origin[j] = cl.refdef.vieworg[j]+cl.refdef.forward[j] * f + cl.refdef.right[j] * r;
ent.v.scale = 1.0f;
ent.serialnumber = cl.frame.ps.number;
ent.v.controller[0] = ent.v.controller[1] = 90.0f;
ent.v.controller[2] = ent.v.controller[3] = 180.0f;
ent.v.modelindex = cl.frame.ps.modelindex;
re->AddRefEntity( &ent, ED_NORMAL, 1.0f );
}
}
/*
================
CL_TestLights
If cl_testlights is set, create 32 lights models
================
*/
void CL_TestLights( void )
{
int i, j;
float f, r;
cdlight_t dl;
if( !cl_testlights->integer )
return;
Mem_Set( &dl, 0, sizeof( cdlight_t ));
V_ClearScene();
for( i = 0; i < 32; i++ )
{
r = 64 * ( (i%4) - 1.5 );
f = 64 * (i/4) + 128;
for( j = 0; j < 3; j++ )
dl.origin[j] = cl.refdef.vieworg[j] + cl.refdef.forward[j] * f + cl.refdef.right[j] * r;
dl.color[0] = ((i%6)+1) & 1;
dl.color[1] = (((i%6)+1) & 2)>>1;
dl.color[2] = (((i%6)+1) & 4)>>2;
dl.radius = 200;
re->AddDynLight( dl.origin, dl.color, dl.radius );
}
}
/*
==============
CL_ClearEffects

View File

@ -342,126 +342,6 @@ void CL_AddPacketEntities( frame_t *frame )
}
}
/*
==============
CL_AddViewWeapon
==============
*/
void CL_AddViewWeapon( entity_state_t *ps )
{
// allow the gun to be completely removed
if( !cl_gun->value ) return;
// don't draw gun if in wide angle view
if( ps->fov > 135 ) return;
if( !ps->viewmodel ) return;
cl.viewent.serialnumber = -1;
cl.viewent.v.effects |= EF_MINLIGHT;
cl.viewent.v.modelindex = ps->viewmodel;
VectorCopy( cl.refdef.vieworg, cl.viewent.v.origin );
VectorCopy( cl.refdef.viewangles, cl.viewent.v.angles );
VectorCopy( cl.refdef.vieworg, cl.viewent.v.oldorigin );
VectorCopy( cl.refdef.viewangles, cl.viewent.v.oldangles );
re->AddRefEntity( &cl.viewent, ED_VIEWMODEL, cl.refdef.lerpfrac );
}
/*
===============
CL_CalcViewValues
Sets cl.refdef view values
===============
*/
void CL_CalcViewValues( void )
{
int i;
float lerp, backlerp;
frame_t *oldframe;
entity_state_t *ps, *ops;
edict_t *clent;
// clamp time
if( cl.time > cl.frame.servertime )
{
if( cl_showclamp->value )
Msg ("high clamp %i\n", cl.time - cl.frame.servertime);
cl.time = cl.frame.servertime;
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.refdef.lerpfrac = 0.0f;
}
else cl.refdef.lerpfrac = 1.0 - (cl.frame.servertime - cl.time) * 0.01f;
// find the previous frame to interpolate from
ps = &cl.frame.ps;
i = (cl.frame.serverframe - 1) & UPDATE_MASK;
oldframe = &cl.frames[i];
if( oldframe->serverframe != cl.frame.serverframe-1 || !oldframe->valid )
oldframe = &cl.frame; // previous frame was dropped or invalid
ops = &oldframe->ps;
clent = EDICT_NUM( cl.playernum + 1 );
// see if the player entity was teleported this frame
if( ps->ed_flags & ESF_NO_PREDICTION )
ops = ps; // don't interpolate
lerp = cl.refdef.lerpfrac;
// calculate the origin
if( cl_predict->integer && !cls.demoplayback )
{
// use predicted values
int delta;
backlerp = 1.0 - lerp;
for( i = 0; i < 3; i++ )
{
cl.refdef.vieworg[i] = cl.predicted_origin[i] + ops->viewoffset[i]
+ cl.refdef.lerpfrac * (ps->viewoffset[i] - ops->viewoffset[i]) - backlerp * cl.prediction_error[i];
}
// smooth out stair climbing
delta = cls.realtime - cl.predicted_step_time;
if( delta < Host_FrameTime()) cl.refdef.vieworg[2] -= cl.predicted_step * (Host_FrameTime() - delta) * 0.01f;
}
else
{
// just use interpolated values
for( i = 0; i < 3; i++ )
cl.refdef.vieworg[i] = LerpView( ops->origin[i], ps->origin[i], ops->viewoffset[i], ps->viewoffset[i], lerp );
}
// if not running a demo or on a locked frame, add the local angle movement
if( cls.demoplayback )
{
for (i = 0; i < 3; i++)
cl.refdef.viewangles[i] = LerpAngle( ops->viewangles[i], ps->viewangles[i], lerp );
}
else
{
// in-game use predicted values
for (i = 0; i < 3; i++) cl.refdef.viewangles[i] = cl.predicted_angles[i];
}
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.refdef.forward, cl.refdef.right, cl.refdef.up );
// interpolate field of view
cl.data.fov = ops->fov + lerp * ( ps->fov - ops->fov );
// add the weapon
CL_AddViewWeapon( ps );
}
/*
===============
CL_AddEntities
@ -474,18 +354,22 @@ void CL_AddEntities( void )
if( cls.state != ca_active )
return;
CL_CalcViewValues();
CL_AddPacketEntities( &cl.frame );
cls.dllFuncs.pfnCreateEntities();
CL_AddParticles();
CL_AddDLights();
CL_AddLightStyles();
CL_AddDecals();
// perfomance test
CL_TestEntities();
CL_TestLights();
}
//
// sound engine implementation
//
void CL_GetEntitySoundSpatialization( int entnum, vec3_t origin, vec3_t velocity )
{
edict_t *ent;

View File

@ -45,7 +45,7 @@ static trace_t CL_TraceToss( edict_t *tossent, edict_t *ignore)
VectorCopy( tossent->v.velocity, original_velocity );
VectorCopy( tossent->v.angles, original_angles );
VectorCopy( tossent->v.avelocity, original_avelocity );
gravity = tossent->v.gravity * clgame.gravity * 0.05;
gravity = tossent->v.gravity * clgame.movevars.gravity * 0.05;
for( i = 0; i < 200; i++ )
{
@ -121,6 +121,11 @@ float *CL_FadeColor( float starttime, float endtime )
void CL_DrawHUD( int state )
{
cls.dllFuncs.pfnRedraw( cl.time * 0.001f, state );
if( state == CL_ACTIVE )
{
cls.dllFuncs.pfnFrame( (double)cl.time * 0.001f );
}
}
void CL_CopyTraceResult( TraceResult *out, trace_t trace )
@ -422,18 +427,6 @@ void pfnSetColor( float r, float g, float b, float a )
re->SetColor( GetRGBA( r, g, b, a ));
}
/*
=============
pfnRegisterVariable
=============
*/
void pfnRegisterVariable( const char *szName, const char *szValue, int flags, const char *szDesc )
{
// FIXME: translate client.dll flags to real cvar flags
Cvar_Get( szName, szValue, flags, szDesc );
}
/*
=============
pfnCvarSetString
@ -838,6 +831,23 @@ edict_t* pfnGetViewModel( void )
return &cl.viewent;
}
/*
=============
pfnGetModelPtr
returns pointer to a studiomodel
=============
*/
static void *pfnGetModelPtr( edict_t* pEdict )
{
cmodel_t *mod;
mod = cl.models[pEdict->v.modelindex];
if( !mod ) return NULL;
return mod->extradata;
}
/*
=============
pfnMakeLevelShot
@ -1109,9 +1119,111 @@ static int pfnDecalIndex( int id )
return cl.decal_shaders[id];
}
/*
=================
TriApi implementation
=================
*/
void TriRenderMode( kRenderMode_t mode )
{
}
void TriBind( shader_t shader )
{
}
void TriBegin( TRI_DRAW mode )
{
}
void TriEnd( void )
{
}
void TriEnable( int cap )
{
}
void TriDisable( int cap )
{
}
void TriVertex2f( float x, float y )
{
}
void TriVertex3f( float x, float y, float z )
{
}
void TriVertex2fv( const float *v )
{
}
void TriVertex3fv( const float *v )
{
}
void TriColor3f( float r, float g, float b )
{
}
void TriColor4f( float r, float g, float b, float a )
{
}
void TriColor4ub( byte r, byte g, byte b, byte a )
{
}
void TriTexCoord2f( float u, float v )
{
}
void TriTexCoord2fv( const float *v )
{
}
void TriCullFace( TRI_CULL mode )
{
}
void TriScreenToWorld( float *screen, float *world )
{
}
int TriWorldToScreen( float *world, float *screen )
{
return 0;
}
void TriFog( float flFogColor[3], float flStart, float flEnd, int bOn )
{
}
static triapi_t gTriApi =
{
sizeof( triapi_t ),
TriRenderMode,
TriBind,
TriBegin,
TriEnd,
TriEnable,
TriDisable,
TriVertex2f,
TriVertex3f,
TriVertex2fv,
TriVertex3fv,
TriColor3f,
TriColor4f,
TriColor4ub,
TriTexCoord2f,
TriTexCoord2fv,
TriCullFace,
TriScreenToWorld,
TriWorldToScreen,
TriFog
};
static efxapi_t gEfxApi =
@ -1136,7 +1248,7 @@ static cl_enginefuncs_t gEngfuncs =
pfnFillRGBA,
pfnDrawImageExt,
pfnSetColor,
pfnRegisterVariable,
pfnCVarRegister,
pfnCvarSetString,
pfnCvarSetValue,
pfnGetCvarFloat,
@ -1166,6 +1278,7 @@ static cl_enginefuncs_t gEngfuncs =
pfnGetClientTime,
pfnGetMaxClients,
pfnGetViewModel,
pfnGetModelPtr,
pfnMakeLevelShot,
pfnPointContents,
pfnTraceLine,
@ -1256,8 +1369,15 @@ bool CL_LoadProgs( const char *name )
pfnHookUserMsg( "bad", NULL );
CL_LinkUserMessage( "bad@0", svc_bad );
clgame.gravity = com.atof( DEFAULT_GRAVITY );
clgame.maxVelocity = com.atof( DEFAULT_MAXVELOCITY );
clgame.movevars.gravity = com.atof( DEFAULT_GRAVITY );
clgame.movevars.maxvelocity = com.atof( DEFAULT_MAXVELOCITY );
clgame.movevars.rollangle = com.atof( DEFAULT_ROLLANGLE );
clgame.movevars.rollspeed = com.atof( DEFAULT_ROLLSPEED );
clgame.movevars.maxspeed = com.atof( DEFAULT_MAXSPEED );
clgame.movevars.stepheight = com.atof( DEFAULT_STEPHEIGHT );
clgame.movevars.accelerate = com.atof( DEFAULT_ACCEL );
clgame.movevars.airaccelerate = com.atof( DEFAULT_AIRACCEL );
clgame.movevars.friction = com.atof( DEFAULT_FRICTION );
for( i = 0, e = EDICT_NUM( 0 ); i < clgame.maxEntities; i++, e++ )
e->free = true; // mark all edicts as freed

View File

@ -32,7 +32,6 @@ cvar_t *cl_timeout;
cvar_t *cl_predict;
cvar_t *cl_showfps;
cvar_t *cl_maxfps;
cvar_t *cl_gun;
cvar_t *cl_add_particles;
cvar_t *cl_add_lights;
@ -1087,7 +1086,6 @@ void CL_InitLocal (void)
cl_add_lights = Cvar_Get ("cl_lights", "1", 0, "disables dynamic lights" );
cl_add_particles = Cvar_Get ("cl_particles", "1", 0, "disables particles engine" );
cl_add_entities = Cvar_Get ("cl_entities", "1", 0, "disables client entities" );
cl_gun = Cvar_Get ("cl_gun", "1", 0, "hide firstperson viewmodel" );
cl_footsteps = Cvar_Get ("cl_footsteps", "1", 0, "disables player footsteps" );
cl_predict = Cvar_Get ("cl_predict", "1", CVAR_ARCHIVE, "disables client movement prediction" );
cl_maxfps = Cvar_Get ("cl_maxfps", "1000", 0, "maximum client fps" );

View File

@ -288,6 +288,66 @@ void CL_ParseBaseline( sizebuf_t *msg )
MSG_ReadDeltaEntity( msg, &nullstate, &ent->pvClientData->baseline, newnum );
}
void CL_ParseMoveVars( int number )
{
float value;
if( number == CS_MAXVELOCITY )
{
value = com.atof( cl.configstrings[CS_MAXVELOCITY] );
if( value > 0 ) clgame.movevars.maxvelocity = value;
else clgame.movevars.maxvelocity = com.atof( DEFAULT_MAXVELOCITY );
}
else if( number == CS_GRAVITY )
{
value = com.atof( cl.configstrings[CS_GRAVITY] );
if( value > 0 ) clgame.movevars.gravity = value;
else clgame.movevars.gravity = com.atof( DEFAULT_GRAVITY );
}
else if( number == CS_ROLLSPEED )
{
value = com.atof( cl.configstrings[CS_ROLLSPEED] );
if( value > 0 ) clgame.movevars.rollspeed = value;
else clgame.movevars.rollspeed = com.atof( DEFAULT_ROLLSPEED );
}
else if( number == CS_ROLLANGLE )
{
value = com.atof( cl.configstrings[CS_ROLLANGLE] );
if( value > 0 ) clgame.movevars.rollangle = value;
else clgame.movevars.rollangle = com.atof( DEFAULT_ROLLANGLE );
}
else if( number == CS_MAXSPEED )
{
value = com.atof( cl.configstrings[CS_MAXSPEED] );
if( value > 0 ) clgame.movevars.maxspeed = value;
else clgame.movevars.maxspeed = com.atof( DEFAULT_MAXSPEED );
}
else if( number == CS_STEPHEIGHT )
{
value = com.atof( cl.configstrings[CS_STEPHEIGHT] );
if( value > 0 ) clgame.movevars.stepheight = value;
else clgame.movevars.stepheight = com.atof( DEFAULT_STEPHEIGHT );
}
else if( number == CS_AIRACCELERATE )
{
value = com.atof( cl.configstrings[CS_AIRACCELERATE] );
if( value > 0 ) clgame.movevars.airaccelerate = value;
else clgame.movevars.airaccelerate = com.atof( DEFAULT_AIRACCEL );
}
else if( number == CS_ACCELERATE )
{
value = com.atof( cl.configstrings[CS_ACCELERATE] );
if( value > 0 ) clgame.movevars.accelerate = value;
else clgame.movevars.accelerate = com.atof( DEFAULT_ACCEL );
}
else if( number == CS_FRICTION )
{
value = com.atof( cl.configstrings[CS_FRICTION] );
if( value > 0 ) clgame.movevars.friction = value;
else clgame.movevars.friction = com.atof( DEFAULT_FRICTION );
}
}
/*
================
CL_ParseConfigString
@ -296,7 +356,6 @@ CL_ParseConfigString
void CL_ParseConfigString( sizebuf_t *msg )
{
int i;
float value;
i = MSG_ReadShort( msg );
if( i < 0 || i >= MAX_CONFIGSTRINGS )
@ -308,17 +367,9 @@ void CL_ParseConfigString( sizebuf_t *msg )
{
re->RegisterShader( cl.configstrings[CS_SKYNAME], SHADER_SKY );
}
else if( i == CS_MAXVELOCITY )
else if( i > CS_BACKGROUND_TRACK && i < CS_MODELS )
{
value = com.atof( cl.configstrings[CS_MAXVELOCITY] );
if( value > 0 ) clgame.maxVelocity = value;
else clgame.maxVelocity = com.atof( DEFAULT_MAXVELOCITY );
}
else if( i == CS_GRAVITY )
{
value = com.atof( cl.configstrings[CS_GRAVITY] );
if( value > 0 ) clgame.gravity = value;
else clgame.gravity = com.atof( DEFAULT_GRAVITY );
CL_ParseMoveVars( i );
}
else if( i == CS_BACKGROUND_TRACK && cl.audio_prepped )
{

View File

@ -212,9 +212,9 @@ void CL_CheckVelocity( edict_t *ent )
// LordHavoc: max velocity fix, inspired by Maddes's source fixes, but this is faster
wishspeed = DotProduct( ent->v.velocity, ent->v.velocity );
if( wishspeed > ( clgame.maxVelocity * clgame.maxVelocity ))
if( wishspeed > ( clgame.movevars.maxvelocity * clgame.movevars.maxvelocity ))
{
wishspeed = clgame.maxVelocity / com.sqrt( wishspeed );
wishspeed = clgame.movevars.maxvelocity / com.sqrt( wishspeed );
ent->v.velocity[0] *= wishspeed;
ent->v.velocity[1] *= wishspeed;
ent->v.velocity[2] *= wishspeed;

View File

@ -6,8 +6,6 @@
#include "common.h"
#include "client.h"
int scr_rect[4]; // position of render window on screen
cvar_t *scr_viewsize;
cvar_t *scr_centertime;
cvar_t *scr_showpause;
@ -302,7 +300,7 @@ 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_DrawPic( cl.refdef.viewport[0] + 64, cl.refdef.viewport[1], 48, 48, cls.netIcon );
}
/*
@ -371,7 +369,6 @@ void SCR_UpdateScreen( void )
CL_DrawHUD( CL_LOADING );
break;
case ca_active:
V_CalcRect();
V_RenderView();
CL_DrawHUD( CL_ACTIVE );
CL_DrawDemoRecording();

View File

@ -35,87 +35,6 @@ void V_ClearScene( void )
re->ClearScene();
}
/*
=================
void V_CalcRect( void )
Sets scr_vrect, the coordinates of the rendered window
=================
*/
void V_CalcRect( void )
{
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;
}
/*
================
V_TestEntities
If cl_testentities is set, create 32 player models
================
*/
void V_TestEntities( void )
{
int i, j;
float f, r;
edict_t ent;
Mem_Set( &ent, 0, sizeof( edict_t ));
V_ClearScene();
for( i = 0; i < 32; i++ )
{
r = 64 * ((i%4) - 1.5 );
f = 64 * (i/4) + 128;
for( j = 0; j < 3; j++ )
ent.v.origin[j] = cl.refdef.vieworg[j]+cl.refdef.forward[j] * f + cl.refdef.right[j] * r;
ent.v.scale = 1.0f;
ent.serialnumber = cl.frame.ps.number;
ent.v.controller[0] = ent.v.controller[1] = 90.0f;
ent.v.controller[2] = ent.v.controller[3] = 180.0f;
ent.v.modelindex = cl.frame.ps.modelindex;
re->AddRefEntity( &ent, ED_NORMAL, 1.0f );
}
}
/*
================
V_TestLights
If cl_testlights is set, create 32 lights models
================
*/
void V_TestLights( void )
{
int i, j;
float f, r;
cdlight_t dl;
Mem_Set( &dl, 0, sizeof( cdlight_t ));
V_ClearScene();
for( i = 0; i < 32; i++ )
{
r = 64 * ( (i%4) - 1.5 );
f = 64 * (i/4) + 128;
for( j = 0; j < 3; j++ )
dl.origin[j] = cl.refdef.vieworg[j] + cl.refdef.forward[j] * f + cl.refdef.right[j] * r;
dl.color[0] = ((i%6)+1) & 1;
dl.color[1] = (((i%6)+1) & 2)>>1;
dl.color[2] = (((i%6)+1) & 4)>>2;
dl.radius = 200;
re->AddDynLight( dl.origin, dl.color, dl.radius );
}
}
/*
====================
V_CalcFov
@ -137,6 +56,145 @@ float V_CalcFov( float fov_x, float width, float height )
return fov_y;
}
/*
===============
V_SetupRefDef
update refdef values each frame
===============
*/
void V_SetupRefDef( void )
{
int i;
float lerp, backlerp;
frame_t *oldframe;
entity_state_t *ps, *ops;
// find the previous frame to interpolate from
ps = &cl.frame.ps;
i = (cl.frame.serverframe - 1) & UPDATE_MASK;
oldframe = &cl.frames[i];
if( oldframe->serverframe != cl.frame.serverframe-1 || !oldframe->valid )
oldframe = &cl.frame; // previous frame was dropped or invalid
ops = &oldframe->ps;
// see if the player entity was teleported this frame
if( ps->ed_flags & ESF_NO_PREDICTION )
ops = ps; // don't interpolate
lerp = cl.refdef.lerpfrac;
if( cl.time > cl.frame.servertime )
{
if( cl_showclamp->integer )
MsgDev( D_NOTE, "cl_highclamp %i\n", cl.time - cl.frame.servertime );
cl.time = cl.frame.servertime;
cl.refdef.lerpfrac = 1.0f;
}
else if( cl.time < cl.frame.servertime - Host_FrameTime())
{
if( cl_showclamp->integer )
MsgDev( D_NOTE, "cl_lowclamp %i\n", cl.frame.servertime - Host_FrameTime() - cl.time );
cl.time = cl.frame.servertime - Host_FrameTime();
cl.refdef.lerpfrac = 0.0f;
}
else cl.refdef.lerpfrac = 1.0 - (cl.frame.servertime - cl.time) * 0.01f;
// interpolate field of view
cl.data.fov = ops->fov + cl.refdef.lerpfrac * ( ps->fov - ops->fov );
VectorCopy( ps->velocity, cl.refdef.velocity );
VectorCopy( ps->origin, cl.refdef.origin );
VectorCopy( ops->origin, cl.refdef.prev.origin );
VectorCopy( ps->angles, cl.refdef.angles );
VectorCopy( ops->angles, cl.refdef.prev.angles );
VectorCopy( ps->viewoffset, cl.refdef.viewheight );
VectorCopy( ops->viewoffset, cl.refdef.prev.viewheight );
VectorCopy( ps->punch_angles, cl.refdef.punchangle );
VectorCopy( ops->punch_angles, cl.refdef.prev.punchangle );
cl.refdef.movevars = &clgame.movevars;
if( ps->flags & FL_ONGROUND )
cl.refdef.onground = EDICT_NUM( ps->groundent );
else cl.refdef.onground = NULL;
cl.refdef.clientnum = cl.playernum; // not a entity num
cl.refdef.viewmodel = ps->viewmodel;
cl.refdef.health = ps->health;
cl.refdef.num_entities = clgame.numEntities;
cl.refdef.max_entities = clgame.maxEntities;
cl.refdef.max_clients = clgame.maxClients;
cl.refdef.oldtime = (cl.oldtime * 0.001f);
cl.refdef.time = (cl.time * 0.001f); // cl.time for right lerping
cl.refdef.frametime = cls.frametime;
cl.refdef.demoplayback = cls.demoplayback;
cl.refdef.demorecord = cls.demorecording;
cl.refdef.paused = cl_paused->integer;
cl.refdef.predicting = cl_predict->integer;
// invalid values
cl.refdef.waterlevel = 0; // FIXME: calc it again
cl.refdef.smoothing = 0; // FIXME: detect right settings
cl.refdef.viewentity = NULL; // remove ???
VectorClear( cl.refdef.crosshairangle );
// calculate the origin
if( cl.refdef.predicting && !cl.refdef.demoplayback )
{
// use predicted values
int delta;
backlerp = 1.0 - lerp;
for( i = 0; i < 3; i++ )
{
cl.refdef.vieworg[i] = cl.predicted_origin[i] + ops->viewoffset[i]
+ cl.refdef.lerpfrac * (ps->viewoffset[i] - ops->viewoffset[i]) - backlerp * cl.prediction_error[i];
}
// smooth out stair climbing
delta = cls.realtime - cl.predicted_step_time;
if( delta < Host_FrameTime()) cl.refdef.vieworg[2] -= cl.predicted_step * (Host_FrameTime() - delta) * 0.01f;
// in-game use predicted values
for( i = 0; i < 3; i++ ) cl.refdef.viewangles[i] = cl.predicted_angles[i];
}
}
/*
===============
V_ApplyRefDef
apply pre-calculated values
===============
*/
void V_ApplyRefDef( void )
{
cl.refdef.areabits = cl.frame.areabits;
cl.refdef.fov_y = V_CalcFov( cl.refdef.fov_x, cl.refdef.viewport[2], cl.refdef.viewport[3] );
if( cl.frame.ps.renderfx == kRenderFxUnderwater )
{
float f = com.sin( cl.time * 0.001 * 0.4 * (M_PI * 2.7));
cl.refdef.fov_x += f;
cl.refdef.fov_y -= f;
}
if( cl.viewent.v.modelindex )
{
re->AddRefEntity( &cl.viewent, ED_VIEWMODEL, cl.refdef.lerpfrac );
}
}
/*
===============
V_CalcRefDef
sets cl.refdef view values
===============
*/
void V_CalcRefDef( void )
{
cls.dllFuncs.pfnCalcRefdef( &cl.refdef );
}
//============================================================================
/*
@ -151,7 +209,7 @@ void V_RenderView( void )
// an invalid frame will just use the exact previous refdef
// we can't use the old frame if the video mode has changed, though...
if ( cl.frame.valid && (cl.force_refdef || !cl_paused->value) )
if( cl.frame.valid && (cl.force_refdef || !cl_paused->value ))
{
cl.force_refdef = false;
V_ClearScene();
@ -161,30 +219,9 @@ void V_RenderView( void )
// refdef.forward, etc.
CL_AddEntities ();
if( cl_testentities->value ) V_TestEntities();
if( cl_testlights->value ) V_TestLights();
// never let it sit exactly on a node line, because a water plane can
// dissapear when viewed with the eye exactly on it.
// the server protocol only specifies to 1/16 pixel, so add 1/32 in each axis
cl.refdef.vieworg[0] += 1.0 / 32;
cl.refdef.vieworg[1] += 1.0 / 32;
cl.refdef.vieworg[2] += 1.0 / 32;
Mem_Copy( &cl.refdef.viewport, &scr_rect, sizeof( cl.refdef.viewport ));
cl.refdef.areabits = cl.frame.areabits;
cl.refdef.fov_y = V_CalcFov( cl.refdef.fov_x, cl.refdef.viewport[2], cl.refdef.viewport[3] );
cl.refdef.oldtime = (cl.oldtime * 0.001f);
cl.refdef.time = (cl.time * 0.001f); // cl.time for right lerping
cl.refdef.frametime = cls.frametime;
if( cl.frame.ps.renderfx == kRenderFxUnderwater )
{
float f = com.sin( cl.time * 0.001 * 0.4 * (M_PI * 2.7));
cl.refdef.fov_x += f;
cl.refdef.fov_y -= f;
}
V_SetupRefDef ();
V_CalcRefDef ();
V_ApplyRefDef ();
}
re->RenderFrame( &cl.refdef );
}

View File

@ -26,6 +26,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "entity_def.h"
#include "clgame_api.h"
#include "render_api.h"
#include "pm_movevars.h"
#define MAX_EDIT_LINE 256
#define COMMAND_HISTORY 32
@ -211,10 +212,8 @@ typedef struct
int numMessages; // actual count of user messages
int hStringTable; // stringtable handle
// sae values from server cvars
float maxVelocity;
float gravity;
// movement values from server
movevars_t movevars;
} clgame_static_t;
typedef struct
@ -284,13 +283,11 @@ SCREEN CONSTS
==============================================================
*/
extern int scr_rect[4]; // position of render window
extern vec4_t g_color_table[8];
//
// cvars
//
extern cvar_t *cl_gun;
extern cvar_t *cl_add_lights;
extern cvar_t *cl_add_particles;
extern cvar_t *cl_add_entities;
@ -551,14 +548,11 @@ void SCR_DrawNet( void );
//
void V_Init (void);
void V_CalcRect( void );
void V_Shutdown( void );
void V_ClearScene( void );
bool V_PreRender( void );
void V_RenderHUD( void );
void V_PostRender( void );
void V_RenderView( void );
void V_RenderLogo( void );
void V_RenderSplash( void );
float V_CalcFov( float fov_x, float width, float height );
//
@ -586,6 +580,8 @@ cdlight_t *CL_AllocDlight( int key );
void CL_AddParticles( void );
void CL_AddDecals( void );
void CL_ClearEffects( void );
void CL_TestLights( void );
void CL_TestEntities( void );
void CL_StudioEvent( dstudioevent_t *event, edict_t *ent );
void CL_AddDecal( vec3_t org, matrix3x3 m, shader_t s, vec4_t rgba, bool fade, decalFragment_t *df, const vec3_t *v );
edict_t *CL_GetEdictByIndex( int index );

View File

@ -32,6 +32,13 @@ extern vsound_exp_t *se;
// some engine shared constants
#define DEFAULT_MAXVELOCITY "2000"
#define DEFAULT_GRAVITY "800"
#define DEFAULT_ROLLSPEED "200"
#define DEFAULT_ROLLANGLE "2"
#define DEFAULT_STEPHEIGHT "18"
#define DEFAULT_AIRACCEL "0"
#define DEFAULT_MAXSPEED "320"
#define DEFAULT_ACCEL "10"
#define DEFAULT_FRICTION "4"
// all drawing is done to a 640*480 virtual screen size
// and will be automatically scaled to the real resolution
@ -153,11 +160,19 @@ PRVM INTERACTIONS
==============================================================
*/
void pfnMemCopy( void *dest, const void *src, size_t cb, const char *filename, const int fileline );
cvar_t *pfnCVarRegister( const char *szName, const char *szValue, int flags, const char *szDesc );
byte* pfnLoadFile( const char *filename, int *pLength );
int pfnFileExists( const char *filename );
long pfnRandomLong( long lLow, long lHigh );
float pfnRandomFloat( float flLow, float flHigh );
void pfnAlertMessage( ALERT_TYPE level, char *szFmt, ... );
void *pfnFOpen( const char* path, const char* mode );
long pfnFWrite( void *file, const void* data, size_t datasize );
long pfnFRead( void *file, void* buffer, size_t buffersize );
int pfnFGets( void *file, byte *string, size_t bufsize );
int pfnFSeek( void *file, long offset, int whence );
int pfnFClose( void *file );
long pfnFTell( void *file );
void pfnGetGameDir( char *szGetGameDir );
#define prog vm->prog // global callback to vprogs.dll

View File

@ -8,6 +8,7 @@
#include "mathlib.h"
#include "const.h"
#include "client.h"
#include "cvardef.h"
/*
=============
@ -53,6 +54,24 @@ float pfnRandomFloat( float flLow, float flHigh )
return Com_RandomFloat( flLow, flHigh );
}
/*
=============
pfnCVarRegister
=============
*/
cvar_t *pfnCVarRegister( const char *szName, const char *szValue, int flags, const char *szDesc )
{
int real_flags = 0;
if( flags & FCVAR_ARCHIVE ) real_flags |= CVAR_ARCHIVE;
if( flags & FCVAR_USERINFO ) real_flags |= CVAR_USERINFO;
if( flags & FCVAR_SERVERINFO ) real_flags |= CVAR_SERVERINFO;
if( flags & FCVAR_LATCH ) real_flags |= CVAR_LATCH;
return Cvar_Get( szName, szValue, real_flags, szDesc );
}
/*
=============
pfnAlertMessage
@ -103,6 +122,83 @@ void pfnMemCopy( void *dest, const void *src, size_t cb, const char *filename, c
com.memcpy( dest, src, cb, filename, fileline );
}
/*
=============
pfnFOpen
=============
*/
void *pfnFOpen( const char* path, const char* mode )
{
return FS_Open( path, mode );
}
/*
=============
pfnFClose
=============
*/
int pfnFClose( void *file )
{
return FS_Close( file );
}
/*
=============
pfnFWrite
=============
*/
long pfnFWrite( void *file, const void* data, size_t datasize )
{
return FS_Write( file, data, datasize );
}
/*
=============
pfnFRead
=============
*/
long pfnFRead( void *file, void* buffer, size_t buffersize )
{
return FS_Read( file, buffer, buffersize );
}
/*
=============
pfnFGets
=============
*/
int pfnFGets( void *file, byte *string, size_t bufsize )
{
return FS_Gets( file, string, bufsize );
}
/*
=============
pfnFSeek
=============
*/
int pfnFSeek( void *file, long offset, int whence )
{
return FS_Seek( file, offset, whence );
}
/*
=============
pfnFTell
=============
*/
long pfnFTell( void *file )
{
return FS_Tell( file );
}
/*
=============
pfnGetGameDir

View File

@ -1,457 +1,295 @@
//=======================================================================
// Copyright XashXT Group 2008 ©
// com_library.c - custom dlls loader
// Copyright XashXT Group 2007 ©
// net_msg.h - message io functions
//=======================================================================
#ifndef NET_MSG_H
#define NET_MSG_H
#include "common.h"
#include "com_library.h"
typedef struct
enum net_types_e
{
PIMAGE_NT_HEADERS headers;
byte *codeBase;
HMODULE *modules;
int numModules;
int initialized;
} MEMORYMODULE, *PMEMORYMODULE;
typedef BOOL (WINAPI *DllEntryProc)( HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpReserved );
#define GET_HEADER_DICTIONARY( module, idx ) &(module)->headers->OptionalHeader.DataDirectory[idx]
#define CALCULATE_ADDRESS( base, offset ) (((DWORD)(base)) + (offset))
static void CopySections( const byte *data, PIMAGE_NT_HEADERS old_headers, PMEMORYMODULE module )
{
int i, size;
byte *dest;
byte *codeBase = module->codeBase;
PIMAGE_SECTION_HEADER section = IMAGE_FIRST_SECTION(module->headers);
for( i = 0; i < module->headers->FileHeader.NumberOfSections; i++, section++ )
{
if( section->SizeOfRawData == 0 )
{
// section doesn't contain data in the dll itself, but may define
// uninitialized data
size = old_headers->OptionalHeader.SectionAlignment;
if( size > 0 )
{
dest = (byte *)VirtualAlloc((byte *)CALCULATE_ADDRESS(codeBase, section->VirtualAddress), size, MEM_COMMIT, PAGE_READWRITE );
section->Misc.PhysicalAddress = (DWORD)dest;
Mem_Set( dest, 0, size );
}
// section is empty
continue;
}
// commit memory block and copy data from dll
dest = (byte *)VirtualAlloc((byte *)CALCULATE_ADDRESS(codeBase, section->VirtualAddress), section->SizeOfRawData, MEM_COMMIT, PAGE_READWRITE );
Mem_Copy( dest, (byte *)CALCULATE_ADDRESS(data, section->PointerToRawData), section->SizeOfRawData );
section->Misc.PhysicalAddress = (DWORD)dest;
}
}
static void FreeSections( PIMAGE_NT_HEADERS old_headers, PMEMORYMODULE module )
{
int i, size;
byte *codeBase = module->codeBase;
PIMAGE_SECTION_HEADER section = IMAGE_FIRST_SECTION(module->headers);
for( i = 0; i < module->headers->FileHeader.NumberOfSections; i++, section++ )
{
if( section->SizeOfRawData == 0 )
{
size = old_headers->OptionalHeader.SectionAlignment;
if( size > 0 )
{
VirtualFree( codeBase + section->VirtualAddress, size, MEM_DECOMMIT );
section->Misc.PhysicalAddress = 0;
}
continue;
}
VirtualFree( codeBase + section->VirtualAddress, section->SizeOfRawData, MEM_DECOMMIT );
section->Misc.PhysicalAddress = 0;
}
}
// Protection flags for memory pages (Executable, Readable, Writeable)
static int ProtectionFlags[2][2][2] =
{
{
{ PAGE_NOACCESS, PAGE_WRITECOPY }, // not executable
{ PAGE_READONLY, PAGE_READWRITE },
},
{
{ PAGE_EXECUTE, PAGE_EXECUTE_WRITECOPY }, // executable
{ PAGE_EXECUTE_READ, PAGE_EXECUTE_READWRITE },
},
NET_BAD = 0,
NET_CHAR,
NET_BYTE,
NET_SHORT,
NET_WORD,
NET_LONG,
NET_FLOAT,
NET_ANGLE,
NET_SCALE,
NET_COORD,
NET_COLOR,
NET_INT64,
NET_DOUBLE,
NET_TYPES,
};
static void FinalizeSections( MEMORYMODULE *module )
typedef struct net_desc_s
{
PIMAGE_SECTION_HEADER section = IMAGE_FIRST_SECTION( module->headers );
int i;
// loop through all sections and change access flags
for( i = 0; i < module->headers->FileHeader.NumberOfSections; i++, section++ )
{
DWORD protect, oldProtect, size;
int executable = (section->Characteristics & IMAGE_SCN_MEM_EXECUTE) != 0;
int readable = (section->Characteristics & IMAGE_SCN_MEM_READ) != 0;
int writeable = (section->Characteristics & IMAGE_SCN_MEM_WRITE) != 0;
int type; // pixelformat
char name[8]; // used for debug
int min_range;
int max_range;
} net_desc_t;
if( section->Characteristics & IMAGE_SCN_MEM_DISCARDABLE )
{
// section is not needed any more and can safely be freed
VirtualFree((LPVOID)section->Misc.PhysicalAddress, section->SizeOfRawData, MEM_DECOMMIT);
continue;
}
// determine protection flags based on characteristics
protect = ProtectionFlags[executable][readable][writeable];
if( section->Characteristics & IMAGE_SCN_MEM_NOT_CACHED )
protect |= PAGE_NOCACHE;
// determine size of region
size = section->SizeOfRawData;
if( size == 0 )
{
if( section->Characteristics & IMAGE_SCN_CNT_INITIALIZED_DATA )
size = module->headers->OptionalHeader.SizeOfInitializedData;
else if( section->Characteristics & IMAGE_SCN_CNT_UNINITIALIZED_DATA )
size = module->headers->OptionalHeader.SizeOfUninitializedData;
}
if( size > 0 )
{
// change memory access flags
if( !VirtualProtect((LPVOID)section->Misc.PhysicalAddress, size, protect, &oldProtect ))
Host_Error( "Com_FinalizeSections: error protecting memory page\n" );
}
}
}
static void PerformBaseRelocation( MEMORYMODULE *module, DWORD delta )
// communication state description
typedef struct net_field_s
{
DWORD i;
byte *codeBase = module->codeBase;
PIMAGE_DATA_DIRECTORY directory = GET_HEADER_DICTIONARY( module, IMAGE_DIRECTORY_ENTRY_BASERELOC );
char *name;
int offset;
int bits;
bool force; // will be send for newentity
} net_field_t;
if( directory->Size > 0 )
{
PIMAGE_BASE_RELOCATION relocation = (PIMAGE_BASE_RELOCATION)CALCULATE_ADDRESS( codeBase, directory->VirtualAddress );
for( ; relocation->VirtualAddress > 0; )
{
byte *dest = (byte *)CALCULATE_ADDRESS( codeBase, relocation->VirtualAddress );
word *relInfo = (word *)((byte *)relocation + IMAGE_SIZEOF_BASE_RELOCATION );
for( i = 0; i<((relocation->SizeOfBlock-IMAGE_SIZEOF_BASE_RELOCATION) / 2); i++, relInfo++ )
{
DWORD *patchAddrHL;
int type, offset;
// the upper 4 bits define the type of relocation
type = *relInfo >> 12;
// the lower 12 bits define the offset
offset = *relInfo & 0xfff;
switch( type )
{
case IMAGE_REL_BASED_ABSOLUTE:
// skip relocation
break;
case IMAGE_REL_BASED_HIGHLOW:
// change complete 32 bit address
patchAddrHL = (DWORD *)CALCULATE_ADDRESS( dest, offset );
*patchAddrHL += delta;
break;
default:
MsgDev( D_ERROR, "PerformBaseRelocation: unknown relocation: %d\n", type );
break;
}
}
// advance to next relocation block
relocation = (PIMAGE_BASE_RELOCATION)CALCULATE_ADDRESS( relocation, relocation->SizeOfBlock );
}
}
}
static int BuildImportTable( MEMORYMODULE *module )
// server to client
enum svc_ops_e
{
int result=1;
byte *codeBase = module->codeBase;
PIMAGE_DATA_DIRECTORY directory = GET_HEADER_DICTIONARY( module, IMAGE_DIRECTORY_ENTRY_IMPORT );
// user messages
svc_bad = 0, // don't send!
if( directory->Size > 0 )
{
PIMAGE_IMPORT_DESCRIPTOR importDesc = (PIMAGE_IMPORT_DESCRIPTOR)CALCULATE_ADDRESS( codeBase, directory->VirtualAddress );
// engine messages
svc_nop = 201, // end of user messages
svc_disconnect, // kick client from server
svc_reconnect, // reconnecting server request
svc_stufftext, // [string] stuffed into client's console buffer, should be \n terminated
svc_serverdata, // [long] protocol ...
svc_configstring, // [short] [string]
svc_spawnbaseline, // valid only at spawn
svc_download, // [short] size [size bytes]
svc_playerinfo, // [...]
svc_packetentities, // [...]
svc_deltapacketentities, // [...]
svc_frame, // server frame
svc_sound, // <see code>
svc_setangle, // [short short short] set the view angle to this absolute value
svc_print, // [byte] id [string] null terminated string
};
for( ; !IsBadReadPtr( importDesc, sizeof( IMAGE_IMPORT_DESCRIPTOR )) && importDesc->Name; importDesc++ )
{
DWORD *thunkRef, *funcRef;
HMODULE handle = LoadLibrary((LPCSTR)CALCULATE_ADDRESS(codeBase, importDesc->Name));
// FIXME: allow to loading libraries from memory
if( handle == INVALID_HANDLE_VALUE )
{
MsgDev( D_ERROR, "couldn't load library\n" );
result = 0;
break;
}
module->modules = (HMODULE *)Z_Realloc( module->modules, (module->numModules + 1) * (sizeof( HMODULE )));
if( module->modules == NULL )
{
result = 0;
break;
}
module->modules[module->numModules++] = handle;
if( importDesc->OriginalFirstThunk )
{
thunkRef = (DWORD *)CALCULATE_ADDRESS( codeBase, importDesc->OriginalFirstThunk );
funcRef = (DWORD *)CALCULATE_ADDRESS( codeBase, importDesc->FirstThunk );
}
else
{
// no hint table
thunkRef = (DWORD *)CALCULATE_ADDRESS( codeBase, importDesc->FirstThunk );
funcRef = (DWORD *)CALCULATE_ADDRESS( codeBase, importDesc->FirstThunk );
}
for( ; *thunkRef; thunkRef++, funcRef++ )
{
if IMAGE_SNAP_BY_ORDINAL( *thunkRef )
*funcRef = (DWORD)GetProcAddress( handle, (LPCSTR)IMAGE_ORDINAL( *thunkRef ));
else
{
PIMAGE_IMPORT_BY_NAME thunkData = (PIMAGE_IMPORT_BY_NAME)CALCULATE_ADDRESS( codeBase, *thunkRef );
*funcRef = (DWORD)GetProcAddress( handle, (LPCSTR)&thunkData->Name );
}
if( *funcRef == 0 )
{
result = 0;
break;
}
}
if( !result ) break;
}
}
return result;
}
void *Com_LoadLibraryExt( const char *name, bool system )
// client to server
enum clc_ops_e
{
MEMORYMODULE *result;
PIMAGE_DOS_HEADER dos_header;
PIMAGE_NT_HEADERS old_header;
byte *code, *headers;
DWORD locationDelta;
DllEntryProc DllEntry;
BOOL successfull;
void *data;
clc_bad = 0,
if( system ) FS_AllowDirectPaths( true );
data = FS_LoadFile( name, NULL );
if( system ) FS_AllowDirectPaths( false );
if( !data ) return NULL;
// engine messages
clc_nop = 201,
clc_move, // [[usercmd_t]
clc_userinfo, // [[userinfo string]
clc_stringcmd, // [string] message
};
dos_header = (PIMAGE_DOS_HEADER)data;
if( dos_header->e_magic != IMAGE_DOS_SIGNATURE )
{
MsgDev( D_NOTE, "%s it's not a valid executable file\n", name );
Mem_Free( data );
return NULL;
}
old_header = (PIMAGE_NT_HEADERS)&((const byte *)(data))[dos_header->e_lfanew];
if( old_header->Signature != IMAGE_NT_SIGNATURE )
{
MsgDev( D_NOTE, "library %s: no PE header found\n", name );
Mem_Free( data );
return NULL;
}
// reserve memory for image of library
code = (byte *)VirtualAlloc((LPVOID)(old_header->OptionalHeader.ImageBase), old_header->OptionalHeader.SizeOfImage, MEM_RESERVE, PAGE_READWRITE );
if( code == NULL )
{
// try to allocate memory at arbitrary position
code = (byte *)VirtualAlloc( NULL, old_header->OptionalHeader.SizeOfImage, MEM_RESERVE, PAGE_READWRITE );
}
if( code == NULL )
{
MsgDev( D_NOTE, "library %s: can't reserve memory\n", name );
Mem_Free( data );
return NULL;
}
result = (MEMORYMODULE *)HeapAlloc( GetProcessHeap(), 0, sizeof( MEMORYMODULE ));
result->codeBase = code;
result->numModules = 0;
result->modules = NULL;
result->initialized = 0;
// XXX: is it correct to commit the complete memory region at once?
// calling DllEntry raises an exception if we don't...
VirtualAlloc( code, old_header->OptionalHeader.SizeOfImage, MEM_COMMIT, PAGE_READWRITE );
// commit memory for headers
headers = (byte *)VirtualAlloc( code, old_header->OptionalHeader.SizeOfHeaders, MEM_COMMIT, PAGE_READWRITE );
// copy PE header to code
Mem_Copy( headers, dos_header, dos_header->e_lfanew + old_header->OptionalHeader.SizeOfHeaders );
result->headers = (PIMAGE_NT_HEADERS)&((const byte *)(headers))[dos_header->e_lfanew];
// update position
result->headers->OptionalHeader.ImageBase = (DWORD)code;
// copy sections from DLL file block to new memory location
CopySections( data, old_header, result );
// adjust base address of imported data
locationDelta = (DWORD)(code - old_header->OptionalHeader.ImageBase);
if( locationDelta != 0 ) PerformBaseRelocation( result, locationDelta );
// load required dlls and adjust function table of imports
if( !BuildImportTable( result )) goto error;
// mark memory pages depending on section headers and release
// sections that are marked as "discardable"
FinalizeSections( result );
// get entry point of loaded library
if( result->headers->OptionalHeader.AddressOfEntryPoint != 0 )
{
DllEntry = (DllEntryProc)CALCULATE_ADDRESS( code, result->headers->OptionalHeader.AddressOfEntryPoint );
if( DllEntry == 0 )
{
MsgDev( D_NOTE, "library %s: has no entry point\n", name );
goto error;
}
// notify library about attaching to process
successfull = (*DllEntry)((HINSTANCE)code, DLL_PROCESS_ATTACH, 0 );
if( !successfull )
{
MsgDev( D_ERROR, "can't attach library %s\n", name );
goto error;
}
result->initialized = 1;
}
Mem_Free( data ); // release memory
return (void *)result;
error:
// cleanup
Mem_Free( data );
Com_FreeLibrary( result );
return NULL;
}
FARPROC Com_GetProcAddress( void *module, const char *name )
typedef enum
{
int idx = -1;
DWORD i, *nameRef;
WORD *ordinal;
PIMAGE_EXPORT_DIRECTORY exports;
byte *codeBase = ((PMEMORYMODULE)module)->codeBase;
PIMAGE_DATA_DIRECTORY directory = GET_HEADER_DICTIONARY((MEMORYMODULE *)module, IMAGE_DIRECTORY_ENTRY_EXPORT );
MSG_ONE = 0, // never send by QC-code (just not declared)
MSG_ALL,
MSG_PHS,
MSG_PVS,
MSG_ONE_R, // reliable messages
MSG_ALL_R,
MSG_PHS_R,
MSG_PVS_R,
} msgtype_t;
if( directory->Size == 0 )
{
// no export table found
return NULL;
}
exports = (PIMAGE_EXPORT_DIRECTORY)CALCULATE_ADDRESS( codeBase, directory->VirtualAddress );
if( exports->NumberOfNames == 0 || exports->NumberOfFunctions == 0 )
{
// DLL doesn't export anything
return NULL;
}
// search function name in list of exported names
nameRef = (DWORD *)CALCULATE_ADDRESS( codeBase, exports->AddressOfNames );
ordinal = (WORD *)CALCULATE_ADDRESS( codeBase, exports->AddressOfNameOrdinals );
for( i = 0; i < exports->NumberOfNames; i++, nameRef++, ordinal++ )
{
// GetProcAddress case insensative ?????
if( !com.stricmp( name, (const char *)CALCULATE_ADDRESS( codeBase, *nameRef )))
{
idx = *ordinal;
break;
}
}
if( idx == -1 )
{
// exported symbol not found
return NULL;
}
if((DWORD)idx > exports->NumberOfFunctions )
{
// name <-> ordinal number don't match
return NULL;
}
// addressOfFunctions contains the RVAs to the "real" functions
return (FARPROC)CALCULATE_ADDRESS( codeBase, *(DWORD *)CALCULATE_ADDRESS( codeBase, exports->AddressOfFunctions + (idx * 4)));
}
void Com_FreeLibrary( void *hInstance )
static const net_desc_t NWDesc[] =
{
MEMORYMODULE *module = (MEMORYMODULE *)hInstance;
int i;
{ NET_BAD, "none", 0, 0 }, // full range
{ NET_CHAR, "Char", -128, 127 },
{ NET_BYTE, "Byte", 0, 255 },
{ NET_SHORT, "Short", -32767, 32767 },
{ NET_WORD, "Word", 0, 65535 },
{ NET_LONG, "Long", 0, 0 }, // can't overflow
{ NET_FLOAT, "Float", 0, 0 }, // can't overflow
{ NET_ANGLE, "Angle", -360, 360 },
{ NET_SCALE, "Scale", -128, 127 },
{ NET_COORD, "Coord", -262140, 262140 },
{ NET_COLOR, "Color", 0, 255 },
{ NET_INT64, "int64", 0, 0 }, // can't overflow
{ NET_DOUBLE, "Double", 0, 0 }, // can't overflow
};
if( module != NULL )
{
if( module->initialized != 0 )
{
// notify library about detaching from process
DllEntryProc DllEntry = (DllEntryProc)CALCULATE_ADDRESS( module->codeBase, module->headers->OptionalHeader.AddressOfEntryPoint );
(*DllEntry)((HINSTANCE)module->codeBase, DLL_PROCESS_DETACH, 0 );
module->initialized = 0;
}
/*
==========================================================
if( module->modules != NULL )
{
// free previously opened libraries
for( i = 0; i < module->numModules; i++ )
if( module->modules[i] != INVALID_HANDLE_VALUE )
FreeLibrary( module->modules[i] );
Mem_Free( module->modules ); // Z_Realloc end
}
ELEMENTS COMMUNICATED ACROSS THE NET
FreeSections( module->headers, module );
==========================================================
*/
if( module->codeBase != NULL )
{
// release memory of library
VirtualFree( module->codeBase, 0, MEM_RELEASE );
}
HeapFree( GetProcessHeap(), 0, module );
}
}
#include "entity_state.h"
void Com_BuildPathExt( const char *dllname, char *fullpath, size_t size, bool clearpath )
#define ES_FIELD( x ) #x,(int)&((entity_state_t*)0)->x
#define CM_FIELD( x ) #x,(int)&((usercmd_t*)0)->x
// config strings are a general means of communication from
// the server to all connected clients.
// each config string can be at most CS_SIZE characters.
#define CS_SIZE 64 // size of one config string
#define CS_NAME 0 // map name
#define CS_MAPCHECKSUM 1 // level checksum (for catching cheater maps)
#define CS_SKYNAME 2 // skybox shader name
#define CS_MAXCLIENTS 3 // server maxclients value (0-255)
#define CS_BACKGROUND_TRACK 4 // basename of background track
#define CS_MAXEDICTS 5 // server limit edicts
#define CS_GRAVITY 6 // sv_gravity
#define CS_MAXVELOCITY 7 // sv_maxvelocity
#define CS_ROLLSPEED 8 // sv_rollspeed
#define CS_ROLLANGLE 9 // sv_rollangle
#define CS_MAXSPEED 10 // client maxspeed
#define CS_STEPHEIGHT 11 // interpolated stepheight
#define CS_AIRACCELERATE 12 // accel when jumping
#define CS_ACCELERATE 13 // accel when running
#define CS_FRICTION 14 // default client friction
// reserved strings
#define CS_MODELS 32 // configstrings starts here
#define CS_SOUNDS (CS_MODELS+MAX_MODELS) // sound names
#define CS_DECALS (CS_SOUNDS+MAX_SOUNDS) // server decal indexes
#define CS_CLASSNAMES (CS_DECALS+MAX_DECALS) // edicts classnames
#define CS_LIGHTSTYLES (CS_CLASSNAMES+MAX_CLASSNAMES) // lightstyle patterns
#define CS_USER_MESSAGES (CS_LIGHTSTYLES+MAX_LIGHTSTYLES) // names of user messages
#define MAX_CONFIGSTRINGS (CS_USER_MESSAGES+MAX_USER_MESSAGES) // total count
// sound flags
#define SND_VOL (1<<0) // a scaled byte
#define SND_ATTN (1<<1) // a byte
#define SND_POS (1<<2) // three coordinates
#define SND_ENT (1<<3) // a short 0 - 2: channel, 3 - 12: entity
#define SND_PITCH (1<<4) // a byte
#define SND_STOP (1<<5) // stop sound or loopsound
#define SND_CHANGE_VOL (1<<6) // change sound vol
#define SND_CHANGE_PITCH (1<<7) // change sound pitch
#define SND_SPAWNING (1<<8) // we're spawing, used in some cases for ambients
/*
==============================================================================
MESSAGE IO FUNCTIONS
Handles byte ordering and avoids alignment errors
==============================================================================
*/
void MSG_Init( sizebuf_t *buf, byte *data, size_t length );
void MSG_Clear( sizebuf_t *buf );
void MSG_Print( sizebuf_t *msg, const char *data );
void MSG_Bitstream( sizebuf_t *buf, bool state );
void _MSG_WriteBits( sizebuf_t *msg, int64 value, const char *name, int bits, const char *filename, const int fileline );
int64 _MSG_ReadBits( sizebuf_t *msg, int bits, const char *filename, const int fileline );
void _MSG_Begin( int dest, const char *filename, int fileline );
void _MSG_WriteString( sizebuf_t *sb, const char *s, const char *filename, int fileline );
void _MSG_WriteFloat( sizebuf_t *sb, float f, const char *filename, int fileline );
void _MSG_WriteDouble( sizebuf_t *sb, double f, const char *filename, int fileline );
void _MSG_WritePos( sizebuf_t *sb, vec3_t pos, const char *filename, int fileline );
void _MSG_WriteData( sizebuf_t *sb, const void *data, size_t length, const char *filename, int fileline );
void _MSG_WriteDeltaUsercmd( sizebuf_t *sb, struct usercmd_s *from, struct usercmd_s *cmd, const char *filename, const int fileline );
void _MSG_WriteDeltaEntity( struct entity_state_s *from, struct entity_state_s *to, sizebuf_t *msg, bool force, bool newentity, const char *filename, int fileline );
void _MSG_Send( msgtype_t to, vec3_t origin, edict_t *ent, const char *filename, int fileline );
#define MSG_Begin( x ) _MSG_Begin( x, __FILE__, __LINE__)
#define MSG_WriteChar(x,y) _MSG_WriteBits (x, y, NULL, NET_CHAR, __FILE__, __LINE__)
#define MSG_WriteByte(x,y) _MSG_WriteBits (x, y, NULL, NET_BYTE, __FILE__, __LINE__)
#define MSG_WriteShort(x,y) _MSG_WriteBits(x, y, NULL, NET_SHORT,__FILE__, __LINE__)
#define MSG_WriteWord(x,y) _MSG_WriteBits (x, y, NULL, NET_WORD, __FILE__, __LINE__)
#define MSG_WriteLong(x,y) _MSG_WriteBits (x, y, NULL, NET_LONG, __FILE__, __LINE__)
#define MSG_WriteFloat(x,y) _MSG_WriteFloat(x, y, __FILE__, __LINE__)
#define MSG_WriteDouble(x,y) _MSG_WriteDouble(x, y, __FILE__, __LINE__)
#define MSG_WriteString(x,y) _MSG_WriteString (x, y, __FILE__, __LINE__)
#define MSG_WriteCoord16(x, y) _MSG_WriteBits(x, y, NULL, NET_COORD, __FILE__, __LINE__)
#define MSG_WriteCoord32(x, y) _MSG_WriteBits(x, y, NULL, NET_FLOAT, __FILE__, __LINE__)
#define MSG_WriteAngle16(x, y) _MSG_WriteBits(x, y, NULL, NET_ANGLE, __FILE__, __LINE__)
#define MSG_WriteAngle32(x, y) _MSG_WriteBits(x, y, NULL, NET_FLOAT, __FILE__, __LINE__)
#define MSG_WritePos(x, y) _MSG_WritePos( x, y, __FILE__, __LINE__ )
#define MSG_WriteData(x,y,z) _MSG_WriteData (x, y, z, __FILE__, __LINE__)
#define MSG_WriteDeltaUsercmd(x, y, z) _MSG_WriteDeltaUsercmd (x, y, z, __FILE__, __LINE__)
#define MSG_WriteDeltaEntity(from, to, msg, force, new ) _MSG_WriteDeltaEntity (from, to, msg, force, new, __FILE__, __LINE__)
#define MSG_WriteBits( buf, value, name, bits ) _MSG_WriteBits( buf, value, name, bits, __FILE__, __LINE__ )
#define MSG_ReadBits( buf, bits ) _MSG_ReadBits( buf, bits, __FILE__, __LINE__ )
#define MSG_Send(x, y, z) _MSG_Send(x, y, z, __FILE__, __LINE__)
void MSG_BeginReading (sizebuf_t *sb);
#define MSG_ReadChar( x ) _MSG_ReadBits( x, NET_CHAR, __FILE__, __LINE__ )
#define MSG_ReadByte( x ) _MSG_ReadBits( x, NET_BYTE, __FILE__, __LINE__ )
#define MSG_ReadShort( x) _MSG_ReadBits( x, NET_SHORT, __FILE__, __LINE__ )
#define MSG_ReadWord( x ) _MSG_ReadBits( x, NET_WORD, __FILE__, __LINE__ )
#define MSG_ReadLong( x ) _MSG_ReadBits( x, NET_LONG, __FILE__, __LINE__ )
#define MSG_ReadAngle16( x ) _MSG_ReadBits( x, NET_ANGLE, __FILE__, __LINE__ )
#define MSG_ReadAngle32( x ) _MSG_ReadBits( x, NET_FLOAT, __FILE__, __LINE__ )
float MSG_ReadFloat( sizebuf_t *msg );
char *MSG_ReadString( sizebuf_t *sb );
double MSG_ReadDouble( sizebuf_t *msg );
char *MSG_ReadStringLine( sizebuf_t *sb );
void MSG_ReadPos( sizebuf_t *sb, vec3_t pos );
void MSG_ReadData( sizebuf_t *sb, void *buffer, size_t size );
void MSG_ReadDeltaUsercmd( sizebuf_t *sb, usercmd_t *from, usercmd_t *cmd );
void MSG_ReadDeltaEntity( sizebuf_t *sb, entity_state_t *from, entity_state_t *to, int number );
entity_state_t MSG_ParseDeltaPlayer( entity_state_t *from, entity_state_t *to );
void MSG_WriteDeltaPlayerstate( entity_state_t *from, entity_state_t *to, sizebuf_t *msg );
void MSG_ReadDeltaPlayerstate( sizebuf_t *msg, entity_state_t *from, entity_state_t *to );
// huffman compression
void Huff_Init( void );
void Huff_CompressPacket( sizebuf_t *msg, int offset );
void Huff_DecompressPacket( sizebuf_t *msg, int offset );
/*
==============================================================
NET
==============================================================
*/
bool NET_GetLoopPacket( netsrc_t sock, netadr_t *from, sizebuf_t *msg );
void NET_SendPacket( netsrc_t sock, int length, void *data, netadr_t to );
bool NET_StringToAdr( const char *s, netadr_t *a );
bool NET_CompareBaseAdr( netadr_t a, netadr_t b );
bool NET_CompareAdr( netadr_t a, netadr_t b );
bool NET_IsLocalAddress( netadr_t adr );
typedef struct netchan_s
{
string name;
bool fatal_error;
netsrc_t sock;
if( !dllname || !fullpath || size <= 0 ) return;
int dropped; // between last packet and previous
bool compress; // enable huffman compression
// only libraries with extension .dll are valid
com.strncpy( name, dllname, sizeof( string ));
FS_FileBase( name, name );
int last_received; // for timeouts
int last_sent; // for retransmits
// game path (Xash3D/game/bin/)
com.snprintf( fullpath, size, "bin/%s.dll", name );
if( FS_FileExists( fullpath )) return; // found
netadr_t remote_address;
int qport; // qport value to write when transmitting
// absoulte path (Xash3D/bin/)
com.snprintf( fullpath, size, "%s.dll", name );
if( FS_FileExists( fullpath )) return; // found
// sequencing variables
int incoming_sequence;
int incoming_acknowledged;
int incoming_reliable_acknowledged; // single bit
if( clearpath ) fullpath[0] = 0;
}
int incoming_reliable_sequence; // single bit, maintained local
int outgoing_sequence;
int reliable_sequence; // single bit
int last_reliable_sequence; // sequence number of last send
// reliable staging and holding areas
sizebuf_t message; // writing buffer to send to server
byte message_buf[MAX_MSGLEN-16]; // leave space for header
// message is copied to this buffer when it is first transfered
int reliable_length;
byte reliable_buf[MAX_MSGLEN-16]; // unacked reliable message
} netchan_t;
#define PROTOCOL_VERSION 36
#define PORT_MASTER 27900
#define PORT_CLIENT 27901
#define PORT_SERVER 27910
#define UPDATE_BACKUP 32 // copies of entity_state_t to keep buffered, must be power of two
#define UPDATE_MASK (UPDATE_BACKUP - 1)
void Netchan_Init( void );
void Netchan_Setup( netsrc_t sock, netchan_t *chan, netadr_t adr, int qport );
bool Netchan_NeedReliable( netchan_t *chan );
void Netchan_Transmit( netchan_t *chan, int length, byte *data );
void Netchan_OutOfBand( int net_socket, netadr_t adr, int length, byte *data );
void Netchan_OutOfBandPrint( int net_socket, netadr_t adr, char *format, ... );
bool Netchan_Process( netchan_t *chan, sizebuf_t *msg );
bool Netchan_CanReliable( netchan_t *chan );
#endif//NET_MSG_H

View File

@ -647,7 +647,7 @@ void Host_Init( int argc, char **argv)
Host_InitVprogs( argc, argv );
// per level user limit
host.max_edicts = bound( 8, Cvar_VariableValue("prvm_maxedicts"), MAX_EDICTS - 1 );
host.max_edicts = bound( 8, Cvar_VariableValue( "host_maxedicts" ), MAX_EDICTS - 1 );
SV_Init();
CL_Init();

View File

@ -2067,18 +2067,6 @@ void pfnWriteEntity( int iValue )
svgame.msg_realsize += 2;
}
/*
=============
pfnCVarRegister
=============
*/
void pfnCVarRegister( const char *name, const char *value, int flags, const char *desc )
{
// FIXME: translate server.dll flags to real cvar flags
Cvar_Get( name, value, flags, desc );
}
/*
=============
pfnCVarGetFloat
@ -2251,7 +2239,7 @@ pfnGetModelPtr
returns pointer to a studiomodel
=============
*/
void* pfnGetModelPtr( edict_t* pEdict )
static void *pfnGetModelPtr( edict_t* pEdict )
{
cmodel_t *mod;
@ -2837,6 +2825,13 @@ static enginefuncs_t gEngfuncs =
pfnSetView,
pfnCrosshairAngle,
pfnLoadFile,
pfnFOpen,
pfnFClose,
pfnFWrite,
pfnFRead,
pfnFGets,
pfnFSeek,
pfnFTell,
pfnFileExists,
pfnCompareFileTime,
pfnGetGameDir,
@ -2996,7 +2991,15 @@ void SV_SpawnEntities( const char *mapname, script_t *entities )
SV_ConfigString( CS_GRAVITY, sv_gravity->string );
SV_ConfigString( CS_MAXVELOCITY, sv_maxvelocity->string );
SV_ConfigString( CS_MAXCLIENTS, va( "%i", Host_MaxClients( )));
SV_ConfigString( CS_ROLLSPEED, sv_rollspeed->string );
SV_ConfigString( CS_ROLLANGLE, sv_rollangle->string );
SV_ConfigString( CS_MAXSPEED, sv_maxspeed->string );
SV_ConfigString( CS_STEPHEIGHT, sv_stepheight->string );
SV_ConfigString( CS_AIRACCELERATE, sv_airaccelerate->string );
SV_ConfigString( CS_ACCELERATE, sv_accelerate->string );
SV_ConfigString( CS_FRICTION, sv_friction->string );
SV_ConfigString( CS_MAXEDICTS, Cvar_VariableString( "host_maxedicts" ));
svgame.globals->mapname = MAKE_STRING( sv.name );
svgame.globals->time = sv.time;
@ -3013,7 +3016,7 @@ void SV_SpawnEntities( const char *mapname, script_t *entities )
ent->pvServerData->client->edict = ent;
svgame.globals->numClients++;
}
Msg("Total %i entities spawned\n", svgame.globals->numEntities );
MsgDev( D_INFO, "Total %i entities spawned\n", svgame.globals->numEntities );
}
void SV_UnloadProgs( void )
@ -3021,6 +3024,8 @@ void SV_UnloadProgs( void )
sv.loadgame = false;
SV_FreeEdicts();
svgame.dllFuncs.pfnGameShutdown();
Sys_FreeNameFuncGlobals();
Com_FreeLibrary( svgame.hInstance );
Mem_FreePool( &svgame.mempool );

View File

@ -247,8 +247,8 @@ A brand new game has been started
*/
void SV_InitGame( void )
{
char i, idmaster[32];
edict_t *ent;
char i, idmaster[32];
edict_t *ent;
if( svs.initialized )
{
@ -265,6 +265,8 @@ void SV_InitGame( void )
CL_Drop();
}
MsgDev( D_INFO, "Dll loaded for mod %s\n", svgame.dllFuncs.pfnGetGameDescription() );
Cmd_ExecuteString( "latch\n" );
svs.initialized = true;

View File

@ -375,7 +375,7 @@ void SV_Init( void )
Cvar_Get ("protocol", va("%i", PROTOCOL_VERSION), CVAR_SERVERINFO|CVAR_INIT, "displays server protocol version" );
sv_fps = Cvar_Get( "sv_fps", "60", CVAR_ARCHIVE, "running physics engine at" );
sv_stepheight = Cvar_Get( "sv_stepheight", "18", CVAR_ARCHIVE|CVAR_LATCH, "how high you can step up" );
sv_stepheight = Cvar_Get( "sv_stepheight", DEFAULT_STEPHEIGHT, CVAR_ARCHIVE|CVAR_LATCH, "how high you can step up" );
sv_playersonly = Cvar_Get( "playersonly", "0", 0, "freezes time, except for players" );
hostname = Cvar_Get ("sv_hostname", "unnamed", CVAR_SERVERINFO | CVAR_ARCHIVE, "host name" );
timeout = Cvar_Get ("timeout", "125", 0, "connection timeout" );
@ -383,15 +383,15 @@ void SV_Init( void )
sv_paused = Cvar_Get ("paused", "0", 0, "server pause" );
sv_enforcetime = Cvar_Get ("sv_enforcetime", "0", 0, "client enforce time" );
allow_download = Cvar_Get ("allow_download", "1", CVAR_ARCHIVE, "allow download resources" );
sv_noreload = Cvar_Get("sv_noreload", "0", 0, "ignore savepoints for singleplayer" );
sv_rollangle = Cvar_Get("sv_rollangle", "2", 0, "how much to tilt the view when strafing" );
sv_rollspeed = Cvar_Get("sv_rollspeed", "200", 0, "how much strafing is necessary to tilt the view" );
sv_airaccelerate = Cvar_Get("sv_airaccelerate", "0", CVAR_LATCH, "player accellerate in air" );
sv_noreload = Cvar_Get( "sv_noreload", "0", 0, "ignore savepoints for singleplayer" );
sv_rollangle = Cvar_Get( "sv_rollangle", DEFAULT_ROLLANGLE, 0, "how much to tilt the view when strafing" );
sv_rollspeed = Cvar_Get( "sv_rollspeed", DEFAULT_ROLLSPEED, 0, "how much strafing is necessary to tilt the view" );
sv_airaccelerate = Cvar_Get("sv_airaccelerate", DEFAULT_AIRACCEL, CVAR_LATCH, "player accellerate in air" );
sv_maxvelocity = Cvar_Get("sv_maxvelocity", DEFAULT_MAXVELOCITY, CVAR_LATCH, "max world velocity" );
sv_gravity = Cvar_Get("sv_gravity", DEFAULT_GRAVITY, CVAR_LATCH, "world gravity" );
sv_maxspeed = Cvar_Get("sv_maxspeed", "320", 0, "maximum speed a player can accelerate to when on ground (can be exceeded by tricks)");
sv_accelerate = Cvar_Get( "sv_accelerate", "10", 0, "rate at which a player accelerates to sv_maxspeed" );
sv_friction = Cvar_Get( "sv_friction", "4", 0, "how fast you slow down" );
sv_maxspeed = Cvar_Get("sv_maxspeed", DEFAULT_MAXSPEED, 0, "maximum speed a player can accelerate to when on ground");
sv_accelerate = Cvar_Get( "sv_accelerate", DEFAULT_ACCEL, 0, "rate at which a player accelerates to sv_maxspeed" );
sv_friction = Cvar_Get( "sv_friction", DEFAULT_FRICTION, 0, "how fast you slow down" );
sv_physics = Cvar_Get( "cm_physic", "1", CVAR_ARCHIVE|CVAR_LATCH, "change physic model: 0 - Classic Quake Physic, 1 - Physics Engine" );
public_server = Cvar_Get ("public", "0", 0, "change server type from private to public" );

File diff suppressed because it is too large Load Diff

View File

@ -72,7 +72,6 @@ enum dev_level
};
typedef long fs_offset_t;
typedef struct cvar_s cvar_t;
typedef struct file_s file_t; // normal file
typedef struct vfile_s vfile_t; // virtual file
typedef struct wfile_s wfile_t; // wad file
@ -646,20 +645,7 @@ typedef struct script_s
char TXcommand;
};
/*
========================================================================
console variables
external and internal cvars struct have some differences
========================================================================
*/
typedef struct cvar_s
{
char *name;
char *string; // normal string
float value; // com.atof( string )
int integer; // com.atoi( string )
bool modified; // set each time the cvar is changed
};
#include "cvardef.h"
/*
==========================================

View File

@ -208,7 +208,7 @@ void R_Bloom_InitTextures( void )
r_downsample.palette = NULL;
r_downsample.buffer = r_framebuffer;
r_downsample.numMips = 1;
r_bloomdownsamplingtexture = R_LoadTexture( "*r_bloomdownsampetexture", &r_downsample, 3, TF_STATIC|TF_NOPICMIP, TF_LINEAR, TW_CLAMP );
r_bloomdownsamplingtexture = R_LoadTexture( "*r_bloomdownsampletexture", &r_downsample, 3, TF_STATIC|TF_NOPICMIP, TF_LINEAR, TW_CLAMP );
}
// Init the screen backup texture

View File

@ -441,7 +441,7 @@ bool R_Init_OpenGL( void )
}
// setup limits
gl_config.max_entities = (int)Cvar_VariableValue( "prvm_maxedicts" );
gl_config.max_entities = (int)Cvar_VariableValue( "host_maxedicts" );
return true;
}

View File

@ -2055,10 +2055,7 @@ int R_StudioDrawPlayer( int flags )
{
edict_t *pplayer;
// FIXME: temporary disabled
//if( !mirror_render )
return 0;
if( !r_refdef.thirdperson ) return 0;
if( !( flags & STUDIO_MIRROR ))
{
//m_pCurrentEntity = IEngineStudio.GetCurrentEntity();

View File

@ -25,24 +25,24 @@ void GameDLLInit( void )
// register cvars here:
CVAR_REGISTER( "sv_soundlist", "0", 0, "show server sound list" );
CVAR_REGISTER( "mp_teamplay", "0", CVAR_SERVERINFO, "sets to 1 to indicate teamplay" );
CVAR_REGISTER( "mp_fraglimit", "0", CVAR_SERVERINFO, "limit of frags for current server" );
CVAR_REGISTER( "mp_timelimit", "0", CVAR_SERVERINFO, "server timelimit" );
CVAR_REGISTER( "mp_teamplay", "0", FCVAR_SERVERINFO, "sets to 1 to indicate teamplay" );
CVAR_REGISTER( "mp_fraglimit", "0", FCVAR_SERVERINFO, "limit of frags for current server" );
CVAR_REGISTER( "mp_timelimit", "0", FCVAR_SERVERINFO, "server timelimit" );
CVAR_REGISTER( "mp_fragsleft", "0", CVAR_SERVERINFO, "counter that indicated how many frags remaining" );
CVAR_REGISTER( "mp_timeleft", "0" , CVAR_SERVERINFO, "counter that indicated how many time remaining" );
CVAR_REGISTER( "mp_fragsleft", "0", FCVAR_SERVERINFO, "counter that indicated how many frags remaining" );
CVAR_REGISTER( "mp_timeleft", "0" , FCVAR_SERVERINFO, "counter that indicated how many time remaining" );
CVAR_REGISTER( "mp_friendlyfire", "0", CVAR_SERVERINFO, "enables firedlyfire for teamplay" );
CVAR_REGISTER( "mp_falldamage", "0", CVAR_SERVERINFO, "falldamage multiplier" );
CVAR_REGISTER( "mp_weaponstay", "0", CVAR_SERVERINFO, "weapon leave stays on ground" );
CVAR_REGISTER( "mp_forcerespawn", "1", CVAR_SERVERINFO, "force client respawn after his death" );
CVAR_REGISTER( "mp_flashlight", "0", CVAR_SERVERINFO, "attempt to use flashlight in multiplayer" );
CVAR_REGISTER( "mp_autocrosshair", "1", CVAR_SERVERINFO, "enables auto-aim in multiplayer" );
CVAR_REGISTER( "decalfrequency", "30", CVAR_SERVERINFO, "how many decals can be spawned" );
CVAR_REGISTER( "mp_teamlist", "hgrunt,scientist", CVAR_SERVERINFO, "names of default teams" );
CVAR_REGISTER( "mp_friendlyfire", "0", FCVAR_SERVERINFO, "enables firedlyfire for teamplay" );
CVAR_REGISTER( "mp_falldamage", "0", FCVAR_SERVERINFO, "falldamage multiplier" );
CVAR_REGISTER( "mp_weaponstay", "0", FCVAR_SERVERINFO, "weapon leave stays on ground" );
CVAR_REGISTER( "mp_forcerespawn", "1", FCVAR_SERVERINFO, "force client respawn after his death" );
CVAR_REGISTER( "mp_flashlight", "0", FCVAR_SERVERINFO, "attempt to use flashlight in multiplayer" );
CVAR_REGISTER( "mp_autocrosshair", "1", FCVAR_SERVERINFO, "enables auto-aim in multiplayer" );
CVAR_REGISTER( "decalfrequency", "30", FCVAR_SERVERINFO, "how many decals can be spawned" );
CVAR_REGISTER( "mp_teamlist", "hgrunt,scientist", FCVAR_SERVERINFO, "names of default teams" );
CVAR_REGISTER( "mp_teamoverride", "1", 0, "can ovveride teams from map settings ?" );
CVAR_REGISTER( "mp_defaultteam", "0", 0, "use default team instead ?" );
CVAR_REGISTER( "mp_chattime", "10", CVAR_SERVERINFO, "time beetween messages" );
CVAR_REGISTER( "mp_chattime", "10", FCVAR_SERVERINFO, "time beetween messages" );
}
// perform any shutdown operations

View File

@ -16,10 +16,7 @@
#ifndef GAME_H
#define GAME_H
// cvar flags
#define CVAR_ARCHIVE BIT(0) // set to cause it to be saved to vars.rc
#define CVAR_USERINFO BIT(1) // added to userinfo when changed
#define CVAR_SERVERINFO BIT(2) // added to serverinfo when changed
#include "cvardef.h"
extern void GameDLLInit( void );
extern void GameDLLShutdown( void );

View File

@ -1130,23 +1130,23 @@ GetGameDescription
Returns the descriptive name of this .dll. E.g., Half-Life, or Team Fortress 2
===============
*/
const char *GetGameDescription()
const char *GetGameDescription( void )
{
char token[256];
char szbuffer[128];
char *pfile = (char *)LOAD_FILE( "liblist.gam", NULL );
if(pfile)
char token[256];
char szbuffer[128];
char *pfile = (char *)LOAD_FILE( "liblist.gam", NULL );
if( pfile )
{
while ( pfile )
while( pfile )
{
if ( !stricmp( token, "game" ))
if( !stricmp( token, "game" ))
{
pfile = COM_ParseFile(pfile, token);
sprintf( szbuffer, "%s ", token );
strcat( text, szbuffer );
}
else if ( !stricmp( token, "version" ))
else if( !stricmp( token, "version" ))
{
pfile = COM_ParseFile(pfile, token);
strcat( text, token );

View File

@ -85,9 +85,6 @@ typedef int EOFFSET;
// In case it's not alread defined
typedef int BOOL;
// In case this ever changes
#define M_PI 3.14159265358979323846
// Keeps clutter down a bit, when declaring external entity/global method prototypes
#define DECLARE_GLOBAL_METHOD(MethodName) extern void DLLEXPORT MethodName( void )
#define GLOBAL_METHOD(funcname) void DLLEXPORT funcname(void)
@ -548,12 +545,6 @@ extern DLL_GLOBAL int g_Language;
#define VEC_DUCK_HULL_MAX Vector( 16, 16, 18)
#define VEC_DUCK_VIEW Vector( 0, 0, 12 )
// camera flags
#define CAMERA_ON 1
#define DRAW_HUD 2
#define INVERSE_X 4
#define MONSTER_VIEW 8
// triggers
#define SF_TRIGGER_ALLOWMONSTERS 1// monsters allowed to fire this trigger
#define SF_TRIGGER_NOCLIENTS 2// players not allowed to fire this trigger

View File

@ -2116,6 +2116,10 @@ void CBaseMonster :: StartMonster ( void )
{
Msg("%s \"%s\" stuck in wall--level design error\n", STRING(pev->classname), STRING(pev->targetname));
pev->effects = EF_BRIGHTFIELD;
// HACKHACK: this is for pre-alpha version
// remove stucked zombies on a start.bsp
UTIL_Remove( this );
}
}
else

View File

@ -2487,67 +2487,58 @@ NoMemory:
// CGraph - FSaveGraph - It's not rocket science.
// this WILL overwrite existing files.
//=========================================================
int CGraph :: FSaveGraph ( char *szMapName )
int CGraph :: FSaveGraph( char *szMapName )
{
int iVersion = GRAPH_VERSION;
int iVersion = GRAPH_VERSION;
char szFilename[MAX_PATH];
FILE *file;
void *file;
if ( !m_fGraphPresent || !m_fGraphPointersSet )
{// protect us in the case that the node graph isn't available or built
ALERT ( at_aiconsole, "Graph not ready!\n" );
if( !m_fGraphPresent || !m_fGraphPointersSet )
{
// protect us in the case that the node graph isn't available or built
ALERT( at_aiconsole, "Graph not ready!\n" );
return FALSE;
}
// make sure directories have been made
GET_GAME_DIR( szFilename );
strcat( szFilename, "/maps" );
CreateDirectory( szFilename, NULL );
strcat( szFilename, "/graphs" );
CreateDirectory( szFilename, NULL );
sprintf( szFilename, "maps/graphs/%s.nod", szMapName );
file = g_engfuncs.pfnFOpen( szFilename, "wb" );
strcat( szFilename, "/" );
strcat( szFilename, szMapName );
strcat( szFilename, ".nod" );
ALERT( at_aiconsole, "Created: %s\n", szFilename );
file = fopen ( szFilename, "wb" );
ALERT ( at_aiconsole, "Created: %s\n", szFilename );
if ( !file )
{// couldn't create
ALERT ( at_aiconsole, "Couldn't Create: %s\n", szFilename );
if( !file )
{
// couldn't create
ALERT( at_aiconsole, "Couldn't Create: %s\n", szFilename );
return FALSE;
}
else
{
// write the version
fwrite ( &iVersion, sizeof ( int ), 1, file );
// write the version
g_engfuncs.pfnFWrite( file, &iVersion, sizeof( int ));
// write the CGraph class
fwrite ( this, sizeof ( CGraph ), 1, file );
// write the CGraph class
g_engfuncs.pfnFWrite( file, this, sizeof( CGraph ));
// write the nodes
fwrite ( m_pNodes, sizeof ( CNode ), m_cNodes, file );
// write the nodes
g_engfuncs.pfnFWrite( file, m_pNodes, sizeof( CNode ) * m_cNodes );
// write the links
fwrite ( m_pLinkPool, sizeof ( CLink ), m_cLinks, file );
// write the links
g_engfuncs.pfnFWrite( file, m_pLinkPool, sizeof( CLink ) * m_cLinks );
fwrite ( m_di, sizeof(DIST_INFO), m_cNodes, file );
g_engfuncs.pfnFWrite( file, m_di, sizeof( DIST_INFO ) * m_cNodes );
// Write the route info.
//
if ( m_pRouteInfo && m_nRouteInfo )
// write the route info.
if( m_pRouteInfo && m_nRouteInfo )
{
fwrite ( m_pRouteInfo, sizeof( char ), m_nRouteInfo, file );
g_engfuncs.pfnFWrite( file, m_pRouteInfo, sizeof( char ) * m_nRouteInfo );
}
if (m_pHashLinks && m_nHashLinks)
if( m_pHashLinks && m_nHashLinks )
{
fwrite(m_pHashLinks, sizeof(short), m_nHashLinks, file);
g_engfuncs.pfnFWrite( file, m_pHashLinks, sizeof( short ) * m_nHashLinks );
}
fclose ( file );
g_engfuncs.pfnFClose( file );
return TRUE;
}
}

View File

@ -61,7 +61,9 @@ Beta 13.12.08
30.func_pendulum OK
31.weapon_egon & weapon_gauss
32.Com_LoadLibrary: searchpaths: game/bin, bin OK
33. prepare resources for pak
33.prepare resources for pak OK
34.V_CalcRefDef export
35.other unused exports cl & sv
Список доступных рендереров: Что в них интересного

View File

@ -246,7 +246,7 @@ void PRVM_Init( int argc, char **argv )
prvm_boundscheck = Cvar_Get( "prvm_boundscheck", "0", 0, "enable vm internal boundschecker" );
prvm_traceqc = Cvar_Get( "prvm_traceqc", "0", 0, "enable tracing (only for debug)" );
prvm_statementprofiling = Cvar_Get ("prvm_statementprofiling", "0", 0, "counts how many times each QC statement has been executed" );
prvm_maxedicts = Cvar_Get( "prvm_maxedicts", "4096", CVAR_SYSTEMINFO, "user limit edicts number fof server, client and renderer, absolute limit 65535" );
prvm_maxedicts = Cvar_Get( "host_maxedicts", "2048", CVAR_SYSTEMINFO, "user limit edicts number fof server, client and renderer, absolute limit 65535" );
if( host_instance == HOST_NORMAL || host_instance == HOST_DEDICATED )
{