deleteSpawn()

This commit is contained in:
Ahmed Samy 2014-01-14 11:04:48 +02:00
parent 93be0f975f
commit e4ba805e00
3 changed files with 10 additions and 0 deletions

View File

@ -407,6 +407,14 @@ SpawnPtr CreatureManager::addSpawn(const Position& centerPos, int radius)
return ret; return ret;
} }
void CreatureManager::deleteSpawn(const SpawnPtr& spawn)
{
const Position& centerPos = spawn->getCenterPos();
auto it = m_spawns.find(centerPos);
if(it != m_spawns.end())
m_spawns.erase(it);
}
std::vector<SpawnPtr> CreatureManager::getSpawns() std::vector<SpawnPtr> CreatureManager::getSpawns()
{ {
std::vector<SpawnPtr> spawns; std::vector<SpawnPtr> spawns;

View File

@ -125,6 +125,7 @@ public:
SpawnPtr getSpawn(const Position& centerPos); SpawnPtr getSpawn(const Position& centerPos);
SpawnPtr getSpawnForPlacePos(const Position& pos); SpawnPtr getSpawnForPlacePos(const Position& pos);
SpawnPtr addSpawn(const Position& centerPos, int radius); SpawnPtr addSpawn(const Position& centerPos, int radius);
void deleteSpawn(const SpawnPtr& spawn);
bool isLoaded() { return m_loaded; } bool isLoaded() { return m_loaded; }
bool isSpawnLoaded() { return m_spawnLoaded; } bool isSpawnLoaded() { return m_spawnLoaded; }

View File

@ -173,6 +173,7 @@ void Client::registerLuaFunctions()
g_lua.bindSingletonFunction("g_creatures", "clear", &CreatureManager::clear, &g_creatures); g_lua.bindSingletonFunction("g_creatures", "clear", &CreatureManager::clear, &g_creatures);
g_lua.bindSingletonFunction("g_creatures", "clearSpawns", &CreatureManager::clearSpawns, &g_creatures); g_lua.bindSingletonFunction("g_creatures", "clearSpawns", &CreatureManager::clearSpawns, &g_creatures);
g_lua.bindSingletonFunction("g_creatures", "getSpawns", &CreatureManager::getSpawns, &g_creatures); g_lua.bindSingletonFunction("g_creatures", "getSpawns", &CreatureManager::getSpawns, &g_creatures);
g_lua.bindSingletonFunction("g_creatures", "deleteSpawn", &CreatureManager::deleteSpawn, &g_creatures);
g_lua.registerSingletonClass("g_game"); g_lua.registerSingletonClass("g_game");
g_lua.bindSingletonFunction("g_game", "loginWorld", &Game::loginWorld, &g_game); g_lua.bindSingletonFunction("g_game", "loginWorld", &Game::loginWorld, &g_game);