Skip to content

Commit e1d1436

Browse files
committed
Merge pull request OpenXcom#1 from redv/craftSellCost
added aircraft's rent for a month.
2 parents c0e6487 + 06f2e7b commit e1d1436

6 files changed

Lines changed: 44 additions & 30 deletions

File tree

‎bin/data/Ruleset/Xcom1Ruleset.rul‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1065,6 +1065,7 @@ crafts:
10651065
soldiers: 14
10661066
vehicles: 3
10671067
costBuy: 500000
1068+
costRent: 500000
10681069
refuelRate: 50
10691070
transferTime: 72
10701071
score: 200
@@ -1085,6 +1086,7 @@ crafts:
10851086
accel: 3
10861087
weapons: 2
10871088
costBuy: 600000
1089+
costRent: 600000
10881090
refuelRate: 50
10891091
transferTime: 96
10901092
score: 250

‎src/Basescape/MonthlyCostsState.cpp‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,11 +118,11 @@ MonthlyCostsState::MonthlyCostsState(Game *game, Base *base) : State(game), _bas
118118
for (std::vector<std::string>::const_iterator i = crafts.begin(); i != crafts.end(); ++i)
119119
{
120120
RuleCraft *craft = _game->getRuleset()->getCraft(*i);
121-
if (craft->getBuyCost() > 0)
121+
if (craft->getRentCost() > 0 && _game->getSavedGame()->isResearched(_game->getRuleset()->getUfopaediaArticle(craft->getType())->requires))
122122
{
123123
std::wstringstream ss2;
124124
ss2 << _base->getCraftCount((*i));
125-
_lstCrafts->addRow(4, _game->getLanguage()->getString(*i).c_str(), Text::formatFunding(craft->getBuyCost()).c_str(), ss2.str().c_str(), Text::formatFunding(_base->getCraftCount(*i) * craft->getBuyCost()).c_str());
125+
_lstCrafts->addRow(4, _game->getLanguage()->getString(*i).c_str(), Text::formatFunding(craft->getRentCost()).c_str(), ss2.str().c_str(), Text::formatFunding(_base->getCraftCount(*i) * craft->getRentCost()).c_str());
126126
}
127127
}
128128

‎src/Basescape/SellState.cpp‎

Lines changed: 19 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@
3636
#include "../Savegame/ItemContainer.h"
3737
#include "../Ruleset/Ruleset.h"
3838
#include "../Ruleset/RuleItem.h"
39-
#include "../Ruleset/RuleCraft.h"
4039
#include "../Ruleset/Armor.h"
4140
#include "../Savegame/CraftWeapon.h"
4241
#include "../Ruleset/RuleCraftWeapon.h"
@@ -158,8 +157,7 @@ SellState::SellState(Game *game, Base *base) : State(game), _base(base), _qtys()
158157
{
159158
_qtys.push_back(0);
160159
_crafts.push_back(*i);
161-
RuleCraft *rule = (*i)->getRules();
162-
_lstItems->addRow(4, (*i)->getName(_game->getLanguage()).c_str(), L"1", L"0", Text::formatFunding(rule->getSellCost()).c_str());
160+
_lstItems->addRow(4, (*i)->getName(_game->getLanguage()).c_str(), L"1", L"0", Text::formatFunding((*i)->getRules()->getSellCost()).c_str());
163161
}
164162
}
165163
if (_base->getAvailableScientists() > 0)
@@ -234,10 +232,10 @@ void SellState::btnOkClick(Action *)
234232
for (unsigned int i = 0; i < _qtys.size(); ++i)
235233
{
236234
if (_qtys[i] > 0)
237-
{
238-
// Sell soldiers
239-
if (SELL_SOLDIER == getType(i))
235+
{
236+
switch (getType(i))
240237
{
238+
case SELL_SOLDIER:
241239
for (std::vector<Soldier*>::iterator s = _base->getSoldiers()->begin(); s != _base->getSoldiers()->end(); ++s)
242240
{
243241
if (*s == _soldiers[i])
@@ -251,11 +249,11 @@ void SellState::btnOkClick(Action *)
251249
}
252250
}
253251
delete _soldiers[i];
254-
}
255-
// Sell crafts
256-
else if (SELL_CRAFT == getType(i))
257-
{
258-
Craft *craft = _crafts[getCraftIndex(i)];
252+
break;
253+
254+
case SELL_CRAFT:
255+
{
256+
Craft *craft = _crafts[getCraftIndex(i)];
259257

260258
// Remove weapons from craft
261259
for (std::vector<CraftWeapon*>::iterator w = craft->getWeapons()->begin(); w != craft->getWeapons()->end(); ++w)
@@ -292,20 +290,18 @@ void SellState::btnOkClick(Action *)
292290
}
293291
}
294292
delete craft;
295-
}
296-
// Sell scientists
297-
else if (SELL_SCIENTIST == getType(i))
298-
{
293+
}
294+
break;
295+
296+
case SELL_SCIENTIST:
299297
_base->setScientists(_base->getScientists() - _qtys[i]);
300-
}
301-
// Sell engineers
302-
else if (SELL_ENGINEER == getType(i))
303-
{
298+
break;
299+
300+
case SELL_ENGINEER:
304301
_base->setEngineers(_base->getEngineers() - _qtys[i]);
305-
}
306-
// Sell items
307-
else
308-
{
302+
break;
303+
304+
case SELL_ITEM:
309305
_base->getItems()->removeItem(_items[getItemIndex(i)], _qtys[i]);
310306
}
311307
}

