UFO: Alien Invasion
Loading...
Searching...
No Matches
ItemCargo Class Reference

Item cargo class. More...

#include <itemcargo.h>

Collaboration diagram for ItemCargo:
Collaboration graph

Public Member Functions

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

Protected Attributes

linkedList_tcargo

Detailed Description

Item cargo class.

Definition at line 41 of file itemcargo.h.

Constructor & Destructor Documentation

◆ ItemCargo() [1/2]

ItemCargo::ItemCargo ( void )

Creates and initializes ItemCargo object.

Definition at line 236 of file itemcargo.cpp.

References cargo, and nullptr.

Referenced by ItemCargo().

◆ ItemCargo() [2/2]

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, ItemCargo(), list(), LIST_Foreach, and nullptr.

◆ ~ItemCargo()

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

◆ add() [1/2]

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().

◆ add() [2/2]

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 add(), objDef_t::ammo, cargo, cgi, and LIST_Foreach.

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

◆ count()

int ItemCargo::count ( void ) const

Count all items in the cargo.

Definition at line 172 of file itemcargo.cpp.

References cargo, count(), and LIST_Foreach.

Referenced by count().

◆ empty()

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().

◆ get()

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.

Referenced by getAmount(), and getLooseAmount().

◆ getAmount()

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_t::amount, and get().

◆ getLooseAmount()

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 get(), and itemCargo_t::looseAmount.

◆ isEmpty()

bool ItemCargo::isEmpty ( void ) const

Checks if the cargo is empty.

Definition at line 107 of file itemcargo.cpp.

References cargo.

◆ list()

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, and LIST_Foreach.

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

◆ load()

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, and xmlNode_t.

Referenced by AIR_LoadAircraftXML(), and TR_LoadXML().

◆ save()

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, and xmlNode_t.

Referenced by AIR_SaveAircraftXML().

◆ size()

int ItemCargo::size ( void ) const

Calculate size of all items in the cargo.

Definition at line 184 of file itemcargo.cpp.

References cargo, LIST_Foreach, and size().

Referenced by size().

Field Documentation

◆ cargo

linkedList_t* ItemCargo::cargo
protected

Definition at line 43 of file itemcargo.h.

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


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