UFO: Alien Invasion
Loading...
Searching...
No Matches
cl_localentity.cpp File Reference

Local entity management. More...

#include "../client.h"
#include "cl_localentity.h"
#include "../sound/s_main.h"
#include "../sound/s_sample.h"
#include "cl_particle.h"
#include "cl_actor.h"
#include "cl_hud.h"
#include "../renderer/r_mesh_anim.h"
#include "../renderer/r_draw.h"
#include "../../common/tracing.h"
#include "../../common/grid.h"
#include "../../shared/moveclip.h"
Include dependency graph for cl_localentity.cpp:

Go to the source code of this file.

Data Structures

class  MoveClipCL
 Client side moveclip. More...

Functions

static void LE_GenerateInlineModelList (void)
static void CL_GridRecalcRouting (const le_t *le)
void CL_CompleteRecalcRouting (void)
void CL_RecalcRouting (const le_t *le)
static void LM_AddToSceneOrder (bool parents)
void LM_AddToScene (void)
 Add the local models to the scene.
static localModel_tLM_Find (int entnum)
 Checks whether a local model with the same entity number is already registered.
void LE_LinkFloorContainer (le_t *le)
 link any floor container into the actor temp floor container
bool LE_IsActor (const le_t *le)
 Checks whether the given le is a living actor.
bool LE_IsLivingActor (const le_t *le)
 Checks whether the given le is a living actor (but might be hidden).
bool LE_IsLivingAndVisibleActor (const le_t *le)
 Checks whether the given le is a living and visible actor.
void LM_Register (void)
 Register misc_models.
void LE_SetThink (le_t *le, localEntityThinkFunc_t think)
localModel_tLM_GetByID (const char *id)
localModel_tLM_AddModel (const char *model, const vec3_t origin, const vec3_t angles, int entnum, int levelflags, int renderFlags, const vec3_t scale)
 Prepares local (not known or handled by the server) models to the map, which will be added later in LM_AddToScene().
void LE_ExecuteThink (le_t *le)
 Call think function for the given local entity if its still in use.
void LE_Think (void)
 Calls the le think function and updates the animation. The animation updated even if the particular local entity is invisible for the client. This ensures, that an animation is always lerped correctly and won't magically start again once the local entity gets visible again.
void LM_Think (void)
const char * LE_GetAnim (const char *anim, int right, int left, int state)
 Get the correct animation for the given actor state and weapons.
void LET_StartIdle (le_t *le)
 Change the animation of an actor to the idle animation (which can be panic, dead or stand).
static void LE_PlaySoundFileForContents (le_t *le, int contents)
 Plays sound of content for moving actor.
static void LE_PlaySoundFileAndParticleForSurface (le_t *le, const char *textureName)
 Plays step sounds and draw particles for different terrain types.
int LE_ActorGetStepTime (const le_t *le, const pos3_t pos, const pos3_t oldPos, const int dir, const int speed)
static void LE_PlayFootStepSound (le_t *le)
static void LE_DoPathMove (le_t *le)
void LE_DoEndPathMove (le_t *le)
 Ends the move of an actor.
static void LE_ActorBodyHit (const le_t *le, const vec3_t impact, int normal)
 Spawns particle effects for a hit actor.
static void LET_PathMove (le_t *le)
 Move the actor along the path to the given location.
void LET_StartPathMove (le_t *le)
 Change the actors animation to walking.
void LET_HiddenMove (le_t *le)
 Handle move for invisible actors.
static void LET_Projectile (le_t *le)
void LE_AddProjectile (const fireDef_t *fd, int flags, const vec3_t muzzle, const vec3_t impact, int normal, le_t *leVictim)
static const objDef_tLE_BiggestItem (const Item *ic)
 Returns the index of the biggest item in the inventory list.
void LE_PlaceItem (le_t *le)
void LE_AddGrenade (const fireDef_t *fd, int flags, const vec3_t muzzle, const vec3_t v0, int dt, le_t *leVictim)
bool LE_BrushModelAction (le_t *le, entity_t *ent)
 Add function for brush models.
void LET_BrushModel (le_t *le)
void LMT_Init (localModel_t *localModel)
void LET_RotateDoor (le_t *le, int speed)
 Rotates a door in the given speed.
void LET_SlideDoor (le_t *le, int speed)
 Slides a door.
void LE_AddAmbientSound (const char *sound, const vec3_t origin, int levelflags, float volume, float attenuation)
 Adds ambient sounds from misc_sound entities.
