UFO: Alien Invasion
Loading...
Searching...
No Matches
e_event_explode.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"
27#include "e_event_explode.h"
28
32int CL_ExplodeTime (const struct eventRegister_s* self, dbuffer* msg, eventTiming_t* eventTiming)
33{
34 if (eventTiming->impactTime > cl.time)
35 return eventTiming->impactTime;
36
37 return eventTiming->nextTime;
38}
39
44void CL_Explode (const eventRegister_t* self, dbuffer* msg)
45{
46 int entnum;
47 char sound[MAX_QPATH];
48
49 NET_ReadFormat(msg, self->formatString, &entnum, sound, sizeof(sound));
50
51 le_t* le = LE_Get(entnum);
52 if (!le)
53 LE_NotFoundError(entnum);
54
55 le->inuse = false;
56 if (le->modelnum1 > 0)
57 cl.model_clip[le->modelnum1] = nullptr;
58
59 const char* file = CL_ConvertSoundFromEvent(sound, sizeof(sound));
60 Com_DPrintf(DEBUG_SOUND, "Play network sample %s at (%f:%f:%f)\n", file, le->origin[0], le->origin[1], le->origin[2]);
62
63 /* Recalc the client routing table because this le (and the inline model) is now gone */
65}
clientBattleScape_t cl
void CL_RecalcRouting(const le_t *le)
le_t * LE_Get(int entnum)
Searches all local entities for the one with the searched entnum.
#define LE_NotFoundError(entnum)
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
#define SOUND_ATTN_NORM
Definition common.h:186
#define DEBUG_SOUND
Definition defines.h:63
void CL_Explode(const eventRegister_t *self, dbuffer *msg)
int CL_ExplodeTime(const struct eventRegister_s *self, dbuffer *msg, eventTiming_t *eventTiming)
Decides when the explode event should get executed. This in the impact time.
const char * CL_ConvertSoundFromEvent(char *sound, size_t size)
Some sound strings may end on a '+' to indicate to use a random sound which can be identified by repl...
Definition e_main.cpp:219
#define MAX_QPATH
Definition filesys.h:40
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
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
Definition s_main.cpp:307
#define SND_VOLUME_DEFAULT
Definition s_main.h:42
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
CL_ParseEvent timers and vars.
Definition e_main.h:30
int nextTime
Definition e_main.h:31
int impactTime
Definition e_main.h:33
a local entity
vec3_t origin
unsigned int modelnum1
bool inuse