UFO: Alien Invasion
Loading...
Searching...
No Matches
e_event_actoradd.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_actoradd.h"
29
37void CL_ActorAdd (const eventRegister_t* self, dbuffer* msg)
38{
39 /* check if the actor is already visible */
40 const int entnum = NET_ReadShort(msg);
41 le_t* le = LE_Get(entnum);
42 if (le) {
43 Com_Printf("CL_ActorAdd: Actor with number %i already exists\n", entnum);
44 NET_SkipFormat(msg, self->formatString);
45 return;
46 }
47 le = LE_Add(entnum);
48
49 /* get the info */
50 int teamDefID;
52 &le->team, &teamDefID,
53 &le->gender, &le->pnum, &le->pos,
54 &le->state, &le->fieldSize);
55
56 if (teamDefID < 0 || teamDefID > csi.numTeamDefs)
57 Com_Printf("CL_ActorAdd: Invalid teamDef index\n");
58 else
59 le->teamDef = &csi.teamDef[teamDefID];
60
61 /*Com_Printf("CL_ActorAdd: Add number: %i\n", entnum);*/
62
63 le->type = ET_ACTORHIDDEN;
64
65 Grid_PosToVec(cl.mapData->routing, le->fieldSize, le->pos, le->origin);
66 le->flags = LE_INVISIBLE;
67}
clientBattleScape_t cl
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.
#define LE_INVISIBLE
Primary header for client.
csi_t csi
Definition common.cpp:39
void Com_Printf(const char *const fmt,...)
Definition common.cpp:428
void CL_ActorAdd(const eventRegister_t *self, dbuffer *msg)
Adds an hidden actor to the list of le's.
void Grid_PosToVec(const Routing &routing, const actorSizeEnum_t actorSize, const pos3_t pos, vec3_t vec)
Converts a grid position to world coordinates.
Definition grid.cpp:832
Battlescape grid functions.
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 NET_ReadShort(dbuffer *buf)
Definition netpack.cpp:242
void NET_SkipFormat(dbuffer *buf, const char *format)
Definition netpack.cpp:476
@ ET_ACTORHIDDEN
Definition q_shared.h:163
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 state
int flags
vec3_t origin
actorSizeEnum_t fieldSize
pos3_t pos
teamDef_t * teamDef
entity_type_t type