g_edicts.c File Reference

functions to handle the storage of all edicts in the game module. More...

#include "g_local.h"
Include dependency graph for g_edicts.c:

Go to the source code of this file.

Functions

edict_tG_EdictsInit (void)
 Allocate space for the entity pointers.
void G_EdictsReset (void)
 Reset the entity pointers for eg. a new game.
int G_EdictsGetNumber (const edict_t *ent)
 Get an entity's ID number.
qboolean G_EdictsIsValidNum (const int num)
 Check if the given number could point to an existing entity.
edict_tG_EdictsGetByNum (const int num)
 Get an entity by it's number.
edict_tG_EdictsGetFirst (void)
 Returns the first entity.
edict_tG_EdictsGetNext (edict_t *lastEnt)
 Iterate through the list of entities.
edict_tG_EdictsGetNewEdict (void)
 Find an entity that is not in use.
edict_tG_EdictsGetNextInUse (edict_t *lastEnt)
 Iterate through the entities that are in use.
edict_tG_EdictsGetNextLivingActor (edict_t *lastEnt)
 Iterate through the living actor entities.
edict_tG_EdictsGetNextLivingActorOfTeam (edict_t *lastEnt, const int team)
 Iterate through the living actor entities of the given team.
edict_tG_EdictsGetNextActor (edict_t *lastEnt)
 Iterate through the actor entities (even the dead! - but skips the invisible).
void G_EdictCalcOrigin (edict_t *ent)
 Calculate the edict's origin vector from it's grid position.
void G_EdictSetOrigin (edict_t *ent, const pos3_t newPos)
 Set the edict's pos and origin vector to the given grid position.
qboolean G_EdictPosIsSameAs (edict_t *ent, const pos3_t cmpPos)
 Set the edict's pos and origin vector to the given grid position.

Variables

static edict_tg_edicts

Detailed Description

functions to handle the storage of all edicts in the game module.

Definition in file g_edicts.c.


Function Documentation

void G_EdictCalcOrigin ( edict_t ent  ) 

Calculate the edict's origin vector from it's grid position.

Parameters:
ent The entity

Definition at line 218 of file g_edicts.c.

References edict_s::fieldSize, gi, edict_s::origin, edict_s::pos, and game_import_t::routingMap.

Referenced by AI_FindHerdLocation(), AI_FindHidingLocation(), G_Actor2x2Spawn(), G_ActorFall(), G_ActorSpawn(), G_ClientMove(), G_SpawnEntities(), G_SpawnFloor(), and SP_civilian_target().

qboolean G_EdictPosIsSameAs ( edict_t ent,
const pos3_t  cmpPos 
)

Set the edict's pos and origin vector to the given grid position.

Parameters:
ent The entity
newPos The grid position to compare to
Returns:
qtrue if positions are equal

Definition at line 240 of file g_edicts.c.

References edict_s::pos, and VectorCompare.

Referenced by G_ClientShoot(), and G_ShootSingle().

void G_EdictSetOrigin ( edict_t ent,
const pos3_t  newPos 
)

Set the edict's pos and origin vector to the given grid position.

Parameters:
ent The entity
newPos The new grid position

Definition at line 228 of file g_edicts.c.

References edict_s::fieldSize, gi, edict_s::origin, edict_s::pos, game_import_t::routingMap, and VectorCopy.

Referenced by AI_CivilianCalcBestAction(), AI_FighterCalcBestAction(), AIL_positionherd(), and AIL_positionhide().

edict_t* G_EdictsGetByNum ( const int  num  ) 

Get an entity by it's number.

Parameters:
[in] num The entity's index in the array of entities

Definition at line 81 of file g_edicts.c.

References G_EdictsIsValidNum(), and gi.

Referenced by G_ClientAction().

edict_t* G_EdictsGetFirst ( void   ) 

Returns the first entity.

Note:
This is always a world edict - but in case of rma there might be several parts of the world spread all over the array.

Definition at line 96 of file g_edicts.c.

Referenced by G_ClientSendEdictsAndBrushModels(), G_FindEdictGroups(), G_SendBoundingBoxes(), and G_SpawnEntities().

edict_t* G_EdictsGetNewEdict ( void   ) 

Find an entity that is not in use.

Definition at line 130 of file g_edicts.c.

References G_EdictsGetNext(), game, globals, edict_s::inuse, game_export_t::num_edicts, and game_locals_t::sv_maxentities.

