Crash fix, new lua function IsSpawnGroupAlive(Zone, Group_ID)
Crash fix for SpawnGroupByID on invalid group, IsSpawnGroupAlive(Zone, Group_ID) added.
This commit is contained in:
parent
5d2d49fd47
commit
ca28e77ae4
@ -3591,13 +3591,6 @@ EQ2Packet* PlayerItemList::serialize(Player* player, int16 version){
|
|||||||
if(item && item->details.new_item)
|
if(item && item->details.new_item)
|
||||||
new_index++;
|
new_index++;
|
||||||
|
|
||||||
if(item) {
|
|
||||||
printf("%u: %s\n", i, item->name.c_str());
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
printf("%u: empty\n", i);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(item && firstRun && i > 19) {
|
if(item && firstRun && i > 19) {
|
||||||
item->details.new_item = true;
|
item->details.new_item = true;
|
||||||
continue;
|
continue;
|
||||||
|
@ -4700,6 +4700,17 @@ int EQ2Emu_lua_IsAlive(lua_State* state) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int EQ2Emu_lua_IsSpawnGroupAlive(lua_State* state) {
|
||||||
|
ZoneServer* zone = lua_interface->GetZone(state);
|
||||||
|
int32 group_id = lua_interface->GetInt32Value(state, 2);
|
||||||
|
lua_interface->ResetFunctionStack(state);
|
||||||
|
if (zone) {
|
||||||
|
lua_interface->SetBooleanValue(state, zone->IsSpawnGroupAlive(group_id));
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
int EQ2Emu_lua_IsInCombat(lua_State* state) {
|
int EQ2Emu_lua_IsInCombat(lua_State* state) {
|
||||||
if (!lua_interface)
|
if (!lua_interface)
|
||||||
return 0;
|
return 0;
|
||||||
@ -10812,6 +10823,9 @@ int EQ2Emu_lua_SpawnGroupByID(lua_State* state) {
|
|||||||
vector<Spawn*> group;
|
vector<Spawn*> group;
|
||||||
|
|
||||||
Spawn* leader = 0;
|
Spawn* leader = 0;
|
||||||
|
if(locs == nullptr)
|
||||||
|
return 0;
|
||||||
|
|
||||||
for (itr = locs->begin(); itr != locs->end(); itr++) {
|
for (itr = locs->begin(); itr != locs->end(); itr++) {
|
||||||
SpawnLocation* location = zone->GetSpawnLocation(itr->second);
|
SpawnLocation* location = zone->GetSpawnLocation(itr->second);
|
||||||
if (!location) {
|
if (!location) {
|
||||||
|
@ -223,6 +223,7 @@ int EQ2Emu_lua_IsGateAllowed(lua_State* state);
|
|||||||
int EQ2Emu_lua_Bind(lua_State* state);
|
int EQ2Emu_lua_Bind(lua_State* state);
|
||||||
int EQ2Emu_lua_Gate(lua_State* state);
|
int EQ2Emu_lua_Gate(lua_State* state);
|
||||||
int EQ2Emu_lua_IsAlive(lua_State* state);
|
int EQ2Emu_lua_IsAlive(lua_State* state);
|
||||||
|
int EQ2Emu_lua_IsSpawnGroupAlive(lua_State* state);
|
||||||
int EQ2Emu_lua_IsInCombat(lua_State* state);
|
int EQ2Emu_lua_IsInCombat(lua_State* state);
|
||||||
int EQ2Emu_lua_SendMessage(lua_State* state);
|
int EQ2Emu_lua_SendMessage(lua_State* state);
|
||||||
int EQ2Emu_lua_SendPopUpMessage(lua_State* state);
|
int EQ2Emu_lua_SendPopUpMessage(lua_State* state);
|
||||||
|
@ -1065,6 +1065,7 @@ void LuaInterface::RegisterFunctions(lua_State* state) {
|
|||||||
lua_register(state, "Zone", EQ2Emu_lua_Zone);
|
lua_register(state, "Zone", EQ2Emu_lua_Zone);
|
||||||
lua_register(state, "AddHate", EQ2Emu_lua_AddHate);
|
lua_register(state, "AddHate", EQ2Emu_lua_AddHate);
|
||||||
lua_register(state, "IsAlive", EQ2Emu_lua_IsAlive);
|
lua_register(state, "IsAlive", EQ2Emu_lua_IsAlive);
|
||||||
|
lua_register(state, "IsSpawnGroupAlive", EQ2Emu_lua_IsSpawnGroupAlive);
|
||||||
lua_register(state, "IsInCombat", EQ2Emu_lua_IsInCombat);
|
lua_register(state, "IsInCombat", EQ2Emu_lua_IsInCombat);
|
||||||
lua_register(state, "Attack", EQ2Emu_lua_Attack);
|
lua_register(state, "Attack", EQ2Emu_lua_Attack);
|
||||||
lua_register(state, "ApplySpellVisual", EQ2Emu_lua_ApplySpellVisual);
|
lua_register(state, "ApplySpellVisual", EQ2Emu_lua_ApplySpellVisual);
|
||||||
|
@ -4178,6 +4178,31 @@ Spawn* ZoneServer::GetSpawnGroup(int32 id){
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ZoneServer::IsSpawnGroupAlive(int32 id){
|
||||||
|
bool ret = false;
|
||||||
|
if(id < 1)
|
||||||
|
return ret;
|
||||||
|
|
||||||
|
Spawn* spawn = GetSpawnGroup(id);
|
||||||
|
if(spawn) {
|
||||||
|
vector<Spawn*> groupMembers;
|
||||||
|
if (!spawn->IsPlayer() && spawn->HasSpawnGroup()) {
|
||||||
|
groupMembers = *spawn->GetSpawnGroup();
|
||||||
|
}
|
||||||
|
|
||||||
|
Spawn* group_spawn = 0;
|
||||||
|
vector<Spawn*>::iterator itr;
|
||||||
|
for(itr = groupMembers.begin(); itr != groupMembers.end(); itr++){
|
||||||
|
group_spawn = *itr;
|
||||||
|
if(group_spawn->Alive()) {
|
||||||
|
ret = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
Spawn* ZoneServer::GetSpawnByLocationID(int32 location_id) {
|
Spawn* ZoneServer::GetSpawnByLocationID(int32 location_id) {
|
||||||
Spawn* ret = 0;
|
Spawn* ret = 0;
|
||||||
Spawn* current_spawn = 0;
|
Spawn* current_spawn = 0;
|
||||||
|
@ -371,7 +371,7 @@ public:
|
|||||||
void Depop(bool respawns = false, bool repop = false);
|
void Depop(bool respawns = false, bool repop = false);
|
||||||
|
|
||||||
Spawn* GetSpawnGroup(int32 id);
|
Spawn* GetSpawnGroup(int32 id);
|
||||||
|
bool IsSpawnGroupAlive(int32 id);
|
||||||
void AddEnemyList(NPC* npc);
|
void AddEnemyList(NPC* npc);
|
||||||
|
|
||||||
void ReloadClientQuests();
|
void ReloadClientQuests();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user