From ecdb435b1e09520118ef87763c3b237992b523f8 Mon Sep 17 00:00:00 2001 From: NoFantasy Date: Sat, 14 May 2011 19:16:39 +0200 Subject: [PATCH] [11489] Remove the old and custom UNIT_NPC_FLAG_GUARD for creatures. Existing data moved to flags_extra field, with value CREATURE_FLAG_EXTRA_GUARD (0x400 / 1024). Remove isGuard() from Unit class to a new IsGuard() function in Creature class. Signed-off-by: NoFantasy --- sql/mangos.sql | 2 +- sql/updates/11489_01_mangos_creature_template.sql | 4 ++++ src/game/Creature.h | 3 +++ src/game/CreatureAISelector.cpp | 2 +- src/game/CreatureEventAI.cpp | 2 +- src/game/GuardAI.cpp | 2 +- src/game/Object.cpp | 3 +-- src/game/Unit.h | 6 +----- src/shared/revision_nr.h | 2 +- src/shared/revision_sql.h | 2 +- 10 files changed, 15 insertions(+), 13 deletions(-) create mode 100644 sql/updates/11489_01_mangos_creature_template.sql diff --git a/sql/mangos.sql b/sql/mangos.sql index 130069b9a..8e27d9d60 100644 --- a/sql/mangos.sql +++ b/sql/mangos.sql @@ -24,7 +24,7 @@ CREATE TABLE `db_version` ( `version` varchar(120) default NULL, `creature_ai_version` varchar(120) default NULL, `cache_id` int(10) default '0', - `required_11453_01_mangos_spell_proc_event` bit(1) default NULL + `required_11489_01_mangos_creature_template` bit(1) default NULL ) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Used DB version notes'; -- diff --git a/sql/updates/11489_01_mangos_creature_template.sql b/sql/updates/11489_01_mangos_creature_template.sql new file mode 100644 index 000000000..89439a07c --- /dev/null +++ b/sql/updates/11489_01_mangos_creature_template.sql @@ -0,0 +1,4 @@ +ALTER TABLE db_version CHANGE COLUMN required_11453_01_mangos_spell_proc_event required_11489_01_mangos_creature_template bit; + +UPDATE creature_template SET flags_extra=flags_extra|0x00000400 WHERE npcflag=npcflag|0x10000000; +UPDATE creature_template SET npcflag=npcflag &~ 0x10000000; diff --git a/src/game/Creature.h b/src/game/Creature.h index 4a6452410..678021f48 100644 --- a/src/game/Creature.h +++ b/src/game/Creature.h @@ -53,6 +53,7 @@ enum CreatureFlagsExtra CREATURE_FLAG_EXTRA_INVISIBLE = 0x00000080, // creature is always invisible for player (mostly trigger creatures) CREATURE_FLAG_EXTRA_NOT_TAUNTABLE = 0x00000100, // creature is immune to taunt auras and effect attack me CREATURE_FLAG_EXTRA_AGGRO_ZONE = 0x00000200, // creature sets itself in combat with zone on aggro + CREATURE_FLAG_EXTRA_GUARD = 0x00000400, // creature is a guard }; // GCC have alternative #pragma pack(N) syntax and old gcc version not support pack(push,N), also any gcc version not support it at some platform @@ -472,6 +473,8 @@ class MANGOS_DLL_SPEC Creature : public Unit void SetCorpseDelay(uint32 delay) { m_corpseDelay = delay; } bool IsRacialLeader() const { return GetCreatureInfo()->RacialLeader; } bool IsCivilian() const { return GetCreatureInfo()->flags_extra & CREATURE_FLAG_EXTRA_CIVILIAN; } + bool IsGuard() const { return GetCreatureInfo()->flags_extra & CREATURE_FLAG_EXTRA_GUARD; } + bool CanWalk() const { return GetCreatureInfo()->InhabitType & INHABIT_GROUND; } bool CanSwim() const { return GetCreatureInfo()->InhabitType & INHABIT_WATER; } bool CanFly() const { return GetCreatureInfo()->InhabitType & INHABIT_AIR; } diff --git a/src/game/CreatureAISelector.cpp b/src/game/CreatureAISelector.cpp index 783c97169..36d3e79bd 100644 --- a/src/game/CreatureAISelector.cpp +++ b/src/game/CreatureAISelector.cpp @@ -56,7 +56,7 @@ namespace FactorySelector if (!ai_factory && !ainame.empty()) ai_factory = ai_registry.GetRegistryItem( ainame.c_str() ); - if (!ai_factory && creature->isGuard() ) + if (!ai_factory && creature->IsGuard()) ai_factory = ai_registry.GetRegistryItem("GuardAI"); // select by permit check diff --git a/src/game/CreatureEventAI.cpp b/src/game/CreatureEventAI.cpp index 681399569..01659d1cb 100644 --- a/src/game/CreatureEventAI.cpp +++ b/src/game/CreatureEventAI.cpp @@ -931,7 +931,7 @@ void CreatureEventAI::JustDied(Unit* killer) { Reset(); - if (m_creature->isGuard()) + if (m_creature->IsGuard()) { //Send Zone Under Attack message to the LocalDefense and WorldDefense Channels if (Player* pKiller = killer->GetCharmerOrOwnerPlayerOrPlayerItself()) diff --git a/src/game/GuardAI.cpp b/src/game/GuardAI.cpp index 486cc3c58..d65cea482 100644 --- a/src/game/GuardAI.cpp +++ b/src/game/GuardAI.cpp @@ -24,7 +24,7 @@ int GuardAI::Permissible(const Creature *creature) { - if( creature->isGuard()) + if (creature->IsGuard()) return PERMIT_BASE_SPECIAL; return PERMIT_BASE_NO; diff --git a/src/game/Object.cpp b/src/game/Object.cpp index d3d96f998..87dac65ad 100644 --- a/src/game/Object.cpp +++ b/src/game/Object.cpp @@ -575,8 +575,7 @@ void Object::BuildValuesUpdate(uint8 updatetype, ByteBuffer * data, UpdateMask * { if (index == UNIT_NPC_FLAGS) { - // remove custom flag before sending - uint32 appendValue = m_uint32Values[index] & ~UNIT_NPC_FLAG_GUARD; + uint32 appendValue = m_uint32Values[index]; if (GetTypeId() == TYPEID_UNIT) { diff --git a/src/game/Unit.h b/src/game/Unit.h index d7214c54e..d595436e8 100644 --- a/src/game/Unit.h +++ b/src/game/Unit.h @@ -586,7 +586,6 @@ enum NPCFlags UNIT_NPC_FLAG_STABLEMASTER = 0x00400000, // 100% UNIT_NPC_FLAG_GUILD_BANKER = 0x00800000, // cause client to send 997 opcode UNIT_NPC_FLAG_SPELLCLICK = 0x01000000, // cause client to send 1015 opcode (spell click), dynamic, set at loading and don't must be set in DB - UNIT_NPC_FLAG_GUARD = 0x10000000 // custom flag for guards }; // used in most movement packets (send and received) @@ -1387,14 +1386,11 @@ class MANGOS_DLL_SPEC Unit : public WorldObject return HasFlag( UNIT_NPC_FLAGS, UNIT_NPC_FLAG_VENDOR | UNIT_NPC_FLAG_TRAINER | UNIT_NPC_FLAG_FLIGHTMASTER | UNIT_NPC_FLAG_PETITIONER | UNIT_NPC_FLAG_BATTLEMASTER | UNIT_NPC_FLAG_BANKER | - UNIT_NPC_FLAG_INNKEEPER | UNIT_NPC_FLAG_GUARD | UNIT_NPC_FLAG_SPIRITHEALER | + UNIT_NPC_FLAG_INNKEEPER | UNIT_NPC_FLAG_SPIRITHEALER | UNIT_NPC_FLAG_SPIRITGUIDE | UNIT_NPC_FLAG_TABARDDESIGNER | UNIT_NPC_FLAG_AUCTIONEER ); } bool isSpiritService() const { return HasFlag( UNIT_NPC_FLAGS, UNIT_NPC_FLAG_SPIRITHEALER | UNIT_NPC_FLAG_SPIRITGUIDE ); } - //Need fix or use this - bool isGuard() const { return HasFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GUARD); } - bool IsTaxiFlying() const { return hasUnitState(UNIT_STAT_TAXI_FLIGHT); } bool isInCombat() const { return HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IN_COMBAT); } diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index afad6b882..55dee2ef1 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "11488" + #define REVISION_NR "11489" #endif // __REVISION_NR_H__ diff --git a/src/shared/revision_sql.h b/src/shared/revision_sql.h index 8db317251..d8694ced9 100644 --- a/src/shared/revision_sql.h +++ b/src/shared/revision_sql.h @@ -1,6 +1,6 @@ #ifndef __REVISION_SQL_H__ #define __REVISION_SQL_H__ #define REVISION_DB_CHARACTERS "required_11436_01_characters_character_queststatus" - #define REVISION_DB_MANGOS "required_11453_01_mangos_spell_proc_event" + #define REVISION_DB_MANGOS "required_11489_01_mangos_creature_template" #define REVISION_DB_REALMD "required_10008_01_realmd_realmd_db_version" #endif // __REVISION_SQL_H__