Browse Source

engine: server: restore original PEntityOfEntIndex function, but still bug-compatible with GoldSrc

pull/2/head
Alibek Omarov 2 years ago
parent
commit
c326853617
  1. 15
      engine/server/sv_game.c

15
engine/server/sv_game.c

@ -61,19 +61,26 @@ qboolean SV_CheckEdict( const edict_t *e, const char *file, const int line )
#endif #endif
static edict_t *SV_PEntityOfEntIndex( const int iEntIndex, const qboolean allentities ) static edict_t *SV_PEntityOfEntIndex( const int iEntIndex, const qboolean allentities )
{
if( iEntIndex >= 0 && iEntIndex < GI->max_edicts )
{ {
edict_t *pEdict = EDICT_NUM( iEntIndex ); edict_t *pEdict = EDICT_NUM( iEntIndex );
qboolean player = allentities ? iEntIndex <= svs.maxclients : iEntIndex < svs.maxclients; qboolean player = allentities ? iEntIndex <= svs.maxclients : iEntIndex < svs.maxclients;
if( !SV_IsValidEdict( pEdict )) if( !iEntIndex || FBitSet( host.features, ENGINE_QUAKE_COMPATIBLE ))
return NULL; return pEdict; // just get access to array
if( !player && !pEdict->pvPrivateData ) if( SV_IsValidEdict( pEdict ) && pEdict->pvPrivateData )
return NULL; return pEdict;
// g-cont: world and clients can be accessed even without private data
if( SV_IsValidEdict( pEdict ) && player )
return pEdict; return pEdict;
} }
return NULL;
}
/* /*
============= =============

Loading…
Cancel
Save