Skip to content

Commit

Permalink
Optimize StartSpell()
Browse files Browse the repository at this point in the history
`isValid` can be set to false initially, removing the need for a case for `SpellType::Invalid`, as if all the previous conditions are not met, `isValid` will remain false.
  • Loading branch information
kphoenix137 authored and AJenbo committed Aug 24, 2024
1 parent 71650f9 commit a374985
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions Source/player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ void StartSpell(Player &player, Direction d, WorldTileCoord cx, WorldTileCoord c
}

// Checks conditions for spell again, because initial check was done when spell was queued and the parameters could be changed meanwhile
bool isValid = true;
bool isValid = false;
switch (player.queuedSpell.spellType) {
case SpellType::Skill:
case SpellType::Spell:
Expand All @@ -265,8 +265,7 @@ void StartSpell(Player &player, Direction d, WorldTileCoord cx, WorldTileCoord c
case SpellType::Charges:
isValid = CanUseStaff(player, player.queuedSpell.spellId);
break;
case SpellType::Invalid:
isValid = false;
default:
break;
}
if (!isValid)
Expand Down

0 comments on commit a374985

Please sign in to comment.