UFO: Alien Invasion
Loading...
Searching...
No Matches
e_event_addbrushmodel.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"
29
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! */
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
96 }
97
98 if (le->type == ET_TRIGGER_RESCUE) {
99 UI_ExecuteConfunc("enable_rescuezone");
100 }
101}
clientBattleScape_t cl
void CL_RecalcRouting(const le_t *le)
bool LE_BrushModelAction(le_t *le, entity_t *ent)
Add function for brush models.
void LET_BrushModel(le_t *le)
const cBspModel_t * LE_GetClipModel(const le_t *le)
le_t * LE_Add(int entnum)
Add a new local entity to the scene.
void LE_SetThink(le_t *le, localEntityThinkFunc_t think)
le_t * LE_Get(int entnum)
Searches all local entities for the one with the searched entnum.
#define LE_IsNotSolid(le)
#define LE_CHECK_LEVELFLAGS
void getDiagonal(vec3_t diagonal) const
Definition aabb.h:159
void set(const AABB &other)
Copies the values from the given aabb.
Definition aabb.h:60
Primary header for client.
cBspModel_t * CM_SetInlineModelOrientation(mapTiles_t *mapTiles, const char *name, const vec3_t origin, const vec3_t angles)
This function updates a model's orientation.
Definition bsp.cpp:963
void Com_Error(int code, const char *fmt,...)
Definition common.cpp:459
#define ERR_DROP
Definition common.h:211
#define CONTENTS_SOLID
Definition defines.h:223
#define MAX_MODELS
Definition defines.h:100
void CL_AddBrushModel(const eventRegister_t *self, dbuffer *msg)
Register local entities for SOLID_BSP models like func_breakable or func_door.
voidpf uLong int origin
Definition ioapi.h:45
#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
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
@ ET_TRIGGER_NEXTMAP
Definition q_shared.h:155
@ ET_TRIGGER_RESCUE
Definition q_shared.h:154
@ ET_ROTATING
Definition q_shared.h:158
@ ET_BREAKABLE
Definition q_shared.h:150
@ ET_DOOR
Definition q_shared.h:156
@ ET_DOOR_SLIDING
Definition q_shared.h:157
QGL_EXTERN GLint GLenum type
Definition r_gl.h:94
model_t * R_FindModel(const char *name)
Tries to load a model.
Definition r_model.cpp:203
bool Com_sprintf(char *dest, size_t size, const char *fmt,...)
copies formatted string with buffer-size checking
Definition shared.cpp:494
AABB cbmBox
Definition typedefs.h:27
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
int slidingSpeed
int flags
int contents
float angles[3]
vec3_t origin
int angle
localEntitiyAddFunc_t addFunc
unsigned int modelnum1
vec3_t oldOrigin
pos3_t pos
model_t * model1
float rotationSpeed
AABB aabb
vec3_t size
char inlineModelName[8]
entity_type_t type
int levelflags
vec_t vec3_t[3]
Definition ufotypes.h:39
void UI_ExecuteConfunc(const char *fmt,...)
Executes confunc - just to identify those confuncs in the code - in this frame.
Definition ui_main.cpp:110
#define VectorCopy(src, dest)
Definition vector.h:51