Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use client viewport in hardcode-range #3706

Merged
merged 1 commit into from
Sep 30, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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