le_tLE_Add (int entnum)
 Add a new local entity to the scene.
void _LE_NotFoundError (int entnum, int type, const char *file, const int line)
void LE_CenterView (const le_t *le)
 Center the camera on the local entity's origin.
le_tLE_Get (int entnum)
 Searches all local entities for the one with the searched entnum.
bool LE_IsLocked (int entnum)
 Checks if a given le_t structure is locked, i.e., used by another event at this time.
void LE_Lock (le_t *le)
 Markes a le_t struct as locked. Should be called at the beginning of an event handler on this le_t, and paired with a LE_Unlock at the end.
void LE_Unlock (le_t *le)
 Unlocks a previously locked le_t struct.
le_tLE_GetFromPos (const pos3_t pos)
 Searches a local entity on a given grid field.
le_tLE_GetNext (le_t *lastLE)
 Iterate through the list of entities.
le_tLE_GetNextInUse (le_t *lastLE)
 Iterate through the entities that are in use.
le_tLE_FindRadius (le_t *from, const vec3_t org, float rad, entity_type_t type)
 Returns entities that have origins within a spherical area.
le_tLE_Find (entity_type_t type, const pos3_t pos)
 Searches a local entity on a given grid field.
static bool LE_IsOriginBrush (const le_t *const le)
static void LE_AddEdictHighlight (const le_t *le)
 Adds a box that highlights the current active door.
void LE_AddToScene (void)
void LE_Cleanup (void)
 Cleanup unused LE inventories that the server sent to the client also free some unused LE memory.
const cBspModel_tLE_GetClipModel (const le_t *le)
model_tLE_GetDrawModel (unsigned int index)
static int32_t CL_HullForEntity (const le_t *le, int *tile, vec3_t rmaShift, vec3_t angles)
 Returns a headnode that can be used for testing or clipping an object of mins/maxs size. Offset is filled in to contain the adjustment that must be added to the testing object's origin to get a point to use with the returned hull.
static void CL_ClipMoveToLEs (MoveClipCL *clip)
 Clip against solid entities.
trace_t CL_Trace (const Line &traceLine, const AABB &box, const le_t *passle, le_t *passle2, int contentmask, int worldLevel)
 Moves the given mins/maxs volume through the world from start to end.

Variables

cvar_tcl_le_debug
cvar_tcl_trace_debug
cvar_tcl_map_draw_rescue_zone

Detailed Description

Local entity management.

Definition in file cl_localentity.cpp.

Function Documentation

◆ _LE_NotFoundError()

void _LE_NotFoundError ( int entnum,
int type,
const char * file,
const int line )

Definition at line 1239 of file cl_localentity.cpp.

References Cmd_ExecuteString(), Com_Error(), ERR_DROP, and type.

◆ CL_ClipMoveToLEs()

◆ CL_CompleteRecalcRouting()

void CL_CompleteRecalcRouting ( void )
See also
G_CompleteRecalcRouting

Definition at line 128 of file cl_localentity.cpp.

References cl, CL_GridRecalcRouting(), Com_Printf(), i, and LE_GenerateInlineModelList().

Referenced by CL_Reset().

◆ CL_GridRecalcRouting()

◆ CL_HullForEntity()

int32_t CL_HullForEntity ( const le_t * le,
int * tile,
vec3_t rmaShift,
vec3_t angles )
static

Returns a headnode that can be used for testing or clipping an object of mins/maxs size. Offset is filled in to contain the adjustment that must be added to the testing object's origin to get a point to use with the returned hull.

Parameters
[in]leThe local entity to get the bmodel from
[out]tileThe maptile the bmodel belongs, too
[out]rmaShiftthe shift vector in case of an RMA (needed for doors)
[out]anglesThe rotation of the entity (in case of bmodels)
Returns
The headnode for the local entity
See also
SV_HullForEntity

Definition at line 1659 of file cl_localentity.cpp.

References le_t::aabb, le_t::angles, cl, CM_HeadnodeForBox(), Com_Error(), le_t::contents, CONTENTS_SOLID, ERR_DROP, cBspModel_t::headnode, LE_GetClipModel(), cBspModel_t::shift, cBspModel_t::tile, le_t::type, vec3_origin, and VectorCopy.

Referenced by CL_ClipMoveToLEs().

◆ CL_RecalcRouting()

void CL_RecalcRouting ( const le_t * le)
See also
CL_Explode
Parameters
[in]leA local entity of a brush model (func_breakable, func_door, ...)

Definition at line 145 of file cl_localentity.cpp.

