From 4dd743b189884f510f4a881a7306a226cb46eaf6 Mon Sep 17 00:00:00 2001 From: VladimirMangos Date: Sun, 8 May 2011 01:38:28 +0400 Subject: [PATCH 01/43] [11435] Fixed IsPositiveEffect triggered spell case and some cleanups Mostly found in time 400 update. --- sql/updates/10762_01_mangos_spell_proc_event.sql | 4 ---- sql/updates/10946_01_mangos_spell_proc_event.sql | 1 - sql/updates/10972_01_mangos_command.sql | 1 - sql/updates/11018_01_mangos_command.sql | 1 - sql/updates/11115_01_mangos_command.sql | 1 - .../11190_01_mangos_pool_creature_template.sql | 2 -- .../11190_01_mangos_pool_gameobject_template.sql | 2 -- sql/updates/11214_02_mangos_command.sql | 1 - sql/updates/11234_01_mangos_command.sql | 1 - src/game/SpellAuras.cpp | 6 +----- src/game/SpellMgr.cpp | 2 +- src/game/Unit.cpp | 15 ++++++++++----- src/game/World.cpp | 3 ++- src/shared/revision_nr.h | 2 +- 14 files changed, 15 insertions(+), 27 deletions(-) diff --git a/sql/updates/10762_01_mangos_spell_proc_event.sql b/sql/updates/10762_01_mangos_spell_proc_event.sql index 9ffd0b67c55..0f681c82525 100644 --- a/sql/updates/10762_01_mangos_spell_proc_event.sql +++ b/sql/updates/10762_01_mangos_spell_proc_event.sql @@ -3,7 +3,3 @@ ALTER TABLE db_version CHANGE COLUMN required_10749_01_mangos_mangos_string requ DELETE FROM `spell_proc_event` WHERE `entry` IN (52437); INSERT INTO spell_proc_event VALUES (52437, 0x00, 4, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000010, 0x00000000, 0.000000, 0.000000, 0); - - - - diff --git a/sql/updates/10946_01_mangos_spell_proc_event.sql b/sql/updates/10946_01_mangos_spell_proc_event.sql index 3bfb6542691..5b286413b3f 100644 --- a/sql/updates/10946_01_mangos_spell_proc_event.sql +++ b/sql/updates/10946_01_mangos_spell_proc_event.sql @@ -2,4 +2,3 @@ ALTER TABLE db_version CHANGE COLUMN required_10945_01_mangos_mangos_string requ DELETE FROM spell_proc_event WHERE entry IN (16257, 16277, 16278, 16279, 16280); DELETE FROM spell_proc_event WHERE entry IN (12966, 12967, 12968, 12969, 12970); - diff --git a/sql/updates/10972_01_mangos_command.sql b/sql/updates/10972_01_mangos_command.sql index 64b6362f85b..49ad159bff3 100644 --- a/sql/updates/10972_01_mangos_command.sql +++ b/sql/updates/10972_01_mangos_command.sql @@ -6,4 +6,3 @@ INSERT INTO command (name, security, help) VALUES ('send mass items',3,'Syntax: .send mass items #racemask|$racename|alliance|horde|all "#subject" "#text" itemid1[:count1] itemid2[:count2] ... itemidN[:countN]\r\n\r\nSend a mail to players. Subject and mail text must be in "". If for itemid not provided related count values then expected 1, if count > max items in stack then items will be send in required amount stacks. All stacks amount in mail limited to 12.'), ('send mass mail',1,'Syntax: .send mass mail #racemask|$racename|alliance|horde|all "#subject" "#text"\r\n\r\nSend a mail to players. Subject and mail text must be in "".'), ('send mass money','3','Syntax: .send mass money #racemask|$racename|alliance|horde|all "#subject" "#text" #money\r\n\r\nSend mail with money to players. Subject and mail text must be in "".'); - diff --git a/sql/updates/11018_01_mangos_command.sql b/sql/updates/11018_01_mangos_command.sql index e93462b82e2..ad20c94d10f 100644 --- a/sql/updates/11018_01_mangos_command.sql +++ b/sql/updates/11018_01_mangos_command.sql @@ -4,4 +4,3 @@ DELETE FROM command WHERE name IN ('send mass mail'); INSERT INTO command (name, security, help) VALUES ('send mass mail',3,'Syntax: .send mass mail #racemask|$racename|alliance|horde|all "#subject" "#text"\r\n\r\nSend a mail to players. Subject and mail text must be in "".'); - diff --git a/sql/updates/11115_01_mangos_command.sql b/sql/updates/11115_01_mangos_command.sql index 89ca6aac01b..44520836077 100644 --- a/sql/updates/11115_01_mangos_command.sql +++ b/sql/updates/11115_01_mangos_command.sql @@ -4,4 +4,3 @@ DELETE FROM command WHERE name = 'gm setview'; INSERT INTO command (name, security, help) VALUES ('gm setview',1,'Syntax: .gm setview\r\n\r\nSet farsight view on selected unit. Select yourself to set view back.'); - diff --git a/sql/updates/11190_01_mangos_pool_creature_template.sql b/sql/updates/11190_01_mangos_pool_creature_template.sql index 6a0740da21c..39ed648ea73 100644 --- a/sql/updates/11190_01_mangos_pool_creature_template.sql +++ b/sql/updates/11190_01_mangos_pool_creature_template.sql @@ -9,5 +9,3 @@ CREATE TABLE `pool_creature_template` ( PRIMARY KEY (`id`), INDEX `pool_idx` (pool_entry) ) ENGINE=MyISAM DEFAULT CHARSET=utf8; - - diff --git a/sql/updates/11190_01_mangos_pool_gameobject_template.sql b/sql/updates/11190_01_mangos_pool_gameobject_template.sql index e305d90a95a..a247d9d7977 100644 --- a/sql/updates/11190_01_mangos_pool_gameobject_template.sql +++ b/sql/updates/11190_01_mangos_pool_gameobject_template.sql @@ -9,5 +9,3 @@ CREATE TABLE `pool_gameobject_template` ( PRIMARY KEY (`id`), INDEX `pool_idx` (pool_entry) ) ENGINE=MyISAM DEFAULT CHARSET=utf8; - - diff --git a/sql/updates/11214_02_mangos_command.sql b/sql/updates/11214_02_mangos_command.sql index 68d0a13f3a9..8fb7068df24 100644 --- a/sql/updates/11214_02_mangos_command.sql +++ b/sql/updates/11214_02_mangos_command.sql @@ -4,4 +4,3 @@ DELETE FROM command WHERE name = 'debug spellcoefs'; INSERT INTO command (name, security, help) VALUES ('debug spellcoefs',3,'Syntax: .debug spellcoefs #pellid\r\n\r\nShow default calculated and DB stored coefficients for direct/dot heal/damage.'); - diff --git a/sql/updates/11234_01_mangos_command.sql b/sql/updates/11234_01_mangos_command.sql index 2075168415d..a15d7a2a992 100644 --- a/sql/updates/11234_01_mangos_command.sql +++ b/sql/updates/11234_01_mangos_command.sql @@ -4,4 +4,3 @@ DELETE FROM command WHERE name = 'debug spellcoefs'; INSERT INTO command (name, security, help) VALUES ('debug spellcoefs',3,'Syntax: .debug spellcoefs #spellid\r\n\r\nShow default calculated and DB stored coefficients for direct/dot heal/damage.'); - diff --git a/src/game/SpellAuras.cpp b/src/game/SpellAuras.cpp index ea6307879bb..97ee5b74bd7 100644 --- a/src/game/SpellAuras.cpp +++ b/src/game/SpellAuras.cpp @@ -2185,12 +2185,7 @@ void Aura::HandleAuraDummy(bool apply, bool Real) break; } case SPELLFAMILY_MAGE: - { - // Fingers of Frost stacks set to max at apply - if (GetId() == 74396) - GetHolder()->SetAuraCharges(GetSpellProto()->StackAmount); break; - } case SPELLFAMILY_HUNTER: { switch(GetId()) @@ -8257,6 +8252,7 @@ m_permanent(false), m_isRemovedOnShapeLost(true), m_deleted(false), m_in_use(0) case 55166: // Tidal Force case 58914: // Kill Command (pet part) case 71564: // Deadly Precision + case 74396: // Fingers of Frost m_stackAmount = m_spellProto->StackAmount; break; } diff --git a/src/game/SpellMgr.cpp b/src/game/SpellMgr.cpp index a3229ec0d7b..e544da7e639 100644 --- a/src/game/SpellMgr.cpp +++ b/src/game/SpellMgr.cpp @@ -740,7 +740,7 @@ bool IsPositiveEffect(SpellEntry const *spellproto, SpellEffectIndex effIndex) { // if non-positive trigger cast targeted to positive target this main cast is non-positive // this will place this spell auras as debuffs - if (IsPositiveTarget(spellTriggeredProto->EffectImplicitTargetA[effIndex], spellTriggeredProto->EffectImplicitTargetB[effIndex]) && + if (IsPositiveTarget(spellTriggeredProto->EffectImplicitTargetA[i], spellTriggeredProto->EffectImplicitTargetB[i]) && !IsPositiveEffect(spellTriggeredProto, SpellEffectIndex(i))) return false; } diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp index 95478dd3fbc..7feec356b9d 100644 --- a/src/game/Unit.cpp +++ b/src/game/Unit.cpp @@ -7174,11 +7174,16 @@ bool Unit::IsImmuneToSpellEffect(SpellEntry const* spellInfo, SpellEffectIndex i // Check for immune to application of harmful magical effects AuraList const& immuneAuraApply = GetAurasByType(SPELL_AURA_MOD_IMMUNE_AURA_APPLY_SCHOOL); - for(AuraList::const_iterator iter = immuneAuraApply.begin(); iter != immuneAuraApply.end(); ++iter) - if (spellInfo->Dispel == DISPEL_MAGIC && // Magic debuff - ((*iter)->GetModifier()->m_miscvalue & GetSpellSchoolMask(spellInfo)) && // Check school - !IsPositiveEffect(spellInfo, index)) // Harmful - return true; + if (!immuneAuraApply.empty() && + spellInfo->Dispel == DISPEL_MAGIC && // Magic debuff) + !IsPositiveEffect(spellInfo, index)) // Harmful + { + // Check school + SpellSchoolMask schoolMask = GetSpellSchoolMask(spellInfo); + for(AuraList::const_iterator iter = immuneAuraApply.begin(); iter != immuneAuraApply.end(); ++iter) + if ((*iter)->GetModifier()->m_miscvalue & schoolMask) + return true; + } } return false; diff --git a/src/game/World.cpp b/src/game/World.cpp index 53d87169a96..785c2607fc6 100644 --- a/src/game/World.cpp +++ b/src/game/World.cpp @@ -1373,7 +1373,8 @@ void World::DetectDBCLang() m_lang_confid = LOCALE_enUS; } - ChrRacesEntry const* race = sChrRacesStore.LookupEntry(1); + ChrRacesEntry const* race = sChrRacesStore.LookupEntry(RACE_HUMAN); + MANGOS_ASSERT(race); std::string availableLocalsStr; diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index 3a1f77807d6..55adf2ebc0c 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 "11434" + #define REVISION_NR "11435" #endif // __REVISION_NR_H__ From 0c749ed6351522f6c1d1ab5dbdc946fc6bbd1d3d Mon Sep 17 00:00:00 2001 From: BThallid Date: Sun, 8 May 2011 01:54:38 +0400 Subject: [PATCH 02/43] [11436] Really save/load item 5/6 objectives counters in quest status. Signed-off-by: VladimirMangos --- sql/characters.sql | 4 +++- ...11436_01_characters_character_queststatus.sql | 6 ++++++ src/game/CharacterHandler.cpp | 2 +- src/game/Player.cpp | 16 +++++++++------- src/shared/revision_nr.h | 2 +- src/shared/revision_sql.h | 2 +- 6 files changed, 21 insertions(+), 11 deletions(-) create mode 100644 sql/updates/11436_01_characters_character_queststatus.sql diff --git a/sql/characters.sql b/sql/characters.sql index d559b95da14..df077652b74 100644 --- a/sql/characters.sql +++ b/sql/characters.sql @@ -21,7 +21,7 @@ DROP TABLE IF EXISTS `character_db_version`; CREATE TABLE `character_db_version` ( - `required_11391_01_characters_auction` bit(1) default NULL + `required_11436_01_characters_character_queststatus` bit(1) default NULL ) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Last applied sql update to DB'; -- @@ -692,6 +692,8 @@ CREATE TABLE `character_queststatus` ( `itemcount2` int(11) unsigned NOT NULL default '0', `itemcount3` int(11) unsigned NOT NULL default '0', `itemcount4` int(11) unsigned NOT NULL default '0', + `itemcount5` int(11) unsigned NOT NULL default '0', + `itemcount6` int(11) unsigned NOT NULL default '0', PRIMARY KEY (`guid`,`quest`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC COMMENT='Player System'; diff --git a/sql/updates/11436_01_characters_character_queststatus.sql b/sql/updates/11436_01_characters_character_queststatus.sql new file mode 100644 index 00000000000..2c07f03f384 --- /dev/null +++ b/sql/updates/11436_01_characters_character_queststatus.sql @@ -0,0 +1,6 @@ +ALTER TABLE character_db_version CHANGE COLUMN required_11391_01_characters_auction required_11436_01_characters_character_queststatus bit; + +ALTER TABLE character_queststatus + ADD COLUMN itemcount5 int(11) unsigned NOT NULL default '0' AFTER itemcount4, + ADD COLUMN itemcount6 int(11) unsigned NOT NULL default '0' AFTER itemcount5; + diff --git a/src/game/CharacterHandler.cpp b/src/game/CharacterHandler.cpp index 7875da3cb07..37a03a67141 100644 --- a/src/game/CharacterHandler.cpp +++ b/src/game/CharacterHandler.cpp @@ -77,7 +77,7 @@ bool LoginQueryHolder::Initialize() res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADBOUNDINSTANCES, "SELECT id, permanent, map, difficulty, resettime FROM character_instance LEFT JOIN instance ON instance = id WHERE guid = '%u'", m_guid.GetCounter()); res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADAURAS, "SELECT caster_guid,item_guid,spell,stackcount,remaincharges,basepoints0,basepoints1,basepoints2,periodictime0,periodictime1,periodictime2,maxduration,remaintime,effIndexMask FROM character_aura WHERE guid = '%u'", m_guid.GetCounter()); res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADSPELLS, "SELECT spell,active,disabled FROM character_spell WHERE guid = '%u'", m_guid.GetCounter()); - res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADQUESTSTATUS, "SELECT quest,status,rewarded,explored,timer,mobcount1,mobcount2,mobcount3,mobcount4,itemcount1,itemcount2,itemcount3,itemcount4 FROM character_queststatus WHERE guid = '%u'", m_guid.GetCounter()); + res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADQUESTSTATUS, "SELECT quest,status,rewarded,explored,timer,mobcount1,mobcount2,mobcount3,mobcount4,itemcount1,itemcount2,itemcount3,itemcount4,itemcount5,itemcount6 FROM character_queststatus WHERE guid = '%u'", m_guid.GetCounter()); res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADDAILYQUESTSTATUS,"SELECT quest FROM character_queststatus_daily WHERE guid = '%u'", m_guid.GetCounter()); res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADWEEKLYQUESTSTATUS,"SELECT quest FROM character_queststatus_weekly WHERE guid = '%u'", m_guid.GetCounter()); res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADMONTHLYQUESTSTATUS,"SELECT quest FROM character_queststatus_monthly WHERE guid = '%u'", m_guid.GetCounter()); diff --git a/src/game/Player.cpp b/src/game/Player.cpp index ebf0243e077..6fec6aa40af 100644 --- a/src/game/Player.cpp +++ b/src/game/Player.cpp @@ -16393,8 +16393,8 @@ void Player::_LoadQuestStatus(QueryResult *result) uint32 slot = 0; - //// 0 1 2 3 4 5 6 7 8 9 10 11 12 - //QueryResult *result = CharacterDatabase.PQuery("SELECT quest, status, rewarded, explored, timer, mobcount1, mobcount2, mobcount3, mobcount4, itemcount1, itemcount2, itemcount3, itemcount4 FROM character_queststatus WHERE guid = '%u'", GetGUIDLow()); + //// 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 + //QueryResult *result = CharacterDatabase.PQuery("SELECT quest, status, rewarded, explored, timer, mobcount1, mobcount2, mobcount3, mobcount4, itemcount1, itemcount2, itemcount3, itemcount4, itemcount5, itemcount6 FROM character_queststatus WHERE guid = '%u'", GetGUIDLow()); if(result) { @@ -16444,6 +16444,8 @@ void Player::_LoadQuestStatus(QueryResult *result) questStatusData.m_itemcount[1] = fields[10].GetUInt32(); questStatusData.m_itemcount[2] = fields[11].GetUInt32(); questStatusData.m_itemcount[3] = fields[12].GetUInt32(); + questStatusData.m_itemcount[4] = fields[13].GetUInt32(); + questStatusData.m_itemcount[5] = fields[14].GetUInt32(); questStatusData.uState = QUEST_UNCHANGED; @@ -17640,8 +17642,8 @@ void Player::_SaveQuestStatus() { case QUEST_NEW : { - SqlStatement stmt = CharacterDatabase.CreateStatement(insertQuestStatus, "INSERT INTO character_queststatus (guid,quest,status,rewarded,explored,timer,mobcount1,mobcount2,mobcount3,mobcount4,itemcount1,itemcount2,itemcount3,itemcount4) " - "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"); + SqlStatement stmt = CharacterDatabase.CreateStatement(insertQuestStatus, "INSERT INTO character_queststatus (guid,quest,status,rewarded,explored,timer,mobcount1,mobcount2,mobcount3,mobcount4,itemcount1,itemcount2,itemcount3,itemcount4,itemcount5,itemcount6) " + "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"); stmt.addUInt32(GetGUIDLow()); stmt.addUInt32(i->first); @@ -17651,7 +17653,7 @@ void Player::_SaveQuestStatus() stmt.addUInt64(uint64(i->second.m_timer / IN_MILLISECONDS+ sWorld.GetGameTime())); for (int k = 0; k < QUEST_OBJECTIVES_COUNT; ++k) stmt.addUInt32(i->second.m_creatureOrGOcount[k]); - for (int k = 0; k < QUEST_OBJECTIVES_COUNT; ++k) + for (int k = 0; k < QUEST_ITEM_OBJECTIVES_COUNT; ++k) stmt.addUInt32(i->second.m_itemcount[k]); stmt.Execute(); } @@ -17659,7 +17661,7 @@ void Player::_SaveQuestStatus() case QUEST_CHANGED : { SqlStatement stmt = CharacterDatabase.CreateStatement(updateQuestStatus, "UPDATE character_queststatus SET status = ?,rewarded = ?,explored = ?,timer = ?," - "mobcount1 = ?,mobcount2 = ?,mobcount3 = ?,mobcount4 = ?,itemcount1 = ?,itemcount2 = ?,itemcount3 = ?,itemcount4 = ? WHERE guid = ? AND quest = ?"); + "mobcount1 = ?,mobcount2 = ?,mobcount3 = ?,mobcount4 = ?,itemcount1 = ?,itemcount2 = ?,itemcount3 = ?,itemcount4 = ?,itemcount5 = ?,itemcount6 = ? WHERE guid = ? AND quest = ?"); stmt.addUInt8(i->second.m_status); stmt.addUInt8(i->second.m_rewarded); @@ -17667,7 +17669,7 @@ void Player::_SaveQuestStatus() stmt.addUInt64(uint64(i->second.m_timer / IN_MILLISECONDS + sWorld.GetGameTime())); for (int k = 0; k < QUEST_OBJECTIVES_COUNT; ++k) stmt.addUInt32(i->second.m_creatureOrGOcount[k]); - for (int k = 0; k < QUEST_OBJECTIVES_COUNT; ++k) + for (int k = 0; k < QUEST_ITEM_OBJECTIVES_COUNT; ++k) stmt.addUInt32(i->second.m_itemcount[k]); stmt.addUInt32(GetGUIDLow()); stmt.addUInt32(i->first); diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index 55adf2ebc0c..ccf80c1f045 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 "11435" + #define REVISION_NR "11436" #endif // __REVISION_NR_H__ diff --git a/src/shared/revision_sql.h b/src/shared/revision_sql.h index 91cda332d8e..6c3a4bfc333 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_11391_01_characters_auction" + #define REVISION_DB_CHARACTERS "required_11436_01_characters_character_queststatus" #define REVISION_DB_MANGOS "required_11433_01_mangos_item_template" #define REVISION_DB_REALMD "required_10008_01_realmd_realmd_db_version" #endif // __REVISION_SQL_H__ From a999823b2254b6056f58335affd2dd905ed97ce6 Mon Sep 17 00:00:00 2001 From: VladimirMangos Date: Sun, 8 May 2011 03:45:20 +0400 Subject: [PATCH 03/43] [11437] Fixed cases where forgotten that bags have TYPEID_CONTAINER != TYPEID_ITEM Script case low chance affect real cases but for mail send from item can fix some problems. --- src/game/Mail.cpp | 1 + src/game/Map.cpp | 4 ++-- src/shared/revision_nr.h | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/game/Mail.cpp b/src/game/Mail.cpp index c8c0b39de0c..d50e29275c1 100644 --- a/src/game/Mail.cpp +++ b/src/game/Mail.cpp @@ -816,6 +816,7 @@ MailSender::MailSender( Object* sender, MailStationery stationery ) : m_statione m_senderId = sender->GetEntry(); break; case TYPEID_ITEM: + case TYPEID_CONTAINER: m_messageType = MAIL_ITEM; m_senderId = sender->GetEntry(); break; diff --git a/src/game/Map.cpp b/src/game/Map.cpp index 5d51acd8c3d..d35f230556b 100644 --- a/src/game/Map.cpp +++ b/src/game/Map.cpp @@ -1611,7 +1611,7 @@ void Map::ScriptsStart(ScriptMapMap const& scripts, uint32 id, Object* source, O // prepare static data ObjectGuid sourceGuid = source->GetObjectGuid(); ObjectGuid targetGuid = target ? target->GetObjectGuid() : ObjectGuid(); - ObjectGuid ownerGuid = (source->GetTypeId()==TYPEID_ITEM) ? ((Item*)source)->GetOwnerGuid() : ObjectGuid(); + ObjectGuid ownerGuid = source->isType(TYPEMASK_ITEM) ? ((Item*)source)->GetOwnerGuid() : ObjectGuid(); ///- Schedule script execution for all scripts in the script map ScriptMap const *s2 = &(s->second); @@ -1642,7 +1642,7 @@ void Map::ScriptCommandStart(ScriptInfo const& script, uint32 delay, Object* sou // prepare static data ObjectGuid sourceGuid = source->GetObjectGuid(); ObjectGuid targetGuid = target ? target->GetObjectGuid() : ObjectGuid(); - ObjectGuid ownerGuid = (source->GetTypeId()==TYPEID_ITEM) ? ((Item*)source)->GetOwnerGuid() : ObjectGuid(); + ObjectGuid ownerGuid = source->isType(TYPEMASK_ITEM) ? ((Item*)source)->GetOwnerGuid() : ObjectGuid(); ScriptAction sa; sa.sourceGuid = sourceGuid; diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index ccf80c1f045..638392b2c87 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 "11436" + #define REVISION_NR "11437" #endif // __REVISION_NR_H__ From f63c8e2d2401d8cad28ecd14f4aa38eb28e76df4 Mon Sep 17 00:00:00 2001 From: VladimirMangos Date: Sun, 8 May 2011 05:45:59 +0400 Subject: [PATCH 04/43] [11438] Clarify code for quest start/source/req items adding/remove at quest start. * Fix problem with complete quest when quest start item == quest source item. And source item not have max items amount setting. * Avoid remove start item for case when it will re-added at next code line as source item --- src/game/Player.cpp | 47 ++++++++++++++++++++++++++++----------- src/game/Player.h | 4 ++-- src/game/QuestHandler.cpp | 17 -------------- src/shared/revision_nr.h | 2 +- 4 files changed, 37 insertions(+), 33 deletions(-) diff --git a/src/game/Player.cpp b/src/game/Player.cpp index 6fec6aa40af..b3b4ff7a5e1 100644 --- a/src/game/Player.cpp +++ b/src/game/Player.cpp @@ -13512,7 +13512,7 @@ bool Player::CanAddQuest(Quest const *pQuest, bool msg) const if (!SatisfyQuestLog(msg)) return false; - if (!CanGiveQuestSourceItem(pQuest)) + if (!CanGiveQuestSourceItemIfNeed(pQuest)) return false; return true; @@ -13726,7 +13726,28 @@ void Player::AddQuest( Quest const *pQuest, Object *questGiver ) questStatusData.m_creatureOrGOcount[i] = 0; } - GiveQuestSourceItem(pQuest); + // remove start item if not need + if (questGiver && questGiver->isType(TYPEID_ITEM)) + { + // destroy not required for quest finish quest starting item + bool notRequiredItem = true; + for(int i = 0; i < QUEST_ITEM_OBJECTIVES_COUNT; ++i) + { + if (pQuest->ReqItemId[i] == questGiver->GetEntry()) + { + notRequiredItem = false; + break; + } + } + + if (pQuest->GetSrcItemId() == questGiver->GetEntry()) + notRequiredItem = false; + + if (notRequiredItem) + DestroyItem(((Item*)questGiver)->GetBagSlot(), ((Item*)questGiver)->GetSlot(), true); + } + + GiveQuestSourceItemIfNeed(pQuest); AdjustQuestReqItemCount( pQuest, questStatusData ); @@ -14374,14 +14395,18 @@ bool Player::SatisfyQuestMonth(Quest const* qInfo, bool msg) const return m_monthlyquests.find(qInfo->GetQuestId()) == m_monthlyquests.end(); } -bool Player::CanGiveQuestSourceItem( Quest const *pQuest, ItemPosCountVec* dest ) const +bool Player::CanGiveQuestSourceItemIfNeed( Quest const *pQuest, ItemPosCountVec* dest) const { - uint32 srcitem = pQuest->GetSrcItemId(); - if (srcitem > 0) + if (uint32 srcitem = pQuest->GetSrcItemId()) { uint32 count = pQuest->GetSrcItemCount(); - if( count <= 0 ) - count = 1; + + // player already have max amount required item (including bank), just report success + uint32 has_count = GetItemCount(srcitem, true); + if (has_count >= count) + return true; + + count -= has_count; // real need amount InventoryResult msg; if (!dest) @@ -14394,9 +14419,6 @@ bool Player::CanGiveQuestSourceItem( Quest const *pQuest, ItemPosCountVec* dest if (msg == EQUIP_ERR_OK) return true; - // player already have max amount required item, just report success - else if (msg == EQUIP_ERR_CANT_CARRY_MORE_OF_THIS) - return true; else SendEquipError( msg, NULL, NULL, srcitem ); return false; @@ -14405,11 +14427,10 @@ bool Player::CanGiveQuestSourceItem( Quest const *pQuest, ItemPosCountVec* dest return true; } -void Player::GiveQuestSourceItem( Quest const *pQuest ) +void Player::GiveQuestSourceItemIfNeed(Quest const *pQuest) { ItemPosCountVec dest; - - if (CanGiveQuestSourceItem(pQuest, &dest) && !dest.empty()) + if (CanGiveQuestSourceItemIfNeed(pQuest, &dest) && !dest.empty()) { uint32 count = 0; for(ItemPosCountVec::const_iterator c_itr = dest.begin(); c_itr != dest.end(); ++c_itr) diff --git a/src/game/Player.h b/src/game/Player.h index 817bfc53a4e..720d5cc94b8 100644 --- a/src/game/Player.h +++ b/src/game/Player.h @@ -1370,8 +1370,8 @@ class MANGOS_DLL_SPEC Player : public Unit bool SatisfyQuestDay( Quest const* qInfo, bool msg ) const; bool SatisfyQuestWeek( Quest const* qInfo, bool msg ) const; bool SatisfyQuestMonth(Quest const* qInfo, bool msg) const; - bool CanGiveQuestSourceItem( Quest const *pQuest, ItemPosCountVec* dest = NULL) const; - void GiveQuestSourceItem( Quest const *pQuest ); + bool CanGiveQuestSourceItemIfNeed( Quest const *pQuest, ItemPosCountVec* dest = NULL) const; + void GiveQuestSourceItemIfNeed(Quest const *pQuest); bool TakeQuestSourceItem( uint32 quest_id, bool msg ); bool GetQuestRewardStatus( uint32 quest_id ) const; QuestStatus GetQuestStatus( uint32 quest_id ) const; diff --git a/src/game/QuestHandler.cpp b/src/game/QuestHandler.cpp index 6c8143646da..3244d1bba8d 100644 --- a/src/game/QuestHandler.cpp +++ b/src/game/QuestHandler.cpp @@ -196,25 +196,8 @@ void WorldSession::HandleQuestgiverAcceptQuestOpcode( WorldPacket & recv_data ) break; case TYPEID_ITEM: case TYPEID_CONTAINER: - { sScriptMgr.OnQuestAccept(_player, (Item*)pObject, qInfo); - - // destroy not required for quest finish quest starting item - bool destroyItem = true; - for(int i = 0; i < QUEST_ITEM_OBJECTIVES_COUNT; ++i) - { - if ((qInfo->ReqItemId[i] == ((Item*)pObject)->GetEntry()) && (((Item*)pObject)->GetProto()->MaxCount > 0)) - { - destroyItem = false; - break; - } - } - - if(destroyItem) - _player->DestroyItem(((Item*)pObject)->GetBagSlot(), ((Item*)pObject)->GetSlot(), true); - break; - } case TYPEID_GAMEOBJECT: sScriptMgr.OnQuestAccept(_player, (GameObject*)pObject, qInfo); break; diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index 638392b2c87..7191dfcfb15 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 "11437" + #define REVISION_NR "11438" #endif // __REVISION_NR_H__ From 8c5e4470889849cb3edf0eac3128fceb6ebed33f Mon Sep 17 00:00:00 2001 From: Den Date: Sun, 8 May 2011 06:04:01 +0400 Subject: [PATCH 05/43] [11439] Cleanup codestyle in Bag.cpp & Bag.h Signed-off-by: VladimirMangos --- src/game/Bag.cpp | 70 +++++++++++++++++++++------------------- src/game/Bag.h | 14 ++++---- src/shared/revision_nr.h | 2 +- 3 files changed, 44 insertions(+), 42 deletions(-) diff --git a/src/game/Bag.cpp b/src/game/Bag.cpp index 5a32a83141f..5797f6daaa0 100644 --- a/src/game/Bag.cpp +++ b/src/game/Bag.cpp @@ -22,19 +22,19 @@ #include "Log.h" #include "UpdateData.h" -Bag::Bag( ): Item() +Bag::Bag(): Item() { m_objectType |= (TYPEMASK_ITEM | TYPEMASK_CONTAINER); m_objectTypeId = TYPEID_CONTAINER; m_valuesCount = CONTAINER_END; - memset(m_bagslot, 0, sizeof(Item *) * MAX_BAG_SIZE); + memset(m_bagslot, 0, sizeof(Item*) * MAX_BAG_SIZE); } Bag::~Bag() { - for(int i = 0; i < MAX_BAG_SIZE; ++i) + for (int i = 0; i < MAX_BAG_SIZE; ++i) if (m_bagslot[i]) delete m_bagslot[i]; } @@ -43,15 +43,15 @@ void Bag::AddToWorld() { Item::AddToWorld(); - for(uint32 i = 0; i < GetBagSize(); ++i) - if(m_bagslot[i]) + for (uint32 i = 0; i < GetBagSize(); ++i) + if (m_bagslot[i]) m_bagslot[i]->AddToWorld(); } void Bag::RemoveFromWorld() { - for(uint32 i = 0; i < GetBagSize(); ++i) - if(m_bagslot[i]) + for (uint32 i = 0; i < GetBagSize(); ++i) + if (m_bagslot[i]) m_bagslot[i]->RemoveFromWorld(); Item::RemoveFromWorld(); @@ -59,12 +59,12 @@ void Bag::RemoveFromWorld() bool Bag::Create(uint32 guidlow, uint32 itemid, Player const* owner) { - ItemPrototype const * itemProto = ObjectMgr::GetItemPrototype(itemid); + ItemPrototype const* itemProto = ObjectMgr::GetItemPrototype(itemid); - if(!itemProto || itemProto->ContainerSlots > MAX_BAG_SIZE) + if (!itemProto || itemProto->ContainerSlots > MAX_BAG_SIZE) return false; - Object::_Create( guidlow, 0, HIGHGUID_CONTAINER ); + Object::_Create(guidlow, 0, HIGHGUID_CONTAINER); SetEntry(itemid); SetObjectScale(DEFAULT_OBJECT_SCALE); @@ -82,7 +82,7 @@ bool Bag::Create(uint32 guidlow, uint32 itemid, Player const* owner) // Cleaning 20 slots for (uint8 i = 0; i < MAX_BAG_SIZE; ++i) { - SetGuidValue(CONTAINER_FIELD_SLOT_1 + (i*2), ObjectGuid()); + SetGuidValue(CONTAINER_FIELD_SLOT_1 + (i * 2), ObjectGuid()); m_bagslot[i] = NULL; } @@ -94,7 +94,7 @@ void Bag::SaveToDB() Item::SaveToDB(); } -bool Bag::LoadFromDB(uint32 guidLow, Field *fields, ObjectGuid ownerGuid) +bool Bag::LoadFromDB(uint32 guidLow, Field* fields, ObjectGuid ownerGuid) { if (!Item::LoadFromDB(guidLow, fields, ownerGuid)) return false; @@ -102,7 +102,7 @@ bool Bag::LoadFromDB(uint32 guidLow, Field *fields, ObjectGuid ownerGuid) // cleanup bag content related item value fields (its will be filled correctly from `character_inventory`) for (int i = 0; i < MAX_BAG_SIZE; ++i) { - SetGuidValue(CONTAINER_FIELD_SLOT_1 + (i*2), ObjectGuid()); + SetGuidValue(CONTAINER_FIELD_SLOT_1 + (i * 2), ObjectGuid()); if (m_bagslot[i]) { delete m_bagslot[i]; @@ -125,14 +125,14 @@ void Bag::DeleteFromDB() uint32 Bag::GetFreeSlots() const { uint32 slots = 0; - for (uint32 i=0; i < GetBagSize(); ++i) + for (uint32 i = 0; i < GetBagSize(); ++i) if (!m_bagslot[i]) ++slots; return slots; } -void Bag::RemoveItem( uint8 slot, bool /*update*/ ) +void Bag::RemoveItem(uint8 slot, bool /*update*/) { MANGOS_ASSERT(slot < MAX_BAG_SIZE); @@ -140,14 +140,14 @@ void Bag::RemoveItem( uint8 slot, bool /*update*/ ) m_bagslot[slot]->SetContainer(NULL); m_bagslot[slot] = NULL; - SetGuidValue(CONTAINER_FIELD_SLOT_1 + (slot*2), ObjectGuid()); + SetGuidValue(CONTAINER_FIELD_SLOT_1 + (slot * 2), ObjectGuid()); } -void Bag::StoreItem( uint8 slot, Item *pItem, bool /*update*/ ) +void Bag::StoreItem(uint8 slot, Item* pItem, bool /*update*/) { MANGOS_ASSERT(slot < MAX_BAG_SIZE); - if( pItem ) + if (pItem) { m_bagslot[slot] = pItem; SetGuidValue(CONTAINER_FIELD_SLOT_1 + (slot * 2), pItem->GetObjectGuid()); @@ -158,28 +158,28 @@ void Bag::StoreItem( uint8 slot, Item *pItem, bool /*update*/ ) } } -void Bag::BuildCreateUpdateBlockForPlayer( UpdateData *data, Player *target ) const +void Bag::BuildCreateUpdateBlockForPlayer(UpdateData* data, Player* target) const { - Item::BuildCreateUpdateBlockForPlayer( data, target ); + Item::BuildCreateUpdateBlockForPlayer(data, target); for (uint32 i = 0; i < GetBagSize(); ++i) - if(m_bagslot[i]) - m_bagslot[i]->BuildCreateUpdateBlockForPlayer( data, target ); + if (m_bagslot[i]) + m_bagslot[i]->BuildCreateUpdateBlockForPlayer(data, target); } // If the bag is empty returns true bool Bag::IsEmpty() const { - for(uint32 i = 0; i < GetBagSize(); ++i) + for (uint32 i = 0; i < GetBagSize(); ++i) if (m_bagslot[i]) return false; return true; } -Item* Bag::GetItemByEntry( uint32 item ) const +Item* Bag::GetItemByEntry(uint32 item) const { - for(uint32 i = 0; i < GetBagSize(); ++i) + for (uint32 i = 0; i < GetBagSize(); ++i) if (m_bagslot[i] && m_bagslot[i]->GetEntry() == item) return m_bagslot[i]; @@ -188,7 +188,7 @@ Item* Bag::GetItemByEntry( uint32 item ) const Item* Bag::GetItemByLimitedCategory(uint32 limitedCategory) const { - for(uint32 i = 0; i < GetBagSize(); ++i) + for (uint32 i = 0; i < GetBagSize(); ++i) if (m_bagslot[i] && m_bagslot[i]->GetProto()->ItemLimitCategory == limitedCategory) return m_bagslot[i]; @@ -198,13 +198,14 @@ Item* Bag::GetItemByLimitedCategory(uint32 limitedCategory) const uint32 Bag::GetItemCount(uint32 item, Item* eItem) const { uint32 count = 0; - for(uint32 i=0; i < GetBagSize(); ++i) + + for (uint32 i = 0; i < GetBagSize(); ++i) if (m_bagslot[i]) if (m_bagslot[i] != eItem && m_bagslot[i]->GetEntry() == item) count += m_bagslot[i]->GetCount(); if (eItem && eItem->GetProto()->GemProperties) - for(uint32 i=0; i < GetBagSize(); ++i) + for (uint32 i = 0; i < GetBagSize(); ++i) if (m_bagslot[i]) if (m_bagslot[i] != eItem && m_bagslot[i]->GetProto()->Socket[0].Color) count += m_bagslot[i]->GetGemCountWithID(item); @@ -215,7 +216,8 @@ uint32 Bag::GetItemCount(uint32 item, Item* eItem) const uint32 Bag::GetItemCountWithLimitCategory(uint32 limitCategory, Item* eItem) const { uint32 count = 0; - for(uint32 i = 0; i < GetBagSize(); ++i) + + for (uint32 i = 0; i < GetBagSize(); ++i) if (m_bagslot[i]) if (m_bagslot[i] != eItem && m_bagslot[i]->GetProto()->ItemLimitCategory == limitCategory ) count += m_bagslot[i]->GetCount(); @@ -225,17 +227,17 @@ uint32 Bag::GetItemCountWithLimitCategory(uint32 limitCategory, Item* eItem) con uint8 Bag::GetSlotByItemGUID(uint64 guid) const { - for(uint32 i = 0; i < GetBagSize(); ++i) - if(m_bagslot[i] != 0) - if(m_bagslot[i]->GetGUID() == guid) + for (uint32 i = 0; i < GetBagSize(); ++i) + if (m_bagslot[i] != 0) + if (m_bagslot[i]->GetGUID() == guid) return i; return NULL_SLOT; } -Item* Bag::GetItemByPos( uint8 slot ) const +Item* Bag::GetItemByPos(uint8 slot) const { - if( slot < GetBagSize() ) + if (slot < GetBagSize()) return m_bagslot[slot]; return NULL; diff --git a/src/game/Bag.h b/src/game/Bag.h index 86e86ef32fc..0cf283f8207 100644 --- a/src/game/Bag.h +++ b/src/game/Bag.h @@ -39,11 +39,11 @@ class Bag : public Item bool Create(uint32 guidlow, uint32 itemid, Player const* owner); void Clear(); - void StoreItem( uint8 slot, Item *pItem, bool update ); - void RemoveItem( uint8 slot, bool update ); + void StoreItem(uint8 slot, Item *pItem, bool update); + void RemoveItem(uint8 slot, bool update); - Item* GetItemByPos( uint8 slot ) const; - Item* GetItemByEntry( uint32 item ) const; + Item* GetItemByPos(uint8 slot) const; + Item* GetItemByEntry(uint32 item) const; Item* GetItemByLimitedCategory(uint32 limitedCategory) const; uint32 GetItemCount(uint32 item, Item* eItem = NULL) const; uint32 GetItemCountWithLimitCategory(uint32 limitCategory, Item* eItem = NULL) const; @@ -57,11 +57,11 @@ class Bag : public Item // overwrite virtual Item::SaveToDB void SaveToDB(); // overwrite virtual Item::LoadFromDB - bool LoadFromDB(uint32 guidLow, Field *fields, ObjectGuid ownerGuid = ObjectGuid()); + bool LoadFromDB(uint32 guidLow, Field* fields, ObjectGuid ownerGuid = ObjectGuid()); // overwrite virtual Item::DeleteFromDB void DeleteFromDB(); - void BuildCreateUpdateBlockForPlayer(UpdateData *data, Player *target) const; + void BuildCreateUpdateBlockForPlayer(UpdateData* data, Player* target) const; protected: @@ -69,7 +69,7 @@ class Bag : public Item Item* m_bagslot[MAX_BAG_SIZE]; }; -inline Item* NewItemOrBag(ItemPrototype const * proto) +inline Item* NewItemOrBag(ItemPrototype const* proto) { if (proto->InventoryType == INVTYPE_BAG) return new Bag; diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index 7191dfcfb15..77234391ed8 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 "11438" + #define REVISION_NR "11439" #endif // __REVISION_NR_H__ From dc092d2b52293e6d4608294d8de9a28bb127d305 Mon Sep 17 00:00:00 2001 From: Den Date: Sun, 8 May 2011 06:52:49 +0400 Subject: [PATCH 06/43] [11440] Restore itemset 650 4p bonus affect work Signed-off-by: VladimirMangos --- src/game/Spell.cpp | 8 +++++++- src/shared/revision_nr.h | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/game/Spell.cpp b/src/game/Spell.cpp index a5859afde99..521cb71bd92 100644 --- a/src/game/Spell.cpp +++ b/src/game/Spell.cpp @@ -3034,8 +3034,14 @@ void Spell::cast(bool skipCheck) break; case SPELLFAMILY_HUNTER: { + // Kill Command + if (m_spellInfo->Id == 34026) + { + if (m_caster->HasAura(37483)) // Improved Kill Command - Item set bonus + m_caster->CastSpell(m_caster, 37482, true);// Exploited Weakness + } // Lock and Load - if (m_spellInfo->Id == 56453) + else if (m_spellInfo->Id == 56453) AddPrecastSpell(67544); // Lock and Load Marker break; } diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index 77234391ed8..825beb23a4d 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 "11439" + #define REVISION_NR "11440" #endif // __REVISION_NR_H__ From 7197a2ed381138e00b17b7ad3880af354ba74b51 Mon Sep 17 00:00:00 2001 From: zergtmn Date: Sun, 8 May 2011 15:49:42 +0600 Subject: [PATCH 07/43] [11441] Add positiveness detection for SPELL_AURA_MOD_RESISTANCE auras --- src/game/SpellMgr.cpp | 1 + src/shared/revision_nr.h | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/game/SpellMgr.cpp b/src/game/SpellMgr.cpp index e544da7e639..b0230c74ae2 100644 --- a/src/game/SpellMgr.cpp +++ b/src/game/SpellMgr.cpp @@ -707,6 +707,7 @@ bool IsPositiveEffect(SpellEntry const *spellproto, SpellEffectIndex effIndex) } } break; case SPELL_AURA_MOD_DAMAGE_DONE: // dependent from base point sign (negative -> negative) + case SPELL_AURA_MOD_RESISTANCE: case SPELL_AURA_MOD_STAT: case SPELL_AURA_MOD_SKILL: case SPELL_AURA_MOD_DODGE_PERCENT: diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index 825beb23a4d..8c81a5a2a2b 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 "11440" + #define REVISION_NR "11441" #endif // __REVISION_NR_H__ From 1d8de3b1b55b678643e1a146fb28b9584f5e6cb8 Mon Sep 17 00:00:00 2001 From: Den Date: Sun, 8 May 2011 20:00:34 +0400 Subject: [PATCH 08/43] [11442] Cleanup codestyle in WorldSocketMgr.cpp & WorldSocketMgr.h Signed-off-by: VladimirMangos --- src/game/WorldSocketMgr.cpp | 152 ++++++++++++++++-------------------- src/game/WorldSocketMgr.h | 57 +++++++------- src/shared/revision_nr.h | 2 +- 3 files changed, 97 insertions(+), 114 deletions(-) diff --git a/src/game/WorldSocketMgr.cpp b/src/game/WorldSocketMgr.cpp index 90139a9098c..4756fed17fb 100644 --- a/src/game/WorldSocketMgr.cpp +++ b/src/game/WorldSocketMgr.cpp @@ -52,8 +52,7 @@ class ReactorRunnable : protected ACE_Task_Base { public: - - ReactorRunnable () : + ReactorRunnable() : m_Reactor (0), m_Connections (0), m_ThreadId (-1) @@ -62,48 +61,48 @@ class ReactorRunnable : protected ACE_Task_Base #if defined (ACE_HAS_EVENT_POLL) || defined (ACE_HAS_DEV_POLL) - imp = new ACE_Dev_Poll_Reactor (); + imp = new ACE_Dev_Poll_Reactor(); - imp->max_notify_iterations (128); - imp->restart (1); + imp->max_notify_iterations(128); + imp->restart(1); #else - imp = new ACE_TP_Reactor (); - imp->max_notify_iterations (128); + imp = new ACE_TP_Reactor(); + imp->max_notify_iterations(128); #endif - m_Reactor = new ACE_Reactor (imp, 1); + m_Reactor = new ACE_Reactor(imp, 1); } - virtual ~ReactorRunnable () + virtual ~ReactorRunnable() { - Stop (); - Wait (); + Stop(); + Wait(); if (m_Reactor) delete m_Reactor; } - void Stop () + void Stop() { - m_Reactor->end_reactor_event_loop (); + m_Reactor->end_reactor_event_loop(); } - int Start () + int Start() { if (m_ThreadId != -1) return -1; - return (m_ThreadId = activate ()); + return (m_ThreadId = activate()); } - void Wait () { ACE_Task_Base::wait (); } + void Wait() { ACE_Task_Base::wait(); } - long Connections () + long Connections() { - return static_cast (m_Connections.value ()); + return static_cast (m_Connections.value()); } int AddSocket (WorldSocket* sock) @@ -118,47 +117,46 @@ class ReactorRunnable : protected ACE_Task_Base return 0; } - ACE_Reactor* GetReactor () + ACE_Reactor* GetReactor() { return m_Reactor; } protected: - - void AddNewSockets () + void AddNewSockets() { ACE_GUARD (ACE_Thread_Mutex, Guard, m_NewSockets_Lock); - if (m_NewSockets.empty ()) + if (m_NewSockets.empty()) return; - for (SocketSet::const_iterator i = m_NewSockets.begin (); i != m_NewSockets.end (); ++i) + for (SocketSet::const_iterator i = m_NewSockets.begin(); i != m_NewSockets.end(); ++i) { WorldSocket* sock = (*i); - if (sock->IsClosed ()) + if (sock->IsClosed()) { - sock->RemoveReference (); + sock->RemoveReference(); --m_Connections; } else - m_Sockets.insert (sock); + m_Sockets.insert(sock); } - m_NewSockets.clear (); + m_NewSockets.clear(); } - virtual int svc () + virtual int svc() { DEBUG_LOG ("Network Thread Starting"); - WorldDatabase.ThreadStart (); + WorldDatabase.ThreadStart(); - MANGOS_ASSERT (m_Reactor); + MANGOS_ASSERT(m_Reactor); SocketSet::iterator i, t; - while (!m_Reactor->reactor_event_loop_done ()) + while (!m_Reactor->reactor_event_loop_done()) { // dont be too smart to move this outside the loop // the run_reactor_event_loop will modify interval @@ -167,25 +165,25 @@ class ReactorRunnable : protected ACE_Task_Base if (m_Reactor->run_reactor_event_loop (interval) == -1) break; - AddNewSockets (); + AddNewSockets(); - for (i = m_Sockets.begin (); i != m_Sockets.end ();) + for (i = m_Sockets.begin(); i != m_Sockets.end();) { - if ((*i)->Update () == -1) + if ((*i)->Update() == -1) { t = i; ++i; - (*t)->CloseSocket (); - (*t)->RemoveReference (); + (*t)->CloseSocket(); + (*t)->RemoveReference(); --m_Connections; - m_Sockets.erase (t); + m_Sockets.erase(t); } else ++i; } } - WorldDatabase.ThreadEnd (); + WorldDatabase.ThreadEnd(); DEBUG_LOG ("Network Thread Exitting"); @@ -206,17 +204,17 @@ class ReactorRunnable : protected ACE_Task_Base ACE_Thread_Mutex m_NewSockets_Lock; }; -WorldSocketMgr::WorldSocketMgr () : - m_NetThreads (0), - m_NetThreadsCount (0), - m_SockOutKBuff (-1), - m_SockOutUBuff (65536), - m_UseNoDelay (true), - m_Acceptor (0) +WorldSocketMgr::WorldSocketMgr(): + m_NetThreads(0), + m_NetThreadsCount(0), + m_SockOutKBuff(-1), + m_SockOutUBuff(65536), + m_UseNoDelay(true), + m_Acceptor(0) { } -WorldSocketMgr::~WorldSocketMgr () +WorldSocketMgr::~WorldSocketMgr() { if (m_NetThreads) delete [] m_NetThreads; @@ -225,8 +223,7 @@ WorldSocketMgr::~WorldSocketMgr () delete m_Acceptor; } -int -WorldSocketMgr::StartReactiveIO (ACE_UINT16 port, const char* address) +int WorldSocketMgr::StartReactiveIO (ACE_UINT16 port, const char* address) { m_UseNoDelay = sConfig.GetBoolDefault ("Network.TcpNodelay", true); @@ -242,44 +239,43 @@ WorldSocketMgr::StartReactiveIO (ACE_UINT16 port, const char* address) m_NetThreads = new ReactorRunnable[m_NetThreadsCount]; - BASIC_LOG("Max allowed socket connections %d",ACE::max_handles ()); + BASIC_LOG("Max allowed socket connections %d", ACE::max_handles()); // -1 means use default - m_SockOutKBuff = sConfig.GetIntDefault ("Network.OutKBuff", -1); + m_SockOutKBuff = sConfig.GetIntDefault("Network.OutKBuff", -1); - m_SockOutUBuff = sConfig.GetIntDefault ("Network.OutUBuff", 65536); + m_SockOutUBuff = sConfig.GetIntDefault("Network.OutUBuff", 65536); - if ( m_SockOutUBuff <= 0 ) + if (m_SockOutUBuff <= 0) { sLog.outError ("Network.OutUBuff is wrong in your config file"); return -1; } - WorldSocket::Acceptor *acc = new WorldSocket::Acceptor; + WorldSocket::Acceptor* acc = new WorldSocket::Acceptor; m_Acceptor = acc; ACE_INET_Addr listen_addr (port, address); - if (acc->open (listen_addr, m_NetThreads[0].GetReactor (), ACE_NONBLOCK) == -1) + if (acc->open (listen_addr, m_NetThreads[0].GetReactor(), ACE_NONBLOCK) == -1) { - sLog.outError ("Failed to open acceptor ,check if the port is free"); + sLog.outError ("Failed to open acceptor, check if the port is free"); return -1; } for (size_t i = 0; i < m_NetThreadsCount; ++i) - m_NetThreads[i].Start (); + m_NetThreads[i].Start(); return 0; } -int -WorldSocketMgr::StartNetwork (ACE_UINT16 port, std::string& address) +int WorldSocketMgr::StartNetwork (ACE_UINT16 port, std::string& address) { m_addr = address; m_port = port; if (!sLog.HasLogLevelOrHigher(LOG_LVL_DEBUG)) - ACE_Log_Msg::instance ()->priority_mask (LM_ERROR, ACE_Log_Msg::PROCESS); + ACE_Log_Msg::instance()->priority_mask (LM_ERROR, ACE_Log_Msg::PROCESS); if (StartReactiveIO (port, address.c_str()) == -1) return -1; @@ -287,46 +283,40 @@ WorldSocketMgr::StartNetwork (ACE_UINT16 port, std::string& address) return 0; } -void -WorldSocketMgr::StopNetwork () +void WorldSocketMgr::StopNetwork() { if (m_Acceptor) { - WorldSocket::Acceptor* acc = dynamic_cast (m_Acceptor); + WorldSocket::Acceptor* acc = dynamic_cast(m_Acceptor); if (acc) - acc->close (); + acc->close(); } if (m_NetThreadsCount != 0) { for (size_t i = 0; i < m_NetThreadsCount; ++i) - m_NetThreads[i].Stop (); + m_NetThreads[i].Stop(); } - Wait (); + Wait(); } -void -WorldSocketMgr::Wait () +void WorldSocketMgr::Wait() { if (m_NetThreadsCount != 0) { for (size_t i = 0; i < m_NetThreadsCount; ++i) - m_NetThreads[i].Wait (); + m_NetThreads[i].Wait(); } } -int -WorldSocketMgr::OnSocketOpen (WorldSocket* sock) +int WorldSocketMgr::OnSocketOpen(WorldSocket* sock) { // set some options here if (m_SockOutKBuff >= 0) { - if (sock->peer ().set_option (SOL_SOCKET, - SO_SNDBUF, - (void*) & m_SockOutKBuff, - sizeof (int)) == -1 && errno != ENOTSUP) + if (sock->peer().set_option(SOL_SOCKET, SO_SNDBUF, (void*)&m_SockOutKBuff, sizeof(int)) == -1 && errno != ENOTSUP) { sLog.outError ("WorldSocketMgr::OnSocketOpen set_option SO_SNDBUF"); return -1; @@ -338,12 +328,9 @@ WorldSocketMgr::OnSocketOpen (WorldSocket* sock) // Set TCP_NODELAY. if (m_UseNoDelay) { - if (sock->peer ().set_option (ACE_IPPROTO_TCP, - TCP_NODELAY, - (void*)&ndoption, - sizeof (int)) == -1) + if (sock->peer().set_option(ACE_IPPROTO_TCP, TCP_NODELAY, (void*)&ndoption, sizeof (int)) == -1) { - sLog.outError ("WorldSocketMgr::OnSocketOpen: peer ().set_option TCP_NODELAY errno = %s", ACE_OS::strerror (errno)); + sLog.outError("WorldSocketMgr::OnSocketOpen: peer().set_option TCP_NODELAY errno = %s", ACE_OS::strerror(errno)); return -1; } } @@ -356,14 +343,13 @@ WorldSocketMgr::OnSocketOpen (WorldSocket* sock) MANGOS_ASSERT (m_NetThreadsCount >= 1); for (size_t i = 1; i < m_NetThreadsCount; ++i) - if (m_NetThreads[i].Connections () < m_NetThreads[min].Connections ()) + if (m_NetThreads[i].Connections() < m_NetThreads[min].Connections()) min = i; return m_NetThreads[min].AddSocket (sock); } -WorldSocketMgr* -WorldSocketMgr::Instance () +WorldSocketMgr* WorldSocketMgr::Instance() { - return ACE_Singleton::instance(); + return ACE_Singleton::instance(); } diff --git a/src/game/WorldSocketMgr.h b/src/game/WorldSocketMgr.h index cfbea8cbc11..d5ea1af5f92 100644 --- a/src/game/WorldSocketMgr.h +++ b/src/game/WorldSocketMgr.h @@ -38,49 +38,46 @@ class ACE_Event_Handler; /// Manages all sockets connected to peers and network threads class WorldSocketMgr { -public: - friend class WorldSocket; - friend class ACE_Singleton; + public: + friend class WorldSocket; + friend class ACE_Singleton; - /// Start network, listen at address:port . - int StartNetwork (ACE_UINT16 port, std::string& address); + /// Start network, listen at address:port . + int StartNetwork(ACE_UINT16 port, std::string& address); - /// Stops all network threads, It will wait for all running threads . - void StopNetwork (); + /// Stops all network threads, It will wait for all running threads . + void StopNetwork(); - /// Wait untill all network threads have "joined" . - void Wait (); + /// Wait untill all network threads have "joined" . + void Wait(); - std::string& GetBindAddress() { return m_addr; } - ACE_UINT16 GetBindPort() { return m_port; } + std::string& GetBindAddress() { return m_addr; } + ACE_UINT16 GetBindPort() { return m_port; } - /// Make this class singleton . - static WorldSocketMgr* Instance (); + /// Make this class singleton . + static WorldSocketMgr* Instance(); -private: - int OnSocketOpen(WorldSocket* sock); + private: + int OnSocketOpen(WorldSocket* sock); + int StartReactiveIO(ACE_UINT16 port, const char* address); - int StartReactiveIO(ACE_UINT16 port, const char* address); + WorldSocketMgr(); + virtual ~WorldSocketMgr(); -private: - WorldSocketMgr (); - virtual ~WorldSocketMgr (); + ReactorRunnable* m_NetThreads; + size_t m_NetThreadsCount; - ReactorRunnable* m_NetThreads; - size_t m_NetThreadsCount; + int m_SockOutKBuff; + int m_SockOutUBuff; + bool m_UseNoDelay; - int m_SockOutKBuff; - int m_SockOutUBuff; - bool m_UseNoDelay; + std::string m_addr; + ACE_UINT16 m_port; - std::string m_addr; - ACE_UINT16 m_port; - - ACE_Event_Handler* m_Acceptor; + ACE_Event_Handler* m_Acceptor; }; -#define sWorldSocketMgr WorldSocketMgr::Instance () - +#define sWorldSocketMgr WorldSocketMgr::Instance() #endif /// @} diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index 8c81a5a2a2b..7f8c073dc91 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 "11441" + #define REVISION_NR "11442" #endif // __REVISION_NR_H__ From 673aff36591cad38c45e978d36e18baa63b4ee62 Mon Sep 17 00:00:00 2001 From: NoFantasy Date: Sun, 8 May 2011 18:57:06 +0200 Subject: [PATCH 09/43] [11443] Implement SPELL_AURA_MIRROR_IMAGE (247) and related receive/reply packets Inspired by different patches posted in forum, thanks guys for the help it was :D Signed-off-by: NoFantasy --- src/game/Opcodes.cpp | 4 +- src/game/Player.cpp | 10 +++++ src/game/Player.h | 1 + src/game/Spell.cpp | 19 +++++++++ src/game/SpellAuraDefines.h | 2 +- src/game/SpellAuras.cpp | 40 +++++++++++++++++- src/game/SpellAuras.h | 1 + src/game/SpellHandler.cpp | 84 +++++++++++++++++++++++++++++++++++++ src/game/Unit.h | 2 +- src/game/WorldSession.h | 1 + src/shared/revision_nr.h | 2 +- 11 files changed, 160 insertions(+), 6 deletions(-) diff --git a/src/game/Opcodes.cpp b/src/game/Opcodes.cpp index c19f218493f..89c6668e211 100644 --- a/src/game/Opcodes.cpp +++ b/src/game/Opcodes.cpp @@ -1051,8 +1051,8 @@ OpcodeHandler opcodeTable[NUM_MSG_TYPES] = /*0x3FE*/ { "MSG_GUILD_BANK_MONEY_WITHDRAWN", STATUS_LOGGEDIN, PROCESS_THREADUNSAFE, &WorldSession::HandleGuildBankMoneyWithdrawn }, /*0x3FF*/ { "MSG_GUILD_EVENT_LOG_QUERY", STATUS_LOGGEDIN, PROCESS_THREADUNSAFE, &WorldSession::HandleGuildEventLogQueryOpcode }, /*0x400*/ { "CMSG_MAELSTROM_RENAME_GUILD", STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_NULL }, - /*0x401*/ { "CMSG_GET_MIRRORIMAGE_DATA", STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_NULL }, - /*0x402*/ { "SMSG_MIRRORIMAGE_DATA", STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_ServerSide }, + /*0x401*/ { "CMSG_GET_MIRRORIMAGE_DATA", STATUS_LOGGEDIN, PROCESS_INPLACE, &WorldSession::HandleGetMirrorimageData }, + /*0x402*/ { "SMSG_MIRRORIMAGE_DATA", STATUS_LOGGEDIN, PROCESS_INPLACE, &WorldSession::Handle_ServerSide }, /*0x403*/ { "SMSG_FORCE_DISPLAY_UPDATE", STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_ServerSide }, /*0x404*/ { "SMSG_SPELL_CHANCE_RESIST_PUSHBACK", STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_ServerSide }, /*0x405*/ { "CMSG_IGNORE_DIMINISHING_RETURNS_CHEAT", STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_NULL }, diff --git a/src/game/Player.cpp b/src/game/Player.cpp index b3b4ff7a5e1..94b0d0db609 100644 --- a/src/game/Player.cpp +++ b/src/game/Player.cpp @@ -9183,6 +9183,16 @@ Item* Player::GetItemByPos( uint8 bag, uint8 slot ) const return NULL; } +uint32 Player::GetItemDisplayIdInSlot(uint8 bag, uint8 slot) const +{ + const Item* pItem = GetItemByPos(bag, slot); + + if (!pItem) + return 0; + + return pItem->GetProto()->DisplayInfoID; +} + Item* Player::GetWeaponForAttack(WeaponAttackType attackType, bool nonbroken, bool useable) const { uint8 slot; diff --git a/src/game/Player.h b/src/game/Player.h index 720d5cc94b8..8e2e137fce2 100644 --- a/src/game/Player.h +++ b/src/game/Player.h @@ -1178,6 +1178,7 @@ class MANGOS_DLL_SPEC Player : public Unit Item* GetItemByLimitedCategory(uint32 limitedCategory) const; Item* GetItemByPos( uint16 pos ) const; Item* GetItemByPos( uint8 bag, uint8 slot ) const; + uint32 GetItemDisplayIdInSlot(uint8 bag, uint8 slot) const; Item* GetWeaponForAttack(WeaponAttackType attackType) const { return GetWeaponForAttack(attackType,false,false); } Item* GetWeaponForAttack(WeaponAttackType attackType, bool nonbroken, bool useable) const; Item* GetShield(bool useable = false) const; diff --git a/src/game/Spell.cpp b/src/game/Spell.cpp index 521cb71bd92..be8ddc6f0ba 100644 --- a/src/game/Spell.cpp +++ b/src/game/Spell.cpp @@ -5531,6 +5531,25 @@ SpellCastResult Spell::CheckCast(bool strict) break; } + case SPELL_AURA_MIRROR_IMAGE: + { + Unit* pTarget = m_targets.getUnitTarget(); + + if (!pTarget) + return SPELL_FAILED_BAD_TARGETS; + + if (pTarget->GetTypeId() != TYPEID_UNIT) // Target must be creature + return SPELL_FAILED_BAD_TARGETS; + + if (pTarget == m_caster) // Clone self can't be accepted + return SPELL_FAILED_BAD_TARGETS; + + // It is assumed that target can not be cloned if already cloned by same or other clone auras + if (!pTarget->GetAurasByType(SPELL_AURA_MIRROR_IMAGE).empty()) + return SPELL_FAILED_BAD_TARGETS; + + break; + } default: break; } diff --git a/src/game/SpellAuraDefines.h b/src/game/SpellAuraDefines.h index 0271c904db2..f82fd21b0da 100644 --- a/src/game/SpellAuraDefines.h +++ b/src/game/SpellAuraDefines.h @@ -282,7 +282,7 @@ enum AuraType SPELL_AURA_COMPREHEND_LANGUAGE = 244, SPELL_AURA_MOD_DURATION_OF_MAGIC_EFFECTS = 245, SPELL_AURA_MOD_DURATION_OF_EFFECTS_BY_DISPEL = 246, - SPELL_AURA_247 = 247, + SPELL_AURA_MIRROR_IMAGE = 247, SPELL_AURA_MOD_COMBAT_RESULT_CHANCE = 248, SPELL_AURA_CONVERT_RUNE = 249, SPELL_AURA_MOD_INCREASE_HEALTH_2 = 250, diff --git a/src/game/SpellAuras.cpp b/src/game/SpellAuras.cpp index 97ee5b74bd7..a0dca8e3f40 100644 --- a/src/game/SpellAuras.cpp +++ b/src/game/SpellAuras.cpp @@ -297,7 +297,7 @@ pAuraHandler AuraHandler[TOTAL_AURAS]= &Aura::HandleComprehendLanguage, //244 SPELL_AURA_COMPREHEND_LANGUAGE &Aura::HandleNoImmediateEffect, //245 SPELL_AURA_MOD_DURATION_OF_MAGIC_EFFECTS implemented in Unit::CalculateAuraDuration &Aura::HandleNoImmediateEffect, //246 SPELL_AURA_MOD_DURATION_OF_EFFECTS_BY_DISPEL implemented in Unit::CalculateAuraDuration - &Aura::HandleNULL, //247 target to become a clone of the caster + &Aura::HandleAuraMirrorImage, //247 SPELL_AURA_MIRROR_IMAGE target to become a clone of the caster &Aura::HandleNoImmediateEffect, //248 SPELL_AURA_MOD_COMBAT_RESULT_CHANCE implemented in Unit::RollMeleeOutcomeAgainst &Aura::HandleAuraConvertRune, //249 SPELL_AURA_CONVERT_RUNE &Aura::HandleAuraModIncreaseHealth, //250 SPELL_AURA_MOD_INCREASE_HEALTH_2 @@ -8032,6 +8032,44 @@ void Aura::HandleAuraOpenStable(bool apply, bool Real) // client auto close stable dialog at !apply aura } +void Aura::HandleAuraMirrorImage(bool apply, bool Real) +{ + if (!Real) + return; + + // Target of aura should always be creature (ref Spell::CheckCast) + Creature* pCreature = (Creature*)GetTarget(); + + // Caster can be player or creature, the unit who pCreature will become an clone of. + Unit* caster = GetCaster(); + + if (apply) + { + pCreature->SetByteValue(UNIT_FIELD_BYTES_0, 0, caster->getRace()); + pCreature->SetByteValue(UNIT_FIELD_BYTES_0, 1, caster->getClass()); + pCreature->SetByteValue(UNIT_FIELD_BYTES_0, 2, caster->getGender()); + pCreature->SetByteValue(UNIT_FIELD_BYTES_0, 3, caster->getPowerType()); + + pCreature->SetFlag(UNIT_FIELD_FLAGS_2, UNIT_FLAG2_CLONED); + + pCreature->SetDisplayId(caster->GetNativeDisplayId()); + } + else + { + const CreatureInfo* cinfo = pCreature->GetCreatureInfo(); + const CreatureModelInfo* minfo = sObjectMgr.GetCreatureModelInfo(pCreature->GetNativeDisplayId()); + + pCreature->SetByteValue(UNIT_FIELD_BYTES_0, 0, 0); + pCreature->SetByteValue(UNIT_FIELD_BYTES_0, 1, cinfo->unit_class); + pCreature->SetByteValue(UNIT_FIELD_BYTES_0, 2, minfo->gender); + pCreature->SetByteValue(UNIT_FIELD_BYTES_0, 3, 0); + + pCreature->RemoveFlag(UNIT_FIELD_FLAGS_2, UNIT_FLAG2_CLONED); + + pCreature->SetDisplayId(pCreature->GetNativeDisplayId()); + } +} + void Aura::HandleAuraConvertRune(bool apply, bool Real) { if(!Real) diff --git a/src/game/SpellAuras.h b/src/game/SpellAuras.h index 7a60fa90875..f771dd743aa 100644 --- a/src/game/SpellAuras.h +++ b/src/game/SpellAuras.h @@ -362,6 +362,7 @@ class MANGOS_DLL_SPEC Aura void HandlePreventFleeing(bool apply, bool Real); void HandleManaShield(bool apply, bool Real); void HandleArenaPreparation(bool apply, bool Real); + void HandleAuraMirrorImage(bool apply, bool Real); void HandleAuraConvertRune(bool apply, bool Real); void HandleAuraIncreaseBaseHealthPercent(bool Apply, bool Real); void HandleNoReagentUseAura(bool Apply, bool Real); diff --git a/src/game/SpellHandler.cpp b/src/game/SpellHandler.cpp index d3ca6ca580e..9925ff29bf6 100644 --- a/src/game/SpellHandler.cpp +++ b/src/game/SpellHandler.cpp @@ -609,3 +609,87 @@ void WorldSession::HandleSpellClick( WorldPacket & recv_data ) } } } + +void WorldSession::HandleGetMirrorimageData(WorldPacket& recv_data) +{ + DEBUG_FILTER_LOG(LOG_FILTER_SPELL_CAST, "WORLD: CMSG_GET_MIRRORIMAGE_DATA"); + + ObjectGuid guid; + recv_data >> guid; + + Creature* pCreature = _player->GetMap()->GetAnyTypeCreature(guid); + + if (!pCreature) + return; + + Unit::AuraList const& images = pCreature->GetAurasByType(SPELL_AURA_MIRROR_IMAGE); + + if (images.empty()) + return; + + Unit* pCaster = images.front()->GetCaster(); + + WorldPacket data(SMSG_MIRRORIMAGE_DATA, 68); + + data << guid; + data << (uint32)pCreature->GetDisplayId(); + + data << (uint8)pCreature->getRace(); + data << (uint8)pCreature->getGender(); + data << (uint8)pCreature->getClass(); + + if (pCaster->GetTypeId() == TYPEID_PLAYER) + { + Player* pPlayer = (Player*)pCaster; + + // skin, face, hair, haircolor + data << (uint8)pPlayer->GetByteValue(PLAYER_BYTES, 0); + data << (uint8)pPlayer->GetByteValue(PLAYER_BYTES, 1); + data << (uint8)pPlayer->GetByteValue(PLAYER_BYTES, 2); + data << (uint8)pPlayer->GetByteValue(PLAYER_BYTES, 3); + + // facial hair + data << (uint8)pPlayer->GetByteValue(PLAYER_BYTES_2, 0); + + // guild id + data << (uint32)pPlayer->GetGuildId(); + + if (pPlayer->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_HIDE_HELM)) + data << (uint32)0; + else + data << (uint32)pPlayer->GetItemDisplayIdInSlot(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_HEAD); + + data << (uint32)pPlayer->GetItemDisplayIdInSlot(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_SHOULDERS); + data << (uint32)pPlayer->GetItemDisplayIdInSlot(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_BODY); + data << (uint32)pPlayer->GetItemDisplayIdInSlot(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_CHEST); + data << (uint32)pPlayer->GetItemDisplayIdInSlot(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_WAIST); + data << (uint32)pPlayer->GetItemDisplayIdInSlot(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_LEGS); + data << (uint32)pPlayer->GetItemDisplayIdInSlot(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_FEET); + data << (uint32)pPlayer->GetItemDisplayIdInSlot(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_WRISTS); + data << (uint32)pPlayer->GetItemDisplayIdInSlot(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_HANDS); + + if (pPlayer->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_HIDE_CLOAK)) + data << (uint32)0; + else + data << (uint32)pPlayer->GetItemDisplayIdInSlot(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_BACK); + + data << (uint32)pPlayer->GetItemDisplayIdInSlot(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_TABARD); + } + else + { + // No data when cloner is not player, data is taken from CreatureDisplayInfoExtraEntry by model already + data << (uint8)0; + data << (uint8)0; + data << (uint8)0; + data << (uint8)0; + + data << (uint8)0; + + data << (uint32)0; + + for (int i = 0; i < 11; ++i) + data << (uint32)0; + } + + SendPacket(&data); +} diff --git a/src/game/Unit.h b/src/game/Unit.h index 2ecd7c75ab4..8adbf60f6dc 100644 --- a/src/game/Unit.h +++ b/src/game/Unit.h @@ -547,7 +547,7 @@ enum UnitFlags2 UNIT_FLAG2_UNK1 = 0x00000002, // Hides body and body armor. Weapons and shoulder and head armor still visible UNIT_FLAG2_UNK2 = 0x00000004, UNIT_FLAG2_COMPREHEND_LANG = 0x00000008, - UNIT_FLAG2_UNK4 = 0x00000010, + UNIT_FLAG2_CLONED = 0x00000010, // Used in SPELL_AURA_MIRROR_IMAGE UNIT_FLAG2_UNK5 = 0x00000020, UNIT_FLAG2_FORCE_MOVE = 0x00000040, UNIT_FLAG2_DISARM_OFFHAND = 0x00000080, // also shield case diff --git a/src/game/WorldSession.h b/src/game/WorldSession.h index e80f6870332..bf396ce4f17 100644 --- a/src/game/WorldSession.h +++ b/src/game/WorldSession.h @@ -840,6 +840,7 @@ class MANGOS_DLL_SPEC WorldSession void HandleCalendarGetNumPending(WorldPacket& recv_data); void HandleSpellClick(WorldPacket& recv_data); + void HandleGetMirrorimageData(WorldPacket& recv_data); void HandleAlterAppearanceOpcode(WorldPacket& recv_data); void HandleRemoveGlyphOpcode(WorldPacket& recv_data); void HandleCharCustomizeOpcode(WorldPacket& recv_data); diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index 7f8c073dc91..8d6e89f9bd9 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 "11442" + #define REVISION_NR "11443" #endif // __REVISION_NR_H__ From 3c7c27fd8aced6b3576ffae13971d4ca3016f6c0 Mon Sep 17 00:00:00 2001 From: NoFantasy Date: Sun, 8 May 2011 19:20:35 +0200 Subject: [PATCH 10/43] [11444] Replace some poo with good shit, improvements related to [11443] Thanks Zergtmn! Signed-off-by: NoFantasy --- src/game/Opcodes.cpp | 2 +- src/game/Spell.cpp | 2 +- src/shared/revision_nr.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/game/Opcodes.cpp b/src/game/Opcodes.cpp index 89c6668e211..5d75b4a279a 100644 --- a/src/game/Opcodes.cpp +++ b/src/game/Opcodes.cpp @@ -1052,7 +1052,7 @@ OpcodeHandler opcodeTable[NUM_MSG_TYPES] = /*0x3FF*/ { "MSG_GUILD_EVENT_LOG_QUERY", STATUS_LOGGEDIN, PROCESS_THREADUNSAFE, &WorldSession::HandleGuildEventLogQueryOpcode }, /*0x400*/ { "CMSG_MAELSTROM_RENAME_GUILD", STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_NULL }, /*0x401*/ { "CMSG_GET_MIRRORIMAGE_DATA", STATUS_LOGGEDIN, PROCESS_INPLACE, &WorldSession::HandleGetMirrorimageData }, - /*0x402*/ { "SMSG_MIRRORIMAGE_DATA", STATUS_LOGGEDIN, PROCESS_INPLACE, &WorldSession::Handle_ServerSide }, + /*0x402*/ { "SMSG_MIRRORIMAGE_DATA", STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_ServerSide }, /*0x403*/ { "SMSG_FORCE_DISPLAY_UPDATE", STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_ServerSide }, /*0x404*/ { "SMSG_SPELL_CHANCE_RESIST_PUSHBACK", STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_ServerSide }, /*0x405*/ { "CMSG_IGNORE_DIMINISHING_RETURNS_CHEAT", STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_NULL }, diff --git a/src/game/Spell.cpp b/src/game/Spell.cpp index be8ddc6f0ba..2ae97b3a512 100644 --- a/src/game/Spell.cpp +++ b/src/game/Spell.cpp @@ -5545,7 +5545,7 @@ SpellCastResult Spell::CheckCast(bool strict) return SPELL_FAILED_BAD_TARGETS; // It is assumed that target can not be cloned if already cloned by same or other clone auras - if (!pTarget->GetAurasByType(SPELL_AURA_MIRROR_IMAGE).empty()) + if (pTarget->HasAuraType(SPELL_AURA_MIRROR_IMAGE)) return SPELL_FAILED_BAD_TARGETS; break; diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index 8d6e89f9bd9..104eebd152d 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 "11443" + #define REVISION_NR "11444" #endif // __REVISION_NR_H__ From 620585da374b82c45683d474b93345c1b70729a3 Mon Sep 17 00:00:00 2001 From: NoFantasy Date: Sun, 8 May 2011 19:47:59 +0200 Subject: [PATCH 11/43] [11445] Correct a possible crash, if caster of aura has disconnected after aura applied A small code adjustment in addition, no need for caster at aura remove. Signed-off-by: NoFantasy --- src/game/SpellAuras.cpp | 6 +++--- src/game/SpellHandler.cpp | 6 ++++-- src/shared/revision_nr.h | 2 +- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/game/SpellAuras.cpp b/src/game/SpellAuras.cpp index a0dca8e3f40..afcd17e0092 100644 --- a/src/game/SpellAuras.cpp +++ b/src/game/SpellAuras.cpp @@ -8040,11 +8040,11 @@ void Aura::HandleAuraMirrorImage(bool apply, bool Real) // Target of aura should always be creature (ref Spell::CheckCast) Creature* pCreature = (Creature*)GetTarget(); - // Caster can be player or creature, the unit who pCreature will become an clone of. - Unit* caster = GetCaster(); - if (apply) { + // Caster can be player or creature, the unit who pCreature will become an clone of. + Unit* caster = GetCaster(); + pCreature->SetByteValue(UNIT_FIELD_BYTES_0, 0, caster->getRace()); pCreature->SetByteValue(UNIT_FIELD_BYTES_0, 1, caster->getClass()); pCreature->SetByteValue(UNIT_FIELD_BYTES_0, 2, caster->getGender()); diff --git a/src/game/SpellHandler.cpp b/src/game/SpellHandler.cpp index 9925ff29bf6..39af52b8e00 100644 --- a/src/game/SpellHandler.cpp +++ b/src/game/SpellHandler.cpp @@ -638,7 +638,7 @@ void WorldSession::HandleGetMirrorimageData(WorldPacket& recv_data) data << (uint8)pCreature->getGender(); data << (uint8)pCreature->getClass(); - if (pCaster->GetTypeId() == TYPEID_PLAYER) + if (pCaster && pCaster->GetTypeId() == TYPEID_PLAYER) { Player* pPlayer = (Player*)pCaster; @@ -677,7 +677,9 @@ void WorldSession::HandleGetMirrorimageData(WorldPacket& recv_data) } else { - // No data when cloner is not player, data is taken from CreatureDisplayInfoExtraEntry by model already + // pCaster may have been NULL (usually not expected, but may happen at disconnect, etc) + // OR + // pCaster is not player, data is taken from CreatureDisplayInfoExtraEntry by model already data << (uint8)0; data << (uint8)0; data << (uint8)0; diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index 104eebd152d..463715536d5 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 "11444" + #define REVISION_NR "11445" #endif // __REVISION_NR_H__ From a38531b2739992f6113bb14d4681c4eae796214e Mon Sep 17 00:00:00 2001 From: VladimirMangos Date: Mon, 9 May 2011 00:53:21 +0400 Subject: [PATCH 12/43] [11446] Reimplement corpse enter to instance. * Resurrect player _before_ enter to instance with corpse * In case corpse in more deep instance teleport to corpse instance inner entrance. * If by some reason player can't enter to corpse instance it will just resurrected before entrance. Original patch and research done by Den. --- src/game/MapManager.cpp | 32 ------------- src/game/MiscHandler.cpp | 89 ++++++++++++++++++++++++++---------- src/game/MovementHandler.cpp | 11 ----- src/shared/revision_nr.h | 2 +- 4 files changed, 65 insertions(+), 69 deletions(-) diff --git a/src/game/MapManager.cpp b/src/game/MapManager.cpp index cece28f3ab5..1b9d9b76bdf 100644 --- a/src/game/MapManager.cpp +++ b/src/game/MapManager.cpp @@ -194,38 +194,6 @@ bool MapManager::CanPlayerEnter(uint32 mapid, Player* player) return false; } - if (!player->isAlive()) - { - if(Corpse *corpse = player->GetCorpse()) - { - // let enter in ghost mode in instance that connected to inner instance with corpse - uint32 instance_map = corpse->GetMapId(); - do - { - if(instance_map==mapid) - break; - - InstanceTemplate const* instance = ObjectMgr::GetInstanceTemplate(instance_map); - instance_map = instance ? instance->parent : 0; - } - while (instance_map); - - if (!instance_map) - { - WorldPacket data(SMSG_AREA_TRIGGER_NO_CORPSE); - player->GetSession()->SendPacket(&data); - - DEBUG_LOG("MAP: Player '%s' doesn't has a corpse in instance '%s' and can't enter", player->GetName(), mapName); - return false; - } - DEBUG_LOG("MAP: Player '%s' has corpse in instance '%s' and can enter", player->GetName(), mapName); - } - else - { - DEBUG_LOG("Map::CanEnter - player '%s' is dead but doesn't have a corpse!", player->GetName()); - } - } - // TODO: move this to a map dependent location /*if(i_data && i_data->IsEncounterInProgress()) { diff --git a/src/game/MiscHandler.cpp b/src/game/MiscHandler.cpp index a5b87627e85..8405f1a4212 100644 --- a/src/game/MiscHandler.cpp +++ b/src/game/MiscHandler.cpp @@ -714,7 +714,7 @@ void WorldSession::HandleAreaTriggerOpcode(WorldPacket & recv_data) return; uint32 quest_id = sObjectMgr.GetQuestForAreaTrigger( Trigger_ID ); - if( quest_id && pl->isAlive() && pl->IsActiveQuest(quest_id) ) + if ( quest_id && pl->isAlive() && pl->IsActiveQuest(quest_id) ) { Quest const* pQuest = sObjectMgr.GetQuestTemplate(quest_id); if( pQuest ) @@ -725,7 +725,7 @@ void WorldSession::HandleAreaTriggerOpcode(WorldPacket & recv_data) } // enter to tavern, not overwrite city rest - if(sObjectMgr.IsTavernAreaTrigger(Trigger_ID)) + if (sObjectMgr.IsTavernAreaTrigger(Trigger_ID)) { // set resting flag we are in the inn if (pl->GetRestType() != REST_TYPE_IN_CITY) @@ -733,7 +733,7 @@ void WorldSession::HandleAreaTriggerOpcode(WorldPacket & recv_data) return; } - if(pl->InBattleGround()) + if (pl->InBattleGround()) { if (BattleGround* bg = pl->GetBattleGround()) bg->HandleAreaTrigger(pl, Trigger_ID); @@ -742,69 +742,108 @@ void WorldSession::HandleAreaTriggerOpcode(WorldPacket & recv_data) // NULL if all values default (non teleport trigger) AreaTrigger const* at = sObjectMgr.GetAreaTrigger(Trigger_ID); - if(!at) + if (!at) return; - if(!GetPlayer()->isGameMaster()) + MapEntry const* targetMapEntry = sMapStore.LookupEntry(at->target_mapId); + if (!targetMapEntry) + return; + + if (!pl->isGameMaster()) { + // ghost resurrected at enter attempt to dungeon with corpse (including fail enter cases) + if (!pl->isAlive() && targetMapEntry->IsDungeon()) + { + int32 corpseMapId = 0; + if (Corpse *corpse = pl->GetCorpse()) + corpseMapId = corpse->GetMapId(); + + // check back way from corpse to entrance + uint32 instance_map = corpseMapId; + do + { + // most often fast case + if (instance_map==targetMapEntry->MapID) + break; + + InstanceTemplate const* instance = ObjectMgr::GetInstanceTemplate(instance_map); + instance_map = instance ? instance->parent : 0; + } + while (instance_map); + + // corpse not in dungeon or some linked deep dungeons + if (!instance_map) + { + WorldPacket data(SMSG_AREA_TRIGGER_NO_CORPSE); + pl->GetSession()->SendPacket(&data); + return; + } + + // need find areatrigger to inner dungeon for landing point + if (at->target_mapId != corpseMapId) + if (AreaTrigger const* corpseAt = sObjectMgr.GetMapEntranceTrigger(corpseMapId)) + at = corpseAt; + + // now we can resurrect player, and then check teleport requirements + pl->ResurrectPlayer(0.5f); + pl->SpawnCorpseBones(); + } + + // check trigger requirements bool missingItem = false; bool missingLevel = false; bool missingQuest = false; - if(GetPlayer()->getLevel() < at->requiredLevel && !sWorld.getConfig(CONFIG_BOOL_INSTANCE_IGNORE_LEVEL)) + if (pl->getLevel() < at->requiredLevel && !sWorld.getConfig(CONFIG_BOOL_INSTANCE_IGNORE_LEVEL)) missingLevel = true; // must have one or the other, report the first one that's missing - if(at->requiredItem) + if (at->requiredItem) { - if(!GetPlayer()->HasItemCount(at->requiredItem, 1) && + if (!pl->HasItemCount(at->requiredItem, 1) && (!at->requiredItem2 || !GetPlayer()->HasItemCount(at->requiredItem2, 1))) missingItem = true; } - else if(at->requiredItem2 && !GetPlayer()->HasItemCount(at->requiredItem2, 1)) + else if (at->requiredItem2 && !pl->HasItemCount(at->requiredItem2, 1)) missingItem = true; - MapEntry const* mapEntry = sMapStore.LookupEntry(at->target_mapId); - if(!mapEntry) - return; - - bool isRegularTargetMap = !mapEntry->IsDungeon() || GetPlayer()->GetDifficulty(mapEntry->IsRaid()) == REGULAR_DIFFICULTY; + bool isRegularTargetMap = !targetMapEntry->IsDungeon() || pl->GetDifficulty(targetMapEntry->IsRaid()) == REGULAR_DIFFICULTY; if (!isRegularTargetMap) { - if(at->heroicKey) + if (at->heroicKey) { - if(!GetPlayer()->HasItemCount(at->heroicKey, 1) && - (!at->heroicKey2 || !GetPlayer()->HasItemCount(at->heroicKey2, 1))) + if (!pl->HasItemCount(at->heroicKey, 1) && + (!at->heroicKey2 || !pl->HasItemCount(at->heroicKey2, 1))) missingItem = true; } - else if(at->heroicKey2 && !GetPlayer()->HasItemCount(at->heroicKey2, 1)) + else if (at->heroicKey2 && !pl->HasItemCount(at->heroicKey2, 1)) missingItem = true; } if (!isRegularTargetMap) { - if (at->requiredQuestHeroic && !GetPlayer()->GetQuestRewardStatus(at->requiredQuestHeroic)) + if (at->requiredQuestHeroic && !pl->GetQuestRewardStatus(at->requiredQuestHeroic)) missingQuest = true; } else { - if (at->requiredQuest && !GetPlayer()->GetQuestRewardStatus(at->requiredQuest)) + if (at->requiredQuest && !pl->GetQuestRewardStatus(at->requiredQuest)) missingQuest = true; } - if(missingItem || missingLevel || missingQuest) + if (missingItem || missingLevel || missingQuest) { // hack for "Opening of the Dark Portal" - if(missingQuest && at->target_mapId == 269) + if (missingQuest && at->target_mapId == 269) SendAreaTriggerMessage("%s", at->requiredFailedText.c_str()); - else if(missingQuest && mapEntry->IsContinent())// do not report anything for quest areatriggers + else if (missingQuest && targetMapEntry->IsContinent())// do not report anything for quest areatriggers return; // hack for TBC heroics - else if(missingLevel && !mapEntry->IsRaid() && GetPlayer()->GetDifficulty(false) == DUNGEON_DIFFICULTY_HEROIC && mapEntry->addon == 1) + else if (missingLevel && !targetMapEntry->IsRaid() && GetPlayer()->GetDifficulty(false) == DUNGEON_DIFFICULTY_HEROIC && targetMapEntry->addon == 1) SendAreaTriggerMessage(GetMangosString(LANG_LEVEL_MINREQUIRED), at->requiredLevel); else - GetPlayer()->SendTransferAborted(at->target_mapId, TRANSFER_ABORT_DIFFICULTY, GetPlayer()->GetDifficulty(mapEntry->IsRaid())); + pl->SendTransferAborted(at->target_mapId, TRANSFER_ABORT_DIFFICULTY, pl->GetDifficulty(targetMapEntry->IsRaid())); return; } } diff --git a/src/game/MovementHandler.cpp b/src/game/MovementHandler.cpp index 7ecd4bdbbdc..ea77930c748 100644 --- a/src/game/MovementHandler.cpp +++ b/src/game/MovementHandler.cpp @@ -169,17 +169,6 @@ void WorldSession::HandleMoveWorldportAckOpcode() GetPlayer()->m_taxi.ClearTaxiDestinations(); } - // resurrect character at enter into instance where his corpse exist after add to map - Corpse *corpse = GetPlayer()->GetCorpse(); - if (corpse && corpse->GetType() != CORPSE_BONES && corpse->GetMapId() == GetPlayer()->GetMapId()) - { - if( mEntry->IsDungeon() ) - { - GetPlayer()->ResurrectPlayer(0.5f); - GetPlayer()->SpawnCorpseBones(); - } - } - if (mInstance) { Difficulty diff = GetPlayer()->GetDifficulty(mEntry->IsRaid()); diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index 463715536d5..745dc02c9b3 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 "11445" + #define REVISION_NR "11446" #endif // __REVISION_NR_H__ From 6c97f77d892a0bab04f203cfc882d60ad9f003ac Mon Sep 17 00:00:00 2001 From: NoFantasy Date: Sun, 8 May 2011 23:05:06 +0200 Subject: [PATCH 13/43] [11447] Make SPELL_AURA_MIRROR_IMAGE work also for TARGET_SCRIPT Not the best solution though, and should figure out a more nice way to deal with it. Signed-off-by: NoFantasy --- src/game/Spell.cpp | 6 +++++- src/shared/revision_nr.h | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/game/Spell.cpp b/src/game/Spell.cpp index 2ae97b3a512..114734ad3d7 100644 --- a/src/game/Spell.cpp +++ b/src/game/Spell.cpp @@ -5535,10 +5535,14 @@ SpellCastResult Spell::CheckCast(bool strict) { Unit* pTarget = m_targets.getUnitTarget(); + // In case of TARGET_SCRIPT, we have already added a target. Use it here (and find a better solution) + if (m_UniqueTargetInfo.size() == 1) + pTarget = m_caster->GetMap()->GetAnyTypeCreature(m_UniqueTargetInfo.front().targetGUID); + if (!pTarget) return SPELL_FAILED_BAD_TARGETS; - if (pTarget->GetTypeId() != TYPEID_UNIT) // Target must be creature + if (pTarget->GetTypeId() != TYPEID_UNIT) // Target must be creature. TODO: Check if target can also be player return SPELL_FAILED_BAD_TARGETS; if (pTarget == m_caster) // Clone self can't be accepted diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index 745dc02c9b3..e7b818bf4a0 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 "11446" + #define REVISION_NR "11447" #endif // __REVISION_NR_H__ From 4bec054fb54e8f60fe3773935c73e8af972df0c2 Mon Sep 17 00:00:00 2001 From: VladimirMangos Date: Mon, 9 May 2011 01:07:45 +0400 Subject: [PATCH 14/43] [11448] Fixed typo as source for recent crashes at quest start. Also more stricjed typecheck for Object::isType arg value. --- src/game/Camera.cpp | 2 +- src/game/Object.h | 2 +- src/game/Player.cpp | 2 +- src/shared/revision_nr.h | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/game/Camera.cpp b/src/game/Camera.cpp index 8eb2093d443..a1105613766 100644 --- a/src/game/Camera.cpp +++ b/src/game/Camera.cpp @@ -65,7 +65,7 @@ void Camera::SetView(WorldObject *obj, bool update_far_sight_field /*= true*/) return; } - if (!obj->isType(TYPEMASK_DYNAMICOBJECT | TYPEMASK_UNIT)) + if (!obj->isType(TypeMask(TYPEMASK_DYNAMICOBJECT | TYPEMASK_UNIT))) { sLog.outError("Camera::SetView, viewpoint type is not available for client"); return; diff --git a/src/game/Object.h b/src/game/Object.h index 072b9baf5b6..a2f583bf584 100644 --- a/src/game/Object.h +++ b/src/game/Object.h @@ -154,7 +154,7 @@ class MANGOS_DLL_SPEC Object void SetObjectScale(float newScale); uint8 GetTypeId() const { return m_objectTypeId; } - bool isType(uint16 mask) const { return (mask & m_objectType); } + bool isType(TypeMask mask) const { return (mask & m_objectType); } virtual void BuildCreateUpdateBlockForPlayer( UpdateData *data, Player *target ) const; void SendCreateUpdateToPlayer(Player* player); diff --git a/src/game/Player.cpp b/src/game/Player.cpp index 94b0d0db609..7d326fa2137 100644 --- a/src/game/Player.cpp +++ b/src/game/Player.cpp @@ -13737,7 +13737,7 @@ void Player::AddQuest( Quest const *pQuest, Object *questGiver ) } // remove start item if not need - if (questGiver && questGiver->isType(TYPEID_ITEM)) + if (questGiver && questGiver->isType(TYPEMASK_ITEM)) { // destroy not required for quest finish quest starting item bool notRequiredItem = true; diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index e7b818bf4a0..b0e1e2dff48 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 "11447" + #define REVISION_NR "11448" #endif // __REVISION_NR_H__ From dea7a468eb642f5e90011bd8430a86e626f57568 Mon Sep 17 00:00:00 2001 From: NoFantasy Date: Mon, 9 May 2011 00:06:00 +0200 Subject: [PATCH 15/43] [11449] Correct script effect of spell 50218 Also for related copy weapon/copy offhand weapon Signed-off-by: NoFantasy --- src/game/SpellEffects.cpp | 8 ++++---- src/shared/revision_nr.h | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/game/SpellEffects.cpp b/src/game/SpellEffects.cpp index 401d594d621..66aaf081034 100644 --- a/src/game/SpellEffects.cpp +++ b/src/game/SpellEffects.cpp @@ -6498,7 +6498,7 @@ void Spell::EffectScriptEffect(SpellEffectIndex eff_idx) if (m_caster->GetTypeId() != TYPEID_UNIT || !unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER) return; - if (Item* pItem = ((Player*)unitTarget)->GetWeaponForAttack(BASE_ATTACK)) + if (Item* pItem = ((Player*)unitTarget)->GetItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_MAINHAND)) { ((Creature*)m_caster)->SetVirtualItem(VIRTUAL_ITEM_SLOT_0, pItem->GetEntry()); @@ -6620,7 +6620,7 @@ void Spell::EffectScriptEffect(SpellEffectIndex eff_idx) if (m_caster->GetTypeId() != TYPEID_UNIT || !unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER) return; - if (Item* pItem = ((Player*)unitTarget)->GetWeaponForAttack(OFF_ATTACK)) + if (Item* pItem = ((Player*)unitTarget)->GetItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_OFFHAND)) { ((Creature*)m_caster)->SetVirtualItem(VIRTUAL_ITEM_SLOT_1, pItem->GetEntry()); @@ -6884,12 +6884,12 @@ void Spell::EffectScriptEffect(SpellEffectIndex eff_idx) switch(eff_idx) { case EFFECT_INDEX_1: - if (((Player*)m_originalCaster)->GetWeaponForAttack(BASE_ATTACK)) + if (((Player*)m_originalCaster)->GetItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_MAINHAND)) unitTarget->CastSpell(m_originalCaster, m_spellInfo->CalculateSimpleValue(eff_idx), true); return; case EFFECT_INDEX_2: - if (((Player*)m_originalCaster)->GetWeaponForAttack(OFF_ATTACK)) + if (((Player*)m_originalCaster)->GetItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_OFFHAND)) unitTarget->CastSpell(m_originalCaster, m_spellInfo->CalculateSimpleValue(eff_idx), true); return; diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index b0e1e2dff48..a1a631855eb 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 "11448" + #define REVISION_NR "11449" #endif // __REVISION_NR_H__ From cd0a28b261a5ebf9fbc77db0d4b2e25a04e1d4eb Mon Sep 17 00:00:00 2001 From: Most_Mangos Date: Mon, 9 May 2011 03:02:10 +0400 Subject: [PATCH 16/43] [11450] Aloow stacking some warlock DoTs Signed-off-by: VladimirMangos --- src/game/SpellMgr.cpp | 10 ++++++++++ src/shared/revision_nr.h | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/game/SpellMgr.cpp b/src/game/SpellMgr.cpp index b0230c74ae2..c4f656ae4bf 100644 --- a/src/game/SpellMgr.cpp +++ b/src/game/SpellMgr.cpp @@ -2045,6 +2045,16 @@ bool SpellMgr::IsNoStackSpellDueToSpell(uint32 spellId_1, uint32 spellId_2) cons ((spellInfo_2->SpellIconID == 313 || spellInfo_2->SpellIconID == 2039) && (spellInfo_1->SpellIconID == 544 || spellInfo_1->SpellIconID == 91))) return false; + // Shadowflame and Curse of Agony + if( spellInfo_1->SpellIconID == 544 && spellInfo_2->SpellIconID == 3317 || + spellInfo_2->SpellIconID == 544 && spellInfo_1->SpellIconID == 3317 ) + return false; + + // Shadowflame and Curse of Doom + if( spellInfo_1->SpellIconID == 91 && spellInfo_2->SpellIconID == 3317 || + spellInfo_2->SpellIconID == 91 && spellInfo_1->SpellIconID == 3317 ) + return false; + // Metamorphosis, diff effects if (spellInfo_1->SpellIconID == 3314 && spellInfo_2->SpellIconID == 3314) return false; diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index a1a631855eb..17e2edca180 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 "11449" + #define REVISION_NR "11450" #endif // __REVISION_NR_H__ From ea490ba8643062c6f091315124893aecddfc755f Mon Sep 17 00:00:00 2001 From: bwsrv Date: Mon, 9 May 2011 04:18:19 +0400 Subject: [PATCH 17/43] [11451] Fixed proc talent 63156 and ranks from 6353 and ranks. Signed-off-by: VladimirMangos --- sql/mangos.sql | 2 +- sql/updates/9_01_mangos_spell_proc_event.sql | 3 +++ src/shared/revision_nr.h | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) create mode 100644 sql/updates/9_01_mangos_spell_proc_event.sql diff --git a/sql/mangos.sql b/sql/mangos.sql index 11f37bb8a72..c55256d6418 100644 --- a/sql/mangos.sql +++ b/sql/mangos.sql @@ -17536,7 +17536,7 @@ INSERT INTO `spell_proc_event` VALUES (62147, 0x00, 15, 0x00000002, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00010000, 0x00000000, 0.000000, 0.000000, 0), (62600, 0x7F, 7, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000002, 0.000000, 0.000000, 0), (63108, 0x00, 5, 0x00000002, 0x00000002, 0x00000002, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0.000000, 0.000000, 0), -(63156, 0x00, 0, 0x00000001, 0x00000001, 0x00000001, 0x00000040, 0x00000040, 0x00000040, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0.000000, 0.000000, 0), +(63156, 0x00, 5, 0x00000001, 0x00000001, 0x00000001, 0x000000C0, 0x000000C0, 0x000000C0, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0.000000, 0.000000, 0), (63251, 0x7F, 0, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0.000000, 0.000000, 45), (63280, 0x00, 11, 0x20000000, 0x20000000, 0x20000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0.000000, 0.000000, 0), (63320, 0x00, 5, 0x00040000, 0x00040000, 0x00040000, 0x00000000, 0x00000000, 0x00000000, 0x00008000, 0x00008000, 0x00008000, 0x00004000, 0x00000001, 0.000000, 0.000000, 0), diff --git a/sql/updates/9_01_mangos_spell_proc_event.sql b/sql/updates/9_01_mangos_spell_proc_event.sql new file mode 100644 index 00000000000..e26f97c7058 --- /dev/null +++ b/sql/updates/9_01_mangos_spell_proc_event.sql @@ -0,0 +1,3 @@ +DELETE FROM spell_proc_event WHERE entry = 63156; +INSERT INTO spell_proc_event VALUES +(63156, 0x00, 5, 0x00000001, 0x00000001, 0x00000001, 0x000000C0, 0x000000C0, 0x000000C0, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0.000000, 0.000000, 0); diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index 17e2edca180..3a5b20cb876 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 "11450" + #define REVISION_NR "11451" #endif // __REVISION_NR_H__ From a9b664a4c7dde6c91c246fe687ff97f28619cfa7 Mon Sep 17 00:00:00 2001 From: stfxpi Date: Mon, 9 May 2011 05:26:32 +0400 Subject: [PATCH 18/43] [11452] Implement spell 14537 effects. Also re-add in correct way sql update for prev. commit. Signed-off-by: VladimirMangos --- sql/mangos.sql | 8 +++-- .../11452_01_mangos_spell_bonus_data.sql | 7 +++++ ...l => 11452_02_mangos_spell_proc_event.sql} | 2 ++ src/game/SpellEffects.cpp | 31 +++++++++++++++++++ src/shared/revision_nr.h | 2 +- src/shared/revision_sql.h | 2 +- 6 files changed, 48 insertions(+), 4 deletions(-) create mode 100644 sql/updates/11452_01_mangos_spell_bonus_data.sql rename sql/updates/{9_01_mangos_spell_proc_event.sql => 11452_02_mangos_spell_proc_event.sql} (67%) diff --git a/sql/mangos.sql b/sql/mangos.sql index c55256d6418..c9ad7899b86 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_11433_01_mangos_item_template` bit(1) default NULL + `required_11452_02_mangos_spell_proc_event` bit(1) default NULL ) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Used DB version notes'; -- @@ -14664,9 +14664,13 @@ INSERT INTO `spell_bonus_data` VALUES (17712, 0, 0, 0, 0, 'Item - Lifestone Healing'), (5707, 0, 0, 0, 0, 'Item - Lifestone Regeneration'), (43733, 0, 0, 0, 0, 'Item - Lightning Zap'), +(71824, 0, 0, 0, 0, 'Item - Shaman T9 Elemental 4P Bonus'), (38395, 0, 0, 0, 0, 'Item - Siphon Essence'), (40293, 0, 0, 0, 0, 'Item - Siphon Essence'), -(71824, 0, 0, 0, 0, 'Item - Shaman T9 Elemental 4P Bonus'); +(21179, 0, 0, 0, 0, 'Item - Six Demon Bag - Chain Lightning'), +(15662, 0, 0, 0, 0, 'Item - Six Demon Bag - Fireball'), +(11538, 0, 0, 0, 0, 'Item - Six Demon Bag - Frostbolt'); + /*!40000 ALTER TABLE `spell_bonus_data` ENABLE KEYS */; UNLOCK TABLES; diff --git a/sql/updates/11452_01_mangos_spell_bonus_data.sql b/sql/updates/11452_01_mangos_spell_bonus_data.sql new file mode 100644 index 00000000000..1581f979c40 --- /dev/null +++ b/sql/updates/11452_01_mangos_spell_bonus_data.sql @@ -0,0 +1,7 @@ +ALTER TABLE db_version CHANGE COLUMN required_11433_01_mangos_item_template required_11452_01_mangos_spell_bonus_data bit; + +DELETE FROM spell_bonus_data WHERE entry IN (15662, 11538, 21179); +INSERT INTO spell_bonus_data VALUES +(15662, 0, 0, 0, 0, 'Item - Six Demon Bag - Fireball'), +(11538, 0, 0, 0, 0, 'Item - Six Demon Bag - Frostbolt'), +(21179, 0, 0, 0, 0, 'Item - Six Demon Bag - Chain Lightning'); diff --git a/sql/updates/9_01_mangos_spell_proc_event.sql b/sql/updates/11452_02_mangos_spell_proc_event.sql similarity index 67% rename from sql/updates/9_01_mangos_spell_proc_event.sql rename to sql/updates/11452_02_mangos_spell_proc_event.sql index e26f97c7058..331cbe41532 100644 --- a/sql/updates/9_01_mangos_spell_proc_event.sql +++ b/sql/updates/11452_02_mangos_spell_proc_event.sql @@ -1,3 +1,5 @@ +ALTER TABLE db_version CHANGE COLUMN required_11452_01_mangos_spell_bonus_data required_11452_02_mangos_spell_proc_event bit; + DELETE FROM spell_proc_event WHERE entry = 63156; INSERT INTO spell_proc_event VALUES (63156, 0x00, 5, 0x00000001, 0x00000001, 0x00000001, 0x000000C0, 0x000000C0, 0x000000C0, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0.000000, 0.000000, 0); diff --git a/src/game/SpellEffects.cpp b/src/game/SpellEffects.cpp index 66aaf081034..fd7e20dfad8 100644 --- a/src/game/SpellEffects.cpp +++ b/src/game/SpellEffects.cpp @@ -887,6 +887,37 @@ void Spell::EffectDummy(SpellEffectIndex eff_idx) } return; } + case 14537: // Six Demon Bag + { + if (!unitTarget) + return; + + Unit* newTarget = unitTarget; + uint32 spell_id = 0; + uint32 roll = urand(0, 99); + if (roll < 25) // Fireball (25% chance) + spell_id = 15662; + else if (roll < 50) // Frostbolt (25% chance) + spell_id = 11538; + else if (roll < 70) // Chain Lighting (20% chance) + spell_id = 21179; + else if (roll < 80) // Polymorph (10% chance) + { + spell_id = 14621; + if (urand(0, 9) < 3) // 30% chance to self-cast + newTarget = m_caster; + } + else if (roll < 95) // Enveloping Winds (15% chance) + spell_id = 25189; + else // Summon Felhund minion (5% chance) + { + spell_id = 14642; + newTarget = m_caster; + } + + m_caster->CastSpell(newTarget, spell_id, true, m_CastItem); + return; + } case 15998: // Capture Worg Pup case 29435: // Capture Female Kaliri Hatchling { diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index 3a5b20cb876..501af71f717 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 "11451" + #define REVISION_NR "11452" #endif // __REVISION_NR_H__ diff --git a/src/shared/revision_sql.h b/src/shared/revision_sql.h index 6c3a4bfc333..506599e8849 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_11433_01_mangos_item_template" + #define REVISION_DB_MANGOS "required_11452_02_mangos_spell_proc_event" #define REVISION_DB_REALMD "required_10008_01_realmd_realmd_db_version" #endif // __REVISION_SQL_H__ From d7df75c7645f0d55f5ead1c717ff0d9ec0838618 Mon Sep 17 00:00:00 2001 From: Den Date: Mon, 9 May 2011 05:49:22 +0400 Subject: [PATCH 19/43] [11453] Fixed tier 8 4p bonus affect work Also small spells ordering fix in `spell_proc_event`. Signed-off-by: VladimirMangos --- sql/mangos.sql | 9 +++++---- sql/updates/11453_01_mangos_spell_proc_event.sql | 5 +++++ src/shared/revision_nr.h | 2 +- src/shared/revision_sql.h | 2 +- 4 files changed, 12 insertions(+), 6 deletions(-) create mode 100644 sql/updates/11453_01_mangos_spell_proc_event.sql diff --git a/sql/mangos.sql b/sql/mangos.sql index c9ad7899b86..130069b9a57 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_11452_02_mangos_spell_proc_event` bit(1) default NULL + `required_11453_01_mangos_spell_proc_event` bit(1) default NULL ) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Used DB version notes'; -- @@ -17547,12 +17547,13 @@ INSERT INTO `spell_proc_event` VALUES (63335, 0x00, 15, 0x00000000, 0x00000000, 0x00000000, 0x00000002, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0.000000, 0.000000, 0), (63373, 0x00, 11, 0x80000000, 0x80000000, 0x80000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00010000, 0x00000000, 0.000000, 0.000000, 0), (63534, 0x00, 6, 0x00000040, 0x00000040, 0x00000040, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00004000, 0x00000000, 0.000000, 0.000000, 0), -(64440, 0x7F, 0, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000020, 0.000000, 0.000000, 0), -(64952, 0x00, 7, 0x00000000, 0x00000000, 0x00000000, 0x00000440, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0.000000, 0.000000, 0), -(64964, 0x00, 15, 0x00000000, 0x00000000, 0x00000000, 0x20000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0.000000, 0.000000, 0), (63611, 0x7F, 0, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00050014, 0x00000000, 0.000000, 0.000000, 0), (63625, 0x00, 6, 0x02000000, 0x02000000, 0x02000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00010000, 0x00000000, 0.000000, 0.000000, 0), (63730, 0x00, 6, 0x00000800, 0x00000800, 0x00000800, 0x00000004, 0x00000004, 0x00000004, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0.000000, 0.000000, 0), +(64440, 0x7F, 0, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000020, 0.000000, 0.000000, 0), +(64860, 0x00, 9, 0x00000000, 0x00000000, 0x00000000, 0x00000001, 0x00000001, 0x00000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0.000000, 0.000000, 0), +(64952, 0x00, 7, 0x00000000, 0x00000000, 0x00000000, 0x00000440, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0.000000, 0.000000, 0), +(64964, 0x00, 15, 0x00000000, 0x00000000, 0x00000000, 0x20000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0.000000, 0.000000, 0), (64928, 0x00, 11, 0x00000001, 0x00000001, 0x00000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000002, 0.000000, 0.000000, 0), (64976, 0x00, 4, 0x00000001, 0x00000001, 0x00000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00010000, 0x00000000, 0.000000, 0.000000, 0), (65661, 0x00, 15, 0x00400011 ,0x00400011, 0x00400011, 0x20020004, 0x20020004, 0x20020004, 0x00000000, 0x00000000, 0x00000000, 0x00000010, 0x00000000, 0.000000, 100.000000,0), diff --git a/sql/updates/11453_01_mangos_spell_proc_event.sql b/sql/updates/11453_01_mangos_spell_proc_event.sql new file mode 100644 index 00000000000..b71059d8ccc --- /dev/null +++ b/sql/updates/11453_01_mangos_spell_proc_event.sql @@ -0,0 +1,5 @@ +ALTER TABLE db_version CHANGE COLUMN required_11452_02_mangos_spell_proc_event required_11453_01_mangos_spell_proc_event bit; + +DELETE FROM spell_proc_event WHERE entry = 64860; +INSERT INTO spell_proc_event VALUES +(64860, 0x00, 9, 0x00000000, 0x00000000, 0x00000000, 0x00000001, 0x00000001, 0x00000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0.000000, 0.000000, 0); diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index 501af71f717..39b93ec9119 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 "11452" + #define REVISION_NR "11453" #endif // __REVISION_NR_H__ diff --git a/src/shared/revision_sql.h b/src/shared/revision_sql.h index 506599e8849..8db31725132 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_11452_02_mangos_spell_proc_event" + #define REVISION_DB_MANGOS "required_11453_01_mangos_spell_proc_event" #define REVISION_DB_REALMD "required_10008_01_realmd_realmd_db_version" #endif // __REVISION_SQL_H__ From 69d3d3ea2f8b2c64b16a797a350aab52e364cdc3 Mon Sep 17 00:00:00 2001 From: VladimirMangos Date: Mon, 9 May 2011 19:09:45 +0400 Subject: [PATCH 20/43] [11454] Use ObjectGuid in class Loot --- src/game/LootHandler.cpp | 2 +- src/game/LootMgr.cpp | 76 ++++++++++++++++++++-------------------- src/game/LootMgr.h | 46 +++++++++++++----------- src/game/Player.cpp | 2 +- src/shared/revision_nr.h | 2 +- 5 files changed, 66 insertions(+), 62 deletions(-) diff --git a/src/game/LootHandler.cpp b/src/game/LootHandler.cpp index c6ec875ff2e..55e84c6f647 100644 --- a/src/game/LootHandler.cpp +++ b/src/game/LootHandler.cpp @@ -495,7 +495,7 @@ void WorldSession::DoLootRelease(ObjectGuid lguid) } //Player is not looking at loot list, he doesn't need to see updates on the loot list - loot->RemoveLooter(player->GetGUID()); + loot->RemoveLooter(player->GetObjectGuid()); } void WorldSession::HandleLootMasterGiveOpcode( WorldPacket & recv_data ) diff --git a/src/game/LootMgr.cpp b/src/game/LootMgr.cpp index 20a6fb6b29d..1340a7e5ac7 100644 --- a/src/game/LootMgr.cpp +++ b/src/game/LootMgr.cpp @@ -422,8 +422,8 @@ void Loot::AddItem(LootStoreItem const & item) { if (item.needs_quest) // Quest drop { - if (quest_items.size() < MAX_NR_QUEST_ITEMS) - quest_items.push_back(LootItem(item)); + if (m_questItems.size() < MAX_NR_QUEST_ITEMS) + m_questItems.push_back(LootItem(item)); } else if (items.size() < MAX_NR_LOOT_ITEMS) // Non-quest drop { @@ -458,7 +458,7 @@ bool Loot::FillLoot(uint32 loot_id, LootStore const& store, Player* loot_owner, } items.reserve(MAX_NR_LOOT_ITEMS); - quest_items.reserve(MAX_NR_QUEST_ITEMS); + m_questItems.reserve(MAX_NR_QUEST_ITEMS); tab->Process(*this, store,store.IsRatesAllowed ()); // Processing is done there, callback via Loot::AddItem() @@ -481,16 +481,16 @@ void Loot::FillNotNormalLootFor(Player* pl) { uint32 plguid = pl->GetGUIDLow(); - QuestItemMap::const_iterator qmapitr = PlayerQuestItems.find(plguid); - if (qmapitr == PlayerQuestItems.end()) + QuestItemMap::const_iterator qmapitr = m_playerQuestItems.find(plguid); + if (qmapitr == m_playerQuestItems.end()) FillQuestLoot(pl); - qmapitr = PlayerFFAItems.find(plguid); - if (qmapitr == PlayerFFAItems.end()) + qmapitr = m_playerFFAItems.find(plguid); + if (qmapitr == m_playerFFAItems.end()) FillFFALoot(pl); - qmapitr = PlayerNonQuestNonFFAConditionalItems.find(plguid); - if (qmapitr == PlayerNonQuestNonFFAConditionalItems.end()) + qmapitr = m_playerNonQuestNonFFAConditionalItems.find(plguid); + if (qmapitr == m_playerNonQuestNonFFAConditionalItems.end()) FillNonQuestNonFFAConditionalLoot(pl); } @@ -513,7 +513,7 @@ QuestItemList* Loot::FillFFALoot(Player* player) return NULL; } - PlayerFFAItems[player->GetGUIDLow()] = ql; + m_playerFFAItems[player->GetGUIDLow()] = ql; return ql; } @@ -522,9 +522,9 @@ QuestItemList* Loot::FillQuestLoot(Player* player) if (items.size() == MAX_NR_LOOT_ITEMS) return NULL; QuestItemList *ql = new QuestItemList(); - for(uint8 i = 0; i < quest_items.size(); ++i) + for(uint8 i = 0; i < m_questItems.size(); ++i) { - LootItem &item = quest_items[i]; + LootItem &item = m_questItems[i]; if(!item.is_looted && item.AllowedForPlayer(player) ) { ql->push_back(QuestItem(i)); @@ -548,7 +548,7 @@ QuestItemList* Loot::FillQuestLoot(Player* player) return NULL; } - PlayerQuestItems[player->GetGUIDLow()] = ql; + m_playerQuestItems[player->GetGUIDLow()] = ql; return ql; } @@ -575,7 +575,7 @@ QuestItemList* Loot::FillNonQuestNonFFAConditionalLoot(Player* player) return NULL; } - PlayerNonQuestNonFFAConditionalItems[player->GetGUIDLow()] = ql; + m_playerNonQuestNonFFAConditionalItems[player->GetGUIDLow()] = ql; return ql; } @@ -585,30 +585,30 @@ void Loot::NotifyItemRemoved(uint8 lootIndex) { // notify all players that are looting this that the item was removed // convert the index to the slot the player sees - std::set::iterator i_next; - for(std::set::iterator i = PlayersLooting.begin(); i != PlayersLooting.end(); i = i_next) + PlayersLooting::iterator i_next; + for (PlayersLooting::iterator i = m_playersLooting.begin(); i != m_playersLooting.end(); i = i_next) { i_next = i; ++i_next; - if(Player* pl = ObjectAccessor::FindPlayer(*i)) + if (Player* pl = ObjectAccessor::FindPlayer(*i)) pl->SendNotifyLootItemRemoved(lootIndex); else - PlayersLooting.erase(i); + m_playersLooting.erase(i); } } void Loot::NotifyMoneyRemoved() { // notify all players that are looting this that the money was removed - std::set::iterator i_next; - for(std::set::iterator i = PlayersLooting.begin(); i != PlayersLooting.end(); i = i_next) + PlayersLooting::iterator i_next; + for (PlayersLooting::iterator i = m_playersLooting.begin(); i != m_playersLooting.end(); i = i_next) { i_next = i; ++i_next; - if(Player* pl = ObjectAccessor::FindPlayer(*i)) + if (Player* pl = ObjectAccessor::FindPlayer(*i)) pl->SendNotifyLootMoneyRemoved(); else - PlayersLooting.erase(i); + m_playersLooting.erase(i); } } @@ -619,15 +619,15 @@ void Loot::NotifyQuestItemRemoved(uint8 questIndex) // (other questitems can be looted by each group member) // bit inefficient but isnt called often - std::set::iterator i_next; - for(std::set::iterator i = PlayersLooting.begin(); i != PlayersLooting.end(); i = i_next) + PlayersLooting::iterator i_next; + for (PlayersLooting::iterator i = m_playersLooting.begin(); i != m_playersLooting.end(); i = i_next) { i_next = i; ++i_next; - if(Player* pl = ObjectAccessor::FindPlayer(*i)) + if (Player* pl = ObjectAccessor::FindPlayer(*i)) { - QuestItemMap::const_iterator pq = PlayerQuestItems.find(pl->GetGUIDLow()); - if (pq != PlayerQuestItems.end() && pq->second) + QuestItemMap::const_iterator pq = m_playerQuestItems.find(pl->GetGUIDLow()); + if (pq != m_playerQuestItems.end() && pq->second) { // find where/if the player has the given item in it's vector QuestItemList& pql = *pq->second; @@ -642,7 +642,7 @@ void Loot::NotifyQuestItemRemoved(uint8 questIndex) } } else - PlayersLooting.erase(i); + m_playersLooting.erase(i); } } @@ -666,13 +666,13 @@ LootItem* Loot::LootItemInSlot(uint32 lootSlot, Player* player, QuestItem **qite if (lootSlot >= items.size()) { uint32 questSlot = lootSlot - items.size(); - QuestItemMap::const_iterator itr = PlayerQuestItems.find(player->GetGUIDLow()); - if (itr != PlayerQuestItems.end() && questSlot < itr->second->size()) + QuestItemMap::const_iterator itr = m_playerQuestItems.find(player->GetGUIDLow()); + if (itr != m_playerQuestItems.end() && questSlot < itr->second->size()) { QuestItem *qitem2 = &itr->second->at(questSlot); if(qitem) *qitem = qitem2; - item = &quest_items[qitem2->index]; + item = &m_questItems[qitem2->index]; is_looted = qitem2->is_looted; } } @@ -682,8 +682,8 @@ LootItem* Loot::LootItemInSlot(uint32 lootSlot, Player* player, QuestItem **qite is_looted = item->is_looted; if(item->freeforall) { - QuestItemMap::const_iterator itr = PlayerFFAItems.find(player->GetGUIDLow()); - if (itr != PlayerFFAItems.end()) + QuestItemMap::const_iterator itr = m_playerFFAItems.find(player->GetGUIDLow()); + if (itr != m_playerFFAItems.end()) { for(QuestItemList::const_iterator iter=itr->second->begin(); iter!= itr->second->end(); ++iter) if(iter->index==lootSlot) @@ -698,8 +698,8 @@ LootItem* Loot::LootItemInSlot(uint32 lootSlot, Player* player, QuestItem **qite } else if(item->conditionId) { - QuestItemMap::const_iterator itr = PlayerNonQuestNonFFAConditionalItems.find(player->GetGUIDLow()); - if (itr != PlayerNonQuestNonFFAConditionalItems.end()) + QuestItemMap::const_iterator itr = m_playerNonQuestNonFFAConditionalItems.find(player->GetGUIDLow()); + if (itr != m_playerNonQuestNonFFAConditionalItems.end()) { for(QuestItemList::const_iterator iter=itr->second->begin(); iter!= itr->second->end(); ++iter) { @@ -724,8 +724,8 @@ LootItem* Loot::LootItemInSlot(uint32 lootSlot, Player* player, QuestItem **qite uint32 Loot::GetMaxSlotInLootFor(Player* player) const { - QuestItemMap::const_iterator itr = PlayerQuestItems.find(player->GetGUIDLow()); - return items.size() + (itr != PlayerQuestItems.end() ? itr->second->size() : 0); + QuestItemMap::const_iterator itr = m_playerQuestItems.find(player->GetGUIDLow()); + return items.size() + (itr != m_playerQuestItems.end() ? itr->second->size() : 0); } ByteBuffer& operator<<(ByteBuffer& b, LootItem const& li) @@ -802,7 +802,7 @@ ByteBuffer& operator<<(ByteBuffer& b, LootView const& lv) QuestItemList *q_list = q_itr->second; for (QuestItemList::const_iterator qi = q_list->begin() ; qi != q_list->end(); ++qi) { - LootItem &item = l.quest_items[qi->index]; + LootItem &item = l.m_questItems[qi->index]; if (!qi->is_looted && !item.is_looted) { b << uint8(l.items.size() + (qi - q_list->begin())); diff --git a/src/game/LootMgr.h b/src/game/LootMgr.h index f6de6b42d48..532fa84ce1d 100644 --- a/src/game/LootMgr.h +++ b/src/game/LootMgr.h @@ -21,6 +21,7 @@ #include "ItemEnchantmentMgr.h" #include "ByteBuffer.h" +#include "ObjectGuid.h" #include "Utilities/LinkedReference/RefManager.h" #include @@ -235,9 +236,9 @@ struct Loot { friend ByteBuffer& operator<<(ByteBuffer& b, LootView const& lv); - QuestItemMap const& GetPlayerQuestItems() const { return PlayerQuestItems; } - QuestItemMap const& GetPlayerFFAItems() const { return PlayerFFAItems; } - QuestItemMap const& GetPlayerNonQuestNonFFAConditionalItems() const { return PlayerNonQuestNonFFAConditionalItems; } + QuestItemMap const& GetPlayerQuestItems() const { return m_playerQuestItems; } + QuestItemMap const& GetPlayerFFAItems() const { return m_playerFFAItems; } + QuestItemMap const& GetPlayerNonQuestNonFFAConditionalItems() const { return m_playerNonQuestNonFFAConditionalItems; } LootItemList items; uint32 gold; @@ -250,30 +251,30 @@ struct Loot // if loot becomes invalid this reference is used to inform the listener void addLootValidatorRef(LootValidatorRef* pLootValidatorRef) { - i_LootValidatorRefManager.insertFirst(pLootValidatorRef); + m_LootValidatorRefManager.insertFirst(pLootValidatorRef); } // void clear(); void clear() { - for (QuestItemMap::const_iterator itr = PlayerQuestItems.begin(); itr != PlayerQuestItems.end(); ++itr) + for (QuestItemMap::const_iterator itr = m_playerQuestItems.begin(); itr != m_playerQuestItems.end(); ++itr) delete itr->second; - PlayerQuestItems.clear(); + m_playerQuestItems.clear(); - for (QuestItemMap::const_iterator itr = PlayerFFAItems.begin(); itr != PlayerFFAItems.end(); ++itr) + for (QuestItemMap::const_iterator itr = m_playerFFAItems.begin(); itr != m_playerFFAItems.end(); ++itr) delete itr->second; - PlayerFFAItems.clear(); + m_playerFFAItems.clear(); - for (QuestItemMap::const_iterator itr = PlayerNonQuestNonFFAConditionalItems.begin(); itr != PlayerNonQuestNonFFAConditionalItems.end(); ++itr) + for (QuestItemMap::const_iterator itr = m_playerNonQuestNonFFAConditionalItems.begin(); itr != m_playerNonQuestNonFFAConditionalItems.end(); ++itr) delete itr->second; - PlayerNonQuestNonFFAConditionalItems.clear(); + m_playerNonQuestNonFFAConditionalItems.clear(); - PlayersLooting.clear(); + m_playersLooting.clear(); items.clear(); - quest_items.clear(); + m_questItems.clear(); gold = 0; unlootedCount = 0; - i_LootValidatorRefManager.clearReferences(); + m_LootValidatorRefManager.clearReferences(); } bool empty() const { return items.empty() && gold == 0; } @@ -282,8 +283,8 @@ struct Loot void NotifyItemRemoved(uint8 lootIndex); void NotifyQuestItemRemoved(uint8 questIndex); void NotifyMoneyRemoved(); - void AddLooter(uint64 GUID) { PlayersLooting.insert(GUID); } - void RemoveLooter(uint64 GUID) { PlayersLooting.erase(GUID); } + void AddLooter(ObjectGuid guid) { m_playersLooting.insert(guid); } + void RemoveLooter(ObjectGuid guid) { m_playersLooting.erase(guid); } void generateMoneyLoot(uint32 minAmount, uint32 maxAmount); bool FillLoot(uint32 loot_id, LootStore const& store, Player* loot_owner, bool personal, bool noEmptyError = false); @@ -300,14 +301,17 @@ struct Loot QuestItemList* FillQuestLoot(Player* player); QuestItemList* FillNonQuestNonFFAConditionalLoot(Player* player); - LootItemList quest_items; - std::set PlayersLooting; - QuestItemMap PlayerQuestItems; - QuestItemMap PlayerFFAItems; - QuestItemMap PlayerNonQuestNonFFAConditionalItems; + LootItemList m_questItems; + + typedef std::set PlayersLooting; + PlayersLooting m_playersLooting; + + QuestItemMap m_playerQuestItems; + QuestItemMap m_playerFFAItems; + QuestItemMap m_playerNonQuestNonFFAConditionalItems; // All rolls are registered here. They need to know, when the loot is not valid anymore - LootValidatorRefManager i_LootValidatorRefManager; + LootValidatorRefManager m_LootValidatorRefManager; }; struct LootView diff --git a/src/game/Player.cpp b/src/game/Player.cpp index 7d326fa2137..0467fa68e2e 100644 --- a/src/game/Player.cpp +++ b/src/game/Player.cpp @@ -8253,7 +8253,7 @@ void Player::SendLoot(ObjectGuid guid, LootType loot_type) // add 'this' player as one of the players that are looting 'loot' if (permission != NONE_PERMISSION) - loot->AddLooter(GetGUID()); + loot->AddLooter(GetObjectGuid()); if (loot_type == LOOT_CORPSE && !guid.IsItem()) SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_LOOTING); diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index 39b93ec9119..968725682b1 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 "11453" + #define REVISION_NR "11454" #endif // __REVISION_NR_H__ From f3a66ad5c725415d71a7a43e5f702e5a5324c369 Mon Sep 17 00:00:00 2001 From: VladimirMangos Date: Mon, 9 May 2011 19:57:10 +0400 Subject: [PATCH 21/43] [11455] Use ObjectGuid in HashMapHolder --- src/game/GMTicketHandler.cpp | 4 ++-- src/game/LFGHandler.cpp | 22 +++++++++++----------- src/game/Level0.cpp | 2 +- src/game/Level3.cpp | 2 +- src/game/MiscHandler.cpp | 34 ++++++++++++++++++---------------- src/game/ObjectAccessor.cpp | 8 ++++---- src/game/ObjectAccessor.h | 8 ++++---- src/shared/revision_nr.h | 2 +- 8 files changed, 42 insertions(+), 40 deletions(-) diff --git a/src/game/GMTicketHandler.cpp b/src/game/GMTicketHandler.cpp index 432bf0a43c8..45017014895 100644 --- a/src/game/GMTicketHandler.cpp +++ b/src/game/GMTicketHandler.cpp @@ -134,9 +134,9 @@ void WorldSession::HandleGMTicketCreateOpcode( WorldPacket & recv_data ) //TODO: Guard player map HashMapHolder::MapType &m = sObjectAccessor.GetPlayers(); - for(HashMapHolder::MapType::const_iterator itr = m.begin(); itr != m.end(); ++itr) + for (HashMapHolder::MapType::const_iterator itr = m.begin(); itr != m.end(); ++itr) { - if(itr->second->GetSession()->GetSecurity() >= SEC_GAMEMASTER && itr->second->isAcceptTickets()) + if (itr->second->GetSession()->GetSecurity() >= SEC_GAMEMASTER && itr->second->isAcceptTickets()) ChatHandler(itr->second).PSendSysMessage(LANG_COMMAND_TICKETNEW,GetPlayer()->GetName()); } } diff --git a/src/game/LFGHandler.cpp b/src/game/LFGHandler.cpp index c9e25a0b88d..45cc0bb4120 100644 --- a/src/game/LFGHandler.cpp +++ b/src/game/LFGHandler.cpp @@ -142,14 +142,14 @@ void WorldSession::SendLfgSearchResults(LfgType type, uint32 entry) data << uint32(playersSize); // players count data << uint32(playersSize); // players count (total?) - for(HashMapHolder::MapType::const_iterator iter = players.begin(); iter != players.end(); ++iter) + for (HashMapHolder::MapType::const_iterator iter = players.begin(); iter != players.end(); ++iter) { Player *plr = iter->second; - if(!plr || plr->GetTeam() != _player->GetTeam()) + if (!plr || plr->GetTeam() != _player->GetTeam()) continue; - if(!plr->IsInWorld()) + if (!plr->IsInWorld()) continue; data << plr->GetObjectGuid(); // guid @@ -157,7 +157,7 @@ void WorldSession::SendLfgSearchResults(LfgType type, uint32 entry) uint32 flags = 0xFF; data << uint32(flags); // flags - if(flags & 0x1) + if (flags & 0x1) { data << uint8(plr->getLevel()); data << uint8(plr->getClass()); @@ -188,25 +188,25 @@ void WorldSession::SendLfgSearchResults(LfgType type, uint32 entry) data << uint32(0); // Expertise } - if(flags & 0x2) + if (flags & 0x2) data << ""; // comment - if(flags & 0x4) + if (flags & 0x4) data << uint8(0); // group leader - if(flags & 0x8) + if (flags & 0x8) data << uint64(1); // group guid - if(flags & 0x10) + if (flags & 0x10) data << uint8(0); // roles - if(flags & 0x20) + if (flags & 0x20) data << uint32(plr->GetZoneId()); // areaid - if(flags & 0x40) + if (flags & 0x40) data << uint8(0); // status - if(flags & 0x80) + if (flags & 0x80) { data << uint64(0); // instance guid data << uint32(0); // completed encounters diff --git a/src/game/Level0.cpp b/src/game/Level0.cpp index 37f5701281d..d0dab5230e5 100644 --- a/src/game/Level0.cpp +++ b/src/game/Level0.cpp @@ -170,7 +170,7 @@ bool ChatHandler::HandleGMListIngameCommand(char* /*args*/) { HashMapHolder::ReadGuard g(HashMapHolder::GetLock()); HashMapHolder::MapType &m = sObjectAccessor.GetPlayers(); - for(HashMapHolder::MapType::const_iterator itr = m.begin(); itr != m.end(); ++itr) + for (HashMapHolder::MapType::const_iterator itr = m.begin(); itr != m.end(); ++itr) { AccountTypes itr_sec = itr->second->GetSession()->GetSecurity(); if ((itr->second->isGameMaster() || (itr_sec > SEC_PLAYER && itr_sec <= (AccountTypes)sWorld.getConfig(CONFIG_UINT32_GM_LEVEL_IN_GM_LIST))) && diff --git a/src/game/Level3.cpp b/src/game/Level3.cpp index 05bbb1ab046..3f681c08644 100644 --- a/src/game/Level3.cpp +++ b/src/game/Level3.cpp @@ -4985,7 +4985,7 @@ bool ChatHandler::HandleResetAllCommand(char* args) CharacterDatabase.PExecute("UPDATE characters SET at_login = at_login | '%u' WHERE (at_login & '%u') = '0'", atLogin, atLogin); HashMapHolder::MapType const& plist = sObjectAccessor.GetPlayers(); - for(HashMapHolder::MapType::const_iterator itr = plist.begin(); itr != plist.end(); ++itr) + for (HashMapHolder::MapType::const_iterator itr = plist.begin(); itr != plist.end(); ++itr) itr->second->SetAtLoginFlag(atLogin); return true; diff --git a/src/game/MiscHandler.cpp b/src/game/MiscHandler.cpp index 8405f1a4212..c3e8a87f496 100644 --- a/src/game/MiscHandler.cpp +++ b/src/game/MiscHandler.cpp @@ -144,47 +144,49 @@ void WorldSession::HandleWhoOpcode( WorldPacket & recv_data ) // TODO: Guard Player map HashMapHolder::MapType& m = sObjectAccessor.GetPlayers(); - for(HashMapHolder::MapType::const_iterator itr = m.begin(); itr != m.end(); ++itr) + for (HashMapHolder::MapType::const_iterator itr = m.begin(); itr != m.end(); ++itr) { + Player* pl = itr->second; + if (security == SEC_PLAYER) { // player can see member of other team only if CONFIG_BOOL_ALLOW_TWO_SIDE_WHO_LIST - if (itr->second->GetTeam() != team && !allowTwoSideWhoList ) + if (pl->GetTeam() != team && !allowTwoSideWhoList ) continue; // player can see MODERATOR, GAME MASTER, ADMINISTRATOR only if CONFIG_GM_IN_WHO_LIST - if (itr->second->GetSession()->GetSecurity() > gmLevelInWhoList) + if (pl->GetSession()->GetSecurity() > gmLevelInWhoList) continue; } // do not process players which are not in world - if(!(itr->second->IsInWorld())) + if (!pl->IsInWorld()) continue; // check if target is globally visible for player - if (!(itr->second->IsVisibleGloballyFor(_player))) + if (!pl->IsVisibleGloballyFor(_player)) continue; // check if target's level is in level range - uint32 lvl = itr->second->getLevel(); + uint32 lvl = pl->getLevel(); if (lvl < level_min || lvl > level_max) continue; // check if class matches classmask - uint32 class_ = itr->second->getClass(); + uint32 class_ = pl->getClass(); if (!(classmask & (1 << class_))) continue; // check if race matches racemask - uint32 race = itr->second->getRace(); + uint32 race = pl->getRace(); if (!(racemask & (1 << race))) continue; - uint32 pzoneid = itr->second->GetZoneId(); - uint8 gender = itr->second->getGender(); + uint32 pzoneid = pl->GetZoneId(); + uint8 gender = pl->getGender(); bool z_show = true; - for(uint32 i = 0; i < zones_count; ++i) + for (uint32 i = 0; i < zones_count; ++i) { if(zoneids[i] == pzoneid) { @@ -197,7 +199,7 @@ void WorldSession::HandleWhoOpcode( WorldPacket & recv_data ) if (!z_show) continue; - std::string pname = itr->second->GetName(); + std::string pname = pl->GetName(); std::wstring wpname; if(!Utf8toWStr(pname,wpname)) continue; @@ -206,9 +208,9 @@ void WorldSession::HandleWhoOpcode( WorldPacket & recv_data ) if (!(wplayer_name.empty() || wpname.find(wplayer_name) != std::wstring::npos)) continue; - std::string gname = sGuildMgr.GetGuildNameById(itr->second->GetGuildId()); + std::string gname = sGuildMgr.GetGuildNameById(pl->GetGuildId()); std::wstring wgname; - if(!Utf8toWStr(gname,wgname)) + if (!Utf8toWStr(gname,wgname)) continue; wstrToLower(wgname); @@ -216,11 +218,11 @@ void WorldSession::HandleWhoOpcode( WorldPacket & recv_data ) continue; std::string aname; - if(AreaTableEntry const* areaEntry = GetAreaEntryByAreaID(itr->second->GetZoneId())) + if (AreaTableEntry const* areaEntry = GetAreaEntryByAreaID(pzoneid)) aname = areaEntry->area_name[GetSessionDbcLocale()]; bool s_show = true; - for(uint32 i = 0; i < str_count; ++i) + for (uint32 i = 0; i < str_count; ++i) { if (!str[i].empty()) { diff --git a/src/game/ObjectAccessor.cpp b/src/game/ObjectAccessor.cpp index a04d865fd97..05970391d22 100644 --- a/src/game/ObjectAccessor.cpp +++ b/src/game/ObjectAccessor.cpp @@ -88,8 +88,8 @@ ObjectAccessor::FindPlayerByName(const char *name) { HashMapHolder::ReadGuard g(HashMapHolder::GetLock()); HashMapHolder::MapType& m = sObjectAccessor.GetPlayers(); - for(HashMapHolder::MapType::iterator iter = m.begin(); iter != m.end(); ++iter) - if(iter->second->IsInWorld() && ( ::strcmp(name, iter->second->GetName()) == 0 )) + for (HashMapHolder::MapType::iterator iter = m.begin(); iter != m.end(); ++iter) + if (iter->second->IsInWorld() && ( ::strcmp(name, iter->second->GetName()) == 0 )) return iter->second; return NULL; @@ -100,7 +100,7 @@ ObjectAccessor::SaveAllPlayers() { HashMapHolder::ReadGuard g(HashMapHolder::GetLock()); HashMapHolder::MapType& m = sObjectAccessor.GetPlayers(); - for(HashMapHolder::MapType::iterator itr = m.begin(); itr != m.end(); ++itr) + for (HashMapHolder::MapType::iterator itr = m.begin(); itr != m.end(); ++itr) itr->second->SaveToDB(); } @@ -270,7 +270,7 @@ void ObjectAccessor::RemoveOldCorpses() /// Define the static member of HashMapHolder -template UNORDERED_MAP< uint64, T* > HashMapHolder::m_objectMap; +template typename HashMapHolder::MapType HashMapHolder::m_objectMap; template ACE_RW_Thread_Mutex HashMapHolder::i_lock; /// Global definitions for the hashmap storage diff --git a/src/game/ObjectAccessor.h b/src/game/ObjectAccessor.h index 3265bbd65a5..374b2657c73 100644 --- a/src/game/ObjectAccessor.h +++ b/src/game/ObjectAccessor.h @@ -46,7 +46,7 @@ class HashMapHolder { public: - typedef UNORDERED_MAP< uint64, T* > MapType; + typedef UNORDERED_MAP MapType; typedef ACE_RW_Thread_Mutex LockType; typedef ACE_Read_Guard ReadGuard; typedef ACE_Write_Guard WriteGuard; @@ -54,19 +54,19 @@ class HashMapHolder static void Insert(T* o) { WriteGuard guard(i_lock); - m_objectMap[o->GetGUID()] = o; + m_objectMap[o->GetObjectGuid()] = o; } static void Remove(T* o) { WriteGuard guard(i_lock); - m_objectMap.erase(o->GetGUID()); + m_objectMap.erase(o->GetObjectGuid()); } static T* Find(ObjectGuid guid) { ReadGuard guard(i_lock); - typename MapType::iterator itr = m_objectMap.find(guid.GetRawValue()); + typename MapType::iterator itr = m_objectMap.find(guid); return (itr != m_objectMap.end()) ? itr->second : NULL; } diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index 968725682b1..61e7cae5ffc 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 "11454" + #define REVISION_NR "11455" #endif // __REVISION_NR_H__ From 543c7f42ba43c208d78dad0353f7a48fd332d32d Mon Sep 17 00:00:00 2001 From: VladimirMangos Date: Mon, 9 May 2011 20:20:31 +0400 Subject: [PATCH 22/43] [11456] Some ObejctGuid uses in Pet code. --- src/game/Pet.cpp | 6 +++--- src/game/PetAI.cpp | 28 ++++++++++++++-------------- src/game/PetAI.h | 4 +++- src/shared/revision_nr.h | 2 +- 4 files changed, 21 insertions(+), 19 deletions(-) diff --git a/src/game/Pet.cpp b/src/game/Pet.cpp index 03dfb6b5e93..194add4d032 100644 --- a/src/game/Pet.cpp +++ b/src/game/Pet.cpp @@ -1281,7 +1281,7 @@ void Pet::_LoadAuras(uint32 timediff) do { Field *fields = result->Fetch(); - uint64 caster_guid = fields[0].GetUInt64(); + ObjectGuid casterGuid = ObjectGuid(fields[0].GetUInt64()); uint32 item_lowguid = fields[1].GetUInt32(); uint32 spellid = fields[2].GetUInt32(); uint32 stackcount = fields[3].GetUInt32(); @@ -1307,7 +1307,7 @@ void Pet::_LoadAuras(uint32 timediff) } // do not load single target auras (unless they were cast by the player) - if (caster_guid != GetGUID() && IsSingleTargetSpell(spellproto)) + if (casterGuid != GetObjectGuid() && IsSingleTargetSpell(spellproto)) continue; if (remaintime != -1 && !IsPositiveSpell(spellproto)) @@ -1336,7 +1336,7 @@ void Pet::_LoadAuras(uint32 timediff) stackcount = 1; SpellAuraHolder *holder = CreateSpellAuraHolder(spellproto, this, NULL); - holder->SetLoadedState(caster_guid, ObjectGuid(HIGHGUID_ITEM, item_lowguid), stackcount, remaincharges, maxduration, remaintime); + holder->SetLoadedState(casterGuid, ObjectGuid(HIGHGUID_ITEM, item_lowguid), stackcount, remaincharges, maxduration, remaintime); for (int32 i = 0; i < MAX_EFFECT_INDEX; ++i) { diff --git a/src/game/PetAI.cpp b/src/game/PetAI.cpp index 0c4a99621ab..ae9b2eaada2 100644 --- a/src/game/PetAI.cpp +++ b/src/game/PetAI.cpp @@ -250,15 +250,15 @@ void PetAI::UpdateAI(const uint32 diff) else { bool spellUsed = false; - for(std::set::const_iterator tar = m_AllySet.begin(); tar != m_AllySet.end(); ++tar) + for (AllySet::const_iterator tar = m_AllySet.begin(); tar != m_AllySet.end(); ++tar) { Unit* Target = ObjectAccessor::GetUnit(*m_creature,*tar); //only buff targets that are in combat, unless the spell can only be cast while out of combat - if(!Target) + if (!Target) continue; - if(spell->CanAutoCast(Target)) + if (spell->CanAutoCast(Target)) { targetSpellStore.push_back(std::make_pair(Target, spell)); spellUsed = true; @@ -317,36 +317,36 @@ void PetAI::UpdateAllies() m_updateAlliesTimer = 10*IN_MILLISECONDS; //update friendly targets every 10 seconds, lesser checks increase performance - if(!owner) + if (!owner) return; - else if(owner->GetTypeId() == TYPEID_PLAYER) + else if (owner->GetTypeId() == TYPEID_PLAYER) pGroup = ((Player*)owner)->GetGroup(); //only pet and owner/not in group->ok - if(m_AllySet.size() == 2 && !pGroup) + if (m_AllySet.size() == 2 && !pGroup) return; //owner is in group; group members filled in already (no raid -> subgroupcount = whole count) - if(pGroup && !pGroup->isRaidGroup() && m_AllySet.size() == (pGroup->GetMembersCount() + 2)) + if (pGroup && !pGroup->isRaidGroup() && m_AllySet.size() == (pGroup->GetMembersCount() + 2)) return; m_AllySet.clear(); - m_AllySet.insert(m_creature->GetGUID()); - if(pGroup) //add group + m_AllySet.insert(m_creature->GetObjectGuid()); + if (pGroup) //add group { - for(GroupReference *itr = pGroup->GetFirstMember(); itr != NULL; itr = itr->next()) + for (GroupReference *itr = pGroup->GetFirstMember(); itr != NULL; itr = itr->next()) { Player* Target = itr->getSource(); - if(!Target || !pGroup->SameSubGroup((Player*)owner, Target)) + if (!Target || !pGroup->SameSubGroup((Player*)owner, Target)) continue; - if(Target->GetGUID() == owner->GetGUID()) + if (Target->GetGUID() == owner->GetGUID()) continue; - m_AllySet.insert(Target->GetGUID()); + m_AllySet.insert(Target->GetObjectGuid()); } } else //remove group - m_AllySet.insert(owner->GetGUID()); + m_AllySet.insert(owner->GetObjectGuid()); } void PetAI::AttackedBy(Unit *attacker) diff --git a/src/game/PetAI.h b/src/game/PetAI.h index d510fdafe4d..4bf1a32160f 100644 --- a/src/game/PetAI.h +++ b/src/game/PetAI.h @@ -49,7 +49,9 @@ class MANGOS_DLL_DECL PetAI : public CreatureAI TimeTracker i_tracker; bool inCombat; - std::set m_AllySet; + + typedef std::set AllySet; + AllySet m_AllySet; uint32 m_updateAlliesTimer; }; #endif diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index 61e7cae5ffc..5641d15907e 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 "11455" + #define REVISION_NR "11456" #endif // __REVISION_NR_H__ From e094749b2594a72462d04c03c839b80248aaf9cd Mon Sep 17 00:00:00 2001 From: VladimirMangos Date: Mon, 9 May 2011 20:28:20 +0400 Subject: [PATCH 23/43] [11457] Use ObjectGuid way work with PLAYER_DUEL_ARBITER. --- src/game/Player.cpp | 33 ++++++++++++++------------------- src/game/SpellEffects.cpp | 4 ++-- src/shared/revision_nr.h | 2 +- 3 files changed, 17 insertions(+), 22 deletions(-) diff --git a/src/game/Player.cpp b/src/game/Player.cpp index 0467fa68e2e..d06b6225300 100644 --- a/src/game/Player.cpp +++ b/src/game/Player.cpp @@ -1765,11 +1765,8 @@ bool Player::TeleportTo(uint32 mapid, float x, float y, float z, float orientati // We have to perform this check before the teleport, otherwise the // ObjectAccessor won't find the flag. if (duel && GetMapId() != mapid) - { - GameObject* obj = GetMap()->GetGameObject(GetUInt64Value(PLAYER_DUEL_ARBITER)); - if (obj) + if (GameObject* obj = GetMap()->GetGameObject(GetGuidValue(PLAYER_DUEL_ARBITER))) DuelComplete(DUEL_FLED); - } // reset movement flags at teleport, because player will continue move with these flags after teleport m_movementInfo.SetMovementFlags(MOVEFLAG_NONE); @@ -6894,17 +6891,16 @@ void Player::UpdateZone(uint32 newZone, uint32 newArea) //If players are too far way of duel flag... then player loose the duel void Player::CheckDuelDistance(time_t currTime) { - if(!duel) + if (!duel) return; - uint64 duelFlagGUID = GetUInt64Value(PLAYER_DUEL_ARBITER); - GameObject* obj = GetMap()->GetGameObject(duelFlagGUID); + GameObject* obj = GetMap()->GetGameObject(GetGuidValue(PLAYER_DUEL_ARBITER)); if(!obj) return; - if(duel->outOfBound == 0) + if (duel->outOfBound == 0) { - if(!IsWithinDistInMap(obj, 50)) + if (!IsWithinDistInMap(obj, 50)) { duel->outOfBound = currTime; @@ -6914,14 +6910,14 @@ void Player::CheckDuelDistance(time_t currTime) } else { - if(IsWithinDistInMap(obj, 40)) + if (IsWithinDistInMap(obj, 40)) { duel->outOfBound = 0; WorldPacket data(SMSG_DUEL_INBOUNDS, 0); GetSession()->SendPacket(&data); } - else if(currTime >= (duel->outOfBound+10)) + else if (currTime >= (duel->outOfBound+10)) { DuelComplete(DUEL_FLED); } @@ -6956,9 +6952,8 @@ void Player::DuelComplete(DuelCompleteType type) } //Remove Duel Flag object - GameObject* obj = GetMap()->GetGameObject(GetUInt64Value(PLAYER_DUEL_ARBITER)); - if(obj) - duel->initiator->RemoveGameObject(obj,true); + if (GameObject* obj = GetMap()->GetGameObject(GetGuidValue(PLAYER_DUEL_ARBITER))) + duel->initiator->RemoveGameObject(obj, true); /* remove auras */ std::vector auras2remove; @@ -6979,7 +6974,7 @@ void Player::DuelComplete(DuelCompleteType type) if (!i->second->IsPositive() && i->second->GetCasterGuid() == duel->opponent->GetObjectGuid() && i->second->GetAuraApplyTime() >= duel->startTime) auras2remove.push_back(i->second->GetId()); } - for(size_t i=0; iopponent->ClearComboPoints(); //cleanups - SetUInt64Value(PLAYER_DUEL_ARBITER, 0); + SetGuidValue(PLAYER_DUEL_ARBITER, ObjectGuid()); SetUInt32Value(PLAYER_DUEL_TEAM, 0); - duel->opponent->SetUInt64Value(PLAYER_DUEL_ARBITER, 0); + duel->opponent->SetGuidValue(PLAYER_DUEL_ARBITER, ObjectGuid()); duel->opponent->SetUInt32Value(PLAYER_DUEL_TEAM, 0); delete duel->opponent->duel; @@ -15670,7 +15665,7 @@ bool Player::LoadFromDB(ObjectGuid guid, SqlQueryHolder *holder ) ClearInCombat(); // make sure the unit is considered not in duel for proper loading - SetUInt64Value(PLAYER_DUEL_ARBITER, 0); + SetGuidValue(PLAYER_DUEL_ARBITER, ObjectGuid()); SetUInt32Value(PLAYER_DUEL_TEAM, 0); // reset stats before loading any modifiers @@ -15682,7 +15677,7 @@ bool Player::LoadFromDB(ObjectGuid guid, SqlQueryHolder *holder ) // rest bonus can only be calculated after InitStatsForLevel() m_rest_bonus = fields[21].GetFloat(); - if(time_diff > 0) + if (time_diff > 0) { //speed collect rest bonus in offline, in logout, far from tavern, city (section/in hour) float bubble0 = 0.031f; diff --git a/src/game/SpellEffects.cpp b/src/game/SpellEffects.cpp index fd7e20dfad8..3debf089c44 100644 --- a/src/game/SpellEffects.cpp +++ b/src/game/SpellEffects.cpp @@ -7765,8 +7765,8 @@ void Spell::EffectDuel(SpellEffectIndex eff_idx) duel2->startTimer = 0; target->duel = duel2; - caster->SetUInt64Value(PLAYER_DUEL_ARBITER, pGameObj->GetGUID()); - target->SetUInt64Value(PLAYER_DUEL_ARBITER, pGameObj->GetGUID()); + caster->SetGuidValue(PLAYER_DUEL_ARBITER, pGameObj->GetObjectGuid()); + target->SetGuidValue(PLAYER_DUEL_ARBITER, pGameObj->GetObjectGuid()); } void Spell::EffectStuck(SpellEffectIndex /*eff_idx*/) diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index 5641d15907e..b9201ed5c93 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 "11456" + #define REVISION_NR "11457" #endif // __REVISION_NR_H__ From f53e94b9a27f56347ecfcc2b83f8b724437a41fa Mon Sep 17 00:00:00 2001 From: VladimirMangos Date: Mon, 9 May 2011 21:47:28 +0400 Subject: [PATCH 24/43] [11458] Non-item related uint64 guids replaced by ObjectGUids in Player.h Also let ObjectAccessor::FindPlayer optimize empty guid case work. --- src/game/ChatHandler.cpp | 2 +- src/game/Group.cpp | 4 +- src/game/Item.cpp | 2 +- src/game/ItemHandler.cpp | 74 +++++++++++++++++----------------- src/game/LootHandler.cpp | 15 +++---- src/game/MiscHandler.cpp | 5 ++- src/game/ObjectAccessor.cpp | 3 ++ src/game/Player.cpp | 80 ++++++++++++++++++------------------- src/game/Player.h | 15 +++---- src/game/QuestHandler.cpp | 39 ++++++++---------- src/game/WorldSession.cpp | 5 ++- src/game/debugcmds.cpp | 2 +- src/shared/revision_nr.h | 2 +- 13 files changed, 123 insertions(+), 125 deletions(-) diff --git a/src/game/ChatHandler.cpp b/src/game/ChatHandler.cpp index 9f16100f870..19e7eabc518 100644 --- a/src/game/ChatHandler.cpp +++ b/src/game/ChatHandler.cpp @@ -223,7 +223,7 @@ void WorldSession::HandleMessagechatOpcode( WorldPacket & recv_data ) } } - GetPlayer()->Whisper(msg, lang, player->GetGUID()); + GetPlayer()->Whisper(msg, lang, player->GetObjectGuid()); } break; case CHAT_MSG_PARTY: diff --git a/src/game/Group.cpp b/src/game/Group.cpp index 78bac74490d..fbd57e530df 100644 --- a/src/game/Group.cpp +++ b/src/game/Group.cpp @@ -1525,7 +1525,7 @@ void Group::UpdateLooterGuid( Creature* creature, bool ifneed ) { if (pl->IsWithinDist(creature, sWorld.getConfig(CONFIG_FLOAT_GROUP_XP_DISTANCE), false)) { - bool refresh = pl->GetLootGUID() == creature->GetGUID(); + bool refresh = pl->GetLootGuid() == creature->GetObjectGuid(); //if(refresh) // update loot for new looter // pl->GetSession()->DoLootRelease(pl->GetLootGUID()); @@ -1546,7 +1546,7 @@ void Group::UpdateLooterGuid( Creature* creature, bool ifneed ) { if (pl->IsWithinDist(creature, sWorld.getConfig(CONFIG_FLOAT_GROUP_XP_DISTANCE), false)) { - bool refresh = pl->GetLootGUID()==creature->GetGUID(); + bool refresh = pl->GetLootGuid() == creature->GetObjectGuid(); //if(refresh) // update loot for new looter // pl->GetSession()->DoLootRelease(pl->GetLootGUID()); diff --git a/src/game/Item.cpp b/src/game/Item.cpp index cb747b389a1..47698b77fa6 100644 --- a/src/game/Item.cpp +++ b/src/game/Item.cpp @@ -847,7 +847,7 @@ bool Item::CanBeTraded(bool mail) const { if (owner->CanUnequipItem(GetPos(),false) != EQUIP_ERR_OK ) return false; - if (owner->GetLootGUID()==GetGUID()) + if (owner->GetLootGuid() == GetObjectGuid()) return false; } diff --git a/src/game/ItemHandler.cpp b/src/game/ItemHandler.cpp index 9725a0a7dae..78fe30b609f 100644 --- a/src/game/ItemHandler.cpp +++ b/src/game/ItemHandler.cpp @@ -490,111 +490,111 @@ void WorldSession::HandleSellItemOpcode( WorldPacket & recv_data ) DEBUG_LOG( "WORLD: Received CMSG_SELL_ITEM" ); ObjectGuid vendorGuid; - uint64 itemguid; + ObjectGuid itemGuid; uint32 count; recv_data >> vendorGuid; - recv_data >> itemguid; + recv_data >> itemGuid; recv_data >> count; - if(!itemguid) + if (itemGuid.IsEmpty()) return; Creature *pCreature = GetPlayer()->GetNPCIfCanInteractWith(vendorGuid, UNIT_NPC_FLAG_VENDOR); if (!pCreature) { DEBUG_LOG("WORLD: HandleSellItemOpcode - %s not found or you can't interact with him.", vendorGuid.GetString().c_str()); - _player->SendSellError( SELL_ERR_CANT_FIND_VENDOR, NULL, itemguid, 0); + _player->SendSellError(SELL_ERR_CANT_FIND_VENDOR, NULL, itemGuid, 0); return; } // remove fake death - if(GetPlayer()->hasUnitState(UNIT_STAT_DIED)) + if (GetPlayer()->hasUnitState(UNIT_STAT_DIED)) GetPlayer()->RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH); - Item *pItem = _player->GetItemByGuid( itemguid ); + Item *pItem = _player->GetItemByGuid(itemGuid); if (pItem) { // prevent sell not owner item if (_player->GetObjectGuid() != pItem->GetOwnerGuid()) { - _player->SendSellError( SELL_ERR_CANT_SELL_ITEM, pCreature, itemguid, 0); + _player->SendSellError(SELL_ERR_CANT_SELL_ITEM, pCreature, itemGuid, 0); return; } // prevent sell non empty bag by drag-and-drop at vendor's item list - if(pItem->IsBag() && !((Bag*)pItem)->IsEmpty()) + if (pItem->IsBag() && !((Bag*)pItem)->IsEmpty()) { - _player->SendSellError( SELL_ERR_CANT_SELL_ITEM, pCreature, itemguid, 0); + _player->SendSellError(SELL_ERR_CANT_SELL_ITEM, pCreature, itemGuid, 0); return; } // prevent sell currently looted item - if(_player->GetLootGUID() == pItem->GetGUID()) + if (_player->GetLootGuid() == pItem->GetObjectGuid()) { - _player->SendSellError( SELL_ERR_CANT_SELL_ITEM, pCreature, itemguid, 0); + _player->SendSellError(SELL_ERR_CANT_SELL_ITEM, pCreature, itemGuid, 0); return; } // special case at auto sell (sell all) - if(count == 0) + if (count == 0) { count = pItem->GetCount(); } else { // prevent sell more items that exist in stack (possible only not from client) - if(count > pItem->GetCount()) + if (count > pItem->GetCount()) { - _player->SendSellError( SELL_ERR_CANT_SELL_ITEM, pCreature, itemguid, 0); + _player->SendSellError(SELL_ERR_CANT_SELL_ITEM, pCreature, itemGuid, 0); return; } } ItemPrototype const *pProto = pItem->GetProto(); - if( pProto ) + if (pProto) { - if( pProto->SellPrice > 0 ) + if (pProto->SellPrice > 0) { - if(count < pItem->GetCount()) // need split items + if (count < pItem->GetCount()) // need split items { Item *pNewItem = pItem->CloneItem( count, _player ); if (!pNewItem) { sLog.outError("WORLD: HandleSellItemOpcode - could not create clone of item %u; count = %u", pItem->GetEntry(), count ); - _player->SendSellError( SELL_ERR_CANT_SELL_ITEM, pCreature, itemguid, 0); + _player->SendSellError(SELL_ERR_CANT_SELL_ITEM, pCreature, itemGuid, 0); return; } - pItem->SetCount( pItem->GetCount() - count ); - _player->ItemRemovedQuestCheck( pItem->GetEntry(), count ); - if( _player->IsInWorld() ) - pItem->SendCreateUpdateToPlayer( _player ); + pItem->SetCount(pItem->GetCount() - count); + _player->ItemRemovedQuestCheck(pItem->GetEntry(), count); + if (_player->IsInWorld()) + pItem->SendCreateUpdateToPlayer(_player); pItem->SetState(ITEM_CHANGED, _player); - _player->AddItemToBuyBackSlot( pNewItem ); - if( _player->IsInWorld() ) - pNewItem->SendCreateUpdateToPlayer( _player ); + _player->AddItemToBuyBackSlot(pNewItem); + if (_player->IsInWorld()) + pNewItem->SendCreateUpdateToPlayer(_player); } else { - _player->ItemRemovedQuestCheck( pItem->GetEntry(), pItem->GetCount()); - _player->RemoveItem( pItem->GetBagSlot(), pItem->GetSlot(), true); + _player->ItemRemovedQuestCheck(pItem->GetEntry(), pItem->GetCount()); + _player->RemoveItem(pItem->GetBagSlot(), pItem->GetSlot(), true); pItem->RemoveFromUpdateQueueOf(_player); - _player->AddItemToBuyBackSlot( pItem ); + _player->AddItemToBuyBackSlot(pItem); } uint32 money = pProto->SellPrice * count; - _player->ModifyMoney( money ); + _player->ModifyMoney(money); _player->GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_MONEY_FROM_VENDORS, money); } else - _player->SendSellError( SELL_ERR_CANT_SELL_ITEM, pCreature, itemguid, 0); + _player->SendSellError(SELL_ERR_CANT_SELL_ITEM, pCreature, itemGuid, 0); return; } } - _player->SendSellError( SELL_ERR_CANT_FIND_ITEM, pCreature, itemguid, 0); + _player->SendSellError(SELL_ERR_CANT_FIND_ITEM, pCreature, itemGuid, 0); return; } @@ -610,7 +610,7 @@ void WorldSession::HandleBuybackItem(WorldPacket & recv_data) if (!pCreature) { DEBUG_LOG("WORLD: HandleBuybackItem - %s not found or you can't interact with him.", vendorGuid.GetString().c_str()); - _player->SendSellError( SELL_ERR_CANT_FIND_VENDOR, NULL, 0, 0); + _player->SendSellError( SELL_ERR_CANT_FIND_VENDOR, NULL, ObjectGuid(), 0); return; } @@ -619,10 +619,10 @@ void WorldSession::HandleBuybackItem(WorldPacket & recv_data) GetPlayer()->RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH); Item *pItem = _player->GetItemFromBuyBackSlot( slot ); - if( pItem ) + if (pItem) { uint32 price = _player->GetUInt32Value( PLAYER_FIELD_BUYBACK_PRICE_1 + slot - BUYBACK_SLOT_START ); - if( _player->GetMoney() < price ) + if (_player->GetMoney() < price) { _player->SendBuyError( BUY_ERR_NOT_ENOUGHT_MONEY, pCreature, pItem->GetEntry(), 0); return; @@ -630,7 +630,7 @@ void WorldSession::HandleBuybackItem(WorldPacket & recv_data) ItemPosCountVec dest; InventoryResult msg = _player->CanStoreItem( NULL_BAG, NULL_SLOT, dest, pItem, false ); - if( msg == EQUIP_ERR_OK ) + if (msg == EQUIP_ERR_OK) { _player->ModifyMoney( -(int32)price ); _player->RemoveItemFromBuyBackSlot( slot, false ); @@ -643,7 +643,7 @@ void WorldSession::HandleBuybackItem(WorldPacket & recv_data) return; } else - _player->SendBuyError( BUY_ERR_CANT_FIND_ITEM, pCreature, 0, 0); + _player->SendBuyError(BUY_ERR_CANT_FIND_ITEM, pCreature, 0, 0); } void WorldSession::HandleBuyItemInSlotOpcode( WorldPacket & recv_data ) @@ -730,7 +730,7 @@ void WorldSession::SendListInventory(ObjectGuid vendorguid) if (!pCreature) { DEBUG_LOG("WORLD: SendListInventory - %s not found or you can't interact with him.", vendorguid.GetString().c_str()); - _player->SendSellError(SELL_ERR_CANT_FIND_VENDOR, NULL, 0, 0); + _player->SendSellError(SELL_ERR_CANT_FIND_VENDOR, NULL, ObjectGuid(), 0); return; } diff --git a/src/game/LootHandler.cpp b/src/game/LootHandler.cpp index 55e84c6f647..786222a43bb 100644 --- a/src/game/LootHandler.cpp +++ b/src/game/LootHandler.cpp @@ -35,7 +35,7 @@ void WorldSession::HandleAutostoreLootItemOpcode( WorldPacket & recv_data ) { DEBUG_LOG("WORLD: CMSG_AUTOSTORE_LOOT_ITEM"); Player *player = GetPlayer(); - ObjectGuid lguid = player->GetLootGUID(); + ObjectGuid lguid = player->GetLootGuid(); Loot *loot; uint8 lootSlot; Item* pItem = NULL; @@ -179,7 +179,7 @@ void WorldSession::HandleLootMoneyOpcode( WorldPacket & /*recv_data*/ ) DEBUG_LOG("WORLD: CMSG_LOOT_MONEY"); Player *player = GetPlayer(); - ObjectGuid guid = player->GetLootGUID(); + ObjectGuid guid = player->GetLootGuid(); if (guid.IsEmpty()) return; @@ -297,8 +297,9 @@ void WorldSession::HandleLootReleaseOpcode( WorldPacket & recv_data ) // use internal stored guid recv_data.read_skip(); // guid; - if(uint64 lguid = GetPlayer()->GetLootGUID()) - DoLootRelease(lguid); + ObjectGuid lootGuid = GetPlayer()->GetLootGuid(); + if (!lootGuid.IsEmpty()) + DoLootRelease(lootGuid); } void WorldSession::DoLootRelease(ObjectGuid lguid) @@ -306,7 +307,7 @@ void WorldSession::DoLootRelease(ObjectGuid lguid) Player *player = GetPlayer(); Loot *loot; - player->SetLootGUID(ObjectGuid()); + player->SetLootGuid(ObjectGuid()); player->SendLootRelease(lguid); player->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_LOOTING); @@ -508,7 +509,7 @@ void WorldSession::HandleLootMasterGiveOpcode( WorldPacket & recv_data ) if (!_player->GetGroup() || _player->GetGroup()->GetLooterGuid() != _player->GetObjectGuid()) { - _player->SendLootRelease(GetPlayer()->GetLootGUID()); + _player->SendLootRelease(GetPlayer()->GetLootGuid()); return; } @@ -518,7 +519,7 @@ void WorldSession::HandleLootMasterGiveOpcode( WorldPacket & recv_data ) DEBUG_LOG("WorldSession::HandleLootMasterGiveOpcode (CMSG_LOOT_MASTER_GIVE, 0x02A3) Target = %s [%s].", target_playerguid.GetString().c_str(), target->GetName()); - if (_player->GetLootGUID() != lootguid.GetRawValue()) + if (_player->GetLootGuid() != lootguid) return; Loot *pLoot = NULL; diff --git a/src/game/MiscHandler.cpp b/src/game/MiscHandler.cpp index c3e8a87f496..c47b03ca246 100644 --- a/src/game/MiscHandler.cpp +++ b/src/game/MiscHandler.cpp @@ -264,8 +264,9 @@ void WorldSession::HandleLogoutRequestOpcode( WorldPacket & /*recv_data*/ ) { DEBUG_LOG( "WORLD: Recvd CMSG_LOGOUT_REQUEST Message, security - %u", GetSecurity() ); - if (uint64 lguid = GetPlayer()->GetLootGUID()) - DoLootRelease(lguid); + ObjectGuid lootGuid = GetPlayer()->GetLootGuid(); + if (!lootGuid.IsEmpty()) + DoLootRelease(lootGuid); //Can not logout if... if( GetPlayer()->isInCombat() || //...is in combat diff --git a/src/game/ObjectAccessor.cpp b/src/game/ObjectAccessor.cpp index 05970391d22..e021256f4f4 100644 --- a/src/game/ObjectAccessor.cpp +++ b/src/game/ObjectAccessor.cpp @@ -76,6 +76,9 @@ Corpse* ObjectAccessor::GetCorpseInMap(ObjectGuid guid, uint32 mapid) Player* ObjectAccessor::FindPlayer(ObjectGuid guid) { + if (guid.IsEmpty()) + return NULL; + Player * plr = HashMapHolder::Find(guid);; if(!plr || !plr->IsInWorld()) return NULL; diff --git a/src/game/Player.cpp b/src/game/Player.cpp index d06b6225300..6f17a8c49bf 100644 --- a/src/game/Player.cpp +++ b/src/game/Player.cpp @@ -418,8 +418,6 @@ Player::Player (WorldSession *session): Unit(), m_mover(this), m_camera(this), m m_session = session; - m_divider = 0; - m_ExtraFlags = 0; if(GetSession()->GetSecurity() >= SEC_GAMEMASTER) SetAcceptTicket(true); @@ -6514,39 +6512,39 @@ void Player::UpdateHonorFields() bool Player::RewardHonor(Unit *uVictim, uint32 groupsize, float honor) { // do not reward honor in arenas, but enable onkill spellproc - if(InArena()) + if (InArena()) { - if(!uVictim || uVictim == this || uVictim->GetTypeId() != TYPEID_PLAYER) + if (!uVictim || uVictim == this || uVictim->GetTypeId() != TYPEID_PLAYER) return false; - if( GetBGTeam() == ((Player*)uVictim)->GetBGTeam() ) + if (GetBGTeam() == ((Player*)uVictim)->GetBGTeam()) return false; return true; } // 'Inactive' this aura prevents the player from gaining honor points and battleground tokens - if(GetDummyAura(SPELL_AURA_PLAYER_INACTIVE)) + if (GetDummyAura(SPELL_AURA_PLAYER_INACTIVE)) return false; - uint64 victim_guid = 0; + ObjectGuid victim_guid; uint32 victim_rank = 0; // need call before fields update to have chance move yesterday data to appropriate fields before today data change. UpdateHonorFields(); - if(honor <= 0) + if (honor <= 0) { - if(!uVictim || uVictim == this || uVictim->HasAuraType(SPELL_AURA_NO_PVP_CREDIT)) + if (!uVictim || uVictim == this || uVictim->HasAuraType(SPELL_AURA_NO_PVP_CREDIT)) return false; - victim_guid = uVictim->GetGUID(); + victim_guid = uVictim->GetObjectGuid(); - if( uVictim->GetTypeId() == TYPEID_PLAYER ) + if (uVictim->GetTypeId() == TYPEID_PLAYER) { Player *pVictim = (Player *)uVictim; - if( GetTeam() == pVictim->GetTeam() && !sWorld.IsFFAPvPRealm() ) + if (GetTeam() == pVictim->GetTeam() && !sWorld.IsFFAPvPRealm()) return false; float f = 1; //need for total kills (?? need more info) @@ -6568,18 +6566,18 @@ bool Player::RewardHonor(Unit *uVictim, uint32 groupsize, float honor) // title[15..28] -> rank[5..18] // title[other] -> 0 if (victim_title == 0) - victim_guid = 0; // Don't show HK: message, only log. + victim_guid.Clear(); // Don't show HK: message, only log. else if (victim_title < 15) victim_rank = victim_title + 4; else if (victim_title < 29) victim_rank = victim_title - 14 + 4; else - victim_guid = 0; // Don't show HK: message, only log. + victim_guid.Clear(); // Don't show HK: message, only log. } k_grey = MaNGOS::XP::GetGrayLevel(k_level); - if(v_level<=k_grey) + if (v_level<=k_grey) return false; float diff_level = (k_level == k_grey) ? 1 : ((float(v_level) - float(k_grey)) / (float(k_level) - float(k_grey))); @@ -6587,7 +6585,7 @@ bool Player::RewardHonor(Unit *uVictim, uint32 groupsize, float honor) int32 v_rank =1; //need more info honor = ((f * diff_level * (190 + v_rank*10))/6); - honor *= ((float)k_level) / 70.0f; //factor of dependence on levels of the killer + honor *= float(k_level) / 70.0f; //factor of dependence on levels of the killer // count the number of playerkills in one day ApplyModUInt32Value(PLAYER_FIELD_KILLS, 1, true); @@ -6614,7 +6612,7 @@ bool Player::RewardHonor(Unit *uVictim, uint32 groupsize, float honor) honor *= sWorld.getConfig(CONFIG_FLOAT_RATE_HONOR); honor *= (GetMaxPositiveAuraModifier(SPELL_AURA_MOD_HONOR_GAIN) + 100.0f)/100.0f; - if(groupsize > 1) + if (groupsize > 1) honor /= groupsize; honor *= (((float)urand(8,12))/10); // approx honor: 80% - 120% of real honor @@ -6625,11 +6623,10 @@ bool Player::RewardHonor(Unit *uVictim, uint32 groupsize, float honor) // victim_rank [1..4] HK: // victim_rank [5..19] HK: // victim_rank [0,20+] HK: <> - WorldPacket data(SMSG_PVP_CREDIT,4+8+4); - data << (uint32) honor; - data << (uint64) victim_guid; - data << (uint32) victim_rank; - + WorldPacket data(SMSG_PVP_CREDIT, 4 + 8 + 4); + data << uint32(honor); + data << ObjectGuid(victim_guid); + data << uint32(victim_rank); GetSession()->SendPacket(&data); // add honor points @@ -7962,8 +7959,9 @@ void Player::SendLootRelease(ObjectGuid guid) void Player::SendLoot(ObjectGuid guid, LootType loot_type) { - if (uint64 lguid = GetLootGUID()) - m_session->DoLootRelease(lguid); + ObjectGuid lootGuid = GetLootGuid(); + if (!lootGuid.IsEmpty()) + m_session->DoLootRelease(lootGuid); Loot *loot = 0; PermissionTypes permission = ALL_PERMISSION; @@ -8226,7 +8224,7 @@ void Player::SendLoot(ObjectGuid guid, LootType loot_type) } } - SetLootGUID(guid); + SetLootGuid(guid); // LOOT_INSIGNIA and LOOT_FISHINGHOLE unsupported by client switch(loot_type) @@ -12298,12 +12296,12 @@ void Player::SendBuyError( BuyResult msg, Creature* pCreature, uint32 item, uint GetSession()->SendPacket(&data); } -void Player::SendSellError( SellResult msg, Creature* pCreature, uint64 guid, uint32 param ) +void Player::SendSellError( SellResult msg, Creature* pCreature, ObjectGuid itemGuid, uint32 param ) { DEBUG_LOG( "WORLD: Sent SMSG_SELL_ITEM" ); WorldPacket data( SMSG_SELL_ITEM,(8+8+(param?4:0)+1)); // last check 2.0.10 data << (pCreature ? pCreature->GetObjectGuid() : ObjectGuid()); - data << uint64(guid); + data << ObjectGuid(itemGuid); if (param > 0) data << uint32(param); data << uint8(msg); @@ -18226,14 +18224,14 @@ void Player::RemovePet(PetSaveMode mode) void Player::BuildPlayerChat(WorldPacket *data, uint8 msgtype, const std::string& text, uint32 language) const { - *data << (uint8)msgtype; - *data << (uint32)language; - *data << (uint64)GetGUID(); - *data << (uint32)language; //language 2.1.0 ? - *data << (uint64)GetGUID(); - *data << (uint32)(text.length()+1); + *data << uint8(msgtype); + *data << uint32(language); + *data << ObjectGuid(GetObjectGuid()); + *data << uint32(language); //language 2.1.0 ? + *data << ObjectGuid(GetObjectGuid()); + *data << uint32(text.length()+1); *data << text; - *data << (uint8)chatTag(); + *data << uint8(chatTag()); } void Player::Say(const std::string& text, const uint32 language) @@ -18257,7 +18255,7 @@ void Player::TextEmote(const std::string& text) SendMessageToSetInRange(&data,sWorld.getConfig(CONFIG_FLOAT_LISTEN_RANGE_TEXTEMOTE),true, !sWorld.getConfig(CONFIG_BOOL_ALLOW_TWO_SIDE_INTERACTION_CHAT) ); } -void Player::Whisper(const std::string& text, uint32 language,uint64 receiver) +void Player::Whisper(const std::string& text, uint32 language, ObjectGuid receiver) { if (language != LANG_ADDON) // if not addon data language = LANG_UNIVERSAL; // whispers should always be readable @@ -20852,22 +20850,22 @@ void Player::RewardSinglePlayerAtKill(Unit* pVictim) void Player::RewardPlayerAndGroupAtEvent(uint32 creature_id, WorldObject* pRewardSource) { - uint64 creature_guid = pRewardSource->GetTypeId()==TYPEID_UNIT ? pRewardSource->GetGUID() : uint64(0); + ObjectGuid creature_guid = pRewardSource->GetTypeId()==TYPEID_UNIT ? pRewardSource->GetObjectGuid() : ObjectGuid(); // prepare data for near group iteration - if(Group *pGroup = GetGroup()) + if (Group *pGroup = GetGroup()) { - for(GroupReference *itr = pGroup->GetFirstMember(); itr != NULL; itr = itr->next()) + for (GroupReference *itr = pGroup->GetFirstMember(); itr != NULL; itr = itr->next()) { Player* pGroupGuy = itr->getSource(); - if(!pGroupGuy) + if (!pGroupGuy) continue; - if(!pGroupGuy->IsAtGroupRewardDistance(pRewardSource)) + if (!pGroupGuy->IsAtGroupRewardDistance(pRewardSource)) continue; // member (alive or dead) or his corpse at req. distance // quest objectives updated only for alive group member or dead but with not released body - if(pGroupGuy->isAlive()|| !pGroupGuy->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_GHOST)) + if (pGroupGuy->isAlive()|| !pGroupGuy->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_GHOST)) pGroupGuy->KilledMonsterCredit(creature_id, creature_guid); } } diff --git a/src/game/Player.h b/src/game/Player.h index 8e2e137fce2..b2193e2a6f8 100644 --- a/src/game/Player.h +++ b/src/game/Player.h @@ -1161,7 +1161,7 @@ class MANGOS_DLL_SPEC Player : public Unit void Say(const std::string& text, const uint32 language); void Yell(const std::string& text, const uint32 language); void TextEmote(const std::string& text); - void Whisper(const std::string& text, const uint32 language,uint64 receiver); + void Whisper(const std::string& text, const uint32 language, ObjectGuid receiver); void BuildPlayerChat(WorldPacket *data, uint8 msgtype, const std::string& text, uint32 language) const; /*********************************************************/ @@ -1276,7 +1276,7 @@ class MANGOS_DLL_SPEC Player : public Unit uint32 GetMaxKeyringSize() const { return KEYRING_SLOT_END-KEYRING_SLOT_START; } void SendEquipError( InventoryResult msg, Item* pItem, Item *pItem2 = NULL, uint32 itemid = 0 ) const; void SendBuyError( BuyResult msg, Creature* pCreature, uint32 item, uint32 param ); - void SendSellError( SellResult msg, Creature* pCreature, uint64 guid, uint32 param ); + void SendSellError( SellResult msg, Creature* pCreature, ObjectGuid itemGuid, uint32 param ); void AddWeaponProficiency(uint32 newflag) { m_WeaponProficiency |= newflag; } void AddArmorProficiency(uint32 newflag) { m_ArmorProficiency |= newflag; } uint32 GetWeaponProficiency() const { return m_WeaponProficiency; } @@ -1441,8 +1441,9 @@ class MANGOS_DLL_SPEC Player : public Unit void SendPushToPartyResponse( Player *pPlayer, uint32 msg ); void SendQuestUpdateAddCreatureOrGo(Quest const* pQuest, ObjectGuid guid, uint32 creatureOrGO_idx, uint32 count); - uint64 GetDivider() { return m_divider; } - void SetDivider( uint64 guid ) { m_divider = guid; } + ObjectGuid GetDividerGuid() const { return m_dividerGuid; } + void SetDividerGuid(ObjectGuid guid) { m_dividerGuid = guid; } + void ClearDividerGuid() { m_dividerGuid.Clear(); } uint32 GetInGameTime() { return m_ingametime; } @@ -1824,8 +1825,8 @@ class MANGOS_DLL_SPEC Player : public Unit void ApplyManaRegenBonus(int32 amount, bool apply); void UpdateManaRegen(); - const uint64& GetLootGUID() const { return m_lootGuid.GetRawValue(); } - void SetLootGUID(ObjectGuid const& guid) { m_lootGuid = guid; } + ObjectGuid const& GetLootGuid() const { return m_lootGuid; } + void SetLootGuid(ObjectGuid const& guid) { m_lootGuid = guid; } void RemovedInsignia(Player* looterPlr); @@ -2360,7 +2361,7 @@ class MANGOS_DLL_SPEC Player : public Unit QuestSet m_weeklyquests; QuestSet m_monthlyquests; - uint64 m_divider; + ObjectGuid m_dividerGuid; uint32 m_ingametime; /*********************************************************/ diff --git a/src/game/QuestHandler.cpp b/src/game/QuestHandler.cpp index 3244d1bba8d..4754e98fb5b 100644 --- a/src/game/QuestHandler.cpp +++ b/src/game/QuestHandler.cpp @@ -131,7 +131,7 @@ void WorldSession::HandleQuestgiverAcceptQuestOpcode( WorldPacket & recv_data ) ) { _player->PlayerTalkClass->CloseGossip(); - _player->SetDivider( 0 ); + _player->ClearDividerGuid(); return; } @@ -142,18 +142,14 @@ void WorldSession::HandleQuestgiverAcceptQuestOpcode( WorldPacket & recv_data ) if(!GetPlayer()->CanTakeQuest(qInfo,true) ) { _player->PlayerTalkClass->CloseGossip(); - _player->SetDivider( 0 ); + _player->ClearDividerGuid(); return; } - if( _player->GetDivider() != 0 ) + if (Player *pPlayer = ObjectAccessor::FindPlayer(_player->GetDividerGuid())) { - Player *pPlayer = ObjectAccessor::FindPlayer( _player->GetDivider() ); - if( pPlayer ) - { - pPlayer->SendPushToPartyResponse( _player, QUEST_PARTY_MSG_ACCEPT_QUEST ); - _player->SetDivider( 0 ); - } + pPlayer->SendPushToPartyResponse(_player, QUEST_PARTY_MSG_ACCEPT_QUEST); + _player->ClearDividerGuid(); } if( _player->CanAddQuest( qInfo, true ) ) @@ -173,7 +169,7 @@ void WorldSession::HandleQuestgiverAcceptQuestOpcode( WorldPacket & recv_data ) if (pPlayer->CanTakeQuest(qInfo, true)) { - pPlayer->SetDivider(_player->GetGUID()); + pPlayer->SetDividerGuid(_player->GetObjectGuid()); //need confirmation that any gossip window will close pPlayer->PlayerTalkClass->CloseGossip(); @@ -374,7 +370,7 @@ void WorldSession::HandleQuestConfirmAccept(WorldPacket& recv_data) if (!pQuest->HasQuestFlag(QUEST_FLAGS_PARTY_ACCEPT)) return; - Player* pOriginalPlayer = ObjectAccessor::FindPlayer(_player->GetDivider()); + Player* pOriginalPlayer = ObjectAccessor::FindPlayer(_player->GetDividerGuid()); if (!pOriginalPlayer) return; @@ -393,7 +389,7 @@ void WorldSession::HandleQuestConfirmAccept(WorldPacket& recv_data) if (_player->CanAddQuest(pQuest, true)) _player->AddQuest(pQuest, NULL); // NULL, this prevent DB script from duplicate running - _player->SetDivider(0); + _player->ClearDividerGuid(); } } @@ -476,14 +472,14 @@ void WorldSession::HandlePushQuestToParty(WorldPacket& recvPacket) continue; } - if (pPlayer->GetDivider() != 0) + if (!pPlayer->GetDividerGuid().IsEmpty()) { _player->SendPushToPartyResponse(pPlayer, QUEST_PARTY_MSG_BUSY); continue; } pPlayer->PlayerTalkClass->SendQuestGiverQuestDetails(pQuest, _player->GetObjectGuid(), true); - pPlayer->SetDivider(_player->GetGUID()); + pPlayer->SetDividerGuid(_player->GetObjectGuid()); } } } @@ -497,16 +493,13 @@ void WorldSession::HandleQuestPushResult(WorldPacket& recvPacket) DEBUG_LOG("WORLD: Received MSG_QUEST_PUSH_RESULT"); - if (_player->GetDivider() != 0) + if (Player *pPlayer = ObjectAccessor::FindPlayer(_player->GetDividerGuid())) { - if (Player *pPlayer = ObjectAccessor::FindPlayer(_player->GetDivider())) - { - WorldPacket data( MSG_QUEST_PUSH_RESULT, (8+1) ); - data << ObjectGuid(guid); - data << uint8(msg); // valid values: 0-8 - pPlayer->GetSession()->SendPacket(&data); - _player->SetDivider( 0 ); - } + WorldPacket data( MSG_QUEST_PUSH_RESULT, (8+1) ); + data << ObjectGuid(guid); + data << uint8(msg); // valid values: 0-8 + pPlayer->GetSession()->SendPacket(&data); + _player->ClearDividerGuid(); } } diff --git a/src/game/WorldSession.cpp b/src/game/WorldSession.cpp index 2bbdaf74030..cd730a462eb 100644 --- a/src/game/WorldSession.cpp +++ b/src/game/WorldSession.cpp @@ -336,8 +336,9 @@ void WorldSession::LogoutPlayer(bool Save) { sLog.outChar("Account: %d (IP: %s) Logout Character:[%s] (guid: %u)", GetAccountId(), GetRemoteAddress().c_str(), _player->GetName() ,_player->GetGUIDLow()); - if (uint64 lguid = GetPlayer()->GetLootGUID()) - DoLootRelease(lguid); + ObjectGuid lootGuid = GetPlayer()->GetLootGuid(); + if (!lootGuid.IsEmpty()) + DoLootRelease(lootGuid); ///- If the player just died before logging out, make him appear as a ghost //FIXME: logout must be delayed in case lost connection with client in time of combat diff --git a/src/game/debugcmds.cpp b/src/game/debugcmds.cpp index 05ef775c57e..13b62c60006 100644 --- a/src/game/debugcmds.cpp +++ b/src/game/debugcmds.cpp @@ -102,7 +102,7 @@ bool ChatHandler::HandleDebugSendSellErrorCommand(char* args) return false; uint8 msg = atoi(args); - m_session->GetPlayer()->SendSellError(SellResult(msg), 0, 0, 0); + m_session->GetPlayer()->SendSellError(SellResult(msg), 0, ObjectGuid(), 0); return true; } diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index b9201ed5c93..3b1c4842d61 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 "11457" + #define REVISION_NR "11458" #endif // __REVISION_NR_H__ From b7616b8813f39e637280884ae1f27af8c316dc3f Mon Sep 17 00:00:00 2001 From: VladimirMangos Date: Mon, 9 May 2011 23:09:39 +0400 Subject: [PATCH 25/43] [11459] More ObjectGuid using in Aura/SpellAuraHolder code. Also fix build in PetAI code. Thanks to rsa for fix code. --- src/game/DynamicObject.cpp | 4 +- src/game/GridNotifiersImpl.h | 2 +- src/game/Object.cpp | 2 +- src/game/Pet.cpp | 4 +- src/game/PetAI.h | 1 + src/game/Player.cpp | 6 +-- src/game/Spell.cpp | 10 ++-- src/game/SpellAuras.cpp | 24 ++++----- src/game/SpellAuras.h | 2 - src/game/SpellEffects.cpp | 30 ++++++----- src/game/SpellHandler.cpp | 2 +- src/game/Unit.cpp | 88 +++++++++++++++++--------------- src/game/Unit.h | 19 +++---- src/game/UnitAuraProcHandler.cpp | 4 +- src/shared/revision_nr.h | 2 +- 15 files changed, 104 insertions(+), 96 deletions(-) diff --git a/src/game/DynamicObject.cpp b/src/game/DynamicObject.cpp index ecbe56e0eeb..9a2a2e703ae 100644 --- a/src/game/DynamicObject.cpp +++ b/src/game/DynamicObject.cpp @@ -160,7 +160,7 @@ void DynamicObject::Delay(int32 delaytime) Unit *target = GetMap()->GetUnit((*iter)); if (target) { - SpellAuraHolder *holder = target->GetSpellAuraHolder(m_spellId, GetCasterGuid().GetRawValue()); + SpellAuraHolder *holder = target->GetSpellAuraHolder(m_spellId, GetCasterGuid()); if (!holder) { ++iter; @@ -183,7 +183,7 @@ void DynamicObject::Delay(int32 delaytime) continue; } - target->DelaySpellAuraHolder(m_spellId, delaytime, GetCasterGuid().GetRawValue()); + target->DelaySpellAuraHolder(m_spellId, delaytime, GetCasterGuid()); ++iter; } else diff --git a/src/game/GridNotifiersImpl.h b/src/game/GridNotifiersImpl.h index a03571384f8..4ddac7a3cb7 100644 --- a/src/game/GridNotifiersImpl.h +++ b/src/game/GridNotifiersImpl.h @@ -160,7 +160,7 @@ inline void MaNGOS::DynamicObjectUpdater::VisitHelper(Unit* target) // Apply PersistentAreaAura on target // in case 2 dynobject overlap areas for same spell, same holder is selected, so dynobjects share holder - SpellAuraHolder *holder = target->GetSpellAuraHolder(spellInfo->Id, i_dynobject.GetCasterGuid().GetRawValue()); + SpellAuraHolder *holder = target->GetSpellAuraHolder(spellInfo->Id, i_dynobject.GetCasterGuid()); if (holder) { diff --git a/src/game/Object.cpp b/src/game/Object.cpp index dfdcde2e5c9..a2523be28a5 100644 --- a/src/game/Object.cpp +++ b/src/game/Object.cpp @@ -603,7 +603,7 @@ void Object::BuildValuesUpdate(uint8 updatetype, ByteBuffer * data, UpdateMask * if (IsPerCasterAuraState) { // IsPerCasterAuraState set if related pet caster aura state set already - if (((Unit*)this)->HasAuraStateForCaster(AURA_STATE_CONFLAGRATE,target->GetGUID())) + if (((Unit*)this)->HasAuraStateForCaster(AURA_STATE_CONFLAGRATE, target->GetObjectGuid())) *data << m_uint32Values[index]; else *data << (m_uint32Values[index] & ~(1 << (AURA_STATE_CONFLAGRATE-1))); diff --git a/src/game/Pet.cpp b/src/game/Pet.cpp index 194add4d032..3ce0afa4c4d 100644 --- a/src/game/Pet.cpp +++ b/src/game/Pet.cpp @@ -1398,7 +1398,7 @@ void Pet::_SaveAuras() //skip all holders from spells that are passive or channeled //do not save single target holders (unless they were cast by the player) - if (save && !holder->IsPassive() && !IsChanneledSpell(holder->GetSpellProto()) && (holder->GetCasterGUID() == GetGUID() || !holder->IsSingleTarget())) + if (save && !holder->IsPassive() && !IsChanneledSpell(holder->GetSpellProto()) && (holder->GetCasterGuid() == GetObjectGuid() || !holder->IsSingleTarget())) { int32 damage[MAX_EFFECT_INDEX]; uint32 periodicTime[MAX_EFFECT_INDEX]; @@ -1412,7 +1412,7 @@ void Pet::_SaveAuras() if (Aura *aur = holder->GetAuraByEffectIndex(SpellEffectIndex(i))) { // don't save not own area auras - if (aur->IsAreaAura() && holder->GetCasterGUID() != GetGUID()) + if (aur->IsAreaAura() && holder->GetCasterGuid() != GetObjectGuid()) continue; damage[i] = aur->GetModifier()->m_amount; diff --git a/src/game/PetAI.h b/src/game/PetAI.h index 4bf1a32160f..492a039adf7 100644 --- a/src/game/PetAI.h +++ b/src/game/PetAI.h @@ -20,6 +20,7 @@ #define MANGOS_PETAI_H #include "CreatureAI.h" +#include "ObjectGuid.h" #include "Timer.h" class Creature; diff --git a/src/game/Player.cpp b/src/game/Player.cpp index 6f17a8c49bf..1d4823ff271 100644 --- a/src/game/Player.cpp +++ b/src/game/Player.cpp @@ -17391,7 +17391,7 @@ void Player::_SaveAuras() SpellAuraHolder *holder = itr->second; //skip all holders from spells that are passive or channeled //do not save single target holders (unless they were cast by the player) - if (!holder->IsPassive() && !IsChanneledSpell(holder->GetSpellProto()) && (holder->GetCasterGUID() == GetGUID() || !holder->IsSingleTarget())) + if (!holder->IsPassive() && !IsChanneledSpell(holder->GetSpellProto()) && (holder->GetCasterGuid() == GetObjectGuid() || !holder->IsSingleTarget())) { int32 damage[MAX_EFFECT_INDEX]; uint32 periodicTime[MAX_EFFECT_INDEX]; @@ -17405,7 +17405,7 @@ void Player::_SaveAuras() if (Aura *aur = holder->GetAuraByEffectIndex(SpellEffectIndex(i))) { // don't save not own area auras - if (aur->IsAreaAura() && holder->GetCasterGUID() != GetGUID()) + if (aur->IsAreaAura() && holder->GetCasterGuid() != GetObjectGuid()) continue; damage[i] = aur->GetModifier()->m_amount; @@ -20736,7 +20736,7 @@ void Player::RemoveItemDependentAurasAndCasts( Item * pItem ) // skip passive (passive item dependent spells work in another way) and not self applied auras SpellEntry const* spellInfo = holder->GetSpellProto(); - if(holder->IsPassive() || holder->GetCasterGUID()!=GetGUID()) + if(holder->IsPassive() || holder->GetCasterGuid() != GetObjectGuid()) { ++itr; continue; diff --git a/src/game/Spell.cpp b/src/game/Spell.cpp index 114734ad3d7..5547d4b978f 100644 --- a/src/game/Spell.cpp +++ b/src/game/Spell.cpp @@ -2876,7 +2876,7 @@ void Spell::cancel() { Unit* unit = m_caster->GetObjectGuid() == (*ihit).targetGUID ? m_caster : ObjectAccessor::GetUnit(*m_caster, ihit->targetGUID); if (unit && unit->isAlive()) - unit->RemoveAurasByCasterSpell(m_spellInfo->Id, m_caster->GetGUID()); + unit->RemoveAurasByCasterSpell(m_spellInfo->Id, m_caster->GetObjectGuid()); } } @@ -3971,12 +3971,12 @@ void Spell::SendChannelUpdate(uint32 time) { if(time == 0) { - m_caster->RemoveAurasByCasterSpell(m_spellInfo->Id, m_caster->GetGUID()); + m_caster->RemoveAurasByCasterSpell(m_spellInfo->Id, m_caster->GetObjectGuid()); ObjectGuid target_guid = m_caster->GetChannelObjectGuid(); if (target_guid != m_caster->GetObjectGuid() && target_guid.IsUnit()) if (Unit* target = ObjectAccessor::GetUnit(*m_caster, target_guid)) - target->RemoveAurasByCasterSpell(m_spellInfo->Id, m_caster->GetGUID()); + target->RemoveAurasByCasterSpell(m_spellInfo->Id, m_caster->GetObjectGuid()); m_caster->SetChannelObjectGuid(ObjectGuid()); m_caster->SetUInt32Value(UNIT_CHANNEL_SPELL, 0); @@ -4561,7 +4561,7 @@ SpellCastResult Spell::CheckCast(bool strict) if(non_caster_target) { // target state requirements (apply to non-self only), to allow cast affects to self like Dirty Deeds - if (m_spellInfo->TargetAuraState && !target->HasAuraStateForCaster(AuraState(m_spellInfo->TargetAuraState), m_caster->GetGUID()) && + if (m_spellInfo->TargetAuraState && !target->HasAuraStateForCaster(AuraState(m_spellInfo->TargetAuraState), m_caster->GetObjectGuid()) && !m_caster->IsIgnoreUnitState(m_spellInfo, m_spellInfo->TargetAuraState == AURA_STATE_FROZEN ? IGNORE_UNIT_TARGET_NON_FROZEN : IGNORE_UNIT_TARGET_STATE)) return SPELL_FAILED_TARGET_AURASTATE; @@ -6561,7 +6561,7 @@ void Spell::DelayedChannel() if ((*ihit).missCondition == SPELL_MISS_NONE) { if (Unit* unit = m_caster->GetObjectGuid() == ihit->targetGUID ? m_caster : ObjectAccessor::GetUnit(*m_caster, ihit->targetGUID)) - unit->DelaySpellAuraHolder(m_spellInfo->Id, delaytime, unit->GetGUID()); + unit->DelaySpellAuraHolder(m_spellInfo->Id, delaytime, unit->GetObjectGuid()); } } diff --git a/src/game/SpellAuras.cpp b/src/game/SpellAuras.cpp index afcd17e0092..6e3579d549e 100644 --- a/src/game/SpellAuras.cpp +++ b/src/game/SpellAuras.cpp @@ -718,7 +718,7 @@ void AreaAura::Update(uint32 diff) if(actualSpellInfo != GetSpellProto()) actualBasePoints = actualSpellInfo->CalculateSimpleValue(m_effIndex); - SpellAuraHolder *holder = (*tIter)->GetSpellAuraHolder(actualSpellInfo->Id, GetCasterGUID()); + SpellAuraHolder *holder = (*tIter)->GetSpellAuraHolder(actualSpellInfo->Id, GetCasterGuid()); bool addedToExisting = true; if (!holder) @@ -763,7 +763,7 @@ void AreaAura::Update(uint32 diff) caster->IsFriendlyTo(target) != needFriendly ) { - target->RemoveSingleAuraFromSpellAuraHolder(GetId(), GetEffIndex(),GetCasterGUID()); + target->RemoveSingleAuraFromSpellAuraHolder(GetId(), GetEffIndex(), GetCasterGuid()); } else if( m_areaAuraType == AREA_AURA_PARTY) // check if in same sub group { @@ -777,10 +777,10 @@ void AreaAura::Update(uint32 diff) { Player* checkTarget = target->GetCharmerOrOwnerPlayerOrPlayerItself(); if(!checkTarget || !pGroup->SameSubGroup(check, checkTarget)) - target->RemoveSingleAuraFromSpellAuraHolder(GetId(), GetEffIndex(),GetCasterGUID()); + target->RemoveSingleAuraFromSpellAuraHolder(GetId(), GetEffIndex(), GetCasterGuid()); } else - target->RemoveSingleAuraFromSpellAuraHolder(GetId(), GetEffIndex(),GetCasterGUID()); + target->RemoveSingleAuraFromSpellAuraHolder(GetId(), GetEffIndex(), GetCasterGuid()); } } else if( m_areaAuraType == AREA_AURA_RAID) // TODO: fix me! @@ -795,16 +795,16 @@ void AreaAura::Update(uint32 diff) { Player* checkTarget = target->GetCharmerOrOwnerPlayerOrPlayerItself(); if(!checkTarget) - target->RemoveSingleAuraFromSpellAuraHolder(GetId(), GetEffIndex(), GetCasterGUID()); + target->RemoveSingleAuraFromSpellAuraHolder(GetId(), GetEffIndex(), GetCasterGuid()); } else - target->RemoveSingleAuraFromSpellAuraHolder(GetId(), GetEffIndex(), GetCasterGUID()); + target->RemoveSingleAuraFromSpellAuraHolder(GetId(), GetEffIndex(), GetCasterGuid()); } } else if (m_areaAuraType == AREA_AURA_PET || m_areaAuraType == AREA_AURA_OWNER) { if (target->GetObjectGuid() != caster->GetCharmerOrOwnerGuid()) - target->RemoveSingleAuraFromSpellAuraHolder(GetId(), GetEffIndex(), GetCasterGUID()); + target->RemoveSingleAuraFromSpellAuraHolder(GetId(), GetEffIndex(), GetCasterGuid()); } } } @@ -9405,13 +9405,13 @@ void SpellAuraHolder::HandleSpellSpecificBoosts(bool apply) else { if (spellId1) - m_target->RemoveAurasByCasterSpell(spellId1, GetCasterGUID()); + m_target->RemoveAurasByCasterSpell(spellId1, GetCasterGuid()); if (spellId2) - m_target->RemoveAurasByCasterSpell(spellId2, GetCasterGUID()); + m_target->RemoveAurasByCasterSpell(spellId2, GetCasterGuid()); if (spellId3) - m_target->RemoveAurasByCasterSpell(spellId3, GetCasterGUID()); + m_target->RemoveAurasByCasterSpell(spellId3, GetCasterGuid()); if (spellId4) - m_target->RemoveAurasByCasterSpell(spellId4, GetCasterGUID()); + m_target->RemoveAurasByCasterSpell(spellId4, GetCasterGuid()); } SetInUse(false); @@ -9464,7 +9464,7 @@ void SpellAuraHolder::Update(uint32 diff) Unit* caster = GetCaster(); if(!caster) { - m_target->RemoveAurasByCasterSpell(GetId(), GetCasterGUID()); + m_target->RemoveAurasByCasterSpell(GetId(), GetCasterGuid()); return; } diff --git a/src/game/SpellAuras.h b/src/game/SpellAuras.h index f771dd743aa..ae6310202b3 100644 --- a/src/game/SpellAuras.h +++ b/src/game/SpellAuras.h @@ -69,7 +69,6 @@ class MANGOS_DLL_SPEC SpellAuraHolder uint32 GetId() const { return m_spellProto->Id; } SpellEntry const* GetSpellProto() const { return m_spellProto; } - uint64 const& GetCasterGUID() const { return m_casterGuid.GetRawValue(); } ObjectGuid const& GetCasterGuid() const { return m_casterGuid; } void SetCasterGuid(ObjectGuid guid) { m_casterGuid = guid; } ObjectGuid const& GetCastItemGuid() const { return m_castItemGuid; } @@ -383,7 +382,6 @@ class MANGOS_DLL_SPEC Aura SpellEntry const* GetSpellProto() const { return GetHolder()->GetSpellProto(); } uint32 GetId() const{ return GetHolder()->GetSpellProto()->Id; } ObjectGuid const& GetCastItemGuid() const { return GetHolder()->GetCastItemGuid(); } - uint64 const& GetCasterGUID() const { return GetHolder()->GetCasterGUID(); }//can't be easy replaced by GetCasterGuid until AuraHolders backporting ig we don't want create additional problems for this. ObjectGuid const& GetCasterGuid() const { return GetHolder()->GetCasterGuid(); } Unit* GetCaster() const { return GetHolder()->GetCaster(); } Unit* GetTarget() const { return GetHolder()->GetTarget(); } diff --git a/src/game/SpellEffects.cpp b/src/game/SpellEffects.cpp index 3debf089c44..3a9a8138f48 100644 --- a/src/game/SpellEffects.cpp +++ b/src/game/SpellEffects.cpp @@ -527,7 +527,7 @@ void Spell::EffectSchoolDMG(SpellEffectIndex effect_idx) // Glyph of Conflagrate if (!m_caster->HasAura(56235)) - unitTarget->RemoveAurasByCasterSpell(aura->GetId(), m_caster->GetGUID()); + unitTarget->RemoveAurasByCasterSpell(aura->GetId(), m_caster->GetObjectGuid()); break; } } @@ -627,7 +627,7 @@ void Spell::EffectSchoolDMG(SpellEffectIndex effect_idx) } if (needConsume) - unitTarget->RemoveAuraHolderFromStack(spellId, doses, m_caster->GetGUID()); + unitTarget->RemoveAuraHolderFromStack(spellId, doses, m_caster->GetObjectGuid()); damage *= doses; damage += int32(((Player*)m_caster)->GetTotalAttackPowerValue(BASE_ATTACK) * 0.09f * doses); @@ -3182,7 +3182,7 @@ void Spell::EffectDummy(SpellEffectIndex eff_idx) } // consume diseases - unitTarget->RemoveAurasWithDispelType(DISPEL_DISEASE, m_caster->GetGUID()); + unitTarget->RemoveAurasWithDispelType(DISPEL_DISEASE, m_caster->GetObjectGuid()); } break; } @@ -4868,7 +4868,7 @@ void Spell::EffectDispel(SpellEffectIndex eff_idx) bool foundDispelled = false; for (std::list >::iterator success_iter = success_list.begin(); success_iter != success_list.end(); ++success_iter) { - if (success_iter->first->GetId() == holder->GetId() && success_iter->first->GetCasterGUID() == holder->GetCasterGUID()) + if (success_iter->first->GetId() == holder->GetId() && success_iter->first->GetCasterGuid() == holder->GetCasterGuid()) { success_iter->second += 1; foundDispelled = true; @@ -4894,7 +4894,7 @@ void Spell::EffectDispel(SpellEffectIndex eff_idx) SpellAuraHolder* dispelledHolder = j->first; data << uint32(dispelledHolder->GetId()); // Spell Id data << uint8(0); // 0 - dispelled !=0 cleansed - unitTarget->RemoveAuraHolderDueToSpellByDispel(dispelledHolder->GetId(), j->second, dispelledHolder->GetCasterGUID(), m_caster); + unitTarget->RemoveAuraHolderDueToSpellByDispel(dispelledHolder->GetId(), j->second, dispelledHolder->GetCasterGuid(), m_caster); } m_caster->SendMessageToSet(&data, true); @@ -7346,7 +7346,7 @@ void Spell::EffectScriptEffect(SpellEffectIndex eff_idx) SpellEntry const *spellInfo = (*itr).second->GetSpellProto(); if(spellInfo->SpellFamilyName == SPELLFAMILY_WARLOCK && (spellInfo->SpellFamilyFlags & UI64LIT(0x0000000000000002)) && - (*itr).second->GetCasterGUID() == m_caster->GetGUID()) + (*itr).second->GetCasterGuid() == m_caster->GetObjectGuid()) (*itr).second->RefreshHolder(); } return; @@ -7378,7 +7378,7 @@ void Spell::EffectScriptEffect(SpellEffectIndex eff_idx) SpellEntry const *spellInfo = (*itr).second->GetSpellProto(); if (spellInfo->SpellFamilyName == SPELLFAMILY_PRIEST && (spellInfo->SpellFamilyFlags & UI64LIT(0x0000000000008000)) && - (*itr).second->GetCasterGUID() == m_caster->GetGUID()) + (*itr).second->GetCasterGuid() == m_caster->GetObjectGuid()) { (*itr).second->RefreshHolder(); return; @@ -7407,7 +7407,7 @@ void Spell::EffectScriptEffect(SpellEffectIndex eff_idx) for(Unit::SpellAuraHolderMap::iterator i = Auras.begin(); i != Auras.end(); ++i) { SpellAuraHolder *holder = i->second; - if (holder->GetCasterGUID() != m_caster->GetGUID()) + if (holder->GetCasterGuid() != m_caster->GetObjectGuid()) continue; // Search only Serpent Sting, Viper Sting, Scorpid Sting auras @@ -8821,7 +8821,8 @@ void Spell::EffectStealBeneficialBuff(SpellEffectIndex eff_idx) if(!unitTarget || unitTarget==m_caster) // can't steal from self return; - std::vector steal_list; + typedef std::vector StealList; + StealList steal_list; // Create dispel mask by dispel type uint32 dispelMask = GetDispellMask( DispelType(m_spellInfo->EffectMiscValue[eff_idx]) ); Unit::SpellAuraHolderMap const& auras = unitTarget->GetSpellAuraHolderMap(); @@ -8838,7 +8839,8 @@ void Spell::EffectStealBeneficialBuff(SpellEffectIndex eff_idx) // Ok if exist some buffs for dispel try dispel it if (!steal_list.empty()) { - std::list < std::pair > success_list; + typedef std::list < std::pair > SuccessList; + SuccessList success_list; int32 list_size = steal_list.size(); // Dispell N = damage buffs (or while exist buffs for dispel) for (int32 count=0; count < damage && list_size > 0; ++count) @@ -8847,13 +8849,13 @@ void Spell::EffectStealBeneficialBuff(SpellEffectIndex eff_idx) SpellAuraHolder *holder = steal_list[urand(0, list_size-1)]; // Not use chance for steal // TODO possible need do it - success_list.push_back( std::pair(holder->GetId(),holder->GetCasterGUID())); + success_list.push_back(SuccessList::value_type(holder->GetId(),holder->GetCasterGuid())); // Remove buff from list for prevent doubles - for (std::vector::iterator j = steal_list.begin(); j != steal_list.end(); ) + for (StealList::iterator j = steal_list.begin(); j != steal_list.end(); ) { SpellAuraHolder *stealed = *j; - if (stealed->GetId() == holder->GetId() && stealed->GetCasterGUID() == holder->GetCasterGUID()) + if (stealed->GetId() == holder->GetId() && stealed->GetCasterGuid() == holder->GetCasterGuid()) { j = steal_list.erase(j); --list_size; @@ -8872,7 +8874,7 @@ void Spell::EffectStealBeneficialBuff(SpellEffectIndex eff_idx) data << uint32(m_spellInfo->Id); // Dispell spell id data << uint8(0); // not used data << uint32(count); // count - for (std::list >::iterator j = success_list.begin(); j != success_list.end(); ++j) + for (SuccessList::iterator j = success_list.begin(); j != success_list.end(); ++j) { SpellEntry const* spellInfo = sSpellStore.LookupEntry(j->first); data << uint32(spellInfo->Id); // Spell Id diff --git a/src/game/SpellHandler.cpp b/src/game/SpellHandler.cpp index 39af52b8e00..772bacbad65 100644 --- a/src/game/SpellHandler.cpp +++ b/src/game/SpellHandler.cpp @@ -479,7 +479,7 @@ void WorldSession::HandleCancelAuraOpcode( WorldPacket& recvPacket) SpellAuraHolder *holder = _player->GetSpellAuraHolder(spellId); // not own area auras can't be cancelled (note: maybe need to check for aura on holder and not general on spell) - if (holder && holder->GetCasterGUID() != _player->GetGUID() && HasAreaAuraEffect(holder->GetSpellProto())) + if (holder && holder->GetCasterGuid() != _player->GetObjectGuid() && HasAreaAuraEffect(holder->GetSpellProto())) return; // non channeled case diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp index 7feec356b9d..1ad6a17dd35 100644 --- a/src/game/Unit.cpp +++ b/src/game/Unit.cpp @@ -3994,10 +3994,10 @@ bool Unit::AddSpellAuraHolder(SpellAuraHolder *holder) for (SpellAuraHolderMap::iterator iter = spair.first; iter != spair.second; ++iter) { SpellAuraHolder *foundHolder = iter->second; - if(foundHolder->GetCasterGUID() == holder->GetCasterGUID()) + if (foundHolder->GetCasterGuid() == holder->GetCasterGuid()) { // Aura can stack on self -> Stack it; - if(aurSpellInfo->StackAmount) + if (aurSpellInfo->StackAmount) { // can be created with >1 stack by some spell mods foundHolder->ModStackAmount(holder->GetStackAmount()); @@ -4241,7 +4241,7 @@ bool Unit::RemoveNoStackAurasDueToAuraHolder(SpellAuraHolder *holder) // single allowed spell specific from same caster or from any caster at target bool is_spellSpecPerTargetPerCaster = IsSingleFromSpellSpecificPerTargetPerCaster(spellId_spec,i_spellId_spec); bool is_spellSpecPerTarget = IsSingleFromSpellSpecificPerTarget(spellId_spec,i_spellId_spec); - if (is_spellSpecPerTarget || (is_spellSpecPerTargetPerCaster && holder->GetCasterGUID() == (*i).second->GetCasterGUID())) + if (is_spellSpecPerTarget || (is_spellSpecPerTargetPerCaster && holder->GetCasterGuid() == (*i).second->GetCasterGuid())) { // cannot remove higher rank if (sSpellMgr.IsRankSpellDueToSpell(spellProto, i_spellId)) @@ -4267,7 +4267,7 @@ bool Unit::RemoveNoStackAurasDueToAuraHolder(SpellAuraHolder *holder) // spell with spell specific that allow single ranks for spell from diff caster // same caster case processed or early or later bool is_spellPerTarget = IsSingleFromSpellSpecificSpellRanksPerTarget(spellId_spec,i_spellId_spec); - if ( is_spellPerTarget && holder->GetCasterGUID() != (*i).second->GetCasterGUID() && sSpellMgr.IsRankSpellDueToSpell(spellProto, i_spellId)) + if ( is_spellPerTarget && holder->GetCasterGuid() != (*i).second->GetCasterGuid() && sSpellMgr.IsRankSpellDueToSpell(spellProto, i_spellId)) { // cannot remove higher rank if(CompareAuraRanks(spellId, i_spellId) < 0) @@ -4351,12 +4351,12 @@ void Unit::RemoveAura(uint32 spellId, SpellEffectIndex effindex, Aura* except) ++iter; } } -void Unit::RemoveAurasByCasterSpell(uint32 spellId, uint64 casterGUID) +void Unit::RemoveAurasByCasterSpell(uint32 spellId, ObjectGuid casterGuid) { SpellAuraHolderBounds spair = GetSpellAuraHolderBounds(spellId); for(SpellAuraHolderMap::iterator iter = spair.first; iter != spair.second; ) { - if (iter->second->GetCasterGUID() == casterGUID) + if (iter->second->GetCasterGuid() == casterGuid) { RemoveSpellAuraHolder(iter->second); spair = GetSpellAuraHolderBounds(spellId); @@ -4367,13 +4367,13 @@ void Unit::RemoveAurasByCasterSpell(uint32 spellId, uint64 casterGUID) } } -void Unit::RemoveSingleAuraFromSpellAuraHolder(uint32 spellId, SpellEffectIndex effindex, uint64 casterGUID, AuraRemoveMode mode) +void Unit::RemoveSingleAuraFromSpellAuraHolder(uint32 spellId, SpellEffectIndex effindex, ObjectGuid casterGuid, AuraRemoveMode mode) { SpellAuraHolderBounds spair = GetSpellAuraHolderBounds(spellId); for(SpellAuraHolderMap::iterator iter = spair.first; iter != spair.second; ) { Aura *aur = iter->second->m_auras[effindex]; - if (aur && aur->GetCasterGUID() == casterGUID) + if (aur && aur->GetCasterGuid() == casterGuid) { RemoveSingleAuraFromSpellAuraHolder(iter->second, effindex, mode); spair = GetSpellAuraHolderBounds(spellId); @@ -4384,7 +4384,7 @@ void Unit::RemoveSingleAuraFromSpellAuraHolder(uint32 spellId, SpellEffectIndex } } -void Unit::RemoveAuraHolderDueToSpellByDispel(uint32 spellId, uint32 stackAmount, uint64 casterGUID, Unit *dispeller) +void Unit::RemoveAuraHolderDueToSpellByDispel(uint32 spellId, uint32 stackAmount, ObjectGuid casterGuid, Unit *dispeller) { SpellEntry const* spellEntry = sSpellStore.LookupEntry(spellId); @@ -4392,32 +4392,32 @@ void Unit::RemoveAuraHolderDueToSpellByDispel(uint32 spellId, uint32 stackAmount // Unstable Affliction if(spellEntry->SpellFamilyName == SPELLFAMILY_WARLOCK && (spellEntry->SpellFamilyFlags & UI64LIT(0x010000000000))) { - if (Aura* dotAura = GetAura(SPELL_AURA_PERIODIC_DAMAGE,SPELLFAMILY_WARLOCK,UI64LIT(0x010000000000),0x00000000,casterGUID)) + if (Aura* dotAura = GetAura(SPELL_AURA_PERIODIC_DAMAGE,SPELLFAMILY_WARLOCK,UI64LIT(0x010000000000), 0x00000000, casterGuid)) { // use clean value for initial damage int32 damage = dotAura->GetSpellProto()->CalculateSimpleValue(EFFECT_INDEX_0); damage *= 9; // Remove spell auras from stack - RemoveAuraHolderFromStack(spellId, stackAmount, casterGUID, AURA_REMOVE_BY_DISPEL); + RemoveAuraHolderFromStack(spellId, stackAmount, casterGuid, AURA_REMOVE_BY_DISPEL); // backfire damage and silence - dispeller->CastCustomSpell(dispeller, 31117, &damage, NULL, NULL, true, NULL, NULL, casterGUID); + dispeller->CastCustomSpell(dispeller, 31117, &damage, NULL, NULL, true, NULL, NULL, casterGuid); return; } } // Lifebloom else if (spellEntry->SpellFamilyName == SPELLFAMILY_DRUID && (spellEntry->SpellFamilyFlags & UI64LIT(0x0000001000000000))) { - if (Aura* dotAura = GetAura(SPELL_AURA_DUMMY, SPELLFAMILY_DRUID, UI64LIT(0x0000001000000000), 0x00000000, casterGUID)) + if (Aura* dotAura = GetAura(SPELL_AURA_DUMMY, SPELLFAMILY_DRUID, UI64LIT(0x0000001000000000), 0x00000000, casterGuid)) { int32 amount = ( dotAura->GetModifier()->m_amount / dotAura->GetStackAmount() ) * stackAmount; - CastCustomSpell(this, 33778, &amount, NULL, NULL, true, NULL, dotAura, casterGUID); + CastCustomSpell(this, 33778, &amount, NULL, NULL, true, NULL, dotAura, casterGuid); if (Unit* caster = dotAura->GetCaster()) { int32 returnmana = (spellEntry->ManaCostPercentage * caster->GetCreateMana() / 100) * stackAmount / 2; - caster->CastCustomSpell(caster, 64372, &returnmana, NULL, NULL, true, NULL, dotAura, casterGUID); + caster->CastCustomSpell(caster, 64372, &returnmana, NULL, NULL, true, NULL, dotAura, casterGuid); } } } @@ -4427,7 +4427,7 @@ void Unit::RemoveAuraHolderDueToSpellByDispel(uint32 spellId, uint32 stackAmount Unit* caster = NULL; uint32 triggeredSpell = 0; - if (Aura* dotAura = GetAura(SPELL_AURA_PERIODIC_DAMAGE, SPELLFAMILY_SHAMAN, UI64LIT(0x10000000), 0x00000000, casterGUID)) + if (Aura* dotAura = GetAura(SPELL_AURA_PERIODIC_DAMAGE, SPELLFAMILY_SHAMAN, UI64LIT(0x10000000), 0x00000000, casterGuid)) caster = dotAura->GetCaster(); if (caster && !caster->isDead()) @@ -4447,7 +4447,7 @@ void Unit::RemoveAuraHolderDueToSpellByDispel(uint32 spellId, uint32 stackAmount } // Remove spell auras from stack - RemoveAuraHolderFromStack(spellId, stackAmount, casterGUID, AURA_REMOVE_BY_DISPEL); + RemoveAuraHolderFromStack(spellId, stackAmount, casterGuid, AURA_REMOVE_BY_DISPEL); // Haste if (triggeredSpell) @@ -4457,7 +4457,7 @@ void Unit::RemoveAuraHolderDueToSpellByDispel(uint32 spellId, uint32 stackAmount // Vampiric touch (first dummy aura) else if (spellEntry->SpellFamilyName == SPELLFAMILY_PRIEST && spellEntry->SpellFamilyFlags & UI64LIT(0x0000040000000000)) { - if (Aura *dot = GetAura(SPELL_AURA_PERIODIC_DAMAGE, SPELLFAMILY_PRIEST, UI64LIT(0x0000040000000000), 0x00000000, casterGUID)) + if (Aura *dot = GetAura(SPELL_AURA_PERIODIC_DAMAGE, SPELLFAMILY_PRIEST, UI64LIT(0x0000040000000000), 0x00000000, casterGuid)) { if (dot->GetCaster()) { @@ -4466,20 +4466,20 @@ void Unit::RemoveAuraHolderDueToSpellByDispel(uint32 spellId, uint32 stackAmount bp0 *= 8; // Remove spell auras from stack - RemoveAuraHolderFromStack(spellId, stackAmount, casterGUID, AURA_REMOVE_BY_DISPEL); + RemoveAuraHolderFromStack(spellId, stackAmount, casterGuid, AURA_REMOVE_BY_DISPEL); - CastCustomSpell(this, 64085, &bp0, NULL, NULL, true, NULL, NULL, casterGUID); + CastCustomSpell(this, 64085, &bp0, NULL, NULL, true, NULL, NULL, casterGuid); return; } } } - RemoveAuraHolderFromStack(spellId, stackAmount, casterGUID, AURA_REMOVE_BY_DISPEL); + RemoveAuraHolderFromStack(spellId, stackAmount, casterGuid, AURA_REMOVE_BY_DISPEL); } -void Unit::RemoveAurasDueToSpellBySteal(uint32 spellId, uint64 casterGUID, Unit *stealer) +void Unit::RemoveAurasDueToSpellBySteal(uint32 spellId, ObjectGuid casterGuid, Unit *stealer) { - SpellAuraHolder *holder = GetSpellAuraHolder(spellId, casterGUID); + SpellAuraHolder *holder = GetSpellAuraHolder(spellId, casterGuid); SpellEntry const* spellProto = sSpellStore.LookupEntry(spellId); SpellAuraHolder *new_holder = CreateSpellAuraHolder(spellProto, stealer, this); @@ -4532,16 +4532,16 @@ void Unit::RemoveAurasDueToSpellByCancel(uint32 spellId) } } -void Unit::RemoveAurasWithDispelType( DispelType type, uint64 casterGUID ) +void Unit::RemoveAurasWithDispelType(DispelType type, ObjectGuid casterGuid) { // Create dispel mask by dispel type uint32 dispelMask = GetDispellMask(type); // Dispel all existing auras vs current dispel type SpellAuraHolderMap& auras = GetSpellAuraHolderMap(); - for(SpellAuraHolderMap::iterator itr = auras.begin(); itr != auras.end(); ) + for (SpellAuraHolderMap::iterator itr = auras.begin(); itr != auras.end(); ) { SpellEntry const* spell = itr->second->GetSpellProto(); - if( ((1<Dispel) & dispelMask) && (!casterGUID || casterGUID == itr->second->GetCasterGUID())) + if (((1<Dispel) & dispelMask) && (casterGuid.IsEmpty() || casterGuid == itr->second->GetCasterGuid())) { // Dispel aura RemoveAurasDueToSpell(spell->Id); @@ -4552,12 +4552,12 @@ void Unit::RemoveAurasWithDispelType( DispelType type, uint64 casterGUID ) } } -void Unit::RemoveAuraHolderFromStack(uint32 spellId, uint32 stackAmount, uint64 casterGUID, AuraRemoveMode mode) +void Unit::RemoveAuraHolderFromStack(uint32 spellId, uint32 stackAmount, ObjectGuid casterGuid, AuraRemoveMode mode) { SpellAuraHolderBounds spair = GetSpellAuraHolderBounds(spellId); - for(SpellAuraHolderMap::iterator iter = spair.first; iter != spair.second; ++iter) + for (SpellAuraHolderMap::iterator iter = spair.first; iter != spair.second; ++iter) { - if (!casterGUID || iter->second->GetCasterGUID() == casterGUID) + if (casterGuid.IsEmpty() || iter->second->GetCasterGuid() == casterGuid) { if (iter->second->ModStackAmount(-int32(stackAmount))) { @@ -4671,7 +4671,7 @@ void Unit::RemoveNotOwnSingleTargetAuras(uint32 newPhase) // remove from target if target found if (Unit* itr_target = GetMap()->GetUnit(itr_targetGuid)) - itr_target->RemoveAurasByCasterSpell(itr_spellEntry->Id, GetGUID()); + itr_target->RemoveAurasByCasterSpell(itr_spellEntry->Id, GetObjectGuid()); itr = scTargets.begin(); // list can be changed at remove aura continue; @@ -4685,7 +4685,7 @@ void Unit::RemoveNotOwnSingleTargetAuras(uint32 newPhase) // remove from target if target found if (itr_target) - itr_target->RemoveAurasByCasterSpell(itr_spellEntry->Id, GetGUID()); + itr_target->RemoveAurasByCasterSpell(itr_spellEntry->Id, GetObjectGuid()); itr = scTargets.begin(); // list can be changed at remove aura continue; @@ -4858,14 +4858,14 @@ void Unit::RemoveAllAurasOnDeath() } } -void Unit::DelaySpellAuraHolder(uint32 spellId, int32 delaytime, uint64 casterGUID) +void Unit::DelaySpellAuraHolder(uint32 spellId, int32 delaytime, ObjectGuid casterGuid) { SpellAuraHolderBounds bounds = GetSpellAuraHolderBounds(spellId); for (SpellAuraHolderMap::iterator iter = bounds.first; iter != bounds.second; ++iter) { SpellAuraHolder* holder = iter->second; - if (casterGUID != holder->GetCasterGUID()) + if (casterGuid != holder->GetCasterGuid()) continue; if (holder->GetAuraDuration() < delaytime) @@ -5763,19 +5763,19 @@ void Unit::RemoveAllAttackers() } } -bool Unit::HasAuraStateForCaster(AuraState flag, uint64 caster) const +bool Unit::HasAuraStateForCaster(AuraState flag, ObjectGuid casterGuid) const { - if(!HasAuraState(flag)) + if (!HasAuraState(flag)) return false; // single per-caster aura state - if(flag == AURA_STATE_CONFLAGRATE) + if (flag == AURA_STATE_CONFLAGRATE) { Unit::AuraList const& dotList = GetAurasByType(SPELL_AURA_PERIODIC_DAMAGE); - for(Unit::AuraList::const_iterator i = dotList.begin(); i != dotList.end(); ++i) + for (Unit::AuraList::const_iterator i = dotList.begin(); i != dotList.end(); ++i) { if ((*i)->GetSpellProto()->SpellFamilyName == SPELLFAMILY_WARLOCK && - (*i)->GetCasterGUID() == caster && + (*i)->GetCasterGuid() == casterGuid && // Immolate (((*i)->GetSpellProto()->SpellFamilyFlags & UI64LIT(0x0000000000000004)) || // Shadowflame @@ -10734,11 +10734,17 @@ bool Unit::CheckAndIncreaseCastCounter() return true; } -SpellAuraHolder* Unit::GetSpellAuraHolder (uint32 spellid, uint64 casterGUID) +SpellAuraHolder* Unit::GetSpellAuraHolder (uint32 spellid) const { - SpellAuraHolderBounds bounds = GetSpellAuraHolderBounds(spellid); + SpellAuraHolderMap::const_iterator itr = m_spellAuraHolders.find(spellid); + return itr != m_spellAuraHolders.end() ? itr->second : NULL; +} + +SpellAuraHolder* Unit::GetSpellAuraHolder (uint32 spellid, ObjectGuid casterGuid) const +{ + SpellAuraHolderConstBounds bounds = GetSpellAuraHolderBounds(spellid); for (SpellAuraHolderMap::const_iterator iter = bounds.first; iter != bounds.second; ++iter) - if (!casterGUID || iter->second->GetCasterGUID() == casterGUID) + if (iter->second->GetCasterGuid() == casterGuid) return iter->second; return NULL; diff --git a/src/game/Unit.h b/src/game/Unit.h index 8adbf60f6dc..d9f65148adc 100644 --- a/src/game/Unit.h +++ b/src/game/Unit.h @@ -1571,13 +1571,13 @@ class MANGOS_DLL_SPEC Unit : public WorldObject void RemoveAura(uint32 spellId, SpellEffectIndex effindex, Aura* except = NULL); void RemoveSpellAuraHolder(SpellAuraHolder *holder, AuraRemoveMode mode = AURA_REMOVE_BY_DEFAULT); void RemoveSingleAuraFromSpellAuraHolder(SpellAuraHolder *holder, SpellEffectIndex index, AuraRemoveMode mode = AURA_REMOVE_BY_DEFAULT); - void RemoveSingleAuraFromSpellAuraHolder(uint32 id, SpellEffectIndex index, uint64 casterGUID, AuraRemoveMode mode = AURA_REMOVE_BY_DEFAULT); + void RemoveSingleAuraFromSpellAuraHolder(uint32 id, SpellEffectIndex index, ObjectGuid casterGuid, AuraRemoveMode mode = AURA_REMOVE_BY_DEFAULT); // removing specific aura stacks by diff reasons and selections void RemoveAurasDueToSpell(uint32 spellId, SpellAuraHolder* except = NULL, AuraRemoveMode mode = AURA_REMOVE_BY_DEFAULT); void RemoveAurasDueToItemSpell(Item* castItem,uint32 spellId); - void RemoveAurasByCasterSpell(uint32 spellId, uint64 casterGUID); - void RemoveAurasDueToSpellBySteal(uint32 spellId, uint64 casterGUID, Unit *stealer); + void RemoveAurasByCasterSpell(uint32 spellId, ObjectGuid casterGuid); + void RemoveAurasDueToSpellBySteal(uint32 spellId, ObjectGuid casterGuid, Unit *stealer); void RemoveAurasDueToSpellByCancel(uint32 spellId); // removing unknown aura stacks by diff reasons and selections @@ -1589,16 +1589,16 @@ class MANGOS_DLL_SPEC Unit : public WorldObject bool RemoveNoStackAurasDueToAuraHolder(SpellAuraHolder *holder); void RemoveAurasWithInterruptFlags(uint32 flags); void RemoveAurasWithAttribute(uint32 flags); - void RemoveAurasWithDispelType( DispelType type, uint64 casterGUID = 0 ); + void RemoveAurasWithDispelType(DispelType type, ObjectGuid casterGuid = ObjectGuid()); void RemoveAllAuras(AuraRemoveMode mode = AURA_REMOVE_BY_DEFAULT); void RemoveArenaAuras(bool onleave = false); void RemoveAllAurasOnDeath(); // removing specific aura FROM stack by diff reasons and selections - void RemoveAuraHolderFromStack(uint32 spellId, uint32 stackAmount = 1, uint64 casterGUID = 0, AuraRemoveMode mode = AURA_REMOVE_BY_DEFAULT); - void RemoveAuraHolderDueToSpellByDispel(uint32 spellId, uint32 stackAmount, uint64 casterGUID, Unit *dispeller); + void RemoveAuraHolderFromStack(uint32 spellId, uint32 stackAmount = 1, ObjectGuid casterGuid = ObjectGuid(), AuraRemoveMode mode = AURA_REMOVE_BY_DEFAULT); + void RemoveAuraHolderDueToSpellByDispel(uint32 spellId, uint32 stackAmount, ObjectGuid casterGuid, Unit *dispeller); - void DelaySpellAuraHolder(uint32 spellId, int32 delaytime, uint64 casterGUID); + void DelaySpellAuraHolder(uint32 spellId, int32 delaytime, ObjectGuid casterGuid); float GetResistanceBuffMods(SpellSchools school, bool positive) const { return GetFloatValue(positive ? UNIT_FIELD_RESISTANCEBUFFMODSPOSITIVE+school : UNIT_FIELD_RESISTANCEBUFFMODSNEGATIVE+school ); } void SetResistanceBuffMods(SpellSchools school, bool positive, float val) { SetFloatValue(positive ? UNIT_FIELD_RESISTANCEBUFFMODSPOSITIVE+school : UNIT_FIELD_RESISTANCEBUFFMODSNEGATIVE+school,val); } @@ -1757,7 +1757,8 @@ class MANGOS_DLL_SPEC Unit : public WorldObject Aura* GetAura(uint32 spellId, SpellEffectIndex effindex); Aura* GetAura(AuraType type, SpellFamily family, uint64 familyFlag, uint32 familyFlag2 = 0, ObjectGuid casterGuid = ObjectGuid()); - SpellAuraHolder* GetSpellAuraHolder (uint32 spellid, uint64 casterGUID = 0); + SpellAuraHolder* GetSpellAuraHolder (uint32 spellid) const; + SpellAuraHolder* GetSpellAuraHolder (uint32 spellid, ObjectGuid casterGUID) const; SpellAuraHolderMap & GetSpellAuraHolderMap() { return m_spellAuraHolders; } SpellAuraHolderMap const& GetSpellAuraHolderMap() const { return m_spellAuraHolders; } @@ -1813,7 +1814,7 @@ class MANGOS_DLL_SPEC Unit : public WorldObject float GetAPMultiplier(WeaponAttackType attType, bool normalized); void ModifyAuraState(AuraState flag, bool apply); bool HasAuraState(AuraState flag) const { return HasFlag(UNIT_FIELD_AURASTATE, 1<<(flag-1)); } - bool HasAuraStateForCaster(AuraState flag, uint64 caster) const; + bool HasAuraStateForCaster(AuraState flag, ObjectGuid casterGuid) const; void UnsummonAllTotems(); Unit* SelectMagnetTarget(Unit *victim, Spell* spell = NULL, SpellEffectIndex eff = EFFECT_INDEX_0); diff --git a/src/game/UnitAuraProcHandler.cpp b/src/game/UnitAuraProcHandler.cpp index d4ace8b3955..21117bd37bc 100644 --- a/src/game/UnitAuraProcHandler.cpp +++ b/src/game/UnitAuraProcHandler.cpp @@ -3731,10 +3731,10 @@ SpellAuraProcResult Unit::HandleMendingAuraProc( Unit* /*pVictim*/, uint32 /*dam // remove before apply next (locked against deleted) triggeredByAura->SetInUse(true); - RemoveAurasByCasterSpell(spellProto->Id,caster->GetGUID()); + RemoveAurasByCasterSpell(spellProto->Id,caster->GetObjectGuid()); caster->AddSpellMod(mod, true); - CastCustomSpell(target,spellProto->Id,&heal,NULL,NULL,true,NULL,triggeredByAura,caster->GetGUID()); + CastCustomSpell(target, spellProto->Id, &heal, NULL, NULL, true, NULL, triggeredByAura, caster->GetObjectGuid()); caster->AddSpellMod(mod, false); triggeredByAura->SetInUse(false); } diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index 3b1c4842d61..367d18d2e0c 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 "11458" + #define REVISION_NR "11459" #endif // __REVISION_NR_H__ From 82d32545bf259451c4695531fb51374865b50da8 Mon Sep 17 00:00:00 2001 From: VladimirMangos Date: Tue, 10 May 2011 11:03:54 +0400 Subject: [PATCH 26/43] [11460] Use ObjectGuids in last missing cases in AI classes. --- src/game/AggressorAI.cpp | 10 +++++----- src/game/AggressorAI.h | 4 +++- src/game/CreatureAI.cpp | 2 +- src/game/CreatureAI.h | 3 ++- src/game/FleeingMovementGenerator.cpp | 12 +++++------- src/game/FleeingMovementGenerator.h | 7 ++++--- src/game/MotionMaster.cpp | 6 +++--- src/game/PetAI.cpp | 2 +- src/game/ReactorAI.cpp | 8 ++++---- src/game/ReactorAI.h | 5 +++-- src/game/TotemAI.cpp | 8 ++++---- src/game/TotemAI.h | 3 ++- src/shared/revision_nr.h | 2 +- 13 files changed, 38 insertions(+), 34 deletions(-) diff --git a/src/game/AggressorAI.cpp b/src/game/AggressorAI.cpp index a07f9d4079c..03f0b754355 100644 --- a/src/game/AggressorAI.cpp +++ b/src/game/AggressorAI.cpp @@ -37,7 +37,7 @@ AggressorAI::Permissible(const Creature *creature) return PERMIT_BASE_NO; } -AggressorAI::AggressorAI(Creature *c) : CreatureAI(c), i_victimGuid(0), i_state(STATE_NORMAL), i_tracker(TIME_INTERVAL_LOOK) +AggressorAI::AggressorAI(Creature *c) : CreatureAI(c), i_state(STATE_NORMAL), i_tracker(TIME_INTERVAL_LOOK) { } @@ -73,7 +73,7 @@ void AggressorAI::EnterEvadeMode() if (!m_creature->isAlive()) { DEBUG_FILTER_LOG(LOG_FILTER_AI_AND_MOVEGENSS, "Creature stopped attacking, he is dead [guid=%u]", m_creature->GetGUIDLow()); - i_victimGuid = 0; + i_victimGuid.Clear(); m_creature->CombatStop(true); m_creature->DeleteThreatList(); return; @@ -114,7 +114,7 @@ void AggressorAI::EnterEvadeMode() } m_creature->DeleteThreatList(); - i_victimGuid = 0; + i_victimGuid.Clear(); m_creature->CombatStop(true); m_creature->SetLootRecipient(NULL); } @@ -126,7 +126,7 @@ AggressorAI::UpdateAI(const uint32 /*diff*/) if(!m_creature->SelectHostileTarget() || !m_creature->getVictim()) return; - i_victimGuid = m_creature->getVictim()->GetGUID(); + i_victimGuid = m_creature->getVictim()->GetObjectGuid(); DoMeleeAttackIfReady(); } @@ -146,7 +146,7 @@ AggressorAI::AttackStart(Unit *u) if(m_creature->Attack(u,true)) { - i_victimGuid = u->GetGUID(); + i_victimGuid = u->GetObjectGuid(); m_creature->AddThreat(u); m_creature->SetInCombatWith(u); diff --git a/src/game/AggressorAI.h b/src/game/AggressorAI.h index 2277b64ec54..9f0b00d3c10 100644 --- a/src/game/AggressorAI.h +++ b/src/game/AggressorAI.h @@ -21,6 +21,7 @@ #include "CreatureAI.h" #include "Timer.h" +#include "ObjectGuid.h" class Creature; @@ -45,8 +46,9 @@ class MANGOS_DLL_DECL AggressorAI : public CreatureAI static int Permissible(const Creature *); private: - uint64 i_victimGuid; + ObjectGuid i_victimGuid; AggressorState i_state; TimeTracker i_tracker; }; + #endif diff --git a/src/game/CreatureAI.cpp b/src/game/CreatureAI.cpp index 8be95b7ab40..fd0829ca4ae 100644 --- a/src/game/CreatureAI.cpp +++ b/src/game/CreatureAI.cpp @@ -73,7 +73,7 @@ CanCastResult CreatureAI::CanCastSpell(Unit* pTarget, const SpellEntry *pSpell, return CAST_FAIL_OTHER; } -CanCastResult CreatureAI::DoCastSpellIfCan(Unit* pTarget, uint32 uiSpell, uint32 uiCastFlags, uint64 uiOriginalCasterGUID) +CanCastResult CreatureAI::DoCastSpellIfCan(Unit* pTarget, uint32 uiSpell, uint32 uiCastFlags, ObjectGuid uiOriginalCasterGUID) { Unit* pCaster = m_creature; diff --git a/src/game/CreatureAI.h b/src/game/CreatureAI.h index 401b6e03870..10ea75c21a5 100644 --- a/src/game/CreatureAI.h +++ b/src/game/CreatureAI.h @@ -24,6 +24,7 @@ #include "Policies/Singleton.h" #include "Dynamic/ObjectRegistry.h" #include "Dynamic/FactoryHolder.h" +#include "ObjectGuid.h" class WorldObject; class GameObject; @@ -156,7 +157,7 @@ class MANGOS_DLL_SPEC CreatureAI ///== Helper functions ============================= bool DoMeleeAttackIfReady(); - CanCastResult DoCastSpellIfCan(Unit* pTarget, uint32 uiSpell, uint32 uiCastFlags = 0, uint64 uiOriginalCasterGUID = 0); + CanCastResult DoCastSpellIfCan(Unit* pTarget, uint32 uiSpell, uint32 uiCastFlags = 0, ObjectGuid uiOriginalCasterGUID = ObjectGuid()); ///== Fields ======================================= diff --git a/src/game/FleeingMovementGenerator.cpp b/src/game/FleeingMovementGenerator.cpp index 64940e08e9c..c4287f3ce88 100644 --- a/src/game/FleeingMovementGenerator.cpp +++ b/src/game/FleeingMovementGenerator.cpp @@ -189,9 +189,9 @@ FleeingMovementGenerator::_setMoveData(T &owner) { float cur_dist_xyz = owner.GetDistance(i_caster_x, i_caster_y, i_caster_z); - if(i_to_distance_from_caster > 0.0f) + if (i_to_distance_from_caster > 0.0f) { - if((i_last_distance_from_caster > i_to_distance_from_caster && cur_dist_xyz < i_to_distance_from_caster) || + if ((i_last_distance_from_caster > i_to_distance_from_caster && cur_dist_xyz < i_to_distance_from_caster) || // if we reach lower distance (i_last_distance_from_caster > i_to_distance_from_caster && cur_dist_xyz > i_last_distance_from_caster) || // if we can't be close @@ -217,12 +217,10 @@ FleeingMovementGenerator::_setMoveData(T &owner) float cur_dist; float angle_to_caster; - Unit * fright = ObjectAccessor::GetUnit(owner, i_frightGUID); - - if(fright) + if (Unit* fright = owner.GetMap()->GetUnit(i_frightGuid)) { cur_dist = fright->GetDistance(&owner); - if(cur_dist < cur_dist_xyz) + if (cur_dist < cur_dist_xyz) { i_caster_x = fright->GetPositionX(); i_caster_y = fright->GetPositionY(); @@ -286,7 +284,7 @@ FleeingMovementGenerator::Initialize(T &owner) _Init(owner); - if(Unit * fright = ObjectAccessor::GetUnit(owner, i_frightGUID)) + if (Unit * fright = owner.GetMap()->GetUnit(i_frightGuid)) { i_caster_x = fright->GetPositionX(); i_caster_y = fright->GetPositionY(); diff --git a/src/game/FleeingMovementGenerator.h b/src/game/FleeingMovementGenerator.h index f3b2b2654f6..7803197cf4f 100644 --- a/src/game/FleeingMovementGenerator.h +++ b/src/game/FleeingMovementGenerator.h @@ -22,13 +22,14 @@ #include "MovementGenerator.h" #include "DestinationHolder.h" #include "Traveller.h" +#include "ObjectGuid.h" template class MANGOS_DLL_SPEC FleeingMovementGenerator : public MovementGeneratorMedium< T, FleeingMovementGenerator > { public: - FleeingMovementGenerator(uint64 fright) : i_frightGUID(fright), i_nextCheckTime(0) {} + FleeingMovementGenerator(ObjectGuid fright) : i_frightGuid(fright), i_nextCheckTime(0) {} void Initialize(T &); void Finalize(T &); @@ -54,7 +55,7 @@ class MANGOS_DLL_SPEC FleeingMovementGenerator float i_last_distance_from_caster; float i_to_distance_from_caster; float i_cur_angle; - uint64 i_frightGUID; + ObjectGuid i_frightGuid; TimeTracker i_nextCheckTime; DestinationHolder< Traveller > i_destinationHolder; @@ -64,7 +65,7 @@ class MANGOS_DLL_SPEC TimedFleeingMovementGenerator : public FleeingMovementGenerator { public: - TimedFleeingMovementGenerator(uint64 fright, uint32 time) : + TimedFleeingMovementGenerator(ObjectGuid fright, uint32 time) : FleeingMovementGenerator(fright), i_totalFleeTime(time) {} diff --git a/src/game/MotionMaster.cpp b/src/game/MotionMaster.cpp index b01c3241d22..dea2b6927cf 100644 --- a/src/game/MotionMaster.cpp +++ b/src/game/MotionMaster.cpp @@ -345,13 +345,13 @@ void MotionMaster::MoveFleeing(Unit* enemy, uint32 time) DEBUG_FILTER_LOG(LOG_FILTER_AI_AND_MOVEGENSS, "%s flee from %s", m_owner->GetGuidStr().c_str(), enemy->GetGuidStr().c_str()); if (m_owner->GetTypeId() == TYPEID_PLAYER) - Mutate(new FleeingMovementGenerator(enemy->GetGUID())); + Mutate(new FleeingMovementGenerator(enemy->GetObjectGuid())); else { if (time) - Mutate(new TimedFleeingMovementGenerator(enemy->GetGUID(), time)); + Mutate(new TimedFleeingMovementGenerator(enemy->GetObjectGuid(), time)); else - Mutate(new FleeingMovementGenerator(enemy->GetGUID())); + Mutate(new FleeingMovementGenerator(enemy->GetObjectGuid())); } } diff --git a/src/game/PetAI.cpp b/src/game/PetAI.cpp index ae9b2eaada2..5692eaf0bba 100644 --- a/src/game/PetAI.cpp +++ b/src/game/PetAI.cpp @@ -252,7 +252,7 @@ void PetAI::UpdateAI(const uint32 diff) bool spellUsed = false; for (AllySet::const_iterator tar = m_AllySet.begin(); tar != m_AllySet.end(); ++tar) { - Unit* Target = ObjectAccessor::GetUnit(*m_creature,*tar); + Unit* Target = m_creature->GetMap()->GetUnit(*tar); //only buff targets that are in combat, unless the spell can only be cast while out of combat if (!Target) diff --git a/src/game/ReactorAI.cpp b/src/game/ReactorAI.cpp index f530f95567c..0a32c864ee0 100644 --- a/src/game/ReactorAI.cpp +++ b/src/game/ReactorAI.cpp @@ -48,7 +48,7 @@ ReactorAI::AttackStart(Unit *p) if(m_creature->Attack(p,true)) { DEBUG_FILTER_LOG(LOG_FILTER_AI_AND_MOVEGENSS, "Tag unit GUID: %u (TypeId: %u) as a victim", p->GetGUIDLow(), p->GetTypeId()); - i_victimGuid = p->GetGUID(); + i_victimGuid = p->GetObjectGuid(); m_creature->AddThreat(p); m_creature->SetInCombatWith(p); @@ -71,7 +71,7 @@ ReactorAI::UpdateAI(const uint32 /*time_diff*/) if (!m_creature->SelectHostileTarget() || !m_creature->getVictim()) return; - i_victimGuid = m_creature->getVictim()->GetGUID(); + i_victimGuid = m_creature->getVictim()->GetObjectGuid(); DoMeleeAttackIfReady(); } @@ -84,7 +84,7 @@ ReactorAI::EnterEvadeMode() DEBUG_FILTER_LOG(LOG_FILTER_AI_AND_MOVEGENSS, "Creature stopped attacking, he is dead [guid=%u]", m_creature->GetGUIDLow()); m_creature->GetMotionMaster()->MovementExpired(); m_creature->GetMotionMaster()->MoveIdle(); - i_victimGuid = 0; + i_victimGuid.Clear(); m_creature->CombatStop(true); m_creature->DeleteThreatList(); return; @@ -111,7 +111,7 @@ ReactorAI::EnterEvadeMode() m_creature->RemoveAllAuras(); m_creature->DeleteThreatList(); - i_victimGuid = 0; + i_victimGuid.Clear(); m_creature->CombatStop(true); m_creature->SetLootRecipient(NULL); diff --git a/src/game/ReactorAI.h b/src/game/ReactorAI.h index e0579f82102..3da990f5e52 100644 --- a/src/game/ReactorAI.h +++ b/src/game/ReactorAI.h @@ -20,6 +20,7 @@ #define MANGOS_REACTORAI_H #include "CreatureAI.h" +#include "ObjectGuid.h" class Unit; @@ -27,7 +28,7 @@ class MANGOS_DLL_DECL ReactorAI : public CreatureAI { public: - explicit ReactorAI(Creature *c) : CreatureAI(c), i_victimGuid(0) {} + explicit ReactorAI(Creature *c) : CreatureAI(c) {} void MoveInLineOfSight(Unit *); void AttackStart(Unit *); @@ -38,6 +39,6 @@ class MANGOS_DLL_DECL ReactorAI : public CreatureAI static int Permissible(const Creature *); private: - uint64 i_victimGuid; + ObjectGuid i_victimGuid; }; #endif diff --git a/src/game/TotemAI.cpp b/src/game/TotemAI.cpp index 1b9a81eab0b..d3467e2a17b 100644 --- a/src/game/TotemAI.cpp +++ b/src/game/TotemAI.cpp @@ -35,7 +35,7 @@ TotemAI::Permissible(const Creature *creature) return PERMIT_BASE_NO; } -TotemAI::TotemAI(Creature *c) : CreatureAI(c), i_victimGuid(0) +TotemAI::TotemAI(Creature *c) : CreatureAI(c) { } @@ -70,7 +70,7 @@ TotemAI::UpdateAI(const uint32 /*diff*/) // SPELLMOD_RANGE not applied in this place just because nonexistent range mods for attacking totems // pointer to appropriate target if found any - Unit* victim = i_victimGuid ? m_creature->GetMap()->GetUnit(i_victimGuid) : NULL; + Unit* victim = m_creature->GetMap()->GetUnit(i_victimGuid); // Search victim if no, not attackable, or out of range, or friendly (possible in case duel end) if( !victim || @@ -88,14 +88,14 @@ TotemAI::UpdateAI(const uint32 /*diff*/) if (victim) { // remember - i_victimGuid = victim->GetGUID(); + i_victimGuid = victim->GetObjectGuid(); // attack m_creature->SetInFront(victim); // client change orientation by self m_creature->CastSpell(victim, getTotem().GetSpell(), false); } else - i_victimGuid = 0; + i_victimGuid.Clear(); } bool diff --git a/src/game/TotemAI.h b/src/game/TotemAI.h index 43dd34bf8d1..fc983793d59 100644 --- a/src/game/TotemAI.h +++ b/src/game/TotemAI.h @@ -20,6 +20,7 @@ #define MANGOS_TOTEMAI_H #include "CreatureAI.h" +#include "ObjectGuid.h" #include "Timer.h" class Creature; @@ -42,6 +43,6 @@ class MANGOS_DLL_DECL TotemAI : public CreatureAI Totem& getTotem(); private: - uint64 i_victimGuid; + ObjectGuid i_victimGuid; }; #endif diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index 367d18d2e0c..a8ce501ce58 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 "11459" + #define REVISION_NR "11460" #endif // __REVISION_NR_H__ From 7d754c6668471f0c7a80d1603f3841f220c3364f Mon Sep 17 00:00:00 2001 From: VladimirMangos Date: Tue, 10 May 2011 11:19:38 +0400 Subject: [PATCH 27/43] [11461] Use ObjectGuid in GuardAI also... --- src/game/GuardAI.cpp | 10 +++++----- src/game/GuardAI.h | 3 ++- src/shared/revision_nr.h | 2 +- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/game/GuardAI.cpp b/src/game/GuardAI.cpp index c477303ff34..486cc3c58fd 100644 --- a/src/game/GuardAI.cpp +++ b/src/game/GuardAI.cpp @@ -30,7 +30,7 @@ int GuardAI::Permissible(const Creature *creature) return PERMIT_BASE_NO; } -GuardAI::GuardAI(Creature *c) : CreatureAI(c), i_victimGuid(0), i_state(STATE_NORMAL), i_tracker(TIME_INTERVAL_LOOK) +GuardAI::GuardAI(Creature *c) : CreatureAI(c), i_state(STATE_NORMAL), i_tracker(TIME_INTERVAL_LOOK) { } @@ -64,7 +64,7 @@ void GuardAI::EnterEvadeMode() i_state = STATE_NORMAL; - i_victimGuid = 0; + i_victimGuid.Clear(); m_creature->CombatStop(true); m_creature->DeleteThreatList(); return; @@ -95,7 +95,7 @@ void GuardAI::EnterEvadeMode() m_creature->RemoveAllAuras(); m_creature->DeleteThreatList(); - i_victimGuid = 0; + i_victimGuid.Clear(); m_creature->CombatStop(true); i_state = STATE_NORMAL; @@ -110,7 +110,7 @@ void GuardAI::UpdateAI(const uint32 /*diff*/) if (!m_creature->SelectHostileTarget() || !m_creature->getVictim()) return; - i_victimGuid = m_creature->getVictim()->GetGUID(); + i_victimGuid = m_creature->getVictim()->GetObjectGuid(); DoMeleeAttackIfReady(); } @@ -128,7 +128,7 @@ void GuardAI::AttackStart(Unit *u) if(m_creature->Attack(u,true)) { - i_victimGuid = u->GetGUID(); + i_victimGuid = u->GetObjectGuid(); m_creature->AddThreat(u); m_creature->SetInCombatWith(u); u->SetInCombatWith(m_creature); diff --git a/src/game/GuardAI.h b/src/game/GuardAI.h index 1530d645df0..b961994a0fe 100644 --- a/src/game/GuardAI.h +++ b/src/game/GuardAI.h @@ -20,6 +20,7 @@ #define MANGOS_GUARDAI_H #include "CreatureAI.h" +#include "ObjectGuid.h" #include "Timer.h" class Creature; @@ -46,7 +47,7 @@ class MANGOS_DLL_DECL GuardAI : public CreatureAI static int Permissible(const Creature *); private: - uint64 i_victimGuid; + ObjectGuid i_victimGuid; GuardState i_state; TimeTracker i_tracker; }; diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index a8ce501ce58..e5464ed36d2 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 "11460" + #define REVISION_NR "11461" #endif // __REVISION_NR_H__ From 2ef80efb0fb5583b16636224a928d15657ebfa3d Mon Sep 17 00:00:00 2001 From: VladimirMangos Date: Tue, 10 May 2011 13:03:17 +0400 Subject: [PATCH 28/43] [11462] Missing ObjectGuids in spell code. --- src/game/Spell.cpp | 60 ++++++++++++++++++--------------------- src/game/Spell.h | 17 +++++------ src/game/SpellEffects.cpp | 20 +++++++------ src/game/SpellHandler.cpp | 8 +++--- src/game/Unit.cpp | 1 - src/game/Unit.h | 2 +- src/shared/revision_nr.h | 2 +- 7 files changed, 53 insertions(+), 57 deletions(-) diff --git a/src/game/Spell.cpp b/src/game/Spell.cpp index 5547d4b978f..207a85d5cbb 100644 --- a/src/game/Spell.cpp +++ b/src/game/Spell.cpp @@ -871,10 +871,9 @@ void Spell::AddUnitTarget(Unit* pVictim, SpellEffectIndex effIndex) m_UniqueTargetInfo.push_back(target); } -void Spell::AddUnitTarget(uint64 unitGUID, SpellEffectIndex effIndex) +void Spell::AddUnitTarget(ObjectGuid unitGuid, SpellEffectIndex effIndex) { - Unit* unit = m_caster->GetGUID() == unitGUID ? m_caster : ObjectAccessor::GetUnit(*m_caster, unitGUID); - if (unit) + if (Unit* unit = m_caster->GetObjectGuid() == unitGuid ? m_caster : ObjectAccessor::GetUnit(*m_caster, unitGuid)) AddUnitTarget(unit, effIndex); } @@ -923,10 +922,9 @@ void Spell::AddGOTarget(GameObject* pVictim, SpellEffectIndex effIndex) m_UniqueGOTargetInfo.push_back(target); } -void Spell::AddGOTarget(uint64 goGUID, SpellEffectIndex effIndex) +void Spell::AddGOTarget(ObjectGuid goGuid, SpellEffectIndex effIndex) { - GameObject* go = m_caster->GetMap()->GetGameObject(goGUID); - if (go) + if (GameObject* go = m_caster->GetMap()->GetGameObject(goGuid)) AddGOTarget(go, effIndex); } @@ -2226,9 +2224,9 @@ void Spell::SetTargetMap(SpellEffectIndex effIndex, uint32 targetMode, UnitList& break; } case TARGET_GAMEOBJECT_ITEM: - if(m_targets.getGOTargetGUID()) + if (!m_targets.getGOTargetGuid().IsEmpty()) AddGOTarget(m_targets.getGOTarget(), effIndex); - else if(m_targets.getItemTarget()) + else if (m_targets.getItemTarget()) AddItemTarget(m_targets.getItemTarget(), effIndex); break; case TARGET_MASTER: @@ -2649,15 +2647,11 @@ void Spell::SetTargetMap(SpellEffectIndex effIndex, uint32 targetMode, UnitList& case SPELL_EFFECT_RESURRECT_NEW: if (m_targets.getUnitTarget()) targetUnitMap.push_back(m_targets.getUnitTarget()); - if (m_targets.getCorpseTargetGUID()) + if (!m_targets.getCorpseTargetGuid().IsEmpty()) { - Corpse *corpse = m_caster->GetMap()->GetCorpse(m_targets.getCorpseTargetGUID()); - if(corpse) - { - Player* owner = ObjectAccessor::FindPlayer(corpse->GetOwnerGuid()); - if(owner) + if (Corpse *corpse = m_caster->GetMap()->GetCorpse(m_targets.getCorpseTargetGuid())) + if (Player* owner = ObjectAccessor::FindPlayer(corpse->GetOwnerGuid())) targetUnitMap.push_back(owner); - } } break; case SPELL_EFFECT_SUMMON: @@ -2711,9 +2705,9 @@ void Spell::SetTargetMap(SpellEffectIndex effIndex, uint32 targetMode, UnitList& case SPELL_EFFECT_SKIN_PLAYER_CORPSE: if (m_targets.getUnitTarget()) targetUnitMap.push_back(m_targets.getUnitTarget()); - else if (m_targets.getCorpseTargetGUID()) + else if (!m_targets.getCorpseTargetGuid().IsEmpty()) { - if (Corpse *corpse = m_caster->GetMap()->GetCorpse(m_targets.getCorpseTargetGUID())) + if (Corpse *corpse = m_caster->GetMap()->GetCorpse(m_targets.getCorpseTargetGuid())) if (Player* owner = ObjectAccessor::FindPlayer(corpse->GetOwnerGuid())) targetUnitMap.push_back(owner); } @@ -2918,7 +2912,7 @@ void Spell::cast(bool skipCheck) UpdatePointers(); // cancel at lost main target unit - if(!m_targets.getUnitTarget() && m_targets.getUnitTargetGUID() && m_targets.getUnitTargetGUID() != m_caster->GetGUID()) + if (!m_targets.getUnitTarget() && !m_targets.getUnitTargetGuid().IsEmpty() && m_targets.getUnitTargetGuid() != m_caster->GetObjectGuid()) { cancel(); m_caster->DecreaseCastCounter(); @@ -2926,11 +2920,11 @@ void Spell::cast(bool skipCheck) return; } - if(m_caster->GetTypeId() != TYPEID_PLAYER && m_targets.getUnitTarget() && m_targets.getUnitTarget() != m_caster) + if (m_caster->GetTypeId() != TYPEID_PLAYER && m_targets.getUnitTarget() && m_targets.getUnitTarget() != m_caster) m_caster->SetInFront(m_targets.getUnitTarget()); SpellCastResult castResult = CheckPower(); - if(castResult != SPELL_CAST_OK) + if (castResult != SPELL_CAST_OK) { SendCastResult(castResult); finish(false); @@ -2940,7 +2934,7 @@ void Spell::cast(bool skipCheck) } // triggered cast called from Spell::prepare where it was already checked - if(!skipCheck) + if (!skipCheck) { castResult = CheckCast(false); if(castResult != SPELL_CAST_OK) @@ -3311,7 +3305,7 @@ void Spell::update(uint32 difftime) // update pointers based at it's GUIDs UpdatePointers(); - if(m_targets.getUnitTargetGUID() && !m_targets.getUnitTarget()) + if (!m_targets.getUnitTargetGuid().IsEmpty() && !m_targets.getUnitTarget()) { cancel(); return; @@ -3916,11 +3910,11 @@ void Spell::SendLogExecute() case SPELL_EFFECT_SUMMON_OBJECT_SLOT2: case SPELL_EFFECT_SUMMON_OBJECT_SLOT3: case SPELL_EFFECT_SUMMON_OBJECT_SLOT4: - if(Unit *unit = m_targets.getUnitTarget()) + if (Unit *unit = m_targets.getUnitTarget()) data << unit->GetPackGUID(); - else if(m_targets.getItemTargetGUID()) - data.appendPackGUID(m_targets.getItemTargetGUID()); - else if(GameObject *go = m_targets.getGOTarget()) + else if (!m_targets.getItemTargetGuid().IsEmpty()) + data << m_targets.getItemTargetGuid().WriteAsPacked(); + else if (GameObject *go = m_targets.getGOTarget()) data << go->GetPackGUID(); else data << uint8(0); // guid @@ -5571,7 +5565,7 @@ SpellCastResult Spell::CheckCast(bool strict) if (!my_trade) return SPELL_FAILED_NOT_TRADING; - TradeSlots slot = TradeSlots(m_targets.getItemTargetGUID()); + TradeSlots slot = TradeSlots(m_targets.getItemTargetGuid().GetRawValue()); if (slot != TRADE_SLOT_NONTRADED) return SPELL_FAILED_ITEM_NOT_READY; @@ -6128,18 +6122,18 @@ SpellCastResult Spell::CheckItems() } // check target item (for triggered case not report error) - if(m_targets.getItemTargetGUID()) + if (!m_targets.getItemTargetGuid().IsEmpty()) { - if(m_caster->GetTypeId() != TYPEID_PLAYER) + if (m_caster->GetTypeId() != TYPEID_PLAYER) return m_IsTriggeredSpell && !(m_targets.m_targetMask & TARGET_FLAG_TRADE_ITEM) ? SPELL_FAILED_DONT_REPORT : SPELL_FAILED_BAD_TARGETS; - if(!m_targets.getItemTarget()) + if (!m_targets.getItemTarget()) return m_IsTriggeredSpell && !(m_targets.m_targetMask & TARGET_FLAG_TRADE_ITEM) ? SPELL_FAILED_DONT_REPORT : SPELL_FAILED_ITEM_GONE; isVellumTarget = m_targets.getItemTarget()->GetProto()->IsVellum(); - if(!m_targets.getItemTarget()->IsFitToSpellRequirements(m_spellInfo)) + if (!m_targets.getItemTarget()->IsFitToSpellRequirements(m_spellInfo)) return m_IsTriggeredSpell && !(m_targets.m_targetMask & TARGET_FLAG_TRADE_ITEM) ? SPELL_FAILED_DONT_REPORT : SPELL_FAILED_EQUIPPED_ITEM_CLASS; @@ -6696,10 +6690,10 @@ bool Spell::CheckTarget( Unit* target, SpellEffectIndex eff ) // player far away, maybe his corpse near? if(target != m_caster && !target->IsWithinLOSInMap(m_caster)) { - if(!m_targets.getCorpseTargetGUID()) + if (!m_targets.getCorpseTargetGuid().IsEmpty()) return false; - Corpse *corpse = m_caster->GetMap()->GetCorpse(m_targets.getCorpseTargetGUID()); + Corpse *corpse = m_caster->GetMap()->GetCorpse(m_targets.getCorpseTargetGuid()); if(!corpse) return false; diff --git a/src/game/Spell.h b/src/game/Spell.h index a0dc2a4d57b..83aa1001597 100644 --- a/src/game/Spell.h +++ b/src/game/Spell.h @@ -135,19 +135,20 @@ class SpellCastTargets return *this; } - uint64 getUnitTargetGUID() const { return m_unitTargetGUID.GetRawValue(); } + ObjectGuid getUnitTargetGuid() const { return m_unitTargetGUID; } Unit *getUnitTarget() const { return m_unitTarget; } void setUnitTarget(Unit *target); void setDestination(float x, float y, float z); void setSource(float x, float y, float z); - uint64 getGOTargetGUID() const { return m_GOTargetGUID.GetRawValue(); } + ObjectGuid getGOTargetGuid() const { return m_GOTargetGUID; } GameObject *getGOTarget() const { return m_GOTarget; } void setGOTarget(GameObject *target); - uint64 getCorpseTargetGUID() const { return m_CorpseTargetGUID.GetRawValue(); } + ObjectGuid getCorpseTargetGuid() const { return m_CorpseTargetGUID; } void setCorpseTarget(Corpse* corpse); - uint64 getItemTargetGUID() const { return m_itemTargetGUID.GetRawValue(); } + + ObjectGuid getItemTargetGuid() const { return m_itemTargetGUID; } Item* getItemTarget() const { return m_itemTarget; } uint32 getItemTargetEntry() const { return m_itemTargetEntry; } void setItemTarget(Item* item); @@ -156,7 +157,7 @@ class SpellCastTargets { if(m_itemTarget && (m_targetMask & TARGET_FLAG_TRADE_ITEM)) { - m_itemTargetGUID = m_itemTarget->GetGUID(); + m_itemTargetGUID = m_itemTarget->GetObjectGuid(); m_itemTargetEntry = m_itemTarget->GetEntry(); } } @@ -496,7 +497,7 @@ class Spell void TriggerGlobalCooldown(); void CancelGlobalCooldown(); - void SendLoot(uint64 guid, LootType loottype); + void SendLoot(ObjectGuid guid, LootType loottype); bool IgnoreItemRequirements() const; // some item use spells have unexpected reagent data void UpdateOriginalCasterPointer(); @@ -608,9 +609,9 @@ class Spell ItemTargetList m_UniqueItemInfo; void AddUnitTarget(Unit* target, SpellEffectIndex effIndex); - void AddUnitTarget(uint64 unitGUID, SpellEffectIndex effIndex); + void AddUnitTarget(ObjectGuid unitGuid, SpellEffectIndex effIndex); void AddGOTarget(GameObject* target, SpellEffectIndex effIndex); - void AddGOTarget(uint64 goGUID, SpellEffectIndex effIndex); + void AddGOTarget(ObjectGuid goGuid, SpellEffectIndex effIndex); void AddItemTarget(Item* target, SpellEffectIndex effIndex); void DoAllEffectOnTarget(TargetInfo *target); void HandleDelayedSpellLaunch(TargetInfo *target); diff --git a/src/game/SpellEffects.cpp b/src/game/SpellEffects.cpp index 3a9a8138f48..6fc83dd0704 100644 --- a/src/game/SpellEffects.cpp +++ b/src/game/SpellEffects.cpp @@ -4302,7 +4302,7 @@ void Spell::EffectEnergisePct(SpellEffectIndex eff_idx) m_caster->EnergizeBySpell(unitTarget, m_spellInfo->Id, gain, power); } -void Spell::SendLoot(uint64 guid, LootType loottype) +void Spell::SendLoot(ObjectGuid guid, LootType loottype) { if (gameObjTarget) { @@ -4345,7 +4345,7 @@ void Spell::EffectOpenLock(SpellEffectIndex eff_idx) Player* player = (Player*)m_caster; uint32 lockId = 0; - uint64 guid = 0; + ObjectGuid guid; // Get lockId if (gameObjTarget) @@ -4377,12 +4377,12 @@ void Spell::EffectOpenLock(SpellEffectIndex eff_idx) } } lockId = goInfo->GetLockId(); - guid = gameObjTarget->GetGUID(); + guid = gameObjTarget->GetObjectGuid(); } else if (itemTarget) { lockId = itemTarget->GetProto()->LockID; - guid = itemTarget->GetGUID(); + guid = itemTarget->GetObjectGuid(); } else { @@ -8059,7 +8059,7 @@ void Spell::EffectSummonObject(SpellEffectIndex eff_idx) uint32 go_id = m_spellInfo->EffectMiscValue[eff_idx]; uint8 slot = 0; - switch(m_spellInfo->Effect[eff_idx]) + switch (m_spellInfo->Effect[eff_idx]) { case SPELL_EFFECT_SUMMON_OBJECT_SLOT1: slot = 0; break; case SPELL_EFFECT_SUMMON_OBJECT_SLOT2: slot = 1; break; @@ -8068,11 +8068,13 @@ void Spell::EffectSummonObject(SpellEffectIndex eff_idx) default: return; } - if(uint64 guid = m_caster->m_ObjectSlot[slot]) + ObjectGuid guid = m_caster->m_ObjectSlotGuid[slot]; + + if (!guid.IsEmpty()) { - if(GameObject* obj = m_caster ? m_caster->GetMap()->GetGameObject(guid) : NULL) + if (GameObject* obj = m_caster ? m_caster->GetMap()->GetGameObject(guid) : NULL) obj->SetLootState(GO_JUST_DEACTIVATED); - m_caster->m_ObjectSlot[slot] = 0; + m_caster->m_ObjectSlotGuid[slot].Clear(); } GameObject* pGameObj = new GameObject; @@ -8105,7 +8107,7 @@ void Spell::EffectSummonObject(SpellEffectIndex eff_idx) map->Add(pGameObj); - m_caster->m_ObjectSlot[slot] = pGameObj->GetGUID(); + m_caster->m_ObjectSlotGuid[slot] = pGameObj->GetObjectGuid(); pGameObj->SummonLinkedTrapIfAny(); diff --git a/src/game/SpellHandler.cpp b/src/game/SpellHandler.cpp index 772bacbad65..3b9a919f510 100644 --- a/src/game/SpellHandler.cpp +++ b/src/game/SpellHandler.cpp @@ -34,11 +34,11 @@ void WorldSession::HandleUseItemOpcode(WorldPacket& recvPacket) uint8 bagIndex, slot; uint8 unk_flags; // flags (if 0x02 - some additional data are received) uint8 cast_count; // next cast if exists (single or not) - uint64 item_guid; + ObjectGuid itemGuid; uint32 glyphIndex; // something to do with glyphs? uint32 spellid; // casted spell id - recvPacket >> bagIndex >> slot >> cast_count >> spellid >> item_guid >> glyphIndex >> unk_flags; + recvPacket >> bagIndex >> slot >> cast_count >> spellid >> itemGuid >> glyphIndex >> unk_flags; // TODO: add targets.read() check Player* pUser = _player; @@ -66,7 +66,7 @@ void WorldSession::HandleUseItemOpcode(WorldPacket& recvPacket) return; } - if (pItem->GetGUID() != item_guid) + if (pItem->GetObjectGuid() != itemGuid) { recvPacket.rpos(recvPacket.wpos()); // prevent spam at not read packet tail pUser->SendEquipError(EQUIP_ERR_ITEM_NOT_FOUND, NULL, NULL ); @@ -250,7 +250,7 @@ void WorldSession::HandleOpenItemOpcode(WorldPacket& recvPacket) uint32 entry = fields[0].GetUInt32(); uint32 flags = fields[1].GetUInt32(); - pItem->SetUInt64Value(ITEM_FIELD_GIFTCREATOR, 0); + pItem->SetGuidValue(ITEM_FIELD_GIFTCREATOR, ObjectGuid()); pItem->SetEntry(entry); pItem->SetUInt32Value(ITEM_FIELD_FLAGS, flags); pItem->SetState(ITEM_CHANGED, pUser); diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp index 1ad6a17dd35..f87c972fbb2 100644 --- a/src/game/Unit.cpp +++ b/src/game/Unit.cpp @@ -210,7 +210,6 @@ Unit::Unit() : m_addDmgOnce = 0; - m_ObjectSlot[0] = m_ObjectSlot[1] = m_ObjectSlot[2] = m_ObjectSlot[3] = 0; //m_Aura = NULL; //m_AurasCheck = 2000; //m_removeAuraTimer = 4; diff --git a/src/game/Unit.h b/src/game/Unit.h index d9f65148adc..93e784a6485 100644 --- a/src/game/Unit.h +++ b/src/game/Unit.h @@ -1646,7 +1646,7 @@ class MANGOS_DLL_SPEC Unit : public WorldObject void DecreaseCastCounter() { if (m_castCounter) --m_castCounter; } uint32 m_addDmgOnce; - uint64 m_ObjectSlot[4]; + ObjectGuid m_ObjectSlotGuid[4]; uint32 m_detectInvisibilityMask; uint32 m_invisibilityMask; diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index e5464ed36d2..fa4f1fa474e 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 "11461" + #define REVISION_NR "11462" #endif // __REVISION_NR_H__ From 4216bd62c371cd23fa71a6533287f5ac8c1a85ef Mon Sep 17 00:00:00 2001 From: Den Date: Tue, 10 May 2011 13:10:01 +0400 Subject: [PATCH 29/43] [11463] Cleanup codestyle in PetHandler.cpp Signed-off-by: VladimirMangos --- src/game/PetHandler.cpp | 218 ++++++++++++++++++++------------------- src/shared/revision_nr.h | 2 +- 2 files changed, 111 insertions(+), 109 deletions(-) diff --git a/src/game/PetHandler.cpp b/src/game/PetHandler.cpp index c95b142d22b..8d8e6fe38f7 100644 --- a/src/game/PetHandler.cpp +++ b/src/game/PetHandler.cpp @@ -28,7 +28,7 @@ #include "Util.h" #include "Pet.h" -void WorldSession::HandlePetAction( WorldPacket & recv_data ) +void WorldSession::HandlePetAction(WorldPacket& recv_data) { ObjectGuid petGuid; uint32 data; @@ -38,7 +38,7 @@ void WorldSession::HandlePetAction( WorldPacket & recv_data ) recv_data >> targetGuid; uint32 spellid = UNIT_ACTION_BUTTON_ACTION(data); - uint8 flag = UNIT_ACTION_BUTTON_TYPE(data); //delete = 0x07 CastSpell = C1 + uint8 flag = UNIT_ACTION_BUTTON_TYPE(data); // delete = 0x07 CastSpell = C1 DETAIL_LOG("HandlePetAction: %s flag is %u, spellid is %u, target %s.", petGuid.GetString().c_str(), uint32(flag), spellid, targetGuid.GetString().c_str()); @@ -68,48 +68,48 @@ void WorldSession::HandlePetAction( WorldPacket & recv_data ) else if (((Creature*)pet)->IsPet()) { // pet can have action bar disabled - if(((Pet*)pet)->GetModeFlags() & PET_MODE_DISABLE_ACTIONS) + if (((Pet*)pet)->GetModeFlags() & PET_MODE_DISABLE_ACTIONS) return; } - CharmInfo *charmInfo = pet->GetCharmInfo(); - if(!charmInfo) + CharmInfo* charmInfo = pet->GetCharmInfo(); + if (!charmInfo) { sLog.outError("WorldSession::HandlePetAction: object (GUID: %u TypeId: %u) is considered pet-like but doesn't have a charminfo!", pet->GetGUIDLow(), pet->GetTypeId()); return; } - switch(flag) + switch (flag) { - case ACT_COMMAND: //0x07 - switch(spellid) + case ACT_COMMAND: // 0x07 + switch (spellid) { - case COMMAND_STAY: //flat=1792 //STAY + case COMMAND_STAY: // flat=1792 //STAY pet->StopMoving(); pet->GetMotionMaster()->Clear(false); pet->GetMotionMaster()->MoveIdle(); - charmInfo->SetCommandState( COMMAND_STAY ); + charmInfo->SetCommandState(COMMAND_STAY); break; - case COMMAND_FOLLOW: //spellid=1792 //FOLLOW + case COMMAND_FOLLOW: // spellid=1792 //FOLLOW pet->AttackStop(); - pet->GetMotionMaster()->MoveFollow(_player,PET_FOLLOW_DIST,PET_FOLLOW_ANGLE); - charmInfo->SetCommandState( COMMAND_FOLLOW ); + pet->GetMotionMaster()->MoveFollow(_player, PET_FOLLOW_DIST,PET_FOLLOW_ANGLE); + charmInfo->SetCommandState(COMMAND_FOLLOW); break; - case COMMAND_ATTACK: //spellid=1792 //ATTACK + case COMMAND_ATTACK: // spellid=1792 // ATTACK { - Unit *TargetUnit = _player->GetMap()->GetUnit(targetGuid); - if(!TargetUnit) + Unit* TargetUnit = _player->GetMap()->GetUnit(targetGuid); + if (!TargetUnit) return; // not let attack friendly units. - if(GetPlayer()->IsFriendlyTo(TargetUnit)) + if (GetPlayer()->IsFriendlyTo(TargetUnit)) return; // Not let attack through obstructions - if(!pet->IsWithinLOSInMap(TargetUnit)) + if (!pet->IsWithinLOSInMap(TargetUnit)) return; // This is true if pet has no target or has target but targets differs. - if(pet->getVictim() != TargetUnit) + if (pet->getVictim() != TargetUnit) { if (pet->getVictim()) pet->AttackStop(); @@ -127,7 +127,7 @@ void WorldSession::HandlePetAction( WorldPacket & recv_data ) ((Creature*)pet)->AI()->AttackStart(TargetUnit); // 10% chance to play special pet attack talk, else growl - if(((Creature*)pet)->IsPet() && ((Pet*)pet)->getPetType() == SUMMON_PET && pet != TargetUnit && roll_chance_i(10)) + if (((Creature*)pet)->IsPet() && ((Pet*)pet)->getPetType() == SUMMON_PET && pet != TargetUnit && roll_chance_i(10)) pet->SendPetTalk((uint32)PET_TALK_ATTACK); else { @@ -139,13 +139,13 @@ void WorldSession::HandlePetAction( WorldPacket & recv_data ) break; } case COMMAND_ABANDON: // abandon (hunter pet) or dismiss (summoned pet) - if(((Creature*)pet)->IsPet()) + if (((Creature*)pet)->IsPet()) { Pet* p = (Pet*)pet; - if(p->getPetType() == HUNTER_PET) + if (p->getPetType() == HUNTER_PET) p->Unsummon(PET_SAVE_AS_DELETED, _player); else - //dismissing a summoned pet is like killing them (this prevents returning a soulshard...) + // dismissing a summoned pet is like killing them (this prevents returning a soulshard...) p->SetDeathState(CORPSE); } else // charmed @@ -156,12 +156,12 @@ void WorldSession::HandlePetAction( WorldPacket & recv_data ) } break; case ACT_REACTION: // 0x6 - switch(spellid) + switch (spellid) { - case REACT_PASSIVE: //passive - case REACT_DEFENSIVE: //recovery - case REACT_AGGRESSIVE: //activete - charmInfo->SetReactState( ReactStates(spellid) ); + case REACT_PASSIVE: // passive + case REACT_DEFENSIVE: // recovery + case REACT_AGGRESSIVE: // activete + charmInfo->SetReactState(ReactStates(spellid)); break; } break; @@ -174,7 +174,7 @@ void WorldSession::HandlePetAction( WorldPacket & recv_data ) unit_target = _player->GetMap()->GetUnit(targetGuid); // do not cast unknown spells - SpellEntry const *spellInfo = sSpellStore.LookupEntry(spellid ); + SpellEntry const* spellInfo = sSpellStore.LookupEntry(spellid); if (!spellInfo) { sLog.outError("WORLD: unknown PET spell id %i", spellid); @@ -184,59 +184,59 @@ void WorldSession::HandlePetAction( WorldPacket & recv_data ) if (pet->GetCharmInfo() && pet->GetCharmInfo()->GetGlobalCooldownMgr().HasGlobalCooldown(spellInfo)) return; - for(int i = 0; i < MAX_EFFECT_INDEX;++i) + for (int i = 0; i < MAX_EFFECT_INDEX; ++i) { - if(spellInfo->EffectImplicitTargetA[i] == TARGET_ALL_ENEMY_IN_AREA || spellInfo->EffectImplicitTargetA[i] == TARGET_ALL_ENEMY_IN_AREA_INSTANT || spellInfo->EffectImplicitTargetA[i] == TARGET_ALL_ENEMY_IN_AREA_CHANNELED) + if (spellInfo->EffectImplicitTargetA[i] == TARGET_ALL_ENEMY_IN_AREA || spellInfo->EffectImplicitTargetA[i] == TARGET_ALL_ENEMY_IN_AREA_INSTANT || spellInfo->EffectImplicitTargetA[i] == TARGET_ALL_ENEMY_IN_AREA_CHANNELED) return; } // do not cast not learned spells - if(!pet->HasSpell(spellid) || IsPassiveSpell(spellInfo)) + if (!pet->HasSpell(spellid) || IsPassiveSpell(spellInfo)) return; pet->clearUnitState(UNIT_STAT_MOVING); - Spell *spell = new Spell(pet, spellInfo, false); + Spell* spell = new Spell(pet, spellInfo, false); SpellCastResult result = spell->CheckPetCast(unit_target); - //auto turn to target unless possessed - if(result == SPELL_FAILED_UNIT_NOT_INFRONT && !pet->HasAuraType(SPELL_AURA_MOD_POSSESS)) + // auto turn to target unless possessed + if (result == SPELL_FAILED_UNIT_NOT_INFRONT && !pet->HasAuraType(SPELL_AURA_MOD_POSSESS)) { - if(unit_target) + if (unit_target) { pet->SetInFront(unit_target); if (unit_target->GetTypeId() == TYPEID_PLAYER) pet->SendCreateUpdateToPlayer( (Player*)unit_target ); } - else if(Unit *unit_target2 = spell->m_targets.getUnitTarget()) + else if (Unit* unit_target2 = spell->m_targets.getUnitTarget()) { pet->SetInFront(unit_target2); if (unit_target2->GetTypeId() == TYPEID_PLAYER) - pet->SendCreateUpdateToPlayer( (Player*)unit_target2 ); + pet->SendCreateUpdateToPlayer((Player*)unit_target2); } if (Unit* powner = pet->GetCharmerOrOwner()) - if(powner->GetTypeId() == TYPEID_PLAYER) + if (powner->GetTypeId() == TYPEID_PLAYER) pet->SendCreateUpdateToPlayer((Player*)powner); result = SPELL_CAST_OK; } - if(result == SPELL_CAST_OK) + if (result == SPELL_CAST_OK) { ((Creature*)pet)->AddCreatureSpellCooldown(spellid); unit_target = spell->m_targets.getUnitTarget(); - //10% chance to play special pet attack talk, else growl - //actually this only seems to happen on special spells, fire shield for imp, torment for voidwalker, but it's stupid to check every spell - if(((Creature*)pet)->IsPet() && (((Pet*)pet)->getPetType() == SUMMON_PET) && (pet != unit_target) && (urand(0, 100) < 10)) + // 10% chance to play special pet attack talk, else growl + // actually this only seems to happen on special spells, fire shield for imp, torment for voidwalker, but it's stupid to check every spell + if (((Creature*)pet)->IsPet() && (((Pet*)pet)->getPetType() == SUMMON_PET) && (pet != unit_target) && (urand(0, 100) < 10)) pet->SendPetTalk((uint32)PET_TALK_SPECIAL_SPELL); else { pet->SendPetAIReaction(); } - if( unit_target && !GetPlayer()->IsFriendlyTo(unit_target) && !pet->HasAuraType(SPELL_AURA_MOD_POSSESS)) + if (unit_target && !GetPlayer()->IsFriendlyTo(unit_target) && !pet->HasAuraType(SPELL_AURA_MOD_POSSESS)) { // This is true if pet has no target or has target but targets differs. if (pet->getVictim() != unit_target) @@ -253,8 +253,8 @@ void WorldSession::HandlePetAction( WorldPacket & recv_data ) } else { - if(pet->HasAuraType(SPELL_AURA_MOD_POSSESS)) - Spell::SendCastResult(GetPlayer(),spellInfo,0,result); + if (pet->HasAuraType(SPELL_AURA_MOD_POSSESS)) + Spell::SendCastResult(GetPlayer(), spellInfo, 0, result); else pet->SendPetCastFail(spellid, result); @@ -297,9 +297,9 @@ void WorldSession::HandlePetStopAttack(WorldPacket& recv_data) pet->AttackStop(); } -void WorldSession::HandlePetNameQueryOpcode( WorldPacket & recv_data ) +void WorldSession::HandlePetNameQueryOpcode(WorldPacket& recv_data) { - DETAIL_LOG( "HandlePetNameQuery. CMSG_PET_NAME_QUERY" ); + DETAIL_LOG("HandlePetNameQuery. CMSG_PET_NAME_QUERY"); uint32 petnumber; uint64 petguid; @@ -307,13 +307,13 @@ void WorldSession::HandlePetNameQueryOpcode( WorldPacket & recv_data ) recv_data >> petnumber; recv_data >> petguid; - SendPetNameQuery(petguid,petnumber); + SendPetNameQuery(petguid, petnumber); } -void WorldSession::SendPetNameQuery( uint64 petguid, uint32 petnumber) +void WorldSession::SendPetNameQuery(uint64 petguid, uint32 petnumber) { Creature* pet = _player->GetMap()->GetAnyTypeCreature(petguid); - if(!pet || !pet->GetCharmInfo() || pet->GetCharmInfo()->GetPetNumber() != petnumber) + if (!pet || !pet->GetCharmInfo() || pet->GetCharmInfo()->GetPetNumber() != petnumber) { WorldPacket data(SMSG_PET_NAME_QUERY_RESPONSE, (4+1+4+1)); data << uint32(petnumber); @@ -331,10 +331,10 @@ void WorldSession::SendPetNameQuery( uint64 petguid, uint32 petnumber) data << name.c_str(); data << uint32(pet->GetUInt32Value(UNIT_FIELD_PET_NAME_TIMESTAMP)); - if( pet->IsPet() && ((Pet*)pet)->GetDeclinedNames() ) + if (pet->IsPet() && ((Pet*)pet)->GetDeclinedNames()) { data << uint8(1); - for(int i = 0; i < MAX_DECLINED_NAME_CASES; ++i) + for (int i = 0; i < MAX_DECLINED_NAME_CASES; ++i) data << ((Pet*)pet)->GetDeclinedNames()->name[i]; } else @@ -343,9 +343,9 @@ void WorldSession::SendPetNameQuery( uint64 petguid, uint32 petnumber) _player->GetSession()->SendPacket(&data); } -void WorldSession::HandlePetSetAction( WorldPacket & recv_data ) +void WorldSession::HandlePetSetAction(WorldPacket& recv_data) { - DETAIL_LOG( "HandlePetSetAction. CMSG_PET_SET_ACTION" ); + DETAIL_LOG("HandlePetSetAction. CMSG_PET_SET_ACTION"); uint64 petguid; uint8 count; @@ -354,18 +354,18 @@ void WorldSession::HandlePetSetAction( WorldPacket & recv_data ) Creature* pet = _player->GetMap()->GetAnyTypeCreature(petguid); - if(!pet || (pet != _player->GetPet() && pet != _player->GetCharm())) + if (!pet || (pet != _player->GetPet() && pet != _player->GetCharm())) { - sLog.outError( "HandlePetSetAction: Unknown pet or pet owner." ); + sLog.outError("HandlePetSetAction: Unknown pet or pet owner."); return; } // pet can have action bar disabled - if(pet->IsPet() && ((Pet*)pet)->GetModeFlags() & PET_MODE_DISABLE_ACTIONS) + if (pet->IsPet() && ((Pet*)pet)->GetModeFlags() & PET_MODE_DISABLE_ACTIONS) return; - CharmInfo *charmInfo = pet->GetCharmInfo(); - if(!charmInfo) + CharmInfo* charmInfo = pet->GetCharmInfo(); + if (!charmInfo) { sLog.outError("WorldSession::HandlePetSetAction: object (GUID: %u TypeId: %u) is considered pet-like but doesn't have a charminfo!", pet->GetGUIDLow(), pet->GetTypeId()); return; @@ -377,15 +377,15 @@ void WorldSession::HandlePetSetAction( WorldPacket & recv_data ) uint32 data[2]; bool move_command = false; - for(uint8 i = 0; i < count; ++i) + for (uint8 i = 0; i < count; ++i) { recv_data >> position[i]; recv_data >> data[i]; uint8 act_state = UNIT_ACTION_BUTTON_TYPE(data[i]); - //ignore invalid position - if(position[i] >= MAX_UNIT_ACTION_BAR_INDEX) + // ignore invalid position + if (position[i] >= MAX_UNIT_ACTION_BAR_INDEX) return; // in the normal case, command and reaction buttons can only be moved, not removed @@ -404,7 +404,7 @@ void WorldSession::HandlePetSetAction( WorldPacket & recv_data ) if (move_command) { uint8 act_state_0 = UNIT_ACTION_BUTTON_TYPE(data[0]); - if(act_state_0 == ACT_COMMAND || act_state_0 == ACT_REACTION) + if (act_state_0 == ACT_COMMAND || act_state_0 == ACT_REACTION) { uint32 spell_id_0 = UNIT_ACTION_BUTTON_ACTION(data[0]); UnitActionBarEntry const* actionEntry_1 = charmInfo->GetActionBarEntry(position[1]); @@ -414,7 +414,7 @@ void WorldSession::HandlePetSetAction( WorldPacket & recv_data ) } uint8 act_state_1 = UNIT_ACTION_BUTTON_TYPE(data[1]); - if(act_state_1 == ACT_COMMAND || act_state_1 == ACT_REACTION) + if (act_state_1 == ACT_COMMAND || act_state_1 == ACT_REACTION) { uint32 spell_id_1 = UNIT_ACTION_BUTTON_ACTION(data[1]); UnitActionBarEntry const* actionEntry_0 = charmInfo->GetActionBarEntry(position[0]); @@ -424,41 +424,41 @@ void WorldSession::HandlePetSetAction( WorldPacket & recv_data ) } } - for(uint8 i = 0; i < count; ++i) + for (uint8 i = 0; i < count; ++i) { uint32 spell_id = UNIT_ACTION_BUTTON_ACTION(data[i]); uint8 act_state = UNIT_ACTION_BUTTON_TYPE(data[i]); DETAIL_LOG( "Player %s has changed pet spell action. Position: %u, Spell: %u, State: 0x%X", _player->GetName(), position[i], spell_id, uint32(act_state)); - //if it's act for spell (en/disable/cast) and there is a spell given (0 = remove spell) which pet doesn't know, don't add - if(!((act_state == ACT_ENABLED || act_state == ACT_DISABLED || act_state == ACT_PASSIVE) && spell_id && !pet->HasSpell(spell_id))) + // if it's act for spell (en/disable/cast) and there is a spell given (0 = remove spell) which pet doesn't know, don't add + if (!((act_state == ACT_ENABLED || act_state == ACT_DISABLED || act_state == ACT_PASSIVE) && spell_id && !pet->HasSpell(spell_id))) { - //sign for autocast - if(act_state == ACT_ENABLED && spell_id) + // sign for autocast + if (act_state == ACT_ENABLED && spell_id) { - if(pet->isCharmed()) + if (pet->isCharmed()) charmInfo->ToggleCreatureAutocast(spell_id, true); else ((Pet*)pet)->ToggleAutocast(spell_id, true); } - //sign for no/turn off autocast - else if(act_state == ACT_DISABLED && spell_id) + // sign for no/turn off autocast + else if (act_state == ACT_DISABLED && spell_id) { - if(pet->isCharmed()) + if (pet->isCharmed()) charmInfo->ToggleCreatureAutocast(spell_id, false); else ((Pet*)pet)->ToggleAutocast(spell_id, false); } - charmInfo->SetActionBar(position[i],spell_id,ActiveStates(act_state)); + charmInfo->SetActionBar(position[i], spell_id, ActiveStates(act_state)); } } } -void WorldSession::HandlePetRename( WorldPacket & recv_data ) +void WorldSession::HandlePetRename(WorldPacket& recv_data) { - DETAIL_LOG( "HandlePetRename. CMSG_PET_RENAME" ); + DETAIL_LOG("HandlePetRename. CMSG_PET_RENAME"); uint64 petguid; uint8 isdeclined; @@ -472,19 +472,19 @@ void WorldSession::HandlePetRename( WorldPacket & recv_data ) Pet* pet = _player->GetMap()->GetPet(petguid); // check it! - if( !pet || pet->getPetType() != HUNTER_PET || + if (!pet || pet->getPetType() != HUNTER_PET || !pet->HasByteFlag(UNIT_FIELD_BYTES_2, 2, UNIT_CAN_BE_RENAMED) || - pet->GetOwnerGuid() != _player->GetObjectGuid() || !pet->GetCharmInfo() ) + pet->GetOwnerGuid() != _player->GetObjectGuid() || !pet->GetCharmInfo()) return; PetNameInvalidReason res = ObjectMgr::CheckPetName(name); - if(res != PET_NAME_SUCCESS) + if (res != PET_NAME_SUCCESS) { SendPetNameInvalid(res, name, NULL); return; } - if(sObjectMgr.IsReservedName(name)) + if (sObjectMgr.IsReservedName(name)) { SendPetNameInvalid(PET_NAME_RESERVED, name, NULL); return; @@ -492,21 +492,21 @@ void WorldSession::HandlePetRename( WorldPacket & recv_data ) pet->SetName(name); - if(_player->GetGroup()) + if (_player->GetGroup()) _player->SetGroupUpdateFlag(GROUP_UPDATE_FLAG_PET_NAME); pet->RemoveByteFlag(UNIT_FIELD_BYTES_2, 2, UNIT_CAN_BE_RENAMED); - if(isdeclined) + if (isdeclined) { - for(int i = 0; i < MAX_DECLINED_NAME_CASES; ++i) + for (int i = 0; i < MAX_DECLINED_NAME_CASES; ++i) { recv_data >> declinedname.name[i]; } std::wstring wname; Utf8toWStr(name, wname); - if(!ObjectMgr::CheckDeclinedNames(GetMainPartOfName(wname,0),declinedname)) + if (!ObjectMgr::CheckDeclinedNames(GetMainPartOfName(wname, 0), declinedname)) { SendPetNameInvalid(PET_NAME_DECLENSION_DOESNT_MATCH_BASE_NAME, name, &declinedname); return; @@ -514,9 +514,9 @@ void WorldSession::HandlePetRename( WorldPacket & recv_data ) } CharacterDatabase.BeginTransaction(); - if(isdeclined) + if (isdeclined) { - for(int i = 0; i < MAX_DECLINED_NAME_CASES; ++i) + for (int i = 0; i < MAX_DECLINED_NAME_CASES; ++i) CharacterDatabase.escape_string(declinedname.name[i]); CharacterDatabase.PExecute("DELETE FROM character_pet_declinedname WHERE owner = '%u' AND id = '%u'", _player->GetGUIDLow(), pet->GetCharmInfo()->GetPetNumber()); CharacterDatabase.PExecute("INSERT INTO character_pet_declinedname (id, owner, genitive, dative, accusative, instrumental, prepositional) VALUES ('%u','%u','%s','%s','%s','%s','%s')", @@ -530,10 +530,10 @@ void WorldSession::HandlePetRename( WorldPacket & recv_data ) pet->SetUInt32Value(UNIT_FIELD_PET_NAME_TIMESTAMP, uint32(time(NULL))); } -void WorldSession::HandlePetAbandon( WorldPacket & recv_data ) +void WorldSession::HandlePetAbandon(WorldPacket& recv_data) { ObjectGuid guid; - recv_data >> guid; //pet guid + recv_data >> guid; // pet guid DETAIL_LOG("HandlePetAbandon. CMSG_PET_ABANDON pet guid is %s", guid.GetString().c_str()); @@ -548,7 +548,7 @@ void WorldSession::HandlePetAbandon( WorldPacket & recv_data ) if (pet->GetObjectGuid() == _player->GetPetGuid()) { uint32 feelty = pet->GetPower(POWER_HAPPINESS); - pet->SetPower(POWER_HAPPINESS ,(feelty-50000) > 0 ?(feelty-50000) : 0); + pet->SetPower(POWER_HAPPINESS, (feelty - 50000) > 0 ? (feelty - 50000) : 0); } ((Pet*)pet)->Unsummon(PET_SAVE_AS_DELETED, _player); @@ -563,6 +563,7 @@ void WorldSession::HandlePetAbandon( WorldPacket & recv_data ) void WorldSession::HandlePetUnlearnOpcode(WorldPacket& recvPacket) { DETAIL_LOG("CMSG_PET_UNLEARN"); + ObjectGuid guid; recvPacket >> guid; // Pet guid @@ -577,7 +578,7 @@ void WorldSession::HandlePetUnlearnOpcode(WorldPacket& recvPacket) if (pet->getPetType() != HUNTER_PET || pet->m_usedTalentCount == 0) return; - CharmInfo *charmInfo = pet->GetCharmInfo(); + CharmInfo* charmInfo = pet->GetCharmInfo(); if (!charmInfo) { sLog.outError("WorldSession::HandlePetUnlearnOpcode: %s is considered pet-like but doesn't have a charminfo!", pet->GetGuidStr().c_str()); @@ -587,12 +588,13 @@ void WorldSession::HandlePetUnlearnOpcode(WorldPacket& recvPacket) _player->SendTalentsInfoData(true); } -void WorldSession::HandlePetSpellAutocastOpcode( WorldPacket& recvPacket ) +void WorldSession::HandlePetSpellAutocastOpcode(WorldPacket& recvPacket) { DETAIL_LOG("CMSG_PET_SPELL_AUTOCAST"); + ObjectGuid guid; uint32 spellid; - uint8 state; //1 for on, 0 for off + uint8 state; // 1 for on, 0 for off recvPacket >> guid >> spellid >> state; Creature* pet = _player->GetMap()->GetAnyTypeCreature(guid); @@ -606,7 +608,7 @@ void WorldSession::HandlePetSpellAutocastOpcode( WorldPacket& recvPacket ) if (!pet->HasSpell(spellid) || IsPassiveSpell(spellid)) return; - CharmInfo *charmInfo = pet->GetCharmInfo(); + CharmInfo* charmInfo = pet->GetCharmInfo(); if (!charmInfo) { sLog.outError("WorldSession::HandlePetSpellAutocastOpcod: %s is considered pet-like but doesn't have a charminfo!", guid.GetString().c_str()); @@ -614,15 +616,15 @@ void WorldSession::HandlePetSpellAutocastOpcode( WorldPacket& recvPacket ) } if (pet->isCharmed()) - //state can be used as boolean + // state can be used as boolean pet->GetCharmInfo()->ToggleCreatureAutocast(spellid, state); else ((Pet*)pet)->ToggleAutocast(spellid, state); - charmInfo->SetSpellAutocast(spellid,state); + charmInfo->SetSpellAutocast(spellid, state); } -void WorldSession::HandlePetCastSpellOpcode( WorldPacket& recvPacket ) +void WorldSession::HandlePetCastSpellOpcode(WorldPacket& recvPacket) { DETAIL_LOG("WORLD: CMSG_PET_CAST_SPELL"); @@ -643,7 +645,7 @@ void WorldSession::HandlePetCastSpellOpcode( WorldPacket& recvPacket ) return; } - SpellEntry const *spellInfo = sSpellStore.LookupEntry(spellid); + SpellEntry const* spellInfo = sSpellStore.LookupEntry(spellid); if (!spellInfo) { sLog.outError("WORLD: unknown PET spell id %i", spellid); @@ -664,7 +666,7 @@ void WorldSession::HandlePetCastSpellOpcode( WorldPacket& recvPacket ) pet->clearUnitState(UNIT_STAT_MOVING); - Spell *spell = new Spell(pet, spellInfo, false); + Spell* spell = new Spell(pet, spellInfo, false); spell->m_cast_count = cast_count; // probably pending spell cast spell->m_targets = targets; @@ -674,9 +676,9 @@ void WorldSession::HandlePetCastSpellOpcode( WorldPacket& recvPacket ) pet->AddCreatureSpellCooldown(spellid); if (pet->IsPet()) { - //10% chance to play special pet attack talk, else growl - //actually this only seems to happen on special spells, fire shield for imp, torment for voidwalker, but it's stupid to check every spell - if(((Pet*)pet)->getPetType() == SUMMON_PET && (urand(0, 100) < 10)) + // 10% chance to play special pet attack talk, else growl + // actually this only seems to happen on special spells, fire shield for imp, torment for voidwalker, but it's stupid to check every spell + if (((Pet*)pet)->getPetType() == SUMMON_PET && (urand(0, 100) < 10)) pet->SendPetTalk((uint32)PET_TALK_SPECIAL_SPELL); else pet->SendPetAIReaction(); @@ -695,15 +697,15 @@ void WorldSession::HandlePetCastSpellOpcode( WorldPacket& recvPacket ) } } -void WorldSession::SendPetNameInvalid(uint32 error, const std::string& name, DeclinedName *declinedName) +void WorldSession::SendPetNameInvalid(uint32 error, const std::string& name, DeclinedName* declinedName) { WorldPacket data(SMSG_PET_NAME_INVALID, 4 + name.size() + 1 + 1); data << uint32(error); data << name; - if(declinedName) + if (declinedName) { data << uint8(1); - for(uint32 i = 0; i < MAX_DECLINED_NAME_CASES; ++i) + for (uint32 i = 0; i < MAX_DECLINED_NAME_CASES; ++i) data << declinedName->name[i]; } else @@ -711,7 +713,7 @@ void WorldSession::SendPetNameInvalid(uint32 error, const std::string& name, Dec SendPacket(&data); } -void WorldSession::HandlePetLearnTalent( WorldPacket & recv_data ) +void WorldSession::HandlePetLearnTalent(WorldPacket& recv_data) { DEBUG_LOG("WORLD: CMSG_PET_LEARN_TALENT"); @@ -723,7 +725,7 @@ void WorldSession::HandlePetLearnTalent( WorldPacket & recv_data ) _player->SendTalentsInfoData(true); } -void WorldSession::HandleLearnPreviewTalentsPet( WorldPacket & recv_data ) +void WorldSession::HandleLearnPreviewTalentsPet(WorldPacket& recv_data) { DEBUG_LOG("CMSG_LEARN_PREVIEW_TALENTS_PET"); @@ -735,7 +737,7 @@ void WorldSession::HandleLearnPreviewTalentsPet( WorldPacket & recv_data ) uint32 talentId, talentRank; - for(uint32 i = 0; i < talentsCount; ++i) + for (uint32 i = 0; i < talentsCount; ++i) { recv_data >> talentId >> talentRank; diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index fa4f1fa474e..d1a53593ec8 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 "11462" + #define REVISION_NR "11463" #endif // __REVISION_NR_H__ From 4ca1c1d533ac8a1bc9f8726992504e353655512d Mon Sep 17 00:00:00 2001 From: TOM_RUS Date: Tue, 10 May 2011 16:10:32 +0400 Subject: [PATCH 30/43] Added spell cast flags research. --- src/game/DBCEnums.h | 2 +- src/game/DBCStructure.h | 2 +- src/game/SharedDefines.h | 2 +- src/game/Spell.cpp | 64 ++++++++++++++++++++++++---------------- src/game/Spell.h | 48 +++++++++++++++--------------- 5 files changed, 65 insertions(+), 53 deletions(-) diff --git a/src/game/DBCEnums.h b/src/game/DBCEnums.h index e5833cf4cfd..cc9014575f6 100644 --- a/src/game/DBCEnums.h +++ b/src/game/DBCEnums.h @@ -420,7 +420,7 @@ enum SpellCastTargetFlags TARGET_FLAG_UNK2 = 0x00010000, // pguid, not used in any spells as of 3.0.3 (can be set dynamically) TARGET_FLAG_GLYPH = 0x00020000, // used in glyph spells TARGET_FLAG_UNK3 = 0x00040000, // - TARGET_FLAG_UNK4 = 0x00080000 // uint32, loop { vec3, guid -> if guid == 0 break } + TARGET_FLAG_VISUAL_CHAIN = 0x00080000 // uint32, loop { vec3, guid -> if guid == 0 break } }; enum SpellEffectIndex diff --git a/src/game/DBCStructure.h b/src/game/DBCStructure.h index bd71cb00829..4f496e47b64 100644 --- a/src/game/DBCStructure.h +++ b/src/game/DBCStructure.h @@ -1510,7 +1510,7 @@ struct SpellEntry uint32 Category; // 1 m_category uint32 Dispel; // 2 m_dispelType uint32 Mechanic; // 3 m_mechanic - uint32 Attributes; // 4 m_attribute + uint32 Attributes; // 4 m_attributes uint32 AttributesEx; // 5 m_attributesEx uint32 AttributesEx2; // 6 m_attributesExB uint32 AttributesEx3; // 7 m_attributesExC diff --git a/src/game/SharedDefines.h b/src/game/SharedDefines.h index 8b23914dd90..5db7aa6737e 100644 --- a/src/game/SharedDefines.h +++ b/src/game/SharedDefines.h @@ -253,7 +253,7 @@ const uint32 ItemQualityColors[MAX_ITEM_QUALITY] = { #define SPELL_ATTR_LEVEL_DAMAGE_CALCULATION 0x00080000 // 19 spelldamage depends on caster level #define SPELL_ATTR_STOP_ATTACK_TARGET 0x00100000 // 20 Stop attack after use this spell (and not begin attack if use) #define SPELL_ATTR_IMPOSSIBLE_DODGE_PARRY_BLOCK 0x00200000 // 21 Cannot be dodged/parried/blocked -#define SPELL_ATTR_UNK22 0x00400000 // 22 +#define SPELL_ATTR_SET_TRACKING_TARGET 0x00400000 // 22 SetTrackingTarget #define SPELL_ATTR_UNK23 0x00800000 // 23 castable while dead? #define SPELL_ATTR_CASTABLE_WHILE_MOUNTED 0x01000000 // 24 castable while mounted #define SPELL_ATTR_DISABLED_WHILE_ACTIVE 0x02000000 // 25 Activate and start cooldown after aura fade or remove summoned creature or go diff --git a/src/game/Spell.cpp b/src/game/Spell.cpp index 207a85d5cbb..b90911135fc 100644 --- a/src/game/Spell.cpp +++ b/src/game/Spell.cpp @@ -3588,12 +3588,12 @@ void Spell::SendSpellStart() DEBUG_FILTER_LOG(LOG_FILTER_SPELL_CAST, "Sending SMSG_SPELL_START id=%u", m_spellInfo->Id); - uint32 castFlags = CAST_FLAG_UNKNOWN1; + uint32 castFlags = CAST_FLAG_UNKNOWN2; if (IsRangedSpell()) castFlags |= CAST_FLAG_AMMO; if (m_spellInfo->runeCostID) - castFlags |= CAST_FLAG_UNKNOWN10; + castFlags |= CAST_FLAG_UNKNOWN19; WorldPacket data(SMSG_SPELL_START, (8+8+4+4+2)); if (m_CastItem) @@ -3602,16 +3602,17 @@ void Spell::SendSpellStart() data << m_caster->GetPackGUID(); data << m_caster->GetPackGUID(); - data << uint8(m_cast_count); // pending spell cast? + data << uint8(m_cast_count); // pending spell cast data << uint32(m_spellInfo->Id); // spellId data << uint32(castFlags); // cast flags data << uint32(m_timer); // delay? + data << m_targets; - if ( castFlags & CAST_FLAG_UNKNOWN6 ) // predicted power? + if (castFlags & CAST_FLAG_PREDICTED_POWER) // predicted power data << uint32(0); - if ( castFlags & CAST_FLAG_UNKNOWN7 ) // rune cooldowns list + if (castFlags & CAST_FLAG_PREDICTED_RUNES) // predicted runes { uint8 v1 = 0;//m_runesState; uint8 v2 = 0;//((Player*)m_caster)->GetRunesState(); @@ -3626,13 +3627,13 @@ void Spell::SendSpellStart() } } - if ( castFlags & CAST_FLAG_AMMO ) + if (castFlags & CAST_FLAG_AMMO) // projectile info WriteAmmoToPacket(&data); - if ( castFlags & CAST_FLAG_UNKNOWN21 ) + if (castFlags & CAST_FLAG_IMMUNITY) // cast immunity { - data << uint32(0); - data << uint32(0); + data << uint32(0); // used for SetCastSchoolImmunities + data << uint32(0); // used for SetCastImmunities } m_caster->SendMessageToSet(&data, true); @@ -3641,25 +3642,25 @@ void Spell::SendSpellStart() void Spell::SendSpellGo() { // not send invisible spell casting - if(!IsNeedSendToClient()) + if (!IsNeedSendToClient()) return; DEBUG_FILTER_LOG(LOG_FILTER_SPELL_CAST, "Sending SMSG_SPELL_GO id=%u", m_spellInfo->Id); - uint32 castFlags = CAST_FLAG_UNKNOWN3; - if(IsRangedSpell()) + uint32 castFlags = CAST_FLAG_UNKNOWN9; + if (IsRangedSpell()) castFlags |= CAST_FLAG_AMMO; // arrows/bullets visual - if((m_caster->GetTypeId() == TYPEID_PLAYER) && (m_caster->getClass() == CLASS_DEATH_KNIGHT) && m_spellInfo->runeCostID) + if ((m_caster->GetTypeId() == TYPEID_PLAYER) && (m_caster->getClass() == CLASS_DEATH_KNIGHT) && m_spellInfo->runeCostID) { - castFlags |= CAST_FLAG_UNKNOWN10; // same as in SMSG_SPELL_START - castFlags |= CAST_FLAG_UNKNOWN6; // makes cooldowns visible - castFlags |= CAST_FLAG_UNKNOWN7; // rune cooldowns list + castFlags |= CAST_FLAG_UNKNOWN19; // same as in SMSG_SPELL_START + castFlags |= CAST_FLAG_PREDICTED_POWER; // makes cooldowns visible + castFlags |= CAST_FLAG_PREDICTED_RUNES; // rune cooldowns list } WorldPacket data(SMSG_SPELL_GO, 50); // guess size - if(m_CastItem) + if (m_CastItem) data << m_CastItem->GetPackGUID(); else data << m_caster->GetPackGUID(); @@ -3668,16 +3669,16 @@ void Spell::SendSpellGo() data << uint8(m_cast_count); // pending spell cast? data << uint32(m_spellInfo->Id); // spellId data << uint32(castFlags); // cast flags - data << uint32(WorldTimer::getMSTime()); // timestamp + data << uint32(WorldTimer::getMSTime()); // timestamp WriteSpellGoTargets(&data); data << m_targets; - if ( castFlags & CAST_FLAG_UNKNOWN6 ) // unknown wotlk, predicted power? + if (castFlags & CAST_FLAG_PREDICTED_POWER) // predicted power data << uint32(0); - if ( castFlags & CAST_FLAG_UNKNOWN7 ) // rune cooldowns list + if (castFlags & CAST_FLAG_PREDICTED_RUNES) // predicted runes { uint8 v1 = m_runesState; uint8 v2 = m_caster->getClass() == CLASS_DEATH_KNIGHT ? ((Player*)m_caster)->GetRunesState() : 0; @@ -3692,26 +3693,37 @@ void Spell::SendSpellGo() } } - if ( castFlags & CAST_FLAG_UNKNOWN4 ) // unknown wotlk + if (castFlags & CAST_FLAG_ADJUST_MISSILE) // adjust missile trajectory duration { data << float(0); data << uint32(0); } - if ( castFlags & CAST_FLAG_AMMO ) + if (castFlags & CAST_FLAG_AMMO) // projectile info WriteAmmoToPacket(&data); - if ( castFlags & CAST_FLAG_UNKNOWN5 ) // unknown wotlk + if (castFlags & CAST_FLAG_VISUAL_CHAIN) // spell visual chain effect { - data << uint32(0); - data << uint32(0); + data << uint32(0); // SpellVisual.dbc id? + data << uint32(0); // overrides previous field if > 0 and violencelevel client cvar < 2 } - if ( m_targets.m_targetMask & TARGET_FLAG_DEST_LOCATION ) + if (m_targets.m_targetMask & TARGET_FLAG_DEST_LOCATION) { data << uint8(0); // The value increase for each time, can remind of a cast count for the spell } + if (m_targets.m_targetMask & TARGET_FLAG_VISUAL_CHAIN) // probably used (or can be used) with CAST_FLAG_VISUAL_CHAIN flag + { + data << uint32(0); // count + + //for(int = 0; i < count; ++i) + //{ + // // position and guid? + // data << float(0) << float(0) << float(0) << uint64(0); + //} + } + m_caster->SendMessageToSet(&data, true); } diff --git a/src/game/Spell.h b/src/game/Spell.h index 83aa1001597..923bd26f0e7 100644 --- a/src/game/Spell.h +++ b/src/game/Spell.h @@ -38,30 +38,30 @@ class Aura; enum SpellCastFlags { - CAST_FLAG_NONE = 0x00000000, - CAST_FLAG_UNKNOWN0 = 0x00000001, // may be pending spell cast - CAST_FLAG_UNKNOWN1 = 0x00000002, - CAST_FLAG_UNKNOWN11 = 0x00000004, - CAST_FLAG_UNKNOWN12 = 0x00000008, - CAST_FLAG_UNKNOWN2 = 0x00000010, - CAST_FLAG_AMMO = 0x00000020, // Projectiles visual - CAST_FLAG_UNKNOWN8 = 0x00000040, - CAST_FLAG_UNKNOWN9 = 0x00000080, - CAST_FLAG_UNKNOWN3 = 0x00000100, - CAST_FLAG_UNKNOWN13 = 0x00000200, - CAST_FLAG_UNKNOWN14 = 0x00000400, - CAST_FLAG_UNKNOWN6 = 0x00000800, // wotlk, trigger rune cooldown - CAST_FLAG_UNKNOWN15 = 0x00001000, - CAST_FLAG_UNKNOWN16 = 0x00002000, - CAST_FLAG_UNKNOWN17 = 0x00004000, - CAST_FLAG_UNKNOWN18 = 0x00008000, - CAST_FLAG_UNKNOWN19 = 0x00010000, - CAST_FLAG_UNKNOWN4 = 0x00020000, // wotlk - CAST_FLAG_UNKNOWN10 = 0x00040000, - CAST_FLAG_UNKNOWN5 = 0x00080000, // wotlk - CAST_FLAG_UNKNOWN20 = 0x00100000, - CAST_FLAG_UNKNOWN7 = 0x00200000, // wotlk, rune cooldown list - CAST_FLAG_UNKNOWN21 = 0x04000000 + CAST_FLAG_NONE = 0x00000000, + CAST_FLAG_HIDDEN_COMBATLOG = 0x00000001, // hide in combat log? + CAST_FLAG_UNKNOWN2 = 0x00000002, + CAST_FLAG_UNKNOWN3 = 0x00000004, + CAST_FLAG_UNKNOWN4 = 0x00000008, + CAST_FLAG_UNKNOWN5 = 0x00000010, + CAST_FLAG_AMMO = 0x00000020, // Projectiles visual + CAST_FLAG_UNKNOWN7 = 0x00000040, // !0x41 mask used to call CGTradeSkillInfo::DoRecast + CAST_FLAG_UNKNOWN8 = 0x00000080, + CAST_FLAG_UNKNOWN9 = 0x00000100, + CAST_FLAG_UNKNOWN10 = 0x00000200, + CAST_FLAG_UNKNOWN11 = 0x00000400, + CAST_FLAG_PREDICTED_POWER = 0x00000800, // wotlk, trigger rune cooldown + CAST_FLAG_UNKNOWN13 = 0x00001000, + CAST_FLAG_UNKNOWN14 = 0x00002000, + CAST_FLAG_UNKNOWN15 = 0x00004000, + CAST_FLAG_UNKNOWN16 = 0x00008000, + CAST_FLAG_UNKNOWN17 = 0x00010000, + CAST_FLAG_ADJUST_MISSILE = 0x00020000, // wotlk + CAST_FLAG_UNKNOWN19 = 0x00040000, // spell cooldown related (may be category cooldown) + CAST_FLAG_VISUAL_CHAIN = 0x00080000, // wotlk + CAST_FLAG_UNKNOWN21 = 0x00100000, + CAST_FLAG_PREDICTED_RUNES = 0x00200000, // wotlk, rune cooldown list + CAST_FLAG_IMMUNITY = 0x04000000 // spell cast school imminity info }; enum SpellNotifyPushType From 5caace198be7cc2e90f73b7166f5cf943345228a Mon Sep 17 00:00:00 2001 From: VladimirMangos Date: Tue, 10 May 2011 16:35:07 +0400 Subject: [PATCH 31/43] [11464] Some item related guids convertion to ObjectGuids --- src/game/Bag.cpp | 4 +-- src/game/Bag.h | 2 +- src/game/Camera.cpp | 2 +- src/game/Item.cpp | 2 +- src/game/ItemHandler.cpp | 59 ++++++++++++++++++++++------------------ src/game/Player.cpp | 8 +++--- src/game/WorldSession.h | 4 +-- src/shared/revision_nr.h | 2 +- 8 files changed, 45 insertions(+), 38 deletions(-) diff --git a/src/game/Bag.cpp b/src/game/Bag.cpp index 5797f6daaa0..54bb4b8f832 100644 --- a/src/game/Bag.cpp +++ b/src/game/Bag.cpp @@ -225,11 +225,11 @@ uint32 Bag::GetItemCountWithLimitCategory(uint32 limitCategory, Item* eItem) con return count; } -uint8 Bag::GetSlotByItemGUID(uint64 guid) const +uint8 Bag::GetSlotByItemGUID(ObjectGuid guid) const { for (uint32 i = 0; i < GetBagSize(); ++i) if (m_bagslot[i] != 0) - if (m_bagslot[i]->GetGUID() == guid) + if (m_bagslot[i]->GetObjectGuid() == guid) return i; return NULL_SLOT; diff --git a/src/game/Bag.h b/src/game/Bag.h index 0cf283f8207..0f195daa4bc 100644 --- a/src/game/Bag.h +++ b/src/game/Bag.h @@ -48,7 +48,7 @@ class Bag : public Item uint32 GetItemCount(uint32 item, Item* eItem = NULL) const; uint32 GetItemCountWithLimitCategory(uint32 limitCategory, Item* eItem = NULL) const; - uint8 GetSlotByItemGUID(uint64 guid) const; + uint8 GetSlotByItemGUID(ObjectGuid guid) const; bool IsEmpty() const; uint32 GetFreeSlots() const; uint32 GetBagSize() const { return GetUInt32Value(CONTAINER_FIELD_NUM_SLOTS); } diff --git a/src/game/Camera.cpp b/src/game/Camera.cpp index a1105613766..ba36e56ff36 100644 --- a/src/game/Camera.cpp +++ b/src/game/Camera.cpp @@ -84,7 +84,7 @@ void Camera::SetView(WorldObject *obj, bool update_far_sight_field /*= true*/) m_source->GetViewPoint().Attach(this); if (update_far_sight_field) - m_owner.SetUInt64Value(PLAYER_FARSIGHT, (m_source == &m_owner ? 0 : m_source->GetGUID())); + m_owner.SetGuidValue(PLAYER_FARSIGHT, (m_source == &m_owner ? ObjectGuid() : m_source->GetObjectGuid())); UpdateForCurrentViewPoint(); } diff --git a/src/game/Item.cpp b/src/game/Item.cpp index 47698b77fa6..fcb8efbf8ae 100644 --- a/src/game/Item.cpp +++ b/src/game/Item.cpp @@ -1073,7 +1073,7 @@ void Item::SendTimeUpdate(Player* owner) return; WorldPacket data(SMSG_ITEM_TIME_UPDATE, (8+4)); - data << uint64(GetGUID()); + data << ObjectGuid(GetObjectGuid()); data << uint32(duration); owner->GetSession()->SendPacket(&data); } diff --git a/src/game/ItemHandler.cpp b/src/game/ItemHandler.cpp index 78fe30b609f..5c17e6cfa17 100644 --- a/src/game/ItemHandler.cpp +++ b/src/game/ItemHandler.cpp @@ -92,15 +92,15 @@ void WorldSession::HandleSwapInvItemOpcode( WorldPacket & recv_data ) void WorldSession::HandleAutoEquipItemSlotOpcode( WorldPacket & recv_data ) { - uint64 itemguid; + ObjectGuid itemGuid; uint8 dstslot; - recv_data >> itemguid >> dstslot; + recv_data >> itemGuid >> dstslot; // cheating attempt, client should never send opcode in that case if(!Player::IsEquipmentPos(INVENTORY_SLOT_BAG_0, dstslot)) return; - Item* item = _player->GetItemByGuid(itemguid); + Item* item = _player->GetItemByGuid(itemGuid); uint16 dstpos = dstslot | (INVENTORY_SLOT_BAG_0 << 8); if(!item || item->GetPos() == dstpos) @@ -1049,25 +1049,25 @@ void WorldSession::HandleSetAmmoOpcode(WorldPacket & recv_data) GetPlayer()->SetAmmo(item); } -void WorldSession::SendEnchantmentLog(uint64 Target, uint64 Caster,uint32 ItemID,uint32 SpellID) +void WorldSession::SendEnchantmentLog(ObjectGuid targetGuid, ObjectGuid casterGuid, uint32 itemId, uint32 spellId) { WorldPacket data(SMSG_ENCHANTMENTLOG, (8+8+4+4+1)); // last check 2.0.10 - data << uint64(Target); - data << uint64(Caster); - data << uint32(ItemID); - data << uint32(SpellID); + data << ObjectGuid(targetGuid); + data << ObjectGuid(casterGuid); + data << uint32(itemId); + data << uint32(spellId); data << uint8(0); SendPacket(&data); } -void WorldSession::SendItemEnchantTimeUpdate(uint64 Playerguid, uint64 Itemguid,uint32 slot,uint32 Duration) +void WorldSession::SendItemEnchantTimeUpdate(ObjectGuid playerGuid, ObjectGuid itemGuid, uint32 slot, uint32 duration) { // last check 2.0.10 WorldPacket data(SMSG_ITEM_ENCHANT_TIME_UPDATE, (8+4+4+8)); - data << uint64(Itemguid); + data << ObjectGuid(itemGuid); data << uint32(slot); - data << uint32(Duration); - data << uint64(Playerguid); + data << uint32(duration); + data << ObjectGuid(playerGuid); SendPacket(&data); } @@ -1222,22 +1222,29 @@ void WorldSession::HandleSocketOpcode(WorldPacket& recv_data) { DEBUG_LOG("WORLD: CMSG_SOCKET_GEMS"); - uint64 item_guid; - uint64 gem_guids[MAX_GEM_SOCKETS]; + ObjectGuid itemGuid; + ObjectGuid gemGuids[MAX_GEM_SOCKETS]; - recv_data >> item_guid; - if(!item_guid) + recv_data >> itemGuid; + if (!itemGuid.IsItem()) return; for(int i = 0; i < MAX_GEM_SOCKETS; ++i) - recv_data >> gem_guids[i]; + recv_data >> gemGuids[i]; //cheat -> tried to socket same gem multiple times - if ((gem_guids[0] && (gem_guids[0] == gem_guids[1] || gem_guids[0] == gem_guids[2])) || - (gem_guids[1] && (gem_guids[1] == gem_guids[2]))) - return; + for(int i = 0; i < MAX_GEM_SOCKETS; ++i) + { + ObjectGuid gemGuid = gemGuids[0]; + if (!gemGuid.IsItem()) + return; + + for(int j = i+1; j < MAX_GEM_SOCKETS; ++j) + if (gemGuids[j] == gemGuid) + return; + } - Item *itemTarget = _player->GetItemByGuid(item_guid); + Item *itemTarget = _player->GetItemByGuid(itemGuid); if(!itemTarget) //missing item to socket return; @@ -1250,7 +1257,7 @@ void WorldSession::HandleSocketOpcode(WorldPacket& recv_data) Item *Gems[MAX_GEM_SOCKETS]; for(int i = 0; i < MAX_GEM_SOCKETS; ++i) - Gems[i] = gem_guids[i] ? _player->GetItemByGuid(gem_guids[i]) : NULL; + Gems[i] = !gemGuids[i].IsEmpty() ? _player->GetItemByGuid(gemGuids[i]) : NULL; GemPropertiesEntry const *GemProps[MAX_GEM_SOCKETS]; for(int i = 0; i < MAX_GEM_SOCKETS; ++i) //get geminfo from dbc storage @@ -1392,15 +1399,15 @@ void WorldSession::HandleSocketOpcode(WorldPacket& recv_data) //if a meta gem is being equipped, all information has to be written to the item before testing if the conditions for the gem are met //remove ALL enchants - for(uint32 enchant_slot = SOCK_ENCHANTMENT_SLOT; enchant_slot < SOCK_ENCHANTMENT_SLOT + MAX_GEM_SOCKETS; ++enchant_slot) + for (uint32 enchant_slot = SOCK_ENCHANTMENT_SLOT; enchant_slot < SOCK_ENCHANTMENT_SLOT + MAX_GEM_SOCKETS; ++enchant_slot) _player->ApplyEnchantment(itemTarget, EnchantmentSlot(enchant_slot), false); - for(int i = 0; i < MAX_GEM_SOCKETS; ++i) + for (int i = 0; i < MAX_GEM_SOCKETS; ++i) { - if(GemEnchants[i]) + if (GemEnchants[i]) { itemTarget->SetEnchantment(EnchantmentSlot(SOCK_ENCHANTMENT_SLOT + i), GemEnchants[i], 0, 0); - if(Item* guidItem = _player->GetItemByGuid(gem_guids[i])) + if(Item* guidItem = !gemGuids[i].IsEmpty() ? _player->GetItemByGuid(gemGuids[i]) : NULL) _player->DestroyItem(guidItem->GetBagSlot(), guidItem->GetSlot(), true ); } } diff --git a/src/game/Player.cpp b/src/game/Player.cpp index 1d4823ff271..e6f1e3ac4b2 100644 --- a/src/game/Player.cpp +++ b/src/game/Player.cpp @@ -12195,7 +12195,7 @@ void Player::AddItemToBuyBackSlot( Item *pItem ) uint32 etime = uint32(base - m_logintime + (30 * 3600)); uint32 eslot = slot - BUYBACK_SLOT_START; - SetUInt64Value( PLAYER_FIELD_VENDORBUYBACK_SLOT_1 + (eslot * 2), pItem->GetGUID() ); + SetGuidValue(PLAYER_FIELD_VENDORBUYBACK_SLOT_1 + (eslot * 2), pItem->GetObjectGuid()); if (ItemPrototype const *pProto = pItem->GetProto()) SetUInt32Value( PLAYER_FIELD_BUYBACK_PRICE_1 + eslot, pProto->SellPrice * pItem->GetCount() ); else @@ -12456,7 +12456,7 @@ void Player::AddEnchantmentDuration(Item *item,EnchantmentSlot slot,uint32 durat } if (item && duration > 0 ) { - GetSession()->SendItemEnchantTimeUpdate(GetGUID(), item->GetGUID(), slot, uint32(duration/1000)); + GetSession()->SendItemEnchantTimeUpdate(GetObjectGuid(), item->GetObjectGuid(), slot, uint32(duration/1000)); m_enchantDuration.push_back(EnchantDuration(item, slot, duration)); } } @@ -12818,7 +12818,7 @@ void Player::SendEnchantmentDurations() { for(EnchantDurationList::const_iterator itr = m_enchantDuration.begin(); itr != m_enchantDuration.end(); ++itr) { - GetSession()->SendItemEnchantTimeUpdate(GetGUID(), itr->item->GetGUID(), itr->slot, uint32(itr->leftduration) / 1000); + GetSession()->SendItemEnchantTimeUpdate(GetObjectGuid(), itr->item->GetObjectGuid(), itr->slot, uint32(itr->leftduration) / 1000); } } @@ -15652,7 +15652,7 @@ bool Player::LoadFromDB(ObjectGuid guid, SqlQueryHolder *holder ) // reset some aura modifiers before aura apply - SetUInt64Value(PLAYER_FARSIGHT, 0); + SetGuidValue(PLAYER_FARSIGHT, ObjectGuid()); SetUInt32Value(PLAYER_TRACK_CREATURES, 0 ); SetUInt32Value(PLAYER_TRACK_RESOURCES, 0 ); diff --git a/src/game/WorldSession.h b/src/game/WorldSession.h index bf396ce4f17..23df98c0c89 100644 --- a/src/game/WorldSession.h +++ b/src/game/WorldSession.h @@ -362,8 +362,8 @@ class MANGOS_DLL_SPEC WorldSession AuctionHouseEntry const* GetCheckedAuctionHouseForAuctioneer(ObjectGuid guid); //Item Enchantment - void SendEnchantmentLog(uint64 Target, uint64 Caster,uint32 ItemID,uint32 SpellID); - void SendItemEnchantTimeUpdate(uint64 Playerguid, uint64 Itemguid,uint32 slot,uint32 Duration); + void SendEnchantmentLog(ObjectGuid targetGuid, ObjectGuid casterGuid, uint32 itemId, uint32 spellId); + void SendItemEnchantTimeUpdate(ObjectGuid playerGuid, ObjectGuid itemGuid, uint32 slot, uint32 duration); //Taxi void SendTaxiStatus(ObjectGuid guid); diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index d1a53593ec8..4fa715c3bda 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 "11463" + #define REVISION_NR "11464" #endif // __REVISION_NR_H__ From eced2e4d8e8ababae314ed45a2812eceecedc94c Mon Sep 17 00:00:00 2001 From: VladimirMangos Date: Tue, 10 May 2011 21:24:43 +0400 Subject: [PATCH 32/43] [11465] non-ObjectGuid guids in random places. Only ChannelMgr code wide use uint64 guids now, and Map object stores. --- src/game/BattleGround.cpp | 46 ++++++++++++------------ src/game/BattleGroundHandler.cpp | 12 +++---- src/game/BattleGroundMgr.cpp | 2 +- src/game/BattleGroundMgr.h | 6 ++-- src/game/BattleGroundWS.cpp | 8 ++--- src/game/Chat.cpp | 12 +++---- src/game/Chat.h | 13 ++++--- src/game/ChatHandler.cpp | 26 +++++++------- src/game/Corpse.cpp | 2 +- src/game/Creature.cpp | 53 ++++++++++++++-------------- src/game/CreatureEventAI.cpp | 2 +- src/game/DynamicObject.cpp | 4 +-- src/game/GameObject.cpp | 16 ++++----- src/game/GossipDef.cpp | 14 ++++---- src/game/GossipDef.h | 2 +- src/game/GridNotifiers.cpp | 4 +-- src/game/GridNotifiersImpl.h | 2 +- src/game/Group.cpp | 2 +- src/game/GroupHandler.cpp | 2 +- src/game/Guild.cpp | 4 +-- src/game/GuildHandler.cpp | 2 +- src/game/ItemHandler.cpp | 2 +- src/game/Level2.cpp | 2 +- src/game/Map.cpp | 2 +- src/game/Object.cpp | 10 +++--- src/game/Object.h | 4 +-- src/game/Pet.cpp | 2 +- src/game/PetAI.cpp | 8 ++--- src/game/Player.cpp | 22 ++++++------ src/game/Player.h | 2 +- src/game/Spell.cpp | 12 +++---- src/game/SpellAuras.cpp | 2 +- src/game/SpellEffects.cpp | 10 +++--- src/game/TaxiHandler.cpp | 14 ++++---- src/game/ThreatManager.cpp | 11 +++--- src/game/ThreatManager.h | 5 +-- src/game/TradeHandler.cpp | 4 +-- src/game/Unit.cpp | 60 +++++++++++++++----------------- src/game/Unit.h | 6 ++-- src/game/UnitAuraProcHandler.cpp | 10 +++--- src/game/World.cpp | 4 +-- src/game/WorldSession.cpp | 2 +- src/game/debugcmds.cpp | 4 +-- src/shared/revision_nr.h | 2 +- 44 files changed, 219 insertions(+), 215 deletions(-) diff --git a/src/game/BattleGround.cpp b/src/game/BattleGround.cpp index 7de9d133ed0..ed5eecbca1f 100644 --- a/src/game/BattleGround.cpp +++ b/src/game/BattleGround.cpp @@ -64,13 +64,13 @@ namespace MaNGOS private: void do_helper(WorldPacket& data, char const* text) { - uint64 target_guid = i_source ? i_source ->GetGUID() : 0; + ObjectGuid targetGuid = i_source ? i_source ->GetObjectGuid() : ObjectGuid(); data << uint8(i_msgtype); data << uint32(LANG_UNIVERSAL); - data << uint64(target_guid); // there 0 for BG messages + data << ObjectGuid(targetGuid); // there 0 for BG messages data << uint32(0); // can be chat msg group or something - data << uint64(target_guid); + data << ObjectGuid(targetGuid); data << uint32(strlen(text)+1); data << text; data << uint8(i_source ? i_source->chatTag() : uint8(0)); @@ -110,16 +110,16 @@ namespace MaNGOS void do_helper(WorldPacket& data, char const* text) { //copyied from BuildMonsterChat - data << (uint8)CHAT_MSG_MONSTER_YELL; - data << (uint32)i_language; - data << (uint64)i_source->GetGUID(); - data << (uint32)0; //2.1.0 - data << (uint32)(strlen(i_source->GetName())+1); + data << uint8(CHAT_MSG_MONSTER_YELL); + data << uint32(i_language); + data << ObjectGuid(i_source->GetObjectGuid()); + data << uint32(0); // 2.1.0 + data << uint32(strlen(i_source->GetName())+1); data << i_source->GetName(); - data << (uint64)0; //Unit Target - isn't important for bgs - data << (uint32)strlen(text)+1; + data << ObjectGuid(); // Unit Target - isn't important for bgs + data << uint32(strlen(text)+1); data << text; - data << (uint8)0; // ChatTag - for bgs allways 0? + data << uint8(0); // ChatTag - for bgs allways 0? } uint32 i_language; @@ -143,13 +143,13 @@ namespace MaNGOS char str [2048]; snprintf(str,2048,text, arg1str, arg2str ); - uint64 target_guid = i_source ? i_source ->GetGUID() : 0; + ObjectGuid targetGuid = i_source ? i_source ->GetObjectGuid() : ObjectGuid(); data << uint8(i_msgtype); data << uint32(LANG_UNIVERSAL); - data << uint64(target_guid); // there 0 for BG messages + data << ObjectGuid(targetGuid); // there 0 for BG messages data << uint32(0); // can be chat msg group or something - data << uint64(target_guid); + data << ObjectGuid(targetGuid); data << uint32(strlen(str)+1); data << str; data << uint8(i_source ? i_source->chatTag() : uint8(0)); @@ -175,18 +175,18 @@ namespace MaNGOS char const* arg2str = i_arg2 ? sObjectMgr.GetMangosString(i_arg2,loc_idx) : ""; char str [2048]; - snprintf(str,2048,text, arg1str, arg2str ); + snprintf(str, 2048, text, arg1str, arg2str); //copyied from BuildMonsterChat - data << (uint8)CHAT_MSG_MONSTER_YELL; - data << (uint32)i_language; - data << (uint64)i_source->GetGUID(); - data << (uint32)0; //2.1.0 - data << (uint32)(strlen(i_source->GetName())+1); + data << uint8(CHAT_MSG_MONSTER_YELL); + data << uint32(i_language); + data << ObjectGuid(i_source->GetObjectGuid()); + data << uint32(0); // 2.1.0 + data << uint32(strlen(i_source->GetName())+1); data << i_source->GetName(); - data << (uint64)0; //Unit Target - isn't important for bgs - data << (uint32)strlen(str)+1; + data << uint64(0); // Unit Target - isn't important for bgs + data << uint32(strlen(str)+1); data << str; - data << (uint8)0; // ChatTag - for bgs allways 0? + data << uint8(0); // ChatTag - for bgs allways 0? } private: diff --git a/src/game/BattleGroundHandler.cpp b/src/game/BattleGroundHandler.cpp index 8b3c34c94d4..db8e8863646 100644 --- a/src/game/BattleGroundHandler.cpp +++ b/src/game/BattleGroundHandler.cpp @@ -249,15 +249,15 @@ void WorldSession::HandleBattleGroundPlayerPositionsOpcode( WorldPacket & /*recv data << count2; // horde flag holders count - obsolete, now count of next fields if (ali_plr) { - data << (uint64)ali_plr->GetGUID(); - data << (float)ali_plr->GetPositionX(); - data << (float)ali_plr->GetPositionY(); + data << ObjectGuid(ali_plr->GetObjectGuid()); + data << float(ali_plr->GetPositionX()); + data << float(ali_plr->GetPositionY()); } if (horde_plr) { - data << (uint64)horde_plr->GetGUID(); - data << (float)horde_plr->GetPositionX(); - data << (float)horde_plr->GetPositionY(); + data << ObjectGuid(horde_plr->GetObjectGuid()); + data << float(horde_plr->GetPositionX()); + data << float(horde_plr->GetPositionY()); } SendPacket(&data); diff --git a/src/game/BattleGroundMgr.cpp b/src/game/BattleGroundMgr.cpp index 30026df8a81..f58b04c36c5 100644 --- a/src/game/BattleGroundMgr.cpp +++ b/src/game/BattleGroundMgr.cpp @@ -484,7 +484,7 @@ bool BattleGroundQueue::InviteGroupToBG(GroupQueueInfo * ginfo, BattleGround * b BGQueueInviteEvent* inviteEvent = new BGQueueInviteEvent(plr->GetObjectGuid(), ginfo->IsInvitedToBGInstanceGUID, bgTypeId, ginfo->arenaType, ginfo->RemoveInviteTime); plr->m_Events.AddEvent(inviteEvent, plr->m_Events.CalculateTime(INVITATION_REMIND_TIME)); // create automatic remove events - BGQueueRemoveEvent* removeEvent = new BGQueueRemoveEvent(plr->GetGUID(), ginfo->IsInvitedToBGInstanceGUID, bgTypeId, bgQueueTypeId, ginfo->RemoveInviteTime); + BGQueueRemoveEvent* removeEvent = new BGQueueRemoveEvent(plr->GetObjectGuid(), ginfo->IsInvitedToBGInstanceGUID, bgTypeId, bgQueueTypeId, ginfo->RemoveInviteTime); plr->m_Events.AddEvent(removeEvent, plr->m_Events.CalculateTime(INVITE_ACCEPT_WAIT_TIME)); WorldPacket data; diff --git a/src/game/BattleGroundMgr.h b/src/game/BattleGroundMgr.h index 632941c1d73..703656f674e 100644 --- a/src/game/BattleGroundMgr.h +++ b/src/game/BattleGroundMgr.h @@ -168,8 +168,8 @@ class BGQueueInviteEvent : public BasicEvent class BGQueueRemoveEvent : public BasicEvent { public: - BGQueueRemoveEvent(const uint64& pl_guid, uint32 bgInstanceGUID, BattleGroundTypeId BgTypeId, BattleGroundQueueTypeId bgQueueTypeId, uint32 removeTime) - : m_PlayerGuid(pl_guid), m_BgInstanceGUID(bgInstanceGUID), m_RemoveTime(removeTime), m_BgTypeId(BgTypeId), m_BgQueueTypeId(bgQueueTypeId) + BGQueueRemoveEvent(ObjectGuid plGuid, uint32 bgInstanceGUID, BattleGroundTypeId BgTypeId, BattleGroundQueueTypeId bgQueueTypeId, uint32 removeTime) + : m_PlayerGuid(plGuid), m_BgInstanceGUID(bgInstanceGUID), m_RemoveTime(removeTime), m_BgTypeId(BgTypeId), m_BgQueueTypeId(bgQueueTypeId) {} virtual ~BGQueueRemoveEvent() {} @@ -177,7 +177,7 @@ class BGQueueRemoveEvent : public BasicEvent virtual bool Execute(uint64 e_time, uint32 p_time); virtual void Abort(uint64 e_time); private: - uint64 m_PlayerGuid; + ObjectGuid m_PlayerGuid; uint32 m_BgInstanceGUID; uint32 m_RemoveTime; BattleGroundTypeId m_BgTypeId; diff --git a/src/game/BattleGroundWS.cpp b/src/game/BattleGroundWS.cpp index eff3c3d8b9f..47e842b990d 100644 --- a/src/game/BattleGroundWS.cpp +++ b/src/game/BattleGroundWS.cpp @@ -357,7 +357,7 @@ void BattleGroundWS::EventPlayerClickedOnFlag(Player *Source, GameObject* target type = CHAT_MSG_BG_SYSTEM_HORDE; PlaySoundToAll(BG_WS_SOUND_ALLIANCE_FLAG_PICKED_UP); SpawnEvent(WS_EVENT_FLAG_A, 0, false); - SetAllianceFlagPicker(Source->GetGUID()); + SetAllianceFlagPicker(Source->GetObjectGuid()); m_FlagState[BG_TEAM_ALLIANCE] = BG_WS_FLAG_STATE_ON_PLAYER; //update world state to show correct flag carrier UpdateFlagState(HORDE, BG_WS_FLAG_STATE_ON_PLAYER); @@ -373,7 +373,7 @@ void BattleGroundWS::EventPlayerClickedOnFlag(Player *Source, GameObject* target type = CHAT_MSG_BG_SYSTEM_ALLIANCE; PlaySoundToAll(BG_WS_SOUND_HORDE_FLAG_PICKED_UP); SpawnEvent(WS_EVENT_FLAG_H, 0, false); - SetHordeFlagPicker(Source->GetGUID()); + SetHordeFlagPicker(Source->GetObjectGuid()); m_FlagState[BG_TEAM_HORDE] = BG_WS_FLAG_STATE_ON_PLAYER; //update world state to show correct flag carrier UpdateFlagState(ALLIANCE, BG_WS_FLAG_STATE_ON_PLAYER); @@ -399,7 +399,7 @@ void BattleGroundWS::EventPlayerClickedOnFlag(Player *Source, GameObject* target type = CHAT_MSG_BG_SYSTEM_HORDE; PlaySoundToAll(BG_WS_SOUND_ALLIANCE_FLAG_PICKED_UP); SpawnEvent(WS_EVENT_FLAG_A, 0, false); - SetAllianceFlagPicker(Source->GetGUID()); + SetAllianceFlagPicker(Source->GetObjectGuid()); Source->CastSpell(Source, BG_WS_SPELL_SILVERWING_FLAG, true); m_FlagState[BG_TEAM_ALLIANCE] = BG_WS_FLAG_STATE_ON_PLAYER; UpdateFlagState(HORDE, BG_WS_FLAG_STATE_ON_PLAYER); @@ -427,7 +427,7 @@ void BattleGroundWS::EventPlayerClickedOnFlag(Player *Source, GameObject* target type = CHAT_MSG_BG_SYSTEM_ALLIANCE; PlaySoundToAll(BG_WS_SOUND_HORDE_FLAG_PICKED_UP); SpawnEvent(WS_EVENT_FLAG_H, 0, false); - SetHordeFlagPicker(Source->GetGUID()); + SetHordeFlagPicker(Source->GetObjectGuid()); Source->CastSpell(Source, BG_WS_SPELL_WARSONG_FLAG, true); m_FlagState[BG_TEAM_HORDE] = BG_WS_FLAG_STATE_ON_PLAYER; UpdateFlagState(ALLIANCE, BG_WS_FLAG_STATE_ON_PLAYER); diff --git a/src/game/Chat.cpp b/src/game/Chat.cpp index 685735a3506..4bee5f94420 100644 --- a/src/game/Chat.cpp +++ b/src/game/Chat.cpp @@ -1993,7 +1993,7 @@ valid examples: } //Note: target_guid used only in CHAT_MSG_WHISPER_INFORM mode (in this case channelName ignored) -void ChatHandler::FillMessageData( WorldPacket *data, WorldSession* session, uint8 type, uint32 language, const char *channelName, uint64 target_guid, const char *message, Unit *speaker) +void ChatHandler::FillMessageData( WorldPacket *data, WorldSession* session, uint8 type, uint32 language, const char *channelName, ObjectGuid targetGuid, const char *message, Unit *speaker) { uint32 messageLength = (message ? strlen(message) : 0) + 1; @@ -2022,7 +2022,7 @@ void ChatHandler::FillMessageData( WorldPacket *data, WorldSession* session, uin case CHAT_MSG_BG_SYSTEM_HORDE: case CHAT_MSG_BATTLEGROUND: case CHAT_MSG_BATTLEGROUND_LEADER: - target_guid = session ? session->GetPlayer()->GetGUID() : 0; + targetGuid = session ? session->GetPlayer()->GetObjectGuid() : ObjectGuid(); break; case CHAT_MSG_MONSTER_SAY: case CHAT_MSG_MONSTER_PARTY: @@ -2033,7 +2033,7 @@ void ChatHandler::FillMessageData( WorldPacket *data, WorldSession* session, uin case CHAT_MSG_RAID_BOSS_EMOTE: case CHAT_MSG_BATTLENET: { - *data << speaker->GetObjectGuid(); + *data << ObjectGuid(speaker->GetObjectGuid()); *data << uint32(0); // 2.1.0 *data << uint32(strlen(speaker->GetName()) + 1); *data << speaker->GetName(); @@ -2051,11 +2051,11 @@ void ChatHandler::FillMessageData( WorldPacket *data, WorldSession* session, uin } default: if (type != CHAT_MSG_WHISPER_INFORM && type != CHAT_MSG_IGNORED && type != CHAT_MSG_DND && type != CHAT_MSG_AFK) - target_guid = 0; // only for CHAT_MSG_WHISPER_INFORM used original value target_guid + targetGuid.Clear(); // only for CHAT_MSG_WHISPER_INFORM used original value target_guid break; } - *data << uint64(target_guid); // there 0 for BG messages + *data << ObjectGuid(targetGuid); // there 0 for BG messages *data << uint32(0); // can be chat msg group or something if (type == CHAT_MSG_CHANNEL) @@ -2064,7 +2064,7 @@ void ChatHandler::FillMessageData( WorldPacket *data, WorldSession* session, uin *data << channelName; } - *data << uint64(target_guid); + *data << ObjectGuid(targetGuid); *data << uint32(messageLength); *data << message; if(session != 0 && type != CHAT_MSG_WHISPER_INFORM && type != CHAT_MSG_DND && type != CHAT_MSG_AFK) diff --git a/src/game/Chat.h b/src/game/Chat.h index 5591607ef5e..64030a938b3 100644 --- a/src/game/Chat.h +++ b/src/game/Chat.h @@ -69,16 +69,21 @@ class ChatHandler explicit ChatHandler(Player* player); ~ChatHandler(); - static void FillMessageData( WorldPacket *data, WorldSession* session, uint8 type, uint32 language, const char *channelName, uint64 target_guid, const char *message, Unit *speaker); + static void FillMessageData( WorldPacket *data, WorldSession* session, uint8 type, uint32 language, const char *channelName, ObjectGuid targetGuid, const char *message, Unit *speaker); - void FillMessageData( WorldPacket *data, uint8 type, uint32 language, uint64 target_guid, const char* message) + static void FillMessageData( WorldPacket *data, WorldSession* session, uint8 type, uint32 language, ObjectGuid targetGuid, const char* message) { - FillMessageData( data, m_session, type, language, NULL, target_guid, message, NULL); + FillMessageData( data, session, type, language, NULL, targetGuid, message, NULL); + } + + static void FillMessageData( WorldPacket *data, WorldSession* session, uint8 type, uint32 language, const char* message) + { + FillMessageData( data, session, type, language, NULL, ObjectGuid(), message, NULL); } void FillSystemMessageData( WorldPacket *data, const char* message ) { - FillMessageData( data, CHAT_MSG_SYSTEM, LANG_UNIVERSAL, 0, message ); + FillMessageData( data, m_session, CHAT_MSG_SYSTEM, LANG_UNIVERSAL, ObjectGuid(), message ); } static char* LineFromMessage(char*& pos) { char* start = strtok(pos,"\n"); pos = NULL; return start; } diff --git a/src/game/ChatHandler.cpp b/src/game/ChatHandler.cpp index 19e7eabc518..f28a94026cb 100644 --- a/src/game/ChatHandler.cpp +++ b/src/game/ChatHandler.cpp @@ -257,7 +257,7 @@ void WorldSession::HandleMessagechatOpcode( WorldPacket & recv_data ) return; WorldPacket data; - ChatHandler::FillMessageData(&data, this, type, lang, NULL, 0, msg.c_str(), NULL); + ChatHandler::FillMessageData(&data, this, type, lang, msg.c_str()); group->BroadcastPacket(&data, false, group->GetMemberGroup(GetPlayer()->GetObjectGuid())); } break; @@ -332,7 +332,7 @@ void WorldSession::HandleMessagechatOpcode( WorldPacket & recv_data ) } WorldPacket data; - ChatHandler::FillMessageData(&data, this, CHAT_MSG_RAID, lang, "", 0, msg.c_str(), NULL); + ChatHandler::FillMessageData(&data, this, CHAT_MSG_RAID, lang, msg.c_str()); group->BroadcastPacket(&data, false); } break; case CHAT_MSG_RAID_LEADER: @@ -362,7 +362,7 @@ void WorldSession::HandleMessagechatOpcode( WorldPacket & recv_data ) } WorldPacket data; - ChatHandler::FillMessageData(&data, this, CHAT_MSG_RAID_LEADER, lang, "", 0, msg.c_str(), NULL); + ChatHandler::FillMessageData(&data, this, CHAT_MSG_RAID_LEADER, lang, msg.c_str()); group->BroadcastPacket(&data, false); } break; @@ -384,7 +384,7 @@ void WorldSession::HandleMessagechatOpcode( WorldPacket & recv_data ) WorldPacket data; //in battleground, raid warning is sent only to players in battleground - code is ok - ChatHandler::FillMessageData(&data, this, CHAT_MSG_RAID_WARNING, lang, "", 0, msg.c_str(), NULL); + ChatHandler::FillMessageData(&data, this, CHAT_MSG_RAID_WARNING, lang, msg.c_str()); group->BroadcastPacket(&data, false); } break; @@ -405,7 +405,7 @@ void WorldSession::HandleMessagechatOpcode( WorldPacket & recv_data ) return; WorldPacket data; - ChatHandler::FillMessageData(&data, this, CHAT_MSG_BATTLEGROUND, lang, "", 0, msg.c_str(), NULL); + ChatHandler::FillMessageData(&data, this, CHAT_MSG_BATTLEGROUND, lang, msg.c_str()); group->BroadcastPacket(&data, false); } break; @@ -426,7 +426,7 @@ void WorldSession::HandleMessagechatOpcode( WorldPacket & recv_data ) return; WorldPacket data; - ChatHandler::FillMessageData(&data, this, CHAT_MSG_BATTLEGROUND_LEADER, lang, "", 0, msg.c_str(), NULL); + ChatHandler::FillMessageData(&data, this, CHAT_MSG_BATTLEGROUND_LEADER, lang, msg.c_str()); group->BroadcastPacket(&data, false); } break; @@ -520,14 +520,14 @@ namespace MaNGOS uint32 namlen = (nam ? strlen(nam) : 0) + 1; data.Initialize(SMSG_TEXT_EMOTE, (20+namlen)); - data << i_player.GetGUID(); - data << (uint32)i_text_emote; - data << i_emote_num; - data << (uint32)namlen; - if( namlen > 1 ) + data << ObjectGuid(i_player.GetObjectGuid()); + data << uint32(i_text_emote); + data << uint32(i_emote_num); + data << uint32(namlen); + if (namlen > 1) data.append(nam, namlen); else - data << (uint8)0x00; + data << uint8(0x00); } private: @@ -609,7 +609,7 @@ void WorldSession::HandleChatIgnoredOpcode(WorldPacket& recv_data ) return; WorldPacket data; - ChatHandler::FillMessageData(&data, this, CHAT_MSG_IGNORED, LANG_UNIVERSAL, NULL, GetPlayer()->GetGUID(), GetPlayer()->GetName(), NULL); + ChatHandler::FillMessageData(&data, this, CHAT_MSG_IGNORED, LANG_UNIVERSAL, NULL, GetPlayer()->GetObjectGuid(), GetPlayer()->GetName(), NULL); player->GetSession()->SendPacket(&data); } diff --git a/src/game/Corpse.cpp b/src/game/Corpse.cpp index e92bf9820eb..e1a7d85246d 100644 --- a/src/game/Corpse.cpp +++ b/src/game/Corpse.cpp @@ -126,7 +126,7 @@ void Corpse::SaveToDB() void Corpse::DeleteBonesFromWorld() { MANGOS_ASSERT(GetType() == CORPSE_BONES); - Corpse* corpse = GetMap()->GetCorpse(GetGUID()); + Corpse* corpse = GetMap()->GetCorpse(GetObjectGuid()); if (!corpse) { diff --git a/src/game/Creature.cpp b/src/game/Creature.cpp index 9e079583c61..f48538b74dc 100644 --- a/src/game/Creature.cpp +++ b/src/game/Creature.cpp @@ -815,15 +815,15 @@ bool Creature::IsTrainerOf(Player* pPlayer, bool msg) const pPlayer->PlayerTalkClass->ClearMenus(); switch(GetCreatureInfo()->trainer_class) { - case CLASS_DRUID: pPlayer->PlayerTalkClass->SendGossipMenu( 4913,GetGUID()); break; - case CLASS_HUNTER: pPlayer->PlayerTalkClass->SendGossipMenu(10090,GetGUID()); break; - case CLASS_MAGE: pPlayer->PlayerTalkClass->SendGossipMenu( 328,GetGUID()); break; - case CLASS_PALADIN:pPlayer->PlayerTalkClass->SendGossipMenu( 1635,GetGUID()); break; - case CLASS_PRIEST: pPlayer->PlayerTalkClass->SendGossipMenu( 4436,GetGUID()); break; - case CLASS_ROGUE: pPlayer->PlayerTalkClass->SendGossipMenu( 4797,GetGUID()); break; - case CLASS_SHAMAN: pPlayer->PlayerTalkClass->SendGossipMenu( 5003,GetGUID()); break; - case CLASS_WARLOCK:pPlayer->PlayerTalkClass->SendGossipMenu( 5836,GetGUID()); break; - case CLASS_WARRIOR:pPlayer->PlayerTalkClass->SendGossipMenu( 4985,GetGUID()); break; + case CLASS_DRUID: pPlayer->PlayerTalkClass->SendGossipMenu( 4913, GetObjectGuid()); break; + case CLASS_HUNTER: pPlayer->PlayerTalkClass->SendGossipMenu(10090, GetObjectGuid()); break; + case CLASS_MAGE: pPlayer->PlayerTalkClass->SendGossipMenu( 328, GetObjectGuid()); break; + case CLASS_PALADIN:pPlayer->PlayerTalkClass->SendGossipMenu( 1635, GetObjectGuid()); break; + case CLASS_PRIEST: pPlayer->PlayerTalkClass->SendGossipMenu( 4436, GetObjectGuid()); break; + case CLASS_ROGUE: pPlayer->PlayerTalkClass->SendGossipMenu( 4797, GetObjectGuid()); break; + case CLASS_SHAMAN: pPlayer->PlayerTalkClass->SendGossipMenu( 5003, GetObjectGuid()); break; + case CLASS_WARLOCK:pPlayer->PlayerTalkClass->SendGossipMenu( 5836, GetObjectGuid()); break; + case CLASS_WARRIOR:pPlayer->PlayerTalkClass->SendGossipMenu( 4985, GetObjectGuid()); break; } } return false; @@ -835,7 +835,7 @@ bool Creature::IsTrainerOf(Player* pPlayer, bool msg) const if (msg) { pPlayer->PlayerTalkClass->ClearMenus(); - pPlayer->PlayerTalkClass->SendGossipMenu(3620, GetGUID()); + pPlayer->PlayerTalkClass->SendGossipMenu(3620, GetObjectGuid()); } return false; } @@ -855,16 +855,16 @@ bool Creature::IsTrainerOf(Player* pPlayer, bool msg) const pPlayer->PlayerTalkClass->ClearMenus(); switch(GetCreatureInfo()->trainer_class) { - case RACE_DWARF: pPlayer->PlayerTalkClass->SendGossipMenu(5865,GetGUID()); break; - case RACE_GNOME: pPlayer->PlayerTalkClass->SendGossipMenu(4881,GetGUID()); break; - case RACE_HUMAN: pPlayer->PlayerTalkClass->SendGossipMenu(5861,GetGUID()); break; - case RACE_NIGHTELF: pPlayer->PlayerTalkClass->SendGossipMenu(5862,GetGUID()); break; - case RACE_ORC: pPlayer->PlayerTalkClass->SendGossipMenu(5863,GetGUID()); break; - case RACE_TAUREN: pPlayer->PlayerTalkClass->SendGossipMenu(5864,GetGUID()); break; - case RACE_TROLL: pPlayer->PlayerTalkClass->SendGossipMenu(5816,GetGUID()); break; - case RACE_UNDEAD: pPlayer->PlayerTalkClass->SendGossipMenu( 624,GetGUID()); break; - case RACE_BLOODELF: pPlayer->PlayerTalkClass->SendGossipMenu(5862,GetGUID()); break; - case RACE_DRAENEI: pPlayer->PlayerTalkClass->SendGossipMenu(5864,GetGUID()); break; + case RACE_DWARF: pPlayer->PlayerTalkClass->SendGossipMenu(5865, GetObjectGuid()); break; + case RACE_GNOME: pPlayer->PlayerTalkClass->SendGossipMenu(4881, GetObjectGuid()); break; + case RACE_HUMAN: pPlayer->PlayerTalkClass->SendGossipMenu(5861, GetObjectGuid()); break; + case RACE_NIGHTELF: pPlayer->PlayerTalkClass->SendGossipMenu(5862, GetObjectGuid()); break; + case RACE_ORC: pPlayer->PlayerTalkClass->SendGossipMenu(5863, GetObjectGuid()); break; + case RACE_TAUREN: pPlayer->PlayerTalkClass->SendGossipMenu(5864, GetObjectGuid()); break; + case RACE_TROLL: pPlayer->PlayerTalkClass->SendGossipMenu(5816, GetObjectGuid()); break; + case RACE_UNDEAD: pPlayer->PlayerTalkClass->SendGossipMenu( 624, GetObjectGuid()); break; + case RACE_BLOODELF: pPlayer->PlayerTalkClass->SendGossipMenu(5862, GetObjectGuid()); break; + case RACE_DRAENEI: pPlayer->PlayerTalkClass->SendGossipMenu(5864, GetObjectGuid()); break; } } return false; @@ -876,7 +876,7 @@ bool Creature::IsTrainerOf(Player* pPlayer, bool msg) const if (msg) { pPlayer->PlayerTalkClass->ClearMenus(); - pPlayer->PlayerTalkClass->SendGossipMenu(11031, GetGUID()); + pPlayer->PlayerTalkClass->SendGossipMenu(11031, GetObjectGuid()); } return false; } @@ -904,9 +904,9 @@ bool Creature::CanInteractWithBattleMaster(Player* pPlayer, bool msg) const pPlayer->PlayerTalkClass->ClearMenus(); switch(bgTypeId) { - case BATTLEGROUND_AV: pPlayer->PlayerTalkClass->SendGossipMenu(7616, GetGUID()); break; - case BATTLEGROUND_WS: pPlayer->PlayerTalkClass->SendGossipMenu(7599, GetGUID()); break; - case BATTLEGROUND_AB: pPlayer->PlayerTalkClass->SendGossipMenu(7642, GetGUID()); break; + case BATTLEGROUND_AV: pPlayer->PlayerTalkClass->SendGossipMenu(7616, GetObjectGuid()); break; + case BATTLEGROUND_WS: pPlayer->PlayerTalkClass->SendGossipMenu(7599, GetObjectGuid()); break; + case BATTLEGROUND_AB: pPlayer->PlayerTalkClass->SendGossipMenu(7642, GetObjectGuid()); break; case BATTLEGROUND_EY: case BATTLEGROUND_NA: case BATTLEGROUND_BE: @@ -914,7 +914,7 @@ bool Creature::CanInteractWithBattleMaster(Player* pPlayer, bool msg) const case BATTLEGROUND_RL: case BATTLEGROUND_SA: case BATTLEGROUND_DS: - case BATTLEGROUND_RV: pPlayer->PlayerTalkClass->SendGossipMenu(10024, GetGUID()); break; + case BATTLEGROUND_RV: pPlayer->PlayerTalkClass->SendGossipMenu(10024, GetObjectGuid()); break; default: break; } return false; @@ -2412,7 +2412,8 @@ void Creature::SendAreaSpiritHealerQueryOpcode(Player *pl) if (Spell* pcurSpell = GetCurrentSpell(CURRENT_CHANNELED_SPELL)) next_resurrect = pcurSpell->GetCastedTime(); WorldPacket data(SMSG_AREA_SPIRIT_HEALER_TIME, 8 + 4); - data << GetGUID() << next_resurrect; + data << ObjectGuid(GetObjectGuid()); + data << uint32(next_resurrect); pl->SendDirectMessage(&data); } diff --git a/src/game/CreatureEventAI.cpp b/src/game/CreatureEventAI.cpp index 2cfc7bea84b..6813995693f 100644 --- a/src/game/CreatureEventAI.cpp +++ b/src/game/CreatureEventAI.cpp @@ -773,7 +773,7 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32 return; } - pInst->SetData64(action.set_inst_data64.field, target->GetGUID()); + pInst->SetData64(action.set_inst_data64.field, target->GetObjectGuid().GetRawValue()); break; } case ACTION_T_UPDATE_TEMPLATE: diff --git a/src/game/DynamicObject.cpp b/src/game/DynamicObject.cpp index 9a2a2e703ae..e8701a37744 100644 --- a/src/game/DynamicObject.cpp +++ b/src/game/DynamicObject.cpp @@ -141,14 +141,14 @@ void DynamicObject::Update(uint32 update_diff, uint32 p_time) if(deleteThis) { - caster->RemoveDynObjectWithGUID(GetGUID()); + caster->RemoveDynObjectWithGUID(GetObjectGuid()); Delete(); } } void DynamicObject::Delete() { - SendObjectDeSpawnAnim(GetGUID()); + SendObjectDeSpawnAnim(GetObjectGuid()); AddObjectToRemoveList(); } diff --git a/src/game/GameObject.cpp b/src/game/GameObject.cpp index 0ac2218c9f2..95fcf22c5bf 100644 --- a/src/game/GameObject.cpp +++ b/src/game/GameObject.cpp @@ -199,7 +199,7 @@ void GameObject::Update(uint32 update_diff, uint32 /*p_time*/) udata.BuildPacket(&packet); ((Player*)caster)->GetSession()->SendPacket(&packet); - SendGameObjectCustomAnim(GetGUID()); + SendGameObjectCustomAnim(GetObjectGuid()); } m_lootState = GO_READY; // can be successfully open with some chance @@ -316,7 +316,7 @@ void GameObject::Update(uint32 update_diff, uint32 /*p_time*/) { Unit *caster = owner ? owner : ok; - caster->CastSpell(ok, goInfo->trap.spellId, true, NULL, NULL, GetGUID()); + caster->CastSpell(ok, goInfo->trap.spellId, true, NULL, NULL, GetObjectGuid()); // use template cooldown if provided m_cooldownTime = time(NULL) + (goInfo->trap.cooldown ? goInfo->trap.cooldown : uint32(4)); @@ -329,7 +329,7 @@ void GameObject::Update(uint32 update_diff, uint32 /*p_time*/) //BattleGround gameobjects case if (((Player*)ok)->InBattleGround()) if (BattleGround *bg = ((Player*)ok)->GetBattleGround()) - bg->HandleTriggerBuff(GetGUID()); + bg->HandleTriggerBuff(GetObjectGuid()); } } } @@ -380,7 +380,7 @@ void GameObject::Update(uint32 update_diff, uint32 /*p_time*/) for (GuidsSet::const_iterator itr = m_UniqueUsers.begin(); itr != m_UniqueUsers.end(); ++itr) { if (Player* owner = GetMap()->GetPlayer(*itr)) - owner->CastSpell(owner, spellId, false, NULL, NULL, GetGUID()); + owner->CastSpell(owner, spellId, false, NULL, NULL, GetObjectGuid()); } ClearAllUsesData(); @@ -404,7 +404,7 @@ void GameObject::Update(uint32 update_diff, uint32 /*p_time*/) // burning flags in some battlegrounds, if you find better condition, just add it if (GetGOInfo()->IsDespawnAtAction() || GetGoAnimProgress() > 0) { - SendObjectDeSpawnAnim(GetGUID()); + SendObjectDeSpawnAnim(GetObjectGuid()); //reset flags SetUInt32Value(GAMEOBJECT_FLAGS, GetGOInfo()->flags); } @@ -458,7 +458,7 @@ void GameObject::AddUniqueUse(Player* player) void GameObject::Delete() { - SendObjectDeSpawnAnim(GetGUID()); + SendObjectDeSpawnAnim(GetObjectGuid()); SetGoState(GO_STATE_READY); SetUInt32Value(GAMEOBJECT_FLAGS, GetGOInfo()->flags); @@ -1098,7 +1098,7 @@ void GameObject::Use(Unit* user) if (info->goober.pageId) // show page... { WorldPacket data(SMSG_GAMEOBJECT_PAGETEXT, 8); - data << GetGUID(); + data << ObjectGuid(GetObjectGuid()); player->GetSession()->SendPacket(&data); } else if (info->goober.gossipID) // ...or gossip, if page does not exist @@ -1139,7 +1139,7 @@ void GameObject::Use(Unit* user) // this appear to be ok, however others exist in addition to this that should have custom (ex: 190510, 188692, 187389) if (time_to_restore && info->goober.customAnim) - SendGameObjectCustomAnim(GetGUID()); + SendGameObjectCustomAnim(GetObjectGuid()); else SetGoState(GO_STATE_ACTIVE); diff --git a/src/game/GossipDef.cpp b/src/game/GossipDef.cpp index fd67ce12b78..21afc978257 100644 --- a/src/game/GossipDef.cpp +++ b/src/game/GossipDef.cpp @@ -149,10 +149,10 @@ bool PlayerMenu::GossipOptionCoded( unsigned int Selection ) return mGossipMenu.MenuItemCoded( Selection ); } -void PlayerMenu::SendGossipMenu(uint32 TitleTextId, uint64 objectGUID) +void PlayerMenu::SendGossipMenu(uint32 TitleTextId, ObjectGuid objectGuid) { WorldPacket data(SMSG_GOSSIP_MESSAGE, (100)); // guess size - data << uint64(objectGUID); + data << ObjectGuid(objectGuid); data << uint32(mGossipMenu.GetMenuId()); // new 2.4.0 data << uint32(TitleTextId); data << uint32(mGossipMenu.MenuItemCount()); // max count 0x20 @@ -160,17 +160,17 @@ void PlayerMenu::SendGossipMenu(uint32 TitleTextId, uint64 objectGUID) for (uint32 iI = 0; iI < mGossipMenu.MenuItemCount(); ++iI ) { GossipMenuItem const& gItem = mGossipMenu.GetItem(iI); - data << uint32( iI ); - data << uint8( gItem.m_gIcon ); - data << uint8( gItem.m_gCoded ); // makes pop up box password + data << uint32(iI); + data << uint8(gItem.m_gIcon); + data << uint8(gItem.m_gCoded); // makes pop up box password data << uint32(gItem.m_gBoxMoney); // money required to open menu, 2.0.3 data << gItem.m_gMessage; // text for gossip item, max 0x800 data << gItem.m_gBoxMessage; // accept text (related to money) pop up box, 2.0.3, max 0x800 } - data << uint32( mQuestMenu.MenuItemCount() ); // max count 0x20 + data << uint32(mQuestMenu.MenuItemCount()); // max count 0x20 - for (uint32 iI = 0; iI < mQuestMenu.MenuItemCount(); ++iI ) + for (uint32 iI = 0; iI < mQuestMenu.MenuItemCount(); ++iI) { QuestMenuItem const& qItem = mQuestMenu.GetItem(iI); uint32 questID = qItem.m_qId; diff --git a/src/game/GossipDef.h b/src/game/GossipDef.h index 42cbbefefac..9e46bb23aa7 100644 --- a/src/game/GossipDef.h +++ b/src/game/GossipDef.h @@ -264,7 +264,7 @@ class MANGOS_DLL_SPEC PlayerMenu uint32 GossipOptionAction( unsigned int Selection ); bool GossipOptionCoded( unsigned int Selection ); - void SendGossipMenu( uint32 TitleTextId, uint64 npcGUID ); + void SendGossipMenu(uint32 titleTextId, ObjectGuid objectGuid); void CloseGossip(); void SendPointOfInterest( float X, float Y, uint32 Icon, uint32 Flags, uint32 Data, const char * locName ); void SendPointOfInterest( uint32 poi_id ); diff --git a/src/game/GridNotifiers.cpp b/src/game/GridNotifiers.cpp index 021cbd27e57..acc7c36c987 100644 --- a/src/game/GridNotifiers.cpp +++ b/src/game/GridNotifiers.cpp @@ -47,12 +47,12 @@ VisibleNotifier::Notify() { for(Transport::PlayerSet::const_iterator itr = transport->GetPassengers().begin();itr!=transport->GetPassengers().end();++itr) { - if (i_clientGUIDs.find((*itr)->GetGUID()) != i_clientGUIDs.end()) + if (i_clientGUIDs.find((*itr)->GetObjectGuid()) != i_clientGUIDs.end()) { // ignore far sight case (*itr)->UpdateVisibilityOf(*itr, &player); player.UpdateVisibilityOf(&player, *itr, i_data, i_visibleNow); - i_clientGUIDs.erase((*itr)->GetGUID()); + i_clientGUIDs.erase((*itr)->GetObjectGuid()); } } } diff --git a/src/game/GridNotifiersImpl.h b/src/game/GridNotifiersImpl.h index 4ddac7a3cb7..59b4dcd5875 100644 --- a/src/game/GridNotifiersImpl.h +++ b/src/game/GridNotifiersImpl.h @@ -34,7 +34,7 @@ inline void MaNGOS::VisibleNotifier::Visit(GridRefManager &m) for(typename GridRefManager::iterator iter = m.begin(); iter != m.end(); ++iter) { i_camera.UpdateVisibilityOf(iter->getSource(), i_data, i_visibleNow); - i_clientGUIDs.erase(iter->getSource()->GetGUID()); + i_clientGUIDs.erase(iter->getSource()->GetObjectGuid()); } } diff --git a/src/game/Group.cpp b/src/game/Group.cpp index fbd57e530df..d983d1cb412 100644 --- a/src/game/Group.cpp +++ b/src/game/Group.cpp @@ -750,7 +750,7 @@ void Group::StartLootRool(Creature* lootTarget, LootMethod method, Loot* loot, u LootItem const& lootItem = loot->items[itemSlot]; - Roll* r = new Roll(lootTarget->GetGUID(), method, lootItem); + Roll* r = new Roll(lootTarget->GetObjectGuid(), method, lootItem); //a vector is filled with only near party members for(GroupReference *itr = GetFirstMember(); itr != NULL; itr = itr->next()) diff --git a/src/game/GroupHandler.cpp b/src/game/GroupHandler.cpp index add6d596e56..33cad559b54 100644 --- a/src/game/GroupHandler.cpp +++ b/src/game/GroupHandler.cpp @@ -622,7 +622,7 @@ void WorldSession::HandleRaidReadyCheckOpcode( WorldPacket & recv_data ) // everything is fine, do it WorldPacket data(MSG_RAID_READY_CHECK, 8); - data << GetPlayer()->GetGUID(); + data << ObjectGuid(GetPlayer()->GetObjectGuid()); group->BroadcastPacket(&data, false, -1); group->OfflineReadyCheck(); diff --git a/src/game/Guild.cpp b/src/game/Guild.cpp index 26491d06213..38c789cc5e0 100644 --- a/src/game/Guild.cpp +++ b/src/game/Guild.cpp @@ -554,7 +554,7 @@ void Guild::BroadcastToGuild(WorldSession *session, const std::string& msg, uint if (session && session->GetPlayer() && HasRankRight(session->GetPlayer()->GetRank(),GR_RIGHT_GCHATSPEAK)) { WorldPacket data; - ChatHandler(session).FillMessageData(&data, CHAT_MSG_GUILD, language, 0, msg.c_str()); + ChatHandler::FillMessageData(&data, session, CHAT_MSG_GUILD, language, msg.c_str()); for (MemberList::const_iterator itr = members.begin(); itr != members.end(); ++itr) { @@ -573,7 +573,7 @@ void Guild::BroadcastToOfficers(WorldSession *session, const std::string& msg, u for(MemberList::const_iterator itr = members.begin(); itr != members.end(); ++itr) { WorldPacket data; - ChatHandler::FillMessageData(&data, session, CHAT_MSG_OFFICER, language, NULL, 0, msg.c_str(), NULL); + ChatHandler::FillMessageData(&data, session, CHAT_MSG_OFFICER, language, msg.c_str()); Player *pl = ObjectAccessor::FindPlayer(ObjectGuid(HIGHGUID_PLAYER, itr->first)); diff --git a/src/game/GuildHandler.cpp b/src/game/GuildHandler.cpp index 174015b3618..72b27243a0c 100644 --- a/src/game/GuildHandler.cpp +++ b/src/game/GuildHandler.cpp @@ -383,7 +383,7 @@ void WorldSession::HandleGuildLeaveOpcode(WorldPacket& /*recvPacket*/) // Put record into guild log guild->LogGuildEvent(GUILD_EVENT_LOG_LEAVE_GUILD, _player->GetObjectGuid()); - guild->BroadcastEvent(GE_LEFT, _player->GetGUID(), _player->GetName()); + guild->BroadcastEvent(GE_LEFT, _player->GetObjectGuid(), _player->GetName()); SendGuildCommandResult(GUILD_QUIT_S, guild->GetName(), ERR_PLAYER_NO_MORE_IN_GUILD); } diff --git a/src/game/ItemHandler.cpp b/src/game/ItemHandler.cpp index 5c17e6cfa17..14db968e78e 100644 --- a/src/game/ItemHandler.cpp +++ b/src/game/ItemHandler.cpp @@ -466,7 +466,7 @@ void WorldSession::HandleReadItemOpcode( WorldPacket & recv_data ) DETAIL_LOG("STORAGE: Unable to read item"); _player->SendEquipError( msg, pItem, NULL ); } - data << pItem->GetGUID(); + data << ObjectGuid(pItem->GetObjectGuid()); SendPacket(&data); } else diff --git a/src/game/Level2.cpp b/src/game/Level2.cpp index 0e850ced83a..e677e80f887 100644 --- a/src/game/Level2.cpp +++ b/src/game/Level2.cpp @@ -3498,7 +3498,7 @@ bool ChatHandler::HandleWpShowCommand(char* args) // (0.001) - There is no other way to compare C++ floats with mySQL floats // See also: http://dev.mysql.com/doc/refman/5.0/en/problems-with-float.html const char* maxDIFF = "0.01"; - PSendSysMessage(LANG_WAYPOINT_NOTFOUNDSEARCH, target->GetGUID()); + PSendSysMessage(LANG_WAYPOINT_NOTFOUNDSEARCH, target->GetObjectGuid().GetRawValue()); result = WorldDatabase.PQuery("SELECT id, point, waittime, emote, spell, textid1, textid2, textid3, textid4, textid5, model1, model2 FROM creature_movement WHERE (abs(position_x - %f) <= %s ) and (abs(position_y - %f) <= %s ) and (abs(position_z - %f) <= %s )", target->GetPositionX(), maxDIFF, target->GetPositionY(), maxDIFF, target->GetPositionZ(), maxDIFF); diff --git a/src/game/Map.cpp b/src/game/Map.cpp index d35f230556b..a39022bda6f 100644 --- a/src/game/Map.cpp +++ b/src/game/Map.cpp @@ -999,7 +999,7 @@ void Map::RemoveAllObjectsInRemoveList() case TYPEID_CORPSE: { // ??? WTF - Corpse* corpse = GetCorpse(obj->GetGUID()); + Corpse* corpse = GetCorpse(obj->GetObjectGuid()); if (!corpse) sLog.outError("Try delete corpse/bones %u that not in map", obj->GetGUIDLow()); else diff --git a/src/game/Object.cpp b/src/game/Object.cpp index a2523be28a5..d3d96f99829 100644 --- a/src/game/Object.cpp +++ b/src/game/Object.cpp @@ -213,7 +213,7 @@ void Object::BuildValuesUpdateBlockForPlayer(UpdateData *data, Player *target) c void Object::BuildOutOfRangeUpdateBlock(UpdateData * data) const { - data->AddOutOfRangeGUID(GetGUID()); + data->AddOutOfRangeGUID(GetObjectGuid()); } void Object::DestroyForPlayer( Player *target, bool anim ) const @@ -1605,17 +1605,17 @@ void WorldObject::SendMessageToSetExcept(WorldPacket *data, Player const* skippe } } -void WorldObject::SendObjectDeSpawnAnim(uint64 guid) +void WorldObject::SendObjectDeSpawnAnim(ObjectGuid guid) { WorldPacket data(SMSG_GAMEOBJECT_DESPAWN_ANIM, 8); - data << uint64(guid); + data << ObjectGuid(guid); SendMessageToSet(&data, true); } -void WorldObject::SendGameObjectCustomAnim(uint64 guid) +void WorldObject::SendGameObjectCustomAnim(ObjectGuid guid) { WorldPacket data(SMSG_GAMEOBJECT_CUSTOM_ANIM, 8+4); - data << uint64(guid); + data << ObjectGuid(guid); data << uint32(0); // not known what this is SendMessageToSet(&data, true); } diff --git a/src/game/Object.h b/src/game/Object.h index a2f583bf584..4559fedfd19 100644 --- a/src/game/Object.h +++ b/src/game/Object.h @@ -546,8 +546,8 @@ class MANGOS_DLL_SPEC WorldObject : public Object void PlayDistanceSound(uint32 sound_id, Player* target = NULL); void PlayDirectSound(uint32 sound_id, Player* target = NULL); - void SendObjectDeSpawnAnim(uint64 guid); - void SendGameObjectCustomAnim(uint64 guid); + void SendObjectDeSpawnAnim(ObjectGuid guid); + void SendGameObjectCustomAnim(ObjectGuid guid); virtual bool IsHostileTo(Unit const* unit) const =0; virtual bool IsFriendlyTo(Unit const* unit) const =0; diff --git a/src/game/Pet.cpp b/src/game/Pet.cpp index 3ce0afa4c4d..d3d10315e02 100644 --- a/src/game/Pet.cpp +++ b/src/game/Pet.cpp @@ -1145,7 +1145,7 @@ void Pet::_LoadSpellCooldowns() time_t curTime = time(NULL); WorldPacket data(SMSG_SPELL_COOLDOWN, (8+1+size_t(result->GetRowCount())*8)); - data << GetGUID(); + data << ObjectGuid(GetObjectGuid()); data << uint8(0x0); // flags (0x1, 0x2) do diff --git a/src/game/PetAI.cpp b/src/game/PetAI.cpp index 5692eaf0bba..ddceb57621f 100644 --- a/src/game/PetAI.cpp +++ b/src/game/PetAI.cpp @@ -335,14 +335,14 @@ void PetAI::UpdateAllies() { for (GroupReference *itr = pGroup->GetFirstMember(); itr != NULL; itr = itr->next()) { - Player* Target = itr->getSource(); - if (!Target || !pGroup->SameSubGroup((Player*)owner, Target)) + Player* target = itr->getSource(); + if (!target || !pGroup->SameSubGroup((Player*)owner, target)) continue; - if (Target->GetGUID() == owner->GetGUID()) + if (target->GetObjectGuid() == owner->GetObjectGuid()) continue; - m_AllySet.insert(Target->GetObjectGuid()); + m_AllySet.insert(target->GetObjectGuid()); } } else //remove group diff --git a/src/game/Player.cpp b/src/game/Player.cpp index e6f1e3ac4b2..5f164e8d11d 100644 --- a/src/game/Player.cpp +++ b/src/game/Player.cpp @@ -4649,7 +4649,7 @@ void Player::SpawnCorpseBones() Corpse* Player::GetCorpse() const { - return sObjectAccessor.GetCorpseForPlayerGUID(GetGUID()); + return sObjectAccessor.GetCorpseForPlayerGUID(GetObjectGuid()); } void Player::DurabilityLossAll(double percent, bool inventory) @@ -8700,7 +8700,7 @@ void Player::SendPetSkillWipeConfirm() if(!pet) return; WorldPacket data(SMSG_PET_UNLEARN_CONFIRM, (8+4)); - data << pet->GetGUID(); + data << ObjectGuid(pet->GetObjectGuid()); data << uint32(pet->resetTalentsCost()); GetSession()->SendPacket( &data ); } @@ -13042,7 +13042,7 @@ void Player::PrepareGossipMenu(WorldObject *pSource, uint32 menuId) if (canTalkToCredit) { if (pSource->HasFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP)) - TalkedToCreature(pSource->GetEntry(), pSource->GetGUID()); + TalkedToCreature(pSource->GetEntry(), pSource->GetObjectGuid()); } // some gossips aren't handled in normal way ... so we need to do it this way .. TODO: handle it in normal way ;-) @@ -13094,7 +13094,7 @@ void Player::SendPreparedGossip(WorldObject *pSource) if (uint32 menuId = PlayerTalkClass->GetGossipMenu().GetMenuId()) textId = GetGossipTextId(menuId); - PlayerTalkClass->SendGossipMenu(textId, pSource->GetGUID()); + PlayerTalkClass->SendGossipMenu(textId, pSource->GetObjectGuid()); } void Player::OnGossipSelect(WorldObject* pSource, uint32 gossipListId, uint32 menuId) @@ -13150,7 +13150,7 @@ void Player::OnGossipSelect(WorldObject* pSource, uint32 gossipListId, uint32 me else if (pMenuData.m_gAction_menu < 0) { PlayerTalkClass->CloseGossip(); - TalkedToCreature(pSource->GetEntry(), pSource->GetGUID()); + TalkedToCreature(pSource->GetEntry(), pSource->GetObjectGuid()); } if (pMenuData.m_gAction_script) @@ -13165,7 +13165,7 @@ void Player::OnGossipSelect(WorldObject* pSource, uint32 gossipListId, uint32 me } case GOSSIP_OPTION_SPIRITHEALER: if (isDead()) - ((Creature*)pSource)->CastSpell(((Creature*)pSource),17251,true,NULL,NULL,GetGUID()); + ((Creature*)pSource)->CastSpell(((Creature*)pSource), 17251, true, NULL, NULL, GetObjectGuid()); break; case GOSSIP_OPTION_QUESTGIVER: PrepareQuestMenu(guid); @@ -16994,7 +16994,7 @@ void Player::ConvertInstancesToGroup(Player *player, Group *group, ObjectGuid pl if (player) { - player_guid = player->GetGUID(); + player_guid = player->GetObjectGuid(); if (!group) group = player->GetGroup(); } @@ -18681,7 +18681,7 @@ void Player::HandleStealthedUnitsDetection() { if(!hasAtClient) { - ObjectGuid i_guid = (*i)->GetGUID(); + ObjectGuid i_guid = (*i)->GetObjectGuid(); (*i)->SendCreateUpdateToPlayer(this); m_clientGUIDs.insert(i_guid); @@ -18698,7 +18698,7 @@ void Player::HandleStealthedUnitsDetection() if(hasAtClient) { (*i)->DestroyForPlayer(this); - m_clientGUIDs.erase((*i)->GetGUID()); + m_clientGUIDs.erase((*i)->GetObjectGuid()); } } } @@ -19914,7 +19914,7 @@ template<> inline void UpdateVisibilityOf_helper(ObjectGuidSet& s64, GameObject* target) { if(!target->IsTransport()) - s64.insert(target->GetGUID()); + s64.insert(target->GetObjectGuid()); } template @@ -20208,7 +20208,7 @@ void Player::ApplyEquipCooldown( Item * pItem ) AddSpellCooldown(spellData.SpellId, pItem->GetEntry(), time(NULL) + 30); WorldPacket data(SMSG_ITEM_COOLDOWN, 12); - data << pItem->GetGUID(); + data << ObjectGuid(pItem->GetObjectGuid()); data << uint32(spellData.SpellId); GetSession()->SendPacket(&data); } diff --git a/src/game/Player.h b/src/game/Player.h index b2193e2a6f8..0e0d38cb2b0 100644 --- a/src/game/Player.h +++ b/src/game/Player.h @@ -2220,7 +2220,7 @@ class MANGOS_DLL_SPEC Player : public Unit // currently visible objects at player client ObjectGuidSet m_clientGUIDs; - bool HaveAtClient(WorldObject const* u) { return u==this || m_clientGUIDs.find(u->GetGUID())!=m_clientGUIDs.end(); } + bool HaveAtClient(WorldObject const* u) { return u==this || m_clientGUIDs.find(u->GetObjectGuid())!=m_clientGUIDs.end(); } bool IsVisibleInGridForPlayer(Player* pl) const; bool IsVisibleGloballyFor(Player* pl) const; diff --git a/src/game/Spell.cpp b/src/game/Spell.cpp index b90911135fc..9fcdf16513c 100644 --- a/src/game/Spell.cpp +++ b/src/game/Spell.cpp @@ -134,7 +134,7 @@ void SpellCastTargets::setUnitTarget(Unit *target) m_destY = target->GetPositionY(); m_destZ = target->GetPositionZ(); m_unitTarget = target; - m_unitTargetGUID = target->GetGUID(); + m_unitTargetGUID = target->GetObjectGuid(); m_targetMask |= TARGET_FLAG_UNIT; } @@ -157,7 +157,7 @@ void SpellCastTargets::setSource(float x, float y, float z) void SpellCastTargets::setGOTarget(GameObject *target) { m_GOTarget = target; - m_GOTargetGUID = target->GetGUID(); + m_GOTargetGUID = target->GetObjectGuid(); // m_targetMask |= TARGET_FLAG_OBJECT; } @@ -167,7 +167,7 @@ void SpellCastTargets::setItemTarget(Item* item) return; m_itemTarget = item; - m_itemTargetGUID = item->GetGUID(); + m_itemTargetGUID = item->GetObjectGuid(); m_itemTargetEntry = item->GetEntry(); m_targetMask |= TARGET_FLAG_ITEM; } @@ -183,7 +183,7 @@ void SpellCastTargets::setTradeItemTarget(Player* caster) void SpellCastTargets::setCorpseTarget(Corpse* corpse) { - m_CorpseTargetGUID = corpse->GetGUID(); + m_CorpseTargetGUID = corpse->GetObjectGuid(); } void SpellCastTargets::Update(Unit* caster) @@ -222,7 +222,7 @@ void SpellCastTargets::read( ByteBuffer& data, Unit *caster ) m_destY = caster->GetPositionY(); m_destZ = caster->GetPositionZ(); m_unitTarget = caster; - m_unitTargetGUID = caster->GetGUID(); + m_unitTargetGUID = caster->GetObjectGuid(); return; } @@ -5321,7 +5321,7 @@ SpellCastResult Spell::CheckCast(bool strict) if (m_caster->GetTypeId() == TYPEID_PLAYER && m_caster->getClass() == CLASS_WARLOCK) { if (strict) //Summoning Disorientation, trigger pet stun (cast by pet so it doesn't attack player) - pet->CastSpell(pet, 32752, true, NULL, NULL, pet->GetGUID()); + pet->CastSpell(pet, 32752, true, NULL, NULL, pet->GetObjectGuid()); } else return SPELL_FAILED_ALREADY_HAVE_SUMMON; diff --git a/src/game/SpellAuras.cpp b/src/game/SpellAuras.cpp index 6e3579d549e..264de682fb7 100644 --- a/src/game/SpellAuras.cpp +++ b/src/game/SpellAuras.cpp @@ -1839,7 +1839,7 @@ void Aura::TriggerSpell() } case 53563: // Beacon of Light // original caster must be target (beacon) - target->CastSpell(target, trigger_spell_id, true, NULL, this, target->GetGUID()); + target->CastSpell(target, trigger_spell_id, true, NULL, this, target->GetObjectGuid()); return; case 56654: // Rapid Recuperation (triggered energize have baspioints == 0) case 58882: diff --git a/src/game/SpellEffects.cpp b/src/game/SpellEffects.cpp index 6fc83dd0704..870e572c00e 100644 --- a/src/game/SpellEffects.cpp +++ b/src/game/SpellEffects.cpp @@ -3097,10 +3097,10 @@ void Spell::EffectDummy(SpellEffectIndex eff_idx) default: return; } - totem->CastSpell(totem, triggered_spell_id, true, NULL, NULL, m_caster->GetGUID()); + totem->CastSpell(totem, triggered_spell_id, true, NULL, NULL, m_caster->GetObjectGuid()); // Fire Nova Visual - totem->CastSpell(totem, 19823, true, NULL, NULL, m_caster->GetGUID()); + totem->CastSpell(totem, 19823, true, NULL, NULL, m_caster->GetObjectGuid()); return; } break; @@ -3919,7 +3919,7 @@ void Spell::EffectHeal(SpellEffectIndex /*eff_idx*/) if (unitTarget == m_targets.getUnitTarget()) { // check for Riptide - Aura* riptide = unitTarget->GetAura(SPELL_AURA_PERIODIC_HEAL, SPELLFAMILY_SHAMAN, UI64LIT(0x0), 0x00000010, caster->GetGUID()); + Aura* riptide = unitTarget->GetAura(SPELL_AURA_PERIODIC_HEAL, SPELLFAMILY_SHAMAN, UI64LIT(0x0), 0x00000010, caster->GetObjectGuid()); if (riptide) { addhealth += addhealth/4; @@ -7483,7 +7483,7 @@ void Spell::EffectScriptEffect(SpellEffectIndex eff_idx) { if (roll_chance_i((*i)->GetModifier()->m_amount)) { - unitTarget->CastSpell(unitTarget, 53398, true, NULL, (*i), m_caster->GetGUID()); + unitTarget->CastSpell(unitTarget, 53398, true, NULL, (*i), m_caster->GetObjectGuid()); break; } } @@ -8765,7 +8765,7 @@ void Spell::EffectProspecting(SpellEffectIndex /*eff_idx*/) p_caster->UpdateGatherSkill(SKILL_JEWELCRAFTING, SkillValue, reqSkillValue); } - ((Player*)m_caster)->SendLoot(itemTarget->GetGUID(), LOOT_PROSPECTING); + ((Player*)m_caster)->SendLoot(itemTarget->GetObjectGuid(), LOOT_PROSPECTING); } void Spell::EffectMilling(SpellEffectIndex /*eff_idx*/) diff --git a/src/game/TaxiHandler.cpp b/src/game/TaxiHandler.cpp index a96f9f963ec..bfcd0d0c262 100644 --- a/src/game/TaxiHandler.cpp +++ b/src/game/TaxiHandler.cpp @@ -132,18 +132,18 @@ bool WorldSession::SendLearnNewTaxiNode( Creature* unit ) // find current node uint32 curloc = sObjectMgr.GetNearestTaxiNode(unit->GetPositionX(),unit->GetPositionY(),unit->GetPositionZ(),unit->GetMapId(),GetPlayer( )->GetTeam()); - if ( curloc == 0 ) + if (curloc == 0) return true; // `true` send to avoid WorldSession::SendTaxiMenu call with one more curlock seartch with same false result. - if( GetPlayer()->m_taxi.SetTaximaskNode(curloc) ) + if (GetPlayer()->m_taxi.SetTaximaskNode(curloc)) { WorldPacket msg(SMSG_NEW_TAXI_PATH, 0); - SendPacket( &msg ); + SendPacket(&msg); - WorldPacket update( SMSG_TAXINODE_STATUS, 9 ); - update << uint64( unit->GetGUID() ); - update << uint8( 1 ); - SendPacket( &update ); + WorldPacket update(SMSG_TAXINODE_STATUS, 9); + update << ObjectGuid(unit->GetObjectGuid()); + update << uint8(1); + SendPacket(&update); return true; } diff --git a/src/game/ThreatManager.cpp b/src/game/ThreatManager.cpp index a1950811e1c..71e1a56a845 100644 --- a/src/game/ThreatManager.cpp +++ b/src/game/ThreatManager.cpp @@ -61,7 +61,7 @@ HostileReference::HostileReference(Unit* pUnit, ThreatManager *pThreatManager, f iThreat = pThreat; iTempThreatModifyer = 0.0f; link(pUnit, pThreatManager); - iUnitGuid = pUnit->GetGUID(); + iUnitGuid = pUnit->GetObjectGuid(); iOnline = true; iAccessible = true; } @@ -128,10 +128,9 @@ void HostileReference::updateOnlineStatus() bool online = false; bool accessible = false; - if(!isValid()) + if (!isValid()) { - Unit* target = ObjectAccessor::GetUnit(*getSourceUnit(), getUnitGuid()); - if(target) + if (Unit* target = ObjectAccessor::GetUnit(*getSourceUnit(), getUnitGuid())) link(target, getSource()); } // only check for online status if @@ -224,10 +223,10 @@ void ThreatContainer::clearReferences() HostileReference* ThreatContainer::getReferenceByTarget(Unit* pVictim) { HostileReference* result = NULL; - uint64 guid = pVictim->GetGUID(); + ObjectGuid guid = pVictim->GetObjectGuid(); for(ThreatList::const_iterator i = iThreatList.begin(); i != iThreatList.end(); ++i) { - if((*i)->getUnitGuid() == guid) + if ((*i)->getUnitGuid() == guid) { result = (*i); break; diff --git a/src/game/ThreatManager.h b/src/game/ThreatManager.h index 09b1ed5f515..6159435b5d0 100644 --- a/src/game/ThreatManager.h +++ b/src/game/ThreatManager.h @@ -24,6 +24,7 @@ #include "Utilities/LinkedReference/Reference.h" #include "UnitEvents.h" #include "Timer.h" +#include "ObjectGuid.h" #include //============================================================== @@ -92,7 +93,7 @@ class MANGOS_DLL_SPEC HostileReference : public Reference //================================================= - uint64 getUnitGuid() const { return iUnitGuid; } + ObjectGuid const& getUnitGuid() const { return iUnitGuid; } //================================================= // reference is not needed anymore. realy delete it ! @@ -121,7 +122,7 @@ class MANGOS_DLL_SPEC HostileReference : public Reference private: float iThreat; float iTempThreatModifyer; // used for taunt - uint64 iUnitGuid; + ObjectGuid iUnitGuid; bool iOnline; bool iAccessible; }; diff --git a/src/game/TradeHandler.cpp b/src/game/TradeHandler.cpp index bad34e974c4..3bbe151ed89 100644 --- a/src/game/TradeHandler.cpp +++ b/src/game/TradeHandler.cpp @@ -620,8 +620,8 @@ void WorldSession::HandleInitiateTradeOpcode(WorldPacket& recvPacket) pOther->m_trade = new TradeData(pOther, _player); WorldPacket data(SMSG_TRADE_STATUS, 12); - data << (uint32) TRADE_STATUS_BEGIN_TRADE; - data << (uint64)_player->GetGUID(); + data << uint32(TRADE_STATUS_BEGIN_TRADE); + data << ObjectGuid(_player->GetObjectGuid()); pOther->GetSession()->SendPacket(&data); } diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp index f87c972fbb2..f3e968ecef4 100644 --- a/src/game/Unit.cpp +++ b/src/game/Unit.cpp @@ -3745,7 +3745,7 @@ void Unit::SetFacingToObject(WorldObject* pObject) // TODO: figure out under what conditions creature will move towards object instead of facing it where it currently is. SetOrientation(GetAngle(pObject)); - SendMonsterMove(GetPositionX(), GetPositionY(), GetPositionZ(), SPLINETYPE_FACINGTARGET, ((Creature*)this)->GetSplineFlags(), 0, NULL, pObject->GetGUID()); + SendMonsterMove(GetPositionX(), GetPositionY(), GetPositionZ(), SPLINETYPE_FACINGTARGET, ((Creature*)this)->GetSplineFlags(), 0, NULL, pObject->GetObjectGuid().GetRawValue()); } bool Unit::isInAccessablePlaceFor(Creature const* c) const @@ -4747,8 +4747,11 @@ void Unit::RemoveSpellAuraHolder(SpellAuraHolder *holder, AuraRemoveMode mode) else delete holder; - if (mode != AURA_REMOVE_BY_EXPIRE && IsChanneledSpell(AurSpellInfo) && !IsAreaOfEffectSpell(AurSpellInfo) && caster && caster->GetGUID() != GetGUID()) + if (mode != AURA_REMOVE_BY_EXPIRE && IsChanneledSpell(AurSpellInfo) && !IsAreaOfEffectSpell(AurSpellInfo) && + caster && caster->GetObjectGuid() != GetObjectGuid()) + { caster->InterruptSpell(CURRENT_CHANNELED_SPELL); + } } void Unit::RemoveSingleAuraFromSpellAuraHolder(SpellAuraHolder *holder, SpellEffectIndex index, AuraRemoveMode mode) @@ -4925,7 +4928,7 @@ bool Unit::HasAura(uint32 spellId, SpellEffectIndex effIndex) const void Unit::AddDynObject(DynamicObject* dynObj) { - m_dynObjGUIDs.push_back(dynObj->GetGUID()); + m_dynObjGUIDs.push_back(dynObj->GetObjectGuid()); } void Unit::RemoveDynObject(uint32 spellid) @@ -4953,8 +4956,7 @@ void Unit::RemoveAllDynObjects() { while(!m_dynObjGUIDs.empty()) { - DynamicObject* dynObj = GetMap()->GetDynamicObject(*m_dynObjGUIDs.begin()); - if(dynObj) + if (DynamicObject* dynObj = GetMap()->GetDynamicObject(*m_dynObjGUIDs.begin())) dynObj->Delete(); m_dynObjGUIDs.erase(m_dynObjGUIDs.begin()); } @@ -5325,15 +5327,12 @@ FactionTemplateEntry const* Unit::getFactionTemplateEntry() const FactionTemplateEntry const* entry = sFactionTemplateStore.LookupEntry(getFaction()); if(!entry) { - static uint64 guid = 0; // prevent repeating spam same faction problem + static ObjectGuid guid; // prevent repeating spam same faction problem - if(GetGUID() != guid) + if (GetObjectGuid() != guid) { - if(GetTypeId() == TYPEID_PLAYER) - sLog.outError("Player %s have invalid faction (faction template id) #%u", ((Player*)this)->GetName(), getFaction()); - else - sLog.outError("Creature (template id: %u) have invalid faction (faction template id) #%u", ((Creature*)this)->GetCreatureInfo()->Entry, getFaction()); - guid = GetGUID(); + sLog.outError("%s have invalid faction (faction template id) #%u", GetGuidStr().c_str(), getFaction()); + guid = GetObjectGuid(); } } return entry; @@ -5955,30 +5954,29 @@ void Unit::SetCharm(Unit* pet) void Unit::AddGuardian( Pet* pet ) { - m_guardianPets.insert(pet->GetGUID()); + m_guardianPets.insert(pet->GetObjectGuid()); } void Unit::RemoveGuardian( Pet* pet ) { - m_guardianPets.erase(pet->GetGUID()); + m_guardianPets.erase(pet->GetObjectGuid()); } void Unit::RemoveGuardians() { - while(!m_guardianPets.empty()) + while (!m_guardianPets.empty()) { - uint64 guid = *m_guardianPets.begin(); - if(Pet* pet = GetMap()->GetPet(guid)) + if (Pet* pet = GetMap()->GetPet(*m_guardianPets.begin())) pet->Unsummon(PET_SAVE_AS_DELETED, this); - m_guardianPets.erase(guid); + m_guardianPets.erase(m_guardianPets.begin()); } } Pet* Unit::FindGuardianWithEntry(uint32 entry) { - for(GuardianPetList::const_iterator itr = m_guardianPets.begin(); itr != m_guardianPets.end(); ++itr) - if(Pet* pet = GetMap()->GetPet(*itr)) + for (GuardianPetList::const_iterator itr = m_guardianPets.begin(); itr != m_guardianPets.end(); ++itr) + if (Pet* pet = GetMap()->GetPet(*itr)) if (pet->GetEntry() == entry) return pet; @@ -5987,8 +5985,8 @@ Pet* Unit::FindGuardianWithEntry(uint32 entry) Pet* Unit::GetProtectorPet() { - for(GuardianPetList::const_iterator itr = m_guardianPets.begin(); itr != m_guardianPets.end(); ++itr) - if(Pet* pet = GetMap()->GetPet(*itr)) + for (GuardianPetList::const_iterator itr = m_guardianPets.begin(); itr != m_guardianPets.end(); ++itr) + if (Pet* pet = GetMap()->GetPet(*itr)) if (pet->getPetType() == PROTECTOR_PET) return pet; @@ -6354,7 +6352,7 @@ uint32 Unit::SpellDamageBonusDone(Unit *pVictim, SpellEntry const *spellProto, u // Twisted Faith case 7377: { - if (pVictim->GetAura(SPELL_AURA_PERIODIC_DAMAGE, SPELLFAMILY_PRIEST, UI64LIT(0x0000000000008000), 0, GetGUID())) + if (pVictim->GetAura(SPELL_AURA_PERIODIC_DAMAGE, SPELLFAMILY_PRIEST, UI64LIT(0x0000000000008000), 0, GetObjectGuid())) DoneTotalMod *= ((*i)->GetModifier()->m_amount+100.0f)/100.0f; break; } @@ -6438,7 +6436,7 @@ uint32 Unit::SpellDamageBonusDone(Unit *pVictim, SpellEntry const *spellProto, u if (spellProto->SpellFamilyFlags & UI64LIT(0x0000000000000001)) { // if Insect Swarm on target - if (pVictim->GetAura(SPELL_AURA_PERIODIC_DAMAGE, SPELLFAMILY_DRUID, UI64LIT(0x000000000200000), 0, GetGUID())) + if (pVictim->GetAura(SPELL_AURA_PERIODIC_DAMAGE, SPELLFAMILY_DRUID, UI64LIT(0x000000000200000), 0, GetObjectGuid())) { Unit::AuraList const& improvedSwarm = GetAurasByType(SPELL_AURA_DUMMY); for(Unit::AuraList::const_iterator iter = improvedSwarm.begin(); iter != improvedSwarm.end(); ++iter) @@ -6730,7 +6728,7 @@ bool Unit::IsSpellCrit(Unit *pVictim, SpellEntry const *spellProto, SpellSchoolM if (spellProto->SpellFamilyFlags & UI64LIT(0x0000000000000004)) { // search for Moonfire on target - if (pVictim->GetAura(SPELL_AURA_PERIODIC_DAMAGE, SPELLFAMILY_DRUID, UI64LIT(0x000000000000002), 0, GetGUID())) + if (pVictim->GetAura(SPELL_AURA_PERIODIC_DAMAGE, SPELLFAMILY_DRUID, UI64LIT(0x000000000000002), 0, GetObjectGuid())) { Unit::AuraList const& improvedSwarm = GetAurasByType(SPELL_AURA_DUMMY); for(Unit::AuraList::const_iterator iter = improvedSwarm.begin(); iter != improvedSwarm.end(); ++iter) @@ -6764,7 +6762,7 @@ bool Unit::IsSpellCrit(Unit *pVictim, SpellEntry const *spellProto, SpellSchoolM if (spellProto->SpellFamilyFlags & UI64LIT(0x0000100000000000)) { // Flame Shock - if (pVictim->GetAura(SPELL_AURA_PERIODIC_DAMAGE, SPELLFAMILY_SHAMAN, UI64LIT(0x0000000010000000), 0, GetGUID())) + if (pVictim->GetAura(SPELL_AURA_PERIODIC_DAMAGE, SPELLFAMILY_SHAMAN, UI64LIT(0x0000000010000000), 0, GetObjectGuid())) return true; } break; @@ -6947,7 +6945,7 @@ uint32 Unit::SpellHealingBonusDone(Unit *pVictim, SpellEntry const *spellProto, } case 7871: // Glyph of Lesser Healing Wave { - if (pVictim->GetAura(SPELL_AURA_DUMMY, SPELLFAMILY_SHAMAN, UI64LIT(0x0000040000000000), 0, GetGUID())) + if (pVictim->GetAura(SPELL_AURA_DUMMY, SPELLFAMILY_SHAMAN, UI64LIT(0x0000040000000000), 0, GetObjectGuid())) DoneTotalMod *= ((*i)->GetModifier()->m_amount+100.0f)/100.0f; break; } @@ -10608,7 +10606,7 @@ void Unit::SendThreatUpdate() data << uint32(count); for (ThreatList::const_iterator itr = tlist.begin(); itr != tlist.end(); ++itr) { - data.appendPackGUID((*itr)->getUnitGuid()); + data << (*itr)->getUnitGuid().WriteAsPacked(); data << uint32((*itr)->getThreat()); } SendMessageToSet(&data, false); @@ -10623,11 +10621,11 @@ void Unit::SendHighestThreatUpdate(HostileReference* pHostilReference) DEBUG_FILTER_LOG(LOG_FILTER_COMBAT, "WORLD: Send SMSG_HIGHEST_THREAT_UPDATE Message"); WorldPacket data(SMSG_HIGHEST_THREAT_UPDATE, 8 + 8 + count * 8); data << GetPackGUID(); - data.appendPackGUID(pHostilReference->getUnitGuid()); + data << pHostilReference->getUnitGuid().WriteAsPacked(); data << uint32(count); for (ThreatList::const_iterator itr = tlist.begin(); itr != tlist.end(); ++itr) { - data.appendPackGUID((*itr)->getUnitGuid()); + data << (*itr)->getUnitGuid().WriteAsPacked(); data << uint32((*itr)->getThreat()); } SendMessageToSet(&data, false); @@ -10647,7 +10645,7 @@ void Unit::SendThreatRemove(HostileReference* pHostileReference) DEBUG_FILTER_LOG(LOG_FILTER_COMBAT, "WORLD: Send SMSG_THREAT_REMOVE Message"); WorldPacket data(SMSG_THREAT_REMOVE, 8 + 8); data << GetPackGUID(); - data.appendPackGUID(pHostileReference->getUnitGuid()); + data << pHostileReference->getUnitGuid().WriteAsPacked(); SendMessageToSet(&data, false); } diff --git a/src/game/Unit.h b/src/game/Unit.h index 93e784a6485..d7214c54ef1 100644 --- a/src/game/Unit.h +++ b/src/game/Unit.h @@ -1106,7 +1106,7 @@ enum IgnoreUnitState IGNORE_UNIT_TARGET_NON_FROZEN = 126, // ignore absent of frozen state }; -typedef std::set GuardianPetList; +typedef std::set GuardianPetList; // delay time next attack to prevent client attack animation problems #define ATTACK_DISPLAY_DELAY 200 @@ -1801,7 +1801,7 @@ class MANGOS_DLL_SPEC Unit : public WorldObject DynamicObject* GetDynObject(uint32 spellId); void AddDynObject(DynamicObject* dynObj); void RemoveDynObject(uint32 spellid); - void RemoveDynObjectWithGUID(uint64 guid) { m_dynObjGUIDs.remove(guid); } + void RemoveDynObjectWithGUID(ObjectGuid guid) { m_dynObjGUIDs.remove(guid); } void RemoveAllDynObjects(); GameObject* GetGameObject(uint32 spellId) const; @@ -1982,7 +1982,7 @@ class MANGOS_DLL_SPEC Unit : public WorldObject SingleCastSpellTargetMap m_singleCastSpellTargets; // casted by unit single per-caster auras - typedef std::list DynObjectGUIDs; + typedef std::list DynObjectGUIDs; DynObjectGUIDs m_dynObjGUIDs; typedef std::list GameObjectList; diff --git a/src/game/UnitAuraProcHandler.cpp b/src/game/UnitAuraProcHandler.cpp index 21117bd37bc..e2e38d9dda7 100644 --- a/src/game/UnitAuraProcHandler.cpp +++ b/src/game/UnitAuraProcHandler.cpp @@ -1361,7 +1361,7 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit *pVictim, uint32 damage, Aura return SPELL_AURA_PROC_FAILED; // Renew - Aura* healingAura = pVictim->GetAura(SPELL_AURA_PERIODIC_HEAL, SPELLFAMILY_PRIEST, UI64LIT(0x40), 0, GetGUID()); + Aura* healingAura = pVictim->GetAura(SPELL_AURA_PERIODIC_HEAL, SPELLFAMILY_PRIEST, UI64LIT(0x40), 0, GetObjectGuid()); if (!healingAura) return SPELL_AURA_PROC_FAILED; @@ -1377,7 +1377,7 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit *pVictim, uint32 damage, Aura if (!procSpell) return SPELL_AURA_PROC_FAILED; - Aura* leachAura = pVictim->GetAura(SPELL_AURA_PERIODIC_LEECH, SPELLFAMILY_PRIEST, UI64LIT(0x02000000), 0, GetGUID()); + Aura* leachAura = pVictim->GetAura(SPELL_AURA_PERIODIC_LEECH, SPELLFAMILY_PRIEST, UI64LIT(0x02000000), 0, GetObjectGuid()); if (!leachAura) return SPELL_AURA_PROC_FAILED; @@ -1595,7 +1595,7 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit *pVictim, uint32 damage, Aura if (!second) return SPELL_AURA_PROC_FAILED; - pVictim->CastSpell(second, procSpell, true, NULL, triggeredByAura, GetGUID()); + pVictim->CastSpell(second, procSpell, true, NULL, triggeredByAura, GetObjectGuid()); return SPELL_AURA_PROC_OK; } } @@ -1790,7 +1790,7 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit *pVictim, uint32 damage, Aura // Glyph of Mend Pet if(dummySpell->Id == 57870) { - pVictim->CastSpell(pVictim, 57894, true, NULL, NULL, GetGUID()); + pVictim->CastSpell(pVictim, 57894, true, NULL, NULL, GetObjectGuid()); return SPELL_AURA_PROC_OK; } // Misdirection @@ -2027,7 +2027,7 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit *pVictim, uint32 damage, Aura basepoints[0] = triggeredByAura->GetModifier()->m_amount*damage/100; // cast with original caster set but beacon to beacon for apply caster mods and avoid LoS check - beacon->CastCustomSpell(beacon,triggered_spell_id,&basepoints[0],NULL,NULL,true,castItem,triggeredByAura,pVictim->GetGUID()); + beacon->CastCustomSpell(beacon,triggered_spell_id,&basepoints[0],NULL,NULL,true,castItem,triggeredByAura,pVictim->GetObjectGuid()); return SPELL_AURA_PROC_OK; } // Seal of Corruption (damage calc on apply aura) diff --git a/src/game/World.cpp b/src/game/World.cpp index 785c2607fc6..ca8750c78d3 100644 --- a/src/game/World.cpp +++ b/src/game/World.cpp @@ -1638,7 +1638,7 @@ void World::SendGlobalText(const char* text, WorldSession *self) while(char* line = ChatHandler::LineFromMessage(pos)) { - ChatHandler::FillMessageData(&data, NULL, CHAT_MSG_SYSTEM, LANG_UNIVERSAL, NULL, 0, line, NULL); + ChatHandler::FillMessageData(&data, NULL, CHAT_MSG_SYSTEM, LANG_UNIVERSAL, line); SendGlobalMessage(&data, self); } @@ -1667,7 +1667,7 @@ void World::SendZoneMessage(uint32 zone, WorldPacket *packet, WorldSession *self void World::SendZoneText(uint32 zone, const char* text, WorldSession *self, uint32 team) { WorldPacket data; - ChatHandler::FillMessageData(&data, NULL, CHAT_MSG_SYSTEM, LANG_UNIVERSAL, NULL, 0, text, NULL); + ChatHandler::FillMessageData(&data, NULL, CHAT_MSG_SYSTEM, LANG_UNIVERSAL, text); SendZoneMessage(zone, &data, self,team); } diff --git a/src/game/WorldSession.cpp b/src/game/WorldSession.cpp index cd730a462eb..b30e480cf9f 100644 --- a/src/game/WorldSession.cpp +++ b/src/game/WorldSession.cpp @@ -436,7 +436,7 @@ void WorldSession::LogoutPlayer(bool Save) slot->UpdateLogoutTime(); } - guild->BroadcastEvent(GE_SIGNED_OFF, _player->GetGUID(), _player->GetName()); + guild->BroadcastEvent(GE_SIGNED_OFF, _player->GetObjectGuid(), _player->GetName()); } ///- Remove pet diff --git a/src/game/debugcmds.cpp b/src/game/debugcmds.cpp index 13b62c60006..6dc70dff585 100644 --- a/src/game/debugcmds.cpp +++ b/src/game/debugcmds.cpp @@ -306,7 +306,7 @@ bool ChatHandler::HandleDebugSendChatMsgCommand(char* args) return false; WorldPacket data; - ChatHandler::FillMessageData(&data, m_session, type, 0, "chan", m_session->GetPlayer()->GetGUID(), msg, m_session->GetPlayer()); + ChatHandler::FillMessageData(&data, m_session, type, 0, "chan", m_session->GetPlayer()->GetObjectGuid(), msg, m_session->GetPlayer()); m_session->SendPacket(&data); return true; } @@ -528,7 +528,7 @@ bool ChatHandler::HandleDebugGetItemStateCommand(char* args) error = true; continue; } - if (item2->GetOwnerGuid() != player->GetGUID()) + if (item2->GetOwnerGuid() != player->GetObjectGuid()) { PSendSysMessage("%s in bag %u at slot %u owner (%s) and inventory owner (%s) don't match!", item2->GetGuidStr().c_str(), bag->GetSlot(), item2->GetSlot(), diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index 4fa715c3bda..b2ccb7a645f 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 "11464" + #define REVISION_NR "11465" #endif // __REVISION_NR_H__ From dafa051ca50120fae4b6b2d53b18dfa399464f5a Mon Sep 17 00:00:00 2001 From: VladimirMangos Date: Tue, 10 May 2011 21:58:20 +0400 Subject: [PATCH 33/43] [11466] Use ObjectGuid in Map::m_objectsStore --- src/game/Creature.cpp | 4 ++-- src/game/DynamicObject.cpp | 4 ++-- src/game/GameObject.cpp | 4 ++-- src/game/Map.cpp | 8 ++++---- src/game/Map.h | 5 +++-- src/game/Pet.cpp | 4 ++-- src/shared/revision_nr.h | 2 +- 7 files changed, 16 insertions(+), 15 deletions(-) diff --git a/src/game/Creature.cpp b/src/game/Creature.cpp index f48538b74dc..b8f41d36963 100644 --- a/src/game/Creature.cpp +++ b/src/game/Creature.cpp @@ -191,7 +191,7 @@ void Creature::AddToWorld() { ///- Register the creature for guid lookup if (!IsInWorld() && GetObjectGuid().IsCreatureOrVehicle()) - GetMap()->GetObjectsStore().insert(GetGUID(), (Creature*)this); + GetMap()->GetObjectsStore().insert(GetObjectGuid(), (Creature*)this); Unit::AddToWorld(); } @@ -200,7 +200,7 @@ void Creature::RemoveFromWorld() { ///- Remove the creature from the accessor if (IsInWorld() && GetObjectGuid().IsCreatureOrVehicle()) - GetMap()->GetObjectsStore().erase(GetGUID(), (Creature*)NULL); + GetMap()->GetObjectsStore().erase(GetObjectGuid(), (Creature*)NULL); Unit::RemoveFromWorld(); } diff --git a/src/game/DynamicObject.cpp b/src/game/DynamicObject.cpp index e8701a37744..998e3e21acf 100644 --- a/src/game/DynamicObject.cpp +++ b/src/game/DynamicObject.cpp @@ -41,7 +41,7 @@ void DynamicObject::AddToWorld() { ///- Register the dynamicObject for guid lookup if(!IsInWorld()) - GetMap()->GetObjectsStore().insert(GetGUID(), (DynamicObject*)this); + GetMap()->GetObjectsStore().insert(GetObjectGuid(), (DynamicObject*)this); Object::AddToWorld(); } @@ -51,7 +51,7 @@ void DynamicObject::RemoveFromWorld() ///- Remove the dynamicObject from the accessor if(IsInWorld()) { - GetMap()->GetObjectsStore().erase(GetGUID(), (DynamicObject*)NULL); + GetMap()->GetObjectsStore().erase(GetObjectGuid(), (DynamicObject*)NULL); GetViewPoint().Event_RemovedFromWorld(); } diff --git a/src/game/GameObject.cpp b/src/game/GameObject.cpp index 95fcf22c5bf..ba9e6802a94 100644 --- a/src/game/GameObject.cpp +++ b/src/game/GameObject.cpp @@ -68,7 +68,7 @@ void GameObject::AddToWorld() { ///- Register the gameobject for guid lookup if(!IsInWorld()) - GetMap()->GetObjectsStore().insert(GetGUID(), (GameObject*)this); + GetMap()->GetObjectsStore().insert(GetObjectGuid(), (GameObject*)this); Object::AddToWorld(); } @@ -91,7 +91,7 @@ void GameObject::RemoveFromWorld() } } - GetMap()->GetObjectsStore().erase(GetGUID(), (GameObject*)NULL); + GetMap()->GetObjectsStore().erase(GetObjectGuid(), (GameObject*)NULL); } Object::RemoveFromWorld(); diff --git a/src/game/Map.cpp b/src/game/Map.cpp index a39022bda6f..becdec24bb4 100644 --- a/src/game/Map.cpp +++ b/src/game/Map.cpp @@ -2902,7 +2902,7 @@ Player* Map::GetPlayer(ObjectGuid guid) */ Creature* Map::GetCreature(ObjectGuid guid) { - return m_objectsStore.find(guid.GetRawValue(), (Creature*)NULL); + return m_objectsStore.find(guid, (Creature*)NULL); } /** @@ -2912,7 +2912,7 @@ Creature* Map::GetCreature(ObjectGuid guid) */ Pet* Map::GetPet(ObjectGuid guid) { - return m_objectsStore.find(guid.GetRawValue(), (Pet*)NULL); + return m_objectsStore.find(guid, (Pet*)NULL); } /** @@ -2953,7 +2953,7 @@ Creature* Map::GetAnyTypeCreature(ObjectGuid guid) */ GameObject* Map::GetGameObject(ObjectGuid guid) { - return m_objectsStore.find(guid.GetRawValue(), (GameObject*)NULL); + return m_objectsStore.find(guid, (GameObject*)NULL); } /** @@ -2963,7 +2963,7 @@ GameObject* Map::GetGameObject(ObjectGuid guid) */ DynamicObject* Map::GetDynamicObject(ObjectGuid guid) { - return m_objectsStore.find(guid.GetRawValue(), (DynamicObject*)NULL); + return m_objectsStore.find(guid, (DynamicObject*)NULL); } /** diff --git a/src/game/Map.h b/src/game/Map.h index cddc8683c6b..3dde4d9a946 100644 --- a/src/game/Map.h +++ b/src/game/Map.h @@ -230,7 +230,8 @@ class MANGOS_DLL_SPEC Map : public GridRefManager Unit* GetUnit(ObjectGuid guid); // only use if sure that need objects at current map, specially for player case WorldObject* GetWorldObject(ObjectGuid guid); // only use if sure that need objects at current map, specially for player case - TypeUnorderedMapContainer& GetObjectsStore() { return m_objectsStore; } + typedef TypeUnorderedMapContainer MapStoredObjectTypesContainer; + MapStoredObjectTypesContainer& GetObjectsStore() { return m_objectsStore; } void AddUpdateObject(Object *obj) { @@ -304,7 +305,7 @@ class MANGOS_DLL_SPEC Map : public GridRefManager typedef std::set ActiveNonPlayers; ActiveNonPlayers m_activeNonPlayers; ActiveNonPlayers::iterator m_activeNonPlayersIter; - TypeUnorderedMapContainer m_objectsStore; + MapStoredObjectTypesContainer m_objectsStore; private: time_t i_gridExpiry; diff --git a/src/game/Pet.cpp b/src/game/Pet.cpp index d3d10315e02..4630e6926f3 100644 --- a/src/game/Pet.cpp +++ b/src/game/Pet.cpp @@ -58,7 +58,7 @@ void Pet::AddToWorld() { ///- Register the pet for guid lookup if(!IsInWorld()) - GetMap()->GetObjectsStore().insert(GetGUID(), (Pet*)this); + GetMap()->GetObjectsStore().insert(GetObjectGuid(), (Pet*)this); Unit::AddToWorld(); } @@ -67,7 +67,7 @@ void Pet::RemoveFromWorld() { ///- Remove the pet from the accessor if(IsInWorld()) - GetMap()->GetObjectsStore().erase(GetGUID(), (Pet*)NULL); + GetMap()->GetObjectsStore().erase(GetObjectGuid(), (Pet*)NULL); ///- Don't call the function for Creature, normal mobs + totems go in a different storage Unit::RemoveFromWorld(); diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index b2ccb7a645f..b66210116a4 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 "11465" + #define REVISION_NR "11466" #endif // __REVISION_NR_H__ From 5764de172ff25255721d84c37ebb900d7c0f0ebe Mon Sep 17 00:00:00 2001 From: VladimirMangos Date: Tue, 10 May 2011 22:49:09 +0400 Subject: [PATCH 34/43] [11467] Reorder class Channel sections to default used in mangos --- src/game/Channel.cpp | 6 +-- src/game/Channel.h | 101 ++++++++++++++++++++------------------- src/game/ObjectMgr.h | 4 +- src/shared/revision_nr.h | 2 +- 4 files changed, 58 insertions(+), 55 deletions(-) diff --git a/src/game/Channel.cpp b/src/game/Channel.cpp index 02c90874817..d120ca5432f 100644 --- a/src/game/Channel.cpp +++ b/src/game/Channel.cpp @@ -624,7 +624,7 @@ void Channel::Invite(uint64 p, const char *newname) if(!newp->GetSocial()->HasIgnore(p)) { MakeInvite(&data, p); - SendToOne(&data, newp->GetGUID()); + SendToOne(&data, newp->GetObjectGuid()); data.clear(); } MakePlayerInvited(&data, newp->GetName()); @@ -667,9 +667,9 @@ void Channel::SendToAll(WorldPacket *data, uint64 p) plr->GetSession()->SendPacket(data); } -void Channel::SendToOne(WorldPacket *data, uint64 who) +void Channel::SendToOne(WorldPacket *data, ObjectGuid who) { - if (Player *plr = sObjectMgr.GetPlayer(who)) + if (Player *plr = ObjectMgr::GetPlayer(who)) plr->GetSession()->SendPacket(data); } diff --git a/src/game/Channel.h b/src/game/Channel.h index 353cc229112..b6ac8a34021 100644 --- a/src/game/Channel.h +++ b/src/game/Channel.h @@ -20,6 +20,7 @@ #define _CHANNEL_H #include "Common.h" +#include "ObjectGuid.h" #include "WorldPacket.h" #include "Opcodes.h" #include "Player.h" @@ -145,17 +146,44 @@ class Channel } }; - typedef std::map PlayerList; - PlayerList players; - typedef std::set BannedList; - BannedList banned; - bool m_announce; - bool m_moderate; - std::string m_name; - std::string m_password; - uint8 m_flags; - uint32 m_channelId; - uint64 m_ownerGUID; + public: + Channel(const std::string& name, uint32 channel_id); + std::string GetName() const { return m_name; } + uint32 GetChannelId() const { return m_channelId; } + bool IsConstant() const { return m_channelId != 0; } + bool IsAnnounce() const { return m_announce; } + bool IsLFG() const { return GetFlags() & CHANNEL_FLAG_LFG; } + std::string GetPassword() const { return m_password; } + void SetPassword(const std::string& npassword) { m_password = npassword; } + void SetAnnounce(bool nannounce) { m_announce = nannounce; } + uint32 GetNumPlayers() const { return players.size(); } + uint8 GetFlags() const { return m_flags; } + bool HasFlag(uint8 flag) { return m_flags & flag; } + + void Join(uint64 p, const char *pass); + void Leave(uint64 p, bool send = true); + void KickOrBan(uint64 good, const char *badname, bool ban); + void Kick(uint64 good, const char *badname) { KickOrBan(good, badname, false); } + void Ban(uint64 good, const char *badname) { KickOrBan(good, badname, true); } + void UnBan(uint64 good, const char *badname); + void Password(uint64 p, const char *pass); + void SetMode(uint64 p, const char *p2n, bool mod, bool set); + void SetOwner(uint64 p, bool exclaim = true); + void SetOwner(uint64 p, const char *newname); + void SendWhoOwner(uint64 p); + void SetModerator(uint64 p, const char *newname) { SetMode(p, newname, true, true); } + void UnsetModerator(uint64 p, const char *newname) { SetMode(p, newname, true, false); } + void SetMute(uint64 p, const char *newname) { SetMode(p, newname, false, true); } + void UnsetMute(uint64 p, const char *newname) { SetMode(p, newname, false, false); } + void List(Player* p); + void Announce(uint64 p); + void Moderate(uint64 p); + void Say(uint64 p, const char *what, uint32 lang); + void Invite(uint64 p, const char *newp); + void Voice(uint64 guid1, uint64 guid2); + void DeVoice(uint64 guid1, uint64 guid2); + void JoinNotify(uint64 guid); // invisible notify + void LeaveNotify(uint64 guid); // invisible notify private: // initial packet data (notify type and channel name) @@ -199,7 +227,7 @@ class Channel void MakeVoiceOff(WorldPacket *data, uint64 guid); //+ 0x23 void SendToAll(WorldPacket *data, uint64 p = 0); - void SendToOne(WorldPacket *data, uint64 who); + void SendToOne(WorldPacket *data, ObjectGuid who); bool IsOn(uint64 who) const { return players.find(who) != players.end(); } bool IsBanned(uint64 guid) const { return banned.find(guid) != banned.end(); } @@ -239,43 +267,18 @@ class Channel } } - public: - Channel(const std::string& name, uint32 channel_id); - std::string GetName() const { return m_name; } - uint32 GetChannelId() const { return m_channelId; } - bool IsConstant() const { return m_channelId != 0; } - bool IsAnnounce() const { return m_announce; } - bool IsLFG() const { return GetFlags() & CHANNEL_FLAG_LFG; } - std::string GetPassword() const { return m_password; } - void SetPassword(const std::string& npassword) { m_password = npassword; } - void SetAnnounce(bool nannounce) { m_announce = nannounce; } - uint32 GetNumPlayers() const { return players.size(); } - uint8 GetFlags() const { return m_flags; } - bool HasFlag(uint8 flag) { return m_flags & flag; } + private: + bool m_announce; + bool m_moderate; + std::string m_name; + std::string m_password; + uint8 m_flags; + uint32 m_channelId; + uint64 m_ownerGUID; - void Join(uint64 p, const char *pass); - void Leave(uint64 p, bool send = true); - void KickOrBan(uint64 good, const char *badname, bool ban); - void Kick(uint64 good, const char *badname) { KickOrBan(good, badname, false); } - void Ban(uint64 good, const char *badname) { KickOrBan(good, badname, true); } - void UnBan(uint64 good, const char *badname); - void Password(uint64 p, const char *pass); - void SetMode(uint64 p, const char *p2n, bool mod, bool set); - void SetOwner(uint64 p, bool exclaim = true); - void SetOwner(uint64 p, const char *newname); - void SendWhoOwner(uint64 p); - void SetModerator(uint64 p, const char *newname) { SetMode(p, newname, true, true); } - void UnsetModerator(uint64 p, const char *newname) { SetMode(p, newname, true, false); } - void SetMute(uint64 p, const char *newname) { SetMode(p, newname, false, true); } - void UnsetMute(uint64 p, const char *newname) { SetMode(p, newname, false, false); } - void List(Player* p); - void Announce(uint64 p); - void Moderate(uint64 p); - void Say(uint64 p, const char *what, uint32 lang); - void Invite(uint64 p, const char *newp); - void Voice(uint64 guid1, uint64 guid2); - void DeVoice(uint64 guid1, uint64 guid2); - void JoinNotify(uint64 guid); // invisible notify - void LeaveNotify(uint64 guid); // invisible notify + typedef std::map PlayerList; + PlayerList players; + typedef std::set BannedList; + BannedList banned; }; #endif diff --git a/src/game/ObjectMgr.h b/src/game/ObjectMgr.h index 004cda60d2f..2cb99cafeed 100644 --- a/src/game/ObjectMgr.h +++ b/src/game/ObjectMgr.h @@ -454,8 +454,8 @@ class ObjectMgr typedef UNORDERED_MAP WeatherZoneMap; - Player* GetPlayer(const char* name) const { return ObjectAccessor::FindPlayerByName(name);} - Player* GetPlayer(ObjectGuid guid) const { return ObjectAccessor::FindPlayer(guid); } + static Player* GetPlayer(const char* name) { return ObjectAccessor::FindPlayerByName(name);} + static Player* GetPlayer(ObjectGuid guid) { return ObjectAccessor::FindPlayer(guid); } static GameObjectInfo const *GetGameObjectInfo(uint32 id) { return sGOStorage.LookupEntry(id); } diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index b66210116a4..bb84e0fbedf 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 "11466" + #define REVISION_NR "11467" #endif // __REVISION_NR_H__ From 54517882685a910b6b111077545478b71f437282 Mon Sep 17 00:00:00 2001 From: VladimirMangos Date: Wed, 11 May 2011 01:46:03 +0400 Subject: [PATCH 35/43] [11468] Finally remove all uses Object::GetGUID from core sources. GetGUID() is now depricted function and will removed soon. Still exist just for give time for update patches/scripts. --- src/game/Channel.cpp | 267 ++++++++++++++++++------------------ src/game/Channel.h | 110 +++++++-------- src/game/ChannelHandler.cpp | 30 ++-- src/game/ChatHandler.cpp | 2 +- src/game/Object.h | 2 +- src/game/Player.cpp | 16 +-- src/shared/revision_nr.h | 2 +- 7 files changed, 214 insertions(+), 215 deletions(-) diff --git a/src/game/Channel.cpp b/src/game/Channel.cpp index d120ca5432f..7302f3d45ac 100644 --- a/src/game/Channel.cpp +++ b/src/game/Channel.cpp @@ -22,7 +22,7 @@ #include "SocialMgr.h" Channel::Channel(const std::string& name, uint32 channel_id) -: m_announce(true), m_moderate(false), m_name(name), m_flags(0), m_channelId(channel_id), m_ownerGUID(0) +: m_announce(true), m_moderate(false), m_name(name), m_flags(0), m_channelId(channel_id) { // set special flags if built-in channel ChatChannelsEntry const* ch = GetChannelEntryFor(channel_id); @@ -50,10 +50,10 @@ Channel::Channel(const std::string& name, uint32 channel_id) } } -void Channel::Join(uint64 p, const char *pass) +void Channel::Join(ObjectGuid p, const char *pass) { WorldPacket data; - if(IsOn(p)) + if (IsOn(p)) { if(!IsConstant()) // non send error message for built-in channels { @@ -63,7 +63,7 @@ void Channel::Join(uint64 p, const char *pass) return; } - if(IsBanned(p)) + if (IsBanned(p)) { MakeBanned(&data); SendToOne(&data, p); @@ -102,10 +102,9 @@ void Channel::Join(uint64 p, const char *pass) data.clear(); - PlayerInfo pinfo; + PlayerInfo& pinfo = m_players[p]; pinfo.player = p; pinfo.flags = 0; - players[p] = pinfo; MakeYouJoined(&data); SendToOne(&data, p); @@ -113,16 +112,16 @@ void Channel::Join(uint64 p, const char *pass) JoinNotify(p); // if no owner first logged will become - if(!IsConstant() && !m_ownerGUID) + if(!IsConstant() && m_ownerGuid.IsEmpty()) { - SetOwner(p, (players.size() > 1 ? true : false)); - players[p].SetModerator(true); + SetOwner(p, (m_players.size() > 1 ? true : false)); + m_players[p].SetModerator(true); } } -void Channel::Leave(uint64 p, bool send) +void Channel::Leave(ObjectGuid p, bool send) { - if(!IsOn(p)) + if (!IsOn(p)) { if(send) { @@ -145,9 +144,9 @@ void Channel::Leave(uint64 p, bool send) data.clear(); } - bool changeowner = players[p].IsOwner(); + bool changeowner = m_players[p].IsOwner(); - players.erase(p); + m_players.erase(p); if(m_announce && (!plr || plr->GetSession()->GetSecurity() < SEC_GAMEMASTER || !sWorld.getConfig(CONFIG_BOOL_SILENTLY_GM_JOIN_TO_CHANNEL) )) { WorldPacket data; @@ -159,26 +158,26 @@ void Channel::Leave(uint64 p, bool send) if(changeowner) { - uint64 newowner = !players.empty() ? players.begin()->second.player : 0; + ObjectGuid newowner = !m_players.empty() ? m_players.begin()->second.player : ObjectGuid(); SetOwner(newowner); } } } -void Channel::KickOrBan(uint64 good, const char *badname, bool ban) +void Channel::KickOrBan(ObjectGuid good, const char *badname, bool ban) { AccountTypes sec = SEC_PLAYER; Player *gplr = sObjectMgr.GetPlayer(good); - if(gplr) + if (gplr) sec = gplr->GetSession()->GetSecurity(); - if(!IsOn(good)) + if (!IsOn(good)) { WorldPacket data; MakeNotMember(&data); SendToOne(&data, good); } - else if(!players[good].IsModerator() && sec < SEC_GAMEMASTER) + else if (!m_players[good].IsModerator() && sec < SEC_GAMEMASTER) { WorldPacket data; MakeNotModerator(&data); @@ -187,13 +186,13 @@ void Channel::KickOrBan(uint64 good, const char *badname, bool ban) else { Player *bad = sObjectMgr.GetPlayer(badname); - if(bad == NULL || !IsOn(bad->GetGUID())) + if (bad == NULL || !IsOn(bad->GetObjectGuid())) { WorldPacket data; MakePlayerNotFound(&data, badname); SendToOne(&data, good); } - else if(sec < SEC_GAMEMASTER && bad->GetGUID() == m_ownerGUID && good != m_ownerGUID) + else if (sec < SEC_GAMEMASTER && bad->GetObjectGuid() == m_ownerGuid && good != m_ownerGuid) { WorldPacket data; MakeNotOwner(&data); @@ -201,45 +200,45 @@ void Channel::KickOrBan(uint64 good, const char *badname, bool ban) } else { - bool changeowner = (m_ownerGUID == bad->GetGUID()); + bool changeowner = (m_ownerGuid == bad->GetObjectGuid()); WorldPacket data; - if(ban && !IsBanned(bad->GetGUID())) + if(ban && !IsBanned(bad->GetObjectGuid())) { - banned.insert(bad->GetGUID()); - MakePlayerBanned(&data, bad->GetGUID(), good); + m_banned.insert(bad->GetObjectGuid()); + MakePlayerBanned(&data, bad->GetObjectGuid(), good); } else - MakePlayerKicked(&data, bad->GetGUID(), good); + MakePlayerKicked(&data, bad->GetObjectGuid(), good); SendToAll(&data); - players.erase(bad->GetGUID()); + m_players.erase(bad->GetObjectGuid()); bad->LeftChannel(this); if(changeowner) { - uint64 newowner = !players.empty() ? good : false; + ObjectGuid newowner = !m_players.empty() ? good : ObjectGuid(); SetOwner(newowner); } } } } -void Channel::UnBan(uint64 good, const char *badname) +void Channel::UnBan(ObjectGuid good, const char *badname) { uint32 sec = 0; Player *gplr = sObjectMgr.GetPlayer(good); if(gplr) sec = gplr->GetSession()->GetSecurity(); - if(!IsOn(good)) + if (!IsOn(good)) { WorldPacket data; MakeNotMember(&data); SendToOne(&data, good); } - else if(!players[good].IsModerator() && sec < SEC_GAMEMASTER) + else if(!m_players[good].IsModerator() && sec < SEC_GAMEMASTER) { WorldPacket data; MakeNotModerator(&data); @@ -248,7 +247,7 @@ void Channel::UnBan(uint64 good, const char *badname) else { Player *bad = sObjectMgr.GetPlayer(badname); - if(bad == NULL || !IsBanned(bad->GetGUID())) + if(bad == NULL || !IsBanned(bad->GetObjectGuid())) { WorldPacket data; MakePlayerNotFound(&data, badname); @@ -256,29 +255,29 @@ void Channel::UnBan(uint64 good, const char *badname) } else { - banned.erase(bad->GetGUID()); + m_banned.erase(bad->GetObjectGuid()); WorldPacket data; - MakePlayerUnbanned(&data, bad->GetGUID(), good); + MakePlayerUnbanned(&data, bad->GetObjectGuid(), good); SendToAll(&data); } } } -void Channel::Password(uint64 p, const char *pass) +void Channel::Password(ObjectGuid p, const char *pass) { uint32 sec = 0; Player *plr = sObjectMgr.GetPlayer(p); - if(plr) + if (plr) sec = plr->GetSession()->GetSecurity(); - if(!IsOn(p)) + if (!IsOn(p)) { WorldPacket data; MakeNotMember(&data); SendToOne(&data, p); } - else if(!players[p].IsModerator() && sec < SEC_GAMEMASTER) + else if(!m_players[p].IsModerator() && sec < SEC_GAMEMASTER) { WorldPacket data; MakeNotModerator(&data); @@ -294,7 +293,7 @@ void Channel::Password(uint64 p, const char *pass) } } -void Channel::SetMode(uint64 p, const char *p2n, bool mod, bool set) +void Channel::SetMode(ObjectGuid p, const char *p2n, bool mod, bool set) { Player *plr = sObjectMgr.GetPlayer(p); if (!plr) @@ -302,13 +301,13 @@ void Channel::SetMode(uint64 p, const char *p2n, bool mod, bool set) uint32 sec = plr->GetSession()->GetSecurity(); - if(!IsOn(p)) + if (!IsOn(p)) { WorldPacket data; MakeNotMember(&data); SendToOne(&data, p); } - else if(!players[p].IsModerator() && sec < SEC_GAMEMASTER) + else if(!m_players[p].IsModerator() && sec < SEC_GAMEMASTER) { WorldPacket data; MakeNotModerator(&data); @@ -325,11 +324,11 @@ void Channel::SetMode(uint64 p, const char *p2n, bool mod, bool set) return; } - PlayerInfo inf = players[newp->GetGUID()]; - if(p == m_ownerGUID && newp->GetGUID() == m_ownerGUID && mod) + PlayerInfo inf = m_players[newp->GetObjectGuid()]; + if(p == m_ownerGuid && newp->GetObjectGuid() == m_ownerGuid && mod) return; - if(!IsOn(newp->GetGUID())) + if (!IsOn(newp->GetObjectGuid())) { WorldPacket data; MakePlayerNotFound(&data, p2n); @@ -348,7 +347,7 @@ void Channel::SetMode(uint64 p, const char *p2n, bool mod, bool set) return; } - if(m_ownerGUID == newp->GetGUID() && m_ownerGUID != p) + if(m_ownerGuid == newp->GetObjectGuid() && m_ownerGuid != p) { WorldPacket data; MakeNotOwner(&data); @@ -357,13 +356,13 @@ void Channel::SetMode(uint64 p, const char *p2n, bool mod, bool set) } if(mod) - SetModerator(newp->GetGUID(), set); + SetModerator(newp->GetObjectGuid(), set); else - SetMute(newp->GetGUID(), set); + SetMute(newp->GetObjectGuid(), set); } } -void Channel::SetOwner(uint64 p, const char *newname) +void Channel::SetOwner(ObjectGuid p, const char *newname) { Player *plr = sObjectMgr.GetPlayer(p); if (!plr) @@ -371,7 +370,7 @@ void Channel::SetOwner(uint64 p, const char *newname) uint32 sec = plr->GetSession()->GetSecurity(); - if(!IsOn(p)) + if (!IsOn(p)) { WorldPacket data; MakeNotMember(&data); @@ -379,7 +378,7 @@ void Channel::SetOwner(uint64 p, const char *newname) return; } - if(sec < SEC_GAMEMASTER && p != m_ownerGUID) + if(sec < SEC_GAMEMASTER && p != m_ownerGuid) { WorldPacket data; MakeNotOwner(&data); @@ -388,7 +387,7 @@ void Channel::SetOwner(uint64 p, const char *newname) } Player *newp = sObjectMgr.GetPlayer(newname); - if(newp == NULL || !IsOn(newp->GetGUID())) + if (newp == NULL || !IsOn(newp->GetObjectGuid())) { WorldPacket data; MakePlayerNotFound(&data, newname); @@ -404,13 +403,13 @@ void Channel::SetOwner(uint64 p, const char *newname) return; } - players[newp->GetGUID()].SetModerator(true); - SetOwner(newp->GetGUID()); + m_players[newp->GetObjectGuid()].SetModerator(true); + SetOwner(newp->GetObjectGuid()); } -void Channel::SendWhoOwner(uint64 p) +void Channel::SendWhoOwner(ObjectGuid p) { - if(!IsOn(p)) + if (!IsOn(p)) { WorldPacket data; MakeNotMember(&data); @@ -426,9 +425,9 @@ void Channel::SendWhoOwner(uint64 p) void Channel::List(Player* player) { - uint64 p = player->GetGUID(); + ObjectGuid p = player->GetObjectGuid(); - if(!IsOn(p)) + if (!IsOn(p)) { WorldPacket data; MakeNotMember(&data); @@ -436,7 +435,7 @@ void Channel::List(Player* player) } else { - WorldPacket data(SMSG_CHANNEL_LIST, 1+(GetName().size()+1)+1+4+players.size()*(8+1)); + WorldPacket data(SMSG_CHANNEL_LIST, 1+(GetName().size()+1)+1+4+m_players.size()*(8+1)); data << uint8(1); // channel type? data << GetName(); // channel name data << uint8(GetFlags()); // channel flags? @@ -447,7 +446,7 @@ void Channel::List(Player* player) AccountTypes gmLevelInWhoList = (AccountTypes)sWorld.getConfig(CONFIG_UINT32_GM_LEVEL_IN_WHO_LIST); uint32 count = 0; - for(PlayerList::const_iterator i = players.begin(); i != players.end(); ++i) + for(PlayerList::const_iterator i = m_players.begin(); i != m_players.end(); ++i) { Player *plr = sObjectMgr.GetPlayer(i->first); @@ -456,7 +455,7 @@ void Channel::List(Player* player) if (plr && (player->GetSession()->GetSecurity() > SEC_PLAYER || plr->GetSession()->GetSecurity() <= gmLevelInWhoList) && plr->IsVisibleGloballyFor(player)) { - data << uint64(i->first); + data << ObjectGuid(i->first); data << uint8(i->second.flags); // flags seems to be changed... ++count; } @@ -468,20 +467,20 @@ void Channel::List(Player* player) } } -void Channel::Announce(uint64 p) +void Channel::Announce(ObjectGuid p) { uint32 sec = 0; Player *plr = sObjectMgr.GetPlayer(p); if(plr) sec = plr->GetSession()->GetSecurity(); - if(!IsOn(p)) + if (!IsOn(p)) { WorldPacket data; MakeNotMember(&data); SendToOne(&data, p); } - else if(!players[p].IsModerator() && sec < SEC_GAMEMASTER) + else if (!m_players[p].IsModerator() && sec < SEC_GAMEMASTER) { WorldPacket data; MakeNotModerator(&data); @@ -500,20 +499,20 @@ void Channel::Announce(uint64 p) } } -void Channel::Moderate(uint64 p) +void Channel::Moderate(ObjectGuid p) { uint32 sec = 0; Player *plr = sObjectMgr.GetPlayer(p); if(plr) sec = plr->GetSession()->GetSecurity(); - if(!IsOn(p)) + if (!IsOn(p)) { WorldPacket data; MakeNotMember(&data); SendToOne(&data, p); } - else if(!players[p].IsModerator() && sec < SEC_GAMEMASTER) + else if (!m_players[p].IsModerator() && sec < SEC_GAMEMASTER) { WorldPacket data; MakeNotModerator(&data); @@ -532,9 +531,9 @@ void Channel::Moderate(uint64 p) } } -void Channel::Say(uint64 p, const char *what, uint32 lang) +void Channel::Say(ObjectGuid p, const char *what, uint32 lang) { - if(!what) + if (!what) return; if (sWorld.getConfig(CONFIG_BOOL_ALLOW_TWO_SIDE_INTERACTION_CHANNEL)) lang = LANG_UNIVERSAL; @@ -544,19 +543,19 @@ void Channel::Say(uint64 p, const char *what, uint32 lang) if(plr) sec = plr->GetSession()->GetSecurity(); - if(!IsOn(p)) + if (!IsOn(p)) { WorldPacket data; MakeNotMember(&data); SendToOne(&data, p); } - else if(players[p].IsMuted()) + else if (m_players[p].IsMuted()) { WorldPacket data; MakeMuted(&data); SendToOne(&data, p); } - else if(m_moderate && !players[p].IsModerator() && sec < SEC_GAMEMASTER) + else if (m_moderate && !m_players[p].IsModerator() && sec < SEC_GAMEMASTER) { WorldPacket data; MakeNotModerator(&data); @@ -567,23 +566,23 @@ void Channel::Say(uint64 p, const char *what, uint32 lang) uint32 messageLength = strlen(what) + 1; WorldPacket data(SMSG_MESSAGECHAT, 1+4+8+4+m_name.size()+1+8+4+messageLength+1); - data << (uint8)CHAT_MSG_CHANNEL; - data << (uint32)lang; - data << p; // 2.1.0 + data << uint8(CHAT_MSG_CHANNEL); + data << uint32(lang); + data << ObjectGuid(p); // 2.1.0 data << uint32(0); // 2.1.0 data << m_name; - data << p; - data << messageLength; + data << ObjectGuid(p); + data << uint32(messageLength); data << what; data << uint8(plr ? plr->chatTag() : 0); - SendToAll(&data, !players[p].IsModerator() ? p : 0); + SendToAll(&data, !m_players[p].IsModerator() ? p : ObjectGuid()); } } -void Channel::Invite(uint64 p, const char *newname) +void Channel::Invite(ObjectGuid p, const char *newname) { - if(!IsOn(p)) + if (!IsOn(p)) { WorldPacket data; MakeNotMember(&data); @@ -612,16 +611,16 @@ void Channel::Invite(uint64 p, const char *newname) return; } - if(IsOn(newp->GetGUID())) + if (IsOn(newp->GetObjectGuid())) { WorldPacket data; - MakePlayerAlreadyMember(&data, newp->GetGUID()); + MakePlayerAlreadyMember(&data, newp->GetObjectGuid()); SendToOne(&data, p); return; } WorldPacket data; - if(!newp->GetSocial()->HasIgnore(p)) + if (!newp->GetSocial()->HasIgnore(p)) { MakeInvite(&data, p); SendToOne(&data, newp->GetObjectGuid()); @@ -631,39 +630,39 @@ void Channel::Invite(uint64 p, const char *newname) SendToOne(&data, p); } -void Channel::SetOwner(uint64 guid, bool exclaim) +void Channel::SetOwner(ObjectGuid guid, bool exclaim) { - if(m_ownerGUID) + if (!m_ownerGuid.IsEmpty()) { // [] will re-add player after it possible removed - PlayerList::iterator p_itr = players.find(m_ownerGUID); - if(p_itr != players.end()) + PlayerList::iterator p_itr = m_players.find(m_ownerGuid); + if (p_itr != m_players.end()) p_itr->second.SetOwner(false); } - m_ownerGUID = guid; - if(m_ownerGUID) + m_ownerGuid = guid; + if (!m_ownerGuid.IsEmpty()) { - uint8 oldFlag = GetPlayerFlags(m_ownerGUID); - players[m_ownerGUID].SetOwner(true); + uint8 oldFlag = GetPlayerFlags(m_ownerGuid); + m_players[m_ownerGuid].SetOwner(true); WorldPacket data; - MakeModeChange(&data, m_ownerGUID, oldFlag); + MakeModeChange(&data, m_ownerGuid, oldFlag); SendToAll(&data); if(exclaim) { - MakeOwnerChanged(&data, m_ownerGUID); + MakeOwnerChanged(&data, m_ownerGuid); SendToAll(&data); } } } -void Channel::SendToAll(WorldPacket *data, uint64 p) +void Channel::SendToAll(WorldPacket *data, ObjectGuid p) { - for(PlayerList::const_iterator i = players.begin(); i != players.end(); ++i) + for(PlayerList::const_iterator i = m_players.begin(); i != m_players.end(); ++i) if (Player *plr = sObjectMgr.GetPlayer(i->first)) - if(!p || !plr->GetSocial()->HasIgnore(p)) + if (p.IsEmpty() || !plr->GetSocial()->HasIgnore(p)) plr->GetSession()->SendPacket(data); } @@ -692,17 +691,17 @@ void Channel::MakeNotifyPacket(WorldPacket *data, uint8 notify_type) } // done 0x00 -void Channel::MakeJoined(WorldPacket *data, uint64 guid) +void Channel::MakeJoined(WorldPacket *data, ObjectGuid guid) { MakeNotifyPacket(data, CHAT_JOINED_NOTICE); - *data << uint64(guid); + *data << ObjectGuid(guid); } // done 0x01 -void Channel::MakeLeft(WorldPacket *data, uint64 guid) +void Channel::MakeLeft(WorldPacket *data, ObjectGuid guid) { MakeNotifyPacket(data, CHAT_LEFT_NOTICE); - *data << uint64(guid); + *data << ObjectGuid(guid); } // done 0x02 @@ -741,17 +740,17 @@ void Channel::MakeNotModerator(WorldPacket *data) } // done 0x07 -void Channel::MakePasswordChanged(WorldPacket *data, uint64 guid) +void Channel::MakePasswordChanged(WorldPacket *data, ObjectGuid guid) { MakeNotifyPacket(data, CHAT_PASSWORD_CHANGED_NOTICE); - *data << uint64(guid); + *data << ObjectGuid(guid); } // done 0x08 -void Channel::MakeOwnerChanged(WorldPacket *data, uint64 guid) +void Channel::MakeOwnerChanged(WorldPacket *data, ObjectGuid guid) { MakeNotifyPacket(data, CHAT_OWNER_CHANGED_NOTICE); - *data << uint64(guid); + *data << ObjectGuid(guid); } // done 0x09 @@ -772,48 +771,48 @@ void Channel::MakeChannelOwner(WorldPacket *data) { std::string name = ""; - if(!sObjectMgr.GetPlayerNameByGUID(m_ownerGUID, name) || name.empty()) + if (!sObjectMgr.GetPlayerNameByGUID(m_ownerGuid, name) || name.empty()) name = "PLAYER_NOT_FOUND"; MakeNotifyPacket(data, CHAT_CHANNEL_OWNER_NOTICE); - *data << ((IsConstant() || !m_ownerGUID) ? "Nobody" : name); + *data << ((IsConstant() || m_ownerGuid.IsEmpty()) ? "Nobody" : name); } // done 0x0C -void Channel::MakeModeChange(WorldPacket *data, uint64 guid, uint8 oldflags) +void Channel::MakeModeChange(WorldPacket *data, ObjectGuid guid, uint8 oldflags) { MakeNotifyPacket(data, CHAT_MODE_CHANGE_NOTICE); - *data << uint64(guid); + *data << ObjectGuid(guid); *data << uint8(oldflags); *data << uint8(GetPlayerFlags(guid)); } // done 0x0D -void Channel::MakeAnnouncementsOn(WorldPacket *data, uint64 guid) +void Channel::MakeAnnouncementsOn(WorldPacket *data, ObjectGuid guid) { MakeNotifyPacket(data, CHAT_ANNOUNCEMENTS_ON_NOTICE); - *data << uint64(guid); + *data << ObjectGuid(guid); } // done 0x0E -void Channel::MakeAnnouncementsOff(WorldPacket *data, uint64 guid) +void Channel::MakeAnnouncementsOff(WorldPacket *data, ObjectGuid guid) { MakeNotifyPacket(data, CHAT_ANNOUNCEMENTS_OFF_NOTICE); - *data << uint64(guid); + *data << ObjectGuid(guid); } // done 0x0F -void Channel::MakeModerationOn(WorldPacket *data, uint64 guid) +void Channel::MakeModerationOn(WorldPacket *data, ObjectGuid guid) { MakeNotifyPacket(data, CHAT_MODERATION_ON_NOTICE); - *data << uint64(guid); + *data << ObjectGuid(guid); } // done 0x10 -void Channel::MakeModerationOff(WorldPacket *data, uint64 guid) +void Channel::MakeModerationOff(WorldPacket *data, ObjectGuid guid) { MakeNotifyPacket(data, CHAT_MODERATION_OFF_NOTICE); - *data << uint64(guid); + *data << ObjectGuid(guid); } // done 0x11 @@ -823,11 +822,11 @@ void Channel::MakeMuted(WorldPacket *data) } // done 0x12 -void Channel::MakePlayerKicked(WorldPacket *data, uint64 bad, uint64 good) +void Channel::MakePlayerKicked(WorldPacket *data, ObjectGuid bad, ObjectGuid good) { MakeNotifyPacket(data, CHAT_PLAYER_KICKED_NOTICE); - *data << uint64(bad); - *data << uint64(good); + *data << ObjectGuid(bad); + *data << ObjectGuid(good); } // done 0x13 @@ -837,40 +836,40 @@ void Channel::MakeBanned(WorldPacket *data) } // done 0x14 -void Channel::MakePlayerBanned(WorldPacket *data, uint64 bad, uint64 good) +void Channel::MakePlayerBanned(WorldPacket *data, ObjectGuid bad, ObjectGuid good) { MakeNotifyPacket(data, CHAT_PLAYER_BANNED_NOTICE); - *data << uint64(bad); - *data << uint64(good); + *data << ObjectGuid(bad); + *data << ObjectGuid(good); } // done 0x15 -void Channel::MakePlayerUnbanned(WorldPacket *data, uint64 bad, uint64 good) +void Channel::MakePlayerUnbanned(WorldPacket *data, ObjectGuid bad, ObjectGuid good) { MakeNotifyPacket(data, CHAT_PLAYER_UNBANNED_NOTICE); - *data << uint64(bad); - *data << uint64(good); + *data << ObjectGuid(bad); + *data << ObjectGuid(good); } // done 0x16 -void Channel::MakePlayerNotBanned(WorldPacket *data, uint64 guid) +void Channel::MakePlayerNotBanned(WorldPacket *data, ObjectGuid guid) { MakeNotifyPacket(data, CHAT_PLAYER_NOT_BANNED_NOTICE); - *data << uint64(guid); // should be string!! + *data << ObjectGuid(guid); // should be string!! } // done 0x17 -void Channel::MakePlayerAlreadyMember(WorldPacket *data, uint64 guid) +void Channel::MakePlayerAlreadyMember(WorldPacket *data, ObjectGuid guid) { MakeNotifyPacket(data, CHAT_PLAYER_ALREADY_MEMBER_NOTICE); - *data << uint64(guid); + *data << ObjectGuid(guid); } // done 0x18 -void Channel::MakeInvite(WorldPacket *data, uint64 guid) +void Channel::MakeInvite(WorldPacket *data, ObjectGuid guid) { MakeNotifyPacket(data, CHAT_INVITE_NOTICE); - *data << uint64(guid); + *data << ObjectGuid(guid); } // done 0x19 @@ -943,16 +942,16 @@ void Channel::MakeVoiceOff(WorldPacket *data, uint64 guid) *data << uint64(guid); } -void Channel::JoinNotify(uint64 guid) +void Channel::JoinNotify(ObjectGuid guid) { WorldPacket data; - if(IsConstant()) + if (IsConstant()) data.Initialize(SMSG_USERLIST_ADD, 8+1+1+4+GetName().size()+1); else data.Initialize(SMSG_USERLIST_UPDATE, 8+1+1+4+GetName().size()+1); - data << uint64(guid); + data << ObjectGuid(guid); data << uint8(GetPlayerFlags(guid)); data << uint8(GetFlags()); data << uint32(GetNumPlayers()); @@ -960,10 +959,10 @@ void Channel::JoinNotify(uint64 guid) SendToAll(&data); } -void Channel::LeaveNotify(uint64 guid) +void Channel::LeaveNotify(ObjectGuid guid) { WorldPacket data(SMSG_USERLIST_REMOVE, 8+1+4+GetName().size()+1); - data << uint64(guid); + data << ObjectGuid(guid); data << uint8(GetFlags()); data << uint32(GetNumPlayers()); data << GetName(); diff --git a/src/game/Channel.h b/src/game/Channel.h index b6ac8a34021..687f6ad79c8 100644 --- a/src/game/Channel.h +++ b/src/game/Channel.h @@ -121,7 +121,7 @@ class Channel struct PlayerInfo { - uint64 player; + ObjectGuid player; uint8 flags; bool HasFlag(uint8 flag) { return flags & flag; } @@ -156,64 +156,64 @@ class Channel std::string GetPassword() const { return m_password; } void SetPassword(const std::string& npassword) { m_password = npassword; } void SetAnnounce(bool nannounce) { m_announce = nannounce; } - uint32 GetNumPlayers() const { return players.size(); } + uint32 GetNumPlayers() const { return m_players.size(); } uint8 GetFlags() const { return m_flags; } bool HasFlag(uint8 flag) { return m_flags & flag; } - void Join(uint64 p, const char *pass); - void Leave(uint64 p, bool send = true); - void KickOrBan(uint64 good, const char *badname, bool ban); - void Kick(uint64 good, const char *badname) { KickOrBan(good, badname, false); } - void Ban(uint64 good, const char *badname) { KickOrBan(good, badname, true); } - void UnBan(uint64 good, const char *badname); - void Password(uint64 p, const char *pass); - void SetMode(uint64 p, const char *p2n, bool mod, bool set); - void SetOwner(uint64 p, bool exclaim = true); - void SetOwner(uint64 p, const char *newname); - void SendWhoOwner(uint64 p); - void SetModerator(uint64 p, const char *newname) { SetMode(p, newname, true, true); } - void UnsetModerator(uint64 p, const char *newname) { SetMode(p, newname, true, false); } - void SetMute(uint64 p, const char *newname) { SetMode(p, newname, false, true); } - void UnsetMute(uint64 p, const char *newname) { SetMode(p, newname, false, false); } + void Join(ObjectGuid p, const char *pass); + void Leave(ObjectGuid p, bool send = true); + void KickOrBan(ObjectGuid good, const char *badname, bool ban); + void Kick(ObjectGuid good, const char *badname) { KickOrBan(good, badname, false); } + void Ban(ObjectGuid good, const char *badname) { KickOrBan(good, badname, true); } + void UnBan(ObjectGuid good, const char *badname); + void Password(ObjectGuid p, const char *pass); + void SetMode(ObjectGuid p, const char *p2n, bool mod, bool set); + void SetOwner(ObjectGuid p, bool exclaim = true); + void SetOwner(ObjectGuid p, const char *newname); + void SendWhoOwner(ObjectGuid p); + void SetModerator(ObjectGuid p, const char *newname) { SetMode(p, newname, true, true); } + void UnsetModerator(ObjectGuid p, const char *newname) { SetMode(p, newname, true, false); } + void SetMute(ObjectGuid p, const char *newname) { SetMode(p, newname, false, true); } + void UnsetMute(ObjectGuid p, const char *newname) { SetMode(p, newname, false, false); } void List(Player* p); - void Announce(uint64 p); - void Moderate(uint64 p); - void Say(uint64 p, const char *what, uint32 lang); - void Invite(uint64 p, const char *newp); + void Announce(ObjectGuid p); + void Moderate(ObjectGuid p); + void Say(ObjectGuid p, const char *what, uint32 lang); + void Invite(ObjectGuid p, const char *newp); void Voice(uint64 guid1, uint64 guid2); void DeVoice(uint64 guid1, uint64 guid2); - void JoinNotify(uint64 guid); // invisible notify - void LeaveNotify(uint64 guid); // invisible notify + void JoinNotify(ObjectGuid guid); // invisible notify + void LeaveNotify(ObjectGuid guid); // invisible notify private: // initial packet data (notify type and channel name) void MakeNotifyPacket(WorldPacket *data, uint8 notify_type); // type specific packet data - void MakeJoined(WorldPacket *data, uint64 guid); //+ 0x00 - void MakeLeft(WorldPacket *data, uint64 guid); //+ 0x01 + void MakeJoined(WorldPacket *data, ObjectGuid guid); //+ 0x00 + void MakeLeft(WorldPacket *data, ObjectGuid guid); //+ 0x01 void MakeYouJoined(WorldPacket *data); //+ 0x02 void MakeYouLeft(WorldPacket *data); //+ 0x03 void MakeWrongPassword(WorldPacket *data); //? 0x04 void MakeNotMember(WorldPacket *data); //? 0x05 void MakeNotModerator(WorldPacket *data); //? 0x06 - void MakePasswordChanged(WorldPacket *data, uint64 guid); //+ 0x07 - void MakeOwnerChanged(WorldPacket *data, uint64 guid); //? 0x08 + void MakePasswordChanged(WorldPacket *data, ObjectGuid guid); //+ 0x07 + void MakeOwnerChanged(WorldPacket *data, ObjectGuid guid); //? 0x08 void MakePlayerNotFound(WorldPacket *data, const std::string& name); //+ 0x09 void MakeNotOwner(WorldPacket *data); //? 0x0A void MakeChannelOwner(WorldPacket *data); //? 0x0B - void MakeModeChange(WorldPacket *data, uint64 guid, uint8 oldflags); //+ 0x0C - void MakeAnnouncementsOn(WorldPacket *data, uint64 guid); //+ 0x0D - void MakeAnnouncementsOff(WorldPacket *data, uint64 guid); //+ 0x0E - void MakeModerationOn(WorldPacket *data, uint64 guid); //+ 0x0F - void MakeModerationOff(WorldPacket *data, uint64 guid); //+ 0x10 + void MakeModeChange(WorldPacket *data, ObjectGuid guid, uint8 oldflags);//+ 0x0C + void MakeAnnouncementsOn(WorldPacket *data, ObjectGuid guid); //+ 0x0D + void MakeAnnouncementsOff(WorldPacket *data, ObjectGuid guid); //+ 0x0E + void MakeModerationOn(WorldPacket *data, ObjectGuid guid); //+ 0x0F + void MakeModerationOff(WorldPacket *data, ObjectGuid guid); //+ 0x10 void MakeMuted(WorldPacket *data); //? 0x11 - void MakePlayerKicked(WorldPacket *data, uint64 bad, uint64 good); //? 0x12 + void MakePlayerKicked(WorldPacket *data, ObjectGuid bad, ObjectGuid good);//? 0x12 void MakeBanned(WorldPacket *data); //? 0x13 - void MakePlayerBanned(WorldPacket *data, uint64 bad, uint64 good); //? 0x14 - void MakePlayerUnbanned(WorldPacket *data, uint64 bad, uint64 good); //? 0x15 - void MakePlayerNotBanned(WorldPacket *data, uint64 guid); //? 0x16 - void MakePlayerAlreadyMember(WorldPacket *data, uint64 guid); //+ 0x17 - void MakeInvite(WorldPacket *data, uint64 guid); //? 0x18 + void MakePlayerBanned(WorldPacket *data, ObjectGuid bad, ObjectGuid good);//? 0x14 + void MakePlayerUnbanned(WorldPacket *data, ObjectGuid bad, ObjectGuid good);//? 0x15 + void MakePlayerNotBanned(WorldPacket *data, ObjectGuid guid); //? 0x16 + void MakePlayerAlreadyMember(WorldPacket *data, ObjectGuid guid); //+ 0x17 + void MakeInvite(WorldPacket *data, ObjectGuid guid); //? 0x18 void MakeInviteWrongFaction(WorldPacket *data); //? 0x19 void MakeWrongFaction(WorldPacket *data); //? 0x1A void MakeInvalidName(WorldPacket *data); //? 0x1B @@ -226,27 +226,27 @@ class Channel void MakeVoiceOn(WorldPacket *data, uint64 guid); //+ 0x22 void MakeVoiceOff(WorldPacket *data, uint64 guid); //+ 0x23 - void SendToAll(WorldPacket *data, uint64 p = 0); + void SendToAll(WorldPacket *data, ObjectGuid p = ObjectGuid()); void SendToOne(WorldPacket *data, ObjectGuid who); - bool IsOn(uint64 who) const { return players.find(who) != players.end(); } - bool IsBanned(uint64 guid) const { return banned.find(guid) != banned.end(); } + bool IsOn(ObjectGuid who) const { return m_players.find(who) != m_players.end(); } + bool IsBanned(ObjectGuid guid) const { return m_banned.find(guid) != m_banned.end(); } - uint8 GetPlayerFlags(uint64 p) const + uint8 GetPlayerFlags(ObjectGuid p) const { - PlayerList::const_iterator p_itr = players.find(p); - if(p_itr == players.end()) + PlayerList::const_iterator p_itr = m_players.find(p); + if (p_itr == m_players.end()) return 0; return p_itr->second.flags; } - void SetModerator(uint64 p, bool set) + void SetModerator(ObjectGuid p, bool set) { - if(players[p].IsModerator() != set) + if (m_players[p].IsModerator() != set) { uint8 oldFlag = GetPlayerFlags(p); - players[p].SetModerator(set); + m_players[p].SetModerator(set); WorldPacket data; MakeModeChange(&data, p, oldFlag); @@ -254,12 +254,12 @@ class Channel } } - void SetMute(uint64 p, bool set) + void SetMute(ObjectGuid p, bool set) { - if(players[p].IsMuted() != set) + if (m_players[p].IsMuted() != set) { uint8 oldFlag = GetPlayerFlags(p); - players[p].SetMuted(set); + m_players[p].SetMuted(set); WorldPacket data; MakeModeChange(&data, p, oldFlag); @@ -274,11 +274,11 @@ class Channel std::string m_password; uint8 m_flags; uint32 m_channelId; - uint64 m_ownerGUID; + ObjectGuid m_ownerGuid; - typedef std::map PlayerList; - PlayerList players; - typedef std::set BannedList; - BannedList banned; + typedef std::map PlayerList; + PlayerList m_players; + typedef std::set BannedList; + BannedList m_banned; }; #endif diff --git a/src/game/ChannelHandler.cpp b/src/game/ChannelHandler.cpp index 520a3e45cbd..1a5b926ac0b 100644 --- a/src/game/ChannelHandler.cpp +++ b/src/game/ChannelHandler.cpp @@ -36,7 +36,7 @@ void WorldSession::HandleJoinChannelOpcode(WorldPacket& recvPacket) recvPacket >> pass; if(ChannelMgr* cMgr = channelMgr(_player->GetTeam())) if(Channel *chn = cMgr->GetJoinChannel(channelname, channel_id)) - chn->Join(_player->GetGUID(), pass.c_str()); + chn->Join(_player->GetObjectGuid(), pass.c_str()); } void WorldSession::HandleLeaveChannelOpcode(WorldPacket& recvPacket) @@ -55,7 +55,7 @@ void WorldSession::HandleLeaveChannelOpcode(WorldPacket& recvPacket) if(ChannelMgr* cMgr = channelMgr(_player->GetTeam())) { if(Channel *chn = cMgr->GetChannel(channelname, _player)) - chn->Leave(_player->GetGUID(), true); + chn->Leave(_player->GetObjectGuid(), true); cMgr->LeftChannel(channelname); } } @@ -83,7 +83,7 @@ void WorldSession::HandleChannelPasswordOpcode(WorldPacket& recvPacket) if(ChannelMgr* cMgr = channelMgr(_player->GetTeam())) if(Channel *chn = cMgr->GetChannel(channelname, _player)) - chn->Password(_player->GetGUID(), pass.c_str()); + chn->Password(_player->GetObjectGuid(), pass.c_str()); } void WorldSession::HandleChannelSetOwnerOpcode(WorldPacket& recvPacket) @@ -100,7 +100,7 @@ void WorldSession::HandleChannelSetOwnerOpcode(WorldPacket& recvPacket) if(ChannelMgr* cMgr = channelMgr(_player->GetTeam())) if(Channel *chn = cMgr->GetChannel(channelname, _player)) - chn->SetOwner(_player->GetGUID(), newp.c_str()); + chn->SetOwner(_player->GetObjectGuid(), newp.c_str()); } void WorldSession::HandleChannelOwnerOpcode(WorldPacket& recvPacket) @@ -111,7 +111,7 @@ void WorldSession::HandleChannelOwnerOpcode(WorldPacket& recvPacket) recvPacket >> channelname; if(ChannelMgr* cMgr = channelMgr(_player->GetTeam())) if(Channel *chn = cMgr->GetChannel(channelname, _player)) - chn->SendWhoOwner(_player->GetGUID()); + chn->SendWhoOwner(_player->GetObjectGuid()); } void WorldSession::HandleChannelModeratorOpcode(WorldPacket& recvPacket) @@ -128,7 +128,7 @@ void WorldSession::HandleChannelModeratorOpcode(WorldPacket& recvPacket) if(ChannelMgr* cMgr = channelMgr(_player->GetTeam())) if(Channel *chn = cMgr->GetChannel(channelname, _player)) - chn->SetModerator(_player->GetGUID(), otp.c_str()); + chn->SetModerator(_player->GetObjectGuid(), otp.c_str()); } void WorldSession::HandleChannelUnmoderatorOpcode(WorldPacket& recvPacket) @@ -145,7 +145,7 @@ void WorldSession::HandleChannelUnmoderatorOpcode(WorldPacket& recvPacket) if(ChannelMgr* cMgr = channelMgr(_player->GetTeam())) if(Channel *chn = cMgr->GetChannel(channelname, _player)) - chn->UnsetModerator(_player->GetGUID(), otp.c_str()); + chn->UnsetModerator(_player->GetObjectGuid(), otp.c_str()); } void WorldSession::HandleChannelMuteOpcode(WorldPacket& recvPacket) @@ -162,7 +162,7 @@ void WorldSession::HandleChannelMuteOpcode(WorldPacket& recvPacket) if(ChannelMgr* cMgr = channelMgr(_player->GetTeam())) if(Channel *chn = cMgr->GetChannel(channelname, _player)) - chn->SetMute(_player->GetGUID(), otp.c_str()); + chn->SetMute(_player->GetObjectGuid(), otp.c_str()); } void WorldSession::HandleChannelUnmuteOpcode(WorldPacket& recvPacket) @@ -180,7 +180,7 @@ void WorldSession::HandleChannelUnmuteOpcode(WorldPacket& recvPacket) if(ChannelMgr* cMgr = channelMgr(_player->GetTeam())) if(Channel *chn = cMgr->GetChannel(channelname, _player)) - chn->UnsetMute(_player->GetGUID(), otp.c_str()); + chn->UnsetMute(_player->GetObjectGuid(), otp.c_str()); } void WorldSession::HandleChannelInviteOpcode(WorldPacket& recvPacket) @@ -197,7 +197,7 @@ void WorldSession::HandleChannelInviteOpcode(WorldPacket& recvPacket) if(ChannelMgr* cMgr = channelMgr(_player->GetTeam())) if(Channel *chn = cMgr->GetChannel(channelname, _player)) - chn->Invite(_player->GetGUID(), otp.c_str()); + chn->Invite(_player->GetObjectGuid(), otp.c_str()); } void WorldSession::HandleChannelKickOpcode(WorldPacket& recvPacket) @@ -213,7 +213,7 @@ void WorldSession::HandleChannelKickOpcode(WorldPacket& recvPacket) if(ChannelMgr* cMgr = channelMgr(_player->GetTeam())) if(Channel *chn = cMgr->GetChannel(channelname, _player)) - chn->Kick(_player->GetGUID(), otp.c_str()); + chn->Kick(_player->GetObjectGuid(), otp.c_str()); } void WorldSession::HandleChannelBanOpcode(WorldPacket& recvPacket) @@ -230,7 +230,7 @@ void WorldSession::HandleChannelBanOpcode(WorldPacket& recvPacket) if(ChannelMgr* cMgr = channelMgr(_player->GetTeam())) if(Channel *chn = cMgr->GetChannel(channelname, _player)) - chn->Ban(_player->GetGUID(), otp.c_str()); + chn->Ban(_player->GetObjectGuid(), otp.c_str()); } void WorldSession::HandleChannelUnbanOpcode(WorldPacket& recvPacket) @@ -248,7 +248,7 @@ void WorldSession::HandleChannelUnbanOpcode(WorldPacket& recvPacket) if(ChannelMgr* cMgr = channelMgr(_player->GetTeam())) if(Channel *chn = cMgr->GetChannel(channelname, _player)) - chn->UnBan(_player->GetGUID(), otp.c_str()); + chn->UnBan(_player->GetObjectGuid(), otp.c_str()); } void WorldSession::HandleChannelAnnouncementsOpcode(WorldPacket& recvPacket) @@ -259,7 +259,7 @@ void WorldSession::HandleChannelAnnouncementsOpcode(WorldPacket& recvPacket) recvPacket >> channelname; if(ChannelMgr* cMgr = channelMgr(_player->GetTeam())) if(Channel *chn = cMgr->GetChannel(channelname, _player)) - chn->Announce(_player->GetGUID()); + chn->Announce(_player->GetObjectGuid()); } void WorldSession::HandleChannelModerateOpcode(WorldPacket& recvPacket) @@ -270,7 +270,7 @@ void WorldSession::HandleChannelModerateOpcode(WorldPacket& recvPacket) recvPacket >> channelname; if(ChannelMgr* cMgr = channelMgr(_player->GetTeam())) if(Channel *chn = cMgr->GetChannel(channelname, _player)) - chn->Moderate(_player->GetGUID()); + chn->Moderate(_player->GetObjectGuid()); } void WorldSession::HandleChannelDisplayListQueryOpcode(WorldPacket &recvPacket) diff --git a/src/game/ChatHandler.cpp b/src/game/ChatHandler.cpp index f28a94026cb..c7eeadafa30 100644 --- a/src/game/ChatHandler.cpp +++ b/src/game/ChatHandler.cpp @@ -444,7 +444,7 @@ void WorldSession::HandleMessagechatOpcode( WorldPacket & recv_data ) if(ChannelMgr* cMgr = channelMgr(_player->GetTeam())) if(Channel *chn = cMgr->GetChannel(channel, _player)) - chn->Say(_player->GetGUID(), msg.c_str(), lang); + chn->Say(_player->GetObjectGuid(), msg.c_str(), lang); } break; case CHAT_MSG_AFK: diff --git a/src/game/Object.h b/src/game/Object.h index 4559fedfd19..286024d5eb5 100644 --- a/src/game/Object.h +++ b/src/game/Object.h @@ -138,7 +138,7 @@ class MANGOS_DLL_SPEC Object } ObjectGuid const& GetObjectGuid() const { return GetGuidValue(OBJECT_FIELD_GUID); } - const uint64& GetGUID() const { return GetUInt64Value(OBJECT_FIELD_GUID); } + const uint64& GetGUID() const { return GetUInt64Value(OBJECT_FIELD_GUID); } // DEPRICATED, not use, will removed soon uint32 GetGUIDLow() const { return GetObjectGuid().GetCounter(); } PackedGuid const& GetPackGUID() const { return m_PackGUID; } std::string GetGuidStr() const { return GetObjectGuid().GetString(); } diff --git a/src/game/Player.cpp b/src/game/Player.cpp index 5f164e8d11d..c224d269fd3 100644 --- a/src/game/Player.cpp +++ b/src/game/Player.cpp @@ -4921,11 +4921,11 @@ void Player::LeftChannel(Channel *c) void Player::CleanupChannels() { - while(!m_channels.empty()) + while (!m_channels.empty()) { Channel* ch = *m_channels.begin(); m_channels.erase(m_channels.begin()); // remove from player's channel list - ch->Leave(GetGUID(), false); // not send to client, not remove from player's channel list + ch->Leave(GetObjectGuid(), false); // not send to client, not remove from player's channel list if (ChannelMgr* cMgr = channelMgr(GetTeam())) cMgr->LeftChannel(ch->GetName()); // deleted channel if empty @@ -4968,12 +4968,12 @@ void Player::UpdateLocalChannels(uint32 newZone ) snprintf(new_channel_name_buf,100,ch->pattern[m_session->GetSessionDbcLocale()],current_zone_name.c_str()); Channel* new_channel = cMgr->GetJoinChannel(new_channel_name_buf,ch->ChannelID); - if((*i)!=new_channel) + if ((*i)!=new_channel) { - new_channel->Join(GetGUID(),""); // will output Changed Channel: N. Name + new_channel->Join(GetObjectGuid(),""); // will output Changed Channel: N. Name // leave old channel - (*i)->Leave(GetGUID(),false); // not send leave channel, it already replaced at client + (*i)->Leave(GetObjectGuid(),false); // not send leave channel, it already replaced at client std::string name = (*i)->GetName(); // store name, (*i)erase in LeftChannel LeftChannel(*i); // remove from player's channel list cMgr->LeftChannel(name); // delete if empty @@ -4986,9 +4986,9 @@ void Player::LeaveLFGChannel() { for(JoinedChannelsList::iterator i = m_channels.begin(); i != m_channels.end(); ++i ) { - if((*i)->IsLFG()) + if ((*i)->IsLFG()) { - (*i)->Leave(GetGUID()); + (*i)->Leave(GetObjectGuid()); break; } } @@ -19907,7 +19907,7 @@ void Player::UpdateVisibilityOf(WorldObject const* viewPoint, WorldObject* targe template inline void UpdateVisibilityOf_helper(ObjectGuidSet& s64, T* target) { - s64.insert(target->GetGUID()); + s64.insert(target->GetObjectGuid()); } template<> diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index bb84e0fbedf..a2d90ff8b60 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 "11467" + #define REVISION_NR "11468" #endif // __REVISION_NR_H__ From 46cf264e39dc57548a51ceff0a71855b20985a6a Mon Sep 17 00:00:00 2001 From: breakwater Date: Wed, 11 May 2011 18:42:17 +0600 Subject: [PATCH 36/43] [11469] Fix unapply of SPELL_AURA_MOD_THREAT auras when caster dies or logs off Signed-off-by: zergtmn --- src/game/SpellAuras.cpp | 5 ----- src/shared/revision_nr.h | 2 +- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/src/game/SpellAuras.cpp b/src/game/SpellAuras.cpp index 264de682fb7..dd8d57c3395 100644 --- a/src/game/SpellAuras.cpp +++ b/src/game/SpellAuras.cpp @@ -4579,11 +4579,6 @@ void Aura::HandleModThreat(bool apply, bool Real) if (!target->isAlive()) return; - Unit* caster = GetCaster(); - - if (!caster || !caster->isAlive()) - return; - int level_diff = 0; int multiplier = 0; switch (GetId()) diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index a2d90ff8b60..eb49df5a8f2 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 "11468" + #define REVISION_NR "11469" #endif // __REVISION_NR_H__ From 81e95a70ff6c1bf92b4b81f11e58e0e705abace3 Mon Sep 17 00:00:00 2001 From: VladimirMangos Date: Wed, 11 May 2011 21:32:50 +0400 Subject: [PATCH 37/43] [11470] Final cleanup uint64 guid cases Also drop logout player update fields cleanup that in any cases not saved. --- src/game/ArenaTeam.cpp | 2 +- src/game/BattleGround.cpp | 2 +- src/game/BattleGroundEY.h | 1 - src/game/BattleGroundHandler.cpp | 12 +++---- src/game/Channel.cpp | 16 ++++----- src/game/Channel.h | 10 +++--- src/game/CharacterHandler.cpp | 4 +-- src/game/Chat.cpp | 9 ++--- src/game/ChatHandler.cpp | 2 +- src/game/GroupHandler.cpp | 8 +++-- src/game/GuildHandler.cpp | 46 ++++++++++++------------ src/game/Level3.cpp | 2 +- src/game/Mail.cpp | 59 +++++++++++++++--------------- src/game/MiscHandler.cpp | 4 +-- src/game/MovementHandler.cpp | 6 ++-- src/game/Object.h | 2 +- src/game/ObjectMgr.cpp | 8 ++--- src/game/ObjectMgr.h | 2 +- src/game/PetHandler.cpp | 16 ++++----- src/game/Player.cpp | 62 ++++++++++++++++---------------- src/game/TradeHandler.cpp | 6 ++-- src/game/Unit.cpp | 2 +- src/game/WorldSession.cpp | 10 ------ src/game/WorldSession.h | 2 +- src/mangosd/CliRunnable.cpp | 2 +- src/shared/revision_nr.h | 2 +- 26 files changed, 144 insertions(+), 153 deletions(-) diff --git a/src/game/ArenaTeam.cpp b/src/game/ArenaTeam.cpp index 62b0451ec1e..033569c08af 100644 --- a/src/game/ArenaTeam.cpp +++ b/src/game/ArenaTeam.cpp @@ -545,7 +545,7 @@ uint8 ArenaTeam::GetSlotByType(ArenaType type ) bool ArenaTeam::HaveMember(ObjectGuid guid) const { for (MemberList::const_iterator itr = m_members.begin(); itr != m_members.end(); ++itr) - if(itr->guid == guid.GetRawValue()) + if(itr->guid == guid) return true; return false; diff --git a/src/game/BattleGround.cpp b/src/game/BattleGround.cpp index ed5eecbca1f..3c8993f8626 100644 --- a/src/game/BattleGround.cpp +++ b/src/game/BattleGround.cpp @@ -183,7 +183,7 @@ namespace MaNGOS data << uint32(0); // 2.1.0 data << uint32(strlen(i_source->GetName())+1); data << i_source->GetName(); - data << uint64(0); // Unit Target - isn't important for bgs + data << ObjectGuid(); // Unit Target - isn't important for bgs data << uint32(strlen(str)+1); data << str; data << uint8(0); // ChatTag - for bgs allways 0? diff --git a/src/game/BattleGroundEY.h b/src/game/BattleGroundEY.h index 907b59ea06e..b9fce80e418 100644 --- a/src/game/BattleGroundEY.h +++ b/src/game/BattleGroundEY.h @@ -263,7 +263,6 @@ class BattleGroundEY : public BattleGround void RespawnFlagAfterDrop(); void RemovePlayer(Player *plr, ObjectGuid guid); - void HandleBuffUse(uint64 const& buff_guid); void HandleAreaTrigger(Player *Source, uint32 Trigger); void HandleKillPlayer(Player *player, Player *killer); virtual WorldSafeLocsEntry const* GetClosestGraveYard(Player* player); diff --git a/src/game/BattleGroundHandler.cpp b/src/game/BattleGroundHandler.cpp index db8e8863646..9a450df3f0e 100644 --- a/src/game/BattleGroundHandler.cpp +++ b/src/game/BattleGroundHandler.cpp @@ -239,14 +239,14 @@ void WorldSession::HandleBattleGroundPlayerPositionsOpcode( WorldPacket & /*recv ++count2; WorldPacket data(MSG_BATTLEGROUND_PLAYER_POSITIONS, (4+4+16*count1+16*count2)); - data << count1; // alliance flag holders count - obsolete, now always 0 + data << count1; // alliance flag holders count - obsolete, now always 0 /*for(uint8 i = 0; i < count1; ++i) { - data << uint64(0); // guid - data << (float)0; // x - data << (float)0; // y + data << ObjectGuid(0); // guid + data << (float)0; // x + data << (float)0; // y }*/ - data << count2; // horde flag holders count - obsolete, now count of next fields + data << count2; // horde flag holders count - obsolete, now count of next fields if (ali_plr) { data << ObjectGuid(ali_plr->GetObjectGuid()); @@ -785,7 +785,7 @@ void WorldSession::HandleBattlemasterJoinArena( WorldPacket & recv_data ) void WorldSession::HandleReportPvPAFK( WorldPacket & recv_data ) { - uint64 playerGuid; + ObjectGuid playerGuid; recv_data >> playerGuid; Player *reportedPlayer = sObjectMgr.GetPlayer(playerGuid); diff --git a/src/game/Channel.cpp b/src/game/Channel.cpp index 7302f3d45ac..cfe3ca0c2fc 100644 --- a/src/game/Channel.cpp +++ b/src/game/Channel.cpp @@ -672,12 +672,12 @@ void Channel::SendToOne(WorldPacket *data, ObjectGuid who) plr->GetSession()->SendPacket(data); } -void Channel::Voice(uint64 /*guid1*/, uint64 /*guid2*/) +void Channel::Voice(ObjectGuid /*guid1*/, ObjectGuid /*guid2*/) { } -void Channel::DeVoice(uint64 /*guid1*/, uint64 /*guid2*/) +void Channel::DeVoice(ObjectGuid /*guid1*/, ObjectGuid /*guid2*/) { } @@ -904,10 +904,10 @@ void Channel::MakePlayerInvited(WorldPacket *data, const std::string& name) } // done 0x1E -void Channel::MakePlayerInviteBanned(WorldPacket *data, uint64 guid) +void Channel::MakePlayerInviteBanned(WorldPacket *data, ObjectGuid guid) { MakeNotifyPacket(data, CHAT_PLAYER_INVITE_BANNED_NOTICE); - *data << uint64(guid); // should be string!! + *data << ObjectGuid(guid); // should be string!! } // done 0x1F @@ -929,17 +929,17 @@ void Channel::MakeNotInLfg(WorldPacket *data) } // done 0x22 -void Channel::MakeVoiceOn(WorldPacket *data, uint64 guid) +void Channel::MakeVoiceOn(WorldPacket *data, ObjectGuid guid) { MakeNotifyPacket(data, CHAT_VOICE_ON_NOTICE); - *data << uint64(guid); + *data << ObjectGuid(guid); } // done 0x23 -void Channel::MakeVoiceOff(WorldPacket *data, uint64 guid) +void Channel::MakeVoiceOff(WorldPacket *data, ObjectGuid guid) { MakeNotifyPacket(data, CHAT_VOICE_OFF_NOTICE); - *data << uint64(guid); + *data << ObjectGuid(guid); } void Channel::JoinNotify(ObjectGuid guid) diff --git a/src/game/Channel.h b/src/game/Channel.h index 687f6ad79c8..5327249cfa4 100644 --- a/src/game/Channel.h +++ b/src/game/Channel.h @@ -180,8 +180,8 @@ class Channel void Moderate(ObjectGuid p); void Say(ObjectGuid p, const char *what, uint32 lang); void Invite(ObjectGuid p, const char *newp); - void Voice(uint64 guid1, uint64 guid2); - void DeVoice(uint64 guid1, uint64 guid2); + void Voice(ObjectGuid guid1, ObjectGuid guid2); + void DeVoice(ObjectGuid guid1, ObjectGuid guid2); void JoinNotify(ObjectGuid guid); // invisible notify void LeaveNotify(ObjectGuid guid); // invisible notify @@ -219,12 +219,12 @@ class Channel void MakeInvalidName(WorldPacket *data); //? 0x1B void MakeNotModerated(WorldPacket *data); //? 0x1C void MakePlayerInvited(WorldPacket *data, const std::string& name); //+ 0x1D - void MakePlayerInviteBanned(WorldPacket *data, uint64 guid); //? 0x1E + void MakePlayerInviteBanned(WorldPacket *data, ObjectGuid guid); //? 0x1E void MakeThrottled(WorldPacket *data); //? 0x1F void MakeNotInArea(WorldPacket *data); //? 0x20 void MakeNotInLfg(WorldPacket *data); //? 0x21 - void MakeVoiceOn(WorldPacket *data, uint64 guid); //+ 0x22 - void MakeVoiceOff(WorldPacket *data, uint64 guid); //+ 0x23 + void MakeVoiceOn(WorldPacket *data, ObjectGuid guid); //+ 0x22 + void MakeVoiceOff(WorldPacket *data, ObjectGuid guid); //+ 0x23 void SendToAll(WorldPacket *data, ObjectGuid p = ObjectGuid()); void SendToOne(WorldPacket *data, ObjectGuid who); diff --git a/src/game/CharacterHandler.cpp b/src/game/CharacterHandler.cpp index 37a03a67141..70b8cf201a3 100644 --- a/src/game/CharacterHandler.cpp +++ b/src/game/CharacterHandler.cpp @@ -286,7 +286,7 @@ void WorldSession::HandleCharCreateOpcode( WorldPacket & recv_data ) return; } - if (sObjectMgr.GetPlayerGUIDByName(name)) + if (!sObjectMgr.GetPlayerGuidByName(name).IsEmpty()) { data << (uint8)CHAR_CREATE_NAME_IN_USE; SendPacket( &data ); @@ -1182,7 +1182,7 @@ void WorldSession::HandleCharCustomizeOpcode(WorldPacket& recv_data) } // character with this name already exist - ObjectGuid newguid = sObjectMgr.GetPlayerGUIDByName(newname); + ObjectGuid newguid = sObjectMgr.GetPlayerGuidByName(newname); if (!newguid.IsEmpty() && newguid != guid) { WorldPacket data(SMSG_CHAR_CUSTOMIZE, 1); diff --git a/src/game/Chat.cpp b/src/game/Chat.cpp index 4bee5f94420..8a6db3ef95b 100644 --- a/src/game/Chat.cpp +++ b/src/game/Chat.cpp @@ -2896,10 +2896,7 @@ ObjectGuid ChatHandler::ExtractGuidFromLink(char** text) if (Player* player = sObjectMgr.GetPlayer(name.c_str())) return player->GetObjectGuid(); - if (uint64 guid = sObjectMgr.GetPlayerGUIDByName(name)) - return ObjectGuid(guid); - - return ObjectGuid(); + return sObjectMgr.GetPlayerGuidByName(name); } case GUID_LINK_CREATURE: { @@ -2992,7 +2989,7 @@ bool ChatHandler::ExtractLocationFromLink(char** text, uint32& mapid, float& x, return true; } - ObjectGuid guid = sObjectMgr.GetPlayerGUIDByName(name); + ObjectGuid guid = sObjectMgr.GetPlayerGuidByName(name); if (!guid.IsEmpty()) { // to point where player stay (if loaded) @@ -3218,7 +3215,7 @@ bool ChatHandler::ExtractPlayerTarget(char** args, Player** player /*= NULL*/, O *player = pl; // if need guid value from DB (in name case for check player existence) - ObjectGuid guid = !pl && (player_guid || player_name) ? sObjectMgr.GetPlayerGUIDByName(name) : uint64(0); + ObjectGuid guid = !pl && (player_guid || player_name) ? sObjectMgr.GetPlayerGuidByName(name) : ObjectGuid(); // if allowed player guid (if no then only online players allowed) if(player_guid) diff --git a/src/game/ChatHandler.cpp b/src/game/ChatHandler.cpp index c7eeadafa30..94119d0d5c7 100644 --- a/src/game/ChatHandler.cpp +++ b/src/game/ChatHandler.cpp @@ -597,7 +597,7 @@ void WorldSession::HandleTextEmoteOpcode( WorldPacket & recv_data ) void WorldSession::HandleChatIgnoredOpcode(WorldPacket& recv_data ) { - uint64 iguid; + ObjectGuid iguid; uint8 unk; //DEBUG_LOG("WORLD: Received CMSG_CHAT_IGNORED"); diff --git a/src/game/GroupHandler.cpp b/src/game/GroupHandler.cpp index 33cad559b54..64758254b73 100644 --- a/src/game/GroupHandler.cpp +++ b/src/game/GroupHandler.cpp @@ -544,8 +544,12 @@ void WorldSession::HandleGroupChangeSubGroupOpcode( WorldPacket & recv_data ) // everything is fine, do it if (Player* player = sObjectMgr.GetPlayer(name.c_str())) group->ChangeMembersGroup(player, groupNr); - else if (uint64 guid = sObjectMgr.GetPlayerGUIDByName(name.c_str())) - group->ChangeMembersGroup(guid, groupNr); + else + { + ObjectGuid guid = sObjectMgr.GetPlayerGuidByName(name.c_str()); + if (!guid.IsEmpty()) + group->ChangeMembersGroup(guid, groupNr); + } } void WorldSession::HandleGroupAssistantLeaderOpcode( WorldPacket & recv_data ) diff --git a/src/game/GuildHandler.cpp b/src/game/GuildHandler.cpp index 72b27243a0c..3e3a9c0943b 100644 --- a/src/game/GuildHandler.cpp +++ b/src/game/GuildHandler.cpp @@ -805,11 +805,11 @@ void WorldSession::HandleGuildBankerActivate( WorldPacket & recv_data ) { DEBUG_LOG("WORLD: Received (CMSG_GUILD_BANKER_ACTIVATE)"); - uint64 GoGuid; + ObjectGuid goGuid; uint8 unk; - recv_data >> GoGuid >> unk; + recv_data >> goGuid >> unk; - if (!GetPlayer()->GetGameObjectIfCanInteractWith(GoGuid, GAMEOBJECT_TYPE_GUILD_BANK)) + if (!GetPlayer()->GetGameObjectIfCanInteractWith(goGuid, GAMEOBJECT_TYPE_GUILD_BANK)) return; if (uint32 GuildId = GetPlayer()->GetGuildId()) @@ -829,11 +829,11 @@ void WorldSession::HandleGuildBankQueryTab( WorldPacket & recv_data ) { DEBUG_LOG("WORLD: Received (CMSG_GUILD_BANK_QUERY_TAB)"); - uint64 GoGuid; + ObjectGuid goGuid; uint8 TabId, unk1; - recv_data >> GoGuid >> TabId >> unk1; + recv_data >> goGuid >> TabId >> unk1; - if (!GetPlayer()->GetGameObjectIfCanInteractWith(GoGuid, GAMEOBJECT_TYPE_GUILD_BANK)) + if (!GetPlayer()->GetGameObjectIfCanInteractWith(goGuid, GAMEOBJECT_TYPE_GUILD_BANK)) return; uint32 GuildId = GetPlayer()->GetGuildId(); @@ -857,14 +857,14 @@ void WorldSession::HandleGuildBankDepositMoney( WorldPacket & recv_data ) { DEBUG_LOG("WORLD: Received (CMSG_GUILD_BANK_DEPOSIT_MONEY)"); - uint64 GoGuid; + ObjectGuid goGuid; uint32 money; - recv_data >> GoGuid >> money; + recv_data >> goGuid >> money; if (!money) return; - if (!GetPlayer()->GetGameObjectIfCanInteractWith(GoGuid, GAMEOBJECT_TYPE_GUILD_BANK)) + if (!GetPlayer()->GetGameObjectIfCanInteractWith(goGuid, GAMEOBJECT_TYPE_GUILD_BANK)) return; if (GetPlayer()->GetMoney() < money) @@ -908,14 +908,14 @@ void WorldSession::HandleGuildBankWithdrawMoney( WorldPacket & recv_data ) { DEBUG_LOG("WORLD: Received (CMSG_GUILD_BANK_WITHDRAW_MONEY)"); - uint64 GoGuid; + ObjectGuid goGuid; uint32 money; - recv_data >> GoGuid >> money; + recv_data >> goGuid >> money; if (!money) return; - if (!GetPlayer()->GetGameObjectIfCanInteractWith(GoGuid, GAMEOBJECT_TYPE_GUILD_BANK)) + if (!GetPlayer()->GetGameObjectIfCanInteractWith(goGuid, GAMEOBJECT_TYPE_GUILD_BANK)) return; uint32 GuildId = GetPlayer()->GetGuildId(); @@ -961,7 +961,7 @@ void WorldSession::HandleGuildBankSwapItems( WorldPacket & recv_data ) { DEBUG_LOG("WORLD: Received (CMSG_GUILD_BANK_SWAP_ITEMS)"); - uint64 GoGuid; + ObjectGuid goGuid; uint8 BankToBank; uint8 BankTab, BankTabSlot, AutoStore; @@ -973,7 +973,7 @@ void WorldSession::HandleGuildBankSwapItems( WorldPacket & recv_data ) uint32 AutoStoreCount = 0; uint32 SplitedAmount = 0; - recv_data >> GoGuid >> BankToBank; + recv_data >> goGuid >> BankToBank; uint32 GuildId = GetPlayer()->GetGuildId(); if (!GuildId) @@ -1037,7 +1037,7 @@ void WorldSession::HandleGuildBankSwapItems( WorldPacket & recv_data ) } } - if (!GetPlayer()->GetGameObjectIfCanInteractWith(GoGuid, GAMEOBJECT_TYPE_GUILD_BANK)) + if (!GetPlayer()->GetGameObjectIfCanInteractWith(goGuid, GAMEOBJECT_TYPE_GUILD_BANK)) return; // Bank <-> Bank @@ -1067,13 +1067,13 @@ void WorldSession::HandleGuildBankBuyTab( WorldPacket & recv_data ) { DEBUG_LOG("WORLD: Received (CMSG_GUILD_BANK_BUY_TAB)"); - uint64 GoGuid; + ObjectGuid goGuid; uint8 TabId; - recv_data >> GoGuid; + recv_data >> goGuid; recv_data >> TabId; - if (!GetPlayer()->GetGameObjectIfCanInteractWith(GoGuid, GAMEOBJECT_TYPE_GUILD_BANK)) + if (!GetPlayer()->GetGameObjectIfCanInteractWith(goGuid, GAMEOBJECT_TYPE_GUILD_BANK)) return; uint32 GuildId = GetPlayer()->GetGuildId(); @@ -1107,23 +1107,23 @@ void WorldSession::HandleGuildBankUpdateTab( WorldPacket & recv_data ) { DEBUG_LOG("WORLD: Received (CMSG_GUILD_BANK_UPDATE_TAB)"); - uint64 GoGuid; + ObjectGuid goGuid; uint8 TabId; std::string Name; std::string IconIndex; - recv_data >> GoGuid; + recv_data >> goGuid; recv_data >> TabId; recv_data >> Name; recv_data >> IconIndex; - if(Name.empty()) + if (Name.empty()) return; - if(IconIndex.empty()) + if (IconIndex.empty()) return; - if (!GetPlayer()->GetGameObjectIfCanInteractWith(GoGuid, GAMEOBJECT_TYPE_GUILD_BANK)) + if (!GetPlayer()->GetGameObjectIfCanInteractWith(goGuid, GAMEOBJECT_TYPE_GUILD_BANK)) return; uint32 GuildId = GetPlayer()->GetGuildId(); diff --git a/src/game/Level3.cpp b/src/game/Level3.cpp index 3f681c08644..229e458bae8 100644 --- a/src/game/Level3.cpp +++ b/src/game/Level3.cpp @@ -5862,7 +5862,7 @@ bool ChatHandler::HandlePDumpWriteCommand(char *args) return false; } - guid = sObjectMgr.GetPlayerGUIDByName(name); + guid = sObjectMgr.GetPlayerGuidByName(name); if (guid.IsEmpty()) { PSendSysMessage(LANG_PLAYER_NOT_FOUND); diff --git a/src/game/Mail.cpp b/src/game/Mail.cpp index d50e29275c1..661a1c1e95f 100644 --- a/src/game/Mail.cpp +++ b/src/game/Mail.cpp @@ -60,11 +60,12 @@ */ void WorldSession::HandleSendMail(WorldPacket & recv_data ) { - uint64 mailbox, unk3; + ObjectGuid mailboxGuid; + uint64 unk3; std::string receiver, subject, body; uint32 unk1, unk2, money, COD; uint8 unk4; - recv_data >> mailbox; + recv_data >> mailboxGuid; recv_data >> receiver; recv_data >> subject; @@ -84,12 +85,12 @@ void WorldSession::HandleSendMail(WorldPacket & recv_data ) return; } - uint64 itemGUIDs[MAX_MAIL_ITEMS]; + ObjectGuid itemGuids[MAX_MAIL_ITEMS]; for(uint8 i = 0; i < items_count; ++i) { recv_data.read_skip(); // item slot in mail, not used - recv_data >> itemGUIDs[i]; + recv_data >> itemGuids[i]; } recv_data >> money >> COD; // money and cod @@ -98,7 +99,7 @@ void WorldSession::HandleSendMail(WorldPacket & recv_data ) // packet read complete, now do check - if (!GetPlayer()->GetGameObjectIfCanInteractWith(mailbox, GAMEOBJECT_TYPE_MAILBOX)) + if (!GetPlayer()->GetGameObjectIfCanInteractWith(mailboxGuid, GAMEOBJECT_TYPE_MAILBOX)) return; if (receiver.empty()) @@ -108,7 +109,7 @@ void WorldSession::HandleSendMail(WorldPacket & recv_data ) ObjectGuid rc; if (normalizePlayerName(receiver)) - rc = sObjectMgr.GetPlayerGUIDByName(receiver); + rc = sObjectMgr.GetPlayerGuidByName(receiver); if (rc.IsEmpty()) { @@ -180,13 +181,13 @@ void WorldSession::HandleSendMail(WorldPacket & recv_data ) for(uint8 i = 0; i < items_count; ++i) { - if (!itemGUIDs[i]) + if (!itemGuids[i].IsItem()) { pl->SendMailResult(0, MAIL_SEND, MAIL_ERR_MAIL_ATTACHMENT_INVALID); return; } - Item* item = pl->GetItemByGuid(itemGUIDs[i]); + Item* item = pl->GetItemByGuid(itemGuids[i]); // prevent sending bag with items (cheat: can be placed in bag after adding equipped empty bag to mail) if(!item) @@ -293,12 +294,12 @@ void WorldSession::HandleSendMail(WorldPacket & recv_data ) */ void WorldSession::HandleMailMarkAsRead(WorldPacket & recv_data ) { - uint64 mailbox; + ObjectGuid mailboxGuid; uint32 mailId; - recv_data >> mailbox; + recv_data >> mailboxGuid; recv_data >> mailId; - if (!GetPlayer()->GetGameObjectIfCanInteractWith(mailbox, GAMEOBJECT_TYPE_MAILBOX)) + if (!GetPlayer()->GetGameObjectIfCanInteractWith(mailboxGuid, GAMEOBJECT_TYPE_MAILBOX)) return; Player *pl = _player; @@ -323,13 +324,13 @@ void WorldSession::HandleMailMarkAsRead(WorldPacket & recv_data ) */ void WorldSession::HandleMailDelete(WorldPacket & recv_data ) { - uint64 mailbox; + ObjectGuid mailboxGuid; uint32 mailId; - recv_data >> mailbox; + recv_data >> mailboxGuid; recv_data >> mailId; recv_data.read_skip(); // mailTemplateId - if (!GetPlayer()->GetGameObjectIfCanInteractWith(mailbox, GAMEOBJECT_TYPE_MAILBOX)) + if (!GetPlayer()->GetGameObjectIfCanInteractWith(mailboxGuid, GAMEOBJECT_TYPE_MAILBOX)) return; Player* pl = _player; @@ -359,13 +360,13 @@ void WorldSession::HandleMailDelete(WorldPacket & recv_data ) */ void WorldSession::HandleMailReturnToSender(WorldPacket & recv_data ) { - uint64 mailbox; + ObjectGuid mailboxGuid; uint32 mailId; - recv_data >> mailbox; + recv_data >> mailboxGuid; recv_data >> mailId; recv_data.read_skip(); // original sender GUID for return to, not used - if (!GetPlayer()->GetGameObjectIfCanInteractWith(mailbox, GAMEOBJECT_TYPE_MAILBOX)) + if (!GetPlayer()->GetGameObjectIfCanInteractWith(mailboxGuid, GAMEOBJECT_TYPE_MAILBOX)) return; Player *pl = _player; @@ -417,14 +418,14 @@ void WorldSession::HandleMailReturnToSender(WorldPacket & recv_data ) */ void WorldSession::HandleMailTakeItem(WorldPacket & recv_data ) { - uint64 mailbox; + ObjectGuid mailboxGuid; uint32 mailId; uint32 itemId; - recv_data >> mailbox; + recv_data >> mailboxGuid; recv_data >> mailId; recv_data >> itemId; // item guid low - if (!GetPlayer()->GetGameObjectIfCanInteractWith(mailbox, GAMEOBJECT_TYPE_MAILBOX)) + if (!GetPlayer()->GetGameObjectIfCanInteractWith(mailboxGuid, GAMEOBJECT_TYPE_MAILBOX)) return; Player* pl = _player; @@ -514,12 +515,12 @@ void WorldSession::HandleMailTakeItem(WorldPacket & recv_data ) */ void WorldSession::HandleMailTakeMoney(WorldPacket & recv_data ) { - uint64 mailbox; + ObjectGuid mailboxGuid; uint32 mailId; - recv_data >> mailbox; + recv_data >> mailboxGuid; recv_data >> mailId; - if (!GetPlayer()->GetGameObjectIfCanInteractWith(mailbox, GAMEOBJECT_TYPE_MAILBOX)) + if (!GetPlayer()->GetGameObjectIfCanInteractWith(mailboxGuid, GAMEOBJECT_TYPE_MAILBOX)) return; Player *pl = _player; @@ -551,10 +552,10 @@ void WorldSession::HandleMailTakeMoney(WorldPacket & recv_data ) */ void WorldSession::HandleGetMailList(WorldPacket & recv_data ) { - uint64 mailbox; - recv_data >> mailbox; + ObjectGuid mailboxGuid; + recv_data >> mailboxGuid; - if (!GetPlayer()->GetGameObjectIfCanInteractWith(mailbox, GAMEOBJECT_TYPE_MAILBOX)) + if (!GetPlayer()->GetGameObjectIfCanInteractWith(mailboxGuid, GAMEOBJECT_TYPE_MAILBOX)) return; // client can't work with packets > max int16 value @@ -677,13 +678,13 @@ void WorldSession::HandleGetMailList(WorldPacket & recv_data ) */ void WorldSession::HandleMailCreateTextItem(WorldPacket & recv_data ) { - uint64 mailbox; + ObjectGuid mailboxGuid; uint32 mailId; - recv_data >> mailbox; + recv_data >> mailboxGuid; recv_data >> mailId; - if (!GetPlayer()->GetGameObjectIfCanInteractWith(mailbox, GAMEOBJECT_TYPE_MAILBOX)) + if (!GetPlayer()->GetGameObjectIfCanInteractWith(mailboxGuid, GAMEOBJECT_TYPE_MAILBOX)) return; Player *pl = _player; diff --git a/src/game/MiscHandler.cpp b/src/game/MiscHandler.cpp index c47b03ca246..dd399a38e95 100644 --- a/src/game/MiscHandler.cpp +++ b/src/game/MiscHandler.cpp @@ -505,7 +505,7 @@ void WorldSession::HandleAddFriendOpcodeCallBack(QueryResult *result, uint32 acc void WorldSession::HandleDelFriendOpcode( WorldPacket & recv_data ) { - uint64 friendGuid; + ObjectGuid friendGuid; DEBUG_LOG( "WORLD: Received CMSG_DEL_FRIEND" ); @@ -575,7 +575,7 @@ void WorldSession::HandleAddIgnoreOpcodeCallBack(QueryResult *result, uint32 acc void WorldSession::HandleDelIgnoreOpcode( WorldPacket & recv_data ) { - uint64 ignoreGuid; + ObjectGuid ignoreGuid; DEBUG_LOG( "WORLD: Received CMSG_DEL_IGNORE" ); diff --git a/src/game/MovementHandler.cpp b/src/game/MovementHandler.cpp index ea77930c748..29eb7018afe 100644 --- a/src/game/MovementHandler.cpp +++ b/src/game/MovementHandler.cpp @@ -500,12 +500,12 @@ void WorldSession::HandleMoveWaterWalkAck(WorldPacket& recv_data) void WorldSession::HandleSummonResponseOpcode(WorldPacket& recv_data) { - if(!_player->isAlive() || _player->isInCombat() ) + if (!_player->isAlive() || _player->isInCombat()) return; - uint64 summoner_guid; + ObjectGuid summonerGuid; bool agree; - recv_data >> summoner_guid; + recv_data >> summonerGuid; recv_data >> agree; _player->SummonIfPossible(agree); diff --git a/src/game/Object.h b/src/game/Object.h index 286024d5eb5..ab96b09f10a 100644 --- a/src/game/Object.h +++ b/src/game/Object.h @@ -138,7 +138,7 @@ class MANGOS_DLL_SPEC Object } ObjectGuid const& GetObjectGuid() const { return GetGuidValue(OBJECT_FIELD_GUID); } - const uint64& GetGUID() const { return GetUInt64Value(OBJECT_FIELD_GUID); } // DEPRICATED, not use, will removed soon + const uint64& GetGUID() const { return GetUInt64Value(OBJECT_FIELD_GUID); } // DEPRECATED, not use, will removed soon uint32 GetGUIDLow() const { return GetObjectGuid().GetCounter(); } PackedGuid const& GetPackGUID() const { return m_PackGUID; } std::string GetGuidStr() const { return GetObjectGuid().GetString(); } diff --git a/src/game/ObjectMgr.cpp b/src/game/ObjectMgr.cpp index a7dc39248ee..7173b271a14 100644 --- a/src/game/ObjectMgr.cpp +++ b/src/game/ObjectMgr.cpp @@ -1583,17 +1583,17 @@ void ObjectMgr::RemoveGameobjectFromGrid(uint32 guid, GameObjectData const* data } // name must be checked to correctness (if received) before call this function -uint64 ObjectMgr::GetPlayerGUIDByName(std::string name) const +ObjectGuid ObjectMgr::GetPlayerGuidByName(std::string name) const { - uint64 guid = 0; + ObjectGuid guid; CharacterDatabase.escape_string(name); // Player name safe to sending to DB (checked at login) and this function using QueryResult *result = CharacterDatabase.PQuery("SELECT guid FROM characters WHERE name = '%s'", name.c_str()); - if(result) + if (result) { - guid = ObjectGuid(HIGHGUID_PLAYER, (*result)[0].GetUInt32()).GetRawValue(); + guid = ObjectGuid(HIGHGUID_PLAYER, (*result)[0].GetUInt32()); delete result; } diff --git a/src/game/ObjectMgr.h b/src/game/ObjectMgr.h index 2cb99cafeed..da595bc9e32 100644 --- a/src/game/ObjectMgr.h +++ b/src/game/ObjectMgr.h @@ -522,7 +522,7 @@ class ObjectMgr } void GetPlayerLevelInfo(uint32 race, uint32 class_,uint32 level, PlayerLevelInfo* info) const; - uint64 GetPlayerGUIDByName(std::string name) const; + ObjectGuid GetPlayerGuidByName(std::string name) const; bool GetPlayerNameByGUID(ObjectGuid guid, std::string &name) const; Team GetPlayerTeamByGUID(ObjectGuid guid) const; uint32 GetPlayerAccountIdByGUID(ObjectGuid guid) const; diff --git a/src/game/PetHandler.cpp b/src/game/PetHandler.cpp index 8d8e6fe38f7..d1e954c0d9d 100644 --- a/src/game/PetHandler.cpp +++ b/src/game/PetHandler.cpp @@ -302,7 +302,7 @@ void WorldSession::HandlePetNameQueryOpcode(WorldPacket& recv_data) DETAIL_LOG("HandlePetNameQuery. CMSG_PET_NAME_QUERY"); uint32 petnumber; - uint64 petguid; + ObjectGuid petguid; recv_data >> petnumber; recv_data >> petguid; @@ -310,7 +310,7 @@ void WorldSession::HandlePetNameQueryOpcode(WorldPacket& recv_data) SendPetNameQuery(petguid, petnumber); } -void WorldSession::SendPetNameQuery(uint64 petguid, uint32 petnumber) +void WorldSession::SendPetNameQuery(ObjectGuid petguid, uint32 petnumber) { Creature* pet = _player->GetMap()->GetAnyTypeCreature(petguid); if (!pet || !pet->GetCharmInfo() || pet->GetCharmInfo()->GetPetNumber() != petnumber) @@ -347,12 +347,12 @@ void WorldSession::HandlePetSetAction(WorldPacket& recv_data) { DETAIL_LOG("HandlePetSetAction. CMSG_PET_SET_ACTION"); - uint64 petguid; + ObjectGuid petGuid; uint8 count; - recv_data >> petguid; + recv_data >> petGuid; - Creature* pet = _player->GetMap()->GetAnyTypeCreature(petguid); + Creature* pet = _player->GetMap()->GetAnyTypeCreature(petGuid); if (!pet || (pet != _player->GetPet() && pet != _player->GetCharm())) { @@ -460,17 +460,17 @@ void WorldSession::HandlePetRename(WorldPacket& recv_data) { DETAIL_LOG("HandlePetRename. CMSG_PET_RENAME"); - uint64 petguid; + ObjectGuid petGuid; uint8 isdeclined; std::string name; DeclinedName declinedname; - recv_data >> petguid; + recv_data >> petGuid; recv_data >> name; recv_data >> isdeclined; - Pet* pet = _player->GetMap()->GetPet(petguid); + Pet* pet = _player->GetMap()->GetPet(petGuid); // check it! if (!pet || pet->getPetType() != HUNTER_PET || !pet->HasByteFlag(UNIT_FIELD_BYTES_2, 2, UNIT_CAN_BE_RENAMED) || diff --git a/src/game/Player.cpp b/src/game/Player.cpp index c224d269fd3..6201bdbefe6 100644 --- a/src/game/Player.cpp +++ b/src/game/Player.cpp @@ -11394,7 +11394,7 @@ void Player::RemoveItem( uint8 bag, uint8 slot, bool update ) UpdateKnownCurrencies(pItem->GetEntry(), false); m_items[slot] = NULL; - SetUInt64Value(PLAYER_FIELD_INV_SLOT_HEAD + (slot * 2), 0); + SetGuidValue(PLAYER_FIELD_INV_SLOT_HEAD + (slot * 2), ObjectGuid()); if ( slot < EQUIPMENT_SLOT_END ) { @@ -11486,7 +11486,7 @@ void Player::DestroyItem( uint8 bag, uint8 slot, bool update ) if( bag == INVENTORY_SLOT_BAG_0 ) { - SetUInt64Value(PLAYER_FIELD_INV_SLOT_HEAD + (slot * 2), 0); + SetGuidValue(PLAYER_FIELD_INV_SLOT_HEAD + (slot * 2), ObjectGuid()); // equipment and equipped bags can have applied bonuses if ( slot < INVENTORY_SLOT_BAG_END ) @@ -12231,9 +12231,9 @@ void Player::RemoveItemFromBuyBackSlot( uint32 slot, bool del ) m_items[slot] = NULL; uint32 eslot = slot - BUYBACK_SLOT_START; - SetUInt64Value( PLAYER_FIELD_VENDORBUYBACK_SLOT_1 + (eslot * 2), 0 ); - SetUInt32Value( PLAYER_FIELD_BUYBACK_PRICE_1 + eslot, 0 ); - SetUInt32Value( PLAYER_FIELD_BUYBACK_TIMESTAMP_1 + eslot, 0 ); + SetGuidValue(PLAYER_FIELD_VENDORBUYBACK_SLOT_1 + (eslot * 2), ObjectGuid()); + SetUInt32Value(PLAYER_FIELD_BUYBACK_PRICE_1 + eslot, 0); + SetUInt32Value(PLAYER_FIELD_BUYBACK_TIMESTAMP_1 + eslot, 0); // if current backslot is filled set to now free slot if (m_items[m_currentBuybackSlot]) @@ -15372,7 +15372,7 @@ bool Player::LoadFromDB(ObjectGuid guid, SqlQueryHolder *holder ) // cleanup inventory related item value fields (its will be filled correctly in _LoadInventory) for(uint8 slot = EQUIPMENT_SLOT_START; slot < EQUIPMENT_SLOT_END; ++slot) { - SetUInt64Value( PLAYER_FIELD_INV_SLOT_HEAD + (slot * 2), 0 ); + SetGuidValue(PLAYER_FIELD_INV_SLOT_HEAD + (slot * 2), ObjectGuid()); SetVisibleItemSlot(slot, NULL); if (m_items[slot]) @@ -15960,7 +15960,7 @@ void Player::_LoadAuras(QueryResult *result, uint32 timediff) do { Field *fields = result->Fetch(); - ObjectGuid caster_guid = fields[0].GetUInt64(); + ObjectGuid caster_guid = ObjectGuid(fields[0].GetUInt64()); uint32 item_lowguid = fields[1].GetUInt32(); uint32 spellid = fields[2].GetUInt32(); uint32 stackcount = fields[3].GetUInt32(); @@ -16112,7 +16112,7 @@ void Player::LoadCorpse() void Player::_LoadInventory(QueryResult *result, uint32 timediff) { //QueryResult *result = CharacterDatabase.PQuery("SELECT data,text,bag,slot,item,item_template FROM character_inventory JOIN item_instance ON character_inventory.item = item_instance.guid WHERE character_inventory.guid = '%u' ORDER BY bag,slot", GetGUIDLow()); - std::map bagMap; // fast guid lookup for bags + std::map bagMap; // fast guid lookup for bags //NOTE: the "order by `bag`" is important because it makes sure //the bagMap is filled before items in the bags are loaded //NOTE2: the "order by `slot`" is needed because mainhand weapons are (wrongly?) @@ -16131,34 +16131,34 @@ void Player::_LoadInventory(QueryResult *result, uint32 timediff) Field *fields = result->Fetch(); uint32 bag_guid = fields[2].GetUInt32(); uint8 slot = fields[3].GetUInt8(); - uint32 item_guid = fields[4].GetUInt32(); + uint32 item_lowguid = fields[4].GetUInt32(); uint32 item_id = fields[5].GetUInt32(); ItemPrototype const * proto = ObjectMgr::GetItemPrototype(item_id); - if(!proto) + if (!proto) { - CharacterDatabase.PExecute("DELETE FROM character_inventory WHERE item = '%u'", item_guid); - CharacterDatabase.PExecute("DELETE FROM item_instance WHERE guid = '%u'", item_guid); + CharacterDatabase.PExecute("DELETE FROM character_inventory WHERE item = '%u'", item_lowguid); + CharacterDatabase.PExecute("DELETE FROM item_instance WHERE guid = '%u'", item_lowguid); sLog.outError( "Player::_LoadInventory: Player %s has an unknown item (id: #%u) in inventory, deleted.", GetName(),item_id ); continue; } Item *item = NewItemOrBag(proto); - if(!item->LoadFromDB(item_guid, fields, GetObjectGuid())) + if (!item->LoadFromDB(item_lowguid, fields, GetObjectGuid())) { sLog.outError( "Player::_LoadInventory: Player %s has broken item (id: #%u) in inventory, deleted.", GetName(),item_id ); - CharacterDatabase.PExecute("DELETE FROM character_inventory WHERE item = '%u'", item_guid); + CharacterDatabase.PExecute("DELETE FROM character_inventory WHERE item = '%u'", item_lowguid); item->FSetState(ITEM_REMOVED); item->SaveToDB(); // it also deletes item object ! continue; } // not allow have in alive state item limited to another map/zone - if(isAlive() && item->IsLimitedToAnotherMapOrZone(GetMapId(),zone) ) + if (isAlive() && item->IsLimitedToAnotherMapOrZone(GetMapId(),zone)) { - CharacterDatabase.PExecute("DELETE FROM character_inventory WHERE item = '%u'", item_guid); + CharacterDatabase.PExecute("DELETE FROM character_inventory WHERE item = '%u'", item_lowguid); item->FSetState(ITEM_REMOVED); item->SaveToDB(); // it also deletes item object ! continue; @@ -16167,7 +16167,7 @@ void Player::_LoadInventory(QueryResult *result, uint32 timediff) // "Conjured items disappear if you are logged out for more than 15 minutes" if (timediff > 15*MINUTE && (item->GetProto()->Flags & ITEM_FLAG_CONJURED)) { - CharacterDatabase.PExecute("DELETE FROM character_inventory WHERE item = '%u'", item_guid); + CharacterDatabase.PExecute("DELETE FROM character_inventory WHERE item = '%u'", item_lowguid); item->FSetState(ITEM_REMOVED); item->SaveToDB(); // it also deletes item object ! continue; @@ -16181,36 +16181,36 @@ void Player::_LoadInventory(QueryResult *result, uint32 timediff) item->SetContainer( NULL ); item->SetSlot(slot); - if( IsInventoryPos( INVENTORY_SLOT_BAG_0, slot ) ) + if (IsInventoryPos( INVENTORY_SLOT_BAG_0, slot)) { ItemPosCountVec dest; - if( CanStoreItem( INVENTORY_SLOT_BAG_0, slot, dest, item, false ) == EQUIP_ERR_OK ) + if (CanStoreItem( INVENTORY_SLOT_BAG_0, slot, dest, item, false) == EQUIP_ERR_OK) item = StoreItem(dest, item, true); else success = false; } - else if( IsEquipmentPos( INVENTORY_SLOT_BAG_0, slot ) ) + else if (IsEquipmentPos( INVENTORY_SLOT_BAG_0, slot)) { uint16 dest; - if( CanEquipItem( slot, dest, item, false, false ) == EQUIP_ERR_OK ) + if (CanEquipItem( slot, dest, item, false, false ) == EQUIP_ERR_OK) QuickEquipItem(dest, item); else success = false; } - else if( IsBankPos( INVENTORY_SLOT_BAG_0, slot ) ) + else if (IsBankPos( INVENTORY_SLOT_BAG_0, slot)) { ItemPosCountVec dest; - if( CanBankItem( INVENTORY_SLOT_BAG_0, slot, dest, item, false, false ) == EQUIP_ERR_OK ) + if (CanBankItem( INVENTORY_SLOT_BAG_0, slot, dest, item, false, false ) == EQUIP_ERR_OK) item = BankItem(dest, item, true); else success = false; } - if(success) + if (success) { // store bags that may contain items in them - if(item->IsBag() && IsBagPos(item->GetPos())) - bagMap[item_guid] = (Bag*)item; + if (item->IsBag() && IsBagPos(item->GetPos())) + bagMap[item_lowguid] = (Bag*)item; } } // the item/bag in a bag @@ -16218,11 +16218,11 @@ void Player::_LoadInventory(QueryResult *result, uint32 timediff) { item->SetSlot(NULL_SLOT); // the item is in a bag, find the bag - std::map::const_iterator itr = bagMap.find(bag_guid); - if(itr != bagMap.end() && slot < itr->second->GetBagSize()) + std::map::const_iterator itr = bagMap.find(bag_guid); + if (itr != bagMap.end() && slot < itr->second->GetBagSize()) { ItemPosCountVec dest; - if( CanStoreItem( itr->second->GetSlot(), slot, dest, item, false ) == EQUIP_ERR_OK ) + if (CanStoreItem(itr->second->GetSlot(), slot, dest, item, false) == EQUIP_ERR_OK) item = StoreItem(dest, item, true); else success = false; @@ -16246,8 +16246,8 @@ void Player::_LoadInventory(QueryResult *result, uint32 timediff) } else { - sLog.outError("Player::_LoadInventory: Player %s has item (GUID: %u Entry: %u) can't be loaded to inventory (Bag GUID: %u Slot: %u) by some reason, will send by mail.", GetName(),item_guid, item_id, bag_guid, slot); - CharacterDatabase.PExecute("DELETE FROM character_inventory WHERE item = '%u'", item_guid); + sLog.outError("Player::_LoadInventory: Player %s has item (GUID: %u Entry: %u) can't be loaded to inventory (Bag GUID: %u Slot: %u) by some reason, will send by mail.", GetName(),item_lowguid, item_id, bag_guid, slot); + CharacterDatabase.PExecute("DELETE FROM character_inventory WHERE item = '%u'", item_lowguid); problematicItems.push_back(item); } } while (result->NextRow()); diff --git a/src/game/TradeHandler.cpp b/src/game/TradeHandler.cpp index 3bbe151ed89..7da647697f7 100644 --- a/src/game/TradeHandler.cpp +++ b/src/game/TradeHandler.cpp @@ -529,8 +529,8 @@ void WorldSession::HandleCancelTradeOpcode(WorldPacket& /*recvPacket*/) void WorldSession::HandleInitiateTradeOpcode(WorldPacket& recvPacket) { - uint64 ID; - recvPacket >> ID; + ObjectGuid otherGuid; + recvPacket >> otherGuid; if (GetPlayer()->m_trade) return; @@ -559,7 +559,7 @@ void WorldSession::HandleInitiateTradeOpcode(WorldPacket& recvPacket) return; } - Player* pOther = ObjectAccessor::FindPlayer( ID ); + Player* pOther = ObjectAccessor::FindPlayer( otherGuid ); if (!pOther) { diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp index f3e968ecef4..fd61481d2a6 100644 --- a/src/game/Unit.cpp +++ b/src/game/Unit.cpp @@ -390,7 +390,7 @@ void Unit::SendMonsterMove(float NewPosX, float NewPosY, float NewPosZ, SplineTy break; } case SPLINETYPE_FACINGTARGET: - data << uint64(va_arg(vargs,uint64)); + data << uint64(va_arg(vargs,uint64)); // ObjectGuid in fact break; case SPLINETYPE_FACINGANGLE: data << float(va_arg(vargs,double)); // facing angle diff --git a/src/game/WorldSession.cpp b/src/game/WorldSession.cpp index b30e480cf9f..8e4072d7f3f 100644 --- a/src/game/WorldSession.cpp +++ b/src/game/WorldSession.cpp @@ -445,17 +445,7 @@ void WorldSession::LogoutPlayer(bool Save) ///- empty buyback items and save the player in the database // some save parts only correctly work in case player present in map/player_lists (pets, etc) if(Save) - { - uint32 eslot; - for(int j = BUYBACK_SLOT_START; j < BUYBACK_SLOT_END; ++j) - { - eslot = j - BUYBACK_SLOT_START; - _player->SetUInt64Value(PLAYER_FIELD_VENDORBUYBACK_SLOT_1 + (eslot * 2), 0); - _player->SetUInt32Value(PLAYER_FIELD_BUYBACK_PRICE_1 + eslot, 0); - _player->SetUInt32Value(PLAYER_FIELD_BUYBACK_TIMESTAMP_1 + eslot, 0); - } _player->SaveToDB(); - } ///- Leave all channels before player delete... _player->CleanupChannels(); diff --git a/src/game/WorldSession.h b/src/game/WorldSession.h index 23df98c0c89..4a3b1b7952a 100644 --- a/src/game/WorldSession.h +++ b/src/game/WorldSession.h @@ -317,7 +317,7 @@ class MANGOS_DLL_SPEC WorldSession void SendPetitionQueryOpcode(ObjectGuid petitionguid); //pet - void SendPetNameQuery(uint64 guid, uint32 petnumber); + void SendPetNameQuery(ObjectGuid guid, uint32 petnumber); void SendStablePet(ObjectGuid guid); void SendStableResult(uint8 res); bool CheckStableMaster(ObjectGuid guid); diff --git a/src/mangosd/CliRunnable.cpp b/src/mangosd/CliRunnable.cpp index 6ab96f24d8f..2f77abe24de 100644 --- a/src/mangosd/CliRunnable.cpp +++ b/src/mangosd/CliRunnable.cpp @@ -269,7 +269,7 @@ void ChatHandler::HandleCharacterDeletedRestoreHelper(DeletedInfo const& delInfo return; } - if (sObjectMgr.GetPlayerGUIDByName(delInfo.name)) + if (!sObjectMgr.GetPlayerGuidByName(delInfo.name).IsEmpty()) { PSendSysMessage(LANG_CHARACTER_DELETED_SKIP_NAME, delInfo.name.c_str(), delInfo.lowguid, delInfo.accountId); return; diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index eb49df5a8f2..2477872f064 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 "11469" + #define REVISION_NR "11470" #endif // __REVISION_NR_H__ From 7732d9d23749ed86bb1b2f6379413fb587c3e4e2 Mon Sep 17 00:00:00 2001 From: Xfurry Date: Wed, 11 May 2011 23:04:29 +0400 Subject: [PATCH 38/43] [11471] Implement dummy effect 21147 Also simplify addThreatPercent but in same time avoid rounding in -100% case. Signed-off-by: VladimirMangos --- src/game/SpellEffects.cpp | 15 +++++++++++++++ src/game/ThreatManager.h | 6 +++++- src/shared/revision_nr.h | 2 +- 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/src/game/SpellEffects.cpp b/src/game/SpellEffects.cpp index 870e572c00e..6b4e689b6c0 100644 --- a/src/game/SpellEffects.cpp +++ b/src/game/SpellEffects.cpp @@ -1030,6 +1030,21 @@ void Spell::EffectDummy(SpellEffectIndex eff_idx) return; } + case 21147: // Arcane Vacuum + { + if (!unitTarget) + return; + + // Spell used by Azuregos to teleport all the players to him + // This also resets the target threat + if (m_caster->getThreatManager().getThreat(unitTarget)) + m_caster->getThreatManager().modifyThreatPercent(unitTarget, -100); + + // cast summon player + m_caster->CastSpell(unitTarget, 21150, true); + + return; + } case 23019: // Crystal Prison Dummy DND { if (!unitTarget || !unitTarget->isAlive() || unitTarget->GetTypeId() != TYPEID_UNIT || ((Creature*)unitTarget)->IsPet()) diff --git a/src/game/ThreatManager.h b/src/game/ThreatManager.h index 6159435b5d0..11dd4e07002 100644 --- a/src/game/ThreatManager.h +++ b/src/game/ThreatManager.h @@ -56,7 +56,11 @@ class MANGOS_DLL_SPEC HostileReference : public Reference void setThreat(float pThreat) { addThreat(pThreat - getThreat()); } - void addThreatPercent(int32 pPercent) { float tmpThreat = iThreat; tmpThreat = tmpThreat * (pPercent+100) / 100; addThreat(tmpThreat-iThreat); } + void addThreatPercent(int32 pPercent) + { + // for special -100 case avoid rounding + addThreat(pPercent == -100 ? -iThreat : iThreat * pPercent / 100.0f); + } float getThreat() const { return iThreat; } diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index 2477872f064..4873598e93f 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 "11470" + #define REVISION_NR "11471" #endif // __REVISION_NR_H__ From 4d64972d4a14b8e8836cff1e26dbd9c9afe603c3 Mon Sep 17 00:00:00 2001 From: Xfurry Date: Thu, 12 May 2011 00:07:18 +0400 Subject: [PATCH 39/43] [11472] Implement spells 23184/25041 periodic trigger code. Also implement classes PlayerListSearcher and AnyPlayerInObjectRangeWithAuraCheck Signed-off-by: VladimirMangos --- src/game/GridNotifiers.h | 35 ++++++++++++++++++++++++++++++++++- src/game/GridNotifiersImpl.h | 9 +++++++++ src/game/SpellAuras.cpp | 27 +++++++++++++++++++++++---- src/shared/revision_nr.h | 2 +- 4 files changed, 67 insertions(+), 6 deletions(-) diff --git a/src/game/GridNotifiers.h b/src/game/GridNotifiers.h index 9ac71ee027a..b04c7818ce8 100644 --- a/src/game/GridNotifiers.h +++ b/src/game/GridNotifiers.h @@ -469,6 +469,21 @@ namespace MaNGOS template void Visit(GridRefManager &) {} }; + template + struct MANGOS_DLL_DECL PlayerListSearcher + { + uint32 i_phaseMask; + std::list &i_objects; + Check& i_check; + + PlayerListSearcher(std::list &objects, Check & check) + : i_phaseMask(check.GetFocusObject().GetPhaseMask()), i_objects(objects),i_check(check) {} + + void Visit(PlayerMapType &m); + + template void Visit(GridRefManager &) {} + }; + template struct MANGOS_DLL_DECL PlayerWorker { @@ -1137,6 +1152,8 @@ namespace MaNGOS NearestCreatureEntryWithLiveStateInObjectRangeCheck(NearestCreatureEntryWithLiveStateInObjectRangeCheck const&); }; + // Player checks and do + class AnyPlayerInObjectRangeCheck { public: @@ -1154,7 +1171,23 @@ namespace MaNGOS float i_range; }; - // Player checks and do + class AnyPlayerInObjectRangeWithAuraCheck + { + public: + AnyPlayerInObjectRangeWithAuraCheck(WorldObject const* obj, float range, uint32 spellId) + : i_obj(obj), i_range(range), i_spellId(spellId) {} + WorldObject const& GetFocusObject() const { return *i_obj; } + bool operator()(Player* u) + { + return u->isAlive() + && i_obj->IsWithinDistInMap(u, i_range) + && u->HasAura(i_spellId); + } + private: + WorldObject const* i_obj; + float i_range; + uint32 i_spellId; + }; // Prepare using Builder localized packets with caching and send to player template diff --git a/src/game/GridNotifiersImpl.h b/src/game/GridNotifiersImpl.h index 59b4dcd5875..f8e8e8f2992 100644 --- a/src/game/GridNotifiersImpl.h +++ b/src/game/GridNotifiersImpl.h @@ -547,6 +547,15 @@ void MaNGOS::PlayerSearcher::Visit(PlayerMapType &m) } } +template +void MaNGOS::PlayerListSearcher::Visit(PlayerMapType &m) +{ + for(PlayerMapType::iterator itr = m.begin(); itr != m.end(); ++itr) + if (itr->getSource()->InSamePhase(i_phaseMask)) + if (i_check(itr->getSource())) + i_objects.push_back(itr->getSource()); +} + template void MaNGOS::LocalizedPacketDo::operator()( Player* p ) { diff --git a/src/game/SpellAuras.cpp b/src/game/SpellAuras.cpp index dd8d57c3395..a854f808ed9 100644 --- a/src/game/SpellAuras.cpp +++ b/src/game/SpellAuras.cpp @@ -1112,8 +1112,29 @@ void Aura::TriggerSpell() target->CastSpell(target, 23171, true, NULL, this); return; } -// // Mark of Frost -// case 23184: break; + case 23184: // Mark of Frost + case 25041: // Mark of Nature + { + std::list targets; + + // spells existed in 1.x.x; 23183 - mark of frost; 25042 - mark of nature; both had radius of 100.0 yards in 1.x.x DBC + // spells are used by Azuregos and the Emerald dragons in order to put a stun debuff on the players which resurrect during the encounter + // in order to implement the missing spells we need to make a grid search for hostile players and check their auras; if they are marked apply debuff + + // Mark of Frost or Mark of Nature + uint32 markSpellId = auraId == 23184 ? 23182 : 25040; + // Aura of Frost or Aura of Nature + uint32 debufSpellId = auraId == 23184 ? 23186 : 25043; + + MaNGOS::AnyPlayerInObjectRangeWithAuraCheck u_check(GetTarget(), 100.0f, markSpellId); + MaNGOS::PlayerListSearcher checker(targets, u_check); + Cell::VisitWorldObjects(GetTarget(), checker, 100.0f); + + for (std::list::iterator itr = targets.begin(); itr != targets.end(); ++itr) + (*itr)->CastSpell((*itr), debufSpellId, true, NULL, NULL, casterGUID); + + return; + } case 23493: // Restoration { uint32 heal = triggerTarget->GetMaxHealth() / 10; @@ -1161,8 +1182,6 @@ void Aura::TriggerSpell() } // // Stink Trap // case 24918: break; -// // Mark of Nature -// case 25041: break; // // Agro Drones // case 25152: break; case 25371: // Consume diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index 4873598e93f..40ef06f663b 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 "11471" + #define REVISION_NR "11472" #endif // __REVISION_NR_H__ From e39b51d83bf3673a58cd634b5011e1132688bc96 Mon Sep 17 00:00:00 2001 From: Vinolentus Date: Thu, 12 May 2011 09:29:27 +0400 Subject: [PATCH 40/43] [11473] Avoid unexpected uint64->ObjectGuid convertion in ObjectGuid::GetString Signed-off-by: VladimirMangos --- src/game/ObjectGuid.cpp | 2 +- src/shared/revision_nr.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/game/ObjectGuid.cpp b/src/game/ObjectGuid.cpp index 59d84785bf5..a206abb35d9 100644 --- a/src/game/ObjectGuid.cpp +++ b/src/game/ObjectGuid.cpp @@ -51,7 +51,7 @@ std::string ObjectGuid::GetString() const if (IsPlayer()) { std::string name; - if (sObjectMgr.GetPlayerNameByGUID(m_guid, name)) + if (sObjectMgr.GetPlayerNameByGUID(*this, name)) str << " " << name; } diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index 40ef06f663b..bb30c8f0560 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 "11472" + #define REVISION_NR "11473" #endif // __REVISION_NR_H__ From 575e237763178bfc321739b9eaaa089e4e814f7d Mon Sep 17 00:00:00 2001 From: NoFantasy Date: Thu, 12 May 2011 08:20:55 +0200 Subject: [PATCH 41/43] [11474] Adjust text of some log messages related to spell target Signed-off-by: NoFantasy --- src/game/Level3.cpp | 2 +- src/game/SpellMgr.cpp | 4 ++-- src/game/World.cpp | 2 +- src/shared/revision_nr.h | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/game/Level3.cpp b/src/game/Level3.cpp index 229e458bae8..867fa5192af 100644 --- a/src/game/Level3.cpp +++ b/src/game/Level3.cpp @@ -638,7 +638,7 @@ bool ChatHandler::HandleReloadSpellScriptTargetCommand(char* /*args*/) bool ChatHandler::HandleReloadSpellTargetPositionCommand(char* /*args*/) { - sLog.outString( "Re-Loading Spell target coordinates..." ); + sLog.outString( "Re-Loading spell target destination coordinates..." ); sSpellMgr.LoadSpellTargetPositions(); SendGlobalSysMessage("DB table `spell_target_position` (destination coordinates for spell targets) reloaded."); return true; diff --git a/src/game/SpellMgr.cpp b/src/game/SpellMgr.cpp index c4f656ae4bf..0aa46bb2b6a 100644 --- a/src/game/SpellMgr.cpp +++ b/src/game/SpellMgr.cpp @@ -994,7 +994,7 @@ void SpellMgr::LoadSpellTargetPositions() bar.step(); sLog.outString(); - sLog.outString( ">> Loaded %u spell target coordinates", count ); + sLog.outString(">> Loaded %u spell target destination coordinates", count); return; } @@ -1070,7 +1070,7 @@ void SpellMgr::LoadSpellTargetPositions() delete result; sLog.outString(); - sLog.outString( ">> Loaded %u spell teleport coordinates", count ); + sLog.outString(">> Loaded %u spell target destination coordinates", count); } template diff --git a/src/game/World.cpp b/src/game/World.cpp index ca8750c78d3..fbd81107ce6 100644 --- a/src/game/World.cpp +++ b/src/game/World.cpp @@ -1113,7 +1113,7 @@ void World::SetInitialWorldSettings() sLog.outString( "Loading Graveyard-zone links..."); sObjectMgr.LoadGraveyardZones(); - sLog.outString( "Loading Spell target coordinates..." ); + sLog.outString( "Loading spell target destination coordinates..." ); sSpellMgr.LoadSpellTargetPositions(); sLog.outString( "Loading spell pet auras..." ); diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index bb30c8f0560..8e3a98e8e04 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 "11473" + #define REVISION_NR "11474" #endif // __REVISION_NR_H__ From e45dadd1b32da1a312107f5e34f76ffe5996e956 Mon Sep 17 00:00:00 2001 From: VladimirMangos Date: Thu, 12 May 2011 13:58:45 +0400 Subject: [PATCH 42/43] [11475] Provide wrappers for set/get ObjectGuid in InstanceData as uint64 --- src/game/InstanceData.h | 4 ++++ src/shared/revision_nr.h | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/game/InstanceData.h b/src/game/InstanceData.h index 1008064ef88..7d52f3f51b2 100644 --- a/src/game/InstanceData.h +++ b/src/game/InstanceData.h @@ -82,6 +82,10 @@ class MANGOS_DLL_SPEC InstanceData virtual uint64 GetData64(uint32 /*Data*/) { return 0; } virtual void SetData64(uint32 /*Data*/, uint64 /*Value*/) { } + //Guid data storage (wrapper for set/get from uint64 storage + ObjectGuid GetGuid(uint32 dataIdx) { return ObjectGuid(GetData64(dataIdx)); } + void SetGuid(uint32 dataIdx, ObjectGuid value) { SetData64(dataIdx, value.GetRawValue()); } + //All-purpose data storage 32 bit virtual uint32 GetData(uint32 /*Type*/) { return 0; } virtual void SetData(uint32 /*Type*/, uint32 /*Data*/) {} diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index 8e3a98e8e04..999a62f438e 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 "11474" + #define REVISION_NR "11475" #endif // __REVISION_NR_H__ From 7fff23f66f8b2ab74d613f1c4eb42b81f54c042a Mon Sep 17 00:00:00 2001 From: VladimirMangos Date: Thu, 12 May 2011 14:10:02 +0400 Subject: [PATCH 43/43] [11476] Fixed possible build problem. --- src/game/InstanceData.h | 1 + src/shared/revision_nr.h | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/game/InstanceData.h b/src/game/InstanceData.h index 7d52f3f51b2..a307b867706 100644 --- a/src/game/InstanceData.h +++ b/src/game/InstanceData.h @@ -20,6 +20,7 @@ #define MANGOS_INSTANCE_DATA_H #include "Common.h" +#include "ObjectGuid.h" class Map; class Unit; diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index 999a62f438e..b072bb1cdf4 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 "11475" + #define REVISION_NR "11476" #endif // __REVISION_NR_H__