UFO: Alien Invasion
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
e_event_explode.cpp
Go to the documentation of this file.
1 
5 /*
6 Copyright (C) 2002-2020 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 "e_event_explode.h"
28 
32 int 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 
44 void 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 */
64  CL_RecalcRouting(le);
65 }
void CL_RecalcRouting(const le_t *le)
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:314
vec3_t origin
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.
CL_ParseEvent timers and vars.
Definition: e_main.h:30
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
le_t * LE_Get(int entnum)
Searches all local entities for the one with the searched entnum.
clientBattleScape_t cl
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
const struct cBspModel_s * model_clip[MAX_MODELS]
Struct that defines one particular event with all its callbacks and data.
Definition: e_main.h:42
a local entity
void CL_Explode(const eventRegister_t *self, dbuffer *msg)
#define MAX_QPATH
Definition: filesys.h:40
bool inuse
int impactTime
Definition: e_main.h:33
#define SOUND_ATTN_NORM
Definition: common.h:186
#define DEBUG_SOUND
Definition: defines.h:63
int nextTime
Definition: e_main.h:31
unsigned int modelnum1
#define SND_VOLUME_DEFAULT
Definition: s_main.h:42
#define LE_NotFoundError(entnum)