References CL_ActorConditionalMoveCalc(), CL_GridRecalcRouting(), LE_GenerateInlineModelList(), and selActor.

Referenced by CL_AddBrushModel(), CL_Explode(), LET_RotateDoor(), and LET_SlideDoor().

◆ CL_Trace()

trace_t CL_Trace ( const Line & traceLine,
const AABB & box,
const le_t * passle,
le_t * passle2,
int contentmask,
int worldLevel )

Moves the given mins/maxs volume through the world from start to end.

Note
Passedict and edicts owned by passedict are explicitly not checked.
See also
CL_ClipMoveToLEs
SV_Trace
Parameters
[in]traceLineStart and end vector of the trace
[in]boxThe box we move through the world
[in]passleIgnore this local entity in the trace (might be nullptr)
[in]passle2Ignore this local entity in the trace (might be nullptr)
[in]contentmaskSearched content the trace should watch for
[in]worldLevelThe worldlevel (0-7) to calculate the levelmask for the trace from

Definition at line 1739 of file cl_localentity.cpp.

References MoveClip::calcBounds(), cl, CL_ClipMoveToLEs(), cl_trace_debug, CM_CompleteBoxTrace(), MoveClip::contentmask, trace_t::fraction, trace_t::le, MoveClip::moveLine, MoveClip::objBox, MoveClipCL::passle, MoveClipCL::passle2, R_DrawBoundingBoxBatched(), AABB::set(), Line::set(), and MoveClipCL::trace.

Referenced by CL_ActorVis(), CL_TargetingGrenade(), CL_TargetingStraight(), LE_PlayFootStepSound(), PTL_Trace(), and Weather::update().

◆ LE_ActorBodyHit()

void LE_ActorBodyHit ( const le_t * le,
const vec3_t impact,
int normal )
static

Spawns particle effects for a hit actor.

Parameters
[in]leThe actor to spawn the particles for.
[in]impactThe impact location (where the particles are spawned).
[in]normalThe index of the normal vector of the particles (think: impact angle).

Definition at line 663 of file cl_localentity.cpp.

References bytedirs, CL_ParticleSpawn(), teamDef_t::hitParticle, and le_t::teamDef.

Referenced by LE_AddProjectile(), and LET_Projectile().

◆ LE_ActorGetStepTime()

int LE_ActorGetStepTime ( const le_t * le,
const pos3_t pos,
const pos3_t oldPos,
const int dir,
const int speed )

sqrt(2) for diagonal movement

Definition at line 570 of file cl_localentity.cpp.

References BASE_DIRECTIONS, cl, CORE_DIRECTIONS, dest, DIRECTION_FALL, le_t::fieldSize, Grid_PosToVec(), oldPos, and UNIT_SIZE.

Referenced by CL_ActorDoMoveTime(), and LE_DoPathMove().

◆ LE_Add()

le_t * LE_Add ( int entnum)

Add a new local entity to the scene.

Parameters
[in]entnumThe entity number (server side)
See also
LE_Get

Definition at line 1209 of file cl_localentity.cpp.

References ACTOR_SIZE_NORMAL, cl, Com_Error(), le_t::entnum, ERR_DROP, le_t::fieldSize, le_t::init(), le_t::inuse, LE_GetNext(), and MAX_EDICTS.

Referenced by CL_ActorAdd(), CL_ActorAppear(), CL_AddBrushModel(), CL_AddEdict(), CL_CameraAppear(), CL_EntAppear(), LE_AddAmbientSound(), LE_AddGrenade(), and LE_AddProjectile().

◆ LE_AddAmbientSound()

void LE_AddAmbientSound ( const char * sound,
const vec3_t origin,
int levelflags,
float volume,
float attenuation )

◆ LE_AddEdictHighlight()

void LE_AddEdictHighlight ( const le_t * le)
static

Adds a box that highlights the current active door.

Definition at line 1470 of file cl_localentity.cpp.

References entity_t::alpha, le_t::angles, CalculateMinsMaxs(), cBspModel_t::cbmBox, cl, entity_t::color, entity_t::eBox, LE_GetClipModel(), le_t::origin, R_AddEntity(), RF_BOX, and VectorSet.

Referenced by LE_AddToScene().

◆ LE_AddGrenade()

void LE_AddGrenade ( const fireDef_t * fd,
int flags,
const vec3_t muzzle,
const vec3_t v0,
int dt,
le_t * leVictim )
Parameters
[in]fdThe grenade fire definition
[in]flagsbitmask: SF_BODY, SF_IMPACT, SF_BOUNCING, SF_BOUNCED
[in]muzzlestarting/location vector
[in]v0velocity vector
[in]dtdelta seconds
[in]leVictimThe actor the grenade is thrown at (not yet supported)

