e_event_addedict.c

Go to the documentation of this file.
00001 
00005 /*
00006 Copyright (C) 2002-2010 UFO: Alien Invasion.
00007 
00008 This program is free software; you can redistribute it and/or
00009 modify it under the terms of the GNU General Public License
00010 as published by the Free Software Foundation; either version 2
00011 of the License, or (at your option) any later version.
00012 
00013 This program is distributed in the hope that it will be useful,
00014 but WITHOUT ANY WARRANTY; without even the implied warranty of
00015 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
00016 
00017 See the GNU General Public License for more details.
00018 
00019 You should have received a copy of the GNU General Public License
00020 along with this program; if not, write to the Free Software
00021 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00022 
00023 */
00024 
00025 #include "../../../../client.h"
00026 #include "../../../cl_localentity.h"
00027 #include "e_event_addedict.h"
00028 
00029 
00033 static qboolean CL_AddEdictFunc (le_t *le, entity_t *ent)
00034 {
00035     ent->flags = RF_BOX;
00036     VectorSet(ent->color, 1, 1, 1);
00037     ent->alpha = 1.0;
00038     VectorCopy(le->mins, ent->mins);
00039     VectorCopy(le->maxs, ent->maxs);
00040     R_EntitySetOrigin(ent, le->origin);
00041     return qtrue;
00042 }
00043 
00049 void CL_AddEdict (const eventRegister_t *self, struct dbuffer * msg)
00050 {
00051     le_t *le;
00052     int entnum;
00053     entity_type_t type;
00054     vec3_t mins, maxs;
00055 
00056     NET_ReadFormat(msg, self->formatString, &type, &entnum, &mins, &maxs);
00057 
00058     /* use an offset to ensure that we don't conflict with any other solid edict that is already spawned */
00059     le = LE_Get(entnum + MAX_EDICTS);
00060     if (!le) {
00061         le = LE_Add(entnum + MAX_EDICTS);
00062     } else {
00063         Com_DPrintf(DEBUG_CLIENT, "CL_AddEdict: Entity appearing already visible... overwriting the old one\n");
00064         le->inuse = qtrue;
00065     }
00066 
00067     VectorCopy(mins, le->mins);
00068     VectorCopy(maxs, le->maxs);
00069     le->addFunc = CL_AddEdictFunc;
00070     le->type = type;
00071 
00072     Com_DPrintf(DEBUG_CLIENT, "CL_AddEdict: entnum: %i - type: %i\n", entnum, type);
00073 }

Generated by  doxygen 1.6.2