aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rwxr-xr-xsrc/server/authserver/Server/AuthSocket.cpp5
-rwxr-xr-xsrc/server/collision/BoundingIntervalHierarchy.h1
-rw-r--r--src/server/collision/Management/VMapManager2.cpp6
-rwxr-xr-xsrc/server/collision/Management/VMapManager2.h3
-rw-r--r--src/server/collision/Maps/TileAssembler.cpp8
-rw-r--r--src/server/collision/Models/WorldModel.cpp3
-rwxr-xr-xsrc/server/game/AI/CreatureAI.cpp4
-rwxr-xr-xsrc/server/game/AI/EventAI/CreatureEventAI.cpp13
-rw-r--r--src/server/game/AI/ScriptedAI/ScriptedCreature.cpp5
-rw-r--r--src/server/game/AI/ScriptedAI/ScriptedEscortAI.cpp2
-rw-r--r--src/server/game/AI/SmartScripts/SmartAI.cpp33
-rw-r--r--src/server/game/AI/SmartScripts/SmartScript.cpp139
-rw-r--r--src/server/game/AI/SmartScripts/SmartScript.h18
-rw-r--r--src/server/game/AI/SmartScripts/SmartScriptMgr.cpp70
-rw-r--r--src/server/game/AI/SmartScripts/SmartScriptMgr.h27
-rwxr-xr-xsrc/server/game/Achievements/AchievementMgr.cpp7
-rwxr-xr-xsrc/server/game/Achievements/AchievementMgr.h2
-rwxr-xr-xsrc/server/game/Battlegrounds/ArenaTeam.cpp38
-rwxr-xr-xsrc/server/game/Battlegrounds/ArenaTeam.h6
-rwxr-xr-xsrc/server/game/Battlegrounds/Battleground.cpp280
-rwxr-xr-xsrc/server/game/Battlegrounds/Battleground.h12
-rwxr-xr-xsrc/server/game/Battlegrounds/BattlegroundMgr.cpp46
-rwxr-xr-xsrc/server/game/Battlegrounds/BattlegroundMgr.h8
-rwxr-xr-xsrc/server/game/Battlegrounds/BattlegroundQueue.cpp145
-rwxr-xr-xsrc/server/game/Battlegrounds/BattlegroundQueue.h1
-rwxr-xr-xsrc/server/game/Battlegrounds/Zones/BattlegroundAA.cpp8
-rwxr-xr-xsrc/server/game/Battlegrounds/Zones/BattlegroundAA.h4
-rwxr-xr-xsrc/server/game/Battlegrounds/Zones/BattlegroundAB.cpp16
-rwxr-xr-xsrc/server/game/Battlegrounds/Zones/BattlegroundAB.h4
-rwxr-xr-xsrc/server/game/Battlegrounds/Zones/BattlegroundAV.cpp40
-rwxr-xr-xsrc/server/game/Battlegrounds/Zones/BattlegroundAV.h4
-rwxr-xr-xsrc/server/game/Battlegrounds/Zones/BattlegroundBE.cpp8
-rwxr-xr-xsrc/server/game/Battlegrounds/Zones/BattlegroundBE.h6
-rwxr-xr-xsrc/server/game/Battlegrounds/Zones/BattlegroundDS.cpp8
-rwxr-xr-xsrc/server/game/Battlegrounds/Zones/BattlegroundDS.h6
-rwxr-xr-xsrc/server/game/Battlegrounds/Zones/BattlegroundEY.cpp50
-rwxr-xr-xsrc/server/game/Battlegrounds/Zones/BattlegroundEY.h4
-rwxr-xr-xsrc/server/game/Battlegrounds/Zones/BattlegroundIC.cpp318
-rwxr-xr-xsrc/server/game/Battlegrounds/Zones/BattlegroundIC.h9
-rwxr-xr-xsrc/server/game/Battlegrounds/Zones/BattlegroundNA.cpp8
-rwxr-xr-xsrc/server/game/Battlegrounds/Zones/BattlegroundNA.h6
-rwxr-xr-xsrc/server/game/Battlegrounds/Zones/BattlegroundRB.cpp8
-rwxr-xr-xsrc/server/game/Battlegrounds/Zones/BattlegroundRB.h4
-rwxr-xr-xsrc/server/game/Battlegrounds/Zones/BattlegroundRL.cpp8
-rwxr-xr-xsrc/server/game/Battlegrounds/Zones/BattlegroundRL.h6
-rwxr-xr-xsrc/server/game/Battlegrounds/Zones/BattlegroundRV.cpp8
-rwxr-xr-xsrc/server/game/Battlegrounds/Zones/BattlegroundRV.h6
-rwxr-xr-xsrc/server/game/Battlegrounds/Zones/BattlegroundSA.cpp74
-rwxr-xr-xsrc/server/game/Battlegrounds/Zones/BattlegroundSA.h6
-rwxr-xr-xsrc/server/game/Battlegrounds/Zones/BattlegroundWS.cpp36
-rwxr-xr-xsrc/server/game/Battlegrounds/Zones/BattlegroundWS.h4
-rwxr-xr-xsrc/server/game/Chat/Channels/Channel.cpp88
-rwxr-xr-xsrc/server/game/Chat/Chat.cpp29
-rwxr-xr-xsrc/server/game/Chat/Chat.h2
-rwxr-xr-xsrc/server/game/Chat/Commands/Level1.cpp28
-rwxr-xr-xsrc/server/game/Chat/Commands/Level2.cpp16
-rwxr-xr-xsrc/server/game/Chat/Commands/Level3.cpp61
-rwxr-xr-xsrc/server/game/Conditions/DisableMgr.cpp17
-rwxr-xr-xsrc/server/game/DataStores/DBCStores.cpp2
-rwxr-xr-xsrc/server/game/DataStores/DBCStores.h1
-rwxr-xr-xsrc/server/game/DataStores/DBCStructure.h24
-rwxr-xr-xsrc/server/game/DataStores/DBCfmt.h3
-rwxr-xr-xsrc/server/game/DungeonFinding/LFGMgr.cpp232
-rwxr-xr-xsrc/server/game/DungeonFinding/LFGMgr.h12
-rw-r--r--src/server/game/DungeonFinding/LFGScripts.cpp25
-rwxr-xr-xsrc/server/game/Entities/Corpse/Corpse.cpp4
-rwxr-xr-xsrc/server/game/Entities/Corpse/Corpse.h6
-rwxr-xr-xsrc/server/game/Entities/Creature/Creature.cpp49
-rwxr-xr-xsrc/server/game/Entities/Creature/Creature.h6
-rwxr-xr-xsrc/server/game/Entities/Creature/GossipDef.cpp78
-rwxr-xr-xsrc/server/game/Entities/GameObject/GameObject.cpp92
-rwxr-xr-xsrc/server/game/Entities/GameObject/GameObject.h1
-rwxr-xr-xsrc/server/game/Entities/Item/Item.cpp34
-rwxr-xr-xsrc/server/game/Entities/Item/Item.h3
-rwxr-xr-xsrc/server/game/Entities/Item/ItemPrototype.h1
-rwxr-xr-xsrc/server/game/Entities/Object/Object.cpp71
-rwxr-xr-xsrc/server/game/Entities/Object/Object.h23
-rwxr-xr-xsrc/server/game/Entities/Object/ObjectPosSelector.cpp22
-rwxr-xr-xsrc/server/game/Entities/Object/ObjectPosSelector.h4
-rwxr-xr-xsrc/server/game/Entities/Object/Updates/UpdateMask.h3
-rwxr-xr-xsrc/server/game/Entities/Pet/Pet.cpp16
-rwxr-xr-xsrc/server/game/Entities/Player/Player.cpp797
-rwxr-xr-xsrc/server/game/Entities/Player/Player.h73
-rwxr-xr-xsrc/server/game/Entities/Player/SocialMgr.cpp12
-rwxr-xr-xsrc/server/game/Entities/Player/SocialMgr.h2
-rwxr-xr-xsrc/server/game/Entities/Totem/Totem.cpp5
-rwxr-xr-xsrc/server/game/Entities/Transport/Transport.cpp47
-rwxr-xr-xsrc/server/game/Entities/Unit/StatSystem.cpp69
-rwxr-xr-xsrc/server/game/Entities/Unit/Unit.cpp367
-rwxr-xr-xsrc/server/game/Entities/Unit/Unit.h46
-rwxr-xr-xsrc/server/game/Entities/Vehicle/Vehicle.cpp6
-rwxr-xr-xsrc/server/game/Events/GameEventMgr.cpp14
-rwxr-xr-xsrc/server/game/Events/GameEventMgr.h4
-rwxr-xr-xsrc/server/game/Globals/ObjectAccessor.cpp66
-rwxr-xr-xsrc/server/game/Globals/ObjectAccessor.h91
-rwxr-xr-xsrc/server/game/Globals/ObjectMgr.cpp504
-rwxr-xr-xsrc/server/game/Globals/ObjectMgr.h6
-rwxr-xr-xsrc/server/game/Grids/Cells/Cell.h103
-rw-r--r--[-rwxr-xr-x]src/server/game/Grids/Cells/CellImpl.h196
-rwxr-xr-xsrc/server/game/Grids/Grid.h49
-rw-r--r--[-rwxr-xr-x]src/server/game/Grids/GridDefines.h88
-rwxr-xr-xsrc/server/game/Grids/GridLoader.h13
-rwxr-xr-xsrc/server/game/Grids/GridStates.cpp27
-rwxr-xr-xsrc/server/game/Grids/GridStates.h14
-rwxr-xr-xsrc/server/game/Grids/NGrid.h63
-rwxr-xr-xsrc/server/game/Grids/Notifiers/GridNotifiers.cpp53
-rwxr-xr-xsrc/server/game/Grids/Notifiers/GridNotifiers.h14
-rwxr-xr-xsrc/server/game/Grids/Notifiers/GridNotifiersImpl.h6
-rwxr-xr-xsrc/server/game/Grids/ObjectGridLoader.cpp154
-rwxr-xr-xsrc/server/game/Grids/ObjectGridLoader.h77
-rwxr-xr-xsrc/server/game/Groups/Group.cpp43
-rwxr-xr-xsrc/server/game/Instances/InstanceSaveMgr.cpp8
-rwxr-xr-xsrc/server/game/Instances/InstanceSaveMgr.h4
-rwxr-xr-xsrc/server/game/Instances/InstanceScript.cpp17
-rwxr-xr-xsrc/server/game/Loot/LootMgr.cpp34
-rwxr-xr-xsrc/server/game/Loot/LootMgr.h2
-rwxr-xr-xsrc/server/game/Maps/Map.cpp433
-rwxr-xr-xsrc/server/game/Maps/Map.h85
-rwxr-xr-xsrc/server/game/Maps/MapInstanced.cpp16
-rwxr-xr-xsrc/server/game/Maps/MapInstanced.h23
-rwxr-xr-xsrc/server/game/Maps/MapManager.cpp43
-rwxr-xr-xsrc/server/game/Maps/MapManager.h21
-rw-r--r--src/server/game/Maps/MapUpdater.cpp6
-rwxr-xr-xsrc/server/game/Miscellaneous/Formulas.h6
-rwxr-xr-xsrc/server/game/Miscellaneous/SharedDefines.h11
-rwxr-xr-xsrc/server/game/Movement/MovementGenerators/ConfusedMovementGenerator.cpp31
-rwxr-xr-xsrc/server/game/Movement/MovementGenerators/PointMovementGenerator.cpp4
-rwxr-xr-xsrc/server/game/Movement/MovementGenerators/WaypointMovementGenerator.cpp10
-rwxr-xr-xsrc/server/game/Movement/Waypoints/WaypointManager.cpp24
-rwxr-xr-xsrc/server/game/Movement/Waypoints/WaypointManager.h2
-rwxr-xr-xsrc/server/game/OutdoorPvP/OutdoorPvP.cpp80
-rwxr-xr-xsrc/server/game/OutdoorPvP/OutdoorPvP.h42
-rwxr-xr-xsrc/server/game/OutdoorPvP/OutdoorPvPMgr.cpp38
-rwxr-xr-xsrc/server/game/OutdoorPvP/OutdoorPvPMgr.h12
-rwxr-xr-xsrc/server/game/Pools/PoolMgr.cpp12
-rwxr-xr-xsrc/server/game/Quests/QuestDef.cpp214
-rwxr-xr-xsrc/server/game/Quests/QuestDef.h176
-rwxr-xr-xsrc/server/game/Reputation/ReputationMgr.cpp2
-rwxr-xr-xsrc/server/game/Scripting/MapScripts.cpp26
-rwxr-xr-xsrc/server/game/Scripting/ScriptMgr.cpp1
-rwxr-xr-xsrc/server/game/Scripting/ScriptSystem.cpp19
-rw-r--r--src/server/game/Scripting/ScriptSystem.h1
-rwxr-xr-xsrc/server/game/Server/Protocol/Handlers/AddonHandler.cpp6
-rwxr-xr-xsrc/server/game/Server/Protocol/Handlers/AuctionHouseHandler.cpp62
-rwxr-xr-xsrc/server/game/Server/Protocol/Handlers/CalendarHandler.cpp75
-rwxr-xr-xsrc/server/game/Server/Protocol/Handlers/CharacterHandler.cpp12
-rwxr-xr-xsrc/server/game/Server/Protocol/Handlers/ChatHandler.cpp7
-rwxr-xr-xsrc/server/game/Server/Protocol/Handlers/DuelHandler.cpp14
-rwxr-xr-xsrc/server/game/Server/Protocol/Handlers/GroupHandler.cpp8
-rwxr-xr-xsrc/server/game/Server/Protocol/Handlers/ItemHandler.cpp2
-rwxr-xr-xsrc/server/game/Server/Protocol/Handlers/LFGHandler.cpp24
-rwxr-xr-xsrc/server/game/Server/Protocol/Handlers/LootHandler.cpp4
-rwxr-xr-xsrc/server/game/Server/Protocol/Handlers/MailHandler.cpp168
-rwxr-xr-xsrc/server/game/Server/Protocol/Handlers/MiscHandler.cpp28
-rwxr-xr-xsrc/server/game/Server/Protocol/Handlers/MovementHandler.cpp8
-rwxr-xr-xsrc/server/game/Server/Protocol/Handlers/QueryHandler.cpp4
-rwxr-xr-xsrc/server/game/Server/Protocol/Handlers/QuestHandler.cpp2
-rw-r--r--src/server/game/Server/Protocol/Handlers/VehicleHandler.cpp20
-rwxr-xr-xsrc/server/game/Server/Protocol/Opcodes.cpp2
-rwxr-xr-xsrc/server/game/Server/Protocol/WorldLog.cpp4
-rwxr-xr-xsrc/server/game/Server/WorldSession.cpp19
-rwxr-xr-xsrc/server/game/Server/WorldSession.h168
-rwxr-xr-xsrc/server/game/Server/WorldSocket.cpp2
-rwxr-xr-xsrc/server/game/Server/WorldSocketMgr.cpp6
-rwxr-xr-xsrc/server/game/Spells/Auras/SpellAuraEffects.cpp90
-rw-r--r--src/server/game/Spells/Auras/SpellAuraEffects.h1
-rwxr-xr-xsrc/server/game/Spells/Auras/SpellAuras.cpp9
-rwxr-xr-xsrc/server/game/Spells/Spell.cpp118
-rwxr-xr-xsrc/server/game/Spells/Spell.h4
-rwxr-xr-xsrc/server/game/Spells/SpellEffects.cpp145
-rw-r--r--src/server/game/Spells/SpellInfo.cpp11
-rw-r--r--src/server/game/Spells/SpellInfo.h1
-rwxr-xr-xsrc/server/game/Spells/SpellMgr.cpp169
-rwxr-xr-xsrc/server/game/Spells/SpellMgr.h69
-rwxr-xr-xsrc/server/game/Texts/CreatureTextMgr.cpp8
-rw-r--r--src/server/game/Tools/PlayerDump.cpp13
-rwxr-xr-xsrc/server/game/World/World.cpp22
-rwxr-xr-xsrc/server/game/World/World.h14
-rw-r--r--src/server/scripts/Commands/cs_account.cpp2
-rw-r--r--src/server/scripts/Commands/cs_gm.cpp4
-rw-r--r--src/server/scripts/Commands/cs_gps.cpp86
-rw-r--r--src/server/scripts/Commands/cs_honor.cpp11
-rw-r--r--src/server/scripts/Commands/cs_learn.cpp124
-rw-r--r--src/server/scripts/Commands/cs_npc.cpp8
-rw-r--r--src/server/scripts/Commands/cs_quest.cpp16
-rw-r--r--src/server/scripts/Commands/cs_tele.cpp57
-rw-r--r--src/server/scripts/Commands/cs_wp.cpp82
-rw-r--r--src/server/scripts/EasternKingdoms/Karazhan/boss_netherspite.cpp6
-rw-r--r--src/server/scripts/EasternKingdoms/MagistersTerrace/boss_priestess_delrissa.cpp3
-rw-r--r--src/server/scripts/EasternKingdoms/MoltenCore/boss_ragnaros.cpp2
-rw-r--r--src/server/scripts/EasternKingdoms/ScarletEnclave/chapter5.cpp8
-rw-r--r--src/server/scripts/EasternKingdoms/ScarletEnclave/the_scarlet_enclave.cpp8
-rw-r--r--src/server/scripts/EasternKingdoms/ScarletMonastery/boss_headless_horseman.cpp11
-rw-r--r--src/server/scripts/EasternKingdoms/ScarletMonastery/boss_mograine_and_whitemane.cpp2
-rw-r--r--src/server/scripts/EasternKingdoms/SunwellPlateau/boss_felmyst.cpp5
-rw-r--r--src/server/scripts/EasternKingdoms/SunwellPlateau/boss_kiljaeden.cpp6
-rw-r--r--src/server/scripts/EasternKingdoms/SunwellPlateau/boss_muru.cpp8
-rw-r--r--src/server/scripts/EasternKingdoms/ZulAman/boss_akilzon.cpp9
-rw-r--r--src/server/scripts/EasternKingdoms/ZulAman/boss_janalai.cpp15
-rw-r--r--src/server/scripts/EasternKingdoms/ZulAman/boss_nalorakk.cpp5
-rw-r--r--src/server/scripts/EasternKingdoms/ZulGurub/boss_mandokir.cpp6
-rw-r--r--src/server/scripts/EasternKingdoms/eversong_woods.cpp86
-rw-r--r--src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/hyjalAI.cpp33
-rw-r--r--src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/instance_hyjal.cpp6
-rw-r--r--src/server/scripts/Kalimdor/CavernsOfTime/CullingOfStratholme/culling_of_stratholme.cpp16
-rw-r--r--src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_cthun.cpp8
-rw-r--r--src/server/scripts/Northrend/AzjolNerub/Ahnkahet/ahnkahet.h (renamed from src/server/scripts/Northrend/AzjolNerub/ahnkahet/ahnkahet.h)0
-rw-r--r--src/server/scripts/Northrend/AzjolNerub/Ahnkahet/boss_amanitar.cpp (renamed from src/server/scripts/Northrend/AzjolNerub/ahnkahet/boss_amanitar.cpp)0
-rw-r--r--src/server/scripts/Northrend/AzjolNerub/Ahnkahet/boss_elder_nadox.cpp (renamed from src/server/scripts/Northrend/AzjolNerub/ahnkahet/boss_elder_nadox.cpp)0
-rw-r--r--src/server/scripts/Northrend/AzjolNerub/Ahnkahet/boss_herald_volazj.cpp (renamed from src/server/scripts/Northrend/AzjolNerub/ahnkahet/boss_herald_volazj.cpp)0
-rw-r--r--src/server/scripts/Northrend/AzjolNerub/Ahnkahet/boss_jedoga_shadowseeker.cpp (renamed from src/server/scripts/Northrend/AzjolNerub/ahnkahet/boss_jedoga_shadowseeker.cpp)0
-rw-r--r--src/server/scripts/Northrend/AzjolNerub/Ahnkahet/boss_prince_taldaram.cpp (renamed from src/server/scripts/Northrend/AzjolNerub/ahnkahet/boss_prince_taldaram.cpp)0
-rw-r--r--src/server/scripts/Northrend/AzjolNerub/Ahnkahet/instance_ahnkahet.cpp (renamed from src/server/scripts/Northrend/AzjolNerub/ahnkahet/instance_ahnkahet.cpp)0
-rw-r--r--src/server/scripts/Northrend/AzjolNerub/AzjolNerub/boss_hadronox.cpp2
-rw-r--r--src/server/scripts/Northrend/CMakeLists.txt48
-rw-r--r--src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheChampion/trial_of_the_champion.cpp21
-rwxr-xr-xsrc/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_anubarak_trial.cpp4
-rwxr-xr-xsrc/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_lord_jaraxxus.cpp9
-rwxr-xr-xsrc/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_northrend_beasts.cpp6
-rw-r--r--src/server/scripts/Northrend/FrozenHalls/ForgeOfSouls/boss_devourer_of_souls.cpp4
-rw-r--r--src/server/scripts/Northrend/FrozenHalls/ForgeOfSouls/forge_of_souls.h1
-rw-r--r--src/server/scripts/Northrend/Gundrak/boss_slad_ran.cpp58
-rwxr-xr-xsrc/server/scripts/Northrend/IcecrownCitadel/boss_festergut.cpp4
-rwxr-xr-xsrc/server/scripts/Northrend/IcecrownCitadel/boss_lady_deathwhisper.cpp8
-rw-r--r--src/server/scripts/Northrend/IcecrownCitadel/boss_sindragosa.cpp7
-rw-r--r--src/server/scripts/Northrend/IcecrownCitadel/boss_the_lich_king.cpp19
-rw-r--r--src/server/scripts/Northrend/Naxxramas/boss_kelthuzad.cpp6
-rw-r--r--src/server/scripts/Northrend/Naxxramas/boss_patchwerk.cpp6
-rw-r--r--src/server/scripts/Northrend/Naxxramas/boss_sapphiron.cpp20
-rw-r--r--src/server/scripts/Northrend/Ulduar/Ulduar/boss_algalon.cpp (renamed from src/server/scripts/Northrend/Ulduar/ulduar/boss_algalon.cpp)0
-rw-r--r--src/server/scripts/Northrend/Ulduar/Ulduar/boss_assembly_of_iron.cpp (renamed from src/server/scripts/Northrend/Ulduar/ulduar/boss_assembly_of_iron.cpp)24
-rw-r--r--src/server/scripts/Northrend/Ulduar/Ulduar/boss_auriaya.cpp (renamed from src/server/scripts/Northrend/Ulduar/ulduar/boss_auriaya.cpp)0
-rw-r--r--src/server/scripts/Northrend/Ulduar/Ulduar/boss_flame_leviathan.cpp (renamed from src/server/scripts/Northrend/Ulduar/ulduar/boss_flame_leviathan.cpp)0
-rw-r--r--src/server/scripts/Northrend/Ulduar/Ulduar/boss_freya.cpp (renamed from src/server/scripts/Northrend/Ulduar/ulduar/boss_freya.cpp)78
-rw-r--r--src/server/scripts/Northrend/Ulduar/Ulduar/boss_general_vezax.cpp (renamed from src/server/scripts/Northrend/Ulduar/ulduar/boss_general_vezax.cpp)0
-rw-r--r--src/server/scripts/Northrend/Ulduar/Ulduar/boss_hodir.cpp (renamed from src/server/scripts/Northrend/Ulduar/ulduar/boss_hodir.cpp)0
-rw-r--r--src/server/scripts/Northrend/Ulduar/Ulduar/boss_ignis.cpp (renamed from src/server/scripts/Northrend/Ulduar/ulduar/boss_ignis.cpp)0
-rw-r--r--src/server/scripts/Northrend/Ulduar/Ulduar/boss_kologarn.cpp (renamed from src/server/scripts/Northrend/Ulduar/ulduar/boss_kologarn.cpp)0
-rw-r--r--src/server/scripts/Northrend/Ulduar/Ulduar/boss_mimiron.cpp (renamed from src/server/scripts/Northrend/Ulduar/ulduar/boss_mimiron.cpp)0
-rw-r--r--src/server/scripts/Northrend/Ulduar/Ulduar/boss_razorscale.cpp (renamed from src/server/scripts/Northrend/Ulduar/ulduar/boss_razorscale.cpp)0
-rw-r--r--src/server/scripts/Northrend/Ulduar/Ulduar/boss_thorim.cpp (renamed from src/server/scripts/Northrend/Ulduar/ulduar/boss_thorim.cpp)0
-rw-r--r--src/server/scripts/Northrend/Ulduar/Ulduar/boss_xt002.cpp (renamed from src/server/scripts/Northrend/Ulduar/ulduar/boss_xt002.cpp)0
-rw-r--r--src/server/scripts/Northrend/Ulduar/Ulduar/boss_yoggsaron.cpp (renamed from src/server/scripts/Northrend/Ulduar/ulduar/boss_yoggsaron.cpp)0
-rw-r--r--src/server/scripts/Northrend/Ulduar/Ulduar/instance_ulduar.cpp (renamed from src/server/scripts/Northrend/Ulduar/ulduar/instance_ulduar.cpp)0
-rw-r--r--src/server/scripts/Northrend/Ulduar/Ulduar/ulduar.h (renamed from src/server/scripts/Northrend/Ulduar/ulduar/ulduar.h)0
-rw-r--r--src/server/scripts/Northrend/Ulduar/Ulduar/ulduar_teleporter.cpp (renamed from src/server/scripts/Northrend/Ulduar/ulduar/ulduar_teleporter.cpp)0
-rw-r--r--src/server/scripts/Northrend/UtgardeKeep/UtgardeKeep/boss_ingvar_the_plunderer.cpp4
-rw-r--r--src/server/scripts/Northrend/UtgardeKeep/UtgardePinnacle/boss_svala.cpp3
-rw-r--r--src/server/scripts/Northrend/borean_tundra.cpp2
-rw-r--r--src/server/scripts/Northrend/dalaran.cpp5
-rw-r--r--src/server/scripts/Northrend/sholazar_basin.cpp3
-rw-r--r--src/server/scripts/Northrend/zuldrak.cpp4
-rwxr-xr-xsrc/server/scripts/OutdoorPvP/OutdoorPvPNA.cpp2
-rw-r--r--src/server/scripts/Outland/Auchindoun/AuchenaiCrypts/boss_exarch_maladaar.cpp2
-rw-r--r--src/server/scripts/Outland/BlackTemple/boss_shade_of_akama.cpp4
-rw-r--r--src/server/scripts/Outland/BlackTemple/boss_warlord_najentus.cpp4
-rw-r--r--src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_lurker_below.cpp2
-rw-r--r--src/server/scripts/Outland/nagrand.cpp730
-rw-r--r--src/server/scripts/Outland/shadowmoon_valley.cpp3
-rw-r--r--src/server/scripts/Outland/shattrath_city.cpp2
-rw-r--r--src/server/scripts/Spells/spell_quest.cpp51
-rw-r--r--src/server/scripts/World/areatrigger_scripts.cpp114
-rw-r--r--src/server/scripts/World/go_scripts.cpp85
-rw-r--r--src/server/scripts/World/npc_professions.cpp4
-rwxr-xr-xsrc/server/shared/Common.h25
-rwxr-xr-xsrc/server/shared/Cryptography/ARC4.h2
-rwxr-xr-xsrc/server/shared/Cryptography/Authentication/AuthCrypt.cpp3
-rwxr-xr-xsrc/server/shared/Cryptography/Authentication/AuthCrypt.h1
-rwxr-xr-xsrc/server/shared/Cryptography/BigNumber.cpp23
-rwxr-xr-xsrc/server/shared/Cryptography/BigNumber.h2
-rwxr-xr-xsrc/server/shared/Cryptography/HMACSHA1.h3
-rwxr-xr-xsrc/server/shared/Cryptography/SHA1.h4
-rwxr-xr-xsrc/server/shared/Database/Implementation/CharacterDatabase.cpp16
-rwxr-xr-xsrc/server/shared/Database/Implementation/CharacterDatabase.h3
-rwxr-xr-xsrc/server/shared/Dynamic/TypeContainer.h10
-rwxr-xr-xsrc/server/shared/Dynamic/TypeContainerFunctions.h51
-rwxr-xr-xsrc/server/shared/Dynamic/UnorderedMap.h1
-rwxr-xr-xsrc/server/shared/Logging/Log.cpp66
-rwxr-xr-xsrc/server/shared/Logging/Log.h6
-rwxr-xr-xsrc/server/shared/Utilities/Util.cpp7
-rwxr-xr-xsrc/server/worldserver/CommandLine/CliRunnable.cpp34
-rwxr-xr-xsrc/server/worldserver/Master.cpp1
-rw-r--r--src/server/worldserver/RemoteAccess/RARunnable.cpp11
283 files changed, 5136 insertions, 5340 deletions
diff --git a/src/server/authserver/Server/AuthSocket.cpp b/src/server/authserver/Server/AuthSocket.cpp
index 1b0800e48ae..c24012efcef 100755
--- a/src/server/authserver/Server/AuthSocket.cpp
+++ b/src/server/authserver/Server/AuthSocket.cpp
@@ -27,6 +27,7 @@
#include "AuthSocket.h"
#include "AuthCodes.h"
#include "SHA1.h"
+#include "openssl/crypto.h"
#define ChunkSize 2048
@@ -615,8 +616,8 @@ bool AuthSocket::_HandleLogonProof()
memcpy(proof.M2, sha.GetDigest(), 20);
proof.cmd = AUTH_LOGON_PROOF;
proof.error = 0;
- proof.unk1 = 0x00800000;
- proof.unk2 = 0x00;
+ proof.unk1 = 0x00800000; // Accountflags. 0x01 = GM, 0x08 = Trial, 0x00800000 = Pro pass (arena tournament)
+ proof.unk2 = 0x00; // SurveyId
proof.unk3 = 0x00;
socket().send((char *)&proof, sizeof(proof));
}
diff --git a/src/server/collision/BoundingIntervalHierarchy.h b/src/server/collision/BoundingIntervalHierarchy.h
index 0dc597e98bc..cb6158e94eb 100755
--- a/src/server/collision/BoundingIntervalHierarchy.h
+++ b/src/server/collision/BoundingIntervalHierarchy.h
@@ -88,6 +88,7 @@ class BIH
{
if (primitives.empty())
return;
+
buildData dat;
dat.maxPrims = leafSize;
dat.numPrims = primitives.size();
diff --git a/src/server/collision/Management/VMapManager2.cpp b/src/server/collision/Management/VMapManager2.cpp
index 9f32c749c5c..0632542f82e 100644
--- a/src/server/collision/Management/VMapManager2.cpp
+++ b/src/server/collision/Management/VMapManager2.cpp
@@ -247,6 +247,9 @@ namespace VMAP
WorldModel* VMapManager2::acquireModelInstance(const std::string& basepath, const std::string& filename)
{
+ //! Critical section, thread safe access to iLoadedModelFiles
+ TRINITY_GUARD(ACE_Thread_Mutex, LoadedModelFilesLock);
+
ModelFileMap::iterator model = iLoadedModelFiles.find(filename);
if (model == iLoadedModelFiles.end())
{
@@ -267,6 +270,9 @@ namespace VMAP
void VMapManager2::releaseModelInstance(const std::string &filename)
{
+ //! Critical section, thread safe access to iLoadedModelFiles
+ TRINITY_GUARD(ACE_Thread_Mutex, LoadedModelFilesLock);
+
ModelFileMap::iterator model = iLoadedModelFiles.find(filename);
if (model == iLoadedModelFiles.end())
{
diff --git a/src/server/collision/Management/VMapManager2.h b/src/server/collision/Management/VMapManager2.h
index ac293e2071b..83fec0f0d11 100755
--- a/src/server/collision/Management/VMapManager2.h
+++ b/src/server/collision/Management/VMapManager2.h
@@ -22,6 +22,7 @@
#include "IVMapManager.h"
#include "Dynamic/UnorderedMap.h"
#include "Define.h"
+#include <ace/Thread_Mutex.h>
//===========================================================
@@ -71,6 +72,8 @@ namespace VMAP
// Tree to check collision
ModelFileMap iLoadedModelFiles;
InstanceTreeMap iInstanceMapTrees;
+ // Mutex for iLoadedModelFiles
+ ACE_Thread_Mutex LoadedModelFilesLock;
bool _loadMap(uint32 mapId, const std::string& basePath, uint32 tileX, uint32 tileY);
/* void _unloadMap(uint32 pMapId, uint32 x, uint32 y); */
diff --git a/src/server/collision/Maps/TileAssembler.cpp b/src/server/collision/Maps/TileAssembler.cpp
index 594e1a9382b..533a7ca825c 100644
--- a/src/server/collision/Maps/TileAssembler.cpp
+++ b/src/server/collision/Maps/TileAssembler.cpp
@@ -500,10 +500,10 @@ namespace VMAP
{
model.setGroupModels(groupsArray);
- std::string filename(iSrcDir);
- filename.push_back('/');
- filename.append(pModelFilename).append(".vmo");
- success = model.writeFile(filename);
+ std::string worldModelFileName(iSrcDir);
+ worldModelFileName.push_back('/');
+ worldModelFileName.append(pModelFilename).append(".vmo");
+ success = model.writeFile(worldModelFileName);
}
//std::cout << "readRawFile2: '" << pModelFilename << "' tris: " << nElements << " nodes: " << nNodes << std::endl;
diff --git a/src/server/collision/Models/WorldModel.cpp b/src/server/collision/Models/WorldModel.cpp
index 55aad9bb029..118ae098c25 100644
--- a/src/server/collision/Models/WorldModel.cpp
+++ b/src/server/collision/Models/WorldModel.cpp
@@ -362,6 +362,7 @@ namespace VMAP
{
if (triangles.empty())
return false;
+
GModelRayCallback callback(triangles, vertices);
meshTree.intersectRay(ray, callback, distance, stopAtFirstHit);
return callback.hit;
@@ -470,6 +471,7 @@ namespace VMAP
{
if (groupModels.empty())
return false;
+
WModelAreaCallback callback(groupModels, down);
groupTree.intersectPoint(p, callback);
if (callback.hit != groupModels.end())
@@ -488,6 +490,7 @@ namespace VMAP
{
if (groupModels.empty())
return false;
+
WModelAreaCallback callback(groupModels, down);
groupTree.intersectPoint(p, callback);
if (callback.hit != groupModels.end())
diff --git a/src/server/game/AI/CreatureAI.cpp b/src/server/game/AI/CreatureAI.cpp
index 329a2d004a5..5752fcede7b 100755
--- a/src/server/game/AI/CreatureAI.cpp
+++ b/src/server/game/AI/CreatureAI.cpp
@@ -59,8 +59,8 @@ void CreatureAI::DoZoneInCombat(Creature* creature /*= NULL*/, float maxRangeToN
if (!creature->HasReactState(REACT_PASSIVE) && !creature->getVictim())
{
- if (Unit* target = creature->SelectNearestTarget(maxRangeToNearestTarget))
- creature->AI()->AttackStart(target);
+ if (Unit* nearTarget = creature->SelectNearestTarget(maxRangeToNearestTarget))
+ creature->AI()->AttackStart(nearTarget);
else if (creature->isSummon())
{
if (Unit* summoner = creature->ToTempSummon()->GetSummoner())
diff --git a/src/server/game/AI/EventAI/CreatureEventAI.cpp b/src/server/game/AI/EventAI/CreatureEventAI.cpp
index 62d7a1f4f58..be0dd8c3679 100755
--- a/src/server/game/AI/EventAI/CreatureEventAI.cpp
+++ b/src/server/game/AI/EventAI/CreatureEventAI.cpp
@@ -1177,9 +1177,8 @@ inline Unit* CreatureEventAI::GetTargetByType(uint32 target, Unit* actionInvoker
Unit* CreatureEventAI::DoSelectLowestHpFriendly(float range, uint32 minHPDiff)
{
- CellPair p(Trinity::ComputeCellPair(me->GetPositionX(), me->GetPositionY()));
+ CellCoord p(Trinity::ComputeCellCoord(me->GetPositionX(), me->GetPositionY()));
Cell cell(p);
- cell.data.Part.reserved = ALL_DISTRICT;
cell.SetNoCreate();
Unit* unit = NULL;
@@ -1199,9 +1198,8 @@ Unit* CreatureEventAI::DoSelectLowestHpFriendly(float range, uint32 minHPDiff)
void CreatureEventAI::DoFindFriendlyCC(std::list<Creature*>& _list, float range)
{
- CellPair p(Trinity::ComputeCellPair(me->GetPositionX(), me->GetPositionY()));
+ CellCoord p(Trinity::ComputeCellCoord(me->GetPositionX(), me->GetPositionY()));
Cell cell(p);
- cell.data.Part.reserved = ALL_DISTRICT;
cell.SetNoCreate();
Trinity::FriendlyCCedInRange u_check(me, range);
@@ -1209,14 +1207,13 @@ void CreatureEventAI::DoFindFriendlyCC(std::list<Creature*>& _list, float range)
TypeContainerVisitor<Trinity::CreatureListSearcher<Trinity::FriendlyCCedInRange>, GridTypeMapContainer > grid_creature_searcher(searcher);
- cell.Visit(p, grid_creature_searcher, *me->GetMap());
+ cell.Visit(p, grid_creature_searcher, *me->GetMap(), *me, range);
}
void CreatureEventAI::DoFindFriendlyMissingBuff(std::list<Creature*>& _list, float range, uint32 spellid)
{
- CellPair p(Trinity::ComputeCellPair(me->GetPositionX(), me->GetPositionY()));
+ CellCoord p(Trinity::ComputeCellCoord(me->GetPositionX(), me->GetPositionY()));
Cell cell(p);
- cell.data.Part.reserved = ALL_DISTRICT;
cell.SetNoCreate();
Trinity::FriendlyMissingBuffInRange u_check(me, range, spellid);
@@ -1224,7 +1221,7 @@ void CreatureEventAI::DoFindFriendlyMissingBuff(std::list<Creature*>& _list, flo
TypeContainerVisitor<Trinity::CreatureListSearcher<Trinity::FriendlyMissingBuffInRange>, GridTypeMapContainer > grid_creature_searcher(searcher);
- cell.Visit(p, grid_creature_searcher, *me->GetMap());
+ cell.Visit(p, grid_creature_searcher, *me->GetMap(), *me, range);
}
// *********************************
diff --git a/src/server/game/AI/ScriptedAI/ScriptedCreature.cpp b/src/server/game/AI/ScriptedAI/ScriptedCreature.cpp
index 2322e88d105..953bbf7521a 100644
--- a/src/server/game/AI/ScriptedAI/ScriptedCreature.cpp
+++ b/src/server/game/AI/ScriptedAI/ScriptedCreature.cpp
@@ -363,16 +363,15 @@ Player* ScriptedAI::GetPlayerAtMinimumRange(float minimumRange)
{
Player* player = NULL;
- CellPair pair(Trinity::ComputeCellPair(me->GetPositionX(), me->GetPositionY()));
+ CellCoord pair(Trinity::ComputeCellCoord(me->GetPositionX(), me->GetPositionY()));
Cell cell(pair);
- cell.data.Part.reserved = ALL_DISTRICT;
cell.SetNoCreate();
Trinity::PlayerAtMinimumRangeAway check(me, minimumRange);
Trinity::PlayerSearcher<Trinity::PlayerAtMinimumRangeAway> searcher(me, player, check);
TypeContainerVisitor<Trinity::PlayerSearcher<Trinity::PlayerAtMinimumRangeAway>, GridTypeMapContainer> visitor(searcher);
- cell.Visit(pair, visitor, *(me->GetMap()));
+ cell.Visit(pair, visitor, *me->GetMap(), *me, minimumRange);
return player;
}
diff --git a/src/server/game/AI/ScriptedAI/ScriptedEscortAI.cpp b/src/server/game/AI/ScriptedAI/ScriptedEscortAI.cpp
index f210f077fdd..06c1570ccd9 100644
--- a/src/server/game/AI/ScriptedAI/ScriptedEscortAI.cpp
+++ b/src/server/game/AI/ScriptedAI/ScriptedEscortAI.cpp
@@ -218,7 +218,7 @@ void npc_escortAI::UpdateAI(uint32 const diff)
if (m_bCanReturnToStart)
{
float fRetX, fRetY, fRetZ;
- me->GetRespawnCoord(fRetX, fRetY, fRetZ);
+ me->GetRespawnPosition(fRetX, fRetY, fRetZ);
me->GetMotionMaster()->MovePoint(POINT_HOME, fRetX, fRetY, fRetZ);
diff --git a/src/server/game/AI/SmartScripts/SmartAI.cpp b/src/server/game/AI/SmartScripts/SmartAI.cpp
index 0b77dd03e87..afa7e9c2932 100644
--- a/src/server/game/AI/SmartScripts/SmartAI.cpp
+++ b/src/server/game/AI/SmartScripts/SmartAI.cpp
@@ -450,12 +450,14 @@ void SmartAI::EnterEvadeMode()
{
AddEscortState(SMART_ESCORT_RETURNING);
ReturnToLastOOCPos();
- } else if (mFollowGuid){
+ }
+ else if (mFollowGuid)
+ {
if (Unit* target = me->GetUnit(*me, mFollowGuid))
me->GetMotionMaster()->MoveFollow(target, mFollowDist, mFollowAngle);
- } else {
- me->GetMotionMaster()->MoveTargetedHome();
}
+ else
+ me->GetMotionMaster()->MoveTargetedHome();
Reset();
}
@@ -705,12 +707,24 @@ void SmartAI::SetRun(bool run)
me->RemoveUnitMovementFlag(MOVEMENTFLAG_WALKING);
else
me->AddUnitMovementFlag(MOVEMENTFLAG_WALKING);
+ me->SendMovementFlagUpdate();
mRun = run;
}
void SmartAI::SetFly(bool fly)
{
+ if (fly)
+ {
+ me->AddUnitMovementFlag(MOVEMENTFLAG_LEVITATING);
+ me->SetByteFlag(UNIT_FIELD_BYTES_1, 3, 0x01);
+ }
+ else
+ {
+ me->RemoveUnitMovementFlag(MOVEMENTFLAG_LEVITATING);
+ me->RemoveByteFlag(UNIT_FIELD_BYTES_1, 3, 0x01);
+ }
me->SetFlying(fly);
+ me->SendMovementFlagUpdate();
}
void SmartAI::SetSwim(bool swim)
@@ -719,6 +733,7 @@ void SmartAI::SetSwim(bool swim)
me->AddUnitMovementFlag(MOVEMENTFLAG_SWIMMING);
else
me->RemoveUnitMovementFlag(MOVEMENTFLAG_SWIMMING);
+ me->SendMovementFlagUpdate();
}
void SmartAI::sGossipHello(Player* player)
@@ -781,8 +796,8 @@ void SmartAI::SetFollow(Unit* target, float dist, float angle, uint32 credit, ui
return;
SetRun(mRun);
mFollowGuid = target->GetGUID();
- mFollowDist = dist;
- mFollowAngle = angle;
+ mFollowDist = dist ? dist : PET_FOLLOW_DIST;
+ mFollowAngle = angle ? angle : me->GetFollowAngle();
mFollowArrivedTimer = 1000;
mFollowCredit = credit;
mFollowArrivedEntry = end;
@@ -902,13 +917,13 @@ class SmartTrigger : public AreaTriggerScript
{
public:
- SmartTrigger()
- : AreaTriggerScript("SmartTrigger")
- {
- }
+ SmartTrigger() : AreaTriggerScript("SmartTrigger") {}
bool OnTrigger(Player* player, AreaTriggerEntry const* trigger)
{
+ if (!player->isAlive())
+ return false;
+
sLog->outDebug(LOG_FILTER_DATABASE_AI, "AreaTrigger %u is using SmartTrigger script", trigger->id);
SmartScript script;
script.OnInitialize(NULL, trigger);
diff --git a/src/server/game/AI/SmartScripts/SmartScript.cpp b/src/server/game/AI/SmartScripts/SmartScript.cpp
index 54c69080c41..ffe21536de4 100644
--- a/src/server/game/AI/SmartScripts/SmartScript.cpp
+++ b/src/server/game/AI/SmartScripts/SmartScript.cpp
@@ -32,6 +32,7 @@
#include "SmartAI.h"
#include "Group.h"
#include "Vehicle.h"
+#include "ScriptedGossip.h"
SmartScript::SmartScript()
{
@@ -139,6 +140,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
ObjectList* targets = GetTargets(e, unit);
Creature* talker = me;
+ Player* targetPlayer = NULL;
if (targets)
{
for (ObjectList::const_iterator itr = targets->begin(); itr != targets->end(); ++itr)
@@ -148,14 +150,26 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
talker = (*itr)->ToCreature();
break;
}
+ else if (IsPlayer((*itr)))
+ {
+ targetPlayer = (*itr)->ToPlayer();
+ break;
+ }
}
delete targets;
}
+
mTalkerEntry = talker->GetEntry();
mLastTextID = e.action.talk.textGroupID;
mTextTimer = e.action.talk.duration;
- mTextGUID = IsPlayer(GetLastInvoker()) ? GetLastInvoker()->GetGUID() : 0;//invoker, used for $vars in texts
+ if (IsPlayer(GetLastInvoker())) // used for $vars in texts and whisper target
+ mTextGUID = GetLastInvoker()->GetGUID();
+ else if (targetPlayer)
+ mTextGUID = targetPlayer->GetGUID();
+ else
+ mTextGUID = 0;
+
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",
@@ -210,7 +224,7 @@ 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 (IsUnit(*itr))
{
(*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",
@@ -1323,7 +1337,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
if (IsCreature(*itr))
(*itr)->ToCreature()->Respawn();
else if (IsGameObject(*itr))
- (*itr)->ToGameObject()->SetRespawnTime(e.action.RespawnTarget.GoRespawnTime);
+ (*itr)->ToGameObject()->SetRespawnTime(e.action.RespawnTarget.goRespawnTime);
}
delete targets;
@@ -1458,28 +1472,6 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
case SMART_ACTION_CALL_SCRIPT_RESET:
OnReset();
break;
- case SMART_ACTION_ENTER_VEHICLE:
- {
- if (!me)
- return;
-
- ObjectList* targets = GetTargets(e, unit);
- if (!targets)
- return;
-
- for (ObjectList::iterator itr = targets->begin(); itr != targets->end(); ++itr)
- {
- if (IsUnit(*itr) && (*itr)->ToUnit()->GetVehicleKit())
- {
- me->EnterVehicle((*itr)->ToUnit(), e.action.enterVehicle.seat);
- delete targets;
- return;
- }
- }
-
- delete targets;
- break;
- }
case SMART_ACTION_CALL_TIMED_ACTIONLIST:
{
if (e.GetTargetType() == SMART_TARGET_NONE)
@@ -1498,9 +1490,9 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
if (IsSmart(target))
CAST_AI(SmartAI, target->AI())->SetScript9(e, e.action.timedActionList.id, GetLastInvoker());
}
- else if (GameObject* target = (*itr)->ToGameObject())
+ else if (GameObject* goTarget = (*itr)->ToGameObject())
{
- if (IsSmartGO(target))
+ if (IsSmartGO(goTarget))
CAST_AI(SmartGameObjectAI, target->AI())->SetScript9(e, e.action.timedActionList.id, GetLastInvoker());
}
}
@@ -1615,9 +1607,9 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
if (IsSmart(target))
CAST_AI(SmartAI, target->AI())->SetScript9(e, id, GetLastInvoker());
}
- else if (GameObject* target = (*itr)->ToGameObject())
+ else if (GameObject* goTarget = (*itr)->ToGameObject())
{
- if (IsSmartGO(target))
+ if (IsSmartGO(goTarget))
CAST_AI(SmartGameObjectAI, target->AI())->SetScript9(e, id, GetLastInvoker());
}
}
@@ -1645,9 +1637,9 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
if (IsSmart(target))
CAST_AI(SmartAI, target->AI())->SetScript9(e, id, GetLastInvoker());
}
- else if (GameObject* target = (*itr)->ToGameObject())
+ else if (GameObject* goTarget = (*itr)->ToGameObject())
{
- if (IsSmartGO(target))
+ if (IsSmartGO(goTarget))
CAST_AI(SmartGameObjectAI, target->AI())->SetScript9(e, id, GetLastInvoker());
}
}
@@ -1781,7 +1773,38 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
}
case SMART_ACTION_JUMP_TO_POS:
{
+ if (!me)
+ return;
+
+ me->GetMotionMaster()->Clear();
me->GetMotionMaster()->MoveJump(e.target.x, e.target.y, e.target.z, (float)e.action.jump.speedxy, (float)e.action.jump.speedz);
+ // TODO: Resume path when reached jump location
+ break;
+ }
+ case SMART_ACTION_SEND_GOSSIP_MENU:
+ {
+ if (!GetBaseObject())
+ return;
+
+ sLog->outDebug(LOG_FILTER_DATABASE_AI, "SmartScript::ProcessAction:: SMART_ACTION_SEND_GOSSIP_MENU: gossipMenuId %d, gossip_option_id %d",
+ e.action.sendGossipMenu.gossipMenuId, e.action.sendGossipMenu.gossipOptionId);
+
+ ObjectList* targets = GetTargets(e, unit);
+ if (!targets)
+ return;
+
+ for (ObjectList::const_iterator itr = targets->begin(); itr != targets->end(); ++itr)
+ if (Player* player = (*itr)->ToPlayer())
+ {
+ if (e.action.sendGossipMenu.gossipMenuId)
+ player->PrepareGossipMenu(GetBaseObject(), e.action.sendGossipMenu.gossipMenuId, true);
+ else
+ player->PlayerTalkClass->ClearMenus();
+
+ player->SEND_GOSSIP_MENU(e.action.sendGossipMenu.gossipOptionId, GetBaseObject()->GetGUID());
+ }
+
+ delete targets;
break;
}
default:
@@ -2122,6 +2145,16 @@ ObjectList* SmartScript::GetTargets(SmartScriptHolder const& e, Unit* invoker /*
l->push_back(target);
break;
}
+ case SMART_TARGET_CLOSEST_PLAYER:
+ {
+ if (me)
+ {
+ Player* target = me->SelectNearestPlayer((float)e.target.playerDistance.dist);
+ if (target)
+ l->push_back(target);
+ }
+ break;
+ }
case SMART_TARGET_OWNER_OR_SUMMONER:
{
if (me)
@@ -2265,10 +2298,10 @@ void SmartScript::ProcessEvent(SmartScriptHolder& e, Unit* unit, uint32 var0, ui
if (!me || !me->isInCombat())
return;
- Unit* unit = DoSelectLowestHpFriendly((float)e.event.friendlyHealt.radius, e.event.friendlyHealt.hpDeficit);
- if (!unit)
+ Unit* target = DoSelectLowestHpFriendly((float)e.event.friendlyHealt.radius, e.event.friendlyHealt.hpDeficit);
+ if (!target)
return;
- ProcessAction(e, unit);
+ ProcessAction(e, target);
RecalcTimer(e, e.event.friendlyHealt.repeatMin, e.event.friendlyHealt.repeatMax);
break;
}
@@ -2608,6 +2641,19 @@ void SmartScript::UpdateTimer(SmartScriptHolder& e, uint32 const diff)
if (e.timer < diff)
{
+ // delay spell cast event if another spell is being casted
+ if (e.GetActionType() == SMART_ACTION_CAST)
+ {
+ if (!(e.action.cast.flags & SMARTCAST_INTERRUPT_PREVIOUS))
+ {
+ if (me && me->HasUnitState(UNIT_STAT_CASTING))
+ {
+ e.timer = 1;
+ return;
+ }
+ }
+ }
+
e.active = true;//activate events with cooldown
switch (e.GetEventType())//process ONLY timed events
{
@@ -2877,10 +2923,11 @@ uint32 SmartScript::DoChat(int8 id, uint64 whisperGuid)
Unit* SmartScript::DoSelectLowestHpFriendly(float range, uint32 MinHPDiff)
{
- if (!me) return NULL;
- CellPair p(Trinity::ComputeCellPair(me->GetPositionX(), me->GetPositionY()));
+ if (!me)
+ return NULL;
+
+ CellCoord p(Trinity::ComputeCellCoord(me->GetPositionX(), me->GetPositionY()));
Cell cell(p);
- cell.data.Part.reserved = ALL_DISTRICT;
cell.SetNoCreate();
Unit* unit = NULL;
@@ -2896,10 +2943,11 @@ Unit* SmartScript::DoSelectLowestHpFriendly(float range, uint32 MinHPDiff)
void SmartScript::DoFindFriendlyCC(std::list<Creature*>& _list, float range)
{
- if (!me) return;
- CellPair p(Trinity::ComputeCellPair(me->GetPositionX(), me->GetPositionY()));
+ if (!me)
+ return;
+
+ CellCoord p(Trinity::ComputeCellCoord(me->GetPositionX(), me->GetPositionY()));
Cell cell(p);
- cell.data.Part.reserved = ALL_DISTRICT;
cell.SetNoCreate();
Trinity::FriendlyCCedInRange u_check(me, range);
@@ -2907,15 +2955,16 @@ void SmartScript::DoFindFriendlyCC(std::list<Creature*>& _list, float range)
TypeContainerVisitor<Trinity::CreatureListSearcher<Trinity::FriendlyCCedInRange>, GridTypeMapContainer > grid_creature_searcher(searcher);
- cell.Visit(p, grid_creature_searcher, *me->GetMap());
+ cell.Visit(p, grid_creature_searcher, *me->GetMap(), *me, range);
}
void SmartScript::DoFindFriendlyMissingBuff(std::list<Creature*>& list, float range, uint32 spellid)
{
- if (!me) return;
- CellPair p(Trinity::ComputeCellPair(me->GetPositionX(), me->GetPositionY()));
+ if (!me)
+ return;
+
+ CellCoord p(Trinity::ComputeCellCoord(me->GetPositionX(), me->GetPositionY()));
Cell cell(p);
- cell.data.Part.reserved = ALL_DISTRICT;
cell.SetNoCreate();
Trinity::FriendlyMissingBuffInRange u_check(me, range, spellid);
@@ -2923,7 +2972,7 @@ void SmartScript::DoFindFriendlyMissingBuff(std::list<Creature*>& list, float ra
TypeContainerVisitor<Trinity::CreatureListSearcher<Trinity::FriendlyMissingBuffInRange>, GridTypeMapContainer > grid_creature_searcher(searcher);
- cell.Visit(p, grid_creature_searcher, *me->GetMap());
+ cell.Visit(p, grid_creature_searcher, *me->GetMap(), *me, range);
}
void SmartScript::SetScript9(SmartScriptHolder& e, uint32 entry)
diff --git a/src/server/game/AI/SmartScripts/SmartScript.h b/src/server/game/AI/SmartScripts/SmartScript.h
index aa4eeb602c0..7ebe8ca500f 100644
--- a/src/server/game/AI/SmartScripts/SmartScript.h
+++ b/src/server/game/AI/SmartScripts/SmartScript.h
@@ -155,33 +155,31 @@ class SmartScript
{
GameObject* gameObject = NULL;
- CellPair p(Trinity::ComputeCellPair(searchObject->GetPositionX(), searchObject->GetPositionY()));
+ CellCoord p(Trinity::ComputeCellCoord(searchObject->GetPositionX(), searchObject->GetPositionY()));
Cell cell(p);
- cell.data.Part.reserved = ALL_DISTRICT;
Trinity::GameObjectWithDbGUIDCheck goCheck(*searchObject, guid);
Trinity::GameObjectSearcher<Trinity::GameObjectWithDbGUIDCheck> checker(searchObject, gameObject, goCheck);
TypeContainerVisitor<Trinity::GameObjectSearcher<Trinity::GameObjectWithDbGUIDCheck>, GridTypeMapContainer > objectChecker(checker);
- cell.Visit(p, objectChecker, *searchObject->GetMap());
+ cell.Visit(p, objectChecker, *searchObject->GetMap(), *searchObject, searchObject->GetGridActivationRange());
return gameObject;
}
Creature* FindCreatureNear(WorldObject* searchObject, uint32 guid) const
{
- Creature* crea = NULL;
- CellPair p(Trinity::ComputeCellPair(searchObject->GetPositionX(), searchObject->GetPositionY()));
+ Creature* creature = NULL;
+ CellCoord p(Trinity::ComputeCellCoord(searchObject->GetPositionX(), searchObject->GetPositionY()));
Cell cell(p);
- cell.data.Part.reserved = ALL_DISTRICT;
Trinity::CreatureWithDbGUIDCheck target_check(searchObject, guid);
- Trinity::CreatureSearcher<Trinity::CreatureWithDbGUIDCheck> checker(searchObject, crea, target_check);
+ Trinity::CreatureSearcher<Trinity::CreatureWithDbGUIDCheck> checker(searchObject, creature, target_check);
TypeContainerVisitor<Trinity::CreatureSearcher <Trinity::CreatureWithDbGUIDCheck>, GridTypeMapContainer > unit_checker(checker);
- cell.Visit(p, unit_checker, *searchObject->GetMap());
+ cell.Visit(p, unit_checker, *searchObject->GetMap(), *searchObject, searchObject->GetGridActivationRange());
- return crea;
+ return creature;
}
ObjectListMap* mTargetStorage;
@@ -224,7 +222,7 @@ class SmartScript
}
void DecPhase(int32 p = 1) { mEventPhase -= (mEventPhase < (uint32)p ? (uint32)p - mEventPhase : (uint32)p); }
- bool IsInPhase(uint32 p) const { return mEventPhase & p; }
+ bool IsInPhase(uint32 p) const { return (1 << (mEventPhase - 1)) & p; }
void SetPhase(uint32 p = 0) { mEventPhase = p; }
SmartAIEventList mEvents;
diff --git a/src/server/game/AI/SmartScripts/SmartScriptMgr.cpp b/src/server/game/AI/SmartScripts/SmartScriptMgr.cpp
index fab2a6b7722..011ed75205d 100644
--- a/src/server/game/AI/SmartScripts/SmartScriptMgr.cpp
+++ b/src/server/game/AI/SmartScripts/SmartScriptMgr.cpp
@@ -68,10 +68,12 @@ void SmartWaypointMgr::LoadFromDB()
path = new WPPath;
last_id = 1;
}
+
if (last_id != id)
{
sLog->outErrorDb("SmartWaypointMgr::LoadFromDB: Path entry %u, unexpected point id %u, expected %u.", entry, id, last_id);
}
+
last_id++;
(*path)[id] = wp;
@@ -158,7 +160,8 @@ void SmartAIMgr::LoadSmartAIFromDB()
sLog->outErrorDb("SmartAIMgr::LoadSmartAIFromDB: not yet implemented source_type %u", (uint32)source_type);
continue;
}
- }else
+ }
+ else
{
if (!sObjectMgr->GetCreatureData(uint32(abs(temp.entryOrGuid))))
{
@@ -166,6 +169,7 @@ void SmartAIMgr::LoadSmartAIFromDB()
continue;
}
}
+
temp.source_type = source_type;
temp.event_id = fields[2].GetUInt16();
temp.link = fields[3].GetUInt16();
@@ -224,41 +228,50 @@ void SmartAIMgr::LoadSmartAIFromDB()
bool SmartAIMgr::IsTargetValid(SmartScriptHolder const& e)
{
if (e.GetActionType() == SMART_ACTION_INSTALL_AI_TEMPLATE)
- return true; //AI template has special handling
+ return true; // AI template has special handling
switch (e.GetTargetType())
{
case SMART_TARGET_CREATURE_DISTANCE:
case SMART_TARGET_CREATURE_RANGE:
+ {
+ if (e.target.unitDistance.creature && !sObjectMgr->GetCreatureTemplate(e.target.unitDistance.creature))
{
- if (e.target.unitDistance.creature && !sObjectMgr->GetCreatureTemplate(e.target.unitDistance.creature))
- {
- sLog->outErrorDb("SmartAIMgr: Entry %d SourceType %u Event %u Action %u uses non-existent Creature entry %u as target_param1, skipped.", e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType(), e.target.unitDistance.creature);
- return false;
- }
- break;
+ sLog->outErrorDb("SmartAIMgr: Entry %d SourceType %u Event %u Action %u uses non-existent Creature entry %u as target_param1, skipped.", e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType(), e.target.unitDistance.creature);
+ return false;
}
+ break;
+ }
case SMART_TARGET_GAMEOBJECT_DISTANCE:
case SMART_TARGET_GAMEOBJECT_RANGE:
+ {
+ if (e.target.goDistance.entry && !sObjectMgr->GetGameObjectTemplate(e.target.goDistance.entry))
{
- if (e.target.goDistance.entry && !sObjectMgr->GetGameObjectTemplate(e.target.goDistance.entry))
- {
- sLog->outErrorDb("SmartAIMgr: Entry %d SourceType %u Event %u Action %u uses non-existent GameObject entry %u as target_param1, skipped.", e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType(), e.target.goDistance.entry);
- return false;
- }
- break;
+ sLog->outErrorDb("SmartAIMgr: Entry %d SourceType %u Event %u Action %u uses non-existent GameObject entry %u as target_param1, skipped.", e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType(), e.target.goDistance.entry);
+ return false;
}
+ break;
+ }
case SMART_TARGET_CREATURE_GUID:
- {
- if (e.target.unitGUID.entry && !IsCreatureValid(e, e.target.unitGUID.entry)) return false;
- break;
- }
+ {
+ if (e.target.unitGUID.entry && !IsCreatureValid(e, e.target.unitGUID.entry)) return false;
+ break;
+ }
case SMART_TARGET_GAMEOBJECT_GUID:
+ {
+ if (e.target.goGUID.entry && !IsGameObjectValid(e, e.target.goGUID.entry)) return false;
+ break;
+ }
+ case SMART_TARGET_PLAYER_DISTANCE:
+ case SMART_TARGET_CLOSEST_PLAYER:
+ {
+ if (e.target.playerDistance.dist == 0)
{
- if (e.target.goGUID.entry && !IsGameObjectValid(e, e.target.goGUID.entry)) return false;
- break;
+ sLog->outErrorDb("SmartAIMgr: Entry %d SourceType %u Event %u Action %u has maxDist 0 as target_param1, skipped.", e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType());
+ return false;
}
+ break;
+ }
case SMART_TARGET_PLAYER_RANGE:
- case SMART_TARGET_PLAYER_DISTANCE:
case SMART_TARGET_SELF:
case SMART_TARGET_VICTIM:
case SMART_TARGET_HOSTILE_SECOND_AGGRO:
@@ -268,12 +281,11 @@ bool SmartAIMgr::IsTargetValid(SmartScriptHolder const& e)
case SMART_TARGET_ACTION_INVOKER:
case SMART_TARGET_POSITION:
case SMART_TARGET_NONE:
- case SMART_TARGET_CLOSEST_CREATURE:
- case SMART_TARGET_CLOSEST_GAMEOBJECT:
- case SMART_TARGET_CLOSEST_PLAYER:
case SMART_TARGET_ACTION_INVOKER_VEHICLE:
case SMART_TARGET_OWNER_OR_SUMMONER:
case SMART_TARGET_THREAT_LIST:
+ case SMART_TARGET_CLOSEST_GAMEOBJECT:
+ case SMART_TARGET_CLOSEST_CREATURE:
break;
default:
sLog->outErrorDb("SmartAIMgr: Not handled target_type(%u), Entry %d SourceType %u Event %u Action %u, skipped.", e.GetTargetType(), e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType());
@@ -394,7 +406,8 @@ bool SmartAIMgr::IsEventValid(SmartScriptHolder& e)
break;
case SMART_EVENT_ACCEPTED_QUEST:
case SMART_EVENT_REWARD_QUEST:
- if (!IsQuestValid(e, e.event.quest.quest)) return false;
+ if (e.event.quest.quest && !IsQuestValid(e, e.event.quest.quest))
+ return false;
break;
case SMART_EVENT_RECEIVE_EMOTE:
{
@@ -526,7 +539,8 @@ bool SmartAIMgr::IsEventValid(SmartScriptHolder& e)
}
break;
case SMART_ACTION_SOUND:
- if (!IsSoundValid(e, e.action.sound.sound)) return false;
+ if (!IsSoundValid(e, e.action.sound.sound))
+ return false;
if (e.action.sound.range > TEXT_RANGE_WORLD)
{
sLog->outErrorDb("SmartAIMgr: Entry %d SourceType %u Event %u Action %u uses invalid Text Range %u, skipped.", e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType(), e.action.sound.range);
@@ -539,7 +553,7 @@ bool SmartAIMgr::IsEventValid(SmartScriptHolder& e)
break;
case SMART_ACTION_FAIL_QUEST:
case SMART_ACTION_ADD_QUEST:
- if (e.action.quest.quest && !IsQuestValid(e, e.action.quest.quest)) return false;
+ if (!e.action.quest.quest || !IsQuestValid(e, e.action.quest.quest)) return false;
break;
case SMART_ACTION_ACTIVATE_TAXI:
{
@@ -755,7 +769,6 @@ bool SmartAIMgr::IsEventValid(SmartScriptHolder& e)
case SMART_ACTION_RESET_SCRIPT_BASE_OBJECT:
case SMART_ACTION_ACTIVATE_GOBJECT:
case SMART_ACTION_CALL_SCRIPT_RESET:
- case SMART_ACTION_ENTER_VEHICLE:
case SMART_ACTION_NONE:
case SMART_ACTION_CALL_TIMED_ACTIONLIST:
case SMART_ACTION_SET_NPC_FLAG:
@@ -775,6 +788,7 @@ bool SmartAIMgr::IsEventValid(SmartScriptHolder& e)
case SMART_ACTION_ADD_DYNAMIC_FLAG:
case SMART_ACTION_REMOVE_DYNAMIC_FLAG:
case SMART_ACTION_JUMP_TO_POS:
+ case SMART_ACTION_SEND_GOSSIP_MENU:
break;
default:
sLog->outErrorDb("SmartAIMgr: Not handled action_type(%u), event_type(%u), Entry %d SourceType %u Event %u, skipped.", e.GetActionType(), e.GetEventType(), e.entryOrGuid, e.GetScriptType(), e.event_id);
diff --git a/src/server/game/AI/SmartScripts/SmartScriptMgr.h b/src/server/game/AI/SmartScripts/SmartScriptMgr.h
index 327d03d31ff..ba986ae310d 100644
--- a/src/server/game/AI/SmartScripts/SmartScriptMgr.h
+++ b/src/server/game/AI/SmartScripts/SmartScriptMgr.h
@@ -387,7 +387,7 @@ enum SMART_ACTION
SMART_ACTION_CALL_GROUPEVENTHAPPENS = 26, // QuestID
SMART_ACTION_CALL_CASTEDCREATUREORGO = 27, // CreatureId, SpellId
SMART_ACTION_REMOVEAURASFROMSPELL = 28, // Spellid
- SMART_ACTION_FOLLOW = 29, // Distance, Angle, EndCreatureEntry, credit, creditType (0monsterkill, 1event)
+ SMART_ACTION_FOLLOW = 29, // Distance (0 = default), Angle (0 = default), EndCreatureEntry, credit, creditType (0monsterkill, 1event)
SMART_ACTION_RANDOM_PHASE = 30, // PhaseId1, PhaseId2, PhaseId3...
SMART_ACTION_RANDOM_PHASE_RANGE = 31, // PhaseMin, PhaseMax
SMART_ACTION_RESET_GOBJECT = 32, //
@@ -439,7 +439,7 @@ enum SMART_ACTION
SMART_ACTION_OVERRIDE_SCRIPT_BASE_OBJECT = 76, // WARNING: CAN CRASH CORE, do not use if you dont know what you are doing
SMART_ACTION_RESET_SCRIPT_BASE_OBJECT = 77, // none
SMART_ACTION_CALL_SCRIPT_RESET = 78, // none
- SMART_ACTION_ENTER_VEHICLE = 79, // seatID
+ // Unused = 79,
SMART_ACTION_CALL_TIMED_ACTIONLIST = 80, // ID (overwrites already running actionlist), stop after combat?(0/1), timer update type(0-OOC, 1-IC, 2-ALWAYS)
SMART_ACTION_SET_NPC_FLAG = 81, // Flags
SMART_ACTION_ADD_NPC_FLAG = 82, // Flags
@@ -450,20 +450,17 @@ enum SMART_ACTION
SMART_ACTION_CALL_RANDOM_TIMED_ACTIONLIST = 87, // script9 ids 1-9
SMART_ACTION_CALL_RANDOM_RANGE_TIMED_ACTIONLIST = 88, // script9 id min, max
SMART_ACTION_RANDOM_MOVE = 89, // maxDist
-
SMART_ACTION_SET_UNIT_FIELD_BYTES_1 = 90, // bytes, target
SMART_ACTION_REMOVE_UNIT_FIELD_BYTES_1 = 91, // bytes, target
-
SMART_ACTION_INTERRUPT_SPELL = 92,
-
SMART_ACTION_SEND_GO_CUSTOM_ANIM = 93, // anim id
-
SMART_ACTION_SET_DYNAMIC_FLAG = 94, // Flags
SMART_ACTION_ADD_DYNAMIC_FLAG = 95, // Flags
SMART_ACTION_REMOVE_DYNAMIC_FLAG = 96, // Flags
SMART_ACTION_JUMP_TO_POS = 97, // speedXY, speedZ, targetX, targetY, targetZ
+ SMART_ACTION_SEND_GOSSIP_MENU = 98, // menuId, optionId
- SMART_ACTION_END = 98,
+ SMART_ACTION_END = 99,
};
struct SmartAction
@@ -859,8 +856,14 @@ struct SmartAction
struct
{
- uint32 GoRespawnTime;
+ uint32 goRespawnTime;
} RespawnTarget;
+
+ struct
+ {
+ uint32 gossipMenuId;
+ uint32 gossipOptionId;
+ } sendGossipMenu;
struct
{
@@ -906,9 +909,9 @@ enum SMARTAI_TARGETS
SMART_TARGET_INVOKER_PARTY = 16, // invoker's party members
SMART_TARGET_PLAYER_RANGE = 17, // min, max
SMART_TARGET_PLAYER_DISTANCE = 18, // maxDist
- SMART_TARGET_CLOSEST_CREATURE = 19, // CreatureEntry(0any)
- SMART_TARGET_CLOSEST_GAMEOBJECT = 20, // entry(0any)
- SMART_TARGET_CLOSEST_PLAYER = 21, // none
+ SMART_TARGET_CLOSEST_CREATURE = 19, // CreatureEntry(0any), maxDist, dead?
+ SMART_TARGET_CLOSEST_GAMEOBJECT = 20, // entry(0any), maxDist
+ SMART_TARGET_CLOSEST_PLAYER = 21, // maxDist
SMART_TARGET_ACTION_INVOKER_VEHICLE = 22, // Unit's vehicle who caused this Event to occur
SMART_TARGET_OWNER_OR_SUMMONER = 23, // Unit's owner or summoner
SMART_TARGET_THREAT_LIST = 24, // All units on creature's threat list
@@ -1124,7 +1127,7 @@ const uint32 SmartAIEventMask[SMART_EVENT_END][2] =
{SMART_EVENT_JUST_CREATED, SMART_SCRIPT_TYPE_MASK_CREATURE + SMART_SCRIPT_TYPE_MASK_GAMEOBJECT },
{SMART_EVENT_GOSSIP_HELLO, SMART_SCRIPT_TYPE_MASK_CREATURE + SMART_SCRIPT_TYPE_MASK_GAMEOBJECT },
{SMART_EVENT_FOLLOW_COMPLETED, SMART_SCRIPT_TYPE_MASK_CREATURE },
- {SMART_EVENT_DUMMY_EFFECT, SMART_SCRIPT_TYPE_MASK_CREATURE },
+ {SMART_EVENT_DUMMY_EFFECT, SMART_SCRIPT_TYPE_MASK_SPELL },
{SMART_EVENT_IS_BEHIND_TARGET, SMART_SCRIPT_TYPE_MASK_CREATURE }
};
diff --git a/src/server/game/Achievements/AchievementMgr.cpp b/src/server/game/Achievements/AchievementMgr.cpp
index fca4df12587..8967446f199 100755
--- a/src/server/game/Achievements/AchievementMgr.cpp
+++ b/src/server/game/Achievements/AchievementMgr.cpp
@@ -46,8 +46,8 @@ namespace Trinity
class AchievementChatBuilder
{
public:
- AchievementChatBuilder(Player const& pl, ChatMsg msgtype, int32 textId, uint32 ach_id)
- : i_player(pl), i_msgtype(msgtype), i_textId(textId), i_achievementId(ach_id) {}
+ AchievementChatBuilder(Player const& player, ChatMsg msgtype, int32 textId, uint32 ach_id)
+ : i_player(player), i_msgtype(msgtype), i_textId(textId), i_achievementId(ach_id) {}
void operator()(WorldPacket& data, LocaleConstant loc_idx)
{
char const* text = sObjectMgr->GetTrinityString(i_textId, loc_idx);
@@ -666,10 +666,9 @@ void AchievementMgr::SendAchievementEarned(AchievementEntry const* achievement)
// if player is in world he can tell his friends about new achievement
else if (GetPlayer()->IsInWorld())
{
- CellPair p = Trinity::ComputeCellPair(GetPlayer()->GetPositionX(), GetPlayer()->GetPositionY());
+ CellCoord p = Trinity::ComputeCellCoord(GetPlayer()->GetPositionX(), GetPlayer()->GetPositionY());
Cell cell(p);
- cell.data.Part.reserved = ALL_DISTRICT;
cell.SetNoCreate();
Trinity::AchievementChatBuilder say_builder(*GetPlayer(), CHAT_MSG_ACHIEVEMENT, LANG_ACHIEVEMENT_EARNED, achievement->ID);
diff --git a/src/server/game/Achievements/AchievementMgr.h b/src/server/game/Achievements/AchievementMgr.h
index df5631c5bc6..7f66565622f 100755
--- a/src/server/game/Achievements/AchievementMgr.h
+++ b/src/server/game/Achievements/AchievementMgr.h
@@ -244,7 +244,7 @@ class WorldPacket;
class AchievementMgr
{
public:
- AchievementMgr(Player* pl);
+ AchievementMgr(Player* player);
~AchievementMgr();
void Reset();
diff --git a/src/server/game/Battlegrounds/ArenaTeam.cpp b/src/server/game/Battlegrounds/ArenaTeam.cpp
index 45f41eebd26..b9fb5a13980 100755
--- a/src/server/game/Battlegrounds/ArenaTeam.cpp
+++ b/src/server/game/Battlegrounds/ArenaTeam.cpp
@@ -391,8 +391,8 @@ void ArenaTeam::Roster(WorldSession* session)
data << uint32(itr->PersonalRating); // personal rating
if (unk308)
{
- data << float(0.0); // 308 unk
- data << float(0.0); // 308 unk
+ data << float(0.0f); // 308 unk
+ data << float(0.0f); // 308 unk
}
}
@@ -433,8 +433,8 @@ void ArenaTeam::NotifyStatsChanged()
// This is called after a rated match ended
// Updates arena team stats for every member of the team (not only the ones who participated!)
for (MemberList::const_iterator itr = Members.begin(); itr != Members.end(); ++itr)
- if (Player* plr = ObjectAccessor::FindPlayer(itr->Guid))
- SendStats(plr->GetSession());
+ if (Player* player = ObjectAccessor::FindPlayer(itr->Guid))
+ SendStats(player->GetSession());
}
void ArenaTeam::Inspect(WorldSession* session, uint64 guid)
@@ -455,17 +455,17 @@ void ArenaTeam::Inspect(WorldSession* session, uint64 guid)
session->SendPacket(&data);
}
-void ArenaTeamMember::ModifyPersonalRating(Player* plr, int32 mod, uint32 slot)
+void ArenaTeamMember::ModifyPersonalRating(Player* player, int32 mod, uint32 slot)
{
if (int32(PersonalRating) + mod < 0)
PersonalRating = 0;
else
PersonalRating += mod;
- if (plr)
+ if (player)
{
- plr->SetArenaTeamInfoField(slot, ARENA_TEAM_PERSONAL_RATING, PersonalRating);
- plr->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_PERSONAL_RATING, PersonalRating, slot);
+ player->SetArenaTeamInfoField(slot, ARENA_TEAM_PERSONAL_RATING, PersonalRating);
+ player->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_PERSONAL_RATING, PersonalRating, slot);
}
}
@@ -716,16 +716,16 @@ int32 ArenaTeam::LostAgainst(uint32 Own_MMRating, uint32 Opponent_MMRating, int3
return mod;
}
-void ArenaTeam::MemberLost(Player* plr, uint32 againstMatchmakerRating, int32 MatchmakerRatingChange)
+void ArenaTeam::MemberLost(Player* player, uint32 againstMatchmakerRating, int32 MatchmakerRatingChange)
{
// Called for each participant of a match after losing
for (MemberList::iterator itr = Members.begin(); itr != Members.end(); ++itr)
{
- if (itr->Guid == plr->GetGUID())
+ if (itr->Guid == player->GetGUID())
{
// Update personal rating
int32 mod = GetRatingMod(itr->PersonalRating, againstMatchmakerRating, false);
- itr->ModifyPersonalRating(plr, mod, GetSlot());
+ itr->ModifyPersonalRating(player, mod, GetSlot());
// Update matchmaker rating
itr->ModifyMatchmakerRating(MatchmakerRatingChange, GetSlot());
@@ -735,8 +735,8 @@ void ArenaTeam::MemberLost(Player* plr, uint32 againstMatchmakerRating, int32 Ma
itr->SeasonGames +=1;
// update the unit fields
- plr->SetArenaTeamInfoField(GetSlot(), ARENA_TEAM_GAMES_WEEK, itr->WeekGames);
- plr->SetArenaTeamInfoField(GetSlot(), ARENA_TEAM_GAMES_SEASON, itr->SeasonGames);
+ player->SetArenaTeamInfoField(GetSlot(), ARENA_TEAM_GAMES_WEEK, itr->WeekGames);
+ player->SetArenaTeamInfoField(GetSlot(), ARENA_TEAM_GAMES_SEASON, itr->SeasonGames);
return;
}
}
@@ -764,16 +764,16 @@ void ArenaTeam::OfflineMemberLost(uint64 guid, uint32 againstMatchmakerRating, i
}
}
-void ArenaTeam::MemberWon(Player* plr, uint32 againstMatchmakerRating, int32 MatchmakerRatingChange)
+void ArenaTeam::MemberWon(Player* player, uint32 againstMatchmakerRating, int32 MatchmakerRatingChange)
{
// called for each participant after winning a match
for (MemberList::iterator itr = Members.begin(); itr != Members.end(); ++itr)
{
- if (itr->Guid == plr->GetGUID())
+ if (itr->Guid == player->GetGUID())
{
// update personal rating
int32 mod = GetRatingMod(itr->PersonalRating, againstMatchmakerRating, true);
- itr->ModifyPersonalRating(plr, mod, GetSlot());
+ itr->ModifyPersonalRating(player, mod, GetSlot());
// update matchmaker rating
itr->ModifyMatchmakerRating(MatchmakerRatingChange, GetSlot());
@@ -784,8 +784,8 @@ void ArenaTeam::MemberWon(Player* plr, uint32 againstMatchmakerRating, int32 Mat
itr->SeasonWins += 1;
itr->WeekWins += 1;
// update unit fields
- plr->SetArenaTeamInfoField(GetSlot(), ARENA_TEAM_GAMES_WEEK, itr->WeekGames);
- plr->SetArenaTeamInfoField(GetSlot(), ARENA_TEAM_GAMES_SEASON, itr->SeasonGames);
+ player->SetArenaTeamInfoField(GetSlot(), ARENA_TEAM_GAMES_WEEK, itr->WeekGames);
+ player->SetArenaTeamInfoField(GetSlot(), ARENA_TEAM_GAMES_SEASON, itr->SeasonGames);
return;
}
}
@@ -800,7 +800,7 @@ void ArenaTeam::UpdateArenaPointsHelper(std::map<uint32, uint32>& playerPoints)
return;
// To get points, a player has to participate in at least 30% of the matches
- uint32 requiredGames = (uint32) ceil(Stats.WeekGames * 0.3);
+ uint32 requiredGames = (uint32)ceil(Stats.WeekGames * 0.3f);
for (MemberList::const_iterator itr = Members.begin(); itr != Members.end(); ++itr)
{
diff --git a/src/server/game/Battlegrounds/ArenaTeam.h b/src/server/game/Battlegrounds/ArenaTeam.h
index 4f013f72e5c..dce8c5776b7 100755
--- a/src/server/game/Battlegrounds/ArenaTeam.h
+++ b/src/server/game/Battlegrounds/ArenaTeam.h
@@ -97,7 +97,7 @@ struct ArenaTeamMember
uint16 PersonalRating;
uint16 MatchMakerRating;
- void ModifyPersonalRating(Player* plr, int32 mod, uint32 slot);
+ void ModifyPersonalRating(Player* player, int32 mod, uint32 slot);
void ModifyMatchmakerRating(int32 mod, uint32 slot);
};
@@ -172,9 +172,9 @@ class ArenaTeam
int32 GetRatingMod(uint32 ownRating, uint32 opponentRating, bool won);
float GetChanceAgainst(uint32 ownRating, uint32 opponentRating);
int32 WonAgainst(uint32 Own_MMRating, uint32 Opponent_MMRating, int32& rating_change);
- void MemberWon(Player* plr, uint32 againstMatchmakerRating, int32 MatchmakerRatingChange);
+ void MemberWon(Player* player, uint32 againstMatchmakerRating, int32 MatchmakerRatingChange);
int32 LostAgainst(uint32 Own_MMRating, uint32 Opponent_MMRating, int32& rating_change);
- void MemberLost(Player* plr, uint32 againstMatchmakerRating, int32 MatchmakerRatingChange = -12);
+ void MemberLost(Player* player, uint32 againstMatchmakerRating, int32 MatchmakerRatingChange = -12);
void OfflineMemberLost(uint64 guid, uint32 againstMatchmakerRating, int32 MatchmakerRatingChange = -12);
void UpdateArenaPointsHelper(std::map<uint32, uint32> & PlayerPoints);
diff --git a/src/server/game/Battlegrounds/Battleground.cpp b/src/server/game/Battlegrounds/Battleground.cpp
index 339f2ebba3b..af350ac39d6 100755
--- a/src/server/game/Battlegrounds/Battleground.cpp
+++ b/src/server/game/Battlegrounds/Battleground.cpp
@@ -75,7 +75,7 @@ namespace Trinity
data << uint64(target_guid);
data << uint32(strlen(text) + 1);
data << text;
- data << uint8 (_source ? _source->chatTag() : uint8(0));
+ data << uint8 (_source ? _source->GetChatTag() : 0);
}
ChatMsg _msgtype;
@@ -108,7 +108,7 @@ namespace Trinity
data << uint64(target_guid);
data << uint32(strlen(str) + 1);
data << str;
- data << uint8 (_source ? _source->chatTag() : uint8(0));
+ data << uint8 (_source ? _source->GetChatTag() : uint8(0));
}
private:
@@ -124,8 +124,8 @@ template<class Do>
void Battleground::BroadcastWorker(Do& _do)
{
for (BattlegroundPlayerMap::const_iterator itr = m_Players.begin(); itr != m_Players.end(); ++itr)
- if (Player* plr = ObjectAccessor::FindPlayer(MAKE_NEW_GUID(itr->first, 0, HIGHGUID_PLAYER)))
- _do(plr);
+ if (Player* player = ObjectAccessor::FindPlayer(MAKE_NEW_GUID(itr->first, 0, HIGHGUID_PLAYER)))
+ _do(player);
}
Battleground::Battleground()
@@ -333,13 +333,13 @@ inline void Battleground::_ProcessRessurect(uint32 diff)
Creature* sh = NULL;
for (std::vector<uint64>::const_iterator itr2 = (itr->second).begin(); itr2 != (itr->second).end(); ++itr2)
{
- Player* plr = ObjectAccessor::FindPlayer(*itr2);
- if (!plr)
+ Player* player = ObjectAccessor::FindPlayer(*itr2);
+ if (!player)
continue;
- if (!sh && plr->IsInWorld())
+ if (!sh && player->IsInWorld())
{
- sh = plr->GetMap()->GetCreature(itr->first);
+ sh = player->GetMap()->GetCreature(itr->first);
// only for visual effect
if (sh)
// Spirit Heal, effect 117
@@ -347,7 +347,7 @@ inline void Battleground::_ProcessRessurect(uint32 diff)
}
// Resurrection visual
- plr->CastSpell(plr, SPELL_RESURRECTION_VISUAL, true);
+ player->CastSpell(player, SPELL_RESURRECTION_VISUAL, true);
m_ResurrectQueue.push_back(*itr2);
}
(itr->second).clear();
@@ -364,12 +364,12 @@ inline void Battleground::_ProcessRessurect(uint32 diff)
{
for (std::vector<uint64>::const_iterator itr = m_ResurrectQueue.begin(); itr != m_ResurrectQueue.end(); ++itr)
{
- Player* plr = ObjectAccessor::FindPlayer(*itr);
- if (!plr)
+ Player* player = ObjectAccessor::FindPlayer(*itr);
+ if (!player)
continue;
- plr->ResurrectPlayer(1.0f);
- plr->CastSpell(plr, 6962, true);
- plr->CastSpell(plr, SPELL_SPIRIT_HEAL_MANA, true);
+ player->ResurrectPlayer(1.0f);
+ player->CastSpell(player, 6962, true);
+ player->CastSpell(player, SPELL_SPIRIT_HEAL_MANA, true);
sObjectAccessor->ConvertCorpseForPlayer(*itr);
}
m_ResurrectQueue.clear();
@@ -429,15 +429,15 @@ inline void Battleground::_ProcessJoin(uint32 diff)
{
m_ResetStatTimer = 0;
for (BattlegroundPlayerMap::const_iterator itr = GetPlayers().begin(); itr != GetPlayers().end(); ++itr)
- if (Player* plr = ObjectAccessor::FindPlayer(itr->first))
- plr->ResetAllPowers();
+ if (Player* player = ObjectAccessor::FindPlayer(itr->first))
+ player->ResetAllPowers();
}
if (!(m_Events & BG_STARTING_EVENT_1))
{
m_Events |= BG_STARTING_EVENT_1;
- if(!FindBgMap())
+ if (!FindBgMap())
{
sLog->outError("Battleground::_ProcessJoin: map (map id: %u, instance id: %u) is not created!", m_MapId, m_InstanceID);
EndNow();
@@ -484,19 +484,19 @@ inline void Battleground::_ProcessJoin(uint32 diff)
{
// TODO : add arena sound PlaySoundToAll(SOUND_ARENA_START);
for (BattlegroundPlayerMap::const_iterator itr = GetPlayers().begin(); itr != GetPlayers().end(); ++itr)
- if (Player* plr = ObjectAccessor::FindPlayer(itr->first))
+ if (Player* player = ObjectAccessor::FindPlayer(itr->first))
{
// BG Status packet
WorldPacket status;
BattlegroundQueueTypeId bgQueueTypeId = sBattlegroundMgr->BGQueueTypeId(m_TypeID, GetArenaType());
- uint32 queueSlot = plr->GetBattlegroundQueueIndex(bgQueueTypeId);
+ uint32 queueSlot = player->GetBattlegroundQueueIndex(bgQueueTypeId);
sBattlegroundMgr->BuildBattlegroundStatusPacket(&status, this, queueSlot, STATUS_IN_PROGRESS, 0, GetStartTime(), GetArenaType());
- plr->GetSession()->SendPacket(&status);
+ player->GetSession()->SendPacket(&status);
- plr->RemoveAurasDueToSpell(SPELL_ARENA_PREPARATION);
- plr->ResetAllPowers();
+ player->RemoveAurasDueToSpell(SPELL_ARENA_PREPARATION);
+ player->ResetAllPowers();
// remove auras with duration lower than 30s
- Unit::AuraApplicationMap & auraMap = plr->GetAppliedAuras();
+ Unit::AuraApplicationMap & auraMap = player->GetAppliedAuras();
for (Unit::AuraApplicationMap::iterator iter = auraMap.begin(); iter != auraMap.end();)
{
AuraApplication * aurApp = iter->second;
@@ -506,7 +506,7 @@ inline void Battleground::_ProcessJoin(uint32 diff)
&& aurApp->IsPositive()
&& (!(aura->GetSpellInfo()->Attributes & SPELL_ATTR0_UNAFFECTED_BY_INVULNERABILITY))
&& (!aura->HasEffectType(SPELL_AURA_MOD_INVISIBILITY)))
- plr->RemoveAura(iter);
+ player->RemoveAura(iter);
else
++iter;
}
@@ -519,10 +519,10 @@ inline void Battleground::_ProcessJoin(uint32 diff)
PlaySoundToAll(SOUND_BG_START);
for (BattlegroundPlayerMap::const_iterator itr = GetPlayers().begin(); itr != GetPlayers().end(); ++itr)
- if (Player* plr = ObjectAccessor::FindPlayer(itr->first))
+ if (Player* player = ObjectAccessor::FindPlayer(itr->first))
{
- plr->RemoveAurasDueToSpell(SPELL_PREPARATION);
- plr->ResetAllPowers();
+ player->RemoveAurasDueToSpell(SPELL_PREPARATION);
+ player->ResetAllPowers();
}
// Announce BG starting
if (sWorld->getBoolConfig(CONFIG_BATTLEGROUND_QUEUE_ANNOUNCER_ENABLE))
@@ -788,28 +788,28 @@ void Battleground::EndBattleground(uint32 winner)
continue;
}
- Player* plr = _GetPlayer(itr, "EndBattleground");
- if (!plr)
+ Player* player = _GetPlayer(itr, "EndBattleground");
+ if (!player)
continue;
// should remove spirit of redemption
- if (plr->HasAuraType(SPELL_AURA_SPIRIT_OF_REDEMPTION))
- plr->RemoveAurasByType(SPELL_AURA_MOD_SHAPESHIFT);
+ if (player->HasAuraType(SPELL_AURA_SPIRIT_OF_REDEMPTION))
+ player->RemoveAurasByType(SPELL_AURA_MOD_SHAPESHIFT);
- if (!plr->isAlive())
+ if (!player->isAlive())
{
- plr->ResurrectPlayer(1.0f);
- plr->SpawnCorpseBones();
+ player->ResurrectPlayer(1.0f);
+ player->SpawnCorpseBones();
}
else
{
//needed cause else in av some creatures will kill the players at the end
- plr->CombatStop();
- plr->getHostileRefManager().deleteReferences();
+ player->CombatStop();
+ player->getHostileRefManager().deleteReferences();
}
//this line is obsolete - team is set ALWAYS
- //if (!team) team = plr->GetTeam();
+ //if (!team) team = player->GetTeam();
// per player calculation
if (isArena() && isRated() && winner_arena_team && loser_arena_team && winner_arena_team != loser_arena_team)
@@ -817,57 +817,57 @@ void Battleground::EndBattleground(uint32 winner)
if (team == winner)
{
// update achievement BEFORE personal rating update
- ArenaTeamMember* member = winner_arena_team->GetMember(plr->GetGUID());
+ ArenaTeamMember* member = winner_arena_team->GetMember(player->GetGUID());
if (member)
- plr->GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_WIN_RATED_ARENA, member->PersonalRating);
+ player->GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_WIN_RATED_ARENA, member->PersonalRating);
- winner_arena_team->MemberWon(plr, loser_matchmaker_rating, winner_matchmaker_change);
+ winner_arena_team->MemberWon(player, loser_matchmaker_rating, winner_matchmaker_change);
}
else
{
- loser_arena_team->MemberLost(plr, winner_matchmaker_rating, loser_matchmaker_change);
+ loser_arena_team->MemberLost(player, winner_matchmaker_rating, loser_matchmaker_change);
// Arena lost => reset the win_rated_arena having the "no_lose" condition
- plr->GetAchievementMgr().ResetAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_WIN_RATED_ARENA, ACHIEVEMENT_CRITERIA_CONDITION_NO_LOSE);
+ player->GetAchievementMgr().ResetAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_WIN_RATED_ARENA, ACHIEVEMENT_CRITERIA_CONDITION_NO_LOSE);
}
}
- uint32 winner_kills = plr->GetRandomWinner() ? BG_REWARD_WINNER_HONOR_LAST : BG_REWARD_WINNER_HONOR_FIRST;
- uint32 loser_kills = plr->GetRandomWinner() ? BG_REWARD_LOSER_HONOR_LAST : BG_REWARD_LOSER_HONOR_FIRST;
- uint32 winner_arena = plr->GetRandomWinner() ? BG_REWARD_WINNER_ARENA_LAST : BG_REWARD_WINNER_ARENA_FIRST;
+ uint32 winner_kills = player->GetRandomWinner() ? BG_REWARD_WINNER_HONOR_LAST : BG_REWARD_WINNER_HONOR_FIRST;
+ uint32 loser_kills = player->GetRandomWinner() ? BG_REWARD_LOSER_HONOR_LAST : BG_REWARD_LOSER_HONOR_FIRST;
+ uint32 winner_arena = player->GetRandomWinner() ? BG_REWARD_WINNER_ARENA_LAST : BG_REWARD_WINNER_ARENA_FIRST;
// Reward winner team
if (team == winner)
{
if (IsRandom() || BattlegroundMgr::IsBGWeekend(GetTypeID()))
{
- UpdatePlayerScore(plr, SCORE_BONUS_HONOR, GetBonusHonorFromKill(winner_kills));
+ UpdatePlayerScore(player, SCORE_BONUS_HONOR, GetBonusHonorFromKill(winner_kills));
if (CanAwardArenaPoints())
- plr->ModifyArenaPoints(winner_arena);
- if (!plr->GetRandomWinner())
- plr->SetRandomWinner(true);
+ player->ModifyArenaPoints(winner_arena);
+ if (!player->GetRandomWinner())
+ player->SetRandomWinner(true);
}
- plr->GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_WIN_BG, 1);
+ player->GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_WIN_BG, 1);
}
else
{
if (IsRandom() || BattlegroundMgr::IsBGWeekend(GetTypeID()))
- UpdatePlayerScore(plr, SCORE_BONUS_HONOR, GetBonusHonorFromKill(loser_kills));
+ UpdatePlayerScore(player, SCORE_BONUS_HONOR, GetBonusHonorFromKill(loser_kills));
}
- plr->ResetAllPowers();
- plr->CombatStopWithPets(true);
+ player->ResetAllPowers();
+ player->CombatStopWithPets(true);
- BlockMovement(plr);
+ BlockMovement(player);
sBattlegroundMgr->BuildPvpLogDataPacket(&data, this);
- plr->GetSession()->SendPacket(&data);
+ player->GetSession()->SendPacket(&data);
BattlegroundQueueTypeId bgQueueTypeId = BattlegroundMgr::BGQueueTypeId(GetTypeID(), GetArenaType());
- sBattlegroundMgr->BuildBattlegroundStatusPacket(&data, this, plr->GetBattlegroundQueueIndex(bgQueueTypeId), STATUS_IN_PROGRESS, TIME_TO_AUTOREMOVE, GetStartTime(), GetArenaType());
- plr->GetSession()->SendPacket(&data);
- plr->GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_BATTLEGROUND, 1);
+ sBattlegroundMgr->BuildBattlegroundStatusPacket(&data, this, player->GetBattlegroundQueueIndex(bgQueueTypeId), STATUS_IN_PROGRESS, TIME_TO_AUTOREMOVE, GetStartTime(), GetArenaType());
+ player->GetSession()->SendPacket(&data);
+ player->GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_BATTLEGROUND, 1);
}
if (isArena() && isRated() && winner_arena_team && loser_arena_team && winner_arena_team != loser_arena_team)
@@ -908,9 +908,9 @@ uint32 Battleground::GetBattlemasterEntry() const
}
}
-void Battleground::BlockMovement(Player* plr)
+void Battleground::BlockMovement(Player* player)
{
- plr->SetClientControl(plr, 0); // movement disabled NOTE: the effect will be automatically removed by client when the player is teleported from the battleground, so no need to send with uint8(1) in RemovePlayerAtLeave()
+ player->SetClientControl(player, 0); // movement disabled NOTE: the effect will be automatically removed by client when the player is teleported from the battleground, so no need to send with uint8(1) in RemovePlayerAtLeave()
}
void Battleground::RemovePlayerAtLeave(uint64 guid, bool Transport, bool SendPacket)
@@ -936,32 +936,32 @@ void Battleground::RemovePlayerAtLeave(uint64 guid, bool Transport, bool SendPac
RemovePlayerFromResurrectQueue(guid);
- Player* plr = ObjectAccessor::FindPlayer(guid);
+ Player* player = ObjectAccessor::FindPlayer(guid);
// should remove spirit of redemption
- if (plr)
+ if (player)
{
- if (plr->HasAuraType(SPELL_AURA_SPIRIT_OF_REDEMPTION))
- plr->RemoveAurasByType(SPELL_AURA_MOD_SHAPESHIFT);
+ if (player->HasAuraType(SPELL_AURA_SPIRIT_OF_REDEMPTION))
+ player->RemoveAurasByType(SPELL_AURA_MOD_SHAPESHIFT);
- if (!plr->isAlive()) // resurrect on exit
+ if (!player->isAlive()) // resurrect on exit
{
- plr->ResurrectPlayer(1.0f);
- plr->SpawnCorpseBones();
+ player->ResurrectPlayer(1.0f);
+ player->SpawnCorpseBones();
}
}
- RemovePlayer(plr, guid, team); // BG subclass specific code
+ RemovePlayer(player, guid, team); // BG subclass specific code
if (participant) // if the player was a match participant, remove auras, calc rating, update queue
{
BattlegroundTypeId bgTypeId = GetTypeID();
BattlegroundQueueTypeId bgQueueTypeId = BattlegroundMgr::BGQueueTypeId(GetTypeID(), GetArenaType());
- if (plr)
+ if (player)
{
- plr->ClearAfkReports();
+ player->ClearAfkReports();
- if (!team) team = plr->GetTeam();
+ if (!team) team = player->GetTeam();
// if arena, remove the specific arena auras
if (isArena())
@@ -969,8 +969,8 @@ void Battleground::RemovePlayerAtLeave(uint64 guid, bool Transport, bool SendPac
bgTypeId=BATTLEGROUND_AA; // set the bg type to all arenas (it will be used for queue refreshing)
// unsummon current and summon old pet if there was one and there isn't a current pet
- plr->RemovePet(NULL, PET_SAVE_NOT_IN_SLOT);
- plr->ResummonPetTemporaryUnSummonedIfAny();
+ player->RemovePet(NULL, PET_SAVE_NOT_IN_SLOT);
+ player->ResummonPetTemporaryUnSummonedIfAny();
if (isRated() && GetStatus() == STATUS_IN_PROGRESS)
{
@@ -978,18 +978,18 @@ void Battleground::RemovePlayerAtLeave(uint64 guid, bool Transport, bool SendPac
ArenaTeam* winner_arena_team = sArenaTeamMgr->GetArenaTeamById(GetArenaTeamIdForTeam(GetOtherTeam(team)));
ArenaTeam* loser_arena_team = sArenaTeamMgr->GetArenaTeamById(GetArenaTeamIdForTeam(team));
if (winner_arena_team && loser_arena_team && winner_arena_team != loser_arena_team)
- loser_arena_team->MemberLost(plr, GetArenaMatchmakerRating(GetOtherTeam(team)));
+ loser_arena_team->MemberLost(player, GetArenaMatchmakerRating(GetOtherTeam(team)));
}
}
if (SendPacket)
{
WorldPacket data;
- sBattlegroundMgr->BuildBattlegroundStatusPacket(&data, this, plr->GetBattlegroundQueueIndex(bgQueueTypeId), STATUS_NONE, 0, 0, 0);
- plr->GetSession()->SendPacket(&data);
+ sBattlegroundMgr->BuildBattlegroundStatusPacket(&data, this, player->GetBattlegroundQueueIndex(bgQueueTypeId), STATUS_NONE, 0, 0, 0);
+ player->GetSession()->SendPacket(&data);
}
// this call is important, because player, when joins to battleground, this method is not called, so it must be called when leaving bg
- plr->RemoveBattlegroundQueueId(bgQueueTypeId);
+ player->RemoveBattlegroundQueueId(bgQueueTypeId);
}
else
// removing offline participant
@@ -1023,20 +1023,20 @@ void Battleground::RemovePlayerAtLeave(uint64 guid, bool Transport, bool SendPac
// Let others know
WorldPacket data;
sBattlegroundMgr->BuildPlayerLeftBattlegroundPacket(&data, guid);
- SendPacketToTeam(team, &data, plr, false);
+ SendPacketToTeam(team, &data, player, false);
}
- if (plr)
+ if (player)
{
// Do next only if found in battleground
- plr->SetBattlegroundId(0, BATTLEGROUND_TYPE_NONE); // We're not in BG.
+ player->SetBattlegroundId(0, BATTLEGROUND_TYPE_NONE); // We're not in BG.
// reset destination bg team
- plr->SetBGTeam(0);
+ player->SetBGTeam(0);
if (Transport)
- plr->TeleportToBGEntryPoint();
+ player->TeleportToBGEntryPoint();
- sLog->outDetail("BATTLEGROUND: Removed player %s from Battleground.", plr->GetName());
+ sLog->outDetail("BATTLEGROUND: Removed player %s from Battleground.", player->GetName());
}
//battleground object will be deleted next Battleground::Update() call
@@ -1087,16 +1087,16 @@ void Battleground::StartBattleground()
sLog->outArena("Arena match type: %u for Team1Id: %u - Team2Id: %u started.", m_ArenaType, m_ArenaTeamIds[BG_TEAM_ALLIANCE], m_ArenaTeamIds[BG_TEAM_HORDE]);
}
-void Battleground::AddPlayer(Player* plr)
+void Battleground::AddPlayer(Player* player)
{
// remove afk from player
- if (plr->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_AFK))
- plr->ToggleAFK();
+ if (player->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_AFK))
+ player->ToggleAFK();
// score struct must be created in inherited class
- uint64 guid = plr->GetGUID();
- uint32 team = plr->GetBGTeam();
+ uint64 guid = player->GetGUID();
+ uint32 team = player->GetBGTeam();
BattlegroundPlayer bp;
bp.OfflineRemoveTime = 0;
@@ -1108,74 +1108,74 @@ void Battleground::AddPlayer(Player* plr)
UpdatePlayersCountByTeam(team, false); // +1 player
WorldPacket data;
- sBattlegroundMgr->BuildPlayerJoinedBattlegroundPacket(&data, plr);
- SendPacketToTeam(team, &data, plr, false);
+ sBattlegroundMgr->BuildPlayerJoinedBattlegroundPacket(&data, player);
+ SendPacketToTeam(team, &data, player, false);
// BG Status packet
WorldPacket status;
BattlegroundQueueTypeId bgQueueTypeId = sBattlegroundMgr->BGQueueTypeId(m_TypeID, GetArenaType());
- uint32 queueSlot = plr->GetBattlegroundQueueIndex(bgQueueTypeId);
+ uint32 queueSlot = player->GetBattlegroundQueueIndex(bgQueueTypeId);
sBattlegroundMgr->BuildBattlegroundStatusPacket(&status, this, queueSlot, STATUS_IN_PROGRESS, 0, GetStartTime(), GetArenaType(), isArena() ? 0 : 1);
- plr->GetSession()->SendPacket(&status);
+ player->GetSession()->SendPacket(&status);
- plr->RemoveAurasByType(SPELL_AURA_MOUNTED);
+ player->RemoveAurasByType(SPELL_AURA_MOUNTED);
// add arena specific auras
if (isArena())
{
- plr->RemoveArenaEnchantments(TEMP_ENCHANTMENT_SLOT);
+ player->RemoveArenaEnchantments(TEMP_ENCHANTMENT_SLOT);
if (team == ALLIANCE) // gold
{
- if (plr->GetTeam() == HORDE)
- plr->CastSpell(plr, SPELL_HORDE_GOLD_FLAG, true);
+ if (player->GetTeam() == HORDE)
+ player->CastSpell(player, SPELL_HORDE_GOLD_FLAG, true);
else
- plr->CastSpell(plr, SPELL_ALLIANCE_GOLD_FLAG, true);
+ player->CastSpell(player, SPELL_ALLIANCE_GOLD_FLAG, true);
}
else // green
{
- if (plr->GetTeam() == HORDE)
- plr->CastSpell(plr, SPELL_HORDE_GREEN_FLAG, true);
+ if (player->GetTeam() == HORDE)
+ player->CastSpell(player, SPELL_HORDE_GREEN_FLAG, true);
else
- plr->CastSpell(plr, SPELL_ALLIANCE_GREEN_FLAG, true);
+ player->CastSpell(player, SPELL_ALLIANCE_GREEN_FLAG, true);
}
- plr->DestroyConjuredItems(true);
- plr->UnsummonPetTemporaryIfAny();
+ player->DestroyConjuredItems(true);
+ player->UnsummonPetTemporaryIfAny();
if (GetStatus() == STATUS_WAIT_JOIN) // not started yet
{
- plr->CastSpell(plr, SPELL_ARENA_PREPARATION, true);
- plr->ResetAllPowers();
+ player->CastSpell(player, SPELL_ARENA_PREPARATION, true);
+ player->ResetAllPowers();
}
WorldPacket teammate;
teammate.Initialize(SMSG_ARENA_OPPONENT_UPDATE, 8);
- teammate << uint64(plr->GetGUID());
- SendPacketToTeam(team, &teammate, plr, false);
+ teammate << uint64(player->GetGUID());
+ SendPacketToTeam(team, &teammate, player, false);
}
else
{
if (GetStatus() == STATUS_WAIT_JOIN) // not started yet
- plr->CastSpell(plr, SPELL_PREPARATION, true); // reduces all mana cost of spells.
+ player->CastSpell(player, SPELL_PREPARATION, true); // reduces all mana cost of spells.
}
- plr->GetAchievementMgr().ResetAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_KILL_CREATURE, ACHIEVEMENT_CRITERIA_CONDITION_BG_MAP, GetMapId(), true);
- plr->GetAchievementMgr().ResetAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_WIN_BG, ACHIEVEMENT_CRITERIA_CONDITION_BG_MAP, GetMapId(), true);
- plr->GetAchievementMgr().ResetAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_DAMAGE_DONE, ACHIEVEMENT_CRITERIA_CONDITION_BG_MAP, GetMapId(), true);
- plr->GetAchievementMgr().ResetAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_BE_SPELL_TARGET, ACHIEVEMENT_CRITERIA_CONDITION_BG_MAP, GetMapId(), true);
- plr->GetAchievementMgr().ResetAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_CAST_SPELL, ACHIEVEMENT_CRITERIA_CONDITION_BG_MAP, GetMapId(), true);
- plr->GetAchievementMgr().ResetAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_BG_OBJECTIVE_CAPTURE, ACHIEVEMENT_CRITERIA_CONDITION_BG_MAP, GetMapId(), true);
- plr->GetAchievementMgr().ResetAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_HONORABLE_KILL_AT_AREA, ACHIEVEMENT_CRITERIA_CONDITION_BG_MAP, GetMapId(), true);
- plr->GetAchievementMgr().ResetAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_HONORABLE_KILL, ACHIEVEMENT_CRITERIA_CONDITION_BG_MAP, GetMapId(), true);
- plr->GetAchievementMgr().ResetAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_HEALING_DONE, ACHIEVEMENT_CRITERIA_CONDITION_BG_MAP, GetMapId(), true);
- plr->GetAchievementMgr().ResetAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_GET_KILLING_BLOWS, ACHIEVEMENT_CRITERIA_CONDITION_BG_MAP, GetMapId(), true);
- plr->GetAchievementMgr().ResetAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_SPECIAL_PVP_KILL, ACHIEVEMENT_CRITERIA_CONDITION_BG_MAP, GetMapId(), true);
+ player->GetAchievementMgr().ResetAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_KILL_CREATURE, ACHIEVEMENT_CRITERIA_CONDITION_BG_MAP, GetMapId(), true);
+ player->GetAchievementMgr().ResetAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_WIN_BG, ACHIEVEMENT_CRITERIA_CONDITION_BG_MAP, GetMapId(), true);
+ player->GetAchievementMgr().ResetAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_DAMAGE_DONE, ACHIEVEMENT_CRITERIA_CONDITION_BG_MAP, GetMapId(), true);
+ player->GetAchievementMgr().ResetAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_BE_SPELL_TARGET, ACHIEVEMENT_CRITERIA_CONDITION_BG_MAP, GetMapId(), true);
+ player->GetAchievementMgr().ResetAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_CAST_SPELL, ACHIEVEMENT_CRITERIA_CONDITION_BG_MAP, GetMapId(), true);
+ player->GetAchievementMgr().ResetAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_BG_OBJECTIVE_CAPTURE, ACHIEVEMENT_CRITERIA_CONDITION_BG_MAP, GetMapId(), true);
+ player->GetAchievementMgr().ResetAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_HONORABLE_KILL_AT_AREA, ACHIEVEMENT_CRITERIA_CONDITION_BG_MAP, GetMapId(), true);
+ player->GetAchievementMgr().ResetAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_HONORABLE_KILL, ACHIEVEMENT_CRITERIA_CONDITION_BG_MAP, GetMapId(), true);
+ player->GetAchievementMgr().ResetAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_HEALING_DONE, ACHIEVEMENT_CRITERIA_CONDITION_BG_MAP, GetMapId(), true);
+ player->GetAchievementMgr().ResetAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_GET_KILLING_BLOWS, ACHIEVEMENT_CRITERIA_CONDITION_BG_MAP, GetMapId(), true);
+ player->GetAchievementMgr().ResetAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_SPECIAL_PVP_KILL, ACHIEVEMENT_CRITERIA_CONDITION_BG_MAP, GetMapId(), true);
// setup BG group membership
- PlayerAddedToBGCheckIfBGIsRunning(plr);
- AddOrSetPlayerToCorrectBgGroup(plr, team);
+ PlayerAddedToBGCheckIfBGIsRunning(player);
+ AddOrSetPlayerToCorrectBgGroup(player, team);
// Log
- sLog->outDetail("BATTLEGROUND: Player %s joined the battle.", plr->GetName());
+ sLog->outDetail("BATTLEGROUND: Player %s joined the battle.", player->GetName());
}
// this method adds player to his team's bg group, or sets his correct group if player is already in bg group
@@ -1385,11 +1385,11 @@ void Battleground::AddPlayerToResurrectQueue(uint64 npc_guid, uint64 player_guid
{
m_ReviveQueue[npc_guid].push_back(player_guid);
- Player* plr = ObjectAccessor::FindPlayer(player_guid);
- if (!plr)
+ Player* player = ObjectAccessor::FindPlayer(player_guid);
+ if (!player)
return;
- plr->CastSpell(plr, SPELL_WAITING_FOR_RESURRECT, true);
+ player->CastSpell(player, SPELL_WAITING_FOR_RESURRECT, true);
}
void Battleground::RemovePlayerFromResurrectQueue(uint64 player_guid)
@@ -1401,8 +1401,8 @@ void Battleground::RemovePlayerFromResurrectQueue(uint64 player_guid)
if (*itr2 == player_guid)
{
(itr->second).erase(itr2);
- if (Player* plr = ObjectAccessor::FindPlayer(player_guid))
- plr->RemoveAurasDueToSpell(SPELL_WAITING_FOR_RESURRECT);
+ if (Player* player = ObjectAccessor::FindPlayer(player_guid))
+ player->RemoveAurasDueToSpell(SPELL_WAITING_FOR_RESURRECT);
return;
}
}
@@ -1680,9 +1680,9 @@ void Battleground::SendWarningToAll(int32 entry, ...)
data << msg.c_str();
data << (uint8)0;
for (BattlegroundPlayerMap::const_iterator itr = m_Players.begin(); itr != m_Players.end(); ++itr)
- if (Player* plr = ObjectAccessor::FindPlayer(MAKE_NEW_GUID(itr->first, 0, HIGHGUID_PLAYER)))
- if (plr->GetSession())
- plr->GetSession()->SendPacket(&data);
+ if (Player* player = ObjectAccessor::FindPlayer(MAKE_NEW_GUID(itr->first, 0, HIGHGUID_PLAYER)))
+ if (player->GetSession())
+ player->GetSession()->SendPacket(&data);
}
void Battleground::SendMessage2ToAll(int32 entry, ChatMsg type, Player const* source, int32 arg1, int32 arg2)
@@ -1759,12 +1759,12 @@ void Battleground::HandleKillPlayer(Player* player, Player* killer)
for (BattlegroundPlayerMap::const_iterator itr = m_Players.begin(); itr != m_Players.end(); ++itr)
{
- Player* plr = ObjectAccessor::FindPlayer(itr->first);
- if (!plr || plr == killer)
+ Player* creditedPlayer = ObjectAccessor::FindPlayer(itr->first);
+ if (!creditedPlayer || creditedPlayer == killer)
continue;
- if (plr->GetTeam() == killer->GetTeam() && plr->IsAtGroupRewardDistance(player))
- UpdatePlayerScore(plr, SCORE_HONORABLE_KILLS, 1);
+ if (creditedPlayer->GetTeam() == killer->GetTeam() && creditedPlayer->IsAtGroupRewardDistance(player))
+ UpdatePlayerScore(creditedPlayer, SCORE_HONORABLE_KILLS, 1);
}
}
@@ -1799,7 +1799,7 @@ bool Battleground::IsPlayerInBattleground(uint64 guid) const
return false;
}
-void Battleground::PlayerAddedToBGCheckIfBGIsRunning(Player* plr)
+void Battleground::PlayerAddedToBGCheckIfBGIsRunning(Player* player)
{
if (GetStatus() != STATUS_WAIT_LEAVE)
return;
@@ -1807,13 +1807,13 @@ void Battleground::PlayerAddedToBGCheckIfBGIsRunning(Player* plr)
WorldPacket data;
BattlegroundQueueTypeId bgQueueTypeId = BattlegroundMgr::BGQueueTypeId(GetTypeID(), GetArenaType());
- BlockMovement(plr);
+ BlockMovement(player);
sBattlegroundMgr->BuildPvpLogDataPacket(&data, this);
- plr->GetSession()->SendPacket(&data);
+ player->GetSession()->SendPacket(&data);
- sBattlegroundMgr->BuildBattlegroundStatusPacket(&data, this, plr->GetBattlegroundQueueIndex(bgQueueTypeId), STATUS_IN_PROGRESS, GetEndTime(), GetStartTime(), GetArenaType());
- plr->GetSession()->SendPacket(&data);
+ sBattlegroundMgr->BuildBattlegroundStatusPacket(&data, this, player->GetBattlegroundQueueIndex(bgQueueTypeId), STATUS_IN_PROGRESS, GetEndTime(), GetStartTime(), GetArenaType());
+ player->GetSession()->SendPacket(&data);
}
uint32 Battleground::GetAlivePlayersCountByTeam(uint32 Team) const
@@ -1823,8 +1823,8 @@ uint32 Battleground::GetAlivePlayersCountByTeam(uint32 Team) const
{
if (itr->second.Team == Team)
{
- Player* pl = ObjectAccessor::FindPlayer(itr->first);
- if (pl && pl->isAlive() && !pl->HasByteFlag(UNIT_FIELD_BYTES_2, 3, FORM_SPIRITOFREDEMPTION))
+ Player* player = ObjectAccessor::FindPlayer(itr->first);
+ if (player && player->isAlive() && !player->HasByteFlag(UNIT_FIELD_BYTES_2, 3, FORM_SPIRITOFREDEMPTION))
++count;
}
}
diff --git a/src/server/game/Battlegrounds/Battleground.h b/src/server/game/Battlegrounds/Battleground.h
index d5921e4bf37..9856312c337 100755
--- a/src/server/game/Battlegrounds/Battleground.h
+++ b/src/server/game/Battlegrounds/Battleground.h
@@ -329,7 +329,7 @@ class Battleground
{
}
- virtual void DestroyGate(Player* /*pl*/, GameObject* /*go*/) {}
+ virtual void DestroyGate(Player* /*player*/, GameObject* /*go*/) {}
/* achievement req. */
virtual bool IsAllNodesConrolledByTeam(uint32 /*team*/) const { return false; }
@@ -463,7 +463,7 @@ class Battleground
void UpdateWorldState(uint32 Field, uint32 Value);
void UpdateWorldStateForPlayer(uint32 Field, uint32 Value, Player* Source);
void EndBattleground(uint32 winner);
- void BlockMovement(Player* plr);
+ void BlockMovement(Player* player);
void SendWarningToAll(int32 entry, ...);
void SendMessageToAll(int32 entry, ChatMsg type, Player const* source = NULL);
@@ -515,7 +515,7 @@ class Battleground
virtual void EventPlayerClickedOnFlag(Player* /*player*/, GameObject* /*target_obj*/) {}
void EventPlayerLoggedIn(Player* player);
void EventPlayerLoggedOut(Player* player);
- virtual void EventPlayerDamagedGO(Player* /*plr*/, GameObject* /*go*/, uint32 /*eventType*/) {}
+ virtual void EventPlayerDamagedGO(Player* /*player*/, GameObject* /*go*/, uint32 /*eventType*/) {}
virtual void EventPlayerUsedGO(Player* /*player*/, GameObject* /*go*/){}
// this function can be used by spell to interact with the BG map
@@ -526,7 +526,7 @@ class Battleground
// Death related
virtual WorldSafeLocsEntry const* GetClosestGraveYard(Player* player);
- virtual void AddPlayer(Player* plr); // must be implemented in BG subclass
+ virtual void AddPlayer(Player* player); // must be implemented in BG subclass
void AddOrSetPlayerToCorrectBgGroup(Player* player, uint32 team);
@@ -554,7 +554,7 @@ class Battleground
//to be removed
const char* GetTrinityString(int32 entry);
- virtual bool HandlePlayerUnderMap(Player* /*plr*/) { return false; }
+ virtual bool HandlePlayerUnderMap(Player* /*player*/) { return false; }
// since arenas can be AvA or Hvh, we have to get the "temporary" team of a player
uint32 GetPlayerTeam(uint64 guid) const;
@@ -575,7 +575,7 @@ class Battleground
protected:
// this method is called, when BG cannot spawn its own spirit guide, or something is wrong, It correctly ends Battleground
void EndNow();
- void PlayerAddedToBGCheckIfBGIsRunning(Player* plr);
+ void PlayerAddedToBGCheckIfBGIsRunning(Player* player);
Player* _GetPlayer(uint64 guid, bool offlineRemove, const char* context) const;
Player* _GetPlayer(BattlegroundPlayerMap::iterator itr, const char* context);
diff --git a/src/server/game/Battlegrounds/BattlegroundMgr.cpp b/src/server/game/Battlegrounds/BattlegroundMgr.cpp
index e00abb03320..a9acced82ae 100755
--- a/src/server/game/Battlegrounds/BattlegroundMgr.cpp
+++ b/src/server/game/Battlegrounds/BattlegroundMgr.cpp
@@ -291,10 +291,10 @@ void BattlegroundMgr::BuildPvpLogDataPacket(WorldPacket* data, Battleground* bg)
}
else
{
- Player* plr = ObjectAccessor::FindPlayer(itr2->first);
+ Player* player = ObjectAccessor::FindPlayer(itr2->first);
uint32 team = bg->GetPlayerTeam(itr2->first);
- if (!team && plr)
- team = plr->GetBGTeam();
+ if (!team && player)
+ team = player->GetBGTeam();
*data << uint8(team == ALLIANCE ? 1 : 0); // green or yellow
}
*data << uint32(itr2->second->DamageDone); // damage done
@@ -422,10 +422,10 @@ void BattlegroundMgr::BuildPlayerLeftBattlegroundPacket(WorldPacket* data, uint6
*data << uint64(guid);
}
-void BattlegroundMgr::BuildPlayerJoinedBattlegroundPacket(WorldPacket* data, Player* plr)
+void BattlegroundMgr::BuildPlayerJoinedBattlegroundPacket(WorldPacket* data, Player* player)
{
data->Initialize(SMSG_BATTLEGROUND_PLAYER_JOINED, 8);
- *data << uint64(plr->GetGUID());
+ *data << uint64(player->GetGUID());
}
Battleground* BattlegroundMgr::GetBattlegroundThroughClientInstance(uint32 instanceId, BattlegroundTypeId bgTypeId)
@@ -804,17 +804,17 @@ void BattlegroundMgr::InitAutomaticArenaPointDistribution()
sLog->outDebug(LOG_FILTER_BATTLEGROUND, "Automatic Arena Point Distribution initialized.");
}
-void BattlegroundMgr::BuildBattlegroundListPacket(WorldPacket* data, uint64 guid, Player* plr, BattlegroundTypeId bgTypeId, uint8 fromWhere)
+void BattlegroundMgr::BuildBattlegroundListPacket(WorldPacket* data, uint64 guid, Player* player, BattlegroundTypeId bgTypeId, uint8 fromWhere)
{
- if (!plr)
+ if (!player)
return;
- uint32 winner_kills = plr->GetRandomWinner() ? BG_REWARD_WINNER_HONOR_LAST : BG_REWARD_WINNER_HONOR_FIRST;
- uint32 winner_arena = plr->GetRandomWinner() ? BG_REWARD_WINNER_ARENA_LAST : BG_REWARD_WINNER_ARENA_FIRST;
- uint32 loser_kills = plr->GetRandomWinner() ? BG_REWARD_LOSER_HONOR_LAST : BG_REWARD_LOSER_HONOR_FIRST;
+ uint32 winner_kills = player->GetRandomWinner() ? BG_REWARD_WINNER_HONOR_LAST : BG_REWARD_WINNER_HONOR_FIRST;
+ uint32 winner_arena = player->GetRandomWinner() ? BG_REWARD_WINNER_ARENA_LAST : BG_REWARD_WINNER_ARENA_FIRST;
+ uint32 loser_kills = player->GetRandomWinner() ? BG_REWARD_LOSER_HONOR_LAST : BG_REWARD_LOSER_HONOR_FIRST;
- winner_kills = Trinity::Honor::hk_honor_at_level(plr->getLevel(), float(winner_kills));
- loser_kills = Trinity::Honor::hk_honor_at_level(plr->getLevel(), float(loser_kills));
+ winner_kills = Trinity::Honor::hk_honor_at_level(player->getLevel(), float(winner_kills));
+ loser_kills = Trinity::Honor::hk_honor_at_level(player->getLevel(), float(loser_kills));
data->Initialize(SMSG_BATTLEFIELD_LIST);
*data << uint64(guid); // battlemaster guid
@@ -824,7 +824,7 @@ void BattlegroundMgr::BuildBattlegroundListPacket(WorldPacket* data, uint64 guid
*data << uint8(0); // unk
// Rewards
- *data << uint8(plr->GetRandomWinner()); // 3.3.3 hasWin
+ *data << uint8(player->GetRandomWinner()); // 3.3.3 hasWin
*data << uint32(winner_kills); // 3.3.3 winHonor
*data << uint32(winner_arena); // 3.3.3 winArena
*data << uint32(loser_kills); // 3.3.3 lossHonor
@@ -835,7 +835,7 @@ void BattlegroundMgr::BuildBattlegroundListPacket(WorldPacket* data, uint64 guid
if (isRandom)
{
// Rewards (random)
- *data << uint8(plr->GetRandomWinner()); // 3.3.3 hasWin_Random
+ *data << uint8(player->GetRandomWinner()); // 3.3.3 hasWin_Random
*data << uint32(winner_kills); // 3.3.3 winHonor_Random
*data << uint32(winner_arena); // 3.3.3 winArena_Random
*data << uint32(loser_kills); // 3.3.3 lossHonor_Random
@@ -853,7 +853,7 @@ void BattlegroundMgr::BuildBattlegroundListPacket(WorldPacket* data, uint64 guid
if (Battleground* bgTemplate = sBattlegroundMgr->GetBattlegroundTemplate(bgTypeId))
{
// expected bracket entry
- if (PvPDifficultyEntry const* bracketEntry = GetBattlegroundBracketByLevel(bgTemplate->GetMapId(), plr->getLevel()))
+ if (PvPDifficultyEntry const* bracketEntry = GetBattlegroundBracketByLevel(bgTemplate->GetMapId(), player->getLevel()))
{
uint32 count = 0;
BattlegroundBracketId bracketId = bracketEntry->GetBracketId();
@@ -868,35 +868,35 @@ void BattlegroundMgr::BuildBattlegroundListPacket(WorldPacket* data, uint64 guid
}
}
-void BattlegroundMgr::SendToBattleground(Player* pl, uint32 instanceId, BattlegroundTypeId bgTypeId)
+void BattlegroundMgr::SendToBattleground(Player* player, uint32 instanceId, BattlegroundTypeId bgTypeId)
{
Battleground* bg = GetBattleground(instanceId, bgTypeId);
if (bg)
{
uint32 mapid = bg->GetMapId();
float x, y, z, O;
- uint32 team = pl->GetBGTeam();
+ uint32 team = player->GetBGTeam();
if (team == 0)
- team = pl->GetTeam();
+ team = player->GetTeam();
bg->GetTeamStartLoc(team, x, y, z, O);
- sLog->outDetail("BATTLEGROUND: Sending %s to map %u, X %f, Y %f, Z %f, O %f", pl->GetName(), mapid, x, y, z, O);
- pl->TeleportTo(mapid, x, y, z, O);
+ sLog->outDetail("BATTLEGROUND: Sending %s to map %u, X %f, Y %f, Z %f, O %f", player->GetName(), mapid, x, y, z, O);
+ player->TeleportTo(mapid, x, y, z, O);
}
else
{
- sLog->outError("player %u is trying to port to non-existent bg instance %u", pl->GetGUIDLow(), instanceId);
+ sLog->outError("player %u is trying to port to non-existent bg instance %u", player->GetGUIDLow(), instanceId);
}
}
-void BattlegroundMgr::SendAreaSpiritHealerQueryOpcode(Player* pl, Battleground* bg, uint64 guid)
+void BattlegroundMgr::SendAreaSpiritHealerQueryOpcode(Player* player, Battleground* bg, uint64 guid)
{
WorldPacket data(SMSG_AREA_SPIRIT_HEALER_TIME, 12);
uint32 time_ = 30000 - bg->GetLastResurrectTime(); // resurrect every 30 seconds
if (time_ == uint32(-1))
time_ = 0;
data << guid << time_;
- pl->GetSession()->SendPacket(&data);
+ player->GetSession()->SendPacket(&data);
}
bool BattlegroundMgr::IsArenaType(BattlegroundTypeId bgTypeId)
diff --git a/src/server/game/Battlegrounds/BattlegroundMgr.h b/src/server/game/Battlegrounds/BattlegroundMgr.h
index 7f35e5366a5..989509111bb 100755
--- a/src/server/game/Battlegrounds/BattlegroundMgr.h
+++ b/src/server/game/Battlegrounds/BattlegroundMgr.h
@@ -65,15 +65,15 @@ class BattlegroundMgr
void Update(uint32 diff);
/* Packet Building */
- void BuildPlayerJoinedBattlegroundPacket(WorldPacket* data, Player* plr);
+ void BuildPlayerJoinedBattlegroundPacket(WorldPacket* data, Player* player);
void BuildPlayerLeftBattlegroundPacket(WorldPacket* data, uint64 guid);
- void BuildBattlegroundListPacket(WorldPacket* data, uint64 guid, Player* plr, BattlegroundTypeId bgTypeId, uint8 fromWhere);
+ void BuildBattlegroundListPacket(WorldPacket* data, uint64 guid, Player* player, BattlegroundTypeId bgTypeId, uint8 fromWhere);
void BuildGroupJoinedBattlegroundPacket(WorldPacket* data, GroupJoinBattlegroundResult result);
void BuildUpdateWorldStatePacket(WorldPacket* data, uint32 field, uint32 value);
void BuildPvpLogDataPacket(WorldPacket* data, Battleground* bg);
void BuildBattlegroundStatusPacket(WorldPacket* data, Battleground* bg, uint8 QueueSlot, uint8 StatusID, uint32 Time1, uint32 Time2, uint8 arenatype, uint8 uiFrame = 1);
void BuildPlaySoundPacket(WorldPacket* data, uint32 soundid);
- void SendAreaSpiritHealerQueryOpcode(Player* pl, Battleground* bg, uint64 guid);
+ void SendAreaSpiritHealerQueryOpcode(Player* player, Battleground* bg, uint64 guid);
/* Battlegrounds */
Battleground* GetBattlegroundThroughClientInstance(uint32 instanceId, BattlegroundTypeId bgTypeId);
@@ -91,7 +91,7 @@ class BattlegroundMgr
void CreateInitialBattlegrounds();
void DeleteAllBattlegrounds();
- void SendToBattleground(Player* pl, uint32 InstanceID, BattlegroundTypeId bgTypeId);
+ void SendToBattleground(Player* player, uint32 InstanceID, BattlegroundTypeId bgTypeId);
/* Battleground queues */
//these queues are instantiated when creating BattlegroundMrg
diff --git a/src/server/game/Battlegrounds/BattlegroundQueue.cpp b/src/server/game/Battlegrounds/BattlegroundQueue.cpp
index 67cea3e7be1..0d76759e1be 100755
--- a/src/server/game/Battlegrounds/BattlegroundQueue.cpp
+++ b/src/server/game/Battlegrounds/BattlegroundQueue.cpp
@@ -285,7 +285,7 @@ uint32 BattlegroundQueue::GetAverageQueueWaitTime(GroupQueueInfo* ginfo, Battleg
//remove player from queue and from group info, if group info is empty then remove it too
void BattlegroundQueue::RemovePlayer(uint64 guid, bool decreaseInvitedCount)
{
- //Player* plr = ObjectAccessor::FindPlayer(guid);
+ //Player* player = ObjectAccessor::FindPlayer(guid);
int32 bracket_id = -1; // signed for proper for-loop finish
QueuedPlayersMap::iterator itr;
@@ -362,8 +362,8 @@ void BattlegroundQueue::RemovePlayer(uint64 guid, bool decreaseInvitedCount)
if (ArenaTeam* at = sArenaTeamMgr->GetArenaTeamById(group->ArenaTeamId))
{
sLog->outDebug(LOG_FILTER_BATTLEGROUND, "UPDATING memberLost's personal arena rating for %u by opponents rating: %u", GUID_LOPART(guid), group->OpponentsTeamRating);
- if (Player* plr = ObjectAccessor::FindPlayer(guid))
- at->MemberLost(plr, group->OpponentsMatchmakerRating);
+ if (Player* player = ObjectAccessor::FindPlayer(guid))
+ at->MemberLost(player, group->OpponentsMatchmakerRating);
else
at->OfflineMemberLost(guid, group->OpponentsMatchmakerRating);
at->SaveToDB();
@@ -442,36 +442,36 @@ bool BattlegroundQueue::InviteGroupToBG(GroupQueueInfo* ginfo, Battleground* bg,
for (std::map<uint64, PlayerQueueInfo*>::iterator itr = ginfo->Players.begin(); itr != ginfo->Players.end(); ++itr)
{
// get the player
- Player* plr = ObjectAccessor::FindPlayer(itr->first);
+ Player* player = ObjectAccessor::FindPlayer(itr->first);
// if offline, skip him, this should not happen - player is removed from queue when he logs out
- if (!plr)
+ if (!player)
continue;
// invite the player
PlayerInvitedToBGUpdateAverageWaitTime(ginfo, bracket_id);
- //sBattlegroundMgr->InvitePlayer(plr, bg, ginfo->Team);
+ //sBattlegroundMgr->InvitePlayer(player, bg, ginfo->Team);
// set invited player counters
bg->IncreaseInvitedCount(ginfo->Team);
- plr->SetInviteForBattlegroundQueueType(bgQueueTypeId, ginfo->IsInvitedToBGInstanceGUID);
+ player->SetInviteForBattlegroundQueueType(bgQueueTypeId, ginfo->IsInvitedToBGInstanceGUID);
// create remind invite events
- BGQueueInviteEvent* inviteEvent = new BGQueueInviteEvent(plr->GetGUID(), ginfo->IsInvitedToBGInstanceGUID, bgTypeId, ginfo->ArenaType, ginfo->RemoveInviteTime);
+ BGQueueInviteEvent* inviteEvent = new BGQueueInviteEvent(player->GetGUID(), ginfo->IsInvitedToBGInstanceGUID, bgTypeId, ginfo->ArenaType, ginfo->RemoveInviteTime);
m_events.AddEvent(inviteEvent, m_events.CalculateTime(INVITATION_REMIND_TIME));
// create automatic remove events
- BGQueueRemoveEvent* removeEvent = new BGQueueRemoveEvent(plr->GetGUID(), ginfo->IsInvitedToBGInstanceGUID, bgTypeId, bgQueueTypeId, ginfo->RemoveInviteTime);
+ BGQueueRemoveEvent* removeEvent = new BGQueueRemoveEvent(player->GetGUID(), ginfo->IsInvitedToBGInstanceGUID, bgTypeId, bgQueueTypeId, ginfo->RemoveInviteTime);
m_events.AddEvent(removeEvent, m_events.CalculateTime(INVITE_ACCEPT_WAIT_TIME));
WorldPacket data;
- uint32 queueSlot = plr->GetBattlegroundQueueIndex(bgQueueTypeId);
+ uint32 queueSlot = player->GetBattlegroundQueueIndex(bgQueueTypeId);
- sLog->outDebug(LOG_FILTER_BATTLEGROUND, "Battleground: invited plr %s (%u) to BG instance %u queueindex %u bgtype %u, I can't help it if they don't press the enter battle button.", plr->GetName(), plr->GetGUIDLow(), bg->GetInstanceID(), queueSlot, bg->GetTypeID());
+ 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());
// send status packet
sBattlegroundMgr->BuildBattlegroundStatusPacket(&data, bg, queueSlot, STATUS_WAIT_JOIN, INVITE_ACCEPT_WAIT_TIME, 0, ginfo->ArenaType);
- plr->GetSession()->SendPacket(&data);
+ player->GetSession()->SendPacket(&data);
}
return true;
}
@@ -911,68 +911,51 @@ void BattlegroundQueue::BattlegroundQueueUpdate(uint32 diff, BattlegroundTypeId
uint32 discardTime = getMSTime() - sBattlegroundMgr->GetRatingDiscardTimer();
// we need to find 2 teams which will play next game
+ GroupsQueueType::iterator itr_teams[BG_TEAMS_COUNT];
+ uint8 found = 0;
+ uint8 team = 0;
- GroupsQueueType::iterator itr_team[BG_TEAMS_COUNT];
-
- //optimalization : --- we dont need to use selection_pools - each update we select max 2 groups
- for (uint32 i = BG_QUEUE_PREMADE_ALLIANCE; i < BG_QUEUE_NORMAL_ALLIANCE; i++)
+ for (uint8 i = BG_QUEUE_PREMADE_ALLIANCE; i < BG_QUEUE_NORMAL_ALLIANCE; i++)
{
// take the group that joined first
- itr_team[i] = m_QueuedGroups[bracket_id][i].begin();
- for (; itr_team[i] != m_QueuedGroups[bracket_id][i].end(); ++(itr_team[i]))
+ GroupsQueueType::iterator itr2 = m_QueuedGroups[bracket_id][i].begin();
+ for (; itr2 != m_QueuedGroups[bracket_id][i].end(); ++itr2)
{
// if group match conditions, then add it to pool
- if (!(*itr_team[i])->IsInvitedToBGInstanceGUID
- && (((*itr_team[i])->ArenaMatchmakerRating >= arenaMinRating && (*itr_team[i])->ArenaMatchmakerRating <= arenaMaxRating)
- || (*itr_team[i])->JoinTime < discardTime))
+ if (!(*itr2)->IsInvitedToBGInstanceGUID
+ && (((*itr2)->ArenaMatchmakerRating >= arenaMinRating && (*itr2)->ArenaMatchmakerRating <= arenaMaxRating)
+ || (*itr2)->JoinTime < discardTime))
{
- m_SelectionPools[i].AddGroup((*itr_team[i]), MaxPlayersPerTeam);
- // break for cycle to be able to start selecting another group from same faction queue
+ itr_teams[found++] = itr2;
+ team = i;
break;
}
}
}
- // now we are done if we have 2 groups - ali vs horde!
- // if we don't have, we must try to continue search in same queue
- // tmp variables are correctly set
- // this code isn't much userfriendly - but it is supposed to continue search for mathing group in HORDE queue
- if (m_SelectionPools[BG_TEAM_ALLIANCE].GetPlayerCount() == 0 && m_SelectionPools[BG_TEAM_HORDE].GetPlayerCount())
- {
- itr_team[BG_TEAM_ALLIANCE] = itr_team[BG_TEAM_HORDE];
- ++itr_team[BG_TEAM_ALLIANCE];
- for (; itr_team[BG_TEAM_ALLIANCE] != m_QueuedGroups[bracket_id][BG_QUEUE_PREMADE_HORDE].end(); ++(itr_team[BG_TEAM_ALLIANCE]))
- {
- if (!(*itr_team[BG_TEAM_ALLIANCE])->IsInvitedToBGInstanceGUID
- && (((*itr_team[BG_TEAM_ALLIANCE])->ArenaMatchmakerRating >= arenaMinRating && (*itr_team[BG_TEAM_ALLIANCE])->ArenaMatchmakerRating <= arenaMaxRating)
- || (*itr_team[BG_TEAM_ALLIANCE])->JoinTime < discardTime))
- {
- m_SelectionPools[BG_TEAM_ALLIANCE].AddGroup((*itr_team[BG_TEAM_ALLIANCE]), MaxPlayersPerTeam);
- break;
- }
- }
- }
+ if (!found)
+ return;
- // this code isn't much userfriendly - but it is supposed to continue search for mathing group in ALLIANCE queue
- if (m_SelectionPools[BG_TEAM_HORDE].GetPlayerCount() == 0 && m_SelectionPools[BG_TEAM_ALLIANCE].GetPlayerCount())
+ if (found == 1)
{
- itr_team[BG_TEAM_HORDE] = itr_team[BG_TEAM_ALLIANCE];
- ++itr_team[BG_TEAM_HORDE];
- for (; itr_team[BG_TEAM_HORDE] != m_QueuedGroups[bracket_id][BG_QUEUE_PREMADE_ALLIANCE].end(); ++(itr_team[BG_TEAM_HORDE]))
+ for (GroupsQueueType::iterator itr3 = itr_teams[0]; itr3 != m_QueuedGroups[bracket_id][team].end(); ++itr3)
{
- if (!(*itr_team[BG_TEAM_HORDE])->IsInvitedToBGInstanceGUID
- && (((*itr_team[BG_TEAM_HORDE])->ArenaMatchmakerRating >= arenaMinRating && (*itr_team[BG_TEAM_HORDE])->ArenaMatchmakerRating <= arenaMaxRating)
- || (*itr_team[BG_TEAM_HORDE])->JoinTime < discardTime))
+ if (!(*itr3)->IsInvitedToBGInstanceGUID
+ && (((*itr3)->ArenaMatchmakerRating >= arenaMinRating && (*itr3)->ArenaMatchmakerRating <= arenaMaxRating)
+ || (*itr3)->JoinTime < discardTime)
+ && (*itr_teams[0])->ArenaTeamId != (*itr3)->ArenaTeamId)
{
- m_SelectionPools[BG_TEAM_HORDE].AddGroup((*itr_team[BG_TEAM_HORDE]), MaxPlayersPerTeam);
+ itr_teams[found++] = itr3;
break;
}
}
}
//if we have 2 teams, then start new arena and invite players!
- if (m_SelectionPools[BG_TEAM_ALLIANCE].GetPlayerCount() && m_SelectionPools[BG_TEAM_HORDE].GetPlayerCount())
+ if (found == 2)
{
+ GroupQueueInfo* aTeam = *itr_teams[BG_TEAM_ALLIANCE];
+ GroupQueueInfo* hTeam = *itr_teams[BG_TEAM_HORDE];
Battleground* arena = sBattlegroundMgr->CreateNewBattleground(bgTypeId, bracketEntry, arenaType, true);
if (!arena)
{
@@ -980,35 +963,31 @@ void BattlegroundQueue::BattlegroundQueueUpdate(uint32 diff, BattlegroundTypeId
return;
}
- (*(itr_team[BG_TEAM_ALLIANCE]))->OpponentsTeamRating = (*(itr_team[BG_TEAM_HORDE]))->ArenaTeamRating;
- (*(itr_team[BG_TEAM_ALLIANCE]))->OpponentsMatchmakerRating = (*(itr_team[BG_TEAM_HORDE]))->ArenaMatchmakerRating;
- sLog->outDebug(LOG_FILTER_BATTLEGROUND, "setting oposite teamrating for team %u to %u", (*(itr_team[BG_TEAM_ALLIANCE]))->ArenaTeamId, (*(itr_team[BG_TEAM_ALLIANCE]))->OpponentsTeamRating);
- (*(itr_team[BG_TEAM_HORDE]))->OpponentsTeamRating = (*(itr_team[BG_TEAM_ALLIANCE]))->ArenaTeamRating;
- (*(itr_team[BG_TEAM_HORDE]))->OpponentsMatchmakerRating = (*(itr_team[BG_TEAM_ALLIANCE]))->ArenaMatchmakerRating;
- sLog->outDebug(LOG_FILTER_BATTLEGROUND, "setting oposite teamrating for team %u to %u", (*(itr_team[BG_TEAM_HORDE]))->ArenaTeamId, (*(itr_team[BG_TEAM_HORDE]))->OpponentsTeamRating);
+ aTeam->OpponentsTeamRating = hTeam->ArenaTeamRating;
+ hTeam->OpponentsTeamRating = aTeam->ArenaTeamRating;
+ aTeam->OpponentsMatchmakerRating = hTeam->ArenaMatchmakerRating;
+ hTeam->OpponentsMatchmakerRating = aTeam->ArenaMatchmakerRating;
+ sLog->outDebug(LOG_FILTER_BATTLEGROUND, "setting oposite teamrating for team %u to %u", aTeam->ArenaTeamId, aTeam->OpponentsTeamRating);
+ sLog->outDebug(LOG_FILTER_BATTLEGROUND, "setting oposite teamrating for team %u to %u", hTeam->ArenaTeamId, hTeam->OpponentsTeamRating);
+
// now we must move team if we changed its faction to another faction queue, because then we will spam log by errors in Queue::RemovePlayer
- if ((*(itr_team[BG_TEAM_ALLIANCE]))->Team != ALLIANCE)
+ if (aTeam->Team != ALLIANCE)
{
- // add to alliance queue
- m_QueuedGroups[bracket_id][BG_QUEUE_PREMADE_ALLIANCE].push_front(*(itr_team[BG_TEAM_ALLIANCE]));
- // erase from horde queue
- m_QueuedGroups[bracket_id][BG_QUEUE_PREMADE_HORDE].erase(itr_team[BG_TEAM_ALLIANCE]);
- itr_team[BG_TEAM_ALLIANCE] = m_QueuedGroups[bracket_id][BG_QUEUE_PREMADE_ALLIANCE].begin();
+ m_QueuedGroups[bracket_id][BG_QUEUE_PREMADE_ALLIANCE].push_front(aTeam);
+ m_QueuedGroups[bracket_id][BG_QUEUE_PREMADE_HORDE].erase(itr_teams[BG_TEAM_ALLIANCE]);
}
- if ((*(itr_team[BG_TEAM_HORDE]))->Team != HORDE)
+ if (hTeam->Team != HORDE)
{
- m_QueuedGroups[bracket_id][BG_QUEUE_PREMADE_HORDE].push_front(*(itr_team[BG_TEAM_HORDE]));
- m_QueuedGroups[bracket_id][BG_QUEUE_PREMADE_ALLIANCE].erase(itr_team[BG_TEAM_HORDE]);
- itr_team[BG_TEAM_HORDE] = m_QueuedGroups[bracket_id][BG_QUEUE_PREMADE_HORDE].begin();
+ m_QueuedGroups[bracket_id][BG_QUEUE_PREMADE_HORDE].push_front(hTeam);
+ m_QueuedGroups[bracket_id][BG_QUEUE_PREMADE_ALLIANCE].erase(itr_teams[BG_TEAM_HORDE]);
}
- arena->SetArenaMatchmakerRating(ALLIANCE, (*(itr_team[BG_TEAM_ALLIANCE]))->ArenaMatchmakerRating);
- arena->SetArenaMatchmakerRating(HORDE, (*(itr_team[BG_TEAM_HORDE]))->ArenaMatchmakerRating);
- InviteGroupToBG(*(itr_team[BG_TEAM_ALLIANCE]), arena, ALLIANCE);
- InviteGroupToBG(*(itr_team[BG_TEAM_HORDE]), arena, HORDE);
+ arena->SetArenaMatchmakerRating(ALLIANCE, aTeam->ArenaMatchmakerRating);
+ arena->SetArenaMatchmakerRating( HORDE, hTeam->ArenaMatchmakerRating);
+ InviteGroupToBG(aTeam, arena, ALLIANCE);
+ InviteGroupToBG(hTeam, arena, HORDE);
sLog->outDebug(LOG_FILTER_BATTLEGROUND, "Starting rated arena match!");
-
arena->StartBattleground();
}
}
@@ -1020,9 +999,9 @@ void BattlegroundQueue::BattlegroundQueueUpdate(uint32 diff, BattlegroundTypeId
bool BGQueueInviteEvent::Execute(uint64 /*e_time*/, uint32 /*p_time*/)
{
- Player* plr = ObjectAccessor::FindPlayer(m_PlayerGuid);
+ Player* player = ObjectAccessor::FindPlayer(m_PlayerGuid);
// player logged off (we should do nothing, he is correctly removed from queue in another procedure)
- if (!plr)
+ if (!player)
return true;
Battleground* bg = sBattlegroundMgr->GetBattleground(m_BgInstanceGUID, m_BgTypeId);
@@ -1031,7 +1010,7 @@ bool BGQueueInviteEvent::Execute(uint64 /*e_time*/, uint32 /*p_time*/)
return true;
BattlegroundQueueTypeId bgQueueTypeId = BattlegroundMgr::BGQueueTypeId(bg->GetTypeID(), bg->GetArenaType());
- uint32 queueSlot = plr->GetBattlegroundQueueIndex(bgQueueTypeId);
+ uint32 queueSlot = player->GetBattlegroundQueueIndex(bgQueueTypeId);
if (queueSlot < PLAYER_MAX_BATTLEGROUND_QUEUES) // player is in queue or in battleground
{
// check if player is invited to this bg
@@ -1041,7 +1020,7 @@ bool BGQueueInviteEvent::Execute(uint64 /*e_time*/, uint32 /*p_time*/)
WorldPacket data;
//we must send remaining time in queue
sBattlegroundMgr->BuildBattlegroundStatusPacket(&data, bg, queueSlot, STATUS_WAIT_JOIN, INVITE_ACCEPT_WAIT_TIME - INVITATION_REMIND_TIME, 0, m_ArenaType);
- plr->GetSession()->SendPacket(&data);
+ player->GetSession()->SendPacket(&data);
}
}
return true; //event will be deleted
@@ -1063,8 +1042,8 @@ void BGQueueInviteEvent::Abort(uint64 /*e_time*/)
*/
bool BGQueueRemoveEvent::Execute(uint64 /*e_time*/, uint32 /*p_time*/)
{
- Player* plr = ObjectAccessor::FindPlayer(m_PlayerGuid);
- if (!plr)
+ Player* player = ObjectAccessor::FindPlayer(m_PlayerGuid);
+ if (!player)
// player logged off (we should do nothing, he is correctly removed from queue in another procedure)
return true;
@@ -1072,16 +1051,16 @@ bool BGQueueRemoveEvent::Execute(uint64 /*e_time*/, uint32 /*p_time*/)
//battleground can be deleted already when we are removing queue info
//bg pointer can be NULL! so use it carefully!
- uint32 queueSlot = plr->GetBattlegroundQueueIndex(m_BgQueueTypeId);
+ uint32 queueSlot = player->GetBattlegroundQueueIndex(m_BgQueueTypeId);
if (queueSlot < PLAYER_MAX_BATTLEGROUND_QUEUES) // player is in queue, or in Battleground
{
// check if player is in queue for this BG and if we are removing his invite event
BattlegroundQueue &bgQueue = sBattlegroundMgr->m_BattlegroundQueues[m_BgQueueTypeId];
if (bgQueue.IsPlayerInvited(m_PlayerGuid, m_BgInstanceGUID, m_RemoveTime))
{
- sLog->outDebug(LOG_FILTER_BATTLEGROUND, "Battleground: removing player %u from bg queue for instance %u because of not pressing enter battle in time.", plr->GetGUIDLow(), m_BgInstanceGUID);
+ sLog->outDebug(LOG_FILTER_BATTLEGROUND, "Battleground: removing player %u from bg queue for instance %u because of not pressing enter battle in time.", player->GetGUIDLow(), m_BgInstanceGUID);
- plr->RemoveBattlegroundQueueId(m_BgQueueTypeId);
+ player->RemoveBattlegroundQueueId(m_BgQueueTypeId);
bgQueue.RemovePlayer(m_PlayerGuid, true);
//update queues if battleground isn't ended
if (bg && bg->isBattleground() && bg->GetStatus() != STATUS_WAIT_LEAVE)
@@ -1089,7 +1068,7 @@ bool BGQueueRemoveEvent::Execute(uint64 /*e_time*/, uint32 /*p_time*/)
WorldPacket data;
sBattlegroundMgr->BuildBattlegroundStatusPacket(&data, bg, queueSlot, STATUS_NONE, 0, 0, 0);
- plr->GetSession()->SendPacket(&data);
+ player->GetSession()->SendPacket(&data);
}
}
diff --git a/src/server/game/Battlegrounds/BattlegroundQueue.h b/src/server/game/Battlegrounds/BattlegroundQueue.h
index 10bff57a251..6b19c23ca68 100755
--- a/src/server/game/Battlegrounds/BattlegroundQueue.h
+++ b/src/server/game/Battlegrounds/BattlegroundQueue.h
@@ -103,6 +103,7 @@ class BattlegroundQueue
class SelectionPool
{
public:
+ SelectionPool(): PlayerCount(0) {};
void Init();
bool AddGroup(GroupQueueInfo* ginfo, uint32 desiredCount);
bool KickGroup(uint32 size);
diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundAA.cpp b/src/server/game/Battlegrounds/Zones/BattlegroundAA.cpp
index 7c7a6262c58..1e8973edf10 100755
--- a/src/server/game/Battlegrounds/Zones/BattlegroundAA.cpp
+++ b/src/server/game/Battlegrounds/Zones/BattlegroundAA.cpp
@@ -47,16 +47,16 @@ void BattlegroundAA::StartingEventOpenDoors()
{
}
-void BattlegroundAA::AddPlayer(Player* plr)
+void BattlegroundAA::AddPlayer(Player* player)
{
- Battleground::AddPlayer(plr);
+ Battleground::AddPlayer(player);
//create score and add it to map, default values are set in constructor
BattlegroundAAScore* sc = new BattlegroundAAScore;
- m_PlayerScores[plr->GetGUID()] = sc;
+ m_PlayerScores[player->GetGUID()] = sc;
}
-void BattlegroundAA::RemovePlayer(Player* /*plr*/, uint64 /*guid*/, uint32 /*team*/)
+void BattlegroundAA::RemovePlayer(Player* /*player*/, uint64 /*guid*/, uint32 /*team*/)
{
}
diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundAA.h b/src/server/game/Battlegrounds/Zones/BattlegroundAA.h
index 33e193bd4ef..bdf1ad7eedd 100755
--- a/src/server/game/Battlegrounds/Zones/BattlegroundAA.h
+++ b/src/server/game/Battlegrounds/Zones/BattlegroundAA.h
@@ -35,11 +35,11 @@ class BattlegroundAA : public Battleground
~BattlegroundAA();
/* inherited from BattlegroundClass */
- virtual void AddPlayer(Player* plr);
+ virtual void AddPlayer(Player* player);
virtual void StartingEventCloseDoors();
virtual void StartingEventOpenDoors();
- void RemovePlayer(Player* plr, uint64 guid, uint32 team);
+ void RemovePlayer(Player* player, uint64 guid, uint32 team);
void HandleAreaTrigger(Player* Source, uint32 Trigger);
bool SetupBattleground();
void HandleKillPlayer(Player* player, Player* killer);
diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundAB.cpp b/src/server/game/Battlegrounds/Zones/BattlegroundAB.cpp
index e2a39ff4666..028773c5229 100755
--- a/src/server/game/Battlegrounds/Zones/BattlegroundAB.cpp
+++ b/src/server/game/Battlegrounds/Zones/BattlegroundAB.cpp
@@ -204,16 +204,16 @@ void BattlegroundAB::StartingEventOpenDoors()
DoorOpen(BG_AB_OBJECT_GATE_H);
}
-void BattlegroundAB::AddPlayer(Player* plr)
+void BattlegroundAB::AddPlayer(Player* player)
{
- Battleground::AddPlayer(plr);
+ Battleground::AddPlayer(player);
//create score and add it to map, default values are set in the constructor
BattlegroundABScore* sc = new BattlegroundABScore;
- m_PlayerScores[plr->GetGUID()] = sc;
+ m_PlayerScores[player->GetGUID()] = sc;
}
-void BattlegroundAB::RemovePlayer(Player* /*plr*/, uint64 /*guid*/, uint32 /*team*/)
+void BattlegroundAB::RemovePlayer(Player* /*player*/, uint64 /*guid*/, uint32 /*team*/)
{
}
@@ -409,15 +409,15 @@ void BattlegroundAB::_NodeDeOccupied(uint8 node)
WorldSafeLocsEntry const* ClosestGrave = NULL;
for (std::vector<uint64>::const_iterator itr = ghost_list.begin(); itr != ghost_list.end(); ++itr)
{
- Player* plr = ObjectAccessor::FindPlayer(*itr);
- if (!plr)
+ Player* player = ObjectAccessor::FindPlayer(*itr);
+ if (!player)
continue;
if (!ClosestGrave) // cache
- ClosestGrave = GetClosestGraveYard(plr);
+ ClosestGrave = GetClosestGraveYard(player);
if (ClosestGrave)
- plr->TeleportTo(GetMapId(), ClosestGrave->x, ClosestGrave->y, ClosestGrave->z, plr->GetOrientation());
+ player->TeleportTo(GetMapId(), ClosestGrave->x, ClosestGrave->y, ClosestGrave->z, player->GetOrientation());
}
}
diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundAB.h b/src/server/game/Battlegrounds/Zones/BattlegroundAB.h
index c848c5f23f8..39f3727d68e 100755
--- a/src/server/game/Battlegrounds/Zones/BattlegroundAB.h
+++ b/src/server/game/Battlegrounds/Zones/BattlegroundAB.h
@@ -245,10 +245,10 @@ class BattlegroundAB : public Battleground
BattlegroundAB();
~BattlegroundAB();
- void AddPlayer(Player* plr);
+ void AddPlayer(Player* player);
virtual void StartingEventCloseDoors();
virtual void StartingEventOpenDoors();
- void RemovePlayer(Player* plr, uint64 guid, uint32 team);
+ void RemovePlayer(Player* player, uint64 guid, uint32 team);
void HandleAreaTrigger(Player* Source, uint32 Trigger);
virtual bool SetupBattleground();
virtual void Reset();
diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundAV.cpp b/src/server/game/Battlegrounds/Zones/BattlegroundAV.cpp
index a647a3c6299..fe570930870 100755
--- a/src/server/game/Battlegrounds/Zones/BattlegroundAV.cpp
+++ b/src/server/game/Battlegrounds/Zones/BattlegroundAV.cpp
@@ -422,14 +422,14 @@ void BattlegroundAV::StartingEventOpenDoors()
DoorOpen(BG_AV_OBJECT_DOOR_A);
}
-void BattlegroundAV::AddPlayer(Player* plr)
+void BattlegroundAV::AddPlayer(Player* player)
{
- Battleground::AddPlayer(plr);
+ Battleground::AddPlayer(player);
//create score and add it to map, default values are set in constructor
BattlegroundAVScore* sc = new BattlegroundAVScore;
- m_PlayerScores[plr->GetGUID()] = sc;
+ m_PlayerScores[player->GetGUID()] = sc;
if (m_MaxLevel == 0)
- m_MaxLevel=(plr->getLevel()%10 == 0)? plr->getLevel() : (plr->getLevel()-(plr->getLevel()%10))+10; //TODO: just look at the code \^_^/ --but queue-info should provide this information..
+ m_MaxLevel=(player->getLevel()%10 == 0)? player->getLevel() : (player->getLevel()-(player->getLevel()%10))+10; //TODO: just look at the code \^_^/ --but queue-info should provide this information..
}
@@ -473,17 +473,17 @@ void BattlegroundAV::EndBattleground(uint32 winner)
Battleground::EndBattleground(winner);
}
-void BattlegroundAV::RemovePlayer(Player* plr, uint64 /*guid*/, uint32 /*team*/)
+void BattlegroundAV::RemovePlayer(Player* player, uint64 /*guid*/, uint32 /*team*/)
{
- if (!plr)
+ if (!player)
{
sLog->outError("bg_AV no player at remove");
return;
}
//TODO search more buffs
- plr->RemoveAurasDueToSpell(AV_BUFF_ARMOR);
- plr->RemoveAurasDueToSpell(AV_BUFF_A_CAPTAIN);
- plr->RemoveAurasDueToSpell(AV_BUFF_H_CAPTAIN);
+ player->RemoveAurasDueToSpell(AV_BUFF_ARMOR);
+ player->RemoveAurasDueToSpell(AV_BUFF_A_CAPTAIN);
+ player->RemoveAurasDueToSpell(AV_BUFF_H_CAPTAIN);
}
void BattlegroundAV::HandleAreaTrigger(Player* Source, uint32 Trigger)
@@ -1029,17 +1029,17 @@ void BattlegroundAV::EventPlayerAssaultsPoint(Player* player, uint32 object)
std::vector<uint64> ghost_list = m_ReviveQueue[m_BgCreatures[node]];
if (!ghost_list.empty())
{
- Player* plr;
+ Player* player;
WorldSafeLocsEntry const* ClosestGrave = NULL;
for (std::vector<uint64>::iterator itr = ghost_list.begin(); itr != ghost_list.end(); ++itr)
{
- plr = ObjectAccessor::FindPlayer(*ghost_list.begin());
- if (!plr)
+ player = ObjectAccessor::FindPlayer(*ghost_list.begin());
+ if (!player)
continue;
if (!ClosestGrave)
- ClosestGrave = GetClosestGraveYard(plr);
+ ClosestGrave = GetClosestGraveYard(player);
else
- plr->TeleportTo(GetMapId(), ClosestGrave->x, ClosestGrave->y, ClosestGrave->z, plr->GetOrientation());
+ player->TeleportTo(GetMapId(), ClosestGrave->x, ClosestGrave->y, ClosestGrave->z, player->GetOrientation());
}
m_ReviveQueue[m_BgCreatures[node]].clear();
}
@@ -1348,23 +1348,23 @@ bool BattlegroundAV::SetupBattleground()
//creatures
sLog->outDebug(LOG_FILTER_BATTLEGROUND, "BG_AV start poputlating nodes");
- for (BG_AV_Nodes i = BG_AV_NODES_FIRSTAID_STATION; i < BG_AV_NODES_MAX; ++i)
+ for (i = BG_AV_NODES_FIRSTAID_STATION; i < BG_AV_NODES_MAX; ++i)
{
if (m_Nodes[i].Owner)
- PopulateNode(i);
+ PopulateNode(BG_AV_Nodes(i));
}
//all creatures which don't get despawned through the script are static
sLog->outDebug(LOG_FILTER_BATTLEGROUND, "BG_AV: start spawning static creatures");
- for (i=0; i < AV_STATICCPLACE_MAX; i++)
- AddAVCreature(0, i+AV_CPLACE_MAX);
+ for (i = 0; i < AV_STATICCPLACE_MAX; i++)
+ AddAVCreature(0, i + AV_CPLACE_MAX);
//mainspiritguides:
sLog->outDebug(LOG_FILTER_BATTLEGROUND, "BG_AV: start spawning spiritguides creatures");
AddSpiritGuide(7, BG_AV_CreaturePos[7][0], BG_AV_CreaturePos[7][1], BG_AV_CreaturePos[7][2], BG_AV_CreaturePos[7][3], ALLIANCE);
AddSpiritGuide(8, BG_AV_CreaturePos[8][0], BG_AV_CreaturePos[8][1], BG_AV_CreaturePos[8][2], BG_AV_CreaturePos[8][3], HORDE);
//spawn the marshals (those who get deleted, if a tower gets destroyed)
sLog->outDebug(LOG_FILTER_BATTLEGROUND, "BG_AV: start spawning marshal creatures");
- for (i=AV_NPC_A_MARSHAL_SOUTH; i <= AV_NPC_H_MARSHAL_WTOWER; i++)
- AddAVCreature(i, AV_CPLACE_A_MARSHAL_SOUTH+(i-AV_NPC_A_MARSHAL_SOUTH));
+ for (i = AV_NPC_A_MARSHAL_SOUTH; i <= AV_NPC_H_MARSHAL_WTOWER; i++)
+ AddAVCreature(i, AV_CPLACE_A_MARSHAL_SOUTH + (i - AV_NPC_A_MARSHAL_SOUTH));
AddAVCreature(AV_NPC_HERALD, AV_CPLACE_HERALD);
return true;
}
diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundAV.h b/src/server/game/Battlegrounds/Zones/BattlegroundAV.h
index 3ae1f52a4f9..2c8ffc0cf72 100755
--- a/src/server/game/Battlegrounds/Zones/BattlegroundAV.h
+++ b/src/server/game/Battlegrounds/Zones/BattlegroundAV.h
@@ -1539,11 +1539,11 @@ class BattlegroundAV : public Battleground
~BattlegroundAV();
/* inherited from BattlegroundClass */
- virtual void AddPlayer(Player* plr);
+ virtual void AddPlayer(Player* player);
virtual void StartingEventCloseDoors();
virtual void StartingEventOpenDoors();
- void RemovePlayer(Player* plr, uint64 guid, uint32 team);
+ void RemovePlayer(Player* player, uint64 guid, uint32 team);
void HandleAreaTrigger(Player* Source, uint32 Trigger);
bool SetupBattleground();
virtual void ResetBGSubclass();
diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundBE.cpp b/src/server/game/Battlegrounds/Zones/BattlegroundBE.cpp
index 1db59547d92..88b9aa6184e 100755
--- a/src/server/game/Battlegrounds/Zones/BattlegroundBE.cpp
+++ b/src/server/game/Battlegrounds/Zones/BattlegroundBE.cpp
@@ -62,18 +62,18 @@ void BattlegroundBE::StartingEventOpenDoors()
SpawnBGObject(i, 60);
}
-void BattlegroundBE::AddPlayer(Player* plr)
+void BattlegroundBE::AddPlayer(Player* player)
{
- Battleground::AddPlayer(plr);
+ Battleground::AddPlayer(player);
//create score and add it to map, default values are set in constructor
BattlegroundBEScore* sc = new BattlegroundBEScore;
- m_PlayerScores[plr->GetGUID()] = sc;
+ m_PlayerScores[player->GetGUID()] = sc;
UpdateArenaWorldState();
}
-void BattlegroundBE::RemovePlayer(Player* /*plr*/, uint64 /*guid*/, uint32 /*team*/)
+void BattlegroundBE::RemovePlayer(Player* /*player*/, uint64 /*guid*/, uint32 /*team*/)
{
if (GetStatus() == STATUS_WAIT_LEAVE)
return;
diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundBE.h b/src/server/game/Battlegrounds/Zones/BattlegroundBE.h
index 13aef8f561b..1b4fa8ebd64 100755
--- a/src/server/game/Battlegrounds/Zones/BattlegroundBE.h
+++ b/src/server/game/Battlegrounds/Zones/BattlegroundBE.h
@@ -55,17 +55,17 @@ class BattlegroundBE : public Battleground
~BattlegroundBE();
/* inherited from BattlegroundClass */
- virtual void AddPlayer(Player* plr);
+ virtual void AddPlayer(Player* player);
virtual void StartingEventCloseDoors();
virtual void StartingEventOpenDoors();
- void RemovePlayer(Player* plr, uint64 guid, uint32 team);
+ void RemovePlayer(Player* player, uint64 guid, uint32 team);
void HandleAreaTrigger(Player* Source, uint32 Trigger);
bool SetupBattleground();
virtual void Reset();
virtual void FillInitialWorldStates(WorldPacket &d);
void HandleKillPlayer(Player* player, Player* killer);
- bool HandlePlayerUnderMap(Player* plr);
+ bool HandlePlayerUnderMap(Player* player);
/* Scorekeeping */
void UpdatePlayerScore(Player* Source, uint32 type, uint32 value, bool doAddHonor = true);
diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundDS.cpp b/src/server/game/Battlegrounds/Zones/BattlegroundDS.cpp
index 6fb07ebb678..754005f3f33 100755
--- a/src/server/game/Battlegrounds/Zones/BattlegroundDS.cpp
+++ b/src/server/game/Battlegrounds/Zones/BattlegroundDS.cpp
@@ -88,18 +88,18 @@ void BattlegroundDS::StartingEventOpenDoors()
SpawnBGObject(i, getWaterFallTimer());
}
-void BattlegroundDS::AddPlayer(Player* plr)
+void BattlegroundDS::AddPlayer(Player* player)
{
- Battleground::AddPlayer(plr);
+ Battleground::AddPlayer(player);
//create score and add it to map, default values are set in constructor
BattlegroundDSScore* sc = new BattlegroundDSScore;
- m_PlayerScores[plr->GetGUID()] = sc;
+ m_PlayerScores[player->GetGUID()] = sc;
UpdateArenaWorldState();
}
-void BattlegroundDS::RemovePlayer(Player* /*plr*/, uint64 /*guid*/, uint32 /*team*/)
+void BattlegroundDS::RemovePlayer(Player* /*player*/, uint64 /*guid*/, uint32 /*team*/)
{
if (GetStatus() == STATUS_WAIT_LEAVE)
return;
diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundDS.h b/src/server/game/Battlegrounds/Zones/BattlegroundDS.h
index e5b2d613810..625eb1c7533 100755
--- a/src/server/game/Battlegrounds/Zones/BattlegroundDS.h
+++ b/src/server/game/Battlegrounds/Zones/BattlegroundDS.h
@@ -64,17 +64,17 @@ class BattlegroundDS : public Battleground
~BattlegroundDS();
/* inherited from BattlegroundClass */
- virtual void AddPlayer(Player* plr);
+ virtual void AddPlayer(Player* player);
virtual void StartingEventCloseDoors();
virtual void StartingEventOpenDoors();
- void RemovePlayer(Player* plr, uint64 guid, uint32 team);
+ void RemovePlayer(Player* player, uint64 guid, uint32 team);
void HandleAreaTrigger(Player* Source, uint32 Trigger);
bool SetupBattleground();
virtual void Reset();
virtual void FillInitialWorldStates(WorldPacket &d);
void HandleKillPlayer(Player* player, Player* killer);
- bool HandlePlayerUnderMap(Player* plr);
+ bool HandlePlayerUnderMap(Player* player);
private:
uint32 m_waterTimer;
bool m_waterfallActive;
diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundEY.cpp b/src/server/game/Battlegrounds/Zones/BattlegroundEY.cpp
index 8c5b0468aca..c790d64e986 100755
--- a/src/server/game/Battlegrounds/Zones/BattlegroundEY.cpp
+++ b/src/server/game/Battlegrounds/Zones/BattlegroundEY.cpp
@@ -146,20 +146,20 @@ void BattlegroundEY::CheckSomeoneJoinedPoint()
uint8 j = 0;
while (j < m_PlayersNearPoint[EY_POINTS_MAX].size())
{
- Player* plr = ObjectAccessor::FindPlayer(m_PlayersNearPoint[EY_POINTS_MAX][j]);
- if (!plr)
+ Player* player = ObjectAccessor::FindPlayer(m_PlayersNearPoint[EY_POINTS_MAX][j]);
+ if (!player)
{
sLog->outError("BattlegroundEY:CheckSomeoneJoinedPoint: Player (GUID: %u) not found!", GUID_LOPART(m_PlayersNearPoint[EY_POINTS_MAX][j]));
++j;
continue;
}
- if (plr->CanCaptureTowerPoint() && plr->IsWithinDistInMap(obj, BG_EY_POINT_RADIUS))
+ if (player->CanCaptureTowerPoint() && player->IsWithinDistInMap(obj, BG_EY_POINT_RADIUS))
{
//player joined point!
//show progress bar
- UpdateWorldStateForPlayer(PROGRESS_BAR_PERCENT_GREY, BG_EY_PROGRESS_BAR_PERCENT_GREY, plr);
- UpdateWorldStateForPlayer(PROGRESS_BAR_STATUS, m_PointBarStatus[i], plr);
- UpdateWorldStateForPlayer(PROGRESS_BAR_SHOW, BG_EY_PROGRESS_BAR_SHOW, plr);
+ UpdateWorldStateForPlayer(PROGRESS_BAR_PERCENT_GREY, BG_EY_PROGRESS_BAR_PERCENT_GREY, player);
+ UpdateWorldStateForPlayer(PROGRESS_BAR_STATUS, m_PointBarStatus[i], player);
+ UpdateWorldStateForPlayer(PROGRESS_BAR_SHOW, BG_EY_PROGRESS_BAR_SHOW, player);
//add player to point
m_PlayersNearPoint[i].push_back(m_PlayersNearPoint[EY_POINTS_MAX][j]);
//remove player from "free space"
@@ -186,8 +186,8 @@ void BattlegroundEY::CheckSomeoneLeftPoint()
uint8 j = 0;
while (j < m_PlayersNearPoint[i].size())
{
- Player* plr = ObjectAccessor::FindPlayer(m_PlayersNearPoint[i][j]);
- if (!plr)
+ Player* player = ObjectAccessor::FindPlayer(m_PlayersNearPoint[i][j]);
+ if (!player)
{
sLog->outError("BattlegroundEY:CheckSomeoneLeftPoint Player (GUID: %u) not found!", GUID_LOPART(m_PlayersNearPoint[i][j]));
//move not existed player to "free space" - this will cause many error showing in log, but it is a very important bug
@@ -196,17 +196,17 @@ void BattlegroundEY::CheckSomeoneLeftPoint()
++j;
continue;
}
- if (!plr->CanCaptureTowerPoint() || !plr->IsWithinDistInMap(obj, BG_EY_POINT_RADIUS))
+ if (!player->CanCaptureTowerPoint() || !player->IsWithinDistInMap(obj, BG_EY_POINT_RADIUS))
//move player out of point (add him to players that are out of points
{
m_PlayersNearPoint[EY_POINTS_MAX].push_back(m_PlayersNearPoint[i][j]);
m_PlayersNearPoint[i].erase(m_PlayersNearPoint[i].begin() + j);
- this->UpdateWorldStateForPlayer(PROGRESS_BAR_SHOW, BG_EY_PROGRESS_BAR_DONT_SHOW, plr);
+ this->UpdateWorldStateForPlayer(PROGRESS_BAR_SHOW, BG_EY_PROGRESS_BAR_DONT_SHOW, player);
}
else
{
//player is neat flag, so update count:
- m_CurrentPointPlayersCount[2 * i + GetTeamIndexByTeamId(plr->GetTeam())]++;
+ m_CurrentPointPlayersCount[2 * i + GetTeamIndexByTeamId(player->GetTeam())]++;
++j;
}
}
@@ -241,20 +241,20 @@ void BattlegroundEY::UpdatePointStatuses()
for (uint8 i = 0; i < m_PlayersNearPoint[point].size(); ++i)
{
- Player* plr = ObjectAccessor::FindPlayer(m_PlayersNearPoint[point][i]);
- if (plr)
+ Player* player = ObjectAccessor::FindPlayer(m_PlayersNearPoint[point][i]);
+ if (player)
{
- this->UpdateWorldStateForPlayer(PROGRESS_BAR_STATUS, m_PointBarStatus[point], plr);
+ this->UpdateWorldStateForPlayer(PROGRESS_BAR_STATUS, m_PointBarStatus[point], player);
//if point owner changed we must evoke event!
if (pointOwnerTeamId != m_PointOwnedByTeam[point])
{
//point was uncontrolled and player is from team which captured point
- if (m_PointState[point] == EY_POINT_STATE_UNCONTROLLED && plr->GetTeam() == pointOwnerTeamId)
- this->EventTeamCapturedPoint(plr, point);
+ if (m_PointState[point] == EY_POINT_STATE_UNCONTROLLED && player->GetTeam() == pointOwnerTeamId)
+ this->EventTeamCapturedPoint(player, point);
//point was under control and player isn't from team which controlled it
- if (m_PointState[point] == EY_POINT_UNDER_CONTROL && plr->GetTeam() != m_PointOwnedByTeam[point])
- this->EventTeamLostPoint(plr, point);
+ if (m_PointState[point] == EY_POINT_UNDER_CONTROL && player->GetTeam() != m_PointOwnedByTeam[point])
+ this->EventTeamLostPoint(player, point);
}
}
}
@@ -330,18 +330,18 @@ void BattlegroundEY::UpdatePointsIcons(uint32 Team, uint32 Point)
}
}
-void BattlegroundEY::AddPlayer(Player* plr)
+void BattlegroundEY::AddPlayer(Player* player)
{
- Battleground::AddPlayer(plr);
+ Battleground::AddPlayer(player);
//create score and add it to map
BattlegroundEYScore* sc = new BattlegroundEYScore;
- m_PlayersNearPoint[EY_POINTS_MAX].push_back(plr->GetGUID());
+ m_PlayersNearPoint[EY_POINTS_MAX].push_back(player->GetGUID());
- m_PlayerScores[plr->GetGUID()] = sc;
+ m_PlayerScores[player->GetGUID()] = sc;
}
-void BattlegroundEY::RemovePlayer(Player* plr, uint64 guid, uint32 /*team*/)
+void BattlegroundEY::RemovePlayer(Player* player, uint64 guid, uint32 /*team*/)
{
// sometimes flag aura not removed :(
for (int j = EY_POINTS_MAX; j >= 0; --j)
@@ -354,8 +354,8 @@ void BattlegroundEY::RemovePlayer(Player* plr, uint64 guid, uint32 /*team*/)
{
if (m_FlagKeeper == guid)
{
- if (plr)
- EventPlayerDroppedFlag(plr);
+ if (player)
+ EventPlayerDroppedFlag(player);
else
{
SetFlagPicker(0);
diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundEY.h b/src/server/game/Battlegrounds/Zones/BattlegroundEY.h
index fdb81491771..aba5754752a 100755
--- a/src/server/game/Battlegrounds/Zones/BattlegroundEY.h
+++ b/src/server/game/Battlegrounds/Zones/BattlegroundEY.h
@@ -336,7 +336,7 @@ class BattlegroundEY : public Battleground
~BattlegroundEY();
/* inherited from BattlegroundClass */
- virtual void AddPlayer(Player* plr);
+ virtual void AddPlayer(Player* player);
virtual void StartingEventCloseDoors();
virtual void StartingEventOpenDoors();
@@ -348,7 +348,7 @@ class BattlegroundEY : public Battleground
void RespawnFlag(bool send_message);
void RespawnFlagAfterDrop();
- void RemovePlayer(Player* plr, uint64 guid, uint32 team);
+ void RemovePlayer(Player* player, uint64 guid, uint32 team);
void HandleBuffUse(uint64 buff_guid);
void HandleAreaTrigger(Player* Source, uint32 Trigger);
void HandleKillPlayer(Player* player, Player* killer);
diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundIC.cpp b/src/server/game/Battlegrounds/Zones/BattlegroundIC.cpp
index b00e8dac1d8..f17df3aaf67 100755
--- a/src/server/game/Battlegrounds/Zones/BattlegroundIC.cpp
+++ b/src/server/game/Battlegrounds/Zones/BattlegroundIC.cpp
@@ -90,22 +90,22 @@ void BattlegroundIC::DoAction(uint32 action, uint64 var)
if (action != ACTION_TELEPORT_PLAYER_TO_TRANSPORT)
return;
- Player* plr = ObjectAccessor::FindPlayer(var);
+ Player* player = ObjectAccessor::FindPlayer(var);
- if (!plr || !gunshipAlliance || !gunshipHorde)
+ if (!player || !gunshipAlliance || !gunshipHorde)
return;
- plr->CastSpell(plr, SPELL_PARACHUTE, true); // this must be changed, there is a trigger in each transport that casts the spell.
- plr->CastSpell(plr, SPELL_SLOW_FALL, true);
+ player->CastSpell(player, SPELL_PARACHUTE, true); // this must be changed, there is a trigger in each transport that casts the spell.
+ player->CastSpell(player, SPELL_SLOW_FALL, true);
- plr->SetTransport(plr->GetTeamId() == TEAM_ALLIANCE ? gunshipAlliance : gunshipHorde);
+ player->SetTransport(player->GetTeamId() == TEAM_ALLIANCE ? gunshipAlliance : gunshipHorde);
- plr->m_movementInfo.t_pos.m_positionX = TransportMovementInfo.GetPositionX();
- plr->m_movementInfo.t_pos.m_positionY = TransportMovementInfo.GetPositionY();
- plr->m_movementInfo.t_pos.m_positionZ = TransportMovementInfo.GetPositionZ();
- plr->m_movementInfo.t_guid = (plr->GetTeamId() == TEAM_ALLIANCE ? gunshipAlliance : gunshipHorde)->GetGUID();
+ player->m_movementInfo.t_pos.m_positionX = TransportMovementInfo.GetPositionX();
+ player->m_movementInfo.t_pos.m_positionY = TransportMovementInfo.GetPositionY();
+ player->m_movementInfo.t_pos.m_positionZ = TransportMovementInfo.GetPositionZ();
+ player->m_movementInfo.t_guid = (player->GetTeamId() == TEAM_ALLIANCE ? gunshipAlliance : gunshipHorde)->GetGUID();
- plr->TeleportTo(GetMapId(), TeleportToTransportPosition.GetPositionX(), TeleportToTransportPosition.GetPositionY(), TeleportToTransportPosition.GetPositionZ(), TeleportToTransportPosition.GetOrientation(), TELE_TO_NOT_LEAVE_TRANSPORT);
+ player->TeleportTo(GetMapId(), TeleportToTransportPosition.GetPositionX(), TeleportToTransportPosition.GetPositionY(), TeleportToTransportPosition.GetPositionZ(), TeleportToTransportPosition.GetOrientation(), TELE_TO_NOT_LEAVE_TRANSPORT);
}
void BattlegroundIC::PostUpdateImpl(uint32 diff)
@@ -135,7 +135,7 @@ void BattlegroundIC::PostUpdateImpl(uint32 diff)
if (nodePoint[i].nodeState == NODE_STATE_CONTROLLED_A ||
nodePoint[i].nodeState == NODE_STATE_CONTROLLED_H)
{
- if (nodePoint[i].timer <= diff)
+ if (docksTimer <= diff)
{
// we need to confirm this, i am not sure if this every 3 minutes
for (uint8 u = (nodePoint[i].faction == TEAM_ALLIANCE ? BG_IC_NPC_CATAPULT_1_A : BG_IC_NPC_CATAPULT_1_H); u < (nodePoint[i].faction == TEAM_ALLIANCE ? BG_IC_NPC_CATAPULT_4_A : BG_IC_NPC_CATAPULT_4_H); u++)
@@ -158,7 +158,7 @@ void BattlegroundIC::PostUpdateImpl(uint32 diff)
}
docksTimer = DOCKS_UPDATE_TIME;
- } else nodePoint[i].timer -= diff;
+ } else docksTimer -= diff;
}
}
@@ -292,29 +292,29 @@ bool BattlegroundIC::IsAllNodesConrolledByTeam(uint32 team) const
return count == NODE_TYPE_WORKSHOP;
}
-void BattlegroundIC::AddPlayer(Player* plr)
+void BattlegroundIC::AddPlayer(Player* player)
{
- Battleground::AddPlayer(plr);
+ Battleground::AddPlayer(player);
//create score and add it to map, default values are set in constructor
BattlegroundICScore* sc = new BattlegroundICScore;
- m_PlayerScores[plr->GetGUID()] = sc;
+ m_PlayerScores[player->GetGUID()] = sc;
- if (nodePoint[NODE_TYPE_QUARRY].nodeState == (plr->GetTeamId() == TEAM_ALLIANCE ? NODE_STATE_CONTROLLED_A : NODE_STATE_CONTROLLED_H))
- plr->CastSpell(plr, SPELL_QUARRY, true);
+ if (nodePoint[NODE_TYPE_QUARRY].nodeState == (player->GetTeamId() == TEAM_ALLIANCE ? NODE_STATE_CONTROLLED_A : NODE_STATE_CONTROLLED_H))
+ player->CastSpell(player, SPELL_QUARRY, true);
- if (nodePoint[NODE_TYPE_REFINERY].nodeState == (plr->GetTeamId() == TEAM_ALLIANCE ? NODE_STATE_CONTROLLED_A : NODE_STATE_CONTROLLED_H))
- plr->CastSpell(plr, SPELL_OIL_REFINERY, true);
+ if (nodePoint[NODE_TYPE_REFINERY].nodeState == (player->GetTeamId() == TEAM_ALLIANCE ? NODE_STATE_CONTROLLED_A : NODE_STATE_CONTROLLED_H))
+ player->CastSpell(player, SPELL_OIL_REFINERY, true);
- SendTransportInit(plr);
+ SendTransportInit(player);
}
-void BattlegroundIC::RemovePlayer(Player* plr, uint64 /*guid*/, uint32 /*team*/)
+void BattlegroundIC::RemovePlayer(Player* player, uint64 /*guid*/, uint32 /*team*/)
{
- if (plr)
+ if (player)
{
- plr->RemoveAura(SPELL_QUARRY);
- plr->RemoveAura(SPELL_OIL_REFINERY);
+ player->RemoveAura(SPELL_QUARRY);
+ player->RemoveAura(SPELL_OIL_REFINERY);
}
}
@@ -482,15 +482,15 @@ void BattlegroundIC::RealocatePlayers(ICNodePointType nodeType)
WorldSafeLocsEntry const* ClosestGrave = NULL;
for (std::vector<uint64>::const_iterator itr = ghost_list.begin(); itr != ghost_list.end(); ++itr)
{
- Player* plr = ObjectAccessor::FindPlayer(*itr);
- if (!plr)
+ Player* player = ObjectAccessor::FindPlayer(*itr);
+ if (!player)
continue;
if (!ClosestGrave) // cache
- ClosestGrave = GetClosestGraveYard(plr);
+ ClosestGrave = GetClosestGraveYard(player);
if (ClosestGrave)
- plr->TeleportTo(GetMapId(), ClosestGrave->x, ClosestGrave->y, ClosestGrave->z, plr->GetOrientation());
+ player->TeleportTo(GetMapId(), ClosestGrave->x, ClosestGrave->y, ClosestGrave->z, player->GetOrientation());
}
}
}
@@ -644,178 +644,178 @@ void BattlegroundIC::HandleCapturedNodes(ICNodePoint* nodePoint, bool recapture)
switch (nodePoint->gameobject_type)
{
- case BG_IC_GO_HANGAR_BANNER:
- // all the players on the stopped transport should be teleported out
- if (!gunshipAlliance || !gunshipHorde)
- break;
+ case BG_IC_GO_HANGAR_BANNER:
+ // all the players on the stopped transport should be teleported out
+ if (!gunshipAlliance || !gunshipHorde)
+ break;
- for (uint8 u = 0; u < MAX_HANGAR_TELEPORTERS_SPAWNS; u++)
- {
- uint8 type = BG_IC_GO_HANGAR_TELEPORTER_1+u;
- AddObject(type, (nodePoint->faction == TEAM_ALLIANCE ? GO_ALLIANCE_GUNSHIP_PORTAL : GO_HORDE_GUNSHIP_PORTAL),
- BG_IC_HangarTeleporters[u].GetPositionX(), BG_IC_HangarTeleporters[u].GetPositionY(),
- BG_IC_HangarTeleporters[u].GetPositionZ(), BG_IC_HangarTeleporters[u].GetOrientation(),
- 0, 0, 0, 0, RESPAWN_ONE_DAY);
- }
-
- //sLog->outError("BG_IC_GO_HANGAR_BANNER CAPTURED Faction: %u", nodePoint->faction);
+ for (uint8 u = 0; u < MAX_HANGAR_TELEPORTERS_SPAWNS; u++)
+ {
+ uint8 type = BG_IC_GO_HANGAR_TELEPORTER_1+u;
+ AddObject(type, (nodePoint->faction == TEAM_ALLIANCE ? GO_ALLIANCE_GUNSHIP_PORTAL : GO_HORDE_GUNSHIP_PORTAL),
+ BG_IC_HangarTeleporters[u].GetPositionX(), BG_IC_HangarTeleporters[u].GetPositionY(),
+ BG_IC_HangarTeleporters[u].GetPositionZ(), BG_IC_HangarTeleporters[u].GetOrientation(),
+ 0, 0, 0, 0, RESPAWN_ONE_DAY);
+ }
- (nodePoint->faction == TEAM_ALLIANCE ? gunshipAlliance : gunshipHorde)->BuildStartMovePacket(GetBgMap());
- (nodePoint->faction == TEAM_ALLIANCE ? gunshipHorde : gunshipAlliance)->BuildStopMovePacket(GetBgMap());
- // we should spawn teleporters
- break;
- case BG_IC_GO_QUARRY_BANNER:
- RemoveAuraOnTeam(SPELL_QUARRY, (nodePoint->faction == TEAM_ALLIANCE ? HORDE : ALLIANCE));
- CastSpellOnTeam(SPELL_QUARRY, (nodePoint->faction == TEAM_ALLIANCE ? ALLIANCE : HORDE));
- break;
- case BG_IC_GO_REFINERY_BANNER:
- RemoveAuraOnTeam(SPELL_OIL_REFINERY, (nodePoint->faction == TEAM_ALLIANCE ? HORDE : ALLIANCE));
- CastSpellOnTeam(SPELL_OIL_REFINERY, (nodePoint->faction == TEAM_ALLIANCE ? ALLIANCE : HORDE));
- break;
- case BG_IC_GO_DOCKS_BANNER:
+ //sLog->outError("BG_IC_GO_HANGAR_BANNER CAPTURED Faction: %u", nodePoint->faction);
- if (recapture)
+ (nodePoint->faction == TEAM_ALLIANCE ? gunshipAlliance : gunshipHorde)->BuildStartMovePacket(GetBgMap());
+ (nodePoint->faction == TEAM_ALLIANCE ? gunshipHorde : gunshipAlliance)->BuildStopMovePacket(GetBgMap());
+ // we should spawn teleporters
break;
+ case BG_IC_GO_QUARRY_BANNER:
+ RemoveAuraOnTeam(SPELL_QUARRY, (nodePoint->faction == TEAM_ALLIANCE ? HORDE : ALLIANCE));
+ CastSpellOnTeam(SPELL_QUARRY, (nodePoint->faction == TEAM_ALLIANCE ? ALLIANCE : HORDE));
+ break;
+ case BG_IC_GO_REFINERY_BANNER:
+ RemoveAuraOnTeam(SPELL_OIL_REFINERY, (nodePoint->faction == TEAM_ALLIANCE ? HORDE : ALLIANCE));
+ CastSpellOnTeam(SPELL_OIL_REFINERY, (nodePoint->faction == TEAM_ALLIANCE ? ALLIANCE : HORDE));
+ break;
+ case BG_IC_GO_DOCKS_BANNER:
- if (docksTimer < DOCKS_UPDATE_TIME)
- docksTimer = DOCKS_UPDATE_TIME;
+ if (recapture)
+ break;
- // we must del opposing faction vehicles when the node is captured (unused ones)
- for (uint8 i = (nodePoint->faction == TEAM_ALLIANCE ? BG_IC_NPC_GLAIVE_THROWER_1_H : BG_IC_NPC_GLAIVE_THROWER_1_A); i < (nodePoint->faction == TEAM_ALLIANCE ? BG_IC_NPC_GLAIVE_THROWER_2_H : BG_IC_NPC_GLAIVE_THROWER_2_A); i++)
- {
- if (Creature* glaiveThrower = GetBGCreature(i))
+ if (docksTimer < DOCKS_UPDATE_TIME)
+ docksTimer = DOCKS_UPDATE_TIME;
+
+ // we must del opposing faction vehicles when the node is captured (unused ones)
+ for (uint8 i = (nodePoint->faction == TEAM_ALLIANCE ? BG_IC_NPC_GLAIVE_THROWER_1_H : BG_IC_NPC_GLAIVE_THROWER_1_A); i < (nodePoint->faction == TEAM_ALLIANCE ? BG_IC_NPC_GLAIVE_THROWER_2_H : BG_IC_NPC_GLAIVE_THROWER_2_A); i++)
{
- if (Vehicle* vehicleGlaive = glaiveThrower->GetVehicleKit())
+ if (Creature* glaiveThrower = GetBGCreature(i))
{
- if (!vehicleGlaive->GetPassenger(0))
- DelCreature(i);
+ if (Vehicle* vehicleGlaive = glaiveThrower->GetVehicleKit())
+ {
+ if (!vehicleGlaive->GetPassenger(0))
+ DelCreature(i);
+ }
}
}
- }
- for (uint8 i = (nodePoint->faction == TEAM_ALLIANCE ? BG_IC_NPC_CATAPULT_1_H : BG_IC_NPC_CATAPULT_1_A); i < (nodePoint->faction == TEAM_ALLIANCE ? BG_IC_NPC_CATAPULT_4_H : BG_IC_NPC_CATAPULT_4_A); i++)
- {
- if (Creature* catapult = GetBGCreature(i))
+ for (uint8 i = (nodePoint->faction == TEAM_ALLIANCE ? BG_IC_NPC_CATAPULT_1_H : BG_IC_NPC_CATAPULT_1_A); i < (nodePoint->faction == TEAM_ALLIANCE ? BG_IC_NPC_CATAPULT_4_H : BG_IC_NPC_CATAPULT_4_A); i++)
{
- if (Vehicle* vehicleGlaive = catapult->GetVehicleKit())
+ if (Creature* catapult = GetBGCreature(i))
{
- if (!vehicleGlaive->GetPassenger(0))
- DelCreature(i);
+ if (Vehicle* vehicleGlaive = catapult->GetVehicleKit())
+ {
+ if (!vehicleGlaive->GetPassenger(0))
+ DelCreature(i);
+ }
}
}
- }
- // spawning glaive throwers
- for (uint8 i = 0; i < MAX_GLAIVE_THROWERS_SPAWNS_PER_FACTION; i++)
- {
- uint8 type = (nodePoint->faction == TEAM_ALLIANCE ? BG_IC_NPC_GLAIVE_THROWER_1_A : BG_IC_NPC_GLAIVE_THROWER_1_H)+i;
+ // spawning glaive throwers
+ for (uint8 i = 0; i < MAX_GLAIVE_THROWERS_SPAWNS_PER_FACTION; i++)
+ {
+ uint8 type = (nodePoint->faction == TEAM_ALLIANCE ? BG_IC_NPC_GLAIVE_THROWER_1_A : BG_IC_NPC_GLAIVE_THROWER_1_H)+i;
- if (GetBGCreature(type) && GetBGCreature(type)->isAlive())
- continue;
+ if (GetBGCreature(type) && GetBGCreature(type)->isAlive())
+ continue;
- if (AddCreature(nodePoint->faction == TEAM_ALLIANCE ? NPC_GLAIVE_THROWER_A : NPC_GLAIVE_THROWER_H, type, nodePoint->faction,
- BG_IC_DocksVehiclesGlaives[i].GetPositionX(), BG_IC_DocksVehiclesGlaives[i].GetPositionY(),
- BG_IC_DocksVehiclesGlaives[i].GetPositionZ(), BG_IC_DocksVehiclesGlaives[i].GetOrientation(),
- RESPAWN_ONE_DAY))
- GetBGCreature(type)->setFaction(BG_IC_Factions[(nodePoint->faction == TEAM_ALLIANCE ? 0 : 1)]);
- }
+ if (AddCreature(nodePoint->faction == TEAM_ALLIANCE ? NPC_GLAIVE_THROWER_A : NPC_GLAIVE_THROWER_H, type, nodePoint->faction,
+ BG_IC_DocksVehiclesGlaives[i].GetPositionX(), BG_IC_DocksVehiclesGlaives[i].GetPositionY(),
+ BG_IC_DocksVehiclesGlaives[i].GetPositionZ(), BG_IC_DocksVehiclesGlaives[i].GetOrientation(),
+ RESPAWN_ONE_DAY))
+ GetBGCreature(type)->setFaction(BG_IC_Factions[(nodePoint->faction == TEAM_ALLIANCE ? 0 : 1)]);
+ }
- // spawning catapults
- for (uint8 i = 0; i < MAX_CATAPULTS_SPAWNS_PER_FACTION; i++)
- {
- uint8 type = (nodePoint->faction == TEAM_ALLIANCE ? BG_IC_NPC_CATAPULT_1_A : BG_IC_NPC_CATAPULT_1_H)+i;
+ // spawning catapults
+ for (uint8 i = 0; i < MAX_CATAPULTS_SPAWNS_PER_FACTION; i++)
+ {
+ uint8 type = (nodePoint->faction == TEAM_ALLIANCE ? BG_IC_NPC_CATAPULT_1_A : BG_IC_NPC_CATAPULT_1_H)+i;
- if (GetBGCreature(type) && GetBGCreature(type)->isAlive())
- continue;
+ if (GetBGCreature(type) && GetBGCreature(type)->isAlive())
+ continue;
- if (AddCreature(NPC_CATAPULT, type, nodePoint->faction,
- BG_IC_DocksVehiclesCatapults[i].GetPositionX(), BG_IC_DocksVehiclesCatapults[i].GetPositionY(),
- BG_IC_DocksVehiclesCatapults[i].GetPositionZ(), BG_IC_DocksVehiclesCatapults[i].GetOrientation(),
- RESPAWN_ONE_DAY))
- GetBGCreature(type)->setFaction(BG_IC_Factions[(nodePoint->faction == TEAM_ALLIANCE ? 0 : 1)]);
- }
- break;
- case BG_IC_GO_WORKSHOP_BANNER:
- {
- if (siegeEngineWorkshopTimer < WORKSHOP_UPDATE_TIME)
- siegeEngineWorkshopTimer = WORKSHOP_UPDATE_TIME;
-
- if (!recapture)
+ if (AddCreature(NPC_CATAPULT, type, nodePoint->faction,
+ BG_IC_DocksVehiclesCatapults[i].GetPositionX(), BG_IC_DocksVehiclesCatapults[i].GetPositionY(),
+ BG_IC_DocksVehiclesCatapults[i].GetPositionZ(), BG_IC_DocksVehiclesCatapults[i].GetOrientation(),
+ RESPAWN_ONE_DAY))
+ GetBGCreature(type)->setFaction(BG_IC_Factions[(nodePoint->faction == TEAM_ALLIANCE ? 0 : 1)]);
+ }
+ break;
+ case BG_IC_GO_WORKSHOP_BANNER:
{
- // we must del opposing faction vehicles when the node is captured (unused ones)
- for (uint8 i = (nodePoint->faction == TEAM_ALLIANCE ? BG_IC_NPC_DEMOLISHER_1_H : BG_IC_NPC_DEMOLISHER_1_A); i < (nodePoint->faction == TEAM_ALLIANCE ? BG_IC_NPC_DEMOLISHER_4_H : BG_IC_NPC_DEMOLISHER_4_A); i++)
+ if (siegeEngineWorkshopTimer < WORKSHOP_UPDATE_TIME)
+ siegeEngineWorkshopTimer = WORKSHOP_UPDATE_TIME;
+
+ if (!recapture)
{
- if (Creature* demolisher = GetBGCreature(i))
+ // we must del opposing faction vehicles when the node is captured (unused ones)
+ for (uint8 i = (nodePoint->faction == TEAM_ALLIANCE ? BG_IC_NPC_DEMOLISHER_1_H : BG_IC_NPC_DEMOLISHER_1_A); i < (nodePoint->faction == TEAM_ALLIANCE ? BG_IC_NPC_DEMOLISHER_4_H : BG_IC_NPC_DEMOLISHER_4_A); i++)
{
- if (Vehicle* vehicleDemolisher = demolisher->GetVehicleKit())
+ if (Creature* demolisher = GetBGCreature(i))
{
- // is IsVehicleInUse working as expected?
- if (!vehicleDemolisher->IsVehicleInUse())
- DelCreature(i);
+ if (Vehicle* vehicleDemolisher = demolisher->GetVehicleKit())
+ {
+ // is IsVehicleInUse working as expected?
+ if (!vehicleDemolisher->IsVehicleInUse())
+ DelCreature(i);
+ }
}
}
- }
- for (uint8 i = 0; i < MAX_DEMOLISHERS_SPAWNS_PER_FACTION; i++)
- {
- uint8 type = (nodePoint->faction == TEAM_ALLIANCE ? BG_IC_NPC_DEMOLISHER_1_A : BG_IC_NPC_DEMOLISHER_1_H)+i;
+ for (uint8 i = 0; i < MAX_DEMOLISHERS_SPAWNS_PER_FACTION; i++)
+ {
+ uint8 type = (nodePoint->faction == TEAM_ALLIANCE ? BG_IC_NPC_DEMOLISHER_1_A : BG_IC_NPC_DEMOLISHER_1_H)+i;
- if (GetBGCreature(type) && GetBGCreature(type)->isAlive())
- continue;
+ if (GetBGCreature(type) && GetBGCreature(type)->isAlive())
+ continue;
- if (AddCreature(NPC_DEMOLISHER, type, nodePoint->faction,
- BG_IC_WorkshopVehicles[i].GetPositionX(), BG_IC_WorkshopVehicles[i].GetPositionY(),
- BG_IC_WorkshopVehicles[i].GetPositionZ(), BG_IC_WorkshopVehicles[i].GetOrientation(),
- RESPAWN_ONE_DAY))
- GetBGCreature(type)->setFaction(BG_IC_Factions[(nodePoint->faction == TEAM_ALLIANCE ? 0 : 1)]);
- }
+ if (AddCreature(NPC_DEMOLISHER, type, nodePoint->faction,
+ BG_IC_WorkshopVehicles[i].GetPositionX(), BG_IC_WorkshopVehicles[i].GetPositionY(),
+ BG_IC_WorkshopVehicles[i].GetPositionZ(), BG_IC_WorkshopVehicles[i].GetOrientation(),
+ RESPAWN_ONE_DAY))
+ GetBGCreature(type)->setFaction(BG_IC_Factions[(nodePoint->faction == TEAM_ALLIANCE ? 0 : 1)]);
+ }
- // we check if the opossing siege engine is in use
- int8 enemySiege = (nodePoint->faction == TEAM_ALLIANCE ? BG_IC_NPC_SIEGE_ENGINE_H : BG_IC_NPC_SIEGE_ENGINE_A);
+ // we check if the opossing siege engine is in use
+ int8 enemySiege = (nodePoint->faction == TEAM_ALLIANCE ? BG_IC_NPC_SIEGE_ENGINE_H : BG_IC_NPC_SIEGE_ENGINE_A);
- if (Creature* siegeEngine = GetBGCreature(enemySiege))
- {
- if (Vehicle* vehicleSiege = siegeEngine->GetVehicleKit())
+ if (Creature* siegeEngine = GetBGCreature(enemySiege))
{
- // is VehicleInUse working as expected ?
- if (!vehicleSiege->IsVehicleInUse())
- DelCreature(enemySiege);
+ if (Vehicle* vehicleSiege = siegeEngine->GetVehicleKit())
+ {
+ // is VehicleInUse working as expected ?
+ if (!vehicleSiege->IsVehicleInUse())
+ DelCreature(enemySiege);
+ }
}
- }
- uint8 siegeType = (nodePoint->faction == TEAM_ALLIANCE ? BG_IC_NPC_SIEGE_ENGINE_A : BG_IC_NPC_SIEGE_ENGINE_H);
- if (!GetBGCreature(siegeType) || !GetBGCreature(siegeType)->isAlive())
- {
- AddCreature((nodePoint->faction == TEAM_ALLIANCE ? NPC_SIEGE_ENGINE_A : NPC_SIEGE_ENGINE_H), siegeType, nodePoint->faction,
- BG_IC_WorkshopVehicles[4].GetPositionX(), BG_IC_WorkshopVehicles[4].GetPositionY(),
- BG_IC_WorkshopVehicles[4].GetPositionZ(), BG_IC_WorkshopVehicles[4].GetOrientation(),
- RESPAWN_ONE_DAY);
-
- if (Creature* siegeEngine = GetBGCreature(siegeType))
+ uint8 siegeType = (nodePoint->faction == TEAM_ALLIANCE ? BG_IC_NPC_SIEGE_ENGINE_A : BG_IC_NPC_SIEGE_ENGINE_H);
+ if (!GetBGCreature(siegeType) || !GetBGCreature(siegeType)->isAlive())
{
- siegeEngine->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE|UNIT_FLAG_UNK_14|UNIT_FLAG_OOC_NOT_ATTACKABLE);
- siegeEngine->setFaction(BG_IC_Factions[(nodePoint->faction == TEAM_ALLIANCE ? 0 : 1)]);
+ AddCreature((nodePoint->faction == TEAM_ALLIANCE ? NPC_SIEGE_ENGINE_A : NPC_SIEGE_ENGINE_H), siegeType, nodePoint->faction,
+ BG_IC_WorkshopVehicles[4].GetPositionX(), BG_IC_WorkshopVehicles[4].GetPositionY(),
+ BG_IC_WorkshopVehicles[4].GetPositionZ(), BG_IC_WorkshopVehicles[4].GetOrientation(),
+ RESPAWN_ONE_DAY);
+
+ if (Creature* siegeEngine = GetBGCreature(siegeType))
+ {
+ siegeEngine->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE|UNIT_FLAG_UNK_14|UNIT_FLAG_OOC_NOT_ATTACKABLE);
+ siegeEngine->setFaction(BG_IC_Factions[(nodePoint->faction == TEAM_ALLIANCE ? 0 : 1)]);
+ }
}
}
- }
- for (uint8 i = 0; i < MAX_WORKSHOP_BOMBS_SPAWNS_PER_FACTION; i++)
- {
- AddObject(BG_IC_GO_SEAFORIUM_BOMBS_1+i, GO_SEAFORIUM_BOMBS,
- workshopBombs[i].GetPositionX(), workshopBombs[i].GetPositionY(),
- workshopBombs[i].GetPositionZ(), workshopBombs[i].GetOrientation(),
- 0, 0, 0, 0, 10);
-
- if (GameObject* seaforiumBombs = GetBGObject(BG_IC_GO_SEAFORIUM_BOMBS_1+i))
+ for (uint8 i = 0; i < MAX_WORKSHOP_BOMBS_SPAWNS_PER_FACTION; i++)
{
- seaforiumBombs->SetRespawnTime(10);
- seaforiumBombs->SetUInt32Value(GAMEOBJECT_FACTION, BG_IC_Factions[(nodePoint->faction == TEAM_ALLIANCE ? 0 : 1)]);
+ AddObject(BG_IC_GO_SEAFORIUM_BOMBS_1+i, GO_SEAFORIUM_BOMBS,
+ workshopBombs[i].GetPositionX(), workshopBombs[i].GetPositionY(),
+ workshopBombs[i].GetPositionZ(), workshopBombs[i].GetOrientation(),
+ 0, 0, 0, 0, 10);
+
+ if (GameObject* seaforiumBombs = GetBGObject(BG_IC_GO_SEAFORIUM_BOMBS_1+i))
+ {
+ seaforiumBombs->SetRespawnTime(10);
+ seaforiumBombs->SetUInt32Value(GAMEOBJECT_FACTION, BG_IC_Factions[(nodePoint->faction == TEAM_ALLIANCE ? 0 : 1)]);
+ }
}
+ break;
}
+ default:
break;
- }
- default:
- break;
}
}
@@ -855,7 +855,7 @@ void BattlegroundIC::DestroyGate(Player* player, GameObject* go)
SendMessage2ToAll(lang_entry, CHAT_MSG_BG_SYSTEM_NEUTRAL, NULL, (player->GetTeamId() == TEAM_ALLIANCE ? LANG_BG_IC_HORDE_KEEP : LANG_BG_IC_ALLIANCE_KEEP));
}
-void BattlegroundIC::EventPlayerDamagedGO(Player* /*plr*/, GameObject* /*go*/, uint32 /*eventType*/)
+void BattlegroundIC::EventPlayerDamagedGO(Player* /*player*/, GameObject* /*go*/, uint32 /*eventType*/)
{
}
@@ -903,7 +903,7 @@ Transport* BattlegroundIC::CreateTransport(uint32 goEntry, uint32 period)
{
Transport* t = new Transport(period, 0);
- const GameObjectTemplate* goinfo = sObjectMgr->GetGameObjectTemplate(goEntry);
+ GameObjectTemplate const* goinfo = sObjectMgr->GetGameObjectTemplate(goEntry);
if (!goinfo)
{
diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundIC.h b/src/server/game/Battlegrounds/Zones/BattlegroundIC.h
index efa91559ca6..552b79ce608 100755
--- a/src/server/game/Battlegrounds/Zones/BattlegroundIC.h
+++ b/src/server/game/Battlegrounds/Zones/BattlegroundIC.h
@@ -93,7 +93,6 @@ enum gameobjectsIC
GO_FLAGPOLE_1 = 195131,
GO_FLAGPOLE_2 = 195439,
- GO_FLAGPOLE_3 = 195131,
GO_GUNSHIP_PORTAL_1 = 195371,
GO_GUNSHIP_PORTAL_2 = 196413,
@@ -270,6 +269,7 @@ enum BG_IC_GOs
BG_IC_GO_FLAGPOLE_1_3,
BG_IC_GO_FLAGPOLE_1_4,
BG_IC_GO_FLAGPOLE_1_5,
+ BG_IC_GO_FLAGPOLE_1_6,
BG_IC_GO_HANGAR_BANNER,
@@ -624,6 +624,7 @@ const ICGo BG_IC_ObjSpawnlocs[MAX_NORMAL_GAMEOBJECTS_SPAWNS] =
{BG_IC_GO_FLAGPOLE_1_3, GO_FLAGPOLE_1, 807.78f, -1000.07f, 132.381f, -1.91986f}, // Flagpole
{BG_IC_GO_FLAGPOLE_1_4, GO_FLAGPOLE_1, 776.229f, -804.283f, 6.45052f, 1.6057f}, // Flagpole
{BG_IC_GO_FLAGPOLE_1_5, GO_FLAGPOLE_1, 251.016f, -1159.32f, 17.2376f, -2.25147f}, // Flagpole
+ {BG_IC_GO_FLAGPOLE_1_6, GO_FLAGPOLE_1, 1269.502f, -400.809f, 37.62525f, -1.762782f}, // Flagpole
{BG_IC_GO_HORDE_KEEP_PORTCULLIS, GO_HORDE_KEEP_PORTCULLIS, 1283.05f, -765.878f, 50.8297f, -3.13286f}, // Horde Keep Portcullis
@@ -862,12 +863,12 @@ class BattlegroundIC : public Battleground
~BattlegroundIC();
/* inherited from BattlegroundClass */
- virtual void AddPlayer(Player* plr);
+ virtual void AddPlayer(Player* player);
virtual void StartingEventCloseDoors();
virtual void StartingEventOpenDoors();
virtual void PostUpdateImpl(uint32 diff);
- void RemovePlayer(Player* plr, uint64 guid, uint32 team);
+ void RemovePlayer(Player* player, uint64 guid, uint32 team);
void HandleAreaTrigger(Player* Source, uint32 Trigger);
bool SetupBattleground();
void SpawnLeader(uint32 teamid);
@@ -876,7 +877,7 @@ class BattlegroundIC : public Battleground
void EndBattleground(uint32 winner);
void EventPlayerClickedOnFlag(Player* source, GameObject* /*target_obj*/);
- void EventPlayerDamagedGO(Player* /*plr*/, GameObject* go, uint32 eventType);
+ void EventPlayerDamagedGO(Player* /*player*/, GameObject* go, uint32 eventType);
void DestroyGate(Player* player, GameObject* go);
virtual WorldSafeLocsEntry const* GetClosestGraveYard(Player* player);
diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundNA.cpp b/src/server/game/Battlegrounds/Zones/BattlegroundNA.cpp
index 58dc20c30cb..37fdd2559c4 100755
--- a/src/server/game/Battlegrounds/Zones/BattlegroundNA.cpp
+++ b/src/server/game/Battlegrounds/Zones/BattlegroundNA.cpp
@@ -59,18 +59,18 @@ void BattlegroundNA::StartingEventOpenDoors()
SpawnBGObject(i, 60);
}
-void BattlegroundNA::AddPlayer(Player* plr)
+void BattlegroundNA::AddPlayer(Player* player)
{
- Battleground::AddPlayer(plr);
+ Battleground::AddPlayer(player);
//create score and add it to map, default values are set in constructor
BattlegroundNAScore* sc = new BattlegroundNAScore;
- m_PlayerScores[plr->GetGUID()] = sc;
+ m_PlayerScores[player->GetGUID()] = sc;
UpdateArenaWorldState();
}
-void BattlegroundNA::RemovePlayer(Player* /*plr*/, uint64 /*guid*/, uint32 /*team*/)
+void BattlegroundNA::RemovePlayer(Player* /*player*/, uint64 /*guid*/, uint32 /*team*/)
{
if (GetStatus() == STATUS_WAIT_LEAVE)
return;
diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundNA.h b/src/server/game/Battlegrounds/Zones/BattlegroundNA.h
index beddbaaeedf..e7fe08063a4 100755
--- a/src/server/game/Battlegrounds/Zones/BattlegroundNA.h
+++ b/src/server/game/Battlegrounds/Zones/BattlegroundNA.h
@@ -56,16 +56,16 @@ class BattlegroundNA : public Battleground
~BattlegroundNA();
/* inherited from BattlegroundClass */
- virtual void AddPlayer(Player* plr);
+ virtual void AddPlayer(Player* player);
virtual void StartingEventCloseDoors();
virtual void StartingEventOpenDoors();
- void RemovePlayer(Player* plr, uint64 guid, uint32 team);
+ void RemovePlayer(Player* player, uint64 guid, uint32 team);
void HandleAreaTrigger(Player* Source, uint32 Trigger);
bool SetupBattleground();
virtual void Reset();
virtual void FillInitialWorldStates(WorldPacket &d);
void HandleKillPlayer(Player* player, Player* killer);
- bool HandlePlayerUnderMap(Player* plr);
+ bool HandlePlayerUnderMap(Player* player);
};
#endif
diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundRB.cpp b/src/server/game/Battlegrounds/Zones/BattlegroundRB.cpp
index e2d64aa39f7..ba4d787b215 100755
--- a/src/server/game/Battlegrounds/Zones/BattlegroundRB.cpp
+++ b/src/server/game/Battlegrounds/Zones/BattlegroundRB.cpp
@@ -43,16 +43,16 @@ void BattlegroundRB::StartingEventOpenDoors()
{
}
-void BattlegroundRB::AddPlayer(Player* plr)
+void BattlegroundRB::AddPlayer(Player* player)
{
- Battleground::AddPlayer(plr);
+ Battleground::AddPlayer(player);
//create score and add it to map, default values are set in constructor
BattlegroundRBScore* sc = new BattlegroundRBScore;
- m_PlayerScores[plr->GetGUID()] = sc;
+ m_PlayerScores[player->GetGUID()] = sc;
}
-void BattlegroundRB::RemovePlayer(Player* /*plr*/, uint64 /*guid*/, uint32 /*team*/)
+void BattlegroundRB::RemovePlayer(Player* /*player*/, uint64 /*guid*/, uint32 /*team*/)
{
}
diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundRB.h b/src/server/game/Battlegrounds/Zones/BattlegroundRB.h
index 0878654d7dd..ef6283ed96a 100755
--- a/src/server/game/Battlegrounds/Zones/BattlegroundRB.h
+++ b/src/server/game/Battlegrounds/Zones/BattlegroundRB.h
@@ -34,11 +34,11 @@ class BattlegroundRB : public Battleground
BattlegroundRB();
~BattlegroundRB();
- virtual void AddPlayer(Player* plr);
+ virtual void AddPlayer(Player* player);
virtual void StartingEventCloseDoors();
virtual void StartingEventOpenDoors();
- void RemovePlayer(Player* plr, uint64 guid, uint32 team);
+ void RemovePlayer(Player* player, uint64 guid, uint32 team);
void HandleAreaTrigger(Player* Source, uint32 Trigger);
/* Scorekeeping */
diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundRL.cpp b/src/server/game/Battlegrounds/Zones/BattlegroundRL.cpp
index 8ede4a6329c..3d1ebe8fec9 100755
--- a/src/server/game/Battlegrounds/Zones/BattlegroundRL.cpp
+++ b/src/server/game/Battlegrounds/Zones/BattlegroundRL.cpp
@@ -59,18 +59,18 @@ void BattlegroundRL::StartingEventOpenDoors()
SpawnBGObject(i, 60);
}
-void BattlegroundRL::AddPlayer(Player* plr)
+void BattlegroundRL::AddPlayer(Player* player)
{
- Battleground::AddPlayer(plr);
+ Battleground::AddPlayer(player);
//create score and add it to map, default values are set in constructor
BattlegroundRLScore* sc = new BattlegroundRLScore;
- m_PlayerScores[plr->GetGUID()] = sc;
+ m_PlayerScores[player->GetGUID()] = sc;
UpdateArenaWorldState();
}
-void BattlegroundRL::RemovePlayer(Player* /*plr*/, uint64 /*guid*/, uint32 /*team*/)
+void BattlegroundRL::RemovePlayer(Player* /*player*/, uint64 /*guid*/, uint32 /*team*/)
{
if (GetStatus() == STATUS_WAIT_LEAVE)
return;
diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundRL.h b/src/server/game/Battlegrounds/Zones/BattlegroundRL.h
index 52ce7d3ca40..5528d0ccf9e 100755
--- a/src/server/game/Battlegrounds/Zones/BattlegroundRL.h
+++ b/src/server/game/Battlegrounds/Zones/BattlegroundRL.h
@@ -52,16 +52,16 @@ class BattlegroundRL : public Battleground
~BattlegroundRL();
/* inherited from BattlegroundClass */
- virtual void AddPlayer(Player* plr);
+ virtual void AddPlayer(Player* player);
virtual void Reset();
virtual void FillInitialWorldStates(WorldPacket &d);
virtual void StartingEventCloseDoors();
virtual void StartingEventOpenDoors();
- void RemovePlayer(Player* plr, uint64 guid, uint32 team);
+ void RemovePlayer(Player* player, uint64 guid, uint32 team);
void HandleAreaTrigger(Player* Source, uint32 Trigger);
bool SetupBattleground();
void HandleKillPlayer(Player* player, Player* killer);
- bool HandlePlayerUnderMap(Player* plr);
+ bool HandlePlayerUnderMap(Player* player);
};
#endif
diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundRV.cpp b/src/server/game/Battlegrounds/Zones/BattlegroundRV.cpp
index 81a75c23cb5..0c44c5d3d96 100755
--- a/src/server/game/Battlegrounds/Zones/BattlegroundRV.cpp
+++ b/src/server/game/Battlegrounds/Zones/BattlegroundRV.cpp
@@ -102,19 +102,19 @@ void BattlegroundRV::StartingEventOpenDoors()
setTimer(BG_RV_FIRST_TIMER);
}
-void BattlegroundRV::AddPlayer(Player* plr)
+void BattlegroundRV::AddPlayer(Player* player)
{
- Battleground::AddPlayer(plr);
+ Battleground::AddPlayer(player);
//create score and add it to map, default values are set in constructor
BattlegroundRVScore* sc = new BattlegroundRVScore;
- m_PlayerScores[plr->GetGUID()] = sc;
+ m_PlayerScores[player->GetGUID()] = sc;
UpdateWorldState(BG_RV_WORLD_STATE_A, GetAlivePlayersCountByTeam(ALLIANCE));
UpdateWorldState(BG_RV_WORLD_STATE_H, GetAlivePlayersCountByTeam(HORDE));
}
-void BattlegroundRV::RemovePlayer(Player* /*plr*/, uint64 /*guid*/, uint32 /*team*/)
+void BattlegroundRV::RemovePlayer(Player* /*player*/, uint64 /*guid*/, uint32 /*team*/)
{
if (GetStatus() == STATUS_WAIT_LEAVE)
return;
diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundRV.h b/src/server/game/Battlegrounds/Zones/BattlegroundRV.h
index 9a6efe64524..70417c1dfce 100755
--- a/src/server/game/Battlegrounds/Zones/BattlegroundRV.h
+++ b/src/server/game/Battlegrounds/Zones/BattlegroundRV.h
@@ -105,17 +105,17 @@ class BattlegroundRV : public Battleground
~BattlegroundRV();
/* inherited from BattlegroundClass */
- virtual void AddPlayer(Player* plr);
+ virtual void AddPlayer(Player* player);
virtual void StartingEventCloseDoors();
virtual void StartingEventOpenDoors();
virtual void Reset();
virtual void FillInitialWorldStates(WorldPacket &d);
- void RemovePlayer(Player* plr, uint64 guid, uint32 team);
+ void RemovePlayer(Player* player, uint64 guid, uint32 team);
void HandleAreaTrigger(Player* Source, uint32 Trigger);
bool SetupBattleground();
void HandleKillPlayer(Player* player, Player* killer);
- bool HandlePlayerUnderMap(Player* plr);
+ bool HandlePlayerUnderMap(Player* player);
private:
uint32 Timer;
diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundSA.cpp b/src/server/game/Battlegrounds/Zones/BattlegroundSA.cpp
index c214ac21068..aaa29e1ca20 100755
--- a/src/server/game/Battlegrounds/Zones/BattlegroundSA.cpp
+++ b/src/server/game/Battlegrounds/Zones/BattlegroundSA.cpp
@@ -62,8 +62,8 @@ bool BattlegroundSA::SetupBattleground()
bool BattlegroundSA::ResetObjs()
{
for (BattlegroundPlayerMap::const_iterator itr = GetPlayers().begin(); itr != GetPlayers().end(); ++itr)
- if (Player* plr = ObjectAccessor::FindPlayer(itr->first))
- SendTransportsRemove(plr);
+ if (Player* player = ObjectAccessor::FindPlayer(itr->first))
+ SendTransportsRemove(player);
uint32 atF = BG_SA_Factions[Attackers];
uint32 defF = BG_SA_Factions[Attackers ? TEAM_ALLIANCE : TEAM_HORDE];
@@ -245,8 +245,8 @@ bool BattlegroundSA::ResetObjs()
for (int i = BG_SA_BOAT_ONE; i <= BG_SA_BOAT_TWO; i++)
for (BattlegroundPlayerMap::const_iterator itr = GetPlayers().begin(); itr != GetPlayers().end(); ++itr)
- if (Player* plr = ObjectAccessor::FindPlayer(itr->first))
- SendTransportInit(plr);
+ if (Player* player = ObjectAccessor::FindPlayer(itr->first))
+ SendTransportInit(player);
TeleportPlayers();
return true;
@@ -431,39 +431,39 @@ void BattlegroundSA::FillInitialWorldStates(WorldPacket& data)
data << uint32(BG_SA_LEFT_ATT_TOKEN_ALL) << ally_attacks;
}
-void BattlegroundSA::AddPlayer(Player* plr)
+void BattlegroundSA::AddPlayer(Player* player)
{
- Battleground::AddPlayer(plr);
+ Battleground::AddPlayer(player);
//create score and add it to map, default values are set in constructor
BattlegroundSAScore* sc = new BattlegroundSAScore;
if (!ShipsStarted)
{
- if (plr->GetTeamId() == Attackers)
+ if (player->GetTeamId() == Attackers)
{
- plr->CastSpell(plr, 12438, true);//Without this player falls before boat loads...
+ player->CastSpell(player, 12438, true);//Without this player falls before boat loads...
if (urand(0, 1))
- plr->TeleportTo(607, 2682.936f, -830.368f, 50.0f, 2.895f, 0);
+ player->TeleportTo(607, 2682.936f, -830.368f, 50.0f, 2.895f, 0);
else
- plr->TeleportTo(607, 2577.003f, 980.261f, 50.0f, 0.807f, 0);
+ player->TeleportTo(607, 2577.003f, 980.261f, 50.0f, 0.807f, 0);
}
else
- plr->TeleportTo(607, 1209.7f, -65.16f, 70.1f, 0.0f, 0);
+ player->TeleportTo(607, 1209.7f, -65.16f, 70.1f, 0.0f, 0);
}
else
{
- if (plr->GetTeamId() == Attackers)
- plr->TeleportTo(607, 1600.381f, -106.263f, 8.8745f, 3.78f, 0);
+ if (player->GetTeamId() == Attackers)
+ player->TeleportTo(607, 1600.381f, -106.263f, 8.8745f, 3.78f, 0);
else
- plr->TeleportTo(607, 1209.7f, -65.16f, 70.1f, 0.0f, 0);
+ player->TeleportTo(607, 1209.7f, -65.16f, 70.1f, 0.0f, 0);
}
- SendTransportInit(plr);
- m_PlayerScores[plr->GetGUID()] = sc;
+ SendTransportInit(player);
+ m_PlayerScores[player->GetGUID()] = sc;
}
-void BattlegroundSA::RemovePlayer(Player* /*plr*/, uint64 /*guid*/, uint32 /*team*/)
+void BattlegroundSA::RemovePlayer(Player* /*player*/, uint64 /*guid*/, uint32 /*team*/)
{
}
@@ -492,37 +492,37 @@ void BattlegroundSA::TeleportPlayers()
{
for (BattlegroundPlayerMap::const_iterator itr = GetPlayers().begin(); itr != GetPlayers().end(); ++itr)
{
- if (Player* plr = ObjectAccessor::FindPlayer(itr->first))
+ if (Player* player = ObjectAccessor::FindPlayer(itr->first))
{
// should remove spirit of redemption
- if (plr->HasAuraType(SPELL_AURA_SPIRIT_OF_REDEMPTION))
- plr->RemoveAurasByType(SPELL_AURA_MOD_SHAPESHIFT);
+ if (player->HasAuraType(SPELL_AURA_SPIRIT_OF_REDEMPTION))
+ player->RemoveAurasByType(SPELL_AURA_MOD_SHAPESHIFT);
- if (!plr->isAlive())
+ if (!player->isAlive())
{
- plr->ResurrectPlayer(1.0f);
- plr->SpawnCorpseBones();
+ player->ResurrectPlayer(1.0f);
+ player->SpawnCorpseBones();
}
- plr->ResetAllPowers();
- plr->CombatStopWithPets(true);
+ player->ResetAllPowers();
+ player->CombatStopWithPets(true);
- if (plr->GetTeamId() == Attackers)
+ if (player->GetTeamId() == Attackers)
{
- plr->CastSpell(plr, 12438, true); //Without this player falls before boat loads...
+ player->CastSpell(player, 12438, true); //Without this player falls before boat loads...
if (urand(0, 1))
- plr->TeleportTo(607, 2682.936f, -830.368f, 50.0f, 2.895f, 0);
+ player->TeleportTo(607, 2682.936f, -830.368f, 50.0f, 2.895f, 0);
else
- plr->TeleportTo(607, 2577.003f, 980.261f, 50.0f, 0.807f, 0);
+ player->TeleportTo(607, 2577.003f, 980.261f, 50.0f, 0.807f, 0);
}
else
- plr->TeleportTo(607, 1209.7f, -65.16f, 70.1f, 0.0f, 0);
+ player->TeleportTo(607, 1209.7f, -65.16f, 70.1f, 0.0f, 0);
}
}
}
-void BattlegroundSA::EventPlayerDamagedGO(Player* /*plr*/, GameObject* go, uint32 eventType)
+void BattlegroundSA::EventPlayerDamagedGO(Player* /*player*/, GameObject* go, uint32 eventType)
{
if (!go || !go->GetGOInfo())
return;
@@ -798,9 +798,9 @@ void BattlegroundSA::EventPlayerUsedGO(Player* Source, GameObject* object)
//Achievement Storm the Beach (1310)
for (BattlegroundPlayerMap::const_iterator itr = GetPlayers().begin(); itr != GetPlayers().end(); ++itr)
{
- if (Player* plr = ObjectAccessor::FindPlayer(itr->first))
- if (plr->GetTeamId() == Attackers)
- plr->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_BE_SPELL_TARGET, 65246);
+ if (Player* player = ObjectAccessor::FindPlayer(itr->first))
+ if (player->GetTeamId() == Attackers)
+ player->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_BE_SPELL_TARGET, 65246);
}
Attackers = (Attackers == TEAM_ALLIANCE) ? TEAM_HORDE : TEAM_ALLIANCE;
@@ -822,9 +822,9 @@ void BattlegroundSA::EventPlayerUsedGO(Player* Source, GameObject* object)
//Achievement Storm the Beach (1310)
for (BattlegroundPlayerMap::const_iterator itr = GetPlayers().begin(); itr != GetPlayers().end(); ++itr)
{
- if (Player* plr = ObjectAccessor::FindPlayer(itr->first))
- if (plr->GetTeamId() == Attackers && RoundScores[1].winner == Attackers)
- plr->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_BE_SPELL_TARGET, 65246);
+ if (Player* player = ObjectAccessor::FindPlayer(itr->first))
+ if (player->GetTeamId() == Attackers && RoundScores[1].winner == Attackers)
+ player->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_BE_SPELL_TARGET, 65246);
}
if (RoundScores[0].time == RoundScores[1].time)
diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundSA.h b/src/server/game/Battlegrounds/Zones/BattlegroundSA.h
index 5f01d0fac4d..8b446fccb9e 100755
--- a/src/server/game/Battlegrounds/Zones/BattlegroundSA.h
+++ b/src/server/game/Battlegrounds/Zones/BattlegroundSA.h
@@ -423,7 +423,7 @@ class BattlegroundSA : public Battleground
/* inherited from BattlegroundClass */
/// Called when a player join battle
- virtual void AddPlayer(Player* plr);
+ virtual void AddPlayer(Player* player);
/// Called when battle start
virtual void StartingEventCloseDoors();
virtual void StartingEventOpenDoors();
@@ -433,7 +433,7 @@ class BattlegroundSA : public Battleground
/// Called for generate packet contain worldstate data
virtual void FillInitialWorldStates(WorldPacket& data);
/// Called when a player deal damage to building (door)
- virtual void EventPlayerDamagedGO(Player* plr, GameObject* go, uint32 eventType);
+ virtual void EventPlayerDamagedGO(Player* player, GameObject* go, uint32 eventType);
/// Called when a player kill a unit in bg
virtual void HandleKillUnit(Creature* unit, Player* killer);
/// Return the nearest graveyard where player can respawn
@@ -477,7 +477,7 @@ class BattlegroundSA : public Battleground
void EndBattleground(uint32 winner);
/// CAlled when a player leave battleground
- void RemovePlayer(Player* plr, uint64 guid, uint32 team);
+ void RemovePlayer(Player* player, uint64 guid, uint32 team);
void HandleAreaTrigger(Player* Source, uint32 Trigger);
/* Scorekeeping */
diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundWS.cpp b/src/server/game/Battlegrounds/Zones/BattlegroundWS.cpp
index 951fe8f6b51..a6aa6f41db2 100755
--- a/src/server/game/Battlegrounds/Zones/BattlegroundWS.cpp
+++ b/src/server/game/Battlegrounds/Zones/BattlegroundWS.cpp
@@ -140,23 +140,23 @@ void BattlegroundWS::PostUpdateImpl(uint32 diff)
m_FlagSpellForceTimer += diff;
if (m_FlagDebuffState == 0 && m_FlagSpellForceTimer >= 600000) //10 minutes
{
- if (Player* plr = ObjectAccessor::FindPlayer(m_FlagKeepers[0]))
- plr->CastSpell(plr, WS_SPELL_FOCUSED_ASSAULT, true);
- if (Player* plr = ObjectAccessor::FindPlayer(m_FlagKeepers[1]))
- plr->CastSpell(plr, WS_SPELL_FOCUSED_ASSAULT, true);
+ if (Player* player = ObjectAccessor::FindPlayer(m_FlagKeepers[0]))
+ player->CastSpell(player, WS_SPELL_FOCUSED_ASSAULT, true);
+ if (Player* player = ObjectAccessor::FindPlayer(m_FlagKeepers[1]))
+ player->CastSpell(player, WS_SPELL_FOCUSED_ASSAULT, true);
m_FlagDebuffState = 1;
}
else if (m_FlagDebuffState == 1 && m_FlagSpellForceTimer >= 900000) //15 minutes
{
- if (Player* plr = ObjectAccessor::FindPlayer(m_FlagKeepers[0]))
+ if (Player* player = ObjectAccessor::FindPlayer(m_FlagKeepers[0]))
{
- plr->RemoveAurasDueToSpell(WS_SPELL_FOCUSED_ASSAULT);
- plr->CastSpell(plr, WS_SPELL_BRUTAL_ASSAULT, true);
+ player->RemoveAurasDueToSpell(WS_SPELL_FOCUSED_ASSAULT);
+ player->CastSpell(player, WS_SPELL_BRUTAL_ASSAULT, true);
}
- if (Player* plr = ObjectAccessor::FindPlayer(m_FlagKeepers[1]))
+ if (Player* player = ObjectAccessor::FindPlayer(m_FlagKeepers[1]))
{
- plr->RemoveAurasDueToSpell(WS_SPELL_FOCUSED_ASSAULT);
- plr->CastSpell(plr, WS_SPELL_BRUTAL_ASSAULT, true);
+ player->RemoveAurasDueToSpell(WS_SPELL_FOCUSED_ASSAULT);
+ player->CastSpell(player, WS_SPELL_BRUTAL_ASSAULT, true);
}
m_FlagDebuffState = 2;
}
@@ -202,13 +202,13 @@ void BattlegroundWS::StartingEventOpenDoors()
StartTimedAchievement(ACHIEVEMENT_TIMED_TYPE_EVENT, WS_EVENT_START_BATTLE);
}
-void BattlegroundWS::AddPlayer(Player* plr)
+void BattlegroundWS::AddPlayer(Player* player)
{
- Battleground::AddPlayer(plr);
+ Battleground::AddPlayer(player);
//create score and add it to map, default values are set in constructor
BattlegroundWGScore* sc = new BattlegroundWGScore;
- m_PlayerScores[plr->GetGUID()] = sc;
+ m_PlayerScores[player->GetGUID()] = sc;
}
void BattlegroundWS::RespawnFlag(uint32 Team, bool captured)
@@ -556,30 +556,30 @@ void BattlegroundWS::EventPlayerClickedOnFlag(Player* Source, GameObject* target
Source->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_ENTER_PVP_COMBAT);
}
-void BattlegroundWS::RemovePlayer(Player* plr, uint64 guid, uint32 /*team*/)
+void BattlegroundWS::RemovePlayer(Player* player, uint64 guid, uint32 /*team*/)
{
// sometimes flag aura not removed :(
if (IsAllianceFlagPickedup() && m_FlagKeepers[BG_TEAM_ALLIANCE] == guid)
{
- if (!plr)
+ if (!player)
{
sLog->outError("BattlegroundWS: Removing offline player who has the FLAG!!");
this->SetAllianceFlagPicker(0);
this->RespawnFlag(ALLIANCE, false);
}
else
- this->EventPlayerDroppedFlag(plr);
+ this->EventPlayerDroppedFlag(player);
}
if (IsHordeFlagPickedup() && m_FlagKeepers[BG_TEAM_HORDE] == guid)
{
- if (!plr)
+ if (!player)
{
sLog->outError("BattlegroundWS: Removing offline player who has the FLAG!!");
this->SetHordeFlagPicker(0);
this->RespawnFlag(HORDE, false);
}
else
- this->EventPlayerDroppedFlag(plr);
+ this->EventPlayerDroppedFlag(player);
}
}
diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundWS.h b/src/server/game/Battlegrounds/Zones/BattlegroundWS.h
index 386cc6945e8..b3c2c88c306 100755
--- a/src/server/game/Battlegrounds/Zones/BattlegroundWS.h
+++ b/src/server/game/Battlegrounds/Zones/BattlegroundWS.h
@@ -163,7 +163,7 @@ class BattlegroundWS : public Battleground
~BattlegroundWS();
/* inherited from BattlegroundClass */
- virtual void AddPlayer(Player* plr);
+ virtual void AddPlayer(Player* player);
virtual void StartingEventCloseDoors();
virtual void StartingEventOpenDoors();
@@ -187,7 +187,7 @@ class BattlegroundWS : public Battleground
virtual void EventPlayerClickedOnFlag(Player* Source, GameObject* target_obj);
virtual void EventPlayerCapturedFlag(Player* Source);
- void RemovePlayer(Player* plr, uint64 guid, uint32 team);
+ void RemovePlayer(Player* player, uint64 guid, uint32 team);
void HandleAreaTrigger(Player* Source, uint32 Trigger);
void HandleKillPlayer(Player* player, Player* killer);
bool SetupBattleground();
diff --git a/src/server/game/Chat/Channels/Channel.cpp b/src/server/game/Chat/Channels/Channel.cpp
index 413070ca1de..1968de70f46 100755
--- a/src/server/game/Chat/Channels/Channel.cpp
+++ b/src/server/game/Chat/Channels/Channel.cpp
@@ -85,7 +85,7 @@ Channel::Channel(const std::string& name, uint32 channel_id, uint32 Team)
}
else // save
{
- PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_ADD_CHANNEL);
+ stmt = CharacterDatabase.GetPreparedStatement(CHAR_ADD_CHANNEL);
stmt->setString(0, name);
stmt->setUInt32(1, m_Team);
CharacterDatabase.Execute(stmt);
@@ -169,22 +169,22 @@ void Channel::Join(uint64 p, const char *pass)
return;
}
- Player* plr = ObjectAccessor::FindPlayer(p);
+ Player* player = ObjectAccessor::FindPlayer(p);
- if (plr)
+ if (player)
{
if (HasFlag(CHANNEL_FLAG_LFG) &&
- sWorld->getBoolConfig(CONFIG_RESTRICTED_LFG_CHANNEL) && AccountMgr::IsPlayerAccount(plr->GetSession()->GetSecurity()) && plr->GetGroup())
+ sWorld->getBoolConfig(CONFIG_RESTRICTED_LFG_CHANNEL) && AccountMgr::IsPlayerAccount(player->GetSession()->GetSecurity()) && player->GetGroup())
{
MakeNotInLfg(&data);
SendToOne(&data, p);
return;
}
- plr->JoinedChannel(this);
+ player->JoinedChannel(this);
}
- if (m_announce && (!plr || !AccountMgr::IsGMAccount(plr->GetSession()->GetSecurity()) || !sWorld->getBoolConfig(CONFIG_SILENTLY_GM_JOIN_TO_CHANNEL)))
+ if (m_announce && (!player || !AccountMgr::IsGMAccount(player->GetSession()->GetSecurity()) || !sWorld->getBoolConfig(CONFIG_SILENTLY_GM_JOIN_TO_CHANNEL)))
{
MakeJoined(&data, p);
SendToAll(&data);
@@ -231,22 +231,22 @@ void Channel::Leave(uint64 p, bool send)
}
else
{
- Player* plr = ObjectAccessor::FindPlayer(p);
+ Player* player = ObjectAccessor::FindPlayer(p);
if (send)
{
WorldPacket data;
MakeYouLeft(&data);
SendToOne(&data, p);
- if (plr)
- plr->LeftChannel(this);
+ if (player)
+ player->LeftChannel(this);
data.clear();
}
bool changeowner = players[p].IsOwner();
players.erase(p);
- if (m_announce && (!plr || !AccountMgr::IsGMAccount(plr->GetSession()->GetSecurity()) || !sWorld->getBoolConfig(CONFIG_SILENTLY_GM_JOIN_TO_CHANNEL)))
+ if (m_announce && (!player || !AccountMgr::IsGMAccount(player->GetSession()->GetSecurity()) || !sWorld->getBoolConfig(CONFIG_SILENTLY_GM_JOIN_TO_CHANNEL)))
{
WorldPacket data;
MakeLeft(&data, p);
@@ -379,11 +379,11 @@ void Channel::UnBan(uint64 good, const char *badname)
void Channel::Password(uint64 p, const char *pass)
{
uint32 sec = 0;
- Player* plr = ObjectAccessor::FindPlayer(p);
- if (plr)
- sec = plr->GetSession()->GetSecurity();
+ Player* player = ObjectAccessor::FindPlayer(p);
+ if (player)
+ sec = player->GetSession()->GetSecurity();
- ChatHandler chat(plr);
+ ChatHandler chat(player);
if (!IsOn(p))
{
@@ -411,11 +411,11 @@ void Channel::Password(uint64 p, const char *pass)
void Channel::SetMode(uint64 p, const char *p2n, bool mod, bool set)
{
- Player* plr = ObjectAccessor::FindPlayer(p);
- if (!plr)
+ Player* player = ObjectAccessor::FindPlayer(p);
+ if (!player)
return;
- uint32 sec = plr->GetSession()->GetSecurity();
+ uint32 sec = player->GetSession()->GetSecurity();
if (!IsOn(p))
{
@@ -453,8 +453,8 @@ void Channel::SetMode(uint64 p, const char *p2n, bool mod, bool set)
// allow make moderator from another team only if both is GMs
// at this moment this only way to show channel post for GM from another team
- if ((!AccountMgr::IsGMAccount(plr->GetSession()->GetSecurity()) || !AccountMgr::IsGMAccount(newp->GetSession()->GetSecurity())) &&
- plr->GetTeam() != newp->GetTeam() && !sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_CHANNEL))
+ if ((!AccountMgr::IsGMAccount(player->GetSession()->GetSecurity()) || !AccountMgr::IsGMAccount(newp->GetSession()->GetSecurity())) &&
+ player->GetTeam() != newp->GetTeam() && !sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_CHANNEL))
{
WorldPacket data;
MakePlayerNotFound(&data, p2n);
@@ -479,11 +479,11 @@ void Channel::SetMode(uint64 p, const char *p2n, bool mod, bool set)
void Channel::SetOwner(uint64 p, const char *newname)
{
- Player* plr = ObjectAccessor::FindPlayer(p);
- if (!plr)
+ Player* player = ObjectAccessor::FindPlayer(p);
+ if (!player)
return;
- uint32 sec = plr->GetSession()->GetSecurity();
+ uint32 sec = player->GetSession()->GetSecurity();
if (!IsOn(p))
{
@@ -510,7 +510,7 @@ void Channel::SetOwner(uint64 p, const char *newname)
return;
}
- if (newp->GetTeam() != plr->GetTeam() && !sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_CHANNEL))
+ if (newp->GetTeam() != player->GetTeam() && !sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_CHANNEL))
{
WorldPacket data;
MakePlayerNotFound(&data, newname);
@@ -563,12 +563,12 @@ void Channel::List(Player* player)
uint32 count = 0;
for (PlayerList::const_iterator i = players.begin(); i != players.end(); ++i)
{
- Player* plr = ObjectAccessor::FindPlayer(i->first);
+ Player* member = ObjectAccessor::FindPlayer(i->first);
// PLAYER can't see MODERATOR, GAME MASTER, ADMINISTRATOR characters
// MODERATOR, GAME MASTER, ADMINISTRATOR can see all
- if (plr && (!AccountMgr::IsPlayerAccount(player->GetSession()->GetSecurity()) || plr->GetSession()->GetSecurity() <= AccountTypes(gmLevelInWhoList)) &&
- plr->IsVisibleGloballyFor(player))
+ if (member && (!AccountMgr::IsPlayerAccount(player->GetSession()->GetSecurity()) || member->GetSession()->GetSecurity() <= AccountTypes(gmLevelInWhoList)) &&
+ member->IsVisibleGloballyFor(player))
{
data << uint64(i->first);
data << uint8(i->second.flags); // flags seems to be changed...
@@ -585,9 +585,9 @@ void Channel::List(Player* player)
void Channel::Announce(uint64 p)
{
uint32 sec = 0;
- Player* plr = ObjectAccessor::FindPlayer(p);
- if (plr)
- sec = plr->GetSession()->GetSecurity();
+ Player* player = ObjectAccessor::FindPlayer(p);
+ if (player)
+ sec = player->GetSession()->GetSecurity();
if (!IsOn(p))
{
@@ -623,7 +623,7 @@ void Channel::Say(uint64 p, const char *what, uint32 lang)
if (sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_CHANNEL))
lang = LANG_UNIVERSAL;
- Player* plr = ObjectAccessor::FindPlayer(p);
+ Player* player = ObjectAccessor::FindPlayer(p);
if (!IsOn(p))
{
@@ -650,7 +650,7 @@ void Channel::Say(uint64 p, const char *what, uint32 lang)
data << p;
data << messageLength;
data << what;
- data << uint8(plr ? plr->chatTag() : 0);
+ data << uint8(player ? player->GetChatTag() : 0);
SendToAll(&data, !players[p].IsModerator() ? p : false);
}
@@ -683,11 +683,11 @@ void Channel::Invite(uint64 p, const char *newname)
return;
}
- Player* plr = ObjectAccessor::FindPlayer(p);
- if (!plr)
+ Player* player = ObjectAccessor::FindPlayer(p);
+ if (!player)
return;
- if (newp->GetTeam() != plr->GetTeam() && !sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_CHANNEL))
+ if (newp->GetTeam() != player->GetTeam() && !sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_CHANNEL))
{
WorldPacket data;
MakeInviteWrongFaction(&data);
@@ -749,11 +749,11 @@ void Channel::SendToAll(WorldPacket* data, uint64 p)
{
for (PlayerList::const_iterator i = players.begin(); i != players.end(); ++i)
{
- Player* plr = ObjectAccessor::FindPlayer(i->first);
- if (plr)
+ Player* player = ObjectAccessor::FindPlayer(i->first);
+ if (player)
{
- if (!p || !plr->GetSocial()->HasIgnore(GUID_LOPART(p)))
- plr->GetSession()->SendPacket(data);
+ if (!p || !player->GetSocial()->HasIgnore(GUID_LOPART(p)))
+ player->GetSession()->SendPacket(data);
}
}
}
@@ -764,18 +764,18 @@ void Channel::SendToAllButOne(WorldPacket* data, uint64 who)
{
if (i->first != who)
{
- Player* plr = ObjectAccessor::FindPlayer(i->first);
- if (plr)
- plr->GetSession()->SendPacket(data);
+ Player* player = ObjectAccessor::FindPlayer(i->first);
+ if (player)
+ player->GetSession()->SendPacket(data);
}
}
}
void Channel::SendToOne(WorldPacket* data, uint64 who)
{
- Player* plr = ObjectAccessor::FindPlayer(who);
- if (plr)
- plr->GetSession()->SendPacket(data);
+ Player* player = ObjectAccessor::FindPlayer(who);
+ if (player)
+ player->GetSession()->SendPacket(data);
}
void Channel::Voice(uint64 /*guid1*/, uint64 /*guid2*/)
diff --git a/src/server/game/Chat/Chat.cpp b/src/server/game/Chat/Chat.cpp
index 8d03530c7f9..be43862eaea 100755
--- a/src/server/game/Chat/Chat.cpp
+++ b/src/server/game/Chat/Chat.cpp
@@ -1051,7 +1051,7 @@ void ChatHandler::FillMessageData(WorldPacket* data, WorldSession* session, uint
*data << uint32(messageLength);
*data << message;
if (session != 0 && type != CHAT_MSG_WHISPER_INFORM && type != CHAT_MSG_DND && type != CHAT_MSG_AFK)
- *data << uint8(session->GetPlayer()->chatTag());
+ *data << uint8(session->GetPlayer()->GetChatTag());
else
*data << uint8(0);
}
@@ -1224,7 +1224,7 @@ GameObject* ChatHandler::GetNearbyGameObject()
GameObject* obj = NULL;
Trinity::NearestGameObjectCheck check(*pl);
Trinity::GameObjectLastSearcher<Trinity::NearestGameObjectCheck> searcher(pl, obj, check);
- pl->VisitNearbyGridObject(999, searcher);
+ pl->VisitNearbyGridObject(SIZE_OF_GRIDS, searcher);
return obj;
}
@@ -1240,15 +1240,14 @@ GameObject* ChatHandler::GetObjectGlobalyWithGuidOrNearWithDbGuid(uint32 lowguid
if (!obj && sObjectMgr->GetGOData(lowguid)) // guid is DB guid of object
{
// search near player then
- CellPair p(Trinity::ComputeCellPair(pl->GetPositionX(), pl->GetPositionY()));
+ CellCoord p(Trinity::ComputeCellCoord(pl->GetPositionX(), pl->GetPositionY()));
Cell cell(p);
- cell.data.Part.reserved = ALL_DISTRICT;
Trinity::GameObjectWithDbGUIDCheck go_check(*pl, lowguid);
Trinity::GameObjectSearcher<Trinity::GameObjectWithDbGUIDCheck> checker(pl, obj, go_check);
TypeContainerVisitor<Trinity::GameObjectSearcher<Trinity::GameObjectWithDbGUIDCheck>, GridTypeMapContainer > object_checker(checker);
- cell.Visit(p, object_checker, *pl->GetMap());
+ cell.Visit(p, object_checker, *pl->GetMap(), *pl, pl->GetGridActivationRange());
}
return obj;
@@ -1552,9 +1551,9 @@ bool CliHandler::needReportToTarget(Player* /*chr*/) const
return true;
}
-bool ChatHandler::GetPlayerGroupAndGUIDByName(const char* cname, Player* &plr, Group* &group, uint64 &guid, bool offline)
+bool ChatHandler::GetPlayerGroupAndGUIDByName(const char* cname, Player* &player, Group* &group, uint64 &guid, bool offline)
{
- plr = NULL;
+ player = NULL;
guid = 0;
if (cname)
@@ -1569,28 +1568,28 @@ bool ChatHandler::GetPlayerGroupAndGUIDByName(const char* cname, Player* &plr, G
return false;
}
- plr = sObjectAccessor->FindPlayerByName(name.c_str());
+ player = sObjectAccessor->FindPlayerByName(name.c_str());
if (offline)
guid = sObjectMgr->GetPlayerGUIDByName(name.c_str());
}
}
- if (plr)
+ if (player)
{
- group = plr->GetGroup();
+ group = player->GetGroup();
if (!guid || !offline)
- guid = plr->GetGUID();
+ guid = player->GetGUID();
}
else
{
if (getSelectedPlayer())
- plr = getSelectedPlayer();
+ player = getSelectedPlayer();
else
- plr = m_session->GetPlayer();
+ player = m_session->GetPlayer();
if (!guid || !offline)
- guid = plr->GetGUID();
- group = plr->GetGroup();
+ guid = player->GetGUID();
+ group = player->GetGroup();
}
return true;
diff --git a/src/server/game/Chat/Chat.h b/src/server/game/Chat/Chat.h
index 6e34e39af5a..24652fcc6d5 100755
--- a/src/server/game/Chat/Chat.h
+++ b/src/server/game/Chat/Chat.h
@@ -109,7 +109,7 @@ class ChatHandler
uint32 extractSpellIdFromLink(char* text);
uint64 extractGuidFromLink(char* text);
GameTele const* extractGameTeleFromLink(char* text);
- bool GetPlayerGroupAndGUIDByName(const char* cname, Player* &plr, Group* &group, uint64 &guid, bool offline = false);
+ bool GetPlayerGroupAndGUIDByName(const char* cname, Player* &player, Group* &group, uint64 &guid, bool offline = false);
std::string extractPlayerNameFromLink(char* text);
// select by arg (name/link) or in-game selection online/offline player
bool extractPlayerTarget(char* args, Player** player, uint64* player_guid = NULL, std::string* player_name = NULL);
diff --git a/src/server/game/Chat/Commands/Level1.cpp b/src/server/game/Chat/Commands/Level1.cpp
index c737e2b0b54..f06f8a7e89c 100755
--- a/src/server/game/Chat/Commands/Level1.cpp
+++ b/src/server/game/Chat/Commands/Level1.cpp
@@ -713,18 +713,18 @@ bool ChatHandler::HandleGroupSummonCommand(const char* args)
for (GroupReference* itr = grp->GetFirstMember(); itr != NULL; itr = itr->next())
{
- Player* pl = itr->getSource();
+ Player* player = itr->getSource();
- if (!pl || pl == m_session->GetPlayer() || !pl->GetSession())
+ if (!player || player == m_session->GetPlayer() || !player->GetSession())
continue;
// check online security
- if (HasLowerSecurity(pl, 0))
+ if (HasLowerSecurity(player, 0))
return false;
- std::string plNameLink = GetNameLink(pl);
+ std::string plNameLink = GetNameLink(player);
- if (pl->IsBeingTeleported() == true)
+ if (player->IsBeingTeleported() == true)
{
PSendSysMessage(LANG_IS_TELEPORTED, plNameLink.c_str());
SetSentErrorMessage(true);
@@ -733,7 +733,7 @@ bool ChatHandler::HandleGroupSummonCommand(const char* args)
if (to_instance)
{
- Map* plMap = pl->GetMap();
+ Map* plMap = player->GetMap();
if (plMap->Instanceable() && plMap->GetInstanceId() != gmMap->GetInstanceId())
{
@@ -745,23 +745,23 @@ bool ChatHandler::HandleGroupSummonCommand(const char* args)
}
PSendSysMessage(LANG_SUMMONING, plNameLink.c_str(), "");
- if (needReportToTarget(pl))
- ChatHandler(pl).PSendSysMessage(LANG_SUMMONED_BY, GetNameLink().c_str());
+ if (needReportToTarget(player))
+ ChatHandler(player).PSendSysMessage(LANG_SUMMONED_BY, GetNameLink().c_str());
// stop flight if need
- if (pl->isInFlight())
+ if (player->isInFlight())
{
- pl->GetMotionMaster()->MovementExpired();
- pl->CleanupAfterTaxiFlight();
+ player->GetMotionMaster()->MovementExpired();
+ player->CleanupAfterTaxiFlight();
}
// save only in non-flight case
else
- pl->SaveRecallPosition();
+ player->SaveRecallPosition();
// before GM
float x, y, z;
- m_session->GetPlayer()->GetClosePoint(x, y, z, pl->GetObjectSize());
- pl->TeleportTo(m_session->GetPlayer()->GetMapId(), x, y, z, pl->GetOrientation());
+ m_session->GetPlayer()->GetClosePoint(x, y, z, player->GetObjectSize());
+ player->TeleportTo(m_session->GetPlayer()->GetMapId(), x, y, z, player->GetOrientation());
}
return true;
diff --git a/src/server/game/Chat/Commands/Level2.cpp b/src/server/game/Chat/Commands/Level2.cpp
index b4b0cff9ea7..1dd603094f6 100755
--- a/src/server/game/Chat/Commands/Level2.cpp
+++ b/src/server/game/Chat/Commands/Level2.cpp
@@ -349,18 +349,18 @@ bool ChatHandler::HandlePInfoCommand(const char* args)
std::string bannedby = "unknown";
std::string banreason = "";
- if (QueryResult result = LoginDatabase.PQuery("SELECT unbandate, bandate = unbandate, bannedby, banreason FROM account_banned "
+ if (QueryResult result2 = LoginDatabase.PQuery("SELECT unbandate, bandate = unbandate, bannedby, banreason FROM account_banned "
"WHERE id = '%u' AND active ORDER BY bandate ASC LIMIT 1", accId))
{
- Field* fields = result->Fetch();
+ Field* fields = result2->Fetch();
banTime = fields[1].GetBool() ? 0 : fields[0].GetUInt64();
bannedby = fields[2].GetString();
banreason = fields[3].GetString();
}
- else if (QueryResult result = CharacterDatabase.PQuery("SELECT unbandate, bandate = unbandate, bannedby, banreason FROM character_banned "
+ else if (QueryResult result3 = CharacterDatabase.PQuery("SELECT unbandate, bandate = unbandate, bannedby, banreason FROM character_banned "
"WHERE guid = '%u' AND active ORDER BY bandate ASC LIMIT 1", GUID_LOPART(target_guid)))
{
- Field* fields = result->Fetch();
+ Field* fields = result3->Fetch();
banTime = fields[1].GetBool() ? 0 : fields[0].GetUInt64();
bannedby = fields[2].GetString();
banreason = fields[3].GetString();
@@ -912,8 +912,8 @@ bool ChatHandler::HandlePetLearnCommand(const char* args)
if (!*args)
return false;
- Player* plr = m_session->GetPlayer();
- Pet* pet = plr->GetPet();
+ Player* player = m_session->GetPlayer();
+ Pet* pet = player->GetPet();
if (!pet)
{
@@ -955,8 +955,8 @@ bool ChatHandler::HandlePetUnlearnCommand(const char *args)
if (!*args)
return false;
- Player* plr = m_session->GetPlayer();
- Pet* pet = plr->GetPet();
+ Player* player = m_session->GetPlayer();
+ Pet* pet = player->GetPet();
if (!pet)
{
diff --git a/src/server/game/Chat/Commands/Level3.cpp b/src/server/game/Chat/Commands/Level3.cpp
index e76cbfcc76b..f4f5892b587 100755
--- a/src/server/game/Chat/Commands/Level3.cpp
+++ b/src/server/game/Chat/Commands/Level3.cpp
@@ -256,10 +256,10 @@ bool ChatHandler::HandleAddItemCommand(const char *args)
if (count == 0)
count = 1;
- Player* pl = m_session->GetPlayer();
+ Player* player = m_session->GetPlayer();
Player* plTarget = getSelectedPlayer();
if (!plTarget)
- plTarget = pl;
+ plTarget = player;
sLog->outDetail(GetTrinityString(LANG_ADDITEM), itemId, count);
@@ -298,15 +298,15 @@ bool ChatHandler::HandleAddItemCommand(const char *args)
Item* item = plTarget->StoreNewItem(dest, itemId, true, Item::GenerateItemRandomPropertyId(itemId));
// remove binding (let GM give it to another player later)
- if (pl == plTarget)
+ if (player == plTarget)
for (ItemPosCountVec::const_iterator itr = dest.begin(); itr != dest.end(); ++itr)
- if (Item* item1 = pl->GetItemByPos(itr->pos))
+ if (Item* item1 = player->GetItemByPos(itr->pos))
item1->SetBinding(false);
if (count > 0 && item)
{
- pl->SendNewItem(item, count, false, true);
- if (pl != plTarget)
+ player->SendNewItem(item, count, false, true);
+ if (player != plTarget)
plTarget->SendNewItem(item, count, true, false);
}
@@ -526,7 +526,7 @@ bool ChatHandler::HandleListItemCommand(const char *args)
"SELECT ah.itemguid, ah.itemowner, c.account, c.name FROM auctionhouse ah "
"INNER JOIN characters c ON c.guid = ah.itemowner "
"INNER JOIN item_instance ii ON ii.guid = ah.itemguid "
- "WHERE ii.itemEntry = '%u' AND LIMIT %u", item_id, count);
+ "WHERE ii.itemEntry = '%u' LIMIT %u", item_id, count);
}
else
result = QueryResult(NULL);
@@ -637,9 +637,9 @@ bool ChatHandler::HandleListObjectCommand(const char *args)
if (m_session)
{
- Player* pl = m_session->GetPlayer();
+ Player* player = m_session->GetPlayer();
result = WorldDatabase.PQuery("SELECT guid, position_x, position_y, position_z, map, id, (POW(position_x - '%f', 2) + POW(position_y - '%f', 2) + POW(position_z - '%f', 2)) AS order_ FROM gameobject WHERE id = '%u' ORDER BY order_ ASC LIMIT %u",
- pl->GetPositionX(), pl->GetPositionY(), pl->GetPositionZ(), go_id, uint32(count));
+ player->GetPositionX(), player->GetPositionY(), player->GetPositionZ(), go_id, uint32(count));
}
else
result = WorldDatabase.PQuery("SELECT guid, position_x, position_y, position_z, map, id FROM gameobject WHERE id = '%u' LIMIT %u",
@@ -709,9 +709,9 @@ bool ChatHandler::HandleListCreatureCommand(const char *args)
if (m_session)
{
- Player* pl = m_session->GetPlayer();
+ Player* player = m_session->GetPlayer();
result = WorldDatabase.PQuery("SELECT guid, position_x, position_y, position_z, map, (POW(position_x - '%f', 2) + POW(position_y - '%f', 2) + POW(position_z - '%f', 2)) AS order_ FROM creature WHERE id = '%u' ORDER BY order_ ASC LIMIT %u",
- pl->GetPositionX(), pl->GetPositionY(), pl->GetPositionZ(), cr_id, uint32(count));
+ player->GetPositionX(), player->GetPositionY(), player->GetPositionZ(), cr_id, uint32(count));
}
else
result = WorldDatabase.PQuery("SELECT guid, position_x, position_y, position_z, map FROM creature WHERE id = '%u' LIMIT %u",
@@ -1859,6 +1859,12 @@ bool ChatHandler::HandleDamageCommand(const char * args)
return false;
}
+ if (target->GetTypeId() == TYPEID_PLAYER)
+ {
+ if (HasLowerSecurity((Player*)target, 0, false))
+ return false;
+ }
+
if (!target->isAlive())
return true;
@@ -2671,7 +2677,7 @@ bool ChatHandler::HandleResetAllCommand(const char * args)
CharacterDatabase.PExecute("UPDATE characters SET at_login = at_login | '%u' WHERE (at_login & '%u') = '0'", atLogin, atLogin);
- ACE_GUARD_RETURN(ACE_Thread_Mutex, guard, *HashMapHolder<Player>::GetLock(), true);
+ TRINITY_READ_GUARD(HashMapHolder<Player>::LockType, *HashMapHolder<Player>::GetLock());
HashMapHolder<Player>::MapType const& plist = sObjectAccessor->GetPlayers();
for (HashMapHolder<Player>::MapType::const_iterator itr = plist.begin(); itr != plist.end(); ++itr)
itr->second->SetAtLoginFlag(atLogin);
@@ -3452,11 +3458,11 @@ bool ChatHandler::HandleBanListIPCommand(const char *args)
bool ChatHandler::HandleRespawnCommand(const char* /*args*/)
{
- Player* pl = m_session->GetPlayer();
+ Player* player = m_session->GetPlayer();
// accept only explicitly selected target (not implicitly self targeting case)
Unit* target = getSelectedUnit();
- if (pl->GetSelection() && target)
+ if (player->GetSelection() && target)
{
if (target->GetTypeId() != TYPEID_UNIT || target->isPet())
{
@@ -3470,16 +3476,15 @@ bool ChatHandler::HandleRespawnCommand(const char* /*args*/)
return true;
}
- CellPair p(Trinity::ComputeCellPair(pl->GetPositionX(), pl->GetPositionY()));
+ CellCoord p(Trinity::ComputeCellCoord(player->GetPositionX(), player->GetPositionY()));
Cell cell(p);
- cell.data.Part.reserved = ALL_DISTRICT;
cell.SetNoCreate();
Trinity::RespawnDo u_do;
- Trinity::WorldObjectWorker<Trinity::RespawnDo> worker(pl, u_do);
+ Trinity::WorldObjectWorker<Trinity::RespawnDo> worker(player, u_do);
TypeContainerVisitor<Trinity::WorldObjectWorker<Trinity::RespawnDo>, GridTypeMapContainer > obj_worker(worker);
- cell.Visit(p, obj_worker, *pl->GetMap());
+ cell.Visit(p, obj_worker, *player->GetMap(), *player, player->GetGridActivationRange());
return true;
}
@@ -4026,9 +4031,9 @@ bool ChatHandler::HandleComeToMeCommand(const char *args)
caster->SetUnitMovementFlags(newFlags);
- Player* pl = m_session->GetPlayer();
+ Player* player = m_session->GetPlayer();
- caster->GetMotionMaster()->MovePoint(0, pl->GetPositionX(), pl->GetPositionY(), pl->GetPositionZ());
+ caster->GetMotionMaster()->MovePoint(0, player->GetPositionX(), player->GetPositionY(), player->GetPositionZ());
return true;
}
@@ -4172,9 +4177,9 @@ bool ChatHandler::HandleInstanceStatsCommand(const char* /*args*/)
bool ChatHandler::HandleInstanceSaveDataCommand(const char * /*args*/)
{
- Player* pl = m_session->GetPlayer();
+ Player* player = m_session->GetPlayer();
- Map* map = pl->GetMap();
+ Map* map = player->GetMap();
if (!map->IsDungeon())
{
PSendSysMessage("Map is not a dungeon.");
@@ -4644,12 +4649,12 @@ bool ChatHandler::HandleListFreezeCommand(const char * /*args*/)
bool ChatHandler::HandleGroupLeaderCommand(const char *args)
{
- Player* plr = NULL;
+ Player* player = NULL;
Group* group = NULL;
uint64 guid = 0;
char* cname = strtok((char*)args, " ");
- if (GetPlayerGroupAndGUIDByName(cname, plr, group, guid))
+ if (GetPlayerGroupAndGUIDByName(cname, player, group, guid))
if (group && group->GetLeaderGUID() != guid)
{
group->ChangeLeader(guid);
@@ -4661,12 +4666,12 @@ bool ChatHandler::HandleGroupLeaderCommand(const char *args)
bool ChatHandler::HandleGroupDisbandCommand(const char *args)
{
- Player* plr = NULL;
+ Player* player = NULL;
Group* group = NULL;
uint64 guid = 0;
char* cname = strtok((char*)args, " ");
- if (GetPlayerGroupAndGUIDByName(cname, plr, group, guid))
+ if (GetPlayerGroupAndGUIDByName(cname, player, group, guid))
if (group)
group->Disband();
@@ -4675,12 +4680,12 @@ bool ChatHandler::HandleGroupDisbandCommand(const char *args)
bool ChatHandler::HandleGroupRemoveCommand(const char *args)
{
- Player* plr = NULL;
+ Player* player = NULL;
Group* group = NULL;
uint64 guid = 0;
char* cname = strtok((char*)args, " ");
- if (GetPlayerGroupAndGUIDByName(cname, plr, group, guid, true))
+ if (GetPlayerGroupAndGUIDByName(cname, player, group, guid, true))
if (group)
group->RemoveMember(guid);
diff --git a/src/server/game/Conditions/DisableMgr.cpp b/src/server/game/Conditions/DisableMgr.cpp
index dafb0ebc11f..07febf889d0 100755
--- a/src/server/game/Conditions/DisableMgr.cpp
+++ b/src/server/game/Conditions/DisableMgr.cpp
@@ -277,26 +277,25 @@ bool IsDisabledFor(DisableType type, uint32 entry, Unit const* unit, uint8 flags
{
case DISABLE_TYPE_SPELL:
{
- uint8 flags = itr->second.flags;
+ uint8 spellFlags = itr->second.flags;
if (unit)
{
-
- if ((flags & SPELL_DISABLE_PLAYER && unit->GetTypeId() == TYPEID_PLAYER) ||
- (unit->GetTypeId() == TYPEID_UNIT && ((unit->ToCreature()->isPet() && flags & SPELL_DISABLE_PET) || flags & SPELL_DISABLE_CREATURE)))
+ if ((spellFlags & SPELL_DISABLE_PLAYER && unit->GetTypeId() == TYPEID_PLAYER) ||
+ (unit->GetTypeId() == TYPEID_UNIT && ((unit->ToCreature()->isPet() && spellFlags & SPELL_DISABLE_PET) || spellFlags & SPELL_DISABLE_CREATURE)))
{
- if (flags & SPELL_DISABLE_MAP)
+ if (spellFlags & SPELL_DISABLE_MAP)
{
std::set<uint32> const& mapIds = itr->second.params[0];
if (mapIds.find(unit->GetMapId()) != mapIds.end())
return true; // Spell is disabled on current map
- if (!(flags & SPELL_DISABLE_AREA))
+ if (!(spellFlags & SPELL_DISABLE_AREA))
return false; // Spell is disabled on another map, but not this one, return false
// Spell is disabled in an area, but not explicitly our current mapId. Continue processing.
}
- if (flags & SPELL_DISABLE_AREA)
+ if (spellFlags & SPELL_DISABLE_AREA)
{
std::set<uint32> const& areaIds = itr->second.params[1];
if (areaIds.find(unit->GetAreaId()) != areaIds.end())
@@ -309,8 +308,10 @@ bool IsDisabledFor(DisableType type, uint32 entry, Unit const* unit, uint8 flags
return false;
}
- else if (flags & SPELL_DISABLE_DEPRECATED_SPELL) // call not from spellcast
+ else if (spellFlags & SPELL_DISABLE_DEPRECATED_SPELL) // call not from spellcast
return true;
+
+ break;
}
case DISABLE_TYPE_MAP:
if (Player const* player = unit->ToPlayer())
diff --git a/src/server/game/DataStores/DBCStores.cpp b/src/server/game/DataStores/DBCStores.cpp
index faa73cefb11..6815d73d1b3 100755
--- a/src/server/game/DataStores/DBCStores.cpp
+++ b/src/server/game/DataStores/DBCStores.cpp
@@ -71,6 +71,7 @@ DBCStorage <ChrRacesEntry> sChrRacesStore(ChrRacesEntryfmt);
DBCStorage <CinematicSequencesEntry> sCinematicSequencesStore(CinematicSequencesEntryfmt);
DBCStorage <CreatureDisplayInfoEntry> sCreatureDisplayInfoStore(CreatureDisplayInfofmt);
DBCStorage <CreatureFamilyEntry> sCreatureFamilyStore(CreatureFamilyfmt);
+DBCStorage <CreatureModelDataEntry> sCreatureModelDataStore(CreatureModelDatafmt);
DBCStorage <CreatureSpellDataEntry> sCreatureSpellDataStore(CreatureSpellDatafmt);
DBCStorage <CreatureTypeEntry> sCreatureTypeStore(CreatureTypefmt);
DBCStorage <CurrencyTypesEntry> sCurrencyTypesStore(CurrencyTypesfmt);
@@ -292,6 +293,7 @@ void LoadDBCStores(const std::string& dataPath)
LoadDBC(availableDbcLocales, bad_dbc_files, sCinematicSequencesStore, dbcPath, "CinematicSequences.dbc");
LoadDBC(availableDbcLocales, bad_dbc_files, sCreatureDisplayInfoStore, dbcPath, "CreatureDisplayInfo.dbc");
LoadDBC(availableDbcLocales, bad_dbc_files, sCreatureFamilyStore, dbcPath, "CreatureFamily.dbc");
+ LoadDBC(availableDbcLocales, bad_dbc_files, sCreatureModelDataStore, dbcPath, "CreatureModelData.dbc");
LoadDBC(availableDbcLocales, bad_dbc_files, sCreatureSpellDataStore, dbcPath, "CreatureSpellData.dbc");
LoadDBC(availableDbcLocales, bad_dbc_files, sCreatureTypeStore, dbcPath, "CreatureType.dbc");
LoadDBC(availableDbcLocales, bad_dbc_files, sCurrencyTypesStore, dbcPath, "CurrencyTypes.dbc");
diff --git a/src/server/game/DataStores/DBCStores.h b/src/server/game/DataStores/DBCStores.h
index 367746616d1..7edfaad03f1 100755
--- a/src/server/game/DataStores/DBCStores.h
+++ b/src/server/game/DataStores/DBCStores.h
@@ -81,6 +81,7 @@ extern DBCStorage <ChrRacesEntry> sChrRacesStore;
extern DBCStorage <CinematicSequencesEntry> sCinematicSequencesStore;
extern DBCStorage <CreatureDisplayInfoEntry> sCreatureDisplayInfoStore;
extern DBCStorage <CreatureFamilyEntry> sCreatureFamilyStore;
+extern DBCStorage <CreatureModelDataEntry> sCreatureModelDataStore;
extern DBCStorage <CreatureSpellDataEntry> sCreatureSpellDataStore;
extern DBCStorage <CreatureTypeEntry> sCreatureTypeStore;
extern DBCStorage <CurrencyTypesEntry> sCurrencyTypesStore;
diff --git a/src/server/game/DataStores/DBCStructure.h b/src/server/game/DataStores/DBCStructure.h
index e01acd2e03d..ba7be495c77 100755
--- a/src/server/game/DataStores/DBCStructure.h
+++ b/src/server/game/DataStores/DBCStructure.h
@@ -723,7 +723,7 @@ struct CinematicSequencesEntry
struct CreatureDisplayInfoEntry
{
uint32 Displayid; // 0 m_ID
- // 1 m_modelID
+ uint32 ModelId; // 1 m_modelID
// 2 m_soundID
// 3 m_extendedDisplayInfoID
float scale; // 4 m_creatureModelScale
@@ -754,6 +754,28 @@ struct CreatureFamilyEntry
// 27 m_iconFile
};
+struct CreatureModelDataEntry
+{
+ uint32 Id;
+ //uint32 Flags;
+ //char* ModelPath[16]
+ //uint32 Unk1;
+ float Scale; // Used in calculation of unit collision data
+ //int32 Unk2
+ //int32 Unk3
+ //uint32 Unk4
+ //uint32 Unk5
+ //float Unk6
+ //uint32 Unk7
+ //float Unk8
+ //uint32 Unk9
+ //uint32 Unk10
+ //float CollisionWidth;
+ float CollisionHeight;
+ float MountHeight; // Used in calculation of unit collision data when mounted
+ //float Unks[11]
+};
+
#define MAX_CREATURE_SPELL_DATA_SLOT 4
struct CreatureSpellDataEntry
diff --git a/src/server/game/DataStores/DBCfmt.h b/src/server/game/DataStores/DBCfmt.h
index 5d33a3011ab..ac0b60d7f80 100755
--- a/src/server/game/DataStores/DBCfmt.h
+++ b/src/server/game/DataStores/DBCfmt.h
@@ -38,8 +38,9 @@ const char ChatChannelsEntryfmt[]="nixssssssssssssssssxxxxxxxxxxxxxxxxxx";
const char ChrClassesEntryfmt[]="nxixxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxixii";
const char ChrRacesEntryfmt[]="nxixiixixxxxixssssssssssssssssxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxi";
const char CinematicSequencesEntryfmt[]="nxxxxxxxxx";
-const char CreatureDisplayInfofmt[]="nxxxfxxxxxxxxxxx";
+const char CreatureDisplayInfofmt[]="nixxfxxxxxxxxxxx";
const char CreatureFamilyfmt[]="nfifiiiiixssssssssssssssssxx";
+const char CreatureModelDatafmt[]="nxxxfxxxxxxxxxxffxxxxxxxxxxx";
const char CreatureSpellDatafmt[]="niiiixxxx";
const char CreatureTypefmt[]="nxxxxxxxxxxxxxxxxxx";
const char CurrencyTypesfmt[]="xnxi";
diff --git a/src/server/game/DungeonFinding/LFGMgr.cpp b/src/server/game/DungeonFinding/LFGMgr.cpp
index 52b41c0a0f7..55f798204db 100755
--- a/src/server/game/DungeonFinding/LFGMgr.cpp
+++ b/src/server/game/DungeonFinding/LFGMgr.cpp
@@ -159,12 +159,12 @@ void LFGMgr::Update(uint32 diff)
{
uint64 guid = itRoles->first;
ClearState(guid);
- if (Player* plr = ObjectAccessor::FindPlayer(guid))
+ if (Player* player = ObjectAccessor::FindPlayer(guid))
{
- plr->GetSession()->SendLfgRoleCheckUpdate(roleCheck);
+ player->GetSession()->SendLfgRoleCheckUpdate(roleCheck);
if (itRoles->first == roleCheck->leader)
- plr->GetSession()->SendLfgJoinResult(LfgJoinResultData(LFG_JOIN_FAILED, LFG_ROLECHECK_MISSING_ROLE));
+ player->GetSession()->SendLfgJoinResult(LfgJoinResultData(LFG_JOIN_FAILED, LFG_ROLECHECK_MISSING_ROLE));
}
}
delete roleCheck;
@@ -226,18 +226,18 @@ void LFGMgr::Update(uint32 diff)
{
guid = itPlayers->first;
SetState(guid, LFG_STATE_PROPOSAL);
- if (Player* plr = ObjectAccessor::FindPlayer(itPlayers->first))
+ if (Player* player = ObjectAccessor::FindPlayer(itPlayers->first))
{
- Group* grp = plr->GetGroup();
+ Group* grp = player->GetGroup();
if (grp)
{
uint64 gguid = grp->GetGUID();
SetState(gguid, LFG_STATE_PROPOSAL);
- plr->GetSession()->SendLfgUpdateParty(LfgUpdateData(LFG_UPDATETYPE_PROPOSAL_BEGIN, GetSelectedDungeons(guid), GetComment(guid)));
+ player->GetSession()->SendLfgUpdateParty(LfgUpdateData(LFG_UPDATETYPE_PROPOSAL_BEGIN, GetSelectedDungeons(guid), GetComment(guid)));
}
else
- plr->GetSession()->SendLfgUpdatePlayer(LfgUpdateData(LFG_UPDATETYPE_PROPOSAL_BEGIN, GetSelectedDungeons(guid), GetComment(guid)));
- plr->GetSession()->SendLfgUpdateProposal(m_lfgProposalId, pProposal);
+ player->GetSession()->SendLfgUpdatePlayer(LfgUpdateData(LFG_UPDATETYPE_PROPOSAL_BEGIN, GetSelectedDungeons(guid), GetComment(guid)));
+ player->GetSession()->SendLfgUpdateProposal(m_lfgProposalId, pProposal);
}
}
@@ -254,7 +254,7 @@ void LFGMgr::Update(uint32 diff)
if (m_QueueTimer > LFG_QUEUEUPDATE_INTERVAL)
{
m_QueueTimer = 0;
- time_t currTime = time(NULL);
+ currTime = time(NULL);
for (LfgQueueInfoMap::const_iterator itQueue = m_QueueInfoMap.begin(); itQueue != m_QueueInfoMap.end(); ++itQueue)
{
LfgQueueInfo* queue = itQueue->second;
@@ -291,8 +291,8 @@ void LFGMgr::Update(uint32 diff)
}
for (LfgRolesMap::const_iterator itPlayer = queue->roles.begin(); itPlayer != queue->roles.end(); ++itPlayer)
- if (Player* plr = ObjectAccessor::FindPlayer(itPlayer->first))
- plr->GetSession()->SendLfgQueueStatus(dungeonId, waitTime, m_WaitTimeAvg, m_WaitTimeTank, m_WaitTimeHealer, m_WaitTimeDps, queuedTime, queue->tanks, queue->healers, queue->dps);
+ if (Player* player = ObjectAccessor::FindPlayer(itPlayer->first))
+ player->GetSession()->SendLfgQueueStatus(dungeonId, waitTime, m_WaitTimeAvg, m_WaitTimeTank, m_WaitTimeHealer, m_WaitTimeDps, queuedTime, queue->tanks, queue->healers, queue->dps);
}
}
else
@@ -358,13 +358,13 @@ bool LFGMgr::RemoveFromQueue(uint64 guid)
/**
Generate the dungeon lock map for a given player
- @param[in] plr Player we need to initialize the lock status map
+ @param[in] player Player we need to initialize the lock status map
*/
-void LFGMgr::InitializeLockedDungeons(Player* plr)
+void LFGMgr::InitializeLockedDungeons(Player* player)
{
- uint64 guid = plr->GetGUID();
- uint8 level = plr->getLevel();
- uint8 expansion = plr->GetSession()->Expansion();
+ uint64 guid = player->GetGUID();
+ uint8 level = player->getLevel();
+ uint8 expansion = player->GetSession()->Expansion();
LfgDungeonSet dungeons = GetDungeonsByRandom(0);
LfgLockMap lock;
@@ -379,9 +379,9 @@ void LFGMgr::InitializeLockedDungeons(Player* plr)
LfgLockStatusType locktype = LFG_LOCKSTATUS_OK;
if (dungeon->expansion > expansion)
locktype = LFG_LOCKSTATUS_INSUFFICIENT_EXPANSION;
- else if (DisableMgr::IsDisabledFor(DISABLE_TYPE_MAP, dungeon->map, plr))
+ else if (DisableMgr::IsDisabledFor(DISABLE_TYPE_MAP, dungeon->map, player))
locktype = LFG_LOCKSTATUS_RAID_LOCKED;
- else if (dungeon->difficulty > DUNGEON_DIFFICULTY_NORMAL && plr->GetBoundInstance(dungeon->map, Difficulty(dungeon->difficulty)))
+ else if (dungeon->difficulty > DUNGEON_DIFFICULTY_NORMAL && player->GetBoundInstance(dungeon->map, Difficulty(dungeon->difficulty)))
locktype = LFG_LOCKSTATUS_RAID_LOCKED;
else if (dungeon->minlevel > level)
locktype = LFG_LOCKSTATUS_TOO_LOW_LEVEL;
@@ -389,19 +389,19 @@ void LFGMgr::InitializeLockedDungeons(Player* plr)
locktype = LFG_LOCKSTATUS_TOO_HIGH_LEVEL;
else if (locktype == LFG_LOCKSTATUS_OK && ar)
{
- if (ar->achievement && !plr->GetAchievementMgr().HasAchieved(sAchievementStore.LookupEntry(ar->achievement)))
+ if (ar->achievement && !player->GetAchievementMgr().HasAchieved(sAchievementStore.LookupEntry(ar->achievement)))
locktype = LFG_LOCKSTATUS_RAID_LOCKED; // FIXME: Check the correct lock value
- else if (plr->GetTeam() == ALLIANCE && ar->quest_A && !plr->GetQuestRewardStatus(ar->quest_A))
+ else if (player->GetTeam() == ALLIANCE && ar->quest_A && !player->GetQuestRewardStatus(ar->quest_A))
locktype = LFG_LOCKSTATUS_QUEST_NOT_COMPLETED;
- else if (plr->GetTeam() == HORDE && ar->quest_H && !plr->GetQuestRewardStatus(ar->quest_H))
+ else if (player->GetTeam() == HORDE && ar->quest_H && !player->GetQuestRewardStatus(ar->quest_H))
locktype = LFG_LOCKSTATUS_QUEST_NOT_COMPLETED;
else
if (ar->item)
{
- if (!plr->HasItemCount(ar->item, 1) && (!ar->item2 || !plr->HasItemCount(ar->item2, 1)))
+ if (!player->HasItemCount(ar->item, 1) && (!ar->item2 || !player->HasItemCount(ar->item2, 1)))
locktype = LFG_LOCKSTATUS_MISSING_ITEM;
}
- else if (ar->item2 && !plr->HasItemCount(ar->item2, 1))
+ else if (ar->item2 && !player->HasItemCount(ar->item2, 1))
locktype = LFG_LOCKSTATUS_MISSING_ITEM;
}
/* TODO VoA closed if WG is not under team control (LFG_LOCKSTATUS_RAID_LOCKED)
@@ -423,18 +423,18 @@ void LFGMgr::InitializeLockedDungeons(Player* plr)
of the group tying to join the group. Join conditions are checked before adding
to the new queue.
- @param[in] plr Player trying to join (or leader of group trying to join)
+ @param[in] player Player trying to join (or leader of group trying to join)
@param[in] roles Player selected roles
@param[in] dungeons Dungeons the player/group is applying for
@param[in] comment Player selected comment
*/
-void LFGMgr::Join(Player* plr, uint8 roles, const LfgDungeonSet& selectedDungeons, const std::string& comment)
+void LFGMgr::Join(Player* player, uint8 roles, const LfgDungeonSet& selectedDungeons, const std::string& comment)
{
- if (!plr || !plr->GetSession() || selectedDungeons.empty())
+ if (!player || !player->GetSession() || selectedDungeons.empty())
return;
- Group* grp = plr->GetGroup();
- uint64 guid = plr->GetGUID();
+ Group* grp = player->GetGroup();
+ uint64 guid = player->GetGUID();
uint64 gguid = grp ? grp->GetGUID() : guid;
LfgJoinResultData joinData;
PlayerSet players;
@@ -457,7 +457,7 @@ void LFGMgr::Join(Player* plr, uint8 roles, const LfgDungeonSet& selectedDungeon
if (playerDungeons == dungeons) // Joining the same dungeons -- Send OK
{
LfgUpdateData updateData = LfgUpdateData(LFG_UPDATETYPE_ADDED_TO_QUEUE, dungeons, comment);
- plr->GetSession()->SendLfgJoinResult(joinData); // Default value of joinData.result = LFG_JOIN_OK
+ player->GetSession()->SendLfgJoinResult(joinData); // Default value of joinData.result = LFG_JOIN_OK
if (grp)
{
for (GroupReference* itr = grp->GetFirstMember(); itr != NULL; itr = itr->next())
@@ -471,11 +471,11 @@ void LFGMgr::Join(Player* plr, uint8 roles, const LfgDungeonSet& selectedDungeon
}
// Check player or group member restrictions
- if (plr->InBattleground() || plr->InArena() || plr->InBattlegroundQueue())
+ if (player->InBattleground() || player->InArena() || player->InBattlegroundQueue())
joinData.result = LFG_JOIN_USING_BG_SYSTEM;
- else if (plr->HasAura(LFG_SPELL_DUNGEON_DESERTER))
+ else if (player->HasAura(LFG_SPELL_DUNGEON_DESERTER))
joinData.result = LFG_JOIN_DESERTER;
- else if (plr->HasAura(LFG_SPELL_DUNGEON_COOLDOWN))
+ else if (player->HasAura(LFG_SPELL_DUNGEON_COOLDOWN))
joinData.result = LFG_JOIN_RANDOM_COOLDOWN;
else if (dungeons.empty())
joinData.result = LFG_JOIN_NOT_MEET_REQS;
@@ -505,7 +505,7 @@ void LFGMgr::Join(Player* plr, uint8 roles, const LfgDungeonSet& selectedDungeon
}
}
else
- players.insert(plr);
+ players.insert(player);
// Check if all dungeons are valid
bool isRaid = false;
@@ -559,7 +559,7 @@ void LFGMgr::Join(Player* plr, uint8 roles, const LfgDungeonSet& selectedDungeon
sLog->outDebug(LOG_FILTER_LFG, "LFGMgr::Join: [" UI64FMTD "] joining with %u members. result: %u", guid, grp ? grp->GetMembersCount() : 1, joinData.result);
if (!dungeons.empty()) // Only should show lockmap when have no dungeons available
joinData.lockmap.clear();
- plr->GetSession()->SendLfgJoinResult(joinData);
+ player->GetSession()->SendLfgJoinResult(joinData);
return;
}
@@ -612,7 +612,7 @@ void LFGMgr::Join(Player* plr, uint8 roles, const LfgDungeonSet& selectedDungeon
// Queue player
LfgQueueInfo* pqInfo = new LfgQueueInfo();
pqInfo->joinTime = time_t(time(NULL));
- pqInfo->roles[plr->GetGUID()] = roles;
+ pqInfo->roles[player->GetGUID()] = roles;
pqInfo->dungeons = dungeons;
if (roles & ROLE_TANK)
--pqInfo->tanks;
@@ -623,8 +623,8 @@ void LFGMgr::Join(Player* plr, uint8 roles, const LfgDungeonSet& selectedDungeon
m_QueueInfoMap[guid] = pqInfo;
// Send update to player
- plr->GetSession()->SendLfgJoinResult(joinData);
- plr->GetSession()->SendLfgUpdatePlayer(LfgUpdateData(LFG_UPDATETYPE_JOIN_PROPOSAL, dungeons, comment));
+ player->GetSession()->SendLfgJoinResult(joinData);
+ player->GetSession()->SendLfgUpdatePlayer(LfgUpdateData(LFG_UPDATETYPE_JOIN_PROPOSAL, dungeons, comment));
SetState(gguid, LFG_STATE_QUEUED);
SetRoles(guid, roles);
if (!isContinue)
@@ -636,7 +636,7 @@ void LFGMgr::Join(Player* plr, uint8 roles, const LfgDungeonSet& selectedDungeon
}
SetSelectedDungeons(guid, dungeons);
}
- AddToQueue(guid, uint8(plr->GetTeam()));
+ AddToQueue(guid, uint8(player->GetTeam()));
}
sLog->outDebug(LOG_FILTER_LFG, "LFGMgr::Join: [" UI64FMTD "] joined with %u members. dungeons: %u", guid, grp ? grp->GetMembersCount() : 1, uint8(dungeons.size()));
}
@@ -645,15 +645,15 @@ void LFGMgr::Join(Player* plr, uint8 roles, const LfgDungeonSet& selectedDungeon
Leaves Dungeon System. Player/Group is removed from queue, rolechecks, proposals
or votekicks. Player or group needs to be not NULL and using Dungeon System
- @param[in] plr Player trying to leave (can be NULL)
+ @param[in] player Player trying to leave (can be NULL)
@param[in] grp Group trying to leave (default NULL)
*/
-void LFGMgr::Leave(Player* plr, Group* grp /* = NULL*/)
+void LFGMgr::Leave(Player* player, Group* grp /* = NULL*/)
{
- if (!plr && !grp)
+ if (!player && !grp)
return;
- uint64 guid = grp ? grp->GetGUID() : plr->GetGUID();
+ uint64 guid = grp ? grp->GetGUID() : player->GetGUID();
LfgState state = GetState(guid);
sLog->outDebug(LOG_FILTER_LFG, "LFGMgr::Leave: [" UI64FMTD "]", guid);
@@ -676,7 +676,7 @@ void LFGMgr::Leave(Player* plr, Group* grp /* = NULL*/)
}
else
{
- plr->GetSession()->SendLfgUpdatePlayer(updateData);
+ player->GetSession()->SendLfgUpdatePlayer(updateData);
ClearState(guid);
}
}
@@ -689,10 +689,9 @@ void LFGMgr::Leave(Player* plr, Group* grp /* = NULL*/)
{
// Remove from Proposals
LfgProposalMap::iterator it = m_Proposals.begin();
- uint64 guid = plr ? plr->GetGUID() : grp->GetLeaderGUID();
while (it != m_Proposals.end())
{
- LfgProposalPlayerMap::iterator itPlayer = it->second->players.find(guid);
+ LfgProposalPlayerMap::iterator itPlayer = it->second->players.find(player ? player->GetGUID() : grp->GetLeaderGUID());
if (itPlayer != it->second->players.end())
{
// Mark the player/leader of group who left as didn't accept the proposal
@@ -866,22 +865,22 @@ bool LFGMgr::CheckCompatibility(LfgGuidList check, LfgProposal*& pProposal)
PlayerSet players;
for (LfgRolesMap::const_iterator it = rolesMap.begin(); it != rolesMap.end(); ++it)
{
- Player* plr = ObjectAccessor::FindPlayer(it->first);
- if (!plr)
+ Player* player = ObjectAccessor::FindPlayer(it->first);
+ if (!player)
sLog->outDebug(LOG_FILTER_LFG, "LFGMgr::CheckCompatibility: (%s) Warning! [" UI64FMTD "] offline! Marking as not compatibles!", strGuids.c_str(), it->first);
else
{
- for (PlayerSet::const_iterator itPlayer = players.begin(); itPlayer != players.end() && plr; ++itPlayer)
+ for (PlayerSet::const_iterator itPlayer = players.begin(); itPlayer != players.end() && player; ++itPlayer)
{
// Do not form a group with ignoring candidates
- if (plr->GetSocial()->HasIgnore((*itPlayer)->GetGUIDLow()) || (*itPlayer)->GetSocial()->HasIgnore(plr->GetGUIDLow()))
+ if (player->GetSocial()->HasIgnore((*itPlayer)->GetGUIDLow()) || (*itPlayer)->GetSocial()->HasIgnore(player->GetGUIDLow()))
{
- sLog->outDebug(LOG_FILTER_LFG, "LFGMgr::CheckCompatibility: (%s) Players [" UI64FMTD "] and [" UI64FMTD "] ignoring", strGuids.c_str(), (*itPlayer)->GetGUID(), plr->GetGUID());
- plr = NULL;
+ sLog->outDebug(LOG_FILTER_LFG, "LFGMgr::CheckCompatibility: (%s) Players [" UI64FMTD "] and [" UI64FMTD "] ignoring", strGuids.c_str(), (*itPlayer)->GetGUID(), player->GetGUID());
+ player = NULL;
}
}
- if (plr)
- players.insert(plr);
+ if (player)
+ players.insert(player);
}
}
@@ -1069,10 +1068,10 @@ void LFGMgr::UpdateRoleCheck(uint64 gguid, uint64 guid /* = 0 */, uint8 roles /*
// Set queue roles needed - As we are using check_roles will not have more that 1 tank, 1 healer, 3 dps
for (LfgRolesMap::const_iterator it = check_roles.begin(); it != check_roles.end(); ++it)
{
- uint8 roles = it->second;
- if (roles & ROLE_TANK)
+ uint8 roles2 = it->second;
+ if (roles2 & ROLE_TANK)
--pqInfo->tanks;
- else if (roles & ROLE_HEALER)
+ else if (roles2 & ROLE_HEALER)
--pqInfo->healers;
else
--pqInfo->dps;
@@ -1152,14 +1151,14 @@ void LFGMgr::GetCompatibleDungeons(LfgDungeonSet& dungeons, const PlayerSet& pla
{
uint64 guid = (*it)->GetGUID();
LfgLockMap cachedLockMap = GetLockedDungeons(guid);
- for (LfgLockMap::const_iterator it = cachedLockMap.begin(); it != cachedLockMap.end() && dungeons.size(); ++it)
+ for (LfgLockMap::const_iterator it2 = cachedLockMap.begin(); it2 != cachedLockMap.end() && dungeons.size(); ++it2)
{
- uint32 dungeonId = (it->first & 0x00FFFFFF); // Compare dungeon ids
+ uint32 dungeonId = (it2->first & 0x00FFFFFF); // Compare dungeon ids
LfgDungeonSet::iterator itDungeon = dungeons.find(dungeonId);
if (itDungeon != dungeons.end())
{
dungeons.erase(itDungeon);
- lockMap[guid][dungeonId] = it->second;
+ lockMap[guid][dungeonId] = it2->second;
}
}
}
@@ -1276,18 +1275,18 @@ void LFGMgr::UpdateProposal(uint32 proposalId, uint64 guid, bool accept)
bool allAnswered = true;
for (LfgProposalPlayerMap::const_iterator itPlayers = pProposal->players.begin(); itPlayers != pProposal->players.end(); ++itPlayers)
{
- if (Player* plr = ObjectAccessor::FindPlayer(itPlayers->first))
+ if (Player* player = ObjectAccessor::FindPlayer(itPlayers->first))
{
if (itPlayers->first == pProposal->leader)
- players.push_front(plr);
+ players.push_front(player);
else
- players.push_back(plr);
+ players.push_back(player);
// Only teleport new players
- Group* grp = plr->GetGroup();
+ Group* grp = player->GetGroup();
uint64 gguid = grp ? grp->GetGUID() : 0;
if (!gguid || !grp->isLFGGroup() || GetState(gguid) == LFG_STATE_FINISHED_DUNGEON)
- playersToTeleport.push_back(plr);
+ playersToTeleport.push_back(player);
}
if (itPlayers->second->accept != LFG_ANSWER_AGREE) // No answer (-1) or not accepted (0)
@@ -1313,8 +1312,8 @@ void LFGMgr::UpdateProposal(uint32 proposalId, uint64 guid, bool accept)
if (player->groupLowGuid != lowgroupguid)
sLog->outError("LFGMgr::UpdateProposal: [" UI64FMTD "] group mismatch: actual (%u) - queued (%u)", (*it)->GetGUID(), lowgroupguid, player->groupLowGuid);
- uint64 guid = player->groupLowGuid ? MAKE_NEW_GUID(player->groupLowGuid, 0, HIGHGUID_GROUP) : (*it)->GetGUID();
- LfgQueueInfoMap::iterator itQueue = m_QueueInfoMap.find(guid);
+ uint64 guid2 = player->groupLowGuid ? MAKE_NEW_GUID(player->groupLowGuid, 0, HIGHGUID_GROUP) : (*it)->GetGUID();
+ LfgQueueInfoMap::iterator itQueue = m_QueueInfoMap.find(guid2);
if (itQueue == m_QueueInfoMap.end())
{
sLog->outError("LFGMgr::UpdateProposal: Queue info for guid [" UI64FMTD "] not found!", guid);
@@ -1329,31 +1328,31 @@ void LFGMgr::UpdateProposal(uint32 proposalId, uint64 guid, bool accept)
Group* grp = pProposal->groupLowGuid ? sGroupMgr->GetGroupByGUID(pProposal->groupLowGuid) : NULL;
for (LfgPlayerList::const_iterator it = players.begin(); it != players.end(); ++it)
{
- Player* plr = (*it);
- uint64 pguid = plr->GetGUID();
- Group* group = plr->GetGroup();
+ Player* player = (*it);
+ uint64 pguid = player->GetGUID();
+ Group* group = player->GetGroup();
if (sendUpdate)
- plr->GetSession()->SendLfgUpdateProposal(proposalId, pProposal);
+ player->GetSession()->SendLfgUpdateProposal(proposalId, pProposal);
if (group)
{
- plr->GetSession()->SendLfgUpdateParty(updateData);
+ player->GetSession()->SendLfgUpdateParty(updateData);
if (group != grp)
- plr->RemoveFromGroup();
+ player->RemoveFromGroup();
}
else
- plr->GetSession()->SendLfgUpdatePlayer(updateData);
+ player->GetSession()->SendLfgUpdatePlayer(updateData);
if (!grp)
{
grp = new Group();
- grp->Create(plr);
+ grp->Create(player);
grp->ConvertToLFG();
uint64 gguid = grp->GetGUID();
SetState(gguid, LFG_STATE_PROPOSAL);
sGroupMgr->AddGroup(grp);
}
else if (group != grp)
- grp->AddMember(plr);
+ grp->AddMember(player);
// Update timers
uint8 role = GetRoles(pguid);
@@ -1363,25 +1362,25 @@ void LFGMgr::UpdateProposal(uint32 proposalId, uint64 guid, bool accept)
case ROLE_DAMAGE:
{
uint32 old_number = m_NumWaitTimeDps++;
- m_WaitTimeDps = int32((m_WaitTimeDps * old_number + waitTimesMap[plr->GetGUID()]) / m_NumWaitTimeDps);
+ m_WaitTimeDps = int32((m_WaitTimeDps * old_number + waitTimesMap[player->GetGUID()]) / m_NumWaitTimeDps);
break;
}
case ROLE_HEALER:
{
uint32 old_number = m_NumWaitTimeHealer++;
- m_WaitTimeHealer = int32((m_WaitTimeHealer * old_number + waitTimesMap[plr->GetGUID()]) / m_NumWaitTimeHealer);
+ m_WaitTimeHealer = int32((m_WaitTimeHealer * old_number + waitTimesMap[player->GetGUID()]) / m_NumWaitTimeHealer);
break;
}
case ROLE_TANK:
{
uint32 old_number = m_NumWaitTimeTank++;
- m_WaitTimeTank = int32((m_WaitTimeTank * old_number + waitTimesMap[plr->GetGUID()]) / m_NumWaitTimeTank);
+ m_WaitTimeTank = int32((m_WaitTimeTank * old_number + waitTimesMap[player->GetGUID()]) / m_NumWaitTimeTank);
break;
}
default:
{
uint32 old_number = m_NumWaitTimeAvg++;
- m_WaitTimeAvg = int32((m_WaitTimeAvg * old_number + waitTimesMap[plr->GetGUID()]) / m_NumWaitTimeAvg);
+ m_WaitTimeAvg = int32((m_WaitTimeAvg * old_number + waitTimesMap[player->GetGUID()]) / m_NumWaitTimeAvg);
break;
}
}
@@ -1399,10 +1398,7 @@ void LFGMgr::UpdateProposal(uint32 proposalId, uint64 guid, bool accept)
// Remove players/groups from Queue
for (LfgGuidList::const_iterator it = pProposal->queues.begin(); it != pProposal->queues.end(); ++it)
- {
- uint64 guid = (*it);
- RemoveFromQueue(guid);
- }
+ RemoveFromQueue(*it);
// Teleport Player
for (LfgPlayerList::const_iterator it = playersToTeleport.begin(); it != playersToTeleport.end(); ++it)
@@ -1454,15 +1450,15 @@ void LFGMgr::RemoveProposal(LfgProposalMap::iterator itProposal, LfgUpdateType t
// Notify players
for (LfgProposalPlayerMap::const_iterator it = pProposal->players.begin(); it != pProposal->players.end(); ++it)
{
- Player* plr = ObjectAccessor::FindPlayer(it->first);
- if (!plr)
+ Player* player = ObjectAccessor::FindPlayer(it->first);
+ if (!player)
continue;
- team = uint8(plr->GetTeam());
- plr->GetSession()->SendLfgUpdateProposal(itProposal->first, pProposal);
+ team = uint8(player->GetTeam());
+ player->GetSession()->SendLfgUpdateProposal(itProposal->first, pProposal);
- Group* grp = plr->GetGroup();
- uint64 guid = plr->GetGUID();
+ Group* grp = player->GetGroup();
+ uint64 guid = player->GetGUID();
uint64 gguid = it->second->groupLowGuid ? MAKE_NEW_GUID(it->second->groupLowGuid, 0, HIGHGUID_GROUP) : guid;
if (toRemove.find(gguid) != toRemove.end()) // Didn't accept or in same group that someone that didn't accept
@@ -1482,10 +1478,10 @@ void LFGMgr::RemoveProposal(LfgProposalMap::iterator itProposal, LfgUpdateType t
if (grp)
{
RestoreState(gguid);
- plr->GetSession()->SendLfgUpdateParty(updateData);
+ player->GetSession()->SendLfgUpdateParty(updateData);
}
else
- plr->GetSession()->SendLfgUpdatePlayer(updateData);
+ player->GetSession()->SendLfgUpdatePlayer(updateData);
}
else
{
@@ -1494,10 +1490,10 @@ void LFGMgr::RemoveProposal(LfgProposalMap::iterator itProposal, LfgUpdateType t
if (grp)
{
SetState(gguid, LFG_STATE_QUEUED);
- plr->GetSession()->SendLfgUpdateParty(LfgUpdateData(LFG_UPDATETYPE_ADDED_TO_QUEUE, GetSelectedDungeons(guid), GetComment(guid)));
+ player->GetSession()->SendLfgUpdateParty(LfgUpdateData(LFG_UPDATETYPE_ADDED_TO_QUEUE, GetSelectedDungeons(guid), GetComment(guid)));
}
else
- plr->GetSession()->SendLfgUpdatePlayer(LfgUpdateData(LFG_UPDATETYPE_ADDED_TO_QUEUE, GetSelectedDungeons(guid), GetComment(guid)));
+ player->GetSession()->SendLfgUpdatePlayer(LfgUpdateData(LFG_UPDATETYPE_ADDED_TO_QUEUE, GetSelectedDungeons(guid), GetComment(guid)));
}
}
@@ -1572,17 +1568,17 @@ void LFGMgr::InitBoot(Group* grp, uint64 kicker, uint64 victim, std::string reas
/**
Update Boot info with player answer
- @param[in] plr Player who has answered
+ @param[in] player Player who has answered
@param[in] accept player answer
*/
-void LFGMgr::UpdateBoot(Player* plr, bool accept)
+void LFGMgr::UpdateBoot(Player* player, bool accept)
{
- Group* grp = plr ? plr->GetGroup() : NULL;
+ Group* grp = player ? player->GetGroup() : NULL;
if (!grp)
return;
uint32 bootId = grp->GetLowGUID();
- uint64 guid = plr->GetGUID();
+ uint64 guid = player->GetGUID();
LfgPlayerBootMap::iterator itBoot = m_Boots.find(bootId);
if (itBoot == m_Boots.end())
@@ -1647,29 +1643,29 @@ void LFGMgr::UpdateBoot(Player* plr, bool accept)
/**
Teleports the player in or out the dungeon
- @param[in] plr Player to teleport
+ @param[in] player Player to teleport
@param[in] out Teleport out (true) or in (false)
@param[in] fromOpcode Function called from opcode handlers? (Default false)
*/
-void LFGMgr::TeleportPlayer(Player* plr, bool out, bool fromOpcode /*= false*/)
+void LFGMgr::TeleportPlayer(Player* player, bool out, bool fromOpcode /*= false*/)
{
- sLog->outDebug(LOG_FILTER_LFG, "LFGMgr::TeleportPlayer: [" UI64FMTD "] is being teleported %s", plr->GetGUID(), out ? "out" : "in");
+ sLog->outDebug(LOG_FILTER_LFG, "LFGMgr::TeleportPlayer: [" UI64FMTD "] is being teleported %s", player->GetGUID(), out ? "out" : "in");
if (out)
{
- plr->RemoveAurasDueToSpell(LFG_SPELL_LUCK_OF_THE_DRAW);
- plr->TeleportToBGEntryPoint();
+ player->RemoveAurasDueToSpell(LFG_SPELL_LUCK_OF_THE_DRAW);
+ player->TeleportToBGEntryPoint();
return;
}
// TODO Add support for LFG_TELEPORTERROR_FATIGUE
LfgTeleportError error = LFG_TELEPORTERROR_OK;
- Group* grp = plr->GetGroup();
+ Group* grp = player->GetGroup();
if (!grp || !grp->isLFGGroup()) // should never happen, but just in case...
error = LFG_TELEPORTERROR_INVALID_LOCATION;
- else if (!plr->isAlive())
+ else if (!player->isAlive())
error = LFG_TELEPORTERROR_PLAYER_DEAD;
- else if (plr->IsFalling() || plr->HasUnitState(UNIT_STAT_JUMPING))
+ else if (player->IsFalling() || player->HasUnitState(UNIT_STAT_JUMPING))
error = LFG_TELEPORTERROR_FALLING;
else
{
@@ -1678,7 +1674,7 @@ void LFGMgr::TeleportPlayer(Player* plr, bool out, bool fromOpcode /*= false*/)
if (!dungeon)
error = LFG_TELEPORTERROR_INVALID_LOCATION;
- else if (plr->GetMapId() != uint32(dungeon->map)) // Do not teleport players in dungeon to the entrance
+ else if (player->GetMapId() != uint32(dungeon->map)) // Do not teleport players in dungeon to the entrance
{
uint32 mapid = 0;
float x = 0;
@@ -1692,7 +1688,7 @@ void LFGMgr::TeleportPlayer(Player* plr, bool out, bool fromOpcode /*= false*/)
for (GroupReference* itr = grp->GetFirstMember(); itr != NULL && !mapid; itr = itr->next())
{
Player* plrg = itr->getSource();
- if (plrg && plrg != plr && plrg->GetMapId() == uint32(dungeon->map))
+ if (plrg && plrg != player && plrg->GetMapId() == uint32(dungeon->map))
{
mapid = plrg->GetMapId();
x = plrg->GetPositionX();
@@ -1708,7 +1704,7 @@ void LFGMgr::TeleportPlayer(Player* plr, bool out, bool fromOpcode /*= false*/)
AreaTrigger const* at = sObjectMgr->GetMapEntranceTrigger(dungeon->map);
if (!at)
{
- sLog->outError("LfgMgr::TeleportPlayer: Failed to teleport [" UI64FMTD "]: No areatrigger found for map: %u difficulty: %u", plr->GetGUID(), dungeon->map, dungeon->difficulty);
+ sLog->outError("LfgMgr::TeleportPlayer: Failed to teleport [" UI64FMTD "]: No areatrigger found for map: %u difficulty: %u", player->GetGUID(), dungeon->map, dungeon->difficulty);
error = LFG_TELEPORTERROR_INVALID_LOCATION;
}
else
@@ -1723,36 +1719,36 @@ void LFGMgr::TeleportPlayer(Player* plr, bool out, bool fromOpcode /*= false*/)
if (error == LFG_TELEPORTERROR_OK)
{
- if (!plr->GetMap()->IsDungeon() && !plr->GetMap()->IsRaid())
- plr->SetBattlegroundEntryPoint();
+ if (!player->GetMap()->IsDungeon() && !player->GetMap()->IsRaid())
+ player->SetBattlegroundEntryPoint();
- if (plr->isInFlight())
+ if (player->isInFlight())
{
- plr->GetMotionMaster()->MovementExpired();
- plr->CleanupAfterTaxiFlight();
+ player->GetMotionMaster()->MovementExpired();
+ player->CleanupAfterTaxiFlight();
}
- if (plr->TeleportTo(mapid, x, y, z, orientation))
+ if (player->TeleportTo(mapid, x, y, z, orientation))
// FIXME - HACK - this should be done by teleport, when teleporting far
- plr->RemoveAurasByType(SPELL_AURA_MOUNTED);
+ player->RemoveAurasByType(SPELL_AURA_MOUNTED);
else
{
error = LFG_TELEPORTERROR_INVALID_LOCATION;
- sLog->outError("LfgMgr::TeleportPlayer: Failed to teleport [" UI64FMTD "] to map %u: ", plr->GetGUID(), mapid);
+ sLog->outError("LfgMgr::TeleportPlayer: Failed to teleport [" UI64FMTD "] to map %u: ", player->GetGUID(), mapid);
}
}
}
}
if (error != LFG_TELEPORTERROR_OK)
- plr->GetSession()->SendLfgTeleportError(uint8(error));
+ player->GetSession()->SendLfgTeleportError(uint8(error));
}
/**
Give completion reward to player
@param[in] dungeonId Id of the dungeon finished
- @param[in] plr Player to reward
+ @param[in] player Player to reward
*/
void LFGMgr::RewardDungeonDoneFor(const uint32 dungeonId, Player* player)
{
diff --git a/src/server/game/DungeonFinding/LFGMgr.h b/src/server/game/DungeonFinding/LFGMgr.h
index 300268ed7c8..95cb2e81869 100755
--- a/src/server/game/DungeonFinding/LFGMgr.h
+++ b/src/server/game/DungeonFinding/LFGMgr.h
@@ -268,8 +268,8 @@ class LFGMgr
LfgReward const* GetRandomDungeonReward(uint32 dungeon, uint8 level);
// Queue
- void Join(Player* plr, uint8 roles, const LfgDungeonSet& dungeons, const std::string& comment);
- void Leave(Player* plr, Group* grp = NULL);
+ void Join(Player* player, uint8 roles, const LfgDungeonSet& dungeons, const std::string& comment);
+ void Leave(Player* player, Group* grp = NULL);
// Role Check
void UpdateRoleCheck(uint64 gguid, uint64 guid = 0, uint8 roles = ROLE_NONE);
@@ -278,20 +278,21 @@ class LFGMgr
void UpdateProposal(uint32 proposalId, uint64 guid, bool accept);
// Teleportation
- void TeleportPlayer(Player* plr, bool out, bool fromOpcode = false);
+ void TeleportPlayer(Player* player, bool out, bool fromOpcode = false);
// Vote kick
void InitBoot(Group* grp, uint64 kguid, uint64 vguid, std::string reason);
- void UpdateBoot(Player* plr, bool accept);
+ void UpdateBoot(Player* player, bool accept);
void OfferContinue(Group* grp);
- void InitializeLockedDungeons(Player* plr);
+ void InitializeLockedDungeons(Player* player);
void SetComment(uint64 guid, const std::string& comment);
const LfgLockMap& GetLockedDungeons(uint64 guid);
LfgState GetState(uint64 guid);
const LfgDungeonSet& GetSelectedDungeons(uint64 guid);
uint32 GetDungeon(uint64 guid, bool asId = true);
+ void SetState(uint64 guid, LfgState state);
void ClearState(uint64 guid);
void RemovePlayerData(uint64 guid);
void RemoveGroupData(uint64 guid);
@@ -304,7 +305,6 @@ class LFGMgr
uint8 GetRoles(uint64 guid);
const std::string& GetComment(uint64 gguid);
void RestoreState(uint64 guid);
- void SetState(uint64 guid, LfgState state);
void SetDungeon(uint64 guid, uint32 dungeon);
void SetSelectedDungeons(uint64 guid, const LfgDungeonSet& dungeons);
void SetLockedDungeons(uint64 guid, const LfgLockMap& lock);
diff --git a/src/server/game/DungeonFinding/LFGScripts.cpp b/src/server/game/DungeonFinding/LFGScripts.cpp
index 23eb10a98ae..42119a02ef8 100644
--- a/src/server/game/DungeonFinding/LFGScripts.cpp
+++ b/src/server/game/DungeonFinding/LFGScripts.cpp
@@ -51,8 +51,8 @@ void LFGScripts::OnAddMember(Group* group, uint64 guid)
sLFGMgr->Leave(NULL, group);
if (sLFGMgr->GetState(guid) == LFG_STATE_QUEUED)
- if (Player* plr = ObjectAccessor::FindPlayer(guid))
- sLFGMgr->Leave(plr);
+ if (Player* player = ObjectAccessor::FindPlayer(guid))
+ sLFGMgr->Leave(player);
}
void LFGScripts::OnRemoveMember(Group* group, uint64 guid, RemoveMethod method, uint64 kicker, const char* reason)
@@ -82,7 +82,8 @@ void LFGScripts::OnRemoveMember(Group* group, uint64 guid, RemoveMethod method,
}
sLFGMgr->ClearState(guid);
- if (Player* plr = ObjectAccessor::FindPlayer(guid))
+ sLFGMgr->SetState(guid, LFG_STATE_NONE);
+ if (Player* player = ObjectAccessor::FindPlayer(guid))
{
/*
if (method == GROUP_REMOVEMETHOD_LEAVE)
@@ -92,9 +93,9 @@ void LFGScripts::OnRemoveMember(Group* group, uint64 guid, RemoveMethod method,
*/
LfgUpdateData updateData = LfgUpdateData(LFG_UPDATETYPE_LEADER);
- plr->GetSession()->SendLfgUpdateParty(updateData);
- if (plr->GetMap()->IsDungeon()) // Teleport player out the dungeon
- sLFGMgr->TeleportPlayer(plr, true);
+ player->GetSession()->SendLfgUpdateParty(updateData);
+ if (player->GetMap()->IsDungeon()) // Teleport player out the dungeon
+ sLFGMgr->TeleportPlayer(player, true);
}
if (sLFGMgr->GetState(gguid) != LFG_STATE_FINISHED_DUNGEON)// Need more players to finish the dungeon
@@ -116,17 +117,17 @@ void LFGScripts::OnChangeLeader(Group* group, uint64 newLeaderGuid, uint64 oldLe
return;
sLog->outDebug(LOG_FILTER_LFG, "LFGScripts::OnChangeLeader [" UI64FMTD "]: old [" UI64FMTD "] new [" UI64FMTD "]", gguid, newLeaderGuid, oldLeaderGuid);
- Player* plr = ObjectAccessor::FindPlayer(newLeaderGuid);
+ Player* player = ObjectAccessor::FindPlayer(newLeaderGuid);
LfgUpdateData updateData = LfgUpdateData(LFG_UPDATETYPE_LEADER);
- if (plr)
- plr->GetSession()->SendLfgUpdateParty(updateData);
+ if (player)
+ player->GetSession()->SendLfgUpdateParty(updateData);
- plr = ObjectAccessor::FindPlayer(oldLeaderGuid);
- if (plr)
+ player = ObjectAccessor::FindPlayer(oldLeaderGuid);
+ if (player)
{
updateData.updateType = LFG_UPDATETYPE_GROUP_DISBAND;
- plr->GetSession()->SendLfgUpdateParty(updateData);
+ player->GetSession()->SendLfgUpdateParty(updateData);
}
}
diff --git a/src/server/game/Entities/Corpse/Corpse.cpp b/src/server/game/Entities/Corpse/Corpse.cpp
index cdd5d61b1c9..31cc21659c9 100755
--- a/src/server/game/Entities/Corpse/Corpse.cpp
+++ b/src/server/game/Entities/Corpse/Corpse.cpp
@@ -95,7 +95,7 @@ bool Corpse::Create(uint32 guidlow, Player* owner)
SetFloatValue(OBJECT_FIELD_SCALE_X, 1);
SetUInt64Value(CORPSE_FIELD_OWNER, owner->GetGUID());
- m_grid = Trinity::ComputeGridPair(GetPositionX(), GetPositionY());
+ _gridCoord = Trinity::ComputeGridCoord(GetPositionX(), GetPositionY());
return true;
}
@@ -211,7 +211,7 @@ bool Corpse::LoadFromDB(uint32 guid, Field* fields)
return false;
}
- m_grid = Trinity::ComputeGridPair(GetPositionX(), GetPositionY());
+ _gridCoord = Trinity::ComputeGridCoord(GetPositionX(), GetPositionY());
return true;
}
diff --git a/src/server/game/Entities/Corpse/Corpse.h b/src/server/game/Entities/Corpse/Corpse.h
index bd68eb688f5..2e45606b88f 100755
--- a/src/server/game/Entities/Corpse/Corpse.h
+++ b/src/server/game/Entities/Corpse/Corpse.h
@@ -70,8 +70,8 @@ class Corpse : public WorldObject, public GridObject<Corpse>
void ResetGhostTime() { m_time = time(NULL); }
CorpseType GetType() const { return m_type; }
- GridPair const& GetGrid() const { return m_grid; }
- void SetGrid(GridPair const& grid) { m_grid = grid; }
+ GridCoord const& GetGridCoord() const { return _gridCoord; }
+ void SetGridCoord(GridCoord const& gridCoord) { _gridCoord = gridCoord; }
Loot loot; // remove insignia ONLY at BG
Player* lootRecipient;
@@ -88,7 +88,7 @@ class Corpse : public WorldObject, public GridObject<Corpse>
private:
CorpseType m_type;
time_t m_time;
- GridPair m_grid; // gride for corpse position for fast search
+ GridCoord _gridCoord; // gride for corpse position for fast search
};
#endif
diff --git a/src/server/game/Entities/Creature/Creature.cpp b/src/server/game/Entities/Creature/Creature.cpp
index 8981e6f610d..922db88bcd0 100755
--- a/src/server/game/Entities/Creature/Creature.cpp
+++ b/src/server/game/Entities/Creature/Creature.cpp
@@ -137,14 +137,13 @@ bool ForcedDespawnDelayEvent::Execute(uint64 /*e_time*/, uint32 /*p_time*/)
return true;
}
-Creature::Creature(): Unit(),
+Creature::Creature(): Unit(), MapCreature(),
lootForPickPocketed(false), lootForBody(false), m_groupLootTimer(0), lootingGroupLowGUID(0),
m_PlayerDamageReq(0), m_lootMoney(0), m_lootRecipient(0), m_lootRecipientGroup(0), m_corpseRemoveTime(0), m_respawnTime(0),
m_respawnDelay(300), m_corpseDelay(60), m_respawnradius(0.0f), m_reactState(REACT_AGGRESSIVE),
m_defaultMovementType(IDLE_MOTION_TYPE), m_DBTableGuid(0), m_equipmentId(0), m_AlreadyCallAssistance(false),
m_AlreadySearchedAssistance(false), m_regenHealth(true), m_AI_locked(false), m_meleeDamageSchoolMask(SPELL_SCHOOL_MASK_NORMAL),
-m_creatureInfo(NULL), m_creatureData(NULL), m_formation(NULL),
-MapCreature()
+m_creatureInfo(NULL), m_creatureData(NULL), m_formation(NULL)
{
m_regenTimer = CREATURE_REGEN_INTERVAL;
m_valuesCount = UNIT_END;
@@ -246,7 +245,7 @@ void Creature::RemoveCorpse(bool setSpawnTime)
m_respawnTime = time(NULL) + respawnDelay;
float x, y, z, o;
- GetRespawnCoord(x, y, z, &o);
+ GetRespawnPosition(x, y, z, &o);
SetHomePosition(x, y, z, o);
GetMap()->CreatureRelocation(this, x, y, z, o);
}
@@ -660,9 +659,8 @@ void Creature::DoFleeToGetAssistance()
{
Creature* creature = NULL;
- CellPair p(Trinity::ComputeCellPair(GetPositionX(), GetPositionY()));
+ CellCoord p(Trinity::ComputeCellCoord(GetPositionX(), GetPositionY()));
Cell cell(p);
- cell.data.Part.reserved = ALL_DISTRICT;
cell.SetNoCreate();
Trinity::NearestAssistCreatureInCreatureRangeCheck u_check(this, getVictim(), radius);
Trinity::CreatureLastSearcher<Trinity::NearestAssistCreatureInCreatureRangeCheck> searcher(this, creature, u_check);
@@ -789,16 +787,11 @@ bool Creature::Create(uint32 guidlow, Map* map, uint32 phaseMask, uint32 Entry,
LastUsedScriptID = GetCreatureInfo()->ScriptID;
// TODO: Replace with spell, handle from DB
- if (isSpiritHealer())
+ if (isSpiritHealer() || isSpiritGuide())
{
m_serverSideVisibility.SetValue(SERVERSIDE_VISIBILITY_GHOST, GHOST_VISIBILITY_GHOST);
m_serverSideVisibilityDetect.SetValue(SERVERSIDE_VISIBILITY_GHOST, GHOST_VISIBILITY_GHOST);
}
- else if (isSpiritGuide())
- {
- m_serverSideVisibility.SetValue(SERVERSIDE_VISIBILITY_GHOST, GHOST_VISIBILITY_GHOST | GHOST_VISIBILITY_ALIVE);
- m_serverSideVisibilityDetect.SetValue(SERVERSIDE_VISIBILITY_GHOST, GHOST_VISIBILITY_GHOST | GHOST_VISIBILITY_ALIVE);
- }
if (Entry == VISUAL_WAYPOINT)
SetVisible(false);
@@ -1286,7 +1279,7 @@ bool Creature::LoadFromDB(uint32 guid, Map* map)
if (canFly())
{
float tz = map->GetHeight(data->posX, data->posY, data->posZ, false);
- if (data->posZ - tz > 0.1)
+ if (data->posZ - tz > 0.1f)
Relocate(data->posX, data->posY, tz);
}
}
@@ -1440,14 +1433,14 @@ bool Creature::canStartAttack(Unit const* who, bool force) const
return IsWithinLOSInMap(who);
}
-float Creature::GetAttackDistance(Unit const* pl) const
+float Creature::GetAttackDistance(Unit const* player) const
{
float aggroRate = sWorld->getRate(RATE_CREATURE_AGGRO);
if (aggroRate == 0)
return 0.0f;
- uint32 playerlevel = pl->getLevelForTarget(this);
- uint32 creaturelevel = getLevelForTarget(pl);
+ uint32 playerlevel = player->getLevelForTarget(this);
+ uint32 creaturelevel = getLevelForTarget(player);
int32 leveldif = int32(playerlevel) - int32(creaturelevel);
@@ -1468,7 +1461,7 @@ float Creature::GetAttackDistance(Unit const* pl) const
RetDistance += GetTotalAuraModifier(SPELL_AURA_MOD_DETECT_RANGE);
// detected range auras
- RetDistance += pl->GetTotalAuraModifier(SPELL_AURA_MOD_DETECTED_RANGE);
+ RetDistance += player->GetTotalAuraModifier(SPELL_AURA_MOD_DETECTED_RANGE);
}
// "Minimum Aggro Radius for a mob seems to be combat range (5 yards)"
@@ -1761,9 +1754,8 @@ SpellInfo const* Creature::reachWithSpellCure(Unit* pVictim)
// select nearest hostile unit within the given distance (regardless of threat list).
Unit* Creature::SelectNearestTarget(float dist) const
{
- CellPair p(Trinity::ComputeCellPair(GetPositionX(), GetPositionY()));
+ CellCoord p(Trinity::ComputeCellCoord(GetPositionX(), GetPositionY()));
Cell cell(p);
- cell.data.Part.reserved = ALL_DISTRICT;
cell.SetNoCreate();
Unit* target = NULL;
@@ -1788,9 +1780,8 @@ Unit* Creature::SelectNearestTarget(float dist) const
// select nearest hostile unit within the given attack distance (i.e. distance is ignored if > than ATTACK_DISTANCE), regardless of threat list.
Unit* Creature::SelectNearestTargetInAttackDistance(float dist) const
{
- CellPair p(Trinity::ComputeCellPair(GetPositionX(), GetPositionY()));
+ CellCoord p(Trinity::ComputeCellCoord(GetPositionX(), GetPositionY()));
Cell cell(p);
- cell.data.Part.reserved = ALL_DISTRICT;
cell.SetNoCreate();
Unit* target = NULL;
@@ -1851,9 +1842,8 @@ void Creature::CallAssistance()
std::list<Creature*> assistList;
{
- CellPair p(Trinity::ComputeCellPair(GetPositionX(), GetPositionY()));
+ CellCoord p(Trinity::ComputeCellCoord(GetPositionX(), GetPositionY()));
Cell cell(p);
- cell.data.Part.reserved = ALL_DISTRICT;
cell.SetNoCreate();
Trinity::AnyAssistCreatureInRangeCheck u_check(this, getVictim(), radius);
@@ -1879,22 +1869,21 @@ void Creature::CallAssistance()
}
}
-void Creature::CallForHelp(float fRadius)
+void Creature::CallForHelp(float radius)
{
- if (fRadius <= 0.0f || !getVictim() || isPet() || isCharmed())
+ if (radius <= 0.0f || !getVictim() || isPet() || isCharmed())
return;
- CellPair p(Trinity::ComputeCellPair(GetPositionX(), GetPositionY()));
+ CellCoord p(Trinity::ComputeCellCoord(GetPositionX(), GetPositionY()));
Cell cell(p);
- cell.data.Part.reserved = ALL_DISTRICT;
cell.SetNoCreate();
- Trinity::CallOfHelpCreatureInRangeDo u_do(this, getVictim(), fRadius);
+ Trinity::CallOfHelpCreatureInRangeDo u_do(this, getVictim(), radius);
Trinity::CreatureWorker<Trinity::CallOfHelpCreatureInRangeDo> worker(this, u_do);
TypeContainerVisitor<Trinity::CreatureWorker<Trinity::CallOfHelpCreatureInRangeDo>, GridTypeMapContainer > grid_creature_searcher(worker);
- cell.Visit(p, grid_creature_searcher, *GetMap(), *this, fRadius);
+ cell.Visit(p, grid_creature_searcher, *GetMap(), *this, radius);
}
bool Creature::CanAssistTo(const Unit* u, const Unit* enemy, bool checkfaction /*= true*/) const
@@ -2206,7 +2195,7 @@ time_t Creature::GetRespawnTimeEx() const
return now;
}
-void Creature::GetRespawnCoord(float &x, float &y, float &z, float* ori, float* dist) const
+void Creature::GetRespawnPosition(float &x, float &y, float &z, float* ori, float* dist) const
{
if (m_DBTableGuid)
{
diff --git a/src/server/game/Entities/Creature/Creature.h b/src/server/game/Entities/Creature/Creature.h
index 5a3c80234d8..665942e134a 100755
--- a/src/server/game/Entities/Creature/Creature.h
+++ b/src/server/game/Entities/Creature/Creature.h
@@ -156,7 +156,7 @@ struct CreatureTemplate
else if (type_flags & CREATURE_TYPEFLAGS_MININGLOOT)
return SKILL_MINING;
else if (type_flags & CREATURE_TYPEFLAGS_ENGINEERLOOT)
- return SKILL_ENGINERING;
+ return SKILL_ENGINEERING;
else
return SKILL_SKINNING; // normal case
}
@@ -456,7 +456,7 @@ class Creature : public Unit, public GridObject<Creature>, public MapCreature
uint32 GetDBTableGUIDLow() const { return m_DBTableGuid; }
void Update(uint32 time); // overwrited Unit::Update
- void GetRespawnCoord(float &x, float &y, float &z, float* ori = NULL, float* dist =NULL) const;
+ void GetRespawnPosition(float &x, float &y, float &z, float* ori = NULL, float* dist =NULL) const;
uint32 GetEquipmentId() const { return GetCreatureInfo()->equipmentId; }
void SetCorpseDelay(uint32 delay) { m_corpseDelay = delay; }
@@ -607,7 +607,7 @@ class Creature : public Unit, public GridObject<Creature>, public MapCreature
CreatureSpellCooldowns m_CreatureCategoryCooldowns;
bool canStartAttack(Unit const* u, bool force) const;
- float GetAttackDistance(Unit const* pl) const;
+ float GetAttackDistance(Unit const* player) const;
void SendAIReaction(AiReaction reactionType);
diff --git a/src/server/game/Entities/Creature/GossipDef.cpp b/src/server/game/Entities/Creature/GossipDef.cpp
index 3ff21645a27..5bf7910466c 100755
--- a/src/server/game/Entities/Creature/GossipDef.cpp
+++ b/src/server/game/Entities/Creature/GossipDef.cpp
@@ -337,13 +337,13 @@ void PlayerMenu::SendQuestGiverQuestDetails(Quest const* quest, uint64 npcGUID,
data << uint32(quest->GetRewChoiceItemsCount());
for (uint32 i=0; i < QUEST_REWARD_CHOICES_COUNT; ++i)
{
- if (!quest->RewChoiceItemId[i])
+ if (!quest->RewardChoiceItemId[i])
continue;
- data << uint32(quest->RewChoiceItemId[i]);
- data << uint32(quest->RewChoiceItemCount[i]);
+ data << uint32(quest->RewardChoiceItemId[i]);
+ data << uint32(quest->RewardChoiceItemCount[i]);
- if (ItemTemplate const* itemTemplate = sObjectMgr->GetItemTemplate(quest->RewChoiceItemId[i]))
+ if (ItemTemplate const* itemTemplate = sObjectMgr->GetItemTemplate(quest->RewardChoiceItemId[i]))
data << uint32(itemTemplate->DisplayInfoID);
else
data << uint32(0x00);
@@ -353,13 +353,13 @@ void PlayerMenu::SendQuestGiverQuestDetails(Quest const* quest, uint64 npcGUID,
for (uint32 i=0; i < QUEST_REWARDS_COUNT; ++i)
{
- if (!quest->RewItemId[i])
+ if (!quest->RewardItemId[i])
continue;
- data << uint32(quest->RewItemId[i]);
- data << uint32(quest->RewItemCount[i]);
+ data << uint32(quest->RewardItemId[i]);
+ data << uint32(quest->RewardItemIdCount[i]);
- if (ItemTemplate const* itemTemplate = sObjectMgr->GetItemTemplate(quest->RewItemId[i]))
+ if (ItemTemplate const* itemTemplate = sObjectMgr->GetItemTemplate(quest->RewardItemId[i]))
data << uint32(itemTemplate->DisplayInfoID);
else
data << uint32(0);
@@ -371,7 +371,7 @@ void PlayerMenu::SendQuestGiverQuestDetails(Quest const* quest, uint64 npcGUID,
// rewarded honor points. Multiply with 10 to satisfy client
data << 10 * Trinity::Honor::hk_honor_at_level(_session->GetPlayer()->getLevel(), quest->GetRewHonorMultiplier());
- data << float(0); // new 3.3.0, honor multiplier?
+ data << float(0.0f); // new 3.3.0, honor multiplier?
data << uint32(quest->GetRewSpell()); // reward spell, this spell will display (icon) (casted if RewSpellCast == 0)
data << int32(quest->GetRewSpellCast()); // casted spell
data << uint32(quest->GetCharTitleId()); // CharTitleId, new 2.4.0, player gets this title (id from CharTitles)
@@ -380,13 +380,13 @@ void PlayerMenu::SendQuestGiverQuestDetails(Quest const* quest, uint64 npcGUID,
data << uint32(0); // unk
for (uint32 i = 0; i < QUEST_REPUTATIONS_COUNT; ++i)
- data << uint32(quest->RewRepFaction[i]);
+ data << uint32(quest->RewardFactionId[i]);
for (uint32 i = 0; i < QUEST_REPUTATIONS_COUNT; ++i)
- data << int32(quest->RewRepValueId[i]);
+ data << int32(quest->RewardFactionValueId[i]);
for (uint32 i = 0; i < QUEST_REPUTATIONS_COUNT; ++i)
- data << int32(quest->RewRepValue[i]);
+ data << int32(quest->RewardFactionValueIdOverride[i]);
data << uint32(QUEST_EMOTE_COUNT);
for (uint32 i = 0; i < QUEST_EMOTE_COUNT; ++i)
@@ -478,24 +478,24 @@ void PlayerMenu::SendQuestQueryResponse(Quest const* quest) const
{
for (uint32 i = 0; i < QUEST_REWARDS_COUNT; ++i)
{
- data << uint32(quest->RewItemId[i]);
- data << uint32(quest->RewItemCount[i]);
+ data << uint32(quest->RewardItemId[i]);
+ data << uint32(quest->RewardItemIdCount[i]);
}
for (uint32 i = 0; i < QUEST_REWARD_CHOICES_COUNT; ++i)
{
- data << uint32(quest->RewChoiceItemId[i]);
- data << uint32(quest->RewChoiceItemCount[i]);
+ data << uint32(quest->RewardChoiceItemId[i]);
+ data << uint32(quest->RewardChoiceItemCount[i]);
}
}
for (uint32 i = 0; i < QUEST_REPUTATIONS_COUNT; ++i) // reward factions ids
- data << uint32(quest->RewRepFaction[i]);
+ data << uint32(quest->RewardFactionId[i]);
for (uint32 i = 0; i < QUEST_REPUTATIONS_COUNT; ++i) // columnid+1 QuestFactionReward.dbc?
- data << int32(quest->RewRepValueId[i]);
+ data << int32(quest->RewardFactionValueId[i]);
for (int i = 0; i < QUEST_REPUTATIONS_COUNT; ++i) // unk (0)
- data << int32(quest->RewRepValue[i]);
+ data << int32(quest->RewardFactionValueIdOverride[i]);
data << quest->GetPointMapId();
data << quest->GetPointX();
@@ -510,20 +510,20 @@ void PlayerMenu::SendQuestQueryResponse(Quest const* quest) const
for (uint32 i = 0; i < QUEST_OBJECTIVES_COUNT; ++i)
{
- if (quest->ReqCreatureOrGOId[i] < 0)
- data << uint32((quest->ReqCreatureOrGOId[i] * (-1)) | 0x80000000); // client expects gameobject template id in form (id|0x80000000)
+ if (quest->RequiredNpcOrGo[i] < 0)
+ data << uint32((quest->RequiredNpcOrGo[i] * (-1)) | 0x80000000); // client expects gameobject template id in form (id|0x80000000)
else
- data << uint32(quest->ReqCreatureOrGOId[i]);
+ data << uint32(quest->RequiredNpcOrGo[i]);
- data << uint32(quest->ReqCreatureOrGOCount[i]);
- data << uint32(quest->ReqSourceId[i]);
+ data << uint32(quest->RequiredNpcOrGoCount[i]);
+ data << uint32(quest->RequiredSourceItemid[i]);
data << uint32(0); // req source count?
}
for (uint32 i = 0; i < QUEST_ITEM_OBJECTIVES_COUNT; ++i)
{
- data << uint32(quest->ReqItemId[i]);
- data << uint32(quest->ReqItemCount[i]);
+ data << uint32(quest->RequiredItemId[i]);
+ data << uint32(quest->RequiredItemCount[i]);
}
for (uint32 i = 0; i < QUEST_OBJECTIVES_COUNT; ++i)
@@ -576,10 +576,10 @@ void PlayerMenu::SendQuestGiverOfferReward(Quest const* quest, uint64 npcGUID, b
data << uint32(quest->GetRewChoiceItemsCount());
for (uint32 i=0; i < quest->GetRewChoiceItemsCount(); ++i)
{
- data << uint32(quest->RewChoiceItemId[i]);
- data << uint32(quest->RewChoiceItemCount[i]);
+ data << uint32(quest->RewardChoiceItemId[i]);
+ data << uint32(quest->RewardChoiceItemCount[i]);
- if (ItemTemplate const* itemTemplate = sObjectMgr->GetItemTemplate(quest->RewChoiceItemId[i]))
+ if (ItemTemplate const* itemTemplate = sObjectMgr->GetItemTemplate(quest->RewardChoiceItemId[i]))
data << uint32(itemTemplate->DisplayInfoID);
else
data << uint32(0);
@@ -588,10 +588,10 @@ void PlayerMenu::SendQuestGiverOfferReward(Quest const* quest, uint64 npcGUID, b
data << uint32(quest->GetRewItemsCount());
for (uint32 i = 0; i < quest->GetRewItemsCount(); ++i)
{
- data << uint32(quest->RewItemId[i]);
- data << uint32(quest->RewItemCount[i]);
+ data << uint32(quest->RewardItemId[i]);
+ data << uint32(quest->RewardItemIdCount[i]);
- if (ItemTemplate const* itemTemplate = sObjectMgr->GetItemTemplate(quest->RewItemId[i]))
+ if (ItemTemplate const* itemTemplate = sObjectMgr->GetItemTemplate(quest->RewardItemId[i]))
data << uint32(itemTemplate->DisplayInfoID);
else
data << uint32(0);
@@ -612,13 +612,13 @@ void PlayerMenu::SendQuestGiverOfferReward(Quest const* quest, uint64 npcGUID, b
data << uint32(0);
for (uint32 i = 0; i < QUEST_REPUTATIONS_COUNT; ++i) // reward factions ids
- data << uint32(quest->RewRepFaction[i]);
+ data << uint32(quest->RewardFactionId[i]);
for (uint32 i = 0; i < QUEST_REPUTATIONS_COUNT; ++i) // columnid in QuestFactionReward.dbc (zero based)?
- data << int32(quest->RewRepValueId[i]);
+ data << int32(quest->RewardFactionValueId[i]);
for (uint32 i = 0; i < QUEST_REPUTATIONS_COUNT; ++i) // reward reputation override?
- data << uint32(quest->RewRepValue[i]);
+ data << uint32(quest->RewardFactionValueIdOverride[i]);
_session->SendPacket(&data);
sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Sent SMSG_QUESTGIVER_OFFER_REWARD NPCGuid=%u, questid=%u", GUID_LOPART(npcGUID), quest->GetQuestId());
@@ -676,13 +676,13 @@ void PlayerMenu::SendQuestGiverRequestItems(Quest const* quest, uint64 npcGUID,
data << uint32(quest->GetReqItemsCount());
for (int i = 0; i < QUEST_ITEM_OBJECTIVES_COUNT; ++i)
{
- if (!quest->ReqItemId[i])
+ if (!quest->RequiredItemId[i])
continue;
- data << uint32(quest->ReqItemId[i]);
- data << uint32(quest->ReqItemCount[i]);
+ data << uint32(quest->RequiredItemId[i]);
+ data << uint32(quest->RequiredItemCount[i]);
- if (ItemTemplate const* itemTemplate = sObjectMgr->GetItemTemplate(quest->ReqItemId[i]))
+ if (ItemTemplate const* itemTemplate = sObjectMgr->GetItemTemplate(quest->RequiredItemId[i]))
data << uint32(itemTemplate->DisplayInfoID);
else
data << uint32(0);
diff --git a/src/server/game/Entities/GameObject/GameObject.cpp b/src/server/game/Entities/GameObject/GameObject.cpp
index 2f353285806..9e514ad34bb 100755
--- a/src/server/game/Entities/GameObject/GameObject.cpp
+++ b/src/server/game/Entities/GameObject/GameObject.cpp
@@ -16,26 +16,14 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "Common.h"
-#include "QuestDef.h"
#include "GameObjectAI.h"
#include "ObjectMgr.h"
#include "GroupMgr.h"
#include "PoolMgr.h"
#include "SpellMgr.h"
-#include "Spell.h"
-#include "UpdateMask.h"
-#include "Opcodes.h"
-#include "WorldPacket.h"
#include "World.h"
-#include "DatabaseEnv.h"
-#include "LootMgr.h"
-#include "GridNotifiers.h"
#include "GridNotifiersImpl.h"
#include "CellImpl.h"
-#include "InstanceScript.h"
-#include "Battleground.h"
-#include "Util.h"
#include "OutdoorPvPMgr.h"
#include "BattlegroundAV.h"
#include "ScriptMgr.h"
@@ -73,15 +61,21 @@ GameObject::GameObject() : WorldObject(), m_goValue(new GameObjectValue), m_AI(N
GameObject::~GameObject()
{
delete m_goValue;
+ delete m_AI;
//if (m_uint32Values) // field array can be not exist if GameOBject not loaded
// CleanupsBeforeDelete();
}
bool GameObject::AIM_Initialize()
{
+ if (m_AI)
+ delete m_AI;
m_AI = FactorySelector::SelectGameObjectAI(this);
- if (!m_AI) return false;
+
+ if (!m_AI)
+ return false;
+
m_AI->InitializeAI();
return true;
}
@@ -97,27 +91,31 @@ void GameObject::CleanupsBeforeDelete(bool /*finalCleanup*/)
RemoveFromWorld();
if (m_uint32Values) // field array can be not exist if GameOBject not loaded
- {
- // Possible crash at access to deleted GO in Unit::m_gameobj
- if (uint64 owner_guid = GetOwnerGUID())
- {
- Unit* owner = ObjectAccessor::GetUnit(*this, owner_guid);
+ RemoveFromOwner();
+}
- if (owner)
- owner->RemoveGameObject(this, false);
- else
- {
- const char * ownerType = "creature";
- if (IS_PLAYER_GUID(owner_guid))
- ownerType = "player";
- else if (IS_PET_GUID(owner_guid))
- ownerType = "pet";
-
- sLog->outError("Delete GameObject (GUID: %u Entry: %u SpellId %u LinkedGO %u) that lost references to owner (GUID %u Type '%s') GO list. Crash possible later.",
- GetGUIDLow(), GetGOInfo()->entry, m_spellId, GetGOInfo()->GetLinkedGameObjectEntry(), GUID_LOPART(owner_guid), ownerType);
- }
- }
+void GameObject::RemoveFromOwner()
+{
+ uint64 ownerGUID = GetOwnerGUID();
+ if (!ownerGUID)
+ return;
+
+ if (Unit* owner = ObjectAccessor::GetUnit(*this, ownerGUID))
+ {
+ owner->RemoveGameObject(this, false);
+ ASSERT(!GetOwnerGUID());
+ return;
}
+
+ const char * ownerType = "creature";
+ if (IS_PLAYER_GUID(ownerGUID))
+ ownerType = "player";
+ else if (IS_PET_GUID(ownerGUID))
+ ownerType = "pet";
+
+ sLog->outCrash("Delete GameObject (GUID: %u Entry: %u SpellId %u LinkedGO %u) that lost references to owner (GUID %u Type '%s') GO list. Crash possible later.",
+ GetGUIDLow(), GetGOInfo()->entry, m_spellId, GetGOInfo()->GetLinkedGameObjectEntry(), GUID_LOPART(ownerGUID), ownerType);
+ SetOwnerGUID(0);
}
void GameObject::AddToWorld()
@@ -141,14 +139,7 @@ void GameObject::RemoveFromWorld()
if (m_zoneScript)
m_zoneScript->OnGameObjectRemove(this);
- // Possible crash at access to deleted GO in Unit::m_gameobj
- if (uint64 owner_guid = GetOwnerGUID())
- {
- if (Unit* owner = GetOwner())
- owner->RemoveGameObject(this, false);
- else
- sLog->outError("Delete GameObject (GUID: %u Entry: %u, Name: %s) that have references in not found creature %u GO list. Crash possible later.", GetGUIDLow(), GetGOInfo()->entry, GetGOInfo()->name.c_str(), GUID_LOPART(owner_guid));
- }
+ RemoveFromOwner();
WorldObject::RemoveFromWorld();
sObjectAccessor->RemoveObject(this);
}
@@ -607,13 +598,8 @@ void GameObject::AddUniqueUse(Player* player)
void GameObject::Delete()
{
SetLootState(GO_NOT_READY);
- if (GetOwnerGUID())
- if (Unit* owner = GetOwner())
- owner->RemoveGameObject(this, false);
- else //! Owner not in world anymore
- SetOwnerGUID(0);
+ RemoveFromOwner();
- ASSERT (!GetOwnerGUID());
SendObjectDeSpawnAnim(GetGUID());
SetGoState(GO_STATE_READY);
@@ -935,9 +921,8 @@ void GameObject::TriggeringLinkedGameObject(uint32 trapEntry, Unit* target)
GameObject* trapGO = NULL;
{
// using original GO distance
- CellPair p(Trinity::ComputeCellPair(GetPositionX(), GetPositionY()));
+ CellCoord p(Trinity::ComputeCellCoord(GetPositionX(), GetPositionY()));
Cell cell(p);
- cell.data.Part.reserved = ALL_DISTRICT;
Trinity::NearestGameObjectEntryInObjectRangeCheck go_check(*target, trapEntry, range);
Trinity::GameObjectLastSearcher<Trinity::NearestGameObjectEntryInObjectRangeCheck> checker(this, trapGO, go_check);
@@ -955,9 +940,8 @@ GameObject* GameObject::LookupFishingHoleAround(float range)
{
GameObject* ok = NULL;
- CellPair p(Trinity::ComputeCellPair(GetPositionX(), GetPositionY()));
+ CellCoord p(Trinity::ComputeCellCoord(GetPositionX(), GetPositionY()));
Cell cell(p);
- cell.data.Part.reserved = ALL_DISTRICT;
Trinity::NearestGameObjectFishingHole u_check(*this, range);
Trinity::GameObjectSearcher<Trinity::NearestGameObjectFishingHole> checker(this, ok, u_check);
@@ -1290,8 +1274,9 @@ void GameObject::Use(Unit* user)
{
player->UpdateFishingSkill();
+ //TODO: I do not understand this hack. Need some explanation.
// prevent removing GO at spell cancel
- player->RemoveGameObject(this, false);
+ RemoveFromOwner();
SetOwnerGUID(player->GetGUID());
//TODO: find reasonable value for fishing hole search
@@ -1539,12 +1524,11 @@ void GameObject::Use(Unit* user)
{
case 179785: // Silverwing Flag
case 179786: // Warsong Flag
- // check if it's correct bg
- if (bg->IsRandom() ? bg->GetTypeID(true) : bg->GetTypeID(false) == BATTLEGROUND_WS)
+ if (bg->GetTypeID(true) == BATTLEGROUND_WS)
bg->EventPlayerClickedOnFlag(player, this);
break;
case 184142: // Netherstorm Flag
- if (bg->IsRandom() ? bg->GetTypeID(true) : bg->GetTypeID(false) == BATTLEGROUND_EY)
+ if (bg->GetTypeID(true) == BATTLEGROUND_EY)
bg->EventPlayerClickedOnFlag(player, this);
break;
}
diff --git a/src/server/game/Entities/GameObject/GameObject.h b/src/server/game/Entities/GameObject/GameObject.h
index 13b410d7373..9167b40d285 100755
--- a/src/server/game/Entities/GameObject/GameObject.h
+++ b/src/server/game/Entities/GameObject/GameObject.h
@@ -815,6 +815,7 @@ class GameObject : public WorldObject, public GridObject<GameObject>
uint16 m_LootMode; // bitmask, default LOOT_MODE_DEFAULT, determines what loot will be lootable
private:
+ void RemoveFromOwner();
void SwitchDoorOrButton(bool activate, bool alternative = false);
//! Object distance/size - overridden from Object::_IsWithinDist. Needs to take in account proper GO size.
diff --git a/src/server/game/Entities/Item/Item.cpp b/src/server/game/Entities/Item/Item.cpp
index d3832ad9151..07275166130 100755
--- a/src/server/game/Entities/Item/Item.cpp
+++ b/src/server/game/Entities/Item/Item.cpp
@@ -1194,25 +1194,23 @@ bool Item::IsRefundExpired()
return (GetPlayedTime() > 2*HOUR);
}
-void Item::SetSoulboundTradeable(AllowedLooterSet* allowedLooters, Player* currentOwner, bool apply)
+void Item::SetSoulboundTradeable(AllowedLooterSet& allowedLooters)
{
- if (apply)
- {
- SetFlag(ITEM_FIELD_FLAGS, ITEM_FLAG_BOP_TRADEABLE);
- allowedGUIDs = *allowedLooters;
- }
- else
- {
- RemoveFlag(ITEM_FIELD_FLAGS, ITEM_FLAG_BOP_TRADEABLE);
- if (allowedGUIDs.empty())
- return;
+ SetFlag(ITEM_FIELD_FLAGS, ITEM_FLAG_BOP_TRADEABLE);
+ allowedGUIDs = allowedLooters;
+}
- allowedGUIDs.clear();
- SetState(ITEM_CHANGED, currentOwner);
- PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_ITEM_BOP_TRADE);
- stmt->setUInt32(0, GetGUIDLow());
- CharacterDatabase.Execute(stmt);
- }
+void Item::ClearSoulboundTradeable(Player* currentOwner)
+{
+ RemoveFlag(ITEM_FIELD_FLAGS, ITEM_FLAG_BOP_TRADEABLE);
+ if (allowedGUIDs.empty())
+ return;
+
+ allowedGUIDs.clear();
+ SetState(ITEM_CHANGED, currentOwner);
+ PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_ITEM_BOP_TRADE);
+ stmt->setUInt32(0, GetGUIDLow());
+ CharacterDatabase.Execute(stmt);
}
bool Item::CheckSoulboundTradeExpire()
@@ -1220,7 +1218,7 @@ bool Item::CheckSoulboundTradeExpire()
// called from owner's update - GetOwner() MUST be valid
if (GetUInt32Value(ITEM_FIELD_CREATE_PLAYED_TIME) + 2*HOUR < GetOwner()->GetTotalPlayedTime())
{
- SetSoulboundTradeable(NULL, GetOwner(), false);
+ ClearSoulboundTradeable(GetOwner());
return true; // remove from tradeable list
}
diff --git a/src/server/game/Entities/Item/Item.h b/src/server/game/Entities/Item/Item.h
index b872b354ea7..4a72e7fea2b 100755
--- a/src/server/game/Entities/Item/Item.h
+++ b/src/server/game/Entities/Item/Item.h
@@ -352,7 +352,8 @@ class Item : public Object
bool IsRefundExpired();
// Soulbound trade system
- void SetSoulboundTradeable(AllowedLooterSet* allowedLooters, Player* currentOwner, bool apply);
+ void SetSoulboundTradeable(AllowedLooterSet& allowedLooters);
+ void ClearSoulboundTradeable(Player* currentOwner);
bool CheckSoulboundTradeExpire();
void BuildUpdate(UpdateDataMapType&);
diff --git a/src/server/game/Entities/Item/ItemPrototype.h b/src/server/game/Entities/Item/ItemPrototype.h
index 155673edbaa..03212c129fd 100755
--- a/src/server/game/Entities/Item/ItemPrototype.h
+++ b/src/server/game/Entities/Item/ItemPrototype.h
@@ -729,7 +729,6 @@ struct ItemTemplate
bool IsWeaponVellum() const { return Class == ITEM_CLASS_TRADE_GOODS && SubClass == ITEM_SUBCLASS_WEAPON_ENCHANTMENT; }
bool IsArmorVellum() const { return Class == ITEM_CLASS_TRADE_GOODS && SubClass == ITEM_SUBCLASS_ARMOR_ENCHANTMENT; }
bool IsConjuredConsumable() const { return Class == ITEM_CLASS_CONSUMABLE && (Flags & ITEM_PROTO_FLAG_CONJURED); }
-
};
// Benchmarked: Faster than std::map (insert/find)
diff --git a/src/server/game/Entities/Object/Object.cpp b/src/server/game/Entities/Object/Object.cpp
index c55892c6f82..978d9accb64 100755
--- a/src/server/game/Entities/Object/Object.cpp
+++ b/src/server/game/Entities/Object/Object.cpp
@@ -780,13 +780,13 @@ void Object::ClearUpdateMask(bool remove)
}
}
-void Object::BuildFieldsUpdate(Player* pl, UpdateDataMapType& data_map) const
+void Object::BuildFieldsUpdate(Player* player, UpdateDataMapType& data_map) const
{
- UpdateDataMapType::iterator iter = data_map.find(pl);
+ UpdateDataMapType::iterator iter = data_map.find(player);
if (iter == data_map.end())
{
- std::pair<UpdateDataMapType::iterator, bool> p = data_map.insert(UpdateDataMapType::value_type(pl, UpdateData()));
+ std::pair<UpdateDataMapType::iterator, bool> p = data_map.insert(UpdateDataMapType::value_type(player, UpdateData()));
ASSERT(p.second);
iter = p.first;
}
@@ -1273,6 +1273,8 @@ void WorldObject::setActive(bool on)
void WorldObject::CleanupsBeforeDelete(bool /*finalCleanup*/)
{
+ if (IsInWorld())
+ RemoveFromWorld();
}
void WorldObject::_Create(uint32 guidlow, HighGuid guidhigh, uint32 phaseMask)
@@ -1868,10 +1870,9 @@ namespace Trinity
void WorldObject::MonsterSay(const char* text, uint32 language, uint64 TargetGuid)
{
- CellPair p = Trinity::ComputeCellPair(GetPositionX(), GetPositionY());
+ CellCoord p = Trinity::ComputeCellCoord(GetPositionX(), GetPositionY());
Cell cell(p);
- cell.data.Part.reserved = ALL_DISTRICT;
cell.SetNoCreate();
Trinity::MonsterCustomChatBuilder say_build(*this, CHAT_MSG_MONSTER_SAY, text, language, TargetGuid);
@@ -1883,10 +1884,9 @@ void WorldObject::MonsterSay(const char* text, uint32 language, uint64 TargetGui
void WorldObject::MonsterSay(int32 textId, uint32 language, uint64 TargetGuid)
{
- CellPair p = Trinity::ComputeCellPair(GetPositionX(), GetPositionY());
+ CellCoord p = Trinity::ComputeCellCoord(GetPositionX(), GetPositionY());
Cell cell(p);
- cell.data.Part.reserved = ALL_DISTRICT;
cell.SetNoCreate();
Trinity::MonsterChatBuilder say_build(*this, CHAT_MSG_MONSTER_SAY, textId, language, TargetGuid);
@@ -1898,10 +1898,9 @@ void WorldObject::MonsterSay(int32 textId, uint32 language, uint64 TargetGuid)
void WorldObject::MonsterYell(const char* text, uint32 language, uint64 TargetGuid)
{
- CellPair p = Trinity::ComputeCellPair(GetPositionX(), GetPositionY());
+ CellCoord p = Trinity::ComputeCellCoord(GetPositionX(), GetPositionY());
Cell cell(p);
- cell.data.Part.reserved = ALL_DISTRICT;
cell.SetNoCreate();
Trinity::MonsterCustomChatBuilder say_build(*this, CHAT_MSG_MONSTER_YELL, text, language, TargetGuid);
@@ -1913,10 +1912,9 @@ void WorldObject::MonsterYell(const char* text, uint32 language, uint64 TargetGu
void WorldObject::MonsterYell(int32 textId, uint32 language, uint64 TargetGuid)
{
- CellPair p = Trinity::ComputeCellPair(GetPositionX(), GetPositionY());
+ CellCoord p = Trinity::ComputeCellCoord(GetPositionX(), GetPositionY());
Cell cell(p);
- cell.data.Part.reserved = ALL_DISTRICT;
cell.SetNoCreate();
Trinity::MonsterChatBuilder say_build(*this, CHAT_MSG_MONSTER_YELL, textId, language, TargetGuid);
@@ -1948,10 +1946,9 @@ void WorldObject::MonsterTextEmote(const char* text, uint64 TargetGuid, bool IsB
void WorldObject::MonsterTextEmote(int32 textId, uint64 TargetGuid, bool IsBossEmote)
{
- CellPair p = Trinity::ComputeCellPair(GetPositionX(), GetPositionY());
+ CellCoord p = Trinity::ComputeCellCoord(GetPositionX(), GetPositionY());
Cell cell(p);
- cell.data.Part.reserved = ALL_DISTRICT;
cell.SetNoCreate();
Trinity::MonsterChatBuilder say_build(*this, IsBossEmote ? CHAT_MSG_RAID_BOSS_EMOTE : CHAT_MSG_MONSTER_EMOTE, textId, LANG_UNIVERSAL, TargetGuid);
@@ -2393,32 +2390,30 @@ GameObject* WorldObject::FindNearestGameObject(uint32 entry, float range) const
return go;
}
-void WorldObject::GetGameObjectListWithEntryInGrid(std::list<GameObject*>& lList, uint32 uiEntry, float fMaxSearchRange) const
+void WorldObject::GetGameObjectListWithEntryInGrid(std::list<GameObject*>& gameobjectList, uint32 entry, float maxSearchRange) const
{
- CellPair pair(Trinity::ComputeCellPair(this->GetPositionX(), this->GetPositionY()));
+ CellCoord pair(Trinity::ComputeCellCoord(this->GetPositionX(), this->GetPositionY()));
Cell cell(pair);
- cell.data.Part.reserved = ALL_DISTRICT;
cell.SetNoCreate();
- Trinity::AllGameObjectsWithEntryInRange check(this, uiEntry, fMaxSearchRange);
- Trinity::GameObjectListSearcher<Trinity::AllGameObjectsWithEntryInRange> searcher(this, lList, check);
+ Trinity::AllGameObjectsWithEntryInRange check(this, entry, maxSearchRange);
+ Trinity::GameObjectListSearcher<Trinity::AllGameObjectsWithEntryInRange> searcher(this, gameobjectList, check);
TypeContainerVisitor<Trinity::GameObjectListSearcher<Trinity::AllGameObjectsWithEntryInRange>, GridTypeMapContainer> visitor(searcher);
- cell.Visit(pair, visitor, *(this->GetMap()));
+ cell.Visit(pair, visitor, *(this->GetMap()), *this, maxSearchRange);
}
-void WorldObject::GetCreatureListWithEntryInGrid(std::list<Creature*>& lList, uint32 uiEntry, float fMaxSearchRange) const
+void WorldObject::GetCreatureListWithEntryInGrid(std::list<Creature*>& creatureList, uint32 entry, float maxSearchRange) const
{
- CellPair pair(Trinity::ComputeCellPair(this->GetPositionX(), this->GetPositionY()));
+ CellCoord pair(Trinity::ComputeCellCoord(this->GetPositionX(), this->GetPositionY()));
Cell cell(pair);
- cell.data.Part.reserved = ALL_DISTRICT;
cell.SetNoCreate();
- Trinity::AllCreaturesOfEntryInRange check(this, uiEntry, fMaxSearchRange);
- Trinity::CreatureListSearcher<Trinity::AllCreaturesOfEntryInRange> searcher(this, lList, check);
+ Trinity::AllCreaturesOfEntryInRange check(this, entry, maxSearchRange);
+ Trinity::CreatureListSearcher<Trinity::AllCreaturesOfEntryInRange> searcher(this, creatureList, check);
TypeContainerVisitor<Trinity::CreatureListSearcher<Trinity::AllCreaturesOfEntryInRange>, GridTypeMapContainer> visitor(searcher);
- cell.Visit(pair, visitor, *(this->GetMap()));
+ cell.Visit(pair, visitor, *(this->GetMap()), *this, maxSearchRange);
}
/*
@@ -2529,9 +2524,8 @@ void WorldObject::GetNearPoint(WorldObject const* /*searcher*/, float &x, float
// adding used positions around object
{
- CellPair p(Trinity::ComputeCellPair(GetPositionX(), GetPositionY()));
+ CellCoord p(Trinity::ComputeCellCoord(GetPositionX(), GetPositionY()));
Cell cell(p);
- cell.data.Part.reserved = ALL_DISTRICT;
cell.SetNoCreate();
Trinity::NearUsedPosDo u_do(*this, searcher, absAngle, selector);
@@ -2731,19 +2725,19 @@ void WorldObject::DestroyForNearbyPlayers()
VisitNearbyWorldObject(GetVisibilityRange(), searcher);
for (std::list<Player*>::const_iterator iter = targets.begin(); iter != targets.end(); ++iter)
{
- Player* plr = (*iter);
+ Player* player = (*iter);
- if (plr == this)
+ if (player == this)
continue;
- if (!plr->HaveAtClient(this))
+ if (!player->HaveAtClient(this))
continue;
- if (isType(TYPEMASK_UNIT) && ((Unit*)this)->GetCharmerGUID() == plr->GetGUID()) // TODO: this is for puppet
+ if (isType(TYPEMASK_UNIT) && ((Unit*)this)->GetCharmerGUID() == player->GetGUID()) // TODO: this is for puppet
continue;
- DestroyForPlayer(plr);
- plr->m_clientGUIDs.erase(GetGUID());
+ DestroyForPlayer(player);
+ player->m_clientGUIDs.erase(GetGUID());
}
}
@@ -2811,13 +2805,13 @@ struct WorldObjectChangeAccumulator
}
}
- void BuildPacket(Player* plr)
+ void BuildPacket(Player* player)
{
// Only send update once to a player
- if (plr_list.find(plr->GetGUID()) == plr_list.end() && plr->HaveAtClient(&i_object))
+ if (plr_list.find(player->GetGUID()) == plr_list.end() && player->HaveAtClient(&i_object))
{
- i_object.BuildFieldsUpdate(plr, i_updateDatas);
- plr_list.insert(plr->GetGUID());
+ i_object.BuildFieldsUpdate(player, i_updateDatas);
+ plr_list.insert(player->GetGUID());
}
}
@@ -2826,9 +2820,8 @@ struct WorldObjectChangeAccumulator
void WorldObject::BuildUpdate(UpdateDataMapType& data_map)
{
- CellPair p = Trinity::ComputeCellPair(GetPositionX(), GetPositionY());
+ CellCoord p = Trinity::ComputeCellCoord(GetPositionX(), GetPositionY());
Cell cell(p);
- cell.data.Part.reserved = ALL_DISTRICT;
cell.SetNoCreate();
WorldObjectChangeAccumulator notifier(*this, data_map);
TypeContainerVisitor<WorldObjectChangeAccumulator, WorldTypeMapContainer > player_notifier(notifier);
diff --git a/src/server/game/Entities/Object/Object.h b/src/server/game/Entities/Object/Object.h
index 7bcd785554e..eab4dbeba99 100755
--- a/src/server/game/Entities/Object/Object.h
+++ b/src/server/game/Entities/Object/Object.h
@@ -527,9 +527,11 @@ template<class T>
class GridObject
{
public:
- GridReference<T> &GetGridRef() { return m_gridRef; }
- protected:
- GridReference<T> m_gridRef;
+ bool IsInGrid() const { return _gridRef.isValid(); }
+ void AddToGrid(GridRefManager<T>& m) { ASSERT(!IsInGrid()); _gridRef.link(&m, (T*)this); }
+ void RemoveFromGrid() { ASSERT(IsInGrid()); _gridRef.unlink(); }
+ private:
+ GridReference<T> _gridRef;
};
template <class T_VALUES, class T_FLAGS, class FLAG_TYPE, uint8 ARRAY_SIZE>
@@ -667,12 +669,17 @@ class WorldObject : public Object, public WorldLocation
}
float GetDistanceZ(const WorldObject* obj) const;
+ bool IsSelfOrInSameMap(const WorldObject* obj) const
+ {
+ if (this == obj)
+ return true;
+ return IsInMap(obj);
+ }
bool IsInMap(const WorldObject* obj) const
{
if (obj)
return IsInWorld() && obj->IsInWorld() && (GetMap() == obj->GetMap()) && InSamePhase(obj);
- else
- return false;
+ return false;
}
bool IsWithinDist3d(float x, float y, float z, float dist) const
{ return IsInDist(x, y, z, dist + GetObjectSize()); }
@@ -793,9 +800,9 @@ class WorldObject : public Object, public WorldLocation
bool isActiveObject() const { return m_isActive; }
void setActive(bool isActiveObject);
void SetWorldObject(bool apply);
- template<class NOTIFIER> void VisitNearbyObject(const float &radius, NOTIFIER &notifier) const { if (IsInWorld()) GetMap()->VisitAll(GetPositionX(), GetPositionY(), radius, notifier); }
- template<class NOTIFIER> void VisitNearbyGridObject(const float &radius, NOTIFIER &notifier) const { if (IsInWorld()) GetMap()->VisitGrid(GetPositionX(), GetPositionY(), radius, notifier); }
- template<class NOTIFIER> void VisitNearbyWorldObject(const float &radius, NOTIFIER &notifier) const { if (IsInWorld()) GetMap()->VisitWorld(GetPositionX(), GetPositionY(), radius, notifier); }
+ template<class NOTIFIER> void VisitNearbyObject(float const& radius, NOTIFIER& notifier) const { if (IsInWorld()) GetMap()->VisitAll(GetPositionX(), GetPositionY(), radius, notifier); }
+ template<class NOTIFIER> void VisitNearbyGridObject(float const& radius, NOTIFIER& notifier) const { if (IsInWorld()) GetMap()->VisitGrid(GetPositionX(), GetPositionY(), radius, notifier); }
+ template<class NOTIFIER> void VisitNearbyWorldObject(float const& radius, NOTIFIER& notifier) const { if (IsInWorld()) GetMap()->VisitWorld(GetPositionX(), GetPositionY(), radius, notifier); }
#ifdef MAP_BASED_RAND_GEN
int32 irand(int32 min, int32 max) const { return int32 (GetMap()->mtRand.randInt(max - min)) + min; }
diff --git a/src/server/game/Entities/Object/ObjectPosSelector.cpp b/src/server/game/Entities/Object/ObjectPosSelector.cpp
index c322c35ef81..fd32e531ed7 100755
--- a/src/server/game/Entities/Object/ObjectPosSelector.cpp
+++ b/src/server/game/Entities/Object/ObjectPosSelector.cpp
@@ -55,10 +55,10 @@ ObjectPosSelector::UsedPosList::value_type const* ObjectPosSelector::nextUsedPos
void ObjectPosSelector::AddUsedPos(float size, float angle, float dist)
{
- if (angle>=0)
- m_UsedPosLists[USED_POS_PLUS].insert(UsedPosList::value_type(angle, UsedPos(1.0, size, dist)));
+ if (angle >= 0)
+ m_UsedPosLists[USED_POS_PLUS].insert(UsedPosList::value_type(angle, UsedPos(1.0f, size, dist)));
else
- m_UsedPosLists[USED_POS_MINUS].insert(UsedPosList::value_type(-angle, UsedPos(-1.0, size, dist)));
+ m_UsedPosLists[USED_POS_MINUS].insert(UsedPosList::value_type(-angle, UsedPos(-1.0f, size, dist)));
}
void ObjectPosSelector::InitializeAngle()
@@ -76,9 +76,9 @@ void ObjectPosSelector::InitializeAngle()
bool ObjectPosSelector::FirstAngle(float& angle)
{
if (m_UsedPosLists[USED_POS_PLUS].empty() && !m_UsedPosLists[USED_POS_MINUS].empty() )
- return NextAngleFor(*m_UsedPosLists[USED_POS_MINUS].begin(), 1.0, USED_POS_PLUS, angle);
+ return NextAngleFor(*m_UsedPosLists[USED_POS_MINUS].begin(), 1.0f, USED_POS_PLUS, angle);
else if (m_UsedPosLists[USED_POS_MINUS].empty() && !m_UsedPosLists[USED_POS_PLUS].empty() )
- return NextAngleFor(*m_UsedPosLists[USED_POS_PLUS].begin(), -1.0, USED_POS_MINUS, angle);
+ return NextAngleFor(*m_UsedPosLists[USED_POS_PLUS].begin(), -1.0f, USED_POS_MINUS, angle);
return false;
}
@@ -118,9 +118,9 @@ bool ObjectPosSelector::NextPosibleAngle(float& angle)
{
bool ok;
if (m_smallStepOk[USED_POS_PLUS])
- ok = NextSmallStepAngle(1.0, USED_POS_PLUS, angle);
+ ok = NextSmallStepAngle(1.0f, USED_POS_PLUS, angle);
else
- ok = NextAngleFor(*m_nextUsedPos[USED_POS_PLUS], 1.0, USED_POS_PLUS, angle);
+ ok = NextAngleFor(*m_nextUsedPos[USED_POS_PLUS], 1.0f, USED_POS_PLUS, angle);
if (!ok)
++m_nextUsedPos[USED_POS_PLUS]; // increase. only at fail (original or checked)
@@ -131,9 +131,9 @@ bool ObjectPosSelector::NextPosibleAngle(float& angle)
{
bool ok;
if (m_smallStepOk[USED_POS_MINUS])
- ok = NextSmallStepAngle(-1.0, USED_POS_MINUS, angle);
+ ok = NextSmallStepAngle(-1.0f, USED_POS_MINUS, angle);
else
- ok = NextAngleFor(*m_nextUsedPos[USED_POS_MINUS], -1.0, USED_POS_MINUS, angle);
+ ok = NextAngleFor(*m_nextUsedPos[USED_POS_MINUS], -1.0f, USED_POS_MINUS, angle);
if (!ok)
++m_nextUsedPos[USED_POS_MINUS];
@@ -142,10 +142,10 @@ bool ObjectPosSelector::NextPosibleAngle(float& angle)
else // both list empty
{
if (m_smallStepOk[USED_POS_PLUS] && (!m_smallStepOk[USED_POS_MINUS] || m_smallStepAngle[USED_POS_PLUS] <= m_smallStepAngle[USED_POS_MINUS]))
- return NextSmallStepAngle(1.0, USED_POS_PLUS, angle);
+ return NextSmallStepAngle(1.0f, USED_POS_PLUS, angle);
// -- direction less updated
else if (m_smallStepOk[USED_POS_MINUS])
- return NextSmallStepAngle(-1.0, USED_POS_MINUS, angle);
+ return NextSmallStepAngle(-1.0f, USED_POS_MINUS, angle);
}
// no angles
diff --git a/src/server/game/Entities/Object/ObjectPosSelector.h b/src/server/game/Entities/Object/ObjectPosSelector.h
index efb655ca1f7..df879c4dd19 100755
--- a/src/server/game/Entities/Object/ObjectPosSelector.h
+++ b/src/server/game/Entities/Object/ObjectPosSelector.h
@@ -68,8 +68,8 @@ struct ObjectPosSelector
bool CheckOriginal() const
{
- return (m_UsedPosLists[USED_POS_PLUS].empty() || CheckAngle(*m_UsedPosLists[USED_POS_PLUS].begin(), 1.0, 0)) &&
- (m_UsedPosLists[USED_POS_MINUS].empty() || CheckAngle(*m_UsedPosLists[USED_POS_MINUS].begin(), -1.0, 0));
+ return (m_UsedPosLists[USED_POS_PLUS].empty() || CheckAngle(*m_UsedPosLists[USED_POS_PLUS].begin(), 1.0f, 0)) &&
+ (m_UsedPosLists[USED_POS_MINUS].empty() || CheckAngle(*m_UsedPosLists[USED_POS_MINUS].begin(), -1.0f, 0));
}
bool IsNonBalanced() const { return m_UsedPosLists[USED_POS_PLUS].empty() != m_UsedPosLists[USED_POS_MINUS].empty(); }
diff --git a/src/server/game/Entities/Object/Updates/UpdateMask.h b/src/server/game/Entities/Object/Updates/UpdateMask.h
index 09bc0b4cc80..abe3c299062 100755
--- a/src/server/game/Entities/Object/Updates/UpdateMask.h
+++ b/src/server/game/Entities/Object/Updates/UpdateMask.h
@@ -72,6 +72,9 @@ class UpdateMask
UpdateMask& operator = (const UpdateMask& mask)
{
+ if (this == &mask)
+ return *this;
+
SetCount(mask.mCount);
memcpy(mUpdateMask, mask.mUpdateMask, mBlocks << 2);
diff --git a/src/server/game/Entities/Pet/Pet.cpp b/src/server/game/Entities/Pet/Pet.cpp
index ca8d863dee9..404fe24d467 100755
--- a/src/server/game/Entities/Pet/Pet.cpp
+++ b/src/server/game/Entities/Pet/Pet.cpp
@@ -382,29 +382,29 @@ void Pet::SavePetToDB(PetSaveMode mode)
// current/stable/not_in_slot
if (mode >= PET_SAVE_AS_CURRENT)
{
- uint32 owner = GUID_LOPART(GetOwnerGUID());
+ uint32 ownerLowGUID = GUID_LOPART(GetOwnerGUID());
std::string name = m_name;
CharacterDatabase.EscapeString(name);
- SQLTransaction trans = CharacterDatabase.BeginTransaction();
+ trans = CharacterDatabase.BeginTransaction();
// remove current data
- trans->PAppend("DELETE FROM character_pet WHERE owner = '%u' AND id = '%u'", owner, m_charmInfo->GetPetNumber());
+ trans->PAppend("DELETE FROM character_pet WHERE owner = '%u' AND id = '%u'", ownerLowGUID, m_charmInfo->GetPetNumber());
// prevent duplicate using slot (except PET_SAVE_NOT_IN_SLOT)
if (mode <= PET_SAVE_LAST_STABLE_SLOT)
trans->PAppend("UPDATE character_pet SET slot = '%u' WHERE owner = '%u' AND slot = '%u'",
- PET_SAVE_NOT_IN_SLOT, owner, uint32(mode));
+ PET_SAVE_NOT_IN_SLOT, ownerLowGUID, uint32(mode));
// prevent existence another hunter pet in PET_SAVE_AS_CURRENT and PET_SAVE_NOT_IN_SLOT
- if (getPetType() == HUNTER_PET && (mode == PET_SAVE_AS_CURRENT||mode > PET_SAVE_LAST_STABLE_SLOT))
+ if (getPetType() == HUNTER_PET && (mode == PET_SAVE_AS_CURRENT || mode > PET_SAVE_LAST_STABLE_SLOT))
trans->PAppend("DELETE FROM character_pet WHERE owner = '%u' AND (slot = '%u' OR slot > '%u')",
- owner, PET_SAVE_AS_CURRENT, PET_SAVE_LAST_STABLE_SLOT);
+ ownerLowGUID, PET_SAVE_AS_CURRENT, PET_SAVE_LAST_STABLE_SLOT);
// save pet
std::ostringstream ss;
ss << "INSERT INTO character_pet (id, entry, owner, modelid, level, exp, Reactstate, slot, name, renamed, curhealth, curmana, curhappiness, abdata, savetime, CreatedBySpell, PetType) "
<< "VALUES ("
<< m_charmInfo->GetPetNumber() << ','
<< GetEntry() << ','
- << owner << ','
+ << ownerLowGUID << ','
<< GetNativeDisplayId() << ','
<< uint32(getLevel()) << ','
<< GetUInt32Value(UNIT_FIELD_PETEXPERIENCE) << ','
@@ -618,7 +618,7 @@ void Pet::LoseHappiness()
return;
int32 addvalue = 670; //value is 70/35/17/8/4 (per min) * 1000 / 8 (timer 7.5 secs)
if (isInCombat()) //we know in combat happiness fades faster, multiplier guess
- addvalue = int32(addvalue * 1.5);
+ addvalue = int32(addvalue * 1.5f);
ModifyPower(POWER_HAPPINESS, -addvalue);
}
diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp
index 8d799e46085..401e965f816 100755
--- a/src/server/game/Entities/Player/Player.cpp
+++ b/src/server/game/Entities/Player/Player.cpp
@@ -279,10 +279,8 @@ uint32 PlayerTaxi::GetCurrentTaxiPath() const
std::ostringstream& operator<< (std::ostringstream& ss, PlayerTaxi const& taxi)
{
- ss << '\'';
for (uint8 i = 0; i < TaxiMaskSize; ++i)
ss << taxi.m_taximask[i] << ' ';
- ss << '\'';
return ss;
}
@@ -940,7 +938,7 @@ bool Player::Create(uint32 guidlow, CharacterCreateInfo* createInfo)
return false;
}
- SetMap(sMapMgr->CreateMap(info->mapId, this, 0));
+ SetMap(sMapMgr->CreateMap(info->mapId, this));
uint8 powertype = cEntry->powerType;
@@ -1148,7 +1146,7 @@ bool Player::Create(uint32 guidlow, CharacterCreateInfo* createInfo)
}
}
- for (PlayerCreateInfoItems::const_iterator item_id_itr = info->item.begin(); item_id_itr != info->item.end(); ++item_id_itr++)
+ for (PlayerCreateInfoItems::const_iterator item_id_itr = info->item.begin(); item_id_itr != info->item.end(); ++item_id_itr)
StoreNewItemInBestSlots(item_id_itr->item_id, item_id_itr->item_amount);
// bags and main-hand weapon must equipped at this moment
@@ -2020,21 +2018,20 @@ bool Player::ToggleDND()
return HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_DND);
}
-uint8 Player::chatTag() const
+uint8 Player::GetChatTag() const
{
- // it's bitmask
- // 0x8 - ??
- // 0x4 - gm
- // 0x2 - dnd
- // 0x1 - afk
+ uint8 tag = CHAT_TAG_NONE;
+
if (isGMChat())
- return 4;
- else if (isDND())
- return 3;
+ tag |= CHAT_TAG_GM;
+ if (isDND())
+ tag |= CHAT_TAG_DND;
if (isAFK())
- return 1;
- else
- return 0;
+ tag |= CHAT_TAG_AFK;
+ if (HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_DEVELOPER))
+ tag |= CHAT_TAG_DEV;
+
+ return tag;
}
void Player::SendTeleportPacket(Position &oldPos)
@@ -2206,8 +2203,11 @@ bool Player::TeleportTo(uint32 mapid, float x, float y, float z, float orientati
if (!sMapMgr->CanPlayerEnter(mapid, this, false))
return false;
- Map* map = sMapMgr->CreateMap(mapid, this, 0);
- if (!map || map->CanEnter(this))
+ //I think this always returns true. Correct me if I am wrong.
+ // If the map is not created, assume it is possible to enter it.
+ // It will be created in the WorldPortAck.
+ //Map* map = sMapMgr->FindBaseNonInstanceMap(mapid);
+ //if (!map || map->CanEnter(this))
{
//lets reset near teleport flag if it wasn't reset during chained teleports
SetSemaphoreTeleportNear(false);
@@ -2278,7 +2278,7 @@ bool Player::TeleportTo(uint32 mapid, float x, float y, float z, float orientati
// remove from old map now
if (oldmap)
- oldmap->RemoveFromMap(this, false);
+ oldmap->RemovePlayerFromMap(this, false);
// new final coordinates
float final_x = x;
@@ -2316,8 +2316,8 @@ bool Player::TeleportTo(uint32 mapid, float x, float y, float z, float orientati
// code for finish transfer to new map called in WorldSession::HandleMoveWorldportAckOpcode at client packet
SetSemaphoreTeleportFar(true);
}
- else
- return false;
+ //else
+ // return false;
}
return true;
}
@@ -2456,7 +2456,7 @@ void Player::RegenerateAll()
// Runes act as cooldowns, and they don't need to send any data
if (getClass() == CLASS_DEATH_KNIGHT)
- for (uint32 i = 0; i < MAX_RUNES; ++i)
+ for (uint8 i = 0; i < MAX_RUNES; ++i)
if (uint32 cd = GetRuneCooldown(i))
SetRuneCooldown(i, (cd > m_regenTimer) ? cd - m_regenTimer : 0);
@@ -2631,7 +2631,7 @@ void Player::RegenerateHealth()
ApplyPctN(addvalue, GetTotalAuraModifier(SPELL_AURA_MOD_REGEN_DURING_COMBAT));
if (!IsStandState())
- addvalue *= 1.5;
+ addvalue *= 1.5f;
}
// always regeneration bonus (including combat)
@@ -2860,7 +2860,6 @@ void Player::SetGMVisible(bool on)
if (on)
{
m_ExtraFlags &= ~PLAYER_EXTRA_GM_INVISIBLE; //remove flag
-
m_serverSideVisibility.SetValue(SERVERSIDE_VISIBILITY_GM, SEC_PLAYER);
}
else
@@ -3089,7 +3088,8 @@ void Player::GiveLevel(uint8 level)
// Refer-A-Friend
if (GetSession()->GetRecruiterId())
if (level < sWorld->getIntConfig(CONFIG_MAX_RECRUIT_A_FRIEND_BONUS_PLAYER_LEVEL))
- if (level % 2 == 0) {
+ if (level % 2 == 0)
+ {
++m_grantableLevels;
if (!HasByteFlag(PLAYER_FIELD_BYTES, 1, 0x01))
@@ -3484,7 +3484,7 @@ bool Player::AddTalent(uint32 spell_id, uint8 spec, bool learning)
if (!rankSpellId || rankSpellId == spell_id)
continue;
- PlayerTalentMap::iterator itr = m_talents[spec]->find(rankSpellId);
+ itr = m_talents[spec]->find(rankSpellId);
if (itr != m_talents[spec]->end())
itr->second->state = PLAYERSPELL_REMOVED;
}
@@ -4094,8 +4094,6 @@ void Player::removeSpell(uint32 spell_id, bool disabled, bool learn_low_rank)
if (uint32 prev_id = sSpellMgr->GetPrevSpellInChain(spell_id))
{
- SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spell_id);
-
// if talent then lesser rank also talent and need learn
if (talentCosts)
{
@@ -4243,8 +4241,8 @@ void Player::RemoveArenaSpellCooldowns(bool removeActivePetCooldowns)
if (Pet* pet = GetPet())
{
// notify player
- for (CreatureSpellCooldowns::const_iterator itr = pet->m_CreatureSpellCooldowns.begin(); itr != pet->m_CreatureSpellCooldowns.end(); ++itr)
- SendClearCooldown(itr->first, pet);
+ for (CreatureSpellCooldowns::const_iterator itr2 = pet->m_CreatureSpellCooldowns.begin(); itr2 != pet->m_CreatureSpellCooldowns.end(); ++itr2)
+ SendClearCooldown(itr2->first, pet);
// actually clear cooldowns
pet->m_CreatureSpellCooldowns.clear();
@@ -4397,9 +4395,9 @@ bool Player::resetTalents(bool no_cost)
RemovePet(NULL, PET_SAVE_NOT_IN_SLOT, true);
- for (uint32 i = 0; i < sTalentStore.GetNumRows(); ++i)
+ for (uint32 talentId = 0; talentId < sTalentStore.GetNumRows(); ++talentId)
{
- TalentEntry const* talentInfo = sTalentStore.LookupEntry(i);
+ TalentEntry const* talentInfo = sTalentStore.LookupEntry(talentId);
if (!talentInfo)
continue;
@@ -4835,14 +4833,14 @@ void Player::DeleteFromDB(uint64 playerguid, uint32 accountId, bool updateRealmC
{
do
{
- Field* fields = resultItems->Fetch();
- uint32 item_guidlow = fields[11].GetUInt32();
- uint32 item_template = fields[12].GetUInt32();
+ Field* fields2 = resultItems->Fetch();
+ uint32 item_guidlow = fields2[11].GetUInt32();
+ uint32 item_template = fields2[12].GetUInt32();
ItemTemplate const* itemProto = sObjectMgr->GetItemTemplate(item_template);
if (!itemProto)
{
- PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_ITEM_INSTANCE);
+ stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_ITEM_INSTANCE);
stmt->setUInt32(0, item_guidlow);
trans->Append(stmt);
continue;
@@ -5063,7 +5061,7 @@ void Player::BuildPlayerRepop()
StopMirrorTimers(); //disable timers(bars)
- SetFloatValue(UNIT_FIELD_BOUNDINGRADIUS, (float)1.0); //see radius of death player?
+ SetFloatValue(UNIT_FIELD_BOUNDINGRADIUS, float(1.0f)); //see radius of death player?
// set and clear other
SetByteValue(UNIT_FIELD_BYTES_1, 3, UNIT_BYTE1_FLAG_ALWAYS_STAND);
@@ -5089,8 +5087,6 @@ void Player::ResurrectPlayer(float restore_percent, bool applySickness)
if (GetSession()->IsARecruiter() || (GetSession()->GetRecruiterId() != 0))
SetFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_REFER_A_FRIEND);
- setDeathState(ALIVE);
-
SetMovement(MOVE_LAND_WALK);
SetMovement(MOVE_UNROOT);
@@ -5120,6 +5116,8 @@ void Player::ResurrectPlayer(float restore_percent, bool applySickness)
// update visibility
UpdateObjectVisibility();
+ setDeathState(ALIVE);
+
if (!applySickness)
return;
@@ -6176,13 +6174,13 @@ static uint32 bonusSkillLevels[] = {75, 150, 225, 300, 375, 450};
bool Player::UpdateSkillPro(uint16 SkillId, int32 Chance, uint32 step)
{
- sLog->outDebug(LOG_FILTER_PLAYER_SKILLS, "UpdateSkillPro(SkillId %d, Chance %3.1f%%)", SkillId, Chance/10.0);
+ sLog->outDebug(LOG_FILTER_PLAYER_SKILLS, "UpdateSkillPro(SkillId %d, Chance %3.1f%%)", SkillId, Chance / 10.0f);
if (!SkillId)
return false;
if (Chance <= 0) // speedup in 0 chance case
{
- sLog->outDebug(LOG_FILTER_PLAYER_SKILLS, "Player::UpdateSkillPro Chance=%3.1f%% missed", Chance/10.0);
+ sLog->outDebug(LOG_FILTER_PLAYER_SKILLS, "Player::UpdateSkillPro Chance=%3.1f%% missed", Chance / 10.0f);
return false;
}
@@ -6220,19 +6218,19 @@ bool Player::UpdateSkillPro(uint16 SkillId, int32 Chance, uint32 step)
}
UpdateSkillEnchantments(SkillId, SkillValue, new_value);
GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_REACH_SKILL_LEVEL, SkillId);
- sLog->outDebug(LOG_FILTER_PLAYER_SKILLS, "Player::UpdateSkillPro Chance=%3.1f%% taken", Chance/10.0);
+ sLog->outDebug(LOG_FILTER_PLAYER_SKILLS, "Player::UpdateSkillPro Chance=%3.1f%% taken", Chance / 10.0f);
return true;
}
- sLog->outDebug(LOG_FILTER_PLAYER_SKILLS, "Player::UpdateSkillPro Chance=%3.1f%% missed", Chance/10.0);
+ sLog->outDebug(LOG_FILTER_PLAYER_SKILLS, "Player::UpdateSkillPro Chance=%3.1f%% missed", Chance / 10.0f);
return false;
}
-void Player::UpdateWeaponSkill (WeaponAttackType attType)
+void Player::UpdateWeaponSkill(WeaponAttackType attType)
{
// no skill gain in pvp
- Unit* pVictim = getVictim();
- if (pVictim && pVictim->GetTypeId() == TYPEID_PLAYER)
+ Unit* victim = getVictim();
+ if (victim && victim->GetTypeId() == TYPEID_PLAYER)
return;
if (IsInFeralForm())
@@ -6241,42 +6239,25 @@ void Player::UpdateWeaponSkill (WeaponAttackType attType)
if (GetShapeshiftForm() == FORM_TREE)
return; // use weapon but not skill up
- if (pVictim && pVictim->GetTypeId() == TYPEID_UNIT && (pVictim->ToCreature()->GetCreatureInfo()->flags_extra & CREATURE_FLAG_EXTRA_NO_SKILLGAIN))
+ if (victim && victim->GetTypeId() == TYPEID_UNIT && (victim->ToCreature()->GetCreatureInfo()->flags_extra & CREATURE_FLAG_EXTRA_NO_SKILLGAIN))
return;
uint32 weapon_skill_gain = sWorld->getIntConfig(CONFIG_SKILL_GAIN_WEAPON);
- switch (attType)
- {
- case BASE_ATTACK:
- {
- Item* tmpitem = GetWeaponForAttack(attType, true);
+ Item* tmpitem = GetWeaponForAttack(attType, true);
+ if (!tmpitem && attType == BASE_ATTACK)
+ UpdateSkill(SKILL_UNARMED, weapon_skill_gain);
+ else if (tmpitem && tmpitem->GetTemplate()->SubClass != ITEM_SUBCLASS_WEAPON_FISHING_POLE)
+ UpdateSkill(tmpitem->GetSkill(), weapon_skill_gain);
- if (!tmpitem)
- UpdateSkill(SKILL_UNARMED, weapon_skill_gain);
- else if (tmpitem->GetTemplate()->SubClass != ITEM_SUBCLASS_WEAPON_FISHING_POLE)
- UpdateSkill(tmpitem->GetSkill(), weapon_skill_gain);
- break;
- }
- case OFF_ATTACK:
- case RANGED_ATTACK:
- {
- Item* tmpitem = GetWeaponForAttack(attType, true);
- if (tmpitem)
- UpdateSkill(tmpitem->GetSkill(), weapon_skill_gain);
- break;
- }
- default:
- break;
- }
UpdateAllCritPercentages();
}
-void Player::UpdateCombatSkills(Unit* pVictim, WeaponAttackType attType, bool defence)
+void Player::UpdateCombatSkills(Unit* victim, WeaponAttackType attType, bool defence)
{
- uint8 plevel = getLevel(); // if defense than pVictim == attacker
+ uint8 plevel = getLevel(); // if defense than victim == attacker
uint8 greylevel = Trinity::XP::GetGrayLevel(plevel);
- uint8 moblevel = pVictim->getLevelForTarget(this);
+ uint8 moblevel = victim->getLevelForTarget(this);
if (moblevel < greylevel)
return;
@@ -7035,22 +7016,22 @@ void Player::RewardReputation(Quest const* quest)
// quest reputation reward/loss
for (uint8 i = 0; i < QUEST_REPUTATIONS_COUNT; ++i)
{
- if (!quest->RewRepFaction[i])
+ if (!quest->RewardFactionId[i])
continue;
- if (quest->RewRepValue[i])
+ if (quest->RewardFactionValueIdOverride[i])
{
- int32 rep = CalculateReputationGain(GetQuestLevel(quest), quest->RewRepValue[i]/100, quest->RewRepFaction[i], true, true);
+ int32 rep = CalculateReputationGain(GetQuestLevel(quest), quest->RewardFactionValueIdOverride[i]/100, quest->RewardFactionId[i], true, true);
if (recruitAFriend)
rep = int32(rep * (1 + sWorld->getRate(RATE_REPUTATION_RECRUIT_A_FRIEND_BONUS)));
- if (FactionEntry const* factionEntry = sFactionStore.LookupEntry(quest->RewRepFaction[i]))
+ if (FactionEntry const* factionEntry = sFactionStore.LookupEntry(quest->RewardFactionId[i]))
GetReputationMgr().ModifyReputation(factionEntry, rep);
}
else
{
- uint32 row = ((quest->RewRepValueId[i] < 0) ? 1 : 0) + 1;
- uint32 field = abs(quest->RewRepValueId[i]);
+ uint32 row = ((quest->RewardFactionValueId[i] < 0) ? 1 : 0) + 1;
+ uint32 field = abs(quest->RewardFactionValueId[i]);
if (const QuestFactionRewEntry* pRow = sQuestFactionRewardStore.LookupEntry(row))
{
@@ -7059,12 +7040,12 @@ void Player::RewardReputation(Quest const* quest)
if (!repPoints)
continue;
- repPoints = CalculateReputationGain(GetQuestLevel(quest), repPoints, quest->RewRepFaction[i], true);
+ repPoints = CalculateReputationGain(GetQuestLevel(quest), repPoints, quest->RewardFactionId[i], true);
if (recruitAFriend)
repPoints = int32(repPoints * (1 + sWorld->getRate(RATE_REPUTATION_RECRUIT_A_FRIEND_BONUS)));
- if (const FactionEntry* factionEntry = sFactionStore.LookupEntry(quest->RewRepFaction[i]))
+ if (const FactionEntry* factionEntry = sFactionStore.LookupEntry(quest->RewardFactionId[i]))
GetReputationMgr().ModifyReputation(factionEntry, repPoints);
}
}
@@ -9533,7 +9514,7 @@ void Player::SendInitWorldStates(uint32 zoneid, uint32 areaid)
// End Round (timer), better explain this by example, eg. ends in 19:59 -> A:BC
data << uint32(0xde9) << uint32(0x0); // 16 3561 C
data << uint32(0xde8) << uint32(0x0); // 17 3560 B
- data << uint32(0xde7) << uint32(0x0); // 18 3559 A
+ data << uint32(0xde7) << uint32(0x0); // 18 3559 A
data << uint32(0xe35) << uint32(0x0); // 19 3637 East g - Horde control
data << uint32(0xe34) << uint32(0x0); // 20 3636 West g - Horde control
data << uint32(0xe33) << uint32(0x0); // 21 3635 South g - Horde control
@@ -11898,8 +11879,14 @@ void Player::RemoveAmmo()
UpdateDamagePhysical(RANGED_ATTACK);
}
+Item* Player::StoreNewItem(ItemPosCountVec const& dest, uint32 item, bool update, int32 randomPropertyId)
+{
+ AllowedLooterSet allowedLooters;
+ return StoreNewItem(dest, item, update, randomPropertyId, allowedLooters);
+}
+
// Return stored item (if stored to stack, it can diff. from pItem). And pItem ca be deleted in this case.
-Item* Player::StoreNewItem(ItemPosCountVec const& dest, uint32 item, bool update, int32 randomPropertyId, AllowedLooterSet* allowedLooters)
+Item* Player::StoreNewItem(ItemPosCountVec const& dest, uint32 item, bool update, int32 randomPropertyId, AllowedLooterSet& allowedLooters)
{
uint32 count = 0;
for (ItemPosCountVec::const_iterator itr = dest.begin(); itr != dest.end(); ++itr)
@@ -11919,16 +11906,18 @@ Item* Player::StoreNewItem(ItemPosCountVec const& dest, uint32 item, bool update
if (proto->Spells[i].SpellTrigger == ITEM_SPELLTRIGGER_ON_NO_DELAY_USE && proto->Spells[i].SpellId > 0) // On obtain trigger
CastSpell(this, proto->Spells[i].SpellId, true, pItem);
- if (allowedLooters && pItem->GetTemplate()->GetMaxStackSize() == 1 && pItem->IsSoulBound())
+ if (allowedLooters.size() > 1 && pItem->GetTemplate()->GetMaxStackSize() == 1 && pItem->IsSoulBound())
{
- pItem->SetSoulboundTradeable(allowedLooters, this, true);
+ pItem->SetSoulboundTradeable(allowedLooters);
pItem->SetUInt32Value(ITEM_FIELD_CREATE_PLAYED_TIME, GetTotalPlayedTime());
m_itemSoulboundTradeable.push_back(pItem);
// save data
std::ostringstream ss;
- for (AllowedLooterSet::iterator itr = allowedLooters->begin(); itr != allowedLooters->end(); ++itr)
- ss << *itr << ' ';
+ AllowedLooterSet::const_iterator itr = allowedLooters.begin();
+ ss << *itr;
+ for (++itr; itr != allowedLooters.end(); ++itr)
+ ss << ' ' << *itr;
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_ADD_ITEM_BOP_TRADE);
stmt->setUInt32(0, pItem->GetGUIDLow());
@@ -12051,7 +12040,7 @@ Item* Player::_StoreItem(uint16 pos, Item* pItem, uint32 count, bool clone, bool
pItem->SetOwnerGUID(GetGUID()); // prevent error at next SetState in case trade/mail/buy from vendor
pItem->SetNotRefundable(this);
- pItem->SetSoulboundTradeable(NULL, this, false);
+ pItem->ClearSoulboundTradeable(this);
RemoveTradeableItem(pItem);
pItem->SetState(ITEM_REMOVED, this);
}
@@ -12168,7 +12157,7 @@ Item* Player::EquipItem(uint16 pos, Item* pItem, bool update)
pItem->SetOwnerGUID(GetGUID()); // prevent error at next SetState in case trade/mail/buy from vendor
pItem->SetNotRefundable(this);
- pItem->SetSoulboundTradeable(NULL, this, false);
+ pItem->ClearSoulboundTradeable(this);
RemoveTradeableItem(pItem);
pItem->SetState(ITEM_REMOVED, this);
pItem2->SetState(ITEM_CHANGED, this);
@@ -12388,7 +12377,7 @@ void Player::DestroyItem(uint8 bag, uint8 slot, bool update)
RemoveItemDurations(pItem);
pItem->SetNotRefundable(this);
- pItem->SetSoulboundTradeable(NULL, this, false);
+ pItem->ClearSoulboundTradeable(this);
RemoveTradeableItem(pItem);
const ItemTemplate* proto = pItem->GetTemplate();
@@ -13335,17 +13324,17 @@ void Player::UpdateSoulboundTradeItems()
{
if (!*itr)
{
- itr = m_itemSoulboundTradeable.erase(itr++);
+ m_itemSoulboundTradeable.erase(itr++);
continue;
}
if ((*itr)->GetOwnerGUID() != GetGUID())
{
- itr = m_itemSoulboundTradeable.erase(itr++);
+ m_itemSoulboundTradeable.erase(itr++);
continue;
}
if ((*itr)->CheckSoulboundTradeExpire())
{
- itr = m_itemSoulboundTradeable.erase(itr++);
+ m_itemSoulboundTradeable.erase(itr++);
continue;
}
++itr;
@@ -13591,7 +13580,7 @@ void Player::ApplyEnchantment(Item* item, EnchantmentSlot slot, bool apply, bool
}
}
}
- // Cast custom spell vs all equal basepoints getted from enchant_amount
+ // Cast custom spell vs all equal basepoints got from enchant_amount
if (basepoints)
CastCustomSpell(this, enchant_spell_id, &basepoints, &basepoints, &basepoints, true, item);
else
@@ -14525,7 +14514,7 @@ Quest const* Player::GetNextQuest(uint64 guid, Quest const* quest)
bool Player::CanSeeStartQuest(Quest const* quest)
{
- if (SatisfyQuestRace(quest, false) && SatisfyQuestSkillOrClass(quest, false) &&
+ if (SatisfyQuestClass(quest, false) && SatisfyQuestRace(quest, false) && SatisfyQuestSkill(quest, false) &&
SatisfyQuestExclusiveGroup(quest, false) && SatisfyQuestReputation(quest, false) &&
SatisfyQuestPreviousQuest(quest, false) && SatisfyQuestNextChain(quest, false) &&
SatisfyQuestPrevChain(quest, false) && SatisfyQuestDay(quest, false) && SatisfyQuestWeek(quest, false) &&
@@ -14540,8 +14529,8 @@ bool Player::CanSeeStartQuest(Quest const* quest)
bool Player::CanTakeQuest(Quest const* quest, bool msg)
{
return SatisfyQuestStatus(quest, msg) && SatisfyQuestExclusiveGroup(quest, msg)
- && SatisfyQuestRace(quest, msg) && SatisfyQuestLevel(quest, msg)
- && SatisfyQuestSkillOrClass(quest, msg) && SatisfyQuestReputation(quest, msg)
+ && SatisfyQuestClass(quest, msg) && SatisfyQuestRace(quest, msg) && SatisfyQuestLevel(quest, msg)
+ && SatisfyQuestSkill(quest, msg) && SatisfyQuestReputation(quest, msg)
&& SatisfyQuestPreviousQuest(quest, msg) && SatisfyQuestTimed(quest, msg)
&& SatisfyQuestNextChain(quest, msg) && SatisfyQuestPrevChain(quest, msg)
&& SatisfyQuestDay(quest, msg) && SatisfyQuestWeek(quest, msg)
@@ -14581,8 +14570,7 @@ bool Player::CanCompleteQuest(uint32 quest_id)
if (!qInfo)
return false;
- RewardedQuestSet::iterator rewItr = m_RewardedQuests.find(quest_id);
- if (!qInfo->IsRepeatable() && rewItr != m_RewardedQuests.end())
+ if (!qInfo->IsRepeatable() && m_RewardedQuests.find(quest_id) != m_RewardedQuests.end())
return false; // not allow re-complete quest
// auto complete quest
@@ -14601,7 +14589,7 @@ bool Player::CanCompleteQuest(uint32 quest_id)
{
for (uint8 i = 0; i < QUEST_ITEM_OBJECTIVES_COUNT; i++)
{
- if (qInfo->ReqItemCount[i]!= 0 && q_status.m_itemcount[i] < qInfo->ReqItemCount[i])
+ if (qInfo->RequiredItemCount[i]!= 0 && q_status.m_itemcount[i] < qInfo->RequiredItemCount[i])
return false;
}
}
@@ -14610,10 +14598,10 @@ bool Player::CanCompleteQuest(uint32 quest_id)
{
for (uint8 i = 0; i < QUEST_OBJECTIVES_COUNT; i++)
{
- if (qInfo->ReqCreatureOrGOId[i] == 0)
+ if (qInfo->RequiredNpcOrGo[i] == 0)
continue;
- if (qInfo->ReqCreatureOrGOCount[i] != 0 && q_status.m_creatureOrGOcount[i] < qInfo->ReqCreatureOrGOCount[i])
+ if (qInfo->RequiredNpcOrGoCount[i] != 0 && q_status.m_creatureOrGOcount[i] < qInfo->RequiredNpcOrGoCount[i])
return false;
}
}
@@ -14654,7 +14642,7 @@ bool Player::CanCompleteRepeatableQuest(Quest const* quest)
if (quest->HasFlag(QUEST_TRINITY_FLAGS_DELIVER))
for (uint8 i = 0; i < QUEST_ITEM_OBJECTIVES_COUNT; i++)
- if (quest->ReqItemId[i] && quest->ReqItemCount[i] && !HasItemCount(quest->ReqItemId[i], quest->ReqItemCount[i]))
+ if (quest->RequiredItemId[i] && quest->RequiredItemCount[i] && !HasItemCount(quest->RequiredItemId[i], quest->RequiredItemCount[i]))
return false;
if (!CanRewardQuest(quest, false))
@@ -14682,11 +14670,11 @@ bool Player::CanRewardQuest(Quest const* quest, bool msg)
{
for (uint8 i = 0; i < QUEST_ITEM_OBJECTIVES_COUNT; i++)
{
- if (quest->ReqItemCount[i]!= 0 &&
- GetItemCount(quest->ReqItemId[i]) < quest->ReqItemCount[i])
+ if (quest->RequiredItemCount[i]!= 0 &&
+ GetItemCount(quest->RequiredItemId[i]) < quest->RequiredItemCount[i])
{
if (msg)
- SendEquipError(EQUIP_ERR_ITEM_NOT_FOUND, NULL, NULL, quest->ReqItemId[i]);
+ SendEquipError(EQUIP_ERR_ITEM_NOT_FOUND, NULL, NULL, quest->RequiredItemId[i]);
return false;
}
}
@@ -14707,13 +14695,13 @@ bool Player::CanRewardQuest(Quest const* quest, uint32 reward, bool msg)
if (quest->GetRewChoiceItemsCount() > 0)
{
- if (quest->RewChoiceItemId[reward])
+ if (quest->RewardChoiceItemId[reward])
{
ItemPosCountVec dest;
- InventoryResult res = CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, quest->RewChoiceItemId[reward], quest->RewChoiceItemCount[reward]);
+ InventoryResult res = CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, quest->RewardChoiceItemId[reward], quest->RewardChoiceItemCount[reward]);
if (res != EQUIP_ERR_OK)
{
- SendEquipError(res, NULL, NULL, quest->RewChoiceItemId[reward]);
+ SendEquipError(res, NULL, NULL, quest->RewardChoiceItemId[reward]);
return false;
}
}
@@ -14723,13 +14711,13 @@ bool Player::CanRewardQuest(Quest const* quest, uint32 reward, bool msg)
{
for (uint32 i = 0; i < quest->GetRewItemsCount(); ++i)
{
- if (quest->RewItemId[i])
+ if (quest->RewardItemId[i])
{
ItemPosCountVec dest;
- InventoryResult res = CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, quest->RewItemId[i], quest->RewItemCount[i]);
+ InventoryResult res = CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, quest->RewardItemId[i], quest->RewardItemIdCount[i]);
if (res != EQUIP_ERR_OK)
{
- SendEquipError(res, NULL, NULL, quest->RewItemId[i]);
+ SendEquipError(res, NULL, NULL, quest->RewardItemId[i]);
return false;
}
}
@@ -14862,15 +14850,15 @@ void Player::RewardQuest(Quest const* quest, uint32 reward, Object* questGiver,
uint32 quest_id = quest->GetQuestId();
for (uint8 i = 0; i < QUEST_ITEM_OBJECTIVES_COUNT; ++i)
- if (quest->ReqItemId[i])
- DestroyItemCount(quest->ReqItemId[i], quest->ReqItemCount[i], true);
+ if (quest->RequiredItemId[i])
+ DestroyItemCount(quest->RequiredItemId[i], quest->RequiredItemCount[i], true);
for (uint8 i = 0; i < QUEST_SOURCE_ITEM_IDS_COUNT; ++i)
{
- if (quest->ReqSourceId[i])
+ if (quest->RequiredSourceItemid[i])
{
- uint32 count = quest->ReqSourceCount[i];
- DestroyItemCount(quest->ReqSourceId[i], count ? count : 9999, true);
+ uint32 count = quest->RequiredSourceItemId[i];
+ DestroyItemCount(quest->RequiredSourceItemid[i], count ? count : 9999, true);
}
}
@@ -14878,13 +14866,13 @@ void Player::RewardQuest(Quest const* quest, uint32 reward, Object* questGiver,
if (quest->GetRewChoiceItemsCount() > 0)
{
- if (uint32 itemId = quest->RewChoiceItemId[reward])
+ if (uint32 itemId = quest->RewardChoiceItemId[reward])
{
ItemPosCountVec dest;
- if (CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, itemId, quest->RewChoiceItemCount[reward]) == EQUIP_ERR_OK)
+ if (CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, itemId, quest->RewardChoiceItemCount[reward]) == EQUIP_ERR_OK)
{
Item* item = StoreNewItem(dest, itemId, true, Item::GenerateItemRandomPropertyId(itemId));
- SendNewItem(item, quest->RewChoiceItemCount[reward], true, false);
+ SendNewItem(item, quest->RewardChoiceItemCount[reward], true, false);
}
}
}
@@ -14893,13 +14881,13 @@ void Player::RewardQuest(Quest const* quest, uint32 reward, Object* questGiver,
{
for (uint32 i = 0; i < quest->GetRewItemsCount(); ++i)
{
- if (uint32 itemId = quest->RewItemId[i])
+ if (uint32 itemId = quest->RewardItemId[i])
{
ItemPosCountVec dest;
- if (CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, itemId, quest->RewItemCount[i]) == EQUIP_ERR_OK)
+ if (CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, itemId, quest->RewardItemIdCount[i]) == EQUIP_ERR_OK)
{
Item* item = StoreNewItem(dest, itemId, true, Item::GenerateItemRandomPropertyId(itemId));
- SendNewItem(item, quest->RewItemCount[i], true, false);
+ SendNewItem(item, quest->RewardItemIdCount[i], true, false);
}
}
}
@@ -14911,8 +14899,7 @@ void Player::RewardQuest(Quest const* quest, uint32 reward, Object* questGiver,
if (log_slot < MAX_QUEST_LOG_SIZE)
SetQuestSlot(log_slot, 0);
- RewardedQuestSet::const_iterator rewItr = m_RewardedQuests.find(quest_id);
- bool rewarded = (rewItr != m_RewardedQuests.end());
+ bool rewarded = (m_RewardedQuests.find(quest_id) != m_RewardedQuests.end());
// Not give XP in case already completed once repeatable quest
uint32 XP = rewarded ? 0 : uint32(quest->XPValue(this)*sWorld->getRate(RATE_XP_QUEST));
@@ -15064,57 +15051,31 @@ void Player::FailQuest(uint32 questId)
// Destroy quest items on quest failure.
for (uint8 i = 0; i < QUEST_OBJECTIVES_COUNT; ++i)
- if (quest->ReqItemId[i] > 0 && quest->ReqItemCount[i] > 0)
+ if (quest->RequiredItemId[i] > 0 && quest->RequiredItemCount[i] > 0)
// Destroy items recieved on starting the quest.
- DestroyItemCount(quest->ReqItemId[i], quest->ReqItemCount[i], true, true);
+ DestroyItemCount(quest->RequiredItemId[i], quest->RequiredItemCount[i], true, true);
for (uint8 i = 0; i < QUEST_SOURCE_ITEM_IDS_COUNT; ++i)
- if (quest->ReqSourceId[i] > 0 && quest->ReqSourceCount[i] > 0)
+ if (quest->RequiredSourceItemid[i] > 0 && quest->RequiredSourceItemId[i] > 0)
// Destroy items recieved during the quest.
- DestroyItemCount(quest->ReqSourceId[i], quest->ReqSourceCount[i], true, true);
+ DestroyItemCount(quest->RequiredSourceItemid[i], quest->RequiredSourceItemId[i], true, true);
}
}
-bool Player::SatisfyQuestSkillOrClass(Quest const* qInfo, bool msg)
+bool Player::SatisfyQuestSkill(Quest const* qInfo, bool msg) const
{
- int32 zoneOrSort = qInfo->GetZoneOrSort();
- int32 skillOrClassMask = qInfo->GetSkillOrClassMask();
+ uint32 skill = qInfo->GetRequiredSkill();
- // skip zone zoneOrSort and 0 case skillOrClass
- if (zoneOrSort >= 0 && skillOrClassMask == 0)
+ // skip 0 case RequiredSkill
+ if (skill == 0)
return true;
- int32 questSort = -zoneOrSort;
- uint8 reqSortClass = ClassByQuestSort(questSort);
-
- // check class sort cases in zoneOrSort
- if (reqSortClass != 0 && getClass() != reqSortClass)
+ // check skill value
+ if (GetSkillValue(skill) < qInfo->GetRequiredSkillValue())
{
if (msg)
SendCanTakeQuestResponse(INVALIDREASON_DONT_HAVE_REQ);
- return false;
- }
- // check class
- if (skillOrClassMask < 0)
- {
- uint32 reqClassMask = -int32(skillOrClassMask);
- if (!(reqClassMask & getClassMask()))
- {
- if (msg)
- SendCanTakeQuestResponse(INVALIDREASON_DONT_HAVE_REQ);
- return false;
- }
- }
- // check skill
- else if (skillOrClassMask > 0)
- {
- uint32 reqSkill = skillOrClassMask;
- if (GetSkillValue(reqSkill) < qInfo->GetRequiredSkillValue())
- {
- if (msg)
- SendCanTakeQuestResponse(INVALIDREASON_DONT_HAVE_REQ);
- return false;
- }
+ return false;
}
return true;
@@ -15242,6 +15203,24 @@ bool Player::SatisfyQuestPreviousQuest(Quest const* qInfo, bool msg)
return false;
}
+bool Player::SatisfyQuestClass(Quest const* qInfo, bool msg) const
+{
+ uint32 reqClass = qInfo->GetRequiredClasses();
+
+ if (reqClass == 0)
+ return true;
+
+ if ((reqClass & getClassMask()) == 0)
+ {
+ if (msg)
+ SendCanTakeQuestResponse(INVALIDREASON_DONT_HAVE_REQ);
+
+ return false;
+ }
+
+ return true;
+}
+
bool Player::SatisfyQuestRace(Quest const* qInfo, bool msg)
{
uint32 reqraces = qInfo->GetRequiredRaces();
@@ -15499,7 +15478,7 @@ bool Player::TakeQuestSourceItem(uint32 questId, bool msg)
// exist two cases when destroy source quest item not possible:
// a) non un-equippable item (equipped non-empty bag, for example)
// b) when quest is started from an item and item also is needed in
- // the end as ReqItemId
+ // the end as RequiredItemId
InventoryResult res = CanUnequipItems(srcItemId, count);
if (res != EQUIP_ERR_OK)
{
@@ -15509,7 +15488,7 @@ bool Player::TakeQuestSourceItem(uint32 questId, bool msg)
}
for (uint8 n = 0; n < QUEST_ITEM_OBJECTIVES_COUNT; ++n)
- if (item->StartQuest == questId && srcItemId == quest->ReqItemId[n])
+ if (item->StartQuest == questId && srcItemId == quest->RequiredItemId[n])
destroyItem = false;
if (destroyItem)
@@ -15601,7 +15580,7 @@ uint16 Player::GetReqKillOrCastCurrentCount(uint32 quest_id, int32 entry)
return 0;
for (uint8 j = 0; j < QUEST_OBJECTIVES_COUNT; ++j)
- if (qInfo->ReqCreatureOrGOId[j] == entry)
+ if (qInfo->RequiredNpcOrGo[j] == entry)
return m_QuestStatus[quest_id].m_creatureOrGOcount[j];
return 0;
@@ -15613,10 +15592,10 @@ void Player::AdjustQuestReqItemCount(Quest const* quest, QuestStatusData& questS
{
for (uint8 i = 0; i < QUEST_ITEM_OBJECTIVES_COUNT; ++i)
{
- uint32 reqitemcount = quest->ReqItemCount[i];
+ uint32 reqitemcount = quest->RequiredItemCount[i];
if (reqitemcount != 0)
{
- uint32 curitemcount = GetItemCount(quest->ReqItemId[i], true);
+ uint32 curitemcount = GetItemCount(quest->RequiredItemId[i], true);
questStatusData.m_itemcount[i] = std::min(curitemcount, reqitemcount);
m_QuestStatusSave[quest->GetQuestId()] = true;
@@ -15661,11 +15640,11 @@ void Player::GroupEventHappens(uint32 questId, WorldObject const* pEventObject)
{
for (GroupReference* itr = group->GetFirstMember(); itr != NULL; itr = itr->next())
{
- Player* pGroupGuy = itr->getSource();
+ Player* player = itr->getSource();
// for any leave or dead (with not released body) group member at appropriate distance
- if (pGroupGuy && pGroupGuy->IsAtGroupRewardDistance(pEventObject) && !pGroupGuy->GetCorpse())
- pGroupGuy->AreaExploredOrEventHappens(questId);
+ if (player && player->IsAtGroupRewardDistance(pEventObject) && !player->GetCorpse())
+ player->AreaExploredOrEventHappens(questId);
}
}
else
@@ -15691,10 +15670,10 @@ void Player::ItemAddedQuestCheck(uint32 entry, uint32 count)
for (uint8 j = 0; j < QUEST_ITEM_OBJECTIVES_COUNT; ++j)
{
- uint32 reqitem = qInfo->ReqItemId[j];
+ uint32 reqitem = qInfo->RequiredItemId[j];
if (reqitem == entry)
{
- uint32 reqitemcount = qInfo->ReqItemCount[j];
+ uint32 reqitemcount = qInfo->RequiredItemCount[j];
uint16 curitemcount = q_status.m_itemcount[j];
if (curitemcount < reqitemcount)
{
@@ -15729,12 +15708,12 @@ void Player::ItemRemovedQuestCheck(uint32 entry, uint32 count)
for (uint8 j = 0; j < QUEST_ITEM_OBJECTIVES_COUNT; ++j)
{
- uint32 reqitem = qInfo->ReqItemId[j];
+ uint32 reqitem = qInfo->RequiredItemId[j];
if (reqitem == entry)
{
QuestStatusData& q_status = m_QuestStatus[questid];
- uint32 reqitemcount = qInfo->ReqItemCount[j];
+ uint32 reqitemcount = qInfo->RequiredItemCount[j];
uint16 curitemcount;
if (q_status.m_status != QUEST_STATUS_COMPLETE)
curitemcount = q_status.m_itemcount[j];
@@ -15798,18 +15777,18 @@ void Player::KilledMonsterCredit(uint32 entry, uint64 guid)
for (uint8 j = 0; j < QUEST_OBJECTIVES_COUNT; ++j)
{
// skip GO activate objective or none
- if (qInfo->ReqCreatureOrGOId[j] <= 0)
+ if (qInfo->RequiredNpcOrGo[j] <= 0)
continue;
// skip Cast at creature objective
- if (qInfo->ReqSpell[j] != 0)
+ if (qInfo->RequiredSpellCast[j] != 0)
continue;
- uint32 reqkill = qInfo->ReqCreatureOrGOId[j];
+ uint32 reqkill = qInfo->RequiredNpcOrGo[j];
if (reqkill == real_entry)
{
- uint32 reqkillcount = qInfo->ReqCreatureOrGOCount[j];
+ uint32 reqkillcount = qInfo->RequiredNpcOrGoCount[j];
uint16 curkillcount = q_status.m_creatureOrGOcount[j];
if (curkillcount < reqkillcount)
{
@@ -15895,7 +15874,7 @@ void Player::CastedCreatureOrGO(uint32 entry, uint64 guid, uint32 spell_id)
for (uint8 j = 0; j < QUEST_OBJECTIVES_COUNT; ++j)
{
// skip kill creature objective (0) or wrong spell casts
- if (qInfo->ReqSpell[j] != spell_id)
+ if (qInfo->RequiredSpellCast[j] != spell_id)
continue;
uint32 reqTarget = 0;
@@ -15903,32 +15882,32 @@ void Player::CastedCreatureOrGO(uint32 entry, uint64 guid, uint32 spell_id)
if (isCreature)
{
// creature activate objectives
- if (qInfo->ReqCreatureOrGOId[j] > 0)
+ if (qInfo->RequiredNpcOrGo[j] > 0)
{
// checked at quest_template loading
- reqTarget = qInfo->ReqCreatureOrGOId[j];
+ reqTarget = qInfo->RequiredNpcOrGo[j];
if (reqTarget != entry) // if entry doesn't match, check for killcredits referenced in template
{
CreatureTemplate const* cinfo = sObjectMgr->GetCreatureTemplate(entry);
- for (uint8 i = 0; i < MAX_KILL_CREDIT; ++i)
- if (cinfo->KillCredit[i] == reqTarget)
- entry = cinfo->KillCredit[i];
+ for (uint8 j = 0; j < MAX_KILL_CREDIT; ++j)
+ if (cinfo->KillCredit[j] == reqTarget)
+ entry = cinfo->KillCredit[j];
}
}
}
else
{
// GO activate objective
- if (qInfo->ReqCreatureOrGOId[j] < 0)
+ if (qInfo->RequiredNpcOrGo[j] < 0)
// checked at quest_template loading
- reqTarget = - qInfo->ReqCreatureOrGOId[j];
+ reqTarget = - qInfo->RequiredNpcOrGo[j];
}
// other not this creature/GO related objectives
if (reqTarget != entry)
continue;
- uint32 reqCastCount = qInfo->ReqCreatureOrGOCount[j];
+ uint32 reqCastCount = qInfo->RequiredNpcOrGoCount[j];
uint16 curCastCount = q_status.m_creatureOrGOcount[j];
if (curCastCount < reqCastCount)
{
@@ -15972,20 +15951,20 @@ void Player::TalkedToCreature(uint32 entry, uint64 guid)
for (uint8 j = 0; j < QUEST_OBJECTIVES_COUNT; ++j)
{
// skip spell casts and Gameobject objectives
- if (qInfo->ReqSpell[j] > 0 || qInfo->ReqCreatureOrGOId[j] < 0)
+ if (qInfo->RequiredSpellCast[j] > 0 || qInfo->RequiredNpcOrGo[j] < 0)
continue;
uint32 reqTarget = 0;
- if (qInfo->ReqCreatureOrGOId[j] > 0) // creature activate objectives
+ if (qInfo->RequiredNpcOrGo[j] > 0) // creature activate objectives
// checked at quest_template loading
- reqTarget = qInfo->ReqCreatureOrGOId[j];
+ reqTarget = qInfo->RequiredNpcOrGo[j];
else
continue;
if (reqTarget == entry)
{
- uint32 reqTalkCount = qInfo->ReqCreatureOrGOCount[j];
+ uint32 reqTalkCount = qInfo->RequiredNpcOrGoCount[j];
uint16 curTalkCount = q_status.m_creatureOrGOcount[j];
if (curTalkCount < reqTalkCount)
{
@@ -16122,14 +16101,14 @@ bool Player::HasQuestForItem(uint32 itemid) const
// This part for ReqItem drop
for (uint8 j = 0; j < QUEST_ITEM_OBJECTIVES_COUNT; ++j)
{
- if (itemid == qinfo->ReqItemId[j] && q_status.m_itemcount[j] < qinfo->ReqItemCount[j])
+ if (itemid == qinfo->RequiredItemId[j] && q_status.m_itemcount[j] < qinfo->RequiredItemCount[j])
return true;
}
// This part - for ReqSource
for (uint8 j = 0; j < QUEST_SOURCE_ITEM_IDS_COUNT; ++j)
{
// examined item is a source item
- if (qinfo->ReqSourceId[j] == itemid)
+ if (qinfo->RequiredSourceItemid[j] == itemid)
{
ItemTemplate const* pProto = sObjectMgr->GetItemTemplate(itemid);
@@ -16138,9 +16117,9 @@ bool Player::HasQuestForItem(uint32 itemid) const
return true;
// allows custom amount drop when not 0
- if (qinfo->ReqSourceCount[j])
+ if (qinfo->RequiredSourceItemId[j])
{
- if (GetItemCount(itemid, true) < qinfo->ReqSourceCount[j])
+ if (GetItemCount(itemid, true) < qinfo->RequiredSourceItemId[j])
return true;
} else if (GetItemCount(itemid, true) < pProto->GetMaxStackSize())
return true;
@@ -16213,7 +16192,7 @@ void Player::SendQuestTimerFailed(uint32 quest_id)
}
}
-void Player::SendCanTakeQuestResponse(uint32 msg)
+void Player::SendCanTakeQuestResponse(uint32 msg) const
{
WorldPacket data(SMSG_QUESTGIVER_QUEST_INVALID, 4);
data << uint32(msg);
@@ -16258,7 +16237,7 @@ void Player::SendQuestUpdateAddItem(Quest const* /*quest*/, uint32 /*item_idx*/,
{
WorldPacket data(SMSG_QUESTUPDATE_ADD_ITEM, 0);
sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Sent SMSG_QUESTUPDATE_ADD_ITEM");
- //data << quest->ReqItemId[item_idx];
+ //data << quest->RequiredItemId[item_idx];
//data << count;
GetSession()->SendPacket(&data);
}
@@ -16267,7 +16246,7 @@ void Player::SendQuestUpdateAddCreatureOrGo(Quest const* quest, uint64 guid, uin
{
ASSERT(old_count + add_count < 65536 && "mob/GO count store in 16 bits 2^16 = 65536 (0..65536)");
- int32 entry = quest->ReqCreatureOrGOId[ creatureOrGO_idx ];
+ int32 entry = quest->RequiredNpcOrGo[ creatureOrGO_idx ];
if (entry < 0)
// client expected gameobject template id in form (id|0x80000000)
entry = (-entry) | 0x80000000;
@@ -16277,7 +16256,7 @@ void Player::SendQuestUpdateAddCreatureOrGo(Quest const* quest, uint64 guid, uin
data << uint32(quest->GetQuestId());
data << uint32(entry);
data << uint32(old_count + add_count);
- data << uint32(quest->ReqCreatureOrGOCount[ creatureOrGO_idx ]);
+ data << uint32(quest->RequiredNpcOrGoCount[ creatureOrGO_idx ]);
data << uint64(guid);
GetSession()->SendPacket(&data);
@@ -16803,7 +16782,7 @@ bool Player::LoadFromDB(uint32 guid, SQLQueryHolder *holder)
// NOW player must have valid map
// load the player's map here if it's not already loaded
- Map* map = sMapMgr->CreateMap(mapId, this, instanceId);
+ Map* map = sMapMgr->CreateMap(mapId, this);
if (!map)
{
@@ -16821,14 +16800,14 @@ bool Player::LoadFromDB(uint32 guid, SQLQueryHolder *holder)
RelocateToHomebind();
}
- map = sMapMgr->CreateMap(mapId, this, 0);
+ map = sMapMgr->CreateMap(mapId, this);
if (!map)
{
PlayerInfo const* info = sObjectMgr->GetPlayerInfo(getRace(), getClass());
mapId = info->mapId;
Relocate(info->positionX, info->positionY, info->positionZ, 0.0f);
sLog->outError("Player (guidlow %d) have invalid coordinates (X: %f Y: %f Z: %f O: %f). Teleport to default race/class locations.", guid, GetPositionX(), GetPositionY(), GetPositionZ(), GetOrientation());
- map = sMapMgr->CreateMap(mapId, this, 0);
+ map = sMapMgr->CreateMap(mapId, this);
if (!map)
{
sLog->outError("Player (guidlow %d) has invalid default map coordinates (X: %f Y: %f Z: %f O: %f). or instance couldn't be created", guid, GetPositionX(), GetPositionY(), GetPositionZ(), GetOrientation());
@@ -17474,7 +17453,7 @@ Item* Player::_LoadItem(SQLTransaction& trans, uint32 zoneId, uint32 timeDiff, F
AllowedLooterSet looters;
for (Tokens::iterator itr = GUIDlist.begin(); itr != GUIDlist.end(); ++itr)
looters.insert(atol(*itr));
- item->SetSoulboundTradeable(&looters, this, true);
+ item->SetSoulboundTradeable(looters);
m_itemSoulboundTradeable.push_back(item);
}
else
@@ -17549,7 +17528,7 @@ void Player::_LoadMailedItems(Mail* mail)
{
sLog->outError("Player %u has unknown item_template (ProtoType) in mailed items(GUID: %u template: %u) in mail (%u), deleted.", GetGUIDLow(), item_guid_low, item_template, mail->messageID);
CharacterDatabase.PExecute("DELETE FROM mail_items WHERE item_guid = '%u'", item_guid_low);
- PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_ITEM_INSTANCE);
+ stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_ITEM_INSTANCE);
stmt->setUInt32(0, item_guid_low);
CharacterDatabase.Execute(stmt);
continue;
@@ -18276,7 +18255,7 @@ bool Player::_LoadHomeBind(PreparedQueryResult result)
/*** SAVE SYSTEM ***/
/*********************************************************/
-void Player::SaveToDB()
+void Player::SaveToDB(bool create /*=false*/)
{
// delay auto save at any saves (manual, in code, or autosave)
m_nextSave = sWorld->getIntConfig(CONFIG_INTERVAL_SAVE);
@@ -18294,156 +18273,228 @@ void Player::SaveToDB()
sLog->outDebug(LOG_FILTER_UNITS, "The value of player %s at save: ", m_name.c_str());
outDebugValues();
- std::string sql_name = m_name;
- CharacterDatabase.EscapeString(sql_name);
+ PreparedStatement* stmt = NULL;
+ uint16 index = 0;
- std::ostringstream ss;
- ss << "REPLACE INTO characters (guid, account, name, race, class, gender, level, xp, money, playerBytes, playerBytes2, playerFlags, "
- "map, instance_id, instance_mode_mask, position_x, position_y, position_z, orientation, "
- "taximask, online, cinematic, "
- "totaltime, leveltime, rest_bonus, logout_time, is_logout_resting, resettalents_cost, resettalents_time, "
- "trans_x, trans_y, trans_z, trans_o, transguid, extra_flags, stable_slots, at_login, zone, "
- "death_expire_time, taxi_path, arenaPoints, totalHonorPoints, todayHonorPoints, yesterdayHonorPoints, totalKills, "
- "todayKills, yesterdayKills, chosenTitle, knownCurrencies, watchedFaction, drunk, health, power1, power2, power3, "
- "power4, power5, power6, power7, latency, speccount, activespec, exploredZones, equipmentCache, ammoId, knownTitles, actionBars, grantableLevels) VALUES ("
- << GetGUIDLow() << ','
- << GetSession()->GetAccountId() << ", '"
- << sql_name << "', "
- << uint32(getRace()) << ','
- << uint32(getClass()) << ','
- << uint32(getGender()) << ','
- << uint32(getLevel()) << ','
- << GetUInt32Value(PLAYER_XP) << ','
- << GetMoney() << ','
- << GetUInt32Value(PLAYER_BYTES) << ','
- << GetUInt32Value(PLAYER_BYTES_2) << ','
- << GetUInt32Value(PLAYER_FLAGS) << ',';
-
- if (!IsBeingTeleported())
- {
- ss << GetMapId() << ','
- << (uint32)GetInstanceId() << ','
- << uint32(uint8(GetDungeonDifficulty()) | uint8(GetRaidDifficulty()) << 4) << ','
- << finiteAlways(GetPositionX()) << ','
- << finiteAlways(GetPositionY()) << ','
- << finiteAlways(GetPositionZ()) << ','
- << finiteAlways(GetOrientation()) << ',';
- }
- else
+ if (create)
{
- ss << GetTeleportDest().GetMapId() << ','
- << (uint32)0 << ','
- << uint32(uint8(GetDungeonDifficulty()) | uint8(GetRaidDifficulty()) << 4) << ','
- << finiteAlways(GetTeleportDest().GetPositionX()) << ','
- << finiteAlways(GetTeleportDest().GetPositionY()) << ','
- << finiteAlways(GetTeleportDest().GetPositionZ()) << ','
- << finiteAlways(GetTeleportDest().GetOrientation()) << ',';
- }
-
- ss << m_taxi << ','; // string with TaxiMaskSize numbers
-
- ss << (IsInWorld() ? 1 : 0) << ',';
-
- ss << uint32(m_cinematic) << ',';
+ //! Insert query
+ //! TO DO: Filter out more redundant fields that can take their default value at player create
+ stmt = CharacterDatabase.GetPreparedStatement(CHAR_ADD_CHARACTER);
+ stmt->setUInt32(index++, GetGUIDLow());
+ stmt->setUInt32(index++, GetSession()->GetAccountId());
+ stmt->setString(index++, GetName());
+ stmt->setUInt8(index++, getRace());
+ stmt->setUInt8(index++, getClass());
+ stmt->setUInt8(index++, getGender());
+ stmt->setUInt8(index++, getLevel());
+ stmt->setUInt32(index++, GetUInt32Value(PLAYER_XP));
+ stmt->setUInt32(index++, GetMoney());
+ stmt->setUInt32(index++, GetUInt32Value(PLAYER_BYTES));
+ stmt->setUInt32(index++, GetUInt32Value(PLAYER_BYTES_2));
+ stmt->setUInt32(index++, GetUInt32Value(PLAYER_FLAGS));
+ stmt->setUInt16(index++, (uint16)GetMapId());
+ stmt->setUInt32(index++, (uint32)GetInstanceId());
+ stmt->setUInt8(index++, (uint8(GetDungeonDifficulty()) | uint8(GetRaidDifficulty()) << 4));
+ stmt->setFloat(index++, finiteAlways(GetPositionX()));
+ stmt->setFloat(index++, finiteAlways(GetPositionY()));
+ stmt->setFloat(index++, finiteAlways(GetPositionZ()));
+ stmt->setFloat(index++, finiteAlways(GetOrientation()));
+
+ std::ostringstream ss;
+ ss << m_taxi;
+ stmt->setString(index++, ss.str());
+ stmt->setUInt8(index++, m_cinematic);
+ stmt->setUInt32(index++, m_Played_time[PLAYED_TIME_TOTAL]);
+ stmt->setUInt32(index++, m_Played_time[PLAYED_TIME_LEVEL]);
+ stmt->setFloat(index++, finiteAlways(m_rest_bonus));
+ stmt->setUInt32(index++, uint32(time(NULL)));
+ stmt->setUInt8(index++, (HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_RESTING) ? 1 : 0));
+ //save, far from tavern/city
+ //save, but in tavern/city
+ stmt->setUInt32(index++, m_resetTalentsCost);
+ stmt->setUInt32(index++, m_resetTalentsTime);
+ stmt->setUInt16(index++, (uint16)m_ExtraFlags);
+ stmt->setUInt8(index++, m_stableSlots);
+ stmt->setUInt16(index++, (uint16)m_atLoginFlags);
+ stmt->setUInt16(index++, GetZoneId());
+ stmt->setUInt32(index++, m_deathExpireTime);
+
+ ss.str("");
+ ss << m_taxi.SaveTaxiDestinationsToString();
+
+ stmt->setString(index++, ss.str());
+ stmt->setUInt32(index++, GetArenaPoints());
+ stmt->setUInt32(index++, GetHonorPoints());
+ stmt->setUInt32(index++, GetUInt32Value(PLAYER_FIELD_TODAY_CONTRIBUTION));
+ stmt->setUInt32(index++, GetUInt32Value(PLAYER_FIELD_YESTERDAY_CONTRIBUTION));
+ stmt->setUInt32(index++, GetUInt32Value(PLAYER_FIELD_LIFETIME_HONORABLE_KILLS));
+ stmt->setUInt16(index++, GetUInt16Value(PLAYER_FIELD_KILLS, 0));
+ stmt->setUInt16(index++, GetUInt16Value(PLAYER_FIELD_KILLS, 1));
+ stmt->setUInt32(index++, GetUInt32Value(PLAYER_CHOSEN_TITLE));
+ stmt->setUInt64(index++, GetUInt64Value(PLAYER_FIELD_KNOWN_CURRENCIES));
+ stmt->setUInt32(index++, GetUInt32Value(PLAYER_FIELD_WATCHED_FACTION_INDEX));
+ stmt->setUInt16(index++, (uint16)(GetUInt32Value(PLAYER_BYTES_3) & 0xFFFE));
+ stmt->setUInt32(index++, GetHealth());
+
+ for (uint32 i = 0; i < MAX_POWERS; ++i)
+ stmt->setUInt32(index++, GetPower(Powers(i)));
+
+ stmt->setUInt32(index++, GetSession()->GetLatency());
+
+ stmt->setUInt8(index++, m_specsCount);
+ stmt->setUInt8(index++, m_activeSpec);
+
+ ss.str("");
+ for (uint32 i = 0; i < PLAYER_EXPLORED_ZONES_SIZE; ++i)
+ ss << GetUInt32Value(PLAYER_EXPLORED_ZONES_1 + i) << ' ';
+ stmt->setString(index++, ss.str());
+
+ ss.str("");
+ // cache equipment...
+ for (uint32 i = 0; i < EQUIPMENT_SLOT_END * 2; ++i)
+ ss << GetUInt32Value(PLAYER_VISIBLE_ITEM_1_ENTRYID + i) << ' ';
+
+ // ...and bags for enum opcode
+ for (uint32 i = INVENTORY_SLOT_BAG_START; i < INVENTORY_SLOT_BAG_END; ++i)
+ {
+ if (Item* item = GetItemByPos(INVENTORY_SLOT_BAG_0, i))
+ ss << item->GetEntry();
+ else
+ ss << '0';
+ ss << " 0 ";
+ }
- ss << m_Played_time[PLAYED_TIME_TOTAL] << ',';
- ss << m_Played_time[PLAYED_TIME_LEVEL] << ',';
+ stmt->setString(index++, ss.str());
+ stmt->setUInt32(index++, GetUInt32Value(PLAYER_AMMO_ID));
- ss << finiteAlways(m_rest_bonus) << ',';
- ss << uint32(time(NULL)) << ',';
- ss << (HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_RESTING) ? 1 : 0) << ',';
- //save, far from tavern/city
- //save, but in tavern/city
- ss << m_resetTalentsCost << ',';
- ss << uint32(m_resetTalentsTime) << ',';
+ ss.str("");
+ for (uint32 i = 0; i < KNOWN_TITLES_SIZE*2; ++i)
+ ss << GetUInt32Value(PLAYER__FIELD_KNOWN_TITLES + i) << ' ';
- ss << finiteAlways(m_movementInfo.t_pos.GetPositionX()) << ',';
- ss << finiteAlways(m_movementInfo.t_pos.GetPositionY()) << ',';
- ss << finiteAlways(m_movementInfo.t_pos.GetPositionZ()) << ',';
- ss << finiteAlways(m_movementInfo.t_pos.GetOrientation()) << ',';
- if (m_transport)
- ss << m_transport->GetGUIDLow();
+ stmt->setString(index++, ss.str());
+ stmt->setUInt8(index++, GetByteValue(PLAYER_FIELD_BYTES, 2));
+ stmt->setUInt32(index++, m_grantableLevels);
+ }
else
- ss << '0';
- ss << ',';
-
- ss << m_ExtraFlags << ',';
-
- ss << uint32(m_stableSlots) << ','; // to prevent save uint8 as char
-
- ss << uint32(m_atLoginFlags) << ',';
-
- ss << GetZoneId() << ',';
-
- ss << uint32(m_deathExpireTime) << ", '";
-
- ss << m_taxi.SaveTaxiDestinationsToString() << "', ";
-
- ss << GetArenaPoints() << ',';
-
- ss << GetHonorPoints() << ',';
-
- ss << GetUInt32Value(PLAYER_FIELD_TODAY_CONTRIBUTION) << ',';
-
- ss << GetUInt32Value(PLAYER_FIELD_YESTERDAY_CONTRIBUTION) << ',';
-
- ss << GetUInt32Value(PLAYER_FIELD_LIFETIME_HONORABLE_KILLS) << ',';
-
- ss << GetUInt16Value(PLAYER_FIELD_KILLS, 0) << ',';
-
- ss << GetUInt16Value(PLAYER_FIELD_KILLS, 1) << ',';
-
- ss << GetUInt32Value(PLAYER_CHOSEN_TITLE) << ',';
-
- ss << GetUInt64Value(PLAYER_FIELD_KNOWN_CURRENCIES) << ',';
-
- ss << GetUInt32Value(PLAYER_FIELD_WATCHED_FACTION_INDEX) << ',';
-
- ss << (uint16)(GetUInt32Value(PLAYER_BYTES_3) & 0xFFFE) << ',';
-
- ss << GetHealth();
-
- for (uint32 i = 0; i < MAX_POWERS; ++i)
- ss << ',' << GetPower(Powers(i));
- ss << ',';
- ss << GetSession()->GetLatency();
- ss << ',';
- ss << uint32(m_specsCount);
- ss << ',';
- ss << uint32(m_activeSpec) << ", '";
- for (uint32 i = 0; i < PLAYER_EXPLORED_ZONES_SIZE; ++i)
- ss << GetUInt32Value(PLAYER_EXPLORED_ZONES_1 + i) << ' ';
-
- // cache equipment...
- ss << "', '";
- for (uint32 i = 0; i < EQUIPMENT_SLOT_END * 2; ++i)
- ss << GetUInt32Value(PLAYER_VISIBLE_ITEM_1_ENTRYID + i) << ' ';
-
- // ...and bags for enum opcode
- for (uint32 i = INVENTORY_SLOT_BAG_START; i < INVENTORY_SLOT_BAG_END; ++i)
{
- if (Item* item = GetItemByPos(INVENTORY_SLOT_BAG_0, i))
- ss << item->GetEntry();
+ // Update query
+ stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_CHARACTER);
+ stmt->setString(index++, GetName());
+ stmt->setUInt8(index++, getRace());
+ stmt->setUInt8(index++, getClass());
+ stmt->setUInt8(index++, getGender());
+ stmt->setUInt8(index++, getLevel());
+ stmt->setUInt32(index++, GetUInt32Value(PLAYER_XP));
+ stmt->setUInt32(index++, GetMoney());
+ stmt->setUInt32(index++, GetUInt32Value(PLAYER_BYTES));
+ stmt->setUInt32(index++, GetUInt32Value(PLAYER_BYTES_2));
+ stmt->setUInt32(index++, GetUInt32Value(PLAYER_FLAGS));
+
+ if (!IsBeingTeleported())
+ {
+ stmt->setUInt16(index++, (uint16)GetMapId());
+ stmt->setUInt32(index++, (uint32)GetInstanceId());
+ stmt->setUInt8(index++, (uint8(GetDungeonDifficulty()) | uint8(GetRaidDifficulty()) << 4));
+ stmt->setFloat(index++, finiteAlways(GetPositionX()));
+ stmt->setFloat(index++, finiteAlways(GetPositionY()));
+ stmt->setFloat(index++, finiteAlways(GetPositionZ()));
+ stmt->setFloat(index++, finiteAlways(GetOrientation()));
+ }
else
- ss << '0';
- ss << " 0 ";
- }
+ {
+ stmt->setUInt16(index++, (uint16)GetTeleportDest().GetMapId());
+ stmt->setUInt32(index++, (uint32)0);
+ stmt->setUInt8(index++, (uint8(GetDungeonDifficulty()) | uint8(GetRaidDifficulty()) << 4));
+ stmt->setFloat(index++, finiteAlways(GetTeleportDest().GetPositionX()));
+ stmt->setFloat(index++, finiteAlways(GetTeleportDest().GetPositionY()));
+ stmt->setFloat(index++, finiteAlways(GetTeleportDest().GetPositionZ()));
+ stmt->setFloat(index++, finiteAlways(GetTeleportDest().GetOrientation()));
+ }
+
+ std::ostringstream ss;
+ ss << m_taxi;
+ stmt->setString(index++, ss.str());
+ stmt->setUInt8(index++, m_cinematic);
+ stmt->setUInt32(index++, m_Played_time[PLAYED_TIME_TOTAL]);
+ stmt->setUInt32(index++, m_Played_time[PLAYED_TIME_LEVEL]);
+ stmt->setFloat(index++, finiteAlways(m_rest_bonus));
+ stmt->setUInt32(index++, uint32(time(NULL)));
+ stmt->setUInt8(index++, (HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_RESTING) ? 1 : 0));
+ //save, far from tavern/city
+ //save, but in tavern/city
+ stmt->setUInt32(index++, m_resetTalentsCost);
+ stmt->setUInt32(index++, m_resetTalentsTime);
+ stmt->setUInt16(index++, (uint16)m_ExtraFlags);
+ stmt->setUInt8(index++, m_stableSlots);
+ stmt->setUInt16(index++, (uint16)m_atLoginFlags);
+ stmt->setUInt16(index++, GetZoneId());
+ stmt->setUInt32(index++, m_deathExpireTime);
+
+ ss.str("");
+ ss << m_taxi.SaveTaxiDestinationsToString();
+
+ stmt->setString(index++, ss.str());
+ stmt->setUInt32(index++, GetArenaPoints());
+ stmt->setUInt32(index++, GetHonorPoints());
+ stmt->setUInt32(index++, GetUInt32Value(PLAYER_FIELD_TODAY_CONTRIBUTION));
+ stmt->setUInt32(index++, GetUInt32Value(PLAYER_FIELD_YESTERDAY_CONTRIBUTION));
+ stmt->setUInt32(index++, GetUInt32Value(PLAYER_FIELD_LIFETIME_HONORABLE_KILLS));
+ stmt->setUInt16(index++, GetUInt16Value(PLAYER_FIELD_KILLS, 0));
+ stmt->setUInt16(index++, GetUInt16Value(PLAYER_FIELD_KILLS, 1));
+ stmt->setUInt32(index++, GetUInt32Value(PLAYER_CHOSEN_TITLE));
+ stmt->setUInt64(index++, GetUInt64Value(PLAYER_FIELD_KNOWN_CURRENCIES));
+ stmt->setUInt32(index++, GetUInt32Value(PLAYER_FIELD_WATCHED_FACTION_INDEX));
+ stmt->setUInt16(index++, (uint16)(GetUInt32Value(PLAYER_BYTES_3) & 0xFFFE));
+ stmt->setUInt32(index++, GetHealth());
+
+ for (uint32 i = 0; i < MAX_POWERS; ++i)
+ stmt->setUInt32(index++, GetPower(Powers(i)));
+
+ stmt->setUInt32(index++, GetSession()->GetLatency());
+
+ stmt->setUInt8(index++, m_specsCount);
+ stmt->setUInt8(index++, m_activeSpec);
+
+ ss.str("");
+ for (uint32 i = 0; i < PLAYER_EXPLORED_ZONES_SIZE; ++i)
+ ss << GetUInt32Value(PLAYER_EXPLORED_ZONES_1 + i) << ' ';
+ stmt->setString(index++, ss.str());
+
+ ss.str("");
+ // cache equipment...
+ for (uint32 i = 0; i < EQUIPMENT_SLOT_END * 2; ++i)
+ ss << GetUInt32Value(PLAYER_VISIBLE_ITEM_1_ENTRYID + i) << ' ';
+
+ // ...and bags for enum opcode
+ for (uint32 i = INVENTORY_SLOT_BAG_START; i < INVENTORY_SLOT_BAG_END; ++i)
+ {
+ if (Item* item = GetItemByPos(INVENTORY_SLOT_BAG_0, i))
+ ss << item->GetEntry();
+ else
+ ss << '0';
+ ss << " 0 ";
+ }
- ss << "',";
+ stmt->setString(index++, ss.str());
+ stmt->setUInt32(index++, GetUInt32Value(PLAYER_AMMO_ID));
- ss << GetUInt32Value(PLAYER_AMMO_ID) << ", '";
- for (uint32 i = 0; i < KNOWN_TITLES_SIZE*2; ++i)
- ss << GetUInt32Value(PLAYER__FIELD_KNOWN_TITLES + i) << ' ';
+ ss.str("");
+ for (uint32 i = 0; i < KNOWN_TITLES_SIZE*2; ++i)
+ ss << GetUInt32Value(PLAYER__FIELD_KNOWN_TITLES + i) << ' ';
- ss << "',";
- ss << uint32(GetByteValue(PLAYER_FIELD_BYTES, 2));
- ss << ",";
- ss << uint32(m_grantableLevels);
- ss << ')';
+ stmt->setString(index++, ss.str());
+ stmt->setUInt8(index++, GetByteValue(PLAYER_FIELD_BYTES, 2));
+ stmt->setUInt32(index++, m_grantableLevels);
+
+ stmt->setUInt8(index++, IsInWorld() ? 1 : 0);
+ // Index
+ stmt->setUInt32(index++, GetGUIDLow());
+ }
SQLTransaction trans = CharacterDatabase.BeginTransaction();
- trans->Append(ss.str().c_str());
+ trans->Append(stmt);
if (m_mailsUpdated) //save mails only when needed
_SaveMail(trans);
@@ -19352,7 +19403,7 @@ inline void Player::BuildPlayerChat(WorldPacket* data, uint8 msgtype, const std:
*data << uint64(GetGUID());
*data << uint32(text.length() + 1);
*data << text;
- *data << uint8(chatTag());
+ *data << uint8(GetChatTag());
}
void Player::Say(const std::string& text, const uint32 language)
@@ -19795,7 +19846,7 @@ void Player::RemoveSpellMods(Spell* spell)
for (uint8 i=0; i<MAX_SPELLMOD; ++i)
{
- for (SpellModList::iterator itr = m_spellMods[i].begin(); itr != m_spellMods[i].end();)
+ for (SpellModList::const_iterator itr = m_spellMods[i].begin(); itr != m_spellMods[i].end();)
{
SpellModifier* mod = *itr;
++itr;
@@ -19827,8 +19878,7 @@ void Player::DropModCharge(SpellModifier* mod, Spell* spell)
if (spell && mod->ownerAura && mod->charges > 0)
{
- --mod->charges;
- if (mod->charges == 0)
+ if (--mod->charges == 0)
mod->charges = -1;
spell->m_appliedMods.insert(mod->ownerAura);
@@ -20137,9 +20187,9 @@ bool Player::ActivateTaxiPathTo(std::vector<uint32> const& nodes, Creature* npc
if (sWorld->getBoolConfig(CONFIG_INSTANT_TAXI))
{
- TaxiNodesEntry const* lastnode = sTaxiNodesStore.LookupEntry(nodes[nodes.size()-1]);
+ TaxiNodesEntry const* lastPathNode = sTaxiNodesStore.LookupEntry(nodes[nodes.size()-1]);
m_taxi.ClearTaxiDestinations();
- TeleportTo(lastnode->map_id, lastnode->x, lastnode->y, lastnode->z, GetOrientation());
+ TeleportTo(lastPathNode->map_id, lastPathNode->x, lastPathNode->y, lastPathNode->z, GetOrientation());
return false;
}
else
@@ -21496,7 +21546,7 @@ void Player::SendInitialPacketsBeforeAddToMap()
data.Initialize(SMSG_LOGIN_SETTIMESPEED, 4 + 4 + 4);
data << uint32(secsToTimeBitFields(sWorld->GetGameTime()));
- data << (float)0.01666667f; // game speed
+ data << float(0.01666667f); // game speed
data << uint32(0); // added in 3.1.2
GetSession()->SendPacket(&data);
@@ -21541,7 +21591,7 @@ void Player::SendInitialPacketsAfterAddToMap()
if (HasAuraType(SPELL_AURA_MOD_STUN))
SetMovement(MOVE_ROOT);
- // manual send package (have code in HandleEffect(this, AURA_EFFECT_HANDLE_SEND_FOR_CLIENT, true); that don't must be re-applied.
+ // manual send package (have code in HandleEffect(this, AURA_EFFECT_HANDLE_SEND_FOR_CLIENT, true); that must not be re-applied.
if (HasAuraType(SPELL_AURA_MOD_ROOT))
{
WorldPacket data2(SMSG_FORCE_MOVE_ROOT, 10);
@@ -22014,10 +22064,10 @@ bool Player::HasQuestForGO(int32 GOId) const
for (uint8 j = 0; j < QUEST_OBJECTIVES_COUNT; ++j)
{
- if (qinfo->ReqCreatureOrGOId[j] >= 0) //skip non GO case
+ if (qinfo->RequiredNpcOrGo[j] >= 0) //skip non GO case
continue;
- if ((-1)*GOId == qinfo->ReqCreatureOrGOId[j] && qs.m_creatureOrGOcount[j] < qinfo->ReqCreatureOrGOCount[j])
+ if ((-1)*GOId == qinfo->RequiredNpcOrGo[j] && qs.m_creatureOrGOcount[j] < qinfo->RequiredNpcOrGoCount[j])
return true;
}
}
@@ -22320,27 +22370,27 @@ bool Player::GetsRecruitAFriendBonus(bool forXP)
{
for (GroupReference* itr = group->GetFirstMember(); itr != NULL; itr = itr->next())
{
- Player* pGroupGuy = itr->getSource();
- if (!pGroupGuy)
+ Player* player = itr->getSource();
+ if (!player)
continue;
- if (!pGroupGuy->IsAtRecruitAFriendDistance(this))
+ if (!player->IsAtRecruitAFriendDistance(this))
continue; // member (alive or dead) or his corpse at req. distance
if (forXP)
{
// level must be allowed to get RaF bonus
- if (pGroupGuy->getLevel() > sWorld->getIntConfig(CONFIG_MAX_RECRUIT_A_FRIEND_BONUS_PLAYER_LEVEL))
+ if (player->getLevel() > sWorld->getIntConfig(CONFIG_MAX_RECRUIT_A_FRIEND_BONUS_PLAYER_LEVEL))
continue;
// level difference must be small enough to get RaF bonus, UNLESS we are lower level
- if (pGroupGuy->getLevel() < getLevel())
- if (uint8(getLevel() - pGroupGuy->getLevel()) > sWorld->getIntConfig(CONFIG_MAX_RECRUIT_A_FRIEND_BONUS_PLAYER_LEVEL_DIFFERENCE))
+ if (player->getLevel() < getLevel())
+ if (uint8(getLevel() - player->getLevel()) > sWorld->getIntConfig(CONFIG_MAX_RECRUIT_A_FRIEND_BONUS_PLAYER_LEVEL_DIFFERENCE))
continue;
}
- bool ARecruitedB = (pGroupGuy->GetSession()->GetRecruiterId() == GetSession()->GetAccountId());
- bool BRecruitedA = (GetSession()->GetRecruiterId() == pGroupGuy->GetSession()->GetAccountId());
+ bool ARecruitedB = (player->GetSession()->GetRecruiterId() == GetSession()->GetAccountId());
+ bool BRecruitedA = (GetSession()->GetRecruiterId() == player->GetSession()->GetAccountId());
if (ARecruitedB || BRecruitedA)
{
recruitAFriend = true;
@@ -22368,16 +22418,16 @@ void Player::RewardPlayerAndGroupAtEvent(uint32 creature_id, WorldObject* pRewar
{
for (GroupReference* itr = group->GetFirstMember(); itr != NULL; itr = itr->next())
{
- Player* pGroupGuy = itr->getSource();
- if (!pGroupGuy)
+ Player* player = itr->getSource();
+ if (!player)
continue;
- if (!pGroupGuy->IsAtGroupRewardDistance(pRewardSource))
+ if (!player->IsAtGroupRewardDistance(pRewardSource))
continue; // member (alive or dead) or his corpse at req. distance
// quest objectives updated only for alive group member or dead but with not released body
- if (pGroupGuy->isAlive()|| !pGroupGuy->GetCorpse())
- pGroupGuy->KilledMonsterCredit(creature_id, creature_guid);
+ if (player->isAlive()|| !player->GetCorpse())
+ player->KilledMonsterCredit(creature_id, creature_guid);
}
}
else // if (!group)
@@ -22779,10 +22829,6 @@ bool ItemPosCount::isContainedIn(ItemPosCountVec const& vec) const
return false;
}
-// ***********************************
-// -------------TRINITY---------------
-// ***********************************
-
void Player::StopCastingBindSight()
{
if (WorldObject* target = GetViewpoint())
@@ -22868,7 +22914,6 @@ bool Player::CanCaptureTowerPoint()
}
uint32 Player::GetBarberShopCost(uint8 newhairstyle, uint8 newhaircolor, uint8 newfacialhair, BarberShopStyleEntry const* newSkin)
-
{
uint8 level = getLevel();
@@ -23128,7 +23173,7 @@ void Player::InitRunes()
m_runes->runeState = 0;
m_runes->lastUsedRune = RUNE_BLOOD;
- for (uint32 i = 0; i < MAX_RUNES; ++i)
+ for (uint8 i = 0; i < MAX_RUNES; ++i)
{
SetBaseRune(i, runeSlotTypes[i]); // init base types
SetCurrentRune(i, runeSlotTypes[i]); // init current types
@@ -23137,13 +23182,13 @@ void Player::InitRunes()
m_runes->SetRuneState(i);
}
- for (uint32 i = 0; i < NUM_RUNE_TYPES; ++i)
+ for (uint8 i = 0; i < NUM_RUNE_TYPES; ++i)
SetFloatValue(PLAYER_RUNE_REGEN_1 + i, 0.1f);
}
bool Player::IsBaseRuneSlotsOnCooldown(RuneType runeType) const
{
- for (uint32 i = 0; i < MAX_RUNES; ++i)
+ for (uint8 i = 0; i < MAX_RUNES; ++i)
if (GetBaseRune(i) == runeType && GetRuneCooldown(i) == 0)
return false;
@@ -23202,8 +23247,8 @@ void Player::StoreLootItem(uint8 lootSlot, Loot* loot)
InventoryResult msg = CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, item->itemid, item->count);
if (msg == EQUIP_ERR_OK)
{
- AllowedLooterSet* looters = item->GetAllowedLooters();
- Item* newitem = StoreNewItem(dest, item->itemid, true, item->randomPropertyId, (looters->size() > 1) ? looters : NULL);
+ AllowedLooterSet looters = item->GetAllowedLooters();
+ Item* newitem = StoreNewItem(dest, item->itemid, true, item->randomPropertyId, looters);
if (qitem)
{
@@ -24346,9 +24391,9 @@ void Player::ActivateSpec(uint8 spec)
// Let client clear his current Actions
SendActionButtons(2);
// m_actionButtons.clear() is called in the next _LoadActionButtons
- for (uint32 i = 0; i < sTalentStore.GetNumRows(); ++i)
+ for (uint32 talentId = 0; talentId < sTalentStore.GetNumRows(); ++talentId)
{
- TalentEntry const* talentInfo = sTalentStore.LookupEntry(i);
+ TalentEntry const* talentInfo = sTalentStore.LookupEntry(talentId);
if (!talentInfo)
continue;
@@ -24716,7 +24761,7 @@ float Player::GetAverageItemLevel()
if (m_items[i] && m_items[i]->GetTemplate())
sum += m_items[i]->GetTemplate()->GetItemLevelIncludingQuality();
- count++;
+ ++count;
}
return ((float)sum) / count;
diff --git a/src/server/game/Entities/Player/Player.h b/src/server/game/Entities/Player/Player.h
index a5067a66d55..651b99e7cb4 100755
--- a/src/server/game/Entities/Player/Player.h
+++ b/src/server/game/Entities/Player/Player.h
@@ -395,10 +395,10 @@ enum PlayerFlags
PLAYER_FLAGS_NO_XP_GAIN = 0x02000000,
PLAYER_FLAGS_UNK26 = 0x04000000,
PLAYER_FLAGS_UNK27 = 0x08000000,
- PLAYER_FLAGS_UNK28 = 0x01000000,
- PLAYER_FLAGS_UNK29 = 0x02000000,
- PLAYER_FLAGS_UNK30 = 0x04000000,
- PLAYER_FLAGS_UNK31 = 0x08000000,
+ PLAYER_FLAGS_UNK28 = 0x10000000,
+ PLAYER_FLAGS_UNK29 = 0x20000000,
+ PLAYER_FLAGS_UNK30 = 0x40000000,
+ PLAYER_FLAGS_UNK31 = 0x80000000,
};
// used for PLAYER__FIELD_KNOWN_TITLES field (uint64), (1<<bit_index) without (-1)
@@ -743,8 +743,8 @@ enum RestType
enum DuelCompleteType
{
DUEL_INTERRUPTED = 0,
- DUEL_WON = 1,
- DUEL_FLED = 2
+ DUEL_WON = 1,
+ DUEL_FLED = 2
};
enum TeleportToOptions
@@ -768,6 +768,16 @@ enum EnviromentalDamage
DAMAGE_FALL_TO_VOID = 6 // custom case for fall without durability loss
};
+enum PlayerChatTag
+{
+ CHAT_TAG_NONE = 0x00,
+ CHAT_TAG_AFK = 0x01,
+ CHAT_TAG_DND = 0x02,
+ CHAT_TAG_GM = 0x04,
+ CHAT_TAG_COM = 0x08, // Commentator
+ CHAT_TAG_DEV = 0x10,
+};
+
enum PlayedTimeIndex
{
PLAYED_TIME_TOTAL = 0,
@@ -1125,7 +1135,7 @@ class Player : public Unit, public GridObject<Player>
bool ToggleDND();
bool isAFK() const { return HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_AFK); }
bool isDND() const { return HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_DND); }
- uint8 chatTag() const;
+ uint8 GetChatTag() const;
std::string afkMsg;
std::string dndMsg;
@@ -1269,8 +1279,8 @@ class Player : public Unit, public GridObject<Player>
bool HasItemTotemCategory(uint32 TotemCategory) const;
InventoryResult CanUseItem(ItemTemplate const* pItem) const;
InventoryResult CanUseAmmo(uint32 item) const;
-
- Item* StoreNewItem(ItemPosCountVec const& pos, uint32 item, bool update, int32 randomPropertyId = 0, AllowedLooterSet* allowedLooters = NULL);
+ Item* StoreNewItem(ItemPosCountVec const& pos, uint32 item, bool update, int32 randomPropertyId = 0);
+ Item* StoreNewItem(ItemPosCountVec const& pos, uint32 item, bool update, int32 randomPropertyId, AllowedLooterSet &allowedLooters);
Item* StoreItem(ItemPosCountVec const& pos, Item* pItem, bool update);
Item* EquipNewItem(uint16 pos, uint32 item, bool update);
Item* EquipItem(uint16 pos, Item* pItem, bool update);
@@ -1400,10 +1410,11 @@ class Player : public Unit, public GridObject<Player>
void IncompleteQuest(uint32 quest_id);
void RewardQuest(Quest const* quest, uint32 reward, Object* questGiver, bool announce = true);
void FailQuest(uint32 quest_id);
- bool SatisfyQuestSkillOrClass(Quest const* qInfo, bool msg);
+ bool SatisfyQuestSkill(Quest const* qInfo, bool msg) const;
bool SatisfyQuestLevel(Quest const* qInfo, bool msg);
bool SatisfyQuestLog(bool msg);
bool SatisfyQuestPreviousQuest(Quest const* qInfo, bool msg);
+ bool SatisfyQuestClass(Quest const* qInfo, bool msg) const;
bool SatisfyQuestRace(Quest const* qInfo, bool msg);
bool SatisfyQuestReputation(Quest const* qInfo, bool msg);
bool SatisfyQuestStatus(Quest const* qInfo, bool msg);
@@ -1483,7 +1494,7 @@ class Player : public Unit, public GridObject<Player>
void SendQuestReward(Quest const* quest, uint32 XP, Object* questGiver);
void SendQuestFailed(uint32 questId, InventoryResult reason = EQUIP_ERR_OK);
void SendQuestTimerFailed(uint32 quest_id);
- void SendCanTakeQuestResponse(uint32 msg);
+ void SendCanTakeQuestResponse(uint32 msg) const;
void SendQuestConfirmAccept(Quest const* quest, Player* pReceiver);
void SendPushToPartyResponse(Player* player, uint32 msg);
void SendQuestUpdateAddItem(Quest const* quest, uint32 item_idx, uint16 count);
@@ -1520,7 +1531,7 @@ class Player : public Unit, public GridObject<Player>
/*** SAVE SYSTEM ***/
/*********************************************************/
- void SaveToDB();
+ void SaveToDB(bool create = false);
void SaveInventoryAndGoldToDB(SQLTransaction& trans); // fast save function for item/money cheating preventing
void SaveGoldToDB(SQLTransaction& trans);
@@ -2290,6 +2301,7 @@ class Player : public Unit, public GridObject<Player>
m_mover = target;
m_mover->m_movedPlayer = this;
}
+
void SetSeer(WorldObject* target) { m_seer = target; }
void SetViewpoint(WorldObject* target, bool apply);
WorldObject* GetViewpoint() const;
@@ -2328,7 +2340,7 @@ class Player : public Unit, public GridObject<Player>
bool IsNeverVisible() const;
- bool IsVisibleGloballyFor(Player* pl) const;
+ bool IsVisibleGloballyFor(Player* player) const;
void SendInitialVisiblePackets(Unit* target);
void UpdateObjectVisibility(bool forced = true);
@@ -2483,6 +2495,41 @@ class Player : public Unit, public GridObject<Player>
void AddWhisperWhiteList(uint64 guid) { WhisperList.push_back(guid); }
bool IsInWhisperWhiteList(uint64 guid);
+ //! Return collision height sent to client
+ float GetCollisionHeight(bool mounted)
+ {
+ if (mounted)
+ {
+ CreatureDisplayInfoEntry const* mountDisplayInfo = sCreatureDisplayInfoStore.LookupEntry(GetUInt32Value(UNIT_FIELD_MOUNTDISPLAYID));
+ if (!mountDisplayInfo)
+ return GetCollisionHeight(false);
+
+ CreatureModelDataEntry const* mountModelData = sCreatureModelDataStore.LookupEntry(mountDisplayInfo->ModelId);
+ if (!mountModelData)
+ return GetCollisionHeight(false);
+
+ CreatureDisplayInfoEntry const* displayInfo = sCreatureDisplayInfoStore.LookupEntry(GetNativeDisplayId());
+ ASSERT(displayInfo);
+ CreatureModelDataEntry const* modelData = sCreatureModelDataStore.LookupEntry(displayInfo->ModelId);
+ ASSERT(modelData);
+
+ float scaleMod = GetFloatValue(OBJECT_FIELD_SCALE_X); // 99% sure about this
+
+ return scaleMod * mountModelData->MountHeight + modelData->CollisionHeight * 0.5f;
+ }
+ else
+ {
+ //! Dismounting case - use basic default model data
+ CreatureDisplayInfoEntry const* displayInfo = sCreatureDisplayInfoStore.LookupEntry(GetNativeDisplayId());
+ ASSERT(displayInfo);
+ CreatureModelDataEntry const* modelData = sCreatureModelDataStore.LookupEntry(displayInfo->ModelId);
+ ASSERT(modelData);
+
+ return modelData->CollisionHeight;
+ }
+ //! TODO: Need a proper calculation for collision height when mounted
+ }
+
protected:
// Gamemaster whisper whitelist
WhisperListContainer WhisperList;
diff --git a/src/server/game/Entities/Player/SocialMgr.cpp b/src/server/game/Entities/Player/SocialMgr.cpp
index 4d343d02146..dbb18496515 100755
--- a/src/server/game/Entities/Player/SocialMgr.cpp
+++ b/src/server/game/Entities/Player/SocialMgr.cpp
@@ -114,23 +114,23 @@ void PlayerSocial::SetFriendNote(uint32 friend_guid, std::string note)
m_playerSocialMap[friend_guid].Note = note;
}
-void PlayerSocial::SendSocialList(Player* plr)
+void PlayerSocial::SendSocialList(Player* player)
{
- if (!plr)
+ if (!player)
return;
uint32 size = m_playerSocialMap.size();
WorldPacket data(SMSG_CONTACT_LIST, (4+4+size*25)); // just can guess size
- data << uint32(7); // unk flag (0x1, 0x2, 0x4), 0x7 if it include ignore list
+ data << uint32(7); // 0x1 = Friendlist update. 0x2 = Ignorelist update. 0x4 = Mutelist update.
data << uint32(size); // friends count
for (PlayerSocialMap::iterator itr = m_playerSocialMap.begin(); itr != m_playerSocialMap.end(); ++itr)
{
- sSocialMgr->GetFriendInfo(plr, itr->first, itr->second);
+ sSocialMgr->GetFriendInfo(player, itr->first, itr->second);
data << uint64(itr->first); // player guid
- data << uint32(itr->second.Flags); // player flag (0x1-friend?, 0x2-ignored?, 0x4-muted?)
+ data << uint32(itr->second.Flags); // player flag (0x1 = Friend, 0x2 = Ignored, 0x4 = Muted)
data << itr->second.Note; // string note
if (itr->second.Flags & SOCIAL_FLAG_FRIEND) // if IsFriend()
{
@@ -144,7 +144,7 @@ void PlayerSocial::SendSocialList(Player* plr)
}
}
- plr->GetSession()->SendPacket(&data);
+ player->GetSession()->SendPacket(&data);
sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Sent SMSG_CONTACT_LIST");
}
diff --git a/src/server/game/Entities/Player/SocialMgr.h b/src/server/game/Entities/Player/SocialMgr.h
index 5faa8f1987c..78965c13948 100755
--- a/src/server/game/Entities/Player/SocialMgr.h
+++ b/src/server/game/Entities/Player/SocialMgr.h
@@ -124,7 +124,7 @@ class PlayerSocial
void RemoveFromSocialList(uint32 friend_guid, bool ignore);
void SetFriendNote(uint32 friend_guid, std::string note);
// Packet send's
- void SendSocialList(Player* plr);
+ void SendSocialList(Player* player);
// Misc
bool HasFriend(uint32 friend_guid);
bool HasIgnore(uint32 ignore_guid);
diff --git a/src/server/game/Entities/Totem/Totem.cpp b/src/server/game/Entities/Totem/Totem.cpp
index 10c54720350..97629e802d4 100755
--- a/src/server/game/Entities/Totem/Totem.cpp
+++ b/src/server/game/Entities/Totem/Totem.cpp
@@ -86,9 +86,10 @@ void Totem::InitStats(uint32 duration)
void Totem::InitSummon()
{
- // use AddAura instead of CastSpell - this in fact should be an AddSpell equivalent for creatures, but nothing like that exists so far.
if (m_type == TOTEM_PASSIVE)
- AddAura(GetSpell(), this);
+ {
+ CastSpell(this, GetSpell(), true);
+ }
// Some totems can have both instant effect and passive spell
if (GetSpell(1))
diff --git a/src/server/game/Entities/Transport/Transport.cpp b/src/server/game/Entities/Transport/Transport.cpp
index 9a31846fa1f..97f5af1c6e9 100755
--- a/src/server/game/Entities/Transport/Transport.cpp
+++ b/src/server/game/Entities/Transport/Transport.cpp
@@ -98,7 +98,7 @@ void MapManager::LoadTransports()
m_TransportsByMap[*i].insert(t);
//If we someday decide to use the grid to track transports, here:
- t->SetMap(sMapMgr->CreateMap(mapid, t, 0));
+ t->SetMap(sMapMgr->CreateBaseMap(mapid));
t->AddToWorld();
++count;
@@ -365,9 +365,9 @@ bool Transport::GenerateWaypoints(uint32 pathid, std::set<uint32> &mapids)
if (keyFrames[keyFrames.size() - 1].node->mapid != keyFrames[0].node->mapid)
teleport = true;
- WayPoint pos(keyFrames[0].node->mapid, keyFrames[0].node->x, keyFrames[0].node->y, keyFrames[0].node->z, teleport, 0,
+ m_WayPoints[0] = WayPoint(keyFrames[0].node->mapid, keyFrames[0].node->x, keyFrames[0].node->y, keyFrames[0].node->z, teleport, 0,
keyFrames[0].node->arrivalEventID, keyFrames[0].node->departureEventID);
- m_WayPoints[0] = pos;
+
t += keyFrames[0].node->delay * 1000;
uint32 cM = keyFrames[0].node->mapid;
@@ -387,12 +387,11 @@ bool Transport::GenerateWaypoints(uint32 pathid, std::set<uint32> &mapids)
if (d > 0)
{
- float newX, newY, newZ;
- newX = keyFrames[i].node->x + (keyFrames[i + 1].node->x - keyFrames[i].node->x) * d / keyFrames[i + 1].distFromPrev;
- newY = keyFrames[i].node->y + (keyFrames[i + 1].node->y - keyFrames[i].node->y) * d / keyFrames[i + 1].distFromPrev;
- newZ = keyFrames[i].node->z + (keyFrames[i + 1].node->z - keyFrames[i].node->z) * d / keyFrames[i + 1].distFromPrev;
+ float newX = keyFrames[i].node->x + (keyFrames[i + 1].node->x - keyFrames[i].node->x) * d / keyFrames[i + 1].distFromPrev;
+ float newY = keyFrames[i].node->y + (keyFrames[i + 1].node->y - keyFrames[i].node->y) * d / keyFrames[i + 1].distFromPrev;
+ float newZ = keyFrames[i].node->z + (keyFrames[i + 1].node->z - keyFrames[i].node->z) * d / keyFrames[i + 1].distFromPrev;
- bool teleport = false;
+ teleport = false;
if (keyFrames[i].node->mapid != cM)
{
teleport = true;
@@ -400,9 +399,8 @@ bool Transport::GenerateWaypoints(uint32 pathid, std::set<uint32> &mapids)
}
// sLog->outString("T: %d, D: %f, x: %f, y: %f, z: %f", t, d, newX, newY, newZ);
- WayPoint pos(keyFrames[i].node->mapid, newX, newY, newZ, teleport, 0);
if (teleport)
- m_WayPoints[t] = pos;
+ m_WayPoints[t] = WayPoint(keyFrames[i].node->mapid, newX, newY, newZ, teleport, 0);
}
if (tFrom < tTo) // caught in tFrom dock's "gravitational pull"
@@ -439,25 +437,18 @@ bool Transport::GenerateWaypoints(uint32 pathid, std::set<uint32> &mapids)
else
t += (long)keyFrames[i + 1].tTo % 100;
- bool teleport = false;
+ teleport = false;
if ((keyFrames[i + 1].node->actionFlag == 1) || (keyFrames[i + 1].node->mapid != keyFrames[i].node->mapid))
{
teleport = true;
cM = keyFrames[i + 1].node->mapid;
}
- WayPoint pos(keyFrames[i + 1].node->mapid, keyFrames[i + 1].node->x, keyFrames[i + 1].node->y, keyFrames[i + 1].node->z, teleport,
+ m_WayPoints[t] = WayPoint(keyFrames[i + 1].node->mapid, keyFrames[i + 1].node->x, keyFrames[i + 1].node->y, keyFrames[i + 1].node->z, teleport,
0, keyFrames[i + 1].node->arrivalEventID, keyFrames[i + 1].node->departureEventID);
// sLog->outString("T: %d, x: %f, y: %f, z: %f, t:%d", t, pos.x, pos.y, pos.z, teleport);
-/*
- if (keyFrames[i+1].delay > 5)
- pos.delayed = true;
-*/
- //if (teleport)
- m_WayPoints[t] = pos;
t += keyFrames[i + 1].node->delay * 1000;
- // sLog->outString("------");
}
uint32 timer = t;
@@ -489,13 +480,13 @@ void Transport::TeleportTransport(uint32 newMapid, float x, float y, float z)
for (PlayerSet::const_iterator itr = m_passengers.begin(); itr != m_passengers.end();)
{
- Player* plr = *itr;
+ Player* player = *itr;
++itr;
- if (plr->isDead() && !plr->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_GHOST))
- plr->ResurrectPlayer(1.0f);
+ if (player->isDead() && !player->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_GHOST))
+ player->ResurrectPlayer(1.0f);
- plr->TeleportTo(newMapid, x, y, z, GetOrientation(), TELE_TO_NOT_LEAVE_TRANSPORT);
+ player->TeleportTo(newMapid, x, y, z, GetOrientation(), TELE_TO_NOT_LEAVE_TRANSPORT);
}
//we need to create and save new Map object with 'newMapid' because if not done -> lead to invalid Map object reference...
@@ -503,7 +494,7 @@ void Transport::TeleportTransport(uint32 newMapid, float x, float y, float z)
RemoveFromWorld();
ResetMap();
- Map* newMap = sMapMgr->CreateMap(newMapid, this, 0);
+ Map* newMap = sMapMgr->CreateBaseMap(newMapid);
SetMap(newMap);
ASSERT (GetMap());
AddToWorld();
@@ -584,13 +575,13 @@ void Transport::Update(uint32 p_diff)
void Transport::UpdateForMap(Map const* targetMap)
{
- Map::PlayerList const& pl = targetMap->GetPlayers();
- if (pl.isEmpty())
+ Map::PlayerList const& player = targetMap->GetPlayers();
+ if (player.isEmpty())
return;
if (GetMapId() == targetMap->GetId())
{
- for (Map::PlayerList::const_iterator itr = pl.begin(); itr != pl.end(); ++itr)
+ for (Map::PlayerList::const_iterator itr = player.begin(); itr != player.end(); ++itr)
{
if (this != itr->getSource()->GetTransport())
{
@@ -609,7 +600,7 @@ void Transport::UpdateForMap(Map const* targetMap)
WorldPacket out_packet;
transData.BuildPacket(&out_packet);
- for (Map::PlayerList::const_iterator itr = pl.begin(); itr != pl.end(); ++itr)
+ for (Map::PlayerList::const_iterator itr = player.begin(); itr != player.end(); ++itr)
if (this != itr->getSource()->GetTransport())
itr->getSource()->SendDirectMessage(&out_packet);
}
diff --git a/src/server/game/Entities/Unit/StatSystem.cpp b/src/server/game/Entities/Unit/StatSystem.cpp
index 594203e0c46..3ab2f786086 100755
--- a/src/server/game/Entities/Unit/StatSystem.cpp
+++ b/src/server/game/Entities/Unit/StatSystem.cpp
@@ -641,20 +641,21 @@ const float m_diminishing_k[MAX_CLASSES] =
float Player::GetMissPercentageFromDefence() const
{
- const float miss_cap[MAX_CLASSES] =
+ float const miss_cap[MAX_CLASSES] =
{
- 16.00f, // Warrior //correct
- 16.00f, // Paladin //correct
- 16.00f, // Hunter //?
- 16.00f, // Rogue //?
- 16.00f, // Priest //?
- 16.00f, // DK //correct
- 16.00f, // Shaman //?
- 16.00f, // Mage //?
- 16.00f, // Warlock //?
- 0.0f, // ??
- 16.00f // Druid //?
+ 16.00f, // Warrior //correct
+ 16.00f, // Paladin //correct
+ 16.00f, // Hunter //?
+ 16.00f, // Rogue //?
+ 16.00f, // Priest //?
+ 16.00f, // DK //correct
+ 16.00f, // Shaman //?
+ 16.00f, // Mage //?
+ 16.00f, // Warlock //?
+ 0.0f, // ??
+ 16.00f // Druid //?
};
+
float diminishing = 0.0f, nondiminishing = 0.0f;
// Modify value from defense skill (only bonus from defense rating diminishes)
nondiminishing += (GetSkillValue(SKILL_DEFENSE) - GetMaxSkillValueForLevel()) * 0.04f;
@@ -669,17 +670,17 @@ void Player::UpdateParryPercentage()
{
const float parry_cap[MAX_CLASSES] =
{
- 47.003525f, // Warrior
- 47.003525f, // Paladin
- 145.560408f, // Hunter
- 145.560408f, // Rogue
- 0.0f, // Priest
- 47.003525f, // DK
- 145.560408f, // Shaman
- 0.0f, // Mage
- 0.0f, // Warlock
- 0.0f, // ??
- 0.0f // Druid
+ 47.003525f, // Warrior
+ 47.003525f, // Paladin
+ 145.560408f, // Hunter
+ 145.560408f, // Rogue
+ 0.0f, // Priest
+ 47.003525f, // DK
+ 145.560408f, // Shaman
+ 0.0f, // Mage
+ 0.0f, // Warlock
+ 0.0f, // ??
+ 0.0f // Druid
};
// No parry
@@ -706,17 +707,17 @@ void Player::UpdateDodgePercentage()
{
const float dodge_cap[MAX_CLASSES] =
{
- 88.129021f, // Warrior
- 88.129021f, // Paladin
- 145.560408f, // Hunter
- 145.560408f, // Rogue
- 150.375940f, // Priest
- 88.129021f, // DK
- 145.560408f, // Shaman
- 150.375940f, // Mage
- 150.375940f, // Warlock
- 0.0f, // ??
- 116.890707f // Druid
+ 88.129021f, // Warrior
+ 88.129021f, // Paladin
+ 145.560408f, // Hunter
+ 145.560408f, // Rogue
+ 150.375940f, // Priest
+ 88.129021f, // DK
+ 145.560408f, // Shaman
+ 150.375940f, // Mage
+ 150.375940f, // Warlock
+ 0.0f, // ??
+ 116.890707f // Druid
};
float diminishing = 0.0f, nondiminishing = 0.0f;
diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp
index 631ea9b7c90..2e2f5591a5d 100755
--- a/src/server/game/Entities/Unit/Unit.cpp
+++ b/src/server/game/Entities/Unit/Unit.cpp
@@ -181,7 +181,8 @@ m_vehicleKit(NULL), m_unitTypeMask(UNIT_MASK_NONE), m_HostileRefManager(this)
for (uint8 i = 0; i < MAX_SUMMON_SLOT; ++i)
m_SummonSlot[i] = 0;
- m_ObjectSlot[0] = m_ObjectSlot[1] = m_ObjectSlot[2] = m_ObjectSlot[3] = 0;
+ for (uint8 i = 0; i < MAX_GAMEOBJECT_SLOT; ++i)
+ m_ObjectSlot[i] = 0;
m_auraUpdateIterator = m_ownedAuras.end();
@@ -585,7 +586,7 @@ bool Unit::IsWithinMeleeRange(const Unit* obj, float dist) const
void Unit::GetRandomContactPoint(const Unit* obj, float &x, float &y, float &z, float distance2dMin, float distance2dMax) const
{
float combat_reach = GetCombatReach();
- if (combat_reach < 0.1) // sometimes bugged for players
+ if (combat_reach < 0.1f) // sometimes bugged for players
combat_reach = DEFAULT_COMBAT_REACH;
uint32 attacker_number = getAttackers().size();
@@ -1511,44 +1512,36 @@ uint32 Unit::CalcArmorReducedDamage(Unit* victim, const uint32 damage, SpellInfo
armor = floor(AddPctN(armor, -(*j)->GetAmount()));
}
+ // Apply Player CR_ARMOR_PENETRATION rating and buffs from stances\specializations etc.
if (GetTypeId() == TYPEID_PLAYER)
{
+ float bonusPct = 0;
AuraEffectList const& ResIgnoreAuras = GetAuraEffectsByType(SPELL_AURA_MOD_ARMOR_PENETRATION_PCT);
for (AuraEffectList::const_iterator itr = ResIgnoreAuras.begin(); itr != ResIgnoreAuras.end(); ++itr)
{
- // item neutral spell
if ((*itr)->GetSpellInfo()->EquippedItemClass == -1)
{
- armor = floor(AddPctN(armor, -(*itr)->GetAmount()));
- continue;
+ if (!spellInfo || (*itr)->IsAffectedOnSpell(spellInfo) || (*itr)->GetMiscValue() & spellInfo->GetSchoolMask())
+ bonusPct += (*itr)->GetAmount();
+ else if (!(*itr)->GetMiscValue() && !(*itr)->HasSpellClassMask())
+ bonusPct += (*itr)->GetAmount();
}
-
- // item dependent spell - check current weapons
- for (int i = 0; i < MAX_ATTACK; ++i)
+ else
{
- Item* weapon = ToPlayer()->GetWeaponForAttack(WeaponAttackType(i), true);
-
- if (weapon && weapon->IsFitToSpellRequirements((*itr)->GetSpellInfo()))
- {
- armor = floor(AddPctN(armor, -(*itr)->GetAmount()));
- break;
- }
+ if (ToPlayer() && ToPlayer()->HasItemFitToSpellRequirements((*itr)->GetSpellInfo()))
+ bonusPct += (*itr)->GetAmount();
}
}
- }
- // Apply Player CR_ARMOR_PENETRATION rating
- if (GetTypeId() == TYPEID_PLAYER)
- {
float maxArmorPen = 0;
- if (getLevel() < 60)
+ if (victim->getLevel() < 60)
maxArmorPen = float(400 + 85 * victim->getLevel());
else
maxArmorPen = 400 + 85 * victim->getLevel() + 4.5f * 85 * (victim->getLevel() - 59);
// Cap armor penetration to this number
maxArmorPen = std::min((armor + maxArmorPen) / 3, armor);
// Figure out how much armor do we ignore
- float armorPen = CalculatePctF(maxArmorPen, ToPlayer()->GetRatingBonusValue(CR_ARMOR_PENETRATION));
+ float armorPen = CalculatePctF(maxArmorPen, bonusPct + ToPlayer()->GetRatingBonusValue(CR_ARMOR_PENETRATION));
// Got the value, apply it
armor -= std::min(armorPen, maxArmorPen);
}
@@ -1573,7 +1566,7 @@ uint32 Unit::CalcArmorReducedDamage(Unit* victim, const uint32 damage, SpellInfo
return (newdamage > 1) ? newdamage : 1;
}
-void Unit::CalcAbsorbResist(Unit* victim, SpellSchoolMask schoolMask, DamageEffectType damagetype, const uint32 damage, uint32 *absorb, uint32 *resist, SpellInfo const* spellInfo)
+void Unit::CalcAbsorbResist(Unit* victim, SpellSchoolMask schoolMask, DamageEffectType damagetype, uint32 const damage, uint32 *absorb, uint32 *resist, SpellInfo const* spellInfo)
{
if (!victim || !victim->isAlive() || !damage)
return;
@@ -1583,15 +1576,19 @@ void Unit::CalcAbsorbResist(Unit* victim, SpellSchoolMask schoolMask, DamageEffe
// Magic damage, check for resists
if ((schoolMask & SPELL_SCHOOL_MASK_NORMAL) == 0)
{
- float baseVictimResistance = float(victim->GetResistance(GetFirstSchoolInMask(schoolMask)));
- float ignoredResistance = float(GetTotalAuraModifierByMiscMask(SPELL_AURA_MOD_TARGET_RESISTANCE, schoolMask));
+ float victimResistance = float(victim->GetResistance(schoolMask));
+ victimResistance += float(GetTotalAuraModifierByMiscMask(SPELL_AURA_MOD_TARGET_RESISTANCE, schoolMask));
+
if (Player* player = ToPlayer())
- ignoredResistance += float(player->GetSpellPenetrationItemMod());
- float victimResistance = baseVictimResistance + ignoredResistance;
+ victimResistance -= float(player->GetSpellPenetrationItemMod());
- static const uint32 BOSS_LEVEL = 83;
- static const float BOSS_RESISTANCE_CONSTANT = 510.0;
- uint32 level = getLevel();
+ // Resistance can't be lower then 0.
+ if (victimResistance < 0.0f)
+ victimResistance = 0.0f;
+
+ static uint32 const BOSS_LEVEL = 83;
+ static float const BOSS_RESISTANCE_CONSTANT = 510.0f;
+ uint32 level = victim->getLevel();
float resistanceConstant = 0.0f;
if (level == BOSS_LEVEL)
@@ -1682,12 +1679,12 @@ void Unit::CalcAbsorbResist(Unit* victim, SpellSchoolMask schoolMask, DamageEffe
if (currentAbsorb < 0)
currentAbsorb = 0;
- uint32 absorb = currentAbsorb;
+ uint32 tempAbsorb = uint32(currentAbsorb);
bool defaultPrevented = false;
- absorbAurEff->GetBase()->CallScriptEffectAbsorbHandlers(absorbAurEff, aurApp, dmgInfo, absorb, defaultPrevented);
- currentAbsorb = absorb;
+ absorbAurEff->GetBase()->CallScriptEffectAbsorbHandlers(absorbAurEff, aurApp, dmgInfo, tempAbsorb, defaultPrevented);
+ currentAbsorb = tempAbsorb;
if (defaultPrevented)
continue;
@@ -1700,8 +1697,8 @@ void Unit::CalcAbsorbResist(Unit* victim, SpellSchoolMask schoolMask, DamageEffe
dmgInfo.AbsorbDamage(currentAbsorb);
- absorb = currentAbsorb;
- absorbAurEff->GetBase()->CallScriptEffectAfterAbsorbHandlers(absorbAurEff, aurApp, dmgInfo, absorb);
+ tempAbsorb = currentAbsorb;
+ absorbAurEff->GetBase()->CallScriptEffectAfterAbsorbHandlers(absorbAurEff, aurApp, dmgInfo, tempAbsorb);
// Check if our aura is using amount to count damage
if (absorbAurEff->GetAmount() >= 0)
@@ -1733,12 +1730,12 @@ void Unit::CalcAbsorbResist(Unit* victim, SpellSchoolMask schoolMask, DamageEffe
if (currentAbsorb < 0)
currentAbsorb = 0;
- uint32 absorb = currentAbsorb;
+ uint32 tempAbsorb = currentAbsorb;
bool defaultPrevented = false;
- absorbAurEff->GetBase()->CallScriptEffectManaShieldHandlers(absorbAurEff, aurApp, dmgInfo, absorb, defaultPrevented);
- currentAbsorb = absorb;
+ absorbAurEff->GetBase()->CallScriptEffectManaShieldHandlers(absorbAurEff, aurApp, dmgInfo, tempAbsorb, defaultPrevented);
+ currentAbsorb = tempAbsorb;
if (defaultPrevented)
continue;
@@ -1761,8 +1758,8 @@ void Unit::CalcAbsorbResist(Unit* victim, SpellSchoolMask schoolMask, DamageEffe
dmgInfo.AbsorbDamage(currentAbsorb);
- absorb = currentAbsorb;
- absorbAurEff->GetBase()->CallScriptEffectAfterManaShieldHandlers(absorbAurEff, aurApp, dmgInfo, absorb);
+ tempAbsorb = currentAbsorb;
+ absorbAurEff->GetBase()->CallScriptEffectAfterManaShieldHandlers(absorbAurEff, aurApp, dmgInfo, tempAbsorb);
// Check if our aura is using amount to count damage
if (absorbAurEff->GetAmount() >= 0)
@@ -2215,22 +2212,23 @@ void Unit::SendMeleeAttackStart(Unit* victim)
WorldPacket data(SMSG_ATTACKSTART, 8 + 8);
data << uint64(GetGUID());
data << uint64(victim->GetGUID());
-
SendMessageToSet(&data, true);
sLog->outStaticDebug("WORLD: Sent SMSG_ATTACKSTART");
}
void Unit::SendMeleeAttackStop(Unit* victim)
{
- if (!victim)
- return;
-
WorldPacket data(SMSG_ATTACKSTOP, (8+8+4)); // we guess size
data.append(GetPackGUID());
- data.append(victim->GetPackGUID()); // can be 0x00...
- data << uint32(0); // can be 0x1
+ data.append(victim ? victim->GetPackGUID() : 0); // can be 0x00...
+ data << uint32(0); // can be 0x1
SendMessageToSet(&data, true);
- sLog->outDetail("%s %u stopped attacking %s %u", (GetTypeId() == TYPEID_PLAYER ? "player" : "creature"), GetGUIDLow(), (victim->GetTypeId() == TYPEID_PLAYER ? "player" : "creature"), victim->GetGUIDLow());
+ sLog->outStaticDebug("WORLD: Sent SMSG_ATTACKSTART");
+
+ if (victim)
+ sLog->outDetail("%s %u stopped attacking %s %u", (GetTypeId() == TYPEID_PLAYER ? "Player" : "Creature"), GetGUIDLow(), (victim->GetTypeId() == TYPEID_PLAYER ? "player" : "creature"), victim->GetGUIDLow());
+ else
+ sLog->outDetail("%s %u stopped attacking", (GetTypeId() == TYPEID_PLAYER ? "Player" : "Creature"), GetGUIDLow());
}
bool Unit::isSpellBlocked(Unit* victim, SpellInfo const* spellProto, WeaponAttackType attackType)
@@ -3007,7 +3005,7 @@ void Unit::InterruptSpell(CurrentSpellTypes spellType, bool withDelayed, bool wi
Spell* spell = m_currentSpells[spellType];
if (spell
&& (withDelayed || spell->getState() != SPELL_STATE_DELAYED)
- && (withInstant || spell->CalcCastTime() > 0))
+ && (withInstant || spell->GetCastTime() > 0))
{
// for example, do not let self-stun aura interrupt itself
if (!spell->IsInterruptable())
@@ -3044,7 +3042,7 @@ bool Unit::IsNonMeleeSpellCasted(bool withDelayed, bool skipChanneled, bool skip
// Maybe later some special spells will be excluded too.
// if skipInstant then instant spells shouldn't count as being casted
- if (skipInstant && m_currentSpells[CURRENT_GENERIC_SPELL] && !m_currentSpells[CURRENT_GENERIC_SPELL]->CalcCastTime())
+ if (skipInstant && m_currentSpells[CURRENT_GENERIC_SPELL] && !m_currentSpells[CURRENT_GENERIC_SPELL]->GetCastTime())
return false;
// generic spells are casted when they are not finished and not delayed
@@ -3095,7 +3093,7 @@ Spell* Unit::FindCurrentSpellBySpellId(uint32 spell_id) const
int32 Unit::GetCurrentSpellCastTime(uint32 spell_id) const
{
if (Spell const* spell = FindCurrentSpellBySpellId(spell_id))
- return spell->CalcCastTime();
+ return spell->GetCastTime();
return 0;
}
@@ -3471,10 +3469,10 @@ void Unit::RemoveOwnedAura(AuraMap::iterator &i, AuraRemoveMode removeMode)
i = m_ownedAuras.begin();
}
-void Unit::RemoveOwnedAura(uint32 spellId, uint64 caster, uint8 reqEffMask, AuraRemoveMode removeMode)
+void Unit::RemoveOwnedAura(uint32 spellId, uint64 casterGUID, uint8 reqEffMask, AuraRemoveMode removeMode)
{
for (AuraMap::iterator itr = m_ownedAuras.lower_bound(spellId); itr != m_ownedAuras.upper_bound(spellId);)
- if (((itr->second->GetEffectMask() & reqEffMask) == reqEffMask) && (!caster || itr->second->GetCasterGUID() == caster))
+ if (((itr->second->GetEffectMask() & reqEffMask) == reqEffMask) && (!casterGUID || itr->second->GetCasterGUID() == casterGUID))
{
RemoveOwnedAura(itr, removeMode);
itr = m_ownedAuras.lower_bound(spellId);
@@ -3577,13 +3575,13 @@ void Unit::RemoveAura(Aura* aura, AuraRemoveMode mode)
RemoveAura(aurApp, mode);
}
-void Unit::RemoveAurasDueToSpell(uint32 spellId, uint64 caster, uint8 reqEffMask, AuraRemoveMode removeMode)
+void Unit::RemoveAurasDueToSpell(uint32 spellId, uint64 casterGUID, uint8 reqEffMask, AuraRemoveMode removeMode)
{
for (AuraApplicationMap::iterator iter = m_appliedAuras.lower_bound(spellId); iter != m_appliedAuras.upper_bound(spellId);)
{
Aura const* aura = iter->second->GetBase();
if (((aura->GetEffectMask() & reqEffMask) == reqEffMask)
- && (!caster || aura->GetCasterGUID() == caster))
+ && (!casterGUID || aura->GetCasterGUID() == casterGUID))
{
RemoveAura(iter, removeMode);
iter = m_appliedAuras.lower_bound(spellId);
@@ -3593,13 +3591,13 @@ void Unit::RemoveAurasDueToSpell(uint32 spellId, uint64 caster, uint8 reqEffMask
}
}
-void Unit::RemoveAuraFromStack(uint32 spellId, uint64 caster, AuraRemoveMode removeMode)
+void Unit::RemoveAuraFromStack(uint32 spellId, uint64 casterGUID, AuraRemoveMode removeMode)
{
for (AuraMap::iterator iter = m_ownedAuras.lower_bound(spellId); iter != m_ownedAuras.upper_bound(spellId);)
{
Aura* aura = iter->second;
if ((aura->GetType() == UNIT_AURA_TYPE)
- && (!caster || aura->GetCasterGUID() == caster))
+ && (!casterGUID || aura->GetCasterGUID() == casterGUID))
{
aura->ModStackAmount(-1, removeMode);
return;
@@ -3738,13 +3736,13 @@ void Unit::RemoveAurasDueToSpellBySteal(uint32 spellId, uint64 casterGUID, Unit*
// Cast duration to unsigned to prevent permanent aura's such as Righteous Fury being permanently added to caster
uint32 dur = std::min(2u * MINUTE * IN_MILLISECONDS, uint32(aura->GetDuration()));
- if (Aura* newAura = stealer->GetAura(aura->GetId(), aura->GetCasterGUID()))
+ if (Aura* oldAura = stealer->GetAura(aura->GetId(), aura->GetCasterGUID()))
{
if (stealCharge)
- newAura->ModCharges(1);
+ oldAura->ModCharges(1);
else
- newAura->ModStackAmount(1);
- newAura->SetDuration(int32(dur));
+ oldAura->ModStackAmount(1);
+ oldAura->SetDuration(int32(dur));
}
else
{
@@ -4421,14 +4419,26 @@ int32 Unit::GetTotalAuraModifierByMiscMask(AuraType auratype, uint32 misc_mask)
float Unit::GetTotalAuraMultiplierByMiscMask(AuraType auratype, uint32 misc_mask) const
{
+ std::map<SpellGroup, int32> SameEffectSpellGroup;
float multiplier = 1.0f;
AuraEffectList const& mTotalAuraList = GetAuraEffectsByType(auratype);
for (AuraEffectList::const_iterator i = mTotalAuraList.begin(); i != mTotalAuraList.end(); ++i)
{
- if ((*i)->GetMiscValue()& misc_mask)
- AddPctN(multiplier, (*i)->GetAmount());
+ if (((*i)->GetMiscValue() & misc_mask))
+ {
+ // Check if the Aura Effect has a the Same Effect Stack Rule and if so, use the highest amount of that SpellGroup
+ // If the Aura Effect does not have this Stack Rule, it returns false so we can add to the multiplier as usual
+ if (!sSpellMgr->AddSameEffectStackRuleSpellGroups((*i)->GetSpellInfo(), (*i)->GetAmount(), SameEffectSpellGroup))
+ AddPctN(multiplier, (*i)->GetAmount());
+ }
}
+ // Add the highest of the Same Effect Stack Rule SpellGroups to the multiplier
+ for (std::map<SpellGroup, int32>::const_iterator itr = SameEffectSpellGroup.begin(); itr != SameEffectSpellGroup.end(); ++itr)
+ {
+ AddPctN(multiplier, itr->second);
+ }
+
return multiplier;
}
@@ -4645,7 +4655,7 @@ void Unit::RemoveGameObject(GameObject* gameObj, bool del)
gameObj->SetOwnerGUID(0);
- for (uint32 i = 0; i < 4; ++i)
+ for (uint8 i = 0; i < MAX_GAMEOBJECT_SLOT; ++i)
{
if (m_ObjectSlot[i] == gameObj->GetGUID())
{
@@ -4705,12 +4715,13 @@ void Unit::RemoveGameObject(uint32 spellid, bool del)
void Unit::RemoveAllGameObjects()
{
// remove references to unit
- for (GameObjectList::iterator i = m_gameObj.begin(); i != m_gameObj.end();)
+ while (!m_gameObj.empty())
{
+ GameObjectList::iterator i = m_gameObj.begin();
(*i)->SetOwnerGUID(0);
(*i)->SetRespawnTime(0);
(*i)->Delete();
- i = m_gameObj.erase(i);
+ m_gameObj.erase(i);
}
}
@@ -5223,6 +5234,7 @@ bool Unit::HandleDummyAuraProc(Unit* victim, uint32 damage, AuraEffect* triggere
break;
case CLASS_ROGUE: // 39511, 40997, 40998, 41002, 41005, 41011
case CLASS_WARRIOR: // 39511, 40997, 40998, 41002, 41005, 41011
+ case CLASS_DEATH_KNIGHT:
triggered_spell_id = RAND(39511, 40997, 40998, 41002, 41005, 41011);
cooldown_spell_id = 39511;
break;
@@ -5270,7 +5282,7 @@ bool Unit::HandleDummyAuraProc(Unit* victim, uint32 damage, AuraEffect* triggere
if (ToPlayer()->GetReputationRank(934) == REP_EXALTED)
{
// triggered at positive/self casts also, current attack target used then
- if (IsFriendlyTo(target))
+ if (target && IsFriendlyTo(target))
{
target = getVictim();
if (!target)
@@ -5747,11 +5759,11 @@ bool Unit::HandleDummyAuraProc(Unit* victim, uint32 damage, AuraEffect* triggere
// Glyph of Ice Block
case 56372:
{
- Player* plr = ToPlayer();
- if (!plr)
+ Player* player = ToPlayer();
+ if (!player)
return false;
- SpellCooldowns const cooldowns = plr->GetSpellCooldowns();
+ SpellCooldowns const cooldowns = player->GetSpellCooldowns();
// remove cooldowns on all ranks of Frost Nova
for (SpellCooldowns::const_iterator itr = cooldowns.begin(); itr != cooldowns.end(); ++itr)
{
@@ -5759,7 +5771,7 @@ bool Unit::HandleDummyAuraProc(Unit* victim, uint32 damage, AuraEffect* triggere
// Frost Nova
if (cdSpell && cdSpell->SpellFamilyName == SPELLFAMILY_MAGE
&& cdSpell->SpellFamilyFlags[0] & 0x00000040)
- plr->RemoveSpellCooldown(cdSpell->Id, true);
+ player->RemoveSpellCooldown(cdSpell->Id, true);
}
break;
}
@@ -6271,7 +6283,7 @@ bool Unit::HandleDummyAuraProc(Unit* victim, uint32 damage, AuraEffect* triggere
{
if (procSpell->SpellVisual[0] == 750 && procSpell->Effects[1].ApplyAuraName == 3)
{
- if (target->GetTypeId() == TYPEID_UNIT)
+ if (target && target->GetTypeId() == TYPEID_UNIT)
{
triggered_spell_id = 54820;
break;
@@ -7041,26 +7053,26 @@ bool Unit::HandleDummyAuraProc(Unit* victim, uint32 damage, AuraEffect* triggere
// Windfury Weapon (Passive) 1-5 Ranks
case 33757:
{
- Player* plr = ToPlayer();
- if (!plr || !castItem || !castItem->IsEquipped() || !victim || !victim->isAlive())
+ Player* player = ToPlayer();
+ if (!player || !castItem || !castItem->IsEquipped() || !victim || !victim->isAlive())
return false;
// custom cooldown processing case
- if (cooldown && plr->HasSpellCooldown(dummySpell->Id))
+ if (cooldown && player->HasSpellCooldown(dummySpell->Id))
return false;
if (triggeredByAura->GetBase() && castItem->GetGUID() != triggeredByAura->GetBase()->GetCastItemGUID())
return false;
- WeaponAttackType attType = WeaponAttackType(plr->GetAttackBySlot(castItem->GetSlot()));
+ WeaponAttackType attType = WeaponAttackType(player->GetAttackBySlot(castItem->GetSlot()));
if ((attType != BASE_ATTACK && attType != OFF_ATTACK) || !isAttackReady(attType))
return false;
// Now compute real proc chance...
uint32 chance = 20;
- plr->ApplySpellMod(dummySpell->Id, SPELLMOD_CHANCE_OF_SUCCESS, chance);
+ player->ApplySpellMod(dummySpell->Id, SPELLMOD_CHANCE_OF_SUCCESS, chance);
- Item* addWeapon = plr->GetWeaponForAttack(attType == BASE_ATTACK ? OFF_ATTACK : BASE_ATTACK, true);
+ Item* addWeapon = player->GetWeaponForAttack(attType == BASE_ATTACK ? OFF_ATTACK : BASE_ATTACK, true);
uint32 enchant_id_add = addWeapon ? addWeapon->GetEnchantmentId(EnchantmentSlot(TEMP_ENCHANTMENT_SLOT)) : 0;
SpellItemEnchantmentEntry const* pEnchant = sSpellItemEnchantmentStore.LookupEntry(enchant_id_add);
if (pEnchant && pEnchant->spellid[0] == dummySpell->Id)
@@ -7105,7 +7117,7 @@ bool Unit::HandleDummyAuraProc(Unit* victim, uint32 damage, AuraEffect* triggere
// apply cooldown before cast to prevent processing itself
if (cooldown)
- plr->AddSpellCooldown(dummySpell->Id, 0, time(NULL) + cooldown);
+ player->AddSpellCooldown(dummySpell->Id, 0, time(NULL) + cooldown);
// Attack Twice
for (uint32 i = 0; i < 2; ++i)
@@ -7231,7 +7243,7 @@ bool Unit::HandleDummyAuraProc(Unit* victim, uint32 damage, AuraEffect* triggere
// Item - Shaman T10 Elemental 4P Bonus
case 70817:
{
- if(!target)
+ if (!target)
return false;
// try to find spell Flame Shock on the target
if (AuraEffect const* aurEff = target->GetAuraEffect(SPELL_AURA_PERIODIC_DAMAGE, SPELLFAMILY_SHAMAN, 0x10000000, 0x0, 0x0, GetGUID()))
@@ -7731,6 +7743,9 @@ bool Unit::HandleDummyAuraProc(Unit* victim, uint32 damage, AuraEffect* triggere
// Guard Dog
case 201:
{
+ if (!victim)
+ return false;
+
triggered_spell_id = 54445;
target = this;
float addThreat = float(CalculatePctN(procSpell->Effects[0].CalcValue(this), triggerAmount));
@@ -7979,11 +7994,8 @@ bool Unit::HandleAuraProc(Unit* victim, uint32 damage, Aura* triggeredByAura, Sp
else if (dummySpell->SpellIconID == 3015)
{
*handled = true;
- if (procSpell->Category == SPELLCATEGORY_JUDGEMENT)
- {
- CastSpell(victim, 68055, true);
- return true;
- }
+ CastSpell(victim, 68055, true);
+ return true;
}
// Glyph of Divinity
else if (dummySpell->Id == 54939)
@@ -8053,9 +8065,9 @@ bool Unit::HandleAuraProc(Unit* victim, uint32 damage, Aura* triggeredByAura, Sp
{
*handled = true;
// Convert recently used Blood Rune to Death Rune
- if (Player* plr = ToPlayer())
+ if (Player* player = ToPlayer())
{
- if (plr->getClass() != CLASS_DEATH_KNIGHT)
+ if (player->getClass() != CLASS_DEATH_KNIGHT)
return false;
RuneType rune = ToPlayer()->GetLastUsedRune();
@@ -8079,22 +8091,22 @@ bool Unit::HandleAuraProc(Unit* victim, uint32 damage, Aura* triggeredByAura, Sp
{
if (dummySpell->SpellIconID == 2622)
{
- if (plr->GetCurrentRune(i) == RUNE_DEATH ||
- plr->GetBaseRune(i) == RUNE_BLOOD)
+ if (player->GetCurrentRune(i) == RUNE_DEATH ||
+ player->GetBaseRune(i) == RUNE_BLOOD)
continue;
}
else
{
- if (plr->GetCurrentRune(i) == RUNE_DEATH ||
- plr->GetBaseRune(i) != RUNE_BLOOD)
+ if (player->GetCurrentRune(i) == RUNE_DEATH ||
+ player->GetBaseRune(i) != RUNE_BLOOD)
continue;
}
- if (plr->GetRuneCooldown(i) != plr->GetRuneBaseCooldown(i))
+ if (player->GetRuneCooldown(i) != player->GetRuneBaseCooldown(i))
continue;
--runesLeft;
// Mark aura as used
- plr->AddRuneByAuraEffect(i, RUNE_DEATH, aurEff);
+ player->AddRuneByAuraEffect(i, RUNE_DEATH, aurEff);
}
return true;
}
@@ -8388,6 +8400,13 @@ bool Unit::HandleProcTriggerSpell(Unit* victim, uint32 damage, AuraEffect* trigg
basepoints0 += victim->GetRemainingPeriodicAmount(GetGUID(), trigger_spell_id, SPELL_AURA_PERIODIC_DAMAGE);
break;
}
+ // Item - Hunter T9 4P Bonus
+ if (auraSpellInfo->Id == 67151)
+ {
+ trigger_spell_id = 68130;
+ target = this;
+ break;
+ }
break;
}
case SPELLFAMILY_PALADIN:
@@ -8730,7 +8749,7 @@ bool Unit::HandleProcTriggerSpell(Unit* victim, uint32 damage, AuraEffect* trigg
case 63156:
case 63158:
// Can proc only if target has hp below 35%
- if (!victim->HasAuraState(AURA_STATE_HEALTHLESS_35_PERCENT, procSpell, this))
+ if (!victim || !victim->HasAuraState(AURA_STATE_HEALTHLESS_35_PERCENT, procSpell, this))
return false;
break;
// Deathbringer Saurfang - Blood Beast's Blood Link
@@ -8770,11 +8789,11 @@ bool Unit::HandleProcTriggerSpell(Unit* victim, uint32 damage, AuraEffect* trigg
// Blade Barrier
if (auraSpellInfo->SpellFamilyName == SPELLFAMILY_DEATHKNIGHT && auraSpellInfo->SpellIconID == 85)
{
- Player* plr = ToPlayer();
- if (!plr || plr->getClass() != CLASS_DEATH_KNIGHT)
+ Player* player = ToPlayer();
+ if (!player || player->getClass() != CLASS_DEATH_KNIGHT)
return false;
- if (!plr->IsBaseRuneSlotsOnCooldown(RUNE_BLOOD))
+ if (!player->IsBaseRuneSlotsOnCooldown(RUNE_BLOOD))
return false;
}
@@ -10123,20 +10142,20 @@ Unit* Unit::GetNextRandomRaidMemberOrPet(float radius)
// only called in Player::SetSeer
// so move it to Player?
-void Unit::AddPlayerToVision(Player* plr)
+void Unit::AddPlayerToVision(Player* player)
{
if (m_sharedVision.empty())
{
setActive(true);
SetWorldObject(true);
}
- m_sharedVision.push_back(plr);
+ m_sharedVision.push_back(player);
}
// only called in Player::SetSeer
-void Unit::RemovePlayerFromVision(Player* plr)
+void Unit::RemovePlayerFromVision(Player* player)
{
- m_sharedVision.remove(plr);
+ m_sharedVision.remove(player);
if (m_sharedVision.empty())
{
setActive(false);
@@ -10592,11 +10611,6 @@ uint32 Unit::SpellDamageBonus(Unit* victim, SpellInfo const* spellProto, uint32
AddPctF(TakenTotalMod, std::max(mod, float((*i)->GetAmount())));
}
break;
- // Ebon Plague
- case 1933:
- if ((*i)->GetMiscValue() & (spellProto ? spellProto->GetSchoolMask() : 0))
- AddPctN(TakenTotalMod, (*i)->GetAmount());
- break;
}
}
@@ -10879,12 +10893,6 @@ bool Unit::isSpellCrit(Unit* victim, SpellInfo const* spellProto, SpellSchoolMas
if (victim->HasAura(6788))
crit_chance+=(*i)->GetAmount();
break;
- case 21: // Test of Faith
- case 6935:
- case 6918:
- if (victim->HealthBelowPct(50))
- crit_chance+=(*i)->GetAmount();
- break;
default:
break;
}
@@ -11109,11 +11117,6 @@ uint32 Unit::SpellHealingBonus(Unit* victim, SpellInfo const* spellProto, uint32
case 3736: // Hateful Totem of the Third Wind / Increased Lesser Healing Wave / LK Arena (4/5/6) Totem of the Third Wind / Savage Totem of the Third Wind
DoneTotal += (*i)->GetAmount();
break;
- case 7997: // Renewed Hope
- case 7998:
- if (victim->HasAura(6788))
- AddPctN(DoneTotalMod, (*i)->GetAmount());
- break;
case 21: // Test of Faith
case 6935:
case 6918:
@@ -11738,23 +11741,6 @@ void Unit::MeleeDamageBonus(Unit* victim, uint32 *pdamage, WeaponAttackType attT
AddPctF(TakenTotalMod, std::max(mod, float((*i)->GetAmount())));
}
break;
- // Blessing of Sanctuary
- // Greater Blessing of Sanctuary
- case 19:
- case 1804:
- {
- if ((*i)->GetSpellInfo()->SpellFamilyName != SPELLFAMILY_PALADIN)
- continue;
-
- if ((*i)->GetMiscValue() & (spellProto ? spellProto->GetSchoolMask() : 0))
- AddPctN(TakenTotalMod, (*i)->GetAmount());
- break;
- }
- // Ebon Plague
- case 1933:
- if ((*i)->GetMiscValue() & (spellProto ? spellProto->GetSchoolMask() : 0))
- AddPctN(TakenTotalMod, (*i)->GetAmount());
- break;
}
}
@@ -11878,7 +11864,7 @@ void Unit::Mount(uint32 mount, uint32 VehicleId, uint32 creatureEntry)
SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_MOUNT);
- if (Player* plr = ToPlayer())
+ if (Player* player = ToPlayer())
{
// mount as a vehicle
if (VehicleId)
@@ -11894,7 +11880,7 @@ void Unit::Mount(uint32 mount, uint32 VehicleId, uint32 creatureEntry)
SendMessageToSet(&data, true);
data.Initialize(SMSG_ON_CANCEL_EXPECTED_RIDE_VEHICLE_AURA, 0);
- plr->GetSession()->SendPacket(&data);
+ player->GetSession()->SendPacket(&data);
// mounts can also have accessories
GetVehicleKit()->InstallAllAccessories(false);
@@ -11902,7 +11888,7 @@ void Unit::Mount(uint32 mount, uint32 VehicleId, uint32 creatureEntry)
}
// unsummon pet
- Pet* pet = plr->GetPet();
+ Pet* pet = player->GetPet();
if (pet)
{
Battleground* bg = ToPlayer()->GetBattleground();
@@ -11910,8 +11896,14 @@ void Unit::Mount(uint32 mount, uint32 VehicleId, uint32 creatureEntry)
if (bg && bg->isArena())
pet->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_STUNNED);
else
- plr->UnsummonPetTemporaryIfAny();
+ player->UnsummonPetTemporaryIfAny();
}
+
+ WorldPacket data(SMSG_MOVE_SET_COLLISION_HGT, GetPackGUID().size() + 4 + 4);
+ data.append(GetPackGUID());
+ data << uint32(sWorld->GetGameTime()); // Packet counter
+ data << player->GetCollisionHeight(true);
+ player->GetSession()->SendPacket(&data);
}
RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_MOUNT);
@@ -11925,6 +11917,15 @@ void Unit::Unmount()
SetUInt32Value(UNIT_FIELD_MOUNTDISPLAYID, 0);
RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_MOUNT);
+ if (Player* thisPlayer = ToPlayer())
+ {
+ WorldPacket data(SMSG_MOVE_SET_COLLISION_HGT, GetPackGUID().size() + 4 + 4);
+ data.append(GetPackGUID());
+ data << uint32(sWorld->GetGameTime()); // Packet counter
+ data << thisPlayer->GetCollisionHeight(false);
+ thisPlayer->GetSession()->SendPacket(&data);
+ }
+
WorldPacket data(SMSG_DISMOUNT, 8);
data.appendPackGUID(GetGUID());
SendMessageToSet(&data, true);
@@ -11933,7 +11934,7 @@ void Unit::Unmount()
if (GetTypeId() == TYPEID_PLAYER && GetVehicleKit())
{
// Send other players that we are no longer a vehicle
- WorldPacket data(SMSG_PLAYER_VEHICLE_DATA, 8+4);
+ data.Initialize(SMSG_PLAYER_VEHICLE_DATA, 8+4);
data.appendPackGUID(GetGUID());
data << uint32(0);
ToPlayer()->SendMessageToSet(&data, true);
@@ -11946,15 +11947,15 @@ void Unit::Unmount()
// only resummon old pet if the player is already added to a map
// this prevents adding a pet to a not created map which would otherwise cause a crash
// (it could probably happen when logging in after a previous crash)
- if (Player* plr = ToPlayer())
+ if (Player* player = ToPlayer())
{
- if (Pet* pPet = plr->GetPet())
+ if (Pet* pPet = player->GetPet())
{
if (pPet->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_STUNNED) && !pPet->HasUnitState(UNIT_STAT_STUNNED))
pPet->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_STUNNED);
}
else
- plr->ResummonPetTemporaryUnSummonedIfAny();
+ player->ResummonPetTemporaryUnSummonedIfAny();
}
}
@@ -13028,16 +13029,16 @@ int32 Unit::CalcSpellDuration(SpellInfo const* spellProto)
return duration;
}
-int32 Unit::ModSpellDuration(SpellInfo const* spellProto, Unit const* target, int32 duration, bool positive)
+int32 Unit::ModSpellDuration(SpellInfo const* spellProto, Unit const* target, int32 duration, bool positive, uint32 effectMask)
{
- // don't mod permament auras duration
+ // don't mod permanent auras duration
if (duration < 0)
return duration;
// cut duration only of negative effects
if (!positive)
{
- int32 mechanic = spellProto->GetAllEffectsMechanicMask();
+ int32 mechanic = spellProto->GetSpellMechanicMaskByEffectMask(effectMask);
int32 durationMod;
int32 durationMod_always = 0;
@@ -13540,10 +13541,10 @@ void Unit::SetHealth(uint32 val)
SetUInt32Value(UNIT_FIELD_HEALTH, val);
// group update
- if (Player* plr = ToPlayer())
+ if (Player* player = ToPlayer())
{
- if (plr->GetGroup())
- plr->SetGroupUpdateFlag(GROUP_UPDATE_FLAG_CUR_HP);
+ if (player->GetGroup())
+ player->SetGroupUpdateFlag(GROUP_UPDATE_FLAG_CUR_HP);
}
else if (Pet* pet = ToCreature()->ToPet())
{
@@ -14315,7 +14316,7 @@ void Unit::ProcDamageAndSpellFor(bool isVictim, Unit* target, uint32 procFlag, u
}
if (!handled)
- for (uint8 effIndex = 0; effIndex<MAX_SPELL_EFFECTS; ++effIndex)
+ for (uint8 effIndex = 0; effIndex < MAX_SPELL_EFFECTS; ++effIndex)
{
if (!(i->effMask & (1<<effIndex)))
continue;
@@ -14335,10 +14336,14 @@ void Unit::ProcDamageAndSpellFor(bool isVictim, Unit* target, uint32 procFlag, u
}
case SPELL_AURA_PROC_TRIGGER_DAMAGE:
{
+ // target has to be valid
+ if (!target)
+ return;
+
sLog->outDebug(LOG_FILTER_SPELLS_AURAS, "ProcDamageAndSpell: doing %u damage from spell id %u (triggered by %s aura of spell %u)", triggeredByAura->GetAmount(), spellInfo->Id, (isVictim?"a victim's":"an attacker's"), triggeredByAura->GetId());
SpellNonMeleeDamage damageInfo(this, target, spellInfo->Id, spellInfo->SchoolMask);
- uint32 damage = SpellDamageBonus(target, spellInfo, triggeredByAura->GetAmount(), SPELL_DIRECT_DAMAGE);
- CalculateSpellDamageTaken(&damageInfo, damage, spellInfo);
+ uint32 newDamage = SpellDamageBonus(target, spellInfo, triggeredByAura->GetAmount(), SPELL_DIRECT_DAMAGE);
+ CalculateSpellDamageTaken(&damageInfo, newDamage, spellInfo);
DealDamageMods(damageInfo.target, damageInfo.damage, &damageInfo.absorb);
SendSpellNonMeleeDamageLog(&damageInfo);
DealSpellDamage(&damageInfo, true);
@@ -14752,9 +14757,9 @@ void Unit::ClearComboPointHolders()
{
uint32 lowguid = *m_ComboPointHolders.begin();
- Player* plr = ObjectAccessor::FindPlayer(MAKE_NEW_GUID(lowguid, 0, HIGHGUID_PLAYER));
- if (plr && plr->GetComboTarget() == GetGUID()) // recheck for safe
- plr->ClearComboPoints(); // remove also guid from m_ComboPointHolders;
+ Player* player = ObjectAccessor::FindPlayer(MAKE_NEW_GUID(lowguid, 0, HIGHGUID_PLAYER));
+ if (player && player->GetComboTarget() == GetGUID()) // recheck for safe
+ player->ClearComboPoints(); // remove also guid from m_ComboPointHolders;
else
m_ComboPointHolders.erase(lowguid); // or remove manually
}
@@ -15321,9 +15326,9 @@ void Unit::Kill(Unit* victim, bool durabilityLoss)
return;
// Inform pets (if any) when player kills target)
- if (Player* plr = ToPlayer())
+ if (Player* player = ToPlayer())
{
- Pet* pet = plr->GetPet();
+ Pet* pet = player->GetPet();
if (pet && pet->isAlive() && pet->isControlled())
pet->AI()->KilledUnit(victim);
}
@@ -15618,6 +15623,9 @@ void Unit::SetControlled(bool apply, UnitState state)
case UNIT_STAT_CONFUSED:
if (!HasUnitState(UNIT_STAT_STUNNED))
{
+ ClearUnitState(UNIT_STAT_MELEE_ATTACKING);
+ SendMeleeAttackStop();
+ // SendAutoRepeatCancel ?
SetConfused(true);
CastStop();
}
@@ -15625,6 +15633,9 @@ void Unit::SetControlled(bool apply, UnitState state)
case UNIT_STAT_FLEEING:
if (!HasUnitState(UNIT_STAT_STUNNED | UNIT_STAT_CONFUSED))
{
+ ClearUnitState(UNIT_STAT_MELEE_ATTACKING);
+ SendMeleeAttackStop();
+ // SendAutoRepeatCancel ?
SetFeared(true);
CastStop();
}
@@ -15895,10 +15906,10 @@ bool Unit::SetCharmedBy(Unit* charmer, CharmType type, AuraApplication const* au
}
else
{
- Player* plr = ToPlayer();
- if (plr->isAFK())
- plr->ToggleAFK();
- plr->SetClientControl(this, 0);
+ Player* player = ToPlayer();
+ if (player->isAFK())
+ player->ToggleAFK();
+ player->SetClientControl(this, 0);
}
// charm is set by aura, and aura effect remove handler was called during apply handler execution
@@ -16542,10 +16553,9 @@ float Unit::GetCombatRatingReduction(CombatRating cr) const
if (Player const* player = ToPlayer())
return player->GetRatingBonusValue(cr);
// Player's pet get resilience from owner
- else if (isPet())
- if (Unit* owner = GetOwner())
- if (Player* player = owner->ToPlayer())
- return player->GetRatingBonusValue(cr);
+ else if (isPet() && GetOwner())
+ if (Player* owner = GetOwner()->ToPlayer())
+ return owner->GetRatingBonusValue(cr);
return 0.0f;
}
@@ -16961,25 +16971,25 @@ void Unit::_EnterVehicle(Vehicle* vehicle, int8 seatId, AuraApplication const* a
if (aurApp && aurApp->GetRemoveMode())
return;
- if (Player* plr = ToPlayer())
+ if (Player* player = ToPlayer())
{
- if (vehicle->GetBase()->GetTypeId() == TYPEID_PLAYER && plr->isInCombat())
+ if (vehicle->GetBase()->GetTypeId() == TYPEID_PLAYER && player->isInCombat())
return;
InterruptNonMeleeSpells(false);
- plr->StopCastingCharm();
- plr->StopCastingBindSight();
+ player->StopCastingCharm();
+ player->StopCastingBindSight();
Unmount();
RemoveAurasByType(SPELL_AURA_MOUNTED);
// drop flag at invisible in bg
- if (Battleground* bg = plr->GetBattleground())
- bg->EventPlayerDroppedFlag(plr);
+ if (Battleground* bg = player->GetBattleground())
+ bg->EventPlayerDroppedFlag(player);
WorldPacket data(SMSG_ON_CANCEL_EXPECTED_RIDE_VEHICLE_AURA, 0);
- plr->GetSession()->SendPacket(&data);
+ player->GetSession()->SendPacket(&data);
- plr->UnsummonPetTemporaryIfAny();
+ player->UnsummonPetTemporaryIfAny();
}
ASSERT(!m_vehicle);
@@ -17053,8 +17063,8 @@ void Unit::_ExitVehicle(Position const* exitPosition)
SendMonsterMoveExitVehicle(&pos);
Relocate(&pos);
- if (Player* plr = ToPlayer())
- plr->ResummonPetTemporaryUnSummonedIfAny();
+ if (Player* player = ToPlayer())
+ player->ResummonPetTemporaryUnSummonedIfAny();
WorldPacket data2;
BuildHeartBeatMsg(&data2);
@@ -17369,7 +17379,7 @@ uint32 Unit::GetRemainingPeriodicAmount(uint64 caster, uint32 spellId, AuraType
AuraEffectList const& periodicAuras = GetAuraEffectsByType(auraType);
for (AuraEffectList::const_iterator i = periodicAuras.begin(); i != periodicAuras.end(); ++i)
{
- if ((*i)->GetCasterGUID() != caster || (*i)->GetId() != spellId || (*i)->GetEffIndex() != effectIndex || (*i)->GetTotalTicks() == 0)
+ if ((*i)->GetCasterGUID() != caster || (*i)->GetId() != spellId || (*i)->GetEffIndex() != effectIndex || !(*i)->GetTotalTicks())
continue;
amount += uint32(((*i)->GetAmount() * std::max<int32>((*i)->GetTotalTicks() - int32((*i)->GetTickNumber()), 0)) / (*i)->GetTotalTicks());
break;
@@ -17385,6 +17395,17 @@ void Unit::SendClearTarget()
SendMessageToSet(&data, false);
}
+uint32 Unit::GetResistance(SpellSchoolMask mask) const
+{
+ int32 resist = -1;
+ for (int i = SPELL_SCHOOL_NORMAL; i < MAX_SPELL_SCHOOL; ++i)
+ if (mask & (1 << i) && (resist < 0 || resist > int32(GetResistance(SpellSchools(i)))))
+ resist = int32(GetResistance(SpellSchools(i)));
+
+ // resist value will never be negative here
+ return uint32(resist);
+}
+
void CharmInfo::SetIsCommandAttack(bool val)
{
m_isCommandAttack = val;
diff --git a/src/server/game/Entities/Unit/Unit.h b/src/server/game/Entities/Unit/Unit.h
index d35298b9963..5906a7f3a2b 100755
--- a/src/server/game/Entities/Unit/Unit.h
+++ b/src/server/game/Entities/Unit/Unit.h
@@ -44,8 +44,8 @@ enum SpellInterruptFlags
{
SPELL_INTERRUPT_FLAG_MOVEMENT = 0x01, // why need this for instant?
SPELL_INTERRUPT_FLAG_PUSH_BACK = 0x02, // push back
- SPELL_INTERRUPT_FLAG_INTERRUPT = 0x04, // interrupt
- SPELL_INTERRUPT_FLAG_AUTOATTACK = 0x08, // enter combat
+ SPELL_INTERRUPT_FLAG_UNK3 = 0x04, // any info?
+ SPELL_INTERRUPT_FLAG_INTERRUPT = 0x08, // interrupt
SPELL_INTERRUPT_FLAG_ABORT_ON_DMG = 0x10, // _complete_ interrupt on direct damage
//SPELL_INTERRUPT_UNK = 0x20 // unk, 564 of 727 spells having this spell start with "Glyph"
};
@@ -53,7 +53,8 @@ enum SpellInterruptFlags
// See SpellAuraInterruptFlags for other values definitions
enum SpellChannelInterruptFlags
{
- CHANNEL_FLAG_DELAY = 0x4000
+ CHANNEL_INTERRUPT_FLAG_INTERRUPT = 0x08, // interrupt
+ CHANNEL_FLAG_DELAY = 0x4000
};
enum SpellAuraInterruptFlags
@@ -1007,8 +1008,8 @@ enum CurrentSpellTypes
{
CURRENT_MELEE_SPELL = 0,
CURRENT_GENERIC_SPELL = 1,
- CURRENT_AUTOREPEAT_SPELL = 2,
- CURRENT_CHANNELED_SPELL = 3
+ CURRENT_CHANNELED_SPELL = 2,
+ CURRENT_AUTOREPEAT_SPELL = 3
};
#define CURRENT_FIRST_NON_MELEE_SPELL 1
@@ -1208,6 +1209,8 @@ enum ReactiveType
#define SUMMON_SLOT_QUEST 6
#define MAX_SUMMON_SLOT 7
+#define MAX_GAMEOBJECT_SLOT 4
+
enum PlayerTotemType
{
SUMMON_TYPE_TOTEM_FIRE = 63,
@@ -1307,7 +1310,7 @@ class Unit : public WorldObject
void CombatStopWithPets(bool includingCast = false);
void StopAttackFaction(uint32 faction_id);
Unit* SelectNearbyTarget(float dist = NOMINAL_MELEE_RANGE) const;
- void SendMeleeAttackStop(Unit* victim);
+ void SendMeleeAttackStop(Unit* victim = NULL);
void SendMeleeAttackStart(Unit* pVictim);
void AddUnitState(uint32 f) { m_state |= f; }
@@ -1343,6 +1346,7 @@ class Unit : public WorldObject
void SetArmor(int32 val) { SetResistance(SPELL_SCHOOL_NORMAL, val); }
uint32 GetResistance(SpellSchools school) const { return GetUInt32Value(UNIT_FIELD_RESISTANCES+school); }
+ uint32 GetResistance(SpellSchoolMask mask) const;
void SetResistance(SpellSchools school, int32 val) { SetStatInt32Value(UNIT_FIELD_RESISTANCES+school, val); }
uint32 GetHealth() const { return GetUInt32Value(UNIT_FIELD_HEALTH); }
@@ -1503,6 +1507,20 @@ class Unit : public WorldObject
}
virtual uint32 GetShieldBlockValue() const =0;
+ uint32 GetShieldBlockValue(uint32 soft_cap, uint32 hard_cap) const
+ {
+ uint32 value = GetShieldBlockValue();
+ if (value >= hard_cap)
+ {
+ value = (soft_cap + hard_cap) / 2;
+ }
+ else if (value > soft_cap)
+ {
+ value = soft_cap + ((value - soft_cap) / 2);
+ }
+
+ return value;
+ }
uint32 GetUnitMeleeSkill(Unit const* target = NULL) const { return (target ? getLevelForTarget(target) : getLevel()) * 5; }
uint32 GetDefenseSkillValue(Unit const* target = NULL) const;
uint32 GetWeaponSkillValue(WeaponAttackType attType, Unit const* target = NULL) const;
@@ -1713,8 +1731,8 @@ class Unit : public WorldObject
//Player* GetMoverSource() const;
Player* m_movedPlayer;
SharedVisionList const& GetSharedVisionList() { return m_sharedVision; }
- void AddPlayerToVision(Player* plr);
- void RemovePlayerFromVision(Player* plr);
+ void AddPlayerToVision(Player* player);
+ void RemovePlayerFromVision(Player* player);
bool HasSharedVision() const { return !m_sharedVision.empty(); }
void RemoveBindSightAuras();
void RemoveCharmAuras();
@@ -1741,7 +1759,7 @@ class Unit : public WorldObject
AuraMap const& GetOwnedAuras() const { return m_ownedAuras; }
void RemoveOwnedAura(AuraMap::iterator &i, AuraRemoveMode removeMode = AURA_REMOVE_BY_DEFAULT);
- void RemoveOwnedAura(uint32 spellId, uint64 caster = 0, uint8 reqEffMask = 0, AuraRemoveMode removeMode = AURA_REMOVE_BY_DEFAULT);
+ void RemoveOwnedAura(uint32 spellId, uint64 casterGUID = 0, uint8 reqEffMask = 0, AuraRemoveMode removeMode = AURA_REMOVE_BY_DEFAULT);
void RemoveOwnedAura(Aura* aura, AuraRemoveMode removeMode = AURA_REMOVE_BY_DEFAULT);
Aura* GetOwnedAura(uint32 spellId, uint64 casterGUID = 0, uint64 itemCasterGUID = 0, uint8 reqEffMask = 0, Aura* except = NULL) const;
@@ -1751,12 +1769,12 @@ class Unit : public WorldObject
AuraApplicationMap const& GetAppliedAuras() const { return m_appliedAuras; }
void RemoveAura(AuraApplicationMap::iterator &i, AuraRemoveMode mode = AURA_REMOVE_BY_DEFAULT);
- void RemoveAura(uint32 spellId, uint64 caster = 0, uint8 reqEffMask = 0, AuraRemoveMode removeMode = AURA_REMOVE_BY_DEFAULT);
+ void RemoveAura(uint32 spellId, uint64 casterGUID = 0, uint8 reqEffMask = 0, AuraRemoveMode removeMode = AURA_REMOVE_BY_DEFAULT);
void RemoveAura(AuraApplication * aurApp, AuraRemoveMode mode = AURA_REMOVE_BY_DEFAULT);
void RemoveAura(Aura* aur, AuraRemoveMode mode = AURA_REMOVE_BY_DEFAULT);
- void RemoveAurasDueToSpell(uint32 spellId, uint64 caster = 0, uint8 reqEffMask = 0, AuraRemoveMode removeMode = AURA_REMOVE_BY_DEFAULT);
- void RemoveAuraFromStack(uint32 spellId, uint64 caster = 0, AuraRemoveMode removeMode = AURA_REMOVE_BY_DEFAULT);
+ void RemoveAurasDueToSpell(uint32 spellId, uint64 casterGUID = 0, uint8 reqEffMask = 0, AuraRemoveMode removeMode = AURA_REMOVE_BY_DEFAULT);
+ void RemoveAuraFromStack(uint32 spellId, uint64 casterGUID = 0, AuraRemoveMode removeMode = AURA_REMOVE_BY_DEFAULT);
void RemoveAurasDueToSpellByDispel(uint32 spellId, uint64 casterGUID, Unit* dispeller, uint8 chargesRemoved = 1);
void RemoveAurasDueToSpellBySteal(uint32 spellId, uint64 casterGUID, Unit* stealer);
void RemoveAurasDueToItemSpell(Item* castItem, uint32 spellId);
@@ -1877,7 +1895,7 @@ class Unit : public WorldObject
uint32 m_addDmgOnce;
uint64 m_SummonSlot[MAX_SUMMON_SLOT];
- uint64 m_ObjectSlot[4];
+ uint64 m_ObjectSlot[MAX_GAMEOBJECT_SLOT];
ShapeshiftForm GetShapeshiftForm() const { return ShapeshiftForm(GetByteValue(UNIT_FIELD_BYTES_2, 3)); }
void SetShapeshiftForm(ShapeshiftForm form)
@@ -2054,7 +2072,7 @@ class Unit : public WorldObject
float ApplyEffectModifiers(SpellInfo const* spellProto, uint8 effect_index, float value) const;
int32 CalculateSpellDamage(Unit const* target, SpellInfo const* spellProto, uint8 effect_index, int32 const* basePoints = NULL) const;
int32 CalcSpellDuration(SpellInfo const* spellProto);
- int32 ModSpellDuration(SpellInfo const* spellProto, Unit const* target, int32 duration, bool positive);
+ int32 ModSpellDuration(SpellInfo const* spellProto, Unit const* target, int32 duration, bool positive, uint32 effectMask);
void ModSpellCastTime(SpellInfo const* spellProto, int32 & castTime, Spell* spell=NULL);
float CalculateLevelPenalty(SpellInfo const* spellProto) const;
diff --git a/src/server/game/Entities/Vehicle/Vehicle.cpp b/src/server/game/Entities/Vehicle/Vehicle.cpp
index 107e275d47b..fe018ec78ce 100755
--- a/src/server/game/Entities/Vehicle/Vehicle.cpp
+++ b/src/server/game/Entities/Vehicle/Vehicle.cpp
@@ -172,8 +172,12 @@ void Vehicle::ApplyAllImmunities()
// Different immunities for vehicles goes below
switch (GetVehicleInfo()->m_ID)
{
- case 160:
+ // code below prevents a bug with movable cannons
+ case 160: // Strand of the Ancients
+ case 244: // Wintergrasp
+ case 510: // Isle of Conquest
_me->SetControlled(true, UNIT_STAT_ROOT);
+ // why we need to apply this? we can simple add immunities to slow mechanic in DB
_me->ApplySpellImmune(0, IMMUNITY_STATE, SPELL_AURA_MOD_DECREASE_SPEED, true);
break;
default:
diff --git a/src/server/game/Events/GameEventMgr.cpp b/src/server/game/Events/GameEventMgr.cpp
index cb42b898406..dbcb07e88f5 100755
--- a/src/server/game/Events/GameEventMgr.cpp
+++ b/src/server/game/Events/GameEventMgr.cpp
@@ -1170,9 +1170,9 @@ void GameEventMgr::GameEventSpawn(int16 event_id)
sObjectMgr->AddCreatureToGrid(*itr, data);
// Spawn if necessary (loaded grids only)
- Map* map = const_cast<Map*>(sMapMgr->CreateBaseMap(data->mapid));
+ Map* map = sMapMgr->CreateBaseMap(data->mapid);
// We use spawn coords to spawn
- if (!map->Instanceable() && map->IsLoaded(data->posX, data->posY))
+ if (!map->Instanceable() && map->IsGridLoaded(data->posX, data->posY))
{
Creature* creature = new Creature;
//sLog->outDebug("Spawning creature %u", *itr);
@@ -1199,9 +1199,9 @@ void GameEventMgr::GameEventSpawn(int16 event_id)
sObjectMgr->AddGameobjectToGrid(*itr, data);
// Spawn if necessary (loaded grids only)
// this base map checked as non-instanced and then only existed
- Map* map = const_cast<Map*>(sMapMgr->CreateBaseMap(data->mapid));
+ Map* map = sMapMgr->CreateBaseMap(data->mapid);
// We use current coords to unspawn, not spawn coords since creature can have changed grid
- if (!map->Instanceable() && map->IsLoaded(data->posX, data->posY))
+ if (!map->Instanceable() && map->IsGridLoaded(data->posX, data->posY))
{
GameObject* pGameobject = new GameObject;
//sLog->outDebug("Spawning gameobject %u", *itr);
@@ -1590,15 +1590,15 @@ void GameEventMgr::SaveWorldEventStateToDB(uint16 event_id)
CharacterDatabase.CommitTransaction(trans);
}
-void GameEventMgr::SendWorldStateUpdate(Player* plr, uint16 event_id)
+void GameEventMgr::SendWorldStateUpdate(Player* player, uint16 event_id)
{
GameEventConditionMap::const_iterator itr;
for (itr = mGameEvent[event_id].conditions.begin(); itr !=mGameEvent[event_id].conditions.end(); ++itr)
{
if (itr->second.done_world_state)
- plr->SendUpdateWorldState(itr->second.done_world_state, (uint32)(itr->second.done));
+ player->SendUpdateWorldState(itr->second.done_world_state, (uint32)(itr->second.done));
if (itr->second.max_world_state)
- plr->SendUpdateWorldState(itr->second.max_world_state, (uint32)(itr->second.reqNum));
+ player->SendUpdateWorldState(itr->second.max_world_state, (uint32)(itr->second.reqNum));
}
}
diff --git a/src/server/game/Events/GameEventMgr.h b/src/server/game/Events/GameEventMgr.h
index 7337110fd65..a2a35a85098 100755
--- a/src/server/game/Events/GameEventMgr.h
+++ b/src/server/game/Events/GameEventMgr.h
@@ -115,11 +115,11 @@ class GameEventMgr
bool StartEvent(uint16 event_id, bool overwrite = false);
void StopEvent(uint16 event_id, bool overwrite = false);
void HandleQuestComplete(uint32 quest_id); // called on world event type quest completions
- void HandleWorldEventGossip(Player* plr, Creature* c);
+ void HandleWorldEventGossip(Player* player, Creature* c);
uint32 GetNPCFlag(Creature* cr);
uint32 GetNpcTextId(uint32 guid);
private:
- void SendWorldStateUpdate(Player* plr, uint16 event_id);
+ void SendWorldStateUpdate(Player* player, uint16 event_id);
void AddActiveEvent(uint16 event_id) { m_ActiveEvents.insert(event_id); }
void RemoveActiveEvent(uint16 event_id) { m_ActiveEvents.erase(event_id); }
void ApplyNewEvent(uint16 event_id);
diff --git a/src/server/game/Globals/ObjectAccessor.cpp b/src/server/game/Globals/ObjectAccessor.cpp
index f98702d4393..82532e6ae29 100755
--- a/src/server/game/Globals/ObjectAccessor.cpp
+++ b/src/server/game/Globals/ObjectAccessor.cpp
@@ -165,9 +165,9 @@ Unit* ObjectAccessor::FindUnit(uint64 guid)
Player* ObjectAccessor::FindPlayerByName(const char* name)
{
- ACE_GUARD_RETURN(LockType, g, *HashMapHolder<Player>::GetLock(), NULL);
- HashMapHolder<Player>::MapType& m = HashMapHolder<Player>::GetContainer();
- for (HashMapHolder<Player>::MapType::iterator iter = m.begin(); iter != m.end(); ++iter)
+ TRINITY_READ_GUARD(HashMapHolder<Player>::LockType, *HashMapHolder<Player>::GetLock());
+ HashMapHolder<Player>::MapType const& m = GetPlayers();
+ for (HashMapHolder<Player>::MapType::const_iterator iter = m.begin(); iter != m.end(); ++iter)
if (iter->second->IsInWorld() && strcmp(name, iter->second->GetName()) == 0)
return iter->second;
@@ -176,15 +176,15 @@ Player* ObjectAccessor::FindPlayerByName(const char* name)
void ObjectAccessor::SaveAllPlayers()
{
- ACE_GUARD(LockType, g, *HashMapHolder<Player>::GetLock());
- HashMapHolder<Player>::MapType& m = HashMapHolder<Player>::GetContainer();
- for (HashMapHolder<Player>::MapType::iterator itr = m.begin(); itr != m.end(); ++itr)
+ TRINITY_READ_GUARD(HashMapHolder<Player>::LockType, *HashMapHolder<Player>::GetLock());
+ HashMapHolder<Player>::MapType const& m = GetPlayers();
+ for (HashMapHolder<Player>::MapType::const_iterator itr = m.begin(); itr != m.end(); ++itr)
itr->second->SaveToDB();
}
Corpse* ObjectAccessor::GetCorpseForPlayerGUID(uint64 guid)
{
- ACE_GUARD_RETURN(LockType, guard, i_corpseGuard, NULL);
+ TRINITY_READ_GUARD(ACE_RW_Thread_Mutex, i_corpseLock);
Player2CorpsesMapType::iterator iter = i_player2corpse.find(guid);
if (iter == i_player2corpse.end())
@@ -199,25 +199,33 @@ void ObjectAccessor::RemoveCorpse(Corpse* corpse)
{
ASSERT(corpse && corpse->GetType() != CORPSE_BONES);
+ //TODO: more works need to be done for corpse and other world object
if (Map* map = corpse->FindMap())
{
corpse->DestroyForNearbyPlayers();
- map->RemoveFromMap(corpse, false);
+ if (corpse->IsInGrid())
+ map->RemoveFromMap(corpse, false);
+ else
+ {
+ corpse->RemoveFromWorld();
+ corpse->ResetMap();
+ }
}
else
+
corpse->RemoveFromWorld();
// Critical section
{
- ACE_GUARD(LockType, g, i_corpseGuard);
+ TRINITY_WRITE_GUARD(ACE_RW_Thread_Mutex, i_corpseLock);
Player2CorpsesMapType::iterator iter = i_player2corpse.find(corpse->GetOwnerGUID());
if (iter == i_player2corpse.end()) // TODO: Fix this
return;
// build mapid*cellid -> guid_set map
- CellPair cell_pair = Trinity::ComputeCellPair(corpse->GetPositionX(), corpse->GetPositionY());
- uint32 cell_id = (cell_pair.y_coord * TOTAL_NUMBER_OF_CELLS_PER_MAP) + cell_pair.x_coord;
+ CellCoord cellCoord = Trinity::ComputeCellCoord(corpse->GetPositionX(), corpse->GetPositionY());
+ uint32 cell_id = (cellCoord.y_coord * TOTAL_NUMBER_OF_CELLS_PER_MAP) + cellCoord.x_coord;
sObjectMgr->DeleteCorpseCellData(corpse->GetMapId(), cell_id, GUID_LOPART(corpse->GetOwnerGUID()));
@@ -231,26 +239,30 @@ void ObjectAccessor::AddCorpse(Corpse* corpse)
// Critical section
{
- ACE_GUARD(LockType, g, i_corpseGuard);
+ TRINITY_WRITE_GUARD(ACE_RW_Thread_Mutex, i_corpseLock);
ASSERT(i_player2corpse.find(corpse->GetOwnerGUID()) == i_player2corpse.end());
i_player2corpse[corpse->GetOwnerGUID()] = corpse;
// build mapid*cellid -> guid_set map
- CellPair cell_pair = Trinity::ComputeCellPair(corpse->GetPositionX(), corpse->GetPositionY());
- uint32 cell_id = (cell_pair.y_coord * TOTAL_NUMBER_OF_CELLS_PER_MAP) + cell_pair.x_coord;
+ CellCoord cellCoord = Trinity::ComputeCellCoord(corpse->GetPositionX(), corpse->GetPositionY());
+ uint32 cell_id = (cellCoord.y_coord * TOTAL_NUMBER_OF_CELLS_PER_MAP) + cellCoord.x_coord;
sObjectMgr->AddCorpseCellData(corpse->GetMapId(), cell_id, GUID_LOPART(corpse->GetOwnerGUID()), corpse->GetInstanceId());
}
}
-void ObjectAccessor::AddCorpsesToGrid(GridPair const& gridpair, GridType& grid, Map* map)
+void ObjectAccessor::AddCorpsesToGrid(GridCoord const& gridpair, GridType& grid, Map* map)
{
- ACE_GUARD(LockType, g, i_corpseGuard);
+ TRINITY_READ_GUARD(ACE_RW_Thread_Mutex, i_corpseLock);
for (Player2CorpsesMapType::iterator iter = i_player2corpse.begin(); iter != i_player2corpse.end(); ++iter)
{
- if (iter->second->GetGrid() == gridpair)
+ // We need this check otherwise a corpose may be added to a grid twice
+ if (iter->second->IsInGrid())
+ continue;
+
+ if (iter->second->GetGridCoord() == gridpair)
{
// verify, if the corpse in our instance (add only corpses which are)
if (map->Instanceable())
@@ -281,6 +293,7 @@ Corpse* ObjectAccessor::ConvertCorpseForPlayer(uint64 player_guid, bool insignia
// remove corpse from player_guid -> corpse map and from current map
RemoveCorpse(corpse);
+
// remove corpse from DB
SQLTransaction trans = CharacterDatabase.BeginTransaction();
corpse->DeleteFromDB(trans);
@@ -301,7 +314,7 @@ Corpse* ObjectAccessor::ConvertCorpseForPlayer(uint64 player_guid, bool insignia
for (uint8 i = OBJECT_FIELD_TYPE + 1; i < CORPSE_END; ++i) // don't overwrite guid and object type
bones->SetUInt32Value(i, corpse->GetUInt32Value(i));
- bones->SetGrid(corpse->GetGrid());
+ bones->SetGridCoord(corpse->GetGridCoord());
// bones->m_time = m_time; // don't overwrite time
// bones->m_type = m_type; // don't overwrite type
bones->Relocate(corpse->GetPositionX(), corpse->GetPositionY(), corpse->GetPositionZ(), corpse->GetOrientation());
@@ -346,17 +359,12 @@ void ObjectAccessor::Update(uint32 /*diff*/)
{
UpdateDataMapType update_players;
- // Critical section
+ while (!i_objects.empty())
{
- ACE_GUARD(LockType, g, i_updateGuard);
-
- while (!i_objects.empty())
- {
- Object* obj = *i_objects.begin();
- ASSERT(obj && obj->IsInWorld());
- i_objects.erase(i_objects.begin());
- obj->BuildUpdate(update_players);
- }
+ Object* obj = *i_objects.begin();
+ ASSERT(obj && obj->IsInWorld());
+ i_objects.erase(i_objects.begin());
+ obj->BuildUpdate(update_players);
}
WorldPacket packet; // here we allocate a std::vector with a size of 0x10000
@@ -380,7 +388,7 @@ void ObjectAccessor::UnloadAll()
/// Define the static members of HashMapHolder
template <class T> UNORDERED_MAP< uint64, T* > HashMapHolder<T>::m_objectMap;
-template <class T> ACE_Thread_Mutex HashMapHolder<T>::i_lock;
+template <class T> typename HashMapHolder<T>::LockType HashMapHolder<T>::i_lock;
/// Global definitions for the hashmap storage
diff --git a/src/server/game/Globals/ObjectAccessor.h b/src/server/game/Globals/ObjectAccessor.h
index a9be8b4971f..25fa20dce70 100755
--- a/src/server/game/Globals/ObjectAccessor.h
+++ b/src/server/game/Globals/ObjectAccessor.h
@@ -48,23 +48,23 @@ class HashMapHolder
public:
typedef UNORDERED_MAP<uint64, T*> MapType;
- typedef ACE_Thread_Mutex LockType;
+ typedef ACE_RW_Thread_Mutex LockType;
static void Insert(T* o)
{
- ACE_GUARD(LockType, Guard, i_lock);
+ TRINITY_WRITE_GUARD(LockType, i_lock);
m_objectMap[o->GetGUID()] = o;
}
static void Remove(T* o)
{
- ACE_GUARD(LockType, Guard, i_lock);
+ TRINITY_WRITE_GUARD(LockType, i_lock);
m_objectMap.erase(o->GetGUID());
}
static T* Find(uint64 guid)
{
- ACE_GUARD_RETURN(LockType, Guard, i_lock, NULL);
+ TRINITY_READ_GUARD(LockType, i_lock);
typename MapType::iterator itr = m_objectMap.find(guid);
return (itr != m_objectMap.end()) ? itr->second : NULL;
}
@@ -84,8 +84,7 @@ class HashMapHolder
class ObjectAccessor
{
- friend class ACE_Singleton<ObjectAccessor, ACE_Thread_Mutex>;
- friend class WorldRunnable;
+ friend class ACE_Singleton<ObjectAccessor, ACE_Null_Mutex>;
private:
ObjectAccessor();
~ObjectAccessor();
@@ -93,15 +92,13 @@ class ObjectAccessor
ObjectAccessor& operator=(const ObjectAccessor&);
public:
- typedef UNORDERED_MAP<uint64, Corpse*> Player2CorpsesMapType;
- typedef UNORDERED_MAP<Player*, UpdateData>::value_type UpdateDataValueType;
-
// TODO: override these template functions for each holder type and add assertions
template<class T> static T* GetObjectInOrOutOfWorld(uint64 guid, T* /*typeSpecifier*/)
{
return HashMapHolder<T>::Find(guid);
}
+
static Unit* GetObjectInOrOutOfWorld(uint64 guid, Unit* /*typeSpecifier*/)
{
if (IS_PLAYER_GUID(guid))
@@ -155,15 +152,15 @@ class ObjectAccessor
if (!obj || obj->GetMapId() != mapid)
return NULL;
- CellPair p = Trinity::ComputeCellPair(x, y);
- if (p.x_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP || p.y_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP)
+ CellCoord p = Trinity::ComputeCellCoord(x, y);
+ if (!p.IsCoordValid())
{
sLog->outError("ObjectAccessor::GetObjectInWorld: invalid coordinates supplied X:%f Y:%f grid cell [%u:%u]", x, y, p.x_coord, p.y_coord);
return NULL;
}
- CellPair q = Trinity::ComputeCellPair(obj->GetPositionX(), obj->GetPositionY());
- if (q.x_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP || q.y_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP)
+ CellCoord q = Trinity::ComputeCellCoord(obj->GetPositionX(), obj->GetPositionY());
+ if (!q.IsCoordValid())
{
sLog->outError("ObjectAccessor::GetObjecInWorld: object (GUID: %u TypeId: %u) has invalid coordinates X:%f Y:%f grid cell [%u:%u]", obj->GetGUIDLow(), obj->GetTypeId(), obj->GetPositionX(), obj->GetPositionY(), q.x_coord, q.y_coord);
return NULL;
@@ -195,83 +192,77 @@ class ObjectAccessor
static Pet* FindPet(uint64);
static Player* FindPlayer(uint64);
static Unit* FindUnit(uint64);
- Player* FindPlayerByName(const char* name);
+ static Player* FindPlayerByName(const char* name);
// when using this, you must use the hashmapholder's lock
- HashMapHolder<Player>::MapType& GetPlayers()
+ static HashMapHolder<Player>::MapType const& GetPlayers()
{
return HashMapHolder<Player>::GetContainer();
}
// when using this, you must use the hashmapholder's lock
- HashMapHolder<Creature>::MapType& GetCreatures()
- {
- return HashMapHolder<Creature>::GetContainer();
- }
-
- // when using this, you must use the hashmapholder's lock
- HashMapHolder<GameObject>::MapType& GetGameObjects()
- {
- return HashMapHolder<GameObject>::GetContainer();
- }
-
- template<class T> void AddObject(T* object)
+ //HashMapHolder<Creature>::MapType& GetCreatures()
+ //{
+ // return HashMapHolder<Creature>::GetContainer();
+ //}
+
+ //// when using this, you must use the hashmapholder's lock
+ //HashMapHolder<GameObject>::MapType& GetGameObjects()
+ //{
+ // return HashMapHolder<GameObject>::GetContainer();
+ //}
+
+ template<class T> static void AddObject(T* object)
{
HashMapHolder<T>::Insert(object);
}
- template<class T> void RemoveObject(T* object)
+ template<class T> static void RemoveObject(T* object)
{
HashMapHolder<T>::Remove(object);
}
- void RemoveObject(Player* pl)
- {
- HashMapHolder<Player>::Remove(pl);
- RemoveUpdateObject((Object*)pl);
- }
-
- void SaveAllPlayers();
+ static void SaveAllPlayers();
+ //non-static functions
void AddUpdateObject(Object* obj)
{
- ACE_GUARD(LockType, Guard, i_updateGuard);
+ TRINITY_GUARD(ACE_Thread_Mutex, i_objectLock);
i_objects.insert(obj);
}
void RemoveUpdateObject(Object* obj)
{
- ACE_GUARD(LockType, Guard, i_updateGuard);
+ TRINITY_GUARD(ACE_Thread_Mutex, i_objectLock);
i_objects.erase(obj);
}
- void Update(uint32 diff);
-
+ //Thread safe
Corpse* GetCorpseForPlayerGUID(uint64 guid);
void RemoveCorpse(Corpse* corpse);
void AddCorpse(Corpse* corpse);
- void AddCorpsesToGrid(GridPair const& gridpair, GridType& grid, Map* map);
+ void AddCorpsesToGrid(GridCoord const& gridpair, GridType& grid, Map* map);
Corpse* ConvertCorpseForPlayer(uint64 player_guid, bool insignia = false);
- void RemoveOldCorpses();
-
- typedef ACE_Thread_Mutex LockType;
- protected:
+ //Thread unsafe
+ void Update(uint32 diff);
+ void RemoveOldCorpses();
void UnloadAll();
private:
-
- Player2CorpsesMapType i_player2corpse;
-
static void _buildChangeObjectForPlayer(WorldObject*, UpdateDataMapType&);
static void _buildPacket(Player*, Object*, UpdateDataMapType&);
void _update();
+ typedef UNORDERED_MAP<uint64, Corpse*> Player2CorpsesMapType;
+ typedef UNORDERED_MAP<Player*, UpdateData>::value_type UpdateDataValueType;
+
std::set<Object*> i_objects;
+ Player2CorpsesMapType i_player2corpse;
- LockType i_updateGuard;
- LockType i_corpseGuard;
+ ACE_Thread_Mutex i_objectLock;
+ ACE_RW_Thread_Mutex i_corpseLock;
};
-#define sObjectAccessor ACE_Singleton<ObjectAccessor, ACE_Thread_Mutex>::instance()
+#define sObjectAccessor ACE_Singleton<ObjectAccessor, ACE_Null_Mutex>::instance()
#endif
diff --git a/src/server/game/Globals/ObjectMgr.cpp b/src/server/game/Globals/ObjectMgr.cpp
index ae7e2d57991..6b0601d9663 100755
--- a/src/server/game/Globals/ObjectMgr.cpp
+++ b/src/server/game/Globals/ObjectMgr.cpp
@@ -1568,8 +1568,8 @@ void ObjectMgr::AddCreatureToGrid(uint32 guid, CreatureData const* data)
{
if (mask & 1)
{
- CellPair cell_pair = Trinity::ComputeCellPair(data->posX, data->posY);
- uint32 cell_id = (cell_pair.y_coord*TOTAL_NUMBER_OF_CELLS_PER_MAP) + cell_pair.x_coord;
+ CellCoord cellCoord = Trinity::ComputeCellCoord(data->posX, data->posY);
+ uint32 cell_id = (cellCoord.y_coord*TOTAL_NUMBER_OF_CELLS_PER_MAP) + cellCoord.x_coord;
CellObjectGuids& cell_guids = mMapObjectGuids[MAKE_PAIR32(data->mapid, i)][cell_id];
cell_guids.creatures.insert(guid);
@@ -1584,8 +1584,8 @@ void ObjectMgr::RemoveCreatureFromGrid(uint32 guid, CreatureData const* data)
{
if (mask & 1)
{
- CellPair cell_pair = Trinity::ComputeCellPair(data->posX, data->posY);
- uint32 cell_id = (cell_pair.y_coord*TOTAL_NUMBER_OF_CELLS_PER_MAP) + cell_pair.x_coord;
+ CellCoord cellCoord = Trinity::ComputeCellCoord(data->posX, data->posY);
+ uint32 cell_id = (cellCoord.y_coord*TOTAL_NUMBER_OF_CELLS_PER_MAP) + cellCoord.x_coord;
CellObjectGuids& cell_guids = mMapObjectGuids[MAKE_PAIR32(data->mapid, i)][cell_id];
cell_guids.creatures.erase(guid);
@@ -1599,7 +1599,7 @@ uint32 ObjectMgr::AddGOData(uint32 entry, uint32 mapId, float x, float y, float
if (!goinfo)
return 0;
- Map* map = const_cast<Map*>(sMapMgr->CreateBaseMap(mapId));
+ Map* map = sMapMgr->CreateBaseMap(mapId);
if (!map)
return 0;
@@ -1627,7 +1627,7 @@ uint32 ObjectMgr::AddGOData(uint32 entry, uint32 mapId, float x, float y, float
// Spawn if necessary (loaded grids only)
// We use spawn coords to spawn
- if (!map->Instanceable() && map->IsLoaded(x, y))
+ if (!map->Instanceable() && map->IsGridLoaded(x, y))
{
GameObject* go = new GameObject;
if (!go->LoadFromDB(guid, map))
@@ -1660,10 +1660,10 @@ bool ObjectMgr::MoveCreData(uint32 guid, uint32 mapId, Position pos)
AddCreatureToGrid(guid, &data);
// Spawn if necessary (loaded grids only)
- if (Map* map = const_cast<Map*>(sMapMgr->CreateBaseMap(mapId)))
+ if (Map* map = sMapMgr->CreateBaseMap(mapId))
{
// We use spawn coords to spawn
- if (!map->Instanceable() && map->IsLoaded(data.posX, data.posY))
+ if (!map->Instanceable() && map->IsGridLoaded(data.posX, data.posY))
{
Creature* creature = new Creature;
if (!creature->LoadFromDB(guid, map))
@@ -1713,7 +1713,7 @@ uint32 ObjectMgr::AddCreData(uint32 entry, uint32 /*team*/, uint32 mapId, float
AddCreatureToGrid(guid, &data);
// Spawn if necessary (loaded grids only)
- if (Map* map = const_cast<Map*>(sMapMgr->CreateBaseMap(mapId)))
+ if (Map* map = sMapMgr->CreateBaseMap(mapId))
{
// We use spawn coords to spawn
if (!map->Instanceable() && !map->IsRemovalGrid(x, y))
@@ -1880,8 +1880,8 @@ void ObjectMgr::AddGameobjectToGrid(uint32 guid, GameObjectData const* data)
{
if (mask & 1)
{
- CellPair cell_pair = Trinity::ComputeCellPair(data->posX, data->posY);
- uint32 cell_id = (cell_pair.y_coord*TOTAL_NUMBER_OF_CELLS_PER_MAP) + cell_pair.x_coord;
+ CellCoord cellCoord = Trinity::ComputeCellCoord(data->posX, data->posY);
+ uint32 cell_id = (cellCoord.y_coord*TOTAL_NUMBER_OF_CELLS_PER_MAP) + cellCoord.x_coord;
CellObjectGuids& cell_guids = mMapObjectGuids[MAKE_PAIR32(data->mapid, i)][cell_id];
cell_guids.gameobjects.insert(guid);
@@ -1896,8 +1896,8 @@ void ObjectMgr::RemoveGameobjectFromGrid(uint32 guid, GameObjectData const* data
{
if (mask & 1)
{
- CellPair cell_pair = Trinity::ComputeCellPair(data->posX, data->posY);
- uint32 cell_id = (cell_pair.y_coord*TOTAL_NUMBER_OF_CELLS_PER_MAP) + cell_pair.x_coord;
+ CellCoord cellCoord = Trinity::ComputeCellCoord(data->posX, data->posY);
+ uint32 cell_id = (cellCoord.y_coord*TOTAL_NUMBER_OF_CELLS_PER_MAP) + cellCoord.x_coord;
CellObjectGuids& cell_guids = mMapObjectGuids[MAKE_PAIR32(data->mapid, i)][cell_id];
cell_guids.gameobjects.erase(guid);
@@ -3691,42 +3691,41 @@ void ObjectMgr::LoadQuests()
mExclusiveQuestGroups.clear();
- // 0 1 2 3 4 5 6 7 8 9
- QueryResult result = WorldDatabase.Query("SELECT entry, Method, ZoneOrSort, SkillOrClassMask, MinLevel, MaxLevel, QuestLevel, Type, RequiredRaces, RequiredSkillValue, "
- // 10 11 12 13 14 15 16 17 18 19
- "RepObjectiveFaction, RepObjectiveValue, RepObjectiveFaction2, RepObjectiveValue2, RequiredMinRepFaction, RequiredMinRepValue, RequiredMaxRepFaction, RequiredMaxRepValue, SuggestedPlayers, LimitTime, "
- // 20 21 22 23 24 25 26 27 28 29 30 31 32 33
- "QuestFlags, SpecialFlags, CharTitleId, PlayersSlain, BonusTalents, RewardArenaPoints, PrevQuestId, NextQuestId, ExclusiveGroup, NextQuestInChain, RewXPId, SrcItemId, SrcItemCount, SrcSpell, "
- // 34 35 36 37 38 39 40 41 42 43 44
- "Title, Details, Objectives, OfferRewardText, RequestItemsText, EndText, CompletedText, ObjectiveText1, ObjectiveText2, ObjectiveText3, ObjectiveText4, "
- // 45 46 47 48 49 50 51 52 53 54 55 56
- "ReqItemId1, ReqItemId2, ReqItemId3, ReqItemId4, ReqItemId5, ReqItemId6, ReqItemCount1, ReqItemCount2, ReqItemCount3, ReqItemCount4, ReqItemCount5, ReqItemCount6, "
- // 57 58 59 60 61 62 63 64
- "ReqSourceId1, ReqSourceId2, ReqSourceId3, ReqSourceId4, ReqSourceCount1, ReqSourceCount2, ReqSourceCount3, ReqSourceCount4, "
- // 65 66 67 68 69 70 71 72
- "ReqCreatureOrGOId1, ReqCreatureOrGOId2, ReqCreatureOrGOId3, ReqCreatureOrGOId4, ReqCreatureOrGOCount1, ReqCreatureOrGOCount2, ReqCreatureOrGOCount3, ReqCreatureOrGOCount4, "
- // 73 74 75 76
- "ReqSpellCast1, ReqSpellCast2, ReqSpellCast3, ReqSpellCast4, "
- // 77 78 79 80 81 82
- "RewChoiceItemId1, RewChoiceItemId2, RewChoiceItemId3, RewChoiceItemId4, RewChoiceItemId5, RewChoiceItemId6, "
- // 83 84 85 86 87 88
- "RewChoiceItemCount1, RewChoiceItemCount2, RewChoiceItemCount3, RewChoiceItemCount4, RewChoiceItemCount5, RewChoiceItemCount6, "
- // 89 90 91 92 93 94 95 96
- "RewItemId1, RewItemId2, RewItemId3, RewItemId4, RewItemCount1, RewItemCount2, RewItemCount3, RewItemCount4, "
- // 97 98 99 100 101 102 103 104 105 106
- "RewRepFaction1, RewRepFaction2, RewRepFaction3, RewRepFaction4, RewRepFaction5, RewRepValueId1, RewRepValueId2, RewRepValueId3, RewRepValueId4, RewRepValueId5, "
- // 107 108 109 110 111
- "RewRepValue1, RewRepValue2, RewRepValue3, RewRepValue4, RewRepValue5, "
- // 112 113 114 115 116 117 118 119 120 121 122 123
- "RewHonorAddition, RewHonorMultiplier, RewOrReqMoney, RewMoneyMaxLevel, RewSpell, RewSpellCast, RewMailTemplateId, RewMailDelaySecs, PointMapId, PointX, PointY, PointOpt, "
- // 124 125 126 127 128 129 130 131
- "DetailsEmote1, DetailsEmote2, DetailsEmote3, DetailsEmote4, DetailsEmoteDelay1, DetailsEmoteDelay2, DetailsEmoteDelay3, DetailsEmoteDelay4, "
- // 132 133 134 135 136 137
- "IncompleteEmote, CompleteEmote, OfferRewardEmote1, OfferRewardEmote2, OfferRewardEmote3, OfferRewardEmote4, "
- // 138 139 140 141
- "OfferRewardEmoteDelay1, OfferRewardEmoteDelay2, OfferRewardEmoteDelay3, OfferRewardEmoteDelay4, "
- // 142 143
- "StartScript, CompleteScript"
+ QueryResult result = WorldDatabase.Query("SELECT "
+ //0 1 2 3 4 5 6 7 8 9 10 11 12
+ "Id, Method, Level, MinLevel, MaxLevel, ZoneOrSort, Type, SuggestedPlayers, LimitTime, RequiredClasses, RequiredRaces, RequiredSkillId, RequiredSkillPoints, "
+ // 13 14 15 16 17 18 19 20
+ "RequiredFactionId1, RequiredFactionId2, RequiredFactionValue1, RequiredFactionValue2, RequiredMinRepFaction, RequiredMaxRepFaction, RequiredMinRepValue, RequiredMaxRepValue, "
+ // 21 22 23 24 25 26 27 28 29 30 31
+ "PrevQuestId, NextQuestId, ExclusiveGroup, NextQuestIdChain, RewardXPId, RewardOrRequiredMoney, RewardMoneyMaxLevel, RewardSpell, RewardSpellCast, RewardHonor, RewardHonorMultiplier, "
+ // 32 33 34 35 36 37 38 39 40 41 42
+ "RewardMailTemplateId, RewardMailDelay, SourceItemId, SourceItemCount, SourceSpellId, Flags, SpecialFlags, RewardTitleId, RequiredPlayerKills, RewardTalents, RewardArenaPoints, "
+ // 43 44 45 46 47 48 49 50
+ "RewardItemId1, RewardItemId2, RewardItemId3, RewardItemId4, RewardItemCount1, RewardItemCount2, RewardItemCount3, RewardItemCount4, "
+ // 51 52 53 54 55 56 57 58 59 60 61 62
+ "RewardChoiceItemId1, RewardChoiceItemId2, RewardChoiceItemId3, RewardChoiceItemId4, RewardChoiceItemId5, RewardChoiceItemId6, RewardChoiceItemCount1, RewardChoiceItemCount2, RewardChoiceItemCount3, RewardChoiceItemCount4, RewardChoiceItemCount5, RewardChoiceItemCount6, "
+ // 63 64 65 66 67 68 69 70 71 72
+ "RewardFactionId1, RewardFactionId2, RewardFactionId3, RewardFactionId4, RewardFactionId5, RewardFactionValueId1, RewardFactionValueId2, RewardFactionValueId3, RewardFactionValueId4, RewardFactionValueId5, "
+ // 73 74 75 76 77
+ "RewardFactionValueIdOverride1, RewardFactionValueIdOverride2, RewardFactionValueIdOverride3, RewardFactionValueIdOverride4, RewardFactionValueIdOverride5, "
+ // 78 79 80 81
+ "PointMapId, PointX, PointY, PointOption, "
+ // 82 83 84 85 86 87 88
+ "Title, Objectives, Details, EndText, OfferRewardText, RequestItemsText, CompletedText, "
+ // 89 90 91 92 93 94 95 96
+ "RequiredNpcOrGo1, RequiredNpcOrGo2, RequiredNpcOrGo3, RequiredNpcOrGo4, RequiredNpcOrGoCount1, RequiredNpcOrGoCount2, RequiredNpcOrGoCount3, RequiredNpcOrGoCount4, "
+ // 97 98 99 100 101 102 103 104
+ "RequiredSourceItemId1, RequiredSourceItemId2, RequiredSourceItemId3, RequiredSourceItemId4, RequiredSourceItemCount1, RequiredSourceItemCount2, RequiredSourceItemCount3, RequiredSourceItemCount4, "
+ // 105 106 107 108 109 110 111 112 113 114 115 116
+ "RequiredItemId1, RequiredItemId2, RequiredItemId3, RequiredItemId4, RequiredItemId5, RequiredItemId6, RequiredItemCount1, RequiredItemCount2, RequiredItemCount3, RequiredItemCount4, RequiredItemCount5, RequiredItemCount6, "
+ // 117 118 119 120 121 122 123 124 125
+ "RequiredSpellCast1, RequiredSpellCast2, RequiredSpellCast3, RequiredSpellCast4, Unknown0, ObjectiveText1, ObjectiveText2, ObjectiveText3, ObjectiveText4, "
+ // 126 127 128 129 130 131 132 133 134 135
+ "DetailsEmote1, DetailsEmote2, DetailsEmote3, DetailsEmote4, DetailsEmoteDelay1, DetailsEmoteDelay2, DetailsEmoteDelay3, DetailsEmoteDelay4, EmoteOnIncomplete, EmoteOnComplete, "
+ // 136 137 138 139 140 141 142 143
+ "OfferRewardEmote1, OfferRewardEmote2, OfferRewardEmote3, OfferRewardEmote4, OfferRewardEmoteDelay1, OfferRewardEmoteDelay2, OfferRewardEmoteDelay3, OfferRewardEmoteDelay4, "
+ // 144 145 146
+ "StartScript, CompleteScript, WDBVerified"
" FROM quest_template");
if (!result)
{
@@ -3764,45 +3763,45 @@ void ObjectMgr::LoadQuests()
sLog->outErrorDb("Quest %u has `Method` = %u, expected values are 0, 1 or 2.", qinfo->GetQuestId(), qinfo->GetQuestMethod());
}
- if (qinfo->QuestFlags & ~QUEST_TRINITY_FLAGS_DB_ALLOWED)
+ if (qinfo->Flags & ~QUEST_TRINITY_FLAGS_DB_ALLOWED)
{
sLog->outErrorDb("Quest %u has `SpecialFlags` = %u > max allowed value. Correct `SpecialFlags` to value <= %u",
- qinfo->GetQuestId(), qinfo->QuestFlags >> 20, QUEST_TRINITY_FLAGS_DB_ALLOWED >> 20);
- qinfo->QuestFlags &= QUEST_TRINITY_FLAGS_DB_ALLOWED;
+ qinfo->GetQuestId(), qinfo->Flags >> 20, QUEST_TRINITY_FLAGS_DB_ALLOWED >> 20);
+ qinfo->Flags &= QUEST_TRINITY_FLAGS_DB_ALLOWED;
}
- if (qinfo->QuestFlags & QUEST_FLAGS_DAILY && qinfo->QuestFlags & QUEST_FLAGS_WEEKLY)
+ if (qinfo->Flags & QUEST_FLAGS_DAILY && qinfo->Flags & QUEST_FLAGS_WEEKLY)
{
- sLog->outErrorDb("Weekly Quest %u is marked as daily quest in `QuestFlags`, removed daily flag.", qinfo->GetQuestId());
- qinfo->QuestFlags &= ~QUEST_FLAGS_DAILY;
+ sLog->outErrorDb("Weekly Quest %u is marked as daily quest in `Flags`, removed daily flag.", qinfo->GetQuestId());
+ qinfo->Flags &= ~QUEST_FLAGS_DAILY;
}
- if (qinfo->QuestFlags & QUEST_FLAGS_DAILY)
+ if (qinfo->Flags & QUEST_FLAGS_DAILY)
{
- if (!(qinfo->QuestFlags & QUEST_TRINITY_FLAGS_REPEATABLE))
+ if (!(qinfo->Flags & QUEST_TRINITY_FLAGS_REPEATABLE))
{
sLog->outErrorDb("Daily Quest %u not marked as repeatable in `SpecialFlags`, added.", qinfo->GetQuestId());
- qinfo->QuestFlags |= QUEST_TRINITY_FLAGS_REPEATABLE;
+ qinfo->Flags |= QUEST_TRINITY_FLAGS_REPEATABLE;
}
}
- if (qinfo->QuestFlags & QUEST_FLAGS_WEEKLY)
+ if (qinfo->Flags & QUEST_FLAGS_WEEKLY)
{
- if (!(qinfo->QuestFlags & QUEST_TRINITY_FLAGS_REPEATABLE))
+ if (!(qinfo->Flags & QUEST_TRINITY_FLAGS_REPEATABLE))
{
sLog->outErrorDb("Weekly Quest %u not marked as repeatable in `SpecialFlags`, added.", qinfo->GetQuestId());
- qinfo->QuestFlags |= QUEST_TRINITY_FLAGS_REPEATABLE;
+ qinfo->Flags |= QUEST_TRINITY_FLAGS_REPEATABLE;
}
}
- if (qinfo->QuestFlags & QUEST_FLAGS_AUTO_REWARDED)
+ if (qinfo->Flags & QUEST_FLAGS_AUTO_REWARDED)
{
- // at auto-reward can be rewarded only RewChoiceItemId[0]
+ // at auto-reward can be rewarded only RewardChoiceItemId[0]
for (int j = 1; j < QUEST_REWARD_CHOICES_COUNT; ++j )
{
- if (uint32 id = qinfo->RewChoiceItemId[j])
+ if (uint32 id = qinfo->RewardChoiceItemId[j])
{
- sLog->outErrorDb("Quest %u has `RewChoiceItemId%d` = %u but item from `RewChoiceItemId%d` can't be rewarded with quest flag QUEST_FLAGS_AUTO_REWARDED.",
+ sLog->outErrorDb("Quest %u has `RewardChoiceItemId%d` = %u but item from `RewardChoiceItemId%d` can't be rewarded with quest flag QUEST_FLAGS_AUTO_REWARDED.",
qinfo->GetQuestId(), j+1, id, j+1);
// no changes, quest ignore this data
}
@@ -3829,77 +3828,68 @@ void ObjectMgr::LoadQuests()
qinfo->GetQuestId(), qinfo->ZoneOrSort);
// no changes, quest not dependent from this value but can have problems at client (note some may be 0, we must allow this so no check)
}
- //check SkillOrClass value (class case).
- if (ClassByQuestSort(-int32(qinfo->ZoneOrSort)))
- {
- // SkillOrClass should not have class case when class case already set in ZoneOrSort.
- if (qinfo->SkillOrClassMask < 0)
- {
- sLog->outErrorDb("Quest %u has `ZoneOrSort` = %i (class sort case) and `SkillOrClassMask` = %i (class case), redundant.",
- qinfo->GetQuestId(), qinfo->ZoneOrSort, qinfo->SkillOrClassMask);
- }
- }
- //check for proper SkillOrClass value (skill case)
+ //check for proper RequiredSkillId value (skill case)
if (int32 skill_id = SkillByQuestSort(-int32(qinfo->ZoneOrSort)))
{
- // skill is positive value in SkillOrClass
- if (qinfo->SkillOrClassMask != skill_id)
+ if (qinfo->RequiredSkillId != skill_id)
{
- sLog->outErrorDb("Quest %u has `ZoneOrSort` = %i (skill sort case) but `SkillOrClassMask` does not have a corresponding value (%i).",
+ sLog->outErrorDb("Quest %u has `ZoneOrSort` = %i but `RequiredSkillId` does not have a corresponding value (%i).",
qinfo->GetQuestId(), qinfo->ZoneOrSort, skill_id);
//override, and force proper value here?
}
}
}
- // SkillOrClassMask (class case)
- if (qinfo->SkillOrClassMask < 0)
+ // RequiredClasses, can be 0/CLASSMASK_ALL_PLAYABLE to allow any class
+ if (qinfo->RequiredClasses)
{
- if (!(-int32(qinfo->SkillOrClassMask) & CLASSMASK_ALL_PLAYABLE))
+ if (!(qinfo->RequiredClasses & CLASSMASK_ALL_PLAYABLE))
{
- sLog->outErrorDb("Quest %u has `SkillOrClassMask` = %i (class case) but classmask does not have valid class",
- qinfo->GetQuestId(), qinfo->SkillOrClassMask);
+ sLog->outErrorDb("Quest %u does not contain any playable classes in `RequiredClasses` (%u), value set to 0 (all classes).", qinfo->GetQuestId(), qinfo->RequiredClasses);
+ qinfo->RequiredClasses = 0;
}
}
- // SkillOrClassMask (skill case)
- if (qinfo->SkillOrClassMask > 0)
+ // RequiredRaces, can be 0/RACEMASK_ALL_PLAYABLE to allow any race
+ if (qinfo->RequiredRaces)
+ {
+ if (!(qinfo->RequiredRaces & RACEMASK_ALL_PLAYABLE))
+ {
+ sLog->outErrorDb("Quest %u does not contain any playable races in `RequiredRaces` (%u), value set to 0 (all races).", qinfo->GetQuestId(), qinfo->RequiredRaces);
+ qinfo->RequiredRaces = 0;
+ }
+ }
+ // RequiredSkillId, can be 0
+ if (qinfo->RequiredSkillId)
{
- if (!sSkillLineStore.LookupEntry(qinfo->SkillOrClassMask))
+ if (!sSkillLineStore.LookupEntry(qinfo->RequiredSkillId))
{
- sLog->outErrorDb("Quest %u has `SkillOrClass` = %u (skill case) but skill (%i) does not exist",
- qinfo->GetQuestId(), qinfo->SkillOrClassMask, qinfo->SkillOrClassMask);
+ sLog->outErrorDb("Quest %u has `RequiredSkillId` = %u but this skill does not exist",
+ qinfo->GetQuestId(), qinfo->RequiredSkillId);
}
}
- if (qinfo->RequiredSkillValue)
+ if (qinfo->RequiredSkillPoints)
{
- if (qinfo->RequiredSkillValue > sWorld->GetConfigMaxSkillValue())
+ if (qinfo->RequiredSkillPoints > sWorld->GetConfigMaxSkillValue())
{
- sLog->outErrorDb("Quest %u has `RequiredSkillValue` = %u but max possible skill is %u, quest can't be done.",
- qinfo->GetQuestId(), qinfo->RequiredSkillValue, sWorld->GetConfigMaxSkillValue());
+ sLog->outErrorDb("Quest %u has `RequiredSkillPoints` = %u but max possible skill is %u, quest can't be done.",
+ qinfo->GetQuestId(), qinfo->RequiredSkillPoints, sWorld->GetConfigMaxSkillValue());
// no changes, quest can't be done for this requirement
}
-
- if (qinfo->SkillOrClassMask <= 0)
- {
- sLog->outErrorDb("Quest %u has `RequiredSkillValue` = %u but `SkillOrClass` = %i (class case), value ignored.",
- qinfo->GetQuestId(), qinfo->RequiredSkillValue, qinfo->SkillOrClassMask);
- // no changes, quest can't be done for this requirement (fail at wrong skill id)
- }
}
// else Skill quests can have 0 skill level, this is ok
- if (qinfo->RepObjectiveFaction2 && !sFactionStore.LookupEntry(qinfo->RepObjectiveFaction2))
+ if (qinfo->RequiredFactionId2 && !sFactionStore.LookupEntry(qinfo->RequiredFactionId2))
{
- sLog->outErrorDb("Quest %u has `RepObjectiveFaction2` = %u but faction template %u does not exist, quest can't be done.",
- qinfo->GetQuestId(), qinfo->RepObjectiveFaction2, qinfo->RepObjectiveFaction2);
+ sLog->outErrorDb("Quest %u has `RequiredFactionId2` = %u but faction template %u does not exist, quest can't be done.",
+ qinfo->GetQuestId(), qinfo->RequiredFactionId2, qinfo->RequiredFactionId2);
// no changes, quest can't be done for this requirement
}
- if (qinfo->RepObjectiveFaction && !sFactionStore.LookupEntry(qinfo->RepObjectiveFaction))
+ if (qinfo->RequiredFactionId1 && !sFactionStore.LookupEntry(qinfo->RequiredFactionId1))
{
- sLog->outErrorDb("Quest %u has `RepObjectiveFaction` = %u but faction template %u does not exist, quest can't be done.",
- qinfo->GetQuestId(), qinfo->RepObjectiveFaction, qinfo->RepObjectiveFaction);
+ sLog->outErrorDb("Quest %u has `RequiredFactionId1` = %u but faction template %u does not exist, quest can't be done.",
+ qinfo->GetQuestId(), qinfo->RequiredFactionId1, qinfo->RequiredFactionId1);
// no changes, quest can't be done for this requirement
}
@@ -3931,17 +3921,17 @@ void ObjectMgr::LoadQuests()
// no changes, quest can't be done for this requirement
}
- if (!qinfo->RepObjectiveFaction && qinfo->RepObjectiveValue != 0)
+ if (!qinfo->RequiredFactionId1 && qinfo->RequiredFactionValue1 != 0)
{
- sLog->outErrorDb("Quest %u has `RepObjectiveValue` = %d but `RepObjectiveFaction` is 0, value has no effect",
- qinfo->GetQuestId(), qinfo->RepObjectiveValue);
+ sLog->outErrorDb("Quest %u has `RequiredFactionValue1` = %d but `RequiredFactionId1` is 0, value has no effect",
+ qinfo->GetQuestId(), qinfo->RequiredFactionValue1);
// warning
}
- if (!qinfo->RepObjectiveFaction2 && qinfo->RepObjectiveValue2 != 0)
+ if (!qinfo->RequiredFactionId2 && qinfo->RequiredFactionValue2 != 0)
{
- sLog->outErrorDb("Quest %u has `RepObjectiveValue2` = %d but `RepObjectiveFaction2` is 0, value has no effect",
- qinfo->GetQuestId(), qinfo->RepObjectiveValue2);
+ sLog->outErrorDb("Quest %u has `RequiredFactionValue2` = %d but `RequiredFactionId2` is 0, value has no effect",
+ qinfo->GetQuestId(), qinfo->RequiredFactionValue2);
// warning
}
@@ -3959,61 +3949,61 @@ void ObjectMgr::LoadQuests()
// warning
}
- if (qinfo->CharTitleId && !sCharTitlesStore.LookupEntry(qinfo->CharTitleId))
+ if (qinfo->RewardTitleId && !sCharTitlesStore.LookupEntry(qinfo->RewardTitleId))
{
- sLog->outErrorDb("Quest %u has `CharTitleId` = %u but CharTitle Id %u does not exist, quest can't be rewarded with title.",
+ sLog->outErrorDb("Quest %u has `RewardTitleId` = %u but CharTitle Id %u does not exist, quest can't be rewarded with title.",
qinfo->GetQuestId(), qinfo->GetCharTitleId(), qinfo->GetCharTitleId());
- qinfo->CharTitleId = 0;
+ qinfo->RewardTitleId = 0;
// quest can't reward this title
}
- if (qinfo->SrcItemId)
+ if (qinfo->SourceItemId)
{
- if (!sObjectMgr->GetItemTemplate(qinfo->SrcItemId))
+ if (!sObjectMgr->GetItemTemplate(qinfo->SourceItemId))
{
- sLog->outErrorDb("Quest %u has `SrcItemId` = %u but item with entry %u does not exist, quest can't be done.",
- qinfo->GetQuestId(), qinfo->SrcItemId, qinfo->SrcItemId);
- qinfo->SrcItemId = 0; // quest can't be done for this requirement
+ sLog->outErrorDb("Quest %u has `SourceItemId` = %u but item with entry %u does not exist, quest can't be done.",
+ qinfo->GetQuestId(), qinfo->SourceItemId, qinfo->SourceItemId);
+ qinfo->SourceItemId = 0; // quest can't be done for this requirement
}
- else if (qinfo->SrcItemCount == 0)
+ else if (qinfo->SourceItemIdCount == 0)
{
- sLog->outErrorDb("Quest %u has `SrcItemId` = %u but `SrcItemCount` = 0, set to 1 but need fix in DB.",
- qinfo->GetQuestId(), qinfo->SrcItemId);
- qinfo->SrcItemCount = 1; // update to 1 for allow quest work for backward compatibility with DB
+ sLog->outErrorDb("Quest %u has `SourceItemId` = %u but `SourceItemIdCount` = 0, set to 1 but need fix in DB.",
+ qinfo->GetQuestId(), qinfo->SourceItemId);
+ qinfo->SourceItemIdCount = 1; // update to 1 for allow quest work for backward compatibility with DB
}
}
- else if (qinfo->SrcItemCount>0)
+ else if (qinfo->SourceItemIdCount>0)
{
- sLog->outErrorDb("Quest %u has `SrcItemId` = 0 but `SrcItemCount` = %u, useless value.",
- qinfo->GetQuestId(), qinfo->SrcItemCount);
- qinfo->SrcItemCount=0; // no quest work changes in fact
+ sLog->outErrorDb("Quest %u has `SourceItemId` = 0 but `SourceItemIdCount` = %u, useless value.",
+ qinfo->GetQuestId(), qinfo->SourceItemIdCount);
+ qinfo->SourceItemIdCount=0; // no quest work changes in fact
}
- if (qinfo->SrcSpell)
+ if (qinfo->SourceSpellid)
{
- SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(qinfo->SrcSpell);
+ SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(qinfo->SourceSpellid);
if (!spellInfo)
{
- sLog->outErrorDb("Quest %u has `SrcSpell` = %u but spell %u doesn't exist, quest can't be done.",
- qinfo->GetQuestId(), qinfo->SrcSpell, qinfo->SrcSpell);
- qinfo->SrcSpell = 0; // quest can't be done for this requirement
+ sLog->outErrorDb("Quest %u has `SourceSpellid` = %u but spell %u doesn't exist, quest can't be done.",
+ qinfo->GetQuestId(), qinfo->SourceSpellid, qinfo->SourceSpellid);
+ qinfo->SourceSpellid = 0; // quest can't be done for this requirement
}
else if (!SpellMgr::IsSpellValid(spellInfo))
{
- sLog->outErrorDb("Quest %u has `SrcSpell` = %u but spell %u is broken, quest can't be done.",
- qinfo->GetQuestId(), qinfo->SrcSpell, qinfo->SrcSpell);
- qinfo->SrcSpell = 0; // quest can't be done for this requirement
+ sLog->outErrorDb("Quest %u has `SourceSpellid` = %u but spell %u is broken, quest can't be done.",
+ qinfo->GetQuestId(), qinfo->SourceSpellid, qinfo->SourceSpellid);
+ qinfo->SourceSpellid = 0; // quest can't be done for this requirement
}
}
for (uint8 j = 0; j < QUEST_ITEM_OBJECTIVES_COUNT; ++j)
{
- uint32 id = qinfo->ReqItemId[j];
+ uint32 id = qinfo->RequiredItemId[j];
if (id)
{
- if (qinfo->ReqItemCount[j] == 0)
+ if (qinfo->RequiredItemCount[j] == 0)
{
- sLog->outErrorDb("Quest %u has `ReqItemId%d` = %u but `ReqItemCount%d` = 0, quest can't be done.",
+ sLog->outErrorDb("Quest %u has `RequiredItemId%d` = %u but `RequiredItemCount%d` = 0, quest can't be done.",
qinfo->GetQuestId(), j+1, id, j+1);
// no changes, quest can't be done for this requirement
}
@@ -4022,37 +4012,37 @@ void ObjectMgr::LoadQuests()
if (!sObjectMgr->GetItemTemplate(id))
{
- sLog->outErrorDb("Quest %u has `ReqItemId%d` = %u but item with entry %u does not exist, quest can't be done.",
+ sLog->outErrorDb("Quest %u has `RequiredItemId%d` = %u but item with entry %u does not exist, quest can't be done.",
qinfo->GetQuestId(), j+1, id, id);
- qinfo->ReqItemCount[j] = 0; // prevent incorrect work of quest
+ qinfo->RequiredItemCount[j] = 0; // prevent incorrect work of quest
}
}
- else if (qinfo->ReqItemCount[j]>0)
+ else if (qinfo->RequiredItemCount[j]>0)
{
- sLog->outErrorDb("Quest %u has `ReqItemId%d` = 0 but `ReqItemCount%d` = %u, quest can't be done.",
- qinfo->GetQuestId(), j+1, j+1, qinfo->ReqItemCount[j]);
- qinfo->ReqItemCount[j] = 0; // prevent incorrect work of quest
+ sLog->outErrorDb("Quest %u has `RequiredItemId%d` = 0 but `RequiredItemCount%d` = %u, quest can't be done.",
+ qinfo->GetQuestId(), j+1, j+1, qinfo->RequiredItemCount[j]);
+ qinfo->RequiredItemCount[j] = 0; // prevent incorrect work of quest
}
}
for (uint8 j = 0; j < QUEST_SOURCE_ITEM_IDS_COUNT; ++j)
{
- uint32 id = qinfo->ReqSourceId[j];
+ uint32 id = qinfo->RequiredSourceItemid[j];
if (id)
{
if (!sObjectMgr->GetItemTemplate(id))
{
- sLog->outErrorDb("Quest %u has `ReqSourceId%d` = %u but item with entry %u does not exist, quest can't be done.",
+ sLog->outErrorDb("Quest %u has `RequiredSourceItemid%d` = %u but item with entry %u does not exist, quest can't be done.",
qinfo->GetQuestId(), j+1, id, id);
// no changes, quest can't be done for this requirement
}
}
else
{
- if (qinfo->ReqSourceCount[j]>0)
+ if (qinfo->RequiredSourceItemId[j]>0)
{
- sLog->outErrorDb("Quest %u has `ReqSourceId%d` = 0 but `ReqSourceCount%d` = %u.",
- qinfo->GetQuestId(), j+1, j+1, qinfo->ReqSourceCount[j]);
+ sLog->outErrorDb("Quest %u has `RequiredSourceItemid%d` = 0 but `RequiredSourceItemId%d` = %u.",
+ qinfo->GetQuestId(), j+1, j+1, qinfo->RequiredSourceItemId[j]);
// no changes, quest ignore this data
}
}
@@ -4060,7 +4050,7 @@ void ObjectMgr::LoadQuests()
for (uint8 j = 0; j < QUEST_OBJECTIVES_COUNT; ++j)
{
- uint32 id = qinfo->ReqSpell[j];
+ uint32 id = qinfo->RequiredSpellCast[j];
if (id)
{
SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(id);
@@ -4071,12 +4061,12 @@ void ObjectMgr::LoadQuests()
continue;
}
- if (!qinfo->ReqCreatureOrGOId[j])
+ if (!qinfo->RequiredNpcOrGo[j])
{
bool found = false;
for (uint8 k = 0; k < MAX_SPELL_EFFECTS; ++k)
{
- if ((spellInfo->Effects[k].Effect == SPELL_EFFECT_QUEST_COMPLETE && uint32(spellInfo->Effects[k].MiscValue) == qinfo->QuestId) ||
+ if ((spellInfo->Effects[k].Effect == SPELL_EFFECT_QUEST_COMPLETE && uint32(spellInfo->Effects[k].MiscValue) == qinfo->Id) ||
spellInfo->Effects[k].Effect == SPELL_EFFECT_SEND_EVENT)
{
found = true;
@@ -4088,7 +4078,7 @@ void ObjectMgr::LoadQuests()
{
if (!qinfo->HasFlag(QUEST_TRINITY_FLAGS_EXPLORATION_OR_EVENT))
{
- sLog->outErrorDb("Spell (id: %u) have SPELL_EFFECT_QUEST_COMPLETE or SPELL_EFFECT_SEND_EVENT for quest %u and ReqCreatureOrGOId%d = 0, but quest not have flag QUEST_TRINITY_FLAGS_EXPLORATION_OR_EVENT. Quest flags or ReqCreatureOrGOId%d must be fixed, quest modified to enable objective.", spellInfo->Id, qinfo->QuestId, j+1, j+1);
+ sLog->outErrorDb("Spell (id: %u) have SPELL_EFFECT_QUEST_COMPLETE or SPELL_EFFECT_SEND_EVENT for quest %u and RequiredNpcOrGo%d = 0, but quest not have flag QUEST_TRINITY_FLAGS_EXPLORATION_OR_EVENT. Quest flags or RequiredNpcOrGo%d must be fixed, quest modified to enable objective.", spellInfo->Id, qinfo->Id, j+1, j+1);
// this will prevent quest completing without objective
const_cast<Quest*>(qinfo)->SetFlag(QUEST_TRINITY_FLAGS_EXPLORATION_OR_EVENT);
@@ -4096,7 +4086,7 @@ void ObjectMgr::LoadQuests()
}
else
{
- sLog->outErrorDb("Quest %u has `ReqSpellCast%d` = %u and ReqCreatureOrGOId%d = 0 but spell %u does not have SPELL_EFFECT_QUEST_COMPLETE or SPELL_EFFECT_SEND_EVENT effect for this quest, quest can't be done.",
+ sLog->outErrorDb("Quest %u has `ReqSpellCast%d` = %u and RequiredNpcOrGo%d = 0 but spell %u does not have SPELL_EFFECT_QUEST_COMPLETE or SPELL_EFFECT_SEND_EVENT effect for this quest, quest can't be done.",
qinfo->GetQuestId(), j+1, id, j+1, id);
// no changes, quest can't be done for this requirement
}
@@ -4106,19 +4096,19 @@ void ObjectMgr::LoadQuests()
for (uint8 j = 0; j < QUEST_OBJECTIVES_COUNT; ++j)
{
- int32 id = qinfo->ReqCreatureOrGOId[j];
+ int32 id = qinfo->RequiredNpcOrGo[j];
if (id < 0 && !sObjectMgr->GetGameObjectTemplate(-id))
{
- sLog->outErrorDb("Quest %u has `ReqCreatureOrGOId%d` = %i but gameobject %u does not exist, quest can't be done.",
+ sLog->outErrorDb("Quest %u has `RequiredNpcOrGo%d` = %i but gameobject %u does not exist, quest can't be done.",
qinfo->GetQuestId(), j+1, id, uint32(-id));
- qinfo->ReqCreatureOrGOId[j] = 0; // quest can't be done for this requirement
+ qinfo->RequiredNpcOrGo[j] = 0; // quest can't be done for this requirement
}
if (id > 0 && !sObjectMgr->GetCreatureTemplate(id))
{
- sLog->outErrorDb("Quest %u has `ReqCreatureOrGOId%d` = %i but creature with entry %u does not exist, quest can't be done.",
+ sLog->outErrorDb("Quest %u has `RequiredNpcOrGo%d` = %i but creature with entry %u does not exist, quest can't be done.",
qinfo->GetQuestId(), j+1, id, uint32(id));
- qinfo->ReqCreatureOrGOId[j] = 0; // quest can't be done for this requirement
+ qinfo->RequiredNpcOrGo[j] = 0; // quest can't be done for this requirement
}
if (id)
@@ -4127,179 +4117,179 @@ void ObjectMgr::LoadQuests()
qinfo->SetFlag(QUEST_TRINITY_FLAGS_KILL_OR_CAST | QUEST_TRINITY_FLAGS_SPEAKTO);
- if (!qinfo->ReqCreatureOrGOCount[j])
+ if (!qinfo->RequiredNpcOrGoCount[j])
{
- sLog->outErrorDb("Quest %u has `ReqCreatureOrGOId%d` = %u but `ReqCreatureOrGOCount%d` = 0, quest can't be done.",
+ sLog->outErrorDb("Quest %u has `RequiredNpcOrGo%d` = %u but `RequiredNpcOrGoCount%d` = 0, quest can't be done.",
qinfo->GetQuestId(), j+1, id, j+1);
// no changes, quest can be incorrectly done, but we already report this
}
}
- else if (qinfo->ReqCreatureOrGOCount[j]>0)
+ else if (qinfo->RequiredNpcOrGoCount[j]>0)
{
- sLog->outErrorDb("Quest %u has `ReqCreatureOrGOId%d` = 0 but `ReqCreatureOrGOCount%d` = %u.",
- qinfo->GetQuestId(), j+1, j+1, qinfo->ReqCreatureOrGOCount[j]);
+ sLog->outErrorDb("Quest %u has `RequiredNpcOrGo%d` = 0 but `RequiredNpcOrGoCount%d` = %u.",
+ qinfo->GetQuestId(), j+1, j+1, qinfo->RequiredNpcOrGoCount[j]);
// no changes, quest ignore this data
}
}
for (uint8 j = 0; j < QUEST_REWARD_CHOICES_COUNT; ++j)
{
- uint32 id = qinfo->RewChoiceItemId[j];
+ uint32 id = qinfo->RewardChoiceItemId[j];
if (id)
{
if (!sObjectMgr->GetItemTemplate(id))
{
- sLog->outErrorDb("Quest %u has `RewChoiceItemId%d` = %u but item with entry %u does not exist, quest will not reward this item.",
+ sLog->outErrorDb("Quest %u has `RewardChoiceItemId%d` = %u but item with entry %u does not exist, quest will not reward this item.",
qinfo->GetQuestId(), j+1, id, id);
- qinfo->RewChoiceItemId[j] = 0; // no changes, quest will not reward this
+ qinfo->RewardChoiceItemId[j] = 0; // no changes, quest will not reward this
}
- if (!qinfo->RewChoiceItemCount[j])
+ if (!qinfo->RewardChoiceItemCount[j])
{
- sLog->outErrorDb("Quest %u has `RewChoiceItemId%d` = %u but `RewChoiceItemCount%d` = 0, quest can't be done.",
+ sLog->outErrorDb("Quest %u has `RewardChoiceItemId%d` = %u but `RewardChoiceItemCount%d` = 0, quest can't be done.",
qinfo->GetQuestId(), j+1, id, j+1);
// no changes, quest can't be done
}
}
- else if (qinfo->RewChoiceItemCount[j]>0)
+ else if (qinfo->RewardChoiceItemCount[j]>0)
{
- sLog->outErrorDb("Quest %u has `RewChoiceItemId%d` = 0 but `RewChoiceItemCount%d` = %u.",
- qinfo->GetQuestId(), j+1, j+1, qinfo->RewChoiceItemCount[j]);
+ sLog->outErrorDb("Quest %u has `RewardChoiceItemId%d` = 0 but `RewardChoiceItemCount%d` = %u.",
+ qinfo->GetQuestId(), j+1, j+1, qinfo->RewardChoiceItemCount[j]);
// no changes, quest ignore this data
}
}
for (uint8 j = 0; j < QUEST_REWARDS_COUNT; ++j)
{
- uint32 id = qinfo->RewItemId[j];
+ uint32 id = qinfo->RewardItemId[j];
if (id)
{
if (!sObjectMgr->GetItemTemplate(id))
{
- sLog->outErrorDb("Quest %u has `RewItemId%d` = %u but item with entry %u does not exist, quest will not reward this item.",
+ sLog->outErrorDb("Quest %u has `RewardItemId%d` = %u but item with entry %u does not exist, quest will not reward this item.",
qinfo->GetQuestId(), j+1, id, id);
- qinfo->RewItemId[j] = 0; // no changes, quest will not reward this item
+ qinfo->RewardItemId[j] = 0; // no changes, quest will not reward this item
}
- if (!qinfo->RewItemCount[j])
+ if (!qinfo->RewardItemIdCount[j])
{
- sLog->outErrorDb("Quest %u has `RewItemId%d` = %u but `RewItemCount%d` = 0, quest will not reward this item.",
+ sLog->outErrorDb("Quest %u has `RewardItemId%d` = %u but `RewardItemIdCount%d` = 0, quest will not reward this item.",
qinfo->GetQuestId(), j+1, id, j+1);
// no changes
}
}
- else if (qinfo->RewItemCount[j]>0)
+ else if (qinfo->RewardItemIdCount[j]>0)
{
- sLog->outErrorDb("Quest %u has `RewItemId%d` = 0 but `RewItemCount%d` = %u.",
- qinfo->GetQuestId(), j+1, j+1, qinfo->RewItemCount[j]);
+ sLog->outErrorDb("Quest %u has `RewardItemId%d` = 0 but `RewardItemIdCount%d` = %u.",
+ qinfo->GetQuestId(), j+1, j+1, qinfo->RewardItemIdCount[j]);
// no changes, quest ignore this data
}
}
for (uint8 j = 0; j < QUEST_REPUTATIONS_COUNT; ++j)
{
- if (qinfo->RewRepFaction[j])
+ if (qinfo->RewardFactionId[j])
{
- if (abs(qinfo->RewRepValueId[j]) > 9)
+ if (abs(qinfo->RewardFactionValueId[j]) > 9)
{
- sLog->outErrorDb("Quest %u has RewRepValueId%d = %i. That is outside the range of valid values (-9 to 9).", qinfo->GetQuestId(), j+1, qinfo->RewRepValueId[j]);
+ sLog->outErrorDb("Quest %u has RewardFactionValueId%d = %i. That is outside the range of valid values (-9 to 9).", qinfo->GetQuestId(), j+1, qinfo->RewardFactionValueId[j]);
}
- if (!sFactionStore.LookupEntry(qinfo->RewRepFaction[j]))
+ if (!sFactionStore.LookupEntry(qinfo->RewardFactionId[j]))
{
- sLog->outErrorDb("Quest %u has `RewRepFaction%d` = %u but raw faction (faction.dbc) %u does not exist, quest will not reward reputation for this faction.", qinfo->GetQuestId(), j+1, qinfo->RewRepFaction[j], qinfo->RewRepFaction[j]);
- qinfo->RewRepFaction[j] = 0; // quest will not reward this
+ sLog->outErrorDb("Quest %u has `RewardFactionId%d` = %u but raw faction (faction.dbc) %u does not exist, quest will not reward reputation for this faction.", qinfo->GetQuestId(), j+1, qinfo->RewardFactionId[j], qinfo->RewardFactionId[j]);
+ qinfo->RewardFactionId[j] = 0; // quest will not reward this
}
}
- else if (qinfo->RewRepValue[j] != 0)
+ else if (qinfo->RewardFactionValueIdOverride[j] != 0)
{
- sLog->outErrorDb("Quest %u has `RewRepFaction%d` = 0 but `RewRepValue%d` = %i.",
- qinfo->GetQuestId(), j+1, j+1, qinfo->RewRepValue[j]);
+ sLog->outErrorDb("Quest %u has `RewardFactionId%d` = 0 but `RewardFactionValueIdOverride%d` = %i.",
+ qinfo->GetQuestId(), j+1, j+1, qinfo->RewardFactionValueIdOverride[j]);
// no changes, quest ignore this data
}
}
- if (qinfo->RewSpell)
+ if (qinfo->RewardSpell)
{
- SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(qinfo->RewSpell);
+ SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(qinfo->RewardSpell);
if (!spellInfo)
{
- sLog->outErrorDb("Quest %u has `RewSpell` = %u but spell %u does not exist, spell removed as display reward.",
- qinfo->GetQuestId(), qinfo->RewSpell, qinfo->RewSpell);
- qinfo->RewSpell = 0; // no spell reward will display for this quest
+ sLog->outErrorDb("Quest %u has `RewardSpell` = %u but spell %u does not exist, spell removed as display reward.",
+ qinfo->GetQuestId(), qinfo->RewardSpell, qinfo->RewardSpell);
+ qinfo->RewardSpell = 0; // no spell reward will display for this quest
}
else if (!SpellMgr::IsSpellValid(spellInfo))
{
- sLog->outErrorDb("Quest %u has `RewSpell` = %u but spell %u is broken, quest will not have a spell reward.",
- qinfo->GetQuestId(), qinfo->RewSpell, qinfo->RewSpell);
- qinfo->RewSpell = 0; // no spell reward will display for this quest
+ sLog->outErrorDb("Quest %u has `RewardSpell` = %u but spell %u is broken, quest will not have a spell reward.",
+ qinfo->GetQuestId(), qinfo->RewardSpell, qinfo->RewardSpell);
+ qinfo->RewardSpell = 0; // no spell reward will display for this quest
}
- else if (GetTalentSpellCost(qinfo->RewSpell))
+ else if (GetTalentSpellCost(qinfo->RewardSpell))
{
- sLog->outErrorDb("Quest %u has `RewSpell` = %u but spell %u is talent, quest will not have a spell reward.",
- qinfo->GetQuestId(), qinfo->RewSpell, qinfo->RewSpell);
- qinfo->RewSpell = 0; // no spell reward will display for this quest
+ sLog->outErrorDb("Quest %u has `RewardSpell` = %u but spell %u is talent, quest will not have a spell reward.",
+ qinfo->GetQuestId(), qinfo->RewardSpell, qinfo->RewardSpell);
+ qinfo->RewardSpell = 0; // no spell reward will display for this quest
}
}
- if (qinfo->RewSpellCast > 0)
+ if (qinfo->RewardSpellCast > 0)
{
- SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(qinfo->RewSpellCast);
+ SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(qinfo->RewardSpellCast);
if (!spellInfo)
{
- sLog->outErrorDb("Quest %u has `RewSpellCast` = %u but spell %u does not exist, quest will not have a spell reward.",
- qinfo->GetQuestId(), qinfo->RewSpellCast, qinfo->RewSpellCast);
- qinfo->RewSpellCast = 0; // no spell will be casted on player
+ sLog->outErrorDb("Quest %u has `RewardSpellCast` = %u but spell %u does not exist, quest will not have a spell reward.",
+ qinfo->GetQuestId(), qinfo->RewardSpellCast, qinfo->RewardSpellCast);
+ qinfo->RewardSpellCast = 0; // no spell will be casted on player
}
else if (!SpellMgr::IsSpellValid(spellInfo))
{
- sLog->outErrorDb("Quest %u has `RewSpellCast` = %u but spell %u is broken, quest will not have a spell reward.",
- qinfo->GetQuestId(), qinfo->RewSpellCast, qinfo->RewSpellCast);
- qinfo->RewSpellCast = 0; // no spell will be casted on player
+ sLog->outErrorDb("Quest %u has `RewardSpellCast` = %u but spell %u is broken, quest will not have a spell reward.",
+ qinfo->GetQuestId(), qinfo->RewardSpellCast, qinfo->RewardSpellCast);
+ qinfo->RewardSpellCast = 0; // no spell will be casted on player
}
- else if (GetTalentSpellCost(qinfo->RewSpellCast))
+ else if (GetTalentSpellCost(qinfo->RewardSpellCast))
{
- sLog->outErrorDb("Quest %u has `RewSpell` = %u but spell %u is talent, quest will not have a spell reward.",
- qinfo->GetQuestId(), qinfo->RewSpellCast, qinfo->RewSpellCast);
- qinfo->RewSpellCast = 0; // no spell will be casted on player
+ sLog->outErrorDb("Quest %u has `RewardSpell` = %u but spell %u is talent, quest will not have a spell reward.",
+ qinfo->GetQuestId(), qinfo->RewardSpellCast, qinfo->RewardSpellCast);
+ qinfo->RewardSpellCast = 0; // no spell will be casted on player
}
}
- if (qinfo->RewMailTemplateId)
+ if (qinfo->RewardMailTemplateId)
{
- if (!sMailTemplateStore.LookupEntry(qinfo->RewMailTemplateId))
+ if (!sMailTemplateStore.LookupEntry(qinfo->RewardMailTemplateId))
{
- sLog->outErrorDb("Quest %u has `RewMailTemplateId` = %u but mail template %u does not exist, quest will not have a mail reward.",
- qinfo->GetQuestId(), qinfo->RewMailTemplateId, qinfo->RewMailTemplateId);
- qinfo->RewMailTemplateId = 0; // no mail will send to player
- qinfo->RewMailDelaySecs = 0; // no mail will send to player
+ sLog->outErrorDb("Quest %u has `RewardMailTemplateId` = %u but mail template %u does not exist, quest will not have a mail reward.",
+ qinfo->GetQuestId(), qinfo->RewardMailTemplateId, qinfo->RewardMailTemplateId);
+ qinfo->RewardMailTemplateId = 0; // no mail will send to player
+ qinfo->RewardMailDelay = 0; // no mail will send to player
}
- else if (usedMailTemplates.find(qinfo->RewMailTemplateId) != usedMailTemplates.end())
+ else if (usedMailTemplates.find(qinfo->RewardMailTemplateId) != usedMailTemplates.end())
{
- std::map<uint32, uint32>::const_iterator used_mt_itr = usedMailTemplates.find(qinfo->RewMailTemplateId);
- sLog->outErrorDb("Quest %u has `RewMailTemplateId` = %u but mail template %u already used for quest %u, quest will not have a mail reward.",
- qinfo->GetQuestId(), qinfo->RewMailTemplateId, qinfo->RewMailTemplateId, used_mt_itr->second);
- qinfo->RewMailTemplateId = 0; // no mail will send to player
- qinfo->RewMailDelaySecs = 0; // no mail will send to player
+ std::map<uint32, uint32>::const_iterator used_mt_itr = usedMailTemplates.find(qinfo->RewardMailTemplateId);
+ sLog->outErrorDb("Quest %u has `RewardMailTemplateId` = %u but mail template %u already used for quest %u, quest will not have a mail reward.",
+ qinfo->GetQuestId(), qinfo->RewardMailTemplateId, qinfo->RewardMailTemplateId, used_mt_itr->second);
+ qinfo->RewardMailTemplateId = 0; // no mail will send to player
+ qinfo->RewardMailDelay = 0; // no mail will send to player
}
else
- usedMailTemplates[qinfo->RewMailTemplateId] = qinfo->GetQuestId();
+ usedMailTemplates[qinfo->RewardMailTemplateId] = qinfo->GetQuestId();
}
- if (qinfo->NextQuestInChain)
+ if (qinfo->NextQuestIdChain)
{
- QuestMap::iterator qNextItr = mQuestTemplates.find(qinfo->NextQuestInChain);
+ QuestMap::iterator qNextItr = mQuestTemplates.find(qinfo->NextQuestIdChain);
if (qNextItr == mQuestTemplates.end())
{
- sLog->outErrorDb("Quest %u has `NextQuestInChain` = %u but quest %u does not exist, quest chain will not work.",
- qinfo->GetQuestId(), qinfo->NextQuestInChain, qinfo->NextQuestInChain);
- qinfo->NextQuestInChain = 0;
+ sLog->outErrorDb("Quest %u has `NextQuestIdChain` = %u but quest %u does not exist, quest chain will not work.",
+ qinfo->GetQuestId(), qinfo->NextQuestIdChain, qinfo->NextQuestIdChain);
+ qinfo->NextQuestIdChain = 0;
}
else
qNextItr->second->prevChainQuests.push_back(qinfo->GetQuestId());
@@ -4336,7 +4326,7 @@ void ObjectMgr::LoadQuests()
mExclusiveQuestGroups.insert(std::pair<int32, uint32>(qinfo->ExclusiveGroup, qinfo->GetQuestId()));
if (qinfo->LimitTime)
qinfo->SetFlag(QUEST_TRINITY_FLAGS_TIMED);
- if (qinfo->PlayersSlain)
+ if (qinfo->RequiredPlayerKills)
qinfo->SetFlag(QUEST_TRINITY_FLAGS_PLAYER_KILL);
}
@@ -5369,11 +5359,11 @@ void ObjectMgr::ReturnOrDeleteOldMails(bool serverUp)
m->checked = fields[7].GetUInt32();
m->mailTemplateId = fields[8].GetInt16();
- Player* pl = NULL;
+ Player* player = NULL;
if (serverUp)
- pl = ObjectAccessor::FindPlayer((uint64)m->receiver);
+ player = ObjectAccessor::FindPlayer((uint64)m->receiver);
- if (pl && pl->m_mailsLoaded)
+ if (player && player->m_mailsLoaded)
{ // this code will run very improbably (the time is between 4 and 5 am, in game is online a player, who has old mail
// his in mailbox and he has already listed his mails)
delete m;
@@ -5392,7 +5382,7 @@ void ObjectMgr::ReturnOrDeleteOldMails(bool serverUp)
// mail open and then not returned
for (MailItemInfoVec::iterator itr2 = m->items.begin(); itr2 != m->items.end(); ++itr2)
{
- PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_ITEM_INSTANCE);
+ stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_ITEM_INSTANCE);
stmt->setUInt32(0, itr2->item_guid);
CharacterDatabase.Execute(stmt);
}
@@ -7084,13 +7074,13 @@ void ObjectMgr::LoadQuestPOI()
{
// The first result should have the highest questId
Field* fields = points->Fetch();
- uint32 questId = fields[0].GetUInt32();
- POIs.resize(questId + 1);
+ uint32 questIdMax = fields[0].GetUInt32();
+ POIs.resize(questIdMax + 1);
do
{
- Field* fields = points->Fetch();
+ fields = points->Fetch();
uint32 questId = fields[0].GetUInt32();
uint32 id = fields[1].GetUInt32();
@@ -8490,13 +8480,13 @@ bool ObjectMgr::RemoveVendorItem(uint32 entry, uint32 item, bool savetodb)
return true;
}
-bool ObjectMgr::IsVendorItemValid(uint32 vendor_entry, uint32 item_id, int32 maxcount, uint32 incrtime, uint32 ExtendedCost, Player* pl, std::set<uint32>* skip_vendors, uint32 ORnpcflag) const
+bool ObjectMgr::IsVendorItemValid(uint32 vendor_entry, uint32 item_id, int32 maxcount, uint32 incrtime, uint32 ExtendedCost, Player* player, std::set<uint32>* skip_vendors, uint32 ORnpcflag) const
{
CreatureTemplate const* cInfo = sObjectMgr->GetCreatureTemplate(vendor_entry);
if (!cInfo)
{
- if (pl)
- ChatHandler(pl).SendSysMessage(LANG_COMMAND_VENDORSELECTION);
+ if (player)
+ ChatHandler(player).SendSysMessage(LANG_COMMAND_VENDORSELECTION);
else
sLog->outErrorDb("Table `(game_event_)npc_vendor` have data for not existed creature template (Entry: %u), ignore", vendor_entry);
return false;
@@ -8506,8 +8496,8 @@ bool ObjectMgr::IsVendorItemValid(uint32 vendor_entry, uint32 item_id, int32 max
{
if (!skip_vendors || skip_vendors->count(vendor_entry) == 0)
{
- if (pl)
- ChatHandler(pl).SendSysMessage(LANG_COMMAND_VENDORSELECTION);
+ if (player)
+ ChatHandler(player).SendSysMessage(LANG_COMMAND_VENDORSELECTION);
else
sLog->outErrorDb("Table `(game_event_)npc_vendor` have data for not creature template (Entry: %u) without vendor flag, ignore", vendor_entry);
@@ -8519,8 +8509,8 @@ bool ObjectMgr::IsVendorItemValid(uint32 vendor_entry, uint32 item_id, int32 max
if (!sObjectMgr->GetItemTemplate(item_id))
{
- if (pl)
- ChatHandler(pl).PSendSysMessage(LANG_ITEM_NOT_FOUND, item_id);
+ if (player)
+ ChatHandler(player).PSendSysMessage(LANG_ITEM_NOT_FOUND, item_id);
else
sLog->outErrorDb("Table `(game_event_)npc_vendor` for Vendor (Entry: %u) have in item list non-existed item (%u), ignore", vendor_entry, item_id);
return false;
@@ -8528,8 +8518,8 @@ bool ObjectMgr::IsVendorItemValid(uint32 vendor_entry, uint32 item_id, int32 max
if (ExtendedCost && !sItemExtendedCostStore.LookupEntry(ExtendedCost))
{
- if (pl)
- ChatHandler(pl).PSendSysMessage(LANG_EXTENDED_COST_NOT_EXIST, ExtendedCost);
+ if (player)
+ ChatHandler(player).PSendSysMessage(LANG_EXTENDED_COST_NOT_EXIST, ExtendedCost);
else
sLog->outErrorDb("Table `(game_event_)npc_vendor` have Item (Entry: %u) with wrong ExtendedCost (%u) for vendor (%u), ignore", item_id, ExtendedCost, vendor_entry);
return false;
@@ -8537,16 +8527,16 @@ bool ObjectMgr::IsVendorItemValid(uint32 vendor_entry, uint32 item_id, int32 max
if (maxcount > 0 && incrtime == 0)
{
- if (pl)
- ChatHandler(pl).PSendSysMessage("MaxCount != 0 (%u) but IncrTime == 0", maxcount);
+ if (player)
+ ChatHandler(player).PSendSysMessage("MaxCount != 0 (%u) but IncrTime == 0", maxcount);
else
sLog->outErrorDb("Table `(game_event_)npc_vendor` has `maxcount` (%u) for item %u of vendor (Entry: %u) but `incrtime`=0, ignore", maxcount, item_id, vendor_entry);
return false;
}
else if (maxcount == 0 && incrtime > 0)
{
- if (pl)
- ChatHandler(pl).PSendSysMessage("MaxCount == 0 but IncrTime<>= 0");
+ if (player)
+ ChatHandler(player).PSendSysMessage("MaxCount == 0 but IncrTime<>= 0");
else
sLog->outErrorDb("Table `(game_event_)npc_vendor` has `maxcount`=0 for item %u of vendor (Entry: %u) but `incrtime`<>0, ignore", item_id, vendor_entry);
return false;
@@ -8558,8 +8548,8 @@ bool ObjectMgr::IsVendorItemValid(uint32 vendor_entry, uint32 item_id, int32 max
if (vItems->FindItemCostPair(item_id, ExtendedCost))
{
- if (pl)
- ChatHandler(pl).PSendSysMessage(LANG_ITEM_ALREADY_IN_LIST, item_id, ExtendedCost);
+ if (player)
+ ChatHandler(player).PSendSysMessage(LANG_ITEM_ALREADY_IN_LIST, item_id, ExtendedCost);
else
sLog->outErrorDb("Table `npc_vendor` has duplicate items %u (with extended cost %u) for vendor (Entry: %u), ignoring", item_id, ExtendedCost, vendor_entry);
return false;
@@ -8567,8 +8557,8 @@ bool ObjectMgr::IsVendorItemValid(uint32 vendor_entry, uint32 item_id, int32 max
if (vItems->GetItemCount() >= MAX_VENDOR_ITEMS)
{
- if (pl)
- ChatHandler(pl).SendSysMessage(LANG_COMMAND_ADDVENDORITEMITEMS);
+ if (player)
+ ChatHandler(player).SendSysMessage(LANG_COMMAND_ADDVENDORITEMITEMS);
else
sLog->outErrorDb("Table `npc_vendor` has too many items (%u >= %i) for vendor (Entry: %u), ignore", vItems->GetItemCount(), MAX_VENDOR_ITEMS, vendor_entry);
return false;
diff --git a/src/server/game/Globals/ObjectMgr.h b/src/server/game/Globals/ObjectMgr.h
index c557af1c2b2..88c593a009d 100755
--- a/src/server/game/Globals/ObjectMgr.h
+++ b/src/server/game/Globals/ObjectMgr.h
@@ -1076,14 +1076,14 @@ class ObjectMgr
time_t GetCreatureRespawnTime(uint32 loguid, uint32 instance)
{
- ACE_GUARD_RETURN(ACE_Thread_Mutex, guard, m_CreatureRespawnTimesMtx, 0);
+ TRINITY_GUARD(ACE_Thread_Mutex, m_CreatureRespawnTimesMtx);
return mCreatureRespawnTimes[MAKE_PAIR64(loguid, instance)];
}
void SaveCreatureRespawnTime(uint32 loguid, uint32 instance, time_t t);
void RemoveCreatureRespawnTime(uint32 loguid, uint32 instance);
time_t GetGORespawnTime(uint32 loguid, uint32 instance)
{
- ACE_GUARD_RETURN(ACE_Thread_Mutex, guard, m_GORespawnTimesMtx, 0);
+ TRINITY_GUARD(ACE_Thread_Mutex, m_GORespawnTimesMtx);
return mGORespawnTimes[MAKE_PAIR64(loguid, instance)];
}
void SaveGORespawnTime(uint32 loguid, uint32 instance, time_t t);
@@ -1140,7 +1140,7 @@ class ObjectMgr
}
void AddVendorItem(uint32 entry, uint32 item, int32 maxcount, uint32 incrtime, uint32 ExtendedCost, bool savetodb = true); // for event
bool RemoveVendorItem(uint32 entry, uint32 item, bool savetodb = true); // for event
- bool IsVendorItemValid(uint32 vendor_entry, uint32 item, int32 maxcount, uint32 ptime, uint32 ExtendedCost, Player* pl = NULL, std::set<uint32>* skip_vendors = NULL, uint32 ORnpcflag = 0) const;
+ bool IsVendorItemValid(uint32 vendor_entry, uint32 item, int32 maxcount, uint32 ptime, uint32 ExtendedCost, Player* player = NULL, std::set<uint32>* skip_vendors = NULL, uint32 ORnpcflag = 0) const;
void LoadScriptNames();
ScriptNameMap &GetScriptNames() { return m_scriptNames; }
diff --git a/src/server/game/Grids/Cells/Cell.h b/src/server/game/Grids/Cells/Cell.h
index a7fd879358e..13bb0afc494 100755
--- a/src/server/game/Grids/Cells/Cell.h
+++ b/src/server/game/Grids/Cells/Cell.h
@@ -29,87 +29,34 @@
class Map;
class WorldObject;
-enum District
-{
- UPPER_DISTRICT = 1,
- LOWER_DISTRICT = 1 << 1,
- LEFT_DISTRICT = 1 << 2,
- RIGHT_DISTRICT = 1 << 3,
- CENTER_DISTRICT = 1 << 4,
- UPPER_LEFT_DISTRICT = (UPPER_DISTRICT | LEFT_DISTRICT),
- UPPER_RIGHT_DISTRICT = (UPPER_DISTRICT | RIGHT_DISTRICT),
- LOWER_LEFT_DISTRICT = (LOWER_DISTRICT | LEFT_DISTRICT),
- LOWER_RIGHT_DISTRICT = (LOWER_DISTRICT | RIGHT_DISTRICT),
- ALL_DISTRICT = (UPPER_DISTRICT | LOWER_DISTRICT | LEFT_DISTRICT | RIGHT_DISTRICT | CENTER_DISTRICT)
-};
-
struct CellArea
{
- CellArea() : right_offset(0), left_offset(0), upper_offset(0), lower_offset(0) {}
- CellArea(int right, int left, int upper, int lower) : right_offset(right), left_offset(left), upper_offset(upper), lower_offset(lower) {}
- bool operator!() const { return !right_offset && !left_offset && !upper_offset && !lower_offset; }
+ CellArea() {}
+ CellArea(CellCoord low, CellCoord high) : low_bound(low), high_bound(high) {}
+
+ bool operator!() const { return low_bound == high_bound; }
- void ResizeBorders(CellPair& begin_cell, CellPair& end_cell) const
+ void ResizeBorders(CellCoord& begin_cell, CellCoord& end_cell) const
{
- begin_cell << left_offset;
- begin_cell -= lower_offset;
- end_cell >> right_offset;
- end_cell += upper_offset;
+ begin_cell = low_bound;
+ end_cell = high_bound;
}
- int right_offset;
- int left_offset;
- int upper_offset;
- int lower_offset;
+ CellCoord low_bound;
+ CellCoord high_bound;
};
struct Cell
{
Cell() { data.All = 0; }
- Cell(const Cell &cell) { data.All = cell.data.All; }
- explicit Cell(CellPair const& p);
-
- void operator|=(Cell &cell)
- {
- data.Part.reserved = 0;
- cell.data.Part.reserved = 0;
- uint32 x, y, old_x, old_y;
- Compute(x, y);
- cell.Compute(old_x, old_y);
-
- if (std::abs(int(x-old_x)) > 1 || std::abs(int(y-old_y)) > 1)
- {
- data.Part.reserved = ALL_DISTRICT;
- cell.data.Part.reserved = ALL_DISTRICT;
- return;
- }
-
- if (x < old_x)
- {
- data.Part.reserved |= LEFT_DISTRICT;
- cell.data.Part.reserved |= RIGHT_DISTRICT;
- }
- else if (old_x < x)
- {
- data.Part.reserved |= RIGHT_DISTRICT;
- cell.data.Part.reserved |= LEFT_DISTRICT;
- }
- if (y < old_y)
- {
- data.Part.reserved |= UPPER_DISTRICT;
- cell.data.Part.reserved |= LOWER_DISTRICT;
- }
- else if (old_y < y)
- {
- data.Part.reserved |= LOWER_DISTRICT;
- cell.data.Part.reserved |= UPPER_DISTRICT;
- }
- }
+ Cell(Cell const& cell) { data.All = cell.data.All; }
+ explicit Cell(CellCoord const& p);
+ explicit Cell(float x, float y);
void Compute(uint32 &x, uint32 &y) const
{
- x = data.Part.grid_x*MAX_NUMBER_OF_CELLS + data.Part.cell_x;
- y = data.Part.grid_y*MAX_NUMBER_OF_CELLS + data.Part.cell_y;
+ x = data.Part.grid_x * MAX_NUMBER_OF_CELLS + data.Part.cell_x;
+ y = data.Part.grid_y * MAX_NUMBER_OF_CELLS + data.Part.cell_y;
}
bool DiffCell(const Cell &cell) const
@@ -131,21 +78,21 @@ struct Cell
bool NoCreate() const { return data.Part.nocreate; }
void SetNoCreate() { data.Part.nocreate = 1; }
- CellPair cellPair() const
+ CellCoord GetCellCoord() const
{
- return CellPair(
- data.Part.grid_x*MAX_NUMBER_OF_CELLS+data.Part.cell_x,
- data.Part.grid_y*MAX_NUMBER_OF_CELLS+data.Part.cell_y);
+ return CellCoord(
+ data.Part.grid_x * MAX_NUMBER_OF_CELLS+data.Part.cell_x,
+ data.Part.grid_y * MAX_NUMBER_OF_CELLS+data.Part.cell_y);
}
- Cell& operator=(const Cell &cell)
+ Cell& operator=(Cell const& cell)
{
this->data.All = cell.data.All;
return *this;
}
- bool operator == (const Cell &cell) const { return (data.All == cell.data.All); }
- bool operator != (const Cell &cell) const { return !operator == (cell); }
+ bool operator == (Cell const& cell) const { return (data.All == cell.data.All); }
+ bool operator != (Cell const& cell) const { return !operator == (cell); }
union
{
struct
@@ -160,15 +107,13 @@ struct Cell
uint32 All;
} data;
- template<class T, class CONTAINER> void Visit(const CellPair&, TypeContainerVisitor<T, CONTAINER> &visitor, Map &) const;
- template<class T, class CONTAINER> void Visit(const CellPair&, TypeContainerVisitor<T, CONTAINER> &visitor, Map &, const WorldObject&, float) const;
- template<class T, class CONTAINER> void Visit(const CellPair&, TypeContainerVisitor<T, CONTAINER> &visitor, Map &, float, float, float) const;
+ template<class T, class CONTAINER> void Visit(CellCoord const&, TypeContainerVisitor<T, CONTAINER>& visitor, Map &, WorldObject const&, float) const;
+ template<class T, class CONTAINER> void Visit(CellCoord const&, TypeContainerVisitor<T, CONTAINER>& visitor, Map &, float, float, float) const;
- static CellArea CalculateCellArea(const WorldObject &obj, float radius);
static CellArea CalculateCellArea(float x, float y, float radius);
private:
- template<class T, class CONTAINER> void VisitCircle(TypeContainerVisitor<T, CONTAINER> &, Map &, const CellPair&, const CellPair&) const;
+ template<class T, class CONTAINER> void VisitCircle(TypeContainerVisitor<T, CONTAINER> &, Map &, CellCoord const&, CellCoord const&) const;
};
#endif
diff --git a/src/server/game/Grids/Cells/CellImpl.h b/src/server/game/Grids/Cells/CellImpl.h
index d36892ffcb0..af697b9f21d 100755..100644
--- a/src/server/game/Grids/Cells/CellImpl.h
+++ b/src/server/game/Grids/Cells/CellImpl.h
@@ -25,7 +25,7 @@
#include "Map.h"
#include "Object.h"
-inline Cell::Cell(CellPair const& p)
+inline Cell::Cell(CellCoord const& p)
{
data.Part.grid_x = p.x_coord / MAX_NUMBER_OF_CELLS;
data.Part.grid_y = p.y_coord / MAX_NUMBER_OF_CELLS;
@@ -35,143 +35,35 @@ inline Cell::Cell(CellPair const& p)
data.Part.reserved = 0;
}
-template<class T, class CONTAINER>
-inline void
-Cell::Visit(const CellPair& standing_cell, TypeContainerVisitor<T, CONTAINER> &visitor, Map &m) const
-{
- if (standing_cell.x_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP || standing_cell.y_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP)
- return;
-
- uint16 district = (District)this->data.Part.reserved;
- if (district == CENTER_DISTRICT)
- {
- m.Visit(*this, visitor);
- return;
- }
-
- // set up the cell range based on the district
- // the overloaded operators handle range checking
- CellPair begin_cell = standing_cell;
- CellPair end_cell = standing_cell;
-
- switch (district)
- {
- case ALL_DISTRICT:
- {
- begin_cell << 1; begin_cell -= 1; // upper left
- end_cell >> 1; end_cell += 1; // lower right
- break;
- }
- case UPPER_LEFT_DISTRICT:
- {
- begin_cell << 1; begin_cell -= 1; // upper left
- break;
- }
- case UPPER_RIGHT_DISTRICT:
- {
- begin_cell -= 1; // up
- end_cell >> 1; // right
- break;
- }
- case LOWER_LEFT_DISTRICT:
- {
- begin_cell << 1; // left
- end_cell += 1; // down
- break;
- }
- case LOWER_RIGHT_DISTRICT:
- {
- end_cell >> 1; end_cell += 1; // lower right
- break;
- }
- case LEFT_DISTRICT:
- {
- begin_cell -= 1; // up
- end_cell >> 1; end_cell += 1; // lower right
- break;
- }
- case RIGHT_DISTRICT:
- {
- begin_cell << 1; begin_cell -= 1; // upper left
- end_cell += 1; // down
- break;
- }
- case UPPER_DISTRICT:
- {
- begin_cell << 1; begin_cell -= 1; // upper left
- end_cell >> 1; // right
- break;
- }
- case LOWER_DISTRICT:
- {
- begin_cell << 1; // left
- end_cell >> 1; end_cell += 1; // lower right
- break;
- }
- default:
- {
- ASSERT(false);
- break;
- }
- }
-
- // loop the cell range
- for (uint32 x = begin_cell.x_coord; x <= end_cell.x_coord; x++)
- {
- for (uint32 y = begin_cell.y_coord; y <= end_cell.y_coord; y++)
- {
- CellPair cell_pair(x, y);
- Cell r_zone(cell_pair);
- r_zone.data.Part.nocreate = this->data.Part.nocreate;
- m.Visit(r_zone, visitor);
- }
- }
-}
-
-inline int CellHelper(const float radius)
-{
- if (radius < 1.0f)
- return 0;
-
- return (int)ceilf(radius/SIZE_OF_GRID_CELL);
-}
-
-inline CellArea Cell::CalculateCellArea(const WorldObject &obj, float radius)
+inline Cell::Cell(float x, float y)
{
- return Cell::CalculateCellArea(obj.GetPositionX(), obj.GetPositionY(), radius);
+ CellCoord p = Trinity::ComputeCellCoord(x, y);
+ data.Part.grid_x = p.x_coord / MAX_NUMBER_OF_CELLS;
+ data.Part.grid_y = p.y_coord / MAX_NUMBER_OF_CELLS;
+ data.Part.cell_x = p.x_coord % MAX_NUMBER_OF_CELLS;
+ data.Part.cell_y = p.y_coord % MAX_NUMBER_OF_CELLS;
+ data.Part.nocreate = 0;
+ data.Part.reserved = 0;
}
inline CellArea Cell::CalculateCellArea(float x, float y, float radius)
{
if (radius <= 0.0f)
- return CellArea();
-
- //lets calculate object coord offsets from cell borders.
- //TODO: add more correct/generic method for this task
- const float x_offset = (x - CENTER_GRID_CELL_OFFSET)/SIZE_OF_GRID_CELL;
- const float y_offset = (y - CENTER_GRID_CELL_OFFSET)/SIZE_OF_GRID_CELL;
-
- const float x_val = floor(x_offset + CENTER_GRID_CELL_ID + 0.5f);
- const float y_val = floor(y_offset + CENTER_GRID_CELL_ID + 0.5f);
-
- const float x_off = (x_offset - x_val + CENTER_GRID_CELL_ID) * SIZE_OF_GRID_CELL;
- const float y_off = (y_offset - y_val + CENTER_GRID_CELL_ID) * SIZE_OF_GRID_CELL;
+ {
+ CellCoord center = Trinity::ComputeCellCoord(x, y).normalize();
+ return CellArea(center, center);
+ }
- const float tmp_diff = radius - CENTER_GRID_CELL_OFFSET;
- //lets calculate upper/lower/right/left corners for cell search
- int right = CellHelper(tmp_diff + x_off);
- int left = CellHelper(tmp_diff - x_off);
- int upper = CellHelper(tmp_diff + y_off);
- int lower = CellHelper(tmp_diff - y_off);
+ CellCoord centerX = Trinity::ComputeCellCoord(x - radius, y - radius).normalize();
+ CellCoord centerY = Trinity::ComputeCellCoord(x + radius, y + radius).normalize();
- return CellArea(right, left, upper, lower);
+ return CellArea(centerX, centerY);
}
template<class T, class CONTAINER>
-inline void
-Cell::Visit(const CellPair& standing_cell, TypeContainerVisitor<T, CONTAINER> &visitor, Map &m, float radius, float x_off, float y_off) const
+inline void Cell::Visit(CellCoord const& standing_cell, TypeContainerVisitor<T, CONTAINER>& visitor, Map& map, float radius, float x_off, float y_off) const
{
- if (standing_cell.x_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP || standing_cell.y_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP)
+ if (!standing_cell.IsCoordValid())
return;
//no jokes here... Actually placing ASSERT() here was good idea, but
@@ -179,7 +71,7 @@ Cell::Visit(const CellPair& standing_cell, TypeContainerVisitor<T, CONTAINER> &v
//maybe it is better to just return when radius <= 0.0f?
if (radius <= 0.0f)
{
- m.Visit(*this, visitor);
+ map.Visit(*this, visitor);
return;
}
//lets limit the upper value for search radius
@@ -191,57 +83,51 @@ Cell::Visit(const CellPair& standing_cell, TypeContainerVisitor<T, CONTAINER> &v
//if radius fits inside standing cell
if (!area)
{
- m.Visit(*this, visitor);
+ map.Visit(*this, visitor);
return;
}
- CellPair begin_cell = standing_cell;
- CellPair end_cell = standing_cell;
-
- area.ResizeBorders(begin_cell, end_cell);
//visit all cells, found in CalculateCellArea()
//if radius is known to reach cell area more than 4x4 then we should call optimized VisitCircle
//currently this technique works with MAX_NUMBER_OF_CELLS 16 and higher, with lower values
//there are nothing to optimize because SIZE_OF_GRID_CELL is too big...
- if (((end_cell.x_coord - begin_cell.x_coord) > 4) && ((end_cell.y_coord - begin_cell.y_coord) > 4))
+ if (((area.high_bound.x_coord - area.low_bound.x_coord) > 4) && ((area.high_bound.y_coord - area.low_bound.y_coord) > 4))
{
- VisitCircle(visitor, m, begin_cell, end_cell);
+ VisitCircle(visitor, map, area.low_bound, area.high_bound);
return;
}
//ALWAYS visit standing cell first!!! Since we deal with small radiuses
//it is very essential to call visitor for standing cell firstly...
- m.Visit(*this, visitor);
+ map.Visit(*this, visitor);
// loop the cell range
- for (uint32 x = begin_cell.x_coord; x <= end_cell.x_coord; ++x)
+ for (uint32 x = area.low_bound.x_coord; x <= area.high_bound.x_coord; ++x)
{
- for (uint32 y = begin_cell.y_coord; y <= end_cell.y_coord; ++y)
+ for (uint32 y = area.low_bound.y_coord; y <= area.high_bound.y_coord; ++y)
{
- CellPair cell_pair(x, y);
+ CellCoord cellCoord(x, y);
//lets skip standing cell since we already visited it
- if (cell_pair != standing_cell)
+ if (cellCoord != standing_cell)
{
- Cell r_zone(cell_pair);
+ Cell r_zone(cellCoord);
r_zone.data.Part.nocreate = this->data.Part.nocreate;
- m.Visit(r_zone, visitor);
+ map.Visit(r_zone, visitor);
}
}
}
}
template<class T, class CONTAINER>
-inline void
-Cell::Visit(const CellPair& l, TypeContainerVisitor<T, CONTAINER> &visitor, Map &m, const WorldObject &obj, float radius) const
+inline void Cell::Visit(CellCoord const& standing_cell, TypeContainerVisitor<T, CONTAINER>& visitor, Map& map, WorldObject const& obj, float radius) const
{
//we should increase search radius by object's radius, otherwise
//we could have problems with huge creatures, which won't attack nearest players etc
- Visit(l, visitor, m, radius + obj.GetObjectSize(), obj.GetPositionX(), obj.GetPositionY());
+ Visit(standing_cell, visitor, map, radius + obj.GetObjectSize(), obj.GetPositionX(), obj.GetPositionY());
}
template<class T, class CONTAINER>
-inline void
-Cell::VisitCircle(TypeContainerVisitor<T, CONTAINER> &visitor, Map &m, const CellPair& begin_cell, const CellPair& end_cell) const
+inline void Cell::VisitCircle(TypeContainerVisitor<T, CONTAINER>& visitor, Map& map, CellCoord const& begin_cell, CellCoord const& end_cell) const
{
//here is an algorithm for 'filling' circum-squared octagon
uint32 x_shift = (uint32)ceilf((end_cell.x_coord - begin_cell.x_coord) * 0.3f - 0.5f);
@@ -254,10 +140,10 @@ Cell::VisitCircle(TypeContainerVisitor<T, CONTAINER> &visitor, Map &m, const Cel
{
for (uint32 y = begin_cell.y_coord; y <= end_cell.y_coord; ++y)
{
- CellPair cell_pair(x, y);
- Cell r_zone(cell_pair);
+ CellCoord cellCoord(x, y);
+ Cell r_zone(cellCoord);
r_zone.data.Part.nocreate = this->data.Part.nocreate;
- m.Visit(r_zone, visitor);
+ map.Visit(r_zone, visitor);
}
}
@@ -278,16 +164,16 @@ Cell::VisitCircle(TypeContainerVisitor<T, CONTAINER> &visitor, Map &m, const Cel
{
//we visit cells symmetrically from both sides, heading from center to sides and from up to bottom
//e.g. filling 2 trapezoids after filling central cell strip...
- CellPair cell_pair_left(x_start - step, y);
- Cell r_zone_left(cell_pair_left);
+ CellCoord cellCoord_left(x_start - step, y);
+ Cell r_zone_left(cellCoord_left);
r_zone_left.data.Part.nocreate = this->data.Part.nocreate;
- m.Visit(r_zone_left, visitor);
+ map.Visit(r_zone_left, visitor);
//right trapezoid cell visit
- CellPair cell_pair_right(x_end + step, y);
- Cell r_zone_right(cell_pair_right);
+ CellCoord cellCoord_right(x_end + step, y);
+ Cell r_zone_right(cellCoord_right);
r_zone_right.data.Part.nocreate = this->data.Part.nocreate;
- m.Visit(r_zone_right, visitor);
+ map.Visit(r_zone_right, visitor);
}
}
}
diff --git a/src/server/game/Grids/Grid.h b/src/server/game/Grids/Grid.h
index a6e1316718e..448c4cb35fd 100755
--- a/src/server/game/Grids/Grid.h
+++ b/src/server/game/Grids/Grid.h
@@ -58,40 +58,42 @@ class Grid
*/
template<class SPECIFIC_OBJECT> void AddWorldObject(SPECIFIC_OBJECT *obj)
{
- if (!i_objects.template insert<SPECIFIC_OBJECT>(obj))
- ASSERT(false);
+ i_objects.template insert<SPECIFIC_OBJECT>(obj);
+ ASSERT(obj->IsInGrid());
}
/** an object of interested exits the grid
*/
- template<class SPECIFIC_OBJECT> void RemoveWorldObject(SPECIFIC_OBJECT *obj)
- {
- if (!i_objects.template remove<SPECIFIC_OBJECT>(obj))
- ASSERT(false);
- }
+ //Actually an unlink is enough, no need to go through the container
+ //template<class SPECIFIC_OBJECT> void RemoveWorldObject(SPECIFIC_OBJECT *obj)
+ //{
+ // ASSERT(obj->GetGridRef().isValid());
+ // i_objects.template remove<SPECIFIC_OBJECT>(obj);
+ // ASSERT(!obj->GetGridRef().isValid());
+ //}
/** Refreshes/update the grid. This required for remote grids.
*/
- void RefreshGrid(void) { /* TBI */}
+ //void RefreshGrid(void) { /* TBI */}
/** Locks a grid. Any object enters must wait until the grid is unlock.
*/
- void LockGrid(void) { /* TBI */ }
+ //void LockGrid(void) { /* TBI */ }
/** Unlocks the grid.
*/
- void UnlockGrid(void) { /* TBI */ }
+ //void UnlockGrid(void) { /* TBI */ }
- /** Grid visitor for grid objects
- */
- template<class T> void Visit(TypeContainerVisitor<T, TypeMapContainer<GRID_OBJECT_TYPES> > &visitor)
+ // Visit grid objects
+ template<class T>
+ void Visit(TypeContainerVisitor<T, TypeMapContainer<GRID_OBJECT_TYPES> > &visitor)
{
visitor.Visit(i_container);
}
- /** Grid visitor for world objects
- */
- template<class T> void Visit(TypeContainerVisitor<T, TypeMapContainer<WORLD_OBJECT_TYPES> > &visitor)
+ // Visit world objects
+ template<class T>
+ void Visit(TypeContainerVisitor<T, TypeMapContainer<WORLD_OBJECT_TYPES> > &visitor)
{
visitor.Visit(i_objects);
}
@@ -104,17 +106,18 @@ class Grid
*/
template<class SPECIFIC_OBJECT> void AddGridObject(SPECIFIC_OBJECT *obj)
{
- if (!i_container.template insert<SPECIFIC_OBJECT>(obj))
- ASSERT(false);
+ i_container.template insert<SPECIFIC_OBJECT>(obj);
+ ASSERT(obj->IsInGrid());
}
/** Removes a containter type object from the grid
*/
- template<class SPECIFIC_OBJECT> void RemoveGridObject(SPECIFIC_OBJECT *obj)
- {
- if (!i_container.template remove<SPECIFIC_OBJECT>(obj))
- ASSERT(false);
- }
+ //template<class SPECIFIC_OBJECT> void RemoveGridObject(SPECIFIC_OBJECT *obj)
+ //{
+ // ASSERT(obj->GetGridRef().isValid());
+ // i_container.template remove<SPECIFIC_OBJECT>(obj);
+ // ASSERT(!obj->GetGridRef().isValid());
+ //}
/*bool NoWorldObjectInGrid() const
{
diff --git a/src/server/game/Grids/GridDefines.h b/src/server/game/Grids/GridDefines.h
index a284e342ca9..44e2588ef81 100755..100644
--- a/src/server/game/Grids/GridDefines.h
+++ b/src/server/game/Grids/GridDefines.h
@@ -71,21 +71,27 @@ typedef NGrid<MAX_NUMBER_OF_CELLS, Player, AllWorldObjectTypes, AllGridObjectTyp
typedef TypeMapContainer<AllGridObjectTypes> GridTypeMapContainer;
typedef TypeMapContainer<AllWorldObjectTypes> WorldTypeMapContainer;
-template<const unsigned int LIMIT>
+template<uint32 LIMIT>
struct CoordPair
{
- CoordPair(uint32 x=0, uint32 y=0) : x_coord(x), y_coord(y) {}
- CoordPair(const CoordPair<LIMIT> &obj) : x_coord(obj.x_coord), y_coord(obj.y_coord) {}
- bool operator == (const CoordPair<LIMIT> &obj) const { return (obj.x_coord == x_coord && obj.y_coord == y_coord); }
- bool operator != (const CoordPair<LIMIT> &obj) const { return !operator == (obj); }
- CoordPair<LIMIT>& operator=(const CoordPair<LIMIT> &obj)
+ CoordPair(uint32 x=0, uint32 y=0)
+ : x_coord(x)
+ , y_coord(y)
+ {}
+
+ CoordPair(const CoordPair<LIMIT> &obj)
+ : x_coord(obj.x_coord)
+ , y_coord(obj.y_coord)
+ {}
+
+ CoordPair<LIMIT> & operator=(const CoordPair<LIMIT> &obj)
{
x_coord = obj.x_coord;
y_coord = obj.y_coord;
return *this;
}
- void operator<<(const uint32 val)
+ void dec_x(uint32 val)
{
if (x_coord > val)
x_coord -= val;
@@ -93,15 +99,15 @@ struct CoordPair
x_coord = 0;
}
- void operator>>(const uint32 val)
+ void inc_x(uint32 val)
{
- if (x_coord+val < LIMIT)
+ if (x_coord + val < LIMIT)
x_coord += val;
else
x_coord = LIMIT - 1;
}
- void operator-=(const uint32 val)
+ void dec_y(uint32 val)
{
if (y_coord > val)
y_coord -= val;
@@ -109,20 +115,44 @@ struct CoordPair
y_coord = 0;
}
- void operator+=(const uint32 val)
+ void inc_y(uint32 val)
{
- if (y_coord+val < LIMIT)
+ if (y_coord + val < LIMIT)
y_coord += val;
else
y_coord = LIMIT - 1;
}
+ bool IsCoordValid() const
+ {
+ return x_coord < LIMIT && y_coord < LIMIT;
+ }
+
+ CoordPair& normalize()
+ {
+ x_coord = std::min(x_coord, LIMIT - 1);
+ y_coord = std::min(y_coord, LIMIT - 1);
+ return *this;
+ }
+
uint32 x_coord;
uint32 y_coord;
};
-typedef CoordPair<MAX_NUMBER_OF_GRIDS> GridPair;
-typedef CoordPair<TOTAL_NUMBER_OF_CELLS_PER_MAP> CellPair;
+template<uint32 LIMIT>
+bool operator==(const CoordPair<LIMIT> &p1, const CoordPair<LIMIT> &p2)
+{
+ return (p1.x_coord == p2.x_coord && p1.y_coord == p2.y_coord);
+}
+
+template<uint32 LIMIT>
+bool operator!=(const CoordPair<LIMIT> &p1, const CoordPair<LIMIT> &p2)
+{
+ return !(p1 == p2);
+}
+
+typedef CoordPair<MAX_NUMBER_OF_GRIDS> GridCoord;
+typedef CoordPair<TOTAL_NUMBER_OF_CELLS_PER_MAP> CellCoord;
namespace Trinity
{
@@ -133,44 +163,44 @@ namespace Trinity
double x_offset = (double(x) - center_offset)/size;
double y_offset = (double(y) - center_offset)/size;
- int x_val = int(x_offset+CENTER_VAL + 0.5);
- int y_val = int(y_offset+CENTER_VAL + 0.5);
+ int x_val = int(x_offset+CENTER_VAL + 0.5f);
+ int y_val = int(y_offset+CENTER_VAL + 0.5f);
return RET_TYPE(x_val, y_val);
}
- inline GridPair ComputeGridPair(float x, float y)
+ inline GridCoord ComputeGridCoord(float x, float y)
{
- return Compute<GridPair, CENTER_GRID_ID>(x, y, CENTER_GRID_OFFSET, SIZE_OF_GRIDS);
+ return Compute<GridCoord, CENTER_GRID_ID>(x, y, CENTER_GRID_OFFSET, SIZE_OF_GRIDS);
}
- inline CellPair ComputeCellPair(float x, float y)
+ inline CellCoord ComputeCellCoord(float x, float y)
{
- return Compute<CellPair, CENTER_GRID_CELL_ID>(x, y, CENTER_GRID_CELL_OFFSET, SIZE_OF_GRID_CELL);
+ return Compute<CellCoord, CENTER_GRID_CELL_ID>(x, y, CENTER_GRID_CELL_OFFSET, SIZE_OF_GRID_CELL);
}
- inline CellPair ComputeCellPair(float x, float y, float &x_off, float &y_off)
+ inline CellCoord ComputeCellCoord(float x, float y, float &x_off, float &y_off)
{
double x_offset = (double(x) - CENTER_GRID_CELL_OFFSET)/SIZE_OF_GRID_CELL;
double y_offset = (double(y) - CENTER_GRID_CELL_OFFSET)/SIZE_OF_GRID_CELL;
- int x_val = int(x_offset + CENTER_GRID_CELL_ID + 0.5);
- int y_val = int(y_offset + CENTER_GRID_CELL_ID + 0.5);
+ int x_val = int(x_offset + CENTER_GRID_CELL_ID + 0.5f);
+ int y_val = int(y_offset + CENTER_GRID_CELL_ID + 0.5f);
x_off = (float(x_offset) - x_val + CENTER_GRID_CELL_ID) * SIZE_OF_GRID_CELL;
y_off = (float(y_offset) - y_val + CENTER_GRID_CELL_ID) * SIZE_OF_GRID_CELL;
- return CellPair(x_val, y_val);
+ return CellCoord(x_val, y_val);
}
inline void NormalizeMapCoord(float &c)
{
- if (c > MAP_HALFSIZE - 0.5)
- c = MAP_HALFSIZE - 0.5;
- else if (c < -(MAP_HALFSIZE - 0.5))
- c = -(MAP_HALFSIZE - 0.5);
+ if (c > MAP_HALFSIZE - 0.5f)
+ c = MAP_HALFSIZE - 0.5f;
+ else if (c < -(MAP_HALFSIZE - 0.5f))
+ c = -(MAP_HALFSIZE - 0.5f);
}
inline bool IsValidMapCoord(float c)
{
- return finite(c) && (std::fabs(c) <= MAP_HALFSIZE - 0.5);
+ return finite(c) && (std::fabs(c) <= MAP_HALFSIZE - 0.5f);
}
inline bool IsValidMapCoord(float x, float y)
diff --git a/src/server/game/Grids/GridLoader.h b/src/server/game/Grids/GridLoader.h
index 0e762d3a07e..43564c920e2 100755
--- a/src/server/game/Grids/GridLoader.h
+++ b/src/server/game/Grids/GridLoader.h
@@ -30,6 +30,8 @@
GridLoader manages the grid (both local and remote).
*/
+//I cannot see why this cannot be replaced by a Grid::Visit
+/*
#include "Define.h"
#include "Grid.h"
#include "TypeContainerVisitor.h"
@@ -44,8 +46,7 @@ class GridLoader
{
public:
- /** Loads the grid
- */
+ // Loads the grid
template<class LOADER>
void Load(Grid<ACTIVE_OBJECT, WORLD_OBJECT_TYPES, GRID_OBJECT_TYPES> &grid, LOADER &loader)
{
@@ -54,8 +55,7 @@ class GridLoader
grid.UnlockGrid();
}
- /** Stop the grid
- */
+ // Stop the grid
template<class STOPER>
void Stop(Grid<ACTIVE_OBJECT, WORLD_OBJECT_TYPES, GRID_OBJECT_TYPES> &grid, STOPER &stoper)
{
@@ -63,8 +63,8 @@ class GridLoader
stoper.Stop(grid);
grid.UnlockGrid();
}
- /** Unloads the grid
- */
+
+ // Unloads the grid
template<class UNLOADER>
void Unload(Grid<ACTIVE_OBJECT, WORLD_OBJECT_TYPES, GRID_OBJECT_TYPES> &grid, UNLOADER &unloader)
{
@@ -73,5 +73,6 @@ class GridLoader
grid.UnlockGrid();
}
};
+*/
#endif
diff --git a/src/server/game/Grids/GridStates.cpp b/src/server/game/Grids/GridStates.cpp
index 91bb926fd02..5f88516c9ac 100755
--- a/src/server/game/Grids/GridStates.cpp
+++ b/src/server/game/Grids/GridStates.cpp
@@ -21,24 +21,23 @@
#include "Grid.h"
#include "Log.h"
-void
-InvalidState::Update(Map &, NGridType &, GridInfo &, const uint32 /*x*/, const uint32 /*y*/, const uint32) const
+void InvalidState::Update(Map &, NGridType &, GridInfo &, const uint32) const
{
}
-void
-ActiveState::Update(Map &m, NGridType &grid, GridInfo & info, const uint32 x, const uint32 y, const uint32 t_diff) const
+void ActiveState::Update(Map &m, NGridType &grid, GridInfo & info, const uint32 t_diff) const
{
// Only check grid activity every (grid_expiry/10) ms, because it's really useless to do it every cycle
info.UpdateTimeTracker(t_diff);
if (info.getTimeTracker().Passed())
{
- if (grid.ActiveObjectsInGrid() == 0 && !m.ActiveObjectsNearGrid(x, y))
+ if (grid.ActiveObjectsInGrid() == 0 && !m.ActiveObjectsNearGrid(grid))
{
- ObjectGridStoper stoper(grid);
- stoper.StopN();
+ ObjectGridStoper worker;
+ TypeContainerVisitor<ObjectGridStoper, GridTypeMapContainer> visitor(worker);
+ grid.VisitAllGrids(visitor);
grid.SetGridState(GRID_STATE_IDLE);
- sLog->outDebug(LOG_FILTER_MAPS, "Grid[%u, %u] on map %u moved to IDLE state", x, y, m.GetId());
+ sLog->outDebug(LOG_FILTER_MAPS, "Grid[%u, %u] on map %u moved to IDLE state", grid.getX(), grid.getY(), m.GetId());
}
else
{
@@ -47,25 +46,23 @@ ActiveState::Update(Map &m, NGridType &grid, GridInfo & info, const uint32 x, co
}
}
-void
-IdleState::Update(Map &m, NGridType &grid, GridInfo &, const uint32 x, const uint32 y, const uint32) const
+void IdleState::Update(Map &m, NGridType &grid, GridInfo &, const uint32) const
{
m.ResetGridExpiry(grid);
grid.SetGridState(GRID_STATE_REMOVAL);
- sLog->outDebug(LOG_FILTER_MAPS, "Grid[%u, %u] on map %u moved to REMOVAL state", x, y, m.GetId());
+ sLog->outDebug(LOG_FILTER_MAPS, "Grid[%u, %u] on map %u moved to REMOVAL state", grid.getX(), grid.getY(), m.GetId());
}
-void
-RemovalState::Update(Map &m, NGridType &grid, GridInfo &info, const uint32 x, const uint32 y, const uint32 t_diff) const
+void RemovalState::Update(Map &m, NGridType &grid, GridInfo &info, const uint32 t_diff) const
{
if (!info.getUnloadLock())
{
info.UpdateTimeTracker(t_diff);
if (info.getTimeTracker().Passed())
{
- if (!m.UnloadGrid(x, y, false))
+ if (!m.UnloadGrid(grid, false))
{
- sLog->outDebug(LOG_FILTER_MAPS, "Grid[%u, %u] for map %u differed unloading due to players or active objects nearby", x, y, m.GetId());
+ sLog->outDebug(LOG_FILTER_MAPS, "Grid[%u, %u] for map %u differed unloading due to players or active objects nearby", grid.getX(), grid.getY(), m.GetId());
m.ResetGridExpiry(grid);
}
}
diff --git a/src/server/game/Grids/GridStates.h b/src/server/game/Grids/GridStates.h
index 81bf749b63f..78f70356608 100755
--- a/src/server/game/Grids/GridStates.h
+++ b/src/server/game/Grids/GridStates.h
@@ -40,35 +40,31 @@ class GridState
void setMagic() { i_Magic = MAGIC_TESTVAL; }
unsigned int i_Magic;
#endif
- virtual void Update(Map &, NGridType&, GridInfo &, const uint32 x, const uint32 y, const uint32 t_diff) const = 0;
+ virtual void Update(Map &, NGridType&, GridInfo &, const uint32 t_diff) const = 0;
};
class InvalidState : public GridState
{
public:
-
- void Update(Map &, NGridType &, GridInfo &, const uint32 x, const uint32 y, const uint32 t_diff) const;
+ void Update(Map &, NGridType &, GridInfo &, const uint32 t_diff) const;
};
class ActiveState : public GridState
{
public:
-
- void Update(Map &, NGridType &, GridInfo &, const uint32 x, const uint32 y, const uint32 t_diff) const;
+ void Update(Map &, NGridType &, GridInfo &, const uint32 t_diff) const;
};
class IdleState : public GridState
{
public:
-
- void Update(Map &, NGridType &, GridInfo &, const uint32 x, const uint32 y, const uint32 t_diff) const;
+ void Update(Map &, NGridType &, GridInfo &, const uint32 t_diff) const;
};
class RemovalState : public GridState
{
public:
-
- void Update(Map &, NGridType &, GridInfo &, const uint32 x, const uint32 y, const uint32 t_diff) const;
+ void Update(Map &, NGridType &, GridInfo &, const uint32 t_diff) const;
};
#endif
diff --git a/src/server/game/Grids/NGrid.h b/src/server/game/Grids/NGrid.h
index cd2345e439d..97a47f7d272 100755
--- a/src/server/game/Grids/NGrid.h
+++ b/src/server/game/Grids/NGrid.h
@@ -69,7 +69,7 @@ typedef enum
template
<
-unsigned int N,
+uint32 N,
class ACTIVE_OBJECT,
class WORLD_OBJECT_TYPES,
class GRID_OBJECT_TYPES
@@ -77,7 +77,6 @@ class GRID_OBJECT_TYPES
class NGrid
{
public:
-
typedef Grid<ACTIVE_OBJECT, WORLD_OBJECT_TYPES, GRID_OBJECT_TYPES> GridType;
NGrid(uint32 id, int32 x, int32 y, time_t expiry, bool unload = true)
: i_gridId(id), i_x(x), i_y(y), i_cellstate(GRID_STATE_INVALID), i_GridObjectDataLoaded(false)
@@ -85,17 +84,15 @@ class NGrid
i_GridInfo = GridInfo(expiry, unload);
}
- const GridType& operator()(unsigned short x, unsigned short y) const
+ GridType& GetGridType(const uint32 x, const uint32 y)
{
- ASSERT(x < N);
- ASSERT(y < N);
+ ASSERT(x < N && y < N);
return i_cells[x][y];
}
- GridType& operator()(unsigned short x, unsigned short y)
+ GridType const& GetGridType(const uint32 x, const uint32 y) const
{
- ASSERT(x < N);
- ASSERT(y < N);
+ ASSERT(x < N && y < N);
return i_cells[x][y];
}
@@ -123,56 +120,54 @@ class NGrid
void ResetTimeTracker(time_t interval) { i_GridInfo.ResetTimeTracker(interval); }
void UpdateTimeTracker(time_t diff) { i_GridInfo.UpdateTimeTracker(diff); }
+ /*
template<class SPECIFIC_OBJECT> void AddWorldObject(const uint32 x, const uint32 y, SPECIFIC_OBJECT *obj)
{
- getGridType(x, y).AddWorldObject(obj);
+ GetGridType(x, y).AddWorldObject(obj);
}
template<class SPECIFIC_OBJECT> void RemoveWorldObject(const uint32 x, const uint32 y, SPECIFIC_OBJECT *obj)
{
- getGridType(x, y).RemoveWorldObject(obj);
+ GetGridType(x, y).RemoveWorldObject(obj);
}
- template<class T, class TT> void Visit(TypeContainerVisitor<T, TypeMapContainer<TT> > &visitor)
+ template<class SPECIFIC_OBJECT> void AddGridObject(const uint32 x, const uint32 y, SPECIFIC_OBJECT *obj)
{
- for (unsigned int x=0; x < N; ++x)
- for (unsigned int y=0; y < N; ++y)
- getGridType(x, y).Visit(visitor);
+ GetGridType(x, y).AddGridObject(obj);
}
- template<class T, class TT> void Visit(const uint32 x, const uint32 y, TypeContainerVisitor<T, TypeMapContainer<TT> > &visitor)
+ template<class SPECIFIC_OBJECT> void RemoveGridObject(const uint32 x, const uint32 y, SPECIFIC_OBJECT *obj)
{
- getGridType(x, y).Visit(visitor);
+ GetGridType(x, y).RemoveGridObject(obj);
}
+ */
- unsigned int ActiveObjectsInGrid(void) const
+ // Visit all Grids (cells) in NGrid (grid)
+ template<class T, class TT>
+ void VisitAllGrids(TypeContainerVisitor<T, TypeMapContainer<TT> > &visitor)
{
- unsigned int count=0;
- for (unsigned int x=0; x < N; ++x)
- for (unsigned int y=0; y < N; ++y)
- count += i_cells[x][y].ActiveObjectsInGrid();
- return count;
+ for (uint32 x = 0; x < N; ++x)
+ for (uint32 y = 0; y < N; ++y)
+ GetGridType(x, y).Visit(visitor);
}
- template<class SPECIFIC_OBJECT> bool AddGridObject(const uint32 x, const uint32 y, SPECIFIC_OBJECT *obj)
+ // Visit a single Grid (cell) in NGrid (grid)
+ template<class T, class TT>
+ void VisitGrid(const uint32 x, const uint32 y, TypeContainerVisitor<T, TypeMapContainer<TT> > &visitor)
{
- return getGridType(x, y).AddGridObject(obj);
+ GetGridType(x, y).Visit(visitor);
}
- template<class SPECIFIC_OBJECT> bool RemoveGridObject(const uint32 x, const uint32 y, SPECIFIC_OBJECT *obj)
+ unsigned int ActiveObjectsInGrid(void) const
{
- return getGridType(x, y).RemoveGridObject(obj);
+ unsigned int count=0;
+ for (unsigned int x=0; x < N; ++x)
+ for (unsigned int y=0; y < N; ++y)
+ count += i_cells[x][y].ActiveObjectsInGrid();
+ return count;
}
private:
-
- GridType& getGridType(const uint32 x, const uint32 y)
- {
- ASSERT(x < N);
- ASSERT(y < N);
- return i_cells[x][y];
- }
-
uint32 i_gridId;
GridInfo i_GridInfo;
GridReference<NGrid<N, ACTIVE_OBJECT, WORLD_OBJECT_TYPES, GRID_OBJECT_TYPES> > i_Reference;
diff --git a/src/server/game/Grids/Notifiers/GridNotifiers.cpp b/src/server/game/Grids/Notifiers/GridNotifiers.cpp
index dc938859e92..ca61a82e840 100755
--- a/src/server/game/Grids/Notifiers/GridNotifiers.cpp
+++ b/src/server/game/Grids/Notifiers/GridNotifiers.cpp
@@ -30,8 +30,7 @@
using namespace Trinity;
-void
-VisibleNotifier::SendToSelf()
+void VisibleNotifier::SendToSelf()
{
// at this moment i_clientGUIDs have guids that not iterate at grid level checks
// but exist one case when this possible and object not out of range: transports
@@ -56,9 +55,9 @@ VisibleNotifier::SendToSelf()
if (IS_PLAYER_GUID(*it))
{
- Player* plr = ObjectAccessor::FindPlayer(*it);
- if (plr && plr->IsInWorld() && !plr->isNeedNotify(NOTIFY_VISIBILITY_CHANGED))
- plr->UpdateVisibilityOf(&i_player);
+ Player* player = ObjectAccessor::FindPlayer(*it);
+ if (player && player->IsInWorld() && !player->isNeedNotify(NOTIFY_VISIBILITY_CHANGED))
+ player->UpdateVisibilityOf(&i_player);
}
}
@@ -73,10 +72,9 @@ VisibleNotifier::SendToSelf()
i_player.SendInitialVisiblePackets(*it);
}
-void
-VisibleChangesNotifier::Visit(PlayerMapType &m)
+void VisibleChangesNotifier::Visit(PlayerMapType &m)
{
- for (PlayerMapType::iterator iter=m.begin(); iter != m.end(); ++iter)
+ for (PlayerMapType::iterator iter = m.begin(); iter != m.end(); ++iter)
{
if (iter->getSource() == &i_object)
continue;
@@ -91,8 +89,7 @@ VisibleChangesNotifier::Visit(PlayerMapType &m)
}
}
-void
-VisibleChangesNotifier::Visit(CreatureMapType &m)
+void VisibleChangesNotifier::Visit(CreatureMapType &m)
{
for (CreatureMapType::iterator iter = m.begin(); iter != m.end(); ++iter)
if (!iter->getSource()->GetSharedVisionList().empty())
@@ -102,8 +99,7 @@ VisibleChangesNotifier::Visit(CreatureMapType &m)
(*i)->UpdateVisibilityOf(&i_object);
}
-void
-VisibleChangesNotifier::Visit(DynamicObjectMapType &m)
+void VisibleChangesNotifier::Visit(DynamicObjectMapType &m)
{
for (DynamicObjectMapType::iterator iter = m.begin(); iter != m.end(); ++iter)
if (IS_PLAYER_GUID(iter->getSource()->GetCasterGUID()))
@@ -126,16 +122,16 @@ void PlayerRelocationNotifier::Visit(PlayerMapType &m)
{
for (PlayerMapType::iterator iter=m.begin(); iter != m.end(); ++iter)
{
- Player* plr = iter->getSource();
+ Player* player = iter->getSource();
- vis_guids.erase(plr->GetGUID());
+ vis_guids.erase(player->GetGUID());
- i_player.UpdateVisibilityOf(plr, i_data, i_visibleNow);
+ i_player.UpdateVisibilityOf(player, i_data, i_visibleNow);
- if (plr->m_seer->isNeedNotify(NOTIFY_VISIBILITY_CHANGED))
+ if (player->m_seer->isNeedNotify(NOTIFY_VISIBILITY_CHANGED))
continue;
- plr->UpdateVisibilityOf(&i_player);
+ player->UpdateVisibilityOf(&i_player);
}
}
@@ -160,12 +156,12 @@ void CreatureRelocationNotifier::Visit(PlayerMapType &m)
{
for (PlayerMapType::iterator iter=m.begin(); iter != m.end(); ++iter)
{
- Player* pl = iter->getSource();
+ Player* player = iter->getSource();
- if (!pl->m_seer->isNeedNotify(NOTIFY_VISIBILITY_CHANGED))
- pl->UpdateVisibilityOf(&i_creature);
+ if (!player->m_seer->isNeedNotify(NOTIFY_VISIBILITY_CHANGED))
+ player->UpdateVisibilityOf(&i_creature);
- CreatureUnitRelocationWorker(&i_creature, pl);
+ CreatureUnitRelocationWorker(&i_creature, player);
}
}
@@ -215,7 +211,7 @@ void DelayedUnitRelocation::Visit(PlayerMapType &m)
if (player != viewPoint && !viewPoint->IsPositionValid())
continue;
- CellPair pair2(Trinity::ComputeCellPair(viewPoint->GetPositionX(), viewPoint->GetPositionY()));
+ CellCoord pair2(Trinity::ComputeCellCoord(viewPoint->GetPositionX(), viewPoint->GetPositionY()));
Cell cell2(pair2);
//cell.SetNoCreate(); need load cells around viewPoint or player, that's why its commented
@@ -241,8 +237,7 @@ void AIRelocationNotifier::Visit(CreatureMapType &m)
}
}
-void
-MessageDistDeliverer::Visit(PlayerMapType &m)
+void MessageDistDeliverer::Visit(PlayerMapType &m)
{
for (PlayerMapType::iterator iter = m.begin(); iter != m.end(); ++iter)
{
@@ -312,17 +307,17 @@ void MessageDistDeliverer::Visit(DynamicObjectMapType &m)
/*
void
-MessageDistDeliverer::VisitObject(Player* plr)
+MessageDistDeliverer::VisitObject(Player* player)
{
- if (!i_ownTeamOnly || (i_source.GetTypeId() == TYPEID_PLAYER && plr->GetTeam() == ((Player&)i_source).GetTeam()))
+ if (!i_ownTeamOnly || (i_source.GetTypeId() == TYPEID_PLAYER && player->GetTeam() == ((Player&)i_source).GetTeam()))
{
- SendPacket(plr);
+ SendPacket(player);
}
}
*/
-template<class T> void
-ObjectUpdater::Visit(GridRefManager<T> &m)
+template<class T>
+void ObjectUpdater::Visit(GridRefManager<T> &m)
{
for (typename GridRefManager<T>::iterator iter = m.begin(); iter != m.end(); ++iter)
{
diff --git a/src/server/game/Grids/Notifiers/GridNotifiers.h b/src/server/game/Grids/Notifiers/GridNotifiers.h
index 0cd15143cee..239c3710b5b 100755
--- a/src/server/game/Grids/Notifiers/GridNotifiers.h
+++ b/src/server/game/Grids/Notifiers/GridNotifiers.h
@@ -61,7 +61,7 @@ namespace Trinity
struct PlayerRelocationNotifier : public VisibleNotifier
{
- PlayerRelocationNotifier(Player &pl) : VisibleNotifier(pl) {}
+ PlayerRelocationNotifier(Player &player) : VisibleNotifier(player) {}
template<class T> void Visit(GridRefManager<T> &m) { VisibleNotifier::Visit(m); }
void Visit(CreatureMapType &);
@@ -81,9 +81,9 @@ namespace Trinity
{
Map &i_map;
Cell &cell;
- CellPair &p;
+ CellCoord &p;
const float i_radius;
- DelayedUnitRelocation(Cell &c, CellPair &pair, Map &map, float radius) :
+ DelayedUnitRelocation(Cell &c, CellCoord &pair, Map &map, float radius) :
i_map(map), cell(c), p(pair), i_radius(radius) {}
template<class T> void Visit(GridRefManager<T> &) {}
void Visit(CreatureMapType &);
@@ -137,16 +137,16 @@ namespace Trinity
void Visit(DynamicObjectMapType &m);
template<class SKIP> void Visit(GridRefManager<SKIP> &) {}
- void SendPacket(Player* plr)
+ void SendPacket(Player* player)
{
// never send packet to self
- if (plr == i_source || (team && plr->GetTeam() != team) || skipped_receiver == plr)
+ if (player == i_source || (team && player->GetTeam() != team) || skipped_receiver == player)
return;
- if (!plr->HaveAtClient(i_source))
+ if (!player->HaveAtClient(i_source))
return;
- if (WorldSession* session = plr->GetSession())
+ if (WorldSession* session = player->GetSession())
session->SendPacket(i_message);
}
};
diff --git a/src/server/game/Grids/Notifiers/GridNotifiersImpl.h b/src/server/game/Grids/Notifiers/GridNotifiersImpl.h
index dcd4207e3e1..543a1d1e280 100755
--- a/src/server/game/Grids/Notifiers/GridNotifiersImpl.h
+++ b/src/server/game/Grids/Notifiers/GridNotifiersImpl.h
@@ -28,8 +28,7 @@
#include "SpellAuras.h"
template<class T>
-inline void
-Trinity::VisibleNotifier::Visit(GridRefManager<T> &m)
+inline void Trinity::VisibleNotifier::Visit(GridRefManager<T> &m)
{
for (typename GridRefManager<T>::iterator iter = m.begin(); iter != m.end(); ++iter)
{
@@ -38,8 +37,7 @@ Trinity::VisibleNotifier::Visit(GridRefManager<T> &m)
}
}
-inline void
-Trinity::ObjectUpdater::Visit(CreatureMapType &m)
+inline void Trinity::ObjectUpdater::Visit(CreatureMapType &m)
{
for (CreatureMapType::iterator iter = m.begin(); iter != m.end(); ++iter)
if (iter->getSource()->IsInWorld())
diff --git a/src/server/game/Grids/ObjectGridLoader.cpp b/src/server/game/Grids/ObjectGridLoader.cpp
index ee488f404dc..56c6410e6d7 100755
--- a/src/server/game/Grids/ObjectGridLoader.cpp
+++ b/src/server/game/Grids/ObjectGridLoader.cpp
@@ -28,26 +28,7 @@
#include "CellImpl.h"
#include "CreatureAI.h"
-class ObjectGridRespawnMover
-{
- public:
- ObjectGridRespawnMover() {}
-
- void Move(GridType &grid);
-
- template<class T> void Visit(GridRefManager<T> &) {}
- void Visit(CreatureMapType &m);
-};
-
-void
-ObjectGridRespawnMover::Move(GridType &grid)
-{
- TypeContainerVisitor<ObjectGridRespawnMover, GridTypeMapContainer > mover(*this);
- grid.Visit(mover);
-}
-
-void
-ObjectGridRespawnMover::Visit(CreatureMapType &m)
+void ObjectGridEvacuator::Visit(CreatureMapType &m)
{
// creature in unloading grid can have respawn point in another grid
// if it will be unloaded then it will not respawn in original grid until unload/load original grid
@@ -82,21 +63,21 @@ class ObjectWorldLoader
uint32 i_corpses;
};
-template<class T> void ObjectGridLoader::SetObjectCell(T* /*obj*/, CellPair const& /*cell_pair*/)
+template<class T> void ObjectGridLoader::SetObjectCell(T* /*obj*/, CellCoord const& /*cellCoord*/)
{
}
-template<> void ObjectGridLoader::SetObjectCell(Creature* obj, CellPair const& cell_pair)
+template<> void ObjectGridLoader::SetObjectCell(Creature* obj, CellCoord const& cellCoord)
{
- Cell cell(cell_pair);
+ Cell cell(cellCoord);
obj->SetCurrentCell(cell);
}
template <class T>
-void AddObjectHelper(CellPair &cell, GridRefManager<T> &m, uint32 &count, Map* map, T *obj)
+void AddObjectHelper(CellCoord &cell, GridRefManager<T> &m, uint32 &count, Map* map, T *obj)
{
- obj->GetGridRef().link(&m, obj);
+ obj->AddToGrid(m);
ObjectGridLoader::SetObjectCell(obj, cell);
obj->AddToWorld();
if (obj->isActiveObject())
@@ -106,7 +87,7 @@ void AddObjectHelper(CellPair &cell, GridRefManager<T> &m, uint32 &count, Map* m
}
template <class T>
-void LoadHelper(CellGuidSet const& guid_set, CellPair &cell, GridRefManager<T> &m, uint32 &count, Map* map)
+void LoadHelper(CellGuidSet const& guid_set, CellCoord &cell, GridRefManager<T> &m, uint32 &count, Map* map)
{
for (CellGuidSet::const_iterator i_guid = guid_set.begin(); i_guid != guid_set.end(); ++i_guid)
{
@@ -123,7 +104,7 @@ void LoadHelper(CellGuidSet const& guid_set, CellPair &cell, GridRefManager<T> &
}
}
-void LoadHelper(CellCorpseSet const& cell_corpses, CellPair &cell, CorpseMapType &m, uint32 &count, Map* map)
+void LoadHelper(CellCorpseSet const& cell_corpses, CellCoord &cell, CorpseMapType &m, uint32 &count, Map* map)
{
if (cell_corpses.empty())
return;
@@ -145,21 +126,26 @@ void LoadHelper(CellCorpseSet const& cell_corpses, CellPair &cell, CorpseMapType
// in that case map == currMap
obj->SetMap(map);
+ if (obj->IsInGrid())
+ {
+ obj->AddToWorld();
+ continue;
+ }
+
AddObjectHelper(cell, m, count, map, obj);
}
}
-void
-ObjectGridLoader::Visit(GameObjectMapType &m)
+void ObjectGridLoader::Visit(GameObjectMapType &m)
{
uint32 x = (i_cell.GridX()*MAX_NUMBER_OF_CELLS) + i_cell.CellX();
uint32 y = (i_cell.GridY()*MAX_NUMBER_OF_CELLS) + i_cell.CellY();
- CellPair cell_pair(x, y);
- uint32 cell_id = (cell_pair.y_coord*TOTAL_NUMBER_OF_CELLS_PER_MAP) + cell_pair.x_coord;
+ CellCoord cellCoord(x, y);
+ uint32 cell_id = (cellCoord.y_coord*TOTAL_NUMBER_OF_CELLS_PER_MAP) + cellCoord.x_coord;
CellObjectGuids const& cell_guids = sObjectMgr->GetCellObjectGuids(i_map->GetId(), i_map->GetSpawnMode(), cell_id);
- LoadHelper(cell_guids.gameobjects, cell_pair, m, i_gameObjects, i_map);
+ LoadHelper(cell_guids.gameobjects, cellCoord, m, i_gameObjects, i_map);
}
void
@@ -167,41 +153,24 @@ ObjectGridLoader::Visit(CreatureMapType &m)
{
uint32 x = (i_cell.GridX()*MAX_NUMBER_OF_CELLS) + i_cell.CellX();
uint32 y = (i_cell.GridY()*MAX_NUMBER_OF_CELLS) + i_cell.CellY();
- CellPair cell_pair(x, y);
- uint32 cell_id = (cell_pair.y_coord*TOTAL_NUMBER_OF_CELLS_PER_MAP) + cell_pair.x_coord;
+ CellCoord cellCoord(x, y);
+ uint32 cell_id = (cellCoord.y_coord*TOTAL_NUMBER_OF_CELLS_PER_MAP) + cellCoord.x_coord;
CellObjectGuids const& cell_guids = sObjectMgr->GetCellObjectGuids(i_map->GetId(), i_map->GetSpawnMode(), cell_id);
- LoadHelper(cell_guids.creatures, cell_pair, m, i_creatures, i_map);
+ LoadHelper(cell_guids.creatures, cellCoord, m, i_creatures, i_map);
}
-void
-ObjectWorldLoader::Visit(CorpseMapType &m)
+void ObjectWorldLoader::Visit(CorpseMapType &m)
{
uint32 x = (i_cell.GridX()*MAX_NUMBER_OF_CELLS) + i_cell.CellX();
uint32 y = (i_cell.GridY()*MAX_NUMBER_OF_CELLS) + i_cell.CellY();
- CellPair cell_pair(x, y);
- uint32 cell_id = (cell_pair.y_coord*TOTAL_NUMBER_OF_CELLS_PER_MAP) + cell_pair.x_coord;
+ CellCoord cellCoord(x, y);
+ uint32 cell_id = (cellCoord.y_coord*TOTAL_NUMBER_OF_CELLS_PER_MAP) + cellCoord.x_coord;
// corpses are always added to spawn mode 0 and they are spawned by their instance id
CellObjectGuids const& cell_guids = sObjectMgr->GetCellObjectGuids(i_map->GetId(), 0, cell_id);
- LoadHelper(cell_guids.corpses, cell_pair, m, i_corpses, i_map);
-}
-
-void
-ObjectGridLoader::Load(GridType &grid)
-{
- {
- TypeContainerVisitor<ObjectGridLoader, GridTypeMapContainer > loader(*this);
- grid.Visit(loader);
- }
-
- {
- ObjectWorldLoader wloader(*this);
- TypeContainerVisitor<ObjectWorldLoader, WorldTypeMapContainer > loader(wloader);
- grid.Visit(loader);
- i_corpses = wloader.i_corpses;
- }
+ LoadHelper(cell_guids.corpses, cellCoord, m, i_corpses, i_map);
}
void ObjectGridLoader::LoadN(void)
@@ -214,35 +183,27 @@ void ObjectGridLoader::LoadN(void)
for (unsigned int y=0; y < MAX_NUMBER_OF_CELLS; ++y)
{
i_cell.data.Part.cell_y = y;
- GridLoader<Player, AllWorldObjectTypes, AllGridObjectTypes> loader;
- loader.Load(i_grid(x, y), *this);
- }
- }
- sLog->outDebug(LOG_FILTER_MAPS, "%u GameObjects, %u Creatures, and %u Corpses/Bones loaded for grid %u on map %u", i_gameObjects, i_creatures, i_corpses, i_grid.GetGridId(), i_map->GetId());
-}
-void ObjectGridUnloader::MoveToRespawnN()
-{
- for (unsigned int x=0; x < MAX_NUMBER_OF_CELLS; ++x)
- {
- for (unsigned int y=0; y < MAX_NUMBER_OF_CELLS; ++y)
- {
- ObjectGridRespawnMover mover;
- mover.Move(i_grid(x, y));
+ //Load creatures and game objects
+ {
+ TypeContainerVisitor<ObjectGridLoader, GridTypeMapContainer> visitor(*this);
+ i_grid.VisitGrid(x, y, visitor);
+ }
+
+ //Load corpses (not bones)
+ {
+ ObjectWorldLoader worker(*this);
+ TypeContainerVisitor<ObjectWorldLoader, WorldTypeMapContainer> visitor(worker);
+ i_grid.VisitGrid(x, y, visitor);
+ i_corpses += worker.i_corpses;
+ }
}
}
-}
-
-void
-ObjectGridUnloader::Unload(GridType &grid)
-{
- TypeContainerVisitor<ObjectGridUnloader, GridTypeMapContainer > unloader(*this);
- grid.Visit(unloader);
+ sLog->outDebug(LOG_FILTER_MAPS, "%u GameObjects, %u Creatures, and %u Corpses/Bones loaded for grid %u on map %u", i_gameObjects, i_creatures, i_corpses, i_grid.GetGridId(), i_map->GetId());
}
template<class T>
-void
-ObjectGridUnloader::Visit(GridRefManager<T> &m)
+void ObjectGridUnloader::Visit(GridRefManager<T> &m)
{
while (!m.isEmpty())
{
@@ -250,20 +211,17 @@ ObjectGridUnloader::Visit(GridRefManager<T> &m)
// if option set then object already saved at this moment
if (!sWorld->getBoolConfig(CONFIG_SAVE_RESPAWN_TIME_IMMEDIATELY))
obj->SaveRespawnTime();
+ //Some creatures may summon other temp summons in CleanupsBeforeDelete()
+ //So we need this even after cleaner (maybe we can remove cleaner)
+ //Example: Flame Leviathan Turret 33139 is summoned when a creature is deleted
+ //TODO: Check if that script has the correct logic. Do we really need to summons something before deleting?
+ obj->CleanupsBeforeDelete();
///- object will get delinked from the manager when deleted
delete obj;
}
}
-void
-ObjectGridStoper::Stop(GridType &grid)
-{
- TypeContainerVisitor<ObjectGridStoper, GridTypeMapContainer > stoper(*this);
- grid.Visit(stoper);
-}
-
-void
-ObjectGridStoper::Visit(CreatureMapType &m)
+void ObjectGridStoper::Visit(CreatureMapType &m)
{
// stop any fights at grid de-activation and remove dynobjects created at cast by creatures
for (CreatureMapType::iterator iter=m.begin(); iter != m.end(); ++iter)
@@ -278,32 +236,18 @@ ObjectGridStoper::Visit(CreatureMapType &m)
}
}
-void
-ObjectGridCleaner::Stop(GridType &grid)
-{
- TypeContainerVisitor<ObjectGridCleaner, GridTypeMapContainer > stoper(*this);
- grid.Visit(stoper);
-}
-
-void
-ObjectGridCleaner::Visit(CreatureMapType &m)
-{
- for (CreatureMapType::iterator iter=m.begin(); iter != m.end(); ++iter)
- iter->getSource()->CleanupsBeforeDelete();
-}
-
template<class T>
-void
-ObjectGridCleaner::Visit(GridRefManager<T> &m)
+void ObjectGridCleaner::Visit(GridRefManager<T> &m)
{
for (typename GridRefManager<T>::iterator iter = m.begin(); iter != m.end(); ++iter)
- iter->getSource()->RemoveFromWorld();
+ iter->getSource()->CleanupsBeforeDelete();
}
template void ObjectGridUnloader::Visit(CreatureMapType &);
template void ObjectGridUnloader::Visit(GameObjectMapType &);
template void ObjectGridUnloader::Visit(DynamicObjectMapType &);
template void ObjectGridUnloader::Visit(CorpseMapType &);
+template void ObjectGridCleaner::Visit(CreatureMapType &);
template void ObjectGridCleaner::Visit<GameObject>(GameObjectMapType &);
template void ObjectGridCleaner::Visit<DynamicObject>(DynamicObjectMapType &);
template void ObjectGridCleaner::Visit<Corpse>(CorpseMapType &);
diff --git a/src/server/game/Grids/ObjectGridLoader.h b/src/server/game/Grids/ObjectGridLoader.h
index 5fc5dc47e71..09a8fb2af9c 100755
--- a/src/server/game/Grids/ObjectGridLoader.h
+++ b/src/server/game/Grids/ObjectGridLoader.h
@@ -36,7 +36,6 @@ class ObjectGridLoader
: i_cell(cell), i_grid(grid), i_map(map), i_gameObjects(0), i_creatures(0), i_corpses (0)
{}
- void Load(GridType &grid);
void Visit(GameObjectMapType &m);
void Visit(CreatureMapType &m);
void Visit(CorpseMapType &) const {}
@@ -44,7 +43,7 @@ class ObjectGridLoader
void LoadN(void);
- template<class T> static void SetObjectCell(T* obj, CellPair const& cellPair);
+ template<class T> static void SetObjectCell(T* obj, CellCoord const& cellCoord);
private:
Cell i_cell;
@@ -55,79 +54,33 @@ class ObjectGridLoader
uint32 i_corpses;
};
-class ObjectGridUnloader
+//Stop the creatures before unloading the NGrid
+class ObjectGridStoper
{
public:
- ObjectGridUnloader(NGridType &grid) : i_grid(grid) {}
-
- void MoveToRespawnN();
- void UnloadN()
- {
- for (unsigned int x=0; x < MAX_NUMBER_OF_CELLS; ++x)
- {
- for (unsigned int y=0; y < MAX_NUMBER_OF_CELLS; ++y)
- {
- GridLoader<Player, AllWorldObjectTypes, AllGridObjectTypes> loader;
- loader.Unload(i_grid(x, y), *this);
- }
- }
- }
-
- void Unload(GridType &grid);
- template<class T> void Visit(GridRefManager<T> &m);
- private:
- NGridType &i_grid;
+ void Visit(CreatureMapType &m);
+ template<class T> void Visit(GridRefManager<T> &) {}
};
-class ObjectGridStoper
+//Move the foreign creatures back to respawn positions before unloading the NGrid
+class ObjectGridEvacuator
{
public:
- ObjectGridStoper(NGridType &grid) : i_grid(grid) {}
-
- void StopN()
- {
- for (unsigned int x=0; x < MAX_NUMBER_OF_CELLS; ++x)
- {
- for (unsigned int y=0; y < MAX_NUMBER_OF_CELLS; ++y)
- {
- GridLoader<Player, AllWorldObjectTypes, AllGridObjectTypes> loader;
- loader.Stop(i_grid(x, y), *this);
- }
- }
- }
-
- void Stop(GridType &grid);
void Visit(CreatureMapType &m);
-
- template<class NONACTIVE> void Visit(GridRefManager<NONACTIVE> &) {}
- private:
- NGridType &i_grid;
+ template<class T> void Visit(GridRefManager<T> &) {}
};
+//Clean up and remove from world
class ObjectGridCleaner
{
public:
- ObjectGridCleaner(NGridType &grid) : i_grid(grid) {}
-
- void CleanN()
- {
- for (unsigned int x=0; x < MAX_NUMBER_OF_CELLS; ++x)
- {
- for (unsigned int y=0; y < MAX_NUMBER_OF_CELLS; ++y)
- {
- GridLoader<Player, AllWorldObjectTypes, AllGridObjectTypes> loader;
- loader.Stop(i_grid(x, y), *this);
- }
- }
- }
-
- void Stop(GridType &grid);
- void Visit(CreatureMapType &m);
template<class T> void Visit(GridRefManager<T> &);
- private:
- NGridType &i_grid;
};
-typedef GridLoader<Player, AllWorldObjectTypes, AllGridObjectTypes> GridLoaderType;
+//Delete objects before deleting NGrid
+class ObjectGridUnloader
+{
+ public:
+ template<class T> void Visit(GridRefManager<T> &m);
+};
#endif
-
diff --git a/src/server/game/Groups/Group.cpp b/src/server/game/Groups/Group.cpp
index 0442172b0fd..6311066f597 100755
--- a/src/server/game/Groups/Group.cpp
+++ b/src/server/game/Groups/Group.cpp
@@ -1052,8 +1052,8 @@ void Group::CountTheRoll(Rolls::iterator rollI, uint32 NumberOfPlayers)
item->is_looted = true;
roll->getLoot()->NotifyItemRemoved(roll->itemSlot);
roll->getLoot()->unlootedCount--;
- AllowedLooterSet* looters = item->GetAllowedLooters();
- player->StoreNewItem(dest, roll->itemid, true, item->randomPropertyId, (looters->size() > 1) ? looters : NULL);
+ AllowedLooterSet looters = item->GetAllowedLooters();
+ player->StoreNewItem(dest, roll->itemid, true, item->randomPropertyId, looters);
}
else
{
@@ -1105,8 +1105,8 @@ void Group::CountTheRoll(Rolls::iterator rollI, uint32 NumberOfPlayers)
item->is_looted = true;
roll->getLoot()->NotifyItemRemoved(roll->itemSlot);
roll->getLoot()->unlootedCount--;
- AllowedLooterSet* looters = item->GetAllowedLooters();
- player->StoreNewItem(dest, roll->itemid, true, item->randomPropertyId, (looters->size() > 1) ? looters : NULL);
+ AllowedLooterSet looters = item->GetAllowedLooters();
+ player->StoreNewItem(dest, roll->itemid, true, item->randomPropertyId, looters);
}
else
{
@@ -1274,12 +1274,12 @@ void Group::BroadcastPacket(WorldPacket* packet, bool ignorePlayersInBGRaid, int
{
for (GroupReference* itr = GetFirstMember(); itr != NULL; itr = itr->next())
{
- Player* plr = itr->getSource();
- if (!plr || (ignore != 0 && plr->GetGUID() == ignore) || (ignorePlayersInBGRaid && plr->GetGroup() != this))
+ Player* player = itr->getSource();
+ if (!player || (ignore != 0 && player->GetGUID() == ignore) || (ignorePlayersInBGRaid && player->GetGroup() != this))
continue;
- if (plr->GetSession() && (group == -1 || itr->getSubGroup() == group))
- plr->GetSession()->SendPacket(packet);
+ if (player->GetSession() && (group == -1 || itr->getSubGroup() == group))
+ player->GetSession()->SendPacket(packet);
}
}
@@ -1287,10 +1287,10 @@ void Group::BroadcastReadyCheck(WorldPacket* packet)
{
for (GroupReference* itr = GetFirstMember(); itr != NULL; itr = itr->next())
{
- Player* plr = itr->getSource();
- if (plr && plr->GetSession())
- if (IsLeader(plr->GetGUID()) || IsAssistant(plr->GetGUID()))
- plr->GetSession()->SendPacket(packet);
+ Player* player = itr->getSource();
+ if (player && player->GetSession())
+ if (IsLeader(player->GetGUID()) || IsAssistant(player->GetGUID()))
+ player->GetSession()->SendPacket(packet);
}
}
@@ -1298,8 +1298,8 @@ void Group::OfflineReadyCheck()
{
for (member_citerator citr = m_memberSlots.begin(); citr != m_memberSlots.end(); ++citr)
{
- Player* plr = ObjectAccessor::FindPlayer(citr->guid);
- if (!plr || !plr->GetSession())
+ Player* player = ObjectAccessor::FindPlayer(citr->guid);
+ if (!player || !player->GetSession())
{
WorldPacket data(MSG_RAID_READY_CHECK_CONFIRM, 9);
data << uint64(citr->guid);
@@ -1425,10 +1425,10 @@ void Group::UpdateLooterGuid(WorldObject* pLootedObject, bool ifneed)
Player* pNewLooter = NULL;
for (member_citerator itr = guid_itr; itr != m_memberSlots.end(); ++itr)
{
- if (Player* pl = ObjectAccessor::FindPlayer(itr->guid))
- if (pl->IsWithinDistInMap(pLootedObject, sWorld->getFloatConfig(CONFIG_GROUP_XP_DISTANCE), false))
+ if (Player* player = ObjectAccessor::FindPlayer(itr->guid))
+ if (player->IsWithinDistInMap(pLootedObject, sWorld->getFloatConfig(CONFIG_GROUP_XP_DISTANCE), false))
{
- pNewLooter = pl;
+ pNewLooter = player;
break;
}
}
@@ -1438,10 +1438,10 @@ void Group::UpdateLooterGuid(WorldObject* pLootedObject, bool ifneed)
// search from start
for (member_citerator itr = m_memberSlots.begin(); itr != guid_itr; ++itr)
{
- if (Player* pl = ObjectAccessor::FindPlayer(itr->guid))
- if (pl->IsWithinDistInMap(pLootedObject, sWorld->getFloatConfig(CONFIG_GROUP_XP_DISTANCE), false))
+ if (Player* player = ObjectAccessor::FindPlayer(itr->guid))
+ if (player->IsWithinDistInMap(pLootedObject, sWorld->getFloatConfig(CONFIG_GROUP_XP_DISTANCE), false))
{
- pNewLooter = pl;
+ pNewLooter = player;
break;
}
}
@@ -2065,4 +2065,5 @@ void Group::ToggleGroupMemberFlag(member_witerator slot, uint8 flag, bool apply)
slot->flags |= flag;
else
slot->flags &= ~flag;
-} \ No newline at end of file
+}
+
diff --git a/src/server/game/Instances/InstanceSaveMgr.cpp b/src/server/game/Instances/InstanceSaveMgr.cpp
index bc2648ed02b..7a2368161d8 100755
--- a/src/server/game/Instances/InstanceSaveMgr.cpp
+++ b/src/server/game/Instances/InstanceSaveMgr.cpp
@@ -309,11 +309,11 @@ void InstanceSaveManager::LoadResetTimes()
while (result->NextRow());
// update reset time for normal instances with the max creature respawn time + X hours
- if (PreparedQueryResult result = CharacterDatabase.Query(CharacterDatabase.GetPreparedStatement(CHAR_GET_MAX_CREATURE_RESPAWNS)))
+ if (PreparedQueryResult result2 = CharacterDatabase.Query(CharacterDatabase.GetPreparedStatement(CHAR_GET_MAX_CREATURE_RESPAWNS)))
{
do
{
- Field* fields = result->Fetch();
+ Field* fields = result2->Fetch();
uint32 instance = fields[1].GetUInt32();
time_t resettime = time_t(fields[0].GetUInt32() + 2 * HOUR);
InstResetTimeMapDiffType::iterator itr = instResetTime.find(instance);
@@ -511,7 +511,7 @@ void InstanceSaveManager::_ResetSave(InstanceSaveHashMap::iterator &itr)
void InstanceSaveManager::_ResetInstance(uint32 mapid, uint32 instanceId)
{
sLog->outDebug(LOG_FILTER_MAPS, "InstanceSaveMgr::_ResetInstance %u, %u", mapid, instanceId);
- Map* map = (MapInstanced*)sMapMgr->CreateBaseMap(mapid);
+ Map const* map = sMapMgr->CreateBaseMap(mapid);
if (!map->Instanceable())
return;
@@ -521,7 +521,7 @@ void InstanceSaveManager::_ResetInstance(uint32 mapid, uint32 instanceId)
DeleteInstanceFromDB(instanceId); // even if save not loaded
- Map* iMap = ((MapInstanced*)map)->FindMap(instanceId);
+ Map* iMap = ((MapInstanced*)map)->FindInstanceMap(instanceId);
if (iMap && iMap->IsDungeon())
((InstanceMap*)iMap)->Reset(INSTANCE_RESET_RESPAWN_DELAY);
diff --git a/src/server/game/Instances/InstanceSaveMgr.h b/src/server/game/Instances/InstanceSaveMgr.h
index dec50e40127..b4e97f40f87 100755
--- a/src/server/game/Instances/InstanceSaveMgr.h
+++ b/src/server/game/Instances/InstanceSaveMgr.h
@@ -80,8 +80,8 @@ class InstanceSave
/* online players bound to the instance (perm/solo)
does not include the members of the group unless they have permanent saves */
- void AddPlayer(Player* player) { ACE_GUARD(ACE_Thread_Mutex, guard, _lock); m_playerList.push_back(player); }
- bool RemovePlayer(Player* player) { ACE_GUARD_RETURN(ACE_Thread_Mutex, guard, _lock, false); m_playerList.remove(player); return UnloadIfEmpty(); }
+ void AddPlayer(Player* player) { TRINITY_GUARD(ACE_Thread_Mutex, _lock); m_playerList.push_back(player); }
+ bool RemovePlayer(Player* player) { TRINITY_GUARD(ACE_Thread_Mutex, _lock); m_playerList.remove(player); return UnloadIfEmpty(); }
/* all groups bound to the instance */
void AddGroup(Group* group) { m_groupList.push_back(group); }
bool RemoveGroup(Group* group) { m_groupList.remove(group); return UnloadIfEmpty(); }
diff --git a/src/server/game/Instances/InstanceScript.cpp b/src/server/game/Instances/InstanceScript.cpp
index b9b9ed281fa..b8987be9adb 100755
--- a/src/server/game/Instances/InstanceScript.cpp
+++ b/src/server/game/Instances/InstanceScript.cpp
@@ -141,34 +141,36 @@ void InstanceScript::AddDoor(GameObject* door, bool add)
for (DoorInfoMap::iterator itr = lower; itr != upper; ++itr)
{
+ DoorInfo const& data = itr->second;
+
if (add)
{
- itr->second.bossInfo->door[itr->second.type].insert(door);
- switch (itr->second.boundary)
+ data.bossInfo->door[data.type].insert(door);
+ switch (data.boundary)
{
default:
case BOUNDARY_NONE:
break;
case BOUNDARY_N:
case BOUNDARY_S:
- itr->second.bossInfo->boundary[itr->second.boundary] = door->GetPositionX();
+ data.bossInfo->boundary[data.boundary] = door->GetPositionX();
break;
case BOUNDARY_E:
case BOUNDARY_W:
- itr->second.bossInfo->boundary[itr->second.boundary] = door->GetPositionY();
+ data.bossInfo->boundary[data.boundary] = door->GetPositionY();
break;
case BOUNDARY_NW:
case BOUNDARY_SE:
- itr->second.bossInfo->boundary[itr->second.boundary] = door->GetPositionX() + door->GetPositionY();
+ data.bossInfo->boundary[data.boundary] = door->GetPositionX() + door->GetPositionY();
break;
case BOUNDARY_NE:
case BOUNDARY_SW:
- itr->second.bossInfo->boundary[itr->second.boundary] = door->GetPositionX() - door->GetPositionY();
+ data.bossInfo->boundary[data.boundary] = door->GetPositionX() - door->GetPositionY();
break;
}
}
else
- itr->second.bossInfo->door[itr->second.type].erase(door);
+ data.bossInfo->door[data.type].erase(door);
}
if (add)
@@ -303,7 +305,6 @@ void InstanceScript::DoUpdateWorldState(uint32 uiStateId, uint32 uiStateData)
void InstanceScript::DoSendNotifyToInstance(const char *format, ...)
{
InstanceMap::PlayerList const &PlayerList = instance->GetPlayers();
- InstanceMap::PlayerList::const_iterator i;
if (!PlayerList.isEmpty())
{
diff --git a/src/server/game/Loot/LootMgr.cpp b/src/server/game/Loot/LootMgr.cpp
index eff811b14eb..dd17e8277d6 100755
--- a/src/server/game/Loot/LootMgr.cpp
+++ b/src/server/game/Loot/LootMgr.cpp
@@ -436,8 +436,8 @@ bool Loot::FillLoot(uint32 lootId, LootStore const& store, Player* lootOwner, bo
roundRobinPlayer = lootOwner->GetGUID();
for (GroupReference* itr = group->GetFirstMember(); itr != NULL; itr = itr->next())
- if (Player* pl = itr->getSource()) // should actually be looted object instead of lootOwner but looter has to be really close so doesnt really matter
- FillNotNormalLootFor(pl, pl->IsAtGroupRewardDistance(lootOwner));
+ if (Player* player = itr->getSource()) // should actually be looted object instead of lootOwner but looter has to be really close so doesnt really matter
+ FillNotNormalLootFor(player, player->IsAtGroupRewardDistance(lootOwner));
for (uint8 i = 0; i < items.size(); ++i)
{
@@ -453,28 +453,28 @@ bool Loot::FillLoot(uint32 lootId, LootStore const& store, Player* lootOwner, bo
return true;
}
-void Loot::FillNotNormalLootFor(Player* pl, bool presentAtLooting)
+void Loot::FillNotNormalLootFor(Player* player, bool presentAtLooting)
{
- uint32 plguid = pl->GetGUIDLow();
+ uint32 plguid = player->GetGUIDLow();
QuestItemMap::const_iterator qmapitr = PlayerQuestItems.find(plguid);
if (qmapitr == PlayerQuestItems.end())
- FillQuestLoot(pl);
+ FillQuestLoot(player);
qmapitr = PlayerFFAItems.find(plguid);
if (qmapitr == PlayerFFAItems.end())
- FillFFALoot(pl);
+ FillFFALoot(player);
qmapitr = PlayerNonQuestNonFFAConditionalItems.find(plguid);
if (qmapitr == PlayerNonQuestNonFFAConditionalItems.end())
- FillNonQuestNonFFAConditionalLoot(pl, presentAtLooting);
+ FillNonQuestNonFFAConditionalLoot(player, presentAtLooting);
// if not auto-processed player will have to come and pick it up manually
if (!presentAtLooting)
return;
// Process currency items
- uint32 max_slot = GetMaxSlotInLootFor(pl);
+ uint32 max_slot = GetMaxSlotInLootFor(player);
LootItem const* item = NULL;
uint32 itemsSize = uint32(items.size());
for (uint32 i = 0; i < max_slot; ++i)
@@ -484,10 +484,10 @@ void Loot::FillNotNormalLootFor(Player* pl, bool presentAtLooting)
else
item = &quest_items[i-itemsSize];
- if (!item->is_looted && item->freeforall && item->AllowedForPlayer(pl))
+ if (!item->is_looted && item->freeforall && item->AllowedForPlayer(player))
if (ItemTemplate const* proto = sObjectMgr->GetItemTemplate(item->itemid))
if (proto->BagFamily & BAG_FAMILY_MASK_CURRENCY_TOKENS)
- pl->StoreLootItem(i, this);
+ player->StoreLootItem(i, this);
}
}
@@ -592,8 +592,8 @@ void Loot::NotifyItemRemoved(uint8 lootIndex)
{
i_next = i;
++i_next;
- if (Player* pl = ObjectAccessor::FindPlayer(*i))
- pl->SendNotifyLootItemRemoved(lootIndex);
+ if (Player* player = ObjectAccessor::FindPlayer(*i))
+ player->SendNotifyLootItemRemoved(lootIndex);
else
PlayersLooting.erase(i);
}
@@ -607,8 +607,8 @@ void Loot::NotifyMoneyRemoved()
{
i_next = i;
++i_next;
- if (Player* pl = ObjectAccessor::FindPlayer(*i))
- pl->SendNotifyLootMoneyRemoved();
+ if (Player* player = ObjectAccessor::FindPlayer(*i))
+ player->SendNotifyLootMoneyRemoved();
else
PlayersLooting.erase(i);
}
@@ -626,9 +626,9 @@ void Loot::NotifyQuestItemRemoved(uint8 questIndex)
{
i_next = i;
++i_next;
- if (Player* pl = ObjectAccessor::FindPlayer(*i))
+ if (Player* player = ObjectAccessor::FindPlayer(*i))
{
- QuestItemMap::const_iterator pq = PlayerQuestItems.find(pl->GetGUIDLow());
+ QuestItemMap::const_iterator pq = PlayerQuestItems.find(player->GetGUIDLow());
if (pq != PlayerQuestItems.end() && pq->second)
{
// find where/if the player has the given item in it's vector
@@ -640,7 +640,7 @@ void Loot::NotifyQuestItemRemoved(uint8 questIndex)
break;
if (j < pql.size())
- pl->SendNotifyLootItemRemoved(items.size()+j);
+ player->SendNotifyLootItemRemoved(items.size()+j);
}
}
else
diff --git a/src/server/game/Loot/LootMgr.h b/src/server/game/Loot/LootMgr.h
index b0adeb03784..10ae786a7d6 100755
--- a/src/server/game/Loot/LootMgr.h
+++ b/src/server/game/Loot/LootMgr.h
@@ -149,7 +149,7 @@ struct LootItem
bool AllowedForPlayer(Player const* player) const;
void AddAllowedLooter(Player const* player);
- AllowedLooterSet* GetAllowedLooters() { return &allowedGUIDs; }
+ const AllowedLooterSet & GetAllowedLooters() const { return allowedGUIDs; }
};
struct QuestItem
diff --git a/src/server/game/Maps/Map.cpp b/src/server/game/Maps/Map.cpp
index 89049f39127..bd419482b5b 100755
--- a/src/server/game/Maps/Map.cpp
+++ b/src/server/game/Maps/Map.cpp
@@ -141,9 +141,9 @@ void Map::LoadMap(int gx, int gy, bool reload)
// load grid map for base map
if (!m_parentMap->GridMaps[gx][gy])
- m_parentMap->EnsureGridCreated(GridPair(63-gx, 63-gy));
+ m_parentMap->EnsureGridCreated(GridCoord(63-gx, 63-gy));
- ((MapInstanced*)(m_parentMap))->AddGridMapReference(GridPair(gx, gy));
+ ((MapInstanced*)(m_parentMap))->AddGridMapReference(GridCoord(gx, gy));
GridMaps[gx][gy] = m_parentMap->GridMaps[gx][gy];
return;
}
@@ -202,11 +202,11 @@ void Map::DeleteStateMachine()
}
Map::Map(uint32 id, time_t expiry, uint32 InstanceId, uint8 SpawnMode, Map* _parent):
-i_mapEntry (sMapStore.LookupEntry(id)), i_spawnMode(SpawnMode), i_InstanceId(InstanceId),
+_creatureToMoveLock(false), i_mapEntry (sMapStore.LookupEntry(id)), i_spawnMode(SpawnMode), i_InstanceId(InstanceId),
m_unloadTimer(0), m_VisibleDistance(DEFAULT_VISIBILITY_DISTANCE),
m_VisibilityNotifyPeriod(DEFAULT_VISIBILITY_NOTIFY_PERIOD),
m_activeNonPlayersIter(m_activeNonPlayers.end()), i_gridExpiry(expiry),
-i_scriptLock(false), _creatureToMoveLock(false)
+i_scriptLock(false)
{
m_parentMap = (_parent ? _parent : this);
for (unsigned int idx=0; idx < MAX_NUMBER_OF_GRIDS; ++idx)
@@ -234,74 +234,52 @@ void Map::InitVisibilityDistance()
// Template specialization of utility methods
template<class T>
-void Map::AddToGrid(T* obj, NGridType *grid, Cell const& cell)
+void Map::AddToGrid(T* obj, Cell const& cell)
{
+ NGridType* grid = getNGrid(cell.GridX(), cell.GridY());
if (obj->m_isWorldObject)
- (*grid)(cell.CellX(), cell.CellY()).template AddWorldObject<T>(obj);
+ grid->GetGridType(cell.CellX(), cell.CellY()).template AddWorldObject<T>(obj);
else
- (*grid)(cell.CellX(), cell.CellY()).template AddGridObject<T>(obj);
+ grid->GetGridType(cell.CellX(), cell.CellY()).template AddGridObject<T>(obj);
}
template<>
-void Map::AddToGrid(Creature* obj, NGridType *grid, Cell const& cell)
+void Map::AddToGrid(Creature* obj, Cell const& cell)
{
+ NGridType* grid = getNGrid(cell.GridX(), cell.GridY());
if (obj->m_isWorldObject)
- (*grid)(cell.CellX(), cell.CellY()).AddWorldObject(obj);
+ grid->GetGridType(cell.CellX(), cell.CellY()).AddWorldObject(obj);
else
- (*grid)(cell.CellX(), cell.CellY()).AddGridObject(obj);
+ grid->GetGridType(cell.CellX(), cell.CellY()).AddGridObject(obj);
obj->SetCurrentCell(cell);
}
template<class T>
-void Map::RemoveFromGrid(T* obj, NGridType *grid, Cell const& cell)
-{
- if (obj->m_isWorldObject)
- (*grid)(cell.CellX(), cell.CellY()).template RemoveWorldObject<T>(obj);
- else
- (*grid)(cell.CellX(), cell.CellY()).template RemoveGridObject<T>(obj);
-}
-
-template<class T>
void Map::SwitchGridContainers(T* obj, bool on)
{
- CellPair p = Trinity::ComputeCellPair(obj->GetPositionX(), obj->GetPositionY());
- if (p.x_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP || p.y_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP)
+ CellCoord p = Trinity::ComputeCellCoord(obj->GetPositionX(), obj->GetPositionY());
+ if (!p.IsCoordValid())
{
sLog->outError("Map::SwitchGridContainers: Object " UI64FMTD " has invalid coordinates X:%f Y:%f grid cell [%u:%u]", obj->GetGUID(), obj->GetPositionX(), obj->GetPositionY(), p.x_coord, p.y_coord);
return;
}
Cell cell(p);
- if (!loaded(GridPair(cell.data.Part.grid_x, cell.data.Part.grid_y)))
+ if (!IsGridLoaded(GridCoord(cell.data.Part.grid_x, cell.data.Part.grid_y)))
return;
sLog->outStaticDebug("Switch object " UI64FMTD " from grid[%u, %u] %u", obj->GetGUID(), cell.data.Part.grid_x, cell.data.Part.grid_y, on);
NGridType *ngrid = getNGrid(cell.GridX(), cell.GridY());
ASSERT(ngrid != NULL);
- GridType &grid = (*ngrid)(cell.CellX(), cell.CellY());
+ GridType &grid = ngrid->GetGridType(cell.CellX(), cell.CellY());
+ obj->RemoveFromGrid(); //This step is not really necessary but we want to do ASSERT in remove/add
if (on)
- {
- grid.RemoveGridObject<T>(obj);
grid.AddWorldObject<T>(obj);
- /*if (!grid.RemoveGridObject<T>(obj, obj->GetGUID())
- || !grid.AddWorldObject<T>(obj, obj->GetGUID()))
- {
- ASSERT(false);
- }*/
- }
else
- {
- grid.RemoveWorldObject<T>(obj);
grid.AddGridObject<T>(obj);
- /*if (!grid.RemoveWorldObject<T>(obj, obj->GetGUID())
- || !grid.AddGridObject<T>(obj, obj->GetGUID()))
- {
- ASSERT(false);
- }*/
- }
obj->m_isWorldObject = on;
}
@@ -316,18 +294,20 @@ void Map::DeleteFromWorld(T* obj)
}
template<>
-void Map::DeleteFromWorld(Player* pl)
+void Map::DeleteFromWorld(Player* player)
{
- sObjectAccessor->RemoveObject(pl);
- delete pl;
+ sObjectAccessor->RemoveObject(player);
+ sObjectAccessor->RemoveUpdateObject(player); //TODO: I do not know why we need this, it should be removed in ~Object anyway
+ delete player;
}
-void
-Map::EnsureGridCreated(const GridPair &p)
+//Create NGrid so the object can be added to it
+//But object data is not loaded here
+void Map::EnsureGridCreated(const GridCoord &p)
{
if (!getNGrid(p.x_coord, p.y_coord))
{
- ACE_GUARD(ACE_Thread_Mutex, Guard, Lock);
+ TRINITY_GUARD(ACE_Thread_Mutex, Lock);
if (!getNGrid(p.x_coord, p.y_coord))
{
sLog->outDebug(LOG_FILTER_MAPS, "Creating grid[%u, %u] for map %u instance %u", p.x_coord, p.y_coord, GetId(), i_InstanceId);
@@ -350,8 +330,8 @@ Map::EnsureGridCreated(const GridPair &p)
}
}
-void
-Map::EnsureGridLoadedAtEnter(const Cell &cell, Player* player)
+//Load NGrid and make it active
+void Map::EnsureGridLoadedForActiveObject(const Cell &cell, WorldObject* object)
{
EnsureGridLoaded(cell);
NGridType *grid = getNGrid(cell.GridX(), cell.GridY());
@@ -360,23 +340,16 @@ Map::EnsureGridLoadedAtEnter(const Cell &cell, Player* player)
// refresh grid state & timer
if (grid->GetGridState() != GRID_STATE_ACTIVE)
{
- if (player)
- {
- sLog->outStaticDebug("Player %s enter cell[%u, %u] triggers loading of grid[%u, %u] on map %u", player->GetName(), cell.CellX(), cell.CellY(), cell.GridX(), cell.GridY(), GetId());
- }
- else
- {
- sLog->outStaticDebug("Active object nearby triggers loading of grid [%u, %u] on map %u", cell.GridX(), cell.GridY(), GetId());
- }
-
+ sLog->outStaticDebug("Active object "UI64FMTD" triggers loading of grid [%u, %u] on map %u", object->GetGUID(), cell.GridX(), cell.GridY(), GetId());
ResetGridExpiry(*grid, 0.1f);
grid->SetGridState(GRID_STATE_ACTIVE);
}
}
+//Create NGrid and load the object data in it
bool Map::EnsureGridLoaded(const Cell &cell)
{
- EnsureGridCreated(GridPair(cell.GridX(), cell.GridY()));
+ EnsureGridCreated(GridCoord(cell.GridX(), cell.GridY()));
NGridType *grid = getNGrid(cell.GridX(), cell.GridY());
ASSERT(grid != NULL);
@@ -390,7 +363,7 @@ bool Map::EnsureGridLoaded(const Cell &cell)
loader.LoadN();
// Add resurrectable corpses to world object list in grid
- sObjectAccessor->AddCorpsesToGrid(GridPair(cell.GridX(), cell.GridY()), (*grid)(cell.CellX(), cell.CellY()), this);
+ sObjectAccessor->AddCorpsesToGrid(GridCoord(cell.GridX(), cell.GridY()), grid->GetGridType(cell.CellX(), cell.CellY()), this);
return true;
}
@@ -399,30 +372,25 @@ bool Map::EnsureGridLoaded(const Cell &cell)
void Map::LoadGrid(float x, float y)
{
- CellPair pair = Trinity::ComputeCellPair(x, y);
- Cell cell(pair);
- EnsureGridLoaded(cell);
+ EnsureGridLoaded(Cell(x, y));
}
-bool Map::AddToMap(Player* player)
+bool Map::AddPlayerToMap(Player* player)
{
- // Check if we are adding to correct map
- ASSERT (player->GetMap() == this);
- CellPair p = Trinity::ComputeCellPair(player->GetPositionX(), player->GetPositionY());
- if (p.x_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP || p.y_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP)
+ CellCoord cellCoord = Trinity::ComputeCellCoord(player->GetPositionX(), player->GetPositionY());
+ if (!cellCoord.IsCoordValid())
{
- sLog->outError("Map::Add: Player (GUID: %u) has invalid coordinates X:%f Y:%f grid cell [%u:%u]", player->GetGUIDLow(), player->GetPositionX(), player->GetPositionY(), p.x_coord, p.y_coord);
+ sLog->outError("Map::Add: Player (GUID: %u) has invalid coordinates X:%f Y:%f grid cell [%u:%u]", player->GetGUIDLow(), player->GetPositionX(), player->GetPositionY(), cellCoord.x_coord, cellCoord.y_coord);
return false;
}
- player->SetMap(this);
-
- Cell cell(p);
- EnsureGridLoadedAtEnter(cell, player);
- NGridType *grid = getNGrid(cell.GridX(), cell.GridY());
- ASSERT(grid != NULL);
- AddToGrid(player, grid, cell);
+ Cell cell(cellCoord);
+ EnsureGridLoadedForActiveObject(cell, player);
+ AddToGrid(player, cell);
+ // Check if we are adding to correct map
+ ASSERT (player->GetMap() == this);
+ player->SetMap(this);
player->AddToWorld();
SendInitSelf(player);
@@ -436,7 +404,7 @@ bool Map::AddToMap(Player* player)
}
template<class T>
-void Map::InitializeObject(T* obj)
+void Map::InitializeObject(T* /*obj*/)
{
}
@@ -447,69 +415,62 @@ void Map::InitializeObject(Creature* obj)
}
template<class T>
-void
-Map::AddToMap(T *obj)
+void Map::AddToMap(T *obj)
{
- CellPair p = Trinity::ComputeCellPair(obj->GetPositionX(), obj->GetPositionY());
- if (p.x_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP || p.y_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP)
+ //TODO: Needs clean up. An object should not be added to map twice.
+ if (obj->IsInWorld())
{
- sLog->outError("Map::Add: Object " UI64FMTD " has invalid coordinates X:%f Y:%f grid cell [%u:%u]", obj->GetGUID(), obj->GetPositionX(), obj->GetPositionY(), p.x_coord, p.y_coord);
+ ASSERT(obj->IsInGrid());
+ obj->UpdateObjectVisibility(true);
return;
}
- Cell cell(p);
- if (obj->IsInWorld()) // need some clean up later
+ CellCoord cellCoord = Trinity::ComputeCellCoord(obj->GetPositionX(), obj->GetPositionY());
+ if (!cellCoord.IsCoordValid())
{
- obj->UpdateObjectVisibility(true);
+ sLog->outError("Map::Add: Object " UI64FMTD " has invalid coordinates X:%f Y:%f grid cell [%u:%u]", obj->GetGUID(), obj->GetPositionX(), obj->GetPositionY(), cellCoord.x_coord, cellCoord.y_coord);
return;
}
+ Cell cell(cellCoord);
if (obj->isActiveObject())
- EnsureGridLoadedAtEnter(cell);
+ EnsureGridLoadedForActiveObject(cell, obj);
else
- EnsureGridCreated(GridPair(cell.GridX(), cell.GridY()));
-
- NGridType *grid = getNGrid(cell.GridX(), cell.GridY());
- ASSERT(grid != NULL);
+ EnsureGridCreated(GridCoord(cell.GridX(), cell.GridY()));
+ AddToGrid(obj, cell);
+ sLog->outStaticDebug("Object %u enters grid[%u, %u]", GUID_LOPART(obj->GetGUID()), cell.GridX(), cell.GridY());
- AddToGrid(obj, grid, cell);
+ //Must already be set before AddToMap. Usually during obj->Create.
//obj->SetMap(this);
obj->AddToWorld();
+
InitializeObject(obj);
if (obj->isActiveObject())
AddToActive(obj);
- sLog->outStaticDebug("Object %u enters grid[%u, %u]", GUID_LOPART(obj->GetGUID()), cell.GridX(), cell.GridY());
-
//something, such as vehicle, needs to be update immediately
//also, trigger needs to cast spell, if not update, cannot see visual
obj->UpdateObjectVisibility(true);
}
-bool Map::loaded(const GridPair &p) const
+bool Map::IsGridLoaded(const GridCoord &p) const
{
return (getNGrid(p.x_coord, p.y_coord) && isGridObjectDataLoaded(p.x_coord, p.y_coord));
}
void Map::VisitNearbyCellsOf(WorldObject* obj, TypeContainerVisitor<Trinity::ObjectUpdater, GridTypeMapContainer> &gridVisitor, TypeContainerVisitor<Trinity::ObjectUpdater, WorldTypeMapContainer> &worldVisitor)
{
- CellPair standing_cell(Trinity::ComputeCellPair(obj->GetPositionX(), obj->GetPositionY()));
-
- // Check for correctness of standing_cell, it also avoids problems with update_cell
- if (standing_cell.x_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP || standing_cell.y_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP)
+ // Check for valid position
+ if (!obj->IsPositionValid())
return;
- // the overloaded operators handle range checking
- // so there's no need for range checking inside the loop
- CellPair begin_cell(standing_cell), end_cell(standing_cell);
- //lets update mobs/objects in ALL visible cells around object!
- CellArea area = Cell::CalculateCellArea(*obj, obj->GetGridActivationRange());
- area.ResizeBorders(begin_cell, end_cell);
+ // Update mobs/objects in ALL visible cells around object!
+ CellArea area = Cell::CalculateCellArea(obj->GetPositionX(), obj->GetPositionY(), obj->GetGridActivationRange());
- for (uint32 x = begin_cell.x_coord; x <= end_cell.x_coord; ++x)
+ for (uint32 x = area.low_bound.x_coord; x <= area.high_bound.x_coord; ++x)
{
- for (uint32 y = begin_cell.y_coord; y <= end_cell.y_coord; ++y)
+ for (uint32 y = area.low_bound.y_coord; y <= area.high_bound.y_coord; ++y)
{
// marked cells are those that have been visited
// don't visit the same cell twice
@@ -518,11 +479,10 @@ void Map::VisitNearbyCellsOf(WorldObject* obj, TypeContainerVisitor<Trinity::Obj
continue;
markCell(cell_id);
- CellPair pair(x, y);
+ CellCoord pair(x, y);
Cell cell(pair);
- cell.data.Part.reserved = CENTER_DISTRICT;
- cell.Visit(pair, gridVisitor, *this);
- cell.Visit(pair, worldVisitor, *this);
+ Visit(cell, gridVisitor);
+ Visit(cell, worldVisitor);
}
}
}
@@ -532,11 +492,11 @@ void Map::Update(const uint32 t_diff)
/// update worldsessions for existing players
for (m_mapRefIter = m_mapRefManager.begin(); m_mapRefIter != m_mapRefManager.end(); ++m_mapRefIter)
{
- Player* plr = m_mapRefIter->getSource();
- if (plr && plr->IsInWorld())
+ Player* player = m_mapRefIter->getSource();
+ if (player && player->IsInWorld())
{
- //plr->Update(t_diff);
- WorldSession* pSession = plr->GetSession();
+ //player->Update(t_diff);
+ WorldSession* pSession = player->GetSession();
MapSessionFilter updater(pSession);
pSession->Update(t_diff, updater);
}
@@ -554,15 +514,15 @@ void Map::Update(const uint32 t_diff)
// to make sure calls to Map::Remove don't invalidate it
for (m_mapRefIter = m_mapRefManager.begin(); m_mapRefIter != m_mapRefManager.end(); ++m_mapRefIter)
{
- Player* plr = m_mapRefIter->getSource();
+ Player* player = m_mapRefIter->getSource();
- if (!plr || !plr->IsInWorld())
+ if (!player || !player->IsInWorld())
continue;
// update players at tick
- plr->Update(t_diff);
+ player->Update(t_diff);
- VisitNearbyCellsOf(plr, grid_object_update, world_object_update);
+ VisitNearbyCellsOf(player, grid_object_update, world_object_update);
}
// non-player active objects, increasing iterator in the loop in case of object removal
@@ -620,8 +580,8 @@ void Map::ProcessRelocationNotifies(const uint32 diff)
uint32 gx = grid->getX(), gy = grid->getY();
- CellPair cell_min(gx*MAX_NUMBER_OF_CELLS, gy*MAX_NUMBER_OF_CELLS);
- CellPair cell_max(cell_min.x_coord + MAX_NUMBER_OF_CELLS, cell_min.y_coord+MAX_NUMBER_OF_CELLS);
+ CellCoord cell_min(gx*MAX_NUMBER_OF_CELLS, gy*MAX_NUMBER_OF_CELLS);
+ CellCoord cell_max(cell_min.x_coord + MAX_NUMBER_OF_CELLS, cell_min.y_coord+MAX_NUMBER_OF_CELLS);
for (uint32 x = cell_min.x_coord; x < cell_max.x_coord; ++x)
{
@@ -631,7 +591,7 @@ void Map::ProcessRelocationNotifies(const uint32 diff)
if (!isCellMarked(cell_id))
continue;
- CellPair pair(x, y);
+ CellCoord pair(x, y);
Cell cell(pair);
cell.SetNoCreate();
@@ -661,8 +621,8 @@ void Map::ProcessRelocationNotifies(const uint32 diff)
uint32 gx = grid->getX(), gy = grid->getY();
- CellPair cell_min(gx*MAX_NUMBER_OF_CELLS, gy*MAX_NUMBER_OF_CELLS);
- CellPair cell_max(cell_min.x_coord + MAX_NUMBER_OF_CELLS, cell_min.y_coord+MAX_NUMBER_OF_CELLS);
+ CellCoord cell_min(gx*MAX_NUMBER_OF_CELLS, gy*MAX_NUMBER_OF_CELLS);
+ CellCoord cell_max(cell_min.x_coord + MAX_NUMBER_OF_CELLS, cell_min.y_coord+MAX_NUMBER_OF_CELLS);
for (uint32 x = cell_min.x_coord; x < cell_max.x_coord; ++x)
{
@@ -672,7 +632,7 @@ void Map::ProcessRelocationNotifies(const uint32 diff)
if (!isCellMarked(cell_id))
continue;
- CellPair pair(x, y);
+ CellCoord pair(x, y);
Cell cell(pair);
cell.SetNoCreate();
Visit(cell, grid_notifier);
@@ -682,29 +642,16 @@ void Map::ProcessRelocationNotifies(const uint32 diff)
}
}
-void Map::RemoveFromMap(Player* player, bool remove)
+void Map::RemovePlayerFromMap(Player* player, bool remove)
{
player->RemoveFromWorld();
SendRemoveTransports(player);
- CellPair p = Trinity::ComputeCellPair(player->GetPositionX(), player->GetPositionY());
- if (p.x_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP || p.y_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP)
- sLog->outCrash("Map::Remove: Player is in invalid cell!");
+ player->UpdateObjectVisibility(true);
+ if (player->IsInGrid())
+ player->RemoveFromGrid();
else
- {
- Cell cell(p);
- if (!getNGrid(cell.data.Part.grid_x, cell.data.Part.grid_y))
- sLog->outError("Map::Remove() i_grids was NULL x:%d, y:%d", cell.data.Part.grid_x, cell.data.Part.grid_y);
- else
- {
- sLog->outStaticDebug("Remove player %s from grid[%u, %u]", player->GetName(), cell.GridX(), cell.GridY());
- NGridType *grid = getNGrid(cell.GridX(), cell.GridY());
- ASSERT(grid != NULL);
-
- player->UpdateObjectVisibility(true);
- RemoveFromGrid(player, grid, cell);
- }
- }
+ ASSERT(remove); //maybe deleted in logoutplayer when player is not in a map
if (remove)
DeleteFromWorld(player);
@@ -720,22 +667,8 @@ Map::RemoveFromMap(T *obj, bool remove)
if (obj->isActiveObject())
RemoveFromActive(obj);
- CellPair p = Trinity::ComputeCellPair(obj->GetPositionX(), obj->GetPositionY());
- if (p.x_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP || p.y_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP)
- sLog->outError("Map::Remove: Object " UI64FMTD " has invalid coordinates X:%f Y:%f grid cell [%u:%u]", obj->GetGUID(), obj->GetPositionX(), obj->GetPositionY(), p.x_coord, p.y_coord);
- else
- {
- Cell cell(p);
- if (loaded(GridPair(cell.data.Part.grid_x, cell.data.Part.grid_y)))
- {
- sLog->outStaticDebug("Remove object " UI64FMTD " from grid[%u, %u]", obj->GetGUID(), cell.data.Part.grid_x, cell.data.Part.grid_y);
- NGridType *grid = getNGrid(cell.GridX(), cell.GridY());
- ASSERT(grid != NULL);
-
- obj->UpdateObjectVisibility(true);
- RemoveFromGrid(obj, grid, cell);
- }
- }
+ obj->UpdateObjectVisibility(true);
+ obj->RemoveFromGrid();
obj->ResetMap();
@@ -753,11 +686,8 @@ Map::PlayerRelocation(Player* player, float x, float y, float z, float orientati
{
ASSERT(player);
- CellPair old_val = Trinity::ComputeCellPair(player->GetPositionX(), player->GetPositionY());
- CellPair new_val = Trinity::ComputeCellPair(x, y);
-
- Cell old_cell(old_val);
- Cell new_cell(new_val);
+ Cell old_cell(player->GetPositionX(), player->GetPositionY());
+ Cell new_cell(x, y);
player->Relocate(x, y, z, orientation);
@@ -765,14 +695,12 @@ Map::PlayerRelocation(Player* player, float x, float y, float z, float orientati
{
sLog->outStaticDebug("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());
- NGridType* oldGrid = getNGrid(old_cell.GridX(), old_cell.GridY());
- RemoveFromGrid(player, oldGrid, old_cell);
+ player->RemoveFromGrid();
if (old_cell.DiffGrid(new_cell))
- EnsureGridLoadedAtEnter(new_cell, player);
+ EnsureGridLoadedForActiveObject(new_cell, player);
- NGridType* newGrid = getNGrid(new_cell.GridX(), new_cell.GridY());
- AddToGrid(player, newGrid, new_cell);
+ AddToGrid(player, new_cell);
}
player->UpdateObjectVisibility(false);
@@ -784,9 +712,7 @@ Map::CreatureRelocation(Creature* creature, float x, float y, float z, float ang
ASSERT(CheckGridIntegrity(creature, false));
Cell old_cell = creature->GetCurrentCell();
-
- CellPair new_val = Trinity::ComputeCellPair(x, y);
- Cell new_cell(new_val);
+ Cell new_cell(x, y);
if (!respawnRelocationOnFail && !getNGrid(new_cell.GridX(), new_cell.GridY()))
return;
@@ -815,7 +741,7 @@ void Map::AddCreatureToMoveList(Creature* c, float x, float y, float z, float an
if (_creatureToMoveLock) //can this happen?
return;
- if(c->_moveState == CREATURE_CELL_MOVE_NONE)
+ if (c->_moveState == CREATURE_CELL_MOVE_NONE)
_creaturesToMove.push_back(c);
c->SetNewCellPosition(x, y, z, ang);
}
@@ -825,7 +751,7 @@ void Map::RemoveCreatureFromMoveList(Creature* c)
if (_creatureToMoveLock) //can this happen?
return;
- if(c->_moveState == CREATURE_CELL_MOVE_ACTIVE)
+ if (c->_moveState == CREATURE_CELL_MOVE_ACTIVE)
c->_moveState = CREATURE_CELL_MOVE_INACTIVE;
}
@@ -849,11 +775,11 @@ void Map::MoveAllCreaturesInMoveList()
continue;
// do move or do move to respawn or remove creature if previous all fail
- if (CreatureCellRelocation(c, Cell(Trinity::ComputeCellPair(c->_newPosition.m_positionX, c->_newPosition.m_positionY))))
+ if (CreatureCellRelocation(c, Cell(c->_newPosition.m_positionX, c->_newPosition.m_positionY)))
{
// update pos
c->Relocate(c->_newPosition);
- //CreatureRelocationNotify(c, new_cell, new_cell.cellPair());
+ //CreatureRelocationNotify(c, new_cell, new_cell.cellCoord());
c->UpdateObjectVisibility(false);
}
else
@@ -895,8 +821,8 @@ bool Map::CreatureCellRelocation(Creature* c, Cell new_cell)
sLog->outDebug(LOG_FILTER_MAPS, "Creature (GUID: %u Entry: %u) moved in grid[%u, %u] from cell[%u, %u] to cell[%u, %u].", c->GetGUIDLow(), c->GetEntry(), old_cell.GridX(), old_cell.GridY(), old_cell.CellX(), old_cell.CellY(), new_cell.CellX(), new_cell.CellY());
#endif
- RemoveFromGrid(c, getNGrid(old_cell.GridX(), old_cell.GridY()), old_cell);
- AddToGrid(c, getNGrid(new_cell.GridX(), new_cell.GridY()), new_cell);
+ c->RemoveFromGrid();
+ AddToGrid(c, new_cell);
}
else
{
@@ -911,28 +837,28 @@ bool Map::CreatureCellRelocation(Creature* c, Cell new_cell)
// in diff. grids but active creature
if (c->isActiveObject())
{
- EnsureGridLoadedAtEnter(new_cell);
+ EnsureGridLoadedForActiveObject(new_cell, c);
#ifdef TRINITY_DEBUG
sLog->outDebug(LOG_FILTER_MAPS, "Active creature (GUID: %u Entry: %u) moved from grid[%u, %u]cell[%u, %u] to grid[%u, %u]cell[%u, %u].", c->GetGUIDLow(), c->GetEntry(), old_cell.GridX(), old_cell.GridY(), old_cell.CellX(), old_cell.CellY(), new_cell.GridX(), new_cell.GridY(), new_cell.CellX(), new_cell.CellY());
#endif
- RemoveFromGrid(c, getNGrid(old_cell.GridX(), old_cell.GridY()), old_cell);
- AddToGrid(c, getNGrid(new_cell.GridX(), new_cell.GridY()), new_cell);
+ c->RemoveFromGrid();
+ AddToGrid(c, new_cell);
return true;
}
// in diff. loaded grid normal creature
- if (loaded(GridPair(new_cell.GridX(), new_cell.GridY())))
+ if (IsGridLoaded(GridCoord(new_cell.GridX(), new_cell.GridY())))
{
#ifdef TRINITY_DEBUG
sLog->outDebug(LOG_FILTER_MAPS, "Creature (GUID: %u Entry: %u) moved from grid[%u, %u]cell[%u, %u] to grid[%u, %u]cell[%u, %u].", c->GetGUIDLow(), c->GetEntry(), old_cell.GridX(), old_cell.GridY(), old_cell.CellX(), old_cell.CellY(), new_cell.GridX(), new_cell.GridY(), new_cell.CellX(), new_cell.CellY());
#endif
- RemoveFromGrid(c, getNGrid(old_cell.GridX(), old_cell.GridY()), old_cell);
- EnsureGridCreated(GridPair(new_cell.GridX(), new_cell.GridY()));
- AddToGrid(c, getNGrid(new_cell.GridX(), new_cell.GridY()), new_cell);
+ c->RemoveFromGrid();
+ EnsureGridCreated(GridCoord(new_cell.GridX(), new_cell.GridY()));
+ AddToGrid(c, new_cell);
return true;
}
@@ -947,12 +873,11 @@ bool Map::CreatureCellRelocation(Creature* c, Cell new_cell)
bool Map::CreatureRespawnRelocation(Creature* c, bool diffGridOnly)
{
float resp_x, resp_y, resp_z, resp_o;
- c->GetRespawnCoord(resp_x, resp_y, resp_z, &resp_o);
- CellPair resp_val = Trinity::ComputeCellPair(resp_x, resp_y);
- Cell resp_cell(resp_val);
+ c->GetRespawnPosition(resp_x, resp_y, resp_z, &resp_o);
+ Cell resp_cell(resp_x, resp_y);
//creature will be unloaded with grid
- if(diffGridOnly && !c->GetCurrentCell().DiffGrid(resp_cell))
+ if (diffGridOnly && !c->GetCurrentCell().DiffGrid(resp_cell))
return true;
c->CombatStop();
@@ -967,7 +892,7 @@ bool Map::CreatureRespawnRelocation(Creature* c, bool diffGridOnly)
{
c->Relocate(resp_x, resp_y, resp_z, resp_o);
c->GetMotionMaster()->Initialize(); // prevent possible problems with default move generators
- //CreatureRelocationNotify(c, resp_cell, resp_cell.cellPair());
+ //CreatureRelocationNotify(c, resp_cell, resp_cell.GetCellCoord());
c->UpdateObjectVisibility(false);
return true;
}
@@ -975,19 +900,17 @@ bool Map::CreatureRespawnRelocation(Creature* c, bool diffGridOnly)
return false;
}
-bool Map::UnloadGrid(const uint32 x, const uint32 y, bool unloadAll)
+bool Map::UnloadGrid(NGridType& ngrid, bool unloadAll)
{
- NGridType *grid = getNGrid(x, y);
- ASSERT(grid != NULL);
+ const uint32 x = ngrid.getX();
+ const uint32 y = ngrid.getY();
{
- if (!unloadAll && ActiveObjectsNearGrid(x, y))
+ if (!unloadAll && ActiveObjectsNearGrid(ngrid))
return false;
sLog->outDebug(LOG_FILTER_MAPS, "Unloading grid[%u, %u] for map %u", x, y, GetId());
- ObjectGridUnloader unloader(*grid);
-
if (!unloadAll)
{
// Finish creature moves, remove and delete all creatures with delayed remove before moving to respawn grids
@@ -995,22 +918,31 @@ bool Map::UnloadGrid(const uint32 x, const uint32 y, bool unloadAll)
MoveAllCreaturesInMoveList();
// move creatures to respawn grids if this is diff.grid or to remove list
- unloader.MoveToRespawnN();
+ ObjectGridEvacuator worker;
+ TypeContainerVisitor<ObjectGridEvacuator, GridTypeMapContainer> visitor(worker);
+ ngrid.VisitAllGrids(visitor);
// Finish creature moves, remove and delete all creatures with delayed remove before unload
MoveAllCreaturesInMoveList();
}
- ObjectGridCleaner cleaner(*grid);
- cleaner.CleanN();
+ {
+ ObjectGridCleaner worker;
+ TypeContainerVisitor<ObjectGridCleaner, GridTypeMapContainer> visitor(worker);
+ ngrid.VisitAllGrids(visitor);
+ }
RemoveAllObjectsInRemoveList();
- unloader.UnloadN();
+ {
+ ObjectGridUnloader worker;
+ TypeContainerVisitor<ObjectGridUnloader, GridTypeMapContainer> visitor(worker);
+ ngrid.VisitAllGrids(visitor);
+ }
ASSERT(i_objectsToRemove.empty());
- delete grid;
+ delete &ngrid;
setNGrid(NULL, x, y);
}
int gx = (MAX_NUMBER_OF_GRIDS - 1) - x;
@@ -1030,7 +962,7 @@ bool Map::UnloadGrid(const uint32 x, const uint32 y, bool unloadAll)
VMAP::VMapFactory::createOrGetVMapManager()->unloadMap(GetId(), gx, gy);
}
else
- ((MapInstanced*)m_parentMap)->RemoveGridMapReference(GridPair(gx, gy));
+ ((MapInstanced*)m_parentMap)->RemoveGridMapReference(GridCoord(gx, gy));
GridMaps[gx][gy] = NULL;
}
@@ -1044,12 +976,12 @@ void Map::RemoveAllPlayers()
{
for (MapRefManager::iterator itr = m_mapRefManager.begin(); itr != m_mapRefManager.end(); ++itr)
{
- Player* plr = itr->getSource();
- if (!plr->IsBeingTeleportedFar())
+ Player* player = itr->getSource();
+ if (!player->IsBeingTeleportedFar())
{
// this is happening for bg
- sLog->outError("Map::UnloadAll: player %s is still in map %u during unload, this should not happen!", plr->GetName(), GetId());
- plr->TeleportTo(plr->m_homebindMapId, plr->m_homebindX, plr->m_homebindY, plr->m_homebindZ, plr->GetOrientation());
+ sLog->outError("Map::UnloadAll: player %s is still in map %u during unload, this should not happen!", player->GetName(), GetId());
+ player->TeleportTo(player->m_homebindMapId, player->m_homebindX, player->m_homebindY, player->m_homebindZ, player->GetOrientation());
}
}
}
@@ -1064,7 +996,7 @@ void Map::UnloadAll()
{
NGridType &grid(*i->getSource());
++i;
- UnloadGrid(grid.getX(), grid.getY(), true); // deletes the grid and removes it from the GridRefManager
+ UnloadGrid(grid, true); // deletes the grid and removes it from the GridRefManager
}
}
@@ -1589,7 +1521,7 @@ inline GridMap* Map::GetGrid(float x, float y)
int gy=(int)(32-y/SIZE_OF_GRIDS); //grid y
// ensure GridMap is loaded
- EnsureGridCreated(GridPair(63-gx, 63-gy));
+ EnsureGridCreated(GridCoord(63-gx, 63-gy));
return GridMaps[gx][gy];
}
@@ -1858,7 +1790,7 @@ bool Map::IsInWater(float x, float y, float pZ, LiquidData* data) const
LiquidData liquid_status;
LiquidData* liquid_ptr = data ? data : &liquid_status;
if (getLiquidStatus(x, y, pZ, MAP_ALL_LIQUIDS, liquid_ptr))
- return true;
+ return true;
}
return false;
}
@@ -1876,9 +1808,7 @@ bool Map::IsUnderWater(float x, float y, float z) const
bool Map::CheckGridIntegrity(Creature* c, bool moved) const
{
Cell const& cur_cell = c->GetCurrentCell();
-
- CellPair xy_val = Trinity::ComputeCellPair(c->GetPositionX(), c->GetPositionY());
- Cell xy_cell(xy_val);
+ Cell xy_cell(c->GetPositionX(), c->GetPositionY());
if (xy_cell != cur_cell)
{
sLog->outDebug(LOG_FILTER_MAPS, "Creature (GUID: %u) X: %f Y: %f (%s) is in grid[%u, %u]cell[%u, %u] instead of grid[%u, %u]cell[%u, %u]",
@@ -1897,20 +1827,18 @@ const char* Map::GetMapName() const
return i_mapEntry ? i_mapEntry->name[sWorld->GetDefaultDbcLocale()] : "UNNAMEDMAP\x0";
}
-void Map::UpdateObjectVisibility(WorldObject* obj, Cell cell, CellPair cellpair)
+void Map::UpdateObjectVisibility(WorldObject* obj, Cell cell, CellCoord cellpair)
{
- cell.data.Part.reserved = ALL_DISTRICT;
cell.SetNoCreate();
Trinity::VisibleChangesNotifier notifier(*obj);
TypeContainerVisitor<Trinity::VisibleChangesNotifier, WorldTypeMapContainer > player_notifier(notifier);
cell.Visit(cellpair, player_notifier, *this, *obj, obj->GetVisibilityRange());
}
-void Map::UpdateObjectsVisibilityFor(Player* player, Cell cell, CellPair cellpair)
+void Map::UpdateObjectsVisibilityFor(Player* player, Cell cell, CellCoord cellpair)
{
Trinity::VisibleNotifier notifier(*player);
- cell.data.Part.reserved = ALL_DISTRICT;
cell.SetNoCreate();
TypeContainerVisitor<Trinity::VisibleNotifier, WorldTypeMapContainer > world_notifier(notifier);
TypeContainerVisitor<Trinity::VisibleNotifier, GridTypeMapContainer > grid_notifier(notifier);
@@ -2027,7 +1955,7 @@ void Map::DelayedUpdate(const uint32 t_diff)
GridInfo* info = i->getSource()->getGridInfoRef();
++i; // The update might delete the map and we need the next map before the iterator gets invalid
ASSERT(grid->GetGridState() >= 0 && grid->GetGridState() < MAX_GRID_STATE);
- si_GridStates[grid->GetGridState()]->Update(*this, *grid, *info, grid->getX(), grid->getY(), t_diff);
+ si_GridStates[grid->GetGridState()]->Update(*this, *grid, *info, t_diff);
}
}
}
@@ -2130,28 +2058,25 @@ void Map::SendToPlayers(WorldPacket const* data) const
itr->getSource()->GetSession()->SendPacket(data);
}
-bool Map::ActiveObjectsNearGrid(uint32 x, uint32 y) const
+bool Map::ActiveObjectsNearGrid(NGridType const& ngrid) const
{
- ASSERT(x < MAX_NUMBER_OF_GRIDS);
- ASSERT(y < MAX_NUMBER_OF_GRIDS);
-
- CellPair cell_min(x*MAX_NUMBER_OF_CELLS, y*MAX_NUMBER_OF_CELLS);
- CellPair cell_max(cell_min.x_coord + MAX_NUMBER_OF_CELLS, cell_min.y_coord+MAX_NUMBER_OF_CELLS);
+ CellCoord cell_min(ngrid.getX() * MAX_NUMBER_OF_CELLS, ngrid.getY() * MAX_NUMBER_OF_CELLS);
+ CellCoord cell_max(cell_min.x_coord + MAX_NUMBER_OF_CELLS, cell_min.y_coord+MAX_NUMBER_OF_CELLS);
//we must find visible range in cells so we unload only non-visible cells...
float viewDist = GetVisibilityRange();
int cell_range = (int)ceilf(viewDist / SIZE_OF_GRID_CELL) + 1;
- cell_min << cell_range;
- cell_min -= cell_range;
- cell_max >> cell_range;
- cell_max += cell_range;
+ cell_min.dec_x(cell_range);
+ cell_min.dec_y(cell_range);
+ cell_max.inc_x(cell_range);
+ cell_max.inc_y(cell_range);
for (MapRefManager::const_iterator iter = m_mapRefManager.begin(); iter != m_mapRefManager.end(); ++iter)
{
- Player* plr = iter->getSource();
+ Player* player = iter->getSource();
- CellPair p = Trinity::ComputeCellPair(plr->GetPositionX(), plr->GetPositionY());
+ CellCoord p = Trinity::ComputeCellCoord(player->GetPositionX(), player->GetPositionY());
if ((cell_min.x_coord <= p.x_coord && p.x_coord <= cell_max.x_coord) &&
(cell_min.y_coord <= p.y_coord && p.y_coord <= cell_max.y_coord))
return true;
@@ -2161,7 +2086,7 @@ bool Map::ActiveObjectsNearGrid(uint32 x, uint32 y) const
{
WorldObject* obj = *iter;
- CellPair p = Trinity::ComputeCellPair(obj->GetPositionX(), obj->GetPositionY());
+ CellCoord p = Trinity::ComputeCellCoord(obj->GetPositionX(), obj->GetPositionY());
if ((cell_min.x_coord <= p.x_coord && p.x_coord <= cell_max.x_coord) &&
(cell_min.y_coord <= p.y_coord && p.y_coord <= cell_max.y_coord))
return true;
@@ -2178,13 +2103,13 @@ void Map::AddToActive(Creature* c)
if (!c->isPet() && c->GetDBTableGUIDLow())
{
float x, y, z;
- c->GetRespawnCoord(x, y, z);
- GridPair p = Trinity::ComputeGridPair(x, y);
+ c->GetRespawnPosition(x, y, z);
+ GridCoord p = Trinity::ComputeGridCoord(x, y);
if (getNGrid(p.x_coord, p.y_coord))
getNGrid(p.x_coord, p.y_coord)->incUnloadActiveLock();
else
{
- GridPair p2 = Trinity::ComputeGridPair(c->GetPositionX(), c->GetPositionY());
+ GridCoord p2 = Trinity::ComputeGridCoord(c->GetPositionX(), c->GetPositionY());
sLog->outError("Active creature (GUID: %u Entry: %u) added to grid[%u, %u] but spawn grid[%u, %u] was not loaded.",
c->GetGUIDLow(), c->GetEntry(), p.x_coord, p.y_coord, p2.x_coord, p2.y_coord);
}
@@ -2199,13 +2124,13 @@ void Map::RemoveFromActive(Creature* c)
if (!c->isPet() && c->GetDBTableGUIDLow())
{
float x, y, z;
- c->GetRespawnCoord(x, y, z);
- GridPair p = Trinity::ComputeGridPair(x, y);
+ c->GetRespawnPosition(x, y, z);
+ GridCoord p = Trinity::ComputeGridCoord(x, y);
if (getNGrid(p.x_coord, p.y_coord))
getNGrid(p.x_coord, p.y_coord)->decUnloadActiveLock();
else
{
- GridPair p2 = Trinity::ComputeGridPair(c->GetPositionX(), c->GetPositionY());
+ GridCoord p2 = Trinity::ComputeGridCoord(c->GetPositionX(), c->GetPositionY());
sLog->outError("Active creature (GUID: %u Entry: %u) removed from grid[%u, %u] but spawn grid[%u, %u] was not loaded.",
c->GetGUIDLow(), c->GetEntry(), p.x_coord, p.y_coord, p2.x_coord, p2.y_coord);
}
@@ -2315,14 +2240,14 @@ bool InstanceMap::CanEnter(Player* player)
/*
Do map specific checks and add the player to the map if successful.
*/
-bool InstanceMap::AddToMap(Player* player)
+bool InstanceMap::AddPlayerToMap(Player* player)
{
// TODO: Not sure about checking player level: already done in HandleAreaTriggerOpcode
// GMs still can teleport player in instance.
// Is it needed?
{
- ACE_GUARD_RETURN(ACE_Thread_Mutex, guard, Lock, false);
+ TRINITY_GUARD(ACE_Thread_Mutex, Lock);
// Check moved to void WorldSession::HandleMoveWorldportAckOpcode()
//if (!CanEnter(player))
//return false;
@@ -2425,7 +2350,7 @@ bool InstanceMap::AddToMap(Player* player)
}
// this will acquire the same mutex so it cannot be in the previous block
- Map::AddToMap(player);
+ Map::AddPlayerToMap(player);
if (i_data)
i_data->OnPlayerEnter(player);
@@ -2441,13 +2366,13 @@ void InstanceMap::Update(const uint32 t_diff)
i_data->Update(t_diff);
}
-void InstanceMap::RemoveFromMap(Player* player, bool remove)
+void InstanceMap::RemovePlayerFromMap(Player* player, bool remove)
{
sLog->outDetail("MAP: Removing player '%s' from instance '%u' of map '%s' before relocating to another map", player->GetName(), 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);
- Map::RemoveFromMap(player, remove);
+ Map::RemovePlayerFromMap(player, remove);
// for normal instances schedule the reset after all players have left
SetResetSchedule(true);
}
@@ -2526,7 +2451,7 @@ bool InstanceMap::Reset(uint8 method)
return m_mapRefManager.isEmpty();
}
-void InstanceMap::PermBindAllPlayers(Player* player)
+void InstanceMap::PermBindAllPlayers(Player* source)
{
if (!IsDungeon())
return;
@@ -2534,28 +2459,28 @@ void InstanceMap::PermBindAllPlayers(Player* player)
InstanceSave* save = sInstanceSaveMgr->GetInstanceSave(GetInstanceId());
if (!save)
{
- sLog->outError("Cannot bind player (GUID: %u, Name: %s), because no instance save is available for instance map (Name: %s, Entry: %u, InstanceId: %u)!", player->GetGUIDLow(), player->GetName(), player->GetMap()->GetMapName(), player->GetMapId(), GetInstanceId());
+ sLog->outError("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());
return;
}
- Group* group = player->GetGroup();
+ Group* group = source->GetGroup();
// group members outside the instance group don't get bound
for (MapRefManager::iterator itr = m_mapRefManager.begin(); itr != m_mapRefManager.end(); ++itr)
{
- Player* plr = itr->getSource();
+ Player* player = itr->getSource();
// players inside an instance cannot be bound to other instances
// some players may already be permanently bound, in this case nothing happens
- InstancePlayerBind* bind = plr->GetBoundInstance(save->GetMapId(), save->GetDifficulty());
+ InstancePlayerBind* bind = player->GetBoundInstance(save->GetMapId(), save->GetDifficulty());
if (!bind || !bind->perm)
{
- plr->BindToInstance(save, true);
+ player->BindToInstance(save, true);
WorldPacket data(SMSG_INSTANCE_SAVE_CREATED, 4);
data << uint32(0);
- plr->GetSession()->SendPacket(&data);
+ player->GetSession()->SendPacket(&data);
}
// if the leader is not in the instance the group will not get a perm bind
- if (group && group->GetLeaderGUID() == plr->GetGUID())
+ if (group && group->GetLeaderGUID() == player->GetGUID())
group->BindToInstance(save, true);
}
}
@@ -2661,23 +2586,23 @@ bool BattlegroundMap::CanEnter(Player* player)
return Map::CanEnter(player);
}
-bool BattlegroundMap::AddToMap(Player* player)
+bool BattlegroundMap::AddPlayerToMap(Player* player)
{
{
- ACE_GUARD_RETURN(ACE_Thread_Mutex, guard, Lock, false);
+ TRINITY_GUARD(ACE_Thread_Mutex, Lock);
//Check moved to void WorldSession::HandleMoveWorldportAckOpcode()
//if (!CanEnter(player))
//return false;
// reset instance validity, battleground maps do not homebind
player->m_InstanceValid = true;
}
- return Map::AddToMap(player);
+ return Map::AddPlayerToMap(player);
}
-void BattlegroundMap::RemoveFromMap(Player* player, bool remove)
+void BattlegroundMap::RemovePlayerFromMap(Player* player, bool remove)
{
sLog->outDetail("MAP: Removing player '%s' from bg '%u' of map '%s' before relocating to another map", player->GetName(), GetInstanceId(), GetMapName());
- Map::RemoveFromMap(player, remove);
+ Map::RemovePlayerFromMap(player, remove);
}
void BattlegroundMap::SetUnload()
@@ -2689,9 +2614,9 @@ void BattlegroundMap::RemoveAllPlayers()
{
if (HavePlayers())
for (MapRefManager::iterator itr = m_mapRefManager.begin(); itr != m_mapRefManager.end(); ++itr)
- if (Player* plr = itr->getSource())
- if (!plr->IsBeingTeleportedFar())
- plr->TeleportTo(plr->GetBattlegroundEntryPoint());
+ if (Player* player = itr->getSource())
+ if (!player->IsBeingTeleportedFar())
+ player->TeleportTo(player->GetBattlegroundEntryPoint());
}
Creature*
diff --git a/src/server/game/Maps/Map.h b/src/server/game/Maps/Map.h
index fd58fd0cc72..9caef8457b8 100755
--- a/src/server/game/Maps/Map.h
+++ b/src/server/game/Maps/Map.h
@@ -244,8 +244,8 @@ class Map : public GridRefManager<NGridType>
return false;
}
- virtual bool AddToMap(Player*);
- virtual void RemoveFromMap(Player*, bool);
+ virtual bool AddPlayerToMap(Player*);
+ virtual void RemovePlayerFromMap(Player*, bool);
template<class T> void AddToMap(T *);
template<class T> void RemoveFromMap(T *, bool);
@@ -263,20 +263,19 @@ class Map : public GridRefManager<NGridType>
bool IsRemovalGrid(float x, float y) const
{
- GridPair p = Trinity::ComputeGridPair(x, y);
+ GridCoord p = Trinity::ComputeGridCoord(x, y);
return !getNGrid(p.x_coord, p.y_coord) || getNGrid(p.x_coord, p.y_coord)->GetGridState() == GRID_STATE_REMOVAL;
}
- bool IsLoaded(float x, float y) const
+ bool IsGridLoaded(float x, float y) const
{
- GridPair p = Trinity::ComputeGridPair(x, y);
- return loaded(p);
+ return IsGridLoaded(Trinity::ComputeGridCoord(x, y));
}
- bool GetUnloadLock(const GridPair &p) const { return getNGrid(p.x_coord, p.y_coord)->getUnloadLock(); }
- void SetUnloadLock(const GridPair &p, bool on) { getNGrid(p.x_coord, p.y_coord)->setUnloadExplicitLock(on); }
+ bool GetUnloadLock(const GridCoord &p) const { return getNGrid(p.x_coord, p.y_coord)->getUnloadLock(); }
+ void SetUnloadLock(const GridCoord &p, bool on) { getNGrid(p.x_coord, p.y_coord)->setUnloadExplicitLock(on); }
void LoadGrid(float x, float y);
- bool UnloadGrid(const uint32 x, const uint32 y, bool pForce);
+ bool UnloadGrid(NGridType& ngrid, bool pForce);
virtual void UnloadAll();
void ResetGridExpiry(NGridType &grid, float factor = 1) const
@@ -371,8 +370,8 @@ class Map : public GridRefManager<NGridType>
void AddObjectToSwitchList(WorldObject* obj, bool on);
virtual void DelayedUpdate(const uint32 diff);
- void UpdateObjectVisibility(WorldObject* obj, Cell cell, CellPair cellpair);
- void UpdateObjectsVisibilityFor(Player* player, Cell cell, CellPair cellpair);
+ void UpdateObjectVisibility(WorldObject* obj, Cell cell, CellCoord cellpair);
+ void UpdateObjectsVisibilityFor(Player* player, Cell cell, CellCoord cellpair);
void resetMarkedCells() { marked_cells.reset(); }
bool isCellMarked(uint32 pCellId) { return marked_cells.test(pCellId); }
@@ -380,7 +379,7 @@ class Map : public GridRefManager<NGridType>
bool HavePlayers() const { return !m_mapRefManager.isEmpty(); }
uint32 GetPlayersCountExceptGMs() const;
- bool ActiveObjectsNearGrid(uint32 x, uint32 y) const;
+ bool ActiveObjectsNearGrid(NGridType const& ngrid) const;
void AddWorldObject(WorldObject* obj) { i_worldObjects.insert(obj); }
void RemoveWorldObject(WorldObject* obj) { i_worldObjects.erase(obj); }
@@ -420,8 +419,8 @@ class Map : public GridRefManager<NGridType>
GameObject* GetGameObject(uint64 guid);
DynamicObject* GetDynamicObject(uint64 guid);
- MapInstanced* ToMainstanced(){ if (Instanceable()) return reinterpret_cast<MapInstanced*>(this); else return NULL; }
- const MapInstanced* ToMainstanced() const { if (Instanceable()) return (const MapInstanced*)((MapInstanced*)this); else return NULL; }
+ MapInstanced* ToMapInstanced(){ if (Instanceable()) return reinterpret_cast<MapInstanced*>(this); else return NULL; }
+ const MapInstanced* ToMapInstanced() const { if (Instanceable()) return (const MapInstanced*)((MapInstanced*)this); else return NULL; }
InstanceMap* ToInstanceMap(){ if (IsDungeon()) return reinterpret_cast<InstanceMap*>(this); else return NULL; }
const InstanceMap* ToInstanceMap() const { if (IsDungeon()) return (const InstanceMap*)((InstanceMap*)this); else return NULL; }
@@ -443,13 +442,14 @@ class Map : public GridRefManager<NGridType>
template<class T> void InitializeObject(T* obj);
void AddCreatureToMoveList(Creature* c, float x, float y, float z, float ang);
void RemoveCreatureFromMoveList(Creature* c);
+
bool _creatureToMoveLock;
std::vector<Creature*> _creaturesToMove;
- bool loaded(const GridPair &) const;
- void EnsureGridCreated(const GridPair &);
+ bool IsGridLoaded(const GridCoord &) const;
+ void EnsureGridCreated(const GridCoord &);
bool EnsureGridLoaded(Cell const&);
- void EnsureGridLoadedAtEnter(Cell const&, Player* player = NULL);
+ void EnsureGridLoadedForActiveObject(Cell const&, WorldObject* object);
void buildNGridLinkage(NGridType* pNGridType) { pNGridType->link(this); }
@@ -458,8 +458,7 @@ class Map : public GridRefManager<NGridType>
NGridType* getNGrid(uint32 x, uint32 y) const
{
- ASSERT(x < MAX_NUMBER_OF_GRIDS);
- ASSERT(y < MAX_NUMBER_OF_GRIDS);
+ ASSERT(x < MAX_NUMBER_OF_GRIDS && y < MAX_NUMBER_OF_GRIDS);
return i_grids[x][y];
}
@@ -471,7 +470,7 @@ class Map : public GridRefManager<NGridType>
void UpdateActiveCells(const float &x, const float &y, const uint32 t_diff);
protected:
- void SetUnloadReferenceLock(const GridPair &p, bool on) { getNGrid(p.x_coord, p.y_coord)->setUnloadReferenceLock(on); }
+ void SetUnloadReferenceLock(const GridCoord &p, bool on) { getNGrid(p.x_coord, p.y_coord)->setUnloadReferenceLock(on); }
ACE_Thread_Mutex Lock;
@@ -524,10 +523,7 @@ class Map : public GridRefManager<NGridType>
// Type specific code for add/remove to/from grid
template<class T>
- void AddToGrid(T*, NGridType *, Cell const&);
-
- template<class T>
- void RemoveFromGrid(T*, NGridType *, Cell const&);
+ void AddToGrid(T* object, Cell const& cell);
template<class T>
void DeleteFromWorld(T*);
@@ -571,14 +567,14 @@ class InstanceMap : public Map
public:
InstanceMap(uint32 id, time_t, uint32 InstanceId, uint8 SpawnMode, Map* _parent);
~InstanceMap();
- bool AddToMap(Player*);
- void RemoveFromMap(Player*, bool);
+ bool AddPlayerToMap(Player*);
+ void RemovePlayerFromMap(Player*, bool);
void Update(const uint32);
void CreateInstanceData(bool load);
bool Reset(uint8 method);
uint32 GetScriptId() { return i_script_id; }
InstanceScript* GetInstanceScript() { return i_data; }
- void PermBindAllPlayers(Player* player);
+ void PermBindAllPlayers(Player* source);
void UnloadAll();
bool CanEnter(Player* player);
void SendResetWarnings(uint32 timeLeft) const;
@@ -601,8 +597,8 @@ class BattlegroundMap : public Map
BattlegroundMap(uint32 id, time_t, uint32 InstanceId, Map* _parent, uint8 spawnMode);
~BattlegroundMap();
- bool AddToMap(Player*);
- void RemoveFromMap(Player*, bool);
+ bool AddPlayerToMap(Player*);
+ void RemovePlayerFromMap(Player*, bool);
bool CanEnter(Player* player);
void SetUnload();
//void UnloadAll(bool pForce);
@@ -616,28 +612,25 @@ class BattlegroundMap : public Map
};
template<class T, class CONTAINER>
-inline void
-Map::Visit(const Cell& cell, TypeContainerVisitor<T, CONTAINER> &visitor)
+inline void Map::Visit(Cell const& cell, TypeContainerVisitor<T, CONTAINER>& visitor)
{
const uint32 x = cell.GridX();
const uint32 y = cell.GridY();
const uint32 cell_x = cell.CellX();
const uint32 cell_y = cell.CellY();
- if (!cell.NoCreate() || loaded(GridPair(x, y)))
+ if (!cell.NoCreate() || IsGridLoaded(GridCoord(x, y)))
{
EnsureGridLoaded(cell);
- getNGrid(x, y)->Visit(cell_x, cell_y, visitor);
+ getNGrid(x, y)->VisitGrid(cell_x, cell_y, visitor);
}
}
template<class NOTIFIER>
-inline void
-Map::VisitAll(const float &x, const float &y, float radius, NOTIFIER &notifier)
+inline void Map::VisitAll(float const& x, float const& y, float radius, NOTIFIER& notifier)
{
- CellPair p(Trinity::ComputeCellPair(x, y));
+ CellCoord p(Trinity::ComputeCellCoord(x, y));
Cell cell(p);
- cell.data.Part.reserved = ALL_DISTRICT;
cell.SetNoCreate();
TypeContainerVisitor<NOTIFIER, WorldTypeMapContainer> world_object_notifier(notifier);
@@ -648,12 +641,10 @@ Map::VisitAll(const float &x, const float &y, float radius, NOTIFIER &notifier)
// should be used with Searcher notifiers, tries to search world if nothing found in grid
template<class NOTIFIER>
-inline void
-Map::VisitFirstFound(const float &x, const float &y, float radius, NOTIFIER &notifier)
+inline void Map::VisitFirstFound(const float &x, const float &y, float radius, NOTIFIER &notifier)
{
- CellPair p(Trinity::ComputeCellPair(x, y));
+ CellCoord p(Trinity::ComputeCellCoord(x, y));
Cell cell(p);
- cell.data.Part.reserved = ALL_DISTRICT;
cell.SetNoCreate();
TypeContainerVisitor<NOTIFIER, WorldTypeMapContainer> world_object_notifier(notifier);
@@ -666,12 +657,10 @@ Map::VisitFirstFound(const float &x, const float &y, float radius, NOTIFIER &not
}
template<class NOTIFIER>
-inline void
-Map::VisitWorld(const float &x, const float &y, float radius, NOTIFIER &notifier)
+inline void Map::VisitWorld(const float &x, const float &y, float radius, NOTIFIER &notifier)
{
- CellPair p(Trinity::ComputeCellPair(x, y));
+ CellCoord p(Trinity::ComputeCellCoord(x, y));
Cell cell(p);
- cell.data.Part.reserved = ALL_DISTRICT;
cell.SetNoCreate();
TypeContainerVisitor<NOTIFIER, WorldTypeMapContainer> world_object_notifier(notifier);
@@ -679,12 +668,10 @@ Map::VisitWorld(const float &x, const float &y, float radius, NOTIFIER &notifier
}
template<class NOTIFIER>
-inline void
-Map::VisitGrid(const float &x, const float &y, float radius, NOTIFIER &notifier)
+inline void Map::VisitGrid(const float &x, const float &y, float radius, NOTIFIER &notifier)
{
- CellPair p(Trinity::ComputeCellPair(x, y));
+ CellCoord p(Trinity::ComputeCellCoord(x, y));
Cell cell(p);
- cell.data.Part.reserved = ALL_DISTRICT;
cell.SetNoCreate();
TypeContainerVisitor<NOTIFIER, GridTypeMapContainer > grid_object_notifier(notifier);
diff --git a/src/server/game/Maps/MapInstanced.cpp b/src/server/game/Maps/MapInstanced.cpp
index 418218a52b3..a56a193ba64 100755
--- a/src/server/game/Maps/MapInstanced.cpp
+++ b/src/server/game/Maps/MapInstanced.cpp
@@ -110,7 +110,7 @@ void MapInstanced::UnloadAll()
- create the instance if it's not created already
- the player is not actually added to the instance (only in InstanceMap::Add)
*/
-Map* MapInstanced::CreateInstance(const uint32 mapId, Player* player)
+Map* MapInstanced::CreateInstanceForPlayer(const uint32 mapId, Player* player)
{
if (GetId() != mapId || !player)
return NULL;
@@ -124,7 +124,7 @@ Map* MapInstanced::CreateInstance(const uint32 mapId, Player* player)
// the instance id is set in battlegroundid
NewInstanceId = player->GetBattlegroundId();
if (!NewInstanceId) return NULL;
- map = _FindMap(NewInstanceId);
+ map = FindInstanceMap(NewInstanceId);
if (!map)
map = CreateBattleground(NewInstanceId, player->GetBattleground());
}
@@ -151,7 +151,7 @@ Map* MapInstanced::CreateInstance(const uint32 mapId, Player* player)
{
// solo/perm/group
NewInstanceId = pSave->GetInstanceId();
- map = _FindMap(NewInstanceId);
+ map = FindInstanceMap(NewInstanceId);
// it is possible that the save exists but the map doesn't
if (!map)
map = CreateInstance(NewInstanceId, pSave, pSave->GetDifficulty());
@@ -163,7 +163,11 @@ Map* MapInstanced::CreateInstance(const uint32 mapId, Player* player)
NewInstanceId = sMapMgr->GenerateInstanceId();
Difficulty diff = player->GetGroup() ? player->GetGroup()->GetDifficulty(IsRaid()) : player->GetDifficulty(IsRaid());
- map = CreateInstance(NewInstanceId, NULL, diff);
+ //Seems it is now possible, but I do not know if it should be allowed
+ //ASSERT(!FindInstanceMap(NewInstanceId));
+ map = FindInstanceMap(NewInstanceId);
+ if (!map)
+ map = CreateInstance(NewInstanceId, NULL, diff);
}
}
@@ -173,7 +177,7 @@ Map* MapInstanced::CreateInstance(const uint32 mapId, Player* player)
InstanceMap* MapInstanced::CreateInstance(uint32 InstanceId, InstanceSave* save, Difficulty difficulty)
{
// load/create a map
- ACE_GUARD_RETURN(ACE_Thread_Mutex, Guard, Lock, NULL);
+ TRINITY_GUARD(ACE_Thread_Mutex, Lock);
// make sure we have a valid map id
const MapEntry* entry = sMapStore.LookupEntry(GetId());
@@ -207,7 +211,7 @@ InstanceMap* MapInstanced::CreateInstance(uint32 InstanceId, InstanceSave* save,
BattlegroundMap* MapInstanced::CreateBattleground(uint32 InstanceId, Battleground* bg)
{
// load/create a map
- ACE_GUARD_RETURN(ACE_Thread_Mutex, Guard, Lock, NULL);
+ TRINITY_GUARD(ACE_Thread_Mutex, Lock);
sLog->outDebug(LOG_FILTER_MAPS, "MapInstanced::CreateBattleground: map bg %d for %d created.", InstanceId, GetId());
diff --git a/src/server/game/Maps/MapInstanced.h b/src/server/game/Maps/MapInstanced.h
index 1913f0add51..9b714cb7fb3 100755
--- a/src/server/game/Maps/MapInstanced.h
+++ b/src/server/game/Maps/MapInstanced.h
@@ -39,39 +39,36 @@ class MapInstanced : public Map
void UnloadAll();
bool CanEnter(Player* player);
- Map* CreateInstance(const uint32 mapId, Player* player);
- Map* FindMap(uint32 InstanceId) const { return _FindMap(InstanceId); }
+ Map* CreateInstanceForPlayer(const uint32 mapId, Player* player);
+ Map* FindInstanceMap(uint32 instanceId) const
+ {
+ InstancedMaps::const_iterator i = m_InstancedMaps.find(instanceId);
+ return(i == m_InstancedMaps.end() ? NULL : i->second);
+ }
bool DestroyInstance(InstancedMaps::iterator &itr);
- void AddGridMapReference(const GridPair &p)
+ void AddGridMapReference(const GridCoord &p)
{
++GridMapReference[p.x_coord][p.y_coord];
- SetUnloadReferenceLock(GridPair(63-p.x_coord, 63-p.y_coord), true);
+ SetUnloadReferenceLock(GridCoord(63-p.x_coord, 63-p.y_coord), true);
}
- void RemoveGridMapReference(GridPair const& p)
+ void RemoveGridMapReference(GridCoord const& p)
{
--GridMapReference[p.x_coord][p.y_coord];
if (!GridMapReference[p.x_coord][p.y_coord])
- SetUnloadReferenceLock(GridPair(63-p.x_coord, 63-p.y_coord), false);
+ SetUnloadReferenceLock(GridCoord(63-p.x_coord, 63-p.y_coord), false);
}
InstancedMaps &GetInstancedMaps() { return m_InstancedMaps; }
virtual void InitVisibilityDistance();
private:
-
InstanceMap* CreateInstance(uint32 InstanceId, InstanceSave* save, Difficulty difficulty);
BattlegroundMap* CreateBattleground(uint32 InstanceId, Battleground* bg);
InstancedMaps m_InstancedMaps;
- Map* _FindMap(uint32 InstanceId) const
- {
- InstancedMaps::const_iterator i = m_InstancedMaps.find(InstanceId);
- return(i == m_InstancedMaps.end() ? NULL : i->second);
- }
-
uint16 GridMapReference[MAX_NUMBER_OF_GRIDS][MAX_NUMBER_OF_GRIDS];
};
#endif
diff --git a/src/server/game/Maps/MapManager.cpp b/src/server/game/Maps/MapManager.cpp
index 0b7abacad28..f31f1348b44 100755
--- a/src/server/game/Maps/MapManager.cpp
+++ b/src/server/game/Maps/MapManager.cpp
@@ -95,13 +95,13 @@ void MapManager::checkAndCorrectGridStatesArray()
++i_GridStateErrorCount;
}
-Map* MapManager::_createBaseMap(uint32 id)
+Map* MapManager::CreateBaseMap(uint32 id)
{
- Map* m = _findMap(id);
+ Map* m = FindBaseMap(id);
if (m == NULL)
{
- ACE_GUARD_RETURN(ACE_Thread_Mutex, Guard, Lock, NULL);
+ TRINITY_GUARD(ACE_Thread_Mutex, Lock);
const MapEntry* entry = sMapStore.LookupEntry(id);
if (entry && entry->Instanceable())
@@ -119,27 +119,34 @@ Map* MapManager::_createBaseMap(uint32 id)
return m;
}
-Map* MapManager::CreateMap(uint32 id, const WorldObject* obj, uint32 /*instanceId*/)
+Map* MapManager::FindBaseNonInstanceMap(uint32 mapId) const
{
- ASSERT(obj);
- //if (!obj->IsInWorld()) sLog->outError("GetMap: called for map %d with object (typeid %d, guid %d, mapid %d, instanceid %d) who is not in world!", id, obj->GetTypeId(), obj->GetGUIDLow(), obj->GetMapId(), obj->GetInstanceId());
- Map* m = _createBaseMap(id);
+ Map* map = FindBaseMap(mapId);
+ if(map && map->Instanceable())
+ return NULL;
+ return map;
+}
+
+Map* MapManager::CreateMap(uint32 id, Player* player)
+{
+ Map* m = CreateBaseMap(id);
- if (m && (obj->GetTypeId() == TYPEID_PLAYER) && m->Instanceable()) m = ((MapInstanced*)m)->CreateInstance(id, (Player*)obj);
+ if (m && m->Instanceable())
+ m = ((MapInstanced*)m)->CreateInstanceForPlayer(id, player);
return m;
}
Map* MapManager::FindMap(uint32 mapid, uint32 instanceId) const
{
- Map* map = _findMap(mapid);
+ Map* map = FindBaseMap(mapid);
if (!map)
return NULL;
if (!map->Instanceable())
return instanceId == 0 ? map : NULL;
- return ((MapInstanced*)map)->FindMap(instanceId);
+ return ((MapInstanced*)map)->FindInstanceMap(instanceId);
}
bool MapManager::CanPlayerEnter(uint32 mapid, Player* player, bool loginCheck)
@@ -201,8 +208,8 @@ bool MapManager::CanPlayerEnter(uint32 mapid, Player* player, bool loginCheck)
if (corpseMap == mapid)
break;
- InstanceTemplate const* instance = sObjectMgr->GetInstanceTemplate(corpseMap);
- corpseMap = instance ? instance->Parent : 0;
+ InstanceTemplate const* corpseInstance = sObjectMgr->GetInstanceTemplate(corpseMap);
+ corpseMap = corpseInstance ? corpseInstance->Parent : 0;
} while (corpseMap);
if (!corpseMap)
@@ -248,7 +255,7 @@ bool MapManager::CanPlayerEnter(uint32 mapid, Player* player, bool loginCheck)
instaceIdToCheck = save->GetInstanceId();
// instanceId can never be 0 - will not be found
- if (!player->CheckInstanceCount(instaceIdToCheck))
+ if (!player->CheckInstanceCount(instaceIdToCheck) && !player->isDead())
{
player->SendTransferAborted(mapid, TRANSFER_ABORT_TOO_MANY_INSTANCES);
return false;
@@ -280,8 +287,8 @@ void MapManager::Update(uint32 diff)
iter->second->DelayedUpdate(uint32(i_timer.GetCurrent()));
sObjectAccessor->Update(uint32(i_timer.GetCurrent()));
- for (TransportSet::iterator iter = m_Transports.begin(); iter != m_Transports.end(); ++iter)
- (*iter)->Update(uint32(i_timer.GetCurrent()));
+ for (TransportSet::iterator itr = m_Transports.begin(); itr != m_Transports.end(); ++itr)
+ (*itr)->Update(uint32(i_timer.GetCurrent()));
i_timer.SetCurrent(0);
}
@@ -292,7 +299,7 @@ void MapManager::DoDelayedMovesAndRemoves()
bool MapManager::ExistMapAndVMap(uint32 mapid, float x, float y)
{
- GridPair p = Trinity::ComputeGridPair(x, y);
+ GridCoord p = Trinity::ComputeGridCoord(x, y);
int gx=63-p.x_coord;
int gy=63-p.y_coord;
@@ -335,7 +342,7 @@ void MapManager::UnloadAll()
uint32 MapManager::GetNumInstances()
{
- ACE_GUARD_RETURN(ACE_Thread_Mutex, Guard, Lock, 0);
+ TRINITY_GUARD(ACE_Thread_Mutex, Lock);
uint32 ret = 0;
for (MapMapType::iterator itr = i_maps.begin(); itr != i_maps.end(); ++itr)
@@ -352,7 +359,7 @@ uint32 MapManager::GetNumInstances()
uint32 MapManager::GetNumPlayersInInstances()
{
- ACE_GUARD_RETURN(ACE_Thread_Mutex, Guard, Lock, 0);
+ TRINITY_GUARD(ACE_Thread_Mutex, Lock);
uint32 ret = 0;
for (MapMapType::iterator itr = i_maps.begin(); itr != i_maps.end(); ++itr)
diff --git a/src/server/game/Maps/MapManager.h b/src/server/game/Maps/MapManager.h
index 926ff2c8051..3b168a57cd5 100755
--- a/src/server/game/Maps/MapManager.h
+++ b/src/server/game/Maps/MapManager.h
@@ -35,14 +35,14 @@ class MapManager
friend class ACE_Singleton<MapManager, ACE_Thread_Mutex>;
public:
-
- Map* CreateMap(uint32, const WorldObject* obj, uint32 instanceId);
- Map const* CreateBaseMap(uint32 id) const { return const_cast<MapManager*>(this)->_createBaseMap(id); }
- Map* FindMap(uint32 mapid, uint32 instanceId = 0) const;
+ Map* CreateBaseMap(uint32 mapId);
+ Map* FindBaseNonInstanceMap(uint32 mapId) const;
+ Map* CreateMap(uint32 mapId, Player* player);
+ Map* FindMap(uint32 mapId, uint32 instanceId) const;
uint16 GetAreaFlag(uint32 mapid, float x, float y, float z) const
{
- Map const* m = CreateBaseMap(mapid);
+ Map const* m = const_cast<MapManager*>(this)->CreateBaseMap(mapid);
return m->GetAreaFlag(x, y, z);
}
uint32 GetAreaId(uint32 mapid, float x, float y, float z) const
@@ -160,16 +160,15 @@ class MapManager
MapManager();
~MapManager();
- MapManager(const MapManager &);
- MapManager& operator=(const MapManager &);
-
- Map* _createBaseMap(uint32 id);
- Map* _findMap(uint32 id) const
+ Map* FindBaseMap(uint32 mapId) const
{
- MapMapType::const_iterator iter = i_maps.find(id);
+ MapMapType::const_iterator iter = i_maps.find(mapId);
return (iter == i_maps.end() ? NULL : iter->second);
}
+ MapManager(const MapManager &);
+ MapManager& operator=(const MapManager &);
+
ACE_Thread_Mutex Lock;
uint32 i_gridCleanUpDelay;
MapMapType i_maps;
diff --git a/src/server/game/Maps/MapUpdater.cpp b/src/server/game/Maps/MapUpdater.cpp
index 7e6b2f03bd0..80025680753 100644
--- a/src/server/game/Maps/MapUpdater.cpp
+++ b/src/server/game/Maps/MapUpdater.cpp
@@ -81,7 +81,7 @@ int MapUpdater::deactivate()
int MapUpdater::wait()
{
- ACE_GUARD_RETURN(ACE_Thread_Mutex, guard, m_mutex, -1);
+ TRINITY_GUARD(ACE_Thread_Mutex, m_mutex);
while (pending_requests > 0)
m_condition.wait();
@@ -91,7 +91,7 @@ int MapUpdater::wait()
int MapUpdater::schedule_update(Map& map, ACE_UINT32 diff)
{
- ACE_GUARD_RETURN(ACE_Thread_Mutex, guard, m_mutex, -1);
+ TRINITY_GUARD(ACE_Thread_Mutex, m_mutex);
++pending_requests;
@@ -113,7 +113,7 @@ bool MapUpdater::activated()
void MapUpdater::update_finished()
{
- ACE_GUARD(ACE_Thread_Mutex, guard, m_mutex);
+ TRINITY_GUARD(ACE_Thread_Mutex, m_mutex);
if (pending_requests == 0)
{
diff --git a/src/server/game/Miscellaneous/Formulas.h b/src/server/game/Miscellaneous/Formulas.h
index f562010549b..cbcad520e5f 100755
--- a/src/server/game/Miscellaneous/Formulas.h
+++ b/src/server/game/Miscellaneous/Formulas.h
@@ -156,7 +156,7 @@ namespace Trinity
return baseGain;
}
- inline uint32 Gain(Player* pl, Unit* u)
+ inline uint32 Gain(Player* player, Unit* u)
{
uint32 gain;
@@ -167,7 +167,7 @@ namespace Trinity
gain = 0;
else
{
- gain = BaseGain(pl->getLevel(), u->getLevel(), GetContentLevelsForMapAndZone(u->GetMapId(), u->GetZoneId()));
+ gain = BaseGain(player->getLevel(), u->getLevel(), GetContentLevelsForMapAndZone(u->GetMapId(), u->GetZoneId()));
if (gain != 0 && u->GetTypeId() == TYPEID_UNIT && ((Creature*)u)->isElite())
{
@@ -181,7 +181,7 @@ namespace Trinity
gain = uint32(gain * sWorld->getRate(RATE_XP_KILL));
}
- sScriptMgr->OnGainCalculation(gain, pl, u);
+ sScriptMgr->OnGainCalculation(gain, player, u);
return gain;
}
diff --git a/src/server/game/Miscellaneous/SharedDefines.h b/src/server/game/Miscellaneous/SharedDefines.h
index 380af30c175..a99d0f37c02 100755
--- a/src/server/game/Miscellaneous/SharedDefines.h
+++ b/src/server/game/Miscellaneous/SharedDefines.h
@@ -409,7 +409,7 @@ enum SpellAttr3
enum SpellAttr4
{
SPELL_ATTR4_UNK0 = 0x00000001, // 0
- SPELL_ATTR4_UNK1 = 0x00000002, // 1 proc on finishing move?
+ SPELL_ATTR4_PROC_ONLY_ON_DUMMY = 0x00000002, // 1 proc only on SPELL_EFFECT_DUMMY?
SPELL_ATTR4_UNK2 = 0x00000004, // 2
SPELL_ATTR4_UNK3 = 0x00000008, // 3
SPELL_ATTR4_UNK4 = 0x00000010, // 4 This will no longer cause guards to attack on use??
@@ -2378,7 +2378,7 @@ enum QuestSort
QUEST_SORT_ROGUE = 162,
QUEST_SORT_ALCHEMY = 181,
QUEST_SORT_LEATHERWORKING = 182,
- QUEST_SORT_ENGINERING = 201,
+ QUEST_SORT_ENGINEERING = 201,
QUEST_SORT_TREASURE_MAP = 221,
QUEST_SORT_SUNKEN_TEMPLE_OLD = 241,
QUEST_SORT_HUNTER = 261,
@@ -2480,7 +2480,7 @@ enum SkillType
SKILL_PET_IMP = 188,
SKILL_PET_FELHUNTER = 189,
SKILL_TAILORING = 197,
- SKILL_ENGINERING = 202,
+ SKILL_ENGINEERING = 202,
SKILL_PET_SPIDER = 203,
SKILL_PET_VOIDWALKER = 204,
SKILL_PET_SUCCUBUS = 205,
@@ -2600,7 +2600,7 @@ inline uint32 SkillByQuestSort(int32 QuestSort)
case QUEST_SORT_BLACKSMITHING: return SKILL_BLACKSMITHING;
case QUEST_SORT_ALCHEMY: return SKILL_ALCHEMY;
case QUEST_SORT_LEATHERWORKING: return SKILL_LEATHERWORKING;
- case QUEST_SORT_ENGINERING: return SKILL_ENGINERING;
+ case QUEST_SORT_ENGINEERING: return SKILL_ENGINEERING;
case QUEST_SORT_TAILORING: return SKILL_TAILORING;
case QUEST_SORT_COOKING: return SKILL_COOKING;
case QUEST_SORT_FIRST_AID: return SKILL_FIRST_AID;
@@ -2816,7 +2816,8 @@ enum DiminishingGroup
DIMINISHING_SILENCE = 16,
DIMINISHING_SLEEP = 17,
DIMINISHING_TAUNT = 18,
- DIMINISHING_LIMITONLY = 19
+ DIMINISHING_LIMITONLY = 19,
+ DIMINISHING_DRAGONS_BREATH = 20,
};
enum SummonCategory
diff --git a/src/server/game/Movement/MovementGenerators/ConfusedMovementGenerator.cpp b/src/server/game/Movement/MovementGenerators/ConfusedMovementGenerator.cpp
index 991b03c44e4..7c3b26c2646 100755
--- a/src/server/game/Movement/MovementGenerators/ConfusedMovementGenerator.cpp
+++ b/src/server/game/Movement/MovementGenerators/ConfusedMovementGenerator.cpp
@@ -29,10 +29,9 @@
#endif
template<class T>
-void
-ConfusedMovementGenerator<T>::Initialize(T &unit)
+void ConfusedMovementGenerator<T>::Initialize(T &unit)
{
- const float wander_distance = 11;
+ float const wanderDistance = 4;
float x, y, z;
x = unit.GetPositionX();
y = unit.GetPositionY();
@@ -47,8 +46,8 @@ ConfusedMovementGenerator<T>::Initialize(T &unit)
for (uint8 idx = 0; idx <= MAX_CONF_WAYPOINTS; ++idx)
{
- float wanderX = x + wander_distance*(float)rand_norm() - wander_distance/2;
- float wanderY = y + wander_distance*(float)rand_norm() - wander_distance/2;
+ float wanderX = x + wanderDistance * (float)rand_norm() - wanderDistance/2;
+ float wanderY = y + wanderDistance * (float)rand_norm() - wanderDistance/2;
Trinity::NormalizeMapCoord(wanderX);
Trinity::NormalizeMapCoord(wanderY);
@@ -68,7 +67,7 @@ ConfusedMovementGenerator<T>::Initialize(T &unit)
}
// Taken from FleeingMovementGenerator
- if (!(new_z - z) || wander_distance / fabs(new_z - z) > 1.0f)
+ if (!(new_z - z) || wanderDistance / fabs(new_z - z) > 1.0f)
{
i_waypoints[idx][0] = wanderX;
i_waypoints[idx][1] = wanderY;
@@ -89,29 +88,26 @@ ConfusedMovementGenerator<T>::Initialize(T &unit)
unit.SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_CONFUSED);
unit.CastStop();
unit.StopMoving();
- unit.RemoveUnitMovementFlag(MOVEMENTFLAG_WALKING);
+ unit.AddUnitMovementFlag(MOVEMENTFLAG_WALKING); // Should actually be splineflag
unit.AddUnitState(UNIT_STAT_CONFUSED);
}
template<>
-void
-ConfusedMovementGenerator<Creature>::_InitSpecific(Creature &creature, bool &is_water_ok, bool &is_land_ok)
+void ConfusedMovementGenerator<Creature>::_InitSpecific(Creature &creature, bool &is_water_ok, bool &is_land_ok)
{
is_water_ok = creature.canSwim();
is_land_ok = creature.canWalk();
}
template<>
-void
-ConfusedMovementGenerator<Player>::_InitSpecific(Player &, bool &is_water_ok, bool &is_land_ok)
+void ConfusedMovementGenerator<Player>::_InitSpecific(Player &, bool &is_water_ok, bool &is_land_ok)
{
is_water_ok = true;
is_land_ok = true;
}
template<class T>
-void
-ConfusedMovementGenerator<T>::Reset(T &unit)
+void ConfusedMovementGenerator<T>::Reset(T &unit)
{
i_nextMove = 1;
i_nextMoveTime.Reset(0);
@@ -120,8 +116,7 @@ ConfusedMovementGenerator<T>::Reset(T &unit)
}
template<class T>
-bool
-ConfusedMovementGenerator<T>::Update(T &unit, const uint32 diff)
+bool ConfusedMovementGenerator<T>::Update(T &unit, const uint32 diff)
{
if (!&unit)
return true;
@@ -141,7 +136,7 @@ ConfusedMovementGenerator<T>::Update(T &unit, const uint32 diff)
unit.ClearUnitState(UNIT_STAT_MOVE);
i_nextMove = urand(1, MAX_CONF_WAYPOINTS);
- i_nextMoveTime.Reset(urand(0, 1500-1)); // TODO: check the minimum reset time, should be probably higher
+ i_nextMoveTime.Reset(urand(100, 1000));
}
}
}
@@ -164,11 +159,11 @@ ConfusedMovementGenerator<T>::Update(T &unit, const uint32 diff)
}
template<class T>
-void
-ConfusedMovementGenerator<T>::Finalize(T &unit)
+void ConfusedMovementGenerator<T>::Finalize(T &unit)
{
unit.RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_CONFUSED);
unit.ClearUnitState(UNIT_STAT_CONFUSED);
+
if (unit.GetTypeId() == TYPEID_UNIT && unit.getVictim())
unit.SetTarget(unit.getVictim()->GetGUID());
}
diff --git a/src/server/game/Movement/MovementGenerators/PointMovementGenerator.cpp b/src/server/game/Movement/MovementGenerators/PointMovementGenerator.cpp
index 3d7a65a4ccc..6d5c803bea8 100755
--- a/src/server/game/Movement/MovementGenerators/PointMovementGenerator.cpp
+++ b/src/server/game/Movement/MovementGenerators/PointMovementGenerator.cpp
@@ -58,6 +58,10 @@ bool PointMovementGenerator<T>::Update(T &unit, const uint32 diff)
arrived = true;
return false;
}
+ else if (!unit.HasUnitState(UNIT_STAT_MOVE) && !unit.HasUnitState(UNIT_STAT_JUMPING))
+ {
+ i_destinationHolder.StartTravel(traveller);
+ }
return true;
}
diff --git a/src/server/game/Movement/MovementGenerators/WaypointMovementGenerator.cpp b/src/server/game/Movement/MovementGenerators/WaypointMovementGenerator.cpp
index 99deef200a6..396b0c489f2 100755
--- a/src/server/game/Movement/MovementGenerators/WaypointMovementGenerator.cpp
+++ b/src/server/game/Movement/MovementGenerators/WaypointMovementGenerator.cpp
@@ -206,7 +206,13 @@ WaypointMovementGenerator<Creature>::Update(Creature &unit, const uint32 diff)
MovementInform(unit);
unit.UpdateWaypointID(i_currentNode);
unit.ClearUnitState(UNIT_STAT_ROAMING);
- unit.Relocate(node->x, node->y, node->z);
+ if (node->orientation)
+ {
+ unit.Relocate(node->x, node->y, node->z, node->orientation);
+ unit.SetFacing(node->orientation, NULL);
+ }
+ else
+ unit.Relocate(node->x, node->y, node->z);
}
}
else
@@ -345,7 +351,7 @@ void FlightPathMovementGenerator::InitEndGridInfo()
void FlightPathMovementGenerator::PreloadEndGrid()
{
// used to preload the final grid where the flightmaster is
- Map* endMap = sMapMgr->FindMap(m_endMapId);
+ Map* endMap = sMapMgr->FindBaseNonInstanceMap(m_endMapId);
// Load the grid
if (endMap)
diff --git a/src/server/game/Movement/Waypoints/WaypointManager.cpp b/src/server/game/Movement/Waypoints/WaypointManager.cpp
index 0ce2a097422..2859fb9227b 100755
--- a/src/server/game/Movement/Waypoints/WaypointManager.cpp
+++ b/src/server/game/Movement/Waypoints/WaypointManager.cpp
@@ -43,7 +43,7 @@ void WaypointMgr::Load()
{
uint32 oldMSTime = getMSTime();
- QueryResult result = WorldDatabase.Query("SELECT id, point, position_x, position_y, position_z, move_flag, delay, action, action_chance FROM waypoint_data ORDER BY id, point");
+ QueryResult result = WorldDatabase.Query("SELECT id, point, position_x, position_y, position_z, orientation, move_flag, delay, action, action_chance FROM waypoint_data ORDER BY id, point");
if (!result)
{
@@ -65,6 +65,7 @@ void WaypointMgr::Load()
float x = fields[2].GetFloat();
float y = fields[3].GetFloat();
float z = fields[4].GetFloat();
+ float o = fields[5].GetFloat();
Trinity::NormalizeMapCoord(x);
Trinity::NormalizeMapCoord(y);
@@ -73,10 +74,11 @@ void WaypointMgr::Load()
wp->x = x;
wp->y = y;
wp->z = z;
- wp->run = fields[5].GetBool();
- wp->delay = fields[6].GetUInt32();
- wp->event_id = fields[7].GetUInt32();
- wp->event_chance = fields[8].GetUInt8();
+ wp->orientation = o;
+ wp->run = fields[6].GetBool();
+ wp->delay = fields[7].GetUInt32();
+ wp->event_id = fields[8].GetUInt32();
+ wp->event_chance = fields[9].GetUInt8();
path.push_back(wp);
++count;
@@ -98,7 +100,7 @@ void WaypointMgr::ReloadPath(uint32 id)
_waypointStore.erase(itr);
}
- QueryResult result = WorldDatabase.PQuery("SELECT point, position_x, position_y, position_z, move_flag, delay, action, action_chance FROM waypoint_data WHERE id = %u ORDER BY point", id);
+ QueryResult result = WorldDatabase.PQuery("SELECT point, position_x, position_y, position_z, orientation, move_flag, delay, action, action_chance FROM waypoint_data WHERE id = %u ORDER BY point", id);
if (!result)
return;
@@ -112,6 +114,7 @@ void WaypointMgr::ReloadPath(uint32 id)
float x = fields[1].GetFloat();
float y = fields[2].GetFloat();
float z = fields[3].GetFloat();
+ float o = fields[4].GetFloat();
Trinity::NormalizeMapCoord(x);
Trinity::NormalizeMapCoord(y);
@@ -120,10 +123,11 @@ void WaypointMgr::ReloadPath(uint32 id)
wp->x = x;
wp->y = y;
wp->z = z;
- wp->run = fields[4].GetBool();
- wp->delay = fields[5].GetUInt32();
- wp->event_id = fields[6].GetUInt32();
- wp->event_chance = fields[7].GetUInt8();
+ wp->orientation = o;
+ wp->run = fields[5].GetBool();
+ wp->delay = fields[6].GetUInt32();
+ wp->event_id = fields[7].GetUInt32();
+ wp->event_chance = fields[8].GetUInt8();
path.push_back(wp);
diff --git a/src/server/game/Movement/Waypoints/WaypointManager.h b/src/server/game/Movement/Waypoints/WaypointManager.h
index 4b374984232..be4a0c8f9bf 100755
--- a/src/server/game/Movement/Waypoints/WaypointManager.h
+++ b/src/server/game/Movement/Waypoints/WaypointManager.h
@@ -26,7 +26,7 @@
struct WaypointData
{
uint32 id;
- float x, y, z;
+ float x, y, z, orientation;
bool run;
uint32 delay;
uint32 event_id;
diff --git a/src/server/game/OutdoorPvP/OutdoorPvP.cpp b/src/server/game/OutdoorPvP/OutdoorPvP.cpp
index b925150ef71..d641971faa0 100755
--- a/src/server/game/OutdoorPvP/OutdoorPvP.cpp
+++ b/src/server/game/OutdoorPvP/OutdoorPvP.cpp
@@ -36,22 +36,22 @@ m_State(OBJECTIVESTATE_NEUTRAL), m_neutralValuePct(0), m_PvP(pvp)
{
}
-bool OPvPCapturePoint::HandlePlayerEnter(Player* plr)
+bool OPvPCapturePoint::HandlePlayerEnter(Player* player)
{
if (m_capturePoint)
{
- plr->SendUpdateWorldState(m_capturePoint->GetGOInfo()->capturePoint.worldState1, 1);
- plr->SendUpdateWorldState(m_capturePoint->GetGOInfo()->capturePoint.worldstate2, (uint32)ceil((m_value + m_maxValue) / (2 * m_maxValue) * 100.0f));
- plr->SendUpdateWorldState(m_capturePoint->GetGOInfo()->capturePoint.worldstate3, m_neutralValuePct);
+ player->SendUpdateWorldState(m_capturePoint->GetGOInfo()->capturePoint.worldState1, 1);
+ 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[plr->GetTeamId()].insert(plr).second;
+ return m_activePlayers[player->GetTeamId()].insert(player).second;
}
-void OPvPCapturePoint::HandlePlayerLeave(Player* plr)
+void OPvPCapturePoint::HandlePlayerLeave(Player* player)
{
if (m_capturePoint)
- plr->SendUpdateWorldState(m_capturePoint->GetGOInfo()->capturePoint.worldState1, 0);
- m_activePlayers[plr->GetTeamId()].erase(plr);
+ player->SendUpdateWorldState(m_capturePoint->GetGOInfo()->capturePoint.worldState1, 0);
+ m_activePlayers[player->GetTeamId()].erase(player);
}
void OPvPCapturePoint::SendChangePhase()
@@ -239,24 +239,24 @@ OutdoorPvP::~OutdoorPvP()
DeleteSpawns();
}
-void OutdoorPvP::HandlePlayerEnterZone(Player* plr, uint32 /*zone*/)
+void OutdoorPvP::HandlePlayerEnterZone(Player* player, uint32 /*zone*/)
{
- m_players[plr->GetTeamId()].insert(plr);
+ m_players[player->GetTeamId()].insert(player);
}
-void OutdoorPvP::HandlePlayerLeaveZone(Player* plr, uint32 /*zone*/)
+void OutdoorPvP::HandlePlayerLeaveZone(Player* player, uint32 /*zone*/)
{
// inform the objectives of the leaving
for (OPvPCapturePointMap::iterator itr = m_capturePoints.begin(); itr != m_capturePoints.end(); ++itr)
- itr->second->HandlePlayerLeave(plr);
+ itr->second->HandlePlayerLeave(player);
// 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 (!plr->GetSession()->PlayerLogout())
- SendRemoveWorldStates(plr);
- m_players[plr->GetTeamId()].erase(plr);
- sLog->outDebug(LOG_FILTER_OUTDOORPVP, "Player %s left an outdoorpvp zone", plr->GetName());
+ 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());
}
-void OutdoorPvP::HandlePlayerResurrects(Player* /*plr*/, uint32 /*zone*/)
+void OutdoorPvP::HandlePlayerResurrects(Player* /*player*/, uint32 /*zone*/)
{
}
@@ -463,88 +463,88 @@ void OutdoorPvP::HandleKill(Player* killer, Unit* killed)
}
}
-bool OutdoorPvP::IsInsideObjective(Player* plr) const
+bool OutdoorPvP::IsInsideObjective(Player* player) const
{
for (OPvPCapturePointMap::const_iterator itr = m_capturePoints.begin(); itr != m_capturePoints.end(); ++itr)
- if (itr->second->IsInsideObjective(plr))
+ if (itr->second->IsInsideObjective(player))
return true;
return false;
}
-bool OPvPCapturePoint::IsInsideObjective(Player* plr) const
+bool OPvPCapturePoint::IsInsideObjective(Player* player) const
{
- return m_activePlayers[plr->GetTeamId()].find(plr) != m_activePlayers[plr->GetTeamId()].end();
+ return m_activePlayers[player->GetTeamId()].find(player) != m_activePlayers[player->GetTeamId()].end();
}
-bool OutdoorPvP::HandleCustomSpell(Player* plr, uint32 spellId, GameObject* go)
+bool OutdoorPvP::HandleCustomSpell(Player* player, uint32 spellId, GameObject* go)
{
for (OPvPCapturePointMap::iterator itr = m_capturePoints.begin(); itr != m_capturePoints.end(); ++itr)
- if (itr->second->HandleCustomSpell(plr, spellId, go))
+ if (itr->second->HandleCustomSpell(player, spellId, go))
return true;
return false;
}
-bool OPvPCapturePoint::HandleCustomSpell(Player* plr, uint32 /*spellId*/, GameObject* /*go*/)
+bool OPvPCapturePoint::HandleCustomSpell(Player* player, uint32 /*spellId*/, GameObject* /*go*/)
{
- if (!plr->IsOutdoorPvPActive())
+ if (!player->IsOutdoorPvPActive())
return false;
return false;
}
-bool OutdoorPvP::HandleOpenGo(Player* plr, uint64 guid)
+bool OutdoorPvP::HandleOpenGo(Player* player, uint64 guid)
{
for (OPvPCapturePointMap::iterator itr = m_capturePoints.begin(); itr != m_capturePoints.end(); ++itr)
- if (itr->second->HandleOpenGo(plr, guid) >= 0)
+ if (itr->second->HandleOpenGo(player, guid) >= 0)
return true;
return false;
}
-bool OutdoorPvP::HandleGossipOption(Player* plr, uint64 guid, uint32 id)
+bool OutdoorPvP::HandleGossipOption(Player* player, uint64 guid, uint32 id)
{
for (OPvPCapturePointMap::iterator itr = m_capturePoints.begin(); itr != m_capturePoints.end(); ++itr)
- if (itr->second->HandleGossipOption(plr, guid, id))
+ if (itr->second->HandleGossipOption(player, guid, id))
return true;
return false;
}
-bool OutdoorPvP::CanTalkTo(Player* plr, Creature* c, GossipMenuItems const& gso)
+bool OutdoorPvP::CanTalkTo(Player* player, Creature* c, GossipMenuItems const& gso)
{
for (OPvPCapturePointMap::iterator itr = m_capturePoints.begin(); itr != m_capturePoints.end(); ++itr)
- if (itr->second->CanTalkTo(plr, c, gso))
+ if (itr->second->CanTalkTo(player, c, gso))
return true;
return false;
}
-bool OutdoorPvP::HandleDropFlag(Player* plr, uint32 id)
+bool OutdoorPvP::HandleDropFlag(Player* player, uint32 id)
{
for (OPvPCapturePointMap::iterator itr = m_capturePoints.begin(); itr != m_capturePoints.end(); ++itr)
- if (itr->second->HandleDropFlag(plr, id))
+ if (itr->second->HandleDropFlag(player, id))
return true;
return false;
}
-bool OPvPCapturePoint::HandleGossipOption(Player* /*plr*/, uint64 /*guid*/, uint32 /*id*/)
+bool OPvPCapturePoint::HandleGossipOption(Player* /*player*/, uint64 /*guid*/, uint32 /*id*/)
{
return false;
}
-bool OPvPCapturePoint::CanTalkTo(Player* /*plr*/, Creature* /*c*/, GossipMenuItems const& /*gso*/)
+bool OPvPCapturePoint::CanTalkTo(Player* /*player*/, Creature* /*c*/, GossipMenuItems const& /*gso*/)
{
return false;
}
-bool OPvPCapturePoint::HandleDropFlag(Player* /*plr*/, uint32 /*id*/)
+bool OPvPCapturePoint::HandleDropFlag(Player* /*player*/, uint32 /*id*/)
{
return false;
}
-int32 OPvPCapturePoint::HandleOpenGo(Player* /*plr*/, uint64 guid)
+int32 OPvPCapturePoint::HandleOpenGo(Player* /*player*/, uint64 guid)
{
std::map<uint64, uint32>::iterator itr = m_ObjectTypes.find(guid);
if (itr != m_ObjectTypes.end())
@@ -554,7 +554,7 @@ int32 OPvPCapturePoint::HandleOpenGo(Player* /*plr*/, uint64 guid)
return -1;
}
-bool OutdoorPvP::HandleAreaTrigger(Player* /*plr*/, uint32 /*trigger*/)
+bool OutdoorPvP::HandleAreaTrigger(Player* /*player*/, uint32 /*trigger*/)
{
return false;
}
@@ -572,9 +572,9 @@ void OutdoorPvP::RegisterZone(uint32 zoneId)
sOutdoorPvPMgr->AddZone(zoneId, this);
}
-bool OutdoorPvP::HasPlayer(Player* plr) const
+bool OutdoorPvP::HasPlayer(Player* player) const
{
- return m_players[plr->GetTeamId()].find(plr) != m_players[plr->GetTeamId()].end();
+ return m_players[player->GetTeamId()].find(player) != m_players[player->GetTeamId()].end();
}
void OutdoorPvP::TeamCastSpell(TeamId team, int32 spellId)
diff --git a/src/server/game/OutdoorPvP/OutdoorPvP.h b/src/server/game/OutdoorPvP/OutdoorPvP.h
index 1969d1f98e1..c57eddc7f86 100755
--- a/src/server/game/OutdoorPvP/OutdoorPvP.h
+++ b/src/server/game/OutdoorPvP/OutdoorPvP.h
@@ -104,15 +104,15 @@ class OPvPCapturePoint
void SendObjectiveComplete(uint32 id, uint64 guid);
// used when player is activated/inactivated in the area
- virtual bool HandlePlayerEnter(Player* plr);
- virtual void HandlePlayerLeave(Player* plr);
+ virtual bool HandlePlayerEnter(Player* player);
+ virtual void HandlePlayerLeave(Player* player);
// checks if player is in range of a capture credit marker
- bool IsInsideObjective(Player* plr) const;
+ bool IsInsideObjective(Player* player) const;
- virtual bool HandleCustomSpell(Player* plr, uint32 spellId, GameObject* go);
+ virtual bool HandleCustomSpell(Player* player, uint32 spellId, GameObject* go);
- virtual int32 HandleOpenGo(Player* plr, uint64 guid);
+ virtual int32 HandleOpenGo(Player* player, uint64 guid);
// returns true if the state of the objective has changed, in this case, the OutdoorPvP must send a world state ui update.
virtual bool Update(uint32 diff);
@@ -123,11 +123,11 @@ class OPvPCapturePoint
virtual void SendChangePhase();
- virtual bool HandleGossipOption(Player* plr, uint64 guid, uint32 gossipid);
+ virtual bool HandleGossipOption(Player* player, uint64 guid, uint32 gossipid);
- virtual bool CanTalkTo(Player* plr, Creature* c, GossipMenuItems const& gso);
+ virtual bool CanTalkTo(Player* player, Creature* c, GossipMenuItems const& gso);
- virtual bool HandleDropFlag(Player* plr, uint32 spellId);
+ virtual bool HandleDropFlag(Player* player, uint32 spellId);
virtual void DeleteSpawns();
@@ -208,13 +208,13 @@ class OutdoorPvP : public ZoneScript
virtual void FillInitialWorldStates(WorldPacket & /*data*/) {}
// called when a player triggers an areatrigger
- virtual bool HandleAreaTrigger(Player* plr, uint32 trigger);
+ virtual bool HandleAreaTrigger(Player* player, uint32 trigger);
// called on custom spell
- virtual bool HandleCustomSpell(Player* plr, uint32 spellId, GameObject* go);
+ virtual bool HandleCustomSpell(Player* player, uint32 spellId, GameObject* go);
// called on go use
- virtual bool HandleOpenGo(Player* plr, uint64 guid);
+ virtual bool HandleOpenGo(Player* player, uint64 guid);
// setup stuff
virtual bool SetupOutdoorPvP() {return true;}
@@ -234,18 +234,18 @@ class OutdoorPvP : public ZoneScript
virtual void HandleKillImpl(Player* /*killer*/, Unit* /*killed*/) {}
// checks if player is in range of a capture credit marker
- bool IsInsideObjective(Player* plr) const;
+ bool IsInsideObjective(Player* player) const;
// awards rewards for player kill
- virtual void AwardKillBonus(Player* /*plr*/) {}
+ virtual void AwardKillBonus(Player* /*player*/) {}
uint32 GetTypeId() {return m_TypeId;}
- virtual bool HandleDropFlag(Player* plr, uint32 spellId);
+ virtual bool HandleDropFlag(Player* player, uint32 spellId);
- virtual bool HandleGossipOption(Player* plr, uint64 guid, uint32 gossipid);
+ virtual bool HandleGossipOption(Player* player, uint64 guid, uint32 gossipid);
- virtual bool CanTalkTo(Player* plr, Creature* c, GossipMenuItems const& gso);
+ virtual bool CanTalkTo(Player* player, Creature* c, GossipMenuItems const& gso);
void TeamApplyBuff(TeamId team, uint32 spellId, uint32 spellId2 = 0);
@@ -261,14 +261,14 @@ class OutdoorPvP : public ZoneScript
bool m_sendUpdate;
// world state stuff
- virtual void SendRemoveWorldStates(Player* /*plr*/) {}
+ virtual void SendRemoveWorldStates(Player* /*player*/) {}
void BroadcastPacket(WorldPacket & data) const;
- virtual void HandlePlayerEnterZone(Player* plr, uint32 zone);
- virtual void HandlePlayerLeaveZone(Player* plr, uint32 zone);
+ virtual void HandlePlayerEnterZone(Player* player, uint32 zone);
+ virtual void HandlePlayerLeaveZone(Player* player, uint32 zone);
- virtual void HandlePlayerResurrects(Player* plr, uint32 zone);
+ virtual void HandlePlayerResurrects(Player* player, uint32 zone);
void AddCapturePoint(OPvPCapturePoint* cp)
{
@@ -285,7 +285,7 @@ class OutdoorPvP : public ZoneScript
void RegisterZone(uint32 zoneid);
- bool HasPlayer(Player* plr) const;
+ bool HasPlayer(Player* player) const;
void TeamCastSpell(TeamId team, int32 spellId);
};
diff --git a/src/server/game/OutdoorPvP/OutdoorPvPMgr.cpp b/src/server/game/OutdoorPvP/OutdoorPvPMgr.cpp
index dda0e7bcb61..4a0da1d3b55 100755
--- a/src/server/game/OutdoorPvP/OutdoorPvPMgr.cpp
+++ b/src/server/game/OutdoorPvP/OutdoorPvPMgr.cpp
@@ -115,31 +115,31 @@ void OutdoorPvPMgr::AddZone(uint32 zoneid, OutdoorPvP* handle)
m_OutdoorPvPMap[zoneid] = handle;
}
-void OutdoorPvPMgr::HandlePlayerEnterZone(Player* plr, uint32 zoneid)
+void OutdoorPvPMgr::HandlePlayerEnterZone(Player* player, uint32 zoneid)
{
OutdoorPvPMap::iterator itr = m_OutdoorPvPMap.find(zoneid);
if (itr == m_OutdoorPvPMap.end())
return;
- if (itr->second->HasPlayer(plr))
+ if (itr->second->HasPlayer(player))
return;
- itr->second->HandlePlayerEnterZone(plr, zoneid);
- sLog->outDebug(LOG_FILTER_OUTDOORPVP, "Player %u entered outdoorpvp id %u", plr->GetGUIDLow(), itr->second->GetTypeId());
+ itr->second->HandlePlayerEnterZone(player, zoneid);
+ sLog->outDebug(LOG_FILTER_OUTDOORPVP, "Player %u entered outdoorpvp id %u", player->GetGUIDLow(), itr->second->GetTypeId());
}
-void OutdoorPvPMgr::HandlePlayerLeaveZone(Player* plr, uint32 zoneid)
+void OutdoorPvPMgr::HandlePlayerLeaveZone(Player* player, uint32 zoneid)
{
OutdoorPvPMap::iterator itr = m_OutdoorPvPMap.find(zoneid);
if (itr == m_OutdoorPvPMap.end())
return;
// teleport: remove once in removefromworld, once in updatezone
- if (!itr->second->HasPlayer(plr))
+ if (!itr->second->HasPlayer(player))
return;
- itr->second->HandlePlayerLeaveZone(plr, zoneid);
- sLog->outDebug(LOG_FILTER_OUTDOORPVP, "Player %u left outdoorpvp id %u", plr->GetGUIDLow(), itr->second->GetTypeId());
+ itr->second->HandlePlayerLeaveZone(player, zoneid);
+ sLog->outDebug(LOG_FILTER_OUTDOORPVP, "Player %u left outdoorpvp id %u", player->GetGUIDLow(), itr->second->GetTypeId());
}
OutdoorPvP* OutdoorPvPMgr::GetOutdoorPvPToZoneId(uint32 zoneid)
@@ -164,11 +164,11 @@ void OutdoorPvPMgr::Update(uint32 diff)
}
}
-bool OutdoorPvPMgr::HandleCustomSpell(Player* plr, uint32 spellId, GameObject* go)
+bool OutdoorPvPMgr::HandleCustomSpell(Player* player, uint32 spellId, GameObject* go)
{
for (OutdoorPvPSet::iterator itr = m_OutdoorPvPSet.begin(); itr != m_OutdoorPvPSet.end(); ++itr)
{
- if ((*itr)->HandleCustomSpell(plr, spellId, go))
+ if ((*itr)->HandleCustomSpell(player, spellId, go))
return true;
}
return false;
@@ -183,21 +183,21 @@ ZoneScript* OutdoorPvPMgr::GetZoneScript(uint32 zoneId)
return NULL;
}
-bool OutdoorPvPMgr::HandleOpenGo(Player* plr, uint64 guid)
+bool OutdoorPvPMgr::HandleOpenGo(Player* player, uint64 guid)
{
for (OutdoorPvPSet::iterator itr = m_OutdoorPvPSet.begin(); itr != m_OutdoorPvPSet.end(); ++itr)
{
- if ((*itr)->HandleOpenGo(plr, guid))
+ if ((*itr)->HandleOpenGo(player, guid))
return true;
}
return false;
}
-void OutdoorPvPMgr::HandleGossipOption(Player* plr, uint64 guid, uint32 gossipid)
+void OutdoorPvPMgr::HandleGossipOption(Player* player, uint64 guid, uint32 gossipid)
{
for (OutdoorPvPSet::iterator itr = m_OutdoorPvPSet.begin(); itr != m_OutdoorPvPSet.end(); ++itr)
{
- if ((*itr)->HandleGossipOption(plr, guid, gossipid))
+ if ((*itr)->HandleGossipOption(player, guid, gossipid))
return;
}
}
@@ -212,21 +212,21 @@ bool OutdoorPvPMgr::CanTalkTo(Player* player, Creature* creature, GossipMenuItem
return false;
}
-void OutdoorPvPMgr::HandleDropFlag(Player* plr, uint32 spellId)
+void OutdoorPvPMgr::HandleDropFlag(Player* player, uint32 spellId)
{
for (OutdoorPvPSet::iterator itr = m_OutdoorPvPSet.begin(); itr != m_OutdoorPvPSet.end(); ++itr)
{
- if ((*itr)->HandleDropFlag(plr, spellId))
+ if ((*itr)->HandleDropFlag(player, spellId))
return;
}
}
-void OutdoorPvPMgr::HandlePlayerResurrects(Player* plr, uint32 zoneid)
+void OutdoorPvPMgr::HandlePlayerResurrects(Player* player, uint32 zoneid)
{
OutdoorPvPMap::iterator itr = m_OutdoorPvPMap.find(zoneid);
if (itr == m_OutdoorPvPMap.end())
return;
- if (itr->second->HasPlayer(plr))
- itr->second->HandlePlayerResurrects(plr, zoneid);
+ if (itr->second->HasPlayer(player))
+ itr->second->HandlePlayerResurrects(player, zoneid);
}
diff --git a/src/server/game/OutdoorPvP/OutdoorPvPMgr.h b/src/server/game/OutdoorPvP/OutdoorPvPMgr.h
index 6f0e0ba91b9..32639cb692e 100755
--- a/src/server/game/OutdoorPvP/OutdoorPvPMgr.h
+++ b/src/server/game/OutdoorPvP/OutdoorPvPMgr.h
@@ -49,22 +49,22 @@ class OutdoorPvPMgr
void InitOutdoorPvP();
// called when a player enters an outdoor pvp area
- void HandlePlayerEnterZone(Player* plr, uint32 areaflag);
+ void HandlePlayerEnterZone(Player* player, uint32 areaflag);
// called when player leaves an outdoor pvp area
- void HandlePlayerLeaveZone(Player* plr, uint32 areaflag);
+ void HandlePlayerLeaveZone(Player* player, uint32 areaflag);
// called when player resurrects
- void HandlePlayerResurrects(Player* plr, uint32 areaflag);
+ void HandlePlayerResurrects(Player* player, uint32 areaflag);
// return assigned outdoor pvp
OutdoorPvP* GetOutdoorPvPToZoneId(uint32 zoneid);
// handle custom (non-exist in dbc) spell if registered
- bool HandleCustomSpell(Player* plr, uint32 spellId, GameObject* go);
+ bool HandleCustomSpell(Player* player, uint32 spellId, GameObject* go);
// handle custom go if registered
- bool HandleOpenGo(Player* plr, uint64 guid);
+ bool HandleOpenGo(Player* player, uint64 guid);
ZoneScript* GetZoneScript(uint32 zoneId);
@@ -76,7 +76,7 @@ class OutdoorPvPMgr
bool CanTalkTo(Player* player, Creature* creature, GossipMenuItems const& gso);
- void HandleDropFlag(Player* plr, uint32 spellId);
+ void HandleDropFlag(Player* player, uint32 spellId);
private:
typedef std::vector<OutdoorPvP*> OutdoorPvPSet;
diff --git a/src/server/game/Pools/PoolMgr.cpp b/src/server/game/Pools/PoolMgr.cpp
index 35c19a6a62f..bd8840ff8a8 100755
--- a/src/server/game/Pools/PoolMgr.cpp
+++ b/src/server/game/Pools/PoolMgr.cpp
@@ -260,7 +260,7 @@ void PoolGroup<Quest>::Despawn1Object(uint32 quest_id)
QuestRelations::iterator lastElement = questMap->upper_bound(itr->second);
for (; qitr != lastElement; ++qitr)
{
- if (qitr->first == itr->second)
+ if (qitr->first == itr->second && qitr->second == itr->first)
{
questMap->erase(qitr); // iterator is now no more valid
break; // but we can exit loop since the element is found
@@ -279,7 +279,7 @@ void PoolGroup<Quest>::Despawn1Object(uint32 quest_id)
QuestRelations::iterator lastElement = questMap->upper_bound(itr->second);
for (; qitr != lastElement; ++qitr)
{
- if (qitr->first == itr->second)
+ if (qitr->first == itr->second && qitr->second == itr->first)
{
questMap->erase(qitr); // iterator is now no more valid
break; // but we can exit loop since the element is found
@@ -359,9 +359,9 @@ void PoolGroup<Creature>::Spawn1Object(PoolObject* obj)
sObjectMgr->AddCreatureToGrid(obj->guid, data);
// Spawn if necessary (loaded grids only)
- Map* map = const_cast<Map*>(sMapMgr->CreateBaseMap(data->mapid));
+ Map* map = sMapMgr->CreateBaseMap(data->mapid);
// We use spawn coords to spawn
- if (!map->Instanceable() && map->IsLoaded(data->posX, data->posY))
+ if (!map->Instanceable() && map->IsGridLoaded(data->posX, data->posY))
{
Creature* creature = new Creature;
//sLog->outDebug(LOG_FILTER_POOLSYS, "Spawning creature %u", guid);
@@ -385,9 +385,9 @@ void PoolGroup<GameObject>::Spawn1Object(PoolObject* obj)
sObjectMgr->AddGameobjectToGrid(obj->guid, data);
// Spawn if necessary (loaded grids only)
// this base map checked as non-instanced and then only existed
- Map* map = const_cast<Map*>(sMapMgr->CreateBaseMap(data->mapid));
+ Map* map = sMapMgr->CreateBaseMap(data->mapid);
// We use current coords to unspawn, not spawn coords since creature can have changed grid
- if (!map->Instanceable() && map->IsLoaded(data->posX, data->posY))
+ if (!map->Instanceable() && map->IsGridLoaded(data->posX, data->posY))
{
GameObject* pGameobject = new GameObject;
//sLog->outDebug(LOG_FILTER_POOLSYS, "Spawning gameobject %u", guid);
diff --git a/src/server/game/Quests/QuestDef.cpp b/src/server/game/Quests/QuestDef.cpp
index a1a1f5d5cac..29bd95a73a3 100755
--- a/src/server/game/Quests/QuestDef.cpp
+++ b/src/server/game/Quests/QuestDef.cpp
@@ -22,127 +22,132 @@
Quest::Quest(Field* questRecord)
{
- QuestId = questRecord[0].GetUInt32();
- QuestMethod = questRecord[1].GetUInt32();
- ZoneOrSort = questRecord[2].GetInt32();
- SkillOrClassMask = questRecord[3].GetInt32();
- MinLevel = questRecord[4].GetUInt32();
- MaxLevel = questRecord[5].GetUInt32();
- QuestLevel = questRecord[6].GetInt32();
- Type = questRecord[7].GetUInt32();
- RequiredRaces = questRecord[8].GetUInt32();
- RequiredSkillValue = questRecord[9].GetUInt32();
- RepObjectiveFaction = questRecord[10].GetUInt32();
- RepObjectiveValue = questRecord[11].GetInt32();
- RepObjectiveFaction2 = questRecord[12].GetUInt32();
- RepObjectiveValue2 = questRecord[13].GetInt32();
- RequiredMinRepFaction = questRecord[14].GetUInt32();
- RequiredMinRepValue = questRecord[15].GetInt32();
- RequiredMaxRepFaction = questRecord[16].GetUInt32();
- RequiredMaxRepValue = questRecord[17].GetInt32();
- SuggestedPlayers = questRecord[18].GetUInt32();
- LimitTime = questRecord[19].GetUInt32();
- QuestFlags = questRecord[20].GetUInt32();
- uint32 SpecialFlags = questRecord[21].GetUInt16();
- CharTitleId = questRecord[22].GetUInt32();
- PlayersSlain = questRecord[23].GetUInt32();
- BonusTalents = questRecord[24].GetUInt32();
- RewArenaPoints = questRecord[25].GetInt32();
- PrevQuestId = questRecord[26].GetInt32();
- NextQuestId = questRecord[27].GetInt32();
- ExclusiveGroup = questRecord[28].GetInt32();
- NextQuestInChain = questRecord[29].GetUInt32();
- XPId = questRecord[30].GetUInt32();
- SrcItemId = questRecord[31].GetUInt32();
- SrcItemCount = questRecord[32].GetUInt32();
- SrcSpell = questRecord[33].GetUInt32();
- Title = questRecord[34].GetString();
- Details = questRecord[35].GetString();
- Objectives = questRecord[36].GetString();
- OfferRewardText = questRecord[37].GetString();
- RequestItemsText = questRecord[38].GetString();
- EndText = questRecord[39].GetString();
- CompletedText = questRecord[40].GetString();
+ Id = questRecord[0].GetUInt32();
+ Method = questRecord[1].GetUInt32();
+ Level = questRecord[2].GetInt32();
+ MinLevel = questRecord[3].GetUInt32();
+ MaxLevel = questRecord[4].GetUInt32();
+ ZoneOrSort = questRecord[5].GetInt32();
+ Type = questRecord[6].GetUInt32();
+ SuggestedPlayers = questRecord[7].GetUInt32();
+ LimitTime = questRecord[8].GetUInt32();
+ RequiredClasses = questRecord[9].GetUInt32();
+ RequiredRaces = questRecord[10].GetUInt32();
+ RequiredSkillId = questRecord[11].GetUInt32();
+ RequiredSkillPoints = questRecord[12].GetUInt32();
+ RequiredFactionId1 = questRecord[13].GetUInt32();
+ RequiredFactionId2 = questRecord[14].GetUInt32();
+ RequiredFactionValue1 = questRecord[15].GetInt32();
+ RequiredFactionValue2 = questRecord[16].GetInt32();
+ RequiredMinRepFaction = questRecord[17].GetUInt32();
+ RequiredMaxRepFaction = questRecord[18].GetUInt32();
+ RequiredMinRepValue = questRecord[19].GetInt32();
+ RequiredMaxRepValue = questRecord[20].GetInt32();
+ PrevQuestId = questRecord[21].GetInt32();
+ NextQuestId = questRecord[22].GetInt32();
+ ExclusiveGroup = questRecord[23].GetInt32();
+ NextQuestIdChain = questRecord[24].GetUInt32();
+ RewardXPId = questRecord[25].GetUInt32();
+ RewardOrRequiredMoney = questRecord[26].GetInt32();
+ RewardMoneyMaxLevel = questRecord[27].GetUInt32();
+ RewardSpell = questRecord[28].GetUInt32();
+ RewardSpellCast = questRecord[29].GetInt32();
+ RewardHonor = questRecord[30].GetUInt32();
+ RewardHonorMultiplier = questRecord[31].GetFloat();
+ RewardMailTemplateId = questRecord[32].GetUInt32();
+ RewardMailDelay = questRecord[33].GetUInt32();
+ SourceItemId = questRecord[34].GetUInt32();
+ SourceItemIdCount = questRecord[35].GetUInt32();
+ SourceSpellid = questRecord[36].GetUInt32();
+ Flags = questRecord[37].GetUInt32();
+ uint32 SpecialFlags = questRecord[38].GetUInt16();
+ RewardTitleId = questRecord[39].GetUInt32();
+ RequiredPlayerKills = questRecord[40].GetUInt32();
+ RewardTalents = questRecord[41].GetUInt32();
+ RewardArenaPoints = questRecord[42].GetInt32();
- for (int i = 0; i < QUEST_OBJECTIVES_COUNT; ++i)
- ObjectiveText[i] = questRecord[41+i].GetString();
+ for (int i = 0; i < QUEST_REWARDS_COUNT; ++i)
+ RewardItemId[i] = questRecord[43+i].GetUInt32();
- for (int i = 0; i < QUEST_ITEM_OBJECTIVES_COUNT; ++i)
- ReqItemId[i] = questRecord[45+i].GetUInt32();
+ for (int i = 0; i < QUEST_REWARDS_COUNT; ++i)
+ RewardItemIdCount[i] = questRecord[47+i].GetUInt32();
- for (int i = 0; i < QUEST_ITEM_OBJECTIVES_COUNT; ++i)
- ReqItemCount[i] = questRecord[51+i].GetUInt32();
+ for (int i = 0; i < QUEST_REWARD_CHOICES_COUNT; ++i)
+ RewardChoiceItemId[i] = questRecord[51+i].GetUInt32();
- for (int i = 0; i < QUEST_SOURCE_ITEM_IDS_COUNT; ++i)
- ReqSourceId[i] = questRecord[57+i].GetUInt32();
+ for (int i = 0; i < QUEST_REWARD_CHOICES_COUNT; ++i)
+ RewardChoiceItemCount[i] = questRecord[57+i].GetUInt32();
+
+ for (int i = 0; i < QUEST_REPUTATIONS_COUNT; ++i)
+ RewardFactionId[i] = questRecord[63+i].GetUInt32();
- for (int i = 0; i < QUEST_SOURCE_ITEM_IDS_COUNT; ++i)
- ReqSourceCount[i] = questRecord[61+i].GetUInt32();
+ for (int i = 0; i < QUEST_REPUTATIONS_COUNT; ++i)
+ RewardFactionValueId[i] = questRecord[68+i].GetInt32();
- for (int i = 0; i < QUEST_OBJECTIVES_COUNT; ++i)
- ReqCreatureOrGOId[i] = questRecord[65+i].GetInt32();
+ for (int i = 0; i < QUEST_REPUTATIONS_COUNT; ++i)
+ RewardFactionValueIdOverride[i] = questRecord[73+i].GetInt32();
+
+ PointMapId = questRecord[78].GetUInt32();
+ PointX = questRecord[79].GetFloat();
+ PointY = questRecord[80].GetFloat();
+ PointOption = questRecord[81].GetUInt32();
+ Title = questRecord[82].GetString();
+ Objectives = questRecord[83].GetString();
+ Details = questRecord[84].GetString();
+ EndText = questRecord[85].GetString();
+ OfferRewardText = questRecord[86].GetString();
+ RequestItemsText = questRecord[87].GetString();
+ CompletedText = questRecord[88].GetString();
for (int i = 0; i < QUEST_OBJECTIVES_COUNT; ++i)
- ReqCreatureOrGOCount[i] = questRecord[69+i].GetUInt32();
+ RequiredNpcOrGo[i] = questRecord[89+i].GetInt32();
for (int i = 0; i < QUEST_OBJECTIVES_COUNT; ++i)
- ReqSpell[i] = questRecord[73+i].GetUInt32();
+ RequiredNpcOrGoCount[i] = questRecord[93+i].GetUInt32();
- for (int i = 0; i < QUEST_REWARD_CHOICES_COUNT; ++i)
- RewChoiceItemId[i] = questRecord[77+i].GetUInt32();
+ for (int i = 0; i < QUEST_SOURCE_ITEM_IDS_COUNT; ++i)
+ RequiredSourceItemid[i] = questRecord[97+i].GetUInt32();
- for (int i = 0; i < QUEST_REWARD_CHOICES_COUNT; ++i)
- RewChoiceItemCount[i] = questRecord[83+i].GetUInt32();
+ for (int i = 0; i < QUEST_SOURCE_ITEM_IDS_COUNT; ++i)
+ RequiredSourceItemId[i] = questRecord[101+i].GetUInt32();
- for (int i = 0; i < QUEST_REWARDS_COUNT; ++i)
- RewItemId[i] = questRecord[89+i].GetUInt32();
+ for (int i = 0; i < QUEST_ITEM_OBJECTIVES_COUNT; ++i)
+ RequiredItemId[i] = questRecord[105+i].GetUInt32();
- for (int i = 0; i < QUEST_REWARDS_COUNT; ++i)
- RewItemCount[i] = questRecord[93+i].GetUInt32();
+ for (int i = 0; i < QUEST_ITEM_OBJECTIVES_COUNT; ++i)
+ RequiredItemCount[i] = questRecord[111+i].GetUInt32();
- for (int i = 0; i < QUEST_REPUTATIONS_COUNT; ++i)
- RewRepFaction[i] = questRecord[97+i].GetUInt32();
+ for (int i = 0; i < QUEST_OBJECTIVES_COUNT; ++i)
+ RequiredSpellCast[i] = questRecord[117+i].GetUInt32();
- for (int i = 0; i < QUEST_REPUTATIONS_COUNT; ++i)
- RewRepValueId[i] = questRecord[102+i].GetInt32();
+ // int8 Unknown0 = questRecord[121].GetUInt32();
- for (int i = 0; i < QUEST_REPUTATIONS_COUNT; ++i)
- RewRepValue[i] = questRecord[107+i].GetInt32();
-
- RewHonorAddition = questRecord[112].GetUInt32();
- RewHonorMultiplier = questRecord[113].GetFloat();
- RewOrReqMoney = questRecord[114].GetInt32();
- RewMoneyMaxLevel = questRecord[115].GetUInt32();
- RewSpell = questRecord[116].GetUInt32();
- RewSpellCast = questRecord[117].GetInt32();
- RewMailTemplateId = questRecord[118].GetUInt32();
- RewMailDelaySecs = questRecord[119].GetUInt32();
- PointMapId = questRecord[120].GetUInt32();
- PointX = questRecord[121].GetFloat();
- PointY = questRecord[122].GetFloat();
- PointOpt = questRecord[123].GetUInt32();
+ for (int i = 0; i < QUEST_OBJECTIVES_COUNT; ++i)
+ ObjectiveText[i] = questRecord[122+i].GetString();
for (int i = 0; i < QUEST_EMOTE_COUNT; ++i)
- DetailsEmote[i] = questRecord[124+i].GetUInt32();
+ DetailsEmote[i] = questRecord[126+i].GetUInt32();
for (int i = 0; i < QUEST_EMOTE_COUNT; ++i)
- DetailsEmoteDelay[i] = questRecord[128+i].GetUInt32();
+ DetailsEmoteDelay[i] = questRecord[130+i].GetUInt32();
- IncompleteEmote = questRecord[132].GetUInt32();
- CompleteEmote = questRecord[133].GetUInt32();
+ EmoteOnIncomplete = questRecord[134].GetUInt32();
+ EmoteOnComplete = questRecord[135].GetUInt32();
for (int i = 0; i < QUEST_EMOTE_COUNT; ++i)
- OfferRewardEmote[i] = questRecord[134+i].GetInt32();
+ OfferRewardEmote[i] = questRecord[136+i].GetInt32();
for (int i = 0; i < QUEST_EMOTE_COUNT; ++i)
- OfferRewardEmoteDelay[i] = questRecord[138+i].GetInt32();
+ OfferRewardEmoteDelay[i] = questRecord[140+i].GetInt32();
+
+ StartScript = questRecord[144].GetUInt32();
+ CompleteScript = questRecord[145].GetUInt32();
- QuestStartScript = questRecord[142].GetUInt32();
- QuestCompleteScript = questRecord[143].GetUInt32();
+ // int32 WDBVerified = questRecord[146].GetInt32();
- QuestFlags |= SpecialFlags << 20;
- if (QuestFlags & QUEST_TRINITY_FLAGS_AUTO_ACCEPT)
- QuestFlags |= QUEST_FLAGS_AUTO_ACCEPT;
+ Flags |= SpecialFlags << 20;
+ if (Flags & QUEST_TRINITY_FLAGS_AUTO_ACCEPT)
+ Flags |= QUEST_FLAGS_AUTO_ACCEPT;
m_reqitemscount = 0;
m_reqCreatureOrGOcount = 0;
@@ -150,19 +155,19 @@ Quest::Quest(Field* questRecord)
m_rewchoiceitemscount = 0;
for (int i=0; i < QUEST_ITEM_OBJECTIVES_COUNT; ++i)
- if (ReqItemId[i])
+ if (RequiredItemId[i])
++m_reqitemscount;
for (int i=0; i < QUEST_OBJECTIVES_COUNT; ++i)
- if (ReqCreatureOrGOId[i])
+ if (RequiredNpcOrGo[i])
++m_reqCreatureOrGOcount;
for (int i=0; i < QUEST_REWARDS_COUNT; ++i)
- if (RewItemId[i])
+ if (RewardItemId[i])
++m_rewitemscount;
for (int i=0; i < QUEST_REWARD_CHOICES_COUNT; ++i)
- if (RewChoiceItemId[i])
+ if (RewardChoiceItemId[i])
++m_rewchoiceitemscount;
}
@@ -170,7 +175,7 @@ uint32 Quest::XPValue(Player* player) const
{
if (player)
{
- int32 quest_level = (QuestLevel == -1 ? player->getLevel() : QuestLevel);
+ int32 quest_level = (Level == -1 ? player->getLevel() : Level);
const QuestXPEntry* xpentry = sQuestXPStore.LookupEntry(quest_level);
if (!xpentry)
return 0;
@@ -181,7 +186,7 @@ uint32 Quest::XPValue(Player* player) const
else if (diffFactor > 10)
diffFactor = 10;
- uint32 xp = diffFactor * xpentry->Exp[XPId] / 10;
+ uint32 xp = diffFactor * xpentry->Exp[RewardXPId] / 10;
if (xp <= 100)
xp = 5 * ((xp + 2) / 5);
else if (xp <= 500)
@@ -199,10 +204,15 @@ uint32 Quest::XPValue(Player* player) const
int32 Quest::GetRewOrReqMoney() const
{
- if (RewOrReqMoney <= 0)
- return RewOrReqMoney;
+ if (RewardOrRequiredMoney <= 0)
+ return RewardOrRequiredMoney;
- return int32(RewOrReqMoney * sWorld->getRate(RATE_DROP_MONEY));
+ return int32(RewardOrRequiredMoney * sWorld->getRate(RATE_DROP_MONEY));
+}
+
+bool Quest::IsAutoComplete() const
+{
+ return Method == 0 || HasFlag(QUEST_FLAGS_AUTOCOMPLETE);
}
bool Quest::IsAllowedInRaid() const
diff --git a/src/server/game/Quests/QuestDef.h b/src/server/game/Quests/QuestDef.h
index 61d492ce88c..fc9a432a11b 100755
--- a/src/server/game/Quests/QuestDef.h
+++ b/src/server/game/Quests/QuestDef.h
@@ -141,7 +141,7 @@ enum __QuestFlags
QUEST_FLAGS_UNAVAILABLE = 0x00004000, // Used on quests that are not generically available
QUEST_FLAGS_WEEKLY = 0x00008000,
QUEST_FLAGS_AUTOCOMPLETE = 0x00010000, // auto complete
- QUEST_FLAGS_SPECIAL_ITEM = 0x00020000, // has something to do with ReqItemId and SrcItemId
+ QUEST_FLAGS_SPECIAL_ITEM = 0x00020000, // has something to do with RequiredItemId and SourceItemId
QUEST_FLAGS_OBJ_TEXT = 0x00040000, // use Objective text as Complete text
QUEST_FLAGS_AUTO_ACCEPT = 0x00080000, // The client recognizes this flag as auto-accept. However, NONE of the current quests (3.3.5a) have this flag. Maybe blizz used to use it, or will use it in the future.
@@ -185,24 +185,25 @@ class Quest
Quest(Field* questRecord);
uint32 XPValue(Player* player) const;
- bool HasFlag(uint32 flag) const { return (QuestFlags & flag) != 0; }
- void SetFlag(uint32 flag) { QuestFlags |= flag; }
+ bool HasFlag(uint32 flag) const { return (Flags & flag) != 0; }
+ void SetFlag(uint32 flag) { Flags |= flag; }
// table data accessors:
- uint32 GetQuestId() const { return QuestId; }
- uint32 GetQuestMethod() const { return QuestMethod; }
+ uint32 GetQuestId() const { return Id; }
+ uint32 GetQuestMethod() const { return Method; }
int32 GetZoneOrSort() const { return ZoneOrSort; }
- int32 GetSkillOrClassMask() const { return SkillOrClassMask; }
uint32 GetMinLevel() const { return MinLevel; }
uint32 GetMaxLevel() const { return MaxLevel; }
- uint32 GetQuestLevel() const { return QuestLevel; }
+ uint32 GetQuestLevel() const { return Level; }
uint32 GetType() const { return Type; }
+ uint32 GetRequiredClasses() const { return RequiredClasses; }
uint32 GetRequiredRaces() const { return RequiredRaces; }
- uint32 GetRequiredSkillValue() const { return RequiredSkillValue; }
- uint32 GetRepObjectiveFaction() const { return RepObjectiveFaction; }
- int32 GetRepObjectiveValue() const { return RepObjectiveValue; }
- uint32 GetRepObjectiveFaction2() const { return RepObjectiveFaction2; }
- int32 GetRepObjectiveValue2() const { return RepObjectiveValue2; }
+ uint32 GetRequiredSkill() const { return RequiredSkillId; }
+ uint32 GetRequiredSkillValue() const { return RequiredSkillPoints; }
+ uint32 GetRepObjectiveFaction() const { return RequiredFactionId1; }
+ int32 GetRepObjectiveValue() const { return RequiredFactionValue1; }
+ uint32 GetRepObjectiveFaction2() const { return RequiredFactionId2; }
+ int32 GetRepObjectiveValue2() const { return RequiredFactionValue2; }
uint32 GetRequiredMinRepFaction() const { return RequiredMinRepFaction; }
int32 GetRequiredMinRepValue() const { return RequiredMinRepValue; }
uint32 GetRequiredMaxRepFaction() const { return RequiredMaxRepFaction; }
@@ -212,15 +213,15 @@ class Quest
int32 GetPrevQuestId() const { return PrevQuestId; }
int32 GetNextQuestId() const { return NextQuestId; }
int32 GetExclusiveGroup() const { return ExclusiveGroup; }
- uint32 GetNextQuestInChain() const { return NextQuestInChain; }
- uint32 GetCharTitleId() const { return CharTitleId; }
- uint32 GetPlayersSlain() const { return PlayersSlain; }
- uint32 GetBonusTalents() const { return BonusTalents; }
- int32 GetRewArenaPoints() const {return RewArenaPoints; }
- uint32 GetXPId() const { return XPId; }
- uint32 GetSrcItemId() const { return SrcItemId; }
- uint32 GetSrcItemCount() const { return SrcItemCount; }
- uint32 GetSrcSpell() const { return SrcSpell; }
+ uint32 GetNextQuestInChain() const { return NextQuestIdChain; }
+ uint32 GetCharTitleId() const { return RewardTitleId; }
+ uint32 GetPlayersSlain() const { return RequiredPlayerKills; }
+ uint32 GetBonusTalents() const { return RewardTalents; }
+ int32 GetRewArenaPoints() const {return RewardArenaPoints; }
+ uint32 GetXPId() const { return RewardXPId; }
+ 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; }
@@ -229,50 +230,50 @@ class Quest
std::string GetEndText() const { return EndText; }
std::string GetCompletedText() const { return CompletedText; }
int32 GetRewOrReqMoney() const;
- uint32 GetRewHonorAddition() const { return RewHonorAddition; }
- float GetRewHonorMultiplier() const { return RewHonorMultiplier; }
- uint32 GetRewMoneyMaxLevel() const { return RewMoneyMaxLevel; }
+ uint32 GetRewHonorAddition() const { return RewardHonor; }
+ float GetRewHonorMultiplier() const { return RewardHonorMultiplier; }
+ uint32 GetRewMoneyMaxLevel() const { return RewardMoneyMaxLevel; }
// use in XP calculation at client
- uint32 GetRewSpell() const { return RewSpell; }
- int32 GetRewSpellCast() const { return RewSpellCast; }
- uint32 GetRewMailTemplateId() const { return RewMailTemplateId; }
- uint32 GetRewMailDelaySecs() const { return RewMailDelaySecs; }
+ uint32 GetRewSpell() const { return RewardSpell; }
+ int32 GetRewSpellCast() const { return RewardSpellCast; }
+ uint32 GetRewMailTemplateId() const { return RewardMailTemplateId; }
+ uint32 GetRewMailDelaySecs() const { return RewardMailDelay; }
uint32 GetPointMapId() const { return PointMapId; }
float GetPointX() const { return PointX; }
float GetPointY() const { return PointY; }
- uint32 GetPointOpt() const { return PointOpt; }
- uint32 GetIncompleteEmote() const { return IncompleteEmote; }
- uint32 GetCompleteEmote() const { return CompleteEmote; }
- uint32 GetQuestStartScript() const { return QuestStartScript; }
- uint32 GetQuestCompleteScript() const { return QuestCompleteScript; }
- bool IsRepeatable() const { return QuestFlags & QUEST_TRINITY_FLAGS_REPEATABLE; }
- bool IsAutoComplete() const { return QuestMethod ? false : true; }
- uint32 GetFlags() const { return QuestFlags; }
- bool IsDaily() const { return QuestFlags & QUEST_FLAGS_DAILY; }
- bool IsWeekly() const { return QuestFlags & QUEST_FLAGS_WEEKLY; }
- bool IsDailyOrWeekly() const { return QuestFlags & (QUEST_FLAGS_DAILY | QUEST_FLAGS_WEEKLY); }
- bool IsAutoAccept() const { return QuestFlags & QUEST_FLAGS_AUTO_ACCEPT; }
+ uint32 GetPointOpt() const { return PointOption; }
+ uint32 GetIncompleteEmote() const { return EmoteOnIncomplete; }
+ uint32 GetCompleteEmote() const { return EmoteOnComplete; }
+ uint32 GetQuestStartScript() const { return StartScript; }
+ uint32 GetQuestCompleteScript() const { return CompleteScript; }
+ bool IsRepeatable() const { return Flags & QUEST_TRINITY_FLAGS_REPEATABLE; }
+ bool IsAutoComplete() const;
+ uint32 GetFlags() const { return Flags; }
+ bool IsDaily() const { return Flags & QUEST_FLAGS_DAILY; }
+ bool IsWeekly() const { return Flags & QUEST_FLAGS_WEEKLY; }
+ bool IsDailyOrWeekly() const { return Flags & (QUEST_FLAGS_DAILY | QUEST_FLAGS_WEEKLY); }
+ bool IsAutoAccept() const { return Flags & QUEST_FLAGS_AUTO_ACCEPT; }
bool IsRaidQuest() const { return Type == QUEST_TYPE_RAID || Type == QUEST_TYPE_RAID_10 || Type == QUEST_TYPE_RAID_25; }
bool IsAllowedInRaid() const;
- bool IsDFQuest() const { return QuestFlags & QUEST_TRINITY_FLAGS_DF_QUEST; }
+ bool IsDFQuest() const { return Flags & QUEST_TRINITY_FLAGS_DF_QUEST; }
uint32 CalculateHonorGain(uint8 level) const;
// multiple values
std::string ObjectiveText[QUEST_OBJECTIVES_COUNT];
- uint32 ReqItemId[QUEST_ITEM_OBJECTIVES_COUNT];
- uint32 ReqItemCount[QUEST_ITEM_OBJECTIVES_COUNT];
- uint32 ReqSourceId[QUEST_SOURCE_ITEM_IDS_COUNT];
- uint32 ReqSourceCount[QUEST_SOURCE_ITEM_IDS_COUNT];
- int32 ReqCreatureOrGOId[QUEST_OBJECTIVES_COUNT]; // >0 Creature <0 Gameobject
- uint32 ReqCreatureOrGOCount[QUEST_OBJECTIVES_COUNT];
- uint32 ReqSpell[QUEST_OBJECTIVES_COUNT];
- uint32 RewChoiceItemId[QUEST_REWARD_CHOICES_COUNT];
- uint32 RewChoiceItemCount[QUEST_REWARD_CHOICES_COUNT];
- uint32 RewItemId[QUEST_REWARDS_COUNT];
- uint32 RewItemCount[QUEST_REWARDS_COUNT];
- uint32 RewRepFaction[QUEST_REPUTATIONS_COUNT];
- int32 RewRepValueId[QUEST_REPUTATIONS_COUNT];
- int32 RewRepValue[QUEST_REPUTATIONS_COUNT];
+ uint32 RequiredItemId[QUEST_ITEM_OBJECTIVES_COUNT];
+ uint32 RequiredItemCount[QUEST_ITEM_OBJECTIVES_COUNT];
+ uint32 RequiredSourceItemid[QUEST_SOURCE_ITEM_IDS_COUNT];
+ uint32 RequiredSourceItemId[QUEST_SOURCE_ITEM_IDS_COUNT];
+ int32 RequiredNpcOrGo[QUEST_OBJECTIVES_COUNT]; // >0 Creature <0 Gameobject
+ uint32 RequiredNpcOrGoCount[QUEST_OBJECTIVES_COUNT];
+ uint32 RequiredSpellCast[QUEST_OBJECTIVES_COUNT];
+ uint32 RewardChoiceItemId[QUEST_REWARD_CHOICES_COUNT];
+ uint32 RewardChoiceItemCount[QUEST_REWARD_CHOICES_COUNT];
+ uint32 RewardItemId[QUEST_REWARDS_COUNT];
+ uint32 RewardItemIdCount[QUEST_REWARDS_COUNT];
+ uint32 RewardFactionId[QUEST_REPUTATIONS_COUNT];
+ int32 RewardFactionValueId[QUEST_REPUTATIONS_COUNT];
+ int32 RewardFactionValueIdOverride[QUEST_REPUTATIONS_COUNT];
uint32 DetailsEmote[QUEST_EMOTE_COUNT];
uint32 DetailsEmoteDelay[QUEST_EMOTE_COUNT];
uint32 OfferRewardEmote[QUEST_EMOTE_COUNT];
@@ -297,39 +298,40 @@ class Quest
// table data
protected:
- uint32 QuestId;
- uint32 QuestMethod;
+ uint32 Id;
+ uint32 Method;
int32 ZoneOrSort;
- int32 SkillOrClassMask;
uint32 MinLevel;
uint32 MaxLevel;
- int32 QuestLevel;
+ int32 Level;
uint32 Type;
+ uint32 RequiredClasses;
uint32 RequiredRaces;
- uint32 RequiredSkillValue;
- uint32 RepObjectiveFaction;
- int32 RepObjectiveValue;
- uint32 RepObjectiveFaction2;
- int32 RepObjectiveValue2;
+ uint32 RequiredSkillId;
+ uint32 RequiredSkillPoints;
+ uint32 RequiredFactionId1;
+ int32 RequiredFactionValue1;
+ uint32 RequiredFactionId2;
+ int32 RequiredFactionValue2;
uint32 RequiredMinRepFaction;
int32 RequiredMinRepValue;
uint32 RequiredMaxRepFaction;
int32 RequiredMaxRepValue;
uint32 SuggestedPlayers;
uint32 LimitTime;
- uint32 QuestFlags;
- uint32 CharTitleId;
- uint32 PlayersSlain;
- uint32 BonusTalents;
- int32 RewArenaPoints;
+ uint32 Flags;
+ uint32 RewardTitleId;
+ uint32 RequiredPlayerKills;
+ uint32 RewardTalents;
+ int32 RewardArenaPoints;
int32 PrevQuestId;
int32 NextQuestId;
int32 ExclusiveGroup;
- uint32 NextQuestInChain;
- uint32 XPId;
- uint32 SrcItemId;
- uint32 SrcItemCount;
- uint32 SrcSpell;
+ uint32 NextQuestIdChain;
+ uint32 RewardXPId;
+ uint32 SourceItemId;
+ uint32 SourceItemIdCount;
+ uint32 SourceSpellid;
std::string Title;
std::string Details;
std::string Objectives;
@@ -337,22 +339,22 @@ class Quest
std::string RequestItemsText;
std::string EndText;
std::string CompletedText;
- uint32 RewHonorAddition;
- float RewHonorMultiplier;
- int32 RewOrReqMoney;
- uint32 RewMoneyMaxLevel;
- uint32 RewSpell;
- int32 RewSpellCast;
- uint32 RewMailTemplateId;
- uint32 RewMailDelaySecs;
+ uint32 RewardHonor;
+ float RewardHonorMultiplier;
+ int32 RewardOrRequiredMoney;
+ uint32 RewardMoneyMaxLevel;
+ uint32 RewardSpell;
+ int32 RewardSpellCast;
+ uint32 RewardMailTemplateId;
+ uint32 RewardMailDelay;
uint32 PointMapId;
float PointX;
float PointY;
- uint32 PointOpt;
- uint32 IncompleteEmote;
- uint32 CompleteEmote;
- uint32 QuestStartScript;
- uint32 QuestCompleteScript;
+ uint32 PointOption;
+ uint32 EmoteOnIncomplete;
+ uint32 EmoteOnComplete;
+ uint32 StartScript;
+ uint32 CompleteScript;
};
struct QuestStatusData
diff --git a/src/server/game/Reputation/ReputationMgr.cpp b/src/server/game/Reputation/ReputationMgr.cpp
index 2f849116f81..c4c8dec5500 100755
--- a/src/server/game/Reputation/ReputationMgr.cpp
+++ b/src/server/game/Reputation/ReputationMgr.cpp
@@ -358,7 +358,7 @@ bool ReputationMgr::SetOneFactionReputation(FactionEntry const* factionEntry, in
if (incremental)
{
// int32 *= float cause one point loss?
- standing = int32(floor((float)standing * sWorld->getRate(RATE_REPUTATION_GAIN) + 0.5));
+ standing = int32(floor((float)standing * sWorld->getRate(RATE_REPUTATION_GAIN) + 0.5f));
standing += itr->second.Standing + BaseRep;
}
diff --git a/src/server/game/Scripting/MapScripts.cpp b/src/server/game/Scripting/MapScripts.cpp
index b141f889196..4236ef49212 100755
--- a/src/server/game/Scripting/MapScripts.cpp
+++ b/src/server/game/Scripting/MapScripts.cpp
@@ -266,21 +266,20 @@ inline void Map::_ScriptProcessDoor(Object* source, Object* target, const Script
}
}
-inline GameObject* Map::_FindGameObject(WorldObject* pSearchObject, uint32 guid) const
+inline GameObject* Map::_FindGameObject(WorldObject* searchObject, uint32 guid) const
{
- GameObject* pGameObject = NULL;
+ GameObject* gameobject = NULL;
- CellPair p(Trinity::ComputeCellPair(pSearchObject->GetPositionX(), pSearchObject->GetPositionY()));
+ CellCoord p(Trinity::ComputeCellCoord(searchObject->GetPositionX(), searchObject->GetPositionY()));
Cell cell(p);
- cell.data.Part.reserved = ALL_DISTRICT;
- Trinity::GameObjectWithDbGUIDCheck goCheck(*pSearchObject, guid);
- Trinity::GameObjectSearcher<Trinity::GameObjectWithDbGUIDCheck> checker(pSearchObject, pGameObject, goCheck);
+ Trinity::GameObjectWithDbGUIDCheck goCheck(*searchObject, guid);
+ Trinity::GameObjectSearcher<Trinity::GameObjectWithDbGUIDCheck> checker(searchObject, gameobject, goCheck);
TypeContainerVisitor<Trinity::GameObjectSearcher<Trinity::GameObjectWithDbGUIDCheck>, GridTypeMapContainer > objectChecker(checker);
- cell.Visit(p, objectChecker, *pSearchObject->GetMap());
+ cell.Visit(p, objectChecker, *searchObject->GetMap(), *searchObject, searchObject->GetGridActivationRange());
- return pGameObject;
+ return gameobject;
}
/// Process queued scripts
@@ -322,11 +321,11 @@ void Map::ScriptsProcess()
source = HashMapHolder<Corpse>::Find(step.sourceGUID);
break;
case HIGHGUID_MO_TRANSPORT:
- for (MapManager::TransportSet::iterator iter = sMapMgr->m_Transports.begin(); iter != sMapMgr->m_Transports.end(); ++iter)
+ for (MapManager::TransportSet::iterator itr2 = sMapMgr->m_Transports.begin(); itr2 != sMapMgr->m_Transports.end(); ++itr2)
{
- if ((*iter)->GetGUID() == step.sourceGUID)
+ if ((*itr2)->GetGUID() == step.sourceGUID)
{
- source = *iter;
+ source = *itr2;
break;
}
}
@@ -818,15 +817,14 @@ void Map::ScriptsProcess()
{
WorldObject* wSource = dynamic_cast <WorldObject*> (source);
- CellPair p(Trinity::ComputeCellPair(wSource->GetPositionX(), wSource->GetPositionY()));
+ CellCoord p(Trinity::ComputeCellCoord(wSource->GetPositionX(), wSource->GetPositionY()));
Cell cell(p);
- cell.data.Part.reserved = ALL_DISTRICT;
Trinity::CreatureWithDbGUIDCheck target_check(wSource, step.script->CallScript.CreatureEntry);
Trinity::CreatureSearcher<Trinity::CreatureWithDbGUIDCheck> checker(wSource, cTarget, target_check);
TypeContainerVisitor<Trinity::CreatureSearcher <Trinity::CreatureWithDbGUIDCheck>, GridTypeMapContainer > unit_checker(checker);
- cell.Visit(p, unit_checker, *wSource->GetMap());
+ cell.Visit(p, unit_checker, *wSource->GetMap(), *wSource, wSource->GetGridActivationRange());
}
else //check hashmap holders
{
diff --git a/src/server/game/Scripting/ScriptMgr.cpp b/src/server/game/Scripting/ScriptMgr.cpp
index 120227c172d..925b352e616 100755
--- a/src/server/game/Scripting/ScriptMgr.cpp
+++ b/src/server/game/Scripting/ScriptMgr.cpp
@@ -295,7 +295,6 @@ void ScriptMgr::Unload()
void ScriptMgr::LoadDatabase()
{
- sScriptSystemMgr->LoadVersion();
sScriptSystemMgr->LoadScriptTexts();
sScriptSystemMgr->LoadScriptTextsCustom();
sScriptSystemMgr->LoadScriptWaypoints();
diff --git a/src/server/game/Scripting/ScriptSystem.cpp b/src/server/game/Scripting/ScriptSystem.cpp
index 8c6f5626101..d0f9a0380b0 100755
--- a/src/server/game/Scripting/ScriptSystem.cpp
+++ b/src/server/game/Scripting/ScriptSystem.cpp
@@ -23,25 +23,6 @@
ScriptPointVector const SystemMgr::_empty;
-void SystemMgr::LoadVersion()
-{
- // Get Version information
- QueryResult result = WorldDatabase.Query("SELECT script_version FROM version LIMIT 1");
-
- if (result)
- {
- Field* fields = result->Fetch();
-
- sLog->outString("TSCR: Database version is: %s", fields[0].GetCString());
- sLog->outString();
- }
- else
- {
- sLog->outError("TSCR: Missing `version`.`script_version` information.");
- sLog->outString();
- }
-}
-
void SystemMgr::LoadScriptTexts()
{
sLog->outString("TSCR: Loading Script Texts...");
diff --git a/src/server/game/Scripting/ScriptSystem.h b/src/server/game/Scripting/ScriptSystem.h
index a17033dc920..daa7fe0d596 100644
--- a/src/server/game/Scripting/ScriptSystem.h
+++ b/src/server/game/Scripting/ScriptSystem.h
@@ -64,7 +64,6 @@ class SystemMgr
typedef UNORDERED_MAP<uint32, ScriptPointVector> PointMoveMap;
//Database
- void LoadVersion();
void LoadScriptTexts();
void LoadScriptTextsCustom();
void LoadScriptWaypoints();
diff --git a/src/server/game/Server/Protocol/Handlers/AddonHandler.cpp b/src/server/game/Server/Protocol/Handlers/AddonHandler.cpp
index 9bbf98ce3fc..c7299eb0caa 100755
--- a/src/server/game/Server/Protocol/Handlers/AddonHandler.cpp
+++ b/src/server/game/Server/Protocol/Handlers/AddonHandler.cpp
@@ -107,9 +107,9 @@ bool AddonHandler::BuildAddonPacket(WorldPacket* Source, WorldPacket* Target)
*Target << uint8(unk1);
if (unk1)
{
- uint8 unk2 = (crc != 0x4c1c776d); // If addon is Standard addon CRC
- *Target << uint8(unk2);
- if (unk2)
+ uint8 unk = (crc != 0x4c1c776d); // If addon is Standard addon CRC
+ *Target << uint8(unk);
+ if (unk)
Target->append(tdata, sizeof(tdata));
*Target << uint32(0);
diff --git a/src/server/game/Server/Protocol/Handlers/AuctionHouseHandler.cpp b/src/server/game/Server/Protocol/Handlers/AuctionHouseHandler.cpp
index a67006382ff..2f8a27740be 100755
--- a/src/server/game/Server/Protocol/Handlers/AuctionHouseHandler.cpp
+++ b/src/server/game/Server/Protocol/Handlers/AuctionHouseHandler.cpp
@@ -125,7 +125,7 @@ void WorldSession::HandleAuctionSellItem(WorldPacket & recv_data)
recv_data >> buyout;
recv_data >> etime;
- Player* pl = GetPlayer();
+ Player* player = GetPlayer();
if (!item || !bid || !etime)
return; //check for cheaters
@@ -162,11 +162,11 @@ void WorldSession::HandleAuctionSellItem(WorldPacket & recv_data)
if (GetPlayer()->HasUnitState(UNIT_STAT_DIED))
GetPlayer()->RemoveAurasByType(SPELL_AURA_FEIGN_DEATH);
- Item* it = pl->GetItemByGuid(item);
+ Item* it = player->GetItemByGuid(item);
//do not allow to sell already auctioned items
if (sAuctionMgr->GetAItem(GUID_LOPART(item)))
{
- sLog->outError("AuctionError, player %s is sending item id: %u, but item is already in another auction", pl->GetName(), GUID_LOPART(item));
+ sLog->outError("AuctionError, player %s is sending item id: %u, but item is already in another auction", player->GetName(), GUID_LOPART(item));
SendAuctionCommandResult(0, AUCTION_SELL_ITEM, AUCTION_INTERNAL_ERROR);
return;
}
@@ -199,7 +199,7 @@ void WorldSession::HandleAuctionSellItem(WorldPacket & recv_data)
//we have to take deposit :
uint32 deposit = sAuctionMgr->GetAuctionDeposit(auctionHouseEntry, etime, it, count);
- if (!pl->HasEnoughMoney(deposit))
+ if (!player->HasEnoughMoney(deposit))
{
SendAuctionCommandResult(0, AUCTION_SELL_ITEM, AUCTION_NOT_ENOUGHT_MONEY);
return;
@@ -211,7 +211,7 @@ void WorldSession::HandleAuctionSellItem(WorldPacket & recv_data)
GetPlayerName(), GetAccountId(), it->GetTemplate()->Name1.c_str(), it->GetEntry(), count);
}
- pl->ModifyMoney(-int32(deposit));
+ player->ModifyMoney(-int32(deposit));
uint32 auction_time = uint32(etime * sWorld->getRate(RATE_AUCTION_TIME));
@@ -223,7 +223,7 @@ void WorldSession::HandleAuctionSellItem(WorldPacket & recv_data)
AH->auctioneer = GUID_LOPART(auctioneer);
AH->item_guidlow = GUID_LOPART(item);
AH->item_template = it->GetEntry();
- AH->owner = pl->GetGUIDLow();
+ AH->owner = player->GetGUIDLow();
AH->startbid = bid;
AH->bidder = 0;
AH->bid = 0;
@@ -236,13 +236,13 @@ void WorldSession::HandleAuctionSellItem(WorldPacket & recv_data)
sAuctionMgr->AddAItem(it);
auctionHouse->AddAuction(AH);
- pl->MoveItemFromInventory(it->GetBagSlot(), it->GetSlot(), true);
+ player->MoveItemFromInventory(it->GetBagSlot(), it->GetSlot(), true);
SQLTransaction trans = CharacterDatabase.BeginTransaction();
it->DeleteFromInventoryDB(trans);
it->SaveToDB(trans); // recursive and not have transaction guard into self, not in inventiory and can be save standalone
AH->SaveToDB(trans);
- pl->SaveInventoryAndGoldToDB(trans);
+ player->SaveInventoryAndGoldToDB(trans);
CharacterDatabase.CommitTransaction(trans);
SendAuctionCommandResult(AH->Id, AUCTION_SELL_ITEM, AUCTION_OK);
@@ -276,9 +276,9 @@ void WorldSession::HandleAuctionPlaceBid(WorldPacket & recv_data)
AuctionHouseObject* auctionHouse = sAuctionMgr->GetAuctionsMap(creature->getFaction());
AuctionEntry* auction = auctionHouse->GetAuction(auctionId);
- Player* pl = GetPlayer();
+ Player* player = GetPlayer();
- if (!auction || auction->owner == pl->GetGUIDLow())
+ if (!auction || auction->owner == player->GetGUIDLow())
{
//you cannot bid your own auction:
SendAuctionCommandResult(0, AUCTION_PLACE_BID, CANNOT_BID_YOUR_AUCTION_ERROR);
@@ -287,7 +287,7 @@ void WorldSession::HandleAuctionPlaceBid(WorldPacket & recv_data)
// impossible have online own another character (use this for speedup check in case online owner)
Player* auction_owner = ObjectAccessor::FindPlayer(MAKE_NEW_GUID(auction->owner, 0, HIGHGUID_PLAYER));
- if (!auction_owner && sObjectMgr->GetPlayerAccountIdByGUID(MAKE_NEW_GUID(auction->owner, 0, HIGHGUID_PLAYER)) == pl->GetSession()->GetAccountId())
+ if (!auction_owner && sObjectMgr->GetPlayerAccountIdByGUID(MAKE_NEW_GUID(auction->owner, 0, HIGHGUID_PLAYER)) == player->GetSession()->GetAccountId())
{
//you cannot bid your another character auction:
SendAuctionCommandResult(0, AUCTION_PLACE_BID, CANNOT_BID_YOUR_AUCTION_ERROR);
@@ -306,7 +306,7 @@ void WorldSession::HandleAuctionPlaceBid(WorldPacket & recv_data)
return;
}
- if (!pl->HasEnoughMoney(price))
+ if (!player->HasEnoughMoney(price))
{
//you don't have enought money!, client tests!
//SendAuctionCommandResult(auction->auctionId, AUCTION_PLACE_BID, ???);
@@ -319,19 +319,19 @@ void WorldSession::HandleAuctionPlaceBid(WorldPacket & recv_data)
{
if (auction->bidder > 0)
{
- if (auction->bidder == pl->GetGUIDLow())
- pl->ModifyMoney(-int32(price - auction->bid));
+ if (auction->bidder == player->GetGUIDLow())
+ player->ModifyMoney(-int32(price - auction->bid));
else
{
// mail to last bidder and return money
sAuctionMgr->SendAuctionOutbiddedMail(auction, price, GetPlayer(), trans);
- pl->ModifyMoney(-int32(price));
+ player->ModifyMoney(-int32(price));
}
}
else
- pl->ModifyMoney(-int32(price));
+ player->ModifyMoney(-int32(price));
- auction->bidder = pl->GetGUIDLow();
+ auction->bidder = player->GetGUIDLow();
auction->bid = price;
GetPlayer()->GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_AUCTION_BID, price);
@@ -342,15 +342,15 @@ void WorldSession::HandleAuctionPlaceBid(WorldPacket & recv_data)
else
{
//buyout:
- if (pl->GetGUIDLow() == auction->bidder)
- pl->ModifyMoney(-int32(auction->buyout - auction->bid));
+ if (player->GetGUIDLow() == auction->bidder)
+ player->ModifyMoney(-int32(auction->buyout - auction->bid));
else
{
- pl->ModifyMoney(-int32(auction->buyout));
+ player->ModifyMoney(-int32(auction->buyout));
if (auction->bidder) //buyout for bidded auction ..
sAuctionMgr->SendAuctionOutbiddedMail(auction, auction->buyout, GetPlayer(), trans);
}
- auction->bidder = pl->GetGUIDLow();
+ auction->bidder = player->GetGUIDLow();
auction->bid = auction->buyout;
GetPlayer()->GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_AUCTION_BID, auction->buyout);
@@ -367,7 +367,7 @@ void WorldSession::HandleAuctionPlaceBid(WorldPacket & recv_data)
sAuctionMgr->RemoveAItem(auction->item_guidlow);
auctionHouse->RemoveAuction(auction, item_template);
}
- pl->SaveInventoryAndGoldToDB(trans);
+ player->SaveInventoryAndGoldToDB(trans);
CharacterDatabase.CommitTransaction(trans);
}
@@ -394,10 +394,10 @@ void WorldSession::HandleAuctionRemoveItem(WorldPacket & recv_data)
AuctionHouseObject* auctionHouse = sAuctionMgr->GetAuctionsMap(creature->getFaction());
AuctionEntry* auction = auctionHouse->GetAuction(auctionId);
- Player* pl = GetPlayer();
+ Player* player = GetPlayer();
SQLTransaction trans = CharacterDatabase.BeginTransaction();
- if (auction && auction->owner == pl->GetGUIDLow())
+ if (auction && auction->owner == player->GetGUIDLow())
{
Item* pItem = sAuctionMgr->GetAItem(auction->item_guidlow);
if (pItem)
@@ -405,11 +405,11 @@ void WorldSession::HandleAuctionRemoveItem(WorldPacket & recv_data)
if (auction->bidder > 0) // If we have a bidder, we have to send him the money he paid
{
uint32 auctionCut = auction->GetAuctionCut();
- if (!pl->HasEnoughMoney(auctionCut)) //player doesn't have enough money, maybe message needed
+ if (!player->HasEnoughMoney(auctionCut)) //player doesn't have enough money, maybe message needed
return;
//some auctionBidderNotification would be needed, but don't know that parts..
sAuctionMgr->SendAuctionCancelledToBidderMail(auction, trans);
- pl->ModifyMoney(-int32(auctionCut));
+ player->ModifyMoney(-int32(auctionCut));
}
// Return the item by mail
std::ostringstream msgAuctionCanceledOwner;
@@ -418,7 +418,7 @@ void WorldSession::HandleAuctionRemoveItem(WorldPacket & recv_data)
// item will deleted or added to received mail list
MailDraft(msgAuctionCanceledOwner.str(), "") // TODO: fix body
.AddItem(pItem)
- .SendMailTo(trans, pl, auction, MAIL_CHECK_MASK_COPIED);
+ .SendMailTo(trans, player, auction, MAIL_CHECK_MASK_COPIED);
}
else
{
@@ -431,7 +431,7 @@ void WorldSession::HandleAuctionRemoveItem(WorldPacket & recv_data)
{
SendAuctionCommandResult(0, AUCTION_CANCEL, AUCTION_INTERNAL_ERROR);
//this code isn't possible ... maybe there should be assert
- sLog->outError("CHEATER : %u, he tried to cancel auction (id: %u) of another player, or auction is NULL", pl->GetGUIDLow(), auctionId);
+ sLog->outError("CHEATER : %u, he tried to cancel auction (id: %u) of another player, or auction is NULL", player->GetGUIDLow(), auctionId);
return;
}
@@ -440,7 +440,7 @@ void WorldSession::HandleAuctionRemoveItem(WorldPacket & recv_data)
// Now remove the auction
- pl->SaveInventoryAndGoldToDB(trans);
+ player->SaveInventoryAndGoldToDB(trans);
auction->DeleteFromDB(trans);
CharacterDatabase.CommitTransaction(trans);
@@ -479,7 +479,7 @@ void WorldSession::HandleAuctionListBidderItems(WorldPacket & recv_data)
AuctionHouseObject* auctionHouse = sAuctionMgr->GetAuctionsMap(creature->getFaction());
WorldPacket data(SMSG_AUCTION_BIDDER_LIST_RESULT, (4+4+4));
- Player* pl = GetPlayer();
+ Player* player = GetPlayer();
data << (uint32) 0; //add 0 as count
uint32 count = 0;
uint32 totalcount = 0;
@@ -496,7 +496,7 @@ void WorldSession::HandleAuctionListBidderItems(WorldPacket & recv_data)
}
}
- auctionHouse->BuildListBidderItems(data, pl, count, totalcount);
+ auctionHouse->BuildListBidderItems(data, player, count, totalcount);
data.put<uint32>(0, count); // add count to placeholder
data << totalcount;
data << (uint32)300; //unk 2.3.0
diff --git a/src/server/game/Server/Protocol/Handlers/CalendarHandler.cpp b/src/server/game/Server/Protocol/Handlers/CalendarHandler.cpp
index 8f32ac84cb8..4c6ec6571a4 100755
--- a/src/server/game/Server/Protocol/Handlers/CalendarHandler.cpp
+++ b/src/server/game/Server/Protocol/Handlers/CalendarHandler.cpp
@@ -25,12 +25,14 @@
#include "Opcodes.h"
#include "Player.h"
-void WorldSession::HandleCalendarGetCalendar(WorldPacket & /*recv_data*/)
+void WorldSession::HandleCalendarGetCalendar(WorldPacket& /*recv_data*/)
{
- sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: CMSG_CALENDAR_GET_CALENDAR"); // empty
+ uint64 guid = _player->GetGUID();
+ sLog->outDebug(LOG_FILTER_NETWORKIO, "CMSG_CALENDAR_GET_CALENDAR [" UI64FMTD "]", guid);
- time_t cur_time = time(NULL);
+ time_t cur_time = time_t(time(NULL));
+ sLog->outDebug(LOG_FILTER_NETWORKIO, "SMSG_CALENDAR_SEND_CALENDAR [" UI64FMTD "]", guid);
WorldPacket data(SMSG_CALENDAR_SEND_CALENDAR, 4+4*0+4+4*0+4+4);
data << uint32(0); // invite count
@@ -58,48 +60,52 @@ void WorldSession::HandleCalendarGetCalendar(WorldPacket & /*recv_data*/)
}
*/
- data << uint32(0); // unk
- data << uint32(secsToTimeBitFields(cur_time)); // current time
+ data << uint32(cur_time); // server time
+ data << uint32(secsToTimeBitFields(cur_time)); // server time
uint32 counter = 0;
size_t p_counter = data.wpos();
- data << uint32(counter); // instance save count
+ data << uint32(counter); // instance save count
- for (int i = 0; i < MAX_DIFFICULTY; ++i)
- {
+ for (uint8 i = 0; i < MAX_DIFFICULTY; ++i)
for (Player::BoundInstancesMap::const_iterator itr = _player->m_boundInstances[i].begin(); itr != _player->m_boundInstances[i].end(); ++itr)
- {
if (itr->second.perm)
{
- InstanceSave* save = itr->second.save;
+ InstanceSave const* save = itr->second.save;
data << uint32(save->GetMapId());
data << uint32(save->GetDifficulty());
data << uint32(save->GetResetTime() - cur_time);
- data << uint64(save->GetInstanceId()); // instance save id as unique instance copy id
+ data << uint64(save->GetInstanceId()); // instance save id as unique instance copy id
++counter;
}
- }
- }
data.put<uint32>(p_counter, counter);
- data << uint32(1135753200); // unk (28.12.2005 12:00)
+ data << uint32(1135753200); // unk (28.12.2005 07:00)
counter = 0;
p_counter = data.wpos();
- data << uint32(counter); // raid reset count
+ data << uint32(counter); // raid reset count
+ std::set<uint32> sentMaps;
+
ResetTimeByMapDifficultyMap const& resets = sInstanceSaveMgr->GetResetTimeMap();
for (ResetTimeByMapDifficultyMap::const_iterator itr = resets.begin(); itr != resets.end(); ++itr)
{
- uint32 mapid = PAIR32_LOPART(itr->first);
- MapEntry const* mapEnt = sMapStore.LookupEntry(mapid);
- if (!mapEnt || !mapEnt->IsRaid())
+ uint32 mapId = PAIR32_LOPART(itr->first);
+
+ if (sentMaps.find(mapId) != sentMaps.end())
+ continue;
+
+ MapEntry const* mapEntry = sMapStore.LookupEntry(mapId);
+ if (!mapEntry || !mapEntry->IsRaid())
continue;
- data << uint32(mapid);
+ sentMaps.insert(mapId);
+
+ data << uint32(mapId);
data << uint32(itr->second - cur_time);
- data << uint32(mapEnt->unk_time);
+ data << uint32(mapEntry->unk_time);
++counter;
}
@@ -126,17 +132,16 @@ void WorldSession::HandleCalendarGetCalendar(WorldPacket & /*recv_data*/)
}
*/
- sLog->outDebug(LOG_FILTER_NETWORKIO, "Sending calendar");
SendPacket(&data);
}
-void WorldSession::HandleCalendarGetEvent(WorldPacket &recv_data)
+void WorldSession::HandleCalendarGetEvent(WorldPacket& recv_data)
{
sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: CMSG_CALENDAR_GET_EVENT");
recv_data.read_skip<uint64>(); // unk
}
-void WorldSession::HandleCalendarGuildFilter(WorldPacket &recv_data)
+void WorldSession::HandleCalendarGuildFilter(WorldPacket& recv_data)
{
sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: CMSG_CALENDAR_GUILD_FILTER");
recv_data.read_skip<uint32>(); // unk1
@@ -144,13 +149,13 @@ void WorldSession::HandleCalendarGuildFilter(WorldPacket &recv_data)
recv_data.read_skip<uint32>(); // unk3
}
-void WorldSession::HandleCalendarArenaTeam(WorldPacket &recv_data)
+void WorldSession::HandleCalendarArenaTeam(WorldPacket& recv_data)
{
sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: CMSG_CALENDAR_ARENA_TEAM");
recv_data.read_skip<uint32>(); // unk
}
-void WorldSession::HandleCalendarAddEvent(WorldPacket &recv_data)
+void WorldSession::HandleCalendarAddEvent(WorldPacket& recv_data)
{
sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: CMSG_CALENDAR_ADD_EVENT");
recv_data.rfinish(); // set to end to avoid warnings spam
@@ -185,7 +190,7 @@ void WorldSession::HandleCalendarAddEvent(WorldPacket &recv_data)
//}
}
-void WorldSession::HandleCalendarUpdateEvent(WorldPacket &recv_data)
+void WorldSession::HandleCalendarUpdateEvent(WorldPacket& recv_data)
{
sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: CMSG_CALENDAR_UPDATE_EVENT");
recv_data.rfinish(); // set to end to avoid warnings spam
@@ -203,7 +208,7 @@ void WorldSession::HandleCalendarUpdateEvent(WorldPacket &recv_data)
//recv_data >> uint32
}
-void WorldSession::HandleCalendarRemoveEvent(WorldPacket &recv_data)
+void WorldSession::HandleCalendarRemoveEvent(WorldPacket& recv_data)
{
sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: CMSG_CALENDAR_REMOVE_EVENT");
recv_data.rfinish(); // set to end to avoid warnings spam
@@ -214,7 +219,7 @@ void WorldSession::HandleCalendarRemoveEvent(WorldPacket &recv_data)
}
-void WorldSession::HandleCalendarCopyEvent(WorldPacket &recv_data)
+void WorldSession::HandleCalendarCopyEvent(WorldPacket& recv_data)
{
sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: CMSG_CALENDAR_COPY_EVENT");
recv_data.rfinish(); // set to end to avoid warnings spam
@@ -225,7 +230,7 @@ void WorldSession::HandleCalendarCopyEvent(WorldPacket &recv_data)
}
-void WorldSession::HandleCalendarEventInvite(WorldPacket &recv_data)
+void WorldSession::HandleCalendarEventInvite(WorldPacket& recv_data)
{
sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: CMSG_CALENDAR_EVENT_INVITE");
recv_data.rfinish(); // set to end to avoid warnings spam
@@ -238,7 +243,7 @@ void WorldSession::HandleCalendarEventInvite(WorldPacket &recv_data)
}
-void WorldSession::HandleCalendarEventRsvp(WorldPacket &recv_data)
+void WorldSession::HandleCalendarEventRsvp(WorldPacket& recv_data)
{
sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: CMSG_CALENDAR_EVENT_RSVP");
recv_data.rfinish(); // set to end to avoid warnings spam
@@ -249,7 +254,7 @@ void WorldSession::HandleCalendarEventRsvp(WorldPacket &recv_data)
}
-void WorldSession::HandleCalendarEventRemoveInvite(WorldPacket &recv_data)
+void WorldSession::HandleCalendarEventRemoveInvite(WorldPacket& recv_data)
{
sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: CMSG_CALENDAR_EVENT_REMOVE_INVITE");
recv_data.rfinish(); // set to end to avoid warnings spam
@@ -260,7 +265,7 @@ void WorldSession::HandleCalendarEventRemoveInvite(WorldPacket &recv_data)
//recv_data >> uint64
}
-void WorldSession::HandleCalendarEventStatus(WorldPacket &recv_data)
+void WorldSession::HandleCalendarEventStatus(WorldPacket& recv_data)
{
sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: CMSG_CALENDAR_EVENT_STATUS");
recv_data.rfinish(); // set to end to avoid warnings spam
@@ -272,7 +277,7 @@ void WorldSession::HandleCalendarEventStatus(WorldPacket &recv_data)
//recv_data >> uint32
}
-void WorldSession::HandleCalendarEventModeratorStatus(WorldPacket &recv_data)
+void WorldSession::HandleCalendarEventModeratorStatus(WorldPacket& recv_data)
{
sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: CMSG_CALENDAR_EVENT_MODERATOR_STATUS");
recv_data.rfinish(); // set to end to avoid warnings spam
@@ -284,7 +289,7 @@ void WorldSession::HandleCalendarEventModeratorStatus(WorldPacket &recv_data)
//recv_data >> uint32
}
-void WorldSession::HandleCalendarComplain(WorldPacket &recv_data)
+void WorldSession::HandleCalendarComplain(WorldPacket& recv_data)
{
sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: CMSG_CALENDAR_COMPLAIN");
recv_data.rfinish(); // set to end to avoid warnings spam
@@ -294,7 +299,7 @@ void WorldSession::HandleCalendarComplain(WorldPacket &recv_data)
//recv_data >> uint64
}
-void WorldSession::HandleCalendarGetNumPending(WorldPacket & /*recv_data*/)
+void WorldSession::HandleCalendarGetNumPending(WorldPacket& /*recv_data*/)
{
sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: CMSG_CALENDAR_GET_NUM_PENDING"); // empty
diff --git a/src/server/game/Server/Protocol/Handlers/CharacterHandler.cpp b/src/server/game/Server/Protocol/Handlers/CharacterHandler.cpp
index a468d05bcdf..83b9ab048ad 100755
--- a/src/server/game/Server/Protocol/Handlers/CharacterHandler.cpp
+++ b/src/server/game/Server/Protocol/Handlers/CharacterHandler.cpp
@@ -658,7 +658,7 @@ void WorldSession::HandleCharCreateCallback(PreparedQueryResult result, Characte
newChar.SetAtLoginFlag(AT_LOGIN_FIRST); // First login
// Player created, save it now
- newChar.SaveToDB();
+ newChar.SaveToDB(true);
createInfo->CharCount += 1;
SQLTransaction trans = LoginDatabase.BeginTransaction();
@@ -920,7 +920,7 @@ void WorldSession::HandlePlayerLogin(LoginQueryHolder * holder)
}
}
- if (!pCurrChar->GetMap()->AddToMap(pCurrChar) || !pCurrChar->CheckInstanceLoginValid())
+ if (!pCurrChar->GetMap()->AddPlayerToMap(pCurrChar) || !pCurrChar->CheckInstanceLoginValid())
{
AreaTrigger const* at = sObjectMgr->GetGoBackTrigger(pCurrChar->GetMapId());
if (at)
@@ -1170,6 +1170,8 @@ void WorldSession::HandleChangePlayerNameOpcodeCallBack(QueryResult result, std:
data << uint64(guid);
data << newname;
SendPacket(&data);
+
+ sWorld->UpdateCharacterNameData(guidLow, newname);
}
void WorldSession::HandleSetPlayerDeclinedNames(WorldPacket& recv_data)
@@ -1407,9 +1409,9 @@ void WorldSession::HandleCharCustomize(WorldPacket& recv_data)
}
CharacterDatabase.EscapeString(newname);
- if (QueryResult result = CharacterDatabase.PQuery("SELECT name FROM characters WHERE guid ='%u'", GUID_LOPART(guid)))
+ if (QueryResult oldNameResult = CharacterDatabase.PQuery("SELECT name FROM characters WHERE guid ='%u'", GUID_LOPART(guid)))
{
- std::string oldname = result->Fetch()[0].GetString();
+ std::string oldname = oldNameResult->Fetch()[0].GetString();
std::string IP_str = GetRemoteAddress();
sLog->outChar("Account: %d (IP: %s), Character[%s] (guid:%u) Customized to: %s", GetAccountId(), IP_str.c_str(), oldname.c_str(), GUID_LOPART(guid), newname.c_str());
}
@@ -1634,7 +1636,7 @@ void WorldSession::HandleCharFactionOrRaceChange(WorldPacket& recv_data)
SQLTransaction trans = CharacterDatabase.BeginTransaction();
trans->PAppend("UPDATE `characters` SET name='%s', race='%u', at_login=at_login & ~ %u WHERE guid='%u'", newname.c_str(), race, used_loginFlag, lowGuid);
trans->PAppend("DELETE FROM character_declinedname WHERE guid ='%u'", lowGuid);
- sWorld->UpdateCharacterNameData(GUID_LOPART(guid), newname, gender, race);
+ sWorld->UpdateCharacterNameData(GUID_LOPART(guid), newname, gender, race);
BattlegroundTeamId team = BG_TEAM_ALLIANCE;
diff --git a/src/server/game/Server/Protocol/Handlers/ChatHandler.cpp b/src/server/game/Server/Protocol/Handlers/ChatHandler.cpp
index 83d92df4f7a..852549b3f53 100755
--- a/src/server/game/Server/Protocol/Handlers/ChatHandler.cpp
+++ b/src/server/game/Server/Protocol/Handlers/ChatHandler.cpp
@@ -495,8 +495,8 @@ namespace Trinity
class EmoteChatBuilder
{
public:
- EmoteChatBuilder(Player const& pl, uint32 text_emote, uint32 emote_num, Unit const* target)
- : i_player(pl), i_text_emote(text_emote), i_emote_num(emote_num), i_target(target) {}
+ EmoteChatBuilder(Player const& player, uint32 text_emote, uint32 emote_num, Unit const* target)
+ : i_player(player), i_text_emote(text_emote), i_emote_num(emote_num), i_target(target) {}
void operator()(WorldPacket& data, LocaleConstant loc_idx)
{
@@ -566,10 +566,9 @@ void WorldSession::HandleTextEmoteOpcode(WorldPacket & recv_data)
Unit* unit = ObjectAccessor::GetUnit(*_player, guid);
- CellPair p = Trinity::ComputeCellPair(GetPlayer()->GetPositionX(), GetPlayer()->GetPositionY());
+ CellCoord p = Trinity::ComputeCellCoord(GetPlayer()->GetPositionX(), GetPlayer()->GetPositionY());
Cell cell(p);
- cell.data.Part.reserved = ALL_DISTRICT;
cell.SetNoCreate();
Trinity::EmoteChatBuilder emote_builder(*GetPlayer(), text_emote, emoteNum, unit);
diff --git a/src/server/game/Server/Protocol/Handlers/DuelHandler.cpp b/src/server/game/Server/Protocol/Handlers/DuelHandler.cpp
index 48bc305ce30..b1e6f3fdc3f 100755
--- a/src/server/game/Server/Protocol/Handlers/DuelHandler.cpp
+++ b/src/server/game/Server/Protocol/Handlers/DuelHandler.cpp
@@ -27,7 +27,7 @@
void WorldSession::HandleDuelAcceptedOpcode(WorldPacket& recvPacket)
{
uint64 guid;
- Player* pl;
+ Player* player;
Player* plTarget;
recvPacket >> guid;
@@ -35,21 +35,21 @@ void WorldSession::HandleDuelAcceptedOpcode(WorldPacket& recvPacket)
if (!GetPlayer()->duel) // ignore accept from duel-sender
return;
- pl = GetPlayer();
- plTarget = pl->duel->opponent;
+ player = GetPlayer();
+ plTarget = player->duel->opponent;
- if (pl == pl->duel->initiator || !plTarget || pl == plTarget || pl->duel->startTime != 0 || plTarget->duel->startTime != 0)
+ if (player == player->duel->initiator || !plTarget || player == plTarget || player->duel->startTime != 0 || plTarget->duel->startTime != 0)
return;
//sLog->outDebug(LOG_FILTER_PACKETIO, "WORLD: Received CMSG_DUEL_ACCEPTED");
- sLog->outStaticDebug("Player 1 is: %u (%s)", pl->GetGUIDLow(), pl->GetName());
+ sLog->outStaticDebug("Player 1 is: %u (%s)", player->GetGUIDLow(), player->GetName());
sLog->outStaticDebug("Player 2 is: %u (%s)", plTarget->GetGUIDLow(), plTarget->GetName());
time_t now = time(NULL);
- pl->duel->startTimer = now;
+ player->duel->startTimer = now;
plTarget->duel->startTimer = now;
- pl->SendDuelCountdown(3000);
+ player->SendDuelCountdown(3000);
plTarget->SendDuelCountdown(3000);
}
diff --git a/src/server/game/Server/Protocol/Handlers/GroupHandler.cpp b/src/server/game/Server/Protocol/Handlers/GroupHandler.cpp
index 404a949371a..65865280459 100755
--- a/src/server/game/Server/Protocol/Handlers/GroupHandler.cpp
+++ b/src/server/game/Server/Protocol/Handlers/GroupHandler.cpp
@@ -306,9 +306,9 @@ void WorldSession::HandleGroupUninviteGuidOpcode(WorldPacket & recv_data)
return;
}
- if (Player* plr = grp->GetInvited(guid))
+ if (Player* player = grp->GetInvited(guid))
{
- plr->UninviteFromGroup();
+ player->UninviteFromGroup();
return;
}
@@ -350,9 +350,9 @@ void WorldSession::HandleGroupUninviteOpcode(WorldPacket & recv_data)
return;
}
- if (Player* plr = grp->GetInvited(membername))
+ if (Player* player = grp->GetInvited(membername))
{
- plr->UninviteFromGroup();
+ player->UninviteFromGroup();
return;
}
diff --git a/src/server/game/Server/Protocol/Handlers/ItemHandler.cpp b/src/server/game/Server/Protocol/Handlers/ItemHandler.cpp
index eca466436be..f4e3af72892 100755
--- a/src/server/game/Server/Protocol/Handlers/ItemHandler.cpp
+++ b/src/server/game/Server/Protocol/Handlers/ItemHandler.cpp
@@ -1341,7 +1341,7 @@ void WorldSession::HandleSocketOpcode(WorldPacket& recv_data)
_player->ToggleMetaGemsActive(slot, true); //turn on all metagems (except for target item)
- itemTarget->SetSoulboundTradeable(NULL, _player, false); // clear tradeable flag
+ itemTarget->ClearSoulboundTradeable(_player); // clear tradeable flag
}
void WorldSession::HandleCancelTempEnchantmentOpcode(WorldPacket& recv_data)
diff --git a/src/server/game/Server/Protocol/Handlers/LFGHandler.cpp b/src/server/game/Server/Protocol/Handlers/LFGHandler.cpp
index fab7bf841c2..3df59b9bba1 100755
--- a/src/server/game/Server/Protocol/Handlers/LFGHandler.cpp
+++ b/src/server/game/Server/Protocol/Handlers/LFGHandler.cpp
@@ -205,14 +205,14 @@ void WorldSession::HandleLfgPlayerLockInfoRequestOpcode(WorldPacket& /*recv_data
ItemTemplate const* iProto = NULL;
for (uint8 i = 0; i < QUEST_REWARDS_COUNT; ++i)
{
- if (!qRew->RewItemId[i])
+ if (!qRew->RewardItemId[i])
continue;
- iProto = sObjectMgr->GetItemTemplate(qRew->RewItemId[i]);
+ iProto = sObjectMgr->GetItemTemplate(qRew->RewardItemId[i]);
- data << uint32(qRew->RewItemId[i]);
+ data << uint32(qRew->RewardItemId[i]);
data << uint32(iProto ? iProto->DisplayInfoID : 0);
- data << uint32(qRew->RewItemCount[i]);
+ data << uint32(qRew->RewardItemIdCount[i]);
}
}
}
@@ -419,8 +419,8 @@ void WorldSession::SendLfgRoleCheckUpdate(const LfgRoleCheck* pRoleCheck)
data << uint64(guid); // Guid
data << uint8(roles > 0); // Ready
data << uint32(roles); // Roles
- Player* plr = ObjectAccessor::FindPlayer(guid);
- data << uint8(plr ? plr->getLevel() : 0); // Level
+ Player* player = ObjectAccessor::FindPlayer(guid);
+ data << uint8(player ? player->getLevel() : 0); // Level
for (LfgRolesMap::const_iterator it = pRoleCheck->roles.begin(); it != pRoleCheck->roles.end(); ++it)
{
@@ -432,8 +432,8 @@ void WorldSession::SendLfgRoleCheckUpdate(const LfgRoleCheck* pRoleCheck)
data << uint64(guid); // Guid
data << uint8(roles > 0); // Ready
data << uint32(roles); // Roles
- plr = ObjectAccessor::FindPlayer(guid);
- data << uint8(plr ? plr->getLevel() : 0); // Level
+ player = ObjectAccessor::FindPlayer(guid);
+ data << uint8(player ? player->getLevel() : 0); // Level
}
}
SendPacket(&data);
@@ -495,14 +495,14 @@ void WorldSession::SendLfgPlayerReward(uint32 rdungeonEntry, uint32 sdungeonEntr
ItemTemplate const* iProto = NULL;
for (uint8 i = 0; i < QUEST_REWARDS_COUNT; ++i)
{
- if (!qRew->RewItemId[i])
+ if (!qRew->RewardItemId[i])
continue;
- iProto = sObjectMgr->GetItemTemplate(qRew->RewItemId[i]);
+ iProto = sObjectMgr->GetItemTemplate(qRew->RewardItemId[i]);
- data << uint32(qRew->RewItemId[i]);
+ data << uint32(qRew->RewardItemId[i]);
data << uint32(iProto ? iProto->DisplayInfoID : 0);
- data << uint32(qRew->RewItemCount[i]);
+ data << uint32(qRew->RewardItemIdCount[i]);
}
}
SendPacket(&data);
diff --git a/src/server/game/Server/Protocol/Handlers/LootHandler.cpp b/src/server/game/Server/Protocol/Handlers/LootHandler.cpp
index 83d3fad3b21..05b4afc99e7 100755
--- a/src/server/game/Server/Protocol/Handlers/LootHandler.cpp
+++ b/src/server/game/Server/Protocol/Handlers/LootHandler.cpp
@@ -489,10 +489,10 @@ void WorldSession::HandleLootMasterGiveOpcode(WorldPacket & recv_data)
}
// list of players allowed to receive this item in trade
- AllowedLooterSet* looters = item.GetAllowedLooters();
+ AllowedLooterSet looters = item.GetAllowedLooters();
// not move item from loot to target inventory
- Item* newitem = target->StoreNewItem(dest, item.itemid, true, item.randomPropertyId, (looters->size() > 1) ? looters : NULL);
+ Item* newitem = target->StoreNewItem(dest, item.itemid, true, item.randomPropertyId, looters);
target->SendNewItem(newitem, uint32(item.count), false, false, true);
target->GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_LOOT_ITEM, item.itemid, item.count);
target->GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_LOOT_TYPE, pLoot->loot_type, item.count);
diff --git a/src/server/game/Server/Protocol/Handlers/MailHandler.cpp b/src/server/game/Server/Protocol/Handlers/MailHandler.cpp
index 432a8bf3f6a..2dee8e3ae15 100755
--- a/src/server/game/Server/Protocol/Handlers/MailHandler.cpp
+++ b/src/server/game/Server/Protocol/Handlers/MailHandler.cpp
@@ -75,9 +75,9 @@ void WorldSession::HandleSendMail(WorldPacket & recv_data)
if (receiver.empty())
return;
- Player* pl = _player;
+ Player* player = _player;
- if (pl->getLevel() < sWorld->getIntConfig(CONFIG_MAIL_LEVEL_REQ))
+ if (player->getLevel() < sWorld->getIntConfig(CONFIG_MAIL_LEVEL_REQ))
{
SendNotification(GetTrinityString(LANG_MAIL_SENDER_REQ), sWorld->getIntConfig(CONFIG_MAIL_LEVEL_REQ));
return;
@@ -90,16 +90,16 @@ void WorldSession::HandleSendMail(WorldPacket & recv_data)
if (!rc)
{
sLog->outDetail("Player %u is sending mail to %s (GUID: not existed!) with subject %s and body %s includes %u items, %u copper and %u COD copper with unk1 = %u, unk2 = %u",
- pl->GetGUIDLow(), receiver.c_str(), subject.c_str(), body.c_str(), items_count, money, COD, unk1, unk2);
- pl->SendMailResult(0, MAIL_SEND, MAIL_ERR_RECIPIENT_NOT_FOUND);
+ player->GetGUIDLow(), receiver.c_str(), subject.c_str(), body.c_str(), items_count, money, COD, unk1, unk2);
+ player->SendMailResult(0, MAIL_SEND, MAIL_ERR_RECIPIENT_NOT_FOUND);
return;
}
- sLog->outDetail("Player %u is sending mail to %s (GUID: %u) with subject %s and body %s includes %u items, %u copper and %u COD copper with unk1 = %u, unk2 = %u", pl->GetGUIDLow(), receiver.c_str(), GUID_LOPART(rc), subject.c_str(), body.c_str(), items_count, money, COD, unk1, unk2);
+ sLog->outDetail("Player %u is sending mail to %s (GUID: %u) with subject %s and body %s includes %u items, %u copper and %u COD copper with unk1 = %u, unk2 = %u", player->GetGUIDLow(), receiver.c_str(), GUID_LOPART(rc), subject.c_str(), body.c_str(), items_count, money, COD, unk1, unk2);
- if (pl->GetGUID() == rc)
+ if (player->GetGUID() == rc)
{
- pl->SendMailResult(0, MAIL_SEND, MAIL_ERR_CANNOT_SEND_TO_SELF);
+ player->SendMailResult(0, MAIL_SEND, MAIL_ERR_CANNOT_SEND_TO_SELF);
return;
}
@@ -107,9 +107,9 @@ void WorldSession::HandleSendMail(WorldPacket & recv_data)
uint32 reqmoney = cost + money;
- if (!pl->HasEnoughMoney(reqmoney))
+ if (!player->HasEnoughMoney(reqmoney))
{
- pl->SendMailResult(0, MAIL_SEND, MAIL_ERR_NOT_ENOUGH_MONEY);
+ player->SendMailResult(0, MAIL_SEND, MAIL_ERR_NOT_ENOUGH_MONEY);
return;
}
@@ -142,14 +142,14 @@ void WorldSession::HandleSendMail(WorldPacket & recv_data)
//do not allow to have more than 100 mails in mailbox.. mails count is in opcode uint8!!! - so max can be 255..
if (mails_count > 100)
{
- pl->SendMailResult(0, MAIL_SEND, MAIL_ERR_RECIPIENT_CAP_REACHED);
+ player->SendMailResult(0, MAIL_SEND, MAIL_ERR_RECIPIENT_CAP_REACHED);
return;
}
// test the receiver's Faction... or all items are account bound
bool accountBound = items_count ? true : false;
for (uint8 i = 0; i < items_count; ++i)
{
- Item* item = pl->GetItemByGuid(itemGUIDs[i]);
+ Item* item = player->GetItemByGuid(itemGUIDs[i]);
if (item)
{
ItemTemplate const* itemProto = item->GetTemplate();
@@ -161,9 +161,9 @@ void WorldSession::HandleSendMail(WorldPacket & recv_data)
}
}
- if (!accountBound && !sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_MAIL) && pl->GetTeam() != rc_team && AccountMgr::IsPlayerAccount(GetSecurity()))
+ if (!accountBound && !sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_MAIL) && player->GetTeam() != rc_team && AccountMgr::IsPlayerAccount(GetSecurity()))
{
- pl->SendMailResult(0, MAIL_SEND, MAIL_ERR_NOT_YOUR_TEAM);
+ player->SendMailResult(0, MAIL_SEND, MAIL_ERR_NOT_YOUR_TEAM);
return;
}
@@ -183,56 +183,56 @@ void WorldSession::HandleSendMail(WorldPacket & recv_data)
{
if (!itemGUIDs[i])
{
- pl->SendMailResult(0, MAIL_SEND, MAIL_ERR_MAIL_ATTACHMENT_INVALID);
+ player->SendMailResult(0, MAIL_SEND, MAIL_ERR_MAIL_ATTACHMENT_INVALID);
return;
}
- Item* item = pl->GetItemByGuid(itemGUIDs[i]);
+ Item* item = player->GetItemByGuid(itemGUIDs[i]);
// prevent sending bag with items (cheat: can be placed in bag after adding equipped empty bag to mail)
if (!item)
{
- pl->SendMailResult(0, MAIL_SEND, MAIL_ERR_MAIL_ATTACHMENT_INVALID);
+ player->SendMailResult(0, MAIL_SEND, MAIL_ERR_MAIL_ATTACHMENT_INVALID);
return;
}
if (!item->CanBeTraded(true))
{
- pl->SendMailResult(0, MAIL_SEND, MAIL_ERR_EQUIP_ERROR, EQUIP_ERR_MAIL_BOUND_ITEM);
+ player->SendMailResult(0, MAIL_SEND, MAIL_ERR_EQUIP_ERROR, EQUIP_ERR_MAIL_BOUND_ITEM);
return;
}
- if (item->IsBoundAccountWide() && item->IsSoulBound() && pl->GetSession()->GetAccountId() != rc_account)
+ if (item->IsBoundAccountWide() && item->IsSoulBound() && player->GetSession()->GetAccountId() != rc_account)
{
- pl->SendMailResult(0, MAIL_SEND, MAIL_ERR_EQUIP_ERROR, EQUIP_ERR_ARTEFACTS_ONLY_FOR_OWN_CHARACTERS);
+ player->SendMailResult(0, MAIL_SEND, MAIL_ERR_EQUIP_ERROR, EQUIP_ERR_ARTEFACTS_ONLY_FOR_OWN_CHARACTERS);
return;
}
if (item->GetTemplate()->Flags & ITEM_PROTO_FLAG_CONJURED || item->GetUInt32Value(ITEM_FIELD_DURATION))
{
- pl->SendMailResult(0, MAIL_SEND, MAIL_ERR_EQUIP_ERROR, EQUIP_ERR_MAIL_BOUND_ITEM);
+ player->SendMailResult(0, MAIL_SEND, MAIL_ERR_EQUIP_ERROR, EQUIP_ERR_MAIL_BOUND_ITEM);
return;
}
if (COD && item->HasFlag(ITEM_FIELD_FLAGS, ITEM_FLAG_WRAPPED))
{
- pl->SendMailResult(0, MAIL_SEND, MAIL_ERR_CANT_SEND_WRAPPED_COD);
+ player->SendMailResult(0, MAIL_SEND, MAIL_ERR_CANT_SEND_WRAPPED_COD);
return;
}
if (item->IsNotEmptyBag())
{
- pl->SendMailResult(0, MAIL_SEND, MAIL_ERR_EQUIP_ERROR, EQUIP_ERR_CAN_ONLY_DO_WITH_EMPTY_BAGS);
+ player->SendMailResult(0, MAIL_SEND, MAIL_ERR_EQUIP_ERROR, EQUIP_ERR_CAN_ONLY_DO_WITH_EMPTY_BAGS);
return;
}
items[i] = item;
}
- pl->SendMailResult(0, MAIL_SEND, MAIL_OK);
+ player->SendMailResult(0, MAIL_SEND, MAIL_OK);
- pl->ModifyMoney(-int32(reqmoney));
- pl->GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_GOLD_SPENT_FOR_MAIL, cost);
+ player->ModifyMoney(-int32(reqmoney));
+ player->GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_GOLD_SPENT_FOR_MAIL, cost);
bool needItemDelay = false;
@@ -254,7 +254,7 @@ void WorldSession::HandleSendMail(WorldPacket & recv_data)
}
item->SetNotRefundable(GetPlayer()); // makes the item no longer refundable
- pl->MoveItemFromInventory(items[i]->GetBagSlot(), item->GetSlot(), true);
+ player->MoveItemFromInventory(items[i]->GetBagSlot(), item->GetSlot(), true);
item->DeleteFromInventoryDB(trans); // deletes item from character's inventory
item->SetOwnerGUID(rc);
@@ -264,7 +264,7 @@ void WorldSession::HandleSendMail(WorldPacket & recv_data)
}
// if item send to character at another account, then apply item delivery delay
- needItemDelay = pl->GetSession()->GetAccountId() != rc_account;
+ needItemDelay = player->GetSession()->GetAccountId() != rc_account;
}
if (money > 0 && !AccountMgr::IsPlayerAccount(GetSecurity()) && sWorld->getBoolConfig(CONFIG_GM_LOG_TRADE))
@@ -281,9 +281,9 @@ void WorldSession::HandleSendMail(WorldPacket & recv_data)
draft
.AddMoney(money)
.AddCOD(COD)
- .SendMailTo(trans, MailReceiver(receive, GUID_LOPART(rc)), MailSender(pl), body.empty() ? MAIL_CHECK_MASK_COPIED : MAIL_CHECK_MASK_HAS_BODY, deliver_delay);
+ .SendMailTo(trans, MailReceiver(receive, GUID_LOPART(rc)), MailSender(player), body.empty() ? MAIL_CHECK_MASK_COPIED : MAIL_CHECK_MASK_HAS_BODY, deliver_delay);
- pl->SaveInventoryAndGoldToDB(trans);
+ player->SaveInventoryAndGoldToDB(trans);
CharacterDatabase.CommitTransaction(trans);
}
@@ -298,14 +298,14 @@ void WorldSession::HandleMailMarkAsRead(WorldPacket & recv_data)
if (!GetPlayer()->GetGameObjectIfCanInteractWith(mailbox, GAMEOBJECT_TYPE_MAILBOX))
return;
- Player* pl = _player;
- Mail* m = pl->GetMail(mailId);
+ Player* player = _player;
+ Mail* m = player->GetMail(mailId);
if (m)
{
- if (pl->unReadMails)
- --pl->unReadMails;
+ if (player->unReadMails)
+ --player->unReadMails;
m->checked = m->checked | MAIL_CHECK_MASK_READ;
- pl->m_mailsUpdated = true;
+ player->m_mailsUpdated = true;
m->state = MAIL_STATE_CHANGED;
}
}
@@ -323,20 +323,20 @@ void WorldSession::HandleMailDelete(WorldPacket & recv_data)
return;
Mail* m = _player->GetMail(mailId);
- Player* pl = _player;
- pl->m_mailsUpdated = true;
+ Player* player = _player;
+ player->m_mailsUpdated = true;
if (m)
{
// delete shouldn't show up for COD mails
if (m->COD)
{
- pl->SendMailResult(mailId, MAIL_DELETED, MAIL_ERR_INTERNAL_ERROR);
+ player->SendMailResult(mailId, MAIL_DELETED, MAIL_ERR_INTERNAL_ERROR);
return;
}
m->state = MAIL_STATE_DELETED;
}
- pl->SendMailResult(mailId, MAIL_DELETED, MAIL_OK);
+ player->SendMailResult(mailId, MAIL_DELETED, MAIL_OK);
}
void WorldSession::HandleMailReturnToSender(WorldPacket & recv_data)
@@ -350,11 +350,11 @@ void WorldSession::HandleMailReturnToSender(WorldPacket & recv_data)
if (!GetPlayer()->GetGameObjectIfCanInteractWith(mailbox, GAMEOBJECT_TYPE_MAILBOX))
return;
- Player* pl = _player;
- Mail* m = pl->GetMail(mailId);
+ Player* player = _player;
+ Mail* m = player->GetMail(mailId);
if (!m || m->state == MAIL_STATE_DELETED || m->deliver_time > time(NULL))
{
- pl->SendMailResult(mailId, MAIL_RETURNED_TO_SENDER, MAIL_ERR_INTERNAL_ERROR);
+ player->SendMailResult(mailId, MAIL_RETURNED_TO_SENDER, MAIL_ERR_INTERNAL_ERROR);
return;
}
//we can return mail now
@@ -362,7 +362,7 @@ void WorldSession::HandleMailReturnToSender(WorldPacket & recv_data)
SQLTransaction trans = CharacterDatabase.BeginTransaction();
trans->PAppend("DELETE FROM mail WHERE id = '%u'", mailId); // needed?
trans->PAppend("DELETE FROM mail_items WHERE mail_id = '%u'", mailId);
- pl->RemoveMail(mailId);
+ player->RemoveMail(mailId);
// only return mail if the player exists (and delete if not existing)
if (m->messageType == MAIL_NORMAL && m->sender)
@@ -375,7 +375,7 @@ void WorldSession::HandleMailReturnToSender(WorldPacket & recv_data)
{
for (MailItemInfoVec::iterator itr2 = m->items.begin(); itr2 != m->items.end(); ++itr2)
{
- Item* item = pl->GetMItem(itr2->item_guid);
+ Item* item = player->GetMItem(itr2->item_guid);
if (item)
draft.AddItem(item);
else
@@ -383,7 +383,7 @@ void WorldSession::HandleMailReturnToSender(WorldPacket & recv_data)
//WTF?
}
- pl->RemoveMItem(itr2->item_guid);
+ player->RemoveMItem(itr2->item_guid);
}
}
draft.AddMoney(m->money).SendReturnToSender(GetAccountId(), m->receiver, m->sender, trans);
@@ -392,7 +392,7 @@ void WorldSession::HandleMailReturnToSender(WorldPacket & recv_data)
CharacterDatabase.CommitTransaction(trans);
delete m; //we can deallocate old mail
- pl->SendMailResult(mailId, MAIL_RETURNED_TO_SENDER, MAIL_OK);
+ player->SendMailResult(mailId, MAIL_RETURNED_TO_SENDER, MAIL_OK);
}
//called when player takes item attached in mail
@@ -408,23 +408,23 @@ void WorldSession::HandleMailTakeItem(WorldPacket & recv_data)
if (!GetPlayer()->GetGameObjectIfCanInteractWith(mailbox, GAMEOBJECT_TYPE_MAILBOX))
return;
- Player* pl = _player;
+ Player* player = _player;
- Mail* m = pl->GetMail(mailId);
+ Mail* m = player->GetMail(mailId);
if (!m || m->state == MAIL_STATE_DELETED || m->deliver_time > time(NULL))
{
- pl->SendMailResult(mailId, MAIL_ITEM_TAKEN, MAIL_ERR_INTERNAL_ERROR);
+ player->SendMailResult(mailId, MAIL_ITEM_TAKEN, MAIL_ERR_INTERNAL_ERROR);
return;
}
// prevent cheating with skip client money check
- if (!pl->HasEnoughMoney(m->COD))
+ if (!player->HasEnoughMoney(m->COD))
{
- pl->SendMailResult(mailId, MAIL_ITEM_TAKEN, MAIL_ERR_NOT_ENOUGH_MONEY);
+ player->SendMailResult(mailId, MAIL_ITEM_TAKEN, MAIL_ERR_NOT_ENOUGH_MONEY);
return;
}
- Item* it = pl->GetMItem(itemId);
+ Item* it = player->GetMItem(itemId);
ItemPosCountVec dest;
uint8 msg = _player->CanStoreItem(NULL_BAG, NULL_SLOT, dest, it, false);
@@ -471,24 +471,24 @@ void WorldSession::HandleMailTakeItem(WorldPacket & recv_data)
.SendMailTo(trans, MailReceiver(receive, m->sender), MailSender(MAIL_NORMAL, m->receiver), MAIL_CHECK_MASK_COD_PAYMENT);
}
- pl->ModifyMoney(-int32(m->COD));
+ player->ModifyMoney(-int32(m->COD));
}
m->COD = 0;
m->state = MAIL_STATE_CHANGED;
- pl->m_mailsUpdated = true;
- pl->RemoveMItem(it->GetGUIDLow());
+ player->m_mailsUpdated = true;
+ player->RemoveMItem(it->GetGUIDLow());
uint32 count = it->GetCount(); // save counts before store and possible merge with deleting
- pl->MoveItemToInventory(dest, it, true);
+ player->MoveItemToInventory(dest, it, true);
- pl->SaveInventoryAndGoldToDB(trans);
- pl->_SaveMail(trans);
+ player->SaveInventoryAndGoldToDB(trans);
+ player->_SaveMail(trans);
CharacterDatabase.CommitTransaction(trans);
- pl->SendMailResult(mailId, MAIL_ITEM_TAKEN, MAIL_OK, 0, itemId, count);
+ player->SendMailResult(mailId, MAIL_ITEM_TAKEN, MAIL_OK, 0, itemId, count);
}
else
- pl->SendMailResult(mailId, MAIL_ITEM_TAKEN, MAIL_ERR_EQUIP_ERROR, msg);
+ player->SendMailResult(mailId, MAIL_ITEM_TAKEN, MAIL_ERR_EQUIP_ERROR, msg);
}
void WorldSession::HandleMailTakeMoney(WorldPacket & recv_data)
@@ -501,26 +501,26 @@ void WorldSession::HandleMailTakeMoney(WorldPacket & recv_data)
if (!GetPlayer()->GetGameObjectIfCanInteractWith(mailbox, GAMEOBJECT_TYPE_MAILBOX))
return;
- Player* pl = _player;
+ Player* player = _player;
- Mail* m = pl->GetMail(mailId);
+ Mail* m = player->GetMail(mailId);
if (!m || m->state == MAIL_STATE_DELETED || m->deliver_time > time(NULL))
{
- pl->SendMailResult(mailId, MAIL_MONEY_TAKEN, MAIL_ERR_INTERNAL_ERROR);
+ player->SendMailResult(mailId, MAIL_MONEY_TAKEN, MAIL_ERR_INTERNAL_ERROR);
return;
}
- pl->SendMailResult(mailId, MAIL_MONEY_TAKEN, MAIL_OK);
+ player->SendMailResult(mailId, MAIL_MONEY_TAKEN, MAIL_OK);
- pl->ModifyMoney(m->money);
+ player->ModifyMoney(m->money);
m->money = 0;
m->state = MAIL_STATE_CHANGED;
- pl->m_mailsUpdated = true;
+ player->m_mailsUpdated = true;
// save money and mail to prevent cheating
SQLTransaction trans = CharacterDatabase.BeginTransaction();
- pl->SaveGoldToDB(trans);
- pl->_SaveMail(trans);
+ player->SaveGoldToDB(trans);
+ player->_SaveMail(trans);
CharacterDatabase.CommitTransaction(trans);
}
@@ -533,11 +533,11 @@ void WorldSession::HandleGetMailList(WorldPacket & recv_data)
if (!GetPlayer()->GetGameObjectIfCanInteractWith(mailbox, GAMEOBJECT_TYPE_MAILBOX))
return;
- Player* pl = _player;
+ Player* player = _player;
//load players mails, and mailed items
- if (!pl->m_mailsLoaded)
- pl ->_LoadMail();
+ if (!player->m_mailsLoaded)
+ player ->_LoadMail();
// client can't work with packets > max int16 value
const uint32 maxPacketSize = 32767;
@@ -550,7 +550,7 @@ void WorldSession::HandleGetMailList(WorldPacket & recv_data)
data << uint8(0); // mail's count
time_t cur_time = time(NULL);
- for (PlayerMails::iterator itr = pl->GetMailBegin(); itr != pl->GetMailEnd(); ++itr)
+ for (PlayerMails::iterator itr = player->GetMailBegin(); itr != player->GetMailEnd(); ++itr)
{
// packet send mail count as uint8, prevent overflow
if (mailsCount >= 254)
@@ -596,16 +596,16 @@ void WorldSession::HandleGetMailList(WorldPacket & recv_data)
data << uint32(0); // probably changed in 3.3.3
data << uint32((*itr)->stationery); // stationery (Stationery.dbc)
data << uint32((*itr)->money); // Gold
- data << uint32((*itr)->checked); // flags
+ data << uint32((*itr)->checked); // flags
data << float(((*itr)->expire_time-time(NULL))/DAY); // Time
data << uint32((*itr)->mailTemplateId); // mail template (MailTemplate.dbc)
- data << (*itr)->subject; // Subject string - once 00, when mail type = 3, max 256
- data << (*itr)->body; // message? max 8000
+ data << (*itr)->subject; // Subject string - once 00, when mail type = 3, max 256
+ data << (*itr)->body; // message? max 8000
data << uint8(item_count); // client limit is 0x10
for (uint8 i = 0; i < item_count; ++i)
{
- Item* item = pl->GetMItem((*itr)->items[i].item_guid);
+ Item* item = player->GetMItem((*itr)->items[i].item_guid);
// item index (0-6?)
data << uint8(i);
// item guid low?
@@ -658,17 +658,17 @@ void WorldSession::HandleMailCreateTextItem(WorldPacket & recv_data)
if (!GetPlayer()->GetGameObjectIfCanInteractWith(mailbox, GAMEOBJECT_TYPE_MAILBOX))
return;
- Player* pl = _player;
+ Player* player = _player;
- Mail* m = pl->GetMail(mailId);
+ Mail* m = player->GetMail(mailId);
if (!m || (m->body.empty() && !m->mailTemplateId) || m->state == MAIL_STATE_DELETED || m->deliver_time > time(NULL))
{
- pl->SendMailResult(mailId, MAIL_MADE_PERMANENT, MAIL_ERR_INTERNAL_ERROR);
+ player->SendMailResult(mailId, MAIL_MADE_PERMANENT, MAIL_ERR_INTERNAL_ERROR);
return;
}
Item* bodyItem = new Item; // This is not bag and then can be used new Item.
- if (!bodyItem->Create(sObjectMgr->GenerateLowGuid(HIGHGUID_ITEM), MAIL_BODY_ITEM_TEMPLATE, pl))
+ if (!bodyItem->Create(sObjectMgr->GenerateLowGuid(HIGHGUID_ITEM), MAIL_BODY_ITEM_TEMPLATE, player))
{
delete bodyItem;
return;
@@ -680,7 +680,7 @@ void WorldSession::HandleMailCreateTextItem(WorldPacket & recv_data)
MailTemplateEntry const* mailTemplateEntry = sMailTemplateStore.LookupEntry(m->mailTemplateId);
if (!mailTemplateEntry)
{
- pl->SendMailResult(mailId, MAIL_MADE_PERMANENT, MAIL_ERR_INTERNAL_ERROR);
+ player->SendMailResult(mailId, MAIL_MADE_PERMANENT, MAIL_ERR_INTERNAL_ERROR);
return;
}
@@ -700,14 +700,14 @@ void WorldSession::HandleMailCreateTextItem(WorldPacket & recv_data)
{
m->checked = m->checked | MAIL_CHECK_MASK_COPIED;
m->state = MAIL_STATE_CHANGED;
- pl->m_mailsUpdated = true;
+ player->m_mailsUpdated = true;
- pl->StoreItem(dest, bodyItem, true);
- pl->SendMailResult(mailId, MAIL_MADE_PERMANENT, MAIL_OK);
+ player->StoreItem(dest, bodyItem, true);
+ player->SendMailResult(mailId, MAIL_MADE_PERMANENT, MAIL_OK);
}
else
{
- pl->SendMailResult(mailId, MAIL_MADE_PERMANENT, MAIL_ERR_EQUIP_ERROR, msg);
+ player->SendMailResult(mailId, MAIL_MADE_PERMANENT, MAIL_ERR_EQUIP_ERROR, msg);
delete bodyItem;
}
}
diff --git a/src/server/game/Server/Protocol/Handlers/MiscHandler.cpp b/src/server/game/Server/Protocol/Handlers/MiscHandler.cpp
index 1b0cef69c04..7327cdbba65 100755
--- a/src/server/game/Server/Protocol/Handlers/MiscHandler.cpp
+++ b/src/server/game/Server/Protocol/Handlers/MiscHandler.cpp
@@ -239,8 +239,8 @@ void WorldSession::HandleWhoOpcode(WorldPacket & recv_data)
data << uint32(matchcount); // placeholder, count of players matching criteria
data << uint32(displaycount); // placeholder, count of players displayed
- ACE_GUARD(ACE_Thread_Mutex, g, *HashMapHolder<Player>::GetLock());
- HashMapHolder<Player>::MapType& m = sObjectAccessor->GetPlayers();
+ TRINITY_READ_GUARD(HashMapHolder<Player>::LockType, *HashMapHolder<Player>::GetLock());
+ HashMapHolder<Player>::MapType const& m = sObjectAccessor->GetPlayers();
for (HashMapHolder<Player>::MapType::const_iterator itr = m.begin(); itr != m.end(); ++itr)
{
if (AccountMgr::IsPlayerAccount(security))
@@ -339,12 +339,6 @@ void WorldSession::HandleWhoOpcode(WorldPacket & recv_data)
if ((matchcount++) >= sWorld->getIntConfig(CONFIG_MAX_WHO))
continue;
- if (itr->second->isGameMaster())
- {
- pname = "<GM>";
- pname.append(itr->second->GetName());
- }
-
data << pname; // player name
data << gname; // guild name
data << uint32(lvl); // player level
@@ -1196,18 +1190,18 @@ void WorldSession::HandleInspectOpcode(WorldPacket& recv_data)
_player->SetSelection(guid);
- Player* plr = ObjectAccessor::FindPlayer(guid);
- if (!plr) // wrong player
+ Player* player = ObjectAccessor::FindPlayer(guid);
+ if (!player) // wrong player
return;
uint32 talent_points = 0x47;
- uint32 guid_size = plr->GetPackGUID().wpos();
+ uint32 guid_size = player->GetPackGUID().wpos();
WorldPacket data(SMSG_INSPECT_TALENT, guid_size+4+talent_points);
- data.append(plr->GetPackGUID());
+ data.append(player->GetPackGUID());
if (sWorld->getBoolConfig(CONFIG_TALENTS_INSPECTING) || _player->isGameMaster())
{
- plr->BuildPlayerTalentsInfoData(&data);
+ player->BuildPlayerTalentsInfoData(&data);
}
else
{
@@ -1216,7 +1210,7 @@ void WorldSession::HandleInspectOpcode(WorldPacket& recv_data)
data << uint8(0); // talentGroupIndex
}
- plr->BuildEnchantmentsInfoData(&data);
+ player->BuildEnchantmentsInfoData(&data);
SendPacket(&data);
}
@@ -1297,15 +1291,15 @@ void WorldSession::HandleWhoisOpcode(WorldPacket& recv_data)
return;
}
- Player* plr = sObjectAccessor->FindPlayerByName(charname.c_str());
+ Player* player = sObjectAccessor->FindPlayerByName(charname.c_str());
- if (!plr)
+ if (!player)
{
SendNotification(LANG_PLAYER_NOT_EXIST_OR_OFFLINE, charname.c_str());
return;
}
- uint32 accid = plr->GetSession()->GetAccountId();
+ uint32 accid = player->GetSession()->GetAccountId();
QueryResult result = LoginDatabase.PQuery("SELECT username, email, last_ip FROM account WHERE id=%u", accid);
if (!result)
diff --git a/src/server/game/Server/Protocol/Handlers/MovementHandler.cpp b/src/server/game/Server/Protocol/Handlers/MovementHandler.cpp
index d343e1b2dae..4e45eb2d6c6 100755
--- a/src/server/game/Server/Protocol/Handlers/MovementHandler.cpp
+++ b/src/server/game/Server/Protocol/Handlers/MovementHandler.cpp
@@ -68,11 +68,11 @@ void WorldSession::HandleMoveWorldportAckOpcode()
if (GetPlayer()->IsInWorld())
{
sLog->outCrash("Player (Name %s) is still in world when teleported from map %u to new map %u", GetPlayer()->GetName(), oldMap->GetId(), loc.GetMapId());
- oldMap->RemoveFromMap(GetPlayer(), false);
+ oldMap->RemovePlayerFromMap(GetPlayer(), false);
}
// relocate the player to the teleport destination
- Map* newMap = sMapMgr->CreateMap(loc.GetMapId(), GetPlayer(), 0);
+ Map* newMap = sMapMgr->CreateMap(loc.GetMapId(), GetPlayer());
// the CanEnter checks are done in TeleporTo but conditions may change
// while the player is in transit, for example the map may get full
if (!newMap || !newMap->CanEnter(GetPlayer()))
@@ -88,7 +88,7 @@ void WorldSession::HandleMoveWorldportAckOpcode()
GetPlayer()->SetMap(newMap);
GetPlayer()->SendInitialPacketsBeforeAddToMap();
- if (!GetPlayer()->GetMap()->AddToMap(GetPlayer()))
+ if (!GetPlayer()->GetMap()->AddPlayerToMap(GetPlayer()))
{
sLog->outError("WORLD: failed to teleport player %s (%d) to map %d because of unknown reason!", GetPlayer()->GetName(), GetPlayer()->GetGUIDLow(), loc.GetMapId());
GetPlayer()->ResetMap();
@@ -373,7 +373,7 @@ void WorldSession::HandleMovementOpcodes(WorldPacket & recv_data)
if (plMover->isAlive())
{
plMover->EnvironmentalDamage(DAMAGE_FALL_TO_VOID, GetPlayer()->GetMaxHealth());
- // pl can be alive if GM/etc
+ // player can be alive if GM/etc
// change the death state to CORPSE to prevent the death timer from
// starting in the next player update
if (!plMover->isAlive())
diff --git a/src/server/game/Server/Protocol/Handlers/QueryHandler.cpp b/src/server/game/Server/Protocol/Handlers/QueryHandler.cpp
index 9277464ca21..bf951619e63 100755
--- a/src/server/game/Server/Protocol/Handlers/QueryHandler.cpp
+++ b/src/server/game/Server/Protocol/Handlers/QueryHandler.cpp
@@ -379,8 +379,8 @@ void WorldSession::HandlePageTextQueryOpcode(WorldPacket & recv_data)
int loc_idx = GetSessionDbLocaleIndex();
if (loc_idx >= 0)
- if (PageTextLocale const* pl = sObjectMgr->GetPageTextLocale(pageID))
- ObjectMgr::GetLocaleString(pl->Text, loc_idx, Text);
+ if (PageTextLocale const* player = sObjectMgr->GetPageTextLocale(pageID))
+ ObjectMgr::GetLocaleString(player->Text, loc_idx, Text);
data << Text;
data << uint32(pageText->NextPage);
diff --git a/src/server/game/Server/Protocol/Handlers/QuestHandler.cpp b/src/server/game/Server/Protocol/Handlers/QuestHandler.cpp
index fbd6c23d20f..e0bcadc89e9 100755
--- a/src/server/game/Server/Protocol/Handlers/QuestHandler.cpp
+++ b/src/server/game/Server/Protocol/Handlers/QuestHandler.cpp
@@ -200,7 +200,7 @@ void WorldSession::HandleQuestgiverAcceptQuestOpcode(WorldPacket & recv_data)
bool destroyItem = true;
for (int i = 0; i < QUEST_ITEM_OBJECTIVES_COUNT; ++i)
{
- if ((qInfo->ReqItemId[i] == ((Item*)pObject)->GetEntry()) && (((Item*)pObject)->GetTemplate()->MaxCount > 0))
+ if ((qInfo->RequiredItemId[i] == ((Item*)pObject)->GetEntry()) && (((Item*)pObject)->GetTemplate()->MaxCount > 0))
{
destroyItem = false;
break;
diff --git a/src/server/game/Server/Protocol/Handlers/VehicleHandler.cpp b/src/server/game/Server/Protocol/Handlers/VehicleHandler.cpp
index 7187241cc3a..256f8b327ff 100644
--- a/src/server/game/Server/Protocol/Handlers/VehicleHandler.cpp
+++ b/src/server/game/Server/Protocol/Handlers/VehicleHandler.cpp
@@ -129,16 +129,16 @@ void WorldSession::HandleEnterPlayerVehicle(WorldPacket &data)
uint64 guid;
data >> guid;
- if (Player* pl = ObjectAccessor::FindPlayer(guid))
+ if (Player* player = ObjectAccessor::FindPlayer(guid))
{
- if (!pl->GetVehicleKit())
+ if (!player->GetVehicleKit())
return;
- if (!pl->IsInRaidWith(_player))
+ if (!player->IsInRaidWith(_player))
return;
- if (!pl->IsWithinDistInMap(_player, INTERACTION_DISTANCE))
+ if (!player->IsWithinDistInMap(_player, INTERACTION_DISTANCE))
return;
- _player->EnterVehicle(pl);
+ _player->EnterVehicle(player);
}
}
@@ -157,23 +157,23 @@ void WorldSession::HandleEjectPassenger(WorldPacket &data)
if (IS_PLAYER_GUID(guid))
{
- Player* plr = ObjectAccessor::FindPlayer(guid);
- if (!plr)
+ Player* player = ObjectAccessor::FindPlayer(guid);
+ if (!player)
{
sLog->outError("Player %u tried to eject player %u from vehicle, but the latter was not found in world!", GetPlayer()->GetGUIDLow(), GUID_LOPART(guid));
return;
}
- if (!plr->IsOnVehicle(vehicle->GetBase()))
+ if (!player->IsOnVehicle(vehicle->GetBase()))
{
sLog->outError("Player %u tried to eject player %u, but they are not in the same vehicle", GetPlayer()->GetGUIDLow(), GUID_LOPART(guid));
return;
}
- VehicleSeatEntry const* seat = vehicle->GetSeatForPassenger(plr);
+ VehicleSeatEntry const* seat = vehicle->GetSeatForPassenger(player);
ASSERT(seat);
if (seat->IsEjectable())
- plr->ExitVehicle();
+ player->ExitVehicle();
else
sLog->outError("Player %u attempted to eject player %u from non-ejectable seat.", GetPlayer()->GetGUIDLow(), GUID_LOPART(guid));
}
diff --git a/src/server/game/Server/Protocol/Opcodes.cpp b/src/server/game/Server/Protocol/Opcodes.cpp
index df7816f7cb9..311a94d4217 100755
--- a/src/server/game/Server/Protocol/Opcodes.cpp
+++ b/src/server/game/Server/Protocol/Opcodes.cpp
@@ -1329,7 +1329,7 @@ OpcodeHandler opcodeTable[NUM_MSG_TYPES] =
/*0x514*/ { "SMSG_SEND_ALL_COMBAT_LOG", STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_ServerSide },
/*0x515*/ { "SMSG_OPEN_LFG_DUNGEON_FINDER", STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_ServerSide },
/*0x516*/ { "SMSG_MOVE_SET_COLLISION_HGT", STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_ServerSide },
- /*0x517*/ { "CMSG_MOVE_SET_COLLISION_HGT_ACK", STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_NULL },
+ /*0x517*/ { "CMSG_MOVE_SET_COLLISION_HGT_ACK", STATUS_UNHANDLED, PROCESS_INPLACE, &WorldSession::Handle_NULL },
/*0x518*/ { "MSG_MOVE_SET_COLLISION_HGT", STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_NULL },
/*0x519*/ { "CMSG_CLEAR_RANDOM_BG_WIN_TIME", STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_NULL },
/*0x51A*/ { "CMSG_CLEAR_HOLIDAY_BG_WIN_TIME", STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_NULL },
diff --git a/src/server/game/Server/Protocol/WorldLog.cpp b/src/server/game/Server/Protocol/WorldLog.cpp
index 579e4363253..334c189af81 100755
--- a/src/server/game/Server/Protocol/WorldLog.cpp
+++ b/src/server/game/Server/Protocol/WorldLog.cpp
@@ -61,7 +61,7 @@ void WorldLog::outTimestampLog(char const* fmt, ...)
{
if (LogWorld())
{
- ACE_GUARD(ACE_Thread_Mutex, Guard, Lock);
+ TRINITY_GUARD(ACE_Thread_Mutex, Lock);
ASSERT(i_file);
Log::outTimestamp(i_file);
@@ -89,7 +89,7 @@ void WorldLog::outLog(char const* fmt, ...)
{
if (LogWorld())
{
- ACE_GUARD(ACE_Thread_Mutex, Guard, Lock);
+ TRINITY_GUARD(ACE_Thread_Mutex, Lock);
ASSERT(i_file);
va_list args;
diff --git a/src/server/game/Server/WorldSession.cpp b/src/server/game/Server/WorldSession.cpp
index 9cb2b1cbe3f..14c86286718 100755
--- a/src/server/game/Server/WorldSession.cpp
+++ b/src/server/game/Server/WorldSession.cpp
@@ -55,12 +55,12 @@ bool MapSessionFilter::Process(WorldPacket* packet)
if (opHandle.packetProcessing == PROCESS_THREADUNSAFE)
return false;
- Player* plr = m_pSession->GetPlayer();
- if (!plr)
+ Player* player = m_pSession->GetPlayer();
+ if (!player)
return false;
//in Map::Update() we do not process packets where player is not in world!
- return plr->IsInWorld();
+ return player->IsInWorld();
}
//we should process ALL packets when player is not in world/logged in
@@ -77,12 +77,12 @@ bool WorldSessionFilter::Process(WorldPacket* packet)
return true;
//no player attached? -> our client! ^^
- Player* plr = m_pSession->GetPlayer();
- if (!plr)
+ Player* player = m_pSession->GetPlayer();
+ if (!player)
return true;
//lets process all packets for non-in-the-world player
- return (plr->IsInWorld() == false);
+ return (player->IsInWorld() == false);
}
/// WorldSession constructor
@@ -494,7 +494,7 @@ void WorldSession::LogoutPlayer(bool Save)
_player->CleanupsBeforeDelete();
sLog->outChar("Account: %d (IP: %s) Logout Character:[%s] (GUID: %u)", GetAccountId(), GetRemoteAddress().c_str(), _player->GetName(), _player->GetGUIDLow());
Map* _map = _player->GetMap();
- _map->RemoveFromMap(_player, true);
+ _map->RemovePlayerFromMap(_player, true);
SetPlayer(NULL); // deleted in Remove call
///- Send the 'logout complete' packet to the client
@@ -964,9 +964,9 @@ void WorldSession::SendAddonsInfo()
SendPacket(&data);
}
-void WorldSession::SetPlayer(Player* plr)
+void WorldSession::SetPlayer(Player* player)
{
- _player = plr;
+ _player = player;
// set m_GUID that can be used while player loggined and later until m_playerRecentlyLogout not reset
if (_player)
@@ -999,6 +999,7 @@ void WorldSession::ProcessQueryCallbacks()
HandleCharCreateCallback(pResult, _charCreateCallback.GetParam());
// Don't call FreeResult() here, the callback handler will do that depending on the events in the callback chain
}
+
//! HandlePlayerLoginOpcode
if (_charLoginCallback.ready())
{
diff --git a/src/server/game/Server/WorldSession.h b/src/server/game/Server/WorldSession.h
index 2337f2a34b2..4a83c2d4092 100755
--- a/src/server/game/Server/WorldSession.h
+++ b/src/server/game/Server/WorldSession.h
@@ -223,10 +223,10 @@ class WorldSession
void SizeError(WorldPacket const& packet, uint32 size) const;
- void ReadAddonsInfo(WorldPacket &data);
+ void ReadAddonsInfo(WorldPacket& data);
void SendAddonsInfo();
- void ReadMovementInfo(WorldPacket &data, MovementInfo* mi);
+ void ReadMovementInfo(WorldPacket& data, MovementInfo* mi);
void WriteMovementInfo(WorldPacket* data, MovementInfo* mi);
void SendPacket(WorldPacket const* packet);
@@ -247,7 +247,7 @@ class WorldSession
char const* GetPlayerName() const;
void SetSecurity(AccountTypes security) { _security = security; }
std::string const& GetRemoteAddress() { return m_Address; }
- void SetPlayer(Player* plr);
+ void SetPlayer(Player* player);
uint8 Expansion() const { return m_expansion; }
/// Session in auth.queue currently
@@ -282,7 +282,7 @@ class WorldSession
void SendTrainerList(uint64 guid);
void SendTrainerList(uint64 guid, const std::string& strTitle);
- void SendListInventory(uint64 vendorGuid);
+ void SendListInventory(uint64 guid);
void SendShowBank(uint64 guid);
void SendTabardVendorActivate(uint64 guid);
void SendSpiritResurrect();
@@ -381,9 +381,7 @@ class WorldSession
}
bool IsConnectionIdle() const
{
- if (m_timeOutTime <= 0 && !m_inQueue)
- return true;
- return false;
+ return (m_timeOutTime <= 0 && !m_inQueue);
}
// Recruit-A-Friend Handling
@@ -421,11 +419,11 @@ class WorldSession
void HandleInspectHonorStatsOpcode(WorldPacket& recvPacket);
void HandleMoveWaterWalkAck(WorldPacket& recvPacket);
- void HandleFeatherFallAck(WorldPacket &recv_data);
+ void HandleFeatherFallAck(WorldPacket& recv_data);
- void HandleMoveHoverAck(WorldPacket & recv_data);
+ void HandleMoveHoverAck(WorldPacket& recv_data);
- void HandleMountSpecialAnimOpcode(WorldPacket &recvdata);
+ void HandleMountSpecialAnimOpcode(WorldPacket& recvdata);
// character view
void HandleShowingHelmOpcode(WorldPacket& recv_data);
@@ -438,7 +436,7 @@ class WorldSession
void HandleMoveKnockBackAck(WorldPacket& recvPacket);
void HandleMoveTeleportAck(WorldPacket& recvPacket);
- void HandleForceSpeedChangeAck(WorldPacket & recv_data);
+ void HandleForceSpeedChangeAck(WorldPacket& recv_data);
void HandlePingOpcode(WorldPacket& recvPacket);
void HandleAuthSessionOpcode(WorldPacket& recvPacket);
@@ -483,10 +481,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& recv_data);
+ void HandleSetFactionCheat(WorldPacket& recv_data);
+ void HandleSetWatchedFactionOpcode(WorldPacket& recv_data);
+ void HandleSetFactionInactiveOpcode(WorldPacket& recv_data);
void HandleUpdateAccountData(WorldPacket& recvPacket);
void HandleRequestAccountData(WorldPacket& recvPacket);
@@ -507,17 +505,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& 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 HandleRequestRaidInfoOpcode(WorldPacket & recv_data);
+ void HandleRequestRaidInfoOpcode(WorldPacket& recv_data);
- void HandleBattlefieldStatusOpcode(WorldPacket &recv_data);
- void HandleBattleMasterHelloOpcode(WorldPacket &recv_data);
+ void HandleBattlefieldStatusOpcode(WorldPacket& recv_data);
+ void HandleBattleMasterHelloOpcode(WorldPacket& recv_data);
void HandleGroupInviteOpcode(WorldPacket& recvPacket);
//void HandleGroupCancelOpcode(WorldPacket& recvPacket);
@@ -527,17 +525,17 @@ class WorldSession
void HandleGroupUninviteGuidOpcode(WorldPacket& recvPacket);
void HandleGroupSetLeaderOpcode(WorldPacket& recvPacket);
void HandleGroupDisbandOpcode(WorldPacket& recvPacket);
- void HandleOptOutOfLootOpcode(WorldPacket &recv_data);
+ void HandleOptOutOfLootOpcode(WorldPacket& recv_data);
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 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);
@@ -613,25 +611,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& 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 SendItemPageInfo(ItemTemplate* itemProto);
void HandleSplitItemOpcode(WorldPacket& recvPacket);
@@ -645,9 +643,9 @@ class WorldSession
void HandleListInventoryOpcode(WorldPacket& recvPacket);
void HandleAutoStoreBagItemOpcode(WorldPacket& recvPacket);
void HandleReadItem(WorldPacket& recvPacket);
- void HandleAutoEquipItemSlotOpcode(WorldPacket & recvPacket);
- void HandleSwapItem(WorldPacket & recvPacket);
- void HandleBuybackItem(WorldPacket & recvPacket);
+ void HandleAutoEquipItemSlotOpcode(WorldPacket& recvPacket);
+ void HandleSwapItem(WorldPacket& recvPacket);
+ void HandleBuybackItem(WorldPacket& recvPacket);
void HandleAutoBankItemOpcode(WorldPacket& recvPacket);
void HandleAutoStoreBankItemOpcode(WorldPacket& recvPacket);
void HandleWrapItemOpcode(WorldPacket& recvPacket);
@@ -728,18 +726,18 @@ 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& recv_data);
+ void HandleTutorialClear(WorldPacket& recv_data);
+ void HandleTutorialReset(WorldPacket& recv_data);
//Pet
- void HandlePetAction(WorldPacket & recv_data);
+ void HandlePetAction(WorldPacket& recv_data);
void HandlePetStopAttack(WorldPacket& recv_data);
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& recv_data);
+ void HandlePetSetAction(WorldPacket& recv_data);
+ void HandlePetAbandon(WorldPacket& recv_data);
+ void HandlePetRename(WorldPacket& recv_data);
void HandlePetCancelAuraOpcode(WorldPacket& recvPacket);
void HandlePetSpellAutocastOpcode(WorldPacket& recvPacket);
void HandlePetCastSpellOpcode(WorldPacket& recvPacket);
@@ -756,15 +754,15 @@ class WorldSession
void HandleDismissCritter(WorldPacket& recv_data);
//Battleground
- void HandleBattlemasterHelloOpcode(WorldPacket &recv_data);
- void HandleBattlemasterJoinOpcode(WorldPacket &recv_data);
+ 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 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);
@@ -783,17 +781,17 @@ class WorldSession
void HandleInstanceLockResponse(WorldPacket& recvPacket);
// Looking for Dungeon/Raid
- void HandleLfgSetCommentOpcode(WorldPacket & recv_data);
+ 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 HandleLfrSearchOpcode(WorldPacket &recv_data);
- void HandleLfrLeaveOpcode(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 HandleLfrSearchOpcode(WorldPacket& recv_data);
+ void HandleLfrLeaveOpcode(WorldPacket& recv_data);
void SendLfgUpdatePlayer(const LfgUpdateData& updateData);
void SendLfgUpdateParty(const LfgUpdateData& updateData);
@@ -836,7 +834,7 @@ class WorldSession
void HandleItemRefundInfoRequest(WorldPacket& recv_data);
void HandleItemRefund(WorldPacket& recv_data);
- void HandleChannelVoiceOnOpcode(WorldPacket & recv_data);
+ void HandleChannelVoiceOnOpcode(WorldPacket& recv_data);
void HandleVoiceSessionEnableOpcode(WorldPacket& recv_data);
void HandleSetActiveVoiceChannel(WorldPacket& recv_data);
void HandleSetTaxiBenchmarkOpcode(WorldPacket& recv_data);
@@ -878,7 +876,7 @@ class WorldSession
void HandleCalendarGetNumPending(WorldPacket& recv_data);
void HandleSpellClick(WorldPacket& recv_data);
- void HandleMirrorImageDataRequest(WorldPacket & recv_data);
+ void HandleMirrorImageDataRequest(WorldPacket& recv_data);
void HandleAlterAppearance(WorldPacket& recv_data);
void HandleRemoveGlyph(WorldPacket& recv_data);
void HandleCharCustomize(WorldPacket& recv_data);
@@ -890,8 +888,8 @@ class WorldSession
void HandleReadyForAccountDataTimes(WorldPacket& recv_data);
void HandleQueryQuestsCompleted(WorldPacket& recv_data);
void HandleQuestPOIQuery(WorldPacket& recv_data);
- void HandleEjectPassenger(WorldPacket &data);
- void HandleEnterPlayerVehicle(WorldPacket &data);
+ void HandleEjectPassenger(WorldPacket& data);
+ void HandleEnterPlayerVehicle(WorldPacket& data);
void HandleUpdateProjectilePosition(WorldPacket& recvPacket);
private:
diff --git a/src/server/game/Server/WorldSocket.cpp b/src/server/game/Server/WorldSocket.cpp
index 3875156289e..0ddc03e3d5c 100755
--- a/src/server/game/Server/WorldSocket.cpp
+++ b/src/server/game/Server/WorldSocket.cpp
@@ -802,7 +802,7 @@ int WorldSocket::HandleAuthSession (WorldPacket& recvPacket)
recvPacket >> clientSeed;
recvPacket >> unk5 >> unk6 >> unk7;
recvPacket >> unk4;
- recvPacket.read (digest, 20);
+ recvPacket.read(digest, 20);
sLog->outStaticDebug ("WorldSocket::HandleAuthSession: client %u, unk2 %u, account %s, unk3 %u, clientseed %u",
BuiltNumberClient,
diff --git a/src/server/game/Server/WorldSocketMgr.cpp b/src/server/game/Server/WorldSocketMgr.cpp
index ec29273d6b0..5fb66524976 100755
--- a/src/server/game/Server/WorldSocketMgr.cpp
+++ b/src/server/game/Server/WorldSocketMgr.cpp
@@ -109,7 +109,7 @@ class ReactorRunnable : protected ACE_Task_Base
int AddSocket (WorldSocket* sock)
{
- ACE_GUARD_RETURN (ACE_Thread_Mutex, Guard, m_NewSockets_Lock, -1);
+ TRINITY_GUARD(ACE_Thread_Mutex, m_NewSockets_Lock);
++m_Connections;
sock->AddReference();
@@ -130,7 +130,7 @@ class ReactorRunnable : protected ACE_Task_Base
void AddNewSockets()
{
- ACE_GUARD (ACE_Thread_Mutex, Guard, m_NewSockets_Lock);
+ TRINITY_GUARD(ACE_Thread_Mutex, m_NewSockets_Lock);
if (m_NewSockets.empty())
return;
@@ -192,7 +192,7 @@ class ReactorRunnable : protected ACE_Task_Base
}
}
- sLog->outStaticDebug ("Network Thread Exitting");
+ sLog->outStaticDebug ("Network Thread exits");
return 0;
}
diff --git a/src/server/game/Spells/Auras/SpellAuraEffects.cpp b/src/server/game/Spells/Auras/SpellAuraEffects.cpp
index e8906d718dc..c4487fbd950 100755
--- a/src/server/game/Spells/Auras/SpellAuraEffects.cpp
+++ b/src/server/game/Spells/Auras/SpellAuraEffects.cpp
@@ -563,10 +563,10 @@ int32 AuraEffect::CalculateAmount(Unit* caster)
amount += (int32)DoneActualBenefit;
// Arena - Dampening
- if (AuraEffect const* pAurEff = caster->GetAuraEffect(74410, 0))
- AddPctN(amount, pAurEff->GetAmount());
- // Battleground - Dampening
- else if (AuraEffect const* pAurEff = caster->GetAuraEffect(74411, 0))
+ AuraEffect const* pAurEff = caster->GetAuraEffect(74410, 0);
+ if (!pAurEff)
+ pAurEff = caster->GetAuraEffect(74411, 0); // Battleground - Dampening
+ if (pAurEff)
AddPctN(amount, pAurEff->GetAmount());
return amount;
@@ -719,7 +719,7 @@ int32 AuraEffect::CalculateAmount(Unit* caster)
case SPELL_AURA_MOD_THREAT:
{
uint8 level_diff = 0;
- float multiplier = 0.0;
+ float multiplier = 0.0f;
switch (GetId())
{
// Arcane Shroud
@@ -1508,15 +1508,15 @@ void AuraEffect::HandleShapeshiftBoosts(Unit* target, bool apply) const
// Nurturing Instinct
if (AuraEffect const* aurEff = target->GetAuraEffect(SPELL_AURA_MOD_SPELL_HEALING_OF_STAT_PERCENT, SPELLFAMILY_DRUID, 2254, 0))
{
- uint32 spellId = 0;
+ uint32 spellId3 = 0;
switch (aurEff->GetId())
{
- case 33872:
- spellId = 47179;
- break;
- case 33873:
- spellId = 47180;
- break;
+ case 33872:
+ spellId3 = 47179;
+ break;
+ case 33873:
+ spellId3 = 47180;
+ break;
}
target->CastSpell(target, spellId, true, NULL, this);
}
@@ -1569,9 +1569,9 @@ void AuraEffect::HandleShapeshiftBoosts(Unit* target, bool apply) const
target->RemoveAurasDueToSpell(spellId2);
// Improved Barkskin - apply/remove armor bonus due to shapeshift
- if (Player* pl=target->ToPlayer())
+ if (Player* player=target->ToPlayer())
{
- if (pl->HasSpell(63410) || pl->HasSpell(63411))
+ if (player->HasSpell(63410) || player->HasSpell(63411))
{
target->RemoveAurasDueToSpell(66530);
target->CastSpell(target, 66530, true);
@@ -2847,7 +2847,7 @@ void AuraEffect::HandleAuraAllowFlight(AuraApplication const* aurApp, uint8 mode
if (target->GetTypeId() == TYPEID_UNIT)
target->SetFlying(apply);
- if (Player* plr = target->m_movedPlayer)
+ if (Player* player = target->m_movedPlayer)
{
// allow flying
WorldPacket data;
@@ -2857,7 +2857,7 @@ void AuraEffect::HandleAuraAllowFlight(AuraApplication const* aurApp, uint8 mode
data.Initialize(SMSG_MOVE_UNSET_CAN_FLY, 12);
data.append(target->GetPackGUID());
data << uint32(0); // unk
- plr->SendDirectMessage(&data);
+ player->SendDirectMessage(&data);
}
}
@@ -3246,16 +3246,16 @@ void AuraEffect::HandleAuraModIncreaseFlightSpeed(AuraApplication const* aurApp,
// do not remove unit flag if there are more than this auraEffect of that kind on unit on unit
if (mode & AURA_EFFECT_HANDLE_SEND_FOR_CLIENT_MASK && (apply || (!target->HasAuraType(SPELL_AURA_MOD_INCREASE_MOUNTED_FLIGHT_SPEED) && !target->HasAuraType(SPELL_AURA_FLY))))
{
- if (Player* plr = target->m_movedPlayer)
+ if (Player* player = target->m_movedPlayer)
{
WorldPacket data;
if (apply)
data.Initialize(SMSG_MOVE_SET_CAN_FLY, 12);
else
data.Initialize(SMSG_MOVE_UNSET_CAN_FLY, 12);
- data.append(plr->GetPackGUID());
+ data.append(player->GetPackGUID());
data << uint32(0); // unknown
- plr->SendDirectMessage(&data);
+ player->SendDirectMessage(&data);
}
}
@@ -4892,8 +4892,8 @@ void AuraEffect::HandleAuraDummy(AuraApplication const* aurApp, uint8 mode, bool
// Living Bomb
if (m_spellInfo->SpellFamilyFlags[1] & 0x20000)
{
- AuraRemoveMode mode = aurApp->GetRemoveMode();
- if (caster && (mode == AURA_REMOVE_BY_ENEMY_SPELL || mode == AURA_REMOVE_BY_EXPIRE))
+ AuraRemoveMode removeMode = aurApp->GetRemoveMode();
+ if (caster && (removeMode == AURA_REMOVE_BY_ENEMY_SPELL || removeMode == AURA_REMOVE_BY_EXPIRE))
caster->CastSpell(target, GetAmount(), true);
}
break;
@@ -5394,9 +5394,9 @@ void AuraEffect::HandleAuraConvertRune(AuraApplication const* aurApp, uint8 mode
if (target->GetTypeId() != TYPEID_PLAYER)
return;
- Player* plr = (Player*)target;
+ Player* player = (Player*)target;
- if (plr->getClass() != CLASS_DEATH_KNIGHT)
+ if (player->getClass() != CLASS_DEATH_KNIGHT)
return;
uint32 runes = m_amount;
@@ -5405,17 +5405,17 @@ void AuraEffect::HandleAuraConvertRune(AuraApplication const* aurApp, uint8 mode
{
for (uint32 i = 0; i < MAX_RUNES && runes; ++i)
{
- if (GetMiscValue() != plr->GetCurrentRune(i))
+ if (GetMiscValue() != player->GetCurrentRune(i))
continue;
- if (!plr->GetRuneCooldown(i))
+ if (!player->GetRuneCooldown(i))
{
- plr->AddRuneByAuraEffect(i, RuneType(GetMiscValueB()), this);
+ player->AddRuneByAuraEffect(i, RuneType(GetMiscValueB()), this);
--runes;
}
}
}
else
- plr->RemoveRunesByAuraEffect(this);
+ player->RemoveRunesByAuraEffect(this);
}
void AuraEffect::HandleAuraLinked(AuraApplication const* aurApp, uint8 mode, bool apply) const
@@ -5599,6 +5599,9 @@ void AuraEffect::HandlePeriodicDummyAuraTick(Unit* target, Unit* caster) const
case 66149: // Bullet Controller Periodic - 10 Man
case 68396: // Bullet Controller Periodic - 25 Man
{
+ if (!caster)
+ break;
+
caster->CastCustomSpell(66152, SPELLVALUE_MAX_TARGETS, urand(1, 6), target, true);
caster->CastCustomSpell(66153, SPELLVALUE_MAX_TARGETS, urand(1, 6), target, true);
break;
@@ -5711,9 +5714,8 @@ void AuraEffect::HandlePeriodicDummyAuraTick(Unit* target, Unit* caster) const
// eff_radius == 0
float radius = GetSpellInfo()->GetMaxRange(false);
- CellPair p(Trinity::ComputeCellPair(target->GetPositionX(), target->GetPositionY()));
+ CellCoord p(Trinity::ComputeCellCoord(target->GetPositionX(), target->GetPositionY()));
Cell cell(p);
- cell.data.Part.reserved = ALL_DISTRICT;
Trinity::AnyUnfriendlyAttackableVisibleUnitInObjectRangeCheck u_check(target, radius);
Trinity::UnitListSearcher<Trinity::AnyUnfriendlyAttackableVisibleUnitInObjectRangeCheck> checker(target, targets, u_check);
@@ -6017,13 +6019,15 @@ void AuraEffect::HandlePeriodicTriggerSpellAuraTick(Unit* target, Unit* caster)
case 65923:
{
Unit* permafrostCaster = NULL;
- if (Aura* permafrostAura = target->GetAura(66193))
- permafrostCaster = permafrostAura->GetCaster();
- else if (Aura* permafrostAura = target->GetAura(67855))
- permafrostCaster = permafrostAura->GetCaster();
- else if (Aura* permafrostAura = target->GetAura(67856))
- permafrostCaster = permafrostAura->GetCaster();
- else if (Aura* permafrostAura = target->GetAura(67857))
+ Aura* permafrostAura = target->GetAura(66193);
+ if (!permafrostAura)
+ permafrostAura = target->GetAura(67855);
+ if (!permafrostAura)
+ permafrostAura = target->GetAura(67856);
+ if (!permafrostAura)
+ permafrostAura = target->GetAura(67857);
+
+ if (permafrostAura)
permafrostCaster = permafrostAura->GetCaster();
if (permafrostCaster)
@@ -6459,15 +6463,15 @@ void AuraEffect::HandlePeriodicHealAurasTick(Unit* target, Unit* caster) const
// damage caster for heal amount
if (target != caster && GetSpellInfo()->AttributesEx2 & SPELL_ATTR2_HEALTH_FUNNEL)
{
- uint32 damage = GetSpellInfo()->Effects[EFFECT_0].CalcValue(); // damage is not affected by spell power
- if ((int32)damage > gain)
- damage = gain;
- uint32 absorb = 0;
- caster->DealDamageMods(caster, damage, &absorb);
- caster->SendSpellNonMeleeDamageLog(caster, GetId(), damage, GetSpellInfo()->GetSchoolMask(), absorb, 0, false, 0, false);
+ uint32 funnelDamage = GetSpellInfo()->Effects[EFFECT_0].CalcValue(); // damage is not affected by spell power
+ if ((int32)funnelDamage > gain)
+ funnelDamage = gain;
+ uint32 funnelAbsorb = 0;
+ caster->DealDamageMods(caster, funnelDamage, &funnelAbsorb);
+ caster->SendSpellNonMeleeDamageLog(caster, GetId(), funnelDamage, GetSpellInfo()->GetSchoolMask(), funnelAbsorb, 0, false, 0, false);
CleanDamage cleanDamage = CleanDamage(0, 0, BASE_ATTACK, MELEE_HIT_NORMAL);
- caster->DealDamage(caster, damage, &cleanDamage, NODAMAGE, GetSpellInfo()->GetSchoolMask(), GetSpellInfo(), true);
+ caster->DealDamage(caster, funnelDamage, &cleanDamage, NODAMAGE, GetSpellInfo()->GetSchoolMask(), GetSpellInfo(), true);
}
uint32 procAttacker = PROC_FLAG_DONE_PERIODIC;
diff --git a/src/server/game/Spells/Auras/SpellAuraEffects.h b/src/server/game/Spells/Auras/SpellAuraEffects.h
index c34391471d7..7f754253719 100644
--- a/src/server/game/Spells/Auras/SpellAuraEffects.h
+++ b/src/server/game/Spells/Auras/SpellAuraEffects.h
@@ -80,6 +80,7 @@ class AuraEffect
bool IsPeriodic() const { return m_isPeriodic; }
void SetPeriodic(bool isPeriodic) { m_isPeriodic = isPeriodic; }
bool IsAffectedOnSpell(SpellInfo const* spell) const;
+ bool HasSpellClassMask() const { return m_spellInfo->Effects[m_effIndex].SpellClassMask; }
void SendTickImmune(Unit* target, Unit* caster) const;
void PeriodicTick(AuraApplication * aurApp, Unit* caster) const;
diff --git a/src/server/game/Spells/Auras/SpellAuras.cpp b/src/server/game/Spells/Auras/SpellAuras.cpp
index df6ac44f2cc..525084a70ed 100755
--- a/src/server/game/Spells/Auras/SpellAuras.cpp
+++ b/src/server/game/Spells/Auras/SpellAuras.cpp
@@ -557,7 +557,14 @@ void Aura::UpdateTargetMap(Unit* caster, bool apply)
else
{
// owner has to be in world, or effect has to be applied to self
- ASSERT((!GetOwner()->IsInWorld() && GetOwner() == itr->first) || GetOwner()->IsInMap(itr->first));
+ if (!GetOwner()->IsSelfOrInSameMap(itr->first))
+ {
+ //TODO: There is a crash caused by shadowfiend load addon
+ sLog->outCrash("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));
+ ASSERT(false);
+ }
itr->first->_CreateAuraApplication(this, itr->second);
++itr;
}
diff --git a/src/server/game/Spells/Spell.cpp b/src/server/game/Spells/Spell.cpp
index 16243396ebb..8a4c0a768d8 100755
--- a/src/server/game/Spells/Spell.cpp
+++ b/src/server/game/Spells/Spell.cpp
@@ -598,9 +598,8 @@ WorldObject* Spell::FindCorpseUsing()
// non-standard target selection
float max_range = m_spellInfo->GetMaxRange(false);
- CellPair p(Trinity::ComputeCellPair(m_caster->GetPositionX(), m_caster->GetPositionY()));
+ CellCoord p(Trinity::ComputeCellCoord(m_caster->GetPositionX(), m_caster->GetPositionY()));
Cell cell(p);
- cell.data.Part.reserved = ALL_DISTRICT;
cell.SetNoCreate();
WorldObject* result = NULL;
@@ -642,23 +641,24 @@ void Spell::InitExplicitTargets(SpellCastTargets const& targets)
// try to select correct unit target if not provided by client or by serverside cast
if (neededTargets & (TARGET_FLAG_UNIT_MASK))
{
- Unit* target = NULL;
+ Unit* unit = NULL;
// try to use player selection as a target
if (Player* playerCaster = m_caster->ToPlayer())
{
// selection has to be found and to be valid target for the spell
if (Unit* selectedUnit = ObjectAccessor::GetUnit(*m_caster, playerCaster->GetSelection()))
if (m_spellInfo->CheckExplicitTarget(m_caster, selectedUnit) == SPELL_CAST_OK)
- target = selectedUnit;
+ unit = selectedUnit;
}
// try to use attacked unit as a target
else if ((m_caster->GetTypeId() == TYPEID_UNIT) && neededTargets & (TARGET_FLAG_UNIT_ENEMY | TARGET_FLAG_UNIT))
- target = m_caster->getVictim();
+ unit = m_caster->getVictim();
+
// didn't find anything - let's use self as target
- if (!target && neededTargets & (TARGET_FLAG_UNIT_RAID | TARGET_FLAG_UNIT_PARTY | TARGET_FLAG_UNIT_ALLY))
- target = m_caster;
+ if (!unit && neededTargets & (TARGET_FLAG_UNIT_RAID | TARGET_FLAG_UNIT_PARTY | TARGET_FLAG_UNIT_ALLY))
+ unit = m_caster;
- m_targets.SetUnitTarget(target);
+ m_targets.SetUnitTarget(unit);
}
}
@@ -1202,7 +1202,6 @@ void Spell::DoAllEffectOnTarget(TargetInfo* target)
m_spellAura = NULL; // Set aura to null for every target-make sure that pointer is not used for unit without aura applied
//Spells with this flag cannot trigger if effect is casted on self
- // Slice and Dice, relentless strikes, eviscerate
bool canEffectTrigger = !(m_spellInfo->AttributesEx3 & SPELL_ATTR3_CANT_TRIGGER_PROC) && unitTarget->CanProc() && CanExecuteTriggersOnHit(mask);
Unit* spellHitTarget = NULL;
@@ -1220,11 +1219,11 @@ void Spell::DoAllEffectOnTarget(TargetInfo* target)
if (spellHitTarget)
{
- SpellMissInfo missInfo = DoSpellHitOnUnit(spellHitTarget, mask, target->scaleAura);
- if (missInfo != SPELL_MISS_NONE)
+ SpellMissInfo missInfo2 = DoSpellHitOnUnit(spellHitTarget, mask, target->scaleAura);
+ if (missInfo2 != SPELL_MISS_NONE)
{
- if (missInfo != SPELL_MISS_MISS)
- m_caster->SendSpellMiss(unit, m_spellInfo->Id, missInfo);
+ if (missInfo2 != SPELL_MISS_MISS)
+ m_caster->SendSpellMiss(unit, m_spellInfo->Id, missInfo2);
m_damage = 0;
spellHitTarget = NULL;
}
@@ -1539,7 +1538,7 @@ SpellMissInfo Spell::DoSpellHitOnUnit(Unit* unit, const uint32 effectMask, bool
if (AuraApplication* aurApp = m_spellAura->GetApplicationOfTarget(m_originalCaster->GetGUID()))
positive = aurApp->IsPositive();
- duration = m_originalCaster->ModSpellDuration(aurSpellInfo, unit, duration, positive);
+ duration = m_originalCaster->ModSpellDuration(aurSpellInfo, unit, duration, positive, effectMask);
// Haste modifies duration of channeled spells
if (m_spellInfo->IsChanneled())
@@ -1598,12 +1597,12 @@ void Spell::DoTriggersOnSpellHit(Unit* unit, uint8 effMask)
// this is executed after spell proc spells on target hit
// spells are triggered for each hit spell target
// info confirmed with retail sniffs of permafrost and shadow weaving
- if (!m_hitTriggerSpells.empty() && CanExecuteTriggersOnHit(effMask))
+ if (!m_hitTriggerSpells.empty())
{
int _duration = 0;
for (HitTriggerSpells::const_iterator i = m_hitTriggerSpells.begin(); i != m_hitTriggerSpells.end(); ++i)
{
- if (roll_chance_i(i->second))
+ if (CanExecuteTriggersOnHit(effMask, i->first) && roll_chance_i(i->second))
{
m_caster->CastSpell(unit, i->first, true);
sLog->outDebug(LOG_FILTER_SPELLS_AURAS, "Spell %d triggered spell %d by SPELL_AURA_ADD_TARGET_TRIGGER aura", m_spellInfo->Id, i->first->Id);
@@ -3836,19 +3835,23 @@ void Spell::SendSpellGo()
if (castFlags & CAST_FLAG_RUNE_LIST) // rune cooldowns list
{
- Player* player = m_caster->ToPlayer();
- uint8 runeMaskInitial = m_runesState;
- uint8 runeMaskAfterCast = player->GetRunesState();
- data << uint8(runeMaskInitial); // runes state before
- data << uint8(runeMaskAfterCast); // runes state after
- for (uint8 i = 0; i < MAX_RUNES; ++i)
+ //TODO: There is a crash caused by a spell with CAST_FLAG_RUNE_LIST casted by a creature
+ //The creature is the mover of a player, so HandleCastSpellOpcode uses it as the caster
+ if (Player* player = m_caster->ToPlayer())
{
- uint8 mask = (1 << i);
- if (mask & runeMaskInitial && !(mask & runeMaskAfterCast)) // usable before andon cooldown now...
+ uint8 runeMaskInitial = m_runesState;
+ uint8 runeMaskAfterCast = player->GetRunesState();
+ data << uint8(runeMaskInitial); // runes state before
+ data << uint8(runeMaskAfterCast); // runes state after
+ for (uint8 i = 0; i < MAX_RUNES; ++i)
{
- // float casts ensure the division is performed on floats as we need float result
- float baseCd = float(player->GetRuneBaseCooldown(i));
- data << uint8((baseCd - float(player->GetRuneCooldown(i))) / baseCd * 255); // rune cooldown passed
+ uint8 mask = (1 << i);
+ if (mask & runeMaskInitial && !(mask & runeMaskAfterCast)) // usable before andon cooldown now...
+ {
+ // float casts ensure the division is performed on floats as we need float result
+ float baseCd = float(player->GetRuneBaseCooldown(i));
+ data << uint8((baseCd - float(player->GetRuneCooldown(i))) / baseCd * 255); // rune cooldown passed
+ }
}
}
}
@@ -4328,9 +4331,9 @@ SpellCastResult Spell::CheckRuneCost(uint32 runeCostID)
if (m_caster->GetTypeId() != TYPEID_PLAYER)
return SPELL_CAST_OK;
- Player* plr = (Player*)m_caster;
+ Player* player = (Player*)m_caster;
- if (plr->getClass() != CLASS_DEATH_KNIGHT)
+ if (player->getClass() != CLASS_DEATH_KNIGHT)
return SPELL_CAST_OK;
SpellRuneCostEntry const* src = sSpellRuneCostStore.LookupEntry(runeCostID);
@@ -4354,8 +4357,8 @@ SpellCastResult Spell::CheckRuneCost(uint32 runeCostID)
for (uint32 i = 0; i < MAX_RUNES; ++i)
{
- RuneType rune = plr->GetCurrentRune(i);
- if ((plr->GetRuneCooldown(i) == 0) && (runeCost[rune] > 0))
+ RuneType rune = player->GetCurrentRune(i);
+ if ((player->GetRuneCooldown(i) == 0) && (runeCost[rune] > 0))
runeCost[rune]--;
}
@@ -5639,7 +5642,16 @@ SpellCastResult Spell::CheckRange(bool strict)
if (!strict && m_casttime == 0)
return SPELL_CAST_OK;
- uint32 range_type = m_spellInfo->RangeEntry ? m_spellInfo->RangeEntry->type : 0;
+ uint32 range_type = 0;
+
+ if (m_spellInfo->RangeEntry)
+ {
+ // self cast is used for triggered spells, no range checking needed
+ if (m_spellInfo->RangeEntry->ID == 1)
+ return SPELL_CAST_OK;
+
+ range_type = m_spellInfo->RangeEntry->type;
+ }
Unit* target = m_targets.GetUnitTarget();
float max_range = m_caster->GetSpellMaxRangeForTarget(target, m_spellInfo);
@@ -5820,9 +5832,8 @@ SpellCastResult Spell::CheckItems()
// check spell focus object
if (m_spellInfo->RequiresSpellFocus)
{
- CellPair p(Trinity::ComputeCellPair(m_caster->GetPositionX(), m_caster->GetPositionY()));
+ CellCoord p(Trinity::ComputeCellCoord(m_caster->GetPositionX(), m_caster->GetPositionY()));
Cell cell(p);
- cell.data.Part.reserved = ALL_DISTRICT;
GameObject* ok = NULL;
Trinity::GameObjectFocusCheck go_check(m_caster, m_spellInfo->RequiresSpellFocus);
@@ -6409,7 +6420,8 @@ bool Spell::IsNextMeleeSwingSpell() const
bool Spell::IsAutoActionResetSpell() const
{
- return !IsTriggered() && (m_spellInfo->InterruptFlags & SPELL_INTERRUPT_FLAG_AUTOATTACK);
+ // TODO: changed SPELL_INTERRUPT_FLAG_AUTOATTACK -> SPELL_INTERRUPT_FLAG_INTERRUPT to fix compile - is this check correct at all?
+ return !IsTriggered() && (m_spellInfo->InterruptFlags & SPELL_INTERRUPT_FLAG_INTERRUPT);
}
bool Spell::IsNeedSendToClient() const
@@ -6787,7 +6799,7 @@ void Spell::SelectTrajTargets()
if (!dist2d)
return;
- float dz = m_targets.GetDst()->m_positionZ - m_targets.GetSrc()->m_positionZ;
+ float srcToDestDelta = m_targets.GetDst()->m_positionZ - m_targets.GetSrc()->m_positionZ;
UnitList unitList;
SearchAreaTarget(unitList, dist2d, PUSH_IN_THIN_LINE, SPELL_TARGETS_ANY);
@@ -6797,8 +6809,9 @@ void Spell::SelectTrajTargets()
unitList.sort(Trinity::ObjectDistanceOrderPred(m_caster));
float b = tangent(m_targets.GetElevation());
- float a = (dz - dist2d * b) / (dist2d * dist2d);
- if (a > -0.0001f) a = 0;
+ float a = (srcToDestDelta - dist2d * b) / (dist2d * dist2d);
+ if (a > -0.0001f)
+ a = 0;
DEBUG_TRAJ(sLog->outError("Spell::SelectTrajTargets: a %f b %f", a, b);)
float bestDist = m_spellInfo->GetMaxRange(false);
@@ -6826,9 +6839,14 @@ void Spell::SelectTrajTargets()
}
#define CHECK_DIST {\
- DEBUG_TRAJ(sLog->outError("Spell::SelectTrajTargets: dist %f, height %f.", dist, height);)\
- if (dist > bestDist) continue;\
- if (dist < objDist2d + size && dist > objDist2d - size) { bestDist = dist; break; }\
+ DEBUG_TRAJ(sLog->outError("Spell::SelectTrajTargets: dist %f, height %f.", dist, height);)\
+ if (dist > bestDist)\
+ continue;\
+ if (dist < objDist2d + size && dist > objDist2d - size)\
+ {\
+ bestDist = dist;\
+ break;\
+ }\
}
if (!a)
@@ -7016,7 +7034,7 @@ bool Spell::CallScriptEffectHandlers(SpellEffIndex effIndex, SpellEffectHandleMo
break;
default:
ASSERT(false);
- break;
+ return false;
}
(*scritr)->_PrepareScriptCall(hookType);
for (; effItr != effEndItr ; ++effItr)
@@ -7085,17 +7103,17 @@ void Spell::CallScriptAfterUnitTargetSelectHandlers(std::list<Unit*>& unitTarget
}
}
-bool Spell::CanExecuteTriggersOnHit(uint8 effMask) const
+bool Spell::CanExecuteTriggersOnHit(uint8 effMask, SpellInfo const* spellInfo) const
{
- // check which effects can trigger proc
- // don't allow to proc for dummy-only spell target hits
- // prevents triggering/procing effects twice from spells like Eviscerate
- for (uint8 i = 0;effMask && i < MAX_SPELL_EFFECTS; ++i)
+ bool only_on_dummy = (spellInfo && (spellInfo->AttributesEx4 & SPELL_ATTR4_PROC_ONLY_ON_DUMMY));
+ // If triggered spell has SPELL_ATTR4_PROC_ONLY_ON_DUMMY then it can only proc on a casted spell with SPELL_EFFECT_DUMMY
+ // If triggered spell doesn't have SPELL_ATTR4_PROC_ONLY_ON_DUMMY then it can NOT proc on SPELL_EFFECT_DUMMY (needs confirmation)
+ for (uint8 i = 0;i < MAX_SPELL_EFFECTS; ++i)
{
- if (m_spellInfo->Effects[i].Effect == SPELL_EFFECT_DUMMY)
- effMask &= ~(1<<i);
+ if ((effMask & (1 << i)) && (only_on_dummy == (m_spellInfo->Effects[i].Effect == SPELL_EFFECT_DUMMY)))
+ return true;
}
- return effMask;
+ return false;
}
void Spell::PrepareTriggersExecutedOnHit()
diff --git a/src/server/game/Spells/Spell.h b/src/server/game/Spells/Spell.h
index 27b0844f32e..624c3b9b9b3 100755
--- a/src/server/game/Spells/Spell.h
+++ b/src/server/game/Spells/Spell.h
@@ -453,7 +453,7 @@ class Spell
UsedSpellMods m_appliedMods;
- int32 CalcCastTime() const { return m_casttime; }
+ int32 GetCastTime() const { return m_casttime; }
bool IsAutoRepeat() const { return m_autoRepeat; }
void SetAutoRepeat(bool rep) { m_autoRepeat = rep; }
void ReSetTimer() { m_timer = m_casttime > 0 ? m_casttime : 0; }
@@ -633,7 +633,7 @@ class Spell
void CallScriptAfterUnitTargetSelectHandlers(std::list<Unit*>& unitTargets, SpellEffIndex effIndex);
std::list<SpellScript*> m_loadedScripts;
- bool CanExecuteTriggersOnHit(uint8 effMask) const;
+ bool CanExecuteTriggersOnHit(uint8 effMask, SpellInfo const* spellInfo = NULL) const;
void PrepareTriggersExecutedOnHit();
typedef std::list< std::pair<SpellInfo const*, int32> > HitTriggerSpells;
HitTriggerSpells m_hitTriggerSpells;
diff --git a/src/server/game/Spells/SpellEffects.cpp b/src/server/game/Spells/SpellEffects.cpp
index 19f84854ae4..a4cf8e6a469 100755
--- a/src/server/game/Spells/SpellEffects.cpp
+++ b/src/server/game/Spells/SpellEffects.cpp
@@ -456,7 +456,11 @@ void Spell::EffectSchoolDMG(SpellEffIndex effIndex)
ApplyPctF(damage, m_caster->GetTotalAttackPowerValue(BASE_ATTACK));
// Shield Slam
else if (m_spellInfo->SpellFamilyFlags[1] & 0x200 && m_spellInfo->Category == 1209)
- damage += int32(m_caster->ApplyEffectModifiers(m_spellInfo, effIndex, float(m_caster->GetShieldBlockValue())));
+ {
+ uint8 level = m_caster->getLevel();
+ uint32 block_value = m_caster->GetShieldBlockValue(uint32(float(level) * 24.5f), uint32(float(level) * 34.5f));
+ damage += int32(m_caster->ApplyEffectModifiers(m_spellInfo, effIndex, float(block_value)));
+ }
// Victory Rush
else if (m_spellInfo->SpellFamilyFlags[1] & 0x100)
ApplyPctF(damage, m_caster->GetTotalAttackPowerValue(BASE_ATTACK));
@@ -716,7 +720,9 @@ void Spell::EffectSchoolDMG(SpellEffIndex effIndex)
// Shield of Righteousness
if (m_spellInfo->SpellFamilyFlags[EFFECT_1] & 0x100000)
{
- damage += CalculatePctN(m_caster->GetShieldBlockValue(), m_spellInfo->Effects[EFFECT_1].CalcValue());
+ uint8 level = m_caster->getLevel();
+ uint32 block_value = m_caster->GetShieldBlockValue(uint32(float(level) * 29.5f), uint32(float(level) * 39.5f));
+ damage += CalculatePctN(block_value, m_spellInfo->Effects[EFFECT_1].CalcValue());
break;
}
break;
@@ -917,7 +923,7 @@ void Spell::EffectDummy(SpellEffIndex effIndex)
if (m_caster->GetTypeId() != TYPEID_PLAYER)
return;
- uint32 spell_id = roll_chance_i(50)
+ spell_id = roll_chance_i(50)
? 29277 // Summon Purified Helboar Meat
: 29278; // Summon Toxic Helboar Meat
@@ -945,12 +951,16 @@ void Spell::EffectDummy(SpellEffIndex effIndex)
return;
case 35745: // Socrethar's Stone
{
- uint32 spell_id;
switch (m_caster->GetAreaId())
{
- case 3900: spell_id = 35743; break; // Socrethar Portal
- case 3742: spell_id = 35744; break; // Socrethar Portal
- default: return;
+ case 3900:
+ spell_id = 35743;
+ break; // Socrethar Portal
+ case 3742:
+ spell_id = 35744;
+ break; // Socrethar Portal
+ default:
+ return;
}
m_caster->CastSpell(m_caster, spell_id, true);
@@ -1447,7 +1457,7 @@ void Spell::EffectDummy(SpellEffIndex effIndex)
if (m_spellInfo->SpellFamilyFlags[0] & SPELLFAMILYFLAG_DK_DEATH_STRIKE)
{
uint32 count = unitTarget->GetDiseasesByCaster(m_caster->GetGUID());
- int32 bp = int32(count * m_caster->CountPctFromMaxHealth(int32(m_spellInfo->Effects[EFFECT_0].DamageMultiplier)));
+ bp = int32(count * m_caster->CountPctFromMaxHealth(int32(m_spellInfo->Effects[EFFECT_0].DamageMultiplier)));
// Improved Death Strike
if (AuraEffect const* aurEff = m_caster->GetAuraEffect(SPELL_AURA_ADD_PCT_MODIFIER, SPELLFAMILY_DEATHKNIGHT, 2751, 0))
AddPctN(bp, m_caster->CalculateSpellDamage(m_caster, aurEff->GetSpellInfo(), 2));
@@ -1459,12 +1469,12 @@ void Spell::EffectDummy(SpellEffIndex effIndex)
{
if (m_caster->IsFriendlyTo(unitTarget))
{
- int32 bp = int32(damage * 1.5f);
+ bp = int32(damage * 1.5f);
m_caster->CastCustomSpell(unitTarget, 47633, &bp, NULL, NULL, true);
}
else
{
- int32 bp = damage;
+ bp = damage;
m_caster->CastCustomSpell(unitTarget, 47632, &bp, NULL, NULL, true);
}
return;
@@ -1663,13 +1673,6 @@ void Spell::EffectTriggerSpell(SpellEffIndex effIndex)
}
return;
}
- // Priest Shadowfiend (34433) need apply mana gain trigger aura on pet
- case 41967:
- {
- if (Unit* pet = unitTarget->GetGuardianPet())
- pet->CastSpell(pet, 28305, true);
- return;
- }
}
}
@@ -2142,6 +2145,16 @@ void Spell::EffectSendEvent(SpellEffIndex effIndex)
&& effectHandleMode != SPELL_EFFECT_HANDLE_HIT)
return;
+ //! it's possible for spells with this spell effect to either have a target or no target
+ //! in case of a target, we will execute this handler on SPELL_EFFECT_HANDLE_HIT_TARGET
+ //! with all relevant variables, and we will skip SPELL_EFFECT_HANDLE_HIT
+ if (effectHandleMode == SPELL_EFFECT_HANDLE_HIT)
+ {
+ if (GetSpellInfo()->Effects[effIndex].TargetA.GetTarget() != 0 ||
+ GetSpellInfo()->Effects[effIndex].TargetB.GetTarget() != 0)
+ return;
+ }
+
WorldObject* target = NULL;
// call events for target if present
@@ -2238,6 +2251,13 @@ void Spell::EffectHeal(SpellEffIndex /*effIndex*/)
addhealth += damageAmount;
}
+ // Runic Healing Injector (heal increased by 25% for engineers - 3.2.0 patch change)
+ else if (m_spellInfo->Id == 67489)
+ {
+ if (Player* player = m_caster->ToPlayer())
+ if (player->HasSkill(SKILL_ENGINEERING))
+ AddPctN(addhealth, 25);
+ }
// Swiftmend - consumes Regrowth or Rejuvenation
else if (m_spellInfo->TargetAuraState == AURA_STATE_SWIFTMEND && unitTarget->HasAuraState(AURA_STATE_SWIFTMEND, m_spellInfo, m_caster))
{
@@ -2630,6 +2650,13 @@ void Spell::EffectEnergize(SpellEffIndex effIndex)
case 48542: // Revitalize
damage = int32(CalculatePctN(unitTarget->GetMaxPower(power), damage));
break;
+ case 67490: // Runic Mana Injector (mana gain increased by 25% for engineers - 3.2.0 patch change)
+ {
+ if (Player* player = m_caster->ToPlayer())
+ if (player->HasSkill(SKILL_ENGINEERING))
+ AddPctN(damage, 25);
+ break;
+ }
case 71132: // Glyph of Shadow Word: Pain
damage = int32(CalculatePctN(unitTarget->GetCreateMana(), 1)); // set 1 as value, missing in dbc
break;
@@ -3575,7 +3602,7 @@ void Spell::EffectEnchantItemPerm(SpellEffIndex effIndex)
// add new enchanting if equipped
item_owner->ApplyEnchantment(itemTarget, PERM_ENCHANTMENT_SLOT, true);
- itemTarget->SetSoulboundTradeable(NULL, item_owner, false);
+ itemTarget->ClearSoulboundTradeable(item_owner);
}
}
@@ -3639,7 +3666,7 @@ void Spell::EffectEnchantItemPrismatic(SpellEffIndex effIndex)
// add new enchanting if equipped
item_owner->ApplyEnchantment(itemTarget, PRISMATIC_ENCHANTMENT_SLOT, true);
- itemTarget->SetSoulboundTradeable(NULL, item_owner, false);
+ itemTarget->ClearSoulboundTradeable(item_owner);
}
void Spell::EffectEnchantItemTmp(SpellEffIndex effIndex)
@@ -4320,19 +4347,22 @@ void Spell::EffectInterruptCast(SpellEffIndex effIndex)
// TODO: not all spells that used this effect apply cooldown at school spells
// also exist case: apply cooldown to interrupted cast only and to all spells
- for (uint32 i = CURRENT_FIRST_NON_MELEE_SPELL; i < CURRENT_MAX_SPELL; ++i)
+ // there is no CURRENT_AUTOREPEAT_SPELL spells that can be interrupted
+ for (uint32 i = CURRENT_FIRST_NON_MELEE_SPELL; i < CURRENT_AUTOREPEAT_SPELL; ++i)
{
if (Spell* spell = unitTarget->GetCurrentSpell(CurrentSpellTypes(i)))
{
SpellInfo const* curSpellInfo = spell->m_spellInfo;
// check if we can interrupt spell
if ((spell->getState() == SPELL_STATE_CASTING
- || (spell->getState() == SPELL_STATE_PREPARING && spell->CalcCastTime() > 0.0f))
- && curSpellInfo->InterruptFlags & SPELL_INTERRUPT_FLAG_INTERRUPT && curSpellInfo->PreventionType == SPELL_PREVENTION_TYPE_SILENCE)
+ || (spell->getState() == SPELL_STATE_PREPARING && spell->GetCastTime() > 0.0f))
+ && curSpellInfo->PreventionType == SPELL_PREVENTION_TYPE_SILENCE
+ && ((i == CURRENT_GENERIC_SPELL && curSpellInfo->InterruptFlags & SPELL_INTERRUPT_FLAG_INTERRUPT)
+ || (i == CURRENT_CHANNELED_SPELL && curSpellInfo->ChannelInterruptFlags & CHANNEL_INTERRUPT_FLAG_INTERRUPT)))
{
if (m_originalCaster)
{
- int32 duration = m_originalCaster->ModSpellDuration(m_spellInfo, unitTarget, m_originalCaster->CalcSpellDuration(m_spellInfo), false);
+ int32 duration = m_originalCaster->ModSpellDuration(m_spellInfo, unitTarget, m_originalCaster->CalcSpellDuration(m_spellInfo), false, 1 << effIndex);
unitTarget->ProhibitSpellSchool(curSpellInfo->GetSchoolMask(), duration/*GetSpellDuration(m_spellInfo)*/);
}
ExecuteLogEffectInterruptCast(effIndex, unitTarget, curSpellInfo->Id);
@@ -4382,8 +4412,8 @@ void Spell::EffectSummonObjectWild(SpellEffIndex effIndex)
if (pGameObj->GetGoType() == GAMEOBJECT_TYPE_FLAGDROP && m_caster->GetTypeId() == TYPEID_PLAYER)
{
- Player* pl = m_caster->ToPlayer();
- Battleground* bg = pl->GetBattleground();
+ Player* player = m_caster->ToPlayer();
+ Battleground* bg = player->GetBattleground();
switch (pGameObj->GetMapId())
{
@@ -4393,7 +4423,7 @@ void Spell::EffectSummonObjectWild(SpellEffIndex effIndex)
{
uint32 team = ALLIANCE;
- if (pl->GetTeam() == team)
+ if (player->GetTeam() == team)
team = HORDE;
((BattlegroundWS*)bg)->SetDroppedFlagGUID(pGameObj->GetGUID(), team);
@@ -4937,6 +4967,25 @@ void Spell::EffectScriptEffect(SpellEffIndex effIndex)
}
return;
}
+ case 57347: // Retrieving (Wintergrasp RP-GG pickup spell)
+ {
+ if (!unitTarget || unitTarget->GetTypeId() != TYPEID_UNIT || m_caster->GetTypeId() != TYPEID_PLAYER)
+ return;
+
+ unitTarget->ToCreature()->DespawnOrUnsummon();
+
+ return;
+ }
+ case 57349: // Drop RP-GG (Wintergrasp RP-GG at death drop spell)
+ {
+ if (m_caster->GetTypeId() != TYPEID_PLAYER)
+ return;
+
+ // Delete item from inventory at death
+ m_caster->ToPlayer()->DestroyItemCount(damage, 5, true);
+
+ return;
+ }
case 58418: // Portal to Orgrimmar
case 58420: // Portal to Stormwind
{
@@ -5328,11 +5377,11 @@ void Spell::EffectScriptEffect(SpellEffIndex effIndex)
case 64142: // Upper Deck - Create Foam Sword
if (unitTarget->GetTypeId() != TYPEID_PLAYER)
return;
- Player* plr = unitTarget->ToPlayer();
+ Player* player = unitTarget->ToPlayer();
static uint32 const itemId[] = {45061, 45176, 45177, 45178, 45179, 0};
// player can only have one of these items
for (uint32 const* itr = &itemId[0]; *itr; ++itr)
- if (plr->HasItemCount(*itr, 1, true))
+ if (player->HasItemCount(*itr, 1, true))
return;
DoCreateItem(effIndex, itemId[urand(0, 4)]);
return;
@@ -6139,15 +6188,15 @@ void Spell::EffectSelfResurrect(SpellEffIndex effIndex)
mana = CalculatePctN(m_caster->GetMaxPower(POWER_MANA), damage);
}
- Player* plr = m_caster->ToPlayer();
- plr->ResurrectPlayer(0.0f);
+ Player* player = m_caster->ToPlayer();
+ player->ResurrectPlayer(0.0f);
- plr->SetHealth(health);
- plr->SetPower(POWER_MANA, mana);
- plr->SetPower(POWER_RAGE, 0);
- plr->SetPower(POWER_ENERGY, plr->GetMaxPower(POWER_ENERGY));
+ player->SetHealth(health);
+ player->SetPower(POWER_MANA, mana);
+ player->SetPower(POWER_RAGE, 0);
+ player->SetPower(POWER_ENERGY, player->GetMaxPower(POWER_ENERGY));
- plr->SpawnCorpseBones();
+ player->SpawnCorpseBones();
}
void Spell::EffectSkinning(SpellEffIndex /*effIndex*/)
@@ -6303,13 +6352,13 @@ void Spell::EffectQuestClear(SpellEffIndex effIndex)
// remove all quest entries for 'entry' from quest log
for (uint8 slot = 0; slot < MAX_QUEST_LOG_SIZE; ++slot)
{
- uint32 quest = player->GetQuestSlotQuestId(slot);
- if (quest == quest_id)
+ uint32 logQuest = player->GetQuestSlotQuestId(slot);
+ if (logQuest == quest_id)
{
player->SetQuestSlot(slot, 0);
- // we ignore unequippable quest items in this case, its' still be equipped
- player->TakeQuestSourceItem(quest, false);
+ // we ignore unequippable quest items in this case, it's still be equipped
+ player->TakeQuestSourceItem(logQuest, false);
}
}
@@ -6921,9 +6970,9 @@ void Spell::EffectActivateRune(SpellEffIndex effIndex)
if (m_caster->GetTypeId() != TYPEID_PLAYER)
return;
- Player* plr = m_caster->ToPlayer();
+ Player* player = m_caster->ToPlayer();
- if (plr->getClass() != CLASS_DEATH_KNIGHT)
+ if (player->getClass() != CLASS_DEATH_KNIGHT)
return;
// needed later
@@ -6933,9 +6982,9 @@ void Spell::EffectActivateRune(SpellEffIndex effIndex)
if (count == 0) count = 1;
for (uint32 j = 0; j < MAX_RUNES && count > 0; ++j)
{
- if (plr->GetRuneCooldown(j) && plr->GetCurrentRune(j) == RuneType(m_spellInfo->Effects[effIndex].MiscValue))
+ if (player->GetRuneCooldown(j) && player->GetCurrentRune(j) == RuneType(m_spellInfo->Effects[effIndex].MiscValue))
{
- plr->SetRuneCooldown(j, 0);
+ player->SetRuneCooldown(j, 0);
--count;
}
}
@@ -6948,8 +6997,8 @@ void Spell::EffectActivateRune(SpellEffIndex effIndex)
for (uint32 i = 0; i < MAX_RUNES; ++i)
{
- if (plr->GetRuneCooldown(i) && (plr->GetCurrentRune(i) == RUNE_FROST || plr->GetCurrentRune(i) == RUNE_DEATH))
- plr->SetRuneCooldown(i, 0);
+ if (player->GetRuneCooldown(i) && (player->GetCurrentRune(i) == RUNE_FROST || player->GetCurrentRune(i) == RUNE_DEATH))
+ player->SetRuneCooldown(i, 0);
}
}
}
@@ -7069,9 +7118,9 @@ void Spell::SummonGuardian(uint32 i, uint32 entry, SummonPropertiesEntry const*
// level of pet summoned using engineering item based at engineering skill level
if (m_CastItem && caster->GetTypeId() == TYPEID_PLAYER)
if (ItemTemplate const* proto = m_CastItem->GetTemplate())
- if (proto->RequiredSkill == SKILL_ENGINERING)
- if (uint16 skill202 = caster->ToPlayer()->GetSkillValue(SKILL_ENGINERING))
- level = skill202/5;
+ if (proto->RequiredSkill == SKILL_ENGINEERING)
+ if (uint16 skill202 = caster->ToPlayer()->GetSkillValue(SKILL_ENGINEERING))
+ level = skill202 / 5;
//float radius = GetSpellRadiusForFriend(sSpellRadiusStore.LookupEntry(m_spellInfo->EffectRadiusIndex[i]));
float radius = 5.0f;
diff --git a/src/server/game/Spells/SpellInfo.cpp b/src/server/game/Spells/SpellInfo.cpp
index 543baa82789..972276c7d26 100644
--- a/src/server/game/Spells/SpellInfo.cpp
+++ b/src/server/game/Spells/SpellInfo.cpp
@@ -1735,6 +1735,17 @@ uint32 SpellInfo::GetEffectMechanicMask(uint8 effIndex) const
return mask;
}
+uint32 SpellInfo::GetSpellMechanicMaskByEffectMask(uint32 effectMask) const
+{
+ uint32 mask = 0;
+ if (Mechanic)
+ mask |= 1<< Mechanic;
+ for (int i = 0; i < MAX_SPELL_EFFECTS; ++i)
+ if ((effectMask & (1 << i)) && Effects[i].Mechanic)
+ mask |= 1<< Effects[i].Mechanic;
+ return mask;
+}
+
Mechanics SpellInfo::GetEffectMechanic(uint8 effIndex) const
{
if (Effects[effIndex].IsEffect() && Effects[effIndex].Mechanic)
diff --git a/src/server/game/Spells/SpellInfo.h b/src/server/game/Spells/SpellInfo.h
index b4f4ca8c11e..7faf0de890d 100644
--- a/src/server/game/Spells/SpellInfo.h
+++ b/src/server/game/Spells/SpellInfo.h
@@ -444,6 +444,7 @@ public:
SpellSchoolMask GetSchoolMask() const;
uint32 GetAllEffectsMechanicMask() const;
uint32 GetEffectMechanicMask(uint8 effIndex) const;
+ uint32 GetSpellMechanicMaskByEffectMask(uint32 effectMask) const;
Mechanics GetEffectMechanic(uint8 effIndex) const;
uint32 GetDispelMask() const;
static uint32 GetDispelMask(DispelType type);
diff --git a/src/server/game/Spells/SpellMgr.cpp b/src/server/game/Spells/SpellMgr.cpp
index 4fc9564baa3..55a70066a8d 100755
--- a/src/server/game/Spells/SpellMgr.cpp
+++ b/src/server/game/Spells/SpellMgr.cpp
@@ -96,7 +96,7 @@ DiminishingGroup GetDiminishingReturnsGroupForSpell(SpellInfo const* spellproto,
return DIMINISHING_CONTROLLED_ROOT;
// Dragon's Breath
else if (spellproto->SpellFamilyFlags[0] & 0x800000)
- return DIMINISHING_DISORIENT;
+ return DIMINISHING_DRAGONS_BREATH;
break;
}
case SPELLFAMILY_WARRIOR:
@@ -167,7 +167,7 @@ DiminishingGroup GetDiminishingReturnsGroupForSpell(SpellInfo const* spellproto,
}
case SPELLFAMILY_HUNTER:
{
- // Hunter's mark
+ // Hunter's Mark
if ((spellproto->SpellFamilyFlags[0] & 0x400) && spellproto->SpellIconID == 538)
return DIMINISHING_LIMITONLY;
// Scatter Shot (own diminishing)
@@ -321,20 +321,20 @@ bool IsDiminishingReturnsGroupDurationLimited(DiminishingGroup group)
{
switch (group)
{
+ case DIMINISHING_BANISH:
case DIMINISHING_CONTROLLED_STUN:
- case DIMINISHING_STUN:
- case DIMINISHING_ENTRAPMENT:
case DIMINISHING_CONTROLLED_ROOT:
- case DIMINISHING_ROOT:
+ case DIMINISHING_CYCLONE:
+ case DIMINISHING_DISORIENT:
+ case DIMINISHING_ENTRAPMENT:
case DIMINISHING_FEAR:
+ case DIMINISHING_HORROR:
case DIMINISHING_MIND_CONTROL:
- case DIMINISHING_DISORIENT:
- case DIMINISHING_CYCLONE:
- case DIMINISHING_BANISH:
- case DIMINISHING_LIMITONLY:
case DIMINISHING_OPENING_STUN:
- case DIMINISHING_HORROR:
+ case DIMINISHING_ROOT:
+ case DIMINISHING_STUN:
case DIMINISHING_SLEEP:
+ case DIMINISHING_LIMITONLY:
return true;
default:
return false;
@@ -351,7 +351,7 @@ SpellMgr::~SpellMgr()
}
/// Some checks for spells, to prevent adding deprecated/broken spells for trainers, spell book, etc
-bool SpellMgr::IsSpellValid(SpellInfo const* spellInfo, Player* pl, bool msg)
+bool SpellMgr::IsSpellValid(SpellInfo const* spellInfo, Player* player, bool msg)
{
// not exist
if (!spellInfo)
@@ -378,8 +378,8 @@ bool SpellMgr::IsSpellValid(SpellInfo const* spellInfo, Player* pl, bool msg)
{
if (msg)
{
- if (pl)
- ChatHandler(pl).PSendSysMessage("Craft spell %u not have create item entry.", spellInfo->Id);
+ if (player)
+ ChatHandler(player).PSendSysMessage("Craft spell %u not have create item entry.", spellInfo->Id);
else
sLog->outErrorDb("Craft spell %u not have create item entry.", spellInfo->Id);
}
@@ -392,8 +392,8 @@ bool SpellMgr::IsSpellValid(SpellInfo const* spellInfo, Player* pl, bool msg)
{
if (msg)
{
- if (pl)
- ChatHandler(pl).PSendSysMessage("Craft spell %u create not-exist in DB item (Entry: %u) and then...", spellInfo->Id, spellInfo->Effects[i].ItemType);
+ if (player)
+ ChatHandler(player).PSendSysMessage("Craft spell %u create not-exist in DB item (Entry: %u) and then...", spellInfo->Id, spellInfo->Effects[i].ItemType);
else
sLog->outErrorDb("Craft spell %u create not-exist in DB item (Entry: %u) and then...", spellInfo->Id, spellInfo->Effects[i].ItemType);
}
@@ -406,12 +406,12 @@ bool SpellMgr::IsSpellValid(SpellInfo const* spellInfo, Player* pl, bool msg)
case SPELL_EFFECT_LEARN_SPELL:
{
SpellInfo const* spellInfo2 = sSpellMgr->GetSpellInfo(spellInfo->Effects[i].TriggerSpell);
- if (!IsSpellValid(spellInfo2, pl, msg))
+ if (!IsSpellValid(spellInfo2, player, msg))
{
if (msg)
{
- if (pl)
- ChatHandler(pl).PSendSysMessage("Spell %u learn to broken spell %u, and then...", spellInfo->Id, spellInfo->Effects[i].TriggerSpell);
+ if (player)
+ ChatHandler(player).PSendSysMessage("Spell %u learn to broken spell %u, and then...", spellInfo->Id, spellInfo->Effects[i].TriggerSpell);
else
sLog->outErrorDb("Spell %u learn to invalid spell %u, and then...", spellInfo->Id, spellInfo->Effects[i].TriggerSpell);
}
@@ -430,8 +430,8 @@ bool SpellMgr::IsSpellValid(SpellInfo const* spellInfo, Player* pl, bool msg)
{
if (msg)
{
- if (pl)
- ChatHandler(pl).PSendSysMessage("Craft spell %u have not-exist reagent in DB item (Entry: %u) and then...", spellInfo->Id, spellInfo->Reagent[j]);
+ if (player)
+ ChatHandler(player).PSendSysMessage("Craft spell %u have not-exist reagent in DB item (Entry: %u) and then...", spellInfo->Id, spellInfo->Reagent[j]);
else
sLog->outErrorDb("Craft spell %u have not-exist reagent in DB item (Entry: %u) and then...", spellInfo->Id, spellInfo->Reagent[j]);
}
@@ -694,6 +694,38 @@ void SpellMgr::GetSetOfSpellsInSpellGroup(SpellGroup group_id, std::set<uint32>&
}
}
+bool SpellMgr::AddSameEffectStackRuleSpellGroups(SpellInfo const* spellInfo, int32 amount, std::map<SpellGroup, int32>& groups) const
+{
+ uint32 spellId = spellInfo->GetFirstRankSpell()->Id;
+ SpellSpellGroupMapBounds spellGroup = GetSpellSpellGroupMapBounds(spellId);
+ // Find group with SPELL_GROUP_STACK_RULE_EXCLUSIVE_SAME_EFFECT if it belongs to one
+ for (SpellSpellGroupMap::const_iterator itr = spellGroup.first; itr != spellGroup.second ; ++itr)
+ {
+ SpellGroup group = itr->second;
+ SpellGroupStackMap::const_iterator found = mSpellGroupStack.find(group);
+ if (found != mSpellGroupStack.end())
+ {
+ if (found->second == SPELL_GROUP_STACK_RULE_EXCLUSIVE_SAME_EFFECT)
+ {
+ // Put the highest amount in the map
+ if (groups.find(group) == groups.end())
+ groups[group] = amount;
+ else
+ {
+ int32 curr_amount = groups[group];
+ // Take absolute value because this also counts for the highest negative aura
+ if (abs(curr_amount) < abs(amount))
+ groups[group] = amount;
+ }
+ // return because a spell should be in only one SPELL_GROUP_STACK_RULE_EXCLUSIVE_SAME_EFFECT group
+ return true;
+ }
+ }
+ }
+ // Not in a SPELL_GROUP_STACK_RULE_EXCLUSIVE_SAME_EFFECT group, so return false
+ return false;
+}
+
SpellGroupStackRule SpellMgr::CheckSpellGroupStackRules(SpellInfo const* spellInfo1, SpellInfo const* spellInfo2) const
{
uint32 spellid_1 = spellInfo1->GetFirstRankSpell()->Id;
@@ -973,7 +1005,7 @@ SpellThreatEntry const* SpellMgr::GetSpellThreatEntry(uint32 spellID) const
else
{
uint32 firstSpell = GetFirstSpellInChain(spellID);
- SpellThreatMap::const_iterator itr = mSpellThreatMap.find(firstSpell);
+ itr = mSpellThreatMap.find(firstSpell);
if (itr != mSpellThreatMap.end())
return &itr->second;
}
@@ -2933,11 +2965,14 @@ void SpellMgr::LoadDbcDataCorrections()
break;
case 31447: // Mark of Kaz'rogal (needs target selection script)
case 31298: // Sleep (needs target selection script)
+ case 51904: // Summon Ghouls On Scarlet Crusade (this should use conditions table, script for this spell needs to be fixed)
+ case 2895: // Wrath of Air Totem rank 1 (Aura)
+ case 68933: // Wrath of Air Totem rank 2 (Aura)
spellInfo->EffectImplicitTargetA[0] = TARGET_UNIT_CASTER;
spellInfo->EffectImplicitTargetB[0] = 0;
break;
case 31344: // Howl of Azgalor
- spellInfo->EffectRadiusIndex[0] = 12; // 100yards instead of 50000?!
+ spellInfo->EffectRadiusIndex[0] = EFFECT_RADIUS_100_YARDS; // 100yards instead of 50000?!
break;
case 42818: // Headless Horseman - Wisp Flight Port
case 42821: // Headless Horseman - Wisp Flight Missile
@@ -2973,10 +3008,14 @@ void SpellMgr::LoadDbcDataCorrections()
case 59725: // Improved Spell Reflection - aoe aura
// Target entry seems to be wrong for this spell :/
spellInfo->EffectImplicitTargetA[0] = TARGET_UNIT_CASTER_AREA_PARTY;
- spellInfo->EffectRadiusIndex[0] = 45;
- break;
- case 44978: case 45001: case 45002: // Wild Magic
- case 45004: case 45006: case 45010: // Wild Magic
+ spellInfo->EffectRadiusIndex[0] = EFFECT_RADIUS_10_YARDS_2;
+ break;
+ case 44978: // Wild Magic
+ case 45001:
+ case 45002:
+ case 45004:
+ case 45006:
+ case 45010:
case 31347: // Doom
case 41635: // Prayer of Mending
case 44869: // Spectral Blast
@@ -3033,7 +3072,8 @@ void SpellMgr::LoadDbcDataCorrections()
case 50312: // Unholy Frenzy
spellInfo->MaxAffectedTargets = 15;
break;
- case 38794: case 33711: //Murmur's Touch
+ case 33711: //Murmur's Touch
+ case 38794:
spellInfo->MaxAffectedTargets = 1;
spellInfo->EffectTriggerSpell[0] = 33760;
break;
@@ -3073,11 +3113,8 @@ void SpellMgr::LoadDbcDataCorrections()
case 51852: // The Eye of Acherus (no spawn in phase 2 in db)
spellInfo->EffectMiscValue[0] |= 1;
break;
- case 51904: // Summon Ghouls On Scarlet Crusade (this should use conditions table, script for this spell needs to be fixed)
- spellInfo->EffectImplicitTargetA[0] = TARGET_UNIT_CASTER;
- break;
case 29809: // Desecration Arm - 36 instead of 37 - typo? :/
- spellInfo->EffectRadiusIndex[0] = 37;
+ spellInfo->EffectRadiusIndex[0] = EFFECT_RADIUS_7_YARDS;
break;
// Master Shapeshifter: missing stance data for forms other than bear - bear version has correct data
// To prevent aura staying on target after talent unlearned
@@ -3116,9 +3153,10 @@ void SpellMgr::LoadDbcDataCorrections()
case 51726:
spellInfo->AttributesEx3 |= SPELL_ATTR3_STACK_FOR_DIFF_CASTERS;
spellInfo->SpellFamilyFlags[2] = 0x10;
+ spellInfo->EffectApplyAuraName[1] = SPELL_AURA_MOD_DAMAGE_PERCENT_TAKEN;
break;
case 41913: // Parasitic Shadowfiend Passive
- spellInfo->EffectApplyAuraName[0] = 4; // proc debuff, and summon infinite fiends
+ spellInfo->EffectApplyAuraName[0] = SPELL_AURA_DUMMY; // proc debuff, and summon infinite fiends
break;
case 27892: // To Anchor 1
case 27928: // To Anchor 1
@@ -3146,12 +3184,25 @@ void SpellMgr::LoadDbcDataCorrections()
case 6474: // Earthbind Totem (instant pulse)
spellInfo->AttributesEx5 |= SPELL_ATTR5_START_PERIODIC_AT_APPLY;
break;
+ case 52109: // Flametongue Totem rank 1 (Aura)
+ case 52110: // Flametongue Totem rank 2 (Aura)
+ case 52111: // Flametongue Totem rank 3 (Aura)
+ case 52112: // Flametongue Totem rank 4 (Aura)
+ case 52113: // Flametongue Totem rank 5 (Aura)
+ case 58651: // Flametongue Totem rank 6 (Aura)
+ case 58654: // Flametongue Totem rank 7 (Aura)
+ case 58655: // Flametongue Totem rank 8 (Aura)
+ spellInfo->EffectImplicitTargetA[0] = TARGET_UNIT_CASTER;
+ spellInfo->EffectImplicitTargetA[1] = TARGET_UNIT_CASTER;
+ spellInfo->EffectImplicitTargetB[0] = 0;
+ spellInfo->EffectImplicitTargetB[1] = 0;
+ break;
case 53241: // Marked for Death (Rank 1)
case 53243: // Marked for Death (Rank 2)
case 53244: // Marked for Death (Rank 3)
case 53245: // Marked for Death (Rank 4)
case 53246: // Marked for Death (Rank 5)
- spellInfo->EffectSpellClassMask[0] = flag96(423937, 276955137, 2049);
+ spellInfo->EffectSpellClassMask[0] = flag96(0x00067801, 0x10820001, 0x00000801);
break;
case 70728: // Exploit Weakness (needs target selection script)
case 70840: // Devious Minds (needs target selection script)
@@ -3184,7 +3235,7 @@ void SpellMgr::LoadDbcDataCorrections()
// ULDUAR SPELLS
//
case 62374: // Pursued (Flame Leviathan)
- spellInfo->EffectRadiusIndex[0] = 28; // 50000yd
+ spellInfo->EffectRadiusIndex[0] = EFFECT_RADIUS_50000_YARDS; // 50000yd
break;
case 63342: // Focused Eyebeam Summon Trigger (Kologarn)
spellInfo->MaxAffectedTargets = 1;
@@ -3252,7 +3303,7 @@ void SpellMgr::LoadDbcDataCorrections()
break;
case 69055: // Saber Lash (Lord Marrowgar)
case 70814: // Saber Lash (Lord Marrowgar)
- spellInfo->EffectRadiusIndex[0] = 8; // 5yd
+ spellInfo->EffectRadiusIndex[0] = EFFECT_RADIUS_5_YARDS; // 5yd
break;
case 69075: // Bone Storm (Lord Marrowgar)
case 70834: // Bone Storm (Lord Marrowgar)
@@ -3264,7 +3315,7 @@ void SpellMgr::LoadDbcDataCorrections()
case 71160: // Plague Stench (Stinky)
case 71161: // Plague Stench (Stinky)
case 71123: // Decimate (Stinky & Precious)
- spellInfo->EffectRadiusIndex[0] = 12; // 100yd
+ spellInfo->EffectRadiusIndex[0] = EFFECT_RADIUS_100_YARDS; // 100yd
break;
case 72723: // Resistant Skin (Deathbringer Saurfang adds)
// this spell initially granted Shadow damage immunity, however it was removed but the data was left in client
@@ -3291,7 +3342,7 @@ void SpellMgr::LoadDbcDataCorrections()
case 72464: // Mutated Plague (Professor Putricide)
case 72506: // Mutated Plague (Professor Putricide)
case 72507: // Mutated Plague (Professor Putricide)
- spellInfo->EffectRadiusIndex[0] = 28; // 50000yd
+ spellInfo->EffectRadiusIndex[0] = EFFECT_RADIUS_50000_YARDS; // 50000yd
break;
case 70911: // Unbound Plague (Professor Putricide) (needs target selection script)
case 72854: // Unbound Plague (Professor Putricide) (needs target selection script)
@@ -3302,7 +3353,7 @@ void SpellMgr::LoadDbcDataCorrections()
case 71518: // Unholy Infusion Quest Credit (Professor Putricide)
case 72934: // Blood Infusion Quest Credit (Blood-Queen Lana'thel)
case 72289: // Frost Infusion Quest Credit (Sindragosa)
- spellInfo->EffectRadiusIndex[0] = 28; // another missing radius
+ spellInfo->EffectRadiusIndex[0] = EFFECT_RADIUS_50000_YARDS; // another missing radius
break;
case 71708: // Empowered Flare (Blood Prince Council)
case 72785: // Empowered Flare (Blood Prince Council)
@@ -3329,7 +3380,7 @@ void SpellMgr::LoadDbcDataCorrections()
break;
case 72706: // Achievement Check (Valithria Dreamwalker)
case 71357: // Order Whelp
- spellInfo->EffectRadiusIndex[0] = 22; // 200yd
+ spellInfo->EffectRadiusIndex[0] = EFFECT_RADIUS_200_YARDS; // 200yd
break;
case 70598: // Sindragosa's Fury
spellInfo->EffectImplicitTargetA[0] = TARGET_DEST_CASTER;
@@ -3353,12 +3404,12 @@ void SpellMgr::LoadDbcDataCorrections()
case 73708: // Defile
case 73709: // Defile
case 73710: // Defile
- spellInfo->EffectRadiusIndex[0] = 22; // 200yd
- spellInfo->EffectRadiusIndex[1] = 22; // 200yd
+ spellInfo->EffectRadiusIndex[0] = EFFECT_RADIUS_200_YARDS; // 200yd
+ spellInfo->EffectRadiusIndex[1] = EFFECT_RADIUS_200_YARDS; // 200yd
break;
case 69030: // Val'kyr Target Search
- spellInfo->EffectRadiusIndex[0] = 22; // 200yd
- spellInfo->EffectRadiusIndex[1] = 22; // 200yd
+ spellInfo->EffectRadiusIndex[0] = EFFECT_RADIUS_200_YARDS; // 200yd
+ spellInfo->EffectRadiusIndex[1] = EFFECT_RADIUS_200_YARDS; // 200yd
break;
case 69198: // Raging Spirit Visual
spellInfo->rangeIndex = 13; // 50000yd
@@ -3367,9 +3418,9 @@ void SpellMgr::LoadDbcDataCorrections()
case 74295: // Harvest Souls
case 74296: // Harvest Souls
case 74297: // Harvest Souls
- spellInfo->EffectRadiusIndex[0] = 28; // 50000yd
- spellInfo->EffectRadiusIndex[1] = 28; // 50000yd
- spellInfo->EffectRadiusIndex[2] = 28; // 50000yd
+ spellInfo->EffectRadiusIndex[0] = EFFECT_RADIUS_50000_YARDS; // 50000yd
+ spellInfo->EffectRadiusIndex[1] = EFFECT_RADIUS_50000_YARDS; // 50000yd
+ spellInfo->EffectRadiusIndex[2] = EFFECT_RADIUS_50000_YARDS; // 50000yd
break;
case 73655: // Harvest Soul
spellInfo->AttributesEx3 |= SPELL_ATTR3_NO_DONE_BONUS;
@@ -3381,34 +3432,34 @@ void SpellMgr::LoadDbcDataCorrections()
spellInfo->DurationIndex = 28; // 5 seconds
break;
case 73529: // Shadow Trap
- spellInfo->EffectRadiusIndex[1] = 13; // 10yd
+ spellInfo->EffectRadiusIndex[1] = EFFECT_RADIUS_10_YARDS; // 10yd
break;
case 74282: // Shadow Trap (searcher)
- spellInfo->EffectRadiusIndex[0] = 15; // 3yd
+ spellInfo->EffectRadiusIndex[0] = EFFECT_RADIUS_3_YARDS; // 3yd
break;
case 72595: // Restore Soul
case 73650: // Restore Soul
- spellInfo->EffectRadiusIndex[0] = 22; // 200yd
+ spellInfo->EffectRadiusIndex[0] = EFFECT_RADIUS_200_YARDS; // 200yd
break;
case 74086: // Destroy Soul
- spellInfo->EffectRadiusIndex[0] = 22; // 200yd
+ spellInfo->EffectRadiusIndex[0] = EFFECT_RADIUS_200_YARDS; // 200yd
break;
case 74302: // Summon Spirit Bomb
case 74342: // Summon Spirit Bomb
- spellInfo->EffectRadiusIndex[0] = 22; // 200yd
+ spellInfo->EffectRadiusIndex[0] = EFFECT_RADIUS_200_YARDS; // 200yd
spellInfo->MaxAffectedTargets = 1;
break;
case 74341: // Summon Spirit Bomb
case 74343: // Summon Spirit Bomb
- spellInfo->EffectRadiusIndex[0] = 22; // 200yd
+ spellInfo->EffectRadiusIndex[0] = EFFECT_RADIUS_200_YARDS; // 200yd
spellInfo->MaxAffectedTargets = 3;
break;
case 73579: // Summon Spirit Bomb
- spellInfo->EffectRadiusIndex[0] = 20; // 25yd
+ spellInfo->EffectRadiusIndex[0] = EFFECT_RADIUS_25_YARDS; // 25yd
break;
case 72350: // Fury of Frostmourne
- spellInfo->EffectRadiusIndex[0] = 28; // 50000yd
- spellInfo->EffectRadiusIndex[1] = 28; // 50000yd
+ spellInfo->EffectRadiusIndex[0] = EFFECT_RADIUS_50000_YARDS; // 50000yd
+ spellInfo->EffectRadiusIndex[1] = EFFECT_RADIUS_50000_YARDS; // 50000yd
break;
case 75127: // Kill Frostmourne Players
case 72351: // Fury of Frostmourne
@@ -3416,18 +3467,18 @@ void SpellMgr::LoadDbcDataCorrections()
case 72429: // Mass Resurrection
case 73159: // Play Movie
case 73582: // Trigger Vile Spirit (Inside, Heroic)
- spellInfo->EffectRadiusIndex[0] = 28; // 50000yd
+ spellInfo->EffectRadiusIndex[0] = EFFECT_RADIUS_50000_YARDS; // 50000yd
break;
case 72376: // Raise Dead
spellInfo->MaxAffectedTargets = 3;
- spellInfo->EffectRadiusIndex[0] = 28; // 50000yd
+ spellInfo->EffectRadiusIndex[0] = EFFECT_RADIUS_50000_YARDS; // 50000yd
break;
case 71809: // Jump
spellInfo->rangeIndex = 3; // 20yd
- spellInfo->EffectRadiusIndex[0] = 20; // 25yd
+ spellInfo->EffectRadiusIndex[0] = EFFECT_RADIUS_25_YARDS; // 25yd
break;
case 72405: // Broken Frostmourne
- spellInfo->EffectRadiusIndex[1] = 22; // 200yd
+ spellInfo->EffectRadiusIndex[1] = EFFECT_RADIUS_200_YARDS; // 200yd
break;
default:
break;
diff --git a/src/server/game/Spells/SpellMgr.h b/src/server/game/Spells/SpellMgr.h
index d701ab2882c..552519d9940 100755
--- a/src/server/game/Spells/SpellMgr.h
+++ b/src/server/game/Spells/SpellMgr.h
@@ -322,6 +322,7 @@ typedef UNORDERED_MAP<uint32, SpellBonusEntry> SpellBonusMap;
enum SpellGroup
{
+ SPELL_GROUP_NONE = 0,
SPELL_GROUP_ELIXIR_BATTLE = 1,
SPELL_GROUP_ELIXIR_GUARDIAN = 2,
SPELL_GROUP_ELIXIR_UNSTABLE = 3,
@@ -344,8 +345,9 @@ enum SpellGroupStackRule
SPELL_GROUP_STACK_RULE_DEFAULT = 0,
SPELL_GROUP_STACK_RULE_EXCLUSIVE = 1,
SPELL_GROUP_STACK_RULE_EXCLUSIVE_FROM_SAME_CASTER = 2,
+ SPELL_GROUP_STACK_RULE_EXCLUSIVE_SAME_EFFECT = 3,
};
-#define SPELL_GROUP_STACK_RULE_MAX 3
+#define SPELL_GROUP_STACK_RULE_MAX 4
typedef std::map<SpellGroup, SpellGroupStackRule> SpellGroupStackMap;
@@ -379,6 +381,68 @@ struct SpellTargetPosition
float target_Orientation;
};
+// Enum with EffectRadiusIndex and their actual radius
+enum EffectRadiusIndex
+{
+ EFFECT_RADIUS_2_YARDS = 7,
+ EFFECT_RADIUS_5_YARDS = 8,
+ EFFECT_RADIUS_20_YARDS = 9,
+ EFFECT_RADIUS_30_YARDS = 10,
+ EFFECT_RADIUS_45_YARDS = 11,
+ EFFECT_RADIUS_100_YARDS = 12,
+ EFFECT_RADIUS_10_YARDS = 13,
+ EFFECT_RADIUS_8_YARDS = 14,
+ EFFECT_RADIUS_3_YARDS = 15,
+ EFFECT_RADIUS_1_YARD = 16,
+ EFFECT_RADIUS_13_YARDS = 17,
+ EFFECT_RADIUS_15_YARDS = 18,
+ EFFECT_RADIUS_18_YARDS = 19,
+ EFFECT_RADIUS_25_YARDS = 20,
+ EFFECT_RADIUS_35_YARDS = 21,
+ EFFECT_RADIUS_200_YARDS = 22,
+ EFFECT_RADIUS_40_YARDS = 23,
+ EFFECT_RADIUS_65_YARDS = 24,
+ EFFECT_RADIUS_70_YARDS = 25,
+ EFFECT_RADIUS_4_YARDS = 26,
+ EFFECT_RADIUS_50_YARDS = 27,
+ EFFECT_RADIUS_50000_YARDS = 28,
+ EFFECT_RADIUS_6_YARDS = 29,
+ EFFECT_RADIUS_500_YARDS = 30,
+ EFFECT_RADIUS_80_YARDS = 31,
+ EFFECT_RADIUS_12_YARDS = 32,
+ EFFECT_RADIUS_99_YARDS = 33,
+ EFFECT_RADIUS_55_YARDS = 35,
+ EFFECT_RADIUS_0_YARDS = 36,
+ EFFECT_RADIUS_7_YARDS = 37,
+ EFFECT_RADIUS_21_YARDS = 38,
+ EFFECT_RADIUS_34_YARDS = 39,
+ EFFECT_RADIUS_9_YARDS = 40,
+ EFFECT_RADIUS_150_YARDS = 41,
+ EFFECT_RADIUS_11_YARDS = 42,
+ EFFECT_RADIUS_16_YARDS = 43,
+ EFFECT_RADIUS_0_5_YARDS = 44, // 0.5 yards
+ EFFECT_RADIUS_10_YARDS_2 = 45,
+ EFFECT_RADIUS_5_YARDS_2 = 46,
+ EFFECT_RADIUS_15_YARDS_2 = 47,
+ EFFECT_RADIUS_60_YARDS = 48,
+ EFFECT_RADIUS_90_YARDS = 49,
+ EFFECT_RADIUS_15_YARDS_3 = 50,
+ EFFECT_RADIUS_60_YARDS_2 = 51,
+ EFFECT_RADIUS_5_YARDS_3 = 52,
+ EFFECT_RADIUS_60_YARDS_3 = 53,
+ EFFECT_RADIUS_50000_YARDS_2 = 54,
+ EFFECT_RADIUS_130_YARDS = 55,
+ EFFECT_RADIUS_38_YARDS = 56,
+ EFFECT_RADIUS_45_YARDS_2 = 57,
+ EFFECT_RADIUS_32_YARDS = 59,
+ EFFECT_RADIUS_44_YARDS = 60,
+ EFFECT_RADIUS_14_YARDS = 61,
+ EFFECT_RADIUS_47_YARDS = 62,
+ EFFECT_RADIUS_23_YARDS = 63,
+ EFFECT_RADIUS_3_5_YARDS = 64, // 3.5 yards
+ EFFECT_RADIUS_80_YARDS_2 = 65
+};
+
typedef UNORDERED_MAP<uint32, SpellTargetPosition> SpellTargetPositionMap;
// Spell pet auras
@@ -553,7 +617,7 @@ class SpellMgr
// Accessors (const or static functions)
public:
// Spell correctess for client using
- static bool IsSpellValid(SpellInfo const* spellInfo, Player* pl = NULL, bool msg = true);
+ static bool IsSpellValid(SpellInfo const* spellInfo, Player* player = NULL, bool msg = true);
// Spell difficulty
uint32 GetSpellDifficultyId(uint32 spellId) const;
@@ -596,6 +660,7 @@ class SpellMgr
void GetSetOfSpellsInSpellGroup(SpellGroup group_id, std::set<uint32>& foundSpells, std::set<SpellGroup>& usedGroups) const;
// Spell Group Stack Rules table
+ bool AddSameEffectStackRuleSpellGroups(SpellInfo const* spellInfo, int32 amount, std::map<SpellGroup, int32>& groups) const;
SpellGroupStackRule CheckSpellGroupStackRules(SpellInfo const* spellInfo1, SpellInfo const* spellInfo2) const;
// Spell proc event table
diff --git a/src/server/game/Texts/CreatureTextMgr.cpp b/src/server/game/Texts/CreatureTextMgr.cpp
index f901c0acac8..2915bab4b77 100755
--- a/src/server/game/Texts/CreatureTextMgr.cpp
+++ b/src/server/game/Texts/CreatureTextMgr.cpp
@@ -381,12 +381,12 @@ void CreatureTextMgr::SendChatPacket(WorldPacket* data, WorldObject* source, Cha
const SessionMap smap = sWorld->GetAllSessions();
for (SessionMap::const_iterator iter = smap.begin(); iter != smap.end(); ++iter)
{
- if (Player* plr = (*iter).second->GetPlayer())
+ if (Player* player = (*iter).second->GetPlayer())
{
if (data->GetOpcode() == SMSG_MESSAGECHAT)//override whisperguid with actual player's guid
- data->put<uint64>(1+4+8+4+4+(int32)(strlen(source->GetName())+1), uint64(plr->GetGUID()));
- if (plr->GetSession() && (!team || Team(plr->GetTeam()) == team) && (!gmOnly || plr->isGameMaster()))
- plr->GetSession()->SendPacket(data);
+ data->put<uint64>(1+4+8+4+4+(int32)(strlen(source->GetName())+1), uint64(player->GetGUID()));
+ if (player->GetSession() && (!team || Team(player->GetTeam()) == team) && (!gmOnly || player->isGameMaster()))
+ player->GetSession()->SendPacket(data);
}
}
return;
diff --git a/src/server/game/Tools/PlayerDump.cpp b/src/server/game/Tools/PlayerDump.cpp
index 92fa001fe46..0c3fd957165 100644
--- a/src/server/game/Tools/PlayerDump.cpp
+++ b/src/server/game/Tools/PlayerDump.cpp
@@ -443,6 +443,10 @@ DumpReturn PlayerDumpReader::LoadDump(const std::string& file, uint32 account, s
typedef PetIds::value_type PetIdsPair;
PetIds petids;
+ uint8 gender = GENDER_NONE;
+ uint8 race = RACE_NONE;
+ uint8 playerClass = 0;
+
SQLTransaction trans = CharacterDatabase.BeginTransaction();
while (!feof(fin))
{
@@ -512,6 +516,9 @@ DumpReturn PlayerDumpReader::LoadDump(const std::string& file, uint32 account, s
if (!changenth(line, 2, chraccount)) // characters.account update
ROLLBACK(DUMP_FILE_BROKEN);
+ race = uint8(atol(getnth(line, 4).c_str()));
+ playerClass = uint8(atol(getnth(line, 5).c_str()));
+ gender = uint8(atol(getnth(line, 6).c_str()));
if (name == "")
{
// check if the original name already exists
@@ -520,10 +527,8 @@ DumpReturn PlayerDumpReader::LoadDump(const std::string& file, uint32 account, s
result = CharacterDatabase.PQuery("SELECT 1 FROM characters WHERE name = '%s'", name.c_str());
if (result)
- {
if (!changenth(line, 37, "1")) // characters.at_login set to "rename on login"
ROLLBACK(DUMP_FILE_BROKEN);
- }
}
else if (!changenth(line, 3, name.c_str())) // characters.name
ROLLBACK(DUMP_FILE_BROKEN);
@@ -654,6 +659,9 @@ DumpReturn PlayerDumpReader::LoadDump(const std::string& file, uint32 account, s
CharacterDatabase.CommitTransaction(trans);
+ // in case of name conflict player has to rename at login anyway
+ sWorld->AddCharacterNameData(guid, name, gender, race, playerClass);
+
sObjectMgr->m_hiItemGuid += items.size();
sObjectMgr->m_mailid += mails.size();
@@ -664,4 +672,3 @@ DumpReturn PlayerDumpReader::LoadDump(const std::string& file, uint32 account, s
return DUMP_SUCCESS;
}
-
diff --git a/src/server/game/World/World.cpp b/src/server/game/World/World.cpp
index 28657faedb1..8aca4563b91 100755
--- a/src/server/game/World/World.cpp
+++ b/src/server/game/World/World.cpp
@@ -2746,22 +2746,18 @@ void World::UpdateMaxSessionCounters()
void World::LoadDBVersion()
{
- QueryResult result = WorldDatabase.Query("SELECT db_version, script_version, cache_id FROM version LIMIT 1");
+ QueryResult result = WorldDatabase.Query("SELECT db_version, cache_id FROM version LIMIT 1");
if (result)
{
Field* fields = result->Fetch();
m_DBVersion = fields[0].GetString();
- m_CreatureEventAIVersion = fields[1].GetString();
// will be overwrite by config values if different and non-0
- m_int_configs[CONFIG_CLIENTCACHE_VERSION] = fields[2].GetUInt32();
+ m_int_configs[CONFIG_CLIENTCACHE_VERSION] = fields[1].GetUInt32();
}
if (m_DBVersion.empty())
m_DBVersion = "Unknown world database.";
-
- if (m_CreatureEventAIVersion.empty())
- m_CreatureEventAIVersion = "Unknown creature EventAI.";
}
void World::ProcessStartEvent()
@@ -2873,7 +2869,7 @@ void World::LoadCharacterNameData()
sLog->outString("Loaded name data for %u characters", count);
}
-void World::AddCharacterNameData(uint32 guid, const std::string& name, uint8 gender, uint8 race, uint8 playerClass)
+void World::AddCharacterNameData(uint32 guid, std::string const& name, uint8 gender, uint8 race, uint8 playerClass)
{
CharacterNameData& data = _characterNameDataMap[guid];
data.m_name = name;
@@ -2882,18 +2878,22 @@ void World::AddCharacterNameData(uint32 guid, const std::string& name, uint8 gen
data.m_class = playerClass;
}
-void World::UpdateCharacterNameData(uint32 guid, const std::string& name, uint8 gender, uint8 race)
+void World::UpdateCharacterNameData(uint32 guid, std::string const& name, uint8 gender /*= GENDER_NONE*/, uint8 race /*= RACE_NONE*/)
{
std::map<uint32, CharacterNameData>::iterator itr = _characterNameDataMap.find(guid);
if (itr == _characterNameDataMap.end())
return;
+
itr->second.m_name = name;
- itr->second.m_gender = gender;
- if(race != RACE_NONE)
+
+ if (gender != GENDER_NONE)
+ itr->second.m_gender = gender;
+
+ if (race != RACE_NONE)
itr->second.m_race = race;
}
-const CharacterNameData* World::GetCharacterNameData(uint32 guid) const
+CharacterNameData const* World::GetCharacterNameData(uint32 guid) const
{
std::map<uint32, CharacterNameData>::const_iterator itr = _characterNameDataMap.find(guid);
if (itr != _characterNameDataMap.end())
diff --git a/src/server/game/World/World.h b/src/server/game/World/World.h
index 06dc0066bb4..f643ae60287 100755
--- a/src/server/game/World/World.h
+++ b/src/server/game/World/World.h
@@ -722,10 +722,9 @@ class World
LocaleConstant GetAvailableDbcLocale(LocaleConstant locale) const { if (m_availableDbcLocaleMask & (1 << locale)) return locale; else return m_defaultDbcLocale; }
- //used World DB version
+ // used World DB version
void LoadDBVersion();
char const* GetDBVersion() const { return m_DBVersion.c_str(); }
- char const* GetCreatureEventAIVersion() const { return m_CreatureEventAIVersion.c_str(); }
void RecordTimeDiff(const char * text, ...);
@@ -739,9 +738,9 @@ class World
bool isEventKillStart;
- const CharacterNameData* GetCharacterNameData(uint32 guid) const;
- void AddCharacterNameData(uint32 guid, const std::string& name, uint8 gender, uint8 race, uint8 playerClass);
- void UpdateCharacterNameData(uint32 guid, const std::string& name, uint8 gender, uint8 race = RACE_NONE);
+ CharacterNameData const* GetCharacterNameData(uint32 guid) const;
+ void AddCharacterNameData(uint32 guid, std::string const& name, uint8 gender, uint8 race, uint8 playerClass);
+ void UpdateCharacterNameData(uint32 guid, std::string const& name, uint8 gender = GENDER_NONE, uint8 race = RACE_NONE);
void DeleteCharaceterNameData(uint32 guid) { _characterNameDataMap.erase(guid); }
uint32 GetCleaningFlags() const { return m_CleaningFlags; }
@@ -821,13 +820,12 @@ class World
//Player Queue
Queue m_QueuedPlayer;
- //sessions that are added async
+ // sessions that are added async
void AddSession_(WorldSession* s);
ACE_Based::LockedQueue<WorldSession*, ACE_Thread_Mutex> addSessQueue;
- //used versions
+ // used versions
std::string m_DBVersion;
- std::string m_CreatureEventAIVersion;
std::list<std::string> m_Autobroadcasts;
diff --git a/src/server/scripts/Commands/cs_account.cpp b/src/server/scripts/Commands/cs_account.cpp
index 80dd2dc366a..ae3250ad7b7 100644
--- a/src/server/scripts/Commands/cs_account.cpp
+++ b/src/server/scripts/Commands/cs_account.cpp
@@ -473,7 +473,7 @@ public:
LoginDatabase.PExecute("DELETE FROM account_access WHERE id = '%u' AND (RealmID = '%d' OR RealmID = '-1')", targetAccountId, realmID);
if (gm != 0)
- LoginDatabase.PExecute("INSERT INTO account_access VALUES ('%u', '%d', '%d')", targetAccountId, gm, realmID);
+ LoginDatabase.PExecute("INSERT INTO account_access VALUES ('%u', '%d', '%d')", targetAccountId, gm, gmRealmID);
handler->PSendSysMessage(LANG_YOU_CHANGE_SECURITY, targetAccountName.c_str(), gm);
return true;
diff --git a/src/server/scripts/Commands/cs_gm.cpp b/src/server/scripts/Commands/cs_gm.cpp
index 2a352e92d01..ab077af0863 100644
--- a/src/server/scripts/Commands/cs_gm.cpp
+++ b/src/server/scripts/Commands/cs_gm.cpp
@@ -117,8 +117,8 @@ public:
bool first = true;
bool footer = false;
- ACE_GUARD_RETURN(ACE_Thread_Mutex, guard, *HashMapHolder<Player>::GetLock(), true);
- HashMapHolder<Player>::MapType& m = sObjectAccessor->GetPlayers();
+ TRINITY_READ_GUARD(HashMapHolder<Player>::LockType, *HashMapHolder<Player>::GetLock());
+ HashMapHolder<Player>::MapType const& m = sObjectAccessor->GetPlayers();
for (HashMapHolder<Player>::MapType::const_iterator itr = m.begin(); itr != m.end(); ++itr)
{
AccountTypes itrSec = itr->second->GetSession()->GetSecurity();
diff --git a/src/server/scripts/Commands/cs_gps.cpp b/src/server/scripts/Commands/cs_gps.cpp
index 2a270527fb8..bafaae465ef 100644
--- a/src/server/scripts/Commands/cs_gps.cpp
+++ b/src/server/scripts/Commands/cs_gps.cpp
@@ -43,16 +43,16 @@ public:
return commandTable;
}
- static bool HandleGPSCommand(ChatHandler* handler, const char *args)
+ static bool HandleGPSCommand(ChatHandler* handler, char const* args)
{
- WorldObject* obj = NULL;
+ WorldObject* object = NULL;
if (*args)
{
uint64 guid = handler->extractGuidFromLink((char*)args);
if (guid)
- obj = (WorldObject*)ObjectAccessor::GetObjectByTypeMask(*handler->GetSession()->GetPlayer(), guid, TYPEMASK_UNIT|TYPEMASK_GAMEOBJECT);
+ object = (WorldObject*)ObjectAccessor::GetObjectByTypeMask(*handler->GetSession()->GetPlayer(), guid, TYPEMASK_UNIT | TYPEMASK_GAMEOBJECT);
- if (!obj)
+ if (!object)
{
handler->SendSysMessage(LANG_PLAYER_NOT_FOUND);
handler->SetSentErrorMessage(true);
@@ -61,71 +61,73 @@ public:
}
else
{
- obj = handler->getSelectedUnit();
+ object = handler->getSelectedUnit();
- if (!obj)
+ if (!object)
{
handler->SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE);
handler->SetSentErrorMessage(true);
return false;
}
}
- CellPair cell_val = Trinity::ComputeCellPair(obj->GetPositionX(), obj->GetPositionY());
- Cell cell(cell_val);
- uint32 zone_id, area_id;
- obj->GetZoneAndAreaId(zone_id, area_id);
+ CellCoord cellCoord = Trinity::ComputeCellCoord(object->GetPositionX(), object->GetPositionY());
+ Cell cell(cellCoord);
- MapEntry const* mapEntry = sMapStore.LookupEntry(obj->GetMapId());
- AreaTableEntry const* zoneEntry = GetAreaEntryByAreaID(zone_id);
- AreaTableEntry const* areaEntry = GetAreaEntryByAreaID(area_id);
+ uint32 zoneId, areaId;
+ object->GetZoneAndAreaId(zoneId, areaId);
- float zone_x = obj->GetPositionX();
- float zone_y = obj->GetPositionY();
+ MapEntry const* mapEntry = sMapStore.LookupEntry(object->GetMapId());
+ AreaTableEntry const* zoneEntry = GetAreaEntryByAreaID(zoneId);
+ AreaTableEntry const* areaEntry = GetAreaEntryByAreaID(areaId);
- Map2ZoneCoordinates(zone_x, zone_y, zone_id);
+ float zoneX = object->GetPositionX();
+ float zoneY = object->GetPositionY();
- Map const* map = obj->GetMap();
- float ground_z = map->GetHeight(obj->GetPositionX(), obj->GetPositionY(), MAX_HEIGHT);
- float floor_z = map->GetHeight(obj->GetPositionX(), obj->GetPositionY(), obj->GetPositionZ());
+ Map2ZoneCoordinates(zoneX, zoneY, zoneId);
- GridPair p = Trinity::ComputeGridPair(obj->GetPositionX(), obj->GetPositionY());
+ Map const* map = object->GetMap();
+ float groundZ = map->GetHeight(object->GetPositionX(), object->GetPositionY(), MAX_HEIGHT);
+ float floorZ = map->GetHeight(object->GetPositionX(), object->GetPositionY(), object->GetPositionZ());
+
+ GridCoord gridCoord = Trinity::ComputeGridCoord(object->GetPositionX(), object->GetPositionY());
// 63? WHY?
- int gx = 63 - p.x_coord;
- int gy = 63 - p.y_coord;
+ int gridX = 63 - gridCoord.x_coord;
+ int gridY = 63 - gridCoord.y_coord;
- uint32 have_map = Map::ExistMap(obj->GetMapId(), gx, gy) ? 1 : 0;
- uint32 have_vmap = Map::ExistVMap(obj->GetMapId(), gx, gy) ? 1 : 0;
+ uint32 haveMap = Map::ExistMap(object->GetMapId(), gridX, gridY) ? 1 : 0;
+ uint32 haveVMap = Map::ExistVMap(object->GetMapId(), gridX, gridY) ? 1 : 0;
- if (have_vmap)
+ if (haveVMap)
{
- if (map->IsOutdoors(obj->GetPositionX(), obj->GetPositionY(), obj->GetPositionZ()))
+ if (map->IsOutdoors(object->GetPositionX(), object->GetPositionY(), object->GetPositionZ()))
handler->PSendSysMessage("You are outdoors");
else
handler->PSendSysMessage("You are indoors");
}
- else handler->PSendSysMessage("no VMAP available for area info");
+ else
+ handler->PSendSysMessage("no VMAP available for area info");
handler->PSendSysMessage(LANG_MAP_POSITION,
- obj->GetMapId(), (mapEntry ? mapEntry->name[handler->GetSessionDbcLocale()] : "<unknown>"),
- zone_id, (zoneEntry ? zoneEntry->area_name[handler->GetSessionDbcLocale()] : "<unknown>"),
- area_id, (areaEntry ? areaEntry->area_name[handler->GetSessionDbcLocale()] : "<unknown>"),
- obj->GetPhaseMask(),
- obj->GetPositionX(), obj->GetPositionY(), obj->GetPositionZ(), obj->GetOrientation(),
- cell.GridX(), cell.GridY(), cell.CellX(), cell.CellY(), obj->GetInstanceId(),
- zone_x, zone_y, ground_z, floor_z, have_map, have_vmap);
-
- LiquidData liquid_status;
- ZLiquidStatus res = map->getLiquidStatus(obj->GetPositionX(), obj->GetPositionY(), obj->GetPositionZ(), MAP_ALL_LIQUIDS, &liquid_status);
- if (res)
- {
- handler->PSendSysMessage(LANG_LIQUID_STATUS, liquid_status.level, liquid_status.depth_level, liquid_status.type, res);
- }
+ object->GetMapId(), (mapEntry ? mapEntry->name[handler->GetSessionDbcLocale()] : "<unknown>"),
+ zoneId, (zoneEntry ? zoneEntry->area_name[handler->GetSessionDbcLocale()] : "<unknown>"),
+ areaId, (areaEntry ? areaEntry->area_name[handler->GetSessionDbcLocale()] : "<unknown>"),
+ object->GetPhaseMask(),
+ object->GetPositionX(), object->GetPositionY(), object->GetPositionZ(), object->GetOrientation(),
+ cell.GridX(), cell.GridY(), cell.CellX(), cell.CellY(), object->GetInstanceId(),
+ zoneX, zoneY, groundZ, floorZ, haveMap, haveVMap);
+
+ LiquidData liquidStatus;
+ ZLiquidStatus status = map->getLiquidStatus(object->GetPositionX(), object->GetPositionY(), object->GetPositionZ(), MAP_ALL_LIQUIDS, &liquidStatus);
+
+ if (status)
+ handler->PSendSysMessage(LANG_LIQUID_STATUS, liquidStatus.level, liquidStatus.depth_level, liquidStatus.type, status);
+
return true;
}
- static bool HandleWPGPSCommand(ChatHandler* handler, const char* /*args*/)
+ static bool HandleWPGPSCommand(ChatHandler* handler, char const* /*args*/)
{
Player* player = handler->GetSession()->GetPlayer();
diff --git a/src/server/scripts/Commands/cs_honor.cpp b/src/server/scripts/Commands/cs_honor.cpp
index 6f44000017d..f6c6d89c0b7 100644
--- a/src/server/scripts/Commands/cs_honor.cpp
+++ b/src/server/scripts/Commands/cs_honor.cpp
@@ -39,12 +39,14 @@ public:
{ "", SEC_GAMEMASTER, false, &HandleHonorAddCommand, "", NULL },
{ NULL, 0, false, NULL, "", NULL }
};
+
static ChatCommand honorCommandTable[] =
{
{ "add", SEC_GAMEMASTER, false, NULL, "", honorAddCommandTable },
{ "update", SEC_GAMEMASTER, false, &HandleHonorUpdateCommand, "", NULL },
{ NULL, 0, false, NULL, "", NULL }
};
+
static ChatCommand commandTable[] =
{
{ "honor", SEC_GAMEMASTER, false, NULL, "", honorCommandTable },
@@ -52,7 +54,8 @@ public:
};
return commandTable;
}
- static bool HandleHonorAddCommand(ChatHandler* handler, const char* args)
+
+ static bool HandleHonorAddCommand(ChatHandler* handler, char const* args)
{
if (!*args)
return false;
@@ -73,7 +76,8 @@ public:
target->RewardHonor(NULL, 1, amount);
return true;
}
- static bool HandleHonorAddKillCommand(ChatHandler* handler, const char* /*args*/)
+
+ static bool HandleHonorAddKillCommand(ChatHandler* handler, char const* /*args*/)
{
Unit* target = handler->getSelectedUnit();
if (!target)
@@ -90,7 +94,8 @@ public:
handler->GetSession()->GetPlayer()->RewardHonor(target, 1);
return true;
}
- static bool HandleHonorUpdateCommand(ChatHandler* handler, const char* /*args*/)
+
+ static bool HandleHonorUpdateCommand(ChatHandler* handler, char const* /*args*/)
{
Player* target = handler->getSelectedPlayer();
if (!target)
diff --git a/src/server/scripts/Commands/cs_learn.cpp b/src/server/scripts/Commands/cs_learn.cpp
index 9eb315b0b6a..d03291d6d5d 100644
--- a/src/server/scripts/Commands/cs_learn.cpp
+++ b/src/server/scripts/Commands/cs_learn.cpp
@@ -37,28 +37,29 @@ public:
{
static ChatCommand learnAllMyCommandTable[] =
{
- { "class", SEC_ADMINISTRATOR, false, &HandleLearnAllMyClassCommand, "", NULL },
- { "pettalents", SEC_ADMINISTRATOR, false, &HandleLearnAllMyPetTalentsCommand, "", NULL },
- { "spells", SEC_ADMINISTRATOR, false, &HandleLearnAllMySpellsCommand, "", NULL },
- { "talents", SEC_ADMINISTRATOR, false, &HandleLearnAllMyTalentsCommand, "", NULL },
- { NULL, 0, false, NULL, "", NULL }
+ { "class", SEC_ADMINISTRATOR, false, &HandleLearnAllMyClassCommand, "", NULL },
+ { "pettalents", SEC_ADMINISTRATOR, false, &HandleLearnAllMyPetTalentsCommand, "", NULL },
+ { "spells", SEC_ADMINISTRATOR, false, &HandleLearnAllMySpellsCommand, "", NULL },
+ { "talents", SEC_ADMINISTRATOR, false, &HandleLearnAllMyTalentsCommand, "", NULL },
+ { NULL, 0, false, NULL, "", NULL }
};
+
static ChatCommand learnAllCommandTable[] =
{
- { "my", SEC_ADMINISTRATOR, false, NULL, "", learnAllMyCommandTable },
- { "gm", SEC_GAMEMASTER, false, &HandleLearnAllGMCommand, "", NULL },
- { "crafts", SEC_GAMEMASTER, false, &HandleLearnAllCraftsCommand, "", NULL },
- { "default", SEC_MODERATOR, false, &HandleLearnAllDefaultCommand, "", NULL },
- { "lang", SEC_MODERATOR, false, &HandleLearnAllLangCommand, "", NULL },
- { "recipes", SEC_GAMEMASTER, false, &HandleLearnAllRecipesCommand, "", NULL },
- { NULL, 0, false, NULL, "", NULL }
+ { "my", SEC_ADMINISTRATOR, false, NULL, "", learnAllMyCommandTable },
+ { "gm", SEC_GAMEMASTER, false, &HandleLearnAllGMCommand, "", NULL },
+ { "crafts", SEC_GAMEMASTER, false, &HandleLearnAllCraftsCommand, "", NULL },
+ { "default", SEC_MODERATOR, false, &HandleLearnAllDefaultCommand, "", NULL },
+ { "lang", SEC_MODERATOR, false, &HandleLearnAllLangCommand, "", NULL },
+ { "recipes", SEC_GAMEMASTER, false, &HandleLearnAllRecipesCommand, "", NULL },
+ { NULL, 0, false, NULL, "", NULL }
};
static ChatCommand learnCommandTable[] =
{
- { "all", SEC_ADMINISTRATOR, false, NULL, "", learnAllCommandTable },
- { "", SEC_ADMINISTRATOR, false, &HandleLearnCommand, "", NULL },
- { NULL, 0, false, NULL, "", NULL }
+ { "all", SEC_ADMINISTRATOR, false, NULL, "", learnAllCommandTable },
+ { "", SEC_ADMINISTRATOR, false, &HandleLearnCommand, "", NULL },
+ { NULL, 0, false, NULL, "", NULL }
};
static ChatCommand commandTable[] =
@@ -68,7 +69,8 @@ public:
};
return commandTable;
}
- static bool HandleLearnCommand(ChatHandler* handler, const char* args)
+
+ static bool HandleLearnCommand(ChatHandler* handler, char const* args)
{
Player* targetPlayer = handler->getSelectedPlayer();
@@ -84,8 +86,8 @@ public:
if (!spell || !sSpellMgr->GetSpellInfo(spell))
return false;
- char const* allStr = strtok(NULL, " ");
- bool allRanks = allStr ? (strncmp(allStr, "all", strlen(allStr)) == 0) : false;
+ char const* all = strtok(NULL, " ");
+ bool allRanks = all ? (strncmp(all, "all", strlen(all)) == 0) : false;
SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spell);
if (!spellInfo || !SpellMgr::IsSpellValid(spellInfo, handler->GetSession()->GetPlayer()))
@@ -110,14 +112,14 @@ public:
else
targetPlayer->learnSpell(spell, false);
- uint32 first_spell = sSpellMgr->GetFirstSpellInChain(spell);
- if (GetTalentSpellCost(first_spell))
+ uint32 firstSpell = sSpellMgr->GetFirstSpellInChain(spell);
+ if (GetTalentSpellCost(firstSpell))
targetPlayer->SendTalentsInfoData(false);
return true;
}
- static bool HandleLearnAllGMCommand(ChatHandler* handler, const char* /*args*/)
+ static bool HandleLearnAllGMCommand(ChatHandler* handler, char const* /*args*/)
{
for (uint32 i = 0; i < sSpellMgr->GetSpellInfoStoreSize(); ++i)
{
@@ -135,19 +137,19 @@ public:
return true;
}
- static bool HandleLearnAllMyClassCommand(ChatHandler* handler, const char* /*args*/)
+ static bool HandleLearnAllMyClassCommand(ChatHandler* handler, char const* /*args*/)
{
HandleLearnAllMySpellsCommand(handler, "");
HandleLearnAllMyTalentsCommand(handler, "");
return true;
}
- static bool HandleLearnAllMySpellsCommand(ChatHandler* handler, const char* /*args*/)
+ static bool HandleLearnAllMySpellsCommand(ChatHandler* handler, char const* /*args*/)
{
- ChrClassesEntry const* clsEntry = sChrClassesStore.LookupEntry(handler->GetSession()->GetPlayer()->getClass());
- if (!clsEntry)
+ ChrClassesEntry const* classEntry = sChrClassesStore.LookupEntry(handler->GetSession()->GetPlayer()->getClass());
+ if (!classEntry)
return true;
- uint32 family = clsEntry->spellfamily;
+ uint32 family = classEntry->spellfamily;
for (uint32 i = 0; i < sSkillLineAbilityStore.GetNumRows(); ++i)
{
@@ -172,8 +174,8 @@ public:
continue;
// skip spells with first rank learned as talent (and all talents then also)
- uint32 first_rank = sSpellMgr->GetFirstSpellInChain(spellInfo->Id);
- if (GetTalentSpellCost(first_rank) > 0)
+ uint32 firstRank = sSpellMgr->GetFirstSpellInChain(spellInfo->Id);
+ if (GetTalentSpellCost(firstRank) > 0)
continue;
// skip broken spells
@@ -187,7 +189,7 @@ public:
return true;
}
- static bool HandleLearnAllMyTalentsCommand(ChatHandler* handler, const char* /*args*/)
+ static bool HandleLearnAllMyTalentsCommand(ChatHandler* handler, char const* /*args*/)
{
Player* player = handler->GetSession()->GetPlayer();
uint32 classMask = player->getClassMask();
@@ -207,7 +209,7 @@ public:
// search highest talent rank
uint32 spellId = 0;
- for (int8 rank = MAX_TALENT_RANK-1; rank >= 0; --rank)
+ for (int8 rank = MAX_TALENT_RANK - 1; rank >= 0; --rank)
{
if (talentInfo->RankID[rank] != 0)
{
@@ -234,7 +236,7 @@ public:
return true;
}
- static bool HandleLearnAllMyPetTalentsCommand(ChatHandler* handler, const char* /*args*/)
+ static bool HandleLearnAllMyPetTalentsCommand(ChatHandler* handler, char const* /*args*/)
{
Player* player = handler->GetSession()->GetPlayer();
@@ -246,23 +248,23 @@ public:
return false;
}
- CreatureTemplate const* ci = pet->GetCreatureInfo();
- if (!ci)
+ CreatureTemplate const* creatureInfo = pet->GetCreatureInfo();
+ if (!creatureInfo)
{
handler->SendSysMessage(LANG_WRONG_PET_TYPE);
handler->SetSentErrorMessage(true);
return false;
}
- CreatureFamilyEntry const* pet_family = sCreatureFamilyStore.LookupEntry(ci->family);
- if (!pet_family)
+ CreatureFamilyEntry const* petFamily = sCreatureFamilyStore.LookupEntry(creatureInfo->family);
+ if (!petFamily)
{
handler->SendSysMessage(LANG_WRONG_PET_TYPE);
handler->SetSentErrorMessage(true);
return false;
}
- if (pet_family->petTalentType < 0) // not hunter pet
+ if (petFamily->petTalentType < 0) // not hunter pet
{
handler->SendSysMessage(LANG_WRONG_PET_TYPE);
handler->SetSentErrorMessage(true);
@@ -280,30 +282,30 @@ public:
continue;
// prevent learn talent for different family (cheating)
- if (((1 << pet_family->petTalentType) & talentTabInfo->petTalentMask) == 0)
+ if (((1 << petFamily->petTalentType) & talentTabInfo->petTalentMask) == 0)
continue;
// search highest talent rank
- uint32 spellid = 0;
+ uint32 spellId = 0;
for (int8 rank = MAX_TALENT_RANK-1; rank >= 0; --rank)
{
if (talentInfo->RankID[rank] != 0)
{
- spellid = talentInfo->RankID[rank];
+ spellId = talentInfo->RankID[rank];
break;
}
}
- if (!spellid) // ??? none spells in talent
+ if (!spellId) // ??? none spells in talent
continue;
- SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellid);
+ SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellId);
if (!spellInfo || !SpellMgr::IsSpellValid(spellInfo, handler->GetSession()->GetPlayer(), false))
continue;
// learn highest rank of talent and learn all non-talent spell ranks (recursive by tree)
- pet->learnSpellHighRank(spellid);
+ pet->learnSpellHighRank(spellId);
}
pet->SetFreeTalentPoints(0);
@@ -312,7 +314,7 @@ public:
return true;
}
- static bool HandleLearnAllLangCommand(ChatHandler* handler, const char* /*args*/)
+ static bool HandleLearnAllLangCommand(ChatHandler* handler, char const* /*args*/)
{
// skipping UNIVERSAL language (0)
for (uint8 i = 1; i < LANGUAGES_COUNT; ++i)
@@ -322,7 +324,7 @@ public:
return true;
}
- static bool HandleLearnAllDefaultCommand(ChatHandler* handler, const char* args)
+ static bool HandleLearnAllDefaultCommand(ChatHandler* handler, char const* args)
{
Player* target;
if (!handler->extractPlayerTarget((char*)args, &target))
@@ -335,9 +337,8 @@ public:
return true;
}
- static bool HandleLearnAllCraftsCommand(ChatHandler* handler, const char* /*args*/)
+ static bool HandleLearnAllCraftsCommand(ChatHandler* handler, char const* /*args*/)
{
-
for (uint32 i = 0; i < sSkillLineStore.GetNumRows(); ++i)
{
SkillLineEntry const* skillInfo = sSkillLineStore.LookupEntry(i);
@@ -355,7 +356,7 @@ public:
return true;
}
- static bool HandleLearnAllRecipesCommand(ChatHandler* handler, const char* args)
+ static bool HandleLearnAllRecipesCommand(ChatHandler* handler, char const* args)
{
// Learns all recipes of specified profession and sets skill to max
// Example: .learn all_recipes enchanting
@@ -370,13 +371,13 @@ public:
if (!*args)
return false;
- std::wstring wnamepart;
+ std::wstring namePart;
- if (!Utf8toWStr(args, wnamepart))
+ if (!Utf8toWStr(args, namePart))
return false;
// converting string that we try to find to lower case
- wstrToLower(wnamepart);
+ wstrToLower(namePart);
std::string name;
@@ -392,29 +393,29 @@ public:
!skillInfo->canLink) // only prof with recipes have set
continue;
- int loc = handler->GetSessionDbcLocale();
- name = skillInfo->name[loc];
+ int locale = handler->GetSessionDbcLocale();
+ name = skillInfo->name[locale];
if (name.empty())
continue;
- if (!Utf8FitTo(name, wnamepart))
+ if (!Utf8FitTo(name, namePart))
{
- loc = 0;
- for (; loc < TOTAL_LOCALES; ++loc)
+ locale = 0;
+ for (; locale < TOTAL_LOCALES; ++locale)
{
- if (loc == handler->GetSessionDbcLocale())
+ if (locale == handler->GetSessionDbcLocale())
continue;
- name = skillInfo->name[loc];
+ name = skillInfo->name[locale];
if (name.empty())
continue;
- if (Utf8FitTo(name, wnamepart))
+ if (Utf8FitTo(name, namePart))
break;
}
}
- if (loc < TOTAL_LOCALES)
+ if (locale < TOTAL_LOCALES)
{
targetSkillInfo = skillInfo;
break;
@@ -431,7 +432,8 @@ public:
handler->PSendSysMessage(LANG_COMMAND_LEARN_ALL_RECIPES, name.c_str());
return true;
}
- static void HandleLearnSkillRecipesHelper(Player* player, uint32 skill_id)
+
+ static void HandleLearnSkillRecipesHelper(Player* player, uint32 skillId)
{
uint32 classmask = player->getClassMask();
@@ -442,7 +444,7 @@ public:
continue;
// wrong skill
- if (skillLine->skillId != skill_id)
+ if (skillLine->skillId != skillId)
continue;
// not high rank
diff --git a/src/server/scripts/Commands/cs_npc.cpp b/src/server/scripts/Commands/cs_npc.cpp
index 0fecfa83221..20d0994b911 100644
--- a/src/server/scripts/Commands/cs_npc.cpp
+++ b/src/server/scripts/Commands/cs_npc.cpp
@@ -155,7 +155,7 @@ public:
}
//add item in vendorlist
- static bool HandleNpcAddVendorItemCommand(ChatHandler* handler, const char* args)
+ static bool HandleNpcAddVendorItemCommand(ChatHandler* handler, char const* args)
{
if (!*args)
return false;
@@ -168,7 +168,11 @@ public:
return false;
}
- uint32 itemId = atol(pitem);
+ int32 item_int = atol(pitem);
+ if (item_int <= 0)
+ return false;
+
+ uint32 itemId = item_int;
char* fmaxcount = strtok(NULL, " "); //add maxcount, default: 0
uint32 maxcount = 0;
diff --git a/src/server/scripts/Commands/cs_quest.cpp b/src/server/scripts/Commands/cs_quest.cpp
index 31d8cd3c8f2..3d437e473f7 100644
--- a/src/server/scripts/Commands/cs_quest.cpp
+++ b/src/server/scripts/Commands/cs_quest.cpp
@@ -128,13 +128,13 @@ public:
// remove all quest entries for 'entry' from quest log
for (uint8 slot = 0; slot < MAX_QUEST_LOG_SIZE; ++slot)
{
- uint32 quest = player->GetQuestSlotQuestId(slot);
- if (quest == entry)
+ uint32 logQuest = player->GetQuestSlotQuestId(slot);
+ if (logQuest == entry)
{
player->SetQuestSlot(slot, 0);
// we ignore unequippable quest items in this case, its' still be equipped
- player->TakeQuestSourceItem(quest, false);
+ player->TakeQuestSourceItem(logQuest, false);
}
}
@@ -176,8 +176,8 @@ public:
// Add quest items for quests that require items
for (uint8 x = 0; x < QUEST_ITEM_OBJECTIVES_COUNT; ++x)
{
- uint32 id = quest->ReqItemId[x];
- uint32 count = quest->ReqItemCount[x];
+ uint32 id = quest->RequiredItemId[x];
+ uint32 count = quest->RequiredItemCount[x];
if (!id || !count)
continue;
@@ -195,10 +195,10 @@ public:
// All creature/GO slain/casted (not required, but otherwise it will display "Creature slain 0/10")
for (uint8 i = 0; i < QUEST_OBJECTIVES_COUNT; ++i)
{
- int32 creature = quest->ReqCreatureOrGOId[i];
- uint32 creaturecount = quest->ReqCreatureOrGOCount[i];
+ int32 creature = quest->RequiredNpcOrGo[i];
+ uint32 creaturecount = quest->RequiredNpcOrGoCount[i];
- if (uint32 spell_id = quest->ReqSpell[i])
+ if (uint32 spell_id = quest->RequiredSpellCast[i])
{
for (uint16 z = 0; z < creaturecount; ++z)
player->CastedCreatureOrGO(creature, 0, spell_id);
diff --git a/src/server/scripts/Commands/cs_tele.cpp b/src/server/scripts/Commands/cs_tele.cpp
index 17c076f903c..ef4ddf17476 100644
--- a/src/server/scripts/Commands/cs_tele.cpp
+++ b/src/server/scripts/Commands/cs_tele.cpp
@@ -125,6 +125,29 @@ public:
if (!handler->extractPlayerTarget(nameStr, &target, &target_guid, &target_name))
return false;
+ if (strcmp(teleStr, "$home") == 0) // References target's homebind
+ {
+ if (target)
+ target->TeleportTo(target->m_homebindMapId, target->m_homebindX, target->m_homebindY, target->m_homebindZ, target->GetOrientation());
+ else
+ {
+ QueryResult resultDB = CharacterDatabase.PQuery("SELECT mapId, zoneId, posX, posY, posZ FROM character_homebind WHERE guid = %u", target_guid);
+ if (resultDB)
+ {
+ Field* fieldsDB = resultDB->Fetch();
+ uint32 mapId = fieldsDB[0].GetUInt32();
+ uint32 zoneId = fieldsDB[1].GetUInt32();
+ float posX = fieldsDB[2].GetFloat();
+ float posY = fieldsDB[3].GetFloat();
+ float posZ = fieldsDB[4].GetFloat();
+
+ Player::SavePositionInDB(mapId, posX, posY, posZ, 0, zoneId, target_guid);
+ }
+ }
+
+ return true;
+ }
+
// id, or string, or [name] Shift-click form |color|Htele:id|h[name]|h|r
GameTele const* tele = handler->extractGameTeleFromLink(teleStr);
if (!tele)
@@ -187,8 +210,8 @@ public:
if (!*args)
return false;
- Player* player = handler->getSelectedPlayer();
- if (!player)
+ Player* target = handler->getSelectedPlayer();
+ if (!target)
{
handler->SendSysMessage(LANG_NO_CHAR_SELECTED);
handler->SetSentErrorMessage(true);
@@ -196,7 +219,7 @@ public:
}
// check online security
- if (handler->HasLowerSecurity(player, 0))
+ if (handler->HasLowerSecurity(target, 0))
return false;
// id, or string, or [name] Shift-click form |color|Htele:id|h[name]|h|r
@@ -216,9 +239,9 @@ public:
return false;
}
- std::string nameLink = handler->GetNameLink(player);
+ std::string nameLink = handler->GetNameLink(target);
- Group* grp = player->GetGroup();
+ Group* grp = target->GetGroup();
if (!grp)
{
handler->PSendSysMessage(LANG_NOT_IN_GROUP, nameLink.c_str());
@@ -228,38 +251,38 @@ public:
for (GroupReference* itr = grp->GetFirstMember(); itr != NULL; itr = itr->next())
{
- Player* pl = itr->getSource();
+ Player* player = itr->getSource();
- if (!pl || !pl->GetSession())
+ if (!player || !player->GetSession())
continue;
// check online security
- if (handler->HasLowerSecurity(pl, 0))
+ if (handler->HasLowerSecurity(player, 0))
return false;
- std::string plNameLink = handler->GetNameLink(pl);
+ std::string plNameLink = handler->GetNameLink(player);
- if (pl->IsBeingTeleported())
+ if (player->IsBeingTeleported())
{
handler->PSendSysMessage(LANG_IS_TELEPORTED, plNameLink.c_str());
continue;
}
handler->PSendSysMessage(LANG_TELEPORTING_TO, plNameLink.c_str(), "", tele->name.c_str());
- if (handler->needReportToTarget(pl))
- (ChatHandler(pl)).PSendSysMessage(LANG_TELEPORTED_TO_BY, nameLink.c_str());
+ if (handler->needReportToTarget(player))
+ (ChatHandler(player)).PSendSysMessage(LANG_TELEPORTED_TO_BY, nameLink.c_str());
// stop flight if need
- if (pl->isInFlight())
+ if (player->isInFlight())
{
- pl->GetMotionMaster()->MovementExpired();
- pl->CleanupAfterTaxiFlight();
+ player->GetMotionMaster()->MovementExpired();
+ player->CleanupAfterTaxiFlight();
}
// save only in non-flight case
else
- pl->SaveRecallPosition();
+ player->SaveRecallPosition();
- pl->TeleportTo(tele->mapId, tele->position_x, tele->position_y, tele->position_z, tele->orientation);
+ player->TeleportTo(tele->mapId, tele->position_x, tele->position_y, tele->position_z, tele->orientation);
}
return true;
diff --git a/src/server/scripts/Commands/cs_wp.cpp b/src/server/scripts/Commands/cs_wp.cpp
index 75904764f23..ebeb7b8f4f4 100644
--- a/src/server/scripts/Commands/cs_wp.cpp
+++ b/src/server/scripts/Commands/cs_wp.cpp
@@ -480,55 +480,43 @@ public:
}
// The visual waypoint
- Creature* wpCreature = NULL;
wpGuid = target->GetGUIDLow();
- // Did the user select a visual spawnpoint?
- if (wpGuid)
- wpCreature = handler->GetSession()->GetPlayer()->GetMap()->GetCreature(MAKE_NEW_GUID(wpGuid, VISUAL_WAYPOINT, HIGHGUID_UNIT));
- // attempt check creature existence by DB data
- else
- {
- handler->PSendSysMessage(LANG_WAYPOINT_CREATNOTFOUND, wpGuid);
- return false;
- }
// User did select a visual waypoint?
+
// Check the creature
- if (wpCreature->GetEntry() == VISUAL_WAYPOINT)
- {
- QueryResult result = WorldDatabase.PQuery("SELECT id, point FROM waypoint_data WHERE wpguid = %u", wpGuid);
+ QueryResult result = WorldDatabase.PQuery("SELECT id, point FROM waypoint_data WHERE wpguid = %u", wpGuid);
+ if (!result)
+ {
+ handler->PSendSysMessage(LANG_WAYPOINT_NOTFOUNDSEARCH, target->GetGUIDLow());
+ // Select waypoint number from database
+ // Since we compare float values, we have to deal with
+ // some difficulties.
+ // Here we search for all waypoints that only differ in one from 1 thousand
+ // (0.001) - There is no other way to compare C++ floats with mySQL floats
+ // See also: http://dev.mysql.com/doc/refman/5.0/en/problems-with-float.html
+ const char* maxDIFF = "0.01";
+ result = WorldDatabase.PQuery("SELECT id, point FROM waypoint_data WHERE (abs(position_x - %f) <= %s) and (abs(position_y - %f) <= %s) and (abs(position_z - %f) <= %s)",
+ target->GetPositionX(), maxDIFF, target->GetPositionY(), maxDIFF, target->GetPositionZ(), maxDIFF);
if (!result)
{
- handler->PSendSysMessage(LANG_WAYPOINT_NOTFOUNDSEARCH, target->GetGUIDLow());
- // Select waypoint number from database
- // Since we compare float values, we have to deal with
- // some difficulties.
- // Here we search for all waypoints that only differ in one from 1 thousand
- // (0.001) - There is no other way to compare C++ floats with mySQL floats
- // See also: http://dev.mysql.com/doc/refman/5.0/en/problems-with-float.html
- const char* maxDIFF = "0.01";
- result = WorldDatabase.PQuery("SELECT id, point FROM waypoint_data WHERE (abs(position_x - %f) <= %s) and (abs(position_y - %f) <= %s) and (abs(position_z - %f) <= %s)",
- wpCreature->GetPositionX(), maxDIFF, wpCreature->GetPositionY(), maxDIFF, wpCreature->GetPositionZ(), maxDIFF);
- if (!result)
- {
- handler->PSendSysMessage(LANG_WAYPOINT_NOTFOUNDDBPROBLEM, wpGuid);
- return true;
- }
- }
-
- do
- {
- Field* fields = result->Fetch();
- pathid = fields[0].GetUInt32();
- point = fields[1].GetUInt32();
+ handler->PSendSysMessage(LANG_WAYPOINT_NOTFOUNDDBPROBLEM, wpGuid);
+ return true;
}
- while (result->NextRow());
+ }
- // We have the waypoint number and the GUID of the "master npc"
- // Text is enclosed in "<>", all other arguments not
- arg_str = strtok((char*)NULL, " ");
+ do
+ {
+ Field* fields = result->Fetch();
+ pathid = fields[0].GetUInt32();
+ point = fields[1].GetUInt32();
}
+ while (result->NextRow());
+
+ // We have the waypoint number and the GUID of the "master npc"
+ // Text is enclosed in "<>", all other arguments not
+ arg_str = strtok((char*)NULL, " ");
// Check for argument
if (show != "del" && show != "move" && arg_str == NULL)
@@ -795,7 +783,7 @@ public:
if (target)
{
wpCreature->SetDisplayId(target->GetDisplayId());
- wpCreature->SetFloatValue(OBJECT_FIELD_SCALE_X, 0.5);
+ wpCreature->SetFloatValue(OBJECT_FIELD_SCALE_X, 0.5f);
wpCreature->SetLevel(point > STRONG_MAX_LEVEL ? STRONG_MAX_LEVEL : point);
}
}
@@ -842,7 +830,7 @@ public:
if (target)
{
creature->SetDisplayId(target->GetDisplayId());
- creature->SetFloatValue(OBJECT_FIELD_SCALE_X, 0.5);
+ creature->SetFloatValue(OBJECT_FIELD_SCALE_X, 0.5f);
}
return true;
@@ -858,7 +846,7 @@ public:
else
Maxpoint = 0;
- result = WorldDatabase.PQuery("SELECT position_x, position_y, position_z FROM waypoint_data WHERE point ='%u' AND id = '%u'", Maxpoint, pathid);
+ result = WorldDatabase.PQuery("SELECT position_x, position_y, position_z, orientation FROM waypoint_data WHERE point ='%u' AND id = '%u'", Maxpoint, pathid);
if (!result)
{
handler->PSendSysMessage(LANG_WAYPOINT_NOTFOUNDLAST, pathid);
@@ -866,13 +854,13 @@ public:
return false;
}
Field* fields = result->Fetch();
- float x = fields[0].GetFloat();
- float y = fields[1].GetFloat();
- float z = fields[2].GetFloat();
+ float x = fields[0].GetFloat();
+ float y = fields[1].GetFloat();
+ float z = fields[2].GetFloat();
+ float o = fields[3].GetFloat();
uint32 id = VISUAL_WAYPOINT;
Player* chr = handler->GetSession()->GetPlayer();
- float o = chr->GetOrientation();
Map* map = chr->GetMap();
Creature* creature = new Creature;
@@ -890,7 +878,7 @@ public:
if (target)
{
creature->SetDisplayId(target->GetDisplayId());
- creature->SetFloatValue(OBJECT_FIELD_SCALE_X, 0.5);
+ creature->SetFloatValue(OBJECT_FIELD_SCALE_X, 0.5f);
}
return true;
diff --git a/src/server/scripts/EasternKingdoms/Karazhan/boss_netherspite.cpp b/src/server/scripts/EasternKingdoms/Karazhan/boss_netherspite.cpp
index 2bcfab80056..aa0fee873e1 100644
--- a/src/server/scripts/EasternKingdoms/Karazhan/boss_netherspite.cpp
+++ b/src/server/scripts/EasternKingdoms/Karazhan/boss_netherspite.cpp
@@ -136,9 +136,9 @@ public:
{
uint8 r = rand()%4;
uint8 pos[3];
- pos[RED_PORTAL] = (r%2 ? (r>1 ? 2: 1): 0);
- pos[GREEN_PORTAL] = (r%2 ? 0: (r>1 ? 2: 1));
- pos[BLUE_PORTAL] = (r>1 ? 1: 2); // Blue Portal not on the left side (0)
+ pos[RED_PORTAL] = ((r % 2) ? (r > 1 ? 2 : 1) : 0);
+ pos[GREEN_PORTAL] = ((r % 2) ? 0 : (r > 1 ? 2 : 1));
+ pos[BLUE_PORTAL] = (r > 1 ? 1 : 2); // Blue Portal not on the left side (0)
for (int i=0; i<3; ++i)
if (Creature* portal = me->SummonCreature(PortalID[i], PortalCoord[pos[i]][0], PortalCoord[pos[i]][1], PortalCoord[pos[i]][2], 0, TEMPSUMMON_TIMED_DESPAWN, 60000))
diff --git a/src/server/scripts/EasternKingdoms/MagistersTerrace/boss_priestess_delrissa.cpp b/src/server/scripts/EasternKingdoms/MagistersTerrace/boss_priestess_delrissa.cpp
index 719c42c0a57..55254a3b8ee 100644
--- a/src/server/scripts/EasternKingdoms/MagistersTerrace/boss_priestess_delrissa.cpp
+++ b/src/server/scripts/EasternKingdoms/MagistersTerrace/boss_priestess_delrissa.cpp
@@ -201,7 +201,8 @@ public:
//object already removed, not exist
if (!pAdd)
{
- if (Creature* pAdd = me->SummonCreature((*itr), LackeyLocations[j][0], LackeyLocations[j][1], fZLocation, fOrientation, TEMPSUMMON_CORPSE_DESPAWN, 0))
+ pAdd = me->SummonCreature((*itr), LackeyLocations[j][0], LackeyLocations[j][1], fZLocation, fOrientation, TEMPSUMMON_CORPSE_DESPAWN, 0);
+ if (pAdd)
m_auiLackeyGUID[j] = pAdd->GetGUID();
}
++j;
diff --git a/src/server/scripts/EasternKingdoms/MoltenCore/boss_ragnaros.cpp b/src/server/scripts/EasternKingdoms/MoltenCore/boss_ragnaros.cpp
index 592e0054fa4..4bc3da16651 100644
--- a/src/server/scripts/EasternKingdoms/MoltenCore/boss_ragnaros.cpp
+++ b/src/server/scripts/EasternKingdoms/MoltenCore/boss_ragnaros.cpp
@@ -110,7 +110,7 @@ class boss_ragnaros : public CreatureScript
void KilledUnit(Unit* /*victim*/)
{
- if (urand(0, 99 < 25))
+ if (urand(0, 99) < 25)
DoScriptText(SAY_KILL, me);
}
diff --git a/src/server/scripts/EasternKingdoms/ScarletEnclave/chapter5.cpp b/src/server/scripts/EasternKingdoms/ScarletEnclave/chapter5.cpp
index aea25af87bf..18316d67cd4 100644
--- a/src/server/scripts/EasternKingdoms/ScarletEnclave/chapter5.cpp
+++ b/src/server/scripts/EasternKingdoms/ScarletEnclave/chapter5.cpp
@@ -497,9 +497,9 @@ public:
SetEscortPaused(bOnHold);
}
- void WaypointReached(uint32 i)
+ void WaypointReached(uint32 wpId)
{
- switch (i)
+ switch (wpId)
{
case 0:
me->RemoveUnitMovementFlag(MOVEMENTFLAG_WALKING);
@@ -1173,8 +1173,8 @@ public:
temp->SetSpeed(MOVE_RUN, 3.0f); // workarounds, make Tirion still running
temp->RemoveUnitMovementFlag(MOVEMENTFLAG_WALKING);
temp->GetMotionMaster()->MovePoint(0, LightofDawnLoc[2].x, LightofDawnLoc[2].y, LightofDawnLoc[2].z);
- if (Creature* temp = Unit::GetCreature(*me, uiLichKingGUID))
- temp->Relocate(LightofDawnLoc[28].x, LightofDawnLoc[28].y, LightofDawnLoc[28].z); // workarounds, he should kick back by Tirion, but here we relocate him
+ if (Creature* lktemp = Unit::GetCreature(*me, uiLichKingGUID))
+ lktemp->Relocate(LightofDawnLoc[28].x, LightofDawnLoc[28].y, LightofDawnLoc[28].z); // workarounds, he should kick back by Tirion, but here we relocate him
}
JumpToNextStep(1500);
break;
diff --git a/src/server/scripts/EasternKingdoms/ScarletEnclave/the_scarlet_enclave.cpp b/src/server/scripts/EasternKingdoms/ScarletEnclave/the_scarlet_enclave.cpp
index a61b88a990d..a6bb95995be 100644
--- a/src/server/scripts/EasternKingdoms/ScarletEnclave/the_scarlet_enclave.cpp
+++ b/src/server/scripts/EasternKingdoms/ScarletEnclave/the_scarlet_enclave.cpp
@@ -51,7 +51,9 @@ public:
phase = 0;
me->GetPosition(x, y, z);
- z += 4; x -= 3.5; y -= 5;
+ z += 4.0f;
+ x -= 3.5f;
+ y -= 5.0f;
me->GetMotionMaster()->Clear(false);
me->SetPosition(x, y, z, 0.0f);
}
@@ -78,7 +80,9 @@ public:
break;
case 1:
player->GetClosePoint(x, y, z, me->GetObjectSize());
- z += 2.5; x -= 2; y -= 1.5;
+ z += 2.5f;
+ x -= 2.0f;
+ y -= 1.5f;
me->GetMotionMaster()->MovePoint(0, x, y, z);
me->SetTarget(player->GetGUID());
me->SetVisible(true);
diff --git a/src/server/scripts/EasternKingdoms/ScarletMonastery/boss_headless_horseman.cpp b/src/server/scripts/EasternKingdoms/ScarletMonastery/boss_headless_horseman.cpp
index 9afbeaa0172..c9ab9084d22 100644
--- a/src/server/scripts/EasternKingdoms/ScarletMonastery/boss_headless_horseman.cpp
+++ b/src/server/scripts/EasternKingdoms/ScarletMonastery/boss_headless_horseman.cpp
@@ -504,15 +504,14 @@ public:
Player* SelectRandomPlayer(float range = 0.0f, bool checkLoS = true)
{
Map* map = me->GetMap();
- if (!map->IsDungeon()) return NULL;
+ if (!map->IsDungeon())
+ return NULL;
Map::PlayerList const &PlayerList = map->GetPlayers();
- Map::PlayerList::const_iterator i;
- if (PlayerList.isEmpty()) return NULL;
+ if (PlayerList.isEmpty())
+ return NULL;
std::list<Player*> temp;
- std::list<Player*>::const_iterator j;
-
for (Map::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i)
if ((me->IsWithinLOSInMap(i->getSource()) || !checkLoS) && me->getVictim() != i->getSource() &&
me->IsWithinDistInMap(i->getSource(), range) && i->getSource()->isAlive())
@@ -520,7 +519,7 @@ public:
if (!temp.empty())
{
- j = temp.begin();
+ std::list<Player*>::const_iterator j = temp.begin();
advance(j, rand()%temp.size());
return (*j);
}
diff --git a/src/server/scripts/EasternKingdoms/ScarletMonastery/boss_mograine_and_whitemane.cpp b/src/server/scripts/EasternKingdoms/ScarletMonastery/boss_mograine_and_whitemane.cpp
index 3b788c72cd8..d0ea617b734 100644
--- a/src/server/scripts/EasternKingdoms/ScarletMonastery/boss_mograine_and_whitemane.cpp
+++ b/src/server/scripts/EasternKingdoms/ScarletMonastery/boss_mograine_and_whitemane.cpp
@@ -102,7 +102,7 @@ public:
{
if (m_instance)
{
- if (m_instance->GetData(TYPE_MOGRAINE_AND_WHITE_EVENT != NOT_STARTED))
+ if (m_instance->GetData(TYPE_MOGRAINE_AND_WHITE_EVENT) != NOT_STARTED)
m_instance->SetData(TYPE_MOGRAINE_AND_WHITE_EVENT, FAIL);
}
}
diff --git a/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_felmyst.cpp b/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_felmyst.cpp
index 4de719d684e..4e3f3899b35 100644
--- a/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_felmyst.cpp
+++ b/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_felmyst.cpp
@@ -484,15 +484,14 @@ public:
float x, y, z;
me->GetPosition(x, y, z);
- CellPair pair(Trinity::ComputeCellPair(x, y));
+ CellCoord pair(Trinity::ComputeCellCoord(x, y));
Cell cell(pair);
- cell.data.Part.reserved = ALL_DISTRICT;
cell.SetNoCreate();
Trinity::AllCreaturesOfEntryInRange check(me, entry, 100);
Trinity::CreatureListSearcher<Trinity::AllCreaturesOfEntryInRange> searcher(me, templist, check);
TypeContainerVisitor<Trinity::CreatureListSearcher<Trinity::AllCreaturesOfEntryInRange>, GridTypeMapContainer> cSearcher(searcher);
- cell.Visit(pair, cSearcher, *(me->GetMap()));
+ cell.Visit(pair, cSearcher, *(me->GetMap()), *me, me->GetGridActivationRange());
for (std::list<Creature*>::const_iterator i = templist.begin(); i != templist.end(); ++i)
{
diff --git a/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_kiljaeden.cpp b/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_kiljaeden.cpp
index b29a0c491cc..ca853d5684e 100644
--- a/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_kiljaeden.cpp
+++ b/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_kiljaeden.cpp
@@ -662,11 +662,13 @@ public:
{
float x, y, z;
Unit* target = NULL;
- for (uint8 z = 0; z < 6; ++z)
+ for (uint8 i = 0; i < 6; ++i)
{
target = SelectTarget(SELECT_TARGET_RANDOM, 0, 100, true);
- if (!target || !target->HasAura(SPELL_VENGEANCE_OF_THE_BLUE_FLIGHT, 0))break;
+ if (!target || !target->HasAura(SPELL_VENGEANCE_OF_THE_BLUE_FLIGHT, 0))
+ break;
}
+
if (target)
{
target->GetPosition(x, y, z);
diff --git a/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_muru.cpp b/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_muru.cpp
index fd11b4a4985..7c14845f060 100644
--- a/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_muru.cpp
+++ b/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_muru.cpp
@@ -330,14 +330,14 @@ public:
else
{
DarkFiend = false;
- for (uint8 i = 0; i < 8; ++i)
- me->SummonCreature(CREATURE_DARK_FIENDS, DarkFiends[i][0], DarkFiends[i][1], DarkFiends[i][2], DarkFiends[i][3], TEMPSUMMON_CORPSE_DESPAWN, 0);
+ for (uint8 j = 0; j < 8; ++j)
+ me->SummonCreature(CREATURE_DARK_FIENDS, DarkFiends[j][0], DarkFiends[j][1], DarkFiends[j][2], DarkFiends[j][3], TEMPSUMMON_CORPSE_DESPAWN, 0);
Timer[TIMER_DARKNESS] = 42000;
}
break;
case TIMER_HUMANOIDES:
- for (uint8 i = 0; i < 6; ++i)
- me->SummonCreature(uint32(Humanoides[i][0]), Humanoides[i][1], Humanoides[i][2], Humanoides[i][3], Humanoides[i][4], TEMPSUMMON_CORPSE_DESPAWN, 0);
+ for (uint8 j = 0; j < 6; ++j)
+ me->SummonCreature(uint32(Humanoides[j][0]), Humanoides[j][1], Humanoides[j][2], Humanoides[j][3], Humanoides[j][4], TEMPSUMMON_CORPSE_DESPAWN, 0);
Timer[TIMER_HUMANOIDES] = 60000;
break;
case TIMER_PHASE:
diff --git a/src/server/scripts/EasternKingdoms/ZulAman/boss_akilzon.cpp b/src/server/scripts/EasternKingdoms/ZulAman/boss_akilzon.cpp
index ba2d638d45f..413897c94e8 100644
--- a/src/server/scripts/EasternKingdoms/ZulAman/boss_akilzon.cpp
+++ b/src/server/scripts/EasternKingdoms/ZulAman/boss_akilzon.cpp
@@ -189,22 +189,21 @@ class boss_akilzon : public CreatureScript
for (uint8 i = 2; i < StormCount; ++i)
bp0 *= 2;
- CellPair p(Trinity::ComputeCellPair(me->GetPositionX(), me->GetPositionY()));
+ CellCoord p(Trinity::ComputeCellCoord(me->GetPositionX(), me->GetPositionY()));
Cell cell(p);
- cell.data.Part.reserved = ALL_DISTRICT;
cell.SetNoCreate();
std::list<Unit*> tempUnitMap;
{
- Trinity::AnyAoETargetUnitInObjectRangeCheck u_check(me, me, 999);
+ Trinity::AnyAoETargetUnitInObjectRangeCheck u_check(me, me, SIZE_OF_GRIDS);
Trinity::UnitListSearcher<Trinity::AnyAoETargetUnitInObjectRangeCheck> searcher(me, tempUnitMap, u_check);
TypeContainerVisitor<Trinity::UnitListSearcher<Trinity::AnyAoETargetUnitInObjectRangeCheck>, WorldTypeMapContainer > world_unit_searcher(searcher);
TypeContainerVisitor<Trinity::UnitListSearcher<Trinity::AnyAoETargetUnitInObjectRangeCheck>, GridTypeMapContainer > grid_unit_searcher(searcher);
- cell.Visit(p, world_unit_searcher, *(me->GetMap()));
- cell.Visit(p, grid_unit_searcher, *(me->GetMap()));
+ cell.Visit(p, world_unit_searcher, *me->GetMap(), *me, SIZE_OF_GRIDS);
+ cell.Visit(p, grid_unit_searcher, *me->GetMap(), *me, SIZE_OF_GRIDS);
}
//dealdamege
for (std::list<Unit*>::const_iterator i = tempUnitMap.begin(); i != tempUnitMap.end(); ++i)
diff --git a/src/server/scripts/EasternKingdoms/ZulAman/boss_janalai.cpp b/src/server/scripts/EasternKingdoms/ZulAman/boss_janalai.cpp
index d2ad81b4910..aea9e322583 100644
--- a/src/server/scripts/EasternKingdoms/ZulAman/boss_janalai.cpp
+++ b/src/server/scripts/EasternKingdoms/ZulAman/boss_janalai.cpp
@@ -233,9 +233,8 @@ class boss_janalai : public CreatureScript
me->GetPosition(x, y, z);
{
- CellPair pair(Trinity::ComputeCellPair(x, y));
+ CellCoord pair(Trinity::ComputeCellCoord(x, y));
Cell cell(pair);
- cell.data.Part.reserved = ALL_DISTRICT;
cell.SetNoCreate();
Trinity::AllCreaturesOfEntryInRange check(me, MOB_EGG, 100);
@@ -243,7 +242,7 @@ class boss_janalai : public CreatureScript
TypeContainerVisitor<Trinity::CreatureListSearcher<Trinity::AllCreaturesOfEntryInRange>, GridTypeMapContainer> cSearcher(searcher);
- cell.Visit(pair, cSearcher, *(me->GetMap()));
+ cell.Visit(pair, cSearcher, *me->GetMap(), *me, me->GetGridActivationRange());
}
//sLog->outError("Eggs %d at middle", templist.size());
@@ -267,9 +266,8 @@ class boss_janalai : public CreatureScript
me->GetPosition(x, y, z);
{
- CellPair pair(Trinity::ComputeCellPair(x, y));
+ CellCoord pair(Trinity::ComputeCellCoord(x, y));
Cell cell(pair);
- cell.data.Part.reserved = ALL_DISTRICT;
cell.SetNoCreate();
Trinity::AllCreaturesOfEntryInRange check(me, MOB_FIRE_BOMB, 100);
@@ -277,7 +275,7 @@ class boss_janalai : public CreatureScript
TypeContainerVisitor<Trinity::CreatureListSearcher<Trinity::AllCreaturesOfEntryInRange>, GridTypeMapContainer> cSearcher(searcher);
- cell.Visit(pair, cSearcher, *(me->GetMap()));
+ cell.Visit(pair, cSearcher, *me->GetMap(), *me, me->GetGridActivationRange());
}
for (std::list<Creature*>::const_iterator i = templist.begin(); i != templist.end(); ++i)
{
@@ -519,9 +517,8 @@ class mob_janalai_hatcher : public CreatureScript
me->GetPosition(x, y, z);
{
- CellPair pair(Trinity::ComputeCellPair(x, y));
+ CellCoord pair(Trinity::ComputeCellCoord(x, y));
Cell cell(pair);
- cell.data.Part.reserved = ALL_DISTRICT;
cell.SetNoCreate();
Trinity::AllCreaturesOfEntryInRange check(me, 23817, 50);
@@ -529,7 +526,7 @@ class mob_janalai_hatcher : public CreatureScript
TypeContainerVisitor<Trinity::CreatureListSearcher<Trinity::AllCreaturesOfEntryInRange>, GridTypeMapContainer> cSearcher(searcher);
- cell.Visit(pair, cSearcher, *(me->GetMap()));
+ cell.Visit(pair, cSearcher, *(me->GetMap()), *me, me->GetGridActivationRange());
}
//sLog->outError("Eggs %d at %d", templist.size(), side);
diff --git a/src/server/scripts/EasternKingdoms/ZulAman/boss_nalorakk.cpp b/src/server/scripts/EasternKingdoms/ZulAman/boss_nalorakk.cpp
index 17968766a5f..3ff465a3c1d 100644
--- a/src/server/scripts/EasternKingdoms/ZulAman/boss_nalorakk.cpp
+++ b/src/server/scripts/EasternKingdoms/ZulAman/boss_nalorakk.cpp
@@ -162,9 +162,8 @@ class boss_nalorakk : public CreatureScript
me->GetPosition(x, y, z);
{
- CellPair pair(Trinity::ComputeCellPair(x, y));
+ CellCoord pair(Trinity::ComputeCellCoord(x, y));
Cell cell(pair);
- cell.data.Part.reserved = ALL_DISTRICT;
cell.SetNoCreate();
Trinity::AllFriendlyCreaturesInGrid check(me);
@@ -172,7 +171,7 @@ class boss_nalorakk : public CreatureScript
TypeContainerVisitor<Trinity::CreatureListSearcher<Trinity::AllFriendlyCreaturesInGrid>, GridTypeMapContainer> cSearcher(searcher);
- cell.Visit(pair, cSearcher, *(me->GetMap()));
+ cell.Visit(pair, cSearcher, *(me->GetMap()), *me, me->GetGridActivationRange());
}
if (templist.empty())
diff --git a/src/server/scripts/EasternKingdoms/ZulGurub/boss_mandokir.cpp b/src/server/scripts/EasternKingdoms/ZulGurub/boss_mandokir.cpp
index f70c764f306..f45c943b0f1 100644
--- a/src/server/scripts/EasternKingdoms/ZulGurub/boss_mandokir.cpp
+++ b/src/server/scripts/EasternKingdoms/ZulGurub/boss_mandokir.cpp
@@ -91,9 +91,9 @@ class boss_mandokir : public CreatureScript
MortalStrike_Timer = 1000;
Check_Timer = 1000;
- targetX = 0.0;
- targetY = 0.0;
- targetZ = 0.0;
+ targetX = 0.0f;
+ targetY = 0.0f;
+ targetZ = 0.0f;
TargetInRange = 0;
WatchTarget = 0;
diff --git a/src/server/scripts/EasternKingdoms/eversong_woods.cpp b/src/server/scripts/EasternKingdoms/eversong_woods.cpp
index 10b7066068b..d02cce3f17c 100644
--- a/src/server/scripts/EasternKingdoms/eversong_woods.cpp
+++ b/src/server/scripts/EasternKingdoms/eversong_woods.cpp
@@ -35,91 +35,6 @@ EndContentData */
#include "ScriptedEscortAI.h"
/*######
-## npc_prospector_anvilward
-######*/
-
-#define GOSSIP_HELLO "I need a moment of your time, sir."
-#define GOSSIP_SELECT "Why... yes, of course. I've something to show you right inside this building, Mr. Anvilward."
-
-enum eProspectorAnvilward
-{
- SAY_ANVIL1 = -1000209,
- SAY_ANVIL2 = -1000210,
- QUEST_THE_DWARVEN_SPY = 8483,
-};
-
-class npc_prospector_anvilward : public CreatureScript
-{
-public:
- npc_prospector_anvilward() : CreatureScript("npc_prospector_anvilward") { }
-
- bool OnGossipSelect(Player* player, Creature* creature, uint32 /*uiSender*/, uint32 uiAction)
- {
- player->PlayerTalkClass->ClearMenus();
- switch (uiAction)
- {
- case GOSSIP_ACTION_INFO_DEF+1:
- player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_SELECT, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+2);
- player->SEND_GOSSIP_MENU(8240, creature->GetGUID());
- break;
- case GOSSIP_ACTION_INFO_DEF+2:
- player->CLOSE_GOSSIP_MENU();
- if (npc_escortAI* pEscortAI = CAST_AI(npc_prospector_anvilward::npc_prospector_anvilwardAI, creature->AI()))
- pEscortAI->Start(true, false, player->GetGUID());
- break;
- }
- return true;
- }
-
- bool OnGossipHello(Player* player, Creature* creature)
- {
- if (player->GetQuestStatus(QUEST_THE_DWARVEN_SPY) == QUEST_STATUS_INCOMPLETE)
- player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_HELLO, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1);
-
- player->SEND_GOSSIP_MENU(8239, creature->GetGUID());
- return true;
- }
-
- CreatureAI* GetAI(Creature* creature) const
- {
- return new npc_prospector_anvilwardAI(creature);
- }
-
- struct npc_prospector_anvilwardAI : public npc_escortAI
- {
- // CreatureAI functions
- npc_prospector_anvilwardAI(Creature* c) : npc_escortAI(c) {}
-
- // Pure Virtual Functions
- void WaypointReached(uint32 i)
- {
- Player* player = GetPlayerForEscort();
-
- if (!player)
- return;
-
- switch (i)
- {
- case 0: DoScriptText(SAY_ANVIL1, me, player); break;
- case 5: DoScriptText(SAY_ANVIL2, me, player); break;
- case 6: me->setFaction(24); break;
- }
- }
-
- void Reset()
- {
- me->RestoreFaction();
- }
-
- void JustDied(Unit* /*killer*/)
- {
- me->RestoreFaction();
- }
- };
-
-};
-
-/*######
## Quest 9686 Second Trial
######*/
@@ -711,7 +626,6 @@ public:
void AddSC_eversong_woods()
{
- new npc_prospector_anvilward();
new npc_second_trial_controller();
new npc_second_trial_paladin();
new go_second_trial();
diff --git a/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/hyjalAI.cpp b/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/hyjalAI.cpp
index 6186369a3a0..187ff9b9dd7 100644
--- a/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/hyjalAI.cpp
+++ b/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/hyjalAI.cpp
@@ -459,7 +459,9 @@ void hyjalAI::SummonCreature(uint32 entry, float Base[4][3])
creature = me->SummonCreature(entry, SpawnPointSpecial[SPAWN_NEAR_TOWER][0]+irand(-20, 20), SpawnPointSpecial[SPAWN_NEAR_TOWER][1]+irand(-20, 20), SpawnPointSpecial[SPAWN_NEAR_TOWER][2]+irand(-10, 10), 0, TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, 120000);
if (creature)
CAST_AI(hyjal_trashAI, creature->AI())->useFlyPath = true;
- }else{//summon at gate
+ }
+ else
+ {//summon at gate
creature = me->SummonCreature(entry, SpawnPointSpecial[SPAWN_GARG_GATE][0]+irand(-10, 10), SpawnPointSpecial[SPAWN_GARG_GATE][1]+irand(-10, 10), SpawnPointSpecial[SPAWN_GARG_GATE][2]+irand(-10, 10), 0, TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, 120000);
}
break;
@@ -910,6 +912,7 @@ void hyjalAI::UpdateAI(const uint32 diff)
DoMeleeAttackIfReady();
}
+
void hyjalAI::JustDied(Unit* /*killer*/)
{
if (IsDummy)return;
@@ -932,23 +935,20 @@ void hyjalAI::JustDied(Unit* /*killer*/)
instance->SetData(DATA_RESET_RAIDDAMAGE, 0);//reset damage on die
}
}
+
void hyjalAI::HideNearPos(float x, float y)
{
- CellPair pair(Trinity::ComputeCellPair(x, y));
+ CellCoord pair(Trinity::ComputeCellCoord(x, y));
Cell cell(pair);
- cell.data.Part.reserved = ALL_DISTRICT;
cell.SetNoCreate();
// First get all creatures.
std::list<Creature*> creatures;
Trinity::AllFriendlyCreaturesInGrid creature_check(me);
Trinity::CreatureListSearcher<Trinity::AllFriendlyCreaturesInGrid> creature_searcher(me, creatures, creature_check);
- TypeContainerVisitor
- <Trinity::CreatureListSearcher<Trinity::AllFriendlyCreaturesInGrid>,
- GridTypeMapContainer> creature_visitor(creature_searcher);
- // Get Creatures
- cell.Visit(pair, creature_visitor, *(me->GetMap()));
+ TypeContainerVisitor <Trinity::CreatureListSearcher<Trinity::AllFriendlyCreaturesInGrid>, GridTypeMapContainer> creature_visitor(creature_searcher);
+ cell.Visit(pair, creature_visitor, *(me->GetMap()), *me, me->GetGridActivationRange());
if (!creatures.empty())
{
@@ -959,18 +959,19 @@ void hyjalAI::HideNearPos(float x, float y)
}
}
}
+
void hyjalAI::RespawnNearPos(float x, float y)
{
- CellPair p(Trinity::ComputeCellPair(x, y));
+ CellCoord p(Trinity::ComputeCellCoord(x, y));
Cell cell(p);
- cell.data.Part.reserved = ALL_DISTRICT;
cell.SetNoCreate();
Trinity::RespawnDo u_do;
Trinity::WorldObjectWorker<Trinity::RespawnDo> worker(me, u_do);
TypeContainerVisitor<Trinity::WorldObjectWorker<Trinity::RespawnDo>, GridTypeMapContainer > obj_worker(worker);
- cell.Visit(p, obj_worker, *me->GetMap());
+ cell.Visit(p, obj_worker, *me->GetMap(), *me, me->GetGridActivationRange());
}
+
void hyjalAI::WaypointReached(uint32 i)
{
if (i == 1 || (i == 0 && me->GetEntry() == THRALL))
@@ -992,9 +993,8 @@ void hyjalAI::WaypointReached(uint32 i)
}
//do some talking
//all alive guards walk near here
- CellPair pair(Trinity::ComputeCellPair(me->GetPositionX(), me->GetPositionY()));
+ CellCoord pair(Trinity::ComputeCellCoord(me->GetPositionX(), me->GetPositionY()));
Cell cell(pair);
- cell.data.Part.reserved = ALL_DISTRICT;
cell.SetNoCreate();
// First get all creatures.
@@ -1005,7 +1005,7 @@ void hyjalAI::WaypointReached(uint32 i)
<Trinity::CreatureListSearcher<Trinity::AllFriendlyCreaturesInGrid>,
GridTypeMapContainer> creature_visitor(creature_searcher);
- cell.Visit(pair, creature_visitor, *(me->GetMap()));
+ cell.Visit(pair, creature_visitor, *(me->GetMap()), *me, me->GetGridActivationRange());
if (!creatures.empty())
{
@@ -1034,9 +1034,8 @@ void hyjalAI::DoOverrun(uint32 faction, const uint32 diff)
{
if (TeleportTimer <= diff)
{
- CellPair pair(Trinity::ComputeCellPair(me->GetPositionX(), me->GetPositionY()));
+ CellCoord pair(Trinity::ComputeCellCoord(me->GetPositionX(), me->GetPositionY()));
Cell cell(pair);
- cell.data.Part.reserved = ALL_DISTRICT;
cell.SetNoCreate();
std::list<Creature*> creatures;
@@ -1046,7 +1045,7 @@ void hyjalAI::DoOverrun(uint32 faction, const uint32 diff)
<Trinity::CreatureListSearcher<Trinity::AllFriendlyCreaturesInGrid>,
GridTypeMapContainer> creature_visitor(creature_searcher);
- cell.Visit(pair, creature_visitor, *(me->GetMap()));
+ cell.Visit(pair, creature_visitor, *(me->GetMap()), *me, me->GetGridActivationRange());
if (!creatures.empty())
{
diff --git a/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/instance_hyjal.cpp b/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/instance_hyjal.cpp
index 0e5233d6620..338f320dcc2 100644
--- a/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/instance_hyjal.cpp
+++ b/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/instance_hyjal.cpp
@@ -205,9 +205,9 @@ public:
{
if (i->getSource())
{
- WorldPacket data(SMSG_MESSAGECHAT, 200);
- unit->BuildMonsterChat(&data, CHAT_MSG_MONSTER_YELL, YELL_EFFORTS, 0, YELL_EFFORTS_NAME, i->getSource()->GetGUID());
- i->getSource()->GetSession()->SendPacket(&data);
+ WorldPacket packet(SMSG_MESSAGECHAT, 200);
+ unit->BuildMonsterChat(&packet, CHAT_MSG_MONSTER_YELL, YELL_EFFORTS, 0, YELL_EFFORTS_NAME, i->getSource()->GetGUID());
+ i->getSource()->GetSession()->SendPacket(&packet);
WorldPacket data2(SMSG_PLAY_SOUND, 4);
data2 << 10986;
diff --git a/src/server/scripts/Kalimdor/CavernsOfTime/CullingOfStratholme/culling_of_stratholme.cpp b/src/server/scripts/Kalimdor/CavernsOfTime/CullingOfStratholme/culling_of_stratholme.cpp
index 02f9435db49..82f16dd7784 100644
--- a/src/server/scripts/Kalimdor/CavernsOfTime/CullingOfStratholme/culling_of_stratholme.cpp
+++ b/src/server/scripts/Kalimdor/CavernsOfTime/CullingOfStratholme/culling_of_stratholme.cpp
@@ -579,13 +579,16 @@ public:
{
//After reset
case 0:
- if (Unit* pJaina = GetClosestCreatureWithEntry(me, NPC_JAINA, 50.0f))
- uiJainaGUID = pJaina->GetGUID();
- else if (Unit* pJaina = me->SummonCreature(NPC_JAINA, 1895.48f, 1292.66f, 143.706f, 0.023475f, TEMPSUMMON_DEAD_DESPAWN, 180000))
+ {
+ Unit* pJaina = GetClosestCreatureWithEntry(me, NPC_JAINA, 50.0f);
+ if (!pJaina)
+ pJaina = pJaina = me->SummonCreature(NPC_JAINA, 1895.48f, 1292.66f, 143.706f, 0.023475f, TEMPSUMMON_DEAD_DESPAWN, 180000);
+ if (pJaina)
uiJainaGUID = pJaina->GetGUID();
bStepping = false;
JumpToNextStep(0);
break;
+ }
//After waypoint 0
case 1:
me->RemoveUnitMovementFlag(MOVEMENTFLAG_WALKING);
@@ -829,9 +832,10 @@ public:
case 37:
if (Creature* pMalganis = Unit::GetCreature(*me, uiMalganisGUID))
{
- if (Creature* pZombie = GetClosestCreatureWithEntry(pMalganis, NPC_CITY_MAN, 100.0f))
- pZombie->UpdateEntry(NPC_ZOMBIE, 0);
- else if (Creature* pZombie = GetClosestCreatureWithEntry(pMalganis, NPC_CITY_MAN2, 100.0f))
+ Creature* pZombie = GetClosestCreatureWithEntry(pMalganis, NPC_CITY_MAN, 100.0f);
+ if (!pZombie)
+ pZombie = GetClosestCreatureWithEntry(pMalganis, NPC_CITY_MAN2, 100.0f);
+ if (pZombie)
pZombie->UpdateEntry(NPC_ZOMBIE, 0);
else //There's no one else to transform
uiStep++;
diff --git a/src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_cthun.cpp b/src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_cthun.cpp
index 4cc1069b838..43265cb4430 100644
--- a/src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_cthun.cpp
+++ b/src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_cthun.cpp
@@ -680,12 +680,8 @@ public:
//Place all units in threat list on outside of stomach
Stomach_Map.clear();
- std::list<HostileReference*>::const_iterator i = me->getThreatManager().getThreatList().begin();
- for (; i != me->getThreatManager().getThreatList().end(); ++i)
- {
- //Outside stomach
- Stomach_Map[(*i)->getUnitGuid()] = false;
- }
+ for (std::list<HostileReference*>::const_iterator i = me->getThreatManager().getThreatList().begin(); i != me->getThreatManager().getThreatList().end(); ++i)
+ Stomach_Map[(*i)->getUnitGuid()] = false; //Outside stomach
//Spawn 2 flesh tentacles
FleshTentaclesKilled = 0;
diff --git a/src/server/scripts/Northrend/AzjolNerub/ahnkahet/ahnkahet.h b/src/server/scripts/Northrend/AzjolNerub/Ahnkahet/ahnkahet.h
index e19054d2f46..e19054d2f46 100644
--- a/src/server/scripts/Northrend/AzjolNerub/ahnkahet/ahnkahet.h
+++ b/src/server/scripts/Northrend/AzjolNerub/Ahnkahet/ahnkahet.h
diff --git a/src/server/scripts/Northrend/AzjolNerub/ahnkahet/boss_amanitar.cpp b/src/server/scripts/Northrend/AzjolNerub/Ahnkahet/boss_amanitar.cpp
index cde97f8d37b..cde97f8d37b 100644
--- a/src/server/scripts/Northrend/AzjolNerub/ahnkahet/boss_amanitar.cpp
+++ b/src/server/scripts/Northrend/AzjolNerub/Ahnkahet/boss_amanitar.cpp
diff --git a/src/server/scripts/Northrend/AzjolNerub/ahnkahet/boss_elder_nadox.cpp b/src/server/scripts/Northrend/AzjolNerub/Ahnkahet/boss_elder_nadox.cpp
index a2371fa0121..a2371fa0121 100644
--- a/src/server/scripts/Northrend/AzjolNerub/ahnkahet/boss_elder_nadox.cpp
+++ b/src/server/scripts/Northrend/AzjolNerub/Ahnkahet/boss_elder_nadox.cpp
diff --git a/src/server/scripts/Northrend/AzjolNerub/ahnkahet/boss_herald_volazj.cpp b/src/server/scripts/Northrend/AzjolNerub/Ahnkahet/boss_herald_volazj.cpp
index bc4d4ba5eea..bc4d4ba5eea 100644
--- a/src/server/scripts/Northrend/AzjolNerub/ahnkahet/boss_herald_volazj.cpp
+++ b/src/server/scripts/Northrend/AzjolNerub/Ahnkahet/boss_herald_volazj.cpp
diff --git a/src/server/scripts/Northrend/AzjolNerub/ahnkahet/boss_jedoga_shadowseeker.cpp b/src/server/scripts/Northrend/AzjolNerub/Ahnkahet/boss_jedoga_shadowseeker.cpp
index b2975797a02..b2975797a02 100644
--- a/src/server/scripts/Northrend/AzjolNerub/ahnkahet/boss_jedoga_shadowseeker.cpp
+++ b/src/server/scripts/Northrend/AzjolNerub/Ahnkahet/boss_jedoga_shadowseeker.cpp
diff --git a/src/server/scripts/Northrend/AzjolNerub/ahnkahet/boss_prince_taldaram.cpp b/src/server/scripts/Northrend/AzjolNerub/Ahnkahet/boss_prince_taldaram.cpp
index 9a7dc2f2cc9..9a7dc2f2cc9 100644
--- a/src/server/scripts/Northrend/AzjolNerub/ahnkahet/boss_prince_taldaram.cpp
+++ b/src/server/scripts/Northrend/AzjolNerub/Ahnkahet/boss_prince_taldaram.cpp
diff --git a/src/server/scripts/Northrend/AzjolNerub/ahnkahet/instance_ahnkahet.cpp b/src/server/scripts/Northrend/AzjolNerub/Ahnkahet/instance_ahnkahet.cpp
index 5ba11dd5353..5ba11dd5353 100644
--- a/src/server/scripts/Northrend/AzjolNerub/ahnkahet/instance_ahnkahet.cpp
+++ b/src/server/scripts/Northrend/AzjolNerub/Ahnkahet/instance_ahnkahet.cpp
diff --git a/src/server/scripts/Northrend/AzjolNerub/AzjolNerub/boss_hadronox.cpp b/src/server/scripts/Northrend/AzjolNerub/AzjolNerub/boss_hadronox.cpp
index dea3d6eaede..605f3a11c8a 100644
--- a/src/server/scripts/Northrend/AzjolNerub/AzjolNerub/boss_hadronox.cpp
+++ b/src/server/scripts/Northrend/AzjolNerub/AzjolNerub/boss_hadronox.cpp
@@ -118,7 +118,7 @@ public:
return;
float x=0.0f, y=0.0f, z=0.0f;
- me->GetRespawnCoord(x, y, z);
+ me->GetRespawnPosition(x, y, z);
if (uiCheckDistanceTimer <= uiDiff)
uiCheckDistanceTimer = 5*IN_MILLISECONDS;
diff --git a/src/server/scripts/Northrend/CMakeLists.txt b/src/server/scripts/Northrend/CMakeLists.txt
index 63e714d17aa..53b47884e57 100644
--- a/src/server/scripts/Northrend/CMakeLists.txt
+++ b/src/server/scripts/Northrend/CMakeLists.txt
@@ -18,23 +18,23 @@ set(scripts_STAT_SRCS
Northrend/Ulduar/HallsOfLightning/boss_ionar.cpp
Northrend/Ulduar/HallsOfLightning/boss_volkhan.cpp
Northrend/Ulduar/HallsOfLightning/boss_loken.cpp
- Northrend/Ulduar/ulduar/boss_general_vezax.cpp
- Northrend/Ulduar/ulduar/ulduar_teleporter.cpp
- Northrend/Ulduar/ulduar/boss_thorim.cpp
- Northrend/Ulduar/ulduar/boss_ignis.cpp
- Northrend/Ulduar/ulduar/boss_algalon.cpp
- Northrend/Ulduar/ulduar/instance_ulduar.cpp
- Northrend/Ulduar/ulduar/boss_auriaya.cpp
- Northrend/Ulduar/ulduar/boss_yoggsaron.cpp
- Northrend/Ulduar/ulduar/boss_hodir.cpp
- Northrend/Ulduar/ulduar/boss_assembly_of_iron.cpp
- Northrend/Ulduar/ulduar/boss_flame_leviathan.cpp
- Northrend/Ulduar/ulduar/boss_xt002.cpp
- Northrend/Ulduar/ulduar/boss_mimiron.cpp
- Northrend/Ulduar/ulduar/ulduar.h
- Northrend/Ulduar/ulduar/boss_freya.cpp
- Northrend/Ulduar/ulduar/boss_razorscale.cpp
- Northrend/Ulduar/ulduar/boss_kologarn.cpp
+ Northrend/Ulduar/Ulduar/boss_general_vezax.cpp
+ Northrend/Ulduar/Ulduar/ulduar_teleporter.cpp
+ Northrend/Ulduar/Ulduar/boss_thorim.cpp
+ Northrend/Ulduar/Ulduar/boss_ignis.cpp
+ Northrend/Ulduar/Ulduar/boss_algalon.cpp
+ Northrend/Ulduar/Ulduar/instance_ulduar.cpp
+ Northrend/Ulduar/Ulduar/boss_auriaya.cpp
+ Northrend/Ulduar/Ulduar/boss_yoggsaron.cpp
+ Northrend/Ulduar/Ulduar/boss_hodir.cpp
+ Northrend/Ulduar/Ulduar/boss_assembly_of_iron.cpp
+ Northrend/Ulduar/Ulduar/boss_flame_leviathan.cpp
+ Northrend/Ulduar/Ulduar/boss_xt002.cpp
+ Northrend/Ulduar/Ulduar/boss_mimiron.cpp
+ Northrend/Ulduar/Ulduar/ulduar.h
+ Northrend/Ulduar/Ulduar/boss_freya.cpp
+ Northrend/Ulduar/Ulduar/boss_razorscale.cpp
+ Northrend/Ulduar/Ulduar/boss_kologarn.cpp
Northrend/Ulduar/HallsOfStone/boss_krystallus.cpp
Northrend/Ulduar/HallsOfStone/halls_of_stone.h
Northrend/Ulduar/HallsOfStone/instance_halls_of_stone.cpp
@@ -142,13 +142,13 @@ set(scripts_STAT_SRCS
Northrend/AzjolNerub/AzjolNerub/boss_krikthir_the_gatewatcher.cpp
Northrend/AzjolNerub/AzjolNerub/boss_hadronox.cpp
Northrend/AzjolNerub/AzjolNerub/boss_anubarak.cpp
- Northrend/AzjolNerub/ahnkahet/boss_herald_volazj.cpp
- Northrend/AzjolNerub/ahnkahet/boss_prince_taldaram.cpp
- Northrend/AzjolNerub/ahnkahet/instance_ahnkahet.cpp
- Northrend/AzjolNerub/ahnkahet/boss_jedoga_shadowseeker.cpp
- Northrend/AzjolNerub/ahnkahet/boss_elder_nadox.cpp
- Northrend/AzjolNerub/ahnkahet/boss_amanitar.cpp
- Northrend/AzjolNerub/ahnkahet/ahnkahet.h
+ Northrend/AzjolNerub/Ahnkahet/boss_herald_volazj.cpp
+ Northrend/AzjolNerub/Ahnkahet/boss_prince_taldaram.cpp
+ Northrend/AzjolNerub/Ahnkahet/instance_ahnkahet.cpp
+ Northrend/AzjolNerub/Ahnkahet/boss_jedoga_shadowseeker.cpp
+ Northrend/AzjolNerub/Ahnkahet/boss_elder_nadox.cpp
+ Northrend/AzjolNerub/Ahnkahet/boss_amanitar.cpp
+ Northrend/AzjolNerub/Ahnkahet/ahnkahet.h
Northrend/VioletHold/boss_zuramat.cpp
Northrend/VioletHold/instance_violet_hold.cpp
Northrend/VioletHold/boss_lavanthor.cpp
diff --git a/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheChampion/trial_of_the_champion.cpp b/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheChampion/trial_of_the_champion.cpp
index 2688005ee22..a1e906e214a 100644
--- a/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheChampion/trial_of_the_champion.cpp
+++ b/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheChampion/trial_of_the_champion.cpp
@@ -221,10 +221,9 @@ public:
{
uiVehicle1GUID = pBoss->GetGUID();
uint64 uiGrandChampionBoss1 = 0;
- if (Creature* pBoss = Unit::GetCreature(*me, uiVehicle1GUID))
- if (Vehicle* pVehicle = pBoss->GetVehicleKit())
- if (Unit* unit = pVehicle->GetPassenger(0))
- uiGrandChampionBoss1 = unit->GetGUID();
+ if (Vehicle* pVehicle = pBoss->GetVehicleKit())
+ if (Unit* unit = pVehicle->GetPassenger(0))
+ uiGrandChampionBoss1 = unit->GetGUID();
if (instance)
{
instance->SetData64(DATA_GRAND_CHAMPION_VEHICLE_1, uiVehicle1GUID);
@@ -237,10 +236,9 @@ public:
{
uiVehicle2GUID = pBoss->GetGUID();
uint64 uiGrandChampionBoss2 = 0;
- if (Creature* pBoss = Unit::GetCreature(*me, uiVehicle2GUID))
- if (Vehicle* pVehicle = pBoss->GetVehicleKit())
- if (Unit* unit = pVehicle->GetPassenger(0))
- uiGrandChampionBoss2 = unit->GetGUID();
+ if (Vehicle* pVehicle = pBoss->GetVehicleKit())
+ if (Unit* unit = pVehicle->GetPassenger(0))
+ uiGrandChampionBoss2 = unit->GetGUID();
if (instance)
{
instance->SetData64(DATA_GRAND_CHAMPION_VEHICLE_2, uiVehicle2GUID);
@@ -253,10 +251,9 @@ public:
{
uiVehicle3GUID = pBoss->GetGUID();
uint64 uiGrandChampionBoss3 = 0;
- if (Creature* pBoss = Unit::GetCreature(*me, uiVehicle3GUID))
- if (Vehicle* pVehicle = pBoss->GetVehicleKit())
- if (Unit* unit = pVehicle->GetPassenger(0))
- uiGrandChampionBoss3 = unit->GetGUID();
+ if (Vehicle* pVehicle = pBoss->GetVehicleKit())
+ if (Unit* unit = pVehicle->GetPassenger(0))
+ uiGrandChampionBoss3 = unit->GetGUID();
if (instance)
{
instance->SetData64(DATA_GRAND_CHAMPION_VEHICLE_3, uiVehicle3GUID);
diff --git a/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_anubarak_trial.cpp b/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_anubarak_trial.cpp
index 1ca1c69831c..be83c4d326a 100755
--- a/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_anubarak_trial.cpp
+++ b/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_anubarak_trial.cpp
@@ -284,7 +284,7 @@ public:
if (m_uiPenetratingColdTimer <= uiDiff)
{
- me->CastCustomSpell(SPELL_PENETRATING_COLD, SPELLVALUE_MAX_TARGETS, RAID_MODE(2, 5));
+ me->CastCustomSpell(SPELL_PENETRATING_COLD, SPELLVALUE_MAX_TARGETS, RAID_MODE(2, 5, 2, 5));
m_uiPenetratingColdTimer = 20*IN_MILLISECONDS;
} else m_uiPenetratingColdTimer -= uiDiff;
@@ -577,7 +577,7 @@ public:
me->SetReactState(REACT_PASSIVE);
me->SetFlying(true);
me->SetDisplayId(25144);
- me->SetSpeed(MOVE_RUN, 0.5, false);
+ me->SetSpeed(MOVE_RUN, 0.5f, false);
me->GetMotionMaster()->MoveRandom(20.0f);
DoCast(SPELL_FROST_SPHERE);
}
diff --git a/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_lord_jaraxxus.cpp b/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_lord_jaraxxus.cpp
index ec573f75bc6..df166c1bf04 100755
--- a/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_lord_jaraxxus.cpp
+++ b/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_lord_jaraxxus.cpp
@@ -490,11 +490,14 @@ public:
void UpdateAI(const uint32 uiDiff)
{
- if (!UpdateVictim())
- return;
-
if (m_instance && m_instance->GetData(TYPE_JARAXXUS) != IN_PROGRESS)
+ {
me->DespawnOrUnsummon();
+ return;
+ }
+
+ if (!UpdateVictim())
+ return;
if (m_uiShivanSlashTimer <= uiDiff)
{
diff --git a/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_northrend_beasts.cpp b/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_northrend_beasts.cpp
index d4514dd547e..1ee7bcb4120 100755
--- a/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_northrend_beasts.cpp
+++ b/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_northrend_beasts.cpp
@@ -348,10 +348,10 @@ public:
m_bTargetDied = true;
me->GetMotionMaster()->MoveJump(gormok->GetPositionX(), gormok->GetPositionY(), gormok->GetPositionZ(), 15.0f, 15.0f);
}
- else if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0))
+ else if (Unit* target2 = SelectTarget(SELECT_TARGET_RANDOM, 0))
{
- m_uiTargetGUID = target->GetGUID();
- me->GetMotionMaster()->MoveJump(target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(), 15.0f, 15.0f);
+ m_uiTargetGUID = target2->GetGUID();
+ me->GetMotionMaster()->MoveJump(target2->GetPositionX(), target2->GetPositionY(), target2->GetPositionZ(), 15.0f, 15.0f);
}
}
}
diff --git a/src/server/scripts/Northrend/FrozenHalls/ForgeOfSouls/boss_devourer_of_souls.cpp b/src/server/scripts/Northrend/FrozenHalls/ForgeOfSouls/boss_devourer_of_souls.cpp
index adbe59555b6..68223f170c5 100644
--- a/src/server/scripts/Northrend/FrozenHalls/ForgeOfSouls/boss_devourer_of_souls.cpp
+++ b/src/server/scripts/Northrend/FrozenHalls/ForgeOfSouls/boss_devourer_of_souls.cpp
@@ -114,6 +114,8 @@ struct outroPosition
{ { 0, 0 }, { 0.0f, 0.0f, 0.0f, 0.0f } }
};
+Position const CrucibleSummonPos = {5672.294f,2520.686f, 713.4386f, 0.9599311f};
+
#define DATA_THREE_FACED 1
class boss_devourer_of_souls : public CreatureScript
@@ -154,6 +156,8 @@ class boss_devourer_of_souls : public CreatureScript
{
DoScriptText(RAND(SAY_FACE_ANGER_AGGRO, SAY_FACE_DESIRE_AGGRO), me);
+ if (!me->FindNearestCreature(NPC_CRUCIBLE_OF_SOULS, 60)) // Prevent double spawn
+ instance->instance->SummonCreature(NPC_CRUCIBLE_OF_SOULS, CrucibleSummonPos);
events.ScheduleEvent(EVENT_PHANTOM_BLAST, 5000);
events.ScheduleEvent(EVENT_MIRRORED_SOUL, 8000);
events.ScheduleEvent(EVENT_WELL_OF_SOULS, 30000);
diff --git a/src/server/scripts/Northrend/FrozenHalls/ForgeOfSouls/forge_of_souls.h b/src/server/scripts/Northrend/FrozenHalls/ForgeOfSouls/forge_of_souls.h
index 85062cc2901..9f34e412847 100644
--- a/src/server/scripts/Northrend/FrozenHalls/ForgeOfSouls/forge_of_souls.h
+++ b/src/server/scripts/Northrend/FrozenHalls/ForgeOfSouls/forge_of_souls.h
@@ -46,5 +46,6 @@ enum Creatures
NPC_CHAMPION_3_HORDE = 37588,
NPC_CHAMPION_1_ALLIANCE = 37496,
NPC_CHAMPION_2_ALLIANCE = 37497,
+ NPC_CRUCIBLE_OF_SOULS = 37094,
};
#endif
diff --git a/src/server/scripts/Northrend/Gundrak/boss_slad_ran.cpp b/src/server/scripts/Northrend/Gundrak/boss_slad_ran.cpp
index 7e417a840f2..f2b9fb704d5 100644
--- a/src/server/scripts/Northrend/Gundrak/boss_slad_ran.cpp
+++ b/src/server/scripts/Northrend/Gundrak/boss_slad_ran.cpp
@@ -52,6 +52,7 @@ enum Creatures
enum ConstrictorSpells
{
SPELL_GRIP_OF_SLAD_RAN = 55093,
+ SPELL_SNAKE_WRAP = 55126,
SPELL_VENOMOUS_BITE = 54987,
H_SPELL_VENOMOUS_BITE = 58996
};
@@ -65,6 +66,8 @@ static Position SpawnLoc[]=
{1716.76f, 635.159f, 129.282f, 0.191986f}
};
+#define DATA_SNAKES_WHYD_IT_HAVE_TO_BE_SNAKES 1
+
class boss_slad_ran : public CreatureScript
{
public:
@@ -89,6 +92,7 @@ public:
uint8 uiPhase;
+ std::set<uint64> lWrappedPlayers;
SummonList lSummons;
InstanceScript* instance;
@@ -100,6 +104,7 @@ public:
uiVenomBoltTimer = 15*IN_MILLISECONDS;
uiSpawnTimer = 5*IN_MILLISECONDS;
uiPhase = 0;
+ lWrappedPlayers.clear();
lSummons.DespawnAll();
@@ -171,6 +176,7 @@ public:
void JustDied(Unit* /*killer*/)
{
DoScriptText(SAY_DEATH, me);
+ lSummons.DespawnAll();
if (instance)
instance->SetData(DATA_SLAD_RAN_EVENT, DONE);
@@ -186,6 +192,17 @@ public:
summoned->GetMotionMaster()->MovePoint(0, me->GetPositionX(), me->GetPositionY(), me->GetPositionZ());
lSummons.Summon(summoned);
}
+
+ void SetGUID(uint64 guid, int32 type)
+ {
+ if (type == DATA_SNAKES_WHYD_IT_HAVE_TO_BE_SNAKES)
+ lWrappedPlayers.insert(guid);
+ }
+
+ bool WasWrapped(uint64 guid)
+ {
+ return lWrappedPlayers.count(guid);
+ }
};
};
@@ -215,10 +232,26 @@ public:
{
if (!UpdateVictim())
return;
+
if (uiGripOfSladRanTimer <= diff)
{
- DoCast(me->getVictim(), SPELL_GRIP_OF_SLAD_RAN);
- uiGripOfSladRanTimer = 5*IN_MILLISECONDS;
+ Unit* target = me->getVictim();
+
+ DoCast(target, SPELL_GRIP_OF_SLAD_RAN);
+ uiGripOfSladRanTimer = urand(3, 6)*IN_MILLISECONDS;
+
+ Aura* grip = target->GetAura(SPELL_GRIP_OF_SLAD_RAN, me->GetGUID());
+ if (grip && grip->GetStackAmount() == 5)
+ {
+ target->RemoveAurasDueToSpell(SPELL_GRIP_OF_SLAD_RAN, me->GetGUID());
+ target->CastSpell(target, SPELL_SNAKE_WRAP, true);
+
+ if (TempSummon* _me = me->ToTempSummon())
+ if (Creature* sladran = _me->GetSummoner()->ToCreature())
+ sladran->AI()->SetGUID(target->GetGUID() ,DATA_SNAKES_WHYD_IT_HAVE_TO_BE_SNAKES);
+
+ me->DespawnOrUnsummon();
+ }
} else uiGripOfSladRanTimer -= diff;
}
@@ -265,9 +298,28 @@ public:
};
+class achievement_snakes_whyd_it_have_to_be_snakes : public AchievementCriteriaScript
+{
+ public:
+ achievement_snakes_whyd_it_have_to_be_snakes() : AchievementCriteriaScript("achievement_snakes_whyd_it_have_to_be_snakes")
+ {
+ }
+
+ bool OnCheck(Player* player, Unit* target)
+ {
+ if (!target)
+ return false;
+
+ if (boss_slad_ran::boss_slad_ranAI* sladRanAI = CAST_AI(boss_slad_ran::boss_slad_ranAI, target->GetAI()))
+ return !sladRanAI->WasWrapped(player->GetGUID());
+ return false;
+ }
+};
+
void AddSC_boss_slad_ran()
{
new boss_slad_ran();
new mob_slad_ran_constrictor();
new mob_slad_ran_viper();
-}
+ new achievement_snakes_whyd_it_have_to_be_snakes();
+} \ No newline at end of file
diff --git a/src/server/scripts/Northrend/IcecrownCitadel/boss_festergut.cpp b/src/server/scripts/Northrend/IcecrownCitadel/boss_festergut.cpp
index b117dadf045..fd693789064 100755
--- a/src/server/scripts/Northrend/IcecrownCitadel/boss_festergut.cpp
+++ b/src/server/scripts/Northrend/IcecrownCitadel/boss_festergut.cpp
@@ -291,6 +291,10 @@ class npc_stinky_icc : public CreatureScript
_events.Reset();
_events.ScheduleEvent(EVENT_DECIMATE, urand(20000, 25000));
_events.ScheduleEvent(EVENT_MORTAL_WOUND, urand(3000, 7000));
+ }
+
+ void EnterCombat(Unit* /*target*/)
+ {
DoCast(me, SPELL_PLAGUE_STENCH);
}
diff --git a/src/server/scripts/Northrend/IcecrownCitadel/boss_lady_deathwhisper.cpp b/src/server/scripts/Northrend/IcecrownCitadel/boss_lady_deathwhisper.cpp
index 9e4079a7a15..ae6f3feb57f 100755
--- a/src/server/scripts/Northrend/IcecrownCitadel/boss_lady_deathwhisper.cpp
+++ b/src/server/scripts/Northrend/IcecrownCitadel/boss_lady_deathwhisper.cpp
@@ -375,7 +375,7 @@ class boss_lady_deathwhisper : public CreatureScript
{
me->ApplySpellImmune(0, IMMUNITY_STATE, SPELL_AURA_MOD_TAUNT, true);
me->ApplySpellImmune(0, IMMUNITY_EFFECT, SPELL_EFFECT_ATTACK_ME, true);
- events.ScheduleEvent(EVENT_P2_SUMMON_WAVE, urand(30000, 60000), 0, PHASE_TWO);
+ events.ScheduleEvent(EVENT_P2_SUMMON_WAVE, 45000, 0, PHASE_TWO);
}
}
}
@@ -438,7 +438,7 @@ class boss_lady_deathwhisper : public CreatureScript
case EVENT_DEATH_AND_DECAY:
if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM))
DoCast(target, SPELL_DEATH_AND_DECAY);
- events.ScheduleEvent(EVENT_DEATH_AND_DECAY, urand(10000, 12000));
+ events.ScheduleEvent(EVENT_DEATH_AND_DECAY, urand(22000, 30000));
break;
case EVENT_DOMINATE_MIND_H:
Talk(SAY_DOMINATE_MIND);
@@ -449,7 +449,7 @@ class boss_lady_deathwhisper : public CreatureScript
break;
case EVENT_P1_SUMMON_WAVE:
SummonWaveP1();
- events.ScheduleEvent(EVENT_P1_SUMMON_WAVE, 60000, 0, PHASE_ONE);
+ events.ScheduleEvent(EVENT_P1_SUMMON_WAVE, IsHeroic() ? 45000 : 60000, 0, PHASE_ONE);
break;
case EVENT_P1_SHADOW_BOLT:
if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM))
@@ -485,7 +485,7 @@ class boss_lady_deathwhisper : public CreatureScript
break;
case EVENT_P2_SUMMON_WAVE:
SummonWaveP2();
- events.ScheduleEvent(EVENT_P2_SUMMON_WAVE, 60000, 0, PHASE_TWO);
+ events.ScheduleEvent(EVENT_P2_SUMMON_WAVE, 45000, 0, PHASE_TWO);
break;
case EVENT_BERSERK:
DoCast(me, SPELL_BERSERK);
diff --git a/src/server/scripts/Northrend/IcecrownCitadel/boss_sindragosa.cpp b/src/server/scripts/Northrend/IcecrownCitadel/boss_sindragosa.cpp
index dca53f1a5e7..29c3276467b 100644
--- a/src/server/scripts/Northrend/IcecrownCitadel/boss_sindragosa.cpp
+++ b/src/server/scripts/Northrend/IcecrownCitadel/boss_sindragosa.cpp
@@ -242,6 +242,9 @@ class boss_sindragosa : public CreatureScript
{
if (action == ACTION_START_FROSTWYRM)
{
+ if (TempSummon* summon = me->ToTempSummon())
+ summon->SetTempSummonType(TEMPSUMMON_DEAD_DESPAWN);
+
instance->SetData(DATA_SINDRAGOSA_FROSTWYRMS, 255);
if (me->isDead())
return;
@@ -968,10 +971,10 @@ class spell_sindragosa_s_fury : public SpellScriptLoader
{
PreventHitDefaultEffect(effIndex);
- if (!GetHitUnit()->isAlive())
+ if (!GetHitUnit()->isAlive() || !_targetCount)
return;
- float resistance = float(GetHitUnit()->GetResistance(GetFirstSchoolInMask(SpellSchoolMask(GetSpellInfo()->SchoolMask))));
+ float resistance = float(GetHitUnit()->GetResistance(SpellSchoolMask(GetSpellInfo()->SchoolMask)));
uint32 minResistFactor = uint32((resistance / (resistance + 510.0f))* 10.0f) * 2;
uint32 randomResist = urand(0, (9 - minResistFactor) * 100)/100 + minResistFactor;
diff --git a/src/server/scripts/Northrend/IcecrownCitadel/boss_the_lich_king.cpp b/src/server/scripts/Northrend/IcecrownCitadel/boss_the_lich_king.cpp
index 1688624be91..2f4f225561c 100644
--- a/src/server/scripts/Northrend/IcecrownCitadel/boss_the_lich_king.cpp
+++ b/src/server/scripts/Northrend/IcecrownCitadel/boss_the_lich_king.cpp
@@ -1227,7 +1227,7 @@ class npc_tirion_fordring_tft : public CreatureScript
SetEquipmentSlots(true); // remove glow on ashbringer
}
- void sGossipSelect(Player* player, uint32 sender, uint32 action)
+ void sGossipSelect(Player* /*player*/, uint32 sender, uint32 action)
{
if (me->GetCreatureInfo()->GossipMenuId == sender && !action)
{
@@ -1335,7 +1335,7 @@ class npc_shambling_horror_icc : public CreatureScript
void DamageTaken(Unit* /*attacker*/, uint32& damage)
{
- if (IsHeroic() && me->HealthBelowPctDamaged(20, damage))
+ if (!_frenzied && IsHeroic() && me->HealthBelowPctDamaged(20, damage))
{
_frenzied = true;
DoCast(me, SPELL_FRENZY, true);
@@ -1407,14 +1407,14 @@ class npc_raging_spirit : public CreatureScript
DoCast(me, SPELL_BOSS_HITTIN_YA, true);
}
- void IsSummonedBy(Unit* summoner)
+ void IsSummonedBy(Unit* /*summoner*/)
{
// player is the spellcaster so register summon manually
if (Creature* lichKing = ObjectAccessor::GetCreature(*me, _instance->GetData64(DATA_THE_LICH_KING)))
lichKing->AI()->JustSummoned(me);
}
- void JustDied(Unit* killer)
+ void JustDied(Unit* /*killer*/)
{
if (Creature* lichKing = ObjectAccessor::GetCreature(*me, _instance->GetData64(DATA_THE_LICH_KING)))
lichKing->AI()->SummonedCreatureDespawn(me);
@@ -1931,7 +1931,7 @@ class npc_spirit_bomb : public CreatureScript
{
}
- void IsSummonedBy(Unit* summoner)
+ void IsSummonedBy(Unit* /*summoner*/)
{
float destX, destY, destZ;
me->GetPosition(destX, destY);
@@ -1954,7 +1954,7 @@ class npc_spirit_bomb : public CreatureScript
{
}
- void UpdateAI(uint32 const diff)
+ void UpdateAI(uint32 const /*diff*/)
{
UpdateVictim();
// no melee attacks
@@ -1983,7 +1983,7 @@ class npc_broken_frostmourne : public CreatureScript
_events.Reset();
}
- void IsSummonedBy(Unit* summoner)
+ void IsSummonedBy(Unit* /*summoner*/)
{
_events.SetPhase(PHASE_OUTRO);
_events.ScheduleEvent(EVENT_OUTRO_KNOCK_BACK, 3000, 0, PHASE_OUTRO);
@@ -2087,7 +2087,6 @@ class spell_the_lich_king_necrotic_plague : public SpellScriptLoader
void OnRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
{
- Unit* newCaster = GetTarget();
switch (GetTargetApplication()->GetRemoveMode())
{
case AURA_REMOVE_BY_ENEMY_SPELL:
@@ -2250,7 +2249,7 @@ class spell_the_lich_king_shadow_trap_visual : public SpellScriptLoader
{
PrepareAuraScript(spell_the_lich_king_shadow_trap_visual_AuraScript);
- void OnRemove(AuraEffect const* aurEff, AuraEffectHandleModes mode)
+ void OnRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
{
if (GetTargetApplication()->GetRemoveMode() == AURA_REMOVE_BY_EXPIRE)
GetTarget()->CastSpell(GetTarget(), SPELL_SHADOW_TRAP_AURA, TRIGGERED_NONE);
@@ -2633,7 +2632,7 @@ class spell_the_lich_king_cast_back_to_caster : public SpellScriptLoader
{
PrepareSpellScript(spell_the_lich_king_cast_back_to_caster_SpellScript);
- void HandleScript(SpellEffIndex effIndex)
+ void HandleScript(SpellEffIndex /*effIndex*/)
{
GetHitUnit()->CastSpell(GetCaster(), uint32(GetEffectValue()), true);
}
diff --git a/src/server/scripts/Northrend/Naxxramas/boss_kelthuzad.cpp b/src/server/scripts/Northrend/Naxxramas/boss_kelthuzad.cpp
index 9c3c9156d63..96c061f4c98 100644
--- a/src/server/scripts/Northrend/Naxxramas/boss_kelthuzad.cpp
+++ b/src/server/scripts/Northrend/Naxxramas/boss_kelthuzad.cpp
@@ -683,7 +683,7 @@ public:
// Note: summon must be done by trigger and not by KT.
// Otherwise, they attack immediately as KT is in combat.
- for (uint8 i = 0; i <= MAX_ABOMINATIONS; ++i)
+ for (uint8 i = 0; i < MAX_ABOMINATIONS; ++i)
{
if (Creature* sum = trigger->SummonCreature(NPC_ABOMINATION, PosAbominations[i]))
{
@@ -692,7 +692,7 @@ public:
sum->SetReactState(REACT_DEFENSIVE);
}
}
- for (uint8 i = 0; i <= MAX_WASTES; ++i)
+ for (uint8 i = 0; i < MAX_WASTES; ++i)
{
if (Creature* sum = trigger->SummonCreature(NPC_WASTE, PosWastes[i]))
{
@@ -701,7 +701,7 @@ public:
sum->SetReactState(REACT_DEFENSIVE);
}
}
- for (uint8 i = 0; i <= MAX_WEAVERS; ++i)
+ for (uint8 i = 0; i < MAX_WEAVERS; ++i)
{
if (Creature* sum = trigger->SummonCreature(NPC_WEAVER, PosWeavers[i]))
{
diff --git a/src/server/scripts/Northrend/Naxxramas/boss_patchwerk.cpp b/src/server/scripts/Northrend/Naxxramas/boss_patchwerk.cpp
index 10f1b809694..3b87dea025c 100644
--- a/src/server/scripts/Northrend/Naxxramas/boss_patchwerk.cpp
+++ b/src/server/scripts/Northrend/Naxxramas/boss_patchwerk.cpp
@@ -91,7 +91,7 @@ public:
_EnterCombat();
Enraged = false;
DoScriptText(RAND(SAY_AGGRO_1, SAY_AGGRO_2), me);
- events.ScheduleEvent(EVENT_HATEFUL, 1200);
+ events.ScheduleEvent(EVENT_HATEFUL, 1000);
events.ScheduleEvent(EVENT_BERSERK, 360000);
if (instance)
@@ -131,7 +131,7 @@ public:
DoCast(pMostHPTarget, RAID_MODE(SPELL_HATEFUL_STRIKE, H_SPELL_HATEFUL_STRIKE), true);
- events.ScheduleEvent(EVENT_HATEFUL, 1200);
+ events.ScheduleEvent(EVENT_HATEFUL, 1000);
break;
}
case EVENT_BERSERK:
@@ -140,7 +140,7 @@ public:
events.ScheduleEvent(EVENT_SLIME, 2000);
break;
case EVENT_SLIME:
- DoCast(me->getVictim(), SPELL_SLIME_BOLT);
+ DoCast(me->getVictim(), SPELL_SLIME_BOLT, true);
events.ScheduleEvent(EVENT_SLIME, 2000);
break;
}
diff --git a/src/server/scripts/Northrend/Naxxramas/boss_sapphiron.cpp b/src/server/scripts/Northrend/Naxxramas/boss_sapphiron.cpp
index d620289a72f..ed1bbd1971a 100644
--- a/src/server/scripts/Northrend/Naxxramas/boss_sapphiron.cpp
+++ b/src/server/scripts/Northrend/Naxxramas/boss_sapphiron.cpp
@@ -271,14 +271,18 @@ public:
break;
}
case EVENT_FLIGHT:
- phase = PHASE_FLIGHT;
- events.SetPhase(PHASE_FLIGHT);
- me->SetReactState(REACT_PASSIVE);
- me->AttackStop();
- float x, y, z, o;
- me->GetHomePosition(x, y, z, o);
- me->GetMotionMaster()->MovePoint(1, x, y, z);
- return;
+ if (HealthAbovePct(10))
+ {
+ phase = PHASE_FLIGHT;
+ events.SetPhase(PHASE_FLIGHT);
+ me->SetReactState(REACT_PASSIVE);
+ me->AttackStop();
+ float x, y, z, o;
+ me->GetHomePosition(x, y, z, o);
+ me->GetMotionMaster()->MovePoint(1, x, y, z);
+ return;
+ }
+ break;
}
}
diff --git a/src/server/scripts/Northrend/Ulduar/ulduar/boss_algalon.cpp b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_algalon.cpp
index 3888cc43bc9..3888cc43bc9 100644
--- a/src/server/scripts/Northrend/Ulduar/ulduar/boss_algalon.cpp
+++ b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_algalon.cpp
diff --git a/src/server/scripts/Northrend/Ulduar/ulduar/boss_assembly_of_iron.cpp b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_assembly_of_iron.cpp
index 2e2ca25385c..a8a4fad5e4e 100644
--- a/src/server/scripts/Northrend/Ulduar/ulduar/boss_assembly_of_iron.cpp
+++ b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_assembly_of_iron.cpp
@@ -56,8 +56,9 @@ enum AssemblySpells
SPELL_CHAIN_LIGHTNING = 61879,
SPELL_OVERLOAD = 61869,
SPELL_LIGHTNING_WHIRL = 61915,
- SPELL_LIGHTNING_TENDRILS = 61887,
- SPELL_LIGHTNING_TENDRILS_SELF_VISUAL = 61883,
+ SPELL_LIGHTNING_TENDRILS_10M = 61887,
+ SPELL_LIGHTNING_TENDRILS_25M = 63486,
+ SPELL_LIGHTNING_TENDRILS_VISUAL = 61883,
SPELL_STORMSHIELD = 64187,
};
@@ -215,7 +216,6 @@ class boss_steelbreaker : public CreatureScript
{
_Reset();
phase = 0;
- me->ResetLootMode();
me->RemoveAllAuras();
RespawnEncounter(instance, me);
}
@@ -342,7 +342,6 @@ class boss_runemaster_molgeim : public CreatureScript
{
_Reset();
phase = 0;
- me->ResetLootMode();
me->RemoveAllAuras();
RespawnEncounter(instance, me);
}
@@ -575,9 +574,10 @@ class boss_stormcaller_brundir : public CreatureScript
{
_Reset();
phase = 0;
- me->ResetLootMode();
me->RemoveAllAuras();
me->RemoveUnitMovementFlag(MOVEMENTFLAG_LEVITATING);
+ me->ApplySpellImmune(0, IMMUNITY_MECHANIC, MECHANIC_INTERRUPT, false); // Should be interruptable unless overridden by spell (Overload)
+ me->ApplySpellImmune(0, IMMUNITY_MECHANIC, MECHANIC_STUN, false); // Reset immumity, Brundir should be stunnable by default
RespawnEncounter(instance, me);
}
@@ -609,6 +609,7 @@ class boss_stormcaller_brundir : public CreatureScript
{
DoCast(me, SPELL_STORMSHIELD);
events.RescheduleEvent(EVENT_LIGHTNING_TENDRILS, urand(50000, 60000));
+ me->ApplySpellImmune(0, IMMUNITY_MECHANIC, MECHANIC_STUN, true); // Apply immumity to stuns
}
break;
@@ -677,10 +678,10 @@ class boss_stormcaller_brundir : public CreatureScript
break;
case EVENT_LIGHTNING_TENDRILS:
DoScriptText(SAY_BRUNDIR_FLIGHT, me);
- DoCast(SPELL_LIGHTNING_TENDRILS);
+ DoCast(RAID_MODE(SPELL_LIGHTNING_TENDRILS_10M, SPELL_LIGHTNING_TENDRILS_25M));
+ DoCast(SPELL_LIGHTNING_TENDRILS_VISUAL);
me->AttackStop();
- me->AddUnitMovementFlag(MOVEMENTFLAG_LEVITATING);
- DoCast(SPELL_LIGHTNING_TENDRILS_SELF_VISUAL);
+ //me->AddUnitMovementFlag(MOVEMENTFLAG_LEVITATING);
me->GetMotionMaster()->Initialize();
me->GetMotionMaster()->MovePoint(0, me->GetPositionX(), me->GetPositionY(), FINAL_FLIGHT_Z);
events.DelayEvents(35000);
@@ -707,11 +708,12 @@ class boss_stormcaller_brundir : public CreatureScript
events.ScheduleEvent(EVENT_GROUND, 2500);
break;
case EVENT_GROUND:
- me->RemoveUnitMovementFlag(MOVEMENTFLAG_LEVITATING);
- me->RemoveAurasDueToSpell(SPELL_LIGHTNING_TENDRILS);
- me->RemoveAurasDueToSpell(SPELL_LIGHTNING_TENDRILS_SELF_VISUAL);
+ //me->RemoveUnitMovementFlag(MOVEMENTFLAG_LEVITATING);
+ me->RemoveAurasDueToSpell(RAID_MODE(SPELL_LIGHTNING_TENDRILS_10M, SPELL_LIGHTNING_TENDRILS_25M));
+ me->RemoveAurasDueToSpell(SPELL_LIGHTNING_TENDRILS_VISUAL);
DoStartMovement(me->getVictim());
events.CancelEvent(EVENT_GROUND);
+ me->getThreatManager().resetAllAggro();
break;
case EVENT_MOVE_POSITION:
if (me->IsWithinMeleeRange(me->getVictim()))
diff --git a/src/server/scripts/Northrend/Ulduar/ulduar/boss_auriaya.cpp b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_auriaya.cpp
index bcc417c50cd..bcc417c50cd 100644
--- a/src/server/scripts/Northrend/Ulduar/ulduar/boss_auriaya.cpp
+++ b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_auriaya.cpp
diff --git a/src/server/scripts/Northrend/Ulduar/ulduar/boss_flame_leviathan.cpp b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_flame_leviathan.cpp
index ad79d1b56cc..ad79d1b56cc 100644
--- a/src/server/scripts/Northrend/Ulduar/ulduar/boss_flame_leviathan.cpp
+++ b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_flame_leviathan.cpp
diff --git a/src/server/scripts/Northrend/Ulduar/ulduar/boss_freya.cpp b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_freya.cpp
index f5a87431550..e7d8b070e53 100644
--- a/src/server/scripts/Northrend/Ulduar/ulduar/boss_freya.cpp
+++ b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_freya.cpp
@@ -282,7 +282,6 @@ class boss_freya : public CreatureScript
uint32 deforestation[6][2];
uint32 elementalTimer[2];
uint32 diffTimer;
- uint32 waveTime;
uint8 trioWaveCount;
uint8 trioWaveController;
uint8 waveCount;
@@ -291,14 +290,12 @@ class boss_freya : public CreatureScript
bool checkElementalAlive[2];
bool trioDefeated[2];
- bool waveInProgress;
bool random[3];
void Reset()
{
_Reset();
summons.clear();
- waveTime = 0;
trioWaveCount = 0;
trioWaveController = 0;
waveCount = 0;
@@ -315,7 +312,6 @@ class boss_freya : public CreatureScript
checkElementalAlive[n] = true;
trioDefeated[n] = false;
}
- waveInProgress = false;
for (uint8 n = 0; n < 3; ++n)
random[n] = false;
}
@@ -325,35 +321,12 @@ class boss_freya : public CreatureScript
DoScriptText(RAND(SAY_SLAY_1, SAY_SLAY_2), me);
}
- void DamageTaken(Unit* /*who*/, uint32& damage)
+ void DamageTaken(Unit* who, uint32& damage)
{
if (damage >= me->GetHealth())
{
damage = 0;
- DoScriptText(SAY_DEATH, me);
- me->SetReactState(REACT_PASSIVE);
- _JustDied();
- me->RemoveAllAuras();
- me->AttackStop();
- me->setFaction(35);
- me->DeleteThreatList();
- me->CombatStop(true);
- me->DespawnOrUnsummon(7500);
- me->CastSpell(me, SPELL_KNOCK_ON_WOOD_CREDIT, true);
-
- Creature* Elder[3];
- for (uint8 n = 0; n < 3; ++n)
- {
- Elder[n] = ObjectAccessor::GetCreature(*me, instance->GetData64(BOSS_BRIGHTLEAF + n));
- if (Elder[n] && Elder[n]->isAlive())
- {
- Elder[n]->RemoveAllAuras();
- Elder[n]->AttackStop();
- Elder[n]->CombatStop(true);
- Elder[n]->DeleteThreatList();
- Elder[n]->GetAI()->DoAction(ACTION_ELDER_FREYA_KILLED);
- }
- }
+ JustDied(who);
}
}
@@ -462,8 +435,6 @@ class boss_freya : public CreatureScript
events.ScheduleEvent(EVENT_UNSTABLE_ENERGY, urand(15000, 20000));
break;
case EVENT_WAVE:
- waveTime = 0;
- waveInProgress = true;
SpawnWave();
if (waveCount < 6)
events.ScheduleEvent(EVENT_WAVE, WAVE_TIME);
@@ -497,9 +468,6 @@ class boss_freya : public CreatureScript
diffTimer += diff; // For getting time difference for Deforestation achievement
- if (waveInProgress)
- waveTime += diff; // Time from the last wave
-
// Elementals must be killed within 12 seconds of each other, or they will all revive and heal
Creature* Elemental[3][2];
for (uint8 i = 0; i < 2; ++i)
@@ -543,7 +511,6 @@ class boss_freya : public CreatureScript
trioDefeated[i] = true;
Elemental[n][i]->CastSpell(me, SPELL_REMOVE_10STACK, true);
}
- TimeCheck();
}
}
}
@@ -633,9 +600,32 @@ class boss_freya : public CreatureScript
/* 25N */ {62952, 62954, 62956, 62958}
};
- who->CastSpell((Unit*)NULL, summonSpell[me->GetMap()->GetDifficulty()][elderCount], true);
+ me->CastSpell((Unit*)NULL, summonSpell[me->GetMap()->GetDifficulty()][elderCount], true);
+ DoScriptText(SAY_DEATH, me);
+ me->SetReactState(REACT_PASSIVE);
_JustDied();
+ me->RemoveAllAuras();
+ me->AttackStop();
+ me->setFaction(35);
+ me->DeleteThreatList();
+ me->CombatStop(true);
+ me->DespawnOrUnsummon(7500);
+ me->CastSpell(me, SPELL_KNOCK_ON_WOOD_CREDIT, true);
+
+ Creature* Elder[3];
+ for (uint8 n = 0; n < 3; ++n)
+ {
+ Elder[n] = ObjectAccessor::GetCreature(*me, instance->GetData64(BOSS_BRIGHTLEAF + n));
+ if (Elder[n] && Elder[n]->isAlive())
+ {
+ Elder[n]->RemoveAllAuras();
+ Elder[n]->AttackStop();
+ Elder[n]->CombatStop(true);
+ Elder[n]->DeleteThreatList();
+ Elder[n]->GetAI()->DoAction(ACTION_ELDER_FREYA_KILLED);
+ }
+ }
}
void JustSummoned(Creature* summoned)
@@ -653,6 +643,7 @@ class boss_freya : public CreatureScript
break;
case NPC_DETONATING_LASHER:
case NPC_ANCIENT_CONSERVATOR:
+ default:
summons.push_back(summoned->GetGUID());
break;
}
@@ -675,29 +666,14 @@ class boss_freya : public CreatureScript
summoned->CastSpell(who, SPELL_DETONATE, true);
summoned->ForcedDespawn(5000);
summons.remove(summoned->GetGUID());
- TimeCheck();
break;
case NPC_ANCIENT_CONSERVATOR:
summoned->CastSpell(me, SPELL_REMOVE_25STACK, true);
summoned->ForcedDespawn(5000);
summons.remove(summoned->GetGUID());
- TimeCheck();
break;
}
}
-
- void TimeCheck()
- {
- if (waveCount >= 6)
- return;
-
- waveInProgress = false;
- uint32 timeDifference = WAVE_TIME - waveTime;
- if (timeDifference <= TIME_DIFFERENCE)
- events.RescheduleEvent(EVENT_WAVE, timeDifference);
- else
- events.RescheduleEvent(EVENT_WAVE, TIME_DIFFERENCE);
- }
};
CreatureAI* GetAI(Creature* creature) const
diff --git a/src/server/scripts/Northrend/Ulduar/ulduar/boss_general_vezax.cpp b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_general_vezax.cpp
index 7d00c0e59fc..7d00c0e59fc 100644
--- a/src/server/scripts/Northrend/Ulduar/ulduar/boss_general_vezax.cpp
+++ b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_general_vezax.cpp
diff --git a/src/server/scripts/Northrend/Ulduar/ulduar/boss_hodir.cpp b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_hodir.cpp
index bb21da94bc5..bb21da94bc5 100644
--- a/src/server/scripts/Northrend/Ulduar/ulduar/boss_hodir.cpp
+++ b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_hodir.cpp
diff --git a/src/server/scripts/Northrend/Ulduar/ulduar/boss_ignis.cpp b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_ignis.cpp
index b8876ae577a..b8876ae577a 100644
--- a/src/server/scripts/Northrend/Ulduar/ulduar/boss_ignis.cpp
+++ b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_ignis.cpp
diff --git a/src/server/scripts/Northrend/Ulduar/ulduar/boss_kologarn.cpp b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_kologarn.cpp
index 5da1c485986..5da1c485986 100644
--- a/src/server/scripts/Northrend/Ulduar/ulduar/boss_kologarn.cpp
+++ b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_kologarn.cpp
diff --git a/src/server/scripts/Northrend/Ulduar/ulduar/boss_mimiron.cpp b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_mimiron.cpp
index 11b7c54975e..11b7c54975e 100644
--- a/src/server/scripts/Northrend/Ulduar/ulduar/boss_mimiron.cpp
+++ b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_mimiron.cpp
diff --git a/src/server/scripts/Northrend/Ulduar/ulduar/boss_razorscale.cpp b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_razorscale.cpp
index 0e3a8926203..0e3a8926203 100644
--- a/src/server/scripts/Northrend/Ulduar/ulduar/boss_razorscale.cpp
+++ b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_razorscale.cpp
diff --git a/src/server/scripts/Northrend/Ulduar/ulduar/boss_thorim.cpp b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_thorim.cpp
index f993c419b8c..f993c419b8c 100644
--- a/src/server/scripts/Northrend/Ulduar/ulduar/boss_thorim.cpp
+++ b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_thorim.cpp
diff --git a/src/server/scripts/Northrend/Ulduar/ulduar/boss_xt002.cpp b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_xt002.cpp
index ae803b24642..ae803b24642 100644
--- a/src/server/scripts/Northrend/Ulduar/ulduar/boss_xt002.cpp
+++ b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_xt002.cpp
diff --git a/src/server/scripts/Northrend/Ulduar/ulduar/boss_yoggsaron.cpp b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_yoggsaron.cpp
index e4b21e1f66e..e4b21e1f66e 100644
--- a/src/server/scripts/Northrend/Ulduar/ulduar/boss_yoggsaron.cpp
+++ b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_yoggsaron.cpp
diff --git a/src/server/scripts/Northrend/Ulduar/ulduar/instance_ulduar.cpp b/src/server/scripts/Northrend/Ulduar/Ulduar/instance_ulduar.cpp
index 3c5697a7995..3c5697a7995 100644
--- a/src/server/scripts/Northrend/Ulduar/ulduar/instance_ulduar.cpp
+++ b/src/server/scripts/Northrend/Ulduar/Ulduar/instance_ulduar.cpp
diff --git a/src/server/scripts/Northrend/Ulduar/ulduar/ulduar.h b/src/server/scripts/Northrend/Ulduar/Ulduar/ulduar.h
index f11212d535e..f11212d535e 100644
--- a/src/server/scripts/Northrend/Ulduar/ulduar/ulduar.h
+++ b/src/server/scripts/Northrend/Ulduar/Ulduar/ulduar.h
diff --git a/src/server/scripts/Northrend/Ulduar/ulduar/ulduar_teleporter.cpp b/src/server/scripts/Northrend/Ulduar/Ulduar/ulduar_teleporter.cpp
index 05b1e395d1e..05b1e395d1e 100644
--- a/src/server/scripts/Northrend/Ulduar/ulduar/ulduar_teleporter.cpp
+++ b/src/server/scripts/Northrend/Ulduar/Ulduar/ulduar_teleporter.cpp
diff --git a/src/server/scripts/Northrend/UtgardeKeep/UtgardeKeep/boss_ingvar_the_plunderer.cpp b/src/server/scripts/Northrend/UtgardeKeep/UtgardeKeep/boss_ingvar_the_plunderer.cpp
index 55211f3f047..dc2d34326a7 100644
--- a/src/server/scripts/Northrend/UtgardeKeep/UtgardeKeep/boss_ingvar_the_plunderer.cpp
+++ b/src/server/scripts/Northrend/UtgardeKeep/UtgardeKeep/boss_ingvar_the_plunderer.cpp
@@ -130,7 +130,7 @@ public:
me->SetHealth(0);
me->InterruptNonMeleeSpells(true);
me->RemoveAllAuras();
- me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_OOC_NOT_ATTACKABLE);
+ me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
me->GetMotionMaster()->MovementExpired(false);
me->GetMotionMaster()->MoveIdle();
me->SetStandState(UNIT_STAND_STATE_DEAD);
@@ -152,7 +152,7 @@ public:
{
bIsUndead = true;
bEventInProgress = false;
- me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_OOC_NOT_ATTACKABLE);
+ me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
me->UpdateEntry(MOB_INGVAR_UNDEAD);
me->SetInCombatWith(me->getVictim());
me->GetMotionMaster()->MoveChase(me->getVictim());
diff --git a/src/server/scripts/Northrend/UtgardeKeep/UtgardePinnacle/boss_svala.cpp b/src/server/scripts/Northrend/UtgardeKeep/UtgardePinnacle/boss_svala.cpp
index 1b70de6244e..45534824860 100644
--- a/src/server/scripts/Northrend/UtgardeKeep/UtgardePinnacle/boss_svala.cpp
+++ b/src/server/scripts/Northrend/UtgardeKeep/UtgardePinnacle/boss_svala.cpp
@@ -48,7 +48,7 @@ enum Yells
};
enum Creatures
{
- CREATURE_ARTHAS = 24266, // Image of Arthas
+ CREATURE_ARTHAS = 29280, // Image of Arthas
CREATURE_SVALA_SORROWGRAVE = 26668, // Svala after transformation
CREATURE_SVALA = 29281, // Svala before transformation
CREATURE_RITUAL_CHANNELER = 27281
@@ -136,7 +136,6 @@ public:
if (Creature* pArthas = me->SummonCreature(CREATURE_ARTHAS, ArthasPos, TEMPSUMMON_MANUAL_DESPAWN))
{
pArthas->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_NOT_SELECTABLE);
- pArthas->SetFloatValue(OBJECT_FIELD_SCALE_X, 5);
uiArthasGUID = pArthas->GetGUID();
}
}
diff --git a/src/server/scripts/Northrend/borean_tundra.cpp b/src/server/scripts/Northrend/borean_tundra.cpp
index 9c40fbb3f82..96f1cb49b84 100644
--- a/src/server/scripts/Northrend/borean_tundra.cpp
+++ b/src/server/scripts/Northrend/borean_tundra.cpp
@@ -2125,7 +2125,7 @@ public:
{
Quest const* qInfo = sObjectMgr->GetQuestTemplate(QUEST_YOU_RE_NOT_SO_BIG_NOW);
if (qInfo)
- CAST_PLR(killer)->KilledMonsterCredit(qInfo->ReqCreatureOrGOId[0], 0);
+ CAST_PLR(killer)->KilledMonsterCredit(qInfo->RequiredNpcOrGo[0], 0);
}
}
};
diff --git a/src/server/scripts/Northrend/dalaran.cpp b/src/server/scripts/Northrend/dalaran.cpp
index be9e9308f4f..8ff5a314dcc 100644
--- a/src/server/scripts/Northrend/dalaran.cpp
+++ b/src/server/scripts/Northrend/dalaran.cpp
@@ -70,8 +70,9 @@ public:
return;
Player* player = who->GetCharmerOrOwnerPlayerOrPlayerItself();
-
- if (!player || player->isGameMaster() || player->IsBeingTeleported())
+
+ // If player has Disguise aura for quest A Meeting With The Magister or An Audience With The Arcanist, do not teleport it away but let it pass
+ if (!player || player->isGameMaster() || player->IsBeingTeleported() || player->HasAura(70973) || player->HasAura(70971))
return;
switch (me->GetEntry())
diff --git a/src/server/scripts/Northrend/sholazar_basin.cpp b/src/server/scripts/Northrend/sholazar_basin.cpp
index b3f1fb1b8b0..6f9481ec226 100644
--- a/src/server/scripts/Northrend/sholazar_basin.cpp
+++ b/src/server/scripts/Northrend/sholazar_basin.cpp
@@ -98,8 +98,7 @@ public:
me->SetUnitMovementFlags(MOVEMENTFLAG_JUMPING);
break;
case 28:
- if (Player* player = GetPlayerForEscort())
- player->GroupEventHappens(QUEST_FORTUNATE_MISUNDERSTANDINGS, me);
+ player->GroupEventHappens(QUEST_FORTUNATE_MISUNDERSTANDINGS, me);
// me->RestoreFaction();
DoScriptText(SAY_END_IRO, me);
SetRun(false);
diff --git a/src/server/scripts/Northrend/zuldrak.cpp b/src/server/scripts/Northrend/zuldrak.cpp
index 5dab265617e..aa3b696f5fd 100644
--- a/src/server/scripts/Northrend/zuldrak.cpp
+++ b/src/server/scripts/Northrend/zuldrak.cpp
@@ -1219,9 +1219,9 @@ public:
{
if (uiMissleTimer <= uiDiff)
{
- DoCast(me, uiSpell); // this spell is not supported ... YET!
+ if (uiSpell) // Sometimes it is 0, why?
+ DoCast(me, uiSpell); // this spell (what spell) is not supported ... YET!
uiMissleTimer = urand(2000, 7000);
-
} else uiMissleTimer -= uiDiff;
}
diff --git a/src/server/scripts/OutdoorPvP/OutdoorPvPNA.cpp b/src/server/scripts/OutdoorPvP/OutdoorPvPNA.cpp
index c081f0970f2..9b0a4a469ae 100755
--- a/src/server/scripts/OutdoorPvP/OutdoorPvPNA.cpp
+++ b/src/server/scripts/OutdoorPvP/OutdoorPvPNA.cpp
@@ -384,7 +384,7 @@ bool OPvPCapturePointNA::HandleCustomSpell(Player* player, uint32 spellId, GameO
int32 count = 10;
uint32 itemid = 24538;
// bomb id count
- uint8 msg = player->CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, itemid, count, &noSpaceForCount);
+ InventoryResult msg = player->CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, itemid, count, &noSpaceForCount);
if (msg != EQUIP_ERR_OK) // convert to possible store amount
count -= noSpaceForCount;
diff --git a/src/server/scripts/Outland/Auchindoun/AuchenaiCrypts/boss_exarch_maladaar.cpp b/src/server/scripts/Outland/Auchindoun/AuchenaiCrypts/boss_exarch_maladaar.cpp
index 7b0c8fc017e..a9f84016a04 100644
--- a/src/server/scripts/Outland/Auchindoun/AuchenaiCrypts/boss_exarch_maladaar.cpp
+++ b/src/server/scripts/Outland/Auchindoun/AuchenaiCrypts/boss_exarch_maladaar.cpp
@@ -193,7 +193,7 @@ public:
void MoveInLineOfSight(Unit* who)
{
- if (!HasTaunted && me->IsWithinDistInMap(who, 150.0))
+ if (!HasTaunted && me->IsWithinDistInMap(who, 150.0f))
{
DoScriptText(SAY_INTRO, me);
HasTaunted = true;
diff --git a/src/server/scripts/Outland/BlackTemple/boss_shade_of_akama.cpp b/src/server/scripts/Outland/BlackTemple/boss_shade_of_akama.cpp
index ce1f8739493..58585d0028e 100644
--- a/src/server/scripts/Outland/BlackTemple/boss_shade_of_akama.cpp
+++ b/src/server/scripts/Outland/BlackTemple/boss_shade_of_akama.cpp
@@ -641,7 +641,7 @@ public:
void EnterCombat(Unit* /*who*/) {}
- void BeginEvent(Player* pl)
+ void BeginEvent(Player* player)
{
if (!instance)
return;
@@ -662,7 +662,7 @@ public:
me->CombatStart(Shade);
Shade->SetUInt32Value(UNIT_NPC_EMOTESTATE, EMOTE_STATE_NONE);
Shade->SetTarget(me->GetGUID());
- if (pl) Shade->AddThreat(pl, 1.0f);
+ if (player) Shade->AddThreat(player, 1.0f);
DoZoneInCombat(Shade);
EventBegun = true;
}
diff --git a/src/server/scripts/Outland/BlackTemple/boss_warlord_najentus.cpp b/src/server/scripts/Outland/BlackTemple/boss_warlord_najentus.cpp
index 1f603699060..6bf26e795ca 100644
--- a/src/server/scripts/Outland/BlackTemple/boss_warlord_najentus.cpp
+++ b/src/server/scripts/Outland/BlackTemple/boss_warlord_najentus.cpp
@@ -94,7 +94,7 @@ public:
void KilledUnit(Unit* /*victim*/)
{
- DoScriptText(rand()%2 ? SAY_SLAY1 : SAY_SLAY2, me);
+ DoScriptText(urand(0, 1) ? SAY_SLAY1 : SAY_SLAY2, me);
events.DelayEvents(5000, GCD_YELL);
}
@@ -175,7 +175,7 @@ public:
SpineTargetGUID = target->GetGUID();
//must let target summon, otherwise you cannot click the spine
target->SummonGameObject(GOBJECT_SPINE, target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(), me->GetOrientation(), 0, 0, 0, 0, 30);
- DoScriptText(rand()%2 ? SAY_NEEDLE1 : SAY_NEEDLE2, me);
+ DoScriptText(urand(0, 1) ? SAY_NEEDLE1 : SAY_NEEDLE2, me);
events.DelayEvents(1500, GCD_CAST);
events.DelayEvents(15000, GCD_YELL);
}
diff --git a/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_lurker_below.cpp b/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_lurker_below.cpp
index f69aa1f0757..f8ed96632df 100644
--- a/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_lurker_below.cpp
+++ b/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_lurker_below.cpp
@@ -234,7 +234,7 @@ public:
{
me->MonsterTextEmote(EMOTE_SPOUT, 0, true);
me->SetReactState(REACT_PASSIVE);
- me->GetMotionMaster()->MoveRotate(20000, rand()%2 ? ROTATE_DIRECTION_LEFT : ROTATE_DIRECTION_RIGHT);
+ me->GetMotionMaster()->MoveRotate(20000, urand(0, 1) ? ROTATE_DIRECTION_LEFT : ROTATE_DIRECTION_RIGHT);
SpoutTimer = 45000;
WhirlTimer = 20000;//whirl directly after spout
RotTimer = 20000;
diff --git a/src/server/scripts/Outland/nagrand.cpp b/src/server/scripts/Outland/nagrand.cpp
index b639050320c..c556253ecf1 100644
--- a/src/server/scripts/Outland/nagrand.cpp
+++ b/src/server/scripts/Outland/nagrand.cpp
@@ -19,330 +19,20 @@
/* ScriptData
SDName: Nagrand
SD%Complete: 90
-SDComment: Quest support: 9849, 9868, 9918, 9874, 9991, 10107, 10108, 10044, 10172, 10646, 10085, 10987. TextId's unknown for altruis_the_sufferer and greatmother_geyah (npc_text)
+SDComment: Quest support: 9868, 9874, 10044, 10172, 10085. TextId's unknown for altruis_the_sufferer and greatmother_geyah (npc_text)
SDCategory: Nagrand
EndScriptData */
/* ContentData
-mob_shattered_rumbler
-mob_lump
-npc_altruis_the_sufferer
npc_greatmother_geyah
-npc_lantresor_of_the_blade
npc_maghar_captive
npc_creditmarker_visit_with_ancestors
-mob_sparrowhawk
EndContentData */
#include "ScriptPCH.h"
#include "ScriptedEscortAI.h"
/*######
-## mob_shattered_rumbler - this should be done with ACID
-######*/
-
-class mob_shattered_rumbler : public CreatureScript
-{
-public:
- mob_shattered_rumbler() : CreatureScript("mob_shattered_rumbler") { }
-
- CreatureAI* GetAI(Creature* creature) const
- {
- return new mob_shattered_rumblerAI (creature);
- }
-
- struct mob_shattered_rumblerAI : public ScriptedAI
- {
- bool Spawn;
-
- mob_shattered_rumblerAI(Creature* c) : ScriptedAI(c) {}
-
- void Reset()
- {
- Spawn = false;
- }
-
- void EnterCombat(Unit* /*who*/) {}
-
- void SpellHit(Unit* Hitter, const SpellInfo* Spellkind)
- {
- if (Spellkind->Id == 32001 && !Spawn)
- {
- float x = me->GetPositionX();
- float y = me->GetPositionY();
- float z = me->GetPositionZ();
-
- Hitter->SummonCreature(18181, x+(0.7f * (rand()%30)), y+(rand()%5), z, 0, TEMPSUMMON_CORPSE_TIMED_DESPAWN, 60000);
- Hitter->SummonCreature(18181, x+(rand()%5), y-(rand()%5), z, 0, TEMPSUMMON_CORPSE_TIMED_DESPAWN, 60000);
- Hitter->SummonCreature(18181, x-(rand()%5), y+(0.5f *(rand()%60)), z, 0, TEMPSUMMON_CORPSE_TIMED_DESPAWN, 60000);
- me->setDeathState(CORPSE);
- Spawn = true;
- }
- return;
- }
- };
-
-};
-
-/*######
-## mob_lump
-######*/
-
-#define SPELL_VISUAL_SLEEP 16093
-#define SPELL_SPEAR_THROW 32248
-
-#define LUMP_SAY0 -1000190
-#define LUMP_SAY1 -1000191
-
-#define LUMP_DEFEAT -1000192
-
-#define GOSSIP_HL "I need answers, ogre!"
-#define GOSSIP_SL1 "Why are Boulderfist out this far? You know that this is Kurenai territory."
-#define GOSSIP_SL2 "And you think you can just eat anything you want? You're obviously trying to eat the Broken of Telaar."
-#define GOSSIP_SL3 "This means war, Lump! War I say!"
-
-class mob_lump : public CreatureScript
-{
-public:
- mob_lump() : CreatureScript("mob_lump") { }
-
- bool OnGossipSelect(Player* player, Creature* creature, uint32 /*uiSender*/, uint32 uiAction)
- {
- player->PlayerTalkClass->ClearMenus();
- switch (uiAction)
- {
- case GOSSIP_ACTION_INFO_DEF:
- player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_SL1, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1);
- player->SEND_GOSSIP_MENU(9353, creature->GetGUID());
- break;
- case GOSSIP_ACTION_INFO_DEF+1:
- player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_SL2, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2);
- player->SEND_GOSSIP_MENU(9354, creature->GetGUID());
- break;
- case GOSSIP_ACTION_INFO_DEF+2:
- player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_SL3, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 3);
- player->SEND_GOSSIP_MENU(9355, creature->GetGUID());
- break;
- case GOSSIP_ACTION_INFO_DEF+3:
- player->SEND_GOSSIP_MENU(9356, creature->GetGUID());
- player->TalkedToCreature(18354, creature->GetGUID());
- break;
- }
- return true;
- }
-
- bool OnGossipHello(Player* player, Creature* creature)
- {
- if (player->GetQuestStatus(9918) == QUEST_STATUS_INCOMPLETE)
- player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_HL, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF);
-
- player->SEND_GOSSIP_MENU(9352, creature->GetGUID());
-
- return true;
- }
-
- CreatureAI* GetAI(Creature* creature) const
- {
- return new mob_lumpAI(creature);
- }
-
- struct mob_lumpAI : public ScriptedAI
- {
- mob_lumpAI(Creature* c) : ScriptedAI(c)
- {
- bReset = false;
- }
-
- uint32 Reset_Timer;
- uint32 Spear_Throw_Timer;
- bool bReset;
-
- void Reset()
- {
- Reset_Timer = 60000;
- Spear_Throw_Timer = 2000;
-
- me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
- }
-
- void AttackedBy(Unit* pAttacker)
- {
- if (me->getVictim())
- return;
-
- if (me->IsFriendlyTo(pAttacker))
- return;
-
- AttackStart(pAttacker);
- }
-
- void DamageTaken(Unit* done_by, uint32 & damage)
- {
- if (done_by->GetTypeId() == TYPEID_PLAYER && me->HealthBelowPctDamaged(30, damage))
- {
- if (!bReset && CAST_PLR(done_by)->GetQuestStatus(9918) == QUEST_STATUS_INCOMPLETE)
- {
- //Take 0 damage
- damage = 0;
-
- CAST_PLR(done_by)->AttackStop();
- me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
- me->RemoveAllAuras();
- me->DeleteThreatList();
- me->CombatStop(true);
- me->setFaction(1080); //friendly
- me->SetStandState(UNIT_STAND_STATE_SIT);
- DoScriptText(LUMP_DEFEAT, me);
-
- bReset = true;
- }
- }
- }
-
- void EnterCombat(Unit* /*who*/)
- {
- if (me->HasAura(SPELL_VISUAL_SLEEP))
- me->RemoveAura(SPELL_VISUAL_SLEEP);
-
- if (!me->IsStandState())
- me->SetStandState(UNIT_STAND_STATE_STAND);
-
- DoScriptText(RAND(LUMP_SAY0, LUMP_SAY1), me);
- }
-
- void UpdateAI(const uint32 diff)
- {
- //check if we waiting for a reset
- if (bReset)
- {
- if (Reset_Timer <= diff)
- {
- EnterEvadeMode();
- bReset = false;
- me->setFaction(1711); //hostile
- return;
- }
- else Reset_Timer -= diff;
- }
-
- //Return since we have no target
- if (!UpdateVictim())
- return;
-
- //Spear_Throw_Timer
- if (Spear_Throw_Timer <= diff)
- {
- DoCast(me->getVictim(), SPELL_SPEAR_THROW);
- Spear_Throw_Timer = 20000;
- } else Spear_Throw_Timer -= diff;
-
- DoMeleeAttackIfReady();
- }
- };
-
-};
-
-/*######
-## npc_altruis_the_sufferer
-######*/
-
-#define GOSSIP_HATS1 "I see twisted steel and smell sundered earth."
-#define GOSSIP_HATS2 "Well...?"
-#define GOSSIP_HATS3 "[PH] Story about Illidan's Pupil"
-
-#define GOSSIP_SATS1 "Legion?"
-#define GOSSIP_SATS2 "And now?"
-#define GOSSIP_SATS3 "How do you see them now?"
-#define GOSSIP_SATS4 "Forge camps?"
-#define GOSSIP_SATS5 "Ok."
-#define GOSSIP_SATS6 "[PH] Story done"
-
-class npc_altruis_the_sufferer : public CreatureScript
-{
-public:
- npc_altruis_the_sufferer() : CreatureScript("npc_altruis_the_sufferer") { }
-
- bool OnQuestAccept(Player* player, Creature* /*creature*/, Quest const* /*quest*/)
- {
- if (!player->GetQuestRewardStatus(9991)) //Survey the Land, q-id 9991
- {
- player->CLOSE_GOSSIP_MENU();
- player->ActivateTaxiPathTo(532); //TaxiPath 532
- }
- return true;
- }
-
- bool OnGossipSelect(Player* player, Creature* creature, uint32 /*uiSender*/, uint32 uiAction)
- {
- player->PlayerTalkClass->ClearMenus();
- switch (uiAction)
- {
- case GOSSIP_ACTION_INFO_DEF+10:
- player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_SATS1, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 11);
- player->SEND_GOSSIP_MENU(9420, creature->GetGUID());
- break;
- case GOSSIP_ACTION_INFO_DEF+11:
- player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_SATS2, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 12);
- player->SEND_GOSSIP_MENU(9421, creature->GetGUID());
- break;
- case GOSSIP_ACTION_INFO_DEF+12:
- player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_SATS3, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 13);
- player->SEND_GOSSIP_MENU(9422, creature->GetGUID());
- break;
- case GOSSIP_ACTION_INFO_DEF+13:
- player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_SATS4, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 14);
- player->SEND_GOSSIP_MENU(9423, creature->GetGUID());
- break;
- case GOSSIP_ACTION_INFO_DEF+14:
- player->SEND_GOSSIP_MENU(9424, creature->GetGUID());
- break;
-
- case GOSSIP_ACTION_INFO_DEF+20:
- player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_SATS5, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 21);
- player->SEND_GOSSIP_MENU(9427, creature->GetGUID());
- break;
- case GOSSIP_ACTION_INFO_DEF+21:
- player->CLOSE_GOSSIP_MENU();
- player->AreaExploredOrEventHappens(9991);
- break;
-
- case GOSSIP_ACTION_INFO_DEF+30:
- player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_SATS6, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 31);
- player->SEND_GOSSIP_MENU(384, creature->GetGUID());
- break;
- case GOSSIP_ACTION_INFO_DEF+31:
- player->CLOSE_GOSSIP_MENU();
- player->AreaExploredOrEventHappens(10646);
- break;
- }
- return true;
- }
-
- bool OnGossipHello(Player* player, Creature* creature)
- {
- if (creature->isQuestGiver())
- player->PrepareQuestMenu(creature->GetGUID());
-
- //gossip before obtaining Survey the Land
- if (player->GetQuestStatus(9991) == QUEST_STATUS_NONE)
- player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_HATS1, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+10);
-
- //gossip when Survey the Land is incomplete (technically, after the flight)
- if (player->GetQuestStatus(9991) == QUEST_STATUS_INCOMPLETE)
- player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_HATS2, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+20);
-
- //wowwiki.com/Varedis
- if (player->GetQuestStatus(10646) == QUEST_STATUS_INCOMPLETE)
- player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_HATS3, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+30);
-
- player->SEND_GOSSIP_MENU(9419, creature->GetGUID());
-
- return true;
- }
-
-};
-
-/*######
## npc_greatmother_geyah
######*/
@@ -453,83 +143,6 @@ public:
};
-/*######
-## npc_lantresor_of_the_blade
-######*/
-
-#define GOSSIP_HLB "I have killed many of your ogres, Lantresor. I have no fear."
-#define GOSSIP_SLB1 "Should I know? You look like an orc to me."
-#define GOSSIP_SLB2 "And the other half?"
-#define GOSSIP_SLB3 "I have heard of your kind, but I never thought to see the day when I would meet a half-breed."
-#define GOSSIP_SLB4 "My apologies. I did not mean to offend. I am here on behalf of my people."
-#define GOSSIP_SLB5 "My people ask that you pull back your Boulderfist ogres and cease all attacks on our territories. In return, we will also pull back our forces."
-#define GOSSIP_SLB6 "We will fight you until the end, then, Lantresor. We will not stand idly by as you pillage our towns and kill our people."
-#define GOSSIP_SLB7 "What do I need to do?"
-
-class npc_lantresor_of_the_blade : public CreatureScript
-{
-public:
- npc_lantresor_of_the_blade() : CreatureScript("npc_lantresor_of_the_blade") { }
-
- bool OnGossipSelect(Player* player, Creature* creature, uint32 /*uiSender*/, uint32 uiAction)
- {
- player->PlayerTalkClass->ClearMenus();
- switch (uiAction)
- {
- case GOSSIP_ACTION_INFO_DEF:
- player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_SLB1, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1);
- player->SEND_GOSSIP_MENU(9362, creature->GetGUID());
- break;
- case GOSSIP_ACTION_INFO_DEF+1:
- player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_SLB2, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2);
- player->SEND_GOSSIP_MENU(9363, creature->GetGUID());
- break;
- case GOSSIP_ACTION_INFO_DEF+2:
- player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_SLB3, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 3);
- player->SEND_GOSSIP_MENU(9364, creature->GetGUID());
- break;
- case GOSSIP_ACTION_INFO_DEF+3:
- player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_SLB4, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 4);
- player->SEND_GOSSIP_MENU(9365, creature->GetGUID());
- break;
- case GOSSIP_ACTION_INFO_DEF+4:
- player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_SLB5, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 5);
- player->SEND_GOSSIP_MENU(9366, creature->GetGUID());
- break;
- case GOSSIP_ACTION_INFO_DEF+5:
- player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_SLB6, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 6);
- player->SEND_GOSSIP_MENU(9367, creature->GetGUID());
- break;
- case GOSSIP_ACTION_INFO_DEF+6:
- player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_SLB7, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 7);
- player->SEND_GOSSIP_MENU(9368, creature->GetGUID());
- break;
- case GOSSIP_ACTION_INFO_DEF+7:
- player->SEND_GOSSIP_MENU(9369, creature->GetGUID());
- if (player->GetQuestStatus(10107) == QUEST_STATUS_INCOMPLETE)
- player->AreaExploredOrEventHappens(10107);
- if (player->GetQuestStatus(10108) == QUEST_STATUS_INCOMPLETE)
- player->AreaExploredOrEventHappens(10108);
- break;
- }
- return true;
- }
-
- bool OnGossipHello(Player* player, Creature* creature)
- {
- if (creature->isQuestGiver())
- player->PrepareQuestMenu(creature->GetGUID());
-
- if (player->GetQuestStatus(10107) == QUEST_STATUS_INCOMPLETE || player->GetQuestStatus(10108) == QUEST_STATUS_INCOMPLETE)
- player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_HLB, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF);
-
- player->SEND_GOSSIP_MENU(9361, creature->GetGUID());
-
- return true;
- }
-
-};
-
/*#####
## npc_maghar_captive
#####*/
@@ -747,113 +360,9 @@ public:
};
/*######
-## mob_sparrowhawk
+## go_corkis_prison and npc_corki
######*/
-#define SPELL_SPARROWHAWK_NET 39810
-#define SPELL_ITEM_CAPTIVE_SPARROWHAWK 39812
-
-class mob_sparrowhawk : public CreatureScript
-{
-public:
- mob_sparrowhawk() : CreatureScript("mob_sparrowhawk") { }
-
- CreatureAI* GetAI(Creature* creature) const
- {
- return new mob_sparrowhawkAI (creature);
- }
-
- struct mob_sparrowhawkAI : public ScriptedAI
- {
-
- mob_sparrowhawkAI(Creature* c) : ScriptedAI(c) {}
-
- uint32 Check_Timer;
- uint64 PlayerGUID;
- bool fleeing;
-
- void Reset()
- {
- me->RemoveAurasDueToSpell(SPELL_SPARROWHAWK_NET);
- Check_Timer = 1000;
- PlayerGUID = 0;
- fleeing = false;
- }
- void AttackStart(Unit* who)
- {
- if (PlayerGUID)
- return;
-
- ScriptedAI::AttackStart(who);
- }
-
- void EnterCombat(Unit* /*who*/) {}
-
- void MoveInLineOfSight(Unit* who)
- {
- if (!who || PlayerGUID)
- return;
-
- if (!PlayerGUID && who->GetTypeId() == TYPEID_PLAYER && me->IsWithinDistInMap(who, 30) && CAST_PLR(who)->GetQuestStatus(10987) == QUEST_STATUS_INCOMPLETE)
- {
- PlayerGUID = who->GetGUID();
- return;
- }
-
- ScriptedAI::MoveInLineOfSight(who);
- }
-
- void UpdateAI(const uint32 diff)
- {
- if (Check_Timer <= diff)
- {
- if (PlayerGUID)
- {
- if (fleeing && me->GetMotionMaster()->GetCurrentMovementGeneratorType() != FLEEING_MOTION_TYPE)
- fleeing = false;
-
- Player* player = Unit::GetPlayer(*me, PlayerGUID);
- if (player && me->IsWithinDistInMap(player, 30))
- {
- if (!fleeing)
- {
- me->DeleteThreatList();
- me->GetMotionMaster()->MoveFleeing(player);
- fleeing = true;
- }
- }
- else if (fleeing)
- {
- me->GetMotionMaster()->MovementExpired(false);
- PlayerGUID = 0;
- fleeing = false;
- }
- }
- Check_Timer = 1000;
- } else Check_Timer -= diff;
-
- if (PlayerGUID)
- return;
-
- ScriptedAI::UpdateAI(diff);
- }
-
- void SpellHit(Unit* caster, const SpellInfo* spell)
- {
- if (caster->GetTypeId() == TYPEID_PLAYER)
- {
- if (spell->Id == SPELL_SPARROWHAWK_NET && CAST_PLR(caster)->GetQuestStatus(10987) == QUEST_STATUS_INCOMPLETE)
- {
- DoCast(caster, SPELL_ITEM_CAPTIVE_SPARROWHAWK, true);
- me->DealDamage(me, me->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false);
- me->RemoveFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_LOOTABLE);
- }
- }
- return;
- }
- };
-};
-
enum CorkiData
{
// first quest
@@ -916,10 +425,6 @@ public:
}
};
-/*######
-## npc_corki
-######*/
-
class npc_corki : public CreatureScript
{
public:
@@ -970,16 +475,237 @@ public:
};
};
+/*#####
+## npc_kurenai_captive
+#####*/
+
+enum KurenaiCaptive
+{
+ SAY_KUR_START = 0,
+ SAY_KUR_NO_ESCAPE = 1,
+ SAY_KUR_MORE = 2,
+ SAY_KUR_MORE_TWO = 3,
+ SAY_KUR_LIGHTNING = 4,
+ SAY_KUR_SHOCK = 5,
+ SAY_KUR_COMPLETE = 6,
+
+ SPELL_KUR_CHAIN_LIGHTNING = 16006,
+ SPELL_KUR_EARTHBIND_TOTEM = 15786,
+ SPELL_KUR_FROST_SHOCK = 12548,
+ SPELL_KUR_HEALING_WAVE = 12491,
+
+ QUEST_TOTEM_KARDASH_A = 9879,
+
+ NPC_KUR_MURK_RAIDER = 18203,
+ NPC_KUR_MURK_BRUTE = 18211,
+ NPC_KUR_MURK_SCAVENGER = 18207,
+ NPC_KUR_MURK_PUTRIFIER = 18202,
+};
+
+static float kurenaiAmbushA[]= {-1568.805786f, 8533.873047f, 1.958f};
+static float kurenaiAmbushB[]= {-1491.554321f, 8506.483398f, 1.248f};
+
+class npc_kurenai_captive : public CreatureScript
+{
+public:
+ npc_kurenai_captive() : CreatureScript("npc_kurenai_captive") { }
+
+ bool OnQuestAccept(Player* player, Creature* creature, const Quest* quest)
+ {
+ if (quest->GetQuestId() == QUEST_TOTEM_KARDASH_A)
+ {
+ if (npc_kurenai_captiveAI* EscortAI = dynamic_cast<npc_kurenai_captiveAI*>(creature->AI()))
+ {
+ creature->SetStandState(UNIT_STAND_STATE_STAND);
+ EscortAI->Start(true, false, player->GetGUID(), quest);
+ DoScriptText(SAY_KUR_START, creature);
+
+ creature->SummonCreature(NPC_KUR_MURK_RAIDER, kurenaiAmbushA[0]+2.5f, kurenaiAmbushA[1]-2.5f, kurenaiAmbushA[2], 0.0f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 25000);
+ creature->SummonCreature(NPC_KUR_MURK_BRUTE, kurenaiAmbushA[0]-2.5f, kurenaiAmbushA[1]+2.5f, kurenaiAmbushA[2], 0.0f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 25000);
+ creature->SummonCreature(NPC_KUR_MURK_SCAVENGER, kurenaiAmbushA[0], kurenaiAmbushA[1], kurenaiAmbushA[2], 0.0f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 25000);
+ }
+ }
+ return true;
+ }
+
+ CreatureAI* GetAI(Creature* creature) const
+ {
+ return new npc_kurenai_captiveAI(creature);
+ }
+
+ struct npc_kurenai_captiveAI : public npc_escortAI
+ {
+ npc_kurenai_captiveAI(Creature* creature) : npc_escortAI(creature) { }
+
+ uint32 ChainLightningTimer;
+ uint32 HealTimer;
+ uint32 FrostShockTimer;
+
+ void Reset()
+ {
+ ChainLightningTimer = 1000;
+ HealTimer = 0;
+ FrostShockTimer = 6000;
+ }
+
+ void EnterCombat(Unit* /*who*/)
+ {
+ DoCast(me, SPELL_KUR_EARTHBIND_TOTEM, false);
+ }
+
+ void JustDied(Unit* /*killer*/)
+ {
+ if (!HasEscortState(STATE_ESCORT_ESCORTING))
+ return;
+
+ if (Player* player = GetPlayerForEscort())
+ {
+ if (player->GetQuestStatus(QUEST_TOTEM_KARDASH_A) != QUEST_STATUS_COMPLETE)
+ player->FailQuest(QUEST_TOTEM_KARDASH_A);
+ }
+ }
+
+ void WaypointReached(uint32 PointId)
+ {
+ switch(PointId)
+ {
+ case 3:
+ {
+ Talk(SAY_KUR_MORE);
+
+ if (Creature* temp = me->SummonCreature(NPC_KUR_MURK_PUTRIFIER, kurenaiAmbushB[0], kurenaiAmbushB[1], kurenaiAmbushB[2], 0.0f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 25000))
+ Talk(SAY_KUR_MORE_TWO);
+
+ me->SummonCreature(NPC_KUR_MURK_PUTRIFIER, kurenaiAmbushB[0]-2.5f, kurenaiAmbushB[1]-2.5f, kurenaiAmbushB[2], 0.0f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 25000);
+ me->SummonCreature(NPC_KUR_MURK_SCAVENGER, kurenaiAmbushB[0]+2.5f, kurenaiAmbushB[1]+2.5f, kurenaiAmbushB[2], 0.0f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 25000);
+ me->SummonCreature(NPC_KUR_MURK_SCAVENGER, kurenaiAmbushB[0]+2.5f, kurenaiAmbushB[1]-2.5f, kurenaiAmbushB[2], 0.0f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 25000);
+ break;
+ }
+ case 7:
+ {
+ Talk(SAY_KUR_COMPLETE);
+
+ if (Player* player = GetPlayerForEscort())
+ player->GroupEventHappens(QUEST_TOTEM_KARDASH_A, me);
+
+ SetRun();
+ break;
+ }
+ }
+ }
+
+ void JustSummoned(Creature* summoned)
+ {
+ if (summoned->GetEntry() == NPC_KUR_MURK_BRUTE)
+ Talk(SAY_KUR_NO_ESCAPE);
+
+ // This function is for when we summoned enemies to fight - so that does NOT mean we should make our totem count in this!
+ if (summoned->isTotem())
+ return;
+
+ summoned->RemoveUnitMovementFlag(MOVEMENTFLAG_WALKING);
+ summoned->GetMotionMaster()->MovePoint(0, me->GetPositionX(), me->GetPositionY(), me->GetPositionZ());
+ summoned->AI()->AttackStart(me);
+ }
+
+ void SpellHitTarget(Unit* /*target*/, const SpellInfo* spell)
+ {
+ if (spell->Id == SPELL_KUR_CHAIN_LIGHTNING)
+ {
+ if (rand()%30)
+ return;
+
+ Talk(SAY_KUR_LIGHTNING);
+ }
+
+ if (spell->Id == SPELL_KUR_FROST_SHOCK)
+ {
+ if (rand()%30)
+ return;
+
+ Talk(SAY_KUR_SHOCK);
+ }
+ }
+
+ void UpdateAI(const uint32 diff)
+ {
+ if (!UpdateVictim())
+ return;
+
+ if (me->HasUnitState(UNIT_STAT_CASTING))
+ return;
+
+ if (ChainLightningTimer <= diff)
+ {
+ DoCast(me->getVictim(), SPELL_KUR_CHAIN_LIGHTNING);
+ ChainLightningTimer = urand(7000,14000);
+ } else ChainLightningTimer -= diff;
+
+ if (HealthBelowPct(30))
+ {
+ if (HealTimer <= diff)
+ {
+ DoCast(me, SPELL_KUR_HEALING_WAVE);
+ HealTimer = 5000;
+ } else HealTimer -= diff;
+ }
+
+ if (FrostShockTimer <= diff)
+ {
+ DoCast(me->getVictim(), SPELL_KUR_FROST_SHOCK);
+ FrostShockTimer = urand(7500,15000);
+ } else FrostShockTimer -= diff;
+
+ DoMeleeAttackIfReady();
+ }
+ };
+};
+
+/*######
+## go_warmaul_prison
+######*/
+
+enum FindingTheSurvivorsData
+{
+ QUEST_FINDING_THE_SURVIVORS = 9948,
+ NPC_MAGHAR_PRISONER = 18428,
+
+ SAY_FREE = 0,
+};
+
+class go_warmaul_prison : public GameObjectScript
+{
+ public:
+ go_warmaul_prison() : GameObjectScript("go_warmaul_prison") { }
+
+ bool OnGossipHello(Player* player, GameObject* go)
+ {
+ if (player->GetQuestStatus(QUEST_FINDING_THE_SURVIVORS) != QUEST_STATUS_INCOMPLETE)
+ return false;
+
+ if (Creature* prisoner = go->FindNearestCreature(NPC_MAGHAR_PRISONER, 5.0f))
+ {
+ if (prisoner)
+ {
+ go->UseDoorOrButton();
+ if (player)
+ player->KilledMonsterCredit(NPC_MAGHAR_PRISONER, 0);
+
+ prisoner->AI()->Talk(SAY_FREE, player->GetGUID());
+ prisoner->ForcedDespawn(6000);
+ }
+ }
+ return true;
+ }
+};
+
void AddSC_nagrand()
{
- new mob_shattered_rumbler();
- new mob_lump();
- new npc_altruis_the_sufferer();
new npc_greatmother_geyah();
- new npc_lantresor_of_the_blade();
new npc_maghar_captive();
new npc_creditmarker_visit_with_ancestors();
- new mob_sparrowhawk();
new npc_corki();
new go_corkis_prison();
+ new npc_kurenai_captive();
+ new go_warmaul_prison();
}
diff --git a/src/server/scripts/Outland/shadowmoon_valley.cpp b/src/server/scripts/Outland/shadowmoon_valley.cpp
index 31aea5ea576..610cf684a77 100644
--- a/src/server/scripts/Outland/shadowmoon_valley.cpp
+++ b/src/server/scripts/Outland/shadowmoon_valley.cpp
@@ -998,8 +998,7 @@ public:
case 50:
DoScriptText(SAY_WIL_END, me, player);
- if (Player* player = GetPlayerForEscort())
- player->GroupEventHappens(QUEST_ESCAPE_COILSCAR, me);
+ player->GroupEventHappens(QUEST_ESCAPE_COILSCAR, me);
break;
}
}
diff --git a/src/server/scripts/Outland/shattrath_city.cpp b/src/server/scripts/Outland/shattrath_city.cpp
index f2aa9fe5786..6ac60e2086b 100644
--- a/src/server/scripts/Outland/shattrath_city.cpp
+++ b/src/server/scripts/Outland/shattrath_city.cpp
@@ -369,7 +369,7 @@ public:
{
if (CAST_PLR(who)->GetQuestStatus(10211) == QUEST_STATUS_INCOMPLETE)
{
- float Radius = 10.0;
+ float Radius = 10.0f;
if (me->IsWithinDistInMap(who, Radius))
{
Start(false, false, who->GetGUID());
diff --git a/src/server/scripts/Spells/spell_quest.cpp b/src/server/scripts/Spells/spell_quest.cpp
index 6ae9577070e..3b2cc5f5e00 100644
--- a/src/server/scripts/Spells/spell_quest.cpp
+++ b/src/server/scripts/Spells/spell_quest.cpp
@@ -899,7 +899,6 @@ class spell_q9874_liquid_fire : public SpellScriptLoader
};
};
-
enum SalvagingLifesStength
{
NPC_SHARD_KILL_CREDIT = 29303,
@@ -950,6 +949,7 @@ enum eBattleStandard
{
NPC_KING_OF_THE_MOUNTAINT_KC = 31766,
};
+
class spell_q13280_13283_plant_battle_standard: public SpellScriptLoader
{
public:
@@ -978,6 +978,54 @@ public:
}
};
+enum ChumTheWaterSummons
+{
+ SUMMON_ANGRY_KVALDIR = 66737,
+ SUMMON_NORTH_SEA_MAKO = 66738,
+ SUMMON_NORTH_SEA_THRESHER = 66739,
+ SUMMON_NORTH_SEA_BLUE_SHARK = 66740
+};
+
+class spell_q14112_14145_chum_the_water: public SpellScriptLoader
+{
+public:
+ spell_q14112_14145_chum_the_water() : SpellScriptLoader("spell_q14112_14145_chum_the_water") { }
+
+ class spell_q14112_14145_chum_the_water_SpellScript : public SpellScript
+ {
+ PrepareSpellScript(spell_q14112_14145_chum_the_water_SpellScript);
+
+ bool Validate(SpellInfo const* /*spellEntry*/)
+ {
+ if (!sSpellMgr->GetSpellInfo(SUMMON_ANGRY_KVALDIR))
+ return false;
+ if (!sSpellMgr->GetSpellInfo(SUMMON_NORTH_SEA_MAKO))
+ return false;
+ if (!sSpellMgr->GetSpellInfo(SUMMON_NORTH_SEA_THRESHER))
+ return false;
+ if (!sSpellMgr->GetSpellInfo(SUMMON_NORTH_SEA_BLUE_SHARK))
+ return false;
+ return true;
+ }
+
+ void HandleScriptEffect(SpellEffIndex /*effIndex*/)
+ {
+ Unit* caster = GetCaster();
+ caster->CastSpell(caster, RAND(SUMMON_ANGRY_KVALDIR, SUMMON_NORTH_SEA_MAKO, SUMMON_NORTH_SEA_THRESHER, SUMMON_NORTH_SEA_BLUE_SHARK));
+ }
+
+ void Register()
+ {
+ OnEffectHitTarget += SpellEffectFn(spell_q14112_14145_chum_the_water_SpellScript::HandleScriptEffect, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT);
+ }
+ };
+
+ SpellScript* GetSpellScript() const
+ {
+ return new spell_q14112_14145_chum_the_water_SpellScript();
+ }
+};
+
void AddSC_quest_spell_scripts()
{
new spell_q55_sacred_cleansing();
@@ -1001,4 +1049,5 @@ void AddSC_quest_spell_scripts()
new spell_q9874_liquid_fire();
new spell_q12805_lifeblood_dummy();
new spell_q13280_13283_plant_battle_standard();
+ new spell_q14112_14145_chum_the_water();
}
diff --git a/src/server/scripts/World/areatrigger_scripts.cpp b/src/server/scripts/World/areatrigger_scripts.cpp
index a9ed794ab45..517746dac55 100644
--- a/src/server/scripts/World/areatrigger_scripts.cpp
+++ b/src/server/scripts/World/areatrigger_scripts.cpp
@@ -24,14 +24,8 @@ SDCategory: Areatrigger
EndScriptData */
/* ContentData
-at_aldurthar_gate q13315/q13351
at_coilfang_waterfall 4591
at_legion_teleporter 4560 Teleporter TO Invasion Point: Cataclysm
-at_ravenholdt
-at_warsong_slaughterhouse
-at_warsong_grainery
-at_torp_farm
-at_warsong_farms q11686
at_stormwright_shelf q12741
at_last_rites q12019
at_sholazar_waygate q12548
@@ -40,46 +34,6 @@ EndContentData */
#include "ScriptPCH.h"
/*######
-## AreaTrigger_at_aldurthar_gate
-######*/
-
-enum eAldurtharGate
-{
- TRIGGER_SOUTH = 5284,
-
- TRIGGER_CENTRAL = 5285,
- TRIGGER_NORTH = 5286,
- TRIGGER_NORTHWEST = 5287,
-
- NPC_SOUTH_GATE = 32195,
- NPC_CENTRAL_GATE = 32196,
- NPC_NORTH_GATE = 32197,
- NPC_NORTHWEST_GATE = 32199
-};
-
-class AreaTrigger_at_aldurthar_gate : public AreaTriggerScript
-{
- public:
-
- AreaTrigger_at_aldurthar_gate()
- : AreaTriggerScript("at_aldurthar_gate")
- {
- }
-
- bool OnTrigger(Player* player, AreaTriggerEntry const* trigger)
- {
- switch (trigger->id)
- {
- case TRIGGER_SOUTH: player->KilledMonsterCredit(NPC_SOUTH_GATE, 0); break;
- case TRIGGER_CENTRAL: player->KilledMonsterCredit(NPC_CENTRAL_GATE, 0); break;
- case TRIGGER_NORTH: player->KilledMonsterCredit(NPC_NORTH_GATE, 0); break;
- case TRIGGER_NORTHWEST: player->KilledMonsterCredit(NPC_NORTHWEST_GATE, 0); break;
- }
- return true;
- }
-};
-
-/*######
## at_coilfang_waterfall
######*/
@@ -151,71 +105,6 @@ class AreaTrigger_at_legion_teleporter : public AreaTriggerScript
}
};
-enum eRavenholdt
-{
- QUEST_MANOR_RAVENHOLDT = 6681,
- NPC_RAVENHOLDT = 13936
-};
-
-class AreaTrigger_at_ravenholdt : public AreaTriggerScript
-{
- public:
-
- AreaTrigger_at_ravenholdt()
- : AreaTriggerScript("at_ravenholdt")
- {
- }
-
- bool OnTrigger(Player* player, AreaTriggerEntry const* /*trigger*/)
- {
- if (player->GetQuestStatus(QUEST_MANOR_RAVENHOLDT) == QUEST_STATUS_INCOMPLETE)
- player->KilledMonsterCredit(NPC_RAVENHOLDT, 0);
-
- return false;
- }
-};
-
-/*######
-## at_warsong_farms
-######*/
-
-enum eWarsongFarms
-{
- QUEST_THE_WARSONG_FARMS = 11686,
-
- NPC_CREDIT_SLAUGHTERHOUSE = 25672,
- NPC_CREDIT_GRAINERY = 25669,
- NPC_CREDIT_TORP_FARM = 25671,
-
- AT_SLAUGHTERHOUSE = 4873,
- AT_GRAINERY = 4871,
- AT_TORP_FARM = 4872
-};
-
-class AreaTrigger_at_warsong_farms : public AreaTriggerScript
-{
- public:
-
- AreaTrigger_at_warsong_farms()
- : AreaTriggerScript("at_warsong_farms")
- {
- }
-
- bool OnTrigger(Player* player, AreaTriggerEntry const* trigger)
- {
- if (!player->isDead() && player->GetQuestStatus(QUEST_THE_WARSONG_FARMS) == QUEST_STATUS_INCOMPLETE)
- {
- switch (trigger->id)
- {
- case AT_SLAUGHTERHOUSE: player->KilledMonsterCredit(NPC_CREDIT_SLAUGHTERHOUSE, 0); break;
- case AT_GRAINERY: player->KilledMonsterCredit(NPC_CREDIT_GRAINERY, 0); break;
- case AT_TORP_FARM: player->KilledMonsterCredit(NPC_CREDIT_TORP_FARM, 0); break;
- }
- }
- return true;
- }
-};
-
/*######
## at_stormwright_shelf
######*/
@@ -370,11 +259,8 @@ class AreaTrigger_at_sholazar_waygate : public AreaTriggerScript
void AddSC_areatrigger_scripts()
{
- new AreaTrigger_at_aldurthar_gate();
new AreaTrigger_at_coilfang_waterfall();
new AreaTrigger_at_legion_teleporter();
- new AreaTrigger_at_ravenholdt();
- new AreaTrigger_at_warsong_farms();
new AreaTrigger_at_stormwright_shelf();
new AreaTrigger_at_scent_larkorwi();
new AreaTrigger_at_last_rites();
diff --git a/src/server/scripts/World/go_scripts.cpp b/src/server/scripts/World/go_scripts.cpp
index cdeac03d76e..3bb969977b6 100644
--- a/src/server/scripts/World/go_scripts.cpp
+++ b/src/server/scripts/World/go_scripts.cpp
@@ -165,7 +165,7 @@ public:
bool OnGossipHello(Player* player, GameObject* /*pGO*/)
{
- if (player->HasSkill(SKILL_ENGINERING) && player->GetBaseSkillValue(SKILL_ENGINERING) >= 300 && !player->HasSpell(22704))
+ if (player->HasSkill(SKILL_ENGINEERING) && player->GetBaseSkillValue(SKILL_ENGINEERING) >= 300 && !player->HasSpell(22704))
{
player->CastSpell(player, 22864, false);
}
@@ -1009,7 +1009,7 @@ public:
if (qInfo)
{
//TODO: prisoner should help player for a short period of time
- player->KilledMonsterCredit(qInfo->ReqCreatureOrGOId[0], 0);
+ player->KilledMonsterCredit(qInfo->RequiredNpcOrGo[0], 0);
pPrisoner->DisappearAndDie();
}
return true;
@@ -1176,14 +1176,79 @@ public:
class go_massive_seaforium_charge : public GameObjectScript
{
-public:
- go_massive_seaforium_charge() : GameObjectScript("go_massive_seaforium_charge") { }
+ public:
+ go_massive_seaforium_charge() : GameObjectScript("go_massive_seaforium_charge") { }
- bool OnGossipHello(Player* /*player*/, GameObject* go)
- {
- go->SetLootState(GO_JUST_DEACTIVATED);
- return true;
- }
+ bool OnGossipHello(Player* /*player*/, GameObject* go)
+ {
+ go->SetLootState(GO_JUST_DEACTIVATED);
+ return true;
+ }
+};
+
+/*######
+## go_gjalerbron_cage
+######*/
+
+enum OfKeysAndCages
+{
+ QUEST_ALLIANCE_OF_KEYS_AND_CAGES = 11231,
+ QUEST_HORDE_OF_KEYS_AND_CAGES = 11265,
+ NPC_GJALERBRON_PRISONER = 24035,
+ SAY_FREE = 0,
+};
+
+class go_gjalerbron_cage : public GameObjectScript
+{
+ public:
+ go_gjalerbron_cage() : GameObjectScript("go_gjalerbron_cage") { }
+
+ bool OnGossipHello(Player* player, GameObject* go)
+ {
+ if ((player->GetTeamId() == TEAM_ALLIANCE && player->GetQuestStatus(QUEST_ALLIANCE_OF_KEYS_AND_CAGES) == QUEST_STATUS_INCOMPLETE) ||
+ (player->GetTeamId() == TEAM_HORDE && player->GetQuestStatus(QUEST_HORDE_OF_KEYS_AND_CAGES) == QUEST_STATUS_INCOMPLETE))
+ {
+ if (Creature* prisoner = go->FindNearestCreature(NPC_GJALERBRON_PRISONER, 5.0f))
+ {
+ go->UseDoorOrButton();
+
+ if (player)
+ player->KilledMonsterCredit(NPC_GJALERBRON_PRISONER, 0);
+
+ prisoner->AI()->Talk(SAY_FREE);
+ prisoner->ForcedDespawn(6000);
+ }
+ }
+ return true;
+ }
+};
+
+/*########
+## go_large_gjalerbron_cage
+#####*/
+
+class go_large_gjalerbron_cage : public GameObjectScript
+{
+ public:
+ go_large_gjalerbron_cage() : GameObjectScript("go_large_gjalerbron_cage") { }
+
+ bool OnGossipHello(Player* player, GameObject* go)
+ {
+ if ((player->GetTeamId() == TEAM_ALLIANCE && player->GetQuestStatus(QUEST_ALLIANCE_OF_KEYS_AND_CAGES) == QUEST_STATUS_INCOMPLETE) ||
+ (player->GetTeamId() == TEAM_HORDE && player->GetQuestStatus(QUEST_HORDE_OF_KEYS_AND_CAGES) == QUEST_STATUS_INCOMPLETE))
+ {
+ std::list<Creature*> prisonerList;
+ GetCreatureListWithEntryInGrid(prisonerList, go, NPC_GJALERBRON_PRISONER, INTERACTION_DISTANCE);
+ for (std::list<Creature*>::const_iterator itr = prisonerList.begin(); itr != prisonerList.end(); ++itr)
+ {
+ go->UseDoorOrButton();
+ player->KilledMonsterCredit(NPC_GJALERBRON_PRISONER, (*itr)->GetGUID());
+ (*itr)->ForcedDespawn(6000);
+ (*itr)->AI()->Talk(SAY_FREE);
+ }
+ }
+ return false;
+ }
};
void AddSC_go_scripts()
@@ -1224,4 +1289,6 @@ void AddSC_go_scripts()
new go_amberpine_outhouse;
new go_hive_pod;
new go_massive_seaforium_charge;
+ new go_gjalerbron_cage;
+ new go_large_gjalerbron_cage;
}
diff --git a/src/server/scripts/World/npc_professions.cpp b/src/server/scripts/World/npc_professions.cpp
index 149e1e455aa..01f12086477 100644
--- a/src/server/scripts/World/npc_professions.cpp
+++ b/src/server/scripts/World/npc_professions.cpp
@@ -774,7 +774,7 @@ public:
{
bool res = false;
npcTextId = textId;
- if (player->GetBaseSkillValue(SKILL_ENGINERING) >= skillValue && player->HasSpell(reqSpellId))
+ if (player->GetBaseSkillValue(SKILL_ENGINEERING) >= skillValue && player->HasSpell(reqSpellId))
{
if (!player->HasSpell(spellId))
res = true;
@@ -790,7 +790,7 @@ public:
std::string gossipItem;
bool canLearn = false;
- if (player->HasSkill(SKILL_ENGINERING))
+ if (player->HasSkill(SKILL_ENGINEERING))
{
switch (creature->GetEntry())
{
diff --git a/src/server/shared/Common.h b/src/server/shared/Common.h
index ffecf020d24..bc9c0c62ccc 100755
--- a/src/server/shared/Common.h
+++ b/src/server/shared/Common.h
@@ -146,12 +146,12 @@ inline float finiteAlways(float f) { return finite(f) ? f : 0.0f; }
enum TimeConstants
{
- MINUTE = 60,
- HOUR = MINUTE*60,
- DAY = HOUR*24,
- WEEK = DAY*7,
- MONTH = DAY*30,
- YEAR = MONTH*12,
+ MINUTE = 60,
+ HOUR = MINUTE*60,
+ DAY = HOUR*24,
+ WEEK = DAY*7,
+ MONTH = DAY*30,
+ YEAR = MONTH*12,
IN_MILLISECONDS = 1000
};
@@ -203,4 +203,17 @@ typedef std::vector<std::string> StringVector;
#endif
#define MAX_QUERY_LEN 32*1024
+
+#define TRINITY_GUARD(MUTEX, LOCK) \
+ ACE_Guard< MUTEX > TRINITY_GUARD_OBJECT (LOCK); \
+ if (TRINITY_GUARD_OBJECT.locked() == 0) ASSERT(false);
+
+# define TRINITY_WRITE_GUARD(MUTEX, LOCK) \
+ ACE_Write_Guard< MUTEX > TRINITY_GUARD_OBJECT (LOCK); \
+ if (TRINITY_GUARD_OBJECT.locked() == 0) ASSERT(false);
+
+# define TRINITY_READ_GUARD(MUTEX, LOCK) \
+ ACE_Read_Guard< MUTEX > TRINITY_GUARD_OBJECT (LOCK); \
+ if (TRINITY_GUARD_OBJECT.locked() == 0) ASSERT(false);
+
#endif
diff --git a/src/server/shared/Cryptography/ARC4.h b/src/server/shared/Cryptography/ARC4.h
index 777dbb8cb99..abf753be02f 100755
--- a/src/server/shared/Cryptography/ARC4.h
+++ b/src/server/shared/Cryptography/ARC4.h
@@ -19,7 +19,7 @@
#ifndef _AUTH_SARC4_H
#define _AUTH_SARC4_H
-#include "Common.h"
+#include "Define.h"
#include <openssl/evp.h>
class ARC4
diff --git a/src/server/shared/Cryptography/Authentication/AuthCrypt.cpp b/src/server/shared/Cryptography/Authentication/AuthCrypt.cpp
index 146f4e992b7..a2db02dfbe3 100755
--- a/src/server/shared/Cryptography/Authentication/AuthCrypt.cpp
+++ b/src/server/shared/Cryptography/Authentication/AuthCrypt.cpp
@@ -18,12 +18,11 @@
#include "AuthCrypt.h"
#include "Cryptography/HMACSHA1.h"
-#include "Logging/Log.h"
#include "Cryptography/BigNumber.h"
AuthCrypt::AuthCrypt() : _clientDecrypt(SHA_DIGEST_LENGTH), _serverEncrypt(SHA_DIGEST_LENGTH)
+ , _initialized(false)
{
- _initialized = false;
}
AuthCrypt::~AuthCrypt()
diff --git a/src/server/shared/Cryptography/Authentication/AuthCrypt.h b/src/server/shared/Cryptography/Authentication/AuthCrypt.h
index 0304ef6b69e..e7463b0d962 100755
--- a/src/server/shared/Cryptography/Authentication/AuthCrypt.h
+++ b/src/server/shared/Cryptography/Authentication/AuthCrypt.h
@@ -19,7 +19,6 @@
#ifndef _AUTHCRYPT_H
#define _AUTHCRYPT_H
-#include <Common.h>
#include "Cryptography/ARC4.h"
class BigNumber;
diff --git a/src/server/shared/Cryptography/BigNumber.cpp b/src/server/shared/Cryptography/BigNumber.cpp
index 6149a680594..76cb74d5e13 100755
--- a/src/server/shared/Cryptography/BigNumber.cpp
+++ b/src/server/shared/Cryptography/BigNumber.cpp
@@ -18,31 +18,30 @@
#include "Cryptography/BigNumber.h"
#include <openssl/bn.h>
+#include <openssl/crypto.h>
#include <algorithm>
BigNumber::BigNumber()
-{
- _bn = BN_new();
- _array = NULL;
-}
+ : _bn(BN_new())
+ , _array(NULL)
+{ }
BigNumber::BigNumber(const BigNumber &bn)
-{
- _bn = BN_dup(bn._bn);
- _array = NULL;
-}
+ : _bn(BN_dup(bn._bn))
+ , _array(NULL)
+{ }
BigNumber::BigNumber(uint32 val)
+ : _bn(BN_new())
+ , _array(NULL)
{
- _bn = BN_new();
BN_set_word(_bn, val);
- _array = NULL;
}
BigNumber::~BigNumber()
{
BN_free(_bn);
- if (_array) delete[] _array;
+ delete[] _array;
}
void BigNumber::SetDword(uint32 val)
@@ -76,6 +75,8 @@ void BigNumber::SetRand(int numbits)
BigNumber BigNumber::operator=(const BigNumber &bn)
{
+ if (this == &bn)
+ return *this;
BN_copy(_bn, bn._bn);
return *this;
}
diff --git a/src/server/shared/Cryptography/BigNumber.h b/src/server/shared/Cryptography/BigNumber.h
index 485d4ced470..eb450c27777 100755
--- a/src/server/shared/Cryptography/BigNumber.h
+++ b/src/server/shared/Cryptography/BigNumber.h
@@ -19,7 +19,7 @@
#ifndef _AUTH_BIGNUMBER_H
#define _AUTH_BIGNUMBER_H
-#include "Common.h"
+#include "Define.h"
struct bignum_st;
diff --git a/src/server/shared/Cryptography/HMACSHA1.h b/src/server/shared/Cryptography/HMACSHA1.h
index 180ac6f4262..2d6e0c276a8 100755
--- a/src/server/shared/Cryptography/HMACSHA1.h
+++ b/src/server/shared/Cryptography/HMACSHA1.h
@@ -19,7 +19,8 @@
#ifndef _AUTH_HMAC_H
#define _AUTH_HMAC_H
-#include "Common.h"
+#include "Define.h"
+#include <string>
#include <openssl/hmac.h>
#include <openssl/sha.h>
diff --git a/src/server/shared/Cryptography/SHA1.h b/src/server/shared/Cryptography/SHA1.h
index 27e2d3290d0..9cb9b7b90f9 100755
--- a/src/server/shared/Cryptography/SHA1.h
+++ b/src/server/shared/Cryptography/SHA1.h
@@ -19,9 +19,9 @@
#ifndef _AUTH_SHA1_H
#define _AUTH_SHA1_H
-#include "Common.h"
+#include "Define.h"
+#include <string>
#include <openssl/sha.h>
-#include <openssl/crypto.h>
class BigNumber;
diff --git a/src/server/shared/Database/Implementation/CharacterDatabase.cpp b/src/server/shared/Database/Implementation/CharacterDatabase.cpp
index 816dc25f1b3..f93c4a70d7c 100755
--- a/src/server/shared/Database/Implementation/CharacterDatabase.cpp
+++ b/src/server/shared/Database/Implementation/CharacterDatabase.cpp
@@ -300,4 +300,20 @@ void CharacterDatabaseConnection::DoPrepareStatements()
// For loading and deleting expired auctions at startup
PREPARE_STATEMENT(CHAR_LOAD_EXPIRED_AUCTIONS, "SELECT id, auctioneerguid, itemguid, itemEntry, itemowner, buyoutprice, time, buyguid, lastbid, startbid, deposit FROM auctionhouse ah INNER JOIN item_instance ii ON ii.guid = ah.itemguid WHERE ah.time <= ?", CONNECTION_SYNCH)
+ // Player saving
+ PREPARE_STATEMENT(CHAR_ADD_CHARACTER, "INSERT INTO characters (guid, account, name, race, class, gender, level, xp, money, playerBytes, playerBytes2, playerFlags, "
+ "map, instance_id, instance_mode_mask, position_x, position_y, position_z, orientation, "
+ "taximask, cinematic, "
+ "totaltime, leveltime, rest_bonus, logout_time, is_logout_resting, resettalents_cost, resettalents_time, "
+ "extra_flags, stable_slots, at_login, zone, "
+ "death_expire_time, taxi_path, arenaPoints, totalHonorPoints, todayHonorPoints, yesterdayHonorPoints, totalKills, "
+ "todayKills, yesterdayKills, chosenTitle, knownCurrencies, watchedFaction, drunk, health, power1, power2, power3, "
+ "power4, power5, power6, power7, latency, speccount, activespec, exploredZones, equipmentCache, ammoId, knownTitles, actionBars, grantableLevels) VALUES "
+ "(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)", CONNECTION_ASYNC);
+ PREPARE_STATEMENT(CHAR_UPD_CHARACTER, "UPDATE characters SET name=?,race=?,class=?,gender=?,level=?,xp=?,money=?,playerBytes=?,playerBytes2=?,playerFlags=?,"
+ "map=?,instance_id=?,instance_mode_mask=?,position_x=?,position_y=?,position_z=?,orientation=?,taximask=?,cinematic=?,totaltime=?,leveltime=?,rest_bonus=?,"
+ "logout_time=?,is_logout_resting=?,resettalents_cost=?,resettalents_time=?,extra_flags=?,stable_slots=?,at_login=?,zone=?,death_expire_time=?,taxi_path=?,"
+ "arenaPoints=?,totalHonorPoints=?,todayHonorPoints=?,yesterdayHonorPoints=?,totalKills=?,todayKills=?,yesterdayKills=?,chosenTitle=?,knownCurrencies=?,"
+ "watchedFaction=?,drunk=?,health=?,power1=?,power2=?,power3=?,power4=?,power5=?,power6=?,power7=?,latency=?,speccount=?,activespec=?,exploredZones=?,"
+ "equipmentCache=?,ammoId=?,knownTitles=?,actionBars=?,grantableLevels=?,online=? WHERE guid=?", CONNECTION_ASYNC);
}
diff --git a/src/server/shared/Database/Implementation/CharacterDatabase.h b/src/server/shared/Database/Implementation/CharacterDatabase.h
index dd752914138..f06a17aa924 100755
--- a/src/server/shared/Database/Implementation/CharacterDatabase.h
+++ b/src/server/shared/Database/Implementation/CharacterDatabase.h
@@ -275,6 +275,9 @@ enum CharacterDatabaseStatements
CHAR_LOAD_EXPIRED_AUCTIONS,
+ CHAR_ADD_CHARACTER,
+ CHAR_UPD_CHARACTER,
+
MAX_CHARACTERDATABASE_STATEMENTS,
};
diff --git a/src/server/shared/Dynamic/TypeContainer.h b/src/server/shared/Dynamic/TypeContainer.h
index 0fb3eb25347..7f6f5fa661c 100755
--- a/src/server/shared/Dynamic/TypeContainer.h
+++ b/src/server/shared/Dynamic/TypeContainer.h
@@ -108,11 +108,11 @@ class TypeMapContainer
}
/// Removes the object from the container, and returns the removed object
- template<class SPECIFIC_TYPE> bool remove(SPECIFIC_TYPE* obj)
- {
- SPECIFIC_TYPE* t = Trinity::Remove(i_elements, obj);
- return (t != NULL);
- }
+ //template<class SPECIFIC_TYPE> bool remove(SPECIFIC_TYPE* obj)
+ //{
+ // SPECIFIC_TYPE* t = Trinity::Remove(i_elements, obj);
+ // return (t != NULL);
+ //}
ContainerMapList<OBJECT_TYPES> & GetElements(void) { return i_elements; }
const ContainerMapList<OBJECT_TYPES> & GetElements(void) const { return i_elements;}
diff --git a/src/server/shared/Dynamic/TypeContainerFunctions.h b/src/server/shared/Dynamic/TypeContainerFunctions.h
index 981cd82197f..9bfbf47da93 100755
--- a/src/server/shared/Dynamic/TypeContainerFunctions.h
+++ b/src/server/shared/Dynamic/TypeContainerFunctions.h
@@ -62,7 +62,7 @@ namespace Trinity
template<class SPECIFIC_TYPE> SPECIFIC_TYPE* Insert(ContainerMapList<SPECIFIC_TYPE> &elements, SPECIFIC_TYPE *obj)
{
//elements._element[hdl] = obj;
- obj->GetGridRef().link(&elements._element, obj);
+ obj->AddToGrid(elements._element);
return obj;
};
@@ -84,31 +84,30 @@ namespace Trinity
return (t != NULL ? t : Insert(elements._TailElements, obj));
}
- // non-const remove method
- template<class SPECIFIC_TYPE> SPECIFIC_TYPE* Remove(ContainerMapList<SPECIFIC_TYPE> & /*elements*/, SPECIFIC_TYPE *obj)
- {
- obj->GetGridRef().unlink();
- return obj;
- }
-
- template<class SPECIFIC_TYPE> SPECIFIC_TYPE* Remove(ContainerMapList<TypeNull> &/*elements*/, SPECIFIC_TYPE * /*obj*/)
- {
- return NULL;
- }
-
- // this is a missed
- template<class SPECIFIC_TYPE, class T> SPECIFIC_TYPE* Remove(ContainerMapList<T> &/*elements*/, SPECIFIC_TYPE * /*obj*/)
- {
- return NULL; // a missed
- }
-
- template<class SPECIFIC_TYPE, class T, class H> SPECIFIC_TYPE* Remove(ContainerMapList<TypeList<H, T> > &elements, SPECIFIC_TYPE *obj)
- {
- // The head element is bad
- SPECIFIC_TYPE* t = Remove(elements._elements, obj);
- return ( t != NULL ? t : Remove(elements._TailElements, obj) );
- }
-
+ //// non-const remove method
+ //template<class SPECIFIC_TYPE> SPECIFIC_TYPE* Remove(ContainerMapList<SPECIFIC_TYPE> & /*elements*/, SPECIFIC_TYPE *obj)
+ //{
+ // obj->GetGridRef().unlink();
+ // return obj;
+ //}
+
+ //template<class SPECIFIC_TYPE> SPECIFIC_TYPE* Remove(ContainerMapList<TypeNull> &/*elements*/, SPECIFIC_TYPE * /*obj*/)
+ //{
+ // return NULL;
+ //}
+
+ //// this is a missed
+ //template<class SPECIFIC_TYPE, class T> SPECIFIC_TYPE* Remove(ContainerMapList<T> &/*elements*/, SPECIFIC_TYPE * /*obj*/)
+ //{
+ // return NULL; // a missed
+ //}
+
+ //template<class SPECIFIC_TYPE, class T, class H> SPECIFIC_TYPE* Remove(ContainerMapList<TypeList<H, T> > &elements, SPECIFIC_TYPE *obj)
+ //{
+ // // The head element is bad
+ // SPECIFIC_TYPE* t = Remove(elements._elements, obj);
+ // return ( t != NULL ? t : Remove(elements._TailElements, obj) );
+ //}
}
#endif
diff --git a/src/server/shared/Dynamic/UnorderedMap.h b/src/server/shared/Dynamic/UnorderedMap.h
index c698cc0a823..92a7dddf8a8 100755
--- a/src/server/shared/Dynamic/UnorderedMap.h
+++ b/src/server/shared/Dynamic/UnorderedMap.h
@@ -71,4 +71,3 @@ namespace __gnu_cxx
using std::hash_map;
#endif
#endif
-
diff --git a/src/server/shared/Logging/Log.cpp b/src/server/shared/Logging/Log.cpp
index 56c02a8e77b..697e7616c40 100755
--- a/src/server/shared/Logging/Log.cpp
+++ b/src/server/shared/Logging/Log.cpp
@@ -139,7 +139,7 @@ void Log::Initialize()
{
bool m_gmlog_timestamp = ConfigMgr::GetBoolDefault("GmLogTimestamp", false);
- size_t dot_pos = m_gmlog_filename_format.find_last_of(".");
+ size_t dot_pos = m_gmlog_filename_format.find_last_of('.');
if (dot_pos!=m_gmlog_filename_format.npos)
{
if (m_gmlog_timestamp)
@@ -556,10 +556,10 @@ void Log::outSQLDriver(const char* str, ...)
{
outTimestamp(sqlLogFile);
- va_list ap;
- va_start(ap, str);
- vfprintf(sqlLogFile, str, ap);
- va_end(ap);
+ va_list apSQL;
+ va_start(apSQL, str);
+ vfprintf(sqlLogFile, str, apSQL);
+ va_end(apSQL);
fprintf(sqlLogFile, "\n");
fflush(sqlLogFile);
@@ -646,11 +646,11 @@ void Log::outBasic(const char * str, ...)
if (logfile)
{
outTimestamp(logfile);
- va_list ap;
- va_start(ap, str);
- vfprintf(logfile, str, ap);
+ va_list ap2;
+ va_start(ap2, str);
+ vfprintf(logfile, str, ap2);
fprintf(logfile, "\n" );
- va_end(ap);
+ va_end(ap2);
fflush(logfile);
}
}
@@ -690,10 +690,10 @@ void Log::outDetail(const char * str, ...)
if (logfile)
{
outTimestamp(logfile);
- va_list ap;
- va_start(ap, str);
- vfprintf(logfile, str, ap);
- va_end(ap);
+ va_list ap2;
+ va_start(ap2, str);
+ vfprintf(logfile, str, ap2);
+ va_end(ap2);
fprintf(logfile, "\n");
fflush(logfile);
@@ -720,10 +720,10 @@ void Log::outDebugInLine(const char * str, ...)
if (logfile)
{
- va_list ap;
- va_start(ap, str);
- vfprintf(logfile, str, ap);
- va_end(ap);
+ va_list ap2;
+ va_start(ap2, str);
+ vfprintf(logfile, str, ap2);
+ va_end(ap2);
}
}
}
@@ -742,10 +742,10 @@ void Log::outSQLDev(const char* str, ...)
if (sqlDevLogFile)
{
- va_list ap;
- va_start(ap, str);
- vfprintf(sqlDevLogFile, str, ap);
- va_end(ap);
+ va_list ap2;
+ va_start(ap2, str);
+ vfprintf(sqlDevLogFile, str, ap2);
+ va_end(ap2);
fprintf(sqlDevLogFile, "\n");
fflush(sqlDevLogFile);
@@ -790,10 +790,10 @@ void Log::outDebug(DebugLogFilters f, const char * str, ...)
if (logfile)
{
outTimestamp(logfile);
- va_list ap;
- va_start(ap, str);
- vfprintf(logfile, str, ap);
- va_end(ap);
+ va_list ap2;
+ va_start(ap2, str);
+ vfprintf(logfile, str, ap2);
+ va_end(ap2);
fprintf(logfile, "\n" );
fflush(logfile);
@@ -835,10 +835,10 @@ void Log::outStaticDebug(const char * str, ...)
if (logfile)
{
outTimestamp(logfile);
- va_list ap;
- va_start(ap, str);
- vfprintf(logfile, str, ap);
- va_end(ap);
+ va_list ap2;
+ va_start(ap2, str);
+ vfprintf(logfile, str, ap2);
+ va_end(ap2);
fprintf(logfile, "\n" );
fflush(logfile);
@@ -900,11 +900,11 @@ void Log::outCommand(uint32 account, const char * str, ...)
if (logfile)
{
outTimestamp(logfile);
- va_list ap;
- va_start(ap, str);
- vfprintf(logfile, str, ap);
+ va_list ap2;
+ va_start(ap2, str);
+ vfprintf(logfile, str, ap2);
fprintf(logfile, "\n" );
- va_end(ap);
+ va_end(ap2);
fflush(logfile);
}
}
diff --git a/src/server/shared/Logging/Log.h b/src/server/shared/Logging/Log.h
index 5c23616ac5c..5b2eb6aafb6 100755
--- a/src/server/shared/Logging/Log.h
+++ b/src/server/shared/Logging/Log.h
@@ -102,8 +102,10 @@ const int Colors = int(WHITE)+1;
class Log
{
friend class ACE_Singleton<Log, ACE_Thread_Mutex>;
- Log();
- ~Log();
+
+ private:
+ Log();
+ ~Log();
public:
void Initialize();
diff --git a/src/server/shared/Utilities/Util.cpp b/src/server/shared/Utilities/Util.cpp
index 187258e41b3..5919529c6bf 100755
--- a/src/server/shared/Utilities/Util.cpp
+++ b/src/server/shared/Utilities/Util.cpp
@@ -17,7 +17,6 @@
*/
#include "Util.h"
-
#include "utf8.h"
#ifdef USE_SFMT_FOR_RNG
#include "SFMT.h"
@@ -162,13 +161,13 @@ std::string secsToTimeString(uint64 timeInSecs, bool shortText, bool hoursOnly)
std::ostringstream ss;
if (days)
- ss << days << (shortText ? "d " : " Day(s) ");
+ ss << days << (shortText ? "d" : " Day(s) ");
if (hours || hoursOnly)
- ss << hours << (shortText ? "h " : " Hour(s) ");
+ ss << hours << (shortText ? "h" : " Hour(s) ");
if (!hoursOnly)
{
if (minutes)
- ss << minutes << (shortText ? "m " : " Minute(s) ");
+ ss << minutes << (shortText ? "m" : " Minute(s) ");
if (secs || (!days && !hours && !minutes) )
ss << secs << (shortText ? "s" : " Second(s).");
}
diff --git a/src/server/worldserver/CommandLine/CliRunnable.cpp b/src/server/worldserver/CommandLine/CliRunnable.cpp
index cf5ad79f878..564f6028eca 100755
--- a/src/server/worldserver/CommandLine/CliRunnable.cpp
+++ b/src/server/worldserver/CommandLine/CliRunnable.cpp
@@ -115,6 +115,7 @@ void commandFinished(void*, bool /*success*/)
printf("TC> ");
fflush(stdout);
}
+
/**
* Collects all GUIDs (and related info) from deleted characters which are still in the database.
*
@@ -562,10 +563,11 @@ void CliRunnable::run()
{
///- Display the list of available CLI functions then beep
//sLog->outString("");
- #if PLATFORM != PLATFORM_WINDOWS
+#if PLATFORM != PLATFORM_WINDOWS
rl_attempted_completion_function = cli_completion;
rl_event_hook = cli_hook_func;
- #endif
+#endif
+
if (ConfigMgr::GetBoolDefault("BeepAtStart", true))
printf("\a"); // \a = Alert
@@ -580,49 +582,49 @@ void CliRunnable::run()
char *command_str ; // = fgets(commandbuf, sizeof(commandbuf), stdin);
- #if PLATFORM == PLATFORM_WINDOWS
+#if PLATFORM == PLATFORM_WINDOWS
char commandbuf[256];
command_str = fgets(commandbuf, sizeof(commandbuf), stdin);
- #else
+#else
command_str = readline("TC>");
rl_bind_key('\t', rl_complete);
- #endif
+#endif
+
if (command_str != NULL)
{
- for (int x=0; command_str[x]; x++)
- if (command_str[x]=='\r'||command_str[x]=='\n')
+ for (int x=0; command_str[x]; ++x)
+ if (command_str[x] == '\r' || command_str[x] == '\n')
{
- command_str[x]=0;
+ command_str[x] = 0;
break;
}
if (!*command_str)
{
- #if PLATFORM == PLATFORM_WINDOWS
+#if PLATFORM == PLATFORM_WINDOWS
printf("TC>");
- #endif
+#endif
continue;
}
std::string command;
if (!consoleToUtf8(command_str, command)) // convert from console encoding to utf8
{
- #if PLATFORM == PLATFORM_WINDOWS
+#if PLATFORM == PLATFORM_WINDOWS
printf("TC>");
- #endif
+#endif
continue;
}
+
fflush(stdout);
sWorld->QueueCliCommand(new CliCommandHolder(NULL, command.c_str(), &utf8print, &commandFinished));
- #if PLATFORM != PLATFORM_WINDOWS
+#if PLATFORM != PLATFORM_WINDOWS
add_history(command.c_str());
- #endif
-
+#endif
}
else if (feof(stdin))
{
World::StopNow(SHUTDOWN_EXIT_CODE);
}
-
}
}
diff --git a/src/server/worldserver/Master.cpp b/src/server/worldserver/Master.cpp
index 5260140fef0..42d72aa2c6f 100755
--- a/src/server/worldserver/Master.cpp
+++ b/src/server/worldserver/Master.cpp
@@ -462,7 +462,6 @@ bool Master::_StartDB()
sWorld->LoadDBVersion();
sLog->outString("Using World DB: %s", sWorld->GetDBVersion());
- sLog->outString("Using creature EventAI: %s", sWorld->GetCreatureEventAIVersion());
return true;
}
diff --git a/src/server/worldserver/RemoteAccess/RARunnable.cpp b/src/server/worldserver/RemoteAccess/RARunnable.cpp
index d7cee88b994..60145cf99aa 100644
--- a/src/server/worldserver/RemoteAccess/RARunnable.cpp
+++ b/src/server/worldserver/RemoteAccess/RARunnable.cpp
@@ -33,22 +33,17 @@
#include "RASocket.h"
-RARunnable::RARunnable() : m_Reactor(NULL)
+RARunnable::RARunnable()
{
- ACE_Reactor_Impl* imp = 0;
+ ACE_Reactor_Impl* imp = NULL;
#if defined (ACE_HAS_EVENT_POLL) || defined (ACE_HAS_DEV_POLL)
-
imp = new ACE_Dev_Poll_Reactor();
-
imp->max_notify_iterations (128);
imp->restart (1);
-
#else
-
imp = new ACE_TP_Reactor();
imp->max_notify_iterations (128);
-
#endif
m_Reactor = new ACE_Reactor (imp, 1);
@@ -68,7 +63,6 @@ void RARunnable::run()
uint16 raport = ConfigMgr::GetIntDefault("Ra.Port", 3443);
std::string stringip = ConfigMgr::GetStringDefault("Ra.IP", "0.0.0.0");
-
ACE_INET_Addr listen_addr(raport, stringip.c_str());
if (acceptor.open(listen_addr, m_Reactor) == -1)
@@ -84,7 +78,6 @@ void RARunnable::run()
// don't be too smart to move this outside the loop
// the run_reactor_event_loop will modify interval
ACE_Time_Value interval(0, 100000);
-
if (m_Reactor->run_reactor_event_loop(interval) == -1)
break;
}