UFO: Alien Invasion
itemcargo.h
Go to the documentation of this file.
1
6/*
7Copyright (C) 2002-2022 UFO: Alien Invasion.
8
9This program is free software; you can redistribute it and/or
10modify it under the terms of the GNU General Public License
11as published by the Free Software Foundation; either version 2
12of the License, or (at your option) any later version.
13
14This program is distributed in the hope that it will be useful,
15but WITHOUT ANY WARRANTY; without even the implied warranty of
16MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
17
18See the GNU General Public License for more details.
19
20You should have received a copy of the GNU General Public License
21along with this program; if not, write to the Free Software
22Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23*/
24
25#pragma once
26
27#include "cp_cgame_callbacks.h"
28
32typedef struct itemCargo_s {
34 int amount;
37
41class 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};
Item cargo class.
Definition: itemcargo.h:41
virtual ~ItemCargo(void)
Destroys ItemCargo with it's internal data.
Definition: itemcargo.cpp:257
int size(void) const
Calculate size of all items in the cargo.
Definition: itemcargo.cpp:184
linkedList_t * cargo
Definition: itemcargo.h:43
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
ItemCargo(void)
Creates and initializes ItemCargo object.
Definition: itemcargo.cpp:236
bool save(xmlNode_t *root) const
Save item cargo to xml savegame.
Definition: itemcargo.cpp:218
bool isEmpty(void) const
Checks if the cargo is empty.
Definition: itemcargo.cpp:107
int count(void) const
Count all items in the cargo.
Definition: itemcargo.cpp:172
itemCargo_t * get(const objDef_t *od) const
Returns a cargo item by its object definition.
Definition: itemcargo.cpp:117
int getLooseAmount(const objDef_t *od) const
Returns amount of loose item in the cargo.
Definition: itemcargo.cpp:144
linkedList_t * list(void) const
Returns a copy of the cargo list.
Definition: itemcargo.cpp:156
virtual bool add(const objDef_t *od, int amount, int looseAmount)
Add items to the cargo.
Definition: itemcargo.cpp:39
int getAmount(const objDef_t *od) const
Returns amount of an item in the cargo.
Definition: itemcargo.cpp:131
item cargo entry
Definition: itemcargo.h:32
const objDef_t * objDef
Definition: itemcargo.h:33
int amount
Definition: itemcargo.h:34
int looseAmount
Definition: itemcargo.h:35
Defines all attributes of objects used in the inventory.
Definition: inv_shared.h:264
#define xmlNode_t
Definition: xml.h:24