aboutsummaryrefslogtreecommitdiff
path: root/src/server/game/Globals/ObjectMgr.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/server/game/Globals/ObjectMgr.cpp')
-rw-r--r--src/server/game/Globals/ObjectMgr.cpp41
1 files changed, 27 insertions, 14 deletions
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))