e_event_invammo.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_invammo.h"
00028 
00029 void CL_InvAmmo (const eventRegister_t *self, struct dbuffer *msg)
00030 {
00031     invList_t   *ic;
00032     le_t    *le;
00033     int     number;
00034     int     ammo, type, x, y;
00035     containerIndex_t container;
00036 
00037     NET_ReadFormat(msg, self->formatString, &number, &ammo, &type, &container, &x, &y);
00038 
00039     le = LE_Get(number);
00040     if (!le) {
00041         Com_DPrintf(DEBUG_CLIENT, "InvAmmo message ignored... LE not found\n");
00042         return;
00043     }
00044 
00045     if (le->team != cls.team)
00046         return;
00047 
00048     assert(container >= 0);
00049     assert(container < MAX_INVDEFS);
00050     ic = INVSH_SearchInInventory(&le->i, INVDEF(container), x, y);
00051     if (!ic)
00052         return;
00053 
00054     /* set new ammo */
00055     ic->item.a = ammo;
00056     ic->item.m = INVSH_GetItemByIDX(type);
00057 }

Generated by  doxygen 1.6.2