Skip to content

Commit

Permalink
Replace hardcoded values for viewport dimensions (#3706)
Browse files Browse the repository at this point in the history
  • Loading branch information
ramon-bernardo authored Sep 30, 2021
1 parent 1a5e3b1 commit 521198c
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/actions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ ReturnValue Actions::canUseFar(const Creature* creature, const Position& toPos,
return creaturePos.z > toPos.z ? RETURNVALUE_FIRSTGOUPSTAIRS : RETURNVALUE_FIRSTGODOWNSTAIRS;
}

if (!Position::areInRange<7, 5>(toPos, creaturePos)) {
if (!Position::areInRange<Map::maxClientViewportX - 1, Map::maxClientViewportY - 1>(toPos, creaturePos)) {
return RETURNVALUE_TOOFARAWAY;
}

Expand Down
2 changes: 1 addition & 1 deletion src/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2209,7 +2209,7 @@ void Game::playerUseWithCreature(uint32_t playerId, const Position& fromPos, uin
return;
}

if (!Position::areInRange<7, 5, 0>(creature->getPosition(), player->getPosition())) {
if (!Position::areInRange<Map::maxClientViewportX - 1, Map::maxClientViewportY - 1, 0>(creature->getPosition(), player->getPosition())) {
return;
}

Expand Down
2 changes: 1 addition & 1 deletion src/spells.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1013,7 +1013,7 @@ bool InstantSpell::canThrowSpell(const Creature* creature, const Creature* targe
const Position& fromPos = creature->getPosition();
const Position& toPos = target->getPosition();
if (fromPos.z != toPos.z ||
(range == -1 && !g_game.canThrowObjectTo(fromPos, toPos, checkLineOfSight, true, 7, 5)) ||
(range == -1 && !g_game.canThrowObjectTo(fromPos, toPos, checkLineOfSight, true, Map::maxClientViewportX - 1, Map::maxClientViewportY - 1)) ||
(range != -1 && !g_game.canThrowObjectTo(fromPos, toPos, checkLineOfSight, true, range, range))) {
return false;
}
Expand Down

0 comments on commit 521198c

Please sign in to comment.