UFO: Alien Invasion
Doxygen documentation generating
e_event_addedict.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 "e_event_addedict.h"
28 
29 
33 static bool CL_AddEdictFunc (le_t* le, entity_t* ent)
34 {
35  ent->flags = RF_BOX;
36  VectorSet(ent->color, 1, 1, 1);
37  ent->alpha = 1.0;
38  ent->eBox.set(le->aabb);
39  R_EntitySetOrigin(ent, le->origin);
40  return true;
41 }
42 
48 void CL_AddEdict (const eventRegister_t* self, dbuffer* msg)
49 {
50  int entnum;
52  AABB box;
53 
54  NET_ReadFormat(msg, self->formatString, &entnum, &type, &box.mins, &box.maxs);
55 
56  /* use an offset to ensure that we don't conflict with any other solid edict that is already spawned */
57  le_t* le = LE_Get(entnum + MAX_EDICTS);
58  if (!le) {
59  le = LE_Add(entnum + MAX_EDICTS);
60  } else {
61  Com_DPrintf(DEBUG_CLIENT, "CL_AddEdict: Entity appearing already visible... overwriting the old one\n");
62  le->inuse = true;
63  }
64 
65  le->aabb.set(box);
67  le->type = type;
68 
69  Com_DPrintf(DEBUG_CLIENT, "CL_AddEdict: entnum: %i - type: %i\n", entnum, type);
70 }
vec3_t maxs
Definition: aabb.h:258
#define VectorSet(v, x, y, z)
Definition: vector.h:59
void CL_AddEdict(const eventRegister_t *self, dbuffer *msg)
Adds server side edicts to the client for displaying them.
QGL_EXTERN GLint GLenum type
Definition: r_gl.h:94
localEntitiyAddFunc_t addFunc
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
float alpha
Definition: r_entity.h:111
vec3_t origin
AABB eBox
Definition: r_entity.h:103
vec3_t color
Definition: r_entity.h:100
a local entity
#define DEBUG_CLIENT
Definition: defines.h:59
int flags
Definition: r_entity.h:112
void set(const AABB &other)
Copies the values from the given aabb.
Definition: aabb.h:60
#define RF_BOX
Definition: r_entity.h:36
le_t * LE_Get(int entnum)
Searches all local entities for the one with the searched entnum.
le_t * LE_Add(int entnum)
Add a new local entity to the scene.
Definition: aabb.h:42
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
vec3_t mins
Definition: aabb.h:257
void R_EntitySetOrigin(entity_t *ent, const vec3_t origin)
setter for entity origin
Definition: r_entity.cpp:47
static bool CL_AddEdictFunc(le_t *le, entity_t *ent)
Draw the bounding boxes for the server side edicts.
entity_type_t
Definition: q_shared.h:145
AABB aabb
entity_type_t type
bool inuse
Struct that defines one particular event with all its callbacks and data.
Definition: e_main.h:42
#define MAX_EDICTS
Definition: defines.h:99