Skip to content

Commit

Permalink
Add "transferTime" property to ruleset soldiers.
Browse files Browse the repository at this point in the history
  • Loading branch information
SupSuper committed Dec 5, 2018
1 parent 70aace3 commit 47d522c
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
5 changes: 4 additions & 1 deletion src/Basescape/PurchaseState.cpp
Expand Up @@ -338,7 +338,10 @@ void PurchaseState::btnOkClick(Action *)
for (int s = 0; s < i->amount; s++)
{
RuleSoldier *rule = (RuleSoldier*)i->rule;
t = new Transfer(_game->getMod()->getPersonnelTime());
int time = rule->getTransferTime();
if (time == 0)
time = _game->getMod()->getPersonnelTime();
t = new Transfer(time);
t->setSoldier(_game->getMod()->genSoldier(_game->getSavedGame(), rule->getType()));
_base->getTransfers()->push_back(t);
}
Expand Down
13 changes: 12 additions & 1 deletion src/Mod/RuleSoldier.cpp
Expand Up @@ -29,7 +29,7 @@ namespace OpenXcom
* type of soldier.
* @param type String defining the type.
*/
RuleSoldier::RuleSoldier(const std::string &type) : _type(type), _costBuy(0), _costSalary(0), _standHeight(0), _kneelHeight(0), _floatHeight(0), _femaleFrequency(50), _value(20)
RuleSoldier::RuleSoldier(const std::string &type) : _type(type), _costBuy(0), _costSalary(0), _standHeight(0), _kneelHeight(0), _floatHeight(0), _femaleFrequency(50), _value(20), _transferTime(0)
{
}

Expand Down Expand Up @@ -67,6 +67,7 @@ void RuleSoldier::load(const YAML::Node &node, Mod *mod)
_floatHeight = node["floatHeight"].as<int>(_floatHeight);
_femaleFrequency = node["femaleFrequency"].as<int>(_femaleFrequency);
_value = node["value"].as<int>(_value);
_transferTime = node["transferTime"].as<int>(_transferTime);

if (node["deathMale"])
{
Expand Down Expand Up @@ -283,4 +284,14 @@ int RuleSoldier::getValue() const
return _value;
}

/**
* Gets the amount of time this item
* takes to arrive at a base.
* @return The time in hours.
*/
int RuleSoldier::getTransferTime() const
{
return _transferTime;
}

}
4 changes: 3 additions & 1 deletion src/Mod/RuleSoldier.h
Expand Up @@ -40,7 +40,7 @@ class RuleSoldier
UnitStats _minStats, _maxStats, _statCaps;
std::string _armor;
int _costBuy, _costSalary, _standHeight, _kneelHeight, _floatHeight;
int _femaleFrequency, _value;
int _femaleFrequency, _value, _transferTime;
std::vector<int> _deathSoundMale, _deathSoundFemale;
std::vector<SoldierNamePool*> _names;

Expand Down Expand Up @@ -84,6 +84,8 @@ class RuleSoldier
const std::vector<SoldierNamePool*> &getNames() const;
/// Gets the value - for score calculation.
int getValue() const;
/// Gets the soldier's transfer time.
int getTransferTime() const;
};

}

0 comments on commit 47d522c

Please sign in to comment.