Definition at line 940 of file cl_localentity.cpp.

References le_t::angle, ptl_t::angles, fireDef_t::bounce, fireDef_t::bounceSound, cl, CL_ParticleSpawn(), crand(), le_t::endTime, le_t::fd, GRAVITY, fireDef_t::hitBody, fireDef_t::hitBodySound, fireDef_t::impact, fireDef_t::impactSound, le_t::inuse, LE_Add(), LE_ExecuteThink(), LE_SetInvisible, LE_SetThink(), LET_Projectile(), ptl_t::omega, fireDef_t::projectile, le_t::ptl, le_t::ref1, le_t::ref2, le_t::ref3, SF_BODY, SF_BOUNCING, SF_IMPACT, fireDef_t::splrad, and VectorSet.

Referenced by CL_ActorDoThrow().

◆ LE_AddProjectile()

◆ LE_AddToScene()

◆ LE_BiggestItem()

const objDef_t * LE_BiggestItem ( const Item * ic)
static

Returns the index of the biggest item in the inventory list.

Note
This item is the only one that will be drawn when lying at the floor
See also
LE_PlaceItem
Returns
the item index in the csi.ods array
Note
Only call this for none empty Item

Definition at line 873 of file cl_localentity.cpp.

References Item::def(), Item::getNext(), INVSH_ShapeSize(), and objDef_t::shape.

Referenced by LE_PlaceItem().

◆ LE_BrushModelAction()

◆ LE_CenterView()

void LE_CenterView ( const le_t * le)

Center the camera on the local entity's origin.

Parameters
leThe local entity which origin is used to center the camera
See also
CL_CenterView
CL_ViewCenterAtGridPosition
CL_CameraRoute

Definition at line 1257 of file cl_localentity.cpp.

References cl, cl_centerview, CL_CheckCameraRoute(), cls, Cvar_SetValue(), le_t::origin, le_t::pos, le_t::team, UNIT_SIZE, VecToPos, Vector2Dist, and VectorCopy.

Referenced by CL_ActorAppear(), CL_ActorReactionFireAddTarget(), CL_ActorSelectList(), CL_EntPerish(), and LET_StartPathMove().

◆ LE_Cleanup()

void LE_Cleanup ( void )

Cleanup unused LE inventories that the server sent to the client also free some unused LE memory.

Definition at line 1557 of file cl_localentity.cpp.

References CID_FLOOR, cl, CL_ActorCleanup(), cls, Com_DPrintf(), DEBUG_CLIENT, i, le_t::inuse, le_t::inv, LE_IsActor(), and LE_IsItem.

Referenced by CL_ClearState().

◆ LE_DoEndPathMove()

◆ LE_DoPathMove()

◆ LE_ExecuteThink()

void LE_ExecuteThink ( le_t * le)

Call think function for the given local entity if its still in use.

Definition at line 371 of file cl_localentity.cpp.

References le_t::inuse, and le_t::think.

Referenced by LE_AddGrenade(), LE_AddProjectile(), LE_DoEndPathMove(), LE_Think(), LET_HiddenMove(), and LET_StartPathMove().

◆ LE_Find()

le_t * LE_Find ( entity_type_t type,
const pos3_t pos )

Searches a local entity on a given grid field.

Parameters
[in]typeEntity type
[in]posThe grid pos to search for an item of the given type

Definition at line 1441 of file cl_localentity.cpp.

References LE_GetNextInUse(), le_t::pos, le_t::type, type, and VectorCompare.

Referenced by CL_ActorRevitalised(), and LE_LinkFloorContainer().

◆ LE_FindRadius()

le_t * LE_FindRadius ( le_t * from,
const vec3_t org,
float rad,
entity_type_t type )

Returns entities that have origins within a spherical area.

Parameters
[in]fromThe entity to start the search from. nullptr will start from the beginning.
[in]orgThe origin that is the center of the circle.
[in]radradius to search an edict in.
[in]typeType of local entity. ET_NULL to ignore the type.

Definition at line 1416 of file cl_localentity.cpp.

References le_t::aabb, ET_NULL, AABB::getCenter(), LE_GetNextInUse(), le_t::origin, le_t::type, type, and VectorLength().

◆ LE_GenerateInlineModelList()

void LE_GenerateInlineModelList ( void )
inlinestatic

