UFO: Alien Invasion
Toggle main menu visibility
Loading...
Searching...
No Matches
e_event_invdel.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_actor.h
"
27
#include "
../../../cl_localentity.h
"
28
#include "
e_event_invdel.h
"
29
33
int
CL_InvDelTime
(
const
struct
eventRegister_s* self,
dbuffer
* msg,
eventTiming_t
* eventTiming)
34
{
35
if
(eventTiming->
parsedShot
) {
36
if
(eventTiming->
parsedDeath
) {
/* drop items after death (caused by impact) */
37
return
eventTiming->
impactTime
+ 1400;
38
}
else
if
(eventTiming->
impactTime
>
cl
.time) {
/* item thrown on the ground */
39
return
eventTiming->
shootTime
+ 75;
40
}
41
}
42
return
eventTiming->
nextTime
;
43
}
44
48
void
CL_InvDel
(
const
eventRegister_t
* self,
dbuffer
* msg)
49
{
50
int
number;
51
int
x, y;
52
containerIndex_t
container;
53
54
NET_ReadFormat
(msg, self->
formatString
, &number, &container, &x, &y);
55
56
le_t
* le =
LE_Get
(number);
57
if
(!le)
58
Com_Error
(
ERR_DROP
,
"InvDel message ignored... LE not found\n"
);
59
60
/* update the local entity to ensure that the correct weapon/item is rendered in the battlescape */
61
if
(container ==
CID_RIGHT
)
62
le->
right
=
NONE
;
63
else
if
(container ==
CID_LEFT
)
64
le->
left
=
NONE
;
65
else
if
(container ==
CID_HEADGEAR
)
66
le->
headgear
=
NONE
;
67
68
if
(le->
type
==
ET_ACTOR
|| le->
type
==
ET_ACTOR2x2
)
69
LE_SetThink
(le,
LET_StartIdle
);
70
71
Item
* item = le->
inv
.
getItemAtPos
(
INVDEF
(container), x, y);
72
/* ic can be null for other team actors - we don't the full inventory of them, only
73
* the object index */
74
if
(!item)
75
return
;
76
77
if
(!
cls
.i.removeFromInventory(&le->
inv
,
INVDEF
(container), item))
78
Com_Error
(
ERR_DROP
,
"CL_InvDel: No item was removed from container %i"
, container);
79
80
if
(le ==
selActor
)
81
Cmd_ExecuteString
(
"hud_updateactorload"
);
82
83
/* update the rendered item after it was removed from the floor container */
84
if
(
LE_IsItem
(le))
85
LE_PlaceItem
(le);
86
}
selActor
le_t * selActor
Definition
cl_actor.cpp:49
cl_actor.h
cl
clientBattleScape_t cl
Definition
cl_battlescape.cpp:29
LE_SetThink
void LE_SetThink(le_t *le, localEntityThinkFunc_t think)
Definition
cl_localentity.cpp:310
LE_PlaceItem
void LE_PlaceItem(le_t *le)
Definition
cl_localentity.cpp:896
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).
Definition
cl_localentity.cpp:478
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_IsItem
#define LE_IsItem(le)
Definition
cl_localentity.h:270
cls
client_static_t cls
Definition
cl_main.cpp:83
INVDEF
#define INVDEF(containerID)
Definition
cl_shared.h:48
Inventory::getItemAtPos
Item * getItemAtPos(const invDef_t *container, const int x, const int y) const
Searches if there is an item at location (x,y) in a container.
Definition
inv_shared.cpp:844
Item
item instance data, with linked list capability
Definition
inv_shared.h:402
dbuffer
Definition
dbuffer.h:20
client.h
Primary header for client.
Cmd_ExecuteString
void Cmd_ExecuteString(const char *text,...)
A complete command line has been parsed, so try to execute it.
Definition
cmd.cpp:1007
Com_Error
void Com_Error(int code, const char *fmt,...)
Definition
common.cpp:459
ERR_DROP
#define ERR_DROP
Definition
common.h:211
NONE
#define NONE
Definition
defines.h:68
CL_InvDelTime
int CL_InvDelTime(const struct eventRegister_s *self, dbuffer *msg, eventTiming_t *eventTiming)
Decides if following events should be delayed.
Definition
e_event_invdel.cpp:33
CL_InvDel
void CL_InvDel(const eventRegister_t *self, dbuffer *msg)
Definition
e_event_invdel.cpp:48
e_event_invdel.h
CID_HEADGEAR
#define CID_HEADGEAR
Definition
inv_shared.h:50
containerIndex_t
int32_t containerIndex_t
Definition
inv_shared.h:46
CID_LEFT
#define CID_LEFT
Definition
inv_shared.h:48
CID_RIGHT
#define CID_RIGHT
Definition
inv_shared.h:47
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
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
eventTiming_t
CL_ParseEvent timers and vars.
Definition
e_main.h:30
eventTiming_t::shootTime
int shootTime
Definition
e_main.h:32
eventTiming_t::nextTime
int nextTime
Definition
e_main.h:31
eventTiming_t::impactTime
int impactTime
Definition
e_main.h:33
eventTiming_t::parsedDeath
bool parsedDeath
Definition
e_main.h:35
eventTiming_t::parsedShot
bool parsedShot
Definition
e_main.h:36
le_t
a local entity
Definition
cl_localentity.h:65
le_t::left
int left
Definition
cl_localentity.h:156
le_t::right
int right
Definition
cl_localentity.h:156
le_t::type
entity_type_t type
Definition
cl_localentity.h:67
le_t::headgear
int headgear
Definition
cl_localentity.h:156
le_t::inv
Inventory inv
Definition
cl_localentity.h:155
src
client
battlescape
events
event
inventory
e_event_invdel.cpp
Generated on __DATE__ __TIME__ for UFO: Alien Invasion by
1.17.0