17 Dec 2008

This commit is contained in:
g-cont 2008-12-17 00:00:00 +03:00 committed by Alibek Omarov
parent 845de86ee5
commit 8b5320bdda
6 changed files with 90 additions and 60 deletions

View File

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

View File

@ -400,8 +400,9 @@ bool SV_CreateMeshBuffer( edict_t *in, cmodel_t *out );
// sv_spawn.c
//
void SV_StartParticle( const float *org, const float *dir, int color, int count );
void SV_FreeEdict( edict_t *ed );
edict_t *SV_AllocEdict( void );
void SV_InitEdict( edict_t *pEdict );
void SV_FreeEdict( edict_t *pEdict );
bool SV_ClientConnect (edict_t *ent, char *userinfo);
void SV_TouchTriggers (edict_t *ent);

View File

@ -480,7 +480,8 @@ void SV_PutClientInServer( edict_t *ent )
sv_client_t *client;
edict_t *viewmodel;
int i;
Com_Assert( 1 );
index = NUM_FOR_EDICT( ent ) - 1;
client = ent->pvEngineData->client;

View File

@ -619,53 +619,62 @@ bool SV_EntitiesIn( bool mode, vec3_t v1, vec3_t v2 )
return true;
}
edict_t *SV_AllocEdict( void )
void SV_InitEdict( edict_t *pEdict )
{
edict_t *pEdict = svg.edicts;
int i;
// search for free entity
for( i = svs.globals->maxClients; i < svs.globals->numEntities; i++ )
{
pEdict = svg.edicts + i;
if( pEdict->free ) break;
}
if( i == svs.globals->numEntities )
{
if( ++svs.globals->numEntities == svs.globals->maxEntities )
{
MsgDev( D_ERROR, "SV_AllocEdict: no free edicts\n" );
return NULL;
}
}
Com_Assert( pEdict == NULL );
pEdict->v.pContainingEntity = pEdict; // make cross-links for consistency
pEdict->pvEngineData = (ed_priv_t *)Mem_Alloc( svs.mempool, sizeof( ed_priv_t ));
pEdict->pvServerData = NULL; // will be alloced later by pfnAllocPrivateData
pEdict->serialnumber = pEdict->pvEngineData->s.number = NUM_FOR_EDICT( pEdict );
pEdict->free = false;
return pEdict;
}
void SV_FreeEdict( edict_t *e )
void SV_FreeEdict( edict_t *pEdict )
{
// unlink from world
SV_UnlinkEdict( e );
pe->RemoveBody( e->pvEngineData->physbody );
SV_UnlinkEdict( pEdict );
pe->RemoveBody( pEdict->pvEngineData->physbody );
if( e->pvEngineData ) Mem_Free( e->pvEngineData );
if( e->pvServerData ) Mem_Free( e->pvServerData );
Mem_Set( &e->v, 0, sizeof( entvars_t ));
if( pEdict->pvEngineData ) Mem_Free( pEdict->pvEngineData );
if( pEdict->pvServerData ) Mem_Free( pEdict->pvServerData );
Mem_Set( &pEdict->v, 0, sizeof( entvars_t ));
e->pvEngineData = NULL;
e->pvServerData = NULL;
pEdict->pvEngineData = NULL;
pEdict->pvServerData = NULL;
// mark edict as freed
e->freetime = sv.time;
e->v.nextthink = -1;
e->serialnumber = 0;
e->free = true;
pEdict->freetime = sv.time;
pEdict->v.nextthink = -1;
pEdict->serialnumber = 0;
pEdict->free = true;
}
edict_t *SV_AllocEdict( void )
{
edict_t *pEdict;
int i;
for( i = svs.globals->maxClients + 1; i < svs.globals->numEntities; i++ )
{
pEdict = EDICT_NUM( i );
// the first couple seconds of server time can involve a lot of
// freeing and allocating, so relax the replacement policy
if( pEdict->free && ( pEdict->freetime < 2.0f || (sv.time - pEdict->freetime) > 0.5f ))
{
SV_InitEdict( pEdict );
return pEdict;
}
}
if( i == svs.globals->maxEntities )
Host_Error( "SV_AllocEdict: no free edicts\n" );
svs.globals->numEntities++;
pEdict = EDICT_NUM( i );
SV_InitEdict( pEdict );
return pEdict;
}
/*
@ -988,8 +997,6 @@ pfnPrecacheModel
*/
int pfnPrecacheModel( const char *s )
{
if( !com.strcmp( s, "" ))
return 0;
return SV_ModelIndex( s );
}
@ -1001,8 +1008,6 @@ pfnPrecacheSound
*/
int pfnPrecacheSound( const char *s )
{
if( !com.strcmp( s, "" ))
return 0;
return SV_SoundIndex( s );
}
@ -1526,8 +1531,10 @@ edict_t* pfnCreateNamedEntity( string_t className )
pszClassName = STRING( className );
ed = pfnCreateEntity();
ed->v.classname = className;
pszClassName = STRING( className );
// also register classname to send for client
Com_Assert( pszClassName == NULL || !pszClassName[0] );
ed->pvEngineData->s.classname = SV_ClassIndex( pszClassName );
return ed;
@ -2240,8 +2247,7 @@ pfnPvAllocEntPrivateData
*/
void *pfnPvAllocEntPrivateData( edict_t *pEdict, long cb )
{
Msg("Alloc %s\n", memprint( cb ));
Com_Assert( pEdict == NULL );
Msg("Edict: %s alloc %s\n", STRING( pEdict->v.classname ), memprint( cb ));
// to avoid multiple alloc
pEdict->pvServerData = (void *)Mem_Alloc( svs.private, cb );
@ -2270,7 +2276,12 @@ FIXME: make work
*/
string_t pfnAllocString( const char *szValue )
{
return ED_NewString( szValue, svs.stringpool ) - svs.globals->pStringBase;
string_t str;
str = ED_NewString( szValue, svs.stringpool ) - svs.globals->pStringBase;
Msg("AllocString: %s\n", STRING( str ));
return str;
}
/*
@ -3028,8 +3039,11 @@ bool SV_ParseEdict( script_t *script, edict_t *ent )
return false;
}
SpawnEdict( NULL ); // same as ED_Alloc
Com_Assert( 1 );
// apply edict classnames
ent->pvEngineData->s.classname = SV_ClassIndex( classname );
ent->v.classname = pfnAllocString( classname );
SpawnEdict( &ent->v );
// apply classname to keyvalue containers and parse fields
for( i = 0; i < numpairs; i++ )
@ -3038,9 +3052,6 @@ bool SV_ParseEdict( script_t *script, edict_t *ent )
pkvd[i].szClassName = (char *)classname;
svs.dllFuncs.pfnKeyValue( ent, &pkvd[i] );
}
// initialize network classname
ent->pvEngineData->s.classname = SV_ClassIndex( classname );
return true;
}
@ -3060,7 +3071,8 @@ void SV_LoadFromFile( script_t *entities )
{
token_t token;
int inhibited, spawned, died;
edict_t *ent = svg.edicts;
bool create_world = true;
edict_t *ent;
inhibited = 0;
spawned = 0;
@ -3072,12 +3084,25 @@ void SV_LoadFromFile( script_t *entities )
if( token.string[0] != '{' )
Host_Error( "SV_LoadFromFile: found %s when expecting {\n", token.string );
if( create_world )
{
create_world = false;
ent = EDICT_NUM( 0 );
SV_InitEdict( ent );
}
else ent = SV_AllocEdict();
if( !SV_ParseEdict( entities, ent ))
continue;
spawned++;
if( ent->free ) died++;
Msg("SpawnEntity: %s\n", STRING( ent->v.classname ));
if( svs.dllFuncs.pfnSpawn( ent ) == -1 )
died++;
else spawned++;
}
MsgDev( D_INFO, "%i entities inhibited\n", inhibited );
Com_Assert( 1 );
}
/*
@ -3111,14 +3136,15 @@ void SV_SpawnEntities( const char *mapname, script_t *entities )
SV_LoadFromFile( entities );
// set client fields on player ents
/*
for( i = 0; i < svs.globals->maxClients; i++ )
{
// setup all clients
ent = EDICT_NUM( i + 1 );
SV_InitEdict( ent );
ent->pvEngineData->client = svs.clients + i;
}
*/
Msg("Total %i entities spawned\n", svs.globals->numEntities );
}
void SV_UnloadProgs( void )
@ -3187,7 +3213,7 @@ bool SV_LoadProgs( const char *name )
}
// get pointer as really static object
svs.globals->pStringBase = (const char *)&svs;
svs.globals->pStringBase = (const char *)GiveFnptrsToDll;
svs.globals->maxEntities = host.max_edicts;
svs.globals->maxClients = Host_MaxClients();
svg.edicts = Mem_Alloc( svs.mempool, sizeof( edict_t ) * svs.globals->maxEntities );

