Skip to content

Commit

Permalink
Merge pull request OpenXcom#1230 from MeridianOXC/november-fixes
Browse files Browse the repository at this point in the history
November fixes
  • Loading branch information
Warboy1982 authored Nov 10, 2019
2 parents 0d30635 + f6586e6 commit 1c84405
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 12 deletions.
25 changes: 14 additions & 11 deletions src/Battlescape/BattlescapeGame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -372,21 +372,24 @@ void BattlescapeGame::endTurn()
Position p;

// check for hot grenades on the ground
for (int i = 0; i < _save->getMapSizeXYZ(); ++i)
if (_save->getSide() != FACTION_NEUTRAL)
{
for (std::vector<BattleItem*>::iterator it = _save->getTiles()[i]->getInventory()->begin(); it != _save->getTiles()[i]->getInventory()->end(); )
for (int i = 0; i < _save->getMapSizeXYZ(); ++i)
{
if ((*it)->getRules()->getBattleType() == BT_GRENADE && (*it)->getFuseTimer() == 0) // it's a grenade to explode now
for (std::vector<BattleItem *>::iterator it = _save->getTiles()[i]->getInventory()->begin(); it != _save->getTiles()[i]->getInventory()->end(); )
{
p.x = _save->getTiles()[i]->getPosition().x*16 + 8;
p.y = _save->getTiles()[i]->getPosition().y*16 + 8;
p.z = _save->getTiles()[i]->getPosition().z*24 - _save->getTiles()[i]->getTerrainLevel();
statePushNext(new ExplosionBState(this, p, (*it), (*it)->getPreviousOwner()));
_save->removeItem((*it));
statePushBack(0);
return;
if ((*it)->getRules()->getBattleType() == BT_GRENADE && (*it)->getFuseTimer() == 0) // it's a grenade to explode now
{
p.x = _save->getTiles()[i]->getPosition().x * 16 + 8;
p.y = _save->getTiles()[i]->getPosition().y * 16 + 8;
p.z = _save->getTiles()[i]->getPosition().z * 24 - _save->getTiles()[i]->getTerrainLevel();
statePushNext(new ExplosionBState(this, p, (*it), (*it)->getPreviousOwner()));
_save->removeItem((*it));
statePushBack(0);
return;
}
++it;
}
++it;
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion src/Geoscape/DogfightState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,8 @@ DogfightState::DogfightState(GeoscapeState *state, Craft *craft, Ufo *ufo) : _st
if (!_ufo->getEscapeCountdown())
{
_ufo->setFireCountdown(0);
_ufo->setEscapeCountdown(_ufo->getRules()->getBreakOffTime() + RNG::generate(0, _ufo->getRules()->getBreakOffTime()) - 30 * _game->getSavedGame()->getDifficultyCoefficient());
int escapeCountdown = _ufo->getRules()->getBreakOffTime() + RNG::generate(0, _ufo->getRules()->getBreakOffTime()) - 30 * _game->getSavedGame()->getDifficultyCoefficient();
_ufo->setEscapeCountdown(std::max(1, escapeCountdown));
}

// technically this block is redundant, but i figure better to initialize the variables as SOMETHING
Expand Down

0 comments on commit 1c84405

Please sign in to comment.