UFO: Alien Invasion
Loading...
Searching...
No Matches
e_event_addedict.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_addedict.h"
28
29
33static 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
48void 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}
le_t * LE_Add(int entnum)
Add a new local entity to the scene.
le_t * LE_Get(int entnum)
Searches all local entities for the one with the searched entnum.
Definition aabb.h:42
vec3_t maxs
Definition aabb.h:258
vec3_t mins
Definition aabb.h:257
void set(const AABB &other)
Copies the values from the given aabb.
Definition aabb.h:60
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 MAX_EDICTS
Definition defines.h:99
#define DEBUG_CLIENT
Definition defines.h:59
void CL_AddEdict(const eventRegister_t *self, dbuffer *msg)
Adds server side edicts to the client for displaying them.
static bool CL_AddEdictFunc(le_t *le, entity_t *ent)
Draw the bounding boxes for the server side edicts.
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
entity_type_t
Definition q_shared.h:145
void R_EntitySetOrigin(entity_t *ent, const vec3_t origin)
setter for entity origin
Definition r_entity.cpp:47
#define RF_BOX
Definition r_entity.h:36
QGL_EXTERN GLint GLenum type
Definition r_gl.h:94
float alpha
Definition r_entity.h:111
int flags
Definition r_entity.h:112
vec3_t color
Definition r_entity.h:100
AABB eBox
Definition r_entity.h:103
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
a local entity
vec3_t origin
localEntitiyAddFunc_t addFunc
AABB aabb
bool inuse
entity_type_t type
#define VectorSet(v, x, y, z)
Definition vector.h:59