Definition at line 91 of file cl_localentity.cpp.

References cl, i, le_t::inlineModelName, LE_GetNextInUse(), and le_t::model1.

Referenced by CL_CompleteRecalcRouting(), and CL_RecalcRouting().

◆ LE_Get()

◆ LE_GetAnim()

const char * LE_GetAnim ( const char * anim,
int right,
int left,
int state )

Get the correct animation for the given actor state and weapons.

Parameters
[in]animType of animation (for example "stand", "walk")
[in]rightods index to determine the weapon in the actors right hand
[in]leftods index to determine the weapon in the actors left hand
[in]statethe actors state - e.g. STATE_CROUCHED (crouched animations) have a 'c' in front of their animation definitions (see *.anm files for characters)

Definition at line 423 of file cl_localentity.cpp.

References objDef_t::animationIndex, Com_sprintf(), INVSH_GetItemByIDX(), length, MAX_VAR, NONE, Q_streq, Q_strstart(), STATE_CROUCHED, objDef_t::type, and type.

Referenced by CL_ActorDoShoot(), CL_ActorStartShoot(), LET_StartIdle(), and LET_StartPathMove().

◆ LE_GetClipModel()

const cBspModel_t * LE_GetClipModel ( const le_t * le)

◆ LE_GetDrawModel()

model_t * LE_GetDrawModel ( unsigned int index)

Definition at line 1637 of file cl_localentity.cpp.

References cl, Com_Error(), ERR_DROP, index, and lengthof.

Referenced by CL_ActorAppear(), and CL_ViewLoadMedia().

◆ LE_GetFromPos()

le_t * LE_GetFromPos ( const pos3_t pos)

Searches a local entity on a given grid field.

Parameters
[in]posThe grid pos to search for an item of the given type

Definition at line 1353 of file cl_localentity.cpp.

References LE_GetNextInUse(), le_t::pos, and VectorCompare.

Referenced by CL_GetHitProbability().

◆ LE_GetNext()

le_t * LE_GetNext ( le_t * lastLE)

Iterate through the list of entities.

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

Definition at line 1370 of file cl_localentity.cpp.

References cl.

Referenced by LE_Add(), LE_GetNextInUse(), and LE_Think().

◆ LE_GetNextInUse()

le_t * LE_GetNextInUse ( le_t * lastLE)

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
lastLEThe entity found in the previous iteration; if nullptr, we start at the beginning

Definition at line 1398 of file cl_localentity.cpp.

References le_t::inuse, and LE_GetNext().

Referenced by CL_ActorConfirmAction_f(), CL_ActorGetClosest(), CL_BattlescapeSearchAtGridPos(), CL_BuildForbiddenList(), CL_ClipMoveToLEs(), CL_CountVisibleEnemies(), CL_EntPerish(), CL_NotifyBattlescapeEventDelay(), CL_ViewLoadMedia(), uiRadarNode::draw(), GAME_CollectAliens(), GAME_CollectItems(), LE_Find(), LE_FindRadius(), LE_GenerateInlineModelList(), LE_Get(), LE_GetFromPos(), LE_PlaceItem(), and S_Frame().

◆ LE_IsActor()

bool LE_IsActor ( const le_t * le)

Checks whether the given le is a living actor.

Parameters
[in]leThe local entity to perform the check for
See also
G_IsLivingActor

Definition at line 253 of file cl_localentity.cpp.

References ET_ACTOR, ET_ACTOR2x2, ET_ACTORHIDDEN, and le_t::type.

Referenced by CL_ActorDoMove(), CL_ActorDoShoot(), CL_ActorDoTurn(), CL_ActorInvMove(), CL_ActorMouseTrace(), CL_ActorStateChange(), GAME_CollectAliens(), GAME_CollectItems(), LE_Cleanup(), and LE_IsLivingActor().

◆ LE_IsLivingActor()

bool LE_IsLivingActor ( const le_t * le)

Checks whether the given le is a living actor (but might be hidden).

Parameters
[in]leThe local entity to perform the check for
See also
G_IsLivingActor
LE_IsActor

Definition at line 265 of file cl_localentity.cpp.

References LE_IsActor(), LE_IsDead, and LE_IsStunned.

Referenced by CL_ActorAppear(), CL_ActorConfirmAction_f(), CL_ActorDie(), CL_ActorRevitalised(), CL_ActorStartShoot(), CL_ActorStateChange(), CL_NotifyBattlescapeEventDelay(), CL_SoundEvent(), and LE_IsLivingAndVisibleActor().

