e_event_invdel.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_invdel.h"
00028 
00032 void CL_InvDel (const eventRegister_t *self, struct dbuffer *msg)
00033 {
00034     le_t    *le;
00035     int     number;
00036     int     x, y;
00037     containerIndex_t container;
00038     invList_t   *ic;
00039 
00040     NET_ReadFormat(msg, self->formatString, &number, &container, &x, &y);
00041 
00042     le = LE_Get(number);
00043     if (!le)
00044         Com_Error(ERR_DROP, "InvDel message ignored... LE not found\n");
00045 
00046     /* update the local entity to ensure that the correct weapon/item is rendered in the battlescape */
00047     if (container == csi.idRight)
00048         le->right = NONE;
00049     else if (container == csi.idLeft)
00050         le->left = NONE;
00051     else if (container == csi.idExtension)
00052         le->extension = NONE;
00053     else if (container == csi.idHeadgear)
00054         le->headgear = NONE;
00055 
00056     if (le->type == ET_ACTOR || le->type == ET_ACTOR2x2)
00057         LE_SetThink(le, LET_StartIdle);
00058 
00059     ic = INVSH_SearchInInventory(&le->i, INVDEF(container), x, y);
00060     /* ic can be null for other team actors - we don't the full inventory of them, only
00061      * the object index */
00062     if (!ic)
00063         return;
00064 
00065     if (!cls.i.RemoveFromInventory(&cls.i, &le->i, INVDEF(container), ic))
00066         Com_Error(ERR_DROP, "CL_InvDel: No item was removed from container %i", container);
00067 
00068     /* update the rendered item after it was removed from the floor container */
00069     if (LE_IsItem(le))
00070         LE_PlaceItem(le);
00071 }
00072 

Generated by  doxygen 1.6.2