aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorModoX <moardox@gmail.com>2023-08-29 21:18:06 +0200
committerGitHub <noreply@github.com>2023-08-29 21:18:06 +0200
commit7c0ef292be90340a81f32fc55df15e3489d13d4e (patch)
treea57e40fd2b444595ed0178809da84b6b68c445bf /src
parent9d69c36bedd73c3c8dd330b9303171b13c0ce9ee (diff)
Core/Creature: Allow creature table to override npc- and unitflags to 0 (#29281)
Diffstat (limited to 'src')
-rw-r--r--src/server/game/Entities/Creature/CreatureData.h8
-rw-r--r--src/server/game/Globals/ObjectMgr.cpp41
2 files changed, 31 insertions, 18 deletions
diff --git a/src/server/game/Entities/Creature/CreatureData.h b/src/server/game/Entities/Creature/CreatureData.h
index fb1733b45f4..3d1d896b0f0 100644
--- a/src/server/game/Entities/Creature/CreatureData.h
+++ b/src/server/game/Entities/Creature/CreatureData.h
@@ -620,10 +620,10 @@ struct CreatureData : public SpawnData
uint32 curhealth = 0;
uint32 curmana = 0;
uint8 movementType = 0;
- uint64 npcflag;
- uint32 unit_flags = 0; // enum UnitFlags mask values
- uint32 unit_flags2 = 0; // enum UnitFlags2 mask values
- uint32 unit_flags3 = 0; // enum UnitFlags3 mask values
+ Optional<uint64> npcflag;
+ Optional<uint32> unit_flags; // enum UnitFlags mask values
+ Optional<uint32> unit_flags2; // enum UnitFlags2 mask values
+ Optional<uint32> unit_flags3; // enum UnitFlags3 mask values
};
struct CreatureModelInfo
diff --git a/src/server/game/Globals/ObjectMgr.cpp b/src/server/game/Globals/ObjectMgr.cpp
index d08133d3348..9e209b438d7 100644
--- a/src/server/game/Globals/ObjectMgr.cpp
+++ b/src/server/game/Globals/ObjectMgr.cpp
@@ -1642,7 +1642,7 @@ CreatureModel const* ObjectMgr::ChooseDisplayId(CreatureTemplate const* cinfo, C
void ObjectMgr::ChooseCreatureFlags(CreatureTemplate const* cInfo, uint64* npcFlags, uint32* unitFlags, uint32* unitFlags2, uint32* unitFlags3, CreatureData const* data /*= nullptr*/)
{
-#define ChooseCreatureFlagSource(field) ((data && data->field) ? data->field : cInfo->field)
+#define ChooseCreatureFlagSource(field) ((data && data->field.has_value()) ? *data->field : cInfo->field)
if (npcFlags)
*npcFlags = ChooseCreatureFlagSource(npcflag);
@@ -2183,10 +2183,14 @@ void ObjectMgr::LoadCreatures()
data.spawnDifficulties = ParseSpawnDifficulties(fields[15].GetStringView(), "creature", guid, data.mapId, spawnMasks[data.mapId]);
int16 gameEvent = fields[16].GetInt8();
data.poolId = fields[17].GetUInt32();
- data.npcflag = fields[18].GetUInt64();
- data.unit_flags = fields[19].GetUInt32();
- data.unit_flags2 = fields[20].GetUInt32();
- data.unit_flags3 = fields[21].GetUInt32();
+ if (!fields[18].IsNull())
+ data.npcflag = fields[18].GetUInt64();
+ if (!fields[19].IsNull())
+ data.unit_flags = fields[19].GetUInt32();
+ if (!fields[20].IsNull())
+ data.unit_flags2 = fields[20].GetUInt32();
+ if (!fields[21].IsNull())
+ data.unit_flags3 = fields[21].GetUInt32();
data.phaseUseFlags = fields[22].GetUInt8();
data.phaseId = fields[23].GetUInt32();
data.phaseGroup = fields[24].GetUInt32();
@@ -2322,22 +2326,31 @@ void ObjectMgr::LoadCreatures()
}
}
- if (uint32 disallowedUnitFlags = (data.unit_flags & ~UNIT_FLAG_ALLOWED))
+ if (data.unit_flags.has_value())
{
- TC_LOG_ERROR("sql.sql", "Table `creature` has creature (GUID: {} Entry: {}) with disallowed `unit_flags` {}, removing incorrect flag.", guid, data.id, disallowedUnitFlags);
- data.unit_flags &= UNIT_FLAG_ALLOWED;
+ if (uint32 disallowedUnitFlags = (*data.unit_flags & ~UNIT_FLAG_ALLOWED))
+ {
+ TC_LOG_ERROR("sql.sql", "Table `creature` has creature (GUID: {} Entry: {}) with disallowed `unit_flags` {}, removing incorrect flag.", guid, data.id, disallowedUnitFlags);
+ *data.unit_flags &= UNIT_FLAG_ALLOWED;
+ }
}
- if (uint32 disallowedUnitFlags2 = (data.unit_flags2 & ~UNIT_FLAG2_ALLOWED))
+ if (data.unit_flags2.has_value())
{
- TC_LOG_ERROR("sql.sql", "Table `creature` has creature (GUID: {} Entry: {}) with disallowed `unit_flags2` {}, removing incorrect flag.", guid, data.id, disallowedUnitFlags2);
- data.unit_flags2 &= UNIT_FLAG2_ALLOWED;
+ if (uint32 disallowedUnitFlags2 = (*data.unit_flags2 & ~UNIT_FLAG2_ALLOWED))
+ {
+ TC_LOG_ERROR("sql.sql", "Table `creature` has creature (GUID: {} Entry: {}) with disallowed `unit_flags2` {}, removing incorrect flag.", guid, data.id, disallowedUnitFlags2);
+ *data.unit_flags2 &= UNIT_FLAG2_ALLOWED;
+ }
}
- if (uint32 disallowedUnitFlags3 = (data.unit_flags3 & ~UNIT_FLAG3_ALLOWED))
+ if (data.unit_flags3.has_value())
{
- TC_LOG_ERROR("sql.sql", "Table `creature` has creature (GUID: {} Entry: {}) with disallowed `unit_flags2` {}, removing incorrect flag.", guid, data.id, disallowedUnitFlags3);
- data.unit_flags3 &= UNIT_FLAG3_ALLOWED;
+ if (uint32 disallowedUnitFlags3 = (*data.unit_flags3 & ~UNIT_FLAG3_ALLOWED))
+ {
+ TC_LOG_ERROR("sql.sql", "Table `creature` has creature (GUID: {} Entry: {}) with disallowed `unit_flags2` {}, removing incorrect flag.", guid, data.id, disallowedUnitFlags3);
+ *data.unit_flags3 &= UNIT_FLAG3_ALLOWED;
+ }
}
if (sWorld->getBoolConfig(CONFIG_CALCULATE_CREATURE_ZONE_AREA_DATA))