◆ LE_IsLivingAndVisibleActor()

bool LE_IsLivingAndVisibleActor ( const le_t * le)

Checks whether the given le is a living and visible actor.

Parameters
[in]leThe local entity to perform the check for
See also
G_IsLivingActor
LE_IsActor

Definition at line 277 of file cl_localentity.cpp.

References ET_ACTORHIDDEN, LE_IsInvisible, LE_IsLivingActor(), and le_t::type.

Referenced by CL_ActorGetClosest(), CL_BattlescapeSearchAtGridPos(), CL_BuildForbiddenList(), CL_CountVisibleEnemies(), CL_NextAlien_f(), CL_NextAlienVisibleFromActor_f(), CL_PrevAlien_f(), and LE_PlaySoundFileAndParticleForSurface().

◆ LE_IsLocked()

bool LE_IsLocked ( int entnum)

Checks if a given le_t structure is locked, i.e., used by another event at this time.

Parameters
entnumthe entnum of the le_t struct involved.
Returns
true if the le_t is locked (used by another event), false if it's not or if it doesn't exist.

Definition at line 1309 of file cl_localentity.cpp.

References le_t::flags, LE_Get(), and LE_LOCKED.

Referenced by CL_CheckDefault().

◆ LE_IsOriginBrush()

bool LE_IsOriginBrush ( const le_t *const le)
inlinestatic

Origin brush entities are bmodel entities that have their mins/maxs relative to the world origin. The origin vector of the entity will be used to calculate e.g. the culling (and not the mins/maxs like for other entities).

Parameters
leThe local entity to check
Returns
true if the given local entity is a func_door or func_rotating

Definition at line 1462 of file cl_localentity.cpp.

References ET_DOOR, ET_ROTATING, and le_t::type.

Referenced by LE_AddToScene().

◆ LE_LinkFloorContainer()

void LE_LinkFloorContainer ( le_t * le)

link any floor container into the actor temp floor container

Definition at line 239 of file cl_localentity.cpp.

References ET_ITEM, LE_Find(), le_t::pos, le_t::resetFloor(), and le_t::setFloor().

Referenced by LE_DoEndPathMove().

◆ LE_Lock()

void LE_Lock ( le_t * le)

Markes a le_t struct as locked. Should be called at the beginning of an event handler on this le_t, and paired with a LE_Unlock at the end.

Parameters
leThe struct to be locked.
Note
Always make sure you call LE_Unlock at the end of the event (might be in a different function), to allow other events on this le_t.

Definition at line 1322 of file cl_localentity.cpp.

References Com_Error(), le_t::entnum, ERR_DROP, le_t::flags, and LE_LOCKED.

Referenced by CL_ActorAppear(), CL_ActorDie(), CL_ActorDoMove(), and CL_ActorRevitalised().

◆ LE_PlaceItem()

◆ LE_PlayFootStepSound()

◆ LE_PlaySoundFileAndParticleForSurface()

void LE_PlaySoundFileAndParticleForSurface ( le_t * le,
const char * textureName )
static

Plays step sounds and draw particles for different terrain types.

Parameters
[in]leThe local entity to play the sound and draw the particle for
[in]textureNameThe name of the texture the actor is standing on
See also
LET_PathMove
Todo
use the Grid_Fall method (ACTOR_SIZE_NORMAL) to ensure, that the particle is drawn at the ground (if needed - maybe the origin is already ground aligned)

Definition at line 544 of file cl_localentity.cpp.

References CL_ParticleSpawn(), Com_DPrintf(), Com_GetTerrainType(), DEBUG_SOUND, terrainType_t::footstepSound, terrainType_t::footstepVolume, LE_IsLivingAndVisibleActor(), LE_IsStunned, terrainType_t::particle, le_t::pos, PosToVec, S_LoadAndPlaySample(), and SOUND_ATTN_STATIC.

Referenced by LE_PlayFootStepSound().

◆ LE_PlaySoundFileForContents()

void LE_PlaySoundFileForContents ( le_t * le,
int contents )
static

Plays sound of content for moving actor.

Parameters
[in]lePointer to local entity being an actor.
[in]contentsThe contents flag of the brush we are currently in
Note
Currently it supports only CONTENTS_WATER, any other special contents can be added here anytime.

Definition at line 514 of file cl_localentity.cpp.

References CONTENTS_WATER, LE_IsCrouched, le_t::origin, le_t::positionContents, S_PlayStdSample(), SND_VOLUME_FOOTSTEPS, SOUND_ATTN_IDLE, SOUND_WATER_IN, SOUND_WATER_MOVE, and SOUND_WATER_OUT.

