Skip to content

Commit

Permalink
fix: spawn monster (opentibiabr#2750)
Browse files Browse the repository at this point in the history
  • Loading branch information
mehah authored Jul 11, 2024
1 parent 418aeb0 commit 762eaea
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 7 deletions.
24 changes: 19 additions & 5 deletions src/creatures/monsters/spawns/spawn_monster.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,29 @@ class SpawnMonster {
centerPos(initPos), radius(initRadius) { }
~SpawnMonster();

SpawnMonster(SpawnMonster &&) { }
SpawnMonster &operator=(SpawnMonster &&) {
return *this;
}

// non-copyable
SpawnMonster(const SpawnMonster &) = delete;
SpawnMonster &operator=(const SpawnMonster &) = delete;

// moveable
SpawnMonster(SpawnMonster &&rhs) noexcept :

Check warning on line 40 in src/creatures/monsters/spawns/spawn_monster.hpp

View workflow job for this annotation

GitHub Actions / ubuntu-22.04-linux-debug

when initialized here [-Wreorder]

Check warning on line 40 in src/creatures/monsters/spawns/spawn_monster.hpp

View workflow job for this annotation

GitHub Actions / ubuntu-22.04-linux-debug

when initialized here [-Wreorder]
spawnMonsterMap(std::move(rhs.spawnMonsterMap)),
spawnedMonsterMap(std::move(rhs.spawnedMonsterMap)),
checkSpawnMonsterEvent(rhs.checkSpawnMonsterEvent), centerPos(rhs.centerPos), radius(rhs.radius), interval(rhs.interval) { }

SpawnMonster &operator=(SpawnMonster &&rhs) noexcept {
if (this != &rhs) {
spawnMonsterMap = std::move(rhs.spawnMonsterMap);
spawnedMonsterMap = std::move(rhs.spawnedMonsterMap);

checkSpawnMonsterEvent = rhs.checkSpawnMonsterEvent;
centerPos = rhs.centerPos;
radius = rhs.radius;
interval = rhs.interval;
}
return *this;
}

bool addMonster(const std::string &name, const Position &pos, Direction dir, uint32_t interval, uint32_t weight = 1);
void removeMonster(std::shared_ptr<Monster> monster);
void removeMonsters();
Expand Down
3 changes: 1 addition & 2 deletions src/lua/functions/creatures/monster/monster_functions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -363,8 +363,7 @@ int MonsterFunctions::luaMonsterSetSpawnPosition(lua_State* L) {
const Position &pos = monster->getPosition();
monster->setMasterPos(pos);

g_game().map.spawnsMonster.getspawnMonsterList().emplace_back(pos, 5);
SpawnMonster &spawnMonster = g_game().map.spawnsMonster.getspawnMonsterList().front();
SpawnMonster &spawnMonster = g_game().map.spawnsMonster.getspawnMonsterList().emplace_back(pos, 5);
uint32_t interval = getNumber<uint32_t>(L, 2, 90) * 1000 * 100 / std::max((uint32_t)1, (g_configManager().getNumber(RATE_SPAWN, __FUNCTION__) * eventschedule));
spawnMonster.addMonster(monster->mType->typeName, pos, DIRECTION_NORTH, static_cast<uint32_t>(interval));
spawnMonster.startSpawnMonsterCheck();
Expand Down

0 comments on commit 762eaea

Please sign in to comment.