Merge branch 'master' of https://git.eq2emu.com/devn00b/EQ2EMu
This commit is contained in:
commit
7757bc249a
4 changed files with 41 additions and 29 deletions
|
@ -6151,12 +6151,13 @@ void Commands::Command_Grid(Client* client, Seperator* sep)
|
||||||
|
|
||||||
if(sep->IsNumber(1))
|
if(sep->IsNumber(1))
|
||||||
grid = atoul(sep->arg[1]);
|
grid = atoul(sep->arg[1]);
|
||||||
std::vector<Spawn*> spawns = client->GetPlayer()->GetZone()->GetSpawnsInGrid(grid);
|
std::vector<Spawn*>* spawns = client->GetPlayer()->GetZone()->GetSpawnsInGrid(grid);
|
||||||
client->Message(CHANNEL_COLOR_RED, "Grid ID %u has %u spawns.", grid, spawns.size());
|
client->Message(CHANNEL_COLOR_RED, "Grid ID %u has %u spawns.", grid, spawns->size());
|
||||||
for(int i=0;i<spawns.size();i++) {
|
for(int i=0;i<spawns->size();i++) {
|
||||||
Spawn* spawn = spawns.at(i);
|
Spawn* spawn = spawns->at(i);
|
||||||
client->Message(CHANNEL_COLOR_YELLOW, "Spawn %s (%u), Loc X/Y/Z: %f/%f/%f.", spawn->GetName(), spawn->GetID(), spawn->GetX(), spawn->GetY(), spawn->GetZ());
|
client->Message(CHANNEL_COLOR_YELLOW, "Spawn %s (%u), Loc X/Y/Z: %f/%f/%f.", spawn->GetName(), spawn->GetID(), spawn->GetX(), spawn->GetY(), spawn->GetZ());
|
||||||
}
|
}
|
||||||
|
safe_delete(spawns);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
client->Message(CHANNEL_COLOR_YELLOW, "Your Grid ID is %u", client->GetPlayer()->appearance.pos.grid_id);
|
client->Message(CHANNEL_COLOR_YELLOW, "Your Grid ID is %u", client->GetPlayer()->appearance.pos.grid_id);
|
||||||
|
|
|
@ -2522,10 +2522,9 @@ void SpellProcess::GetSpellTargetsTrueAOE(LuaSpell* luaspell) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
int32 ignore_target = 0;
|
int32 ignore_target = 0;
|
||||||
vector<Spawn*> spawns = luaspell->caster->GetZone()->GetAttackableSpawnsByDistance(luaspell->caster, luaspell->spell->GetSpellData()->radius);
|
vector<int32> spawns = luaspell->caster->GetZone()->GetAttackableSpawnsByDistance(luaspell->caster, luaspell->spell->GetSpellData()->radius);
|
||||||
luaspell->MSpellTargets.writelock(__FUNCTION__, __LINE__);
|
luaspell->MSpellTargets.writelock(__FUNCTION__, __LINE__);
|
||||||
for (int8 i = 0; i < spawns.size(); i++) {
|
for (int8 i = 0; i < spawns.size(); i++) {
|
||||||
Spawn* spawn = spawns.at(i);
|
|
||||||
if (i == 0){
|
if (i == 0){
|
||||||
if (luaspell->initial_target && luaspell->caster->GetID() != luaspell->initial_target){
|
if (luaspell->initial_target && luaspell->caster->GetID() != luaspell->initial_target){
|
||||||
//this is the "Direct" target and aoe can't be avoided
|
//this is the "Direct" target and aoe can't be avoided
|
||||||
|
@ -2535,13 +2534,15 @@ void SpellProcess::GetSpellTargetsTrueAOE(LuaSpell* luaspell) {
|
||||||
if (luaspell->targets.size() >= luaspell->spell->GetSpellData()->max_aoe_targets)
|
if (luaspell->targets.size() >= luaspell->spell->GetSpellData()->max_aoe_targets)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32 target_id = spawns.at(i);
|
||||||
|
Spawn* spawn = luaspell->caster->GetZone()->GetSpawnByID(target_id);
|
||||||
|
if(!spawn) {
|
||||||
|
LogWrite(SPELL__ERROR, 0, "Spell", "Error: Spell target is NULL! SpellProcess::ProcessSpell for Spell '%s' target id %u", (luaspell->spell != nullptr) ? luaspell->spell->GetName() : "Unknown", target_id);
|
||||||
|
}
|
||||||
//If we have already added this spawn, check the next spawn in the list
|
//If we have already added this spawn, check the next spawn in the list
|
||||||
if (spawn && spawn->GetID() == ignore_target){
|
if (spawn && spawn->GetID() == ignore_target){
|
||||||
i++;
|
continue;
|
||||||
if (i < spawns.size())
|
|
||||||
spawn = spawns.at(i);
|
|
||||||
else
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
if (spawn){
|
if (spawn){
|
||||||
//If this spawn is immune to aoe, continue
|
//If this spawn is immune to aoe, continue
|
||||||
|
|
|
@ -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<int32> ZoneServer::GetAttackableSpawnsByDistance(Spawn* caster, float distance) {
|
||||||
vector<Spawn*> ret;
|
vector<int32> ret;
|
||||||
Spawn* spawn = 0;
|
Spawn* spawn = 0;
|
||||||
std::vector<Spawn*> ret_list = GetSpawnsInGrid(caster->GetLocation());
|
|
||||||
std::vector<Spawn*>::iterator itr;
|
std::shared_lock lock(MGridMaps);
|
||||||
for (itr = ret_list.begin(); itr != ret_list.end(); itr++) {
|
std::map<int32, GridMap*>::iterator grids = grid_maps.find(caster->GetLocation());
|
||||||
spawn = *itr;
|
if(grids != grid_maps.end()) {
|
||||||
if (spawn && spawn->IsNPC() && spawn->appearance.attackable > 0 && spawn->GetID() > 0 && spawn->GetID() != caster->GetID() &&
|
grids->second->MSpawns.lock();
|
||||||
spawn->Alive() && spawn->GetDistance(caster, true) <= distance)
|
typedef map <int32, Spawn*> SpawnMapType;
|
||||||
ret.push_back(spawn);
|
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*>* ZoneServer::GetSpawnsInGrid(int32 grid_id) {
|
||||||
std::vector<Spawn*> ret;
|
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();
|
||||||
}
|
}
|
||||||
|
|
|
@ -441,7 +441,7 @@ public:
|
||||||
Client* GetClientByCharID(int32 charid);
|
Client* GetClientByCharID(int32 charid);
|
||||||
|
|
||||||
/// <summary>Gets spawns for a true AoE spell</summary>
|
/// <summary>Gets spawns for a true AoE spell</summary>
|
||||||
vector<Spawn*> GetAttackableSpawnsByDistance(Spawn* spawn, float distance);
|
vector<int32> GetAttackableSpawnsByDistance(Spawn* spawn, float distance);
|
||||||
|
|
||||||
void StartZoneSpawnsForLevelThread(Client* client);
|
void StartZoneSpawnsForLevelThread(Client* client);
|
||||||
|
|
||||||
|
@ -713,7 +713,7 @@ public:
|
||||||
void AddSpawnToGrid(Spawn* spawn, int32 grid_id);
|
void AddSpawnToGrid(Spawn* spawn, int32 grid_id);
|
||||||
void RemoveSpawnFromGrid(Spawn* spawn, int32 grid_id);
|
void RemoveSpawnFromGrid(Spawn* spawn, int32 grid_id);
|
||||||
int32 GetSpawnCountInGrid(int32 grid_id);
|
int32 GetSpawnCountInGrid(int32 grid_id);
|
||||||
std::vector<Spawn*> GetSpawnsInGrid(int32 grid_id);
|
std::vector<Spawn*>* GetSpawnsInGrid(int32 grid_id);
|
||||||
private:
|
private:
|
||||||
#ifndef WIN32
|
#ifndef WIN32
|
||||||
pthread_t ZoneThread;
|
pthread_t ZoneThread;
|
||||||
|
|
Loading…
Reference in a new issue