UFO: Alien Invasion
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
g_edicts.cpp File Reference

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

#include "g_edicts.h"
#include "g_actor.h"

Go to the source code of this file.

Functions

EdictG_EdictsConstruct (void)
 Allocate space for the entity pointers. More...
 
void G_EdictsInit (void)
 Reset the entity pointers for eg. a new game. More...
 
int G_EdictsGetNumber (const Edict *ent)
 Get an entity's ID number. More...
 
bool G_EdictsIsValidNum (const int num)
 Check if the given number could point to an existing entity. More...
 
EdictG_EdictsGetByNum (const int num)
 Get an entity by it's number. More...
 
EdictG_EdictsGetFirst (void)
 Returns the first entity. More...
 
EdictG_EdictsGetNext (Edict *lastEnt)
 Iterate through the list of entities. More...
 
EdictG_EdictDuplicate (const Edict *edict)
 
EdictG_EdictsGetNewEdict (void)
 Find an entity that is not in use. More...
 
EdictG_EdictsGetNextInUse (Edict *lastEnt)
 Iterate through the entities that are in use. More...
 
EdictG_EdictsGetTriggerNextMaps (Edict *lastEnt)
 Iterator through all the trigger_nextmap edicts. More...
 
ActorG_EdictsGetNextLivingActor (Actor *lastEnt)
 Iterate through the living actor entities. More...
 
ActorG_EdictsGetNextLivingActorOfTeam (Actor *lastEnt, const int team)
 Iterate through the living actor entities of the given team. More...
 
ActorG_EdictsGetNextActor (Actor *lastEnt)
 Iterate through the actor entities (even the dead!) More...
 
ActorG_EdictsGetActorByUCN (const int ucn, const int team)
 Searches an actor by a unique character number. More...
 
ActorG_EdictsGetLivingActorFromPos (const pos3_t pos)
 Searches an actor at the given grid location. More...
 
EdictG_EdictsFindTargetEntity (const char *target)
 Searches the edict that has the given target as targetname set. More...
 
void G_EdictsThink (void)
 Called every frame to let the edicts tick. More...
 
ActormakeActor (Edict *ent)
 Convert an Edict pointer into an Actor pointer. More...
 

Variables

static Edictg_edicts
 

Detailed Description

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

Definition in file g_edicts.cpp.

Function Documentation