Referenced by LE_PlayFootStepSound().

◆ LE_SetThink()

◆ LE_Think()

void LE_Think ( void )

Calls the le think function and updates the animation. The animation updated even if the particular local entity is invisible for the client. This ensures, that an animation is always lerped correctly and won't magically start again once the local entity gets visible again.

See also
LET_StartIdle
LET_PathMove
LET_StartPathMove
LET_Projectile

Definition at line 387 of file cl_localentity.cpp.

References le_t::as, ca_active, cls, LE_ExecuteThink(), LE_GetNext(), le_t::model1, and R_AnimRun().

Referenced by CL_Frame().

◆ LE_Unlock()

void LE_Unlock ( le_t * le)

Unlocks a previously locked le_t struct.

Parameters
leThe le_t to unlock.
Note
Make sure that this is always paired with the corresponding LE_Lock around the conceptual beginning and ending of a le_t event. Should never be called by the handler(s) of a different event than the one that locked le. The owner of the lock is currently not checked.
Todo
If the event loop ever becomes multithreaded, this should be a real mutex lock.

Definition at line 1341 of file cl_localentity.cpp.

References Com_Error(), le_t::entnum, ERR_DROP, le_t::flags, and LE_LOCKED.

Referenced by CL_ActorAppear(), CL_ActorDie(), CL_ActorRevitalised(), LE_DoEndPathMove(), and LET_HiddenMove().

◆ LET_BrushModel()

void LET_BrushModel ( le_t * le)

◆ LET_HiddenMove()

void LET_HiddenMove ( le_t * le)

Handle move for invisible actors.

Note
Think function.
Todo
Is there something we should do here?

Definition at line 737 of file cl_localentity.cpp.

References LE_ExecuteThink(), LE_SetThink(), LE_Unlock(), LET_StartIdle(), le_t::newPos, le_t::pos, and VectorCopy.

Referenced by CL_ActorDoMove().

◆ LET_PathMove()

void LET_PathMove ( le_t * le)
static

Move the actor along the path to the given location.

Note
Think function
See also
CL_ActorDoMove

Definition at line 677 of file cl_localentity.cpp.

References cl, dest, le_t::endTime, le_t::fieldSize, Grid_PosToVec(), LE_DoEndPathMove(), LE_DoPathMove(), le_t::oldPos, le_t::origin, le_t::pathLength, le_t::pathPos, le_t::pos, le_t::startTime, VectorCopy, VectorMA(), and VectorSubtract.

Referenced by LET_StartPathMove().

◆ LET_Projectile()

◆ LET_RotateDoor()

void LET_RotateDoor ( le_t * le,
int speed )

Rotates a door in the given speed.

Parameters
[in]leThe local entity of the door to rotate
[in]speedThe speed to rotate the door with
Todo
lerp the rotation

Definition at line 1081 of file cl_localentity.cpp.

References le_t::angles, cl, CL_RecalcRouting(), CM_SetInlineModelOrientation(), le_t::dir, DOOR_OPEN_REVERSE, DOOR_ROTATION_ANGLE, le_t::inlineModelName, LE_SetThink(), and le_t::origin.

Referenced by LET_DoorRotatingClose(), and LET_DoorRotatingOpen().

◆ LET_SlideDoor()

void LET_SlideDoor ( le_t * le,
int speed )

Slides a door.

Note
Though doors, sliding doors need a very different handling: because it's movement is animated (unlike the rotating door), the final position that is used to calculate the routing data is set once the animation finished (because this recalculation might be very expensive).
Parameters
[in,out]leThe local entity of the inline model
[in]speedThe speed to slide with - a negative value to close the door
See also
Door_SlidingUse

Definition at line 1110 of file cl_localentity.cpp.

References AngleVectors(), cBspModel_t::cbmBox, cl, CL_RecalcRouting(), CM_InlineModel(), le_t::dir, DotProduct, GET_SLIDING_DOOR_SHIFT_VECTOR, le_t::inlineModelName, LE_SetThink(), le_t::origin, AABB::shift(), le_t::size, le_t::thinkDelay, VectorAdd, VectorEmpty, and VectorMul.

Referenced by LET_DoorSlidingClose(), and LET_DoorSlidingOpen().

◆ LET_StartIdle()

void LET_StartIdle ( le_t * le)

Change the animation of an actor to the idle animation (which can be panic, dead or stand).

