Skip to content

Commit

Permalink
Unit logic
Browse files Browse the repository at this point in the history
- UpdateMeleeAttackingState : I guess I should study up some more on
logical gates myself. thanks for pointing @VladimirMangos - return
swingerror enstead of returning 0. if we wanted
to return 0 we sould just return false.... ehh... why are we returning
0? why is this functio not just void?

- Attack : Logical error: If we are doing a mele attack and we are
already attacking the unit, we should not return a false, but rather a
true.
  • Loading branch information
Phatcat authored and Fabian committed Aug 29, 2016
1 parent 54ec0a1 commit 85972d7
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/game/Unit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -718,7 +718,7 @@ bool Unit::UpdateMeleeAttackingState()
player->SwingErrorMsg(swingError);
}

return swingError == 0;
return swingError;
}

bool Unit::haveOffhandWeapon() const
Expand Down Expand Up @@ -6107,10 +6107,13 @@ bool Unit::Attack(Unit* victim, bool meleeAttack)
if (m_attacking == victim)
{
// switch to melee attack from ranged/magic
if (meleeAttack && !hasUnitState(UNIT_STAT_MELEE_ATTACKING))
if (meleeAttack)
{
addUnitState(UNIT_STAT_MELEE_ATTACKING);
SendMeleeAttackStart(victim);
if (!hasUnitState(UNIT_STAT_MELEE_ATTACKING))
{
addUnitState(UNIT_STAT_MELEE_ATTACKING);
SendMeleeAttackStart(victim);
}
return true;
}
return false;
Expand Down

0 comments on commit 85972d7

Please sign in to comment.