Edict* G_EdictDuplicate ( const Edict edict)
Edict* G_EdictsConstruct ( 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 39 of file g_edicts.cpp.

References g_edicts, G_TagMalloc, game, game_locals_s::sv_maxentities, and TAG_GAME.

Referenced by G_Init().

Edict* G_EdictsFindTargetEntity ( const char *  target)

Searches the edict that has the given target as targetname set.

Parameters
targetThe target name of the edict that you are searching
Returns
nullptr if no edict with the given target name was found, otherwise the edict that has the targetname set you were looking for.

Definition at line 290 of file g_edicts.cpp.

References G_EdictsGetNextInUse(), Q_streq, and Edict::targetname.

Referenced by G_MissionUse(), and Touch_TouchTrigger().

Actor* G_EdictsGetActorByUCN ( const int  ucn,
const int  team 
)

Searches an actor by a unique character number.

Parameters
[in]ucnThe unique character number
[in]teamThe team to get the actor with the ucn from
Returns
The actor edict if found, otherwise nullptr

Definition at line 254 of file g_edicts.cpp.

References Edict::chr, G_EdictsGetNextActor(), Edict::getTeam(), and character_s::ucn.

Referenced by G_ClientInitActorStates().

Edict* G_EdictsGetByNum ( const int  num)

Get an entity by it's number.

Parameters
[in]numThe entity's index in the array of entities

Definition at line 83 of file g_edicts.cpp.

References G_EdictsIsValidNum(), and gi.

Referenced by AI_CheckLineOfFire(), G_ClientAction(), G_EventShoot(), G_ShootGrenade(), G_ShootSingle(), ReactionFireTargets::notifyClientMove(), ReactionFireTargets::notifyClientOnShot(), and ReactionFireTargets::notifyClientOnStep().

Edict* 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 98 of file g_edicts.cpp.

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

Actor* G_EdictsGetLivingActorFromPos ( const pos3_t  pos)

Searches an actor at the given grid location.

Parameters
posThe grid location to look for an edict.
Returns
nullptr if nothing was found, otherwise the actor located at the given grid position.

Definition at line 270 of file g_edicts.cpp.

References G_EdictsGetNextLivingActor(), Edict::pos, and VectorCompare.

Referenced by G_ActorShouldStopInMidMove(), G_ClientGetFreeSpawnPoint(), G_ClientShoot(), and G_SpawnItemOnFloor().

Edict* G_EdictsGetNewEdict ( void  )

Find an entity that is not in use.

Definition at line 141 of file g_edicts.cpp.

References G_EdictsGetNext(), game, globals, Edict::inuse, game_export_s::num_edicts, and game_locals_s::sv_maxentities.

Referenced by G_EdictDuplicate(), and G_Spawn().

Edict* G_EdictsGetNext ( Edict lastEnt)

Iterate through the list of entities.

Parameters
lastEntThe entity found in the previous iteration; if nullptr, we start at the beginning

Definition at line 107 of file g_edicts.cpp.

References g_edicts, globals, and game_export_s::num_edicts.

Referenced by G_EdictsGetNewEdict(), and G_EdictsGetNextInUse().

Actor* G_EdictsGetNextActor ( Actor lastEnt)

Iterate through the actor entities (even the dead!)

Parameters
lastEntThe entity found in the previous iteration; if nullptr, we start at the beginning

Definition at line 231 of file g_edicts.cpp.

References G_EdictsGetNextInUse(), G_IsActor, globals, game_export_s::num_edicts, and Sys_Error().

Referenced by AIL_squad(), G_ClientEndRound(), G_EdictsGetActorByUCN(), G_MatchSendResults(), G_SendInvisible(), and G_SendPlayerStats().

Actor* G_EdictsGetNextLivingActorOfTeam ( Actor lastEnt,
const int  team 
)

Iterate through the living actor entities of the given team.

Parameters
lastEntThe entity found in the previous iteration; if nullptr, we start at the beginning
teamThe team we are looking for

Definition at line 216 of file g_edicts.cpp.

References G_EdictsGetNextLivingActor(), and Edict::getTeam().

Referenced by AI_CheckFF(), AI_CheckForMissionTargets(), AI_FighterCalcActionScore(), AI_PlayerRun(), AIL_waypoints(), G_BleedWounds(), G_GiveTimeUnits(), G_MatchEndCheck(), G_MoraleBehaviour(), G_ReactionFireReset(), G_RoundTouchTriggers(), G_TeamPointVis(), G_UpdateCarriedWeight(), G_UpdateStunState(), and TEST_F().

int G_EdictsGetNumber ( const Edict ent)

Get an entity's ID number.

Parameters
entThe 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 60 of file g_edicts.cpp.

References g_edicts, globals, and game_export_s::num_edicts.

Referenced by G_EdictDuplicate(), and G_Spawn().

Edict* G_EdictsGetTriggerNextMaps ( Edict lastEnt)

Iterator through all the trigger_nextmap edicts.

Parameters
lastEntThe entity found in the previous iteration; if nullptr, we start at the beginning

Definition at line 181 of file g_edicts.cpp.

References G_EdictsGetNextInUse(), and G_IsTriggerNextMap.

Referenced by G_MatchEndTrigger().

void G_EdictsInit ( void  )

Reset the entity pointers for eg. a new game.

Definition at line 48 of file g_edicts.cpp.

References game, i, and game_locals_s::sv_maxentities.

Referenced by G_SpawnEntities().

bool 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]numThe entity's index in the array of entities

Definition at line 72 of file g_edicts.cpp.

References globals, and game_export_s::num_edicts.

Referenced by G_EdictsGetByNum().

void G_EdictsThink ( void  )

Called every frame to let the edicts tick.

Definition at line 306 of file g_edicts.cpp.

References G_EdictsGetNextInUse(), level, Edict::nextthink, SERVER_FRAME_SECONDS, Edict::think, and level_locals_s::time.

Referenced by G_RunFrame().

Variable Documentation

Edict* g_edicts
static

This is where we store the edicts

Definition at line 33 of file g_edicts.cpp.

Referenced by G_EdictsConstruct(), G_EdictsGetNext(), and G_EdictsGetNumber().