MCPcopy Create free account
hub / github.com/OpenXcom/OpenXcom / getCarriedWeight

Method getCarriedWeight

src/Savegame/BattleUnit.cpp:2433–2443  ·  view source on GitHub ↗

* Get the units carried weight in strength units. * @param draggingItem item to ignore * @return weight */

Source from the content-addressed store, hash-verified

2431 * @return weight
2432 */
2433int BattleUnit::getCarriedWeight(BattleItem *draggingItem) const
2434{
2435 int weight = _armor->getWeight();
2436 for (std::vector<BattleItem*>::const_iterator i = _inventory.begin(); i != _inventory.end(); ++i)
2437 {
2438 if ((*i) == draggingItem) continue;
2439 weight += (*i)->getRules()->getWeight();
2440 if ((*i)->getAmmoItem() != (*i) && (*i)->getAmmoItem()) weight += (*i)->getAmmoItem()->getRules()->getWeight();
2441 }
2442 return std::max(0,weight);
2443}
2444
2445/**
2446 * Set how long since this unit was last exposed.

Callers 2

addItemMethod · 0.80
updateStatsMethod · 0.80

Calls 3

getWeightMethod · 0.45
getRulesMethod · 0.45
getAmmoItemMethod · 0.45

Tested by

no test coverage detected