Skip to content

Commit

Permalink
fix: crash on place monster spawn
Browse files Browse the repository at this point in the history
  • Loading branch information
phacUFPE committed Jun 4, 2024
1 parent 0a0acba commit 1321d40
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions source/spawn_monster_brush.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,14 @@ void SpawnMonsterBrush::draw(BaseMap* map, Tile* tile, void* parameter) {
}
}

for (int i = 0; i < toSpawn; ++i) {
auto iter = positions.begin();
std::advance(iter, rand() % positions.size());
auto monsterBrush = monsters[rand() % monsters.size()];
monsterBrush->drawMonster(map, map->getTile(*iter), &time);
positions.erase(iter);
if (monsters.size() > 0) {
for (int i = 0; i < toSpawn; ++i) {
auto iter = positions.begin();
std::advance(iter, rand() % positions.size());
auto monsterBrush = monsters[rand() % monsters.size()];
monsterBrush->drawMonster(map, map->getTile(*iter), &time);
positions.erase(iter);
}
}
}
}

0 comments on commit 1321d40

Please sign in to comment.