Referenced by G_Spawn().

edict_t* G_EdictsGetNext ( edict_t lastEnt  ) 

Iterate through the list of entities.

Parameters:
lastEnt The entity found in the previous iteration; if NULL, we start at the beginning

Definition at line 105 of file g_edicts.c.

References globals, and game_export_t::num_edicts.

Referenced by G_ClientGetFreeSpawnPoint(), G_EdictsGetNewEdict(), G_EdictsGetNextInUse(), and G_FindTargetEntity().

edict_t* G_EdictsGetNextActor ( edict_t lastEnt  ) 

Iterate through the actor entities (even the dead! - but skips the invisible).

Parameters:
lastEnt The entity found in the previous iteration; if NULL, we start at the beginning

Definition at line 201 of file g_edicts.c.

References G_EdictsGetNextInUse(), G_IsActor, globals, and game_export_t::num_edicts.

Referenced by AIL_Cleanup(), G_ActorGetByUCN(), G_MatchSendResults(), G_SendInvisible(), and G_SendPlayerStats().

edict_t* G_EdictsGetNextInUse ( edict_t lastEnt  ) 

Iterate through the entities that are in use.

Note:
we can hopefully get rid of this function once we know when it makes sense to iterate through entities that are NOT in use
Parameters:
lastEnt The entity found in the previous iteration; if NULL, we start at the beginning

Definition at line 155 of file g_edicts.c.

References G_EdictsGetNext(), and edict_s::inuse.

Referenced by AI_CheckForMissionTargets(), AI_SearchDestroyableObject(), G_BuildForbiddenList(), G_CheckVisPlayer(), G_CheckVisTeamAll(), G_ClearVisFlags(), G_ClientSendEdictsAndBrushModels(), G_CompleteRecalcRouting(), G_EdictsGetNextActor(), G_EdictsGetNextLivingActor(), G_Find(), G_FindEdictGroups(), G_FindRadius(), G_GenerateEntList(), G_GetEdictFromPos(), G_MatchSendResults(), G_MissionThink(), G_Morale(), G_MoraleBehaviour(), G_PhysicsRun(), G_ResetTriggers(), G_SendBoundingBoxes(), G_SplashDamage(), and G_TestVis().

edict_t* G_EdictsGetNextLivingActor ( edict_t lastEnt  ) 
edict_t* G_EdictsGetNextLivingActorOfTeam ( edict_t lastEnt,
const int  team 
)

Iterate through the living actor entities of the given team.

Parameters:
lastEnt The entity found in the previous iteration; if NULL, we start at the beginning
team The team we are looking for

Definition at line 186 of file g_edicts.c.

References G_EdictsGetNextLivingActor(), and edict_s::team.

Referenced by AI_CheckFF(), AI_FindHerdLocation(), AI_Run(), G_GiveTimeUnits(), G_MatchEndCheck(), G_ReactionFireReset(), G_TeamPointVis(), and G_UpdateStunState().

int G_EdictsGetNumber ( const edict_t ent  ) 

Get an entity's ID number.

Parameters:
ent The entity
Returns:
the entity's ID number, currently the index in the array
Note:
DO NOT use this number as anything other than an identifier !

Definition at line 58 of file g_edicts.c.

References globals, and game_export_t::num_edicts.

Referenced by G_InitEdict().

edict_t* G_EdictsInit ( void   ) 

Allocate space for the entity pointers.

Note:
No need to set it to zero, G_TagMalloc will do that for us

Definition at line 38 of file g_edicts.c.

References G_TagMalloc, game, game_locals_t::sv_maxentities, and TAG_GAME.

Referenced by G_Init().

qboolean G_EdictsIsValidNum ( const int  num  ) 

Check if the given number could point to an existing entity.

Note:
entity must also be 'in use' to be really valid
Parameters:
[in] num The entity's index in the array of entities

Definition at line 70 of file g_edicts.c.

References globals, game_export_t::num_edicts, qfalse, and qtrue.

Referenced by G_EdictsGetByNum().

void G_EdictsReset ( void   ) 

Reset the entity pointers for eg. a new game.

Definition at line 47 of file g_edicts.c.

References game, and game_locals_t::sv_maxentities.

Referenced by G_SpawnEntities().


Variable Documentation

edict_t* g_edicts [static]

This is where we store the edicts

Definition at line 32 of file g_edicts.c.


Generated by  doxygen 1.6.2