UFO: Alien Invasion
Loading...
Searching...
No Matches
e_event_entperish.cpp
Go to the documentation of this file.
1
4
5/*
6Copyright (C) 2002-2025 UFO: Alien Invasion.
7
8This program is free software; you can redistribute it and/or
9modify it under the terms of the GNU General Public License
10as published by the Free Software Foundation; either version 2
11of the License, or (at your option) any later version.
12
13This program is distributed in the hope that it will be useful,
14but WITHOUT ANY WARRANTY; without even the implied warranty of
15MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16
17See the GNU General Public License for more details.
18
19You should have received a copy of the GNU General Public License
20along with this program; if not, write to the Free Software
21Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22
23*/
24
25#include "../../../../client.h"
28#include "e_event_entperish.h"
29
34void CL_EntPerish (const eventRegister_t* self, dbuffer* msg)
35{
36 int entnum;
37 int type;
38
39 NET_ReadFormat(msg, self->formatString, &entnum, &type);
40
41 le_t* le = LE_Get(entnum);
42
43 if (!le)
45
46 le_t* actor = nullptr;
47 switch (le->type) {
48 case ET_ITEM:
49 cls.i.emptyContainer(&le->inv, CID_FLOOR);
50
51 /* search owners (there can be many, some of them dead) */
52 while ((actor = LE_GetNextInUse(actor))) {
53 if ((actor->type == ET_ACTOR || actor->type == ET_ACTOR2x2)
54 && VectorCompare(actor->pos, le->pos)) {
55 Com_DPrintf(DEBUG_CLIENT, "CL_EntPerish: le of type ET_ITEM hidden\n");
56 actor->resetFloor();
57 }
58 }
59 break;
60 case ET_ACTOR:
61 case ET_ACTOR2x2:
62 if (!cls.isOurRound() && le->team != TEAM_CIVILIAN)
63 LE_CenterView(le);
64 cls.i.destroyInventory(&le->inv);
65 if (le->ptl) {
67 le->ptl = nullptr;
68 }
69 /* Clear anim data to prevent actor "jumping" to new animation when it reappears, or worse animation issues. */
70 OBJZERO(le->as);
71 break;
72#ifdef DEBUG
73 case ET_ACTORHIDDEN:
74 Com_DPrintf(DEBUG_CLIENT, "CL_EntPerish: It should not happen that we perish a hidden actor\n");
75 return;
76#endif
77 case ET_PARTICLE:
78 if (le->ptl) {
80 le->ptl = nullptr;
81 } else {
82 Com_Printf("CL_EntPerish: Particle is nullptr for entnum %i!\n", entnum);
83 }
84 break;
85 case ET_BREAKABLE:
86 case ET_DOOR:
87 case ET_DOOR_SLIDING:
88 break;
89 default:
90 break;
91 }
92
93 le->flags |= LE_INVISIBLE;
94 /* decrease the count of spotted aliens (also stunned) */
95 cl.numEnemiesSpotted = CL_CountVisibleEnemies();
96 Cvar_SetValue("mn_numaliensspotted", cl.numEnemiesSpotted);
97}
clientBattleScape_t cl
int CL_CountVisibleEnemies(void)
Counts visible enemies on the battlescape.
le_t * LE_GetNextInUse(le_t *lastLE)
Iterate through the entities that are in use.
void LE_CenterView(const le_t *le)
Center the camera on the local entity's origin.
le_t * LE_Get(int entnum)
Searches all local entities for the one with the searched entnum.
#define LE_INVISIBLE
#define LE_NotFoundWithTypeError(entnum, type)
client_static_t cls
Definition cl_main.cpp:83
void CL_ParticleFree(ptl_t *p)
Free a particle and all it's children.
Primary header for client.
void Com_DPrintf(int level, const char *fmt,...)
A Com_Printf that only shows up if the "developer" cvar is set.
Definition common.cpp:440
void Com_Printf(const char *const fmt,...)
Definition common.cpp:428
void Cvar_SetValue(const char *varName, float value)
Expands value to a string and calls Cvar_Set.
Definition cvar.cpp:671
#define DEBUG_CLIENT
Definition defines.h:59
void CL_EntPerish(const eventRegister_t *self, dbuffer *msg)
Called whenever an entity disappears from view.
#define CID_FLOOR
Definition inv_shared.h:55
void NET_ReadFormat(dbuffer *buf, const char *format,...)
The user-friendly version of NET_ReadFormat that reads variable arguments from a buffer according to ...
Definition netpack.cpp:533
@ ET_ACTOR
Definition q_shared.h:148
@ ET_ACTOR2x2
Definition q_shared.h:160
@ ET_ACTORHIDDEN
Definition q_shared.h:163
@ ET_PARTICLE
Definition q_shared.h:164
@ ET_BREAKABLE
Definition q_shared.h:150
@ ET_DOOR
Definition q_shared.h:156
@ ET_DOOR_SLIDING
Definition q_shared.h:157
@ ET_ITEM
Definition q_shared.h:149
#define TEAM_CIVILIAN
Definition q_shared.h:61
QGL_EXTERN GLint GLenum type
Definition r_gl.h:94
#define OBJZERO(obj)
Definition shared.h:178
Struct that defines one particular event with all its callbacks and data.
Definition e_main.h:42
const char * formatString
The format string that is used to write and parse this event.
Definition e_main.h:54
a local entity
int flags
void resetFloor()
ptl_t * ptl
pos3_t pos
animState_t as
entity_type_t type
Inventory inv
#define VectorCompare(a, b)
Definition vector.h:63