UFO: Alien Invasion
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
ItemCargo Class Reference

Item cargo class. More...

#include <itemcargo.h>

Public Member Functions

virtual bool add (const objDef_t *od, int amount, int looseAmount)
 Add items to the cargo. More...
 
virtual bool add (const char *objDefId, int amount, int looseAmount)
 Add items to the cargo by objDef Id. More...
 
void empty (void)
 Empties the cargo. More...
 
bool isEmpty (void) const
 Checks if the cargo is empty. More...
 
itemCargo_tget (const objDef_t *od) const
 Returns a cargo item by its object definition. More...
 
int getAmount (const objDef_t *od) const
 Returns amount of an item in the cargo. More...
 
int getLooseAmount (const objDef_t *od) const
 Returns amount of loose item in the cargo. More...
 
linkedList_tlist (void) const
 Returns a copy of the cargo list. More...
 
int count (void) const
 Count all items in the cargo. More...
 
int size (void) const
 Calculate size of all items in the cargo. More...
 
bool load (xmlNode_t *root)
 Load item cargo from xml savegame. More...
 
bool save (xmlNode_t *root) const
 Save item cargo to xml savegame. More...
 
 ItemCargo (void)
 Creates and initializes ItemCargo object. More...
 
 ItemCargo (ItemCargo &itemCargo)
 Creates and initializes ItemCargo object from another one. More...
 
virtual ~ItemCargo (void)
 Destroys ItemCargo with it's internal data. More...
 

Protected Attributes

linkedList_tcargo
 

Detailed Description

Item cargo class.

Definition at line 41 of file itemcargo.h.

Constructor & Destructor Documentation

ItemCargo::ItemCargo ( void  )

Creates and initializes ItemCargo object.

Definition at line 236 of file itemcargo.cpp.

ItemCargo::ItemCargo ( ItemCargo itemCargo)

Creates and initializes ItemCargo object from another one.

Parameters
[in]itemCargoOther object to make copy of

Definition at line 244 of file itemcargo.cpp.

References cargo, cgi, list(), cgame_import_s::LIST_Add(), and LIST_Foreach.

ItemCargo::~ItemCargo ( void  )
virtual

Destroys ItemCargo with it's internal data.

Definition at line 257 of file itemcargo.cpp.

References cargo, and cgi.

Member Function Documentation

bool ItemCargo::add ( const objDef_t od,
int  amount,
int  looseAmount = 0 
)
virtual

Add items to the cargo.

Parameters
[in]odPointer to the Object Definition
[in]amountNumber of items to add
[in]looseAmountNumber of loose items to add (bullets)
Note
use negative values to remove

Definition at line 39 of file itemcargo.cpp.

References objDef_s::ammo, cargo, cgi, cgame_import_s::LIST_Add(), and LIST_Foreach.

Referenced by add(), AII_CollectAmmo(), AII_CollectingItems(), AII_CollectItem(), load(), TEST_F(), TR_Add_f(), and TR_LoadXML().

bool ItemCargo::add ( const char *  objDefId,
int  amount,
int  looseAmount = 0 
)
virtual

Add items to the cargo by objDef Id.

Parameters
[in]objDefIdScripted Id of an object definition
[in]amountNumber of items to add
[in]looseAmountNumber of loose items to add (bullets)

Definition at line 86 of file itemcargo.cpp.

References add(), and INVSH_GetItemByIDSilent().

int ItemCargo::count ( void  ) const

Count all items in the cargo.

Definition at line 172 of file itemcargo.cpp.

References cargo, and LIST_Foreach.

void ItemCargo::empty ( void  )

Empties the cargo.

Definition at line 99 of file itemcargo.cpp.

References cargo, and cgi.

Referenced by AII_CollectingItems(), and B_SellOrAddItems().

itemCargo_t * ItemCargo::get ( const objDef_t od) const

Returns a cargo item by its object definition.

Parameters
[in]odObject Definition pointer
Returns
pointer to the itemCargo_t entry or if no objDef cargo found

Definition at line 117 of file itemcargo.cpp.

References cargo, and LIST_Foreach.

int ItemCargo::getAmount ( const objDef_t od) const

Returns amount of an item in the cargo.

Parameters
[in]odObject Definition pointer
Returns
number of items in the cargo

Definition at line 131 of file itemcargo.cpp.

References itemCargo_s::amount.

Referenced by TR_Add_f(), and TR_FillItems().

int ItemCargo::getLooseAmount ( const objDef_t od) const

Returns amount of loose item in the cargo.

Parameters
[in]odObject Definition pointer
Returns
number of loose items in the cargo

Definition at line 144 of file itemcargo.cpp.

References itemCargo_s::looseAmount.

bool ItemCargo::isEmpty ( void  ) const

Checks if the cargo is empty.

Definition at line 107 of file itemcargo.cpp.

References cargo.

linkedList_t * ItemCargo::list ( void  ) const

Returns a copy of the cargo list.

Returns
linked list of itemCargo_t structures

Definition at line 156 of file itemcargo.cpp.

References cargo, cgi, cgame_import_s::LIST_Add(), and LIST_Foreach.

Referenced by AII_CollectingItems(), B_SellOrAddItems(), ItemCargo(), TR_CargoList(), TR_EmptyTransferCargo(), and TR_TransferStart().

bool ItemCargo::load ( xmlNode_t root)

Load item cargo from xml savegame.

Parameters
[in]rootRoot xml node to load data from

Definition at line 197 of file itemcargo.cpp.

References add(), cgi, SAVE_ITEMCARGO_AMOUNT, SAVE_ITEMCARGO_ITEM, SAVE_ITEMCARGO_ITEMID, SAVE_ITEMCARGO_LOOSEAMOUNT, cgame_import_s::XML_GetNextNode(), cgame_import_s::XML_GetNode(), cgame_import_s::XML_GetString(), and xmlNode_t.

Referenced by AIR_LoadAircraftXML(), and TR_LoadXML().

bool ItemCargo::save ( xmlNode_t root) const

Save item cargo to xml savegame.

Parameters
[out]rootRoot xml node to save data under

Definition at line 218 of file itemcargo.cpp.

References cargo, cgi, LIST_Foreach, SAVE_ITEMCARGO_AMOUNT, SAVE_ITEMCARGO_ITEM, SAVE_ITEMCARGO_ITEMID, SAVE_ITEMCARGO_LOOSEAMOUNT, cgame_import_s::XML_AddNode(), and xmlNode_t.

Referenced by AIR_SaveAircraftXML().

int ItemCargo::size ( void  ) const

Calculate size of all items in the cargo.

Definition at line 184 of file itemcargo.cpp.

References cargo, and LIST_Foreach.

Referenced by TR_DestinationCapacityList_f().

Field Documentation

linkedList_t* ItemCargo::cargo
protected

Definition at line 43 of file itemcargo.h.

Referenced by add(), count(), empty(), get(), isEmpty(), ItemCargo(), list(), save(), size(), and ~ItemCargo().


The documentation for this class was generated from the following files: