[Crash] Fix IsUnderwaterOnly crash where npc data references can be stale (#2830)

* [Crash] Fix IsUnderwaterOnly crash where npc data references can be stale

* m_ prefix
This commit is contained in:
Chris Miles 2023-02-06 17:24:38 -06:00 committed by GitHub
parent 34d21d4056
commit c6eb12ac16
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 40 additions and 37 deletions

View File

@ -196,6 +196,7 @@ NPC::NPC(const NPCType *npc_type_data, Spawn2 *in_respawn, const glm::vec4 &posi
WIS = npc_type_data->WIS; WIS = npc_type_data->WIS;
CHA = npc_type_data->CHA; CHA = npc_type_data->CHA;
npc_mana = npc_type_data->Mana; npc_mana = npc_type_data->Mana;
m_is_underwater_only = npc_type_data->underwater;
//quick fix of ordering if they screwed it up in the DB //quick fix of ordering if they screwed it up in the DB
if (max_dmg < min_dmg) { if (max_dmg < min_dmg) {

View File

@ -437,7 +437,7 @@ public:
/* Only allows players that killed corpse to loot */ /* Only allows players that killed corpse to loot */
const bool HasPrivateCorpse() const { return NPCTypedata_ours ? NPCTypedata_ours->private_corpse : NPCTypedata->private_corpse; } const bool HasPrivateCorpse() const { return NPCTypedata_ours ? NPCTypedata_ours->private_corpse : NPCTypedata->private_corpse; }
virtual const bool IsUnderwaterOnly() const { return NPCTypedata_ours ? NPCTypedata_ours->underwater : NPCTypedata->underwater; } virtual const bool IsUnderwaterOnly() const { return m_is_underwater_only; }
const char* GetRawNPCTypeName() const { return NPCTypedata_ours ? NPCTypedata_ours->name : NPCTypedata->name; } const char* GetRawNPCTypeName() const { return NPCTypedata_ours ? NPCTypedata_ours->name : NPCTypedata->name; }
virtual int GetKillExpMod() const { return NPCTypedata_ours ? NPCTypedata_ours->exp_mod : NPCTypedata->exp_mod; } virtual int GetKillExpMod() const { return NPCTypedata_ours ? NPCTypedata_ours->exp_mod : NPCTypedata->exp_mod; }
@ -674,6 +674,8 @@ protected:
QGlobalCache *qGlobals; QGlobalCache *qGlobals;
uint32 adventure_template_id; uint32 adventure_template_id;
bool m_is_underwater_only = false;
//mercenary stuff //mercenary stuff
std::list<MercType> mercTypeList; std::list<MercType> mercTypeList;
std::list<MercData> mercDataList; std::list<MercData> mercDataList;