UFO: Alien Invasion
Toggle main menu visibility
Loading...
Searching...
No Matches
e_event_entperish.cpp
Go to the documentation of this file.
1
4
5
/*
6
Copyright (C) 2002-2025 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)
44
LE_NotFoundWithTypeError
(entnum,
type
);
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
) {
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) */
95
cl
.numEnemiesSpotted =
CL_CountVisibleEnemies
();
96
Cvar_SetValue
(
"mn_numaliensspotted"
,
cl
.numEnemiesSpotted);
97
}
cl
clientBattleScape_t cl
Definition
cl_battlescape.cpp:29
CL_CountVisibleEnemies
int CL_CountVisibleEnemies(void)
Counts visible enemies on the battlescape.
Definition
cl_battlescape.cpp:319
LE_GetNextInUse
le_t * LE_GetNextInUse(le_t *lastLE)
Iterate through the entities that are in use.
Definition
cl_localentity.cpp:1398
LE_CenterView
void LE_CenterView(const le_t *le)
Center the camera on the local entity's origin.
Definition
cl_localentity.cpp:1257
LE_Get
le_t * LE_Get(int entnum)
Searches all local entities for the one with the searched entnum.
Definition
cl_localentity.cpp:1287
cl_localentity.h
LE_INVISIBLE
#define LE_INVISIBLE
Definition
cl_localentity.h:53
LE_NotFoundWithTypeError
#define LE_NotFoundWithTypeError(entnum, type)
Definition
cl_localentity.h:323
cls
client_static_t cls
Definition
cl_main.cpp:83
CL_ParticleFree
void CL_ParticleFree(ptl_t *p)
Free a particle and all it's children.
Definition
cl_particle.cpp:776
cl_particle.h
dbuffer
Definition
dbuffer.h:20
client.h
Primary header for client.
Com_DPrintf
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
Com_Printf
void Com_Printf(const char *const fmt,...)
Definition
common.cpp:428
Cvar_SetValue
void Cvar_SetValue(const char *varName, float value)
Expands value to a string and calls Cvar_Set.
Definition
cvar.cpp:671
DEBUG_CLIENT
#define DEBUG_CLIENT
Definition
defines.h:59
CL_EntPerish
void CL_EntPerish(const eventRegister_t *self, dbuffer *msg)
Called whenever an entity disappears from view.
Definition
e_event_entperish.cpp:34
e_event_entperish.h
CID_FLOOR
#define CID_FLOOR
Definition
inv_shared.h:55
NET_ReadFormat
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
@ ET_ACTOR
Definition
q_shared.h:148
ET_ACTOR2x2
@ ET_ACTOR2x2
Definition
q_shared.h:160
ET_ACTORHIDDEN
@ ET_ACTORHIDDEN
Definition
q_shared.h:163
ET_PARTICLE
@ ET_PARTICLE
Definition
q_shared.h:164
ET_BREAKABLE
@ ET_BREAKABLE
Definition
q_shared.h:150
ET_DOOR
@ ET_DOOR
Definition
q_shared.h:156
ET_DOOR_SLIDING
@ ET_DOOR_SLIDING
Definition
q_shared.h:157
ET_ITEM
@ ET_ITEM
Definition
q_shared.h:149
TEAM_CIVILIAN
#define TEAM_CIVILIAN
Definition
q_shared.h:61
type
QGL_EXTERN GLint GLenum type
Definition
r_gl.h:94
OBJZERO
#define OBJZERO(obj)
Definition
shared.h:178
eventRegister_t
Struct that defines one particular event with all its callbacks and data.
Definition
e_main.h:42
eventRegister_t::formatString
const char * formatString
The format string that is used to write and parse this event.
Definition
e_main.h:54
le_t
a local entity
Definition
cl_localentity.h:65
le_t::flags
int flags
Definition
cl_localentity.h:91
le_t::resetFloor
void resetFloor()
Definition
cl_localentity.h:196
le_t::ptl
ptl_t * ptl
Definition
cl_localentity.h:152
le_t::pos
pos3_t pos
Definition
cl_localentity.h:71
le_t::as
animState_t as
Definition
cl_localentity.h:149
le_t::team
int team
Definition
cl_localentity.h:87
le_t::type
entity_type_t type
Definition
cl_localentity.h:67
le_t::inv
Inventory inv
Definition
cl_localentity.h:155
VectorCompare
#define VectorCompare(a, b)
Definition
vector.h:63
src
client
battlescape
events
event
world
e_event_entperish.cpp
Generated on __DATE__ __TIME__ for UFO: Alien Invasion by
1.17.0