UFO: Alien Invasion
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
itemcargo.h
Go to the documentation of this file.
1 
6 /*
7 Copyright (C) 2002-2020 UFO: Alien Invasion.
8 
9 This program is free software; you can redistribute it and/or
10 modify it under the terms of the GNU General Public License
11 as published by the Free Software Foundation; either version 2
12 of the License, or (at your option) any later version.
13 
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
17 
18 See the GNU General Public License for more details.
19 
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23 */
24 
25 #pragma once
26 
27 #include "cp_cgame_callbacks.h"
28 
32 typedef struct itemCargo_s {
33  const objDef_t* objDef;
34  int amount;
36 } itemCargo_t;
37 
41 class ItemCargo {
42  protected:
44  public:
45  virtual bool add (const objDef_t* od, int amount, int looseAmount);
46  virtual bool add (const char* objDefId, int amount, int looseAmount);
47 
48  void empty (void);
49  bool isEmpty (void) const;
50 
51  itemCargo_t* get (const objDef_t* od) const;
52  int getAmount (const objDef_t* od) const;
53  int getLooseAmount (const objDef_t* od) const;
54  linkedList_t* list (void) const;
55 
56  int count (void) const;
57  int size (void) const;
58 
59  bool load(xmlNode_t* root);
60  bool save(xmlNode_t* root) const;
61 
62  ItemCargo (void);
63  ItemCargo (ItemCargo& itemCargo);
64  virtual ~ItemCargo (void);
65 };
const objDef_t * objDef
Definition: itemcargo.h:33
virtual bool add(const objDef_t *od, int amount, int looseAmount)
Add items to the cargo.
Definition: itemcargo.cpp:39
int getLooseAmount(const objDef_t *od) const
Returns amount of loose item in the cargo.
Definition: itemcargo.cpp:144
int looseAmount
Definition: itemcargo.h:35
void empty(void)
Empties the cargo.
Definition: itemcargo.cpp:99
bool load(xmlNode_t *root)
Load item cargo from xml savegame.
Definition: itemcargo.cpp:197
Defines all attributes of objects used in the inventory.
Definition: inv_shared.h:264
struct itemCargo_s itemCargo_t
item cargo entry
#define xmlNode_t
Definition: xml.h:24
int size(void) const
Calculate size of all items in the cargo.
Definition: itemcargo.cpp:184
Item cargo class.
Definition: itemcargo.h:41
linkedList_t * cargo
Definition: itemcargo.h:43
bool isEmpty(void) const
Checks if the cargo is empty.
Definition: itemcargo.cpp:107
ItemCargo(void)
Creates and initializes ItemCargo object.
Definition: itemcargo.cpp:236
virtual ~ItemCargo(void)
Destroys ItemCargo with it's internal data.
Definition: itemcargo.cpp:257
int count(void) const
Count all items in the cargo.
Definition: itemcargo.cpp:172
int amount
Definition: itemcargo.h:34
bool save(xmlNode_t *root) const
Save item cargo to xml savegame.
Definition: itemcargo.cpp:218
linkedList_t * list(void) const
Returns a copy of the cargo list.
Definition: itemcargo.cpp:156
item cargo entry
Definition: itemcargo.h:32
int getAmount(const objDef_t *od) const
Returns amount of an item in the cargo.
Definition: itemcargo.cpp:131