mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-16 07:30:42 +01:00
Core/Creature: Disallow nearly all non-static flags on DB side (#27024)
Closes #25764
(cherry picked from commit a88001938e)
This commit is contained in:
@@ -149,6 +149,16 @@ enum UnitFlags : uint32
|
||||
UNIT_FLAG_PREVENT_EMOTES_FROM_CHAT_TEXT = 0x20000000, // Prevent automatically playing emotes from parsing chat text, for example "lol" in /say, ending message with ? or !, or using /yell
|
||||
UNIT_FLAG_SHEATHE = 0x40000000,
|
||||
UNIT_FLAG_IMMUNE = 0x80000000, // Immune to damage
|
||||
|
||||
UNIT_FLAG_DISALLOWED = (UNIT_FLAG_SERVER_CONTROLLED | UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_REMOVE_CLIENT_CONTROL |
|
||||
UNIT_FLAG_PLAYER_CONTROLLED | UNIT_FLAG_RENAME | UNIT_FLAG_PREPARATION | /* UNIT_FLAG_UNK_6 | */
|
||||
UNIT_FLAG_NOT_ATTACKABLE_1 | UNIT_FLAG_LOOTING | UNIT_FLAG_PET_IN_COMBAT | UNIT_FLAG_PVP_ENABLING |
|
||||
UNIT_FLAG_SILENCED | UNIT_FLAG_NON_ATTACKABLE_2 | UNIT_FLAG_PACIFIED | UNIT_FLAG_STUNNED |
|
||||
UNIT_FLAG_IN_COMBAT | UNIT_FLAG_ON_TAXI | UNIT_FLAG_DISARMED | UNIT_FLAG_CONFUSED | UNIT_FLAG_FLEEING |
|
||||
UNIT_FLAG_POSSESSED | UNIT_FLAG_SKINNABLE | UNIT_FLAG_MOUNT | UNIT_FLAG_UNK_28 |
|
||||
UNIT_FLAG_PREVENT_EMOTES_FROM_CHAT_TEXT | UNIT_FLAG_SHEATHE | UNIT_FLAG_IMMUNE),
|
||||
|
||||
UNIT_FLAG_ALLOWED = (0xFFFFFFFF & ~UNIT_FLAG_DISALLOWED)
|
||||
};
|
||||
|
||||
// Value masks for UNIT_FIELD_FLAGS_2
|
||||
@@ -184,7 +194,21 @@ enum UnitFlags2 : uint32
|
||||
UNIT_FLAG2_UNTARGETABLE_BY_CLIENT = 0x04000000, // TITLE Untargetable By Client
|
||||
UNIT_FLAG2_ATTACKER_IGNORES_MINIMUM_RANGES = 0x08000000, // TITLE Attacker Ignores Minimum Ranges
|
||||
UNIT_FLAG2_UNINTERACTIBLE_IF_HOSTILE = 0x10000000, // TITLE Uninteractible If Hostile
|
||||
UNIT_FLAG2_UNUSED_11 = 0x20000000,
|
||||
UNIT_FLAG2_INFINITE_AOI = 0x40000000, // TITLE Infinite (AOI)
|
||||
UNIT_FLAG2_UNUSED_13 = 0x80000000,
|
||||
|
||||
UNIT_FLAG2_DISALLOWED = (UNIT_FLAG2_FEIGN_DEATH | UNIT_FLAG2_IGNORE_REPUTATION | UNIT_FLAG2_COMPREHEND_LANG |
|
||||
UNIT_FLAG2_MIRROR_IMAGE | UNIT_FLAG2_FORCE_MOVEMENT | UNIT_FLAG2_DISARM_OFFHAND |
|
||||
UNIT_FLAG2_DISABLE_PRED_STATS | UNIT_FLAG2_ALLOW_CHANGING_TALENTS | UNIT_FLAG2_DISARM_RANGED |
|
||||
/* UNIT_FLAG2_REGENERATE_POWER | */ UNIT_FLAG2_RESTRICT_PARTY_INTERACTION |
|
||||
UNIT_FLAG2_PREVENT_SPELL_CLICK | UNIT_FLAG2_INTERACT_WHILE_HOSTILE | /* UNIT_FLAG2_CANNOT_TURN | */
|
||||
/* UNIT_FLAG2_PLAY_DEATH_ANIM | */ UNIT_FLAG2_ALLOW_CHEAT_SPELLS | UNIT_FLAG2_SUPPRESS_HIGHLIGHT_WHEN_TARGETED_OR_MOUSED_OVER |
|
||||
UNIT_FLAG2_TREAT_AS_RAID_UNIT_FOR_HELPFUL_SPELLS | UNIT_FLAG2_LARGE_AOI | UNIT_FLAG2_GIGANTIC_AOI | UNIT_FLAG2_NO_ACTIONS |
|
||||
UNIT_FLAG2_AI_WILL_ONLY_SWIM_IF_TARGET_SWIMS | UNIT_FLAG2_DONT_GENERATE_COMBAT_LOG_WHEN_ENGAGED_WITH_NPCS | UNIT_FLAG2_UNTARGETABLE_BY_CLIENT | UNIT_FLAG2_ATTACKER_IGNORES_MINIMUM_RANGES |
|
||||
UNIT_FLAG2_UNINTERACTIBLE_IF_HOSTILE | UNIT_FLAG2_UNUSED_11 | UNIT_FLAG2_INFINITE_AOI | UNIT_FLAG2_UNUSED_13),
|
||||
|
||||
UNIT_FLAG2_ALLOWED = (0xFFFFFFFF & ~UNIT_FLAG2_DISALLOWED)
|
||||
};
|
||||
|
||||
// Value masks for UNIT_FIELD_FLAGS_3
|
||||
@@ -192,6 +216,9 @@ enum UnitFlags2 : uint32
|
||||
enum UnitFlags3 : uint32
|
||||
{
|
||||
UNIT_FLAG3_UNK1 = 0x00000001,
|
||||
|
||||
UNIT_FLAG3_DISALLOWED = 0xFFFFFFFF,
|
||||
UNIT_FLAG3_ALLOWED = (0xFFFFFFFF & ~UNIT_FLAG3_DISALLOWED)
|
||||
};
|
||||
|
||||
/// Non Player Character flags
|
||||
|
||||
@@ -1126,6 +1126,30 @@ void ObjectMgr::CheckCreatureTemplate(CreatureTemplate const* cInfo)
|
||||
const_cast<CreatureTemplate*>(cInfo)->flags_extra &= CREATURE_FLAG_EXTRA_DB_ALLOWED;
|
||||
}
|
||||
|
||||
if (uint32 disallowedUnitFlags = (cInfo->unit_flags & ~UNIT_FLAG_ALLOWED))
|
||||
{
|
||||
TC_LOG_ERROR("sql.sql", "Table `creature_template` lists creature (Entry: %u) with disallowed `unit_flags` %u, removing incorrect flag.", cInfo->Entry, disallowedUnitFlags);
|
||||
const_cast<CreatureTemplate*>(cInfo)->unit_flags &= UNIT_FLAG_ALLOWED;
|
||||
}
|
||||
|
||||
if (uint32 disallowedUnitFlags2 = (cInfo->unit_flags2 & ~UNIT_FLAG2_ALLOWED))
|
||||
{
|
||||
TC_LOG_ERROR("sql.sql", "Table `creature_template` lists creature (Entry: %u) with disallowed `unit_flags2` %u, removing incorrect flag.", cInfo->Entry, disallowedUnitFlags2);
|
||||
const_cast<CreatureTemplate*>(cInfo)->unit_flags2 &= UNIT_FLAG2_ALLOWED;
|
||||
}
|
||||
|
||||
if (uint32 disallowedUnitFlags3 = (cInfo->unit_flags3 & ~UNIT_FLAG3_ALLOWED))
|
||||
{
|
||||
TC_LOG_ERROR("sql.sql", "Table `creature_template` lists creature (Entry: %u) with disallowed `unit_flags2` %u, removing incorrect flag.", cInfo->Entry, disallowedUnitFlags3);
|
||||
const_cast<CreatureTemplate*>(cInfo)->unit_flags3 &= UNIT_FLAG3_ALLOWED;
|
||||
}
|
||||
|
||||
if (cInfo->dynamicflags)
|
||||
{
|
||||
TC_LOG_ERROR("sql.sql", "Table `creature_template` lists creature (Entry: %u) with `dynamicflags` > 0. Ignored and set to 0.", cInfo->Entry);
|
||||
const_cast<CreatureTemplate*>(cInfo)->dynamicflags = 0;
|
||||
}
|
||||
|
||||
std::pair<int16, int16> levels = cInfo->GetMinMaxLevel();
|
||||
if (levels.first < 1 || levels.first > STRONG_MAX_LEVEL)
|
||||
{
|
||||
@@ -2311,6 +2335,30 @@ void ObjectMgr::LoadCreatures()
|
||||
}
|
||||
}
|
||||
|
||||
if (uint32 disallowedUnitFlags = (data.unit_flags & ~UNIT_FLAG_ALLOWED))
|
||||
{
|
||||
TC_LOG_ERROR("sql.sql", "Table `creature` has creature (GUID: " UI64FMTD " Entry: %u) with disallowed `unit_flags` %u, removing incorrect flag.", guid, data.id, disallowedUnitFlags);
|
||||
data.unit_flags &= UNIT_FLAG_ALLOWED;
|
||||
}
|
||||
|
||||
if (uint32 disallowedUnitFlags2 = (data.unit_flags2 & ~UNIT_FLAG2_ALLOWED))
|
||||
{
|
||||
TC_LOG_ERROR("sql.sql", "Table `creature` has creature (GUID: " UI64FMTD " Entry: %u) with disallowed `unit_flags2` %u, removing incorrect flag.", guid, data.id, disallowedUnitFlags2);
|
||||
data.unit_flags2 &= UNIT_FLAG2_ALLOWED;
|
||||
}
|
||||
|
||||
if (uint32 disallowedUnitFlags3 = (data.unit_flags3 & ~UNIT_FLAG3_ALLOWED))
|
||||
{
|
||||
TC_LOG_ERROR("sql.sql", "Table `creature` has creature (GUID: " UI64FMTD " Entry: %u) with disallowed `unit_flags2` %u, removing incorrect flag.", guid, data.id, disallowedUnitFlags3);
|
||||
data.unit_flags3 &= UNIT_FLAG3_ALLOWED;
|
||||
}
|
||||
|
||||
if (data.dynamicflags)
|
||||
{
|
||||
TC_LOG_ERROR("sql.sql", "Table `creature` has creature (GUID: " UI64FMTD " Entry: %u) with `dynamicflags` > 0. Ignored and set to 0.", guid, data.id);
|
||||
data.dynamicflags = 0;
|
||||
}
|
||||
|
||||
if (sWorld->getBoolConfig(CONFIG_CALCULATE_CREATURE_ZONE_AREA_DATA))
|
||||
{
|
||||
uint32 zoneId = 0;
|
||||
|
||||
Reference in New Issue
Block a user