Skip to content

Commit 31c5a51

Browse files
committed
- Fixed used hangars miscounting crafts in production.
- Fixed misleading function name.
1 parent bb3710c commit 31c5a51

5 files changed

Lines changed: 19 additions & 19 deletions

File tree

‎src/Basescape/ManufactureInfoState.cpp‎

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ void ManufactureInfoState::setAssignedEngineer()
244244
s3 << L">\x01" << _production->getAssignedEngineers();
245245
_txtAllocated->setText(s3.str());
246246
std::wstringstream s4;
247-
s4 << L">\x01" << _production->getAmountRemaining ();
247+
s4 << L">\x01" << _production->getAmountTotal ();
248248
_txtTodo->setText(s4.str());
249249
}
250250

@@ -353,18 +353,18 @@ void ManufactureInfoState::moreUnitClick(Action * action)
353353
{
354354
// TODO: virtual infinite value for produce & sell automatically
355355
// now it just raises the value to 999 or max-available-hangars on crafts
356-
int more = _production->getAmountRemaining ();
356+
int more = _production->getAmountTotal ();
357357
if (_production->getRules()->getCategory() == "STR_CRAFT")
358358
{
359359
if (_base->getAvailableHangars() - _base->getUsedHangars() > 0)
360360
{
361-
_production->setAmountRemaining(std::max(more,_base->getAvailableHangars() - _base->getUsedHangars()));
361+
_production->setAmountTotal(std::max(more,_base->getAvailableHangars() - _base->getUsedHangars()));
362362
setAssignedEngineer();
363363
}
364364
}
365365
else
366366
{
367-
_production->setAmountRemaining(std::max(more,999));
367+
_production->setAmountTotal(std::max(more,999));
368368
setAssignedEngineer();
369369
}
370370
}
@@ -396,10 +396,10 @@ void ManufactureInfoState::lessUnitClick(Action * action)
396396
{
397397
if (action->getDetails()->button.button == SDL_BUTTON_RIGHT)
398398
{
399-
int less = _production->getAmountRemaining ();
399+
int less = _production->getAmountTotal ();
400400
if (less > (_production->getAmountProduced () + 1))
401401
{
402-
_production->setAmountRemaining(_production->getAmountProduced () + 1);
402+
_production->setAmountTotal(_production->getAmountProduced () + 1);
403403
setAssignedEngineer();
404404
}
405405
}
@@ -440,15 +440,15 @@ void ManufactureInfoState::onLessEngineer()
440440
*/
441441
void ManufactureInfoState::onMoreUnit()
442442
{
443-
int more = _production->getAmountRemaining ();
443+
int more = _production->getAmountTotal ();
444444
if (_production->getRules()->getCategory() == "STR_CRAFT" && _base->getAvailableHangars() - _base->getUsedHangars() == 0)
445445
{
446446
_timerMoreUnit->stop();
447447
_game->pushState(new ErrorMessageState(_game, "STR_NO_FREE_HANGARS_FOR_CRAFT_PRODUCTION", Palette::blockOffset(15)+1, "BACK17.SCR", 6));
448448
}
449449
else
450450
{
451-
_production->setAmountRemaining (++more);
451+
_production->setAmountTotal (++more);
452452
setAssignedEngineer();
453453
}
454454
}
@@ -458,10 +458,10 @@ void ManufactureInfoState::onMoreUnit()
458458
*/
459459
void ManufactureInfoState::onLessUnit()
460460
{
461-
int less = _production->getAmountRemaining ();
461+
int less = _production->getAmountTotal ();
462462
if(less > (_production->getAmountProduced () + 1))
463463
{
464-
_production->setAmountRemaining (--less);
464+
_production->setAmountTotal (--less);
465465
setAssignedEngineer();
466466
}
467467
}

‎src/Basescape/ManufactureState.cpp‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,13 +193,13 @@ void ManufactureState::fillProductionList()
193193
std::wstringstream s2;
194194
s2 << (*iter)->getAmountProduced();
195195
std::wstringstream s3;
196-
s3 << (*iter)->getAmountRemaining();
196+
s3 << (*iter)->getAmountTotal();
197197
std::wstringstream s4;
198198
s4 << Text::formatFunding((*iter)->getRules()->getManufactureCost());
199199
std::wstringstream s5;
200200
if ((*iter)->getAssignedEngineers() > 0)
201201
{
202-
int timeLeft = (*iter)->getAmountRemaining () * (*iter)->getRules()->getManufactureTime() - (*iter)->getTimeSpent ();
202+
int timeLeft = (*iter)->getAmountTotal () * (*iter)->getRules()->getManufactureTime() - (*iter)->getTimeSpent ();
203203
timeLeft /= (*iter)->getAssignedEngineers();
204204
float dayLeft = timeLeft / 24.0f;
205205
int hours = (dayLeft - static_cast<int>(dayLeft)) * 24;

‎src/Savegame/Base.cpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -671,7 +671,7 @@ int Base::getUsedHangars() const
671671
{
672672
if ((*i)->getRules()->getCategory() == "STR_CRAFT")
673673
{
674-
total += (*i)->getAmountRemaining();
674+
total += ((*i)->getAmountTotal() - (*i)->getAmountProduced());
675675
}
676676
}
677677
return total;

‎src/Savegame/Production.cpp‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,12 @@ Production::Production (const RuleManufacture * rules, int amount) : _rules(rule
3030
{
3131
}
3232

33-
int Production::getAmountRemaining () const
33+
int Production::getAmountTotal () const
3434
{
3535
return _amount;
3636
}
3737

38-
void Production::setAmountRemaining (int amount)
38+
void Production::setAmountTotal (int amount)
3939
{
4040
_amount = amount;
4141
}
@@ -128,7 +128,7 @@ void Production::save(YAML::Emitter &out)
128128
out << YAML::Key << "item" << YAML::Value << getRules ()->getName ();
129129
out << YAML::Key << "assigned" << YAML::Value << getAssignedEngineers ();
130130
out << YAML::Key << "spent" << YAML::Value << getTimeSpent ();
131-
out << YAML::Key << "amount" << YAML::Value << getAmountRemaining ();
131+
out << YAML::Key << "amount" << YAML::Value << getAmountTotal ();
132132
out << YAML::EndMap;
133133
}
134134

@@ -142,6 +142,6 @@ void Production::load(const YAML::Node &node)
142142
node["amount"] >> amount;
143143
setAssignedEngineers(assigned);
144144
setTimeSpent(spent);
145-
setAmountRemaining(amount);
145+
setAmountTotal(amount);
146146
}
147147
};

‎src/Savegame/Production.h‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ class Production
3232
{
3333
public:
3434
Production (const RuleManufacture * rules, int amount);
35-
int getAmountRemaining () const;
36-
void setAmountRemaining (int);
35+
int getAmountTotal () const;
36+
void setAmountTotal (int);
3737
int getTimeSpent () const;
3838
void setTimeSpent (int);
3939
int getAmountProduced () const;

0 commit comments

Comments
 (0)