diff options
245 files changed, 6769 insertions, 4317 deletions
diff --git a/sql/updates/characters/2012_11_02_00_character_misc.sql b/sql/updates/characters/2012_11_02_00_character_misc.sql new file mode 100644 index 00000000000..a7613944dc4 --- /dev/null +++ b/sql/updates/characters/2012_11_02_00_character_misc.sql @@ -0,0 +1,30 @@ +CREATE TABLE IF NOT EXISTS `guild_member_withdraw` ( + `guid` int(10) unsigned NOT NULL, + `tab0` int(10) unsigned NOT NULL DEFAULT '0', + `tab1` int(10) unsigned NOT NULL DEFAULT '0', + `tab2` int(10) unsigned NOT NULL DEFAULT '0', + `tab3` int(10) unsigned NOT NULL DEFAULT '0', + `tab4` int(10) unsigned NOT NULL DEFAULT '0', + `tab5` int(10) unsigned NOT NULL DEFAULT '0', + `money` int(10) unsigned NOT NULL DEFAULT '0', + PRIMARY KEY (`guid`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Guild Member Daily Withdraws'; + +ALTER TABLE `guild_member` DROP COLUMN `BankRemMoney`; +ALTER TABLE `guild_member` DROP COLUMN `BankRemSlotsTab0`; +ALTER TABLE `guild_member` DROP COLUMN `BankRemSlotsTab1`; +ALTER TABLE `guild_member` DROP COLUMN `BankRemSlotsTab2`; +ALTER TABLE `guild_member` DROP COLUMN `BankRemSlotsTab3`; +ALTER TABLE `guild_member` DROP COLUMN `BankRemSlotsTab4`; +ALTER TABLE `guild_member` DROP COLUMN `BankRemSlotsTab5`; +ALTER TABLE `guild_member` DROP COLUMN `BankResetTimeMoney`; +ALTER TABLE `guild_member` DROP COLUMN `BankResetTimeTab0`; +ALTER TABLE `guild_member` DROP COLUMN `BankResetTimeTab1`; +ALTER TABLE `guild_member` DROP COLUMN `BankResetTimeTab2`; +ALTER TABLE `guild_member` DROP COLUMN `BankResetTimeTab3`; +ALTER TABLE `guild_member` DROP COLUMN `BankResetTimeTab4`; +ALTER TABLE `guild_member` DROP COLUMN `BankResetTimeTab5`; + +DELETE FROM `worldstates` WHERE `entry`=20006; +INSERT INTO `worldstates` (`entry`,`value`,`comment`) VALUES (20006,0, 'Guild daily reset'); + diff --git a/sql/updates/world/2012_10_14_00_world_creature.sql b/sql/updates/world/2012_10_14_00_world_creature.sql new file mode 100644 index 00000000000..dd650f37aef --- /dev/null +++ b/sql/updates/world/2012_10_14_00_world_creature.sql @@ -0,0 +1,10 @@ +-- Spawnmask updates +UPDATE `creature` SET `spawnMask`=15 WHERE `id` IN(40091, 40081); + +-- Auras updates (Now in script, can't be used in creature_addon because dynamically spawned) +DELETE FROM `creature_template_addon` WHERE `entry` IN(39863, 40142); + +-- Blazing Aura +-- NOTE: This still does not work, no clue why. Probably a core-side bug ? +INSERT INTO `conditions` (`SourceTypeOrReferenceId`, `SourceGroup`, `SourceEntry`, `SourceId`, `ElseGroup`, `ConditionTypeOrReference`, `ConditionTarget`, `ConditionValue1`, `ConditionValue2`, `ConditionValue3`, `NegativeCondition`, `ErrorTextId`, `ScriptName`, `Comment`) VALUES +(13,2,75886,0,0,31,0,3,40683,0,0,0, '', 'Blazing Aura can only target Living Embers'); diff --git a/sql/updates/world/2012_10_18_00_world_trinity_string.sql b/sql/updates/world/2012_10_18_00_world_trinity_string.sql deleted file mode 100644 index a12b20388eb..00000000000 --- a/sql/updates/world/2012_10_18_00_world_trinity_string.sql +++ /dev/null @@ -1,17 +0,0 @@ -DELETE FROM `trinity_string` WHERE `entry` IN (9986, 9987, 9989, 9990, 9991, 9992, 9993, 9994, 9995, 9996, 9997, 9998, 9999); -INSERT INTO `trinity_string` (`entry`, `content_default`, `content_loc1`, `content_loc2`, `content_loc3`, `content_loc4`, `content_loc5`, `content_loc6`, `content_loc7`, `content_loc8`) -VALUES - (9986, 'Error', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL), - (9987, 'None', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL), - (9988, 'Leader', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL), - (9989, 'Dps', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL), - (9990, 'Healer', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL), - (9991, 'Tank', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL), - (9992, 'Raid browser', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL), - (9993, 'Finished dungeon', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL), - (9994, 'In dungeon', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL), - (9995, 'Vote kick', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL), - (9996, 'Proposal', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL), - (9997, 'Queued', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL), - (9998, 'Role check', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL), - (9999, 'None', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); diff --git a/sql/updates/world/2012_10_19_00_world_creature_text.sql b/sql/updates/world/2012_10_19_00_world_creature_text.sql deleted file mode 100644 index aad3627a26a..00000000000 --- a/sql/updates/world/2012_10_19_00_world_creature_text.sql +++ /dev/null @@ -1,36 +0,0 @@ --- Gnomeregan/Blastmaster Emi Shortfuse's event -DELETE FROM `script_texts` WHERE `entry` BETWEEN -1090028 AND -1090000; -DELETE FROM `creature_text` WHERE `entry` IN (7361,7998); -INSERT INTO `creature_text` (`entry`, `groupid`, `id`, `text`, `type`, `language`, `probability`, `emote`, `duration`, `sound`, `comment`) VALUES --- Emi Shortfuse -(7998,0,0, 'With your help, I can evaluate these tunnels.',12,0,100,0,0,0, 'SAY_BLASTMASTER_0'), -(7998,1,0, 'Let''s see if we can find out where these Troggs are coming from... and put a stop to the invasion!',12,0,100,0,0,0, 'SAY_BLASTMASTER_1'), -(7998,2,0, 'Such devastation... what horrible mess...',12,0,100,0,0,0, 'SAY_BLASTMASTER_2'), -(7998,3,0, 'It''s quiet here...',12,0,100,0,0,0, 'SAY_BLASTMASTER_3'), -(7998,4,0, '...too quiet.',12,0,100,0,0,0, 'SAY_BLASTMASTER_4'), -(7998,5,0, 'Look! Over there at the tunnel wall!',12,0,100,0,0,0, 'SAY_BLASTMASTER_5'), -(7998,6,0, 'Trogg incrusion! Defend me while I blast the hole closed!',12,0,100,0,0,0, 'SAY_BLASTMASTER_6'), -(7998,7,0, 'The charges are set. Get back before they blow!',12,0,100,0,0,0, 'SAY_BLASTMASTER_7'), -(7998,8,0, 'Incoming blast in 10 seconds!',14,0,100,0,0,0, 'SAY_BLASTMASTER_8'), -(7998,9,0, 'Incoming blast in 5 seconds. Clear the tunnel!',14,0,100,0,0,0, 'SAY_BLASTMASTER_9'), -(7998,10,0, 'FIRE IN THE HOLE!',14,0,100,0,0,0, 'SAY_BLASTMASTER_10'), -(7998,11,0, 'Well done! Without your help I would have never been able to thwart that wave of troggs.',12,0,100,0,0,0, 'SAY_BLASTMASTER_11'), -(7998,12,0, 'Did you hear something?',12,0,100,0,0,0, 'SAY_BLASTMASTER_12'), -(7998,13,0, 'I heard something over there.',12,0,100,0,0,0, 'SAY_BLASTMASTER_13'), -(7998,14,0, 'More troggs! Ward them off as I prepare the explosives!',12,0,100,0,0,0, 'SAY_BLASTMASTER_14'), -(7998,15,0, 'The final charge is set. Stand back!',12,0,100,0,0,0, 'SAY_BLASTMASTER_15'), -(7998,16,0, 'The final charge is set. Stand back!',12,0,100,0,0,0, 'SAY_BLASTMASTER_16'), -(7998,17,0, 'Incoming blast in 10 seconds!',14,0,100,0,0,0, 'SAY_BLASTMASTER_17'), -(7998,18,0, 'Incoming blast in 5 seconds. Clear the tunnel!',14,0,100,0,0,0, 'SAY_BLASTMASTER_18'), -(7998,19,0, 'I don''t think one charge is going to cut it. Keep fending them off!',12,0,100,0,0,0, 'SAY_BLASTMASTER_19'), -(7998,20,0, 'FIRE IN THE HOLE!',14,0,100,0,0,0, 'SAY_BLASTMASTER_20'), -(7998,21,0, 'Well done! Without your help I would have never been able to thwart that wave of troggs.',12,0,100,0,0,0, 'SAY_BLASTMASTER_21'), -(7998,22,0, 'Did you hear something?',12,0,100,0,0,0, 'SAY_BLASTMASTER_22'), -(7998,23,0, 'I heard something over there.',12,0,100,0,0,0, 'SAY_BLASTMASTER_23'), -(7998,24,0, 'More troggs! Ward them off as I prepare the explosives!',12,0,100,0,0,0, 'SAY_BLASTMASTER_24'), -(7998,25,0, 'The final charge is set. Stand back!',12,0,100,0,0,0, 'SAY_BLASTMASTER_25'), -(7998,26,0, '10 seconds to blast! Stand back!!!',14,0,100,0,0,0, 'SAY_BLASTMASTER_26'), -(7998,27,0, '5 seconds until detonation!!',14,0,100,0,0,0, 'SAY_BLASTMASTER_27'), -(7998,28,0, 'Superb! Because of your help, my people stand a chance of re-taking our belowed city. Three cheers to you!',12,0,100,0,0,0, 'SAY_BLASTMASTER_28'), --- Grubbis -(7361,0,0, 'We come from below! You can never stop us!',14,0,100,0,0,0, 'SAY_GRUBBIS'); diff --git a/sql/updates/world/2012_10_20_00_world_transports.sql b/sql/updates/world/2012_10_20_00_world_transports.sql new file mode 100644 index 00000000000..8cc2bae4b47 --- /dev/null +++ b/sql/updates/world/2012_10_20_00_world_transports.sql @@ -0,0 +1,6 @@ +-- Update position for Koltira Deathweaver +UPDATE `creature_transport` SET `TransOffsetX`=45.50927,`TransOffsetY`=6.679555,`TransOffsetZ`=30.17881,`TransOffsetO`=5.445427 WHERE `guid`=36; + +-- Set proper name and period timers for icecrown ships +UPDATE `transports` SET `name`= 'Alliance gunship patrolling above Icecrown (\"The Skybreaker\")',`period`=1051388 WHERE `entry`=192242; +UPDATE `transports` SET `name`= 'Horde gunship patrolling above Icecrown (\"Orgrim''s Hammer\")',`period`=1431158 WHERE `entry`=192241; diff --git a/sql/updates/world/2012_10_20_01_world_spell_script_names.sql b/sql/updates/world/2012_10_20_01_world_spell_script_names.sql new file mode 100644 index 00000000000..814f1b40e65 --- /dev/null +++ b/sql/updates/world/2012_10_20_01_world_spell_script_names.sql @@ -0,0 +1,8 @@ +-- Spellscript and conditions for spells of quest Gordunni Cobalt +DELETE FROM `spell_script_names` WHERE `spell_id`=19395; +INSERT INTO `spell_script_names`(`spell_id`,`ScriptName`) VALUES +(19395,'spell_gordunni_trap'); + +DELETE FROM `conditions` WHERE `SourceTypeOrReferenceId`=13 AND `SourceEntry`=11757; +INSERT INTO `conditions`(`SourceTypeOrReferenceId`,`SourceGroup`,`SourceEntry`,`ConditionTypeOrReference`,`ConditionValue1`,`ConditionValue2`,`Comment`) VALUES +(13,1,11757,31,5,144050,'Digging for Cobalt targets Gordunni Trap'); diff --git a/sql/updates/world/2012_10_20_02_world_creature_text.sql b/sql/updates/world/2012_10_20_02_world_creature_text.sql new file mode 100644 index 00000000000..bb153c6b2f6 --- /dev/null +++ b/sql/updates/world/2012_10_20_02_world_creature_text.sql @@ -0,0 +1,27 @@ +-- Gnomeregan/Blastmaster Emi Shortfuse's event +DELETE FROM `script_texts` WHERE `entry` BETWEEN -1090028 AND -1090000; +DELETE FROM `creature_text` WHERE `entry` IN (7361,7998); +INSERT INTO `creature_text` (`entry`, `groupid`, `id`, `text`, `type`, `language`, `probability`, `emote`, `duration`, `sound`, `comment`) VALUES +-- Emi Shortfuse +(7998,0,0, 'With your help, I can evaluate these tunnels.',12,0,100,0,0,0, 'SAY_BLASTMASTER_0'), +(7998,1,0, 'Let''s see if we can find out where these Troggs are coming from... and put a stop to the invasion!',12,0,100,0,0,0, 'SAY_BLASTMASTER_1'), +(7998,2,0, 'Such devastation... what horrible mess...',12,0,100,0,0,0, 'SAY_BLASTMASTER_2'), +(7998,3,0, 'It''s quiet here...',12,0,100,0,0,0, 'SAY_BLASTMASTER_3'), +(7998,4,0, '...too quiet.',12,0,100,0,0,0, 'SAY_BLASTMASTER_4'), +(7998,5,0, 'Look! Over there at the tunnel wall!',12,0,100,0,0,0, 'SAY_BLASTMASTER_5'), +(7998,6,0, 'Trogg incrusion! Defend me while I blast the hole closed!',12,0,100,0,0,0, 'SAY_BLASTMASTER_6'), +(7998,7,0, 'I don''t think one charge is going to cut it. Keep fending them off!',12,0,100,0,0,0, 'SAY_BLASTMASTER_7'), +(7998,8,0, 'The charges are set. Get back before they blow!',12,0,100,0,0,0, 'SAY_BLASTMASTER_8'), +(7998,9,0, 'Incoming blast in 10 seconds!',14,0,100,0,0,0, 'SAY_BLASTMASTER_9'), +(7998,10,0, 'Incoming blast in 5 seconds. Clear the tunnel!',14,0,100,0,0,0, 'SAY_BLASTMASTER_10'), +(7998,11,0, 'FIRE IN THE HOLE!',14,0,100,0,0,0, 'SAY_BLASTMASTER_11'), +(7998,12,0, 'Well done! Without your help I would have never been able to thwart that wave of troggs.',12,0,100,0,0,0, 'SAY_BLASTMASTER_12'), +(7998,13,0, 'Did you hear something?',12,0,100,0,0,0, 'SAY_BLASTMASTER_13'), +(7998,14,0, 'I heard something over there.',12,0,100,0,0,0, 'SAY_BLASTMASTER_14'), +(7998,15,0, 'More troggs! Ward them off as I prepare the explosives!',12,0,100,0,0,0, 'SAY_BLASTMASTER_15'), +(7998,16,0, 'The final charge is set. Stand back!',12,0,100,0,0,0, 'SAY_BLASTMASTER_16'), +(7998,17,0, '10 seconds to blast! Stand back!!!',14,0,100,0,0,0, 'SAY_BLASTMASTER_17'), +(7998,18,0, '5 seconds until detonation!!',14,0,100,0,0,0, 'SAY_BLASTMASTER_18'), +(7998,19,0, 'Superb! Because of your help, my people stand a chance of re-taking our belowed city. Three cheers to you!',12,0,100,0,0,0, 'SAY_BLASTMASTER_19'), +-- Grubbis +(7361,0,0, 'We come from below! You can never stop us!',14,0,100,0,0,0, 'SAY_GRUBBIS'); diff --git a/sql/updates/world/2012_10_21_00_world_conditions.sql b/sql/updates/world/2012_10_21_00_world_conditions.sql new file mode 100644 index 00000000000..62161a932f9 --- /dev/null +++ b/sql/updates/world/2012_10_21_00_world_conditions.sql @@ -0,0 +1 @@ +ALTER TABLE `conditions` CHANGE COLUMN `SourceEntry` `SourceEntry` MEDIUMINT(8) NOT NULL DEFAULT 0; diff --git a/sql/updates/world/2012_10_21_01_world_misc.sql b/sql/updates/world/2012_10_21_01_world_misc.sql new file mode 100644 index 00000000000..fe74f8a7a80 --- /dev/null +++ b/sql/updates/world/2012_10_21_01_world_misc.sql @@ -0,0 +1,37 @@ +-- Area conditions for Plant Chieftains Totem +DELETE FROM `conditions` WHERE `SourceTypeOrReferenceId`=17 AND `SourceEntry`=56765; +INSERT INTO `conditions`(`SourceTypeOrReferenceId`,`SourceEntry`,`ConditionTypeOrReference`,`ConditionValue1`,`ConditionValue2`,`ErrorTextId`,`Comment`) VALUES +(17,56765,29,30446,15,64,'Plant Chieftains Totem only useable next to Rift'); + +-- Apply Close Rift to The Chieftain's Totem +DELETE FROM `creature_template_addon` WHERE `entry`=30444; +INSERT INTO `creature_template_addon`(`entry`,`auras`) VALUES +(30444,'56763'); + +-- Assign aura script to Close Rift +DELETE FROM `spell_script_names` WHERE `spell_id`=56763; +INSERT INTO `spell_script_names`(`spell_id`,`ScriptName`) VALUES +(56763,'spell_close_rift'); + +-- Target conditions for spell triggered by Close Rift Periodic +DELETE FROM `conditions` WHERE `SourceTypeOrReferenceId`=13 AND `SourceEntry` IN (56764,61665); +INSERT INTO `conditions`(`SourceTypeOrReferenceId`,`SourceGroup`,`SourceEntry`,`ConditionTypeOrReference`,`ConditionValue1`,`ConditionValue2`,`Comment`) VALUES +(13,1,56764,31,3,30446,'Close Rift Periodic targets Frostfloe Rift'), +(13,1,61665,31,3,30446,'Despawn Rift targets Frostfloe Rift'); + +-- Assign SmartAI to Frostfloe Rift +UPDATE `creature_template` SET `AIName`='SmartAI',`ScriptName`='' WHERE `entry`=30446; + +-- Create SAI for Frostfloe Rift +DELETE FROM `smart_scripts` WHERE `entryorguid`=30446 AND `source_type`=0; +INSERT INTO `smart_scripts`(`entryorguid`,`id`,`link`,`event_type`,`event_param1`,`action_type`,`action_param1`,`action_param2`,`target_type`,`comment`) VALUES +(30446,1,2,8,61665,45,1,1,7,'Frostfloe Rift - On spell hit - Set data of invoker'), +(30446,2,0,61,0,41,0,0,1,'Frostfloe Rift - On spell hit - Despawn'); + +-- Assign SmartAI to Chieftain's Totem +UPDATE `creature_template` SET `AIName`='SmartAI',`ScriptName`='' WHERE `entry`=30444; + +-- Create SAI for Chieftain's Totem +DELETE FROM `smart_scripts` WHERE `entryorguid`=30444 AND `source_type`=0; +INSERT INTO `smart_scripts`(`entryorguid`,`event_type`,`event_param1`,`event_param2`,`action_type`,`action_param1`,`target_type`,`comment`) VALUES +(30444,38,1,1,33,30444,23,'Chieftains Totem - On data set - Give quest credit'); diff --git a/sql/updates/world/2012_10_23_00_world_trinity_string.sql b/sql/updates/world/2012_10_23_00_world_trinity_string.sql new file mode 100644 index 00000000000..60318667fbc --- /dev/null +++ b/sql/updates/world/2012_10_23_00_world_trinity_string.sql @@ -0,0 +1,22 @@ +DELETE FROM `trinity_string` WHERE `entry` IN (9980, 9981, 9982, 9983, 9984, 9985, 9986, 9987, 9988, 9989, 9990, 9991, 9992, 9993, 9994, 9995, 9996, 9997, 9998, 9999); +INSERT INTO `trinity_string` (`entry`, `content_default`, `content_loc1`, `content_loc2`, `content_loc3`, `content_loc4`, `content_loc5`, `content_loc6`, `content_loc7`, `content_loc8`) VALUES + (9980, 'Player name: %s, State: %s, Dungeons: %u (%s), Roles: %s, Comment: %s', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL), + (9981, 'LfgGroup?: %u, State: %s, Dungeon: %u', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL), + (9982, 'Not in group', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL), + (9983, 'Queues cleared', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL), + (9984, 'Lfg options: %u', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL), + (9985, 'Lfg options changed', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL), + (9986, 'None', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL), + (9987, 'Role check', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL), + (9988, 'Queued', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL), + (9989, 'Proposal', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL), + (9990, 'Vote kick', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL), + (9991, 'In dungeon', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL), + (9992, 'Finished dungeon', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL), + (9993, 'Raid browser', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL), + (9994, 'Tank', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL), + (9995, 'Healer', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL), + (9996, 'Dps', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL), + (9997, 'Leader', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL), + (9998, 'None', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL), + (9999, 'Error', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); diff --git a/sql/updates/world/2012_10_23_01_world_command.sql b/sql/updates/world/2012_10_23_01_world_command.sql new file mode 100644 index 00000000000..b46882c5949 --- /dev/null +++ b/sql/updates/world/2012_10_23_01_world_command.sql @@ -0,0 +1,8 @@ +DELETE FROM `command` WHERE `name` LIKE 'lfg%'; + +INSERT INTO `command` (`name`, `security`, `help`) VALUES +('lfg player', 2, 'Syntax: .lfg player\n Shows information about player (state, roles, comment, dungeons selected).'), +('lfg group', 2, 'Syntax: .lfg group\n Shows information about all players in the group (state, roles, comment, dungeons selected).'), +('lfg queue', 2, 'Syntax: .lfg queue\n Shows info about current lfg queues.'), +('lfg clean', 3, 'Syntax: .flg clean\n Cleans current queue, only for debugging purposes.'), +('lfg options', 3, 'Syntax: .lfg options [new value]\n Shows current lfg options. New value is set if extra param is present.'); diff --git a/sql/updates/world/2012_10_25_00_world_childrens_week.sql b/sql/updates/world/2012_10_25_00_world_childrens_week.sql new file mode 100644 index 00000000000..e2d6eec4dd2 --- /dev/null +++ b/sql/updates/world/2012_10_25_00_world_childrens_week.sql @@ -0,0 +1,574 @@ +-- Orphan Matron Aria +UPDATE `creature_template` SET `AIName`='SmartAI',`ScriptName`='' WHERE `entry`=34365; + +DELETE FROM `smart_scripts` WHERE `entryorguid`=34365 AND `source_type`=0; +INSERT INTO `smart_scripts`(`entryorguid`,`id`,`link`,`event_type`,`event_param1`,`event_param2`,`action_type`,`action_param1`,`target_type`,`comment`) VALUES +(34365,1,4,62,10502,1,33,34365,7,'Orphan Matron Aria - On gossip select - Give quest credit'), +(34365,2,4,62,10502,2,11,65359,7,'Orphan Matron Aria - On gossip select - Create oracle orphan whistle'), +(34365,3,4,62,10502,3,11,65360,7,'Orphan Matron Aria - On gossip select - Create wolvar orphan whistle'), +(34365,4,0,61,0,0,72,0,7,'Orphan Matron Aria - On gossip select - Close gossip'); + +DELETE FROM `gossip_menu_option` WHERE `menu_id`=10502; +INSERT INTO `gossip_menu_option`(`menu_id`,`id`,`option_icon`,`option_text`,`option_id`,`npc_option_npcflag`) VALUES +(10502,1,0,'Tell me about the orphans.',1,1), +(10502,2,0,'I need a new Oracle Orphan Whistle.',1,1), +(10502,3,0,'I need a new Wolvar Orphan Whistle.',1,1); + +DELETE FROM `conditions` WHERE `SourceTypeOrReferenceId`=15 AND `SourceGroup`=10502; +INSERT INTO `conditions`(`SourceTypeOrReferenceId`,`SourceGroup`,`SourceEntry`,`ElseGroup`,`ConditionTypeOrReference`,`ConditionValue1`,`ConditionValue2`,`NegativeCondition`,`Comment`) VALUES +(15,10502,1,1,12,10,0,0,'Childrens Week must be active'), +(15,10502,1,1,1,58818,0,0,'Needs aura 58818'), +(15,10502,1,1,9,13927,0,0,'Quest 13927 must be active'), +(15,10502,1,2,12,10,0,0,'Childrens Week must be active'), +(15,10502,1,2,1,58818,0,0,'Needs aura 58818'), +(15,10502,1,2,9,13926,0,0,'Quest 13926 must be active'), +(15,10502,2,0,12,10,0,0,'Childrens Week must be active'), +(15,10502,2,0,8,13926,0,0,'Quest 13926 must be rewarded'), +(15,10502,2,0,2,46397,1,1,'Must not have item 46397'), +(15,10502,3,0,12,10,0,0,'Childrens Week must be active'), +(15,10502,3,0,8,13927,0,0,'Quest 13926 must be rewarded'), +(15,10502,3,0,2,46396,1,1,'Must not have item 46397'); + +-- Orphan Matron Battlewail +UPDATE `creature_template` SET `AIName`='SmartAI',`ScriptName`='' WHERE `entry`=14451; + +DELETE FROM `smart_scripts` WHERE `entryorguid`=14451 AND `source_type`=0; +INSERT INTO `smart_scripts`(`entryorguid`,`id`,`link`,`event_type`,`event_param1`,`event_param2`,`action_type`,`action_param1`,`target_type`,`comment`) VALUES +(14451,1,2,62,5848,1,11,23125,7,'Orphan Matron Battlewail - On gossip select - Create orc orphan whistle'), +(14451,2,0,61,0,0,72,0,7,'Orphan Matron Battlewail - On gossip select - Close gossip'); + +DELETE FROM `gossip_menu_option` WHERE `menu_id`=5848; +INSERT INTO `gossip_menu_option`(`menu_id`,`id`,`option_icon`,`option_text`,`option_id`,`npc_option_npcflag`) VALUES +(5848,1,0,'I need a new Orc Orphan Whistle.',1,1); + +DELETE FROM `conditions` WHERE `SourceTypeOrReferenceId`=15 AND `SourceGroup`=5848; +INSERT INTO `conditions`(`SourceTypeOrReferenceId`,`SourceGroup`,`SourceEntry`,`ElseGroup`,`ConditionTypeOrReference`,`ConditionValue1`,`ConditionValue2`,`NegativeCondition`,`Comment`) VALUES +(15,5848,1,0,12,10,0,0,'Childrens Week must be active'), +(15,5848,1,0,8,172,0,0,'Quest 172 must be rewarded'), +(15,5848,1,0,2,18597,1,1,'Must not have item 18597'); + +-- Orphan Matron Mercy +UPDATE `creature_template` SET `AIName`='SmartAI',`ScriptName`='' WHERE `entry`=22819; + +DELETE FROM `smart_scripts` WHERE `entryorguid`=22819 AND `source_type`=0; +INSERT INTO `smart_scripts`(`entryorguid`,`id`,`link`,`event_type`,`event_param1`,`event_param2`,`action_type`,`action_param1`,`target_type`,`comment`) VALUES +(22819,1,3,62,8568,1,11,39512,7,'Orphan Matron Mercy - On gossip select - Create blood elf orphan whistle'), +(22819,2,3,62,8568,2,11,39513,7,'Orphan Matron Mercy - On gossip select - Create draenei orphan whistle'), +(22819,3,0,61,0,0,72,0,7,'Orphan Matron Mercy - On gossip select - Close gossip'); + +DELETE FROM `gossip_menu_option` WHERE `menu_id`=8568; +INSERT INTO `gossip_menu_option`(`menu_id`,`id`,`option_icon`,`option_text`,`option_id`,`npc_option_npcflag`) VALUES +(8568,1,0,'I need a new Blood Elf Orphan Whistle.',1,1), +(8568,2,0,'I need a new Draenei Orphan Whistle.',1,1); + +DELETE FROM `conditions` WHERE `SourceTypeOrReferenceId`=15 AND `SourceGroup`=8568; +INSERT INTO `conditions`(`SourceTypeOrReferenceId`,`SourceGroup`,`SourceEntry`,`ElseGroup`,`ConditionTypeOrReference`,`ConditionValue1`,`ConditionValue2`,`NegativeCondition`,`Comment`) VALUES +(15,8568,1,0,12,10,0,0,'Childrens Week must be active'), +(15,8568,1,0,8,10942,0,0,'Quest 10942 must be rewarded'), +(15,8568,1,0,2,31880,1,1,'Must not have item 31880'), +(15,8568,2,0,12,10,0,0,'Childrens Week must be active'), +(15,8568,2,0,8,10943,0,0,'Quest 10943 must be rewarded'), +(15,8568,2,0,2,31881,1,1,'Must not have item 31881'); + +-- Orphan Matron Nightingale +UPDATE `creature_template` SET `AIName`='SmartAI',`ScriptName`='' WHERE `entry`=14450; + +DELETE FROM `smart_scripts` WHERE `entryorguid`=14450 AND `source_type`=0; +INSERT INTO `smart_scripts`(`entryorguid`,`id`,`link`,`event_type`,`event_param1`,`event_param2`,`action_type`,`action_param1`,`target_type`,`comment`) VALUES +(14450,1,2,62,5849,1,11,23124,7,'Orphan Matron Nightingale - On gossip select - Create human orphan whistle'), +(14450,2,0,61,0,0,72,0,7,'Orphan Matron Nightingale - On gossip select - Close gossip'); + +DELETE FROM `gossip_menu_option` WHERE `menu_id`=5849; +INSERT INTO `gossip_menu_option`(`menu_id`,`id`,`option_icon`,`option_text`,`option_id`,`npc_option_npcflag`) VALUES +(5849,1,0,'I need a new Human Orphan Whistle.',1,1); + +DELETE FROM `conditions` WHERE `SourceTypeOrReferenceId`=15 AND `SourceGroup`=5849; +INSERT INTO `conditions`(`SourceTypeOrReferenceId`,`SourceGroup`,`SourceEntry`,`ElseGroup`,`ConditionTypeOrReference`,`ConditionValue1`,`ConditionValue2`,`NegativeCondition`,`Comment`) VALUES +(15,5849,1,0,12,10,0,0,'Childrens Week must be active'), +(15,5849,1,0,8,1468,0,0,'Quest 1468 must be rewarded'), +(15,5849,1,0,2,18598,1,1,'Must not have item 18598'); + +-- Oracle Orphan +SET @TEXT_ORACLE_ORPHAN_1 = 1; +SET @TEXT_ORACLE_ORPHAN_2 = 2; +SET @TEXT_ORACLE_ORPHAN_3 = 3; +SET @TEXT_ORACLE_ORPHAN_4 = 4; +SET @TEXT_ORACLE_ORPHAN_5 = 5; +SET @TEXT_ORACLE_ORPHAN_6 = 6; +SET @TEXT_ORACLE_ORPHAN_7 = 7; +SET @TEXT_ORACLE_ORPHAN_8 = 8; +SET @TEXT_ORACLE_ORPHAN_9 = 9; +SET @TEXT_ORACLE_ORPHAN_10 = 10; +SET @TEXT_ORACLE_ORPHAN_11 = 11; +SET @TEXT_ORACLE_ORPHAN_12 = 12; +SET @TEXT_ORACLE_ORPHAN_13 = 13; +SET @TEXT_ORACLE_ORPHAN_14 = 14; + +UPDATE `creature_template` SET `AIName`='SmartAI',`ScriptName`='' WHERE `entry`=33533; + +DELETE FROM `smart_scripts` WHERE `entryorguid`=33533 AND `source_type`=0; +INSERT INTO `smart_scripts`(`entryorguid`,`event_type`,`event_param1`,`action_type`,`action_param1`,`target_type`,`comment`) VALUES +(33533,8,65357,33,36209,7,'Oracle Orphan - On spellhit - Give quest credit'); + +DELETE FROM `creature_text` WHERE `entry`=33533; +INSERT INTO `creature_text`(`entry`,`groupid`,`text`,`type`,`emote`) VALUE +(33533,@TEXT_ORACLE_ORPHAN_1,"Look!",12,0), +(33533,@TEXT_ORACLE_ORPHAN_2,"We can dance too!",12,0), +(33533,@TEXT_ORACLE_ORPHAN_3,"We made a new friend!",12,0), +(33533,@TEXT_ORACLE_ORPHAN_4,"We here! Only, if this is world tree, how come it broke when they tried to put whole world in?",12,0), +(33533,@TEXT_ORACLE_ORPHAN_5,"Look! Is that us? We think it's us. A bit older, maybe?",12,0), +(33533,@TEXT_ORACLE_ORPHAN_6,"Looks like we blessed by Great Ones! Shrines give magic, make us high-oracle someday? Maybe?",12,0), +(33533,@TEXT_ORACLE_ORPHAN_7,"Wow! A real Great One? We don't even think Soo-say has met a real Great One!",12,0), +(33533,@TEXT_ORACLE_ORPHAN_8,"Um, hello, Mr. Great One. We are honored to meet you.",12,0), +(33533,@TEXT_ORACLE_ORPHAN_9,"Maybe you're asleep, Mr. Great One? We stand. Must be hard working being Great One, collecting all the shinies we leave for you.",12,0), +(33533,@TEXT_ORACLE_ORPHAN_10,"We brought you a gift, Great One. Maybe you see it when you wake up. Maybe you remember we came to see you, oki?",12,0), +(33533,@TEXT_ORACLE_ORPHAN_11,"So that's the queen of the dragons? Hmm... we thought she'd be bigger. Yes, we did.",12,0), +(33533,@TEXT_ORACLE_ORPHAN_12,"How come she doesn't look like the other dragons? could she turn into a big ol' dragon if she wanted to?",12,0), +(33533,@TEXT_ORACLE_ORPHAN_13,"Um... Your Majesty, would you turn into a dragon for us?",12,0), +(33533,@TEXT_ORACLE_ORPHAN_14,"Oki... How about now?",12,0); + +DELETE FROM `creature_questrelation` WHERE `id`=33533; + +DELETE FROM `game_event_creature_quest` WHERE `id`=33533; +INSERT INTO `game_event_creature_quest`(`eventEntry`,`id`,`quest`) VALUES +(10,33533,13929), +(10,33533,13933), +(10,33533,13950), +(10,33533,13954), +(10,33533,13956), +(10,33533,13937), +(10,33533,13959); + +DELETE FROM `creature_involvedrelation` WHERE `id`=33533; +INSERT INTO `creature_involvedrelation`(`id`,`quest`) VALUES +(33533,13929), +(33533,13933), +(33533,13950), +(33533,13954), +(33533,13956), +(33533,13937), +(33533,13926); + +DELETE FROM `conditions` WHERE `SourceTypeOrReferenceId` IN (19,20) AND `SourceEntry` IN (13954,13956,13937); +INSERT INTO `conditions`(`SourceTypeOrReferenceId`,`SourceEntry`,`ConditionTypeOrReference`,`ConditionValue1`,`comment`) VALUES +(19,13954,8,13929,'Accept quest 13954 - Quest 13929 needs to be rewarded'), +(19,13954,8,13933,'Accept quest 13954 - Quest 13933 needs to be rewarded'), +(19,13954,8,13950,'Accept quest 13954 - Quest 13950 needs to be rewarded'), +(19,13956,8,13929,'Accept quest 13956 - Quest 13929 needs to be rewarded'), +(19,13956,8,13933,'Accept quest 13956 - Quest 13933 needs to be rewarded'), +(19,13956,8,13950,'Accept quest 13956 - Quest 13950 needs to be rewarded'), +(19,13937,8,13956,'Accept quest 13937 - Quest 13956 needs to be rewarded'), +(20,13954,8,13929,'Show quest mark 13954 - Quest 13929 needs to be rewarded'), +(20,13954,8,13933,'Show quest mark 13954 - Quest 13933 needs to be rewarded'), +(20,13954,8,13950,'Show quest mark 13954 - Quest 13950 needs to be rewarded'), +(20,13956,8,13929,'Show quest mark 13956 - Quest 13929 needs to be rewarded'), +(20,13956,8,13933,'Show quest mark 13956 - Quest 13933 needs to be rewarded'), +(20,13956,8,13950,'Show quest mark 13956 - Quest 13950 needs to be rewarded'), +(20,13937,8,13956,'Show quest mark 13937 - Quest 13956 needs to be rewarded'); + +-- Wolvar Orphan +SET @TEXT_WOLVAR_ORPHAN_1 = 1; +SET @TEXT_WOLVAR_ORPHAN_2 = 2; +SET @TEXT_WOLVAR_ORPHAN_3 = 3; +SET @TEXT_WOLVAR_ORPHAN_4 = 4; +SET @TEXT_WOLVAR_ORPHAN_5 = 5; +SET @TEXT_WOLVAR_ORPHAN_6 = 6; +SET @TEXT_WOLVAR_ORPHAN_7 = 7; +SET @TEXT_WOLVAR_ORPHAN_8 = 8; +SET @TEXT_WOLVAR_ORPHAN_9 = 9; +SET @TEXT_WOLVAR_ORPHAN_10 = 10; +SET @TEXT_WOLVAR_ORPHAN_11 = 11; +SET @TEXT_WOLVAR_ORPHAN_12 = 12; +SET @TEXT_WOLVAR_ORPHAN_13 = 13; + +UPDATE `creature_template` SET `AIName`='SmartAI',`ScriptName`='' WHERE `entry`=33532; + +DELETE FROM `smart_scripts` WHERE `entryorguid`=33532 AND `source_type`=0; +INSERT INTO `smart_scripts`(`entryorguid`,`event_type`,`event_param1`,`action_type`,`action_param1`,`target_type`,`comment`) VALUES +(33532,8,65357,33,36209,7,'Wolvar Orphan - On spellhit - Give quest credit'); + +DELETE FROM `creature_text` WHERE `entry`=33532; +INSERT INTO `creature_text`(`entry`,`groupid`,`text`,`type`,`emote`) VALUE +(33532,@TEXT_WOLVAR_ORPHAN_1,"Look!",12,0), +(33532,@TEXT_WOLVAR_ORPHAN_2,"Got you back!",12,0), +(33532,@TEXT_WOLVAR_ORPHAN_3,"Good snowball fight!",12,0), +(33532,@TEXT_WOLVAR_ORPHAN_4,"Look! That must be Kekek as a mighty warrior! See? What Kekek tell you?",12,0), +(33532,@TEXT_WOLVAR_ORPHAN_5,"Hmm... that Kekek very old. Must be elder, leader of Frenzyheart. This good. Kekek have good future as warrior and leader. Kekek very happy you bring him here. Orphan-lady never do that for Kekek.",12,0), +(33532,@TEXT_WOLVAR_ORPHAN_6,"Wow. At last, Kekek get to meet Hemet Nesingwary!",12,0), +(33532,@TEXT_WOLVAR_ORPHAN_7,"Even Frenzyheart know all about you after you come to Sholazar. Maybe you teach Kekek your tricks?",12,0), +(33532,@TEXT_WOLVAR_ORPHAN_8,"Not sure how reading helps. Kekek can't read anyway, but if Hemet Nesingwary say, Kekek try.",12,0), +(33532,@TEXT_WOLVAR_ORPHAN_9,"Maybe give up and throw book at animals, but try.",12,0), +(33532,@TEXT_WOLVAR_ORPHAN_10,"You think maybe one day, Kekek lead Frenzyheart home, like bear-men fight to get tree-city back? Kekek want own home, not city with purple men, not jungle with big-tongues.",12,0), +(33532,@TEXT_WOLVAR_ORPHAN_11,"Kekek thought we go see dragon queen. This just some elf-lady with funny horns.",12,0), +(33532,@TEXT_WOLVAR_ORPHAN_12,"But why? Dragons big and powerful. Elf-lady weak. Kekek want to see dragon queen's real form.",12,0), +(33532,@TEXT_WOLVAR_ORPHAN_13,"Oh! Now Kekek understand. Not want to be crushed by big dragon-lady. Maybe come back sometime when not so crowded. Nice to meet you, dragon-lady.",12,0); + +DELETE FROM `game_event_creature_quest` WHERE `id`=33532; +INSERT INTO `game_event_creature_quest`(`eventEntry`,`id`,`quest`) VALUES +(10,33532,13938), +(10,33532,13960), +(10,33532,13930), +(10,33532,13951), +(10,33532,13934), +(10,33532,13955), +(10,33532,13957); + +DELETE FROM `creature_involvedrelation` WHERE `id`=33532; +INSERT INTO `creature_involvedrelation`(`id`,`quest`) VALUES +(33532,13938), +(33532,13930), +(33532,13927), +(33532,13951), +(33532,13934), +(33532,13955), +(33532,13957); + +DELETE FROM `conditions` WHERE `SourceTypeOrReferenceId` IN (19,20) AND `SourceEntry` IN (13955,13957,13938); +INSERT INTO `conditions`(`SourceTypeOrReferenceId`,`SourceEntry`,`ConditionTypeOrReference`,`ConditionValue1`,`comment`) VALUES +(19,13955,8,13930,'Accept quest 13955 - Quest 13930 needs to be rewarded'), +(19,13955,8,13934,'Accept quest 13955 - Quest 13934 needs to be rewarded'), +(19,13955,8,13951,'Accept quest 13955 - Quest 13951 needs to be rewarded'), +(19,13957,8,13930,'Accept quest 13957 - Quest 13930 needs to be rewarded'), +(19,13957,8,13934,'Accept quest 13957 - Quest 13934 needs to be rewarded'), +(19,13957,8,13951,'Accept quest 13957 - Quest 13951 needs to be rewarded'), +(19,13938,8,13957,'Accept quest 13938 - Quest 13957 needs to be rewarded'), +(20,13955,8,13930,'Show quest mark 13955 - Quest 13930 needs to be rewarded'), +(20,13955,8,13934,'Show quest mark 13955 - Quest 13934 needs to be rewarded'), +(20,13955,8,13951,'Show quest mark 13955 - Quest 13951 needs to be rewarded'), +(20,13957,8,13930,'Show quest mark 13957 - Quest 13930 needs to be rewarded'), +(20,13957,8,13934,'Show quest mark 13957 - Quest 13934 needs to be rewarded'), +(20,13957,8,13951,'Show quest mark 13957 - Quest 13951 needs to be rewarded'), +(20,13938,8,13957,'Show quest mark 13938 - Quest 13957 needs to be rewarded'); + +-- Blood Elf Orphan +UPDATE `quest_template` SET `SpecialFlags`=`SpecialFlags`|2 WHERE `Id` IN (10945,10953,10951,10963); + +DELETE FROM `game_event_creature_quest` WHERE `id`=22817; +INSERT INTO `game_event_creature_quest`(`eventEntry`,`id`,`quest`) VALUES +(10,22817,10945), +(10,22817,10953), +(10,22817,10951), +(10,22817,10963), +(10,22817,11975), +(10,22817,10967); + +DELETE FROM `creature_involvedrelation` WHERE `id`=22817; +INSERT INTO `creature_involvedrelation`(`id`,`quest`) VALUES +(22817,10942), +(22817,10951), +(22817,11975), +(22817,10963); + +DELETE FROM `conditions` WHERE `SourceTypeOrReferenceId` IN (19,20) AND `SourceEntry` IN (11975,10963,10967); +INSERT INTO `conditions`(`SourceTypeOrReferenceId`,`SourceEntry`,`ConditionTypeOrReference`,`ConditionValue1`,`comment`) VALUES +(19,11975,8,10945,'Accept quest 11975 - Quest 10945 needs to be rewarded'), +(19,11975,8,10953,'Accept quest 11975 - Quest 10953 needs to be rewarded'), +(19,11975,8,10951,'Accept quest 11975 - Quest 10951 needs to be rewarded'), +(19,10963,8,10945,'Accept quest 10963 - Quest 10945 needs to be rewarded'), +(19,10963,8,10953,'Accept quest 10963 - Quest 10953 needs to be rewarded'), +(19,10963,8,10951,'Accept quest 10963 - Quest 10951 needs to be rewarded'), +(19,10967,8,10963,'Accept quest 10967 - Quest 10963 needs to be rewarded'), +(20,11975,8,10945,'Show quest mark 11975 - Quest 10945 needs to be rewarded'), +(20,11975,8,10953,'Show quest mark 11975 - Quest 10953 needs to be rewarded'), +(20,11975,8,10951,'Show quest mark 11975 - Quest 10951 needs to be rewarded'), +(20,10963,8,10945,'Show quest mark 10963 - Quest 10945 needs to be rewarded'), +(20,10963,8,10953,'Show quest mark 10963 - Quest 10953 needs to be rewarded'), +(20,10963,8,10951,'Show quest mark 10963 - Quest 10951 needs to be rewarded'), +(20,10967,8,10963,'Show quest mark 10967 - Quest 10963 needs to be rewarded'); + +-- Draenei Orphan +UPDATE `quest_template` SET `SpecialFlags`=`SpecialFlags`|2 WHERE `Id` IN (10956,10968,10950,10952,10954,10962); + +DELETE FROM `game_event_creature_quest` WHERE `id`=22818; +INSERT INTO `game_event_creature_quest`(`eventEntry`,`id`,`quest`) VALUES +(10,22818,10952), +(10,22818,10950), +(10,22818,10966), +(10,22818,10954), +(10,22818,10956), +(10,22818,10962); + +DELETE FROM `creature_involvedrelation` WHERE `id`=22818; +INSERT INTO `creature_involvedrelation`(`id`,`quest`) VALUES +(22818,10950), +(22818,10952), +(22818,10943), +(22818,10962); + +DELETE FROM `conditions` WHERE `SourceTypeOrReferenceId` IN (19,20) AND `SourceEntry` IN (10956,10962,10966); +INSERT INTO `conditions`(`SourceTypeOrReferenceId`,`SourceEntry`,`ConditionTypeOrReference`,`ConditionValue1`,`comment`) VALUES +(19,10956,8,10950,'Accept quest 10956 - Quest 10950 needs to be rewarded'), +(19,10956,8,10954,'Accept quest 10956 - Quest 10954 needs to be rewarded'), +(19,10956,8,10952,'Accept quest 10956 - Quest 10952 needs to be rewarded'), +(19,10962,8,10950,'Accept quest 10962 - Quest 10950 needs to be rewarded'), +(19,10962,8,10954,'Accept quest 10962 - Quest 10954 needs to be rewarded'), +(19,10962,8,10952,'Accept quest 10962 - Quest 10952 needs to be rewarded'), +(19,10966,8,10962,'Accept quest 10966 - Quest 10962 needs to be rewarded'), +(20,10956,8,10950,'Show quest mark 10956 - Quest 10950 needs to be rewarded'), +(20,10956,8,10954,'Show quest mark 10956 - Quest 10954 needs to be rewarded'), +(20,10956,8,10952,'Show quest mark 10956 - Quest 10952 needs to be rewarded'), +(20,10962,8,10950,'Show quest mark 10962 - Quest 10950 needs to be rewarded'), +(20,10962,8,10954,'Show quest mark 10962 - Quest 10954 needs to be rewarded'), +(20,10962,8,10952,'Show quest mark 10962 - Quest 10952 needs to be rewarded'), +(20,10966,8,10962,'Show quest mark 10966 - Quest 10962 needs to be rewarded'); + +-- Human Orphan +DELETE FROM `creature_questrelation` WHERE `id`=14305; + +DELETE FROM `game_event_creature_quest` WHERE `id`=14305; +INSERT INTO `game_event_creature_quest`(`eventEntry`,`id`,`quest`) VALUES +(10,14305,171), +(10,14305,558), +(10,14305,1687), +(10,14305,1479), +(10,14305,1558), +(10,14305,4822); + +DELETE FROM `creature_involvedrelation` WHERE `id`=14305; +INSERT INTO `creature_involvedrelation`(`id`,`quest`) VALUES +(14305,1468), +(14305,558), +(14305,1687), +(14305,1479), +(14305,1558), +(14305,4822); + +DELETE FROM `conditions` WHERE `SourceTypeOrReferenceId` IN (19,20) AND `SourceEntry` IN (558,4822,171); +INSERT INTO `conditions`(`SourceTypeOrReferenceId`,`SourceEntry`,`ConditionTypeOrReference`,`ConditionValue1`,`comment`) VALUES +(19,558,8,1687,'Accept quest 558 - Quest 1687 needs to be rewarded'), +(19,558,8,1558,'Accept quest 558 - Quest 1558 needs to be rewarded'), +(19,558,8,1479,'Accept quest 558 - Quest 1479 needs to be rewarded'), +(19,558,16,1101,'Accept quest 558 - Needs to be in race mask 1101'), +(19,4822,8,1687,'Accept quest 4822 - Quest 1687 needs to be rewarded'), +(19,4822,8,1558,'Accept quest 4822 - Quest 1558 needs to be rewarded'), +(19,4822,8,1479,'Accept quest 4822 - Quest 1479 needs to be rewarded'), +(19,171,8,4822,'Accept quest 171 - Quest 4822 needs to be rewarded'), +(20,558,8,1687,'Show quest mark 558 - Quest 1687 needs to be rewarded'), +(20,558,8,1558,'Show quest mark 558 - Quest 1558 needs to be rewarded'), +(20,558,8,1479,'Show quest mark 558 - Quest 1479 needs to be rewarded'), +(20,558,16,1101,'Show quest mark 558 - Needs to be in race mask 1101'), +(20,4822,8,1687,'Show quest mark 4822 - Quest 1687 needs to be rewarded'), +(20,4822,8,1558,'Show quest mark 4822 - Quest 1558 needs to be rewarded'), +(20,4822,8,1479,'Show quest mark 4822 - Quest 1479 needs to be rewarded'), +(20,171,8,4822,'Show quest mark 171 - Quest 4822 needs to be rewarded'); + +-- Orcish Orphan +DELETE FROM `creature_questrelation` WHERE `id`=14444; + +DELETE FROM `game_event_creature_quest` WHERE `id`=14444; +INSERT INTO `game_event_creature_quest`(`eventEntry`,`id`,`quest`) VALUES +(10,14444,910), +(10,14444,911), +(10,14444,1800), +(10,14444,925), +(10,14444,915), +(10,14444,5502); + +DELETE FROM `creature_involvedrelation` WHERE `id`=14444; +INSERT INTO `creature_involvedrelation`(`id`,`quest`) VALUES +(14444,925), +(14444,172), +(14444,910), +(14444,911), +(14444,1800), +(14444,915); + +DELETE FROM `conditions` WHERE `SourceTypeOrReferenceId` IN (19,20) AND `SourceEntry` IN (915,925,5502); +INSERT INTO `conditions`(`SourceTypeOrReferenceId`,`SourceEntry`,`ConditionTypeOrReference`,`ConditionValue1`,`comment`) VALUES +(19,925,8,910,'Accept quest 925 - Quest 910 needs to be rewarded'), +(19,925,8,911,'Accept quest 925 - Quest 911 needs to be rewarded'), +(19,925,8,1800,'Accept quest 925 - Quest 1800 needs to be rewarded'), +(19,915,8,910,'Accept quest 915 - Quest 910 needs to be rewarded'), +(19,915,8,911,'Accept quest 915 - Quest 911 needs to be rewarded'), +(19,915,8,1800,'Accept quest 915 - Quest 1800 needs to be rewarded'), +(19,5502,8,925,'Accept quest 5502 - Quest 925 needs to be rewarded'), +(20,925,8,910,'Show quest mark 925 - Quest 910 needs to be rewarded'), +(20,925,8,911,'Show quest mark 925 - Quest 911 needs to be rewarded'), +(20,925,8,1800,'Show quest mark 925 - Quest 1800 needs to be rewarded'), +(20,915,8,910,'Show quest mark 915 - Quest 910 needs to be rewarded'), +(20,915,8,911,'Show quest mark 915 - Quest 911 needs to be rewarded'), +(20,915,8,1800,'Show quest mark 915 - Quest 1800 needs to be rewarded'), +(20,5502,8,925,'Show quest mark 5502 - Quest 925 needs to be rewarded'); + +-- Home of the bear-men +SET @GUIDS = 85179; +SET @GUID_GRIZZLEMAW_TRIGGER_1 = @GUIDS + 0; +SET @GUID_GRIZZLEMAW_TRIGGER_2 = @GUIDS + 1; +SET @GUID_GRIZZLEMAW_TRIGGER_3 = @GUIDS + 2; + +UPDATE `creature_template` SET `AIName`='',`ScriptName`='npc_grizzlemaw_cw_trigger',`flags_extra`=0 WHERE `entry`=36209; + +DELETE FROM `creature` WHERE `guid` IN (@GUID_GRIZZLEMAW_TRIGGER_1,@GUID_GRIZZLEMAW_TRIGGER_2,@GUID_GRIZZLEMAW_TRIGGER_3); +INSERT INTO `creature`(`guid`,`id`,`map`,`position_x`,`position_y`,`position_z`) VALUES +(@GUID_GRIZZLEMAW_TRIGGER_1,36209,571,4068.82,-3811,223.4), +(@GUID_GRIZZLEMAW_TRIGGER_2,36209,571,4073.2,-3734.354,222.6634), +(@GUID_GRIZZLEMAW_TRIGGER_3,36209,571,3923.109,-3763.967,165.362); + +-- Elder Kekek +SET @GUID_KEKEK = @GUIDS + 3; +SET @TEXT_ELDER_KEKEK_1 = 1; + +UPDATE `creature_template` SET `ScriptName`='npc_elder_kekek' WHERE `entry`=34387; + +DELETE FROM `creature` WHERE `guid`=@GUID_KEKEK OR `id`=34387; +INSERT INTO `creature`(`guid`,`id`,`map`,`position_x`,`position_y`,`position_z`,`orientation`) VALUES +(@GUID_KEKEK,34387,571,4181.482,-461.453,120.728,1.398097); + +DELETE FROM `creature_text` WHERE `entry`=34387; +INSERT INTO `creature_text`(`entry`,`groupid`,`text`,`type`,`emote`) VALUE +(34387,@TEXT_ELDER_KEKEK_1,"No worry, Kekek. You grow up, be strong for Frenzyheart. You lead people back to old home, where there no big-tongue babies.",12,0); + +-- Alexstraza +SET @TEXT_ALEXSTRASZA_2 = 2; +SET @TEXT_KRASUS_8 = 8; + +UPDATE `creature_template` SET `AIName`='',`ScriptName`='npc_alexstraza_the_lifebinder' WHERE `entry`=26917; + +DELETE FROM `creature_text` WHERE (`entry`=26917 AND `groupid`=@TEXT_ALEXSTRASZA_2) OR (`entry`=27990 AND `groupid`=@TEXT_KRASUS_8); +INSERT INTO `creature_text`(`entry`,`groupid`,`text`,`type`,`emote`) VALUE +(26917,@TEXT_ALEXSTRASZA_2,"If I was in my dragon form, there wouldn't be any room for anyone else, little one.",12,0), +(27990,@TEXT_KRASUS_8,"Rest assured, Kekek, she is the queen of the dragons. We often take the forms of smaller beings when we work with them.",12,0); + +-- High Oracle Soo Roo +SET @GUID_SOO_ROO = @GUIDS + 4; +SET @TEXT_SOO_ROO_1 = 1; + +UPDATE `creature_template` SET `AIName`='',`ScriptName`='npc_high_oracle_soo_roo' WHERE `entry`=34386; + +DELETE FROM `creature_text` WHERE `entry`=34386; +INSERT INTO `creature_text`(`entry`,`groupid`,`text`,`type`,`emote`) VALUE +(34386,@TEXT_SOO_ROO_1,"We remember this visit, yes we do. Never forget what you learn from your new friend, little Roo. You got great future ahead.",12,0); + +DELETE FROM `creature` WHERE `guid`=@GUID_SOO_ROO OR `id`=34386; +INSERT INTO `creature`(`guid`,`id`,`map`,`position_x`,`position_y`,`position_z`,`orientation`) VALUES +(@GUID_SOO_ROO,34386,571,4120.996,-329.486,121.443817,0.299253); + +-- Nesingwary +SET @TEXT_NESINGWARY_1 = 1; + +DELETE FROM `creature_text` WHERE `entry`=27986; +INSERT INTO `creature_text`(`entry`,`groupid`,`text`,`type`,`emote`) VALUE +(27986,@TEXT_NESINGWARY_1,"Well, lad, you can start by readin' The Green Hills of Stranglethorn. Then, maybe you can join me on one of my safaris. What do you say?",12,0); + +-- Snowfall Glade Playmate +SET @GUID_SNOWFALL_GLADE_PLAYMATE = @GUIDS + 5; +SET @TEXT_SNOWFALL_GLADE_PLAYMATE_1 = 1; +SET @TEXT_SNOWFALL_GLADE_PLAYMATE_2 = 2; + +UPDATE `creature_template` SET `AIName`='',`ScriptName`='npc_snowfall_glade_playmate' WHERE `entry`=34490; + +DELETE FROM `creature_text` WHERE `entry`=34490; +INSERT INTO `creature_text`(`entry`,`groupid`,`text`,`type`,`emote`) VALUE +(34490,@TEXT_SNOWFALL_GLADE_PLAYMATE_1,"Better watch out!",12,0), +(34490,@TEXT_SNOWFALL_GLADE_PLAYMATE_2,"Got you good!",12,0); + +DELETE FROM `creature` WHERE `guid`=@GUID_SNOWFALL_GLADE_PLAYMATE OR `id`=34490; +INSERT INTO `creature`(`guid`,`id`,`map`,`position_x`,`position_y`,`position_z`,`orientation`) VALUES +(@GUID_SNOWFALL_GLADE_PLAYMATE,34490,571,3325.193,1026.451,138.1712,2.062184); + +-- Winterfin Playmate +SET @GUID_WINTERFIN_PLAYMATE = @GUIDS + 6; +SET @TEXT_WINTERFIN_PLAYMATE_1 = 1; +SET @TEXT_WINTERFIN_PLAYMATE_2 = 2; + +UPDATE `creature_template` SET `AIName`='',`ScriptName`='npc_winterfin_playmate' WHERE `entry`=34489; + +DELETE FROM `creature_text` WHERE `entry`=34489; +INSERT INTO `creature_text`(`entry`,`groupid`,`text`,`type`,`emote`) VALUE +(34489,@TEXT_WINTERFIN_PLAYMATE_1,"Wanna see what I can do?",12,0), +(34489,@TEXT_WINTERFIN_PLAYMATE_2,"Now dance together!",12,0); + +DELETE FROM `creature` WHERE `guid`=@GUID_WINTERFIN_PLAYMATE OR `id`=34489; +INSERT INTO `creature`(`guid`,`id`,`map`,`position_x`,`position_y`,`position_z`,`orientation`) VALUES +(@GUID_WINTERFIN_PLAYMATE,34489,571,4382.502,6066.199,0.724562,3.571894); + +-- Biggest Tree Ever +SET @GUID_BIGGEST_TREE_TRIGGER = @GUIDS + 7; + +UPDATE `creature_template` SET `AIName`='',`ScriptName`='npc_the_biggest_tree',`flags_extra`=0 WHERE `entry`=34381; + +DELETE FROM `creature` WHERE `guid`=@GUID_BIGGEST_TREE_TRIGGER OR `id`=34381; +INSERT INTO `creature`(`guid`,`id`,`map`,`position_x`,`position_y`,`position_z`,`orientation`) VALUES +(@GUID_BIGGEST_TREE_TRIGGER,34381,571,4022.666,-3777.682,115.443588,4.857019); + +-- Meeting A Great One +UPDATE `creature_template` SET `ScriptName`='npc_the_etymidian' WHERE `entry`=28092; + +-- POIs +DELETE FROM `quest_poi` WHERE `questId` IN (13956,13929,13950,13951,13957,13933,13934,13930,13954,13955); +INSERT INTO `quest_poi`(`questId`,`objIndex`,`mapid`,`WorldMapAreaId`,`unk4`) VALUES +(13956,16,1,201,3), +(13929,16,571,490,3), +(13950,16,571,486,3), +(13951,16,571,488,3), +(13957,16,571,493,3), +(13933,16,571,488,3), +(13934,16,571,488,3), +(13930,16,571,490,3), +(13954,16,571,488,3), +(13955,16,571,488,3); + +DELETE FROM `quest_poi_points` WHERE `questid` IN (13956,13929,13950,13951,13957,13933,13934,13930,13954,13955); +INSERT INTO `quest_poi_points`(`questId`,`x`,`y`) VALUES +(13956,-6193,-1223), +(13929,4022,-3777), +(13950,4382,6066), +(13951,3325,1026), +(13957,5584,5748), +(13933,4121,-329), +(13934,4181,-461), +(13930,4071,-3773), +(13954,3530,271), +(13955,3530,271); + +-- NPC areatriggers +SET @GUID_AERIS_LANDING_TRIGGER = @GUIDS + 8; +SET @GUID_SILVERMOON_TRIGGER_01 = @GUIDS + 9; +SET @GUID_AUCHINDOUN_TRIGGER = @GUIDS + 10; +SET @GUID_SPOREGGAR_TRIGGER = @GUIDS + 11; +SET @GUID_THRONE_OF_ELEMENTS_TRIGGER = @GUIDS + 12; + +UPDATE `creature_template` SET `InhabitType`=7,`flags_extra`=0,`unit_flags`=33554432,`ScriptName`='npc_cw_area_trigger',`AIName`='' WHERE `entry` IN (22905,22851,22838,22866,22831,22829,22872,22839); + +DELETE FROM `creature` WHERE `guid` IN (@GUID_SILVERMOON_TRIGGER_01,@GUID_AERIS_LANDING_TRIGGER,@GUID_AUCHINDOUN_TRIGGER,@GUID_SPOREGGAR_TRIGGER,@GUID_THRONE_OF_ELEMENTS_TRIGGER); +INSERT INTO `creature`(`guid`,`id`,`map`,`position_x`,`position_y`,`position_z`,`orientation`) VALUES +(@GUID_AERIS_LANDING_TRIGGER,22838,530,-2075.759,8559.336,23.027,4.857019), +(@GUID_SILVERMOON_TRIGGER_01,22866,530,9506.086,-7329.313,14.397272,0), +(@GUID_AUCHINDOUN_TRIGGER,22831,530,-3320.860,4925.095,-101.1,0), +(@GUID_SPOREGGAR_TRIGGER,22829,530,203.587,8550.11,22.3256,0), +(@GUID_THRONE_OF_ELEMENTS_TRIGGER,22839,530,-781.294,6943.52,33.3344,0); + +-- Misc +DELETE `game_event_creature` FROM `game_event_creature` INNER JOIN `creature` ON `creature`.`guid`=`game_event_creature`.`guid` +WHERE `id` IN (22905,22851,22838,22866,22831,22829,22872,22839,14450,22819,14451,34365,34387,34386,34490,34489,34381,36209); +INSERT INTO `game_event_creature`(`eventEntry`,`guid`) SELECT 10,`guid` FROM `creature` +WHERE `id` IN (22905,22851,22838,22866,22831,22829,22872,22839,14450,22819,14451,34365,34387,34386,34490,34489,34381,36209); + +DELETE FROM `game_event_npc_vendor` WHERE `eventEntry`=10 AND `item`=46693; +INSERT INTO `game_event_npc_vendor` (`eventEntry`, `guid`, `item`) VALUES +(10,99369,46693), +(10,97984,46693); + +UPDATE `item_template` SET `minMoneyLoot`=50000,`maxMoneyLoot`=50000 WHERE `entry`=23022; +UPDATE `item_template` SET `HolidayId`=201 WHERE `entry` IN (46396,46397,31880,31881,18598,18597); + +DELETE FROM `conditions` WHERE `SourceTypeOrReferenceId`=17 AND `SourceEntry` IN (23012,23013,39478,39479,65352,65353); +INSERT INTO `conditions` (`SourceTypeOrReferenceId`,`SourceGroup`,`SourceEntry`,`ElseGroup`,`ConditionTypeOrReference`,`ConditionValue1`,`ErrorTextId`,`Comment`) VALUES +(17,0,23012,0,12,10,0,"Orphan Whistle only while children's week"), +(17,0,23013,0,12,10,0,"Orphan Whistle only while children's week"), +(17,0,39478,0,12,10,0,"Orphan Whistle only while children's week"), +(17,0,39479,0,12,10,0,"Orphan Whistle only while children's week"), +(17,0,65352,0,12,10,0,"Orphan Whistle only while children's week"), +(17,0,65353,0,12,10,0,"Orphan Whistle only while children's week"); + +UPDATE `quest_poi_points` SET `x`=1642,`y`=239 WHERE `questId`=1800 AND `id`=0 AND `idx`=0; +UPDATE `quest_poi_points` SET `x`=-248,`y`=956 WHERE `questId`=10952 AND `id`=0 AND `idx`=0; +UPDATE `quest_poi_points` SET `x`=-11400.211,`y`=1944.599 WHERE `questId`=1687 AND `id`=0 AND `idx`=0; +UPDATE `quest_poi_points` SET `x`=-998.183,`y`=-3822.07 WHERE `questId`=910 AND `id`=0 AND `idx`=0; +UPDATE `quest_poi_points` SET `x`=1260.812,`y`=-2223.765 WHERE `questId`=911 AND `id`=0 AND `idx`=0; +UPDATE `quest_poi_points` SET `x`=9933,`y`=2500 WHERE `questId`=1479 AND `id`=0 AND `idx`=0; +UPDATE `quest_poi_points` SET `x`=-2075.759,`y`=8559.336 WHERE `questId`=10954 AND `id`=0 AND `idx`=0; +UPDATE `quest_poi_points` SET `x`=9506,`y`=-7329 WHERE `questId`=11975 AND `id`=0 AND `idx`=0; +UPDATE `quest_poi_points` SET `x`=-3320.860,`y`=4925.095 WHERE `questId`=10950 AND `id`=0 AND `idx`=0; +UPDATE `quest_poi_points` SET `x`=203.587,`y`=8550.11 WHERE `questId`=10945 AND `id`=0 AND `idx`=0; +UPDATE `quest_poi_points` SET `x`=-781.294,`y`=6943.52 WHERE `questId`=10953 AND `id`=0 AND `idx`=0; diff --git a/sql/updates/world/2012_10_26_00_world_sai.sql b/sql/updates/world/2012_10_26_00_world_sai.sql new file mode 100644 index 00000000000..8e4c2fa0922 --- /dev/null +++ b/sql/updates/world/2012_10_26_00_world_sai.sql @@ -0,0 +1 @@ +UPDATE `smart_scripts` SET `action_param3`=3500,`action_param4`=6000 WHERE `entryorguid`=9458 AND `source_type`=0 AND `id`=0; diff --git a/sql/updates/world/2012_10_27_00_world_creature.sql b/sql/updates/world/2012_10_27_00_world_creature.sql new file mode 100644 index 00000000000..c00c450aeca --- /dev/null +++ b/sql/updates/world/2012_10_27_00_world_creature.sql @@ -0,0 +1,13 @@ +-- Dragonbone Condor +UPDATE `creature` SET `spawndist`=0, `MovementType`=0 WHERE `guid` IN (106595,106596,106597,106598,106603,106604,106605,106607,106608,106626,106629,106631,106643,106646,106658,106663,106665,106668,106669,106675,106676,106679,106680,106681,106682,106683,106684,106685,106686,106687,106688,106692,106693,106696,106702,106703,106706,106722,106723,106724,106726,106727,106728,106733,106737,106741,106749,106755,106757,131072); +UPDATE `creature` SET `position_z`=72.130 WHERE `guid`=106631; +UPDATE `creature` SET `position_z`=72.902 WHERE `guid`=106675; +UPDATE `creature` SET `position_z`=69.505 WHERE `guid`=131072; +/* Carrion Condor + * All these have unitfieldbyte1=1 which means sitting. Obviously that makes no sense when they are moving randomly within their spawndist. They should be sitting on the pillars in Borean Tundra. + * There are some that are spawned very close to dead Taunka. From retail I know they should be flying directly on top of them not moving so I changed them, too. */ +UPDATE `creature` SET `spawndist`=0, `MovementType`=0 WHERE `guid` IN (101804,101805,101806,101807,101808,101809,101810,101814,101815,101818,101819,101820,101823,101824,101825,101832,101834,101836,101837,101838,101839,101842,101845,101849,101850,101856,101859,101860,101862,101866,101872,101876,101877,101890,101921,101923); +-- Courier Lanson: The npc should be sleeping on the bed instead of just standing there. +DELETE FROM `creature_template_addon` WHERE `entry`=27060; +INSERT INTO `creature_template_addon` (`entry`,`path_id`,`mount`,`bytes1`,`bytes2`,`emote`,`auras`) VALUES +(27060,0,0,3,0,0,''); diff --git a/sql/updates/world/2012_10_27_01_world_creature_loot_template.sql b/sql/updates/world/2012_10_27_01_world_creature_loot_template.sql new file mode 100644 index 00000000000..3367dbf0fa8 --- /dev/null +++ b/sql/updates/world/2012_10_27_01_world_creature_loot_template.sql @@ -0,0 +1,22 @@ +DELETE FROM `conditions` WHERE `SourceTypeOrReferenceId`=1 AND `SourceEntry`=51315; +INSERT INTO `conditions` (`SourceTypeOrReferenceId`,`SourceGroup`,`SourceEntry`,`SourceId`,`ElseGroup`,`ConditionTypeOrReference`,`ConditionTarget`,`ConditionValue1`,`ConditionValue2`,`ConditionValue3`,`NegativeCondition`,`ErrorTextId`,`Scriptname`,`Comment`) VALUES +-- Lich King 10N +(1,36597,51315,0,1,2,0,51315,1,1,1,0 ,'' , 'Sealed Chest will drop only if the player doesn''t have it already'), +(1,36597,51315,0,1,3,0,49623,1,1,1,0 ,'' , 'Sealed Chest will drop only if the player is wielding Shadowmourne'), +(1,36597,51315,0,1,9,0,24748,0,0,0,0 ,'' , 'Sealed Chest will drop only if the player has "The Lich King''s Last Stand" in their quest log'), +(1,36597,51315,0,1,14,0,24914,0,0,0,0,'' , 'Sealed Chest will drop only if the player has not completed the quest Personal Property'), +-- Lich King 25N +(1,39166,51315,0,1,2,0,51315,1,1,1,0 ,'' , 'Sealed Chest will drop only if the player doesn''t have it already'), +(1,39166,51315,0,1,3,0,49623,1,1,1,0 ,'' , 'Sealed Chest will drop only if the player is wielding Shadowmourne'), +(1,39166,51315,0,1,9,0,24748,0,0,0,0 ,'' , 'Sealed Chest will drop only if the player has "The Lich King''s Last Stand" in their quest log'), +(1,39166,51315,0,1,14,0,24914,0,0,0,0,'' , 'Sealed Chest will drop only if the player has not completed the quest Personal Property'), +-- Lich King 10H +(1,39167,51315,0,1,2,0,51315,1,1,1,0 ,'' , 'Sealed Chest will drop only if the player doesn''t have it already'), +(1,39167,51315,0,1,3,0,49623,1,1,1,0 ,'' , 'Sealed Chest will drop only if the player is wielding Shadowmourne'), +(1,39167,51315,0,1,9,0,24748,0,0,0,0 ,'' , 'Sealed Chest will drop only if the player has "The Lich King''s Last Stand" in their quest log'), +(1,39167,51315,0,1,14,0,24914,0,0,0,0,'' , 'Sealed Chest will drop only if the player has not completed the quest Personal Property'), +-- Lich King 25H +(1,39168,51315,0,1,2,0,51315,1,1,1,0 ,'' , 'Sealed Chest will drop only if the player doesn''t have it already'), +(1,39168,51315,0,1,3,0,49623,1,1,1,0 ,'' , 'Sealed Chest will drop only if the player is wielding Shadowmourne'), +(1,39168,51315,0,1,9,0,24748,0,0,0,0 ,'' , 'Sealed Chest will drop only if the player has "The Lich King''s Last Stand" in their quest log'), +(1,39168,51315,0,1,14,0,24914,0,0,0,0,'' , 'Sealed Chest will drop only if the player has not completed the quest Personal Property'); diff --git a/sql/updates/world/2012_10_29_00_world_conditions.sql b/sql/updates/world/2012_10_29_00_world_conditions.sql new file mode 100644 index 00000000000..d1fac5361fb --- /dev/null +++ b/sql/updates/world/2012_10_29_00_world_conditions.sql @@ -0,0 +1,2 @@ +-- fix bad condition2/3 values on ItemEquip Conditions +UPDATE `conditions` SET `ConditionValue2`=0,`ConditionValue3`=0 WHERE `ConditionTypeOrReference`=3; diff --git a/sql/updates/world/2012_11_03_00_world_creature_loot_template.sql b/sql/updates/world/2012_11_03_00_world_creature_loot_template.sql new file mode 100644 index 00000000000..0e5c39b796d --- /dev/null +++ b/sql/updates/world/2012_11_03_00_world_creature_loot_template.sql @@ -0,0 +1,6 @@ +-- Readd loot to Stinky +DELETE FROM `creature_loot_template` WHERE `entry` IN(37025,38064); +INSERT INTO `creature_loot_template` (`entry`,`item`,`ChanceOrQuestChance`,`lootmode`,`groupid`,`mincountOrRef`,`maxcount`) +VALUES +(37025,1,100,1,0,-35069,2), +(38064,1,100,1,0,-35069,2); diff --git a/src/server/authserver/Main.cpp b/src/server/authserver/Main.cpp index 011210dd95b..90d112a1433 100755 --- a/src/server/authserver/Main.cpp +++ b/src/server/authserver/Main.cpp @@ -86,7 +86,7 @@ extern int main(int argc, char **argv) { if (++c >= argc) { - printf("Runtime-Error: -c option requires an input argument"); + printf("Runtime-Error: -c option requires an input argument\n"); usage(argv[0]); return 1; } @@ -98,8 +98,8 @@ extern int main(int argc, char **argv) if (!ConfigMgr::Load(cfg_file)) { - printf("Invalid or missing configuration file : %s", cfg_file); - printf("Verify that the file exists and has \'[authserver]\' written in the top of the file!"); + printf("Invalid or missing configuration file : %s\n", cfg_file); + printf("Verify that the file exists and has \'[authserver]\' written in the top of the file!\n"); return 1; } diff --git a/src/server/game/AI/CoreAI/GuardAI.cpp b/src/server/game/AI/CoreAI/GuardAI.cpp index 6e2326ca9d5..90ca7009098 100755 --- a/src/server/game/AI/CoreAI/GuardAI.cpp +++ b/src/server/game/AI/CoreAI/GuardAI.cpp @@ -40,8 +40,8 @@ bool GuardAI::CanSeeAlways(WorldObject const* obj) if (!obj->isType(TYPEMASK_UNIT)) return false; - std::list<HostileReference*> threatList = me->getThreatManager().getThreatList(); - for (std::list<HostileReference*>::const_iterator itr = threatList.begin(); itr != threatList.end(); ++itr) + ThreatContainer::StorageType threatList = me->getThreatManager().getThreatList(); + for (ThreatContainer::StorageType::const_iterator itr = threatList.begin(); itr != threatList.end(); ++itr) if ((*itr)->getUnitGuid() == obj->GetGUID()) return true; diff --git a/src/server/game/AI/CoreAI/UnitAI.cpp b/src/server/game/AI/CoreAI/UnitAI.cpp index e159c1a7d9b..9f2c9a86094 100755 --- a/src/server/game/AI/CoreAI/UnitAI.cpp +++ b/src/server/game/AI/CoreAI/UnitAI.cpp @@ -60,25 +60,20 @@ void UnitAI::DoMeleeAttackIfReady() bool UnitAI::DoSpellAttackIfReady(uint32 spell) { - if (me->HasUnitState(UNIT_STATE_CASTING)) + if (me->HasUnitState(UNIT_STATE_CASTING) || !me->isAttackReady()) return true; - if (me->isAttackReady()) + if (SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spell)) { - if (SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spell)) + if (me->IsWithinCombatRange(me->getVictim(), spellInfo->GetMaxRange(false))) { - if (me->IsWithinCombatRange(me->getVictim(), spellInfo->GetMaxRange(false))) - { - me->CastSpell(me->getVictim(), spell, false); - me->resetAttackTimer(); - } - else - return false; + me->CastSpell(me->getVictim(), spell, false); + me->resetAttackTimer(); + return true; } - else - return false; } - return true; + + return false; } Unit* UnitAI::SelectTarget(SelectAggroTarget targetType, uint32 position, float dist, bool playerOnly, int32 aura) @@ -101,8 +96,8 @@ void UnitAI::DoAddAuraToAllHostilePlayers(uint32 spellid) { if (me->isInCombat()) { - std::list<HostileReference*>& threatlist = me->getThreatManager().getThreatList(); - for (std::list<HostileReference*>::iterator itr = threatlist.begin(); itr != threatlist.end(); ++itr) + ThreatContainer::StorageType threatlist = me->getThreatManager().getThreatList(); + for (ThreatContainer::StorageType::const_iterator itr = threatlist.begin(); itr != threatlist.end(); ++itr) { if (Unit* unit = Unit::GetUnit(*me, (*itr)->getUnitGuid())) if (unit->GetTypeId() == TYPEID_PLAYER) @@ -116,8 +111,8 @@ void UnitAI::DoCastToAllHostilePlayers(uint32 spellid, bool triggered) { if (me->isInCombat()) { - std::list<HostileReference*>& threatlist = me->getThreatManager().getThreatList(); - for (std::list<HostileReference*>::iterator itr = threatlist.begin(); itr != threatlist.end(); ++itr) + ThreatContainer::StorageType threatlist = me->getThreatManager().getThreatList(); + for (ThreatContainer::StorageType::const_iterator itr = threatlist.begin(); itr != threatlist.end(); ++itr) { if (Unit* unit = Unit::GetUnit(*me, (*itr)->getUnitGuid())) if (unit->GetTypeId() == TYPEID_PLAYER) diff --git a/src/server/game/AI/CoreAI/UnitAI.h b/src/server/game/AI/CoreAI/UnitAI.h index 89359372355..b07c766ae0b 100755 --- a/src/server/game/AI/CoreAI/UnitAI.h +++ b/src/server/game/AI/CoreAI/UnitAI.h @@ -61,7 +61,7 @@ struct DefaultTargetSelector : public std::unary_function<Unit*, bool> // dist: if 0: ignored, if > 0: maximum distance to the reference unit, if < 0: minimum distance to the reference unit // playerOnly: self explaining // aura: if 0: ignored, if > 0: the target shall have the aura, if < 0, the target shall NOT have the aura - DefaultTargetSelector(Unit const* unit, float dist, bool playerOnly, int32 aura) : me(unit), m_dist(dist), m_playerOnly(playerOnly), m_aura(aura) {} + DefaultTargetSelector(Unit const* unit, float dist, bool playerOnly, int32 aura) : me(unit), m_dist(dist), m_playerOnly(playerOnly), m_aura(aura) { } bool operator()(Unit const* target) const { @@ -156,12 +156,12 @@ class UnitAI // predicate shall extend std::unary_function<Unit*, bool> template <class PREDICATE> Unit* SelectTarget(SelectAggroTarget targetType, uint32 position, PREDICATE const& predicate) { - const std::list<HostileReference*>& threatlist = me->getThreatManager().getThreatList(); + ThreatContainer::StorageType const& threatlist = me->getThreatManager().getThreatList(); if (position >= threatlist.size()) return NULL; std::list<Unit*> targetList; - for (std::list<HostileReference*>::const_iterator itr = threatlist.begin(); itr != threatlist.end(); ++itr) + for (ThreatContainer::StorageType::const_iterator itr = threatlist.begin(); itr != threatlist.end(); ++itr) if (predicate((*itr)->getTarget())) targetList.push_back((*itr)->getTarget()); @@ -206,11 +206,11 @@ class UnitAI // predicate shall extend std::unary_function<Unit*, bool> template <class PREDICATE> void SelectTargetList(std::list<Unit*>& targetList, PREDICATE const& predicate, uint32 maxTargets, SelectAggroTarget targetType) { - std::list<HostileReference*> const& threatlist = me->getThreatManager().getThreatList(); + ThreatContainer::StorageType const& threatlist = me->getThreatManager().getThreatList(); if (threatlist.empty()) return; - for (std::list<HostileReference*>::const_iterator itr = threatlist.begin(); itr != threatlist.end(); ++itr) + for (ThreatContainer::StorageType::const_iterator itr = threatlist.begin(); itr != threatlist.end(); ++itr) if (predicate((*itr)->getTarget())) targetList.push_back((*itr)->getTarget()); diff --git a/src/server/game/AI/EventAI/CreatureEventAI.cpp b/src/server/game/AI/EventAI/CreatureEventAI.cpp index 951a035628a..78a84eb7ae4 100755 --- a/src/server/game/AI/EventAI/CreatureEventAI.cpp +++ b/src/server/game/AI/EventAI/CreatureEventAI.cpp @@ -520,10 +520,10 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32 break; case ACTION_T_THREAT_ALL_PCT: { - std::list<HostileReference*>& threatList = me->getThreatManager().getThreatList(); - for (std::list<HostileReference*>::iterator i = threatList.begin(); i != threatList.end(); ++i) - if (Unit* Temp = Unit::GetUnit(*me, (*i)->getUnitGuid())) - me->getThreatManager().modifyThreatPercent(Temp, action.threat_all_pct.percent); + ThreatContainer::StorageType const& threatList = me->getThreatManager().getThreatList(); + for (ThreatContainer::StorageType::const_iterator i = threatList.begin(); i != threatList.end(); ++i) + if (Unit* unit = Unit::GetUnit(*me, (*i)->getUnitGuid())) + me->getThreatManager().modifyThreatPercent(unit, action.threat_all_pct.percent); break; } case ACTION_T_QUEST_EVENT: @@ -634,11 +634,11 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32 break; case ACTION_T_CAST_EVENT_ALL: { - std::list<HostileReference*>& threatList = me->getThreatManager().getThreatList(); - for (std::list<HostileReference*>::iterator i = threatList.begin(); i != threatList.end(); ++i) - if (Unit* Temp = Unit::GetUnit(*me, (*i)->getUnitGuid())) - if (Temp->GetTypeId() == TYPEID_PLAYER) - Temp->ToPlayer()->CastedCreatureOrGO(action.cast_event_all.creatureId, me->GetGUID(), action.cast_event_all.spellId); + ThreatContainer::StorageType const& threatList = me->getThreatManager().getThreatList(); + for (ThreatContainer::StorageType::const_iterator i = threatList.begin(); i != threatList.end(); ++i) + if (Unit* unit = Unit::GetUnit(*me, (*i)->getUnitGuid())) + if (unit->GetTypeId() == TYPEID_PLAYER) + unit->ToPlayer()->CastedCreatureOrGO(action.cast_event_all.creatureId, me->GetGUID(), action.cast_event_all.spellId); break; } case ACTION_T_REMOVEAURASFROMSPELL: @@ -884,11 +884,11 @@ void CreatureEventAI::Reset() (*i).Enabled = true; break; } - //default: - //TODO: enable below code line / verify this is correct to enable events previously disabled (ex. aggro yell), instead of enable this in void EnterCombat() - //(*i).Enabled = true; - //(*i).Time = 0; - //break; + default: + //TODO: enable below code line / verify this is correct to enable events previously disabled (ex. aggro yell), instead of enable this in void EnterCombat() + //(*i).Enabled = true; + //(*i).Time = 0; + break; } } } diff --git a/src/server/game/AI/EventAI/CreatureEventAIMgr.cpp b/src/server/game/AI/EventAI/CreatureEventAIMgr.cpp index 728b17b0bbf..2d973d9eb8f 100755 --- a/src/server/game/AI/EventAI/CreatureEventAIMgr.cpp +++ b/src/server/game/AI/EventAI/CreatureEventAIMgr.cpp @@ -44,7 +44,6 @@ void CreatureEventAIMgr::LoadCreatureEventAI_Texts() if (!result) { sLog->outInfo(LOG_FILTER_SERVER_LOADING, ">> Loaded 0 additional CreatureEventAI Texts data. DB table `creature_ai_texts` is empty."); - return; } @@ -99,7 +98,6 @@ void CreatureEventAIMgr::LoadCreatureEventAI_Texts() while (result->NextRow()); sLog->outInfo(LOG_FILTER_SERVER_LOADING, ">> Loaded %u additional CreatureEventAI Texts data in %u ms", count, GetMSTimeDiffToNow(oldMSTime)); - } void CreatureEventAIMgr::LoadCreatureEventAI_Summons() @@ -115,7 +113,6 @@ void CreatureEventAIMgr::LoadCreatureEventAI_Summons() if (!result) { sLog->outInfo(LOG_FILTER_SERVER_LOADING, ">> Loaded 0 CreatureEventAI Summon definitions. DB table `creature_ai_summons` is empty."); - return; } @@ -147,7 +144,6 @@ void CreatureEventAIMgr::LoadCreatureEventAI_Summons() while (result->NextRow()); sLog->outInfo(LOG_FILTER_SERVER_LOADING, ">> Loaded %u CreatureEventAI summon definitions in %u ms", count, GetMSTimeDiffToNow(oldMSTime)); - } void CreatureEventAIMgr::LoadCreatureEventAI_Scripts() @@ -168,7 +164,6 @@ void CreatureEventAIMgr::LoadCreatureEventAI_Scripts() if (!result) { sLog->outInfo(LOG_FILTER_SERVER_LOADING, ">> Loaded 0 CreatureEventAI scripts. DB table `creature_ai_scripts` is empty."); - return; } @@ -739,5 +734,4 @@ void CreatureEventAIMgr::LoadCreatureEventAI_Scripts() while (result->NextRow()); sLog->outInfo(LOG_FILTER_SERVER_LOADING, ">> Loaded %u CreatureEventAI scripts in %u ms", count, GetMSTimeDiffToNow(oldMSTime)); - } diff --git a/src/server/game/AI/ScriptedAI/ScriptedCreature.cpp b/src/server/game/AI/ScriptedAI/ScriptedCreature.cpp index 76bb3aaa76a..f8025a32b7f 100644 --- a/src/server/game/AI/ScriptedAI/ScriptedCreature.cpp +++ b/src/server/game/AI/ScriptedAI/ScriptedCreature.cpp @@ -254,12 +254,11 @@ void ScriptedAI::DoResetThreat() return; } - std::list<HostileReference*>& threatlist = me->getThreatManager().getThreatList(); + ThreatContainer::StorageType threatlist = me->getThreatManager().getThreatList(); - for (std::list<HostileReference*>::iterator itr = threatlist.begin(); itr != threatlist.end(); ++itr) + for (ThreatContainer::StorageType::const_iterator itr = threatlist.begin(); itr != threatlist.end(); ++itr) { Unit* unit = Unit::GetUnit(*me, (*itr)->getUnitGuid()); - if (unit && DoGetThreat(unit)) DoModifyThreatPercent(unit, -100); } @@ -299,7 +298,8 @@ void ScriptedAI::DoTeleportPlayer(Unit* unit, float x, float y, float z, float o if (Player* player = unit->ToPlayer()) player->TeleportTo(unit->GetMapId(), x, y, z, o, TELE_TO_NOT_LEAVE_COMBAT); else - sLog->outError(LOG_FILTER_TSCR, "Creature " UI64FMTD " (Entry: %u) Tried to teleport non-player unit (Type: %u GUID: " UI64FMTD ") to x: %f y:%f z: %f o: %f. Aborted.", me->GetGUID(), me->GetEntry(), unit->GetTypeId(), unit->GetGUID(), x, y, z, o); + sLog->outError(LOG_FILTER_TSCR, "Creature " UI64FMTD " (Entry: %u) Tried to teleport non-player unit (Type: %u GUID: " UI64FMTD ") to x: %f y:%f z: %f o: %f. Aborted.", + me->GetGUID(), me->GetEntry(), unit->GetTypeId(), unit->GetGUID(), x, y, z, o); } void ScriptedAI::DoTeleportAll(float x, float y, float z, float o) @@ -331,6 +331,7 @@ std::list<Creature*> ScriptedAI::DoFindFriendlyCC(float range) Trinity::FriendlyCCedInRange u_check(me, range); Trinity::CreatureListSearcher<Trinity::FriendlyCCedInRange> searcher(me, list, u_check); me->VisitNearbyObject(range, searcher); + return list; } @@ -340,6 +341,7 @@ std::list<Creature*> ScriptedAI::DoFindFriendlyMissingBuff(float range, uint32 u Trinity::FriendlyMissingBuffInRange u_check(me, range, uiSpellid); Trinity::CreatureListSearcher<Trinity::FriendlyMissingBuffInRange> searcher(me, list, u_check); me->VisitNearbyObject(range, searcher); + return list; } @@ -451,7 +453,6 @@ void Scripted_NoMovementAI::AttackStart(Unit* target) } // BossAI - for instanced bosses - BossAI::BossAI(Creature* creature, uint32 bossId) : ScriptedAI(creature), instance(creature->GetInstanceScript()), summons(creature), @@ -503,8 +504,9 @@ void BossAI::TeleportCheaters() { float x, y, z; me->GetPosition(x, y, z); - std::list<HostileReference*>& threatList = me->getThreatManager().getThreatList(); - for (std::list<HostileReference*>::iterator itr = threatList.begin(); itr != threatList.end(); ++itr) + + ThreatContainer::StorageType threatList = me->getThreatManager().getThreatList(); + for (ThreatContainer::StorageType::const_iterator itr = threatList.begin(); itr != threatList.end(); ++itr) if (Unit* target = (*itr)->getTarget()) if (target->GetTypeId() == TYPEID_PLAYER && !CheckBoundary(target)) target->NearTeleportTo(x, y, z, 0); diff --git a/src/server/game/AI/ScriptedAI/ScriptedEscortAI.cpp b/src/server/game/AI/ScriptedAI/ScriptedEscortAI.cpp index 003c9ac9d1c..9c666e7de32 100644 --- a/src/server/game/AI/ScriptedAI/ScriptedEscortAI.cpp +++ b/src/server/game/AI/ScriptedAI/ScriptedEscortAI.cpp @@ -438,7 +438,7 @@ void npc_escortAI::Start(bool isActiveAttacker /* = true*/, bool run /* = false if (WaypointList.empty()) { - sLog->outError(LOG_FILTER_SQL, "TSCR: EscortAI (script: %s, creature entry: %u) starts with 0 waypoints (possible missing entry in script_waypoint. Quest: %u).", + sLog->outError(LOG_FILTER_TSCR, "EscortAI (script: %s, creature entry: %u) starts with 0 waypoints (possible missing entry in script_waypoint. Quest: %u).", me->GetScriptName().c_str(), me->GetEntry(), quest ? quest->GetQuestId() : 0); return; } diff --git a/src/server/game/AI/ScriptedAI/ScriptedFollowerAI.cpp b/src/server/game/AI/ScriptedAI/ScriptedFollowerAI.cpp index 1e83c203553..ebb734156b4 100644 --- a/src/server/game/AI/ScriptedAI/ScriptedFollowerAI.cpp +++ b/src/server/game/AI/ScriptedAI/ScriptedFollowerAI.cpp @@ -116,7 +116,7 @@ void FollowerAI::MoveInLineOfSight(Unit* who) } } -void FollowerAI::JustDied(Unit* /*pKiller*/) +void FollowerAI::JustDied(Unit* /*killer*/) { if (!HasFollowState(STATE_FOLLOW_INPROGRESS) || !m_uiLeaderGUID || !m_pQuestForFollow) return; @@ -305,7 +305,7 @@ void FollowerAI::StartFollow(Player* player, uint32 factionForFollower, const Qu me->GetMotionMaster()->MoveFollow(player, PET_FOLLOW_DIST, PET_FOLLOW_ANGLE); - sLog->outDebug(LOG_FILTER_TSCR, "FollowerAI start follow %s (GUID " UI64FMTD ")", player->GetName(), m_uiLeaderGUID); + sLog->outDebug(LOG_FILTER_TSCR, "FollowerAI start follow %s (GUID " UI64FMTD ")", player->GetName().c_str(), m_uiLeaderGUID); } Player* FollowerAI::GetLeaderForFollower() diff --git a/src/server/game/AI/SmartScripts/SmartScript.cpp b/src/server/game/AI/SmartScripts/SmartScript.cpp index 6097edf6641..a1fb2147cc2 100644 --- a/src/server/game/AI/SmartScripts/SmartScript.cpp +++ b/src/server/game/AI/SmartScripts/SmartScript.cpp @@ -46,13 +46,13 @@ class TrinityStringTextBuilder size_t operator()(WorldPacket* data, LocaleConstant locale) const { std::string text = sObjectMgr->GetTrinityString(_textId, locale); - char const* localizedName = _source->GetNameForLocaleIdx(locale); + std::string localizedName = _source->GetNameForLocaleIdx(locale); *data << uint8(_msgType); *data << uint32(_language); *data << uint64(_source->GetGUID()); *data << uint32(1); // 2.1.0 - *data << uint32(strlen(localizedName)+1); + *data << uint32(localizedName.size() + 1); *data << localizedName; size_t whisperGUIDpos = data->wpos(); *data << uint64(_targetGUID); // Unit Target @@ -154,7 +154,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u mLastInvoker = unit->GetGUID(); if (Unit* tempInvoker = GetLastInvoker()) - sLog->outDebug(LOG_FILTER_DATABASE_AI, "SmartScript::ProcessAction: Invoker: %s (guidlow: %u)", tempInvoker->GetName(), tempInvoker->GetGUIDLow()); + sLog->outDebug(LOG_FILTER_DATABASE_AI, "SmartScript::ProcessAction: Invoker: %s (guidlow: %u)", tempInvoker->GetName().c_str(), tempInvoker->GetGUIDLow()); switch (e.GetActionType()) { @@ -198,7 +198,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u mUseTextTimer = true; sCreatureTextMgr->SendChat(talker, uint8(e.action.talk.textGroupID), mTextGUID); sLog->outDebug(LOG_FILTER_DATABASE_AI, "SmartScript::ProcessAction: SMART_ACTION_TALK: talker: %s (GuidLow: %u), textGuid: %u", - talker->GetName(), talker->GetGUIDLow(), GUID_LOPART(mTextGUID)); + talker->GetName().c_str(), talker->GetGUIDLow(), GUID_LOPART(mTextGUID)); break; } case SMART_ACTION_SIMPLE_TALK: @@ -216,7 +216,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u sCreatureTextMgr->SendChat(me, uint8(e.action.talk.textGroupID), IsPlayer(templastInvoker) ? templastInvoker->GetGUID() : 0, CHAT_MSG_ADDON, LANG_ADDON, TEXT_RANGE_NORMAL, 0, TEAM_OTHER, false, (*itr)->ToPlayer()); } sLog->outDebug(LOG_FILTER_DATABASE_AI, "SmartScript::ProcessAction:: SMART_ACTION_SIMPLE_TALK: talker: %s (GuidLow: %u), textGroupId: %u", - (*itr)->GetName(), (*itr)->GetGUIDLow(), uint8(e.action.talk.textGroupID)); + (*itr)->GetName().c_str(), (*itr)->GetGUIDLow(), uint8(e.action.talk.textGroupID)); } delete targets; @@ -234,7 +234,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u { (*itr)->ToUnit()->HandleEmoteCommand(e.action.emote.emote); sLog->outDebug(LOG_FILTER_DATABASE_AI, "SmartScript::ProcessAction:: SMART_ACTION_PLAY_EMOTE: target: %s (GuidLow: %u), emote: %u", - (*itr)->GetName(), (*itr)->GetGUIDLow(), e.action.emote.emote); + (*itr)->GetName().c_str(), (*itr)->GetGUIDLow(), e.action.emote.emote); } } @@ -253,7 +253,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u { (*itr)->SendPlaySound(e.action.sound.sound, e.action.sound.range > 0 ? true : false); sLog->outDebug(LOG_FILTER_DATABASE_AI, "SmartScript::ProcessAction:: SMART_ACTION_SOUND: target: %s (GuidLow: %u), sound: %u, onlyself: %u", - (*itr)->GetName(), (*itr)->GetGUIDLow(), e.action.sound.sound, e.action.sound.range); + (*itr)->GetName().c_str(), (*itr)->GetGUIDLow(), e.action.sound.sound, e.action.sound.range); } } @@ -366,14 +366,12 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u for (ObjectList::const_iterator itr = targets->begin(); itr != targets->end(); ++itr) { if (IsPlayer(*itr)) - { if (Quest const* q = sObjectMgr->GetQuestTemplate(e.action.quest.quest)) { (*itr)->ToPlayer()->AddQuest(q, NULL); sLog->outDebug(LOG_FILTER_DATABASE_AI, "SmartScript::ProcessAction:: SMART_ACTION_ADD_QUEST: Player guidLow %u add quest %u", (*itr)->GetGUIDLow(), e.action.quest.quest); } - } } delete targets; @@ -432,8 +430,8 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u if (!me) break; - std::list<HostileReference*> const& threatList = me->getThreatManager().getThreatList(); - for (std::list<HostileReference*>::const_iterator i = threatList.begin(); i != threatList.end(); ++i) + ThreatContainer::StorageType threatList = me->getThreatManager().getThreatList(); + for (ThreatContainer::StorageType::const_iterator i = threatList.begin(); i != threatList.end(); ++i) { if (Unit* target = Unit::GetUnit(*me, (*i)->getUnitGuid())) { @@ -2348,8 +2346,8 @@ ObjectList* SmartScript::GetTargets(SmartScriptHolder const& e, Unit* invoker /* { if (me) { - std::list<HostileReference*> const& threatList = me->getThreatManager().getThreatList(); - for (std::list<HostileReference*>::const_iterator i = threatList.begin(); i != threatList.end(); ++i) + ThreatContainer::StorageType threatList = me->getThreatManager().getThreatList(); + for (ThreatContainer::StorageType::const_iterator i = threatList.begin(); i != threatList.end(); ++i) if (Unit* temp = Unit::GetUnit(*me, (*i)->getUnitGuid())) l->push_back(temp); } diff --git a/src/server/game/Accounts/AccountMgr.cpp b/src/server/game/Accounts/AccountMgr.cpp index b666add74b3..2b67acfd6d0 100755 --- a/src/server/game/Accounts/AccountMgr.cpp +++ b/src/server/game/Accounts/AccountMgr.cpp @@ -176,7 +176,7 @@ AccountOpResult ChangePassword(uint32 accountId, std::string newPassword) return AOR_OK; } -uint32 GetId(std::string username) +uint32 GetId(std::string const& username) { PreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_GET_ACCOUNT_ID_BY_USERNAME); stmt->setString(0, username); @@ -265,7 +265,7 @@ bool normalizeString(std::string& utf8String) return WStrToUtf8(buffer, maxLength, utf8String); } -std::string CalculateShaPassHash(std::string& name, std::string& password) +std::string CalculateShaPassHash(std::string const& name, std::string const& password) { SHA1Hash sha; sha.Initialize(); diff --git a/src/server/game/Accounts/AccountMgr.h b/src/server/game/Accounts/AccountMgr.h index aaaf4f4f603..c14bcc48bdc 100755 --- a/src/server/game/Accounts/AccountMgr.h +++ b/src/server/game/Accounts/AccountMgr.h @@ -42,12 +42,12 @@ namespace AccountMgr AccountOpResult ChangePassword(uint32 accountId, std::string newPassword); bool CheckPassword(uint32 accountId, std::string password); - uint32 GetId(std::string username); + uint32 GetId(std::string const& username); uint32 GetSecurity(uint32 accountId); uint32 GetSecurity(uint32 accountId, int32 realmId); bool GetName(uint32 accountId, std::string& name); uint32 GetCharactersCount(uint32 accountId); - std::string CalculateShaPassHash(std::string& name, std::string& password); + std::string CalculateShaPassHash(std::string const& name, std::string const& password); bool normalizeString(std::string& utf8String); bool IsPlayerAccount(uint32 gmlevel); diff --git a/src/server/game/Achievements/AchievementMgr.cpp b/src/server/game/Achievements/AchievementMgr.cpp index fe4bbea34fb..0ee133edce9 100755 --- a/src/server/game/Achievements/AchievementMgr.cpp +++ b/src/server/game/Achievements/AchievementMgr.cpp @@ -690,10 +690,10 @@ void AchievementMgr::SendAchievementEarned(AchievementEntry const* achievement) guild->BroadcastWorker(say_do, GetPlayer()); } - if (achievement->flags & (ACHIEVEMENT_FLAG_REALM_FIRST_KILL|ACHIEVEMENT_FLAG_REALM_FIRST_REACH)) + if (achievement->flags & (ACHIEVEMENT_FLAG_REALM_FIRST_KILL | ACHIEVEMENT_FLAG_REALM_FIRST_REACH)) { // broadcast realm first reached - WorldPacket data(SMSG_SERVER_FIRST_ACHIEVEMENT, strlen(GetPlayer()->GetName())+1+8+4+4); + WorldPacket data(SMSG_SERVER_FIRST_ACHIEVEMENT, GetPlayer()->GetName().size() + 1 + 8 + 4 + 4); data << GetPlayer()->GetName(); data << uint64(GetPlayer()->GetGUID()); data << uint32(achievement->ID); diff --git a/src/server/game/Addons/AddonMgr.cpp b/src/server/game/Addons/AddonMgr.cpp index a0789040e9a..a595c73c7c0 100755 --- a/src/server/game/Addons/AddonMgr.cpp +++ b/src/server/game/Addons/AddonMgr.cpp @@ -44,7 +44,6 @@ void LoadFromDB() if (!result) { sLog->outInfo(LOG_FILTER_SERVER_LOADING, ">> Loaded 0 known addons. DB table `addons` is empty!"); - return; } @@ -64,7 +63,6 @@ void LoadFromDB() while (result->NextRow()); sLog->outInfo(LOG_FILTER_SERVER_LOADING, ">> Loaded %u known addons in %u ms", count, GetMSTimeDiffToNow(oldMSTime)); - } void SaveAddon(AddonInfo const& addon) diff --git a/src/server/game/Addons/AddonMgr.h b/src/server/game/Addons/AddonMgr.h index fd227b258c5..9efbabc8b9f 100755 --- a/src/server/game/Addons/AddonMgr.h +++ b/src/server/game/Addons/AddonMgr.h @@ -25,7 +25,8 @@ struct AddonInfo { AddonInfo(const std::string& name, uint8 enabled, uint32 crc, uint8 state, bool crcOrPubKey) - : Name(name), Enabled(enabled), CRC(crc), State(state), UsePublicKeyOrCRC(crcOrPubKey) {} + : Name(name), Enabled(enabled), CRC(crc), State(state), UsePublicKeyOrCRC(crcOrPubKey) + { } std::string Name; uint8 Enabled; @@ -56,4 +57,3 @@ namespace AddonMgr } #endif - diff --git a/src/server/game/Battlefield/Battlefield.cpp b/src/server/game/Battlefield/Battlefield.cpp index 1c99934bafc..b3f5c7bf704 100644 --- a/src/server/game/Battlefield/Battlefield.cpp +++ b/src/server/game/Battlefield/Battlefield.cpp @@ -440,7 +440,7 @@ void Battlefield::BroadcastPacketToWar(WorldPacket& data) const player->GetSession()->SendPacket(&data); } -WorldPacket Battlefield::BuildWarningAnnPacket(std::string msg) +WorldPacket Battlefield::BuildWarningAnnPacket(std::string const& msg) { WorldPacket data(SMSG_MESSAGECHAT, 200); diff --git a/src/server/game/Battlefield/Battlefield.h b/src/server/game/Battlefield/Battlefield.h index 2ca6a2e3f96..0752fa88fc1 100644 --- a/src/server/game/Battlefield/Battlefield.h +++ b/src/server/game/Battlefield/Battlefield.h @@ -314,7 +314,7 @@ class Battlefield : public ZoneScript /// Called when a player enter in battlefield zone virtual void OnPlayerEnterZone(Player* /*player*/) {}; - WorldPacket BuildWarningAnnPacket(std::string msg); + WorldPacket BuildWarningAnnPacket(std::string const& msg); void SendWarningToAllInZone(uint32 entry); //void SendWarningToAllInWar(int32 entry, ...); -- UNUSED void SendWarningToPlayer(Player* player, uint32 entry); diff --git a/src/server/game/Battlefield/BattlefieldHandler.cpp b/src/server/game/Battlefield/BattlefieldHandler.cpp index b852082d582..1ebeb664fb3 100644 --- a/src/server/game/Battlefield/BattlefieldHandler.cpp +++ b/src/server/game/Battlefield/BattlefieldHandler.cpp @@ -95,12 +95,12 @@ void WorldSession::SendBfLeaveMessage(uint32 BattleId, BFLeaveReason reason) } //Send by client when he click on accept for queue -void WorldSession::HandleBfQueueInviteResponse(WorldPacket & recv_data) +void WorldSession::HandleBfQueueInviteResponse(WorldPacket & recvData) { uint32 BattleId; uint8 Accepted; - recv_data >> BattleId >> Accepted; + recvData >> BattleId >> Accepted; sLog->outError(LOG_FILTER_GENERAL, "HandleQueueInviteResponse: BattleID:%u Accepted:%u", BattleId, Accepted); Battlefield* Bf = sBattlefieldMgr->GetBattlefieldByBattleId(BattleId); if (!Bf) @@ -113,12 +113,12 @@ void WorldSession::HandleBfQueueInviteResponse(WorldPacket & recv_data) } //Send by client on clicking in accept or refuse of invitation windows for join game -void WorldSession::HandleBfEntryInviteResponse(WorldPacket & recv_data) +void WorldSession::HandleBfEntryInviteResponse(WorldPacket & recvData) { uint32 BattleId; uint8 Accepted; - recv_data >> BattleId >> Accepted; + recvData >> BattleId >> Accepted; sLog->outError(LOG_FILTER_GENERAL, "HandleBattlefieldInviteResponse: BattleID:%u Accepted:%u", BattleId, Accepted); Battlefield* Bf = sBattlefieldMgr->GetBattlefieldByBattleId(BattleId); if (!Bf) @@ -136,11 +136,11 @@ void WorldSession::HandleBfEntryInviteResponse(WorldPacket & recv_data) } } -void WorldSession::HandleBfExitRequest(WorldPacket & recv_data) +void WorldSession::HandleBfExitRequest(WorldPacket & recvData) { uint32 BattleId; - recv_data >> BattleId; + recvData >> BattleId; sLog->outError(LOG_FILTER_GENERAL, "HandleBfExitRequest: BattleID:%u ", BattleId); Battlefield* Bf = sBattlefieldMgr->GetBattlefieldByBattleId(BattleId); if (!Bf) diff --git a/src/server/game/Battlegrounds/ArenaTeam.cpp b/src/server/game/Battlegrounds/ArenaTeam.cpp index e88c501398e..d763b29bbc1 100755 --- a/src/server/game/Battlegrounds/ArenaTeam.cpp +++ b/src/server/game/Battlegrounds/ArenaTeam.cpp @@ -36,10 +36,9 @@ ArenaTeam::ArenaTeam() } ArenaTeam::~ArenaTeam() -{ -} +{ } -bool ArenaTeam::Create(uint64 captainGuid, uint8 type, std::string teamName, uint32 backgroundColor, uint8 emblemStyle, uint32 emblemColor, uint8 borderStyle, uint32 borderColor) +bool ArenaTeam::Create(uint64 captainGuid, uint8 type, std::string const& teamName, uint32 backgroundColor, uint8 emblemStyle, uint32 emblemColor, uint8 borderStyle, uint32 borderColor) { // Check if captain is present if (!ObjectAccessor::FindPlayer(captainGuid)) @@ -284,14 +283,15 @@ void ArenaTeam::SetCaptain(uint64 guid) CharacterDatabase.Execute(stmt); // Enable remove/promote buttons - Player* newCaptain = ObjectAccessor::FindPlayer(guid); - if (newCaptain) + if (Player* newCaptain = ObjectAccessor::FindPlayer(guid)) { newCaptain->SetArenaTeamInfoField(GetSlot(), ARENA_TEAM_MEMBER, 0); - char const* oldCaptainName = oldCaptain ? oldCaptain->GetName() : ""; - uint32 oldCaptainLowGuid = oldCaptain ? oldCaptain->GetGUIDLow() : 0; - sLog->outInfo(LOG_FILTER_ARENAS, "Player: %s [GUID: %u] promoted player: %s [GUID: %u] to leader of arena team [Id: %u] [Type: %u].", - oldCaptainName, oldCaptainLowGuid, newCaptain->GetName(), newCaptain->GetGUIDLow(), GetId(), GetType()); + if (oldCaptain) + { + sLog->outDebug(LOG_FILTER_BATTLEGROUND, "Player: %s [GUID: %u] promoted player: %s [GUID: %u] to leader of arena team [Id: %u] [Type: %u].", + oldCaptain->GetName().c_str(), oldCaptain->GetGUIDLow(), newCaptain->GetName().c_str(), + newCaptain->GetGUIDLow(), GetId(), GetType()); + } } } @@ -299,13 +299,11 @@ void ArenaTeam::DelMember(uint64 guid, bool cleanDb) { // Remove member from team for (MemberList::iterator itr = Members.begin(); itr != Members.end(); ++itr) - { if (itr->Guid == guid) { Members.erase(itr); break; } - } // Inform player and remove arena team info from player data if (Player* player = ObjectAccessor::FindPlayer(guid)) @@ -314,7 +312,7 @@ void ArenaTeam::DelMember(uint64 guid, bool cleanDb) // delete all info regarding this team for (uint32 i = 0; i < ARENA_TEAM_END; ++i) player->SetArenaTeamInfoField(GetSlot(), ArenaTeamInfoType(i), 0); - sLog->outInfo(LOG_FILTER_ARENAS, "Player: %s [GUID: %u] left arena team type: %u [Id: %u].", player->GetName(), player->GetGUIDLow(), GetType(), GetId()); + sLog->outDebug(LOG_FILTER_ARENAS, "Player: %s [GUID: %u] left arena team type: %u [Id: %u].", player->GetName().c_str(), player->GetGUIDLow(), GetType(), GetId()); } // Only used for single member deletion, for arena team disband we use a single query for more efficiency @@ -336,10 +334,10 @@ void ArenaTeam::Disband(WorldSession* session) // Broadcast update if (session) { - BroadcastEvent(ERR_ARENA_TEAM_DISBANDED_S, 0, 2, session->GetPlayerName(), GetName(), ""); + BroadcastEvent(ERR_ARENA_TEAM_DISBANDED_S, 0, 2, session->GetPlayerName().c_str(), GetName(), ""); if (Player* player = session->GetPlayer()) - sLog->outInfo(LOG_FILTER_ARENAS, "Player: %s [GUID: %u] disbanded arena team type: %u [Id: %u].", player->GetName(), player->GetGUIDLow(), GetType(), GetId()); + sLog->outDebug(LOG_FILTER_ARENAS, "Player: %s [GUID: %u] disbanded arena team type: %u [Id: %u].", player->GetName().c_str(), player->GetGUIDLow(), GetType(), GetId()); } // Update database @@ -481,7 +479,7 @@ void ArenaTeam::BroadcastPacket(WorldPacket* packet) player->GetSession()->SendPacket(packet); } -void ArenaTeam::BroadcastEvent(ArenaTeamEvents event, uint64 guid, uint8 strCount, std::string str1, std::string str2, std::string str3) +void ArenaTeam::BroadcastEvent(ArenaTeamEvents event, uint64 guid, uint8 strCount, std::string const& str1, std::string const& str2, std::string const& str3) { WorldPacket data(SMSG_ARENA_TEAM_EVENT, 1+1+1); data << uint8(event); diff --git a/src/server/game/Battlegrounds/ArenaTeam.h b/src/server/game/Battlegrounds/ArenaTeam.h index d8ad2c09e59..7d2d680cddc 100755 --- a/src/server/game/Battlegrounds/ArenaTeam.h +++ b/src/server/game/Battlegrounds/ArenaTeam.h @@ -119,7 +119,7 @@ class ArenaTeam ArenaTeam(); ~ArenaTeam(); - bool Create(uint64 captainGuid, uint8 type, std::string teamName, uint32 backgroundColor, uint8 emblemStyle, uint32 emblemColor, uint8 borderStyle, uint32 borderColor); + bool Create(uint64 captainGuid, uint8 type, std::string const& teamName, uint32 backgroundColor, uint8 emblemStyle, uint32 emblemColor, uint8 borderStyle, uint32 borderColor); void Disband(WorldSession* session); typedef std::list<ArenaTeamMember> MemberList; @@ -129,7 +129,7 @@ class ArenaTeam uint8 GetSlot() const { return GetSlotByType(GetType()); } static uint8 GetSlotByType(uint32 type); uint64 GetCaptain() const { return CaptainGuid; } - std::string GetName() const { return TeamName; } + std::string const& GetName() const { return TeamName; } const ArenaTeamStats& GetStats() const { return Stats; } uint32 GetRating() const { return Stats.Rating; } @@ -149,7 +149,7 @@ class ArenaTeam bool IsMember(uint64 guid) const; ArenaTeamMember* GetMember(uint64 guid); - ArenaTeamMember* GetMember(const std::string& name); + ArenaTeamMember* GetMember(std::string const& name); bool IsFighting() const; @@ -159,7 +159,7 @@ class ArenaTeam void SaveToDB(); void BroadcastPacket(WorldPacket* packet); - void BroadcastEvent(ArenaTeamEvents event, uint64 guid, uint8 strCount, std::string str1, std::string str2, std::string str3); + void BroadcastEvent(ArenaTeamEvents event, uint64 guid, uint8 strCount, std::string const& str1, std::string const& str2, std::string const& str3); void NotifyStatsChanged(); void Roster(WorldSession* session); diff --git a/src/server/game/Battlegrounds/Battleground.cpp b/src/server/game/Battlegrounds/Battleground.cpp index 963fd5e2d07..50f8554d5db 100755 --- a/src/server/game/Battlegrounds/Battleground.cpp +++ b/src/server/game/Battlegrounds/Battleground.cpp @@ -320,7 +320,7 @@ inline void Battleground::_CheckSafePositions(uint32 diff) GetTeamStartLoc(player->GetBGTeam(), x, y, z, o); if (pos.GetExactDistSq(x, y, z) > maxDist) { - sLog->outDebug(LOG_FILTER_BATTLEGROUND, "BATTLEGROUND: Sending %s back to start location (map: %u) (possible exploit)", player->GetName(), GetMapId()); + sLog->outDebug(LOG_FILTER_BATTLEGROUND, "BATTLEGROUND: Sending %s back to start location (map: %u) (possible exploit)", player->GetName().c_str(), GetMapId()); player->TeleportTo(GetMapId(), x, y, z, o); } } @@ -786,7 +786,12 @@ void Battleground::EndBattleground(uint32 winner) if (sWorld->getBoolConfig(CONFIG_ARENA_LOG_EXTENDED_INFO)) for (Battleground::BattlegroundScoreMap::const_iterator itr = GetPlayerScoresBegin(); itr != GetPlayerScoresEnd(); ++itr) if (Player* player = ObjectAccessor::FindPlayer(itr->first)) - sLog->outDebug(LOG_FILTER_ARENAS, "Statistics match Type: %u for %s (GUID: " UI64FMTD ", Team: %d, IP: %s): %u damage, %u healing, %u killing blows", m_ArenaType, player->GetName(), itr->first, player->GetArenaTeamId(m_ArenaType == 5 ? 2 : m_ArenaType == 3), player->GetSession()->GetRemoteAddress().c_str(), itr->second->DamageDone, itr->second->HealingDone, itr->second->KillingBlows); + { + sLog->outDebug(LOG_FILTER_ARENAS, "Statistics match Type: %u for %s (GUID: " UI64FMTD ", Team: %d, IP: %s): %u damage, %u healing, %u killing blows", + m_ArenaType, player->GetName().c_str(), itr->first, player->GetArenaTeamId(m_ArenaType == 5 ? 2 : m_ArenaType == 3), + player->GetSession()->GetRemoteAddress().c_str(), itr->second->DamageDone, itr->second->HealingDone, + itr->second->KillingBlows); + } } // Deduct 16 points from each teams arena-rating if there are no winners after 45+2 minutes else @@ -1059,7 +1064,7 @@ void Battleground::RemovePlayerAtLeave(uint64 guid, bool Transport, bool SendPac if (Transport) player->TeleportToBGEntryPoint(); - sLog->outInfo(LOG_FILTER_BATTLEGROUND, "BATTLEGROUND: Removed player %s from Battleground.", player->GetName()); + sLog->outInfo(LOG_FILTER_BATTLEGROUND, "BATTLEGROUND: Removed player %s from Battleground.", player->GetName().c_str()); } //battleground object will be deleted next Battleground::Update() call @@ -1200,7 +1205,7 @@ void Battleground::AddPlayer(Player* player) AddOrSetPlayerToCorrectBgGroup(player, team); // Log - sLog->outInfo(LOG_FILTER_BATTLEGROUND, "BATTLEGROUND: Player %s joined the battle.", player->GetName()); + sLog->outInfo(LOG_FILTER_BATTLEGROUND, "BATTLEGROUND: Player %s joined the battle.", player->GetName().c_str()); } // this method adds player to his team's bg group, or sets his correct group if player is already in bg group diff --git a/src/server/game/Battlegrounds/BattlegroundMgr.cpp b/src/server/game/Battlegrounds/BattlegroundMgr.cpp index a787f4b6810..bfa3b955427 100755 --- a/src/server/game/Battlegrounds/BattlegroundMgr.cpp +++ b/src/server/game/Battlegrounds/BattlegroundMgr.cpp @@ -873,11 +873,11 @@ void BattlegroundMgr::SendToBattleground(Player* player, uint32 instanceId, Batt team = player->GetTeam(); bg->GetTeamStartLoc(team, x, y, z, O); - sLog->outDebug(LOG_FILTER_BATTLEGROUND, "BattlegroundMgr::SendToBattleground: Sending %s to map %u, X %f, Y %f, Z %f, O %f (bgType %u)", player->GetName(), mapid, x, y, z, O, bgTypeId); + sLog->outDebug(LOG_FILTER_BATTLEGROUND, "BattlegroundMgr::SendToBattleground: Sending %s to map %u, X %f, Y %f, Z %f, O %f (bgType %u)", player->GetName().c_str(), mapid, x, y, z, O, bgTypeId); player->TeleportTo(mapid, x, y, z, O); } else - sLog->outError(LOG_FILTER_BATTLEGROUND, "BattlegroundMgr::SendToBattleground: Instance %u (bgType %u) not found while trying to teleport player %s", instanceId, bgTypeId, player->GetName()); + sLog->outError(LOG_FILTER_BATTLEGROUND, "BattlegroundMgr::SendToBattleground: Instance %u (bgType %u) not found while trying to teleport player %s", instanceId, bgTypeId, player->GetName().c_str()); } void BattlegroundMgr::SendAreaSpiritHealerQueryOpcode(Player* player, Battleground* bg, uint64 guid) diff --git a/src/server/game/Battlegrounds/BattlegroundQueue.cpp b/src/server/game/Battlegrounds/BattlegroundQueue.cpp index aa4177eaf51..922cccb9186 100755 --- a/src/server/game/Battlegrounds/BattlegroundQueue.cpp +++ b/src/server/game/Battlegrounds/BattlegroundQueue.cpp @@ -476,7 +476,7 @@ bool BattlegroundQueue::InviteGroupToBG(GroupQueueInfo* ginfo, Battleground* bg, uint32 queueSlot = player->GetBattlegroundQueueIndex(bgQueueTypeId); sLog->outDebug(LOG_FILTER_BATTLEGROUND, "Battleground: invited player %s (%u) to BG instance %u queueindex %u bgtype %u, I can't help it if they don't press the enter battle button.", - player->GetName(), player->GetGUIDLow(), bg->GetInstanceID(), queueSlot, bg->GetTypeID()); + player->GetName().c_str(), player->GetGUIDLow(), bg->GetInstanceID(), queueSlot, bg->GetTypeID()); // send status packet sBattlegroundMgr->BuildBattlegroundStatusPacket(&data, bg, queueSlot, STATUS_WAIT_JOIN, INVITE_ACCEPT_WAIT_TIME, 0, ginfo->ArenaType); diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundEY.cpp b/src/server/game/Battlegrounds/Zones/BattlegroundEY.cpp index ee25f72b382..e900bc9b1d3 100755 --- a/src/server/game/Battlegrounds/Zones/BattlegroundEY.cpp +++ b/src/server/game/Battlegrounds/Zones/BattlegroundEY.cpp @@ -648,9 +648,9 @@ void BattlegroundEY::EventPlayerClickedOnFlag(Player* Source, GameObject* target Source->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_ENTER_PVP_COMBAT); if (Source->GetTeam() == ALLIANCE) - PSendMessageToAll(LANG_BG_EY_HAS_TAKEN_FLAG, CHAT_MSG_BG_SYSTEM_ALLIANCE, NULL, Source->GetName()); + PSendMessageToAll(LANG_BG_EY_HAS_TAKEN_FLAG, CHAT_MSG_BG_SYSTEM_ALLIANCE, NULL, Source->GetName().c_str()); else - PSendMessageToAll(LANG_BG_EY_HAS_TAKEN_FLAG, CHAT_MSG_BG_SYSTEM_HORDE, NULL, Source->GetName()); + PSendMessageToAll(LANG_BG_EY_HAS_TAKEN_FLAG, CHAT_MSG_BG_SYSTEM_HORDE, NULL, Source->GetName().c_str()); } void BattlegroundEY::EventTeamLostPoint(Player* Source, uint32 Point) diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundSA.cpp b/src/server/game/Battlegrounds/Zones/BattlegroundSA.cpp index 35304bc9190..7dba811c1a1 100755 --- a/src/server/game/Battlegrounds/Zones/BattlegroundSA.cpp +++ b/src/server/game/Battlegrounds/Zones/BattlegroundSA.cpp @@ -86,13 +86,13 @@ bool BattlegroundSA::ResetObjs() for (uint8 i = 0; i < 6; i++) GateStatus[i] = BG_SA_GATE_OK; - for (uint8 i = 0; i < BG_SA_BOAT_ONE; i++) + for (uint8 i = 0; i <= BG_SA_PORTAL_DEFFENDER_RED; i++) { if (!AddObject(i, BG_SA_ObjEntries[i], BG_SA_ObjSpawnlocs[i][0], BG_SA_ObjSpawnlocs[i][1], BG_SA_ObjSpawnlocs[i][2], BG_SA_ObjSpawnlocs[i][3], 0, 0, 0, 0, RESPAWN_ONE_DAY)) return false; } - for (uint8 i = BG_SA_BOAT_ONE; i < BG_SA_SIGIL_1; i++) + for (uint8 i = BG_SA_BOAT_ONE; i <= BG_SA_BOAT_TWO; i++) { uint32 boatid = 0; switch (i) @@ -113,7 +113,7 @@ bool BattlegroundSA::ResetObjs() return false; } - for (uint8 i = BG_SA_SIGIL_1; i < BG_SA_CENTRAL_FLAG; i++) + for (uint8 i = BG_SA_SIGIL_1; i <= BG_SA_LEFT_FLAGPOLE; i++) { if (!AddObject(i, BG_SA_ObjEntries[i], BG_SA_ObjSpawnlocs[i][0], BG_SA_ObjSpawnlocs[i][1], @@ -141,7 +141,7 @@ bool BattlegroundSA::ResetObjs() OverrideGunFaction(); DemolisherStartState(true); - for (uint8 i = 0; i <= BG_SA_TITAN_RELIC; i++) + for (uint8 i = 0; i <= BG_SA_PORTAL_DEFFENDER_RED; i++) { SpawnBGObject(i, RESPAWN_IMMEDIATELY); GetBGObject(i)->SetUInt32Value(GAMEOBJECT_FACTION, defF); @@ -182,7 +182,7 @@ bool BattlegroundSA::ResetObjs() } //GY capture points - for (uint8 i = BG_SA_CENTRAL_FLAG; i < BG_SA_PORTAL_DEFFENDER_BLUE; i++) + for (uint8 i = BG_SA_CENTRAL_FLAG; i <= BG_SA_LEFT_FLAG; i++) { AddObject(i, (BG_SA_ObjEntries[i] - (Attackers == TEAM_ALLIANCE ? 1 : 0)), BG_SA_ObjSpawnlocs[i][0], BG_SA_ObjSpawnlocs[i][1], @@ -191,15 +191,6 @@ bool BattlegroundSA::ResetObjs() GetBGObject(i)->SetUInt32Value(GAMEOBJECT_FACTION, atF); } - for (uint8 i = BG_SA_PORTAL_DEFFENDER_BLUE; i < BG_SA_BOMB; i++) - { - AddObject(i, BG_SA_ObjEntries[i], - BG_SA_ObjSpawnlocs[i][0], BG_SA_ObjSpawnlocs[i][1], - BG_SA_ObjSpawnlocs[i][2], BG_SA_ObjSpawnlocs[i][3], - 0, 0, 0, 0, RESPAWN_ONE_DAY); - GetBGObject(i)->SetUInt32Value(GAMEOBJECT_FACTION, defF); - } - for (uint8 i = BG_SA_BOMB; i < BG_SA_MAXOBJ; i++) { AddObject(i, BG_SA_ObjEntries[BG_SA_BOMB], @@ -657,7 +648,7 @@ void BattlegroundSA::DestroyGate(Player* player, GameObject* go) } if (i < 5) - DelObject(i+9); + DelObject(i + 14); UpdatePlayerScore(player, SCORE_DESTROYED_WALL, 1); if (rewardHonor) UpdatePlayerScore(player, SCORE_BONUS_HONOR, GetBonusHonorFromKill(1)); @@ -973,4 +964,3 @@ void BattlegroundSA::SendTransportsRemove(Player* player) player->GetSession()->SendPacket(&packet); } } - diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundSA.h b/src/server/game/Battlegrounds/Zones/BattlegroundSA.h index 6de3731da50..9089f0c2818 100755 --- a/src/server/game/Battlegrounds/Zones/BattlegroundSA.h +++ b/src/server/game/Battlegrounds/Zones/BattlegroundSA.h @@ -228,6 +228,11 @@ enum BG_SA_Objects BG_SA_PURPLE_GATE, BG_SA_ANCIENT_GATE, BG_SA_TITAN_RELIC, + BG_SA_PORTAL_DEFFENDER_BLUE, + BG_SA_PORTAL_DEFFENDER_GREEN, + BG_SA_PORTAL_DEFFENDER_YELLOW, + BG_SA_PORTAL_DEFFENDER_PURPLE, + BG_SA_PORTAL_DEFFENDER_RED, BG_SA_BOAT_ONE, BG_SA_BOAT_TWO, BG_SA_SIGIL_1, @@ -241,11 +246,6 @@ enum BG_SA_Objects BG_SA_CENTRAL_FLAG, BG_SA_RIGHT_FLAG, BG_SA_LEFT_FLAG, - BG_SA_PORTAL_DEFFENDER_BLUE, - BG_SA_PORTAL_DEFFENDER_GREEN, - BG_SA_PORTAL_DEFFENDER_YELLOW, - BG_SA_PORTAL_DEFFENDER_PURPLE, - BG_SA_PORTAL_DEFFENDER_RED, BG_SA_BOMB, BG_SA_MAXOBJ = BG_SA_BOMB+68 }; @@ -259,6 +259,12 @@ float const BG_SA_ObjSpawnlocs[BG_SA_MAXOBJ][4] = { 1214.681f, 81.21f, 53.413f, 5.745f }, { 878.555f, -108.2f, 117.845f, 0.0f }, { 836.5f, -108.8f, 120.219f, 0.0f }, + // Portal + {1468.380005f, -225.798996f, 30.896200f, 0.0f}, //blue + {1394.270020f, 72.551399f, 31.054300f, 0.0f}, //green + {1065.260010f, -89.79501f, 81.073402f, 0.0f}, //yellow + {1216.069946f, 47.904301f, 54.278198f, 0.0f}, //purple + {1255.569946f, -233.548996f, 56.43699f, 0.0f}, //red // Ships { 2679.696777f, -826.891235f, 3.712860f, 5.78367f}, //rot2 1 rot3 0.0002f { 2574.003662f, 981.261475f, 2.603424f, 0.807696f}, @@ -276,12 +282,6 @@ float const BG_SA_ObjSpawnlocs[BG_SA_MAXOBJ][4] = { 1215.108032f, -65.715767f, 70.084267f, -3.124123f}, { 1338.859253f, -153.327316f, 30.895077f, -2.530723f}, { 1309.192017f, 9.416233f, 30.893402f, 1.518436f}, - // Portal - {1468.380005f, -225.798996f, 30.896200f, 0.0f}, //blue - {1394.270020f, 72.551399f, 31.054300f, 0.0f}, //green - {1065.260010f, -89.79501f, 81.073402f, 0.0f}, //yellow - {1216.069946f, 47.904301f, 54.278198f, 0.0f}, //purple - {1255.569946f, -233.548996f, 56.43699f, 0.0f}, //red // Bombs {1333.45f, 211.354f, 31.0538f, 5.03666f}, {1334.29f, 209.582f, 31.0532f, 1.28088f}, @@ -375,6 +375,11 @@ uint32 const BG_SA_ObjEntries[BG_SA_MAXOBJ + BG_SA_FLAG_AMOUNT] = 190723, 192549, 192834, + 192819, + 192819, + 192819, + 192819, + 192819, 0, // Boat 0, // Boat 192687, @@ -388,11 +393,6 @@ uint32 const BG_SA_ObjEntries[BG_SA_MAXOBJ + BG_SA_FLAG_AMOUNT] = 191310, 191306, 191308, - 192819, - 192819, - 192819, - 192819, - 192819, 190753 }; diff --git a/src/server/game/Calendar/Calendar.h b/src/server/game/Calendar/Calendar.h index a2d2dc2ffb7..273db4c3854 100755 --- a/src/server/game/Calendar/Calendar.h +++ b/src/server/game/Calendar/Calendar.h @@ -46,8 +46,8 @@ class CalendarInvite void SetStatusTime(uint32 statusTime) { _statusTime = statusTime; } uint32 GetStatusTime() const { return _statusTime; } - void SetText(std::string text) { _text = text; } - std::string GetText() const { return _text; } + void SetText(std::string const& text) { _text = text; } + std::string const& GetText() const { return _text; } void SetStatus(CalendarInviteStatus status) { _status = status; } CalendarInviteStatus GetStatus() const { return _status; } @@ -89,11 +89,11 @@ class CalendarEvent void SetGuildId(uint32 guildId) { _guildId = guildId; } uint32 GetGuildId() const { return _guildId; } - void SetTitle(std::string title) { _title = title; } - std::string GetTitle() const { return _title; } + void SetTitle(std::string const& title) { _title = title; } + std::string const& GetTitle() const { return _title; } - void SetDescription(std::string description) { _description = description; } - std::string GetDescription() const { return _description; } + void SetDescription(std::string const& description) { _description = description; } + std::string const& GetDescription() const { return _description; } void SetType(CalendarEventType type) { _type = type; } CalendarEventType GetType() const { return _type; } diff --git a/src/server/game/Chat/Channels/Channel.cpp b/src/server/game/Chat/Channels/Channel.cpp index 579f322594a..66f964fb4cf 100755 --- a/src/server/game/Chat/Channels/Channel.cpp +++ b/src/server/game/Chat/Channels/Channel.cpp @@ -24,8 +24,9 @@ #include "DatabaseEnv.h" #include "AccountMgr.h" -Channel::Channel(const std::string& name, uint32 channel_id, uint32 Team) - : m_announce(true), m_ownership(true), m_name(name), m_password(""), m_flags(0), m_channelId(channel_id), m_ownerGUID(0), m_Team(Team) +Channel::Channel(const std::string& name, uint32 channel_id, uint32 Team) : m_announce(true), + m_ownership(true), m_name(name), m_password(""), m_flags(0), m_channelId(channel_id), + m_ownerGUID(0), m_Team(Team) { m_IsSaved = false; // set special flags if built-in channel @@ -70,10 +71,9 @@ Channel::Channel(const std::string& name, uint32 channel_id, uint32 Team) if (db_BannedList) { Tokenizer tokens(db_BannedList, ' '); - Tokenizer::const_iterator iter; - for (iter = tokens.begin(); iter != tokens.end(); ++iter) + for (Tokenizer::const_iterator i = tokens.begin(); i != tokens.end(); ++i) { - uint64 banned_guid = atol(*iter); + uint64 banned_guid = atol(*i); if (banned_guid) { sLog->outDebug(LOG_FILTER_CHATSYS, "Channel(%s) loaded banned guid:" UI64FMTD "", name.c_str(), banned_guid); @@ -118,7 +118,6 @@ void Channel::UpdateChannelInDB() const sLog->outDebug(LOG_FILTER_CHATSYS, "Channel(%s) updated in database", m_name.c_str()); } - } void Channel::UpdateChannelUseageInDB() const diff --git a/src/server/game/Chat/Channels/Channel.h b/src/server/game/Chat/Channels/Channel.h index 04bb4ae2916..bdb5112c7ef 100755 --- a/src/server/game/Chat/Channels/Channel.h +++ b/src/server/game/Chat/Channels/Channel.h @@ -172,7 +172,7 @@ class Channel void MakeNotModerator(WorldPacket* data); //? 0x06 void MakePasswordChanged(WorldPacket* data, uint64 guid); //+ 0x07 void MakeOwnerChanged(WorldPacket* data, uint64 guid); //? 0x08 - void MakePlayerNotFound(WorldPacket* data, const std::string& name); //+ 0x09 + void MakePlayerNotFound(WorldPacket* data, std::string const& name); //+ 0x09 void MakeNotOwner(WorldPacket* data); //? 0x0A void MakeChannelOwner(WorldPacket* data); //? 0x0B void MakeModeChange(WorldPacket* data, uint64 guid, uint8 oldflags); //+ 0x0C @@ -183,15 +183,15 @@ class Channel 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, const std::string& name); //? 0x16 + void MakePlayerNotBanned(WorldPacket* data, std::string const& name); //? 0x16 void MakePlayerAlreadyMember(WorldPacket* data, uint64 guid); //+ 0x17 void MakeInvite(WorldPacket* data, uint64 guid); //? 0x18 void MakeInviteWrongFaction(WorldPacket* data); //? 0x19 void MakeWrongFaction(WorldPacket* data); //? 0x1A void MakeInvalidName(WorldPacket* data); //? 0x1B void MakeNotModerated(WorldPacket* data); //? 0x1C - void MakePlayerInvited(WorldPacket* data, const std::string& name); //+ 0x1D - void MakePlayerInviteBanned(WorldPacket* data, const std::string &name);//? 0x1E + void MakePlayerInvited(WorldPacket* data, std::string const& name); //+ 0x1D + void MakePlayerInviteBanned(WorldPacket* data, std::string const& name);//? 0x1E void MakeThrottled(WorldPacket* data); //? 0x1F void MakeNotInArea(WorldPacket* data); //? 0x20 void MakeNotInLfg(WorldPacket* data); //? 0x21 @@ -245,14 +245,14 @@ class Channel public: uint32 m_Team; - Channel(const std::string& name, uint32 channel_id, uint32 Team = 0); - std::string GetName() const { return m_name; } + Channel(std::string const& name, uint32 channel_id, uint32 Team = 0); + std::string const& 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; } + std::string const& GetPassword() const { return m_password; } + void SetPassword(std::string const& npassword) { m_password = npassword; } void SetAnnounce(bool nannounce) { m_announce = nannounce; } uint32 GetNumPlayers() const { return players.size(); } uint8 GetFlags() const { return m_flags; } diff --git a/src/server/game/Chat/Channels/ChannelMgr.cpp b/src/server/game/Chat/Channels/ChannelMgr.cpp index 75436e1eb5f..78b71744e0e 100755 --- a/src/server/game/Chat/Channels/ChannelMgr.cpp +++ b/src/server/game/Chat/Channels/ChannelMgr.cpp @@ -20,7 +20,15 @@ #include "World.h" -ChannelMgr* channelMgr(uint32 team) +ChannelMgr::~ChannelMgr() +{ + for (ChannelMap::iterator itr = channels.begin(); itr != channels.end(); ++itr) + delete itr->second; + + channels.clear(); +} + +ChannelMgr* ChannelMgr::forTeam(uint32 team) { if (sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_CHANNEL)) return ACE_Singleton<AllianceChannelMgr, ACE_Null_Mutex>::instance(); // cross-faction @@ -33,31 +41,25 @@ ChannelMgr* channelMgr(uint32 team) return NULL; } -ChannelMgr::~ChannelMgr() -{ - for (ChannelMap::iterator itr = channels.begin(); itr != channels.end(); ++itr) - delete itr->second; - - channels.clear(); -} - -Channel* ChannelMgr::GetJoinChannel(std::string name, uint32 channel_id) +Channel* ChannelMgr::GetJoinChannel(std::string const& name, uint32 channel_id) { std::wstring wname; Utf8toWStr(name, wname); wstrToLower(wname); - if (channels.find(wname) == channels.end()) + ChannelMap::const_iterator i = channels.find(wname); + + if (i == channels.end()) { Channel* nchan = new Channel(name, channel_id, team); channels[wname] = nchan; return nchan; } - return channels[wname]; + return i->second; } -Channel* ChannelMgr::GetChannel(std::string name, Player* p, bool pkt) +Channel* ChannelMgr::GetChannel(std::string const& name, Player* player, bool pkt) { std::wstring wname; Utf8toWStr(name, wname); @@ -71,7 +73,7 @@ Channel* ChannelMgr::GetChannel(std::string name, Player* p, bool pkt) { WorldPacket data; MakeNotOnPacket(&data, name); - p->GetSession()->SendPacket(&data); + player->GetSession()->SendPacket(&data); } return NULL; @@ -80,7 +82,7 @@ Channel* ChannelMgr::GetChannel(std::string name, Player* p, bool pkt) return i->second; } -void ChannelMgr::LeftChannel(std::string name) +void ChannelMgr::LeftChannel(std::string const& name) { std::wstring wname; Utf8toWStr(name, wname); @@ -100,7 +102,7 @@ void ChannelMgr::LeftChannel(std::string name) } } -void ChannelMgr::MakeNotOnPacket(WorldPacket* data, std::string name) +void ChannelMgr::MakeNotOnPacket(WorldPacket* data, std::string const& name) { data->Initialize(SMSG_CHANNEL_NOTIFY, (1+10)); // we guess size (*data) << (uint8)0x05 << name; diff --git a/src/server/game/Chat/Channels/ChannelMgr.h b/src/server/game/Chat/Channels/ChannelMgr.h index 887e53f49a5..c1d1793c446 100755 --- a/src/server/game/Chat/Channels/ChannelMgr.h +++ b/src/server/game/Chat/Channels/ChannelMgr.h @@ -29,23 +29,29 @@ class ChannelMgr { + typedef std::map<std::wstring, Channel*> ChannelMap; + public: - uint32 team; - typedef std::map<std::wstring, Channel*> ChannelMap; - ChannelMgr() {team = 0;} + ChannelMgr() : team(0) + { } + ~ChannelMgr(); - Channel* GetJoinChannel(std::string name, uint32 channel_id); - Channel* GetChannel(std::string name, Player* p, bool pkt = true); - void LeftChannel(std::string name); + static ChannelMgr * forTeam(uint32 team); + void setTeam(uint32 newTeam) { team = newTeam; } + + Channel* GetJoinChannel(std::string const& name, uint32 channel_id); + Channel* GetChannel(std::string const& name, Player* p, bool pkt = true); + void LeftChannel(std::string const& name); + private: ChannelMap channels; - void MakeNotOnPacket(WorldPacket* data, std::string name); + uint32 team; + + void MakeNotOnPacket(WorldPacket* data, std::string const& name); }; class AllianceChannelMgr : public ChannelMgr {}; class HordeChannelMgr : public ChannelMgr {}; -ChannelMgr* channelMgr(uint32 team); - #endif diff --git a/src/server/game/Chat/Chat.cpp b/src/server/game/Chat/Chat.cpp index b5bad419c98..7faf05a577c 100755 --- a/src/server/game/Chat/Chat.cpp +++ b/src/server/game/Chat/Chat.cpp @@ -350,8 +350,8 @@ bool ChatHandler::ExecuteCommandInTable(ChatCommand* table, const char* text, co Player* p = m_session->GetPlayer(); uint64 sel_guid = p->GetSelection(); sLog->outCommand(m_session->GetAccountId(), "Command: %s [Player: %s (Account: %u) X: %f Y: %f Z: %f Map: %u Selected %s: %s (GUID: %u)]", - fullcmd.c_str(), p->GetName(), m_session->GetAccountId(), p->GetPositionX(), p->GetPositionY(), p->GetPositionZ(), p->GetMapId(), - GetLogNameForGuid(sel_guid), (p->GetSelectedUnit()) ? p->GetSelectedUnit()->GetName() : "", GUID_LOPART(sel_guid)); + fullcmd.c_str(), p->GetName().c_str(), m_session->GetAccountId(), p->GetPositionX(), p->GetPositionY(), p->GetPositionZ(), p->GetMapId(), + GetLogNameForGuid(sel_guid), (p->GetSelectedUnit()) ? p->GetSelectedUnit()->GetName().c_str() : "", GUID_LOPART(sel_guid)); } } } @@ -370,7 +370,7 @@ bool ChatHandler::ExecuteCommandInTable(ChatCommand* table, const char* text, co return false; } -bool ChatHandler::SetDataForCommandInTable(ChatCommand* table, const char* text, uint32 security, std::string const& help, std::string const& fullcommand) +bool ChatHandler::SetDataForCommandInTable(ChatCommand* table, char const* text, uint32 security, std::string const& help, std::string const& fullcommand) { std::string cmd = ""; @@ -425,7 +425,7 @@ bool ChatHandler::SetDataForCommandInTable(ChatCommand* table, const char* text, return false; } -int ChatHandler::ParseCommands(const char* text) +bool ChatHandler::ParseCommands(char const* text) { ASSERT(text); ASSERT(*text); @@ -433,23 +433,23 @@ int ChatHandler::ParseCommands(const char* text) std::string fullcmd = text; if (m_session && AccountMgr::IsPlayerAccount(m_session->GetSecurity()) && !sWorld->getBoolConfig(CONFIG_ALLOW_PLAYER_COMMANDS)) - return 0; + return false; /// chat case (.command or !command format) if (m_session) { if (text[0] != '!' && text[0] != '.') - return 0; + return false; } /// ignore single . and ! in line if (strlen(text) < 2) - return 0; + return false; // original `text` can't be used. It content destroyed in command code processing. /// ignore messages staring from many dots. if ((text[0] == '.' && text[1] == '.') || (text[0] == '!' && text[1] == '!')) - return 0; + return false; /// skip first . or ! (in console allowed use command with . and ! and without its) if (text[0] == '!' || text[0] == '.') @@ -458,14 +458,14 @@ int ChatHandler::ParseCommands(const char* text) if (!ExecuteCommandInTable(getCommandTable(), text, fullcmd)) { if (m_session && AccountMgr::IsPlayerAccount(m_session->GetSecurity())) - return 0; + return false; SendSysMessage(LANG_NO_CMD); } - return 1; + return true; } -bool ChatHandler::isValidChatMessage(const char* message) +bool ChatHandler::isValidChatMessage(char const* message) { /* Valid examples: @@ -663,7 +663,7 @@ void ChatHandler::FillMessageData(WorldPacket* data, WorldSession* session, uint { *data << uint64(speaker->GetGUID()); *data << uint32(0); // 2.1.0 - *data << uint32(strlen(speaker->GetName()) + 1); + *data << uint32(speaker->GetName().size() + 1); *data << speaker->GetName(); uint64 listener_guid = 0; *data << uint64(listener_guid); @@ -1020,7 +1020,7 @@ uint64 ChatHandler::extractGuidFromLink(char* text) if (!normalizePlayerName(name)) return 0; - if (Player* player = sObjectAccessor->FindPlayerByName(name.c_str())) + if (Player* player = sObjectAccessor->FindPlayerByName(name)) return player->GetGUID(); if (uint64 guid = sObjectMgr->GetPlayerGUIDByName(name)) @@ -1078,7 +1078,7 @@ bool ChatHandler::extractPlayerTarget(char* args, Player** player, uint64* playe return false; } - Player* pl = sObjectAccessor->FindPlayerByName(name.c_str()); + Player* pl = sObjectAccessor->FindPlayerByName(name); // if allowed player pointer if (player) @@ -1213,7 +1213,7 @@ bool ChatHandler::GetPlayerGroupAndGUIDByName(const char* cname, Player* &player return false; } - player = sObjectAccessor->FindPlayerByName(name.c_str()); + player = sObjectAccessor->FindPlayerByName(name); if (offline) guid = sObjectMgr->GetPlayerGUIDByName(name.c_str()); } diff --git a/src/server/game/Chat/Chat.h b/src/server/game/Chat/Chat.h index d4701b10ce1..0c1b22182e1 100755 --- a/src/server/game/Chat/Chat.h +++ b/src/server/game/Chat/Chat.h @@ -74,7 +74,7 @@ class ChatHandler void PSendSysMessage(int32 entry, ...); std::string PGetParseString(int32 entry, ...) const; - int ParseCommands(const char* text); + bool ParseCommands(const char* text); static ChatCommand* getCommandTable(); @@ -128,7 +128,7 @@ class ChatHandler protected: explicit ChatHandler() : m_session(NULL), sentErrorMessage(false) {} // for CLI subclass static bool SetDataForCommandInTable(ChatCommand* table, const char* text, uint32 security, std::string const& help, std::string const& fullcommand); - bool ExecuteCommandInTable(ChatCommand* table, const char* text, const std::string& fullcmd); + bool ExecuteCommandInTable(ChatCommand* table, const char* text, std::string const& fullcmd); bool ShowHelpForSubCommands(ChatCommand* table, char const* cmd, char const* subcmd); private: diff --git a/src/server/game/Combat/ThreatManager.cpp b/src/server/game/Combat/ThreatManager.cpp index cd6b9a7da60..2c45067d95a 100755 --- a/src/server/game/Combat/ThreatManager.cpp +++ b/src/server/game/Combat/ThreatManager.cpp @@ -253,25 +253,29 @@ Unit* HostileReference::getSourceUnit() void ThreatContainer::clearReferences() { - for (std::list<HostileReference*>::const_iterator i = iThreatList.begin(); i != iThreatList.end(); ++i) + for (ThreatContainer::StorageType::const_iterator i = iThreatList.begin(); i != iThreatList.end(); ++i) { (*i)->unlink(); delete (*i); } + iThreatList.clear(); } //============================================================ // Return the HostileReference of NULL, if not found -HostileReference* ThreatContainer::getReferenceByTarget(Unit* victim) +HostileReference* ThreatContainer::getReferenceByTarget(Unit* victim) const { if (!victim) return NULL; - uint64 guid = victim->GetGUID(); - for (std::list<HostileReference*>::const_iterator i = iThreatList.begin(); i != iThreatList.end(); ++i) - if ((*i) && (*i)->getUnitGuid() == guid) - return (*i); + uint64 const guid = victim->GetGUID(); + for (ThreatContainer::StorageType::const_iterator i = iThreatList.begin(); i != iThreatList.end(); ++i) + { + HostileReference *ref = (*i); + if (ref && ref->getUnitGuid() == guid) + return ref; + } return NULL; } @@ -310,16 +314,16 @@ void ThreatContainer::update() // return the next best victim // could be the current victim -HostileReference* ThreatContainer::selectNextVictim(Creature* attacker, HostileReference* currentVictim) +HostileReference* ThreatContainer::selectNextVictim(Creature* attacker, HostileReference* currentVictim) const { HostileReference* currentRef = NULL; bool found = false; bool noPriorityTargetFound = false; - std::list<HostileReference*>::const_iterator lastRef = iThreatList.end(); + ThreatContainer::StorageType::const_iterator lastRef = iThreatList.end(); --lastRef; - for (std::list<HostileReference*>::const_iterator iter = iThreatList.begin(); iter != iThreatList.end() && !found;) + for (ThreatContainer::StorageType::const_iterator iter = iThreatList.begin(); iter != iThreatList.end() && !found;) { currentRef = (*iter); @@ -577,17 +581,15 @@ bool ThreatManager::isNeedUpdateToClient(uint32 time) return false; } -// Reset all aggro without modifying the threadlist. +// Reset all aggro without modifying the threatlist. void ThreatManager::resetAllAggro() { - std::list<HostileReference*> &threatList = getThreatList(); + ThreatContainer::StorageType &threatList = iThreatContainer.iThreatList; if (threatList.empty()) return; - for (std::list<HostileReference*>::iterator itr = threatList.begin(); itr != threatList.end(); ++itr) - { + for (ThreatContainer::StorageType::iterator itr = threatList.begin(); itr != threatList.end(); ++itr) (*itr)->setThreat(0); - } setDirty(true); } diff --git a/src/server/game/Combat/ThreatManager.h b/src/server/game/Combat/ThreatManager.h index e5badcd24ce..665acd6d751 100755 --- a/src/server/game/Combat/ThreatManager.h +++ b/src/server/game/Combat/ThreatManager.h @@ -142,39 +142,57 @@ class ThreatManager; class ThreatContainer { - private: - std::list<HostileReference*> iThreatList; - bool iDirty; - protected: friend class ThreatManager; - void remove(HostileReference* hostileRef) { iThreatList.remove(hostileRef); } - void addReference(HostileReference* hostileRef) { iThreatList.push_back(hostileRef); } - void clearReferences(); - - // Sort the list if necessary - void update(); public: - ThreatContainer() { iDirty = false; } + typedef std::list<HostileReference*> StorageType; + + ThreatContainer(): iDirty(false) { } + ~ThreatContainer() { clearReferences(); } HostileReference* addThreat(Unit* victim, float threat); void modifyThreatPercent(Unit* victim, int32 percent); - HostileReference* selectNextVictim(Creature* attacker, HostileReference* currentVictim); + HostileReference* selectNextVictim(Creature* attacker, HostileReference* currentVictim) const; void setDirty(bool isDirty) { iDirty = isDirty; } bool isDirty() const { return iDirty; } - bool empty() const { return iThreatList.empty(); } + bool empty() const + { + return iThreatList.empty(); + } - HostileReference* getMostHated() { return iThreatList.empty() ? NULL : iThreatList.front(); } + HostileReference* getMostHated() const + { + return iThreatList.empty() ? NULL : iThreatList.front(); + } + + HostileReference* getReferenceByTarget(Unit* victim) const; - HostileReference* getReferenceByTarget(Unit* victim); + StorageType const & getThreatList() const { return iThreatList; } - std::list<HostileReference*>& getThreatList() { return iThreatList; } + private: + void remove(HostileReference* hostileRef) + { + iThreatList.remove(hostileRef); + } + + void addReference(HostileReference* hostileRef) + { + iThreatList.push_back(hostileRef); + } + + void clearReferences(); + + // Sort the list if necessary + void update(); + + StorageType iThreatList; + bool iDirty; }; //================================================= @@ -198,15 +216,15 @@ class ThreatManager float getThreat(Unit* victim, bool alsoSearchOfflineList = false); - bool isThreatListEmpty() { return iThreatContainer.empty(); } + bool isThreatListEmpty() const { return iThreatContainer.empty(); } void processThreatEvent(ThreatRefStatusChangeEvent* threatRefStatusChangeEvent); bool isNeedUpdateToClient(uint32 time); - HostileReference* getCurrentVictim() { return iCurrentVictim; } + HostileReference* getCurrentVictim() const { return iCurrentVictim; } - Unit* getOwner() { return iOwner; } + Unit* getOwner() const { return iOwner; } Unit* getHostilTarget(); @@ -223,11 +241,11 @@ class ThreatManager // Reset all aggro of unit in threadlist satisfying the predicate. template<class PREDICATE> void resetAggro(PREDICATE predicate) { - std::list<HostileReference*> &threatList = getThreatList(); + ThreatContainer::StorageType &threatList = iThreatContainer.iThreatList; if (threatList.empty()) return; - for (std::list<HostileReference*>::iterator itr = threatList.begin(); itr != threatList.end(); ++itr) + for (ThreatContainer::StorageType::iterator itr = threatList.begin(); itr != threatList.end(); ++itr) { HostileReference* ref = (*itr); @@ -241,8 +259,8 @@ class ThreatManager // methods to access the lists from the outside to do some dirty manipulation (scriping and such) // I hope they are used as little as possible. - std::list<HostileReference*>& getThreatList() { return iThreatContainer.getThreatList(); } - std::list<HostileReference*>& getOfflineThreatList() { return iThreatOfflineContainer.getThreatList(); } + ThreatContainer::StorageType const & getThreatList() const { return iThreatContainer.getThreatList(); } + ThreatContainer::StorageType const & getOfflineThreatList() const { return iThreatOfflineContainer.getThreatList(); } ThreatContainer& getOnlineContainer() { return iThreatContainer; } ThreatContainer& getOfflineContainer() { return iThreatOfflineContainer; } private: @@ -273,4 +291,3 @@ namespace Trinity }; } #endif - diff --git a/src/server/game/Conditions/ConditionMgr.cpp b/src/server/game/Conditions/ConditionMgr.cpp index 7dc4b57d188..72f00406c69 100755 --- a/src/server/game/Conditions/ConditionMgr.cpp +++ b/src/server/game/Conditions/ConditionMgr.cpp @@ -661,7 +661,7 @@ ConditionList ConditionMgr::GetConditionsForVehicleSpell(uint32 creatureId, uint CreatureSpellConditionContainer::const_iterator itr = VehicleSpellConditionStore.find(creatureId); if (itr != VehicleSpellConditionStore.end()) { - ConditionTypeContainer::const_iterator i = (*itr).second.find(spellId); + ConditionTypeContainer::const_iterator i = (*itr).second.find(spellId); if (i != (*itr).second.end()) { cond = (*i).second; @@ -737,7 +737,7 @@ void ConditionMgr::LoadConditions(bool isReload) Condition* cond = new Condition(); int32 iSourceTypeOrReferenceId = fields[0].GetInt32(); cond->SourceGroup = fields[1].GetUInt32(); - cond->SourceEntry = fields[2].GetUInt32(); + cond->SourceEntry = fields[2].GetInt32(); cond->SourceId = fields[3].GetInt32(); cond->ElseGroup = fields[4].GetUInt32(); int32 iConditionTypeOrReference = fields[5].GetInt32(); diff --git a/src/server/game/Conditions/DisableMgr.cpp b/src/server/game/Conditions/DisableMgr.cpp index 9b065729b88..a209d9b6cf6 100755 --- a/src/server/game/Conditions/DisableMgr.cpp +++ b/src/server/game/Conditions/DisableMgr.cpp @@ -60,7 +60,6 @@ void LoadDisables() if (!result) { sLog->outInfo(LOG_FILTER_SERVER_LOADING, ">> Loaded 0 disables. DB table `disables` is empty!"); - return; } @@ -134,10 +133,12 @@ void LoadDisables() case MAP_INSTANCE: case MAP_RAID: if (flags & DUNGEON_STATUSFLAG_HEROIC && !GetMapDifficultyData(entry, DUNGEON_DIFFICULTY_HEROIC)) - isFlagInvalid = true; - else if (flags & RAID_STATUSFLAG_10MAN_HEROIC && !GetMapDifficultyData(entry, RAID_DIFFICULTY_10MAN_HEROIC)) - isFlagInvalid = true; - else if (flags & RAID_STATUSFLAG_25MAN_HEROIC && !GetMapDifficultyData(entry, RAID_DIFFICULTY_25MAN_HEROIC)) + flags -= DUNGEON_STATUSFLAG_HEROIC; + if (flags & RAID_STATUSFLAG_10MAN_HEROIC && !GetMapDifficultyData(entry, RAID_DIFFICULTY_10MAN_HEROIC)) + flags -= RAID_STATUSFLAG_10MAN_HEROIC; + if (flags & RAID_STATUSFLAG_25MAN_HEROIC && !GetMapDifficultyData(entry, RAID_DIFFICULTY_25MAN_HEROIC)) + flags -= RAID_STATUSFLAG_25MAN_HEROIC; + if (!flags) isFlagInvalid = true; break; case MAP_BATTLEGROUND: @@ -229,7 +230,6 @@ void LoadDisables() while (result->NextRow()); sLog->outInfo(LOG_FILTER_SERVER_LOADING, ">> Loaded %u disables in %u ms", total_count, GetMSTimeDiffToNow(oldMSTime)); - } void CheckQuestDisables() @@ -240,7 +240,6 @@ void CheckQuestDisables() if (!count) { sLog->outInfo(LOG_FILTER_SERVER_LOADING, ">> Checked 0 quest disables."); - return; } @@ -260,7 +259,6 @@ void CheckQuestDisables() } sLog->outInfo(LOG_FILTER_SERVER_LOADING, ">> Checked %u quest disables in %u ms", count, GetMSTimeDiffToNow(oldMSTime)); - } bool IsDisabledFor(DisableType type, uint32 entry, Unit const* unit, uint8 flags) diff --git a/src/server/game/DungeonFinding/LFG.h b/src/server/game/DungeonFinding/LFG.h index abdb0ffa511..6ad30547670 100755 --- a/src/server/game/DungeonFinding/LFG.h +++ b/src/server/game/DungeonFinding/LFG.h @@ -49,7 +49,7 @@ enum LfgUpdateType LFG_UPDATETYPE_GROUP_FOUND = 10, LFG_UPDATETYPE_ADDED_TO_QUEUE = 12, LFG_UPDATETYPE_PROPOSAL_BEGIN = 13, - LFG_UPDATETYPE_CLEAR_LOCK_LIST = 14, + LFG_UPDATETYPE_UPDATE_STATUS = 14, LFG_UPDATETYPE_GROUP_MEMBER_OFFLINE = 15, LFG_UPDATETYPE_GROUP_DISBAND_UNK16 = 16, // FIXME: Sometimes at group disband }; diff --git a/src/server/game/DungeonFinding/LFGGroupData.cpp b/src/server/game/DungeonFinding/LFGGroupData.cpp index 712ae5132b0..a4ee230b5eb 100644 --- a/src/server/game/DungeonFinding/LFGGroupData.cpp +++ b/src/server/game/DungeonFinding/LFGGroupData.cpp @@ -93,11 +93,16 @@ LfgState LfgGroupData::GetOldState() const return m_OldState; } -const LfgGuidSet &LfgGroupData::GetPlayers() const +LfgGuidSet const& LfgGroupData::GetPlayers() const { return m_Players; } +uint8 LfgGroupData::GetPlayerCount() const +{ + return m_Players.size(); +} + uint64 LfgGroupData::GetLeader() const { return m_Leader; diff --git a/src/server/game/DungeonFinding/LFGGroupData.h b/src/server/game/DungeonFinding/LFGGroupData.h index 43cd64f97c3..2054e776282 100644 --- a/src/server/game/DungeonFinding/LFGGroupData.h +++ b/src/server/game/DungeonFinding/LFGGroupData.h @@ -54,6 +54,7 @@ class LfgGroupData LfgState GetState() const; LfgState GetOldState() const; LfgGuidSet const& GetPlayers() const; + uint8 GetPlayerCount() const; uint64 GetLeader() const; // Dungeon diff --git a/src/server/game/DungeonFinding/LFGMgr.cpp b/src/server/game/DungeonFinding/LFGMgr.cpp index 659986fb148..c91be00080e 100755 --- a/src/server/game/DungeonFinding/LFGMgr.cpp +++ b/src/server/game/DungeonFinding/LFGMgr.cpp @@ -31,19 +31,16 @@ #include "GroupMgr.h" #include "GameEventMgr.h" -LFGMgr::LFGMgr(): m_QueueTimer(0), m_lfgProposalId(1) +LFGMgr::LFGMgr(): m_QueueTimer(0), m_lfgProposalId(1), + m_options(sWorld->getIntConfig(CONFIG_LFG_OPTIONSMASK)) { - m_options = sWorld->getBoolConfig(CONFIG_DUNGEON_FINDER_ENABLE); - if (m_options) - { - new LFGPlayerScript(); - new LFGGroupScript(); - } + new LFGPlayerScript(); + new LFGGroupScript(); } LFGMgr::~LFGMgr() { - for (LfgRewardMap::iterator itr = m_RewardMap.begin(); itr != m_RewardMap.end(); ++itr) + for (LfgRewardContainer::iterator itr = RewardMapStore.begin(); itr != RewardMapStore.end(); ++itr) delete itr->second; } @@ -55,8 +52,9 @@ void LFGMgr::_LoadFromDB(Field* fields, uint64 guid) if (!IS_GROUP(guid)) return; - uint32 dungeon = fields[16].GetUInt32(); + SetLeader(guid, MAKE_NEW_GUID(fields[0].GetUInt32(), 0, HIGHGUID_PLAYER)); + uint32 dungeon = fields[16].GetUInt32(); uint8 state = fields[17].GetUInt8(); if (!dungeon || !state) @@ -144,7 +142,7 @@ std::string LFGMgr::GetRolesString(uint8 roles) return rolesstr; } -char const * LFGMgr::GetStateString(LfgState state) +std::string LFGMgr::GetStateString(LfgState state) { int32 entry = LANG_LFG_ERROR; switch (state) @@ -174,8 +172,8 @@ char const * LFGMgr::GetStateString(LfgState state) entry = LANG_LFG_STATE_RAIDBROWSER; break; } - char const * const str = sObjectMgr->GetTrinityStringForDBCLocale(entry); - return str; + + return std::string(sObjectMgr->GetTrinityStringForDBCLocale(entry)); } /// Load rewards for completing dungeons @@ -183,9 +181,9 @@ void LFGMgr::LoadRewards() { uint32 oldMSTime = getMSTime(); - for (LfgRewardMap::iterator itr = m_RewardMap.begin(); itr != m_RewardMap.end(); ++itr) + for (LfgRewardContainer::iterator itr = RewardMapStore.begin(); itr != RewardMapStore.end(); ++itr) delete itr->second; - m_RewardMap.clear(); + RewardMapStore.clear(); // ORDER BY is very important for GetRandomDungeonReward! QueryResult result = WorldDatabase.Query("SELECT dungeonId, maxLevel, firstQuestId, firstMoneyVar, firstXPVar, otherQuestId, otherMoneyVar, otherXPVar FROM lfg_dungeon_rewards ORDER BY dungeonId, maxLevel ASC"); @@ -235,7 +233,7 @@ void LFGMgr::LoadRewards() otherQuestId = 0; } - m_RewardMap.insert(LfgRewardMap::value_type(dungeonId, new LfgReward(maxLevel, firstQuestId, firstMoneyVar, firstXPVar, otherQuestId, otherMoneyVar, otherXPVar))); + RewardMapStore.insert(LfgRewardContainer::value_type(dungeonId, new LfgReward(maxLevel, firstQuestId, firstMoneyVar, firstXPVar, otherQuestId, otherMoneyVar, otherXPVar))); ++count; } while (result->NextRow()); @@ -244,23 +242,23 @@ void LFGMgr::LoadRewards() LFGDungeonData const* LFGMgr::GetLFGDungeon(uint32 id) { - LFGDungeonMap::const_iterator itr = m_LfgDungeonMap.find(id); - if (itr != m_LfgDungeonMap.end()) + LFGDungeonContainer::const_iterator itr = LfgDungeonStore.find(id); + if (itr != LfgDungeonStore.end()) return &(itr->second); return NULL; } -LFGDungeonMap & LFGMgr::GetLFGDungeonMap() +LFGDungeonContainer & LFGMgr::GetLFGDungeonMap() { - return m_LfgDungeonMap; + return LfgDungeonStore; } void LFGMgr::LoadLFGDungeons(bool reload /* = false */) { uint32 oldMSTime = getMSTime(); - m_LfgDungeonMap.clear(); + LfgDungeonStore.clear(); // Initialize Dungeon map with data from dbcs for (uint32 i = 0; i < sLFGDungeonStore.GetNumRows(); ++i) @@ -275,7 +273,7 @@ void LFGMgr::LoadLFGDungeons(bool reload /* = false */) case LFG_TYPE_HEROIC: case LFG_TYPE_RAID: case LFG_TYPE_RANDOM: - m_LfgDungeonMap[dungeon->ID] = LFGDungeonData(dungeon); + LfgDungeonStore[dungeon->ID] = LFGDungeonData(dungeon); break; } } @@ -295,8 +293,8 @@ void LFGMgr::LoadLFGDungeons(bool reload /* = false */) { Field* fields = result->Fetch(); uint32 dungeonId = fields[0].GetUInt32(); - LFGDungeonMap::iterator dungeonItr = m_LfgDungeonMap.find(dungeonId); - if (dungeonItr == m_LfgDungeonMap.end()) + LFGDungeonContainer::iterator dungeonItr = LfgDungeonStore.find(dungeonId); + if (dungeonItr == LfgDungeonStore.end()) { sLog->outError(LOG_FILTER_SQL, "table `lfg_entrances` contains coordinates for wrong dungeon %u", dungeonId); continue; @@ -315,11 +313,12 @@ void LFGMgr::LoadLFGDungeons(bool reload /* = false */) sLog->outInfo(LOG_FILTER_SERVER_LOADING, ">> Loaded %u lfg entrance positions in %u ms", count, GetMSTimeDiffToNow(oldMSTime)); // Fill all other teleport coords from areatriggers - for (LFGDungeonMap::iterator itr = m_LfgDungeonMap.begin(); itr != m_LfgDungeonMap.end(); ++itr) + for (LFGDungeonContainer::iterator itr = LfgDungeonStore.begin(); itr != LfgDungeonStore.end(); ++itr) { LFGDungeonData& dungeon = itr->second; + // No teleport coords in database, load from areatriggers - if (dungeon.x == 0.0f && dungeon.y == 0.0f && dungeon.z == 0.0f) + if (dungeon.type != LFG_TYPE_RANDOM && dungeon.x == 0.0f && dungeon.y == 0.0f && dungeon.z == 0.0f) { AreaTrigger const* at = sObjectMgr->GetMapEntranceTrigger(dungeon.map); if (!at) @@ -336,15 +335,15 @@ void LFGMgr::LoadLFGDungeons(bool reload /* = false */) } if (dungeon.type != LFG_TYPE_RANDOM) - m_CachedDungeonMap[dungeon.group].insert(dungeon.id); - m_CachedDungeonMap[0].insert(dungeon.id); + CachedDungeonMapStore[dungeon.group].insert(dungeon.id); + CachedDungeonMapStore[0].insert(dungeon.id); } if (reload) { - m_CachedDungeonMap.clear(); + CachedDungeonMapStore.clear(); // Recalculate locked dungeons - for (LfgPlayerDataMap::const_iterator it = m_Players.begin(); it != m_Players.end(); ++it) + for (LfgPlayerDataContainer::const_iterator it = PlayersStore.begin(); it != PlayersStore.end(); ++it) if (Player* player = ObjectAccessor::FindPlayer(it->first)) InitializeLockedDungeons(player); } @@ -352,15 +351,15 @@ void LFGMgr::LoadLFGDungeons(bool reload /* = false */) void LFGMgr::Update(uint32 diff) { - if (!m_options) + if (!isOptionEnabled(LFG_OPTION_ENABLE_DUNGEON_FINDER | LFG_OPTION_ENABLE_RAID_BROWSER)) return; time_t currTime = time(NULL); // Remove obsolete role checks - for (LfgRoleCheckMap::iterator it = m_RoleChecks.begin(); it != m_RoleChecks.end();) + for (LfgRoleCheckContainer::iterator it = RoleChecksStore.begin(); it != RoleChecksStore.end();) { - LfgRoleCheckMap::iterator itRoleCheck = it++; + LfgRoleCheckContainer::iterator itRoleCheck = it++; LfgRoleCheck& roleCheck = itRoleCheck->second; if (currTime < roleCheck.cancelTime) continue; @@ -374,51 +373,53 @@ void LFGMgr::Update(uint32 diff) if (guid == roleCheck.leader) SendLfgJoinResult(guid, LfgJoinResultData(LFG_JOIN_FAILED, LFG_ROLECHECK_MISSING_ROLE)); } - m_RoleChecks.erase(itRoleCheck); + RoleChecksStore.erase(itRoleCheck); } // Remove obsolete proposals - for (LfgProposalMap::iterator it = m_Proposals.begin(); it != m_Proposals.end();) + for (LfgProposalContainer::iterator it = ProposalsStore.begin(); it != ProposalsStore.end();) { - LfgProposalMap::iterator itRemove = it++; + LfgProposalContainer::iterator itRemove = it++; if (itRemove->second.cancelTime < currTime) RemoveProposal(itRemove, LFG_UPDATETYPE_PROPOSAL_FAILED); } // Remove obsolete kicks - for (LfgPlayerBootMap::iterator it = m_Boots.begin(); it != m_Boots.end();) + for (LfgPlayerBootContainer::iterator it = BootsStore.begin(); it != BootsStore.end();) { - LfgPlayerBootMap::iterator itBoot = it++; + LfgPlayerBootContainer::iterator itBoot = it++; LfgPlayerBoot& boot = itBoot->second; if (boot.cancelTime < currTime) { boot.inProgress = false; - for (LfgAnswerMap::const_iterator itVotes = boot.votes.begin(); itVotes != boot.votes.end(); ++itVotes) + for (LfgAnswerContainer::const_iterator itVotes = boot.votes.begin(); itVotes != boot.votes.end(); ++itVotes) { uint64 pguid = itVotes->first; if (pguid != boot.victim) SendLfgBootProposalUpdate(pguid, boot); + SetState(pguid, LFG_STATE_DUNGEON); } - m_Boots.erase(itBoot); + SetState(itBoot->first, LFG_STATE_DUNGEON); + BootsStore.erase(itBoot); } } uint32 lastProposalId = m_lfgProposalId; // Check if a proposal can be formed with the new groups being added - for (LfgQueueMap::iterator it = m_Queues.begin(); it != m_Queues.end(); ++it) + for (LfgQueueContainer::iterator it = QueuesStore.begin(); it != QueuesStore.end(); ++it) if (uint8 newProposals = it->second.FindGroups()) sLog->outDebug(LOG_FILTER_LFG, "LFGMgr::Update: Found %u new groups in queue %u", newProposals, it->first); if (lastProposalId != m_lfgProposalId) { // FIXME lastProposalId ? lastProposalId +1 ? - for (LfgProposalMap::const_iterator itProposal = m_Proposals.find(m_lfgProposalId); itProposal != m_Proposals.end(); ++itProposal) + for (LfgProposalContainer::const_iterator itProposal = ProposalsStore.find(m_lfgProposalId); itProposal != ProposalsStore.end(); ++itProposal) { uint32 proposalId = itProposal->first; - LfgProposal& proposal = m_Proposals[proposalId]; + LfgProposal& proposal = ProposalsStore[proposalId]; uint64 guid = 0; - for (LfgProposalPlayerMap::const_iterator itPlayers = proposal.players.begin(); itPlayers != proposal.players.end(); ++itPlayers) + for (LfgProposalPlayerContainer::const_iterator itPlayers = proposal.players.begin(); itPlayers != proposal.players.end(); ++itPlayers) { guid = itPlayers->first; SetState(guid, LFG_STATE_PROPOSAL); @@ -442,7 +443,7 @@ void LFGMgr::Update(uint32 diff) { m_QueueTimer = 0; time_t currTime = time(NULL); - for (LfgQueueMap::iterator it = m_Queues.begin(); it != m_Queues.end(); ++it) + for (LfgQueueContainer::iterator it = QueuesStore.begin(); it != QueuesStore.end(); ++it) it->second.UpdateQueueTimers(currTime); } else @@ -493,10 +494,10 @@ void LFGMgr::InitializeLockedDungeons(Player* player, uint8 level /* = 0 */) else if (ar->item) { - if (!player->HasItemCount(ar->item, 1) && (!ar->item2 || !player->HasItemCount(ar->item2, 1))) + if (!player->HasItemCount(ar->item) && (!ar->item2 || !player->HasItemCount(ar->item2))) lockData = LFG_LOCKSTATUS_MISSING_ITEM; } - else if (ar->item2 && !player->HasItemCount(ar->item2, 1)) + else if (ar->item2 && !player->HasItemCount(ar->item2)) lockData = LFG_LOCKSTATUS_MISSING_ITEM; } @@ -562,7 +563,7 @@ void LFGMgr::JoinLfg(Player* player, uint8 roles, LfgDungeonSet& dungeons, const } else // Remove from queue and rejoin { - LfgQueue& queue = GetQueue(gguid); + LFGQueue& queue = GetQueue(gguid); queue.RemoveFromQueue(gguid); } } @@ -673,7 +674,7 @@ void LFGMgr::JoinLfg(Player* player, uint8 roles, LfgDungeonSet& dungeons, const if (grp) // Begin rolecheck { // Create new rolecheck - LfgRoleCheck& roleCheck = m_RoleChecks[gguid]; + LfgRoleCheck& roleCheck = RoleChecksStore[gguid]; roleCheck.cancelTime = time_t(time(NULL)) + LFG_TIME_ROLECHECK; roleCheck.state = LFG_ROLECHECK_INITIALITING; roleCheck.leader = guid; @@ -711,7 +712,7 @@ void LFGMgr::JoinLfg(Player* player, uint8 roles, LfgDungeonSet& dungeons, const { LfgRolesMap rolesMap; rolesMap[guid] = roles; - LfgQueue& queue = GetQueue(gguid); + LFGQueue& queue = GetQueue(gguid); queue.AddQueueData(guid, time_t(time(NULL)), dungeons, rolesMap); if (!isContinue) @@ -757,7 +758,7 @@ void LFGMgr::LeaveLfg(uint64 guid) case LFG_STATE_QUEUED: if (gguid) { - LfgQueue& queue = GetQueue(gguid); + LFGQueue& queue = GetQueue(gguid); queue.RemoveFromQueue(gguid); RestoreState(gguid, "Leave queue"); const LfgGuidSet& players = GetPlayers(gguid); @@ -770,7 +771,7 @@ void LFGMgr::LeaveLfg(uint64 guid) } else { - LfgQueue& queue = GetQueue(guid); + LFGQueue& queue = GetQueue(guid); queue.RemoveFromQueue(guid); SendLfgUpdatePlayer(guid, LfgUpdateData(LFG_UPDATETYPE_REMOVED_FROM_QUEUE)); ClearState(guid, "Leave queue"); @@ -783,11 +784,11 @@ void LFGMgr::LeaveLfg(uint64 guid) case LFG_STATE_PROPOSAL: { // Remove from Proposals - LfgProposalMap::iterator it = m_Proposals.begin(); + LfgProposalContainer::iterator it = ProposalsStore.begin(); uint64 pguid = gguid == guid ? GetLeader(gguid) : guid; - while (it != m_Proposals.end()) + while (it != ProposalsStore.end()) { - LfgProposalPlayerMap::iterator itPlayer = it->second.players.find(pguid); + LfgProposalPlayerContainer::iterator itPlayer = it->second.players.find(pguid); if (itPlayer != it->second.players.end()) { // Mark the player/leader of group who left as didn't accept the proposal @@ -798,7 +799,7 @@ void LFGMgr::LeaveLfg(uint64 guid) } // Remove from queue - if proposal is found, RemoveProposal will call RemoveFromQueue - if (it != m_Proposals.end()) + if (it != ProposalsStore.end()) RemoveProposal(it, LFG_UPDATETYPE_PROPOSAL_DECLINED); break; } @@ -820,8 +821,8 @@ void LFGMgr::UpdateRoleCheck(uint64 gguid, uint64 guid /* = 0 */, uint8 roles /* return; LfgRolesMap check_roles; - LfgRoleCheckMap::iterator itRoleCheck = m_RoleChecks.find(gguid); - if (itRoleCheck == m_RoleChecks.end()) + LfgRoleCheckContainer::iterator itRoleCheck = RoleChecksStore.find(gguid); + if (itRoleCheck == RoleChecksStore.end()) return; LfgRoleCheck& roleCheck = itRoleCheck->second; @@ -884,13 +885,15 @@ void LFGMgr::UpdateRoleCheck(uint64 gguid, uint64 guid /* = 0 */, uint8 roles /* if (roleCheck.state == LFG_ROLECHECK_FINISHED) { SetState(gguid, LFG_STATE_QUEUED); - LfgQueue& queue = GetQueue(gguid); + LFGQueue& queue = GetQueue(gguid); queue.AddQueueData(gguid, time_t(time(NULL)), roleCheck.dungeons, roleCheck.roles); + RoleChecksStore.erase(itRoleCheck); } else if (roleCheck.state != LFG_ROLECHECK_INITIALITING) + { RestoreState(gguid, "Rolecheck Failed"); - - m_RoleChecks.erase(itRoleCheck); + RoleChecksStore.erase(itRoleCheck); + } } /** @@ -947,19 +950,19 @@ bool LFGMgr::CheckGroupRoles(LfgRolesMap& groles, bool removeLeaderFlag /*= true if (it->second == PLAYER_ROLE_NONE) return false; - if (it->second & PLAYER_ROLE_TANK) + if (it->second & PLAYER_ROLE_DAMAGE) { - if (it->second != PLAYER_ROLE_TANK) + if (it->second != PLAYER_ROLE_DAMAGE) { - it->second -= PLAYER_ROLE_TANK; + it->second -= PLAYER_ROLE_DAMAGE; if (CheckGroupRoles(groles, false)) return true; - it->second += PLAYER_ROLE_TANK; + it->second += PLAYER_ROLE_DAMAGE; } - else if (tank == LFG_TANKS_NEEDED) + else if (damage == LFG_DPS_NEEDED) return false; else - tank++; + damage++; } if (it->second & PLAYER_ROLE_HEALER) @@ -977,19 +980,19 @@ bool LFGMgr::CheckGroupRoles(LfgRolesMap& groles, bool removeLeaderFlag /*= true healer++; } - if (it->second & PLAYER_ROLE_DAMAGE) + if (it->second & PLAYER_ROLE_TANK) { - if (it->second != PLAYER_ROLE_DAMAGE) + if (it->second != PLAYER_ROLE_TANK) { - it->second -= PLAYER_ROLE_DAMAGE; + it->second -= PLAYER_ROLE_TANK; if (CheckGroupRoles(groles, false)) return true; - it->second += PLAYER_ROLE_DAMAGE; + it->second += PLAYER_ROLE_TANK; } - else if (damage == LFG_DPS_NEEDED) + else if (tank == LFG_TANKS_NEEDED) return false; else - damage++; + tank++; } } return (tank + healer + damage) == uint8(groles.size()); @@ -1004,7 +1007,7 @@ void LFGMgr::MakeNewGroup(const LfgProposal& proposal) LfgGuidList players; LfgGuidList playersToTeleport; - for (LfgProposalPlayerMap::const_iterator it = proposal.players.begin(); it != proposal.players.end(); ++it) + for (LfgProposalPlayerContainer::const_iterator it = proposal.players.begin(); it != proposal.players.end(); ++it) { uint64 guid = it->first; if (guid == proposal.leader) @@ -1069,7 +1072,7 @@ void LFGMgr::MakeNewGroup(const LfgProposal& proposal) uint32 LFGMgr::AddProposal(LfgProposal const& proposal) { - m_Proposals[++m_lfgProposalId] = proposal; + ProposalsStore[++m_lfgProposalId] = proposal; return m_lfgProposalId; } @@ -1083,14 +1086,14 @@ uint32 LFGMgr::AddProposal(LfgProposal const& proposal) void LFGMgr::UpdateProposal(uint32 proposalId, uint64 guid, bool accept) { // Check if the proposal exists - LfgProposalMap::iterator itProposal = m_Proposals.find(proposalId); - if (itProposal == m_Proposals.end()) + LfgProposalContainer::iterator itProposal = ProposalsStore.find(proposalId); + if (itProposal == ProposalsStore.end()) return; LfgProposal& proposal = itProposal->second; // Check if proposal have the current player - LfgProposalPlayerMap::iterator itProposalPlayer = proposal.players.find(guid); + LfgProposalPlayerContainer::iterator itProposalPlayer = proposal.players.find(guid); if (itProposalPlayer == proposal.players.end()) return; @@ -1106,13 +1109,13 @@ void LFGMgr::UpdateProposal(uint32 proposalId, uint64 guid, bool accept) // check if all have answered and reorder players (leader first) bool allAnswered = true; - for (LfgProposalPlayerMap::const_iterator itPlayers = proposal.players.begin(); itPlayers != proposal.players.end(); ++itPlayers) + for (LfgProposalPlayerContainer::const_iterator itPlayers = proposal.players.begin(); itPlayers != proposal.players.end(); ++itPlayers) if (itPlayers->second.accept != LFG_ANSWER_AGREE) // No answer (-1) or not accepted (0) allAnswered = false; if (!allAnswered) { - for (LfgProposalPlayerMap::const_iterator it = proposal.players.begin(); it != proposal.players.end(); ++it) + for (LfgProposalPlayerContainer::const_iterator it = proposal.players.begin(); it != proposal.players.end(); ++it) { uint64 guid = it->first; SendLfgUpdateProposal(guid, proposalId, proposal); @@ -1124,9 +1127,9 @@ void LFGMgr::UpdateProposal(uint32 proposalId, uint64 guid, bool accept) proposal.state = LFG_PROPOSAL_SUCCESS; time_t joinTime = time_t(time(NULL)); - LfgQueue& queue = GetQueue(guid); + LFGQueue& queue = GetQueue(guid); LfgUpdateData updateData = LfgUpdateData(LFG_UPDATETYPE_GROUP_FOUND); - for (LfgProposalPlayerMap::const_iterator it = proposal.players.begin(); it != proposal.players.end(); ++it) + for (LfgProposalPlayerContainer::const_iterator it = proposal.players.begin(); it != proposal.players.end(); ++it) { uint64 pguid = it->first; uint64 gguid = it->second.group; @@ -1168,7 +1171,7 @@ void LFGMgr::UpdateProposal(uint32 proposalId, uint64 guid, bool accept) break; } - m_teleport.push_back(pguid); + teleportStore.push_back(pguid); SetState(pguid, LFG_STATE_DUNGEON); } @@ -1177,7 +1180,7 @@ void LFGMgr::UpdateProposal(uint32 proposalId, uint64 guid, bool accept) queue.RemoveFromQueue(*it); MakeNewGroup(proposal); - m_Proposals.erase(itProposal); + ProposalsStore.erase(itProposal); } /** @@ -1186,7 +1189,7 @@ void LFGMgr::UpdateProposal(uint32 proposalId, uint64 guid, bool accept) @param[in] itProposal Iterator to the proposal to remove @param[in] type Type of removal (LFG_UPDATETYPE_PROPOSAL_FAILED, LFG_UPDATETYPE_PROPOSAL_DECLINED) */ -void LFGMgr::RemoveProposal(LfgProposalMap::iterator itProposal, LfgUpdateType type) +void LFGMgr::RemoveProposal(LfgProposalContainer::iterator itProposal, LfgUpdateType type) { LfgProposal& proposal = itProposal->second; proposal.state = LFG_PROPOSAL_FAILED; @@ -1194,13 +1197,13 @@ void LFGMgr::RemoveProposal(LfgProposalMap::iterator itProposal, LfgUpdateType t sLog->outDebug(LOG_FILTER_LFG, "LFGMgr::RemoveProposal: Proposal %u, state FAILED, UpdateType %u", itProposal->first, type); // Mark all people that didn't answered as no accept if (type == LFG_UPDATETYPE_PROPOSAL_FAILED) - for (LfgProposalPlayerMap::iterator it = proposal.players.begin(); it != proposal.players.end(); ++it) + for (LfgProposalPlayerContainer::iterator it = proposal.players.begin(); it != proposal.players.end(); ++it) if (it->second.accept == LFG_ANSWER_PENDING) it->second.accept = LFG_ANSWER_DENY; // Mark players/groups to be removed LfgGuidSet toRemove; - for (LfgProposalPlayerMap::iterator it = proposal.players.begin(); it != proposal.players.end(); ++it) + for (LfgProposalPlayerContainer::iterator it = proposal.players.begin(); it != proposal.players.end(); ++it) { if (it->second.accept == LFG_ANSWER_AGREE) continue; @@ -1215,7 +1218,7 @@ void LFGMgr::RemoveProposal(LfgProposalMap::iterator itProposal, LfgUpdateType t } // Notify players - for (LfgProposalPlayerMap::const_iterator it = proposal.players.begin(); it != proposal.players.end(); ++it) + for (LfgProposalPlayerContainer::const_iterator it = proposal.players.begin(); it != proposal.players.end(); ++it) { uint64 guid = it->first; uint64 gguid = it->second.group ? it->second.group : guid; @@ -1258,7 +1261,7 @@ void LFGMgr::RemoveProposal(LfgProposalMap::iterator itProposal, LfgUpdateType t } } - LfgQueue& queue = GetQueue(proposal.players.begin()->first); + LFGQueue& queue = GetQueue(proposal.players.begin()->first); // Remove players/groups from queue for (LfgGuidSet::const_iterator it = toRemove.begin(); it != toRemove.end(); ++it) { @@ -1274,7 +1277,7 @@ void LFGMgr::RemoveProposal(LfgProposalMap::iterator itProposal, LfgUpdateType t queue.AddToQueue(guid); } - m_Proposals.erase(itProposal); + ProposalsStore.erase(itProposal); } /** @@ -1289,7 +1292,7 @@ void LFGMgr::InitBoot(uint64 gguid, uint64 kicker, uint64 victim, std::string co { SetState(gguid, LFG_STATE_BOOT); - LfgPlayerBoot& boot = m_Boots[gguid]; + LfgPlayerBoot& boot = BootsStore[gguid]; boot.inProgress = true; boot.cancelTime = time_t(time(NULL)) + LFG_TIME_BOOT; boot.reason = reason; @@ -1325,8 +1328,8 @@ void LFGMgr::UpdateBoot(uint64 guid, bool accept) if (!gguid) return; - LfgPlayerBootMap::iterator itBoot = m_Boots.find(gguid); - if (itBoot == m_Boots.end()) + LfgPlayerBootContainer::iterator itBoot = BootsStore.find(gguid); + if (itBoot == BootsStore.end()) return; LfgPlayerBoot& boot = itBoot->second; @@ -1338,7 +1341,7 @@ void LFGMgr::UpdateBoot(uint64 guid, bool accept) uint8 votesNum = 0; uint8 agreeNum = 0; - for (LfgAnswerMap::const_iterator itVotes = boot.votes.begin(); itVotes != boot.votes.end(); ++itVotes) + for (LfgAnswerContainer::const_iterator itVotes = boot.votes.begin(); itVotes != boot.votes.end(); ++itVotes) { if (itVotes->second != LFG_ANSWER_PENDING) { @@ -1354,7 +1357,7 @@ void LFGMgr::UpdateBoot(uint64 guid, bool accept) // Send update info to all players boot.inProgress = false; - for (LfgAnswerMap::const_iterator itVotes = boot.votes.begin(); itVotes != boot.votes.end(); ++itVotes) + for (LfgAnswerContainer::const_iterator itVotes = boot.votes.begin(); itVotes != boot.votes.end(); ++itVotes) { uint64 pguid = itVotes->first; if (pguid != boot.victim) @@ -1371,7 +1374,7 @@ void LFGMgr::UpdateBoot(uint64 guid, bool accept) Player::RemoveFromGroup(group, boot.victim, GROUP_REMOVEMETHOD_KICK_LFG); DecreaseKicksLeft(gguid); } - m_Boots.erase(itBoot); + BootsStore.erase(itBoot); } /** @@ -1383,26 +1386,36 @@ void LFGMgr::UpdateBoot(uint64 guid, bool accept) */ void LFGMgr::TeleportPlayer(Player* player, bool out, bool fromOpcode /*= false*/) { - sLog->outDebug(LOG_FILTER_LFG, "LFGMgr::TeleportPlayer: [" UI64FMTD "] is being teleported %s", player->GetGUID(), out ? "out" : "in"); + LFGDungeonData const* dungeon = NULL; + Group* group = player->GetGroup(); - Group* grp = player->GetGroup(); - uint64 gguid = grp->GetGUID(); - LFGDungeonData const* dungeon = GetLFGDungeon(GetDungeon(gguid)); - if (!dungeon || (out && player->GetMapId() != uint32(dungeon->map))) + if (group && group->isLFGGroup()) + dungeon = GetLFGDungeon(GetDungeon(group->GetGUID())); + + if (!dungeon) + { + sLog->outDebug(LOG_FILTER_LFG, "TeleportPlayer: Player %s not in group/lfggroup or dungeon not found!", + player->GetName().c_str()); + player->GetSession()->SendLfgTeleportError(uint8(LFG_TELEPORTERROR_INVALID_LOCATION)); return; + } if (out) { - player->RemoveAurasDueToSpell(LFG_SPELL_LUCK_OF_THE_DRAW); - player->TeleportToBGEntryPoint(); + sLog->outDebug(LOG_FILTER_LFG, "TeleportPlayer: Player %s is being teleported out. Current Map %u - Expected Map %u", + player->GetName().c_str(), player->GetMapId(), uint32(dungeon->map)); + if (player->GetMapId() == uint32(dungeon->map)) + { + player->RemoveAurasDueToSpell(LFG_SPELL_LUCK_OF_THE_DRAW); + player->TeleportToBGEntryPoint(); + } + return; } LfgTeleportError error = LFG_TELEPORTERROR_OK; - if (!grp || !grp->isLFGGroup()) // should never happen, but just in case... - error = LFG_TELEPORTERROR_INVALID_LOCATION; - else if (!player->isAlive()) + if (!player->isAlive()) error = LFG_TELEPORTERROR_PLAYER_DEAD; else if (player->IsFalling() || player->HasUnitState(UNIT_STATE_JUMPING)) error = LFG_TELEPORTERROR_FALLING; @@ -1412,57 +1425,56 @@ void LFGMgr::TeleportPlayer(Player* player, bool out, bool fromOpcode /*= false* error = LFG_TELEPORTERROR_IN_VEHICLE; else if (player->GetCharmGUID()) error = LFG_TELEPORTERROR_CHARMING; - else + else if (player->GetMapId() != uint32(dungeon->map)) // Do not teleport players in dungeon to the entrance { - if (!dungeon) - error = LFG_TELEPORTERROR_INVALID_LOCATION; - else if (player->GetMapId() != uint32(dungeon->map)) // Do not teleport players in dungeon to the entrance - { - uint32 mapid = dungeon->map; - float x = dungeon->x; - float y = dungeon->y; - float z = dungeon->z; - float orientation = dungeon->o; + uint32 mapid = dungeon->map; + float x = dungeon->x; + float y = dungeon->y; + float z = dungeon->z; + float orientation = dungeon->o; - if (!fromOpcode) + if (!fromOpcode) + { + // Select a player inside to be teleported to + for (GroupReference* itr = group->GetFirstMember(); itr != NULL && !mapid; itr = itr->next()) { - // Select a player inside to be teleported to - for (GroupReference* itr = grp->GetFirstMember(); itr != NULL && !mapid; itr = itr->next()) + Player* plrg = itr->getSource(); + if (plrg && plrg != player && plrg->GetMapId() == uint32(dungeon->map)) { - Player* plrg = itr->getSource(); - if (plrg && plrg != player && plrg->GetMapId() == uint32(dungeon->map)) - { - mapid = plrg->GetMapId(); - x = plrg->GetPositionX(); - y = plrg->GetPositionY(); - z = plrg->GetPositionZ(); - orientation = plrg->GetOrientation(); - } + mapid = plrg->GetMapId(); + x = plrg->GetPositionX(); + y = plrg->GetPositionY(); + z = plrg->GetPositionZ(); + orientation = plrg->GetOrientation(); + break; } } + } - if (error == LFG_TELEPORTERROR_OK) - { - if (!player->GetMap()->IsDungeon()) - player->SetBattlegroundEntryPoint(); + if (error == LFG_TELEPORTERROR_OK) + { + if (!player->GetMap()->IsDungeon()) + player->SetBattlegroundEntryPoint(); - if (player->isInFlight()) - { - player->GetMotionMaster()->MovementExpired(); - player->CleanupAfterTaxiFlight(); - } + if (player->isInFlight()) + { + player->GetMotionMaster()->MovementExpired(); + player->CleanupAfterTaxiFlight(); + } - if (!player->TeleportTo(mapid, x, y, z, orientation)) - { - error = LFG_TELEPORTERROR_INVALID_LOCATION; - sLog->outError(LOG_FILTER_LFG, "LfgMgr::TeleportPlayer: Failed to teleport [" UI64FMTD "] to map %u: ", player->GetGUID(), mapid); - } + if (!player->TeleportTo(mapid, x, y, z, orientation)) + { + error = LFG_TELEPORTERROR_INVALID_LOCATION; + sLog->outError(LOG_FILTER_LFG, "TeleportPlayer: Failed to teleport [" UI64FMTD "] to map %u (x: %f, y: %f, z: %f)", player->GetGUID(), mapid, x, y, z); } } } if (error != LFG_TELEPORTERROR_OK) player->GetSession()->SendLfgTeleportError(uint8(error)); + + sLog->outDebug(LOG_FILTER_LFG, "TeleportPlayer: Player %s is being teleported in. Result: %u", + player->GetName().c_str(), error); } /** @@ -1556,7 +1568,7 @@ const LfgDungeonSet& LFGMgr::GetDungeonsByRandom(uint32 randomdungeon) { LFGDungeonData const* dungeon = GetLFGDungeon(randomdungeon); uint32 group = dungeon ? dungeon->group : 0; - return m_CachedDungeonMap[group]; + return CachedDungeonMapStore[group]; } /** @@ -1569,8 +1581,8 @@ const LfgDungeonSet& LFGMgr::GetDungeonsByRandom(uint32 randomdungeon) LfgReward const* LFGMgr::GetRandomDungeonReward(uint32 dungeon, uint8 level) { LfgReward const* rew = NULL; - LfgRewardMapBounds bounds = m_RewardMap.equal_range(dungeon & 0x00FFFFFF); - for (LfgRewardMap::const_iterator itr = bounds.first; itr != bounds.second; ++itr) + LfgRewardContainerBounds bounds = RewardMapStore.equal_range(dungeon & 0x00FFFFFF); + for (LfgRewardContainer::const_iterator itr = bounds.first; itr != bounds.second; ++itr) { rew = itr->second; // ordered properly at loading @@ -1600,9 +1612,9 @@ LfgState LFGMgr::GetState(uint64 guid) { LfgState state; if (IS_GROUP(guid)) - state = m_Groups[guid].GetState(); + state = GroupsStore[guid].GetState(); else - state = m_Players[guid].GetState(); + state = PlayersStore[guid].GetState(); sLog->outDebug(LOG_FILTER_LFG, "LFGMgr::GetState: [" UI64FMTD "] = %u", guid, state); return state; @@ -1610,29 +1622,41 @@ LfgState LFGMgr::GetState(uint64 guid) uint32 LFGMgr::GetDungeon(uint64 guid, bool asId /*= true */) { - uint32 dungeon = m_Groups[guid].GetDungeon(asId); + uint32 dungeon = GroupsStore[guid].GetDungeon(asId); sLog->outDebug(LOG_FILTER_LFG, "LFGMgr::GetDungeon: [" UI64FMTD "] asId: %u = %u", guid, asId, dungeon); return dungeon; } +uint32 LFGMgr::GetDungeonMapId(uint64 guid) +{ + uint32 dungeonId = GroupsStore[guid].GetDungeon(true); + uint32 mapId = 0; + if (dungeonId) + if (LFGDungeonData const* dungeon = GetLFGDungeon(dungeonId)) + mapId = dungeon->map; + + sLog->outDebug(LOG_FILTER_LFG, "LFGMgr::GetDungeonMapId: [" UI64FMTD "] = %u (DungeonId = %u)", guid, mapId, dungeonId); + return mapId; +} + uint8 LFGMgr::GetRoles(uint64 guid) { - uint8 roles = m_Players[guid].GetRoles(); + uint8 roles = PlayersStore[guid].GetRoles(); sLog->outDebug(LOG_FILTER_LFG, "LFGMgr::GetRoles: [" UI64FMTD "] = %u", guid, roles); return roles; } const std::string& LFGMgr::GetComment(uint64 guid) { - sLog->outDebug(LOG_FILTER_LFG, "LFGMgr::GetComment: [" UI64FMTD "] = %s", guid, m_Players[guid].GetComment().c_str()); - return m_Players[guid].GetComment(); + sLog->outDebug(LOG_FILTER_LFG, "LFGMgr::GetComment: [" UI64FMTD "] = %s", guid, PlayersStore[guid].GetComment().c_str()); + return PlayersStore[guid].GetComment(); } bool LFGMgr::IsTeleported(uint64 pguid) { - if (std::find(m_teleport.begin(), m_teleport.end(), pguid) != m_teleport.end()) + if (std::find(teleportStore.begin(), teleportStore.end(), pguid) != teleportStore.end()) { - m_teleport.remove(pguid); + teleportStore.remove(pguid); return true; } return false; @@ -1641,37 +1665,46 @@ bool LFGMgr::IsTeleported(uint64 pguid) const LfgDungeonSet& LFGMgr::GetSelectedDungeons(uint64 guid) { sLog->outDebug(LOG_FILTER_LFG, "LFGMgr::GetSelectedDungeons: [" UI64FMTD "]", guid); - return m_Players[guid].GetSelectedDungeons(); + return PlayersStore[guid].GetSelectedDungeons(); } const LfgLockMap& LFGMgr::GetLockedDungeons(uint64 guid) { sLog->outDebug(LOG_FILTER_LFG, "LFGMgr::GetLockedDungeons: [" UI64FMTD "]", guid); - return m_Players[guid].GetLockedDungeons(); + return PlayersStore[guid].GetLockedDungeons(); } uint8 LFGMgr::GetKicksLeft(uint64 guid) { - uint8 kicks = m_Groups[guid].GetKicksLeft(); + uint8 kicks = GroupsStore[guid].GetKicksLeft(); sLog->outDebug(LOG_FILTER_LFG, "LFGMgr::GetKicksLeft: [" UI64FMTD "] = %u", guid, kicks); return kicks; } void LFGMgr::RestoreState(uint64 guid, char const *debugMsg) { - LfgGroupData& data = m_Groups[guid]; - char const * const ps = GetStateString(data.GetState()); - char const * const os = GetStateString(data.GetOldState()); - sLog->outDebug(LOG_FILTER_LFG, "LFGMgr::RestoreState: Group: [" UI64FMTD "] (%s), State: %s, oldState: %s", guid, debugMsg, ps, os); + LfgGroupData& data = GroupsStore[guid]; + if (sLog->ShouldLog(LOG_FILTER_LFG, LOG_LEVEL_DEBUG)) + { + std::string const& ps = GetStateString(data.GetState()); + std::string const& os = GetStateString(data.GetOldState()); + sLog->outDebug(LOG_FILTER_LFG, "LFGMgr::RestoreState: Group: [" UI64FMTD "] (%s) State: %s, oldState: %s", + guid, debugMsg, ps.c_str(), os.c_str()); + } + data.RestoreState(); } void LFGMgr::ClearState(uint64 guid, char const *debugMsg) { - LfgPlayerData& data = m_Players[guid]; - char const * const ps = GetStateString(data.GetState()); - char const * const os = GetStateString(data.GetOldState()); - sLog->outDebug(LOG_FILTER_LFG, "LFGMgr::ClearState: Player: [" UI64FMTD "] (%s) State: %s, oldState: %s", guid, debugMsg, ps, os); + LfgPlayerData& data = PlayersStore[guid]; + if (sLog->ShouldLog(LOG_FILTER_LFG, LOG_LEVEL_DEBUG)) + { + std::string const& ps = GetStateString(data.GetState()); + std::string const& os = GetStateString(data.GetOldState()); + sLog->outDebug(LOG_FILTER_LFG, "LFGMgr::ClearState: Player: [" UI64FMTD "] (%s) State: %s, oldState: %s", + guid, debugMsg, ps.c_str(), os.c_str()); + } data.ClearState(); } @@ -1679,20 +1712,28 @@ void LFGMgr::SetState(uint64 guid, LfgState state) { if (IS_GROUP(guid)) { - LfgGroupData& data = m_Groups[guid]; - char const * const ns = GetStateString(state); - char const * const ps = GetStateString(data.GetState()); - char const * const os = GetStateString(data.GetOldState()); - sLog->outDebug(LOG_FILTER_LFG, "LFGMgr::SetState: Group: [" UI64FMTD "] newState: %s, previous: %s, oldState: %s", guid, ns, ps, os); + LfgGroupData& data = GroupsStore[guid]; + if (sLog->ShouldLog(LOG_FILTER_LFG, LOG_LEVEL_DEBUG)) + { + std::string const& ns = GetStateString(state); + std::string const& ps = GetStateString(data.GetState()); + std::string const& os = GetStateString(data.GetOldState()); + sLog->outDebug(LOG_FILTER_LFG, "LFGMgr::SetState: Group: [" UI64FMTD "] newState: %s, previous: %s, oldState: %s", + guid, ns.c_str(), ps.c_str(), os.c_str()); + } data.SetState(state); } else { - LfgPlayerData& data = m_Players[guid]; - char const * const ns = GetStateString(state); - char const * const ps = GetStateString(data.GetState()); - char const * const os = GetStateString(data.GetOldState()); - sLog->outDebug(LOG_FILTER_LFG, "LFGMgr::SetState: Player: [" UI64FMTD "] newState: %s, previous: %s, oldState: %s", guid, ns, ps, os); + LfgPlayerData& data = PlayersStore[guid]; + if (sLog->ShouldLog(LOG_FILTER_LFG, LOG_LEVEL_DEBUG)) + { + std::string const& ns = GetStateString(state); + std::string const& ps = GetStateString(data.GetState()); + std::string const& os = GetStateString(data.GetOldState()); + sLog->outDebug(LOG_FILTER_LFG, "LFGMgr::SetState: Player: [" UI64FMTD "] newState: %s, previous: %s, oldState: %s", + guid, ns.c_str(), ps.c_str(), os.c_str()); + } data.SetState(state); } } @@ -1700,73 +1741,83 @@ void LFGMgr::SetState(uint64 guid, LfgState state) void LFGMgr::SetDungeon(uint64 guid, uint32 dungeon) { sLog->outDebug(LOG_FILTER_LFG, "LFGMgr::SetDungeon: [" UI64FMTD "] dungeon %u", guid, dungeon); - m_Groups[guid].SetDungeon(dungeon); + GroupsStore[guid].SetDungeon(dungeon); } void LFGMgr::SetRoles(uint64 guid, uint8 roles) { sLog->outDebug(LOG_FILTER_LFG, "LFGMgr::SetRoles: [" UI64FMTD "] roles: %u", guid, roles); - m_Players[guid].SetRoles(roles); + PlayersStore[guid].SetRoles(roles); } void LFGMgr::SetComment(uint64 guid, const std::string& comment) { sLog->outDebug(LOG_FILTER_LFG, "LFGMgr::SetComment: [" UI64FMTD "] comment: %s", guid, comment.c_str()); - m_Players[guid].SetComment(comment); + PlayersStore[guid].SetComment(comment); } void LFGMgr::SetSelectedDungeons(uint64 guid, const LfgDungeonSet& dungeons) { sLog->outDebug(LOG_FILTER_LFG, "LFGMgr::SetSelectedDungeons: [" UI64FMTD "]", guid); - m_Players[guid].SetSelectedDungeons(dungeons); + PlayersStore[guid].SetSelectedDungeons(dungeons); } void LFGMgr::SetLockedDungeons(uint64 guid, const LfgLockMap& lock) { sLog->outDebug(LOG_FILTER_LFG, "LFGMgr::SetLockedDungeons: [" UI64FMTD "]", guid); - m_Players[guid].SetLockedDungeons(lock); + PlayersStore[guid].SetLockedDungeons(lock); } void LFGMgr::DecreaseKicksLeft(uint64 guid) { sLog->outDebug(LOG_FILTER_LFG, "LFGMgr::DecreaseKicksLeft: [" UI64FMTD "]", guid); - m_Groups[guid].DecreaseKicksLeft(); + GroupsStore[guid].DecreaseKicksLeft(); } void LFGMgr::RemovePlayerData(uint64 guid) { sLog->outDebug(LOG_FILTER_LFG, "LFGMgr::RemovePlayerData: [" UI64FMTD "]", guid); - LfgPlayerDataMap::iterator it = m_Players.find(guid); - if (it != m_Players.end()) - m_Players.erase(it); + LfgPlayerDataContainer::iterator it = PlayersStore.find(guid); + if (it != PlayersStore.end()) + PlayersStore.erase(it); } void LFGMgr::RemoveGroupData(uint64 guid) { sLog->outDebug(LOG_FILTER_LFG, "LFGMgr::RemoveGroupData: [" UI64FMTD "]", guid); - LfgGroupDataMap::iterator it = m_Groups.find(guid); - if (it != m_Groups.end()) - m_Groups.erase(it); + LfgGroupDataContainer::iterator it = GroupsStore.find(guid); + if (it == GroupsStore.end()) + return; + + LfgGuidSet const& players = it->second.GetPlayers(); + for (LfgGuidSet::const_iterator it = players.begin(); it != players.end(); ++it) + { + uint64 guid = (*it); + ClearState(*it, "Group Disband"); + SetGroup(*it, 0); + SendLfgUpdateParty(guid, LfgUpdateData(LFG_UPDATETYPE_REMOVED_FROM_QUEUE)); + } + GroupsStore.erase(it); } uint8 LFGMgr::GetTeam(uint64 guid) { - return m_Players[guid].GetTeam(); + return PlayersStore[guid].GetTeam(); } uint8 LFGMgr::RemovePlayerFromGroup(uint64 gguid, uint64 guid) { - return m_Groups[gguid].RemovePlayer(guid); + return GroupsStore[gguid].RemovePlayer(guid); } void LFGMgr::AddPlayerToGroup(uint64 gguid, uint64 guid) { - m_Groups[gguid].AddPlayer(guid); + GroupsStore[gguid].AddPlayer(guid); } void LFGMgr::SetLeader(uint64 gguid, uint64 leader) { - m_Groups[gguid].SetLeader(leader); + GroupsStore[gguid].SetLeader(leader); } void LFGMgr::SetTeam(uint64 guid, uint8 team) @@ -1774,27 +1825,32 @@ void LFGMgr::SetTeam(uint64 guid, uint8 team) if (sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_GROUP)) team = 0; - m_Players[guid].SetTeam(team); + PlayersStore[guid].SetTeam(team); } uint64 LFGMgr::GetGroup(uint64 guid) { - return m_Players[guid].GetGroup(); + return PlayersStore[guid].GetGroup(); } void LFGMgr::SetGroup(uint64 guid, uint64 group) { - m_Players[guid].SetGroup(group); + PlayersStore[guid].SetGroup(group); +} + +LfgGuidSet const& LFGMgr::GetPlayers(uint64 guid) +{ + return GroupsStore[guid].GetPlayers(); } -const LfgGuidSet& LFGMgr::GetPlayers(uint64 guid) +uint8 LFGMgr::GetPlayerCount(uint64 guid) { - return m_Groups[guid].GetPlayers(); + return GroupsStore[guid].GetPlayerCount(); } uint64 LFGMgr::GetLeader(uint64 guid) { - return m_Groups[guid].GetLeader(); + return GroupsStore[guid].GetLeader(); } bool LFGMgr::HasIgnore(uint64 guid1, uint64 guid2) @@ -1812,43 +1868,43 @@ void LFGMgr::SendLfgRoleChosen(uint64 guid, uint64 pguid, uint8 roles) player->GetSession()->SendLfgRoleChosen(pguid, roles); } -void LFGMgr::SendLfgRoleCheckUpdate(uint64 guid, const LfgRoleCheck& roleCheck) +void LFGMgr::SendLfgRoleCheckUpdate(uint64 guid, LfgRoleCheck const& roleCheck) { if (Player* player = ObjectAccessor::FindPlayer(guid)) player->GetSession()->SendLfgRoleCheckUpdate(roleCheck); } -void LFGMgr::SendLfgUpdatePlayer(uint64 guid, const LfgUpdateData& data) +void LFGMgr::SendLfgUpdatePlayer(uint64 guid, LfgUpdateData const& data) { if (Player* player = ObjectAccessor::FindPlayer(guid)) player->GetSession()->SendLfgUpdatePlayer(data); } -void LFGMgr::SendLfgUpdateParty(uint64 guid, const LfgUpdateData& data) +void LFGMgr::SendLfgUpdateParty(uint64 guid, LfgUpdateData const& data) { if (Player* player = ObjectAccessor::FindPlayer(guid)) player->GetSession()->SendLfgUpdateParty(data); } -void LFGMgr::SendLfgJoinResult(uint64 guid, const LfgJoinResultData& data) +void LFGMgr::SendLfgJoinResult(uint64 guid, LfgJoinResultData const& data) { if (Player* player = ObjectAccessor::FindPlayer(guid)) player->GetSession()->SendLfgJoinResult(data); } -void LFGMgr::SendLfgBootProposalUpdate(uint64 guid, const LfgPlayerBoot& boot) +void LFGMgr::SendLfgBootProposalUpdate(uint64 guid, LfgPlayerBoot const& boot) { if (Player* player = ObjectAccessor::FindPlayer(guid)) player->GetSession()->SendLfgBootProposalUpdate(boot); } -void LFGMgr::SendLfgUpdateProposal(uint64 guid, uint32 proposalId, const LfgProposal& proposal) +void LFGMgr::SendLfgUpdateProposal(uint64 guid, uint32 proposalId, LfgProposal const& proposal) { if (Player* player = ObjectAccessor::FindPlayer(guid)) player->GetSession()->SendLfgUpdateProposal(proposalId, proposal); } -void LFGMgr::SendLfgQueueStatus(uint64 guid, const LfgQueueStatusData& data) +void LFGMgr::SendLfgQueueStatus(uint64 guid, LfgQueueStatusData const& data) { if (Player* player = ObjectAccessor::FindPlayer(guid)) player->GetSession()->SendLfgQueueStatus(data); @@ -1856,10 +1912,10 @@ void LFGMgr::SendLfgQueueStatus(uint64 guid, const LfgQueueStatusData& data) bool LFGMgr::IsLfgGroup(uint64 guid) { - return guid && IS_GROUP(guid) && m_Groups[guid].IsLfgGroup(); + return guid && IS_GROUP(guid) && GroupsStore[guid].IsLfgGroup(); } -LfgQueue& LFGMgr::GetQueue(uint64 guid) +LFGQueue& LFGMgr::GetQueue(uint64 guid) { uint8 queueId = 0; if (IS_GROUP(guid)) @@ -1871,10 +1927,10 @@ LfgQueue& LFGMgr::GetQueue(uint64 guid) } else queueId = GetTeam(guid); - return m_Queues[queueId]; + return QueuesStore[queueId]; } -bool LFGMgr::AllQueued(const LfgGuidList& check) +bool LFGMgr::AllQueued(LfgGuidList const& check) { if (check.empty()) return false; @@ -1885,6 +1941,34 @@ bool LFGMgr::AllQueued(const LfgGuidList& check) return true; } +// Only for debugging purposes +void LFGMgr::Clean() +{ + QueuesStore.clear(); +} + +bool LFGMgr::isOptionEnabled(uint32 option) +{ + return m_options & option; +} + +uint32 LFGMgr::GetOptions() +{ + return m_options; +} + +void LFGMgr::SetOptions(uint32 options) +{ + m_options = options; +} + +LfgState LFGMgr::GetLfgStatus(uint64 guid, LfgUpdateData& data) +{ + LfgPlayerData& playerData = PlayersStore[guid]; + data.dungeons = playerData.GetSelectedDungeons(); + return playerData.GetState(); +} + bool LFGMgr::IsSeasonActive(uint32 dungeonId) { switch (dungeonId) @@ -1900,3 +1984,29 @@ bool LFGMgr::IsSeasonActive(uint32 dungeonId) } return false; } + +std::string LFGMgr::DumpQueueInfo(bool full) +{ + uint32 size = uint32(QueuesStore.size()); + std::ostringstream o; + + o << "Number of Queues: " << size << "\n"; + for (LfgQueueContainer::const_iterator itr = QueuesStore.begin(); itr != QueuesStore.end(); ++itr) + { + std::string const& queued = itr->second.DumpQueueInfo(); + std::string const& compatibles = itr->second.DumpCompatibleInfo(full); + o << queued << compatibles; + } + + return o.str(); +} + +void LFGMgr::SetupGroupMember(uint64 guid, uint64 gguid) +{ + LfgDungeonSet dungeons; + dungeons.insert(GetDungeon(gguid)); + SetSelectedDungeons(guid, dungeons); + SetState(guid, GetState(gguid)); + SetGroup(guid, gguid); + AddPlayerToGroup(gguid, guid); +} diff --git a/src/server/game/DungeonFinding/LFGMgr.h b/src/server/game/DungeonFinding/LFGMgr.h index 286e82386a7..ba1cc251278 100755 --- a/src/server/game/DungeonFinding/LFGMgr.h +++ b/src/server/game/DungeonFinding/LFGMgr.h @@ -28,6 +28,12 @@ class Group; class Player; +enum LfgOptions +{ + LFG_OPTION_ENABLE_DUNGEON_FINDER = 0x01, + LFG_OPTION_ENABLE_RAID_BROWSER = 0x02, +}; + enum LFGMgrEnum { LFG_TIME_ROLECHECK = 40 * IN_MILLISECONDS, @@ -123,18 +129,18 @@ struct LfgProposal; struct LfgProposalPlayer; struct LfgPlayerBoot; -typedef std::map<uint8, LfgQueue> LfgQueueMap; -typedef std::multimap<uint32, LfgReward const*> LfgRewardMap; -typedef std::pair<LfgRewardMap::const_iterator, LfgRewardMap::const_iterator> LfgRewardMapBounds; -typedef std::map<uint8, LfgDungeonSet> LfgCachedDungeonMap; -typedef std::map<uint64, LfgAnswer> LfgAnswerMap; -typedef std::map<uint64, LfgRoleCheck> LfgRoleCheckMap; -typedef std::map<uint32, LfgProposal> LfgProposalMap; -typedef std::map<uint64, LfgProposalPlayer> LfgProposalPlayerMap; -typedef std::map<uint64, LfgPlayerBoot> LfgPlayerBootMap; -typedef std::map<uint64, LfgGroupData> LfgGroupDataMap; -typedef std::map<uint64, LfgPlayerData> LfgPlayerDataMap; -typedef UNORDERED_MAP<uint32, LFGDungeonData> LFGDungeonMap; +typedef std::map<uint8, LFGQueue> LfgQueueContainer; +typedef std::multimap<uint32, LfgReward const*> LfgRewardContainer; +typedef std::pair<LfgRewardContainer::const_iterator, LfgRewardContainer::const_iterator> LfgRewardContainerBounds; +typedef std::map<uint8, LfgDungeonSet> LfgCachedDungeonContainer; +typedef std::map<uint64, LfgAnswer> LfgAnswerContainer; +typedef std::map<uint64, LfgRoleCheck> LfgRoleCheckContainer; +typedef std::map<uint32, LfgProposal> LfgProposalContainer; +typedef std::map<uint64, LfgProposalPlayer> LfgProposalPlayerContainer; +typedef std::map<uint64, LfgPlayerBoot> LfgPlayerBootContainer; +typedef std::map<uint64, LfgGroupData> LfgGroupDataContainer; +typedef std::map<uint64, LfgPlayerData> LfgPlayerDataContainer; +typedef UNORDERED_MAP<uint32, LFGDungeonData> LFGDungeonContainer; // Data needed by SMSG_LFG_JOIN_RESULT struct LfgJoinResultData @@ -150,7 +156,7 @@ struct LfgJoinResultData struct LfgUpdateData { LfgUpdateData(LfgUpdateType _type = LFG_UPDATETYPE_DEFAULT): updateType(_type), comment("") {} - LfgUpdateData(LfgUpdateType _type, LfgDungeonSet const& _dungeons, std::string _comment): + LfgUpdateData(LfgUpdateType _type, LfgDungeonSet const& _dungeons, std::string const& _comment): updateType(_type), dungeons(_dungeons), comment(_comment) {} LfgUpdateType updateType; @@ -225,7 +231,7 @@ struct LfgProposal uint32 encounters; ///< Dungeon Encounters bool isNew; ///< Determines if it's new group or not LfgGuidList queues; ///< Queue Ids to remove/readd - LfgProposalPlayerMap players; ///< Players data + LfgProposalPlayerContainer players; ///< Players data }; /// Stores all rolecheck info of a group that wants to join @@ -244,7 +250,7 @@ struct LfgPlayerBoot { time_t cancelTime; ///< Time left to vote bool inProgress; ///< Vote in progress - LfgAnswerMap votes; ///< Player votes (-1 not answer | 0 Not agree | 1 agree) + LfgAnswerContainer votes; ///< Player votes (-1 not answer | 0 Not agree | 1 agree) uint64 victim; ///< Player guid to be kicked (can't vote) std::string reason; ///< kick reason }; @@ -322,7 +328,6 @@ class LFGMgr void SetGroup(uint64 guid, uint64 group); void SetLeader(uint64 gguid, uint64 leader); void SetState(uint64 guid, LfgState state); - void SetSelectedDungeons(uint64 guid, LfgDungeonSet const& dungeons); void _LoadFromDB(Field* fields, uint64 guid); void _SaveToDB(uint64 guid, uint32 db_guid); @@ -335,6 +340,7 @@ class LFGMgr LfgLockMap const& GetLockedDungeons(uint64 guid); LfgDungeonSet const& GetSelectedDungeons(uint64 guid); uint32 GetDungeon(uint64 guid, bool asId = true); + uint32 GetDungeonMapId(uint64 guid); LfgState GetState(uint64 guid); uint8 GetKicksLeft(uint64 gguid); uint64 GetLeader(uint64 guid); @@ -342,40 +348,48 @@ class LFGMgr uint8 GetRoles(uint64 guid); std::string const& GetComment(uint64 gguid); LfgGuidSet const& GetPlayers(uint64 guid); + uint8 GetPlayerCount(uint64 guid); bool IsTeleported(uint64 guid); bool AllQueued(LfgGuidList const& check); + void Clean(); + static bool HasIgnore(uint64 guid1, uint64 guid2); static void SendLfgQueueStatus(uint64 guid, LfgQueueStatusData const& data); + bool isOptionEnabled(uint32 option); + uint32 GetOptions(); + void SetOptions(uint32 options); + LfgState GetLfgStatus(uint64 guid, LfgUpdateData& data); bool IsSeasonActive(uint32 dungeonId); + std::string DumpQueueInfo(bool full = false); static std::string ConcatenateDungeons(LfgDungeonSet const& dungeons); static std::string GetRolesString(uint8 roles); - static char const * GetStateString(LfgState state); + static std::string GetStateString(LfgState state); void LoadLFGDungeons(bool reload = false); LFGDungeonData const* GetLFGDungeon(uint32 id); - LFGDungeonMap& GetLFGDungeonMap(); + LFGDungeonContainer& GetLFGDungeonMap(); + void SetupGroupMember(uint64 guid, uint64 gguid); + uint64 GetGroup(uint64 guid); - void ClearState(uint64 guid, char const *debugMsg); private: - uint8 GetTeam(uint64 guid); - uint64 GetGroup(uint64 guid); void RestoreState(uint64 guid, char const *debugMsg); - + void ClearState(uint64 guid, char const *debugMsg); void SetDungeon(uint64 guid, uint32 dungeon); + void SetSelectedDungeons(uint64 guid, LfgDungeonSet const& dungeons); void SetLockedDungeons(uint64 guid, LfgLockMap const& lock); void DecreaseKicksLeft(uint64 guid); // Proposals - void RemoveProposal(LfgProposalMap::iterator itProposal, LfgUpdateType type); + void RemoveProposal(LfgProposalContainer::iterator itProposal, LfgUpdateType type); void MakeNewGroup(LfgProposal const& proposal); // Generic - LfgQueue &GetQueue(uint64 guid); + LFGQueue &GetQueue(uint64 guid); LfgDungeonSet const& GetDungeonsByRandom(uint32 randomdungeon); LfgType GetDungeonType(uint32 dungeon); @@ -392,18 +406,18 @@ class LFGMgr uint32 m_lfgProposalId; ///< used as internal counter for proposals uint32 m_options; ///< Stores config options - LfgQueueMap m_Queues; ///< Queues - LfgCachedDungeonMap m_CachedDungeonMap; ///< Stores all dungeons by groupType + LfgQueueContainer QueuesStore; ///< Queues + LfgCachedDungeonContainer CachedDungeonMapStore; ///< Stores all dungeons by groupType // Reward System - LfgRewardMap m_RewardMap; ///< Stores rewards for random dungeons - LFGDungeonMap m_LfgDungeonMap; + LfgRewardContainer RewardMapStore; ///< Stores rewards for random dungeons + LFGDungeonContainer LfgDungeonStore; // Rolecheck - Proposal - Vote Kicks - LfgRoleCheckMap m_RoleChecks; ///< Current Role checks - LfgProposalMap m_Proposals; ///< Current Proposals - LfgPlayerBootMap m_Boots; ///< Current player kicks - LfgPlayerDataMap m_Players; ///< Player data - LfgGroupDataMap m_Groups; ///< Group data - LfgGuidList m_teleport; ///< Players being teleported + LfgRoleCheckContainer RoleChecksStore; ///< Current Role checks + LfgProposalContainer ProposalsStore; ///< Current Proposals + LfgPlayerBootContainer BootsStore; ///< Current player kicks + LfgPlayerDataContainer PlayersStore; ///< Player data + LfgGroupDataContainer GroupsStore; ///< Group data + LfgGuidList teleportStore; ///< Players being teleported }; #define sLFGMgr ACE_Singleton<LFGMgr, ACE_Null_Mutex>::instance() diff --git a/src/server/game/DungeonFinding/LFGQueue.cpp b/src/server/game/DungeonFinding/LFGQueue.cpp index c1d89a16300..cf600b0645f 100644 --- a/src/server/game/DungeonFinding/LFGQueue.cpp +++ b/src/server/game/DungeonFinding/LFGQueue.cpp @@ -25,6 +25,7 @@ #include "Log.h" #include "ObjectMgr.h" #include "World.h" +#include "GroupMgr.h" /** Given a list of guids returns the concatenation using | as delimiter @@ -50,7 +51,7 @@ std::string ConcatenateGuids(LfgGuidList const& check) return o.str(); } -char const * GetCompatibleString(LfgCompatibility compatibles) +char const* GetCompatibleString(LfgCompatibility compatibles) { switch (compatibles) { @@ -79,83 +80,102 @@ char const * GetCompatibleString(LfgCompatibility compatibles) } } -void LfgQueue::AddToQueue(uint64 guid) +void LFGQueue::AddToQueue(uint64 guid) { - LfgQueueDataMap::iterator itQueue = m_QueueDataMap.find(guid); - if (itQueue == m_QueueDataMap.end()) + LfgQueueDataContainer::iterator itQueue = QueueDataStore.find(guid); + if (itQueue == QueueDataStore.end()) { - sLog->outError(LOG_FILTER_LFG, "LfgQueue::AddToQueue: Queue data not found for [" UI64FMTD "]", guid); + sLog->outError(LOG_FILTER_LFG, "LFGQueue::AddToQueue: Queue data not found for [" UI64FMTD "]", guid); return; } AddToNewQueue(guid); } -void LfgQueue::RemoveFromQueue(uint64 guid) +void LFGQueue::RemoveFromQueue(uint64 guid) { RemoveFromNewQueue(guid); RemoveFromCurrentQueue(guid); RemoveFromCompatibles(guid); - RemoveQueueData(guid); + + std::ostringstream o; + o << guid; + std::string sguid = o.str(); + + LfgQueueDataContainer::iterator itDelete = QueueDataStore.end(); + for (LfgQueueDataContainer::iterator itr = QueueDataStore.begin(); itr != QueueDataStore.end(); ++itr) + if (itr->first != guid) + { + if (std::string::npos != itr->second.bestCompatible.find(sguid)) + { + itr->second.bestCompatible.clear(); + FindBestCompatibleInQueue(itr); + } + } + else + itDelete = itr; + + if (itDelete != QueueDataStore.end()) + QueueDataStore.erase(itDelete); } -void LfgQueue::AddToNewQueue(uint64 guid) +void LFGQueue::AddToNewQueue(uint64 guid) { - m_newToQueue.push_back(guid); + newToQueueStore.push_back(guid); } -void LfgQueue::RemoveFromNewQueue(uint64 guid) +void LFGQueue::RemoveFromNewQueue(uint64 guid) { - m_newToQueue.remove(guid); + newToQueueStore.remove(guid); } -void LfgQueue::AddToCurrentQueue(uint64 guid) +void LFGQueue::AddToCurrentQueue(uint64 guid) { - m_currentQueue.push_back(guid); + currentQueueStore.push_back(guid); } -void LfgQueue::RemoveFromCurrentQueue(uint64 guid) +void LFGQueue::RemoveFromCurrentQueue(uint64 guid) { - m_currentQueue.remove(guid); + currentQueueStore.remove(guid); } -void LfgQueue::AddQueueData(uint64 guid, time_t joinTime, const LfgDungeonSet &dungeons, const LfgRolesMap &rolesMap) +void LFGQueue::AddQueueData(uint64 guid, time_t joinTime, const LfgDungeonSet &dungeons, const LfgRolesMap &rolesMap) { - m_QueueDataMap[guid] = LfgQueueData(joinTime, dungeons, rolesMap); + QueueDataStore[guid] = LfgQueueData(joinTime, dungeons, rolesMap); AddToQueue(guid); } -void LfgQueue::RemoveQueueData(uint64 guid) +void LFGQueue::RemoveQueueData(uint64 guid) { - LfgQueueDataMap::iterator it = m_QueueDataMap.find(guid); - if (it != m_QueueDataMap.end()) - m_QueueDataMap.erase(it); + LfgQueueDataContainer::iterator it = QueueDataStore.find(guid); + if (it != QueueDataStore.end()) + QueueDataStore.erase(it); } -void LfgQueue::UpdateWaitTimeAvg(int32 waitTime, uint32 dungeonId) +void LFGQueue::UpdateWaitTimeAvg(int32 waitTime, uint32 dungeonId) { - LfgWaitTime &wt = m_waitTimesAvg[dungeonId]; + LfgWaitTime &wt = waitTimesAvgStore[dungeonId]; uint32 old_number = wt.number++; wt.time = int32((wt.time * old_number + waitTime) / wt.number); } -void LfgQueue::UpdateWaitTimeTank(int32 waitTime, uint32 dungeonId) +void LFGQueue::UpdateWaitTimeTank(int32 waitTime, uint32 dungeonId) { - LfgWaitTime &wt = m_waitTimesTank[dungeonId]; + LfgWaitTime &wt = waitTimesTankStore[dungeonId]; uint32 old_number = wt.number++; wt.time = int32((wt.time * old_number + waitTime) / wt.number); } -void LfgQueue::UpdateWaitTimeHealer(int32 waitTime, uint32 dungeonId) +void LFGQueue::UpdateWaitTimeHealer(int32 waitTime, uint32 dungeonId) { - LfgWaitTime &wt = m_waitTimesHealer[dungeonId]; + LfgWaitTime &wt = waitTimesHealerStore[dungeonId]; uint32 old_number = wt.number++; wt.time = int32((wt.time * old_number + waitTime) / wt.number); } -void LfgQueue::UpdateWaitTimeDps(int32 waitTime, uint32 dungeonId) +void LFGQueue::UpdateWaitTimeDps(int32 waitTime, uint32 dungeonId) { - LfgWaitTime &wt = m_waitTimesDps[dungeonId]; + LfgWaitTime &wt = waitTimesDpsStore[dungeonId]; uint32 old_number = wt.number++; wt.time = int32((wt.time * old_number + waitTime) / wt.number); } @@ -165,61 +185,76 @@ void LfgQueue::UpdateWaitTimeDps(int32 waitTime, uint32 dungeonId) @param[in] guid Guid to remove from compatible cache */ -void LfgQueue::RemoveFromCompatibles(uint64 guid) +void LFGQueue::RemoveFromCompatibles(uint64 guid) { std::stringstream out; out << guid; std::string strGuid = out.str(); - sLog->outDebug(LOG_FILTER_LFG, "LfgQueue::RemoveFromCompatibles: Removing [" UI64FMTD "]", guid); - for (LfgCompatibleMap::iterator itNext = m_CompatibleMap.begin(); itNext != m_CompatibleMap.end();) + sLog->outDebug(LOG_FILTER_LFG, "LFGQueue::RemoveFromCompatibles: Removing [" UI64FMTD "]", guid); + for (LfgCompatibleContainer::iterator itNext = CompatibleMapStore.begin(); itNext != CompatibleMapStore.end();) { - LfgCompatibleMap::iterator it = itNext++; - if (it->first.find(strGuid) != std::string::npos) // Found, remove it - m_CompatibleMap.erase(it); + LfgCompatibleContainer::iterator it = itNext++; + if (std::string::npos != it->first.find(strGuid)) + CompatibleMapStore.erase(it); } } - /** Stores the compatibility of a list of guids @param[in] key String concatenation of guids (| used as separator) @param[in] compatibles type of compatibility */ -void LfgQueue::SetCompatibles(const std::string &key, LfgCompatibility compatibles) +void LFGQueue::SetCompatibles(std::string const& key, LfgCompatibility compatibles) +{ + LfgCompatibilityData& data = CompatibleMapStore[key]; + data.compatibility = compatibles; +} + +void LFGQueue::SetCompatibilityData(std::string const& key, LfgCompatibilityData const& data) { - m_CompatibleMap[key] = compatibles; + CompatibleMapStore[key] = data; } + /** Get the compatibility of a group of guids @param[in] key String concatenation of guids (| used as separator) @return LfgCompatibility type of compatibility */ -LfgCompatibility LfgQueue::GetCompatibles(std::string const& key) +LfgCompatibility LFGQueue::GetCompatibles(std::string const& key) { - LfgCompatibleMap::iterator it = m_CompatibleMap.find(key); - if (it != m_CompatibleMap.end()) - return it->second; + LfgCompatibleContainer::iterator itr = CompatibleMapStore.find(key); + if (itr != CompatibleMapStore.end()) + return itr->second.compatibility; return LFG_COMPATIBILITY_PENDING; } -uint8 LfgQueue::FindGroups() +LfgCompatibilityData* LFGQueue::GetCompatibilityData(std::string const& key) +{ + LfgCompatibleContainer::iterator itr = CompatibleMapStore.find(key); + if (itr != CompatibleMapStore.end()) + return &(itr->second); + + return NULL; +} + +uint8 LFGQueue::FindGroups() { uint8 proposals = 0; LfgGuidList firstNew; - while (!m_newToQueue.empty()) + while (!newToQueueStore.empty()) { - uint64 frontguid = m_newToQueue.front(); - sLog->outDebug(LOG_FILTER_LFG, "LfgQueue::FindGroups: checking [" UI64FMTD "] newToQueue(%u), currentQueue(%u)", frontguid, uint32(m_newToQueue.size()), uint32(m_currentQueue.size())); + uint64 frontguid = newToQueueStore.front(); + sLog->outDebug(LOG_FILTER_LFG, "LFGQueue::FindGroups: checking [" UI64FMTD "] newToQueue(%u), currentQueue(%u)", frontguid, uint32(newToQueueStore.size()), uint32(currentQueueStore.size())); firstNew.clear(); firstNew.push_back(frontguid); RemoveFromNewQueue(frontguid); - LfgGuidList temporalList = m_currentQueue; + LfgGuidList temporalList = currentQueueStore; LfgCompatibility compatibles = FindNewGroups(firstNew, temporalList); if (compatibles == LFG_COMPATIBLES_MATCH) @@ -237,15 +272,22 @@ uint8 LfgQueue::FindGroups() @param[in] all List of all other guids in main queue to match against @return LfgCompatibility type of compatibility between groups */ -LfgCompatibility LfgQueue::FindNewGroups(LfgGuidList& check, LfgGuidList& all) +LfgCompatibility LFGQueue::FindNewGroups(LfgGuidList& check, LfgGuidList& all) { std::string strGuids = ConcatenateGuids(check); LfgCompatibility compatibles = GetCompatibles(strGuids); sLog->outDebug(LOG_FILTER_LFG, "LFGQueue::FindNewGroup: (%s): %s - all(%s)", strGuids.c_str(), GetCompatibleString(compatibles), ConcatenateGuids(all).c_str()); - if (compatibles == LFG_COMPATIBILITY_PENDING || compatibles == LFG_COMPATIBLES_BAD_STATES) // Not previously cached, calculate + if (compatibles == LFG_COMPATIBILITY_PENDING) // Not previously cached, calculate compatibles = CheckCompatibility(check); + if (compatibles == LFG_COMPATIBLES_BAD_STATES && sLFGMgr->AllQueued(check)) + { + sLog->outDebug(LOG_FILTER_LFG, "LFGQueue::FindNewGroup: (%s) compatibles (cached) changed from bad states to match", strGuids.c_str()); + SetCompatibles(strGuids, LFG_COMPATIBLES_MATCH); + return LFG_COMPATIBLES_MATCH; + } + if (compatibles != LFG_COMPATIBLES_WITH_LESS_PLAYERS) return compatibles; @@ -268,7 +310,7 @@ LfgCompatibility LfgQueue::FindNewGroups(LfgGuidList& check, LfgGuidList& all) @param[in] check List of guids to check compatibilities @return LfgCompatibility type of compatibility */ -LfgCompatibility LfgQueue::CheckCompatibility(LfgGuidList check) +LfgCompatibility LFGQueue::CheckCompatibility(LfgGuidList check) { std::string strGuids = ConcatenateGuids(check); LfgProposal proposal; @@ -283,10 +325,6 @@ LfgCompatibility LfgQueue::CheckCompatibility(LfgGuidList check) return LFG_INCOMPATIBLES_WRONG_GROUP_SIZE; } - // Player joining alone always compatible - if (check.size() == 1 && IS_PLAYER_GUID(check.front())) - return LFG_COMPATIBLES_WITH_LESS_PLAYERS; - // Check all-but-new compatiblitity if (check.size() > 2) { @@ -310,8 +348,8 @@ LfgCompatibility LfgQueue::CheckCompatibility(LfgGuidList check) for (LfgGuidList::const_iterator it = check.begin(); it != check.end() && numLfgGroups < 2 && numPlayers <= MAXGROUPSIZE; ++it) { uint64 guid = (*it); - LfgQueueDataMap::iterator itQueue = m_QueueDataMap.find(guid); - if (itQueue == m_QueueDataMap.end()) + LfgQueueDataContainer::iterator itQueue = QueueDataStore.find(guid); + if (itQueue == QueueDataStore.end()) { sLog->outError(LOG_FILTER_LFG, "LFGQueue::CheckCompatibility: [" UI64FMTD "] is not queued but listed as queued!", guid); RemoveFromQueue(guid); @@ -336,6 +374,14 @@ LfgCompatibility LfgQueue::CheckCompatibility(LfgGuidList check) if (check.size() == 1 && numPlayers != MAXGROUPSIZE) { sLog->outDebug(LOG_FILTER_LFG, "LFGQueue::CheckCompatibility: (%s) sigle group. Compatibles", strGuids.c_str()); + LfgQueueDataContainer::iterator itQueue = QueueDataStore.find(check.front()); + + LfgCompatibilityData data(LFG_COMPATIBLES_WITH_LESS_PLAYERS); + data.roles = itQueue->second.roles; + LFGMgr::CheckGroupRoles(data.roles); + + UpdateBestCompatibleInQueue(itQueue, strGuids, data.roles); + SetCompatibilityData(strGuids, data); return LFG_COMPATIBLES_WITH_LESS_PLAYERS; } @@ -358,14 +404,14 @@ LfgCompatibility LfgQueue::CheckCompatibility(LfgGuidList check) { for (LfgGuidList::const_iterator it = check.begin(); it != check.end(); ++it) { - const LfgRolesMap &roles = m_QueueDataMap[(*it)].roles; + const LfgRolesMap &roles = QueueDataStore[(*it)].roles; for (LfgRolesMap::const_iterator itRoles = roles.begin(); itRoles != roles.end(); ++itRoles) { LfgRolesMap::const_iterator itPlayer; for (itPlayer = proposalRoles.begin(); itPlayer != proposalRoles.end(); ++itPlayer) { if (itRoles->first == itPlayer->first) - sLog->outDebug(LOG_FILTER_LFG, "LFGQueue::CheckCompatibility: ERROR! Player multiple times in queue! [" UI64FMTD "]", itRoles->first); + sLog->outError(LOG_FILTER_LFG, "LFGQueue::CheckCompatibility: ERROR! Player multiple times in queue! [" UI64FMTD "]", itRoles->first); else if (sLFGMgr->HasIgnore(itRoles->first, itPlayer->first)) break; } @@ -381,7 +427,7 @@ LfgCompatibility LfgQueue::CheckCompatibility(LfgGuidList check) return LFG_INCOMPATIBLES_HAS_IGNORES; } - LfgRolesMap debugRoles = proposalRoles; // DEBUG + LfgRolesMap debugRoles = proposalRoles; if (!LFGMgr::CheckGroupRoles(proposalRoles)) { std::ostringstream o; @@ -394,13 +440,13 @@ LfgCompatibility LfgQueue::CheckCompatibility(LfgGuidList check) } LfgGuidList::iterator itguid = check.begin(); - proposalDungeons = m_QueueDataMap[*itguid].dungeons; + proposalDungeons = QueueDataStore[*itguid].dungeons; std::ostringstream o; o << ", " << *itguid << ": (" << sLFGMgr->ConcatenateDungeons(proposalDungeons) << ")"; for (++itguid; itguid != check.end(); ++itguid) { LfgDungeonSet temporal; - LfgDungeonSet &dungeons = m_QueueDataMap[*itguid].dungeons; + LfgDungeonSet &dungeons = QueueDataStore[*itguid].dungeons; o << ", " << *itguid << ": (" << sLFGMgr->ConcatenateDungeons(dungeons) << ")"; std::set_intersection(proposalDungeons.begin(), proposalDungeons.end(), dungeons.begin(), dungeons.end(), std::inserter(temporal, temporal.begin())); proposalDungeons = temporal; @@ -416,7 +462,7 @@ LfgCompatibility LfgQueue::CheckCompatibility(LfgGuidList check) else { uint64 gguid = *check.begin(); - const LfgQueueData &queue = m_QueueDataMap[gguid]; + const LfgQueueData &queue = QueueDataStore[gguid]; proposalDungeons = queue.dungeons; proposalRoles = queue.roles; LFGMgr::CheckGroupRoles(proposalRoles); // assing new roles @@ -426,7 +472,13 @@ LfgCompatibility LfgQueue::CheckCompatibility(LfgGuidList check) if (numPlayers != MAXGROUPSIZE) { sLog->outDebug(LOG_FILTER_LFG, "LFGQueue::CheckCompatibility: (%s) Compatibles but not enough players(%u)", strGuids.c_str(), numPlayers); - SetCompatibles(strGuids, LFG_COMPATIBLES_WITH_LESS_PLAYERS); + LfgCompatibilityData data(LFG_COMPATIBLES_WITH_LESS_PLAYERS); + data.roles = proposalRoles; + + for (LfgGuidList::const_iterator itr = check.begin(); itr != check.end(); ++itr) + UpdateBestCompatibleInQueue(QueueDataStore.find(*itr), strGuids, data.roles); + + SetCompatibilityData(strGuids, data); return LFG_COMPATIBLES_WITH_LESS_PLAYERS; } @@ -487,19 +539,20 @@ LfgCompatibility LfgQueue::CheckCompatibility(LfgGuidList check) return LFG_COMPATIBLES_MATCH; } -void LfgQueue::UpdateQueueTimers(time_t currTime) +void LFGQueue::UpdateQueueTimers(time_t currTime) { - for (LfgQueueDataMap::const_iterator itQueue = m_QueueDataMap.begin(); itQueue != m_QueueDataMap.end(); ++itQueue) + sLog->outTrace(LOG_FILTER_LFG, "Updating queue timers..."); + for (LfgQueueDataContainer::iterator itQueue = QueueDataStore.begin(); itQueue != QueueDataStore.end(); ++itQueue) { - const LfgQueueData &queueinfo = itQueue->second; + LfgQueueData& queueinfo = itQueue->second; uint32 dungeonId = (*queueinfo.dungeons.begin()); uint32 queuedTime = uint32(currTime - queueinfo.joinTime); uint8 role = PLAYER_ROLE_NONE; int32 waitTime = -1; - int32 wtTank = m_waitTimesTank[dungeonId].time; - int32 wtHealer = m_waitTimesHealer[dungeonId].time; - int32 wtDps = m_waitTimesDps[dungeonId].time; - int32 wtAvg = m_waitTimesAvg[dungeonId].time; + int32 wtTank = waitTimesTankStore[dungeonId].time; + int32 wtHealer = waitTimesHealerStore[dungeonId].time; + int32 wtDps = waitTimesDpsStore[dungeonId].time; + int32 wtAvg = waitTimesAvgStore[dungeonId].time; for (LfgRolesMap::const_iterator itPlayer = queueinfo.roles.begin(); itPlayer != queueinfo.roles.end(); ++itPlayer) role |= itPlayer->second; @@ -524,6 +577,9 @@ void LfgQueue::UpdateQueueTimers(time_t currTime) break; } + if (queueinfo.bestCompatible.empty()) + FindBestCompatibleInQueue(itQueue); + LfgQueueStatusData queueData(dungeonId, waitTime, wtAvg, wtTank, wtHealer, wtDps, queuedTime, queueinfo.tanks, queueinfo.healers, queueinfo.dps); for (LfgRolesMap::const_iterator itPlayer = queueinfo.roles.begin(); itPlayer != queueinfo.roles.end(); ++itPlayer) { @@ -533,7 +589,90 @@ void LfgQueue::UpdateQueueTimers(time_t currTime) } } -time_t LfgQueue::GetJoinTime(uint64 guid) +time_t LFGQueue::GetJoinTime(uint64 guid) +{ + return QueueDataStore[guid].joinTime; +} + +std::string LFGQueue::DumpQueueInfo() const +{ + uint32 players = 0; + uint32 groups = 0; + uint32 playersInGroup = 0; + + for (uint8 i = 0; i < 2; ++i) + { + LfgGuidList const& queue = i ? newToQueueStore : currentQueueStore; + for (LfgGuidList::const_iterator it = queue.begin(); it != queue.end(); ++it) + { + uint64 guid = *it; + if (IS_GROUP(guid)) + { + groups++; + playersInGroup += sLFGMgr->GetPlayerCount(guid); + } + else + players++; + } + } + std::ostringstream o; + o << "Queued Players: " << players << " (in group: " << playersInGroup << ") Groups: " << groups << "\n"; + return o.str(); +} + +std::string LFGQueue::DumpCompatibleInfo(bool full /* = false */) const +{ + std::ostringstream o; + o << "Compatible Map size: " << CompatibleMapStore.size() << "\n"; + if (full) + for (LfgCompatibleContainer::const_iterator itr = CompatibleMapStore.begin(); itr != CompatibleMapStore.end(); ++itr) + o << "(" << itr->first << "): " << GetCompatibleString(itr->second.compatibility) << "\n"; + + return o.str(); +} + +void LFGQueue::FindBestCompatibleInQueue(LfgQueueDataContainer::iterator itrQueue) { - return m_QueueDataMap[guid].joinTime; -}
\ No newline at end of file + sLog->outDebug(LOG_FILTER_LFG, "LFGQueue::FindBestCompatibleInQueue: " UI64FMTD, itrQueue->first); + std::ostringstream o; + o << itrQueue->first; + std::string sguid = o.str(); + + for (LfgCompatibleContainer::const_iterator itr = CompatibleMapStore.begin(); itr != CompatibleMapStore.end(); ++itr) + if (itr->second.compatibility == LFG_COMPATIBLES_WITH_LESS_PLAYERS && + std::string::npos != itr->first.find(sguid)) + { + UpdateBestCompatibleInQueue(itrQueue, itr->first, itr->second.roles); + } +} + +void LFGQueue::UpdateBestCompatibleInQueue(LfgQueueDataContainer::iterator itrQueue, std::string const& key, LfgRolesMap const& roles) +{ + LfgQueueData& queueData = itrQueue->second; + + uint8 storedSize = queueData.bestCompatible.empty() ? 0 : + std::count(queueData.bestCompatible.begin(), queueData.bestCompatible.end(), '|') + 1; + + uint8 size = std::count(key.begin(), key.end(), '|') + 1; + + if (size <= storedSize) + return; + + sLog->outDebug(LOG_FILTER_LFG, "LFGQueue::UpdateBestCompatibleInQueue: Changed (%s) to (%s) as best compatible group for " UI64FMTD, + queueData.bestCompatible.c_str(), key.c_str(), itrQueue->first); + + queueData.bestCompatible = key; + queueData.tanks = LFG_TANKS_NEEDED; + queueData.healers = LFG_HEALERS_NEEDED; + queueData.dps = LFG_DPS_NEEDED; + for (LfgRolesMap::const_iterator it = roles.begin(); it != roles.end(); ++it) + { + uint8 role = it->second; + if (role & PLAYER_ROLE_TANK) + --queueData.tanks; + else if (role & PLAYER_ROLE_HEALER) + --queueData.healers; + else + --queueData.dps; + } +} diff --git a/src/server/game/DungeonFinding/LFGQueue.h b/src/server/game/DungeonFinding/LFGQueue.h index f08199d725a..f937ac0d21a 100644 --- a/src/server/game/DungeonFinding/LFGQueue.h +++ b/src/server/game/DungeonFinding/LFGQueue.h @@ -34,6 +34,17 @@ enum LfgCompatibility LFG_COMPATIBLES_MATCH // Must be the last one }; +struct LfgCompatibilityData +{ + LfgCompatibilityData(): compatibility(LFG_COMPATIBILITY_PENDING) { } + LfgCompatibilityData(LfgCompatibility _compatibility): compatibility(_compatibility) { } + LfgCompatibilityData(LfgCompatibility _compatibility, LfgRolesMap const& _roles): + compatibility(_compatibility), roles(_roles) { } + + LfgCompatibility compatibility; + LfgRolesMap roles; +}; + /// Stores player or group queue info struct LfgQueueData { @@ -41,26 +52,10 @@ struct LfgQueueData healers(LFG_HEALERS_NEEDED), dps(LFG_DPS_NEEDED) { } - LfgQueueData(time_t _joinTime, const LfgDungeonSet &_dungeons, const LfgRolesMap &_roles) - { - joinTime = _joinTime; - dungeons = _dungeons; - roles = _roles; - tanks = LFG_TANKS_NEEDED; - healers = LFG_HEALERS_NEEDED; - dps = LFG_DPS_NEEDED; - - for (LfgRolesMap::const_iterator it = roles.begin(); it != roles.end(); ++it) - { - uint8 role = it->second; - if (role & PLAYER_ROLE_TANK) - --tanks; - else if (role & PLAYER_ROLE_HEALER) - --healers; - else - --dps; - } - } + LfgQueueData(time_t _joinTime, const LfgDungeonSet &_dungeons, LfgRolesMap const& _roles): + joinTime(_joinTime), tanks(LFG_TANKS_NEEDED), healers(LFG_HEALERS_NEEDED), + dps(LFG_DPS_NEEDED), dungeons(_dungeons), roles(_roles) + { } time_t joinTime; ///< Player queue join time (to calculate wait times) uint8 tanks; ///< Tanks needed @@ -68,6 +63,7 @@ struct LfgQueueData uint8 dps; ///< Dps needed LfgDungeonSet dungeons; ///< Selected Player/Group Dungeon/s LfgRolesMap roles; ///< Selected Player Role/s + std::string bestCompatible; ///< Best compatible combination of people queued }; struct LfgWaitTime @@ -77,14 +73,14 @@ struct LfgWaitTime uint32 number; ///< Number of people used to get that wait time }; -typedef std::map<uint32, LfgWaitTime> LfgWaitTimesMap; -typedef std::map<std::string, LfgCompatibility> LfgCompatibleMap; -typedef std::map<uint64, LfgQueueData> LfgQueueDataMap; +typedef std::map<uint32, LfgWaitTime> LfgWaitTimesContainer; +typedef std::map<std::string, LfgCompatibilityData> LfgCompatibleContainer; +typedef std::map<uint64, LfgQueueData> LfgQueueDataContainer; /** Stores all data related to queue */ -class LfgQueue +class LFGQueue { public: @@ -108,10 +104,13 @@ class LfgQueue uint8 FindGroups(); // Just for debugging purposes - LfgCompatibleMap const& GetCompatibleMap(); std::string DumpQueueInfo() const; - std::string DumpCompatibleInfo() const; + std::string DumpCompatibleInfo(bool full = false) const; + private: + void SetQueueUpdateData(std::string const& strGuids, LfgRolesMap const& proposalRoles); + LfgRolesMap const& RemoveFromQueueUpdateData(uint64 guid); + void AddToNewQueue(uint64 guid); void AddToCurrentQueue(uint64 guid); void RemoveFromNewQueue(uint64 guid); @@ -121,19 +120,24 @@ class LfgQueue LfgCompatibility GetCompatibles(std::string const& key); void RemoveFromCompatibles(uint64 guid); + void SetCompatibilityData(std::string const& key, LfgCompatibilityData const& compatibles); + LfgCompatibilityData* GetCompatibilityData(std::string const& key); + void FindBestCompatibleInQueue(LfgQueueDataContainer::iterator itrQueue); + void UpdateBestCompatibleInQueue(LfgQueueDataContainer::iterator itrQueue, std::string const& key, LfgRolesMap const& roles); + LfgCompatibility FindNewGroups(LfgGuidList& check, LfgGuidList& all); LfgCompatibility CheckCompatibility(LfgGuidList check); // Queue - LfgQueueDataMap m_QueueDataMap; ///< Queued groups - LfgCompatibleMap m_CompatibleMap; ///< Compatible dungeons - - LfgWaitTimesMap m_waitTimesAvg; ///< Average wait time to find a group queuing as multiple roles - LfgWaitTimesMap m_waitTimesTank; ///< Average wait time to find a group queuing as tank - LfgWaitTimesMap m_waitTimesHealer; ///< Average wait time to find a group queuing as healer - LfgWaitTimesMap m_waitTimesDps; ///< Average wait time to find a group queuing as dps - LfgGuidList m_currentQueue; ///< Ordered list. Used to find groups - LfgGuidList m_newToQueue; ///< New groups to add to queue + LfgQueueDataContainer QueueDataStore; ///< Queued groups + LfgCompatibleContainer CompatibleMapStore; ///< Compatible dungeons + + LfgWaitTimesContainer waitTimesAvgStore; ///< Average wait time to find a group queuing as multiple roles + LfgWaitTimesContainer waitTimesTankStore; ///< Average wait time to find a group queuing as tank + LfgWaitTimesContainer waitTimesHealerStore; ///< Average wait time to find a group queuing as healer + LfgWaitTimesContainer waitTimesDpsStore; ///< Average wait time to find a group queuing as dps + LfgGuidList currentQueueStore; ///< Ordered list. Used to find groups + LfgGuidList newToQueueStore; ///< New groups to add to queue }; #endif diff --git a/src/server/game/DungeonFinding/LFGScripts.cpp b/src/server/game/DungeonFinding/LFGScripts.cpp index 10ce42da610..91314e64285 100644 --- a/src/server/game/DungeonFinding/LFGScripts.cpp +++ b/src/server/game/DungeonFinding/LFGScripts.cpp @@ -34,11 +34,17 @@ LFGPlayerScript::LFGPlayerScript() : PlayerScript("LFGPlayerScript") void LFGPlayerScript::OnLevelChanged(Player* player, uint8 /*oldLevel*/) { + if (!sLFGMgr->isOptionEnabled(LFG_OPTION_ENABLE_DUNGEON_FINDER | LFG_OPTION_ENABLE_RAID_BROWSER)) + return; + sLFGMgr->InitializeLockedDungeons(player); } void LFGPlayerScript::OnLogout(Player* player) { + if (!sLFGMgr->isOptionEnabled(LFG_OPTION_ENABLE_DUNGEON_FINDER | LFG_OPTION_ENABLE_RAID_BROWSER)) + return; + uint64 guid = player->GetGUID(); sLFGMgr->LeaveLfg(guid); LfgUpdateData updateData = LfgUpdateData(LFG_UPDATETYPE_REMOVED_FROM_QUEUE); @@ -51,6 +57,24 @@ void LFGPlayerScript::OnLogout(Player* player) void LFGPlayerScript::OnLogin(Player* player) { + if (!sLFGMgr->isOptionEnabled(LFG_OPTION_ENABLE_DUNGEON_FINDER | LFG_OPTION_ENABLE_RAID_BROWSER)) + return; + + // Temporal: Trying to determine when group data and LFG data gets desynched + uint64 guid = player->GetGUID(); + uint64 gguid = sLFGMgr->GetGroup(guid); + + if (Group const* group = player->GetGroup()) + { + uint64 gguid2 = group->GetGUID(); + if (gguid != gguid2) + { + sLog->outError(LOG_FILTER_LFG, "%s on group %u but LFG has group %u saved... Fixing.", + player->GetSession()->GetPlayerInfo().c_str(), GUID_LOPART(gguid2), GUID_LOPART(gguid)); + sLFGMgr->SetupGroupMember(guid, group->GetGUID()); + } + } + sLFGMgr->InitializeLockedDungeons(player); sLFGMgr->SetTeam(player->GetGUID(), player->GetTeam()); // TODO - Restore LfgPlayerData and send proper status to player if it was in a group @@ -69,6 +93,9 @@ LFGGroupScript::LFGGroupScript() : GroupScript("LFGGroupScript") void LFGGroupScript::OnAddMember(Group* group, uint64 guid) { + if (!sLFGMgr->isOptionEnabled(LFG_OPTION_ENABLE_DUNGEON_FINDER | LFG_OPTION_ENABLE_RAID_BROWSER)) + return; + uint64 gguid = group->GetGUID(); uint64 leader = group->GetLeaderGUID(); @@ -82,7 +109,7 @@ void LFGGroupScript::OnAddMember(Group* group, uint64 guid) LfgState gstate = sLFGMgr->GetState(gguid); LfgState state = sLFGMgr->GetState(guid); sLog->outDebug(LOG_FILTER_LFG, "LFGScripts::OnAddMember [" UI64FMTD "]: added [" UI64FMTD "] leader " UI64FMTD "] gstate: %u, state: %u", gguid, guid, leader, gstate, state); - LfgUpdateData updateData = LfgUpdateData(LFG_UPDATETYPE_CLEAR_LOCK_LIST); + LfgUpdateData updateData = LfgUpdateData(LFG_UPDATETYPE_UPDATE_STATUS); for (GroupReference* itr = group->GetFirstMember(); itr != NULL; itr = itr->next()) { if (Player* plrg = itr->getSource()) @@ -106,6 +133,9 @@ void LFGGroupScript::OnAddMember(Group* group, uint64 guid) void LFGGroupScript::OnRemoveMember(Group* group, uint64 guid, RemoveMethod method, uint64 kicker, char const* reason) { + if (!sLFGMgr->isOptionEnabled(LFG_OPTION_ENABLE_DUNGEON_FINDER | LFG_OPTION_ENABLE_RAID_BROWSER)) + return; + uint64 gguid = group->GetGUID(); sLog->outDebug(LOG_FILTER_LFG, "LFGScripts::OnRemoveMember [" UI64FMTD "]: remove [" UI64FMTD "] Method: %d Kicker: [" UI64FMTD "] Reason: %s", gguid, guid, method, kicker, (reason ? reason : "")); @@ -157,6 +187,9 @@ void LFGGroupScript::OnRemoveMember(Group* group, uint64 guid, RemoveMethod meth void LFGGroupScript::OnDisband(Group* group) { + if (!sLFGMgr->isOptionEnabled(LFG_OPTION_ENABLE_DUNGEON_FINDER | LFG_OPTION_ENABLE_RAID_BROWSER)) + return; + uint64 gguid = group->GetGUID(); sLog->outDebug(LOG_FILTER_LFG, "LFGScripts::OnDisband [" UI64FMTD "]", gguid); @@ -165,6 +198,9 @@ void LFGGroupScript::OnDisband(Group* group) void LFGGroupScript::OnChangeLeader(Group* group, uint64 newLeaderGuid, uint64 oldLeaderGuid) { + if (!sLFGMgr->isOptionEnabled(LFG_OPTION_ENABLE_DUNGEON_FINDER | LFG_OPTION_ENABLE_RAID_BROWSER)) + return; + uint64 gguid = group->GetGUID(); sLog->outDebug(LOG_FILTER_LFG, "LFGScripts::OnChangeLeader [" UI64FMTD "]: old [" UI64FMTD "] new [" UI64FMTD "]", gguid, newLeaderGuid, oldLeaderGuid); @@ -173,6 +209,9 @@ void LFGGroupScript::OnChangeLeader(Group* group, uint64 newLeaderGuid, uint64 o void LFGGroupScript::OnInviteMember(Group* group, uint64 guid) { + if (!sLFGMgr->isOptionEnabled(LFG_OPTION_ENABLE_DUNGEON_FINDER | LFG_OPTION_ENABLE_RAID_BROWSER)) + return; + uint64 gguid = group->GetGUID(); uint64 leader = group->GetLeaderGUID(); sLog->outDebug(LOG_FILTER_LFG, "LFGScripts::OnInviteMember [" UI64FMTD "]: invite [" UI64FMTD "] leader [" UI64FMTD "]", gguid, guid, leader); diff --git a/src/server/game/Entities/Corpse/Corpse.cpp b/src/server/game/Entities/Corpse/Corpse.cpp index 9359581e3a0..bbee663c955 100755 --- a/src/server/game/Entities/Corpse/Corpse.cpp +++ b/src/server/game/Entities/Corpse/Corpse.cpp @@ -79,7 +79,7 @@ bool Corpse::Create(uint32 guidlow, Player* owner) if (!IsPositionValid()) { sLog->outError(LOG_FILTER_PLAYER, "Corpse (guidlow %d, owner %s) not created. Suggested coordinates isn't valid (X: %f Y: %f)", - guidlow, owner->GetName(), owner->GetPositionX(), owner->GetPositionY()); + guidlow, owner->GetName().c_str(), owner->GetPositionX(), owner->GetPositionY()); return false; } diff --git a/src/server/game/Entities/Creature/Creature.cpp b/src/server/game/Entities/Creature/Creature.cpp index 305168881a5..9bcd4d9c1e2 100755 --- a/src/server/game/Entities/Creature/Creature.cpp +++ b/src/server/game/Entities/Creature/Creature.cpp @@ -1601,7 +1601,8 @@ void Creature::Respawn(bool force) if (m_DBTableGuid) GetMap()->RemoveCreatureRespawnTime(m_DBTableGuid); - sLog->outDebug(LOG_FILTER_UNITS, "Respawning creature %s (GuidLow: %u, Full GUID: " UI64FMTD " Entry: %u)", GetName(), GetGUIDLow(), GetGUID(), GetEntry()); + sLog->outDebug(LOG_FILTER_UNITS, "Respawning creature %s (GuidLow: %u, Full GUID: " UI64FMTD " Entry: %u)", + GetName().c_str(), GetGUIDLow(), GetGUID(), GetEntry()); m_respawnTime = 0; lootForPickPocketed = false; lootForBody = false; @@ -2443,7 +2444,7 @@ TrainerSpellData const* Creature::GetTrainerSpells() const } // overwrite WorldObject function for proper name localization -const char* Creature::GetNameForLocaleIdx(LocaleConstant loc_idx) const +std::string const & Creature::GetNameForLocaleIdx(LocaleConstant loc_idx) const { if (loc_idx != DEFAULT_LOCALE) { @@ -2452,7 +2453,7 @@ const char* Creature::GetNameForLocaleIdx(LocaleConstant loc_idx) const if (cl) { if (cl->Name.size() > uloc_idx && !cl->Name[uloc_idx].empty()) - return cl->Name[uloc_idx].c_str(); + return cl->Name[uloc_idx]; } } diff --git a/src/server/game/Entities/Creature/Creature.h b/src/server/game/Entities/Creature/Creature.h index b9fb5c8831c..c0703196075 100755 --- a/src/server/game/Entities/Creature/Creature.h +++ b/src/server/game/Entities/Creature/Creature.h @@ -584,7 +584,7 @@ class Creature : public Unit, public GridObject<Creature>, public MapCreature void YellToZone(int32 textId, uint32 language, uint64 TargetGuid) { MonsterYellToZone(textId, language, TargetGuid); } // override WorldObject function for proper name localization - const char* GetNameForLocaleIdx(LocaleConstant locale_idx) const; + std::string const& GetNameForLocaleIdx(LocaleConstant locale_idx) const; void setDeathState(DeathState s); // override virtual Unit::setDeathState diff --git a/src/server/game/Entities/Creature/GossipDef.cpp b/src/server/game/Entities/Creature/GossipDef.cpp index ec196280d99..17a8711379a 100755 --- a/src/server/game/Entities/Creature/GossipDef.cpp +++ b/src/server/game/Entities/Creature/GossipDef.cpp @@ -142,9 +142,9 @@ void PlayerMenu::SendGossipMenu(uint32 titleTextId, uint64 objectGUID) const data << uint32(_questMenu.GetMenuItemCount()); // max count 0x20 - for (uint32 iI = 0; iI < _questMenu.GetMenuItemCount(); ++iI) + for (uint8 i = 0; i < _questMenu.GetMenuItemCount(); ++i) { - QuestMenuItem const& item = _questMenu.GetItem(iI); + QuestMenuItem const& item = _questMenu.GetItem(i); uint32 questID = item.QuestId; Quest const* quest = sObjectMgr->GetQuestTemplate(questID); @@ -155,7 +155,7 @@ void PlayerMenu::SendGossipMenu(uint32 titleTextId, uint64 objectGUID) const data << uint8(0); // 3.3.3 changes icon: blue question or yellow exclamation std::string title = quest->GetTitle(); - int locale = _session->GetSessionDbLocaleIndex(); + int32 locale = _session->GetSessionDbLocaleIndex(); if (locale >= 0) if (QuestLocale const* localeData = sObjectMgr->GetQuestLocale(questID)) ObjectMgr::GetLocaleString(localeData->Title, locale, title); @@ -262,10 +262,10 @@ void PlayerMenu::SendQuestGiverQuestList(QEmote eEmote, const std::string& Title { std::string title = quest->GetTitle(); - int loc_idx = _session->GetSessionDbLocaleIndex(); - if (loc_idx >= 0) - if (QuestLocale const* ql = sObjectMgr->GetQuestLocale(questID)) - ObjectMgr::GetLocaleString(ql->Title, loc_idx, title); + int32 locale = _session->GetSessionDbLocaleIndex(); + if (locale >= 0) + if (QuestLocale const* localeData = sObjectMgr->GetQuestLocale(questID)) + ObjectMgr::GetLocaleString(localeData->Title, locale, title); data << uint32(questID); data << uint32(qmi.QuestIcon); @@ -405,7 +405,7 @@ void PlayerMenu::SendQuestQueryResponse(Quest const* quest) const std::string questCompletedText = quest->GetCompletedText(); std::string questObjectiveText[QUEST_OBJECTIVES_COUNT]; - for (uint32 i = 0; i < QUEST_OBJECTIVES_COUNT; ++i) + for (uint8 i = 0; i < QUEST_OBJECTIVES_COUNT; ++i) questObjectiveText[i] = quest->ObjectiveText[i]; int32 locale = _session->GetSessionDbLocaleIndex(); @@ -419,7 +419,7 @@ void PlayerMenu::SendQuestQueryResponse(Quest const* quest) const ObjectMgr::GetLocaleString(localeData->EndText, locale, questEndText); ObjectMgr::GetLocaleString(localeData->CompletedText, locale, questCompletedText); - for (int i = 0; i < QUEST_OBJECTIVES_COUNT; ++i) + for (uint8 i = 0; i < QUEST_OBJECTIVES_COUNT; ++i) ObjectMgr::GetLocaleString(localeData->ObjectiveText[i], locale, questObjectiveText[i]); } } @@ -466,46 +466,46 @@ void PlayerMenu::SendQuestQueryResponse(Quest const* quest) const if (quest->HasFlag(QUEST_FLAGS_HIDDEN_REWARDS)) { - for (uint32 i = 0; i < QUEST_REWARDS_COUNT; ++i) + for (uint8 i = 0; i < QUEST_REWARDS_COUNT; ++i) data << uint32(0) << uint32(0); - for (uint32 i = 0; i < QUEST_REWARD_CHOICES_COUNT; ++i) + for (uint8 i = 0; i < QUEST_REWARD_CHOICES_COUNT; ++i) data << uint32(0) << uint32(0); } else { - for (uint32 i = 0; i < QUEST_REWARDS_COUNT; ++i) + for (uint8 i = 0; i < QUEST_REWARDS_COUNT; ++i) { data << uint32(quest->RewardItemId[i]); data << uint32(quest->RewardItemIdCount[i]); } - for (uint32 i = 0; i < QUEST_REWARD_CHOICES_COUNT; ++i) + for (uint8 i = 0; i < QUEST_REWARD_CHOICES_COUNT; ++i) { data << uint32(quest->RewardChoiceItemId[i]); data << uint32(quest->RewardChoiceItemCount[i]); } } - for (uint32 i = 0; i < QUEST_REPUTATIONS_COUNT; ++i) // reward factions ids + for (uint8 i = 0; i < QUEST_REPUTATIONS_COUNT; ++i) // reward factions ids data << uint32(quest->RewardFactionId[i]); - for (uint32 i = 0; i < QUEST_REPUTATIONS_COUNT; ++i) // columnid+1 QuestFactionReward.dbc? + for (uint8 i = 0; i < QUEST_REPUTATIONS_COUNT; ++i) // columnid+1 QuestFactionReward.dbc? data << int32(quest->RewardFactionValueId[i]); - for (int i = 0; i < QUEST_REPUTATIONS_COUNT; ++i) // unk (0) + for (uint8 i = 0; i < QUEST_REPUTATIONS_COUNT; ++i) // unk (0) data << int32(quest->RewardFactionValueIdOverride[i]); - data << quest->GetPointMapId(); - data << quest->GetPointX(); - data << quest->GetPointY(); - data << quest->GetPointOpt(); + data << uint32(quest->GetPointMapId()); + data << float(quest->GetPointX()); + data << float(quest->GetPointY()); + data << uint32(quest->GetPointOpt()); data << questTitle; data << questObjectives; data << questDetails; data << questEndText; - data << questCompletedText; // display in quest objectives window once all objectives are completed + data << questCompletedText; // display in quest objectives window once all objectives are completed - for (uint32 i = 0; i < QUEST_OBJECTIVES_COUNT; ++i) + for (uint8 i = 0; i < QUEST_OBJECTIVES_COUNT; ++i) { if (quest->RequiredNpcOrGo[i] < 0) data << uint32((quest->RequiredNpcOrGo[i] * (-1)) | 0x80000000); // client expects gameobject template id in form (id|0x80000000) @@ -517,13 +517,13 @@ void PlayerMenu::SendQuestQueryResponse(Quest const* quest) const data << uint32(0); // req source count? } - for (uint32 i = 0; i < QUEST_ITEM_OBJECTIVES_COUNT; ++i) + for (uint8 i = 0; i < QUEST_ITEM_OBJECTIVES_COUNT; ++i) { data << uint32(quest->RequiredItemId[i]); data << uint32(quest->RequiredItemCount[i]); } - for (uint32 i = 0; i < QUEST_OBJECTIVES_COUNT; ++i) + for (uint8 i = 0; i < QUEST_OBJECTIVES_COUNT; ++i) data << questObjectiveText[i]; _session->SendPacket(&data); @@ -535,7 +535,7 @@ void PlayerMenu::SendQuestGiverOfferReward(Quest const* quest, uint64 npcGUID, b std::string questTitle = quest->GetTitle(); std::string questOfferRewardText = quest->GetOfferRewardText(); - int locale = _session->GetSessionDbLocaleIndex(); + int32 locale = _session->GetSessionDbLocaleIndex(); if (locale >= 0) { if (QuestLocale const* localeData = sObjectMgr->GetQuestLocale(quest->GetQuestId())) @@ -556,7 +556,7 @@ void PlayerMenu::SendQuestGiverOfferReward(Quest const* quest, uint64 npcGUID, b data << uint32(quest->GetSuggestedPlayers()); // SuggestedGroupNum uint32 emoteCount = 0; - for (uint32 i = 0; i < QUEST_EMOTE_COUNT; ++i) + for (uint8 i = 0; i < QUEST_EMOTE_COUNT; ++i) { if (quest->OfferRewardEmote[i] <= 0) break; @@ -564,7 +564,7 @@ void PlayerMenu::SendQuestGiverOfferReward(Quest const* quest, uint64 npcGUID, b } data << emoteCount; // Emote Count - for (uint32 i = 0; i < emoteCount; ++i) + for (uint8 i = 0; i < emoteCount; ++i) { data << uint32(quest->OfferRewardEmoteDelay[i]); // Delay Emote data << uint32(quest->OfferRewardEmote[i]); @@ -651,7 +651,7 @@ void PlayerMenu::SendQuestGiverRequestItems(Quest const* quest, uint64 npcGUID, data << questTitle; data << requestItemsText; - data << uint32(0x00); // unknown + data << uint32(0); // unknown if (canComplete) data << quest->GetCompleteEmote(); @@ -659,10 +659,7 @@ void PlayerMenu::SendQuestGiverRequestItems(Quest const* quest, uint64 npcGUID, data << quest->GetIncompleteEmote(); // Close Window after cancel - if (closeOnCancel) - data << uint32(0x01); - else - data << uint32(0x00); + data << uint32(closeOnCancel); data << uint32(quest->GetFlags()); // 3.3.3 questFlags data << uint32(quest->GetSuggestedPlayers()); // SuggestedGroupNum diff --git a/src/server/game/Entities/GameObject/GameObject.cpp b/src/server/game/Entities/GameObject/GameObject.cpp index 59f68a0494f..214df2672cb 100755 --- a/src/server/game/Entities/GameObject/GameObject.cpp +++ b/src/server/game/Entities/GameObject/GameObject.cpp @@ -33,7 +33,7 @@ #include "GameObjectModel.h" #include "DynamicTree.h" -GameObject::GameObject() : WorldObject(false), m_model(NULL), m_goValue(new GameObjectValue), m_AI(NULL) +GameObject::GameObject(): WorldObject(false), m_model(NULL), m_goValue(), m_AI(NULL) { m_objectType |= TYPEMASK_GAMEOBJECT; m_objectTypeId = TYPEID_GAMEOBJECT; @@ -65,7 +65,6 @@ GameObject::GameObject() : WorldObject(false), m_model(NULL), m_goValue(new Game GameObject::~GameObject() { - delete m_goValue; delete m_AI; delete m_model; //if (m_uint32Values) // field array can be not exist if GameOBject not loaded @@ -226,8 +225,8 @@ bool GameObject::Create(uint32 guidlow, uint32 name_id, Map* map, uint32 phaseMa switch (goinfo->type) { case GAMEOBJECT_TYPE_DESTRUCTIBLE_BUILDING: - m_goValue->Building.Health = goinfo->building.intactNumHits + goinfo->building.damagedNumHits; - m_goValue->Building.MaxHealth = m_goValue->Building.Health; + m_goValue.Building.Health = goinfo->building.intactNumHits + goinfo->building.damagedNumHits; + m_goValue.Building.MaxHealth = m_goValue.Building.Health; SetGoAnimProgress(255); break; case GAMEOBJECT_TYPE_TRANSPORT: @@ -360,7 +359,7 @@ void GameObject::Update(uint32 diff) Unit* caster = GetOwner(); if (caster && caster->GetTypeId() == TYPEID_PLAYER) { - caster->FinishSpell(CURRENT_CHANNELED_SPELL); + caster->ToPlayer()->RemoveGameObject(this, false); WorldPacket data(SMSG_FISH_ESCAPED, 0); caster->ToPlayer()->GetSession()->SendPacket(&data); @@ -1115,6 +1114,19 @@ void GameObject::Use(Unit* user) player->SendPreparedGossip(this); return; } + case GAMEOBJECT_TYPE_TRAP: //6 + { + GameObjectTemplate const* goInfo = GetGOInfo(); + if (goInfo->trap.spellId) + CastSpell(user, goInfo->trap.spellId); + + m_cooldownTime = time(NULL) + (goInfo->trap.cooldown ? goInfo->trap.cooldown : uint32(4)); // template or 4 seconds + + if (goInfo->trap.type == 1) // Deactivate after trigger + SetLootState(GO_JUST_DEACTIVATED); + + return; + } //Sitting: Wooden bench, chairs enzz case GAMEOBJECT_TYPE_CHAIR: //7 { @@ -1348,6 +1360,8 @@ void GameObject::Use(Unit* user) player->SendLoot(GetGUID(), LOOT_FISHING); } // TODO: else: junk + else + m_respawnTime = time(NULL); break; } @@ -1629,7 +1643,7 @@ void GameObject::Use(Unit* user) default: if (GetGoType() >= MAX_GAMEOBJECT_TYPE) sLog->outError(LOG_FILTER_GENERAL, "GameObject::Use(): unit (type: %u, guid: %u, name: %s) tries to use object (guid: %u, entry: %u, name: %s) of unknown type (%u)", - user->GetTypeId(), user->GetGUIDLow(), user->GetName(), GetGUIDLow(), GetEntry(), GetGOInfo()->name.c_str(), GetGoType()); + user->GetTypeId(), user->GetGUIDLow(), user->GetName().c_str(), GetGUIDLow(), GetEntry(), GetGOInfo()->name.c_str(), GetGoType()); break; } @@ -1743,14 +1757,14 @@ void GameObject::EventInform(uint32 eventId) } // overwrite WorldObject function for proper name localization -const char* GameObject::GetNameForLocaleIdx(LocaleConstant loc_idx) const +std::string const & GameObject::GetNameForLocaleIdx(LocaleConstant loc_idx) const { if (loc_idx != DEFAULT_LOCALE) { uint8 uloc_idx = uint8(loc_idx); if (GameObjectLocale const* cl = sObjectMgr->GetGameObjectLocale(GetEntry())) if (cl->Name.size() > uloc_idx && !cl->Name[uloc_idx].empty()) - return cl->Name[uloc_idx].c_str(); + return cl->Name[uloc_idx]; } return GetName(); @@ -1788,22 +1802,22 @@ void GameObject::UpdateRotationFields(float rotation2 /*=0.0f*/, float rotation3 void GameObject::ModifyHealth(int32 change, Unit* attackerOrHealer /*= NULL*/, uint32 spellId /*= 0*/) { - if (!GetGOValue()->Building.MaxHealth || !change) + if (!m_goValue.Building.MaxHealth || !change) return; // prevent double destructions of the same object - if (change < 0 && !GetGOValue()->Building.Health) + if (change < 0 && !m_goValue.Building.Health) return; - if (int32(GetGOValue()->Building.Health) + change <= 0) - GetGOValue()->Building.Health = 0; - else if (int32(GetGOValue()->Building.Health) + change >= int32(GetGOValue()->Building.MaxHealth)) - GetGOValue()->Building.Health = GetGOValue()->Building.MaxHealth; + if (int32(m_goValue.Building.Health) + change <= 0) + m_goValue.Building.Health = 0; + else if (int32(m_goValue.Building.Health) + change >= int32(m_goValue.Building.MaxHealth)) + m_goValue.Building.Health = m_goValue.Building.MaxHealth; else - GetGOValue()->Building.Health += change; + m_goValue.Building.Health += change; // Set the health bar, value = 255 * healthPct; - SetGoAnimProgress(GetGOValue()->Building.Health * 255 / GetGOValue()->Building.MaxHealth); + SetGoAnimProgress(m_goValue.Building.Health * 255 / m_goValue.Building.MaxHealth); Player* player = attackerOrHealer->GetCharmerOrOwnerPlayerOrPlayerItself(); @@ -1822,11 +1836,11 @@ void GameObject::ModifyHealth(int32 change, Unit* attackerOrHealer /*= NULL*/, u GameObjectDestructibleState newState = GetDestructibleState(); - if (!GetGOValue()->Building.Health) + if (!m_goValue.Building.Health) newState = GO_DESTRUCTIBLE_DESTROYED; - else if (GetGOValue()->Building.Health <= GetGOInfo()->building.damagedNumHits) + else if (m_goValue.Building.Health <= GetGOInfo()->building.damagedNumHits) newState = GO_DESTRUCTIBLE_DAMAGED; - else if (GetGOValue()->Building.Health == GetGOValue()->Building.MaxHealth) + else if (m_goValue.Building.Health == m_goValue.Building.MaxHealth) newState = GO_DESTRUCTIBLE_INTACT; if (newState == GetDestructibleState()) @@ -1847,7 +1861,7 @@ void GameObject::SetDestructibleState(GameObjectDestructibleState state, Player* SetDisplayId(m_goInfo->displayId); if (setHealth) { - m_goValue->Building.Health = m_goValue->Building.MaxHealth; + m_goValue.Building.Health = m_goValue.Building.MaxHealth; SetGoAnimProgress(255); } EnableCollision(true); @@ -1871,12 +1885,12 @@ void GameObject::SetDestructibleState(GameObjectDestructibleState state, Player* if (setHealth) { - m_goValue->Building.Health = m_goInfo->building.damagedNumHits; - uint32 maxHealth = m_goValue->Building.MaxHealth; + m_goValue.Building.Health = m_goInfo->building.damagedNumHits; + uint32 maxHealth = m_goValue.Building.MaxHealth; // in this case current health is 0 anyway so just prevent crashing here if (!maxHealth) maxHealth = 1; - SetGoAnimProgress(m_goValue->Building.Health * 255 / maxHealth); + SetGoAnimProgress(m_goValue.Building.Health * 255 / maxHealth); } break; } @@ -1904,7 +1918,7 @@ void GameObject::SetDestructibleState(GameObjectDestructibleState state, Player* if (setHealth) { - m_goValue->Building.Health = 0; + m_goValue.Building.Health = 0; SetGoAnimProgress(0); } EnableCollision(false); @@ -1924,7 +1938,7 @@ void GameObject::SetDestructibleState(GameObjectDestructibleState state, Player* // restores to full health if (setHealth) { - m_goValue->Building.Health = m_goValue->Building.MaxHealth; + m_goValue.Building.Health = m_goValue.Building.MaxHealth; SetGoAnimProgress(255); } EnableCollision(true); diff --git a/src/server/game/Entities/GameObject/GameObject.h b/src/server/game/Entities/GameObject/GameObject.h index 8fb81a0e021..32d73579f51 100755 --- a/src/server/game/Entities/GameObject/GameObject.h +++ b/src/server/game/Entities/GameObject/GameObject.h @@ -628,7 +628,7 @@ class GameObject : public WorldObject, public GridObject<GameObject> static GameObject* GetGameObject(WorldObject& object, uint64 guid); GameObjectTemplate const* GetGOInfo() const { return m_goInfo; } GameObjectData const* GetGOData() const { return m_goData; } - GameObjectValue * GetGOValue() const { return m_goValue; } + GameObjectValue const* GetGOValue() const { return &m_goValue; } bool IsTransport() const; bool IsDynTransport() const; @@ -645,7 +645,7 @@ class GameObject : public WorldObject, public GridObject<GameObject> void YellToZone(int32 textId, uint32 language, uint64 TargetGuid) { MonsterYellToZone(textId, language, TargetGuid); } // overwrite WorldObject function for proper name localization - const char* GetNameForLocaleIdx(LocaleConstant locale_idx) const; + std::string const& GetNameForLocaleIdx(LocaleConstant locale_idx) const; void SaveToDB(); void SaveToDB(uint32 mapid, uint8 spawnMask, uint32 phaseMask); @@ -826,7 +826,7 @@ class GameObject : public WorldObject, public GridObject<GameObject> uint32 m_DBTableGuid; ///< For new or temporary gameobjects is 0 for saved it is lowguid GameObjectTemplate const* m_goInfo; GameObjectData const* m_goData; - GameObjectValue * const m_goValue; + GameObjectValue m_goValue; uint64 m_rotation; diff --git a/src/server/game/Entities/Object/Object.cpp b/src/server/game/Entities/Object/Object.cpp index 2c5d448cc63..d7e87cedbf8 100755 --- a/src/server/game/Entities/Object/Object.cpp +++ b/src/server/game/Entities/Object/Object.cpp @@ -92,7 +92,8 @@ WorldObject::~WorldObject() { if (GetTypeId() == TYPEID_CORPSE) { - sLog->outFatal(LOG_FILTER_GENERAL, "Object::~Object Corpse guid="UI64FMTD", type=%d, entry=%u deleted but still in map!!", GetGUID(), ((Corpse*)this)->GetType(), GetEntry()); + sLog->outFatal(LOG_FILTER_GENERAL, "Object::~Object Corpse guid="UI64FMTD", type=%d, entry=%u deleted but still in map!!", + GetGUID(), ((Corpse*)this)->GetType(), GetEntry()); ASSERT(false); } ResetMap(); @@ -767,23 +768,6 @@ void Object::BuildFieldsUpdate(Player* player, UpdateDataMapType& data_map) cons BuildValuesUpdateBlockForPlayer(&iter->second, iter->first); } -void Object::_LoadIntoDataField(char const* data, uint32 startOffset, uint32 count) -{ - if (!data) - return; - - Tokenizer tokens(data, ' ', count); - - if (tokens.size() != count) - return; - - for (uint32 index = 0; index < count; ++index) - { - m_uint32Values[startOffset + index] = atol(tokens[index]); - _changedFields[startOffset + index] = true; - } -} - void Object::GetUpdateFieldData(Player const* target, uint32*& flags, bool& isOwner, bool& isItemOwner, bool& hasSpecialInfo, bool& isPartyMember) const { // This function assumes updatefield index is always valid @@ -844,6 +828,23 @@ bool Object::IsUpdateFieldVisible(uint32 flags, bool isSelf, bool isOwner, bool return false; } +void Object::_LoadIntoDataField(std::string const& data, uint32 startOffset, uint32 count) +{ + if (data.empty()) + return; + + Tokenizer tokens(data, ' ', count); + + if (tokens.size() != count) + return; + + for (uint32 index = 0; index < count; ++index) + { + m_uint32Values[startOffset + index] = atol(tokens[index]); + _changedFields[startOffset + index] = true; + } +} + void Object::_SetUpdateBits(UpdateMask* updateMask, Player* target) const { bool* indexes = _changedFields; @@ -2124,13 +2125,13 @@ void WorldObject::MonsterWhisper(int32 textId, uint64 receiver, bool IsBossWhisp player->GetSession()->SendPacket(&data); } -void WorldObject::BuildMonsterChat(WorldPacket* data, uint8 msgtype, char const* text, uint32 language, char const* name, uint64 targetGuid) const +void WorldObject::BuildMonsterChat(WorldPacket* data, uint8 msgtype, char const* text, uint32 language, std::string const &name, uint64 targetGuid) const { *data << (uint8)msgtype; *data << (uint32)language; *data << (uint64)GetGUID(); *data << (uint32)0; // 2.1.0 - *data << (uint32)(strlen(name)+1); + *data << (uint32)(name.size()+1); *data << name; *data << (uint64)targetGuid; // Unit Target if (targetGuid && !IS_PLAYER_GUID(targetGuid)) diff --git a/src/server/game/Entities/Object/Object.h b/src/server/game/Entities/Object/Object.h index 410903f6619..0bb4214de32 100755 --- a/src/server/game/Entities/Object/Object.h +++ b/src/server/game/Entities/Object/Object.h @@ -51,7 +51,7 @@ enum TypeMask TYPEMASK_OBJECT = 0x0001, TYPEMASK_ITEM = 0x0002, TYPEMASK_CONTAINER = 0x0006, // TYPEMASK_ITEM | 0x0004 - TYPEMASK_UNIT = 0x0008, // creature + TYPEMASK_UNIT = 0x0008, // creature TYPEMASK_PLAYER = 0x0010, TYPEMASK_GAMEOBJECT = 0x0020, TYPEMASK_DYNAMICOBJECT = 0x0040, @@ -325,7 +325,7 @@ class Object void _InitValues(); void _Create(uint32 guidlow, uint32 entry, HighGuid guidhigh); std::string _ConcatFields(uint16 startIndex, uint16 size) const; - void _LoadIntoDataField(const char* data, uint32 startOffset, uint32 count); + void _LoadIntoDataField(std::string const& data, uint32 startOffset, uint32 count); void GetUpdateFieldData(Player const* target, uint32*& flags, bool& isOwner, bool& isItemOwner, bool& hasSpecialInfo, bool& isPartyMember) const; @@ -654,10 +654,10 @@ class WorldObject : public Object, public WorldLocation InstanceScript* GetInstanceScript(); - const char* GetName() const { return m_name.c_str(); } - void SetName(const std::string& newname) { m_name=newname; } + std::string const& GetName() const { return m_name; } + void SetName(std::string const& newname) { m_name=newname; } - virtual const char* GetNameForLocaleIdx(LocaleConstant /*locale_idx*/) const { return GetName(); } + virtual std::string const& GetNameForLocaleIdx(LocaleConstant /*locale_idx*/) const { return m_name; } float GetDistance(const WorldObject* obj) const { @@ -743,7 +743,7 @@ class WorldObject : public Object, public WorldLocation void MonsterTextEmote(int32 textId, uint64 TargetGuid, bool IsBossEmote = false); void MonsterWhisper(int32 textId, uint64 receiver, bool IsBossWhisper = false); void MonsterYellToZone(int32 textId, uint32 language, uint64 TargetGuid); - void BuildMonsterChat(WorldPacket* data, uint8 msgtype, char const* text, uint32 language, char const* name, uint64 TargetGuid) const; + void BuildMonsterChat(WorldPacket* data, uint8 msgtype, char const* text, uint32 language, std::string const& name, uint64 TargetGuid) const; void PlayDistanceSound(uint32 sound_id, Player* target = NULL); void PlayDirectSound(uint32 sound_id, Player* target = NULL); diff --git a/src/server/game/Entities/Object/ObjectDefines.h b/src/server/game/Entities/Object/ObjectDefines.h index a3c8901880f..03fa44da08a 100755 --- a/src/server/game/Entities/Object/ObjectDefines.h +++ b/src/server/game/Entities/Object/ObjectDefines.h @@ -122,4 +122,3 @@ inline char const* GetLogNameForGuid(uint64 guid) } } #endif - diff --git a/src/server/game/Entities/Pet/Pet.cpp b/src/server/game/Entities/Pet/Pet.cpp index 283f2032ab0..d2d9bdac4b3 100755 --- a/src/server/game/Entities/Pet/Pet.cpp +++ b/src/server/game/Entities/Pet/Pet.cpp @@ -34,9 +34,9 @@ #define PET_XP_FACTOR 0.05f Pet::Pet(Player* owner, PetType type) : Guardian(NULL, owner, true), -m_usedTalentCount(0), m_removed(false), m_owner(owner), -m_happinessTimer(7500), m_petType(type), m_duration(0), -m_auraRaidUpdateMask(0), m_loading(false), m_declinedname(NULL) + m_usedTalentCount(0), m_removed(false), m_owner(owner), + m_happinessTimer(7500), m_petType(type), m_duration(0), + m_auraRaidUpdateMask(0), m_loading(false), m_declinedname(NULL) { m_unitTypeMask |= UNIT_MASK_PET; if (type == HUNTER_PET) @@ -77,7 +77,6 @@ void Pet::AddToWorld() GetCharmInfo()->SetIsFollowing(false); GetCharmInfo()->SetIsReturning(false); } - } void Pet::RemoveFromWorld() @@ -456,7 +455,7 @@ void Pet::SavePetToDB(PetSaveMode mode) for (uint32 i = ACTION_BAR_INDEX_START; i < ACTION_BAR_INDEX_END; ++i) { ss << uint32(m_charmInfo->GetActionBarEntry(i)->GetType()) << ' ' - << uint32(m_charmInfo->GetActionBarEntry(i)->GetAction()) << ' '; + << uint32(m_charmInfo->GetActionBarEntry(i)->GetAction()) << ' '; }; ss << "', " @@ -562,7 +561,7 @@ void Pet::Update(uint32 diff) { if (owner->GetPetGUID() != GetGUID()) { - sLog->outError(LOG_FILTER_PETS, "Pet %u is not pet of owner %s, removed", GetEntry(), m_owner->GetName()); + sLog->outError(LOG_FILTER_PETS, "Pet %u is not pet of owner %s, removed", GetEntry(), m_owner->GetName().c_str()); Remove(getPetType() == HUNTER_PET?PET_SAVE_AS_DELETED:PET_SAVE_NOT_IN_SLOT); return; } @@ -2069,4 +2068,4 @@ void Pet::ProhibitSpellSchool(SpellSchoolMask idSchoolMask, uint32 unTimeMs) if (Player* owner = GetOwner()) owner->GetSession()->SendPacket(&data); -}
\ No newline at end of file +} diff --git a/src/server/game/Entities/Pet/Pet.h b/src/server/game/Entities/Pet/Pet.h index 6e080263862..f55d03ce081 100755 --- a/src/server/game/Entities/Pet/Pet.h +++ b/src/server/game/Entities/Pet/Pet.h @@ -225,7 +225,7 @@ class Pet : public Guardian bool m_removed; // prevent overwrite pet state in DB at next Pet::Update if pet already removed(saved) - Player* GetOwner() { return m_owner; } + Player* GetOwner() const { return m_owner; } protected: Player* m_owner; uint32 m_happinessTimer; diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp index e06463bf0aa..46110a2cc11 100755 --- a/src/server/game/Entities/Player/Player.cpp +++ b/src/server/game/Entities/Player/Player.cpp @@ -190,16 +190,14 @@ void PlayerTaxi::InitTaxiNodesForLevel(uint32 race, uint32 chrClass, uint8 level SetTaximaskNode(213); //Shattered Sun Staging Area } -void PlayerTaxi::LoadTaxiMask(const char* data) +void PlayerTaxi::LoadTaxiMask(std::string const &data) { Tokenizer tokens(data, ' '); - uint8 index; - Tokenizer::const_iterator iter; - for (iter = tokens.begin(), index = 0; - (index < TaxiMaskSize) && (iter != tokens.end()); ++iter, ++index) + uint8 index = 0; + for (Tokenizer::const_iterator iter = tokens.begin(); index < TaxiMaskSize && iter != tokens.end(); ++iter, ++index) { - // load and set bits only for existed taxi nodes + // load and set bits only for existing taxi nodes m_taximask[index] = sTaxiNodesMask[index] & uint32(atol(*iter)); } } @@ -1579,7 +1577,7 @@ void Player::Update(uint32 p_time) // check every second if (now > m_Last_tick + 1) UpdateSoulboundTradeItems(); - + // If mute expired, remove it from the DB if (GetSession()->m_muteTime && GetSession()->m_muteTime < now) { @@ -1753,7 +1751,7 @@ void Player::Update(uint32 p_time) { // m_nextSave reseted in SaveToDB call SaveToDB(); - sLog->outDebug(LOG_FILTER_PLAYER, "Player '%s' (GUID: %u) saved", GetName(), GetGUIDLow()); + sLog->outDebug(LOG_FILTER_PLAYER, "Player '%s' (GUID: %u) saved", GetName().c_str(), GetGUIDLow()); } else m_nextSave -= p_time; @@ -1842,7 +1840,7 @@ void Player::setDeathState(DeathState s) { if (!cur) { - sLog->outError(LOG_FILTER_PLAYER, "setDeathState: attempt to kill a dead player %s(%d)", GetName(), GetGUIDLow()); + sLog->outError(LOG_FILTER_PLAYER, "setDeathState: attempt to kill a dead player %s(%d)", GetName().c_str(), GetGUIDLow()); return; } @@ -2088,13 +2086,13 @@ bool Player::TeleportTo(uint32 mapid, float x, float y, float z, float orientati if (!MapManager::IsValidMapCoord(mapid, x, y, z, orientation)) { sLog->outError(LOG_FILTER_MAPS, "TeleportTo: invalid map (%d) or invalid coordinates (X: %f, Y: %f, Z: %f, O: %f) given when teleporting player (GUID: %u, name: %s, map: %d, X: %f, Y: %f, Z: %f, O: %f).", - mapid, x, y, z, orientation, GetGUIDLow(), GetName(), GetMapId(), GetPositionX(), GetPositionY(), GetPositionZ(), GetOrientation()); + mapid, x, y, z, orientation, GetGUIDLow(), GetName().c_str(), GetMapId(), GetPositionX(), GetPositionY(), GetPositionZ(), GetOrientation()); return false; } if (AccountMgr::IsPlayerAccount(GetSession()->GetSecurity()) && DisableMgr::IsDisabledFor(DISABLE_TYPE_MAP, mapid, this)) { - sLog->outError(LOG_FILTER_MAPS, "Player (GUID: %u, name: %s) tried to enter a forbidden map %u", GetGUIDLow(), GetName(), mapid); + sLog->outError(LOG_FILTER_MAPS, "Player (GUID: %u, name: %s) tried to enter a forbidden map %u", GetGUIDLow(), GetName().c_str(), mapid); SendTransferAborted(mapid, TRANSFER_ABORT_MAP_NOT_ALLOWED); return false; } @@ -2112,7 +2110,7 @@ bool Player::TeleportTo(uint32 mapid, float x, float y, float z, float orientati // client without expansion support if (GetSession()->Expansion() < mEntry->Expansion()) { - sLog->outDebug(LOG_FILTER_MAPS, "Player %s using client without required expansion tried teleport to non accessible map %u", GetName(), mapid); + sLog->outDebug(LOG_FILTER_MAPS, "Player %s using client without required expansion tried teleport to non accessible map %u", GetName().c_str(), mapid); if (GetTransport()) { @@ -2129,7 +2127,7 @@ bool Player::TeleportTo(uint32 mapid, float x, float y, float z, float orientati return false; // normal client can't teleport to this map... } else - sLog->outDebug(LOG_FILTER_MAPS, "Player %s is being teleported to map %u", GetName(), mapid); + sLog->outDebug(LOG_FILTER_MAPS, "Player %s is being teleported to map %u", GetName().c_str(), mapid); if (m_vehicle) ExitVehicle(); @@ -2451,7 +2449,8 @@ void Player::RemoveFromWorld() { if (WorldObject* viewpoint = GetViewpoint()) { - sLog->outError(LOG_FILTER_PLAYER, "Player %s has viewpoint %u %u when removed from world", GetName(), viewpoint->GetEntry(), viewpoint->GetTypeId()); + sLog->outError(LOG_FILTER_PLAYER, "Player %s has viewpoint %u %u when removed from world", + GetName().c_str(), viewpoint->GetEntry(), viewpoint->GetTypeId()); SetViewpoint(viewpoint, false); } } @@ -2776,7 +2775,7 @@ GameObject* Player::GetGameObjectIfCanInteractWith(uint64 guid, GameobjectTypes return go; sLog->outDebug(LOG_FILTER_MAPS, "IsGameObjectOfTypeInRange: GameObject '%s' [GUID: %u] is too far away from player %s [GUID: %u] to be used by him (distance=%f, maximal 10 is allowed)", go->GetGOInfo()->name.c_str(), - go->GetGUIDLow(), GetName(), GetGUIDLow(), go->GetDistance(this)); + go->GetGUIDLow(), GetName().c_str(), GetGUIDLow(), go->GetDistance(this)); } } return NULL; @@ -3023,6 +3022,9 @@ void Player::GiveLevel(uint8 level) if (level == oldLevel) return; + if (Guild* guild = GetGuild()) + guild->UpdateMemberData(this, GUILD_MEMBER_DATA_LEVEL, level); + PlayerLevelInfo info; sObjectMgr->GetPlayerLevelInfo(getRace(), getClass(), level, &info); @@ -5077,7 +5079,7 @@ void Player::BuildPlayerRepop() // the player cannot have a corpse already, only bones which are not returned by GetCorpse if (GetCorpse()) { - sLog->outError(LOG_FILTER_PLAYER, "BuildPlayerRepop: player %s(%d) already has a corpse", GetName(), GetGUIDLow()); + sLog->outError(LOG_FILTER_PLAYER, "BuildPlayerRepop: player %s(%d) already has a corpse", GetName().c_str(), GetGUIDLow()); return; } @@ -5086,7 +5088,7 @@ void Player::BuildPlayerRepop() Corpse* corpse = GetCorpse(); if (!corpse) { - sLog->outError(LOG_FILTER_PLAYER, "Error creating corpse for Player %s [%u]", GetName(), GetGUIDLow()); + sLog->outError(LOG_FILTER_PLAYER, "Error creating corpse for Player %s [%u]", GetName().c_str(), GetGUIDLow()); return; } GetMap()->AddToMap(corpse); @@ -5579,7 +5581,7 @@ void Player::CleanupChannels() 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 - if (ChannelMgr* cMgr = channelMgr(GetTeam())) + if (ChannelMgr* cMgr = ChannelMgr::forTeam(GetTeam())) cMgr->LeftChannel(ch->GetName()); // deleted channel if empty } sLog->outDebug(LOG_FILTER_CHATSYS, "Player: channels cleaned up!"); @@ -5594,7 +5596,7 @@ void Player::UpdateLocalChannels(uint32 newZone) if (!current_zone) return; - ChannelMgr* cMgr = channelMgr(GetTeam()); + ChannelMgr* cMgr = ChannelMgr::forTeam(GetTeam()); if (!cMgr) return; @@ -5782,7 +5784,7 @@ void Player::GetDodgeFromAgility(float &diminishing, float &nondiminishing) const float dodge_base[MAX_CLASSES] = { 0.036640f, // Warrior - 0.034943f, // Paladi + 0.034943f, // Paladin -0.040873f, // Hunter 0.020957f, // Rogue 0.034178f, // Priest @@ -6650,13 +6652,13 @@ bool Player::IsActionButtonDataValid(uint8 button, uint32 action, uint8 type) { if (button >= MAX_ACTION_BUTTONS) { - sLog->outError(LOG_FILTER_PLAYER_LOADING, "Action %u not added into button %u for player %s: button must be < %u", action, button, GetName(), MAX_ACTION_BUTTONS); + sLog->outError(LOG_FILTER_PLAYER, "Action %u not added into button %u for player %s: button must be < %u", action, button, GetName().c_str(), MAX_ACTION_BUTTONS ); return false; } if (action >= MAX_ACTION_BUTTON_ACTION_VALUE) { - sLog->outError(LOG_FILTER_PLAYER_LOADING, "Action %u not added into button %u for player %s: action must be < %u", action, button, GetName(), MAX_ACTION_BUTTON_ACTION_VALUE); + sLog->outError(LOG_FILTER_PLAYER, "Action %u not added into button %u for player %s: action must be < %u", action, button, GetName().c_str(), MAX_ACTION_BUTTON_ACTION_VALUE); return false; } @@ -6665,25 +6667,31 @@ bool Player::IsActionButtonDataValid(uint8 button, uint32 action, uint8 type) case ACTION_BUTTON_SPELL: if (!sSpellMgr->GetSpellInfo(action)) { - sLog->outError(LOG_FILTER_PLAYER_LOADING, "Spell action %u not added into button %u for player %s: spell not exist", action, button, GetName()); + sLog->outError(LOG_FILTER_PLAYER, "Spell action %u not added into button %u for player %s: spell not exist", action, button, GetName().c_str()); return false; } if (!HasSpell(action)) { - sLog->outDebug(LOG_FILTER_PLAYER_LOADING, "Player::IsActionButtonDataValid Spell action %u not added into button %u for player %s: player don't known this spell", action, button, GetName()); + sLog->outError(LOG_FILTER_PLAYER, "Spell action %u not added into button %u for player %s: player don't known this spell", action, button, GetName().c_str()); return false; } break; case ACTION_BUTTON_ITEM: if (!sObjectMgr->GetItemTemplate(action)) { - sLog->outError(LOG_FILTER_PLAYER_LOADING, "Item action %u not added into button %u for player %s: item not exist", action, button, GetName()); + sLog->outError(LOG_FILTER_PLAYER, "Item action %u not added into button %u for player %s: item not exist", action, button, GetName().c_str()); return false; } break; + case ACTION_BUTTON_C: + case ACTION_BUTTON_CMACRO: + case ACTION_BUTTON_MACRO: + case ACTION_BUTTON_EQSET: + break; default: - break; // other cases not checked at this moment + sLog->outError(LOG_FILTER_PLAYER, "Unknown action type %u", type); + return false; // other cases not checked at this moment } return true; @@ -6700,7 +6708,7 @@ ActionButton* Player::addActionButton(uint8 button, uint32 action, uint8 type) // set data and update to CHANGED if not NEW ab.SetActionAndType(action, ActionButtonType(type)); - sLog->outInfo(LOG_FILTER_PLAYER_LOADING, "Player '%u' Added Action '%u' (type %u) to Button '%u'", GetGUIDLow(), action, type, button); + sLog->outDebug(LOG_FILTER_PLAYER, "Player '%u' Added Action '%u' (type %u) to Button '%u'", GetGUIDLow(), action, type, button); return &ab; } @@ -6715,7 +6723,7 @@ void Player::removeActionButton(uint8 button) else buttonItr->second.uState = ACTIONBUTTON_DELETED; // saved, will deleted at next save - sLog->outInfo(LOG_FILTER_PLAYER_LOADING, "Action Button '%u' Removed from Player '%u'", button, GetGUIDLow()); + sLog->outDebug(LOG_FILTER_PLAYER, "Action Button '%u' Removed from Player '%u'", button, GetGUIDLow()); } ActionButton const* Player::GetActionButton(uint8 button) @@ -7103,21 +7111,21 @@ void Player::UpdateHonorFields() ///Calculate the amount of honor gained based on the victim ///and the size of the group for which the honor is divided ///An exact honor value can also be given (overriding the calcs) -bool Player::RewardHonor(Unit* uVictim, uint32 groupsize, int32 honor, bool pvptoken) +bool Player::RewardHonor(Unit* victim, uint32 groupsize, int32 honor, bool pvptoken) { // do not reward honor in arenas, but enable onkill spellproc if (InArena()) { - if (!uVictim || uVictim == this || uVictim->GetTypeId() != TYPEID_PLAYER) + if (!victim || victim == this || victim->GetTypeId() != TYPEID_PLAYER) return false; - if (GetBGTeam() == uVictim->ToPlayer()->GetBGTeam()) + if (GetBGTeam() == victim->ToPlayer()->GetBGTeam()) return false; return true; } - // 'Inactive' this aura prevents the player from gaining honor points and battleground tokens + // 'Inactive' this aura prevents the player from gaining honor points and battleground Tokenizer if (HasAura(SPELL_AURA_PLAYER_INACTIVE)) return false; @@ -7136,16 +7144,14 @@ bool Player::RewardHonor(Unit* uVictim, uint32 groupsize, int32 honor, bool pvpt if (honor_f <= 0) { - if (!uVictim || uVictim == this || uVictim->HasAuraType(SPELL_AURA_NO_PVP_CREDIT)) + if (!victim || victim == this || victim->HasAuraType(SPELL_AURA_NO_PVP_CREDIT)) return false; - victim_guid = uVictim->GetGUID(); + victim_guid = victim->GetGUID(); - if (uVictim->GetTypeId() == TYPEID_PLAYER) + if (Player* plrVictim = victim->ToPlayer()) { - Player* victim = uVictim->ToPlayer(); - - if (GetTeam() == victim->GetTeam() && !sWorld->IsFFAPvPRealm()) + if (GetTeam() == plrVictim->GetTeam() && !sWorld->IsFFAPvPRealm()) return false; uint8 k_level = getLevel(); @@ -7190,7 +7196,7 @@ bool Player::RewardHonor(Unit* uVictim, uint32 groupsize, int32 honor, bool pvpt } else { - if (!uVictim->ToCreature()->isRacialLeader()) + if (!victim->ToCreature()->isRacialLeader()) return false; honor_f = 100.0f; // ??? need more info @@ -7198,7 +7204,7 @@ bool Player::RewardHonor(Unit* uVictim, uint32 groupsize, int32 honor, bool pvpt } } - if (uVictim != NULL) + if (victim != NULL) { if (groupsize > 1) honor_f /= groupsize; @@ -7216,9 +7222,9 @@ bool Player::RewardHonor(Unit* uVictim, uint32 groupsize, int32 honor, bool pvpt // victim_rank [5..19] HK: <alliance\horde rank> // victim_rank [0, 20+] HK: <> WorldPacket data(SMSG_PVP_CREDIT, 4+8+4); - data << honor; - data << victim_guid; - data << victim_rank; + data << uint32(honor); + data << uint64(victim_guid); + data << uint32(victim_rank); GetSession()->SendPacket(&data); @@ -7237,10 +7243,10 @@ bool Player::RewardHonor(Unit* uVictim, uint32 groupsize, int32 honor, bool pvpt if (sWorld->getBoolConfig(CONFIG_PVP_TOKEN_ENABLE) && pvptoken) { - if (!uVictim || uVictim == this || uVictim->HasAuraType(SPELL_AURA_NO_PVP_CREDIT)) + if (!victim || victim == this || victim->HasAuraType(SPELL_AURA_NO_PVP_CREDIT)) return true; - if (uVictim->GetTypeId() == TYPEID_PLAYER) + if (victim->GetTypeId() == TYPEID_PLAYER) { // Check if allowed to receive it in current map uint8 MapType = sWorld->getIntConfig(CONFIG_PVP_TOKEN_MAP_TYPE); @@ -7443,6 +7449,8 @@ void Player::UpdateZone(uint32 newZone, uint32 newArea) sBattlefieldMgr->HandlePlayerLeaveZone(this, m_zoneUpdateId); sBattlefieldMgr->HandlePlayerEnterZone(this, newZone); SendInitWorldStates(newZone, newArea); // only if really enters to new zone, not just area change, works strange... + if (Guild* guild = GetGuild()) + guild->UpdateMemberData(this, GUILD_MEMBER_DATA_ZONEID, newZone); } // group update @@ -7597,7 +7605,7 @@ void Player::DuelComplete(DuelCompleteType type) if (!duel) return; - sLog->outDebug(LOG_FILTER_UNITS, "Duel Complete %s %s", GetName(), duel->opponent->GetName()); + sLog->outDebug(LOG_FILTER_UNITS, "Duel Complete %s %s", GetName().c_str(), duel->opponent->GetName().c_str()); WorldPacket data(SMSG_DUEL_COMPLETE, (1)); data << (uint8)((type != DUEL_INTERRUPTED) ? 1 : 0); @@ -8386,7 +8394,7 @@ void Player::CastItemCombatSpell(Unit* target, WeaponAttackType attType, uint32 if (!spellInfo) { sLog->outError(LOG_FILTER_PLAYER_ITEMS, "Player::CastItemCombatSpell(GUID: %u, name: %s, enchant: %i): unknown spell %i is casted, ignoring...", - GetGUIDLow(), GetName(), pEnchant->ID, pEnchant->spellid[s]); + GetGUIDLow(), GetName().c_str(), pEnchant->ID, pEnchant->spellid[s]); continue; } @@ -11627,7 +11635,7 @@ InventoryResult Player::CanBankItem(uint8 bag, uint8 slot, ItemPosCountVec &dest if (pItemslot >= CURRENCYTOKEN_SLOT_START && pItemslot < CURRENCYTOKEN_SLOT_END) { sLog->outError(LOG_FILTER_PLAYER, "Possible hacking attempt: Player %s [guid: %u] tried to move token [guid: %u, entry: %u] out of the currency bag!", - GetName(), GetGUIDLow(), pItem->GetGUIDLow(), pProto->ItemId); + GetName().c_str(), GetGUIDLow(), pItem->GetGUIDLow(), pProto->ItemId); return EQUIP_ERR_ITEMS_CANT_BE_SWAPPED; } @@ -15711,7 +15719,7 @@ void Player::SetQuestStatus(uint32 quest_id, QuestStatus status) } uint32 zone = 0, area = 0; - + SpellAreaForQuestMapBounds saBounds = sSpellMgr->GetSpellAreaForQuestMapBounds(quest_id); if (saBounds.first != saBounds.second) { @@ -15722,7 +15730,7 @@ void Player::SetQuestStatus(uint32 quest_id, QuestStatus status) if (!HasAura(itr->second->spellId)) CastSpell(this, itr->second->spellId, true); } - + saBounds = sSpellMgr->GetSpellAreaForQuestEndMapBounds(quest_id); if (saBounds.first != saBounds.second) { @@ -16967,7 +16975,7 @@ bool Player::LoadFromDB(uint32 guid, SQLQueryHolder *holder) { if (GetSession()->Expansion() < mapEntry->Expansion()) { - sLog->outDebug(LOG_FILTER_PLAYER_LOADING, "Player %s using client without required expansion tried login at non accessible map %u", GetName(), mapId); + sLog->outDebug(LOG_FILTER_PLAYER_LOADING, "Player %s using client without required expansion tried login at non accessible map %u", GetName().c_str(), mapId); RelocateToHomebind(); } @@ -17022,7 +17030,7 @@ bool Player::LoadFromDB(uint32 guid, SQLQueryHolder *holder) Relocate(at->target_X, at->target_Y, at->target_Z, at->target_Orientation); else { - sLog->outError(LOG_FILTER_PLAYER, "Player %s(GUID: %u) logged in to a reset instance (map: %u) and there is no area-trigger leading to this map. Thus he can't be ported back to the entrance. This _might_ be an exploit attempt.", GetName(), GetGUIDLow(), mapId); + sLog->outError(LOG_FILTER_PLAYER, "Player %s(GUID: %u) logged in to a reset instance (map: %u) and there is no area-trigger leading to this map. Thus he can't be ported back to the entrance. This _might_ be an exploit attempt.", GetName().c_str(), GetGUIDLow(), mapId); RelocateToHomebind(); } } @@ -17057,7 +17065,7 @@ bool Player::LoadFromDB(uint32 guid, SQLQueryHolder *holder) m_resetTalentsCost = fields[24].GetUInt32(); m_resetTalentsTime = time_t(fields[25].GetUInt32()); - m_taxi.LoadTaxiMask(fields[17].GetCString()); // must be before InitTaxiNodesForLevel + m_taxi.LoadTaxiMask(fields[17].GetString()); // must be before InitTaxiNodesForLevel uint32 extraflags = fields[31].GetUInt16(); @@ -17142,7 +17150,7 @@ bool Player::LoadFromDB(uint32 guid, SQLQueryHolder *holder) if (m_specsCount > MAX_TALENT_SPECS || m_activeSpec > MAX_TALENT_SPEC || m_specsCount < MIN_TALENT_SPECS) { m_activeSpec = 0; - sLog->outError(LOG_FILTER_PLAYER, "Player %s(GUID: %u) has SpecCount = %u and ActiveSpec = %u.", GetName(), GetGUIDLow(), m_specsCount, m_activeSpec); + sLog->outError(LOG_FILTER_PLAYER, "Player %s(GUID: %u) has SpecCount = %u and ActiveSpec = %u.", GetName().c_str(), GetGUIDLow(), m_specsCount, m_activeSpec); } _LoadTalents(holder->GetPreparedResult(PLAYER_LOGIN_QUERY_LOADTALENTS)); @@ -17565,7 +17573,7 @@ void Player::_LoadInventory(PreparedQueryResult result, uint32 timeDiff) else { sLog->outError(LOG_FILTER_PLAYER, "Player::_LoadInventory: player (GUID: %u, name: '%s') has item (GUID: %u, entry: %u) which doesnt have a valid bag (Bag GUID: %u, slot: %u). Possible cheat?", - GetGUIDLow(), GetName(), item->GetGUIDLow(), item->GetEntry(), bagGuid, slot); + GetGUIDLow(), GetName().c_str(), item->GetGUIDLow(), item->GetEntry(), bagGuid, slot); item->DeleteFromInventoryDB(trans); delete item; continue; @@ -17579,7 +17587,7 @@ void Player::_LoadInventory(PreparedQueryResult result, uint32 timeDiff) else { sLog->outError(LOG_FILTER_PLAYER, "Player::_LoadInventory: player (GUID: %u, name: '%s') has item (GUID: %u, entry: %u) which can't be loaded into inventory (Bag GUID: %u, slot: %u) by reason %u. Item will be sent by mail.", - GetGUIDLow(), GetName(), item->GetGUIDLow(), item->GetEntry(), bagGuid, slot, err); + GetGUIDLow(), GetName().c_str(), item->GetGUIDLow(), item->GetEntry(), bagGuid, slot, err); item->DeleteFromInventoryDB(trans); problematicItems.push_back(item); } @@ -17624,14 +17632,14 @@ Item* Player::_LoadItem(SQLTransaction& trans, uint32 zoneId, uint32 timeDiff, F if (isAlive() && item->IsLimitedToAnotherMapOrZone(GetMapId(), zoneId)) { sLog->outDebug(LOG_FILTER_PLAYER_LOADING, "Player::_LoadInventory: player (GUID: %u, name: '%s', map: %u) has item (GUID: %u, entry: %u) limited to another map (%u). Deleting item.", - GetGUIDLow(), GetName(), GetMapId(), item->GetGUIDLow(), item->GetEntry(), zoneId); + GetGUIDLow(), GetName().c_str(), GetMapId(), item->GetGUIDLow(), item->GetEntry(), zoneId); remove = true; } // "Conjured items disappear if you are logged out for more than 15 minutes" else if (timeDiff > 15 * MINUTE && proto->Flags & ITEM_PROTO_FLAG_CONJURED) { sLog->outDebug(LOG_FILTER_PLAYER_LOADING, "Player::_LoadInventory: player (GUID: %u, name: '%s', diff: %u) has conjured item (GUID: %u, entry: %u) with expired lifetime (15 minutes). Deleting item.", - GetGUIDLow(), GetName(), timeDiff, item->GetGUIDLow(), item->GetEntry()); + GetGUIDLow(), GetName().c_str(), timeDiff, item->GetGUIDLow(), item->GetEntry()); remove = true; } else if (item->HasFlag(ITEM_FIELD_FLAGS, ITEM_FLAG_REFUNDABLE)) @@ -17639,7 +17647,7 @@ Item* Player::_LoadItem(SQLTransaction& trans, uint32 zoneId, uint32 timeDiff, F if (item->GetPlayedTime() > (2 * HOUR)) { sLog->outDebug(LOG_FILTER_PLAYER_LOADING, "Player::_LoadInventory: player (GUID: %u, name: '%s') has item (GUID: %u, entry: %u) with expired refund time (%u). Deleting refund data and removing refundable flag.", - GetGUIDLow(), GetName(), item->GetGUIDLow(), item->GetEntry(), item->GetPlayedTime()); + GetGUIDLow(), GetName().c_str(), item->GetGUIDLow(), item->GetEntry(), item->GetPlayedTime()); stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_ITEM_REFUND_INSTANCE); stmt->setUInt32(0, item->GetGUIDLow()); @@ -17662,7 +17670,7 @@ Item* Player::_LoadItem(SQLTransaction& trans, uint32 zoneId, uint32 timeDiff, F else { sLog->outDebug(LOG_FILTER_PLAYER_LOADING, "Player::_LoadInventory: player (GUID: %u, name: '%s') has item (GUID: %u, entry: %u) with refundable flags, but without data in item_refund_instance. Removing flag.", - GetGUIDLow(), GetName(), item->GetGUIDLow(), item->GetEntry()); + GetGUIDLow(), GetName().c_str(), item->GetGUIDLow(), item->GetEntry()); item->RemoveFlag(ITEM_FIELD_FLAGS, ITEM_FLAG_REFUNDABLE); } } @@ -17684,7 +17692,7 @@ Item* Player::_LoadItem(SQLTransaction& trans, uint32 zoneId, uint32 timeDiff, F else { sLog->outDebug(LOG_FILTER_PLAYER_LOADING, "Player::_LoadInventory: player (GUID: %u, name: '%s') has item (GUID: %u, entry: %u) with ITEM_FLAG_BOP_TRADEABLE flag, but without data in item_soulbound_trade_data. Removing flag.", - GetGUIDLow(), GetName(), item->GetGUIDLow(), item->GetEntry()); + GetGUIDLow(), GetName().c_str(), item->GetGUIDLow(), item->GetEntry()); item->RemoveFlag(ITEM_FIELD_FLAGS, ITEM_FLAG_BOP_TRADEABLE); } } @@ -17706,7 +17714,7 @@ Item* Player::_LoadItem(SQLTransaction& trans, uint32 zoneId, uint32 timeDiff, F else { sLog->outError(LOG_FILTER_PLAYER, "Player::_LoadInventory: player (GUID: %u, name: '%s') has broken item (GUID: %u, entry: %u) in inventory. Deleting item.", - GetGUIDLow(), GetName(), itemGuid, itemEntry); + GetGUIDLow(), GetName().c_str(), itemGuid, itemEntry); remove = true; } // Remove item from inventory if necessary @@ -17721,7 +17729,7 @@ Item* Player::_LoadItem(SQLTransaction& trans, uint32 zoneId, uint32 timeDiff, F else { sLog->outError(LOG_FILTER_PLAYER, "Player::_LoadInventory: player (GUID: %u, name: '%s') has unknown item (entry: %u) in inventory. Deleting item.", - GetGUIDLow(), GetName(), itemEntry); + GetGUIDLow(), GetName().c_str(), itemEntry); Item::DeleteFromInventoryDB(trans, itemGuid); Item::DeleteFromDB(trans, itemGuid); } @@ -17888,7 +17896,7 @@ void Player::_LoadQuestStatus(PreparedQueryResult result) { questStatusData.Status = QUEST_STATUS_INCOMPLETE; sLog->outError(LOG_FILTER_PLAYER, "Player %s (GUID: %u) has invalid quest %d status (%u), replaced by QUEST_STATUS_INCOMPLETE(3).", - GetName(), GetGUIDLow(), quest_id, qstatus); + GetName().c_str(), GetGUIDLow(), quest_id, qstatus); } questStatusData.Explored = (fields[2].GetUInt8() > 0); @@ -18142,12 +18150,12 @@ void Player::_LoadBoundInstances(PreparedQueryResult result) MapEntry const* mapEntry = sMapStore.LookupEntry(mapId); if (!mapEntry || !mapEntry->IsDungeon()) { - sLog->outError(LOG_FILTER_PLAYER, "_LoadBoundInstances: player %s(%d) has bind to not existed or not dungeon map %d", GetName(), GetGUIDLow(), mapId); + sLog->outError(LOG_FILTER_PLAYER, "_LoadBoundInstances: player %s(%d) has bind to not existed or not dungeon map %d", GetName().c_str(), GetGUIDLow(), mapId); deleteInstance = true; } else if (difficulty >= MAX_DIFFICULTY) { - sLog->outError(LOG_FILTER_PLAYER, "_LoadBoundInstances: player %s(%d) has bind to not existed difficulty %d instance for map %u", GetName(), GetGUIDLow(), difficulty, mapId); + sLog->outError(LOG_FILTER_PLAYER, "_LoadBoundInstances: player %s(%d) has bind to not existed difficulty %d instance for map %u", GetName().c_str(), GetGUIDLow(), difficulty, mapId); deleteInstance = true; } else @@ -18155,12 +18163,12 @@ void Player::_LoadBoundInstances(PreparedQueryResult result) MapDifficulty const* mapDiff = GetMapDifficultyData(mapId, Difficulty(difficulty)); if (!mapDiff) { - sLog->outError(LOG_FILTER_PLAYER, "_LoadBoundInstances: player %s(%d) has bind to not existed difficulty %d instance for map %u", GetName(), GetGUIDLow(), difficulty, mapId); + sLog->outError(LOG_FILTER_PLAYER, "_LoadBoundInstances: player %s(%d) has bind to not existed difficulty %d instance for map %u", GetName().c_str(), GetGUIDLow(), difficulty, mapId); deleteInstance = true; } else if (!perm && group) { - sLog->outError(LOG_FILTER_PLAYER, "_LoadBoundInstances: player %s(%d) is in group %d but has a non-permanent character bind to map %d, %d, %d", GetName(), GetGUIDLow(), GUID_LOPART(group->GetGUID()), mapId, instanceId, difficulty); + sLog->outError(LOG_FILTER_PLAYER, "_LoadBoundInstances: player %s(%d) is in group %d but has a non-permanent character bind to map %d, %d, %d", GetName().c_str(), GetGUIDLow(), GUID_LOPART(group->GetGUID()), mapId, instanceId, difficulty); deleteInstance = true; } } @@ -18285,7 +18293,7 @@ InstancePlayerBind* Player::BindToInstance(InstanceSave* save, bool permanent, b bind.save = save; bind.perm = permanent; if (!load) - sLog->outDebug(LOG_FILTER_MAPS, "Player::BindToInstance: %s(%d) is now bound to map %d, instance %d, difficulty %d", GetName(), GetGUIDLow(), save->GetMapId(), save->GetInstanceId(), save->GetDifficulty()); + sLog->outDebug(LOG_FILTER_MAPS, "Player::BindToInstance: %s(%d) is now bound to map %d, instance %d, difficulty %d", GetName().c_str(), GetGUIDLow(), save->GetMapId(), save->GetInstanceId(), save->GetDifficulty()); sScriptMgr->OnPlayerBindToInstance(this, save->GetDifficulty(), save->GetMapId(), permanent); return &bind; } @@ -18426,11 +18434,11 @@ bool Player::Satisfy(AccessRequirement const* ar, uint32 target_map, bool report uint32 missingItem = 0; if (ar->item) { - if (!HasItemCount(ar->item, 1) && - (!ar->item2 || !HasItemCount(ar->item2, 1))) + if (!HasItemCount(ar->item) && + (!ar->item2 || !HasItemCount(ar->item2))) missingItem = ar->item; } - else if (ar->item2 && !HasItemCount(ar->item2, 1)) + else if (ar->item2 && !HasItemCount(ar->item2)) missingItem = ar->item2; if (DisableMgr::IsDisabledFor(DISABLE_TYPE_MAP, target_map, this)) @@ -18506,7 +18514,7 @@ bool Player::_LoadHomeBind(PreparedQueryResult result) PlayerInfo const* info = sObjectMgr->GetPlayerInfo(getRace(), getClass()); if (!info) { - sLog->outError(LOG_FILTER_PLAYER, "Player (Name %s) has incorrect race/class pair. Can't be loaded.", GetName()); + sLog->outError(LOG_FILTER_PLAYER, "Player (Name %s) has incorrect race/class pair. Can't be loaded.", GetName().c_str()); return false; } @@ -19029,7 +19037,7 @@ void Player::_SaveInventory(SQLTransaction& trans) uint32 bagTestGUID = 0; if (Item* test2 = GetItemByPos(INVENTORY_SLOT_BAG_0, item->GetBagSlot())) bagTestGUID = test2->GetGUIDLow(); - sLog->outError(LOG_FILTER_PLAYER, "Player(GUID: %u Name: %s)::_SaveInventory - the bag(%u) and slot(%u) values for the item with guid %u (state %d) are incorrect, the player doesn't have an item at that position!", lowGuid, GetName(), item->GetBagSlot(), item->GetSlot(), item->GetGUIDLow(), (int32)item->GetState()); + sLog->outError(LOG_FILTER_PLAYER, "Player(GUID: %u Name: %s)::_SaveInventory - the bag(%u) and slot(%u) values for the item with guid %u (state %d) are incorrect, the player doesn't have an item at that position!", lowGuid, GetName().c_str(), item->GetBagSlot(), item->GetSlot(), item->GetGUIDLow(), (int32)item->GetState()); // according to the test that was just performed nothing should be in this slot, delete stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_INVENTORY_BY_BAG_SLOT); stmt->setUInt32(0, bagTestGUID); @@ -19045,7 +19053,7 @@ void Player::_SaveInventory(SQLTransaction& trans) } else if (test != item) { - sLog->outError(LOG_FILTER_PLAYER, "Player(GUID: %u Name: %s)::_SaveInventory - the bag(%u) and slot(%u) values for the item with guid %u are incorrect, the item with guid %u is there instead!", lowGuid, GetName(), item->GetBagSlot(), item->GetSlot(), item->GetGUIDLow(), test->GetGUIDLow()); + sLog->outError(LOG_FILTER_PLAYER, "Player(GUID: %u Name: %s)::_SaveInventory - the bag(%u) and slot(%u) values for the item with guid %u are incorrect, the item with guid %u is there instead!", lowGuid, GetName().c_str(), item->GetBagSlot(), item->GetSlot(), item->GetGUIDLow(), test->GetGUIDLow()); // save all changes to the item... if (item->GetState() != ITEM_NEW) // only for existing items, no dupes item->SaveToDB(trans); @@ -19877,7 +19885,7 @@ void Player::StopCastingCharm() if (GetCharmGUID()) { - sLog->outFatal(LOG_FILTER_PLAYER, "Player %s (GUID: " UI64FMTD " is not able to uncharm unit (GUID: " UI64FMTD " Entry: %u, Type: %u)", GetName(), GetGUID(), GetCharmGUID(), charm->GetEntry(), charm->GetTypeId()); + sLog->outFatal(LOG_FILTER_PLAYER, "Player %s (GUID: " UI64FMTD " is not able to uncharm unit (GUID: " UI64FMTD " Entry: %u, Type: %u)", GetName().c_str(), GetGUID(), GetCharmGUID(), charm->GetEntry(), charm->GetTypeId()); if (charm->GetCharmerGUID()) { sLog->outFatal(LOG_FILTER_PLAYER, "Charmed unit has charmer guid " UI64FMTD, charm->GetCharmerGUID()); @@ -19959,7 +19967,7 @@ void Player::Whisper(const std::string& text, uint32 language, uint64 receiver) } else if (!isAddonMessage) // announce to player that player he is whispering to is dnd and cannot receive his message - ChatHandler(this).PSendSysMessage(LANG_PLAYER_DND, rPlayer->GetName(), rPlayer->dndMsg.c_str()); + ChatHandler(this).PSendSysMessage(LANG_PLAYER_DND, rPlayer->GetName().c_str(), rPlayer->dndMsg.c_str()); // rest stuff shouldn't happen in case of addon message if (isAddonMessage) @@ -19973,7 +19981,7 @@ void Player::Whisper(const std::string& text, uint32 language, uint64 receiver) // announce to player that player he is whispering to is afk if (rPlayer->isAFK()) - ChatHandler(this).PSendSysMessage(LANG_PLAYER_AFK, rPlayer->GetName(), rPlayer->afkMsg.c_str()); + ChatHandler(this).PSendSysMessage(LANG_PLAYER_AFK, rPlayer->GetName().c_str(), rPlayer->afkMsg.c_str()); // if player whisper someone, auto turn of dnd to be able to receive an answer if (isDND() && !rPlayer->isGameMaster()) @@ -21094,7 +21102,7 @@ bool Player::BuyItemFromVendorSlot(uint64 vendorguid, uint32 vendorslot, uint32 uint32 maxCount = MAX_MONEY_AMOUNT / pProto->BuyPrice; if ((uint32)count > maxCount) { - sLog->outError(LOG_FILTER_PLAYER, "Player %s tried to buy %u item id %u, causing overflow", GetName(), (uint32)count, pProto->ItemId); + sLog->outError(LOG_FILTER_PLAYER, "Player %s tried to buy %u item id %u, causing overflow", GetName().c_str(), (uint32)count, pProto->ItemId); count = (uint8)maxCount; } price = pProto->BuyPrice * count; //it should not exceed MAX_MONEY_AMOUNT @@ -21188,7 +21196,7 @@ void Player::UpdateHomebindTime(uint32 time) data << uint32(m_HomebindTimer); data << uint32(1); GetSession()->SendPacket(&data); - sLog->outDebug(LOG_FILTER_MAPS, "PLAYER: Player '%s' (GUID: %u) will be teleported to homebind in 60 seconds", GetName(), GetGUIDLow()); + sLog->outDebug(LOG_FILTER_MAPS, "PLAYER: Player '%s' (GUID: %u) will be teleported to homebind in 60 seconds", GetName().c_str(), GetGUIDLow()); } } @@ -21514,7 +21522,7 @@ void Player::ToggleMetaGemsActive(uint8 exceptslot, bool apply) //cycle all equipped items for (int slot = EQUIPMENT_SLOT_START; slot < EQUIPMENT_SLOT_END; ++slot) { - //enchants for the slot being socketed are handled by WorldSession::HandleSocketOpcode(WorldPacket& recv_data) + //enchants for the slot being socketed are handled by WorldSession::HandleSocketOpcode(WorldPacket& recvData) if (slot == exceptslot) continue; @@ -22909,7 +22917,7 @@ uint32 Player::GetResurrectionSpellId() } // Reincarnation (passive spell) // prio: 1 // Glyph of Renewed Life - if (prio < 1 && HasSpell(20608) && !HasSpellCooldown(21169) && (HasAura(58059) || HasItemCount(17030, 1))) + if (prio < 1 && HasSpell(20608) && !HasSpellCooldown(21169) && (HasAura(58059) || HasItemCount(17030))) spell_id = 21169; return spell_id; @@ -23460,11 +23468,11 @@ void Player::SetViewpoint(WorldObject* target, bool apply) { if (apply) { - sLog->outDebug(LOG_FILTER_MAPS, "Player::CreateViewpoint: Player %s create seer %u (TypeId: %u).", GetName(), target->GetEntry(), target->GetTypeId()); + sLog->outDebug(LOG_FILTER_MAPS, "Player::CreateViewpoint: Player %s create seer %u (TypeId: %u).", GetName().c_str(), target->GetEntry(), target->GetTypeId()); if (!AddUInt64Value(PLAYER_FARSIGHT, target->GetGUID())) { - sLog->outFatal(LOG_FILTER_PLAYER, "Player::CreateViewpoint: Player %s cannot add new viewpoint!", GetName()); + sLog->outFatal(LOG_FILTER_PLAYER, "Player::CreateViewpoint: Player %s cannot add new viewpoint!", GetName().c_str()); return; } @@ -23476,11 +23484,11 @@ void Player::SetViewpoint(WorldObject* target, bool apply) } else { - sLog->outDebug(LOG_FILTER_MAPS, "Player::CreateViewpoint: Player %s remove seer", GetName()); + sLog->outDebug(LOG_FILTER_MAPS, "Player::CreateViewpoint: Player %s remove seer", GetName().c_str()); if (!RemoveUInt64Value(PLAYER_FARSIGHT, target->GetGUID())) { - sLog->outFatal(LOG_FILTER_PLAYER, "Player::CreateViewpoint: Player %s cannot remove current viewpoint!", GetName()); + sLog->outFatal(LOG_FILTER_PLAYER, "Player::CreateViewpoint: Player %s cannot remove current viewpoint!", GetName().c_str()); return; } @@ -23504,11 +23512,15 @@ WorldObject* Player::GetViewpoint() const bool Player::CanUseBattlegroundObject(GameObject* gameobject) { - FactionTemplateEntry const* playerFaction = getFactionTemplateEntry(); - FactionTemplateEntry const* faction = sFactionTemplateStore.LookupEntry(gameobject->GetUInt32Value(GAMEOBJECT_FACTION)); + // It is possible to call this method with a null pointer, only skipping faction check. + if (gameobject) + { + FactionTemplateEntry const* playerFaction = getFactionTemplateEntry(); + FactionTemplateEntry const* faction = sFactionTemplateStore.LookupEntry(gameobject->GetUInt32Value(GAMEOBJECT_FACTION)); - if (playerFaction && faction && !playerFaction->IsFriendlyTo(*faction)) - return false; + if (playerFaction && faction && !playerFaction->IsFriendlyTo(*faction)) + return false; + } // BUG: sometimes when player clicks on flag in AB - client won't send gameobject_use, only gameobject_report_use packet // Note: Mount, stealth and invisibility will be removed when used @@ -23520,9 +23532,8 @@ bool Player::CanUseBattlegroundObject(GameObject* gameobject) bool Player::CanCaptureTowerPoint() { return (!HasStealthAura() && // not stealthed - !HasInvisibilityAura() && // not invisible - isAlive() // live player -); + !HasInvisibilityAura() && // not invisible + isAlive()); // live player } uint32 Player::GetBarberShopCost(uint8 newhairstyle, uint8 newhaircolor, uint8 newfacialhair, BarberShopStyleEntry const* newSkin) @@ -24775,7 +24786,7 @@ void Player::SetEquipmentSet(uint32 index, EquipmentSet eqset) if (!found) // something wrong... { - sLog->outError(LOG_FILTER_PLAYER, "Player %s tried to save equipment set "UI64FMTD" (index %u), but that equipment set not found!", GetName(), eqset.Guid, index); + sLog->outError(LOG_FILTER_PLAYER, "Player %s tried to save equipment set "UI64FMTD" (index %u), but that equipment set not found!", GetName().c_str(), eqset.Guid, index); return; } } @@ -25237,12 +25248,12 @@ void Player::SetReputation(uint32 factionentry, uint32 value) { GetReputationMgr().SetReputation(sFactionStore.LookupEntry(factionentry), value); } -uint32 Player::GetReputation(uint32 factionentry) +uint32 Player::GetReputation(uint32 factionentry) const { return GetReputationMgr().GetReputation(sFactionStore.LookupEntry(factionentry)); } -std::string Player::GetGuildName() +std::string const& Player::GetGuildName() { return sGuildMgr->GetGuildById(GetGuildId())->GetName(); } @@ -25577,3 +25588,9 @@ void Player::SendMovementSetFeatherFall(bool apply) data << uint32(0); //! movement counter SendDirectMessage(&data); } + +Guild* Player::GetGuild() +{ + uint32 guildId = GetGuildId(); + return guildId ? sGuildMgr->GetGuildById(guildId) : NULL; +} diff --git a/src/server/game/Entities/Player/Player.h b/src/server/game/Entities/Player/Player.h index 9d80a17bc5e..fe1d1a5b798 100755 --- a/src/server/game/Entities/Player/Player.h +++ b/src/server/game/Entities/Player/Player.h @@ -46,6 +46,7 @@ class Channel; class Creature; class DynamicObject; class Group; +class Guild; class OutdoorPvP; class Pet; class PlayerMenu; @@ -911,7 +912,7 @@ class PlayerTaxi ~PlayerTaxi() {} // Nodes void InitTaxiNodesForLevel(uint32 race, uint32 chrClass, uint8 level); - void LoadTaxiMask(const char* data); + void LoadTaxiMask(std::string const& data); bool IsTaximaskNodeKnown(uint32 nodeidx) const { @@ -934,7 +935,7 @@ class PlayerTaxi void AppendTaximaskTo(ByteBuffer& data, bool all); // Destinations - bool LoadTaxiDestinationsFromString(const std::string& values, uint32 team); + bool LoadTaxiDestinationsFromString(std::string const& values, uint32 team); std::string SaveTaxiDestinationsToString(); void ClearTaxiDestinations() { m_TaxiDestinations.clear(); } @@ -1198,11 +1199,11 @@ class Player : public Unit, public GridObject<Player> void RemovePet(Pet* pet, PetSaveMode mode, bool returnreagent = false); uint32 GetPhaseMaskForSpawn() const; // used for proper set phase for DB at GM-mode creature/GO spawn - 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 BuildPlayerChat(WorldPacket* data, uint8 msgtype, const std::string& text, uint32 language) const; + void Say(std::string const& text, const uint32 language); + void Yell(std::string const& text, const uint32 language); + void TextEmote(std::string const& text); + void Whisper(std::string const& text, const uint32 language, uint64 receiver); + void BuildPlayerChat(WorldPacket* data, uint8 msgtype, std::string const& text, uint32 language) const; /*********************************************************/ /*** STORAGE SYSTEM ***/ @@ -1239,7 +1240,7 @@ class Player : public Unit, public GridObject<Player> bool IsValidPos(uint8 bag, uint8 slot, bool explicit_pos); uint8 GetBankBagSlotCount() const { return GetByteValue(PLAYER_BYTES_2, 2); } void SetBankBagSlotCount(uint8 count) { SetByteValue(PLAYER_BYTES_2, 2, count); } - bool HasItemCount(uint32 item, uint32 count, bool inBankAlso = false) const; + bool HasItemCount(uint32 item, uint32 count = 1, bool inBankAlso = false) const; bool HasItemFitToSpellRequirements(SpellInfo const* spellInfo, Item const* ignoreItem = NULL); bool CanNoReagentCast(SpellInfo const* spellInfo) const; bool HasItemOrGemWithIdEquipped(uint32 item, uint32 count, uint8 except_slot = NULL_SLOT) const; @@ -1256,7 +1257,6 @@ class Player : public Unit, public GridObject<Player> return EQUIP_ERR_ITEM_NOT_FOUND; uint32 count = pItem->GetCount(); return CanStoreItem(bag, slot, dest, pItem->GetEntry(), count, pItem, swap, NULL); - } InventoryResult CanStoreItems(Item** pItem, int count) const; InventoryResult CanEquipNewItem(uint8 slot, uint16& dest, uint32 item, bool swap) const; @@ -1661,8 +1661,8 @@ class Player : public Unit, public GridObject<Player> void AddTemporarySpell(uint32 spellId); void RemoveTemporarySpell(uint32 spellId); void SetReputation(uint32 factionentry, uint32 value); - uint32 GetReputation(uint32 factionentry); - std::string GetGuildName(); + uint32 GetReputation(uint32 factionentry) const; + std::string const& GetGuildName(); uint32 GetFreeTalentPoints() const { return GetUInt32Value(PLAYER_CHARACTER_POINTS1); } void SetFreeTalentPoints(uint32 points); bool resetTalents(bool no_cost = false); @@ -1820,9 +1820,10 @@ class Player : public Unit, public GridObject<Player> void SetInGuild(uint32 GuildId) { SetUInt32Value(PLAYER_GUILDID, GuildId); } void SetRank(uint8 rankId) { SetUInt32Value(PLAYER_GUILDRANK, rankId); } - uint8 GetRank() { return uint8(GetUInt32Value(PLAYER_GUILDRANK)); } + uint8 GetRank() const { return uint8(GetUInt32Value(PLAYER_GUILDRANK)); } void SetGuildIdInvited(uint32 GuildId) { m_GuildIdInvited = GuildId; } - uint32 GetGuildId() { return GetUInt32Value(PLAYER_GUILDID); } + uint32 GetGuildId() const { return GetUInt32Value(PLAYER_GUILDID); } + Guild* GetGuild(); static uint32 GetGuildIdFromDB(uint64 guid); static uint8 GetRankFromDB(uint64 guid); int GetGuildIdInvited() { return m_GuildIdInvited; } diff --git a/src/server/game/Entities/Player/SocialMgr.cpp b/src/server/game/Entities/Player/SocialMgr.cpp index 1ded8cda81b..bc16a7f42a2 100755 --- a/src/server/game/Entities/Player/SocialMgr.cpp +++ b/src/server/game/Entities/Player/SocialMgr.cpp @@ -182,9 +182,9 @@ void PlayerSocial::SendSocialList(Player* player) sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Sent SMSG_CONTACT_LIST"); } -bool PlayerSocial::HasFriend(uint32 friend_guid) +bool PlayerSocial::HasFriend(uint32 friendGuid) { - PlayerSocialMap::const_iterator itr = m_playerSocialMap.find(friend_guid); + PlayerSocialMap::const_iterator itr = m_playerSocialMap.find(friendGuid); if (itr != m_playerSocialMap.end()) return itr->second.Flags & SOCIAL_FLAG_FRIEND; return false; @@ -231,7 +231,7 @@ void SocialMgr::GetFriendInfo(Player* player, uint32 friendGUID, FriendInfo &fri // PLAYER see his team only and PLAYER can't see MODERATOR, GAME MASTER, ADMINISTRATOR characters // MODERATOR, GAME MASTER, ADMINISTRATOR can see all - if (pFriend && pFriend->GetName() && + if (pFriend && (!AccountMgr::IsPlayerAccount(security) || ((pFriend->GetTeam() == team || allowTwoSideWhoList) && (pFriend->GetSession()->GetSecurity() <= gmLevelInWhoList))) && pFriend->IsVisibleGloballyFor(player)) @@ -249,18 +249,18 @@ void SocialMgr::GetFriendInfo(Player* player, uint32 friendGUID, FriendInfo &fri void SocialMgr::MakeFriendStatusPacket(FriendsResult result, uint32 guid, WorldPacket* data) { - data->Initialize(SMSG_FRIEND_STATUS, 5); + data->Initialize(SMSG_FRIEND_STATUS, 9); *data << uint8(result); *data << uint64(guid); } -void SocialMgr::SendFriendStatus(Player* player, FriendsResult result, uint32 friend_guid, bool broadcast) +void SocialMgr::SendFriendStatus(Player* player, FriendsResult result, uint32 friendGuid, bool broadcast) { FriendInfo fi; WorldPacket data; - MakeFriendStatusPacket(result, friend_guid, &data); - GetFriendInfo(player, friend_guid, fi); + MakeFriendStatusPacket(result, friendGuid, &data); + GetFriendInfo(player, friendGuid, fi); switch (result) { case FRIEND_ADDED_OFFLINE: @@ -329,7 +329,7 @@ PlayerSocial* SocialMgr::LoadFromDB(PreparedQueryResult result, uint32 guid) if (!result) return social; - uint32 friend_guid = 0; + uint32 friendGuid = 0; uint8 flags = 0; std::string note = ""; @@ -337,11 +337,11 @@ PlayerSocial* SocialMgr::LoadFromDB(PreparedQueryResult result, uint32 guid) { Field* fields = result->Fetch(); - friend_guid = fields[0].GetUInt32(); + friendGuid = fields[0].GetUInt32(); flags = fields[1].GetUInt8(); note = fields[2].GetString(); - social->m_playerSocialMap[friend_guid] = FriendInfo(flags, note); + social->m_playerSocialMap[friendGuid] = FriendInfo(flags, note); // client's friends list and ignore list limit if (social->m_playerSocialMap.size() >= (SOCIALMGR_FRIEND_LIMIT + SOCIALMGR_IGNORE_LIMIT)) @@ -351,4 +351,3 @@ PlayerSocial* SocialMgr::LoadFromDB(PreparedQueryResult result, uint32 guid) return social; } - diff --git a/src/server/game/Entities/Player/SocialMgr.h b/src/server/game/Entities/Player/SocialMgr.h index 99a40d6110f..85daf369f69 100755 --- a/src/server/game/Entities/Player/SocialMgr.h +++ b/src/server/game/Entities/Player/SocialMgr.h @@ -55,12 +55,10 @@ struct FriendInfo std::string Note; FriendInfo() : Status(FRIEND_STATUS_OFFLINE), Flags(0), Area(0), Level(0), Class(0), Note() - { - } + { } - FriendInfo(uint8 flags, const std::string& note) : Status(FRIEND_STATUS_OFFLINE), Flags(flags), Area(0), Level(0), Class(0), Note(note) - { - } + FriendInfo(uint8 flags, std::string const& note) : Status(FRIEND_STATUS_OFFLINE), Flags(flags), Area(0), Level(0), Class(0), Note(note) + { } }; typedef std::map<uint32, FriendInfo> PlayerSocialMap; @@ -149,4 +147,3 @@ class SocialMgr #define sSocialMgr ACE_Singleton<SocialMgr, ACE_Null_Mutex>::instance() #endif - diff --git a/src/server/game/Entities/Transport/Transport.cpp b/src/server/game/Entities/Transport/Transport.cpp index e7084353491..f52d0059a36 100755 --- a/src/server/game/Entities/Transport/Transport.cpp +++ b/src/server/game/Entities/Transport/Transport.cpp @@ -507,7 +507,7 @@ void Transport::TeleportTransport(uint32 newMapid, float x, float y, float z) bool Transport::AddPassenger(Player* passenger) { if (m_passengers.insert(passenger).second) - sLog->outInfo(LOG_FILTER_TRANSPORTS, "Player %s boarded transport %s.", passenger->GetName(), GetName()); + sLog->outInfo(LOG_FILTER_TRANSPORTS, "Player %s boarded transport %s.", passenger->GetName().c_str(), GetName().c_str()); sScriptMgr->OnAddPassenger(this, passenger); return true; @@ -516,7 +516,7 @@ bool Transport::AddPassenger(Player* passenger) bool Transport::RemovePassenger(Player* passenger) { if (m_passengers.erase(passenger)) - sLog->outInfo(LOG_FILTER_TRANSPORTS, "Player %s removed from transport %s.", passenger->GetName(), GetName()); + sLog->outInfo(LOG_FILTER_TRANSPORTS, "Player %s removed from transport %s.", passenger->GetName().c_str(), GetName().c_str()); sScriptMgr->OnRemovePassenger(this, passenger); return true; @@ -605,7 +605,7 @@ void Transport::DoEventIfAny(WayPointMap::value_type const& node, bool departure { if (uint32 eventid = departure ? node.second.departureEventID : node.second.arrivalEventID) { - sLog->outDebug(LOG_FILTER_MAPSCRIPTS, "Taxi %s event %u of node %u of %s path", departure ? "departure" : "arrival", eventid, node.first, GetName()); + sLog->outDebug(LOG_FILTER_MAPSCRIPTS, "Taxi %s event %u of node %u of %s path", departure ? "departure" : "arrival", eventid, node.first, GetName().c_str()); GetMap()->ScriptsStart(sEventScripts, eventid, this, this); EventInform(eventid); } diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp index 9e8ed7997e1..29afc0c1b36 100755 --- a/src/server/game/Entities/Unit/Unit.cpp +++ b/src/server/game/Entities/Unit/Unit.cpp @@ -6672,7 +6672,7 @@ bool Unit::HandleDummyAuraProc(Unit* victim, uint32 damage, AuraEffect* triggere victim->CastCustomSpell(beaconTarget, triggered_spell_id, &basepoints0, NULL, NULL, true, 0, triggeredByAura); return true; } - + return false; } // Judgements of the Wise @@ -9232,11 +9232,11 @@ FactionTemplateEntry const* Unit::getFactionTemplateEntry() const if (GetGUID() != guid) { if (Player const* player = ToPlayer()) - sLog->outError(LOG_FILTER_UNITS, "Player %s has invalid faction (faction template id) #%u", player->GetName(), getFaction()); + sLog->outError(LOG_FILTER_UNITS, "Player %s has invalid faction (faction template id) #%u", player->GetName().c_str(), getFaction()); else if (Creature const* creature = ToCreature()) sLog->outError(LOG_FILTER_UNITS, "Creature (template id: %u) has invalid faction (faction template id) #%u", creature->GetCreatureTemplate()->Entry, getFaction()); else - sLog->outError(LOG_FILTER_UNITS, "Unit (name=%s, type=%u) has invalid faction (faction template id) #%u", GetName(), uint32(GetTypeId()), getFaction()); + sLog->outError(LOG_FILTER_UNITS, "Unit (name=%s, type=%u) has invalid faction (faction template id) #%u", GetName().c_str(), uint32(GetTypeId()), getFaction()); guid = GetGUID(); } @@ -9982,7 +9982,7 @@ void Unit::SetCharm(Unit* charm, bool apply) if (GetTypeId() == TYPEID_PLAYER) { if (!AddUInt64Value(UNIT_FIELD_CHARM, charm->GetGUID())) - sLog->outFatal(LOG_FILTER_UNITS, "Player %s is trying to charm unit %u, but it already has a charmed unit " UI64FMTD "", GetName(), charm->GetEntry(), GetCharmGUID()); + sLog->outFatal(LOG_FILTER_UNITS, "Player %s is trying to charm unit %u, but it already has a charmed unit " UI64FMTD "", GetName().c_str(), charm->GetEntry(), GetCharmGUID()); charm->m_ControlledByPlayer = true; // TODO: maybe we can use this flag to check if controlled by player @@ -10011,7 +10011,7 @@ void Unit::SetCharm(Unit* charm, bool apply) if (GetTypeId() == TYPEID_PLAYER) { if (!RemoveUInt64Value(UNIT_FIELD_CHARM, charm->GetGUID())) - sLog->outFatal(LOG_FILTER_UNITS, "Player %s is trying to uncharm unit %u, but it has another charmed unit " UI64FMTD "", GetName(), charm->GetEntry(), GetCharmGUID()); + sLog->outFatal(LOG_FILTER_UNITS, "Player %s is trying to uncharm unit %u, but it has another charmed unit " UI64FMTD "", GetName().c_str(), charm->GetEntry(), GetCharmGUID()); } if (!charm->RemoveUInt64Value(UNIT_FIELD_CHARMEDBY, GetGUID())) @@ -17378,11 +17378,11 @@ void Unit::SendThreatListUpdate() WorldPacket data(SMSG_THREAT_UPDATE, 8 + count * 8); data.append(GetPackGUID()); data << uint32(count); - std::list<HostileReference*>& tlist = getThreatManager().getThreatList(); - for (std::list<HostileReference*>::const_iterator itr = tlist.begin(); itr != tlist.end(); ++itr) + ThreatContainer::StorageType const &tlist = getThreatManager().getThreatList(); + for (ThreatContainer::StorageType::const_iterator itr = tlist.begin(); itr != tlist.end(); ++itr) { data.appendPackGUID((*itr)->getUnitGuid()); - data << uint32((*itr)->getThreat() * 100); + data << uint32((*itr)->getThreat()*100); } SendMessageToSet(&data, false); } @@ -17399,8 +17399,8 @@ void Unit::SendChangeCurrentVictimOpcode(HostileReference* pHostileReference) data.append(GetPackGUID()); data.appendPackGUID(pHostileReference->getUnitGuid()); data << uint32(count); - std::list<HostileReference*>& tlist = getThreatManager().getThreatList(); - for (std::list<HostileReference*>::const_iterator itr = tlist.begin(); itr != tlist.end(); ++itr) + ThreatContainer::StorageType const &tlist = getThreatManager().getThreatList(); + for (ThreatContainer::StorageType::const_iterator itr = tlist.begin(); itr != tlist.end(); ++itr) { data.appendPackGUID((*itr)->getUnitGuid()); data << uint32((*itr)->getThreat()); @@ -17494,7 +17494,7 @@ void Unit::StopAttackFaction(uint32 faction_id) void Unit::OutDebugInfo() const { sLog->outError(LOG_FILTER_UNITS, "Unit::OutDebugInfo"); - sLog->outInfo(LOG_FILTER_UNITS, "GUID "UI64FMTD", entry %u, type %u, name %s", GetGUID(), GetEntry(), (uint32)GetTypeId(), GetName()); + sLog->outInfo(LOG_FILTER_UNITS, "GUID "UI64FMTD", entry %u, type %u, name %s", GetGUID(), GetEntry(), (uint32)GetTypeId(), GetName().c_str()); sLog->outInfo(LOG_FILTER_UNITS, "OwnerGUID "UI64FMTD", MinionGUID "UI64FMTD", CharmerGUID "UI64FMTD", CharmedGUID "UI64FMTD, GetOwnerGUID(), GetMinionGUID(), GetCharmerGUID(), GetCharmGUID()); sLog->outInfo(LOG_FILTER_UNITS, "In world %u, unit type mask %u", (uint32)(IsInWorld() ? 1 : 0), m_unitTypeMask); if (IsInWorld()) diff --git a/src/server/game/Entities/Vehicle/Vehicle.cpp b/src/server/game/Entities/Vehicle/Vehicle.cpp index da15372ca16..84274a9692d 100755 --- a/src/server/game/Entities/Vehicle/Vehicle.cpp +++ b/src/server/game/Entities/Vehicle/Vehicle.cpp @@ -323,7 +323,7 @@ bool Vehicle::AddPassenger(Unit* unit, int8 seatId) ASSERT(!seat->second.Passenger); } - sLog->outDebug(LOG_FILTER_VEHICLES, "Unit %s enter vehicle entry %u id %u dbguid %u seat %d", unit->GetName(), _me->GetEntry(), _vehicleInfo->m_ID, _me->GetGUIDLow(), (int32)seat->first); + sLog->outDebug(LOG_FILTER_VEHICLES, "Unit %s enter vehicle entry %u id %u dbguid %u seat %d", unit->GetName().c_str(), _me->GetEntry(), _vehicleInfo->m_ID, _me->GetGUIDLow(), (int32)seat->first); seat->second.Passenger = unit->GetGUID(); if (seat->second.SeatInfo->CanEnterOrExit()) @@ -397,7 +397,7 @@ void Vehicle::RemovePassenger(Unit* unit) SeatMap::iterator seat = GetSeatIteratorForPassenger(unit); ASSERT(seat != Seats.end()); - sLog->outDebug(LOG_FILTER_VEHICLES, "Unit %s exit vehicle entry %u id %u dbguid %u seat %d", unit->GetName(), _me->GetEntry(), _vehicleInfo->m_ID, _me->GetGUIDLow(), (int32)seat->first); + sLog->outDebug(LOG_FILTER_VEHICLES, "Unit %s exit vehicle entry %u id %u dbguid %u seat %d", unit->GetName().c_str(), _me->GetEntry(), _vehicleInfo->m_ID, _me->GetGUIDLow(), (int32)seat->first); seat->second.Passenger = 0; if (seat->second.SeatInfo->CanEnterOrExit()) diff --git a/src/server/game/Globals/ObjectAccessor.cpp b/src/server/game/Globals/ObjectAccessor.cpp index 81a132a40d8..b19abc778a9 100755 --- a/src/server/game/Globals/ObjectAccessor.cpp +++ b/src/server/game/Globals/ObjectAccessor.cpp @@ -163,7 +163,7 @@ Unit* ObjectAccessor::FindUnit(uint64 guid) return GetObjectInWorld(guid, (Unit*)NULL); } -Player* ObjectAccessor::FindPlayerByName(const char* name) +Player* ObjectAccessor::FindPlayerByName(std::string const& name) { TRINITY_READ_GUARD(HashMapHolder<Player>::LockType, *HashMapHolder<Player>::GetLock()); std::string nameStr = name; diff --git a/src/server/game/Globals/ObjectAccessor.h b/src/server/game/Globals/ObjectAccessor.h index 0a1b41eb292..41a7abc9a24 100755 --- a/src/server/game/Globals/ObjectAccessor.h +++ b/src/server/game/Globals/ObjectAccessor.h @@ -74,12 +74,11 @@ class HashMapHolder static LockType* GetLock() { return &i_lock; } private: - //Non instanceable only static HashMapHolder() {} static LockType i_lock; - static MapType m_objectMap; + static MapType m_objectMap; }; class ObjectAccessor @@ -120,9 +119,7 @@ class ObjectAccessor static Player* GetObjectInWorld(uint64 guid, Player* /*typeSpecifier*/) { Player* player = HashMapHolder<Player>::Find(guid); - if (player && player->IsInWorld()) - return player; - return NULL; + return player && player->IsInWorld() ? player : NULL; } static Unit* GetObjectInWorld(uint64 guid, Unit* /*typeSpecifier*/) @@ -193,7 +190,7 @@ class ObjectAccessor static Player* FindPlayer(uint64); static Creature* FindCreature(uint64); static Unit* FindUnit(uint64); - static Player* FindPlayerByName(const char* name); + static Player* FindPlayerByName(std::string const& name); // when using this, you must use the hashmapholder's lock static HashMapHolder<Player>::MapType const& GetPlayers() diff --git a/src/server/game/Globals/ObjectMgr.cpp b/src/server/game/Globals/ObjectMgr.cpp index 17982a58061..db8a484ad76 100755 --- a/src/server/game/Globals/ObjectMgr.cpp +++ b/src/server/game/Globals/ObjectMgr.cpp @@ -1865,7 +1865,7 @@ Player* ObjectMgr::GetPlayerByLowGUID(uint32 lowguid) const } // name must be checked to correctness (if received) before call this function -uint64 ObjectMgr::GetPlayerGUIDByName(std::string name) const +uint64 ObjectMgr::GetPlayerGUIDByName(std::string const& name) const { uint64 guid = 0; @@ -7062,7 +7062,7 @@ void ObjectMgr::DeleteCorpseCellData(uint32 mapid, uint32 cellid, uint32 player_ cell_guids.corpses.erase(player_guid); } -void ObjectMgr::LoadQuestRelationsHelper(QuestRelations& map, std::string table, bool starter, bool go) +void ObjectMgr::LoadQuestRelationsHelper(QuestRelations& map, std::string const& table, bool starter, bool go) { uint32 oldMSTime = getMSTime(); @@ -7075,7 +7075,6 @@ void ObjectMgr::LoadQuestRelationsHelper(QuestRelations& map, std::string table, if (!result) { sLog->outError(LOG_FILTER_SQL, ">> Loaded 0 quest relations from `%s`, table is empty.", table.c_str()); - return; } diff --git a/src/server/game/Globals/ObjectMgr.h b/src/server/game/Globals/ObjectMgr.h index bfedd8cd8d0..29ca353bdd7 100755 --- a/src/server/game/Globals/ObjectMgr.h +++ b/src/server/game/Globals/ObjectMgr.h @@ -665,11 +665,11 @@ class ObjectMgr void GetPlayerLevelInfo(uint32 race, uint32 class_, uint8 level, PlayerLevelInfo* info) const; - uint64 GetPlayerGUIDByName(std::string name) const; + uint64 GetPlayerGUIDByName(std::string const& name) const; bool GetPlayerNameByGUID(uint64 guid, std::string &name) const; uint32 GetPlayerTeamByGUID(uint64 guid) const; uint32 GetPlayerAccountIdByGUID(uint64 guid) const; - uint32 GetPlayerAccountIdByPlayerName(const std::string& name) const; + uint32 GetPlayerAccountIdByPlayerName(std::string const& name) const; uint32 GetNearestTaxiNode(float x, float y, float z, uint32 mapid, uint32 team); void GetTaxiPath(uint32 source, uint32 destination, uint32 &path, uint32 &cost); @@ -1057,12 +1057,12 @@ class ObjectMgr // reserved names void LoadReservedPlayersNames(); - bool IsReservedName(const std::string& name) const; + bool IsReservedName(std::string const& name) const; // name with valid structure and symbols - static uint8 CheckPlayerName(const std::string& name, bool create = false); - static PetNameInvalidReason CheckPetName(const std::string& name); - static bool IsValidCharterName(const std::string& name); + static uint8 CheckPlayerName(std::string const& name, bool create = false); + static PetNameInvalidReason CheckPetName(std::string const& name); + static bool IsValidCharterName(std::string const& name); static bool CheckDeclinedNames(std::wstring w_ownname, DeclinedName const& names); @@ -1072,10 +1072,10 @@ class ObjectMgr if (itr == _gameTeleStore.end()) return NULL; return &itr->second; } - GameTele const* GetGameTele(const std::string& name) const; + GameTele const* GetGameTele(std::string const& name) const; GameTeleContainer const& GetGameTeleMap() const { return _gameTeleStore; } bool AddGameTele(GameTele& data); - bool DeleteGameTele(const std::string& name); + bool DeleteGameTele(std::string const& name); TrainerSpellData const* GetNpcTrainerSpells(uint32 entry) const { @@ -1130,7 +1130,7 @@ class ObjectMgr // for wintergrasp only GraveYardContainer GraveYardStore; - static void AddLocaleString(const std::string& s, LocaleConstant locale, StringVector& data); + static void AddLocaleString(std::string const& s, LocaleConstant locale, StringVector& data); static inline void GetLocaleString(const StringVector& data, int loc_idx, std::string& value) { if (data.size() > size_t(loc_idx) && !data[loc_idx].empty()) @@ -1222,7 +1222,7 @@ class ObjectMgr private: void LoadScripts(ScriptsType type); void CheckScripts(ScriptsType type, std::set<int32>& ids); - void LoadQuestRelationsHelper(QuestRelations& map, std::string table, bool starter, bool go); + void LoadQuestRelationsHelper(QuestRelations& map, std::string const& table, bool starter, bool go); void PlayerCreateInfoAddItemHelper(uint32 race_, uint32 class_, uint32 itemId, int32 count); MailLevelRewardContainer _mailLevelRewardStore; diff --git a/src/server/game/Grids/Notifiers/GridNotifiers.cpp b/src/server/game/Grids/Notifiers/GridNotifiers.cpp index a02c18ca008..1cd442e48f9 100755 --- a/src/server/game/Grids/Notifiers/GridNotifiers.cpp +++ b/src/server/game/Grids/Notifiers/GridNotifiers.cpp @@ -81,18 +81,22 @@ void VisibleChangesNotifier::Visit(PlayerMapType &m) iter->getSource()->UpdateVisibilityOf(&i_object); - if (!iter->getSource()->GetSharedVisionList().empty()) + if (iter->getSource()->HasSharedVision()) + { for (SharedVisionList::const_iterator i = iter->getSource()->GetSharedVisionList().begin(); i != iter->getSource()->GetSharedVisionList().end(); ++i) + { if ((*i)->m_seer == iter->getSource()) (*i)->UpdateVisibilityOf(&i_object); + } + } } } void VisibleChangesNotifier::Visit(CreatureMapType &m) { for (CreatureMapType::iterator iter = m.begin(); iter != m.end(); ++iter) - if (!iter->getSource()->GetSharedVisionList().empty()) + if (iter->getSource()->HasSharedVision()) for (SharedVisionList::const_iterator i = iter->getSource()->GetSharedVisionList().begin(); i != iter->getSource()->GetSharedVisionList().end(); ++i) if ((*i)->m_seer == iter->getSource()) @@ -154,7 +158,7 @@ void PlayerRelocationNotifier::Visit(CreatureMapType &m) void CreatureRelocationNotifier::Visit(PlayerMapType &m) { - for (PlayerMapType::iterator iter=m.begin(); iter != m.end(); ++iter) + for (PlayerMapType::iterator iter = m.begin(); iter != m.end(); ++iter) { Player* player = iter->getSource(); @@ -170,7 +174,7 @@ void CreatureRelocationNotifier::Visit(CreatureMapType &m) if (!i_creature.isAlive()) return; - for (CreatureMapType::iterator iter=m.begin(); iter != m.end(); ++iter) + for (CreatureMapType::iterator iter = m.begin(); iter != m.end(); ++iter) { Creature* c = iter->getSource(); CreatureUnitRelocationWorker(&i_creature, c); @@ -249,7 +253,7 @@ void MessageDistDeliverer::Visit(PlayerMapType &m) continue; // Send packet to all who are sharing the player's vision - if (!target->GetSharedVisionList().empty()) + if (target->HasSharedVision()) { SharedVisionList::const_iterator i = target->GetSharedVisionList().begin(); for (; i != target->GetSharedVisionList().end(); ++i) @@ -274,7 +278,7 @@ void MessageDistDeliverer::Visit(CreatureMapType &m) continue; // Send packet to all who are sharing the creature's vision - if (!target->GetSharedVisionList().empty()) + if (target->HasSharedVision()) { SharedVisionList::const_iterator i = target->GetSharedVisionList().begin(); for (; i != target->GetSharedVisionList().end(); ++i) diff --git a/src/server/game/Groups/Group.cpp b/src/server/game/Groups/Group.cpp index 11d9f502bab..45473f792c4 100755 --- a/src/server/game/Groups/Group.cpp +++ b/src/server/game/Groups/Group.cpp @@ -104,12 +104,15 @@ bool Group::Create(Player* leader) m_leaderGuid = leaderGuid; m_leaderName = leader->GetName(); - m_groupType = (isBGGroup() || isBFGroup()) ? GROUPTYPE_BGRAID : GROUPTYPE_NORMAL; + if (isBGGroup() || isBFGroup()) + m_groupType = GROUPTYPE_BGRAID; if (m_groupType & GROUPTYPE_RAID) _initRaidSubGroupsCounter(); - m_lootMethod = GROUP_LOOT; + if (!isLFGGroup()) + m_lootMethod = GROUP_LOOT; + m_lootThreshold = ITEM_QUALITY_UNCOMMON; m_looterGuid = leaderGuid; @@ -219,13 +222,7 @@ void Group::LoadMemberFromDB(uint32 guidLow, uint8 memberFlags, uint8 subgroup, SubGroupCounterIncrease(subgroup); - if (isLFGGroup()) - { - LfgDungeonSet Dungeons; - Dungeons.insert(sLFGMgr->GetDungeon(GetGUID())); - sLFGMgr->SetSelectedDungeons(member.guid, Dungeons); - sLFGMgr->SetState(member.guid, sLFGMgr->GetState(GetGUID())); - } + sLFGMgr->SetupGroupMember(member.guid, GetGUID()); } void Group::ConvertToLFG() @@ -599,9 +596,9 @@ bool Group::RemoveMember(uint64 guid, const RemoveMethod &method /*= GROUP_REMOV if (isLFGGroup() && GetMembersCount() == 1) { - Player* Leader = ObjectAccessor::FindPlayer(GetLeaderGUID()); - LFGDungeonData const* dungeon = sLFGMgr->GetLFGDungeon(sLFGMgr->GetDungeon(GetGUID())); - if ((Leader && dungeon && Leader->isAlive() && Leader->GetMapId() != uint32(dungeon->map)) || !dungeon) + Player* leader = ObjectAccessor::FindPlayer(GetLeaderGUID()); + uint32 mapId = sLFGMgr->GetDungeonMapId(GetGUID()); + if (!mapId || !leader || (leader->isAlive() && leader->GetMapId() != mapId)) { Disband(); return false; @@ -2091,7 +2088,7 @@ void Group::BroadcastGroupUpdate(void) { pp->ForceValuesUpdateAtIndex(UNIT_FIELD_BYTES_2); pp->ForceValuesUpdateAtIndex(UNIT_FIELD_FACTIONTEMPLATE); - sLog->outDebug(LOG_FILTER_GENERAL, "-- Forced group value update for '%s'", pp->GetName()); + sLog->outDebug(LOG_FILTER_GENERAL, "-- Forced group value update for '%s'", pp->GetName().c_str()); } } } @@ -2099,12 +2096,12 @@ void Group::BroadcastGroupUpdate(void) void Group::ResetMaxEnchantingLevel() { m_maxEnchantingLevel = 0; - Player* pMember = NULL; + Player* member = NULL; for (member_citerator citr = m_memberSlots.begin(); citr != m_memberSlots.end(); ++citr) { - pMember = ObjectAccessor::FindPlayer(citr->guid); - if (pMember && m_maxEnchantingLevel < pMember->GetSkillValue(SKILL_ENCHANTING)) - m_maxEnchantingLevel = pMember->GetSkillValue(SKILL_ENCHANTING); + member = ObjectAccessor::FindPlayer(citr->guid); + if (member && m_maxEnchantingLevel < member->GetSkillValue(SKILL_ENCHANTING)) + m_maxEnchantingLevel = member->GetSkillValue(SKILL_ENCHANTING); } } diff --git a/src/server/game/Guilds/Guild.cpp b/src/server/game/Guilds/Guild.cpp index 332c0924b61..e41b8ff4ac8 100755 --- a/src/server/game/Guilds/Guild.cpp +++ b/src/server/game/Guilds/Guild.cpp @@ -43,7 +43,7 @@ inline uint32 _GetGuildBankTabPrice(uint8 tabId) } } -void Guild::SendCommandResult(WorldSession* session, GuildCommandType type, GuildCommandError errCode, const std::string& param) +void Guild::SendCommandResult(WorldSession* session, GuildCommandType type, GuildCommandError errCode, std::string const& param) { WorldPacket data(SMSG_GUILD_COMMAND_RESULT, 8 + param.size() + 1); data << uint32(type); @@ -51,7 +51,8 @@ void Guild::SendCommandResult(WorldSession* session, GuildCommandType type, Guil data << uint32(errCode); session->SendPacket(&data); - sLog->outDebug(LOG_FILTER_GUILD, "WORLD: Sent (SMSG_GUILD_COMMAND_RESULT)"); + sLog->outDebug(LOG_FILTER_GUILD, "SMSG_GUILD_COMMAND_RESULT [%s]: Type: %u, code: %u, param: %s" + , session->GetPlayerInfo().c_str(), type, errCode, param.c_str()); } void Guild::SendSaveEmblemResult(WorldSession* session, GuildEmblemError errCode) @@ -60,7 +61,7 @@ void Guild::SendSaveEmblemResult(WorldSession* session, GuildEmblemError errCode data << uint32(errCode); session->SendPacket(&data); - sLog->outDebug(LOG_FILTER_GUILD, "WORLD: Sent (MSG_SAVE_GUILD_EMBLEM)"); + sLog->outDebug(LOG_FILTER_GUILD, "MSG_SAVE_GUILD_EMBLEM [%s] Code: %u", session->GetPlayerInfo().c_str(), errCode); } // LogHolder @@ -115,13 +116,10 @@ inline uint32 Guild::LogHolder::GetNextGUID() return m_nextGUID; } -/////////////////////////////////////////////////////////////////////////////// // EventLogEntry void Guild::EventLogEntry::SaveToDB(SQLTransaction& trans) const { - PreparedStatement* stmt = NULL; - - stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_GUILD_EVENTLOG); + PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_GUILD_EVENTLOG); stmt->setUInt32(0, m_guildId); stmt->setUInt32(1, m_guid); CharacterDatabase.ExecuteOrAppend(trans, stmt); @@ -154,14 +152,12 @@ void Guild::EventLogEntry::WritePacket(WorldPacket& data) const data << uint32(::time(NULL) - m_timestamp); } -/////////////////////////////////////////////////////////////////////////////// // BankEventLogEntry void Guild::BankEventLogEntry::SaveToDB(SQLTransaction& trans) const { - PreparedStatement* stmt = NULL; uint8 index = 0; - stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_GUILD_BANK_EVENTLOG); + PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_GUILD_BANK_EVENTLOG); stmt->setUInt32( index, m_guildId); stmt->setUInt32(++index, m_guid); stmt->setUInt8 (++index, m_bankTabId); @@ -185,19 +181,27 @@ void Guild::BankEventLogEntry::WritePacket(WorldPacket& data) const { data << uint8(m_eventType); data << uint64(MAKE_NEW_GUID(m_playerGuid, 0, HIGHGUID_PLAYER)); - data << uint32(m_itemOrMoney); - // if ( m_eventType != 4 || m_eventType != 5 || m_eventType != 6 || m_eventType != 8 || m_eventType != 9 ) - if (m_eventType < GUILD_BANK_LOG_DEPOSIT_MONEY) - { - data << uint32(m_itemStackCount); - if (m_eventType == GUILD_BANK_LOG_MOVE_ITEM || m_eventType == GUILD_BANK_LOG_MOVE_ITEM2) + + switch(m_eventType) + { + case GUILD_BANK_LOG_DEPOSIT_ITEM: + case GUILD_BANK_LOG_WITHDRAW_ITEM: + data << uint32(m_itemOrMoney); + data << uint32(m_itemStackCount); + break; + case GUILD_BANK_LOG_MOVE_ITEM: + case GUILD_BANK_LOG_MOVE_ITEM2: + data << uint32(m_itemOrMoney); + data << uint32(m_itemStackCount); data << uint8(m_destTabId); + break; + default: + data << uint64(m_itemOrMoney); } data << uint32(time(NULL) - m_timestamp); } -/////////////////////////////////////////////////////////////////////////////// // RankInfo void Guild::RankInfo::LoadFromDB(Field* fields) { @@ -219,18 +223,47 @@ void Guild::RankInfo::SaveToDB(SQLTransaction& trans) const CharacterDatabase.ExecuteOrAppend(trans, stmt); } +bool Guild::RankInfo::CreateMissingTabsIfNeeded(uint8 ranks, SQLTransaction& trans) +{ + bool ret = false; + for (uint8 i = 0; i < ranks; ++i) + { + GuildBankRightsAndSlots& rightsAndSlots = m_bankTabRightsAndSlots[i]; + if (rightsAndSlots.GetTabId() == i) + continue; + + rightsAndSlots.SetTabId(i); + if (m_rankId == GR_GUILDMASTER) + rightsAndSlots.SetGuildMasterValues(); + + ret = true; + PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_GUILD_BANK_RIGHT); + stmt->setUInt32(0, m_guildId); + stmt->setUInt8 (1, i); + stmt->setUInt8 (2, m_rankId); + stmt->setUInt32(3, rightsAndSlots.GetRights()); + stmt->setUInt32(4, rightsAndSlots.GetSlots()); + trans->Append(stmt); + } + + return ret; +} + void Guild::RankInfo::WritePacket(WorldPacket& data) const { data << uint32(m_rights); - data << uint32(m_bankMoneyPerDay); // In game set in gold, in packet set in bronze. + if (m_bankMoneyPerDay == GUILD_WITHDRAW_MONEY_UNLIMITED) + data << uint32(GUILD_WITHDRAW_MONEY_UNLIMITED); + else + data << uint32(m_bankMoneyPerDay); for (uint8 i = 0; i < GUILD_BANK_MAX_TABS; ++i) { - data << uint32(m_bankTabRightsAndSlots[i].rights); - data << uint32(m_bankTabRightsAndSlots[i].slots); + data << uint32(m_bankTabRightsAndSlots[i].GetRights()); + data << uint32(m_bankTabRightsAndSlots[i].GetSlots()); } } -void Guild::RankInfo::SetName(const std::string& name) +void Guild::RankInfo::SetName(std::string const& name) { if (m_name == name) return; @@ -271,62 +304,39 @@ void Guild::RankInfo::SetBankMoneyPerDay(uint32 money) m_bankMoneyPerDay = money; - PreparedStatement* stmt = NULL; - stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_GUILD_RANK_BANK_MONEY); + PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_GUILD_RANK_BANK_MONEY); stmt->setUInt32(0, money); stmt->setUInt8 (1, m_rankId); stmt->setUInt32(2, m_guildId); CharacterDatabase.Execute(stmt); - - stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_GUILD_RANK_BANK_RESET_TIME); - stmt->setUInt32(0, m_guildId); - stmt->setUInt8 (1, m_rankId); - CharacterDatabase.Execute(stmt); } -void Guild::RankInfo::SetBankTabSlotsAndRights(uint8 tabId, GuildBankRightsAndSlots rightsAndSlots, bool saveToDB) +void Guild::RankInfo::SetBankTabSlotsAndRights(GuildBankRightsAndSlots rightsAndSlots, bool saveToDB) { if (m_rankId == GR_GUILDMASTER) // Prevent loss of leader rights rightsAndSlots.SetGuildMasterValues(); - if (m_bankTabRightsAndSlots[tabId].IsEqual(rightsAndSlots)) - return; - - m_bankTabRightsAndSlots[tabId] = rightsAndSlots; + GuildBankRightsAndSlots& guildBR = m_bankTabRightsAndSlots[rightsAndSlots.GetTabId()]; + guildBR = rightsAndSlots; if (saveToDB) { - PreparedStatement* stmt = NULL; - - stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_GUILD_BANK_RIGHT); + PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_GUILD_BANK_RIGHT); stmt->setUInt32(0, m_guildId); - stmt->setUInt8 (1, tabId); + stmt->setUInt8 (1, guildBR.GetTabId()); stmt->setUInt8 (2, m_rankId); - CharacterDatabase.Execute(stmt); - - stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_GUILD_BANK_RIGHT); - stmt->setUInt32(0, m_guildId); - stmt->setUInt8 (1, tabId); - stmt->setUInt8 (2, m_rankId); - stmt->setUInt8 (3, m_bankTabRightsAndSlots[tabId].rights); - stmt->setUInt32(4, m_bankTabRightsAndSlots[tabId].slots); - CharacterDatabase.Execute(stmt); - - stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_GUILD_RANK_BANK_TIME0 + tabId); - stmt->setUInt32(0, m_guildId); - stmt->setUInt8 (1, m_rankId); + stmt->setUInt8 (3, guildBR.GetRights()); + stmt->setUInt32(4, guildBR.GetSlots()); CharacterDatabase.Execute(stmt); } } -/////////////////////////////////////////////////////////////////////////////// // BankTab -bool Guild::BankTab::LoadFromDB(Field* fields) +void Guild::BankTab::LoadFromDB(Field* fields) { m_name = fields[2].GetString(); m_icon = fields[3].GetString(); m_text = fields[4].GetString(); - return true; } bool Guild::BankTab::LoadItemFromDB(Field* fields) @@ -352,7 +362,7 @@ bool Guild::BankTab::LoadItemFromDB(Field* fields) { sLog->outError(LOG_FILTER_GUILD, "Item (GUID %u, id: %u) not found in item_instance, deleting from guild bank!", itemGuid, itemEntry); - PreparedStatement *stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_NONEXISTENT_GUILD_BANK_ITEM); + PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_NONEXISTENT_GUILD_BANK_ITEM); stmt->setUInt32(0, m_guildId); stmt->setUInt8 (1, m_tabId); stmt->setUInt8 (2, slotId); @@ -383,26 +393,41 @@ void Guild::BankTab::Delete(SQLTransaction& trans, bool removeItemsFromDB) inline void Guild::BankTab::WritePacket(WorldPacket& data) const { - data << uint8(GUILD_BANK_MAX_SLOTS); + uint8 count = 0; + + size_t pos = data.wpos(); + data << uint8(0); + for (uint8 slotId = 0; slotId < GUILD_BANK_MAX_SLOTS; ++slotId) - WriteSlotPacket(data, slotId); + if (WriteSlotPacket(data, slotId)) + ++count; + + data.put<uint8>(pos, count); } // Writes information about contents of specified slot into packet. -void Guild::BankTab::WriteSlotPacket(WorldPacket& data, uint8 slotId) const +bool Guild::BankTab::WriteSlotPacket(WorldPacket& data, uint8 slotId, bool ignoreEmpty /* = true */) const { Item* pItem = GetItem(slotId); uint32 itemEntry = pItem ? pItem->GetEntry() : 0; + if (!itemEntry && ignoreEmpty) + return false; + data << uint8(slotId); data << uint32(itemEntry); if (itemEntry) { data << uint32(0); // 3.3.0 (0x00018020, 0x00018000) - data << uint32(pItem->GetItemRandomPropertyId()); // Random item property id - if (pItem->GetItemRandomPropertyId()) + + if (uint32 random = pItem->GetItemRandomPropertyId()) + { + data << uint32(random); // Random item property id data << uint32(pItem->GetItemSuffixFactor()); // SuffixFactor + } + else + data << uint32(0); data << uint32(pItem->GetCount()); // ITEM_FIELD_STACK_COUNT data << uint32(0); @@ -421,9 +446,10 @@ void Guild::BankTab::WriteSlotPacket(WorldPacket& data, uint8 slotId) const } data.put<uint8>(enchCountPos, enchCount); } + return true; } -void Guild::BankTab::SetInfo(const std::string& name, const std::string& icon) +void Guild::BankTab::SetInfo(std::string const& name, std::string const& icon) { if (m_name == name && m_icon == icon) return; @@ -439,7 +465,7 @@ void Guild::BankTab::SetInfo(const std::string& name, const std::string& icon) CharacterDatabase.Execute(stmt); } -void Guild::BankTab::SetText(const std::string& text) +void Guild::BankTab::SetText(std::string const& text) { if (m_text == text) return; @@ -456,51 +482,55 @@ void Guild::BankTab::SetText(const std::string& text) // Sets/removes contents of specified slot. // If pItem == NULL contents are removed. -bool Guild::BankTab::SetItem(SQLTransaction& trans, uint8 slotId, Item* pItem) +bool Guild::BankTab::SetItem(SQLTransaction& trans, uint8 slotId, Item* item) { if (slotId >= GUILD_BANK_MAX_SLOTS) return false; - m_items[slotId] = pItem; - - PreparedStatement* stmt = NULL; + m_items[slotId] = item; - stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_GUILD_BANK_ITEM); + PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_GUILD_BANK_ITEM); stmt->setUInt32(0, m_guildId); stmt->setUInt8 (1, m_tabId); stmt->setUInt8 (2, slotId); CharacterDatabase.ExecuteOrAppend(trans, stmt); - if (pItem) + if (item) { stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_GUILD_BANK_ITEM); stmt->setUInt32(0, m_guildId); stmt->setUInt8 (1, m_tabId); stmt->setUInt8 (2, slotId); - stmt->setUInt32(3, pItem->GetGUIDLow()); + stmt->setUInt32(3, item->GetGUIDLow()); CharacterDatabase.ExecuteOrAppend(trans, stmt); - pItem->SetUInt64Value(ITEM_FIELD_CONTAINED, 0); - pItem->SetUInt64Value(ITEM_FIELD_OWNER, 0); - pItem->FSetState(ITEM_NEW); - pItem->SaveToDB(trans); // Not in inventory and can be saved standalone + item->SetUInt64Value(ITEM_FIELD_CONTAINED, 0); + item->SetUInt64Value(ITEM_FIELD_OWNER, 0); + item->FSetState(ITEM_NEW); + item->SaveToDB(trans); // Not in inventory and can be saved standalone } return true; } -void Guild::BankTab::SendText(const Guild* guild, WorldSession* session) const +void Guild::BankTab::SendText(Guild const* guild, WorldSession* session) const { WorldPacket data(MSG_QUERY_GUILD_BANK_TEXT, 1 + m_text.size() + 1); data << uint8(m_tabId); data << m_text; if (session) + { + sLog->outDebug(LOG_FILTER_GUILD, "MSG_QUERY_GUILD_BANK_TEXT [%s]: Tabid: %u, Text: %s" + , session->GetPlayerInfo().c_str(), m_tabId, m_text.c_str()); session->SendPacket(&data); + } else + { + sLog->outDebug(LOG_FILTER_GUILD, "MSG_QUERY_GUILD_BANK_TEXT [Broadcast]: Tabid: %u, Text: %s", m_tabId, m_text.c_str()); guild->BroadcastPacket(&data); + } } -/////////////////////////////////////////////////////////////////////////////// // Member void Guild::Member::SetStats(Player* player) { @@ -511,7 +541,7 @@ void Guild::Member::SetStats(Player* player) m_accountId = player->GetSession()->GetAccountId(); } -void Guild::Member::SetStats(const std::string& name, uint8 level, uint8 _class, uint32 zoneId, uint32 accountId) +void Guild::Member::SetStats(std::string const& name, uint8 level, uint8 _class, uint32 zoneId, uint32 accountId) { m_name = name; m_level = level; @@ -520,7 +550,7 @@ void Guild::Member::SetStats(const std::string& name, uint8 level, uint8 _class, m_accountId = accountId; } -void Guild::Member::SetPublicNote(const std::string& publicNote) +void Guild::Member::SetPublicNote(std::string const& publicNote) { if (m_publicNote == publicNote) return; @@ -533,7 +563,7 @@ void Guild::Member::SetPublicNote(const std::string& publicNote) CharacterDatabase.Execute(stmt); } -void Guild::Member::SetOfficerNote(const std::string& officerNote) +void Guild::Member::SetOfficerNote(std::string const& officerNote) { if (m_officerNote == officerNote) return; @@ -576,22 +606,18 @@ void Guild::Member::SaveToDB(SQLTransaction& trans) const // In this case member has to be removed from guild. bool Guild::Member::LoadFromDB(Field* fields) { - m_publicNote = fields[3].GetString(); - m_officerNote = fields[4].GetString(); - m_bankRemaining[GUILD_BANK_MAX_TABS].resetTime = fields[5].GetUInt32(); - m_bankRemaining[GUILD_BANK_MAX_TABS].value = fields[6].GetUInt32(); - for (uint8 i = 0; i < GUILD_BANK_MAX_TABS; ++i) - { - m_bankRemaining[i].resetTime = fields[7 + i * 2].GetUInt32(); - m_bankRemaining[i].value = fields[8 + i * 2].GetUInt32(); - } + m_publicNote = fields[3].GetString(); + m_officerNote = fields[4].GetString(); + + for (uint8 i = 0; i <= GUILD_BANK_MAX_TABS; ++i) + m_bankWithdraw[i] = fields[5 + i].GetUInt32(); - SetStats(fields[19].GetString(), - fields[20].GetUInt8(), // characters.level - fields[21].GetUInt8(), // characters.class - fields[22].GetUInt16(), // characters.zone - fields[23].GetUInt32()); // characters.account - m_logoutTime = fields[24].GetUInt32(); // characters.logout_time + SetStats(fields[12].GetString(), + fields[13].GetUInt8(), // characters.level + fields[14].GetUInt8(), // characters.class + fields[15].GetUInt16(), // characters.zone + fields[16].GetUInt32()); // characters.account + m_logoutTime = fields[17].GetUInt32(); // characters.logout_time if (!CheckStats()) return false; @@ -601,6 +627,7 @@ bool Guild::Member::LoadFromDB(Field* fields) sLog->outError(LOG_FILTER_GUILD, "Player (GUID: %u) has broken zone-data", GUID_LOPART(m_guid)); m_zoneId = Player::GetZoneIdFromDB(m_guid); } + ResetFlags(); return true; } @@ -612,6 +639,7 @@ bool Guild::Member::CheckStats() const sLog->outError(LOG_FILTER_GUILD, "Player (GUID: %u) has a broken data in field `characters`.`level`, deleting him from guild!", GUID_LOPART(m_guid)); return false; } + if (m_class < CLASS_WARRIOR || m_class >= MAX_CLASSES) { sLog->outError(LOG_FILTER_GUILD, "Player (GUID: %u) has a broken data in field `characters`.`class`, deleting him from guild!", GUID_LOPART(m_guid)); @@ -622,100 +650,64 @@ bool Guild::Member::CheckStats() const void Guild::Member::WritePacket(WorldPacket& data) const { - if (Player* player = FindPlayer()) - { - data << uint64(player->GetGUID()); - data << uint8(1); - data << player->GetName(); - data << uint32(m_rankId); - data << uint8(player->getLevel()); - data << uint8(player->getClass()); - data << uint8(0); // new 2.4.0 - data << uint32(player->GetZoneId()); - } - else - { - data << m_guid; - data << uint8(0); - data << m_name; - data << uint32(m_rankId); - data << uint8(m_level); - data << uint8(m_class); - data << uint8(0); // new 2.4.0 - data << uint32(m_zoneId); + data << uint64(m_guid) + << uint8(m_flags) + << m_name + << uint32(m_rankId) + << uint8(m_level) + << uint8(m_class) + << uint8(0) + << uint32(m_zoneId); + + if (!m_flags) data << float(float(::time(NULL) - m_logoutTime) / DAY); - } - data << m_publicNote; - data << m_officerNote; + + data << m_publicNote + << m_officerNote; } // Decreases amount of money/slots left for today. // If (tabId == GUILD_BANK_MAX_TABS) decrease money amount. // Otherwise decrease remaining items amount for specified tab. -void Guild::Member::DecreaseBankRemainingValue(SQLTransaction& trans, uint8 tabId, uint32 amount) +void Guild::Member::UpdateBankWithdrawValue(SQLTransaction& trans, uint8 tabId, uint32 amount) { - m_bankRemaining[tabId].value -= amount; + m_bankWithdraw[tabId] += amount; + + PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_GUILD_MEMBER_WITHDRAW); + stmt->setUInt32(0, GUID_LOPART(m_guid)); + for (uint8 i = 0; i <= GUILD_BANK_MAX_TABS;) + { + uint32 withdraw = m_bankWithdraw[i++]; + stmt->setUInt32(i, withdraw); + } - PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement( - tabId == GUILD_BANK_MAX_TABS ? - CHAR_UPD_GUILD_MEMBER_BANK_REM_MONEY : - CHAR_UPD_GUILD_MEMBER_BANK_REM_SLOTS0 + tabId); - stmt->setUInt32(0, m_bankRemaining[tabId].value); - stmt->setUInt32(1, m_guildId); - stmt->setUInt32(2, GUID_LOPART(m_guid)); CharacterDatabase.ExecuteOrAppend(trans, stmt); } +void Guild::Member::ResetValues() +{ + for (uint8 tabId = 0; tabId <= GUILD_BANK_MAX_TABS; ++tabId) + m_bankWithdraw[tabId] = 0; +} + // Get amount of money/slots left for today. // If (tabId == GUILD_BANK_MAX_TABS) return money amount. // Otherwise return remaining items amount for specified tab. -// If reset time was more than 24 hours ago, renew reset time and reset amount to maximum value. -uint32 Guild::Member::GetBankRemainingValue(uint8 tabId, const Guild* guild) const +int32 Guild::Member::GetBankWithdrawValue(uint8 tabId) const { // Guild master has unlimited amount. if (IsRank(GR_GUILDMASTER)) return tabId == GUILD_BANK_MAX_TABS ? GUILD_WITHDRAW_MONEY_UNLIMITED : GUILD_WITHDRAW_SLOT_UNLIMITED; - // Check rights for non-money tab. - if (tabId != GUILD_BANK_MAX_TABS) - if ((guild->_GetRankBankTabRights(m_rankId, tabId) & GUILD_BANK_RIGHT_VIEW_TAB) != GUILD_BANK_RIGHT_VIEW_TAB) - return 0; - - uint32 curTime = uint32(::time(NULL) / MINUTE); // minutes - if (curTime > m_bankRemaining[tabId].resetTime + 24 * HOUR / MINUTE) - { - RemainingValue& rv = const_cast <RemainingValue&> (m_bankRemaining[tabId]); - rv.resetTime = curTime; - rv.value = tabId == GUILD_BANK_MAX_TABS ? - guild->_GetRankBankMoneyPerDay(m_rankId) : - guild->_GetRankBankTabSlotsPerDay(m_rankId, tabId); - - PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement( - tabId == GUILD_BANK_MAX_TABS ? - CHAR_UPD_GUILD_MEMBER_BANK_TIME_MONEY : - CHAR_UPD_GUILD_MEMBER_BANK_TIME_REM_SLOTS0 + tabId); - stmt->setUInt32(0, m_bankRemaining[tabId].resetTime); - stmt->setUInt32(1, m_bankRemaining[tabId].value); - stmt->setUInt32(2, m_guildId); - stmt->setUInt32(3, GUID_LOPART(m_guid)); - CharacterDatabase.Execute(stmt); - } - return m_bankRemaining[tabId].value; -} - -inline void Guild::Member::ResetTabTimes() -{ - for (uint8 tabId = 0; tabId < GUILD_BANK_MAX_TABS; ++tabId) - m_bankRemaining[tabId].resetTime = 0; + return m_bankWithdraw[tabId]; } -inline void Guild::Member::ResetMoneyTime() +// EmblemInfo +void EmblemInfo::ReadPacket(WorldPacket& recv) { - m_bankRemaining[GUILD_BANK_MAX_TABS].resetTime = 0; + recv >> m_style >> m_color >> m_borderStyle >> m_borderColor >> m_backgroundColor; } -/////////////////////////////////////////////////////////////////////////////// -// EmblemInfo void EmblemInfo::LoadFromDB(Field* fields) { m_style = fields[3].GetUInt8(); @@ -746,7 +738,6 @@ void EmblemInfo::SaveToDB(uint32 guildId) const CharacterDatabase.Execute(stmt); } -/////////////////////////////////////////////////////////////////////////////// // MoveItemData bool Guild::MoveItemData::CheckItem(uint32& splitedAmount) { @@ -794,7 +785,6 @@ inline void Guild::MoveItemData::CopySlots(SlotIds& ids) const ids.insert(uint8(itr->pos)); } -/////////////////////////////////////////////////////////////////////////////// // PlayerMoveItemData bool Guild::PlayerMoveItemData::InitItem() { @@ -854,7 +844,6 @@ inline InventoryResult Guild::PlayerMoveItemData::CanStore(Item* pItem, bool swa return m_pPlayer->CanStoreItem(m_container, m_slotId, m_vec, pItem, swap); } -/////////////////////////////////////////////////////////////////////////////// // BankMoveItemData bool Guild::BankMoveItemData::InitItem() { @@ -877,7 +866,12 @@ bool Guild::BankMoveItemData::HasWithdrawRights(MoveItemData* pOther) const // Do not check rights if item is being swapped within the same bank tab if (pOther->IsBank() && pOther->GetContainer() == m_container) return true; - return (m_pGuild->_GetMemberRemainingSlots(m_pPlayer->GetGUID(), m_container) != 0); + + int32 slots = 0; + if (Member const* member = m_pGuild->GetMember(m_pPlayer->GetGUID())) + slots = m_pGuild->_GetMemberRemainingSlots(member, m_container); + + return slots != 0; } void Guild::BankMoveItemData::RemoveItem(SQLTransaction& trans, MoveItemData* pOther, uint32 splitedAmount) @@ -896,7 +890,7 @@ void Guild::BankMoveItemData::RemoveItem(SQLTransaction& trans, MoveItemData* pO } // Decrease amount of player's remaining items (if item is moved to different tab or to player) if (!pOther->IsBank() || pOther->GetContainer() != m_container) - m_pGuild->_DecreaseMemberRemainingSlots(trans, m_pPlayer->GetGUID(), m_container); + m_pGuild->_UpdateMemberWithdrawSlots(trans, m_pPlayer->GetGUID(), m_container); } Item* Guild::BankMoveItemData::StoreItem(SQLTransaction& trans, Item* pItem) @@ -940,7 +934,7 @@ void Guild::BankMoveItemData::LogAction(MoveItemData* pFrom) const if (!pFrom->IsBank() && sWorld->getBoolConfig(CONFIG_GM_LOG_TRADE) && !AccountMgr::IsPlayerAccount(m_pPlayer->GetSession()->GetSecurity())) // TODO: move to scripts sLog->outCommand(m_pPlayer->GetSession()->GetAccountId(), "GM %s (Account: %u) deposit item: %s (Entry: %d Count: %u) to guild bank (Guild ID: %u)", - m_pPlayer->GetName(), m_pPlayer->GetSession()->GetAccountId(), + m_pPlayer->GetName().c_str(), m_pPlayer->GetSession()->GetAccountId(), pFrom->GetItem()->GetTemplate()->Name1.c_str(), pFrom->GetItem()->GetEntry(), pFrom->GetItem()->GetCount(), m_pGuild->GetId()); } @@ -1067,9 +1061,14 @@ InventoryResult Guild::BankMoveItemData::CanStore(Item* pItem, bool swap) return EQUIP_ERR_BANK_FULL; } -/////////////////////////////////////////////////////////////////////////////// // Guild -Guild::Guild() : m_id(0), m_leaderGuid(0), m_createdDate(0), m_accountsNumber(0), m_bankMoney(0), m_eventLog(NULL) +Guild::Guild(): + m_id(0), + m_leaderGuid(0), + m_createdDate(0), + m_accountsNumber(0), + m_bankMoney(0), + m_eventLog(NULL) { memset(&m_bankEventLog, 0, (GUILD_BANK_MAX_TABS + 1) * sizeof(LogHolder*)); } @@ -1080,17 +1079,24 @@ Guild::~Guild() _DeleteBankItems(temp); // Cleanup - if (m_eventLog) - delete m_eventLog; + delete m_eventLog; + m_eventLog = NULL; + for (uint8 tabId = 0; tabId <= GUILD_BANK_MAX_TABS; ++tabId) - if (m_bankEventLog[tabId]) - delete m_bankEventLog[tabId]; + { + delete m_bankEventLog[tabId]; + m_bankEventLog[tabId] = NULL; + } + for (Members::iterator itr = m_members.begin(); itr != m_members.end(); ++itr) + { delete itr->second; + itr->second = NULL; + } } // Creates new guild with default data and saves it to database. -bool Guild::Create(Player* pLeader, const std::string& name) +bool Guild::Create(Player* pLeader, std::string const& name) { // Check if guild with such name already exists if (sGuildMgr->GetGuildByName(name)) @@ -1110,12 +1116,11 @@ bool Guild::Create(Player* pLeader, const std::string& name) _CreateLogHolders(); sLog->outDebug(LOG_FILTER_GUILD, "GUILD: creating guild [%s] for leader %s (%u)", - name.c_str(), pLeader->GetName(), GUID_LOPART(m_leaderGuid)); + name.c_str(), pLeader->GetName().c_str(), GUID_LOPART(m_leaderGuid)); - PreparedStatement* stmt = NULL; SQLTransaction trans = CharacterDatabase.BeginTransaction(); - stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_GUILD_MEMBERS); + PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_GUILD_MEMBERS); stmt->setUInt32(0, m_id); trans->Append(stmt); @@ -1136,12 +1141,10 @@ bool Guild::Create(Player* pLeader, const std::string& name) trans->Append(stmt); CharacterDatabase.CommitTransaction(trans); - // Create default ranks - _CreateDefaultGuildRanks(pLeaderSession->GetSessionDbLocaleIndex()); - // Add guildmaster - bool ret = AddMember(m_leaderGuid, GR_GUILDMASTER); + _CreateDefaultGuildRanks(pLeaderSession->GetSessionDbLocaleIndex()); // Create default ranks + bool ret = AddMember(m_leaderGuid, GR_GUILDMASTER); // Add guildmaster + if (ret) - // Call scripts on successful create sScriptMgr->OnGuildCreate(this, pLeader, name); return ret; @@ -1161,9 +1164,9 @@ void Guild::Disband() DeleteMember(itr->second->GetGUID(), true); } - PreparedStatement* stmt = NULL; SQLTransaction trans = CharacterDatabase.BeginTransaction(); - stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_GUILD); + + PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_GUILD); stmt->setUInt32(0, m_id); trans->Append(stmt); @@ -1198,8 +1201,36 @@ void Guild::Disband() sGuildMgr->RemoveGuild(m_id); } -/////////////////////////////////////////////////////////////////////////////// -// HANDLE CLIENT COMMANDS +void Guild::UpdateMemberData(Player* player, uint8 dataid, uint32 value) +{ + if (Member* member = GetMember(player->GetGUID())) + { + switch (dataid) + { + case GUILD_MEMBER_DATA_ZONEID: + member->SetZoneID(value); + break; + case GUILD_MEMBER_DATA_LEVEL: + member->SetLevel(value); + break; + default: + sLog->outError(LOG_FILTER_GUILD, "Guild::UpdateMemberData: Called with incorrect DATAID %u (value %u)", dataid, value); + return; + } + //HandleRoster(); + } +} + +void Guild::OnPlayerStatusChange(Player* player, uint32 flag, bool state) +{ + if (Member* member = GetMember(player->GetGUID())) + { + if (state) + member->AddFlag(flag); + else member->RemFlag(flag); + } +} + void Guild::HandleRoster(WorldSession* session /*= NULL*/) { // Guess size @@ -1216,10 +1247,15 @@ void Guild::HandleRoster(WorldSession* session /*= NULL*/) itr->second->WritePacket(data); if (session) + { + sLog->outDebug(LOG_FILTER_GUILD, "SMSG_GUILD_ROSTER [%s]", session->GetPlayerInfo().c_str()); session->SendPacket(&data); + } else + { + sLog->outDebug(LOG_FILTER_GUILD, "SMSG_GUILD_ROSTER [Broadcast]"); BroadcastPacket(&data); - sLog->outDebug(LOG_FILTER_GUILD, "WORLD: Sent (SMSG_GUILD_ROSTER)"); + } } void Guild::HandleQuery(WorldSession* session) @@ -1228,6 +1264,7 @@ void Guild::HandleQuery(WorldSession* session) data << uint32(m_id); data << m_name; + // Rank name for (uint8 i = 0; i < GUILD_RANKS_MAX_COUNT; ++i) // Always show 10 ranks { if (i < _GetRanksSize()) @@ -1237,20 +1274,20 @@ void Guild::HandleQuery(WorldSession* session) } m_emblemInfo.WritePacket(data); - data << uint32(_GetRanksSize()); // Amount of ranks - session->SendPacket(&data); + data << uint32(_GetRanksSize()); // Number of ranks used - sLog->outDebug(LOG_FILTER_GUILD, "WORLD: Sent (SMSG_GUILD_QUERY_RESPONSE)"); + session->SendPacket(&data); + sLog->outDebug(LOG_FILTER_GUILD, "SMSG_GUILD_QUERY_RESPONSE [%s]", session->GetPlayerInfo().c_str()); } -void Guild::HandleSetMOTD(WorldSession* session, const std::string& motd) +void Guild::HandleSetMOTD(WorldSession* session, std::string const& motd) { if (m_motd == motd) return; // Player must have rights to set MOTD if (!_HasRankRight(session->GetPlayer(), GR_RIGHT_SETMOTD)) - SendCommandResult(session, GUILD_INVITE_S, ERR_GUILD_PERMISSIONS); + SendCommandResult(session, GUILD_COMMAND_EDIT_MOTD, ERR_GUILD_PERMISSIONS); else { m_motd = motd; @@ -1266,15 +1303,13 @@ void Guild::HandleSetMOTD(WorldSession* session, const std::string& motd) } } -void Guild::HandleSetInfo(WorldSession* session, const std::string& info) +void Guild::HandleSetInfo(WorldSession* session, std::string const& info) { if (m_info == info) return; // Player must have rights to set guild's info - if (!_HasRankRight(session->GetPlayer(), GR_RIGHT_MODIFY_GUILD_INFO)) - SendCommandResult(session, GUILD_CREATE_S, ERR_GUILD_PERMISSIONS); - else + if (_HasRankRight(session->GetPlayer(), GR_RIGHT_MODIFY_GUILD_INFO)) { m_info = info; @@ -1291,11 +1326,9 @@ void Guild::HandleSetEmblem(WorldSession* session, const EmblemInfo& emblemInfo) { Player* player = session->GetPlayer(); if (!_IsLeader(player)) - // "Only guild leaders can create emblems." - SendSaveEmblemResult(session, ERR_GUILDEMBLEM_NOTGUILDMASTER); + SendSaveEmblemResult(session, ERR_GUILDEMBLEM_NOTGUILDMASTER); // "Only guild leaders can create emblems." else if (!player->HasEnoughMoney(EMBLEM_PRICE)) - // "You can't afford to do that." - SendSaveEmblemResult(session, ERR_GUILDEMBLEM_NOTENOUGHMONEY); + SendSaveEmblemResult(session, ERR_GUILDEMBLEM_NOTENOUGHMONEY); // "You can't afford to do that." else { player->ModifyMoney(-int32(EMBLEM_PRICE)); @@ -1303,111 +1336,125 @@ void Guild::HandleSetEmblem(WorldSession* session, const EmblemInfo& emblemInfo) m_emblemInfo = emblemInfo; m_emblemInfo.SaveToDB(m_id); - // "Guild Emblem saved." - SendSaveEmblemResult(session, ERR_GUILDEMBLEM_SUCCESS); + SendSaveEmblemResult(session, ERR_GUILDEMBLEM_SUCCESS); // "Guild Emblem saved." HandleQuery(session); } } -void Guild::HandleSetLeader(WorldSession* session, const std::string& name) +void Guild::HandleSetLeader(WorldSession* session, std::string const& name) { Player* player = session->GetPlayer(); // Only leader can assign new leader if (!_IsLeader(player)) - SendCommandResult(session, GUILD_INVITE_S, ERR_GUILD_PERMISSIONS); + SendCommandResult(session, GUILD_COMMAND_CHANGE_LEADER, ERR_GUILD_PERMISSIONS); // Old leader must be a member of guild else if (Member* pOldLeader = GetMember(player->GetGUID())) { // New leader must be a member of guild - if (Member* pNewLeader = GetMember(session, name)) + if (Member* pNewLeader = GetMember(name)) { _SetLeaderGUID(pNewLeader); pOldLeader->ChangeRank(GR_OFFICER); - _BroadcastEvent(GE_LEADER_CHANGED, 0, player->GetName(), name.c_str()); + _BroadcastEvent(GE_LEADER_CHANGED, 0, player->GetName().c_str(), name.c_str()); } } - else - SendCommandResult(session, GUILD_INVITE_S, ERR_GUILD_PERMISSIONS); } -void Guild::HandleSetBankTabInfo(WorldSession* session, uint8 tabId, const std::string& name, const std::string& icon) +void Guild::HandleSetBankTabInfo(WorldSession* session, uint8 tabId, std::string const& name, std::string const& icon) { - if (BankTab* pTab = GetBankTab(tabId)) + BankTab* tab = GetBankTab(tabId); + if (!tab) { - pTab->SetInfo(name, icon); - SendBankTabsInfo(session); - _SendBankContent(session, tabId); + sLog->outError(LOG_FILTER_GUILD, "Guild::HandleSetBankTabInfo: Player %s trying to change bank tab info from unexisting tab %d.", + session->GetPlayerInfo().c_str(), tabId); + return; } + + char aux[2]; + sprintf(aux, "%u", tabId); + + tab->SetInfo(name, icon); + _BroadcastEvent(GE_BANK_TAB_UPDATED, 0, aux, name.c_str(), icon.c_str()); } -void Guild::HandleSetMemberNote(WorldSession* session, const std::string& name, const std::string& note, bool officer) +void Guild::HandleSetMemberNote(WorldSession* session, std::string const& name, std::string const& note, bool isPublic) { // Player must have rights to set public/officer note - if (!_HasRankRight(session->GetPlayer(), officer ? GR_RIGHT_EOFFNOTE : GR_RIGHT_EPNOTE)) - SendCommandResult(session, GUILD_INVITE_S, ERR_GUILD_PERMISSIONS); - // Noted player must be a member of guild - else if (Member* member = GetMember(session, name)) + if (!_HasRankRight(session->GetPlayer(), isPublic ? GR_RIGHT_EPNOTE : GR_RIGHT_EOFFNOTE)) + SendCommandResult(session, GUILD_COMMAND_PUBLIC_NOTE, ERR_GUILD_PERMISSIONS); + else if (Member* member = GetMember(name)) { - if (officer) - member->SetOfficerNote(note); - else + if (isPublic) member->SetPublicNote(note); + else + member->SetOfficerNote(note); + HandleRoster(session); } } -void Guild::HandleSetRankInfo(WorldSession* session, uint8 rankId, const std::string& name, uint32 rights, uint32 moneyPerDay, GuildBankRightsAndSlotsVec rightsAndSlots) +void Guild::HandleSetRankInfo(WorldSession* session, uint8 rankId, std::string const& name, uint32 rights, uint32 moneyPerDay, GuildBankRightsAndSlotsVec rightsAndSlots) { // Only leader can modify ranks if (!_IsLeader(session->GetPlayer())) - SendCommandResult(session, GUILD_INVITE_S, ERR_GUILD_PERMISSIONS); + SendCommandResult(session, GUILD_COMMAND_CHANGE_RANK, ERR_GUILD_PERMISSIONS); else if (RankInfo* rankInfo = GetRankInfo(rankId)) { - sLog->outDebug(LOG_FILTER_GUILD, "WORLD: Changed RankName to '%s', rights to 0x%08X", name.c_str(), rights); + sLog->outDebug(LOG_FILTER_GUILD, "Changed RankName to '%s', rights to 0x%08X", name.c_str(), rights); rankInfo->SetName(name); rankInfo->SetRights(rights); _SetRankBankMoneyPerDay(rankId, moneyPerDay); - uint8 tabId = 0; for (GuildBankRightsAndSlotsVec::const_iterator itr = rightsAndSlots.begin(); itr != rightsAndSlots.end(); ++itr) - _SetRankBankTabRightsAndSlots(rankId, tabId++, *itr); + _SetRankBankTabRightsAndSlots(rankId, *itr); - HandleQuery(session); - HandleRoster(); // Broadcast for tab rights update + char aux[2]; + sprintf(aux, "%u", rankId); + _BroadcastEvent(GE_RANK_UPDATED, 0, aux, name.c_str()); } } void Guild::HandleBuyBankTab(WorldSession* session, uint8 tabId) { - if (tabId != _GetPurchasedTabsSize()) + Player* player = session->GetPlayer(); + if (!player) return; - uint32 tabCost = _GetGuildBankTabPrice(tabId) * GOLD; - if (!tabCost) + Member const* member = GetMember(player->GetGUID()); + if (!member) return; - Player* player = session->GetPlayer(); - if (!player->HasEnoughMoney(tabCost)) // Should not happen, this is checked by client + if (_GetPurchasedTabsSize() >= GUILD_BANK_MAX_TABS) return; - if (!_CreateNewBankTab()) - return; + if (tabId != _GetPurchasedTabsSize()) + return; + + uint32 tabCost = _GetGuildBankTabPrice(tabId) * GOLD; + if (!tabCost) + return; - player->ModifyMoney(-int32(tabCost)); - _SetRankBankMoneyPerDay(player->GetRank(), uint32(GUILD_WITHDRAW_MONEY_UNLIMITED)); - _SetRankBankTabRightsAndSlots(player->GetRank(), tabId, GuildBankRightsAndSlots(GUILD_BANK_RIGHT_FULL, uint32(GUILD_WITHDRAW_SLOT_UNLIMITED))); - HandleRoster(); // Broadcast for tab rights update + if (!player->HasEnoughMoney(tabCost)) // Should not happen, this is checked by client + return; + + player->ModifyMoney(-int32(tabCost)); + + uint8 rankId = member->GetRankId(); + _CreateNewBankTab(); + _SetRankBankMoneyPerDay(rankId, uint32(GUILD_WITHDRAW_MONEY_UNLIMITED)); + GuildBankRightsAndSlots rightsAndSlots(tabId); + _SetRankBankTabRightsAndSlots(rankId, rightsAndSlots); SendBankTabsInfo(session); } -void Guild::HandleInviteMember(WorldSession* session, const std::string& name) +void Guild::HandleInviteMember(WorldSession* session, std::string const& name) { - Player* pInvitee = sObjectAccessor->FindPlayerByName(name.c_str()); + Player* pInvitee = sObjectAccessor->FindPlayerByName(name); if (!pInvitee) { - SendCommandResult(session, GUILD_INVITE_S, ERR_GUILD_PLAYER_NOT_FOUND_S, name); + SendCommandResult(session, GUILD_COMMAND_INVITE, ERR_GUILD_PLAYER_NOT_FOUND_S, name); return; } @@ -1415,31 +1462,34 @@ void Guild::HandleInviteMember(WorldSession* session, const std::string& name) // Do not show invitations from ignored players if (pInvitee->GetSocial()->HasIgnore(player->GetGUIDLow())) return; + if (!sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_GUILD) && pInvitee->GetTeam() != player->GetTeam()) { - SendCommandResult(session, GUILD_INVITE_S, ERR_GUILD_NOT_ALLIED, name); + SendCommandResult(session, GUILD_COMMAND_INVITE, ERR_GUILD_NOT_ALLIED, name); return; } // Invited player cannot be in another guild if (pInvitee->GetGuildId()) { - SendCommandResult(session, GUILD_INVITE_S, ERR_ALREADY_IN_GUILD_S, name); + SendCommandResult(session, GUILD_COMMAND_INVITE, ERR_ALREADY_IN_GUILD_S, name); return; } // Invited player cannot be invited if (pInvitee->GetGuildIdInvited()) { - SendCommandResult(session, GUILD_INVITE_S, ERR_ALREADY_INVITED_TO_GUILD_S, name); + SendCommandResult(session, GUILD_COMMAND_INVITE, ERR_ALREADY_INVITED_TO_GUILD_S, name); return; } // Inviting player must have rights to invite if (!_HasRankRight(player, GR_RIGHT_INVITE)) { - SendCommandResult(session, GUILD_INVITE_S, ERR_GUILD_PERMISSIONS); + SendCommandResult(session, GUILD_COMMAND_INVITE, ERR_GUILD_PERMISSIONS); return; } - sLog->outDebug(LOG_FILTER_GUILD, "Player %s invited %s to join his Guild", player->GetName(), name.c_str()); + SendCommandResult(session, GUILD_COMMAND_INVITE, ERR_GUILD_COMMAND_SUCCESS, name); + + sLog->outDebug(LOG_FILTER_GUILD, "Player %s invited %s to join his Guild", player->GetName().c_str(), name.c_str()); pInvitee->SetGuildIdInvited(m_id); _LogEvent(GUILD_EVENT_LOG_INVITE_PLAYER, player->GetGUIDLow(), pInvitee->GetGUIDLow()); @@ -1448,8 +1498,7 @@ void Guild::HandleInviteMember(WorldSession* session, const std::string& name) data << player->GetName(); data << m_name; pInvitee->GetSession()->SendPacket(&data); - - sLog->outDebug(LOG_FILTER_GUILD, "WORLD: Sent (SMSG_GUILD_INVITE)"); + sLog->outDebug(LOG_FILTER_GUILD, "SMSG_GUILD_INVITE [%s]", pInvitee->GetName().c_str()); } void Guild::HandleAcceptMember(WorldSession* session) @@ -1459,11 +1508,7 @@ void Guild::HandleAcceptMember(WorldSession* session) player->GetTeam() != sObjectMgr->GetPlayerTeamByGUID(GetLeaderGUID())) return; - if (AddMember(player->GetGUID())) - { - _LogEvent(GUILD_EVENT_LOG_JOIN_GUILD, player->GetGUIDLow()); - _BroadcastEvent(GE_JOINED, player->GetGUID(), player->GetName()); - } + AddMember(player->GetGUID()); } void Guild::HandleLeaveMember(WorldSession* session) @@ -1474,7 +1519,7 @@ void Guild::HandleLeaveMember(WorldSession* session) { if (m_members.size() > 1) // Leader cannot leave if he is not the last member - SendCommandResult(session, GUILD_QUIT_S, ERR_GUILD_LEADER_LEAVE); + SendCommandResult(session, GUILD_COMMAND_QUIT, ERR_GUILD_LEADER_LEAVE); else // Guild is disbanded if leader leaves. Disband(); @@ -1484,132 +1529,134 @@ void Guild::HandleLeaveMember(WorldSession* session) DeleteMember(player->GetGUID(), false, false); _LogEvent(GUILD_EVENT_LOG_LEAVE_GUILD, player->GetGUIDLow()); - _BroadcastEvent(GE_LEFT, player->GetGUID(), player->GetName()); + _BroadcastEvent(GE_LEFT, player->GetGUID(), player->GetName().c_str()); - SendCommandResult(session, GUILD_QUIT_S, ERR_PLAYER_NO_MORE_IN_GUILD, m_name); + SendCommandResult(session, GUILD_COMMAND_QUIT, ERR_GUILD_COMMAND_SUCCESS, m_name); } } -void Guild::HandleRemoveMember(WorldSession* session, const std::string& name) +void Guild::HandleRemoveMember(WorldSession* session, std::string const& name) { Player* player = session->GetPlayer(); // Player must have rights to remove members if (!_HasRankRight(player, GR_RIGHT_REMOVE)) - SendCommandResult(session, GUILD_INVITE_S, ERR_GUILD_PERMISSIONS); - // Removed player must be a member of guild - else if (Member* member = GetMember(session, name)) + SendCommandResult(session, GUILD_COMMAND_REMOVE, ERR_GUILD_PERMISSIONS); + else if (Member* member = GetMember(name)) { - // Leader cannot be removed + // Guild masters cannot be removed if (member->IsRank(GR_GUILDMASTER)) - SendCommandResult(session, GUILD_QUIT_S, ERR_GUILD_LEADER_LEAVE); + SendCommandResult(session, GUILD_COMMAND_REMOVE, ERR_GUILD_LEADER_LEAVE); // Do not allow to remove player with the same rank or higher - else if (member->IsRankNotLower(player->GetRank())) - SendCommandResult(session, GUILD_QUIT_S, ERR_GUILD_RANK_TOO_HIGH_S, name); else { - uint64 guid = member->GetGUID(); - // After call to DeleteMember pointer to member becomes invalid - DeleteMember(guid, false, true); - _LogEvent(GUILD_EVENT_LOG_UNINVITE_PLAYER, player->GetGUIDLow(), GUID_LOPART(guid)); - _BroadcastEvent(GE_REMOVED, 0, name.c_str(), player->GetName()); + Member const* memberMe = GetMember(player->GetGUID()); + if (!memberMe || member->IsRankNotLower(memberMe->GetRankId())) + SendCommandResult(session, GUILD_COMMAND_REMOVE, ERR_GUILD_RANK_TOO_HIGH_S, name); + else + { + uint64 guid = member->GetGUID(); + // After call to DeleteMember pointer to member becomes invalid + DeleteMember(guid, false, true); + _LogEvent(GUILD_EVENT_LOG_UNINVITE_PLAYER, player->GetGUIDLow(), GUID_LOPART(guid)); + _BroadcastEvent(GE_REMOVED, 0, name.c_str(), player->GetName().c_str()); + } } } } -void Guild::HandleUpdateMemberRank(WorldSession* session, const std::string& name, bool demote) +void Guild::HandleUpdateMemberRank(WorldSession* session, std::string const& name, bool demote) { Player* player = session->GetPlayer(); + GuildCommandType type = demote ? GUILD_COMMAND_DEMOTE : GUILD_COMMAND_PROMOTE; // Player must have rights to promote if (!_HasRankRight(player, demote ? GR_RIGHT_DEMOTE : GR_RIGHT_PROMOTE)) - SendCommandResult(session, GUILD_INVITE_S, ERR_GUILD_PERMISSIONS); + SendCommandResult(session, type, ERR_GUILD_PERMISSIONS); // Promoted player must be a member of guild - else if (Member* member = GetMember(session, name)) + else if (Member* member = GetMember(name)) { // Player cannot promote himself if (member->IsSamePlayer(player->GetGUID())) { - SendCommandResult(session, GUILD_INVITE_S, ERR_GUILD_NAME_INVALID); + SendCommandResult(session, type, ERR_GUILD_NAME_INVALID); return; } + Member const* memberMe = GetMember(player->GetGUID()); + uint8 rankId = memberMe->GetRankId(); if (demote) { // Player can demote only lower rank members - if (member->IsRankNotLower(player->GetRank())) + if (member->IsRankNotLower(rankId)) { - SendCommandResult(session, GUILD_INVITE_S, ERR_GUILD_RANK_TOO_HIGH_S, name); + SendCommandResult(session, type, ERR_GUILD_RANK_TOO_HIGH_S, name); return; } // Lowest rank cannot be demoted if (member->GetRankId() >= _GetLowestRankId()) { - SendCommandResult(session, GUILD_INVITE_S, ERR_GUILD_RANK_TOO_LOW_S, name); + SendCommandResult(session, type, ERR_GUILD_RANK_TOO_LOW_S, name); return; } } else { // Allow to promote only to lower rank than member's rank - // member->GetRank() + 1 is the highest rank that current player can promote to - if (member->IsRankNotLower(player->GetRank() + 1)) + // member->GetRankId() + 1 is the highest rank that current player can promote to + if (member->IsRankNotLower(rankId + 1)) { - SendCommandResult(session, GUILD_INVITE_S, ERR_GUILD_RANK_TOO_HIGH_S, name); + SendCommandResult(session, type, ERR_GUILD_RANK_TOO_HIGH_S, name); return; } } - // When promoting player, rank is decreased, when demoting - increased uint32 newRankId = member->GetRankId() + (demote ? 1 : -1); member->ChangeRank(newRankId); _LogEvent(demote ? GUILD_EVENT_LOG_DEMOTE_PLAYER : GUILD_EVENT_LOG_PROMOTE_PLAYER, player->GetGUIDLow(), GUID_LOPART(member->GetGUID()), newRankId); - _BroadcastEvent(demote ? GE_DEMOTION : GE_PROMOTION, 0, player->GetName(), name.c_str(), _GetRankName(newRankId).c_str()); + _BroadcastEvent(demote ? GE_DEMOTION : GE_PROMOTION, 0, player->GetName().c_str(), name.c_str(), _GetRankName(newRankId).c_str()); } } -void Guild::HandleAddNewRank(WorldSession* session, const std::string& name) +void Guild::HandleAddNewRank(WorldSession* session, std::string const& name) { - if (_GetRanksSize() >= GUILD_RANKS_MAX_COUNT) + uint8 size = _GetRanksSize(); + if (size >= GUILD_RANKS_MAX_COUNT) return; // Only leader can add new rank - if (!_IsLeader(session->GetPlayer())) - SendCommandResult(session, GUILD_INVITE_S, ERR_GUILD_PERMISSIONS); - else - { - _CreateRank(name, GR_RIGHT_GCHATLISTEN | GR_RIGHT_GCHATSPEAK); - HandleQuery(session); - HandleRoster(); // Broadcast for tab rights update - } + if (_IsLeader(session->GetPlayer())) + if (_CreateRank(name, GR_RIGHT_GCHATLISTEN | GR_RIGHT_GCHATSPEAK)) + { + char aux[2]; + sprintf(aux, "%u", size); + _BroadcastEvent(GE_RANK_UPDATED, 0, aux, name.c_str()); + } } void Guild::HandleRemoveLowestRank(WorldSession* session) { - // Cannot remove rank if total count is minimum allowed by the client - if (_GetRanksSize() <= GUILD_RANKS_MIN_COUNT) + HandleRemoveRank(session, _GetLowestRankId()); +} + +void Guild::HandleRemoveRank(WorldSession* session, uint8 rankId) +{ + // Cannot remove rank if total count is minimum allowed by the client or is not leader + if (_GetRanksSize() <= GUILD_RANKS_MIN_COUNT || rankId >= _GetRanksSize() || !_IsLeader(session->GetPlayer())) return; - // Only leader can delete ranks - if (!_IsLeader(session->GetPlayer())) - SendCommandResult(session, GUILD_INVITE_S, ERR_GUILD_PERMISSIONS); - else - { - uint8 rankId = _GetLowestRankId(); - // Delete bank rights for rank - PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_GUILD_BANK_RIGHTS_FOR_RANK); - stmt->setUInt32(0, m_id); - stmt->setUInt8 (1, rankId); - CharacterDatabase.Execute(stmt); - // Delete rank - stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_GUILD_LOWEST_RANK); - stmt->setUInt32(0, m_id); - stmt->setUInt8 (1, rankId); - CharacterDatabase.Execute(stmt); + // Delete bank rights for rank + PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_GUILD_BANK_RIGHTS_FOR_RANK); + stmt->setUInt32(0, m_id); + stmt->setUInt8(1, rankId); + CharacterDatabase.Execute(stmt); + // Delete rank + stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_GUILD_LOWEST_RANK); + stmt->setUInt32(0, m_id); + stmt->setUInt8(1, rankId); + CharacterDatabase.Execute(stmt); - m_ranks.pop_back(); + m_ranks.pop_back(); - HandleQuery(session); - HandleRoster(); // Broadcast for tab rights update - } + _BroadcastEvent(GE_RANK_DELETED, 0); } void Guild::HandleMemberDepositMoney(WorldSession* session, uint32 amount) @@ -1620,26 +1667,23 @@ void Guild::HandleMemberDepositMoney(WorldSession* session, uint32 amount) sScriptMgr->OnGuildMemberDepositMoney(this, player, amount); SQLTransaction trans = CharacterDatabase.BeginTransaction(); - // Add money to bank _ModifyBankMoney(trans, amount, true); - // Remove money from player + player->ModifyMoney(-int32(amount)); player->SaveGoldToDB(trans); - // Log GM action (TODO: move to scripts) + _LogBankEvent(trans, GUILD_BANK_LOG_DEPOSIT_MONEY, uint8(0), player->GetGUIDLow(), amount); + + CharacterDatabase.CommitTransaction(trans); + + std::string aux = ByteArrayToHexStr(reinterpret_cast<uint8*>(&amount), 8, true); + _BroadcastEvent(GE_BANK_MONEY_CHANGED, 0, aux.c_str()); + if (!AccountMgr::IsPlayerAccount(player->GetSession()->GetSecurity()) && sWorld->getBoolConfig(CONFIG_GM_LOG_TRADE)) { sLog->outCommand(player->GetSession()->GetAccountId(), "GM %s (Account: %u) deposit money (Amount: %u) to guild bank (Guild ID %u)", - player->GetName(), player->GetSession()->GetAccountId(), amount, m_id); + player->GetName().c_str(), player->GetSession()->GetAccountId(), amount, m_id); } - // Log guild bank event - _LogBankEvent(trans, GUILD_BANK_LOG_DEPOSIT_MONEY, uint8(0), player->GetGUIDLow(), amount); - - CharacterDatabase.CommitTransaction(trans); - - SendBankTabsInfo(session); - _SendBankContent(session, 0); - _SendBankMoneyUpdate(session); } bool Guild::HandleMemberWithdrawMoney(WorldSession* session, uint32 amount, bool repair) @@ -1648,24 +1692,20 @@ bool Guild::HandleMemberWithdrawMoney(WorldSession* session, uint32 amount, bool return false; Player* player = session->GetPlayer(); - if (!_HasRankRight(player, repair ? GR_RIGHT_WITHDRAW_REPAIR : GR_RIGHT_WITHDRAW_GOLD)) - return false; - uint32 remainingMoney = _GetMemberRemainingMoney(player->GetGUID()); - if (!remainingMoney) + Member* member = GetMember(player->GetGUID()); + if (!member) return false; - if (remainingMoney < amount) - return false; + if (uint32(_GetMemberRemainingMoney(member)) < amount) // Check if we have enough slot/money today + return false; // Call script after validation and before money transfer. sScriptMgr->OnGuildMemberWitdrawMoney(this, player, amount, repair); SQLTransaction trans = CharacterDatabase.BeginTransaction(); // Update remaining money amount - if (remainingMoney < uint32(GUILD_WITHDRAW_MONEY_UNLIMITED)) - if (Member* member = GetMember(player->GetGUID())) - member->DecreaseBankRemainingValue(trans, GUILD_BANK_MAX_TABS, amount); + member->UpdateBankWithdrawValue(trans, GUILD_BANK_MAX_TABS, amount); // Remove money from bank _ModifyBankMoney(trans, amount, false); // Add money to player (if required) @@ -1678,13 +1718,8 @@ bool Guild::HandleMemberWithdrawMoney(WorldSession* session, uint32 amount, bool _LogBankEvent(trans, repair ? GUILD_BANK_LOG_REPAIR_MONEY : GUILD_BANK_LOG_WITHDRAW_MONEY, uint8(0), player->GetGUIDLow(), amount); CharacterDatabase.CommitTransaction(trans); - SendMoneyInfo(session); - if (!repair) - { - SendBankTabsInfo(session); - _SendBankContent(session, 0); - _SendBankMoneyUpdate(session); - } + std::string aux = ByteArrayToHexStr(reinterpret_cast<uint8*>(&amount), 8, true); + _BroadcastEvent(GE_BANK_MONEY_CHANGED, 0, aux.c_str()); return true; } @@ -1695,23 +1730,21 @@ void Guild::HandleMemberLogout(WorldSession* session) { member->SetStats(player); member->UpdateLogoutTime(); + member->ResetFlags(); } - _BroadcastEvent(GE_SIGNED_OFF, player->GetGUID(), player->GetName()); + _BroadcastEvent(GE_SIGNED_OFF, player->GetGUID(), player->GetName().c_str()); } void Guild::HandleDisband(WorldSession* session) { // Only leader can disband guild - if (!_IsLeader(session->GetPlayer())) - Guild::SendCommandResult(session, GUILD_INVITE_S, ERR_GUILD_PERMISSIONS); - else + if (_IsLeader(session->GetPlayer())) { Disband(); - sLog->outDebug(LOG_FILTER_GUILD, "WORLD: Guild Successfully Disbanded"); + sLog->outDebug(LOG_FILTER_GUILD, "Guild Successfully Disbanded"); } } -/////////////////////////////////////////////////////////////////////////////// // Send data to client void Guild::SendInfo(WorldSession* session) const { @@ -1722,7 +1755,7 @@ void Guild::SendInfo(WorldSession* session) const data << m_accountsNumber; // Number of accounts session->SendPacket(&data); - sLog->outDebug(LOG_FILTER_GUILD, "WORLD: Sent (SMSG_GUILD_INFO)"); + sLog->outDebug(LOG_FILTER_GUILD, "SMSG_GUILD_INFO [%s]", session->GetPlayerInfo().c_str()); } void Guild::SendEventLog(WorldSession* session) const @@ -1730,7 +1763,7 @@ void Guild::SendEventLog(WorldSession* session) const WorldPacket data(MSG_GUILD_EVENT_LOG_QUERY, 1 + m_eventLog->GetSize() * (1 + 8 + 4)); m_eventLog->WritePacket(data); session->SendPacket(&data); - sLog->outDebug(LOG_FILTER_GUILD, "WORLD: Sent (MSG_GUILD_EVENT_LOG_QUERY)"); + sLog->outDebug(LOG_FILTER_GUILD, "MSG_GUILD_EVENT_LOG_QUERY [%s]", session->GetPlayerInfo().c_str()); } void Guild::SendBankLog(WorldSession* session, uint8 tabId) const @@ -1743,87 +1776,87 @@ void Guild::SendBankLog(WorldSession* session, uint8 tabId) const data << uint8(tabId); pLog->WritePacket(data); session->SendPacket(&data); - sLog->outDebug(LOG_FILTER_GUILD, "WORLD: Sent (MSG_GUILD_BANK_LOG_QUERY)"); + sLog->outDebug(LOG_FILTER_GUILD, "MSG_GUILD_BANK_LOG_QUERY [%s]", session->GetPlayerInfo().c_str()); } } void Guild::SendBankTabData(WorldSession* session, uint8 tabId) const { if (tabId < _GetPurchasedTabsSize()) - { - SendMoneyInfo(session); _SendBankContent(session, tabId); - } } -void Guild::SendBankTabsInfo(WorldSession* session) const +void Guild::SendBankTabsInfo(WorldSession* session, bool sendAllSlots /*= false*/) const { - WorldPacket data(SMSG_GUILD_BANK_LIST, 500); - - data << uint64(m_bankMoney); - data << uint8(0); // TabInfo packet must be for tabId 0 - data << uint32(_GetMemberRemainingSlots(session->GetPlayer()->GetGUID(), 0)); - data << uint8(1); // Tell client that this packet includes tab info - - data << uint8(_GetPurchasedTabsSize()); // Number of tabs - for (uint8 i = 0; i < _GetPurchasedTabsSize(); ++i) - m_bankTabs[i]->WriteInfoPacket(data); - - data << uint8(0); // Do not send tab content - session->SendPacket(&data); - - sLog->outDebug(LOG_FILTER_GUILD, "WORLD: Sent (SMSG_GUILD_BANK_LIST)"); + _SendBankList(session, 0, sendAllSlots); } void Guild::SendBankTabText(WorldSession* session, uint8 tabId) const { - if (const BankTab* pTab = GetBankTab(tabId)) - pTab->SendText(this, session); + if (BankTab const* tab = GetBankTab(tabId)) + tab->SendText(this, session); } void Guild::SendPermissions(WorldSession* session) const { - uint64 guid = session->GetPlayer()->GetGUID(); - uint8 rankId = session->GetPlayer()->GetRank(); + Member const* member = GetMember(session->GetPlayer()->GetGUID()); + if (!member) + return; + + uint8 rankId = member->GetRankId(); WorldPacket data(MSG_GUILD_PERMISSIONS, 4 * 15 + 1); data << uint32(rankId); data << uint32(_GetRankRights(rankId)); - data << uint32(_GetMemberRemainingMoney(guid)); - data << uint8 (_GetPurchasedTabsSize()); - // Why sending all info when not all tabs are purchased??? + data << uint32(_GetMemberRemainingMoney(member)); + data << uint8(_GetPurchasedTabsSize()); for (uint8 tabId = 0; tabId < GUILD_BANK_MAX_TABS; ++tabId) { data << uint32(_GetRankBankTabRights(rankId, tabId)); - data << uint32(_GetMemberRemainingSlots(guid, tabId)); + data << uint32(_GetMemberRemainingSlots(member, tabId)); } + session->SendPacket(&data); - sLog->outDebug(LOG_FILTER_GUILD, "WORLD: Sent (MSG_GUILD_PERMISSIONS)"); + sLog->outDebug(LOG_FILTER_GUILD, "MSG_GUILD_PERMISSIONS [%s] Rank: %u", session->GetPlayerInfo().c_str(), rankId); } void Guild::SendMoneyInfo(WorldSession* session) const { + Member const* member = GetMember(session->GetPlayer()->GetGUID()); + if (!member) + return; + + int32 amount = _GetMemberRemainingMoney(member); WorldPacket data(MSG_GUILD_BANK_MONEY_WITHDRAWN, 4); - data << uint32(_GetMemberRemainingMoney(session->GetPlayer()->GetGUID())); + data << int32(amount); session->SendPacket(&data); - sLog->outDebug(LOG_FILTER_GUILD, "WORLD: Sent MSG_GUILD_BANK_MONEY_WITHDRAWN"); + sLog->outDebug(LOG_FILTER_GUILD, "MSG_GUILD_BANK_MONEY_WITHDRAWN [%s] Money: %u", session->GetPlayerInfo().c_str(), amount); } -void Guild::SendLoginInfo(WorldSession* session) const +void Guild::SendLoginInfo(WorldSession* session) { WorldPacket data(SMSG_GUILD_EVENT, 1 + 1 + m_motd.size() + 1); data << uint8(GE_MOTD); data << uint8(1); data << m_motd; session->SendPacket(&data); - sLog->outDebug(LOG_FILTER_GUILD, "WORLD: Sent guild MOTD (SMSG_GUILD_EVENT)"); + + sLog->outDebug(LOG_FILTER_GUILD, "SMSG_GUILD_EVENT [%s] MOTD", session->GetPlayerInfo().c_str()); SendBankTabsInfo(session); - _BroadcastEvent(GE_SIGNED_ON, session->GetPlayer()->GetGUID(), session->GetPlayer()->GetName()); + Player* player = session->GetPlayer(); + + HandleRoster(session); + _BroadcastEvent(GE_SIGNED_ON, player->GetGUID(), player->GetName().c_str()); + + if (Member* member = GetMember(player->GetGUID())) + { + member->SetStats(player); + member->AddFlag(GUILDMEMBER_STATUS_ONLINE); + } } -/////////////////////////////////////////////////////////////////////////////// // Loading methods bool Guild::LoadFromDB(Field* fields) { @@ -1873,10 +1906,10 @@ bool Guild::LoadMemberFromDB(Field* fields) void Guild::LoadBankRightFromDB(Field* fields) { - // rights slots - GuildBankRightsAndSlots rightsAndSlots(fields[3].GetUInt8(), fields[4].GetUInt32()); - // rankId tabId - _SetRankBankTabRightsAndSlots(fields[2].GetUInt8(), fields[1].GetUInt8(), rightsAndSlots, false); + // tabId rights slots + GuildBankRightsAndSlots rightsAndSlots(fields[1].GetUInt8(), fields[3].GetUInt8(), fields[4].GetUInt32()); + // rankId + _SetRankBankTabRightsAndSlots(fields[2].GetUInt8(), rightsAndSlots, false); } bool Guild::LoadEventLogFromDB(Field* fields) @@ -1936,15 +1969,13 @@ bool Guild::LoadBankEventLogFromDB(Field* fields) return true; } -bool Guild::LoadBankTabFromDB(Field* fields) +void Guild::LoadBankTabFromDB(Field* fields) { uint8 tabId = fields[1].GetUInt8(); if (tabId >= _GetPurchasedTabsSize()) - { sLog->outError(LOG_FILTER_GUILD, "Invalid tab (tabId: %u) in guild bank, skipped.", tabId); - return false; - } - return m_bankTabs[tabId]->LoadFromDB(fields); + else + m_bankTabs[tabId]->LoadFromDB(fields); } bool Guild::LoadBankItemFromDB(Field* fields) @@ -1968,14 +1999,15 @@ bool Guild::Validate() // Between ranks in sequence cannot be gaps - so 0, 1, 2, 4 is impossible // Min ranks count is 5 and max is 10. bool broken_ranks = false; - if (_GetRanksSize() < GUILD_RANKS_MIN_COUNT || _GetRanksSize() > GUILD_RANKS_MAX_COUNT) + uint8 ranks = _GetRanksSize(); + if (ranks < GUILD_RANKS_MIN_COUNT || ranks > GUILD_RANKS_MAX_COUNT) { sLog->outError(LOG_FILTER_GUILD, "Guild %u has invalid number of ranks, creating new...", m_id); broken_ranks = true; } else { - for (uint8 rankId = 0; rankId < _GetRanksSize(); ++rankId) + for (uint8 rankId = 0; rankId < ranks; ++rankId) { RankInfo* rankInfo = GetRankInfo(rankId); if (rankInfo->GetId() != rankId) @@ -1983,6 +2015,15 @@ bool Guild::Validate() sLog->outError(LOG_FILTER_GUILD, "Guild %u has broken rank id %u, creating default set of ranks...", m_id, rankId); broken_ranks = true; } + else + { + SQLTransaction trans = CharacterDatabase.BeginTransaction(); + if (rankInfo->CreateMissingTabsIfNeeded(_GetPurchasedTabsSize(), trans)) + { + sLog->outError(LOG_FILTER_GUILD, "Guild %u has broken Tabs for rank id %u, creating default tab...", m_id, rankId); + CharacterDatabase.CommitTransaction(trans); + } + } } } @@ -2024,9 +2065,8 @@ bool Guild::Validate() return true; } -/////////////////////////////////////////////////////////////////////////////// // Broadcasts -void Guild::BroadcastToGuild(WorldSession* session, bool officerOnly, const std::string& msg, uint32 language) const +void Guild::BroadcastToGuild(WorldSession* session, bool officerOnly, std::string const& msg, uint32 language) const { if (session && session->GetPlayer() && _HasRankRight(session->GetPlayer(), officerOnly ? GR_RIGHT_OFFCHATSPEAK : GR_RIGHT_GCHATSPEAK)) { @@ -2055,7 +2095,6 @@ void Guild::BroadcastPacket(WorldPacket* packet) const player->GetSession()->SendPacket(packet); } -/////////////////////////////////////////////////////////////////////////////// // Members handling bool Guild::AddMember(uint64 guid, uint8 rankId) { @@ -2075,15 +2114,26 @@ bool Guild::AddMember(uint64 guid, uint8 rankId) uint32 lowguid = GUID_LOPART(guid); - // If rank was not passed, assing lowest possible rank + // If rank was not passed, assign lowest possible rank if (rankId == GUILD_RANK_NONE) rankId = _GetLowestRankId(); Member* member = new Member(m_id, guid, rankId); + std::string name; if (player) + { + m_members[lowguid] = member; + player->SetInGuild(m_id); + player->SetGuildIdInvited(0); + player->SetRank(rankId); member->SetStats(player); + SendLoginInfo(player->GetSession()); + name = player->GetName(); + } else { + member->ResetFlags(); + bool ok = false; // Player must exist PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHAR_DATA_FOR_GUILD); @@ -2091,8 +2141,9 @@ bool Guild::AddMember(uint64 guid, uint8 rankId) if (PreparedQueryResult result = CharacterDatabase.Query(stmt)) { Field* fields = result->Fetch(); + name = fields[0].GetString(); member->SetStats( - fields[0].GetString(), + name, fields[1].GetUInt8(), fields[2].GetUInt8(), fields[3].GetUInt16(), @@ -2105,20 +2156,15 @@ bool Guild::AddMember(uint64 guid, uint8 rankId) delete member; return false; } + m_members[lowguid] = member; } - m_members[lowguid] = member; SQLTransaction trans(NULL); member->SaveToDB(trans); - // If player not in game data in will be loaded from guild tables, so no need to update it! - if (player) - { - player->SetInGuild(m_id); - player->SetRank(rankId); - player->SetGuildIdInvited(0); - } _UpdateAccountsNumber(); + _LogEvent(GUILD_EVENT_LOG_JOIN_GUILD, lowguid); + _BroadcastEvent(GE_JOINED, guid, name.c_str()); // Call scripts if member was succesfully added (and stored to database) sScriptMgr->OnGuildAddMember(this, player, rankId); @@ -2144,6 +2190,7 @@ void Guild::DeleteMember(uint64 guid, bool isDisbanding, bool isKicked) else if (!newLeader || newLeader->GetRankId() > i->second->GetRankId()) newLeader = i->second; } + if (!newLeader) { Disband(); @@ -2163,7 +2210,7 @@ void Guild::DeleteMember(uint64 guid, bool isDisbanding, bool isKicked) _BroadcastEvent(GE_LEFT, guid, oldLeader->GetName().c_str()); } } - // Call script on remove before member is acutally removed from guild (and database) + // Call script on remove before member is actually removed from guild (and database) sScriptMgr->OnGuildRemoveMember(this, player, isDisbanding, isKicked); if (Member* member = GetMember(guid)) @@ -2193,7 +2240,6 @@ bool Guild::ChangeMemberRank(uint64 guid, uint8 newRank) return false; } -/////////////////////////////////////////////////////////////////////////////// // Bank (items move) void Guild::SwapItems(Player* player, uint8 tabId, uint8 slotId, uint8 destTabId, uint8 destSlotId, uint32 splitedAmount) { @@ -2222,9 +2268,8 @@ void Guild::SwapItemsWithInventory(Player* player, bool toChar, uint8 tabId, uin _MoveItems(&charData, &bankData, splitedAmount); } -/////////////////////////////////////////////////////////////////////////////// // Bank tabs -void Guild::SetBankTabText(uint8 tabId, const std::string& text) +void Guild::SetBankTabText(uint8 tabId, std::string const& text) { if (BankTab* pTab = GetBankTab(tabId)) { @@ -2233,7 +2278,6 @@ void Guild::SetBankTabText(uint8 tabId, const std::string& text) } } -/////////////////////////////////////////////////////////////////////////////// // Private methods void Guild::_CreateLogHolders() { @@ -2242,18 +2286,14 @@ void Guild::_CreateLogHolders() m_bankEventLog[tabId] = new LogHolder(m_id, sWorld->getIntConfig(CONFIG_GUILD_BANK_EVENT_LOG_COUNT)); } -bool Guild::_CreateNewBankTab() +void Guild::_CreateNewBankTab() { - if (_GetPurchasedTabsSize() >= GUILD_BANK_MAX_TABS) - return false; - uint8 tabId = _GetPurchasedTabsSize(); // Next free id m_bankTabs.push_back(new BankTab(m_id, tabId)); - PreparedStatement* stmt = NULL; SQLTransaction trans = CharacterDatabase.BeginTransaction(); - stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_GUILD_BANK_TAB); + PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_GUILD_BANK_TAB); stmt->setUInt32(0, m_id); stmt->setUInt8 (1, tabId); trans->Append(stmt); @@ -2264,14 +2304,11 @@ bool Guild::_CreateNewBankTab() trans->Append(stmt); CharacterDatabase.CommitTransaction(trans); - return true; } void Guild::_CreateDefaultGuildRanks(LocaleConstant loc) { - PreparedStatement* stmt = NULL; - - stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_GUILD_RANKS); + PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_GUILD_RANKS); stmt->setUInt32(0, m_id); CharacterDatabase.Execute(stmt); @@ -2286,29 +2323,22 @@ void Guild::_CreateDefaultGuildRanks(LocaleConstant loc) _CreateRank(sObjectMgr->GetTrinityString(LANG_GUILD_INITIATE, loc), GR_RIGHT_GCHATLISTEN | GR_RIGHT_GCHATSPEAK); } -void Guild::_CreateRank(const std::string& name, uint32 rights) +bool Guild::_CreateRank(std::string const& name, uint32 rights) { - if (_GetRanksSize() >= GUILD_RANKS_MAX_COUNT) - return; - - // Ranks represent sequence 0, 1, 2, ... where 0 means guildmaster uint8 newRankId = _GetRanksSize(); + if (newRankId >= GUILD_RANKS_MAX_COUNT) + return false; + // Ranks represent sequence 0, 1, 2, ... where 0 means guildmaster RankInfo info(m_id, newRankId, name, rights, 0); m_ranks.push_back(info); SQLTransaction trans = CharacterDatabase.BeginTransaction(); - for (uint8 i = 0; i < _GetPurchasedTabsSize(); ++i) - { - // Create bank rights with default values - PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_GUILD_BANK_RIGHT_DEFAULT); - stmt->setUInt32(0, m_id); - stmt->setUInt8 (1, i); - stmt->setUInt8 (2, newRankId); - trans->Append(stmt); - } + info.CreateMissingTabsIfNeeded(_GetPurchasedTabsSize(), trans); info.SaveToDB(trans); CharacterDatabase.CommitTransaction(trans); + + return true; } // Updates the number of accounts that are in the guild @@ -2382,28 +2412,16 @@ void Guild::_SetLeaderGUID(Member* pLeader) void Guild::_SetRankBankMoneyPerDay(uint8 rankId, uint32 moneyPerDay) { if (RankInfo* rankInfo = GetRankInfo(rankId)) - { - for (Members::iterator itr = m_members.begin(); itr != m_members.end(); ++itr) - if (itr->second->IsRank(rankId)) - itr->second->ResetMoneyTime(); - rankInfo->SetBankMoneyPerDay(moneyPerDay); - } } -void Guild::_SetRankBankTabRightsAndSlots(uint8 rankId, uint8 tabId, GuildBankRightsAndSlots rightsAndSlots, bool saveToDB) +void Guild::_SetRankBankTabRightsAndSlots(uint8 rankId, GuildBankRightsAndSlots rightsAndSlots, bool saveToDB) { - if (tabId >= _GetPurchasedTabsSize()) + if (rightsAndSlots.GetTabId() >= _GetPurchasedTabsSize()) return; if (RankInfo* rankInfo = GetRankInfo(rankId)) - { - for (Members::iterator itr = m_members.begin(); itr != m_members.end(); ++itr) - if (itr->second->IsRank(rankId)) - itr->second->ResetTabTimes(); - - rankInfo->SetBankTabSlotsAndRights(tabId, rightsAndSlots, saveToDB); - } + rankInfo->SetBankTabSlotsAndRights(rightsAndSlots, saveToDB); } inline std::string Guild::_GetRankName(uint8 rankId) const @@ -2420,14 +2438,14 @@ inline uint32 Guild::_GetRankRights(uint8 rankId) const return 0; } -inline uint32 Guild::_GetRankBankMoneyPerDay(uint8 rankId) const +inline int32 Guild::_GetRankBankMoneyPerDay(uint8 rankId) const { if (const RankInfo* rankInfo = GetRankInfo(rankId)) return rankInfo->GetBankMoneyPerDay(); return 0; } -inline uint32 Guild::_GetRankBankTabSlotsPerDay(uint8 rankId, uint8 tabId) const +inline int32 Guild::_GetRankBankTabSlotsPerDay(uint8 rankId, uint8 tabId) const { if (tabId < _GetPurchasedTabsSize()) if (const RankInfo* rankInfo = GetRankInfo(rankId)) @@ -2435,35 +2453,57 @@ inline uint32 Guild::_GetRankBankTabSlotsPerDay(uint8 rankId, uint8 tabId) const return 0; } -inline uint8 Guild::_GetRankBankTabRights(uint8 rankId, uint8 tabId) const +inline int8 Guild::_GetRankBankTabRights(uint8 rankId, uint8 tabId) const { if (const RankInfo* rankInfo = GetRankInfo(rankId)) return rankInfo->GetBankTabRights(tabId); return 0; } -inline uint32 Guild::_GetMemberRemainingSlots(uint64 guid, uint8 tabId) const +inline int32 Guild::_GetMemberRemainingSlots(Member const* member, uint8 tabId) const { - if (const Member* member = GetMember(guid)) - return member->GetBankRemainingValue(tabId, this); + if (member) + { + uint8 rankId = member->GetRankId(); + if (rankId == GR_GUILDMASTER) + return GUILD_WITHDRAW_SLOT_UNLIMITED; + if ((_GetRankBankTabRights(rankId, tabId) & GUILD_BANK_RIGHT_VIEW_TAB) != GR_RIGHT_EMPTY) + { + int32 remaining = _GetRankBankTabSlotsPerDay(rankId, tabId) - member->GetBankWithdrawValue(tabId); + if (remaining > 0) + return remaining; + } + } return 0; } -inline uint32 Guild::_GetMemberRemainingMoney(uint64 guid) const +inline int32 Guild::_GetMemberRemainingMoney(Member const* member) const { - if (const Member* member = GetMember(guid)) - return member->GetBankRemainingValue(GUILD_BANK_MAX_TABS, this); + if (member) + { + uint8 rankId = member->GetRankId(); + if (rankId == GR_GUILDMASTER) + return GUILD_WITHDRAW_MONEY_UNLIMITED; + + if ((_GetRankRights(rankId) & (GR_RIGHT_WITHDRAW_REPAIR | GR_RIGHT_WITHDRAW_GOLD)) != GR_RIGHT_EMPTY) + { + int32 remaining = _GetRankBankMoneyPerDay(rankId) - member->GetBankWithdrawValue(GUILD_BANK_MAX_TABS); + if (remaining > 0) + return remaining; + } + } return 0; } -inline void Guild::_DecreaseMemberRemainingSlots(SQLTransaction& trans, uint64 guid, uint8 tabId) +inline void Guild::_UpdateMemberWithdrawSlots(SQLTransaction& trans, uint64 guid, uint8 tabId) { - // Remaining slots must be more then 0 - if (uint32 remainingSlots = _GetMemberRemainingSlots(guid, tabId)) - // Ignore guild master - if (remainingSlots < uint32(GUILD_WITHDRAW_SLOT_UNLIMITED)) - if (Member* member = GetMember(guid)) - member->DecreaseBankRemainingValue(trans, tabId, 1); + if (Member* member = GetMember(guid)) + { + uint8 rankId = member->GetRankId(); + if (rankId != GR_GUILDMASTER + && member->GetBankWithdrawValue(tabId) < _GetRankBankTabSlotsPerDay(rankId, tabId)) + member->UpdateBankWithdrawValue(trans, tabId, 1); + } } inline bool Guild::_MemberHasTabRights(uint64 guid, uint8 tabId, uint32 rights) const @@ -2494,6 +2534,10 @@ void Guild::_LogBankEvent(SQLTransaction& trans, GuildBankEventLogTypes eventTyp if (tabId > GUILD_BANK_MAX_TABS) return; + // not logging moves within the same tab + if (eventType == GUILD_BANK_LOG_MOVE_ITEM && tabId == destTabId) + return; + uint8 dbTabId = tabId; if (BankEventLogEntry::IsMoneyEvent(eventType)) { @@ -2531,7 +2575,7 @@ void Guild::_MoveItems(MoveItemData* pSrc, MoveItemData* pDest, uint32 splitedAm /* if (pItemSrc->GetCount() == 0) { - sLog->outFatal(LOG_FILTER_GENERAL, "Guild::SwapItems: Player %s(GUIDLow: %u) tried to move item %u from tab %u slot %u to tab %u slot %u, but item %u has a stack of zero!", + sLog->outFatal(LOG_FILTER_GUILD, "Guild::SwapItems: Player %s(GUIDLow: %u) tried to move item %u from tab %u slot %u to tab %u slot %u, but item %u has a stack of zero!", player->GetName(), player->GetGUIDLow(), pItemSrc->GetEntry(), tabId, slotId, destTabId, destSlotId, pItemSrc->GetEntry()); //return; // Commented out for now, uncomment when it's verified that this causes a crash!! } @@ -2627,36 +2671,15 @@ bool Guild::_DoItemsMove(MoveItemData* pSrc, MoveItemData* pDest, bool sendError void Guild::_SendBankContent(WorldSession* session, uint8 tabId) const { uint64 guid = session->GetPlayer()->GetGUID(); - if (_MemberHasTabRights(guid, tabId, GUILD_BANK_RIGHT_VIEW_TAB)) - if (const BankTab* pTab = GetBankTab(tabId)) - { - WorldPacket data(SMSG_GUILD_BANK_LIST, 1200); - - data << uint64(m_bankMoney); - data << uint8(tabId); - data << uint32(_GetMemberRemainingSlots(guid, tabId)); - data << uint8(0); // Tell client that there's no tab info in this packet - - pTab->WritePacket(data); - - session->SendPacket(&data); + if (!_MemberHasTabRights(guid, tabId, GUILD_BANK_RIGHT_VIEW_TAB)) + return; - sLog->outDebug(LOG_FILTER_GUILD, "WORLD: Sent (SMSG_GUILD_BANK_LIST)"); - } + _SendBankList(session, tabId, true); } void Guild::_SendBankMoneyUpdate(WorldSession* session) const { - WorldPacket data(SMSG_GUILD_BANK_LIST, 8 + 1 + 4 + 1 + 1); - - data << uint64(m_bankMoney); - data << uint8(0); // tabId, default 0 - data << uint32(_GetMemberRemainingSlots(session->GetPlayer()->GetGUID(), 0)); - data << uint8(0); // Tell that there's no tab info in this packet - data << uint8(0); // No items - BroadcastPacket(&data); - - sLog->outDebug(LOG_FILTER_GUILD, "WORLD: Sent (SMSG_GUILD_BANK_LIST)"); + _SendBankList(session); } void Guild::_SendBankContentUpdate(MoveItemData* pSrc, MoveItemData* pDest) const @@ -2687,37 +2710,13 @@ void Guild::_SendBankContentUpdate(MoveItemData* pSrc, MoveItemData* pDest) cons tabId = pDest->GetContainer(); pDest->CopySlots(slots); } + _SendBankContentUpdate(tabId, slots); } void Guild::_SendBankContentUpdate(uint8 tabId, SlotIds slots) const { - if (const BankTab* pTab = GetBankTab(tabId)) - { - WorldPacket data(SMSG_GUILD_BANK_LIST, 1200); - - data << uint64(m_bankMoney); - data << uint8(tabId); - - size_t rempos = data.wpos(); - data << uint32(0); // Item withdraw amount, will be filled later - data << uint8(0); // Tell client that there's no tab info in this packet - - data << uint8(slots.size()); - for (uint8 slotId = 0; slotId < GUILD_BANK_MAX_SLOTS; ++slotId) - if (slots.find(slotId) != slots.end()) - pTab->WriteSlotPacket(data, slotId); - - for (Members::const_iterator itr = m_members.begin(); itr != m_members.end(); ++itr) - if (_MemberHasTabRights(itr->second->GetGUID(), tabId, GUILD_BANK_RIGHT_VIEW_TAB)) - if (Player* player = itr->second->FindPlayer()) - { - data.put<uint32>(rempos, uint32(_GetMemberRemainingSlots(player->GetGUID(), tabId))); - player->GetSession()->SendPacket(&data); - } - - sLog->outDebug(LOG_FILTER_GUILD, "WORLD: Sent (SMSG_GUILD_BANK_LIST)"); - } + _SendBankList(NULL, tabId, false, &slots); } void Guild::_BroadcastEvent(GuildEvents guildEvent, uint64 guid, const char* param1, const char* param2, const char* param3) const @@ -2739,6 +2738,73 @@ void Guild::_BroadcastEvent(GuildEvents guildEvent, uint64 guid, const char* par data << uint64(guid); BroadcastPacket(&data); + sLog->outDebug(LOG_FILTER_GUILD, "SMSG_GUILD_EVENT [Broadcast] Event: %u", guildEvent); +} + +void Guild::_SendBankList(WorldSession* session /* = NULL*/, uint8 tabId /*= 0*/, bool sendAllSlots /*= false*/, SlotIds *slots /*= NULL*/) const +{ + WorldPacket data(SMSG_GUILD_BANK_LIST, 500); + data << uint64(m_bankMoney); + data << uint8(tabId); + size_t rempos = data.wpos(); + data << uint32(0); + data << uint8(sendAllSlots); + + if (sendAllSlots && !tabId) + { + data << uint8(_GetPurchasedTabsSize()); // Number of tabs + for (uint8 i = 0; i < _GetPurchasedTabsSize(); ++i) + m_bankTabs[i]->WriteInfoPacket(data); + } + + BankTab const* tab = GetBankTab(tabId); + if (!tab) + data << uint8(0); + else if (sendAllSlots) + tab->WritePacket(data); + else if (slots && !slots->empty()) + { + data << uint8(slots->size()); + for (SlotIds::const_iterator itr = slots->begin(); itr != slots->end(); ++itr) + tab->WriteSlotPacket(data, *itr, false); + } + else + data << uint8(0); + + if (session) + { + int32 numSlots = 0; + if (Member const* member = GetMember(session->GetPlayer()->GetGUID())) + numSlots = _GetMemberRemainingSlots(member, tabId); + data.put<uint32>(rempos, numSlots); + session->SendPacket(&data); + sLog->outDebug(LOG_FILTER_GUILD, "SMSG_GUILD_BANK_LIST [%s]: TabId: %u, FullSlots: %u, slots: %d", + session->GetPlayerInfo().c_str(), tabId, sendAllSlots, numSlots); + } + else // TODO - Probably this is just sent to session + those that have sent CMSG_GUILD_BANKER_ACTIVATE + { + for (Members::const_iterator itr = m_members.begin(); itr != m_members.end(); ++itr) + { + if (!_MemberHasTabRights(itr->second->GetGUID(), tabId, GUILD_BANK_RIGHT_VIEW_TAB)) + continue; + Player* player = itr->second->FindPlayer(); + if (!player) + continue; + + uint32 numSlots = _GetMemberRemainingSlots(itr->second, tabId); + data.put<uint32>(rempos, numSlots); + player->GetSession()->SendPacket(&data); + sLog->outDebug(LOG_FILTER_GUILD, "SMSG_GUILD_BANK_LIST [%s]: TabId: %u, FullSlots: %u, slots: %u" + , player->GetName().c_str(), tabId, sendAllSlots, numSlots); + } + } +} + +void Guild::ResetTimes() +{ + for (Members::const_iterator itr = m_members.begin(); itr != m_members.end(); ++itr) + itr->second->ResetValues(); - sLog->outDebug(LOG_FILTER_GUILD, "WORLD: Sent SMSG_GUILD_EVENT"); + // Hack... way to force client to ask for money/slots + _BroadcastEvent(GE_RANK_UPDATED, 0, "0", GetRankInfo(0)->GetName().c_str()); } diff --git a/src/server/game/Guilds/Guild.h b/src/server/game/Guilds/Guild.h index dd1fb7cc6b6..deb89c169b6 100755 --- a/src/server/game/Guilds/Guild.h +++ b/src/server/game/Guilds/Guild.h @@ -37,7 +37,14 @@ enum GuildMisc GUILD_RANK_NONE = 0xFF, GUILD_WITHDRAW_MONEY_UNLIMITED = 0xFFFFFFFF, GUILD_WITHDRAW_SLOT_UNLIMITED = 0xFFFFFFFF, - GUILD_EVENT_LOG_GUID_UNDEFINED = 0xFFFFFFFF + GUILD_EVENT_LOG_GUID_UNDEFINED = 0xFFFFFFFF, + TAB_UNDEFINED = 0xFF, +}; + +enum GuildMemberData +{ + GUILD_MEMBER_DATA_ZONEID, + GUILD_MEMBER_DATA_LEVEL, }; enum GuildDefaultRanks @@ -54,87 +61,97 @@ enum GuildDefaultRanks enum GuildRankRights { - GR_RIGHT_EMPTY = 0x00000040, - GR_RIGHT_GCHATLISTEN = GR_RIGHT_EMPTY | 0x00000001, - GR_RIGHT_GCHATSPEAK = GR_RIGHT_EMPTY | 0x00000002, - GR_RIGHT_OFFCHATLISTEN = GR_RIGHT_EMPTY | 0x00000004, - GR_RIGHT_OFFCHATSPEAK = GR_RIGHT_EMPTY | 0x00000008, - GR_RIGHT_INVITE = GR_RIGHT_EMPTY | 0x00000010, - GR_RIGHT_REMOVE = GR_RIGHT_EMPTY | 0x00000020, - GR_RIGHT_PROMOTE = GR_RIGHT_EMPTY | 0x00000080, - GR_RIGHT_DEMOTE = GR_RIGHT_EMPTY | 0x00000100, - GR_RIGHT_SETMOTD = GR_RIGHT_EMPTY | 0x00001000, - GR_RIGHT_EPNOTE = GR_RIGHT_EMPTY | 0x00002000, - GR_RIGHT_VIEWOFFNOTE = GR_RIGHT_EMPTY | 0x00004000, - GR_RIGHT_EOFFNOTE = GR_RIGHT_EMPTY | 0x00008000, - GR_RIGHT_MODIFY_GUILD_INFO = GR_RIGHT_EMPTY | 0x00010000, - GR_RIGHT_WITHDRAW_GOLD_LOCK = 0x00020000, // remove money withdraw capacity - GR_RIGHT_WITHDRAW_REPAIR = 0x00040000, // withdraw for repair - GR_RIGHT_WITHDRAW_GOLD = 0x00080000, // withdraw gold - GR_RIGHT_CREATE_GUILD_EVENT = 0x00100000, // wotlk - GR_RIGHT_ALL = 0x001DF1FF + GR_RIGHT_EMPTY = 0x00000040, + GR_RIGHT_GCHATLISTEN = GR_RIGHT_EMPTY | 0x00000001, + GR_RIGHT_GCHATSPEAK = GR_RIGHT_EMPTY | 0x00000002, + GR_RIGHT_OFFCHATLISTEN = GR_RIGHT_EMPTY | 0x00000004, + GR_RIGHT_OFFCHATSPEAK = GR_RIGHT_EMPTY | 0x00000008, + GR_RIGHT_INVITE = GR_RIGHT_EMPTY | 0x00000010, + GR_RIGHT_REMOVE = GR_RIGHT_EMPTY | 0x00000020, + GR_RIGHT_PROMOTE = GR_RIGHT_EMPTY | 0x00000080, + GR_RIGHT_DEMOTE = GR_RIGHT_EMPTY | 0x00000100, + GR_RIGHT_SETMOTD = GR_RIGHT_EMPTY | 0x00001000, + GR_RIGHT_EPNOTE = GR_RIGHT_EMPTY | 0x00002000, + GR_RIGHT_VIEWOFFNOTE = GR_RIGHT_EMPTY | 0x00004000, + GR_RIGHT_EOFFNOTE = GR_RIGHT_EMPTY | 0x00008000, + GR_RIGHT_MODIFY_GUILD_INFO = GR_RIGHT_EMPTY | 0x00010000, + GR_RIGHT_WITHDRAW_GOLD_LOCK = 0x00020000, // remove money withdraw capacity + GR_RIGHT_WITHDRAW_REPAIR = 0x00040000, // withdraw for repair + GR_RIGHT_WITHDRAW_GOLD = 0x00080000, // withdraw gold + GR_RIGHT_CREATE_GUILD_EVENT = 0x00100000, // wotlk + GR_RIGHT_ALL = 0x001DF1FF }; enum GuildCommandType { - GUILD_CREATE_S = 0x00, - GUILD_INVITE_S = 0x01, - GUILD_QUIT_S = 0x03, - GUILD_FOUNDER_S = 0x0E, - GUILD_UNK1 = 0x13, - GUILD_UNK2 = 0x14 + GUILD_COMMAND_CREATE = 0, + GUILD_COMMAND_INVITE = 1, + GUILD_COMMAND_QUIT = 3, + GUILD_COMMAND_ROSTER = 5, + GUILD_COMMAND_PROMOTE = 6, + GUILD_COMMAND_DEMOTE = 7, + GUILD_COMMAND_REMOVE = 8, + GUILD_COMMAND_CHANGE_LEADER = 10, + GUILD_COMMAND_EDIT_MOTD = 11, + GUILD_COMMAND_GUILD_CHAT = 13, + GUILD_COMMAND_FOUNDER = 14, + GUILD_COMMAND_CHANGE_RANK = 16, + GUILD_COMMAND_PUBLIC_NOTE = 19, + GUILD_COMMAND_VIEW_TAB = 21, + GUILD_COMMAND_MOVE_ITEM = 22, + GUILD_COMMAND_REPAIR = 25, }; enum GuildCommandError { - ERR_PLAYER_NO_MORE_IN_GUILD = 0x00, - ERR_GUILD_INTERNAL = 0x01, - ERR_ALREADY_IN_GUILD = 0x02, - ERR_ALREADY_IN_GUILD_S = 0x03, - ERR_INVITED_TO_GUILD = 0x04, - ERR_ALREADY_INVITED_TO_GUILD_S = 0x05, - ERR_GUILD_NAME_INVALID = 0x06, - ERR_GUILD_NAME_EXISTS_S = 0x07, - ERR_GUILD_LEADER_LEAVE = 0x08, - ERR_GUILD_PERMISSIONS = 0x08, - ERR_GUILD_PLAYER_NOT_IN_GUILD = 0x09, - ERR_GUILD_PLAYER_NOT_IN_GUILD_S = 0x0A, - ERR_GUILD_PLAYER_NOT_FOUND_S = 0x0B, - ERR_GUILD_NOT_ALLIED = 0x0C, - ERR_GUILD_RANK_TOO_HIGH_S = 0x0D, - ERR_GUILD_RANK_TOO_LOW_S = 0x0E, - ERR_GUILD_RANKS_LOCKED = 0x11, - ERR_GUILD_RANK_IN_USE = 0x12, - ERR_GUILD_IGNORING_YOU_S = 0x13, - ERR_GUILD_UNK1 = 0x14, - ERR_GUILD_WITHDRAW_LIMIT = 0x19, - ERR_GUILD_NOT_ENOUGH_MONEY = 0x1A, - ERR_GUILD_BANK_FULL = 0x1C, - ERR_GUILD_ITEM_NOT_FOUND = 0x1D + ERR_GUILD_COMMAND_SUCCESS = 0, + ERR_GUILD_INTERNAL = 1, + ERR_ALREADY_IN_GUILD = 2, + ERR_ALREADY_IN_GUILD_S = 3, + ERR_INVITED_TO_GUILD = 4, + ERR_ALREADY_INVITED_TO_GUILD_S = 5, + ERR_GUILD_NAME_INVALID = 6, + ERR_GUILD_NAME_EXISTS_S = 7, + ERR_GUILD_LEADER_LEAVE = 8, + ERR_GUILD_PERMISSIONS = 8, + ERR_GUILD_PLAYER_NOT_IN_GUILD = 9, + ERR_GUILD_PLAYER_NOT_IN_GUILD_S = 10, + ERR_GUILD_PLAYER_NOT_FOUND_S = 11, + ERR_GUILD_NOT_ALLIED = 12, + ERR_GUILD_RANK_TOO_HIGH_S = 13, + ERR_GUILD_RANK_TOO_LOW_S = 14, + ERR_GUILD_RANKS_LOCKED = 17, + ERR_GUILD_RANK_IN_USE = 18, + ERR_GUILD_IGNORING_YOU_S = 19, + ERR_GUILD_UNK1 = 20, // Forces roster update + ERR_GUILD_WITHDRAW_LIMIT = 25, + ERR_GUILD_NOT_ENOUGH_MONEY = 26, + ERR_GUILD_BANK_FULL = 28, + ERR_GUILD_ITEM_NOT_FOUND = 29, }; enum GuildEvents { - GE_PROMOTION = 0x00, - GE_DEMOTION = 0x01, - GE_MOTD = 0x02, - GE_JOINED = 0x03, - GE_LEFT = 0x04, - GE_REMOVED = 0x05, - GE_LEADER_IS = 0x06, - GE_LEADER_CHANGED = 0x07, - GE_DISBANDED = 0x08, - GE_TABARDCHANGE = 0x09, - GE_UNK1 = 0x0A, // string, string EVENT_GUILD_ROSTER_UPDATE tab content change? - GE_UNK2 = 0x0B, // EVENT_GUILD_ROSTER_UPDATE - GE_SIGNED_ON = 0x0C, // ERR_FRIEND_ONLINE_SS - GE_SIGNED_OFF = 0x0D, // ERR_FRIEND_OFFLINE_S - GE_GUILDBANK_BAGSLOTS_CHANGED = 0x0E, // EVENT_GUILDBANK_BAGSLOTS_CHANGED - GE_GUILDBANK_TAB_PURCHASED = 0x0F, // EVENT_GUILDBANK_UPDATE_TABS - GE_UNK5 = 0x10, // EVENT_GUILDBANK_UPDATE_TABS - GE_GUILDBANK_MONEY_UPDATE = 0x11, // EVENT_GUILDBANK_UPDATE_MONEY, string 0000000000002710 is 1 gold - GE_GUILDBANK_MONEY_WITHDRAWN = 0x12, // MSG_GUILD_BANK_MONEY_WITHDRAWN - GE_GUILDBANK_TEXT_CHANGED = 0x13 // EVENT_GUILDBANK_TEXT_CHANGED + GE_PROMOTION = 0, + GE_DEMOTION = 1, + GE_MOTD = 2, + GE_JOINED = 3, + GE_LEFT = 4, + GE_REMOVED = 5, + GE_LEADER_IS = 6, + GE_LEADER_CHANGED = 7, + GE_DISBANDED = 8, + GE_TABARDCHANGE = 9, + GE_RANK_UPDATED = 10, + GE_RANK_DELETED = 11, + GE_SIGNED_ON = 12, + GE_SIGNED_OFF = 13, + GE_GUILDBANKBAGSLOTS_CHANGED = 14, + GE_BANK_TAB_PURCHASED = 15, + GE_BANK_TAB_UPDATED = 16, + GE_BANK_MONEY_SET = 17, + GE_BANK_MONEY_CHANGED = 18, + GE_BANK_TEXT_CHANGED = 19, }; enum PetitionTurns @@ -146,44 +163,44 @@ enum PetitionTurns enum PetitionSigns { - PETITION_SIGN_OK = 0, - PETITION_SIGN_ALREADY_SIGNED = 1, - PETITION_SIGN_ALREADY_IN_GUILD = 2, - PETITION_SIGN_CANT_SIGN_OWN = 3, - PETITION_SIGN_NOT_SERVER = 4 + PETITION_SIGN_OK = 0, + PETITION_SIGN_ALREADY_SIGNED = 1, + PETITION_SIGN_ALREADY_IN_GUILD = 2, + PETITION_SIGN_CANT_SIGN_OWN = 3, + PETITION_SIGN_NOT_SERVER = 4 }; enum GuildBankRights { - GUILD_BANK_RIGHT_VIEW_TAB = 0x01, - GUILD_BANK_RIGHT_PUT_ITEM = 0x02, - GUILD_BANK_RIGHT_UPDATE_TEXT = 0x04, + GUILD_BANK_RIGHT_VIEW_TAB = 0x01, + GUILD_BANK_RIGHT_PUT_ITEM = 0x02, + GUILD_BANK_RIGHT_UPDATE_TEXT = 0x04, - GUILD_BANK_RIGHT_DEPOSIT_ITEM = GUILD_BANK_RIGHT_VIEW_TAB | GUILD_BANK_RIGHT_PUT_ITEM, - GUILD_BANK_RIGHT_FULL = 0xFF + GUILD_BANK_RIGHT_DEPOSIT_ITEM = GUILD_BANK_RIGHT_VIEW_TAB | GUILD_BANK_RIGHT_PUT_ITEM, + GUILD_BANK_RIGHT_FULL = 0xFF }; enum GuildBankEventLogTypes { - GUILD_BANK_LOG_DEPOSIT_ITEM = 1, - GUILD_BANK_LOG_WITHDRAW_ITEM = 2, - GUILD_BANK_LOG_MOVE_ITEM = 3, - GUILD_BANK_LOG_DEPOSIT_MONEY = 4, - GUILD_BANK_LOG_WITHDRAW_MONEY = 5, - GUILD_BANK_LOG_REPAIR_MONEY = 6, - GUILD_BANK_LOG_MOVE_ITEM2 = 7, - GUILD_BANK_LOG_UNK1 = 8, - GUILD_BANK_LOG_UNK2 = 9 + GUILD_BANK_LOG_DEPOSIT_ITEM = 1, + GUILD_BANK_LOG_WITHDRAW_ITEM = 2, + GUILD_BANK_LOG_MOVE_ITEM = 3, + GUILD_BANK_LOG_DEPOSIT_MONEY = 4, + GUILD_BANK_LOG_WITHDRAW_MONEY = 5, + GUILD_BANK_LOG_REPAIR_MONEY = 6, + GUILD_BANK_LOG_MOVE_ITEM2 = 7, + GUILD_BANK_LOG_UNK1 = 8, + GUILD_BANK_LOG_BUY_SLOT = 9 }; enum GuildEventLogTypes { - GUILD_EVENT_LOG_INVITE_PLAYER = 1, - GUILD_EVENT_LOG_JOIN_GUILD = 2, - GUILD_EVENT_LOG_PROMOTE_PLAYER = 3, - GUILD_EVENT_LOG_DEMOTE_PLAYER = 4, - GUILD_EVENT_LOG_UNINVITE_PLAYER = 5, - GUILD_EVENT_LOG_LEAVE_GUILD = 6 + GUILD_EVENT_LOG_INVITE_PLAYER = 1, + GUILD_EVENT_LOG_JOIN_GUILD = 2, + GUILD_EVENT_LOG_PROMOTE_PLAYER = 3, + GUILD_EVENT_LOG_DEMOTE_PLAYER = 4, + GUILD_EVENT_LOG_UNINVITE_PLAYER = 5, + GUILD_EVENT_LOG_LEAVE_GUILD = 6 }; enum GuildEmblemError @@ -196,7 +213,15 @@ enum GuildEmblemError ERR_GUILDEMBLEM_INVALIDVENDOR = 5 }; -//////////////////////////////////////////////////////////////////////////////////////////// +enum GuildMemberFlags +{ + GUILDMEMBER_STATUS_NONE = 0x0000, + GUILDMEMBER_STATUS_ONLINE = 0x0001, + GUILDMEMBER_STATUS_AFK = 0x0002, + GUILDMEMBER_STATUS_DND = 0x0004, + GUILDMEMBER_STATUS_MOBILE = 0x0008, // remote chat from mobile app +}; + // Emblem info class EmblemInfo { @@ -205,7 +230,7 @@ public: void LoadFromDB(Field* fields); void SaveToDB(uint32 guildId) const; - void ReadPacket(WorldPacket& recv) { recv >> m_style >> m_color >> m_borderStyle >> m_borderColor >> m_backgroundColor; } + void ReadPacket(WorldPacket& recv); void WritePacket(WorldPacket& data) const; uint32 GetStyle() const { return m_style; } @@ -223,21 +248,33 @@ private: }; // Structure for storing guild bank rights and remaining slots together. -struct GuildBankRightsAndSlots +class GuildBankRightsAndSlots { - GuildBankRightsAndSlots() : rights(0), slots(0) { } - GuildBankRightsAndSlots(uint8 _rights, uint32 _slots) : rights(_rights), slots(_slots) { } +public: + GuildBankRightsAndSlots() : tabId(TAB_UNDEFINED), rights(0), slots(0) { } + GuildBankRightsAndSlots(uint8 _tabId) : tabId(_tabId), rights(0), slots(0) { } + GuildBankRightsAndSlots(uint8 _tabId, uint8 _rights, uint32 _slots) : tabId(_tabId), rights(_rights), slots(_slots) { } - inline bool IsEqual(GuildBankRightsAndSlots const& rhs) const { return rights == rhs.rights && slots == rhs.slots; } void SetGuildMasterValues() { rights = GUILD_BANK_RIGHT_FULL; slots = uint32(GUILD_WITHDRAW_SLOT_UNLIMITED); } + void SetTabId(uint8 _tabId) { tabId = _tabId; } + void SetSlots(uint32 _slots) { slots = _slots; } + void SetRights(uint8 _rights) { rights = _rights; } + + int8 GetTabId() const { return tabId; } + int32 GetSlots() const { return slots; } + int8 GetRights() const { return rights; } + +private: + uint8 tabId; uint8 rights; uint32 slots; }; + typedef std::vector <GuildBankRightsAndSlots> GuildBankRightsAndSlotsVec; typedef std::set <uint8> SlotIds; @@ -248,32 +285,49 @@ private: // Class representing guild member class Member { - struct RemainingValue - { - RemainingValue() : value(0), resetTime(0) { } - - uint32 value; - uint32 resetTime; - }; - public: - Member(uint32 guildId, uint64 guid, uint8 rankId) : m_guildId(guildId), m_guid(guid), m_logoutTime(::time(NULL)), m_rankId(rankId) { } + Member(uint32 guildId, uint64 guid, uint8 rankId): + m_guildId(guildId), + m_guid(guid), + m_zoneId(0), + m_level(0), + m_class(0), + m_logoutTime(::time(NULL)), + m_accountId(0), + m_rankId(rankId) + { + memset(m_bankWithdraw, 0, (GUILD_BANK_MAX_TABS + 1) * sizeof(int32)); + } void SetStats(Player* player); - void SetStats(const std::string& name, uint8 level, uint8 _class, uint32 zoneId, uint32 accountId); + void SetStats(std::string const& name, uint8 level, uint8 _class, uint32 zoneId, uint32 accountId); bool CheckStats() const; - void SetPublicNote(const std::string& publicNote); - void SetOfficerNote(const std::string& officerNote); + void SetPublicNote(std::string const& publicNote); + void SetOfficerNote(std::string const& officerNote); + void SetZoneID(uint32 id) { m_zoneId = id; } + void SetLevel(uint8 var) { m_level = var; } + + void AddFlag(uint8 var) { m_flags |= var; } + void RemFlag(uint8 var) { m_flags &= ~var; } + void ResetFlags() { m_flags = GUILDMEMBER_STATUS_NONE; } bool LoadFromDB(Field* fields); void SaveToDB(SQLTransaction& trans) const; void WritePacket(WorldPacket& data) const; uint64 GetGUID() const { return m_guid; } - std::string GetName() const { return m_name; } + std::string const& GetName() const { return m_name; } uint32 GetAccountId() const { return m_accountId; } uint8 GetRankId() const { return m_rankId; } + uint64 GetLogoutTime() const { return m_logoutTime; } + std::string GetPublicNote() const { return m_publicNote; } + std::string GetOfficerNote() const { return m_officerNote; } + uint8 GetClass() const { return m_class; } + uint8 GetLevel() const { return m_level; } + uint8 GetFlags() const { return m_flags; } + uint32 GetZoneId() const { return m_zoneId; } + bool IsOnline() { return (m_flags & GUILDMEMBER_STATUS_ONLINE); } void ChangeRank(uint8 newRank); @@ -282,11 +336,9 @@ private: inline bool IsRankNotLower(uint8 rankId) const { return m_rankId <= rankId; } inline bool IsSamePlayer(uint64 guid) const { return m_guid == guid; } - void DecreaseBankRemainingValue(SQLTransaction& trans, uint8 tabId, uint32 amount); - uint32 GetBankRemainingValue(uint8 tabId, const Guild* guild) const; - - void ResetTabTimes(); - void ResetMoneyTime(); + void UpdateBankWithdrawValue(SQLTransaction& trans, uint8 tabId, uint32 amount); + int32 GetBankWithdrawValue(uint8 tabId) const; + void ResetValues(); inline Player* FindPlayer() const { return ObjectAccessor::FindPlayer(m_guid); } @@ -296,16 +348,17 @@ private: uint64 m_guid; std::string m_name; uint32 m_zoneId; - uint8 m_level; - uint8 m_class; + uint8 m_level; + uint8 m_class; + uint8 m_flags; uint64 m_logoutTime; uint32 m_accountId; // Fields from guild_member table - uint8 m_rankId; + uint8 m_rankId; std::string m_publicNote; std::string m_officerNote; - RemainingValue m_bankRemaining[GUILD_BANK_MAX_TABS + 1]; + int32 m_bankWithdraw[GUILD_BANK_MAX_TABS + 1]; }; // Base class for event entries @@ -317,6 +370,7 @@ private: virtual ~LogEntry() { } uint32 GetGUID() const { return m_guid; } + uint64 GetTimestamp() const { return m_timestamp; } virtual void SaveToDB(SQLTransaction& trans) const = 0; virtual void WritePacket(WorldPacket& data) const = 0; @@ -384,6 +438,8 @@ private: }; // Class encapsulating work with events collection + typedef std::list<LogEntry*> GuildLog; + class LogHolder { public: @@ -402,19 +458,19 @@ private: uint32 GetNextGUID(); private: - typedef std::list<LogEntry*> GuildLog; GuildLog m_log; uint32 m_guildId; uint32 m_maxRecords; uint32 m_nextGUID; }; - // Class incapsulating guild rank data + // Class encapsulating guild rank data class RankInfo { public: + RankInfo(): m_guildId(0), m_rankId(GUILD_RANK_NONE), m_rights(GR_RIGHT_EMPTY), m_bankMoneyPerDay(0) { } RankInfo(uint32 guildId) : m_guildId(guildId), m_rankId(GUILD_RANK_NONE), m_rights(GR_RIGHT_EMPTY), m_bankMoneyPerDay(0) { } - RankInfo(uint32 guildId, uint8 rankId, const std::string& name, uint32 rights, uint32 money) : + RankInfo(uint32 guildId, uint8 rankId, std::string const& name, uint32 rights, uint32 money) : m_guildId(guildId), m_rankId(rankId), m_name(name), m_rights(rights), m_bankMoneyPerDay(money) { } void LoadFromDB(Field* fields); @@ -423,23 +479,28 @@ private: uint8 GetId() const { return m_rankId; } - std::string GetName() const { return m_name; } - void SetName(const std::string& name); + std::string const& GetName() const { return m_name; } + void SetName(std::string const& name); uint32 GetRights() const { return m_rights; } void SetRights(uint32 rights); - uint32 GetBankMoneyPerDay() const { return m_rankId == GR_GUILDMASTER ? GUILD_WITHDRAW_MONEY_UNLIMITED : m_bankMoneyPerDay; } + int32 GetBankMoneyPerDay() const { return m_bankMoneyPerDay; } + void SetBankMoneyPerDay(uint32 money); - inline uint8 GetBankTabRights(uint8 tabId) const { return tabId < GUILD_BANK_MAX_TABS ? m_bankTabRightsAndSlots[tabId].rights : 0; } - inline uint32 GetBankTabSlotsPerDay(uint8 tabId) const + inline int8 GetBankTabRights(uint8 tabId) const { - if (tabId < GUILD_BANK_MAX_TABS) - return m_rankId == GR_GUILDMASTER ? GUILD_WITHDRAW_SLOT_UNLIMITED : m_bankTabRightsAndSlots[tabId].slots; - return 0; + return tabId < GUILD_BANK_MAX_TABS ? m_bankTabRightsAndSlots[tabId].GetRights() : 0; } - void SetBankTabSlotsAndRights(uint8 tabId, GuildBankRightsAndSlots rightsAndSlots, bool saveToDB); + + inline int32 GetBankTabSlotsPerDay(uint8 tabId) const + { + return tabId < GUILD_BANK_MAX_TABS ? m_bankTabRightsAndSlots[tabId].GetSlots() : 0; + } + + void SetBankTabSlotsAndRights(GuildBankRightsAndSlots rightsAndSlots, bool saveToDB); + bool CreateMissingTabsIfNeeded(uint8 ranks, SQLTransaction& trans); private: uint32 m_guildId; @@ -459,20 +520,20 @@ private: memset(m_items, 0, GUILD_BANK_MAX_SLOTS * sizeof(Item*)); } - bool LoadFromDB(Field* fields); + void LoadFromDB(Field* fields); bool LoadItemFromDB(Field* fields); void Delete(SQLTransaction& trans, bool removeItemsFromDB = false); void WritePacket(WorldPacket& data) const; - void WriteSlotPacket(WorldPacket& data, uint8 slotId) const; + bool WriteSlotPacket(WorldPacket& data, uint8 slotId, bool ignoreEmpty = true) const; void WriteInfoPacket(WorldPacket& data) const { data << m_name; data << m_icon; } - void SetInfo(const std::string& name, const std::string& icon); - void SetText(const std::string& text); + void SetInfo(std::string const& name, std::string const& icon); + void SetText(std::string const& text); void SendText(const Guild* guild, WorldSession* session) const; inline Item* GetItem(uint8 slotId) const { return slotId < GUILD_BANK_MAX_SLOTS ? m_items[slotId] : NULL; } @@ -523,6 +584,7 @@ private: Item* GetItem(bool isCloned = false) const { return isCloned ? m_pClonedItem : m_pItem; } uint8 GetContainer() const { return m_container; } uint8 GetSlotId() const { return m_slotId; } + protected: virtual InventoryResult CanStore(Item* pItem, bool swap) = 0; @@ -579,55 +641,59 @@ private: typedef std::vector<BankTab*> BankTabs; public: - static void SendCommandResult(WorldSession* session, GuildCommandType type, GuildCommandError errCode, const std::string& param = ""); + static void SendCommandResult(WorldSession* session, GuildCommandType type, GuildCommandError errCode, std::string const& param = ""); static void SendSaveEmblemResult(WorldSession* session, GuildEmblemError errCode); Guild(); ~Guild(); - bool Create(Player* pLeader, const std::string& name); + bool Create(Player* pLeader, std::string const& name); void Disband(); // Getters uint32 GetId() const { return m_id; } uint64 GetLeaderGUID() const { return m_leaderGuid; } - const std::string& GetName() const { return m_name; } - const std::string& GetMOTD() const { return m_motd; } - const std::string& GetInfo() const { return m_info; } + std::string const& GetName() const { return m_name; } + std::string const& GetMOTD() const { return m_motd; } + std::string const& GetInfo() const { return m_info; } // Handle client commands void HandleRoster(WorldSession* session = NULL); // NULL = broadcast void HandleQuery(WorldSession* session); - void HandleSetMOTD(WorldSession* session, const std::string& motd); - void HandleSetInfo(WorldSession* session, const std::string& info); + void HandleSetMOTD(WorldSession* session, std::string const& motd); + void HandleSetInfo(WorldSession* session, std::string const& info); void HandleSetEmblem(WorldSession* session, const EmblemInfo& emblemInfo); - void HandleSetLeader(WorldSession* session, const std::string& name); - void HandleSetBankTabInfo(WorldSession* session, uint8 tabId, const std::string& name, const std::string& icon); - void HandleSetMemberNote(WorldSession* session, const std::string& name, const std::string& note, bool officer); - void HandleSetRankInfo(WorldSession* session, uint8 rankId, const std::string& name, uint32 rights, uint32 moneyPerDay, GuildBankRightsAndSlotsVec rightsAndSlots); + void HandleSetLeader(WorldSession* session, std::string const& name); + void HandleSetBankTabInfo(WorldSession* session, uint8 tabId, std::string const& name, std::string const& icon); + void HandleSetMemberNote(WorldSession* session, std::string const& name, std::string const& note, bool officer); + void HandleSetRankInfo(WorldSession* session, uint8 rankId, std::string const& name, uint32 rights, uint32 moneyPerDay, GuildBankRightsAndSlotsVec rightsAndSlots); void HandleBuyBankTab(WorldSession* session, uint8 tabId); - void HandleInviteMember(WorldSession* session, const std::string& name); + void HandleInviteMember(WorldSession* session, std::string const& name); void HandleAcceptMember(WorldSession* session); void HandleLeaveMember(WorldSession* session); - void HandleRemoveMember(WorldSession* session, const std::string& name); - void HandleUpdateMemberRank(WorldSession* session, const std::string& name, bool demote); - void HandleAddNewRank(WorldSession* session, const std::string& name); + void HandleRemoveMember(WorldSession* session, std::string const& name); + void HandleUpdateMemberRank(WorldSession* session, std::string const& name, bool demote); + void HandleAddNewRank(WorldSession* session, std::string const& name); + void HandleRemoveRank(WorldSession* session, uint8 rankId); void HandleRemoveLowestRank(WorldSession* session); void HandleMemberDepositMoney(WorldSession* session, uint32 amount); bool HandleMemberWithdrawMoney(WorldSession* session, uint32 amount, bool repair = false); void HandleMemberLogout(WorldSession* session); void HandleDisband(WorldSession* session); + void UpdateMemberData(Player* player, uint8 dataid, uint32 value); + void OnPlayerStatusChange(Player* player, uint32 flag, bool state); + // Send info to client void SendInfo(WorldSession* session) const; void SendEventLog(WorldSession* session) const; void SendBankLog(WorldSession* session, uint8 tabId) const; - void SendBankTabsInfo(WorldSession* session) const; + void SendBankTabsInfo(WorldSession* session, bool showTabs = false) const; void SendBankTabData(WorldSession* session, uint8 tabId) const; void SendBankTabText(WorldSession* session, uint8 tabId) const; void SendPermissions(WorldSession* session) const; void SendMoneyInfo(WorldSession* session) const; - void SendLoginInfo(WorldSession* session) const; + void SendLoginInfo(WorldSession* session); // Load from DB bool LoadFromDB(Field* fields); @@ -635,13 +701,13 @@ public: bool LoadMemberFromDB(Field* fields); bool LoadEventLogFromDB(Field* fields); void LoadBankRightFromDB(Field* fields); - bool LoadBankTabFromDB(Field* fields); + void LoadBankTabFromDB(Field* fields); bool LoadBankEventLogFromDB(Field* fields); bool LoadBankItemFromDB(Field* fields); bool Validate(); // Broadcasts - void BroadcastToGuild(WorldSession* session, bool officerOnly, const std::string& msg, uint32 language = LANG_UNIVERSAL) const; + void BroadcastToGuild(WorldSession* session, bool officerOnly, std::string const& msg, uint32 language = LANG_UNIVERSAL) const; void BroadcastPacketToRank(WorldPacket* packet, uint8 rankId) const; void BroadcastPacket(WorldPacket* packet) const; @@ -665,7 +731,9 @@ public: void SwapItemsWithInventory(Player* player, bool toChar, uint8 tabId, uint8 slotId, uint8 playerBag, uint8 playerSlotId, uint32 splitedAmount); // Bank tabs - void SetBankTabText(uint8 tabId, const std::string& text); + void SetBankTabText(uint8 tabId, std::string const& text); + + void ResetTimes(); protected: uint32 m_id; @@ -691,7 +759,14 @@ private: inline uint8 _GetRanksSize() const { return uint8(m_ranks.size()); } inline const RankInfo* GetRankInfo(uint8 rankId) const { return rankId < _GetRanksSize() ? &m_ranks[rankId] : NULL; } inline RankInfo* GetRankInfo(uint8 rankId) { return rankId < _GetRanksSize() ? &m_ranks[rankId] : NULL; } - inline bool _HasRankRight(Player* player, uint32 right) const { return (_GetRankRights(player->GetRank()) & right) != GR_RIGHT_EMPTY; } + inline bool _HasRankRight(Player* player, uint32 right) const + { + if (player) + if (Member const* member = GetMember(player->GetGUID())) + return (_GetRankRights(member->GetRankId()) & right) != GR_RIGHT_EMPTY; + return false; + } + inline uint8 _GetLowestRankId() const { return uint8(m_ranks.size() - 1); } inline uint8 _GetPurchasedTabsSize() const { return uint8(m_bankTabs.size()); } @@ -703,20 +778,22 @@ private: Members::const_iterator itr = m_members.find(GUID_LOPART(guid)); return itr != m_members.end() ? itr->second : NULL; } + inline Member* GetMember(uint64 guid) { Members::iterator itr = m_members.find(GUID_LOPART(guid)); return itr != m_members.end() ? itr->second : NULL; } - inline Member* GetMember(WorldSession* session, const std::string& name) + + inline Member* GetMember(std::string const& name) { for (Members::iterator itr = m_members.begin(); itr != m_members.end(); ++itr) if (itr->second->GetName() == name) return itr->second; - SendCommandResult(session, GUILD_INVITE_S, ERR_GUILD_PLAYER_NOT_IN_GUILD_S, name); return NULL; } + inline void _DeleteMemberFromDB(uint32 lowguid) const { PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_GUILD_MEMBER); @@ -727,11 +804,11 @@ private: // Creates log holders (either when loading or when creating guild) void _CreateLogHolders(); // Tries to create new bank tab - bool _CreateNewBankTab(); + void _CreateNewBankTab(); // Creates default guild ranks with names in given locale void _CreateDefaultGuildRanks(LocaleConstant loc); // Creates new rank - void _CreateRank(const std::string& name, uint32 rights); + bool _CreateRank(std::string const& name, uint32 rights); // Update account number when member added/removed from guild void _UpdateAccountsNumber(); bool _IsLeader(Player* player) const; @@ -740,16 +817,16 @@ private: void _SetLeaderGUID(Member* pLeader); void _SetRankBankMoneyPerDay(uint8 rankId, uint32 moneyPerDay); - void _SetRankBankTabRightsAndSlots(uint8 rankId, uint8 tabId, GuildBankRightsAndSlots rightsAndSlots, bool saveToDB = true); - uint8 _GetRankBankTabRights(uint8 rankId, uint8 tabId) const; + void _SetRankBankTabRightsAndSlots(uint8 rankId, GuildBankRightsAndSlots rightsAndSlots, bool saveToDB = true); + int8 _GetRankBankTabRights(uint8 rankId, uint8 tabId) const; uint32 _GetRankRights(uint8 rankId) const; - uint32 _GetRankBankMoneyPerDay(uint8 rankId) const; - uint32 _GetRankBankTabSlotsPerDay(uint8 rankId, uint8 tabId) const; + int32 _GetRankBankMoneyPerDay(uint8 rankId) const; + int32 _GetRankBankTabSlotsPerDay(uint8 rankId, uint8 tabId) const; std::string _GetRankName(uint8 rankId) const; - uint32 _GetMemberRemainingSlots(uint64 guid, uint8 tabId) const; - uint32 _GetMemberRemainingMoney(uint64 guid) const; - void _DecreaseMemberRemainingSlots(SQLTransaction& trans, uint64 guid, uint8 tabId); + int32 _GetMemberRemainingSlots(Member const* member, uint8 tabId) const; + int32 _GetMemberRemainingMoney(Member const* member) const; + void _UpdateMemberWithdrawSlots(SQLTransaction& trans, uint64 guid, uint8 tabId); bool _MemberHasTabRights(uint64 guid, uint8 tabId, uint32 rights) const; void _LogEvent(GuildEventLogTypes eventType, uint32 playerGuid1, uint32 playerGuid2 = 0, uint8 newRank = 0); @@ -764,6 +841,7 @@ private: void _SendBankMoneyUpdate(WorldSession* session) const; void _SendBankContentUpdate(MoveItemData* pSrc, MoveItemData* pDest) const; void _SendBankContentUpdate(uint8 tabId, SlotIds slots) const; + void _SendBankList(WorldSession* session = NULL, uint8 tabId = 0, bool sendFullSlots = false, SlotIds *slots = NULL) const; void _BroadcastEvent(GuildEvents guildEvent, uint64 guid, const char* param1 = NULL, const char* param2 = NULL, const char* param3 = NULL) const; }; diff --git a/src/server/game/Guilds/GuildMgr.cpp b/src/server/game/Guilds/GuildMgr.cpp index cebcf6040f9..0a1eb415ee6 100644 --- a/src/server/game/Guilds/GuildMgr.cpp +++ b/src/server/game/Guilds/GuildMgr.cpp @@ -18,10 +18,8 @@ #include "Common.h" #include "GuildMgr.h" -GuildMgr::GuildMgr() -{ - NextGuildId = 1; -} +GuildMgr::GuildMgr() : NextGuildId(1) +{ } GuildMgr::~GuildMgr() { @@ -121,6 +119,7 @@ void GuildMgr::LoadGuilds() delete guild; continue; } + AddGuild(guild); ++count; @@ -172,21 +171,18 @@ void GuildMgr::LoadGuilds() // Delete orphaned guild member entries before loading the valid ones CharacterDatabase.DirectExecute("DELETE gm FROM guild_member gm LEFT JOIN guild g ON gm.guildId = g.guildId WHERE g.guildId IS NULL"); + CharacterDatabase.DirectExecute("DELETE gm FROM guild_member_withdraw gm LEFT JOIN guild_member g ON gm.guid = g.guid WHERE g.guid IS NULL"); - // 0 1 2 3 4 5 6 - QueryResult result = CharacterDatabase.Query("SELECT guildid, gm.guid, rank, pnote, offnote, BankResetTimeMoney, BankRemMoney, " - // 7 8 9 10 11 12 - "BankResetTimeTab0, BankRemSlotsTab0, BankResetTimeTab1, BankRemSlotsTab1, BankResetTimeTab2, BankRemSlotsTab2, " - // 13 14 15 16 17 18 - "BankResetTimeTab3, BankRemSlotsTab3, BankResetTimeTab4, BankRemSlotsTab4, BankResetTimeTab5, BankRemSlotsTab5, " - // 19 20 21 22 23 24 - "c.name, c.level, c.class, c.zone, c.account, c.logout_time " - "FROM guild_member gm LEFT JOIN characters c ON c.guid = gm.guid ORDER BY guildid ASC"); + // 0 1 2 3 4 5 6 7 8 9 10 + QueryResult result = CharacterDatabase.Query("SELECT guildid, gm.guid, rank, pnote, offnote, w.tab0, w.tab1, w.tab2, w.tab3, w.tab4, w.tab5, " + // 11 12 13 14 15 16 17 + "w.money, c.name, c.level, c.class, c.zone, c.account, c.logout_time " + "FROM guild_member gm " + "LEFT JOIN guild_member_withdraw w ON gm.guid = w.guid " + "LEFT JOIN characters c ON c.guid = gm.guid ORDER BY guildid ASC"); if (!result) - { sLog->outInfo(LOG_FILTER_SERVER_LOADING, ">> Loaded 0 guild members. DB table `guild_member` is empty."); - } else { uint32 count = 0; @@ -215,7 +211,7 @@ void GuildMgr::LoadGuilds() // Delete orphaned guild bank right entries before loading the valid ones CharacterDatabase.DirectExecute("DELETE gbr FROM guild_bank_right gbr LEFT JOIN guild g ON gbr.guildId = g.guildId WHERE g.guildId IS NULL"); - // 0 1 2 3 4 + // 0 1 2 3 4 QueryResult result = CharacterDatabase.Query("SELECT guildid, TabId, rid, gbright, SlotPerDay FROM guild_bank_right ORDER BY guildid ASC, TabId ASC"); if (!result) @@ -382,20 +378,31 @@ void GuildMgr::LoadGuilds() sLog->outInfo(LOG_FILTER_GUILD, "Validating data of loaded guilds..."); { uint32 oldMSTime = getMSTime(); + std::set<Guild*> rm; // temporary storage to avoid modifying GuildStore with RemoveGuild() while iterating for (GuildContainer::iterator itr = GuildStore.begin(); itr != GuildStore.end(); ++itr) { Guild* guild = itr->second; - if (guild) - { - if (!guild->Validate()) - { - RemoveGuild(guild->GetId()); - delete guild; - } - } + if (guild && !guild->Validate()) + rm.insert(guild); + } + + for (std::set<Guild*>::iterator itr = rm.begin(); itr != rm.end(); ++itr) + { + Guild* guild = *itr; + RemoveGuild(guild->GetId()); + delete guild; } sLog->outInfo(LOG_FILTER_SERVER_LOADING, ">> Validated data of loaded guilds in %u ms", GetMSTimeDiffToNow(oldMSTime)); } } + +void GuildMgr::ResetTimes() +{ + for (GuildContainer::const_iterator itr = GuildStore.begin(); itr != GuildStore.end(); ++itr) + if (Guild* guild = itr->second) + guild->ResetTimes(); + + CharacterDatabase.DirectExecute("TRUNCATE guild_member_withdraw"); +}
\ No newline at end of file diff --git a/src/server/game/Guilds/GuildMgr.h b/src/server/game/Guilds/GuildMgr.h index 9654fced227..f5fa4680039 100644 --- a/src/server/game/Guilds/GuildMgr.h +++ b/src/server/game/Guilds/GuildMgr.h @@ -23,16 +23,15 @@ class GuildMgr { friend class ACE_Singleton<GuildMgr, ACE_Null_Mutex>; + private: GuildMgr(); ~GuildMgr(); public: - typedef UNORDERED_MAP<uint32, Guild*> GuildContainer; - Guild* GetGuildByLeader(uint64 guid) const; Guild* GetGuildById(uint32 guildId) const; - Guild* GetGuildByName(const std::string& guildName) const; + Guild* GetGuildByName(std::string const& guildName) const; std::string GetGuildNameById(uint32 guildId) const; void LoadGuilds(); @@ -42,7 +41,9 @@ public: uint32 GenerateGuildId(); void SetNextGuildId(uint32 Id) { NextGuildId = Id; } + void ResetTimes(); protected: + typedef UNORDERED_MAP<uint32, Guild*> GuildContainer; uint32 NextGuildId; GuildContainer GuildStore; }; diff --git a/src/server/game/Handlers/ArenaTeamHandler.cpp b/src/server/game/Handlers/ArenaTeamHandler.cpp index 8fb820713ce..d3738883d6d 100755 --- a/src/server/game/Handlers/ArenaTeamHandler.cpp +++ b/src/server/game/Handlers/ArenaTeamHandler.cpp @@ -90,7 +90,7 @@ void WorldSession::HandleArenaTeamInviteOpcode(WorldPacket & recvData) if (!normalizePlayerName(invitedName)) return; - player = sObjectAccessor->FindPlayerByName(invitedName.c_str()); + player = sObjectAccessor->FindPlayerByName(invitedName); } if (!player) @@ -140,7 +140,7 @@ void WorldSession::HandleArenaTeamInviteOpcode(WorldPacket & recvData) return; } - sLog->outDebug(LOG_FILTER_BATTLEGROUND, "Player %s Invited %s to Join his ArenaTeam", GetPlayer()->GetName(), invitedName.c_str()); + sLog->outDebug(LOG_FILTER_BATTLEGROUND, "Player %s Invited %s to Join his ArenaTeam", GetPlayer()->GetName().c_str(), invitedName.c_str()); player->SetArenaTeamIdInvited(arenaTeam->GetId()); @@ -152,7 +152,7 @@ void WorldSession::HandleArenaTeamInviteOpcode(WorldPacket & recvData) sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Sent SMSG_ARENA_TEAM_INVITE"); } -void WorldSession::HandleArenaTeamAcceptOpcode(WorldPacket & /*recv_data*/) +void WorldSession::HandleArenaTeamAcceptOpcode(WorldPacket & /*recvData*/) { sLog->outDebug(LOG_FILTER_NETWORKIO, "CMSG_ARENA_TEAM_ACCEPT"); // empty opcode @@ -185,7 +185,7 @@ void WorldSession::HandleArenaTeamAcceptOpcode(WorldPacket & /*recv_data*/) arenaTeam->BroadcastEvent(ERR_ARENA_TEAM_JOIN_SS, _player->GetGUID(), 2, _player->GetName(), arenaTeam->GetName(), ""); } -void WorldSession::HandleArenaTeamDeclineOpcode(WorldPacket & /*recv_data*/) +void WorldSession::HandleArenaTeamDeclineOpcode(WorldPacket & /*recvData*/) { sLog->outDebug(LOG_FILTER_NETWORKIO, "CMSG_ARENA_TEAM_DECLINE"); // empty opcode diff --git a/src/server/game/Handlers/AuctionHouseHandler.cpp b/src/server/game/Handlers/AuctionHouseHandler.cpp index 74d4f4102cf..3c3a6978384 100755 --- a/src/server/game/Handlers/AuctionHouseHandler.cpp +++ b/src/server/game/Handlers/AuctionHouseHandler.cpp @@ -33,10 +33,10 @@ //post-incrementation is always slower than pre-incrementation ! //void called when player click on auctioneer npc -void WorldSession::HandleAuctionHelloOpcode(WorldPacket & recv_data) +void WorldSession::HandleAuctionHelloOpcode(WorldPacket & recvData) { uint64 guid; //NPC guid - recv_data >> guid; + recvData >> guid; Creature* unit = GetPlayer()->GetNPCIfCanInteractWith(guid, UNIT_NPC_FLAG_AUCTIONEER); if (!unit) @@ -113,12 +113,12 @@ void WorldSession::SendAuctionOwnerNotification(AuctionEntry* auction) } //this void creates new auction and adds auction to some auctionhouse -void WorldSession::HandleAuctionSellItem(WorldPacket & recv_data) +void WorldSession::HandleAuctionSellItem(WorldPacket & recvData) { uint64 auctioneer; uint32 itemsCount, etime, bid, buyout; - recv_data >> auctioneer; - recv_data >> itemsCount; + recvData >> auctioneer; + recvData >> itemsCount; uint64 itemGUIDs[MAX_AUCTION_ITEMS]; // 160 slot = 4x 36 slot bag + backpack 16 slot uint32 count[MAX_AUCTION_ITEMS]; @@ -131,16 +131,16 @@ void WorldSession::HandleAuctionSellItem(WorldPacket & recv_data) for (uint32 i = 0; i < itemsCount; ++i) { - recv_data >> itemGUIDs[i]; - recv_data >> count[i]; + recvData >> itemGUIDs[i]; + recvData >> count[i]; if (!itemGUIDs[i] || !count[i] || count[i] > 1000 ) return; } - recv_data >> bid; - recv_data >> buyout; - recv_data >> etime; + recvData >> bid; + recvData >> buyout; + recvData >> etime; if (!bid || !etime) return; @@ -262,7 +262,7 @@ void WorldSession::HandleAuctionSellItem(WorldPacket & recv_data) AH->deposit = deposit; AH->auctionHouseEntry = auctionHouseEntry; - sLog->outInfo(LOG_FILTER_NETWORKIO, "CMSG_AUCTION_SELL_ITEM: Player %s (guid %d) is selling item %s entry %u (guid %d) to auctioneer %u with count %u with initial bid %u with buyout %u and with time %u (in sec) in auctionhouse %u", _player->GetName(), _player->GetGUIDLow(), item->GetTemplate()->Name1.c_str(), item->GetEntry(), item->GetGUIDLow(), AH->auctioneer, item->GetCount(), bid, buyout, auctionTime, AH->GetHouseId()); + sLog->outInfo(LOG_FILTER_NETWORKIO, "CMSG_AUCTION_SELL_ITEM: Player %s (guid %d) is selling item %s entry %u (guid %d) to auctioneer %u with count %u with initial bid %u with buyout %u and with time %u (in sec) in auctionhouse %u", _player->GetName().c_str(), _player->GetGUIDLow(), item->GetTemplate()->Name1.c_str(), item->GetEntry(), item->GetGUIDLow(), AH->auctioneer, item->GetCount(), bid, buyout, auctionTime, AH->GetHouseId()); sAuctionMgr->AddAItem(item); auctionHouse->AddAuction(AH); @@ -308,7 +308,7 @@ void WorldSession::HandleAuctionSellItem(WorldPacket & recv_data) AH->deposit = deposit; AH->auctionHouseEntry = auctionHouseEntry; - sLog->outInfo(LOG_FILTER_NETWORKIO, "CMSG_AUCTION_SELL_ITEM: Player %s (guid %d) is selling item %s entry %u (guid %d) to auctioneer %u with count %u with initial bid %u with buyout %u and with time %u (in sec) in auctionhouse %u", _player->GetName(), _player->GetGUIDLow(), newItem->GetTemplate()->Name1.c_str(), newItem->GetEntry(), newItem->GetGUIDLow(), AH->auctioneer, newItem->GetCount(), bid, buyout, auctionTime, AH->GetHouseId()); + sLog->outInfo(LOG_FILTER_NETWORKIO, "CMSG_AUCTION_SELL_ITEM: Player %s (guid %d) is selling item %s entry %u (guid %d) to auctioneer %u with count %u with initial bid %u with buyout %u and with time %u (in sec) in auctionhouse %u", _player->GetName().c_str(), _player->GetGUIDLow(), newItem->GetTemplate()->Name1.c_str(), newItem->GetEntry(), newItem->GetGUIDLow(), AH->auctioneer, newItem->GetCount(), bid, buyout, auctionTime, AH->GetHouseId()); sAuctionMgr->AddAItem(newItem); auctionHouse->AddAuction(AH); @@ -354,15 +354,15 @@ void WorldSession::HandleAuctionSellItem(WorldPacket & recv_data) } //this function is called when client bids or buys out auction -void WorldSession::HandleAuctionPlaceBid(WorldPacket & recv_data) +void WorldSession::HandleAuctionPlaceBid(WorldPacket & recvData) { sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Received CMSG_AUCTION_PLACE_BID"); uint64 auctioneer; uint32 auctionId; uint32 price; - recv_data >> auctioneer; - recv_data >> auctionId >> price; + recvData >> auctioneer; + recvData >> auctionId >> price; if (!auctionId || !price) return; //check for cheaters @@ -481,14 +481,14 @@ void WorldSession::HandleAuctionPlaceBid(WorldPacket & recv_data) } //this void is called when auction_owner cancels his auction -void WorldSession::HandleAuctionRemoveItem(WorldPacket & recv_data) +void WorldSession::HandleAuctionRemoveItem(WorldPacket & recvData) { sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Received CMSG_AUCTION_REMOVE_ITEM"); uint64 auctioneer; uint32 auctionId; - recv_data >> auctioneer; - recv_data >> auctionId; + recvData >> auctioneer; + recvData >> auctionId; //sLog->outDebug("Cancel AUCTION AuctionID: %u", auctionId); Creature* creature = GetPlayer()->GetNPCIfCanInteractWith(auctioneer, UNIT_NPC_FLAG_AUCTIONEER); @@ -558,7 +558,7 @@ void WorldSession::HandleAuctionRemoveItem(WorldPacket & recv_data) } //called when player lists his bids -void WorldSession::HandleAuctionListBidderItems(WorldPacket & recv_data) +void WorldSession::HandleAuctionListBidderItems(WorldPacket & recvData) { sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Received CMSG_AUCTION_LIST_BIDDER_ITEMS"); @@ -566,12 +566,12 @@ void WorldSession::HandleAuctionListBidderItems(WorldPacket & recv_data) uint32 listfrom; //page of auctions uint32 outbiddedCount; //count of outbidded auctions - recv_data >> guid; - recv_data >> listfrom; // not used in fact (this list not have page control in client) - recv_data >> outbiddedCount; - if (recv_data.size() != (16 + outbiddedCount * 4)) + recvData >> guid; + recvData >> listfrom; // not used in fact (this list not have page control in client) + recvData >> outbiddedCount; + if (recvData.size() != (16 + outbiddedCount * 4)) { - sLog->outError(LOG_FILTER_NETWORKIO, "Client sent bad opcode!!! with count: %u and size : %lu (must be: %u)", outbiddedCount, (unsigned long)recv_data.size(), (16 + outbiddedCount * 4)); + sLog->outError(LOG_FILTER_NETWORKIO, "Client sent bad opcode!!! with count: %u and size : %lu (must be: %u)", outbiddedCount, (unsigned long)recvData.size(), (16 + outbiddedCount * 4)); outbiddedCount = 0; } @@ -579,7 +579,7 @@ void WorldSession::HandleAuctionListBidderItems(WorldPacket & recv_data) if (!creature) { sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: HandleAuctionListBidderItems - Unit (GUID: %u) not found or you can't interact with him.", uint32(GUID_LOPART(guid))); - recv_data.rfinish(); + recvData.rfinish(); return; } @@ -598,7 +598,7 @@ void WorldSession::HandleAuctionListBidderItems(WorldPacket & recv_data) { --outbiddedCount; uint32 outbiddedAuctionId; - recv_data >> outbiddedAuctionId; + recvData >> outbiddedAuctionId; AuctionEntry* auction = auctionHouse->GetAuction(outbiddedAuctionId); if (auction && auction->BuildAuctionInfo(data)) { @@ -615,15 +615,15 @@ void WorldSession::HandleAuctionListBidderItems(WorldPacket & recv_data) } //this void sends player info about his auctions -void WorldSession::HandleAuctionListOwnerItems(WorldPacket & recv_data) +void WorldSession::HandleAuctionListOwnerItems(WorldPacket & recvData) { sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Received CMSG_AUCTION_LIST_OWNER_ITEMS"); uint32 listfrom; uint64 guid; - recv_data >> guid; - recv_data >> listfrom; // not used in fact (this list not have page control in client) + recvData >> guid; + recvData >> listfrom; // not used in fact (this list not have page control in client) Creature* creature = GetPlayer()->GetNPCIfCanInteractWith(guid, UNIT_NPC_FLAG_AUCTIONEER); if (!creature) @@ -652,7 +652,7 @@ void WorldSession::HandleAuctionListOwnerItems(WorldPacket & recv_data) } //this void is called when player clicks on search button -void WorldSession::HandleAuctionListItems(WorldPacket & recv_data) +void WorldSession::HandleAuctionListItems(WorldPacket & recvData) { sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Received CMSG_AUCTION_LIST_ITEMS"); @@ -661,23 +661,23 @@ void WorldSession::HandleAuctionListItems(WorldPacket & recv_data) uint32 listfrom, auctionSlotID, auctionMainCategory, auctionSubCategory, quality; uint64 guid; - recv_data >> guid; - recv_data >> listfrom; // start, used for page control listing by 50 elements - recv_data >> searchedname; + recvData >> guid; + recvData >> listfrom; // start, used for page control listing by 50 elements + recvData >> searchedname; - recv_data >> levelmin >> levelmax; - recv_data >> auctionSlotID >> auctionMainCategory >> auctionSubCategory; - recv_data >> quality >> usable; + recvData >> levelmin >> levelmax; + recvData >> auctionSlotID >> auctionMainCategory >> auctionSubCategory; + recvData >> quality >> usable; - recv_data.read_skip<uint8>(); // unk + recvData.read_skip<uint8>(); // unk // this block looks like it uses some lame byte packing or similar... uint8 unkCnt; - recv_data >> unkCnt; + recvData >> unkCnt; for (uint8 i = 0; i < unkCnt; i++) { - recv_data.read_skip<uint8>(); - recv_data.read_skip<uint8>(); + recvData.read_skip<uint8>(); + recvData.read_skip<uint8>(); } Creature* creature = GetPlayer()->GetNPCIfCanInteractWith(guid, UNIT_NPC_FLAG_AUCTIONEER); @@ -719,11 +719,11 @@ void WorldSession::HandleAuctionListItems(WorldPacket & recv_data) SendPacket(&data); } -void WorldSession::HandleAuctionListPendingSales(WorldPacket & recv_data) +void WorldSession::HandleAuctionListPendingSales(WorldPacket & recvData) { sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Received CMSG_AUCTION_LIST_PENDING_SALES"); - recv_data.read_skip<uint64>(); + recvData.read_skip<uint64>(); uint32 count = 0; diff --git a/src/server/game/Handlers/BattleGroundHandler.cpp b/src/server/game/Handlers/BattleGroundHandler.cpp index 25c8cd3cc2a..3a359704916 100755 --- a/src/server/game/Handlers/BattleGroundHandler.cpp +++ b/src/server/game/Handlers/BattleGroundHandler.cpp @@ -35,10 +35,10 @@ #include "DisableMgr.h" #include "Group.h" -void WorldSession::HandleBattlemasterHelloOpcode(WorldPacket & recv_data) +void WorldSession::HandleBattlemasterHelloOpcode(WorldPacket & recvData) { uint64 guid; - recv_data >> guid; + recvData >> guid; sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Recvd CMSG_BATTLEMASTER_HELLO Message from (GUID: %u TypeId:%u)", GUID_LOPART(guid), GuidHigh2TypeId(GUID_HIPART(guid))); Creature* unit = GetPlayer()->GetMap()->GetCreature(guid); @@ -70,7 +70,7 @@ void WorldSession::SendBattleGroundList(uint64 guid, BattlegroundTypeId bgTypeId SendPacket(&data); } -void WorldSession::HandleBattlemasterJoinOpcode(WorldPacket & recv_data) +void WorldSession::HandleBattlemasterJoinOpcode(WorldPacket & recvData) { uint64 guid; uint32 bgTypeId_; @@ -79,10 +79,10 @@ void WorldSession::HandleBattlemasterJoinOpcode(WorldPacket & recv_data) bool isPremade = false; Group* grp = NULL; - recv_data >> guid; // battlemaster guid - recv_data >> bgTypeId_; // battleground type id (DBC id) - recv_data >> instanceId; // instance id, 0 if First Available selected - recv_data >> joinAsGroup; // join as group + recvData >> guid; // battlemaster guid + recvData >> bgTypeId_; // battleground type id (DBC id) + recvData >> instanceId; // instance id, 0 if First Available selected + recvData >> joinAsGroup; // join as group if (!sBattlemasterListStore.LookupEntry(bgTypeId_)) { @@ -190,7 +190,7 @@ void WorldSession::HandleBattlemasterJoinOpcode(WorldPacket & recv_data) sBattlegroundMgr->BuildBattlegroundStatusPacket(&data, bg, queueSlot, STATUS_WAIT_QUEUE, avgTime, 0, ginfo->ArenaType); SendPacket(&data); sLog->outDebug(LOG_FILTER_BATTLEGROUND, "Battleground: player joined queue for bg queue type %u bg type %u: GUID %u, NAME %s", - bgQueueTypeId, bgTypeId, _player->GetGUIDLow(), _player->GetName()); + bgQueueTypeId, bgTypeId, _player->GetGUIDLow(), _player->GetName().c_str()); } else { @@ -237,15 +237,15 @@ void WorldSession::HandleBattlemasterJoinOpcode(WorldPacket & recv_data) member->GetSession()->SendPacket(&data); sBattlegroundMgr->BuildGroupJoinedBattlegroundPacket(&data, err); member->GetSession()->SendPacket(&data); - sLog->outDebug(LOG_FILTER_BATTLEGROUND, "Battleground: player joined queue for bg queue type %u bg type %u: GUID %u, NAME %s", bgQueueTypeId, bgTypeId, member->GetGUIDLow(), member->GetName()); + sLog->outDebug(LOG_FILTER_BATTLEGROUND, "Battleground: player joined queue for bg queue type %u bg type %u: GUID %u, NAME %s", + bgQueueTypeId, bgTypeId, member->GetGUIDLow(), member->GetName().c_str()); } sLog->outDebug(LOG_FILTER_BATTLEGROUND, "Battleground: group end"); - } sBattlegroundMgr->ScheduleQueueUpdate(0, 0, bgQueueTypeId, bgTypeId, bracketEntry->GetBracketId()); } -void WorldSession::HandleBattlegroundPlayerPositionsOpcode(WorldPacket& /*recv_data*/) +void WorldSession::HandleBattlegroundPlayerPositionsOpcode(WorldPacket& /*recvData*/) { sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Recvd MSG_BATTLEGROUND_PLAYER_POSITIONS Message"); @@ -296,7 +296,7 @@ void WorldSession::HandleBattlegroundPlayerPositionsOpcode(WorldPacket& /*recv_d SendPacket(&data); } -void WorldSession::HandlePVPLogDataOpcode(WorldPacket & /*recv_data*/) +void WorldSession::HandlePVPLogDataOpcode(WorldPacket & /*recvData*/) { sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Recvd MSG_PVP_LOG_DATA Message"); @@ -315,23 +315,23 @@ void WorldSession::HandlePVPLogDataOpcode(WorldPacket & /*recv_data*/) sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Sent MSG_PVP_LOG_DATA Message"); } -void WorldSession::HandleBattlefieldListOpcode(WorldPacket &recv_data) +void WorldSession::HandleBattlefieldListOpcode(WorldPacket &recvData) { sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Recvd CMSG_BATTLEFIELD_LIST Message"); uint32 bgTypeId; - recv_data >> bgTypeId; // id from DBC + recvData >> bgTypeId; // id from DBC uint8 fromWhere; - recv_data >> fromWhere; // 0 - battlemaster (lua: ShowBattlefieldList), 1 - UI (lua: RequestBattlegroundInstanceInfo) + recvData >> fromWhere; // 0 - battlemaster (lua: ShowBattlefieldList), 1 - UI (lua: RequestBattlegroundInstanceInfo) uint8 canGainXP; - recv_data >> canGainXP; // players with locked xp have their own bg queue on retail + recvData >> canGainXP; // players with locked xp have their own bg queue on retail BattlemasterListEntry const* bl = sBattlemasterListStore.LookupEntry(bgTypeId); if (!bl) { - sLog->outDebug(LOG_FILTER_BATTLEGROUND, "BattlegroundHandler: invalid bgtype (%u) with player (Name: %s, GUID: %u) received.", bgTypeId, _player->GetName(), _player->GetGUIDLow()); + sLog->outDebug(LOG_FILTER_BATTLEGROUND, "BattlegroundHandler: invalid bgtype (%u) with player (Name: %s, GUID: %u) received.", bgTypeId, _player->GetName().c_str(), _player->GetGUIDLow()); return; } @@ -340,7 +340,7 @@ void WorldSession::HandleBattlefieldListOpcode(WorldPacket &recv_data) SendPacket(&data); } -void WorldSession::HandleBattleFieldPortOpcode(WorldPacket &recv_data) +void WorldSession::HandleBattleFieldPortOpcode(WorldPacket &recvData) { sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Recvd CMSG_BATTLEFIELD_PORT Message"); @@ -350,17 +350,17 @@ void WorldSession::HandleBattleFieldPortOpcode(WorldPacket &recv_data) uint16 unk; // 0x1F90 constant? uint8 action; // enter battle 0x1, leave queue 0x0 - recv_data >> type >> unk2 >> bgTypeId_ >> unk >> action; + recvData >> type >> unk2 >> bgTypeId_ >> unk >> action; if (!sBattlemasterListStore.LookupEntry(bgTypeId_)) { - sLog->outDebug(LOG_FILTER_BATTLEGROUND, "BattlegroundHandler: invalid bgtype (%u) with player (Name: %s, GUID: %u) received.", bgTypeId_, _player->GetName(), _player->GetGUIDLow()); + sLog->outDebug(LOG_FILTER_BATTLEGROUND, "BattlegroundHandler: invalid bgtype (%u) with player (Name: %s, GUID: %u) received.", bgTypeId_, _player->GetName().c_str(), _player->GetGUIDLow()); return; } if (!_player->InBattlegroundQueue()) { - sLog->outDebug(LOG_FILTER_BATTLEGROUND, "BattlegroundHandler: Invalid CMSG_BATTLEFIELD_PORT received from player (Name: %s, GUID: %u), he is not in bg_queue.", _player->GetName(), _player->GetGUIDLow()); + sLog->outDebug(LOG_FILTER_BATTLEGROUND, "BattlegroundHandler: Invalid CMSG_BATTLEFIELD_PORT received from player (Name: %s, GUID: %u), he is not in bg_queue.", _player->GetName().c_str(), _player->GetGUIDLow()); return; } @@ -409,13 +409,13 @@ void WorldSession::HandleBattleFieldPortOpcode(WorldPacket &recv_data) sBattlegroundMgr->BuildGroupJoinedBattlegroundPacket(&data2, ERR_GROUP_JOIN_BATTLEGROUND_DESERTERS); _player->GetSession()->SendPacket(&data2); action = 0; - sLog->outDebug(LOG_FILTER_BATTLEGROUND, "Battleground: player %s (%u) has a deserter debuff, do not port him to battleground!", _player->GetName(), _player->GetGUIDLow()); + sLog->outDebug(LOG_FILTER_BATTLEGROUND, "Battleground: player %s (%u) has a deserter debuff, do not port him to battleground!", _player->GetName().c_str(), _player->GetGUIDLow()); } //if player don't match battleground max level, then do not allow him to enter! (this might happen when player leveled up during his waiting in queue if (_player->getLevel() > bg->GetMaxLevel()) { sLog->outError(LOG_FILTER_NETWORKIO, "Battleground: Player %s (%u) has level (%u) higher than maxlevel (%u) of battleground (%u)! Do not port him to battleground!", - _player->GetName(), _player->GetGUIDLow(), _player->getLevel(), bg->GetMaxLevel(), bg->GetTypeID()); + _player->GetName().c_str(), _player->GetGUIDLow(), _player->getLevel(), bg->GetMaxLevel(), bg->GetTypeID()); action = 0; } } @@ -460,7 +460,7 @@ void WorldSession::HandleBattleFieldPortOpcode(WorldPacket &recv_data) sBattlegroundMgr->SendToBattleground(_player, ginfo.IsInvitedToBGInstanceGUID, bgTypeId); // add only in HandleMoveWorldPortAck() // bg->AddPlayer(_player, team); - sLog->outDebug(LOG_FILTER_BATTLEGROUND, "Battleground: player %s (%u) joined battle for bg %u, bgtype %u, queue type %u.", _player->GetName(), _player->GetGUIDLow(), bg->GetInstanceID(), bg->GetTypeID(), bgQueueTypeId); + sLog->outDebug(LOG_FILTER_BATTLEGROUND, "Battleground: player %s (%u) joined battle for bg %u, bgtype %u, queue type %u.", _player->GetName().c_str(), _player->GetGUIDLow(), bg->GetInstanceID(), bg->GetTypeID(), bgQueueTypeId); break; case 0: // leave queue if (bg->isArena() && bg->GetStatus() > STATUS_WAIT_QUEUE) @@ -484,7 +484,7 @@ void WorldSession::HandleBattleFieldPortOpcode(WorldPacket &recv_data) if (!ginfo.ArenaType) sBattlegroundMgr->ScheduleQueueUpdate(ginfo.ArenaMatchmakerRating, ginfo.ArenaType, bgQueueTypeId, bgTypeId, bracketEntry->GetBracketId()); SendPacket(&data); - sLog->outDebug(LOG_FILTER_BATTLEGROUND, "Battleground: player %s (%u) left queue for bgtype %u, queue type %u.", _player->GetName(), _player->GetGUIDLow(), bg->GetTypeID(), bgQueueTypeId); + sLog->outDebug(LOG_FILTER_BATTLEGROUND, "Battleground: player %s (%u) left queue for bgtype %u, queue type %u.", _player->GetName().c_str(), _player->GetGUIDLow(), bg->GetTypeID(), bgQueueTypeId); break; default: sLog->outError(LOG_FILTER_NETWORKIO, "Battleground port: unknown action %u", action); @@ -492,14 +492,14 @@ void WorldSession::HandleBattleFieldPortOpcode(WorldPacket &recv_data) } } -void WorldSession::HandleLeaveBattlefieldOpcode(WorldPacket& recv_data) +void WorldSession::HandleLeaveBattlefieldOpcode(WorldPacket& recvData) { sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Recvd CMSG_LEAVE_BATTLEFIELD Message"); - recv_data.read_skip<uint8>(); // unk1 - recv_data.read_skip<uint8>(); // unk2 - recv_data.read_skip<uint32>(); // BattlegroundTypeId - recv_data.read_skip<uint16>(); // unk3 + recvData.read_skip<uint8>(); // unk1 + recvData.read_skip<uint8>(); // unk2 + recvData.read_skip<uint32>(); // BattlegroundTypeId + recvData.read_skip<uint16>(); // unk3 // not allow leave battleground in combat if (_player->isInCombat()) @@ -510,7 +510,7 @@ void WorldSession::HandleLeaveBattlefieldOpcode(WorldPacket& recv_data) _player->LeaveBattleground(); } -void WorldSession::HandleBattlefieldStatusOpcode(WorldPacket & /*recv_data*/) +void WorldSession::HandleBattlefieldStatusOpcode(WorldPacket & /*recvData*/) { // empty opcode sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Battleground status"); @@ -574,7 +574,7 @@ void WorldSession::HandleBattlefieldStatusOpcode(WorldPacket & /*recv_data*/) } } -void WorldSession::HandleBattlemasterJoinArena(WorldPacket & recv_data) +void WorldSession::HandleBattlemasterJoinArena(WorldPacket & recvData) { sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: CMSG_BATTLEMASTER_JOIN_ARENA"); @@ -584,7 +584,7 @@ void WorldSession::HandleBattlemasterJoinArena(WorldPacket & recv_data) uint8 isRated; // isRated Group* grp = NULL; - recv_data >> guid >> arenaslot >> asGroup >> isRated; + recvData >> guid >> arenaslot >> asGroup >> isRated; // ignore if we already in BG or BG queue if (_player->InBattleground()) @@ -691,7 +691,7 @@ void WorldSession::HandleBattlemasterJoinArena(WorldPacket & recv_data) sLog->outDebug(LOG_FILTER_BATTLEGROUND, "Battleground: arena join as group start"); if (isRated) { - sLog->outDebug(LOG_FILTER_BATTLEGROUND, "Battleground: arena team id %u, leader %s queued with matchmaker rating %u for type %u", _player->GetArenaTeamId(arenaslot), _player->GetName(), matchmakerRating, arenatype); + sLog->outDebug(LOG_FILTER_BATTLEGROUND, "Battleground: arena team id %u, leader %s queued with matchmaker rating %u for type %u", _player->GetArenaTeamId(arenaslot), _player->GetName().c_str(), matchmakerRating, arenatype); bg->SetRated(true); } else @@ -724,7 +724,7 @@ void WorldSession::HandleBattlemasterJoinArena(WorldPacket & recv_data) member->GetSession()->SendPacket(&data); sBattlegroundMgr->BuildGroupJoinedBattlegroundPacket(&data, err); member->GetSession()->SendPacket(&data); - sLog->outDebug(LOG_FILTER_BATTLEGROUND, "Battleground: player joined queue for arena as group bg queue type %u bg type %u: GUID %u, NAME %s", bgQueueTypeId, bgTypeId, member->GetGUIDLow(), member->GetName()); + sLog->outDebug(LOG_FILTER_BATTLEGROUND, "Battleground: player joined queue for arena as group bg queue type %u bg type %u: GUID %u, NAME %s", bgQueueTypeId, bgTypeId, member->GetGUIDLow(), member->GetName().c_str()); } } else @@ -737,15 +737,15 @@ void WorldSession::HandleBattlemasterJoinArena(WorldPacket & recv_data) // send status packet (in queue) sBattlegroundMgr->BuildBattlegroundStatusPacket(&data, bg, queueSlot, STATUS_WAIT_QUEUE, avgTime, 0, arenatype); SendPacket(&data); - sLog->outDebug(LOG_FILTER_BATTLEGROUND, "Battleground: player joined queue for arena, skirmish, bg queue type %u bg type %u: GUID %u, NAME %s", bgQueueTypeId, bgTypeId, _player->GetGUIDLow(), _player->GetName()); + sLog->outDebug(LOG_FILTER_BATTLEGROUND, "Battleground: player joined queue for arena, skirmish, bg queue type %u bg type %u: GUID %u, NAME %s", bgQueueTypeId, bgTypeId, _player->GetGUIDLow(), _player->GetName().c_str()); } sBattlegroundMgr->ScheduleQueueUpdate(matchmakerRating, arenatype, bgQueueTypeId, bgTypeId, bracketEntry->GetBracketId()); } -void WorldSession::HandleReportPvPAFK(WorldPacket & recv_data) +void WorldSession::HandleReportPvPAFK(WorldPacket & recvData) { uint64 playerGuid; - recv_data >> playerGuid; + recvData >> playerGuid; Player* reportedPlayer = ObjectAccessor::FindPlayer(playerGuid); if (!reportedPlayer) @@ -754,7 +754,7 @@ void WorldSession::HandleReportPvPAFK(WorldPacket & recv_data) return; } - sLog->outDebug(LOG_FILTER_BATTLEGROUND, "WorldSession::HandleReportPvPAFK: %s reported %s", _player->GetName(), reportedPlayer->GetName()); + sLog->outDebug(LOG_FILTER_BATTLEGROUND, "WorldSession::HandleReportPvPAFK: %s reported %s", _player->GetName().c_str(), reportedPlayer->GetName().c_str()); reportedPlayer->ReportedAfkBy(_player); } diff --git a/src/server/game/Handlers/CalendarHandler.cpp b/src/server/game/Handlers/CalendarHandler.cpp index d1209eead22..0cecd3d615a 100755 --- a/src/server/game/Handlers/CalendarHandler.cpp +++ b/src/server/game/Handlers/CalendarHandler.cpp @@ -404,7 +404,7 @@ void WorldSession::HandleCalendarEventInvite(WorldPacket& recvData) uint32 team = 0; recvData >> eventId >> inviteId >> name >> status >> rank; - if (Player* player = sObjectAccessor->FindPlayerByName(name.c_str())) + if (Player* player = sObjectAccessor->FindPlayerByName(name)) { invitee = player->GetGUID(); team = player->GetTeam(); diff --git a/src/server/game/Handlers/ChannelHandler.cpp b/src/server/game/Handlers/ChannelHandler.cpp index 9b749fa8005..a65e3830a81 100755 --- a/src/server/game/Handlers/ChannelHandler.cpp +++ b/src/server/game/Handlers/ChannelHandler.cpp @@ -49,9 +49,9 @@ void WorldSession::HandleJoinChannel(WorldPacket& recvPacket) if (channelname.empty()) return; - if (ChannelMgr* cMgr = channelMgr(_player->GetTeam())) + if (ChannelMgr* cMgr = ChannelMgr::forTeam(_player->GetTeam())) { - cMgr->team = _player->GetTeam(); + cMgr->setTeam(_player->GetTeam()); if (Channel* chn = cMgr->GetJoinChannel(channelname, channel_id)) chn->Join(_player->GetGUID(), pass.c_str()); } @@ -69,7 +69,7 @@ void WorldSession::HandleLeaveChannel(WorldPacket& recvPacket) if (channelname.empty()) return; - if (ChannelMgr* cMgr = channelMgr(_player->GetTeam())) + if (ChannelMgr* cMgr = ChannelMgr::forTeam(_player->GetTeam())) { if (Channel* chn = cMgr->GetChannel(channelname, _player)) chn->Leave(_player->GetGUID(), true); @@ -83,7 +83,7 @@ void WorldSession::HandleChannelList(WorldPacket& recvPacket) std::string channelname; recvPacket >> channelname; - if (ChannelMgr* cMgr = channelMgr(_player->GetTeam())) + if (ChannelMgr* cMgr = ChannelMgr::forTeam(_player->GetTeam())) if (Channel* chn = cMgr->GetChannel(channelname, _player)) chn->List(_player); } @@ -96,7 +96,7 @@ void WorldSession::HandleChannelPassword(WorldPacket& recvPacket) recvPacket >> pass; - if (ChannelMgr* cMgr = channelMgr(_player->GetTeam())) + if (ChannelMgr* cMgr = ChannelMgr::forTeam(_player->GetTeam())) if (Channel* chn = cMgr->GetChannel(channelname, _player)) chn->Password(_player->GetGUID(), pass.c_str()); } @@ -112,7 +112,7 @@ void WorldSession::HandleChannelSetOwner(WorldPacket& recvPacket) if (!normalizePlayerName(newp)) return; - if (ChannelMgr* cMgr = channelMgr(_player->GetTeam())) + if (ChannelMgr* cMgr = ChannelMgr::forTeam(_player->GetTeam())) if (Channel* chn = cMgr->GetChannel(channelname, _player)) chn->SetOwner(_player->GetGUID(), newp.c_str()); } @@ -122,7 +122,7 @@ void WorldSession::HandleChannelOwner(WorldPacket& recvPacket) sLog->outDebug(LOG_FILTER_NETWORKIO, "Opcode %u", recvPacket.GetOpcode()); std::string channelname; recvPacket >> channelname; - if (ChannelMgr* cMgr = channelMgr(_player->GetTeam())) + if (ChannelMgr* cMgr = ChannelMgr::forTeam(_player->GetTeam())) if (Channel* chn = cMgr->GetChannel(channelname, _player)) chn->SendWhoOwner(_player->GetGUID()); } @@ -138,7 +138,7 @@ void WorldSession::HandleChannelModerator(WorldPacket& recvPacket) if (!normalizePlayerName(otp)) return; - if (ChannelMgr* cMgr = channelMgr(_player->GetTeam())) + if (ChannelMgr* cMgr = ChannelMgr::forTeam(_player->GetTeam())) if (Channel* chn = cMgr->GetChannel(channelname, _player)) chn->SetModerator(_player->GetGUID(), otp.c_str()); } @@ -154,7 +154,7 @@ void WorldSession::HandleChannelUnmoderator(WorldPacket& recvPacket) if (!normalizePlayerName(otp)) return; - if (ChannelMgr* cMgr = channelMgr(_player->GetTeam())) + if (ChannelMgr* cMgr = ChannelMgr::forTeam(_player->GetTeam())) if (Channel* chn = cMgr->GetChannel(channelname, _player)) chn->UnsetModerator(_player->GetGUID(), otp.c_str()); } @@ -170,7 +170,7 @@ void WorldSession::HandleChannelMute(WorldPacket& recvPacket) if (!normalizePlayerName(otp)) return; - if (ChannelMgr* cMgr = channelMgr(_player->GetTeam())) + if (ChannelMgr* cMgr = ChannelMgr::forTeam(_player->GetTeam())) if (Channel* chn = cMgr->GetChannel(channelname, _player)) chn->SetMute(_player->GetGUID(), otp.c_str()); } @@ -187,7 +187,7 @@ void WorldSession::HandleChannelUnmute(WorldPacket& recvPacket) if (!normalizePlayerName(otp)) return; - if (ChannelMgr* cMgr = channelMgr(_player->GetTeam())) + if (ChannelMgr* cMgr = ChannelMgr::forTeam(_player->GetTeam())) if (Channel* chn = cMgr->GetChannel(channelname, _player)) chn->UnsetMute(_player->GetGUID(), otp.c_str()); } @@ -203,7 +203,7 @@ void WorldSession::HandleChannelInvite(WorldPacket& recvPacket) if (!normalizePlayerName(otp)) return; - if (ChannelMgr* cMgr = channelMgr(_player->GetTeam())) + if (ChannelMgr* cMgr = ChannelMgr::forTeam(_player->GetTeam())) if (Channel* chn = cMgr->GetChannel(channelname, _player)) chn->Invite(_player->GetGUID(), otp.c_str()); } @@ -218,7 +218,7 @@ void WorldSession::HandleChannelKick(WorldPacket& recvPacket) if (!normalizePlayerName(otp)) return; - if (ChannelMgr* cMgr = channelMgr(_player->GetTeam())) + if (ChannelMgr* cMgr = ChannelMgr::forTeam(_player->GetTeam())) if (Channel* chn = cMgr->GetChannel(channelname, _player)) chn->Kick(_player->GetGUID(), otp.c_str()); } @@ -234,7 +234,7 @@ void WorldSession::HandleChannelBan(WorldPacket& recvPacket) if (!normalizePlayerName(otp)) return; - if (ChannelMgr* cMgr = channelMgr(_player->GetTeam())) + if (ChannelMgr* cMgr = ChannelMgr::forTeam(_player->GetTeam())) if (Channel* chn = cMgr->GetChannel(channelname, _player)) chn->Ban(_player->GetGUID(), otp.c_str()); } @@ -251,7 +251,7 @@ void WorldSession::HandleChannelUnban(WorldPacket& recvPacket) if (!normalizePlayerName(otp)) return; - if (ChannelMgr* cMgr = channelMgr(_player->GetTeam())) + if (ChannelMgr* cMgr = ChannelMgr::forTeam(_player->GetTeam())) if (Channel* chn = cMgr->GetChannel(channelname, _player)) chn->UnBan(_player->GetGUID(), otp.c_str()); } @@ -261,7 +261,7 @@ void WorldSession::HandleChannelAnnouncements(WorldPacket& recvPacket) sLog->outDebug(LOG_FILTER_NETWORKIO, "Opcode %u", recvPacket.GetOpcode()); std::string channelname; recvPacket >> channelname; - if (ChannelMgr* cMgr = channelMgr(_player->GetTeam())) + if (ChannelMgr* cMgr = ChannelMgr::forTeam(_player->GetTeam())) if (Channel* chn = cMgr->GetChannel(channelname, _player)) chn->Announce(_player->GetGUID()); } @@ -277,7 +277,7 @@ void WorldSession::HandleGetChannelMemberCount(WorldPacket &recvPacket) sLog->outDebug(LOG_FILTER_NETWORKIO, "Opcode %u", recvPacket.GetOpcode()); std::string channelname; recvPacket >> channelname; - if (ChannelMgr* cMgr = channelMgr(_player->GetTeam())) + if (ChannelMgr* cMgr = ChannelMgr::forTeam(_player->GetTeam())) { if (Channel* chn = cMgr->GetChannel(channelname, _player)) { @@ -299,4 +299,3 @@ void WorldSession::HandleSetChannelWatch(WorldPacket &recvPacket) if (Channel* chn = cMgr->GetChannel(channelname, _player)) chn->JoinNotify(_player->GetGUID());*/ } - diff --git a/src/server/game/Handlers/CharacterHandler.cpp b/src/server/game/Handlers/CharacterHandler.cpp index 396537c1304..258878b1f87 100644 --- a/src/server/game/Handlers/CharacterHandler.cpp +++ b/src/server/game/Handlers/CharacterHandler.cpp @@ -230,7 +230,7 @@ void WorldSession::HandleCharEnum(PreparedQueryResult result) SendPacket(&data); } -void WorldSession::HandleCharEnumOpcode(WorldPacket & /*recv_data*/) +void WorldSession::HandleCharEnumOpcode(WorldPacket & /*recvData*/) { // remove expired bans PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_EXPIRED_BANS); @@ -249,20 +249,20 @@ void WorldSession::HandleCharEnumOpcode(WorldPacket & /*recv_data*/) _charEnumCallback = CharacterDatabase.AsyncQuery(stmt); } -void WorldSession::HandleCharCreateOpcode(WorldPacket & recv_data) +void WorldSession::HandleCharCreateOpcode(WorldPacket & recvData) { std::string name; uint8 race_, class_; - recv_data >> name; + recvData >> name; - recv_data >> race_; - recv_data >> class_; + recvData >> race_; + recvData >> class_; // extract other data required for player creating uint8 gender, skin, face, hairStyle, hairColor, facialHair, outfitId; - recv_data >> gender >> skin >> face; - recv_data >> hairStyle >> hairColor >> facialHair >> outfitId; + recvData >> gender >> skin >> face; + recvData >> hairStyle >> hairColor >> facialHair >> outfitId; WorldPacket data(SMSG_CHAR_CREATE, 1); // returned with diff.values in all cases @@ -387,7 +387,7 @@ void WorldSession::HandleCharCreateOpcode(WorldPacket & recv_data) } delete _charCreateCallback.GetParam(); // Delete existing if any, to make the callback chain reset to stage 0 - _charCreateCallback.SetParam(new CharacterCreateInfo(name, race_, class_, gender, skin, face, hairStyle, hairColor, facialHair, outfitId, recv_data)); + _charCreateCallback.SetParam(new CharacterCreateInfo(name, race_, class_, gender, skin, face, hairStyle, hairColor, facialHair, outfitId, recvData)); PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHECK_NAME); stmt->setString(0, name); _charCreateCallback.SetFutureResult(CharacterDatabase.AsyncQuery(stmt)); @@ -660,7 +660,7 @@ void WorldSession::HandleCharCreateCallback(PreparedQueryResult result, Characte std::string IP_str = GetRemoteAddress(); sLog->outInfo(LOG_FILTER_CHARACTER, "Account: %d (IP: %s) Create Character:[%s] (GUID: %u)", GetAccountId(), IP_str.c_str(), createInfo->Name.c_str(), newChar.GetGUIDLow()); sScriptMgr->OnPlayerCreate(&newChar); - sWorld->AddCharacterNameData(newChar.GetGUIDLow(), std::string(newChar.GetName()), newChar.getGender(), newChar.getRace(), newChar.getClass(), newChar.getLevel()); + sWorld->AddCharacterNameData(newChar.GetGUIDLow(), newChar.GetName(), newChar.getGender(), newChar.getRace(), newChar.getClass(), newChar.getLevel()); newChar.CleanupsBeforeDelete(); delete createInfo; @@ -670,10 +670,10 @@ void WorldSession::HandleCharCreateCallback(PreparedQueryResult result, Characte } } -void WorldSession::HandleCharDeleteOpcode(WorldPacket & recv_data) +void WorldSession::HandleCharDeleteOpcode(WorldPacket & recvData) { uint64 guid; - recv_data >> guid; + recvData >> guid; // can't delete loaded character if (ObjectAccessor::FindPlayer(guid)) @@ -733,7 +733,7 @@ void WorldSession::HandleCharDeleteOpcode(WorldPacket & recv_data) SendPacket(&data); } -void WorldSession::HandlePlayerLoginOpcode(WorldPacket & recv_data) +void WorldSession::HandlePlayerLoginOpcode(WorldPacket & recvData) { if (PlayerLoading() || GetPlayer() != NULL) { @@ -746,7 +746,7 @@ void WorldSession::HandlePlayerLoginOpcode(WorldPacket & recv_data) sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Recvd Player Logon Message"); - recv_data >> playerGuid; + recvData >> playerGuid; if (!CharCanLogin(GUID_LOPART(playerGuid))) { @@ -863,7 +863,7 @@ void WorldSession::HandlePlayerLogin(LoginQueryHolder* holder) else { // remove wrong guild data - sLog->outError(LOG_FILTER_NETWORKIO, "Player %s (GUID: %u) marked as member of not existing guild (id: %u), removing guild membership for player.", pCurrChar->GetName(), pCurrChar->GetGUIDLow(), pCurrChar->GetGuildId()); + sLog->outError(LOG_FILTER_NETWORKIO, "Player %s (GUID: %u) marked as member of not existing guild (id: %u), removing guild membership for player.", pCurrChar->GetName().c_str(), pCurrChar->GetGUIDLow(), pCurrChar->GetGuildId()); pCurrChar->SetInGuild(0); } } @@ -893,17 +893,6 @@ void WorldSession::HandlePlayerLogin(LoginQueryHolder* holder) } } - if (Group* group = pCurrChar->GetGroup()) - { - if (group->isLFGGroup()) - { - LfgDungeonSet Dungeons; - Dungeons.insert(sLFGMgr->GetDungeon(group->GetGUID())); - sLFGMgr->SetSelectedDungeons(pCurrChar->GetGUID(), Dungeons); - sLFGMgr->SetState(pCurrChar->GetGUID(), sLFGMgr->GetState(group->GetGUID())); - } - } - if (!pCurrChar->GetMap()->AddPlayerToMap(pCurrChar) || !pCurrChar->CheckInstanceLoginValid()) { AreaTrigger const* at = sObjectMgr->GetGoBackTrigger(pCurrChar->GetMapId()); @@ -914,7 +903,7 @@ void WorldSession::HandlePlayerLogin(LoginQueryHolder* holder) } sObjectAccessor->AddObject(pCurrChar); - //sLog->outDebug("Player %s added to Map.", pCurrChar->GetName()); + //sLog->outDebug("Player %s added to Map.", pCurrChar->GetName().c_str()); pCurrChar->SendInitialPacketsAfterAddToMap(); @@ -1002,7 +991,7 @@ void WorldSession::HandlePlayerLogin(LoginQueryHolder* holder) std::string IP_str = GetRemoteAddress(); sLog->outInfo(LOG_FILTER_CHARACTER, "Account: %d (IP: %s) Login Character:[%s] (GUID: %u) Level: %d", - GetAccountId(), IP_str.c_str(), pCurrChar->GetName(), pCurrChar->GetGUIDLow(), pCurrChar->getLevel()); + GetAccountId(), IP_str.c_str(), pCurrChar->GetName().c_str(), pCurrChar->GetGUIDLow(), pCurrChar->getLevel()); if (!pCurrChar->IsStandState() && !pCurrChar->HasUnitState(UNIT_STATE_STUNNED)) pCurrChar->SetStandState(UNIT_STAND_STATE_STAND); @@ -1013,30 +1002,30 @@ void WorldSession::HandlePlayerLogin(LoginQueryHolder* holder) delete holder; } -void WorldSession::HandleSetFactionAtWar(WorldPacket & recv_data) +void WorldSession::HandleSetFactionAtWar(WorldPacket & recvData) { sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Received CMSG_SET_FACTION_ATWAR"); uint32 repListID; uint8 flag; - recv_data >> repListID; - recv_data >> flag; + recvData >> repListID; + recvData >> flag; GetPlayer()->GetReputationMgr().SetAtWar(repListID, flag); } //I think this function is never used :/ I dunno, but i guess this opcode not exists -void WorldSession::HandleSetFactionCheat(WorldPacket & /*recv_data*/) +void WorldSession::HandleSetFactionCheat(WorldPacket & /*recvData*/) { sLog->outError(LOG_FILTER_NETWORKIO, "WORLD SESSION: HandleSetFactionCheat, not expected call, please report."); GetPlayer()->GetReputationMgr().SendStates(); } -void WorldSession::HandleTutorialFlag(WorldPacket & recv_data) +void WorldSession::HandleTutorialFlag(WorldPacket & recvData) { uint32 data; - recv_data >> data; + recvData >> data; uint8 index = uint8(data / 32); if (index >= MAX_ACCOUNT_TUTORIAL_VALUES) @@ -1049,57 +1038,57 @@ void WorldSession::HandleTutorialFlag(WorldPacket & recv_data) SetTutorialInt(index, flag); } -void WorldSession::HandleTutorialClear(WorldPacket & /*recv_data*/) +void WorldSession::HandleTutorialClear(WorldPacket & /*recvData*/) { for (uint8 i = 0; i < MAX_ACCOUNT_TUTORIAL_VALUES; ++i) SetTutorialInt(i, 0xFFFFFFFF); } -void WorldSession::HandleTutorialReset(WorldPacket & /*recv_data*/) +void WorldSession::HandleTutorialReset(WorldPacket & /*recvData*/) { for (uint8 i = 0; i < MAX_ACCOUNT_TUTORIAL_VALUES; ++i) SetTutorialInt(i, 0x00000000); } -void WorldSession::HandleSetWatchedFactionOpcode(WorldPacket & recv_data) +void WorldSession::HandleSetWatchedFactionOpcode(WorldPacket & recvData) { sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Received CMSG_SET_WATCHED_FACTION"); uint32 fact; - recv_data >> fact; + recvData >> fact; GetPlayer()->SetUInt32Value(PLAYER_FIELD_WATCHED_FACTION_INDEX, fact); } -void WorldSession::HandleSetFactionInactiveOpcode(WorldPacket & recv_data) +void WorldSession::HandleSetFactionInactiveOpcode(WorldPacket & recvData) { sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Received CMSG_SET_FACTION_INACTIVE"); uint32 replistid; uint8 inactive; - recv_data >> replistid >> inactive; + recvData >> replistid >> inactive; _player->GetReputationMgr().SetInactive(replistid, inactive); } -void WorldSession::HandleShowingHelmOpcode(WorldPacket& recv_data) +void WorldSession::HandleShowingHelmOpcode(WorldPacket& recvData) { - sLog->outDebug(LOG_FILTER_NETWORKIO, "CMSG_SHOWING_HELM for %s", _player->GetName()); - recv_data.read_skip<uint8>(); // unknown, bool? + sLog->outDebug(LOG_FILTER_NETWORKIO, "CMSG_SHOWING_HELM for %s", _player->GetName().c_str()); + recvData.read_skip<uint8>(); // unknown, bool? _player->ToggleFlag(PLAYER_FLAGS, PLAYER_FLAGS_HIDE_HELM); } -void WorldSession::HandleShowingCloakOpcode(WorldPacket& recv_data) +void WorldSession::HandleShowingCloakOpcode(WorldPacket& recvData) { - sLog->outDebug(LOG_FILTER_NETWORKIO, "CMSG_SHOWING_CLOAK for %s", _player->GetName()); - recv_data.read_skip<uint8>(); // unknown, bool? + sLog->outDebug(LOG_FILTER_NETWORKIO, "CMSG_SHOWING_CLOAK for %s", _player->GetName().c_str()); + recvData.read_skip<uint8>(); // unknown, bool? _player->ToggleFlag(PLAYER_FLAGS, PLAYER_FLAGS_HIDE_CLOAK); } -void WorldSession::HandleCharRenameOpcode(WorldPacket& recv_data) +void WorldSession::HandleCharRenameOpcode(WorldPacket& recvData) { uint64 guid; std::string newName; - recv_data >> guid; - recv_data >> newName; + recvData >> guid; + recvData >> newName; // prevent character rename to invalid name if (!normalizePlayerName(newName)) @@ -1145,7 +1134,7 @@ void WorldSession::HandleCharRenameOpcode(WorldPacket& recv_data) _charRenameCallback.SetFutureResult(CharacterDatabase.AsyncQuery(stmt)); } -void WorldSession::HandleChangePlayerNameOpcodeCallBack(PreparedQueryResult result, std::string newName) +void WorldSession::HandleChangePlayerNameOpcodeCallBack(PreparedQueryResult result, std::string const& newName) { if (!result) { @@ -1189,11 +1178,11 @@ void WorldSession::HandleChangePlayerNameOpcodeCallBack(PreparedQueryResult resu sWorld->UpdateCharacterNameData(guidLow, newName); } -void WorldSession::HandleSetPlayerDeclinedNames(WorldPacket& recv_data) +void WorldSession::HandleSetPlayerDeclinedNames(WorldPacket& recvData) { uint64 guid; - recv_data >> guid; + recvData >> guid; // not accept declined names for unsupported languages std::string name; @@ -1228,7 +1217,7 @@ void WorldSession::HandleSetPlayerDeclinedNames(WorldPacket& recv_data) std::string name2; DeclinedName declinedname; - recv_data >> name2; + recvData >> name2; if (name2 != name) // character have different name { @@ -1241,7 +1230,7 @@ void WorldSession::HandleSetPlayerDeclinedNames(WorldPacket& recv_data) for (int i = 0; i < MAX_DECLINED_NAME_CASES; ++i) { - recv_data >> declinedname.name[i]; + recvData >> declinedname.name[i]; if (!normalizePlayerName(declinedname.name[i])) { WorldPacket data(SMSG_SET_PLAYER_DECLINED_NAMES_RESULT, 4+8); @@ -1286,12 +1275,12 @@ void WorldSession::HandleSetPlayerDeclinedNames(WorldPacket& recv_data) SendPacket(&data); } -void WorldSession::HandleAlterAppearance(WorldPacket & recv_data) +void WorldSession::HandleAlterAppearance(WorldPacket & recvData) { sLog->outDebug(LOG_FILTER_NETWORKIO, "CMSG_ALTER_APPEARANCE"); uint32 Hair, Color, FacialHair, SkinColor; - recv_data >> Hair >> Color >> FacialHair >> SkinColor; + recvData >> Hair >> Color >> FacialHair >> SkinColor; BarberShopStyleEntry const* bs_hair = sBarberShopStyleStore.LookupEntry(Hair); @@ -1358,10 +1347,10 @@ void WorldSession::HandleAlterAppearance(WorldPacket & recv_data) _player->SetStandState(0); // stand up } -void WorldSession::HandleRemoveGlyph(WorldPacket & recv_data) +void WorldSession::HandleRemoveGlyph(WorldPacket & recvData) { uint32 slot; - recv_data >> slot; + recvData >> slot; if (slot >= MAX_GLYPH_SLOT_INDEX) { @@ -1380,16 +1369,16 @@ void WorldSession::HandleRemoveGlyph(WorldPacket & recv_data) } } -void WorldSession::HandleCharCustomize(WorldPacket& recv_data) +void WorldSession::HandleCharCustomize(WorldPacket& recvData) { uint64 guid; std::string newName; - recv_data >> guid; - recv_data >> newName; + recvData >> guid; + recvData >> newName; uint8 gender, skin, face, hairStyle, hairColor, facialHair; - recv_data >> gender >> skin >> hairColor >> hairStyle >> facialHair >> face; + recvData >> gender >> skin >> hairColor >> hairStyle >> facialHair >> face; PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHARACTER_AT_LOGIN); @@ -1496,23 +1485,23 @@ void WorldSession::HandleCharCustomize(WorldPacket& recv_data) SendPacket(&data); } -void WorldSession::HandleEquipmentSetSave(WorldPacket &recv_data) +void WorldSession::HandleEquipmentSetSave(WorldPacket &recvData) { sLog->outDebug(LOG_FILTER_NETWORKIO, "CMSG_EQUIPMENT_SET_SAVE"); uint64 setGuid; - recv_data.readPackGUID(setGuid); + recvData.readPackGUID(setGuid); uint32 index; - recv_data >> index; + recvData >> index; if (index >= MAX_EQUIPMENT_SET_INDEX) // client set slots amount return; std::string name; - recv_data >> name; + recvData >> name; std::string iconName; - recv_data >> iconName; + recvData >> iconName; EquipmentSet eqSet; @@ -1524,7 +1513,7 @@ void WorldSession::HandleEquipmentSetSave(WorldPacket &recv_data) for (uint32 i = 0; i < EQUIPMENT_SLOT_END; ++i) { uint64 itemGuid; - recv_data.readPackGUID(itemGuid); + recvData.readPackGUID(itemGuid); // equipment manager sends "1" (as raw GUID) for slots set to "ignore" (don't touch slot at equip set) if (itemGuid == 1) @@ -1548,17 +1537,17 @@ void WorldSession::HandleEquipmentSetSave(WorldPacket &recv_data) _player->SetEquipmentSet(index, eqSet); } -void WorldSession::HandleEquipmentSetDelete(WorldPacket &recv_data) +void WorldSession::HandleEquipmentSetDelete(WorldPacket &recvData) { sLog->outDebug(LOG_FILTER_NETWORKIO, "CMSG_EQUIPMENT_SET_DELETE"); uint64 setGuid; - recv_data.readPackGUID(setGuid); + recvData.readPackGUID(setGuid); _player->DeleteEquipmentSet(setGuid); } -void WorldSession::HandleEquipmentSetUse(WorldPacket &recv_data) +void WorldSession::HandleEquipmentSetUse(WorldPacket &recvData) { if (_player->isInCombat()) return; @@ -1568,10 +1557,10 @@ void WorldSession::HandleEquipmentSetUse(WorldPacket &recv_data) for (uint32 i = 0; i < EQUIPMENT_SLOT_END; ++i) { uint64 itemGuid; - recv_data.readPackGUID(itemGuid); + recvData.readPackGUID(itemGuid); uint8 srcbag, srcslot; - recv_data >> srcbag >> srcslot; + recvData >> srcbag >> srcslot; sLog->outDebug(LOG_FILTER_PLAYER_ITEMS, "Item " UI64FMTD ": srcbag %u, srcslot %u", itemGuid, srcbag, srcslot); @@ -1613,15 +1602,14 @@ void WorldSession::HandleEquipmentSetUse(WorldPacket &recv_data) SendPacket(&data); } -void WorldSession::HandleCharFactionOrRaceChange(WorldPacket& recv_data) +void WorldSession::HandleCharFactionOrRaceChange(WorldPacket& recvData) { - // TODO: Move queries to prepared statements uint64 guid; std::string newname; uint8 gender, skin, face, hairStyle, hairColor, facialHair, race; - recv_data >> guid; - recv_data >> newname; - recv_data >> gender >> skin >> hairColor >> hairStyle >> facialHair >> face >> race; + recvData >> guid; + recvData >> newname; + recvData >> gender >> skin >> hairColor >> hairStyle >> facialHair >> face >> race; uint32 lowGuid = GUID_LOPART(guid); @@ -1646,7 +1634,7 @@ void WorldSession::HandleCharFactionOrRaceChange(WorldPacket& recv_data) Field* fields = result->Fetch(); uint32 at_loginFlags = fields[0].GetUInt16(); char const* knownTitlesStr = fields[1].GetCString(); - uint32 used_loginFlag = ((recv_data.GetOpcode() == CMSG_CHAR_RACE_CHANGE) ? AT_LOGIN_CHANGE_RACE : AT_LOGIN_CHANGE_FACTION); + uint32 used_loginFlag = ((recvData.GetOpcode() == CMSG_CHAR_RACE_CHANGE) ? AT_LOGIN_CHANGE_RACE : AT_LOGIN_CHANGE_FACTION); if (!sObjectMgr->GetPlayerInfo(race, playerClass)) { @@ -1732,384 +1720,387 @@ void WorldSession::HandleCharFactionOrRaceChange(WorldPacket& recv_data) sWorld->UpdateCharacterNameData(GUID_LOPART(guid), newname, gender, race); - TeamId team = TEAM_ALLIANCE; - - // Search each faction is targeted - switch (race) + if (oldRace != race) { - case RACE_ORC: - case RACE_TAUREN: - case RACE_UNDEAD_PLAYER: - case RACE_TROLL: - case RACE_BLOODELF: - team = TEAM_HORDE; - break; - default: - break; - } - - // Switch Languages - // delete all languages first - stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_SKILL_LANGUAGES); - stmt->setUInt32(0, lowGuid); - trans->Append(stmt); - - // Now add them back - stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_CHAR_SKILL_LANGUAGE); - stmt->setUInt32(0, lowGuid); - - // Faction specific languages - if (team == TEAM_HORDE) - stmt->setUInt16(1, 109); - else - stmt->setUInt16(1, 98); - - trans->Append(stmt); - - // Race specific languages - if (race != RACE_ORC && race != RACE_HUMAN) - { - stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_CHAR_SKILL_LANGUAGE); - stmt->setUInt32(0, lowGuid); + TeamId team = TEAM_ALLIANCE; + // Search each faction is targeted switch (race) { - case RACE_DWARF: - stmt->setUInt16(1, 111); - break; - case RACE_DRAENEI: - stmt->setUInt16(1, 759); - break; - case RACE_GNOME: - stmt->setUInt16(1, 313); - break; - case RACE_NIGHTELF: - stmt->setUInt16(1, 113); - break; - case RACE_UNDEAD_PLAYER: - stmt->setUInt16(1, 673); - break; + case RACE_ORC: case RACE_TAUREN: - stmt->setUInt16(1, 115); - break; + case RACE_UNDEAD_PLAYER: case RACE_TROLL: - stmt->setUInt16(1, 315); - break; case RACE_BLOODELF: - stmt->setUInt16(1, 137); + team = TEAM_HORDE; + break; + default: break; } + // Switch Languages + // delete all languages first + stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_SKILL_LANGUAGES); + stmt->setUInt32(0, lowGuid); trans->Append(stmt); - } - if (recv_data.GetOpcode() == CMSG_CHAR_FACTION_CHANGE) - { - // Delete all Flypaths - PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_CHAR_TAXI_PATH); + // Now add them back + stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_CHAR_SKILL_LANGUAGE); stmt->setUInt32(0, lowGuid); + + // Faction specific languages + if (team == TEAM_HORDE) + stmt->setUInt16(1, 109); + else + stmt->setUInt16(1, 98); + trans->Append(stmt); - if (level > 7) + // Race specific languages + if (race != RACE_ORC && race != RACE_HUMAN) { - // Update Taxi path - // this doesn't seem to be 100% blizzlike... but it can't really be helped. - std::ostringstream taximaskstream; - uint32 numFullTaximasks = level / 7; - if (numFullTaximasks > 11) - numFullTaximasks = 11; - if (team == TEAM_ALLIANCE) - { - if (playerClass != CLASS_DEATH_KNIGHT) - { - for (uint8 i = 0; i < numFullTaximasks; ++i) - taximaskstream << uint32(sAllianceTaxiNodesMask[i]) << ' '; - } - else - { - for (uint8 i = 0; i < numFullTaximasks; ++i) - taximaskstream << uint32(sAllianceTaxiNodesMask[i] | sDeathKnightTaxiNodesMask[i]) << ' '; - } - } - else + stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_CHAR_SKILL_LANGUAGE); + stmt->setUInt32(0, lowGuid); + + switch (race) { - if (playerClass != CLASS_DEATH_KNIGHT) - { - for (uint8 i = 0; i < numFullTaximasks; ++i) - taximaskstream << uint32(sHordeTaxiNodesMask[i]) << ' '; - } - else - { - for (uint8 i = 0; i < numFullTaximasks; ++i) - taximaskstream << uint32(sHordeTaxiNodesMask[i] | sDeathKnightTaxiNodesMask[i]) << ' '; - } + case RACE_DWARF: + stmt->setUInt16(1, 111); + break; + case RACE_DRAENEI: + stmt->setUInt16(1, 759); + break; + case RACE_GNOME: + stmt->setUInt16(1, 313); + break; + case RACE_NIGHTELF: + stmt->setUInt16(1, 113); + break; + case RACE_UNDEAD_PLAYER: + stmt->setUInt16(1, 673); + break; + case RACE_TAUREN: + stmt->setUInt16(1, 115); + break; + case RACE_TROLL: + stmt->setUInt16(1, 315); + break; + case RACE_BLOODELF: + stmt->setUInt16(1, 137); + break; } - uint32 numEmptyTaximasks = 11 - numFullTaximasks; - for (uint8 i = 0; i < numEmptyTaximasks; ++i) - taximaskstream << "0 "; - taximaskstream << '0'; - std::string taximask = taximaskstream.str(); - - PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_CHAR_TAXIMASK); - stmt->setString(0, taximask); - stmt->setUInt32(1, lowGuid); trans->Append(stmt); } - // Delete all current quests - stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_QUESTSTATUS); - stmt->setUInt32(0, GUID_LOPART(guid)); - trans->Append(stmt); - - // Delete record of the faction old completed quests + if (recvData.GetOpcode() == CMSG_CHAR_FACTION_CHANGE) { - std::ostringstream quests; - ObjectMgr::QuestMap const& qTemplates = sObjectMgr->GetQuestTemplates(); - for (ObjectMgr::QuestMap::const_iterator iter = qTemplates.begin(); iter != qTemplates.end(); ++iter) + // Delete all Flypaths + PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_CHAR_TAXI_PATH); + stmt->setUInt32(0, lowGuid); + trans->Append(stmt); + + if (level > 7) { - Quest *qinfo = iter->second; - uint32 requiredRaces = qinfo->GetRequiredRaces(); + // Update Taxi path + // this doesn't seem to be 100% blizzlike... but it can't really be helped. + std::ostringstream taximaskstream; + uint32 numFullTaximasks = level / 7; + if (numFullTaximasks > 11) + numFullTaximasks = 11; if (team == TEAM_ALLIANCE) { - if (requiredRaces & RACEMASK_ALLIANCE) + if (playerClass != CLASS_DEATH_KNIGHT) + { + for (uint8 i = 0; i < numFullTaximasks; ++i) + taximaskstream << uint32(sAllianceTaxiNodesMask[i]) << ' '; + } + else { - quests << uint32(qinfo->GetQuestId()); - quests << ','; + for (uint8 i = 0; i < numFullTaximasks; ++i) + taximaskstream << uint32(sAllianceTaxiNodesMask[i] | sDeathKnightTaxiNodesMask[i]) << ' '; } } - else // if (team == TEAM_HORDE) + else { - if (requiredRaces & RACEMASK_HORDE) + if (playerClass != CLASS_DEATH_KNIGHT) { - quests << uint32(qinfo->GetQuestId()); - quests << ','; + for (uint8 i = 0; i < numFullTaximasks; ++i) + taximaskstream << uint32(sHordeTaxiNodesMask[i]) << ' '; + } + else + { + for (uint8 i = 0; i < numFullTaximasks; ++i) + taximaskstream << uint32(sHordeTaxiNodesMask[i] | sDeathKnightTaxiNodesMask[i]) << ' '; } } - } - std::string questsStr = quests.str(); - questsStr = questsStr.substr(0, questsStr.length() - 1); + uint32 numEmptyTaximasks = 11 - numFullTaximasks; + for (uint8 i = 0; i < numEmptyTaximasks; ++i) + taximaskstream << "0 "; + taximaskstream << '0'; + std::string taximask = taximaskstream.str(); - if (!questsStr.empty()) - trans->PAppend("DELETE FROM `character_queststatus_rewarded` WHERE guid='%u' AND quest IN (%s)", lowGuid, questsStr.c_str()); - } + PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_CHAR_TAXIMASK); + stmt->setString(0, taximask); + stmt->setUInt32(1, lowGuid); + trans->Append(stmt); + } - if (!sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_GUILD)) - { - // Reset guild - PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_GUILD_MEMBER); + // Delete all current quests + stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_QUESTSTATUS); + stmt->setUInt32(0, GUID_LOPART(guid)); + trans->Append(stmt); - stmt->setUInt32(0, lowGuid); + // Delete record of the faction old completed quests + { + std::ostringstream quests; + ObjectMgr::QuestMap const& qTemplates = sObjectMgr->GetQuestTemplates(); + for (ObjectMgr::QuestMap::const_iterator iter = qTemplates.begin(); iter != qTemplates.end(); ++iter) + { + Quest *qinfo = iter->second; + uint32 requiredRaces = qinfo->GetRequiredRaces(); + if (team == TEAM_ALLIANCE) + { + if (requiredRaces & RACEMASK_ALLIANCE) + { + quests << uint32(qinfo->GetQuestId()); + quests << ','; + } + } + else // if (team == TEAM_HORDE) + { + if (requiredRaces & RACEMASK_HORDE) + { + quests << uint32(qinfo->GetQuestId()); + quests << ','; + } + } + } - PreparedQueryResult result = CharacterDatabase.Query(stmt); - if (result) - if (Guild* guild = sGuildMgr->GetGuildById((result->Fetch()[0]).GetUInt32())) - guild->DeleteMember(MAKE_NEW_GUID(lowGuid, 0, HIGHGUID_PLAYER)); - } + std::string questsStr = quests.str(); + questsStr = questsStr.substr(0, questsStr.length() - 1); - if (!sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_ADD_FRIEND)) - { - // Delete Friend List - PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_SOCIAL_BY_GUID); - stmt->setUInt32(0, lowGuid); - trans->Append(stmt); + if (!questsStr.empty()) + trans->PAppend("DELETE FROM `character_queststatus_rewarded` WHERE guid='%u' AND quest IN (%s)", lowGuid, questsStr.c_str()); + } - stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_SOCIAL_BY_FRIEND); - stmt->setUInt32(0, lowGuid); - trans->Append(stmt); + if (!sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_GUILD)) + { + // Reset guild + PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_GUILD_MEMBER); - } + stmt->setUInt32(0, lowGuid); - // Leave Arena Teams - Player::LeaveAllArenaTeams(guid); + PreparedQueryResult result = CharacterDatabase.Query(stmt); + if (result) + if (Guild* guild = sGuildMgr->GetGuildById((result->Fetch()[0]).GetUInt32())) + guild->DeleteMember(MAKE_NEW_GUID(lowGuid, 0, HIGHGUID_PLAYER)); + } - // Reset homebind and position - stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_PLAYER_HOMEBIND); - stmt->setUInt32(0, lowGuid); - trans->Append(stmt); + if (!sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_ADD_FRIEND)) + { + // Delete Friend List + PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_SOCIAL_BY_GUID); + stmt->setUInt32(0, lowGuid); + trans->Append(stmt); - stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_PLAYER_HOMEBIND); - stmt->setUInt32(0, lowGuid); - if (team == TEAM_ALLIANCE) - { - stmt->setUInt16(1, 0); - stmt->setUInt16(2, 1519); - stmt->setFloat (3, -8867.68f); - stmt->setFloat (4, 673.373f); - stmt->setFloat (5, 97.9034f); - Player::SavePositionInDB(0, -8867.68f, 673.373f, 97.9034f, 0.0f, 1519, lowGuid); - } - else - { - stmt->setUInt16(1, 1); - stmt->setUInt16(2, 1637); - stmt->setFloat (3, 1633.33f); - stmt->setFloat (4, -4439.11f); - stmt->setFloat (5, 15.7588f); - Player::SavePositionInDB(1, 1633.33f, -4439.11f, 15.7588f, 0.0f, 1637, lowGuid); - } - trans->Append(stmt); + stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_SOCIAL_BY_FRIEND); + stmt->setUInt32(0, lowGuid); + trans->Append(stmt); - // Achievement conversion - for (std::map<uint32, uint32>::const_iterator it = sObjectMgr->FactionChange_Achievements.begin(); it != sObjectMgr->FactionChange_Achievements.end(); ++it) - { - uint32 achiev_alliance = it->first; - uint32 achiev_horde = it->second; + } - PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_ACHIEVEMENT_BY_ACHIEVEMENT); - stmt->setUInt16(0, uint16(team == TEAM_ALLIANCE ? achiev_alliance : achiev_horde)); - stmt->setUInt32(1, lowGuid); - trans->Append(stmt); + // Leave Arena Teams + Player::LeaveAllArenaTeams(guid); - stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_CHAR_ACHIEVEMENT); - stmt->setUInt16(0, uint16(team == TEAM_ALLIANCE ? achiev_alliance : achiev_horde)); - stmt->setUInt16(1, uint16(team == TEAM_ALLIANCE ? achiev_horde : achiev_alliance)); - stmt->setUInt32(2, lowGuid); + // Reset homebind and position + stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_PLAYER_HOMEBIND); + stmt->setUInt32(0, lowGuid); trans->Append(stmt); - } - // Item conversion - for (std::map<uint32, uint32>::const_iterator it = sObjectMgr->FactionChange_Items.begin(); it != sObjectMgr->FactionChange_Items.end(); ++it) - { - uint32 item_alliance = it->first; - uint32 item_horde = it->second; - - PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_CHAR_INVENTORY_FACTION_CHANGE); - stmt->setUInt32(0, (team == TEAM_ALLIANCE ? item_alliance : item_horde)); - stmt->setUInt32(1, (team == TEAM_ALLIANCE ? item_horde : item_alliance)); - stmt->setUInt32(2, guid); + stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_PLAYER_HOMEBIND); + stmt->setUInt32(0, lowGuid); + if (team == TEAM_ALLIANCE) + { + stmt->setUInt16(1, 0); + stmt->setUInt16(2, 1519); + stmt->setFloat (3, -8867.68f); + stmt->setFloat (4, 673.373f); + stmt->setFloat (5, 97.9034f); + Player::SavePositionInDB(0, -8867.68f, 673.373f, 97.9034f, 0.0f, 1519, lowGuid); + } + else + { + stmt->setUInt16(1, 1); + stmt->setUInt16(2, 1637); + stmt->setFloat (3, 1633.33f); + stmt->setFloat (4, -4439.11f); + stmt->setFloat (5, 15.7588f); + Player::SavePositionInDB(1, 1633.33f, -4439.11f, 15.7588f, 0.0f, 1637, lowGuid); + } trans->Append(stmt); - } - // Spell conversion - for (std::map<uint32, uint32>::const_iterator it = sObjectMgr->FactionChange_Spells.begin(); it != sObjectMgr->FactionChange_Spells.end(); ++it) - { - uint32 spell_alliance = it->first; - uint32 spell_horde = it->second; + // Achievement conversion + for (std::map<uint32, uint32>::const_iterator it = sObjectMgr->FactionChange_Achievements.begin(); it != sObjectMgr->FactionChange_Achievements.end(); ++it) + { + uint32 achiev_alliance = it->first; + uint32 achiev_horde = it->second; - PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_SPELL_BY_SPELL); - stmt->setUInt32(0, (team == TEAM_ALLIANCE ? spell_alliance : spell_horde)); - stmt->setUInt32(1, lowGuid); - trans->Append(stmt); + PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_ACHIEVEMENT_BY_ACHIEVEMENT); + stmt->setUInt16(0, uint16(team == TEAM_ALLIANCE ? achiev_alliance : achiev_horde)); + stmt->setUInt32(1, lowGuid); + trans->Append(stmt); - stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_CHAR_SPELL_FACTION_CHANGE); - stmt->setUInt32(0, (team == TEAM_ALLIANCE ? spell_alliance : spell_horde)); - stmt->setUInt32(1, (team == TEAM_ALLIANCE ? spell_horde : spell_alliance)); - stmt->setUInt32(2, lowGuid); - trans->Append(stmt); - } + stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_CHAR_ACHIEVEMENT); + stmt->setUInt16(0, uint16(team == TEAM_ALLIANCE ? achiev_alliance : achiev_horde)); + stmt->setUInt16(1, uint16(team == TEAM_ALLIANCE ? achiev_horde : achiev_alliance)); + stmt->setUInt32(2, lowGuid); + trans->Append(stmt); + } - // Reputation conversion - for (std::map<uint32, uint32>::const_iterator it = sObjectMgr->FactionChange_Reputation.begin(); it != sObjectMgr->FactionChange_Reputation.end(); ++it) - { - uint32 reputation_alliance = it->first; - uint32 reputation_horde = it->second; - uint32 newReputation = (team == TEAM_ALLIANCE) ? reputation_alliance : reputation_horde; - uint32 oldReputation = (team == TEAM_ALLIANCE) ? reputation_horde : reputation_alliance; - - // select old standing set in db - PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHAR_REP_BY_FACTION); - stmt->setUInt32(0, oldReputation); - stmt->setUInt32(1, lowGuid); - PreparedQueryResult result = CharacterDatabase.Query(stmt); - - if (!result) + // Item conversion + for (std::map<uint32, uint32>::const_iterator it = sObjectMgr->FactionChange_Items.begin(); it != sObjectMgr->FactionChange_Items.end(); ++it) { - WorldPacket data(SMSG_CHAR_FACTION_CHANGE, 1); - data << uint8(CHAR_CREATE_ERROR); - SendPacket(&data); - return; + uint32 item_alliance = it->first; + uint32 item_horde = it->second; + + PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_CHAR_INVENTORY_FACTION_CHANGE); + stmt->setUInt32(0, (team == TEAM_ALLIANCE ? item_alliance : item_horde)); + stmt->setUInt32(1, (team == TEAM_ALLIANCE ? item_horde : item_alliance)); + stmt->setUInt32(2, guid); + trans->Append(stmt); } - Field* fields = result->Fetch(); - int32 oldDBRep = fields[0].GetInt32(); - FactionEntry const* factionEntry = sFactionStore.LookupEntry(oldReputation); + // Spell conversion + for (std::map<uint32, uint32>::const_iterator it = sObjectMgr->FactionChange_Spells.begin(); it != sObjectMgr->FactionChange_Spells.end(); ++it) + { + uint32 spell_alliance = it->first; + uint32 spell_horde = it->second; - // old base reputation - int32 oldBaseRep = sObjectMgr->GetBaseReputationOff(factionEntry, oldRace, playerClass); + PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_SPELL_BY_SPELL); + stmt->setUInt32(0, (team == TEAM_ALLIANCE ? spell_alliance : spell_horde)); + stmt->setUInt32(1, lowGuid); + trans->Append(stmt); - // new base reputation - int32 newBaseRep = sObjectMgr->GetBaseReputationOff(sFactionStore.LookupEntry(newReputation), race, playerClass); + stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_CHAR_SPELL_FACTION_CHANGE); + stmt->setUInt32(0, (team == TEAM_ALLIANCE ? spell_alliance : spell_horde)); + stmt->setUInt32(1, (team == TEAM_ALLIANCE ? spell_horde : spell_alliance)); + stmt->setUInt32(2, lowGuid); + trans->Append(stmt); + } - // final reputation shouldnt change - int32 FinalRep = oldDBRep + oldBaseRep; - int32 newDBRep = FinalRep - newBaseRep; + // Reputation conversion + for (std::map<uint32, uint32>::const_iterator it = sObjectMgr->FactionChange_Reputation.begin(); it != sObjectMgr->FactionChange_Reputation.end(); ++it) + { + uint32 reputation_alliance = it->first; + uint32 reputation_horde = it->second; + uint32 newReputation = (team == TEAM_ALLIANCE) ? reputation_alliance : reputation_horde; + uint32 oldReputation = (team == TEAM_ALLIANCE) ? reputation_horde : reputation_alliance; + + // select old standing set in db + PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHAR_REP_BY_FACTION); + stmt->setUInt32(0, oldReputation); + stmt->setUInt32(1, lowGuid); + PreparedQueryResult result = CharacterDatabase.Query(stmt); - stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_REP_BY_FACTION); - stmt->setUInt32(0, newReputation); - stmt->setUInt32(1, lowGuid); - trans->Append(stmt); + if (!result) + { + WorldPacket data(SMSG_CHAR_FACTION_CHANGE, 1); + data << uint8(CHAR_CREATE_ERROR); + SendPacket(&data); + return; + } - stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_CHAR_REP_FACTION_CHANGE); - stmt->setUInt16(0, uint16(newReputation)); - stmt->setInt32(1, newDBRep); - stmt->setUInt16(2, uint16(oldReputation)); - stmt->setUInt32(3, lowGuid); - trans->Append(stmt); - } + Field* fields = result->Fetch(); + int32 oldDBRep = fields[0].GetInt32(); + FactionEntry const* factionEntry = sFactionStore.LookupEntry(oldReputation); - // Title conversion - if (knownTitlesStr) - { - const uint32 ktcount = KNOWN_TITLES_SIZE * 2; - uint32 knownTitles[ktcount]; - Tokenizer tokens(knownTitlesStr, ' ', ktcount); + // old base reputation + int32 oldBaseRep = sObjectMgr->GetBaseReputationOff(factionEntry, oldRace, playerClass); - if (tokens.size() != ktcount) - return; + // new base reputation + int32 newBaseRep = sObjectMgr->GetBaseReputationOff(sFactionStore.LookupEntry(newReputation), race, playerClass); - for (uint32 index = 0; index < ktcount; ++index) - knownTitles[index] = atol(tokens[index]); + // final reputation shouldnt change + int32 FinalRep = oldDBRep + oldBaseRep; + int32 newDBRep = FinalRep - newBaseRep; - for (std::map<uint32, uint32>::const_iterator it = sObjectMgr->FactionChange_Titles.begin(); it != sObjectMgr->FactionChange_Titles.end(); ++it) + stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_REP_BY_FACTION); + stmt->setUInt32(0, newReputation); + stmt->setUInt32(1, lowGuid); + trans->Append(stmt); + + stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_CHAR_REP_FACTION_CHANGE); + stmt->setUInt16(0, uint16(newReputation)); + stmt->setInt32(1, newDBRep); + stmt->setUInt16(2, uint16(oldReputation)); + stmt->setUInt32(3, lowGuid); + trans->Append(stmt); + } + + // Title conversion + if (knownTitlesStr) { - uint32 title_alliance = it->first; - uint32 title_horde = it->second; + const uint32 ktcount = KNOWN_TITLES_SIZE * 2; + uint32 knownTitles[ktcount]; + Tokenizer tokens(knownTitlesStr, ' ', ktcount); - CharTitlesEntry const* atitleInfo = sCharTitlesStore.LookupEntry(title_alliance); - CharTitlesEntry const* htitleInfo = sCharTitlesStore.LookupEntry(title_horde); - // new team - if (team == TEAM_ALLIANCE) + if (tokens.size() != ktcount) + return; + + for (uint32 index = 0; index < ktcount; ++index) + knownTitles[index] = atol(tokens[index]); + + for (std::map<uint32, uint32>::const_iterator it = sObjectMgr->FactionChange_Titles.begin(); it != sObjectMgr->FactionChange_Titles.end(); ++it) { - uint32 bitIndex = htitleInfo->bit_index; - uint32 index = bitIndex / 32; - uint32 old_flag = 1 << (bitIndex % 32); - uint32 new_flag = 1 << (atitleInfo->bit_index % 32); - if (knownTitles[index] & old_flag) + uint32 title_alliance = it->first; + uint32 title_horde = it->second; + + CharTitlesEntry const* atitleInfo = sCharTitlesStore.LookupEntry(title_alliance); + CharTitlesEntry const* htitleInfo = sCharTitlesStore.LookupEntry(title_horde); + // new team + if (team == TEAM_ALLIANCE) { - knownTitles[index] &= ~old_flag; - // use index of the new title - knownTitles[atitleInfo->bit_index / 32] |= new_flag; + uint32 bitIndex = htitleInfo->bit_index; + uint32 index = bitIndex / 32; + uint32 old_flag = 1 << (bitIndex % 32); + uint32 new_flag = 1 << (atitleInfo->bit_index % 32); + if (knownTitles[index] & old_flag) + { + knownTitles[index] &= ~old_flag; + // use index of the new title + knownTitles[atitleInfo->bit_index / 32] |= new_flag; + } } - } - else - { - uint32 bitIndex = atitleInfo->bit_index; - uint32 index = bitIndex / 32; - uint32 old_flag = 1 << (bitIndex % 32); - uint32 new_flag = 1 << (htitleInfo->bit_index % 32); - if (knownTitles[index] & old_flag) + else { - knownTitles[index] &= ~old_flag; - // use index of the new title - knownTitles[htitleInfo->bit_index / 32] |= new_flag; + uint32 bitIndex = atitleInfo->bit_index; + uint32 index = bitIndex / 32; + uint32 old_flag = 1 << (bitIndex % 32); + uint32 new_flag = 1 << (htitleInfo->bit_index % 32); + if (knownTitles[index] & old_flag) + { + knownTitles[index] &= ~old_flag; + // use index of the new title + knownTitles[htitleInfo->bit_index / 32] |= new_flag; + } } - } - std::ostringstream ss; - for (uint32 index = 0; index < ktcount; ++index) - ss << knownTitles[index] << ' '; + std::ostringstream ss; + for (uint32 index = 0; index < ktcount; ++index) + ss << knownTitles[index] << ' '; - PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_CHAR_TITLES_FACTION_CHANGE); - stmt->setString(0, ss.str().c_str()); - stmt->setUInt32(1, lowGuid); - trans->Append(stmt); + PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_CHAR_TITLES_FACTION_CHANGE); + stmt->setString(0, ss.str().c_str()); + stmt->setUInt32(1, lowGuid); + trans->Append(stmt); - // unset any currently chosen title - stmt = CharacterDatabase.GetPreparedStatement(CHAR_RES_CHAR_TITLES_FACTION_CHANGE); - stmt->setUInt32(0, lowGuid); - trans->Append(stmt); + // unset any currently chosen title + stmt = CharacterDatabase.GetPreparedStatement(CHAR_RES_CHAR_TITLES_FACTION_CHANGE); + stmt->setUInt32(0, lowGuid); + trans->Append(stmt); + } } } } @@ -2117,7 +2108,7 @@ void WorldSession::HandleCharFactionOrRaceChange(WorldPacket& recv_data) CharacterDatabase.CommitTransaction(trans); std::string IP_str = GetRemoteAddress(); - sLog->outDebug(LOG_FILTER_UNITS, "Account: %d (IP: %s), Character guid: %u Change Race/Faction to: %s", GetAccountId(), IP_str.c_str(), lowGuid, newname.c_str()); + sLog->outDebug(LOG_FILTER_PLAYER, "%s (IP: %s) changed race from %u to %u", GetPlayerInfo().c_str(), IP_str.c_str(), oldRace, race); WorldPacket data(SMSG_CHAR_FACTION_CHANGE, 1 + 8 + (newname.size() + 1) + 1 + 1 + 1 + 1 + 1 + 1 + 1); data << uint8(RESPONSE_SUCCESS); diff --git a/src/server/game/Handlers/ChatHandler.cpp b/src/server/game/Handlers/ChatHandler.cpp index 711d7af4dc3..8b7fc5542ab 100755 --- a/src/server/game/Handlers/ChatHandler.cpp +++ b/src/server/game/Handlers/ChatHandler.cpp @@ -24,7 +24,6 @@ #include "WorldPacket.h" #include "WorldSession.h" #include "DatabaseEnv.h" - #include "CellImpl.h" #include "Chat.h" #include "ChannelMgr.h" @@ -41,40 +40,18 @@ #include "ScriptMgr.h" #include "AccountMgr.h" -bool WorldSession::processChatmessageFurtherAfterSecurityChecks(std::string& msg, uint32 lang) -{ - if (lang != LANG_ADDON) - { - // strip invisible characters for non-addon messages - if (sWorld->getBoolConfig(CONFIG_CHAT_FAKE_MESSAGE_PREVENTING)) - stripLineInvisibleChars(msg); - - if (sWorld->getIntConfig(CONFIG_CHAT_STRICT_LINK_CHECKING_SEVERITY) && AccountMgr::IsPlayerAccount(GetSecurity()) - && !ChatHandler(this).isValidChatMessage(msg.c_str())) - { - sLog->outError(LOG_FILTER_NETWORKIO, "Player %s (GUID: %u) sent a chatmessage with an invalid link: %s", GetPlayer()->GetName(), - GetPlayer()->GetGUIDLow(), msg.c_str()); - if (sWorld->getIntConfig(CONFIG_CHAT_STRICT_LINK_CHECKING_KICK)) - KickPlayer(); - return false; - } - } - - return true; -} - -void WorldSession::HandleMessagechatOpcode(WorldPacket & recv_data) +void WorldSession::HandleMessagechatOpcode(WorldPacket& recvData) { uint32 type; uint32 lang; - recv_data >> type; - recv_data >> lang; + recvData >> type; + recvData >> lang; if (type >= MAX_CHAT_MSG_TYPE) { sLog->outError(LOG_FILTER_NETWORKIO, "CHAT: Wrong message type received: %u", type); - recv_data.rfinish(); + recvData.rfinish(); return; } @@ -87,7 +64,7 @@ void WorldSession::HandleMessagechatOpcode(WorldPacket & recv_data) if (!langDesc) { SendNotification(LANG_UNKNOWN_LANGUAGE); - recv_data.rfinish(); + recvData.rfinish(); return; } if (langDesc->skill_id != 0 && !sender->HasSkill(langDesc->skill_id)) @@ -106,27 +83,43 @@ void WorldSession::HandleMessagechatOpcode(WorldPacket & recv_data) if (!foundAura) { SendNotification(LANG_NOT_LEARNED_LANGUAGE); - recv_data.rfinish(); + recvData.rfinish(); return; } } if (lang == LANG_ADDON) { - if (sWorld->getBoolConfig(CONFIG_CHATLOG_ADDON)) + // LANG_ADDON is only valid for the following message types + switch (type) { - std::string msg = ""; - recv_data >> msg; + case CHAT_MSG_PARTY: + case CHAT_MSG_RAID: + case CHAT_MSG_GUILD: + case CHAT_MSG_BATTLEGROUND: + case CHAT_MSG_WHISPER: + if (sWorld->getBoolConfig(CONFIG_CHATLOG_ADDON)) + { + std::string msg = ""; + recvData >> msg; - if (msg.empty()) - return; + if (msg.empty()) + return; - sScriptMgr->OnPlayerChat(sender, uint32(CHAT_MSG_ADDON), lang, msg); - } + sScriptMgr->OnPlayerChat(sender, uint32(CHAT_MSG_ADDON), lang, msg); + } - // Disabled addon channel? - if (!sWorld->getBoolConfig(CONFIG_ADDON_CHANNEL)) - return; + // Disabled addon channel? + if (!sWorld->getBoolConfig(CONFIG_ADDON_CHANNEL)) + return; + break; + default: + sLog->outError(LOG_FILTER_NETWORKIO, "Player %s (GUID: %u) sent a chatmessage with an invalid language/message type combination", + GetPlayer()->GetName().c_str(), GetPlayer()->GetGUIDLow()); + + recvData.rfinish(); + return; + } } // LANG_ADDON should not be changed nor be affected by flood control else @@ -171,7 +164,7 @@ void WorldSession::HandleMessagechatOpcode(WorldPacket & recv_data) { std::string timeStr = secsToTimeString(m_muteTime - time(NULL)); SendNotification(GetTrinityString(LANG_WAIT_BEFORE_SPEAKING), timeStr.c_str()); - recv_data.rfinish(); // Prevent warnings + recvData.rfinish(); // Prevent warnings return; } @@ -181,10 +174,8 @@ void WorldSession::HandleMessagechatOpcode(WorldPacket & recv_data) if (sender->HasAura(1852) && type != CHAT_MSG_WHISPER) { - std::string msg=""; - recv_data >> msg; - - SendNotification(GetTrinityString(LANG_GM_SILENCE), sender->GetName()); + SendNotification(GetTrinityString(LANG_GM_SILENCE), sender->GetName().c_str()); + recvData.rfinish(); return; } @@ -204,19 +195,19 @@ void WorldSession::HandleMessagechatOpcode(WorldPacket & recv_data) case CHAT_MSG_RAID_WARNING: case CHAT_MSG_BATTLEGROUND: case CHAT_MSG_BATTLEGROUND_LEADER: - recv_data >> msg; + recvData >> msg; break; case CHAT_MSG_WHISPER: - recv_data >> to; - recv_data >> msg; + recvData >> to; + recvData >> msg; break; case CHAT_MSG_CHANNEL: - recv_data >> channel; - recv_data >> msg; + recvData >> channel; + recvData >> msg; break; case CHAT_MSG_AFK: case CHAT_MSG_DND: - recv_data >> msg; + recvData >> msg; ignoreChecks = true; break; } @@ -226,14 +217,26 @@ void WorldSession::HandleMessagechatOpcode(WorldPacket & recv_data) if (msg.empty()) return; - if (ChatHandler(this).ParseCommands(msg.c_str()) > 0) + if (ChatHandler(this).ParseCommands(msg.c_str())) return; - if (!processChatmessageFurtherAfterSecurityChecks(msg, lang)) - return; + if (lang != LANG_ADDON) + { + // Strip invisible characters for non-addon messages + if (sWorld->getBoolConfig(CONFIG_CHAT_FAKE_MESSAGE_PREVENTING)) + stripLineInvisibleChars(msg); - if (msg.empty()) - return; + if (sWorld->getIntConfig(CONFIG_CHAT_STRICT_LINK_CHECKING_SEVERITY) && !ChatHandler(this).isValidChatMessage(msg.c_str())) + { + sLog->outError(LOG_FILTER_NETWORKIO, "Player %s (GUID: %u) sent a chatmessage with an invalid link: %s", GetPlayer()->GetName().c_str(), + GetPlayer()->GetGUIDLow(), msg.c_str()); + + if (sWorld->getIntConfig(CONFIG_CHAT_STRICT_LINK_CHECKING_KICK)) + KickPlayer(); + + return; + } + } } switch (type) @@ -269,7 +272,7 @@ void WorldSession::HandleMessagechatOpcode(WorldPacket & recv_data) break; } - Player* receiver = sObjectAccessor->FindPlayerByName(to.c_str()); + Player* receiver = sObjectAccessor->FindPlayerByName(to); bool senderIsPlayer = AccountMgr::IsPlayerAccount(GetSecurity()); bool receiverIsPlayer = AccountMgr::IsPlayerAccount(receiver ? receiver->GetSession()->GetSecurity() : SEC_PLAYER); if (!receiver || (senderIsPlayer && !receiverIsPlayer && !receiver->isAcceptWhispers() && !receiver->IsInWhisperWhiteList(sender->GetGUID()))) @@ -287,7 +290,7 @@ void WorldSession::HandleMessagechatOpcode(WorldPacket & recv_data) if (GetPlayer()->HasAura(1852) && !receiver->isGameMaster()) { - SendNotification(GetTrinityString(LANG_GM_SILENCE), GetPlayer()->GetName()); + SendNotification(GetTrinityString(LANG_GM_SILENCE), GetPlayer()->GetName().c_str()); return; } @@ -426,13 +429,11 @@ void WorldSession::HandleMessagechatOpcode(WorldPacket & recv_data) } } - if (ChannelMgr* cMgr = channelMgr(_player->GetTeam())) + if (ChannelMgr* cMgr = ChannelMgr::forTeam(_player->GetTeam())) { - if (Channel* chn = cMgr->GetChannel(channel, _player)) { sScriptMgr->OnPlayerChat(_player, type, lang, msg, chn); - chn->Say(_player->GetGUID(), msg.c_str(), lang); } } @@ -479,13 +480,13 @@ void WorldSession::HandleMessagechatOpcode(WorldPacket & recv_data) } } -void WorldSession::HandleEmoteOpcode(WorldPacket & recv_data) +void WorldSession::HandleEmoteOpcode(WorldPacket& recvData) { if (!GetPlayer()->isAlive() || GetPlayer()->HasUnitState(UNIT_STATE_DIED)) return; uint32 emote; - recv_data >> emote; + recvData >> emote; sScriptMgr->OnPlayerEmote(GetPlayer(), emote); GetPlayer()->HandleEmoteCommand(emote); } @@ -500,18 +501,18 @@ namespace Trinity void operator()(WorldPacket& data, LocaleConstant loc_idx) { - char const* nam = i_target ? i_target->GetNameForLocaleIdx(loc_idx) : NULL; - uint32 namlen = (nam ? strlen(nam) : 0) + 1; + std::string const name(i_target ? i_target->GetNameForLocaleIdx(loc_idx) : ""); + uint32 namlen = name.size(); - data.Initialize(SMSG_TEXT_EMOTE, (20+namlen)); + data.Initialize(SMSG_TEXT_EMOTE, 20 + namlen); data << i_player.GetGUID(); - data << (uint32)i_text_emote; - data << i_emote_num; - data << (uint32)namlen; + data << uint32(i_text_emote); + data << uint32(i_emote_num); + data << uint32(namlen); if (namlen > 1) - data.append(nam, namlen); + data << name; else - data << (uint8)0x00; + data << uint8(0x00); } private: @@ -522,7 +523,7 @@ namespace Trinity }; } // namespace Trinity -void WorldSession::HandleTextEmoteOpcode(WorldPacket & recv_data) +void WorldSession::HandleTextEmoteOpcode(WorldPacket& recvData) { if (!GetPlayer()->isAlive()) return; @@ -537,9 +538,9 @@ void WorldSession::HandleTextEmoteOpcode(WorldPacket & recv_data) uint32 text_emote, emoteNum; uint64 guid; - recv_data >> text_emote; - recv_data >> emoteNum; - recv_data >> guid; + recvData >> text_emote; + recvData >> emoteNum; + recvData >> guid; sScriptMgr->OnPlayerTextEmote(GetPlayer(), text_emote, emoteNum, guid); @@ -584,21 +585,21 @@ void WorldSession::HandleTextEmoteOpcode(WorldPacket & recv_data) ((Creature*)unit)->AI()->ReceiveEmote(GetPlayer(), text_emote); } -void WorldSession::HandleChatIgnoredOpcode(WorldPacket& recv_data) +void WorldSession::HandleChatIgnoredOpcode(WorldPacket& recvData) { uint64 iguid; uint8 unk; //sLog->outDebug(LOG_FILTER_PACKETIO, "WORLD: Received CMSG_CHAT_IGNORED"); - recv_data >> iguid; - recv_data >> unk; // probably related to spam reporting + recvData >> iguid; + recvData >> unk; // probably related to spam reporting Player* player = ObjectAccessor::FindPlayer(iguid); if (!player || !player->GetSession()) 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()->GetGUID(), GetPlayer()->GetName().c_str(), NULL); player->GetSession()->SendPacket(&data); } @@ -607,14 +608,14 @@ void WorldSession::HandleChannelDeclineInvite(WorldPacket &recvPacket) sLog->outDebug(LOG_FILTER_NETWORKIO, "Opcode %u", recvPacket.GetOpcode()); } -void WorldSession::SendPlayerNotFoundNotice(std::string name) +void WorldSession::SendPlayerNotFoundNotice(std::string const& name) { WorldPacket data(SMSG_CHAT_PLAYER_NOT_FOUND, name.size()+1); data << name; SendPacket(&data); } -void WorldSession::SendPlayerAmbiguousNotice(std::string name) +void WorldSession::SendPlayerAmbiguousNotice(std::string const& name) { WorldPacket data(SMSG_CHAT_PLAYER_AMBIGUOUS, name.size()+1); data << name; diff --git a/src/server/game/Handlers/CombatHandler.cpp b/src/server/game/Handlers/CombatHandler.cpp index 78547d2d0f3..1cd86afc6d2 100755 --- a/src/server/game/Handlers/CombatHandler.cpp +++ b/src/server/game/Handlers/CombatHandler.cpp @@ -26,10 +26,10 @@ #include "Vehicle.h" #include "VehicleDefines.h" -void WorldSession::HandleAttackSwingOpcode(WorldPacket& recv_data) +void WorldSession::HandleAttackSwingOpcode(WorldPacket& recvData) { uint64 guid; - recv_data >> guid; + recvData >> guid; sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Recvd CMSG_ATTACKSWING Message guidlow:%u guidhigh:%u", GUID_LOPART(guid), GUID_HIPART(guid)); @@ -66,15 +66,15 @@ void WorldSession::HandleAttackSwingOpcode(WorldPacket& recv_data) _player->Attack(pEnemy, true); } -void WorldSession::HandleAttackStopOpcode(WorldPacket & /*recv_data*/) +void WorldSession::HandleAttackStopOpcode(WorldPacket & /*recvData*/) { GetPlayer()->AttackStop(); } -void WorldSession::HandleSetSheathedOpcode(WorldPacket& recv_data) +void WorldSession::HandleSetSheathedOpcode(WorldPacket& recvData) { uint32 sheathed; - recv_data >> sheathed; + recvData >> sheathed; //sLog->outDebug(LOG_FILTER_PACKETIO, "WORLD: Recvd CMSG_SETSHEATHED Message guidlow:%u value1:%u", GetPlayer()->GetGUIDLow(), sheathed); diff --git a/src/server/game/Handlers/DuelHandler.cpp b/src/server/game/Handlers/DuelHandler.cpp index 1b3f71c8cf1..bdfb2369198 100755 --- a/src/server/game/Handlers/DuelHandler.cpp +++ b/src/server/game/Handlers/DuelHandler.cpp @@ -42,8 +42,8 @@ void WorldSession::HandleDuelAcceptedOpcode(WorldPacket& recvPacket) return; //sLog->outDebug(LOG_FILTER_PACKETIO, "WORLD: Received CMSG_DUEL_ACCEPTED"); - sLog->outDebug(LOG_FILTER_NETWORKIO, "Player 1 is: %u (%s)", player->GetGUIDLow(), player->GetName()); - sLog->outDebug(LOG_FILTER_NETWORKIO, "Player 2 is: %u (%s)", plTarget->GetGUIDLow(), plTarget->GetName()); + sLog->outDebug(LOG_FILTER_NETWORKIO, "Player 1 is: %u (%s)", player->GetGUIDLow(), player->GetName().c_str()); + sLog->outDebug(LOG_FILTER_NETWORKIO, "Player 2 is: %u (%s)", plTarget->GetGUIDLow(), plTarget->GetName().c_str()); time_t now = time(NULL); player->duel->startTimer = now; diff --git a/src/server/game/Handlers/GroupHandler.cpp b/src/server/game/Handlers/GroupHandler.cpp index 43655750aff..223a5316c7a 100755 --- a/src/server/game/Handlers/GroupHandler.cpp +++ b/src/server/game/Handlers/GroupHandler.cpp @@ -56,13 +56,13 @@ void WorldSession::SendPartyResult(PartyOperation operation, const std::string& SendPacket(&data); } -void WorldSession::HandleGroupInviteOpcode(WorldPacket & recv_data) +void WorldSession::HandleGroupInviteOpcode(WorldPacket & recvData) { sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Received CMSG_GROUP_INVITE"); std::string membername; - recv_data >> membername; - recv_data.read_skip<uint32>(); + recvData >> membername; + recvData.read_skip<uint32>(); // attempt add selected player @@ -73,7 +73,7 @@ void WorldSession::HandleGroupInviteOpcode(WorldPacket & recv_data) return; } - Player* player = sObjectAccessor->FindPlayerByName(membername.c_str()); + Player* player = sObjectAccessor->FindPlayerByName(membername); // no player if (!player) @@ -195,11 +195,11 @@ void WorldSession::HandleGroupInviteOpcode(WorldPacket & recv_data) SendPartyResult(PARTY_OP_INVITE, membername, ERR_PARTY_RESULT_OK); } -void WorldSession::HandleGroupAcceptOpcode(WorldPacket& recv_data) +void WorldSession::HandleGroupAcceptOpcode(WorldPacket& recvData) { sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Received CMSG_GROUP_ACCEPT"); - recv_data.read_skip<uint32>(); + recvData.read_skip<uint32>(); Group* group = GetPlayer()->GetGroupInvite(); if (!group) @@ -210,7 +210,7 @@ void WorldSession::HandleGroupAcceptOpcode(WorldPacket& recv_data) if (group->GetLeaderGUID() == GetPlayer()->GetGUID()) { - sLog->outError(LOG_FILTER_NETWORKIO, "HandleGroupAcceptOpcode: player %s(%d) tried to accept an invite to his own group", GetPlayer()->GetName(), GetPlayer()->GetGUIDLow()); + sLog->outError(LOG_FILTER_NETWORKIO, "HandleGroupAcceptOpcode: player %s(%d) tried to accept an invite to his own group", GetPlayer()->GetName().c_str(), GetPlayer()->GetGUIDLow()); return; } @@ -247,7 +247,7 @@ void WorldSession::HandleGroupAcceptOpcode(WorldPacket& recv_data) group->BroadcastGroupUpdate(); } -void WorldSession::HandleGroupDeclineOpcode(WorldPacket & /*recv_data*/) +void WorldSession::HandleGroupDeclineOpcode(WorldPacket & /*recvData*/) { sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Received CMSG_GROUP_DECLINE"); @@ -265,25 +265,25 @@ void WorldSession::HandleGroupDeclineOpcode(WorldPacket & /*recv_data*/) return; // report - std::string name = std::string(GetPlayer()->GetName()); - WorldPacket data(SMSG_GROUP_DECLINE, name.length()); - data << name.c_str(); + WorldPacket data(SMSG_GROUP_DECLINE, GetPlayer()->GetName().length()); + data << GetPlayer()->GetName(); leader->GetSession()->SendPacket(&data); } -void WorldSession::HandleGroupUninviteGuidOpcode(WorldPacket & recv_data) +void WorldSession::HandleGroupUninviteGuidOpcode(WorldPacket & recvData) { sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Received CMSG_GROUP_UNINVITE_GUID"); uint64 guid; std::string reason; - recv_data >> guid; - recv_data >> reason; + recvData >> guid; + recvData >> reason; //can't uninvite yourself if (guid == GetPlayer()->GetGUID()) { - sLog->outError(LOG_FILTER_NETWORKIO, "WorldSession::HandleGroupUninviteGuidOpcode: leader %s(%d) tried to uninvite himself from the group.", GetPlayer()->GetName(), GetPlayer()->GetGUIDLow()); + sLog->outError(LOG_FILTER_NETWORKIO, "WorldSession::HandleGroupUninviteGuidOpcode: leader %s(%d) tried to uninvite himself from the group.", + GetPlayer()->GetName().c_str(), GetPlayer()->GetGUIDLow()); return; } @@ -319,12 +319,12 @@ void WorldSession::HandleGroupUninviteGuidOpcode(WorldPacket & recv_data) SendPartyResult(PARTY_OP_UNINVITE, "", ERR_TARGET_NOT_IN_GROUP_S); } -void WorldSession::HandleGroupUninviteOpcode(WorldPacket & recv_data) +void WorldSession::HandleGroupUninviteOpcode(WorldPacket & recvData) { sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Received CMSG_GROUP_UNINVITE"); std::string membername; - recv_data >> membername; + recvData >> membername; // player not found if (!normalizePlayerName(membername)) @@ -333,7 +333,8 @@ void WorldSession::HandleGroupUninviteOpcode(WorldPacket & recv_data) // can't uninvite yourself if (GetPlayer()->GetName() == membername) { - sLog->outError(LOG_FILTER_NETWORKIO, "WorldSession::HandleGroupUninviteOpcode: leader %s(%d) tried to uninvite himself from the group.", GetPlayer()->GetName(), GetPlayer()->GetGUIDLow()); + sLog->outError(LOG_FILTER_NETWORKIO, "WorldSession::HandleGroupUninviteOpcode: leader %s(%d) tried to uninvite himself from the group.", + GetPlayer()->GetName().c_str(), GetPlayer()->GetGUIDLow()); return; } @@ -363,12 +364,12 @@ void WorldSession::HandleGroupUninviteOpcode(WorldPacket & recv_data) SendPartyResult(PARTY_OP_UNINVITE, membername, ERR_TARGET_NOT_IN_GROUP_S); } -void WorldSession::HandleGroupSetLeaderOpcode(WorldPacket & recv_data) +void WorldSession::HandleGroupSetLeaderOpcode(WorldPacket & recvData) { sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Received CMSG_GROUP_SET_LEADER"); uint64 guid; - recv_data >> guid; + recvData >> guid; Player* player = ObjectAccessor::FindPlayer(guid); Group* group = GetPlayer()->GetGroup(); @@ -384,7 +385,7 @@ void WorldSession::HandleGroupSetLeaderOpcode(WorldPacket & recv_data) group->SendUpdate(); } -void WorldSession::HandleGroupDisbandOpcode(WorldPacket & /*recv_data*/) +void WorldSession::HandleGroupDisbandOpcode(WorldPacket & /*recvData*/) { sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Received CMSG_GROUP_DISBAND"); @@ -407,14 +408,14 @@ void WorldSession::HandleGroupDisbandOpcode(WorldPacket & /*recv_data*/) GetPlayer()->RemoveFromGroup(GROUP_REMOVEMETHOD_LEAVE); } -void WorldSession::HandleLootMethodOpcode(WorldPacket & recv_data) +void WorldSession::HandleLootMethodOpcode(WorldPacket & recvData) { sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Received CMSG_LOOT_METHOD"); uint32 lootMethod; uint64 lootMaster; uint32 lootThreshold; - recv_data >> lootMethod >> lootMaster >> lootThreshold; + recvData >> lootMethod >> lootMaster >> lootThreshold; Group* group = GetPlayer()->GetGroup(); if (!group) @@ -458,7 +459,7 @@ void WorldSession::HandleLootRoll(WorldPacket& recvData) } } -void WorldSession::HandleMinimapPingOpcode(WorldPacket& recv_data) +void WorldSession::HandleMinimapPingOpcode(WorldPacket& recvData) { sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Received MSG_MINIMAP_PING"); @@ -466,8 +467,8 @@ void WorldSession::HandleMinimapPingOpcode(WorldPacket& recv_data) return; float x, y; - recv_data >> x; - recv_data >> y; + recvData >> x; + recvData >> y; //sLog->outDebug("Received opcode MSG_MINIMAP_PING X: %f, Y: %f", x, y); @@ -482,13 +483,13 @@ void WorldSession::HandleMinimapPingOpcode(WorldPacket& recv_data) GetPlayer()->GetGroup()->BroadcastPacket(&data, true, -1, GetPlayer()->GetGUID()); } -void WorldSession::HandleRandomRollOpcode(WorldPacket& recv_data) +void WorldSession::HandleRandomRollOpcode(WorldPacket& recvData) { sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Received MSG_RANDOM_ROLL"); uint32 minimum, maximum, roll; - recv_data >> minimum; - recv_data >> maximum; + recvData >> minimum; + recvData >> maximum; /** error handling **/ if (minimum > maximum || maximum > 10000) // < 32768 for urand call @@ -511,7 +512,7 @@ void WorldSession::HandleRandomRollOpcode(WorldPacket& recv_data) SendPacket(&data); } -void WorldSession::HandleRaidTargetUpdateOpcode(WorldPacket & recv_data) +void WorldSession::HandleRaidTargetUpdateOpcode(WorldPacket & recvData) { sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Received MSG_RAID_TARGET_UPDATE"); @@ -520,7 +521,7 @@ void WorldSession::HandleRaidTargetUpdateOpcode(WorldPacket & recv_data) return; uint8 x; - recv_data >> x; + recvData >> x; /** error handling **/ /********************/ @@ -536,12 +537,12 @@ void WorldSession::HandleRaidTargetUpdateOpcode(WorldPacket & recv_data) return; uint64 guid; - recv_data >> guid; + recvData >> guid; group->SetTargetIcon(x, _player->GetGUID(), guid); } } -void WorldSession::HandleGroupRaidConvertOpcode(WorldPacket & /*recv_data*/) +void WorldSession::HandleGroupRaidConvertOpcode(WorldPacket & /*recvData*/) { sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Received CMSG_GROUP_RAID_CONVERT"); @@ -562,7 +563,7 @@ void WorldSession::HandleGroupRaidConvertOpcode(WorldPacket & /*recv_data*/) group->ConvertToRaid(); } -void WorldSession::HandleGroupChangeSubGroupOpcode(WorldPacket & recv_data) +void WorldSession::HandleGroupChangeSubGroupOpcode(WorldPacket & recvData) { sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Received CMSG_GROUP_CHANGE_SUB_GROUP"); @@ -573,8 +574,8 @@ void WorldSession::HandleGroupChangeSubGroupOpcode(WorldPacket & recv_data) std::string name; uint8 groupNr; - recv_data >> name; - recv_data >> groupNr; + recvData >> name; + recvData >> groupNr; if (groupNr >= MAX_RAID_SUBGROUPS) return; @@ -586,7 +587,7 @@ void WorldSession::HandleGroupChangeSubGroupOpcode(WorldPacket & recv_data) if (!group->HasFreeSlotSubGroup(groupNr)) return; - Player* movedPlayer = sObjectAccessor->FindPlayerByName(name.c_str()); + Player* movedPlayer = sObjectAccessor->FindPlayerByName(name); uint64 guid; if (movedPlayer) { @@ -601,7 +602,7 @@ void WorldSession::HandleGroupChangeSubGroupOpcode(WorldPacket & recv_data) group->ChangeMembersGroup(guid, groupNr); } -void WorldSession::HandleGroupAssistantLeaderOpcode(WorldPacket & recv_data) +void WorldSession::HandleGroupAssistantLeaderOpcode(WorldPacket & recvData) { sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Received CMSG_GROUP_ASSISTANT_LEADER"); @@ -614,15 +615,15 @@ void WorldSession::HandleGroupAssistantLeaderOpcode(WorldPacket & recv_data) uint64 guid; bool apply; - recv_data >> guid; - recv_data >> apply; + recvData >> guid; + recvData >> apply; group->SetGroupMemberFlag(guid, apply, MEMBER_FLAG_ASSISTANT); group->SendUpdate(); } -void WorldSession::HandlePartyAssignmentOpcode(WorldPacket & recv_data) +void WorldSession::HandlePartyAssignmentOpcode(WorldPacket & recvData) { sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Received MSG_PARTY_ASSIGNMENT"); @@ -637,8 +638,8 @@ void WorldSession::HandlePartyAssignmentOpcode(WorldPacket & recv_data) uint8 assignment; bool apply; uint64 guid; - recv_data >> assignment >> apply; - recv_data >> guid; + recvData >> assignment >> apply; + recvData >> guid; switch (assignment) { @@ -656,7 +657,7 @@ void WorldSession::HandlePartyAssignmentOpcode(WorldPacket & recv_data) group->SendUpdate(); } -void WorldSession::HandleRaidReadyCheckOpcode(WorldPacket & recv_data) +void WorldSession::HandleRaidReadyCheckOpcode(WorldPacket & recvData) { sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Received MSG_RAID_READY_CHECK"); @@ -664,7 +665,7 @@ void WorldSession::HandleRaidReadyCheckOpcode(WorldPacket & recv_data) if (!group) return; - if (recv_data.empty()) // request + if (recvData.empty()) // request { /** error handling **/ if (!group->IsLeader(GetPlayer()->GetGUID()) && !group->IsAssistant(GetPlayer()->GetGUID())) @@ -681,7 +682,7 @@ void WorldSession::HandleRaidReadyCheckOpcode(WorldPacket & recv_data) else // answer { uint8 state; - recv_data >> state; + recvData >> state; // everything's fine, do it WorldPacket data(MSG_RAID_READY_CHECK_CONFIRM, 9); @@ -691,7 +692,7 @@ void WorldSession::HandleRaidReadyCheckOpcode(WorldPacket & recv_data) } } -void WorldSession::HandleRaidReadyCheckFinishedOpcode(WorldPacket & /*recv_data*/) +void WorldSession::HandleRaidReadyCheckFinishedOpcode(WorldPacket & /*recvData*/) { //Group* group = GetPlayer()->GetGroup(); //if (!group) @@ -871,11 +872,11 @@ void WorldSession::BuildPartyMemberStatsChangedPacket(Player* player, WorldPacke } /*this procedure handles clients CMSG_REQUEST_PARTY_MEMBER_STATS request*/ -void WorldSession::HandleRequestPartyMemberStatsOpcode(WorldPacket &recv_data) +void WorldSession::HandleRequestPartyMemberStatsOpcode(WorldPacket &recvData) { sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Received CMSG_REQUEST_PARTY_MEMBER_STATS"); uint64 Guid; - recv_data >> Guid; + recvData >> Guid; Player* player = HashMapHolder<Player>::Find(Guid); if (!player) @@ -961,23 +962,23 @@ void WorldSession::HandleRequestPartyMemberStatsOpcode(WorldPacket &recv_data) SendPacket(&data); } -/*!*/void WorldSession::HandleRequestRaidInfoOpcode(WorldPacket & /*recv_data*/) +/*!*/void WorldSession::HandleRequestRaidInfoOpcode(WorldPacket & /*recvData*/) { // every time the player checks the character screen _player->SendRaidInfo(); } -/*void WorldSession::HandleGroupCancelOpcode(WorldPacket & recv_data) +/*void WorldSession::HandleGroupCancelOpcode(WorldPacket & recvData) { sLog->outDebug("WORLD: got CMSG_GROUP_CANCEL."); }*/ -void WorldSession::HandleOptOutOfLootOpcode(WorldPacket & recv_data) +void WorldSession::HandleOptOutOfLootOpcode(WorldPacket & recvData) { sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Received CMSG_OPT_OUT_OF_LOOT"); uint32 passOnLoot; - recv_data >> passOnLoot; // 1 always pass, 0 do not pass + recvData >> passOnLoot; // 1 always pass, 0 do not pass // ignore if player not loaded if (!GetPlayer()) // needed because STATUS_AUTHED diff --git a/src/server/game/Handlers/GuildHandler.cpp b/src/server/game/Handlers/GuildHandler.cpp index ccd1c931f51..929a31938d2 100755 --- a/src/server/game/Handlers/GuildHandler.cpp +++ b/src/server/game/Handlers/GuildHandler.cpp @@ -28,29 +28,17 @@ #include "GossipDef.h" #include "SocialMgr.h" -// Helper for getting guild object of session's player. -// If guild does not exist, sends error (if necessary). -inline Guild* _GetPlayerGuild(WorldSession* session, bool sendError = false) -{ - if (uint32 guildId = session->GetPlayer()->GetGuildId()) // If guild id = 0, player is not in guild - if (Guild* guild = sGuildMgr->GetGuildById(guildId)) // Find guild by id - return guild; - if (sendError) - Guild::SendCommandResult(session, GUILD_CREATE_S, ERR_GUILD_PLAYER_NOT_IN_GUILD); - return NULL; -} - void WorldSession::HandleGuildQueryOpcode(WorldPacket& recvPacket) { - sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Received CMSG_GUILD_QUERY"); - uint32 guildId; recvPacket >> guildId; - // Use received guild id to access guild method (not player's guild id) + + sLog->outDebug(LOG_FILTER_GUILD, "CMSG_GUILD_QUERY [%s]: Guild: %u", GetPlayerInfo().c_str(), guildId); + if (!guildId) + return; + if (Guild* guild = sGuildMgr->GetGuildById(guildId)) guild->HandleQuery(this); - else - Guild::SendCommandResult(this, GUILD_CREATE_S, ERR_GUILD_PLAYER_NOT_IN_GUILD); } void WorldSession::HandleGuildCreateOpcode(WorldPacket& recvPacket) @@ -72,41 +60,39 @@ void WorldSession::HandleGuildCreateOpcode(WorldPacket& recvPacket) void WorldSession::HandleGuildInviteOpcode(WorldPacket& recvPacket) { - sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Received CMSG_GUILD_INVITE"); - std::string invitedName; recvPacket >> invitedName; + sLog->outDebug(LOG_FILTER_GUILD, "CMSG_GUILD_INVITE [%s]: Invited: %s", GetPlayerInfo().c_str(), invitedName.c_str()); if (normalizePlayerName(invitedName)) - if (Guild* guild = _GetPlayerGuild(this, true)) + if (Guild* guild = GetPlayer()->GetGuild()) guild->HandleInviteMember(this, invitedName); } void WorldSession::HandleGuildRemoveOpcode(WorldPacket& recvPacket) { - sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Received CMSG_GUILD_REMOVE"); - std::string playerName; recvPacket >> playerName; + sLog->outDebug(LOG_FILTER_GUILD, "CMSG_GUILD_REMOVE [%s]: Target: %s", GetPlayerInfo().c_str(), playerName.c_str()); + if (normalizePlayerName(playerName)) - if (Guild* guild = _GetPlayerGuild(this, true)) + if (Guild* guild = GetPlayer()->GetGuild()) guild->HandleRemoveMember(this, playerName); } void WorldSession::HandleGuildAcceptOpcode(WorldPacket& /*recvPacket*/) { - sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Received CMSG_GUILD_ACCEPT"); - // Player cannot be in guild + sLog->outDebug(LOG_FILTER_GUILD, "CMSG_GUILD_ACCEPT [%s]", GetPlayer()->GetName().c_str()); + if (!GetPlayer()->GetGuildId()) - // Guild where player was invited must exist if (Guild* guild = sGuildMgr->GetGuildById(GetPlayer()->GetGuildIdInvited())) guild->HandleAcceptMember(this); } void WorldSession::HandleGuildDeclineOpcode(WorldPacket& /*recvPacket*/) { - sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Received CMSG_GUILD_DECLINE"); + sLog->outDebug(LOG_FILTER_GUILD, "CMSG_GUILD_DECLINE [%s]", GetPlayerInfo().c_str()); GetPlayer()->SetGuildIdInvited(0); GetPlayer()->SetInGuild(0); @@ -114,125 +100,115 @@ void WorldSession::HandleGuildDeclineOpcode(WorldPacket& /*recvPacket*/) void WorldSession::HandleGuildInfoOpcode(WorldPacket& /*recvPacket*/) { - sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Received CMSG_GUILD_INFO"); + sLog->outDebug(LOG_FILTER_GUILD, "CMSG_GUILD_INFO [%s]", GetPlayerInfo().c_str()); - if (Guild* guild = _GetPlayerGuild(this, true)) + if (Guild* guild = GetPlayer()->GetGuild()) guild->SendInfo(this); } void WorldSession::HandleGuildRosterOpcode(WorldPacket& /*recvPacket*/) { - sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Received CMSG_GUILD_ROSTER"); + sLog->outDebug(LOG_FILTER_GUILD, "CMSG_GUILD_ROSTER [%s]", GetPlayerInfo().c_str()); - if (Guild* guild = _GetPlayerGuild(this)) + if (Guild* guild = GetPlayer()->GetGuild()) guild->HandleRoster(this); + else + Guild::SendCommandResult(this, GUILD_COMMAND_ROSTER, ERR_GUILD_PLAYER_NOT_IN_GUILD); } void WorldSession::HandleGuildPromoteOpcode(WorldPacket& recvPacket) { - sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Received CMSG_GUILD_PROMOTE"); - std::string playerName; recvPacket >> playerName; + sLog->outDebug(LOG_FILTER_GUILD, "CMSG_GUILD_PROMOTE [%s]: Target: %s", GetPlayerInfo().c_str(), playerName.c_str()); + if (normalizePlayerName(playerName)) - if (Guild* guild = _GetPlayerGuild(this, true)) + if (Guild* guild = GetPlayer()->GetGuild()) guild->HandleUpdateMemberRank(this, playerName, false); } void WorldSession::HandleGuildDemoteOpcode(WorldPacket& recvPacket) { - sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Received CMSG_GUILD_DEMOTE"); - std::string playerName; recvPacket >> playerName; + sLog->outDebug(LOG_FILTER_GUILD, "CMSG_GUILD_DEMOTE [%s]: Target: %s", GetPlayerInfo().c_str(), playerName.c_str()); + if (normalizePlayerName(playerName)) - if (Guild* guild = _GetPlayerGuild(this, true)) + if (Guild* guild = GetPlayer()->GetGuild()) guild->HandleUpdateMemberRank(this, playerName, true); } void WorldSession::HandleGuildLeaveOpcode(WorldPacket& /*recvPacket*/) { - sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Received CMSG_GUILD_LEAVE"); + sLog->outDebug(LOG_FILTER_GUILD, "CMSG_GUILD_LEAVE [%s]", GetPlayerInfo().c_str()); - if (Guild* guild = _GetPlayerGuild(this, true)) + if (Guild* guild = GetPlayer()->GetGuild()) guild->HandleLeaveMember(this); } void WorldSession::HandleGuildDisbandOpcode(WorldPacket& /*recvPacket*/) { - sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Received CMSG_GUILD_DISBAND"); + sLog->outDebug(LOG_FILTER_GUILD, "CMSG_GUILD_DISBAND [%s]", GetPlayerInfo().c_str()); - if (Guild* guild = _GetPlayerGuild(this, true)) + if (Guild* guild = GetPlayer()->GetGuild()) guild->HandleDisband(this); } void WorldSession::HandleGuildLeaderOpcode(WorldPacket& recvPacket) { - sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Received CMSG_GUILD_LEADER"); - std::string name; recvPacket >> name; + sLog->outDebug(LOG_FILTER_GUILD, "CMSG_GUILD_LEADER [%s]: Target: %s", GetPlayerInfo().c_str(), name.c_str()); + if (normalizePlayerName(name)) - if (Guild* guild = _GetPlayerGuild(this, true)) + if (Guild* guild = GetPlayer()->GetGuild()) guild->HandleSetLeader(this, name); } void WorldSession::HandleGuildMOTDOpcode(WorldPacket& recvPacket) { - sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Received CMSG_GUILD_MOTD"); + std::string motd; + recvPacket >> motd; - std::string motd; // Empty by default - if (!recvPacket.empty()) - recvPacket >> motd; + sLog->outDebug(LOG_FILTER_GUILD, "CMSG_GUILD_MOTD [%s]: MOTD: %s", GetPlayerInfo().c_str(), motd.c_str()); - if (Guild* guild = _GetPlayerGuild(this, true)) + if (Guild* guild = GetPlayer()->GetGuild()) guild->HandleSetMOTD(this, motd); } void WorldSession::HandleGuildSetPublicNoteOpcode(WorldPacket& recvPacket) { - sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Received CMSG_GUILD_SET_PUBLIC_NOTE"); - std::string playerName; - recvPacket >> playerName; + std::string note; + recvPacket >> playerName >> note; - std::string publicNote; - recvPacket >> publicNote; + sLog->outDebug(LOG_FILTER_GUILD, "CMSG_GUILD_SET_PUBLIC_NOTE [%s]: Target: %s, Note: %s", + GetPlayerInfo().c_str(), playerName.c_str(), note.c_str()); if (normalizePlayerName(playerName)) - if (Guild* guild = _GetPlayerGuild(this, true)) - guild->HandleSetMemberNote(this, playerName, publicNote, false); + if (Guild* guild = GetPlayer()->GetGuild()) + guild->HandleSetMemberNote(this, playerName, note, true); } void WorldSession::HandleGuildSetOfficerNoteOpcode(WorldPacket& recvPacket) { - sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Received CMSG_GUILD_SET_OFFICER_NOTE"); - std::string playerName; - recvPacket >> playerName; + std::string note; + recvPacket >> playerName >> note; - std::string officerNote; - recvPacket >> officerNote; + sLog->outDebug(LOG_FILTER_GUILD, "CMSG_GUILD_SET_OFFICER_NOTE [%s]: Target: %s, Note: %s", + GetPlayerInfo().c_str(), playerName.c_str(), note.c_str()); if (normalizePlayerName(playerName)) - if (Guild* guild = _GetPlayerGuild(this, true)) - guild->HandleSetMemberNote(this, playerName, officerNote, true); + if (Guild* guild = GetPlayer()->GetGuild()) + guild->HandleSetMemberNote(this, playerName, note, false); } void WorldSession::HandleGuildRankOpcode(WorldPacket& recvPacket) { - sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Received CMSG_GUILD_RANK"); - - Guild* guild = _GetPlayerGuild(this, true); - if (!guild) - { - recvPacket.rpos(recvPacket.wpos()); - return; - } - uint32 rankId; recvPacket >> rankId; @@ -245,7 +221,17 @@ void WorldSession::HandleGuildRankOpcode(WorldPacket& recvPacket) uint32 money; recvPacket >> money; + sLog->outDebug(LOG_FILTER_GUILD, "CMSG_GUILD_RANK [%s]: Rank: %s (%u)", GetPlayerInfo().c_str(), rankName.c_str(), rankId); + + Guild* guild = GetPlayer()->GetGuild(); + if (!guild) + { + recvPacket.rpos(recvPacket.wpos()); + return; + } + GuildBankRightsAndSlotsVec rightsAndSlots(GUILD_BANK_MAX_TABS); + for (uint8 tabId = 0; tabId < GUILD_BANK_MAX_TABS; ++tabId) { uint32 bankRights; @@ -254,7 +240,7 @@ void WorldSession::HandleGuildRankOpcode(WorldPacket& recvPacket) recvPacket >> bankRights; recvPacket >> slots; - rightsAndSlots[tabId] = GuildBankRightsAndSlots(uint8(bankRights), slots); + rightsAndSlots[tabId] = GuildBankRightsAndSlots(tabId, bankRights, slots); } guild->HandleSetRankInfo(this, rankId, rankName, rights, money, rightsAndSlots); @@ -262,181 +248,175 @@ void WorldSession::HandleGuildRankOpcode(WorldPacket& recvPacket) void WorldSession::HandleGuildAddRankOpcode(WorldPacket& recvPacket) { - sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Received CMSG_GUILD_ADD_RANK"); - std::string rankName; recvPacket >> rankName; - if (Guild* guild = _GetPlayerGuild(this, true)) + sLog->outDebug(LOG_FILTER_GUILD, "CMSG_GUILD_ADD_RANK [%s]: Rank: %s", GetPlayerInfo().c_str(), rankName.c_str()); + + if (Guild* guild = GetPlayer()->GetGuild()) guild->HandleAddNewRank(this, rankName); } void WorldSession::HandleGuildDelRankOpcode(WorldPacket& /*recvPacket*/) { - sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Received CMSG_GUILD_DEL_RANK"); + sLog->outDebug(LOG_FILTER_GUILD, "CMSG_GUILD_DEL_RANK [%s]", GetPlayerInfo().c_str()); - if (Guild* guild = _GetPlayerGuild(this, true)) + if (Guild* guild = GetPlayer()->GetGuild()) guild->HandleRemoveLowestRank(this); } void WorldSession::HandleGuildChangeInfoTextOpcode(WorldPacket& recvPacket) { - sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Received CMSG_GUILD_INFO_TEXT"); - std::string info; recvPacket >> info; - if (Guild* guild = _GetPlayerGuild(this, true)) + sLog->outDebug(LOG_FILTER_GUILD, "CMSG_GUILD_INFO_TEXT [%s]: %s", GetPlayerInfo().c_str(), info.c_str()); + + if (Guild* guild = GetPlayer()->GetGuild()) guild->HandleSetInfo(this, info); } void WorldSession::HandleSaveGuildEmblemOpcode(WorldPacket& recvPacket) { - sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Received MSG_SAVE_GUILD_EMBLEM"); - uint64 vendorGuid; recvPacket >> vendorGuid; EmblemInfo emblemInfo; emblemInfo.ReadPacket(recvPacket); + sLog->outDebug(LOG_FILTER_GUILD, "MSG_SAVE_GUILD_EMBLEM [%s]: Guid: [" UI64FMTD + "] Style: %d, Color: %d, BorderStyle: %d, BorderColor: %d, BackgroundColor: %d" + , GetPlayerInfo().c_str(), vendorGuid, emblemInfo.GetStyle() + , emblemInfo.GetColor(), emblemInfo.GetBorderStyle() + , emblemInfo.GetBorderColor(), emblemInfo.GetBackgroundColor()); + if (GetPlayer()->GetNPCIfCanInteractWith(vendorGuid, UNIT_NPC_FLAG_TABARDDESIGNER)) { // Remove fake death if (GetPlayer()->HasUnitState(UNIT_STATE_DIED)) GetPlayer()->RemoveAurasByType(SPELL_AURA_FEIGN_DEATH); - if (Guild* guild = _GetPlayerGuild(this)) + if (Guild* guild = GetPlayer()->GetGuild()) guild->HandleSetEmblem(this, emblemInfo); else - // "You are not part of a guild!"; - Guild::SendSaveEmblemResult(this, ERR_GUILDEMBLEM_NOGUILD); + Guild::SendSaveEmblemResult(this, ERR_GUILDEMBLEM_NOGUILD); // "You are not part of a guild!"; } else - { - // "That's not an emblem vendor!" - Guild::SendSaveEmblemResult(this, ERR_GUILDEMBLEM_INVALIDVENDOR); - sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: HandleSaveGuildEmblemOpcode - Unit (GUID: %u) not found or you can't interact with him.", GUID_LOPART(vendorGuid)); - } + Guild::SendSaveEmblemResult(this, ERR_GUILDEMBLEM_INVALIDVENDOR); // "That's not an emblem vendor!" } void WorldSession::HandleGuildEventLogQueryOpcode(WorldPacket& /* recvPacket */) { - sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Received (MSG_GUILD_EVENT_LOG_QUERY)"); + sLog->outDebug(LOG_FILTER_GUILD, "MSG_GUILD_EVENT_LOG_QUERY [%s]", GetPlayerInfo().c_str()); - if (Guild* guild = _GetPlayerGuild(this)) + if (Guild* guild = GetPlayer()->GetGuild()) guild->SendEventLog(this); } -void WorldSession::HandleGuildBankMoneyWithdrawn(WorldPacket & /* recv_data */) +void WorldSession::HandleGuildBankMoneyWithdrawn(WorldPacket & /* recvData */) { - sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Received (MSG_GUILD_BANK_MONEY_WITHDRAWN)"); + sLog->outDebug(LOG_FILTER_GUILD, "MSG_GUILD_BANK_MONEY_WITHDRAWN [%s]", GetPlayerInfo().c_str()); - if (Guild* guild = _GetPlayerGuild(this)) + if (Guild* guild = GetPlayer()->GetGuild()) guild->SendMoneyInfo(this); } -void WorldSession::HandleGuildPermissions(WorldPacket& /* recv_data */) +void WorldSession::HandleGuildPermissions(WorldPacket& /* recvData */) { - sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Received (MSG_GUILD_PERMISSIONS)"); + sLog->outDebug(LOG_FILTER_GUILD, "MSG_GUILD_PERMISSIONS [%s]", GetPlayerInfo().c_str()); - if (Guild* guild = _GetPlayerGuild(this)) + if (Guild* guild = GetPlayer()->GetGuild()) guild->SendPermissions(this); } // Called when clicking on Guild bank gameobject -void WorldSession::HandleGuildBankerActivate(WorldPacket & recv_data) +void WorldSession::HandleGuildBankerActivate(WorldPacket& recvData) { - sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Received (CMSG_GUILD_BANKER_ACTIVATE)"); - - uint64 GoGuid; - recv_data >> GoGuid; + uint64 guid; + bool sendAllSlots; + recvData >> guid >> sendAllSlots; - uint8 fullSlotList; - recv_data >> fullSlotList; // 0 = only slots updated in last operation are shown. 1 = all slots updated + sLog->outDebug(LOG_FILTER_GUILD, "CMSG_GUILD_BANKER_ACTIVATE [%s]: Go: [" UI64FMTD "] AllSlots: %u" + , GetPlayerInfo().c_str(), guid, sendAllSlots); - if (GetPlayer()->GetGameObjectIfCanInteractWith(GoGuid, GAMEOBJECT_TYPE_GUILD_BANK)) + Guild * const guild = GetPlayer()->GetGuild(); + if (!guild) { - if (Guild* guild = _GetPlayerGuild(this)) - guild->SendBankTabsInfo(this); - else - Guild::SendCommandResult(this, GUILD_UNK1, ERR_GUILD_PLAYER_NOT_IN_GUILD); + Guild::SendCommandResult(this, GUILD_COMMAND_VIEW_TAB, ERR_GUILD_PLAYER_NOT_IN_GUILD); + return; } + + guild->SendBankTabsInfo(this, sendAllSlots); } // Called when opening guild bank tab only (first one) -void WorldSession::HandleGuildBankQueryTab(WorldPacket & recv_data) +void WorldSession::HandleGuildBankQueryTab(WorldPacket& recvData) { - sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Received (CMSG_GUILD_BANK_QUERY_TAB)"); - - uint64 GoGuid; - recv_data >> GoGuid; - + uint64 guid; uint8 tabId; - recv_data >> tabId; + bool full; - uint8 fullSlotList; - recv_data >> fullSlotList; // 0 = only slots updated in last operation are shown. 1 = all slots updated + recvData >> guid >> tabId >> full; - if (GetPlayer()->GetGameObjectIfCanInteractWith(GoGuid, GAMEOBJECT_TYPE_GUILD_BANK)) - if (Guild* guild = _GetPlayerGuild(this)) + sLog->outDebug(LOG_FILTER_GUILD, "CMSG_GUILD_BANK_QUERY_TAB [%s]: Go: [" UI64FMTD "], TabId: %u, ShowTabs: %u" + , GetPlayerInfo().c_str(), guid, tabId, full); + + if (GetPlayer()->GetGameObjectIfCanInteractWith(guid, GAMEOBJECT_TYPE_GUILD_BANK)) + if (Guild* guild = GetPlayer()->GetGuild()) guild->SendBankTabData(this, tabId); } -void WorldSession::HandleGuildBankDepositMoney(WorldPacket & recv_data) +void WorldSession::HandleGuildBankDepositMoney(WorldPacket& recvData) { - sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Received (CMSG_GUILD_BANK_DEPOSIT_MONEY)"); - - uint64 GoGuid; - recv_data >> GoGuid; - + uint64 guid; uint32 money; - recv_data >> money; + recvData >> guid >> money; + + sLog->outDebug(LOG_FILTER_GUILD, "CMSG_GUILD_BANK_DEPOSIT_MONEY [%s]: Go: [" UI64FMTD "], money: %u", + GetPlayerInfo().c_str(), guid, money); - if (GetPlayer()->GetGameObjectIfCanInteractWith(GoGuid, GAMEOBJECT_TYPE_GUILD_BANK)) + if (GetPlayer()->GetGameObjectIfCanInteractWith(guid, GAMEOBJECT_TYPE_GUILD_BANK)) if (money && GetPlayer()->HasEnoughMoney(money)) - if (Guild* guild = _GetPlayerGuild(this)) + if (Guild* guild = GetPlayer()->GetGuild()) guild->HandleMemberDepositMoney(this, money); } -void WorldSession::HandleGuildBankWithdrawMoney(WorldPacket & recv_data) +void WorldSession::HandleGuildBankWithdrawMoney(WorldPacket& recvData) { - sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Received (CMSG_GUILD_BANK_WITHDRAW_MONEY)"); - - uint64 GoGuid; - recv_data >> GoGuid; - + uint64 guid; uint32 money; - recv_data >> money; + recvData >> guid >> money; - if (money) - if (GetPlayer()->GetGameObjectIfCanInteractWith(GoGuid, GAMEOBJECT_TYPE_GUILD_BANK)) - if (Guild* guild = _GetPlayerGuild(this)) - guild->HandleMemberWithdrawMoney(this, money); + sLog->outDebug(LOG_FILTER_GUILD, "CMSG_GUILD_BANK_WITHDRAW_MONEY [%s]: Go: [" UI64FMTD "], money: %u", + GetPlayerInfo().c_str(), guid, money); + + if (money && GetPlayer()->GetGameObjectIfCanInteractWith(guid, GAMEOBJECT_TYPE_GUILD_BANK)) + if (Guild* guild = GetPlayer()->GetGuild()) + guild->HandleMemberWithdrawMoney(this, money); } -void WorldSession::HandleGuildBankSwapItems(WorldPacket & recv_data) +void WorldSession::HandleGuildBankSwapItems(WorldPacket& recvData) { - sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Received (CMSG_GUILD_BANK_SWAP_ITEMS)"); + sLog->outDebug(LOG_FILTER_GUILD, "CMSG_GUILD_BANK_SWAP_ITEMS [%s]", GetPlayerInfo().c_str()); uint64 GoGuid; - recv_data >> GoGuid; + recvData >> GoGuid; if (!GetPlayer()->GetGameObjectIfCanInteractWith(GoGuid, GAMEOBJECT_TYPE_GUILD_BANK)) { - recv_data.rfinish(); // Prevent additional spam at rejected packet + recvData.rfinish(); // Prevent additional spam at rejected packet return; } - Guild* guild = _GetPlayerGuild(this); + Guild* guild = GetPlayer()->GetGuild(); if (!guild) { - recv_data.rfinish(); // Prevent additional spam at rejected packet + recvData.rfinish(); // Prevent additional spam at rejected packet return; } uint8 bankToBank; - recv_data >> bankToBank; + recvData >> bankToBank; uint8 tabId; uint8 slotId; @@ -446,18 +426,18 @@ void WorldSession::HandleGuildBankSwapItems(WorldPacket & recv_data) if (bankToBank) { uint8 destTabId; - recv_data >> destTabId; + recvData >> destTabId; uint8 destSlotId; - recv_data >> destSlotId; - recv_data.read_skip<uint32>(); // Always 0 + recvData >> destSlotId; + recvData.read_skip<uint32>(); // Always 0 - recv_data >> tabId; - recv_data >> slotId; - recv_data >> itemEntry; - recv_data.read_skip<uint8>(); // Always 0 + recvData >> tabId; + recvData >> slotId; + recvData >> itemEntry; + recvData.read_skip<uint8>(); // Always 0 - recv_data >> splitedAmount; + recvData >> splitedAmount; guild->SwapItems(GetPlayer(), tabId, slotId, destTabId, destSlotId, splitedAmount); } @@ -467,24 +447,24 @@ void WorldSession::HandleGuildBankSwapItems(WorldPacket & recv_data) uint8 playerSlotId = NULL_SLOT; uint8 toChar = 1; - recv_data >> tabId; - recv_data >> slotId; - recv_data >> itemEntry; + recvData >> tabId; + recvData >> slotId; + recvData >> itemEntry; uint8 autoStore; - recv_data >> autoStore; + recvData >> autoStore; if (autoStore) { - recv_data.read_skip<uint32>(); // autoStoreCount - recv_data.read_skip<uint8>(); // ToChar (?), always and expected to be 1 (autostore only triggered in Bank -> Char) - recv_data.read_skip<uint32>(); // Always 0 + recvData.read_skip<uint32>(); // autoStoreCount + recvData.read_skip<uint8>(); // ToChar (?), always and expected to be 1 (autostore only triggered in Bank -> Char) + recvData.read_skip<uint32>(); // Always 0 } else { - recv_data >> playerBag; - recv_data >> playerSlotId; - recv_data >> toChar; - recv_data >> splitedAmount; + recvData >> playerBag; + recvData >> playerSlotId; + recvData >> toChar; + recvData >> splitedAmount; } // Player <-> Bank @@ -496,75 +476,68 @@ void WorldSession::HandleGuildBankSwapItems(WorldPacket & recv_data) } } -void WorldSession::HandleGuildBankBuyTab(WorldPacket & recv_data) +void WorldSession::HandleGuildBankBuyTab(WorldPacket& recvData) { - sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Received (CMSG_GUILD_BANK_BUY_TAB)"); + uint64 guid; + uint8 tabId; - uint64 GoGuid; - recv_data >> GoGuid; + recvData >> guid >> tabId; + + sLog->outDebug(LOG_FILTER_GUILD, "CMSG_GUILD_BANK_BUY_TAB [%s]: Go: [" UI64FMTD "], TabId: %u", GetPlayerInfo().c_str(), guid, tabId); - uint8 tabId; - recv_data >> tabId; - if (GetPlayer()->GetGameObjectIfCanInteractWith(GoGuid, GAMEOBJECT_TYPE_GUILD_BANK)) - if (Guild* guild = _GetPlayerGuild(this)) + if (GetPlayer()->GetGameObjectIfCanInteractWith(guid, GAMEOBJECT_TYPE_GUILD_BANK)) + if (Guild* guild = GetPlayer()->GetGuild()) guild->HandleBuyBankTab(this, tabId); } -void WorldSession::HandleGuildBankUpdateTab(WorldPacket & recv_data) +void WorldSession::HandleGuildBankUpdateTab(WorldPacket& recvData) { - sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Received (CMSG_GUILD_BANK_UPDATE_TAB)"); - - uint64 GoGuid; - recv_data >> GoGuid; - + uint64 guid; uint8 tabId; - recv_data >> tabId; + std::string name, icon; - std::string name; - recv_data >> name; + recvData >> guid >> tabId >> name >> icon; - std::string icon; - recv_data >> icon; + sLog->outDebug(LOG_FILTER_GUILD, "CMSG_GUILD_BANK_UPDATE_TAB [%s]: Go: [" UI64FMTD "], TabId: %u, Name: %s, Icon: %s" + , GetPlayerInfo().c_str(), guid, tabId, name.c_str(), icon.c_str()); if (!name.empty() && !icon.empty()) - if (GetPlayer()->GetGameObjectIfCanInteractWith(GoGuid, GAMEOBJECT_TYPE_GUILD_BANK)) - if (Guild* guild = _GetPlayerGuild(this)) + if (GetPlayer()->GetGameObjectIfCanInteractWith(guid, GAMEOBJECT_TYPE_GUILD_BANK)) + if (Guild* guild = GetPlayer()->GetGuild()) guild->HandleSetBankTabInfo(this, tabId, name, icon); } -void WorldSession::HandleGuildBankLogQuery(WorldPacket & recv_data) +void WorldSession::HandleGuildBankLogQuery(WorldPacket& recvData) { - sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Received (MSG_GUILD_BANK_LOG_QUERY)"); - uint8 tabId; - recv_data >> tabId; + recvData >> tabId; - if (Guild* guild = _GetPlayerGuild(this)) + sLog->outDebug(LOG_FILTER_GUILD, "MSG_GUILD_BANK_LOG_QUERY [%s]: TabId: %u", GetPlayerInfo().c_str(), tabId); + + if (Guild* guild = GetPlayer()->GetGuild()) guild->SendBankLog(this, tabId); } -void WorldSession::HandleQueryGuildBankTabText(WorldPacket &recv_data) +void WorldSession::HandleQueryGuildBankTabText(WorldPacket &recvData) { - sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Received MSG_QUERY_GUILD_BANK_TEXT"); - uint8 tabId; - recv_data >> tabId; + recvData >> tabId; - if (Guild* guild = _GetPlayerGuild(this)) + sLog->outDebug(LOG_FILTER_GUILD, "MSG_QUERY_GUILD_BANK_TEXT [%s]: TabId: %u", GetPlayerInfo().c_str(), tabId); + + if (Guild* guild = GetPlayer()->GetGuild()) guild->SendBankTabText(this, tabId); } -void WorldSession::HandleSetGuildBankTabText(WorldPacket &recv_data) +void WorldSession::HandleSetGuildBankTabText(WorldPacket &recvData) { - sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Received CMSG_SET_GUILD_BANK_TEXT"); - uint8 tabId; - recv_data >> tabId; - std::string text; - recv_data >> text; + recvData >> tabId >> text; + + sLog->outDebug(LOG_FILTER_GUILD, "CMSG_SET_GUILD_BANK_TEXT [%s]: TabId: %u, Text: %s", GetPlayerInfo().c_str(), tabId, text.c_str()); - if (Guild* guild = _GetPlayerGuild(this)) + if (Guild* guild = GetPlayer()->GetGuild()) guild->SetBankTabText(tabId, text); } diff --git a/src/server/game/Handlers/ItemHandler.cpp b/src/server/game/Handlers/ItemHandler.cpp index 614e0064132..6dc7dc427d3 100755 --- a/src/server/game/Handlers/ItemHandler.cpp +++ b/src/server/game/Handlers/ItemHandler.cpp @@ -28,13 +28,13 @@ #include "ObjectAccessor.h" #include "SpellInfo.h" -void WorldSession::HandleSplitItemOpcode(WorldPacket & recv_data) +void WorldSession::HandleSplitItemOpcode(WorldPacket & recvData) { //sLog->outDebug(LOG_FILTER_PACKETIO, "WORLD: CMSG_SPLIT_ITEM"); uint8 srcbag, srcslot, dstbag, dstslot; uint32 count; - recv_data >> srcbag >> srcslot >> dstbag >> dstslot >> count; + recvData >> srcbag >> srcslot >> dstbag >> dstslot >> count; //sLog->outDebug("STORAGE: receive srcbag = %u, srcslot = %u, dstbag = %u, dstslot = %u, count = %u", srcbag, srcslot, dstbag, dstslot, count); uint16 src = ((srcbag << 8) | srcslot); @@ -61,12 +61,12 @@ void WorldSession::HandleSplitItemOpcode(WorldPacket & recv_data) _player->SplitItem(src, dst, count); } -void WorldSession::HandleSwapInvItemOpcode(WorldPacket & recv_data) +void WorldSession::HandleSwapInvItemOpcode(WorldPacket & recvData) { //sLog->outDebug(LOG_FILTER_PACKETIO, "WORLD: CMSG_SWAP_INV_ITEM"); uint8 srcslot, dstslot; - recv_data >> dstslot >> srcslot; + recvData >> dstslot >> srcslot; //sLog->outDebug("STORAGE: receive srcslot = %u, dstslot = %u", srcslot, dstslot); // prevent attempt swap same item to current position generated by client at special checting sequence @@ -91,11 +91,11 @@ void WorldSession::HandleSwapInvItemOpcode(WorldPacket & recv_data) _player->SwapItem(src, dst); } -void WorldSession::HandleAutoEquipItemSlotOpcode(WorldPacket & recv_data) +void WorldSession::HandleAutoEquipItemSlotOpcode(WorldPacket & recvData) { uint64 itemguid; uint8 dstslot; - recv_data >> itemguid >> dstslot; + recvData >> itemguid >> dstslot; // cheating attempt, client should never send opcode in that case if (!Player::IsEquipmentPos(INVENTORY_SLOT_BAG_0, dstslot)) @@ -110,12 +110,12 @@ void WorldSession::HandleAutoEquipItemSlotOpcode(WorldPacket & recv_data) _player->SwapItem(item->GetPos(), dstpos); } -void WorldSession::HandleSwapItem(WorldPacket & recv_data) +void WorldSession::HandleSwapItem(WorldPacket & recvData) { //sLog->outDebug(LOG_FILTER_PACKETIO, "WORLD: CMSG_SWAP_ITEM"); uint8 dstbag, dstslot, srcbag, srcslot; - recv_data >> dstbag >> dstslot >> srcbag >> srcslot; + recvData >> dstbag >> dstslot >> srcbag >> srcslot; //sLog->outDebug("STORAGE: receive srcbag = %u, srcslot = %u, dstbag = %u, dstslot = %u", srcbag, srcslot, dstbag, dstslot); uint16 src = ((srcbag << 8) | srcslot); @@ -140,12 +140,12 @@ void WorldSession::HandleSwapItem(WorldPacket & recv_data) _player->SwapItem(src, dst); } -void WorldSession::HandleAutoEquipItemOpcode(WorldPacket & recv_data) +void WorldSession::HandleAutoEquipItemOpcode(WorldPacket & recvData) { //sLog->outDebug(LOG_FILTER_PACKETIO, "WORLD: CMSG_AUTOEQUIP_ITEM"); uint8 srcbag, srcslot; - recv_data >> srcbag >> srcslot; + recvData >> srcbag >> srcslot; //sLog->outDebug("STORAGE: receive srcbag = %u, srcslot = %u", srcbag, srcslot); Item* pSrcItem = _player->GetItemByPos(srcbag, srcslot); @@ -234,12 +234,12 @@ void WorldSession::HandleAutoEquipItemOpcode(WorldPacket & recv_data) } } -void WorldSession::HandleDestroyItemOpcode(WorldPacket & recv_data) +void WorldSession::HandleDestroyItemOpcode(WorldPacket & recvData) { //sLog->outDebug(LOG_FILTER_PACKETIO, "WORLD: CMSG_DESTROYITEM"); uint8 bag, slot, count, data1, data2, data3; - recv_data >> bag >> slot >> count >> data1 >> data2 >> data3; + recvData >> bag >> slot >> count >> data1 >> data2 >> data3; //sLog->outDebug("STORAGE: receive bag = %u, slot = %u, count = %u", bag, slot, count); uint16 pos = (bag << 8) | slot; @@ -278,11 +278,11 @@ void WorldSession::HandleDestroyItemOpcode(WorldPacket & recv_data) } // Only _static_ data send in this packet !!! -void WorldSession::HandleItemQuerySingleOpcode(WorldPacket & recv_data) +void WorldSession::HandleItemQuerySingleOpcode(WorldPacket & recvData) { //sLog->outDebug(LOG_FILTER_PACKETIO, "WORLD: CMSG_ITEM_QUERY_SINGLE"); uint32 item; - recv_data >> item; + recvData >> item; sLog->outInfo(LOG_FILTER_NETWORKIO, "STORAGE: Item Query = %u", item); @@ -437,12 +437,12 @@ void WorldSession::HandleItemQuerySingleOpcode(WorldPacket & recv_data) } } -void WorldSession::HandleReadItem(WorldPacket & recv_data) +void WorldSession::HandleReadItem(WorldPacket & recvData) { //sLog->outDebug(LOG_FILTER_PACKETIO, "WORLD: CMSG_READ_ITEM"); uint8 bag, slot; - recv_data >> bag >> slot; + recvData >> bag >> slot; //sLog->outInfo(LOG_FILTER_NETWORKIO, "STORAGE: Read bag = %u, slot = %u", bag, slot); Item* pItem = _player->GetItemByPos(bag, slot); @@ -470,26 +470,26 @@ void WorldSession::HandleReadItem(WorldPacket & recv_data) _player->SendEquipError(EQUIP_ERR_ITEM_NOT_FOUND, NULL, NULL); } -void WorldSession::HandlePageQuerySkippedOpcode(WorldPacket & recv_data) +void WorldSession::HandlePageQuerySkippedOpcode(WorldPacket & recvData) { sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Received CMSG_PAGE_TEXT_QUERY"); uint32 itemid; uint64 guid; - recv_data >> itemid >> guid; + recvData >> itemid >> guid; sLog->outInfo(LOG_FILTER_NETWORKIO, "Packet Info: itemid: %u guidlow: %u guidentry: %u guidhigh: %u", itemid, GUID_LOPART(guid), GUID_ENPART(guid), GUID_HIPART(guid)); } -void WorldSession::HandleSellItemOpcode(WorldPacket & recv_data) +void WorldSession::HandleSellItemOpcode(WorldPacket & recvData) { sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Received CMSG_SELL_ITEM"); uint64 vendorguid, itemguid; uint32 count; - recv_data >> vendorguid >> itemguid >> count; + recvData >> vendorguid >> itemguid >> count; if (!itemguid) return; @@ -597,13 +597,13 @@ void WorldSession::HandleSellItemOpcode(WorldPacket & recv_data) return; } -void WorldSession::HandleBuybackItem(WorldPacket & recv_data) +void WorldSession::HandleBuybackItem(WorldPacket & recvData) { sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Received CMSG_BUYBACK_ITEM"); uint64 vendorguid; uint32 slot; - recv_data >> vendorguid >> slot; + recvData >> vendorguid >> slot; Creature* creature = GetPlayer()->GetNPCIfCanInteractWith(vendorguid, UNIT_NPC_FLAG_VENDOR); if (!creature) @@ -645,14 +645,14 @@ void WorldSession::HandleBuybackItem(WorldPacket & recv_data) _player->SendBuyError(BUY_ERR_CANT_FIND_ITEM, creature, 0, 0); } -void WorldSession::HandleBuyItemInSlotOpcode(WorldPacket & recv_data) +void WorldSession::HandleBuyItemInSlotOpcode(WorldPacket & recvData) { sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Received CMSG_BUY_ITEM_IN_SLOT"); uint64 vendorguid, bagguid; uint32 item, slot, count; uint8 bagslot; - recv_data >> vendorguid >> item >> slot >> bagguid >> bagslot >> count; + recvData >> vendorguid >> item >> slot >> bagguid >> bagslot >> count; // client expects count starting at 1, and we send vendorslot+1 to client already if (slot > 0) @@ -687,14 +687,14 @@ void WorldSession::HandleBuyItemInSlotOpcode(WorldPacket & recv_data) GetPlayer()->BuyItemFromVendorSlot(vendorguid, slot, item, count, bag, bagslot); } -void WorldSession::HandleBuyItemOpcode(WorldPacket & recv_data) +void WorldSession::HandleBuyItemOpcode(WorldPacket & recvData) { sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Received CMSG_BUY_ITEM"); uint64 vendorguid; uint32 item, slot, count; uint8 unk1; - recv_data >> vendorguid >> item >> slot >> count >> unk1; + recvData >> vendorguid >> item >> slot >> count >> unk1; // client expects count starting at 1, and we send vendorslot+1 to client already if (slot > 0) @@ -705,11 +705,11 @@ void WorldSession::HandleBuyItemOpcode(WorldPacket & recv_data) GetPlayer()->BuyItemFromVendorSlot(vendorguid, slot, item, count, NULL_BAG, NULL_SLOT); } -void WorldSession::HandleListInventoryOpcode(WorldPacket & recv_data) +void WorldSession::HandleListInventoryOpcode(WorldPacket & recvData) { uint64 guid; - recv_data >> guid; + recvData >> guid; if (!GetPlayer()->isAlive()) return; @@ -807,12 +807,12 @@ void WorldSession::SendListInventory(uint64 vendorGuid) SendPacket(&data); } -void WorldSession::HandleAutoStoreBagItemOpcode(WorldPacket & recv_data) +void WorldSession::HandleAutoStoreBagItemOpcode(WorldPacket & recvData) { //sLog->outDebug(LOG_FILTER_PACKETIO, "WORLD: CMSG_AUTOSTORE_BAG_ITEM"); uint8 srcbag, srcslot, dstbag; - recv_data >> srcbag >> srcslot >> dstbag; + recvData >> srcbag >> srcslot >> dstbag; //sLog->outDebug("STORAGE: receive srcbag = %u, srcslot = %u, dstbag = %u", srcbag, srcslot, dstbag); Item* pItem = _player->GetItemByPos(srcbag, srcslot); @@ -983,7 +983,7 @@ void WorldSession::HandleAutoStoreBankItemOpcode(WorldPacket& recvPacket) } } -void WorldSession::HandleSetAmmoOpcode(WorldPacket & recv_data) +void WorldSession::HandleSetAmmoOpcode(WorldPacket & recvData) { if (!GetPlayer()->isAlive()) { @@ -994,7 +994,7 @@ void WorldSession::HandleSetAmmoOpcode(WorldPacket & recv_data) sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: CMSG_SET_AMMO"); uint32 item; - recv_data >> item; + recvData >> item; if (!item) GetPlayer()->RemoveAmmo(); @@ -1024,11 +1024,11 @@ void WorldSession::SendItemEnchantTimeUpdate(uint64 Playerguid, uint64 Itemguid, SendPacket(&data); } -void WorldSession::HandleItemNameQueryOpcode(WorldPacket & recv_data) +void WorldSession::HandleItemNameQueryOpcode(WorldPacket & recvData) { uint32 itemid; - recv_data >> itemid; - recv_data.read_skip<uint64>(); // guid + recvData >> itemid; + recvData.read_skip<uint64>(); // guid sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: CMSG_ITEM_NAME_QUERY %u", itemid); ItemSetNameEntry const* pName = sObjectMgr->GetItemSetNameEntry(itemid); @@ -1048,14 +1048,14 @@ void WorldSession::HandleItemNameQueryOpcode(WorldPacket & recv_data) } } -void WorldSession::HandleWrapItemOpcode(WorldPacket& recv_data) +void WorldSession::HandleWrapItemOpcode(WorldPacket& recvData) { sLog->outDebug(LOG_FILTER_NETWORKIO, "Received opcode CMSG_WRAP_ITEM"); uint8 gift_bag, gift_slot, item_bag, item_slot; - recv_data >> gift_bag >> gift_slot; // paper - recv_data >> item_bag >> item_slot; // item + recvData >> gift_bag >> gift_slot; // paper + recvData >> item_bag >> item_slot; // item sLog->outDebug(LOG_FILTER_NETWORKIO, "WRAP: receive gift_bag = %u, gift_slot = %u, item_bag = %u, item_slot = %u", gift_bag, gift_slot, item_bag, item_slot); @@ -1159,19 +1159,19 @@ void WorldSession::HandleWrapItemOpcode(WorldPacket& recv_data) _player->DestroyItemCount(gift, count, true); } -void WorldSession::HandleSocketOpcode(WorldPacket& recv_data) +void WorldSession::HandleSocketOpcode(WorldPacket& recvData) { sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: CMSG_SOCKET_GEMS"); uint64 item_guid; uint64 gem_guids[MAX_GEM_SOCKETS]; - recv_data >> item_guid; + recvData >> item_guid; if (!item_guid) return; for (int i = 0; i < MAX_GEM_SOCKETS; ++i) - recv_data >> gem_guids[i]; + recvData >> gem_guids[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])) || @@ -1353,13 +1353,13 @@ void WorldSession::HandleSocketOpcode(WorldPacket& recv_data) itemTarget->ClearSoulboundTradeable(_player); // clear tradeable flag } -void WorldSession::HandleCancelTempEnchantmentOpcode(WorldPacket& recv_data) +void WorldSession::HandleCancelTempEnchantmentOpcode(WorldPacket& recvData) { sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: CMSG_CANCEL_TEMP_ENCHANTMENT"); uint32 eslot; - recv_data >> eslot; + recvData >> eslot; // apply only to equipped item if (!Player::IsEquipmentPos(INVENTORY_SLOT_BAG_0, eslot)) @@ -1377,12 +1377,12 @@ void WorldSession::HandleCancelTempEnchantmentOpcode(WorldPacket& recv_data) item->ClearEnchantment(TEMP_ENCHANTMENT_SLOT); } -void WorldSession::HandleItemRefundInfoRequest(WorldPacket& recv_data) +void WorldSession::HandleItemRefundInfoRequest(WorldPacket& recvData) { sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: CMSG_ITEM_REFUND_INFO"); uint64 guid; - recv_data >> guid; // item guid + recvData >> guid; // item guid Item* item = _player->GetItemByGuid(guid); if (!item) @@ -1394,11 +1394,11 @@ void WorldSession::HandleItemRefundInfoRequest(WorldPacket& recv_data) GetPlayer()->SendRefundInfo(item); } -void WorldSession::HandleItemRefund(WorldPacket &recv_data) +void WorldSession::HandleItemRefund(WorldPacket &recvData) { sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: CMSG_ITEM_REFUND"); uint64 guid; - recv_data >> guid; // item guid + recvData >> guid; // item guid Item* item = _player->GetItemByGuid(guid); if (!item) @@ -1415,10 +1415,10 @@ void WorldSession::HandleItemRefund(WorldPacket &recv_data) * * This function is called when player clicks on item which has some flag set */ -void WorldSession::HandleItemTextQuery(WorldPacket & recv_data ) +void WorldSession::HandleItemTextQuery(WorldPacket & recvData ) { uint64 itemGuid; - recv_data >> itemGuid; + recvData >> itemGuid; sLog->outDebug(LOG_FILTER_NETWORKIO, "CMSG_ITEM_TEXT_QUERY item guid: %u", GUID_LOPART(itemGuid)); diff --git a/src/server/game/Handlers/LFGHandler.cpp b/src/server/game/Handlers/LFGHandler.cpp index 116afdf8c75..9926c75eb2a 100755 --- a/src/server/game/Handlers/LFGHandler.cpp +++ b/src/server/game/Handlers/LFGHandler.cpp @@ -44,13 +44,13 @@ void BuildPartyLockDungeonBlock(WorldPacket& data, const LfgLockPartyMap& lockMa } } -void WorldSession::HandleLfgJoinOpcode(WorldPacket& recv_data) +void WorldSession::HandleLfgJoinOpcode(WorldPacket& recvData) { - if (!sWorld->getBoolConfig(CONFIG_DUNGEON_FINDER_ENABLE) || + if (!sLFGMgr->isOptionEnabled(LFG_OPTION_ENABLE_DUNGEON_FINDER | LFG_OPTION_ENABLE_RAID_BROWSER) || (GetPlayer()->GetGroup() && GetPlayer()->GetGroup()->GetLeaderGUID() != GetPlayer()->GetGUID() && (GetPlayer()->GetGroup()->GetMembersCount() == MAXGROUPSIZE || !GetPlayer()->GetGroup()->isLFGGroup()))) { - recv_data.rfinish(); + recvData.rfinish(); return; } @@ -58,112 +58,112 @@ void WorldSession::HandleLfgJoinOpcode(WorldPacket& recv_data) uint32 dungeon; uint32 roles; - recv_data >> roles; - recv_data.read_skip<uint16>(); // uint8 (always 0) - uint8 (always 0) - recv_data >> numDungeons; + recvData >> roles; + recvData.read_skip<uint16>(); // uint8 (always 0) - uint8 (always 0) + recvData >> numDungeons; if (!numDungeons) { - sLog->outDebug(LOG_FILTER_NETWORKIO, "CMSG_LFG_JOIN [" UI64FMTD "] no dungeons selected", GetPlayer()->GetGUID()); - recv_data.rfinish(); + sLog->outDebug(LOG_FILTER_LFG, "CMSG_LFG_JOIN [" UI64FMTD "] no dungeons selected", GetPlayer()->GetGUID()); + recvData.rfinish(); return; } LfgDungeonSet newDungeons; for (int8 i = 0; i < numDungeons; ++i) { - recv_data >> dungeon; + recvData >> dungeon; newDungeons.insert((dungeon & 0x00FFFFFF)); // remove the type from the dungeon entry } - recv_data.read_skip<uint32>(); // for 0..uint8 (always 3) { uint8 (always 0) } + recvData.read_skip<uint32>(); // for 0..uint8 (always 3) { uint8 (always 0) } std::string comment; - recv_data >> comment; - sLog->outDebug(LOG_FILTER_NETWORKIO, "CMSG_LFG_JOIN [" UI64FMTD "] roles: %u, Dungeons: %u, Comment: %s", GetPlayer()->GetGUID(), roles, uint8(newDungeons.size()), comment.c_str()); + recvData >> comment; + sLog->outDebug(LOG_FILTER_LFG, "CMSG_LFG_JOIN [" UI64FMTD "] roles: %u, Dungeons: %u, Comment: %s", GetPlayer()->GetGUID(), roles, uint8(newDungeons.size()), comment.c_str()); sLFGMgr->JoinLfg(GetPlayer(), uint8(roles), newDungeons, comment); } -void WorldSession::HandleLfgLeaveOpcode(WorldPacket& /*recv_data*/) +void WorldSession::HandleLfgLeaveOpcode(WorldPacket& /*recvData*/) { Group* grp = GetPlayer()->GetGroup(); uint64 guid = GetPlayer()->GetGUID(); uint64 gguid = grp ? grp->GetGUID() : guid; - sLog->outDebug(LOG_FILTER_NETWORKIO, "CMSG_LFG_LEAVE [" UI64FMTD "] in group: %u", guid, grp ? 1 : 0); + sLog->outDebug(LOG_FILTER_LFG, "CMSG_LFG_LEAVE [" UI64FMTD "] in group: %u", guid, grp ? 1 : 0); // Check cheating - only leader can leave the queue if (!grp || grp->GetLeaderGUID() == GetPlayer()->GetGUID()) sLFGMgr->LeaveLfg(gguid); } -void WorldSession::HandleLfgProposalResultOpcode(WorldPacket& recv_data) +void WorldSession::HandleLfgProposalResultOpcode(WorldPacket& recvData) { uint32 lfgGroupID; // Internal lfgGroupID bool accept; // Accept to join? - recv_data >> lfgGroupID; - recv_data >> accept; + recvData >> lfgGroupID; + recvData >> accept; - sLog->outDebug(LOG_FILTER_NETWORKIO, "CMSG_LFG_PROPOSAL_RESULT [" UI64FMTD "] proposal: %u accept: %u", GetPlayer()->GetGUID(), lfgGroupID, accept ? 1 : 0); + sLog->outDebug(LOG_FILTER_LFG, "CMSG_LFG_PROPOSAL_RESULT [" UI64FMTD "] proposal: %u accept: %u", GetPlayer()->GetGUID(), lfgGroupID, accept ? 1 : 0); sLFGMgr->UpdateProposal(lfgGroupID, GetPlayer()->GetGUID(), accept); } -void WorldSession::HandleLfgSetRolesOpcode(WorldPacket& recv_data) +void WorldSession::HandleLfgSetRolesOpcode(WorldPacket& recvData) { uint8 roles; - recv_data >> roles; // Player Group Roles + recvData >> roles; // Player Group Roles uint64 guid = GetPlayer()->GetGUID(); Group* grp = GetPlayer()->GetGroup(); if (!grp) { - sLog->outDebug(LOG_FILTER_NETWORKIO, "CMSG_LFG_SET_ROLES [" UI64FMTD "] Not in group", guid); + sLog->outDebug(LOG_FILTER_LFG, "CMSG_LFG_SET_ROLES [" UI64FMTD "] Not in group", guid); return; } uint64 gguid = grp->GetGUID(); - sLog->outDebug(LOG_FILTER_NETWORKIO, "CMSG_LFG_SET_ROLES: Group [" UI64FMTD "], Player [" UI64FMTD "], Roles: %u", gguid, guid, roles); + sLog->outDebug(LOG_FILTER_LFG, "CMSG_LFG_SET_ROLES: Group [" UI64FMTD "], Player [" UI64FMTD "], Roles: %u", gguid, guid, roles); sLFGMgr->UpdateRoleCheck(gguid, guid, roles); } -void WorldSession::HandleLfgSetCommentOpcode(WorldPacket& recv_data) +void WorldSession::HandleLfgSetCommentOpcode(WorldPacket& recvData) { std::string comment; - recv_data >> comment; + recvData >> comment; uint64 guid = GetPlayer()->GetGUID(); - sLog->outDebug(LOG_FILTER_NETWORKIO, "CMSG_LFG_SET_COMMENT [" UI64FMTD "] comment: %s", guid, comment.c_str()); + sLog->outDebug(LOG_FILTER_LFG, "CMSG_LFG_SET_COMMENT [" UI64FMTD "] comment: %s", guid, comment.c_str()); sLFGMgr->SetComment(guid, comment); } -void WorldSession::HandleLfgSetBootVoteOpcode(WorldPacket& recv_data) +void WorldSession::HandleLfgSetBootVoteOpcode(WorldPacket& recvData) { bool agree; // Agree to kick player - recv_data >> agree; + recvData >> agree; uint64 guid = GetPlayer()->GetGUID(); - sLog->outDebug(LOG_FILTER_NETWORKIO, "CMSG_LFG_SET_BOOT_VOTE [" UI64FMTD "] agree: %u", guid, agree ? 1 : 0); + sLog->outDebug(LOG_FILTER_LFG, "CMSG_LFG_SET_BOOT_VOTE [" UI64FMTD "] agree: %u", guid, agree ? 1 : 0); sLFGMgr->UpdateBoot(guid, agree); } -void WorldSession::HandleLfgTeleportOpcode(WorldPacket& recv_data) +void WorldSession::HandleLfgTeleportOpcode(WorldPacket& recvData) { bool out; - recv_data >> out; + recvData >> out; - sLog->outDebug(LOG_FILTER_NETWORKIO, "CMSG_LFG_TELEPORT [" UI64FMTD "] out: %u", GetPlayer()->GetGUID(), out ? 1 : 0); + sLog->outDebug(LOG_FILTER_LFG, "CMSG_LFG_TELEPORT [" UI64FMTD "] out: %u", GetPlayer()->GetGUID(), out ? 1 : 0); sLFGMgr->TeleportPlayer(GetPlayer(), out, true); } -void WorldSession::HandleLfgPlayerLockInfoRequestOpcode(WorldPacket& /*recv_data*/) +void WorldSession::HandleLfgPlayerLockInfoRequestOpcode(WorldPacket& /*recvData*/) { uint64 guid = GetPlayer()->GetGUID(); - sLog->outDebug(LOG_FILTER_NETWORKIO, "CMSG_LFG_PLAYER_LOCK_INFO_REQUEST [" UI64FMTD "]", guid); + sLog->outDebug(LOG_FILTER_LFG, "CMSG_LFG_PLAYER_LOCK_INFO_REQUEST [" UI64FMTD "]", guid); // Get Random dungeons that can be done at a certain level and expansion LfgDungeonSet randomDungeons; uint8 level = GetPlayer()->getLevel(); uint8 expansion = GetPlayer()->GetSession()->Expansion(); - LFGDungeonMap& LfgDungeons = sLFGMgr->GetLFGDungeonMap(); - for (LFGDungeonMap::const_iterator itr = LfgDungeons.begin(); itr != LfgDungeons.end(); ++itr) + LFGDungeonContainer& LfgDungeons = sLFGMgr->GetLFGDungeonMap(); + for (LFGDungeonContainer::const_iterator itr = LfgDungeons.begin(); itr != LfgDungeons.end(); ++itr) { LFGDungeonData const& dungeon = itr->second; if ((dungeon.type == LFG_TYPE_RANDOM || (dungeon.seasonal && sLFGMgr->IsSeasonActive(dungeon.id))) @@ -176,7 +176,7 @@ void WorldSession::HandleLfgPlayerLockInfoRequestOpcode(WorldPacket& /*recv_data uint32 rsize = uint32(randomDungeons.size()); uint32 lsize = uint32(lock.size()); - sLog->outDebug(LOG_FILTER_NETWORKIO, "SMSG_LFG_PLAYER_INFO [" UI64FMTD "]", guid); + sLog->outDebug(LOG_FILTER_LFG, "SMSG_LFG_PLAYER_INFO [" UI64FMTD "]", guid); WorldPacket data(SMSG_LFG_PLAYER_INFO, 1 + rsize * (4 + 1 + 4 + 4 + 4 + 4 + 1 + 4 + 4 + 4) + 4 + lsize * (1 + 4 + 4 + 4 + 4 + 1 + 4 + 4 + 4)); data << uint8(randomDungeons.size()); // Random Dungeon count @@ -231,10 +231,10 @@ void WorldSession::HandleLfgPlayerLockInfoRequestOpcode(WorldPacket& /*recv_data SendPacket(&data); } -void WorldSession::HandleLfgPartyLockInfoRequestOpcode(WorldPacket& /*recv_data*/) +void WorldSession::HandleLfgPartyLockInfoRequestOpcode(WorldPacket& /*recvData*/) { uint64 guid = GetPlayer()->GetGUID(); - sLog->outDebug(LOG_FILTER_NETWORKIO, "CMSG_LFG_PARTY_LOCK_INFO_REQUEST [" UI64FMTD "]", guid); + sLog->outDebug(LOG_FILTER_LFG, "CMSG_LFG_PARTY_LOCK_INFO_REQUEST [" UI64FMTD "]", guid); Group* grp = GetPlayer()->GetGroup(); if (!grp) @@ -259,25 +259,25 @@ void WorldSession::HandleLfgPartyLockInfoRequestOpcode(WorldPacket& /*recv_data for (LfgLockPartyMap::const_iterator it = lockMap.begin(); it != lockMap.end(); ++it) size += 8 + 4 + uint32(it->second.size()) * (4 + 4); - sLog->outDebug(LOG_FILTER_NETWORKIO, "SMSG_LFG_PARTY_INFO [" UI64FMTD "]", guid); + sLog->outDebug(LOG_FILTER_LFG, "SMSG_LFG_PARTY_INFO [" UI64FMTD "]", guid); WorldPacket data(SMSG_LFG_PARTY_INFO, 1 + size); BuildPartyLockDungeonBlock(data, lockMap); SendPacket(&data); } -void WorldSession::HandleLfrJoinOpcode(WorldPacket& recv_data) +void WorldSession::HandleLfrJoinOpcode(WorldPacket& recvData) { uint32 entry; // Raid id to search - recv_data >> entry; - sLog->outDebug(LOG_FILTER_NETWORKIO, "CMSG_LFG_LFR_JOIN [" UI64FMTD "] dungeon entry: %u", GetPlayer()->GetGUID(), entry); + recvData >> entry; + sLog->outDebug(LOG_FILTER_LFG, "CMSG_LFG_LFR_JOIN [" UI64FMTD "] dungeon entry: %u", GetPlayer()->GetGUID(), entry); //SendLfrUpdateListOpcode(entry); } -void WorldSession::HandleLfrLeaveOpcode(WorldPacket& recv_data) +void WorldSession::HandleLfrLeaveOpcode(WorldPacket& recvData) { uint32 dungeonId; // Raid id queue to leave - recv_data >> dungeonId; - sLog->outDebug(LOG_FILTER_NETWORKIO, "CMSG_LFG_LFR_LEAVE [" UI64FMTD "] dungeonId: %u", GetPlayer()->GetGUID(), dungeonId); + recvData >> dungeonId; + sLog->outDebug(LOG_FILTER_LFG, "CMSG_LFG_LFR_LEAVE [" UI64FMTD "] dungeonId: %u", GetPlayer()->GetGUID(), dungeonId); //sLFGMgr->LeaveLfr(GetPlayer(), dungeonId); } @@ -295,7 +295,9 @@ void WorldSession::SendLfgUpdatePlayer(const LfgUpdateData& updateData) queued = true; extrainfo = true; break; - //case LFG_UPDATETYPE_CLEAR_LOCK_LIST: // TODO: Sometimes has extrainfo - Check ocurrences... + case LFG_UPDATETYPE_UPDATE_STATUS: + extrainfo = size > 0; + break; case LFG_UPDATETYPE_PROPOSAL_BEGIN: extrainfo = true; break; @@ -303,7 +305,7 @@ void WorldSession::SendLfgUpdatePlayer(const LfgUpdateData& updateData) break; } - sLog->outDebug(LOG_FILTER_NETWORKIO, "SMSG_LFG_UPDATE_PLAYER [" UI64FMTD "] updatetype: %u", guid, updateData.updateType); + sLog->outDebug(LOG_FILTER_LFG, "SMSG_LFG_UPDATE_PLAYER [" UI64FMTD "] updatetype: %u", guid, updateData.updateType); WorldPacket data(SMSG_LFG_UPDATE_PLAYER, 1 + 1 + (extrainfo ? 1 : 0) * (1 + 1 + 1 + 1 + size * 4 + updateData.comment.length())); data << uint8(updateData.updateType); // Lfg Update type data << uint8(extrainfo); // Extra info @@ -340,8 +342,9 @@ void WorldSession::SendLfgUpdateParty(const LfgUpdateData& updateData) join = true; queued = true; break; - case LFG_UPDATETYPE_CLEAR_LOCK_LIST: - // join = true; // TODO: Sometimes queued and extrainfo - Check ocurrences... + case LFG_UPDATETYPE_UPDATE_STATUS: + extrainfo = size > 0; + join = true; queued = true; break; case LFG_UPDATETYPE_PROPOSAL_BEGIN: @@ -352,7 +355,7 @@ void WorldSession::SendLfgUpdateParty(const LfgUpdateData& updateData) break; } - sLog->outDebug(LOG_FILTER_NETWORKIO, "SMSG_LFG_UPDATE_PARTY [" UI64FMTD "] updatetype: %u", guid, updateData.updateType); + sLog->outDebug(LOG_FILTER_LFG, "SMSG_LFG_UPDATE_PARTY [" UI64FMTD "] updatetype: %u", guid, updateData.updateType); WorldPacket data(SMSG_LFG_UPDATE_PARTY, 1 + 1 + (extrainfo ? 1 : 0) * (1 + 1 + 1 + 1 + 1 + size * 4 + updateData.comment.length())); data << uint8(updateData.updateType); // Lfg Update type data << uint8(extrainfo); // Extra info @@ -376,7 +379,7 @@ void WorldSession::SendLfgUpdateParty(const LfgUpdateData& updateData) void WorldSession::SendLfgRoleChosen(uint64 guid, uint8 roles) { - sLog->outDebug(LOG_FILTER_NETWORKIO, "SMSG_LFG_ROLE_CHOSEN [" UI64FMTD "] guid: [" UI64FMTD "] roles: %u", GetPlayer()->GetGUID(), guid, roles); + sLog->outDebug(LOG_FILTER_LFG, "SMSG_LFG_ROLE_CHOSEN [" UI64FMTD "] guid: [" UI64FMTD "] roles: %u", GetPlayer()->GetGUID(), guid, roles); WorldPacket data(SMSG_LFG_ROLE_CHOSEN, 8 + 1 + 4); data << uint64(guid); // Guid @@ -393,7 +396,7 @@ void WorldSession::SendLfgRoleCheckUpdate(const LfgRoleCheck& roleCheck) else dungeons = roleCheck.dungeons; - sLog->outDebug(LOG_FILTER_NETWORKIO, "SMSG_LFG_ROLE_CHECK_UPDATE [" UI64FMTD "]", GetPlayer()->GetGUID()); + sLog->outDebug(LOG_FILTER_LFG, "SMSG_LFG_ROLE_CHECK_UPDATE [" UI64FMTD "]", GetPlayer()->GetGUID()); WorldPacket data(SMSG_LFG_ROLE_CHECK_UPDATE, 4 + 1 + 1 + dungeons.size() * 4 + 1 + roleCheck.roles.size() * (8 + 1 + 4 + 1)); data << uint32(roleCheck.state); // Check result @@ -443,7 +446,7 @@ void WorldSession::SendLfgJoinResult(const LfgJoinResultData& joinData) for (LfgLockPartyMap::const_iterator it = joinData.lockmap.begin(); it != joinData.lockmap.end(); ++it) size += 8 + 4 + uint32(it->second.size()) * (4 + 4); - sLog->outDebug(LOG_FILTER_NETWORKIO, "SMSG_LFG_JOIN_RESULT [" UI64FMTD "] checkResult: %u checkValue: %u", GetPlayer()->GetGUID(), joinData.result, joinData.state); + sLog->outDebug(LOG_FILTER_LFG, "SMSG_LFG_JOIN_RESULT [" UI64FMTD "] checkResult: %u checkValue: %u", GetPlayer()->GetGUID(), joinData.result, joinData.state); WorldPacket data(SMSG_LFG_JOIN_RESULT, 4 + 4 + size); data << uint32(joinData.result); // Check Result data << uint32(joinData.state); // Check Value @@ -454,7 +457,7 @@ void WorldSession::SendLfgJoinResult(const LfgJoinResultData& joinData) void WorldSession::SendLfgQueueStatus(const LfgQueueStatusData& queueData) { - sLog->outDebug(LOG_FILTER_NETWORKIO, "SMSG_LFG_QUEUE_STATUS [" UI64FMTD "] dungeon: %u - waitTime: %d - avgWaitTime: %d - waitTimeTanks: %d - waitTimeHealer: %d - waitTimeDps: %d - queuedTime: %u - tanks: %u - healers: %u - dps: %u", + sLog->outDebug(LOG_FILTER_LFG, "SMSG_LFG_QUEUE_STATUS [" UI64FMTD "] dungeon: %u - waitTime: %d - avgWaitTime: %d - waitTimeTanks: %d - waitTimeHealer: %d - waitTimeDps: %d - queuedTime: %u - tanks: %u - healers: %u - dps: %u", GetPlayer()->GetGUID(), queueData.dungeonId, queueData.waitTime, queueData.waitTimeAvg, queueData.waitTimeTank, queueData.waitTimeHealer, queueData.waitTimeDps, queueData.queuedTime, queueData.tanks, queueData.healers, queueData.dps); WorldPacket data(SMSG_LFG_QUEUE_STATUS, 4 + 4 + 4 + 4 + 4 +4 + 1 + 1 + 1 + 4); @@ -478,7 +481,7 @@ void WorldSession::SendLfgPlayerReward(uint32 rdungeonEntry, uint32 sdungeonEntr uint8 itemNum = uint8(quest ? quest->GetRewItemsCount() : 0); - sLog->outDebug(LOG_FILTER_NETWORKIO, "SMSG_LFG_PLAYER_REWARD [" UI64FMTD "] rdungeonEntry: %u - sdungeonEntry: %u - done: %u", GetPlayer()->GetGUID(), rdungeonEntry, sdungeonEntry, done); + sLog->outDebug(LOG_FILTER_LFG, "SMSG_LFG_PLAYER_REWARD [" UI64FMTD "] rdungeonEntry: %u - sdungeonEntry: %u - done: %u", GetPlayer()->GetGUID(), rdungeonEntry, sdungeonEntry, done); WorldPacket data(SMSG_LFG_PLAYER_REWARD, 4 + 4 + 1 + 4 + 4 + 4 + 4 + 4 + 1 + itemNum * (4 + 4 + 4)); data << uint32(rdungeonEntry); // Random Dungeon Finished data << uint32(sdungeonEntry); // Dungeon Finished @@ -510,7 +513,7 @@ void WorldSession::SendLfgBootProposalUpdate(const LfgPlayerBoot& boot) uint8 votesNum = 0; uint8 agreeNum = 0; uint32 secsleft = uint8((boot.cancelTime - time(NULL)) / 1000); - for (LfgAnswerMap::const_iterator it = boot.votes.begin(); it != boot.votes.end(); ++it) + for (LfgAnswerContainer::const_iterator it = boot.votes.begin(); it != boot.votes.end(); ++it) { if (it->second != LFG_ANSWER_PENDING) { @@ -519,7 +522,7 @@ void WorldSession::SendLfgBootProposalUpdate(const LfgPlayerBoot& boot) ++agreeNum; } } - sLog->outDebug(LOG_FILTER_NETWORKIO, "SMSG_LFG_BOOT_PROPOSAL_UPDATE [" UI64FMTD "] inProgress: %u - didVote: %u - agree: %u - victim: [" UI64FMTD "] votes: %u - agrees: %u - left: %u - needed: %u - reason %s", + sLog->outDebug(LOG_FILTER_LFG, "SMSG_LFG_BOOT_PROPOSAL_UPDATE [" UI64FMTD "] inProgress: %u - didVote: %u - agree: %u - victim: [" UI64FMTD "] votes: %u - agrees: %u - left: %u - needed: %u - reason %s", guid, uint8(boot.inProgress), uint8(playerVote != LFG_ANSWER_PENDING), uint8(playerVote == LFG_ANSWER_AGREE), boot.victim, votesNum, agreeNum, secsleft, LFG_GROUP_KICK_VOTES_NEEDED, boot.reason.c_str()); WorldPacket data(SMSG_LFG_BOOT_PROPOSAL_UPDATE, 1 + 1 + 1 + 8 + 4 + 4 + 4 + 4 + boot.reason.length()); data << uint8(boot.inProgress); // Vote in progress @@ -541,7 +544,7 @@ void WorldSession::SendLfgUpdateProposal(uint32 proposalId, LfgProposal const& p bool silent = !proposal.isNew && gguid == proposal.group; uint32 dungeonEntry = proposal.dungeonId; - sLog->outDebug(LOG_FILTER_NETWORKIO, "SMSG_LFG_PROPOSAL_UPDATE [" UI64FMTD "] state: %u", guid, proposal.state); + sLog->outDebug(LOG_FILTER_LFG, "SMSG_LFG_PROPOSAL_UPDATE [" UI64FMTD "] state: %u", guid, proposal.state); WorldPacket data(SMSG_LFG_PROPOSAL_UPDATE, 4 + 1 + 4 + 4 + 1 + 1 + proposal.players.size() * (4 + 1 + 1 + 1 + 1 +1)); // show random dungeon if player selected random dungeon and it's not lfg group @@ -562,7 +565,7 @@ void WorldSession::SendLfgUpdateProposal(uint32 proposalId, LfgProposal const& p data << uint8(silent); // Show proposal window data << uint8(proposal.players.size()); // Group size - for (LfgProposalPlayerMap::const_iterator it = proposal.players.begin(); it != proposal.players.end(); ++it) + for (LfgProposalPlayerContainer::const_iterator it = proposal.players.begin(); it != proposal.players.end(); ++it) { LfgProposalPlayer const& player = it->second; data << uint32(player.role); // Role @@ -585,7 +588,7 @@ void WorldSession::SendLfgUpdateProposal(uint32 proposalId, LfgProposal const& p void WorldSession::SendLfgLfrList(bool update) { - sLog->outDebug(LOG_FILTER_NETWORKIO, "SMSG_LFG_LFR_LIST [" UI64FMTD "] update: %u", GetPlayer()->GetGUID(), update ? 1 : 0); + sLog->outDebug(LOG_FILTER_LFG, "SMSG_LFG_LFR_LIST [" UI64FMTD "] update: %u", GetPlayer()->GetGUID(), update ? 1 : 0); WorldPacket data(SMSG_LFG_UPDATE_SEARCH, 1); data << uint8(update); // In Lfg Queue? SendPacket(&data); @@ -593,14 +596,14 @@ void WorldSession::SendLfgLfrList(bool update) void WorldSession::SendLfgDisabled() { - sLog->outDebug(LOG_FILTER_NETWORKIO, "SMSG_LFG_DISABLED [" UI64FMTD "]", GetPlayer()->GetGUID()); + sLog->outDebug(LOG_FILTER_LFG, "SMSG_LFG_DISABLED [" UI64FMTD "]", GetPlayer()->GetGUID()); WorldPacket data(SMSG_LFG_DISABLED, 0); SendPacket(&data); } void WorldSession::SendLfgOfferContinue(uint32 dungeonEntry) { - sLog->outDebug(LOG_FILTER_NETWORKIO, "SMSG_LFG_OFFER_CONTINUE [" UI64FMTD "] dungeon entry: %u", GetPlayer()->GetGUID(), dungeonEntry); + sLog->outDebug(LOG_FILTER_LFG, "SMSG_LFG_OFFER_CONTINUE [" UI64FMTD "] dungeon entry: %u", GetPlayer()->GetGUID(), dungeonEntry); WorldPacket data(SMSG_LFG_OFFER_CONTINUE, 4); data << uint32(dungeonEntry); SendPacket(&data); @@ -608,12 +611,44 @@ void WorldSession::SendLfgOfferContinue(uint32 dungeonEntry) void WorldSession::SendLfgTeleportError(uint8 err) { - sLog->outDebug(LOG_FILTER_NETWORKIO, "SMSG_LFG_TELEPORT_DENIED [" UI64FMTD "] reason: %u", GetPlayer()->GetGUID(), err); + sLog->outDebug(LOG_FILTER_LFG, "SMSG_LFG_TELEPORT_DENIED [" UI64FMTD "] reason: %u", GetPlayer()->GetGUID(), err); WorldPacket data(SMSG_LFG_TELEPORT_DENIED, 4); data << uint32(err); // Error SendPacket(&data); } +void WorldSession::HandleLfgGetStatus(WorldPacket& /*recvData*/) +{ + uint64 guid = GetPlayer()->GetGUID(); + sLog->outDebug(LOG_FILTER_LFG, "SMSG_LFG_GET_STATUS [" UI64FMTD "]", guid); + + LfgUpdateData updateData = LfgUpdateData(LFG_UPDATETYPE_UPDATE_STATUS); + LfgState state = sLFGMgr->GetLfgStatus(guid, updateData); + + if (state == LFG_STATE_NONE || updateData.dungeons.empty()) + { + SendLfgUpdatePlayer(updateData); + SendLfgUpdateParty(updateData); + return; + } + + if (state != LFG_STATE_QUEUED) + return; + + if (GetPlayer()->GetGroup()) + { + SendLfgUpdateParty(updateData); + updateData.dungeons.clear(); + SendLfgUpdatePlayer(updateData); + } + else + { + SendLfgUpdatePlayer(updateData); + updateData.dungeons.clear(); + SendLfgUpdateParty(updateData); + } +} + /* void WorldSession::SendLfrUpdateListOpcode(uint32 dungeonEntry) { diff --git a/src/server/game/Handlers/LootHandler.cpp b/src/server/game/Handlers/LootHandler.cpp index 73c8457eb66..83deaaa1bc6 100755 --- a/src/server/game/Handlers/LootHandler.cpp +++ b/src/server/game/Handlers/LootHandler.cpp @@ -30,7 +30,7 @@ #include "World.h" #include "Util.h" -void WorldSession::HandleAutostoreLootItemOpcode(WorldPacket & recv_data) +void WorldSession::HandleAutostoreLootItemOpcode(WorldPacket & recvData) { sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: CMSG_AUTOSTORE_LOOT_ITEM"); Player* player = GetPlayer(); @@ -38,7 +38,7 @@ void WorldSession::HandleAutostoreLootItemOpcode(WorldPacket & recv_data) Loot* loot = NULL; uint8 lootSlot = 0; - recv_data >> lootSlot; + recvData >> lootSlot; if (IS_GAMEOBJECT_GUID(lguid)) { @@ -94,7 +94,7 @@ void WorldSession::HandleAutostoreLootItemOpcode(WorldPacket & recv_data) player->StoreLootItem(lootSlot, loot); } -void WorldSession::HandleLootMoneyOpcode(WorldPacket & /*recv_data*/) +void WorldSession::HandleLootMoneyOpcode(WorldPacket & /*recvData*/) { sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: CMSG_LOOT_MONEY"); @@ -202,12 +202,12 @@ void WorldSession::HandleLootMoneyOpcode(WorldPacket & /*recv_data*/) } } -void WorldSession::HandleLootOpcode(WorldPacket & recv_data) +void WorldSession::HandleLootOpcode(WorldPacket & recvData) { sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: CMSG_LOOT"); uint64 guid; - recv_data >> guid; + recvData >> guid; // Check possible cheat if (!_player->isAlive()) @@ -428,12 +428,12 @@ void WorldSession::DoLootRelease(uint64 lguid) loot->RemoveLooter(player->GetGUID()); } -void WorldSession::HandleLootMasterGiveOpcode(WorldPacket & recv_data) +void WorldSession::HandleLootMasterGiveOpcode(WorldPacket & recvData) { uint8 slotid; uint64 lootguid, target_playerguid; - recv_data >> lootguid >> slotid >> target_playerguid; + recvData >> lootguid >> slotid >> target_playerguid; if (!_player->GetGroup() || _player->GetGroup()->GetLooterGuid() != _player->GetGUID()) { @@ -445,7 +445,7 @@ void WorldSession::HandleLootMasterGiveOpcode(WorldPacket & recv_data) if (!target) return; - sLog->outDebug(LOG_FILTER_NETWORKIO, "WorldSession::HandleLootMasterGiveOpcode (CMSG_LOOT_MASTER_GIVE, 0x02A3) Target = [%s].", target->GetName()); + sLog->outDebug(LOG_FILTER_NETWORKIO, "WorldSession::HandleLootMasterGiveOpcode (CMSG_LOOT_MASTER_GIVE, 0x02A3) Target = [%s].", target->GetName().c_str()); if (_player->GetLootGUID() != lootguid) return; @@ -474,7 +474,8 @@ void WorldSession::HandleLootMasterGiveOpcode(WorldPacket & recv_data) if (slotid >= loot->items.size() + loot->quest_items.size()) { - sLog->outDebug(LOG_FILTER_LOOT, "MasterLootItem: Player %s might be using a hack! (slot %d, size %lu)", GetPlayer()->GetName(), slotid, (unsigned long)loot->items.size()); + sLog->outDebug(LOG_FILTER_LOOT, "MasterLootItem: Player %s might be using a hack! (slot %d, size %lu)", + GetPlayer()->GetName().c_str(), slotid, (unsigned long)loot->items.size()); return; } diff --git a/src/server/game/Handlers/MailHandler.cpp b/src/server/game/Handlers/MailHandler.cpp index c6b5377fe36..5a7a3b52b56 100755 --- a/src/server/game/Handlers/MailHandler.cpp +++ b/src/server/game/Handlers/MailHandler.cpp @@ -29,29 +29,29 @@ #include "Item.h" #include "AccountMgr.h" -void WorldSession::HandleSendMail(WorldPacket & recv_data) +void WorldSession::HandleSendMail(WorldPacket & recvData) { uint64 mailbox, unk3; std::string receiver, subject, body; uint32 unk1, unk2, money, COD; uint8 unk4; - recv_data >> mailbox; - recv_data >> receiver; + recvData >> mailbox; + recvData >> receiver; - recv_data >> subject; + recvData >> subject; - recv_data >> body; + recvData >> body; - recv_data >> unk1; // stationery? - recv_data >> unk2; // 0x00000000 + recvData >> unk1; // stationery? + recvData >> unk2; // 0x00000000 uint8 items_count; - recv_data >> items_count; // attached items count + recvData >> items_count; // attached items count if (items_count > MAX_MAIL_ITEMS) // client limit { GetPlayer()->SendMailResult(0, MAIL_SEND, MAIL_ERR_TOO_MANY_ATTACHMENTS); - recv_data.rfinish(); // set to end to avoid warnings spam + recvData.rfinish(); // set to end to avoid warnings spam return; } @@ -59,13 +59,13 @@ void WorldSession::HandleSendMail(WorldPacket & recv_data) for (uint8 i = 0; i < items_count; ++i) { - recv_data.read_skip<uint8>(); // item slot in mail, not used - recv_data >> itemGUIDs[i]; + recvData.read_skip<uint8>(); // item slot in mail, not used + recvData >> itemGUIDs[i]; } - recv_data >> money >> COD; // money and cod - recv_data >> unk3; // const 0 - recv_data >> unk4; // const 0 + recvData >> money >> COD; // money and cod + recvData >> unk3; // const 0 + recvData >> unk4; // const 0 // packet read complete, now do check @@ -302,12 +302,12 @@ void WorldSession::HandleSendMail(WorldPacket & recv_data) } //called when mail is read -void WorldSession::HandleMailMarkAsRead(WorldPacket & recv_data) +void WorldSession::HandleMailMarkAsRead(WorldPacket & recvData) { uint64 mailbox; uint32 mailId; - recv_data >> mailbox; - recv_data >> mailId; + recvData >> mailbox; + recvData >> mailId; if (!GetPlayer()->GetGameObjectIfCanInteractWith(mailbox, GAMEOBJECT_TYPE_MAILBOX)) return; @@ -325,13 +325,13 @@ void WorldSession::HandleMailMarkAsRead(WorldPacket & recv_data) } //called when client deletes mail -void WorldSession::HandleMailDelete(WorldPacket & recv_data) +void WorldSession::HandleMailDelete(WorldPacket & recvData) { uint64 mailbox; uint32 mailId; - recv_data >> mailbox; - recv_data >> mailId; - recv_data.read_skip<uint32>(); // mailTemplateId + recvData >> mailbox; + recvData >> mailId; + recvData.read_skip<uint32>(); // mailTemplateId if (!GetPlayer()->GetGameObjectIfCanInteractWith(mailbox, GAMEOBJECT_TYPE_MAILBOX)) return; @@ -353,13 +353,13 @@ void WorldSession::HandleMailDelete(WorldPacket & recv_data) player->SendMailResult(mailId, MAIL_DELETED, MAIL_OK); } -void WorldSession::HandleMailReturnToSender(WorldPacket & recv_data) +void WorldSession::HandleMailReturnToSender(WorldPacket & recvData) { uint64 mailbox; uint32 mailId; - recv_data >> mailbox; - recv_data >> mailId; - recv_data.read_skip<uint64>(); // original sender GUID for return to, not used + recvData >> mailbox; + recvData >> mailId; + recvData.read_skip<uint64>(); // original sender GUID for return to, not used if (!GetPlayer()->GetGameObjectIfCanInteractWith(mailbox, GAMEOBJECT_TYPE_MAILBOX)) return; @@ -417,14 +417,14 @@ void WorldSession::HandleMailReturnToSender(WorldPacket & recv_data) } //called when player takes item attached in mail -void WorldSession::HandleMailTakeItem(WorldPacket & recv_data) +void WorldSession::HandleMailTakeItem(WorldPacket & recvData) { uint64 mailbox; uint32 mailId; uint32 itemId; - recv_data >> mailbox; - recv_data >> mailId; - recv_data >> itemId; // item guid low + recvData >> mailbox; + recvData >> mailId; + recvData >> itemId; // item guid low if (!GetPlayer()->GetGameObjectIfCanInteractWith(mailbox, GAMEOBJECT_TYPE_MAILBOX)) return; @@ -513,12 +513,12 @@ void WorldSession::HandleMailTakeItem(WorldPacket & recv_data) player->SendMailResult(mailId, MAIL_ITEM_TAKEN, MAIL_ERR_EQUIP_ERROR, msg); } -void WorldSession::HandleMailTakeMoney(WorldPacket & recv_data) +void WorldSession::HandleMailTakeMoney(WorldPacket & recvData) { uint64 mailbox; uint32 mailId; - recv_data >> mailbox; - recv_data >> mailId; + recvData >> mailbox; + recvData >> mailId; if (!GetPlayer()->GetGameObjectIfCanInteractWith(mailbox, GAMEOBJECT_TYPE_MAILBOX)) return; @@ -547,10 +547,10 @@ void WorldSession::HandleMailTakeMoney(WorldPacket & recv_data) } //called when player lists his received mails -void WorldSession::HandleGetMailList(WorldPacket & recv_data) +void WorldSession::HandleGetMailList(WorldPacket & recvData) { uint64 mailbox; - recv_data >> mailbox; + recvData >> mailbox; if (!GetPlayer()->GetGameObjectIfCanInteractWith(mailbox, GAMEOBJECT_TYPE_MAILBOX)) return; @@ -669,13 +669,13 @@ void WorldSession::HandleGetMailList(WorldPacket & recv_data) } //used when player copies mail body to his inventory -void WorldSession::HandleMailCreateTextItem(WorldPacket & recv_data) +void WorldSession::HandleMailCreateTextItem(WorldPacket & recvData) { uint64 mailbox; uint32 mailId; - recv_data >> mailbox; - recv_data >> mailId; + recvData >> mailbox; + recvData >> mailId; if (!GetPlayer()->GetGameObjectIfCanInteractWith(mailbox, GAMEOBJECT_TYPE_MAILBOX)) return; @@ -735,7 +735,7 @@ void WorldSession::HandleMailCreateTextItem(WorldPacket & recv_data) } //TODO Fix me! ... this void has probably bad condition, but good data are sent -void WorldSession::HandleQueryNextMailTime(WorldPacket & /*recv_data*/) +void WorldSession::HandleQueryNextMailTime(WorldPacket & /*recvData*/) { WorldPacket data(MSG_QUERY_NEXT_MAIL_TIME, 8); diff --git a/src/server/game/Handlers/MiscHandler.cpp b/src/server/game/Handlers/MiscHandler.cpp index e6e32e81e51..8928a7c15a1 100755 --- a/src/server/game/Handlers/MiscHandler.cpp +++ b/src/server/game/Handlers/MiscHandler.cpp @@ -56,11 +56,11 @@ #include "Battlefield.h" #include "BattlefieldMgr.h" -void WorldSession::HandleRepopRequestOpcode(WorldPacket & recv_data) +void WorldSession::HandleRepopRequestOpcode(WorldPacket& recvData) { sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Recvd CMSG_REPOP_REQUEST Message"); - recv_data.read_skip<uint8>(); + recvData.read_skip<uint8>(); if (GetPlayer()->isAlive() || GetPlayer()->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_GHOST)) return; @@ -75,7 +75,8 @@ void WorldSession::HandleRepopRequestOpcode(WorldPacket & recv_data) // release spirit after he's killed but before he is updated if (GetPlayer()->getDeathState() == JUST_DIED) { - sLog->outDebug(LOG_FILTER_NETWORKIO, "HandleRepopRequestOpcode: got request after player %s(%d) was killed and before he was updated", GetPlayer()->GetName(), GetPlayer()->GetGUIDLow()); + sLog->outDebug(LOG_FILTER_NETWORKIO, "HandleRepopRequestOpcode: got request after player %s(%d) was killed and before he was updated", + GetPlayer()->GetName().c_str(), GetPlayer()->GetGUIDLow()); GetPlayer()->KillPlayer(); } @@ -85,7 +86,7 @@ void WorldSession::HandleRepopRequestOpcode(WorldPacket & recv_data) GetPlayer()->RepopAtGraveyard(); } -void WorldSession::HandleGossipSelectOptionOpcode(WorldPacket & recv_data) +void WorldSession::HandleGossipSelectOptionOpcode(WorldPacket& recvData) { sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: CMSG_GOSSIP_SELECT_OPTION"); @@ -94,10 +95,10 @@ void WorldSession::HandleGossipSelectOptionOpcode(WorldPacket & recv_data) uint64 guid; std::string code = ""; - recv_data >> guid >> menuId >> gossipListId; + recvData >> guid >> menuId >> gossipListId; if (_player->PlayerTalkClass->IsGossipOptionCoded(gossipListId)) - recv_data >> code; + recvData >> code; Creature* unit = NULL; GameObject* go = NULL; @@ -170,7 +171,7 @@ void WorldSession::HandleGossipSelectOptionOpcode(WorldPacket & recv_data) } } -void WorldSession::HandleWhoOpcode(WorldPacket & recv_data) +void WorldSession::HandleWhoOpcode(WorldPacket& recvData) { sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Recvd CMSG_WHO Message"); @@ -185,15 +186,15 @@ void WorldSession::HandleWhoOpcode(WorldPacket & recv_data) uint32 zoneids[10]; // 10 is client limit std::string player_name, guild_name; - recv_data >> level_min; // maximal player level, default 0 - recv_data >> level_max; // minimal player level, default 100 (MAX_LEVEL) - recv_data >> player_name; // player name, case sensitive... + recvData >> level_min; // maximal player level, default 0 + recvData >> level_max; // minimal player level, default 100 (MAX_LEVEL) + recvData >> player_name; // player name, case sensitive... - recv_data >> guild_name; // guild name, case sensitive... + recvData >> guild_name; // guild name, case sensitive... - recv_data >> racemask; // race mask - recv_data >> classmask; // class mask - recv_data >> zones_count; // zones count, client limit = 10 (2.0.10) + recvData >> racemask; // race mask + recvData >> classmask; // class mask + recvData >> zones_count; // zones count, client limit = 10 (2.0.10) if (zones_count > 10) return; // can't be received from real client or broken packet @@ -201,12 +202,12 @@ void WorldSession::HandleWhoOpcode(WorldPacket & recv_data) for (uint32 i = 0; i < zones_count; ++i) { uint32 temp; - recv_data >> temp; // zone id, 0 if zone is unknown... + recvData >> temp; // zone id, 0 if zone is unknown... zoneids[i] = temp; sLog->outDebug(LOG_FILTER_NETWORKIO, "Zone %u: %u", i, zoneids[i]); } - recv_data >> str_count; // user entered strings count, client limit=4 (checked on 2.0.10) + recvData >> str_count; // user entered strings count, client limit=4 (checked on 2.0.10) if (str_count > 4) return; // can't be received from real client or broken packet @@ -217,7 +218,7 @@ void WorldSession::HandleWhoOpcode(WorldPacket & recv_data) for (uint32 i = 0; i < str_count; ++i) { std::string temp; - recv_data >> temp; // user entered string, it used as universal search pattern(guild+player name)? + recvData >> temp; // user entered string, it used as universal search pattern(guild+player name)? if (!Utf8toWStr(temp, str[i])) continue; @@ -367,7 +368,7 @@ void WorldSession::HandleWhoOpcode(WorldPacket & recv_data) sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Send SMSG_WHO Message"); } -void WorldSession::HandleLogoutRequestOpcode(WorldPacket & /*recv_data*/) +void WorldSession::HandleLogoutRequestOpcode(WorldPacket& /*recvData*/) { sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Recvd CMSG_LOGOUT_REQUEST Message, security - %u", GetSecurity()); @@ -424,12 +425,12 @@ void WorldSession::HandleLogoutRequestOpcode(WorldPacket & /*recv_data*/) LogoutRequest(time(NULL)); } -void WorldSession::HandlePlayerLogoutOpcode(WorldPacket & /*recv_data*/) +void WorldSession::HandlePlayerLogoutOpcode(WorldPacket& /*recvData*/) { sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Recvd CMSG_PLAYER_LOGOUT Message"); } -void WorldSession::HandleLogoutCancelOpcode(WorldPacket & /*recv_data*/) +void WorldSession::HandleLogoutCancelOpcode(WorldPacket& /*recvData*/) { sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Recvd CMSG_LOGOUT_CANCEL Message"); @@ -461,13 +462,13 @@ void WorldSession::HandleLogoutCancelOpcode(WorldPacket & /*recv_data*/) sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Sent SMSG_LOGOUT_CANCEL_ACK Message"); } -void WorldSession::HandleTogglePvP(WorldPacket & recv_data) +void WorldSession::HandleTogglePvP(WorldPacket& recvData) { // this opcode can be used in two ways: Either set explicit new status or toggle old status - if (recv_data.size() == 1) + if (recvData.size() == 1) { bool newPvPStatus; - recv_data >> newPvPStatus; + recvData >> newPvPStatus; GetPlayer()->ApplyModFlag(PLAYER_FLAGS, PLAYER_FLAGS_IN_PVP, newPvPStatus); GetPlayer()->ApplyModFlag(PLAYER_FLAGS, PLAYER_FLAGS_PVP_TIMER, !newPvPStatus); } @@ -492,10 +493,10 @@ void WorldSession::HandleTogglePvP(WorldPacket & recv_data) // pvp->HandlePlayerActivityChanged(_player); } -void WorldSession::HandleZoneUpdateOpcode(WorldPacket & recv_data) +void WorldSession::HandleZoneUpdateOpcode(WorldPacket& recvData) { uint32 newZone; - recv_data >> newZone; + recvData >> newZone; sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Recvd ZONE_UPDATE: %u", newZone); @@ -506,46 +507,47 @@ void WorldSession::HandleZoneUpdateOpcode(WorldPacket & recv_data) //GetPlayer()->SendInitWorldStates(true, newZone); } -void WorldSession::HandleSetSelectionOpcode(WorldPacket & recv_data) +void WorldSession::HandleSetSelectionOpcode(WorldPacket& recvData) { uint64 guid; - recv_data >> guid; + recvData >> guid; _player->SetSelection(guid); } -void WorldSession::HandleStandStateChangeOpcode(WorldPacket & recv_data) +void WorldSession::HandleStandStateChangeOpcode(WorldPacket& recvData) { - // sLog->outDebug(LOG_FILTER_PACKETIO, "WORLD: Received CMSG_STANDSTATECHANGE"); -- too many spam in log at lags/debug stop + // sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Received CMSG_STANDSTATECHANGE"); -- too many spam in log at lags/debug stop uint32 animstate; - recv_data >> animstate; + recvData >> animstate; _player->SetStandState(animstate); } -void WorldSession::HandleContactListOpcode(WorldPacket & recv_data) +void WorldSession::HandleContactListOpcode(WorldPacket& recvData) { uint32 unk; - recv_data >> unk; + recvData >> unk; sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Received CMSG_CONTACT_LIST - Unk: %d", unk); _player->GetSocial()->SendSocialList(_player); } -void WorldSession::HandleAddFriendOpcode(WorldPacket & recv_data) +void WorldSession::HandleAddFriendOpcode(WorldPacket& recvData) { sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Received CMSG_ADD_FRIEND"); std::string friendName = GetTrinityString(LANG_FRIEND_IGNORE_UNKNOWN); std::string friendNote; - recv_data >> friendName; + recvData >> friendName; - recv_data >> friendNote; + recvData >> friendNote; if (!normalizePlayerName(friendName)) return; - sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: %s asked to add friend : '%s'", GetPlayer()->GetName(), friendName.c_str()); + sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: %s asked to add friend : '%s'", + GetPlayer()->GetName().c_str(), friendName.c_str()); PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_GUID_RACE_ACC_BY_NAME); @@ -555,7 +557,7 @@ void WorldSession::HandleAddFriendOpcode(WorldPacket & recv_data) _addFriendCallback.SetFutureResult(CharacterDatabase.AsyncQuery(stmt)); } -void WorldSession::HandleAddFriendOpcodeCallBack(PreparedQueryResult result, std::string friendNote) +void WorldSession::HandleAddFriendOpcodeCallBack(PreparedQueryResult result, std::string const& friendNote) { if (!GetPlayer()) return; @@ -596,7 +598,7 @@ void WorldSession::HandleAddFriendOpcodeCallBack(PreparedQueryResult result, std if (!GetPlayer()->GetSocial()->AddToSocialList(GUID_LOPART(friendGuid), false)) { friendResult = FRIEND_LIST_FULL; - sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: %s's friend list is full.", GetPlayer()->GetName()); + sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: %s's friend list is full.", GetPlayer()->GetName().c_str()); } } GetPlayer()->GetSocial()->SetFriendNote(GUID_LOPART(friendGuid), friendNote); @@ -609,13 +611,13 @@ void WorldSession::HandleAddFriendOpcodeCallBack(PreparedQueryResult result, std sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Sent (SMSG_FRIEND_STATUS)"); } -void WorldSession::HandleDelFriendOpcode(WorldPacket & recv_data) +void WorldSession::HandleDelFriendOpcode(WorldPacket& recvData) { uint64 FriendGUID; sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Received CMSG_DEL_FRIEND"); - recv_data >> FriendGUID; + recvData >> FriendGUID; _player->GetSocial()->RemoveFromSocialList(GUID_LOPART(FriendGUID), false); @@ -624,19 +626,19 @@ void WorldSession::HandleDelFriendOpcode(WorldPacket & recv_data) sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Sent motd (SMSG_FRIEND_STATUS)"); } -void WorldSession::HandleAddIgnoreOpcode(WorldPacket & recv_data) +void WorldSession::HandleAddIgnoreOpcode(WorldPacket& recvData) { sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Received CMSG_ADD_IGNORE"); std::string ignoreName = GetTrinityString(LANG_FRIEND_IGNORE_UNKNOWN); - recv_data >> ignoreName; + recvData >> ignoreName; if (!normalizePlayerName(ignoreName)) return; sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: %s asked to Ignore: '%s'", - GetPlayer()->GetName(), ignoreName.c_str()); + GetPlayer()->GetName().c_str(), ignoreName.c_str()); PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_GUID_BY_NAME); @@ -682,13 +684,13 @@ void WorldSession::HandleAddIgnoreOpcodeCallBack(PreparedQueryResult result) sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Sent (SMSG_FRIEND_STATUS)"); } -void WorldSession::HandleDelIgnoreOpcode(WorldPacket & recv_data) +void WorldSession::HandleDelIgnoreOpcode(WorldPacket& recvData) { uint64 IgnoreGUID; sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Received CMSG_DEL_IGNORE"); - recv_data >> IgnoreGUID; + recvData >> IgnoreGUID; _player->GetSocial()->RemoveFromSocialList(GUID_LOPART(IgnoreGUID), true); @@ -697,23 +699,23 @@ void WorldSession::HandleDelIgnoreOpcode(WorldPacket & recv_data) sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Sent motd (SMSG_FRIEND_STATUS)"); } -void WorldSession::HandleSetContactNotesOpcode(WorldPacket & recv_data) +void WorldSession::HandleSetContactNotesOpcode(WorldPacket& recvData) { sLog->outDebug(LOG_FILTER_NETWORKIO, "CMSG_SET_CONTACT_NOTES"); uint64 guid; std::string note; - recv_data >> guid >> note; + recvData >> guid >> note; _player->GetSocial()->SetFriendNote(GUID_LOPART(guid), note); } -void WorldSession::HandleBugOpcode(WorldPacket & recv_data) +void WorldSession::HandleBugOpcode(WorldPacket& recvData) { uint32 suggestion, contentlen, typelen; std::string content, type; - recv_data >> suggestion >> contentlen >> content; + recvData >> suggestion >> contentlen >> content; - recv_data >> typelen >> type; + recvData >> typelen >> type; if (suggestion == 0) sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Received CMSG_BUG [Bug Report]"); @@ -731,12 +733,12 @@ void WorldSession::HandleBugOpcode(WorldPacket & recv_data) CharacterDatabase.Execute(stmt); } -void WorldSession::HandleReclaimCorpseOpcode(WorldPacket &recv_data) +void WorldSession::HandleReclaimCorpseOpcode(WorldPacket& recvData) { sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Received CMSG_RECLAIM_CORPSE"); uint64 guid; - recv_data >> guid; + recvData >> guid; if (GetPlayer()->isAlive()) return; @@ -768,14 +770,14 @@ void WorldSession::HandleReclaimCorpseOpcode(WorldPacket &recv_data) GetPlayer()->SpawnCorpseBones(); } -void WorldSession::HandleResurrectResponseOpcode(WorldPacket & recv_data) +void WorldSession::HandleResurrectResponseOpcode(WorldPacket& recvData) { sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Received CMSG_RESURRECT_RESPONSE"); uint64 guid; uint8 status; - recv_data >> guid; - recv_data >> status; + recvData >> guid; + recvData >> status; if (GetPlayer()->isAlive()) return; @@ -809,10 +811,10 @@ void WorldSession::SendAreaTriggerMessage(const char* Text, ...) SendPacket(&data); } -void WorldSession::HandleAreaTriggerOpcode(WorldPacket& recv_data) +void WorldSession::HandleAreaTriggerOpcode(WorldPacket& recvData) { uint32 triggerId; - recv_data >> triggerId; + recvData >> triggerId; sLog->outDebug(LOG_FILTER_NETWORKIO, "CMSG_AREATRIGGER. Trigger ID: %u", triggerId); @@ -820,7 +822,7 @@ void WorldSession::HandleAreaTriggerOpcode(WorldPacket& recv_data) if (player->isInFlight()) { sLog->outDebug(LOG_FILTER_NETWORKIO, "HandleAreaTriggerOpcode: Player '%s' (GUID: %u) in flight, ignore Area Trigger ID:%u", - player->GetName(), player->GetGUIDLow(), triggerId); + player->GetName().c_str(), player->GetGUIDLow(), triggerId); return; } @@ -828,14 +830,14 @@ void WorldSession::HandleAreaTriggerOpcode(WorldPacket& recv_data) if (!atEntry) { sLog->outDebug(LOG_FILTER_NETWORKIO, "HandleAreaTriggerOpcode: Player '%s' (GUID: %u) send unknown (by DBC) Area Trigger ID:%u", - player->GetName(), player->GetGUIDLow(), triggerId); + player->GetName().c_str(), player->GetGUIDLow(), triggerId); return; } if (player->GetMapId() != atEntry->mapid) { sLog->outDebug(LOG_FILTER_NETWORKIO, "HandleAreaTriggerOpcode: Player '%s' (GUID: %u) too far (trigger map: %u player map: %u), ignore Area Trigger ID: %u", - player->GetName(), atEntry->mapid, player->GetMapId(), player->GetGUIDLow(), triggerId); + player->GetName().c_str(), atEntry->mapid, player->GetMapId(), player->GetGUIDLow(), triggerId); return; } @@ -849,7 +851,7 @@ void WorldSession::HandleAreaTriggerOpcode(WorldPacket& recv_data) if (dist > atEntry->radius + delta) { sLog->outDebug(LOG_FILTER_NETWORKIO, "HandleAreaTriggerOpcode: Player '%s' (GUID: %u) too far (radius: %f distance: %f), ignore Area Trigger ID: %u", - player->GetName(), player->GetGUIDLow(), atEntry->radius, dist, triggerId); + player->GetName().c_str(), player->GetGUIDLow(), atEntry->radius, dist, triggerId); return; } } @@ -880,7 +882,7 @@ void WorldSession::HandleAreaTriggerOpcode(WorldPacket& recv_data) (fabs(dz) > atEntry->box_z / 2 + delta)) { sLog->outDebug(LOG_FILTER_NETWORKIO, "HandleAreaTriggerOpcode: Player '%s' (GUID: %u) too far (1/2 box X: %f 1/2 box Y: %f 1/2 box Z: %f rotatedPlayerX: %f rotatedPlayerY: %f dZ:%f), ignore Area Trigger ID: %u", - player->GetName(), player->GetGUIDLow(), atEntry->box_x/2, atEntry->box_y/2, atEntry->box_z/2, rotPlayerX, rotPlayerY, dz, triggerId); + player->GetName().c_str(), player->GetGUIDLow(), atEntry->box_x/2, atEntry->box_y/2, atEntry->box_z/2, rotPlayerX, rotPlayerY, dz, triggerId); return; } } @@ -939,12 +941,12 @@ void WorldSession::HandleAreaTriggerOpcode(WorldPacket& recv_data) player->TeleportTo(at->target_mapId, at->target_X, at->target_Y, at->target_Z, at->target_Orientation, TELE_TO_NOT_LEAVE_TRANSPORT); } -void WorldSession::HandleUpdateAccountData(WorldPacket &recv_data) +void WorldSession::HandleUpdateAccountData(WorldPacket& recvData) { sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Received CMSG_UPDATE_ACCOUNT_DATA"); uint32 type, timestamp, decompressedSize; - recv_data >> type >> timestamp >> decompressedSize; + recvData >> type >> timestamp >> decompressedSize; sLog->outDebug(LOG_FILTER_NETWORKIO, "UAD: type %u, time %u, decompressedSize %u", type, timestamp, decompressedSize); @@ -965,7 +967,7 @@ void WorldSession::HandleUpdateAccountData(WorldPacket &recv_data) if (decompressedSize > 0xFFFF) { - recv_data.rfinish(); // unnneded warning spam in this case + recvData.rfinish(); // unnneded warning spam in this case sLog->outError(LOG_FILTER_NETWORKIO, "UAD: Account data packet too big, size %u", decompressedSize); return; } @@ -974,14 +976,14 @@ void WorldSession::HandleUpdateAccountData(WorldPacket &recv_data) dest.resize(decompressedSize); uLongf realSize = decompressedSize; - if (uncompress(const_cast<uint8*>(dest.contents()), &realSize, const_cast<uint8*>(recv_data.contents() + recv_data.rpos()), recv_data.size() - recv_data.rpos()) != Z_OK) + if (uncompress(const_cast<uint8*>(dest.contents()), &realSize, const_cast<uint8*>(recvData.contents() + recvData.rpos()), recvData.size() - recvData.rpos()) != Z_OK) { - recv_data.rfinish(); // unnneded warning spam in this case + recvData.rfinish(); // unnneded warning spam in this case sLog->outError(LOG_FILTER_NETWORKIO, "UAD: Failed to decompress account data"); return; } - recv_data.rfinish(); // uncompress read (recv_data.size() - recv_data.rpos()) + recvData.rfinish(); // uncompress read (recvData.size() - recvData.rpos()) std::string adata; dest >> adata; @@ -994,12 +996,12 @@ void WorldSession::HandleUpdateAccountData(WorldPacket &recv_data) SendPacket(&data); } -void WorldSession::HandleRequestAccountData(WorldPacket& recv_data) +void WorldSession::HandleRequestAccountData(WorldPacket& recvData) { sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Received CMSG_REQUEST_ACCOUNT_DATA"); uint32 type; - recv_data >> type; + recvData >> type; sLog->outDebug(LOG_FILTER_NETWORKIO, "RAD: type %u", type); @@ -1032,70 +1034,42 @@ void WorldSession::HandleRequestAccountData(WorldPacket& recv_data) SendPacket(&data); } -void WorldSession::HandleSetActionButtonOpcode(WorldPacket& recv_data) +void WorldSession::HandleSetActionButtonOpcode(WorldPacket& recvData) { - sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Received CMSG_SET_ACTION_BUTTON"); uint8 button; uint32 packetData; - recv_data >> button >> packetData; + recvData >> button >> packetData; + sLog->outDebug(LOG_FILTER_NETWORKIO, "CMSG_SET_ACTION_BUTTON Button: %u Data: %u", button, packetData); - uint32 action = ACTION_BUTTON_ACTION(packetData); - uint8 type = ACTION_BUTTON_TYPE(packetData); - - sLog->outInfo(LOG_FILTER_NETWORKIO, "BUTTON: %u ACTION: %u TYPE: %u", button, action, type); if (!packetData) - { - sLog->outInfo(LOG_FILTER_NETWORKIO, "MISC: Remove action from button %u", button); GetPlayer()->removeActionButton(button); - } else - { - switch (type) - { - case ACTION_BUTTON_MACRO: - case ACTION_BUTTON_CMACRO: - sLog->outInfo(LOG_FILTER_NETWORKIO, "MISC: Added Macro %u into button %u", action, button); - break; - case ACTION_BUTTON_EQSET: - sLog->outInfo(LOG_FILTER_NETWORKIO, "MISC: Added EquipmentSet %u into button %u", action, button); - break; - case ACTION_BUTTON_SPELL: - sLog->outInfo(LOG_FILTER_NETWORKIO, "MISC: Added Spell %u into button %u", action, button); - break; - case ACTION_BUTTON_ITEM: - sLog->outInfo(LOG_FILTER_NETWORKIO, "MISC: Added Item %u into button %u", action, button); - break; - default: - sLog->outError(LOG_FILTER_NETWORKIO, "MISC: Unknown action button type %u for action %u into button %u for player %s (GUID: %u)", type, action, button, _player->GetName(), _player->GetGUIDLow()); - return; - } - GetPlayer()->addActionButton(button, action, type); - } + GetPlayer()->addActionButton(button, ACTION_BUTTON_ACTION(packetData), ACTION_BUTTON_TYPE(packetData)); } -void WorldSession::HandleCompleteCinematic(WorldPacket & /*recv_data*/) +void WorldSession::HandleCompleteCinematic(WorldPacket& /*recvData*/) { sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Received CMSG_COMPLETE_CINEMATIC"); } -void WorldSession::HandleNextCinematicCamera(WorldPacket & /*recv_data*/) +void WorldSession::HandleNextCinematicCamera(WorldPacket& /*recvData*/) { sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Received CMSG_NEXT_CINEMATIC_CAMERA"); } -void WorldSession::HandleMoveTimeSkippedOpcode(WorldPacket & recv_data) +void WorldSession::HandleMoveTimeSkippedOpcode(WorldPacket& recvData) { /* WorldSession::Update(getMSTime());*/ sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Received CMSG_MOVE_TIME_SKIPPED"); uint64 guid; - recv_data.readPackGUID(guid); - recv_data.read_skip<uint32>(); + recvData.readPackGUID(guid); + recvData.read_skip<uint32>(); /* uint64 guid; uint32 time_skipped; - recv_data >> guid; - recv_data >> time_skipped; + recvData >> guid; + recvData >> time_skipped; sLog->outDebug(LOG_FILTER_PACKETIO, "WORLD: CMSG_MOVE_TIME_SKIPPED"); /// TODO @@ -1106,84 +1080,84 @@ void WorldSession::HandleMoveTimeSkippedOpcode(WorldPacket & recv_data) */ } -void WorldSession::HandleFeatherFallAck(WorldPacket &recv_data) +void WorldSession::HandleFeatherFallAck(WorldPacket& recvData) { sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: CMSG_MOVE_FEATHER_FALL_ACK"); // no used - recv_data.rfinish(); // prevent warnings spam + recvData.rfinish(); // prevent warnings spam } -void WorldSession::HandleMoveUnRootAck(WorldPacket& recv_data) +void WorldSession::HandleMoveUnRootAck(WorldPacket& recvData) { // no used - recv_data.rfinish(); // prevent warnings spam + recvData.rfinish(); // prevent warnings spam /* uint64 guid; - recv_data >> guid; + recvData >> guid; // now can skip not our packet if (_player->GetGUID() != guid) { - recv_data.rfinish(); // prevent warnings spam + recvData.rfinish(); // prevent warnings spam return; } sLog->outDebug(LOG_FILTER_PACKETIO, "WORLD: CMSG_FORCE_MOVE_UNROOT_ACK"); - recv_data.read_skip<uint32>(); // unk + recvData.read_skip<uint32>(); // unk MovementInfo movementInfo; movementInfo.guid = guid; - ReadMovementInfo(recv_data, &movementInfo); - recv_data.read_skip<float>(); // unk2 + ReadMovementInfo(recvData, &movementInfo); + recvData.read_skip<float>(); // unk2 */ } -void WorldSession::HandleMoveRootAck(WorldPacket& recv_data) +void WorldSession::HandleMoveRootAck(WorldPacket& recvData) { // no used - recv_data.rfinish(); // prevent warnings spam + recvData.rfinish(); // prevent warnings spam /* uint64 guid; - recv_data >> guid; + recvData >> guid; // now can skip not our packet if (_player->GetGUID() != guid) { - recv_data.rfinish(); // prevent warnings spam + recvData.rfinish(); // prevent warnings spam return; } sLog->outDebug(LOG_FILTER_PACKETIO, "WORLD: CMSG_FORCE_MOVE_ROOT_ACK"); - recv_data.read_skip<uint32>(); // unk + recvData.read_skip<uint32>(); // unk MovementInfo movementInfo; - ReadMovementInfo(recv_data, &movementInfo); + ReadMovementInfo(recvData, &movementInfo); */ } -void WorldSession::HandleSetActionBarToggles(WorldPacket& recv_data) +void WorldSession::HandleSetActionBarToggles(WorldPacket& recvData) { - uint8 ActionBar; + uint8 actionBar; - recv_data >> ActionBar; + recvData >> actionBar; if (!GetPlayer()) // ignore until not logged (check needed because STATUS_AUTHED) { - if (ActionBar != 0) - sLog->outError(LOG_FILTER_NETWORKIO, "WorldSession::HandleSetActionBarToggles in not logged state with value: %u, ignored", uint32(ActionBar)); + if (actionBar != 0) + sLog->outError(LOG_FILTER_NETWORKIO, "WorldSession::HandleSetActionBarToggles in not logged state with value: %u, ignored", uint32(actionBar)); return; } - GetPlayer()->SetByteValue(PLAYER_FIELD_BYTES, 2, ActionBar); + GetPlayer()->SetByteValue(PLAYER_FIELD_BYTES, 2, actionBar); } -void WorldSession::HandlePlayedTime(WorldPacket& recv_data) +void WorldSession::HandlePlayedTime(WorldPacket& recvData) { uint8 unk1; - recv_data >> unk1; // 0 or 1 expected + recvData >> unk1; // 0 or 1 expected WorldPacket data(SMSG_PLAYED_TIME, 4 + 4 + 1); data << uint32(_player->GetTotalPlayedTime()); @@ -1192,10 +1166,10 @@ void WorldSession::HandlePlayedTime(WorldPacket& recv_data) SendPacket(&data); } -void WorldSession::HandleInspectOpcode(WorldPacket& recv_data) +void WorldSession::HandleInspectOpcode(WorldPacket& recvData) { uint64 guid; - recv_data >> guid; + recvData >> guid; sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Received CMSG_INSPECT"); @@ -1214,9 +1188,7 @@ void WorldSession::HandleInspectOpcode(WorldPacket& recv_data) data.append(player->GetPackGUID()); if (sWorld->getBoolConfig(CONFIG_TALENTS_INSPECTING) || _player->isGameMaster()) - { player->BuildPlayerTalentsInfoData(&data); - } else { data << uint32(0); // unspentTalentPoints @@ -1228,10 +1200,10 @@ void WorldSession::HandleInspectOpcode(WorldPacket& recv_data) SendPacket(&data); } -void WorldSession::HandleInspectHonorStatsOpcode(WorldPacket& recv_data) +void WorldSession::HandleInspectHonorStatsOpcode(WorldPacket& recvData) { uint64 guid; - recv_data >> guid; + recvData >> guid; Player* player = ObjectAccessor::FindPlayer(guid); @@ -1251,7 +1223,7 @@ void WorldSession::HandleInspectHonorStatsOpcode(WorldPacket& recv_data) SendPacket(&data); } -void WorldSession::HandleWorldTeleportOpcode(WorldPacket& recv_data) +void WorldSession::HandleWorldTeleportOpcode(WorldPacket& recvData) { uint32 time; uint32 mapid; @@ -1260,22 +1232,24 @@ void WorldSession::HandleWorldTeleportOpcode(WorldPacket& recv_data) float PositionZ; float Orientation; - recv_data >> time; // time in m.sec. - recv_data >> mapid; - recv_data >> PositionX; - recv_data >> PositionY; - recv_data >> PositionZ; - recv_data >> Orientation; // o (3.141593 = 180 degrees) + recvData >> time; // time in m.sec. + recvData >> mapid; + recvData >> PositionX; + recvData >> PositionY; + recvData >> PositionZ; + recvData >> Orientation; // o (3.141593 = 180 degrees) sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Received CMSG_WORLD_TELEPORT"); if (GetPlayer()->isInFlight()) { - sLog->outDebug(LOG_FILTER_NETWORKIO, "Player '%s' (GUID: %u) in flight, ignore worldport command.", GetPlayer()->GetName(), GetPlayer()->GetGUIDLow()); + sLog->outDebug(LOG_FILTER_NETWORKIO, "Player '%s' (GUID: %u) in flight, ignore worldport command.", + GetPlayer()->GetName().c_str(), GetPlayer()->GetGUIDLow()); return; } - sLog->outDebug(LOG_FILTER_NETWORKIO, "CMSG_WORLD_TELEPORT: Player = %s, Time = %u, map = %u, x = %f, y = %f, z = %f, o = %f", GetPlayer()->GetName(), time, mapid, PositionX, PositionY, PositionZ, Orientation); + sLog->outDebug(LOG_FILTER_NETWORKIO, "CMSG_WORLD_TELEPORT: Player = %s, Time = %u, map = %u, x = %f, y = %f, z = %f, o = %f", + GetPlayer()->GetName().c_str(), time, mapid, PositionX, PositionY, PositionZ, Orientation); if (AccountMgr::IsAdminAccount(GetSecurity())) GetPlayer()->TeleportTo(mapid, PositionX, PositionY, PositionZ, Orientation); @@ -1283,11 +1257,11 @@ void WorldSession::HandleWorldTeleportOpcode(WorldPacket& recv_data) SendNotification(LANG_YOU_NOT_HAVE_PERMISSION); } -void WorldSession::HandleWhoisOpcode(WorldPacket& recv_data) +void WorldSession::HandleWhoisOpcode(WorldPacket& recvData) { sLog->outDebug(LOG_FILTER_NETWORKIO, "Received opcode CMSG_WHOIS"); std::string charname; - recv_data >> charname; + recvData >> charname; if (!AccountMgr::IsAdminAccount(GetSecurity())) { @@ -1301,7 +1275,7 @@ void WorldSession::HandleWhoisOpcode(WorldPacket& recv_data) return; } - Player* player = sObjectAccessor->FindPlayerByName(charname.c_str()); + Player* player = sObjectAccessor->FindPlayerByName(charname); if (!player) { @@ -1340,10 +1314,11 @@ void WorldSession::HandleWhoisOpcode(WorldPacket& recv_data) data << msg; SendPacket(&data); - sLog->outDebug(LOG_FILTER_NETWORKIO, "Received whois command from player %s for character %s", GetPlayer()->GetName(), charname.c_str()); + sLog->outDebug(LOG_FILTER_NETWORKIO, "Received whois command from player %s for character %s", + GetPlayer()->GetName().c_str(), charname.c_str()); } -void WorldSession::HandleComplainOpcode(WorldPacket & recv_data) +void WorldSession::HandleComplainOpcode(WorldPacket& recvData) { sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: CMSG_COMPLAIN"); @@ -1354,21 +1329,21 @@ void WorldSession::HandleComplainOpcode(WorldPacket & recv_data) uint32 unk3 = 0; uint32 unk4 = 0; std::string description = ""; - recv_data >> spam_type; // unk 0x01 const, may be spam type (mail/chat) - recv_data >> spammer_guid; // player guid + recvData >> spam_type; // unk 0x01 const, may be spam type (mail/chat) + recvData >> spammer_guid; // player guid switch (spam_type) { case 0: - recv_data >> unk1; // const 0 - recv_data >> unk2; // probably mail id - recv_data >> unk3; // const 0 + recvData >> unk1; // const 0 + recvData >> unk2; // probably mail id + recvData >> unk3; // const 0 break; case 1: - recv_data >> unk1; // probably language - recv_data >> unk2; // message type? - recv_data >> unk3; // probably channel id - recv_data >> unk4; // unk random value - recv_data >> description; // spam description string (messagetype, channel name, player name, message) + recvData >> unk1; // probably language + recvData >> unk2; // message type? + recvData >> unk3; // probably channel id + recvData >> unk4; // unk random value + recvData >> description; // spam description string (messagetype, channel name, player name, message) break; } @@ -1383,13 +1358,13 @@ void WorldSession::HandleComplainOpcode(WorldPacket & recv_data) sLog->outDebug(LOG_FILTER_NETWORKIO, "REPORT SPAM: type %u, guid %u, unk1 %u, unk2 %u, unk3 %u, unk4 %u, message %s", spam_type, GUID_LOPART(spammer_guid), unk1, unk2, unk3, unk4, description.c_str()); } -void WorldSession::HandleRealmSplitOpcode(WorldPacket & recv_data) +void WorldSession::HandleRealmSplitOpcode(WorldPacket& recvData) { sLog->outDebug(LOG_FILTER_NETWORKIO, "CMSG_REALM_SPLIT"); uint32 unk; std::string split_date = "01/01/01"; - recv_data >> unk; + recvData >> unk; WorldPacket data(SMSG_REALM_SPLIT, 4+4+split_date.size()+1); data << unk; @@ -1403,12 +1378,12 @@ void WorldSession::HandleRealmSplitOpcode(WorldPacket & recv_data) //sLog->outDebug("response sent %u", unk); } -void WorldSession::HandleFarSightOpcode(WorldPacket & recv_data) +void WorldSession::HandleFarSightOpcode(WorldPacket& recvData) { sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: CMSG_FAR_SIGHT"); uint8 apply; - recv_data >> apply; + recvData >> apply; switch (apply) { @@ -1421,7 +1396,7 @@ void WorldSession::HandleFarSightOpcode(WorldPacket & recv_data) if (WorldObject* target = _player->GetViewpoint()) _player->SetSeer(target); else - sLog->outError(LOG_FILTER_NETWORKIO, "Player %s requests non-existing seer " UI64FMTD, _player->GetName(), _player->GetUInt64Value(PLAYER_FARSIGHT)); + sLog->outError(LOG_FILTER_NETWORKIO, "Player %s requests non-existing seer " UI64FMTD, _player->GetName().c_str(), _player->GetUInt64Value(PLAYER_FARSIGHT)); break; default: sLog->outDebug(LOG_FILTER_NETWORKIO, "Unhandled mode in CMSG_FAR_SIGHT: %u", apply); @@ -1431,12 +1406,12 @@ void WorldSession::HandleFarSightOpcode(WorldPacket & recv_data) GetPlayer()->UpdateVisibilityForPlayer(); } -void WorldSession::HandleSetTitleOpcode(WorldPacket & recv_data) +void WorldSession::HandleSetTitleOpcode(WorldPacket& recvData) { sLog->outDebug(LOG_FILTER_NETWORKIO, "CMSG_SET_TITLE"); int32 title; - recv_data >> title; + recvData >> title; // -1 at none if (title > 0 && title < MAX_TITLE_INDEX) @@ -1450,15 +1425,15 @@ void WorldSession::HandleSetTitleOpcode(WorldPacket & recv_data) GetPlayer()->SetUInt32Value(PLAYER_CHOSEN_TITLE, title); } -void WorldSession::HandleTimeSyncResp(WorldPacket & recv_data) +void WorldSession::HandleTimeSyncResp(WorldPacket& recvData) { sLog->outDebug(LOG_FILTER_NETWORKIO, "CMSG_TIME_SYNC_RESP"); uint32 counter, clientTicks; - recv_data >> counter >> clientTicks; + recvData >> counter >> clientTicks; if (counter != _player->m_timeSyncCounter - 1) - sLog->outDebug(LOG_FILTER_NETWORKIO, "Wrong time sync counter from player %s (cheater?)", _player->GetName()); + sLog->outDebug(LOG_FILTER_NETWORKIO, "Wrong time sync counter from player %s (cheater?)", _player->GetName().c_str()); sLog->outDebug(LOG_FILTER_NETWORKIO, "Time sync received: counter %u, client ticks %u, time since last sync %u", counter, clientTicks, clientTicks - _player->m_timeSyncClient); @@ -1470,7 +1445,7 @@ void WorldSession::HandleTimeSyncResp(WorldPacket & recv_data) _player->m_timeSyncClient = clientTicks; } -void WorldSession::HandleResetInstancesOpcode(WorldPacket & /*recv_data*/) +void WorldSession::HandleResetInstancesOpcode(WorldPacket& /*recvData*/) { sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: CMSG_RESET_INSTANCES"); @@ -1483,12 +1458,12 @@ void WorldSession::HandleResetInstancesOpcode(WorldPacket & /*recv_data*/) _player->ResetInstances(INSTANCE_RESET_ALL, false); } -void WorldSession::HandleSetDungeonDifficultyOpcode(WorldPacket & recv_data) +void WorldSession::HandleSetDungeonDifficultyOpcode(WorldPacket& recvData) { sLog->outDebug(LOG_FILTER_NETWORKIO, "MSG_SET_DUNGEON_DIFFICULTY"); uint32 mode; - recv_data >> mode; + recvData >> mode; if (mode >= MAX_DUNGEON_DIFFICULTY) { @@ -1503,7 +1478,8 @@ void WorldSession::HandleSetDungeonDifficultyOpcode(WorldPacket & recv_data) Map* map = _player->FindMap(); if (map && map->IsDungeon()) { - sLog->outError(LOG_FILTER_NETWORKIO, "WorldSession::HandleSetDungeonDifficultyOpcode: player (Name: %s, GUID: %u) tried to reset the instance while player is inside!", _player->GetName(), _player->GetGUIDLow()); + sLog->outError(LOG_FILTER_NETWORKIO, "WorldSession::HandleSetDungeonDifficultyOpcode: player (Name: %s, GUID: %u) tried to reset the instance while player is inside!", + _player->GetName().c_str(), _player->GetGUIDLow()); return; } @@ -1523,7 +1499,8 @@ void WorldSession::HandleSetDungeonDifficultyOpcode(WorldPacket & recv_data) if (groupGuy->GetMap()->IsNonRaidDungeon()) { - sLog->outError(LOG_FILTER_NETWORKIO, "WorldSession::HandleSetDungeonDifficultyOpcode: player %d tried to reset the instance while group member (Name: %s, GUID: %u) is inside!", _player->GetGUIDLow(), groupGuy->GetName(), groupGuy->GetGUIDLow()); + sLog->outError(LOG_FILTER_NETWORKIO, "WorldSession::HandleSetDungeonDifficultyOpcode: player %d tried to reset the instance while group member (Name: %s, GUID: %u) is inside!", + _player->GetGUIDLow(), groupGuy->GetName().c_str(), groupGuy->GetGUIDLow()); return; } } @@ -1540,12 +1517,12 @@ void WorldSession::HandleSetDungeonDifficultyOpcode(WorldPacket & recv_data) } } -void WorldSession::HandleSetRaidDifficultyOpcode(WorldPacket & recv_data) +void WorldSession::HandleSetRaidDifficultyOpcode(WorldPacket& recvData) { sLog->outDebug(LOG_FILTER_NETWORKIO, "MSG_SET_RAID_DIFFICULTY"); uint32 mode; - recv_data >> mode; + recvData >> mode; if (mode >= MAX_RAID_DIFFICULTY) { @@ -1597,7 +1574,7 @@ void WorldSession::HandleSetRaidDifficultyOpcode(WorldPacket & recv_data) } } -void WorldSession::HandleCancelMountAuraOpcode(WorldPacket & /*recv_data*/) +void WorldSession::HandleCancelMountAuraOpcode(WorldPacket& /*recvData*/) { sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: CMSG_CANCEL_MOUNT_AURA"); @@ -1618,46 +1595,47 @@ void WorldSession::HandleCancelMountAuraOpcode(WorldPacket & /*recv_data*/) _player->RemoveAurasByType(SPELL_AURA_MOUNTED); } -void WorldSession::HandleMoveSetCanFlyAckOpcode(WorldPacket & recv_data) +void WorldSession::HandleMoveSetCanFlyAckOpcode(WorldPacket& recvData) { // fly mode on/off sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: CMSG_MOVE_SET_CAN_FLY_ACK"); uint64 guid; // guid - unused - recv_data.readPackGUID(guid); + recvData.readPackGUID(guid); - recv_data.read_skip<uint32>(); // unk + recvData.read_skip<uint32>(); // unk MovementInfo movementInfo; movementInfo.guid = guid; - ReadMovementInfo(recv_data, &movementInfo); + ReadMovementInfo(recvData, &movementInfo); - recv_data.read_skip<float>(); // unk2 + recvData.read_skip<float>(); // unk2 _player->m_mover->m_movementInfo.flags = movementInfo.GetMovementFlags(); } -void WorldSession::HandleRequestPetInfoOpcode(WorldPacket & /*recv_data */) +void WorldSession::HandleRequestPetInfoOpcode(WorldPacket& /*recvData */) { /* sLog->outDebug(LOG_FILTER_PACKETIO, "WORLD: CMSG_REQUEST_PET_INFO"); - recv_data.hexlike(); + recvData.hexlike(); */ } -void WorldSession::HandleSetTaxiBenchmarkOpcode(WorldPacket & recv_data) +void WorldSession::HandleSetTaxiBenchmarkOpcode(WorldPacket& recvData) { uint8 mode; - recv_data >> mode; + recvData >> mode; sLog->outDebug(LOG_FILTER_NETWORKIO, "Client used \"/timetest %d\" command", mode); } -void WorldSession::HandleQueryInspectAchievements(WorldPacket & recv_data) +void WorldSession::HandleQueryInspectAchievements(WorldPacket& recvData) { uint64 guid; - recv_data.readPackGUID(guid); + recvData.readPackGUID(guid); + sLog->outDebug(LOG_FILTER_NETWORKIO, "CMSG_QUERY_INSPECT_ACHIEVEMENTS [" UI64FMTD "] Inspected Player [" UI64FMTD "]", _player->GetGUID(), guid); Player* player = ObjectAccessor::FindPlayer(guid); if (!player) return; @@ -1665,7 +1643,7 @@ void WorldSession::HandleQueryInspectAchievements(WorldPacket & recv_data) player->SendRespondInspectAchievements(_player); } -void WorldSession::HandleWorldStateUITimerUpdate(WorldPacket& /*recv_data*/) +void WorldSession::HandleWorldStateUITimerUpdate(WorldPacket& /*recvData*/) { // empty opcode sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: CMSG_WORLD_STATE_UI_TIMER_UPDATE"); @@ -1675,7 +1653,7 @@ void WorldSession::HandleWorldStateUITimerUpdate(WorldPacket& /*recv_data*/) SendPacket(&data); } -void WorldSession::HandleReadyForAccountDataTimes(WorldPacket& /*recv_data*/) +void WorldSession::HandleReadyForAccountDataTimes(WorldPacket& /*recvData*/) { // empty opcode sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: CMSG_READY_FOR_ACCOUNT_DATA_TIMES"); @@ -1690,14 +1668,14 @@ void WorldSession::SendSetPhaseShift(uint32 PhaseShift) SendPacket(&data); } // Battlefield and Battleground -void WorldSession::HandleAreaSpiritHealerQueryOpcode(WorldPacket & recv_data) +void WorldSession::HandleAreaSpiritHealerQueryOpcode(WorldPacket& recvData) { sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: CMSG_AREA_SPIRIT_HEALER_QUERY"); Battleground* bg = _player->GetBattleground(); uint64 guid; - recv_data >> guid; + recvData >> guid; Creature* unit = GetPlayer()->GetMap()->GetCreature(guid); if (!unit) @@ -1713,14 +1691,14 @@ void WorldSession::HandleAreaSpiritHealerQueryOpcode(WorldPacket & recv_data) bf->SendAreaSpiritHealerQueryOpcode(_player,guid); } -void WorldSession::HandleAreaSpiritHealerQueueOpcode(WorldPacket & recv_data) +void WorldSession::HandleAreaSpiritHealerQueueOpcode(WorldPacket& recvData) { sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: CMSG_AREA_SPIRIT_HEALER_QUEUE"); Battleground* bg = _player->GetBattleground(); uint64 guid; - recv_data >> guid; + recvData >> guid; Creature* unit = GetPlayer()->GetMap()->GetCreature(guid); if (!unit) @@ -1736,7 +1714,7 @@ void WorldSession::HandleAreaSpiritHealerQueueOpcode(WorldPacket & recv_data) bf->AddPlayerToResurrectQueue(guid, _player->GetGUID()); } -void WorldSession::HandleHearthAndResurrect(WorldPacket& /*recv_data*/) +void WorldSession::HandleHearthAndResurrect(WorldPacket& /*recvData*/) { if (_player->isInFlight()) return; @@ -1763,7 +1741,8 @@ void WorldSession::HandleInstanceLockResponse(WorldPacket& recvPacket) if (!_player->HasPendingBind()) { - sLog->outInfo(LOG_FILTER_NETWORKIO, "InstanceLockResponse: Player %s (guid %u) tried to bind himself/teleport to graveyard without a pending bind!", _player->GetName(), _player->GetGUIDLow()); + sLog->outInfo(LOG_FILTER_NETWORKIO, "InstanceLockResponse: Player %s (guid %u) tried to bind himself/teleport to graveyard without a pending bind!", + _player->GetName().c_str(), _player->GetGUIDLow()); return; } diff --git a/src/server/game/Handlers/MovementHandler.cpp b/src/server/game/Handlers/MovementHandler.cpp index ca80921a7b2..0eaf3c127b7 100755 --- a/src/server/game/Handlers/MovementHandler.cpp +++ b/src/server/game/Handlers/MovementHandler.cpp @@ -31,7 +31,7 @@ #include "InstanceSaveMgr.h" #include "ObjectMgr.h" -void WorldSession::HandleMoveWorldportAckOpcode(WorldPacket & /*recv_data*/) +void WorldSession::HandleMoveWorldportAckOpcode(WorldPacket & /*recvData*/) { sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: got MSG_MOVE_WORLDPORT_ACK."); HandleMoveWorldportAckOpcode(); @@ -46,7 +46,7 @@ void WorldSession::HandleMoveWorldportAckOpcode() GetPlayer()->SetSemaphoreTeleportFar(false); // get the teleport destination - WorldLocation const loc = GetPlayer()->GetTeleportDest(); + WorldLocation const& loc = GetPlayer()->GetTeleportDest(); // possible errors in the coordinate validity check if (!MapManager::IsValidMapCoord(loc)) @@ -66,7 +66,7 @@ void WorldSession::HandleMoveWorldportAckOpcode() Map* oldMap = GetPlayer()->GetMap(); if (GetPlayer()->IsInWorld()) { - sLog->outError(LOG_FILTER_NETWORKIO, "Player (Name %s) is still in world when teleported from map %u to new map %u", GetPlayer()->GetName(), oldMap->GetId(), loc.GetMapId()); + sLog->outError(LOG_FILTER_NETWORKIO, "Player (Name %s) is still in world when teleported from map %u to new map %u", GetPlayer()->GetName().c_str(), oldMap->GetId(), loc.GetMapId()); oldMap->RemovePlayerFromMap(GetPlayer(), false); } @@ -89,7 +89,8 @@ void WorldSession::HandleMoveWorldportAckOpcode() GetPlayer()->SendInitialPacketsBeforeAddToMap(); if (!GetPlayer()->GetMap()->AddPlayerToMap(GetPlayer())) { - sLog->outError(LOG_FILTER_NETWORKIO, "WORLD: failed to teleport player %s (%d) to map %d because of unknown reason!", GetPlayer()->GetName(), GetPlayer()->GetGUIDLow(), loc.GetMapId()); + sLog->outError(LOG_FILTER_NETWORKIO, "WORLD: failed to teleport player %s (%d) to map %d because of unknown reason!", + GetPlayer()->GetName().c_str(), GetPlayer()->GetGUIDLow(), loc.GetMapId()); GetPlayer()->ResetMap(); GetPlayer()->SetMap(oldMap); GetPlayer()->TeleportTo(GetPlayer()->m_homebindMapId, GetPlayer()->m_homebindX, GetPlayer()->m_homebindY, GetPlayer()->m_homebindZ, GetPlayer()->GetOrientation()); @@ -187,15 +188,15 @@ void WorldSession::HandleMoveWorldportAckOpcode() GetPlayer()->ProcessDelayedOperations(); } -void WorldSession::HandleMoveTeleportAck(WorldPacket& recv_data) +void WorldSession::HandleMoveTeleportAck(WorldPacket& recvData) { sLog->outDebug(LOG_FILTER_NETWORKIO, "MSG_MOVE_TELEPORT_ACK"); uint64 guid; - recv_data.readPackGUID(guid); + recvData.readPackGUID(guid); uint32 flags, time; - recv_data >> flags >> time; + recvData >> flags >> time; sLog->outDebug(LOG_FILTER_NETWORKIO, "Guid " UI64FMTD, guid); sLog->outDebug(LOG_FILTER_NETWORKIO, "Flags %u, time %u", flags, time/IN_MILLISECONDS); @@ -406,9 +407,9 @@ void WorldSession::HandleMovementOpcodes(WorldPacket & recvData) } } -void WorldSession::HandleForceSpeedChangeAck(WorldPacket &recv_data) +void WorldSession::HandleForceSpeedChangeAck(WorldPacket &recvData) { - uint32 opcode = recv_data.GetOpcode(); + uint32 opcode = recvData.GetOpcode(); sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Recvd %s (%u, 0x%X) opcode", LookupOpcodeName(opcode), opcode, opcode); /* extract packet */ @@ -416,24 +417,24 @@ void WorldSession::HandleForceSpeedChangeAck(WorldPacket &recv_data) uint32 unk1; float newspeed; - recv_data.readPackGUID(guid); + recvData.readPackGUID(guid); // now can skip not our packet if (_player->GetGUID() != guid) { - recv_data.rfinish(); // prevent warnings spam + recvData.rfinish(); // prevent warnings spam return; } // continue parse packet - recv_data >> unk1; // counter or moveEvent + recvData >> unk1; // counter or moveEvent MovementInfo movementInfo; movementInfo.guid = guid; - ReadMovementInfo(recv_data, &movementInfo); + ReadMovementInfo(recvData, &movementInfo); - recv_data >> newspeed; + recvData >> newspeed; /*----------------*/ // client ACK send one packet for mounted/run case and need skip all except last from its @@ -473,24 +474,24 @@ void WorldSession::HandleForceSpeedChangeAck(WorldPacket &recv_data) if (_player->GetSpeed(move_type) > newspeed) // must be greater - just correct { sLog->outError(LOG_FILTER_NETWORKIO, "%sSpeedChange player %s is NOT correct (must be %f instead %f), force set to correct value", - move_type_name[move_type], _player->GetName(), _player->GetSpeed(move_type), newspeed); + move_type_name[move_type], _player->GetName().c_str(), _player->GetSpeed(move_type), newspeed); _player->SetSpeed(move_type, _player->GetSpeedRate(move_type), true); } else // must be lesser - cheating { sLog->outDebug(LOG_FILTER_GENERAL, "Player %s from account id %u kicked for incorrect speed (must be %f instead %f)", - _player->GetName(), _player->GetSession()->GetAccountId(), _player->GetSpeed(move_type), newspeed); + _player->GetName().c_str(), _player->GetSession()->GetAccountId(), _player->GetSpeed(move_type), newspeed); _player->GetSession()->KickPlayer(); } } } -void WorldSession::HandleSetActiveMoverOpcode(WorldPacket &recv_data) +void WorldSession::HandleSetActiveMoverOpcode(WorldPacket &recvData) { sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Recvd CMSG_SET_ACTIVE_MOVER"); uint64 guid; - recv_data >> guid; + recvData >> guid; if (GetPlayer()->IsInWorld()) { @@ -499,22 +500,22 @@ void WorldSession::HandleSetActiveMoverOpcode(WorldPacket &recv_data) } } -void WorldSession::HandleMoveNotActiveMover(WorldPacket &recv_data) +void WorldSession::HandleMoveNotActiveMover(WorldPacket &recvData) { sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Recvd CMSG_MOVE_NOT_ACTIVE_MOVER"); uint64 old_mover_guid; - recv_data.readPackGUID(old_mover_guid); + recvData.readPackGUID(old_mover_guid); MovementInfo mi; - ReadMovementInfo(recv_data, &mi); + ReadMovementInfo(recvData, &mi); mi.guid = old_mover_guid; _player->m_movementInfo = mi; } -void WorldSession::HandleMountSpecialAnimOpcode(WorldPacket& /*recv_data*/) +void WorldSession::HandleMountSpecialAnimOpcode(WorldPacket& /*recvData*/) { WorldPacket data(SMSG_MOUNTSPECIAL_ANIM, 8); data << uint64(GetPlayer()->GetGUID()); @@ -522,20 +523,20 @@ void WorldSession::HandleMountSpecialAnimOpcode(WorldPacket& /*recv_data*/) GetPlayer()->SendMessageToSet(&data, false); } -void WorldSession::HandleMoveKnockBackAck(WorldPacket & recv_data) +void WorldSession::HandleMoveKnockBackAck(WorldPacket & recvData) { sLog->outDebug(LOG_FILTER_NETWORKIO, "CMSG_MOVE_KNOCK_BACK_ACK"); uint64 guid; - recv_data.readPackGUID(guid); + recvData.readPackGUID(guid); if (_player->m_mover->GetGUID() != guid) return; - recv_data.read_skip<uint32>(); // unk + recvData.read_skip<uint32>(); // unk MovementInfo movementInfo; - ReadMovementInfo(recv_data, &movementInfo); + ReadMovementInfo(recvData, &movementInfo); _player->m_movementInfo = movementInfo; @@ -552,45 +553,45 @@ void WorldSession::HandleMoveKnockBackAck(WorldPacket & recv_data) _player->SendMessageToSet(&data, false); } -void WorldSession::HandleMoveHoverAck(WorldPacket& recv_data) +void WorldSession::HandleMoveHoverAck(WorldPacket& recvData) { sLog->outDebug(LOG_FILTER_NETWORKIO, "CMSG_MOVE_HOVER_ACK"); uint64 guid; // guid - unused - recv_data.readPackGUID(guid); + recvData.readPackGUID(guid); - recv_data.read_skip<uint32>(); // unk + recvData.read_skip<uint32>(); // unk MovementInfo movementInfo; - ReadMovementInfo(recv_data, &movementInfo); + ReadMovementInfo(recvData, &movementInfo); - recv_data.read_skip<uint32>(); // unk2 + recvData.read_skip<uint32>(); // unk2 } -void WorldSession::HandleMoveWaterWalkAck(WorldPacket& recv_data) +void WorldSession::HandleMoveWaterWalkAck(WorldPacket& recvData) { sLog->outDebug(LOG_FILTER_NETWORKIO, "CMSG_MOVE_WATER_WALK_ACK"); uint64 guid; // guid - unused - recv_data.readPackGUID(guid); + recvData.readPackGUID(guid); - recv_data.read_skip<uint32>(); // unk + recvData.read_skip<uint32>(); // unk MovementInfo movementInfo; - ReadMovementInfo(recv_data, &movementInfo); + ReadMovementInfo(recvData, &movementInfo); - recv_data.read_skip<uint32>(); // unk2 + recvData.read_skip<uint32>(); // unk2 } -void WorldSession::HandleSummonResponseOpcode(WorldPacket& recv_data) +void WorldSession::HandleSummonResponseOpcode(WorldPacket& recvData) { if (!_player->isAlive() || _player->isInCombat()) return; uint64 summoner_guid; bool agree; - recv_data >> summoner_guid; - recv_data >> agree; + recvData >> summoner_guid; + recvData >> agree; _player->SummonIfPossible(agree); } diff --git a/src/server/game/Handlers/NPCHandler.cpp b/src/server/game/Handlers/NPCHandler.cpp index 085e3c49157..0265d1e6f60 100755 --- a/src/server/game/Handlers/NPCHandler.cpp +++ b/src/server/game/Handlers/NPCHandler.cpp @@ -47,10 +47,10 @@ enum StableResultCode STABLE_ERR_EXOTIC = 0x0C // "you are unable to control exotic creatures" }; -void WorldSession::HandleTabardVendorActivateOpcode(WorldPacket & recv_data) +void WorldSession::HandleTabardVendorActivateOpcode(WorldPacket & recvData) { uint64 guid; - recv_data >> guid; + recvData >> guid; Creature* unit = GetPlayer()->GetNPCIfCanInteractWith(guid, UNIT_NPC_FLAG_TABARDDESIGNER); if (!unit) @@ -73,13 +73,13 @@ void WorldSession::SendTabardVendorActivate(uint64 guid) SendPacket(&data); } -void WorldSession::HandleBankerActivateOpcode(WorldPacket & recv_data) +void WorldSession::HandleBankerActivateOpcode(WorldPacket & recvData) { uint64 guid; sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Received CMSG_BANKER_ACTIVATE"); - recv_data >> guid; + recvData >> guid; Creature* unit = GetPlayer()->GetNPCIfCanInteractWith(guid, UNIT_NPC_FLAG_BANKER); if (!unit) @@ -102,11 +102,11 @@ void WorldSession::SendShowBank(uint64 guid) SendPacket(&data); } -void WorldSession::HandleTrainerListOpcode(WorldPacket & recv_data) +void WorldSession::HandleTrainerListOpcode(WorldPacket & recvData) { uint64 guid; - recv_data >> guid; + recvData >> guid; SendTrainerList(guid); } @@ -234,12 +234,12 @@ void WorldSession::SendTrainerList(uint64 guid, const std::string& strTitle) SendPacket(&data); } -void WorldSession::HandleTrainerBuySpellOpcode(WorldPacket & recv_data) +void WorldSession::HandleTrainerBuySpellOpcode(WorldPacket & recvData) { uint64 guid; uint32 spellId = 0; - recv_data >> guid >> spellId; + recvData >> guid >> spellId; sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Received CMSG_TRAINER_BUY_SPELL NpcGUID=%u, learn spell id is: %u", uint32(GUID_LOPART(guid)), spellId); Creature* unit = GetPlayer()->GetNPCIfCanInteractWith(guid, UNIT_NPC_FLAG_TRAINER); @@ -294,12 +294,12 @@ void WorldSession::HandleTrainerBuySpellOpcode(WorldPacket & recv_data) SendPacket(&data); } -void WorldSession::HandleGossipHelloOpcode(WorldPacket & recv_data) +void WorldSession::HandleGossipHelloOpcode(WorldPacket & recvData) { sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Received CMSG_GOSSIP_HELLO"); uint64 guid; - recv_data >> guid; + recvData >> guid; Creature* unit = GetPlayer()->GetNPCIfCanInteractWith(guid, UNIT_NPC_FLAG_NONE); if (!unit) @@ -343,7 +343,7 @@ void WorldSession::HandleGossipHelloOpcode(WorldPacket & recv_data) unit->AI()->sGossipHello(_player); } -/*void WorldSession::HandleGossipSelectOptionOpcode(WorldPacket & recv_data) +/*void WorldSession::HandleGossipSelectOptionOpcode(WorldPacket & recvData) { sLog->outDebug(LOG_FILTER_PACKETIO, "WORLD: CMSG_GOSSIP_SELECT_OPTION"); @@ -352,12 +352,12 @@ void WorldSession::HandleGossipHelloOpcode(WorldPacket & recv_data) uint64 guid; std::string code = ""; - recv_data >> guid >> unk >> option; + recvData >> guid >> unk >> option; if (_player->PlayerTalkClass->GossipOptionCoded(option)) { sLog->outDebug(LOG_FILTER_PACKETIO, "reading string"); - recv_data >> code; + recvData >> code; sLog->outDebug(LOG_FILTER_PACKETIO, "string read: %s", code.c_str()); } @@ -384,13 +384,13 @@ void WorldSession::HandleGossipHelloOpcode(WorldPacket & recv_data) } }*/ -void WorldSession::HandleSpiritHealerActivateOpcode(WorldPacket & recv_data) +void WorldSession::HandleSpiritHealerActivateOpcode(WorldPacket & recvData) { sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: CMSG_SPIRIT_HEALER_ACTIVATE"); uint64 guid; - recv_data >> guid; + recvData >> guid; Creature* unit = GetPlayer()->GetNPCIfCanInteractWith(guid, UNIT_NPC_FLAG_SPIRITHEALER); if (!unit) @@ -439,10 +439,10 @@ void WorldSession::SendSpiritResurrect() _player->UpdateObjectVisibility(); } -void WorldSession::HandleBinderActivateOpcode(WorldPacket & recv_data) +void WorldSession::HandleBinderActivateOpcode(WorldPacket & recvData) { uint64 npcGUID; - recv_data >> npcGUID; + recvData >> npcGUID; if (!GetPlayer()->IsInWorld() || !GetPlayer()->isAlive()) return; @@ -496,12 +496,12 @@ void WorldSession::SendBindPoint(Creature* npc) _player->PlayerTalkClass->SendCloseGossip(); } -void WorldSession::HandleListStabledPetsOpcode(WorldPacket & recv_data) +void WorldSession::HandleListStabledPetsOpcode(WorldPacket & recvData) { sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Recv MSG_LIST_STABLED_PETS"); uint64 npcGUID; - recv_data >> npcGUID; + recvData >> npcGUID; if (!CheckStableMaster(npcGUID)) return; @@ -589,12 +589,12 @@ void WorldSession::SendStableResult(uint8 res) SendPacket(&data); } -void WorldSession::HandleStablePet(WorldPacket & recv_data) +void WorldSession::HandleStablePet(WorldPacket & recvData) { sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Recv CMSG_STABLE_PET"); uint64 npcGUID; - recv_data >> npcGUID; + recvData >> npcGUID; if (!GetPlayer()->isAlive()) { @@ -664,13 +664,13 @@ void WorldSession::HandleStablePetCallback(PreparedQueryResult result) SendStableResult(STABLE_ERR_STABLE); } -void WorldSession::HandleUnstablePet(WorldPacket & recv_data) +void WorldSession::HandleUnstablePet(WorldPacket & recvData) { sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Recv CMSG_UNSTABLE_PET."); uint64 npcGUID; uint32 petnumber; - recv_data >> npcGUID >> petnumber; + recvData >> npcGUID >> petnumber; if (!CheckStableMaster(npcGUID)) { @@ -745,12 +745,12 @@ void WorldSession::HandleUnstablePetCallback(PreparedQueryResult result, uint32 SendStableResult(STABLE_SUCCESS_UNSTABLE); } -void WorldSession::HandleBuyStableSlot(WorldPacket & recv_data) +void WorldSession::HandleBuyStableSlot(WorldPacket & recvData) { sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Recv CMSG_BUY_STABLE_SLOT."); uint64 npcGUID; - recv_data >> npcGUID; + recvData >> npcGUID; if (!CheckStableMaster(npcGUID)) { @@ -778,18 +778,18 @@ void WorldSession::HandleBuyStableSlot(WorldPacket & recv_data) SendStableResult(STABLE_ERR_STABLE); } -void WorldSession::HandleStableRevivePet(WorldPacket &/* recv_data */) +void WorldSession::HandleStableRevivePet(WorldPacket &/* recvData */) { sLog->outDebug(LOG_FILTER_NETWORKIO, "HandleStableRevivePet: Not implemented"); } -void WorldSession::HandleStableSwapPet(WorldPacket & recv_data) +void WorldSession::HandleStableSwapPet(WorldPacket & recvData) { sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Recv CMSG_STABLE_SWAP_PET."); uint64 npcGUID; uint32 petId; - recv_data >> npcGUID >> petId; + recvData >> npcGUID >> petId; if (!CheckStableMaster(npcGUID)) { @@ -875,14 +875,14 @@ void WorldSession::HandleStableSwapPetCallback(PreparedQueryResult result, uint3 SendStableResult(STABLE_SUCCESS_UNSTABLE); } -void WorldSession::HandleRepairItemOpcode(WorldPacket & recv_data) +void WorldSession::HandleRepairItemOpcode(WorldPacket & recvData) { sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: CMSG_REPAIR_ITEM"); uint64 npcGUID, itemGUID; uint8 guildBank; // new in 2.3.2, bool that means from guild bank money - recv_data >> npcGUID >> itemGUID >> guildBank; + recvData >> npcGUID >> itemGUID >> guildBank; Creature* unit = GetPlayer()->GetNPCIfCanInteractWith(npcGUID, UNIT_NPC_FLAG_REPAIR); if (!unit) diff --git a/src/server/game/Handlers/PetHandler.cpp b/src/server/game/Handlers/PetHandler.cpp index f8cb0344a96..7ed5e3846ef 100755 --- a/src/server/game/Handlers/PetHandler.cpp +++ b/src/server/game/Handlers/PetHandler.cpp @@ -32,10 +32,10 @@ #include "Group.h" #include "SpellInfo.h" -void WorldSession::HandleDismissCritter(WorldPacket &recv_data) +void WorldSession::HandleDismissCritter(WorldPacket &recvData) { uint64 guid; - recv_data >> guid; + recvData >> guid; sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Received CMSG_DISMISS_CRITTER for GUID " UI64FMTD, guid); @@ -44,7 +44,7 @@ void WorldSession::HandleDismissCritter(WorldPacket &recv_data) if (!pet) { sLog->outDebug(LOG_FILTER_NETWORKIO, "Vanitypet (guid: %u) does not exist - player '%s' (guid: %u / account: %u) attempted to dismiss it (possibly lagged out)", - uint32(GUID_LOPART(guid)), GetPlayer()->GetName(), GetPlayer()->GetGUIDLow(), GetAccountId()); + uint32(GUID_LOPART(guid)), GetPlayer()->GetName().c_str(), GetPlayer()->GetGUIDLow(), GetAccountId()); return; } @@ -55,14 +55,14 @@ void WorldSession::HandleDismissCritter(WorldPacket &recv_data) } } -void WorldSession::HandlePetAction(WorldPacket & recv_data) +void WorldSession::HandlePetAction(WorldPacket & recvData) { uint64 guid1; uint32 data; uint64 guid2; - recv_data >> guid1; //pet guid - recv_data >> data; - recv_data >> guid2; //tag guid + recvData >> guid1; //pet guid + recvData >> data; + recvData >> guid2; //tag guid uint32 spellid = UNIT_ACTION_BUTTON_ACTION(data); uint8 flag = UNIT_ACTION_BUTTON_TYPE(data); //delete = 0x07 CastSpell = C1 @@ -73,13 +73,13 @@ void WorldSession::HandlePetAction(WorldPacket & recv_data) if (!pet) { - sLog->outError(LOG_FILTER_NETWORKIO, "HandlePetAction: Pet (GUID: %u) doesn't exist for player '%s'", uint32(GUID_LOPART(guid1)), GetPlayer()->GetName()); + sLog->outError(LOG_FILTER_NETWORKIO, "HandlePetAction: Pet (GUID: %u) doesn't exist for player '%s'", uint32(GUID_LOPART(guid1)), GetPlayer()->GetName().c_str()); return; } if (pet != GetPlayer()->GetFirstControlled()) { - sLog->outError(LOG_FILTER_NETWORKIO, "HandlePetAction: Pet (GUID: %u) does not belong to player '%s'", uint32(GUID_LOPART(guid1)), GetPlayer()->GetName()); + sLog->outError(LOG_FILTER_NETWORKIO, "HandlePetAction: Pet (GUID: %u) does not belong to player '%s'", uint32(GUID_LOPART(guid1)), GetPlayer()->GetName().c_str()); return; } @@ -110,10 +110,10 @@ void WorldSession::HandlePetAction(WorldPacket & recv_data) } } -void WorldSession::HandlePetStopAttack(WorldPacket &recv_data) +void WorldSession::HandlePetStopAttack(WorldPacket &recvData) { uint64 guid; - recv_data >> guid; + recvData >> guid; sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Received CMSG_PET_STOP_ATTACK for GUID " UI64FMTD "", guid); @@ -127,7 +127,8 @@ void WorldSession::HandlePetStopAttack(WorldPacket &recv_data) if (pet != GetPlayer()->GetPet() && pet != GetPlayer()->GetCharm()) { - sLog->outError(LOG_FILTER_NETWORKIO, "HandlePetStopAttack: Pet GUID %u isn't a pet or charmed creature of player %s", uint32(GUID_LOPART(guid)), GetPlayer()->GetName()); + sLog->outError(LOG_FILTER_NETWORKIO, "HandlePetStopAttack: Pet GUID %u isn't a pet or charmed creature of player %s", + uint32(GUID_LOPART(guid)), GetPlayer()->GetName().c_str()); return; } @@ -394,15 +395,15 @@ void WorldSession::HandlePetActionHelper(Unit* pet, uint64 guid1, uint16 spellid } } -void WorldSession::HandlePetNameQuery(WorldPacket & recv_data) +void WorldSession::HandlePetNameQuery(WorldPacket & recvData) { sLog->outInfo(LOG_FILTER_NETWORKIO, "HandlePetNameQuery. CMSG_PET_NAME_QUERY"); uint32 petnumber; uint64 petguid; - recv_data >> petnumber; - recv_data >> petguid; + recvData >> petnumber; + recvData >> petguid; SendPetNameQuery(petguid, petnumber); } @@ -421,11 +422,9 @@ void WorldSession::SendPetNameQuery(uint64 petguid, uint32 petnumber) return; } - std::string name = pet->GetName(); - - WorldPacket data(SMSG_PET_NAME_QUERY_RESPONSE, (4+4+name.size()+1)); + WorldPacket data(SMSG_PET_NAME_QUERY_RESPONSE, (4+4+pet->GetName().size()+1)); data << uint32(petnumber); - data << name.c_str(); + data << pet->GetName(); data << uint32(pet->GetUInt32Value(UNIT_FIELD_PET_NAME_TIMESTAMP)); if (pet->isPet() && ((Pet*)pet)->GetDeclinedNames()) @@ -463,14 +462,14 @@ bool WorldSession::CheckStableMaster(uint64 guid) return true; } -void WorldSession::HandlePetSetAction(WorldPacket & recv_data) +void WorldSession::HandlePetSetAction(WorldPacket & recvData) { sLog->outInfo(LOG_FILTER_NETWORKIO, "HandlePetSetAction. CMSG_PET_SET_ACTION"); uint64 petguid; uint8 count; - recv_data >> petguid; + recvData >> petguid; Unit* pet = ObjectAccessor::GetUnit(*_player, petguid); @@ -487,7 +486,7 @@ void WorldSession::HandlePetSetAction(WorldPacket & recv_data) return; } - count = (recv_data.size() == 24) ? 2 : 1; + count = (recvData.size() == 24) ? 2 : 1; uint32 position[2]; uint32 data[2]; @@ -495,8 +494,8 @@ void WorldSession::HandlePetSetAction(WorldPacket & recv_data) for (uint8 i = 0; i < count; ++i) { - recv_data >> position[i]; - recv_data >> data[i]; + recvData >> position[i]; + recvData >> data[i]; uint8 act_state = UNIT_ACTION_BUTTON_TYPE(data[i]); @@ -545,7 +544,8 @@ void WorldSession::HandlePetSetAction(WorldPacket & recv_data) uint32 spell_id = UNIT_ACTION_BUTTON_ACTION(data[i]); uint8 act_state = UNIT_ACTION_BUTTON_TYPE(data[i]); - sLog->outInfo(LOG_FILTER_NETWORKIO, "Player %s has changed pet spell action. Position: %u, Spell: %u, State: 0x%X", _player->GetName(), position[i], spell_id, uint32(act_state)); + sLog->outInfo(LOG_FILTER_NETWORKIO, "Player %s has changed pet spell action. Position: %u, Spell: %u, State: 0x%X", + _player->GetName().c_str(), 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))) @@ -579,7 +579,7 @@ void WorldSession::HandlePetSetAction(WorldPacket & recv_data) } } -void WorldSession::HandlePetRename(WorldPacket & recv_data) +void WorldSession::HandlePetRename(WorldPacket & recvData) { sLog->outInfo(LOG_FILTER_NETWORKIO, "HandlePetRename. CMSG_PET_RENAME"); @@ -589,9 +589,9 @@ void WorldSession::HandlePetRename(WorldPacket & recv_data) std::string name; DeclinedName declinedname; - recv_data >> petguid; - recv_data >> name; - recv_data >> isdeclined; + recvData >> petguid; + recvData >> name; + recvData >> isdeclined; Pet* pet = ObjectAccessor::FindPet(petguid); // check it! @@ -625,7 +625,7 @@ void WorldSession::HandlePetRename(WorldPacket & recv_data) { for (uint8 i = 0; i < MAX_DECLINED_NAME_CASES; ++i) { - recv_data >> declinedname.name[i]; + recvData >> declinedname.name[i]; } std::wstring wname; @@ -664,10 +664,10 @@ void WorldSession::HandlePetRename(WorldPacket & recv_data) pet->SetUInt32Value(UNIT_FIELD_PET_NAME_TIMESTAMP, uint32(time(NULL))); // cast can't be helped } -void WorldSession::HandlePetAbandon(WorldPacket & recv_data) +void WorldSession::HandlePetAbandon(WorldPacket & recvData) { uint64 guid; - recv_data >> guid; //pet guid + recvData >> guid; //pet guid sLog->outInfo(LOG_FILTER_NETWORKIO, "HandlePetAbandon. CMSG_PET_ABANDON pet guid is %u", GUID_LOPART(guid)); if (!_player->IsInWorld()) @@ -710,13 +710,13 @@ void WorldSession::HandlePetSpellAutocastOpcode(WorldPacket& recvPacket) if (!pet || (pet != _player->GetGuardianPet() && pet != _player->GetCharm())) { - sLog->outError(LOG_FILTER_NETWORKIO, "HandlePetSpellAutocastOpcode.Pet %u isn't pet of player %s .", uint32(GUID_LOPART(guid)), GetPlayer()->GetName()); + sLog->outError(LOG_FILTER_NETWORKIO, "HandlePetSpellAutocastOpcode.Pet %u isn't pet of player %s .", uint32(GUID_LOPART(guid)), GetPlayer()->GetName().c_str()); return; } SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellid); // do not add not learned spells/ passive spells - if (!pet->HasSpell(spellid) || spellInfo->IsAutocastable()) + if (!pet->HasSpell(spellid) || !spellInfo->IsAutocastable()) return; CharmInfo* charmInfo = pet->GetCharmInfo(); @@ -755,7 +755,7 @@ void WorldSession::HandlePetCastSpellOpcode(WorldPacket& recvPacket) if (!caster || (caster != _player->GetGuardianPet() && caster != _player->GetCharm())) { - sLog->outError(LOG_FILTER_NETWORKIO, "HandlePetCastSpellOpcode: Pet %u isn't pet of player %s .", uint32(GUID_LOPART(guid)), GetPlayer()->GetName()); + sLog->outError(LOG_FILTER_NETWORKIO, "HandlePetCastSpellOpcode: Pet %u isn't pet of player %s .", uint32(GUID_LOPART(guid)), GetPlayer()->GetName().c_str()); return; } @@ -848,33 +848,33 @@ void WorldSession::SendPetNameInvalid(uint32 error, const std::string& name, Dec SendPacket(&data); } -void WorldSession::HandlePetLearnTalent(WorldPacket & recv_data) +void WorldSession::HandlePetLearnTalent(WorldPacket & recvData) { sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: CMSG_PET_LEARN_TALENT"); uint64 guid; uint32 talent_id, requested_rank; - recv_data >> guid >> talent_id >> requested_rank; + recvData >> guid >> talent_id >> requested_rank; _player->LearnPetTalent(guid, talent_id, requested_rank); _player->SendTalentsInfoData(true); } -void WorldSession::HandleLearnPreviewTalentsPet(WorldPacket & recv_data) +void WorldSession::HandleLearnPreviewTalentsPet(WorldPacket & recvData) { sLog->outDebug(LOG_FILTER_NETWORKIO, "CMSG_LEARN_PREVIEW_TALENTS_PET"); uint64 guid; - recv_data >> guid; + recvData >> guid; uint32 talentsCount; - recv_data >> talentsCount; + recvData >> talentsCount; uint32 talentId, talentRank; for (uint32 i = 0; i < talentsCount; ++i) { - recv_data >> talentId >> talentRank; + recvData >> talentId >> talentRank; _player->LearnPetTalent(guid, talentId, talentRank); } diff --git a/src/server/game/Handlers/PetitionsHandler.cpp b/src/server/game/Handlers/PetitionsHandler.cpp index 90af03113bf..0da9c762ca9 100755 --- a/src/server/game/Handlers/PetitionsHandler.cpp +++ b/src/server/game/Handlers/PetitionsHandler.cpp @@ -33,12 +33,6 @@ #define CHARTER_DISPLAY_ID 16161 -/*enum PetitionType // dbc data -{ - PETITION_TYPE_GUILD = 1, - PETITION_TYPE_ARENA_TEAM = 3 -};*/ - // Charters ID in item_template enum CharterItemIDs { @@ -56,7 +50,7 @@ enum CharterCosts ARENA_TEAM_CHARTER_5v5_COST = 2000000 }; -void WorldSession::HandlePetitionBuyOpcode(WorldPacket & recv_data) +void WorldSession::HandlePetitionBuyOpcode(WorldPacket & recvData) { sLog->outDebug(LOG_FILTER_NETWORKIO, "Received opcode CMSG_PETITION_BUY"); @@ -64,28 +58,28 @@ void WorldSession::HandlePetitionBuyOpcode(WorldPacket & recv_data) uint32 clientIndex; // 1 for guild and arenaslot+1 for arenas in client std::string name; - recv_data >> guidNPC; // NPC GUID - recv_data.read_skip<uint32>(); // 0 - recv_data.read_skip<uint64>(); // 0 - recv_data >> name; // name - recv_data.read_skip<std::string>(); // some string - recv_data.read_skip<uint32>(); // 0 - recv_data.read_skip<uint32>(); // 0 - recv_data.read_skip<uint32>(); // 0 - recv_data.read_skip<uint32>(); // 0 - recv_data.read_skip<uint32>(); // 0 - recv_data.read_skip<uint32>(); // 0 - recv_data.read_skip<uint32>(); // 0 - recv_data.read_skip<uint16>(); // 0 - recv_data.read_skip<uint32>(); // 0 - recv_data.read_skip<uint32>(); // 0 - recv_data.read_skip<uint32>(); // 0 + recvData >> guidNPC; // NPC GUID + recvData.read_skip<uint32>(); // 0 + recvData.read_skip<uint64>(); // 0 + recvData >> name; // name + recvData.read_skip<std::string>(); // some string + recvData.read_skip<uint32>(); // 0 + recvData.read_skip<uint32>(); // 0 + recvData.read_skip<uint32>(); // 0 + recvData.read_skip<uint32>(); // 0 + recvData.read_skip<uint32>(); // 0 + recvData.read_skip<uint32>(); // 0 + recvData.read_skip<uint32>(); // 0 + recvData.read_skip<uint16>(); // 0 + recvData.read_skip<uint32>(); // 0 + recvData.read_skip<uint32>(); // 0 + recvData.read_skip<uint32>(); // 0 for (int i = 0; i < 10; ++i) - recv_data.read_skip<std::string>(); + recvData.read_skip<std::string>(); - recv_data >> clientIndex; // index - recv_data.read_skip<uint32>(); // 0 + recvData >> clientIndex; // index + recvData.read_skip<uint32>(); // 0 sLog->outDebug(LOG_FILTER_NETWORKIO, "Petitioner with GUID %u tried sell petition: name %s", GUID_LOPART(guidNPC), name.c_str()); @@ -157,12 +151,13 @@ void WorldSession::HandlePetitionBuyOpcode(WorldPacket & recv_data) { if (sGuildMgr->GetGuildByName(name)) { - Guild::SendCommandResult(this, GUILD_CREATE_S, ERR_GUILD_NAME_EXISTS_S, name); + Guild::SendCommandResult(this, GUILD_COMMAND_CREATE, ERR_GUILD_NAME_EXISTS_S, name); return; } + if (sObjectMgr->IsReservedName(name) || !ObjectMgr::IsValidCharterName(name)) { - Guild::SendCommandResult(this, GUILD_CREATE_S, ERR_GUILD_NAME_INVALID, name); + Guild::SendCommandResult(this, GUILD_COMMAND_CREATE, ERR_GUILD_NAME_INVALID, name); return; } } @@ -250,13 +245,13 @@ void WorldSession::HandlePetitionBuyOpcode(WorldPacket & recv_data) CharacterDatabase.CommitTransaction(trans); } -void WorldSession::HandlePetitionShowSignOpcode(WorldPacket& recv_data) +void WorldSession::HandlePetitionShowSignOpcode(WorldPacket& recvData) { sLog->outDebug(LOG_FILTER_NETWORKIO, "Received opcode CMSG_PETITION_SHOW_SIGNATURES"); uint8 signs = 0; uint64 petitionguid; - recv_data >> petitionguid; // petition guid + recvData >> petitionguid; // petition guid // solve (possible) some strange compile problems with explicit use GUID_LOPART(petitionguid) at some GCC versions (wrong code optimization in compiler?) uint32 petitionGuidLow = GUID_LOPART(petitionguid); @@ -269,7 +264,7 @@ void WorldSession::HandlePetitionShowSignOpcode(WorldPacket& recv_data) if (!result) { - sLog->outDebug(LOG_FILTER_PLAYER_ITEMS, "Petition %u is not found for player %u %s", GUID_LOPART(petitionguid), GetPlayer()->GetGUIDLow(), GetPlayer()->GetName()); + sLog->outDebug(LOG_FILTER_PLAYER_ITEMS, "Petition %u is not found for player %u %s", GUID_LOPART(petitionguid), GetPlayer()->GetGUIDLow(), GetPlayer()->GetName().c_str()); return; } Field* fields = result->Fetch(); @@ -310,14 +305,14 @@ void WorldSession::HandlePetitionShowSignOpcode(WorldPacket& recv_data) SendPacket(&data); } -void WorldSession::HandlePetitionQueryOpcode(WorldPacket & recv_data) +void WorldSession::HandlePetitionQueryOpcode(WorldPacket & recvData) { sLog->outDebug(LOG_FILTER_NETWORKIO, "Received opcode CMSG_PETITION_QUERY"); // ok uint32 guildguid; uint64 petitionguid; - recv_data >> guildguid; // in Trinity always same as GUID_LOPART(petitionguid) - recv_data >> petitionguid; // petition guid + recvData >> guildguid; // in Trinity always same as GUID_LOPART(petitionguid) + recvData >> petitionguid; // petition guid sLog->outDebug(LOG_FILTER_NETWORKIO, "CMSG_PETITION_QUERY Petition GUID %u Guild GUID %u", GUID_LOPART(petitionguid), guildguid); SendPetitionQueryOpcode(petitionguid); @@ -355,8 +350,9 @@ void WorldSession::SendPetitionQueryOpcode(uint64 petitionguid) data << uint8(0); // some string if (type == GUILD_CHARTER_TYPE) { - data << uint32(9); - data << uint32(9); + uint32 needed = sWorld->getIntConfig(CONFIG_MIN_PETITION_SIGNS); + data << uint32(needed); + data << uint32(needed); data << uint32(0); // bypass client - side limitation, a different value is needed here for each petition } else @@ -379,15 +375,12 @@ void WorldSession::SendPetitionQueryOpcode(uint64 petitionguid) data << uint32(0); // 14 - if (type == GUILD_CHARTER_TYPE) - data << uint32(0); // 15 0 - guild, 1 - arena team - else - data << uint32(1); + data << uint32(type != GUILD_CHARTER_TYPE); // 15 0 - guild, 1 - arena team SendPacket(&data); } -void WorldSession::HandlePetitionRenameOpcode(WorldPacket & recv_data) +void WorldSession::HandlePetitionRenameOpcode(WorldPacket & recvData) { sLog->outDebug(LOG_FILTER_NETWORKIO, "Received opcode MSG_PETITION_RENAME"); // ok @@ -395,8 +388,8 @@ void WorldSession::HandlePetitionRenameOpcode(WorldPacket & recv_data) uint32 type; std::string newName; - recv_data >> petitionGuid; // guid - recv_data >> newName; // new name + recvData >> petitionGuid; // guid + recvData >> newName; // new name Item* item = _player->GetItemByGuid(petitionGuid); if (!item) @@ -423,12 +416,12 @@ void WorldSession::HandlePetitionRenameOpcode(WorldPacket & recv_data) { if (sGuildMgr->GetGuildByName(newName)) { - Guild::SendCommandResult(this, GUILD_CREATE_S, ERR_GUILD_NAME_EXISTS_S, newName); + Guild::SendCommandResult(this, GUILD_COMMAND_CREATE, ERR_GUILD_NAME_EXISTS_S, newName); return; } if (sObjectMgr->IsReservedName(newName) || !ObjectMgr::IsValidCharterName(newName)) { - Guild::SendCommandResult(this, GUILD_CREATE_S, ERR_GUILD_NAME_INVALID, newName); + Guild::SendCommandResult(this, GUILD_COMMAND_CREATE, ERR_GUILD_NAME_INVALID, newName); return; } } @@ -460,15 +453,15 @@ void WorldSession::HandlePetitionRenameOpcode(WorldPacket & recv_data) SendPacket(&data); } -void WorldSession::HandlePetitionSignOpcode(WorldPacket & recv_data) +void WorldSession::HandlePetitionSignOpcode(WorldPacket & recvData) { sLog->outDebug(LOG_FILTER_NETWORKIO, "Received opcode CMSG_PETITION_SIGN"); // ok Field* fields; uint64 petitionGuid; uint8 unk; - recv_data >> petitionGuid; // petition guid - recv_data >> unk; + recvData >> petitionGuid; // petition guid + recvData >> unk; PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_PETITION_SIGNATURES); @@ -479,7 +472,7 @@ void WorldSession::HandlePetitionSignOpcode(WorldPacket & recv_data) if (!result) { - sLog->outError(LOG_FILTER_NETWORKIO, "Petition %u is not found for player %u %s", GUID_LOPART(petitionGuid), GetPlayer()->GetGUIDLow(), GetPlayer()->GetName()); + sLog->outError(LOG_FILTER_NETWORKIO, "Petition %u is not found for player %u %s", GUID_LOPART(petitionGuid), GetPlayer()->GetGUIDLow(), GetPlayer()->GetName().c_str()); return; } @@ -498,7 +491,7 @@ void WorldSession::HandlePetitionSignOpcode(WorldPacket & recv_data) if (type != GUILD_CHARTER_TYPE) SendArenaTeamCommandResult(ERR_ARENA_TEAM_INVITE_SS, "", "", ERR_ARENA_TEAM_NOT_ALLIED); else - Guild::SendCommandResult(this, GUILD_CREATE_S, ERR_GUILD_NOT_ALLIED); + Guild::SendCommandResult(this, GUILD_COMMAND_CREATE, ERR_GUILD_NOT_ALLIED); return; } @@ -506,7 +499,7 @@ void WorldSession::HandlePetitionSignOpcode(WorldPacket & recv_data) { if (_player->getLevel() < sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL)) { - SendArenaTeamCommandResult(ERR_ARENA_TEAM_CREATE_S, "", _player->GetName(), ERR_ARENA_TEAM_TARGET_TOO_LOW_S); + SendArenaTeamCommandResult(ERR_ARENA_TEAM_CREATE_S, "", _player->GetName().c_str(), ERR_ARENA_TEAM_TARGET_TOO_LOW_S); return; } @@ -516,13 +509,13 @@ void WorldSession::HandlePetitionSignOpcode(WorldPacket & recv_data) if (_player->GetArenaTeamId(slot)) { - SendArenaTeamCommandResult(ERR_ARENA_TEAM_INVITE_SS, "", _player->GetName(), ERR_ALREADY_IN_ARENA_TEAM_S); + SendArenaTeamCommandResult(ERR_ARENA_TEAM_INVITE_SS, "", _player->GetName().c_str(), ERR_ALREADY_IN_ARENA_TEAM_S); return; } if (_player->GetArenaTeamIdInvited()) { - SendArenaTeamCommandResult(ERR_ARENA_TEAM_INVITE_SS, "", _player->GetName(), ERR_ALREADY_INVITED_TO_ARENA_TEAM_S); + SendArenaTeamCommandResult(ERR_ARENA_TEAM_INVITE_SS, "", _player->GetName().c_str(), ERR_ALREADY_INVITED_TO_ARENA_TEAM_S); return; } } @@ -530,12 +523,12 @@ void WorldSession::HandlePetitionSignOpcode(WorldPacket & recv_data) { if (_player->GetGuildId()) { - Guild::SendCommandResult(this, GUILD_INVITE_S, ERR_ALREADY_IN_GUILD_S, _player->GetName()); + Guild::SendCommandResult(this, GUILD_COMMAND_INVITE, ERR_ALREADY_IN_GUILD_S, _player->GetName()); return; } if (_player->GetGuildIdInvited()) { - Guild::SendCommandResult(this, GUILD_INVITE_S, ERR_ALREADY_INVITED_TO_GUILD_S, _player->GetName()); + Guild::SendCommandResult(this, GUILD_COMMAND_INVITE, ERR_ALREADY_INVITED_TO_GUILD_S, _player->GetName()); return; } } @@ -577,7 +570,7 @@ void WorldSession::HandlePetitionSignOpcode(WorldPacket & recv_data) CharacterDatabase.Execute(stmt); - sLog->outDebug(LOG_FILTER_NETWORKIO, "PETITION SIGN: GUID %u by player: %s (GUID: %u Account: %u)", GUID_LOPART(petitionGuid), _player->GetName(), playerGuid, GetAccountId()); + sLog->outDebug(LOG_FILTER_NETWORKIO, "PETITION SIGN: GUID %u by player: %s (GUID: %u Account: %u)", GUID_LOPART(petitionGuid), _player->GetName().c_str(), playerGuid, GetAccountId()); WorldPacket data(SMSG_PETITION_SIGN_RESULTS, (8+8+4)); data << uint64(petitionGuid); @@ -597,13 +590,13 @@ void WorldSession::HandlePetitionSignOpcode(WorldPacket & recv_data) owner->GetSession()->SendPacket(&data); } -void WorldSession::HandlePetitionDeclineOpcode(WorldPacket & recv_data) +void WorldSession::HandlePetitionDeclineOpcode(WorldPacket & recvData) { sLog->outDebug(LOG_FILTER_NETWORKIO, "Received opcode MSG_PETITION_DECLINE"); // ok uint64 petitionguid; uint64 ownerguid; - recv_data >> petitionguid; // petition guid + recvData >> petitionguid; // petition guid sLog->outDebug(LOG_FILTER_NETWORKIO, "Petition %u declined by %u", GUID_LOPART(petitionguid), _player->GetGUIDLow()); PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_PETITION_OWNER_BY_GUID); @@ -627,7 +620,7 @@ void WorldSession::HandlePetitionDeclineOpcode(WorldPacket & recv_data) } } -void WorldSession::HandleOfferPetitionOpcode(WorldPacket & recv_data) +void WorldSession::HandleOfferPetitionOpcode(WorldPacket & recvData) { sLog->outDebug(LOG_FILTER_NETWORKIO, "Received opcode CMSG_OFFER_PETITION"); // ok @@ -635,9 +628,9 @@ void WorldSession::HandleOfferPetitionOpcode(WorldPacket & recv_data) uint64 petitionguid, plguid; uint32 type, junk; Player* player; - recv_data >> junk; // this is not petition type! - recv_data >> petitionguid; // petition guid - recv_data >> plguid; // player guid + recvData >> junk; // this is not petition type! + recvData >> petitionguid; // petition guid + recvData >> plguid; // player guid player = ObjectAccessor::FindPlayer(plguid); if (!player) @@ -662,7 +655,7 @@ void WorldSession::HandleOfferPetitionOpcode(WorldPacket & recv_data) if (type != GUILD_CHARTER_TYPE) SendArenaTeamCommandResult(ERR_ARENA_TEAM_INVITE_SS, "", "", ERR_ARENA_TEAM_NOT_ALLIED); else - Guild::SendCommandResult(this, GUILD_CREATE_S, ERR_GUILD_NOT_ALLIED); + Guild::SendCommandResult(this, GUILD_COMMAND_CREATE, ERR_GUILD_NOT_ALLIED); return; } @@ -671,7 +664,7 @@ void WorldSession::HandleOfferPetitionOpcode(WorldPacket & recv_data) if (player->getLevel() < sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL)) { // player is too low level to join an arena team - SendArenaTeamCommandResult(ERR_ARENA_TEAM_CREATE_S, player->GetName(), "", ERR_ARENA_TEAM_TARGET_TOO_LOW_S); + SendArenaTeamCommandResult(ERR_ARENA_TEAM_CREATE_S, player->GetName().c_str(), "", ERR_ARENA_TEAM_TARGET_TOO_LOW_S); return; } @@ -682,13 +675,13 @@ void WorldSession::HandleOfferPetitionOpcode(WorldPacket & recv_data) if (player->GetArenaTeamId(slot)) { // player is already in an arena team - SendArenaTeamCommandResult(ERR_ARENA_TEAM_CREATE_S, player->GetName(), "", ERR_ALREADY_IN_ARENA_TEAM_S); + SendArenaTeamCommandResult(ERR_ARENA_TEAM_CREATE_S, player->GetName().c_str(), "", ERR_ALREADY_IN_ARENA_TEAM_S); return; } if (player->GetArenaTeamIdInvited()) { - SendArenaTeamCommandResult(ERR_ARENA_TEAM_INVITE_SS, "", _player->GetName(), ERR_ALREADY_INVITED_TO_ARENA_TEAM_S); + SendArenaTeamCommandResult(ERR_ARENA_TEAM_INVITE_SS, "", _player->GetName().c_str(), ERR_ALREADY_INVITED_TO_ARENA_TEAM_S); return; } } @@ -696,13 +689,13 @@ void WorldSession::HandleOfferPetitionOpcode(WorldPacket & recv_data) { if (player->GetGuildId()) { - Guild::SendCommandResult(this, GUILD_INVITE_S, ERR_ALREADY_IN_GUILD_S, _player->GetName()); + Guild::SendCommandResult(this, GUILD_COMMAND_INVITE, ERR_ALREADY_IN_GUILD_S, _player->GetName()); return; } if (player->GetGuildIdInvited()) { - Guild::SendCommandResult(this, GUILD_INVITE_S, ERR_ALREADY_INVITED_TO_GUILD_S, _player->GetName()); + Guild::SendCommandResult(this, GUILD_COMMAND_INVITE, ERR_ALREADY_INVITED_TO_GUILD_S, _player->GetName()); return; } } @@ -736,7 +729,7 @@ void WorldSession::HandleOfferPetitionOpcode(WorldPacket & recv_data) player->GetSession()->SendPacket(&data); } -void WorldSession::HandleTurnInPetitionOpcode(WorldPacket & recv_data) +void WorldSession::HandleTurnInPetitionOpcode(WorldPacket & recvData) { sLog->outDebug(LOG_FILTER_NETWORKIO, "Received opcode CMSG_TURN_IN_PETITION"); @@ -744,7 +737,7 @@ void WorldSession::HandleTurnInPetitionOpcode(WorldPacket & recv_data) WorldPacket data; uint64 petitionGuid; - recv_data >> petitionGuid; + recvData >> petitionGuid; // Check if player really has the required petition charter Item* item = _player->GetItemByGuid(petitionGuid); @@ -771,7 +764,7 @@ void WorldSession::HandleTurnInPetitionOpcode(WorldPacket & recv_data) } else { - sLog->outError(LOG_FILTER_NETWORKIO, "Player %s (guid: %u) tried to turn in petition (guid: %u) that is not present in the database", _player->GetName(), _player->GetGUIDLow(), GUID_LOPART(petitionGuid)); + sLog->outError(LOG_FILTER_NETWORKIO, "Player %s (guid: %u) tried to turn in petition (guid: %u) that is not present in the database", _player->GetName().c_str(), _player->GetGUIDLow(), GUID_LOPART(petitionGuid)); return; } @@ -794,7 +787,7 @@ void WorldSession::HandleTurnInPetitionOpcode(WorldPacket & recv_data) // Check if guild name is already taken if (sGuildMgr->GetGuildByName(name)) { - Guild::SendCommandResult(this, GUILD_CREATE_S, ERR_GUILD_NAME_EXISTS_S, name); + Guild::SendCommandResult(this, GUILD_COMMAND_CREATE, ERR_GUILD_NAME_EXISTS_S, name); return; } } @@ -866,6 +859,8 @@ void WorldSession::HandleTurnInPetitionOpcode(WorldPacket & recv_data) // Register guild and add guild master sGuildMgr->AddGuild(guild); + Guild::SendCommandResult(this, GUILD_COMMAND_CREATE, ERR_GUILD_COMMAND_SUCCESS, name); + // Add members from signatures for (uint8 i = 0; i < signatures; ++i) { @@ -878,7 +873,7 @@ void WorldSession::HandleTurnInPetitionOpcode(WorldPacket & recv_data) { // Receive the rest of the packet in arena team creation case uint32 background, icon, iconcolor, border, bordercolor; - recv_data >> background >> icon >> iconcolor >> border >> bordercolor; + recvData >> background >> icon >> iconcolor >> border >> bordercolor; // Create arena team ArenaTeam* arenaTeam = new ArenaTeam(); @@ -924,12 +919,12 @@ void WorldSession::HandleTurnInPetitionOpcode(WorldPacket & recv_data) SendPacket(&data); } -void WorldSession::HandlePetitionShowListOpcode(WorldPacket & recv_data) +void WorldSession::HandlePetitionShowListOpcode(WorldPacket & recvData) { sLog->outDebug(LOG_FILTER_NETWORKIO, "Received CMSG_PETITION_SHOWLIST"); uint64 guid; - recv_data >> guid; + recvData >> guid; SendPetitionShowList(guid); } @@ -954,7 +949,7 @@ void WorldSession::SendPetitionShowList(uint64 guid) data << uint32(CHARTER_DISPLAY_ID); // charter display id data << uint32(GUILD_CHARTER_COST); // charter cost data << uint32(0); // unknown - data << uint32(9); // required signs? + data << uint32(sWorld->getIntConfig(CONFIG_MIN_PETITION_SIGNS)); // required signs } else { diff --git a/src/server/game/Handlers/QueryHandler.cpp b/src/server/game/Handlers/QueryHandler.cpp index d3f51867831..534f992b594 100755 --- a/src/server/game/Handlers/QueryHandler.cpp +++ b/src/server/game/Handlers/QueryHandler.cpp @@ -64,10 +64,10 @@ void WorldSession::SendNameQueryOpcode(uint64 guid) SendPacket(&data); } -void WorldSession::HandleNameQueryOpcode(WorldPacket& recv_data) +void WorldSession::HandleNameQueryOpcode(WorldPacket& recvData) { uint64 guid; - recv_data >> guid; + recvData >> guid; // This is disable by default to prevent lots of console spam // sLog->outInfo(LOG_FILTER_NETWORKIO, "HandleNameQueryOpcode %u", guid); @@ -75,7 +75,7 @@ void WorldSession::HandleNameQueryOpcode(WorldPacket& recv_data) SendNameQueryOpcode(guid); } -void WorldSession::HandleQueryTimeOpcode(WorldPacket & /*recv_data*/) +void WorldSession::HandleQueryTimeOpcode(WorldPacket & /*recvData*/) { SendQueryTimeResponse(); } @@ -89,12 +89,12 @@ void WorldSession::SendQueryTimeResponse() } /// Only _static_ data is sent in this packet !!! -void WorldSession::HandleCreatureQueryOpcode(WorldPacket & recv_data) +void WorldSession::HandleCreatureQueryOpcode(WorldPacket & recvData) { uint32 entry; - recv_data >> entry; + recvData >> entry; uint64 guid; - recv_data >> guid; + recvData >> guid; CreatureTemplate const* ci = sObjectMgr->GetCreatureTemplate(entry); if (ci) @@ -152,12 +152,12 @@ void WorldSession::HandleCreatureQueryOpcode(WorldPacket & recv_data) } /// Only _static_ data is sent in this packet !!! -void WorldSession::HandleGameObjectQueryOpcode(WorldPacket & recv_data) +void WorldSession::HandleGameObjectQueryOpcode(WorldPacket & recvData) { uint32 entry; - recv_data >> entry; + recvData >> entry; uint64 guid; - recv_data >> guid; + recvData >> guid; const GameObjectTemplate* info = sObjectMgr->GetGameObjectTemplate(entry); if (info) @@ -207,7 +207,7 @@ void WorldSession::HandleGameObjectQueryOpcode(WorldPacket & recv_data) } } -void WorldSession::HandleCorpseQueryOpcode(WorldPacket & /*recv_data*/) +void WorldSession::HandleCorpseQueryOpcode(WorldPacket & /*recvData*/) { sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Received MSG_CORPSE_QUERY"); @@ -258,15 +258,15 @@ void WorldSession::HandleCorpseQueryOpcode(WorldPacket & /*recv_data*/) SendPacket(&data); } -void WorldSession::HandleNpcTextQueryOpcode(WorldPacket & recv_data) +void WorldSession::HandleNpcTextQueryOpcode(WorldPacket & recvData) { uint32 textID; uint64 guid; - recv_data >> textID; + recvData >> textID; sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: CMSG_NPC_TEXT_QUERY ID '%u'", textID); - recv_data >> guid; + recvData >> guid; GetPlayer()->SetSelection(guid); GossipText const* pGossip = sObjectMgr->GetGossipText(textID); @@ -342,13 +342,13 @@ void WorldSession::HandleNpcTextQueryOpcode(WorldPacket & recv_data) } /// Only _static_ data is sent in this packet !!! -void WorldSession::HandlePageTextQueryOpcode(WorldPacket & recv_data) +void WorldSession::HandlePageTextQueryOpcode(WorldPacket & recvData) { sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Received CMSG_PAGE_TEXT_QUERY"); uint32 pageID; - recv_data >> pageID; - recv_data.read_skip<uint64>(); // guid + recvData >> pageID; + recvData.read_skip<uint64>(); // guid while (pageID) { @@ -382,12 +382,12 @@ void WorldSession::HandlePageTextQueryOpcode(WorldPacket & recv_data) } } -void WorldSession::HandleCorpseMapPositionQuery(WorldPacket & recv_data) +void WorldSession::HandleCorpseMapPositionQuery(WorldPacket & recvData) { sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Recv CMSG_CORPSE_MAP_POSITION_QUERY"); uint32 unk; - recv_data >> unk; + recvData >> unk; WorldPacket data(SMSG_CORPSE_MAP_POSITION_QUERY_RESPONSE, 4+4+4+4); data << float(0); @@ -397,14 +397,14 @@ void WorldSession::HandleCorpseMapPositionQuery(WorldPacket & recv_data) SendPacket(&data); } -void WorldSession::HandleQuestPOIQuery(WorldPacket& recv_data) +void WorldSession::HandleQuestPOIQuery(WorldPacket& recvData) { uint32 count; - recv_data >> count; // quest count, max=25 + recvData >> count; // quest count, max=25 if (count >= MAX_QUEST_LOG_SIZE) { - recv_data.rfinish(); + recvData.rfinish(); return; } @@ -414,7 +414,7 @@ void WorldSession::HandleQuestPOIQuery(WorldPacket& recv_data) for (uint32 i = 0; i < count; ++i) { uint32 questId; - recv_data >> questId; // quest id + recvData >> questId; // quest id bool questOk = false; diff --git a/src/server/game/Handlers/QuestHandler.cpp b/src/server/game/Handlers/QuestHandler.cpp index b16459a48b0..4196bc26b91 100755 --- a/src/server/game/Handlers/QuestHandler.cpp +++ b/src/server/game/Handlers/QuestHandler.cpp @@ -33,10 +33,10 @@ #include "ScriptMgr.h" #include "GameObjectAI.h" -void WorldSession::HandleQuestgiverStatusQueryOpcode(WorldPacket & recv_data) +void WorldSession::HandleQuestgiverStatusQueryOpcode(WorldPacket & recvData) { uint64 guid; - recv_data >> guid; + recvData >> guid; uint8 questStatus = DIALOG_STATUS_NONE; uint8 defstatus = DIALOG_STATUS_NONE; @@ -79,10 +79,10 @@ void WorldSession::HandleQuestgiverStatusQueryOpcode(WorldPacket & recv_data) _player->PlayerTalkClass->SendQuestGiverStatus(questStatus, guid); } -void WorldSession::HandleQuestgiverHelloOpcode(WorldPacket & recv_data) +void WorldSession::HandleQuestgiverHelloOpcode(WorldPacket & recvData) { uint64 guid; - recv_data >> guid; + recvData >> guid; sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Received CMSG_QUESTGIVER_HELLO npc = %u", GUID_LOPART(guid)); @@ -109,12 +109,12 @@ void WorldSession::HandleQuestgiverHelloOpcode(WorldPacket & recv_data) creature->AI()->sGossipHello(_player); } -void WorldSession::HandleQuestgiverAcceptQuestOpcode(WorldPacket & recv_data) +void WorldSession::HandleQuestgiverAcceptQuestOpcode(WorldPacket & recvData) { uint64 guid; uint32 questId; uint32 unk1; - recv_data >> guid >> questId >> unk1; + recvData >> guid >> questId >> unk1; sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Received CMSG_QUESTGIVER_ACCEPT_QUEST npc = %u, quest = %u, unk1 = %u", uint32(GUID_LOPART(guid)), questId, unk1); @@ -230,12 +230,12 @@ void WorldSession::HandleQuestgiverAcceptQuestOpcode(WorldPacket & recv_data) _player->PlayerTalkClass->SendCloseGossip(); } -void WorldSession::HandleQuestgiverQueryQuestOpcode(WorldPacket & recv_data) +void WorldSession::HandleQuestgiverQueryQuestOpcode(WorldPacket & recvData) { uint64 guid; uint32 questId; uint8 unk1; - recv_data >> guid >> questId >> unk1; + recvData >> guid >> questId >> unk1; sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Received CMSG_QUESTGIVER_QUERY_QUEST npc = %u, quest = %u, unk1 = %u", uint32(GUID_LOPART(guid)), questId, unk1); // Verify that the guid is valid and is a questgiver or involved in the requested quest @@ -268,28 +268,28 @@ void WorldSession::HandleQuestgiverQueryQuestOpcode(WorldPacket & recv_data) } } -void WorldSession::HandleQuestQueryOpcode(WorldPacket & recv_data) +void WorldSession::HandleQuestQueryOpcode(WorldPacket & recvData) { if (!_player) return; uint32 questId; - recv_data >> questId; + recvData >> questId; sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Received CMSG_QUEST_QUERY quest = %u", questId); if (Quest const* quest = sObjectMgr->GetQuestTemplate(questId)) _player->PlayerTalkClass->SendQuestQueryResponse(quest); } -void WorldSession::HandleQuestgiverChooseRewardOpcode(WorldPacket & recv_data) +void WorldSession::HandleQuestgiverChooseRewardOpcode(WorldPacket & recvData) { uint32 questId, reward; uint64 guid; - recv_data >> guid >> questId >> reward; + recvData >> guid >> questId >> reward; if (reward >= QUEST_REWARD_CHOICES_COUNT) { - sLog->outError(LOG_FILTER_NETWORKIO, "Error in CMSG_QUESTGIVER_CHOOSE_REWARD: player %s (guid %d) tried to get invalid reward (%u) (probably packet hacking)", _player->GetName(), _player->GetGUIDLow(), reward); + sLog->outError(LOG_FILTER_NETWORKIO, "Error in CMSG_QUESTGIVER_CHOOSE_REWARD: player %s (guid %d) tried to get invalid reward (%u) (probably packet hacking)", _player->GetName().c_str(), _player->GetGUIDLow(), reward); return; } @@ -309,7 +309,7 @@ void WorldSession::HandleQuestgiverChooseRewardOpcode(WorldPacket & recv_data) (_player->GetQuestStatus(questId) != QUEST_STATUS_COMPLETE && !quest->IsAutoComplete())) { sLog->outError(LOG_FILTER_NETWORKIO, "HACK ALERT: Player %s (guid: %u) is trying to complete quest (id: %u) but he has no right to do it!", - _player->GetName(), _player->GetGUIDLow(), questId); + _player->GetName().c_str(), _player->GetGUIDLow(), questId); return; } if (_player->CanRewardQuest(quest, reward, true)) @@ -365,11 +365,11 @@ void WorldSession::HandleQuestgiverChooseRewardOpcode(WorldPacket & recv_data) } } -void WorldSession::HandleQuestgiverRequestRewardOpcode(WorldPacket & recv_data) +void WorldSession::HandleQuestgiverRequestRewardOpcode(WorldPacket & recvData) { uint32 questId; uint64 guid; - recv_data >> guid >> questId; + recvData >> guid >> questId; sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Received CMSG_QUESTGIVER_REQUEST_REWARD npc = %u, quest = %u", uint32(GUID_LOPART(guid)), questId); @@ -391,17 +391,17 @@ void WorldSession::HandleQuestgiverRequestRewardOpcode(WorldPacket & recv_data) _player->PlayerTalkClass->SendQuestGiverOfferReward(quest, guid, true); } -void WorldSession::HandleQuestgiverCancel(WorldPacket& /*recv_data*/) +void WorldSession::HandleQuestgiverCancel(WorldPacket& /*recvData*/) { sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Received CMSG_QUESTGIVER_CANCEL"); _player->PlayerTalkClass->SendCloseGossip(); } -void WorldSession::HandleQuestLogSwapQuest(WorldPacket& recv_data) +void WorldSession::HandleQuestLogSwapQuest(WorldPacket& recvData) { uint8 slot1, slot2; - recv_data >> slot1 >> slot2; + recvData >> slot1 >> slot2; if (slot1 == slot2 || slot1 >= MAX_QUEST_LOG_SIZE || slot2 >= MAX_QUEST_LOG_SIZE) return; @@ -411,10 +411,10 @@ void WorldSession::HandleQuestLogSwapQuest(WorldPacket& recv_data) GetPlayer()->SwapQuestSlot(slot1, slot2); } -void WorldSession::HandleQuestLogRemoveQuest(WorldPacket& recv_data) +void WorldSession::HandleQuestLogRemoveQuest(WorldPacket& recvData) { uint8 slot; - recv_data >> slot; + recvData >> slot; sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Received CMSG_QUESTLOG_REMOVE_QUEST slot = %u", slot); @@ -444,10 +444,10 @@ void WorldSession::HandleQuestLogRemoveQuest(WorldPacket& recv_data) } } -void WorldSession::HandleQuestConfirmAccept(WorldPacket& recv_data) +void WorldSession::HandleQuestConfirmAccept(WorldPacket& recvData) { uint32 questId; - recv_data >> questId; + recvData >> questId; sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Received CMSG_QUEST_CONFIRM_ACCEPT quest = %u", questId); @@ -479,12 +479,12 @@ void WorldSession::HandleQuestConfirmAccept(WorldPacket& recv_data) } } -void WorldSession::HandleQuestgiverCompleteQuest(WorldPacket& recv_data) +void WorldSession::HandleQuestgiverCompleteQuest(WorldPacket& recvData) { uint32 questId; uint64 guid; - recv_data >> guid >> questId; + recvData >> guid >> questId; sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Received CMSG_QUESTGIVER_COMPLETE_QUEST npc = %u, quest = %u", uint32(GUID_LOPART(guid)), questId); @@ -501,7 +501,7 @@ void WorldSession::HandleQuestgiverCompleteQuest(WorldPacket& recv_data) if (!_player->CanSeeStartQuest(quest) && _player->GetQuestStatus(questId) == QUEST_STATUS_NONE) { sLog->outError(LOG_FILTER_NETWORKIO, "Possible hacking attempt: Player %s [guid: %u] tried to complete quest [entry: %u] without being in possession of the quest!", - _player->GetName(), _player->GetGUIDLow(), questId); + _player->GetName().c_str(), _player->GetGUIDLow(), questId); return; } // TODO: need a virtual function @@ -760,7 +760,7 @@ void WorldSession::HandleQuestgiverStatusMultipleQuery(WorldPacket& /*recvPacket SendPacket(&data); } -void WorldSession::HandleQueryQuestsCompleted(WorldPacket & /*recv_data*/) +void WorldSession::HandleQueryQuestsCompleted(WorldPacket & /*recvData*/) { size_t rew_count = _player->GetRewardedQuestCount(); diff --git a/src/server/game/Handlers/ReferAFriendHandler.cpp b/src/server/game/Handlers/ReferAFriendHandler.cpp index 58d425ddf98..7822c38d390 100644 --- a/src/server/game/Handlers/ReferAFriendHandler.cpp +++ b/src/server/game/Handlers/ReferAFriendHandler.cpp @@ -21,12 +21,12 @@ #include "Opcodes.h" #include "Log.h" -void WorldSession::HandleGrantLevel(WorldPacket& recv_data) +void WorldSession::HandleGrantLevel(WorldPacket& recvData) { sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: CMSG_GRANT_LEVEL"); uint64 guid; - recv_data.readPackGUID(guid); + recvData.readPackGUID(guid); Player* target = ObjectAccessor::GetObjectInWorld(guid, _player); @@ -63,12 +63,12 @@ void WorldSession::HandleGrantLevel(WorldPacket& recv_data) target->GetSession()->SendPacket(&data2); } -void WorldSession::HandleAcceptGrantLevel(WorldPacket& recv_data) +void WorldSession::HandleAcceptGrantLevel(WorldPacket& recvData) { sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: CMSG_ACCEPT_LEVEL_GRANT"); uint64 guid; - recv_data.readPackGUID(guid); + recvData.readPackGUID(guid); Player* other = ObjectAccessor::GetObjectInWorld(guid, _player); if (!(other && other->GetSession())) diff --git a/src/server/game/Handlers/SkillHandler.cpp b/src/server/game/Handlers/SkillHandler.cpp index 8872816f87d..88ae01f59be 100755 --- a/src/server/game/Handlers/SkillHandler.cpp +++ b/src/server/game/Handlers/SkillHandler.cpp @@ -26,10 +26,10 @@ #include "ObjectAccessor.h" #include "UpdateMask.h" -void WorldSession::HandleLearnTalentOpcode(WorldPacket & recv_data) +void WorldSession::HandleLearnTalentOpcode(WorldPacket & recvData) { uint32 talent_id, requested_rank; - recv_data >> talent_id >> requested_rank; + recvData >> talent_id >> requested_rank; _player->LearnTalent(talent_id, requested_rank); _player->SendTalentsInfoData(false); @@ -54,11 +54,11 @@ void WorldSession::HandleLearnPreviewTalents(WorldPacket& recvPacket) _player->SendTalentsInfoData(false); } -void WorldSession::HandleTalentWipeConfirmOpcode(WorldPacket & recv_data) +void WorldSession::HandleTalentWipeConfirmOpcode(WorldPacket & recvData) { sLog->outDebug(LOG_FILTER_NETWORKIO, "MSG_TALENT_WIPE_CONFIRM"); uint64 guid; - recv_data >> guid; + recvData >> guid; Creature* unit = GetPlayer()->GetNPCIfCanInteractWith(guid, UNIT_NPC_FLAG_TRAINER); if (!unit) diff --git a/src/server/game/Handlers/SpellHandler.cpp b/src/server/game/Handlers/SpellHandler.cpp index 0e5d68d51e4..1c834b323ac 100755 --- a/src/server/game/Handlers/SpellHandler.cpp +++ b/src/server/game/Handlers/SpellHandler.cpp @@ -208,7 +208,7 @@ void WorldSession::HandleOpenItemOpcode(WorldPacket& recvPacket) { pUser->SendEquipError(EQUIP_ERR_CANT_DO_RIGHT_NOW, item, NULL); sLog->outError(LOG_FILTER_NETWORKIO, "Possible hacking attempt: Player %s [guid: %u] tried to open item [guid: %u, entry: %u] which is not openable!", - pUser->GetName(), pUser->GetGUIDLow(), item->GetGUIDLow(), proto->ItemId); + pUser->GetName().c_str(), pUser->GetGUIDLow(), item->GetGUIDLow(), proto->ItemId); return; } @@ -269,11 +269,11 @@ void WorldSession::HandleOpenItemOpcode(WorldPacket& recvPacket) pUser->SendLoot(item->GetGUID(), LOOT_CORPSE); } -void WorldSession::HandleGameObjectUseOpcode(WorldPacket & recv_data) +void WorldSession::HandleGameObjectUseOpcode(WorldPacket & recvData) { uint64 guid; - recv_data >> guid; + recvData >> guid; sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Recvd CMSG_GAMEOBJ_USE Message [guid=%u]", GUID_LOPART(guid)); @@ -453,13 +453,13 @@ void WorldSession::HandlePetCancelAuraOpcode(WorldPacket& recvPacket) if (!pet) { - sLog->outError(LOG_FILTER_NETWORKIO, "HandlePetCancelAura: Attempt to cancel an aura for non-existant pet %u by player '%s'", uint32(GUID_LOPART(guid)), GetPlayer()->GetName()); + sLog->outError(LOG_FILTER_NETWORKIO, "HandlePetCancelAura: Attempt to cancel an aura for non-existant pet %u by player '%s'", uint32(GUID_LOPART(guid)), GetPlayer()->GetName().c_str()); return; } if (pet != GetPlayer()->GetGuardianPet() && pet != GetPlayer()->GetCharm()) { - sLog->outError(LOG_FILTER_NETWORKIO, "HandlePetCancelAura: Pet %u is not a pet of player '%s'", uint32(GUID_LOPART(guid)), GetPlayer()->GetName()); + sLog->outError(LOG_FILTER_NETWORKIO, "HandlePetCancelAura: Pet %u is not a pet of player '%s'", uint32(GUID_LOPART(guid)), GetPlayer()->GetName().c_str()); return; } @@ -485,9 +485,9 @@ void WorldSession::HandleCancelAutoRepeatSpellOpcode(WorldPacket& /*recvPacket*/ _player->InterruptSpell(CURRENT_AUTOREPEAT_SPELL); } -void WorldSession::HandleCancelChanneling(WorldPacket & recv_data) +void WorldSession::HandleCancelChanneling(WorldPacket & recvData) { - recv_data.read_skip<uint32>(); // spellid, not used + recvData.read_skip<uint32>(); // spellid, not used // ignore for remote control state (for player case) Unit* mover = _player->m_mover; @@ -520,7 +520,7 @@ void WorldSession::HandleTotemDestroyed(WorldPacket& recvPacket) totem->ToTotem()->UnSummon(); } -void WorldSession::HandleSelfResOpcode(WorldPacket & /*recv_data*/) +void WorldSession::HandleSelfResOpcode(WorldPacket & /*recvData*/) { sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: CMSG_SELF_RES"); // empty opcode @@ -537,10 +537,10 @@ void WorldSession::HandleSelfResOpcode(WorldPacket & /*recv_data*/) } } -void WorldSession::HandleSpellClick(WorldPacket& recv_data) +void WorldSession::HandleSpellClick(WorldPacket& recvData) { uint64 guid; - recv_data >> guid; + recvData >> guid; // this will get something not in world. crash Creature* unit = ObjectAccessor::GetCreatureOrPetOrVehicle(*_player, guid); @@ -555,11 +555,11 @@ void WorldSession::HandleSpellClick(WorldPacket& recv_data) unit->HandleSpellClick(_player); } -void WorldSession::HandleMirrorImageDataRequest(WorldPacket & recv_data) +void WorldSession::HandleMirrorImageDataRequest(WorldPacket & recvData) { sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: CMSG_GET_MIRRORIMAGE_DATA"); uint64 guid; - recv_data >> guid; + recvData >> guid; // Get unit for which data is needed by client Unit* unit = ObjectAccessor::GetObjectInWorld(guid, (Unit*)NULL); diff --git a/src/server/game/Handlers/TaxiHandler.cpp b/src/server/game/Handlers/TaxiHandler.cpp index b774fbcba70..16ffdfbc440 100755 --- a/src/server/game/Handlers/TaxiHandler.cpp +++ b/src/server/game/Handlers/TaxiHandler.cpp @@ -28,13 +28,13 @@ #include "Path.h" #include "WaypointMovementGenerator.h" -void WorldSession::HandleTaxiNodeStatusQueryOpcode(WorldPacket & recv_data) +void WorldSession::HandleTaxiNodeStatusQueryOpcode(WorldPacket & recvData) { sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Received CMSG_TAXINODE_STATUS_QUERY"); uint64 guid; - recv_data >> guid; + recvData >> guid; SendTaxiStatus(guid); } @@ -63,12 +63,12 @@ void WorldSession::SendTaxiStatus(uint64 guid) sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Sent SMSG_TAXINODE_STATUS"); } -void WorldSession::HandleTaxiQueryAvailableNodes(WorldPacket & recv_data) +void WorldSession::HandleTaxiQueryAvailableNodes(WorldPacket & recvData) { sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Received CMSG_TAXIQUERYAVAILABLENODES"); uint64 guid; - recv_data >> guid; + recvData >> guid; // cheating checks Creature* unit = GetPlayer()->GetNPCIfCanInteractWith(guid, UNIT_NPC_FLAG_FLIGHTMASTER); @@ -163,14 +163,14 @@ void WorldSession::SendDiscoverNewTaxiNode(uint32 nodeid) } } -void WorldSession::HandleActivateTaxiExpressOpcode (WorldPacket & recv_data) +void WorldSession::HandleActivateTaxiExpressOpcode (WorldPacket & recvData) { sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Received CMSG_ACTIVATETAXIEXPRESS"); uint64 guid; uint32 node_count; - recv_data >> guid >> node_count; + recvData >> guid >> node_count; Creature* npc = GetPlayer()->GetNPCIfCanInteractWith(guid, UNIT_NPC_FLAG_FLIGHTMASTER); if (!npc) @@ -183,7 +183,7 @@ void WorldSession::HandleActivateTaxiExpressOpcode (WorldPacket & recv_data) for (uint32 i = 0; i < node_count; ++i) { uint32 node; - recv_data >> node; + recvData >> node; nodes.push_back(node); } @@ -195,17 +195,17 @@ void WorldSession::HandleActivateTaxiExpressOpcode (WorldPacket & recv_data) GetPlayer()->ActivateTaxiPathTo(nodes, npc); } -void WorldSession::HandleMoveSplineDoneOpcode(WorldPacket& recv_data) +void WorldSession::HandleMoveSplineDoneOpcode(WorldPacket& recvData) { sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Received CMSG_MOVE_SPLINE_DONE"); uint64 guid; // used only for proper packet read - recv_data.readPackGUID(guid); + recvData.readPackGUID(guid); MovementInfo movementInfo; // used only for proper packet read - ReadMovementInfo(recv_data, &movementInfo); + ReadMovementInfo(recvData, &movementInfo); - recv_data.read_skip<uint32>(); // unk + recvData.read_skip<uint32>(); // unk // in taxi flight packet received in 2 case: // 1) end taxi path in far (multi-node) flight @@ -273,7 +273,7 @@ void WorldSession::HandleMoveSplineDoneOpcode(WorldPacket& recv_data) GetPlayer()->CastSpell(GetPlayer(), 2479, true); } -void WorldSession::HandleActivateTaxiOpcode(WorldPacket & recv_data) +void WorldSession::HandleActivateTaxiOpcode(WorldPacket & recvData) { sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Received CMSG_ACTIVATETAXI"); @@ -281,7 +281,7 @@ void WorldSession::HandleActivateTaxiOpcode(WorldPacket & recv_data) std::vector<uint32> nodes; nodes.resize(2); - recv_data >> guid >> nodes[0] >> nodes[1]; + recvData >> guid >> nodes[0] >> nodes[1]; sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Received CMSG_ACTIVATETAXI from %d to %d", nodes[0], nodes[1]); Creature* npc = GetPlayer()->GetNPCIfCanInteractWith(guid, UNIT_NPC_FLAG_FLIGHTMASTER); if (!npc) diff --git a/src/server/game/Handlers/TicketHandler.cpp b/src/server/game/Handlers/TicketHandler.cpp index 7fcfbbbc23e..41e834d84e8 100755 --- a/src/server/game/Handlers/TicketHandler.cpp +++ b/src/server/game/Handlers/TicketHandler.cpp @@ -86,7 +86,7 @@ void WorldSession::HandleGMTicketCreateOpcode(WorldPacket& recvData) sTicketMgr->AddTicket(ticket); sTicketMgr->UpdateLastChange(); - sWorld->SendGMText(LANG_COMMAND_TICKETNEW, GetPlayer()->GetName(), ticket->GetId()); + sWorld->SendGMText(LANG_COMMAND_TICKETNEW, GetPlayer()->GetName().c_str(), ticket->GetId()); response = GMTICKET_RESPONSE_CREATE_SUCCESS; } @@ -96,10 +96,10 @@ void WorldSession::HandleGMTicketCreateOpcode(WorldPacket& recvData) SendPacket(&data); } -void WorldSession::HandleGMTicketUpdateOpcode(WorldPacket & recv_data) +void WorldSession::HandleGMTicketUpdateOpcode(WorldPacket & recvData) { std::string message; - recv_data >> message; + recvData >> message; GMTicketResponse response = GMTICKET_RESPONSE_UPDATE_ERROR; if (GmTicket* ticket = sTicketMgr->GetTicketByPlayer(GetPlayer()->GetGUID())) @@ -108,7 +108,7 @@ void WorldSession::HandleGMTicketUpdateOpcode(WorldPacket & recv_data) ticket->SetMessage(message); ticket->SaveToDB(trans); - sWorld->SendGMText(LANG_COMMAND_TICKETUPDATED, GetPlayer()->GetName(), ticket->GetId()); + sWorld->SendGMText(LANG_COMMAND_TICKETUPDATED, GetPlayer()->GetName().c_str(), ticket->GetId()); response = GMTICKET_RESPONSE_UPDATE_SUCCESS; } @@ -118,7 +118,7 @@ void WorldSession::HandleGMTicketUpdateOpcode(WorldPacket & recv_data) SendPacket(&data); } -void WorldSession::HandleGMTicketDeleteOpcode(WorldPacket & /*recv_data*/) +void WorldSession::HandleGMTicketDeleteOpcode(WorldPacket & /*recvData*/) { if (GmTicket* ticket = sTicketMgr->GetTicketByPlayer(GetPlayer()->GetGUID())) { @@ -126,14 +126,14 @@ void WorldSession::HandleGMTicketDeleteOpcode(WorldPacket & /*recv_data*/) data << uint32(GMTICKET_RESPONSE_TICKET_DELETED); SendPacket(&data); - sWorld->SendGMText(LANG_COMMAND_TICKETPLAYERABANDON, GetPlayer()->GetName(), ticket->GetId()); + sWorld->SendGMText(LANG_COMMAND_TICKETPLAYERABANDON, GetPlayer()->GetName().c_str(), ticket->GetId()); sTicketMgr->CloseTicket(ticket->GetId(), GetPlayer()->GetGUID()); sTicketMgr->SendTicket(this, NULL); } } -void WorldSession::HandleGMTicketGetTicketOpcode(WorldPacket & /*recv_data*/) +void WorldSession::HandleGMTicketGetTicketOpcode(WorldPacket & /*recvData*/) { SendQueryTimeResponse(); @@ -148,7 +148,7 @@ void WorldSession::HandleGMTicketGetTicketOpcode(WorldPacket & /*recv_data*/) sTicketMgr->SendTicket(this, NULL); } -void WorldSession::HandleGMTicketSystemStatusOpcode(WorldPacket & /*recv_data*/) +void WorldSession::HandleGMTicketSystemStatusOpcode(WorldPacket & /*recvData*/) { // Note: This only disables the ticket UI at client side and is not fully reliable // are we sure this is a uint32? Should ask Zor @@ -157,25 +157,25 @@ void WorldSession::HandleGMTicketSystemStatusOpcode(WorldPacket & /*recv_data*/) SendPacket(&data); } -void WorldSession::HandleGMSurveySubmit(WorldPacket& recv_data) +void WorldSession::HandleGMSurveySubmit(WorldPacket& recvData) { uint32 nextSurveyID = sTicketMgr->GetNextSurveyID(); // just put the survey into the database uint32 mainSurvey; // GMSurveyCurrentSurvey.dbc, column 1 (all 9) ref to GMSurveySurveys.dbc - recv_data >> mainSurvey; + recvData >> mainSurvey; // sub_survey1, r1, comment1, sub_survey2, r2, comment2, sub_survey3, r3, comment3, sub_survey4, r4, comment4, sub_survey5, r5, comment5, sub_survey6, r6, comment6, sub_survey7, r7, comment7, sub_survey8, r8, comment8, sub_survey9, r9, comment9, sub_survey10, r10, comment10, for (uint8 i = 0; i < 10; i++) { uint32 subSurveyId; // ref to i'th GMSurveySurveys.dbc field (all fields in that dbc point to fields in GMSurveyQuestions.dbc) - recv_data >> subSurveyId; + recvData >> subSurveyId; if (!subSurveyId) break; uint8 rank; // probably some sort of ref to GMSurveyAnswers.dbc - recv_data >> rank; + recvData >> rank; std::string comment; // comment ("Usage: GMSurveyAnswerSubmit(question, rank, comment)") - recv_data >> comment; + recvData >> comment; PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_GM_SUBSURVEY); stmt->setUInt32(0, nextSurveyID); @@ -186,7 +186,7 @@ void WorldSession::HandleGMSurveySubmit(WorldPacket& recv_data) } std::string comment; // just a guess - recv_data >> comment; + recvData >> comment; PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_GM_SURVEY); stmt->setUInt32(0, GUID_LOPART(GetPlayer()->GetGUID())); @@ -197,17 +197,17 @@ void WorldSession::HandleGMSurveySubmit(WorldPacket& recv_data) CharacterDatabase.Execute(stmt); } -void WorldSession::HandleReportLag(WorldPacket& recv_data) +void WorldSession::HandleReportLag(WorldPacket& recvData) { // just put the lag report into the database... // can't think of anything else to do with it uint32 lagType, mapId; - recv_data >> lagType; - recv_data >> mapId; + recvData >> lagType; + recvData >> mapId; float x, y, z; - recv_data >> x; - recv_data >> y; - recv_data >> z; + recvData >> x; + recvData >> y; + recvData >> z; PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_LAG_REPORT); stmt->setUInt32(0, GUID_LOPART(GetPlayer()->GetGUID())); diff --git a/src/server/game/Handlers/TradeHandler.cpp b/src/server/game/Handlers/TradeHandler.cpp index f50b9ebd311..08f2d61826e 100755 --- a/src/server/game/Handlers/TradeHandler.cpp +++ b/src/server/game/Handlers/TradeHandler.cpp @@ -155,9 +155,9 @@ void WorldSession::moveItems(Item* myItems[], Item* hisItems[]) if (!AccountMgr::IsPlayerAccount(_player->GetSession()->GetSecurity()) && sWorld->getBoolConfig(CONFIG_GM_LOG_TRADE)) { sLog->outCommand(_player->GetSession()->GetAccountId(), "GM %s (Account: %u) trade: %s (Entry: %d Count: %u) to player: %s (Account: %u)", - _player->GetName(), _player->GetSession()->GetAccountId(), + _player->GetName().c_str(), _player->GetSession()->GetAccountId(), myItems[i]->GetTemplate()->Name1.c_str(), myItems[i]->GetEntry(), myItems[i]->GetCount(), - trader->GetName(), trader->GetSession()->GetAccountId()); + trader->GetName().c_str(), trader->GetSession()->GetAccountId()); } // adjust time (depends on /played) @@ -173,9 +173,9 @@ void WorldSession::moveItems(Item* myItems[], Item* hisItems[]) if (!AccountMgr::IsPlayerAccount(trader->GetSession()->GetSecurity()) && sWorld->getBoolConfig(CONFIG_GM_LOG_TRADE)) { sLog->outCommand(trader->GetSession()->GetAccountId(), "GM %s (Account: %u) trade: %s (Entry: %d Count: %u) to player: %s (Account: %u)", - trader->GetName(), trader->GetSession()->GetAccountId(), + trader->GetName().c_str(), trader->GetSession()->GetAccountId(), hisItems[i]->GetTemplate()->Name1.c_str(), hisItems[i]->GetEntry(), hisItems[i]->GetCount(), - _player->GetName(), _player->GetSession()->GetAccountId()); + _player->GetName().c_str(), _player->GetSession()->GetAccountId()); } // adjust time (depends on /played) @@ -463,16 +463,16 @@ void WorldSession::HandleAcceptTradeOpcode(WorldPacket& /*recvPacket*/) if (!AccountMgr::IsPlayerAccount(_player->GetSession()->GetSecurity()) && my_trade->GetMoney() > 0) { sLog->outCommand(_player->GetSession()->GetAccountId(), "GM %s (Account: %u) give money (Amount: %u) to player: %s (Account: %u)", - _player->GetName(), _player->GetSession()->GetAccountId(), + _player->GetName().c_str(), _player->GetSession()->GetAccountId(), my_trade->GetMoney(), - trader->GetName(), trader->GetSession()->GetAccountId()); + trader->GetName().c_str(), trader->GetSession()->GetAccountId()); } if (!AccountMgr::IsPlayerAccount(trader->GetSession()->GetSecurity()) && his_trade->GetMoney() > 0) { sLog->outCommand(trader->GetSession()->GetAccountId(), "GM %s (Account: %u) give money (Amount: %u) to player: %s (Account: %u)", - trader->GetName(), trader->GetSession()->GetAccountId(), + trader->GetName().c_str(), trader->GetSession()->GetAccountId(), his_trade->GetMoney(), - _player->GetName(), _player->GetSession()->GetAccountId()); + _player->GetName().c_str(), _player->GetSession()->GetAccountId()); } } diff --git a/src/server/game/Handlers/VehicleHandler.cpp b/src/server/game/Handlers/VehicleHandler.cpp index f0ccfc44e60..e16f535a757 100644 --- a/src/server/game/Handlers/VehicleHandler.cpp +++ b/src/server/game/Handlers/VehicleHandler.cpp @@ -23,7 +23,7 @@ #include "Log.h" #include "ObjectAccessor.h" -void WorldSession::HandleDismissControlledVehicle(WorldPacket &recv_data) +void WorldSession::HandleDismissControlledVehicle(WorldPacket &recvData) { sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Recvd CMSG_DISMISS_CONTROLLED_VEHICLE"); @@ -31,44 +31,44 @@ void WorldSession::HandleDismissControlledVehicle(WorldPacket &recv_data) if (!vehicleGUID) // something wrong here... { - recv_data.rfinish(); // prevent warnings spam + recvData.rfinish(); // prevent warnings spam return; } uint64 guid; - recv_data.readPackGUID(guid); + recvData.readPackGUID(guid); MovementInfo mi; mi.guid = guid; - ReadMovementInfo(recv_data, &mi); + ReadMovementInfo(recvData, &mi); _player->m_movementInfo = mi; _player->ExitVehicle(); } -void WorldSession::HandleChangeSeatsOnControlledVehicle(WorldPacket &recv_data) +void WorldSession::HandleChangeSeatsOnControlledVehicle(WorldPacket &recvData) { sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Recvd CMSG_CHANGE_SEATS_ON_CONTROLLED_VEHICLE"); Unit* vehicle_base = GetPlayer()->GetVehicleBase(); if (!vehicle_base) { - recv_data.rfinish(); // prevent warnings spam + recvData.rfinish(); // prevent warnings spam return; } VehicleSeatEntry const* seat = GetPlayer()->GetVehicle()->GetSeatForPassenger(GetPlayer()); if (!seat->CanSwitchFromSeat()) { - recv_data.rfinish(); // prevent warnings spam + recvData.rfinish(); // prevent warnings spam sLog->outError(LOG_FILTER_NETWORKIO, "HandleChangeSeatsOnControlledVehicle, Opcode: %u, Player %u tried to switch seats but current seatflags %u don't permit that.", - recv_data.GetOpcode(), GetPlayer()->GetGUIDLow(), seat->m_flags); + recvData.GetOpcode(), GetPlayer()->GetGUIDLow(), seat->m_flags); return; } - switch (recv_data.GetOpcode()) + switch (recvData.GetOpcode()) { case CMSG_REQUEST_VEHICLE_PREV_SEAT: GetPlayer()->ChangeSeat(-1, false); @@ -79,17 +79,17 @@ void WorldSession::HandleChangeSeatsOnControlledVehicle(WorldPacket &recv_data) case CMSG_CHANGE_SEATS_ON_CONTROLLED_VEHICLE: { uint64 guid; // current vehicle guid - recv_data.readPackGUID(guid); + recvData.readPackGUID(guid); MovementInfo movementInfo; - ReadMovementInfo(recv_data, &movementInfo); + ReadMovementInfo(recvData, &movementInfo); vehicle_base->m_movementInfo = movementInfo; uint64 accessory; // accessory guid - recv_data.readPackGUID(accessory); + recvData.readPackGUID(accessory); int8 seatId; - recv_data >> seatId; + recvData >> seatId; if (vehicle_base->GetGUID() != guid) return; @@ -107,10 +107,10 @@ void WorldSession::HandleChangeSeatsOnControlledVehicle(WorldPacket &recv_data) case CMSG_REQUEST_VEHICLE_SWITCH_SEAT: { uint64 guid; // current vehicle guid - recv_data.readPackGUID(guid); + recvData.readPackGUID(guid); int8 seatId; - recv_data >> seatId; + recvData >> seatId; if (vehicle_base->GetGUID() == guid) GetPlayer()->ChangeSeat(seatId); @@ -209,7 +209,7 @@ void WorldSession::HandleEjectPassenger(WorldPacket &data) sLog->outError(LOG_FILTER_NETWORKIO, "HandleEjectPassenger: Player %u tried to eject invalid GUID "UI64FMTD, GetPlayer()->GetGUIDLow(), guid); } -void WorldSession::HandleRequestVehicleExit(WorldPacket& /*recv_data*/) +void WorldSession::HandleRequestVehicleExit(WorldPacket& /*recvData*/) { sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Recvd CMSG_REQUEST_VEHICLE_EXIT"); diff --git a/src/server/game/Handlers/VoiceChatHandler.cpp b/src/server/game/Handlers/VoiceChatHandler.cpp index 34ad5ac3eae..785b4f8e5cd 100755 --- a/src/server/game/Handlers/VoiceChatHandler.cpp +++ b/src/server/game/Handlers/VoiceChatHandler.cpp @@ -22,24 +22,24 @@ #include "Opcodes.h" #include "Log.h" -void WorldSession::HandleVoiceSessionEnableOpcode(WorldPacket& recv_data) +void WorldSession::HandleVoiceSessionEnableOpcode(WorldPacket& recvData) { sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: CMSG_VOICE_SESSION_ENABLE"); // uint8 isVoiceEnabled, uint8 isMicrophoneEnabled - recv_data.read_skip<uint8>(); - recv_data.read_skip<uint8>(); + recvData.read_skip<uint8>(); + recvData.read_skip<uint8>(); } -void WorldSession::HandleChannelVoiceOnOpcode(WorldPacket& /*recv_data*/) +void WorldSession::HandleChannelVoiceOnOpcode(WorldPacket& /*recvData*/) { sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: CMSG_CHANNEL_VOICE_ON"); // Enable Voice button in channel context menu } -void WorldSession::HandleSetActiveVoiceChannel(WorldPacket& recv_data) +void WorldSession::HandleSetActiveVoiceChannel(WorldPacket& recvData) { sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: CMSG_SET_ACTIVE_VOICE_CHANNEL"); - recv_data.read_skip<uint32>(); - recv_data.read_skip<char*>(); + recvData.read_skip<uint32>(); + recvData.read_skip<char*>(); } diff --git a/src/server/game/Mails/Mail.h b/src/server/game/Mails/Mail.h index 10095268ead..7c12ac1a1c6 100755 --- a/src/server/game/Mails/Mail.h +++ b/src/server/game/Mails/Mail.h @@ -119,7 +119,7 @@ class MailDraft explicit MailDraft(uint16 mailTemplateId, bool need_items = true) : m_mailTemplateId(mailTemplateId), m_mailTemplateItemsNeed(need_items), m_money(0), m_COD(0) {} - MailDraft(std::string subject, std::string body) + MailDraft(std::string const& subject, std::string const& body) : m_mailTemplateId(0), m_mailTemplateItemsNeed(false), m_subject(subject), m_body(body), m_money(0), m_COD(0) {} public: // Accessors uint16 GetMailTemplateId() const { return m_mailTemplateId; } diff --git a/src/server/game/Maps/Map.cpp b/src/server/game/Maps/Map.cpp index 85ce35e17a6..b1200252c54 100755 --- a/src/server/game/Maps/Map.cpp +++ b/src/server/game/Maps/Map.cpp @@ -730,7 +730,7 @@ void Map::PlayerRelocation(Player* player, float x, float y, float z, float orie if (old_cell.DiffGrid(new_cell) || old_cell.DiffCell(new_cell)) { - sLog->outDebug(LOG_FILTER_MAPS, "Player %s relocation grid[%u, %u]cell[%u, %u]->grid[%u, %u]cell[%u, %u]", player->GetName(), old_cell.GridX(), old_cell.GridY(), old_cell.CellX(), old_cell.CellY(), new_cell.GridX(), new_cell.GridY(), new_cell.CellX(), new_cell.CellY()); + sLog->outDebug(LOG_FILTER_MAPS, "Player %s relocation grid[%u, %u]cell[%u, %u]->grid[%u, %u]cell[%u, %u]", player->GetName().c_str(), old_cell.GridX(), old_cell.GridY(), old_cell.CellX(), old_cell.CellY(), new_cell.GridX(), new_cell.GridY(), new_cell.CellX(), new_cell.CellY()); player->RemoveFromGrid(); @@ -1031,7 +1031,7 @@ void Map::RemoveAllPlayers() if (!player->IsBeingTeleportedFar()) { // this is happening for bg - sLog->outError(LOG_FILTER_MAPS, "Map::UnloadAll: player %s is still in map %u during unload, this should not happen!", player->GetName(), GetId()); + sLog->outError(LOG_FILTER_MAPS, "Map::UnloadAll: player %s is still in map %u during unload, this should not happen!", player->GetName().c_str(), GetId()); player->TeleportTo(player->m_homebindMapId, player->m_homebindX, player->m_homebindY, player->m_homebindZ, player->GetOrientation()); } } @@ -2326,7 +2326,7 @@ bool InstanceMap::CanEnter(Player* player) { if (player->GetMapRef().getTarget() == this) { - sLog->outError(LOG_FILTER_MAPS, "InstanceMap::CanEnter - player %s(%u) already in map %d, %d, %d!", player->GetName(), player->GetGUIDLow(), GetId(), GetInstanceId(), GetSpawnMode()); + sLog->outError(LOG_FILTER_MAPS, "InstanceMap::CanEnter - player %s(%u) already in map %d, %d, %d!", player->GetName().c_str(), player->GetGUIDLow(), GetId(), GetInstanceId(), GetSpawnMode()); ASSERT(false); return false; } @@ -2339,7 +2339,7 @@ bool InstanceMap::CanEnter(Player* player) uint32 maxPlayers = GetMaxPlayers(); if (GetPlayersCountExceptGMs() >= maxPlayers) { - sLog->outInfo(LOG_FILTER_MAPS, "MAP: Instance '%u' of map '%s' cannot have more than '%u' players. Player '%s' rejected", GetInstanceId(), GetMapName(), maxPlayers, player->GetName()); + sLog->outInfo(LOG_FILTER_MAPS, "MAP: Instance '%u' of map '%s' cannot have more than '%u' players. Player '%s' rejected", GetInstanceId(), GetMapName(), maxPlayers, player->GetName().c_str()); player->SendTransferAborted(GetId(), TRANSFER_ABORT_MAX_PLAYERS); return false; } @@ -2420,7 +2420,7 @@ bool InstanceMap::AddPlayerToMap(Player* player) // cannot enter other instances if bound permanently if (playerBind->save != mapSave) { - sLog->outError(LOG_FILTER_MAPS, "InstanceMap::Add: player %s(%d) is permanently bound to instance %d, %d, %d, %d, %d, %d but he is being put into instance %d, %d, %d, %d, %d, %d", player->GetName(), player->GetGUIDLow(), playerBind->save->GetMapId(), playerBind->save->GetInstanceId(), playerBind->save->GetDifficulty(), playerBind->save->GetPlayerCount(), playerBind->save->GetGroupCount(), playerBind->save->CanReset(), mapSave->GetMapId(), mapSave->GetInstanceId(), mapSave->GetDifficulty(), mapSave->GetPlayerCount(), mapSave->GetGroupCount(), mapSave->CanReset()); + sLog->outError(LOG_FILTER_MAPS, "InstanceMap::Add: player %s(%d) is permanently bound to instance %d, %d, %d, %d, %d, %d but he is being put into instance %d, %d, %d, %d, %d, %d", player->GetName().c_str(), player->GetGUIDLow(), playerBind->save->GetMapId(), playerBind->save->GetInstanceId(), playerBind->save->GetDifficulty(), playerBind->save->GetPlayerCount(), playerBind->save->GetGroupCount(), playerBind->save->CanReset(), mapSave->GetMapId(), mapSave->GetInstanceId(), mapSave->GetDifficulty(), mapSave->GetPlayerCount(), mapSave->GetGroupCount(), mapSave->CanReset()); return false; } } @@ -2432,7 +2432,7 @@ bool InstanceMap::AddPlayerToMap(Player* player) InstanceGroupBind* groupBind = group->GetBoundInstance(this); if (playerBind && playerBind->save != mapSave) { - sLog->outError(LOG_FILTER_MAPS, "InstanceMap::Add: player %s(%d) is being put into instance %d, %d, %d, %d, %d, %d but he is in group %d and is bound to instance %d, %d, %d, %d, %d, %d!", player->GetName(), player->GetGUIDLow(), mapSave->GetMapId(), mapSave->GetInstanceId(), mapSave->GetDifficulty(), mapSave->GetPlayerCount(), mapSave->GetGroupCount(), mapSave->CanReset(), GUID_LOPART(group->GetLeaderGUID()), playerBind->save->GetMapId(), playerBind->save->GetInstanceId(), playerBind->save->GetDifficulty(), playerBind->save->GetPlayerCount(), playerBind->save->GetGroupCount(), playerBind->save->CanReset()); + sLog->outError(LOG_FILTER_MAPS, "InstanceMap::Add: player %s(%d) is being put into instance %d, %d, %d, %d, %d, %d but he is in group %d and is bound to instance %d, %d, %d, %d, %d, %d!", player->GetName().c_str(), player->GetGUIDLow(), mapSave->GetMapId(), mapSave->GetInstanceId(), mapSave->GetDifficulty(), mapSave->GetPlayerCount(), mapSave->GetGroupCount(), mapSave->CanReset(), GUID_LOPART(group->GetLeaderGUID()), playerBind->save->GetMapId(), playerBind->save->GetInstanceId(), playerBind->save->GetDifficulty(), playerBind->save->GetPlayerCount(), playerBind->save->GetGroupCount(), playerBind->save->CanReset()); if (groupBind) sLog->outError(LOG_FILTER_MAPS, "InstanceMap::Add: the group is bound to the instance %d, %d, %d, %d, %d, %d", groupBind->save->GetMapId(), groupBind->save->GetInstanceId(), groupBind->save->GetDifficulty(), groupBind->save->GetPlayerCount(), groupBind->save->GetGroupCount(), groupBind->save->CanReset()); //ASSERT(false); @@ -2446,7 +2446,7 @@ bool InstanceMap::AddPlayerToMap(Player* player) // cannot jump to a different instance without resetting it if (groupBind->save != mapSave) { - sLog->outError(LOG_FILTER_MAPS, "InstanceMap::Add: player %s(%d) is being put into instance %d, %d, %d but he is in group %d which is bound to instance %d, %d, %d!", player->GetName(), player->GetGUIDLow(), mapSave->GetMapId(), mapSave->GetInstanceId(), mapSave->GetDifficulty(), GUID_LOPART(group->GetLeaderGUID()), groupBind->save->GetMapId(), groupBind->save->GetInstanceId(), groupBind->save->GetDifficulty()); + sLog->outError(LOG_FILTER_MAPS, "InstanceMap::Add: player %s(%d) is being put into instance %d, %d, %d but he is in group %d which is bound to instance %d, %d, %d!", player->GetName().c_str(), player->GetGUIDLow(), mapSave->GetMapId(), mapSave->GetInstanceId(), mapSave->GetDifficulty(), GUID_LOPART(group->GetLeaderGUID()), groupBind->save->GetMapId(), groupBind->save->GetInstanceId(), groupBind->save->GetDifficulty()); if (mapSave) sLog->outError(LOG_FILTER_MAPS, "MapSave players: %d, group count: %d", mapSave->GetPlayerCount(), mapSave->GetGroupCount()); else @@ -2493,7 +2493,7 @@ bool InstanceMap::AddPlayerToMap(Player* player) // first player enters (no players yet) SetResetSchedule(false); - sLog->outInfo(LOG_FILTER_MAPS, "MAP: Player '%s' entered instance '%u' of map '%s'", player->GetName(), GetInstanceId(), GetMapName()); + sLog->outInfo(LOG_FILTER_MAPS, "MAP: Player '%s' entered instance '%u' of map '%s'", player->GetName().c_str(), GetInstanceId(), GetMapName()); // initialize unload state m_unloadTimer = 0; m_resetAfterUnload = false; @@ -2519,7 +2519,7 @@ void InstanceMap::Update(const uint32 t_diff) void InstanceMap::RemovePlayerFromMap(Player* player, bool remove) { - sLog->outInfo(LOG_FILTER_MAPS, "MAP: Removing player '%s' from instance '%u' of map '%s' before relocating to another map", player->GetName(), GetInstanceId(), GetMapName()); + sLog->outInfo(LOG_FILTER_MAPS, "MAP: Removing player '%s' from instance '%u' of map '%s' before relocating to another map", player->GetName().c_str(), GetInstanceId(), GetMapName()); //if last player set unload timer if (!m_unloadTimer && m_mapRefManager.getSize() == 1) m_unloadTimer = m_unloadWhenEmpty ? MIN_UNLOAD_DELAY : std::max(sWorld->getIntConfig(CONFIG_INSTANCE_UNLOAD_DELAY), (uint32)MIN_UNLOAD_DELAY); @@ -2614,7 +2614,7 @@ void InstanceMap::PermBindAllPlayers(Player* source) InstanceSave* save = sInstanceSaveMgr->GetInstanceSave(GetInstanceId()); if (!save) { - sLog->outError(LOG_FILTER_MAPS, "Cannot bind player (GUID: %u, Name: %s), because no instance save is available for instance map (Name: %s, Entry: %u, InstanceId: %u)!", source->GetGUIDLow(), source->GetName(), source->GetMap()->GetMapName(), source->GetMapId(), GetInstanceId()); + sLog->outError(LOG_FILTER_MAPS, "Cannot bind player (GUID: %u, Name: %s), because no instance save is available for instance map (Name: %s, Entry: %u, InstanceId: %u)!", source->GetGUIDLow(), source->GetName().c_str(), source->GetMap()->GetMapName(), source->GetMapId(), GetInstanceId()); return; } @@ -2758,7 +2758,7 @@ bool BattlegroundMap::AddPlayerToMap(Player* player) void BattlegroundMap::RemovePlayerFromMap(Player* player, bool remove) { - sLog->outInfo(LOG_FILTER_MAPS, "MAP: Removing player '%s' from bg '%u' of map '%s' before relocating to another map", player->GetName(), GetInstanceId(), GetMapName()); + sLog->outInfo(LOG_FILTER_MAPS, "MAP: Removing player '%s' from bg '%u' of map '%s' before relocating to another map", player->GetName().c_str(), GetInstanceId(), GetMapName()); Map::RemovePlayerFromMap(player, remove); } diff --git a/src/server/game/Maps/MapManager.cpp b/src/server/game/Maps/MapManager.cpp index b49d7db0a27..f6aa6ff7dc3 100755 --- a/src/server/game/Maps/MapManager.cpp +++ b/src/server/game/Maps/MapManager.cpp @@ -192,7 +192,7 @@ bool MapManager::CanPlayerEnter(uint32 mapid, Player* player, bool loginCheck) // probably there must be special opcode, because client has this string constant in GlobalStrings.lua // TODO: this is not a good place to send the message player->GetSession()->SendAreaTriggerMessage(player->GetSession()->GetTrinityString(LANG_INSTANCE_RAID_GROUP_ONLY), mapName); - sLog->outDebug(LOG_FILTER_MAPS, "MAP: Player '%s' must be in a raid group to enter instance '%s'", player->GetName(), mapName); + sLog->outDebug(LOG_FILTER_MAPS, "MAP: Player '%s' must be in a raid group to enter instance '%s'", player->GetName().c_str(), mapName); return false; } } @@ -216,15 +216,15 @@ bool MapManager::CanPlayerEnter(uint32 mapid, Player* player, bool loginCheck) { WorldPacket data(SMSG_CORPSE_NOT_IN_INSTANCE); player->GetSession()->SendPacket(&data); - sLog->outDebug(LOG_FILTER_MAPS, "MAP: Player '%s' does not have a corpse in instance '%s' and cannot enter.", player->GetName(), mapName); + sLog->outDebug(LOG_FILTER_MAPS, "MAP: Player '%s' does not have a corpse in instance '%s' and cannot enter.", player->GetName().c_str(), mapName); return false; } - sLog->outDebug(LOG_FILTER_MAPS, "MAP: Player '%s' has corpse in instance '%s' and can enter.", player->GetName(), mapName); + sLog->outDebug(LOG_FILTER_MAPS, "MAP: Player '%s' has corpse in instance '%s' and can enter.", player->GetName().c_str(), mapName); player->ResurrectPlayer(0.5f, false); player->SpawnCorpseBones(); } else - sLog->outDebug(LOG_FILTER_MAPS, "Map::CanPlayerEnter - player '%s' is dead but does not have a corpse!", player->GetName()); + sLog->outDebug(LOG_FILTER_MAPS, "Map::CanPlayerEnter - player '%s' is dead but does not have a corpse!", player->GetName().c_str()); } //Get instance where player's group is bound & its map diff --git a/src/server/game/Miscellaneous/Language.h b/src/server/game/Miscellaneous/Language.h index 6868db35975..07bfd284a7d 100755 --- a/src/server/game/Miscellaneous/Language.h +++ b/src/server/game/Miscellaneous/Language.h @@ -990,6 +990,12 @@ enum TrinityStrings LANG_WORLD_CLOSED = 7523, LANG_WORLD_OPENED = 7524, + LANG_LFG_PLAYER_INFO = 9980, + LANG_LFG_GROUP_INFO = 9981, + LANG_LFG_NOT_IN_GROUP = 9982, + LANG_LFG_CLEAN = 9983, + LANG_LFG_OPTIONS = 9984, + LANG_LFG_OPTIONS_CHANGED = 9985, LANG_LFG_STATE_NONE = 9986, LANG_LFG_STATE_ROLECHECK = 9987, LANG_LFG_STATE_QUEUED = 9988, @@ -1098,4 +1104,3 @@ enum TrinityStrings // For other tables maybe 2000010000-2147483647 (max index) }; #endif - diff --git a/src/server/game/Movement/MotionMaster.cpp b/src/server/game/Movement/MotionMaster.cpp index 386a95fa838..b9cfbdf024f 100644 --- a/src/server/game/Movement/MotionMaster.cpp +++ b/src/server/game/Movement/MotionMaster.cpp @@ -44,7 +44,8 @@ void MotionMaster::Initialize() { MovementGenerator *curr = top(); pop(); - if (curr) DirectDelete(curr); + if (curr) + DirectDelete(curr); } InitDefault(); @@ -500,14 +501,14 @@ void MotionMaster::MoveTaxiFlight(uint32 path, uint32 pathnode) { if (path < sTaxiPathNodesByPath.size()) { - sLog->outDebug(LOG_FILTER_GENERAL, "%s taxi to (Path %u node %u)", _owner->GetName(), path, pathnode); + sLog->outDebug(LOG_FILTER_GENERAL, "%s taxi to (Path %u node %u)", _owner->GetName().c_str(), path, pathnode); FlightPathMovementGenerator* mgen = new FlightPathMovementGenerator(sTaxiPathNodesByPath[path], pathnode); Mutate(mgen, MOTION_SLOT_CONTROLLED); } else { sLog->outError(LOG_FILTER_GENERAL, "%s attempt taxi to (not existed Path %u node %u)", - _owner->GetName(), path, pathnode); + _owner->GetName().c_str(), path, pathnode); } } else diff --git a/src/server/game/Movement/MovementGenerators/WaypointMovementGenerator.cpp b/src/server/game/Movement/MovementGenerators/WaypointMovementGenerator.cpp index c576d7389f3..22b2a2a450b 100755 --- a/src/server/game/Movement/MovementGenerators/WaypointMovementGenerator.cpp +++ b/src/server/game/Movement/MovementGenerators/WaypointMovementGenerator.cpp @@ -41,7 +41,7 @@ void WaypointMovementGenerator<Creature>::LoadPath(Creature* creature) if (!i_path) { // No movement found for entry - sLog->outError(LOG_FILTER_SQL, "WaypointMovementGenerator::LoadPath: creature %s (Entry: %u GUID: %u) doesn't have waypoint path id: %u", creature->GetName(), creature->GetEntry(), creature->GetGUIDLow(), path_id); + sLog->outError(LOG_FILTER_SQL, "WaypointMovementGenerator::LoadPath: creature %s (Entry: %u GUID: %u) doesn't have waypoint path id: %u", creature->GetName().c_str(), creature->GetEntry(), creature->GetGUIDLow(), path_id); return; } @@ -283,7 +283,7 @@ void FlightPathMovementGenerator::DoEventIfAny(Player* player, TaxiPathNodeEntry { if (uint32 eventid = departure ? node.departureEventID : node.arrivalEventID) { - sLog->outDebug(LOG_FILTER_MAPSCRIPTS, "Taxi %s event %u of node %u of path %u for player %s", departure ? "departure" : "arrival", eventid, node.index, node.path, player->GetName()); + sLog->outDebug(LOG_FILTER_MAPSCRIPTS, "Taxi %s event %u of node %u of path %u for player %s", departure ? "departure" : "arrival", eventid, node.index, node.path, player->GetName().c_str()); player->GetMap()->ScriptsStart(sEventScripts, eventid, player, player); } } diff --git a/src/server/game/Movement/Spline/MoveSpline.cpp b/src/server/game/Movement/Spline/MoveSpline.cpp index 699d054be4b..7160f64c0fb 100644 --- a/src/server/game/Movement/Spline/MoveSpline.cpp +++ b/src/server/game/Movement/Spline/MoveSpline.cpp @@ -19,6 +19,7 @@ #include "MoveSpline.h" #include <sstream> #include "Log.h" +#include "Creature.h" namespace Movement{ @@ -195,12 +196,12 @@ MoveSpline::MoveSpline() : m_Id(0), time_passed(0), /// ============================================================================================ -bool MoveSplineInitArgs::Validate() const +bool MoveSplineInitArgs::Validate(Unit* unit) const { #define CHECK(exp) \ if (!(exp))\ {\ - sLog->outError(LOG_FILTER_GENERAL, "MoveSplineInitArgs::Validate: expression '%s' failed", #exp);\ + sLog->outError(LOG_FILTER_GENERAL, "MoveSplineInitArgs::Validate: expression '%s' failed for GUID: %u", #exp, unit->GetTypeId() == TYPEID_PLAYER ? unit->GetGUIDLow() : unit->ToCreature()->GetDBTableGUIDLow());\ return false;\ } CHECK(path.size() > 1); diff --git a/src/server/game/Movement/Spline/MoveSplineInit.cpp b/src/server/game/Movement/Spline/MoveSplineInit.cpp index edef9cfed43..67b019b93f7 100644 --- a/src/server/game/Movement/Spline/MoveSplineInit.cpp +++ b/src/server/game/Movement/Spline/MoveSplineInit.cpp @@ -98,7 +98,7 @@ namespace Movement if (!args.HasVelocity) args.velocity = unit->GetSpeed(SelectSpeedType(moveFlags)); - if (!args.Validate()) + if (!args.Validate(&unit)) return 0; if (moveFlags & MOVEMENTFLAG_ROOT) diff --git a/src/server/game/Movement/Spline/MoveSplineInitArgs.h b/src/server/game/Movement/Spline/MoveSplineInitArgs.h index de02b35d0a0..32045629c9f 100644 --- a/src/server/game/Movement/Spline/MoveSplineInitArgs.h +++ b/src/server/game/Movement/Spline/MoveSplineInitArgs.h @@ -22,6 +22,8 @@ #include "MoveSplineFlag.h" #include <G3D/Vector3.h> +class Unit; + namespace Movement { typedef std::vector<Vector3> PointsArray; @@ -61,7 +63,7 @@ namespace Movement bool TransformForTransport; /** Returns true to show that the arguments were configured correctly and MoveSpline initialization will succeed. */ - bool Validate() const; + bool Validate(Unit* unit) const; private: bool _checkPathBounds() const; }; diff --git a/src/server/game/OutdoorPvP/OutdoorPvP.cpp b/src/server/game/OutdoorPvP/OutdoorPvP.cpp index 6985cb92804..5e3d37acb71 100755 --- a/src/server/game/OutdoorPvP/OutdoorPvP.cpp +++ b/src/server/game/OutdoorPvP/OutdoorPvP.cpp @@ -29,12 +29,11 @@ #include "GridNotifiersImpl.h" #include "CellImpl.h" -OPvPCapturePoint::OPvPCapturePoint(OutdoorPvP* pvp) : -m_capturePointGUID(0), m_capturePoint(NULL), m_maxValue(0.0f), m_minValue(0.0f), m_maxSpeed(0), -m_value(0), m_team(TEAM_NEUTRAL), m_OldState(OBJECTIVESTATE_NEUTRAL), -m_State(OBJECTIVESTATE_NEUTRAL), m_neutralValuePct(0), m_PvP(pvp) -{ -} +OPvPCapturePoint::OPvPCapturePoint(OutdoorPvP* pvp): + m_capturePointGUID(0), m_capturePoint(NULL), m_maxValue(0.0f), m_minValue(0.0f), m_maxSpeed(0), + m_value(0), m_team(TEAM_NEUTRAL), m_OldState(OBJECTIVESTATE_NEUTRAL), + m_State(OBJECTIVESTATE_NEUTRAL), m_neutralValuePct(0), m_PvP(pvp) +{ } bool OPvPCapturePoint::HandlePlayerEnter(Player* player) { @@ -44,14 +43,14 @@ bool OPvPCapturePoint::HandlePlayerEnter(Player* player) player->SendUpdateWorldState(m_capturePoint->GetGOInfo()->capturePoint.worldstate2, (uint32)ceil((m_value + m_maxValue) / (2 * m_maxValue) * 100.0f)); player->SendUpdateWorldState(m_capturePoint->GetGOInfo()->capturePoint.worldstate3, m_neutralValuePct); } - return m_activePlayers[player->GetTeamId()].insert(player).second; + return m_activePlayers[player->GetTeamId()].insert(player->GetGUID()).second; } void OPvPCapturePoint::HandlePlayerLeave(Player* player) { if (m_capturePoint) player->SendUpdateWorldState(m_capturePoint->GetGOInfo()->capturePoint.worldState1, 0); - m_activePlayers[player->GetTeamId()].erase(player); + m_activePlayers[player->GetTeamId()].erase(player->GetGUID()); } void OPvPCapturePoint::SendChangePhase() @@ -243,7 +242,7 @@ OutdoorPvP::~OutdoorPvP() void OutdoorPvP::HandlePlayerEnterZone(Player* player, uint32 /*zone*/) { - m_players[player->GetTeamId()].insert(player); + m_players[player->GetTeamId()].insert(player->GetGUID()); } void OutdoorPvP::HandlePlayerLeaveZone(Player* player, uint32 /*zone*/) @@ -254,8 +253,8 @@ void OutdoorPvP::HandlePlayerLeaveZone(Player* player, uint32 /*zone*/) // remove the world state information from the player (we can't keep everyone up to date, so leave out those who are not in the concerning zones) if (!player->GetSession()->PlayerLogout()) SendRemoveWorldStates(player); - m_players[player->GetTeamId()].erase(player); - sLog->outDebug(LOG_FILTER_OUTDOORPVP, "Player %s left an outdoorpvp zone", player->GetName()); + m_players[player->GetTeamId()].erase(player->GetGUID()); + sLog->outDebug(LOG_FILTER_OUTDOORPVP, "Player %s left an outdoorpvp zone", player->GetName().c_str()); } void OutdoorPvP::HandlePlayerResurrects(Player* /*player*/, uint32 /*zone*/) @@ -281,15 +280,10 @@ bool OPvPCapturePoint::Update(uint32 diff) float radius = (float)m_capturePoint->GetGOInfo()->capturePoint.radius; for (uint32 team = 0; team < 2; ++team) - { - for (PlayerSet::iterator itr = m_activePlayers[team].begin(); itr != m_activePlayers[team].end();) - { - Player* player = *itr; - ++itr; - if (!m_capturePoint->IsWithinDistInMap(player, radius) || !player->IsOutdoorPvPActive()) - HandlePlayerLeave(player); - } - } + for (PlayerSet::iterator itr = m_activePlayers[team].begin(); itr != m_activePlayers[team].end(); ++itr) + if (Player* player = ObjectAccessor::FindPlayer(*itr)) + if (!m_capturePoint->IsWithinDistInMap(player, radius) || !player->IsOutdoorPvPActive()) + HandlePlayerLeave(player); std::list<Player*> players; Trinity::AnyPlayerInObjectRangeCheck checker(m_capturePoint, radius); @@ -298,9 +292,10 @@ bool OPvPCapturePoint::Update(uint32 diff) for (std::list<Player*>::iterator itr = players.begin(); itr != players.end(); ++itr) { - if ((*itr)->IsOutdoorPvPActive()) + Player* const player = *itr; + if (player->IsOutdoorPvPActive()) { - if (m_activePlayers[(*itr)->GetTeamId()].insert(*itr).second) + if (m_activePlayers[player->GetTeamId()].insert(player->GetGUID()).second) HandlePlayerEnter(*itr); } } @@ -397,7 +392,8 @@ void OutdoorPvP::SendUpdateWorldState(uint32 field, uint32 value) if (m_sendUpdate) for (int i = 0; i < 2; ++i) for (PlayerSet::iterator itr = m_players[i].begin(); itr != m_players[i].end(); ++itr) - (*itr)->SendUpdateWorldState(field, value); + if (Player * const player = ObjectAccessor::FindPlayer(*itr)) + player->SendUpdateWorldState(field, value); } void OPvPCapturePoint::SendUpdateWorldState(uint32 field, uint32 value) @@ -406,9 +402,8 @@ void OPvPCapturePoint::SendUpdateWorldState(uint32 field, uint32 value) { // send to all players present in the area for (PlayerSet::iterator itr = m_activePlayers[team].begin(); itr != m_activePlayers[team].end(); ++itr) - { - (*itr)->SendUpdateWorldState(field, value); - } + if (Player * const player = ObjectAccessor::FindPlayer(*itr)) + player->SendUpdateWorldState(field, value); } } @@ -429,7 +424,8 @@ void OPvPCapturePoint::SendObjectiveComplete(uint32 id, uint64 guid) // send to all players present in the area for (PlayerSet::iterator itr = m_activePlayers[team].begin(); itr != m_activePlayers[team].end(); ++itr) - (*itr)->KilledMonsterCredit(id, guid); + if (Player * const player = ObjectAccessor::FindPlayer(*itr)) + player->KilledMonsterCredit(id, guid); } void OutdoorPvP::HandleKill(Player* killer, Unit* killed) @@ -476,7 +472,8 @@ bool OutdoorPvP::IsInsideObjective(Player* player) const bool OPvPCapturePoint::IsInsideObjective(Player* player) const { - return m_activePlayers[player->GetTeamId()].find(player) != m_activePlayers[player->GetTeamId()].end(); + PlayerSet const &plSet = m_activePlayers[player->GetTeamId()]; + return plSet.find(player->GetGUID()) != plSet.end(); } bool OutdoorPvP::HandleCustomSpell(Player* player, uint32 spellId, GameObject* go) @@ -566,7 +563,8 @@ void OutdoorPvP::BroadcastPacket(WorldPacket &data) const // This is faster than sWorld->SendZoneMessage for (uint32 team = 0; team < 2; ++team) for (PlayerSet::const_iterator itr = m_players[team].begin(); itr != m_players[team].end(); ++itr) - (*itr)->GetSession()->SendPacket(&data); + if (Player * const player = ObjectAccessor::FindPlayer(*itr)) + player->GetSession()->SendPacket(&data); } void OutdoorPvP::RegisterZone(uint32 zoneId) @@ -574,19 +572,26 @@ void OutdoorPvP::RegisterZone(uint32 zoneId) sOutdoorPvPMgr->AddZone(zoneId, this); } -bool OutdoorPvP::HasPlayer(Player* player) const +bool OutdoorPvP::HasPlayer(Player const* player) const { - return m_players[player->GetTeamId()].find(player) != m_players[player->GetTeamId()].end(); + PlayerSet const &plSet = m_players[player->GetTeamId()]; + return plSet.find(player->GetGUID()) != plSet.end(); } void OutdoorPvP::TeamCastSpell(TeamId team, int32 spellId) { if (spellId > 0) + { for (PlayerSet::iterator itr = m_players[team].begin(); itr != m_players[team].end(); ++itr) - (*itr)->CastSpell(*itr, (uint32)spellId, true); + if (Player * const player = ObjectAccessor::FindPlayer(*itr)) + player->CastSpell(player, (uint32)spellId, true); + } else + { for (PlayerSet::iterator itr = m_players[team].begin(); itr != m_players[team].end(); ++itr) - (*itr)->RemoveAura((uint32)-spellId); // by stack? + if (Player * const player = ObjectAccessor::FindPlayer(*itr)) + player->RemoveAura((uint32)-spellId); // by stack? + } } void OutdoorPvP::TeamApplyBuff(TeamId team, uint32 spellId, uint32 spellId2) diff --git a/src/server/game/OutdoorPvP/OutdoorPvP.h b/src/server/game/OutdoorPvP/OutdoorPvP.h index e896fa2acf6..e9d5ff9dfdc 100755 --- a/src/server/game/OutdoorPvP/OutdoorPvP.h +++ b/src/server/game/OutdoorPvP/OutdoorPvP.h @@ -18,7 +18,7 @@ #ifndef OUTDOOR_PVP_H_ #define OUTDOOR_PVP_H_ -#include "Utilities/Util.h" +#include "Util.h" #include "SharedDefines.h" #include "ZoneScript.h" @@ -85,7 +85,7 @@ class Unit; struct GossipMenuItems; class OutdoorPvP; -typedef std::set<Player*> PlayerSet; +typedef std::set<uint64> PlayerSet; class OPvPCapturePoint { @@ -285,7 +285,7 @@ class OutdoorPvP : public ZoneScript void RegisterZone(uint32 zoneid); - bool HasPlayer(Player* player) const; + bool HasPlayer(Player const * player) const; void TeamCastSpell(TeamId team, int32 spellId); }; diff --git a/src/server/game/Quests/QuestDef.h b/src/server/game/Quests/QuestDef.h index 5a8891d888c..58734751cea 100755 --- a/src/server/game/Quests/QuestDef.h +++ b/src/server/game/Quests/QuestDef.h @@ -222,18 +222,17 @@ class Quest uint32 GetSrcItemId() const { return SourceItemId; } uint32 GetSrcItemCount() const { return SourceItemIdCount; } uint32 GetSrcSpell() const { return SourceSpellid; } - std::string GetTitle() const { return Title; } - std::string GetDetails() const { return Details; } - std::string GetObjectives() const { return Objectives; } - std::string GetOfferRewardText() const { return OfferRewardText; } - std::string GetRequestItemsText() const { return RequestItemsText; } - std::string GetEndText() const { return EndText; } - std::string GetCompletedText() const { return CompletedText; } + std::string const& GetTitle() const { return Title; } + std::string const& GetDetails() const { return Details; } + std::string const& GetObjectives() const { return Objectives; } + std::string const& GetOfferRewardText() const { return OfferRewardText; } + std::string const& GetRequestItemsText() const { return RequestItemsText; } + std::string const& GetEndText() const { return EndText; } + std::string const& GetCompletedText() const { return CompletedText; } int32 GetRewOrReqMoney() const; uint32 GetRewHonorAddition() const { return RewardHonor; } float GetRewHonorMultiplier() const { return RewardHonorMultiplier; } - uint32 GetRewMoneyMaxLevel() const { return RewardMoneyMaxLevel; } - // use in XP calculation at client + uint32 GetRewMoneyMaxLevel() const { return RewardMoneyMaxLevel; } // use in XP calculation at client uint32 GetRewSpell() const { return RewardSpell; } int32 GetRewSpellCast() const { return RewardSpellCast; } uint32 GetRewMailTemplateId() const { return RewardMailTemplateId; } diff --git a/src/server/game/Reputation/ReputationMgr.cpp b/src/server/game/Reputation/ReputationMgr.cpp index 7ef59916099..356a70ba6a5 100755 --- a/src/server/game/Reputation/ReputationMgr.cpp +++ b/src/server/game/Reputation/ReputationMgr.cpp @@ -45,7 +45,7 @@ bool ReputationMgr::IsAtWar(uint32 faction_id) const if (!factionEntry) { - sLog->outError(LOG_FILTER_GENERAL, "ReputationMgr::IsAtWar: Can't get AtWar flag of %s for unknown faction (faction id) #%u.", _player->GetName(), faction_id); + sLog->outError(LOG_FILTER_GENERAL, "ReputationMgr::IsAtWar: Can't get AtWar flag of %s for unknown faction (faction id) #%u.", _player->GetName().c_str(), faction_id); return 0; } @@ -68,7 +68,7 @@ int32 ReputationMgr::GetReputation(uint32 faction_id) const if (!factionEntry) { - sLog->outError(LOG_FILTER_GENERAL, "ReputationMgr::GetReputation: Can't get reputation of %s for unknown faction (faction id) #%u.", _player->GetName(), faction_id); + sLog->outError(LOG_FILTER_GENERAL, "ReputationMgr::GetReputation: Can't get reputation of %s for unknown faction (faction id) #%u.", _player->GetName().c_str(), faction_id); return 0; } diff --git a/src/server/game/Scripting/ScriptLoader.cpp b/src/server/game/Scripting/ScriptLoader.cpp index 5f3400804c3..56a020cad88 100755 --- a/src/server/game/Scripting/ScriptLoader.cpp +++ b/src/server/game/Scripting/ScriptLoader.cpp @@ -61,6 +61,7 @@ void AddSC_guild_commandscript(); void AddSC_honor_commandscript(); void AddSC_instance_commandscript(); void AddSC_learn_commandscript(); +void AddSC_lfg_commandscript(); void AddSC_list_commandscript(); void AddSC_lookup_commandscript(); void AddSC_message_commandscript(); @@ -90,6 +91,7 @@ void AddSC_npc_innkeeper(); void AddSC_npcs_special(); void AddSC_npc_taxi(); void AddSC_achievement_scripts(); +void AddSC_event_scripts(); //eastern kingdoms void AddSC_alterac_valley(); //Alterac Valley @@ -682,6 +684,7 @@ void AddCommandScripts() AddSC_instance_commandscript(); AddSC_learn_commandscript(); AddSC_lookup_commandscript(); + AddSC_lfg_commandscript(); AddSC_list_commandscript(); AddSC_message_commandscript(); AddSC_misc_commandscript(); @@ -713,6 +716,7 @@ void AddWorldScripts() AddSC_npc_taxi(); AddSC_achievement_scripts(); AddSC_chat_log(); + AddSC_event_scripts(); #endif } diff --git a/src/server/game/Server/Protocol/Opcodes.cpp b/src/server/game/Server/Protocol/Opcodes.cpp index af2ff2c6d86..9078f6720a0 100755 --- a/src/server/game/Server/Protocol/Opcodes.cpp +++ b/src/server/game/Server/Protocol/Opcodes.cpp @@ -688,7 +688,7 @@ OpcodeHandler opcodeTable[NUM_MSG_TYPES] = /*0x293*/ { "SMSG_LFG_OFFER_CONTINUE", STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_ServerSide }, /*0x294*/ { "CMSG_TEST_DROP_RATE", STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_NULL }, /*0x295*/ { "SMSG_TEST_DROP_RATE_RESULT", STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_ServerSide }, - /*0x296*/ { "CMSG_LFG_GET_STATUS", STATUS_UNHANDLED, PROCESS_INPLACE, &WorldSession::Handle_NULL }, + /*0x296*/ { "CMSG_LFG_GET_STATUS", STATUS_LOGGEDIN, PROCESS_THREADSAFE, &WorldSession::HandleLfgGetStatus }, /*0x297*/ { "SMSG_SHOW_MAILBOX", STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_ServerSide }, /*0x298*/ { "SMSG_RESET_RANGED_COMBAT_TIMER", STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_ServerSide }, /*0x299*/ { "SMSG_MEETINGSTONE_MEMBER_ADDED", STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_ServerSide }, diff --git a/src/server/game/Server/WorldSession.cpp b/src/server/game/Server/WorldSession.cpp index a3a850ff1c1..18ff3b32d67 100755 --- a/src/server/game/Server/WorldSession.cpp +++ b/src/server/game/Server/WorldSession.cpp @@ -45,6 +45,12 @@ #include "WardenWin.h" #include "WardenMac.h" +namespace { + +std::string const DefaultPlayerName = "<none>"; + +} // namespace + bool MapSessionFilter::Process(WorldPacket* packet) { OpcodeHandler const& opHandle = opcodeTable[packet->GetOpcode()]; @@ -137,29 +143,20 @@ WorldSession::~WorldSession() LoginDatabase.PExecute("UPDATE account SET online = 0 WHERE id = %u;", GetAccountId()); // One-time query } -/// Get the player name -std::string WorldSession::GetPlayerName(bool simple /* = true */) const - { - std::string name = "[Player: "; - uint32 guidLow = 0; +std::string const & WorldSession::GetPlayerName() const +{ + return _player != NULL ? _player->GetName() : DefaultPlayerName; +} - if (Player* player = GetPlayer()) - { - name.append(player->GetName()); - guidLow = player->GetGUIDLow(); - } - else - name.append("<none>"); +std::string WorldSession::GetPlayerInfo() const +{ + std::ostringstream ss; - if (!simple) - { - std::ostringstream ss; - ss << " (Guid: " << guidLow << ", Account: " << GetAccountId() << ")"; - name.append(ss.str()); - } + ss << "[Player: " << GetPlayerName() + << " (Guid: " << (_player != NULL ? _player->GetGUID() : 0) + << ", Account: " << GetAccountId() << ")]"; - name.append("]"); - return name; + return ss.str(); } /// Get player guid if available. Use for logging purposes only @@ -222,14 +219,14 @@ void WorldSession::QueuePacket(WorldPacket* new_packet) void WorldSession::LogUnexpectedOpcode(WorldPacket* packet, const char* status, const char *reason) { sLog->outError(LOG_FILTER_OPCODES, "Received unexpected opcode %s Status: %s Reason: %s from %s", - GetOpcodeNameForLogging(packet->GetOpcode()).c_str(), status, reason, GetPlayerName(false).c_str()); + GetOpcodeNameForLogging(packet->GetOpcode()).c_str(), status, reason, GetPlayerInfo().c_str()); } /// Logging helper for unexpected opcodes void WorldSession::LogUnprocessedTail(WorldPacket* packet) { sLog->outError(LOG_FILTER_OPCODES, "Unprocessed tail data (read stop at %u from %u) Opcode %s from %s", - uint32(packet->rpos()), uint32(packet->wpos()), GetOpcodeNameForLogging(packet->GetOpcode()).c_str(), GetPlayerName(false).c_str()); + uint32(packet->rpos()), uint32(packet->wpos()), GetOpcodeNameForLogging(packet->GetOpcode()).c_str(), GetPlayerInfo().c_str()); packet->print_storage(); } @@ -263,7 +260,7 @@ bool WorldSession::Update(uint32 diff, PacketFilter& updater) if (packet->GetOpcode() >= NUM_MSG_TYPES) { sLog->outError(LOG_FILTER_OPCODES, "Received non-existed opcode %s from %s", GetOpcodeNameForLogging(packet->GetOpcode()).c_str() - , GetPlayerName(false).c_str()); + , GetPlayerInfo().c_str()); sScriptMgr->OnUnknownPacketReceive(m_Socket, WorldPacket(*packet)); } else @@ -347,11 +344,11 @@ bool WorldSession::Update(uint32 diff, PacketFilter& updater) break; case STATUS_NEVER: sLog->outError(LOG_FILTER_OPCODES, "Received not allowed opcode %s from %s", GetOpcodeNameForLogging(packet->GetOpcode()).c_str() - , GetPlayerName(false).c_str()); + , GetPlayerInfo().c_str()); break; case STATUS_UNHANDLED: sLog->outDebug(LOG_FILTER_OPCODES, "Received not handled opcode %s from %s", GetOpcodeNameForLogging(packet->GetOpcode()).c_str() - , GetPlayerName(false).c_str()); + , GetPlayerInfo().c_str()); break; } } @@ -545,7 +542,8 @@ void WorldSession::LogoutPlayer(bool Save) // e.g if he got disconnected during a transfer to another map // calls to GetMap in this case may cause crashes _player->CleanupsBeforeDelete(); - sLog->outInfo(LOG_FILTER_CHARACTER, "Account: %d (IP: %s) Logout Character:[%s] (GUID: %u) Level: %d", GetAccountId(), GetRemoteAddress().c_str(), _player->GetName(), _player->GetGUIDLow(), _player->getLevel()); + sLog->outInfo(LOG_FILTER_CHARACTER, "Account: %d (IP: %s) Logout Character:[%s] (GUID: %u) Level: %d", + GetAccountId(), GetRemoteAddress().c_str(), _player->GetName().c_str(), _player->GetGUIDLow(), _player->getLevel()); if (Map* _map = _player->FindMap()) _map->RemovePlayerFromMap(_player, true); @@ -619,25 +617,25 @@ const char *WorldSession::GetTrinityString(int32 entry) const void WorldSession::Handle_NULL(WorldPacket& recvPacket) { sLog->outError(LOG_FILTER_OPCODES, "Received unhandled opcode %s from %s" - , GetOpcodeNameForLogging(recvPacket.GetOpcode()).c_str(), GetPlayerName(false).c_str()); + , GetOpcodeNameForLogging(recvPacket.GetOpcode()).c_str(), GetPlayerInfo().c_str()); } void WorldSession::Handle_EarlyProccess(WorldPacket& recvPacket) { sLog->outError(LOG_FILTER_OPCODES, "Received opcode %s that must be processed in WorldSocket::OnRead from %s" - , GetOpcodeNameForLogging(recvPacket.GetOpcode()).c_str(), GetPlayerName(false).c_str()); + , GetOpcodeNameForLogging(recvPacket.GetOpcode()).c_str(), GetPlayerInfo().c_str()); } void WorldSession::Handle_ServerSide(WorldPacket& recvPacket) { sLog->outError(LOG_FILTER_OPCODES, "Received server-side opcode %s from %s" - , GetOpcodeNameForLogging(recvPacket.GetOpcode()).c_str(), GetPlayerName(false).c_str()); + , GetOpcodeNameForLogging(recvPacket.GetOpcode()).c_str(), GetPlayerInfo().c_str()); } void WorldSession::Handle_Deprecated(WorldPacket& recvPacket) { sLog->outError(LOG_FILTER_OPCODES, "Received deprecated opcode %s from %s" - , GetOpcodeNameForLogging(recvPacket.GetOpcode()).c_str(), GetPlayerName(false).c_str()); + , GetOpcodeNameForLogging(recvPacket.GetOpcode()).c_str(), GetPlayerInfo().c_str()); } void WorldSession::SendAuthWaitQue(uint32 position) @@ -698,7 +696,7 @@ void WorldSession::LoadAccountData(PreparedQueryResult result, uint32 mask) while (result->NextRow()); } -void WorldSession::SetAccountData(AccountDataType type, time_t tm, std::string data) +void WorldSession::SetAccountData(AccountDataType type, time_t tm, std::string const& data) { uint32 id = 0; uint32 index = 0; @@ -1178,7 +1176,7 @@ void WorldSession::ProcessQueryCallbacks() } } -void WorldSession::InitWarden(BigNumber* k, std::string os) +void WorldSession::InitWarden(BigNumber* k, std::string const& os) { if (os == "Win") { diff --git a/src/server/game/Server/WorldSession.h b/src/server/game/Server/WorldSession.h index 3ff45bff3b1..7d5dba847d4 100755 --- a/src/server/game/Server/WorldSession.h +++ b/src/server/game/Server/WorldSession.h @@ -197,7 +197,7 @@ class CharacterCreateInfo friend class Player; protected: - CharacterCreateInfo(std::string name, uint8 race, uint8 cclass, uint8 gender, uint8 skin, uint8 face, uint8 hairStyle, uint8 hairColor, uint8 facialHair, uint8 outfitId, + CharacterCreateInfo(std::string const& name, uint8 race, uint8 cclass, uint8 gender, uint8 skin, uint8 face, uint8 hairStyle, uint8 hairColor, uint8 facialHair, uint8 outfitId, WorldPacket& data) : Name(name), Race(race), Class(cclass), Gender(gender), Skin(skin), Face(face), HairStyle(hairStyle), HairColor(hairColor), FacialHair(facialHair), OutfitId(outfitId), Data(data), CharCount(0) {} @@ -243,8 +243,8 @@ class WorldSession void SendPacket(WorldPacket const* packet); void SendNotification(const char *format, ...) ATTR_PRINTF(2, 3); void SendNotification(uint32 string_id, ...); - void SendPetNameInvalid(uint32 error, const std::string& name, DeclinedName *declinedName); - void SendPartyResult(PartyOperation operation, const std::string& member, PartyResult res, uint32 val = 0); + void SendPetNameInvalid(uint32 error, std::string const& name, DeclinedName *declinedName); + void SendPartyResult(PartyOperation operation, std::string const& member, PartyResult res, uint32 val = 0); void SendAreaTriggerMessage(const char* Text, ...) ATTR_PRINTF(2, 3); void SendSetPhaseShift(uint32 phaseShift); void SendQueryTimeResponse(); @@ -255,14 +255,16 @@ class WorldSession AccountTypes GetSecurity() const { return _security; } uint32 GetAccountId() const { return _accountId; } Player* GetPlayer() const { return _player; } - std::string GetPlayerName(bool simple = true) const; + std::string const& GetPlayerName() const; + std::string GetPlayerInfo() const; + uint32 GetGuidLow() const; void SetSecurity(AccountTypes security) { _security = security; } std::string const& GetRemoteAddress() { return m_Address; } void SetPlayer(Player* player); uint8 Expansion() const { return m_expansion; } - void InitWarden(BigNumber* k, std::string os); + void InitWarden(BigNumber* k, std::string const& os); /// Session in auth.queue currently void SetInQueue(bool state) { m_inQueue = state; } @@ -295,7 +297,7 @@ class WorldSession void SendNameQueryOpcode(uint64 guid); void SendTrainerList(uint64 guid); - void SendTrainerList(uint64 guid, const std::string& strTitle); + void SendTrainerList(uint64 guid, std::string const& strTitle); void SendListInventory(uint64 guid); void SendShowBank(uint64 guid); void SendTabardVendorActivate(uint64 guid); @@ -324,7 +326,7 @@ class WorldSession // Account Data AccountData* GetAccountData(AccountDataType type) { return &m_accountData[type]; } - void SetAccountData(AccountDataType type, time_t tm, std::string data); + void SetAccountData(AccountDataType type, time_t tm, std::string const& data); void SendAccountDataTimes(uint32 mask); void LoadGlobalAccountData(); void LoadAccountData(PreparedQueryResult result, uint32 mask); @@ -361,7 +363,7 @@ class WorldSession void SendDiscoverNewTaxiNode(uint32 nodeid); // Guild/Arena Team - void SendArenaTeamCommandResult(uint32 team_action, const std::string& team, const std::string& player, uint32 error_id); + void SendArenaTeamCommandResult(uint32 team_action, std::string const& team, std::string const& player, uint32 error_id); void SendNotInArenaTeamPacket(uint8 type); void SendPetitionShowList(uint64 guid); @@ -416,7 +418,7 @@ class WorldSession void HandlePlayerLoginOpcode(WorldPacket& recvPacket); void HandleCharEnum(PreparedQueryResult result); void HandlePlayerLogin(LoginQueryHolder * holder); - void HandleCharFactionOrRaceChange(WorldPacket& recv_data); + void HandleCharFactionOrRaceChange(WorldPacket& recvData); // played time void HandlePlayedTime(WorldPacket& recvPacket); @@ -433,15 +435,15 @@ class WorldSession void HandleInspectHonorStatsOpcode(WorldPacket& recvPacket); void HandleMoveWaterWalkAck(WorldPacket& recvPacket); - void HandleFeatherFallAck(WorldPacket& recv_data); + void HandleFeatherFallAck(WorldPacket& recvData); - void HandleMoveHoverAck(WorldPacket& recv_data); + void HandleMoveHoverAck(WorldPacket& recvData); void HandleMountSpecialAnimOpcode(WorldPacket& recvdata); // character view - void HandleShowingHelmOpcode(WorldPacket& recv_data); - void HandleShowingCloakOpcode(WorldPacket& recv_data); + void HandleShowingHelmOpcode(WorldPacket& recvData); + void HandleShowingCloakOpcode(WorldPacket& recvData); // repair void HandleRepairItemOpcode(WorldPacket& recvPacket); @@ -450,7 +452,7 @@ class WorldSession void HandleMoveKnockBackAck(WorldPacket& recvPacket); void HandleMoveTeleportAck(WorldPacket& recvPacket); - void HandleForceSpeedChangeAck(WorldPacket& recv_data); + void HandleForceSpeedChangeAck(WorldPacket& recvData); void HandlePingOpcode(WorldPacket& recvPacket); void HandleAuthSessionOpcode(WorldPacket& recvPacket); @@ -483,7 +485,7 @@ class WorldSession void HandleEmoteOpcode(WorldPacket& recvPacket); void HandleContactListOpcode(WorldPacket& recvPacket); void HandleAddFriendOpcode(WorldPacket& recvPacket); - void HandleAddFriendOpcodeCallBack(PreparedQueryResult result, std::string friendNote); + void HandleAddFriendOpcodeCallBack(PreparedQueryResult result, std::string const& friendNote); void HandleDelFriendOpcode(WorldPacket& recvPacket); void HandleAddIgnoreOpcode(WorldPacket& recvPacket); void HandleAddIgnoreOpcodeCallBack(PreparedQueryResult result); @@ -495,10 +497,10 @@ class WorldSession void HandleAreaTriggerOpcode(WorldPacket& recvPacket); - void HandleSetFactionAtWar(WorldPacket& recv_data); - void HandleSetFactionCheat(WorldPacket& recv_data); - void HandleSetWatchedFactionOpcode(WorldPacket& recv_data); - void HandleSetFactionInactiveOpcode(WorldPacket& recv_data); + void HandleSetFactionAtWar(WorldPacket& recvData); + void HandleSetFactionCheat(WorldPacket& recvData); + void HandleSetWatchedFactionOpcode(WorldPacket& recvData); + void HandleSetFactionInactiveOpcode(WorldPacket& recvData); void HandleUpdateAccountData(WorldPacket& recvPacket); void HandleRequestAccountData(WorldPacket& recvPacket); @@ -520,17 +522,17 @@ class WorldSession void HandleMoveWorldportAckOpcode(); // for server-side calls void HandleMovementOpcodes(WorldPacket& recvPacket); - void HandleSetActiveMoverOpcode(WorldPacket& recv_data); - void HandleMoveNotActiveMover(WorldPacket& recv_data); - void HandleDismissControlledVehicle(WorldPacket& recv_data); - void HandleRequestVehicleExit(WorldPacket& recv_data); - void HandleChangeSeatsOnControlledVehicle(WorldPacket& recv_data); - void HandleMoveTimeSkippedOpcode(WorldPacket& recv_data); + void HandleSetActiveMoverOpcode(WorldPacket& recvData); + void HandleMoveNotActiveMover(WorldPacket& recvData); + void HandleDismissControlledVehicle(WorldPacket& recvData); + void HandleRequestVehicleExit(WorldPacket& recvData); + void HandleChangeSeatsOnControlledVehicle(WorldPacket& recvData); + void HandleMoveTimeSkippedOpcode(WorldPacket& recvData); - void HandleRequestRaidInfoOpcode(WorldPacket& recv_data); + void HandleRequestRaidInfoOpcode(WorldPacket& recvData); - void HandleBattlefieldStatusOpcode(WorldPacket& recv_data); - void HandleBattleMasterHelloOpcode(WorldPacket& recv_data); + void HandleBattlefieldStatusOpcode(WorldPacket& recvData); + void HandleBattleMasterHelloOpcode(WorldPacket& recvData); void HandleGroupInviteOpcode(WorldPacket& recvPacket); //void HandleGroupCancelOpcode(WorldPacket& recvPacket); @@ -540,26 +542,26 @@ class WorldSession void HandleGroupUninviteGuidOpcode(WorldPacket& recvPacket); void HandleGroupSetLeaderOpcode(WorldPacket& recvPacket); void HandleGroupDisbandOpcode(WorldPacket& recvPacket); - void HandleOptOutOfLootOpcode(WorldPacket& recv_data); + void HandleOptOutOfLootOpcode(WorldPacket& recvData); void HandleLootMethodOpcode(WorldPacket& recvPacket); - void HandleLootRoll(WorldPacket& recv_data); - void HandleRequestPartyMemberStatsOpcode(WorldPacket& recv_data); - void HandleRaidTargetUpdateOpcode(WorldPacket& recv_data); - void HandleRaidReadyCheckOpcode(WorldPacket& recv_data); - void HandleRaidReadyCheckFinishedOpcode(WorldPacket& recv_data); - void HandleGroupRaidConvertOpcode(WorldPacket& recv_data); - void HandleGroupChangeSubGroupOpcode(WorldPacket& recv_data); - void HandleGroupAssistantLeaderOpcode(WorldPacket& recv_data); - void HandlePartyAssignmentOpcode(WorldPacket& recv_data); - - void HandlePetitionBuyOpcode(WorldPacket& recv_data); - void HandlePetitionShowSignOpcode(WorldPacket& recv_data); - void HandlePetitionQueryOpcode(WorldPacket& recv_data); - void HandlePetitionRenameOpcode(WorldPacket& recv_data); - void HandlePetitionSignOpcode(WorldPacket& recv_data); - void HandlePetitionDeclineOpcode(WorldPacket& recv_data); - void HandleOfferPetitionOpcode(WorldPacket& recv_data); - void HandleTurnInPetitionOpcode(WorldPacket& recv_data); + void HandleLootRoll(WorldPacket& recvData); + void HandleRequestPartyMemberStatsOpcode(WorldPacket& recvData); + void HandleRaidTargetUpdateOpcode(WorldPacket& recvData); + void HandleRaidReadyCheckOpcode(WorldPacket& recvData); + void HandleRaidReadyCheckFinishedOpcode(WorldPacket& recvData); + void HandleGroupRaidConvertOpcode(WorldPacket& recvData); + void HandleGroupChangeSubGroupOpcode(WorldPacket& recvData); + void HandleGroupAssistantLeaderOpcode(WorldPacket& recvData); + void HandlePartyAssignmentOpcode(WorldPacket& recvData); + + void HandlePetitionBuyOpcode(WorldPacket& recvData); + void HandlePetitionShowSignOpcode(WorldPacket& recvData); + void HandlePetitionQueryOpcode(WorldPacket& recvData); + void HandlePetitionRenameOpcode(WorldPacket& recvData); + void HandlePetitionSignOpcode(WorldPacket& recvData); + void HandlePetitionDeclineOpcode(WorldPacket& recvData); + void HandleOfferPetitionOpcode(WorldPacket& recvData); + void HandleTurnInPetitionOpcode(WorldPacket& recvData); void HandleGuildQueryOpcode(WorldPacket& recvPacket); void HandleGuildCreateOpcode(WorldPacket& recvPacket); @@ -627,25 +629,25 @@ class WorldSession void HandleUnacceptTradeOpcode(WorldPacket& recvPacket); void HandleAuctionHelloOpcode(WorldPacket& recvPacket); - void HandleAuctionListItems(WorldPacket& recv_data); - void HandleAuctionListBidderItems(WorldPacket& recv_data); - void HandleAuctionSellItem(WorldPacket& recv_data); - void HandleAuctionRemoveItem(WorldPacket& recv_data); - void HandleAuctionListOwnerItems(WorldPacket& recv_data); - void HandleAuctionPlaceBid(WorldPacket& recv_data); - void HandleAuctionListPendingSales(WorldPacket& recv_data); - - void HandleGetMailList(WorldPacket& recv_data); - void HandleSendMail(WorldPacket& recv_data); - void HandleMailTakeMoney(WorldPacket& recv_data); - void HandleMailTakeItem(WorldPacket& recv_data); - void HandleMailMarkAsRead(WorldPacket& recv_data); - void HandleMailReturnToSender(WorldPacket& recv_data); - void HandleMailDelete(WorldPacket& recv_data); - void HandleItemTextQuery(WorldPacket& recv_data); - void HandleMailCreateTextItem(WorldPacket& recv_data); - void HandleQueryNextMailTime(WorldPacket& recv_data); - void HandleCancelChanneling(WorldPacket& recv_data); + void HandleAuctionListItems(WorldPacket& recvData); + void HandleAuctionListBidderItems(WorldPacket& recvData); + void HandleAuctionSellItem(WorldPacket& recvData); + void HandleAuctionRemoveItem(WorldPacket& recvData); + void HandleAuctionListOwnerItems(WorldPacket& recvData); + void HandleAuctionPlaceBid(WorldPacket& recvData); + void HandleAuctionListPendingSales(WorldPacket& recvData); + + void HandleGetMailList(WorldPacket& recvData); + void HandleSendMail(WorldPacket& recvData); + void HandleMailTakeMoney(WorldPacket& recvData); + void HandleMailTakeItem(WorldPacket& recvData); + void HandleMailMarkAsRead(WorldPacket& recvData); + void HandleMailReturnToSender(WorldPacket& recvData); + void HandleMailDelete(WorldPacket& recvData); + void HandleItemTextQuery(WorldPacket& recvData); + void HandleMailCreateTextItem(WorldPacket& recvData); + void HandleQueryNextMailTime(WorldPacket& recvData); + void HandleCancelChanneling(WorldPacket& recvData); void SendItemPageInfo(ItemTemplate* itemProto); void HandleSplitItemOpcode(WorldPacket& recvPacket); @@ -691,19 +693,18 @@ class WorldSession void HandleQuestgiverChooseRewardOpcode(WorldPacket& recvPacket); void HandleQuestgiverRequestRewardOpcode(WorldPacket& recvPacket); void HandleQuestQueryOpcode(WorldPacket& recvPacket); - void HandleQuestgiverCancel(WorldPacket& recv_data); - void HandleQuestLogSwapQuest(WorldPacket& recv_data); - void HandleQuestLogRemoveQuest(WorldPacket& recv_data); - void HandleQuestConfirmAccept(WorldPacket& recv_data); - void HandleQuestgiverCompleteQuest(WorldPacket& recv_data); + void HandleQuestgiverCancel(WorldPacket& recvData); + void HandleQuestLogSwapQuest(WorldPacket& recvData); + void HandleQuestLogRemoveQuest(WorldPacket& recvData); + void HandleQuestConfirmAccept(WorldPacket& recvData); + void HandleQuestgiverCompleteQuest(WorldPacket& recvData); void HandleQuestgiverQuestAutoLaunch(WorldPacket& recvPacket); void HandlePushQuestToParty(WorldPacket& recvPacket); void HandleQuestPushResult(WorldPacket& recvPacket); - bool processChatmessageFurtherAfterSecurityChecks(std::string&, uint32); void HandleMessagechatOpcode(WorldPacket& recvPacket); - void SendPlayerNotFoundNotice(std::string name); - void SendPlayerAmbiguousNotice(std::string name); + void SendPlayerNotFoundNotice(std::string const& name); + void SendPlayerAmbiguousNotice(std::string const& name); void SendWrongFactionNotice(); void SendChatRestrictedNotice(ChatRestrictionType restriction); void HandleTextEmoteOpcode(WorldPacket& recvPacket); @@ -713,7 +714,7 @@ class WorldSession void HandleCorpseQueryOpcode(WorldPacket& recvPacket); void HandleCorpseMapPositionQuery(WorldPacket& recvPacket); void HandleResurrectResponseOpcode(WorldPacket& recvPacket); - void HandleSummonResponseOpcode(WorldPacket& recv_data); + void HandleSummonResponseOpcode(WorldPacket& recvData); void HandleJoinChannel(WorldPacket& recvPacket); void HandleLeaveChannel(WorldPacket& recvPacket); @@ -742,58 +743,58 @@ class WorldSession void HandlePageQuerySkippedOpcode(WorldPacket& recvPacket); void HandlePageTextQueryOpcode(WorldPacket& recvPacket); - void HandleTutorialFlag (WorldPacket& recv_data); - void HandleTutorialClear(WorldPacket& recv_data); - void HandleTutorialReset(WorldPacket& recv_data); + void HandleTutorialFlag (WorldPacket& recvData); + void HandleTutorialClear(WorldPacket& recvData); + void HandleTutorialReset(WorldPacket& recvData); //Pet - void HandlePetAction(WorldPacket& recv_data); - void HandlePetStopAttack(WorldPacket& recv_data); + void HandlePetAction(WorldPacket& recvData); + void HandlePetStopAttack(WorldPacket& recvData); void HandlePetActionHelper(Unit* pet, uint64 guid1, uint16 spellid, uint16 flag, uint64 guid2); - void HandlePetNameQuery(WorldPacket& recv_data); - void HandlePetSetAction(WorldPacket& recv_data); - void HandlePetAbandon(WorldPacket& recv_data); - void HandlePetRename(WorldPacket& recv_data); + void HandlePetNameQuery(WorldPacket& recvData); + void HandlePetSetAction(WorldPacket& recvData); + void HandlePetAbandon(WorldPacket& recvData); + void HandlePetRename(WorldPacket& recvData); void HandlePetCancelAuraOpcode(WorldPacket& recvPacket); void HandlePetSpellAutocastOpcode(WorldPacket& recvPacket); void HandlePetCastSpellOpcode(WorldPacket& recvPacket); void HandlePetLearnTalent(WorldPacket& recvPacket); void HandleLearnPreviewTalentsPet(WorldPacket& recvPacket); - void HandleSetActionBarToggles(WorldPacket& recv_data); + void HandleSetActionBarToggles(WorldPacket& recvData); - void HandleCharRenameOpcode(WorldPacket& recv_data); - void HandleChangePlayerNameOpcodeCallBack(PreparedQueryResult result, std::string newName); - void HandleSetPlayerDeclinedNames(WorldPacket& recv_data); + void HandleCharRenameOpcode(WorldPacket& recvData); + void HandleChangePlayerNameOpcodeCallBack(PreparedQueryResult result, std::string const& newName); + void HandleSetPlayerDeclinedNames(WorldPacket& recvData); - void HandleTotemDestroyed(WorldPacket& recv_data); - void HandleDismissCritter(WorldPacket& recv_data); + void HandleTotemDestroyed(WorldPacket& recvData); + void HandleDismissCritter(WorldPacket& recvData); //Battleground - void HandleBattlemasterHelloOpcode(WorldPacket& recv_data); - void HandleBattlemasterJoinOpcode(WorldPacket& recv_data); - void HandleBattlegroundPlayerPositionsOpcode(WorldPacket& recv_data); - void HandlePVPLogDataOpcode(WorldPacket& recv_data); - void HandleBattleFieldPortOpcode(WorldPacket& recv_data); - void HandleBattlefieldListOpcode(WorldPacket& recv_data); - void HandleLeaveBattlefieldOpcode(WorldPacket& recv_data); - void HandleBattlemasterJoinArena(WorldPacket& recv_data); - void HandleReportPvPAFK(WorldPacket& recv_data); - - void HandleWardenDataOpcode(WorldPacket& recv_data); - void HandleWorldTeleportOpcode(WorldPacket& recv_data); - void HandleMinimapPingOpcode(WorldPacket& recv_data); - void HandleRandomRollOpcode(WorldPacket& recv_data); - void HandleFarSightOpcode(WorldPacket& recv_data); - void HandleSetDungeonDifficultyOpcode(WorldPacket& recv_data); - void HandleSetRaidDifficultyOpcode(WorldPacket& recv_data); - void HandleMoveSetCanFlyAckOpcode(WorldPacket& recv_data); - void HandleSetTitleOpcode(WorldPacket& recv_data); - void HandleRealmSplitOpcode(WorldPacket& recv_data); - void HandleTimeSyncResp(WorldPacket& recv_data); - void HandleWhoisOpcode(WorldPacket& recv_data); - void HandleResetInstancesOpcode(WorldPacket& recv_data); - void HandleHearthAndResurrect(WorldPacket& recv_data); + void HandleBattlemasterHelloOpcode(WorldPacket& recvData); + void HandleBattlemasterJoinOpcode(WorldPacket& recvData); + void HandleBattlegroundPlayerPositionsOpcode(WorldPacket& recvData); + void HandlePVPLogDataOpcode(WorldPacket& recvData); + void HandleBattleFieldPortOpcode(WorldPacket& recvData); + void HandleBattlefieldListOpcode(WorldPacket& recvData); + void HandleLeaveBattlefieldOpcode(WorldPacket& recvData); + void HandleBattlemasterJoinArena(WorldPacket& recvData); + void HandleReportPvPAFK(WorldPacket& recvData); + + void HandleWardenDataOpcode(WorldPacket& recvData); + void HandleWorldTeleportOpcode(WorldPacket& recvData); + void HandleMinimapPingOpcode(WorldPacket& recvData); + void HandleRandomRollOpcode(WorldPacket& recvData); + void HandleFarSightOpcode(WorldPacket& recvData); + void HandleSetDungeonDifficultyOpcode(WorldPacket& recvData); + void HandleSetRaidDifficultyOpcode(WorldPacket& recvData); + void HandleMoveSetCanFlyAckOpcode(WorldPacket& recvData); + void HandleSetTitleOpcode(WorldPacket& recvData); + void HandleRealmSplitOpcode(WorldPacket& recvData); + void HandleTimeSyncResp(WorldPacket& recvData); + void HandleWhoisOpcode(WorldPacket& recvData); + void HandleResetInstancesOpcode(WorldPacket& recvData); + void HandleHearthAndResurrect(WorldPacket& recvData); void HandleInstanceLockResponse(WorldPacket& recvPacket); // Battlefield @@ -802,22 +803,23 @@ class WorldSession void SendBfQueueInviteResponse(uint32 BattleId,uint32 ZoneId, bool CanQueue = true, bool Full = false); void SendBfEntered(uint32 BattleId); void SendBfLeaveMessage(uint32 BattleId, BFLeaveReason reason = BF_LEAVE_REASON_EXITED); - void HandleBfQueueInviteResponse(WorldPacket &recv_data); - void HandleBfEntryInviteResponse(WorldPacket &recv_data); - void HandleBfExitRequest(WorldPacket &recv_data); + void HandleBfQueueInviteResponse(WorldPacket &recvData); + void HandleBfEntryInviteResponse(WorldPacket &recvData); + void HandleBfExitRequest(WorldPacket &recvData); // Looking for Dungeon/Raid - void HandleLfgSetCommentOpcode(WorldPacket& recv_data); - void HandleLfgPlayerLockInfoRequestOpcode(WorldPacket& recv_data); - void HandleLfgPartyLockInfoRequestOpcode(WorldPacket& recv_data); - void HandleLfgJoinOpcode(WorldPacket& recv_data); - void HandleLfgLeaveOpcode(WorldPacket& recv_data); - void HandleLfgSetRolesOpcode(WorldPacket& recv_data); - void HandleLfgProposalResultOpcode(WorldPacket& recv_data); - void HandleLfgSetBootVoteOpcode(WorldPacket& recv_data); - void HandleLfgTeleportOpcode(WorldPacket& recv_data); - void HandleLfrJoinOpcode(WorldPacket& recv_data); - void HandleLfrLeaveOpcode(WorldPacket& recv_data); + void HandleLfgSetCommentOpcode(WorldPacket& recvData); + void HandleLfgPlayerLockInfoRequestOpcode(WorldPacket& recvData); + void HandleLfgPartyLockInfoRequestOpcode(WorldPacket& recvData); + void HandleLfgJoinOpcode(WorldPacket& recvData); + void HandleLfgLeaveOpcode(WorldPacket& recvData); + void HandleLfgSetRolesOpcode(WorldPacket& recvData); + void HandleLfgProposalResultOpcode(WorldPacket& recvData); + void HandleLfgSetBootVoteOpcode(WorldPacket& recvData); + void HandleLfgTeleportOpcode(WorldPacket& recvData); + void HandleLfrJoinOpcode(WorldPacket& recvData); + void HandleLfrLeaveOpcode(WorldPacket& recvData); + void HandleLfgGetStatus(WorldPacket& recvData); void SendLfgUpdatePlayer(const LfgUpdateData& updateData); void SendLfgUpdateParty(const LfgUpdateData& updateData); @@ -834,55 +836,55 @@ class WorldSession void SendLfgTeleportError(uint8 err); // Arena Team - void HandleInspectArenaTeamsOpcode(WorldPacket& recv_data); - void HandleArenaTeamQueryOpcode(WorldPacket& recv_data); - void HandleArenaTeamRosterOpcode(WorldPacket& recv_data); - void HandleArenaTeamInviteOpcode(WorldPacket& recv_data); - void HandleArenaTeamAcceptOpcode(WorldPacket& recv_data); - void HandleArenaTeamDeclineOpcode(WorldPacket& recv_data); - void HandleArenaTeamLeaveOpcode(WorldPacket& recv_data); - void HandleArenaTeamRemoveOpcode(WorldPacket& recv_data); - void HandleArenaTeamDisbandOpcode(WorldPacket& recv_data); - void HandleArenaTeamLeaderOpcode(WorldPacket& recv_data); - - void HandleAreaSpiritHealerQueryOpcode(WorldPacket& recv_data); - void HandleAreaSpiritHealerQueueOpcode(WorldPacket& recv_data); - void HandleCancelMountAuraOpcode(WorldPacket& recv_data); - void HandleSelfResOpcode(WorldPacket& recv_data); - void HandleComplainOpcode(WorldPacket& recv_data); - void HandleRequestPetInfoOpcode(WorldPacket& recv_data); + void HandleInspectArenaTeamsOpcode(WorldPacket& recvData); + void HandleArenaTeamQueryOpcode(WorldPacket& recvData); + void HandleArenaTeamRosterOpcode(WorldPacket& recvData); + void HandleArenaTeamInviteOpcode(WorldPacket& recvData); + void HandleArenaTeamAcceptOpcode(WorldPacket& recvData); + void HandleArenaTeamDeclineOpcode(WorldPacket& recvData); + void HandleArenaTeamLeaveOpcode(WorldPacket& recvData); + void HandleArenaTeamRemoveOpcode(WorldPacket& recvData); + void HandleArenaTeamDisbandOpcode(WorldPacket& recvData); + void HandleArenaTeamLeaderOpcode(WorldPacket& recvData); + + void HandleAreaSpiritHealerQueryOpcode(WorldPacket& recvData); + void HandleAreaSpiritHealerQueueOpcode(WorldPacket& recvData); + void HandleCancelMountAuraOpcode(WorldPacket& recvData); + void HandleSelfResOpcode(WorldPacket& recvData); + void HandleComplainOpcode(WorldPacket& recvData); + void HandleRequestPetInfoOpcode(WorldPacket& recvData); // Socket gem - void HandleSocketOpcode(WorldPacket& recv_data); + void HandleSocketOpcode(WorldPacket& recvData); - void HandleCancelTempEnchantmentOpcode(WorldPacket& recv_data); + void HandleCancelTempEnchantmentOpcode(WorldPacket& recvData); - void HandleItemRefundInfoRequest(WorldPacket& recv_data); - void HandleItemRefund(WorldPacket& recv_data); + void HandleItemRefundInfoRequest(WorldPacket& recvData); + void HandleItemRefund(WorldPacket& recvData); - void HandleChannelVoiceOnOpcode(WorldPacket& recv_data); - void HandleVoiceSessionEnableOpcode(WorldPacket& recv_data); - void HandleSetActiveVoiceChannel(WorldPacket& recv_data); - void HandleSetTaxiBenchmarkOpcode(WorldPacket& recv_data); + void HandleChannelVoiceOnOpcode(WorldPacket& recvData); + void HandleVoiceSessionEnableOpcode(WorldPacket& recvData); + void HandleSetActiveVoiceChannel(WorldPacket& recvData); + void HandleSetTaxiBenchmarkOpcode(WorldPacket& recvData); // Guild Bank - void HandleGuildPermissions(WorldPacket& recv_data); - void HandleGuildBankMoneyWithdrawn(WorldPacket& recv_data); - void HandleGuildBankerActivate(WorldPacket& recv_data); - void HandleGuildBankQueryTab(WorldPacket& recv_data); - void HandleGuildBankLogQuery(WorldPacket& recv_data); - void HandleGuildBankDepositMoney(WorldPacket& recv_data); - void HandleGuildBankWithdrawMoney(WorldPacket& recv_data); - void HandleGuildBankSwapItems(WorldPacket& recv_data); - - void HandleGuildBankUpdateTab(WorldPacket& recv_data); - void HandleGuildBankBuyTab(WorldPacket& recv_data); - void HandleQueryGuildBankTabText(WorldPacket& recv_data); - void HandleSetGuildBankTabText(WorldPacket& recv_data); + void HandleGuildPermissions(WorldPacket& recvData); + void HandleGuildBankMoneyWithdrawn(WorldPacket& recvData); + void HandleGuildBankerActivate(WorldPacket& recvData); + void HandleGuildBankQueryTab(WorldPacket& recvData); + void HandleGuildBankLogQuery(WorldPacket& recvData); + void HandleGuildBankDepositMoney(WorldPacket& recvData); + void HandleGuildBankWithdrawMoney(WorldPacket& recvData); + void HandleGuildBankSwapItems(WorldPacket& recvData); + + void HandleGuildBankUpdateTab(WorldPacket& recvData); + void HandleGuildBankBuyTab(WorldPacket& recvData); + void HandleQueryGuildBankTabText(WorldPacket& recvData); + void HandleSetGuildBankTabText(WorldPacket& recvData); // Refer-a-Friend - void HandleGrantLevel(WorldPacket& recv_data); - void HandleAcceptGrantLevel(WorldPacket& recv_data); + void HandleGrantLevel(WorldPacket& recvData); + void HandleAcceptGrantLevel(WorldPacket& recvData); // Calendar void HandleCalendarGetCalendar(WorldPacket& recvData); @@ -916,19 +918,19 @@ class WorldSession void SendCalendarRaidLockoutUpdated(InstanceSave const* save); void SendCalendarCommandResult(CalendarError err, char const* param = NULL); - void HandleSpellClick(WorldPacket& recv_data); - void HandleMirrorImageDataRequest(WorldPacket& recv_data); - void HandleAlterAppearance(WorldPacket& recv_data); - void HandleRemoveGlyph(WorldPacket& recv_data); - void HandleCharCustomize(WorldPacket& recv_data); - void HandleQueryInspectAchievements(WorldPacket& recv_data); - void HandleEquipmentSetSave(WorldPacket& recv_data); - void HandleEquipmentSetDelete(WorldPacket& recv_data); - void HandleEquipmentSetUse(WorldPacket& recv_data); - void HandleWorldStateUITimerUpdate(WorldPacket& recv_data); - void HandleReadyForAccountDataTimes(WorldPacket& recv_data); - void HandleQueryQuestsCompleted(WorldPacket& recv_data); - void HandleQuestPOIQuery(WorldPacket& recv_data); + void HandleSpellClick(WorldPacket& recvData); + void HandleMirrorImageDataRequest(WorldPacket& recvData); + void HandleAlterAppearance(WorldPacket& recvData); + void HandleRemoveGlyph(WorldPacket& recvData); + void HandleCharCustomize(WorldPacket& recvData); + void HandleQueryInspectAchievements(WorldPacket& recvData); + void HandleEquipmentSetSave(WorldPacket& recvData); + void HandleEquipmentSetDelete(WorldPacket& recvData); + void HandleEquipmentSetUse(WorldPacket& recvData); + void HandleWorldStateUITimerUpdate(WorldPacket& recvData); + void HandleReadyForAccountDataTimes(WorldPacket& recvData); + void HandleQueryQuestsCompleted(WorldPacket& recvData); + void HandleQuestPOIQuery(WorldPacket& recvData); void HandleEjectPassenger(WorldPacket& data); void HandleEnterPlayerVehicle(WorldPacket& data); void HandleUpdateProjectilePosition(WorldPacket& recvPacket); diff --git a/src/server/game/Server/WorldSocket.cpp b/src/server/game/Server/WorldSocket.cpp index 92455f8edfe..ee54c8d662c 100755 --- a/src/server/game/Server/WorldSocket.cpp +++ b/src/server/game/Server/WorldSocket.cpp @@ -483,7 +483,7 @@ int WorldSocket::handle_input_header (void) sLog->outError(LOG_FILTER_NETWORKIO, "WorldSocket::handle_input_header(): client (account: %u, char [GUID: %u, name: %s]) sent malformed packet (size: %d, cmd: %d)", m_Session ? m_Session->GetAccountId() : 0, _player ? _player->GetGUIDLow() : 0, - _player ? _player->GetName() : "<none>", + _player ? _player->GetName().c_str() : "<none>", header.size, header.cmd); errno = EINVAL; @@ -683,7 +683,7 @@ int WorldSocket::ProcessIncoming(WorldPacket* new_pct) case CMSG_AUTH_SESSION: if (m_Session) { - sLog->outError(LOG_FILTER_NETWORKIO, "WorldSocket::ProcessIncoming: received duplicate CMSG_AUTH_SESSION from %s", m_Session->GetPlayerName(false).c_str()); + sLog->outError(LOG_FILTER_NETWORKIO, "WorldSocket::ProcessIncoming: received duplicate CMSG_AUTH_SESSION from %s", m_Session->GetPlayerInfo().c_str()); return -1; } @@ -1006,7 +1006,7 @@ int WorldSocket::HandlePing (WorldPacket& recvPacket) if (m_Session && AccountMgr::IsPlayerAccount(m_Session->GetSecurity())) { sLog->outError(LOG_FILTER_NETWORKIO, "WorldSocket::HandlePing: %s kicked for over-speed pings (address: %s)", - m_Session->GetPlayerName(false).c_str(), GetRemoteAddress().c_str()); + m_Session->GetPlayerInfo().c_str(), GetRemoteAddress().c_str()); return -1; } diff --git a/src/server/game/Spells/Auras/SpellAuras.cpp b/src/server/game/Spells/Auras/SpellAuras.cpp index 9c08ebae5ac..d0d9d417c3e 100755 --- a/src/server/game/Spells/Auras/SpellAuras.cpp +++ b/src/server/game/Spells/Auras/SpellAuras.cpp @@ -567,8 +567,8 @@ void Aura::UpdateTargetMap(Unit* caster, bool apply) { //TODO: There is a crash caused by shadowfiend load addon sLog->outFatal(LOG_FILTER_SPELLS_AURAS, "Aura %u: Owner %s (map %u) is not in the same map as target %s (map %u).", GetSpellInfo()->Id, - GetOwner()->GetName(), GetOwner()->IsInWorld() ? GetOwner()->GetMap()->GetId() : uint32(-1), - itr->first->GetName(), itr->first->IsInWorld() ? itr->first->GetMap()->GetId() : uint32(-1)); + GetOwner()->GetName().c_str(), GetOwner()->IsInWorld() ? GetOwner()->GetMap()->GetId() : uint32(-1), + itr->first->GetName().c_str(), itr->first->IsInWorld() ? itr->first->GetMap()->GetId() : uint32(-1)); ASSERT(false); } itr->first->_CreateAuraApplication(this, itr->second); diff --git a/src/server/game/Spells/Spell.cpp b/src/server/game/Spells/Spell.cpp index 45c4338f03d..77adece17b4 100755 --- a/src/server/game/Spells/Spell.cpp +++ b/src/server/game/Spells/Spell.cpp @@ -4300,13 +4300,15 @@ void Spell::SendResurrectRequest(Player* target) { // get ressurector name for creature resurrections, otherwise packet will be not accepted // for player resurrections the name is looked up by guid - char const* resurrectorName = m_caster->GetTypeId() == TYPEID_PLAYER ? "" : m_caster->GetNameForLocaleIdx(target->GetSession()->GetSessionDbLocaleIndex()); + std::string const sentName(m_caster->GetTypeId() == TYPEID_PLAYER + ? "" + : m_caster->GetNameForLocaleIdx(target->GetSession()->GetSessionDbLocaleIndex())); - WorldPacket data(SMSG_RESURRECT_REQUEST, (8+4+strlen(resurrectorName)+1+1+1+4)); - data << uint64(m_caster->GetGUID()); // resurrector guid - data << uint32(strlen(resurrectorName) + 1); + WorldPacket data(SMSG_RESURRECT_REQUEST, (8+4+sentName.size()+1+1+1+4)); + data << uint64(m_caster->GetGUID()); + data << uint32(sentName.size() + 1); - data << resurrectorName; + data << sentName; data << uint8(0); // null terminator data << uint8(m_caster->GetTypeId() == TYPEID_PLAYER ? 0 : 1); // "you'll be afflicted with resurrection sickness" @@ -5865,7 +5867,7 @@ SpellCastResult Spell::CheckItems() else { uint32 itemid = m_CastItem->GetEntry(); - if (!p_caster->HasItemCount(itemid, 1)) + if (!p_caster->HasItemCount(itemid)) return SPELL_FAILED_ITEM_NOT_READY; ItemTemplate const* proto = m_CastItem->GetTemplate(); @@ -6017,7 +6019,7 @@ SpellCastResult Spell::CheckItems() { if (m_spellInfo->Totem[i] != 0) { - if (p_caster->HasItemCount(m_spellInfo->Totem[i], 1)) + if (p_caster->HasItemCount(m_spellInfo->Totem[i])) { totems -= 1; continue; @@ -6072,7 +6074,7 @@ SpellCastResult Spell::CheckItems() { if (!(m_spellInfo->SpellFamilyName == SPELLFAMILY_MAGE && (m_spellInfo->SpellFamilyFlags[0] & 0x40000000))) return SPELL_FAILED_TOO_MANY_OF_ITEM; - else if (!(p_caster->HasItemCount(m_spellInfo->Effects[i].ItemType, 1))) + else if (!(p_caster->HasItemCount(m_spellInfo->Effects[i].ItemType))) return SPELL_FAILED_TOO_MANY_OF_ITEM; else p_caster->CastSpell(m_caster, m_spellInfo->Effects[EFFECT_1].CalcValue(), false); // move this to anywhere @@ -6251,7 +6253,7 @@ SpellCastResult Spell::CheckItems() case ITEM_SUBCLASS_WEAPON_THROWN: { uint32 ammo = pItem->GetEntry(); - if (!m_caster->ToPlayer()->HasItemCount(ammo, 1)) + if (!m_caster->ToPlayer()->HasItemCount(ammo)) return SPELL_FAILED_NO_AMMO; }; break; @@ -6292,7 +6294,7 @@ SpellCastResult Spell::CheckItems() return SPELL_FAILED_NO_AMMO; } - if (!m_caster->ToPlayer()->HasItemCount(ammo, 1)) + if (!m_caster->ToPlayer()->HasItemCount(ammo)) { m_caster->ToPlayer()->SetUInt32Value(PLAYER_AMMO_ID, 0); return SPELL_FAILED_NO_AMMO; diff --git a/src/server/game/Spells/SpellEffects.cpp b/src/server/game/Spells/SpellEffects.cpp index a88ffffd5ea..cdb9490c10d 100755 --- a/src/server/game/Spells/SpellEffects.cpp +++ b/src/server/game/Spells/SpellEffects.cpp @@ -1779,7 +1779,7 @@ void Spell::EffectCreateItem2(SpellEffIndex effIndex) { if (item_id) { - if (!player->HasItemCount(item_id, 1)) + if (!player->HasItemCount(item_id)) return; // remove reagent @@ -1989,7 +1989,7 @@ void Spell::SendLoot(uint64 guid, LootType loottype) if (!gameObjTarget->isSpawned() && !player->isGameMaster()) { sLog->outError(LOG_FILTER_SPELLS_AURAS, "Possible hacking attempt: Player %s [guid: %u] tried to loot a gameobject [entry: %u id: %u] which is on respawn time without being in GM mode!", - player->GetName(), player->GetGUIDLow(), gameObjTarget->GetEntry(), gameObjTarget->GetGUIDLow()); + player->GetName().c_str(), player->GetGUIDLow(), gameObjTarget->GetEntry(), gameObjTarget->GetGUIDLow()); return; } // special case, already has GossipHello inside so return and avoid calling twice @@ -2400,7 +2400,7 @@ void Spell::EffectSummonType(SpellEffIndex effIndex) // randomize position for multiple summons m_caster->GetRandomPoint(*destTarget, radius, pos); - summon = m_originalCaster->SummonCreature(entry, *destTarget, summonType, duration); + summon = m_originalCaster->SummonCreature(entry, pos, summonType, duration); if (!summon) continue; @@ -2799,9 +2799,9 @@ void Spell::EffectEnchantItemPerm(SpellEffIndex effIndex) if (item_owner != p_caster && !AccountMgr::IsPlayerAccount(p_caster->GetSession()->GetSecurity()) && sWorld->getBoolConfig(CONFIG_GM_LOG_TRADE)) { sLog->outCommand(p_caster->GetSession()->GetAccountId(), "GM %s (Account: %u) enchanting(perm): %s (Entry: %d) for player: %s (Account: %u)", - p_caster->GetName(), p_caster->GetSession()->GetAccountId(), + p_caster->GetName().c_str(), p_caster->GetSession()->GetAccountId(), itemTarget->GetTemplate()->Name1.c_str(), itemTarget->GetEntry(), - item_owner->GetName(), item_owner->GetSession()->GetAccountId()); + item_owner->GetName().c_str(), item_owner->GetSession()->GetAccountId()); } // remove old enchanting before applying new if equipped @@ -2864,9 +2864,9 @@ void Spell::EffectEnchantItemPrismatic(SpellEffIndex effIndex) if (item_owner != p_caster && !AccountMgr::IsPlayerAccount(p_caster->GetSession()->GetSecurity()) && sWorld->getBoolConfig(CONFIG_GM_LOG_TRADE)) { sLog->outCommand(p_caster->GetSession()->GetAccountId(), "GM %s (Account: %u) enchanting(perm): %s (Entry: %d) for player: %s (Account: %u)", - p_caster->GetName(), p_caster->GetSession()->GetAccountId(), + p_caster->GetName().c_str(), p_caster->GetSession()->GetAccountId(), itemTarget->GetTemplate()->Name1.c_str(), itemTarget->GetEntry(), - item_owner->GetName(), item_owner->GetSession()->GetAccountId()); + item_owner->GetName().c_str(), item_owner->GetSession()->GetAccountId()); } // remove old enchanting before applying new if equipped @@ -2998,9 +2998,9 @@ void Spell::EffectEnchantItemTmp(SpellEffIndex effIndex) if (item_owner != p_caster && !AccountMgr::IsPlayerAccount(p_caster->GetSession()->GetSecurity()) && sWorld->getBoolConfig(CONFIG_GM_LOG_TRADE)) { sLog->outCommand(p_caster->GetSession()->GetAccountId(), "GM %s (Account: %u) enchanting(temp): %s (Entry: %d) for player: %s (Account: %u)", - p_caster->GetName(), p_caster->GetSession()->GetAccountId(), + p_caster->GetName().c_str(), p_caster->GetSession()->GetAccountId(), itemTarget->GetTemplate()->Name1.c_str(), itemTarget->GetEntry(), - item_owner->GetName(), item_owner->GetSession()->GetAccountId()); + item_owner->GetName().c_str(), item_owner->GetSession()->GetAccountId()); } // remove old enchanting before applying new if equipped @@ -3929,7 +3929,7 @@ void Spell::EffectScriptEffect(SpellEffIndex effIndex) const char *gender = "his"; if (m_caster->getGender() > 0) gender = "her"; - sprintf(buf, "%s rubs %s [Decahedral Dwarven Dice] between %s hands and rolls. One %u and one %u.", m_caster->GetName(), gender, gender, urand(1, 10), urand(1, 10)); + sprintf(buf, "%s rubs %s [Decahedral Dwarven Dice] between %s hands and rolls. One %u and one %u.", m_caster->GetName().c_str(), gender, gender, urand(1, 10), urand(1, 10)); m_caster->MonsterTextEmote(buf, 0); break; } @@ -3940,7 +3940,7 @@ void Spell::EffectScriptEffect(SpellEffIndex effIndex) const char *gender = "his"; if (m_caster->getGender() > 0) gender = "her"; - sprintf(buf, "%s causually tosses %s [Worn Troll Dice]. One %u and one %u.", m_caster->GetName(), gender, urand(1, 6), urand(1, 6)); + sprintf(buf, "%s causually tosses %s [Worn Troll Dice]. One %u and one %u.", m_caster->GetName().c_str(), gender, urand(1, 6), urand(1, 6)); m_caster->MonsterTextEmote(buf, 0); break; } @@ -4550,7 +4550,7 @@ void Spell::EffectStuck(SpellEffIndex /*effIndex*/) Player* target = (Player*)m_caster; sLog->outDebug(LOG_FILTER_SPELLS_AURAS, "Spell Effect: Stuck"); - sLog->outInfo(LOG_FILTER_SPELLS_AURAS, "Player %s (guid %u) used auto-unstuck future at map %u (%f, %f, %f)", target->GetName(), target->GetGUIDLow(), m_caster->GetMapId(), m_caster->GetPositionX(), target->GetPositionY(), target->GetPositionZ()); + sLog->outInfo(LOG_FILTER_SPELLS_AURAS, "Player %s (guid %u) used auto-unstuck future at map %u (%f, %f, %f)", target->GetName().c_str(), target->GetGUIDLow(), m_caster->GetMapId(), m_caster->GetPositionX(), target->GetPositionY(), target->GetPositionZ()); if (target->isInFlight()) return; diff --git a/src/server/game/Spells/SpellInfo.cpp b/src/server/game/Spells/SpellInfo.cpp index 37f6a4b8640..27b4f22bbcf 100644 --- a/src/server/game/Spells/SpellInfo.cpp +++ b/src/server/game/Spells/SpellInfo.cpp @@ -2338,7 +2338,7 @@ bool SpellInfo::_IsPositiveEffect(uint8 effIndex, bool deep) const continue; // 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->Effects[i].TargetA.GetTarget(), spellTriggeredProto->Effects[effIndex].TargetB.GetTarget()) && !spellTriggeredProto->_IsPositiveEffect(i, true)) + if (_IsPositiveTarget(spellTriggeredProto->Effects[i].TargetA.GetTarget(), spellTriggeredProto->Effects[i].TargetB.GetTarget()) && !spellTriggeredProto->_IsPositiveEffect(i, true)) return false; } } diff --git a/src/server/game/Spells/SpellMgr.cpp b/src/server/game/Spells/SpellMgr.cpp index 06f1187a833..4ffbab6cb63 100755 --- a/src/server/game/Spells/SpellMgr.cpp +++ b/src/server/game/Spells/SpellMgr.cpp @@ -3593,6 +3593,10 @@ void SpellMgr::LoadDbcDataCorrections() spellInfo->AttributesEx6 |= SPELL_ATTR6_CAN_TARGET_INVISIBLE; spellInfo->AttributesEx2 |= SPELL_ATTR2_CAN_TARGET_NOT_IN_LOS; break; + case 75888: // Awaken Flames + case 75889: // Awaken Flames + spellInfo->AttributesEx |= SPELL_ATTR1_CANT_TARGET_SELF; + break; // ENDOF RUBY SANCTUM SPELLS // case 40055: // Introspection diff --git a/src/server/game/Spells/SpellScript.h b/src/server/game/Spells/SpellScript.h index b1a2097a8f9..26dda4d2327 100755 --- a/src/server/game/Spells/SpellScript.h +++ b/src/server/game/Spells/SpellScript.h @@ -72,6 +72,8 @@ class _SpellScript { public: EffectHook(uint8 _effIndex); + virtual ~EffectHook() { } + uint8 GetAffectedEffectsMask(SpellInfo const* spellEntry); bool IsEffectAffected(SpellInfo const* spellEntry, uint8 effIndex); virtual bool CheckEffect(SpellInfo const* spellEntry, uint8 effIndex) = 0; @@ -83,7 +85,7 @@ class _SpellScript class EffectNameCheck { public: - EffectNameCheck(uint16 _effName) {effName = _effName;}; + EffectNameCheck(uint16 _effName) { effName = _effName; } bool Check(SpellInfo const* spellEntry, uint8 effIndex); std::string ToString(); private: @@ -118,7 +120,7 @@ class _SpellScript virtual bool Load() { return true; } // Function called when script is destroyed // use for: deallocating memory allocated by script - virtual void Unload() {} + virtual void Unload() { } }; // SpellScript interface - enum used for runtime checks of script function calls diff --git a/src/server/game/Texts/CreatureTextMgr.cpp b/src/server/game/Texts/CreatureTextMgr.cpp index 7818527b34b..5c2639175d2 100755 --- a/src/server/game/Texts/CreatureTextMgr.cpp +++ b/src/server/game/Texts/CreatureTextMgr.cpp @@ -34,14 +34,14 @@ class CreatureTextBuilder size_t operator()(WorldPacket* data, LocaleConstant locale) const { - std::string text = sCreatureTextMgr->GetLocalizedChatString(_source->GetEntry(), _textGroup, _textId, locale); - char const* localizedName = _source->GetNameForLocaleIdx(locale); + std::string const& text = sCreatureTextMgr->GetLocalizedChatString(_source->GetEntry(), _textGroup, _textId, locale); + std::string const& localizedName = _source->GetNameForLocaleIdx(locale); *data << uint8(_msgType); *data << uint32(_language); *data << uint64(_source->GetGUID()); *data << uint32(1); // 2.1.0 - *data << uint32(strlen(localizedName)+1); + *data << uint32(localizedName.size() + 1); *data << localizedName; size_t whisperGUIDpos = data->wpos(); *data << uint64(_targetGUID); // Unit Target @@ -178,7 +178,7 @@ uint32 CreatureTextMgr::SendChat(Creature* source, uint8 textGroup, uint64 whisp CreatureTextMap::const_iterator sList = mTextMap.find(source->GetEntry()); if (sList == mTextMap.end()) { - sLog->outError(LOG_FILTER_SQL, "CreatureTextMgr: Could not find Text for Creature(%s) Entry %u in 'creature_text' table. Ignoring.", source->GetName(), source->GetEntry()); + sLog->outError(LOG_FILTER_SQL, "CreatureTextMgr: Could not find Text for Creature(%s) Entry %u in 'creature_text' table. Ignoring.", source->GetName().c_str(), source->GetEntry()); return 0; } @@ -186,7 +186,7 @@ uint32 CreatureTextMgr::SendChat(Creature* source, uint8 textGroup, uint64 whisp CreatureTextHolder::const_iterator itr = textHolder.find(textGroup); if (itr == textHolder.end()) { - sLog->outError(LOG_FILTER_SQL, "CreatureTextMgr: Could not find TextGroup %u for Creature(%s) GuidLow %u Entry %u. Ignoring.", uint32(textGroup), source->GetName(), source->GetGUIDLow(), source->GetEntry()); + sLog->outError(LOG_FILTER_SQL, "CreatureTextMgr: Could not find TextGroup %u for Creature(%s) GuidLow %u Entry %u. Ignoring.", uint32(textGroup), source->GetName().c_str(), source->GetGUIDLow(), source->GetEntry()); return 0; } @@ -383,7 +383,7 @@ void CreatureTextMgr::SetRepeatId(Creature* source, uint8 textGroup, uint8 id) if (std::find(repeats.begin(), repeats.end(), id) == repeats.end()) repeats.push_back(id); else - sLog->outError(LOG_FILTER_SQL, "CreatureTextMgr: TextGroup %u for Creature(%s) GuidLow %u Entry %u, id %u already added", uint32(textGroup), source->GetName(), source->GetGUIDLow(), source->GetEntry(), uint32(id)); + sLog->outError(LOG_FILTER_SQL, "CreatureTextMgr: TextGroup %u for Creature(%s) GuidLow %u Entry %u, id %u already added", uint32(textGroup), source->GetName().c_str(), source->GetGUIDLow(), source->GetEntry(), uint32(id)); } CreatureTextRepeatIds CreatureTextMgr::GetRepeatGroup(Creature* source, uint8 textGroup) diff --git a/src/server/game/Tickets/TicketMgr.h b/src/server/game/Tickets/TicketMgr.h index 63837e39452..7e6768b96b2 100755 --- a/src/server/game/Tickets/TicketMgr.h +++ b/src/server/game/Tickets/TicketMgr.h @@ -94,8 +94,8 @@ public: uint32 GetId() const { return _id; } Player* GetPlayer() const { return ObjectAccessor::FindPlayer(_playerGuid); } - std::string GetPlayerName() const { return _playerName; } - std::string GetMessage() const { return _message; } + std::string const& GetPlayerName() const { return _playerName; } + std::string const& GetMessage() const { return _message; } Player* GetAssignedPlayer() const { return ObjectAccessor::FindPlayer(_assignedTo); } uint64 GetAssignedToGUID() const { return _assignedTo; } std::string GetAssignedToName() const @@ -120,16 +120,16 @@ public: _escalatedStatus = TICKET_ASSIGNED; } void SetClosedBy(const int64& value) { _closedBy = value; } - void SetMessage(const std::string& message) + void SetMessage(std::string const& message) { _message = message; _lastModifiedTime = uint64(time(NULL)); } - void SetComment(const std::string& comment) { _comment = comment; } + void SetComment(std::string const& comment) { _comment = comment; } void SetViewed() { _viewed = true; } void SetUnassigned(); - void AppendResponse(const std::string& response) { _response += response; } + void AppendResponse(std::string const& response) { _response += response; } bool LoadFromDB(Field* fields); void SaveToDB(SQLTransaction& trans) const; @@ -143,7 +143,7 @@ public: std::string FormatMessageString(ChatHandler& handler, const char* szClosedName, const char* szAssignedToName, const char* szUnassignedName, const char* szDeletedName) const; void SetChatLog(std::list<uint32> time, std::string const& log); - std::string GetChatLog() const { return _chatLog; } + std::string const& GetChatLog() const { return _chatLog; } private: uint32 _id; diff --git a/src/server/game/Tools/PlayerDump.cpp b/src/server/game/Tools/PlayerDump.cpp index ef516a0ba4f..ec7d2e08001 100644 --- a/src/server/game/Tools/PlayerDump.cpp +++ b/src/server/game/Tools/PlayerDump.cpp @@ -117,7 +117,7 @@ std::string gettablename(std::string &str) return str.substr(s, e-s); } -bool changenth(std::string &str, int n, const char *with, bool insert = false, bool nonzero = false) +bool changenth(std::string &str, int n, char const* with, bool insert = false, bool nonzero = false) { std::string::size_type s, e; if (!findnth(str, n, s, e)) @@ -142,7 +142,7 @@ std::string getnth(std::string &str, int n) return str.substr(s, e-s); } -bool changetoknth(std::string &str, int n, const char *with, bool insert = false, bool nonzero = false) +bool changetoknth(std::string &str, int n, char const* with, bool insert = false, bool nonzero = false) { std::string::size_type s = 0, e = 0; if (!findtoknth(str, n, s, e)) @@ -198,7 +198,7 @@ std::string CreateDumpString(char const* tableName, QueryResult result) { if (!tableName || !result) return ""; std::ostringstream ss; - ss << "INSERT INTO "<< _TABLE_SIM_ << tableName << _TABLE_SIM_ << " VALUES ("; + ss << "INSERT INTO " << _TABLE_SIM_ << tableName << _TABLE_SIM_ << " VALUES ("; Field* fields = result->Fetch(); for (uint32 i = 0; i < result->GetFieldCount(); ++i) { @@ -395,7 +395,7 @@ void fixNULLfields(std::string &line) } } -DumpReturn PlayerDumpReader::LoadDump(const std::string& file, uint32 account, std::string name, uint32 guid) +DumpReturn PlayerDumpReader::LoadDump(std::string const& file, uint32 account, std::string name, uint32 guid) { uint32 charcount = AccountMgr::GetCharactersCount(account); if (charcount >= 10) diff --git a/src/server/game/Tools/PlayerDump.h b/src/server/game/Tools/PlayerDump.h index 6662d91fb31..321649fc485 100755 --- a/src/server/game/Tools/PlayerDump.h +++ b/src/server/game/Tools/PlayerDump.h @@ -73,7 +73,7 @@ class PlayerDumpWriter : public PlayerDump PlayerDumpWriter() {} bool GetDump(uint32 guid, std::string& dump); - DumpReturn WriteDump(const std::string& file, uint32 guid); + DumpReturn WriteDump(std::string const& file, uint32 guid); private: typedef std::set<uint32> GUIDs; @@ -91,8 +91,7 @@ class PlayerDumpReader : public PlayerDump public: PlayerDumpReader() {} - DumpReturn LoadDump(const std::string& file, uint32 account, std::string name, uint32 guid); + DumpReturn LoadDump(std::string const& file, uint32 account, std::string name, uint32 guid); }; #endif - diff --git a/src/server/game/Warden/Warden.cpp b/src/server/game/Warden/Warden.cpp index d651fbd4ce1..ce64dbd1a94 100644 --- a/src/server/game/Warden/Warden.cpp +++ b/src/server/game/Warden/Warden.cpp @@ -106,7 +106,7 @@ void Warden::Update() if (_clientResponseTimer > maxClientResponseDelay * IN_MILLISECONDS) { sLog->outWarn(LOG_FILTER_WARDEN, "%s (latency: %u, IP: %s) exceeded Warden module response delay for more than %s - disconnecting client", - _session->GetPlayerName(false).c_str(), _session->GetLatency(), _session->GetRemoteAddress().c_str(), secsToTimeString(maxClientResponseDelay, true).c_str()); + _session->GetPlayerInfo().c_str(), _session->GetLatency(), _session->GetRemoteAddress().c_str(), secsToTimeString(maxClientResponseDelay, true).c_str()); _session->KickPlayer(); } else diff --git a/src/server/game/Warden/WardenMac.cpp b/src/server/game/Warden/WardenMac.cpp index 9c90662105a..e08d24ecbcd 100644 --- a/src/server/game/Warden/WardenMac.cpp +++ b/src/server/game/Warden/WardenMac.cpp @@ -152,7 +152,7 @@ void WardenMac::HandleHashResult(ByteBuffer &buff) // Verify key if (memcmp(buff.contents() + 1, sha1.GetDigest(), 20) != 0) { - sLog->outWarn(LOG_FILTER_WARDEN, "%s failed hash reply. Action: %s", _session->GetPlayerName(false).c_str(), Penalty().c_str()); + sLog->outWarn(LOG_FILTER_WARDEN, "%s failed hash reply. Action: %s", _session->GetPlayerInfo().c_str(), Penalty().c_str()); return; } diff --git a/src/server/game/Warden/WardenWin.cpp b/src/server/game/Warden/WardenWin.cpp index 20f09ec5bda..3d5f27f6a31 100644 --- a/src/server/game/Warden/WardenWin.cpp +++ b/src/server/game/Warden/WardenWin.cpp @@ -156,7 +156,7 @@ void WardenWin::HandleHashResult(ByteBuffer &buff) // Verify key if (memcmp(buff.contents() + 1, Module.ClientKeySeedHash, 20) != 0) { - sLog->outWarn(LOG_FILTER_WARDEN, "%s failed hash reply. Action: %s", _session->GetPlayerName(false).c_str(), Penalty().c_str()); + sLog->outWarn(LOG_FILTER_WARDEN, "%s failed hash reply. Action: %s", _session->GetPlayerInfo().c_str(), Penalty().c_str()); return; } @@ -341,7 +341,7 @@ void WardenWin::HandleData(ByteBuffer &buff) if (!IsValidCheckSum(Checksum, buff.contents() + buff.rpos(), Length)) { buff.rpos(buff.wpos()); - sLog->outWarn(LOG_FILTER_WARDEN, "%s failed checksum. Action: %s", _session->GetPlayerName(false).c_str(), Penalty().c_str()); + sLog->outWarn(LOG_FILTER_WARDEN, "%s failed checksum. Action: %s", _session->GetPlayerInfo().c_str(), Penalty().c_str()); return; } @@ -352,7 +352,7 @@ void WardenWin::HandleData(ByteBuffer &buff) // TODO: test it. if (result == 0x00) { - sLog->outWarn(LOG_FILTER_WARDEN, "%s failed timing check. Action: %s", _session->GetPlayerName(false).c_str(), Penalty().c_str()); + sLog->outWarn(LOG_FILTER_WARDEN, "%s failed timing check. Action: %s", _session->GetPlayerInfo().c_str(), Penalty().c_str()); return; } @@ -494,7 +494,7 @@ void WardenWin::HandleData(ByteBuffer &buff) if (checkFailed > 0) { WardenCheck* check = sWardenCheckMgr->GetWardenDataById(checkFailed); - sLog->outWarn(LOG_FILTER_WARDEN, "%s failed Warden check %u. Action: %s", _session->GetPlayerName(false).c_str(), checkFailed, Penalty(check).c_str()); + sLog->outWarn(LOG_FILTER_WARDEN, "%s failed Warden check %u. Action: %s", _session->GetPlayerInfo().c_str(), checkFailed, Penalty(check).c_str()); } // Set hold off timer, minimum timer should at least be 1 second diff --git a/src/server/game/World/World.cpp b/src/server/game/World/World.cpp index 5f3963f405b..e19f0b56f4b 100755 --- a/src/server/game/World/World.cpp +++ b/src/server/game/World/World.cpp @@ -983,6 +983,13 @@ void World::LoadConfigSettings(bool reload) m_int_configs[CONFIG_RANDOM_BG_RESET_HOUR] = 6; } + m_int_configs[CONFIG_GUILD_RESET_HOUR] = ConfigMgr::GetIntDefault("Guild.ResetHour", 6); + if (m_int_configs[CONFIG_GUILD_RESET_HOUR] > 23) + { + sLog->outError(LOG_FILTER_GENERAL, "Guild.ResetHour (%i) can't be load. Set to 6.", m_int_configs[CONFIG_GUILD_RESET_HOUR]); + m_int_configs[CONFIG_GUILD_RESET_HOUR] = 6; + } + m_bool_configs[CONFIG_DETECT_POS_COLLISION] = ConfigMgr::GetBoolDefault("DetectPosCollision", true); m_bool_configs[CONFIG_RESTRICTED_LFG_CHANNEL] = ConfigMgr::GetBoolDefault("Channel.RestrictedLfg", true); @@ -1187,7 +1194,7 @@ void World::LoadConfigSettings(bool reload) m_int_configs[CONFIG_WARDEN_CLIENT_RESPONSE_DELAY] = ConfigMgr::GetIntDefault("Warden.ClientResponseDelay", 600); // Dungeon finder - m_bool_configs[CONFIG_DUNGEON_FINDER_ENABLE] = ConfigMgr::GetBoolDefault("DungeonFinder.Enable", false); + m_int_configs[CONFIG_LFG_OPTIONSMASK] = ConfigMgr::GetIntDefault("DungeonFinder.OptionsMask", 1); // DBC_ItemAttributes m_bool_configs[CONFIG_DBC_ENFORCE_ITEM_ATTRIBUTES] = ConfigMgr::GetBoolDefault("DBC.EnforceItemAttributes", true); @@ -1469,16 +1476,6 @@ void World::SetInitialWorldSettings() sLog->outInfo(LOG_FILTER_SERVER_LOADING, "Loading Vehicle Accessories..."); sObjectMgr->LoadVehicleAccessories(); // must be after LoadCreatureTemplates() and LoadNPCSpellClickSpells() - sLog->outInfo(LOG_FILTER_SERVER_LOADING, "Loading LFG entrance positions..."); - sLFGMgr->LoadLFGDungeons(); - - sLog->outInfo(LOG_FILTER_SERVER_LOADING, "Loading Dungeon boss data..."); - sObjectMgr->LoadInstanceEncounters(); - - sLog->outInfo(LOG_FILTER_SERVER_LOADING, "Loading LFG rewards..."); - sLFGMgr->LoadRewards(); - - sLog->outInfo(LOG_FILTER_SERVER_LOADING, "Loading SpellArea Data..."); // must be after quest load sSpellMgr->LoadSpellAreas(); @@ -1497,6 +1494,15 @@ void World::SetInitialWorldSettings() sLog->outInfo(LOG_FILTER_SERVER_LOADING, "Loading AreaTrigger script names..."); sObjectMgr->LoadAreaTriggerScripts(); + sLog->outInfo(LOG_FILTER_SERVER_LOADING, "Loading LFG entrance positions..."); // Must be after areatriggers + sLFGMgr->LoadLFGDungeons(); + + sLog->outInfo(LOG_FILTER_SERVER_LOADING, "Loading Dungeon boss data..."); + sObjectMgr->LoadInstanceEncounters(); + + sLog->outInfo(LOG_FILTER_SERVER_LOADING, "Loading LFG rewards..."); + sLFGMgr->LoadRewards(); + sLog->outInfo(LOG_FILTER_SERVER_LOADING, "Loading Graveyard-zone links..."); sObjectMgr->LoadGraveyardZones(); @@ -1780,6 +1786,9 @@ void World::SetInitialWorldSettings() sLog->outInfo(LOG_FILTER_SERVER_LOADING, "Calculate random battleground reset time..."); InitRandomBGResetTime(); + sLog->outInfo(LOG_FILTER_SERVER_LOADING, "Calculate Guild cap reset time..."); + InitGuildResetTime(); + LoadCharacterNameData(); uint32 startupDuration = GetMSTimeDiffToNow(startupBegin); @@ -1935,6 +1944,9 @@ void World::Update(uint32 diff) if (m_gameTime > m_NextRandomBGReset) ResetRandomBG(); + if (m_gameTime > m_NextGuildReset) + ResetGuildCap(); + /// <ul><li> Handle auctions when the timer has passed if (m_timers[WUPDATE_AUCTIONS].Passed()) { @@ -2276,7 +2288,7 @@ void World::KickAllLess(AccountTypes sec) } /// Ban an account or ban an IP address, duration will be parsed using TimeStringToSecs if it is positive, otherwise permban -BanReturn World::BanAccount(BanMode mode, std::string nameOrIP, std::string duration, std::string reason, std::string author) +BanReturn World::BanAccount(BanMode mode, std::string const& nameOrIP, std::string const& duration, std::string const& reason, std::string const& author) { uint32 duration_secs = TimeStringToSecs(duration); PreparedQueryResult resultAccounts = PreparedQueryResult(NULL); //used for kicking @@ -2354,7 +2366,7 @@ BanReturn World::BanAccount(BanMode mode, std::string nameOrIP, std::string dura } /// Remove a ban from an account or IP address -bool World::RemoveBanAccount(BanMode mode, std::string nameOrIP) +bool World::RemoveBanAccount(BanMode mode, std::string const& nameOrIP) { PreparedStatement* stmt = NULL; if (mode == BAN_IP) @@ -2383,9 +2395,9 @@ bool World::RemoveBanAccount(BanMode mode, std::string nameOrIP) } /// Ban an account or ban an IP address, duration will be parsed using TimeStringToSecs if it is positive, otherwise permban -BanReturn World::BanCharacter(std::string name, std::string duration, std::string reason, std::string author) +BanReturn World::BanCharacter(std::string const& name, std::string const& duration, std::string const& reason, std::string const& author) { - Player* pBanned = sObjectAccessor->FindPlayerByName(name.c_str()); + Player* pBanned = sObjectAccessor->FindPlayerByName(name); uint32 guid = 0; uint32 duration_secs = TimeStringToSecs(duration); @@ -2424,9 +2436,9 @@ BanReturn World::BanCharacter(std::string name, std::string duration, std::strin } /// Remove a ban from a character -bool World::RemoveBanCharacter(std::string name) +bool World::RemoveBanCharacter(std::string const& name) { - Player* pBanned = sObjectAccessor->FindPlayerByName(name.c_str()); + Player* pBanned = sObjectAccessor->FindPlayerByName(name); uint32 guid = 0; /// Pick a player to ban if not online @@ -2745,6 +2757,33 @@ void World::InitRandomBGResetTime() sWorld->setWorldState(WS_BG_DAILY_RESET_TIME, uint64(m_NextRandomBGReset)); } +void World::InitGuildResetTime() +{ + time_t gtime = uint64(getWorldState(WS_GUILD_DAILY_RESET_TIME)); + if (!gtime) + m_NextGuildReset = time_t(time(NULL)); // game time not yet init + + // generate time by config + time_t curTime = time(NULL); + tm localTm = *localtime(&curTime); + localTm.tm_hour = getIntConfig(CONFIG_GUILD_RESET_HOUR); + localTm.tm_min = 0; + localTm.tm_sec = 0; + + // current day reset time + time_t nextDayResetTime = mktime(&localTm); + + // next reset time before current moment + if (curTime >= nextDayResetTime) + nextDayResetTime += DAY; + + // normalize reset time + m_NextGuildReset = gtime < curTime ? nextDayResetTime - DAY : nextDayResetTime; + + if (!gtime) + sWorld->setWorldState(WS_GUILD_DAILY_RESET_TIME, uint64(m_NextGuildReset)); +} + void World::ResetDailyQuests() { sLog->outInfo(LOG_FILTER_GENERAL, "Daily quests reset for all characters."); @@ -2821,6 +2860,15 @@ void World::ResetRandomBG() sWorld->setWorldState(WS_BG_DAILY_RESET_TIME, uint64(m_NextRandomBGReset)); } +void World::ResetGuildCap() +{ + sLog->outInfo(LOG_FILTER_GENERAL, "Guild Daily Cap reset."); + + m_NextGuildReset = time_t(m_NextGuildReset + DAY); + sWorld->setWorldState(WS_GUILD_DAILY_RESET_TIME, uint64(m_NextGuildReset)); + sGuildMgr->ResetTimes(); +} + void World::UpdateMaxSessionCounters() { m_maxActiveSessionCount = std::max(m_maxActiveSessionCount, uint32(m_sessions.size()-m_QueuedPlayer.size())); diff --git a/src/server/game/World/World.h b/src/server/game/World/World.h index 369cd95830c..7342c76f619 100644 --- a/src/server/game/World/World.h +++ b/src/server/game/World/World.h @@ -154,7 +154,6 @@ enum WorldBoolConfigs CONFIG_CHATLOG_PUBLIC, CONFIG_CHATLOG_ADDON, CONFIG_CHATLOG_BGROUND, - CONFIG_DUNGEON_FINDER_ENABLE, CONFIG_AUTOBROADCAST, CONFIG_ALLOW_TICKETS, CONFIG_DBC_ENFORCE_ITEM_ATTRIBUTES, @@ -304,6 +303,7 @@ enum WorldIntConfigs CONFIG_GUILD_BANK_EVENT_LOG_COUNT, CONFIG_MIN_LEVEL_STAT_SAVE, CONFIG_RANDOM_BG_RESET_HOUR, + CONFIG_GUILD_RESET_HOUR, CONFIG_CHARDELETE_KEEP_DAYS, CONFIG_CHARDELETE_METHOD, CONFIG_CHARDELETE_MIN_LEVEL, @@ -313,6 +313,7 @@ enum WorldIntConfigs CONFIG_DB_PING_INTERVAL, CONFIG_PRESERVE_CUSTOM_CHANNEL_DURATION, CONFIG_PERSISTENT_CHARACTER_CLEAN_FLAGS, + CONFIG_LFG_OPTIONSMASK, CONFIG_MAX_INSTANCES_PER_HOUR, CONFIG_WARDEN_CLIENT_RESPONSE_DELAY, CONFIG_WARDEN_CLIENT_CHECK_HOLDOFF, @@ -468,8 +469,9 @@ enum RealmZone enum WorldStates { - WS_WEEKLY_QUEST_RESET_TIME = 20002, // Next weekly reset time - WS_BG_DAILY_RESET_TIME = 20003 // Next daily BG reset time + WS_WEEKLY_QUEST_RESET_TIME = 20002, // Next weekly reset time + WS_BG_DAILY_RESET_TIME = 20003, // Next daily BG reset time + WS_GUILD_DAILY_RESET_TIME = 20006, // Next guild cap reset time }; // DB scripting commands @@ -605,19 +607,19 @@ class World void SetAllowMovement(bool allow) { m_allowMovement = allow; } /// Set a new Message of the Day - void SetMotd(const std::string& motd); + void SetMotd(std::string const& motd); /// Get the current Message of the Day const char* GetMotd() const; /// Set the string for new characters (first login) - void SetNewCharString(std::string str) { m_newCharString = str; } + void SetNewCharString(std::string const& str) { m_newCharString = str; } /// Get the string for new characters (first login) - const std::string& GetNewCharString() const { return m_newCharString; } + std::string const& GetNewCharString() const { return m_newCharString; } LocaleConstant GetDefaultDbcLocale() const { return m_defaultDbcLocale; } /// Get the path where data (dbc, maps) are stored on disk - std::string GetDataPath() const { return m_dataPath; } + std::string const& GetDataPath() const { return m_dataPath; } /// When server started? time_t const& GetStartTime() const { return m_startTime; } @@ -720,10 +722,10 @@ class World void KickAll(); void KickAllLess(AccountTypes sec); - BanReturn BanAccount(BanMode mode, std::string nameOrIP, std::string duration, std::string reason, std::string author); - bool RemoveBanAccount(BanMode mode, std::string nameOrIP); - BanReturn BanCharacter(std::string name, std::string duration, std::string reason, std::string author); - bool RemoveBanCharacter(std::string name); + BanReturn BanAccount(BanMode mode, std::string const& nameOrIP, std::string const& duration, std::string const& reason, std::string const& author); + bool RemoveBanAccount(BanMode mode, std::string const& nameOrIP); + BanReturn BanCharacter(std::string const& name, std::string const& duration, std::string const& reason, std::string const& author); + bool RemoveBanCharacter(std::string const& name); // for max speed access static float GetMaxVisibleDistanceOnContinents() { return m_MaxVisibleDistanceOnContinents; } @@ -776,9 +778,11 @@ class World void InitDailyQuestResetTime(); void InitWeeklyQuestResetTime(); void InitRandomBGResetTime(); + void InitGuildResetTime(); void ResetDailyQuests(); void ResetWeeklyQuests(); void ResetRandomBG(); + void ResetGuildCap(); private: static ACE_Atomic_Op<ACE_Thread_Mutex, bool> m_stopEvent; static uint8 m_ExitCode; @@ -839,6 +843,7 @@ class World time_t m_NextDailyQuestReset; time_t m_NextWeeklyQuestReset; time_t m_NextRandomBGReset; + time_t m_NextGuildReset; //Player Queue Queue m_QueuedPlayer; diff --git a/src/server/scripts/CMakeLists.txt b/src/server/scripts/CMakeLists.txt index 619e2730f79..2d15dfb3081 100644 --- a/src/server/scripts/CMakeLists.txt +++ b/src/server/scripts/CMakeLists.txt @@ -44,6 +44,7 @@ if(SCRIPTS) include(Kalimdor/CMakeLists.txt) include(Outland/CMakeLists.txt) include(Northrend/CMakeLists.txt) + include(Events/CMakeLists.txt) endif() message(STATUS "SCRIPT PREPARATION COMPLETE") diff --git a/src/server/scripts/Commands/CMakeLists.txt b/src/server/scripts/Commands/CMakeLists.txt index e799cf20633..e7e2e430f81 100644 --- a/src/server/scripts/Commands/CMakeLists.txt +++ b/src/server/scripts/Commands/CMakeLists.txt @@ -27,6 +27,7 @@ set(scripts_STAT_SRCS Commands/cs_honor.cpp Commands/cs_instance.cpp Commands/cs_learn.cpp + Commands/cs_lfg.cpp Commands/cs_list.cpp Commands/cs_lookup.cpp Commands/cs_message.cpp diff --git a/src/server/scripts/Commands/cs_account.cpp b/src/server/scripts/Commands/cs_account.cpp index 1024a3acf15..15a724e69d1 100644 --- a/src/server/scripts/Commands/cs_account.cpp +++ b/src/server/scripts/Commands/cs_account.cpp @@ -111,9 +111,9 @@ public: handler->PSendSysMessage(LANG_ACCOUNT_CREATED, accountName); if (handler->GetSession()) { - sLog->outInfo(LOG_FILTER_CHARACTER, "Account: %d (IP: %s) Character:[%s] (GUID: %u) Change Password." - , handler->GetSession()->GetAccountId(),handler->GetSession()->GetRemoteAddress().c_str() - , handler->GetSession()->GetPlayer()->GetName(), handler->GetSession()->GetPlayer()->GetGUIDLow()); + sLog->outInfo(LOG_FILTER_CHARACTER, "Account: %d (IP: %s) Character:[%s] (GUID: %u) Change Password.", + handler->GetSession()->GetAccountId(), handler->GetSession()->GetRemoteAddress().c_str(), + handler->GetSession()->GetPlayer()->GetName().c_str(), handler->GetSession()->GetPlayer()->GetGUIDLow()); } break; case AOR_NAME_TOO_LONG: diff --git a/src/server/scripts/Commands/cs_character.cpp b/src/server/scripts/Commands/cs_character.cpp index 1f32368adfd..2202edbe4aa 100644 --- a/src/server/scripts/Commands/cs_character.cpp +++ b/src/server/scripts/Commands/cs_character.cpp @@ -265,7 +265,7 @@ public: return false; LocaleConstant loc = handler->GetSessionDbcLocale(); - char const* targetName = target->GetName(); + char const* targetName = target->GetName().c_str(); char const* knownStr = handler->GetTrinityString(LANG_KNOWN); // Search in CharTitles.dbc @@ -681,7 +681,7 @@ public: uint64 characterGuid; uint32 accountId; - Player* player = sObjectAccessor->FindPlayerByName(characterName.c_str()); + Player* player = sObjectAccessor->FindPlayerByName(characterName); if (player) { characterGuid = player->GetGUID(); diff --git a/src/server/scripts/Commands/cs_debug.cpp b/src/server/scripts/Commands/cs_debug.cpp index 7f25a11bcdd..99ed8cc4301 100644 --- a/src/server/scripts/Commands/cs_debug.cpp +++ b/src/server/scripts/Commands/cs_debug.cpp @@ -417,7 +417,7 @@ public: sLog->outDebug(LOG_FILTER_NETWORKIO, "Sending opcode %u", data.GetOpcode()); data.hexlike(); player->GetSession()->SendPacket(&data); - handler->PSendSysMessage(LANG_COMMAND_OPCODESENT, data.GetOpcode(), unit->GetName()); + handler->PSendSysMessage(LANG_COMMAND_OPCODESENT, data.GetOpcode(), unit->GetName().c_str()); return true; } @@ -496,7 +496,9 @@ public: if (!target) return false; - handler->PSendSysMessage("Loot recipient for creature %s (GUID %u, DB GUID %u) is %s", target->GetName(), target->GetGUIDLow(), target->GetDBTableGUIDLow(), target->hasLootRecipient() ? (target->GetLootRecipient() ? target->GetLootRecipient()->GetName() : "offline") : "no loot recipient"); + handler->PSendSysMessage("Loot recipient for creature %s (GUID %u, DB GUID %u) is %s", + target->GetName().c_str(), target->GetGUIDLow(), target->GetDBTableGUIDLow(), + target->hasLootRecipient() ? (target->GetLootRecipient() ? target->GetLootRecipient()->GetName().c_str() : "offline") : "no loot recipient"); return true; } @@ -796,17 +798,17 @@ public: if (!target || target->isTotem() || target->isPet()) return false; - std::list<HostileReference*>& threatList = target->getThreatManager().getThreatList(); - std::list<HostileReference*>::iterator itr; + ThreatContainer::StorageType const &threatList = target->getThreatManager().getThreatList(); + ThreatContainer::StorageType::const_iterator itr; uint32 count = 0; - handler->PSendSysMessage("Threat list of %s (guid %u)", target->GetName(), target->GetGUIDLow()); + handler->PSendSysMessage("Threat list of %s (guid %u)", target->GetName().c_str(), target->GetGUIDLow()); for (itr = threatList.begin(); itr != threatList.end(); ++itr) { Unit* unit = (*itr)->getTarget(); if (!unit) continue; ++count; - handler->PSendSysMessage(" %u. %s (guid %u) - threat %f", count, unit->GetName(), unit->GetGUIDLow(), (*itr)->getThreat()); + handler->PSendSysMessage(" %u. %s (guid %u) - threat %f", count, unit->GetName().c_str(), unit->GetGUIDLow(), (*itr)->getThreat()); } handler->SendSysMessage("End of threat list."); return true; @@ -819,13 +821,13 @@ public: target = handler->GetSession()->GetPlayer(); HostileReference* ref = target->getHostileRefManager().getFirst(); uint32 count = 0; - handler->PSendSysMessage("Hostil reference list of %s (guid %u)", target->GetName(), target->GetGUIDLow()); + handler->PSendSysMessage("Hostil reference list of %s (guid %u)", target->GetName().c_str(), target->GetGUIDLow()); while (ref) { if (Unit* unit = ref->getSource()->getOwner()) { ++count; - handler->PSendSysMessage(" %u. %s (guid %u) - threat %f", count, unit->GetName(), unit->GetGUIDLow(), ref->getThreat()); + handler->PSendSysMessage(" %u. %s (guid %u) - threat %f", count, unit->GetName().c_str(), unit->GetGUIDLow(), ref->getThreat()); } ref = ref->next(); } @@ -1047,7 +1049,7 @@ public: static bool HandleDebugLoSCommand(ChatHandler* handler, char const* /*args*/) { if (Unit* unit = handler->getSelectedUnit()) - handler->PSendSysMessage("Unit %s (GuidLow: %u) is %sin LoS", unit->GetName(), unit->GetGUIDLow(), handler->GetSession()->GetPlayer()->IsWithinLOSInMap(unit) ? "" : "not "); + handler->PSendSysMessage("Unit %s (GuidLow: %u) is %sin LoS", unit->GetName().c_str(), unit->GetGUIDLow(), handler->GetSession()->GetPlayer()->IsWithinLOSInMap(unit) ? "" : "not "); return true; } diff --git a/src/server/scripts/Commands/cs_gm.cpp b/src/server/scripts/Commands/cs_gm.cpp index 3dfc6f9c7e8..4c6e36d3f71 100644 --- a/src/server/scripts/Commands/cs_gm.cpp +++ b/src/server/scripts/Commands/cs_gm.cpp @@ -133,16 +133,17 @@ public: handler->SendSysMessage(LANG_GMS_ON_SRV); handler->SendSysMessage("========================"); } - char const* name = itr->second->GetName(); + std::string const& name = itr->second->GetName(); + uint8 size = name.size(); uint8 security = itrSec; - uint8 max = ((16 - strlen(name)) / 2); + uint8 max = ((16 - size) / 2); uint8 max2 = max; - if ((max + max2 + strlen(name)) == 16) + if ((max + max2 + size) == 16) max2 = max - 1; if (handler->GetSession()) - handler->PSendSysMessage("| %s GMLevel %u", name, security); + handler->PSendSysMessage("| %s GMLevel %u", name.c_str(), security); else - handler->PSendSysMessage("|%*s%s%*s| %u |", max, " ", name, max2, " ", security); + handler->PSendSysMessage("|%*s%s%*s| %u |", max, " ", name.c_str(), max2, " ", security); } } if (footer) diff --git a/src/server/scripts/Commands/cs_lfg.cpp b/src/server/scripts/Commands/cs_lfg.cpp new file mode 100644 index 00000000000..5f1ed59176f --- /dev/null +++ b/src/server/scripts/Commands/cs_lfg.cpp @@ -0,0 +1,134 @@ +/* + * Copyright (C) 2008-2012 TrinityCore <http://www.trinitycore.org/> + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#include "ScriptMgr.h" +#include "Chat.h" +#include "LFGMgr.h" +#include "Group.h" + +void GetPlayerInfo(ChatHandler* handler, Player* player) +{ + if (!player) + return; + + uint64 guid = player->GetGUID(); + LfgDungeonSet dungeons = sLFGMgr->GetSelectedDungeons(guid); + + std::string const& state = sLFGMgr->GetStateString(sLFGMgr->GetState(guid)); + handler->PSendSysMessage(LANG_LFG_PLAYER_INFO, player->GetName().c_str(), + state.c_str(), uint8(dungeons.size()), sLFGMgr->ConcatenateDungeons(dungeons).c_str(), + sLFGMgr->GetRolesString(sLFGMgr->GetRoles(guid)).c_str(), sLFGMgr->GetComment(guid).c_str()); +} + +class lfg_commandscript : public CommandScript +{ +public: + lfg_commandscript() : CommandScript("lfg_commandscript") { } + + ChatCommand* GetCommands() const + { + static ChatCommand lfgCommandTable[] = + { + { "player", SEC_GAMEMASTER, false, &HandleLfgPlayerInfoCommand, "", NULL }, + { "group", SEC_GAMEMASTER, false, &HandleLfgGroupInfoCommand, "", NULL }, + { "queue", SEC_GAMEMASTER, false, &HandleLfgQueueInfoCommand, "", NULL }, + { "clean", SEC_ADMINISTRATOR, false, &HandleLfgCleanCommand, "", NULL }, + { "options", SEC_ADMINISTRATOR, false, &HandleLfgOptionsCommand, "", NULL }, + { NULL, SEC_PLAYER, false, NULL, "", NULL } + }; + + static ChatCommand commandTable[] = + { + { "lfg", SEC_GAMEMASTER, false, NULL, "", lfgCommandTable }, + { NULL, SEC_PLAYER, false, NULL, "", NULL } + }; + return commandTable; + } + + static bool HandleLfgPlayerInfoCommand(ChatHandler* handler, char const* args) + { + Player* target = NULL; + std::string playerName; + if (!handler->extractPlayerTarget((char*)args, &target, NULL, &playerName)) + return false; + + GetPlayerInfo(handler, target); + return true; + } + + static bool HandleLfgGroupInfoCommand(ChatHandler* handler, char const* args) + { + Player* target = NULL; + std::string playerName; + if (!handler->extractPlayerTarget((char*)args, &target, NULL, &playerName)) + return false; + + Group* grp = target->GetGroup(); + if (!grp) + { + handler->PSendSysMessage(LANG_LFG_NOT_IN_GROUP, playerName.c_str()); + return true; + } + + uint64 guid = grp->GetGUID(); + std::string const& state = sLFGMgr->GetStateString(sLFGMgr->GetState(guid)); + handler->PSendSysMessage(LANG_LFG_GROUP_INFO, grp->isLFGGroup(), + state.c_str(), sLFGMgr->GetDungeon(guid)); + + for (GroupReference* itr = grp->GetFirstMember(); itr != NULL; itr = itr->next()) + GetPlayerInfo(handler, itr->getSource()); + + return true; + } + + static bool HandleLfgOptionsCommand(ChatHandler* handler, char const* args) + { + int32 options = -1; + if (char* str = strtok((char*)args, " ")) + { + int32 tmp = atoi(str); + if (tmp > -1) + options = tmp; + } + + if (options != -1) + { + sLFGMgr->SetOptions(options); + handler->PSendSysMessage(LANG_LFG_OPTIONS_CHANGED); + } + handler->PSendSysMessage(LANG_LFG_OPTIONS, sLFGMgr->GetOptions()); + return true; + } + + static bool HandleLfgQueueInfoCommand(ChatHandler* handler, char const* args) + { + handler->SendSysMessage(sLFGMgr->DumpQueueInfo(*args).c_str()); + return true; + } + + static bool HandleLfgCleanCommand(ChatHandler* handler, char const* /*args*/) + { + handler->PSendSysMessage(LANG_LFG_CLEAN); + sLFGMgr->Clean(); + return true; + } +}; + +void AddSC_lfg_commandscript() +{ + new lfg_commandscript(); +} diff --git a/src/server/scripts/Commands/cs_lookup.cpp b/src/server/scripts/Commands/cs_lookup.cpp index 951ebc7714b..8f7e3ed3247 100644 --- a/src/server/scripts/Commands/cs_lookup.cpp +++ b/src/server/scripts/Commands/cs_lookup.cpp @@ -1081,7 +1081,7 @@ public: Player* target = handler->getSelectedPlayer(); // title name have single string arg for player name - char const* targetName = target ? target->GetName() : "NAME"; + char const* targetName = target ? target->GetName().c_str() : "NAME"; std::string namePart = args; std::wstring wNamePart; diff --git a/src/server/scripts/Commands/cs_message.cpp b/src/server/scripts/Commands/cs_message.cpp index d61abf34e2f..de2fcf26943 100644 --- a/src/server/scripts/Commands/cs_message.cpp +++ b/src/server/scripts/Commands/cs_message.cpp @@ -71,7 +71,7 @@ public: Player* player = handler->GetSession()->GetPlayer(); Channel* channcel = NULL; - if (ChannelMgr* cMgr = channelMgr(player->GetTeam())) + if (ChannelMgr* cMgr = ChannelMgr::forTeam(player->GetTeam())) channcel = cMgr->GetChannel(channelStr, player); if (strcmp(argStr, "on") == 0) diff --git a/src/server/scripts/Commands/cs_misc.cpp b/src/server/scripts/Commands/cs_misc.cpp index f7280cf906e..7e460c7482f 100644 --- a/src/server/scripts/Commands/cs_misc.cpp +++ b/src/server/scripts/Commands/cs_misc.cpp @@ -1923,9 +1923,9 @@ public: if (!target) handler->SendSysMessage(LANG_MOVEGENS_CHASE_NULL); else if (target->GetTypeId() == TYPEID_PLAYER) - handler->PSendSysMessage(LANG_MOVEGENS_CHASE_PLAYER, target->GetName(), target->GetGUIDLow()); + handler->PSendSysMessage(LANG_MOVEGENS_CHASE_PLAYER, target->GetName().c_str(), target->GetGUIDLow()); else - handler->PSendSysMessage(LANG_MOVEGENS_CHASE_CREATURE, target->GetName(), target->GetGUIDLow()); + handler->PSendSysMessage(LANG_MOVEGENS_CHASE_CREATURE, target->GetName().c_str(), target->GetGUIDLow()); break; } case FOLLOW_MOTION_TYPE: @@ -1939,9 +1939,9 @@ public: if (!target) handler->SendSysMessage(LANG_MOVEGENS_FOLLOW_NULL); else if (target->GetTypeId() == TYPEID_PLAYER) - handler->PSendSysMessage(LANG_MOVEGENS_FOLLOW_PLAYER, target->GetName(), target->GetGUIDLow()); + handler->PSendSysMessage(LANG_MOVEGENS_FOLLOW_PLAYER, target->GetName().c_str(), target->GetGUIDLow()); else - handler->PSendSysMessage(LANG_MOVEGENS_FOLLOW_CREATURE, target->GetName(), target->GetGUIDLow()); + handler->PSendSysMessage(LANG_MOVEGENS_FOLLOW_CREATURE, target->GetName().c_str(), target->GetGUIDLow()); break; } case HOME_MOTION_TYPE: @@ -2534,7 +2534,7 @@ public: { name = TargetName; normalizePlayerName(name); - player = sObjectAccessor->FindPlayerByName(name.c_str()); + player = sObjectAccessor->FindPlayerByName(name); } if (!player) @@ -2593,7 +2593,7 @@ public: { name = targetName; normalizePlayerName(name); - player = sObjectAccessor->FindPlayerByName(name.c_str()); + player = sObjectAccessor->FindPlayerByName(name); } else // If no name was entered - use target { diff --git a/src/server/scripts/Commands/cs_npc.cpp b/src/server/scripts/Commands/cs_npc.cpp index 77fc2918e0b..ba7342caa80 100644 --- a/src/server/scripts/Commands/cs_npc.cpp +++ b/src/server/scripts/Commands/cs_npc.cpp @@ -47,19 +47,19 @@ public: { "weapon", SEC_ADMINISTRATOR, false, &HandleNpcAddWeaponCommand, "", NULL }, //} { "", SEC_GAMEMASTER, false, &HandleNpcAddCommand, "", NULL }, - { NULL, 0, false, NULL, "", NULL } + { NULL, SEC_PLAYER, false, NULL, "", NULL } }; static ChatCommand npcDeleteCommandTable[] = { { "item", SEC_GAMEMASTER, false, &HandleNpcDeleteVendorItemCommand, "", NULL }, { "", SEC_GAMEMASTER, false, &HandleNpcDeleteCommand, "", NULL }, - { NULL, 0, false, NULL, "", NULL } + { NULL, SEC_PLAYER, false, NULL, "", NULL } }; static ChatCommand npcFollowCommandTable[] = { { "stop", SEC_GAMEMASTER, false, &HandleNpcUnFollowCommand, "", NULL }, { "", SEC_GAMEMASTER, false, &HandleNpcFollowCommand, "", NULL }, - { NULL, 0, false, NULL, "", NULL } + { NULL, SEC_PLAYER, false, NULL, "", NULL } }; static ChatCommand npcSetCommandTable[] = { @@ -79,7 +79,7 @@ public: { "name", SEC_GAMEMASTER, false, &HandleNpcSetNameCommand, "", NULL }, { "subname", SEC_GAMEMASTER, false, &HandleNpcSetSubNameCommand, "", NULL }, //} - { NULL, 0, false, NULL, "", NULL } + { NULL, SEC_PLAYER, false, NULL, "", NULL } }; static ChatCommand npcCommandTable[] = { @@ -95,18 +95,18 @@ public: { "delete", SEC_GAMEMASTER, false, NULL, "", npcDeleteCommandTable }, { "follow", SEC_GAMEMASTER, false, NULL, "", npcFollowCommandTable }, { "set", SEC_GAMEMASTER, false, NULL, "", npcSetCommandTable }, - { NULL, 0, false, NULL, "", NULL } + { NULL, SEC_PLAYER, false, NULL, "", NULL } }; static ChatCommand commandTable[] = { { "npc", SEC_MODERATOR, false, NULL, "", npcCommandTable }, - { NULL, 0, false, NULL, "", NULL } + { NULL, SEC_PLAYER, false, NULL, "", NULL } }; return commandTable; } //add spawn of creature - static bool HandleNpcAddCommand(ChatHandler* handler, const char* args) + static bool HandleNpcAddCommand(ChatHandler* handler, char const* args) { if (!*args) return false; @@ -229,7 +229,7 @@ public: } //add move for creature - static bool HandleNpcAddMoveCommand(ChatHandler* handler, const char* args) + static bool HandleNpcAddMoveCommand(ChatHandler* handler, char const* args) { if (!*args) return false; @@ -293,7 +293,7 @@ public: return true; } - static bool HandleNpcSetAllowMovementCommand(ChatHandler* handler, const char* /*args*/) + static bool HandleNpcSetAllowMovementCommand(ChatHandler* handler, char const* /*args*/) { if (sWorld->getAllowMovement()) { @@ -308,7 +308,7 @@ public: return true; } - static bool HandleNpcSetEntryCommand(ChatHandler* handler, const char* args) + static bool HandleNpcSetEntryCommand(ChatHandler* handler, char const* args) { if (!*args) return false; @@ -333,7 +333,7 @@ public: } //change level of creature or pet - static bool HandleNpcSetLevelCommand(ChatHandler* handler, const char* args) + static bool HandleNpcSetLevelCommand(ChatHandler* handler, char const* args) { if (!*args) return false; @@ -374,7 +374,7 @@ public: return true; } - static bool HandleNpcDeleteCommand(ChatHandler* handler, const char* args) + static bool HandleNpcDeleteCommand(ChatHandler* handler, char const* args) { Creature* unit = NULL; @@ -413,7 +413,7 @@ public: } //del item from vendor list - static bool HandleNpcDeleteVendorItemCommand(ChatHandler* handler, const char* args) + static bool HandleNpcDeleteVendorItemCommand(ChatHandler* handler, char const* args) { if (!*args) return false; @@ -449,7 +449,7 @@ public: } //set faction of creature - static bool HandleNpcSetFactionIdCommand(ChatHandler* handler, const char* args) + static bool HandleNpcSetFactionIdCommand(ChatHandler* handler, char const* args) { if (!*args) return false; @@ -496,7 +496,7 @@ public: } //set npcflag of creature - static bool HandleNpcSetFlagCommand(ChatHandler* handler, const char* args) + static bool HandleNpcSetFlagCommand(ChatHandler* handler, char const* args) { if (!*args) return false; @@ -527,7 +527,7 @@ public: } //set data of creature for testing scripting - static bool HandleNpcSetDataCommand(ChatHandler* handler, const char* args) + static bool HandleNpcSetDataCommand(ChatHandler* handler, char const* args) { if (!*args) return false; @@ -555,12 +555,12 @@ public: creature->AI()->SetData(data_1, data_2); std::string AIorScript = creature->GetAIName() != "" ? "AI type: " + creature->GetAIName() : (creature->GetScriptName() != "" ? "Script Name: " + creature->GetScriptName() : "No AI or Script Name Set"); - handler->PSendSysMessage(LANG_NPC_SETDATA, creature->GetGUID(), creature->GetEntry(), creature->GetName(), data_1, data_2, AIorScript.c_str()); + handler->PSendSysMessage(LANG_NPC_SETDATA, creature->GetGUID(), creature->GetEntry(), creature->GetName().c_str(), data_1, data_2, AIorScript.c_str()); return true; } //npc follow handling - static bool HandleNpcFollowCommand(ChatHandler* handler, const char* /*args*/) + static bool HandleNpcFollowCommand(ChatHandler* handler, char const* /*args*/) { Player* player = handler->GetSession()->GetPlayer(); Creature* creature = handler->getSelectedCreature(); @@ -575,11 +575,11 @@ public: // Follow player - Using pet's default dist and angle creature->GetMotionMaster()->MoveFollow(player, PET_FOLLOW_DIST, creature->GetFollowAngle()); - handler->PSendSysMessage(LANG_CREATURE_FOLLOW_YOU_NOW, creature->GetName()); + handler->PSendSysMessage(LANG_CREATURE_FOLLOW_YOU_NOW, creature->GetName().c_str()); return true; } - static bool HandleNpcInfoCommand(ChatHandler* handler, const char* /*args*/) + static bool HandleNpcInfoCommand(ChatHandler* handler, char const* /*args*/) { Creature* target = handler->getSelectedCreature(); @@ -625,7 +625,7 @@ public: } //move selected creature - static bool HandleNpcMoveCommand(ChatHandler* handler, const char* args) + static bool HandleNpcMoveCommand(ChatHandler* handler, char const* args) { uint32 lowguid = 0; @@ -713,7 +713,7 @@ public: } //play npc emote - static bool HandleNpcPlayEmoteCommand(ChatHandler* handler, const char* args) + static bool HandleNpcPlayEmoteCommand(ChatHandler* handler, char const* args) { uint32 emote = atoi((char*)args); @@ -742,7 +742,7 @@ public: } //set model of creature - static bool HandleNpcSetModelCommand(ChatHandler* handler, const char* args) + static bool HandleNpcSetModelCommand(ChatHandler* handler, char const* args) { if (!*args) return false; @@ -778,7 +778,7 @@ public: * additional parameter: NODEL - so no waypoints are deleted, if you * change the movement type */ - static bool HandleNpcSetMoveTypeCommand(ChatHandler* handler, const char* args) + static bool HandleNpcSetMoveTypeCommand(ChatHandler* handler, char const* args) { if (!*args) return false; @@ -914,7 +914,7 @@ public: //npc phasemask handling //change phasemask of creature or pet - static bool HandleNpcSetPhaseCommand(ChatHandler* handler, const char* args) + static bool HandleNpcSetPhaseCommand(ChatHandler* handler, char const* args) { if (!*args) return false; @@ -944,7 +944,7 @@ public: } //set spawn dist of creature - static bool HandleNpcSetSpawnDistCommand(ChatHandler* handler, const char* args) + static bool HandleNpcSetSpawnDistCommand(ChatHandler* handler, char const* args) { if (!*args) return false; @@ -990,7 +990,7 @@ public: } //spawn time handling - static bool HandleNpcSetSpawnTimeCommand(ChatHandler* handler, const char* args) + static bool HandleNpcSetSpawnTimeCommand(ChatHandler* handler, char const* args) { if (!*args) return false; @@ -1030,7 +1030,7 @@ public: return true; } - static bool HandleNpcSayCommand(ChatHandler* handler, const char* args) + static bool HandleNpcSayCommand(ChatHandler* handler, char const* args) { if (!*args) return false; @@ -1058,7 +1058,7 @@ public: } //show text emote by creature in chat - static bool HandleNpcTextEmoteCommand(ChatHandler* handler, const char* args) + static bool HandleNpcTextEmoteCommand(ChatHandler* handler, char const* args) { if (!*args) return false; @@ -1078,7 +1078,7 @@ public: } //npc unfollow handling - static bool HandleNpcUnFollowCommand(ChatHandler* handler, const char* /*args*/) + static bool HandleNpcUnFollowCommand(ChatHandler* handler, char const* /*args*/) { Player* player = handler->GetSession()->GetPlayer(); Creature* creature = handler->getSelectedCreature(); @@ -1093,7 +1093,7 @@ public: if (/*creature->GetMotionMaster()->empty() ||*/ creature->GetMotionMaster()->GetCurrentMovementGeneratorType() != FOLLOW_MOTION_TYPE) { - handler->PSendSysMessage(LANG_CREATURE_NOT_FOLLOW_YOU, creature->GetName()); + handler->PSendSysMessage(LANG_CREATURE_NOT_FOLLOW_YOU, creature->GetName().c_str()); handler->SetSentErrorMessage(true); return false; } @@ -1102,7 +1102,7 @@ public: if (mgen->GetTarget() != player) { - handler->PSendSysMessage(LANG_CREATURE_NOT_FOLLOW_YOU, creature->GetName()); + handler->PSendSysMessage(LANG_CREATURE_NOT_FOLLOW_YOU, creature->GetName().c_str()); handler->SetSentErrorMessage(true); return false; } @@ -1110,12 +1110,12 @@ public: // reset movement creature->GetMotionMaster()->MovementExpired(true); - handler->PSendSysMessage(LANG_CREATURE_NOT_FOLLOW_YOU_NOW, creature->GetName()); + handler->PSendSysMessage(LANG_CREATURE_NOT_FOLLOW_YOU_NOW, creature->GetName().c_str()); return true; } // make npc whisper to player - static bool HandleNpcWhisperCommand(ChatHandler* handler, const char* args) + static bool HandleNpcWhisperCommand(ChatHandler* handler, char const* args) { if (!*args) return false; @@ -1142,7 +1142,7 @@ public: return true; } - static bool HandleNpcYellCommand(ChatHandler* handler, const char* args) + static bool HandleNpcYellCommand(ChatHandler* handler, char const* args) { if (!*args) return false; @@ -1164,7 +1164,7 @@ public: } // add creature, temp only - static bool HandleNpcAddTempSpawnCommand(ChatHandler* handler, const char* args) + static bool HandleNpcAddTempSpawnCommand(ChatHandler* handler, char const* args) { if (!*args) return false; @@ -1184,7 +1184,7 @@ public: } //npc tame handling - static bool HandleNpcTameCommand(ChatHandler* handler, const char* /*args*/) + static bool HandleNpcTameCommand(ChatHandler* handler, char const* /*args*/) { Creature* creatureTarget = handler->getSelectedCreature(); if (!creatureTarget || creatureTarget->isPet()) @@ -1250,7 +1250,7 @@ public: return true; } - static bool HandleNpcAddFormationCommand(ChatHandler* handler, const char* args) + static bool HandleNpcAddFormationCommand(ChatHandler* handler, char const* args) { if (!*args) return false; @@ -1302,7 +1302,7 @@ public: return true; } - static bool HandleNpcSetLinkCommand(ChatHandler* handler, const char* args) + static bool HandleNpcSetLinkCommand(ChatHandler* handler, char const* args) { if (!*args) return false; @@ -1337,7 +1337,7 @@ public: } //TODO: NpcCommands that need to be fixed : - static bool HandleNpcAddWeaponCommand(ChatHandler* /*handler*/, const char* /*args*/) + static bool HandleNpcAddWeaponCommand(ChatHandler* /*handler*/, char const* /*args*/) { /*if (!*args) return false; @@ -1405,7 +1405,7 @@ public: return true; } - static bool HandleNpcSetNameCommand(ChatHandler* /*handler*/, const char* /*args*/) + static bool HandleNpcSetNameCommand(ChatHandler* /*handler*/, char const* /*args*/) { /* Temp. disabled if (!*args) @@ -1452,7 +1452,7 @@ public: return true; } - static bool HandleNpcSetSubNameCommand(ChatHandler* /*handler*/, const char* /*args*/) + static bool HandleNpcSetSubNameCommand(ChatHandler* /*handler*/, char const* /*args*/) { /* Temp. disabled diff --git a/src/server/scripts/Commands/cs_ticket.cpp b/src/server/scripts/Commands/cs_ticket.cpp index baaa5d2bd43..c99931a90fb 100644 --- a/src/server/scripts/Commands/cs_ticket.cpp +++ b/src/server/scripts/Commands/cs_ticket.cpp @@ -156,7 +156,7 @@ public: sTicketMgr->CloseTicket(ticket->GetId(), player ? player->GetGUID() : -1); sTicketMgr->UpdateLastChange(); - std::string msg = ticket->FormatMessageString(*handler, player ? player->GetName() : "Console", NULL, NULL, NULL); + std::string msg = ticket->FormatMessageString(*handler, player ? player->GetName().c_str() : "Console", NULL, NULL, NULL); handler->SendGlobalGMSysMessage(msg.c_str()); // Inform player, who submitted this ticket, that it is closed @@ -206,7 +206,7 @@ public: sTicketMgr->UpdateLastChange(); std::string msg = ticket->FormatMessageString(*handler, NULL, ticket->GetAssignedToName().c_str(), NULL, NULL); - msg += handler->PGetParseString(LANG_COMMAND_TICKETLISTADDCOMMENT, player ? player->GetName() : "Console", comment); + msg += handler->PGetParseString(LANG_COMMAND_TICKETLISTADDCOMMENT, player ? player->GetName().c_str() : "Console", comment); handler->SendGlobalGMSysMessage(msg.c_str()); return true; @@ -258,7 +258,7 @@ public: return true; } - std::string msg = ticket->FormatMessageString(*handler, NULL, NULL, NULL, handler->GetSession() ? handler->GetSession()->GetPlayer()->GetName() : "Console"); + std::string msg = ticket->FormatMessageString(*handler, NULL, NULL, NULL, handler->GetSession() ? handler->GetSession()->GetPlayer()->GetName().c_str() : "Console"); handler->SendGlobalGMSysMessage(msg.c_str()); sTicketMgr->RemoveTicket(ticket->GetId()); @@ -389,7 +389,7 @@ public: sTicketMgr->UpdateLastChange(); std::string msg = ticket->FormatMessageString(*handler, NULL, ticket->GetAssignedToName().c_str(), - handler->GetSession() ? handler->GetSession()->GetPlayer()->GetName() : "Console", NULL); + handler->GetSession() ? handler->GetSession()->GetPlayer()->GetName().c_str() : "Console", NULL); handler->SendGlobalGMSysMessage(msg.c_str()); return true; @@ -427,7 +427,7 @@ public: // Detect target's GUID uint64 guid = 0; - if (Player* player = sObjectAccessor->FindPlayerByName(name.c_str())) + if (Player* player = sObjectAccessor->FindPlayerByName(name)) guid = player->GetGUID(); else guid = sObjectMgr->GetPlayerGUIDByName(name); diff --git a/src/server/scripts/Commands/cs_titles.cpp b/src/server/scripts/Commands/cs_titles.cpp index f35f6baca98..e1b30d122de 100644 --- a/src/server/scripts/Commands/cs_titles.cpp +++ b/src/server/scripts/Commands/cs_titles.cpp @@ -36,7 +36,7 @@ public: static ChatCommand titlesSetCommandTable[] = { { "mask", SEC_GAMEMASTER, false, &HandleTitlesSetMaskCommand, "", NULL }, - { NULL, 0, false, NULL, "", NULL } + { NULL, SEC_PLAYER, false, NULL, "", NULL } }; static ChatCommand titlesCommandTable[] = { @@ -44,17 +44,17 @@ public: { "current", SEC_GAMEMASTER, false, &HandleTitlesCurrentCommand, "", NULL }, { "remove", SEC_GAMEMASTER, false, &HandleTitlesRemoveCommand, "", NULL }, { "set", SEC_GAMEMASTER, false, NULL, "", titlesSetCommandTable }, - { NULL, 0, false, NULL, "", NULL } + { NULL, SEC_PLAYER, false, NULL, "", NULL } }; static ChatCommand commandTable[] = { { "titles", SEC_GAMEMASTER, false, NULL, "", titlesCommandTable }, - { NULL, 0, false, NULL, "", NULL } + { NULL, SEC_PLAYER, false, NULL, "", NULL } }; return commandTable; } - static bool HandleTitlesCurrentCommand(ChatHandler* handler, const char* args) + static bool HandleTitlesCurrentCommand(ChatHandler* handler, char const* args) { // number or [name] Shift-click form |color|Htitle:title_id|h[name]|h|r char* id_p = handler->extractKeyFromLink((char*)args, "Htitle"); @@ -99,7 +99,7 @@ public: return true; } - static bool HandleTitlesAddCommand(ChatHandler* handler, const char* args) + static bool HandleTitlesAddCommand(ChatHandler* handler, char const* args) { // number or [name] Shift-click form |color|Htitle:title_id|h[name]|h|r char* id_p = handler->extractKeyFromLink((char*)args, "Htitle"); @@ -136,9 +136,8 @@ public: std::string tNameLink = handler->GetNameLink(target); - char const* targetName = target->GetName(); char titleNameStr[80]; - snprintf(titleNameStr, 80, titleInfo->name[handler->GetSessionDbcLocale()], targetName); + snprintf(titleNameStr, 80, titleInfo->name[handler->GetSessionDbcLocale()], target->GetName().c_str()); target->SetTitle(titleInfo); handler->PSendSysMessage(LANG_TITLE_ADD_RES, id, titleNameStr, tNameLink.c_str()); @@ -146,7 +145,7 @@ public: return true; } - static bool HandleTitlesRemoveCommand(ChatHandler* handler, const char* args) + static bool HandleTitlesRemoveCommand(ChatHandler* handler, char const* args) { // number or [name] Shift-click form |color|Htitle:title_id|h[name]|h|r char* id_p = handler->extractKeyFromLink((char*)args, "Htitle"); @@ -185,9 +184,8 @@ public: std::string tNameLink = handler->GetNameLink(target); - char const* targetName = target->GetName(); char titleNameStr[80]; - snprintf(titleNameStr, 80, titleInfo->name[handler->GetSessionDbcLocale()], targetName); + snprintf(titleNameStr, 80, titleInfo->name[handler->GetSessionDbcLocale()], target->GetName().c_str()); handler->PSendSysMessage(LANG_TITLE_REMOVE_RES, id, titleNameStr, tNameLink.c_str()); @@ -201,7 +199,7 @@ public: } //Edit Player KnownTitles - static bool HandleTitlesSetMaskCommand(ChatHandler* handler, const char* args) + static bool HandleTitlesSetMaskCommand(ChatHandler* handler, char const* args) { if (!*args) return false; diff --git a/src/server/scripts/EasternKingdoms/BlackrockDepths/blackrock_depths.cpp b/src/server/scripts/EasternKingdoms/BlackrockDepths/blackrock_depths.cpp index 7286466d335..263897edfad 100644 --- a/src/server/scripts/EasternKingdoms/BlackrockDepths/blackrock_depths.cpp +++ b/src/server/scripts/EasternKingdoms/BlackrockDepths/blackrock_depths.cpp @@ -546,7 +546,7 @@ public: if (player->GetQuestRewardStatus(QUEST_A_BINDING_CONTRACT) != 1 && !player->HasItemCount(ITEM_THRORIUM_BROTHERHOOD_CONTRACT, 1, true) && - player->HasItemCount(ITEM_SULFURON_INGOT, 1)) + player->HasItemCount(ITEM_SULFURON_INGOT)) { player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_ITEM_GET_CONTRACT, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1); } diff --git a/src/server/scripts/EasternKingdoms/BlackwingLair/boss_chromaggus.cpp b/src/server/scripts/EasternKingdoms/BlackwingLair/boss_chromaggus.cpp index 25c3f2e41e3..9beb3bb10fe 100644 --- a/src/server/scripts/EasternKingdoms/BlackwingLair/boss_chromaggus.cpp +++ b/src/server/scripts/EasternKingdoms/BlackwingLair/boss_chromaggus.cpp @@ -240,8 +240,8 @@ public: //Affliction_Timer if (Affliction_Timer <= diff) { - std::list<HostileReference*> threatlist = me->getThreatManager().getThreatList(); - for (std::list<HostileReference*>::const_iterator i = threatlist.begin(); i != threatlist.end(); ++i) + ThreatContainer::StorageType threatlist = me->getThreatManager().getThreatList(); + for (ThreatContainer::StorageType::const_iterator i = threatlist.begin(); i != threatlist.end(); ++i) { if ((*i) && (*i)->getSource()) { diff --git a/src/server/scripts/EasternKingdoms/Gnomeregan/gnomeregan.cpp b/src/server/scripts/EasternKingdoms/Gnomeregan/gnomeregan.cpp index 65dc6c37d8a..8f79c4973f7 100644 --- a/src/server/scripts/EasternKingdoms/Gnomeregan/gnomeregan.cpp +++ b/src/server/scripts/EasternKingdoms/Gnomeregan/gnomeregan.cpp @@ -54,15 +54,6 @@ enum BlastmasterEmi SAY_BLASTMASTER_17 = 17, SAY_BLASTMASTER_18 = 18, SAY_BLASTMASTER_19 = 19, - SAY_BLASTMASTER_20 = 20, - SAY_BLASTMASTER_21 = 21, - SAY_BLASTMASTER_22 = 22, - SAY_BLASTMASTER_23 = 23, - SAY_BLASTMASTER_24 = 24, - SAY_BLASTMASTER_25 = 25, - SAY_BLASTMASTER_26 = 26, - SAY_BLASTMASTER_27 = 27, - SAY_BLASTMASTER_28 = 28, SAY_GRUBBIS = 0 }; @@ -304,12 +295,12 @@ public: NextStep(25000, false, 18); break; case 13: - Summon(7); + Summon(6); NextStep(25000, false, 19); break; case 14: SetInFace(false); - Talk(SAY_BLASTMASTER_26); + Talk(SAY_BLASTMASTER_17); SetEscortPaused(true); NextStep(5000, false, 20); break; @@ -372,7 +363,7 @@ public: me->SummonCreature(NPC_CAVERNDEEP_AMBUSHER, SpawnPosition[1], TEMPSUMMON_CORPSE_TIMED_DESPAWN, 1800000); me->SummonCreature(NPC_CAVERNDEEP_AMBUSHER, SpawnPosition[2], TEMPSUMMON_CORPSE_TIMED_DESPAWN, 1800000); me->SummonCreature(NPC_CAVERNDEEP_AMBUSHER, SpawnPosition[3], TEMPSUMMON_CORPSE_TIMED_DESPAWN, 1800000); - Talk(SAY_BLASTMASTER_19); + Talk(SAY_BLASTMASTER_7); break; case 4: if (GameObject* go = me->SummonGameObject(183410, -542.199f, -96.854f, -155.790f, 0, 0, 0, 0, 0, 1000)) @@ -382,39 +373,33 @@ public: } break; case 5: - me->SummonCreature(NPC_CAVERNDEEP_AMBUSHER, SpawnPosition[0], TEMPSUMMON_CORPSE_TIMED_DESPAWN, 1800000); - me->SummonCreature(NPC_CAVERNDEEP_AMBUSHER, SpawnPosition[1], TEMPSUMMON_CORPSE_TIMED_DESPAWN, 1800000); - me->SummonCreature(NPC_CAVERNDEEP_AMBUSHER, SpawnPosition[2], TEMPSUMMON_CORPSE_TIMED_DESPAWN, 1800000); - Talk(SAY_BLASTMASTER_15); - break; - case 6: me->SummonCreature(NPC_CAVERNDEEP_AMBUSHER, SpawnPosition[10], TEMPSUMMON_CORPSE_TIMED_DESPAWN, 1800000); me->SummonCreature(NPC_CAVERNDEEP_AMBUSHER, SpawnPosition[11], TEMPSUMMON_CORPSE_TIMED_DESPAWN, 1800000); me->SummonCreature(NPC_CAVERNDEEP_AMBUSHER, SpawnPosition[12], TEMPSUMMON_CORPSE_TIMED_DESPAWN, 1800000); me->SummonCreature(NPC_CAVERNDEEP_AMBUSHER, SpawnPosition[13], TEMPSUMMON_CORPSE_TIMED_DESPAWN, 1800000); me->SummonCreature(NPC_CAVERNDEEP_AMBUSHER, SpawnPosition[14], TEMPSUMMON_CORPSE_TIMED_DESPAWN, 1800000); break; - case 7: + case 6: if (GameObject* go = me->SummonGameObject(183410, -507.820f, -103.333f, -151.353f, 0, 0, 0, 0, 0, 1000)) { GoSummonList.push_back(go->GetGUID()); go->SetFlag(GAMEOBJECT_FLAGS, GO_FLAG_NOT_SELECTABLE); //We can't use it! - Summon(6); + Summon(5); } break; - case 8: + case 7: if (GameObject* go = me->SummonGameObject(183410, -511.829f, -86.249f, -151.431f, 0, 0, 0, 0, 0, 1000)) { GoSummonList.push_back(go->GetGUID()); go->SetFlag(GAMEOBJECT_FLAGS, GO_FLAG_NOT_SELECTABLE); //We can't use it! } break; - case 9: + case 8: if (Creature* grubbis = me->SummonCreature(NPC_GRUBBIS, SpawnPosition[15], TEMPSUMMON_CORPSE_TIMED_DESPAWN, 1800000)) grubbis->AI()->Talk(SAY_GRUBBIS); me->SummonCreature(NPC_CHOMPER, SpawnPosition[16], TEMPSUMMON_CORPSE_TIMED_DESPAWN, 1800000); break; - case 10: + case 9: me->SummonGameObject(GO_RED_ROCKET, SpawnPosition[17].GetPositionX(), SpawnPosition[17].GetPositionY(), SpawnPosition[17].GetPositionZ(), SpawnPosition[17].GetOrientation(), 0, 0, 0, 0, 7200); me->SummonGameObject(GO_RED_ROCKET, SpawnPosition[18].GetPositionX(), SpawnPosition[18].GetPositionY(), SpawnPosition[18].GetPositionZ(), SpawnPosition[18].GetOrientation(), 0, 0, 0, 0, 7200); me->SummonGameObject(GO_RED_ROCKET, SpawnPosition[19].GetPositionX(), SpawnPosition[19].GetPositionY(), SpawnPosition[19].GetPositionZ(), SpawnPosition[19].GetOrientation(), 0, 0, 0, 0, 7200); @@ -475,31 +460,32 @@ public: break; case 10: Summon(4); + Talk(SAY_BLASTMASTER_8); NextStep(0, false); break; case 11: - Talk(SAY_BLASTMASTER_17); + Talk(SAY_BLASTMASTER_9); NextStep(5000, true); break; case 12: - Talk(SAY_BLASTMASTER_18); + Talk(SAY_BLASTMASTER_10); NextStep(5000, true); break; case 13: - Talk(SAY_BLASTMASTER_20); + Talk(SAY_BLASTMASTER_11); CaveDestruction(true); NextStep(8000, true); break; case 14: - Talk(SAY_BLASTMASTER_21); + Talk(SAY_BLASTMASTER_12); NextStep(8500, true); break; case 15: - Talk(SAY_BLASTMASTER_22); + Talk(SAY_BLASTMASTER_13); NextStep(2000, true); break; case 16: - Talk(SAY_BLASTMASTER_23); + Talk(SAY_BLASTMASTER_14); SetInFace(false); if (instance) if (GameObject* go = GameObject::GetGameObject(*me, instance->GetData64(DATA_GO_CAVE_IN_LEFT))) @@ -508,36 +494,36 @@ public: break; case 17: SetEscortPaused(false); - Talk(SAY_BLASTMASTER_24); - Summon(6); + Talk(SAY_BLASTMASTER_15); + Summon(5); NextStep(0, false); break; case 18: - Summon(7); + Summon(6); NextStep(0, false); break; case 19: SetInFace(false); - Summon(8); - Talk(SAY_BLASTMASTER_25); + Summon(7); + Talk(SAY_BLASTMASTER_16); NextStep(0, false); break; case 20: - Talk(SAY_BLASTMASTER_27); + Talk(SAY_BLASTMASTER_18); NextStep(2000, true); break; case 21: - Summon(9); + Summon(8); NextStep(0, false); break; case 22: CaveDestruction(false); - Talk(SAY_BLASTMASTER_20); - NextStep(2000, true); + Talk(SAY_BLASTMASTER_11); + NextStep(3000, true); break; case 23: - Summon(10); - Talk(SAY_BLASTMASTER_28); + Summon(9); + Talk(SAY_BLASTMASTER_19); NextStep(0, false); break; } diff --git a/src/server/scripts/EasternKingdoms/Karazhan/boss_curator.cpp b/src/server/scripts/EasternKingdoms/Karazhan/boss_curator.cpp index bf27cad44ef..2c7e1b9c48a 100644 --- a/src/server/scripts/EasternKingdoms/Karazhan/boss_curator.cpp +++ b/src/server/scripts/EasternKingdoms/Karazhan/boss_curator.cpp @@ -187,13 +187,11 @@ public: if (Unit* target = SelectTarget(SELECT_TARGET_TOPAGGRO, 1)) DoCast(target, SPELL_HATEFUL_BOLT); - } else HatefulBoltTimer -= diff; DoMeleeAttackIfReady(); } }; - }; void AddSC_boss_curator() diff --git a/src/server/scripts/EasternKingdoms/Karazhan/boss_maiden_of_virtue.cpp b/src/server/scripts/EasternKingdoms/Karazhan/boss_maiden_of_virtue.cpp index 8921867be21..5f974a890bf 100644 --- a/src/server/scripts/EasternKingdoms/Karazhan/boss_maiden_of_virtue.cpp +++ b/src/server/scripts/EasternKingdoms/Karazhan/boss_maiden_of_virtue.cpp @@ -132,9 +132,7 @@ public: DoMeleeAttackIfReady(); } - }; - }; void AddSC_boss_maiden_of_virtue() diff --git a/src/server/scripts/EasternKingdoms/Karazhan/boss_midnight.cpp b/src/server/scripts/EasternKingdoms/Karazhan/boss_midnight.cpp index ea9cfe5c3c1..7eeced1d970 100644 --- a/src/server/scripts/EasternKingdoms/Karazhan/boss_midnight.cpp +++ b/src/server/scripts/EasternKingdoms/Karazhan/boss_midnight.cpp @@ -111,7 +111,6 @@ public: DoScriptText(SAY_DISARMED, me); } }; - }; class boss_midnight : public CreatureScript @@ -232,7 +231,6 @@ public: CAST_AI(boss_attumen::boss_attumenAI, pAttumen->AI())->Midnight = value; } }; - }; void boss_attumen::boss_attumenAI::UpdateAI(const uint32 diff) @@ -284,9 +282,9 @@ void boss_attumen::boss_attumenAI::UpdateAI(const uint32 diff) if (ChargeTimer <= diff) { Unit* target = NULL; - std::list<HostileReference*> t_list = me->getThreatManager().getThreatList(); + ThreatContainer::StorageType const &t_list = me->getThreatManager().getThreatList(); std::vector<Unit*> target_list; - for (std::list<HostileReference*>::const_iterator itr = t_list.begin(); itr!= t_list.end(); ++itr) + for (ThreatContainer::StorageType::const_iterator itr = t_list.begin(); itr != t_list.end(); ++itr) { target = Unit::GetUnit(*me, (*itr)->getUnitGuid()); if (target && !target->IsWithinDist(me, ATTACK_DISTANCE, false)) diff --git a/src/server/scripts/EasternKingdoms/Karazhan/boss_moroes.cpp b/src/server/scripts/EasternKingdoms/Karazhan/boss_moroes.cpp index 533a1aac2f0..99f2cb51c85 100644 --- a/src/server/scripts/EasternKingdoms/Karazhan/boss_moroes.cpp +++ b/src/server/scripts/EasternKingdoms/Karazhan/boss_moroes.cpp @@ -307,7 +307,6 @@ public: DoMeleeAttackIfReady(); } }; - }; struct boss_moroes_guestAI : public ScriptedAI @@ -452,7 +451,6 @@ public: } else ShadowWordPain_Timer -= diff; } }; - }; class boss_baron_rafe_dreuger : public CreatureScript @@ -510,7 +508,6 @@ public: } else HammerOfJustice_Timer -= diff; } }; - }; class boss_lady_catriona_von_indi : public CreatureScript @@ -581,7 +578,6 @@ public: } else DispelMagic_Timer -= diff; } }; - }; class boss_lady_keira_berrybuck : public CreatureScript @@ -656,7 +652,6 @@ public: } else Cleanse_Timer -= diff; } }; - }; class boss_lord_robin_daris : public CreatureScript @@ -713,7 +708,6 @@ public: } else WhirlWind_Timer -= diff; } }; - }; class boss_lord_crispin_ference : public CreatureScript @@ -778,7 +772,6 @@ public: } else ShieldWall_Timer -= diff; } }; - }; void AddSC_boss_moroes() diff --git a/src/server/scripts/EasternKingdoms/Karazhan/boss_netherspite.cpp b/src/server/scripts/EasternKingdoms/Karazhan/boss_netherspite.cpp index 60e1a5ebc4c..c6587c3cd8a 100644 --- a/src/server/scripts/EasternKingdoms/Karazhan/boss_netherspite.cpp +++ b/src/server/scripts/EasternKingdoms/Karazhan/boss_netherspite.cpp @@ -333,7 +333,6 @@ public: DoMeleeAttackIfReady(); } }; - }; void AddSC_boss_netherspite() diff --git a/src/server/scripts/EasternKingdoms/Karazhan/boss_nightbane.cpp b/src/server/scripts/EasternKingdoms/Karazhan/boss_nightbane.cpp index e2420749a4c..690822203b5 100644 --- a/src/server/scripts/EasternKingdoms/Karazhan/boss_nightbane.cpp +++ b/src/server/scripts/EasternKingdoms/Karazhan/boss_nightbane.cpp @@ -413,7 +413,6 @@ public: } } }; - }; void AddSC_boss_nightbane() diff --git a/src/server/scripts/EasternKingdoms/Karazhan/boss_prince_malchezaar.cpp b/src/server/scripts/EasternKingdoms/Karazhan/boss_prince_malchezaar.cpp index f4195620dda..d1c4790d705 100644 --- a/src/server/scripts/EasternKingdoms/Karazhan/boss_prince_malchezaar.cpp +++ b/src/server/scripts/EasternKingdoms/Karazhan/boss_prince_malchezaar.cpp @@ -169,7 +169,6 @@ public: void Cleanup(); }; - }; class boss_malchezaar : public CreatureScript @@ -314,14 +313,14 @@ public: if (!info) return; - std::list<HostileReference*> t_list = me->getThreatManager().getThreatList(); + ThreatContainer::StorageType const &t_list = me->getThreatManager().getThreatList(); std::vector<Unit*> targets; if (t_list.empty()) return; //begin + 1, so we don't target the one with the highest threat - std::list<HostileReference*>::const_iterator itr = t_list.begin(); + ThreatContainer::StorageType::const_iterator itr = t_list.begin(); std::advance(itr, 1); for (; itr != t_list.end(); ++itr) //store the threat list in a different container if (Unit* target = Unit::GetUnit(*me, (*itr)->getUnitGuid())) @@ -483,14 +482,12 @@ public: { DoCast(me->getVictim(), SPELL_SUNDER_ARMOR); SunderArmorTimer = urand(10000, 18000); - } else SunderArmorTimer -= diff; if (Cleave_Timer <= diff) { DoCast(me->getVictim(), SPELL_CLEAVE); Cleave_Timer = urand(6000, 12000); - } else Cleave_Timer -= diff; } else @@ -602,15 +599,14 @@ public: positions.push_back(point); } }; - }; void netherspite_infernal::netherspite_infernalAI::Cleanup() { - Unit* pMalchezaar = Unit::GetUnit(*me, malchezaar); + Creature *pMalchezaar = Unit::GetCreature(*me, malchezaar); if (pMalchezaar && pMalchezaar->isAlive()) - CAST_AI(boss_malchezaar::boss_malchezaarAI, CAST_CRE(pMalchezaar)->AI())->Cleanup(me, point); + CAST_AI(boss_malchezaar::boss_malchezaarAI, pMalchezaar->AI())->Cleanup(me, point); } void AddSC_boss_malchezaar() diff --git a/src/server/scripts/EasternKingdoms/Karazhan/boss_shade_of_aran.cpp b/src/server/scripts/EasternKingdoms/Karazhan/boss_shade_of_aran.cpp index 7dd4e731a18..25fafdfcd0d 100644 --- a/src/server/scripts/EasternKingdoms/Karazhan/boss_shade_of_aran.cpp +++ b/src/server/scripts/EasternKingdoms/Karazhan/boss_shade_of_aran.cpp @@ -187,13 +187,13 @@ public: void FlameWreathEffect() { std::vector<Unit*> targets; - std::list<HostileReference*> t_list = me->getThreatManager().getThreatList(); + ThreatContainer::StorageType const &t_list = me->getThreatManager().getThreatList(); if (t_list.empty()) return; //store the threat list in a different container - for (std::list<HostileReference*>::const_iterator itr = t_list.begin(); itr!= t_list.end(); ++itr) + for (ThreatContainer::StorageType::const_iterator itr = t_list.begin(); itr!= t_list.end(); ++itr) { Unit* target = Unit::GetUnit(*me, (*itr)->getUnitGuid()); //only on alive players @@ -508,7 +508,6 @@ public: } } }; - }; class mob_aran_elemental : public CreatureScript @@ -546,7 +545,6 @@ public: } else CastTimer -= diff; } }; - }; void AddSC_boss_shade_of_aran() diff --git a/src/server/scripts/EasternKingdoms/Karazhan/boss_terestian_illhoof.cpp b/src/server/scripts/EasternKingdoms/Karazhan/boss_terestian_illhoof.cpp index 44cd7e0faea..688a678060f 100644 --- a/src/server/scripts/EasternKingdoms/Karazhan/boss_terestian_illhoof.cpp +++ b/src/server/scripts/EasternKingdoms/Karazhan/boss_terestian_illhoof.cpp @@ -127,7 +127,6 @@ public: DoMeleeAttackIfReady(); } }; - }; class mob_demon_chain : public CreatureScript @@ -165,7 +164,6 @@ public: } } }; - }; class mob_fiendish_portal : public CreatureScript @@ -200,7 +198,6 @@ public: summons.DespawnAll(); } }; - }; #define SPELL_FIREBOLT 30050 // Blasts a target for 181-209 Fire damage. @@ -245,7 +242,6 @@ public: DoMeleeAttackIfReady(); } }; - }; class boss_terestian_illhoof : public CreatureScript @@ -422,7 +418,6 @@ public: DoMeleeAttackIfReady(); } }; - }; void AddSC_boss_terestian_illhoof() diff --git a/src/server/scripts/EasternKingdoms/Karazhan/bosses_opera.cpp b/src/server/scripts/EasternKingdoms/Karazhan/bosses_opera.cpp index 30d33dc65cf..a4f4f603206 100644 --- a/src/server/scripts/EasternKingdoms/Karazhan/bosses_opera.cpp +++ b/src/server/scripts/EasternKingdoms/Karazhan/bosses_opera.cpp @@ -216,7 +216,6 @@ public: DoMeleeAttackIfReady(); } }; - }; class mob_tito : public CreatureScript @@ -271,7 +270,6 @@ public: DoMeleeAttackIfReady(); } }; - }; void boss_dorothee::boss_dorotheeAI::SummonTito() @@ -398,7 +396,6 @@ public: DoMeleeAttackIfReady(); } }; - }; class boss_tinhead : public CreatureScript @@ -508,7 +505,6 @@ public: DoMeleeAttackIfReady(); } }; - }; class boss_roar : public CreatureScript @@ -617,7 +613,6 @@ public: DoMeleeAttackIfReady(); } }; - }; class boss_crone : public CreatureScript @@ -699,7 +694,6 @@ public: DoMeleeAttackIfReady(); } }; - }; class mob_cyclone : public CreatureScript @@ -743,7 +737,6 @@ public: } else MoveTimer -= diff; } }; - }; /**************************************/ @@ -792,7 +785,6 @@ public: return true; } - }; class boss_bigbadwolf : public CreatureScript @@ -915,10 +907,8 @@ public: DoCast(me->getVictim(), SPELL_WIDE_SWIPE); SwipeTimer = urand(25000, 30000); } else SwipeTimer -= diff; - } }; - }; /**********************************************/ @@ -977,7 +967,7 @@ void PretendToDie(Creature* creature) creature->GetMotionMaster()->MovementExpired(false); creature->GetMotionMaster()->MoveIdle(); creature->SetStandState(UNIT_STAND_STATE_DEAD); -}; +} void Resurrect(Creature* target) { @@ -992,7 +982,7 @@ void Resurrect(Creature* target) } else target->GetMotionMaster()->Initialize(); -}; +} class boss_julianne : public CreatureScript { @@ -1114,7 +1104,6 @@ public: void UpdateAI(const uint32 diff); }; - }; class boss_romulo : public CreatureScript @@ -1321,7 +1310,6 @@ public: DoMeleeAttackIfReady(); } }; - }; void boss_julianne::boss_julianneAI::UpdateAI(const uint32 diff) diff --git a/src/server/scripts/EasternKingdoms/Karazhan/instance_karazhan.cpp b/src/server/scripts/EasternKingdoms/Karazhan/instance_karazhan.cpp index 05d6ecf1478..2ecd98cbc4c 100644 --- a/src/server/scripts/EasternKingdoms/Karazhan/instance_karazhan.cpp +++ b/src/server/scripts/EasternKingdoms/Karazhan/instance_karazhan.cpp @@ -288,7 +288,7 @@ public: return 0; } - void Load(const char* chrIn) + void Load(char const* chrIn) { if (!chrIn) { @@ -308,7 +308,6 @@ public: OUT_LOAD_INST_DATA_COMPLETE; } }; - }; void AddSC_instance_karazhan() diff --git a/src/server/scripts/EasternKingdoms/Karazhan/karazhan.cpp b/src/server/scripts/EasternKingdoms/Karazhan/karazhan.cpp index b84fc15d664..3bdfeab30da 100644 --- a/src/server/scripts/EasternKingdoms/Karazhan/karazhan.cpp +++ b/src/server/scripts/EasternKingdoms/Karazhan/karazhan.cpp @@ -321,7 +321,6 @@ public: WipeTimer = 15000; } else WipeTimer -= diff; } - } } }; @@ -344,17 +343,17 @@ public: case GOSSIP_ACTION_INFO_DEF+3: player->CLOSE_GOSSIP_MENU(); pBarnesAI->m_uiEventId = EVENT_OZ; - sLog->outInfo(LOG_FILTER_TSCR, "TSCR: player (GUID " UI64FMTD ") manually set Opera event to EVENT_OZ", player->GetGUID()); + sLog->outInfo(LOG_FILTER_TSCR, "player (GUID " UI64FMTD ") manually set Opera event to EVENT_OZ", player->GetGUID()); break; case GOSSIP_ACTION_INFO_DEF+4: player->CLOSE_GOSSIP_MENU(); pBarnesAI->m_uiEventId = EVENT_HOOD; - sLog->outInfo(LOG_FILTER_TSCR, "TSCR: player (GUID " UI64FMTD ") manually set Opera event to EVENT_HOOD", player->GetGUID()); + sLog->outInfo(LOG_FILTER_TSCR, "player (GUID " UI64FMTD ") manually set Opera event to EVENT_HOOD", player->GetGUID()); break; case GOSSIP_ACTION_INFO_DEF+5: player->CLOSE_GOSSIP_MENU(); pBarnesAI->m_uiEventId = EVENT_RAJ; - sLog->outInfo(LOG_FILTER_TSCR, "TSCR: player (GUID " UI64FMTD ") manually set Opera event to EVENT_RAJ", player->GetGUID()); + sLog->outInfo(LOG_FILTER_TSCR, "player (GUID " UI64FMTD ") manually set Opera event to EVENT_RAJ", player->GetGUID()); break; } @@ -397,7 +396,6 @@ public: { return new npc_barnesAI(creature); } - }; /*### @@ -438,7 +436,6 @@ public: player->SEND_GOSSIP_MENU(player->GetGossipTextId(creature), creature->GetGUID()); return true; } - }; /*### @@ -538,7 +535,7 @@ public: uint32 NextStep(uint32 Step) { - Unit* arca = Unit::GetUnit(*me, ArcanagosGUID); + Creature* arca = Unit::GetCreature(*me, ArcanagosGUID); Map* map = me->GetMap(); switch (Step) { @@ -548,21 +545,21 @@ public: return 10000; case 2: if (arca) - CAST_CRE(arca)->MonsterYell(SAY_DIALOG_ARCANAGOS_2, LANG_UNIVERSAL, 0); + arca->MonsterYell(SAY_DIALOG_ARCANAGOS_2, LANG_UNIVERSAL, 0); return 20000; case 3: me->MonsterYell(SAY_DIALOG_MEDIVH_3, LANG_UNIVERSAL, 0); return 10000; case 4: if (arca) - CAST_CRE(arca)->MonsterYell(SAY_DIALOG_ARCANAGOS_4, LANG_UNIVERSAL, 0); + arca->MonsterYell(SAY_DIALOG_ARCANAGOS_4, LANG_UNIVERSAL, 0); return 20000; case 5: me->MonsterYell(SAY_DIALOG_MEDIVH_5, LANG_UNIVERSAL, 0); return 20000; case 6: if (arca) - CAST_CRE(arca)->MonsterYell(SAY_DIALOG_ARCANAGOS_6, LANG_UNIVERSAL, 0); + arca->MonsterYell(SAY_DIALOG_ARCANAGOS_6, LANG_UNIVERSAL, 0); return 10000; case 7: FireArcanagosTimer = 500; @@ -580,7 +577,7 @@ public: return 1000; case 11: if (arca) - CAST_CRE(arca)->MonsterYell(SAY_DIALOG_ARCANAGOS_8, LANG_UNIVERSAL, 0); + arca->MonsterYell(SAY_DIALOG_ARCANAGOS_8, LANG_UNIVERSAL, 0); return 5000; case 12: arca->GetMotionMaster()->MovePoint(0, -11010.82f, -1761.18f, 156.47f); @@ -613,12 +610,10 @@ public: return 5000; default : return 9999999; } - } void UpdateAI(const uint32 diff) { - if (YellTimer <= diff) { if (EventStarted) @@ -645,7 +640,6 @@ public: } } }; - }; void AddSC_karazhan() diff --git a/src/server/scripts/EasternKingdoms/Karazhan/karazhan.h b/src/server/scripts/EasternKingdoms/Karazhan/karazhan.h index e1817034189..c8a1aa55c7e 100644 --- a/src/server/scripts/EasternKingdoms/Karazhan/karazhan.h +++ b/src/server/scripts/EasternKingdoms/Karazhan/karazhan.h @@ -64,4 +64,3 @@ enum OperaEvents #define ERROR_INST_DATA(a) sLog->outError(LOG_FILTER_TSCR, "Instance Data for Karazhan not set properly. Encounter for Creature Entry %u may not work properly.", a->GetEntry()); #endif - diff --git a/src/server/scripts/EasternKingdoms/MagistersTerrace/boss_felblood_kaelthas.cpp b/src/server/scripts/EasternKingdoms/MagistersTerrace/boss_felblood_kaelthas.cpp index bd79cbba628..e21a84d9499 100644 --- a/src/server/scripts/EasternKingdoms/MagistersTerrace/boss_felblood_kaelthas.cpp +++ b/src/server/scripts/EasternKingdoms/MagistersTerrace/boss_felblood_kaelthas.cpp @@ -189,20 +189,20 @@ public: ScriptedAI::MoveInLineOfSight(who); } - void SetThreatList(Creature* SummonedUnit) + void SetThreatList(Creature* summonedUnit) { - if (!SummonedUnit) + if (!summonedUnit) return; - std::list<HostileReference*>& m_threatlist = me->getThreatManager().getThreatList(); - std::list<HostileReference*>::const_iterator i = m_threatlist.begin(); - for (i = m_threatlist.begin(); i != m_threatlist.end(); ++i) + ThreatContainer::StorageType const &threatlist = me->getThreatManager().getThreatList(); + ThreatContainer::StorageType::const_iterator i = threatlist.begin(); + for (i = threatlist.begin(); i != threatlist.end(); ++i) { Unit* unit = Unit::GetUnit(*me, (*i)->getUnitGuid()); if (unit && unit->isAlive()) { float threat = me->getThreatManager().getThreat(unit); - SummonedUnit->AddThreat(unit, threat); + summonedUnit->AddThreat(unit, threat); } } } @@ -212,9 +212,9 @@ public: float x = KaelLocations[0][0]; float y = KaelLocations[0][1]; me->SetPosition(x, y, LOCATION_Z, 0.0f); - //me->SendMonsterMove(x, y, LOCATION_Z, 0, 0, 0); // causes some issues... - std::list<HostileReference*>::const_iterator i = me->getThreatManager().getThreatList().begin(); - for (i = me->getThreatManager().getThreatList().begin(); i!= me->getThreatManager().getThreatList().end(); ++i) + ThreatContainer::StorageType threatlist = me->getThreatManager().getThreatList(); + ThreatContainer::StorageType::const_iterator i = threatlist.begin(); + for (i = threatlist.begin(); i != threatlist.end(); ++i) { Unit* unit = Unit::GetUnit(*me, (*i)->getUnitGuid()); if (unit && (unit->GetTypeId() == TYPEID_PLAYER)) @@ -225,8 +225,9 @@ public: void CastGravityLapseKnockUp() { - std::list<HostileReference*>::const_iterator i = me->getThreatManager().getThreatList().begin(); - for (i = me->getThreatManager().getThreatList().begin(); i!= me->getThreatManager().getThreatList().end(); ++i) + ThreatContainer::StorageType threatlist = me->getThreatManager().getThreatList(); + ThreatContainer::StorageType::const_iterator i = threatlist.begin(); + for (i = threatlist.begin(); i != threatlist.end(); ++i) { Unit* unit = Unit::GetUnit(*me, (*i)->getUnitGuid()); if (unit && (unit->GetTypeId() == TYPEID_PLAYER)) @@ -237,8 +238,9 @@ public: void CastGravityLapseFly() // Use Fly Packet hack for now as players can't cast "fly" spells unless in map 530. Has to be done a while after they get knocked into the air... { - std::list<HostileReference*>::const_iterator i = me->getThreatManager().getThreatList().begin(); - for (i = me->getThreatManager().getThreatList().begin(); i!= me->getThreatManager().getThreatList().end(); ++i) + ThreatContainer::StorageType threatlist = me->getThreatManager().getThreatList(); + ThreatContainer::StorageType::const_iterator i = threatlist.begin(); + for (i = threatlist.begin(); i != threatlist.end(); ++i) { Unit* unit = Unit::GetUnit(*me, (*i)->getUnitGuid()); if (unit && (unit->GetTypeId() == TYPEID_PLAYER)) @@ -257,8 +259,9 @@ public: void RemoveGravityLapse() { - std::list<HostileReference*>::const_iterator i = me->getThreatManager().getThreatList().begin(); - for (i = me->getThreatManager().getThreatList().begin(); i!= me->getThreatManager().getThreatList().end(); ++i) + ThreatContainer::StorageType threatlist = me->getThreatManager().getThreatList(); + ThreatContainer::StorageType::const_iterator i = threatlist.begin(); + for (i = threatlist.begin(); i != threatlist.end(); ++i) { Unit* unit = Unit::GetUnit(*me, (*i)->getUnitGuid()); if (unit && (unit->GetTypeId() == TYPEID_PLAYER)) @@ -306,7 +309,6 @@ public: if (PhoenixTimer <= diff) { - Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 1); uint8 random = urand(1, 2); @@ -410,7 +412,6 @@ public: Orb->AddThreat(target, 1000000.0f); Orb->AI()->AttackStart(target); } - } DoCast(me, SPELL_GRAVITY_LAPSE_CHANNEL); @@ -431,7 +432,6 @@ public: } } }; - }; class mob_felkael_flamestrike : public CreatureScript @@ -473,7 +473,6 @@ public: } else FlameStrikeTimer -= diff; } }; - }; class mob_felkael_phoenix : public CreatureScript @@ -522,7 +521,6 @@ public: { damage = 0; return; - } //Don't really die in all phases of Kael'Thas if (instance && instance->GetData(DATA_KAELTHAS_EVENT) == 0) @@ -544,9 +542,7 @@ public: me->GetMotionMaster()->Clear(); me->GetMotionMaster()->MoveIdle(); me->SetStandState(UNIT_STAND_STATE_DEAD); - } - } void JustDied(Unit* /*killer*/) @@ -556,7 +552,6 @@ public: void UpdateAI(const uint32 diff) { - //If we are fake death, we cast revbirth and after that we kill the phoenix to spawn the egg. if (FakeDeath) { @@ -568,7 +563,6 @@ public: if (Rebirth) { - if (Death_Timer <= diff) { me->SummonCreature(CREATURE_PHOENIX_EGG, 0.0f, 0.0f, 0.0f, 0.0f, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 45000); @@ -576,7 +570,6 @@ public: Rebirth = false; } else Death_Timer -= diff; } - } if (!UpdateVictim()) @@ -593,7 +586,6 @@ public: DoMeleeAttackIfReady(); } }; - }; class mob_felkael_phoenix_egg : public CreatureScript @@ -627,10 +619,8 @@ public: me->SummonCreature(CREATURE_PHOENIX, 0.0f, 0.0f, 0.0f, 0.0f, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 60000); me->Kill(me); } else HatchTimer -= diff; - } }; - }; class mob_arcane_sphere : public CreatureScript @@ -687,7 +677,6 @@ public: } else ChangeTargetTimer -= diff; } }; - }; void AddSC_boss_felblood_kaelthas() diff --git a/src/server/scripts/EasternKingdoms/MagistersTerrace/boss_priestess_delrissa.cpp b/src/server/scripts/EasternKingdoms/MagistersTerrace/boss_priestess_delrissa.cpp index 7ce9b08845f..2af417381a5 100644 --- a/src/server/scripts/EasternKingdoms/MagistersTerrace/boss_priestess_delrissa.cpp +++ b/src/server/scripts/EasternKingdoms/MagistersTerrace/boss_priestess_delrissa.cpp @@ -331,7 +331,6 @@ public: DoMeleeAttackIfReady(); } }; - }; enum eHealingPotion @@ -574,7 +573,6 @@ public: DoMeleeAttackIfReady(); } }; - }; enum eWarlockSpells @@ -671,7 +669,6 @@ public: DoMeleeAttackIfReady(); } }; - }; enum eKickDown @@ -728,7 +725,6 @@ public: DoMeleeAttackIfReady(); } }; - }; enum eMageSpells @@ -835,8 +831,8 @@ public: if (Blink_Timer <= diff) { bool InMeleeRange = false; - std::list<HostileReference*>& t_list = me->getThreatManager().getThreatList(); - for (std::list<HostileReference*>::const_iterator itr = t_list.begin(); itr!= t_list.end(); ++itr) + ThreatContainer::StorageType const &t_list = me->getThreatManager().getThreatList(); + for (ThreatContainer::StorageType::const_iterator itr = t_list.begin(); itr!= t_list.end(); ++itr) { if (Unit* target = Unit::GetUnit(*me, (*itr)->getUnitGuid())) { @@ -859,7 +855,6 @@ public: DoMeleeAttackIfReady(); } }; - }; enum eWarriorSpells @@ -922,8 +917,8 @@ public: if (Intercept_Stun_Timer <= diff) { bool InMeleeRange = false; - std::list<HostileReference*>& t_list = me->getThreatManager().getThreatList(); - for (std::list<HostileReference*>::const_iterator itr = t_list.begin(); itr!= t_list.end(); ++itr) + ThreatContainer::StorageType const &t_list = me->getThreatManager().getThreatList(); + for (ThreatContainer::StorageType::const_iterator itr = t_list.begin(); itr!= t_list.end(); ++itr) { if (Unit* target = Unit::GetUnit(*me, (*itr)->getUnitGuid())) { @@ -979,7 +974,6 @@ public: DoMeleeAttackIfReady(); } }; - }; enum eHunterSpells @@ -1103,7 +1097,6 @@ public: } } }; - }; enum Spells @@ -1203,7 +1196,6 @@ public: DoMeleeAttackIfReady(); } }; - }; enum eEngineerSpells @@ -1298,7 +1290,6 @@ public: DoMeleeAttackIfReady(); } }; - }; /* diff --git a/src/server/scripts/EasternKingdoms/MagistersTerrace/boss_selin_fireheart.cpp b/src/server/scripts/EasternKingdoms/MagistersTerrace/boss_selin_fireheart.cpp index 82ad3ee2630..430bbb79bde 100644 --- a/src/server/scripts/EasternKingdoms/MagistersTerrace/boss_selin_fireheart.cpp +++ b/src/server/scripts/EasternKingdoms/MagistersTerrace/boss_selin_fireheart.cpp @@ -105,20 +105,20 @@ public: for (std::list<uint64>::const_iterator itr = Crystals.begin(); itr != Crystals.end(); ++itr) { //Unit* unit = Unit::GetUnit(*me, FelCrystals[i]); - Unit* unit = Unit::GetUnit(*me, *itr); - if (unit) + if (Creature *creature = Unit::GetCreature(*me, *itr)) { - if (!unit->isAlive()) - CAST_CRE(unit)->Respawn(); // Let the core handle setting death state, etc. + if (!creature->isAlive()) + creature->Respawn(); // Let the core handle setting death state, etc. // Only need to set unselectable flag. You can't attack unselectable units so non_attackable flag is not necessary here. - unit->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); + creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); } } instance->HandleGameObject(instance->GetData64(DATA_SELIN_ENCOUNTER_DOOR), true); // Open the big encounter door. Close it in Aggro and open it only in JustDied(and here) - // Small door opened after event are expected to be closed by default + // Small door opened after event are expected to be closed by default + // Set Inst data for encounter instance->SetData(DATA_SELIN_EVENT, NOT_STARTED); } else sLog->outError(LOG_FILTER_TSCR, ERROR_INST_DATA); @@ -291,7 +291,6 @@ public: DrainCrystalTimer = urand(20000, 25000); } else DrainCrystalTimer -= diff; } - }else { if (IsDraining) @@ -319,7 +318,6 @@ public: DoMeleeAttackIfReady(); // No need to check if we are draining crystal here, as the spell has a stun. } }; - }; class mob_fel_crystal : public CreatureScript @@ -365,7 +363,6 @@ public: } else sLog->outError(LOG_FILTER_TSCR, ERROR_INST_DATA); } }; - }; void AddSC_boss_selin_fireheart() diff --git a/src/server/scripts/EasternKingdoms/MagistersTerrace/boss_vexallus.cpp b/src/server/scripts/EasternKingdoms/MagistersTerrace/boss_vexallus.cpp index b5cf443c5a5..34682683ee3 100644 --- a/src/server/scripts/EasternKingdoms/MagistersTerrace/boss_vexallus.cpp +++ b/src/server/scripts/EasternKingdoms/MagistersTerrace/boss_vexallus.cpp @@ -192,7 +192,6 @@ public: DoMeleeAttackIfReady(); } }; - }; class mob_pure_energy : public CreatureScript @@ -224,7 +223,6 @@ public: void MoveInLineOfSight(Unit* /*who*/) {} void AttackStart(Unit* /*who*/) {} }; - }; void AddSC_boss_vexallus() diff --git a/src/server/scripts/EasternKingdoms/MagistersTerrace/instance_magisters_terrace.cpp b/src/server/scripts/EasternKingdoms/MagistersTerrace/instance_magisters_terrace.cpp index cd2874f7253..da8b24c3985 100644 --- a/src/server/scripts/EasternKingdoms/MagistersTerrace/instance_magisters_terrace.cpp +++ b/src/server/scripts/EasternKingdoms/MagistersTerrace/instance_magisters_terrace.cpp @@ -262,7 +262,6 @@ public: return 0; } }; - }; void AddSC_instance_magisters_terrace() diff --git a/src/server/scripts/EasternKingdoms/MagistersTerrace/magisters_terrace.cpp b/src/server/scripts/EasternKingdoms/MagistersTerrace/magisters_terrace.cpp index 69e0e5bff40..64b6c8d75b2 100644 --- a/src/server/scripts/EasternKingdoms/MagistersTerrace/magisters_terrace.cpp +++ b/src/server/scripts/EasternKingdoms/MagistersTerrace/magisters_terrace.cpp @@ -140,14 +140,14 @@ public: if (lList.isEmpty()) return; - SpellInfo const* pSpell = sSpellMgr->GetSpellInfo(SPELL_ORB_KILL_CREDIT); + SpellInfo const* spell = sSpellMgr->GetSpellInfo(SPELL_ORB_KILL_CREDIT); for (Map::PlayerList::const_iterator i = lList.begin(); i != lList.end(); ++i) { if (Player* player = i->getSource()) { - if (pSpell && pSpell->Effects[0].MiscValue) - player->KilledMonsterCredit(pSpell->Effects[0].MiscValue, 0); + if (spell && spell->Effects[0].MiscValue) + player->KilledMonsterCredit(spell->Effects[0].MiscValue, 0); } } } @@ -170,7 +170,6 @@ public: } } }; - }; void AddSC_magisters_terrace() diff --git a/src/server/scripts/EasternKingdoms/MagistersTerrace/magisters_terrace.h b/src/server/scripts/EasternKingdoms/MagistersTerrace/magisters_terrace.h index 78aa14b9102..660e58d325a 100644 --- a/src/server/scripts/EasternKingdoms/MagistersTerrace/magisters_terrace.h +++ b/src/server/scripts/EasternKingdoms/MagistersTerrace/magisters_terrace.h @@ -20,7 +20,6 @@ #define DEF_MAGISTERS_TERRACE_H #define ERROR_INST_DATA "TSCR Error: Instance Data not set properly for Magister's Terrace instance (map 585). Encounters will be buggy." -#endif enum Data { @@ -47,3 +46,5 @@ enum Data DATA_ESCAPE_ORB = 16 }; + +#endif diff --git a/src/server/scripts/EasternKingdoms/ScarletMonastery/boss_headless_horseman.cpp b/src/server/scripts/EasternKingdoms/ScarletMonastery/boss_headless_horseman.cpp index ca91fb920b1..5e7fa111a7b 100644 --- a/src/server/scripts/EasternKingdoms/ScarletMonastery/boss_headless_horseman.cpp +++ b/src/server/scripts/EasternKingdoms/ScarletMonastery/boss_headless_horseman.cpp @@ -46,7 +46,7 @@ uint32 RandomLaugh[] = {11965, 11975, 11976}; enum Entry { HH_MOUNTED = 23682, - HH_DISMOUNTED = 23800, // unhorsed?? wtf type of engrish was that? + HH_DISMOUNTED = 23800, HEAD = 23775, PULSING_PUMPKIN = 23694, PUMPKIN_FIEND = 23545, @@ -127,7 +127,7 @@ static Locations Spawn[]= {1765.28f, 1347.46f, 17.55f} //spawn point for smoke }; -static const char* Text[]= +static char const* Text[]= { "Horseman rise...", "Your time is nigh...", @@ -592,8 +592,8 @@ public: caster->GetMotionMaster()->Clear(false); caster->GetMotionMaster()->MoveFollow(me, 6, float(urand(0, 5))); //DoResetThreat();//not sure if need - std::list<HostileReference*>::const_iterator itr; - for (itr = caster->getThreatManager().getThreatList().begin(); itr != caster->getThreatManager().getThreatList().end(); ++itr) + ThreatContainer::StorageType threatlist = caster->getThreatManager().getThreatList(); + for (ThreatContainer::StorageType::const_iterator itr = threatlist.begin(); itr != threatlist.end(); ++itr) { Unit* unit = Unit::GetUnit(*me, (*itr)->getUnitGuid()); if (unit && unit->isAlive() && unit != caster) diff --git a/src/server/scripts/EasternKingdoms/ScarletMonastery/boss_herod.cpp b/src/server/scripts/EasternKingdoms/ScarletMonastery/boss_herod.cpp index 59244585ecf..dbbbb7fb0dd 100644 --- a/src/server/scripts/EasternKingdoms/ScarletMonastery/boss_herod.cpp +++ b/src/server/scripts/EasternKingdoms/ScarletMonastery/boss_herod.cpp @@ -153,12 +153,7 @@ public: uint32 Start_Timer; void Reset() {} - - void WaypointReached(uint32 /*waypointId*/) - { - - } - + void WaypointReached(uint32 /*waypointId*/) {} void EnterCombat(Unit* /*who*/) {} void UpdateAI(const uint32 diff) diff --git a/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_brutallus.cpp b/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_brutallus.cpp index e40a48d0251..c763cb69dec 100644 --- a/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_brutallus.cpp +++ b/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_brutallus.cpp @@ -344,7 +344,6 @@ public: DoMeleeAttackIfReady(); } }; - }; void AddSC_boss_brutallus() diff --git a/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_eredar_twins.cpp b/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_eredar_twins.cpp index e7b0e86285e..34548ec9116 100644 --- a/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_eredar_twins.cpp +++ b/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_eredar_twins.cpp @@ -121,13 +121,12 @@ public: if (instance) { - Unit* Temp = Unit::GetUnit(*me, instance->GetData64(DATA_ALYTHESS)); - if (Temp) + if (Creature *temp = Unit::GetCreature(*me, instance->GetData64(DATA_ALYTHESS))) { - if (Temp->isDead()) - CAST_CRE(Temp)->Respawn(); - else if (Temp->getVictim()) - me->getThreatManager().addThreat(Temp->getVictim(), 0.0f); + if (temp->isDead()) + temp->Respawn(); + else if (temp->getVictim()) + me->getThreatManager().addThreat(temp->getVictim(), 0.0f); } } @@ -153,9 +152,9 @@ public: if (instance) { - Unit* Temp = Unit::GetUnit(*me, instance->GetData64(DATA_ALYTHESS)); - if (Temp && Temp->isAlive() && !(Temp->getVictim())) - CAST_CRE(Temp)->AI()->AttackStart(who); + Creature *temp = Unit::GetCreature(*me, instance->GetData64(DATA_ALYTHESS)); + if (temp && temp->isAlive() && !temp->getVictim()) + temp->AI()->AttackStart(who); } if (instance) @@ -341,7 +340,6 @@ public: } } }; - }; class boss_alythess : public CreatureScript @@ -383,13 +381,12 @@ public: if (instance) { - Unit* Temp = Unit::GetUnit(*me, instance->GetData64(DATA_SACROLASH)); - if (Temp) + if (Creature *temp = Unit::GetCreature((*me), instance->GetData64(DATA_SACROLASH))) { - if (Temp->isDead()) - CAST_CRE(Temp)->Respawn(); - else if (Temp->getVictim()) - me->getThreatManager().addThreat(Temp->getVictim(), 0.0f); + if (temp->isDead()) + temp->Respawn(); + else if (temp->getVictim()) + me->getThreatManager().addThreat(temp->getVictim(), 0.0f); } } @@ -416,9 +413,9 @@ public: if (instance) { - Unit* Temp = Unit::GetUnit(*me, instance->GetData64(DATA_SACROLASH)); - if (Temp && Temp->isAlive() && !(Temp->getVictim())) - CAST_CRE(Temp)->AI()->AttackStart(who); + Creature *temp = Unit::GetCreature(*me, instance->GetData64(DATA_SACROLASH)); + if (temp && temp->isAlive() && !temp->getVictim()) + temp->AI()->AttackStart(who); } if (instance) @@ -480,7 +477,6 @@ public: { switch (spell->Id) { - case SPELL_BLAZE: target->CastSpell(target, SPELL_BLAZE_SUMMON, true); case SPELL_CONFLAGRATION: @@ -670,7 +666,6 @@ public: } else EnrageTimer -= diff; } }; - }; class mob_shadow_image : public CreatureScript @@ -705,7 +700,6 @@ public: { switch (spell->Id) { - case SPELL_SHADOW_FURY: case SPELL_DARK_STRIKE: if (!target->HasAura(SPELL_DARK_FLAME)) @@ -752,7 +746,6 @@ public: } else DarkstrikeTimer -= diff; } }; - }; void AddSC_boss_eredar_twins() diff --git a/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_felmyst.cpp b/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_felmyst.cpp index 7267c4e1bdb..bc841d76714 100644 --- a/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_felmyst.cpp +++ b/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_felmyst.cpp @@ -512,7 +512,6 @@ public: } } }; - }; class mob_felmyst_vapor : public CreatureScript @@ -545,7 +544,6 @@ public: AttackStart(target); } }; - }; class mob_felmyst_trail : public CreatureScript @@ -573,7 +571,6 @@ public: void MoveInLineOfSight(Unit* /*who*/) {} void UpdateAI(const uint32 /*diff*/) {} }; - }; void AddSC_boss_felmyst() diff --git a/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_kalecgos.cpp b/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_kalecgos.cpp index 57e69238816..3e503a547d8 100644 --- a/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_kalecgos.cpp +++ b/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_kalecgos.cpp @@ -304,11 +304,20 @@ public: if (SpectralBlastTimer <= diff) { - std::list<HostileReference*> &m_threatlist = me->getThreatManager().getThreatList(); + ThreatContainer::StorageType const& m_threatlist = me->getThreatManager().getThreatList(); std::list<Unit*> targetList; - for (std::list<HostileReference*>::const_iterator itr = m_threatlist.begin(); itr!= m_threatlist.end(); ++itr) - if ((*itr)->getTarget() && (*itr)->getTarget()->GetTypeId() == TYPEID_PLAYER && (*itr)->getTarget()->GetGUID() != me->getVictim()->GetGUID() && !(*itr)->getTarget()->HasAura(AURA_SPECTRAL_EXHAUSTION) && (*itr)->getTarget()->GetPositionZ() > me->GetPositionZ()-5) - targetList.push_back((*itr)->getTarget()); + for (ThreatContainer::StorageType::const_iterator itr = m_threatlist.begin(); itr!= m_threatlist.end(); ++itr) + { + Unit* target = (*itr)->getTarget(); + if (target + && target->GetTypeId() == TYPEID_PLAYER + && target->GetGUID() != me->getVictim()->GetGUID() + && target->GetPositionZ() > me->GetPositionZ() - 5 + && !target->HasAura(AURA_SPECTRAL_EXHAUSTION)) + { + targetList.push_back(target); + } + } if (targetList.empty()) { SpectralBlastTimer = 1000; @@ -431,7 +440,6 @@ public: } } }; - }; class boss_kalec : public CreatureScript @@ -533,7 +541,6 @@ public: DoMeleeAttackIfReady(); } }; - }; class kalecgos_teleporter : public GameObjectScript @@ -561,7 +568,6 @@ public: player->CastSpell(player, SPELL_TELEPORT_SPECTRAL, true); return true; } - }; class boss_sathrovarr : public CreatureScript @@ -761,15 +767,12 @@ public: if (ResetThreat <= diff) { - for (std::list<HostileReference*>::const_iterator itr = me->getThreatManager().getThreatList().begin(); itr != me->getThreatManager().getThreatList().end(); ++itr) + ThreatContainer::StorageType threatlist = me->getThreatManager().getThreatList(); + for (ThreatContainer::StorageType::const_iterator itr = threatlist.begin(); itr != threatlist.end(); ++itr) { if (Unit* unit = Unit::GetUnit(*me, (*itr)->getUnitGuid())) - { - if (unit->GetPositionZ() > me->GetPositionZ()+5) - { + if (unit->GetPositionZ() > me->GetPositionZ() + 5) me->getThreatManager().modifyThreatPercent(unit, -100); - } - } } ResetThreat = 1000; } else ResetThreat -= diff; @@ -799,7 +802,6 @@ public: DoMeleeAttackIfReady(); } }; - }; void AddSC_boss_kalecgos() diff --git a/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_kiljaeden.cpp b/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_kiljaeden.cpp index e368124abaf..096f6daaec2 100644 --- a/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_kiljaeden.cpp +++ b/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_kiljaeden.cpp @@ -367,7 +367,6 @@ public: } } }; - }; class go_orb_of_the_blue_flight : public GameObjectScript @@ -391,7 +390,6 @@ public: } return true; } - }; //AI for Kil'jaeden Event Controller @@ -492,7 +490,6 @@ public: } } }; - }; //AI for Kil'jaeden @@ -900,7 +897,6 @@ public: } } }; - }; //AI for Hand of the Deceiver @@ -987,8 +983,8 @@ public: { if (Creature* pPortal = DoSpawnCreature(CREATURE_FELFIRE_PORTAL, 0, 0, 0, 0, TEMPSUMMON_TIMED_DESPAWN, 20000)) { - std::list<HostileReference*>::iterator itr; - for (itr = me->getThreatManager().getThreatList().begin(); itr != me->getThreatManager().getThreatList().end(); ++itr) + ThreatContainer::StorageType const &threatlist = me->getThreatManager().getThreatList(); + for (ThreatContainer::StorageType::const_iterator itr = threatlist.begin(); itr != threatlist.end(); ++itr) { Unit* unit = Unit::GetUnit(*me, (*itr)->getUnitGuid()); if (unit) @@ -1001,7 +997,6 @@ public: DoMeleeAttackIfReady(); } }; - }; //AI for Felfire Portal @@ -1046,7 +1041,6 @@ public: } else uiSpawnFiendTimer -= diff; } }; - }; //AI for Felfire Fiend @@ -1104,7 +1098,6 @@ public: } } }; - }; //AI for Armageddon target @@ -1159,7 +1152,6 @@ public: } else uiTimer -=diff; } }; - }; //AI for Shield Orbs @@ -1247,7 +1239,6 @@ public: bPointReached = true; } }; - }; //AI for Sinister Reflection @@ -1310,7 +1301,8 @@ public: } } - switch (victimClass) { + switch (victimClass) + { case CLASS_DRUID: if (uiTimer[1] <= diff) { @@ -1411,13 +1403,12 @@ public: } DoMeleeAttackIfReady(); break; - } - sLog->outDebug(LOG_FILTER_TSCR, "Sinister-Timer"); - for (uint8 i = 0; i < 3; ++i) - uiTimer[i] -= diff; } + sLog->outDebug(LOG_FILTER_TSCR, "Sinister-Timer"); + for (uint8 i = 0; i < 3; ++i) + uiTimer[i] -= diff; + } }; - }; void AddSC_boss_kiljaeden() diff --git a/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_muru.cpp b/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_muru.cpp index c00ab84b567..9fd0a5eb5d8 100644 --- a/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_muru.cpp +++ b/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_muru.cpp @@ -199,7 +199,6 @@ public: DoMeleeAttackIfReady(); } }; - }; class boss_muru : public CreatureScript @@ -364,7 +363,6 @@ public: } } }; - }; class npc_muru_portal : public CreatureScript @@ -448,7 +446,6 @@ public: } else SummonTimer -= diff; } }; - }; class npc_dark_fiend : public CreatureScript @@ -500,7 +497,6 @@ public: } else { - if (me->IsWithinDist(me->getVictim(), 5)) { DoCastAOE(SPELL_DARKFIEND_AOE, false); @@ -511,7 +507,6 @@ public: } else WaitTimer -= diff; } }; - }; class npc_void_sentinel : public CreatureScript @@ -567,7 +562,6 @@ public: DoMeleeAttackIfReady(); } }; - }; class npc_blackhole : public CreatureScript @@ -646,7 +640,6 @@ public: else DespawnTimer -= diff; } }; - }; void AddSC_boss_muru() diff --git a/src/server/scripts/EasternKingdoms/SunwellPlateau/instance_sunwell_plateau.cpp b/src/server/scripts/EasternKingdoms/SunwellPlateau/instance_sunwell_plateau.cpp index 6324c5adf16..bea73837304 100644 --- a/src/server/scripts/EasternKingdoms/SunwellPlateau/instance_sunwell_plateau.cpp +++ b/src/server/scripts/EasternKingdoms/SunwellPlateau/instance_sunwell_plateau.cpp @@ -134,8 +134,9 @@ public: return player; } } + else + sLog->outDebug(LOG_FILTER_TSCR, "Instance Sunwell Plateau: GetPlayerInMap, but PlayerList is empty!"); - sLog->outDebug(LOG_FILTER_TSCR, "Instance Sunwell Plateau: GetPlayerInMap, but PlayerList is empty!"); return NULL; } @@ -281,7 +282,7 @@ public: return stream.str(); } - void Load(const char* in) + void Load(char const* in) { if (!in) { @@ -299,7 +300,6 @@ public: OUT_LOAD_INST_DATA_COMPLETE; } }; - }; void AddSC_instance_sunwell_plateau() diff --git a/src/server/scripts/EasternKingdoms/blasted_lands.cpp b/src/server/scripts/EasternKingdoms/blasted_lands.cpp index 3d8e68dfbf8..75109f3a2f6 100644 --- a/src/server/scripts/EasternKingdoms/blasted_lands.cpp +++ b/src/server/scripts/EasternKingdoms/blasted_lands.cpp @@ -60,7 +60,7 @@ public: bool OnGossipHello(Player* player, Creature* creature) { - if (player->GetQuestStatus(3628) == QUEST_STATUS_INCOMPLETE && player->HasItemCount(10757, 1)) + if (player->GetQuestStatus(3628) == QUEST_STATUS_INCOMPLETE && player->HasItemCount(10757)) player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_ITEM_USHER, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF); player->SEND_GOSSIP_MENU(player->GetGossipTextId(creature), creature->GetGUID()); diff --git a/src/server/scripts/Events/CMakeLists.txt b/src/server/scripts/Events/CMakeLists.txt new file mode 100644 index 00000000000..d8be052d645 --- /dev/null +++ b/src/server/scripts/Events/CMakeLists.txt @@ -0,0 +1,17 @@ +# Copyright (C) 2008-2011 TrinityCore <http://www.trinitycore.org/> +# +# This file is free software; as a special exception the author gives +# unlimited permission to copy and/or distribute it, with or without +# modifications, as long as this notice is preserved. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY, to the extent permitted by law; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + +set(scripts_STAT_SRCS + ${scripts_STAT_SRCS} + Events/childrens_week.cpp + Events/event.cpp +) + +message(" -> Prepared: Events") diff --git a/src/server/scripts/Events/childrens_week.cpp b/src/server/scripts/Events/childrens_week.cpp new file mode 100644 index 00000000000..763961271d8 --- /dev/null +++ b/src/server/scripts/Events/childrens_week.cpp @@ -0,0 +1,1049 @@ +/* +* Copyright (C) 2008-2012 TrinityCore <http://www.trinitycore.org/> +* +* This program is free software; you can redistribute it and/or modify it +* under the terms of the GNU General Public License as published by the +* Free Software Foundation; either version 2 of the License, or (at your +* option) any later version. +* +* This program is distributed in the hope that it will be useful, but WITHOUT +* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for +* more details. +* +* You should have received a copy of the GNU General Public License along +* with this program. If not, see <http://www.gnu.org/licenses/>. +*/ + +#include "ScriptMgr.h" +#include "ScriptedCreature.h" +#include "SpellAuras.h" + +enum Orphans +{ + ORPHAN_ORACLE = 33533, + ORPHAN_WOLVAR = 33532, + ORPHAN_BLOOD_ELF = 22817, + ORPHAN_DRAENEI = 22818, + ORPHAN_HUMAN = 14305, + ORPHAN_ORCISH = 14444, +}; + +enum Texts +{ + TEXT_ORACLE_ORPHAN_1 = 1, + TEXT_ORACLE_ORPHAN_2 = 2, + TEXT_ORACLE_ORPHAN_3 = 3, + TEXT_ORACLE_ORPHAN_4 = 4, + TEXT_ORACLE_ORPHAN_5 = 5, + TEXT_ORACLE_ORPHAN_6 = 6, + TEXT_ORACLE_ORPHAN_7 = 7, + TEXT_ORACLE_ORPHAN_8 = 8, + TEXT_ORACLE_ORPHAN_9 = 9, + TEXT_ORACLE_ORPHAN_10 = 10, + TEXT_ORACLE_ORPHAN_11 = 11, + TEXT_ORACLE_ORPHAN_12 = 12, + TEXT_ORACLE_ORPHAN_13 = 13, + TEXT_ORACLE_ORPHAN_14 = 14, + + TEXT_WOLVAR_ORPHAN_1 = 1, + TEXT_WOLVAR_ORPHAN_2 = 2, + TEXT_WOLVAR_ORPHAN_3 = 3, + TEXT_WOLVAR_ORPHAN_4 = 4, + TEXT_WOLVAR_ORPHAN_5 = 5, + // 6 - 9 used in Nesingwary script + TEXT_WOLVAR_ORPHAN_10 = 10, + TEXT_WOLVAR_ORPHAN_11 = 11, + TEXT_WOLVAR_ORPHAN_12 = 12, + TEXT_WOLVAR_ORPHAN_13 = 13, + + TEXT_WINTERFIN_PLAYMATE_1 = 1, + TEXT_WINTERFIN_PLAYMATE_2 = 2, + + TEXT_SNOWFALL_GLADE_PLAYMATE_1 = 1, + TEXT_SNOWFALL_GLADE_PLAYMATE_2 = 2, + + TEXT_SOO_ROO_1 = 1, + TEXT_ELDER_KEKEK_1 = 1, + + TEXT_ALEXSTRASZA_2 = 2, + TEXT_KRASUS_8 = 8, +}; + +enum Quests +{ + QUEST_PLAYMATE_WOLVAR = 13951, + QUEST_PLAYMATE_ORACLE = 13950, + QUEST_THE_BIGGEST_TREE_EVER = 13929, + QUEST_THE_BRONZE_DRAGONSHRINE_ORACLE = 13933, + QUEST_THE_BRONZE_DRAGONSHRINE_WOLVAR = 13934, + QUEST_MEETING_A_GREAT_ONE = 13956, + QUEST_THE_MIGHTY_HEMET_NESINGWARY = 13957, + QUEST_DOWN_AT_THE_DOCKS = 910, + QUEST_GATEWAY_TO_THE_FRONTIER = 911, + QUEST_BOUGHT_OF_ETERNALS = 1479, + QUEST_SPOOKY_LIGHTHOUSE = 1687, + QUEST_STONEWROUGHT_DAM = 1558, + QUEST_DARK_PORTAL_H = 10951, + QUEST_DARK_PORTAL_A = 10952, + QUEST_LORDAERON_THRONE_ROOM = 1800, + QUEST_AUCHINDOUN_AND_THE_RING = 10950, + QUEST_TIME_TO_VISIT_THE_CAVERNS_H = 10963, + QUEST_TIME_TO_VISIT_THE_CAVERNS_A = 10962, + QUEST_THE_SEAT_OF_THE_NARUU = 10956, + QUEST_CALL_ON_THE_FARSEER = 10968, + QUEST_JHEEL_IS_AT_AERIS_LANDING = 10954, + QUEST_HCHUU_AND_THE_MUSHROOM_PEOPLE = 10945, + QUEST_VISIT_THE_THRONE_OF_ELEMENTS = 10953, + QUEST_NOW_WHEN_I_GROW_UP = 11975, + QUEST_HOME_OF_THE_BEAR_MEN = 13930, + QUEST_THE_DRAGON_QUEEN_ORACLE = 13954, + QUEST_THE_DRAGON_QUEEN_WOLVAR = 13955, +}; + +enum Areatriggers +{ + AT_DOWN_AT_THE_DOCKS = 3551, + AT_GATEWAY_TO_THE_FRONTIER = 3549, + AT_LORDAERON_THRONE_ROOM = 3547, + AT_BOUGHT_OF_ETERNALS = 3546, + AT_SPOOKY_LIGHTHOUSE = 3552, + AT_STONEWROUGHT_DAM = 3548, + AT_DARK_PORTAL = 4356, + + NPC_CAVERNS_OF_TIME_CW_TRIGGER = 22872, + NPC_EXODAR_01_CW_TRIGGER = 22851, + NPC_EXODAR_02_CW_TRIGGER = 22905, + NPC_AERIS_LANDING_CW_TRIGGER = 22838, + NPC_AUCHINDOUN_CW_TRIGGER = 22831, + NPC_SPOREGGAR_CW_TRIGGER = 22829, + NPC_THRONE_OF_ELEMENTS_CW_TRIGGER = 22839, + NPC_SILVERMOON_01_CW_TRIGGER = 22866, + NPC_KRASUS = 27990, +}; + +enum Misc +{ + SPELL_SNOWBALL = 21343, + SPELL_ORPHAN_OUT = 58818, + + DISPLAY_INVISIBLE = 11686, +}; + +uint64 getOrphanGUID(Player* player, uint32 orphan) +{ + if (Aura* orphanOut = player->GetAura(SPELL_ORPHAN_OUT)) + if (orphanOut->GetCaster() && orphanOut->GetCaster()->GetEntry() == orphan) + return orphanOut->GetCaster()->GetGUID(); + + return 0; +} + +/*###### +## npc_winterfin_playmate +######*/ +class npc_winterfin_playmate : public CreatureScript +{ + public: + npc_winterfin_playmate() : CreatureScript("npc_winterfin_playmate") {} + + struct npc_winterfin_playmateAI : public ScriptedAI + { + npc_winterfin_playmateAI(Creature* creature) : ScriptedAI (creature) {} + + void Reset() + { + timer = 0; + phase = 0; + playerGUID = 0; + orphanGUID = 0; + } + + void MoveInLineOfSight(Unit* who) + { + if (!phase && who && who->GetDistance2d(me) < 10.0f) + if (Player* player = who->ToPlayer()) + if (player->GetQuestStatus(QUEST_PLAYMATE_ORACLE) == QUEST_STATUS_INCOMPLETE) + { + playerGUID = player->GetGUID(); + if ((orphanGUID = getOrphanGUID(player, ORPHAN_ORACLE))) + phase = 1; + } + } + + void UpdateAI(const uint32 diff) + { + if (!phase) + return; + + if (timer <= diff) + { + Player* player = Player::GetPlayer(*me, playerGUID); + Creature* orphan = Creature::GetCreature(*me, orphanGUID); + + if (!orphan || !player) + { + Reset(); + return; + } + + switch(phase) + { + case 1: + orphan->GetMotionMaster()->MovePoint(0, me->GetPositionX() + cos(me->GetOrientation()) * 5,me->GetPositionY() + sin(me->GetOrientation()) * 5, me->GetPositionZ()); + orphan->AI()->Talk(TEXT_ORACLE_ORPHAN_1); + timer = 3000; + break; + case 2: + orphan->SetFacingToObject(me); + Talk(TEXT_WINTERFIN_PLAYMATE_1); + me->HandleEmoteCommand(EMOTE_STATE_DANCE); + timer = 3000; + break; + case 3: + orphan->AI()->Talk(TEXT_ORACLE_ORPHAN_2); + timer = 3000; + break; + case 4: + Talk(TEXT_WINTERFIN_PLAYMATE_2); + timer = 5000; + break; + case 5: + orphan->AI()->Talk(TEXT_ORACLE_ORPHAN_3); + me->HandleEmoteCommand(EMOTE_STATE_NONE); + player->GroupEventHappens(QUEST_PLAYMATE_ORACLE, me); + orphan->GetMotionMaster()->MoveFollow(player, PET_FOLLOW_DIST, PET_FOLLOW_ANGLE); + Reset(); + return; + } + ++phase; + } + else + timer -= diff; + } + + private: + uint32 timer; + int8 phase; + uint64 playerGUID; + uint64 orphanGUID; + + }; + + CreatureAI* GetAI(Creature* creature) const + { + return new npc_winterfin_playmateAI(creature); + } +}; + +/*###### +## npc_snowfall_glade_playmate +######*/ +class npc_snowfall_glade_playmate : public CreatureScript +{ + public: + npc_snowfall_glade_playmate() : CreatureScript("npc_snowfall_glade_playmate") {} + + struct npc_snowfall_glade_playmateAI : public ScriptedAI + { + npc_snowfall_glade_playmateAI(Creature* creature) : ScriptedAI (creature) {} + + void Reset() + { + timer = 0; + phase = 0; + playerGUID = 0; + orphanGUID = 0; + } + + void MoveInLineOfSight(Unit* who) + { + if (!phase && who && who->GetDistance2d(me) < 10.0f) + if (Player* player = who->ToPlayer()) + if (player->GetQuestStatus(QUEST_PLAYMATE_WOLVAR) == QUEST_STATUS_INCOMPLETE) + { + playerGUID = player->GetGUID(); + if ((orphanGUID = getOrphanGUID(player, ORPHAN_WOLVAR))) + phase = 1; + } + } + + void UpdateAI(const uint32 diff) + { + if (!phase) + return; + + if (timer <= diff) + { + Player* player = Player::GetPlayer(*me, playerGUID); + Creature* orphan = Creature::GetCreature(*me, orphanGUID); + + if (!orphan || !player) + { + Reset(); + return; + } + + switch (phase) + { + case 1: + orphan->GetMotionMaster()->MovePoint(0, me->GetPositionX() + cos(me->GetOrientation()) * 5,me->GetPositionY() + sin(me->GetOrientation()) * 5, me->GetPositionZ()); + orphan->AI()->Talk(TEXT_WOLVAR_ORPHAN_1); + timer = 5000; + break; + case 2: + orphan->SetFacingToObject(me); + Talk(TEXT_SNOWFALL_GLADE_PLAYMATE_1); + DoCast(orphan, SPELL_SNOWBALL); + timer = 5000; + break; + case 3: + Talk(TEXT_SNOWFALL_GLADE_PLAYMATE_2); + timer = 5000; + break; + case 4: + orphan->AI()->Talk(TEXT_WOLVAR_ORPHAN_2); + orphan->AI()->DoCast(me, SPELL_SNOWBALL); + timer = 5000; + break; + case 5: + orphan->AI()->Talk(TEXT_WOLVAR_ORPHAN_3); + player->GroupEventHappens(QUEST_PLAYMATE_WOLVAR, me); + orphan->GetMotionMaster()->MoveFollow(player, PET_FOLLOW_DIST, PET_FOLLOW_ANGLE); + Reset(); + return; + } + ++phase; + } + else + timer -= diff; + } + + private: + uint32 timer; + int8 phase; + uint64 playerGUID; + uint64 orphanGUID; + }; + + CreatureAI* GetAI(Creature* pCreature) const + { + return new npc_snowfall_glade_playmateAI(pCreature); + } +}; + +/*###### +## npc_the_biggest_tree +######*/ +class npc_the_biggest_tree : public CreatureScript +{ + public: + npc_the_biggest_tree() : CreatureScript("npc_the_biggest_tree") {} + + struct npc_the_biggest_treeAI : public ScriptedAI + { + npc_the_biggest_treeAI(Creature* creature) : ScriptedAI (creature) + { + me->SetDisplayId(DISPLAY_INVISIBLE); + } + + void Reset() + { + timer = 1000; + phase = 0; + playerGUID = 0; + orphanGUID = 0; + } + + void MoveInLineOfSight(Unit* who) + { + if (!phase && who && who->GetDistance2d(me) < 10.0f) + if (Player* player = who->ToPlayer()) + if (player->GetQuestStatus(QUEST_THE_BIGGEST_TREE_EVER) == QUEST_STATUS_INCOMPLETE) + { + playerGUID = player->GetGUID(); + if ((orphanGUID = getOrphanGUID(player, ORPHAN_ORACLE))) + phase = 1; + } + } + + void UpdateAI(const uint32 diff) + { + if (!phase) + return; + + if (timer <= diff) + { + Player* player = Player::GetPlayer(*me, playerGUID); + Creature* orphan = Creature::GetCreature(*me, orphanGUID); + + if (!orphan || !player) + { + Reset(); + return; + } + + switch (phase) + { + case 1: + orphan->GetMotionMaster()->MovePoint(0, me->GetPositionX() + cos(me->GetOrientation()) * 5, me->GetPositionY() + sin(me->GetOrientation()) * 5, me->GetPositionZ()); + timer = 2000; + break; + case 2: + orphan->SetFacingToObject(me); + orphan->AI()->Talk(TEXT_ORACLE_ORPHAN_4); + timer = 5000; + break; + case 3: + player->GroupEventHappens(QUEST_THE_BIGGEST_TREE_EVER, me); + orphan->GetMotionMaster()->MoveFollow(player, PET_FOLLOW_DIST, PET_FOLLOW_ANGLE); + Reset(); + return; + } + ++phase; + } + else + timer -= diff; + } + + private: + uint32 timer; + uint8 phase; + uint64 playerGUID; + uint64 orphanGUID; + + }; + + CreatureAI* GetAI(Creature* creature) const + { + return new npc_the_biggest_treeAI(creature); + } +}; + +/*###### +## npc_high_oracle_soo_roo +######*/ +class npc_high_oracle_soo_roo : public CreatureScript +{ + public: + npc_high_oracle_soo_roo() : CreatureScript("npc_high_oracle_soo_roo") {} + + struct npc_high_oracle_soo_rooAI : public ScriptedAI + { + npc_high_oracle_soo_rooAI(Creature* creature) : ScriptedAI (creature) {} + + void Reset() + { + timer = 0; + phase = 0; + playerGUID = 0; + orphanGUID = 0; + } + + void MoveInLineOfSight(Unit* who) + { + if (!phase && who && who->GetDistance2d(me) < 10.0f) + if (Player* player = who->ToPlayer()) + if (player->GetQuestStatus(QUEST_THE_BRONZE_DRAGONSHRINE_ORACLE) == QUEST_STATUS_INCOMPLETE) + { + playerGUID = player->GetGUID(); + if ((orphanGUID = getOrphanGUID(player, ORPHAN_ORACLE))) + phase = 1; + } + } + + void UpdateAI(const uint32 diff) + { + if (!phase) + return; + + if (timer <= diff) + { + Player* player = Player::GetPlayer(*me, playerGUID); + Creature* orphan = Creature::GetCreature(*me, orphanGUID); + + if (!orphan || !player) + { + Reset(); + return; + } + + switch (phase) + { + case 1: + orphan->GetMotionMaster()->MovePoint(0, me->GetPositionX() + cos(me->GetOrientation()) * 5, me->GetPositionY() + sin(me->GetOrientation()) * 5, me->GetPositionZ()); + orphan->AI()->Talk(TEXT_ORACLE_ORPHAN_5); + timer = 3000; + break; + case 2: + orphan->SetFacingToObject(me); + Talk(TEXT_SOO_ROO_1); + timer = 6000; + break; + case 3: + orphan->AI()->Talk(TEXT_ORACLE_ORPHAN_6); + player->GroupEventHappens(QUEST_THE_BRONZE_DRAGONSHRINE_ORACLE, me); + orphan->GetMotionMaster()->MoveFollow(player, PET_FOLLOW_DIST, PET_FOLLOW_ANGLE); + Reset(); + return; + } + ++phase; + } + else + timer -= diff; + } + + private: + uint32 timer; + int8 phase; + uint64 playerGUID; + uint64 orphanGUID; + + }; + + CreatureAI* GetAI(Creature* creature) const + { + return new npc_high_oracle_soo_rooAI(creature); + } +}; + +/*###### +## npc_elder_kekek +######*/ +class npc_elder_kekek : public CreatureScript +{ + public: + npc_elder_kekek() : CreatureScript("npc_elder_kekek") {} + + struct npc_elder_kekekAI : public ScriptedAI + { + npc_elder_kekekAI(Creature* creature) : ScriptedAI (creature) {} + + void Reset() + { + timer = 0; + phase = 0; + playerGUID = 0; + orphanGUID = 0; + } + + void MoveInLineOfSight(Unit* who) + { + if (!phase && who && who->GetDistance2d(me) < 10.0f) + if (Player* player = who->ToPlayer()) + if (player->GetQuestStatus(QUEST_THE_BRONZE_DRAGONSHRINE_WOLVAR) == QUEST_STATUS_INCOMPLETE) + { + playerGUID = player->GetGUID(); + if ((orphanGUID = getOrphanGUID(player, ORPHAN_WOLVAR))) + phase = 1; + } + } + + void UpdateAI(const uint32 diff) + { + if (!phase) + return; + + if (timer <= diff) + { + Player* player = Player::GetPlayer(*me, playerGUID); + Creature* orphan = Creature::GetCreature(*me, orphanGUID); + + if (!player || !orphan) + { + Reset(); + return; + } + + switch (phase) + { + case 1: + orphan->GetMotionMaster()->MovePoint(0, me->GetPositionX() + cos(me->GetOrientation()) * 5, me->GetPositionY() + sin(me->GetOrientation()) * 5, me->GetPositionZ()); + orphan->AI()->Talk(TEXT_WOLVAR_ORPHAN_4); + timer = 3000; + break; + case 2: + Talk(TEXT_ELDER_KEKEK_1); + timer = 6000; + break; + case 3: + orphan->AI()->Talk(TEXT_WOLVAR_ORPHAN_5); + player->GroupEventHappens(QUEST_THE_BRONZE_DRAGONSHRINE_WOLVAR, me); + orphan->GetMotionMaster()->MoveFollow(player, PET_FOLLOW_DIST, PET_FOLLOW_ANGLE); + Reset(); + return; + } + ++phase; + } + else + timer -= diff; + } + + private: + uint32 timer; + int8 phase; + uint64 playerGUID; + uint64 orphanGUID; + + }; + + CreatureAI* GetAI(Creature* creature) const + { + return new npc_elder_kekekAI(creature); + } +}; + +/*###### +## npc_the_etymidian +## TODO: A red crystal as a gift for the great one should be spawned during the event. +######*/ +class npc_the_etymidian : public CreatureScript +{ + public: + npc_the_etymidian() : CreatureScript("npc_the_etymidian") {} + + struct npc_the_etymidianAI : public ScriptedAI + { + npc_the_etymidianAI(Creature* creature) : ScriptedAI (creature) {} + + void Reset() + { + timer = 0; + phase = 0; + playerGUID = 0; + orphanGUID = 0; + } + + void MoveInLineOfSight(Unit* who) + { + if (!phase && who && who->GetDistance2d(me) < 10.0f) + if (Player* player = who->ToPlayer()) + if (player->GetQuestStatus(QUEST_MEETING_A_GREAT_ONE) == QUEST_STATUS_INCOMPLETE) + { + playerGUID = player->GetGUID(); + if ((orphanGUID = getOrphanGUID(player, ORPHAN_ORACLE))) + phase = 1; + } + } + + void UpdateAI(const uint32 diff) + { + if (!phase) + return; + + if (timer <= diff) + { + Player* player = Player::GetPlayer(*me, playerGUID); + Creature* orphan = Creature::GetCreature(*me, orphanGUID); + + if (!orphan || !player) + { + Reset(); + return; + } + + switch (phase) + { + case 1: + orphan->GetMotionMaster()->MovePoint(0, me->GetPositionX() + cos(me->GetOrientation()) * 5, me->GetPositionY() + sin(me->GetOrientation()) * 5, me->GetPositionZ()); + orphan->AI()->Talk(TEXT_ORACLE_ORPHAN_7); + timer = 5000; + break; + case 2: + orphan->SetFacingToObject(me); + orphan->AI()->Talk(TEXT_ORACLE_ORPHAN_8); + timer = 5000; + break; + case 3: + orphan->AI()->Talk(TEXT_ORACLE_ORPHAN_9); + timer = 5000; + break; + case 4: + orphan->AI()->Talk(TEXT_ORACLE_ORPHAN_10); + timer = 5000; + break; + case 5: + orphan->GetMotionMaster()->MoveFollow(player, PET_FOLLOW_DIST, PET_FOLLOW_ANGLE); + player->GroupEventHappens(QUEST_MEETING_A_GREAT_ONE, me); + Reset(); + return; + } + ++phase; + } + else + timer -= diff; + } + + private: + uint32 timer; + int8 phase; + uint32 GOtimer; + uint64 playerGUID; + uint64 orphanGUID; + + }; + + CreatureAI* GetAI(Creature* creature) const + { + return new npc_the_etymidianAI(creature); + } +}; + +/*###### +## npc_cw_alexstrasza_trigger +######*/ +class npc_alexstraza_the_lifebinder : public CreatureScript +{ + public: + npc_alexstraza_the_lifebinder() : CreatureScript("npc_alexstraza_the_lifebinder") {} + + struct npc_alexstraza_the_lifebinderAI : public ScriptedAI + { + npc_alexstraza_the_lifebinderAI(Creature* creature) : ScriptedAI (creature) {} + + void Reset() + { + timer = 0; + phase = 0; + playerGUID = 0; + orphanGUID = 0; + } + + void SetData(uint32 type, uint32 data) + { + // Existing SmartAI + if (type == 0) + { + switch (data) + { + case 1: + me->SetOrientation(1.6049f); + break; + case 2: + me->SetOrientation(me->GetHomePosition().GetOrientation()); + break; + } + } + } + + void MoveInLineOfSight(Unit* who) + { + if (!phase && who && who->GetDistance2d(me) < 10.0f) + if (Player* player = who->ToPlayer()) + { + if (player->GetQuestStatus(QUEST_THE_DRAGON_QUEEN_ORACLE) == QUEST_STATUS_INCOMPLETE) + { + if ((orphanGUID = getOrphanGUID(player, ORPHAN_ORACLE))) + phase = 1; + playerGUID = player->GetGUID(); + } + else if (player->GetQuestStatus(QUEST_THE_DRAGON_QUEEN_WOLVAR) == QUEST_STATUS_INCOMPLETE) + { + if ((orphanGUID = getOrphanGUID(player, ORPHAN_WOLVAR))) + phase = 7; + playerGUID = player->GetGUID(); + } + } + } + + void UpdateAI(const uint32 diff) + { + if (!phase) + return; + + if (timer <= diff) + { + Player* player = Player::GetPlayer(*me, playerGUID); + Creature* orphan = Creature::GetCreature(*me, orphanGUID); + + if (!orphan || !player) + { + Reset(); + return; + } + + switch (phase) + { + case 1: + orphan->GetMotionMaster()->MovePoint(0, me->GetPositionX() + cos(me->GetOrientation()) * 5, me->GetPositionY() + sin(me->GetOrientation()) * 5, me->GetPositionZ()); + orphan->AI()->Talk(TEXT_ORACLE_ORPHAN_11); + timer = 5000; + break; + case 2: + orphan->SetFacingToObject(me); + orphan->AI()->Talk(TEXT_ORACLE_ORPHAN_12); + timer = 5000; + break; + case 3: + orphan->AI()->Talk(TEXT_ORACLE_ORPHAN_13); + timer = 5000; + break; + case 4: + Talk(TEXT_ALEXSTRASZA_2); + me->SetStandState(UNIT_STAND_STATE_KNEEL); + me->SetFacingToObject(orphan); + timer = 5000; + break; + case 5: + orphan->AI()->Talk(TEXT_ORACLE_ORPHAN_14); + timer = 5000; + break; + case 6: + me->SetStandState(UNIT_STAND_STATE_STAND); + me->SetOrientation(me->GetHomePosition().GetOrientation()); + player->GroupEventHappens(QUEST_THE_DRAGON_QUEEN_ORACLE, me); + orphan->GetMotionMaster()->MoveFollow(player, PET_FOLLOW_DIST, PET_FOLLOW_ANGLE); + Reset(); + return; + case 7: + orphan->GetMotionMaster()->MovePoint(0, me->GetPositionX() + cos(me->GetOrientation()) * 5, me->GetPositionY() + sin(me->GetOrientation()) * 5, me->GetPositionZ()); + orphan->AI()->Talk(TEXT_WOLVAR_ORPHAN_11); + timer = 5000; + break; + case 8: + if(Creature* krasus = me->FindNearestCreature(NPC_KRASUS, 10.0f)) + { + orphan->SetFacingToObject(krasus); + krasus->AI()->Talk(TEXT_KRASUS_8); + } + timer = 5000; + break; + case 9: + orphan->AI()->Talk(TEXT_WOLVAR_ORPHAN_12); + timer = 5000; + break; + case 10: + orphan->SetFacingToObject(me); + Talk(TEXT_ALEXSTRASZA_2); + timer = 5000; + break; + case 11: + orphan->AI()->Talk(TEXT_WOLVAR_ORPHAN_13); + timer = 5000; + break; + case 12: + player->GroupEventHappens(QUEST_THE_DRAGON_QUEEN_WOLVAR, me); + orphan->GetMotionMaster()->MoveFollow(player, PET_FOLLOW_DIST, PET_FOLLOW_ANGLE); + Reset(); + return; + } + ++phase; + } + else + timer -= diff; + } + + private: + int8 phase; + uint32 timer; + uint64 playerGUID; + uint64 orphanGUID; + uint64 alexstraszaGUID; + + }; + + CreatureAI* GetAI(Creature* creature) const + { + return new npc_alexstraza_the_lifebinderAI(creature); + } +}; + +/*###### +## at_bring_your_orphan_to +######*/ + +class at_bring_your_orphan_to : public AreaTriggerScript +{ + public: + at_bring_your_orphan_to() : AreaTriggerScript("at_bring_your_orphan_to") { } + + bool OnTrigger(Player* player, AreaTriggerEntry const* trigger) + { + if (player->isDead() || !player->HasAura(SPELL_ORPHAN_OUT)) + return false; + + uint32 questId = 0; + uint32 orphanId = 0; + + switch (trigger->id) + { + case AT_DOWN_AT_THE_DOCKS: + questId = QUEST_DOWN_AT_THE_DOCKS; + orphanId = ORPHAN_ORCISH; + break; + case AT_GATEWAY_TO_THE_FRONTIER: + questId = QUEST_GATEWAY_TO_THE_FRONTIER; + orphanId = ORPHAN_ORCISH; + break; + case AT_LORDAERON_THRONE_ROOM: + questId = QUEST_LORDAERON_THRONE_ROOM; + orphanId = ORPHAN_ORCISH; + break; + case AT_BOUGHT_OF_ETERNALS: + questId = QUEST_BOUGHT_OF_ETERNALS; + orphanId = ORPHAN_HUMAN; + break; + case AT_SPOOKY_LIGHTHOUSE: + questId = QUEST_SPOOKY_LIGHTHOUSE; + orphanId = ORPHAN_HUMAN; + break; + case AT_STONEWROUGHT_DAM: + questId = QUEST_STONEWROUGHT_DAM; + orphanId = ORPHAN_HUMAN; + break; + case AT_DARK_PORTAL: + questId = player->GetTeam() == ALLIANCE ? QUEST_DARK_PORTAL_A : QUEST_DARK_PORTAL_H; + orphanId = player->GetTeam() == ALLIANCE ? ORPHAN_DRAENEI : ORPHAN_BLOOD_ELF; + break; + } + + if (questId && orphanId && getOrphanGUID(player, orphanId) && player->GetQuestStatus(questId) == QUEST_STATUS_INCOMPLETE) + player->AreaExploredOrEventHappens(questId); + + return true; + } +}; + +/*###### +## npc_cw_area_trigger +######*/ +class npc_cw_area_trigger : public CreatureScript +{ + public: + npc_cw_area_trigger() : CreatureScript("npc_cw_area_trigger") {} + + struct npc_cw_area_triggerAI : public ScriptedAI + { + npc_cw_area_triggerAI(Creature* creature) : ScriptedAI (creature) + { + me->SetDisplayId(DISPLAY_INVISIBLE); + } + + void MoveInLineOfSight(Unit* who) + { + if (who && me->GetDistance2d(who) < 20.0f) + if (Player* player = who->ToPlayer()) + if (player->HasAura(SPELL_ORPHAN_OUT)) + { + uint32 questId = 0; + uint32 orphanId = 0; + switch (me->GetEntry()) + { + case NPC_CAVERNS_OF_TIME_CW_TRIGGER: + questId = player->GetTeam() == ALLIANCE ? QUEST_TIME_TO_VISIT_THE_CAVERNS_A : QUEST_TIME_TO_VISIT_THE_CAVERNS_H; + orphanId = player->GetTeam() == ALLIANCE ? ORPHAN_DRAENEI : ORPHAN_BLOOD_ELF; + break; + case NPC_EXODAR_01_CW_TRIGGER: + questId = QUEST_THE_SEAT_OF_THE_NARUU; + orphanId = ORPHAN_DRAENEI; + break; + case NPC_EXODAR_02_CW_TRIGGER: + questId = QUEST_CALL_ON_THE_FARSEER; + orphanId = ORPHAN_DRAENEI; + break; + case NPC_AERIS_LANDING_CW_TRIGGER: + questId = QUEST_JHEEL_IS_AT_AERIS_LANDING; + orphanId = ORPHAN_DRAENEI; + break; + case NPC_AUCHINDOUN_CW_TRIGGER: + questId = QUEST_AUCHINDOUN_AND_THE_RING; + orphanId = ORPHAN_DRAENEI; + break; + case NPC_SPOREGGAR_CW_TRIGGER: + questId = QUEST_HCHUU_AND_THE_MUSHROOM_PEOPLE; + orphanId = ORPHAN_BLOOD_ELF; + break; + case NPC_THRONE_OF_ELEMENTS_CW_TRIGGER: + questId = QUEST_VISIT_THE_THRONE_OF_ELEMENTS; + orphanId = ORPHAN_BLOOD_ELF; + break; + case NPC_SILVERMOON_01_CW_TRIGGER: + if (player->GetQuestStatus(QUEST_NOW_WHEN_I_GROW_UP) == QUEST_STATUS_INCOMPLETE && getOrphanGUID(player, ORPHAN_BLOOD_ELF)) + { + player->AreaExploredOrEventHappens(QUEST_NOW_WHEN_I_GROW_UP); + if (player->GetQuestStatus(QUEST_NOW_WHEN_I_GROW_UP) == QUEST_STATUS_COMPLETE) + if (Creature* samuro = me->FindNearestCreature(25151, 20.0f)) + { + uint32 emote = 0; + switch(urand(1,5)) + { + case 1: + emote = EMOTE_ONESHOT_WAVE; + break; + case 2: + emote = EMOTE_ONESHOT_ROAR; + break; + case 3: + emote = EMOTE_ONESHOT_FLEX; + break; + case 4: + emote = EMOTE_ONESHOT_SALUTE; + break; + case 5: + emote = EMOTE_ONESHOT_DANCE; + break; + } + samuro->HandleEmoteCommand(emote); + } + } + break; + } + if (questId && orphanId && getOrphanGUID(player, orphanId) && player->GetQuestStatus(questId) == QUEST_STATUS_INCOMPLETE) + player->AreaExploredOrEventHappens(questId); + } + } + }; + + CreatureAI* GetAI(Creature* creature) const + { + return new npc_cw_area_triggerAI(creature); + } +}; + +/*###### +## npc_grizzlemaw_cw_trigger +######*/ +class npc_grizzlemaw_cw_trigger : public CreatureScript +{ + public: + npc_grizzlemaw_cw_trigger() : CreatureScript("npc_grizzlemaw_cw_trigger") {} + + struct npc_grizzlemaw_cw_triggerAI : public ScriptedAI + { + npc_grizzlemaw_cw_triggerAI(Creature* creature) : ScriptedAI (creature) + { + me->SetDisplayId(DISPLAY_INVISIBLE); + } + + void MoveInLineOfSight(Unit* who) + { + if (who && who->GetDistance2d(me) < 10.0f) + if (Player* player = who->ToPlayer()) + if (player->GetQuestStatus(QUEST_HOME_OF_THE_BEAR_MEN) == QUEST_STATUS_INCOMPLETE) + if (Creature* orphan = Creature::GetCreature(*me, getOrphanGUID(player, ORPHAN_WOLVAR))) + { + player->AreaExploredOrEventHappens(QUEST_HOME_OF_THE_BEAR_MEN); + orphan->AI()->Talk(TEXT_WOLVAR_ORPHAN_10); + } + } + }; + + CreatureAI* GetAI(Creature* creature) const + { + return new npc_grizzlemaw_cw_triggerAI(creature); + } +}; + +void AddSC_event_childrens_week() +{ + new npc_elder_kekek(); + new npc_high_oracle_soo_roo(); + new npc_winterfin_playmate(); + new npc_snowfall_glade_playmate(); + new npc_the_etymidian(); + new npc_the_biggest_tree(); + new at_bring_your_orphan_to(); + new npc_grizzlemaw_cw_trigger(); + new npc_cw_area_trigger(); + new npc_alexstraza_the_lifebinder(); +} diff --git a/src/server/scripts/Events/event.cpp b/src/server/scripts/Events/event.cpp new file mode 100644 index 00000000000..22334f8d365 --- /dev/null +++ b/src/server/scripts/Events/event.cpp @@ -0,0 +1,25 @@ +/* + * Copyright (C) 2008-2012 TrinityCore <http://www.trinitycore.org/> + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#include "ScriptPCH.h" + +void AddSC_event_childrens_week(); + +void AddSC_event_scripts() +{ + AddSC_event_childrens_week(); +} diff --git a/src/server/scripts/Examples/example_gossip_codebox.cpp b/src/server/scripts/Examples/example_gossip_codebox.cpp index a5627c68ff6..d6936c8fb9e 100644 --- a/src/server/scripts/Examples/example_gossip_codebox.cpp +++ b/src/server/scripts/Examples/example_gossip_codebox.cpp @@ -72,7 +72,7 @@ class example_gossip_codebox : public CreatureScript return true; } - bool OnGossipSelectCode(Player* player, Creature* creature, uint32 sender, uint32 action, const char* code) + bool OnGossipSelectCode(Player* player, Creature* creature, uint32 sender, uint32 action, char const* code) { player->PlayerTalkClass->ClearMenus(); if (sender == GOSSIP_SENDER_MAIN) @@ -80,7 +80,7 @@ class example_gossip_codebox : public CreatureScript switch (action) { case GOSSIP_ACTION_INFO_DEF+1: - if (std::strcmp(code, player->GetName()) != 0) + if (player->GetName() != code) { DoScriptText(SAY_WRONG, creature); creature->CastSpell(player, SPELL_POLYMORPH, true); diff --git a/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/boss_archimonde.cpp b/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/boss_archimonde.cpp index ee988accbac..1c91d78cd29 100644 --- a/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/boss_archimonde.cpp +++ b/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/boss_archimonde.cpp @@ -129,7 +129,6 @@ public: } else CheckTimer -= diff; } }; - }; /* This script is merely a placeholder for the Doomfire that triggers Doomfire spell. It will @@ -220,7 +219,6 @@ public: } else ChangeTargetTimer -= diff; } }; - }; /* Finally, Archimonde's script. His script isn't extremely complex, most are simply spells on timers. @@ -315,8 +313,8 @@ public: { Talk(SAY_SLAY); - if (victim && (victim->GetTypeId() == TYPEID_PLAYER)) - GainSoulCharge(CAST_PLR(victim)); + if (victim && victim->GetTypeId() == TYPEID_PLAYER) + GainSoulCharge(victim->ToPlayer()); } void GainSoulCharge(Player* victim) @@ -360,13 +358,13 @@ public: if (victim && me->IsWithinDistInMap(victim, me->GetAttackDistance(victim))) return false; - std::list<HostileReference*>& m_threatlist = me->getThreatManager().getThreatList(); - if (m_threatlist.empty()) + ThreatContainer::StorageType const &threatlist = me->getThreatManager().getThreatList(); + if (threatlist.empty()) return false; std::list<Unit*> targets; - std::list<HostileReference*>::const_iterator itr = m_threatlist.begin(); - for (; itr != m_threatlist.end(); ++itr) + ThreatContainer::StorageType::const_iterator itr = threatlist.begin(); + for (; itr != threatlist.end(); ++itr) { Unit* unit = Unit::GetUnit(*me, (*itr)->getUnitGuid()); if (unit && unit->isAlive()) @@ -637,13 +635,8 @@ public: DoMeleeAttackIfReady(); } - - void WaypointReached(uint32 /*waypointId*/) - { - - } + void WaypointReached(uint32 /*waypointId*/) { } }; - }; void AddSC_boss_archimonde() diff --git a/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/hyjal.cpp b/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/hyjal.cpp index ee7ef383603..48dd847b190 100644 --- a/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/hyjal.cpp +++ b/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/hyjal.cpp @@ -236,7 +236,7 @@ public: uint32 AzgalorEvent = ai->GetInstanceData(DATA_AZGALOREVENT); // Only let them get item if Azgalor is dead. - if (AzgalorEvent == DONE && !player->HasItemCount(ITEM_TEAR_OF_GODDESS, 1)) + if (AzgalorEvent == DONE && !player->HasItemCount(ITEM_TEAR_OF_GODDESS)) player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_ITEM_TYRANDE, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF); player->SEND_GOSSIP_MENU(907, creature->GetGUID()); return true; diff --git a/src/server/scripts/Kalimdor/CavernsOfTime/DarkPortal/dark_portal.cpp b/src/server/scripts/Kalimdor/CavernsOfTime/DarkPortal/dark_portal.cpp index ee8c4d1bae1..bed3cde6fa4 100644 --- a/src/server/scripts/Kalimdor/CavernsOfTime/DarkPortal/dark_portal.cpp +++ b/src/server/scripts/Kalimdor/CavernsOfTime/DarkPortal/dark_portal.cpp @@ -388,13 +388,13 @@ public: if (creature->isQuestGiver()) player->PrepareQuestMenu(creature->GetGUID()); - if (player->GetQuestStatus(QUEST_OPENING_PORTAL) == QUEST_STATUS_INCOMPLETE && !player->HasItemCount(ITEM_CHRONO_BEACON, 1)) + if (player->GetQuestStatus(QUEST_OPENING_PORTAL) == QUEST_STATUS_INCOMPLETE && !player->HasItemCount(ITEM_CHRONO_BEACON)) { player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_ITEM_OBTAIN, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1); player->SEND_GOSSIP_MENU(10000, creature->GetGUID()); return true; } - else if (player->GetQuestRewardStatus(QUEST_OPENING_PORTAL) && !player->HasItemCount(ITEM_CHRONO_BEACON, 1)) + else if (player->GetQuestRewardStatus(QUEST_OPENING_PORTAL) && !player->HasItemCount(ITEM_CHRONO_BEACON)) { player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_ITEM_OBTAIN, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1); player->SEND_GOSSIP_MENU(10001, creature->GetGUID()); diff --git a/src/server/scripts/Kalimdor/CavernsOfTime/EscapeFromDurnholdeKeep/old_hillsbrad.cpp b/src/server/scripts/Kalimdor/CavernsOfTime/EscapeFromDurnholdeKeep/old_hillsbrad.cpp index 3690e87354d..0158d470ef9 100644 --- a/src/server/scripts/Kalimdor/CavernsOfTime/EscapeFromDurnholdeKeep/old_hillsbrad.cpp +++ b/src/server/scripts/Kalimdor/CavernsOfTime/EscapeFromDurnholdeKeep/old_hillsbrad.cpp @@ -79,7 +79,7 @@ public: player->PrepareQuestMenu(creature->GetGUID()); InstanceScript* instance = creature->GetInstanceScript(); - if (instance && instance->GetData(TYPE_BARREL_DIVERSION) != DONE && !player->HasItemCount(ITEM_ENTRY_BOMBS, 1)) + if (instance && instance->GetData(TYPE_BARREL_DIVERSION) != DONE && !player->HasItemCount(ITEM_ENTRY_BOMBS)) player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_HELLO_EROZION1, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1); if (player->GetQuestStatus(QUEST_ENTRY_RETURN) == QUEST_STATUS_COMPLETE) diff --git a/src/server/scripts/Kalimdor/boss_azuregos.cpp b/src/server/scripts/Kalimdor/boss_azuregos.cpp index ec098951c03..3b431d55a2c 100644 --- a/src/server/scripts/Kalimdor/boss_azuregos.cpp +++ b/src/server/scripts/Kalimdor/boss_azuregos.cpp @@ -90,9 +90,9 @@ public: if (TeleportTimer <= diff) { DoScriptText(SAY_TELEPORT, me); - std::list<HostileReference*>& threatlist = me->getThreatManager().getThreatList(); - std::list<HostileReference*>::const_iterator i = threatlist.begin(); - for (i = threatlist.begin(); i!= threatlist.end(); ++i) + ThreatContainer::StorageType threatlist = me->getThreatManager().getThreatList(); + ThreatContainer::StorageType::const_iterator i = threatlist.begin(); + for (i = threatlist.begin(); i != threatlist.end(); ++i) { Unit* unit = Unit::GetUnit(*me, (*i)->getUnitGuid()); if (unit && (unit->GetTypeId() == TYPEID_PLAYER)) @@ -158,7 +158,6 @@ public: DoMeleeAttackIfReady(); } }; - }; void AddSC_boss_azuregos() diff --git a/src/server/scripts/Kalimdor/feralas.cpp b/src/server/scripts/Kalimdor/feralas.cpp index 4fcd20951c9..c1e247044f7 100644 --- a/src/server/scripts/Kalimdor/feralas.cpp +++ b/src/server/scripts/Kalimdor/feralas.cpp @@ -27,6 +27,7 @@ EndScriptData */ #include "ScriptedCreature.h" #include "ScriptedEscortAI.h" #include "ScriptedGossip.h" +#include "SpellScript.h" /*###### ## npc_gregan_brewspewer @@ -202,6 +203,39 @@ public: }; +enum GordunniTrap +{ + GO_GORDUNNI_DIRT_MOUND = 144064, +}; + +class spell_gordunni_trap : public SpellScriptLoader +{ + public: + spell_gordunni_trap() : SpellScriptLoader("spell_gordunni_trap") { } + + class spell_gordunni_trap_SpellScript : public SpellScript + { + PrepareSpellScript(spell_gordunni_trap_SpellScript); + + void HandleDummy() + { + if (Unit* caster = GetCaster()) + if (GameObject* chest = caster->SummonGameObject(GO_GORDUNNI_DIRT_MOUND, caster->GetPositionX(), caster->GetPositionY(), caster->GetPositionZ(), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0)) + chest->SetSpellId(GetSpellInfo()->Id); + } + + void Register() + { + OnCast += SpellCastFn(spell_gordunni_trap_SpellScript::HandleDummy); + } + }; + + SpellScript* GetSpellScript() const + { + return new spell_gordunni_trap_SpellScript(); + } +}; + /*###### ## AddSC ######*/ @@ -211,4 +245,5 @@ void AddSC_feralas() new npc_gregan_brewspewer(); new npc_oox22fe(); new npc_screecher_spirit(); + new spell_gordunni_trap(); } diff --git a/src/server/scripts/Kalimdor/silithus.cpp b/src/server/scripts/Kalimdor/silithus.cpp index bad278f51c7..45a2fad9999 100644 --- a/src/server/scripts/Kalimdor/silithus.cpp +++ b/src/server/scripts/Kalimdor/silithus.cpp @@ -1289,37 +1289,37 @@ class go_wind_stone : public GameObjectScript { case TEMPLAR: { - if (player->HasItemCount(ITEM_TEMPLAR_FIRE, 1)) + if (player->HasItemCount(ITEM_TEMPLAR_FIRE)) result |= FIRE; - if (player->HasItemCount(ITEM_TEMPLAR_WATER, 1)) + if (player->HasItemCount(ITEM_TEMPLAR_WATER)) result |= WATER; - if (player->HasItemCount(ITEM_TEMPLAR_EARTH, 1)) + if (player->HasItemCount(ITEM_TEMPLAR_EARTH)) result |= EARTH; - if (player->HasItemCount(ITEM_TEMPLAR_AIR, 1)) + if (player->HasItemCount(ITEM_TEMPLAR_AIR)) result |= AIR; break; } case DUKE: { - if (player->HasItemCount(ITEM_DUKE_FIRE, 1)) + if (player->HasItemCount(ITEM_DUKE_FIRE)) result |= FIRE; - if (player->HasItemCount(ITEM_DUKE_WATER, 1)) + if (player->HasItemCount(ITEM_DUKE_WATER)) result |= WATER; - if (player->HasItemCount(ITEM_DUKE_EARTH, 1)) + if (player->HasItemCount(ITEM_DUKE_EARTH)) result |= EARTH; - if (player->HasItemCount(ITEM_DUKE_AIR, 1)) + if (player->HasItemCount(ITEM_DUKE_AIR)) result |= AIR; break; } case ROYAL: { - if (player->HasItemCount(ITEM_ROYAL_FIRE, 1)) + if (player->HasItemCount(ITEM_ROYAL_FIRE)) result |= FIRE; - if (player->HasItemCount(ITEM_ROYAL_WATER, 1)) + if (player->HasItemCount(ITEM_ROYAL_WATER)) result |= WATER; - if (player->HasItemCount(ITEM_ROYAL_EARTH, 1)) + if (player->HasItemCount(ITEM_ROYAL_EARTH)) result |= EARTH; - if (player->HasItemCount(ITEM_ROYAL_AIR, 1)) + if (player->HasItemCount(ITEM_ROYAL_AIR)) result |= AIR; break; } diff --git a/src/server/scripts/Northrend/ChamberOfAspects/RubySanctum/boss_halion.cpp b/src/server/scripts/Northrend/ChamberOfAspects/RubySanctum/boss_halion.cpp index 6ba13014585..82739c0026a 100644 --- a/src/server/scripts/Northrend/ChamberOfAspects/RubySanctum/boss_halion.cpp +++ b/src/server/scripts/Northrend/ChamberOfAspects/RubySanctum/boss_halion.cpp @@ -113,6 +113,8 @@ enum Spells SPELL_SUMMON_EXIT_PORTALS = 74805, // Custom spell created in spell_dbc. SPELL_TWILIGHT_MENDING = 75509, SPELL_TWILIGHT_REALM = 74807, + SPELL_DUSK_SHROUD = 75476, + SPELL_TWILIGHT_PRECISION = 78243, SPELL_COPY_DAMAGE = 74810 // Aura not found in DBCs. }; @@ -226,19 +228,24 @@ struct generic_halionAI : public BossAI { generic_halionAI(Creature* creature, uint32 bossId) : BossAI(creature, bossId), _canEvade(false) { } - void EnterCombat(Unit* /*who*/) + void EnterCombat(Unit* who) { - Talk(SAY_AGGRO); - _EnterCombat(); + BossAI::EnterCombat(who); _canEvade = false; - events.Reset(); events.ScheduleEvent(EVENT_CLEAVE, urand(8000, 10000)); + events.ScheduleEvent(EVENT_TAIL_LASH, 10000); + } + + void Reset() + { + _canEvade = false; + BossAI::Reset(); } void EnterEvadeMode() { + BossAI::EnterEvadeMode(); instance->SendEncounterUnit(ENCOUNTER_FRAME_DISENGAGE, me); - _EnterEvadeMode(); } void ExecuteEvent(uint32 const eventId) @@ -249,6 +256,10 @@ struct generic_halionAI : public BossAI DoCastVictim(SPELL_CLEAVE); events.ScheduleEvent(EVENT_CLEAVE, urand(8000, 10000)); break; + case EVENT_TAIL_LASH: + DoCastAOE(SPELL_TAIL_LASH); + events.ScheduleEvent(EVENT_TAIL_LASH, 10000); + break; } } @@ -297,52 +308,54 @@ class boss_halion : public CreatureScript struct boss_halionAI : public generic_halionAI { - boss_halionAI(Creature* creature) : generic_halionAI(creature, DATA_HALION) { } + boss_halionAI(Creature* creature) : generic_halionAI(creature, DATA_HALION) + { + me->SetHomePosition(HalionSpawnPos); + } void Reset() { generic_halionAI::Reset(); me->SetReactState(REACT_DEFENSIVE); - - instance->SendEncounterUnit(ENCOUNTER_FRAME_DISENGAGE, me); - me->RemoveAurasDueToSpell(SPELL_TWILIGHT_PHASING); me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); + me->AddAura(SPELL_TWILIGHT_PRECISION, me); } void EnterEvadeMode() { // Phase 1: We always can evade. Phase 2 & 3: We can evade if and only if the controller tells us to. - // Controller has absolute priority over the phasemask. if ((events.GetPhaseMask() & PHASE_ONE_MASK) || _canEvade) generic_halionAI::EnterEvadeMode(); } void EnterCombat(Unit* who) { + Talk(SAY_AGGRO); + + events.Reset(); + events.SetPhase(PHASE_ONE); + generic_halionAI::EnterCombat(who); instance->SendEncounterUnit(ENCOUNTER_FRAME_ENGAGE, me, 1); instance->SetBossState(DATA_HALION, IN_PROGRESS); - events.SetPhase(PHASE_ONE); - events.ScheduleEvent(EVENT_ACTIVATE_FIREWALL, 10000); + events.ScheduleEvent(EVENT_ACTIVATE_FIREWALL, 5000); events.ScheduleEvent(EVENT_FLAME_BREATH, urand(10000, 12000)); events.ScheduleEvent(EVENT_METEOR_STRIKE, urand(20000, 25000)); events.ScheduleEvent(EVENT_FIERY_COMBUSTION, urand(15000, 18000)); - events.ScheduleEvent(EVENT_TAIL_LASH, 10000); if (Creature* controller = ObjectAccessor::GetCreature(*me, instance->GetData64(DATA_HALION_CONTROLLER))) controller->AI()->SetData(DATA_FIGHT_PHASE, PHASE_ONE); } - void JustDied(Unit* /*killer*/) + void JustDied(Unit* killer) { - _JustDied(); + BossAI::JustDied(killer); Talk(SAY_DEATH); instance->SendEncounterUnit(ENCOUNTER_FRAME_DISENGAGE, me); - me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); if (Creature* controller = ObjectAccessor::GetCreature(*me, instance->GetData64(DATA_HALION_CONTROLLER))) me->Kill(controller); @@ -356,7 +369,7 @@ class boss_halion : public CreatureScript { events.SetPhase(PHASE_TWO); Talk(SAY_PHASE_TWO); - + me->CastStop(); me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); DoCast(me, SPELL_TWILIGHT_PHASING); @@ -390,21 +403,15 @@ class boss_halion : public CreatureScript switch (eventId) { case EVENT_ACTIVATE_FIREWALL: - { - // Flame ring is activated 10 seconds after starting encounter, DOOR_TYPE_ROOM is only instant. + // Flame ring is activated 5 seconds after starting encounter, DOOR_TYPE_ROOM is only instant. for (uint8 i = DATA_FLAME_RING; i <= DATA_TWILIGHT_FLAME_RING; ++i) if (GameObject* flameRing = ObjectAccessor::GetGameObject(*me, instance->GetData64(i))) instance->HandleGameObject(instance->GetData64(DATA_FLAME_RING), false, flameRing); break; - } case EVENT_FLAME_BREATH: DoCast(me, SPELL_FLAME_BREATH); events.ScheduleEvent(EVENT_FLAME_BREATH, 25000); break; - case EVENT_TAIL_LASH: - DoCastAOE(SPELL_TAIL_LASH); - events.ScheduleEvent(EVENT_TAIL_LASH, 10000); - break; case EVENT_METEOR_STRIKE: { if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 0.0f, true, -SPELL_TWILIGHT_REALM)) @@ -466,29 +473,32 @@ class boss_twilight_halion : public CreatureScript if (!halion) return; - // We use explicit targeting here to avoid conditions + SPELL_ATTR6_CANT_TARGET_SELF. // Using AddAura because no spell cast packet in sniffs. - halion->AddAura(SPELL_COPY_DAMAGE, me); + halion->AddAura(SPELL_COPY_DAMAGE, me); // We use explicit targeting here to avoid conditions + SPELL_ATTR6_CANT_TARGET_SELF. me->AddAura(SPELL_COPY_DAMAGE, halion); + me->AddAura(SPELL_DUSK_SHROUD, me); me->SetHealth(halion->GetHealth()); me->SetPhaseMask(0x20, true); me->SetReactState(REACT_AGGRESSIVE); + } - instance->SendEncounterUnit(ENCOUNTER_FRAME_ENGAGE, me, 2); - + void EnterCombat(Unit* who) + { events.Reset(); events.SetPhase(PHASE_TWO); + + generic_halionAI::EnterCombat(who); + events.ScheduleEvent(EVENT_DARK_BREATH, urand(10000, 15000)); events.ScheduleEvent(EVENT_SOUL_CONSUMPTION, 20000); - events.ScheduleEvent(EVENT_TAIL_LASH, 10000); - } - void EnterEvadeMode() - { - // We don't care about evading, we will be despawned. + instance->SendEncounterUnit(ENCOUNTER_FRAME_ENGAGE, me, 2); } + // Never evade + void EnterEvadeMode() { } + void KilledUnit(Unit* victim) { if (victim->GetTypeId() == TYPEID_PLAYER) @@ -565,10 +575,6 @@ class boss_twilight_halion : public CreatureScript DoCast(target, SPELL_SOUL_CONSUMPTION); events.ScheduleEvent(EVENT_SOUL_CONSUMPTION, 20000); break; - case EVENT_TAIL_LASH: - DoCastAOE(SPELL_TAIL_LASH); - events.ScheduleEvent(EVENT_TAIL_LASH, 10000); - break; default: generic_halionAI::ExecuteEvent(eventId); break; @@ -1186,10 +1192,19 @@ class npc_living_inferno : public CreatureScript { npc_living_infernoAI(Creature* creature) : ScriptedAI(creature) { } - void JustSummoned(Creature* /*summoner*/) + void IsSummonedBy(Unit* /*summoner*/) { me->SetInCombatWithZone(); - DoCast(me, SPELL_BLAZING_AURA); + me->CastSpell(me, SPELL_BLAZING_AURA, true); + + if (InstanceScript* instance = me->GetInstanceScript()) + if (Creature* controller = ObjectAccessor::GetCreature(*me, instance->GetData64(DATA_HALION_CONTROLLER))) + controller->AI()->JustSummoned(me); + } + + void JustDied(Unit* /*killer*/) + { + me->DespawnOrUnsummon(1); } }; @@ -1220,6 +1235,18 @@ class npc_living_ember : public CreatureScript _hasEnraged = false; } + void IsSummonedBy(Unit* /*summoner*/) + { + if (InstanceScript* instance = me->GetInstanceScript()) + if (Creature* controller = ObjectAccessor::GetCreature(*me, instance->GetData64(DATA_HALION_CONTROLLER))) + controller->AI()->JustSummoned(me); + } + + void JustDied(Unit* /*killer*/) + { + me->DespawnOrUnsummon(1); + } + void UpdateAI(uint32 const diff) { if (!UpdateVictim() || me->HasUnitState(UNIT_STATE_CASTING)) @@ -1714,7 +1741,7 @@ void AddSC_boss_halion() { new boss_halion(); new boss_twilight_halion(); - + new npc_halion_controller(); new npc_meteor_strike_initial(); new npc_meteor_strike(); diff --git a/src/server/scripts/Northrend/ChamberOfAspects/RubySanctum/instance_ruby_sanctum.cpp b/src/server/scripts/Northrend/ChamberOfAspects/RubySanctum/instance_ruby_sanctum.cpp index a6b50467538..bf48132b2b2 100644 --- a/src/server/scripts/Northrend/ChamberOfAspects/RubySanctum/instance_ruby_sanctum.cpp +++ b/src/server/scripts/Northrend/ChamberOfAspects/RubySanctum/instance_ruby_sanctum.cpp @@ -45,7 +45,6 @@ class instance_ruby_sanctum : public InstanceMapScript OrbCarrierGUID = 0; OrbRotationFocusGUID = 0; HalionControllerGUID = 0; - CombatStalkerGUID = 0; CrystalChannelTargetGUID = 0; XerestraszaGUID = 0; BaltharusSharedHealth = 0; @@ -56,6 +55,13 @@ class instance_ruby_sanctum : public InstanceMapScript memset(BurningTreeGUID, 0, 4 * sizeof(uint64)); } + void OnPlayerEnter(Player* /*player*/) + { + if (!GetData64(DATA_HALION_CONTROLLER) && GetBossState(DATA_HALION) != DONE && GetBossState(DATA_GENERAL_ZARITHRIAN) == DONE) + if (Creature* halionController = instance->SummonCreature(NPC_HALION_CONTROLLER, HalionControllerSpawnPos)) + halionController->AI()->DoAction(ACTION_INTRO_HALION); + } + void OnCreatureCreate(Creature* creature) { switch (creature->GetEntry()) @@ -84,9 +90,6 @@ class instance_ruby_sanctum : public InstanceMapScript case NPC_ORB_ROTATION_FOCUS: OrbRotationFocusGUID = creature->GetGUID(); break; - case NPC_COMBAT_STALKER: - CombatStalkerGUID = creature->GetGUID(); - break; case NPC_BALTHARUS_TARGET: CrystalChannelTargetGUID = creature->GetGUID(); break; @@ -195,8 +198,6 @@ class instance_ruby_sanctum : public InstanceMapScript return FlameRingGUID; case DATA_TWILIGHT_FLAME_RING: return TwilightFlameRingGUID; - case DATA_COMBAT_STALKER: - return CombatStalkerGUID; default: break; } @@ -207,14 +208,7 @@ class instance_ruby_sanctum : public InstanceMapScript bool SetBossState(uint32 type, EncounterState state) { if (!InstanceScript::SetBossState(type, state)) - { - // Summon Halion on instance loading if conditions are met. Without those lines, - // InstanceScript::SetBossState returns false, thus preventing the switch from being called. - if (type == DATA_HALION && state != DONE && GetBossState(DATA_GENERAL_ZARITHRIAN) == DONE && !GetData64(DATA_HALION_CONTROLLER)) - if (Creature* halionController = instance->SummonCreature(NPC_HALION_CONTROLLER, HalionControllerSpawnPos)) - halionController->AI()->DoAction(ACTION_INTRO_HALION); return false; - } switch (type) { @@ -353,7 +347,6 @@ class instance_ruby_sanctum : public InstanceMapScript uint64 BurningTreeGUID[4]; uint64 FlameRingGUID; uint64 TwilightFlameRingGUID; - uint64 CombatStalkerGUID; uint32 BaltharusSharedHealth; }; diff --git a/src/server/scripts/Northrend/ChamberOfAspects/RubySanctum/ruby_sanctum.h b/src/server/scripts/Northrend/ChamberOfAspects/RubySanctum/ruby_sanctum.h index 7eb1b73721c..47a55f9035f 100644 --- a/src/server/scripts/Northrend/ChamberOfAspects/RubySanctum/ruby_sanctum.h +++ b/src/server/scripts/Northrend/ChamberOfAspects/RubySanctum/ruby_sanctum.h @@ -52,7 +52,6 @@ enum DataTypes DATA_BURNING_TREE_4 = 16, DATA_FLAME_RING = 17, DATA_TWILIGHT_FLAME_RING = 18, - DATA_COMBAT_STALKER = 19, }; enum SharedActions @@ -97,7 +96,7 @@ enum CreaturesIds NPC_METEOR_STRIKE_FLAME = 40055, NPC_COMBUSTION = 40001, NPC_CONSUMPTION = 40135, - NPC_COMBAT_STALKER = 40151, + NPC_COMBAT_STALKER = 40151, // Seen in sniffs but not used, so no wonder. // Xerestrasza NPC_XERESTRASZA = 40429, diff --git a/src/server/scripts/Northrend/Naxxramas/boss_kelthuzad.cpp b/src/server/scripts/Northrend/Naxxramas/boss_kelthuzad.cpp index 10b40b490c4..c88377da3f3 100644 --- a/src/server/scripts/Northrend/Naxxramas/boss_kelthuzad.cpp +++ b/src/server/scripts/Northrend/Naxxramas/boss_kelthuzad.cpp @@ -59,7 +59,8 @@ enum Yells SAY_REQUEST_AID = -1533103, //start of phase 3 SAY_ANSWER_REQUEST = -1533104 //lich king answer }; -enum Event + +enum Events { EVENT_NONE, EVENT_BOLT, @@ -607,13 +608,17 @@ public: case EVENT_DETONATE: { std::vector<Unit*> unitList; - std::list<HostileReference*> *threatList = &me->getThreatManager().getThreatList(); - for (std::list<HostileReference*>::const_iterator itr = threatList->begin(); itr != threatList->end(); ++itr) + ThreatContainer::StorageType const &threatList = me->getThreatManager().getThreatList(); + for (ThreatContainer::StorageType::const_iterator itr = threatList.begin(); itr != threatList.end(); ++itr) { - if ((*itr)->getTarget()->GetTypeId() == TYPEID_PLAYER - && (*itr)->getTarget()->getPowerType() == POWER_MANA - && (*itr)->getTarget()->GetPower(POWER_MANA)) - unitList.push_back((*itr)->getTarget()); + Unit * const target = (*itr)->getTarget(); + + if (target->GetTypeId() == TYPEID_PLAYER + && target->getPowerType() == POWER_MANA + && target->GetPower(POWER_MANA)) + { + unitList.push_back(target); + } } if (!unitList.empty()) @@ -654,7 +659,6 @@ public: { return new boss_kelthuzadAI (creature); } - }; class at_kelthuzad_center : public AreaTriggerScript diff --git a/src/server/scripts/Northrend/Nexus/EyeOfEternity/boss_malygos.cpp b/src/server/scripts/Northrend/Nexus/EyeOfEternity/boss_malygos.cpp index 9f5eb8d879a..28f73ed14b0 100644 --- a/src/server/scripts/Northrend/Nexus/EyeOfEternity/boss_malygos.cpp +++ b/src/server/scripts/Northrend/Nexus/EyeOfEternity/boss_malygos.cpp @@ -305,8 +305,8 @@ public: summons.DespawnAll(); // players that used Hover Disk are no in the aggro list me->SetInCombatWithZone(); - std::list<HostileReference*> &m_threatlist = me->getThreatManager().getThreatList(); - for (std::list<HostileReference*>::const_iterator itr = m_threatlist.begin(); itr!= m_threatlist.end(); ++itr) + ThreatContainer::StorageType const& m_threatlist = me->getThreatManager().getThreatList(); + for (ThreatContainer::StorageType::const_iterator itr = m_threatlist.begin(); itr!= m_threatlist.end(); ++itr) { if (Unit* target = (*itr)->getTarget()) { @@ -683,8 +683,8 @@ class spell_malygos_vortex_visual : public SpellScriptLoader { if (Unit* caster = GetCaster()) { - std::list<HostileReference*> &m_threatlist = caster->getThreatManager().getThreatList(); - for (std::list<HostileReference*>::const_iterator itr = m_threatlist.begin(); itr!= m_threatlist.end(); ++itr) + ThreatContainer::StorageType const& m_threatlist = caster->getThreatManager().getThreatList(); + for (ThreatContainer::StorageType::const_iterator itr = m_threatlist.begin(); itr!= m_threatlist.end(); ++itr) { if (Unit* target = (*itr)->getTarget()) { diff --git a/src/server/scripts/Northrend/Nexus/Oculus/oculus.cpp b/src/server/scripts/Northrend/Nexus/Oculus/oculus.cpp index 28595571a2f..f00369fd9e2 100644 --- a/src/server/scripts/Northrend/Nexus/Oculus/oculus.cpp +++ b/src/server/scripts/Northrend/Nexus/Oculus/oculus.cpp @@ -32,7 +32,7 @@ #define GOSSIP_ITEM_ETERNOS1 "I want to fly on the wings of the Bronze Flight" #define GOSSIP_ITEM_ETERNOS2 "What abilities do Amber Drakes have?" -#define HAS_ESSENCE(a) ((a)->HasItemCount(ITEM_EMERALD_ESSENCE, 1) || (a)->HasItemCount(ITEM_AMBER_ESSENCE, 1) || (a)->HasItemCount(ITEM_RUBY_ESSENCE, 1)) +#define HAS_ESSENCE(a) ((a)->HasItemCount(ITEM_EMERALD_ESSENCE) || (a)->HasItemCount(ITEM_AMBER_ESSENCE) || (a)->HasItemCount(ITEM_RUBY_ESSENCE)) enum GossipNPCs { diff --git a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_algalon_the_observer.cpp b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_algalon_the_observer.cpp index a0c00f73bff..7967a86039e 100644 --- a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_algalon_the_observer.cpp +++ b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_algalon_the_observer.cpp @@ -978,7 +978,7 @@ class go_celestial_planetarium_access : public GameObjectScript if (!lock->Index[i]) continue; - if (player->HasItemCount(lock->Index[i], 1)) + if (player->HasItemCount(lock->Index[i])) { hasKey = true; break; diff --git a/src/server/scripts/Northrend/sholazar_basin.cpp b/src/server/scripts/Northrend/sholazar_basin.cpp index 56ef25c5753..63960f13bb7 100644 --- a/src/server/scripts/Northrend/sholazar_basin.cpp +++ b/src/server/scripts/Northrend/sholazar_basin.cpp @@ -33,6 +33,7 @@ EndContentData */ #include "ScriptedGossip.h" #include "ScriptedEscortAI.h" #include "SpellScript.h" +#include "SpellAuras.h" /*###### ## npc_injured_rainspeaker_oracle @@ -470,11 +471,27 @@ public: enum utils { - NPC_HEMET = 27986, - NPC_HADRIUS = 28047, - NPC_TAMARA = 28568, - SPELL_OFFER = 51962, - QUEST_ENTRY = 12645, + NPC_HEMET = 27986, + NPC_HADRIUS = 28047, + NPC_TAMARA = 28568, + SPELL_OFFER = 51962, + QUEST_ENTRY = 12645, +}; + +enum NesingwaryChildrensWeek +{ + SPELL_ORPHAN_OUT = 58818, + + QUEST_THE_MIGHTY_HEMET_NESINGWARY = 13957, + + ORPHAN_WOLVAR = 33532, + + TEXT_WOLVAR_ORPHAN_6 = 6, + TEXT_WOLVAR_ORPHAN_7 = 7, + TEXT_WOLVAR_ORPHAN_8 = 8, + TEXT_WOLVAR_ORPHAN_9 = 9, + + TEXT_NESINGWARY_1 = 1, }; class npc_jungle_punch_target : public CreatureScript @@ -486,17 +503,86 @@ public: { npc_jungle_punch_targetAI(Creature* creature) : ScriptedAI(creature) {} - uint16 sayTimer; - uint8 sayStep; - void Reset() { sayTimer = 3500; sayStep = 0; + timer = 0; + phase = 0; + playerGUID = 0; + orphanGUID = 0; + } + + void MoveInLineOfSight(Unit* who) + { + if (!phase && who && who->GetDistance2d(me) < 10.0f) + if (Player* player = who->ToPlayer()) + if (player->GetQuestStatus(QUEST_THE_MIGHTY_HEMET_NESINGWARY) == QUEST_STATUS_INCOMPLETE) + { + playerGUID = player->GetGUID(); + if (Aura* orphanOut = player->GetAura(SPELL_ORPHAN_OUT)) + if (orphanOut->GetCaster() && orphanOut->GetCaster()->GetEntry() == ORPHAN_WOLVAR) + { + orphanGUID = orphanOut->GetCaster()->GetGUID(); + phase = 1; + } + } + } + + void proceedCwEvent(const uint32 diff) + { + if (timer <= diff) + { + Player* player = Player::GetPlayer(*me, playerGUID); + Creature* orphan = Creature::GetCreature(*me, orphanGUID); + + if(!orphan || !player) + { + Reset(); + return; + } + + switch(phase) + { + case 1: + orphan->GetMotionMaster()->MovePoint(0, me->GetPositionX() + cos(me->GetOrientation()) * 5, me->GetPositionY() + sin(me->GetOrientation()) * 5, me->GetPositionZ()); + orphan->AI()->Talk(TEXT_WOLVAR_ORPHAN_6); + timer = 5000; + break; + case 2: + orphan->SetFacingToObject(me); + orphan->AI()->Talk(TEXT_WOLVAR_ORPHAN_7); + timer = 5000; + break; + case 3: + Talk(TEXT_NESINGWARY_1); + timer = 5000; + break; + case 4: + orphan->AI()->Talk(TEXT_WOLVAR_ORPHAN_8); + timer = 5000; + break; + case 5: + orphan->AI()->Talk(TEXT_WOLVAR_ORPHAN_9); + timer = 5000; + break; + case 6: + orphan->GetMotionMaster()->MoveFollow(player, PET_FOLLOW_DIST, PET_FOLLOW_ANGLE); + player->GroupEventHappens(QUEST_THE_MIGHTY_HEMET_NESINGWARY, me); + Reset(); + return; + } + ++phase; + } + else + timer -= diff; } void UpdateAI(const uint32 uiDiff) { + if (phase) + proceedCwEvent(uiDiff); + if (!sayStep) return; @@ -588,6 +674,14 @@ public: break; } } + + private: + uint16 sayTimer; + uint8 sayStep; + uint32 timer; + int8 phase; + uint64 playerGUID; + uint64 orphanGUID; }; CreatureAI* GetAI(Creature* creature) const diff --git a/src/server/scripts/Northrend/storm_peaks.cpp b/src/server/scripts/Northrend/storm_peaks.cpp index 976a6e5dba5..1733af17580 100644 --- a/src/server/scripts/Northrend/storm_peaks.cpp +++ b/src/server/scripts/Northrend/storm_peaks.cpp @@ -19,6 +19,8 @@ #include "ScriptedCreature.h" #include "ScriptedGossip.h" #include "ScriptedEscortAI.h" +#include "SpellScript.h" +#include "SpellAuraEffects.h" #include "Vehicle.h" #include "CombatAI.h" @@ -564,6 +566,53 @@ class npc_hyldsmeet_protodrake : public CreatureScript } }; +enum CloseRift +{ + SPELL_DESPAWN_RIFT = 61665 +}; + +class spell_close_rift : public SpellScriptLoader +{ + public: + spell_close_rift() : SpellScriptLoader("spell_close_rift") { } + + class spell_close_rift_AuraScript : public AuraScript + { + PrepareAuraScript(spell_close_rift_AuraScript); + + bool Load() + { + _counter = 0; + return true; + } + + bool Validate(SpellInfo const* /*spell*/) + { + return sSpellMgr->GetSpellInfo(SPELL_DESPAWN_RIFT); + } + + void HandlePeriodic(AuraEffect const* /* aurEff */) + { + if (++_counter == 5) + GetTarget()->CastSpell((Unit*)NULL, SPELL_DESPAWN_RIFT, true); + } + + void Register() + { + OnEffectPeriodic += AuraEffectPeriodicFn(spell_close_rift_AuraScript::HandlePeriodic, EFFECT_0, SPELL_AURA_PERIODIC_TRIGGER_SPELL); + } + + private: + uint8 _counter; + + }; + + AuraScript* GetAuraScript() const + { + return new spell_close_rift_AuraScript(); + } +}; + void AddSC_storm_peaks() { new npc_agnetta_tyrsdottar(); @@ -574,4 +623,5 @@ void AddSC_storm_peaks() new npc_freed_protodrake(); new npc_icefang(); new npc_hyldsmeet_protodrake(); + new spell_close_rift(); } diff --git a/src/server/scripts/Northrend/wintergrasp.cpp b/src/server/scripts/Northrend/wintergrasp.cpp index 2aed813550d..d4a3f83ab70 100644 --- a/src/server/scripts/Northrend/wintergrasp.cpp +++ b/src/server/scripts/Northrend/wintergrasp.cpp @@ -559,7 +559,8 @@ public: { if (Battlefield* wg = sBattlefieldMgr->GetBattlefieldByBattleId(BATTLEFIELD_BATTLEID_WG)) if (Player* target = GetExplTargetUnit()->ToPlayer()) - if (target->GetTeamId() != wg->GetDefenderTeam() || target->HasAura(SPELL_WINTERGRASP_TELEPORT_TRIGGER)) + // check if we are in Wintergrasp at all, SotA uses same teleport spells + if ((target->GetZoneId() == 4197) && target->GetTeamId() != wg->GetDefenderTeam() || target->HasAura(SPELL_WINTERGRASP_TELEPORT_TRIGGER)) return SPELL_FAILED_BAD_TARGETS; return SPELL_CAST_OK; } diff --git a/src/server/scripts/OutdoorPvP/OutdoorPvPEP.cpp b/src/server/scripts/OutdoorPvP/OutdoorPvPEP.cpp index 2a94ddb3134..2e911406979 100755 --- a/src/server/scripts/OutdoorPvP/OutdoorPvPEP.cpp +++ b/src/server/scripts/OutdoorPvP/OutdoorPvPEP.cpp @@ -693,7 +693,7 @@ void OutdoorPvPEP::BuffTeams() { for (PlayerSet::iterator itr = m_players[0].begin(); itr != m_players[0].end(); ++itr) { - Player* player = *itr; + if (Player* player = ObjectAccessor::FindPlayer(*itr)) { for (int i = 0; i < 4; ++i) player->RemoveAurasDueToSpell(EP_AllianceBuffs[i]); @@ -703,7 +703,7 @@ void OutdoorPvPEP::BuffTeams() } for (PlayerSet::iterator itr = m_players[1].begin(); itr != m_players[1].end(); ++itr) { - Player* player = *itr; + if (Player* player = ObjectAccessor::FindPlayer(*itr)) { for (int i = 0; i < 4; ++i) player->RemoveAurasDueToSpell(EP_HordeBuffs[i]); diff --git a/src/server/scripts/OutdoorPvP/OutdoorPvPTF.cpp b/src/server/scripts/OutdoorPvP/OutdoorPvPTF.cpp index 9572125a4bd..fdf6533a64b 100755 --- a/src/server/scripts/OutdoorPvP/OutdoorPvPTF.cpp +++ b/src/server/scripts/OutdoorPvP/OutdoorPvPTF.cpp @@ -296,9 +296,12 @@ void OPvPCapturePointTF::ChangeState() uint32 alliance_towers = ((OutdoorPvPTF*)m_PvP)->GetAllianceTowersControlled(); if (alliance_towers < TF_TOWER_NUM) ((OutdoorPvPTF*)m_PvP)->SetAllianceTowersControlled(++alliance_towers); + sWorld->SendZoneText(OutdoorPvPTFBuffZones[0], sObjectMgr->GetTrinityStringForDBCLocale(LANG_OPVP_TF_CAPTURE_A)); + for (PlayerSet::iterator itr = m_activePlayers[0].begin(); itr != m_activePlayers[0].end(); ++itr) - (*itr)->AreaExploredOrEventHappens(TF_ALLY_QUEST); + if (Player* player = ObjectAccessor::FindPlayer(*itr)) + player->AreaExploredOrEventHappens(TF_ALLY_QUEST); break; } case OBJECTIVESTATE_HORDE: @@ -308,9 +311,12 @@ void OPvPCapturePointTF::ChangeState() uint32 horde_towers = ((OutdoorPvPTF*)m_PvP)->GetHordeTowersControlled(); if (horde_towers < TF_TOWER_NUM) ((OutdoorPvPTF*)m_PvP)->SetHordeTowersControlled(++horde_towers); + sWorld->SendZoneText(OutdoorPvPTFBuffZones[0], sObjectMgr->GetTrinityStringForDBCLocale(LANG_OPVP_TF_CAPTURE_H)); + for (PlayerSet::iterator itr = m_activePlayers[1].begin(); itr != m_activePlayers[1].end(); ++itr) - (*itr)->AreaExploredOrEventHappens(TF_HORDE_QUEST); + if (Player* player = ObjectAccessor::FindPlayer(*itr)) + player->AreaExploredOrEventHappens(TF_HORDE_QUEST); break; } case OBJECTIVESTATE_NEUTRAL: diff --git a/src/server/scripts/Outland/Auchindoun/ShadowLabyrinth/boss_murmur.cpp b/src/server/scripts/Outland/Auchindoun/ShadowLabyrinth/boss_murmur.cpp index 4f8fc917424..0f3bcce6493 100644 --- a/src/server/scripts/Outland/Auchindoun/ShadowLabyrinth/boss_murmur.cpp +++ b/src/server/scripts/Outland/Auchindoun/ShadowLabyrinth/boss_murmur.cpp @@ -80,8 +80,8 @@ public: void SonicBoomEffect() { - std::list<HostileReference*> t_list = me->getThreatManager().getThreatList(); - for (std::list<HostileReference*>::const_iterator itr = t_list.begin(); itr!= t_list.end(); ++itr) + ThreatContainer::StorageType const &t_list = me->getThreatManager().getThreatList(); + for (ThreatContainer::StorageType::const_iterator itr = t_list.begin(); itr!= t_list.end(); ++itr) { Unit* target = Unit::GetUnit(*me, (*itr)->getUnitGuid()); if (target && target->GetTypeId() == TYPEID_PLAYER) @@ -165,8 +165,8 @@ public: // Thundering Storm if (ThunderingStorm_Timer <= diff) { - std::list<HostileReference*>& m_threatlist = me->getThreatManager().getThreatList(); - for (std::list<HostileReference*>::const_iterator i = m_threatlist.begin(); i != m_threatlist.end(); ++i) + ThreatContainer::StorageType threatlist = me->getThreatManager().getThreatList(); + for (ThreatContainer::StorageType::const_iterator i = threatlist.begin(); i != threatlist.end(); ++i) if (Unit* target = Unit::GetUnit(*me, (*i)->getUnitGuid())) if (target->isAlive() && !me->IsWithinDist(target, 35, false)) DoCast(target, SPELL_THUNDERING_STORM, true); @@ -188,8 +188,8 @@ public: return; if (!me->IsWithinMeleeRange(me->getVictim())) { - std::list<HostileReference*>& m_threatlist = me->getThreatManager().getThreatList(); - for (std::list<HostileReference*>::const_iterator i = m_threatlist.begin(); i != m_threatlist.end(); ++i) + ThreatContainer::StorageType threatlist = me->getThreatManager().getThreatList(); + for (ThreatContainer::StorageType::const_iterator i = threatlist.begin(); i != threatlist.end(); ++i) if (Unit* target = Unit::GetUnit(*me, (*i)->getUnitGuid())) if (target->isAlive() && me->IsWithinMeleeRange(target)) { @@ -201,7 +201,6 @@ public: DoMeleeAttackIfReady(); } }; - }; void AddSC_boss_murmur() diff --git a/src/server/scripts/Outland/BlackTemple/boss_illidan.cpp b/src/server/scripts/Outland/BlackTemple/boss_illidan.cpp index 6fd6f61c061..f812b1b35cd 100644 --- a/src/server/scripts/Outland/BlackTemple/boss_illidan.cpp +++ b/src/server/scripts/Outland/BlackTemple/boss_illidan.cpp @@ -46,9 +46,9 @@ EndScriptData */ #define SOUND_AKAMA_LEAVE 11390 // Self explanatory -const char* SAY_KILL1 = "Who shall be next to taste my blades?!"; +char const* SAY_KILL1 = "Who shall be next to taste my blades?!"; #define SOUND_KILL1 11473 -const char* SAY_KILL2 = "This is too easy!"; +char const* SAY_KILL2 = "This is too easy!"; #define SOUND_KILL2 11472 // I think I'll fly now and let my subordinates take you on @@ -254,7 +254,6 @@ struct Yells }; static const Yells Conversation[22] = - { {11463, "Akama... your duplicity is hardly surprising. I should have slaughtered you and your malformed brethren long ago.", ILLIDAN_STORMRAGE, 8000, 0, true}, {0, "", ILLIDAN_STORMRAGE, 5000, 396, true}, @@ -464,7 +463,6 @@ public: DoMeleeAttackIfReady(); } }; - }; /************************************** Illidan's AI* **************************************/ @@ -614,7 +612,8 @@ public: void DeleteFromThreatList(uint64 TargetGUID) { - for (std::list<HostileReference*>::const_iterator itr = me->getThreatManager().getThreatList().begin(); itr != me->getThreatManager().getThreatList().end(); ++itr) + ThreatContainer::StorageType threatlist = me->getThreatManager().getThreatList(); + for (ThreatContainer::StorageType::const_iterator itr = threatlist.begin(); itr != threatlist.end(); ++itr) { if ((*itr)->getUnitGuid() == TargetGUID) { @@ -1151,7 +1150,6 @@ public: } } }; - }; /********************************** End of Illidan AI* *****************************************/ @@ -1378,7 +1376,6 @@ public: DoMeleeAttackIfReady(); } }; - }; class npc_akama_illidan : public CreatureScript @@ -1491,9 +1488,9 @@ public: void KillAllElites() { - std::list<HostileReference*>& threatList = me->getThreatManager().getThreatList(); + ThreatContainer::StorageType const &threatList = me->getThreatManager().getThreatList(); std::vector<Unit*> eliteList; - for (std::list<HostileReference*>::const_iterator itr = threatList.begin(); itr != threatList.end(); ++itr) + for (ThreatContainer::StorageType::const_iterator itr = threatList.begin(); itr != threatList.end(); ++itr) { Unit* unit = Unit::GetUnit(*me, (*itr)->getUnitGuid()); if (unit && unit->GetEntry() == ILLIDARI_ELITE) @@ -1649,7 +1646,8 @@ public: void HandleChannelSequence() { - Unit* Channel = NULL, *Spirit[2] = { NULL, NULL }; + Unit* Channel = NULL; + Unit* Spirit[2] = { NULL, NULL }; if (ChannelCount <= 5) { Channel = Unit::GetUnit(*me, ChannelGUID); @@ -1840,7 +1838,6 @@ public: { return new npc_akama_illidanAI(creature); } - }; void boss_illidan_stormrage::boss_illidan_stormrageAI::Reset() @@ -2000,7 +1997,6 @@ void boss_illidan_stormrage::boss_illidan_stormrageAI::HandleTalkSequence() Akama->SetPosition(x, y, z, 0.0f); Akama->MonsterMoveWithSpeed(x, y, z, 0); // Illidan must not die until Akama arrives. Akama->GetMotionMaster()->MoveChase(me); - } } break; @@ -2194,7 +2190,6 @@ public: me->SetDisplayId(21431);// appear when hit by Illidan's glaive } }; - }; class mob_parasitic_shadowfiend : public CreatureScript diff --git a/src/server/scripts/Outland/BlackTemple/boss_reliquary_of_souls.cpp b/src/server/scripts/Outland/BlackTemple/boss_reliquary_of_souls.cpp index ec9e4e116bf..5ab9dcab667 100644 --- a/src/server/scripts/Outland/BlackTemple/boss_reliquary_of_souls.cpp +++ b/src/server/scripts/Outland/BlackTemple/boss_reliquary_of_souls.cpp @@ -128,7 +128,6 @@ public: void JustDied(Unit* /*killer*/); }; - }; class boss_reliquary_of_souls : public CreatureScript @@ -233,9 +232,8 @@ public: if (!target) return; - std::list<HostileReference*>& m_threatlist = target->getThreatManager().getThreatList(); - std::list<HostileReference*>::const_iterator itr = m_threatlist.begin(); - for (; itr != m_threatlist.end(); ++itr) + ThreatContainer::StorageType threatlist = target->getThreatManager().getThreatList(); + for (ThreatContainer::StorageType::const_iterator itr = threatlist.begin(); itr != threatlist.end(); ++itr) { Unit* unit = Unit::GetUnit(*me, (*itr)->getUnitGuid()); if (unit) @@ -376,7 +374,6 @@ public: } else Timer -= diff; } }; - }; void npc_enslaved_soul::npc_enslaved_soulAI::JustDied(Unit* /*killer*/) @@ -453,12 +450,12 @@ public: void CastFixate() { - std::list<HostileReference*>& m_threatlist = me->getThreatManager().getThreatList(); - if (m_threatlist.empty()) + ThreatContainer::StorageType const &threatlist = me->getThreatManager().getThreatList(); + if (threatlist.empty()) return; // No point continuing if empty threatlist. std::list<Unit*> targets; - std::list<HostileReference*>::const_iterator itr = m_threatlist.begin(); - for (; itr != m_threatlist.end(); ++itr) + ThreatContainer::StorageType::const_iterator itr = threatlist.begin(); + for (; itr != threatlist.end(); ++itr) { Unit* unit = Unit::GetUnit(*me, (*itr)->getUnitGuid()); if (unit && unit->isAlive() && (unit->GetTypeId() == TYPEID_PLAYER)) // Only alive players @@ -511,7 +508,6 @@ public: DoMeleeAttackIfReady(); } }; - }; class boss_essence_of_desire : public CreatureScript @@ -615,7 +611,6 @@ public: DoMeleeAttackIfReady(); } }; - }; class boss_essence_of_anger : public CreatureScript @@ -716,7 +711,6 @@ public: DoMeleeAttackIfReady(); } }; - }; void AddSC_boss_reliquary_of_souls() diff --git a/src/server/scripts/Outland/BlackTemple/boss_supremus.cpp b/src/server/scripts/Outland/BlackTemple/boss_supremus.cpp index e34a229eea5..77d1c86951b 100644 --- a/src/server/scripts/Outland/BlackTemple/boss_supremus.cpp +++ b/src/server/scripts/Outland/BlackTemple/boss_supremus.cpp @@ -78,7 +78,6 @@ public: me->CastSpell(me, SPELL_MOLTEN_FLAME, true); } }; - }; class boss_supremus : public CreatureScript @@ -183,9 +182,9 @@ public: uint32 health = 0; Unit* target = NULL; - std::list<HostileReference*>& m_threatlist = me->getThreatManager().getThreatList(); - std::list<HostileReference*>::const_iterator i = m_threatlist.begin(); - for (i = m_threatlist.begin(); i!= m_threatlist.end(); ++i) + ThreatContainer::StorageType const &threatlist = me->getThreatManager().getThreatList(); + ThreatContainer::StorageType::const_iterator i = threatlist.begin(); + for (i = threatlist.begin(); i != threatlist.end(); ++i) { Unit* unit = Unit::GetUnit(*me, (*i)->getUnitGuid()); if (unit && me->IsWithinMeleeRange(unit)) @@ -258,7 +257,6 @@ public: DoMeleeAttackIfReady(); } }; - }; class npc_volcano : public CreatureScript @@ -303,9 +301,7 @@ public: } else wait -= diff; } - }; - }; void AddSC_boss_supremus() diff --git a/src/server/scripts/Outland/BlackTemple/boss_teron_gorefiend.cpp b/src/server/scripts/Outland/BlackTemple/boss_teron_gorefiend.cpp index 524992b3c44..9a200d07d2b 100644 --- a/src/server/scripts/Outland/BlackTemple/boss_teron_gorefiend.cpp +++ b/src/server/scripts/Outland/BlackTemple/boss_teron_gorefiend.cpp @@ -169,12 +169,12 @@ public: void CheckPlayers() { - std::list<HostileReference*>& m_threatlist = me->getThreatManager().getThreatList(); - if (m_threatlist.empty()) + ThreatContainer::StorageType const &threatlist = me->getThreatManager().getThreatList(); + if (threatlist.empty()) return; // No threat list. Don't continue. - std::list<HostileReference*>::const_iterator itr = m_threatlist.begin(); + ThreatContainer::StorageType::const_iterator itr = threatlist.begin(); std::list<Unit*> targets; - for (; itr != m_threatlist.end(); ++itr) + for (; itr != threatlist.end(); ++itr) { Unit* unit = Unit::GetUnit(*me, (*itr)->getUnitGuid()); if (unit && unit->isAlive()) @@ -207,7 +207,6 @@ public: } else CheckTeronTimer -= diff; } }; - }; class boss_teron_gorefiend : public CreatureScript @@ -317,20 +316,20 @@ public: return coord; } - void SetThreatList(Creature* Blossom) + void SetThreatList(Creature* blossom) { - if (!Blossom) + if (!blossom) return; - std::list<HostileReference*>& m_threatlist = me->getThreatManager().getThreatList(); - std::list<HostileReference*>::const_iterator i = m_threatlist.begin(); - for (i = m_threatlist.begin(); i != m_threatlist.end(); ++i) + ThreatContainer::StorageType const &threatlist = me->getThreatManager().getThreatList(); + ThreatContainer::StorageType::const_iterator i = threatlist.begin(); + for (i = threatlist.begin(); i != threatlist.end(); ++i) { Unit* unit = Unit::GetUnit(*me, (*i)->getUnitGuid()); if (unit && unit->isAlive()) { float threat = DoGetThreat(unit); - Blossom->AddThreat(unit, threat); + blossom->AddThreat(unit, threat); } } } @@ -344,26 +343,26 @@ public: /** WHAT IS FULLY NECESSARY FOR GOREFIEND TO BE 100% COMPLETE *****/ /************************************************************************/ - Unit* Ghost = NULL; + Unit* ghost = NULL; if (GhostGUID) - Ghost = Unit::GetUnit(*me, GhostGUID); - if (Ghost && Ghost->isAlive() && Ghost->HasAura(SPELL_SHADOW_OF_DEATH)) + ghost = Unit::GetUnit(*me, GhostGUID); + if (ghost && ghost->isAlive() && ghost->HasAura(SPELL_SHADOW_OF_DEATH)) { /*float x, y, z; - Ghost->GetPosition(x, y, z); + ghost->GetPosition(x, y, z); Creature* control = me->SummonCreature(CREATURE_GHOST, x, y, z, 0, TEMPSUMMON_TIMED_DESAWN, 30000); if (control) { - CAST_PLR(Ghost)->Possess(control); - Ghost->DealDamage(Ghost, Ghost->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, + CAST_PLR(ghost)->Possess(control); + ghost->DealDamage(ghost, ghost->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); }*/ for (uint8 i = 0; i < 4; ++i) { Creature* Construct = NULL; - float X = CalculateRandomLocation(Ghost->GetPositionX(), 10); - float Y = CalculateRandomLocation(Ghost->GetPositionY(), 10); - Construct = me->SummonCreature(CREATURE_SHADOWY_CONSTRUCT, X, Y, Ghost->GetPositionZ(), 0, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 45000); + float X = CalculateRandomLocation(ghost->GetPositionX(), 10); + float Y = CalculateRandomLocation(ghost->GetPositionY(), 10); + Construct = me->SummonCreature(CREATURE_SHADOWY_CONSTRUCT, X, Y, ghost->GetPositionZ(), 0, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 45000); if (Construct) { Construct->CastSpell(Construct, SPELL_PASSIVE_SHADOWFORM, true); @@ -511,7 +510,6 @@ public: DoMeleeAttackIfReady(); } }; - }; void AddSC_boss_teron_gorefiend() diff --git a/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_leotheras_the_blind.cpp b/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_leotheras_the_blind.cpp index 81e03a19c1f..9b739a1a6ac 100644 --- a/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_leotheras_the_blind.cpp +++ b/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_leotheras_the_blind.cpp @@ -171,7 +171,6 @@ public: DoMeleeAttackIfReady(); } }; - }; //Original Leotheras the Blind AI @@ -263,7 +262,6 @@ public: Creature* binder = me->SummonCreature(MOB_SPELLBINDER, nx, ny, z, o, TEMPSUMMON_DEAD_DESPAWN, 0); if (binder) SpellBinderGUID[i] = binder->GetGUID(); - } } void MoveInLineOfSight(Unit* who) @@ -525,9 +523,9 @@ public: //Summon Inner Demon if (InnerDemons_Timer <= diff) { - std::list<HostileReference*>& ThreatList = me->getThreatManager().getThreatList(); + ThreatContainer::StorageType const & ThreatList = me->getThreatManager().getThreatList(); std::vector<Unit*> TargetList; - for (std::list<HostileReference*>::const_iterator itr = ThreatList.begin(); itr != ThreatList.end(); ++itr) + for (ThreatContainer::StorageType::const_iterator itr = ThreatList.begin(); itr != ThreatList.end(); ++itr) { Unit* tempTarget = Unit::GetUnit(*me, (*itr)->getUnitGuid()); if (tempTarget && tempTarget->GetTypeId() == TYPEID_PLAYER && tempTarget->GetGUID() != me->getVictim()->GetGUID() && TargetList.size()<5) @@ -602,7 +600,6 @@ public: } } }; - }; //Leotheras the Blind Demon Form AI @@ -812,7 +809,6 @@ public: void JustDied(Unit* /*killer*/) {} }; - }; void AddSC_boss_leotheras_the_blind() diff --git a/src/server/scripts/Outland/TempestKeep/Eye/boss_kaelthas.cpp b/src/server/scripts/Outland/TempestKeep/Eye/boss_kaelthas.cpp index f60cc1d188c..29c87e57c83 100644 --- a/src/server/scripts/Outland/TempestKeep/Eye/boss_kaelthas.cpp +++ b/src/server/scripts/Outland/TempestKeep/Eye/boss_kaelthas.cpp @@ -176,7 +176,7 @@ struct advisorbase_ai : public ScriptedAI //reset encounter if (instance && (instance->GetData(DATA_KAELTHASEVENT) == 1 || instance->GetData(DATA_KAELTHASEVENT) == 3)) - if (Creature* Kaelthas = Unit::GetCreature((*me), instance->GetData64(DATA_KAELTHAS))) + if (Creature* Kaelthas = Unit::GetCreature(*me, instance->GetData64(DATA_KAELTHAS))) Kaelthas->AI()->EnterEvadeMode(); } @@ -344,7 +344,7 @@ class boss_kaelthas : public CreatureScript { for (uint8 i = 0; i < MAX_ADVISORS; ++i) { - if (Creature* creature = Unit::GetCreature((*me), m_auiAdvisorGuid[i])) + if (Creature* creature = Unit::GetCreature(*me, m_auiAdvisorGuid[i])) { creature->Respawn(); creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); @@ -379,7 +379,6 @@ class boss_kaelthas : public CreatureScript if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0)) AttackStart(target); - } else { @@ -499,7 +498,7 @@ class boss_kaelthas : public CreatureScript case 1: if (Phase_Timer <= diff) { - Advisor = (Unit::GetCreature((*me), m_auiAdvisorGuid[0])); + Advisor = (Unit::GetCreature(*me, m_auiAdvisorGuid[0])); if (Advisor) { @@ -517,7 +516,7 @@ class boss_kaelthas : public CreatureScript //Subphase 2 - Start case 2: - Advisor = (Unit::GetCreature((*me), m_auiAdvisorGuid[0])); + Advisor = (Unit::GetCreature(*me, m_auiAdvisorGuid[0])); if (Advisor && (Advisor->getStandState() == UNIT_STAND_STATE_DEAD)) { @@ -533,7 +532,7 @@ class boss_kaelthas : public CreatureScript case 3: if (Phase_Timer <= diff) { - Advisor = (Unit::GetCreature((*me), m_auiAdvisorGuid[1])); + Advisor = (Unit::GetCreature(*me, m_auiAdvisorGuid[1])); if (Advisor) { @@ -551,7 +550,7 @@ class boss_kaelthas : public CreatureScript //Subphase 3 - Start case 4: - Advisor = (Unit::GetCreature((*me), m_auiAdvisorGuid[1])); + Advisor = (Unit::GetCreature(*me, m_auiAdvisorGuid[1])); if (Advisor && (Advisor->getStandState() == UNIT_STAND_STATE_DEAD)) { @@ -567,7 +566,7 @@ class boss_kaelthas : public CreatureScript case 5: if (Phase_Timer <= diff) { - Advisor = (Unit::GetCreature((*me), m_auiAdvisorGuid[2])); + Advisor = (Unit::GetCreature(*me, m_auiAdvisorGuid[2])); if (Advisor) { @@ -585,7 +584,7 @@ class boss_kaelthas : public CreatureScript //Subphase 4 - Start case 6: - Advisor = (Unit::GetCreature((*me), m_auiAdvisorGuid[2])); + Advisor = (Unit::GetCreature(*me, m_auiAdvisorGuid[2])); if (Advisor && (Advisor->getStandState() == UNIT_STAND_STATE_DEAD)) { @@ -601,7 +600,7 @@ class boss_kaelthas : public CreatureScript case 7: if (Phase_Timer <= diff) { - Advisor = (Unit::GetCreature((*me), m_auiAdvisorGuid[3])); + Advisor = (Unit::GetCreature(*me, m_auiAdvisorGuid[3])); if (Advisor) { @@ -620,7 +619,7 @@ class boss_kaelthas : public CreatureScript //End of phase 1 case 8: - Advisor = (Unit::GetCreature((*me), m_auiAdvisorGuid[3])); + Advisor = (Unit::GetCreature(*me, m_auiAdvisorGuid[3])); if (Advisor && (Advisor->getStandState() == UNIT_STAND_STATE_DEAD)) { @@ -691,7 +690,7 @@ class boss_kaelthas : public CreatureScript Creature* Advisor; for (uint8 i = 0; i < MAX_ADVISORS; ++i) { - Advisor = Unit::GetCreature((*me), m_auiAdvisorGuid[i]); + Advisor = Unit::GetCreature(*me, m_auiAdvisorGuid[i]); if (!Advisor) sLog->outError(LOG_FILTER_TSCR, "SD2: Kael'Thas Advisor %u does not exist. Possibly despawned? Incorrectly Killed?", i); @@ -787,7 +786,7 @@ class boss_kaelthas : public CreatureScript if (me->getThreatManager().getThreatList().size() >= 2) for (uint32 i = 0; i < 3; ++i) { - sLog->outDebug(LOG_FILTER_TSCR, "SD2: Kael'Thas mind control not supported."); + sLog->outDebug(LOG_FILTER_TSCR, "Kael'Thas mind control not supported."); //DoCast(unit, SPELL_MIND_CONTROL); } @@ -879,11 +878,12 @@ class boss_kaelthas : public CreatureScript //Phase 5 if (Phase == 6) { - //GravityLapse_Timer if (GravityLapse_Timer <= diff) { - std::list<HostileReference*>::const_iterator i = me->getThreatManager().getThreatList().begin(); + ThreatContainer::StorageType threatlist = me->getThreatManager().getThreatList(); + ThreatContainer::StorageType::const_iterator i = threatlist.begin(); + switch (GravityLapse_Phase) { case 0: @@ -894,7 +894,7 @@ class boss_kaelthas : public CreatureScript me->MonsterMoveWithSpeed(afGravityPos[0], afGravityPos[1], afGravityPos[2], 0); // 1) Kael'thas will portal the whole raid right into his body - for (i = me->getThreatManager().getThreatList().begin(); i!= me->getThreatManager().getThreatList().end(); ++i) + for (i = threatlist.begin(); i != threatlist.end(); ++i) { Unit* unit = Unit::GetUnit(*me, (*i)->getUnitGuid()); if (unit && (unit->GetTypeId() == TYPEID_PLAYER)) @@ -915,7 +915,7 @@ class boss_kaelthas : public CreatureScript DoScriptText(RAND(SAY_GRAVITYLAPSE1, SAY_GRAVITYLAPSE2), me); // 2) At that point he will put a Gravity Lapse debuff on everyone - for (i = me->getThreatManager().getThreatList().begin(); i != me->getThreatManager().getThreatList().end(); ++i) + for (i = threatlist.begin(); i != threatlist.end(); ++i) { if (Unit* unit = Unit::GetUnit(*me, (*i)->getUnitGuid())) { @@ -948,7 +948,7 @@ class boss_kaelthas : public CreatureScript case 3: //Remove flight - for (i = me->getThreatManager().getThreatList().begin(); i!= me->getThreatManager().getThreatList().end(); ++i) + for (i = threatlist.begin(); i != threatlist.end(); ++i) { if (Unit* unit = Unit::GetUnit(*me, (*i)->getUnitGuid())) { @@ -1287,8 +1287,8 @@ class boss_grand_astromancer_capernian : public CreatureScript { bool InMeleeRange = false; Unit* target = NULL; - std::list<HostileReference*>& m_threatlist = me->getThreatManager().getThreatList(); - for (std::list<HostileReference*>::const_iterator i = m_threatlist.begin(); i!= m_threatlist.end(); ++i) + ThreatContainer::StorageType const &threatlist = me->getThreatManager().getThreatList(); + for (ThreatContainer::StorageType::const_iterator i = threatlist.begin(); i!= threatlist.end(); ++i) { Unit* unit = Unit::GetUnit(*me, (*i)->getUnitGuid()); //if in melee range diff --git a/src/server/scripts/Outland/netherstorm.cpp b/src/server/scripts/Outland/netherstorm.cpp index 480275c42bd..8533491c15f 100644 --- a/src/server/scripts/Outland/netherstorm.cpp +++ b/src/server/scripts/Outland/netherstorm.cpp @@ -323,22 +323,22 @@ public: { case 3726: //b'naar if ((player->GetQuestStatus(10299) == QUEST_STATUS_INCOMPLETE || player->GetQuestStatus(10329) == QUEST_STATUS_INCOMPLETE) && - player->HasItemCount(29366, 1)) + player->HasItemCount(29366)) manaforge = player->SummonCreature(ENTRY_BNAAR_C_CONSOLE, 2918.95f, 4189.98f, 161.88f, 0.34f, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 125000); break; case 3730: //coruu if ((player->GetQuestStatus(10321) == QUEST_STATUS_INCOMPLETE || player->GetQuestStatus(10330) == QUEST_STATUS_INCOMPLETE) && - player->HasItemCount(29396, 1)) + player->HasItemCount(29396)) manaforge = player->SummonCreature(ENTRY_CORUU_C_CONSOLE, 2426.77f, 2750.38f, 133.24f, 2.14f, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 125000); break; case 3734: //duro if ((player->GetQuestStatus(10322) == QUEST_STATUS_INCOMPLETE || player->GetQuestStatus(10338) == QUEST_STATUS_INCOMPLETE) && - player->HasItemCount(29397, 1)) + player->HasItemCount(29397)) manaforge = player->SummonCreature(ENTRY_DURO_C_CONSOLE, 2976.48f, 2183.29f, 163.20f, 1.85f, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 125000); break; case 3722: //ara if ((player->GetQuestStatus(10323) == QUEST_STATUS_INCOMPLETE || player->GetQuestStatus(10365) == QUEST_STATUS_INCOMPLETE) && - player->HasItemCount(29411, 1)) + player->HasItemCount(29411)) manaforge = player->SummonCreature(ENTRY_ARA_C_CONSOLE, 4013.71f, 4028.76f, 192.10f, 1.25f, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 125000); break; } @@ -704,7 +704,7 @@ public: if (creature->isQuestGiver()) player->PrepareQuestMenu(creature->GetGUID()); - if (player->GetQuestStatus(QUEST_ON_NETHERY_WINGS) == QUEST_STATUS_INCOMPLETE && !player->HasItemCount(29778, 1)) + if (player->GetQuestStatus(QUEST_ON_NETHERY_WINGS) == QUEST_STATUS_INCOMPLETE && !player->HasItemCount(29778)) player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_ITEM, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1); player->SEND_GOSSIP_MENU(player->GetGossipTextId(creature), creature->GetGUID()); diff --git a/src/server/scripts/Outland/zangarmarsh.cpp b/src/server/scripts/Outland/zangarmarsh.cpp index aa51b532c27..a48866a2f83 100644 --- a/src/server/scripts/Outland/zangarmarsh.cpp +++ b/src/server/scripts/Outland/zangarmarsh.cpp @@ -249,7 +249,7 @@ public: break; case GOSSIP_ACTION_INFO_DEF + 2: { - if (!player->HasItemCount(24573, 1)) + if (!player->HasItemCount(24573)) { ItemPosCountVec dest; uint32 itemId = 24573; diff --git a/src/server/scripts/Spells/spell_rogue.cpp b/src/server/scripts/Spells/spell_rogue.cpp index ab6d0e95c1d..68cc50a3022 100644 --- a/src/server/scripts/Spells/spell_rogue.cpp +++ b/src/server/scripts/Spells/spell_rogue.cpp @@ -350,7 +350,7 @@ class spell_rog_deadly_poison : public SpellScriptLoader SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(enchant->spellid[s]); if (!spellInfo) { - sLog->outError(LOG_FILTER_SPELLS_AURAS, "Player::CastItemCombatSpell Enchant %i, player (Name: %s, GUID: %u) cast unknown spell %i", enchant->ID, player->GetName(), player->GetGUIDLow(), enchant->spellid[s]); + sLog->outError(LOG_FILTER_SPELLS_AURAS, "Player::CastItemCombatSpell Enchant %i, player (Name: %s, GUID: %u) cast unknown spell %i", enchant->ID, player->GetName().c_str(), player->GetGUIDLow(), enchant->spellid[s]); continue; } diff --git a/src/server/scripts/World/areatrigger_scripts.cpp b/src/server/scripts/World/areatrigger_scripts.cpp index f302009a4f3..67aeda314bf 100644 --- a/src/server/scripts/World/areatrigger_scripts.cpp +++ b/src/server/scripts/World/areatrigger_scripts.cpp @@ -235,21 +235,19 @@ enum eWaygate QUEST_THE_MAKERS_OVERLOOK = 12613, QUEST_THE_MAKERS_PERCH = 12559, + QUEST_MEETING_A_GREAT_ONE = 13956, }; class AreaTrigger_at_sholazar_waygate : public AreaTriggerScript { public: - AreaTrigger_at_sholazar_waygate() - : AreaTriggerScript("at_sholazar_waygate") - { - } + AreaTrigger_at_sholazar_waygate() : AreaTriggerScript("at_sholazar_waygate") {} bool OnTrigger(Player* player, AreaTriggerEntry const* trigger) { - if (player->GetQuestStatus(QUEST_THE_MAKERS_OVERLOOK) == QUEST_STATUS_REWARDED && !player->isDead() && - player->GetQuestStatus(QUEST_THE_MAKERS_PERCH) == QUEST_STATUS_REWARDED) + if (!player->isDead() && (player->GetQuestStatus(QUEST_MEETING_A_GREAT_ONE) != QUEST_STATUS_NONE || + (player->GetQuestStatus(QUEST_THE_MAKERS_OVERLOOK) == QUEST_STATUS_REWARDED && player->GetQuestStatus(QUEST_THE_MAKERS_PERCH) == QUEST_STATUS_REWARDED))) { switch (trigger->id) { @@ -303,76 +301,6 @@ class AreaTrigger_at_nats_landing : public AreaTriggerScript }; /*###### -## at_bring_your_orphan_to -######*/ - -enum BringYourOrphanTo -{ - QUEST_DOWN_AT_THE_DOCKS = 910, - QUEST_GATEWAY_TO_THE_FRONTIER = 911, - QUEST_LORDAERON_THRONE_ROOM = 1800, - QUEST_BOUGHT_OF_ETERNALS = 1479, - QUEST_SPOOKY_LIGHTHOUSE = 1687, - QUEST_STONEWROUGHT_DAM = 1558, - QUEST_DARK_PORTAL_H = 10951, - QUEST_DARK_PORTAL_A = 10952, - - AT_DOWN_AT_THE_DOCKS = 3551, - AT_GATEWAY_TO_THE_FRONTIER = 3549, - AT_LORDAERON_THRONE_ROOM = 3547, - AT_BOUGHT_OF_ETERNALS = 3546, - AT_SPOOKY_LIGHTHOUSE = 3552, - AT_STONEWROUGHT_DAM = 3548, - AT_DARK_PORTAL = 4356, - - AURA_ORPHAN_OUT = 58818, -}; - -class AreaTrigger_at_bring_your_orphan_to : public AreaTriggerScript -{ - public: - AreaTrigger_at_bring_your_orphan_to() : AreaTriggerScript("at_bring_your_orphan_to") { } - - bool OnTrigger(Player* player, AreaTriggerEntry const* trigger) - { - uint32 questId = 0; - - if (player->isDead() || !player->HasAura(AURA_ORPHAN_OUT)) - return false; - - switch (trigger->id) - { - case AT_DOWN_AT_THE_DOCKS: - questId = QUEST_DOWN_AT_THE_DOCKS; - break; - case AT_GATEWAY_TO_THE_FRONTIER: - questId = QUEST_GATEWAY_TO_THE_FRONTIER; - break; - case AT_LORDAERON_THRONE_ROOM: - questId = QUEST_LORDAERON_THRONE_ROOM; - break; - case AT_BOUGHT_OF_ETERNALS: - questId = QUEST_BOUGHT_OF_ETERNALS; - break; - case AT_SPOOKY_LIGHTHOUSE: - questId = QUEST_SPOOKY_LIGHTHOUSE; - break; - case AT_STONEWROUGHT_DAM: - questId = QUEST_STONEWROUGHT_DAM; - break; - case AT_DARK_PORTAL: - questId = player->GetTeam() == ALLIANCE ? QUEST_DARK_PORTAL_A : QUEST_DARK_PORTAL_H; - break; - } - - if (questId && player->GetQuestStatus(questId) == QUEST_STATUS_INCOMPLETE) - player->AreaExploredOrEventHappens(questId); - - return true; - } -}; - -/*###### ## at_brewfest ######*/ @@ -505,7 +433,6 @@ void AddSC_areatrigger_scripts() new AreaTrigger_at_last_rites(); new AreaTrigger_at_sholazar_waygate(); new AreaTrigger_at_nats_landing(); - new AreaTrigger_at_bring_your_orphan_to(); new AreaTrigger_at_brewfest(); new AreaTrigger_at_area_52_entrance(); } diff --git a/src/server/scripts/World/chat_log.cpp b/src/server/scripts/World/chat_log.cpp index fb540c177bc..236436b229b 100755 --- a/src/server/scripts/World/chat_log.cpp +++ b/src/server/scripts/World/chat_log.cpp @@ -32,25 +32,25 @@ public: case CHAT_MSG_ADDON: if (sWorld->getBoolConfig(CONFIG_CHATLOG_ADDON)) sLog->outDebug(LOG_FILTER_PLAYER_CHATLOG, "[ADDON] Player %s sends: %s", - player->GetName(), msg.c_str()); + player->GetName().c_str(), msg.c_str()); break; case CHAT_MSG_SAY: if (sWorld->getBoolConfig(CONFIG_CHATLOG_PUBLIC)) sLog->outDebug(LOG_FILTER_PLAYER_CHATLOG, "[SAY] Player %s says (language %u): %s", - player->GetName(), lang, msg.c_str()); + player->GetName().c_str(), lang, msg.c_str()); break; case CHAT_MSG_EMOTE: if (sWorld->getBoolConfig(CONFIG_CHATLOG_PUBLIC)) sLog->outDebug(LOG_FILTER_PLAYER_CHATLOG, "[TEXTEMOTE] Player %s emotes: %s", - player->GetName(), msg.c_str()); + player->GetName().c_str(), msg.c_str()); break; case CHAT_MSG_YELL: if (sWorld->getBoolConfig(CONFIG_CHATLOG_PUBLIC)) sLog->outDebug(LOG_FILTER_PLAYER_CHATLOG, "[YELL] Player %s yells (language %u): %s", - player->GetName(), lang, msg.c_str()); + player->GetName().c_str(), lang, msg.c_str()); break; } } @@ -59,10 +59,10 @@ public: { if (lang != LANG_ADDON && sWorld->getBoolConfig(CONFIG_CHATLOG_WHISPER)) sLog->outDebug(LOG_FILTER_PLAYER_CHATLOG, "[WHISPER] Player %s tells %s: %s", - player->GetName(), receiver ? receiver->GetName() : "<unknown>", msg.c_str()); + player->GetName().c_str(), receiver ? receiver->GetName().c_str() : "<unknown>", msg.c_str()); else if (lang == LANG_ADDON && sWorld->getBoolConfig(CONFIG_CHATLOG_ADDON)) sLog->outDebug(LOG_FILTER_PLAYER_CHATLOG, "[ADDON] Player %s tells %s: %s", - player->GetName(), receiver ? receiver->GetName() : "<unknown>", msg.c_str()); + player->GetName().c_str(), receiver ? receiver->GetName().c_str() : "<unknown>", msg.c_str()); } void OnChat(Player* player, uint32 type, uint32 lang, std::string& msg, Group* group) @@ -74,52 +74,52 @@ public: case CHAT_MSG_PARTY: if (lang != LANG_ADDON && sWorld->getBoolConfig(CONFIG_CHATLOG_PARTY)) sLog->outDebug(LOG_FILTER_PLAYER_CHATLOG, "[PARTY] Player %s tells group with leader %s: %s", - player->GetName(), group ? group->GetLeaderName() : "<unknown>", msg.c_str()); + player->GetName().c_str(), group ? group->GetLeaderName() : "<unknown>", msg.c_str()); else if (lang == LANG_ADDON && sWorld->getBoolConfig(CONFIG_CHATLOG_ADDON)) sLog->outDebug(LOG_FILTER_PLAYER_CHATLOG, "[ADDON] Player %s tells group with leader %s: %s", - player->GetName(), group ? group->GetLeaderName() : "<unknown>", msg.c_str()); + player->GetName().c_str(), group ? group->GetLeaderName() : "<unknown>", msg.c_str()); break; case CHAT_MSG_PARTY_LEADER: if (sWorld->getBoolConfig(CONFIG_CHATLOG_PARTY)) sLog->outDebug(LOG_FILTER_PLAYER_CHATLOG, "[PARTY] Leader %s tells group: %s", - player->GetName(), msg.c_str()); + player->GetName().c_str(), msg.c_str()); break; case CHAT_MSG_RAID: if (lang != LANG_ADDON && sWorld->getBoolConfig(CONFIG_CHATLOG_RAID)) sLog->outDebug(LOG_FILTER_PLAYER_CHATLOG, "[RAID] Player %s tells raid with leader %s: %s", - player->GetName(), group ? group->GetLeaderName() : "<unknown>", msg.c_str()); + player->GetName().c_str(), group ? group->GetLeaderName() : "<unknown>", msg.c_str()); else if (lang == LANG_ADDON && sWorld->getBoolConfig(CONFIG_CHATLOG_ADDON)) sLog->outDebug(LOG_FILTER_PLAYER_CHATLOG, "[ADDON] Player %s tells raid with leader %s: %s", - player->GetName(), group ? group->GetLeaderName() : "<unknown>", msg.c_str()); + player->GetName().c_str(), group ? group->GetLeaderName() : "<unknown>", msg.c_str()); break; case CHAT_MSG_RAID_LEADER: if (sWorld->getBoolConfig(CONFIG_CHATLOG_RAID)) sLog->outDebug(LOG_FILTER_PLAYER_CHATLOG, "[RAID] Leader player %s tells raid: %s", - player->GetName(), msg.c_str()); + player->GetName().c_str(), msg.c_str()); break; case CHAT_MSG_RAID_WARNING: if (sWorld->getBoolConfig(CONFIG_CHATLOG_RAID)) sLog->outDebug(LOG_FILTER_PLAYER_CHATLOG, "[RAID] Leader player %s warns raid with: %s", - player->GetName(), msg.c_str()); + player->GetName().c_str(), msg.c_str()); break; case CHAT_MSG_BATTLEGROUND: if (lang != LANG_ADDON && sWorld->getBoolConfig(CONFIG_CHATLOG_BGROUND)) sLog->outDebug(LOG_FILTER_PLAYER_CHATLOG, "[BATTLEGROUND] Player %s tells battleground with leader %s: %s", - player->GetName(), group ? group->GetLeaderName() : "<unknown>", msg.c_str()); + player->GetName().c_str(), group ? group->GetLeaderName() : "<unknown>", msg.c_str()); else if (lang == LANG_ADDON && sWorld->getBoolConfig(CONFIG_CHATLOG_ADDON)) sLog->outDebug(LOG_FILTER_PLAYER_CHATLOG, "[ADDON] Player %s tells battleground with leader %s: %s", - player->GetName(), group ? group->GetLeaderName() : "<unknown>", msg.c_str()); + player->GetName().c_str(), group ? group->GetLeaderName() : "<unknown>", msg.c_str()); break; case CHAT_MSG_BATTLEGROUND_LEADER: if (sWorld->getBoolConfig(CONFIG_CHATLOG_BGROUND)) sLog->outDebug(LOG_FILTER_PLAYER_CHATLOG, "[BATTLEGROUND] Leader player %s tells battleground: %s", - player->GetName(), msg.c_str()); + player->GetName().c_str(), msg.c_str()); break; } } @@ -131,16 +131,16 @@ public: case CHAT_MSG_GUILD: if (lang != LANG_ADDON && sWorld->getBoolConfig(CONFIG_CHATLOG_GUILD)) sLog->outDebug(LOG_FILTER_PLAYER_CHATLOG, "[GUILD] Player %s tells guild %s: %s", - player->GetName(), guild ? guild->GetName().c_str() : "<unknown>", msg.c_str()); + player->GetName().c_str(), guild ? guild->GetName().c_str() : "<unknown>", msg.c_str()); else if (lang == LANG_ADDON && sWorld->getBoolConfig(CONFIG_CHATLOG_ADDON)) sLog->outDebug(LOG_FILTER_PLAYER_CHATLOG, "[ADDON] Player %s sends to guild %s: %s", - player->GetName(), guild ? guild->GetName().c_str() : "<unknown>", msg.c_str()); + player->GetName().c_str(), guild ? guild->GetName().c_str() : "<unknown>", msg.c_str()); break; case CHAT_MSG_OFFICER: if (sWorld->getBoolConfig(CONFIG_CHATLOG_GUILD)) sLog->outDebug(LOG_FILTER_PLAYER_CHATLOG, "[OFFICER] Player %s tells guild %s officers: %s", - player->GetName(), guild ? guild->GetName().c_str() : "<unknown>", msg.c_str()); + player->GetName().c_str(), guild ? guild->GetName().c_str() : "<unknown>", msg.c_str()); break; } } @@ -155,10 +155,10 @@ public: if (sWorld->getBoolConfig(CONFIG_CHATLOG_SYSCHAN) && isSystem) sLog->outDebug(LOG_FILTER_PLAYER_CHATLOG, "[SYSCHAN] Player %s tells channel %s: %s", - player->GetName(), channel->GetName().c_str(), msg.c_str()); + player->GetName().c_str(), channel->GetName().c_str(), msg.c_str()); else if (sWorld->getBoolConfig(CONFIG_CHATLOG_CHANNEL)) sLog->outDebug(LOG_FILTER_PLAYER_CHATLOG, "[CHANNEL] Player %s tells channel %s: %s", - player->GetName(), channel ? channel->GetName().c_str() : "<unknown>", msg.c_str()); + player->GetName().c_str(), channel ? channel->GetName().c_str() : "<unknown>", msg.c_str()); } }; diff --git a/src/server/scripts/World/go_scripts.cpp b/src/server/scripts/World/go_scripts.cpp index 2a5d58122ed..ddb0044a888 100644 --- a/src/server/scripts/World/go_scripts.cpp +++ b/src/server/scripts/World/go_scripts.cpp @@ -677,28 +677,28 @@ public: switch (go->GetEntry()) { case MATRIX_PUNCHOGRAPH_3005_A: - if (player->HasItemCount(ITEM_WHITE_PUNCH_CARD, 1)) + if (player->HasItemCount(ITEM_WHITE_PUNCH_CARD)) { player->DestroyItemCount(ITEM_WHITE_PUNCH_CARD, 1, true); player->CastSpell(player, SPELL_YELLOW_PUNCH_CARD, true); } break; case MATRIX_PUNCHOGRAPH_3005_B: - if (player->HasItemCount(ITEM_YELLOW_PUNCH_CARD, 1)) + if (player->HasItemCount(ITEM_YELLOW_PUNCH_CARD)) { player->DestroyItemCount(ITEM_YELLOW_PUNCH_CARD, 1, true); player->CastSpell(player, SPELL_BLUE_PUNCH_CARD, true); } break; case MATRIX_PUNCHOGRAPH_3005_C: - if (player->HasItemCount(ITEM_BLUE_PUNCH_CARD, 1)) + if (player->HasItemCount(ITEM_BLUE_PUNCH_CARD)) { player->DestroyItemCount(ITEM_BLUE_PUNCH_CARD, 1, true); player->CastSpell(player, SPELL_RED_PUNCH_CARD, true); } break; case MATRIX_PUNCHOGRAPH_3005_D: - if (player->HasItemCount(ITEM_RED_PUNCH_CARD, 1)) + if (player->HasItemCount(ITEM_RED_PUNCH_CARD)) { player->DestroyItemCount(ITEM_RED_PUNCH_CARD, 1, true); player->CastSpell(player, SPELL_PRISMATIC_PUNCH_CARD, true); @@ -884,7 +884,7 @@ public: bool OnGossipHello(Player* player, GameObject* /*go*/) { - if (player->HasItemCount(ITEM_CUERGOS_KEY, 1)) + if (player->HasItemCount(ITEM_CUERGOS_KEY)) return false; player->CastSpell(player, SPELL_SUMMON_PIRATES_TREASURE_AND_TRIGGER_MOB, true); @@ -910,7 +910,7 @@ public: bool OnGossipHello(Player* player, GameObject* go) { - if (!player->HasItemCount(ITEM_TELEPORTER_POWER_PACK, 1)) + if (!player->HasItemCount(ITEM_TELEPORTER_POWER_PACK)) return false; go->SummonCreature(NPC_IMAGE_WIND_TRADER, go->GetPositionX(), go->GetPositionY(), go->GetPositionZ(), go->GetAngle(player), TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, 60000); @@ -998,7 +998,7 @@ class go_soulwell : public GameObjectScript return true; // Don't try to add a stone if we already have one. - if (player->HasItemCount(_stoneId, 1)) + if (player->HasItemCount(_stoneId)) { if (SpellInfo const* spell = sSpellMgr->GetSpellInfo(_stoneSpell)) Spell::SendCastResult(player, spell, 0, SPELL_FAILED_TOO_MANY_OF_ITEM); @@ -1007,7 +1007,7 @@ class go_soulwell : public GameObjectScript owner->CastSpell(player, _stoneSpell, true); // Item has to actually be created to remove a charge on the well. - if (player->HasItemCount(_stoneId, 1)) + if (player->HasItemCount(_stoneId)) go->AddUse(); return false; @@ -1158,7 +1158,7 @@ public: go->CastSpell(target, SPELL_INDISPOSED_III); } go->CastSpell(player, SPELL_INDISPOSED); - if (player->HasItemCount(ITEM_ANDERHOLS_SLIDER_CIDER, 1)) + if (player->HasItemCount(ITEM_ANDERHOLS_SLIDER_CIDER)) go->CastSpell(player, SPELL_CREATE_AMBERSEEDS); return true; } diff --git a/src/server/scripts/World/npc_taxi.cpp b/src/server/scripts/World/npc_taxi.cpp index 6241978fbd2..efdd4da73d6 100644 --- a/src/server/scripts/World/npc_taxi.cpp +++ b/src/server/scripts/World/npc_taxi.cpp @@ -77,7 +77,7 @@ public: player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_SUSURRUS, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF); break; case 20903: // Netherstorm - Protectorate Nether Drake - if (player->GetQuestStatus(10438) == QUEST_STATUS_INCOMPLETE && player->HasItemCount(29778, 1)) + if (player->GetQuestStatus(10438) == QUEST_STATUS_INCOMPLETE && player->HasItemCount(29778)) player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_NETHER_DRAKE, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1); break; case 18725: // Old Hillsbrad Foothills - Brazen @@ -203,7 +203,7 @@ public: player->ActivateTaxiPathTo(627); //TaxiPath 627 (possibly 627+628(152->153->154->155)) break; case GOSSIP_ACTION_INFO_DEF + 2: - if (!player->HasItemCount(25853, 1)) + if (!player->HasItemCount(25853)) player->SEND_GOSSIP_MENU(9780, creature->GetGUID()); else { diff --git a/src/server/scripts/World/npcs_special.cpp b/src/server/scripts/World/npcs_special.cpp index b291b9751b4..4f0687ef11d 100644 --- a/src/server/scripts/World/npcs_special.cpp +++ b/src/server/scripts/World/npcs_special.cpp @@ -1268,7 +1268,7 @@ public: if (player->GetSpecsCount() == 1 && creature->isCanTrainingAndResetTalentsOf(player) && player->getLevel() >= sWorld->getIntConfig(CONFIG_MIN_DUALSPEC_LEVEL)) player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TRAINER, GOSSIP_HELLO_ROGUE3, GOSSIP_SENDER_MAIN, GOSSIP_OPTION_LEARNDUALSPEC); - if (player->getClass() == CLASS_ROGUE && player->getLevel() >= 24 && !player->HasItemCount(17126, 1) && !player->GetQuestRewardStatus(6681)) + if (player->getClass() == CLASS_ROGUE && player->getLevel() >= 24 && !player->HasItemCount(17126) && !player->GetQuestRewardStatus(6681)) { player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_HELLO_ROGUE2, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1); player->SEND_GOSSIP_MENU(5996, creature->GetGUID()); diff --git a/src/server/shared/Database/Implementation/CharacterDatabase.cpp b/src/server/shared/Database/Implementation/CharacterDatabase.cpp index d9b517c098f..db9a5646a69 100644 --- a/src/server/shared/Database/Implementation/CharacterDatabase.cpp +++ b/src/server/shared/Database/Implementation/CharacterDatabase.cpp @@ -169,10 +169,9 @@ void CharacterDatabaseConnection::DoPrepareStatements() PREPARE_STATEMENT(CHAR_INS_GUILD_BANK_ITEM, "INSERT INTO guild_bank_item (guildid, TabId, SlotId, item_guid) VALUES (?, ?, ?, ?)", CONNECTION_ASYNC) PREPARE_STATEMENT(CHAR_DEL_GUILD_BANK_ITEM, "DELETE FROM guild_bank_item WHERE guildid = ? AND TabId = ? AND SlotId = ?", CONNECTION_ASYNC) // 0: uint32, 1: uint8, 2: uint8 PREPARE_STATEMENT(CHAR_DEL_GUILD_BANK_ITEMS, "DELETE FROM guild_bank_item WHERE guildid = ?", CONNECTION_ASYNC) // 0: uint32 - PREPARE_STATEMENT(CHAR_INS_GUILD_BANK_RIGHT_DEFAULT, "INSERT INTO guild_bank_right (guildid, TabId, rid) VALUES (?, ?, ?)", CONNECTION_ASYNC) // 0: uint32, 1: uint8, 2: uint8 // 0: uint32, 1: uint8, 2: uint8, 3: uint8, 4: uint32 - PREPARE_STATEMENT(CHAR_INS_GUILD_BANK_RIGHT, "INSERT INTO guild_bank_right (guildid, TabId, rid, gbright, SlotPerDay) VALUES (?, ?, ?, ?, ?)", CONNECTION_ASYNC) - PREPARE_STATEMENT(CHAR_DEL_GUILD_BANK_RIGHT, "DELETE FROM guild_bank_right WHERE guildid = ? AND TabId = ? AND rid = ?", CONNECTION_ASYNC) // 0: uint32, 1: uint8, 2: uint8 + PREPARE_STATEMENT(CHAR_INS_GUILD_BANK_RIGHT, "INSERT INTO guild_bank_right (guildid, TabId, rid, gbright, SlotPerDay) VALUES (?, ?, ?, ?, ?) " + "ON DUPLICATE KEY UPDATE gbright = VALUES(gbright), SlotPerDay = VALUES(SlotPerDay)", CONNECTION_ASYNC) PREPARE_STATEMENT(CHAR_DEL_GUILD_BANK_RIGHTS, "DELETE FROM guild_bank_right WHERE guildid = ?", CONNECTION_ASYNC) // 0: uint32 PREPARE_STATEMENT(CHAR_DEL_GUILD_BANK_RIGHTS_FOR_RANK, "DELETE FROM guild_bank_right WHERE guildid = ? AND rid = ?", CONNECTION_ASYNC) // 0: uint32, 1: uint8 // 0-1: uint32, 2-3: uint8, 4-5: uint32, 6: uint16, 7: uint8, 8: uint64 @@ -198,32 +197,15 @@ void CharacterDatabaseConnection::DoPrepareStatements() PREPARE_STATEMENT(CHAR_UPD_GUILD_BANK_MONEY, "UPDATE guild SET BankMoney = ? WHERE guildid = ?", CONNECTION_ASYNC) // 0: uint64, 1: uint32 // 0: uint8, 1: uint32, 2: uint8, 3: uint32 PREPARE_STATEMENT(CHAR_UPD_GUILD_BANK_EVENTLOG_TAB, "UPDATE guild_bank_eventlog SET TabId = ? WHERE guildid = ? AND TabId = ? AND LogGuid = ?", CONNECTION_ASYNC) - PREPARE_STATEMENT(CHAR_UPD_GUILD_MEMBER_BANK_REM_MONEY, "UPDATE guild_member SET BankRemMoney = ? WHERE guildid = ? AND guid = ?", CONNECTION_ASYNC) // 0: uint32, 1: uint32, 2: uint32 - PREPARE_STATEMENT(CHAR_UPD_GUILD_MEMBER_BANK_TIME_MONEY, "UPDATE guild_member SET BankResetTimeMoney = ?, BankRemMoney = ? WHERE guildid = ? AND guid = ?", CONNECTION_ASYNC) // 0: uint32, 1: uint32, 2: uint32, 3: uint32 - PREPARE_STATEMENT(CHAR_UPD_GUILD_RANK_BANK_RESET_TIME, "UPDATE guild_member SET BankResetTimeMoney = 0 WHERE guildid = ? AND rank = ?", CONNECTION_ASYNC) // 0: uint32, 1: uint8 PREPARE_STATEMENT(CHAR_UPD_GUILD_RANK_BANK_MONEY, "UPDATE guild_rank SET BankMoneyPerDay = ? WHERE rid = ? AND guildid = ?", CONNECTION_ASYNC) // 0: uint32, 1: uint8, 2: uint32 PREPARE_STATEMENT(CHAR_UPD_GUILD_BANK_TAB_TEXT, "UPDATE guild_bank_tab SET TabText = ? WHERE guildid = ? AND TabId = ?", CONNECTION_ASYNC) // 0: string, 1: uint32, 2: uint8 + + PREPARE_STATEMENT(CHAR_INS_GUILD_MEMBER_WITHDRAW, + "INSERT INTO guild_member_withdraw (guid, tab0, tab1, tab2, tab3, tab4, tab5, money) VALUES (?, ?, ?, ?, ?, ?, ?, ?) " + "ON DUPLICATE KEY UPDATE tab0 = VALUES (tab0), tab1 = VALUES (tab1), tab2 = VALUES (tab2), tab3 = VALUES (tab3), tab4 = VALUES (tab4), tab5 = VALUES (tab5)", CONNECTION_ASYNC) + PREPARE_STATEMENT(CHAR_DEL_GUILD_MEMBER_WITHDRAW, "TRUNCATE guild_member_withdraw", CONNECTION_ASYNC) + // 0: uint32, 1: uint32, 2: uint32 - PREPARE_STATEMENT(CHAR_UPD_GUILD_MEMBER_BANK_REM_SLOTS0, "UPDATE guild_member SET BankRemSlotsTab0 = ? WHERE guildid = ? AND guid = ?", CONNECTION_ASYNC) - PREPARE_STATEMENT(CHAR_UPD_GUILD_MEMBER_BANK_REM_SLOTS1, "UPDATE guild_member SET BankRemSlotsTab1 = ? WHERE guildid = ? AND guid = ?", CONNECTION_ASYNC) - PREPARE_STATEMENT(CHAR_UPD_GUILD_MEMBER_BANK_REM_SLOTS2, "UPDATE guild_member SET BankRemSlotsTab2 = ? WHERE guildid = ? AND guid = ?", CONNECTION_ASYNC) - PREPARE_STATEMENT(CHAR_UPD_GUILD_MEMBER_BANK_REM_SLOTS3, "UPDATE guild_member SET BankRemSlotsTab3 = ? WHERE guildid = ? AND guid = ?", CONNECTION_ASYNC) - PREPARE_STATEMENT(CHAR_UPD_GUILD_MEMBER_BANK_REM_SLOTS4, "UPDATE guild_member SET BankRemSlotsTab4 = ? WHERE guildid = ? AND guid = ?", CONNECTION_ASYNC) - PREPARE_STATEMENT(CHAR_UPD_GUILD_MEMBER_BANK_REM_SLOTS5, "UPDATE guild_member SET BankRemSlotsTab5 = ? WHERE guildid = ? AND guid = ?", CONNECTION_ASYNC) - // 0: uint32, 1: uint32, 2: uint32, 3: uint32 - PREPARE_STATEMENT(CHAR_UPD_GUILD_MEMBER_BANK_TIME_REM_SLOTS0, "UPDATE guild_member SET BankResetTimeTab0 = ?, BankRemSlotsTab0 = ? WHERE guildid = ? AND guid = ?", CONNECTION_ASYNC) - PREPARE_STATEMENT(CHAR_UPD_GUILD_MEMBER_BANK_TIME_REM_SLOTS1, "UPDATE guild_member SET BankResetTimeTab1 = ?, BankRemSlotsTab1 = ? WHERE guildid = ? AND guid = ?", CONNECTION_ASYNC) - PREPARE_STATEMENT(CHAR_UPD_GUILD_MEMBER_BANK_TIME_REM_SLOTS2, "UPDATE guild_member SET BankResetTimeTab2 = ?, BankRemSlotsTab2 = ? WHERE guildid = ? AND guid = ?", CONNECTION_ASYNC) - PREPARE_STATEMENT(CHAR_UPD_GUILD_MEMBER_BANK_TIME_REM_SLOTS3, "UPDATE guild_member SET BankResetTimeTab3 = ?, BankRemSlotsTab3 = ? WHERE guildid = ? AND guid = ?", CONNECTION_ASYNC) - PREPARE_STATEMENT(CHAR_UPD_GUILD_MEMBER_BANK_TIME_REM_SLOTS4, "UPDATE guild_member SET BankResetTimeTab4 = ?, BankRemSlotsTab4 = ? WHERE guildid = ? AND guid = ?", CONNECTION_ASYNC) - PREPARE_STATEMENT(CHAR_UPD_GUILD_MEMBER_BANK_TIME_REM_SLOTS5, "UPDATE guild_member SET BankResetTimeTab5 = ?, BankRemSlotsTab5 = ? WHERE guildid = ? AND guid = ?", CONNECTION_ASYNC) - // 0: uint32, 1: uint8 - PREPARE_STATEMENT(CHAR_UPD_GUILD_RANK_BANK_TIME0, "UPDATE guild_member SET BankResetTimeTab0 = 0 WHERE guildid = ? AND rank = ?", CONNECTION_ASYNC) - PREPARE_STATEMENT(CHAR_UPD_GUILD_RANK_BANK_TIME1, "UPDATE guild_member SET BankResetTimeTab1 = 0 WHERE guildid = ? AND rank = ?", CONNECTION_ASYNC) - PREPARE_STATEMENT(CHAR_UPD_GUILD_RANK_BANK_TIME2, "UPDATE guild_member SET BankResetTimeTab2 = 0 WHERE guildid = ? AND rank = ?", CONNECTION_ASYNC) - PREPARE_STATEMENT(CHAR_UPD_GUILD_RANK_BANK_TIME3, "UPDATE guild_member SET BankResetTimeTab3 = 0 WHERE guildid = ? AND rank = ?", CONNECTION_ASYNC) - PREPARE_STATEMENT(CHAR_UPD_GUILD_RANK_BANK_TIME4, "UPDATE guild_member SET BankResetTimeTab4 = 0 WHERE guildid = ? AND rank = ?", CONNECTION_ASYNC) - PREPARE_STATEMENT(CHAR_UPD_GUILD_RANK_BANK_TIME5, "UPDATE guild_member SET BankResetTimeTab5 = 0 WHERE guildid = ? AND rank = ?", CONNECTION_ASYNC) PREPARE_STATEMENT(CHAR_SEL_CHAR_DATA_FOR_GUILD, "SELECT name, level, class, zone, account FROM characters WHERE guid = ?", CONNECTION_SYNCH) // Chat channel handling diff --git a/src/server/shared/Database/Implementation/CharacterDatabase.h b/src/server/shared/Database/Implementation/CharacterDatabase.h index 88018997e4b..e421a7917ca 100644 --- a/src/server/shared/Database/Implementation/CharacterDatabase.h +++ b/src/server/shared/Database/Implementation/CharacterDatabase.h @@ -173,9 +173,7 @@ enum CharacterDatabaseStatements CHAR_INS_GUILD_BANK_ITEM, CHAR_DEL_GUILD_BANK_ITEM, CHAR_DEL_GUILD_BANK_ITEMS, - CHAR_INS_GUILD_BANK_RIGHT_DEFAULT, CHAR_INS_GUILD_BANK_RIGHT, - CHAR_DEL_GUILD_BANK_RIGHT, CHAR_DEL_GUILD_BANK_RIGHTS, CHAR_DEL_GUILD_BANK_RIGHTS_FOR_RANK, CHAR_INS_GUILD_BANK_EVENTLOG, @@ -196,29 +194,10 @@ enum CharacterDatabaseStatements CHAR_UPD_GUILD_BANK_TAB_INFO, CHAR_UPD_GUILD_BANK_MONEY, CHAR_UPD_GUILD_BANK_EVENTLOG_TAB, - CHAR_UPD_GUILD_MEMBER_BANK_REM_MONEY, - CHAR_UPD_GUILD_MEMBER_BANK_TIME_MONEY, - CHAR_UPD_GUILD_RANK_BANK_RESET_TIME, CHAR_UPD_GUILD_RANK_BANK_MONEY, CHAR_UPD_GUILD_BANK_TAB_TEXT, - CHAR_UPD_GUILD_MEMBER_BANK_TIME_REM_SLOTS0, - CHAR_UPD_GUILD_MEMBER_BANK_TIME_REM_SLOTS1, - CHAR_UPD_GUILD_MEMBER_BANK_TIME_REM_SLOTS2, - CHAR_UPD_GUILD_MEMBER_BANK_TIME_REM_SLOTS3, - CHAR_UPD_GUILD_MEMBER_BANK_TIME_REM_SLOTS4, - CHAR_UPD_GUILD_MEMBER_BANK_TIME_REM_SLOTS5, - CHAR_UPD_GUILD_MEMBER_BANK_REM_SLOTS0, - CHAR_UPD_GUILD_MEMBER_BANK_REM_SLOTS1, - CHAR_UPD_GUILD_MEMBER_BANK_REM_SLOTS2, - CHAR_UPD_GUILD_MEMBER_BANK_REM_SLOTS3, - CHAR_UPD_GUILD_MEMBER_BANK_REM_SLOTS4, - CHAR_UPD_GUILD_MEMBER_BANK_REM_SLOTS5, - CHAR_UPD_GUILD_RANK_BANK_TIME0, - CHAR_UPD_GUILD_RANK_BANK_TIME1, - CHAR_UPD_GUILD_RANK_BANK_TIME2, - CHAR_UPD_GUILD_RANK_BANK_TIME3, - CHAR_UPD_GUILD_RANK_BANK_TIME4, - CHAR_UPD_GUILD_RANK_BANK_TIME5, + CHAR_INS_GUILD_MEMBER_WITHDRAW, + CHAR_DEL_GUILD_MEMBER_WITHDRAW, CHAR_SEL_CHAR_DATA_FOR_GUILD, CHAR_SEL_CHANNEL, diff --git a/src/server/shared/Logging/Appender.cpp b/src/server/shared/Logging/Appender.cpp index 348ec4b3c7c..0bfcc8abbd2 100644 --- a/src/server/shared/Logging/Appender.cpp +++ b/src/server/shared/Logging/Appender.cpp @@ -217,6 +217,8 @@ char const* Appender::getLogFilterTypeString(LogFilterType type) return "SERVER LOADING"; case LOG_FILTER_OPCODES: return "OPCODE"; + case LOG_FILTER_SOAP: + return "SOAP"; default: break; } diff --git a/src/server/shared/Logging/Appender.h b/src/server/shared/Logging/Appender.h index 5c4b009ef67..89d0016ce2b 100644 --- a/src/server/shared/Logging/Appender.h +++ b/src/server/shared/Logging/Appender.h @@ -25,51 +25,52 @@ enum LogFilterType { - LOG_FILTER_GENERAL, // This one should only be used inside Log.cpp - LOG_FILTER_UNITS, // Anything related to units that doesn't fit in other categories. ie. creature formations - LOG_FILTER_PETS, - LOG_FILTER_VEHICLES, - LOG_FILTER_TSCR, // C++ AI, instance scripts, etc. - LOG_FILTER_DATABASE_AI, // SmartAI, EventAI, Creature* * AI - LOG_FILTER_MAPSCRIPTS, - LOG_FILTER_NETWORKIO, - LOG_FILTER_SPELLS_AURAS, - LOG_FILTER_ACHIEVEMENTSYS, - LOG_FILTER_CONDITIONSYS, - LOG_FILTER_POOLSYS, - LOG_FILTER_AUCTIONHOUSE, - LOG_FILTER_BATTLEGROUND, - LOG_FILTER_OUTDOORPVP, - LOG_FILTER_CHATSYS, - LOG_FILTER_LFG, - LOG_FILTER_MAPS, - LOG_FILTER_PLAYER, // Any player log that does not fit in other player filters - LOG_FILTER_PLAYER_LOADING, // Debug output from Player::_Load functions - LOG_FILTER_PLAYER_ITEMS, - LOG_FILTER_PLAYER_SKILLS, - LOG_FILTER_PLAYER_CHATLOG, - LOG_FILTER_LOOT, - LOG_FILTER_GUILD, - LOG_FILTER_TRANSPORTS, - LOG_FILTER_SQL, - LOG_FILTER_GMCOMMAND, - LOG_FILTER_REMOTECOMMAND, - LOG_FILTER_WARDEN, - LOG_FILTER_AUTHSERVER, - LOG_FILTER_WORLDSERVER, - LOG_FILTER_GAMEEVENTS, - LOG_FILTER_CALENDAR, - LOG_FILTER_CHARACTER, - LOG_FILTER_ARENAS, - LOG_FILTER_SQL_DRIVER, - LOG_FILTER_SQL_DEV, - LOG_FILTER_PLAYER_DUMP, - LOG_FILTER_BATTLEFIELD, - LOG_FILTER_SERVER_LOADING, - LOG_FILTER_OPCODES + LOG_FILTER_GENERAL = 0, // This one should only be used inside Log.cpp + LOG_FILTER_UNITS = 1, // Anything related to units that doesn't fit in other categories. ie. creature formations + LOG_FILTER_PETS = 2, + LOG_FILTER_VEHICLES = 3, + LOG_FILTER_TSCR = 4, // C++ AI, instance scripts, etc. + LOG_FILTER_DATABASE_AI = 5, // SmartAI, EventAI, Creature* * AI + LOG_FILTER_MAPSCRIPTS = 6, + LOG_FILTER_NETWORKIO = 7, + LOG_FILTER_SPELLS_AURAS = 8, + LOG_FILTER_ACHIEVEMENTSYS = 9, + LOG_FILTER_CONDITIONSYS = 10, + LOG_FILTER_POOLSYS = 11, + LOG_FILTER_AUCTIONHOUSE = 12, + LOG_FILTER_BATTLEGROUND = 13, + LOG_FILTER_OUTDOORPVP = 14, + LOG_FILTER_CHATSYS = 15, + LOG_FILTER_LFG = 16, + LOG_FILTER_MAPS = 17, + LOG_FILTER_PLAYER = 18, // Any player log that does not fit in other player filters + LOG_FILTER_PLAYER_LOADING = 19, // Debug output from Player::_Load functions + LOG_FILTER_PLAYER_ITEMS = 20, + LOG_FILTER_PLAYER_SKILLS = 21, + LOG_FILTER_PLAYER_CHATLOG = 22, + LOG_FILTER_LOOT = 23, + LOG_FILTER_GUILD = 24, + LOG_FILTER_TRANSPORTS = 25, + LOG_FILTER_SQL = 26, + LOG_FILTER_GMCOMMAND = 27, + LOG_FILTER_REMOTECOMMAND = 28, + LOG_FILTER_WARDEN = 29, + LOG_FILTER_AUTHSERVER = 30, + LOG_FILTER_WORLDSERVER = 31, + LOG_FILTER_GAMEEVENTS = 32, + LOG_FILTER_CALENDAR = 33, + LOG_FILTER_CHARACTER = 34, + LOG_FILTER_ARENAS = 35, + LOG_FILTER_SQL_DRIVER = 36, + LOG_FILTER_SQL_DEV = 37, + LOG_FILTER_PLAYER_DUMP = 38, + LOG_FILTER_BATTLEFIELD = 39, + LOG_FILTER_SERVER_LOADING = 40, + LOG_FILTER_OPCODES = 41, + LOG_FILTER_SOAP = 42 }; -const uint8 MaxLogFilter = uint8(LOG_FILTER_OPCODES) + 1; +const uint8 MaxLogFilter = 43; // Values assigned have their equivalent in enum ACE_Log_Priority enum LogLevel @@ -95,12 +96,12 @@ enum AppenderType enum AppenderFlags { - APPENDER_FLAGS_NONE = 0x00, - APPENDER_FLAGS_PREFIX_TIMESTAMP = 0x01, - APPENDER_FLAGS_PREFIX_LOGLEVEL = 0x02, - APPENDER_FLAGS_PREFIX_LOGFILTERTYPE = 0x04, - APPENDER_FLAGS_USE_TIMESTAMP = 0x08, // only used by FileAppender - APPENDER_FLAGS_MAKE_FILE_BACKUP = 0x10 // only used by FileAppender + APPENDER_FLAGS_NONE = 0x00, + APPENDER_FLAGS_PREFIX_TIMESTAMP = 0x01, + APPENDER_FLAGS_PREFIX_LOGLEVEL = 0x02, + APPENDER_FLAGS_PREFIX_LOGFILTERTYPE = 0x04, + APPENDER_FLAGS_USE_TIMESTAMP = 0x08, // only used by FileAppender + APPENDER_FLAGS_MAKE_FILE_BACKUP = 0x10 // only used by FileAppender }; struct LogMessage diff --git a/src/server/shared/Logging/Log.cpp b/src/server/shared/Logging/Log.cpp index 4538fc75c1e..d8914ac8ee0 100755 --- a/src/server/shared/Logging/Log.cpp +++ b/src/server/shared/Logging/Log.cpp @@ -435,10 +435,10 @@ void Log::outCharDump(char const* str, uint32 accountId, uint32 guid, char const << ")\n" << str << "\n== END DUMP ==\n"; LogMessage* msg = new LogMessage(LOG_LEVEL_INFO, LOG_FILTER_PLAYER_DUMP, ss.str()); - ss.clear(); - ss << guid << '_' << name; + std::ostringstream param; + param << guid << '_' << name; - msg->param1 = ss.str(); + msg->param1 = param.str(); write(msg); } diff --git a/src/server/worldserver/Main.cpp b/src/server/worldserver/Main.cpp index 7e43cf87dfc..16fbca2597d 100755 --- a/src/server/worldserver/Main.cpp +++ b/src/server/worldserver/Main.cpp @@ -104,13 +104,13 @@ extern int main(int argc, char **argv) if (strcmp(argv[c], "install") == 0) { if (WinServiceInstall()) - printf("Installing service"); + printf("Installing service\n"); return 1; } else if (strcmp(argv[c], "uninstall") == 0) { if (WinServiceUninstall()) - printf("Uninstalling service"); + printf("Uninstalling service\n"); return 1; } else @@ -131,8 +131,8 @@ extern int main(int argc, char **argv) if (!ConfigMgr::Load(cfg_file)) { - printf("Invalid or missing configuration file : %s", cfg_file); - printf("Verify that the file exists and has \'[worldserver]' written in the top of the file!"); + printf("Invalid or missing configuration file : %s\n", cfg_file); + printf("Verify that the file exists and has \'[worldserver]' written in the top of the file!\n"); return 1; } sLog->outInfo(LOG_FILTER_WORLDSERVER, "Using configuration file %s.", cfg_file); diff --git a/src/server/worldserver/TCSoap/TCSoap.cpp b/src/server/worldserver/TCSoap/TCSoap.cpp index 3ce4d4f59cb..40b35df9aee 100755 --- a/src/server/worldserver/TCSoap/TCSoap.cpp +++ b/src/server/worldserver/TCSoap/TCSoap.cpp @@ -32,18 +32,18 @@ void TCSoapRunnable::run() soap.send_timeout = 5; if (!soap_valid_socket(soap_bind(&soap, m_host.c_str(), m_port, 100))) { - sLog->outError(LOG_FILTER_WORLDSERVER, "TCSoap: couldn't bind to %s:%d", m_host.c_str(), m_port); + sLog->outError(LOG_FILTER_SOAP, "Couldn't bind to %s:%d", m_host.c_str(), m_port); exit(-1); } - sLog->outInfo(LOG_FILTER_WORLDSERVER, "TCSoap: bound to http://%s:%d", m_host.c_str(), m_port); + sLog->outInfo(LOG_FILTER_SOAP, "Bound to http://%s:%d", m_host.c_str(), m_port); while (!World::IsStopped()) { if (!soap_valid_socket(soap_accept(&soap))) continue; // ran into an accept timeout - sLog->outDebug(LOG_FILTER_NETWORKIO, "TCSoap: accepted connection from IP=%d.%d.%d.%d", (int)(soap.ip>>24)&0xFF, (int)(soap.ip>>16)&0xFF, (int)(soap.ip>>8)&0xFF, (int)soap.ip&0xFF); + sLog->outDebug(LOG_FILTER_SOAP, "Accepted connection from IP=%d.%d.%d.%d", (int)(soap.ip>>24)&0xFF, (int)(soap.ip>>16)&0xFF, (int)(soap.ip>>8)&0xFF, (int)soap.ip&0xFF); struct soap* thread_soap = soap_copy(&soap);// make a safe copy ACE_Message_Block* mb = new ACE_Message_Block(sizeof(struct soap*)); @@ -78,33 +78,33 @@ int ns1__executeCommand(soap* soap, char* command, char** result) // security check if (!soap->userid || !soap->passwd) { - sLog->outDebug(LOG_FILTER_NETWORKIO, "TCSoap: Client didn't provide login information"); + sLog->outDebug(LOG_FILTER_SOAP, "Client didn't provide login information"); return 401; } uint32 accountId = AccountMgr::GetId(soap->userid); if (!accountId) { - sLog->outDebug(LOG_FILTER_NETWORKIO, "TCSoap: Client used invalid username '%s'", soap->userid); + sLog->outDebug(LOG_FILTER_SOAP, "Client used invalid username '%s'", soap->userid); return 401; } if (!AccountMgr::CheckPassword(accountId, soap->passwd)) { - sLog->outDebug(LOG_FILTER_NETWORKIO, "TCSoap: invalid password for account '%s'", soap->userid); + sLog->outDebug(LOG_FILTER_SOAP, "Invalid password for account '%s'", soap->userid); return 401; } if (AccountMgr::GetSecurity(accountId) < SEC_ADMINISTRATOR) { - sLog->outDebug(LOG_FILTER_NETWORKIO, "TCSoap: %s's gmlevel is too low", soap->userid); + sLog->outDebug(LOG_FILTER_SOAP, "%s's gmlevel is too low", soap->userid); return 403; } if (!command || !*command) return soap_sender_fault(soap, "Command mustn't be empty", "The supplied command was an empty string"); - sLog->outDebug(LOG_FILTER_NETWORKIO, "TCSoap: got command '%s'", command); + sLog->outDebug(LOG_FILTER_SOAP, "Got command '%s'", command); SOAPCommand connection; // commands are executed in the world thread. We have to wait for them to be completed @@ -119,7 +119,7 @@ int ns1__executeCommand(soap* soap, char* command, char** result) int acc = connection.pendingCommands.acquire(); if (acc) { - sLog->outError(LOG_FILTER_WORLDSERVER, "TCSoap: Error while acquiring lock, acc = %i, errno = %u", acc, errno); + sLog->outError(LOG_FILTER_SOAP, "Error while acquiring lock, acc = %i, errno = %u", acc, errno); } // alright, command finished diff --git a/src/server/worldserver/worldserver.conf.dist b/src/server/worldserver/worldserver.conf.dist index 14d772aa79a..426d4ab2d55 100644 --- a/src/server/worldserver/worldserver.conf.dist +++ b/src/server/worldserver/worldserver.conf.dist @@ -983,6 +983,14 @@ Quests.IgnoreAutoComplete = 0 Guild.EventLogRecordsCount = 100 # +# Guild.ResetHour +# Description: Hour of the day when the daily cap resets occur. +# Range: 0-23 +# Default: 6 - (06:00 AM) + +Guild.ResetHour = 6 + +# # Guild.BankEventLogRecordsCount # Description: Number of log entries for guild bank events that are stored per guild. Old # entries will be overwritten if the number of log entries exceed the @@ -1113,12 +1121,15 @@ Command.LookupMaxResults = 0 AllowTickets = 1 # -# DungeonFinder.Enable +# DungeonFinder.OptionsMask # Description: Dungeon and raid finder system. -# Default: 1 - (Enabled) -# 0 - (Disabled) +# Value is a bitmask consisting of: +# LFG_OPTION_ENABLE_DUNGEON_FINDER = 1, Enable the dungeon finder browser +# LFG_OPTION_ENABLE_RAID_BROWSER = 2, Enable the raid browser +# Default: 1 + +DungeonFinder.OptionsMask = 1 -DungeonFinder.Enable = 1 # # DBC.EnforceItemAttributes @@ -2790,6 +2801,8 @@ Appenders=Console Server GM DBErrors Char RA Warden Chat # 39 - Battlefield # 40 - Server Loading # 41 - Opcodes (just id and name sent / received) +# 42 - SOAP +# # LogLevel # 0 - (Disabled) # 1 - (Trace) |