Permalink
Browse files

Merge pull request #1184 from MeridianOXC/yankes-fixes

Yankes fixes
  • Loading branch information...
SupSuper committed May 10, 2018
2 parents 8d59578 + a7a8790 commit 57a10ae13866f80894463b3f92dd9a2fb110c562
@@ -517,7 +517,7 @@ void PurchaseState::increaseByValue(int change)
}
else
{
RuleItem *rule = (RuleItem*)getRow().rule;
RuleItem *rule = 0;
switch (getRow().type)
{
case TRANSFER_SOLDIER:
@@ -535,6 +535,7 @@ void PurchaseState::increaseByValue(int change)
}
break;
case TRANSFER_ITEM:
rule = (RuleItem*)getRow().rule;
if (_iQty + rule->getSize() > _base->getAvailableStores() - _base->getUsedStores())
{
errorMessage = tr("STR_NOT_ENOUGH_STORE_SPACE");
@@ -612,7 +613,7 @@ void PurchaseState::decreaseByValue(int change)
if (0 >= change || 0 >= getRow().amount) return;
change = std::min(getRow().amount, change);
RuleItem *rule = (RuleItem*)getRow().rule;
RuleItem *rule = 0;
switch (getRow().type)
{
case TRANSFER_SOLDIER:
@@ -624,6 +625,7 @@ void PurchaseState::decreaseByValue(int change)
_cQty -= change;
break;
case TRANSFER_ITEM:
rule = (RuleItem*)getRow().rule;
_iQty -= rule->getSize() * change;
break;
}
@@ -179,11 +179,6 @@ void ResearchInfoState::btnOkClick(Action *)
*/
void ResearchInfoState::btnCancelClick(Action *)
{
const RuleResearch *ruleResearch = _rule ? _rule : _project->getRules();
if (ruleResearch->needItem() && ruleResearch->destroyItem())
{
_base->getStorageItems()->addItem(ruleResearch->getName(), 1);
}
_base->removeResearch(_project);
_game->popState();
}
@@ -100,7 +100,6 @@ ResearchState::ResearchState(Base *base) : _base(base)
_lstResearch->setMargin(2);
_lstResearch->setWordWrap(true);
_lstResearch->onMouseClick((ActionHandler)&ResearchState::onSelectProject);
fillProjectList();
}
/**
@@ -1461,8 +1461,8 @@ void GeoscapeState::time1Hour()
{
if (j->second > PROGRESS_NOT_COMPLETE)
{
(*i)->removeProduction (j->first);
popup(new ProductionCompleteState((*i), tr(j->first->getRules()->getName()), this, j->second));
(*i)->removeProduction(j->first);
}
}
@@ -1565,19 +1565,22 @@ void GeoscapeState::time1Day()
_game->getSavedGame()->getAvailableResearchProjects(before, _game->getMod(), *i);
}
// 3. add finished research, including lookups and getonefrees (up to 4x)
for (std::vector<ResearchProject*>::const_iterator iter = finished.begin(); iter != finished.end(); ++iter)
for (std::vector<ResearchProject*>::iterator iter = finished.begin(); iter != finished.end(); ++iter)
{
const RuleResearch *bonus = 0;
const RuleResearch *research = (*iter)->getRules();
// 3a. remove finished research from the base where it was researched
(*i)->removeResearch(*iter);
// 3b. handle interrogations
RuleResearch * bonus = 0;
const RuleResearch * research = (*iter)->getRules();
(*iter) = 0;
// 3b. handle interrogation
if (Options::retainCorpses && research->destroyItem() && _game->getMod()->getUnit(research->getName()))
{
(*i)->getStorageItems()->addItem(_game->getMod()->getArmor(_game->getMod()->getUnit(research->getName())->getArmor(), true)->getCorpseGeoscape());
}
// 3c. handle getonefrees (topic+lookup)
if (!(*iter)->getRules()->getGetOneFree().empty())
if (!research->getGetOneFree().empty())
{
std::vector<std::string> possibilities;
for (std::vector<std::string>::const_iterator f = research->getGetOneFree().begin(); f != research->getGetOneFree().end(); ++f)
@@ -1681,8 +1684,6 @@ void GeoscapeState::time1Day()
}
}
}
// 3k. remove processed item from the list (and continue with the next item)
delete(*iter);
}
// Handle soldier wounds
@@ -1095,20 +1095,31 @@ void Base::removeResearch(ResearchProject * project)
{
_research.erase(iter);
}
const RuleResearch *ruleResearch = project->getRules();
if (!project->isFinished())
{
if (ruleResearch->needItem() && ruleResearch->destroyItem())
{
getStorageItems()->addItem(ruleResearch->getName(), 1);
}
}
delete project;
}
/**
* Remove a Production from the Base
* @param p A pointer to a Production
*/
void Base::removeProduction (Production * p)
void Base::removeProduction(Production * p)
{
_engineers += p->getAssignedEngineers();
std::vector<Production *>::iterator iter = std::find (_productions.begin(), _productions.end(), p);
if (iter != _productions.end())
{
_productions.erase(iter);
}
delete p;
}
/**
@@ -1618,7 +1629,7 @@ void Base::destroyFacility(std::vector<BaseFacility*>::iterator facility)
}
}
}
else if ((*facility)->getRules()->getPsiLaboratories() > 0)
if ((*facility)->getRules()->getPsiLaboratories() > 0)
{
// psi lab destruction: remove any soldiers over the maximum allowable from psi training.
int toRemove = (*facility)->getRules()->getPsiLaboratories() - getFreePsiLabs();
@@ -1631,7 +1642,7 @@ void Base::destroyFacility(std::vector<BaseFacility*>::iterator facility)
}
}
}
else if ((*facility)->getRules()->getLaboratories())
if ((*facility)->getRules()->getLaboratories())
{
// lab destruction: enforce lab space limits. take scientists off projects until
// it all evens out. research is not cancelled.
@@ -1653,7 +1664,7 @@ void Base::destroyFacility(std::vector<BaseFacility*>::iterator facility)
}
}
}
else if ((*facility)->getRules()->getWorkshops())
if ((*facility)->getRules()->getWorkshops())
{
// workshop destruction: similar to lab destruction, but we'll lay off engineers instead
// in this case, however, production IS cancelled, as it takes up space in the workshop.
@@ -1675,7 +1686,7 @@ void Base::destroyFacility(std::vector<BaseFacility*>::iterator facility)
}
}
}
else if ((*facility)->getRules()->getStorage())
if ((*facility)->getRules()->getStorage())
{
// we won't destroy the items physically AT the base,
// but any items in transit will end up at the dead letter office.
@@ -1695,7 +1706,7 @@ void Base::destroyFacility(std::vector<BaseFacility*>::iterator facility)
}
}
}
else if ((*facility)->getRules()->getPersonnel())
if ((*facility)->getRules()->getPersonnel())
{
// as above, we won't actually fire people, but we'll block any new ones coming in.
if ((getAvailableQuarters() - getUsedQuarters()) - (*facility)->getRules()->getPersonnel() < 0 && !_transfers.empty())
@@ -995,6 +995,8 @@ void Craft::unload(const Mod *mod)
{
_base->getStorageItems()->addItem((*w)->getRules()->getLauncherItem());
_base->getStorageItems()->addItem((*w)->getRules()->getClipItem(), (*w)->getClipsLoaded(mod));
delete (*w);
(*w) = 0;
}
}
@@ -1012,7 +1014,10 @@ void Craft::unload(const Mod *mod)
{
_base->getStorageItems()->addItem((*v)->getRules()->getCompatibleAmmo()->front(), (*v)->getAmmo());
}
delete (*v);
(*v) = 0;
}
_vehicles.clear();
// Remove soldiers
for (std::vector<Soldier*>::iterator s = _base->getSoldiers()->begin(); s != _base->getSoldiers()->end(); ++s)
@@ -37,11 +37,15 @@ ResearchProject::ResearchProject(RuleResearch * p, int c) : _project(p), _assign
bool ResearchProject::step()
{
_spent += _assigned;
if (_spent >= getCost())
{
return true;
}
return false;
return isFinished();
}
/**
* gets state of project.
*/
bool ResearchProject::isFinished()
{
return _spent >= getCost();
}
/**
@@ -39,6 +39,8 @@ class ResearchProject
ResearchProject(RuleResearch * p, int c = 0);
/// Game logic. Called every new day to compute time spent.
bool step();
/// gets state of project.
bool isFinished();
/// set the number of scientist assigned to this ResearchProject
void setAssigned (int nb);
/// get the number of scientist assigned to this ResearchProject

0 comments on commit 57a10ae

Please sign in to comment.