|
@@ -4165,9 +4165,9 @@ void ZoneServer::KillSpawnByDistance(Spawn* spawn, float max_distance, bool incl
|
|
return;
|
|
return;
|
|
|
|
|
|
Spawn* test_spawn = 0;
|
|
Spawn* test_spawn = 0;
|
|
- std::vector<Spawn*> ret_list = GetSpawnsInGrid(spawn->GetLocation());
|
|
|
|
|
|
+ std::vector<Spawn*>* ret_list = GetSpawnsInGrid(spawn->GetLocation());
|
|
std::vector<Spawn*>::iterator itr;
|
|
std::vector<Spawn*>::iterator itr;
|
|
- for (itr = ret_list.begin(); itr != ret_list.end(); itr++) {
|
|
|
|
|
|
+ for (itr = ret_list->begin(); itr != ret_list->end(); itr++) {
|
|
test_spawn = *itr;
|
|
test_spawn = *itr;
|
|
if(test_spawn && test_spawn->Alive() && test_spawn->GetID() > 0 && test_spawn->GetID() != spawn->GetID() && test_spawn->IsEntity() &&
|
|
if(test_spawn && test_spawn->Alive() && test_spawn->GetID() > 0 && test_spawn->GetID() != spawn->GetID() && test_spawn->IsEntity() &&
|
|
(!test_spawn->IsPlayer() || include_players)){
|
|
(!test_spawn->IsPlayer() || include_players)){
|
|
@@ -4175,6 +4175,7 @@ void ZoneServer::KillSpawnByDistance(Spawn* spawn, float max_distance, bool incl
|
|
KillSpawn(true, test_spawn, spawn, send_packet);
|
|
KillSpawn(true, test_spawn, spawn, send_packet);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ safe_delete(ret_list);
|
|
}
|
|
}
|
|
|
|
|
|
void ZoneServer::SpawnSetByDistance(Spawn* spawn, float max_distance, string field, string value){
|
|
void ZoneServer::SpawnSetByDistance(Spawn* spawn, float max_distance, string field, string value){
|
|
@@ -4186,9 +4187,9 @@ void ZoneServer::SpawnSetByDistance(Spawn* spawn, float max_distance, string fie
|
|
if(type == 0xFFFFFFFF)
|
|
if(type == 0xFFFFFFFF)
|
|
return;
|
|
return;
|
|
|
|
|
|
- std::vector<Spawn*> ret_list = GetSpawnsInGrid(spawn->GetLocation());
|
|
|
|
|
|
+ std::vector<Spawn*>* ret_list = GetSpawnsInGrid(spawn->GetLocation());
|
|
std::vector<Spawn*>::iterator itr;
|
|
std::vector<Spawn*>::iterator itr;
|
|
- for (itr = ret_list.begin(); itr != ret_list.end(); itr++) {
|
|
|
|
|
|
+ for (itr = ret_list->begin(); itr != ret_list->end(); itr++) {
|
|
test_spawn = *itr;
|
|
test_spawn = *itr;
|
|
if(test_spawn && test_spawn->GetID() > 0 && test_spawn->GetID() != spawn->GetID() && !test_spawn->IsPlayer()){
|
|
if(test_spawn && test_spawn->GetID() > 0 && test_spawn->GetID() != spawn->GetID() && !test_spawn->IsPlayer()){
|
|
if(test_spawn->GetDistance(spawn) < max_distance){
|
|
if(test_spawn->GetDistance(spawn) < max_distance){
|
|
@@ -4196,6 +4197,7 @@ void ZoneServer::SpawnSetByDistance(Spawn* spawn, float max_distance, string fie
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ safe_delete(ret_list);
|
|
}
|
|
}
|
|
|
|
|
|
void ZoneServer::AddSpawnScriptTimer(SpawnScriptTimer* timer){
|
|
void ZoneServer::AddSpawnScriptTimer(SpawnScriptTimer* timer){
|
|
@@ -7023,17 +7025,25 @@ void ZoneServer::RemovePlayerPassenger(int32 char_id) {
|
|
MTransportSpawns.releasereadlock(__FUNCTION__, __LINE__);
|
|
MTransportSpawns.releasereadlock(__FUNCTION__, __LINE__);
|
|
}
|
|
}
|
|
|
|
|
|
-vector<Spawn*> ZoneServer::GetAttackableSpawnsByDistance(Spawn* caster, float distance) {
|
|
|
|
- vector<Spawn*> ret;
|
|
|
|
|
|
+vector<int32> ZoneServer::GetAttackableSpawnsByDistance(Spawn* caster, float distance) {
|
|
|
|
+ vector<int32> ret;
|
|
Spawn* spawn = 0;
|
|
Spawn* spawn = 0;
|
|
- std::vector<Spawn*> ret_list = GetSpawnsInGrid(caster->GetLocation());
|
|
|
|
- std::vector<Spawn*>::iterator itr;
|
|
|
|
- for (itr = ret_list.begin(); itr != ret_list.end(); itr++) {
|
|
|
|
- spawn = *itr;
|
|
|
|
- if (spawn && spawn->IsNPC() && spawn->appearance.attackable > 0 && spawn->GetID() > 0 && spawn->GetID() != caster->GetID() &&
|
|
|
|
- spawn->Alive() && spawn->GetDistance(caster, true) <= distance)
|
|
|
|
- ret.push_back(spawn);
|
|
|
|
|
|
+
|
|
|
|
+ std::shared_lock lock(MGridMaps);
|
|
|
|
+ std::map<int32, GridMap*>::iterator grids = grid_maps.find(caster->GetLocation());
|
|
|
|
+ if(grids != grid_maps.end()) {
|
|
|
|
+ grids->second->MSpawns.lock();
|
|
|
|
+ typedef map <int32, Spawn*> SpawnMapType;
|
|
|
|
+ for( SpawnMapType::iterator it = grids->second->spawns.begin(); it != grids->second->spawns.end(); ++it ) {
|
|
|
|
+ Spawn* spawn = it->second;
|
|
|
|
+ if (spawn && spawn->IsNPC() && spawn->appearance.attackable > 0 && spawn->GetID() > 0 && spawn->GetID() != caster->GetID() &&
|
|
|
|
+ spawn->Alive() && spawn->GetDistance(caster, true) <= distance) {
|
|
|
|
+ ret.push_back(spawn->GetID());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ grids->second->MSpawns.unlock();
|
|
}
|
|
}
|
|
|
|
+
|
|
return ret;
|
|
return ret;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -8552,8 +8562,8 @@ int32 ZoneServer::GetSpawnCountInGrid(int32 grid_id) {
|
|
return count;
|
|
return count;
|
|
}
|
|
}
|
|
|
|
|
|
-std::vector<Spawn*> ZoneServer::GetSpawnsInGrid(int32 grid_id) {
|
|
|
|
- std::vector<Spawn*> ret;
|
|
|
|
|
|
+std::vector<Spawn*>* ZoneServer::GetSpawnsInGrid(int32 grid_id) {
|
|
|
|
+ std::vector<Spawn*>* ret = new std::vector<Spawn*>();
|
|
int32 count = 0;
|
|
int32 count = 0;
|
|
std::shared_lock lock(MGridMaps);
|
|
std::shared_lock lock(MGridMaps);
|
|
std::map<int32, GridMap*>::iterator grids = grid_maps.find(grid_id);
|
|
std::map<int32, GridMap*>::iterator grids = grid_maps.find(grid_id);
|
|
@@ -8561,7 +8571,7 @@ std::vector<Spawn*> ZoneServer::GetSpawnsInGrid(int32 grid_id) {
|
|
grids->second->MSpawns.lock();
|
|
grids->second->MSpawns.lock();
|
|
typedef map <int32, Spawn*> SpawnMapType;
|
|
typedef map <int32, Spawn*> SpawnMapType;
|
|
for( SpawnMapType::iterator it = grids->second->spawns.begin(); it != grids->second->spawns.end(); ++it ) {
|
|
for( SpawnMapType::iterator it = grids->second->spawns.begin(); it != grids->second->spawns.end(); ++it ) {
|
|
- ret.push_back( it->second );
|
|
|
|
|
|
+ ret->push_back( it->second );
|
|
}
|
|
}
|
|
grids->second->MSpawns.unlock();
|
|
grids->second->MSpawns.unlock();
|
|
}
|
|
}
|