UFO: Alien Invasion
Doxygen documentation generating
e_event_entperish.cpp
Go to the documentation of this file.
1 
5 /*
6 Copyright (C) 2002-2023 UFO: Alien Invasion.
7 
8 This program is free software; you can redistribute it and/or
9 modify it under the terms of the GNU General Public License
10 as published by the Free Software Foundation; either version 2
11 of the License, or (at your option) any later version.
12 
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16 
17 See the GNU General Public License for more details.
18 
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22 
23 */
24 
25 #include "../../../../client.h"
26 #include "../../../cl_localentity.h"
27 #include "../../../cl_particle.h"
28 #include "e_event_entperish.h"
29 
34 void 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:
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) {
66  CL_ParticleFree(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) {
79  CL_ParticleFree(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) */
96  Cvar_SetValue("mn_numaliensspotted", cl.numEnemiesSpotted);
97 }
Inventory inv
QGL_EXTERN GLint GLenum type
Definition: r_gl.h:94
void LE_CenterView(const le_t *le)
Center the camera on the local entity's origin.
int flags
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
InventoryInterface i
Definition: client.h:101
#define TEAM_CIVILIAN
Definition: q_shared.h:61
void Com_Printf(const char *const fmt,...)
Definition: common.cpp:386
#define LE_NotFoundWithTypeError(entnum, type)
bool isOurRound() const
Definition: client.h:106
client_static_t cls
Definition: cl_main.cpp:83
a local entity
#define DEBUG_CLIENT
Definition: defines.h:59
#define OBJZERO(obj)
Definition: shared.h:178
le_t * LE_Get(int entnum)
Searches all local entities for the one with the searched entnum.
clientBattleScape_t cl
#define CID_FLOOR
Definition: inv_shared.h:55
int CL_CountVisibleEnemies(void)
Counts visible enemies on the battlescape.
void Com_DPrintf(int level, const char *fmt,...)
A Com_Printf that only shows up if the "developer" cvar is set.
Definition: common.cpp:398
int team
#define VectorCompare(a, b)
Definition: vector.h:63
#define LE_INVISIBLE
le_t * LE_GetNextInUse(le_t *lastLE)
Iterate through the entities that are in use.
void CL_ParticleFree(ptl_t *p)
Free a particle and all it's children.
void resetFloor()
void CL_EntPerish(const eventRegister_t *self, dbuffer *msg)
Called whenever an entity disappears from view.
void destroyInventory(Inventory *const inv)
Destroys inventory.
Definition: inventory.cpp:521
entity_type_t type
animState_t as
void Cvar_SetValue(const char *varName, float value)
Expands value to a string and calls Cvar_Set.
Definition: cvar.cpp:671
void emptyContainer(Inventory *const inv, const containerIndex_t container)
Clears the linked list of a container - removes all items from this container.
Definition: inventory.cpp:501
Struct that defines one particular event with all its callbacks and data.
Definition: e_main.h:42
ptl_t * ptl
pos3_t pos