Skip to content

Commit

Permalink
Fixes all known resurrection bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
ciplogic committed Sep 8, 2018
1 parent 8393827 commit 69b60fd
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
9 changes: 8 additions & 1 deletion src/fheroes2/battle/battle_cell.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,13 @@

#define INFL 12

Battle::Position& Battle::Position::operator=(const Position& pos)
{
first = pos.first;
second = pos.second;
return *this;
}

void Battle::Position::Set(s32 head, bool wide, bool reflect)
{
first = Board::GetCell(head);
Expand Down Expand Up @@ -232,7 +239,7 @@ bool Battle::Cell::isPassable4(const Unit& b, const Cell& from) const
case BOTTOM_LEFT:
case TOP_LEFT:
{
bool reflect = (BOTTOM_LEFT | TOP_LEFT) & dir;
const bool reflect = (BOTTOM_LEFT | TOP_LEFT) & dir;
const Cell* tail = Board::GetCell(index, reflect ? RIGHT : LEFT);
return tail && tail->isPassable1(true) && isPassable1(true);
}
Expand Down
3 changes: 3 additions & 0 deletions src/fheroes2/battle/battle_cell.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,9 @@ namespace Battle
{
}

Position& operator=(const Position& pos);


void Set(s32 head, bool wide, bool reflect);

void Swap();
Expand Down
4 changes: 2 additions & 2 deletions src/fheroes2/battle/battle_troop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -988,7 +988,7 @@ void Battle::Unit::PostKilledAction()

uint32_t Battle::Unit::Resurrect(uint32_t points, bool allow_overflow, bool skip_dead)
{
uint32_t resurrect = _monster.GetCountFromHitPoints(this->_monster, hp + points) - GetCount();
int resurrect = Monster::GetCountFromHitPoints(this->_monster, hp + points);

SetCount(GetCount() + resurrect);
hp += points;
Expand All @@ -1001,7 +1001,7 @@ uint32_t Battle::Unit::Resurrect(uint32_t points, bool allow_overflow, bool skip
{
resurrect -= GetCount() - count0;
SetCount(count0);
hp = ArmyTroop::GetHitPointsTroop();
hp = _monster.GetHitPoints();
}

if (!skip_dead)
Expand Down

0 comments on commit 69b60fd

Please sign in to comment.