View File

@ -1772,6 +1772,8 @@ void SV_Physics( void )
svs.globals->time = sv.time;
// svs.dllFuncs.pfnEndFrame();
Msg("NumEnts %d\n", svs.globals->numEntities - 1 );
// decrement svs.globals->numEntities if the highest number entities died
for( ; EDICT_NUM( svs.globals->numEntities - 1)->free; svs.globals->numEntities-- );

View File

@ -43,7 +43,7 @@ RSC=rc.exe
# PROP Ignore_Export_Lib 1
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /YX /c
# ADD CPP /nologo /GB /MD /W3 /O2 /I "./" /I "./ents" /I "./game" /I "./global" /I "./monsters" /I "../public" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /FD /c
# ADD CPP /nologo /MD /W3 /O2 /I "./" /I "./ents" /I "./game" /I "./global" /I "./monsters" /I "../public" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /FD /c
# SUBTRACT CPP /Fr /YX
# ADD BASE MTL /nologo /D "NDEBUG" /win32
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
@ -61,8 +61,8 @@ TargetDir=\Xash3D\src_main\temp\server\!release
InputPath=\Xash3D\src_main\temp\server\!release\server.dll
SOURCE="$(InputPath)"
"D:\Xash3D\xash\bin\server.dll" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
copy $(TargetDir)\server.dll "D:\Xash3D\xash\bin\server.dll"
"D:\Xash3D\tmpQuArK\bin\server.dll" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
copy $(TargetDir)\server.dll "D:\Xash3D\tmpQuArK\bin\server.dll"
# End Custom Build
@ -82,7 +82,7 @@ SOURCE="$(InputPath)"
# PROP Target_Dir ""
# ADD BASE CPP /nologo /G5 /MT /W3 /O2 /I "..\server" /I "..\common\engine" /I "..\common" /I "..\server\ents" /I "..\server\global" /I "..\server\weapons" /I "..\server\game" /I "..\server\monsters" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /YX /FD /c
# SUBTRACT BASE CPP /Fr
# ADD CPP /nologo /GB /MDd /W3 /Gm /Gi /GX /ZI /Od /I "./" /I "./ents" /I "./game" /I "./global" /I "./monsters" /I "../public" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /FR /FD /c
# ADD CPP /nologo /MDd /W3 /Gm /Gi /GX /ZI /Od /I "./" /I "./ents" /I "./game" /I "./global" /I "./monsters" /I "../public" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /FR /FD /c
# SUBTRACT CPP /u /YX
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
@ -101,8 +101,8 @@ TargetDir=\Xash3D\src_main\temp\server\!debug
InputPath=\Xash3D\src_main\temp\server\!debug\server.dll
SOURCE="$(InputPath)"
"D:\Xash3D\xash\bin\server.dll" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
copy $(TargetDir)\server.dll "D:\Xash3D\xash\bin\server.dll"
"D:\Xash3D\tmpQuArK\bin\server.dll" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
copy $(TargetDir)\server.dll "D:\Xash3D\tmpQuArK\bin\server.dll"
# End Custom Build