‎src/Ruleset/RuleCraft.cpp‎

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ namespace OpenXcom
2929
*/
3030
RuleCraft::RuleCraft(const std::string &type) :
3131
_type(type), _sprite(-1), _fuelMax(0), _damageMax(0), _speedMax(0), _accel(0),
32-
_weapons(0), _soldiers(0), _vehicles(0), _costBuy(0), _costSell(0), _refuelItem(""),
33-
_repairRate(1), _refuelRate(1), _radarRange(600), _transferTime(0), _score(0),
34-
_battlescapeTerrainData(0), _spacecraft(false), _listOrder(0)
32+
_weapons(0), _soldiers(0), _vehicles(0), _costBuy(0), _costRent(0), _costSell(0),
33+
_refuelItem(""), _repairRate(1), _refuelRate(1), _radarRange(600), _transferTime(0),
34+
_score(0), _battlescapeTerrainData(0), _spacecraft(false), _listOrder(0)
3535
{
3636

3737
}
@@ -100,6 +100,10 @@ void RuleCraft::load(const YAML::Node &node, Ruleset *ruleset, int modIndex, int
100100
{
101101
i.second() >> _costBuy;
102102
}
103+
else if (key == "costRent")
104+
{
105+
i.second() >> _costRent;
106+
}
103107
else if (key == "costSell")
104108
{
105109
i.second() >> _costSell;
@@ -168,6 +172,7 @@ void RuleCraft::save(YAML::Emitter &out) const
168172
out << YAML::Key << "soldiers" << YAML::Value << _soldiers;
169173
out << YAML::Key << "vehicles" << YAML::Value << _vehicles;
170174
out << YAML::Key << "costBuy" << YAML::Value << _costBuy;
175+
out << YAML::Key << "costRent" << YAML::Value << _costRent;
171176
out << YAML::Key << "costSell" << YAML::Value << _costSell;
172177
out << YAML::Key << "refuelItem" << YAML::Value << _refuelItem;
173178
out << YAML::Key << "repairRate" << YAML::Value << _repairRate;
@@ -283,6 +288,15 @@ int RuleCraft::getBuyCost() const
283288
return _costBuy;
284289
}
285290

291+
/**
292+
* Returns the cost of rent for a month.
293+
* @return Cost.
294+
*/
295+
int RuleCraft::getRentCost() const
296+
{
297+
return _costRent;
298+
}
299+
286300
/**
287301
* Returns sell value of this craft
288302
* Rented craft should use 0.

‎src/Ruleset/RuleCraft.h‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ class RuleCraft
4040
private:
4141
std::string _type;
4242
int _sprite;
43-
int _fuelMax, _damageMax, _speedMax, _accel, _weapons, _soldiers, _vehicles, _costBuy, _costSell;
43+
int _fuelMax, _damageMax, _speedMax, _accel, _weapons, _soldiers, _vehicles, _costBuy, _costRent, _costSell;
4444
std::string _refuelItem;
4545
int _repairRate, _refuelRate, _radarRange, _transferTime, _score;
4646
// battlescape:
@@ -76,6 +76,8 @@ class RuleCraft
7676
int getVehicles() const;
7777
/// Gets the craft's cost.
7878
int getBuyCost() const;
79+
/// Gets the craft's rent for a month.
80+
int getRentCost() const;
7981
/// Gets the craft's value.
8082
int getSellCost() const;
8183
/// Gets the craft's refuel item.

‎src/Savegame/Base.cpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -853,7 +853,7 @@ int Base::getCraftMaintenance() const
853853
int total = 0;
854854
for (std::vector<Craft*>::const_iterator i = _crafts.begin(); i != _crafts.end(); ++i)
855855
{
856-
total += (*i)->getRules()->getBuyCost();
856+
total += (*i)->getRules()->getRentCost();
857857
}
858858
return total;
859859
}

0 commit comments

Comments
 (0)