31 Mar 2010

This commit is contained in:
g-cont 2010-03-31 00:00:00 +04:00 committed by Alibek Omarov
parent fe42613ec2
commit 0e6c9987f0
28 changed files with 980 additions and 767 deletions

View File

@ -399,14 +399,11 @@ void TE_ParseBSPDecal( void )
decalIndex = READ_SHORT();
entityIndex = READ_SHORT();
if( entityIndex != 0 )
{
if( entityIndex != NULLENT_INDEX )
modelIndex = READ_SHORT();
}
pEntity = GetEntityByIndex( entityIndex );
g_pTempEnts->PlaceDecal( pos, 2.0f, decalIndex );
g_pTempEnts->PlaceDecal( pos, 5.0f, decalIndex );
}
/*

View File

@ -99,6 +99,10 @@ typedef struct cl_globalvars_s
int windowState; // 0 - inactive (minimize, notfocus), 1 - active
int maxEntities;
int numEntities; // actual ents count
const char *pStringBase; // actual only when sys_sharedstrings is 1
void *pSaveData; // (SAVERESTOREDATA *) pointer
} cl_globalvars_t;
typedef struct cl_enginefuncs_s

View File

@ -47,7 +47,7 @@ typedef struct globalvars_s
int maxClients;
int maxEntities;
const char *pStringBase;
const char *pStringBase; // actual only when sys_sharedstrings is 1
void *pSaveData; // (SAVERESTOREDATA *) pointer
vec3_t vecLandmarkOffset;

View File

@ -46,6 +46,12 @@ CL_AllocString
*/
string_t CL_AllocString( const char *szValue )
{
if( sys_sharedstrings->integer )
{
const char *newString;
newString = com.stralloc( clgame.stringspool, szValue, __FILE__, __LINE__ );
return newString - clgame.globals->pStringBase;
}
return StringTable_SetString( clgame.hStringTable, szValue );
}
@ -57,6 +63,8 @@ CL_GetString
*/
const char *CL_GetString( string_t iString )
{
if( sys_sharedstrings->integer )
return (clgame.globals->pStringBase + iString);
return StringTable_GetString( clgame.hStringTable, iString );
}
@ -486,7 +494,6 @@ void CL_DrawCrosshair( void )
vec3_t forward;
vec3_t point, screen;
// FIXME: this code is wrong
VectorAdd( cl.refdef.viewangles, cl.refdef.crosshairangle, angles );
AngleVectors( angles, forward, NULL, NULL );
VectorAdd( cl.refdef.vieworg, forward, point );
@ -822,7 +829,11 @@ void CL_FreeEdicts( void )
if( clgame.baselines ) Mem_Free( clgame.baselines );
// clear globals
StringTable_Clear( clgame.hStringTable );
if( sys_sharedstrings->integer )
Mem_EmptyPool( clgame.stringspool );
else StringTable_Clear( clgame.hStringTable );
clgame.globals->numEntities = 0;
clgame.baselines = NULL;
clgame.edicts = NULL;
@ -1031,12 +1042,64 @@ static void pfnSPR_DisableScissor( void )
=========
pfnSPR_GetList
FIXME: implement original hl1 SPR_GetList
for parsing half-life scripts - hud.txt etc
=========
*/
static client_sprite_t *pfnSPR_GetList( char *psz, int *piCount )
{
return NULL;
client_sprite_t *pList;
int index, iTemp;
int numSprites;
script_t *script;
token_t token;
if( piCount ) *piCount = 0;
script = Com_OpenScript( psz, NULL, 0 );
if( !script ) return NULL;
Com_ReadUlong( script, false, &numSprites );
// name, res, pic, x, y, w, h
pList = Mem_Alloc( clgame.mempool, sizeof( *pList ) * numSprites );
for( index = 0; index < numSprites; index++ )
{
if( !Com_ReadToken( script, SC_ALLOW_NEWLINES, &token ))
break;
com.strncpy( pList[index].szName, token.string, sizeof( pList[index].szName ));
// read resolution
Com_ReadUlong( script, false, &iTemp );
pList[index].iRes = iTemp;
// read spritename
Com_ReadToken( script, false, &token );
com.strncpy( pList[index].szSprite, token.string, sizeof( pList[index].szSprite ));
// parse rectangle
Com_ReadUlong( script, false, &iTemp );
pList[index].rc.left = iTemp;
Com_ReadUlong( script, false, &iTemp );
pList[index].rc.top = iTemp;
Com_ReadUlong( script, false, &iTemp );
pList[index].rc.right = pList[index].rc.left + iTemp;
Com_ReadUlong( script, false, &iTemp );
pList[index].rc.bottom = pList[index].rc.top + iTemp;
if( piCount ) (*piCount)++;
}
if( index < numSprites )
MsgDev( D_WARN, "SPR_GetList: unexpected end of %s\n", psz );
Com_CloseScript( script );
return pList;
}
/*
@ -1463,12 +1526,11 @@ static const char* pfnPhysInfo_ValueForKey( const char *key )
=============
pfnServerInfo_ValueForKey
FIXME: this is valid only for local client
=============
*/
static const char* pfnServerInfo_ValueForKey( const char *key )
{
return Info_ValueForKey( Cvar_Serverinfo(), key );
return Info_ValueForKey( cl.serverinfo, key );
}
/*
@ -1917,7 +1979,7 @@ pfnStopAllSounds
*/
void pfnStopAllSounds( edict_t *ent, int entchannel )
{
// FIXME: this not valid code
// FIXME: this code is wrong
S_StopAllSounds ();
}
@ -1974,7 +2036,7 @@ VGui_GetPanel
*/
void *VGui_GetPanel( void )
{
// FIXME: implement
// UNDONE: wait for version 0.75
return NULL;
}
@ -1986,7 +2048,7 @@ VGui_ViewportPaintBackground
*/
void VGui_ViewportPaintBackground( int extents[4] )
{
// FIXME: implement
// UNDONE: wait for version 0.75
}
/*
@ -2527,7 +2589,10 @@ void CL_UnloadProgs( void )
// deinitialize game
clgame.dllFuncs.pfnShutdown();
StringTable_Delete( clgame.hStringTable );
if( sys_sharedstrings->integer )
Mem_FreePool( &clgame.stringspool );
else StringTable_Delete( clgame.hStringTable );
FS_FreeLibrary( clgame.hInstance );
Mem_FreePool( &cls.mempool );
Mem_FreePool( &clgame.mempool );
@ -2578,8 +2643,19 @@ bool CL_LoadProgs( const char *name )
return false;
}
// 65535 unique strings should be enough ...
clgame.hStringTable = StringTable_Create( "Client", 0x10000 );
clgame.globals->pStringBase = ""; // setup string base
if( sys_sharedstrings->integer )
{
// just use Half-Life system - base pointer and malloc
clgame.stringspool = Mem_AllocPool( "Client Strings" );
}
else
{
// 65535 unique strings should be enough ...
clgame.hStringTable = StringTable_Create( "Client", 0x10000 );
}
clgame.globals->maxEntities = GI->max_edicts; // merge during loading
// register svc_bad message

View File

@ -22,7 +22,7 @@ char *svc_strings[256] =
"svc_configstring",
"svc_spawnbaseline",
"svc_download",
"svc_playerinfo",
"svc_changing",
"svc_physinfo",
"svc_packetentities",
"svc_frame",
@ -38,7 +38,8 @@ char *svc_strings[256] =
"svc_soundfade",
"svc_bspdecal",
"svc_event",
"svc_event_reliable"
"svc_event_reliable",
"svc_serverinfo"
};
typedef struct
@ -670,6 +671,23 @@ void CL_UpdateUserinfo( sizebuf_t *msg )
else Mem_Set( player, 0, sizeof( *player ));
}
/*
==============
CL_ServerInfo
change serverinfo
==============
*/
void CL_ServerInfo( sizebuf_t *msg )
{
char key[MAX_MSGLEN];
char value[MAX_MSGLEN];
com.strncpy( key, MSG_ReadString( msg ), sizeof( key ));
com.strncpy( value, MSG_ReadString( msg ), sizeof( value ));
Info_SetValueForKey( cl.serverinfo, key, value );
}
/*
=====================================================================
@ -798,6 +816,9 @@ void CL_ParseServerMessage( sizebuf_t *msg )
case svc_updateuserinfo:
CL_UpdateUserinfo( msg );
break;
case svc_serverinfo:
CL_ServerInfo( msg );
break;
case svc_frame:
CL_ParseFrame( msg );
break;

View File

@ -149,6 +149,8 @@ V_PreRender
*/
bool V_PreRender( void )
{
bool clearScene = true;
// too early
if( !re ) return false;
@ -157,8 +159,11 @@ bool V_PreRender( void )
if( host.state == HOST_SLEEP )
return false;
re->BeginFrame( !cl.refdef.paused );
return true;
if( cl.refdef.paused || !cls.drawplaque )
clearScene = false;
re->BeginFrame( clearScene );
return cls.drawplaque;
}
/*

View File

@ -82,6 +82,7 @@ typedef struct
cinematics_t *cin;
char serverinfo[MAX_INFO_STRING];
player_info_t players[MAX_CLIENTS];
event_state_t events;
@ -254,6 +255,7 @@ typedef struct
edict_t viewent; // viewmodel or playermodel in UI_PlayerSetup
edict_t playermodel; // uiPlayerSetup latched vars
byte *stringspool; // for shared strings
int numMessages; // actual count of user messages
int hStringTable; // stringtable handle

View File

@ -27,6 +27,7 @@
extern cvar_t *scr_width;
extern cvar_t *scr_height;
extern cvar_t *allow_download;
extern cvar_t *sys_sharedstrings;
extern string video_dlls[MAX_RENDERS];
extern string audio_dlls[MAX_RENDERS];

View File

@ -78,6 +78,7 @@ enum svc_ops_e
svc_event, // playback event queue
svc_event_reliable, // playback event directly from message, not queue
svc_updateuserinfo, // [byte] playernum, [string] userinfo
svc_serverinfo, // [string] key [string] value
};
// client to server

View File

@ -27,6 +27,7 @@ dll_info_t vsound_dll = { "", NULL, "CreateAPI", NULL, NULL, 0, sizeof(vsound_ex
dll_info_t physic_dll = { "", NULL, "CreateAPI", NULL, NULL, 0, sizeof(physic_exp_t), sizeof(stdlib_api_t) };
cvar_t *timescale;
cvar_t *sys_sharedstrings;
cvar_t *host_serverstate;
cvar_t *host_cheats;
cvar_t *host_maxfps;
@ -746,6 +747,8 @@ void Host_InitCommon( const int argc, const char **argv )
Host_InitEvents();
sys_sharedstrings = Cvar_Get( "sys_sharedstrings", "0", CVAR_SYSTEMINFO, "hl1 strings or stringtable" );
FS_LoadGameInfo( NULL );
Image_Init( GI->texmode, -1 );

View File

@ -220,6 +220,7 @@ typedef struct
DLL_FUNCTIONS dllFuncs; // dll exported funcs
byte *private; // server.dll private pool
byte *mempool; // server premamnent pool: edicts etc
byte *stringspool; // for shared strings
int hStringTable; // stringtable handle
SAVERESTOREDATA SaveData; // shared struct, used for save data
@ -277,6 +278,7 @@ extern cvar_t *sv_rollangle;
extern cvar_t *sv_rollspeed;
extern cvar_t *sv_maxspeed;
extern cvar_t *sv_maxclients;
extern cvar_t *serverinfo;
extern cvar_t *physinfo;
extern sv_client_t *sv_client;
@ -324,6 +326,7 @@ bool SV_CheckWater( edict_t *ent );
bool SV_RunThink( edict_t *ent );
bool SV_UnstickEntity( edict_t *ent );
void SV_FreeOldEntities( void );
bool SV_TestEntityPosition( edict_t *ent, const vec3_t offset ); // for EntityInSolid checks
//
// sv_move.c
@ -363,6 +366,7 @@ void SV_RunCmd( sv_client_t *cl, usercmd_t *ucmd );
void SV_PostRunCmd( sv_client_t *cl );
void SV_SetIdealPitch( sv_client_t *cl );
void SV_InitClientMove( void );
void SV_UpdateServerInfo( void );
//
// sv_cmds.c

View File

@ -104,7 +104,7 @@ void SV_ConfigString( int index, const char *val )
}
}
static bool SV_EntitiesIn( int mode, vec3_t v1, vec3_t v2 )
static bool SV_EntitiesIn( int mode, const vec3_t v1, const vec3_t v2 )
{
int leafnum, cluster;
int area1, area2;
@ -338,7 +338,12 @@ edict_t* SV_AllocPrivateData( edict_t *ent, string_t className )
LINK_ENTITY_FUNC SpawnEdict;
pszClassName = STRING( className );
if( !ent ) ent = SV_AllocEdict();
if( !ent )
{
// allocate new one
ent = SV_AllocEdict();
}
else if( ent->free )
{
SV_InitEdict( ent ); // re-init edict
@ -826,7 +831,7 @@ edict_t* pfnFindEntityByString( edict_t *pStartEdict, const char *pszField, cons
if( pStartEdict ) e = NUM_FOR_EDICT( pStartEdict );
if( !pszValue || !*pszValue ) return NULL;
while((desc = svgame.dllFuncs.pfnGetEntvarsDescirption( index++ )) != NULL )
while(( desc = svgame.dllFuncs.pfnGetEntvarsDescirption( index++ )) != NULL )
{
if( !com.strcmp( pszField, desc->fieldName ))
break;
@ -841,7 +846,7 @@ edict_t* pfnFindEntityByString( edict_t *pStartEdict, const char *pszField, cons
for( e++; e < svgame.globals->numEntities; e++ )
{
ed = EDICT_NUM( e );
if( ed->free ) continue;
if( !SV_IsValidEdict( ed )) continue;
switch( desc->fieldType )
{
@ -894,6 +899,7 @@ edict_t* pfnFindEntityByString( edict_t *pStartEdict, const char *pszField, cons
==============
pfnGetEntityIllum
FIXME: implement
==============
*/
int pfnGetEntityIllum( edict_t* pEnt )
@ -903,7 +909,7 @@ int pfnGetEntityIllum( edict_t* pEnt )
MsgDev( D_WARN, "SV_GetEntityIllum: invalid entity %s\n", SV_ClassName( pEnt ));
return 255;
}
return 255; // FIXME: implement
return 255;
}
/*
@ -922,13 +928,13 @@ edict_t* pfnFindEntityInSphere( edict_t *pStartEdict, const float *org, float fl
flRadius *= flRadius;
if( pStartEdict )
if( SV_IsValidEdict( pStartEdict ))
e = NUM_FOR_EDICT( pStartEdict );
for( e++; e < svgame.globals->numEntities; e++ )
{
ent = EDICT_NUM( e );
if( ent->free ) continue;
if( !SV_IsValidEdict( ent )) continue;
distSquared = 0;
for( j = 0; j < 3 && distSquared <= flRadius; j++ )
@ -957,15 +963,27 @@ return NULL instead of world
*/
edict_t* pfnFindClientInPVS( edict_t *pEdict )
{
edict_t *pClient;
int i;
edict_t *pClient;
sv_client_t *cl;
const float *org;
int i;
if( !SV_IsValidEdict( pEdict ))
return NULL;
for( i = 0; i < svgame.globals->maxClients; i++ )
{
pClient = EDICT_NUM( i + 1 );
if( pClient->free ) continue;
if( SV_EntitiesIn( DVIS_PVS, pEdict->v.origin, pClient->v.origin ))
return pEdict;
if(( cl = SV_ClientFromEdict( pClient, true )) == NULL )
continue;
// check for SET_VIEW
if( SV_IsValidEdict( cl->pViewEntity ))
org = cl->pViewEntity->v.origin;
else org = pClient->v.origin;
if( SV_EntitiesIn( DVIS_PVS, pEdict->v.origin, org ))
return pClient;
}
return NULL;
}
@ -979,15 +997,27 @@ return NULL instead of world
*/
edict_t* pfnFindClientInPHS( edict_t *pEdict )
{
edict_t *pClient;
int i;
edict_t *pClient;
sv_client_t *cl;
const float *org;
int i;
if( !SV_IsValidEdict( pEdict ))
return NULL;
for( i = 0; i < svgame.globals->maxClients; i++ )
{
pClient = EDICT_NUM( i + 1 );
if( pClient->free ) continue;
if( SV_EntitiesIn( DVIS_PHS, pEdict->v.origin, pClient->v.origin ))
return pEdict;
if(( cl = SV_ClientFromEdict( pClient, true )) == NULL )
continue;
// check for SET_VIEW
if( SV_IsValidEdict( cl->pViewEntity ))
org = cl->pViewEntity->v.origin;
else org = pClient->v.origin;
if( SV_EntitiesIn( DVIS_PHS, pEdict->v.origin, org ))
return pClient;
}
return NULL;
}
@ -1001,6 +1031,7 @@ pfnEntitiesInPVS
edict_t* pfnEntitiesInPVS( edict_t *pplayer )
{
edict_t *pEdict, *chain;
vec3_t checkPos;
int i;
chain = NULL;
@ -1011,8 +1042,14 @@ edict_t* pfnEntitiesInPVS( edict_t *pplayer )
for( i = svgame.globals->maxClients + 1; i < svgame.globals->numEntities; i++ )
{
pEdict = EDICT_NUM( i );
if( pEdict->free ) continue;
if( SV_EntitiesIn( DVIS_PVS, pEdict->v.origin, pplayer->v.origin ))
if( !SV_IsValidEdict( pEdict )) continue;
if( CM_GetModelType( pEdict->v.modelindex ) == mod_brush )
VectorAverage( pEdict->v.mins, pEdict->v.maxs, checkPos );
else VectorCopy( pEdict->v.origin, checkPos );
if( SV_EntitiesIn( DVIS_PVS, checkPos, pplayer->v.origin ))
{
pEdict->v.chain = chain;
chain = pEdict;
@ -1030,6 +1067,7 @@ pfnEntitiesInPHS
edict_t* pfnEntitiesInPHS( edict_t *pplayer )
{
edict_t *pEdict, *chain;
vec3_t checkPos;
int i;
chain = NULL;
@ -1040,8 +1078,14 @@ edict_t* pfnEntitiesInPHS( edict_t *pplayer )
for( i = svgame.globals->maxClients + 1; i < svgame.globals->numEntities; i++ )
{
pEdict = EDICT_NUM( i );
if( pEdict->free ) continue;
if( SV_EntitiesIn( DVIS_PHS, pEdict->v.origin, pplayer->v.origin ))
if( !SV_IsValidEdict( pEdict )) continue;
if( CM_GetModelType( pEdict->v.modelindex ) == mod_brush )
VectorAverage( pEdict->v.mins, pEdict->v.maxs, checkPos );
else VectorCopy( pEdict->v.origin, checkPos );
if( SV_EntitiesIn( DVIS_PHS, checkPos, pplayer->v.origin ))
{
pEdict->v.chain = chain;
chain = pEdict;
@ -1554,7 +1598,7 @@ FIXME: implement
*/
static void pfnTraceSphere( const float *v1, const float *v2, int fNoMonsters, float radius, edict_t *pentToSkip, TraceResult *ptr )
{
Host_Error( "not implemented\n" );
Host_Error( "SV_TraceSphere: not implemented\n" );
}
/*
@ -1610,7 +1654,7 @@ void pfnGetAimVector( edict_t* ent, float speed, float *rgflReturn )
if( fNoFriendlyFire && ent->v.team > 0 && ent->v.team == check->v.team )
continue; // don't aim at teammate
for( j = 0; j < 3; j++ )
end[j] = check->v.origin[j] + 0.5 * (check->v.mins[j] + check->v.maxs[j]);
end[j] = check->v.origin[j] + 0.5f * (check->v.mins[j] + check->v.maxs[j]);
VectorSubtract( end, start, dir );
VectorNormalize( dir );
dist = DotProduct( dir, svgame.globals->v_forward );
@ -2021,6 +2065,8 @@ void pfnFreeEntPrivateData( edict_t *pEdict )
pEdict->pvPrivateData = NULL; // freed
}
#define HL_STRINGS
/*
=============
SV_AllocString
@ -2029,6 +2075,12 @@ SV_AllocString
*/
string_t SV_AllocString( const char *szValue )
{
if( sys_sharedstrings->integer )
{
const char *newString;
newString = com.stralloc( svgame.stringspool, szValue, __FILE__, __LINE__ );
return newString - svgame.globals->pStringBase;
}
return StringTable_SetString( svgame.hStringTable, szValue );
}
@ -2040,6 +2092,8 @@ SV_GetString
*/
const char *SV_GetString( string_t iString )
{
if( sys_sharedstrings->integer )
return (svgame.globals->pStringBase + iString);
return StringTable_GetString( svgame.hStringTable, iString );
}
@ -2086,7 +2140,7 @@ pfnIndexOfEdict
*/
int pfnIndexOfEdict( const edict_t *pEdict )
{
if( !pEdict || pEdict->free )
if( !SV_IsValidEdict( pEdict ))
return NULLENT_INDEX;
return NUM_FOR_EDICT( pEdict );
}
@ -2113,14 +2167,20 @@ debug routine
*/
edict_t* pfnFindEntityByVars( entvars_t *pvars )
{
edict_t *e = EDICT_NUM( 0 );
edict_t *e;
int i;
for( i = 0; i < svgame.globals->numEntities; i++, e++ )
// don't pass invalid arguments
if( !pvars ) return NULL;
for( i = 0; i < svgame.globals->numEntities; i++ )
{
if( e->free ) continue;
e = EDICT_NUM( i );
if( !memcmp( &e->v, pvars, sizeof( entvars_t )))
{
Msg( "FindEntityByVars: %s\n", SV_ClassName( e ));
return e; // found it
}
}
return NULL;
}
@ -3325,7 +3385,7 @@ bool SV_ParseEdict( script_t *script, edict_t *ent )
if( token.string[0] == '}' ) break; // end of desc
// anglehack is to allow QuakeEd to write single scalar angles
// and allow them to be turned into vectors. (FIXME...)
// and allow them to be turned into vectors.
if( !com.strcmp( token.string, "angle" ))
{
com.strncpy( token.string, "angles", sizeof( token.string ));
@ -3498,6 +3558,8 @@ void SV_SpawnEntities( const char *mapname, script_t *entities )
// spawn the rest of the entities on the map
SV_LoadFromFile( entities );
SV_FreeOldEntities (); // release all ents until map loading
MsgDev( D_NOTE, "Total %i entities spawned\n", svgame.globals->numEntities );
}
@ -3506,7 +3568,10 @@ void SV_UnloadProgs( void )
SV_DeactivateServer ();
svgame.dllFuncs.pfnGameShutdown ();
StringTable_Delete( svgame.hStringTable );
if( sys_sharedstrings->integer )
Mem_FreePool( &svgame.stringspool );
else StringTable_Delete( svgame.hStringTable );
FS_FreeLibrary( svgame.hInstance );
Mem_FreePool( &svgame.mempool );
@ -3550,8 +3615,19 @@ bool SV_LoadProgs( const char *name )
return false;
}
// 65535 unique strings should be enough ...
if( !sv.loadgame ) svgame.hStringTable = StringTable_Create( "Server", 0x10000 );
svgame.globals->pStringBase = ""; // setup string base
if( sys_sharedstrings->integer )
{
// just use Half-Life system - base pointer and malloc
svgame.stringspool = Mem_AllocPool( "Server Strings" );
}
else
{
// 65535 unique strings should be enough ...
svgame.hStringTable = StringTable_Create( "Server", 0x10000 );
}
svgame.globals->maxEntities = GI->max_edicts;
svgame.globals->maxClients = sv_maxclients->integer;
svgame.edicts = Mem_Alloc( svgame.mempool, sizeof( edict_t ) * svgame.globals->maxEntities );

View File

@ -226,7 +226,10 @@ void SV_DeactivateServer( void )
SV_FreeEdicts ();
sv.state = ss_dead;
StringTable_Clear( svgame.hStringTable );
if( sys_sharedstrings->integer )
Mem_EmptyPool( svgame.stringspool );
else StringTable_Clear( svgame.hStringTable );
svgame.dllFuncs.pfnServerDeactivate();
svgame.globals->maxEntities = GI->max_edicts;

View File

@ -24,7 +24,7 @@ cvar_t *sv_idealpitchscale;
cvar_t *sv_maxvelocity;
cvar_t *sv_gravity;
cvar_t *sv_stepheight;
cvar_t *sv_noreload; // don't reload level state when reentering
cvar_t *sv_noreload; // don't reload level state when reentering
cvar_t *sv_playersonly;
cvar_t *sv_rollangle;
cvar_t *sv_rollspeed;
@ -40,8 +40,9 @@ cvar_t *sv_stopspeed;
cvar_t *hostname;
cvar_t *sv_maxclients;
cvar_t *sv_check_errors;
cvar_t *public_server; // should heartbeats be sent
cvar_t *sv_reconnect_limit;// minimum seconds between connect messages
cvar_t *public_server; // should heartbeats be sent
cvar_t *sv_reconnect_limit; // minimum seconds between connect messages
cvar_t *serverinfo;
cvar_t *physinfo;
void Master_Shutdown (void);
@ -196,6 +197,28 @@ void SV_UpdateMovevars( void )
physinfo->modified = false;
}
void pfnUpdateServerInfo( const char *szKey, const char *szValue, const char *unused, void *unused2 )
{
cvar_t *cv = Cvar_FindVar( szKey );
if( !cv || !cv->modified ) return; // this cvar not changed
MSG_WriteByte( &sv.multicast, svc_serverinfo );
MSG_WriteString( &sv.multicast, szKey );
MSG_WriteString( &sv.multicast, szValue );
MSG_Send( MSG_ALL, vec3_origin, NULL );
cv->modified = false; // reset state
}
void SV_UpdateServerInfo( void )
{
if( !serverinfo->modified ) return;
Cvar_LookupVars( CVAR_SERVERINFO, NULL, NULL, pfnUpdateServerInfo );
serverinfo->modified = false;
}
/*
=================
SV_ReadPackets
@ -411,6 +434,9 @@ void SV_Frame( int time )
// let everything in the world think and move
SV_RunGameFrame ();
// refresh serverinfo on the client side
SV_UpdateServerInfo ();
// refresh physic movevars on the client side
SV_UpdateMovevars ();
@ -561,6 +587,7 @@ void SV_Init( void )
sv_check_errors = Cvar_Get( "sv_check_errors", "0", CVAR_ARCHIVE, "ignore physic engine errors" );
sv_synchthink = Cvar_Get( "sv_fast_think", "0", CVAR_ARCHIVE, "allows entities to think more often than the server framerate" );
physinfo = Cvar_Get( "@physinfo", "0", CVAR_READ_ONLY, "" ); // use ->modified value only
serverinfo = Cvar_Get( "@serverinfo", "0", CVAR_READ_ONLY, "" ); // use ->modified value only
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" );

View File

@ -42,7 +42,7 @@ SV_TestEntityPosition
returns true if the entity is in solid currently
============
*/
static bool SV_TestEntityPosition( edict_t *ent, const vec3_t offset )
bool SV_TestEntityPosition( edict_t *ent, const vec3_t offset )
{
vec3_t org;
trace_t trace;

View File

@ -344,19 +344,16 @@ void LandmarkOrigin( SAVERESTOREDATA *pSaveData, vec3_t output, const char *pLan
// if it contains any solid space? or would that eliminate some entities we want to keep?
int EntityInSolid( edict_t *ent )
{
vec3_t point;
edict_t *pParent = ent->v.aiment;
// HACKHACK -- If you're attached to a client, always go through
if( pParent )
if( SV_IsValidEdict( pParent ))
{
if( pParent->v.flags & FL_CLIENT )
return 0;
}
VectorAverage( ent->v.absmin, ent->v.absmax, point );
// FIXME: probably this is doesn't working correctly
return (SV_PointContents( point ) == CONTENTS_SOLID);
return SV_TestEntityPosition( ent, vec3_origin );
}
void SV_ClearSaveDir( void )
@ -1061,6 +1058,7 @@ int SV_CreateEntityTransitionList( SAVERESTOREDATA *pSaveData, int levelMask )
}
else if( active )
{
// create named entity
pent = SV_AllocPrivateData( NULL, pEntInfo->classname );
}
}
@ -1083,7 +1081,7 @@ int SV_CreateEntityTransitionList( SAVERESTOREDATA *pSaveData, int levelMask )
pSaveData->currentIndex = i;
SaveRestore_Seek( pSaveData, pEntInfo->location );
if( pent && ( pEntInfo->flags & levelMask )) // screen out the player if he's not to be spawned
if( SV_IsValidEdict( pent ) && ( pEntInfo->flags & levelMask )) // screen out the player if he's not to be spawned
{
if( pEntInfo->flags & FENTTABLE_GLOBAL )
{
@ -1099,7 +1097,7 @@ int SV_CreateEntityTransitionList( SAVERESTOREDATA *pSaveData, int levelMask )
}
else
{
MsgDev( D_INFO, "Transferring %s (%d)\n", STRING( pEntInfo->classname ), pent ? pent->serialnumber : -1 );
MsgDev( D_NOTE, "Transferring %s (%d)\n", STRING( pEntInfo->classname ), pent->serialnumber );
if( svgame.dllFuncs.pfnRestore( pent, pSaveData, false ) < 0 )
{
@ -1107,7 +1105,7 @@ int SV_CreateEntityTransitionList( SAVERESTOREDATA *pSaveData, int levelMask )
}
else
{
if( !( pEntInfo->flags & FENTTABLE_PLAYER ) && EntityInSolid( pent ))
if(!( pEntInfo->flags & FENTTABLE_PLAYER ) && EntityInSolid( pent ))
{
// this can happen during normal processing - PVS is just a guess,
// some map areas won't exist in the new map

View File

@ -13,7 +13,7 @@ int cvar_modifiedFlags;
cvar_t cvar_indexes[MAX_CVARS];
static cvar_t *hashTable[FILE_HASH_SIZE];
cvar_t *cvar_vars;
cvar_t *userinfo, *physinfo;
cvar_t *userinfo, *physinfo, *serverinfo;
/*
================
@ -361,7 +361,8 @@ cvar_t *Cvar_Set2 (const char *var_name, const char *value, bool force)
}
// nothing to change
if( !com.strcmp( value, var->string )) return var;
if( !com.strcmp( value, var->string ))
return var;
var->modified = true;
var->modificationCount++;
@ -371,6 +372,9 @@ cvar_t *Cvar_Set2 (const char *var_name, const char *value, bool force)
if( var->flags & CVAR_PHYSICINFO )
physinfo->modified = true; // transmit at next oportunity
if( var->flags & CVAR_SERVERINFO )
serverinfo->modified = true; // transmit at next oportunity
// free the old value string
Mem_Free( var->string );
@ -912,6 +916,7 @@ void Cvar_Init( void )
ZeroMemory( hashTable, sizeof( *hashTable ) * FILE_HASH_SIZE );
userinfo = Cvar_Get( "@userinfo", "0", CVAR_READ_ONLY, "" ); // use ->modified value only
physinfo = Cvar_Get( "@physinfo", "0", CVAR_READ_ONLY, "" ); // use ->modified value only
serverinfo = Cvar_Get( "@serverinfo", "0", CVAR_READ_ONLY, "" ); // use ->modified value only
Cmd_AddCommand ("toggle", Cvar_Toggle_f, "toggles a console variable's values (use for more info)" );
Cmd_AddCommand ("set", Cvar_Set_f, "create or change the value of a console variable" );

View File

@ -186,7 +186,7 @@ int DispatchCreate( edict_t *pent, const char *szName )
// Xash3D extension
// handle virtual entities here
// simple example for potentially weapon_generic
// just example for future weapon_generic
if( !strncmp( szName, "weapon_", 7 ))
{
CBasePlayerWeapon *pWeapon = GetClassPtr((CBasePlayerWeapon *)VARS( pent ));
@ -351,6 +351,7 @@ int DispatchRestore( edict_t *pent, SAVERESTOREDATA *pSaveData, int globalEntity
tmpRestore.ReadEntVars( "ENTVARS", &tmpVars );
// HACKHACK - reset the save pointers, we're going to restore for real this time
// NOTE: in Xash3D this pointers already sets by engine
pSaveData->size = pSaveData->pTable[pSaveData->currentIndex].location;
pSaveData->pCurrentData = pSaveData->pBaseData + pSaveData->size;
// -------------------
@ -471,7 +472,7 @@ void SaveReadFields( SAVERESTOREDATA *pSaveData, const char *pname, void *pBaseD
restoreHelper.ReadFields( pname, pBaseData, pFields, fieldCount );
}
void OnFreeEntPrivateData( edict_s *pEdict )
void OnFreeEntPrivateData( edict_t *pEdict )
{
if( pEdict && pEdict->pvPrivateData )
{

View File

@ -225,11 +225,6 @@ public:
m_MoveWith = ALLOC_STRING(pkvd->szValue);
pkvd->fHandled = TRUE;
}
else if (FStrEq(pkvd->szKeyName, "skill"))
{
m_iLFlags = atoi(pkvd->szValue);
pkvd->fHandled = TRUE;
}
else if (FStrEq(pkvd->szKeyName, "style"))
{
m_iStyle = atoi(pkvd->szValue);

View File

@ -853,6 +853,7 @@ void CGib :: Spawn( const char *szGibModel )
// pev->solid = SOLID_SLIDEBOX;/// hopefully this will fix the VELOCITY TOO LOW crap
pev->classname = MAKE_STRING("gib");
SetObjectClass( ED_NORMAL ); // AutoClassify can't determine gibs properly
SET_MODEL(ENT(pev), szGibModel);
UTIL_SetSize(pev, Vector( 0, 0, 0), Vector(0, 0, 0));

File diff suppressed because it is too large Load Diff

View File

@ -62,7 +62,7 @@ void CGraph :: InitGraph( void)
//
if ( m_pLinkPool )
{
FREE ( m_pLinkPool );
free ( m_pLinkPool );
m_pLinkPool = NULL;
}
@ -70,13 +70,13 @@ void CGraph :: InitGraph( void)
//
if ( m_pNodes )
{
FREE ( m_pNodes );
free ( m_pNodes );
m_pNodes = NULL;
}
if ( m_di )
{
FREE ( m_di );
free ( m_di );
m_di = NULL;
}
@ -84,13 +84,13 @@ void CGraph :: InitGraph( void)
//
if ( m_pRouteInfo )
{
FREE ( m_pRouteInfo );
free ( m_pRouteInfo );
m_pRouteInfo = NULL;
}
if (m_pHashLinks)
{
FREE ( m_pHashLinks );
free ( m_pHashLinks );
m_pHashLinks = NULL;
}
@ -112,7 +112,7 @@ void CGraph :: InitGraph( void)
int CGraph :: AllocNodes ( void )
{
// malloc all of the nodes
WorldGraph.m_pNodes = (CNode *)CALLOC ( sizeof ( CNode ), MAX_NODES );
WorldGraph.m_pNodes = (CNode *)calloc ( sizeof ( CNode ), MAX_NODES );
// could not malloc space for all the nodes!
if ( !WorldGraph.m_pNodes )
@ -1636,7 +1636,7 @@ void CTestHull :: BuildNodeGraph( void )
SetNextThink( 0 );
// malloc a swollen temporary connection pool that we trim down after we know exactly how many connections there are.
pTempPool = (CLink *)CALLOC ( sizeof ( CLink ) , ( WorldGraph.m_cNodes * MAX_NODE_INITIAL_LINKS ) );
pTempPool = (CLink *)calloc ( sizeof ( CLink ) , ( WorldGraph.m_cNodes * MAX_NODE_INITIAL_LINKS ) );
if ( !pTempPool )
{
ALERT ( at_aiconsole, "**Could not malloc TempPool!\n" );
@ -1660,7 +1660,7 @@ void CTestHull :: BuildNodeGraph( void )
if ( pTempPool )
{
FREE ( pTempPool );
free ( pTempPool );
}
return;
@ -1747,7 +1747,7 @@ void CTestHull :: BuildNodeGraph( void )
if ( pTempPool )
{
FREE ( pTempPool );
free ( pTempPool );
}
if ( file )
@ -1816,7 +1816,7 @@ void CTestHull :: BuildNodeGraph( void )
ALERT ( at_aiconsole, "**** j = %d ****\n", j );
if ( pTempPool )
{
FREE ( pTempPool );
free ( pTempPool );
}
if ( file )
@ -1927,14 +1927,14 @@ void CTestHull :: BuildNodeGraph( void )
cPoolLinks -= WorldGraph.RejectInlineLinks ( pTempPool, file );
// now malloc a pool just large enough to hold the links that are actually used
WorldGraph.m_pLinkPool = (CLink *) CALLOC ( sizeof ( CLink ), cPoolLinks );
WorldGraph.m_pLinkPool = (CLink *) calloc ( sizeof ( CLink ), cPoolLinks );
if ( !WorldGraph.m_pLinkPool )
{// couldn't make the link pool!
ALERT ( at_aiconsole, "Couldn't malloc LinkPool!\n" );
if ( pTempPool )
{
FREE ( pTempPool );
free ( pTempPool );
}
if ( file )
{// close the file
@ -2027,7 +2027,7 @@ void CTestHull :: BuildNodeGraph( void )
if ( pTempPool )
{// free the temp pool
FREE ( pTempPool );
free ( pTempPool );
}
if ( file )
@ -2358,7 +2358,7 @@ int CGraph :: FLoadGraph ( char *szMapName )
// Malloc for the nodes
//
m_pNodes = ( CNode * )CALLOC ( sizeof ( CNode ), m_cNodes );
m_pNodes = ( CNode * )calloc ( sizeof ( CNode ), m_cNodes );
if ( !m_pNodes )
{
@ -2376,7 +2376,7 @@ int CGraph :: FLoadGraph ( char *szMapName )
// Malloc for the link pool
//
m_pLinkPool = ( CLink * )CALLOC ( sizeof ( CLink ), m_cLinks );
m_pLinkPool = ( CLink * )calloc ( sizeof ( CLink ), m_cLinks );
if ( !m_pLinkPool )
{
@ -2393,7 +2393,7 @@ int CGraph :: FLoadGraph ( char *szMapName )
// Malloc for the sorting info.
//
m_di = (DIST_INFO *)CALLOC( sizeof(DIST_INFO), m_cNodes );
m_di = (DIST_INFO *)calloc( sizeof(DIST_INFO), m_cNodes );
if ( !m_di )
{
ALERT ( at_aiconsole, "***ERROR**\nCouldn't malloc %d entries sorting nodes!\n", m_cNodes );
@ -2410,7 +2410,7 @@ int CGraph :: FLoadGraph ( char *szMapName )
// Malloc for the routing info.
//
m_fRoutingComplete = FALSE;
m_pRouteInfo = (char *)CALLOC( sizeof(char), m_nRouteInfo );
m_pRouteInfo = (char *)calloc( sizeof(char), m_nRouteInfo );
if ( !m_pRouteInfo )
{
ALERT ( at_aiconsole, "***ERROR**\nCounldn't malloc %d route bytes!\n", m_nRouteInfo );
@ -2432,7 +2432,7 @@ int CGraph :: FLoadGraph ( char *szMapName )
// malloc for the hash links
//
m_pHashLinks = (short *)CALLOC(sizeof(short), m_nHashLinks);
m_pHashLinks = (short *)calloc(sizeof(short), m_nHashLinks);
if (!m_pHashLinks)
{
ALERT ( at_aiconsole, "***ERROR**\nCounldn't malloc %d hash link bytes!\n", m_nHashLinks );
@ -2831,7 +2831,7 @@ void CGraph::BuildLinkLookups(void)
m_nHashLinks = 3*m_cLinks/2 + 3;
HashChoosePrimes(m_nHashLinks);
m_pHashLinks = (short *)CALLOC(sizeof(short), m_nHashLinks);
m_pHashLinks = (short *)calloc(sizeof(short), m_nHashLinks);
if (!m_pHashLinks)
{
ALERT(at_aiconsole, "Couldn't allocated Link Lookup Table.\n");
@ -2864,11 +2864,11 @@ void CGraph::BuildLinkLookups(void)
void CGraph::BuildRegionTables(void)
{
if (m_di) FREE(m_di);
if (m_di) free(m_di);
// Go ahead and setup for range searching the nodes for FindNearestNodes
//
m_di = (DIST_INFO *)CALLOC(sizeof(DIST_INFO), m_cNodes);
m_di = (DIST_INFO *)calloc(sizeof(DIST_INFO), m_cNodes);
if (!m_di)
{
ALERT(at_aiconsole, "Couldn't allocated node ordering array.\n");
@ -3275,9 +3275,9 @@ void CGraph :: ComputeStaticRoutingTables( void )
}
else
{
char *Tmp = (char *)CALLOC(sizeof(char), (m_nRouteInfo + nRoute));
char *Tmp = (char *)calloc(sizeof(char), (m_nRouteInfo + nRoute));
memcpy(Tmp, m_pRouteInfo, m_nRouteInfo);
FREE ( m_pRouteInfo );
free ( m_pRouteInfo );
m_pRouteInfo = Tmp;
memcpy(m_pRouteInfo + m_nRouteInfo, pRoute, nRoute);
m_pNodes[ iFrom ].m_pNextBestNode[iHull][iCap] = m_nRouteInfo;
@ -3288,7 +3288,7 @@ void CGraph :: ComputeStaticRoutingTables( void )
else
{
m_nRouteInfo = nRoute;
m_pRouteInfo = (char *)CALLOC(sizeof(char), nRoute);
m_pRouteInfo = (char *)calloc(sizeof(char), nRoute);
memcpy(m_pRouteInfo, pRoute, nRoute);
m_pNodes[ iFrom ].m_pNextBestNode[iHull][iCap] = 0;
nTotalCompressedSize += CompressedSize;

View File

@ -3624,16 +3624,8 @@ void CBasePlayer::CheatImpulseCommands( int iImpulse )
{
case 76:
{
if (!giPrecacheGrunt)
{
giPrecacheGrunt = 1;
ALERT(at_debug, "You must now restart to use Grunt-o-matic.\n");
}
else
{
UTIL_MakeVectors( Vector( 0, pev->viewangles.y, 0 ) );
Create("monster_human_grunt", pev->origin + gpGlobals->v_forward * 128, pev->angles);
}
UTIL_MakeVectors( Vector( 0, pev->viewangles.y, 0 ) );
Create("monster_human_grunt", pev->origin + gpGlobals->v_forward * 128, pev->angles);
break;
}

View File

@ -319,6 +319,7 @@ CBaseMonster* CCineMonster :: FindEntity( const char* sName, CBaseEntity *pActiv
pEntity = UTIL_FindEntityByTargetname(NULL, sName, pActivator);
//m_hTargetEnt = NULL;
CBaseMonster *pMonster = NULL;
int numIterations = 0;
while (pEntity)
{

View File

@ -438,7 +438,7 @@ void CTripmine::PrimaryAttack( void )
SendWeaponAnim( TRIPMINE_ARM2 );
Vector angles = UTIL_VecToAngles( tr.vecPlaneNormal );
CBaseEntity *pEnt = CBaseEntity::Create( "monster_tripmine", tr.vecEndPos + tr.vecPlaneNormal * 4 + gpGlobals->v_up * -6, angles, m_pPlayer->edict() );
CBaseEntity *pEnt = CBaseEntity::Create( "monster_tripmine", tr.vecEndPos + tr.vecPlaneNormal * 5 + gpGlobals->v_up * -6, angles, m_pPlayer->edict() );
CTripmineGrenade *pMine = (CTripmineGrenade *)pEnt;
}
}

View File

@ -154,7 +154,7 @@ void CDecal :: TriggerDecal ( CBaseEntity *pActivator, CBaseEntity *pCaller, USE
WRITE_SHORT( (int)pev->skin );
entityIndex = (short)ENTINDEX(trace.pHit);
WRITE_SHORT( entityIndex );
if ( entityIndex )
if( entityIndex != NULLENT_INDEX )
WRITE_SHORT( (int)VARS(trace.pHit)->modelindex );
MESSAGE_END();

View File

@ -27,4 +27,4 @@ Xash 0.71 Beta 05.05.10
3. complete lights.shader
4. revision server physic
5. revision monster moving
6. fix save\restore global state
6. fix save\restore global state OK

View File

@ -3542,7 +3542,7 @@ void CreateTraceLightsForBounds( vec3_t mins, vec3_t maxs, vec3_t normal, int nu
void FreeTraceLights( light_trace_t *trace )
{
if( trace->lights != NULL )
if( trace->lights != NULL && Mem_IsAllocated( basepool, trace->lights ))
Mem_Free( trace->lights );
trace->lights = NULL;
}