Skip to content

Commit

Permalink
Fix issue #20
Browse files Browse the repository at this point in the history
- resolves problem of monsters' ownership transferring to a non existent spawn point
  • Loading branch information
Codinablack committed Dec 8, 2024
1 parent ddce98f commit 921d0ca
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 12 deletions.
9 changes: 0 additions & 9 deletions src/spawn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -267,11 +267,6 @@ bool Spawn::findPlayer(const Position& pos)
return false;
}

bool Spawn::isInSpawnZone(const Position& pos)
{
return Spawns::isInZone(centerPos, radius, pos);
}

bool Spawn::spawnMonster(uint32_t spawnId, spawnBlock_t sb, bool startup/* = false*/)
{
bool isBlocked = !startup && findPlayer(sb.pos);
Expand Down Expand Up @@ -388,14 +383,10 @@ void Spawn::cleanup()
{
auto it = spawnedMap.begin();
while (it != spawnedMap.end()) {
uint32_t spawnId = it->first;
Monster* monster = it->second;
if (monster->isRemoved()) {
monster->decrementReferenceCounter();
it = spawnedMap.erase(it);
} else if (!isInSpawnZone(monster->getPosition()) && spawnId != 0) {
spawnedMap.insert({0, monster});
it = spawnedMap.erase(it);
} else {
++it;
}
Expand Down
4 changes: 1 addition & 3 deletions src/spawn.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,10 @@ class Spawn
uint32_t getInterval() const {
return interval;
}

void startup();

void startSpawnCheck();
void stopEvent();

bool isInSpawnZone(const Position& pos);
void cleanup();

private:
Expand Down

0 comments on commit 921d0ca

Please sign in to comment.