26 #include "../client.h"
28 #include "../sound/s_main.h"
29 #include "../sound/s_sample.h"
33 #include "../renderer/r_mesh_anim.h"
34 #include "../renderer/r_draw.h"
35 #include "../../common/tracing.h"
36 #include "../../common/grid.h"
37 #include "../../shared/moveclip.h"
130 const double start = time(
nullptr);
138 Com_Printf(
"Rerouted for %i LEs in %5.2fs\n", i, time(
nullptr) - start);
172 if (!parents && lm.
parent ==
nullptr)
178 ent.model = lm.
model;
179 ent.skinnum = lm.
skin;
181 ent.setScale(lm.
scale);
186 if (ent.tagent ==
nullptr)
200 ent.as.frame = lm.
frame;
302 Com_Printf(
"LM_Register: Could not change anim of %s to '%s'\n",
348 Com_Error(
ERR_DROP,
"Already a local model with the same id (%i) loaded\n", entnum);
423 const char*
LE_GetAnim (
const char* anim,
int right,
int left,
int state)
430 size_t length =
sizeof(retAnim);
442 animationIndex =
'0';
448 if (!
Q_streq(type,
"grenade")) {
462 Com_sprintf(mod, length,
"%s%c", anim, animationIndex);
496 if (step !=
nullptr) {
580 return (start[2] - dest[2]);
615 byte newCrouchingState = crouchingState;
640 Com_Error(
ERR_DROP,
"LE_DoEndPathMove: Actor movement is out of sync: %i:%i:%i should be %i:%i:%i (step %i of %i) (team %i)",
725 Com_Printf(
"LET_StartPathMove: Could not change anim of le: %i, team: %i, pnum: %i\n",
814 ptl_t* ptl =
nullptr;
836 if (fd->
impact !=
nullptr)
879 for (max = ic->
def(); ic; ic = ic->
getNext()) {
881 if (size > maxSize) {
901 le_t* actor =
nullptr;
918 Com_Error(
ERR_DROP,
"Model for item %s is not precached in the cls.model_weapons array",
1002 const int drawFlags = cl_map_draw_rescue_zone->
integer;
1008 enum { DRAW_TEXTURE = 0x1, DRAW_CIRCLES = 0x2 };
1009 ent->model =
nullptr;
1011 VectorSet(ent->color, 0.5f, 1.0f, 0.0f);
1012 if ((drawFlags & DRAW_TEXTURE) && ent->texture ==
nullptr) {
1014 ent->texture =
R_FindPics(
"sfx/misc/rescue");
1017 ent->eBox.set(le->
aabb);
1019 if (!(drawFlags & DRAW_CIRCLES))
1029 circle.oldorigin[0] = circle.oldorigin[1] = circle.oldorigin[2] =
UNIT_SIZE / 2.0f;
1031 circle.alpha = ent->alpha;
1057 le->
angles[le->
angle] = (angle >= 360.0 ? angle - 360.0 : angle);
1065 if (localModel->
target[0] !=
'\0') {
1072 localModel->
think =
nullptr;
1112 vec3_t moveAngles, moveDir;
1122 moveDir[0] = fabsf(moveDir[0]);
1123 moveDir[1] = fabsf(moveDir[1]);
1124 moveDir[2] = fabsf(moveDir[2]);
1128 bool endPos =
false;
1132 if (fabs(le->
origin[le->
dir & 3]) >= distance)
1154 VectorMul(distance, moveAngles, distanceVec);
1171 if (strstr(sound,
"sound/"))
1180 Com_Printf(
"Could not add ambient sound entity\n");
1190 if (volume < 0.0f || volume > 1.0
f) {
1192 Com_Printf(
"Invalid volume for local entity given - only values between 0.0 and 1.0 are valid\n");
1244 Com_Error(
ERR_DROP,
"LE_NotFoundError: Could not get LE with entnum %i of type: %i (%s:%i)\n", entnum, type, file, line);
1246 Com_Error(
ERR_DROP,
"LE_NotFoundError: Could not get LE with entnum %i (%s:%i)\n", entnum, file, line);
1264 const float minDistToMove = 4.0f *
UNIT_SIZE;
1266 if (dist < minDistToMove) {
1269 if (le->
pos[2] != currentCamPos[2])
1295 if (le->
entnum == entnum)
1380 assert(lastLE >=
cl.
LEs);
1381 assert(lastLE < endOfLEs);
1426 for (
int j = 0; j < 3; j++)
1427 eorg[j] = org[j] - (le->
origin[j] + leCenter[j]);
1476 ent.alpha = (sin(
cl.
time * 6.28) + 1.0) / 2.0;
1504 ent.alpha = le.
alpha;
1527 ent.isOriginBrushModel =
true;
1577 void LE_List_f (
void)
1579 Com_Printf(
"number | entnum | type | inuse | invis | pnum | team | size | HP | state | level | model/ptl\n");
1582 Com_Printf(
"#%5i | #%5i | %4i | %5i | %5i | %4i | %4i | %4i | %3i | %5i | %5i | ",
1600 void LM_List_f (
void)
1602 Com_Printf(
"number | entnum | skin | frame | lvlflg | renderflags | origin | name\n");
1605 Com_Printf(
"#%5i | #%5i | #%3i | #%4i | %6i | %11i | %5.0f:%5.0f:%3.0f | %s\n",
1667 *tile = model->
tile;
1707 headnode, clip->
contentmask, 0, origin, angles, shift, 1.0);
1713 clip->
trace = trace;
1718 clip->
trace = trace;
void LET_SlideDoor(le_t *le, int speed)
Slides a door.
bool Q_strnull(const char *string)
void CalculateMinsMaxs(const vec3_t angles, const AABB &relBox, const vec3_t origin, AABB &absBox)
Calculates the bounding box in absolute coordinates, also for rotating objects. WARNING: do not use t...
vec_t VectorLength(const vec3_t v)
Calculate the length of a vector.
static ipos3_t shift
The shift array is used for random map assemblies (RMA) to shift the mins/maxs and stuff like that...
#define VectorCopy(src, dest)
entity_t * R_GetEntity(int id)
Returns a specific entity from the list.
void CL_RecalcRouting(const le_t *le)
char hitParticle[MAX_VAR]
#define VectorSet(v, x, y, z)
void set(const Line &other)
Copies the values from the given Line.
void LE_AddGrenade(const fireDef_t *fd, int flags, const vec3_t muzzle, const vec3_t v0, int dt, le_t *leVictim)
#define LE_IsCrouched(le)
void LE_ExecuteThink(le_t *le)
Call think function for the given local entity if its still in use.
QGL_EXTERN GLint GLenum type
void VectorMA(const vec3_t veca, const float scale, const vec3_t vecb, vec3_t outVector)
Sets vector_out (vc) to vevtor1 (va) + scale * vector2 (vb)
const char * LE_GetAnim(const char *anim, int right, int left, int state)
Get the correct animation for the given actor state and weapons.
int S_LoadSampleIdx(const char *soundFile)
Loads and registers a sound file for later use.
this is a fire definition for our weapons/ammo
int INVSH_ShapeSize(const uint32_t shape)
Counts the used bits in a shape (item shape).
const char * va(const char *format,...)
does a varargs printf into a temp buffer, so I don't need to have varargs versions of all text functi...
void LE_CenterView(const le_t *le)
Center the camera on the local entity's origin.
const terrainType_t * Com_GetTerrainType(const char *textureName)
Searches the terrain definition if given.
static const vec3_t scale
This is a cvar definition. Cvars can be user modified and used in our menus e.g.
const cBspModel_t * LE_GetClipModel(const le_t *le)
ptl_t * CL_ParticleSpawn(const char *name, int levelFlags, const vec3_t s, const vec3_t v, const vec3_t a)
Spawn a new particle to the map.
bool Com_sprintf(char *dest, size_t size, const char *fmt,...)
copies formatted string with buffer-size checking
void LM_AddToScene(void)
Add the local models to the scene.
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_AddProjectile(const fireDef_t *fd, int flags, const vec3_t muzzle, const vec3_t impact, int normal, le_t *leVictim)
#define BASE_DIRECTIONS
Number of direct connected fields for a position.
void LE_Unlock(le_t *le)
Unlocks a previously locked le_t struct.
#define LE_IsInvisible(le)
const image_t * R_FindPics(const char *name)
Searches for an image in the image array.
localModel_t LMs[MAX_LOCALMODELS]
const objDef_t * def(void) const
struct le_s * clientAction
bool S_LoadAndPlaySample(const char *s, const vec3_t origin, float attenuation, float volume)
does what the name implies in just one function to avoid exposing s_sample_t
bool CL_OutsideMap(const vec3_t position, const float delta)
Checks whether give position is still inside the map borders.
static void LE_GenerateInlineModelList(void)
void set(const AABB &other)
Copies the values from the given aabb.
void Com_Printf(const char *const fmt,...)
model_t * LE_GetDrawModel(unsigned int index)
void Grid_RecalcRouting(mapTiles_t *mapTiles, Routing &routing, const char *name, const GridBox &box, const char **list)
This function recalculates the routing surrounding the entity name.
le_t * LE_GetFromPos(const pos3_t pos)
Searches a local entity on a given grid field.
void LET_BrushModel(le_t *le)
const char * hitBodySound
const char * leInlineModelList[MAX_EDICTS+1]
void LMT_Init(localModel_t *localModel)
Defines all attributes of objects used in the inventory.
void CL_CheckCameraRoute(const pos3_t from, const pos3_t target)
Only moves the camera to the given target location if its not yet close enough.
struct localModel_s * parent
bool LE_IsActor(const le_t *le)
Checks whether the given le is a living actor.
#define VectorScale(in, scale, out)
static void CL_GridRecalcRouting(const le_t *le)
void LE_PlaceItem(le_t *le)
The bounding box of a moving object.
static void LET_PathMove(le_t *le)
Move the actor along the path to the given location.
static void LE_PlaySoundFileAndParticleForSurface(le_t *le, const char *textureName)
Plays step sounds and draw particles for different terrain types.
void setScale(const vec3_t scale_)
const struct objDef_s * obj
void R_AnimChange(animState_t *as, const model_t *mod, const char *name)
Changes the animation for md2 models.
#define Q_strvalid(string)
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.
void Com_Error(int code, const char *fmt,...)
#define SKIP_LOCAL_ENTITY
actorSizeEnum_t fieldSize
int LE_ActorGetStepTime(const le_t *le, const pos3_t pos, const pos3_t oldPos, const int dir, const int speed)
void Cmd_ExecuteString(const char *text,...)
A complete command line has been parsed, so try to execute it.
void LE_Cleanup(void)
Cleanup unused LE inventories that the server sent to the client also free some unused LE memory...
trace_t CM_HintedTransformedBoxTrace(MapTile &tile, const Line &traceLine, const AABB &traceBox, const int headnode, const int contentmask, const int brushrejects, const vec3_t origin, const vec3_t angles, const vec3_t rmaShift, const float fraction)
Handles offseting and rotation of the end points for moving and rotating entities.
item instance data, with linked list capability
void Q_strncpyz(char *dest, const char *src, size_t destsize)
Safe strncpy that ensures a trailing zero.
#define LE_CHECK_LEVELFLAGS
void AngleVectors(const vec3_t angles, vec3_t forward, vec3_t right, vec3_t up)
Create the rotation matrix in order to rotate something.
void CL_ActorConditionalMoveCalc(le_t *le)
Recalculate forbidden list, available moves and actor's move length for the current selected actor...
void CL_CompleteRecalcRouting(void)
void CL_ActorPlaySound(const le_t *le, actorSound_t soundType)
Plays various sounds on actor action.
#define VectorMul(scalar, b, dest)
#define DotProduct(x, y)
Returns the distance between two 3-dimensional vectors.
#define FLYING_DIRECTIONS
#define LE_GetAnimationIndexForDeath(le)
Valid indices from 1 - MAX_DEATH.
#define SND_VOLUME_FOOTSTEPS
model_t * modelPool[MAX_OBJDEFS]
cvar_t * cl_map_draw_rescue_zone
void calcBounds()
Create the bounding box for the entire move.
static bool LE_IsOriginBrush(const le_t *const le)
QGL_EXTERN GLuint GLsizei GLsizei * length
#define DOOR_ROTATION_ANGLE
model_t * model_draw[MAX_MODELS]
le_t * LE_Get(int entnum)
Searches all local entities for the one with the searched entnum.
void S_PlayStdSample(const stdsound_t sId, const vec3_t origin, float attenuation, float volume)
plays one of the precached samples
int32_t CM_HeadnodeForBox(MapTile &tile, const AABB &box)
To keep everything totally uniform, bounding boxes are turned into small BSP trees instead of being c...
void(* localEntityThinkFunc_t)(struct le_s *le)
void _LE_NotFoundError(int entnum, int type, const char *file, const int line)
#define LE_IsSelected(le)
void VecToAngles(const vec3_t value1, vec3_t angles)
Converts a vector to an angle vector.
#define VecToPos(v, p)
Map boundary is +/- MAX_WORLD_WIDTH - to get into the positive area we add the possible max negative ...
le_t * LE_Add(int entnum)
Add a new local entity to the scene.
bool LE_IsLivingAndVisibleActor(const le_t *le)
Checks whether the given le is a living and visible actor.
#define PosToVec(p, v)
Pos boundary size is +/- 128 - to get into the positive area we add the possible max negative value a...
localModel_t * LM_GetByID(const char *id)
localEntitiyAddFunc_t addFunc
char const * Q_strstart(char const *str, char const *start)
Matches the start of a string.
#define LE_REMOVE_NEXT_FRAME
void LE_DoEndPathMove(le_t *le)
Ends the move of an actor.
Item * getFloorContainer() const
void Com_DPrintf(int level, const char *fmt,...)
A Com_Printf that only shows up if the "developer" cvar is set.
static void LM_AddToSceneOrder(bool parents)
model_t * R_FindModel(const char *name)
Tries to load a model.
void LET_RotateDoor(le_t *le, int speed)
Rotates a door in the given speed.
void R_AnimRun(animState_t *as, const model_t *mod, int msec)
Run the animation of the given model.
char footstepSound[MAX_VAR]
static void LE_DoPathMove(le_t *le)
const struct cBspModel_s * model_clip[MAX_MODELS]
static const objDef_t * LE_BiggestItem(const Item *ic)
Returns the index of the biggest item in the inventory list.
static localModel_t * LM_Find(int entnum)
Checks whether a local model with the same entity number is already registered.
void getCenter(vec3_t center) const
Calculates the center of the bounding box.
QGL_EXTERN GLenum GLuint * dest
void LM_Register(void)
Register misc_models.
#define PosAddDV(p, crouch, dv)
#define GET_SLIDING_DOOR_SHIFT_VECTOR(dir, speed, vecout)
void LE_LinkFloorContainer(le_t *le)
link any floor container into the actor temp floor container
cBspModel_t * CM_InlineModel(const mapTiles_t *mapTiles, const char *name)
Searches all inline models and return the cBspModel_t pointer for the given modelnumber or -name...
#define LE_SetInvisible(le)
#define VectorCompare(a, b)
le_t * LE_GetNextInUse(le_t *lastLE)
Iterate through the entities that are in use.
#define Vector2Dist(a, b)
int pathContents[MAX_ROUTE]
#define VectorAdd(a, b, dest)
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 L...
#define SND_VOLUME_WEAPONS
void LE_Think(void)
Calls the le think function and updates the animation. The animation updated even if the particular l...
static void CL_ClipMoveToLEs(MoveClipCL *clip)
Clip against solid entities.
static void LE_PlayFootStepSound(le_t *le)
TR_TILE_TYPE mapTiles[MAX_MAPTILES]
#define SOUND_ATTN_STATIC
localEntityThinkFunc_t think
static void LE_PlaySoundFileForContents(le_t *le, int contents)
Plays sound of content for moving actor.
byte actorMoveLength
The TUs that the current selected actor needs to walk to the current grid position marked by the mous...
void CL_ParticleFree(ptl_t *p)
Free a particle and all it's children.
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...
cBspModel_t * CM_SetInlineModelOrientation(mapTiles_t *mapTiles, const char *name, const vec3_t origin, const vec3_t angles)
This function updates a model's orientation.
static void LE_AddEdictHighlight(const le_t *le)
Adds a box that highlights the current active door.
void R_EntitySetOrigin(entity_t *ent, const vec3_t origin)
setter for entity origin
float crand(void)
Return random values between -1 and 1.
int R_AddEntity(const entity_t *ent)
Adds a copy of the specified entity to the list of all known render entities.
void(* think)(struct localModel_s *localModel)
void LE_AddAmbientSound(const char *sound, const vec3_t origin, int levelflags, float volume, float attenuation)
Adds ambient sounds from misc_sound entities.
void shift(const vec3_t shiftVec)
shove the whole box by the given vector
const objDef_t * INVSH_GetItemByIDX(int index)
Returns the item that belongs to the given index or nullptr if the index is invalid.
le_t * LE_Find(entity_type_t type, const pos3_t pos)
Searches a local entity on a given grid field.
bool LE_BrushModelAction(le_t *le, entity_t *ent)
Add function for brush models.
static void LET_Projectile(le_t *le)
Different terrain definitions for footsteps and particles.
const float directionAngles[CORE_DIRECTIONS]
short dvec_t
The direction vector tells us where the actor came from (in his previous step). The pathing table hol...
#define LE_IsPanicked(le)
const char * footstepSound
void LET_HiddenMove(le_t *le)
Handle move for invisible actors.
void emptyContainer(Inventory *const inv, const containerIndex_t container)
Clears the linked list of a container - removes all items from this container.
bool LE_IsLivingActor(const le_t *le)
Checks whether the given le is a living actor (but might be hidden)
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.
void R_DrawBoundingBoxBatched(const AABB &absbox)
#define ACTOR_SIZE_NORMAL
void setFloor(le_s *other)
void Grid_PosToVec(const Routing &routing, const actorSizeEnum_t actorSize, const pos3_t pos, vec3_t vec)
Converts a grid position to world coordinates.
void Cvar_SetValue(const char *varName, float value)
Expands value to a string and calls Cvar_Set.
#define LE_ALWAYS_VISIBLE
void LE_SetThink(le_t *le, localEntityThinkFunc_t think)
le_t * LE_GetNext(le_t *lastLE)
Iterate through the list of entities.
#define DOOR_OPEN_REVERSE
#define ACTOR_SIZE_INVALID
int Com_ServerState(void)
Check whether we are the server or have a singleplayer tactical mission.
fireDefIndex_t currentSelectedFiremode
void LET_StartIdle(le_t *le)
Change the animation of an actor to the idle animation (which can be panic, dead or stand) ...
void CL_ActorCleanup(le_t *le)
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...
#define VectorSubtract(a, b, dest)
trace_t CM_CompleteBoxTrace(mapTiles_t *mapTiles, const Line &trLine, const AABB &box, int levelmask, int brushmask, int brushreject)
Traces all submodels in all tiles. Used by ufo and ufo_ded.
void LET_StartPathMove(le_t *le)
Change the actors animation to walking.
#define SND_VOLUME_DEFAULT
static void LE_ActorBodyHit(const le_t *le, const vec3_t impact, int normal)
Spawns particle effects for a hit actor.