From 653e064b78d39c68dd3a2daaed4206444bda7435 Mon Sep 17 00:00:00 2001 From: Eduardo Dantas Date: Wed, 30 Oct 2024 23:31:02 -0300 Subject: [PATCH] improve: AreaSpawnEvent::executeEvent remove unused variable (#3036) Removed unused variable and added pointer to const ref. --- src/lua/creature/raids.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/lua/creature/raids.cpp b/src/lua/creature/raids.cpp index 7b262402bb1..2a9a174e6a7 100644 --- a/src/lua/creature/raids.cpp +++ b/src/lua/creature/raids.cpp @@ -539,24 +539,24 @@ bool AreaSpawnEvent::executeEvent() { for (const MonsterSpawn &spawn : spawnMonsterList) { const uint32_t amount = uniform_random(spawn.minAmount, spawn.maxAmount); for (uint32_t i = 0; i < amount; ++i) { - std::shared_ptr monster = Monster::createMonster(spawn.name); + const std::shared_ptr &monster = Monster::createMonster(spawn.name); if (!monster) { g_logger().error("{} - Can't create monster {}", __FUNCTION__, spawn.name); return false; } - bool success = false; for (int32_t tries = 0; tries < MAXIMUM_TRIES_PER_MONSTER; tries++) { const auto &tile = g_game().map.getTile(static_cast(uniform_random(fromPos.x, toPos.x)), static_cast(uniform_random(fromPos.y, toPos.y)), static_cast(uniform_random(fromPos.z, toPos.z))); - if (tile && !tile->isMovableBlocking() && !tile->hasFlag(TILESTATE_PROTECTIONZONE) && tile->getTopCreature() == nullptr && g_game().placeCreature(monster, tile->getPosition(), false, true)) { - success = true; + if (!tile) { + continue; + } + + const auto &topCreature = tile->getTopCreature(); + if (!tile->isMovableBlocking() && !tile->hasFlag(TILESTATE_PROTECTIONZONE) && topCreature == nullptr && g_game().placeCreature(monster, tile->getPosition(), false, true)) { monster->setForgeMonster(false); break; } } - - if (!success) { - } } } return true;