UFO: Alien Invasion
Doxygen documentation generating
e_event_addbrushmodel.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_addbrushmodel.h"
28 #include "../../../../ui/ui_main.h"
29 
37 void CL_AddBrushModel (const eventRegister_t* self, dbuffer* msg)
38 {
39  int entnum, modelnum1, levelflags, speed, dir;
41  const cBspModel_t* model;
42  int angle;
43  vec3_t origin, angles;
44 
45  NET_ReadFormat(msg, self->formatString, &entnum, &type, &modelnum1, &levelflags, &origin, &angles, &speed, &angle, &dir);
46 
48  Com_Error(ERR_DROP, "Invalid le announced via EV_ADD_BRUSH_MODEL type: %i\n", type);
49  else if (modelnum1 > MAX_MODELS || modelnum1 < 1)
50  Com_Error(ERR_DROP, "Invalid le modelnum1 announced via EV_ADD_BRUSH_MODEL\n");
51 
52  /* check if the ent is already visible */
53  le_t* le = LE_Get(entnum);
54  if (le)
55  Com_Error(ERR_DROP, "le announced a second time - le for entnum %i (type: %i) already exists (via EV_ADD_BRUSH_MODEL)\n", entnum, type);
56 
57  le = LE_Add(entnum);
58  assert(le);
59 
60  le->rotationSpeed = speed;
61  le->slidingSpeed = speed;
62  le->angle = angle;
63  le->dir = dir;
64  le->type = type;
65  le->modelnum1 = modelnum1;
66  le->levelflags = levelflags;
69  /* The origin and angles are REQUIRED for doors to work! */
70  VectorCopy(origin, le->origin);
71  /* store the initial position - needed for sliding doors */
72  VectorCopy(le->origin, le->oldOrigin);
73  VectorCopy(angles, le->angles);
74 
75  Com_sprintf(le->inlineModelName, sizeof(le->inlineModelName), "*%i", le->modelnum1);
76  model = LE_GetClipModel(le);
78  if (!le->model1)
79  Com_Error(ERR_DROP, "CL_AddBrushModel: Could not register inline model %i", le->modelnum1);
80 
81  /* Transfer model mins and maxs to entity */
82  le->aabb.set(model->cbmBox);
83  le->aabb.getDiagonal(le->size);
84  VecToPos(le->origin, le->pos);
85 
86  /* to allow tracing against this le */
87  if (!LE_IsNotSolid(le)) {
88  /* This is to help the entity collision code out */
89  /* Copy entity origin and angles to model*/
91 
94 
95  CL_RecalcRouting(le);
96  }
97 
98  if (le->type == ET_TRIGGER_RESCUE) {
99  UI_ExecuteConfunc("enable_rescuezone");
100  }
101 }
vec3_t size
#define VectorCopy(src, dest)
Definition: vector.h:51
void CL_RecalcRouting(const le_t *le)
QGL_EXTERN GLint GLenum type
Definition: r_gl.h:94
localEntitiyAddFunc_t addFunc
vec3_t oldOrigin
const cBspModel_t * LE_GetClipModel(const le_t *le)
#define CONTENTS_SOLID
Definition: defines.h:223
void getDiagonal(vec3_t diagonal) const
Definition: aabb.h:159
voidpf uLong int origin
Definition: ioapi.h:45
bool Com_sprintf(char *dest, size_t size, const char *fmt,...)
copies formatted string with buffer-size checking
Definition: shared.cpp:494
int flags
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
int contents
void LET_BrushModel(le_t *le)
vec3_t origin
mapTiles_t * mapTiles
int angle
void Com_Error(int code, const char *fmt,...)
Definition: common.cpp:417
model_t * model1
#define LE_CHECK_LEVELFLAGS
float angles[3]
a local entity
#define ERR_DROP
Definition: common.h:211
void set(const AABB &other)
Copies the values from the given aabb.
Definition: aabb.h:60
le_t * LE_Get(int entnum)
Searches all local entities for the one with the searched entnum.
int slidingSpeed
void CL_AddBrushModel(const eventRegister_t *self, dbuffer *msg)
Register local entities for SOLID_BSP models like func_breakable or func_door.
#define VecToPos(v, p)
Map boundary is +/- MAX_WORLD_WIDTH - to get into the positive area we add the possible max negative ...
Definition: mathlib.h:100
le_t * LE_Add(int entnum)
Add a new local entity to the scene.
clientBattleScape_t cl
int dir
model_t * R_FindModel(const char *name)
Tries to load a model.
Definition: r_model.cpp:203
int levelflags
#define MAX_MODELS
Definition: defines.h:100
AABB cbmBox
Definition: typedefs.h:27
unsigned int modelnum1
float rotationSpeed
cBspModel_t * CM_SetInlineModelOrientation(mapTiles_t *mapTiles, const char *name, const vec3_t origin, const vec3_t angles)
This function updates a model&#39;s orientation.
Definition: bsp.cpp:963
vec_t vec3_t[3]
Definition: ufotypes.h:39
entity_type_t
Definition: q_shared.h:145
AABB aabb
bool LE_BrushModelAction(le_t *le, entity_t *ent)
Add function for brush models.
entity_type_t type
char inlineModelName[8]
void LE_SetThink(le_t *le, localEntityThinkFunc_t think)
#define LE_IsNotSolid(le)
Struct that defines one particular event with all its callbacks and data.
Definition: e_main.h:42
void UI_ExecuteConfunc(const char *fmt,...)
Executes confunc - just to identify those confuncs in the code - in this frame.
Definition: ui_main.cpp:110
pos3_t pos