Skip to content

Commit

Permalink
fix: review
Browse files Browse the repository at this point in the history
  • Loading branch information
dudantas committed Nov 5, 2024
1 parent 7c5e838 commit edb5324
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions src/map/spectators.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,15 @@ bool Spectators::checkCache(const SpectatorsCache::FloorData &specData, bool onl
spectators.reserve(creatures.size());
for (const auto &creature : *list) {
const auto &specPos = creature->getPosition();
if (centerPos.x - specPos.x >= minRangeX
&& centerPos.y - specPos.y >= minRangeY
&& centerPos.x - specPos.x <= maxRangeX
&& centerPos.y - specPos.y <= maxRangeY
&& (multifloor || specPos.z == centerPos.z)
&& ((onlyPlayers && creature->getPlayer())
|| (onlyMonsters && creature->getMonster())
|| (onlyNpcs && creature->getNpc()))
|| (!onlyPlayers && !onlyMonsters && !onlyNpcs)) {
if ((centerPos.x - specPos.x >= minRangeX
&& centerPos.y - specPos.y >= minRangeY
&& centerPos.x - specPos.x <= maxRangeX
&& centerPos.y - specPos.y <= maxRangeY
&& (multifloor || specPos.z == centerPos.z)
&& ((onlyPlayers && creature->getPlayer())

Check warning on line 66 in src/map/spectators.cpp

View workflow job for this annotation

GitHub Actions / ubuntu-24.04-linux-debug

suggest parentheses around ‘&&’ within ‘||’ [-Wparentheses]
|| (onlyMonsters && creature->getMonster())
|| (onlyNpcs && creature->getNpc()))
|| (!onlyPlayers && !onlyMonsters && !onlyNpcs))) {
spectators.emplace_back(creature);
}
}
Expand Down Expand Up @@ -266,6 +266,8 @@ Spectators Spectators::excludeMaster() const {
specs.insert(c);
}
}

return specs;
}

Spectators Spectators::excludePlayerMaster() const {
Expand All @@ -277,10 +279,12 @@ Spectators Spectators::excludePlayerMaster() const {
specs.creatures.reserve(creatures.size());

for (const auto &c : creatures) {
if (c->getMonster() != nullptr && !c->getMaster() || !c->getMaster()->getPlayer()) {
if ((c->getMonster() != nullptr && !c->getMaster() || !c->getMaster()->getPlayer())) {

Check warning on line 282 in src/map/spectators.cpp

View workflow job for this annotation

GitHub Actions / ubuntu-24.04-linux-debug

suggest parentheses around ‘&&’ within ‘||’ [-Wparentheses]
specs.insert(c);
}
}

return specs;
}

Spectators Spectators::filter(bool onlyPlayers, bool onlyMonsters, bool onlyNpcs) const {
Expand Down

0 comments on commit edb5324

Please sign in to comment.