diff --git a/source/WorldServer/LuaFunctions.cpp b/source/WorldServer/LuaFunctions.cpp index 1695465..0fdc601 100644 --- a/source/WorldServer/LuaFunctions.cpp +++ b/source/WorldServer/LuaFunctions.cpp @@ -14235,11 +14235,11 @@ int EQ2Emu_lua_GetSpellInitialTarget(lua_State* state) { lua_interface->ResetFunctionStack(state); if (spell) { if(!spell->caster) { - lua_interface->LogError("%s: LUA GetSpellTarget command error, caster does not exist.", lua_interface->GetScriptName(state)); + lua_interface->LogError("%s: LUA GetSpellInitialTarget command error, caster does not exist.", lua_interface->GetScriptName(state)); return 0; } if(!spell->caster->GetZone()) { - lua_interface->LogError("%s: LUA GetSpellTarget command error, zone does not exist.", lua_interface->GetScriptName(state)); + lua_interface->LogError("%s: LUA GetSpellInitialTarget command error, zone does not exist.", lua_interface->GetScriptName(state)); return 0; } Spawn* spawn = spell->caster->GetZone()->GetSpawnByID(spell->initial_target); @@ -14248,7 +14248,7 @@ int EQ2Emu_lua_GetSpellInitialTarget(lua_State* state) { return 1; } else { - lua_interface->LogError("%s: LUA GetSpellTarget command error, could not find initial target %u to map to spawn.", lua_interface->GetScriptName(state), spell->initial_target); + lua_interface->LogError("%s: LUA GetSpellInitialTarget command error, could not find initial target %u to map to spawn.", lua_interface->GetScriptName(state), spell->initial_target); } } return 0; diff --git a/source/WorldServer/zoneserver.cpp b/source/WorldServer/zoneserver.cpp index 85b759f..8586581 100644 --- a/source/WorldServer/zoneserver.cpp +++ b/source/WorldServer/zoneserver.cpp @@ -3496,9 +3496,12 @@ GroundSpawn* ZoneServer::AddGroundSpawn(SpawnLocation* spawnlocation, SpawnEntry } void ZoneServer::AddSpawn(Spawn* spawn) { - if(!spawn->IsPlayer()) // we already set it on loadCharacter - spawn->SetZone(this); - + if(!spawn->IsPlayer()) { + spawn->SetZone(this); // we already set it on loadCharacter + } + else { + pNumPlayers++; + } MIgnoredWidgets.lock_shared(); std::map::iterator itr; for(itr = ignored_widgets.begin(); itr != ignored_widgets.end(); itr++) { @@ -4654,6 +4657,10 @@ void ZoneServer::RemoveFromRangeMap(Client* client){ void ZoneServer::RemoveSpawn(Spawn* spawn, bool delete_spawn, bool respawn, bool lock, bool erase_from_spawn_list, bool lock_spell_process) { + if(spawn->IsPlayer()) { + if(pNumPlayers > 0) + pNumPlayers--; + } LogWrite(ZONE__DEBUG, 3, "Zone", "Processing RemoveSpawn function for %s (%i)...", spawn->GetName(),spawn->GetID()); PacketStruct* packet = 0; diff --git a/source/WorldServer/zoneserver.h b/source/WorldServer/zoneserver.h index 68c9afd..0ca2be4 100644 --- a/source/WorldServer/zoneserver.h +++ b/source/WorldServer/zoneserver.h @@ -936,7 +936,7 @@ private: bool always_loaded; bool isInstance; - int32 pNumPlayers; + std::atomic pNumPlayers; sint16 minimumStatus; int16 minimumLevel; int16 maximumLevel;