Note
We have more than one animation for dead - the index is given by the state of the local entity
Think function
See the *.anm files in the models dir

Definition at line 478 of file cl_localentity.cpp.

References le_t::as, Com_Error(), le_t::entnum, ERR_DROP, LE_GetAnim(), LE_GetAnimationIndexForDeath, LE_IsDead, LE_IsInvisible, LE_IsPanicked, LE_SetThink(), le_t::left, Mem_Free, le_t::model1, leStep_t::next, le_t::pathLength, le_t::pathPos, R_AnimChange(), le_t::right, le_t::state, le_t::stepIndex, le_t::stepList, and va().

Referenced by CL_ActorAppear(), CL_ActorEndShoot(), CL_ActorRevitalised(), CL_ActorStateChange(), CL_InvAdd(), CL_InvDel(), LE_DoEndPathMove(), and LET_HiddenMove().

◆ LET_StartPathMove()

void LET_StartPathMove ( le_t * le)

Change the actors animation to walking.

Note
Think function
See the *.anm files in the models dir

Definition at line 716 of file cl_localentity.cpp.

References le_t::as, animState_t::change, cls, Com_Printf(), le_t::entnum, LE_CenterView(), LE_ExecuteThink(), LE_GetAnim(), LE_SetThink(), le_t::left, LET_PathMove(), le_t::model1, le_t::pnum, R_AnimChange(), le_t::right, le_t::state, le_t::team, and TEAM_CIVILIAN.

Referenced by CL_ActorDoMove().

◆ LM_AddModel()

localModel_t * LM_AddModel ( const char * model,
const vec3_t origin,
const vec3_t angles,
int entnum,
int levelflags,
int renderFlags,
const vec3_t scale )

Prepares local (not known or handled by the server) models to the map, which will be added later in LM_AddToScene().

Parameters
[in]modelThe model name.
[in]originOrigin of the model (position on map).
[in]anglesAngles of the model (how it should be rotated after adding to map).
[in]scaleScaling of the model (how it should be scaled after adding to map).
[in]entnumEntity number.
[in]levelflagsThe levels in which the entity resides/is visible.
[in]renderFlagsThe flags for the renderer, eg. 'translucent'.
Note
misc_model
See also
CL_SpawnParseEntitystring
LM_AddToScene

Definition at line 341 of file cl_localentity.cpp.

References localModel_t::angles, cl, Com_Error(), localModel_t::entnum, ERR_DROP, localModel_t::inuse, localModel_t::levelflags, LM_Find(), MAX_LOCALMODELS, localModel_t::name, OBJZERO, localModel_t::origin, Q_strncpyz(), localModel_t::renderFlags, scale, localModel_t::setScale(), and VectorCopy.

Referenced by SP_misc_model().

◆ LM_AddToScene()

void LM_AddToScene ( void )

Add the local models to the scene.

See also
CL_ViewRender
LE_AddToScene
LM_AddModel

Definition at line 218 of file cl_localentity.cpp.

References LM_AddToSceneOrder().

Referenced by CL_ViewRender().

◆ LM_AddToSceneOrder()

◆ LM_Find()

localModel_t * LM_Find ( int entnum)
inlinestatic

Checks whether a local model with the same entity number is already registered.

Definition at line 227 of file cl_localentity.cpp.

References cl, and i.

Referenced by LM_AddModel().

◆ LM_GetByID()

localModel_t * LM_GetByID ( const char * id)

Definition at line 315 of file cl_localentity.cpp.

References cl, i, localModel_t::id, Q_streq, and Q_strnull().

Referenced by LMT_Init(), and SP_misc_model().

◆ LM_Register()

◆ LM_Think()

void LM_Think ( void )

Definition at line 400 of file cl_localentity.cpp.

References cl, i, and localModel_t::think.

Referenced by CL_SpawnParseEntitystring().

◆ LMT_Init()

void LMT_Init ( localModel_t * localModel)

Variable Documentation

◆ cl_le_debug

cvar_t* cl_le_debug

Definition at line 39 of file cl_localentity.cpp.

Referenced by CL_InitLocal(), and LE_AddToScene().

◆ cl_map_draw_rescue_zone

cvar_t* cl_map_draw_rescue_zone

Definition at line 41 of file cl_localentity.cpp.

Referenced by CL_ViewInit(), and LE_BrushModelAction().

◆ cl_trace_debug

cvar_t* cl_trace_debug

Definition at line 40 of file cl_localentity.cpp.

Referenced by CL_InitLocal(), and CL_Trace().