UFO: Alien Invasion
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
e_event_cameraappear.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 "../../../../renderer/r_mesh_anim.h"
28 #include "e_event_cameraappear.h"
29 
34 void CL_CameraAppear (const eventRegister_t* self, dbuffer* msg)
35 {
36  int entnum;
37  int team;
38  int levelflags;
39  int dir;
40  int rotate;
41  vec3_t origin;
42  camera_type_t cameraType;
43 
44  NET_ReadFormat(msg, self->formatString, &entnum, &origin, &team, &dir, &cameraType, &levelflags, &rotate);
45 
46  le_t* le = LE_Get(entnum);
47  if (!le) {
48  le = LE_Add(entnum);
49  } else {
50  le->inuse = true;
51  }
52 
53  VectorCopy(origin, le->origin);
54  le->type = ET_CAMERA;
55  le->team = team;
56  le->angles[YAW] = directionAngles[le->angle];
58  le->levelflags = levelflags;
59  le->model1 = R_FindModel(va("objects/cameras/camera%i", cameraType));
60  if (rotate) {
61  const char* rotateAnim = "rotate";
62  R_AnimChange(&le->as, le->model1, rotateAnim);
63  }
64 
65  Com_DPrintf(DEBUG_CLIENT, "CL_CameraAppear: entnum: %i\n", entnum);
66 }
animState_t as
#define VectorCopy(src, dest)
Definition: vector.h:51
const char * va(const char *format,...)
does a varargs printf into a temp buffer, so I don't need to have varargs versions of all text functi...
Definition: shared.cpp:410
float angles[3]
voidpf uLong int origin
Definition: ioapi.h:45
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 angle
vec3_t origin
void R_AnimChange(animState_t *as, const model_t *mod, const char *name)
Changes the animation for md2 models.
#define YAW
Definition: mathlib.h:55
#define LE_CHECK_LEVELFLAGS
int flags
#define DEBUG_CLIENT
Definition: defines.h:59
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.
model_t * model1
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
model_t * R_FindModel(const char *name)
Tries to load a model.
Definition: r_model.cpp:203
Struct that defines one particular event with all its callbacks and data.
Definition: e_main.h:42
a local entity
void CL_CameraAppear(const eventRegister_t *self, dbuffer *msg)
Adds a camera edicts to the client for displaying them.
entity_type_t type
camera_type_t
Definition: q_shared.h:178
bool inuse
vec_t vec3_t[3]
Definition: ufotypes.h:39
const float directionAngles[CORE_DIRECTIONS]
Definition: mathlib.cpp:105
int levelflags
int team