Skip to content

Commit

Permalink
[11489] Remove the old and custom UNIT_NPC_FLAG_GUARD for creatures.
Browse files Browse the repository at this point in the history
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 <nofantasy@nf.no>
  • Loading branch information
NoFantasy committed May 14, 2011
1 parent b41bf58 commit 487721b
Show file tree
Hide file tree
Showing 10 changed files with 15 additions and 13 deletions.
2 changes: 1 addition & 1 deletion sql/mangos.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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';

--
Expand Down
4 changes: 4 additions & 0 deletions sql/updates/11489_01_mangos_creature_template.sql
Original file line number Diff line number Diff line change
@@ -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;

This comment has been minimized.

Copy link
@Shauren

Shauren May 14, 2011

Contributor

mysql is weird, this shouldnt work as it does

WHERE (npcflag & 0x10000000) != 0

is way more readable (obvious)

This comment has been minimized.

Copy link
@VladimirMangos

VladimirMangos May 15, 2011

(npcflag=npcflag|0x10000000) exactly same as ((npcflag & 0x10000000) != 0)
Not related only mysql but by way how | & work

UPDATE creature_template SET npcflag=npcflag &~ 0x10000000;
3 changes: 3 additions & 0 deletions src/game/Creature.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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; }
Expand Down
2 changes: 1 addition & 1 deletion src/game/CreatureAISelector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/game/CreatureEventAI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down
2 changes: 1 addition & 1 deletion src/game/GuardAI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

int GuardAI::Permissible(const Creature *creature)
{
if( creature->isGuard())
if (creature->IsGuard())
return PERMIT_BASE_SPECIAL;

return PERMIT_BASE_NO;
Expand Down
3 changes: 1 addition & 2 deletions src/game/Object.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
6 changes: 1 addition & 5 deletions src/game/Unit.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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); }
Expand Down
2 changes: 1 addition & 1 deletion src/shared/revision_nr.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__
#define __REVISION_NR_H__
#define REVISION_NR "11488"
#define REVISION_NR "11489"
#endif // __REVISION_NR_H__
2 changes: 1 addition & 1 deletion src/shared/revision_sql.h
Original file line number Diff line number Diff line change
@@ -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__

0 comments on commit 487721b

Please sign in to comment.