mirror of
https://github.com/EQEmu/Server.git
synced 2026-05-06 04:42:28 +00:00
[Fix] Fix crash from lingering spawn2 reference in NPCs.
This commit is contained in:
parent
b8884d6572
commit
b79030310b
@ -2611,8 +2611,11 @@ bool NPC::Death(Mob* killer_mob, int64 damage, uint16 spell, EQ::skills::SkillTy
|
|||||||
|
|
||||||
safe_delete(app);
|
safe_delete(app);
|
||||||
|
|
||||||
if (respawn2) {
|
if (respawn2_id) {
|
||||||
respawn2->DeathReset(1);
|
auto respawn2 = GetSpawn();
|
||||||
|
if (respawn2) {
|
||||||
|
respawn2->DeathReset(1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (killer_mob && GetClass() != Class::LDoNTreasure) {
|
if (killer_mob && GetClass() != Class::LDoNTreasure) {
|
||||||
|
|||||||
@ -520,7 +520,7 @@ void EntityList::MobProcess()
|
|||||||
|
|
||||||
old_client_count = numclients;
|
old_client_count = numclients;
|
||||||
|
|
||||||
Spawn2* s2 = mob->CastToNPC()->respawn2;
|
Spawn2* s2 = mob->CastToNPC()->GetSpawn();
|
||||||
|
|
||||||
// Perform normal mob processing if any of these are true:
|
// Perform normal mob processing if any of these are true:
|
||||||
// -- zone is not empty
|
// -- zone is not empty
|
||||||
|
|||||||
@ -188,7 +188,7 @@ void command_advnpcspawn(Client *c, const Seperator *sep)
|
|||||||
}
|
}
|
||||||
|
|
||||||
auto target = c->GetTarget()->CastToNPC();
|
auto target = c->GetTarget()->CastToNPC();
|
||||||
auto spawn2 = target->respawn2;
|
auto spawn2 = target->GetSpawn();
|
||||||
if (!spawn2) {
|
if (!spawn2) {
|
||||||
c->Message(Chat::White, "Failed to delete spawn because NPC has no Spawn2.");
|
c->Message(Chat::White, "Failed to delete spawn because NPC has no Spawn2.");
|
||||||
return;
|
return;
|
||||||
@ -297,7 +297,7 @@ void command_advnpcspawn(Client *c, const Seperator *sep)
|
|||||||
}
|
}
|
||||||
|
|
||||||
auto target = c->GetTarget()->CastToNPC();
|
auto target = c->GetTarget()->CastToNPC();
|
||||||
auto spawn2 = target->respawn2;
|
auto spawn2 = target->GetSpawn();
|
||||||
if (!spawn2) {
|
if (!spawn2) {
|
||||||
c->Message(Chat::White, "Failed to edit respawn because NPC has no Spawn2.");
|
c->Message(Chat::White, "Failed to edit respawn because NPC has no Spawn2.");
|
||||||
return;
|
return;
|
||||||
@ -434,7 +434,7 @@ void command_advnpcspawn(Client *c, const Seperator *sep)
|
|||||||
}
|
}
|
||||||
|
|
||||||
auto target = c->GetTarget()->CastToNPC();
|
auto target = c->GetTarget()->CastToNPC();
|
||||||
auto spawn2 = target->respawn2;
|
auto spawn2 = target->GetSpawn();
|
||||||
if (!spawn2) {
|
if (!spawn2) {
|
||||||
c->Message(Chat::White, "Failed to move spawn because NPC has no Spawn2.");
|
c->Message(Chat::White, "Failed to move spawn because NPC has no Spawn2.");
|
||||||
return;
|
return;
|
||||||
|
|||||||
@ -8,7 +8,7 @@ void command_spawnfix(Client* c, const Seperator* sep)
|
|||||||
}
|
}
|
||||||
|
|
||||||
auto target = c->GetTarget()->CastToNPC();
|
auto target = c->GetTarget()->CastToNPC();
|
||||||
auto spawn2 = target->respawn2;
|
auto spawn2 = target->GetSpawn();
|
||||||
|
|
||||||
if (!spawn2) {
|
if (!spawn2) {
|
||||||
c->Message(Chat::White, "Failed to fix spawn, the spawn must not exist in the database.");
|
c->Message(Chat::White, "Failed to fix spawn, the spawn must not exist in the database.");
|
||||||
|
|||||||
@ -5,7 +5,7 @@ void command_wpadd(Client *c, const Seperator *sep)
|
|||||||
int type1 = 0, type2 = 0, pause = 0; // Defaults for a new grid
|
int type1 = 0, type2 = 0, pause = 0; // Defaults for a new grid
|
||||||
Mob *target = c->GetTarget();
|
Mob *target = c->GetTarget();
|
||||||
if (target && target->IsNPC()) {
|
if (target && target->IsNPC()) {
|
||||||
Spawn2 *s2info = target->CastToNPC()->respawn2;
|
Spawn2 *s2info = target->CastToNPC()->GetSpawn();
|
||||||
if (s2info == nullptr) {
|
if (s2info == nullptr) {
|
||||||
c->Message(
|
c->Message(
|
||||||
Chat::White,
|
Chat::White,
|
||||||
|
|||||||
26
zone/npc.cpp
26
zone/npc.cpp
@ -156,7 +156,7 @@ NPC::NPC(const NPCType *npc_type_data, Spawn2 *in_respawn, const glm::vec4 &posi
|
|||||||
|
|
||||||
NPCTypedata = npc_type_data;
|
NPCTypedata = npc_type_data;
|
||||||
NPCTypedata_ours = nullptr;
|
NPCTypedata_ours = nullptr;
|
||||||
respawn2 = in_respawn;
|
respawn2_id = in_respawn ? in_respawn->GetID() : 0;
|
||||||
|
|
||||||
swarm_timer.Disable();
|
swarm_timer.Disable();
|
||||||
|
|
||||||
@ -870,11 +870,14 @@ void NPC::Depop(bool start_spawn_timer) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
p_depop = true;
|
p_depop = true;
|
||||||
if (respawn2) {
|
if (respawn2_id) {
|
||||||
if (start_spawn_timer) {
|
auto respawn2 = entity_list.GetSpawnByID(respawn2_id);
|
||||||
respawn2->DeathReset();
|
if (respawn2) {
|
||||||
} else {
|
if (start_spawn_timer) {
|
||||||
respawn2->Depop();
|
respawn2->DeathReset();
|
||||||
|
} else {
|
||||||
|
respawn2->Depop();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1357,10 +1360,11 @@ uint32 ZoneDatabase::AddNewNPCSpawnGroupCommand(
|
|||||||
uint32 respawn_time = 1200;
|
uint32 respawn_time = 1200;
|
||||||
uint32 spawn_id = 0;
|
uint32 spawn_id = 0;
|
||||||
|
|
||||||
|
Spawn2 *respawn2 = n->respawn2_id ? entity_list.GetSpawnByID(n->respawn2_id) : nullptr;
|
||||||
if (in_respawn_time) {
|
if (in_respawn_time) {
|
||||||
respawn_time = in_respawn_time;
|
respawn_time = in_respawn_time;
|
||||||
} else if (n->respawn2 && n->respawn2->RespawnTimer()) {
|
} else if (respawn2 && respawn2->RespawnTimer()) {
|
||||||
respawn_time = n->respawn2->RespawnTimer();
|
respawn_time = respawn2->RespawnTimer();
|
||||||
}
|
}
|
||||||
|
|
||||||
auto s2 = Spawn2Repository::NewEntity();
|
auto s2 = Spawn2Repository::NewEntity();
|
||||||
@ -1420,7 +1424,7 @@ uint32 ZoneDatabase::UpdateNPCTypeAppearance(Client* c, NPC* n)
|
|||||||
|
|
||||||
uint32 ZoneDatabase::DeleteSpawnLeaveInNPCTypeTable(const std::string& zone, Client* c, NPC* n, uint32 remove_spawngroup_id)
|
uint32 ZoneDatabase::DeleteSpawnLeaveInNPCTypeTable(const std::string& zone, Client* c, NPC* n, uint32 remove_spawngroup_id)
|
||||||
{
|
{
|
||||||
if (!n->respawn2) {
|
if (!n->respawn2_id) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1428,7 +1432,7 @@ uint32 ZoneDatabase::DeleteSpawnLeaveInNPCTypeTable(const std::string& zone, Cli
|
|||||||
*this,
|
*this,
|
||||||
fmt::format(
|
fmt::format(
|
||||||
"`id` = {} AND `zone` = '{}' AND `spawngroupID` = {}",
|
"`id` = {} AND `zone` = '{}' AND `spawngroupID` = {}",
|
||||||
n->respawn2->GetID(),
|
n->respawn2_id,
|
||||||
zone,
|
zone,
|
||||||
n->GetSpawnGroupId()
|
n->GetSpawnGroupId()
|
||||||
)
|
)
|
||||||
@ -2778,7 +2782,7 @@ void NPC::LevelScale() {
|
|||||||
|
|
||||||
uint32 NPC::GetSpawnPointID() const
|
uint32 NPC::GetSpawnPointID() const
|
||||||
{
|
{
|
||||||
return respawn2 ? respawn2->GetID() : 0;
|
return respawn2_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
void NPC::NPCSlotTexture(uint8 slot, uint32 texture)
|
void NPC::NPCSlotTexture(uint8 slot, uint32 texture)
|
||||||
|
|||||||
@ -248,7 +248,7 @@ public:
|
|||||||
|
|
||||||
uint16 GetWaypointMax() const { return wp_m; }
|
uint16 GetWaypointMax() const { return wp_m; }
|
||||||
int32 GetGrid() const { return grid; }
|
int32 GetGrid() const { return grid; }
|
||||||
Spawn2* GetSpawn() { return respawn2 ? respawn2 : nullptr; }
|
Spawn2* GetSpawn() { return respawn2_id ? entity_list.GetSpawnByID(respawn2_id) : nullptr; }
|
||||||
uint32 GetSpawnGroupId() const { return spawn_group_id; }
|
uint32 GetSpawnGroupId() const { return spawn_group_id; }
|
||||||
uint32 GetSpawnPointID() const;
|
uint32 GetSpawnPointID() const;
|
||||||
|
|
||||||
@ -417,7 +417,7 @@ public:
|
|||||||
bool IsProximitySet();
|
bool IsProximitySet();
|
||||||
|
|
||||||
NPCProximity* proximity;
|
NPCProximity* proximity;
|
||||||
Spawn2* respawn2;
|
uint32 respawn2_id;
|
||||||
QGlobalCache *GetQGlobals() { return qGlobals; }
|
QGlobalCache *GetQGlobals() { return qGlobals; }
|
||||||
QGlobalCache *CreateQGlobals() { qGlobals = new QGlobalCache(); return qGlobals; }
|
QGlobalCache *CreateQGlobals() { qGlobals = new QGlobalCache(); return qGlobals; }
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user