aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/common/CMakeLists.txt2
-rw-r--r--src/common/Collision/Management/VMapManager2.cpp5
-rw-r--r--src/common/Collision/Management/VMapManager2.h2
-rw-r--r--src/common/Collision/Maps/MapTree.cpp6
-rw-r--r--src/common/Collision/Models/ModelInstance.h3
-rw-r--r--src/common/Collision/Models/WorldModel.cpp19
-rw-r--r--src/common/Collision/Models/WorldModel.h10
-rw-r--r--src/common/Common.h26
-rw-r--r--src/common/Debugging/Errors.cpp11
-rw-r--r--src/common/Debugging/Errors.h6
-rw-r--r--src/common/Debugging/WheatyExceptionReport.cpp72
-rw-r--r--src/common/Debugging/WheatyExceptionReport.h4
-rw-r--r--src/server/database/Database/DatabaseLoader.cpp2
-rw-r--r--src/server/database/Database/DatabaseWorkerPool.h2
-rw-r--r--src/server/database/Database/Field.h36
-rw-r--r--src/server/database/Database/Implementation/CharacterDatabase.cpp21
-rw-r--r--src/server/database/Database/Implementation/CharacterDatabase.h4
-rw-r--r--src/server/database/Database/Implementation/LoginDatabase.cpp11
-rw-r--r--src/server/database/Database/Implementation/LoginDatabase.h3
-rw-r--r--src/server/game/AI/CoreAI/CombatAI.cpp12
-rw-r--r--src/server/game/AI/CoreAI/CombatAI.h2
-rw-r--r--src/server/game/AI/CreatureAIFactory.h5
-rw-r--r--src/server/game/AI/CreatureAIImpl.h290
-rw-r--r--src/server/game/AI/CreatureAISelector.cpp30
-rw-r--r--src/server/game/AI/SmartScripts/SmartScript.cpp33
-rw-r--r--src/server/game/AI/SmartScripts/SmartScript.h6
-rw-r--r--src/server/game/Accounts/RBAC.cpp23
-rw-r--r--src/server/game/Accounts/RBAC.h4
-rw-r--r--src/server/game/Achievements/AchievementMgr.cpp2
-rw-r--r--src/server/game/Battlegrounds/Battleground.cpp9
-rw-r--r--src/server/game/Battlegrounds/Battleground.h9
-rw-r--r--src/server/game/Battlegrounds/BattlegroundMgr.cpp2
-rw-r--r--src/server/game/Battlegrounds/BattlegroundQueue.cpp10
-rw-r--r--src/server/game/Chat/Chat.cpp86
-rw-r--r--src/server/game/Chat/Chat.h27
-rw-r--r--src/server/game/Conditions/ConditionMgr.cpp298
-rw-r--r--src/server/game/Conditions/ConditionMgr.h87
-rw-r--r--src/server/game/DataStores/DBCStores.cpp62
-rw-r--r--src/server/game/DataStores/DBCStores.h4
-rw-r--r--src/server/game/DataStores/DBCStructure.h23
-rw-r--r--src/server/game/DataStores/DBCfmt.h4
-rw-r--r--src/server/game/Entities/Corpse/Corpse.cpp27
-rw-r--r--src/server/game/Entities/Corpse/Corpse.h9
-rw-r--r--src/server/game/Entities/Creature/Creature.cpp16
-rw-r--r--src/server/game/Entities/Creature/Creature.h6
-rw-r--r--src/server/game/Entities/Creature/CreatureGroups.cpp3
-rw-r--r--src/server/game/Entities/Creature/CreatureGroups.h4
-rw-r--r--src/server/game/Entities/Item/Item.cpp17
-rw-r--r--src/server/game/Entities/Item/Item.h2
-rw-r--r--src/server/game/Entities/Object/Object.cpp2
-rw-r--r--src/server/game/Entities/Object/ObjectGuid.h7
-rw-r--r--src/server/game/Entities/Player/KillRewarder.cpp274
-rw-r--r--src/server/game/Entities/Player/KillRewarder.h59
-rw-r--r--src/server/game/Entities/Player/Player.cpp577
-rw-r--r--src/server/game/Entities/Player/Player.h110
-rw-r--r--src/server/game/Entities/Player/TradeData.cpp139
-rw-r--r--src/server/game/Entities/Player/TradeData.h81
-rw-r--r--src/server/game/Entities/Unit/Unit.cpp17
-rw-r--r--src/server/game/Globals/ObjectMgr.cpp137
-rw-r--r--src/server/game/Globals/ObjectMgr.h14
-rw-r--r--src/server/game/Grids/ObjectGridLoader.cpp9
-rw-r--r--src/server/game/Grids/ObjectGridLoader.h1
-rw-r--r--src/server/game/Handlers/BattleGroundHandler.cpp10
-rw-r--r--src/server/game/Handlers/CharacterHandler.cpp37
-rw-r--r--src/server/game/Handlers/ItemHandler.cpp3
-rw-r--r--src/server/game/Handlers/PetHandler.cpp2
-rw-r--r--src/server/game/Handlers/QueryHandler.cpp18
-rw-r--r--src/server/game/Handlers/QuestHandler.cpp3
-rw-r--r--src/server/game/Handlers/TradeHandler.cpp5
-rw-r--r--src/server/game/Loot/LootMgr.cpp8
-rw-r--r--src/server/game/Loot/LootMgr.h6
-rw-r--r--src/server/game/Maps/Map.cpp74
-rw-r--r--src/server/game/Maps/Map.h3
-rw-r--r--src/server/game/Miscellaneous/Formulas.h2
-rw-r--r--src/server/game/Movement/MovementGenerators/HomeMovementGenerator.cpp2
-rw-r--r--src/server/game/OutdoorPvP/OutdoorPvP.h4
-rw-r--r--src/server/game/OutdoorPvP/OutdoorPvPMgr.cpp2
-rw-r--r--src/server/game/Scripting/ScriptLoader.cpp6
-rw-r--r--src/server/game/Scripting/ScriptMgr.cpp177
-rw-r--r--src/server/game/Scripting/ScriptMgr.h40
-rw-r--r--src/server/game/Server/WorldSession.cpp115
-rw-r--r--src/server/game/Server/WorldSession.h13
-rw-r--r--src/server/game/Server/WorldSocket.cpp343
-rw-r--r--src/server/game/Server/WorldSocket.h24
-rw-r--r--src/server/game/Skills/SkillExtraItems.cpp4
-rw-r--r--src/server/game/Spells/Auras/SpellAuraEffects.cpp17
-rw-r--r--src/server/game/Spells/Auras/SpellAuras.cpp6
-rw-r--r--src/server/game/Spells/Spell.cpp42
-rw-r--r--src/server/game/Spells/Spell.h20
-rw-r--r--src/server/game/Spells/SpellEffects.cpp11
-rw-r--r--src/server/game/Spells/SpellHistory.cpp326
-rw-r--r--src/server/game/Spells/SpellHistory.h34
-rw-r--r--src/server/game/Spells/SpellInfo.cpp8
-rw-r--r--src/server/game/Spells/SpellInfo.h8
-rw-r--r--src/server/game/Spells/SpellMgr.cpp30
-rw-r--r--src/server/game/Tickets/TicketMgr.cpp14
-rw-r--r--src/server/game/Tickets/TicketMgr.h16
-rw-r--r--src/server/game/Tools/PlayerDump.cpp263
-rw-r--r--src/server/game/Tools/PlayerDump.h17
-rw-r--r--src/server/game/Weather/WeatherMgr.cpp2
-rw-r--r--src/server/game/World/World.cpp104
-rw-r--r--src/server/game/World/World.h33
-rw-r--r--src/server/scripts/Commands/cs_account.cpp45
-rw-r--r--src/server/scripts/Commands/cs_achievement.cpp10
-rw-r--r--src/server/scripts/Commands/cs_ahbot.cpp44
-rw-r--r--src/server/scripts/Commands/cs_arena.cpp24
-rw-r--r--src/server/scripts/Commands/cs_ban.cpp45
-rw-r--r--src/server/scripts/Commands/cs_bf.cpp18
-rw-r--r--src/server/scripts/Commands/cs_cast.cpp111
-rw-r--r--src/server/scripts/Commands/cs_character.cpp52
-rw-r--r--src/server/scripts/Commands/cs_cheat.cpp25
-rw-r--r--src/server/scripts/Commands/cs_debug.cpp94
-rw-r--r--src/server/scripts/Commands/cs_deserter.cpp22
-rw-r--r--src/server/scripts/Commands/cs_disable.cpp46
-rw-r--r--src/server/scripts/Commands/cs_event.cpp16
-rw-r--r--src/server/scripts/Commands/cs_gm.cpp20
-rw-r--r--src/server/scripts/Commands/cs_go.cpp30
-rw-r--r--src/server/scripts/Commands/cs_gobject.cpp38
-rw-r--r--src/server/scripts/Commands/cs_group.cpp20
-rw-r--r--src/server/scripts/Commands/cs_guild.cpp22
-rw-r--r--src/server/scripts/Commands/cs_honor.cpp17
-rw-r--r--src/server/scripts/Commands/cs_instance.cpp48
-rw-r--r--src/server/scripts/Commands/cs_learn.cpp36
-rw-r--r--src/server/scripts/Commands/cs_lfg.cpp18
-rw-r--r--src/server/scripts/Commands/cs_list.cpp18
-rw-r--r--src/server/scripts/Commands/cs_lookup.cpp50
-rw-r--r--src/server/scripts/Commands/cs_message.cpp27
-rw-r--r--src/server/scripts/Commands/cs_misc.cpp121
-rw-r--r--src/server/scripts/Commands/cs_mmaps.cpp20
-rw-r--r--src/server/scripts/Commands/cs_modify.cpp67
-rw-r--r--src/server/scripts/Commands/cs_npc.cpp182
-rw-r--r--src/server/scripts/Commands/cs_pet.cpp14
-rw-r--r--src/server/scripts/Commands/cs_quest.cpp16
-rw-r--r--src/server/scripts/Commands/cs_rbac.cpp21
-rw-r--r--src/server/scripts/Commands/cs_reload.cpp213
-rw-r--r--src/server/scripts/Commands/cs_reset.cpp22
-rw-r--r--src/server/scripts/Commands/cs_send.cpp16
-rw-r--r--src/server/scripts/Commands/cs_server.cpp57
-rw-r--r--src/server/scripts/Commands/cs_tele.cpp18
-rw-r--r--src/server/scripts/Commands/cs_ticket.cpp49
-rw-r--r--src/server/scripts/Commands/cs_titles.cpp19
-rw-r--r--src/server/scripts/Commands/cs_wp.cpp22
-rw-r--r--src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockDepths/boss_anubshiah.cpp116
-rw-r--r--src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockDepths/boss_gorosh_the_dervish.cpp93
-rw-r--r--src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockDepths/boss_grizzle.cpp110
-rw-r--r--src/server/scripts/EasternKingdoms/CMakeLists.txt3
-rw-r--r--src/server/scripts/EasternKingdoms/Gnomeregan/gnomeregan.cpp4
-rw-r--r--src/server/scripts/EasternKingdoms/Karazhan/boss_netherspite.cpp28
-rw-r--r--src/server/scripts/EasternKingdoms/Karazhan/karazhan.cpp40
-rw-r--r--src/server/scripts/EasternKingdoms/MagistersTerrace/magisters_terrace.cpp28
-rw-r--r--src/server/scripts/EasternKingdoms/ScarletEnclave/chapter5.cpp4
-rw-r--r--src/server/scripts/EasternKingdoms/ScarletMonastery/boss_headless_horseman.cpp6
-rw-r--r--src/server/scripts/EasternKingdoms/Stratholme/boss_baron_rivendare.cpp3
-rw-r--r--src/server/scripts/EasternKingdoms/SunwellPlateau/boss_kalecgos.cpp16
-rw-r--r--src/server/scripts/Kalimdor/CavernsOfTime/EscapeFromDurnholdeKeep/old_hillsbrad.cpp12
-rw-r--r--src/server/scripts/Kalimdor/RazorfenKraul/instance_razorfen_kraul.cpp10
-rw-r--r--src/server/scripts/Kalimdor/RuinsOfAhnQiraj/boss_ossirian.cpp4
-rw-r--r--src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_cthun.cpp17
-rw-r--r--src/server/scripts/Northrend/AzjolNerub/Ahnkahet/boss_herald_volazj.cpp6
-rw-r--r--src/server/scripts/Northrend/AzjolNerub/Ahnkahet/boss_jedoga_shadowseeker.cpp2
-rw-r--r--src/server/scripts/Northrend/ChamberOfAspects/ObsidianSanctum/obsidian_sanctum.cpp52
-rw-r--r--src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheChampion/boss_grand_champions.cpp8
-rw-r--r--src/server/scripts/Northrend/IcecrownCitadel/boss_blood_queen_lana_thel.cpp2
-rw-r--r--src/server/scripts/Northrend/IcecrownCitadel/boss_festergut.cpp18
-rw-r--r--src/server/scripts/Northrend/IcecrownCitadel/boss_rotface.cpp18
-rw-r--r--src/server/scripts/Northrend/IcecrownCitadel/boss_valithria_dreamwalker.cpp8
-rw-r--r--src/server/scripts/Northrend/IcecrownCitadel/icecrown_citadel.h1
-rw-r--r--src/server/scripts/Northrend/Naxxramas/boss_anubrekhan.cpp207
-rw-r--r--src/server/scripts/Northrend/Naxxramas/boss_faerlina.cpp130
-rw-r--r--src/server/scripts/Northrend/Naxxramas/boss_gothik.cpp66
-rw-r--r--src/server/scripts/Northrend/Naxxramas/boss_heigan.cpp4
-rw-r--r--src/server/scripts/Northrend/Naxxramas/boss_noth.cpp12
-rw-r--r--src/server/scripts/Northrend/Naxxramas/boss_thaddius.cpp1368
-rw-r--r--src/server/scripts/Northrend/Naxxramas/instance_naxxramas.cpp58
-rw-r--r--src/server/scripts/Northrend/Naxxramas/naxxramas.h12
-rw-r--r--src/server/scripts/Northrend/Ulduar/Ulduar/boss_algalon_the_observer.cpp8
-rw-r--r--src/server/scripts/Northrend/Ulduar/Ulduar/boss_general_vezax.cpp52
-rw-r--r--src/server/scripts/Northrend/zone_sholazar_basin.cpp68
-rw-r--r--src/server/scripts/OutdoorPvP/OutdoorPvPEP.cpp2
-rw-r--r--src/server/scripts/OutdoorPvP/OutdoorPvPSI.cpp10
-rw-r--r--src/server/scripts/Outland/Auchindoun/AuchenaiCrypts/boss_shirrak_the_dead_watcher.cpp3
-rw-r--r--src/server/scripts/Outland/Auchindoun/ShadowLabyrinth/boss_grandmaster_vorpil.cpp3
-rw-r--r--src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_lady_vashj.cpp3
-rw-r--r--src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_leotheras_the_blind.cpp3
-rw-r--r--src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_lurker_below.cpp15
-rw-r--r--src/server/scripts/Outland/HellfireCitadel/ShatteredHalls/shattered_halls.cpp2
-rw-r--r--src/server/scripts/Outland/TempestKeep/Eye/boss_kaelthas.cpp14
-rw-r--r--src/server/scripts/Outland/zone_hellfire_peninsula.cpp10
-rw-r--r--src/server/scripts/Spells/spell_dk.cpp10
-rw-r--r--src/server/scripts/World/duel_reset.cpp79
-rw-r--r--src/server/shared/Dynamic/TypeContainer.h6
-rw-r--r--src/server/shared/Networking/MessageBuffer.h4
-rw-r--r--src/server/shared/Networking/Socket.h2
-rw-r--r--src/server/worldserver/CommandLine/CliRunnable.cpp13
-rw-r--r--src/server/worldserver/worldserver.conf.dist31
-rw-r--r--src/tools/map_extractor/CMakeLists.txt18
-rw-r--r--src/tools/map_extractor/System.cpp201
-rw-r--r--src/tools/map_extractor/loadlib.cpp8
-rw-r--r--src/tools/map_extractor/loadlib/loadlib.h30
-rw-r--r--src/tools/map_extractor/mpq_libmpq04.h6
-rw-r--r--src/tools/mmaps_generator/IntermediateValues.h1
-rw-r--r--src/tools/mmaps_generator/MapBuilder.cpp20
-rw-r--r--src/tools/mmaps_generator/MapBuilder.h16
-rw-r--r--src/tools/mmaps_generator/PathCommon.h5
-rw-r--r--src/tools/mmaps_generator/TerrainBuilder.cpp8
-rw-r--r--src/tools/mmaps_generator/TerrainBuilder.h11
-rw-r--r--src/tools/mmaps_generator/VMapExtensions.cpp70
-rw-r--r--src/tools/vmap4_extractor/adtfile.cpp10
-rw-r--r--src/tools/vmap4_extractor/mpq_libmpq04.h15
-rw-r--r--src/tools/vmap4_extractor/vmapexport.cpp50
-rw-r--r--src/tools/vmap4_extractor/wdtfile.cpp5
-rw-r--r--src/tools/vmap4_extractor/wdtfile.h13
-rw-r--r--src/tools/vmap4_extractor/wmo.cpp6
213 files changed, 5063 insertions, 4623 deletions
diff --git a/src/common/CMakeLists.txt b/src/common/CMakeLists.txt
index 2339399e022..7f20fe36ab6 100644
--- a/src/common/CMakeLists.txt
+++ b/src/common/CMakeLists.txt
@@ -83,6 +83,8 @@ add_library(common STATIC
${common_STAT_PCH_SRC}
)
+add_dependencies(common revision_data.h)
+
# Generate precompiled header
if (USE_COREPCH)
add_cxx_pch(common ${common_STAT_PCH_HDR} ${common_STAT_PCH_SRC})
diff --git a/src/common/Collision/Management/VMapManager2.cpp b/src/common/Collision/Management/VMapManager2.cpp
index 9594951196f..a63eac1b935 100644
--- a/src/common/Collision/Management/VMapManager2.cpp
+++ b/src/common/Collision/Management/VMapManager2.cpp
@@ -326,4 +326,9 @@ namespace VMAP
return StaticMapTree::CanLoadMap(std::string(basePath), mapId, x, y);
}
+ void VMapManager2::getInstanceMapTree(InstanceTreeMap &instanceMapTree)
+ {
+ instanceMapTree = iInstanceMapTrees;
+ }
+
} // namespace VMAP
diff --git a/src/common/Collision/Management/VMapManager2.h b/src/common/Collision/Management/VMapManager2.h
index a5891e9642b..c2e1aee1ff7 100644
--- a/src/common/Collision/Management/VMapManager2.h
+++ b/src/common/Collision/Management/VMapManager2.h
@@ -128,7 +128,7 @@ namespace VMAP
return getMapFileName(mapId);
}
virtual bool existsMap(const char* basePath, unsigned int mapId, int x, int y) override;
- public:
+
void getInstanceMapTree(InstanceTreeMap &instanceMapTree);
typedef uint32(*GetLiquidFlagsFn)(uint32 liquidType);
diff --git a/src/common/Collision/Maps/MapTree.cpp b/src/common/Collision/Maps/MapTree.cpp
index b493ec18f5f..e374da4f1b9 100644
--- a/src/common/Collision/Maps/MapTree.cpp
+++ b/src/common/Collision/Maps/MapTree.cpp
@@ -474,4 +474,10 @@ namespace VMAP
}
iLoadedTiles.erase(tile);
}
+
+ void StaticMapTree::getModelInstances(ModelInstance* &models, uint32 &count)
+ {
+ models = iTreeValues;
+ count = iNTreeValues;
+ }
}
diff --git a/src/common/Collision/Models/ModelInstance.h b/src/common/Collision/Models/ModelInstance.h
index dfdb001db0a..f8bbfa4fa73 100644
--- a/src/common/Collision/Models/ModelInstance.h
+++ b/src/common/Collision/Models/ModelInstance.h
@@ -70,12 +70,11 @@ namespace VMAP
void intersectPoint(const G3D::Vector3& p, AreaInfo &info) const;
bool GetLocationInfo(const G3D::Vector3& p, LocationInfo &info) const;
bool GetLiquidLevel(const G3D::Vector3& p, LocationInfo &info, float &liqHeight) const;
+ WorldModel* getWorldModel() { return iModel; }
protected:
G3D::Matrix3 iInvRot;
float iInvScale;
WorldModel* iModel;
- public:
- WorldModel* getWorldModel();
};
} // namespace VMAP
diff --git a/src/common/Collision/Models/WorldModel.cpp b/src/common/Collision/Models/WorldModel.cpp
index 86ab9366c71..7f4d76b244a 100644
--- a/src/common/Collision/Models/WorldModel.cpp
+++ b/src/common/Collision/Models/WorldModel.cpp
@@ -249,6 +249,13 @@ namespace VMAP
return result;
}
+ void WmoLiquid::getPosInfo(uint32 &tilesX, uint32 &tilesY, G3D::Vector3 &corner) const
+ {
+ tilesX = iTilesX;
+ tilesY = iTilesY;
+ corner = iCorner;
+ }
+
// ===================== GroupModel ==================================
GroupModel::GroupModel(const GroupModel &other):
@@ -409,6 +416,13 @@ namespace VMAP
return 0;
}
+ void GroupModel::getMeshData(std::vector<G3D::Vector3>& outVertices, std::vector<MeshTriangle>& outTriangles, WmoLiquid*& liquid)
+ {
+ outVertices = vertices;
+ outTriangles = triangles;
+ liquid = iLiquid;
+ }
+
// ===================== WorldModel ==================================
void WorldModel::setGroupModels(std::vector<GroupModel> &models)
@@ -582,4 +596,9 @@ namespace VMAP
fclose(rf);
return result;
}
+
+ void WorldModel::getGroupModels(std::vector<GroupModel>& outGroupModels)
+ {
+ outGroupModels = groupModels;
+ }
}
diff --git a/src/common/Collision/Models/WorldModel.h b/src/common/Collision/Models/WorldModel.h
index 6a901a59fdf..afa9d15b264 100644
--- a/src/common/Collision/Models/WorldModel.h
+++ b/src/common/Collision/Models/WorldModel.h
@@ -58,6 +58,7 @@ namespace VMAP
uint32 GetFileSize();
bool writeToFile(FILE* wf);
static bool readFromFile(FILE* rf, WmoLiquid* &liquid);
+ void getPosInfo(uint32 &tilesX, uint32 &tilesY, G3D::Vector3 &corner) const;
private:
WmoLiquid() : iTilesX(0), iTilesY(0), iCorner(), iType(0), iHeight(NULL), iFlags(NULL) { }
uint32 iTilesX; //!< number of tiles in x direction, each
@@ -66,8 +67,6 @@ namespace VMAP
uint32 iType; //!< liquid type
float *iHeight; //!< (tilesX + 1)*(tilesY + 1) height values
uint8 *iFlags; //!< info if liquid tile is used
- public:
- void getPosInfo(uint32 &tilesX, uint32 &tilesY, G3D::Vector3 &corner) const;
};
/*! holding additional info for WMO group files */
@@ -92,6 +91,7 @@ namespace VMAP
const G3D::AABox& GetBound() const { return iBound; }
uint32 GetMogpFlags() const { return iMogpFlags; }
uint32 GetWmoID() const { return iGroupWMOID; }
+ void getMeshData(std::vector<G3D::Vector3>& outVertices, std::vector<MeshTriangle>& outTriangles, WmoLiquid*& liquid);
protected:
G3D::AABox iBound;
uint32 iMogpFlags;// 0x8 outdor; 0x2000 indoor
@@ -100,9 +100,8 @@ namespace VMAP
std::vector<MeshTriangle> triangles;
BIH meshTree;
WmoLiquid* iLiquid;
- public:
- void getMeshData(std::vector<G3D::Vector3> &vertices, std::vector<MeshTriangle> &triangles, WmoLiquid* &liquid);
};
+
/*! Holds a model (converted M2 or WMO) in its original coordinate space */
class WorldModel
{
@@ -117,12 +116,11 @@ namespace VMAP
bool GetLocationInfo(const G3D::Vector3 &p, const G3D::Vector3 &down, float &dist, LocationInfo &info) const;
bool writeFile(const std::string &filename);
bool readFile(const std::string &filename);
+ void getGroupModels(std::vector<GroupModel>& outGroupModels);
protected:
uint32 RootWMOID;
std::vector<GroupModel> groupModels;
BIH groupTree;
- public:
- void getGroupModels(std::vector<GroupModel> &groupModels);
};
} // namespace VMAP
diff --git a/src/common/Common.h b/src/common/Common.h
index 4c209f89ec8..7a1ea247a94 100644
--- a/src/common/Common.h
+++ b/src/common/Common.h
@@ -21,7 +21,6 @@
#include "Define.h"
-#include <unordered_map>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -32,14 +31,19 @@
#include <assert.h>
#include <set>
+#include <unordered_set>
#include <list>
#include <string>
#include <map>
+#include <unordered_map>
#include <queue>
#include <sstream>
#include <algorithm>
#include <memory>
#include <vector>
+#include <array>
+
+#include <boost/functional/hash.hpp>
#include "Debugging/Errors.h"
@@ -116,10 +120,11 @@ enum LocaleConstant
LOCALE_zhTW = 5,
LOCALE_esES = 6,
LOCALE_esMX = 7,
- LOCALE_ruRU = 8
+ LOCALE_ruRU = 8,
+
+ TOTAL_LOCALES
};
-const uint8 TOTAL_LOCALES = 9;
#define DEFAULT_LOCALE LOCALE_enUS
#define MAX_LOCALES 8
@@ -156,4 +161,19 @@ namespace Trinity
}
}
+//! Hash implementation for std::pair to allow using pairs in unordered_set or as key for unordered_map
+//! Individual types used in pair must be hashable by boost::hash
+namespace std
+{
+ template<class K, class V>
+ struct hash<std::pair<K, V>>
+ {
+ public:
+ size_t operator()(std::pair<K, V> const& key) const
+ {
+ return boost::hash_value(key);
+ }
+ };
+}
+
#endif
diff --git a/src/common/Debugging/Errors.cpp b/src/common/Debugging/Errors.cpp
index 45f130ceb3b..4c7e91a8219 100644
--- a/src/common/Debugging/Errors.cpp
+++ b/src/common/Debugging/Errors.cpp
@@ -59,10 +59,15 @@ void Assert(char const* file, int line, char const* function, char const* messag
exit(1);
}
-void Fatal(char const* file, int line, char const* function, char const* message)
+void Fatal(char const* file, int line, char const* function, char const* message, ...)
{
- fprintf(stderr, "\n%s:%i in %s FATAL ERROR:\n %s\n",
- file, line, function, message);
+ va_list args;
+ va_start(args, message);
+
+ fprintf(stderr, "\n%s:%i in %s FATAL ERROR:\n ", file, line, function);
+ vfprintf(stderr, message, args);
+ fprintf(stderr, "\n");
+ fflush(stderr);
std::this_thread::sleep_for(std::chrono::seconds(10));
*((volatile int*)NULL) = 0;
diff --git a/src/common/Debugging/Errors.h b/src/common/Debugging/Errors.h
index edf56b29136..9e526933acc 100644
--- a/src/common/Debugging/Errors.h
+++ b/src/common/Debugging/Errors.h
@@ -26,10 +26,10 @@ namespace Trinity
DECLSPEC_NORETURN void Assert(char const* file, int line, char const* function, char const* message) ATTR_NORETURN;
DECLSPEC_NORETURN void Assert(char const* file, int line, char const* function, char const* message, char const* format, ...) ATTR_NORETURN ATTR_PRINTF(5, 6);
- DECLSPEC_NORETURN void Fatal(char const* file, int line, char const* function, char const* message) ATTR_NORETURN;
+ DECLSPEC_NORETURN void Fatal(char const* file, int line, char const* function, char const* message, ...) ATTR_NORETURN ATTR_PRINTF(4, 5);
DECLSPEC_NORETURN void Error(char const* file, int line, char const* function, char const* message) ATTR_NORETURN;
-
+
DECLSPEC_NORETURN void Abort(char const* file, int line, char const* function) ATTR_NORETURN;
void Warning(char const* file, int line, char const* function, char const* message);
@@ -45,7 +45,7 @@ namespace Trinity
#endif
#define WPAssert(cond, ...) ASSERT_BEGIN do { if (!(cond)) Trinity::Assert(__FILE__, __LINE__, __FUNCTION__, #cond, ##__VA_ARGS__); } while(0) ASSERT_END
-#define WPFatal(cond, msg) ASSERT_BEGIN do { if (!(cond)) Trinity::Fatal(__FILE__, __LINE__, __FUNCTION__, (msg)); } while(0) ASSERT_END
+#define WPFatal(cond, ...) ASSERT_BEGIN do { if (!(cond)) Trinity::Fatal(__FILE__, __LINE__, __FUNCTION__, ##__VA_ARGS__); } while(0) ASSERT_END
#define WPError(cond, msg) ASSERT_BEGIN do { if (!(cond)) Trinity::Error(__FILE__, __LINE__, __FUNCTION__, (msg)); } while(0) ASSERT_END
#define WPWarning(cond, msg) ASSERT_BEGIN do { if (!(cond)) Trinity::Warning(__FILE__, __LINE__, __FUNCTION__, (msg)); } while(0) ASSERT_END
#define WPAbort() ASSERT_BEGIN do { Trinity::Abort(__FILE__, __LINE__, __FUNCTION__); } while(0) ASSERT_END
diff --git a/src/common/Debugging/WheatyExceptionReport.cpp b/src/common/Debugging/WheatyExceptionReport.cpp
index 7cf109b4070..5b9a1b1bd6c 100644
--- a/src/common/Debugging/WheatyExceptionReport.cpp
+++ b/src/common/Debugging/WheatyExceptionReport.cpp
@@ -63,6 +63,8 @@ std::stack<SymbolDetail> WheatyExceptionReport::symbolDetails;
bool WheatyExceptionReport::stackOverflowException;
bool WheatyExceptionReport::alreadyCrashed;
std::mutex WheatyExceptionReport::alreadyCrashedLock;
+WheatyExceptionReport::pRtlGetVersion WheatyExceptionReport::RtlGetVersion;
+
// Declare global instance of class
WheatyExceptionReport g_WheatyExceptionReport;
@@ -76,6 +78,7 @@ WheatyExceptionReport::WheatyExceptionReport() // Constructor
m_hProcess = GetCurrentProcess();
stackOverflowException = false;
alreadyCrashed = false;
+ RtlGetVersion = (pRtlGetVersion)GetProcAddress(GetModuleHandle(_T("ntdll.dll")), "RtlGetVersion");
if (!IsDebuggerPresent())
{
_CrtSetReportMode(_CRT_ERROR, _CRTDBG_MODE_FILE);
@@ -207,21 +210,36 @@ BOOL WheatyExceptionReport::_GetProcessorName(TCHAR* sProcessorName, DWORD maxco
return TRUE;
}
+template<size_t size>
+void ToTchar(wchar_t const* src, TCHAR (&dst)[size], std::true_type)
+{
+ wcstombs_s(nullptr, dst, src, size);
+}
+
+template<size_t size>
+void ToTchar(wchar_t const* src, TCHAR (&dst)[size], std::false_type)
+{
+ wcscpy_s(dst, src);
+}
+
BOOL WheatyExceptionReport::_GetWindowsVersion(TCHAR* szVersion, DWORD cntMax)
{
// Try calling GetVersionEx using the OSVERSIONINFOEX structure.
// If that fails, try using the OSVERSIONINFO structure.
- OSVERSIONINFOEX osvi = { 0 };
- osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);
- BOOL bOsVersionInfoEx;
- bOsVersionInfoEx = ::GetVersionEx((LPOSVERSIONINFO)(&osvi));
- if (!bOsVersionInfoEx)
+ RTL_OSVERSIONINFOEXW osvi = { 0 };
+ osvi.dwOSVersionInfoSize = sizeof(RTL_OSVERSIONINFOEXW);
+ NTSTATUS bVersionEx = RtlGetVersion((PRTL_OSVERSIONINFOW)&osvi);
+ if (bVersionEx < 0)
{
- osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
- if (!::GetVersionEx((OSVERSIONINFO*)&osvi))
+ osvi.dwOSVersionInfoSize = sizeof(RTL_OSVERSIONINFOW);
+ if (!RtlGetVersion((PRTL_OSVERSIONINFOW)&osvi))
return FALSE;
}
*szVersion = _T('\0');
+
+ TCHAR szCSDVersion[256];
+ ToTchar(osvi.szCSDVersion, szCSDVersion, std::is_same<TCHAR, char>::type());
+
TCHAR wszTmp[128];
switch (osvi.dwPlatformId)
{
@@ -237,17 +255,28 @@ BOOL WheatyExceptionReport::_GetWindowsVersion(TCHAR* szVersion, DWORD cntMax)
#endif // WINVER < 0x0500
// Test for the specific product family.
- if (osvi.dwMajorVersion == 6)
+ if (osvi.dwMajorVersion == 10)
+ {
+ if (productType == VER_NT_WORKSTATION)
+ _tcsncat(szVersion, _T("Windows 10 "), cntMax);
+ else
+ _tcsncat(szVersion, _T("Windows Server 2016 "), cntMax);
+ }
+ else if (osvi.dwMajorVersion == 6)
{
if (productType == VER_NT_WORKSTATION)
{
- if (osvi.dwMinorVersion == 2)
+ if (osvi.dwMinorVersion == 3)
+ _tcsncat(szVersion, _T("Windows 8.1 "), cntMax);
+ else if (osvi.dwMinorVersion == 2)
_tcsncat(szVersion, _T("Windows 8 "), cntMax);
else if (osvi.dwMinorVersion == 1)
_tcsncat(szVersion, _T("Windows 7 "), cntMax);
else
_tcsncat(szVersion, _T("Windows Vista "), cntMax);
}
+ else if (osvi.dwMinorVersion == 3)
+ _tcsncat(szVersion, _T("Windows Server 2012 R2 "), cntMax);
else if (osvi.dwMinorVersion == 2)
_tcsncat(szVersion, _T("Windows Server 2012 "), cntMax);
else if (osvi.dwMinorVersion == 1)
@@ -265,7 +294,7 @@ BOOL WheatyExceptionReport::_GetWindowsVersion(TCHAR* szVersion, DWORD cntMax)
_tcsncat(szVersion, _T("Microsoft Windows NT "), cntMax);
// Test for specific product on Windows NT 4.0 SP6 and later.
- if (bOsVersionInfoEx)
+ if (bVersionEx >= 0)
{
// Test for the workstation type.
if (productType == VER_NT_WORKSTATION)
@@ -282,7 +311,18 @@ BOOL WheatyExceptionReport::_GetWindowsVersion(TCHAR* szVersion, DWORD cntMax)
// Test for the server type.
else if (productType == VER_NT_SERVER)
{
- if (osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 2)
+ if (osvi.dwMajorVersion == 6 || osvi.dwMajorVersion == 10)
+ {
+ if (suiteMask & VER_SUITE_SMALLBUSINESS_RESTRICTED)
+ _tcsncat(szVersion, _T("Essentials "), cntMax);
+ else if (suiteMask & VER_SUITE_DATACENTER)
+ _tcsncat(szVersion, _T("Datacenter "), cntMax);
+ else if (suiteMask & VER_SUITE_ENTERPRISE)
+ _tcsncat(szVersion, _T("Enterprise "), cntMax);
+ else
+ _tcsncat(szVersion, _T("Standard "), cntMax);
+ }
+ else if (osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 2)
{
if (suiteMask & VER_SUITE_DATACENTER)
_tcsncat(szVersion, _T("Datacenter Edition "), cntMax);
@@ -313,7 +353,7 @@ BOOL WheatyExceptionReport::_GetWindowsVersion(TCHAR* szVersion, DWORD cntMax)
}
// Display service pack (if any) and build number.
- if (osvi.dwMajorVersion == 4 && _tcsicmp(osvi.szCSDVersion, _T("Service Pack 6")) == 0)
+ if (osvi.dwMajorVersion == 4 && _tcsicmp(szCSDVersion, _T("Service Pack 6")) == 0)
{
HKEY hKey;
LONG lRet;
@@ -329,26 +369,26 @@ BOOL WheatyExceptionReport::_GetWindowsVersion(TCHAR* szVersion, DWORD cntMax)
else // Windows NT 4.0 prior to SP6a
{
_stprintf(wszTmp, _T("%s (Version %d.%d, Build %d)"),
- osvi.szCSDVersion, osvi.dwMajorVersion, osvi.dwMinorVersion, osvi.dwBuildNumber & 0xFFFF);
+ szCSDVersion, osvi.dwMajorVersion, osvi.dwMinorVersion, osvi.dwBuildNumber & 0xFFFF);
_tcsncat(szVersion, wszTmp, cntMax);
}
::RegCloseKey(hKey);
}
else // Windows NT 3.51 and earlier or Windows 2000 and later
{
- if (!_tcslen(osvi.szCSDVersion))
+ if (!_tcslen(szCSDVersion))
_stprintf(wszTmp, _T("(Version %d.%d, Build %d)"),
osvi.dwMajorVersion, osvi.dwMinorVersion, osvi.dwBuildNumber & 0xFFFF);
else
_stprintf(wszTmp, _T("%s (Version %d.%d, Build %d)"),
- osvi.szCSDVersion, osvi.dwMajorVersion, osvi.dwMinorVersion, osvi.dwBuildNumber & 0xFFFF);
+ szCSDVersion, osvi.dwMajorVersion, osvi.dwMinorVersion, osvi.dwBuildNumber & 0xFFFF);
_tcsncat(szVersion, wszTmp, cntMax);
}
break;
}
default:
_stprintf(wszTmp, _T("%s (Version %d.%d, Build %d)"),
- osvi.szCSDVersion, osvi.dwMajorVersion, osvi.dwMinorVersion, osvi.dwBuildNumber & 0xFFFF);
+ szCSDVersion, osvi.dwMajorVersion, osvi.dwMinorVersion, osvi.dwBuildNumber & 0xFFFF);
_tcsncat(szVersion, wszTmp, cntMax);
break;
}
diff --git a/src/common/Debugging/WheatyExceptionReport.h b/src/common/Debugging/WheatyExceptionReport.h
index 8c2479d5232..eb62d8bceef 100644
--- a/src/common/Debugging/WheatyExceptionReport.h
+++ b/src/common/Debugging/WheatyExceptionReport.h
@@ -3,6 +3,8 @@
#if PLATFORM == PLATFORM_WINDOWS && !defined(__MINGW32__)
+#include <winnt.h>
+#include <winternl.h>
#include <dbghelp.h>
#include <set>
#include <stdlib.h>
@@ -197,6 +199,8 @@ class WheatyExceptionReport
static bool stackOverflowException;
static bool alreadyCrashed;
static std::mutex alreadyCrashedLock;
+ typedef NTSTATUS(NTAPI* pRtlGetVersion)(PRTL_OSVERSIONINFOW lpVersionInformation);
+ static pRtlGetVersion RtlGetVersion;
static char* PushSymbolDetail(char* pszCurrBuffer);
static char* PopSymbolDetail(char* pszCurrBuffer);
diff --git a/src/server/database/Database/DatabaseLoader.cpp b/src/server/database/Database/DatabaseLoader.cpp
index a3e2083fff4..69e212cf7e1 100644
--- a/src/server/database/Database/DatabaseLoader.cpp
+++ b/src/server/database/Database/DatabaseLoader.cpp
@@ -66,7 +66,7 @@ DatabaseLoader& DatabaseLoader::AddDatabase(DatabaseWorkerPool<T>& pool, std::st
if (error)
{
TC_LOG_ERROR("sql.driver", "\nDatabasePool %s NOT opened. There were errors opening the MySQL connections. Check your SQLDriverLogFile "
- "for specific errors. Read wiki at http://collab.kpsn.org/display/tc/TrinityCore+Home", name.c_str());
+ "for specific errors. Read wiki at http://www.trinitycore.info/display/tc/TrinityCore+Home", name.c_str());
return false;
}
diff --git a/src/server/database/Database/DatabaseWorkerPool.h b/src/server/database/Database/DatabaseWorkerPool.h
index 32837daf5da..c7b5d8c8fea 100644
--- a/src/server/database/Database/DatabaseWorkerPool.h
+++ b/src/server/database/Database/DatabaseWorkerPool.h
@@ -67,6 +67,8 @@ class DatabaseWorkerPool
WPFatal(mysql_thread_safe(), "Used MySQL library isn't thread-safe.");
WPFatal(mysql_get_client_version() >= MIN_MYSQL_CLIENT_VERSION, "TrinityCore does not support MySQL versions below 5.1");
+ WPFatal(mysql_get_client_version() == MYSQL_VERSION_ID, "Used MySQL library version (%s) does not match the version used to compile TrinityCore (%s).",
+ mysql_get_client_info(), MYSQL_SERVER_VERSION);
}
~DatabaseWorkerPool()
diff --git a/src/server/database/Database/Field.h b/src/server/database/Database/Field.h
index 42a842e6283..72364f2c034 100644
--- a/src/server/database/Database/Field.h
+++ b/src/server/database/Database/Field.h
@@ -23,6 +23,36 @@
#include <mysql.h>
+/**
+ @class Field
+
+ @brief Class used to access individual fields of database query result
+
+ Guideline on field type matching:
+
+ | MySQL type | method to use |
+ |------------------------|----------------------------------------|
+ | TINYINT | GetBool, GetInt8, GetUInt8 |
+ | SMALLINT | GetInt16, GetUInt16 |
+ | MEDIUMINT, INT | GetInt32, GetUInt32 |
+ | BIGINT | GetInt64, GetUInt64 |
+ | FLOAT | GetFloat |
+ | DOUBLE, DECIMAL | GetDouble |
+ | CHAR, VARCHAR, | GetCString, GetString |
+ | TINYTEXT, MEDIUMTEXT, | GetCString, GetString |
+ | TEXT, LONGTEXT | GetCString, GetString |
+ | TINYBLOB, MEDIUMBLOB, | GetBinary, GetString |
+ | BLOB, LONGBLOB | GetBinary, GetString |
+ | BINARY, VARBINARY | GetBinary |
+
+ Return types of aggregate functions:
+
+ | Function | Type |
+ |----------|-------------------|
+ | MIN, MAX | Same as the field |
+ | SUM, AVG | DECIMAL |
+ | COUNT | BIGINT |
+*/
class Field
{
friend class ResultSet;
@@ -214,15 +244,15 @@ class Field
return 0.0f;
#ifdef TRINITY_DEBUG
- if (!IsType(MYSQL_TYPE_DOUBLE))
+ if (!IsType(MYSQL_TYPE_DOUBLE) && !IsType(MYSQL_TYPE_NEWDECIMAL))
{
- TC_LOG_WARN("sql.sql", "Warning: GetDouble() on non-double field %s.%s (%s.%s) at index %u. Using type: %s.",
+ TC_LOG_WARN("sql.sql", "Warning: GetDouble() on non-double/non-decimal field %s.%s (%s.%s) at index %u. Using type: %s.",
meta.TableAlias, meta.Alias, meta.TableName, meta.Name, meta.Index, meta.Type);
return 0.0f;
}
#endif
- if (data.raw)
+ if (data.raw && !IsType(MYSQL_TYPE_NEWDECIMAL))
return *reinterpret_cast<double*>(data.value);
return static_cast<double>(atof((char*)data.value));
}
diff --git a/src/server/database/Database/Implementation/CharacterDatabase.cpp b/src/server/database/Database/Implementation/CharacterDatabase.cpp
index b41ba41bcff..45bfee5d596 100644
--- a/src/server/database/Database/Implementation/CharacterDatabase.cpp
+++ b/src/server/database/Database/Implementation/CharacterDatabase.cpp
@@ -105,7 +105,7 @@ void CharacterDatabaseConnection::DoPrepareStatements()
PrepareStatement(CHAR_SEL_MAIL_COUNT, "SELECT COUNT(*) FROM mail WHERE receiver = ?", CONNECTION_SYNCH);
PrepareStatement(CHAR_SEL_CHARACTER_SOCIALLIST, "SELECT friend, flags, note FROM character_social JOIN characters ON characters.guid = character_social.friend WHERE character_social.guid = ? AND deleteinfos_name IS NULL LIMIT 255", CONNECTION_ASYNC);
PrepareStatement(CHAR_SEL_CHARACTER_HOMEBIND, "SELECT mapId, zoneId, posX, posY, posZ FROM character_homebind WHERE guid = ?", CONNECTION_ASYNC);
- PrepareStatement(CHAR_SEL_CHARACTER_SPELLCOOLDOWNS, "SELECT spell, item, time FROM character_spell_cooldown WHERE guid = ? AND time > UNIX_TIMESTAMP()", CONNECTION_ASYNC);
+ PrepareStatement(CHAR_SEL_CHARACTER_SPELLCOOLDOWNS, "SELECT spell, item, time, categoryId, categoryEnd FROM character_spell_cooldown WHERE guid = ? AND time > UNIX_TIMESTAMP()", CONNECTION_ASYNC);
PrepareStatement(CHAR_SEL_CHARACTER_DECLINEDNAMES, "SELECT genitive, dative, accusative, instrumental, prepositional FROM character_declinedname WHERE guid = ?", CONNECTION_ASYNC);
PrepareStatement(CHAR_SEL_GUILD_MEMBER, "SELECT guildid, rank FROM guild_member WHERE guid = ?", CONNECTION_BOTH);
PrepareStatement(CHAR_SEL_GUILD_MEMBER_EXTENDED, "SELECT g.guildid, g.name, gr.rname, gr.rid, gm.pnote, gm.offnote "
@@ -157,7 +157,6 @@ void CharacterDatabaseConnection::DoPrepareStatements()
PrepareStatement(CHAR_DEL_GIFT, "DELETE FROM character_gifts WHERE item_guid = ?", CONNECTION_ASYNC);
PrepareStatement(CHAR_SEL_CHARACTER_GIFT_BY_ITEM, "SELECT entry, flags FROM character_gifts WHERE item_guid = ?", CONNECTION_SYNCH);
PrepareStatement(CHAR_SEL_ACCOUNT_BY_NAME, "SELECT account FROM characters WHERE name = ?", CONNECTION_SYNCH);
- PrepareStatement(CHAR_SEL_ACCOUNT_BY_GUID, "SELECT account FROM characters WHERE guid = ?", CONNECTION_SYNCH);
PrepareStatement(CHAR_SEL_CHARACTER_DATA_BY_GUID, "SELECT account, name, level FROM characters WHERE guid = ?", CONNECTION_SYNCH);
PrepareStatement(CHAR_DEL_ACCOUNT_INSTANCE_LOCK_TIMES, "DELETE FROM account_instance_times WHERE accountId = ?", CONNECTION_ASYNC);
PrepareStatement(CHAR_INS_ACCOUNT_INSTANCE_LOCK_TIMES, "INSERT INTO account_instance_times (accountId, instanceId, releaseTime) VALUES (?, ?, ?)", CONNECTION_ASYNC);
@@ -251,7 +250,7 @@ void CharacterDatabaseConnection::DoPrepareStatements()
"VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", CONNECTION_ASYNC);
// Account data
- PrepareStatement(CHAR_SEL_ACCOUNT_DATA, "SELECT type, time, data FROM account_data WHERE accountId = ?", CONNECTION_SYNCH);
+ PrepareStatement(CHAR_SEL_ACCOUNT_DATA, "SELECT type, time, data FROM account_data WHERE accountId = ?", CONNECTION_ASYNC);
PrepareStatement(CHAR_REP_ACCOUNT_DATA, "REPLACE INTO account_data (accountId, type, time, data) VALUES (?, ?, ?, ?)", CONNECTION_ASYNC);
PrepareStatement(CHAR_DEL_ACCOUNT_DATA, "DELETE FROM account_data WHERE accountId = ?", CONNECTION_ASYNC);
PrepareStatement(CHAR_SEL_PLAYER_ACCOUNT_DATA, "SELECT type, time, data FROM character_account_data WHERE guid = ?", CONNECTION_ASYNC);
@@ -259,7 +258,7 @@ void CharacterDatabaseConnection::DoPrepareStatements()
PrepareStatement(CHAR_DEL_PLAYER_ACCOUNT_DATA, "DELETE FROM character_account_data WHERE guid = ?", CONNECTION_ASYNC);
// Tutorials
- PrepareStatement(CHAR_SEL_TUTORIALS, "SELECT tut0, tut1, tut2, tut3, tut4, tut5, tut6, tut7 FROM account_tutorial WHERE accountId = ?", CONNECTION_SYNCH);
+ PrepareStatement(CHAR_SEL_TUTORIALS, "SELECT tut0, tut1, tut2, tut3, tut4, tut5, tut6, tut7 FROM account_tutorial WHERE accountId = ?", CONNECTION_ASYNC);
PrepareStatement(CHAR_SEL_HAS_TUTORIALS, "SELECT 1 FROM account_tutorial WHERE accountId = ?", CONNECTION_SYNCH);
PrepareStatement(CHAR_INS_TUTORIALS, "INSERT INTO account_tutorial(tut0, tut1, tut2, tut3, tut4, tut5, tut6, tut7, accountId) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)", CONNECTION_ASYNC);
PrepareStatement(CHAR_UPD_TUTORIALS, "UPDATE account_tutorial SET tut0 = ?, tut1 = ?, tut2 = ?, tut3 = ?, tut4 = ?, tut5 = ?, tut6 = ?, tut7 = ? WHERE accountId = ?", CONNECTION_ASYNC);
@@ -336,10 +335,11 @@ void CharacterDatabaseConnection::DoPrepareStatements()
PrepareStatement(CHAR_DEL_GO_RESPAWN_BY_INSTANCE, "DELETE FROM gameobject_respawn WHERE mapId = ? AND instanceId = ?", CONNECTION_ASYNC);
// GM Tickets
- PrepareStatement(CHAR_SEL_GM_TICKETS, "SELECT id, playerGuid, name, description, createTime, mapId, posX, posY, posZ, lastModifiedTime, closedBy, assignedTo, comment, response, completed, escalated, viewed, needMoreHelp FROM gm_ticket", CONNECTION_SYNCH);
- PrepareStatement(CHAR_REP_GM_TICKET, "REPLACE INTO gm_ticket (id, playerGuid, name, description, createTime, mapId, posX, posY, posZ, lastModifiedTime, closedBy, assignedTo, comment, response, completed, escalated, viewed, needMoreHelp, resolvedBy) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", CONNECTION_ASYNC);
+ PrepareStatement(CHAR_SEL_GM_TICKETS, "SELECT id, type, playerGuid, name, description, createTime, mapId, posX, posY, posZ, lastModifiedTime, closedBy, assignedTo, comment, response, completed, escalated, viewed, needMoreHelp FROM gm_ticket", CONNECTION_SYNCH);
+ PrepareStatement(CHAR_REP_GM_TICKET, "REPLACE INTO gm_ticket (id, type, playerGuid, name, description, createTime, mapId, posX, posY, posZ, lastModifiedTime, closedBy, assignedTo, comment, response, completed, escalated, viewed, needMoreHelp, resolvedBy) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", CONNECTION_ASYNC);
PrepareStatement(CHAR_DEL_GM_TICKET, "DELETE FROM gm_ticket WHERE id = ?", CONNECTION_ASYNC);
PrepareStatement(CHAR_DEL_PLAYER_GM_TICKETS, "DELETE FROM gm_ticket WHERE playerGuid = ?", CONNECTION_ASYNC);
+ PrepareStatement(CHAR_UPD_PLAYER_GM_TICKETS_ON_CHAR_DELETION, "UPDATE gm_ticket SET type = 2 WHERE playerGuid = ?", CONNECTION_ASYNC);
// GM Survey/subsurvey/lag report
PrepareStatement(CHAR_INS_GM_SURVEY, "INSERT INTO gm_survey (guid, surveyId, mainSurvey, comment, createTime) VALUES (?, ?, ?, ?, UNIX_TIMESTAMP(NOW()))", CONNECTION_ASYNC);
@@ -498,7 +498,7 @@ void CharacterDatabaseConnection::DoPrepareStatements()
PrepareStatement(CHAR_UPD_CHAR_TITLES_FACTION_CHANGE, "UPDATE characters SET knownTitles = ? WHERE guid = ?", CONNECTION_ASYNC);
PrepareStatement(CHAR_RES_CHAR_TITLES_FACTION_CHANGE, "UPDATE characters SET chosenTitle = 0 WHERE guid = ?", CONNECTION_ASYNC);
PrepareStatement(CHAR_DEL_CHAR_SPELL_COOLDOWNS, "DELETE FROM character_spell_cooldown WHERE guid = ?", CONNECTION_ASYNC);
- PrepareStatement(CHAR_INS_CHAR_SPELL_COOLDOWN, "INSERT INTO character_spell_cooldown (guid, spell, item, time) VALUES (?, ?, ?, ?)", CONNECTION_ASYNC);
+ PrepareStatement(CHAR_INS_CHAR_SPELL_COOLDOWN, "INSERT INTO character_spell_cooldown (guid, spell, item, time, categoryId, categoryEnd) VALUES (?, ?, ?, ?, ?, ?)", CONNECTION_ASYNC);
PrepareStatement(CHAR_DEL_CHARACTER, "DELETE FROM characters WHERE guid = ?", CONNECTION_ASYNC);
PrepareStatement(CHAR_DEL_CHAR_ACTION, "DELETE FROM character_action WHERE guid = ?", CONNECTION_ASYNC);
PrepareStatement(CHAR_DEL_CHAR_AURA, "DELETE FROM character_aura WHERE guid = ?", CONNECTION_ASYNC);
@@ -578,12 +578,12 @@ void CharacterDatabaseConnection::DoPrepareStatements()
PrepareStatement(CHAR_INS_CHAR_PET_DECLINEDNAME, "INSERT INTO character_pet_declinedname (id, owner, genitive, dative, accusative, instrumental, prepositional) VALUES (?, ?, ?, ?, ?, ?, ?)", CONNECTION_ASYNC);
PrepareStatement(CHAR_SEL_PET_AURA, "SELECT casterGuid, spell, effectMask, recalculateMask, stackCount, amount0, amount1, amount2, base_amount0, base_amount1, base_amount2, maxDuration, remainTime, remainCharges FROM pet_aura WHERE guid = ?", CONNECTION_SYNCH);
PrepareStatement(CHAR_SEL_PET_SPELL, "SELECT spell, active FROM pet_spell WHERE guid = ?", CONNECTION_SYNCH);
- PrepareStatement(CHAR_SEL_PET_SPELL_COOLDOWN, "SELECT spell, time FROM pet_spell_cooldown WHERE guid = ? AND time > UNIX_TIMESTAMP()", CONNECTION_SYNCH);
+ PrepareStatement(CHAR_SEL_PET_SPELL_COOLDOWN, "SELECT spell, time, categoryId, categoryEnd FROM pet_spell_cooldown WHERE guid = ? AND time > UNIX_TIMESTAMP()", CONNECTION_SYNCH);
PrepareStatement(CHAR_SEL_PET_DECLINED_NAME, "SELECT genitive, dative, accusative, instrumental, prepositional FROM character_pet_declinedname WHERE owner = ? AND id = ?", CONNECTION_SYNCH);
PrepareStatement(CHAR_DEL_PET_AURAS, "DELETE FROM pet_aura WHERE guid = ?", CONNECTION_BOTH);
PrepareStatement(CHAR_DEL_PET_SPELLS, "DELETE FROM pet_spell WHERE guid = ?", CONNECTION_ASYNC);
PrepareStatement(CHAR_DEL_PET_SPELL_COOLDOWNS, "DELETE FROM pet_spell_cooldown WHERE guid = ?", CONNECTION_BOTH);
- PrepareStatement(CHAR_INS_PET_SPELL_COOLDOWN, "INSERT INTO pet_spell_cooldown (guid, spell, time) VALUES (?, ?, ?)", CONNECTION_BOTH);
+ PrepareStatement(CHAR_INS_PET_SPELL_COOLDOWN, "INSERT INTO pet_spell_cooldown (guid, spell, time, categoryId, categoryEnd) VALUES (?, ?, ?, ?, ?)", CONNECTION_BOTH);
PrepareStatement(CHAR_DEL_PET_SPELL_BY_SPELL, "DELETE FROM pet_spell WHERE guid = ? and spell = ?", CONNECTION_ASYNC);
PrepareStatement(CHAR_INS_PET_SPELL, "INSERT INTO pet_spell (guid, spell, active) VALUES (?, ?, ?)", CONNECTION_BOTH);
PrepareStatement(CHAR_INS_PET_AURA, "INSERT INTO pet_aura (guid, casterGuid, spell, effectMask, recalculateMask, stackCount, amount0, amount1, amount2, "
@@ -611,4 +611,7 @@ void CharacterDatabaseConnection::DoPrepareStatements()
PrepareStatement(CHAR_UPD_QUEST_TRACK_GM_COMPLETE, "UPDATE quest_tracker SET completed_by_gm = 1 WHERE id = ? AND character_guid = ? ORDER BY quest_accept_time DESC LIMIT 1", CONNECTION_ASYNC);
PrepareStatement(CHAR_UPD_QUEST_TRACK_COMPLETE_TIME, "UPDATE quest_tracker SET quest_complete_time = NOW() WHERE id = ? AND character_guid = ? ORDER BY quest_accept_time DESC LIMIT 1", CONNECTION_ASYNC);
PrepareStatement(CHAR_UPD_QUEST_TRACK_ABANDON_TIME, "UPDATE quest_tracker SET quest_abandon_time = NOW() WHERE id = ? AND character_guid = ? ORDER BY quest_accept_time DESC LIMIT 1", CONNECTION_ASYNC);
+
+ // DeserterTracker
+ PrepareStatement(CHAR_INS_DESERTER_TRACK, "INSERT INTO battleground_deserters (guid, type, datetime) VALUES (?, ?, NOW())", CONNECTION_ASYNC);
}
diff --git a/src/server/database/Database/Implementation/CharacterDatabase.h b/src/server/database/Database/Implementation/CharacterDatabase.h
index c76c584a0a8..7a463c73df2 100644
--- a/src/server/database/Database/Implementation/CharacterDatabase.h
+++ b/src/server/database/Database/Implementation/CharacterDatabase.h
@@ -143,7 +143,6 @@ enum CharacterDatabaseStatements
CHAR_DEL_GIFT,
CHAR_SEL_CHARACTER_GIFT_BY_ITEM,
CHAR_SEL_ACCOUNT_BY_NAME,
- CHAR_SEL_ACCOUNT_BY_GUID,
CHAR_DEL_ACCOUNT_INSTANCE_LOCK_TIMES,
CHAR_INS_ACCOUNT_INSTANCE_LOCK_TIMES,
CHAR_SEL_CHARACTER_NAME_CLASS,
@@ -287,6 +286,7 @@ enum CharacterDatabaseStatements
CHAR_DEL_GM_TICKET,
CHAR_DEL_ALL_GM_TICKETS,
CHAR_DEL_PLAYER_GM_TICKETS,
+ CHAR_UPD_PLAYER_GM_TICKETS_ON_CHAR_DELETION,
CHAR_INS_GM_SURVEY,
CHAR_INS_GM_SUBSURVEY,
@@ -531,6 +531,8 @@ enum CharacterDatabaseStatements
CHAR_UPD_QUEST_TRACK_COMPLETE_TIME,
CHAR_UPD_QUEST_TRACK_ABANDON_TIME,
+ CHAR_INS_DESERTER_TRACK,
+
MAX_CHARACTERDATABASE_STATEMENTS
};
diff --git a/src/server/database/Database/Implementation/LoginDatabase.cpp b/src/server/database/Database/Implementation/LoginDatabase.cpp
index 8f0b5067957..de003c2092b 100644
--- a/src/server/database/Database/Implementation/LoginDatabase.cpp
+++ b/src/server/database/Database/Implementation/LoginDatabase.cpp
@@ -25,6 +25,9 @@ void LoginDatabaseConnection::DoPrepareStatements()
PrepareStatement(LOGIN_SEL_REALMLIST, "SELECT id, name, address, localAddress, localSubnetMask, port, icon, flag, timezone, allowedSecurityLevel, population, gamebuild FROM realmlist WHERE flag <> 3 ORDER BY name", CONNECTION_SYNCH);
PrepareStatement(LOGIN_DEL_EXPIRED_IP_BANS, "DELETE FROM ip_banned WHERE unbandate<>bandate AND unbandate<=UNIX_TIMESTAMP()", CONNECTION_ASYNC);
PrepareStatement(LOGIN_UPD_EXPIRED_ACCOUNT_BANS, "UPDATE account_banned SET active = 0 WHERE active = 1 AND unbandate<>bandate AND unbandate<=UNIX_TIMESTAMP()", CONNECTION_SYNCH);
+ PrepareStatement(LOGIN_SEL_IP_INFO, "(SELECT unbandate > UNIX_TIMESTAMP() OR unbandate = bandate AS banned, NULL as country FROM ip_banned WHERE ip = ?) "
+ "UNION "
+ "(SELECT NULL AS banned, country FROM ip2nation WHERE INET_NTOA(ip) = ?)", CONNECTION_ASYNC);
PrepareStatement(LOGIN_SEL_IP_BANNED, "SELECT * FROM ip_banned WHERE ip = ?", CONNECTION_SYNCH);
PrepareStatement(LOGIN_INS_IP_AUTO_BANNED, "INSERT INTO ip_banned (ip, bandate, unbandate, bannedby, banreason) VALUES (?, UNIX_TIMESTAMP(), UNIX_TIMESTAMP()+?, 'Trinity Auth', 'Failed login autoban')", CONNECTION_ASYNC);
PrepareStatement(LOGIN_SEL_IP_BANNED_ALL, "SELECT ip, bandate, unbandate, bannedby, banreason FROM ip_banned WHERE (bandate = unbandate OR unbandate > UNIX_TIMESTAMP()) ORDER BY unbandate", CONNECTION_SYNCH);
@@ -43,7 +46,9 @@ void LoginDatabaseConnection::DoPrepareStatements()
PrepareStatement(LOGIN_SEL_FAILEDLOGINS, "SELECT id, failed_logins FROM account WHERE username = ?", CONNECTION_SYNCH);
PrepareStatement(LOGIN_SEL_ACCOUNT_ID_BY_NAME, "SELECT id FROM account WHERE username = ?", CONNECTION_SYNCH);
PrepareStatement(LOGIN_SEL_ACCOUNT_LIST_BY_NAME, "SELECT id, username FROM account WHERE username = ?", CONNECTION_SYNCH);
- PrepareStatement(LOGIN_SEL_ACCOUNT_INFO_BY_NAME, "SELECT id, sessionkey, last_ip, locked, expansion, mutetime, locale, recruiter, os FROM account WHERE username = ?", CONNECTION_SYNCH);
+ PrepareStatement(LOGIN_SEL_ACCOUNT_INFO_BY_NAME, "SELECT a.id, a.sessionkey, a.last_ip, a.locked, a.lock_country, a.expansion, a.mutetime, a.locale, a.recruiter, a.os, aa.gmLevel, "
+ "ab.unbandate > UNIX_TIMESTAMP() OR ab.unbandate = ab.bandate, r.id FROM account a LEFT JOIN account_access aa ON a.id = aa.id AND aa.RealmID IN (-1, ?) "
+ "LEFT JOIN account_banned ab ON a.id = ab.id AND ab.active = 1 LEFT JOIN account r ON a.id = r.recruiter WHERE a.username = ? ORDER BY aa.RealmID DESC LIMIT 1", CONNECTION_ASYNC);
PrepareStatement(LOGIN_SEL_ACCOUNT_LIST_BY_EMAIL, "SELECT id, username FROM account WHERE email = ?", CONNECTION_SYNCH);
PrepareStatement(LOGIN_SEL_NUM_CHARS_ON_REALM, "SELECT numchars FROM realmcharacters WHERE realmid = ? AND acctid= ?", CONNECTION_SYNCH);
PrepareStatement(LOGIN_SEL_ACCOUNT_BY_IP, "SELECT id, username FROM account WHERE last_ip = ?", CONNECTION_SYNCH);
@@ -88,8 +93,6 @@ void LoginDatabaseConnection::DoPrepareStatements()
PrepareStatement(LOGIN_SEL_ACCOUNT_INFO, "SELECT a.username, a.last_ip, aa.gmlevel, a.expansion FROM account a LEFT JOIN account_access aa ON (a.id = aa.id) WHERE a.id = ?", CONNECTION_SYNCH);
PrepareStatement(LOGIN_SEL_ACCOUNT_ACCESS_GMLEVEL_TEST, "SELECT 1 FROM account_access WHERE id = ? AND gmlevel > ?", CONNECTION_SYNCH);
PrepareStatement(LOGIN_SEL_ACCOUNT_ACCESS, "SELECT a.id, aa.gmlevel, aa.RealmID FROM account a LEFT JOIN account_access aa ON (a.id = aa.id) WHERE a.username = ?", CONNECTION_SYNCH);
- PrepareStatement(LOGIN_SEL_ACCOUNT_RECRUITER, "SELECT 1 FROM account WHERE recruiter = ?", CONNECTION_SYNCH);
- PrepareStatement(LOGIN_SEL_BANS, "SELECT 1 FROM account_banned WHERE id = ? AND active = 1 UNION SELECT 1 FROM ip_banned WHERE ip = ?", CONNECTION_SYNCH);
PrepareStatement(LOGIN_SEL_ACCOUNT_WHOIS, "SELECT username, email, last_ip FROM account WHERE id = ?", CONNECTION_SYNCH);
PrepareStatement(LOGIN_SEL_LAST_ATTEMPT_IP, "SELECT last_attempt_ip FROM account WHERE id = ?", CONNECTION_SYNCH);
PrepareStatement(LOGIN_SEL_LAST_IP, "SELECT last_ip FROM account WHERE id = ?", CONNECTION_SYNCH);
@@ -108,7 +111,7 @@ void LoginDatabaseConnection::DoPrepareStatements()
PrepareStatement(LOGIN_INS_FALP_IP_LOGGING, "INSERT INTO logs_ip_actions (account_id,character_guid,type,ip,systemnote,unixtime,time) VALUES ((SELECT id FROM account WHERE username = ?), 0, 1, ?, ?, unix_timestamp(NOW()), NOW())", CONNECTION_ASYNC);
PrepareStatement(LOGIN_SEL_ACCOUNT_ACCESS_BY_ID, "SELECT gmlevel, RealmID FROM account_access WHERE id = ? and (RealmID = ? OR RealmID = -1) ORDER BY gmlevel desc", CONNECTION_SYNCH);
- PrepareStatement(LOGIN_SEL_RBAC_ACCOUNT_PERMISSIONS, "SELECT permissionId, granted FROM rbac_account_permissions WHERE accountId = ? AND (realmId = ? OR realmId = -1) ORDER BY permissionId, realmId", CONNECTION_SYNCH);
+ PrepareStatement(LOGIN_SEL_RBAC_ACCOUNT_PERMISSIONS, "SELECT permissionId, granted FROM rbac_account_permissions WHERE accountId = ? AND (realmId = ? OR realmId = -1) ORDER BY permissionId, realmId", CONNECTION_BOTH);
PrepareStatement(LOGIN_INS_RBAC_ACCOUNT_PERMISSION, "INSERT INTO rbac_account_permissions (accountId, permissionId, granted, realmId) VALUES (?, ?, ?, ?) ON DUPLICATE KEY UPDATE granted = VALUES(granted)", CONNECTION_ASYNC);
PrepareStatement(LOGIN_DEL_RBAC_ACCOUNT_PERMISSION, "DELETE FROM rbac_account_permissions WHERE accountId = ? AND permissionId = ? AND (realmId = ? OR realmId = -1)", CONNECTION_ASYNC);
PrepareStatement(LOGIN_INS_ACCOUNT_MUTE, "INSERT INTO account_muted VALUES (?, UNIX_TIMESTAMP(), ?, ?, ?)", CONNECTION_ASYNC);
diff --git a/src/server/database/Database/Implementation/LoginDatabase.h b/src/server/database/Database/Implementation/LoginDatabase.h
index 79b7a53cb6e..3b30105e670 100644
--- a/src/server/database/Database/Implementation/LoginDatabase.h
+++ b/src/server/database/Database/Implementation/LoginDatabase.h
@@ -32,6 +32,7 @@ enum LoginDatabaseStatements
LOGIN_SEL_REALMLIST,
LOGIN_DEL_EXPIRED_IP_BANS,
LOGIN_UPD_EXPIRED_ACCOUNT_BANS,
+ LOGIN_SEL_IP_INFO,
LOGIN_SEL_IP_BANNED,
LOGIN_INS_IP_AUTO_BANNED,
LOGIN_SEL_ACCOUNT_BANNED,
@@ -95,8 +96,6 @@ enum LoginDatabaseStatements
LOGIN_SEL_ACCOUNT_INFO,
LOGIN_SEL_ACCOUNT_ACCESS_GMLEVEL_TEST,
LOGIN_SEL_ACCOUNT_ACCESS,
- LOGIN_SEL_ACCOUNT_RECRUITER,
- LOGIN_SEL_BANS,
LOGIN_SEL_ACCOUNT_WHOIS,
LOGIN_SEL_REALMLIST_SECURITY_LEVEL,
LOGIN_DEL_ACCOUNT,
diff --git a/src/server/game/AI/CoreAI/CombatAI.cpp b/src/server/game/AI/CoreAI/CombatAI.cpp
index 7efed2976c4..9d76ee5573d 100644
--- a/src/server/game/AI/CoreAI/CombatAI.cpp
+++ b/src/server/game/AI/CoreAI/CombatAI.cpp
@@ -259,7 +259,7 @@ void TurretAI::UpdateAI(uint32 /*diff*/)
// VehicleAI
//////////////
-VehicleAI::VehicleAI(Creature* creature) : CreatureAI(creature), m_ConditionsTimer(VEHICLE_CONDITION_CHECK_TIME)
+VehicleAI::VehicleAI(Creature* creature) : CreatureAI(creature), m_HasConditions(false), m_ConditionsTimer(VEHICLE_CONDITION_CHECK_TIME)
{
LoadConditions();
m_DoDismiss = false;
@@ -285,7 +285,7 @@ void VehicleAI::UpdateAI(uint32 diff)
void VehicleAI::OnCharmed(bool apply)
{
- if (!me->GetVehicleKit()->IsVehicleInUse() && !apply && !conditions.empty()) // was used and has conditions
+ if (!me->GetVehicleKit()->IsVehicleInUse() && !apply && m_HasConditions) // was used and has conditions
{
m_DoDismiss = true; // needs reset
}
@@ -297,16 +297,14 @@ void VehicleAI::OnCharmed(bool apply)
void VehicleAI::LoadConditions()
{
- conditions = sConditionMgr->GetConditionsForNotGroupedEntry(CONDITION_SOURCE_TYPE_CREATURE_TEMPLATE_VEHICLE, me->GetEntry());
- if (!conditions.empty())
- TC_LOG_DEBUG("condition", "VehicleAI::LoadConditions: loaded %u conditions", uint32(conditions.size()));
+ m_HasConditions = sConditionMgr->HasConditionsForNotGroupedEntry(CONDITION_SOURCE_TYPE_CREATURE_TEMPLATE_VEHICLE, me->GetEntry());
}
void VehicleAI::CheckConditions(uint32 diff)
{
if (m_ConditionsTimer < diff)
{
- if (!conditions.empty())
+ if (m_HasConditions)
{
if (Vehicle* vehicleKit = me->GetVehicleKit())
for (SeatMap::iterator itr = vehicleKit->Seats.begin(); itr != vehicleKit->Seats.end(); ++itr)
@@ -314,7 +312,7 @@ void VehicleAI::CheckConditions(uint32 diff)
{
if (Player* player = passenger->ToPlayer())
{
- if (!sConditionMgr->IsObjectMeetToConditions(player, me, conditions))
+ if (!sConditionMgr->IsObjectMeetingNotGroupedConditions(CONDITION_SOURCE_TYPE_CREATURE_TEMPLATE_VEHICLE, me->GetEntry(), player, me))
{
player->ExitVehicle();
return; // check other pessanger in next tick
diff --git a/src/server/game/AI/CoreAI/CombatAI.h b/src/server/game/AI/CoreAI/CombatAI.h
index 97308f22e5d..26b5db3e7c8 100644
--- a/src/server/game/AI/CoreAI/CombatAI.h
+++ b/src/server/game/AI/CoreAI/CombatAI.h
@@ -112,7 +112,7 @@ struct VehicleAI : public CreatureAI
private:
void LoadConditions();
void CheckConditions(uint32 diff);
- ConditionList conditions;
+ bool m_HasConditions;
uint32 m_ConditionsTimer;
bool m_DoDismiss;
uint32 m_DismissTimer;
diff --git a/src/server/game/AI/CreatureAIFactory.h b/src/server/game/AI/CreatureAIFactory.h
index 4473d3e9cd5..4e11630259b 100644
--- a/src/server/game/AI/CreatureAIFactory.h
+++ b/src/server/game/AI/CreatureAIFactory.h
@@ -50,6 +50,8 @@ CreatureAIFactory<REAL_AI>::Create(void* data) const
typedef FactoryHolder<CreatureAI> CreatureAICreator;
typedef FactoryHolder<CreatureAI>::FactoryHolderRegistry CreatureAIRegistry;
+#define sCreatureAIRegistry CreatureAIRegistry::instance()
+
//GO
struct SelectableGameObjectAI : public FactoryHolder<GameObjectAI>, public Permissible<GameObject>
{
@@ -76,4 +78,7 @@ GameObjectAIFactory<REAL_GO_AI>::Create(void* data) const
typedef FactoryHolder<GameObjectAI> GameObjectAICreator;
typedef FactoryHolder<GameObjectAI>::FactoryHolderRegistry GameObjectAIRegistry;
+
+#define sGameObjectAIRegistry GameObjectAIRegistry::instance()
+
#endif
diff --git a/src/server/game/AI/CreatureAIImpl.h b/src/server/game/AI/CreatureAIImpl.h
index a2c5c5db057..529f7420021 100644
--- a/src/server/game/AI/CreatureAIImpl.h
+++ b/src/server/game/AI/CreatureAIImpl.h
@@ -23,292 +23,14 @@
#include "CreatureAI.h"
#include "SpellMgr.h"
-template<class T>
-inline
-const T& RAND(const T& v1, const T& v2)
-{
- return (urand(0, 1)) ? v1 : v2;
-}
-
-template<class T>
-inline
-const T& RAND(const T& v1, const T& v2, const T& v3)
-{
- switch (urand(0, 2))
- {
- default:
- case 0: return v1;
- case 1: return v2;
- case 2: return v3;
- }
-}
-
-template<class T>
-inline
-const T& RAND(const T& v1, const T& v2, const T& v3, const T& v4)
-{
- switch (urand(0, 3))
- {
- default:
- case 0: return v1;
- case 1: return v2;
- case 2: return v3;
- case 3: return v4;
- }
-}
-
-template<class T>
-inline
-const T& RAND(const T& v1, const T& v2, const T& v3, const T& v4, const T& v5)
-{
- switch (urand(0, 4))
- {
- default:
- case 0: return v1;
- case 1: return v2;
- case 2: return v3;
- case 3: return v4;
- case 4: return v5;
- }
-}
-
-template<class T>
-inline
-const T& RAND(const T& v1, const T& v2, const T& v3, const T& v4, const T& v5, const T& v6)
-{
- switch (urand(0, 5))
- {
- default:
- case 0: return v1;
- case 1: return v2;
- case 2: return v3;
- case 3: return v4;
- case 4: return v5;
- case 5: return v6;
- }
-}
-
-template<class T>
-inline
-const T& RAND(const T& v1, const T& v2, const T& v3, const T& v4, const T& v5, const T& v6, const T& v7)
-{
- switch (urand(0, 6))
- {
- default:
- case 0: return v1;
- case 1: return v2;
- case 2: return v3;
- case 3: return v4;
- case 4: return v5;
- case 5: return v6;
- case 6: return v7;
- }
-}
-
-template<class T>
-inline
-const T& RAND(const T& v1, const T& v2, const T& v3, const T& v4, const T& v5, const T& v6, const T& v7, const T& v8)
-{
- switch (urand(0, 7))
- {
- default:
- case 0: return v1;
- case 1: return v2;
- case 2: return v3;
- case 3: return v4;
- case 4: return v5;
- case 5: return v6;
- case 6: return v7;
- case 7: return v8;
- }
-}
-
-template<class T>
-inline
-const T& RAND(const T& v1, const T& v2, const T& v3, const T& v4, const T& v5, const T& v6, const T& v7, const T& v8,
- const T& v9)
-{
- switch (urand(0, 8))
- {
- default:
- case 0: return v1;
- case 1: return v2;
- case 2: return v3;
- case 3: return v4;
- case 4: return v5;
- case 5: return v6;
- case 6: return v7;
- case 7: return v8;
- case 8: return v9;
- }
-}
-
-template<class T>
-inline
-const T& RAND(const T& v1, const T& v2, const T& v3, const T& v4, const T& v5, const T& v6, const T& v7, const T& v8,
- const T& v9, const T& v10)
-{
- switch (urand(0, 9))
- {
- default:
- case 0: return v1;
- case 1: return v2;
- case 2: return v3;
- case 3: return v4;
- case 4: return v5;
- case 5: return v6;
- case 6: return v7;
- case 7: return v8;
- case 8: return v9;
- case 9: return v10;
- }
-}
-
-template<class T>
-inline
-const T& RAND(const T& v1, const T& v2, const T& v3, const T& v4, const T& v5, const T& v6, const T& v7, const T& v8,
- const T& v9, const T& v10, const T& v11)
-{
- switch (urand(0, 10))
- {
- default:
- case 0: return v1;
- case 1: return v2;
- case 2: return v3;
- case 3: return v4;
- case 4: return v5;
- case 5: return v6;
- case 6: return v7;
- case 7: return v8;
- case 8: return v9;
- case 9: return v10;
- case 10: return v11;
- }
-}
-
-template<class T>
-inline
-const T& RAND(const T& v1, const T& v2, const T& v3, const T& v4, const T& v5, const T& v6, const T& v7, const T& v8,
- const T& v9, const T& v10, const T& v11, const T& v12)
-{
- switch (urand(0, 11))
- {
- default:
- case 0: return v1;
- case 1: return v2;
- case 2: return v3;
- case 3: return v4;
- case 4: return v5;
- case 5: return v6;
- case 6: return v7;
- case 7: return v8;
- case 8: return v9;
- case 9: return v10;
- case 10: return v11;
- case 11: return v12;
- }
-}
-
-template<class T>
-inline
-const T& RAND(const T& v1, const T& v2, const T& v3, const T& v4, const T& v5, const T& v6, const T& v7, const T& v8,
- const T& v9, const T& v10, const T& v11, const T& v12, const T& v13)
-{
- switch (urand(0, 12))
- {
- default:
- case 0: return v1;
- case 1: return v2;
- case 2: return v3;
- case 3: return v4;
- case 4: return v5;
- case 5: return v6;
- case 6: return v7;
- case 7: return v8;
- case 8: return v9;
- case 9: return v10;
- case 10: return v11;
- case 11: return v12;
- case 12: return v13;
- }
-}
-
-template<class T>
-inline
-const T& RAND(const T& v1, const T& v2, const T& v3, const T& v4, const T& v5, const T& v6, const T& v7, const T& v8,
- const T& v9, const T& v10, const T& v11, const T& v12, const T& v13, const T& v14)
-{
- switch (urand(0, 13))
- {
- default:
- case 0: return v1;
- case 1: return v2;
- case 2: return v3;
- case 3: return v4;
- case 4: return v5;
- case 5: return v6;
- case 6: return v7;
- case 7: return v8;
- case 8: return v9;
- case 9: return v10;
- case 10: return v11;
- case 11: return v12;
- case 12: return v13;
- case 13: return v14;
- }
-}
-
-template<class T>
-inline
-const T& RAND(const T& v1, const T& v2, const T& v3, const T& v4, const T& v5, const T& v6, const T& v7, const T& v8,
- const T& v9, const T& v10, const T& v11, const T& v12, const T& v13, const T& v14, const T& v15)
-{
- switch (urand(0, 14))
- {
- default:
- case 0: return v1;
- case 1: return v2;
- case 2: return v3;
- case 3: return v4;
- case 4: return v5;
- case 5: return v6;
- case 6: return v7;
- case 7: return v8;
- case 8: return v9;
- case 9: return v10;
- case 10: return v11;
- case 11: return v12;
- case 12: return v13;
- case 13: return v14;
- case 14: return v15;
- }
-}
+#include <functional>
+#include <type_traits>
-template<class T>
-inline
-const T& RAND(const T& v1, const T& v2, const T& v3, const T& v4, const T& v5, const T& v6, const T& v7, const T& v8,
- const T& v9, const T& v10, const T& v11, const T& v12, const T& v13, const T& v14, const T& v15, const T& v16)
+template<typename First, typename Second, typename... Rest>
+static inline First const& RAND(First const& first, Second const& second, Rest const&... rest)
{
- switch (urand(0, 15))
- {
- default:
- case 0: return v1;
- case 1: return v2;
- case 2: return v3;
- case 3: return v4;
- case 4: return v5;
- case 5: return v6;
- case 6: return v7;
- case 7: return v8;
- case 8: return v9;
- case 9: return v10;
- case 10: return v11;
- case 11: return v12;
- case 12: return v13;
- case 13: return v14;
- case 14: return v15;
- case 15: return v16;
- }
+ std::reference_wrapper<typename std::add_const<First>::type> const pack[] = { first, second, rest... };
+ return pack[urand(0, sizeof...(rest) + 1)].get();
}
enum AITarget
diff --git a/src/server/game/AI/CreatureAISelector.cpp b/src/server/game/AI/CreatureAISelector.cpp
index d3e11733997..4cab7d5c099 100644
--- a/src/server/game/AI/CreatureAISelector.cpp
+++ b/src/server/game/AI/CreatureAISelector.cpp
@@ -30,10 +30,9 @@ namespace FactorySelector
CreatureAI* selectAI(Creature* creature)
{
const CreatureAICreator* ai_factory = NULL;
- CreatureAIRegistry& ai_registry(*CreatureAIRegistry::instance());
if (creature->IsPet())
- ai_factory = ai_registry.GetRegistryItem("PetAI");
+ ai_factory = sCreatureAIRegistry->GetRegistryItem("PetAI");
//scriptname in db
if (!ai_factory)
@@ -43,32 +42,32 @@ namespace FactorySelector
// AIname in db
std::string ainame=creature->GetAIName();
if (!ai_factory && !ainame.empty())
- ai_factory = ai_registry.GetRegistryItem(ainame);
+ ai_factory = sCreatureAIRegistry->GetRegistryItem(ainame);
// select by NPC flags
if (!ai_factory)
{
if (creature->IsVehicle())
- ai_factory = ai_registry.GetRegistryItem("VehicleAI");
+ ai_factory = sCreatureAIRegistry->GetRegistryItem("VehicleAI");
else if (creature->HasUnitTypeMask(UNIT_MASK_CONTROLABLE_GUARDIAN) && ((Guardian*)creature)->GetOwner()->GetTypeId() == TYPEID_PLAYER)
- ai_factory = ai_registry.GetRegistryItem("PetAI");
+ ai_factory = sCreatureAIRegistry->GetRegistryItem("PetAI");
else if (creature->HasFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_SPELLCLICK))
- ai_factory = ai_registry.GetRegistryItem("NullCreatureAI");
+ ai_factory = sCreatureAIRegistry->GetRegistryItem("NullCreatureAI");
else if (creature->IsGuard())
- ai_factory = ai_registry.GetRegistryItem("GuardAI");
+ ai_factory = sCreatureAIRegistry->GetRegistryItem("GuardAI");
else if (creature->HasUnitTypeMask(UNIT_MASK_CONTROLABLE_GUARDIAN))
- ai_factory = ai_registry.GetRegistryItem("PetAI");
+ ai_factory = sCreatureAIRegistry->GetRegistryItem("PetAI");
else if (creature->IsTotem())
- ai_factory = ai_registry.GetRegistryItem("TotemAI");
+ ai_factory = sCreatureAIRegistry->GetRegistryItem("TotemAI");
else if (creature->IsTrigger())
{
if (creature->m_spells[0])
- ai_factory = ai_registry.GetRegistryItem("TriggerAI");
+ ai_factory = sCreatureAIRegistry->GetRegistryItem("TriggerAI");
else
- ai_factory = ai_registry.GetRegistryItem("NullCreatureAI");
+ ai_factory = sCreatureAIRegistry->GetRegistryItem("NullCreatureAI");
}
else if (creature->IsCritter() && !creature->HasUnitTypeMask(UNIT_MASK_GUARDIAN))
- ai_factory = ai_registry.GetRegistryItem("CritterAI");
+ ai_factory = sCreatureAIRegistry->GetRegistryItem("CritterAI");
}
// select by permit check
@@ -76,7 +75,7 @@ namespace FactorySelector
{
int best_val = -1;
typedef CreatureAIRegistry::RegistryMapType RMT;
- RMT const& l = ai_registry.GetRegisteredItems();
+ RMT const& l = sCreatureAIRegistry->GetRegisteredItems();
for (RMT::const_iterator iter = l.begin(); iter != l.end(); ++iter)
{
const CreatureAICreator* factory = iter->second;
@@ -128,14 +127,13 @@ namespace FactorySelector
GameObjectAI* SelectGameObjectAI(GameObject* go)
{
- const GameObjectAICreator* ai_factory = NULL;
- GameObjectAIRegistry& ai_registry(*GameObjectAIRegistry::instance());
+ GameObjectAICreator const* ai_factory = NULL;
// scriptname in db
if (GameObjectAI* scriptedAI = sScriptMgr->GetGameObjectAI(go))
return scriptedAI;
- ai_factory = ai_registry.GetRegistryItem(go->GetAIName());
+ ai_factory = sGameObjectAIRegistry->GetRegistryItem(go->GetAIName());
//future goAI types go here
diff --git a/src/server/game/AI/SmartScripts/SmartScript.cpp b/src/server/game/AI/SmartScripts/SmartScript.cpp
index efee565e151..a1703dfa78f 100644
--- a/src/server/game/AI/SmartScripts/SmartScript.cpp
+++ b/src/server/game/AI/SmartScripts/SmartScript.cpp
@@ -89,13 +89,8 @@ void SmartScript::ProcessEventsFor(SMART_EVENT e, Unit* unit, uint32 var0, uint3
continue;
if (eventType == e /*&& (!i->event.event_phase_mask || IsInPhase(i->event.event_phase_mask)) && !(i->event.event_flags & SMART_EVENT_FLAG_NOT_REPEATABLE && i->runOnce)*/)
- {
- ConditionList conds = sConditionMgr->GetConditionsForSmartEvent(i->entryOrGuid, i->event_id, i->source_type);
- ConditionSourceInfo info = ConditionSourceInfo(unit, GetBaseObject());
-
- if (sConditionMgr->IsObjectMeetToConditions(info, conds))
+ if (sConditionMgr->IsObjectMeetingSmartEventConditions(i->entryOrGuid, i->event_id, i->source_type, unit, GetBaseObject()))
ProcessEvent(*i, unit, var0, var1, bvar, spell, gob);
- }
}
}
@@ -1031,16 +1026,21 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
for (ObjectList::const_iterator itr = targets->begin(); itr != targets->end(); ++itr)
{
- if (!IsCreature(*itr))
- continue;
-
- if ((*itr)->ToUnit()->IsAlive() && IsSmart((*itr)->ToCreature()))
+ if (Creature* target = (*itr)->ToCreature())
{
- ENSURE_AI(SmartAI, (*itr)->ToCreature()->AI())->SetDespawnTime(e.action.forceDespawn.delay + 1); // Next tick
- ENSURE_AI(SmartAI, (*itr)->ToCreature()->AI())->StartDespawn();
+ if (target->IsAlive() && IsSmart(target))
+ {
+ ENSURE_AI(SmartAI, target->AI())->SetDespawnTime(e.action.forceDespawn.delay + 1); // Next tick
+ ENSURE_AI(SmartAI, target->AI())->StartDespawn();
+ }
+ else
+ target->DespawnOrUnsummon(e.action.forceDespawn.delay);
+ }
+ else if (GameObject* goTarget = (*itr)->ToGameObject())
+ {
+ if (IsSmartGO(goTarget))
+ goTarget->SetRespawnTime(e.action.forceDespawn.delay + 1);
}
- else
- (*itr)->ToCreature()->DespawnOrUnsummon(e.action.forceDespawn.delay);
}
delete targets;
@@ -2322,10 +2322,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
void SmartScript::ProcessTimedAction(SmartScriptHolder& e, uint32 const& min, uint32 const& max, Unit* unit, uint32 var0, uint32 var1, bool bvar, const SpellInfo* spell, GameObject* gob)
{
- ConditionList const conds = sConditionMgr->GetConditionsForSmartEvent(e.entryOrGuid, e.event_id, e.source_type);
- ConditionSourceInfo info = ConditionSourceInfo(unit, GetBaseObject());
-
- if (sConditionMgr->IsObjectMeetToConditions(info, conds))
+ if (sConditionMgr->IsObjectMeetingSmartEventConditions(e.entryOrGuid, e.event_id, e.source_type, unit, GetBaseObject()))
ProcessAction(e, unit, var0, var1, bvar, spell, gob);
RecalcTimer(e, min, max);
diff --git a/src/server/game/AI/SmartScripts/SmartScript.h b/src/server/game/AI/SmartScripts/SmartScript.h
index 96aa1f735fc..6f9046520b0 100644
--- a/src/server/game/AI/SmartScripts/SmartScript.h
+++ b/src/server/game/AI/SmartScripts/SmartScript.h
@@ -246,10 +246,10 @@ class SmartScript
DecPhase(abs(p));
}
- void DecPhase(int32 p = 1)
- {
+ void DecPhase(int32 p = 1)
+ {
if(mEventPhase > (uint32)p)
- mEventPhase -= (uint32)p;
+ mEventPhase -= (uint32)p;
else
mEventPhase = 0;
}
diff --git a/src/server/game/Accounts/RBAC.cpp b/src/server/game/Accounts/RBAC.cpp
index 74ff060636e..c520564f0fa 100644
--- a/src/server/game/Accounts/RBAC.cpp
+++ b/src/server/game/Accounts/RBAC.cpp
@@ -17,7 +17,6 @@
#include "RBAC.h"
#include "AccountMgr.h"
-#include "DatabaseEnv.h"
#include "Log.h"
namespace rbac
@@ -180,7 +179,24 @@ void RBACData::LoadFromDB()
stmt->setUInt32(0, GetId());
stmt->setInt32(1, GetRealmId());
- PreparedQueryResult result = LoginDatabase.Query(stmt);
+ LoadFromDBCallback(LoginDatabase.Query(stmt));
+}
+
+PreparedQueryResultFuture RBACData::LoadFromDBAsync()
+{
+ ClearData();
+
+ TC_LOG_DEBUG("rbac", "RBACData::LoadFromDB [Id: %u Name: %s]: Loading permissions", GetId(), GetName().c_str());
+ // Load account permissions (granted and denied) that affect current realm
+ PreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_SEL_RBAC_ACCOUNT_PERMISSIONS);
+ stmt->setUInt32(0, GetId());
+ stmt->setInt32(1, GetRealmId());
+
+ return LoginDatabase.AsyncQuery(stmt);
+}
+
+void RBACData::LoadFromDBCallback(PreparedQueryResult result)
+{
if (result)
{
do
@@ -190,8 +206,7 @@ void RBACData::LoadFromDB()
GrantPermission(fields[0].GetUInt32());
else
DenyPermission(fields[0].GetUInt32());
- }
- while (result->NextRow());
+ } while (result->NextRow());
}
// Add default permissions
diff --git a/src/server/game/Accounts/RBAC.h b/src/server/game/Accounts/RBAC.h
index 805f613155d..4acadd7f2b4 100644
--- a/src/server/game/Accounts/RBAC.h
+++ b/src/server/game/Accounts/RBAC.h
@@ -40,7 +40,7 @@
#ifndef _RBAC_H
#define _RBAC_H
-#include "Define.h"
+#include "DatabaseEnv.h"
#include <string>
#include <set>
#include <map>
@@ -864,6 +864,8 @@ class RBACData
/// Loads all permissions assigned to current account
void LoadFromDB();
+ PreparedQueryResultFuture LoadFromDBAsync();
+ void LoadFromDBCallback(PreparedQueryResult result);
/// Sets security level
void SetSecurityLevel(uint8 id)
diff --git a/src/server/game/Achievements/AchievementMgr.cpp b/src/server/game/Achievements/AchievementMgr.cpp
index 2662273697f..2bacaff496f 100644
--- a/src/server/game/Achievements/AchievementMgr.cpp
+++ b/src/server/game/Achievements/AchievementMgr.cpp
@@ -2344,7 +2344,7 @@ void AchievementGlobalMgr::LoadAchievementCriteriaData()
if (dataType != ACHIEVEMENT_CRITERIA_DATA_TYPE_SCRIPT)
TC_LOG_ERROR("sql.sql", "Table `achievement_criteria_data` has ScriptName set for non-scripted data type (Entry: %u, type %u), useless data.", criteria_id, dataType);
else
- scriptId = sObjectMgr->GetScriptId(scriptName.c_str());
+ scriptId = sObjectMgr->GetScriptId(scriptName);
}
AchievementCriteriaData data(dataType, fields[2].GetUInt32(), fields[3].GetUInt32(), scriptId);
diff --git a/src/server/game/Battlegrounds/Battleground.cpp b/src/server/game/Battlegrounds/Battleground.cpp
index 0e44925cd57..d368b347a0f 100644
--- a/src/server/game/Battlegrounds/Battleground.cpp
+++ b/src/server/game/Battlegrounds/Battleground.cpp
@@ -306,6 +306,15 @@ inline void Battleground::_ProcessOfflineQueue()
{
if (itr->second.OfflineRemoveTime <= sWorld->GetGameTime())
{
+ if (isBattleground() && sWorld->getBoolConfig(CONFIG_BATTLEGROUND_TRACK_DESERTERS) &&
+ (GetStatus() == STATUS_IN_PROGRESS || GetStatus() == STATUS_WAIT_JOIN))
+ {
+ PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_DESERTER_TRACK);
+ stmt->setUInt32(0, itr->first.GetCounter());
+ stmt->setUInt8(1, BG_DESERTION_TYPE_OFFLINE);
+ CharacterDatabase.Execute(stmt);
+ }
+
RemovePlayerAtLeave(itr->first, true, true);// remove player from BG
m_OfflineQueue.pop_front(); // remove from offline queue
//do not use itr for anything, because it is erased in RemovePlayerAtLeave()
diff --git a/src/server/game/Battlegrounds/Battleground.h b/src/server/game/Battlegrounds/Battleground.h
index 08134298569..471da9846b2 100644
--- a/src/server/game/Battlegrounds/Battleground.h
+++ b/src/server/game/Battlegrounds/Battleground.h
@@ -40,6 +40,15 @@ class BattlegroundMap;
struct PvPDifficultyEntry;
struct WorldSafeLocsEntry;
+enum BattlegroundDesertionType
+{
+ BG_DESERTION_TYPE_LEAVE_BG = 0, // player leaves the BG
+ BG_DESERTION_TYPE_OFFLINE = 1, // player is kicked from BG because offline
+ BG_DESERTION_TYPE_LEAVE_QUEUE = 2, // player is invited to join and refuses to do it
+ BG_DESERTION_TYPE_NO_ENTER_BUTTON = 3, // player is invited to join and do nothing (time expires)
+ BG_DESERTION_TYPE_INVITE_LOGOUT = 4, // player is invited to join and logs out
+};
+
enum BattlegroundCriteriaId
{
BG_CRITERIA_CHECK_RESILIENT_VICTORY,
diff --git a/src/server/game/Battlegrounds/BattlegroundMgr.cpp b/src/server/game/Battlegrounds/BattlegroundMgr.cpp
index 5bdaf0e661d..3aac3f080f2 100644
--- a/src/server/game/Battlegrounds/BattlegroundMgr.cpp
+++ b/src/server/game/Battlegrounds/BattlegroundMgr.cpp
@@ -549,7 +549,7 @@ void BattlegroundMgr::LoadBattlegroundTemplates()
float dist = fields[9].GetFloat();
bgTemplate.MaxStartDistSq = dist * dist;
bgTemplate.Weight = fields[10].GetUInt8();
- bgTemplate.ScriptId = sObjectMgr->GetScriptId(fields[11].GetCString());
+ bgTemplate.ScriptId = sObjectMgr->GetScriptId(fields[11].GetString());
bgTemplate.BattlemasterEntry = bl;
if (bgTemplate.MaxPlayersPerTeam == 0 || bgTemplate.MinPlayersPerTeam > bgTemplate.MaxPlayersPerTeam)
diff --git a/src/server/game/Battlegrounds/BattlegroundQueue.cpp b/src/server/game/Battlegrounds/BattlegroundQueue.cpp
index 162122ab4db..223b71eb8c5 100644
--- a/src/server/game/Battlegrounds/BattlegroundQueue.cpp
+++ b/src/server/game/Battlegrounds/BattlegroundQueue.cpp
@@ -1068,6 +1068,16 @@ bool BGQueueRemoveEvent::Execute(uint64 /*e_time*/, uint32 /*p_time*/)
BattlegroundQueue &bgQueue = sBattlegroundMgr->GetBattlegroundQueue(m_BgQueueTypeId);
if (bgQueue.IsPlayerInvited(m_PlayerGuid, m_BgInstanceGUID, m_RemoveTime))
{
+ // track if player leaves the BG by not clicking enter button
+ if (bg && bg->isBattleground() && sWorld->getBoolConfig(CONFIG_BATTLEGROUND_TRACK_DESERTERS) &&
+ (bg->GetStatus() == STATUS_IN_PROGRESS || bg->GetStatus() == STATUS_WAIT_JOIN))
+ {
+ PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_DESERTER_TRACK);
+ stmt->setUInt32(0, player->GetGUID().GetCounter());
+ stmt->setUInt8(1, BG_DESERTION_TYPE_NO_ENTER_BUTTON);
+ CharacterDatabase.Execute(stmt);
+ }
+
TC_LOG_DEBUG("bg.battleground", "Battleground: removing player %u from bg queue for instance %u because of not pressing enter battle in time.", player->GetGUID().GetCounter(), m_BgInstanceGUID);
player->RemoveBattlegroundQueueId(m_BgQueueTypeId);
diff --git a/src/server/game/Chat/Chat.cpp b/src/server/game/Chat/Chat.cpp
index da3055ebaaf..c99fe62f11e 100644
--- a/src/server/game/Chat/Chat.cpp
+++ b/src/server/game/Chat/Chat.cpp
@@ -34,54 +34,16 @@
bool ChatHandler::load_command_table = true;
-// get number of commands in table
-static size_t getCommandTableSize(const ChatCommand* commands)
+std::vector<ChatCommand> const& ChatHandler::getCommandTable()
{
- if (!commands)
- return 0;
- size_t count = 0;
- while (commands[count].Name != NULL)
- count++;
- return count;
-}
-
-// append source command table to target, return number of appended commands
-static size_t appendCommandTable(ChatCommand* target, const ChatCommand* source)
-{
- const size_t count = getCommandTableSize(source);
- if (count)
- memcpy(target, source, count * sizeof(ChatCommand));
- return count;
-}
-
-ChatCommand* ChatHandler::getCommandTable()
-{
- // cache for commands, needed because some commands are loaded dynamically through ScriptMgr
- // cache is never freed and will show as a memory leak in diagnostic tools
- // can't use vector as vector storage is implementation-dependent, eg, there can be alignment gaps between elements
- static ChatCommand* commandTableCache = NULL;
+ static std::vector<ChatCommand> commandTableCache;
if (LoadCommandTable())
{
SetLoadCommandTable(false);
- {
- // count total number of top-level commands
- size_t total = 0;
- std::vector<ChatCommand*> const& dynamic = sScriptMgr->GetChatCommands();
- for (std::vector<ChatCommand*>::const_iterator it = dynamic.begin(); it != dynamic.end(); ++it)
- total += getCommandTableSize(*it);
- total += 1; // ending zero
-
- // cache top-level commands
- size_t added = 0;
- free(commandTableCache);
- commandTableCache = (ChatCommand*)malloc(sizeof(ChatCommand) * total);
- ASSERT(commandTableCache);
- memset(commandTableCache, 0, sizeof(ChatCommand) * total);
- for (std::vector<ChatCommand*>::const_iterator it = dynamic.begin(); it != dynamic.end(); ++it)
- added += appendCommandTable(commandTableCache + added, *it);
- }
+ std::vector<ChatCommand> cmds = sScriptMgr->GetChatCommands();
+ commandTableCache.swap(cmds);
PreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_SEL_COMMANDS);
PreparedQueryResult result = WorldDatabase.Query(stmt);
@@ -264,7 +226,7 @@ void ChatHandler::SendSysMessage(uint32 entry)
SendSysMessage(GetTrinityString(entry));
}
-bool ChatHandler::ExecuteCommandInTable(ChatCommand* table, const char* text, std::string const& fullcmd)
+bool ChatHandler::ExecuteCommandInTable(std::vector<ChatCommand> const& table, const char* text, std::string const& fullcmd)
{
char const* oldtext = text;
std::string cmd = "";
@@ -277,7 +239,7 @@ bool ChatHandler::ExecuteCommandInTable(ChatCommand* table, const char* text, st
while (*text == ' ') ++text;
- for (uint32 i = 0; table[i].Name != NULL; ++i)
+ for (uint32 i = 0; i < table.size(); ++i)
{
if (!hasStringAbbr(table[i].Name, cmd.c_str()))
continue;
@@ -285,7 +247,7 @@ bool ChatHandler::ExecuteCommandInTable(ChatCommand* table, const char* text, st
bool match = false;
if (strlen(table[i].Name) > cmd.length())
{
- for (uint32 j = 0; table[j].Name != NULL; ++j)
+ for (uint32 j = 0; j < table.size(); ++j)
{
if (!hasStringAbbr(table[j].Name, cmd.c_str()))
continue;
@@ -301,7 +263,7 @@ bool ChatHandler::ExecuteCommandInTable(ChatCommand* table, const char* text, st
continue;
// select subcommand from child commands list
- if (table[i].ChildCommands != NULL)
+ if (!table[i].ChildCommands.empty())
{
if (!ExecuteCommandInTable(table[i].ChildCommands, text, fullcmd))
{
@@ -346,7 +308,7 @@ bool ChatHandler::ExecuteCommandInTable(ChatCommand* table, const char* text, st
fullcmd.c_str(), player->GetName().c_str(), player->GetGUID().ToString().c_str(),
m_session->GetAccountId(), player->GetPositionX(), player->GetPositionY(),
player->GetPositionZ(), player->GetMapId(),
- player->GetMap() ? player->GetMap()->GetMapName() : "Unknown",
+ player->FindMap() ? player->FindMap()->GetMapName() : "Unknown",
areaId, areaName.c_str(), zoneName.c_str(),
(player->GetSelectedUnit()) ? player->GetSelectedUnit()->GetName().c_str() : "",
guid.ToString().c_str());
@@ -367,7 +329,7 @@ bool ChatHandler::ExecuteCommandInTable(ChatCommand* table, const char* text, st
return false;
}
-bool ChatHandler::SetDataForCommandInTable(ChatCommand* table, char const* text, uint32 permission, std::string const& help, std::string const& fullcommand)
+bool ChatHandler::SetDataForCommandInTable(std::vector<ChatCommand>& table, char const* text, uint32 permission, std::string const& help, std::string const& fullcommand)
{
std::string cmd = "";
@@ -379,14 +341,14 @@ bool ChatHandler::SetDataForCommandInTable(ChatCommand* table, char const* text,
while (*text == ' ') ++text;
- for (uint32 i = 0; table[i].Name != NULL; i++)
+ for (uint32 i = 0; i < table.size(); i++)
{
// for data fill use full explicit command names
if (table[i].Name != cmd)
continue;
// select subcommand from child commands list (including "")
- if (table[i].ChildCommands != NULL)
+ if (!table[i].ChildCommands.empty())
{
if (SetDataForCommandInTable(table[i].ChildCommands, text, permission, help, fullcommand))
return true;
@@ -413,7 +375,7 @@ bool ChatHandler::SetDataForCommandInTable(ChatCommand* table, char const* text,
// in case "" command let process by caller
if (!cmd.empty())
{
- if (table == getCommandTable())
+ if (&table == &getCommandTable())
TC_LOG_ERROR("sql.sql", "Table `command` have not existed command '%s', skip.", cmd.c_str());
else
TC_LOG_ERROR("sql.sql", "Table `command` have not existed subcommand '%s' in command '%s', skip.", cmd.c_str(), fullcommand.c_str());
@@ -519,10 +481,10 @@ Valid examples:
return LinkExtractor(message).IsValidMessage();
}
-bool ChatHandler::ShowHelpForSubCommands(ChatCommand* table, char const* cmd, char const* subcmd)
+bool ChatHandler::ShowHelpForSubCommands(std::vector<ChatCommand> const& table, char const* cmd, char const* subcmd)
{
std::string list;
- for (uint32 i = 0; table[i].Name != NULL; ++i)
+ for (uint32 i = 0; i < table.size(); ++i)
{
// must be available (ignore handler existence for show command with possible available subcommands)
if (!isAvailable(table[i]))
@@ -539,14 +501,14 @@ bool ChatHandler::ShowHelpForSubCommands(ChatCommand* table, char const* cmd, ch
list += table[i].Name;
- if (table[i].ChildCommands)
+ if (!table[i].ChildCommands.empty())
list += " ...";
}
if (list.empty())
return false;
- if (table == getCommandTable())
+ if (&table == &getCommandTable())
{
SendSysMessage(LANG_AVIABLE_CMD);
PSendSysMessage("%s", list.c_str());
@@ -557,11 +519,11 @@ bool ChatHandler::ShowHelpForSubCommands(ChatCommand* table, char const* cmd, ch
return true;
}
-bool ChatHandler::ShowHelpForCommand(ChatCommand* table, const char* cmd)
+bool ChatHandler::ShowHelpForCommand(std::vector<ChatCommand> const& table, const char* cmd)
{
if (*cmd)
{
- for (uint32 i = 0; table[i].Name != NULL; ++i)
+ for (uint32 i = 0; i < table.size(); ++i)
{
// must be available (ignore handler existence for show command with possible available subcommands)
if (!isAvailable(table[i]))
@@ -573,7 +535,7 @@ bool ChatHandler::ShowHelpForCommand(ChatCommand* table, const char* cmd)
// have subcommand
char const* subcmd = (*cmd) ? strtok(NULL, " ") : "";
- if (table[i].ChildCommands && subcmd && *subcmd)
+ if (!table[i].ChildCommands.empty() && subcmd && *subcmd)
{
if (ShowHelpForCommand(table[i].ChildCommands, subcmd))
return true;
@@ -582,7 +544,7 @@ bool ChatHandler::ShowHelpForCommand(ChatCommand* table, const char* cmd)
if (!table[i].Help.empty())
SendSysMessage(table[i].Help.c_str());
- if (table[i].ChildCommands)
+ if (!table[i].ChildCommands.empty())
if (ShowHelpForSubCommands(table[i].ChildCommands, table[i].Name, subcmd ? subcmd : ""))
return true;
@@ -591,7 +553,7 @@ bool ChatHandler::ShowHelpForCommand(ChatCommand* table, const char* cmd)
}
else
{
- for (uint32 i = 0; table[i].Name != NULL; ++i)
+ for (uint32 i = 0; i < table.size(); ++i)
{
// must be available (ignore handler existence for show command with possible available subcommands)
if (!isAvailable(table[i]))
@@ -603,7 +565,7 @@ bool ChatHandler::ShowHelpForCommand(ChatCommand* table, const char* cmd)
if (!table[i].Help.empty())
SendSysMessage(table[i].Help.c_str());
- if (table[i].ChildCommands)
+ if (!table[i].ChildCommands.empty())
if (ShowHelpForSubCommands(table[i].ChildCommands, "", ""))
return true;
@@ -1169,7 +1131,7 @@ void ChatHandler::extractOptFirstArg(char* args, char** arg1, char** arg2)
char* ChatHandler::extractQuotedArg(char* args)
{
- if (!*args)
+ if (!args || !*args)
return NULL;
if (*args == '"')
diff --git a/src/server/game/Chat/Chat.h b/src/server/game/Chat/Chat.h
index 57192f948d5..2420331e363 100644
--- a/src/server/game/Chat/Chat.h
+++ b/src/server/game/Chat/Chat.h
@@ -38,13 +38,18 @@ struct GameTele;
class ChatCommand
{
+ typedef bool(*pHandler)(ChatHandler*, char const*);
+
public:
- const char * Name;
- uint32 Permission; // function pointer required correct align (use uint32)
- bool AllowConsole;
- bool (*Handler)(ChatHandler*, const char* args);
- std::string Help;
- ChatCommand* ChildCommands;
+ ChatCommand(char const* name, uint32 permission, bool allowConsole, pHandler handler, std::string help, std::vector<ChatCommand> childCommands = std::vector<ChatCommand>())
+ : Name(ASSERT_NOTNULL(name)), Permission(permission), AllowConsole(allowConsole), Handler(handler), Help(std::move(help)), ChildCommands(std::move(childCommands)) { }
+
+ char const* Name;
+ uint32 Permission; // function pointer required correct align (use uint32)
+ bool AllowConsole;
+ pHandler Handler;
+ std::string Help;
+ std::vector<ChatCommand> ChildCommands;
};
class ChatHandler
@@ -90,7 +95,7 @@ class ChatHandler
bool ParseCommands(const char* text);
- static ChatCommand* getCommandTable();
+ static std::vector<ChatCommand> const& getCommandTable();
bool isValidChatMessage(const char* msg);
void SendGlobalSysMessage(const char *str);
@@ -141,12 +146,12 @@ class ChatHandler
static bool LoadCommandTable() { return load_command_table; }
static void SetLoadCommandTable(bool val) { load_command_table = val; }
- bool ShowHelpForCommand(ChatCommand* table, const char* cmd);
+ bool ShowHelpForCommand(std::vector<ChatCommand> const& table, const char* cmd);
protected:
explicit ChatHandler() : m_session(NULL), sentErrorMessage(false) { } // for CLI subclass
- static bool SetDataForCommandInTable(ChatCommand* table, const char* text, uint32 permission, std::string const& help, std::string const& fullcommand);
- bool ExecuteCommandInTable(ChatCommand* table, const char* text, std::string const& fullcmd);
- bool ShowHelpForSubCommands(ChatCommand* table, char const* cmd, char const* subcmd);
+ static bool SetDataForCommandInTable(std::vector<ChatCommand>& table, const char* text, uint32 permission, std::string const& help, std::string const& fullcommand);
+ bool ExecuteCommandInTable(std::vector<ChatCommand> const& table, const char* text, std::string const& fullcmd);
+ bool ShowHelpForSubCommands(std::vector<ChatCommand> const& table, char const* cmd, char const* subcmd);
private:
WorldSession* m_session; // != NULL for chat command call and NULL for CLI command
diff --git a/src/server/game/Conditions/ConditionMgr.cpp b/src/server/game/Conditions/ConditionMgr.cpp
index f7260326857..8e8c640ccf7 100644
--- a/src/server/game/Conditions/ConditionMgr.cpp
+++ b/src/server/game/Conditions/ConditionMgr.cpp
@@ -28,7 +28,7 @@
#include "SpellAuras.h"
#include "SpellMgr.h"
-char const* ConditionMgr::StaticSourceTypeData[CONDITION_SOURCE_TYPE_MAX] =
+char const* const ConditionMgr::StaticSourceTypeData[CONDITION_SOURCE_TYPE_MAX] =
{
"None",
"Creature Loot",
@@ -105,7 +105,7 @@ ConditionMgr::ConditionTypeInfo const ConditionMgr::StaticConditionTypeData[COND
// Checks if object meets the condition
// Can have CONDITION_SOURCE_TYPE_NONE && !mReferenceId if called from a special event (ie: eventAI)
-bool Condition::Meets(ConditionSourceInfo& sourceInfo)
+bool Condition::Meets(ConditionSourceInfo& sourceInfo) const
{
ASSERT(ConditionTarget < MAX_CONDITION_TARGETS);
WorldObject* object = sourceInfo.mConditionTargets[ConditionTarget];
@@ -231,7 +231,7 @@ bool Condition::Meets(ConditionSourceInfo& sourceInfo)
case CONDITION_INSTANCE_INFO:
{
Map* map = object->GetMap();
- if (map && map->IsDungeon())
+ if (map->IsDungeon())
{
if (InstanceScript const* instance = ((InstanceMap*)map)->GetInstanceScript())
{
@@ -324,7 +324,7 @@ bool Condition::Meets(ConditionSourceInfo& sourceInfo)
Unit* unit = object->ToUnit();
if (toUnit && unit)
{
- switch (ConditionValue2)
+ switch (static_cast<RelationType>(ConditionValue2))
{
case RELATION_SELF:
condMeets = unit == toUnit;
@@ -344,6 +344,8 @@ bool Condition::Meets(ConditionSourceInfo& sourceInfo)
case RELATION_CREATED_BY:
condMeets = unit->GetCreatorGUID() == toUnit->GetGUID();
break;
+ default:
+ break;
}
}
}
@@ -445,7 +447,7 @@ bool Condition::Meets(ConditionSourceInfo& sourceInfo)
return condMeets && script;
}
-uint32 Condition::GetSearcherTypeMaskForCondition()
+uint32 Condition::GetSearcherTypeMaskForCondition() const
{
// build mask of types for which condition can return true
// this is used for speeding up gridsearches
@@ -607,7 +609,7 @@ uint32 Condition::GetSearcherTypeMaskForCondition()
return mask;
}
-uint32 Condition::GetMaxAvailableConditionTargets()
+uint32 Condition::GetMaxAvailableConditionTargets() const
{
// returns number of targets which are available for given source type
switch (SourceType)
@@ -663,114 +665,105 @@ ConditionMgr::~ConditionMgr()
Clean();
}
-ConditionList ConditionMgr::GetConditionReferences(uint32 refId)
-{
- ConditionList conditions;
- ConditionReferenceContainer::const_iterator ref = ConditionReferenceStore.find(refId);
- if (ref != ConditionReferenceStore.end())
- conditions = (*ref).second;
- return conditions;
-}
-
-uint32 ConditionMgr::GetSearcherTypeMaskForConditionList(ConditionList const& conditions)
+uint32 ConditionMgr::GetSearcherTypeMaskForConditionList(ConditionContainer const& conditions) const
{
if (conditions.empty())
return GRID_MAP_TYPE_MASK_ALL;
// groupId, typeMask
- std::map<uint32, uint32> ElseGroupStore;
- for (ConditionList::const_iterator i = conditions.begin(); i != conditions.end(); ++i)
+ std::map<uint32, uint32> elseGroupSearcherTypeMasks;
+ for (ConditionContainer::const_iterator i = conditions.begin(); i != conditions.end(); ++i)
{
// no point of having not loaded conditions in list
ASSERT((*i)->isLoaded() && "ConditionMgr::GetSearcherTypeMaskForConditionList - not yet loaded condition found in list");
- std::map<uint32, uint32>::const_iterator itr = ElseGroupStore.find((*i)->ElseGroup);
+ std::map<uint32, uint32>::const_iterator itr = elseGroupSearcherTypeMasks.find((*i)->ElseGroup);
// group not filled yet, fill with widest mask possible
- if (itr == ElseGroupStore.end())
- ElseGroupStore[(*i)->ElseGroup] = GRID_MAP_TYPE_MASK_ALL;
+ if (itr == elseGroupSearcherTypeMasks.end())
+ elseGroupSearcherTypeMasks[(*i)->ElseGroup] = GRID_MAP_TYPE_MASK_ALL;
// no point of checking anymore, empty mask
- else if (!(*itr).second)
+ else if (!itr->second)
continue;
if ((*i)->ReferenceId) // handle reference
{
ConditionReferenceContainer::const_iterator ref = ConditionReferenceStore.find((*i)->ReferenceId);
ASSERT(ref != ConditionReferenceStore.end() && "ConditionMgr::GetSearcherTypeMaskForConditionList - incorrect reference");
- ElseGroupStore[(*i)->ElseGroup] &= GetSearcherTypeMaskForConditionList((*ref).second);
+ elseGroupSearcherTypeMasks[(*i)->ElseGroup] &= GetSearcherTypeMaskForConditionList((*ref).second);
}
else // handle normal condition
{
// object will match conditions in one ElseGroupStore only when it matches all of them
// so, let's find a smallest possible mask which satisfies all conditions
- ElseGroupStore[(*i)->ElseGroup] &= (*i)->GetSearcherTypeMaskForCondition();
+ elseGroupSearcherTypeMasks[(*i)->ElseGroup] &= (*i)->GetSearcherTypeMaskForCondition();
}
}
// object will match condition when one of the checks in ElseGroupStore is matching
// so, let's include all possible masks
uint32 mask = 0;
- for (std::map<uint32, uint32>::const_iterator i = ElseGroupStore.begin(); i != ElseGroupStore.end(); ++i)
+ for (std::map<uint32, uint32>::const_iterator i = elseGroupSearcherTypeMasks.begin(); i != elseGroupSearcherTypeMasks.end(); ++i)
mask |= i->second;
return mask;
}
-bool ConditionMgr::IsObjectMeetToConditionList(ConditionSourceInfo& sourceInfo, ConditionList const& conditions)
+bool ConditionMgr::IsObjectMeetToConditionList(ConditionSourceInfo& sourceInfo, ConditionContainer const& conditions) const
{
// groupId, groupCheckPassed
- std::map<uint32, bool> ElseGroupStore;
- for (ConditionList::const_iterator i = conditions.begin(); i != conditions.end(); ++i)
+ std::map<uint32, bool> elseGroupStore;
+ for (Condition const* condition : conditions)
{
- TC_LOG_DEBUG("condition", "ConditionMgr::IsPlayerMeetToConditionList %s val1: %u", (*i)->ToString().c_str(), (*i)->ConditionValue1);
- if ((*i)->isLoaded())
+ TC_LOG_DEBUG("condition", "ConditionMgr::IsPlayerMeetToConditionList %s val1: %u", condition->ToString().c_str(), condition->ConditionValue1);
+ if (condition->isLoaded())
{
//! Find ElseGroup in ElseGroupStore
- std::map<uint32, bool>::const_iterator itr = ElseGroupStore.find((*i)->ElseGroup);
+ std::map<uint32, bool>::const_iterator itr = elseGroupStore.find(condition->ElseGroup);
//! If not found, add an entry in the store and set to true (placeholder)
- if (itr == ElseGroupStore.end())
- ElseGroupStore[(*i)->ElseGroup] = true;
+ if (itr == elseGroupStore.end())
+ elseGroupStore[condition->ElseGroup] = true;
else if (!(*itr).second)
continue;
- if ((*i)->ReferenceId)//handle reference
+ if (condition->ReferenceId)//handle reference
{
- ConditionReferenceContainer::const_iterator ref = ConditionReferenceStore.find((*i)->ReferenceId);
+ ConditionReferenceContainer::const_iterator ref = ConditionReferenceStore.find(condition->ReferenceId);
if (ref != ConditionReferenceStore.end())
{
- if (!IsObjectMeetToConditionList(sourceInfo, (*ref).second))
- ElseGroupStore[(*i)->ElseGroup] = false;
+ if (!IsObjectMeetToConditionList(sourceInfo, ref->second))
+ elseGroupStore[condition->ElseGroup] = false;
}
else
{
TC_LOG_DEBUG("condition", "ConditionMgr::IsPlayerMeetToConditionList %s Reference template -%u not found",
- (*i)->ToString().c_str(), (*i)->ReferenceId); // checked at loading, should never happen
+ condition->ToString().c_str(), condition->ReferenceId); // checked at loading, should never happen
}
}
else //handle normal condition
{
- if (!(*i)->Meets(sourceInfo))
- ElseGroupStore[(*i)->ElseGroup] = false;
+ if (!condition->Meets(sourceInfo))
+ elseGroupStore[condition->ElseGroup] = false;
}
}
}
- for (std::map<uint32, bool>::const_iterator i = ElseGroupStore.begin(); i != ElseGroupStore.end(); ++i)
+ for (std::map<uint32, bool>::const_iterator i = elseGroupStore.begin(); i != elseGroupStore.end(); ++i)
if (i->second)
return true;
return false;
}
-bool ConditionMgr::IsObjectMeetToConditions(WorldObject* object, ConditionList const& conditions)
+bool ConditionMgr::IsObjectMeetToConditions(WorldObject* object, ConditionContainer const& conditions) const
{
ConditionSourceInfo srcInfo = ConditionSourceInfo(object);
return IsObjectMeetToConditions(srcInfo, conditions);
}
-bool ConditionMgr::IsObjectMeetToConditions(WorldObject* object1, WorldObject* object2, ConditionList const& conditions)
+bool ConditionMgr::IsObjectMeetToConditions(WorldObject* object1, WorldObject* object2, ConditionContainer const& conditions) const
{
ConditionSourceInfo srcInfo = ConditionSourceInfo(object1, object2);
return IsObjectMeetToConditions(srcInfo, conditions);
}
-bool ConditionMgr::IsObjectMeetToConditions(ConditionSourceInfo& sourceInfo, ConditionList const& conditions)
+bool ConditionMgr::IsObjectMeetToConditions(ConditionSourceInfo& sourceInfo, ConditionContainer const& conditions) const
{
if (conditions.empty())
return true;
@@ -807,87 +800,113 @@ bool ConditionMgr::CanHaveSourceIdSet(ConditionSourceType sourceType)
return (sourceType == CONDITION_SOURCE_TYPE_SMART_EVENT);
}
-ConditionList ConditionMgr::GetConditionsForNotGroupedEntry(ConditionSourceType sourceType, uint32 entry)
+bool ConditionMgr::IsObjectMeetingNotGroupedConditions(ConditionSourceType sourceType, uint32 entry, ConditionSourceInfo& sourceInfo) const
{
- ConditionList spellCond;
if (sourceType > CONDITION_SOURCE_TYPE_NONE && sourceType < CONDITION_SOURCE_TYPE_MAX)
{
- ConditionContainer::const_iterator itr = ConditionStore.find(sourceType);
- if (itr != ConditionStore.end())
+ ConditionsByEntryMap::const_iterator i = ConditionStore[sourceType].find(entry);
+ if (i != ConditionStore[sourceType].end())
{
- ConditionTypeContainer::const_iterator i = (*itr).second.find(entry);
- if (i != (*itr).second.end())
- {
- spellCond = (*i).second;
- TC_LOG_DEBUG("condition", "GetConditionsForNotGroupedEntry: found conditions for type %u and entry %u", uint32(sourceType), entry);
- }
+ TC_LOG_DEBUG("condition", "GetConditionsForNotGroupedEntry: found conditions for type %u and entry %u", uint32(sourceType), entry);
+ return IsObjectMeetToConditions(sourceInfo, i->second);
}
}
- return spellCond;
+
+ return true;
}
-ConditionList ConditionMgr::GetConditionsForSpellClickEvent(uint32 creatureId, uint32 spellId)
+bool ConditionMgr::IsObjectMeetingNotGroupedConditions(ConditionSourceType sourceType, uint32 entry, WorldObject* target0, WorldObject* target1 /*= nullptr*/, WorldObject* target2 /*= nullptr*/) const
{
- ConditionList cond;
- CreatureSpellConditionContainer::const_iterator itr = SpellClickEventConditionStore.find(creatureId);
+ ConditionSourceInfo conditionSource(target0, target1, target2);
+ return IsObjectMeetingNotGroupedConditions(sourceType, entry, conditionSource);
+}
+
+bool ConditionMgr::HasConditionsForNotGroupedEntry(ConditionSourceType sourceType, uint32 entry) const
+{
+ if (sourceType > CONDITION_SOURCE_TYPE_NONE && sourceType < CONDITION_SOURCE_TYPE_MAX)
+ if (ConditionStore[sourceType].find(entry) != ConditionStore[sourceType].end())
+ return true;
+
+ return false;
+}
+
+bool ConditionMgr::IsObjectMeetingSpellClickConditions(uint32 creatureId, uint32 spellId, WorldObject* clicker, WorldObject* target) const
+{
+ ConditionEntriesByCreatureIdMap::const_iterator itr = SpellClickEventConditionStore.find(creatureId);
if (itr != SpellClickEventConditionStore.end())
{
- ConditionTypeContainer::const_iterator i = (*itr).second.find(spellId);
- if (i != (*itr).second.end())
+ ConditionsByEntryMap::const_iterator i = itr->second.find(spellId);
+ if (i != itr->second.end())
+ {
+ TC_LOG_DEBUG("condition", "GetConditionsForSpellClickEvent: found conditions for SpellClickEvent entry %u spell %u", creatureId, spellId);
+ ConditionSourceInfo sourceInfo(clicker, target);
+ return IsObjectMeetToConditions(sourceInfo, i->second);
+ }
+ }
+ return true;
+}
+
+ConditionContainer const* ConditionMgr::GetConditionsForSpellClickEvent(uint32 creatureId, uint32 spellId) const
+{
+ ConditionEntriesByCreatureIdMap::const_iterator itr = SpellClickEventConditionStore.find(creatureId);
+ if (itr != SpellClickEventConditionStore.end())
+ {
+ ConditionsByEntryMap::const_iterator i = itr->second.find(spellId);
+ if (i != itr->second.end())
{
- cond = (*i).second;
TC_LOG_DEBUG("condition", "GetConditionsForSpellClickEvent: found conditions for SpellClickEvent entry %u spell %u", creatureId, spellId);
+ return &i->second;
}
}
- return cond;
+ return nullptr;
}
-ConditionList ConditionMgr::GetConditionsForVehicleSpell(uint32 creatureId, uint32 spellId)
+bool ConditionMgr::IsObjectMeetingVehicleSpellConditions(uint32 creatureId, uint32 spellId, Player* player, Unit* vehicle) const
{
- ConditionList cond;
- CreatureSpellConditionContainer::const_iterator itr = VehicleSpellConditionStore.find(creatureId);
+ ConditionEntriesByCreatureIdMap::const_iterator itr = VehicleSpellConditionStore.find(creatureId);
if (itr != VehicleSpellConditionStore.end())
{
- ConditionTypeContainer::const_iterator i = (*itr).second.find(spellId);
- if (i != (*itr).second.end())
+ ConditionsByEntryMap::const_iterator i = itr->second.find(spellId);
+ if (i != itr->second.end())
{
- cond = (*i).second;
TC_LOG_DEBUG("condition", "GetConditionsForVehicleSpell: found conditions for Vehicle entry %u spell %u", creatureId, spellId);
+ ConditionSourceInfo sourceInfo(player, vehicle);
+ return IsObjectMeetToConditions(sourceInfo, i->second);
}
}
- return cond;
+ return true;
}
-ConditionList ConditionMgr::GetConditionsForSmartEvent(int32 entryOrGuid, uint32 eventId, uint32 sourceType)
+bool ConditionMgr::IsObjectMeetingSmartEventConditions(int32 entryOrGuid, uint32 eventId, uint32 sourceType, Unit* unit, WorldObject* baseObject) const
{
- ConditionList cond;
SmartEventConditionContainer::const_iterator itr = SmartEventConditionStore.find(std::make_pair(entryOrGuid, sourceType));
if (itr != SmartEventConditionStore.end())
{
- ConditionTypeContainer::const_iterator i = (*itr).second.find(eventId + 1);
- if (i != (*itr).second.end())
+ ConditionsByEntryMap::const_iterator i = itr->second.find(eventId + 1);
+ if (i != itr->second.end())
{
- cond = (*i).second;
TC_LOG_DEBUG("condition", "GetConditionsForSmartEvent: found conditions for Smart Event entry or guid %d eventId %u", entryOrGuid, eventId);
+ ConditionSourceInfo sourceInfo(unit, baseObject);
+ return IsObjectMeetToConditions(sourceInfo, i->second);
}
}
- return cond;
+ return true;
}
-ConditionList ConditionMgr::GetConditionsForNpcVendorEvent(uint32 creatureId, uint32 itemId)
+bool ConditionMgr::IsObjectMeetingVendorItemConditions(uint32 creatureId, uint32 itemId, Player* player, Creature* vendor) const
{
- ConditionList cond;
- NpcVendorConditionContainer::const_iterator itr = NpcVendorConditionContainerStore.find(creatureId);
+ ConditionEntriesByCreatureIdMap::const_iterator itr = NpcVendorConditionContainerStore.find(creatureId);
if (itr != NpcVendorConditionContainerStore.end())
{
- ConditionTypeContainer::const_iterator i = (*itr).second.find(itemId);
+ ConditionsByEntryMap::const_iterator i = (*itr).second.find(itemId);
if (i != (*itr).second.end())
{
- cond = (*i).second;
TC_LOG_DEBUG("condition", "GetConditionsForNpcVendorEvent: found conditions for creature entry %u item %u", creatureId, itemId);
+ ConditionSourceInfo sourceInfo(player, vendor);
+ return IsObjectMeetToConditions(sourceInfo, i->second);
}
}
- return cond;
+ return true;
}
void ConditionMgr::LoadConditions(bool isReload)
@@ -950,7 +969,7 @@ void ConditionMgr::LoadConditions(bool isReload)
cond->NegativeCondition = fields[10].GetBool();
cond->ErrorType = fields[11].GetUInt32();
cond->ErrorTextId = fields[12].GetUInt32();
- cond->ScriptId = sObjectMgr->GetScriptId(fields[13].GetCString());
+ cond->ScriptId = sObjectMgr->GetScriptId(fields[13].GetString());
if (iConditionTypeOrReference >= 0)
cond->ConditionType = ConditionTypes(iConditionTypeOrReference);
@@ -995,14 +1014,8 @@ void ConditionMgr::LoadConditions(bool isReload)
if (iSourceTypeOrReferenceId < 0)//it is a reference template
{
- uint32 uRefId = abs(iSourceTypeOrReferenceId);
- if (ConditionReferenceStore.find(uRefId) == ConditionReferenceStore.end())//make sure we have a list for our conditions, based on reference id
- {
- ConditionList mCondList;
- ConditionReferenceStore[uRefId] = mCondList;
- }
- ConditionReferenceStore[uRefId].push_back(cond);//add to reference storage
- count++;
+ ConditionReferenceStore[std::abs(iSourceTypeOrReferenceId)].push_back(cond);//add to reference storage
+ ++count;
continue;
}//end of reference templates
@@ -1138,20 +1151,6 @@ void ConditionMgr::LoadConditions(bool isReload)
}
//handle not grouped conditions
- //make sure we have a storage list for our SourceType
- if (ConditionStore.find(cond->SourceType) == ConditionStore.end())
- {
- ConditionTypeContainer mTypeMap;
- ConditionStore[cond->SourceType] = mTypeMap;//add new empty list for SourceType
- }
-
- //make sure we have a condition list for our SourceType's entry
- if (ConditionStore[cond->SourceType].find(cond->SourceEntry) == ConditionStore[cond->SourceType].end())
- {
- ConditionList mCondList;
- ConditionStore[cond->SourceType][cond->SourceEntry] = mCondList;
- }
-
//add new Condition to storage based on Type/Entry
ConditionStore[cond->SourceType][cond->SourceEntry].push_back(cond);
++count;
@@ -1161,7 +1160,7 @@ void ConditionMgr::LoadConditions(bool isReload)
TC_LOG_INFO("server.loading", ">> Loaded %u conditions in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
}
-bool ConditionMgr::addToLootTemplate(Condition* cond, LootTemplate* loot)
+bool ConditionMgr::addToLootTemplate(Condition* cond, LootTemplate* loot) const
{
if (!loot)
{
@@ -1176,7 +1175,7 @@ bool ConditionMgr::addToLootTemplate(Condition* cond, LootTemplate* loot)
return false;
}
-bool ConditionMgr::addToGossipMenus(Condition* cond)
+bool ConditionMgr::addToGossipMenus(Condition* cond) const
{
GossipMenusMapBoundsNonConst pMenuBounds = sObjectMgr->GetGossipMenusMapBoundsNonConst(cond->SourceGroup);
@@ -1196,7 +1195,7 @@ bool ConditionMgr::addToGossipMenus(Condition* cond)
return false;
}
-bool ConditionMgr::addToGossipMenuItems(Condition* cond)
+bool ConditionMgr::addToGossipMenuItems(Condition* cond) const
{
GossipMenuItemsMapBoundsNonConst pMenuItemBounds = sObjectMgr->GetGossipMenuItemsMapBoundsNonConst(cond->SourceGroup);
if (pMenuItemBounds.first != pMenuItemBounds.second)
@@ -1215,7 +1214,7 @@ bool ConditionMgr::addToGossipMenuItems(Condition* cond)
return false;
}
-bool ConditionMgr::addToSpellImplicitTargetConditions(Condition* cond)
+bool ConditionMgr::addToSpellImplicitTargetConditions(Condition* cond) const
{
uint32 conditionEffMask = cond->SourceGroup;
SpellInfo* spellInfo = const_cast<SpellInfo*>(sSpellMgr->EnsureSpellInfo(cond->SourceEntry));
@@ -1236,9 +1235,9 @@ bool ConditionMgr::addToSpellImplicitTargetConditions(Condition* cond)
continue;
// build new shared mask with found effect
- uint32 sharedMask = (1 << i);
- ConditionList* cmp = spellInfo->Effects[i].ImplicitTargetConditions;
- for (uint8 effIndex = i+1; effIndex < MAX_SPELL_EFFECTS; ++effIndex)
+ uint32 sharedMask = 1 << i;
+ ConditionContainer* cmp = spellInfo->Effects[i].ImplicitTargetConditions;
+ for (uint8 effIndex = i + 1; effIndex < MAX_SPELL_EFFECTS; ++effIndex)
{
if (spellInfo->Effects[effIndex].ImplicitTargetConditions == cmp)
sharedMask |= 1 << effIndex;
@@ -1260,7 +1259,7 @@ bool ConditionMgr::addToSpellImplicitTargetConditions(Condition* cond)
return false;
// get shared data
- ConditionList* sharedList = spellInfo->Effects[firstEffIndex].ImplicitTargetConditions;
+ ConditionContainer* sharedList = spellInfo->Effects[firstEffIndex].ImplicitTargetConditions;
// there's already data entry for that sharedMask
if (sharedList)
@@ -1277,7 +1276,7 @@ bool ConditionMgr::addToSpellImplicitTargetConditions(Condition* cond)
else
{
// add new list, create new shared mask
- sharedList = new ConditionList();
+ sharedList = new ConditionContainer();
bool assigned = false;
for (uint8 i = firstEffIndex; i < MAX_SPELL_EFFECTS; ++i)
{
@@ -1298,7 +1297,7 @@ bool ConditionMgr::addToSpellImplicitTargetConditions(Condition* cond)
return true;
}
-bool ConditionMgr::isSourceTypeValid(Condition* cond)
+bool ConditionMgr::isSourceTypeValid(Condition* cond) const
{
if (cond->SourceType == CONDITION_SOURCE_TYPE_NONE || cond->SourceType >= CONDITION_SOURCE_TYPE_MAX)
{
@@ -1650,7 +1649,7 @@ bool ConditionMgr::isSourceTypeValid(Condition* cond)
return true;
}
-bool ConditionMgr::isConditionTypeValid(Condition* cond)
+bool ConditionMgr::isConditionTypeValid(Condition* cond) const
{
if (cond->ConditionType == CONDITION_NONE || cond->ConditionType >= CONDITION_MAX)
{
@@ -2113,81 +2112,50 @@ void ConditionMgr::LogUselessConditionValue(Condition* cond, uint8 index, uint32
void ConditionMgr::Clean()
{
for (ConditionReferenceContainer::iterator itr = ConditionReferenceStore.begin(); itr != ConditionReferenceStore.end(); ++itr)
- {
- for (ConditionList::const_iterator it = itr->second.begin(); it != itr->second.end(); ++it)
+ for (ConditionContainer::const_iterator it = itr->second.begin(); it != itr->second.end(); ++it)
delete *it;
- itr->second.clear();
- }
ConditionReferenceStore.clear();
- for (ConditionContainer::iterator itr = ConditionStore.begin(); itr != ConditionStore.end(); ++itr)
+ for (uint32 i = 0; i < CONDITION_SOURCE_TYPE_MAX; ++i)
{
- for (ConditionTypeContainer::iterator it = itr->second.begin(); it != itr->second.end(); ++it)
- {
- for (ConditionList::const_iterator i = it->second.begin(); i != it->second.end(); ++i)
- delete *i;
- it->second.clear();
- }
- itr->second.clear();
- }
+ for (ConditionsByEntryMap::iterator it = ConditionStore[i].begin(); it != ConditionStore[i].end(); ++it)
+ for (ConditionContainer::const_iterator itr = it->second.begin(); itr != it->second.end(); ++itr)
+ delete *itr;
- ConditionStore.clear();
+ ConditionStore[i].clear();
+ }
- for (CreatureSpellConditionContainer::iterator itr = VehicleSpellConditionStore.begin(); itr != VehicleSpellConditionStore.end(); ++itr)
- {
- for (ConditionTypeContainer::iterator it = itr->second.begin(); it != itr->second.end(); ++it)
- {
- for (ConditionList::const_iterator i = it->second.begin(); i != it->second.end(); ++i)
+ for (ConditionEntriesByCreatureIdMap::iterator itr = VehicleSpellConditionStore.begin(); itr != VehicleSpellConditionStore.end(); ++itr)
+ for (ConditionsByEntryMap::iterator it = itr->second.begin(); it != itr->second.end(); ++it)
+ for (ConditionContainer::const_iterator i = it->second.begin(); i != it->second.end(); ++i)
delete *i;
- it->second.clear();
- }
- itr->second.clear();
- }
VehicleSpellConditionStore.clear();
for (SmartEventConditionContainer::iterator itr = SmartEventConditionStore.begin(); itr != SmartEventConditionStore.end(); ++itr)
- {
- for (ConditionTypeContainer::iterator it = itr->second.begin(); it != itr->second.end(); ++it)
- {
- for (ConditionList::const_iterator i = it->second.begin(); i != it->second.end(); ++i)
+ for (ConditionsByEntryMap::iterator it = itr->second.begin(); it != itr->second.end(); ++it)
+ for (ConditionContainer::const_iterator i = it->second.begin(); i != it->second.end(); ++i)
delete *i;
- it->second.clear();
- }
- itr->second.clear();
- }
SmartEventConditionStore.clear();
- for (CreatureSpellConditionContainer::iterator itr = SpellClickEventConditionStore.begin(); itr != SpellClickEventConditionStore.end(); ++itr)
- {
- for (ConditionTypeContainer::iterator it = itr->second.begin(); it != itr->second.end(); ++it)
- {
- for (ConditionList::const_iterator i = it->second.begin(); i != it->second.end(); ++i)
+ for (ConditionEntriesByCreatureIdMap::iterator itr = SpellClickEventConditionStore.begin(); itr != SpellClickEventConditionStore.end(); ++itr)
+ for (ConditionsByEntryMap::iterator it = itr->second.begin(); it != itr->second.end(); ++it)
+ for (ConditionContainer::const_iterator i = it->second.begin(); i != it->second.end(); ++i)
delete *i;
- it->second.clear();
- }
- itr->second.clear();
- }
SpellClickEventConditionStore.clear();
- for (NpcVendorConditionContainer::iterator itr = NpcVendorConditionContainerStore.begin(); itr != NpcVendorConditionContainerStore.end(); ++itr)
- {
- for (ConditionTypeContainer::iterator it = itr->second.begin(); it != itr->second.end(); ++it)
- {
- for (ConditionList::const_iterator i = it->second.begin(); i != it->second.end(); ++i)
+ for (ConditionEntriesByCreatureIdMap::iterator itr = NpcVendorConditionContainerStore.begin(); itr != NpcVendorConditionContainerStore.end(); ++itr)
+ for (ConditionsByEntryMap::iterator it = itr->second.begin(); it != itr->second.end(); ++it)
+ for (ConditionContainer::const_iterator i = it->second.begin(); i != it->second.end(); ++i)
delete *i;
- it->second.clear();
- }
- itr->second.clear();
- }
NpcVendorConditionContainerStore.clear();
// this is a BIG hack, feel free to fix it if you can figure out the ConditionMgr ;)
- for (std::list<Condition*>::const_iterator itr = AllocatedMemoryStore.begin(); itr != AllocatedMemoryStore.end(); ++itr)
+ for (std::vector<Condition*>::const_iterator itr = AllocatedMemoryStore.begin(); itr != AllocatedMemoryStore.end(); ++itr)
delete *itr;
AllocatedMemoryStore.clear();
diff --git a/src/server/game/Conditions/ConditionMgr.h b/src/server/game/Conditions/ConditionMgr.h
index 27983782bdc..81fe379f0db 100644
--- a/src/server/game/Conditions/ConditionMgr.h
+++ b/src/server/game/Conditions/ConditionMgr.h
@@ -19,12 +19,9 @@
#ifndef TRINITY_CONDITIONMGR_H
#define TRINITY_CONDITIONMGR_H
-#include "Define.h"
-#include "Errors.h"
-#include <list>
-#include <map>
-#include <string>
+#include "Common.h"
+class Creature;
class Player;
class Unit;
class WorldObject;
@@ -162,13 +159,13 @@ enum MaxConditionTargets
struct ConditionSourceInfo
{
WorldObject* mConditionTargets[MAX_CONDITION_TARGETS]; // an array of targets available for conditions
- Condition* mLastFailedCondition;
- ConditionSourceInfo(WorldObject* target0, WorldObject* target1 = NULL, WorldObject* target2 = NULL)
+ Condition const* mLastFailedCondition;
+ ConditionSourceInfo(WorldObject* target0, WorldObject* target1 = nullptr, WorldObject* target2 = nullptr)
{
mConditionTargets[0] = target0;
mConditionTargets[1] = target1;
mConditionTargets[2] = target2;
- mLastFailedCondition = NULL;
+ mLastFailedCondition = nullptr;
}
};
@@ -209,22 +206,20 @@ struct Condition
NegativeCondition = false;
}
- bool Meets(ConditionSourceInfo& sourceInfo);
- uint32 GetSearcherTypeMaskForCondition();
+ bool Meets(ConditionSourceInfo& sourceInfo) const;
+ uint32 GetSearcherTypeMaskForCondition() const;
bool isLoaded() const { return ConditionType > CONDITION_NONE || ReferenceId; }
- uint32 GetMaxAvailableConditionTargets();
+ uint32 GetMaxAvailableConditionTargets() const;
std::string ToString(bool ext = false) const; /// For logging purpose
};
-typedef std::list<Condition*> ConditionList;
-typedef std::map<uint32, ConditionList> ConditionTypeContainer;
-typedef std::map<ConditionSourceType, ConditionTypeContainer> ConditionContainer;
-typedef std::map<uint32, ConditionTypeContainer> CreatureSpellConditionContainer;
-typedef std::map<uint32, ConditionTypeContainer> NpcVendorConditionContainer;
-typedef std::map<std::pair<int32, uint32 /*SAI source_type*/>, ConditionTypeContainer> SmartEventConditionContainer;
-
-typedef std::map<uint32, ConditionList> ConditionReferenceContainer;//only used for references
+typedef std::vector<Condition*> ConditionContainer;
+typedef std::unordered_map<uint32 /*SourceEntry*/, ConditionContainer> ConditionsByEntryMap;
+typedef std::array<ConditionsByEntryMap, CONDITION_SOURCE_TYPE_MAX> ConditionEntriesByTypeArray;
+typedef std::unordered_map<uint32, ConditionsByEntryMap> ConditionEntriesByCreatureIdMap;
+typedef std::unordered_map<std::pair<int32, uint32 /*SAI source_type*/>, ConditionsByEntryMap> SmartEventConditionContainer;
+typedef std::unordered_map<uint32, ConditionContainer> ConditionReferenceContainer;//only used for references
class ConditionMgr
{
@@ -240,20 +235,22 @@ class ConditionMgr
}
void LoadConditions(bool isReload = false);
- bool isConditionTypeValid(Condition* cond);
- ConditionList GetConditionReferences(uint32 refId);
+ bool isConditionTypeValid(Condition* cond) const;
- uint32 GetSearcherTypeMaskForConditionList(ConditionList const& conditions);
- bool IsObjectMeetToConditions(WorldObject* object, ConditionList const& conditions);
- bool IsObjectMeetToConditions(WorldObject* object1, WorldObject* object2, ConditionList const& conditions);
- bool IsObjectMeetToConditions(ConditionSourceInfo& sourceInfo, ConditionList const& conditions);
+ uint32 GetSearcherTypeMaskForConditionList(ConditionContainer const& conditions) const;
+ bool IsObjectMeetToConditions(WorldObject* object, ConditionContainer const& conditions) const;
+ bool IsObjectMeetToConditions(WorldObject* object1, WorldObject* object2, ConditionContainer const& conditions) const;
+ bool IsObjectMeetToConditions(ConditionSourceInfo& sourceInfo, ConditionContainer const& conditions) const;
static bool CanHaveSourceGroupSet(ConditionSourceType sourceType);
static bool CanHaveSourceIdSet(ConditionSourceType sourceType);
- ConditionList GetConditionsForNotGroupedEntry(ConditionSourceType sourceType, uint32 entry);
- ConditionList GetConditionsForSpellClickEvent(uint32 creatureId, uint32 spellId);
- ConditionList GetConditionsForSmartEvent(int32 entryOrGuid, uint32 eventId, uint32 sourceType);
- ConditionList GetConditionsForVehicleSpell(uint32 creatureId, uint32 spellId);
- ConditionList GetConditionsForNpcVendorEvent(uint32 creatureId, uint32 itemId);
+ bool IsObjectMeetingNotGroupedConditions(ConditionSourceType sourceType, uint32 entry, ConditionSourceInfo& sourceInfo) const;
+ bool IsObjectMeetingNotGroupedConditions(ConditionSourceType sourceType, uint32 entry, WorldObject* target0, WorldObject* target1 = nullptr, WorldObject* target2 = nullptr) const;
+ bool HasConditionsForNotGroupedEntry(ConditionSourceType sourceType, uint32 entry) const;
+ bool IsObjectMeetingSpellClickConditions(uint32 creatureId, uint32 spellId, WorldObject* clicker, WorldObject* target) const;
+ ConditionContainer const* GetConditionsForSpellClickEvent(uint32 creatureId, uint32 spellId) const;
+ bool IsObjectMeetingVehicleSpellConditions(uint32 creatureId, uint32 spellId, Player* player, Unit* vehicle) const;
+ bool IsObjectMeetingSmartEventConditions(int32 entryOrGuid, uint32 eventId, uint32 sourceType, Unit* unit, WorldObject* baseObject) const;
+ bool IsObjectMeetingVendorItemConditions(uint32 creatureId, uint32 itemId, Player* player, Creature* vendor) const;
struct ConditionTypeInfo
{
@@ -262,28 +259,28 @@ class ConditionMgr
bool HasConditionValue2;
bool HasConditionValue3;
};
- static char const* StaticSourceTypeData[CONDITION_SOURCE_TYPE_MAX];
+ static char const* const StaticSourceTypeData[CONDITION_SOURCE_TYPE_MAX];
static ConditionTypeInfo const StaticConditionTypeData[CONDITION_MAX];
private:
- bool isSourceTypeValid(Condition* cond);
- bool addToLootTemplate(Condition* cond, LootTemplate* loot);
- bool addToGossipMenus(Condition* cond);
- bool addToGossipMenuItems(Condition* cond);
- bool addToSpellImplicitTargetConditions(Condition* cond);
- bool IsObjectMeetToConditionList(ConditionSourceInfo& sourceInfo, ConditionList const& conditions);
+ bool isSourceTypeValid(Condition* cond) const;
+ bool addToLootTemplate(Condition* cond, LootTemplate* loot) const;
+ bool addToGossipMenus(Condition* cond) const;
+ bool addToGossipMenuItems(Condition* cond) const;
+ bool addToSpellImplicitTargetConditions(Condition* cond) const;
+ bool IsObjectMeetToConditionList(ConditionSourceInfo& sourceInfo, ConditionContainer const& conditions) const;
static void LogUselessConditionValue(Condition* cond, uint8 index, uint32 value);
void Clean(); // free up resources
- std::list<Condition*> AllocatedMemoryStore; // some garbage collection :)
-
- ConditionContainer ConditionStore;
- ConditionReferenceContainer ConditionReferenceStore;
- CreatureSpellConditionContainer VehicleSpellConditionStore;
- CreatureSpellConditionContainer SpellClickEventConditionStore;
- NpcVendorConditionContainer NpcVendorConditionContainerStore;
- SmartEventConditionContainer SmartEventConditionStore;
+ std::vector<Condition*> AllocatedMemoryStore; // some garbage collection :)
+
+ ConditionEntriesByTypeArray ConditionStore;
+ ConditionReferenceContainer ConditionReferenceStore;
+ ConditionEntriesByCreatureIdMap VehicleSpellConditionStore;
+ ConditionEntriesByCreatureIdMap SpellClickEventConditionStore;
+ ConditionEntriesByCreatureIdMap NpcVendorConditionContainerStore;
+ SmartEventConditionContainer SmartEventConditionStore;
};
#define sConditionMgr ConditionMgr::instance()
diff --git a/src/server/game/DataStores/DBCStores.cpp b/src/server/game/DataStores/DBCStores.cpp
index e268b376b34..806d9d46763 100644
--- a/src/server/game/DataStores/DBCStores.cpp
+++ b/src/server/game/DataStores/DBCStores.cpp
@@ -25,6 +25,7 @@
#include "Timer.h"
#include "ObjectDefines.h"
+#include <boost/regex.hpp>
#include <map>
typedef std::map<uint16, uint32> AreaFlagByAreaID;
@@ -140,6 +141,12 @@ MapDifficultyMap sMapDifficultyMap;
DBCStorage <MovieEntry> sMovieStore(MovieEntryfmt);
+DBCStorage<NamesProfanityEntry> sNamesProfanityStore(NamesProfanityEntryfmt);
+DBCStorage<NamesReservedEntry> sNamesReservedStore(NamesReservedEntryfmt);
+typedef std::array<std::vector<boost::regex>, TOTAL_LOCALES> NameValidationRegexContainer;
+NameValidationRegexContainer NamesProfaneValidators;
+NameValidationRegexContainer NamesReservedValidators;
+
DBCStorage <OverrideSpellDataEntry> sOverrideSpellDataStore(OverrideSpellDatafmt);
DBCStorage <PowerDisplayEntry> sPowerDisplayStore(PowerDisplayfmt);
@@ -163,7 +170,6 @@ DBCStorage <SoundEntriesEntry> sSoundEntriesStore(SoundEntriesfmt);
DBCStorage <SpellItemEnchantmentEntry> sSpellItemEnchantmentStore(SpellItemEnchantmentfmt);
DBCStorage <SpellItemEnchantmentConditionEntry> sSpellItemEnchantmentConditionStore(SpellItemEnchantmentConditionfmt);
DBCStorage <SpellEntry> sSpellStore(SpellEntryfmt);
-SpellCategoryStore sSpellsByCategoryStore;
PetFamilySpellsStore sPetFamilySpellsStore;
DBCStorage <SpellCastTimesEntry> sSpellCastTimesStore(SpellCastTimefmt);
@@ -402,6 +408,37 @@ void LoadDBCStores(const std::string& dataPath)
LoadDBC(availableDbcLocales, bad_dbc_files, sMovieStore, dbcPath, "Movie.dbc");
+ LoadDBC(availableDbcLocales, bad_dbc_files, sNamesProfanityStore, dbcPath, "NamesProfanity.dbc");
+ LoadDBC(availableDbcLocales, bad_dbc_files, sNamesReservedStore, dbcPath, "NamesReserved.dbc");
+ for (uint32 i = 0; i < sNamesProfanityStore.GetNumRows(); ++i)
+ {
+ NamesProfanityEntry const* namesProfanity = sNamesProfanityStore.LookupEntry(i);
+ if (!namesProfanity)
+ continue;
+
+ ASSERT(namesProfanity->Language < TOTAL_LOCALES || namesProfanity->Language == -1);
+ if (namesProfanity->Language != -1)
+ NamesProfaneValidators[namesProfanity->Language].emplace_back(namesProfanity->Name, boost::regex::perl | boost::regex::icase | boost::regex::optimize);
+ else
+ for (uint32 i = 0; i < TOTAL_LOCALES; ++i)
+ NamesProfaneValidators[i].emplace_back(namesProfanity->Name, boost::regex::perl | boost::regex::icase | boost::regex::optimize);
+ }
+
+ for (uint32 i = 0; i < sNamesReservedStore.GetNumRows(); ++i)
+ {
+ NamesReservedEntry const* namesReserved = sNamesReservedStore.LookupEntry(i);
+ if (!namesReserved)
+ continue;
+
+ ASSERT(namesReserved->Language < TOTAL_LOCALES || namesReserved->Language == -1);
+ if (namesReserved->Language != -1)
+ NamesReservedValidators[namesReserved->Language].emplace_back(namesReserved->Name, boost::regex::perl | boost::regex::icase | boost::regex::optimize);
+ else
+ for (uint32 i = 0; i < TOTAL_LOCALES; ++i)
+ NamesReservedValidators[i].emplace_back(namesReserved->Name, boost::regex::perl | boost::regex::icase | boost::regex::optimize);
+ }
+
+
LoadDBC(availableDbcLocales, bad_dbc_files, sOverrideSpellDataStore, dbcPath, "OverrideSpellData.dbc");
LoadDBC(availableDbcLocales, bad_dbc_files, sPowerDisplayStore, dbcPath, "PowerDisplay.dbc");
@@ -430,12 +467,6 @@ void LoadDBCStores(const std::string& dataPath)
LoadDBC(availableDbcLocales, bad_dbc_files, sSkillTiersStore, dbcPath, "SkillTiers.dbc");
LoadDBC(availableDbcLocales, bad_dbc_files, sSoundEntriesStore, dbcPath, "SoundEntries.dbc");
LoadDBC(availableDbcLocales, bad_dbc_files, sSpellStore, dbcPath, "Spell.dbc", &CustomSpellEntryfmt, &CustomSpellEntryIndex);
- for (uint32 i = 1; i < sSpellStore.GetNumRows(); ++i)
- {
- SpellEntry const* spell = sSpellStore.LookupEntry(i);
- if (spell && spell->Category)
- sSpellsByCategoryStore[spell->Category].insert(i);
- }
for (uint32 j = 0; j < sSkillLineAbilityStore.GetNumRows(); ++j)
{
@@ -1012,3 +1043,20 @@ SkillRaceClassInfoEntry const* GetSkillRaceClassInfo(uint32 skill, uint8 race, u
return NULL;
}
+
+ResponseCodes ValidateName(std::string const& name, LocaleConstant locale)
+{
+ if (locale >= TOTAL_LOCALES)
+ return RESPONSE_FAILURE;
+
+ for (boost::regex const& regex : NamesProfaneValidators[locale])
+ if (boost::regex_search(name, regex))
+ return CHAR_NAME_PROFANE;
+
+ // regexes at TOTAL_LOCALES are loaded from NamesReserved which is not locale specific
+ for (boost::regex const& regex : NamesReservedValidators[locale])
+ if (boost::regex_search(name, regex))
+ return CHAR_NAME_RESERVED;
+
+ return CHAR_NAME_SUCCESS;
+}
diff --git a/src/server/game/DataStores/DBCStores.h b/src/server/game/DataStores/DBCStores.h
index d955e9581ab..2def7901244 100644
--- a/src/server/game/DataStores/DBCStores.h
+++ b/src/server/game/DataStores/DBCStores.h
@@ -22,6 +22,7 @@
#include "Common.h"
#include "DBCStore.h"
#include "DBCStructure.h"
+#include "SharedDefines.h"
#include <list>
@@ -79,6 +80,8 @@ typedef std::unordered_multimap<uint32, SkillRaceClassInfoEntry const*> SkillRac
typedef std::pair<SkillRaceClassInfoMap::iterator, SkillRaceClassInfoMap::iterator> SkillRaceClassInfoBounds;
SkillRaceClassInfoEntry const* GetSkillRaceClassInfo(uint32 skill, uint8 race, uint8 class_);
+ResponseCodes ValidateName(std::string const& name, LocaleConstant locale);
+
extern DBCStorage <AchievementEntry> sAchievementStore;
extern DBCStorage <AchievementCriteriaEntry> sAchievementCriteriaStore;
extern DBCStorage <AreaTableEntry> sAreaStore;// recommend access using functions
@@ -165,7 +168,6 @@ extern DBCStorage <SpellDurationEntry> sSpellDurationStore;
extern DBCStorage <SpellFocusObjectEntry> sSpellFocusObjectStore;
extern DBCStorage <SpellItemEnchantmentEntry> sSpellItemEnchantmentStore;
extern DBCStorage <SpellItemEnchantmentConditionEntry> sSpellItemEnchantmentConditionStore;
-extern SpellCategoryStore sSpellsByCategoryStore;
extern PetFamilySpellsStore sPetFamilySpellsStore;
extern DBCStorage <SpellRadiusEntry> sSpellRadiusStore;
extern DBCStorage <SpellRangeEntry> sSpellRangeStore;
diff --git a/src/server/game/DataStores/DBCStructure.h b/src/server/game/DataStores/DBCStructure.h
index 092ef714145..dc4ad55d9c2 100644
--- a/src/server/game/DataStores/DBCStructure.h
+++ b/src/server/game/DataStores/DBCStructure.h
@@ -21,7 +21,6 @@
#include "Common.h"
#include "DBCEnums.h"
-#include "Define.h"
#include "Util.h"
// Structures using to access raw DBC data and required packing to portability
@@ -1405,6 +1404,20 @@ struct MovieEntry
//uint32 unk2; // 2 always 100
};
+struct NamesProfanityEntry
+{
+ //uint32 ID; // 0
+ char const* Name; // 1
+ int32 Language; // 2
+};
+
+struct NamesReservedEntry
+{
+ //uint32 ID; // 0
+ char const* Name; // 1
+ int32 Language; // 2
+};
+
#define MAX_OVERRIDE_SPELL 10
struct OverrideSpellDataEntry
@@ -1638,10 +1651,8 @@ struct SpellEntry
uint32 AttributesEx5; // 9 m_attributesExE
uint32 AttributesEx6; // 10 m_attributesExF
uint32 AttributesEx7; // 11 m_attributesExG
- uint32 Stances; // 12 m_shapeshiftMask
- // uint32 unk_320_2; // 13 3.2.0
- uint32 StancesNot; // 14 m_shapeshiftExclude
- // uint32 unk_320_3; // 15 3.2.0
+ uint32 Stances[2]; // 12 m_shapeshiftMask
+ uint32 StancesNot[2]; // 14 m_shapeshiftExclude
uint32 Targets; // 16 m_targets
uint32 TargetCreatureType; // 17 m_targetCreatureType
uint32 RequiresSpellFocus; // 18 m_requiresSpellFocus
@@ -1737,8 +1748,6 @@ struct SpellEntry
//uint32 SpellDifficultyId; // 233 3.3.0
};
-typedef std::set<uint32> SpellCategorySet;
-typedef std::map<uint32, SpellCategorySet > SpellCategoryStore;
typedef std::set<uint32> PetFamilySpellsSet;
typedef std::map<uint32, PetFamilySpellsSet > PetFamilySpellsStore;
diff --git a/src/server/game/DataStores/DBCfmt.h b/src/server/game/DataStores/DBCfmt.h
index 5c24e6f938a..c75c0fff625 100644
--- a/src/server/game/DataStores/DBCfmt.h
+++ b/src/server/game/DataStores/DBCfmt.h
@@ -88,6 +88,8 @@ char const MailTemplateEntryfmt[] = "nxxxxxxxxxxxxxxxxxssssssssssssssssx";
char const MapEntryfmt[] = "nxiixssssssssssssssssxixxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxixiffxiii";
char const MapDifficultyEntryfmt[] = "diisxxxxxxxxxxxxxxxxiix";
char const MovieEntryfmt[] = "nxx";
+char const NamesProfanityEntryfmt[] = "dsi";
+char const NamesReservedEntryfmt[] = "dsi";
char const OverrideSpellDatafmt[] = "niiiiiiiiiix";
char const QuestFactionRewardfmt[] = "niiiiiiiiii";
char const QuestSortEntryfmt[] = "nxxxxxxxxxxxxxxxxx";
@@ -108,7 +110,7 @@ char const SpellDifficultyfmt[] = "niiii";
const std::string CustomSpellDifficultyfmt = "ppppp";
const std::string CustomSpellDifficultyIndex = "id";
char const SpellDurationfmt[] = "niii";
-char const SpellEntryfmt[] = "niiiiiiiiiiiixixiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiifxiiiiiiiiiiiiiiiiiiiiiiiiiiiifffiiiiiiiiiiiiiiiiiiiiifffiiiiiiiiiiiiiiifffiiiiiiiiiiiiixssssssssssssssssxssssssssssssssssxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxiiiiiiiiiiixfffxxxiiiiixxfffxx";
+char const SpellEntryfmt[] = "niiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiifxiiiiiiiiiiiiiiiiiiiiiiiiiiiifffiiiiiiiiiiiiiiiiiiiiifffiiiiiiiiiiiiiiifffiiiiiiiiiiiiixssssssssssssssssxssssssssssssssssxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxiiiiiiiiiiixfffxxxiiiiixxfffxx";
const std::string CustomSpellEntryfmt = "papppppppppppapapaaaaaaaaaaapaaapapppppppaaaaapaapaaaaaaaaaaaaaaaaaappppppppppppppppppppppppppppppppppppaaappppppppppppaaapppppppppaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaappppppppapppaaaaappaaaaaaa";
const std::string CustomSpellEntryIndex = "Id";
char const SpellFocusObjectfmt[] = "nxxxxxxxxxxxxxxxxx";
diff --git a/src/server/game/Entities/Corpse/Corpse.cpp b/src/server/game/Entities/Corpse/Corpse.cpp
index ca808ad15a8..ce4e94b8ea6 100644
--- a/src/server/game/Entities/Corpse/Corpse.cpp
+++ b/src/server/game/Entities/Corpse/Corpse.cpp
@@ -59,9 +59,8 @@ void Corpse::RemoveFromWorld()
WorldObject::RemoveFromWorld();
}
-bool Corpse::Create(ObjectGuid::LowType guidlow, Map* map)
+bool Corpse::Create(ObjectGuid::LowType guidlow)
{
- SetMap(map);
Object::_Create(guidlow, 0, HighGuid::Corpse);
return true;
}
@@ -79,16 +78,12 @@ bool Corpse::Create(ObjectGuid::LowType guidlow, Player* owner)
return false;
}
- //we need to assign owner's map for corpse
- //in other way we will get a crash in Corpse::SaveToDB()
- SetMap(owner->GetMap());
-
WorldObject::_Create(guidlow, HighGuid::Corpse, owner->GetPhaseMask());
SetObjectScale(1.0f);
SetGuidValue(CORPSE_FIELD_OWNER, owner->GetGUID());
- _gridCoord = Trinity::ComputeGridCoord(GetPositionX(), GetPositionY());
+ _cellCoord = Trinity::ComputeCellCoord(GetPositionX(), GetPositionY());
return true;
}
@@ -123,20 +118,6 @@ void Corpse::SaveToDB()
CharacterDatabase.CommitTransaction(trans);
}
-void Corpse::DeleteBonesFromWorld()
-{
- ASSERT(GetType() == CORPSE_BONES);
- Corpse* corpse = ObjectAccessor::GetCorpse(*this, GetGUID());
-
- if (!corpse)
- {
- TC_LOG_ERROR("entities.player", "Bones %u not found in world.", GetGUID().GetCounter());
- return;
- }
-
- AddObjectToRemoveList();
-}
-
void Corpse::DeleteFromDB(SQLTransaction& trans)
{
DeleteFromDB(GetOwnerGUID(), trans);
@@ -192,14 +173,14 @@ bool Corpse::LoadCorpseFromDB(ObjectGuid::LowType guid, Field* fields)
return false;
}
- _gridCoord = Trinity::ComputeGridCoord(GetPositionX(), GetPositionY());
+ _cellCoord = Trinity::ComputeCellCoord(GetPositionX(), GetPositionY());
return true;
}
bool Corpse::IsExpired(time_t t) const
{
// Deleted character
- if (!sWorld->GetCharacterNameData(GetOwnerGUID()))
+ if (!sWorld->GetCharacterInfo(GetOwnerGUID()))
return true;
if (m_type == CORPSE_BONES)
diff --git a/src/server/game/Entities/Corpse/Corpse.h b/src/server/game/Entities/Corpse/Corpse.h
index be2cb435ac9..7f2608e4bf3 100644
--- a/src/server/game/Entities/Corpse/Corpse.h
+++ b/src/server/game/Entities/Corpse/Corpse.h
@@ -55,13 +55,12 @@ class Corpse : public WorldObject, public GridObject<Corpse>
void AddToWorld() override;
void RemoveFromWorld() override;
- bool Create(ObjectGuid::LowType guidlow, Map* map);
+ bool Create(ObjectGuid::LowType guidlow);
bool Create(ObjectGuid::LowType guidlow, Player* owner);
void SaveToDB();
bool LoadCorpseFromDB(ObjectGuid::LowType guid, Field* fields);
- void DeleteBonesFromWorld();
void DeleteFromDB(SQLTransaction& trans);
static void DeleteFromDB(ObjectGuid const& ownerGuid, SQLTransaction& trans);
@@ -71,8 +70,8 @@ class Corpse : public WorldObject, public GridObject<Corpse>
void ResetGhostTime() { m_time = time(NULL); }
CorpseType GetType() const { return m_type; }
- GridCoord const& GetGridCoord() const { return _gridCoord; }
- void SetGridCoord(GridCoord const& gridCoord) { _gridCoord = gridCoord; }
+ CellCoord const& GetCellCoord() const { return _cellCoord; }
+ void SetCellCoord(CellCoord const& cellCoord) { _cellCoord = cellCoord; }
Loot loot; // remove insignia ONLY at BG
Player* lootRecipient;
@@ -83,6 +82,6 @@ class Corpse : public WorldObject, public GridObject<Corpse>
private:
CorpseType m_type;
time_t m_time;
- GridCoord _gridCoord; // gride for corpse position for fast search
+ CellCoord _cellCoord;
};
#endif
diff --git a/src/server/game/Entities/Creature/Creature.cpp b/src/server/game/Entities/Creature/Creature.cpp
index 6a994d61852..ea10ce7988b 100644
--- a/src/server/game/Entities/Creature/Creature.cpp
+++ b/src/server/game/Entities/Creature/Creature.cpp
@@ -441,6 +441,7 @@ bool Creature::UpdateEntry(uint32 entry, CreatureData const* data /*= nullptr*/)
}
UpdateMovementFlags();
+ LoadCreaturesAddon();
return true;
}
@@ -820,8 +821,6 @@ bool Creature::Create(ObjectGuid::LowType guidlow, Map* map, uint32 phaseMask, u
break;
}
- LoadCreaturesAddon();
-
//! Need to be called after LoadCreaturesAddon - MOVEMENTFLAG_HOVER is set there
if (HasUnitMovementFlag(MOVEMENTFLAG_HOVER))
{
@@ -1411,11 +1410,11 @@ bool Creature::CanStartAttack(Unit const* who, bool force) const
return false;
// This set of checks is should be done only for creatures
- if ((HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_NPC) && who->GetTypeId() != TYPEID_PLAYER) // flag is valid only for non player characters
+ if ((HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_NPC) && who->GetTypeId() != TYPEID_PLAYER) // flag is valid only for non player characters
|| (HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_PC) && who->GetTypeId() == TYPEID_PLAYER) // immune to PC and target is a player, return false
|| (who->GetOwner() && who->GetOwner()->GetTypeId() == TYPEID_PLAYER && HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_PC))) // player pets are immune to pc as well
return false;
-
+
// Do not attack non-combat pets
if (who->GetTypeId() == TYPEID_UNIT && who->GetCreatureType() == CREATURE_TYPE_NON_COMBAT_PET)
return false;
@@ -1557,7 +1556,7 @@ void Creature::setDeathState(DeathState s)
if (GetCreatureData() && GetPhaseMask() != GetCreatureData()->phaseMask)
SetPhaseMask(GetCreatureData()->phaseMask, false);
Unit::setDeathState(ALIVE);
- LoadCreaturesAddon(true);
+ LoadCreaturesAddon();
}
}
@@ -2063,7 +2062,7 @@ CreatureAddon const* Creature::GetCreatureAddon() const
}
//creature_addon table
-bool Creature::LoadCreaturesAddon(bool reload)
+bool Creature::LoadCreaturesAddon()
{
CreatureAddon const* cainfo = GetCreatureAddon();
if (!cainfo)
@@ -2129,12 +2128,7 @@ bool Creature::LoadCreaturesAddon(bool reload)
// skip already applied aura
if (HasAura(*itr))
- {
- if (!reload)
- TC_LOG_ERROR("sql.sql", "Creature (GUID: %u Entry: %u) has duplicate aura (spell %u) in `auras` field.", GetSpawnId(), GetEntry(), *itr);
-
continue;
- }
AddAura(*itr, this);
TC_LOG_DEBUG("entities.unit", "Spell: %u added to creature (GUID: %u Entry: %u)", *itr, GetGUID().GetCounter(), GetEntry());
diff --git a/src/server/game/Entities/Creature/Creature.h b/src/server/game/Entities/Creature/Creature.h
index 7744e30f122..9a41c8570ed 100644
--- a/src/server/game/Entities/Creature/Creature.h
+++ b/src/server/game/Entities/Creature/Creature.h
@@ -83,7 +83,7 @@ struct CreatureTemplate
uint32 Modelid3;
uint32 Modelid4;
std::string Name;
- std::string SubName;
+ std::string Title;
std::string IconName;
uint32 GossipMenuId;
uint8 minlevel;
@@ -218,7 +218,7 @@ typedef std::unordered_map<uint16, CreatureBaseStats> CreatureBaseStatsContainer
struct CreatureLocale
{
StringVector Name;
- StringVector SubName;
+ StringVector Title;
};
struct GossipMenuItemsLocale
@@ -432,7 +432,7 @@ class Creature : public Unit, public GridObject<Creature>, public MapObject
void DisappearAndDie();
bool Create(ObjectGuid::LowType guidlow, Map* map, uint32 phaseMask, uint32 entry, float x, float y, float z, float ang, CreatureData const* data = nullptr, uint32 vehId = 0);
- bool LoadCreaturesAddon(bool reload = false);
+ bool LoadCreaturesAddon();
void SelectLevel();
void LoadEquipment(int8 id = 1, bool force = false);
diff --git a/src/server/game/Entities/Creature/CreatureGroups.cpp b/src/server/game/Entities/Creature/CreatureGroups.cpp
index 2d353fa154e..e8ce0acdc86 100644
--- a/src/server/game/Entities/Creature/CreatureGroups.cpp
+++ b/src/server/game/Entities/Creature/CreatureGroups.cpp
@@ -240,7 +240,8 @@ void CreatureGroup::LeaderMoveTo(float x, float y, float z)
Trinity::NormalizeMapCoord(dx);
Trinity::NormalizeMapCoord(dy);
- member->UpdateGroundPositionZ(dx, dy, dz);
+ if (!member->IsFlying())
+ member->UpdateGroundPositionZ(dx, dy, dz);
if (member->IsWithinDist(m_leader, dist + MAX_DESYNC))
member->SetUnitMovementFlags(m_leader->GetUnitMovementFlags());
diff --git a/src/server/game/Entities/Creature/CreatureGroups.h b/src/server/game/Entities/Creature/CreatureGroups.h
index e4b2f63c1a3..3de1370379b 100644
--- a/src/server/game/Entities/Creature/CreatureGroups.h
+++ b/src/server/game/Entities/Creature/CreatureGroups.h
@@ -32,8 +32,8 @@ struct FormationInfo
float follow_dist;
float follow_angle;
uint8 groupAI;
- uint16 point_1;
- uint16 point_2;
+ uint32 point_1;
+ uint32 point_2;
};
typedef std::unordered_map<uint32/*memberDBGUID*/, FormationInfo*> CreatureGroupInfoType;
diff --git a/src/server/game/Entities/Item/Item.cpp b/src/server/game/Entities/Item/Item.cpp
index 9a6af376e6d..1b7914fd85f 100644
--- a/src/server/game/Entities/Item/Item.cpp
+++ b/src/server/game/Entities/Item/Item.cpp
@@ -28,6 +28,7 @@
#include "ConditionMgr.h"
#include "Player.h"
#include "WorldSession.h"
+#include "TradeData.h"
void AddItemsSetItem(Player* player, Item* item)
{
@@ -1435,3 +1436,19 @@ void Item::ItemContainerDeleteLootMoneyAndLootItemsFromDB()
ItemContainerDeleteLootMoneyFromDB();
ItemContainerDeleteLootItemsFromDB();
}
+
+void Item::SetCount(uint32 value)
+{
+ SetUInt32Value(ITEM_FIELD_STACK_COUNT, value);
+
+ if (Player* player = GetOwner())
+ {
+ if (TradeData* tradeData = player->GetTradeData())
+ {
+ TradeSlots slot = tradeData->GetTradeSlotForItem(GetGUID());
+
+ if (slot != TRADE_SLOT_INVALID)
+ tradeData->SetItem(slot, this, true);
+ }
+ }
+}
diff --git a/src/server/game/Entities/Item/Item.h b/src/server/game/Entities/Item/Item.h
index a268334b212..1eb6530a996 100644
--- a/src/server/game/Entities/Item/Item.h
+++ b/src/server/game/Entities/Item/Item.h
@@ -262,7 +262,7 @@ class Item : public Object
bool GemsFitSockets() const;
uint32 GetCount() const { return GetUInt32Value(ITEM_FIELD_STACK_COUNT); }
- void SetCount(uint32 value) { SetUInt32Value(ITEM_FIELD_STACK_COUNT, value); }
+ void SetCount(uint32 value);
uint32 GetMaxStackCount() const { return GetTemplate()->GetMaxStackSize(); }
uint8 GetGemCountWithID(uint32 GemID) const;
uint8 GetGemCountWithLimitCategory(uint32 limitCategory) const;
diff --git a/src/server/game/Entities/Object/Object.cpp b/src/server/game/Entities/Object/Object.cpp
index e4d9e61bca3..afb987f1980 100644
--- a/src/server/game/Entities/Object/Object.cpp
+++ b/src/server/game/Entities/Object/Object.cpp
@@ -1863,7 +1863,7 @@ TempSummon* Map::SummonCreature(uint32 entry, Position const& pos, SummonPropert
summon = new Minion(properties, summoner, false);
break;
}
-
+
if (!summon->Create(GenerateLowGuid<HighGuid::Unit>(), this, phase, entry, pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ(), pos.GetOrientation(), nullptr, vehId))
{
delete summon;
diff --git a/src/server/game/Entities/Object/ObjectGuid.h b/src/server/game/Entities/Object/ObjectGuid.h
index 697ee3835f6..74fffe09796 100644
--- a/src/server/game/Entities/Object/ObjectGuid.h
+++ b/src/server/game/Entities/Object/ObjectGuid.h
@@ -21,10 +21,8 @@
#include "Common.h"
#include "ByteBuffer.h"
-
#include <type_traits>
#include <functional>
-#include <unordered_set>
enum TypeID
{
@@ -130,11 +128,6 @@ class ObjectGuid
explicit ObjectGuid(uint64 guid) : _guid(guid) { }
ObjectGuid(HighGuid hi, uint32 entry, LowType counter) : _guid(counter ? uint64(counter) | (uint64(entry) << 24) | (uint64(hi) << 48) : 0) { }
ObjectGuid(HighGuid hi, LowType counter) : _guid(counter ? uint64(counter) | (uint64(hi) << 48) : 0) { }
- ObjectGuid(ObjectGuid const& r) : _guid(r._guid) { }
- ObjectGuid(ObjectGuid&& r) : _guid(r._guid) { }
-
- ObjectGuid& operator=(ObjectGuid const& r) { _guid = r._guid; return *this; }
- ObjectGuid& operator=(ObjectGuid&& r) { _guid = r._guid; return *this; }
operator uint64() const { return _guid; }
PackedGuidReader ReadAsPacked() { return PackedGuidReader(*this); }
diff --git a/src/server/game/Entities/Player/KillRewarder.cpp b/src/server/game/Entities/Player/KillRewarder.cpp
new file mode 100644
index 00000000000..ad2f8f641ea
--- /dev/null
+++ b/src/server/game/Entities/Player/KillRewarder.cpp
@@ -0,0 +1,274 @@
+/*
+ * Copyright (C) 2008-2015 TrinityCore <http://www.trinitycore.org/>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2 of the License, or (at your
+ * option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "KillRewarder.h"
+#include "SpellAuraEffects.h"
+#include "Creature.h"
+#include "Formulas.h"
+#include "Group.h"
+#include "Guild.h"
+#include "GuildMgr.h"
+#include "InstanceScript.h"
+#include "Pet.h"
+#include "Player.h"
+
+ // == KillRewarder ====================================================
+ // KillRewarder encapsulates logic of rewarding player upon kill with:
+ // * XP;
+ // * honor;
+ // * reputation;
+ // * kill credit (for quest objectives).
+ // Rewarding is initiated in two cases: when player kills unit in Unit::Kill()
+ // and on battlegrounds in Battleground::RewardXPAtKill().
+ //
+ // Rewarding algorithm is:
+ // 1. Initialize internal variables to default values.
+ // 2. In case when player is in group, initialize variables necessary for group calculations:
+ // 2.1. _count - number of alive group members within reward distance;
+ // 2.2. _sumLevel - sum of levels of alive group members within reward distance;
+ // 2.3. _maxLevel - maximum level of alive group member within reward distance;
+ // 2.4. _maxNotGrayMember - maximum level of alive group member within reward distance,
+ // for whom victim is not gray;
+ // 2.5. _isFullXP - flag identifying that for all group members victim is not gray,
+ // so 100% XP will be rewarded (50% otherwise).
+ // 3. Reward killer (and group, if necessary).
+ // 3.1. If killer is in group, reward group.
+ // 3.1.1. Initialize initial XP amount based on maximum level of group member,
+ // for whom victim is not gray.
+ // 3.1.2. Alter group rate if group is in raid (not for battlegrounds).
+ // 3.1.3. Reward each group member (even dead) within reward distance (see 4. for more details).
+ // 3.2. Reward single killer (not group case).
+ // 3.2.1. Initialize initial XP amount based on killer's level.
+ // 3.2.2. Reward killer (see 4. for more details).
+ // 4. Reward player.
+ // 4.1. Give honor (player must be alive and not on BG).
+ // 4.2. Give XP.
+ // 4.2.1. If player is in group, adjust XP:
+ // * set to 0 if player's level is more than maximum level of not gray member;
+ // * cut XP in half if _isFullXP is false.
+ // 4.2.2. Apply auras modifying rewarded XP.
+ // 4.2.3. Give XP to player.
+ // 4.2.4. If player has pet, reward pet with XP (100% for single player, 50% for group case).
+ // 4.3. Give reputation (player must not be on BG).
+ // 4.4. Give kill credit (player must not be in group, or he must be alive or without corpse).
+ // 5. Credit instance encounter.
+
+KillRewarder::KillRewarder(Player* killer, Unit* victim, bool isBattleGround) :
+ // 1. Initialize internal variables to default values.
+ _killer(killer), _victim(victim), _group(killer->GetGroup()),
+ _groupRate(1.0f), _maxNotGrayMember(nullptr), _count(0), _sumLevel(0), _xp(0),
+ _isFullXP(false), _maxLevel(0), _isBattleGround(isBattleGround), _isPvP(false)
+{
+ // mark the credit as pvp if victim is player
+ if (victim->GetTypeId() == TYPEID_PLAYER)
+ _isPvP = true;
+ // or if its owned by player and its not a vehicle
+ else if (victim->GetCharmerOrOwnerGUID().IsPlayer())
+ _isPvP = !victim->IsVehicle();
+
+ _InitGroupData();
+}
+
+inline void KillRewarder::_InitGroupData()
+{
+ if (_group)
+ {
+ // 2. In case when player is in group, initialize variables necessary for group calculations:
+ for (GroupReference* itr = _group->GetFirstMember(); itr != nullptr; itr = itr->next())
+ if (Player* member = itr->GetSource())
+ if (member->IsAlive() && member->IsAtGroupRewardDistance(_victim))
+ {
+ const uint8 lvl = member->getLevel();
+ // 2.1. _count - number of alive group members within reward distance;
+ ++_count;
+ // 2.2. _sumLevel - sum of levels of alive group members within reward distance;
+ _sumLevel += lvl;
+ // 2.3. _maxLevel - maximum level of alive group member within reward distance;
+ if (_maxLevel < lvl)
+ _maxLevel = lvl;
+ // 2.4. _maxNotGrayMember - maximum level of alive group member within reward distance,
+ // for whom victim is not gray;
+ uint32 grayLevel = Trinity::XP::GetGrayLevel(lvl);
+ if (_victim->getLevel() > grayLevel && (!_maxNotGrayMember || _maxNotGrayMember->getLevel() < lvl))
+ _maxNotGrayMember = member;
+ }
+ // 2.5. _isFullXP - flag identifying that for all group members victim is not gray,
+ // so 100% XP will be rewarded (50% otherwise).
+ _isFullXP = _maxNotGrayMember && (_maxLevel == _maxNotGrayMember->getLevel());
+ }
+ else
+ _count = 1;
+}
+
+inline void KillRewarder::_InitXP(Player* player)
+{
+ // Get initial value of XP for kill.
+ // XP is given:
+ // * on battlegrounds;
+ // * otherwise, not in PvP;
+ // * not if killer is on vehicle.
+ if (_isBattleGround || (!_isPvP && !_killer->GetVehicle()))
+ _xp = Trinity::XP::Gain(player, _victim, _isBattleGround);
+}
+
+inline void KillRewarder::_RewardHonor(Player* player)
+{
+ // Rewarded player must be alive.
+ if (player->IsAlive())
+ player->RewardHonor(_victim, _count, -1, true);
+}
+
+inline void KillRewarder::_RewardXP(Player* player, float rate)
+{
+ uint32 xp(_xp);
+ if (_group)
+ {
+ // 4.2.1. If player is in group, adjust XP:
+ // * set to 0 if player's level is more than maximum level of not gray member;
+ // * cut XP in half if _isFullXP is false.
+ if (_maxNotGrayMember && player->IsAlive() &&
+ _maxNotGrayMember->getLevel() >= player->getLevel())
+ xp = _isFullXP ?
+ uint32(xp * rate) : // Reward FULL XP if all group members are not gray.
+ uint32(xp * rate / 2) + 1; // Reward only HALF of XP if some of group members are gray.
+ else
+ xp = 0;
+ }
+ if (xp)
+ {
+ // 4.2.2. Apply auras modifying rewarded XP (SPELL_AURA_MOD_XP_PCT).
+ for (auto const& aura : player->GetAuraEffectsByType(SPELL_AURA_MOD_XP_PCT))
+ AddPct(xp, aura->GetAmount());
+
+ // 4.2.3. Give XP to player.
+ player->GiveXP(xp, _victim, _groupRate);
+ if (Pet* pet = player->GetPet())
+ // 4.2.4. If player has pet, reward pet with XP (100% for single player, 50% for group case).
+ pet->GivePetXP(_group ? xp / 2 : xp);
+ }
+}
+
+inline void KillRewarder::_RewardReputation(Player* player, float rate)
+{
+ // 4.3. Give reputation (player must not be on BG).
+ // Even dead players and corpses are rewarded.
+ player->RewardReputation(_victim, rate);
+}
+
+inline void KillRewarder::_RewardKillCredit(Player* player)
+{
+ // 4.4. Give kill credit (player must not be in group, or he must be alive or without corpse).
+ if (!_group || player->IsAlive() || !player->GetCorpse())
+ if (Creature* target = _victim->ToCreature())
+ {
+ player->KilledMonster(target->GetCreatureTemplate(), target->GetGUID());
+ player->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_KILL_CREATURE_TYPE, target->GetCreatureType(), 1, target);
+ }
+}
+
+void KillRewarder::_RewardPlayer(Player* player, bool isDungeon)
+{
+ // 4. Reward player.
+ if (!_isBattleGround)
+ {
+ // 4.1. Give honor (player must be alive and not on BG).
+ _RewardHonor(player);
+ // 4.1.1 Send player killcredit for quests with PlayerSlain
+ if (_victim->GetTypeId() == TYPEID_PLAYER)
+ player->KilledPlayerCredit();
+ }
+ // Give XP only in PvE or in battlegrounds.
+ // Give reputation and kill credit only in PvE.
+ if (!_isPvP || _isBattleGround)
+ {
+ float const rate = _group ?
+ _groupRate * float(player->getLevel()) / _sumLevel : // Group rate depends on summary level.
+ 1.0f; // Personal rate is 100%.
+ if (_xp)
+ // 4.2. Give XP.
+ _RewardXP(player, rate);
+ if (!_isBattleGround)
+ {
+ // If killer is in dungeon then all members receive full reputation at kill.
+ _RewardReputation(player, isDungeon ? 1.0f : rate);
+ _RewardKillCredit(player);
+ }
+ }
+}
+
+void KillRewarder::_RewardGroup()
+{
+ if (_maxLevel)
+ {
+ if (_maxNotGrayMember)
+ // 3.1.1. Initialize initial XP amount based on maximum level of group member,
+ // for whom victim is not gray.
+ _InitXP(_maxNotGrayMember);
+ // To avoid unnecessary calculations and calls,
+ // proceed only if XP is not ZERO or player is not on battleground
+ // (battleground rewards only XP, that's why).
+ if (!_isBattleGround || _xp)
+ {
+ bool const isDungeon = !_isPvP && sMapStore.LookupEntry(_killer->GetMapId())->IsDungeon();
+ if (!_isBattleGround)
+ {
+ // 3.1.2. Alter group rate if group is in raid (not for battlegrounds).
+ bool const isRaid = !_isPvP && sMapStore.LookupEntry(_killer->GetMapId())->IsRaid() && _group->isRaidGroup();
+ _groupRate = Trinity::XP::xp_in_group_rate(_count, isRaid);
+ }
+
+ // 3.1.3. Reward each group member (even dead or corpse) within reward distance.
+ for (GroupReference* itr = _group->GetFirstMember(); itr != nullptr; itr = itr->next())
+ {
+ if (Player* member = itr->GetSource())
+ {
+ if (member->IsAtGroupRewardDistance(_victim))
+ {
+ _RewardPlayer(member, isDungeon);
+ member->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_SPECIAL_PVP_KILL, 1, 0, _victim);
+ }
+ }
+ }
+ }
+ }
+}
+
+void KillRewarder::Reward()
+{
+ // 3. Reward killer (and group, if necessary).
+ if (_group)
+ // 3.1. If killer is in group, reward group.
+ _RewardGroup();
+ else
+ {
+ // 3.2. Reward single killer (not group case).
+ // 3.2.1. Initialize initial XP amount based on killer's level.
+ _InitXP(_killer);
+ // To avoid unnecessary calculations and calls,
+ // proceed only if XP is not ZERO or player is not on battleground
+ // (battleground rewards only XP, that's why).
+ if (!_isBattleGround || _xp)
+ // 3.2.2. Reward killer.
+ _RewardPlayer(_killer, false);
+ }
+
+ // 5. Credit instance encounter.
+ if (Creature* victim = _victim->ToCreature())
+ if (victim->IsDungeonBoss())
+ if (InstanceScript* instance = _victim->GetInstanceScript())
+ instance->UpdateEncounterState(ENCOUNTER_CREDIT_KILL_CREATURE, _victim->GetEntry(), _victim);
+}
diff --git a/src/server/game/Entities/Player/KillRewarder.h b/src/server/game/Entities/Player/KillRewarder.h
new file mode 100644
index 00000000000..577a8ffea20
--- /dev/null
+++ b/src/server/game/Entities/Player/KillRewarder.h
@@ -0,0 +1,59 @@
+/*
+ * Copyright (C) 2008-2015 TrinityCore <http://www.trinitycore.org/>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2 of the License, or (at your
+ * option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef KillRewarder_h__
+#define KillRewarder_h__
+
+#include "Define.h"
+
+class Player;
+class Unit;
+class Group;
+
+class KillRewarder
+{
+public:
+ KillRewarder(Player* killer, Unit* victim, bool isBattleGround);
+
+ void Reward();
+
+private:
+ void _InitXP(Player* player);
+ void _InitGroupData();
+
+ void _RewardHonor(Player* player);
+ void _RewardXP(Player* player, float rate);
+ void _RewardReputation(Player* player, float rate);
+ void _RewardKillCredit(Player* player);
+ void _RewardPlayer(Player* player, bool isDungeon);
+ void _RewardGroup();
+
+ Player* _killer;
+ Unit* _victim;
+ Group* _group;
+ float _groupRate;
+ Player* _maxNotGrayMember;
+ uint32 _count;
+ uint32 _sumLevel;
+ uint32 _xp;
+ bool _isFullXP;
+ uint8 _maxLevel;
+ bool _isBattleGround;
+ bool _isPvP;
+};
+
+#endif // KillRewarder_h__
diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp
index bfcdb7a8f57..1a9c0fbce4b 100644
--- a/src/server/game/Entities/Player/Player.cpp
+++ b/src/server/game/Entities/Player/Player.cpp
@@ -48,6 +48,7 @@
#include "GuildMgr.h"
#include "InstanceSaveMgr.h"
#include "InstanceScript.h"
+#include "KillRewarder.h"
#include "LFGMgr.h"
#include "Language.h"
#include "Log.h"
@@ -69,6 +70,7 @@
#include "SpellMgr.h"
#include "SpellHistory.h"
#include "Transport.h"
+#include "TicketMgr.h"
#include "UpdateData.h"
#include "UpdateFieldFlags.h"
#include "UpdateMask.h"
@@ -288,374 +290,6 @@ std::ostringstream& operator<< (std::ostringstream& ss, PlayerTaxi const& taxi)
return ss;
}
-//== TradeData =================================================
-
-TradeData* TradeData::GetTraderData() const
-{
- return m_trader->GetTradeData();
-}
-
-Item* TradeData::GetItem(TradeSlots slot) const
-{
- return m_items[slot] ? m_player->GetItemByGuid(m_items[slot]) : NULL;
-}
-
-bool TradeData::HasItem(ObjectGuid itemGuid) const
-{
- for (uint8 i = 0; i < TRADE_SLOT_COUNT; ++i)
- if (m_items[i] == itemGuid)
- return true;
-
- return false;
-}
-
-TradeSlots TradeData::GetTradeSlotForItem(ObjectGuid itemGuid) const
-{
- for (uint8 i = 0; i < TRADE_SLOT_COUNT; ++i)
- if (m_items[i] == itemGuid)
- return TradeSlots(i);
-
- return TRADE_SLOT_INVALID;
-}
-
-Item* TradeData::GetSpellCastItem() const
-{
- return m_spellCastItem ? m_player->GetItemByGuid(m_spellCastItem) : NULL;
-}
-
-void TradeData::SetItem(TradeSlots slot, Item* item)
-{
- ObjectGuid itemGuid;
- if (item)
- itemGuid = item->GetGUID();
-
- if (m_items[slot] == itemGuid)
- return;
-
- m_items[slot] = itemGuid;
-
- SetAccepted(false);
- GetTraderData()->SetAccepted(false);
-
- Update();
-
- // need remove possible trader spell applied to changed item
- if (slot == TRADE_SLOT_NONTRADED)
- GetTraderData()->SetSpell(0);
-
- // need remove possible player spell applied (possible move reagent)
- SetSpell(0);
-}
-
-void TradeData::SetSpell(uint32 spell_id, Item* castItem /*= NULL*/)
-{
- ObjectGuid itemGuid = castItem ? castItem->GetGUID() : ObjectGuid::Empty;
-
- if (m_spell == spell_id && m_spellCastItem == itemGuid)
- return;
-
- m_spell = spell_id;
- m_spellCastItem = itemGuid;
-
- SetAccepted(false);
- GetTraderData()->SetAccepted(false);
-
- Update(true); // send spell info to item owner
- Update(false); // send spell info to caster self
-}
-
-void TradeData::SetMoney(uint32 money)
-{
- if (m_money == money)
- return;
-
- if (!m_player->HasEnoughMoney(money))
- {
- TradeStatusInfo info;
- info.Status = TRADE_STATUS_CLOSE_WINDOW;
- info.Result = EQUIP_ERR_NOT_ENOUGH_MONEY;
- m_player->GetSession()->SendTradeStatus(info);
- return;
- }
-
- m_money = money;
-
- SetAccepted(false);
- GetTraderData()->SetAccepted(false);
-
- Update(true);
-}
-
-void TradeData::Update(bool forTarget /*= true*/)
-{
- if (forTarget)
- m_trader->GetSession()->SendUpdateTrade(true); // player state for trader
- else
- m_player->GetSession()->SendUpdateTrade(false); // player state for player
-}
-
-void TradeData::SetAccepted(bool state, bool crosssend /*= false*/)
-{
- m_accepted = state;
-
- if (!state)
- {
- TradeStatusInfo info;
- info.Status = TRADE_STATUS_BACK_TO_TRADE;
- if (crosssend)
- m_trader->GetSession()->SendTradeStatus(info);
- else
- m_player->GetSession()->SendTradeStatus(info);
- }
-}
-
-// == KillRewarder ====================================================
-// KillRewarder incapsulates logic of rewarding player upon kill with:
-// * XP;
-// * honor;
-// * reputation;
-// * kill credit (for quest objectives).
-// Rewarding is initiated in two cases: when player kills unit in Unit::Kill()
-// and on battlegrounds in Battleground::RewardXPAtKill().
-//
-// Rewarding algorithm is:
-// 1. Initialize internal variables to default values.
-// 2. In case when player is in group, initialize variables necessary for group calculations:
-// 2.1. _count - number of alive group members within reward distance;
-// 2.2. _sumLevel - sum of levels of alive group members within reward distance;
-// 2.3. _maxLevel - maximum level of alive group member within reward distance;
-// 2.4. _maxNotGrayMember - maximum level of alive group member within reward distance,
-// for whom victim is not gray;
-// 2.5. _isFullXP - flag identifying that for all group members victim is not gray,
-// so 100% XP will be rewarded (50% otherwise).
-// 3. Reward killer (and group, if necessary).
-// 3.1. If killer is in group, reward group.
-// 3.1.1. Initialize initial XP amount based on maximum level of group member,
-// for whom victim is not gray.
-// 3.1.2. Alter group rate if group is in raid (not for battlegrounds).
-// 3.1.3. Reward each group member (even dead) within reward distance (see 4. for more details).
-// 3.2. Reward single killer (not group case).
-// 3.2.1. Initialize initial XP amount based on killer's level.
-// 3.2.2. Reward killer (see 4. for more details).
-// 4. Reward player.
-// 4.1. Give honor (player must be alive and not on BG).
-// 4.2. Give XP.
-// 4.2.1. If player is in group, adjust XP:
-// * set to 0 if player's level is more than maximum level of not gray member;
-// * cut XP in half if _isFullXP is false.
-// 4.2.2. Apply auras modifying rewarded XP.
-// 4.2.3. Give XP to player.
-// 4.2.4. If player has pet, reward pet with XP (100% for single player, 50% for group case).
-// 4.3. Give reputation (player must not be on BG).
-// 4.4. Give kill credit (player must not be in group, or he must be alive or without corpse).
-// 5. Credit instance encounter.
-KillRewarder::KillRewarder(Player* killer, Unit* victim, bool isBattleGround) :
- // 1. Initialize internal variables to default values.
- _killer(killer), _victim(victim), _group(killer->GetGroup()),
- _groupRate(1.0f), _maxNotGrayMember(NULL), _count(0), _sumLevel(0), _xp(0),
- _isFullXP(false), _maxLevel(0), _isBattleGround(isBattleGround), _isPvP(false)
-{
- // mark the credit as pvp if victim is player
- if (victim->GetTypeId() == TYPEID_PLAYER)
- _isPvP = true;
- // or if its owned by player and its not a vehicle
- else if (victim->GetCharmerOrOwnerGUID().IsPlayer())
- _isPvP = !victim->IsVehicle();
-
- _InitGroupData();
-}
-
-inline void KillRewarder::_InitGroupData()
-{
- if (_group)
- {
- // 2. In case when player is in group, initialize variables necessary for group calculations:
- for (GroupReference* itr = _group->GetFirstMember(); itr != NULL; itr = itr->next())
- if (Player* member = itr->GetSource())
- if (member->IsAlive() && member->IsAtGroupRewardDistance(_victim))
- {
- const uint8 lvl = member->getLevel();
- // 2.1. _count - number of alive group members within reward distance;
- ++_count;
- // 2.2. _sumLevel - sum of levels of alive group members within reward distance;
- _sumLevel += lvl;
- // 2.3. _maxLevel - maximum level of alive group member within reward distance;
- if (_maxLevel < lvl)
- _maxLevel = lvl;
- // 2.4. _maxNotGrayMember - maximum level of alive group member within reward distance,
- // for whom victim is not gray;
- uint32 grayLevel = Trinity::XP::GetGrayLevel(lvl);
- if (_victim->getLevel() > grayLevel && (!_maxNotGrayMember || _maxNotGrayMember->getLevel() < lvl))
- _maxNotGrayMember = member;
- }
- // 2.5. _isFullXP - flag identifying that for all group members victim is not gray,
- // so 100% XP will be rewarded (50% otherwise).
- _isFullXP = _maxNotGrayMember && (_maxLevel == _maxNotGrayMember->getLevel());
- }
- else
- _count = 1;
-}
-
-inline void KillRewarder::_InitXP(Player* player)
-{
- // Get initial value of XP for kill.
- // XP is given:
- // * on battlegrounds;
- // * otherwise, not in PvP;
- // * not if killer is on vehicle.
- if (_isBattleGround || (!_isPvP && !_killer->GetVehicle()))
- _xp = Trinity::XP::Gain(player, _victim, _isBattleGround);
-}
-
-inline void KillRewarder::_RewardHonor(Player* player)
-{
- // Rewarded player must be alive.
- if (player->IsAlive())
- player->RewardHonor(_victim, _count, -1, true);
-}
-
-inline void KillRewarder::_RewardXP(Player* player, float rate)
-{
- uint32 xp(_xp);
- if (_group)
- {
- // 4.2.1. If player is in group, adjust XP:
- // * set to 0 if player's level is more than maximum level of not gray member;
- // * cut XP in half if _isFullXP is false.
- if (_maxNotGrayMember && player->IsAlive() &&
- _maxNotGrayMember->getLevel() >= player->getLevel())
- xp = _isFullXP ?
- uint32(xp * rate) : // Reward FULL XP if all group members are not gray.
- uint32(xp * rate / 2) + 1; // Reward only HALF of XP if some of group members are gray.
- else
- xp = 0;
- }
- if (xp)
- {
- // 4.2.2. Apply auras modifying rewarded XP (SPELL_AURA_MOD_XP_PCT).
- Unit::AuraEffectList const& auras = player->GetAuraEffectsByType(SPELL_AURA_MOD_XP_PCT);
- for (Unit::AuraEffectList::const_iterator i = auras.begin(); i != auras.end(); ++i)
- AddPct(xp, (*i)->GetAmount());
-
- // 4.2.3. Give XP to player.
- player->GiveXP(xp, _victim, _groupRate);
- if (Pet* pet = player->GetPet())
- // 4.2.4. If player has pet, reward pet with XP (100% for single player, 50% for group case).
- pet->GivePetXP(_group ? xp / 2 : xp);
- }
-}
-
-inline void KillRewarder::_RewardReputation(Player* player, float rate)
-{
- // 4.3. Give reputation (player must not be on BG).
- // Even dead players and corpses are rewarded.
- player->RewardReputation(_victim, rate);
-}
-
-inline void KillRewarder::_RewardKillCredit(Player* player)
-{
- // 4.4. Give kill credit (player must not be in group, or he must be alive or without corpse).
- if (!_group || player->IsAlive() || !player->GetCorpse())
- if (Creature* target = _victim->ToCreature())
- {
- player->KilledMonster(target->GetCreatureTemplate(), target->GetGUID());
- player->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_KILL_CREATURE_TYPE, target->GetCreatureType(), 1, target);
- }
-}
-
-void KillRewarder::_RewardPlayer(Player* player, bool isDungeon)
-{
- // 4. Reward player.
- if (!_isBattleGround)
- {
- // 4.1. Give honor (player must be alive and not on BG).
- _RewardHonor(player);
- // 4.1.1 Send player killcredit for quests with PlayerSlain
- if (_victim->GetTypeId() == TYPEID_PLAYER)
- player->KilledPlayerCredit();
- }
- // Give XP only in PvE or in battlegrounds.
- // Give reputation and kill credit only in PvE.
- if (!_isPvP || _isBattleGround)
- {
- const float rate = _group ?
- _groupRate * float(player->getLevel()) / _sumLevel : // Group rate depends on summary level.
- 1.0f; // Personal rate is 100%.
- if (_xp)
- // 4.2. Give XP.
- _RewardXP(player, rate);
- if (!_isBattleGround)
- {
- // If killer is in dungeon then all members receive full reputation at kill.
- _RewardReputation(player, isDungeon ? 1.0f : rate);
- _RewardKillCredit(player);
- }
- }
-}
-
-void KillRewarder::_RewardGroup()
-{
- if (_maxLevel)
- {
- if (_maxNotGrayMember)
- // 3.1.1. Initialize initial XP amount based on maximum level of group member,
- // for whom victim is not gray.
- _InitXP(_maxNotGrayMember);
- // To avoid unnecessary calculations and calls,
- // proceed only if XP is not ZERO or player is not on battleground
- // (battleground rewards only XP, that's why).
- if (!_isBattleGround || _xp)
- {
- const bool isDungeon = !_isPvP && sMapStore.LookupEntry(_killer->GetMapId())->IsDungeon();
- if (!_isBattleGround)
- {
- // 3.1.2. Alter group rate if group is in raid (not for battlegrounds).
- const bool isRaid = !_isPvP && sMapStore.LookupEntry(_killer->GetMapId())->IsRaid() && _group->isRaidGroup();
- _groupRate = Trinity::XP::xp_in_group_rate(_count, isRaid);
- }
-
- // 3.1.3. Reward each group member (even dead or corpse) within reward distance.
- for (GroupReference* itr = _group->GetFirstMember(); itr != NULL; itr = itr->next())
- {
- if (Player* member = itr->GetSource())
- {
- if (member->IsAtGroupRewardDistance(_victim))
- {
- _RewardPlayer(member, isDungeon);
- member->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_SPECIAL_PVP_KILL, 1, 0, _victim);
- }
- }
- }
- }
- }
-}
-
-void KillRewarder::Reward()
-{
- // 3. Reward killer (and group, if necessary).
- if (_group)
- // 3.1. If killer is in group, reward group.
- _RewardGroup();
- else
- {
- // 3.2. Reward single killer (not group case).
- // 3.2.1. Initialize initial XP amount based on killer's level.
- _InitXP(_killer);
- // To avoid unnecessary calculations and calls,
- // proceed only if XP is not ZERO or player is not on battleground
- // (battleground rewards only XP, that's why).
- if (!_isBattleGround || _xp)
- // 3.2.2. Reward killer.
- _RewardPlayer(_killer, false);
- }
-
- // 5. Credit instance encounter.
- if (Creature* victim = _victim->ToCreature())
- if (victim->IsDungeonBoss())
- if (InstanceScript* instance = _victim->GetInstanceScript())
- instance->UpdateEncounterState(ENCOUNTER_CREDIT_KILL_CREATURE, _victim->GetEntry(), _victim);
-}
-
Player::Player(WorldSession* session): Unit(true)
{
m_speakTime = 0;
@@ -901,6 +535,8 @@ Player::Player(WorldSession* session): Unit(true)
SetPendingBind(0, 0);
_activeCheats = CHEAT_NONE;
+ healthBeforeDuel = 0;
+ manaBeforeDuel = 0;
m_achievementMgr = new AchievementMgr(this);
m_reputationMgr = new ReputationMgr(this);
}
@@ -3551,7 +3187,7 @@ bool Player::AddTalent(uint32 spellId, uint8 spec, bool learning)
return false;
}
-bool Player::AddSpell(uint32 spellId, bool active, bool learning, bool dependent, bool disabled, bool loading /*= false*/, bool fromSkill /*= false*/)
+bool Player::AddSpell(uint32 spellId, bool active, bool learning, bool dependent, bool disabled, bool loading /*= false*/, uint32 fromSkill /*= 0*/)
{
SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellId);
if (!spellInfo)
@@ -3809,10 +3445,10 @@ bool Player::AddSpell(uint32 spellId, bool active, bool learning, bool dependent
SkillLineAbilityMapBounds skill_bounds = sSpellMgr->GetSkillLineAbilityMapBounds(spellId);
- // add dependent skills if this spell is not learned from adding skill already
- if (!fromSkill)
+ if (SpellLearnSkillNode const* spellLearnSkill = sSpellMgr->GetSpellLearnSkill(spellId))
{
- if (SpellLearnSkillNode const* spellLearnSkill = sSpellMgr->GetSpellLearnSkill(spellId))
+ // add dependent skills if this spell is not learned from adding skill already
+ if (spellLearnSkill->skill != fromSkill)
{
uint32 skill_value = GetPureSkillValue(spellLearnSkill->skill);
uint32 skill_max_value = GetPureMaxSkillValue(spellLearnSkill->skill);
@@ -3827,26 +3463,29 @@ bool Player::AddSpell(uint32 spellId, bool active, bool learning, bool dependent
SetSkill(spellLearnSkill->skill, spellLearnSkill->step, skill_value, skill_max_value);
}
- else
+ }
+ else
+ {
+ // not ranked skills
+ for (SkillLineAbilityMap::const_iterator _spell_idx = skill_bounds.first; _spell_idx != skill_bounds.second; ++_spell_idx)
{
- // not ranked skills
- for (SkillLineAbilityMap::const_iterator _spell_idx = skill_bounds.first; _spell_idx != skill_bounds.second; ++_spell_idx)
- {
- SkillLineEntry const* pSkill = sSkillLineStore.LookupEntry(_spell_idx->second->skillId);
- if (!pSkill)
- continue;
+ SkillLineEntry const* pSkill = sSkillLineStore.LookupEntry(_spell_idx->second->skillId);
+ if (!pSkill)
+ continue;
- ///@todo: confirm if rogues start with lockpicking skill at level 1 but only receive the spell to use it at level 16
- // Also added for runeforging. It's already confirmed this happens upon learning for Death Knights, not from character creation.
- if ((_spell_idx->second->AutolearnType == SKILL_LINE_ABILITY_LEARNED_ON_SKILL_LEARN && !HasSkill(pSkill->id)) || ((pSkill->id == SKILL_LOCKPICKING || pSkill->id == SKILL_RUNEFORGING) && _spell_idx->second->max_value == 0))
- LearnDefaultSkill(pSkill->id, 0);
+ if (pSkill->id == fromSkill)
+ continue;
- if (pSkill->id == SKILL_MOUNTS && !Has310Flyer(false))
- for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
- if (spellInfo->Effects[i].ApplyAuraName == SPELL_AURA_MOD_INCREASE_MOUNTED_FLIGHT_SPEED &&
- spellInfo->Effects[i].CalcValue() == 310)
- SetHas310Flyer(true);
- }
+ ///@todo: confirm if rogues start with lockpicking skill at level 1 but only receive the spell to use it at level 16
+ // Also added for runeforging. It's already confirmed this happens upon learning for Death Knights, not from character creation.
+ if ((_spell_idx->second->AutolearnType == SKILL_LINE_ABILITY_LEARNED_ON_SKILL_LEARN && !HasSkill(pSkill->id)) || ((pSkill->id == SKILL_LOCKPICKING || pSkill->id == SKILL_RUNEFORGING) && _spell_idx->second->max_value == 0))
+ LearnDefaultSkill(pSkill->id, 0);
+
+ if (pSkill->id == SKILL_MOUNTS && !Has310Flyer(false))
+ for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
+ if (spellInfo->Effects[i].ApplyAuraName == SPELL_AURA_MOD_INCREASE_MOUNTED_FLIGHT_SPEED &&
+ spellInfo->Effects[i].CalcValue() == 310)
+ SetHas310Flyer(true);
}
}
@@ -3912,14 +3551,14 @@ bool Player::IsNeedCastPassiveSpellAtLearn(SpellInfo const* spellInfo) const
// note: form passives activated with shapeshift spells be implemented by HandleShapeshiftBoosts instead of spell_learn_spell
// talent dependent passives activated at form apply have proper stance data
ShapeshiftForm form = GetShapeshiftForm();
- bool need_cast = (!spellInfo->Stances || (form && (spellInfo->Stances & (1 << (form - 1)))) ||
+ bool need_cast = (!spellInfo->Stances || (form && (spellInfo->Stances & (UI64LIT(1) << (form - 1)))) ||
(!form && spellInfo->HasAttribute(SPELL_ATTR2_NOT_NEED_SHAPESHIFT)));
//Check CasterAuraStates
return need_cast && (!spellInfo->CasterAuraState || HasAuraState(AuraStateType(spellInfo->CasterAuraState)));
}
-void Player::LearnSpell(uint32 spell_id, bool dependent, bool fromSkill /*= false*/)
+void Player::LearnSpell(uint32 spell_id, bool dependent, uint32 fromSkill /*= 0*/)
{
PlayerSpellMap::iterator itr = m_spells.find(spell_id);
@@ -4528,14 +4167,14 @@ void Player::DeleteFromDB(ObjectGuid playerguid, uint32 accountId, bool updateRe
if (deleteFinally)
charDelete_method = CHAR_DELETE_REMOVE;
- else if (CharacterNameData const* nameData = sWorld->GetCharacterNameData(playerguid)) // To avoid a query, we select loaded data. If it doesn't exist, return.
+ else if (CharacterInfo const* nameData = sWorld->GetCharacterInfo(playerguid)) // To avoid a query, we select loaded data. If it doesn't exist, return.
{
// Define the required variables
- uint32 charDelete_minLvl = sWorld->getIntConfig(nameData->m_class != CLASS_DEATH_KNIGHT ? CONFIG_CHARDELETE_MIN_LEVEL : CONFIG_CHARDELETE_HEROIC_MIN_LEVEL);
+ uint32 charDelete_minLvl = sWorld->getIntConfig(nameData->Class != CLASS_DEATH_KNIGHT ? CONFIG_CHARDELETE_MIN_LEVEL : CONFIG_CHARDELETE_HEROIC_MIN_LEVEL);
// if we want to finalize the character removal or the character does not meet the level requirement of either heroic or non-heroic settings,
// we set it to mode CHAR_DELETE_REMOVE
- if (nameData->m_level < charDelete_minLvl)
+ if (nameData->Level < charDelete_minLvl)
charDelete_method = CHAR_DELETE_REMOVE;
}
@@ -4543,6 +4182,11 @@ void Player::DeleteFromDB(ObjectGuid playerguid, uint32 accountId, bool updateRe
if (Guild* guild = sGuildMgr->GetGuildById(guildId))
guild->DeleteMember(playerguid, false, false, true);
+ // close player ticket if any
+ GmTicket* ticket = sTicketMgr->GetTicketByPlayer(playerguid);
+ if (ticket)
+ ticket->SetClosedBy(playerguid);
+
// remove from arena teams
LeaveAllArenaTeams(playerguid);
@@ -4754,9 +4398,18 @@ void Player::DeleteFromDB(ObjectGuid playerguid, uint32 accountId, bool updateRe
stmt->setUInt32(0, guid);
trans->Append(stmt);
- stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_PLAYER_GM_TICKETS);
- stmt->setUInt32(0, guid);
- trans->Append(stmt);
+ if (sWorld->getBoolConfig(CONFIG_DELETE_CHARACTER_TICKET_TRACE))
+ {
+ stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_PLAYER_GM_TICKETS_ON_CHAR_DELETION);
+ stmt->setUInt32(0, guid);
+ trans->Append(stmt);
+ }
+ else
+ {
+ stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_PLAYER_GM_TICKETS);
+ stmt->setUInt32(0, guid);
+ trans->Append(stmt);
+ }
stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_ITEM_INSTANCE_BY_OWNER);
stmt->setUInt32(0, guid);
@@ -4862,7 +4515,7 @@ void Player::DeleteFromDB(ObjectGuid playerguid, uint32 accountId, bool updateRe
if (updateRealmChars)
sWorld->UpdateRealmCharCount(accountId);
- sWorld->DeleteCharacterNameData(playerguid);
+ sWorld->DeleteCharacterInfo(playerguid);
}
/**
@@ -5164,12 +4817,13 @@ Corpse* Player::CreateCorpse()
}
}
+ // register for player, but not show
+ GetMap()->AddCorpse(corpse);
+
// we do not need to save corpses for BG/arenas
if (!GetMap()->IsBattlegroundOrArena())
corpse->SaveToDB();
- // register for player, but not show
- GetMap()->AddCorpse(corpse);
return corpse;
}
@@ -6916,7 +6570,7 @@ void Player::RewardReputation(Unit* victim, float rate)
{
// support for: Championing - http://www.wowwiki.com/Championing
Map const* map = GetMap();
- if (map && map->IsNonRaidDungeon())
+ if (map->IsNonRaidDungeon())
if (LFGDungeonEntry const* dungeon = GetLFGDungeon(map->GetId(), map->GetDifficulty()))
if (dungeon->reclevel == 80)
ChampioningFaction = GetChampioningFaction();
@@ -8097,7 +7751,7 @@ void Player::ApplyItemEquipSpell(Item* item, bool apply, bool form_change)
_Spell const& spellData = proto->Spells[i];
// no spell
- if (!spellData.SpellId)
+ if (spellData.SpellId <= 0)
continue;
// wrong triggering type
@@ -8225,7 +7879,7 @@ void Player::CastItemCombatSpell(Unit* target, WeaponAttackType attType, uint32
_Spell const& spellData = proto->Spells[i];
// no spell
- if (!spellData.SpellId)
+ if (spellData.SpellId <= 0)
continue;
// wrong triggering type
@@ -8354,7 +8008,7 @@ void Player::CastItemUseSpell(Item* item, SpellCastTargets const& targets, uint8
_Spell const& spellData = proto->Spells[i];
// no spell
- if (!spellData.SpellId)
+ if (spellData.SpellId <= 0)
continue;
// wrong triggering type
@@ -15639,8 +15293,7 @@ bool Player::SatisfyQuestStatus(Quest const* qInfo, bool msg)
bool Player::SatisfyQuestConditions(Quest const* qInfo, bool msg)
{
- ConditionList conditions = sConditionMgr->GetConditionsForNotGroupedEntry(CONDITION_SOURCE_TYPE_QUEST_ACCEPT, qInfo->GetQuestId());
- if (!sConditionMgr->IsObjectMeetToConditions(this, conditions))
+ if (!sConditionMgr->IsObjectMeetingNotGroupedConditions(CONDITION_SOURCE_TYPE_QUEST_ACCEPT, qInfo->GetQuestId(), this))
{
if (msg)
{
@@ -15906,6 +15559,17 @@ bool Player::GetQuestRewardStatus(uint32 quest_id) const
Quest const* qInfo = sObjectMgr->GetQuestTemplate(quest_id);
if (qInfo)
{
+ if (qInfo->IsSeasonal() && !qInfo->IsRepeatable())
+ {
+ uint16 eventId = sGameEventMgr->GetEventIdForQuest(qInfo);
+ auto seasonalQuestItr = m_seasonalquests.find(eventId);
+ if (seasonalQuestItr != m_seasonalquests.end())
+ return seasonalQuestItr->second.find(quest_id) != seasonalQuestItr->second.end();
+
+ return false;
+ }
+
+
// for repeatable quests: rewarded field is set after first reward only to prevent getting XP more than once
if (!qInfo->IsRepeatable())
return m_RewardedQuests.find(quest_id) != m_RewardedQuests.end();
@@ -15924,8 +15588,18 @@ QuestStatus Player::GetQuestStatus(uint32 quest_id) const
return itr->second.Status;
if (Quest const* qInfo = sObjectMgr->GetQuestTemplate(quest_id))
+ {
+ if (qInfo->IsSeasonal() && !qInfo->IsRepeatable())
+ {
+ uint16 eventId = sGameEventMgr->GetEventIdForQuest(qInfo);
+ auto seasonalQuestItr = m_seasonalquests.find(eventId);
+ if (seasonalQuestItr == m_seasonalquests.end() || seasonalQuestItr->second.find(quest_id) == seasonalQuestItr->second.end())
+ return QUEST_STATUS_NONE;
+ }
+
if (!qInfo->IsRepeatable() && m_RewardedQuests.find(quest_id) != m_RewardedQuests.end())
return QUEST_STATUS_REWARDED;
+ }
}
return QUEST_STATUS_NONE;
}
@@ -16052,8 +15726,7 @@ QuestGiverStatus Player::GetQuestDialogStatus(Object* questgiver)
if (!quest)
continue;
- ConditionList conditions = sConditionMgr->GetConditionsForNotGroupedEntry(CONDITION_SOURCE_TYPE_QUEST_SHOW_MARK, quest->GetQuestId());
- if (!sConditionMgr->IsObjectMeetToConditions(this, conditions))
+ if (!sConditionMgr->IsObjectMeetingNotGroupedConditions(CONDITION_SOURCE_TYPE_QUEST_SHOW_MARK, quest->GetQuestId(), this))
continue;
QuestStatus status = GetQuestStatus(questId);
@@ -16080,8 +15753,7 @@ QuestGiverStatus Player::GetQuestDialogStatus(Object* questgiver)
if (!quest)
continue;
- ConditionList conditions = sConditionMgr->GetConditionsForNotGroupedEntry(CONDITION_SOURCE_TYPE_QUEST_SHOW_MARK, quest->GetQuestId());
- if (!sConditionMgr->IsObjectMeetToConditions(this, conditions))
+ if (!sConditionMgr->IsObjectMeetingNotGroupedConditions(CONDITION_SOURCE_TYPE_QUEST_SHOW_MARK, quest->GetQuestId(), this))
continue;
QuestStatus status = GetQuestStatus(questId);
@@ -17097,7 +16769,7 @@ bool Player::LoadFromDB(ObjectGuid guid, SQLQueryHolder *holder)
m_name = fields[2].GetString();
// check name limitations
- if (ObjectMgr::CheckPlayerName(m_name) != CHAR_NAME_SUCCESS ||
+ if (ObjectMgr::CheckPlayerName(m_name, GetSession()->GetSessionDbcLocale()) != CHAR_NAME_SUCCESS ||
(!GetSession()->HasPermission(rbac::RBAC_PERM_SKIP_CHECK_CHARACTER_CREATION_RESERVEDNAME) &&
sObjectMgr->IsReservedName(m_name)))
{
@@ -17433,7 +17105,7 @@ bool Player::LoadFromDB(ObjectGuid guid, SQLQueryHolder *holder)
}
else if (map->IsDungeon()) // if map is dungeon...
{
- if (!((InstanceMap*)map)->CanEnter(this)) // ... and can't enter map, then look for entry point.
+ if (!((InstanceMap*)map)->CanEnter(this) || !CheckInstanceLoginValid(map)) // ... and can't enter map, then look for entry point.
{
areaTrigger = sObjectMgr->GetGoBackTrigger(mapId);
check = true;
@@ -17460,6 +17132,7 @@ bool Player::LoadFromDB(ObjectGuid guid, SQLQueryHolder *holder)
{
TC_LOG_ERROR("entities.player", "Player %s %s Map: %u, X: %f, Y: %f, Z: %f, O: %f. Areatrigger not found.",
m_name.c_str(), guid.ToString().c_str(), mapId, GetPositionX(), GetPositionY(), GetPositionZ(), GetOrientation());
+ RelocateToHomebind();
map = NULL;
}
}
@@ -18808,9 +18481,11 @@ void Player::BindToInstance()
WorldPacket data(SMSG_INSTANCE_SAVE_CREATED, 4);
data << uint32(0);
GetSession()->SendPacket(&data);
- BindToInstance(mapSave, true);
-
- GetSession()->SendCalendarRaidLockout(mapSave, true);
+ if (!IsGameMaster())
+ {
+ BindToInstance(mapSave, true);
+ GetSession()->SendCalendarRaidLockout(mapSave, true);
+ }
}
void Player::SetPendingBind(uint32 instanceId, uint32 bindTimer)
@@ -18990,15 +18665,12 @@ bool Player::Satisfy(AccessRequirement const* ar, uint32 target_map, bool report
return true;
}
-bool Player::CheckInstanceLoginValid()
+bool Player::CheckInstanceLoginValid(Map* map)
{
- if (!FindMap())
- return false;
-
- if (!GetMap()->IsDungeon() || IsGameMaster())
+ if (!map->IsDungeon() || IsGameMaster())
return true;
- if (GetMap()->IsRaid())
+ if (map->IsRaid())
{
// cannot be in raid instance without a group
if (!GetGroup())
@@ -19007,12 +18679,12 @@ bool Player::CheckInstanceLoginValid()
else
{
// cannot be in normal instance without a group and more players than 1 in instance
- if (!GetGroup() && GetMap()->GetPlayersCountExceptGMs() > 1)
+ if (!GetGroup() && map->GetPlayersCountExceptGMs() > 1)
return false;
}
// do checks for satisfy accessreqs, instance full, encounter in progress (raid), perm bind group != perm bind player
- return sMapMgr->CanPlayerEnter(GetMap()->GetId(), this, true);
+ return sMapMgr->CanPlayerEnter(map->GetId(), this, true);
}
bool Player::CheckInstanceCount(uint32 instanceId) const
@@ -19125,7 +18797,7 @@ void Player::SaveToDB(bool create /*=false*/)
stmt->setString(index++, GetName());
stmt->setUInt8(index++, getRace());
stmt->setUInt8(index++, getClass());
- stmt->setUInt8(index++, getGender());
+ stmt->setUInt8(index++, GetByteValue(PLAYER_BYTES_3, 0)); // save gender from PLAYER_BYTES_3, UNIT_BYTES_0 changes with every transform effect
stmt->setUInt8(index++, getLevel());
stmt->setUInt32(index++, GetUInt32Value(PLAYER_XP));
stmt->setUInt32(index++, GetMoney());
@@ -19230,7 +18902,7 @@ void Player::SaveToDB(bool create /*=false*/)
stmt->setString(index++, GetName());
stmt->setUInt8(index++, getRace());
stmt->setUInt8(index++, getClass());
- stmt->setUInt8(index++, getGender());
+ stmt->setUInt8(index++, GetByteValue(PLAYER_BYTES_3, 0)); // save gender from PLAYER_BYTES_3, UNIT_BYTES_0 changes with every transform effect
stmt->setUInt8(index++, getLevel());
stmt->setUInt32(index++, GetUInt32Value(PLAYER_XP));
stmt->setUInt32(index++, GetMoney());
@@ -20241,7 +19913,7 @@ void Player::ResetInstances(uint8 method, bool isRaid)
// if the map is loaded, reset it
Map* map = sMapMgr->FindMap(p->GetMapId(), p->GetInstanceId());
if (map && map->IsDungeon())
- if (!((InstanceMap*)map)->Reset(method))
+ if (!map->ToInstanceMap()->Reset(method))
{
++itr;
continue;
@@ -20662,8 +20334,7 @@ void Player::VehicleSpellInitialize()
continue;
}
- ConditionList conditions = sConditionMgr->GetConditionsForVehicleSpell(vehicle->GetEntry(), spellId);
- if (!sConditionMgr->IsObjectMeetToConditions(this, vehicle, conditions))
+ if (!sConditionMgr->IsObjectMeetingVehicleSpellConditions(vehicle->GetEntry(), spellId, this, vehicle))
{
TC_LOG_DEBUG("condition", "VehicleSpellInitialize: conditions not met for Vehicle entry %u spell %u", vehicle->ToCreature()->GetEntry(), spellId);
data << uint16(0) << uint8(0) << uint8(i+8);
@@ -21394,7 +21065,7 @@ void Player::InitDisplayIds()
PlayerInfo const* info = sObjectMgr->GetPlayerInfo(getRace(), getClass());
if (!info)
{
- TC_LOG_ERROR("entities.player", "Player %u has incorrect race/class pair. Can't init display ids.", GetGUID().GetCounter());
+ TC_LOG_ERROR("entities.player", "Player %s (%s) has incorrect race/class pair. Can't init display ids.", GetName().c_str(), GetGUID().ToString().c_str());
return;
}
@@ -21410,8 +21081,7 @@ void Player::InitDisplayIds()
SetNativeDisplayId(info->displayId_m);
break;
default:
- TC_LOG_ERROR("entities.player", "Invalid gender %u for player", gender);
- return;
+ TC_LOG_ERROR("entities.player", "Player %s (%s) has invalid gender %u", GetName().c_str(), GetGUID().ToString().c_str(), gender);
}
}
@@ -21515,8 +21185,7 @@ bool Player::BuyItemFromVendorSlot(ObjectGuid vendorguid, uint32 vendorslot, uin
return false;
}
- ConditionList conditions = sConditionMgr->GetConditionsForNpcVendorEvent(creature->GetEntry(), item);
- if (!sConditionMgr->IsObjectMeetToConditions(this, creature, conditions))
+ if (!sConditionMgr->IsObjectMeetingVendorItemConditions(creature->GetEntry(), item, this, creature))
{
TC_LOG_DEBUG("condition", "BuyItemFromVendor: conditions not met for creature entry %u item %u", creature->GetEntry(), item);
SendBuyError(BUY_ERR_CANT_FIND_ITEM, creature, item, 0);
@@ -22031,6 +21700,16 @@ void Player::LeaveBattleground(bool teleportToEntryPoint)
CastSpell(this, 26013, true); // Deserter
}
}
+
+ // track if player leaves the BG while inside it
+ if (bg->isBattleground() && sWorld->getBoolConfig(CONFIG_BATTLEGROUND_TRACK_DESERTERS) &&
+ (bg->GetStatus() == STATUS_IN_PROGRESS || bg->GetStatus() == STATUS_WAIT_JOIN))
+ {
+ PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_DESERTER_TRACK);
+ stmt->setUInt32(0, GetGUID().GetCounter());
+ stmt->setUInt8(1, BG_DESERTION_TYPE_LEAVE_BG);
+ CharacterDatabase.Execute(stmt);
+ }
}
}
@@ -22685,7 +22364,7 @@ void Player::ApplyEquipCooldown(Item* pItem)
_Spell const& spellData = pItem->GetTemplate()->Spells[i];
// no spell
- if (!spellData.SpellId)
+ if (spellData.SpellId <= 0)
continue;
// wrong triggering type (note: ITEM_SPELLTRIGGER_ON_NO_DELAY_USE not have cooldown)
@@ -22693,7 +22372,7 @@ void Player::ApplyEquipCooldown(Item* pItem)
continue;
// Don't replace longer cooldowns by equip cooldown if we have any.
- if (GetSpellHistory()->GetRemainingCooldown(spellData.SpellId) > 30 * IN_MILLISECONDS)
+ if (GetSpellHistory()->GetRemainingCooldown(sSpellMgr->EnsureSpellInfo(spellData.SpellId)) > 30 * IN_MILLISECONDS)
continue;
GetSpellHistory()->AddCooldown(spellData.SpellId, pItem->GetEntry(), std::chrono::seconds(30));
@@ -22967,9 +22646,9 @@ void Player::LearnSkillRewardedSpells(uint32 skillId, uint32 skillValue)
RemoveSpell(ability->spellId);
// need learn
else if (!IsInWorld())
- AddSpell(ability->spellId, true, true, true, false, false, true);
+ AddSpell(ability->spellId, true, true, true, false, false, ability->skillId);
else
- LearnSpell(ability->spellId, true, true);
+ LearnSpell(ability->spellId, true, ability->skillId);
}
}
@@ -23320,16 +22999,18 @@ void Player::UpdateForQuestWorldObjects()
{
//! This code doesn't look right, but it was logically converted to condition system to do the exact
//! same thing it did before. It definitely needs to be overlooked for intended functionality.
- ConditionList conds = sConditionMgr->GetConditionsForSpellClickEvent(obj->GetEntry(), _itr->second.spellId);
- bool buildUpdateBlock = false;
- for (ConditionList::const_iterator jtr = conds.begin(); jtr != conds.end() && !buildUpdateBlock; ++jtr)
- if ((*jtr)->ConditionType == CONDITION_QUESTREWARDED || (*jtr)->ConditionType == CONDITION_QUESTTAKEN)
- buildUpdateBlock = true;
-
- if (buildUpdateBlock)
+ if (ConditionContainer const* conds = sConditionMgr->GetConditionsForSpellClickEvent(obj->GetEntry(), _itr->second.spellId))
{
- obj->BuildValuesUpdateBlockForPlayer(&udata, this);
- break;
+ bool buildUpdateBlock = false;
+ for (ConditionContainer::const_iterator jtr = conds->begin(); jtr != conds->end() && !buildUpdateBlock; ++jtr)
+ if ((*jtr)->ConditionType == CONDITION_QUESTREWARDED || (*jtr)->ConditionType == CONDITION_QUESTTAKEN)
+ buildUpdateBlock = true;
+
+ if (buildUpdateBlock)
+ {
+ obj->BuildValuesUpdateBlockForPlayer(&udata, this);
+ break;
+ }
}
}
}
@@ -25254,9 +24935,7 @@ bool Player::CanSeeSpellClickOn(Creature const* c) const
if (!itr->second.IsFitToRequirements(this, c))
return false;
- ConditionList conds = sConditionMgr->GetConditionsForSpellClickEvent(c->GetEntry(), itr->second.spellId);
- ConditionSourceInfo info = ConditionSourceInfo(const_cast<Player*>(this), const_cast<Creature*>(c));
- if (sConditionMgr->IsObjectMeetToConditions(info, conds))
+ if (sConditionMgr->IsObjectMeetingSpellClickConditions(c->GetEntry(), itr->second.spellId, const_cast<Player*>(this), const_cast<Creature*>(c)))
return true;
}
diff --git a/src/server/game/Entities/Player/Player.h b/src/server/game/Entities/Player/Player.h
index 17176786085..2a9dfc49280 100644
--- a/src/server/game/Entities/Player/Player.h
+++ b/src/server/game/Entities/Player/Player.h
@@ -29,6 +29,7 @@
#include "SpellMgr.h"
#include "SpellHistory.h"
#include "Unit.h"
+#include "TradeData.h"
#include <limits>
#include <string>
@@ -687,14 +688,6 @@ struct ItemPosCount
};
typedef std::vector<ItemPosCount> ItemPosCountVec;
-enum TradeSlots
-{
- TRADE_SLOT_COUNT = 7,
- TRADE_SLOT_TRADED_COUNT = 6,
- TRADE_SLOT_NONTRADED = 6,
- TRADE_SLOT_INVALID = -1
-};
-
enum TransferAbortReason
{
TRANSFER_ABORT_NONE = 0x00,
@@ -1007,88 +1000,6 @@ struct TradeStatusInfo
uint8 Slot;
};
-class TradeData
-{
- public: // constructors
- TradeData(Player* player, Player* trader) :
- m_player(player), m_trader(trader), m_accepted(false), m_acceptProccess(false),
- m_money(0), m_spell(0), m_spellCastItem() { }
-
- Player* GetTrader() const { return m_trader; }
- TradeData* GetTraderData() const;
-
- Item* GetItem(TradeSlots slot) const;
- bool HasItem(ObjectGuid itemGuid) const;
- TradeSlots GetTradeSlotForItem(ObjectGuid itemGuid) const;
- void SetItem(TradeSlots slot, Item* item);
-
- uint32 GetSpell() const { return m_spell; }
- void SetSpell(uint32 spell_id, Item* castItem = NULL);
-
- Item* GetSpellCastItem() const;
- bool HasSpellCastItem() const { return !m_spellCastItem.IsEmpty(); }
-
- uint32 GetMoney() const { return m_money; }
- void SetMoney(uint32 money);
-
- bool IsAccepted() const { return m_accepted; }
- void SetAccepted(bool state, bool crosssend = false);
-
- bool IsInAcceptProcess() const { return m_acceptProccess; }
- void SetInAcceptProcess(bool state) { m_acceptProccess = state; }
-
- private: // internal functions
-
- void Update(bool for_trader = true);
-
- private: // fields
-
- Player* m_player; // Player who own of this TradeData
- Player* m_trader; // Player who trade with m_player
-
- bool m_accepted; // m_player press accept for trade list
- bool m_acceptProccess; // one from player/trader press accept and this processed
-
- uint32 m_money; // m_player place money to trade
-
- uint32 m_spell; // m_player apply spell to non-traded slot item
- ObjectGuid m_spellCastItem; // applied spell cast by item use
-
- ObjectGuid m_items[TRADE_SLOT_COUNT]; // traded items from m_player side including non-traded slot
-};
-
-class KillRewarder
-{
-public:
- KillRewarder(Player* killer, Unit* victim, bool isBattleGround);
-
- void Reward();
-
-private:
- void _InitXP(Player* player);
- void _InitGroupData();
-
- void _RewardHonor(Player* player);
- void _RewardXP(Player* player, float rate);
- void _RewardReputation(Player* player, float rate);
- void _RewardKillCredit(Player* player);
- void _RewardPlayer(Player* player, bool isDungeon);
- void _RewardGroup();
-
- Player* _killer;
- Unit* _victim;
- Group* _group;
- float _groupRate;
- Player* _maxNotGrayMember;
- uint32 _count;
- uint32 _sumLevel;
- uint32 _xp;
- bool _isFullXP;
- uint8 _maxLevel;
- bool _isBattleGround;
- bool _isPvP;
-};
-
class Player : public Unit, public GridObject<Player>
{
friend class WorldSession;
@@ -1325,7 +1236,7 @@ class Player : public Unit, public GridObject<Player>
float GetReputationPriceDiscount(Creature const* creature) const;
- Player* GetTrader() const { return m_trade ? m_trade->GetTrader() : NULL; }
+ Player* GetTrader() const { return m_trade ? m_trade->GetTrader() : nullptr; }
TradeData* GetTradeData() const { return m_trade; }
void TradeCancel(bool sendback);
@@ -1595,8 +1506,8 @@ class Player : public Unit, public GridObject<Player>
void SendProficiency(ItemClass itemClass, uint32 itemSubclassMask);
void SendInitialSpells();
- bool AddSpell(uint32 spellId, bool active, bool learning, bool dependent, bool disabled, bool loading = false, bool fromSkill = false);
- void LearnSpell(uint32 spell_id, bool dependent, bool fromSkill = false);
+ bool AddSpell(uint32 spellId, bool active, bool learning, bool dependent, bool disabled, bool loading = false, uint32 fromSkill = 0);
+ void LearnSpell(uint32 spell_id, bool dependent, uint32 fromSkill = 0);
void RemoveSpell(uint32 spell_id, bool disabled = false, bool learn_low_rank = true);
void ResetSpells(bool myClassOnly = false);
void LearnCustomSpells();
@@ -1947,6 +1858,12 @@ class Player : public Unit, public GridObject<Player>
void SetHonorPoints(uint32 value);
void SetArenaPoints(uint32 value);
+ // duel health and mana reset methods
+ void SaveHealthBeforeDuel() { healthBeforeDuel = GetHealth(); }
+ void SaveManaBeforeDuel() { manaBeforeDuel = GetPower(POWER_MANA); }
+ void RestoreHealthAfterDuel() { SetHealth(healthBeforeDuel); }
+ void RestoreManaAfterDuel() { SetPower(POWER_MANA, manaBeforeDuel); }
+
//End of PvP System
void SetDrunkValue(uint8 newDrunkValue, uint32 itemId = 0);
@@ -2198,7 +2115,7 @@ class Player : public Unit, public GridObject<Player>
void SendSavedInstances();
static void ConvertInstancesToGroup(Player* player, Group* group, bool switchLeader);
bool Satisfy(AccessRequirement const* ar, uint32 target_map, bool report = false);
- bool CheckInstanceLoginValid();
+ bool CheckInstanceLoginValid(Map* map);
bool CheckInstanceCount(uint32 instanceId) const;
void AddInstanceEnterTime(uint32 instanceId, time_t enterTime);
@@ -2370,7 +2287,6 @@ class Player : public Unit, public GridObject<Player>
void _LoadGroup(PreparedQueryResult result);
void _LoadSkills(PreparedQueryResult result);
void _LoadSpells(PreparedQueryResult result);
- void _LoadFriendList(PreparedQueryResult result);
bool _LoadHomeBind(PreparedQueryResult result);
void _LoadDeclinedNames(PreparedQueryResult result);
void _LoadArenaTeamInfo(PreparedQueryResult result);
@@ -2631,6 +2547,10 @@ class Player : public Unit, public GridObject<Player>
uint32 _activeCheats;
+ // variables to save health and mana before duel and restore them after duel
+ uint32 healthBeforeDuel;
+ uint32 manaBeforeDuel;
+
WorldLocation _corpseLocation;
};
diff --git a/src/server/game/Entities/Player/TradeData.cpp b/src/server/game/Entities/Player/TradeData.cpp
new file mode 100644
index 00000000000..bbbd1c81773
--- /dev/null
+++ b/src/server/game/Entities/Player/TradeData.cpp
@@ -0,0 +1,139 @@
+/*
+ * Copyright (C) 2008-2015 TrinityCore <http://www.trinitycore.org/>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2 of the License, or (at your
+ * option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "TradeData.h"
+#include "Player.h"
+#include "WorldSession.h"
+
+TradeData* TradeData::GetTraderData() const
+{
+ return _trader->GetTradeData();
+}
+
+Item* TradeData::GetItem(TradeSlots slot) const
+{
+ return !_items[slot].IsEmpty() ? _player->GetItemByGuid(_items[slot]) : nullptr;
+}
+
+bool TradeData::HasItem(ObjectGuid itemGuid) const
+{
+ for (uint8 i = 0; i < TRADE_SLOT_COUNT; ++i)
+ if (_items[i] == itemGuid)
+ return true;
+
+ return false;
+}
+
+TradeSlots TradeData::GetTradeSlotForItem(ObjectGuid itemGuid) const
+{
+ for (uint8 i = 0; i < TRADE_SLOT_COUNT; ++i)
+ if (_items[i] == itemGuid)
+ return TradeSlots(i);
+
+ return TRADE_SLOT_INVALID;
+}
+
+Item* TradeData::GetSpellCastItem() const
+{
+ return !_spellCastItem.IsEmpty() ? _player->GetItemByGuid(_spellCastItem) : nullptr;
+}
+
+void TradeData::SetItem(TradeSlots slot, Item* item, bool update /*= false*/)
+{
+ ObjectGuid itemGuid;
+ if (item)
+ itemGuid = item->GetGUID();
+
+ if (_items[slot] == itemGuid && !update)
+ return;
+
+ _items[slot] = itemGuid;
+
+ SetAccepted(false);
+ GetTraderData()->SetAccepted(false);
+
+ Update();
+
+ // need remove possible trader spell applied to changed item
+ if (slot == TRADE_SLOT_NONTRADED)
+ GetTraderData()->SetSpell(0);
+
+ // need remove possible player spell applied (possible move reagent)
+ SetSpell(0);
+}
+
+void TradeData::SetSpell(uint32 spell_id, Item* castItem /*= nullptr*/)
+{
+ ObjectGuid itemGuid = castItem ? castItem->GetGUID() : ObjectGuid::Empty;
+
+ if (_spell == spell_id && _spellCastItem == itemGuid)
+ return;
+
+ _spell = spell_id;
+ _spellCastItem = itemGuid;
+
+ SetAccepted(false);
+ GetTraderData()->SetAccepted(false);
+
+ Update(true); // send spell info to item owner
+ Update(false); // send spell info to caster self
+}
+
+void TradeData::SetMoney(uint32 money)
+{
+ if (_money == money)
+ return;
+
+ if (!_player->HasEnoughMoney(money))
+ {
+ TradeStatusInfo info;
+ info.Status = TRADE_STATUS_CLOSE_WINDOW;
+ info.Result = EQUIP_ERR_NOT_ENOUGH_MONEY;
+ _player->GetSession()->SendTradeStatus(info);
+ return;
+ }
+
+ _money = money;
+
+ SetAccepted(false);
+ GetTraderData()->SetAccepted(false);
+
+ Update(true);
+}
+
+void TradeData::Update(bool forTrader /*= true*/) const
+{
+ if (forTrader)
+ _trader->GetSession()->SendUpdateTrade(true); // player state for trader
+ else
+ _player->GetSession()->SendUpdateTrade(false); // player state for player
+}
+
+void TradeData::SetAccepted(bool state, bool forTrader /*= false*/)
+{
+ _accepted = state;
+
+ if (!state)
+ {
+ TradeStatusInfo info;
+ info.Status = TRADE_STATUS_BACK_TO_TRADE;
+ if (forTrader)
+ _trader->GetSession()->SendTradeStatus(info);
+ else
+ _player->GetSession()->SendTradeStatus(info);
+ }
+}
diff --git a/src/server/game/Entities/Player/TradeData.h b/src/server/game/Entities/Player/TradeData.h
new file mode 100644
index 00000000000..cfaf066bde0
--- /dev/null
+++ b/src/server/game/Entities/Player/TradeData.h
@@ -0,0 +1,81 @@
+/*
+ * Copyright (C) 2008-2015 TrinityCore <http://www.trinitycore.org/>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2 of the License, or (at your
+ * option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef TradeData_h__
+#define TradeData_h__
+
+#include "ObjectGuid.h"
+
+enum TradeSlots
+{
+ TRADE_SLOT_COUNT = 7,
+ TRADE_SLOT_TRADED_COUNT = 6,
+ TRADE_SLOT_NONTRADED = 6,
+ TRADE_SLOT_INVALID = -1
+};
+
+class Item;
+class Player;
+
+class TradeData
+{
+public:
+ TradeData(Player* player, Player* trader) :
+ _player(player), _trader(trader), _accepted(false), _acceptProccess(false),
+ _money(0), _spell(0), _spellCastItem() { }
+
+ Player* GetTrader() const { return _trader; }
+ TradeData* GetTraderData() const;
+
+ Item* GetItem(TradeSlots slot) const;
+ bool HasItem(ObjectGuid itemGuid) const;
+ TradeSlots GetTradeSlotForItem(ObjectGuid itemGuid) const;
+ void SetItem(TradeSlots slot, Item* item, bool update = false);
+
+ uint32 GetSpell() const { return _spell; }
+ void SetSpell(uint32 spell_id, Item* castItem = nullptr);
+
+ Item* GetSpellCastItem() const;
+ bool HasSpellCastItem() const { return !_spellCastItem.IsEmpty(); }
+
+ uint32 GetMoney() const { return _money; }
+ void SetMoney(uint32 money);
+
+ bool IsAccepted() const { return _accepted; }
+ void SetAccepted(bool state, bool forTrader = false);
+
+ bool IsInAcceptProcess() const { return _acceptProccess; }
+ void SetInAcceptProcess(bool state) { _acceptProccess = state; }
+
+private:
+ void Update(bool for_trader = true) const;
+
+ Player* _player; // Player who own of this TradeData
+ Player* _trader; // Player who trade with _player
+
+ bool _accepted; // _player press accept for trade list
+ bool _acceptProccess; // one from player/trader press accept and this processed
+
+ uint32 _money; // _player place money to trade
+
+ uint32 _spell; // _player apply spell to non-traded slot item
+ ObjectGuid _spellCastItem; // applied spell cast by item use
+
+ ObjectGuid _items[TRADE_SLOT_COUNT]; // traded items from _player side including non-traded slot
+};
+
+#endif // TradeData_h__
diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp
index 0de88a62f02..b6ae38dc52c 100644
--- a/src/server/game/Entities/Unit/Unit.cpp
+++ b/src/server/game/Entities/Unit/Unit.cpp
@@ -13445,7 +13445,7 @@ void Unit::SetLevel(uint8 lvl)
if (player->GetGroup())
player->SetGroupUpdateFlag(GROUP_UPDATE_FLAG_LEVEL);
- sWorld->UpdateCharacterNameDataLevel(GetGUID(), lvl);
+ sWorld->UpdateCharacterInfoLevel(GetGUID(), lvl);
}
}
@@ -13792,7 +13792,7 @@ void CharmInfo::InitPossessCreateSpells()
{
uint32 spellId = _unit->ToCreature()->m_spells[i];
SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellId);
- if (spellInfo && !spellInfo->HasAttribute(SPELL_ATTR0_CASTABLE_WHILE_DEAD))
+ if (spellInfo)
{
if (spellInfo->IsPassive())
_unit->CastSpell(_unit, spellInfo, true);
@@ -13820,7 +13820,7 @@ void CharmInfo::InitCharmCreateSpells()
uint32 spellId = _unit->ToCreature()->m_spells[x];
SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellId);
- if (!spellInfo || spellInfo->HasAttribute(SPELL_ATTR0_CASTABLE_WHILE_DEAD))
+ if (!spellInfo)
{
_charmspells[x].SetActionAndType(spellId, ACT_DISABLED);
continue;
@@ -14197,9 +14197,7 @@ void Unit::ProcDamageAndSpellFor(bool isVictim, Unit* target, uint32 procFlag, u
continue;
// do checks using conditions table
- ConditionList conditions = sConditionMgr->GetConditionsForNotGroupedEntry(CONDITION_SOURCE_TYPE_SPELL_PROC, spellProto->Id);
- ConditionSourceInfo condInfo = ConditionSourceInfo(eventInfo.GetActor(), eventInfo.GetActionTarget());
- if (!sConditionMgr->IsObjectMeetToConditions(condInfo, conditions))
+ if (!sConditionMgr->IsObjectMeetingNotGroupedConditions(CONDITION_SOURCE_TYPE_SPELL_PROC, spellProto->Id, eventInfo.GetActor(), eventInfo.GetActionTarget()))
continue;
// AuraScript Hook
@@ -14668,6 +14666,9 @@ bool Unit::IsPolymorphed() const
void Unit::SetDisplayId(uint32 modelId)
{
SetUInt32Value(UNIT_FIELD_DISPLAYID, modelId);
+ // Set Gender by modelId
+ if (CreatureModelInfo const* minfo = sObjectMgr->GetCreatureModelInfo(modelId))
+ SetByteValue(UNIT_FIELD_BYTES_0, 2, minfo->gender);
}
void Unit::RestoreDisplayId()
@@ -16900,9 +16901,7 @@ bool Unit::HandleSpellClick(Unit* clicker, int8 seatId)
continue;
//! Check database conditions
- ConditionList conds = sConditionMgr->GetConditionsForSpellClickEvent(spellClickEntry, itr->second.spellId);
- ConditionSourceInfo info = ConditionSourceInfo(clicker, this);
- if (!sConditionMgr->IsObjectMeetToConditions(info, conds))
+ if (!sConditionMgr->IsObjectMeetingSpellClickConditions(spellClickEntry, itr->second.spellId, clicker, this))
continue;
Unit* caster = (itr->second.castFlags & NPC_CLICK_CAST_CASTER_CLICKER) ? clicker : this;
diff --git a/src/server/game/Globals/ObjectMgr.cpp b/src/server/game/Globals/ObjectMgr.cpp
index db352ec80dd..b2be5c49b91 100644
--- a/src/server/game/Globals/ObjectMgr.cpp
+++ b/src/server/game/Globals/ObjectMgr.cpp
@@ -291,8 +291,8 @@ void ObjectMgr::LoadCreatureLocales()
_creatureLocaleStore.clear(); // need for reload case
- QueryResult result = WorldDatabase.Query("SELECT entry, name_loc1, subname_loc1, name_loc2, subname_loc2, name_loc3, subname_loc3, name_loc4, subname_loc4, name_loc5, subname_loc5, name_loc6, subname_loc6, name_loc7, subname_loc7, name_loc8, subname_loc8 FROM locales_creature");
-
+ // 0 1 2 3
+ QueryResult result = WorldDatabase.Query("SELECT entry, locale, Name, Title FROM creature_template_locale");
if (!result)
return;
@@ -300,16 +300,20 @@ void ObjectMgr::LoadCreatureLocales()
{
Field* fields = result->Fetch();
- uint32 entry = fields[0].GetUInt32();
+ uint32 id = fields[0].GetUInt32();
+ std::string localeName = fields[1].GetString();
- CreatureLocale& data = _creatureLocaleStore[entry];
+ std::string name = fields[2].GetString();
+ std::string title = fields[3].GetString();
+
+ CreatureLocale& data = _creatureLocaleStore[id];
+ LocaleConstant locale = GetLocaleByName(localeName);
+ if (locale == LOCALE_enUS)
+ continue;
+
+ AddLocaleString(name, locale, data.Name);
+ AddLocaleString(title, locale, data.Title);
- for (uint8 i = TOTAL_LOCALES - 1; i > 0; --i)
- {
- LocaleConstant locale = (LocaleConstant) i;
- AddLocaleString(fields[1 + 2 * (i - 1)].GetString(), locale, data.Name);
- AddLocaleString(fields[1 + 2 * (i - 1) + 1].GetString(), locale, data.SubName);
- }
} while (result->NextRow());
TC_LOG_INFO("server.loading", ">> Loaded %u creature locale strings in %u ms", uint32(_creatureLocaleStore.size()), GetMSTimeDiffToNow(oldMSTime));
@@ -442,7 +446,7 @@ void ObjectMgr::LoadCreatureTemplate(Field* fields)
creatureTemplate.Modelid3 = fields[8].GetUInt32();
creatureTemplate.Modelid4 = fields[9].GetUInt32();
creatureTemplate.Name = fields[10].GetString();
- creatureTemplate.SubName = fields[11].GetString();
+ creatureTemplate.Title = fields[11].GetString();
creatureTemplate.IconName = fields[12].GetString();
creatureTemplate.GossipMenuId = fields[13].GetUInt32();
creatureTemplate.minlevel = fields[14].GetUInt8();
@@ -499,7 +503,7 @@ void ObjectMgr::LoadCreatureTemplate(Field* fields)
creatureTemplate.RegenHealth = fields[71].GetBool();
creatureTemplate.MechanicImmuneMask = fields[72].GetUInt32();
creatureTemplate.flags_extra = fields[73].GetUInt32();
- creatureTemplate.ScriptID = GetScriptId(fields[74].GetCString());
+ creatureTemplate.ScriptID = GetScriptId(fields[74].GetString());
}
void ObjectMgr::LoadCreatureTemplateAddons()
@@ -551,6 +555,12 @@ void ObjectMgr::LoadCreatureTemplateAddons()
if (AdditionalSpellInfo->HasAura(SPELL_AURA_CONTROL_VEHICLE))
TC_LOG_ERROR("sql.sql", "Creature (Entry: %u) has SPELL_AURA_CONTROL_VEHICLE aura %lu defined in `auras` field in `creature_template_addon`.", entry, atoul(*itr));
+ if (std::find(creatureAddon.auras.begin(), creatureAddon.auras.end(), atoul(*itr)) != creatureAddon.auras.end())
+ {
+ TC_LOG_ERROR("sql.sql", "Creature (Entry: %u) has duplicate aura (spell %lu) in `auras` field in `creature_template_addon`.", entry, atoul(*itr));
+ continue;
+ }
+
creatureAddon.auras[i++] = atoul(*itr);
}
@@ -999,6 +1009,12 @@ void ObjectMgr::LoadCreatureAddons()
if (AdditionalSpellInfo->HasAura(SPELL_AURA_CONTROL_VEHICLE))
TC_LOG_ERROR("sql.sql", "Creature (GUID: %u) has SPELL_AURA_CONTROL_VEHICLE aura %lu defined in `auras` field in `creature_addon`.", guid, atoul(*itr));
+ if (std::find(creatureAddon.auras.begin(), creatureAddon.auras.end(), atoul(*itr)) != creatureAddon.auras.end())
+ {
+ TC_LOG_ERROR("sql.sql", "Creature (GUID: %u) has duplicate aura (spell %lu) in `auras` field in `creature_addon`.", guid, atoul(*itr));
+ continue;
+ }
+
creatureAddon.auras[i++] = atoul(*itr);
}
@@ -2192,23 +2208,10 @@ uint32 ObjectMgr::GetPlayerTeamByGUID(ObjectGuid guid) const
uint32 ObjectMgr::GetPlayerAccountIdByGUID(ObjectGuid guid) const
{
- // prevent DB access for online player
- if (Player* player = ObjectAccessor::FindConnectedPlayer(guid))
- {
- return player->GetSession()->GetAccountId();
- }
+ if (CharacterInfo const* characterInfo = sWorld->GetCharacterInfo(guid))
+ return characterInfo->AccountId;
- PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_ACCOUNT_BY_GUID);
-
- stmt->setUInt32(0, guid.GetCounter());
- PreparedQueryResult result = CharacterDatabase.Query(stmt);
-
- if (result)
- {
- uint32 acc = (*result)[0].GetUInt32();
- return acc;
- }
return 0;
}
@@ -2344,6 +2347,12 @@ void ObjectMgr::LoadItemTemplates()
itemTemplate.ContainerSlots = uint32(fields[26].GetUInt8());
itemTemplate.StatsCount = uint32(fields[27].GetUInt8());
+ if (itemTemplate.StatsCount > MAX_ITEM_PROTO_STATS)
+ {
+ TC_LOG_ERROR("sql.sql", "Item (Entry: %u) has too large value in statscount (%u), replace by hardcoded limit (%u).", entry, itemTemplate.StatsCount, MAX_ITEM_PROTO_STATS);
+ itemTemplate.StatsCount = MAX_ITEM_PROTO_STATS;
+ }
+
for (uint8 i = 0; i < itemTemplate.StatsCount; ++i)
{
itemTemplate.ItemStat[i].ItemStatType = uint32(fields[28 + i*2].GetUInt8());
@@ -2414,7 +2423,7 @@ void ObjectMgr::LoadItemTemplates()
itemTemplate.Duration = fields[129].GetUInt32();
itemTemplate.ItemLimitCategory = uint32(fields[130].GetInt16());
itemTemplate.HolidayId = fields[131].GetUInt32();
- itemTemplate.ScriptId = sObjectMgr->GetScriptId(fields[132].GetCString());
+ itemTemplate.ScriptId = sObjectMgr->GetScriptId(fields[132].GetString());
itemTemplate.DisenchantID = fields[133].GetUInt32();
itemTemplate.FoodType = uint32(fields[134].GetUInt8());
itemTemplate.MinMoneyLoot = fields[135].GetUInt32();
@@ -2530,7 +2539,7 @@ void ObjectMgr::LoadItemTemplates()
if (!req)
for (uint8 j = 0; j < MAX_ITEM_PROTO_SPELLS; ++j)
{
- if (itemTemplate.Spells[j].SpellId)
+ if (itemTemplate.Spells[j].SpellId > 0)
{
req = true;
break;
@@ -2591,12 +2600,6 @@ void ObjectMgr::LoadItemTemplates()
itemTemplate.ContainerSlots = MAX_BAG_SIZE;
}
- if (itemTemplate.StatsCount > MAX_ITEM_PROTO_STATS)
- {
- TC_LOG_ERROR("sql.sql", "Item (Entry: %u) has too large value in statscount (%u), replace by hardcoded limit (%u).", entry, itemTemplate.StatsCount, MAX_ITEM_PROTO_STATS);
- itemTemplate.StatsCount = MAX_ITEM_PROTO_STATS;
- }
-
for (uint8 j = 0; j < itemTemplate.StatsCount; ++j)
{
// for ItemStatValue != 0
@@ -2715,15 +2718,6 @@ void ObjectMgr::LoadItemTemplates()
TC_LOG_ERROR("sql.sql", "Item (Entry: %u) has broken spell in spellid_%d (%d)", entry, j+1, itemTemplate.Spells[j].SpellId);
itemTemplate.Spells[j].SpellId = 0;
}
-
- if (spellInfo && itemTemplate.Spells[j].SpellCategory
- && itemTemplate.Spells[j].SpellCategory != SPELL_CATEGORY_FOOD)
- {
- bool added = sSpellsByCategoryStore[itemTemplate.Spells[j].SpellCategory].insert(itemTemplate.Spells[j].SpellId).second;
- if (added)
- TC_LOG_DEBUG("sql.sql", "Item(Entry: %u) spellid_%d (%d) category %u added to sSpellsByCategoryStore",
- entry, j + 1, itemTemplate.Spells[j].SpellId, itemTemplate.Spells[j].SpellCategory);
- }
}
}
}
@@ -5121,8 +5115,8 @@ void ObjectMgr::LoadSpellScriptNames()
Field* fields = result->Fetch();
- int32 spellId = fields[0].GetInt32();
- char const* scriptName = fields[1].GetCString();
+ int32 spellId = fields[0].GetInt32();
+ std::string const scriptName = fields[1].GetString();
bool allRanks = false;
if (spellId < 0)
@@ -5134,18 +5128,18 @@ void ObjectMgr::LoadSpellScriptNames()
SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellId);
if (!spellInfo)
{
- TC_LOG_ERROR("sql.sql", "Scriptname: `%s` spell (Id: %d) does not exist.", scriptName, spellId);
+ TC_LOG_ERROR("sql.sql", "Scriptname: `%s` spell (Id: %d) does not exist.", scriptName.c_str(), spellId);
continue;
}
if (allRanks)
{
if (!spellInfo->IsRanked())
- TC_LOG_ERROR("sql.sql", "Scriptname: `%s` spell (Id: %d) has no ranks of spell.", scriptName, fields[0].GetInt32());
+ TC_LOG_ERROR("sql.sql", "Scriptname: `%s` spell (Id: %d) has no ranks of spell.", scriptName.c_str(), fields[0].GetInt32());
if (spellInfo->GetFirstRankSpell()->Id != uint32(spellId))
{
- TC_LOG_ERROR("sql.sql", "Scriptname: `%s` spell (Id: %d) is not first rank of spell.", scriptName, fields[0].GetInt32());
+ TC_LOG_ERROR("sql.sql", "Scriptname: `%s` spell (Id: %d) is not first rank of spell.", scriptName.c_str(), fields[0].GetInt32());
continue;
}
@@ -5158,7 +5152,7 @@ void ObjectMgr::LoadSpellScriptNames()
else
{
if (spellInfo->IsRanked())
- TC_LOG_ERROR("sql.sql", "Scriptname: `%s` spell (Id: %d) is ranked spell. Perhaps not all ranks are assigned to this script.", scriptName, spellId);
+ TC_LOG_ERROR("sql.sql", "Scriptname: `%s` spell (Id: %d) is ranked spell. Perhaps not all ranks are assigned to this script.", scriptName.c_str(), spellId);
_spellScriptsStore.insert(SpellScriptsContainer::value_type(spellInfo->Id, GetScriptId(scriptName)));
}
@@ -5196,7 +5190,7 @@ void ObjectMgr::ValidateSpellScripts()
bool valid = true;
if (!spellScript && !auraScript)
{
- TC_LOG_ERROR("scripts", "Functions GetSpellScript() and GetAuraScript() of script `%s` do not return objects - script skipped", GetScriptName(sitr->second->second));
+ TC_LOG_ERROR("scripts", "Functions GetSpellScript() and GetAuraScript() of script `%s` do not return objects - script skipped", GetScriptName(sitr->second->second).c_str());
valid = false;
}
if (spellScript)
@@ -5332,7 +5326,7 @@ void ObjectMgr::LoadInstanceTemplate()
instanceTemplate.AllowMount = fields[3].GetBool();
instanceTemplate.Parent = uint32(fields[1].GetUInt16());
- instanceTemplate.ScriptId = sObjectMgr->GetScriptId(fields[2].GetCString());
+ instanceTemplate.ScriptId = sObjectMgr->GetScriptId(fields[2].GetString());
_instanceTemplateStore[mapID] = instanceTemplate;
@@ -5797,8 +5791,8 @@ void ObjectMgr::LoadAreaTriggerScripts()
{
Field* fields = result->Fetch();
- uint32 triggerId = fields[0].GetUInt32();
- char const* scriptName = fields[1].GetCString();
+ uint32 triggerId = fields[0].GetUInt32();
+ std::string const scriptName = fields[1].GetString();
AreaTriggerEntry const* atEntry = sAreaTriggerStore.LookupEntry(triggerId);
if (!atEntry)
@@ -6019,7 +6013,8 @@ WorldSafeLocsEntry const* ObjectMgr::GetClosestGraveYard(float x, float y, float
// not need to check validity of map object; MapId _MUST_ be valid here
if (range.first == range.second && !map->IsBattlegroundOrArena())
{
- TC_LOG_ERROR("sql.sql", "Table `game_graveyard_zone` incomplete: Zone %u Team %u does not have a linked graveyard.", zoneId, team);
+ if (zoneId != 0) // zone == 0 can't be fixed, used by bliz for bugged zones
+ TC_LOG_ERROR("sql.sql", "Table `game_graveyard_zone` incomplete: Zone %u Team %u does not have a linked graveyard.", zoneId, team);
return GetDefaultGraveYard(team);
}
@@ -6542,6 +6537,8 @@ void ObjectMgr::LoadGameObjectLocales()
GameObjectLocale& data = _gameObjectLocaleStore[id];
LocaleConstant locale = GetLocaleByName(localeName);
+ if (locale == LOCALE_enUS)
+ continue;
AddLocaleString(name, locale, data.Name);
AddLocaleString(castBarCaption, locale, data.CastBarCaption);
@@ -6653,7 +6650,7 @@ void ObjectMgr::LoadGameObjectTemplate()
got.raw.data[i] = fields[10 + i].GetInt32(); // data1 and data6 can be -1
got.AIName = fields[34].GetString();
- got.ScriptId = GetScriptId(fields[35].GetCString());
+ got.ScriptId = GetScriptId(fields[35].GetString());
// Checks
@@ -7584,7 +7581,7 @@ bool isValidString(const std::wstring& wstr, uint32 strictMask, bool numericOrSp
return false;
}
-ResponseCodes ObjectMgr::CheckPlayerName(const std::string& name, bool create)
+ResponseCodes ObjectMgr::CheckPlayerName(std::string const& name, LocaleConstant locale, bool create /*= false*/)
{
std::wstring wname;
if (!Utf8toWStr(name, wname))
@@ -7606,7 +7603,7 @@ ResponseCodes ObjectMgr::CheckPlayerName(const std::string& name, bool create)
if (wname[i] == wname[i-1] && wname[i] == wname[i-2])
return CHAR_NAME_THREE_CONSECUTIVE;
- return CHAR_NAME_SUCCESS;
+ return ValidateName(name, locale);
}
bool ObjectMgr::IsValidCharterName(const std::string& name)
@@ -7627,7 +7624,7 @@ bool ObjectMgr::IsValidCharterName(const std::string& name)
return isValidString(wname, strictMask, true);
}
-PetNameInvalidReason ObjectMgr::CheckPetName(const std::string& name)
+PetNameInvalidReason ObjectMgr::CheckPetName(const std::string& name, LocaleConstant locale)
{
std::wstring wname;
if (!Utf8toWStr(name, wname))
@@ -7644,6 +7641,17 @@ PetNameInvalidReason ObjectMgr::CheckPetName(const std::string& name)
if (!isValidString(wname, strictMask, false))
return PET_NAME_MIXED_LANGUAGES;
+ switch (ValidateName(name, locale))
+ {
+ case CHAR_NAME_PROFANE:
+ return PET_NAME_PROFANE;
+ case CHAR_NAME_RESERVED:
+ return PET_NAME_RESERVED;
+ case RESPONSE_FAILURE:
+ return PET_NAME_INVALID;
+ default:
+ break;
+ }
return PET_NAME_SUCCESS;
}
@@ -8590,11 +8598,18 @@ void ObjectMgr::LoadScriptNames()
TC_LOG_INFO("server.loading", ">> Loaded " SZFMTD " ScriptNames in %u ms", _scriptNamesStore.size(), GetMSTimeDiffToNow(oldMSTime));
}
-uint32 ObjectMgr::GetScriptId(char const* name)
+std::string const& ObjectMgr::GetScriptName(uint32 id) const
+{
+ static std::string const empty = "";
+ return id < _scriptNamesStore.size() ? _scriptNamesStore[id] : empty;
+}
+
+
+uint32 ObjectMgr::GetScriptId(std::string const& name)
{
// use binary search to find the script name in the sorted vector
// assume "" is the first element
- if (!name)
+ if (name.empty())
return 0;
ScriptNameContainer::const_iterator itr = std::lower_bound(_scriptNamesStore.begin(), _scriptNamesStore.end(), name);
diff --git a/src/server/game/Globals/ObjectMgr.h b/src/server/game/Globals/ObjectMgr.h
index cdd974fa013..396be440205 100644
--- a/src/server/game/Globals/ObjectMgr.h
+++ b/src/server/game/Globals/ObjectMgr.h
@@ -564,14 +564,14 @@ struct GossipMenuItems
uint32 BoxMoney;
std::string BoxText;
uint32 BoxBroadcastTextId;
- ConditionList Conditions;
+ ConditionContainer Conditions;
};
struct GossipMenus
{
uint32 entry;
uint32 text_id;
- ConditionList conditions;
+ ConditionContainer conditions;
};
typedef std::multimap<uint32, GossipMenus> GossipMenusContainer;
@@ -778,7 +778,7 @@ class ObjectMgr
* If the player is online, the name is retrieved immediately otherwise
* a database query is done.
*
- * @remark Use sWorld->GetCharacterNameData because it doesn't require a database query when player is offline
+ * @remark Use sWorld->GetCharacterInfo because it doesn't require a database query when player is offline
*
* @param guid player full guid
* @param name returned name
@@ -1230,8 +1230,8 @@ class ObjectMgr
bool IsReservedName(std::string const& name) const;
// name with valid structure and symbols
- static ResponseCodes CheckPlayerName(std::string const& name, bool create = false);
- static PetNameInvalidReason CheckPetName(std::string const& name);
+ static ResponseCodes CheckPlayerName(std::string const& name, LocaleConstant locale, bool create = false);
+ static PetNameInvalidReason CheckPetName(std::string const& name, LocaleConstant locale);
static bool IsValidCharterName(std::string const& name);
static bool CheckDeclinedNames(const std::wstring& w_ownname, DeclinedName const& names);
@@ -1270,8 +1270,8 @@ class ObjectMgr
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();
- char const* GetScriptName(uint32 id) const { return id < _scriptNamesStore.size() ? _scriptNamesStore[id].c_str() : ""; }
- uint32 GetScriptId(char const* name);
+ std::string const& GetScriptName(uint32 id) const;
+ uint32 GetScriptId(std::string const& name);
SpellClickInfoMapBounds GetSpellClickInfoMapBounds(uint32 creature_id) const
{
diff --git a/src/server/game/Grids/ObjectGridLoader.cpp b/src/server/game/Grids/ObjectGridLoader.cpp
index efbbf1abf72..2c292c43785 100644
--- a/src/server/game/Grids/ObjectGridLoader.cpp
+++ b/src/server/game/Grids/ObjectGridLoader.cpp
@@ -152,7 +152,12 @@ void ObjectWorldLoader::Visit(CorpseMapType& /*m*/)
for (Corpse* corpse : *corpses)
{
corpse->AddToWorld();
- i_grid.GetGridType(i_cell.CellX(), i_cell.CellY()).AddWorldObject(corpse);
+ GridType& cell = i_grid.GetGridType(i_cell.CellX(), i_cell.CellY());
+ if (corpse->IsWorldObject())
+ cell.AddWorldObject(corpse);
+ else
+ cell.AddGridObject(corpse);
+
++i_corpses;
}
}
@@ -230,7 +235,7 @@ void ObjectGridCleaner::Visit(GridRefManager<T> &m)
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 &);
diff --git a/src/server/game/Grids/ObjectGridLoader.h b/src/server/game/Grids/ObjectGridLoader.h
index 54dadaefdb3..126ebd0d0a3 100644
--- a/src/server/game/Grids/ObjectGridLoader.h
+++ b/src/server/game/Grids/ObjectGridLoader.h
@@ -82,6 +82,7 @@ class ObjectGridCleaner
class ObjectGridUnloader
{
public:
+ void Visit(CorpseMapType& /*m*/) { } // corpses are deleted with Map
template<class T> void Visit(GridRefManager<T> &m);
};
#endif
diff --git a/src/server/game/Handlers/BattleGroundHandler.cpp b/src/server/game/Handlers/BattleGroundHandler.cpp
index fec0b8e0d40..d4291e34df6 100644
--- a/src/server/game/Handlers/BattleGroundHandler.cpp
+++ b/src/server/game/Handlers/BattleGroundHandler.cpp
@@ -506,6 +506,16 @@ void WorldSession::HandleBattleFieldPortOpcode(WorldPacket &recvData)
sBattlegroundMgr->ScheduleQueueUpdate(ginfo.ArenaMatchmakerRating, ginfo.ArenaType, bgQueueTypeId, bgTypeId, bracketEntry->GetBracketId());
SendPacket(&data);
TC_LOG_DEBUG("bg.battleground", "Battleground: player %s (%u) left queue for bgtype %u, queue type %u.", _player->GetName().c_str(), _player->GetGUID().GetCounter(), bg->GetTypeID(), bgQueueTypeId);
+
+ // track if player refuses to join the BG after being invited
+ if (bg->isBattleground() && sWorld->getBoolConfig(CONFIG_BATTLEGROUND_TRACK_DESERTERS) &&
+ (bg->GetStatus() == STATUS_IN_PROGRESS || bg->GetStatus() == STATUS_WAIT_JOIN))
+ {
+ PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_DESERTER_TRACK);
+ stmt->setUInt32(0, _player->GetGUID().GetCounter());
+ stmt->setUInt8(1, BG_DESERTION_TYPE_LEAVE_QUEUE);
+ CharacterDatabase.Execute(stmt);
+ }
}
}
diff --git a/src/server/game/Handlers/CharacterHandler.cpp b/src/server/game/Handlers/CharacterHandler.cpp
index 29761ead707..e5b32f548f9 100644
--- a/src/server/game/Handlers/CharacterHandler.cpp
+++ b/src/server/game/Handlers/CharacterHandler.cpp
@@ -231,8 +231,8 @@ void WorldSession::HandleCharEnum(PreparedQueryResult result)
if (!(*result)[20].GetUInt32())
_legitCharacters.insert(guid);
- if (!sWorld->HasCharacterNameData(guid)) // This can happen if characters are inserted into the database manually. Core hasn't loaded name data yet.
- sWorld->AddCharacterNameData(guid, (*result)[1].GetString(), (*result)[4].GetUInt8(), (*result)[2].GetUInt8(), (*result)[3].GetUInt8(), (*result)[7].GetUInt8());
+ if (!sWorld->HasCharacterInfo(guid)) // This can happen if characters are inserted into the database manually. Core hasn't loaded name data yet.
+ sWorld->AddCharacterInfo(guid, GetAccountId(), (*result)[1].GetString(), (*result)[4].GetUInt8(), (*result)[2].GetUInt8(), (*result)[3].GetUInt8(), (*result)[7].GetUInt8());
++num;
}
}
@@ -363,7 +363,7 @@ void WorldSession::HandleCharCreateOpcode(WorldPacket& recvData)
}
// check name limitations
- ResponseCodes res = ObjectMgr::CheckPlayerName(createInfo.Name, true);
+ ResponseCodes res = ObjectMgr::CheckPlayerName(createInfo.Name, GetSessionDbcLocale(), true);
if (res != CHAR_NAME_SUCCESS)
{
SendCharCreate(res);
@@ -433,14 +433,11 @@ void WorldSession::HandleCharCreateCallback(PreparedQueryResult result, Characte
}
case 1:
{
- uint16 acctCharCount = 0;
+ uint64 acctCharCount = 0;
if (result)
{
Field* fields = result->Fetch();
- // SELECT SUM(x) is MYSQL_TYPE_NEWDECIMAL - needs to be read as string
- const char* ch = fields[0].GetCString();
- if (ch)
- acctCharCount = atoi(ch);
+ acctCharCount = uint64(fields[0].GetDouble());
}
if (acctCharCount >= sWorld->getIntConfig(CONFIG_CHARACTERS_PER_ACCOUNT))
@@ -645,7 +642,7 @@ void WorldSession::HandleCharCreateCallback(PreparedQueryResult result, Characte
TC_LOG_INFO("entities.player.character", "Account: %d (IP: %s) Create Character:[%s] (GUID: %u)", GetAccountId(), GetRemoteAddress().c_str(), createInfo->Name.c_str(), newChar.GetGUID().GetCounter());
sScriptMgr->OnPlayerCreate(&newChar);
- sWorld->AddCharacterNameData(newChar.GetGUID(), newChar.GetName(), newChar.getGender(), newChar.getRace(), newChar.getClass(), newChar.getLevel());
+ sWorld->AddCharacterInfo(newChar.GetGUID(), GetAccountId(), newChar.GetName(), newChar.getGender(), newChar.getRace(), newChar.getClass(), newChar.getLevel());
newChar.CleanupsBeforeDelete();
delete createInfo;
@@ -887,7 +884,7 @@ void WorldSession::HandlePlayerLogin(LoginQueryHolder* holder)
}
}
- if (!pCurrChar->GetMap()->AddPlayerToMap(pCurrChar) || !pCurrChar->CheckInstanceLoginValid())
+ if (!pCurrChar->GetMap()->AddPlayerToMap(pCurrChar))
{
AreaTrigger const* at = sObjectMgr->GetGoBackTrigger(pCurrChar->GetMapId());
if (at)
@@ -1095,7 +1092,7 @@ void WorldSession::HandleCharRenameOpcode(WorldPacket& recvData)
return;
}
- ResponseCodes res = ObjectMgr::CheckPlayerName(renameInfo.Name, true);
+ ResponseCodes res = ObjectMgr::CheckPlayerName(renameInfo.Name, GetSessionDbcLocale(), true);
if (res != CHAR_NAME_SUCCESS)
{
SendCharRename(res, renameInfo);
@@ -1157,7 +1154,7 @@ void WorldSession::HandleChangePlayerNameOpcodeCallBack(PreparedQueryResult resu
SendCharRename(RESPONSE_SUCCESS, *renameInfo);
- sWorld->UpdateCharacterNameData(renameInfo->Guid, renameInfo->Name);
+ sWorld->UpdateCharacterInfo(renameInfo->Guid, renameInfo->Name);
}
void WorldSession::HandleSetPlayerDeclinedNames(WorldPacket& recvData)
@@ -1394,7 +1391,7 @@ void WorldSession::HandleCharCustomize(WorldPacket& recvData)
return;
}
- ResponseCodes res = ObjectMgr::CheckPlayerName(customizeInfo.Name, true);
+ ResponseCodes res = ObjectMgr::CheckPlayerName(customizeInfo.Name, GetSessionDbcLocale(), true);
if (res != CHAR_NAME_SUCCESS)
{
SendCharCustomize(res, customizeInfo);
@@ -1447,7 +1444,7 @@ void WorldSession::HandleCharCustomize(WorldPacket& recvData)
CharacterDatabase.CommitTransaction(trans);
- sWorld->UpdateCharacterNameData(customizeInfo.Guid, customizeInfo.Name, customizeInfo.Gender);
+ sWorld->UpdateCharacterInfo(customizeInfo.Guid, customizeInfo.Name, customizeInfo.Gender);
SendCharCustomize(RESPONSE_SUCCESS, customizeInfo);
}
@@ -1596,16 +1593,16 @@ void WorldSession::HandleCharFactionOrRaceChange(WorldPacket& recvData)
ObjectGuid::LowType lowGuid = factionChangeInfo.Guid.GetCounter();
// get the players old (at this moment current) race
- CharacterNameData const* nameData = sWorld->GetCharacterNameData(factionChangeInfo.Guid);
+ CharacterInfo const* nameData = sWorld->GetCharacterInfo(factionChangeInfo.Guid);
if (!nameData)
{
SendCharFactionChange(CHAR_CREATE_ERROR, factionChangeInfo);
return;
}
- uint8 oldRace = nameData->m_race;
- uint8 playerClass = nameData->m_class;
- uint8 level = nameData->m_level;
+ uint8 oldRace = nameData->Race;
+ uint8 playerClass = nameData->Class;
+ uint8 level = nameData->Level;
// TO Do: Make async
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHAR_AT_LOGIN_TITLES);
@@ -1652,7 +1649,7 @@ void WorldSession::HandleCharFactionOrRaceChange(WorldPacket& recvData)
return;
}
- ResponseCodes res = ObjectMgr::CheckPlayerName(factionChangeInfo.Name, true);
+ ResponseCodes res = ObjectMgr::CheckPlayerName(factionChangeInfo.Name, GetSessionDbcLocale(), true);
if (res != CHAR_NAME_SUCCESS)
{
SendCharFactionChange(res, factionChangeInfo);
@@ -1695,7 +1692,7 @@ void WorldSession::HandleCharFactionOrRaceChange(WorldPacket& recvData)
stmt->setUInt32(0, lowGuid);
trans->Append(stmt);
- sWorld->UpdateCharacterNameData(factionChangeInfo.Guid, factionChangeInfo.Name, factionChangeInfo.Gender, factionChangeInfo.Race);
+ sWorld->UpdateCharacterInfo(factionChangeInfo.Guid, factionChangeInfo.Name, factionChangeInfo.Gender, factionChangeInfo.Race);
if (oldRace != factionChangeInfo.Race)
{
diff --git a/src/server/game/Handlers/ItemHandler.cpp b/src/server/game/Handlers/ItemHandler.cpp
index 13987c983f7..b1f46c381bf 100644
--- a/src/server/game/Handlers/ItemHandler.cpp
+++ b/src/server/game/Handlers/ItemHandler.cpp
@@ -786,8 +786,7 @@ void WorldSession::SendListInventory(ObjectGuid vendorGuid)
if (!_player->IsGameMaster() && !leftInStock)
continue;
- ConditionList conditions = sConditionMgr->GetConditionsForNpcVendorEvent(vendor->GetEntry(), item->item);
- if (!sConditionMgr->IsObjectMeetToConditions(_player, vendor, conditions))
+ if (!sConditionMgr->IsObjectMeetingVendorItemConditions(vendor->GetEntry(), item->item, _player, vendor))
{
TC_LOG_DEBUG("condition", "SendListInventory: conditions not met for creature entry %u item %u", vendor->GetEntry(), item->item);
continue;
diff --git a/src/server/game/Handlers/PetHandler.cpp b/src/server/game/Handlers/PetHandler.cpp
index 4495c044c61..8c3c3e9082b 100644
--- a/src/server/game/Handlers/PetHandler.cpp
+++ b/src/server/game/Handlers/PetHandler.cpp
@@ -600,7 +600,7 @@ void WorldSession::HandlePetRename(WorldPacket& recvData)
pet->GetOwnerGUID() != _player->GetGUID() || !pet->GetCharmInfo())
return;
- PetNameInvalidReason res = ObjectMgr::CheckPetName(name);
+ PetNameInvalidReason res = ObjectMgr::CheckPetName(name, GetSessionDbcLocale());
if (res != PET_NAME_SUCCESS)
{
SendPetNameInvalid(res, name, NULL);
diff --git a/src/server/game/Handlers/QueryHandler.cpp b/src/server/game/Handlers/QueryHandler.cpp
index 6d896bee26c..153ce736946 100644
--- a/src/server/game/Handlers/QueryHandler.cpp
+++ b/src/server/game/Handlers/QueryHandler.cpp
@@ -31,7 +31,7 @@
void WorldSession::SendNameQueryOpcode(ObjectGuid guid)
{
Player* player = ObjectAccessor::FindConnectedPlayer(guid);
- CharacterNameData const* nameData = sWorld->GetCharacterNameData(guid);
+ CharacterInfo const* nameData = sWorld->GetCharacterInfo(guid);
WorldPacket data(SMSG_NAME_QUERY_RESPONSE, (8+1+1+1+1+1+10));
data << guid.WriteAsPacked();
@@ -43,11 +43,11 @@ void WorldSession::SendNameQueryOpcode(ObjectGuid guid)
}
data << uint8(0); // name known
- data << nameData->m_name; // played name
+ data << nameData->Name; // played name
data << uint8(0); // realm name - only set for cross realm interaction (such as Battlegrounds)
- data << uint8(nameData->m_race);
- data << uint8(nameData->m_gender);
- data << uint8(nameData->m_class);
+ data << uint8(nameData->Race);
+ data << uint8(nameData->Sex);
+ data << uint8(nameData->Class);
if (DeclinedName const* names = (player ? player->GetDeclinedNames() : NULL))
{
@@ -96,9 +96,9 @@ void WorldSession::HandleCreatureQueryOpcode(WorldPacket& recvData)
CreatureTemplate const* ci = sObjectMgr->GetCreatureTemplate(entry);
if (ci)
{
- std::string Name, SubName;
+ std::string Name, Title;
Name = ci->Name;
- SubName = ci->SubName;
+ Title = ci->Title;
int loc_idx = GetSessionDbLocaleIndex();
if (loc_idx >= 0)
@@ -106,7 +106,7 @@ void WorldSession::HandleCreatureQueryOpcode(WorldPacket& recvData)
if (CreatureLocale const* cl = sObjectMgr->GetCreatureLocale(entry))
{
ObjectMgr::GetLocaleString(cl->Name, loc_idx, Name);
- ObjectMgr::GetLocaleString(cl->SubName, loc_idx, SubName);
+ ObjectMgr::GetLocaleString(cl->Title, loc_idx, Title);
}
}
TC_LOG_DEBUG("network", "WORLD: CMSG_CREATURE_QUERY '%s' - Entry: %u.", ci->Name.c_str(), entry);
@@ -115,7 +115,7 @@ void WorldSession::HandleCreatureQueryOpcode(WorldPacket& recvData)
data << uint32(entry); // creature entry
data << Name;
data << uint8(0) << uint8(0) << uint8(0); // name2, name3, name4, always empty
- data << SubName;
+ data << Title;
data << ci->IconName; // "Directions" for guard, string for Icons 2.3.0
data << uint32(ci->type_flags); // flags
data << uint32(ci->type); // CreatureType.dbc
diff --git a/src/server/game/Handlers/QuestHandler.cpp b/src/server/game/Handlers/QuestHandler.cpp
index 91bc8309b18..fd7c4439c8f 100644
--- a/src/server/game/Handlers/QuestHandler.cpp
+++ b/src/server/game/Handlers/QuestHandler.cpp
@@ -124,8 +124,7 @@ void WorldSession::HandleQuestgiverAcceptQuestOpcode(WorldPacket& recvData)
if (Player* playerQuestObject = object->ToPlayer())
{
- if ((_player->GetDivider() && _player->GetDivider() != guid) ||
- ((object != _player && !playerQuestObject->CanShareQuest(questId))))
+ if ((_player->GetDivider() && _player->GetDivider() != guid) || !playerQuestObject->CanShareQuest(questId))
{
CLOSE_GOSSIP_CLEAR_DIVIDER();
return;
diff --git a/src/server/game/Handlers/TradeHandler.cpp b/src/server/game/Handlers/TradeHandler.cpp
index fbfd16ae1c6..1bb21971935 100644
--- a/src/server/game/Handlers/TradeHandler.cpp
+++ b/src/server/game/Handlers/TradeHandler.cpp
@@ -28,6 +28,7 @@
#include "SocialMgr.h"
#include "Language.h"
#include "AccountMgr.h"
+#include "TradeData.h"
void WorldSession::SendTradeStatus(TradeStatusInfo const& info)
{
@@ -454,6 +455,8 @@ void WorldSession::HandleAcceptTradeOpcode(WorldPacket& /*recvPacket*/)
SendTradeStatus(myCanCompleteInfo);
my_trade->SetAccepted(false);
his_trade->SetAccepted(false);
+ delete my_spell;
+ delete his_spell;
return;
}
else if (hisCanCompleteInfo.Result != EQUIP_ERR_OK)
@@ -466,6 +469,8 @@ void WorldSession::HandleAcceptTradeOpcode(WorldPacket& /*recvPacket*/)
trader->GetSession()->SendTradeStatus(hisCanCompleteInfo);
my_trade->SetAccepted(false);
his_trade->SetAccepted(false);
+ delete my_spell;
+ delete his_spell;
return;
}
diff --git a/src/server/game/Loot/LootMgr.cpp b/src/server/game/Loot/LootMgr.cpp
index be1b395b082..b7a19a72bf5 100644
--- a/src/server/game/Loot/LootMgr.cpp
+++ b/src/server/game/Loot/LootMgr.cpp
@@ -95,7 +95,7 @@ class LootTemplate::LootGroup // A set of loot def
void CheckLootRefs(LootTemplateMap const& store, LootIdSet* ref_set) const;
LootStoreItemList* GetExplicitlyChancedItemList() { return &ExplicitlyChanced; }
LootStoreItemList* GetEqualChancedItemList() { return &EqualChanced; }
- void CopyConditions(ConditionList conditions);
+ void CopyConditions(ConditionContainer conditions);
private:
LootStoreItemList ExplicitlyChanced; // Entries with chances defined in DB
LootStoreItemList EqualChanced; // Zero chances - every entry takes the same chance
@@ -218,7 +218,7 @@ void LootStore::ResetConditions()
{
for (LootTemplateMap::iterator itr = m_LootTemplates.begin(); itr != m_LootTemplates.end(); ++itr)
{
- ConditionList empty;
+ ConditionContainer empty;
itr->second->CopyConditions(empty);
}
}
@@ -1155,7 +1155,7 @@ bool LootTemplate::LootGroup::HasQuestDropForPlayer(Player const* player) const
return false;
}
-void LootTemplate::LootGroup::CopyConditions(ConditionList /*conditions*/)
+void LootTemplate::LootGroup::CopyConditions(ConditionContainer /*conditions*/)
{
for (LootStoreItemList::iterator i = ExplicitlyChanced.begin(); i != ExplicitlyChanced.end(); ++i)
(*i)->conditions.clear();
@@ -1260,7 +1260,7 @@ void LootTemplate::AddEntry(LootStoreItem* item)
Entries.push_back(item);
}
-void LootTemplate::CopyConditions(const ConditionList& conditions)
+void LootTemplate::CopyConditions(const ConditionContainer& conditions)
{
for (LootStoreItemList::iterator i = Entries.begin(); i != Entries.end(); ++i)
(*i)->conditions.clear();
diff --git a/src/server/game/Loot/LootMgr.h b/src/server/game/Loot/LootMgr.h
index 35687aee66c..08cd224cd0b 100644
--- a/src/server/game/Loot/LootMgr.h
+++ b/src/server/game/Loot/LootMgr.h
@@ -132,7 +132,7 @@ struct LootStoreItem
uint8 groupid : 7;
uint8 mincount; // mincount for drop items
uint8 maxcount; // max drop count for the item mincount or Ref multiplicator
- ConditionList conditions; // additional loot condition
+ ConditionContainer conditions; // additional loot condition
// Constructor
// displayid is filled in IsValid() which must be called after
@@ -153,7 +153,7 @@ struct LootItem
uint32 itemid;
uint32 randomSuffix;
int32 randomPropertyId;
- ConditionList conditions; // additional loot condition
+ ConditionContainer conditions; // additional loot condition
AllowedLooterSet allowedGUIDs;
uint8 count : 8;
bool is_looted : 1;
@@ -252,7 +252,7 @@ class LootTemplate
void AddEntry(LootStoreItem* item);
// Rolls for every item in the template and adds the rolled items the the loot
void Process(Loot& loot, bool rate, uint16 lootMode, uint8 groupId = 0) const;
- void CopyConditions(const ConditionList& conditions);
+ void CopyConditions(const ConditionContainer& conditions);
void CopyConditions(LootItem* li) const;
// True if template includes at least 1 quest drop entry
diff --git a/src/server/game/Maps/Map.cpp b/src/server/game/Maps/Map.cpp
index 7ab83d51c7c..6fbef752228 100644
--- a/src/server/game/Maps/Map.cpp
+++ b/src/server/game/Maps/Map.cpp
@@ -299,6 +299,25 @@ void Map::AddToGrid(DynamicObject* obj, Cell const& cell)
obj->SetCurrentCell(cell);
}
+template<>
+void Map::AddToGrid(Corpse* obj, Cell const& cell)
+{
+ NGridType* grid = getNGrid(cell.GridX(), cell.GridY());
+ // Corpses are a special object type - they can be added to grid via a call to AddToMap
+ // or loaded through ObjectGridLoader.
+ // Both corpses loaded from database and these freshly generated by Player::CreateCoprse are added to _corpsesByCell
+ // ObjectGridLoader loads all corpses from _corpsesByCell even if they were already added to grid before it was loaded
+ // so we need to explicitly check it here (Map::AddToGrid is only called from Player::BuildPlayerRepop, not from ObjectGridLoader)
+ // to avoid failing an assertion in GridObject::AddToGrid
+ if (grid->isGridObjectDataLoaded())
+ {
+ if (obj->IsWorldObject())
+ grid->GetGridType(cell.CellX(), cell.CellY()).AddWorldObject(obj);
+ else
+ grid->GetGridType(cell.CellX(), cell.CellY()).AddGridObject(obj);
+ }
+}
+
template<class T>
void Map::SwitchGridContainers(T* /*obj*/, bool /*on*/) { }
@@ -1601,6 +1620,20 @@ void Map::UnloadAll()
RemoveFromMap<Transport>(transport, true);
}
+
+ for (auto& cellCorpsePair : _corpsesByCell)
+ {
+ for (Corpse* corpse : cellCorpsePair.second)
+ {
+ corpse->RemoveFromWorld();
+ corpse->ResetMap();
+ delete corpse;
+ }
+ }
+
+ _corpsesByCell.clear();
+ _corpsesByPlayer.clear();
+ _corpseBones.clear();
}
// *****************************
@@ -3144,7 +3177,7 @@ void InstanceMap::CreateInstanceData(bool load)
i_data->SetCompletedEncountersMask(fields[1].GetUInt32());
if (!data.empty())
{
- TC_LOG_DEBUG("maps", "Loading instance data for `%s` with id %u", sObjectMgr->GetScriptName(i_script_id), i_InstanceId);
+ TC_LOG_DEBUG("maps", "Loading instance data for `%s` with id %u", sObjectMgr->GetScriptName(i_script_id).c_str(), i_InstanceId);
i_data->Load(data.c_str());
}
}
@@ -3216,8 +3249,8 @@ void InstanceMap::PermBindAllPlayers(Player* source)
WorldPacket data(SMSG_INSTANCE_SAVE_CREATED, 4);
data << uint32(0);
player->GetSession()->SendPacket(&data);
-
- player->GetSession()->SendCalendarRaidLockout(save, true);
+ if (!player->IsGameMaster())
+ player->GetSession()->SendCalendarRaidLockout(save, true);
}
// if the leader is not in the instance the group will not get a perm bind
@@ -3575,14 +3608,16 @@ void Map::AddCorpse(Corpse* corpse)
{
corpse->SetMap(this);
- CellCoord cellCoord = Trinity::ComputeCellCoord(corpse->GetPositionX(), corpse->GetPositionY());
- _corpsesByCell[cellCoord.GetId()].insert(corpse);
- _corpsesByPlayer[corpse->GetOwnerGUID()] = corpse;
+ _corpsesByCell[corpse->GetCellCoord().GetId()].insert(corpse);
+ if (corpse->GetType() != CORPSE_BONES)
+ _corpsesByPlayer[corpse->GetOwnerGUID()] = corpse;
+ else
+ _corpseBones.insert(corpse);
}
void Map::RemoveCorpse(Corpse* corpse)
{
- ASSERT(corpse && corpse->GetType() != CORPSE_BONES);
+ ASSERT(corpse);
corpse->DestroyForNearbyPlayers();
if (corpse->IsInGrid())
@@ -3593,9 +3628,11 @@ void Map::RemoveCorpse(Corpse* corpse)
corpse->ResetMap();
}
- CellCoord cellCoord = Trinity::ComputeCellCoord(corpse->GetPositionX(), corpse->GetPositionY());
- _corpsesByCell[cellCoord.GetId()].erase(corpse);
- _corpsesByPlayer.erase(corpse->GetOwnerGUID());
+ _corpsesByCell[corpse->GetCellCoord().GetId()].erase(corpse);
+ if (corpse->GetType() != CORPSE_BONES)
+ _corpsesByPlayer.erase(corpse->GetOwnerGUID());
+ else
+ _corpseBones.erase(corpse);
}
Corpse* Map::ConvertCorpseToBones(ObjectGuid const& ownerGuid, bool insignia /*= false*/)
@@ -3621,12 +3658,12 @@ Corpse* Map::ConvertCorpseToBones(ObjectGuid const& ownerGuid, bool insignia /*=
{
// Create bones, don't change Corpse
bones = new Corpse();
- bones->Create(corpse->GetGUID().GetCounter(), this);
+ bones->Create(corpse->GetGUID().GetCounter());
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->SetGridCoord(corpse->GetGridCoord());
+ bones->SetCellCoord(corpse->GetCellCoord());
bones->Relocate(corpse->GetPositionX(), corpse->GetPositionY(), corpse->GetPositionZ(), corpse->GetOrientation());
bones->SetPhaseMask(corpse->GetPhaseMask(), false);
@@ -3637,6 +3674,8 @@ Corpse* Map::ConvertCorpseToBones(ObjectGuid const& ownerGuid, bool insignia /*=
if (corpse->GetUInt32Value(CORPSE_FIELD_ITEM + i))
bones->SetUInt32Value(CORPSE_FIELD_ITEM + i, 0);
+ AddCorpse(bones);
+
// add bones in grid store if grid loaded where corpse placed
AddToMap(bones);
}
@@ -3660,6 +3699,17 @@ void Map::RemoveOldCorpses()
for (ObjectGuid const& ownerGuid : corpses)
ConvertCorpseToBones(ownerGuid);
+
+ std::vector<Corpse*> expiredBones;
+ for (Corpse* bones : _corpseBones)
+ if (bones->IsExpired(now))
+ expiredBones.push_back(bones);
+
+ for (Corpse* bones : expiredBones)
+ {
+ RemoveCorpse(bones);
+ delete bones;
+ }
}
void Map::SendZoneDynamicInfo(Player* player)
diff --git a/src/server/game/Maps/Map.h b/src/server/game/Maps/Map.h
index 184f1f9a426..0962bcc9d6c 100644
--- a/src/server/game/Maps/Map.h
+++ b/src/server/game/Maps/Map.h
@@ -561,7 +561,7 @@ class Map : public GridRefManager<NGridType>
{
_updateObjects.insert(obj);
}
-
+
void RemoveUpdateObject(Object* obj)
{
_updateObjects.erase(obj);
@@ -733,6 +733,7 @@ class Map : public GridRefManager<NGridType>
GameObjectBySpawnIdContainer _gameobjectBySpawnIdStore;
std::unordered_map<uint32/*cellId*/, std::unordered_set<Corpse*>> _corpsesByCell;
std::unordered_map<ObjectGuid, Corpse*> _corpsesByPlayer;
+ std::unordered_set<Corpse*> _corpseBones;
std::unordered_set<Object*> _updateObjects;
};
diff --git a/src/server/game/Miscellaneous/Formulas.h b/src/server/game/Miscellaneous/Formulas.h
index aa9a738b5dc..6edc3d74a5d 100644
--- a/src/server/game/Miscellaneous/Formulas.h
+++ b/src/server/game/Miscellaneous/Formulas.h
@@ -175,7 +175,7 @@ namespace Trinity
if (creature->isElite())
{
// Elites in instances have a 2.75x XP bonus instead of the regular 2x world bonus.
- if (u->GetMap() && u->GetMap()->IsDungeon())
+ if (u->GetMap()->IsDungeon())
xpMod *= 2.75f;
else
xpMod *= 2.0f;
diff --git a/src/server/game/Movement/MovementGenerators/HomeMovementGenerator.cpp b/src/server/game/Movement/MovementGenerators/HomeMovementGenerator.cpp
index 4245bffb864..7ab7534199a 100644
--- a/src/server/game/Movement/MovementGenerators/HomeMovementGenerator.cpp
+++ b/src/server/game/Movement/MovementGenerators/HomeMovementGenerator.cpp
@@ -33,7 +33,7 @@ void HomeMovementGenerator<Creature>::DoFinalize(Creature* owner)
{
owner->ClearUnitState(UNIT_STATE_EVADE);
owner->SetWalk(true);
- owner->LoadCreaturesAddon(true);
+ owner->LoadCreaturesAddon();
owner->AI()->JustReachedHome();
}
}
diff --git a/src/server/game/OutdoorPvP/OutdoorPvP.h b/src/server/game/OutdoorPvP/OutdoorPvP.h
index b35147a8502..4a423a8da5b 100644
--- a/src/server/game/OutdoorPvP/OutdoorPvP.h
+++ b/src/server/game/OutdoorPvP/OutdoorPvP.h
@@ -308,12 +308,12 @@ class OutdoorPvP : public ZoneScript
template<class Worker>
void BroadcastWorker(Worker& _worker, uint32 zoneId);
-
+
// Hack to store map because this code is just shit
void SetMapFromZone(uint32 zone);
std::map<ObjectGuid::LowType, GameObject*> m_GoScriptStore;
std::map<ObjectGuid::LowType, Creature*> m_CreatureScriptStore;
-
+
Map* m_map;
};
diff --git a/src/server/game/OutdoorPvP/OutdoorPvPMgr.cpp b/src/server/game/OutdoorPvP/OutdoorPvPMgr.cpp
index e7b6765c177..37a380bf576 100644
--- a/src/server/game/OutdoorPvP/OutdoorPvPMgr.cpp
+++ b/src/server/game/OutdoorPvP/OutdoorPvPMgr.cpp
@@ -71,7 +71,7 @@ void OutdoorPvPMgr::InitOutdoorPvP()
OutdoorPvPData* data = new OutdoorPvPData();
OutdoorPvPTypes realTypeId = OutdoorPvPTypes(typeId);
data->TypeId = realTypeId;
- data->ScriptId = sObjectMgr->GetScriptId(fields[1].GetCString());
+ data->ScriptId = sObjectMgr->GetScriptId(fields[1].GetString());
m_OutdoorPvPDatas[realTypeId] = data;
++count;
diff --git a/src/server/game/Scripting/ScriptLoader.cpp b/src/server/game/Scripting/ScriptLoader.cpp
index a6a8eca6004..47a23dedf0c 100644
--- a/src/server/game/Scripting/ScriptLoader.cpp
+++ b/src/server/game/Scripting/ScriptLoader.cpp
@@ -102,11 +102,8 @@ void AddSC_boss_galvangar();
void AddSC_boss_vanndar();
void AddSC_blackrock_depths(); //Blackrock Depths
void AddSC_boss_ambassador_flamelash();
-void AddSC_boss_anubshiah();
void AddSC_boss_draganthaurissan();
void AddSC_boss_general_angerforge();
-void AddSC_boss_gorosh_the_dervish();
-void AddSC_boss_grizzle();
void AddSC_boss_high_interrogator_gerstahn();
void AddSC_boss_magmus();
void AddSC_boss_moira_bronzebeard();
@@ -804,11 +801,8 @@ void AddEasternKingdomsScripts()
AddSC_boss_vanndar();
AddSC_blackrock_depths(); //Blackrock Depths
AddSC_boss_ambassador_flamelash();
- AddSC_boss_anubshiah();
AddSC_boss_draganthaurissan();
AddSC_boss_general_angerforge();
- AddSC_boss_gorosh_the_dervish();
- AddSC_boss_grizzle();
AddSC_boss_high_interrogator_gerstahn();
AddSC_boss_magmus();
AddSC_boss_moira_bronzebeard();
diff --git a/src/server/game/Scripting/ScriptMgr.cpp b/src/server/game/Scripting/ScriptMgr.cpp
index db5e09c5d2a..3cbdf93ca54 100644
--- a/src/server/game/Scripting/ScriptMgr.cpp
+++ b/src/server/game/Scripting/ScriptMgr.cpp
@@ -33,6 +33,7 @@
#include "Player.h"
#include "WorldPacket.h"
#include "WorldSession.h"
+#include "Chat.h"
// namespace
// {
@@ -40,6 +41,60 @@
UnusedScriptNamesContainer UnusedScriptNames;
// }
+// Trait which indicates whether this script type
+// must be assigned in the database.
+template<typename>
+struct is_script_database_bound
+ : std::false_type { };
+
+template<>
+struct is_script_database_bound<SpellScriptLoader>
+ : std::true_type { };
+
+template<>
+struct is_script_database_bound<InstanceMapScript>
+ : std::true_type { };
+
+template<>
+struct is_script_database_bound<ItemScript>
+ : std::true_type { };
+
+template<>
+struct is_script_database_bound<CreatureScript>
+ : std::true_type { };
+
+template<>
+struct is_script_database_bound<GameObjectScript>
+ : std::true_type { };
+
+template<>
+struct is_script_database_bound<AreaTriggerScript>
+ : std::true_type { };
+
+template<>
+struct is_script_database_bound<BattlegroundScript>
+ : std::true_type { };
+
+template<>
+struct is_script_database_bound<OutdoorPvPScript>
+ : std::true_type { };
+
+template<>
+struct is_script_database_bound<WeatherScript>
+ : std::true_type { };
+
+template<>
+struct is_script_database_bound<ConditionScript>
+ : std::true_type { };
+
+template<>
+struct is_script_database_bound<TransportScript>
+ : std::true_type { };
+
+template<>
+struct is_script_database_bound<AchievementCriteriaScript>
+ : std::true_type { };
+
// This is the global static registry of scripts.
template<class TScript>
class ScriptRegistry
@@ -70,78 +125,83 @@ class ScriptRegistry
}
}
- if (script->IsDatabaseBound())
+ AddScript(is_script_database_bound<TScript>{}, script);
+ }
+
+ // Gets a script by its ID (assigned by ObjectMgr).
+ static TScript* GetScriptById(uint32 id)
+ {
+ ScriptMapIterator it = ScriptPointerList.find(id);
+ if (it != ScriptPointerList.end())
+ return it->second;
+
+ return NULL;
+ }
+
+ private:
+
+ // Adds a database bound script
+ static void AddScript(std::true_type, TScript* const script)
+ {
+ // Get an ID for the script. An ID only exists if it's a script that is assigned in the database
+ // through a script name (or similar).
+ uint32 id = sObjectMgr->GetScriptId(script->GetName());
+ if (id)
{
- // Get an ID for the script. An ID only exists if it's a script that is assigned in the database
- // through a script name (or similar).
- uint32 id = sObjectMgr->GetScriptId(script->GetName().c_str());
- if (id)
+ // Try to find an existing script.
+ bool existing = false;
+ for (ScriptMapIterator it = ScriptPointerList.begin(); it != ScriptPointerList.end(); ++it)
{
- // Try to find an existing script.
- bool existing = false;
- for (ScriptMapIterator it = ScriptPointerList.begin(); it != ScriptPointerList.end(); ++it)
- {
- // If the script names match...
- if (it->second->GetName() == script->GetName())
- {
- // ... It exists.
- existing = true;
- break;
- }
- }
-
- // If the script isn't assigned -> assign it!
- if (!existing)
+ // If the script names match...
+ if (it->second->GetName() == script->GetName())
{
- ScriptPointerList[id] = script;
- sScriptMgr->IncrementScriptCount();
-
- #ifdef SCRIPTS
- UnusedScriptNamesContainer::iterator itr = std::lower_bound(UnusedScriptNames.begin(), UnusedScriptNames.end(), script->GetName());
- if (itr != UnusedScriptNames.end() && *itr == script->GetName())
- UnusedScriptNames.erase(itr);
- #endif
+ // ... It exists.
+ existing = true;
+ break;
}
- else
- {
- // If the script is already assigned -> delete it!
- TC_LOG_ERROR("scripts", "Script '%s' already assigned with the same script name, so the script can't work.",
- script->GetName().c_str());
+ }
- ABORT(); // Error that should be fixed ASAP.
- }
+ // If the script isn't assigned -> assign it!
+ if (!existing)
+ {
+ ScriptPointerList[id] = script;
+ sScriptMgr->IncrementScriptCount();
+
+ #ifdef SCRIPTS
+ UnusedScriptNamesContainer::iterator itr = std::lower_bound(UnusedScriptNames.begin(), UnusedScriptNames.end(), script->GetName());
+ if (itr != UnusedScriptNames.end() && *itr == script->GetName())
+ UnusedScriptNames.erase(itr);
+ #endif
}
else
{
- // The script uses a script name from database, but isn't assigned to anything.
- TC_LOG_ERROR("sql.sql", "Script named '%s' does not have a script name assigned in database.", script->GetName().c_str());
+ // If the script is already assigned -> delete it!
+ TC_LOG_ERROR("scripts", "Script '%s' already assigned with the same script name, so the script can't work.",
+ script->GetName().c_str());
- // Avoid calling "delete script;" because we are currently in the script constructor
- // In a valid scenario this will not happen because every script has a name assigned in the database
- UnusedScripts.push_back(script);
- return;
+ ABORT(); // Error that should be fixed ASAP.
}
}
else
{
- // We're dealing with a code-only script; just add it.
- ScriptPointerList[_scriptIdCounter++] = script;
- sScriptMgr->IncrementScriptCount();
+ // The script uses a script name from database, but isn't assigned to anything.
+ TC_LOG_ERROR("sql.sql", "Script named '%s' does not have a script name assigned in database.", script->GetName().c_str());
+
+ // Avoid calling "delete script;" because we are currently in the script constructor
+ // In a valid scenario this will not happen because every script has a name assigned in the database
+ UnusedScripts.push_back(script);
+ return;
}
}
- // Gets a script by its ID (assigned by ObjectMgr).
- static TScript* GetScriptById(uint32 id)
+ // Adds a non database bound script
+ static void AddScript(std::false_type, TScript* const script)
{
- ScriptMapIterator it = ScriptPointerList.find(id);
- if (it != ScriptPointerList.end())
- return it->second;
-
- return NULL;
+ // We're dealing with a code-only script; just add it.
+ ScriptPointerList[_scriptIdCounter++] = script;
+ sScriptMgr->IncrementScriptCount();
}
- private:
-
// Counter used for code-only scripts.
static uint32 _scriptIdCounter;
};
@@ -972,12 +1032,15 @@ OutdoorPvP* ScriptMgr::CreateOutdoorPvP(OutdoorPvPData const* data)
return tmpscript->GetOutdoorPvP();
}
-std::vector<ChatCommand*> ScriptMgr::GetChatCommands()
+std::vector<ChatCommand> ScriptMgr::GetChatCommands()
{
- std::vector<ChatCommand*> table;
+ std::vector<ChatCommand> table;
FOR_SCRIPTS_RET(CommandScript, itr, end, table)
- table.push_back(itr->second->GetCommands());
+ {
+ std::vector<ChatCommand> cmds = itr->second->GetCommands();
+ table.insert(table.end(), cmds.begin(), cmds.end());
+ }
return table;
}
@@ -1030,7 +1093,7 @@ void ScriptMgr::OnAuctionExpire(AuctionHouseObject* ah, AuctionEntry* entry)
FOREACH_SCRIPT(AuctionHouseScript)->OnAuctionExpire(ah, entry);
}
-bool ScriptMgr::OnConditionCheck(Condition* condition, ConditionSourceInfo& sourceInfo)
+bool ScriptMgr::OnConditionCheck(Condition const* condition, ConditionSourceInfo& sourceInfo)
{
ASSERT(condition);
diff --git a/src/server/game/Scripting/ScriptMgr.h b/src/server/game/Scripting/ScriptMgr.h
index 7e1751244fd..046c6c1a009 100644
--- a/src/server/game/Scripting/ScriptMgr.h
+++ b/src/server/game/Scripting/ScriptMgr.h
@@ -153,10 +153,6 @@ class ScriptObject
public:
- // Do not override this in scripts; it should be overridden by the various script type classes. It indicates
- // whether or not this script type must be assigned in the database.
- virtual bool IsDatabaseBound() const { return false; }
-
const std::string& GetName() const { return _name; }
protected:
@@ -198,8 +194,6 @@ class SpellScriptLoader : public ScriptObject
public:
- bool IsDatabaseBound() const final override { return true; }
-
// Should return a fully valid SpellScript pointer.
virtual SpellScript* GetSpellScript() const { return NULL; }
@@ -356,8 +350,6 @@ class InstanceMapScript : public ScriptObject, public MapScript<InstanceMap>
public:
- bool IsDatabaseBound() const final override { return true; }
-
// Gets an InstanceScript object for this instance.
virtual InstanceScript* GetInstanceScript(InstanceMap* /*map*/) const { return NULL; }
};
@@ -377,8 +369,6 @@ class ItemScript : public ScriptObject
public:
- bool IsDatabaseBound() const final override { return true; }
-
// Called when a dummy spell effect is triggered on the item.
virtual bool OnDummyEffect(Unit* /*caster*/, uint32 /*spellId*/, SpellEffIndex /*effIndex*/, Item* /*target*/) { return false; }
@@ -426,8 +416,6 @@ class CreatureScript : public UnitScript, public UpdatableScript<Creature>
public:
- bool IsDatabaseBound() const final override { return true; }
-
// Called when a dummy spell effect is triggered on the creature.
virtual bool OnDummyEffect(Unit* /*caster*/, uint32 /*spellId*/, SpellEffIndex /*effIndex*/, Creature* /*target*/) { return false; }
@@ -464,8 +452,6 @@ class GameObjectScript : public ScriptObject, public UpdatableScript<GameObject>
public:
- bool IsDatabaseBound() const final override { return true; }
-
// Called when a dummy spell effect is triggered on the gameobject.
virtual bool OnDummyEffect(Unit* /*caster*/, uint32 /*spellId*/, SpellEffIndex /*effIndex*/, GameObject* /*target*/) { return false; }
@@ -511,8 +497,6 @@ class AreaTriggerScript : public ScriptObject
public:
- bool IsDatabaseBound() const final override { return true; }
-
// Called when the area trigger is activated by a player.
virtual bool OnTrigger(Player* /*player*/, AreaTriggerEntry const* /*trigger*/) { return false; }
};
@@ -525,8 +509,6 @@ class BattlegroundScript : public ScriptObject
public:
- bool IsDatabaseBound() const final override { return true; }
-
// Should return a fully valid Battleground object for the type ID.
virtual Battleground* GetBattleground() const = 0;
};
@@ -539,8 +521,6 @@ class OutdoorPvPScript : public ScriptObject
public:
- bool IsDatabaseBound() const final override { return true; }
-
// Should return a fully valid OutdoorPvP object for the type ID.
virtual OutdoorPvP* GetOutdoorPvP() const = 0;
};
@@ -554,7 +534,7 @@ class CommandScript : public ScriptObject
public:
// Should return a pointer to a valid command table (ChatCommand array) to be used by ChatHandler.
- virtual ChatCommand* GetCommands() const = 0;
+ virtual std::vector<ChatCommand> GetCommands() const = 0;
};
class WeatherScript : public ScriptObject, public UpdatableScript<Weather>
@@ -565,8 +545,6 @@ class WeatherScript : public ScriptObject, public UpdatableScript<Weather>
public:
- bool IsDatabaseBound() const final override { return true; }
-
// Called when the weather changes in the zone this script is associated with.
virtual void OnChange(Weather* /*weather*/, WeatherState /*state*/, float /*grade*/) { }
};
@@ -600,10 +578,8 @@ class ConditionScript : public ScriptObject
public:
- bool IsDatabaseBound() const final override { return true; }
-
// Called when a single condition is checked for a player.
- virtual bool OnConditionCheck(Condition* /*condition*/, ConditionSourceInfo& /*sourceInfo*/) { return true; }
+ virtual bool OnConditionCheck(Condition const* /*condition*/, ConditionSourceInfo& /*sourceInfo*/) { return true; }
};
class VehicleScript : public ScriptObject
@@ -648,8 +624,6 @@ class TransportScript : public ScriptObject, public UpdatableScript<Transport>
public:
- bool IsDatabaseBound() const final override { return true; }
-
// Called when a player boards the transport.
virtual void OnAddPassenger(Transport* /*transport*/, Player* /*player*/) { }
@@ -671,8 +645,6 @@ class AchievementCriteriaScript : public ScriptObject
public:
- bool IsDatabaseBound() const final override { return true; }
-
// Called when an additional criteria is checked.
virtual bool OnCheck(Player* source, Unit* target) = 0;
};
@@ -809,8 +781,6 @@ class GuildScript : public ScriptObject
public:
- bool IsDatabaseBound() const final override { return false; }
-
// Called when a member is added to the guild.
virtual void OnAddMember(Guild* /*guild*/, Player* /*player*/, uint8& /*plRank*/) { }
@@ -852,8 +822,6 @@ class GroupScript : public ScriptObject
public:
- bool IsDatabaseBound() const final override { return false; }
-
// Called when a member is added to a group.
virtual void OnAddMember(Group* /*group*/, ObjectGuid /*guid*/) { }
@@ -1014,7 +982,7 @@ class ScriptMgr
public: /* CommandScript */
- std::vector<ChatCommand*> GetChatCommands();
+ std::vector<ChatCommand> GetChatCommands();
public: /* WeatherScript */
@@ -1030,7 +998,7 @@ class ScriptMgr
public: /* ConditionScript */
- bool OnConditionCheck(Condition* condition, ConditionSourceInfo& sourceInfo);
+ bool OnConditionCheck(Condition const* condition, ConditionSourceInfo& sourceInfo);
public: /* VehicleScript */
diff --git a/src/server/game/Server/WorldSession.cpp b/src/server/game/Server/WorldSession.cpp
index b4bb7541be8..b1a043c4b5b 100644
--- a/src/server/game/Server/WorldSession.cpp
+++ b/src/server/game/Server/WorldSession.cpp
@@ -95,7 +95,7 @@ bool WorldSessionFilter::Process(WorldPacket* packet)
}
/// WorldSession constructor
-WorldSession::WorldSession(uint32 id, std::shared_ptr<WorldSocket> sock, AccountTypes sec, uint8 expansion, time_t mute_time, LocaleConstant locale, uint32 recruiter, bool isARecruiter):
+WorldSession::WorldSession(uint32 id, std::string&& name, std::shared_ptr<WorldSocket> sock, AccountTypes sec, uint8 expansion, time_t mute_time, LocaleConstant locale, uint32 recruiter, bool isARecruiter):
m_muteTime(mute_time),
m_timeOutTime(0),
AntiDOS(this),
@@ -104,6 +104,7 @@ WorldSession::WorldSession(uint32 id, std::shared_ptr<WorldSocket> sock, Account
m_Socket(sock),
_security(sec),
_accountId(id),
+ _accountName(std::move(name)),
m_expansion(expansion),
_warden(NULL),
_logoutTime(0),
@@ -170,11 +171,11 @@ std::string WorldSession::GetPlayerInfo() const
{
std::ostringstream ss;
- ss << "[Player: " << GetPlayerName() << " (";
- if (_player != NULL)
- ss << _player->GetGUID().ToString() << ", ";
+ ss << "[Player: ";
+ if (!m_playerLoading && _player)
+ ss << _player->GetName() << ' ' << _player->GetGUID().ToString() << ", ";
- ss << "Account: " << GetAccountId() << ")]";
+ ss << "Account: " << GetAccountId() << "]";
return ss.str();
}
@@ -483,6 +484,15 @@ void WorldSession::LogoutPlayer(bool save)
{
if (BattlegroundQueueTypeId bgQueueTypeId = _player->GetBattlegroundQueueTypeId(i))
{
+ // track if player logs out after invited to join BG
+ if (_player->IsInvitedForBattlegroundQueueType(bgQueueTypeId) && sWorld->getBoolConfig(CONFIG_BATTLEGROUND_TRACK_DESERTERS))
+ {
+ PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_DESERTER_TRACK);
+ stmt->setUInt32(0, _player->GetGUID().GetCounter());
+ stmt->setUInt8(1, BG_DESERTION_TYPE_INVITE_LOGOUT);
+ CharacterDatabase.Execute(stmt);
+ }
+
_player->RemoveBattlegroundQueueId(bgQueueTypeId);
BattlegroundQueue& queue = sBattlegroundMgr->GetBattlegroundQueue(bgQueueTypeId);
queue.RemovePlayer(_player->GetGUID(), true);
@@ -666,13 +676,6 @@ void WorldSession::SendAuthWaitQue(uint32 position)
}
}
-void WorldSession::LoadGlobalAccountData()
-{
- PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_ACCOUNT_DATA);
- stmt->setUInt32(0, GetAccountId());
- LoadAccountData(CharacterDatabase.Query(stmt), GLOBAL_CACHE_MASK);
-}
-
void WorldSession::LoadAccountData(PreparedQueryResult result, uint32 mask)
{
for (uint32 i = 0; i < NUM_ACCOUNT_DATA_TYPES; ++i)
@@ -748,13 +751,11 @@ void WorldSession::SendAccountDataTimes(uint32 mask)
SendPacket(&data);
}
-void WorldSession::LoadTutorialsData()
+void WorldSession::LoadTutorialsData(PreparedQueryResult result)
{
memset(m_Tutorials, 0, sizeof(uint32) * MAX_ACCOUNT_TUTORIAL_VALUES);
- PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_TUTORIALS);
- stmt->setUInt32(0, GetAccountId());
- if (PreparedQueryResult result = CharacterDatabase.Query(stmt))
+ if (result)
for (uint8 i = 0; i < MAX_ACCOUNT_TUTORIAL_VALUES; ++i)
m_Tutorials[i] = (*result)[i].GetUInt32();
@@ -957,7 +958,7 @@ void WorldSession::WriteMovementInfo(WorldPacket* data, MovementInfo* mi)
*data << mi->splineElevation;
}
-void WorldSession::ReadAddonsInfo(WorldPacket &data)
+void WorldSession::ReadAddonsInfo(ByteBuffer &data)
{
if (data.rpos() + 4 > data.size())
return;
@@ -1116,6 +1117,9 @@ void WorldSession::ProcessQueryCallbacks()
{
PreparedQueryResult result;
+ if (_realmAccountLoginCallback.valid() && _realmAccountLoginCallback.wait_for(std::chrono::seconds(0)) == std::future_status::ready)
+ InitializeSessionCallback(_realmAccountLoginCallback.get());
+
//! HandleCharEnumOpcode
if (_charEnumCallback.valid() && _charEnumCallback.wait_for(std::chrono::seconds(0)) == std::future_status::ready)
{
@@ -1215,15 +1219,84 @@ void WorldSession::InitWarden(BigNumber* k, std::string const& os)
void WorldSession::LoadPermissions()
{
uint32 id = GetAccountId();
- std::string name;
- AccountMgr::GetName(id, name);
uint8 secLevel = GetSecurity();
- _RBACData = new rbac::RBACData(id, name, realmID, secLevel);
+ _RBACData = new rbac::RBACData(id, _accountName, realmID, secLevel);
_RBACData->LoadFromDB();
+}
+
+PreparedQueryResultFuture WorldSession::LoadPermissionsAsync()
+{
+ uint32 id = GetAccountId();
+ uint8 secLevel = GetSecurity();
TC_LOG_DEBUG("rbac", "WorldSession::LoadPermissions [AccountId: %u, Name: %s, realmId: %d, secLevel: %u]",
- id, name.c_str(), realmID, secLevel);
+ id, _accountName.c_str(), realmID, secLevel);
+
+ _RBACData = new rbac::RBACData(id, _accountName, realmID, secLevel);
+ return _RBACData->LoadFromDBAsync();
+}
+
+class AccountInfoQueryHolderPerRealm : public SQLQueryHolder
+{
+public:
+ enum
+ {
+ GLOBAL_ACCOUNT_DATA = 0,
+ TUTORIALS,
+
+ MAX_QUERIES
+ };
+
+ AccountInfoQueryHolderPerRealm() { SetSize(MAX_QUERIES); }
+
+ bool Initialize(uint32 accountId)
+ {
+ bool ok = true;
+
+ PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_ACCOUNT_DATA);
+ stmt->setUInt32(0, accountId);
+ ok = SetPreparedQuery(GLOBAL_ACCOUNT_DATA, stmt) && ok;
+
+ stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_TUTORIALS);
+ stmt->setUInt32(0, accountId);
+ ok = SetPreparedQuery(TUTORIALS, stmt) && ok;
+
+ return ok;
+ }
+};
+
+void WorldSession::InitializeSession()
+{
+ AccountInfoQueryHolderPerRealm* realmHolder = new AccountInfoQueryHolderPerRealm();
+ if (!realmHolder->Initialize(GetAccountId()))
+ {
+ delete realmHolder;
+ SendAuthResponse(AUTH_SYSTEM_ERROR, false);
+ return;
+ }
+
+ _realmAccountLoginCallback = CharacterDatabase.DelayQueryHolder(realmHolder);
+}
+
+void WorldSession::InitializeSessionCallback(SQLQueryHolder* realmHolder)
+{
+ LoadAccountData(realmHolder->GetPreparedResult(AccountInfoQueryHolderPerRealm::GLOBAL_ACCOUNT_DATA), GLOBAL_CACHE_MASK);
+ LoadTutorialsData(realmHolder->GetPreparedResult(AccountInfoQueryHolderPerRealm::TUTORIALS));
+
+ if (!m_inQueue)
+ SendAuthResponse(AUTH_OK, true);
+ else
+ SendAuthWaitQue(0);
+
+ SetInQueue(false);
+ ResetTimeOutTime();
+
+ SendAddonsInfo();
+ SendClientCacheVersion(sWorld->getIntConfig(CONFIG_CLIENTCACHE_VERSION));
+ SendTutorialsData();
+
+ delete realmHolder;
}
rbac::RBACData* WorldSession::GetRBACData()
diff --git a/src/server/game/Server/WorldSession.h b/src/server/game/Server/WorldSession.h
index 6b1279e3e0c..af2d2d22c57 100644
--- a/src/server/game/Server/WorldSession.h
+++ b/src/server/game/Server/WorldSession.h
@@ -249,7 +249,7 @@ struct PacketCounter
class WorldSession
{
public:
- WorldSession(uint32 id, std::shared_ptr<WorldSocket> sock, AccountTypes sec, uint8 expansion, time_t mute_time, LocaleConstant locale, uint32 recruiter, bool isARecruiter);
+ WorldSession(uint32 id, std::string&& name, std::shared_ptr<WorldSocket> sock, AccountTypes sec, uint8 expansion, time_t mute_time, LocaleConstant locale, uint32 recruiter, bool isARecruiter);
~WorldSession();
bool PlayerLoading() const { return m_playerLoading; }
@@ -258,7 +258,7 @@ class WorldSession
bool PlayerRecentlyLoggedOut() const { return m_playerRecentlyLogout; }
bool PlayerDisconnected() const { return !m_Socket; }
- void ReadAddonsInfo(WorldPacket& data);
+ void ReadAddonsInfo(ByteBuffer& data);
void SendAddonsInfo();
void ReadMovementInfo(WorldPacket& data, MovementInfo* mi);
@@ -276,9 +276,13 @@ class WorldSession
void SendAuthResponse(uint8 code, bool shortForm, uint32 queuePos = 0);
void SendClientCacheVersion(uint32 version);
+ void InitializeSession();
+ void InitializeSessionCallback(SQLQueryHolder* realmHolder);
+
rbac::RBACData* GetRBACData();
bool HasPermission(uint32 permissionId);
void LoadPermissions();
+ PreparedQueryResultFuture LoadPermissionsAsync();
void InvalidateRBACData(); // Used to force LoadPermissions at next HasPermission check
AccountTypes GetSecurity() const { return _security; }
@@ -358,10 +362,9 @@ class WorldSession
AccountData* GetAccountData(AccountDataType type) { return &m_accountData[type]; }
void SetAccountData(AccountDataType type, time_t tm, std::string const& data);
void SendAccountDataTimes(uint32 mask);
- void LoadGlobalAccountData();
void LoadAccountData(PreparedQueryResult result, uint32 mask);
- void LoadTutorialsData();
+ void LoadTutorialsData(PreparedQueryResult result);
void SendTutorialsData();
void SaveTutorialsData(SQLTransaction& trans);
uint32 GetTutorialInt(uint8 index) const { return m_Tutorials[index]; }
@@ -965,6 +968,7 @@ class WorldSession
void InitializeQueryCallbackParameters();
void ProcessQueryCallbacks();
+ QueryResultHolderFuture _realmAccountLoginCallback;
PreparedQueryResultFuture _charEnumCallback;
PreparedQueryResultFuture _addIgnoreCallback;
PreparedQueryResultFuture _stablePetCallback;
@@ -1034,6 +1038,7 @@ class WorldSession
AccountTypes _security;
uint32 _accountId;
+ std::string _accountName;
uint8 m_expansion;
typedef std::list<AddonInfo> AddonsList;
diff --git a/src/server/game/Server/WorldSocket.cpp b/src/server/game/Server/WorldSocket.cpp
index 066a4e501be..1dc470744a1 100644
--- a/src/server/game/Server/WorldSocket.cpp
+++ b/src/server/game/Server/WorldSocket.cpp
@@ -35,10 +35,65 @@ WorldSocket::WorldSocket(tcp::socket&& socket)
void WorldSocket::Start()
{
+ std::string ip_address = GetRemoteIpAddress().to_string();
+ PreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_SEL_IP_INFO);
+ stmt->setString(0, ip_address);
+ stmt->setUInt32(1, inet_addr(ip_address.c_str()));
+
+ {
+ std::lock_guard<std::mutex> guard(_queryLock);
+ _queryCallback = io_service().wrap(std::bind(&WorldSocket::CheckIpCallback, this, std::placeholders::_1));
+ _queryFuture = LoginDatabase.AsyncQuery(stmt);
+ }
+}
+
+void WorldSocket::CheckIpCallback(PreparedQueryResult result)
+{
+ if (result)
+ {
+ bool banned = false;
+ do
+ {
+ Field* fields = result->Fetch();
+ if (fields[0].GetUInt64() != 0)
+ banned = true;
+
+ if (!fields[1].GetString().empty())
+ _ipCountry = fields[1].GetString();
+
+ } while (result->NextRow());
+
+ if (banned)
+ {
+ SendAuthResponseError(AUTH_REJECT);
+ TC_LOG_ERROR("network", "WorldSocket::CheckIpCallback: Sent Auth Response (IP %s banned).", GetRemoteIpAddress().to_string().c_str());
+ DelayedCloseSocket();
+ return;
+ }
+ }
+
AsyncRead();
HandleSendAuthSession();
}
+bool WorldSocket::Update()
+{
+ if (!BaseSocket::Update())
+ return false;
+
+ {
+ std::lock_guard<std::mutex> guard(_queryLock);
+ if (_queryFuture.valid() && _queryFuture.wait_for(std::chrono::seconds(0)) == std::future_status::ready)
+ {
+ auto callback = std::move(_queryCallback);
+ _queryCallback = nullptr;
+ callback(_queryFuture.get());
+ }
+ }
+
+ return true;
+}
+
void WorldSocket::HandleSendAuthSession()
{
WorldPacket packet(SMSG_AUTH_CHALLENGE, 37);
@@ -111,13 +166,15 @@ void WorldSocket::ReadHandler()
}
// just received fresh new payload
- if (!ReadDataHandler())
+ ReadDataHandlerResult result = ReadDataHandler();
+ _headerBuffer.Reset();
+ if (result != ReadDataHandlerResult::Ok)
{
- CloseSocket();
+ if (result != ReadDataHandlerResult::WaitingForQuery)
+ CloseSocket();
+
return;
}
-
- _headerBuffer.Reset();
}
AsyncRead();
@@ -145,7 +202,72 @@ bool WorldSocket::ReadHeaderHandler()
return true;
}
-bool WorldSocket::ReadDataHandler()
+struct AuthSession
+{
+ uint32 BattlegroupID = 0;
+ uint32 LoginServerType = 0;
+ uint32 RealmID = 0;
+ uint32 Build = 0;
+ uint32 LocalChallenge = 0;
+ uint32 LoginServerID = 0;
+ uint32 RegionID = 0;
+ uint64 DosResponse = 0;
+ uint8 Digest[SHA_DIGEST_LENGTH] = {};
+ std::string Account;
+ ByteBuffer AddonInfo;
+};
+
+struct AccountInfo
+{
+ uint32 Id;
+ BigNumber SessionKey;
+ std::string LastIP;
+ bool IsLockedToIP;
+ std::string LockCountry;
+ uint8 Expansion;
+ int64 MuteTime;
+ LocaleConstant Locale;
+ uint32 Recruiter;
+ std::string OS;
+ bool IsRectuiter;
+ AccountTypes Security;
+ bool IsBanned;
+
+ explicit AccountInfo(Field* fields)
+ {
+ // 0 1 2 3 4 5 6 7 8 9 10
+ // SELECT a.id, a.sessionkey, a.last_ip, a.locked, a.lock_country, a.expansion, a.mutetime, a.locale, a.recruiter, a.os, aa.gmLevel,
+ // 11 12
+ // ab.unbandate > UNIX_TIMESTAMP() OR ab.unbandate = ab.bandate, r.id
+ // FROM account a
+ // LEFT JOIN account_access aa ON a.id = aa.id AND aa.RealmID IN (-1, ?)
+ // LEFT JOIN account_banned ab ON a.id = ab.id
+ // LEFT JOIN account r ON a.id = r.recruiter
+ // WHERE a.username = ? ORDER BY aa.RealmID DESC LIMIT 1
+ Id = fields[0].GetUInt32();
+ SessionKey.SetHexStr(fields[1].GetCString());
+ LastIP = fields[2].GetString();
+ IsLockedToIP = fields[3].GetBool();
+ LockCountry = fields[4].GetString();
+ Expansion = fields[5].GetUInt8();
+ MuteTime = fields[6].GetInt64();
+ Locale = LocaleConstant(fields[7].GetUInt8());
+ Recruiter = fields[8].GetUInt32();
+ OS = fields[9].GetString();
+ Security = AccountTypes(fields[10].GetUInt8());
+ IsBanned = fields[11].GetUInt64() != 0;
+ IsRectuiter = fields[12].GetUInt32() != 0;
+
+ uint32 world_expansion = sWorld->getIntConfig(CONFIG_EXPANSION);
+ if (Expansion > world_expansion)
+ Expansion = world_expansion;
+
+ if (Locale >= TOTAL_LOCALES)
+ Locale = LOCALE_enUS;
+ }
+};
+
+WorldSocket::ReadDataHandlerResult WorldSocket::ReadDataHandler()
{
ClientPktHeader* header = reinterpret_cast<ClientPktHeader*>(_headerBuffer.GetReadPointer());
@@ -162,7 +284,7 @@ bool WorldSocket::ReadDataHandler()
{
case CMSG_PING:
LogOpcodeText(opcode, sessionGuard);
- return HandlePing(packet);
+ return HandlePing(packet) ? ReadDataHandlerResult::Ok : ReadDataHandlerResult::Error;
case CMSG_AUTH_SESSION:
LogOpcodeText(opcode, sessionGuard);
if (_authed)
@@ -170,11 +292,11 @@ bool WorldSocket::ReadDataHandler()
// locking just to safely log offending user is probably overkill but we are disconnecting him anyway
if (sessionGuard.try_lock())
TC_LOG_ERROR("network", "WorldSocket::ProcessIncoming: received duplicate CMSG_AUTH_SESSION from %s", _worldSession->GetPlayerInfo().c_str());
- return false;
+ return ReadDataHandlerResult::Error;
}
HandleAuthSession(packet);
- break;
+ return ReadDataHandlerResult::WaitingForQuery;
case CMSG_KEEP_ALIVE:
LogOpcodeText(opcode, sessionGuard);
break;
@@ -186,7 +308,7 @@ bool WorldSocket::ReadDataHandler()
{
TC_LOG_ERROR("network.opcode", "ProcessIncoming: Client not authed opcode = %u", uint32(opcode));
CloseSocket();
- return false;
+ return ReadDataHandlerResult::Error;
}
// Our Idle timer will reset on any non PING opcodes.
@@ -199,7 +321,7 @@ bool WorldSocket::ReadDataHandler()
}
}
- return true;
+ return ReadDataHandlerResult::Ok;
}
void WorldSocket::LogOpcodeText(uint16 opcode, std::unique_lock<std::mutex> const& guard) const
@@ -256,48 +378,35 @@ void WorldSocket::SendPacket(WorldPacket const& packet)
void WorldSocket::HandleAuthSession(WorldPacket& recvPacket)
{
- uint8 digest[SHA_DIGEST_LENGTH];
- uint32 clientSeed;
- uint8 security;
- uint32 id;
- LocaleConstant locale;
- std::string account;
- SHA1Hash sha;
- uint32 clientBuild;
- uint32 serverId, loginServerType, region, battlegroup, realmIndex;
- uint64 unk4;
- WorldPacket packet, SendAddonPacked;
- BigNumber k;
- bool wardenActive = sWorld->getBoolConfig(CONFIG_WARDEN_ENABLED);
+ std::shared_ptr<AuthSession> authSession = std::make_shared<AuthSession>();
// Read the content of the packet
- recvPacket >> clientBuild;
- recvPacket >> serverId; // Used for GRUNT only
- recvPacket >> account;
- recvPacket >> loginServerType; // 0 GRUNT, 1 Battle.net
- recvPacket >> clientSeed;
- recvPacket >> region >> battlegroup; // Used for Battle.net only
- recvPacket >> realmIndex; // realmId from auth_database.realmlist table
- recvPacket >> unk4;
- recvPacket.read(digest, 20);
-
- TC_LOG_DEBUG("network", "WorldSocket::HandleAuthSession: client %u, serverId %u, account %s, loginServerType %u, clientseed %u, realmIndex %u",
- clientBuild,
- serverId,
- account.c_str(),
- loginServerType,
- clientSeed,
- realmIndex);
+ recvPacket >> authSession->Build;
+ recvPacket >> authSession->LoginServerID;
+ recvPacket >> authSession->Account;
+ recvPacket >> authSession->LoginServerType;
+ recvPacket >> authSession->LocalChallenge;
+ recvPacket >> authSession->RegionID;
+ recvPacket >> authSession->BattlegroupID;
+ recvPacket >> authSession->RealmID; // realmId from auth_database.realmlist table
+ recvPacket >> authSession->DosResponse;
+ recvPacket.read(authSession->Digest, 20);
+ authSession->AddonInfo.append(recvPacket.contents() + recvPacket.rpos(), recvPacket.size() - recvPacket.rpos());
// Get the account information from the auth database
- // 0 1 2 3 4 5 6 7 8
- // SELECT id, sessionkey, last_ip, locked, expansion, mutetime, locale, recruiter, os FROM account WHERE username = ?
PreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_SEL_ACCOUNT_INFO_BY_NAME);
+ stmt->setInt32(0, int32(realmID));
+ stmt->setString(1, authSession->Account);
- stmt->setString(0, account);
-
- PreparedQueryResult result = LoginDatabase.Query(stmt);
+ {
+ std::lock_guard<std::mutex> guard(_queryLock);
+ _queryCallback = io_service().wrap(std::bind(&WorldSocket::HandleAuthSessionCallback, this, authSession, std::placeholders::_1));
+ _queryFuture = LoginDatabase.AsyncQuery(stmt);
+ }
+}
+void WorldSocket::HandleAuthSessionCallback(std::shared_ptr<AuthSession> authSession, PreparedQueryResult result)
+{
// Stop if the account is not found
if (!result)
{
@@ -308,32 +417,20 @@ void WorldSocket::HandleAuthSession(WorldPacket& recvPacket)
return;
}
- Field* fields = result->Fetch();
-
- uint8 expansion = fields[4].GetUInt8();
- uint32 world_expansion = sWorld->getIntConfig(CONFIG_EXPANSION);
- if (expansion > world_expansion)
- expansion = world_expansion;
+ AccountInfo account(result->Fetch());
// For hook purposes, we get Remoteaddress at this point.
std::string address = GetRemoteIpAddress().to_string();
// As we don't know if attempted login process by ip works, we update last_attempt_ip right away
- stmt = LoginDatabase.GetPreparedStatement(LOGIN_UPD_LAST_ATTEMPT_IP);
-
+ PreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_UPD_LAST_ATTEMPT_IP);
stmt->setString(0, address);
- stmt->setString(1, account);
-
+ stmt->setString(1, authSession->Account);
LoginDatabase.Execute(stmt);
// This also allows to check for possible "hack" attempts on account
- // id has to be fetched at this point, so that first actual account response that fails can be logged
- id = fields[0].GetUInt32();
-
- k.SetHexStr(fields[1].GetCString());
-
// even if auth credentials are bad, try using the session key we have - client cannot read auth response error without it
- _authCrypt.Init(&k);
+ _authCrypt.Init(&account.SessionKey);
// First reject the connection if packet contains invalid data or realm state doesn't allow logging in
if (sWorld->IsClosed())
@@ -344,7 +441,7 @@ void WorldSocket::HandleAuthSession(WorldPacket& recvPacket)
return;
}
- if (realmIndex != realmID)
+ if (authSession->RealmID != realmID)
{
SendAuthResponseError(REALM_LIST_REALM_NOT_FOUND);
TC_LOG_ERROR("network", "WorldSocket::HandleAuthSession: Sent Auth Response (bad realm).");
@@ -352,13 +449,12 @@ void WorldSocket::HandleAuthSession(WorldPacket& recvPacket)
return;
}
- std::string os = fields[8].GetString();
-
// Must be done before WorldSession is created
- if (wardenActive && os != "Win" && os != "OSX")
+ bool wardenActive = sWorld->getBoolConfig(CONFIG_WARDEN_ENABLED);
+ if (wardenActive && account.OS != "Win" && account.OS != "OSX")
{
SendAuthResponseError(AUTH_REJECT);
- TC_LOG_ERROR("network", "WorldSocket::HandleAuthSession: Client %s attempted to log in using invalid client OS (%s).", address.c_str(), os.c_str());
+ TC_LOG_ERROR("network", "WorldSocket::HandleAuthSession: Client %s attempted to log in using invalid client OS (%s).", address.c_str(), account.OS.c_str());
DelayedCloseSocket();
return;
}
@@ -366,135 +462,112 @@ void WorldSocket::HandleAuthSession(WorldPacket& recvPacket)
// Check that Key and account name are the same on client and server
uint32 t = 0;
- sha.UpdateData(account);
+ SHA1Hash sha;
+ sha.UpdateData(authSession->Account);
sha.UpdateData((uint8*)&t, 4);
- sha.UpdateData((uint8*)&clientSeed, 4);
+ sha.UpdateData((uint8*)&authSession->LocalChallenge, 4);
sha.UpdateData((uint8*)&_authSeed, 4);
- sha.UpdateBigNumbers(&k, NULL);
+ sha.UpdateBigNumbers(&account.SessionKey, NULL);
sha.Finalize();
- if (memcmp(sha.GetDigest(), digest, SHA_DIGEST_LENGTH) != 0)
+ if (memcmp(sha.GetDigest(), authSession->Digest, SHA_DIGEST_LENGTH) != 0)
{
SendAuthResponseError(AUTH_FAILED);
- TC_LOG_ERROR("network", "WorldSocket::HandleAuthSession: Authentication failed for account: %u ('%s') address: %s", id, account.c_str(), address.c_str());
+ TC_LOG_ERROR("network", "WorldSocket::HandleAuthSession: Authentication failed for account: %u ('%s') address: %s", account.Id, authSession->Account.c_str(), address.c_str());
DelayedCloseSocket();
return;
}
///- Re-check ip locking (same check as in auth).
- if (fields[3].GetUInt8() == 1) // if ip is locked
+ if (account.IsLockedToIP)
{
- if (strcmp(fields[2].GetCString(), address.c_str()) != 0)
+ if (account.LastIP != address)
{
SendAuthResponseError(AUTH_FAILED);
- TC_LOG_DEBUG("network", "WorldSocket::HandleAuthSession: Sent Auth Response (Account IP differs. Original IP: %s, new IP: %s).", fields[2].GetCString(), address.c_str());
+ TC_LOG_DEBUG("network", "WorldSocket::HandleAuthSession: Sent Auth Response (Account IP differs. Original IP: %s, new IP: %s).", account.LastIP.c_str(), address.c_str());
// We could log on hook only instead of an additional db log, however action logger is config based. Better keep DB logging as well
- sScriptMgr->OnFailedAccountLogin(id);
+ sScriptMgr->OnFailedAccountLogin(account.Id);
+ DelayedCloseSocket();
+ return;
+ }
+ }
+ else if (!account.LockCountry.empty() && account.LockCountry != "00" && !_ipCountry.empty())
+ {
+ if (account.LockCountry != _ipCountry)
+ {
+ SendAuthResponseError(AUTH_FAILED);
+ TC_LOG_DEBUG("network", "WorldSocket::HandleAuthSession: Sent Auth Response (Account country differs. Original country: %s, new country: %s).", account.LockCountry.c_str(), _ipCountry.c_str());
+ // We could log on hook only instead of an additional db log, however action logger is config based. Better keep DB logging as well
+ sScriptMgr->OnFailedAccountLogin(account.Id);
DelayedCloseSocket();
return;
}
}
- int64 mutetime = fields[5].GetInt64();
+ int64 mutetime = account.MuteTime;
//! Negative mutetime indicates amount of seconds to be muted effective on next login - which is now.
if (mutetime < 0)
{
mutetime = time(NULL) + llabs(mutetime);
PreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_UPD_MUTE_TIME_LOGIN);
-
stmt->setInt64(0, mutetime);
- stmt->setUInt32(1, id);
-
+ stmt->setUInt32(1, account.Id);
LoginDatabase.Execute(stmt);
}
- locale = LocaleConstant(fields[6].GetUInt8());
- if (locale >= TOTAL_LOCALES)
- locale = LOCALE_enUS;
-
- uint32 recruiter = fields[7].GetUInt32();
- // Checks gmlevel per Realm
- stmt = LoginDatabase.GetPreparedStatement(LOGIN_GET_GMLEVEL_BY_REALMID);
-
- stmt->setUInt32(0, id);
- stmt->setInt32(1, int32(realmID));
-
- result = LoginDatabase.Query(stmt);
-
- if (!result)
- security = 0;
- else
- {
- fields = result->Fetch();
- security = fields[0].GetUInt8();
- }
-
- // Re-check account ban (same check as in auth)
- stmt = LoginDatabase.GetPreparedStatement(LOGIN_SEL_BANS);
-
- stmt->setUInt32(0, id);
- stmt->setString(1, address);
-
- PreparedQueryResult banresult = LoginDatabase.Query(stmt);
-
- if (banresult) // if account banned
+ if (account.IsBanned)
{
SendAuthResponseError(AUTH_BANNED);
TC_LOG_ERROR("network", "WorldSocket::HandleAuthSession: Sent Auth Response (Account banned).");
- sScriptMgr->OnFailedAccountLogin(id);
+ sScriptMgr->OnFailedAccountLogin(account.Id);
DelayedCloseSocket();
return;
}
// Check locked state for server
AccountTypes allowedAccountType = sWorld->GetPlayerSecurityLimit();
- TC_LOG_DEBUG("network", "Allowed Level: %u Player Level %u", allowedAccountType, AccountTypes(security));
- if (allowedAccountType > SEC_PLAYER && AccountTypes(security) < allowedAccountType)
+ TC_LOG_DEBUG("network", "Allowed Level: %u Player Level %u", allowedAccountType, account.Security);
+ if (allowedAccountType > SEC_PLAYER && account.Security < allowedAccountType)
{
SendAuthResponseError(AUTH_UNAVAILABLE);
TC_LOG_DEBUG("network", "WorldSocket::HandleAuthSession: User tries to login but his security level is not enough");
- sScriptMgr->OnFailedAccountLogin(id);
+ sScriptMgr->OnFailedAccountLogin(account.Id);
DelayedCloseSocket();
return;
}
- TC_LOG_DEBUG("network", "WorldSocket::HandleAuthSession: Client '%s' authenticated successfully from %s.",
- account.c_str(),
- address.c_str());
-
- // Check if this user is by any chance a recruiter
- stmt = LoginDatabase.GetPreparedStatement(LOGIN_SEL_ACCOUNT_RECRUITER);
-
- stmt->setUInt32(0, id);
-
- result = LoginDatabase.Query(stmt);
-
- bool isRecruiter = false;
- if (result)
- isRecruiter = true;
+ TC_LOG_DEBUG("network", "WorldSocket::HandleAuthSession: Client '%s' authenticated successfully from %s.", authSession->Account.c_str(), address.c_str());
// Update the last_ip in the database as it was successful for login
stmt = LoginDatabase.GetPreparedStatement(LOGIN_UPD_LAST_IP);
stmt->setString(0, address);
- stmt->setString(1, account);
+ stmt->setString(1, authSession->Account);
LoginDatabase.Execute(stmt);
// At this point, we can safely hook a successful login
- sScriptMgr->OnAccountLogin(id);
+ sScriptMgr->OnAccountLogin(account.Id);
_authed = true;
- _worldSession = new WorldSession(id, shared_from_this(), AccountTypes(security), expansion, mutetime, locale, recruiter, isRecruiter);
- _worldSession->LoadGlobalAccountData();
- _worldSession->LoadTutorialsData();
- _worldSession->ReadAddonsInfo(recvPacket);
- _worldSession->LoadPermissions();
+ _worldSession = new WorldSession(account.Id, std::move(authSession->Account), shared_from_this(), account.Security,
+ account.Expansion, mutetime, account.Locale, account.Recruiter, account.IsRectuiter);
+ _worldSession->ReadAddonsInfo(authSession->AddonInfo);
// Initialize Warden system only if it is enabled by config
if (wardenActive)
- _worldSession->InitWarden(&k, os);
+ _worldSession->InitWarden(&account.SessionKey, account.OS);
+
+ _queryCallback = io_service().wrap(std::bind(&WorldSocket::LoadSessionPermissionsCallback, this, std::placeholders::_1));
+ _queryFuture = _worldSession->LoadPermissionsAsync();
+ AsyncRead();
+}
+
+void WorldSocket::LoadSessionPermissionsCallback(PreparedQueryResult result)
+{
+ // RBAC must be loaded before adding session to check for skip queue permission
+ _worldSession->GetRBACData()->LoadFromDBCallback(result);
sWorld->AddSession(_worldSession);
}
diff --git a/src/server/game/Server/WorldSocket.h b/src/server/game/Server/WorldSocket.h
index 0f6acd0d72c..f0da520cf4c 100644
--- a/src/server/game/Server/WorldSocket.h
+++ b/src/server/game/Server/WorldSocket.h
@@ -45,8 +45,12 @@ struct ClientPktHeader
#pragma pack(pop)
+struct AuthSession;
+
class WorldSocket : public Socket<WorldSocket>
{
+ typedef Socket<WorldSocket> BaseSocket;
+
public:
WorldSocket(tcp::socket&& socket);
@@ -54,6 +58,7 @@ public:
WorldSocket& operator=(WorldSocket const& right) = delete;
void Start() override;
+ bool Update() override;
void SendPacket(WorldPacket const& packet);
@@ -61,9 +66,19 @@ protected:
void OnClose() override;
void ReadHandler() override;
bool ReadHeaderHandler();
- bool ReadDataHandler();
+
+ enum class ReadDataHandlerResult
+ {
+ Ok = 0,
+ Error = 1,
+ WaitingForQuery = 2
+ };
+
+ ReadDataHandlerResult ReadDataHandler();
private:
+ void CheckIpCallback(PreparedQueryResult result);
+
/// writes network.opcode log
/// accessing WorldSession is not threadsafe, only do it when holding _worldSessionLock
void LogOpcodeText(uint16 opcode, std::unique_lock<std::mutex> const& guard) const;
@@ -71,6 +86,8 @@ private:
void SendPacketAndLogOpcode(WorldPacket const& packet);
void HandleSendAuthSession();
void HandleAuthSession(WorldPacket& recvPacket);
+ void HandleAuthSessionCallback(std::shared_ptr<AuthSession> authSession, PreparedQueryResult result);
+ void LoadSessionPermissionsCallback(PreparedQueryResult result);
void SendAuthResponseError(uint8 code);
bool HandlePing(WorldPacket& recvPacket);
@@ -87,6 +104,11 @@ private:
MessageBuffer _headerBuffer;
MessageBuffer _packetBuffer;
+
+ std::mutex _queryLock;
+ PreparedQueryResultFuture _queryFuture;
+ std::function<void(PreparedQueryResult&&)> _queryCallback;
+ std::string _ipCountry;
};
#endif
diff --git a/src/server/game/Skills/SkillExtraItems.cpp b/src/server/game/Skills/SkillExtraItems.cpp
index 2c9a2a7bcfd..50e00b24133 100644
--- a/src/server/game/Skills/SkillExtraItems.cpp
+++ b/src/server/game/Skills/SkillExtraItems.cpp
@@ -210,7 +210,7 @@ bool CanCreatePerfectItem(Player* player, uint32 spellId, float &perfectCreateCh
// lack of entry means no perfection proc possible
if (!thisEntry)
return false;
-
+
// if you don't have the spell needed, then no procs for you
if (!player->HasSpell(thisEntry->requiredSpecialization))
return false;
@@ -218,7 +218,7 @@ bool CanCreatePerfectItem(Player* player, uint32 spellId, float &perfectCreateCh
// set values as appropriate
perfectCreateChance = thisEntry->perfectCreateChance;
perfectItemType = thisEntry->perfectItemType;
-
+
// and tell the caller to start rolling the dice
return true;
}
diff --git a/src/server/game/Spells/Auras/SpellAuraEffects.cpp b/src/server/game/Spells/Auras/SpellAuraEffects.cpp
index 79658032c6b..da3504f5a0a 100644
--- a/src/server/game/Spells/Auras/SpellAuraEffects.cpp
+++ b/src/server/game/Spells/Auras/SpellAuraEffects.cpp
@@ -1131,7 +1131,7 @@ void AuraEffect::HandleShapeshiftBoosts(Unit* target, bool apply) const
if (!spellInfo || !(spellInfo->HasAttribute(SPELL_ATTR0_PASSIVE) || spellInfo->HasAttribute(SPELL_ATTR0_HIDDEN_CLIENTSIDE)))
continue;
- if (spellInfo->Stances & (1<<(GetMiscValue()-1)))
+ if (spellInfo->Stances & (UI64LIT(1) << (GetMiscValue() - 1)))
target->CastSpell(target, itr->first, true, NULL, this);
}
@@ -1145,7 +1145,8 @@ void AuraEffect::HandleShapeshiftBoosts(Unit* target, bool apply) const
SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(glyph->SpellId);
if (!spellInfo || !(spellInfo->HasAttribute(SPELL_ATTR0_PASSIVE) || spellInfo->HasAttribute(SPELL_ATTR0_HIDDEN_CLIENTSIDE)))
continue;
- if (spellInfo->Stances & (1<<(GetMiscValue()-1)))
+
+ if (spellInfo->Stances & (UI64LIT(1) << (GetMiscValue() - 1)))
target->CastSpell(target, glyph->SpellId, true, NULL, this);
}
}
@@ -1155,7 +1156,7 @@ void AuraEffect::HandleShapeshiftBoosts(Unit* target, bool apply) const
if (target->ToPlayer()->HasSpell(17007))
{
SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(24932);
- if (spellInfo && spellInfo->Stances & (1<<(GetMiscValue()-1)))
+ if (spellInfo && spellInfo->Stances & (UI64LIT(1) << (GetMiscValue() - 1)))
target->CastSpell(target, 24932, true, NULL, this);
}
// Improved Barkskin - apply/remove armor bonus due to shapeshift
@@ -1275,14 +1276,8 @@ void AuraEffect::HandleShapeshiftBoosts(Unit* target, bool apply) const
for (Unit::AuraApplicationMap::iterator itr = tAuras.begin(); itr != tAuras.end();)
{
// Use the new aura to see on what stance the target will be
- uint32 newStance = 0;
- if (newAura)
- {
- if (newAura->GetMiscValue() > 0 && newAura->GetMiscValue() <= 32) //Not null and GetMiscValue is not == FORM_NONE
- newStance = 1 << (newAura->GetMiscValue() - 1);
- else
- TC_LOG_ERROR("spell.aura", "newAura->GetMiscValue() returned value %i for SpellID: %u when it was expecting a value in range [0..31] for a bitshift", newAura->GetMiscValue(), newAura->GetId());
- }
+ uint64 newStance = newAura ? (UI64LIT(1) << (newAura->GetMiscValue() - 1)) : 0;
+
// If the stances are not compatible with the spell, remove it
if (itr->second->GetBase()->IsRemovedOnShapeLost(target) && !(itr->second->GetBase()->GetSpellInfo()->Stances & newStance))
target->RemoveAura(itr);
diff --git a/src/server/game/Spells/Auras/SpellAuras.cpp b/src/server/game/Spells/Auras/SpellAuras.cpp
index e42f66c6ffb..93b8c3eb368 100644
--- a/src/server/game/Spells/Auras/SpellAuras.cpp
+++ b/src/server/game/Spells/Auras/SpellAuras.cpp
@@ -1487,7 +1487,7 @@ void Aura::HandleAuraSpecificMods(AuraApplication const* aurApp, Unit* caster, b
{
// This additional check is needed to add a minimal delay before cooldown in in effect
// to allow all bubbles broken by a single damage source proc mana return
- if (caster->GetSpellHistory()->GetRemainingCooldown(aura->GetId()) <= 11)
+ if (caster->GetSpellHistory()->GetRemainingCooldown(aura->GetSpellInfo()) <= 11)
break;
}
else // and add if needed
@@ -1920,9 +1920,7 @@ bool Aura::IsProcTriggeredOnEvent(AuraApplication* aurApp, ProcEventInfo& eventI
return false;
// do checks using conditions table
- ConditionList conditions = sConditionMgr->GetConditionsForNotGroupedEntry(CONDITION_SOURCE_TYPE_SPELL_PROC, GetId());
- ConditionSourceInfo condInfo = ConditionSourceInfo(eventInfo.GetActor(), eventInfo.GetActionTarget());
- if (!sConditionMgr->IsObjectMeetToConditions(condInfo, conditions))
+ if (!sConditionMgr->IsObjectMeetingNotGroupedConditions(CONDITION_SOURCE_TYPE_SPELL_PROC, GetId(), eventInfo.GetActor(), eventInfo.GetActionTarget()))
return false;
// AuraScript Hook
diff --git a/src/server/game/Spells/Spell.cpp b/src/server/game/Spells/Spell.cpp
index 0ae09913bc8..4f3b60d6f37 100644
--- a/src/server/game/Spells/Spell.cpp
+++ b/src/server/game/Spells/Spell.cpp
@@ -53,6 +53,7 @@
#include "SpellHistory.h"
#include "Battlefield.h"
#include "BattlefieldMgr.h"
+#include "TradeData.h"
extern pEffect SpellEffects[TOTAL_SPELL_EFFECTS];
@@ -1019,7 +1020,7 @@ void Spell::SelectImplicitNearbyTargets(SpellEffIndex effIndex, SpellImplicitTar
break;
}
- ConditionList* condList = m_spellInfo->Effects[effIndex].ImplicitTargetConditions;
+ ConditionContainer* condList = m_spellInfo->Effects[effIndex].ImplicitTargetConditions;
// handle emergency case - try to use other provided targets if no conditions provided
if (targetType.GetCheckType() == TARGET_CHECK_ENTRY && (!condList || condList->empty()))
@@ -1105,7 +1106,7 @@ void Spell::SelectImplicitConeTargets(SpellEffIndex effIndex, SpellImplicitTarge
std::list<WorldObject*> targets;
SpellTargetObjectTypes objectType = targetType.GetObjectType();
SpellTargetCheckTypes selectionType = targetType.GetCheckType();
- ConditionList* condList = m_spellInfo->Effects[effIndex].ImplicitTargetConditions;
+ ConditionContainer* condList = m_spellInfo->Effects[effIndex].ImplicitTargetConditions;
float coneAngle = float(M_PI) / 2;
float radius = m_spellInfo->Effects[effIndex].CalcRadius(m_caster) * m_spellValue->RadiusMod;
@@ -1725,7 +1726,7 @@ void Spell::SelectEffectTypeImplicitTargets(uint8 effIndex)
}
}
-uint32 Spell::GetSearcherTypeMask(SpellTargetObjectTypes objType, ConditionList* condList)
+uint32 Spell::GetSearcherTypeMask(SpellTargetObjectTypes objType, ConditionContainer* condList)
{
// this function selects which containers need to be searched for spell target
uint32 retMask = GRID_MAP_TYPE_MASK_ALL;
@@ -1793,7 +1794,7 @@ void Spell::SearchTargets(SEARCHER& searcher, uint32 containerMask, Unit* refere
}
}
-WorldObject* Spell::SearchNearbyTarget(float range, SpellTargetObjectTypes objectType, SpellTargetCheckTypes selectionType, ConditionList* condList)
+WorldObject* Spell::SearchNearbyTarget(float range, SpellTargetObjectTypes objectType, SpellTargetCheckTypes selectionType, ConditionContainer* condList)
{
WorldObject* target = NULL;
uint32 containerTypeMask = GetSearcherTypeMask(objectType, condList);
@@ -1805,7 +1806,7 @@ WorldObject* Spell::SearchNearbyTarget(float range, SpellTargetObjectTypes objec
return target;
}
-void Spell::SearchAreaTargets(std::list<WorldObject*>& targets, float range, Position const* position, Unit* referer, SpellTargetObjectTypes objectType, SpellTargetCheckTypes selectionType, ConditionList* condList)
+void Spell::SearchAreaTargets(std::list<WorldObject*>& targets, float range, Position const* position, Unit* referer, SpellTargetObjectTypes objectType, SpellTargetCheckTypes selectionType, ConditionContainer* condList)
{
uint32 containerTypeMask = GetSearcherTypeMask(objectType, condList);
if (!containerTypeMask)
@@ -1815,7 +1816,7 @@ void Spell::SearchAreaTargets(std::list<WorldObject*>& targets, float range, Pos
SearchTargets<Trinity::WorldObjectListSearcher<Trinity::WorldObjectSpellAreaTargetCheck> > (searcher, containerTypeMask, m_caster, position, range);
}
-void Spell::SearchChainTargets(std::list<WorldObject*>& targets, uint32 chainTargets, WorldObject* target, SpellTargetObjectTypes objectType, SpellTargetCheckTypes selectType, ConditionList* condList, bool isChainHeal)
+void Spell::SearchChainTargets(std::list<WorldObject*>& targets, uint32 chainTargets, WorldObject* target, SpellTargetObjectTypes objectType, SpellTargetCheckTypes selectType, ConditionContainer* condList, bool isChainHeal)
{
// max dist for jump target selection
float jumpRadius = 0.0f;
@@ -2428,9 +2429,8 @@ void Spell::DoAllEffectOnTarget(TargetInfo* target)
{
m_caster->CombatStart(unit, !m_spellInfo->HasAttribute(SPELL_ATTR3_NO_INITIAL_AGGRO));
- if (m_spellInfo->HasAttribute(SPELL_ATTR0_CU_AURA_CC))
- if (!unit->IsStandState())
- unit->SetStandState(UNIT_STAND_STATE_STAND);
+ if (!unit->IsStandState())
+ unit->SetStandState(UNIT_STAND_STATE_STAND);
}
if (spellHitTarget)
@@ -2514,8 +2514,8 @@ SpellMissInfo Spell::DoSpellHitOnUnit(Unit* unit, uint32 effectMask, bool scaleA
if (m_caster->_IsValidAttackTarget(unit, m_spellInfo))
{
unit->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_HITBYSPELL);
- /// @todo This is a hack. But we do not know what types of stealth should be interrupted by CC
- if (m_spellInfo->HasAttribute(SPELL_ATTR0_CU_AURA_CC) && unit->IsControlledByPlayer())
+
+ if (!m_spellInfo->HasAttribute(SPELL_ATTR0_CU_DONT_BREAK_STEALTH))
unit->RemoveAurasByType(SPELL_AURA_MOD_STEALTH);
}
else if (m_caster->IsFriendlyTo(unit))
@@ -4253,7 +4253,7 @@ void Spell::TakeCastItem()
for (int i = 0; i < MAX_ITEM_PROTO_SPELLS; ++i)
{
- if (proto->Spells[i].SpellId)
+ if (proto->Spells[i].SpellId > 0)
{
// item has limited charges
if (proto->Spells[i].SpellCharges)
@@ -4668,7 +4668,7 @@ SpellCastResult Spell::CheckCast(bool strict)
return SPELL_FAILED_NOT_READY;
}
- if (!m_caster->GetSpellHistory()->IsReady(m_spellInfo))
+ if (!m_caster->GetSpellHistory()->IsReady(m_spellInfo, m_castItemEntry))
{
if (m_triggeredByAuraSpell)
return SPELL_FAILED_DONT_REPORT;
@@ -4789,10 +4789,8 @@ SpellCastResult Spell::CheckCast(bool strict)
// check spell cast conditions from database
{
- ConditionSourceInfo condInfo = ConditionSourceInfo(m_caster);
- condInfo.mConditionTargets[1] = m_targets.GetObjectTarget();
- ConditionList conditions = sConditionMgr->GetConditionsForNotGroupedEntry(CONDITION_SOURCE_TYPE_SPELL, m_spellInfo->Id);
- if (!conditions.empty() && !sConditionMgr->IsObjectMeetToConditions(condInfo, conditions))
+ ConditionSourceInfo condInfo = ConditionSourceInfo(m_caster, m_targets.GetObjectTarget());
+ if (!sConditionMgr->IsObjectMeetingNotGroupedConditions(CONDITION_SOURCE_TYPE_SPELL, m_spellInfo->Id, condInfo))
{
// mLastFailedCondition can be NULL if there was an error processing the condition in Condition::Meets (i.e. wrong data for ConditionTarget or others)
if (condInfo.mLastFailedCondition && condInfo.mLastFailedCondition->ErrorType)
@@ -6046,7 +6044,7 @@ SpellCastResult Spell::CheckItems()
for (uint8 e = 0; e < MAX_ITEM_PROTO_SPELLS; ++e)
{
ItemTemplate const* proto = targetItem->GetTemplate();
- if (proto->Spells[e].SpellId && (
+ if (proto->Spells[e].SpellId > 0 && (
proto->Spells[e].SpellTrigger == ITEM_SPELLTRIGGER_ON_USE ||
proto->Spells[e].SpellTrigger == ITEM_SPELLTRIGGER_ON_NO_DELAY_USE))
{
@@ -7315,7 +7313,7 @@ namespace Trinity
{
WorldObjectSpellTargetCheck::WorldObjectSpellTargetCheck(Unit* caster, Unit* referer, SpellInfo const* spellInfo,
- SpellTargetCheckTypes selectionType, ConditionList* condList) : _caster(caster), _referer(referer), _spellInfo(spellInfo),
+ SpellTargetCheckTypes selectionType, ConditionContainer* condList) : _caster(caster), _referer(referer), _spellInfo(spellInfo),
_targetSelectionType(selectionType), _condList(condList)
{
if (condList)
@@ -7389,7 +7387,7 @@ bool WorldObjectSpellTargetCheck::operator()(WorldObject* target)
}
WorldObjectSpellNearbyTargetCheck::WorldObjectSpellNearbyTargetCheck(float range, Unit* caster, SpellInfo const* spellInfo,
- SpellTargetCheckTypes selectionType, ConditionList* condList)
+ SpellTargetCheckTypes selectionType, ConditionContainer* condList)
: WorldObjectSpellTargetCheck(caster, caster, spellInfo, selectionType, condList), _range(range), _position(caster) { }
bool WorldObjectSpellNearbyTargetCheck::operator()(WorldObject* target)
@@ -7404,7 +7402,7 @@ bool WorldObjectSpellNearbyTargetCheck::operator()(WorldObject* target)
}
WorldObjectSpellAreaTargetCheck::WorldObjectSpellAreaTargetCheck(float range, Position const* position, Unit* caster,
- Unit* referer, SpellInfo const* spellInfo, SpellTargetCheckTypes selectionType, ConditionList* condList)
+ Unit* referer, SpellInfo const* spellInfo, SpellTargetCheckTypes selectionType, ConditionContainer* condList)
: WorldObjectSpellTargetCheck(caster, referer, spellInfo, selectionType, condList), _range(range), _position(position) { }
bool WorldObjectSpellAreaTargetCheck::operator()(WorldObject* target)
@@ -7415,7 +7413,7 @@ bool WorldObjectSpellAreaTargetCheck::operator()(WorldObject* target)
}
WorldObjectSpellConeTargetCheck::WorldObjectSpellConeTargetCheck(float coneAngle, float range, Unit* caster,
- SpellInfo const* spellInfo, SpellTargetCheckTypes selectionType, ConditionList* condList)
+ SpellInfo const* spellInfo, SpellTargetCheckTypes selectionType, ConditionContainer* condList)
: WorldObjectSpellAreaTargetCheck(range, caster, caster, caster, spellInfo, selectionType, condList), _coneAngle(coneAngle) { }
bool WorldObjectSpellConeTargetCheck::operator()(WorldObject* target)
diff --git a/src/server/game/Spells/Spell.h b/src/server/game/Spells/Spell.h
index 1aac88ac602..6b96f56c538 100644
--- a/src/server/game/Spells/Spell.h
+++ b/src/server/game/Spells/Spell.h
@@ -374,12 +374,12 @@ class Spell
void SelectEffectTypeImplicitTargets(uint8 effIndex);
- uint32 GetSearcherTypeMask(SpellTargetObjectTypes objType, ConditionList* condList);
+ uint32 GetSearcherTypeMask(SpellTargetObjectTypes objType, ConditionContainer* condList);
template<class SEARCHER> void SearchTargets(SEARCHER& searcher, uint32 containerMask, Unit* referer, Position const* pos, float radius);
- WorldObject* SearchNearbyTarget(float range, SpellTargetObjectTypes objectType, SpellTargetCheckTypes selectionType, ConditionList* condList = NULL);
- void SearchAreaTargets(std::list<WorldObject*>& targets, float range, Position const* position, Unit* referer, SpellTargetObjectTypes objectType, SpellTargetCheckTypes selectionType, ConditionList* condList);
- void SearchChainTargets(std::list<WorldObject*>& targets, uint32 chainTargets, WorldObject* target, SpellTargetObjectTypes objectType, SpellTargetCheckTypes selectType, ConditionList* condList, bool isChainHeal);
+ WorldObject* SearchNearbyTarget(float range, SpellTargetObjectTypes objectType, SpellTargetCheckTypes selectionType, ConditionContainer* condList = NULL);
+ void SearchAreaTargets(std::list<WorldObject*>& targets, float range, Position const* position, Unit* referer, SpellTargetObjectTypes objectType, SpellTargetCheckTypes selectionType, ConditionContainer* condList);
+ void SearchChainTargets(std::list<WorldObject*>& targets, uint32 chainTargets, WorldObject* target, SpellTargetObjectTypes objectType, SpellTargetCheckTypes selectType, ConditionContainer* condList, bool isChainHeal);
GameObject* SearchSpellFocus();
@@ -583,6 +583,8 @@ class Spell
// Targets store structures and data
struct TargetInfo
{
+ // a bug in gcc-4.7 needs a destructor to call move operator instead of copy operator in std::vector remove
+ ~TargetInfo() { }
ObjectGuid targetGUID;
uint64 timeDelay;
SpellMissInfo missCondition:8;
@@ -712,10 +714,10 @@ namespace Trinity
SpellInfo const* _spellInfo;
SpellTargetCheckTypes _targetSelectionType;
ConditionSourceInfo* _condSrcInfo;
- ConditionList* _condList;
+ ConditionContainer* _condList;
WorldObjectSpellTargetCheck(Unit* caster, Unit* referer, SpellInfo const* spellInfo,
- SpellTargetCheckTypes selectionType, ConditionList* condList);
+ SpellTargetCheckTypes selectionType, ConditionContainer* condList);
~WorldObjectSpellTargetCheck();
bool operator()(WorldObject* target);
};
@@ -725,7 +727,7 @@ namespace Trinity
float _range;
Position const* _position;
WorldObjectSpellNearbyTargetCheck(float range, Unit* caster, SpellInfo const* spellInfo,
- SpellTargetCheckTypes selectionType, ConditionList* condList);
+ SpellTargetCheckTypes selectionType, ConditionContainer* condList);
bool operator()(WorldObject* target);
};
@@ -734,7 +736,7 @@ namespace Trinity
float _range;
Position const* _position;
WorldObjectSpellAreaTargetCheck(float range, Position const* position, Unit* caster,
- Unit* referer, SpellInfo const* spellInfo, SpellTargetCheckTypes selectionType, ConditionList* condList);
+ Unit* referer, SpellInfo const* spellInfo, SpellTargetCheckTypes selectionType, ConditionContainer* condList);
bool operator()(WorldObject* target);
};
@@ -742,7 +744,7 @@ namespace Trinity
{
float _coneAngle;
WorldObjectSpellConeTargetCheck(float coneAngle, float range, Unit* caster,
- SpellInfo const* spellInfo, SpellTargetCheckTypes selectionType, ConditionList* condList);
+ SpellInfo const* spellInfo, SpellTargetCheckTypes selectionType, ConditionContainer* condList);
bool operator()(WorldObject* target);
};
diff --git a/src/server/game/Spells/SpellEffects.cpp b/src/server/game/Spells/SpellEffects.cpp
index e587a59858a..b345c5affea 100644
--- a/src/server/game/Spells/SpellEffects.cpp
+++ b/src/server/game/Spells/SpellEffects.cpp
@@ -4373,11 +4373,14 @@ void Spell::EffectEnchantHeldItem(SpellEffIndex effIndex)
if (m_spellInfo->Effects[effIndex].MiscValue)
{
uint32 enchant_id = m_spellInfo->Effects[effIndex].MiscValue;
- int32 duration = m_spellInfo->GetDuration(); //Try duration index first ..
+ int32 duration = m_spellInfo->GetDuration(); // Try duration index first ..
if (!duration)
- duration = damage;//+1; //Base points after ..
+ duration = damage;//+1; // Base points after ..
if (!duration)
- duration = 10; //10 seconds for enchants which don't have listed duration
+ duration = 10 * IN_MILLISECONDS; // 10 seconds for enchants which don't have listed duration
+
+ if (m_spellInfo->Id == 14792) // Venomhide Poison
+ duration = 5 * MINUTE * IN_MILLISECONDS;
SpellItemEnchantmentEntry const* pEnchant = sSpellItemEnchantmentStore.LookupEntry(enchant_id);
if (!pEnchant)
@@ -4391,7 +4394,7 @@ void Spell::EffectEnchantHeldItem(SpellEffIndex effIndex)
return;
// Apply the temporary enchantment
- item->SetEnchantment(slot, enchant_id, duration*IN_MILLISECONDS, 0, m_caster->GetGUID());
+ item->SetEnchantment(slot, enchant_id, duration, 0, m_caster->GetGUID());
item_owner->ApplyEnchantment(item, slot, true);
}
}
diff --git a/src/server/game/Spells/SpellHistory.cpp b/src/server/game/Spells/SpellHistory.cpp
index 3c157f0b17b..ed5c31c25c6 100644
--- a/src/server/game/Spells/SpellHistory.cpp
+++ b/src/server/game/Spells/SpellHistory.cpp
@@ -41,8 +41,11 @@ struct SpellHistory::PersistenceHelper<Player>
if (!sSpellMgr->GetSpellInfo(*spellId))
return false;
+ cooldownEntry->SpellId = *spellId;
cooldownEntry->CooldownEnd = Clock::from_time_t(time_t(fields[2].GetUInt32()));
cooldownEntry->ItemId = fields[1].GetUInt32();
+ cooldownEntry->CategoryId = fields[3].GetUInt32();
+ cooldownEntry->CategoryEnd = Clock::from_time_t(time_t(fields[4].GetUInt32()));
return true;
}
@@ -51,6 +54,8 @@ struct SpellHistory::PersistenceHelper<Player>
stmt->setUInt32(index++, cooldown.first);
stmt->setUInt32(index++, cooldown.second.ItemId);
stmt->setUInt32(index++, uint32(Clock::to_time_t(cooldown.second.CooldownEnd)));
+ stmt->setUInt32(index++, cooldown.second.CategoryId);
+ stmt->setUInt32(index++, uint32(Clock::to_time_t(cooldown.second.CategoryEnd)));
}
};
@@ -68,8 +73,11 @@ struct SpellHistory::PersistenceHelper<Pet>
if (!sSpellMgr->GetSpellInfo(*spellId))
return false;
+ cooldownEntry->SpellId = *spellId;
cooldownEntry->CooldownEnd = Clock::from_time_t(time_t(fields[1].GetUInt32()));
cooldownEntry->ItemId = 0;
+ cooldownEntry->CategoryId = fields[2].GetUInt32();
+ cooldownEntry->CategoryEnd = Clock::from_time_t(time_t(fields[3].GetUInt32()));
return true;
}
@@ -77,6 +85,8 @@ struct SpellHistory::PersistenceHelper<Pet>
{
stmt->setUInt32(index++, cooldown.first);
stmt->setUInt32(index++, uint32(Clock::to_time_t(cooldown.second.CooldownEnd)));
+ stmt->setUInt32(index++, cooldown.second.CategoryId);
+ stmt->setUInt32(index++, uint32(Clock::to_time_t(cooldown.second.CategoryEnd)));
}
};
@@ -92,7 +102,11 @@ void SpellHistory::LoadFromDB(PreparedQueryResult cooldownsResult)
uint32 spellId;
CooldownEntry cooldown;
if (StatementInfo::ReadCooldown(cooldownsResult->Fetch(), &spellId, &cooldown))
+ {
_spellCooldowns[spellId] = cooldown;
+ if (cooldown.CategoryId)
+ _categoryCooldowns[cooldown.CategoryId] = &_spellCooldowns[spellId];
+ }
} while (cooldownsResult->NextRow());
}
@@ -125,10 +139,18 @@ void SpellHistory::Update()
{
SQLTransaction t;
Clock::time_point now = Clock::now();
+ for (auto itr = _categoryCooldowns.begin(); itr != _categoryCooldowns.end();)
+ {
+ if (itr->second->CategoryEnd < now)
+ itr = _categoryCooldowns.erase(itr);
+ else
+ ++itr;
+ }
+
for (auto itr = _spellCooldowns.begin(); itr != _spellCooldowns.end();)
{
if (itr->second.CooldownEnd < now)
- itr = _spellCooldowns.erase(itr);
+ itr = EraseCooldown(itr);
else
++itr;
}
@@ -136,29 +158,37 @@ void SpellHistory::Update()
void SpellHistory::HandleCooldowns(SpellInfo const* spellInfo, Item const* item, Spell* spell /*= nullptr*/)
{
+ HandleCooldowns(spellInfo, item ? item->GetEntry() : 0, spell);
+}
+
+void SpellHistory::HandleCooldowns(SpellInfo const* spellInfo, uint32 itemID, Spell* spell /*= nullptr*/)
+{
if (Player* player = _owner->ToPlayer())
{
// potions start cooldown until exiting combat
- if (item && (item->IsPotion() || spellInfo->IsCooldownStartedOnEvent()))
+ if (ItemTemplate const* itemTemplate = sObjectMgr->GetItemTemplate(itemID))
{
- player->SetLastPotionId(item->GetEntry());
- return;
+ if (itemTemplate->IsPotion() || spellInfo->IsCooldownStartedOnEvent())
+ {
+ player->SetLastPotionId(itemID);
+ return;
+ }
}
}
if (spellInfo->IsCooldownStartedOnEvent() || spellInfo->IsPassive() || (spell && spell->IsIgnoringCooldowns()))
return;
- StartCooldown(spellInfo, item ? item->GetEntry() : 0, spell);
+ StartCooldown(spellInfo, itemID, spell);
}
-bool SpellHistory::IsReady(SpellInfo const* spellInfo) const
+bool SpellHistory::IsReady(SpellInfo const* spellInfo, uint32 itemId /*= 0*/) const
{
if (spellInfo->PreventionType == SPELL_PREVENTION_TYPE_SILENCE)
if (IsSchoolLocked(spellInfo->GetSchoolMask()))
return false;
- if (HasCooldown(spellInfo->Id))
+ if (HasCooldown(spellInfo->Id, itemId))
return false;
return true;
@@ -168,42 +198,33 @@ template<>
void SpellHistory::WritePacket<Pet>(WorldPacket& packet) const
{
Clock::time_point now = Clock::now();
-
+
uint8 cooldownsCount = _spellCooldowns.size();
packet << uint8(cooldownsCount);
for (auto const& spellCooldown : _spellCooldowns)
{
- SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellCooldown.first);
- if (!spellInfo)
- {
- packet << uint32(0);
- packet << uint16(0);
- packet << uint32(0);
- packet << uint32(0);
- continue;
- }
-
- packet << uint32(spellCooldown.first); // spell ID
- packet << uint16(spellInfo->GetCategory()); // spell category
+ packet << uint32(spellCooldown.first); // spell ID
+ packet << uint16(spellCooldown.second.CategoryId); // spell category
if (!spellCooldown.second.OnHold)
{
- uint32 cooldownDuration = spellCooldown.second.CooldownEnd > now ? std::chrono::duration_cast<std::chrono::milliseconds>(spellCooldown.second.CooldownEnd - now).count() : 0;
- if (cooldownDuration <= 0)
+ std::chrono::milliseconds cooldownDuration = std::chrono::duration_cast<std::chrono::milliseconds>(spellCooldown.second.CooldownEnd - now);
+ if (cooldownDuration.count() <= 0)
{
packet << uint32(0);
packet << uint32(0);
continue;
}
- if (spellInfo->GetCategory())
+ std::chrono::milliseconds categoryDuration = std::chrono::duration_cast<std::chrono::milliseconds>(spellCooldown.second.CategoryEnd - now);
+ if (categoryDuration.count() > 0)
{
packet << uint32(0);
- packet << uint32(cooldownDuration);
+ packet << uint32(categoryDuration.count());
}
else
{
- packet << uint32(cooldownDuration);
+ packet << uint32(cooldownDuration.count());
packet << uint32(0);
}
}
@@ -216,23 +237,13 @@ void SpellHistory::WritePacket<Player>(WorldPacket& packet) const
Clock::time_point now = Clock::now();
Clock::time_point infTime = now + InfinityCooldownDelayCheck;
- uint16 cooldownsCount = _spellCooldowns.size();
- size_t dataPos = packet.wpos();
- packet << uint16(cooldownsCount);
+ packet << uint16(_spellCooldowns.size());
for (auto const& spellCooldown : _spellCooldowns)
{
- SpellInfo const* sEntry = sSpellMgr->GetSpellInfo(spellCooldown.first);
- if (!sEntry)
- {
- --cooldownsCount;
- continue;
- }
-
packet << uint32(spellCooldown.first);
-
packet << uint16(spellCooldown.second.ItemId); // cast item id
- packet << uint16(sEntry->GetCategory()); // spell category
+ packet << uint16(spellCooldown.second.CategoryId); // spell category
// send infinity cooldown in special format
if (spellCooldown.second.CooldownEnd >= infTime)
@@ -242,21 +253,26 @@ void SpellHistory::WritePacket<Player>(WorldPacket& packet) const
continue;
}
- uint32 cooldownDuration = spellCooldown.second.CooldownEnd > now ? std::chrono::duration_cast<std::chrono::milliseconds>(spellCooldown.second.CooldownEnd - now).count() : 0;
+ std::chrono::milliseconds cooldownDuration = std::chrono::duration_cast<std::chrono::milliseconds>(spellCooldown.second.CooldownEnd - now);
+ if (cooldownDuration.count() <= 0)
+ {
+ packet << uint32(0);
+ packet << uint32(0);
+ continue;
+ }
- if (sEntry->GetCategory()) // may be wrong, but anyway better than nothing...
+ std::chrono::milliseconds categoryDuration = std::chrono::duration_cast<std::chrono::milliseconds>(spellCooldown.second.CategoryEnd - now);
+ if (categoryDuration.count() >= 0)
{
packet << uint32(0); // cooldown
- packet << uint32(cooldownDuration); // category cooldown
+ packet << uint32(categoryDuration.count()); // category cooldown
}
else
{
- packet << uint32(cooldownDuration); // cooldown
+ packet << uint32(cooldownDuration.count()); // cooldown
packet << uint32(0); // category cooldown
}
}
-
- packet.put<uint16>(dataPos, cooldownsCount);
}
void SpellHistory::StartCooldown(SpellInfo const* spellInfo, uint32 itemId, Spell* spell /*= nullptr*/, bool onHold /*= false*/)
@@ -266,32 +282,7 @@ void SpellHistory::StartCooldown(SpellInfo const* spellInfo, uint32 itemId, Spel
int32 cooldown = -1;
int32 categoryCooldown = -1;
- // some special item spells without correct cooldown in SpellInfo
- // cooldown information stored in item prototype
- if (itemId)
- {
- if (ItemTemplate const* proto = sObjectMgr->GetItemTemplate(itemId))
- {
- for (uint8 idx = 0; idx < MAX_ITEM_PROTO_SPELLS; ++idx)
- {
- if (uint32(proto->Spells[idx].SpellId) == spellInfo->Id)
- {
- categoryId = proto->Spells[idx].SpellCategory;
- cooldown = proto->Spells[idx].SpellCooldown;
- categoryCooldown = proto->Spells[idx].SpellCategoryCooldown;
- break;
- }
- }
- }
- }
-
- // if no cooldown found above then base at DBC data
- if (cooldown < 0 && categoryCooldown < 0)
- {
- categoryId = spellInfo->GetCategory();
- cooldown = spellInfo->RecoveryTime;
- categoryCooldown = spellInfo->CategoryRecoveryTime;
- }
+ GetCooldownDurations(spellInfo, itemId, &cooldown, &categoryId, &categoryCooldown);
Clock::time_point curTime = Clock::now();
Clock::time_point catrecTime;
@@ -351,7 +342,7 @@ void SpellHistory::StartCooldown(SpellInfo const* spellInfo, uint32 itemId, Spel
// self spell cooldown
if (recTime != curTime)
{
- AddCooldown(spellInfo->Id, itemId, recTime, onHold);
+ AddCooldown(spellInfo->Id, itemId, recTime, categoryId, catrecTime, onHold);
if (needsCooldownPacket)
{
@@ -363,73 +354,51 @@ void SpellHistory::StartCooldown(SpellInfo const* spellInfo, uint32 itemId, Spel
}
}
}
-
- // category spells
- if (categoryId && catrecTime != curTime)
- {
- SpellCategoryStore::const_iterator i_scstore = sSpellsByCategoryStore.find(categoryId);
- if (i_scstore != sSpellsByCategoryStore.end())
- {
- for (SpellCategorySet::const_iterator i_scset = i_scstore->second.begin(); i_scset != i_scstore->second.end(); ++i_scset)
- {
- if (*i_scset == spellInfo->Id) // skip main spell, already handled above
- continue;
-
- AddCooldown(*i_scset, itemId, catrecTime, onHold);
- }
- }
- }
}
void SpellHistory::SendCooldownEvent(SpellInfo const* spellInfo, uint32 itemId /*= 0*/, Spell* spell /*= nullptr*/, bool startCooldown /*= true*/)
{
- // start cooldowns at server side, if any
- if (startCooldown)
- StartCooldown(spellInfo, itemId, spell);
-
+ // Send activate cooldown timer (possible 0) at client side
if (Player* player = GetPlayerOwner())
{
- // Send activate cooldown timer (possible 0) at client side
- WorldPacket data(SMSG_COOLDOWN_EVENT, 4 + 8);
- data << uint32(spellInfo->Id);
- data << uint64(_owner->GetGUID());
- player->SendDirectMessage(&data);
-
uint32 category = spellInfo->GetCategory();
- if (category && spellInfo->CategoryRecoveryTime)
- {
- SpellCategoryStore::const_iterator ct = sSpellsByCategoryStore.find(category);
- if (ct != sSpellsByCategoryStore.end())
- {
- for (auto const& cooldownPair : _spellCooldowns)
- {
- uint32 categorySpell = cooldownPair.first;
- if (!ct->second.count(categorySpell))
- continue;
-
- if (categorySpell == spellInfo->Id) // skip main spell, already handled above
- continue;
+ GetCooldownDurations(spellInfo, itemId, nullptr, &category, nullptr);
- SpellInfo const* spellInfo2 = sSpellMgr->EnsureSpellInfo(categorySpell);
- if (!spellInfo2->IsCooldownStartedOnEvent())
- continue;
+ auto categoryItr = _categoryCooldowns.find(category);
+ if (categoryItr != _categoryCooldowns.end() && categoryItr->second->SpellId != spellInfo->Id)
+ {
+ WorldPacket data(SMSG_COOLDOWN_EVENT, 4 + 8);
+ data << uint32(categoryItr->second->SpellId);
+ data << uint64(_owner->GetGUID());
+ player->SendDirectMessage(&data);
- data.Initialize(SMSG_COOLDOWN_EVENT, 4 + 8);
- data << uint32(categorySpell);
- data << uint64(_owner->GetGUID());
- player->SendDirectMessage(&data);
- }
- }
+ if (startCooldown)
+ StartCooldown(sSpellMgr->EnsureSpellInfo(categoryItr->second->SpellId), itemId, spell);
}
+
+ WorldPacket data(SMSG_COOLDOWN_EVENT, 4 + 8);
+ data << uint32(spellInfo->Id);
+ data << uint64(_owner->GetGUID());
+ player->SendDirectMessage(&data);
}
+
+ // start cooldowns at server side, if any
+ if (startCooldown)
+ StartCooldown(spellInfo, itemId, spell);
}
-void SpellHistory::AddCooldown(uint32 spellId, uint32 itemId, Clock::time_point cooldownEnd, bool onHold /*= false*/)
+void SpellHistory::AddCooldown(uint32 spellId, uint32 itemId, Clock::time_point cooldownEnd, uint32 categoryId, Clock::time_point categoryEnd, bool onHold /*= false*/)
{
CooldownEntry& cooldownEntry = _spellCooldowns[spellId];
+ cooldownEntry.SpellId = spellId;
cooldownEntry.CooldownEnd = cooldownEnd;
cooldownEntry.ItemId = itemId;
+ cooldownEntry.CategoryId = categoryId;
+ cooldownEntry.CategoryEnd = categoryEnd;
cooldownEntry.OnHold = onHold;
+
+ if (categoryId)
+ _categoryCooldowns[categoryId] = &cooldownEntry;
}
void SpellHistory::ModifyCooldown(uint32 spellId, int32 cooldownModMs)
@@ -443,7 +412,7 @@ void SpellHistory::ModifyCooldown(uint32 spellId, int32 cooldownModMs)
if (itr->second.CooldownEnd + offset > now)
itr->second.CooldownEnd += offset;
else
- _spellCooldowns.erase(itr);
+ EraseCooldown(itr);
if (Player* playerOwner = GetPlayerOwner())
{
@@ -477,7 +446,7 @@ void SpellHistory::ResetCooldown(CooldownStorageType::iterator& itr, bool update
}
}
- itr = _spellCooldowns.erase(itr);
+ itr = EraseCooldown(itr);
}
void SpellHistory::ResetAllCooldowns()
@@ -492,31 +461,55 @@ void SpellHistory::ResetAllCooldowns()
SendClearCooldowns(cooldowns);
}
+ _categoryCooldowns.clear();
_spellCooldowns.clear();
}
-bool SpellHistory::HasCooldown(uint32 spellId) const
+bool SpellHistory::HasCooldown(SpellInfo const* spellInfo, uint32 itemId /*= 0*/) const
{
- return _spellCooldowns.count(spellId) != 0;
+ if (_spellCooldowns.count(spellInfo->Id) != 0)
+ return true;
+
+ uint32 category = 0;
+ GetCooldownDurations(spellInfo, itemId, nullptr, &category, nullptr);
+ if (!category)
+ return false;
+
+ return _categoryCooldowns.count(category) != 0;
}
-uint32 SpellHistory::GetRemainingCooldown(uint32 spellId) const
+bool SpellHistory::HasCooldown(uint32 spellId, uint32 itemId /*= 0*/) const
{
- auto itr = _spellCooldowns.find(spellId);
- if (itr == _spellCooldowns.end())
- return 0;
+ return HasCooldown(sSpellMgr->EnsureSpellInfo(spellId), itemId);
+}
+
+uint32 SpellHistory::GetRemainingCooldown(SpellInfo const* spellInfo) const
+{
+ Clock::time_point end;
+ auto itr = _spellCooldowns.find(spellInfo->Id);
+ if (itr != _spellCooldowns.end())
+ end = itr->second.CooldownEnd;
+ else
+ {
+ auto catItr = _categoryCooldowns.find(spellInfo->GetCategory());
+ if (catItr == _categoryCooldowns.end())
+ return 0;
+
+ end = catItr->second->CategoryEnd;
+ }
Clock::time_point now = Clock::now();
- if (itr->second.CooldownEnd < now)
+ if (end < now)
return 0;
- Clock::duration remaining = itr->second.CooldownEnd - now;
+ Clock::duration remaining = end - now;
return uint32(std::chrono::duration_cast<std::chrono::milliseconds>(remaining).count());
}
void SpellHistory::LockSpellSchool(SpellSchoolMask schoolMask, uint32 lockoutTime)
{
- Clock::time_point lockoutEnd = Clock::now() + std::chrono::duration_cast<Clock::duration>(std::chrono::milliseconds(lockoutTime));
+ Clock::time_point now = Clock::now();
+ Clock::time_point lockoutEnd = now + std::chrono::duration_cast<Clock::duration>(std::chrono::milliseconds(lockoutTime));
for (uint32 i = 0; i < MAX_SPELL_SCHOOL; ++i)
if (SpellSchoolMask(1 << i) & schoolMask)
_schoolLockouts[i] = lockoutEnd;
@@ -553,10 +546,10 @@ void SpellHistory::LockSpellSchool(SpellSchoolMask schoolMask, uint32 lockoutTim
if (spellInfo->PreventionType != SPELL_PREVENTION_TYPE_SILENCE)
continue;
- if ((schoolMask & spellInfo->GetSchoolMask()) && GetRemainingCooldown(spellId) < lockoutTime)
+ if ((schoolMask & spellInfo->GetSchoolMask()) && GetRemainingCooldown(spellInfo) < lockoutTime)
{
cooldowns[spellId] = lockoutTime;
- AddCooldown(spellId, 0, lockoutEnd);
+ AddCooldown(spellId, 0, lockoutEnd, 0, now);
}
}
@@ -637,6 +630,48 @@ void SpellHistory::BuildCooldownPacket(WorldPacket& data, uint8 flags, PacketCoo
}
}
+void SpellHistory::GetCooldownDurations(SpellInfo const* spellInfo, uint32 itemId, int32* cooldown, uint32* categoryId, int32* categoryCooldown)
+{
+ ASSERT(cooldown || categoryId || categoryCooldown);
+ int32 tmpCooldown = -1;
+ uint32 tmpCategoryId = 0;
+ int32 tmpCategoryCooldown = -1;
+
+ // some special item spells without correct cooldown in SpellInfo
+ // cooldown information stored in item prototype
+ if (itemId)
+ {
+ if (ItemTemplate const* proto = sObjectMgr->GetItemTemplate(itemId))
+ {
+ for (uint8 idx = 0; idx < MAX_ITEM_PROTO_SPELLS; ++idx)
+ {
+ if (uint32(proto->Spells[idx].SpellId) == spellInfo->Id)
+ {
+ tmpCooldown = proto->Spells[idx].SpellCooldown;
+ tmpCategoryId = proto->Spells[idx].SpellCategory;
+ tmpCategoryCooldown = proto->Spells[idx].SpellCategoryCooldown;
+ break;
+ }
+ }
+ }
+ }
+
+ // if no cooldown found above then base at DBC data
+ if (tmpCooldown < 0 && tmpCategoryCooldown < 0)
+ {
+ tmpCooldown = spellInfo->RecoveryTime;
+ tmpCategoryId = spellInfo->GetCategory();
+ tmpCategoryCooldown = spellInfo->CategoryRecoveryTime;
+ }
+
+ if (cooldown)
+ *cooldown = tmpCooldown;
+ if (categoryId)
+ *categoryId = tmpCategoryId;
+ if (categoryCooldown)
+ *categoryCooldown = tmpCategoryCooldown;
+}
+
void SpellHistory::SaveCooldownStateBeforeDuel()
{
_spellCooldownsBeforeDuel = _spellCooldowns;
@@ -644,6 +679,7 @@ void SpellHistory::SaveCooldownStateBeforeDuel()
void SpellHistory::RestoreCooldownStateAfterDuel()
{
+ // category cooldows are not preserved.
if (Player* player = _owner->ToPlayer())
{
// add all profession CDs created while in duel (if any)
@@ -656,19 +692,14 @@ void SpellHistory::RestoreCooldownStateAfterDuel()
_spellCooldownsBeforeDuel[itr->first] = _spellCooldowns[itr->first];
}
- _spellCooldowns = _spellCooldownsBeforeDuel;
-
- // update the client: clear all cooldowns
- std::vector<int32> resetCooldowns;
- resetCooldowns.reserve(_spellCooldowns.size());
-
- for (auto itr = _spellCooldowns.begin(); itr != _spellCooldowns.end(); ++itr)
- resetCooldowns.push_back(itr->first);
-
- if (resetCooldowns.empty())
- return;
-
- SendClearCooldowns(resetCooldowns);
+ // check for spell with onHold active before and during the duel
+ for (auto itr = _spellCooldownsBeforeDuel.begin(); itr != _spellCooldownsBeforeDuel.end(); ++itr)
+ {
+ if (!itr->second.OnHold &&
+ _spellCooldowns.find(itr->first) != _spellCooldowns.end() &&
+ !_spellCooldowns[itr->first].OnHold)
+ _spellCooldowns[itr->first] = _spellCooldownsBeforeDuel[itr->first];
+ }
// update the client: restore old cooldowns
PacketCooldowns cooldowns;
@@ -678,14 +709,15 @@ void SpellHistory::RestoreCooldownStateAfterDuel()
Clock::time_point now = Clock::now();
uint32 cooldownDuration = itr->second.CooldownEnd > now ? std::chrono::duration_cast<std::chrono::milliseconds>(itr->second.CooldownEnd - now).count() : 0;
- if (cooldownDuration == 0)
+ // cooldownDuration must be between 0 and 10 minutes in order to avoid any visual bugs
+ if (cooldownDuration <= 0 || cooldownDuration > 10 * MINUTE * IN_MILLISECONDS || itr->second.OnHold)
continue;
cooldowns[itr->first] = cooldownDuration;
}
WorldPacket data;
- BuildCooldownPacket(data, SPELL_COOLDOWN_FLAG_NONE, cooldowns);
+ BuildCooldownPacket(data, SPELL_COOLDOWN_FLAG_INCLUDE_EVENT_COOLDOWNS, cooldowns);
player->SendDirectMessage(&data);
}
}
diff --git a/src/server/game/Spells/SpellHistory.h b/src/server/game/Spells/SpellHistory.h
index 86737ec7da9..db65cd50c3e 100644
--- a/src/server/game/Spells/SpellHistory.h
+++ b/src/server/game/Spells/SpellHistory.h
@@ -38,15 +38,16 @@ public:
struct CooldownEntry
{
- CooldownEntry() : ItemId(0), OnHold(false) { }
- CooldownEntry(Clock::time_point endTime, uint32 itemId) : CooldownEnd(endTime), ItemId(itemId), OnHold(false) { }
-
+ uint32 SpellId = 0;
Clock::time_point CooldownEnd;
- uint32 ItemId;
- bool OnHold;
+ uint32 ItemId = 0;
+ uint32 CategoryId = 0;
+ Clock::time_point CategoryEnd;
+ bool OnHold = false;
};
typedef std::unordered_map<uint32 /*spellId*/, CooldownEntry> CooldownStorageType;
+ typedef std::unordered_map<uint32 /*categoryId*/, CooldownEntry*> CategoryCooldownStorageType;
typedef std::unordered_map<uint32 /*categoryId*/, Clock::time_point> GlobalCooldownStorageType;
explicit SpellHistory(Unit* owner) : _owner(owner), _schoolLockouts() { }
@@ -60,7 +61,8 @@ public:
void Update();
void HandleCooldowns(SpellInfo const* spellInfo, Item const* item, Spell* spell = nullptr);
- bool IsReady(SpellInfo const* spellInfo) const;
+ void HandleCooldowns(SpellInfo const* spellInfo, uint32 itemID, Spell* spell = nullptr);
+ bool IsReady(SpellInfo const* spellInfo, uint32 itemId = 0) const;
template<class OwnerType>
void WritePacket(WorldPacket& packet) const;
@@ -74,10 +76,11 @@ public:
template<class Type, class Period>
void AddCooldown(uint32 spellId, uint32 itemId, std::chrono::duration<Type, Period> cooldownDuration)
{
- AddCooldown(spellId, itemId, Clock::now() + std::chrono::duration_cast<Clock::duration>(cooldownDuration));
+ Clock::time_point now = Clock::now();
+ AddCooldown(spellId, itemId, now + std::chrono::duration_cast<Clock::duration>(cooldownDuration), 0, now);
}
- void AddCooldown(uint32 spellId, uint32 itemId, Clock::time_point cooldownEnd, bool onHold = false);
+ void AddCooldown(uint32 spellId, uint32 itemId, Clock::time_point cooldownEnd, uint32 categoryId, Clock::time_point categoryEnd, bool onHold = false);
void ModifyCooldown(uint32 spellId, int32 cooldownModMs);
void ResetCooldown(uint32 spellId, bool update = false);
void ResetCooldown(CooldownStorageType::iterator& itr, bool update = false);
@@ -102,8 +105,9 @@ public:
}
void ResetAllCooldowns();
- bool HasCooldown(uint32 spellId) const;
- uint32 GetRemainingCooldown(uint32 spellId) const;
+ bool HasCooldown(SpellInfo const* spellInfo, uint32 itemId = 0) const;
+ bool HasCooldown(uint32 spellId, uint32 itemId = 0) const;
+ uint32 GetRemainingCooldown(SpellInfo const* spellInfo) const;
// School lockouts
void LockSpellSchool(SpellSchoolMask schoolMask, uint32 lockoutTime);
@@ -119,17 +123,25 @@ public:
CooldownStorageType::size_type GetCooldownsSizeForPacket() const { return _spellCooldowns.size(); }
void SaveCooldownStateBeforeDuel();
void RestoreCooldownStateAfterDuel();
-
+
private:
Player* GetPlayerOwner() const;
void SendClearCooldowns(std::vector<int32> const& cooldowns) const;
+ CooldownStorageType::iterator EraseCooldown(CooldownStorageType::iterator itr)
+ {
+ _categoryCooldowns.erase(itr->second.CategoryId);
+ return _spellCooldowns.erase(itr);
+ }
typedef std::unordered_map<uint32, uint32> PacketCooldowns;
void BuildCooldownPacket(WorldPacket& data, uint8 flags, PacketCooldowns const& cooldowns) const;
+ static void GetCooldownDurations(SpellInfo const* spellInfo, uint32 itemId, int32* cooldown, uint32* categoryId, int32* categoryCooldown);
+
Unit* _owner;
CooldownStorageType _spellCooldowns;
CooldownStorageType _spellCooldownsBeforeDuel;
+ CategoryCooldownStorageType _categoryCooldowns;
Clock::time_point _schoolLockouts[MAX_SPELL_SCHOOL];
GlobalCooldownStorageType _globalCooldowns;
diff --git a/src/server/game/Spells/SpellInfo.cpp b/src/server/game/Spells/SpellInfo.cpp
index ea5e4c8df0b..6486a7eada7 100644
--- a/src/server/game/Spells/SpellInfo.cpp
+++ b/src/server/game/Spells/SpellInfo.cpp
@@ -776,8 +776,8 @@ SpellInfo::SpellInfo(SpellEntry const* spellEntry)
AttributesEx6 = spellEntry->AttributesEx6;
AttributesEx7 = spellEntry->AttributesEx7;
AttributesCu = 0;
- Stances = spellEntry->Stances;
- StancesNot = spellEntry->StancesNot;
+ Stances = MAKE_PAIR64(spellEntry->Stances[0], spellEntry->Stances[1]);
+ StancesNot = MAKE_PAIR64(spellEntry->StancesNot[0], spellEntry->StancesNot[1]);
Targets = spellEntry->Targets;
TargetCreatureType = spellEntry->TargetCreatureType;
RequiresSpellFocus = spellEntry->RequiresSpellFocus;
@@ -1309,7 +1309,7 @@ SpellCastResult SpellInfo::CheckShapeshift(uint32 form) const
(Effects[0].Effect == SPELL_EFFECT_LEARN_SPELL || Effects[1].Effect == SPELL_EFFECT_LEARN_SPELL || Effects[2].Effect == SPELL_EFFECT_LEARN_SPELL))
return SPELL_CAST_OK;
- uint32 stanceMask = (form ? 1 << (form - 1) : 0);
+ uint64 stanceMask = (form ? UI64LIT(1) << (form - 1) : 0);
if (stanceMask & StancesNot) // can explicitly not be cast in this stance
return SPELL_FAILED_NOT_SHAPESHIFT;
@@ -2658,7 +2658,7 @@ void SpellInfo::_UnloadImplicitTargetConditionLists()
// find the same instances of ConditionList and delete them.
for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
{
- ConditionList* cur = Effects[i].ImplicitTargetConditions;
+ ConditionContainer* cur = Effects[i].ImplicitTargetConditions;
if (!cur)
continue;
for (uint8 j = i; j < MAX_SPELL_EFFECTS; ++j)
diff --git a/src/server/game/Spells/SpellInfo.h b/src/server/game/Spells/SpellInfo.h
index cfa9877405d..d042f926d02 100644
--- a/src/server/game/Spells/SpellInfo.h
+++ b/src/server/game/Spells/SpellInfo.h
@@ -176,7 +176,7 @@ enum SpellCustomAttributes
SPELL_ATTR0_CU_CONE_LINE = 0x00000004,
SPELL_ATTR0_CU_SHARE_DAMAGE = 0x00000008,
SPELL_ATTR0_CU_NO_INITIAL_THREAT = 0x00000010,
- SPELL_ATTR0_CU_AURA_CC = 0x00000040,
+ SPELL_ATTR0_CU_DONT_BREAK_STEALTH = 0x00000040,
SPELL_ATTR0_CU_DIRECT_DAMAGE = 0x00000100,
SPELL_ATTR0_CU_CHARGE = 0x00000200,
SPELL_ATTR0_CU_PICKPOCKET = 0x00000400,
@@ -249,7 +249,7 @@ public:
uint32 ItemType;
uint32 TriggerSpell;
flag96 SpellClassMask;
- std::list<Condition*>* ImplicitTargetConditions;
+ std::vector<Condition*>* ImplicitTargetConditions;
SpellEffectInfo() : _spellInfo(NULL), _effIndex(0), Effect(0), ApplyAuraName(0), Amplitude(0), DieSides(0),
RealPointsPerLevel(0), BasePoints(0), PointsPerComboPoint(0), ValueMultiplier(0), DamageMultiplier(0),
@@ -306,8 +306,8 @@ public:
uint32 AttributesEx6;
uint32 AttributesEx7;
uint32 AttributesCu;
- uint32 Stances;
- uint32 StancesNot;
+ uint64 Stances;
+ uint64 StancesNot;
uint32 Targets;
uint32 TargetCreatureType;
uint32 RequiresSpellFocus;
diff --git a/src/server/game/Spells/SpellMgr.cpp b/src/server/game/Spells/SpellMgr.cpp
index 55d0ad0b4dc..019b9e6f4d5 100644
--- a/src/server/game/Spells/SpellMgr.cpp
+++ b/src/server/game/Spells/SpellMgr.cpp
@@ -2801,14 +2801,6 @@ void SpellMgr::LoadSpellInfoCustomAttributes()
{
switch (spellInfo->Effects[j].ApplyAuraName)
{
- case SPELL_AURA_MOD_POSSESS:
- case SPELL_AURA_MOD_CONFUSE:
- case SPELL_AURA_MOD_CHARM:
- case SPELL_AURA_AOE_CHARM:
- case SPELL_AURA_MOD_FEAR:
- case SPELL_AURA_MOD_STUN:
- spellInfo->AttributesCu |= SPELL_ATTR0_CU_AURA_CC;
- break;
case SPELL_AURA_PERIODIC_HEAL:
case SPELL_AURA_PERIODIC_DAMAGE:
case SPELL_AURA_PERIODIC_DAMAGE_PERCENT:
@@ -2901,22 +2893,6 @@ void SpellMgr::LoadSpellInfoCustomAttributes()
if (spellInfo->SpellVisual[0] == 3879)
spellInfo->AttributesCu |= SPELL_ATTR0_CU_CONE_BACK;
- switch (spellInfo->SpellFamilyName)
- {
- case SPELLFAMILY_WARRIOR:
- // Shout
- if (spellInfo->SpellFamilyFlags[0] & 0x20000 || spellInfo->SpellFamilyFlags[1] & 0x20)
- spellInfo->AttributesCu |= SPELL_ATTR0_CU_AURA_CC;
- break;
- case SPELLFAMILY_DRUID:
- // Roar
- if (spellInfo->SpellFamilyFlags[0] & 0x8)
- spellInfo->AttributesCu |= SPELL_ATTR0_CU_AURA_CC;
- break;
- default:
- break;
- }
-
spellInfo->_InitializeExplicitTargetMask();
}
@@ -3182,13 +3158,13 @@ void SpellMgr::LoadSpellInfoCorrections()
// Master Shapeshifter: missing stance data for forms other than bear - bear version has correct data
// To prevent aura staying on target after talent unlearned
case 48420:
- spellInfo->Stances = 1 << (FORM_CAT - 1);
+ spellInfo->Stances = UI64LIT(1) << (FORM_CAT - 1);
break;
case 48421:
- spellInfo->Stances = 1 << (FORM_MOONKIN - 1);
+ spellInfo->Stances = UI64LIT(1) << (FORM_MOONKIN - 1);
break;
case 48422:
- spellInfo->Stances = 1 << (FORM_TREE - 1);
+ spellInfo->Stances = UI64LIT(1) << (FORM_TREE - 1);
break;
case 51466: // Elemental Oath (Rank 1)
case 51470: // Elemental Oath (Rank 2)
diff --git a/src/server/game/Tickets/TicketMgr.cpp b/src/server/game/Tickets/TicketMgr.cpp
index dbf66c6bd71..b4b3b8267c6 100644
--- a/src/server/game/Tickets/TicketMgr.cpp
+++ b/src/server/game/Tickets/TicketMgr.cpp
@@ -32,11 +32,11 @@ inline float GetAge(uint64 t) { return float(time(NULL) - t) / DAY; }
///////////////////////////////////////////////////////////////////////////////////////////////////
// GM ticket
-GmTicket::GmTicket() : _id(0), _posX(0), _posY(0), _posZ(0), _mapId(0), _createTime(0), _lastModifiedTime(0),
+GmTicket::GmTicket() : _id(0), _type(TICKET_TYPE_OPEN), _posX(0), _posY(0), _posZ(0), _mapId(0), _createTime(0), _lastModifiedTime(0),
_completed(false), _escalatedStatus(TICKET_UNASSIGNED), _viewed(false),
_needResponse(false), _needMoreHelp(false) { }
-GmTicket::GmTicket(Player* player) : _posX(0), _posY(0), _posZ(0), _mapId(0), _createTime(time(NULL)), _lastModifiedTime(time(NULL)),
+GmTicket::GmTicket(Player* player) : _type(TICKET_TYPE_OPEN), _posX(0), _posY(0), _posZ(0), _mapId(0), _createTime(time(NULL)), _lastModifiedTime(time(NULL)),
_completed(false), _escalatedStatus(TICKET_UNASSIGNED), _viewed(false),
_needResponse(false), _needMoreHelp(false)
{
@@ -49,10 +49,11 @@ GmTicket::~GmTicket() { }
bool GmTicket::LoadFromDB(Field* fields)
{
- // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
- // ticketId, guid, name, message, createTime, mapId, posX, posY, posZ, lastModifiedTime, closedBy, assignedTo, comment, response, completed, escalated, viewed, haveTicket
+ // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
+ // id, type, playerGuid, name, description, createTime, mapId, posX, posY, posZ, lastModifiedTime, closedBy, assignedTo, comment, response, completed, escalated, viewed, needMoreHelp
uint8 index = 0;
_id = fields[ index].GetUInt32();
+ _type = TicketType(fields[++index].GetUInt8());
_playerGuid = ObjectGuid(HighGuid::Player, fields[++index].GetUInt32());
_playerName = fields[++index].GetString();
_message = fields[++index].GetString();
@@ -75,11 +76,12 @@ bool GmTicket::LoadFromDB(Field* fields)
void GmTicket::SaveToDB(SQLTransaction& trans) const
{
- // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
- // id, playerGuid, name, description, createTime, mapId, posX, posY, posZ, lastModifiedTime, closedBy, assignedTo, comment, response, completed, escalated, viewed, needMoreHelp, resolvedBy
+ // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
+ // id, type, playerGuid, name, description, createTime, mapId, posX, posY, posZ, lastModifiedTime, closedBy, assignedTo, comment, response, completed, escalated, viewed, needMoreHelp, resolvedBy
uint8 index = 0;
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_REP_GM_TICKET);
stmt->setUInt32( index, _id);
+ stmt->setUInt8 (++index, uint8(_type));
stmt->setUInt32(++index, _playerGuid.GetCounter());
stmt->setString(++index, _playerName);
stmt->setString(++index, _message);
diff --git a/src/server/game/Tickets/TicketMgr.h b/src/server/game/Tickets/TicketMgr.h
index f7d3178978f..a90a1ec0206 100644
--- a/src/server/game/Tickets/TicketMgr.h
+++ b/src/server/game/Tickets/TicketMgr.h
@@ -77,6 +77,13 @@ enum LagReportType
LAG_REPORT_TYPE_SPELL = 6
};
+enum TicketType
+{
+ TICKET_TYPE_OPEN = 0,
+ TICKET_TYPE_CLOSED = 1,
+ TICKET_TYPE_CHARACTER_DELETED = 2,
+};
+
class GmTicket
{
public:
@@ -84,7 +91,7 @@ public:
GmTicket(Player* player);
~GmTicket();
- bool IsClosed() const { return !_closedBy.IsEmpty(); }
+ bool IsClosed() const { return _type != TICKET_TYPE_OPEN; }
bool IsCompleted() const { return _completed; }
bool IsFromPlayer(ObjectGuid guid) const { return guid == _playerGuid; }
bool IsAssigned() const { return !_assignedTo.IsEmpty(); }
@@ -118,7 +125,7 @@ public:
else if (_escalatedStatus == TICKET_UNASSIGNED)
_escalatedStatus = TICKET_ASSIGNED;
}
- void SetClosedBy(ObjectGuid value) { _closedBy = value; }
+ void SetClosedBy(ObjectGuid value) { _closedBy = value; _type = TICKET_TYPE_CLOSED; }
void SetResolvedBy(ObjectGuid value) { _resolvedBy = value; }
void SetCompleted() { _completed = true; }
void SetMessage(std::string const& message)
@@ -150,6 +157,7 @@ public:
private:
uint32 _id;
+ TicketType _type; // 0 = Open, 1 = Closed, 2 = Character deleted
ObjectGuid _playerGuid;
std::string _playerName;
float _posX;
@@ -159,8 +167,8 @@ private:
std::string _message;
uint64 _createTime;
uint64 _lastModifiedTime;
- ObjectGuid _closedBy; // 0 = Open, -1 = Console, playerGuid = player abandoned ticket or read the GM response message, other = GM who closed it.
- ObjectGuid _resolvedBy; // 0 = Open, -1 = Resolved by Console, GM who resolved it by closing or completing the ticket.
+ ObjectGuid _closedBy; // 0 = Open or Closed by Console (if type = 1), playerGuid = GM who closed it or player abandoned ticket or read the GM response message.
+ ObjectGuid _resolvedBy; // 0 = Open or Resolved by Console (if type = 1), playerGuid = GM who resolved it by closing or completing the ticket.
ObjectGuid _assignedTo;
std::string _comment;
bool _completed;
diff --git a/src/server/game/Tools/PlayerDump.cpp b/src/server/game/Tools/PlayerDump.cpp
index 1657b6cd028..0a47da1c788 100644
--- a/src/server/game/Tools/PlayerDump.cpp
+++ b/src/server/game/Tools/PlayerDump.cpp
@@ -21,6 +21,7 @@
#include "DatabaseEnv.h"
#include "UpdateFields.h"
#include "ObjectMgr.h"
+#include "Player.h"
#include "AccountMgr.h"
#include "World.h"
@@ -63,11 +64,15 @@ static DumpTable dumpTables[DUMP_TABLE_COUNT] =
};
// Low level functions
-static bool findtoknth(std::string &str, int n, std::string::size_type &s, std::string::size_type &e)
+static bool FindTokNth(std::string const& str, uint32 n, std::string::size_type& s, std::string::size_type& e)
{
- int i; s = e = 0;
- std::string::size_type size = str.size();
- for (i = 1; s < size && i < n; s++) if (str[s] == ' ') ++i;
+ s = e = 0;
+
+ uint32 i = 1;
+ for (; s < str.size() && i < n; ++s)
+ if (str[s] == ' ')
+ ++i;
+
if (i < n)
return false;
@@ -76,80 +81,86 @@ static bool findtoknth(std::string &str, int n, std::string::size_type &s, std::
return e != std::string::npos;
}
-std::string gettoknth(std::string &str, int n)
+std::string GetTokNth(std::string const& str, uint32 n)
{
std::string::size_type s = 0, e = 0;
- if (!findtoknth(str, n, s, e))
+ if (!FindTokNth(str, n, s, e))
return "";
- return str.substr(s, e-s);
+ return str.substr(s, e - s);
}
-bool findnth(std::string &str, int n, std::string::size_type &s, std::string::size_type &e)
+bool FindNth(std::string const& str, uint32 n, std::string::size_type& s, std::string::size_type& e)
{
- s = str.find("VALUES ('")+9;
- if (s == std::string::npos) return false;
+ s = str.find("VALUES ('") + 9;
+ if (s == std::string::npos)
+ return false;
do
{
e = str.find('\'', s);
- if (e == std::string::npos) return false;
- } while (str[e-1] == '\\');
+ if (e == std::string::npos)
+ return false;
+ } while (str[e - 1] == '\\');
- for (int i = 1; i < n; ++i)
+ for (uint32 i = 1; i < n; ++i)
{
do
{
- s = e+4;
+ s = e + 4;
e = str.find('\'', s);
- if (e == std::string::npos) return false;
- } while (str[e-1] == '\\');
+ if (e == std::string::npos)
+ return false;
+ } while (str[e - 1] == '\\');
}
return true;
}
-std::string gettablename(std::string &str)
+std::string GetTableName(std::string const& str)
{
- std::string::size_type s = 13;
+ static std::string::size_type const s = 13;
std::string::size_type e = str.find(_TABLE_SIM_, s);
if (e == std::string::npos)
return "";
- return str.substr(s, e-s);
+ return str.substr(s, e - s);
}
-bool changenth(std::string &str, int n, char const* with, bool insert = false, bool nonzero = false)
+bool ChangeNth(std::string& str, uint32 n, char const* with, bool insert = false, bool allowZero = false)
{
std::string::size_type s, e;
- if (!findnth(str, n, s, e))
+ if (!FindNth(str, n, s, e))
return false;
- if (nonzero && str.substr(s, e-s) == "0")
+ if (allowZero && str.substr(s, e - s) == "0")
return true; // not an error
+
if (!insert)
- str.replace(s, e-s, with);
+ str.replace(s, e - s, with);
else
str.insert(s, with);
return true;
}
-std::string getnth(std::string &str, int n)
+std::string GetNth(std::string& str, uint32 n)
{
std::string::size_type s, e;
- if (!findnth(str, n, s, e))
+ if (!FindNth(str, n, s, e))
return "";
return str.substr(s, e-s);
}
-bool changetoknth(std::string &str, int n, char const* with, bool insert = false, bool nonzero = false)
+bool ChangeTokNth(std::string& str, uint32 n, char const* with, bool insert = false, bool allowZero = false)
{
std::string::size_type s = 0, e = 0;
- if (!findtoknth(str, n, s, e))
+ if (!FindTokNth(str, n, s, e))
return false;
- if (nonzero && str.substr(s, e-s) == "0")
+
+ if (allowZero && str.substr(s, e - s) == "0")
return true; // not an error
+
if (!insert)
str.replace(s, e-s, with);
else
@@ -158,41 +169,28 @@ bool changetoknth(std::string &str, int n, char const* with, bool insert = false
return true;
}
-ObjectGuid::LowType registerNewGuid(ObjectGuid::LowType oldGuid, std::map<ObjectGuid::LowType, ObjectGuid::LowType> &guidMap, ObjectGuid::LowType hiGuid)
+ObjectGuid::LowType RegisterNewGuid(ObjectGuid::LowType oldGuid, PlayerDump::DumpGuidMap& guidMap, ObjectGuid::LowType guidOffset)
{
- std::map<ObjectGuid::LowType, ObjectGuid::LowType>::const_iterator itr = guidMap.find(oldGuid);
+ PlayerDumpWriter::DumpGuidMap::const_iterator itr = guidMap.find(oldGuid);
if (itr != guidMap.end())
return itr->second;
- ObjectGuid::LowType newguid = hiGuid + guidMap.size();
+ ObjectGuid::LowType newguid = guidOffset + guidMap.size();
guidMap[oldGuid] = newguid;
return newguid;
}
-bool changeGuid(std::string &str, int n, std::map<ObjectGuid::LowType, ObjectGuid::LowType> &guidMap, ObjectGuid::LowType hiGuid, bool nonzero = false)
+bool ChangeGuid(std::string& str, uint32 n, PlayerDump::DumpGuidMap& guidMap, ObjectGuid::LowType guidOffset, bool allowZero = false)
{
- char chritem[20];
- ObjectGuid::LowType oldGuid = atoi(getnth(str, n).c_str());
- if (nonzero && oldGuid == 0)
+ ObjectGuid::LowType oldGuid = strtoull(GetNth(str, n).c_str(), nullptr, 10);
+ if (allowZero && !oldGuid)
return true; // not an error
- ObjectGuid::LowType newGuid = registerNewGuid(oldGuid, guidMap, hiGuid);
- snprintf(chritem, 20, "%u", newGuid);
-
- return changenth(str, n, chritem, false, nonzero);
-}
-
-bool changetokGuid(std::string &str, int n, std::map<ObjectGuid::LowType, ObjectGuid::LowType> &guidMap, ObjectGuid::LowType hiGuid, bool nonzero = false)
-{
char chritem[20];
- ObjectGuid::LowType oldGuid = atoi(gettoknth(str, n).c_str());
- if (nonzero && oldGuid == 0)
- return true; // not an error
-
- ObjectGuid::LowType newGuid = registerNewGuid(oldGuid, guidMap, hiGuid);
+ ObjectGuid::LowType newGuid = RegisterNewGuid(oldGuid, guidMap, guidOffset);
snprintf(chritem, 20, "%u", newGuid);
- return changetoknth(str, n, chritem, false, nonzero);
+ return ChangeNth(str, n, chritem, false, allowZero);
}
std::string CreateDumpString(char const* tableName, QueryResult result)
@@ -223,29 +221,26 @@ std::string PlayerDumpWriter::GenerateWhereStr(char const* field, ObjectGuid::Lo
return wherestr.str();
}
-std::string PlayerDumpWriter::GenerateWhereStr(char const* field, GUIDs const& guids, GUIDs::const_iterator& itr)
+std::string PlayerDumpWriter::GenerateWhereStr(char const* field, DumpGuidSet const& guids, DumpGuidSet::const_iterator& itr)
{
std::ostringstream wherestr;
wherestr << field << " IN ('";
- for (; itr != guids.end(); ++itr)
+ for (; itr != guids.end();)
{
wherestr << *itr;
+ ++itr;
if (wherestr.str().size() > MAX_QUERY_LEN - 50) // near to max query
- {
- ++itr;
break;
- }
- GUIDs::const_iterator itr2 = itr;
- if (++itr2 != guids.end())
+ if (itr != guids.end())
wherestr << "', '";
}
wherestr << "')";
return wherestr.str();
}
-void StoreGUID(QueryResult result, uint32 field, std::set<ObjectGuid::LowType>& guids)
+void StoreGUID(QueryResult result, uint32 field, PlayerDump::DumpGuidSet &guids)
{
Field* fields = result->Fetch();
ObjectGuid::LowType guid = fields[field].GetUInt32();
@@ -253,20 +248,20 @@ void StoreGUID(QueryResult result, uint32 field, std::set<ObjectGuid::LowType>&
guids.insert(guid);
}
-void StoreGUID(QueryResult result, uint32 data, uint32 field, std::set<ObjectGuid::LowType>& guids)
+void StoreGUID(QueryResult result, uint32 data, uint32 field, PlayerDump::DumpGuidSet& guids)
{
Field* fields = result->Fetch();
std::string dataStr = fields[data].GetString();
- ObjectGuid::LowType guid = atoi(gettoknth(dataStr, field).c_str());
+ ObjectGuid::LowType guid = strtoull(GetTokNth(dataStr, field).c_str(), nullptr, 10);
if (guid)
guids.insert(guid);
}
// Writing - High-level functions
-bool PlayerDumpWriter::DumpTable(std::string& dump, ObjectGuid::LowType guid, char const*tableFrom, char const*tableTo, DumpTableType type)
+bool PlayerDumpWriter::DumpTable(std::string& dump, ObjectGuid::LowType guid, char const* tableFrom, char const* tableTo, DumpTableType type)
{
- GUIDs const* guids = NULL;
- char const* fieldname = NULL;
+ DumpGuidSet const* guids = nullptr;
+ char const* fieldname = nullptr;
switch (type)
{
@@ -281,20 +276,20 @@ bool PlayerDumpWriter::DumpTable(std::string& dump, ObjectGuid::LowType guid, ch
// for guid set stop if set is empty
if (guids && guids->empty())
- return true; // nothing to do
+ return true; // nothing to do
// setup for guids case start position
- GUIDs::const_iterator guids_itr;
+ DumpGuidSet::const_iterator guidsItr;
if (guids)
- guids_itr = guids->begin();
+ guidsItr = guids->begin();
do
{
std::string wherestr;
- if (guids) // set case, get next guids string
- wherestr = GenerateWhereStr(fieldname, *guids, guids_itr);
- else // not set case, get single guid string
+ if (guids) // set case, get next guids string
+ wherestr = GenerateWhereStr(fieldname, *guids, guidsItr);
+ else // not set case, get single guid string
wherestr = GenerateWhereStr(fieldname, guid);
QueryResult result = CharacterDatabase.PQuery("SELECT * FROM %s WHERE %s", tableFrom, wherestr.c_str());
@@ -336,7 +331,7 @@ bool PlayerDumpWriter::DumpTable(std::string& dump, ObjectGuid::LowType guid, ch
}
while (result->NextRow());
}
- while (guids && guids_itr != guids->end()); // not set case iterate single time, set case iterate for all guids
+ while (guids && guidsItr != guids->end()); // not set case iterate single time, set case iterate for all guids
return true;
}
@@ -345,7 +340,7 @@ bool PlayerDumpWriter::GetDump(ObjectGuid::LowType guid, std::string &dump)
dump = "IMPORTANT NOTE: THIS DUMPFILE IS MADE FOR USE WITH THE 'PDUMP' COMMAND ONLY - EITHER THROUGH INGAME CHAT OR ON CONSOLE!\n";
dump += "IMPORTANT NOTE: DO NOT apply it directly - it will irreversibly DAMAGE and CORRUPT your database! You have been warned!\n\n";
- for (int i = 0; i < DUMP_TABLE_COUNT; ++i)
+ for (uint8 i = 0; i < DUMP_TABLE_COUNT; ++i)
if (!DumpTable(dump, guid, dumpTables[i].name, dumpTables[i].name, dumpTables[i].type))
return false;
@@ -360,12 +355,14 @@ DumpReturn PlayerDumpWriter::WriteDump(const std::string& file, ObjectGuid::LowT
if (sWorld->getBoolConfig(CONFIG_PDUMP_NO_PATHS))
if (strstr(file.c_str(), "\\") || strstr(file.c_str(), "/"))
return DUMP_FILE_OPEN_ERROR;
+
if (sWorld->getBoolConfig(CONFIG_PDUMP_NO_OVERWRITE))
if (FILE* f = fopen(file.c_str(), "r"))
{
fclose(f);
return DUMP_FILE_OPEN_ERROR;
}
+
FILE* fout = fopen(file.c_str(), "w");
if (!fout)
return DUMP_FILE_OPEN_ERROR;
@@ -383,9 +380,9 @@ DumpReturn PlayerDumpWriter::WriteDump(const std::string& file, ObjectGuid::LowT
// Reading - High-level functions
#define ROLLBACK(DR) {fclose(fin); return (DR);}
-void fixNULLfields(std::string &line)
+void fixNULLfields(std::string& line)
{
- std::string nullString("'NULL'");
+ static std::string const nullString("'NULL'");
size_t pos = line.find(nullString);
while (pos != std::string::npos)
{
@@ -404,7 +401,7 @@ DumpReturn PlayerDumpReader::LoadDump(std::string const& file, uint32 account, s
if (!fin)
return DUMP_FILE_OPEN_ERROR;
- char newguid[20], chraccount[20], newpetid[20], currpetid[20], lastpetid[20];
+ char newguid[20], chraccount[20];
// make sure the same guid doesn't already exist and is safe to use
bool incHighest = true;
@@ -418,7 +415,8 @@ DumpReturn PlayerDumpReader::LoadDump(std::string const& file, uint32 account, s
if (result)
guid = sObjectMgr->GetGenerator<HighGuid::Player>().GetNextAfterMaxUsed(); // use first free if exists
- else incHighest = false;
+ else
+ incHighest = false;
}
else
guid = sObjectMgr->GetGenerator<HighGuid::Player>().GetNextAfterMaxUsed();
@@ -428,7 +426,7 @@ DumpReturn PlayerDumpReader::LoadDump(std::string const& file, uint32 account, s
if (!normalizePlayerName(name))
name.clear();
- if (ObjectMgr::CheckPlayerName(name, true) == CHAR_NAME_SUCCESS)
+ if (ObjectMgr::CheckPlayerName(name, sWorld->GetDefaultDbcLocale(), true) == CHAR_NAME_SUCCESS)
{
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHECK_NAME);
stmt->setString(0, name);
@@ -444,22 +442,22 @@ DumpReturn PlayerDumpReader::LoadDump(std::string const& file, uint32 account, s
snprintf(newguid, 20, "%u", guid);
snprintf(chraccount, 20, "%u", account);
- snprintf(newpetid, 20, "%u", sObjectMgr->GeneratePetNumber());
- snprintf(lastpetid, 20, "%s", "");
- std::map<uint32, uint32> items;
- std::map<uint32, uint32> mails;
- char buf[32000] = "";
+ DumpGuidMap items;
+ DumpGuidMap mails;
+ char buf[32000];
+ memset(buf, 0, sizeof(buf));
- typedef std::map<uint32, uint32> PetIds; // old->new petid relation
- typedef PetIds::value_type PetIdsPair;
- PetIds petids;
+ typedef std::map<uint32 /*old*/, uint32 /*new*/> PetIds;
+ PetIds petIds;
uint8 gender = GENDER_NONE;
uint8 race = RACE_NONE;
uint8 playerClass = 0;
uint8 level = 1;
+ ObjectGuid::LowType itemLowGuidOffset = sObjectMgr->GetGenerator<HighGuid::Item>().GetNextAfterMaxUsed();
+
SQLTransaction trans = CharacterDatabase.BeginTransaction();
while (!feof(fin))
{
@@ -495,7 +493,7 @@ DumpReturn PlayerDumpReader::LoadDump(std::string const& file, uint32 account, s
*/
// determine table name and load type
- std::string tn = gettablename(line);
+ std::string tn = GetTableName(line);
if (tn.empty())
{
TC_LOG_ERROR("misc", "LoadPlayerDump: Can't extract table name from line: '%s'!", line.c_str());
@@ -524,142 +522,139 @@ DumpReturn PlayerDumpReader::LoadDump(std::string const& file, uint32 account, s
{
case DTT_CHARACTER:
{
- if (!changenth(line, 1, newguid)) // characters.guid update
+ if (!ChangeNth(line, 1, newguid)) // characters.guid update
ROLLBACK(DUMP_FILE_BROKEN);
- if (!changenth(line, 2, chraccount)) // characters.account update
+ if (!ChangeNth(line, 2, chraccount)) // characters.account update
ROLLBACK(DUMP_FILE_BROKEN);
- race = uint8(atoul(getnth(line, 4).c_str()));
- playerClass = uint8(atoul(getnth(line, 5).c_str()));
- gender = uint8(atoul(getnth(line, 6).c_str()));
- level = uint8(atoul(getnth(line, 7).c_str()));
+ race = uint8(atoul(GetNth(line, 4).c_str()));
+ playerClass = uint8(atoul(GetNth(line, 5).c_str()));
+ gender = uint8(atoul(GetNth(line, 6).c_str()));
+ level = uint8(atoul(GetNth(line, 7).c_str()));
if (name.empty())
{
// check if the original name already exists
- name = getnth(line, 3);
+ name = GetNth(line, 3);
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHECK_NAME);
stmt->setString(0, name);
PreparedQueryResult result = CharacterDatabase.Query(stmt);
if (result)
- if (!changenth(line, 37, "1")) // characters.at_login set to "rename on login"
+ 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
+ else if (!ChangeNth(line, 3, name.c_str())) // characters.name
ROLLBACK(DUMP_FILE_BROKEN);
const char null[5] = "NULL";
- if (!changenth(line, 69, null)) // characters.deleteInfos_Account
+ if (!ChangeNth(line, 69, null)) // characters.deleteInfos_Account
ROLLBACK(DUMP_FILE_BROKEN);
- if (!changenth(line, 70, null)) // characters.deleteInfos_Name
+ if (!ChangeNth(line, 70, null)) // characters.deleteInfos_Name
ROLLBACK(DUMP_FILE_BROKEN);
- if (!changenth(line, 71, null)) // characters.deleteDate
+ if (!ChangeNth(line, 71, null)) // characters.deleteDate
ROLLBACK(DUMP_FILE_BROKEN);
break;
}
case DTT_CHAR_TABLE:
{
- if (!changenth(line, 1, newguid)) // character_*.guid update
+ if (!ChangeNth(line, 1, newguid)) // character_*.guid update
ROLLBACK(DUMP_FILE_BROKEN);
break;
}
case DTT_EQSET_TABLE:
{
- if (!changenth(line, 1, newguid))
+ if (!ChangeNth(line, 1, newguid))
ROLLBACK(DUMP_FILE_BROKEN); // character_equipmentsets.guid
char newSetGuid[24];
snprintf(newSetGuid, 24, UI64FMTD, sObjectMgr->GenerateEquipmentSetGuid());
- if (!changenth(line, 2, newSetGuid))
+ if (!ChangeNth(line, 2, newSetGuid))
ROLLBACK(DUMP_FILE_BROKEN); // character_equipmentsets.setguid
+
+ for (uint8 slot = 0; slot < EQUIPMENT_SLOT_END; ++slot)
+ if (!ChangeGuid(line, 7 + slot, items, itemLowGuidOffset, true))
+ ROLLBACK(DUMP_FILE_BROKEN); // character_equipmentsets.item
break;
}
case DTT_INVENTORY:
{
- if (!changenth(line, 1, newguid)) // character_inventory.guid update
+ if (!ChangeNth(line, 1, newguid)) // character_inventory.guid update
ROLLBACK(DUMP_FILE_BROKEN);
- if (!changeGuid(line, 2, items,sObjectMgr->GetGenerator<HighGuid::Item>().GetNextAfterMaxUsed(), true))
+ if (!ChangeGuid(line, 2, items, itemLowGuidOffset, true))
ROLLBACK(DUMP_FILE_BROKEN); // character_inventory.bag update
- if (!changeGuid(line, 4, items, sObjectMgr->GetGenerator<HighGuid::Item>().GetNextAfterMaxUsed()))
+ if (!ChangeGuid(line, 4, items, itemLowGuidOffset))
ROLLBACK(DUMP_FILE_BROKEN); // character_inventory.item update
break;
}
case DTT_MAIL: // mail
{
- if (!changeGuid(line, 1, mails, sObjectMgr->_mailId))
+ if (!ChangeGuid(line, 1, mails, sObjectMgr->_mailId))
ROLLBACK(DUMP_FILE_BROKEN); // mail.id update
- if (!changenth(line, 6, newguid)) // mail.receiver update
+ if (!ChangeNth(line, 6, newguid)) // mail.receiver update
ROLLBACK(DUMP_FILE_BROKEN);
break;
}
case DTT_MAIL_ITEM: // mail_items
{
- if (!changeGuid(line, 1, mails, sObjectMgr->_mailId))
+ if (!ChangeGuid(line, 1, mails, sObjectMgr->_mailId))
ROLLBACK(DUMP_FILE_BROKEN); // mail_items.id
- if (!changeGuid(line, 2, items, sObjectMgr->GetGenerator<HighGuid::Item>().GetNextAfterMaxUsed()))
+ if (!ChangeGuid(line, 2, items, itemLowGuidOffset))
ROLLBACK(DUMP_FILE_BROKEN); // mail_items.item_guid
- if (!changenth(line, 3, newguid)) // mail_items.receiver
+ if (!ChangeNth(line, 3, newguid)) // mail_items.receiver
ROLLBACK(DUMP_FILE_BROKEN);
break;
}
case DTT_ITEM:
{
// item, owner, data field:item, owner guid
- if (!changeGuid(line, 1, items, sObjectMgr->GetGenerator<HighGuid::Item>().GetNextAfterMaxUsed()))
+ if (!ChangeGuid(line, 1, items, itemLowGuidOffset))
ROLLBACK(DUMP_FILE_BROKEN); // item_instance.guid update
- if (!changenth(line, 3, newguid)) // item_instance.owner_guid update
+ if (!ChangeNth(line, 3, newguid)) // item_instance.owner_guid update
ROLLBACK(DUMP_FILE_BROKEN);
break;
}
case DTT_ITEM_GIFT:
{
- if (!changenth(line, 1, newguid)) // character_gifts.guid update
+ if (!ChangeNth(line, 1, newguid)) // character_gifts.guid update
ROLLBACK(DUMP_FILE_BROKEN);
- if (!changeGuid(line, 2, items, sObjectMgr->GetGenerator<HighGuid::Item>().GetNextAfterMaxUsed()))
+ if (!ChangeGuid(line, 2, items, itemLowGuidOffset))
ROLLBACK(DUMP_FILE_BROKEN); // character_gifts.item_guid update
break;
}
case DTT_PET:
{
- //store a map of old pet id to new inserted pet id for use by type 5 tables
- snprintf(currpetid, 20, "%s", getnth(line, 1).c_str());
- if (*lastpetid == '\0')
- snprintf(lastpetid, 20, "%s", currpetid);
- if (strcmp(lastpetid, currpetid) != 0)
- {
- snprintf(newpetid, 20, "%u", sObjectMgr->GeneratePetNumber());
- snprintf(lastpetid, 20, "%s", currpetid);
- }
+ // store a map of old pet id to new inserted pet id for use by DTT_PET_TABLE tables
+ std::string petIdStr = GetNth(line, 1);
- std::map<uint32, uint32> :: const_iterator petids_iter = petids.find(atoi(currpetid));
+ uint32 currentPetId = atoul(petIdStr.c_str());
- if (petids_iter == petids.end())
- {
- petids.insert(PetIdsPair(atoi(currpetid), atoi(newpetid)));
- }
+ PetIds::const_iterator petIdsItr = petIds.find(currentPetId);
+ if (petIdsItr != petIds.end()) // duplicate pets
+ ROLLBACK(DUMP_FILE_BROKEN);
+
+ uint32 newPetId = sObjectMgr->GeneratePetNumber();
+ petIds[currentPetId] = newPetId;
- if (!changenth(line, 1, newpetid)) // character_pet.id update
+ if (!ChangeNth(line, 1, std::to_string(newPetId).c_str())) // character_pet.id update
ROLLBACK(DUMP_FILE_BROKEN);
- if (!changenth(line, 3, newguid)) // character_pet.owner update
+ if (!ChangeNth(line, 3, newguid)) // character_pet.owner update
ROLLBACK(DUMP_FILE_BROKEN);
break;
}
case DTT_PET_TABLE: // pet_aura, pet_spell, pet_spell_cooldown
{
- snprintf(currpetid, 20, "%s", getnth(line, 1).c_str());
+ std::string petIdStr = GetNth(line, 1);
// lookup currpetid and match to new inserted pet id
- std::map<uint32, uint32> :: const_iterator petids_iter = petids.find(atoi(currpetid));
- if (petids_iter == petids.end()) // couldn't find new inserted id
+ PetIds::const_iterator petIdsItr = petIds.find(atoul(petIdStr.c_str()));
+ if (petIdsItr == petIds.end()) // couldn't find new inserted id
ROLLBACK(DUMP_FILE_BROKEN);
- snprintf(newpetid, 20, "%d", petids_iter->second);
-
- if (!changenth(line, 1, newpetid))
+ if (!ChangeNth(line, 1, std::to_string(petIdsItr->second).c_str()))
ROLLBACK(DUMP_FILE_BROKEN);
break;
@@ -677,7 +672,7 @@ DumpReturn PlayerDumpReader::LoadDump(std::string const& file, uint32 account, s
CharacterDatabase.CommitTransaction(trans);
// in case of name conflict player has to rename at login anyway
- sWorld->AddCharacterNameData(ObjectGuid(HighGuid::Player, guid), name, gender, race, playerClass, level);
+ sWorld->AddCharacterInfo(ObjectGuid(HighGuid::Player, guid), account, name, gender, race, playerClass, level);
sObjectMgr->GetGenerator<HighGuid::Item>().Set(sObjectMgr->GetGenerator<HighGuid::Item>().GetNextAfterMaxUsed() + items.size());
diff --git a/src/server/game/Tools/PlayerDump.h b/src/server/game/Tools/PlayerDump.h
index d0c5b90fec5..5cdcc4b6bb8 100644
--- a/src/server/game/Tools/PlayerDump.h
+++ b/src/server/game/Tools/PlayerDump.h
@@ -64,6 +64,10 @@ enum DumpReturn
class PlayerDump
{
+ public:
+ typedef std::set<ObjectGuid::LowType> DumpGuidSet;
+ typedef std::map<ObjectGuid::LowType, ObjectGuid::LowType> DumpGuidMap;
+
protected:
PlayerDump() { }
};
@@ -75,16 +79,15 @@ class PlayerDumpWriter : public PlayerDump
bool GetDump(ObjectGuid::LowType guid, std::string& dump);
DumpReturn WriteDump(std::string const& file, ObjectGuid::LowType guid);
- private:
- typedef std::set<ObjectGuid::LowType> GUIDs;
- bool DumpTable(std::string& dump, ObjectGuid::LowType guid, char const*tableFrom, char const*tableTo, DumpTableType type);
- std::string GenerateWhereStr(char const* field, GUIDs const& guids, GUIDs::const_iterator& itr);
+ private:
+ bool DumpTable(std::string& dump, ObjectGuid::LowType guid, char const* tableFrom, char const* tableTo, DumpTableType type);
+ std::string GenerateWhereStr(char const* field, DumpGuidSet const& guids, DumpGuidSet::const_iterator& itr);
std::string GenerateWhereStr(char const* field, ObjectGuid::LowType guid);
- GUIDs pets;
- GUIDs mails;
- GUIDs items;
+ DumpGuidSet pets;
+ DumpGuidSet mails;
+ DumpGuidSet items;
};
class PlayerDumpReader : public PlayerDump
diff --git a/src/server/game/Weather/WeatherMgr.cpp b/src/server/game/Weather/WeatherMgr.cpp
index 64775a05faa..ff55d2d9a27 100644
--- a/src/server/game/Weather/WeatherMgr.cpp
+++ b/src/server/game/Weather/WeatherMgr.cpp
@@ -131,7 +131,7 @@ void LoadWeatherData()
}
}
- wzc.ScriptId = sObjectMgr->GetScriptId(fields[13].GetCString());
+ wzc.ScriptId = sObjectMgr->GetScriptId(fields[13].GetString());
++count;
}
diff --git a/src/server/game/World/World.cpp b/src/server/game/World/World.cpp
index 1c401be97c6..c41caa8f955 100644
--- a/src/server/game/World/World.cpp
+++ b/src/server/game/World/World.cpp
@@ -269,10 +269,7 @@ void World::AddSession_(WorldSession* s)
return;
}
- s->SendAuthResponse(AUTH_OK, true);
- s->SendAddonsInfo();
- s->SendClientCacheVersion(sWorld->getIntConfig(CONFIG_CLIENTCACHE_VERSION));
- s->SendTutorialsData();
+ s->InitializeSession();
UpdateMaxSessionCounters();
@@ -362,15 +359,7 @@ bool World::RemoveQueuedPlayer(WorldSession* sess)
if ((!m_playerLimit || sessions < m_playerLimit) && !m_QueuedPlayer.empty())
{
WorldSession* pop_sess = m_QueuedPlayer.front();
- pop_sess->SetInQueue(false);
- pop_sess->ResetTimeOutTime();
- pop_sess->SendAuthWaitQue(0);
- pop_sess->SendAddonsInfo();
-
- pop_sess->SendClientCacheVersion(sWorld->getIntConfig(CONFIG_CLIENTCACHE_VERSION));
- pop_sess->SendAccountDataTimes(GLOBAL_CACHE_MASK);
- pop_sess->SendTutorialsData();
-
+ pop_sess->InitializeSession();
m_QueuedPlayer.pop_front();
// update iter to point first queued socket or end() if queue is empty now
@@ -406,6 +395,7 @@ void World::LoadConfigSettings(bool reload)
///- Read ticket system setting from the config file
m_bool_configs[CONFIG_ALLOW_TICKETS] = sConfigMgr->GetBoolDefault("AllowTickets", true);
+ m_bool_configs[CONFIG_DELETE_CHARACTER_TICKET_TRACE] = sConfigMgr->GetBoolDefault("DeletedCharacterTicketTrace", false);
///- Get string for new logins (newly created characters)
SetNewCharString(sConfigMgr->GetStringDefault("PlayerStart.String", ""));
@@ -1038,6 +1028,7 @@ void World::LoadConfigSettings(bool reload)
m_bool_configs[CONFIG_BATTLEGROUND_QUEUE_ANNOUNCER_ENABLE] = sConfigMgr->GetBoolDefault("Battleground.QueueAnnouncer.Enable", false);
m_bool_configs[CONFIG_BATTLEGROUND_QUEUE_ANNOUNCER_PLAYERONLY] = sConfigMgr->GetBoolDefault("Battleground.QueueAnnouncer.PlayerOnly", false);
m_bool_configs[CONFIG_BATTLEGROUND_STORE_STATISTICS_ENABLE] = sConfigMgr->GetBoolDefault("Battleground.StoreStatistics.Enable", false);
+ m_bool_configs[CONFIG_BATTLEGROUND_TRACK_DESERTERS] = sConfigMgr->GetBoolDefault("Battleground.TrackDeserters.Enable", false);
m_int_configs[CONFIG_BATTLEGROUND_INVITATION_TYPE] = sConfigMgr->GetIntDefault ("Battleground.InvitationType", 0);
m_int_configs[CONFIG_BATTLEGROUND_PREMATURE_FINISH_TIMER] = sConfigMgr->GetIntDefault ("Battleground.PrematureFinishTimer", 5 * MINUTE * IN_MILLISECONDS);
m_int_configs[CONFIG_BATTLEGROUND_PREMADE_GROUP_WAIT_FOR_MATCH] = sConfigMgr->GetIntDefault ("Battleground.PremadeGroupWaitForMatch", 30 * MINUTE * IN_MILLISECONDS);
@@ -1192,6 +1183,7 @@ void World::LoadConfigSettings(bool reload)
m_bool_configs[CONFIG_START_ALL_SPELLS] = sConfigMgr->GetBoolDefault("PlayerStart.AllSpells", false);
m_int_configs[CONFIG_HONOR_AFTER_DUEL] = sConfigMgr->GetIntDefault("HonorPointsAfterDuel", 0);
m_bool_configs[CONFIG_RESET_DUEL_COOLDOWNS] = sConfigMgr->GetBoolDefault("ResetDuelCooldowns", false);
+ m_bool_configs[CONFIG_RESET_DUEL_HEALTH_MANA] = sConfigMgr->GetBoolDefault("ResetDuelHealthMana", false);
m_bool_configs[CONFIG_START_ALL_EXPLORED] = sConfigMgr->GetBoolDefault("PlayerStart.MapsExplored", false);
m_bool_configs[CONFIG_START_ALL_REP] = sConfigMgr->GetBoolDefault("PlayerStart.AllReputation", false);
m_bool_configs[CONFIG_ALWAYS_MAXSKILL] = sConfigMgr->GetBoolDefault("AlwaysMaxWeaponSkill", false);
@@ -1881,7 +1873,7 @@ void World::SetInitialWorldSettings()
TC_LOG_INFO("server.loading", "Calculate guild limitation(s) reset time...");
InitGuildResetTime();
- LoadCharacterNameData();
+ LoadCharacterInfoStore();
uint32 startupDuration = GetMSTimeDiffToNow(startupBegin);
@@ -3172,6 +3164,15 @@ void World::ProcessQueryCallbacks()
}
}
+CharacterInfo const* World::GetCharacterInfo(ObjectGuid const& guid) const
+{
+ CharacterInfoContainer::const_iterator itr = _characterInfoStore.find(guid);
+ if (itr != _characterInfoStore.end())
+ return &itr->second;
+
+ return nullptr;
+}
+
/**
* @brief Loads several pieces of information on server startup with the GUID
* There is no further database query necessary.
@@ -3181,87 +3182,78 @@ void World::ProcessQueryCallbacks()
* @return Name, Gender, Race, Class and Level of player character
* Example Usage:
* @code
-* CharacterNameData const* nameData = sWorld->GetCharacterNameData(GUID);
-* if (!nameData)
+* CharacterInfo const* characterInfo = sWorld->GetCharacterInfo(GUID);
+* if (!characterInfo)
* return;
*
-* std::string playerName = nameData->m_name;
-* uint8 playerGender = nameData->m_gender;
-* uint8 playerRace = nameData->m_race;
-* uint8 playerClass = nameData->m_class;
-* uint8 playerLevel = nameData->m_level;
+* std::string playerName = characterInfo->Name;
+* uint8 playerGender = characterInfo->Sex;
+* uint8 playerRace = characterInfo->Race;
+* uint8 playerClass = characterInfo->Class;
+* uint8 playerLevel = characterInfo->Level;
* @endcode
**/
-void World::LoadCharacterNameData()
+void World::LoadCharacterInfoStore()
{
- TC_LOG_INFO("server.loading", "Loading character name data");
+ TC_LOG_INFO("server.loading", "Loading character info store");
- QueryResult result = CharacterDatabase.Query("SELECT guid, name, race, gender, class, level FROM characters WHERE deleteDate IS NULL");
+ _characterInfoStore.clear();
+
+ QueryResult result = CharacterDatabase.Query("SELECT guid, name, account, race, gender, class, level FROM characters");
if (!result)
{
TC_LOG_INFO("server.loading", "No character name data loaded, empty query");
return;
}
- uint32 count = 0;
-
do
{
Field* fields = result->Fetch();
- AddCharacterNameData(ObjectGuid(HighGuid::Player, fields[0].GetUInt32()), fields[1].GetString(),
- fields[3].GetUInt8() /*gender*/, fields[2].GetUInt8() /*race*/, fields[4].GetUInt8() /*class*/, fields[5].GetUInt8() /*level*/);
- ++count;
+ AddCharacterInfo(ObjectGuid::Create<HighGuid::Player>(fields[0].GetUInt32()), fields[2].GetUInt32(), fields[1].GetString(),
+ fields[4].GetUInt8() /*gender*/, fields[3].GetUInt8() /*race*/, fields[5].GetUInt8() /*class*/, fields[6].GetUInt8() /*level*/);
} while (result->NextRow());
- TC_LOG_INFO("server.loading", "Loaded name data for %u characters", count);
+ TC_LOG_INFO("server.loading", "Loaded character infos for " SZFMTD " characters", _characterInfoStore.size());
}
-void World::AddCharacterNameData(ObjectGuid guid, std::string const& name, uint8 gender, uint8 race, uint8 playerClass, uint8 level)
+void World::AddCharacterInfo(ObjectGuid const& guid, uint32 accountId, std::string const& name, uint8 gender, uint8 race, uint8 playerClass, uint8 level)
{
- CharacterNameData& data = _characterNameDataMap[guid];
- data.m_name = name;
- data.m_race = race;
- data.m_gender = gender;
- data.m_class = playerClass;
- data.m_level = level;
+ CharacterInfo& data = _characterInfoStore[guid];
+ data.Name = name;
+ data.AccountId = accountId;
+ data.Race = race;
+ data.Sex = gender;
+ data.Class = playerClass;
+ data.Level = level;
}
-void World::UpdateCharacterNameData(ObjectGuid guid, std::string const& name, uint8 gender /*= GENDER_NONE*/, uint8 race /*= RACE_NONE*/)
+void World::UpdateCharacterInfo(ObjectGuid const& guid, std::string const& name, uint8 gender /*= GENDER_NONE*/, uint8 race /*= RACE_NONE*/)
{
- std::map<ObjectGuid, CharacterNameData>::iterator itr = _characterNameDataMap.find(guid);
- if (itr == _characterNameDataMap.end())
+ CharacterInfoContainer::iterator itr = _characterInfoStore.find(guid);
+ if (itr == _characterInfoStore.end())
return;
- itr->second.m_name = name;
+ itr->second.Name = name;
if (gender != GENDER_NONE)
- itr->second.m_gender = gender;
+ itr->second.Sex = gender;
if (race != RACE_NONE)
- itr->second.m_race = race;
+ itr->second.Race = race;
WorldPacket data(SMSG_INVALIDATE_PLAYER, 8);
data << guid;
SendGlobalMessage(&data);
}
-void World::UpdateCharacterNameDataLevel(ObjectGuid guid, uint8 level)
+void World::UpdateCharacterInfoLevel(ObjectGuid const& guid, uint8 level)
{
- std::map<ObjectGuid, CharacterNameData>::iterator itr = _characterNameDataMap.find(guid);
- if (itr == _characterNameDataMap.end())
+ CharacterInfoContainer::iterator itr = _characterInfoStore.find(guid);
+ if (itr == _characterInfoStore.end())
return;
- itr->second.m_level = level;
-}
-
-CharacterNameData const* World::GetCharacterNameData(ObjectGuid guid) const
-{
- std::map<ObjectGuid, CharacterNameData>::const_iterator itr = _characterNameDataMap.find(guid);
- if (itr != _characterNameDataMap.end())
- return &itr->second;
- else
- return NULL;
+ itr->second.Level = level;
}
void World::ReloadRBAC()
diff --git a/src/server/game/World/World.h b/src/server/game/World/World.h
index 7c7af77d19d..133ac3f2386 100644
--- a/src/server/game/World/World.h
+++ b/src/server/game/World/World.h
@@ -124,6 +124,7 @@ enum WorldBoolConfigs
CONFIG_BATTLEGROUND_QUEUE_ANNOUNCER_ENABLE,
CONFIG_BATTLEGROUND_QUEUE_ANNOUNCER_PLAYERONLY,
CONFIG_BATTLEGROUND_STORE_STATISTICS_ENABLE,
+ CONFIG_BATTLEGROUND_TRACK_DESERTERS,
CONFIG_BG_XP_FOR_KILL,
CONFIG_ARENA_AUTO_DISTRIBUTE_POINTS,
CONFIG_ARENA_QUEUE_ANNOUNCER_ENABLE,
@@ -143,6 +144,7 @@ enum WorldBoolConfigs
CONFIG_SHOW_BAN_IN_WORLD,
CONFIG_AUTOBROADCAST,
CONFIG_ALLOW_TICKETS,
+ CONFIG_DELETE_CHARACTER_TICKET_TRACE,
CONFIG_DBC_ENFORCE_ITEM_ATTRIBUTES,
CONFIG_PRESERVE_CUSTOM_CHANNELS,
CONFIG_PDUMP_NO_PATHS,
@@ -162,6 +164,7 @@ enum WorldBoolConfigs
CONFIG_CALCULATE_CREATURE_ZONE_AREA_DATA,
CONFIG_CALCULATE_GAMEOBJECT_ZONE_AREA_DATA,
CONFIG_RESET_DUEL_COOLDOWNS,
+ CONFIG_RESET_DUEL_HEALTH_MANA,
BOOL_CONFIG_VALUE_COUNT
};
@@ -524,13 +527,14 @@ private:
typedef std::unordered_map<uint32, WorldSession*> SessionMap;
-struct CharacterNameData
+struct CharacterInfo
{
- std::string m_name;
- uint8 m_class;
- uint8 m_race;
- uint8 m_gender;
- uint8 m_level;
+ std::string Name;
+ uint32 AccountId;
+ uint8 Class;
+ uint8 Race;
+ uint8 Sex;
+ uint8 Level;
};
/// The World
@@ -750,12 +754,12 @@ class World
void UpdateAreaDependentAuras();
- CharacterNameData const* GetCharacterNameData(ObjectGuid guid) const;
- void AddCharacterNameData(ObjectGuid guid, std::string const& name, uint8 gender, uint8 race, uint8 playerClass, uint8 level);
- void UpdateCharacterNameData(ObjectGuid guid, std::string const& name, uint8 gender = GENDER_NONE, uint8 race = RACE_NONE);
- void UpdateCharacterNameDataLevel(ObjectGuid guid, uint8 level);
- void DeleteCharacterNameData(ObjectGuid guid) { _characterNameDataMap.erase(guid); }
- bool HasCharacterNameData(ObjectGuid guid) { return _characterNameDataMap.find(guid) != _characterNameDataMap.end(); }
+ CharacterInfo const* GetCharacterInfo(ObjectGuid const& guid) const;
+ void AddCharacterInfo(ObjectGuid const& guid, uint32 accountId, std::string const& name, uint8 gender, uint8 race, uint8 playerClass, uint8 level);
+ void DeleteCharacterInfo(ObjectGuid const& guid) { _characterInfoStore.erase(guid); }
+ bool HasCharacterInfo(ObjectGuid const& guid) { return _characterInfoStore.find(guid) != _characterInfoStore.end(); }
+ void UpdateCharacterInfo(ObjectGuid const& guid, std::string const& name, uint8 gender = GENDER_NONE, uint8 race = RACE_NONE);
+ void UpdateCharacterInfoLevel(ObjectGuid const& guid, uint8 level);
uint32 GetCleaningFlags() const { return m_CleaningFlags; }
void SetCleaningFlags(uint32 flags) { m_CleaningFlags = flags; }
@@ -862,8 +866,9 @@ class World
typedef std::map<uint8, uint8> AutobroadcastsWeightMap;
AutobroadcastsWeightMap m_AutobroadcastsWeights;
- std::map<ObjectGuid, CharacterNameData> _characterNameDataMap;
- void LoadCharacterNameData();
+ typedef std::unordered_map<ObjectGuid, CharacterInfo> CharacterInfoContainer;
+ CharacterInfoContainer _characterInfoStore;
+ void LoadCharacterInfoStore();
void ProcessQueryCallbacks();
std::deque<std::future<PreparedQueryResult>> m_realmCharCallbacks;
diff --git a/src/server/scripts/Commands/cs_account.cpp b/src/server/scripts/Commands/cs_account.cpp
index 04520101d15..8d9a40d9d1f 100644
--- a/src/server/scripts/Commands/cs_account.cpp
+++ b/src/server/scripts/Commands/cs_account.cpp
@@ -33,45 +33,40 @@ class account_commandscript : public CommandScript
public:
account_commandscript() : CommandScript("account_commandscript") { }
- ChatCommand* GetCommands() const override
+ std::vector<ChatCommand> GetCommands() const override
{
- static ChatCommand accountSetSecTable[] =
+ static std::vector<ChatCommand> accountSetSecTable =
{
- { "regmail", rbac::RBAC_PERM_COMMAND_ACCOUNT_SET_SEC_REGMAIL, true, &HandleAccountSetRegEmailCommand, "", NULL },
- { "email", rbac::RBAC_PERM_COMMAND_ACCOUNT_SET_SEC_EMAIL, true, &HandleAccountSetEmailCommand, "", NULL },
- { NULL, 0, false, NULL, "", NULL }
+ { "regmail", rbac::RBAC_PERM_COMMAND_ACCOUNT_SET_SEC_REGMAIL, true, &HandleAccountSetRegEmailCommand, "" },
+ { "email", rbac::RBAC_PERM_COMMAND_ACCOUNT_SET_SEC_EMAIL, true, &HandleAccountSetEmailCommand, "" },
};
- static ChatCommand accountSetCommandTable[] =
+ static std::vector<ChatCommand> accountSetCommandTable =
{
- { "addon", rbac::RBAC_PERM_COMMAND_ACCOUNT_SET_ADDON, true, &HandleAccountSetAddonCommand, "", NULL },
+ { "addon", rbac::RBAC_PERM_COMMAND_ACCOUNT_SET_ADDON, true, &HandleAccountSetAddonCommand, "" },
{ "sec", rbac::RBAC_PERM_COMMAND_ACCOUNT_SET_SEC, true, NULL, "", accountSetSecTable },
- { "gmlevel", rbac::RBAC_PERM_COMMAND_ACCOUNT_SET_GMLEVEL, true, &HandleAccountSetGmLevelCommand, "", NULL },
- { "password", rbac::RBAC_PERM_COMMAND_ACCOUNT_SET_PASSWORD, true, &HandleAccountSetPasswordCommand, "", NULL },
- { NULL, 0, false, NULL, "", NULL }
+ { "gmlevel", rbac::RBAC_PERM_COMMAND_ACCOUNT_SET_GMLEVEL, true, &HandleAccountSetGmLevelCommand, "" },
+ { "password", rbac::RBAC_PERM_COMMAND_ACCOUNT_SET_PASSWORD, true, &HandleAccountSetPasswordCommand, "" },
};
- static ChatCommand accountLockCommandTable[] =
+ static std::vector<ChatCommand> accountLockCommandTable =
{
- { "country", rbac::RBAC_PERM_COMMAND_ACCOUNT_LOCK_COUNTRY, false, &HandleAccountLockCountryCommand, "", NULL },
- { "ip", rbac::RBAC_PERM_COMMAND_ACCOUNT_LOCK_IP, false, &HandleAccountLockIpCommand, "", NULL },
- { NULL, 0, false, NULL, "", NULL }
+ { "country", rbac::RBAC_PERM_COMMAND_ACCOUNT_LOCK_COUNTRY, false, &HandleAccountLockCountryCommand, "" },
+ { "ip", rbac::RBAC_PERM_COMMAND_ACCOUNT_LOCK_IP, false, &HandleAccountLockIpCommand, "" },
};
- static ChatCommand accountCommandTable[] =
+ static std::vector<ChatCommand> accountCommandTable =
{
- { "addon", rbac::RBAC_PERM_COMMAND_ACCOUNT_ADDON, false, &HandleAccountAddonCommand, "", NULL },
- { "create", rbac::RBAC_PERM_COMMAND_ACCOUNT_CREATE, true, &HandleAccountCreateCommand, "", NULL },
- { "delete", rbac::RBAC_PERM_COMMAND_ACCOUNT_DELETE, true, &HandleAccountDeleteCommand, "", NULL },
- { "email", rbac::RBAC_PERM_COMMAND_ACCOUNT_EMAIL, false, &HandleAccountEmailCommand, "", NULL },
- { "onlinelist", rbac::RBAC_PERM_COMMAND_ACCOUNT_ONLINE_LIST, true, &HandleAccountOnlineListCommand, "", NULL },
+ { "addon", rbac::RBAC_PERM_COMMAND_ACCOUNT_ADDON, false, &HandleAccountAddonCommand, "" },
+ { "create", rbac::RBAC_PERM_COMMAND_ACCOUNT_CREATE, true, &HandleAccountCreateCommand, "" },
+ { "delete", rbac::RBAC_PERM_COMMAND_ACCOUNT_DELETE, true, &HandleAccountDeleteCommand, "" },
+ { "email", rbac::RBAC_PERM_COMMAND_ACCOUNT_EMAIL, false, &HandleAccountEmailCommand, "" },
+ { "onlinelist", rbac::RBAC_PERM_COMMAND_ACCOUNT_ONLINE_LIST, true, &HandleAccountOnlineListCommand, "" },
{ "lock", rbac::RBAC_PERM_COMMAND_ACCOUNT_LOCK, false, NULL, "", accountLockCommandTable },
{ "set", rbac::RBAC_PERM_COMMAND_ACCOUNT_SET, true, NULL, "", accountSetCommandTable },
- { "password", rbac::RBAC_PERM_COMMAND_ACCOUNT_PASSWORD, false, &HandleAccountPasswordCommand, "", NULL },
- { "", rbac::RBAC_PERM_COMMAND_ACCOUNT, false, &HandleAccountCommand, "", NULL },
- { NULL, 0, false, NULL, "", NULL }
+ { "password", rbac::RBAC_PERM_COMMAND_ACCOUNT_PASSWORD, false, &HandleAccountPasswordCommand, "" },
+ { "", rbac::RBAC_PERM_COMMAND_ACCOUNT, false, &HandleAccountCommand, "" },
};
- static ChatCommand commandTable[] =
+ static std::vector<ChatCommand> commandTable =
{
{ "account", rbac::RBAC_PERM_COMMAND_ACCOUNT, true, NULL, "", accountCommandTable },
- { NULL, 0, false, NULL, "", NULL }
};
return commandTable;
}
diff --git a/src/server/scripts/Commands/cs_achievement.cpp b/src/server/scripts/Commands/cs_achievement.cpp
index 8a038844ec1..ea77bc1f189 100644
--- a/src/server/scripts/Commands/cs_achievement.cpp
+++ b/src/server/scripts/Commands/cs_achievement.cpp
@@ -33,17 +33,15 @@ class achievement_commandscript : public CommandScript
public:
achievement_commandscript() : CommandScript("achievement_commandscript") { }
- ChatCommand* GetCommands() const override
+ std::vector<ChatCommand> GetCommands() const override
{
- static ChatCommand achievementCommandTable[] =
+ static std::vector<ChatCommand> achievementCommandTable =
{
- { "add", rbac::RBAC_PERM_COMMAND_ACHIEVEMENT_ADD, false, &HandleAchievementAddCommand, "", NULL },
- { NULL, 0, false, NULL, "", NULL }
+ { "add", rbac::RBAC_PERM_COMMAND_ACHIEVEMENT_ADD, false, &HandleAchievementAddCommand, "" },
};
- static ChatCommand commandTable[] =
+ static std::vector<ChatCommand> commandTable =
{
{ "achievement", rbac::RBAC_PERM_COMMAND_ACHIEVEMENT, false, NULL, "", achievementCommandTable },
- { NULL, 0, false, NULL, "", NULL }
};
return commandTable;
}
diff --git a/src/server/scripts/Commands/cs_ahbot.cpp b/src/server/scripts/Commands/cs_ahbot.cpp
index 559a775da31..44889fccd37 100644
--- a/src/server/scripts/Commands/cs_ahbot.cpp
+++ b/src/server/scripts/Commands/cs_ahbot.cpp
@@ -33,44 +33,40 @@ class ahbot_commandscript : public CommandScript
public:
ahbot_commandscript(): CommandScript("ahbot_commandscript") {}
- ChatCommand* GetCommands() const
+ std::vector<ChatCommand> GetCommands() const
{
- static ChatCommand ahbotItemsAmountCommandTable[] =
+ static std::vector<ChatCommand> ahbotItemsAmountCommandTable =
{
- { "gray", rbac::RBAC_PERM_COMMAND_AHBOT_ITEMS_GRAY, true, &HandleAHBotItemsAmountQualityCommand<AUCTION_QUALITY_GRAY>, "", NULL },
- { "white", rbac::RBAC_PERM_COMMAND_AHBOT_ITEMS_WHITE, true, &HandleAHBotItemsAmountQualityCommand<AUCTION_QUALITY_WHITE>, "", NULL },
- { "green", rbac::RBAC_PERM_COMMAND_AHBOT_ITEMS_GREEN, true, &HandleAHBotItemsAmountQualityCommand<AUCTION_QUALITY_GREEN>, "", NULL },
- { "blue", rbac::RBAC_PERM_COMMAND_AHBOT_ITEMS_BLUE, true, &HandleAHBotItemsAmountQualityCommand<AUCTION_QUALITY_BLUE>, "", NULL },
- { "purple", rbac::RBAC_PERM_COMMAND_AHBOT_ITEMS_PURPLE, true, &HandleAHBotItemsAmountQualityCommand<AUCTION_QUALITY_PURPLE>, "", NULL },
- { "orange", rbac::RBAC_PERM_COMMAND_AHBOT_ITEMS_ORANGE, true, &HandleAHBotItemsAmountQualityCommand<AUCTION_QUALITY_ORANGE>, "", NULL },
- { "yellow", rbac::RBAC_PERM_COMMAND_AHBOT_ITEMS_YELLOW, true, &HandleAHBotItemsAmountQualityCommand<AUCTION_QUALITY_YELLOW>, "", NULL },
- { "", rbac::RBAC_PERM_COMMAND_AHBOT_ITEMS, true, &HandleAHBotItemsAmountCommand, "", NULL },
- { NULL, 0, true, NULL, "", NULL }
+ { "gray", rbac::RBAC_PERM_COMMAND_AHBOT_ITEMS_GRAY, true, &HandleAHBotItemsAmountQualityCommand<AUCTION_QUALITY_GRAY>, "" },
+ { "white", rbac::RBAC_PERM_COMMAND_AHBOT_ITEMS_WHITE, true, &HandleAHBotItemsAmountQualityCommand<AUCTION_QUALITY_WHITE>, "" },
+ { "green", rbac::RBAC_PERM_COMMAND_AHBOT_ITEMS_GREEN, true, &HandleAHBotItemsAmountQualityCommand<AUCTION_QUALITY_GREEN>, "" },
+ { "blue", rbac::RBAC_PERM_COMMAND_AHBOT_ITEMS_BLUE, true, &HandleAHBotItemsAmountQualityCommand<AUCTION_QUALITY_BLUE>, "" },
+ { "purple", rbac::RBAC_PERM_COMMAND_AHBOT_ITEMS_PURPLE, true, &HandleAHBotItemsAmountQualityCommand<AUCTION_QUALITY_PURPLE>, "" },
+ { "orange", rbac::RBAC_PERM_COMMAND_AHBOT_ITEMS_ORANGE, true, &HandleAHBotItemsAmountQualityCommand<AUCTION_QUALITY_ORANGE>, "" },
+ { "yellow", rbac::RBAC_PERM_COMMAND_AHBOT_ITEMS_YELLOW, true, &HandleAHBotItemsAmountQualityCommand<AUCTION_QUALITY_YELLOW>, "" },
+ { "", rbac::RBAC_PERM_COMMAND_AHBOT_ITEMS, true, &HandleAHBotItemsAmountCommand, "" },
};
- static ChatCommand ahbotItemsRatioCommandTable[] =
+ static std::vector<ChatCommand> ahbotItemsRatioCommandTable =
{
- { "alliance", rbac::RBAC_PERM_COMMAND_AHBOT_RATIO_ALLIANCE, true, &HandleAHBotItemsRatioHouseCommand<AUCTION_HOUSE_ALLIANCE>, "", NULL },
- { "horde", rbac::RBAC_PERM_COMMAND_AHBOT_RATIO_HORDE, true, &HandleAHBotItemsRatioHouseCommand<AUCTION_HOUSE_HORDE>, "", NULL },
- { "neutral", rbac::RBAC_PERM_COMMAND_AHBOT_RATIO_NEUTRAL, true, &HandleAHBotItemsRatioHouseCommand<AUCTION_HOUSE_NEUTRAL>, "", NULL },
- { "", rbac::RBAC_PERM_COMMAND_AHBOT_RATIO, true, &HandleAHBotItemsRatioCommand, "", NULL },
- { NULL, 0, true, NULL, "", NULL }
+ { "alliance", rbac::RBAC_PERM_COMMAND_AHBOT_RATIO_ALLIANCE, true, &HandleAHBotItemsRatioHouseCommand<AUCTION_HOUSE_ALLIANCE>, "" },
+ { "horde", rbac::RBAC_PERM_COMMAND_AHBOT_RATIO_HORDE, true, &HandleAHBotItemsRatioHouseCommand<AUCTION_HOUSE_HORDE>, "" },
+ { "neutral", rbac::RBAC_PERM_COMMAND_AHBOT_RATIO_NEUTRAL, true, &HandleAHBotItemsRatioHouseCommand<AUCTION_HOUSE_NEUTRAL>, "" },
+ { "", rbac::RBAC_PERM_COMMAND_AHBOT_RATIO, true, &HandleAHBotItemsRatioCommand, "" },
};
- static ChatCommand ahbotCommandTable[] =
+ static std::vector<ChatCommand> ahbotCommandTable =
{
{ "items", rbac::RBAC_PERM_COMMAND_AHBOT_ITEMS, true, NULL, "", ahbotItemsAmountCommandTable },
{ "ratio", rbac::RBAC_PERM_COMMAND_AHBOT_RATIO, true, NULL, "", ahbotItemsRatioCommandTable },
- { "rebuild", rbac::RBAC_PERM_COMMAND_AHBOT_REBUILD, true, &HandleAHBotRebuildCommand, "", NULL },
- { "reload", rbac::RBAC_PERM_COMMAND_AHBOT_RELOAD, true, &HandleAHBotReloadCommand, "", NULL },
- { "status", rbac::RBAC_PERM_COMMAND_AHBOT_STATUS, true, &HandleAHBotStatusCommand, "", NULL },
- { NULL, 0, true, NULL, "", NULL }
+ { "rebuild", rbac::RBAC_PERM_COMMAND_AHBOT_REBUILD, true, &HandleAHBotRebuildCommand, "" },
+ { "reload", rbac::RBAC_PERM_COMMAND_AHBOT_RELOAD, true, &HandleAHBotReloadCommand, "" },
+ { "status", rbac::RBAC_PERM_COMMAND_AHBOT_STATUS, true, &HandleAHBotStatusCommand, "" },
};
- static ChatCommand commandTable[] =
+ static std::vector<ChatCommand> commandTable =
{
{ "ahbot", rbac::RBAC_PERM_COMMAND_AHBOT, false, NULL, "", ahbotCommandTable },
- { NULL, 0, false, NULL, "", NULL }
};
return commandTable;
diff --git a/src/server/scripts/Commands/cs_arena.cpp b/src/server/scripts/Commands/cs_arena.cpp
index 4cafb651add..71657d51e7b 100644
--- a/src/server/scripts/Commands/cs_arena.cpp
+++ b/src/server/scripts/Commands/cs_arena.cpp
@@ -34,22 +34,20 @@ class arena_commandscript : public CommandScript
public:
arena_commandscript() : CommandScript("arena_commandscript") { }
- ChatCommand* GetCommands() const override
+ std::vector<ChatCommand> GetCommands() const override
{
- static ChatCommand arenaCommandTable[] =
+ static std::vector<ChatCommand> arenaCommandTable =
{
- { "create", rbac::RBAC_PERM_COMMAND_ARENA_CREATE, true, &HandleArenaCreateCommand, "", NULL },
- { "disband", rbac::RBAC_PERM_COMMAND_ARENA_DISBAND, true, &HandleArenaDisbandCommand, "", NULL },
- { "rename", rbac::RBAC_PERM_COMMAND_ARENA_RENAME, true, &HandleArenaRenameCommand, "", NULL },
- { "captain", rbac::RBAC_PERM_COMMAND_ARENA_CAPTAIN, false, &HandleArenaCaptainCommand, "", NULL },
- { "info", rbac::RBAC_PERM_COMMAND_ARENA_INFO, true, &HandleArenaInfoCommand, "", NULL },
- { "lookup", rbac::RBAC_PERM_COMMAND_ARENA_LOOKUP, false, &HandleArenaLookupCommand, "", NULL },
- { NULL, 0, false, NULL, "", NULL }
+ { "create", rbac::RBAC_PERM_COMMAND_ARENA_CREATE, true, &HandleArenaCreateCommand, "" },
+ { "disband", rbac::RBAC_PERM_COMMAND_ARENA_DISBAND, true, &HandleArenaDisbandCommand, "" },
+ { "rename", rbac::RBAC_PERM_COMMAND_ARENA_RENAME, true, &HandleArenaRenameCommand, "" },
+ { "captain", rbac::RBAC_PERM_COMMAND_ARENA_CAPTAIN, false, &HandleArenaCaptainCommand, "" },
+ { "info", rbac::RBAC_PERM_COMMAND_ARENA_INFO, true, &HandleArenaInfoCommand, "" },
+ { "lookup", rbac::RBAC_PERM_COMMAND_ARENA_LOOKUP, false, &HandleArenaLookupCommand, "" },
};
- static ChatCommand commandTable[] =
+ static std::vector<ChatCommand> commandTable =
{
{ "arena", rbac::RBAC_PERM_COMMAND_ARENA, false, NULL, "", arenaCommandTable },
- { NULL, 0, false, NULL, "", NULL }
};
return commandTable;
}
@@ -275,14 +273,14 @@ public:
arena->SetCaptain(targetGuid);
- CharacterNameData const* oldCaptainNameData = sWorld->GetCharacterNameData(arena->GetCaptain());
+ CharacterInfo const* oldCaptainNameData = sWorld->GetCharacterInfo(arena->GetCaptain());
if (!oldCaptainNameData)
{
handler->SetSentErrorMessage(true);
return false;
}
- handler->PSendSysMessage(LANG_ARENA_CAPTAIN, arena->GetName().c_str(), arena->GetId(), oldCaptainNameData->m_name.c_str(), target->GetName().c_str());
+ handler->PSendSysMessage(LANG_ARENA_CAPTAIN, arena->GetName().c_str(), arena->GetId(), oldCaptainNameData->Name.c_str(), target->GetName().c_str());
if (handler->GetSession())
TC_LOG_DEBUG("bg.arena", "GameMaster: %s [GUID: %u] promoted player: %s [GUID: %u] to leader of arena team \"%s\"[Id: %u]",
handler->GetSession()->GetPlayer()->GetName().c_str(), handler->GetSession()->GetPlayer()->GetGUID().GetCounter(), target->GetName().c_str(), target->GetGUID().GetCounter(), arena->GetName().c_str(), arena->GetId());
diff --git a/src/server/scripts/Commands/cs_ban.cpp b/src/server/scripts/Commands/cs_ban.cpp
index ed7b31198db..67015cd7d9c 100644
--- a/src/server/scripts/Commands/cs_ban.cpp
+++ b/src/server/scripts/Commands/cs_ban.cpp
@@ -35,45 +35,40 @@ class ban_commandscript : public CommandScript
public:
ban_commandscript() : CommandScript("ban_commandscript") { }
- ChatCommand* GetCommands() const override
+ std::vector<ChatCommand> GetCommands() const override
{
- static ChatCommand unbanCommandTable[] =
+ static std::vector<ChatCommand> unbanCommandTable =
{
- { "account", rbac::RBAC_PERM_COMMAND_UNBAN_ACCOUNT, true, &HandleUnBanAccountCommand, "", NULL },
- { "character", rbac::RBAC_PERM_COMMAND_UNBAN_CHARACTER, true, &HandleUnBanCharacterCommand, "", NULL },
- { "playeraccount", rbac::RBAC_PERM_COMMAND_UNBAN_PLAYERACCOUNT, true, &HandleUnBanAccountByCharCommand, "", NULL },
- { "ip", rbac::RBAC_PERM_COMMAND_UNBAN_IP, true, &HandleUnBanIPCommand, "", NULL },
- { NULL, 0, false, NULL, "", NULL }
+ { "account", rbac::RBAC_PERM_COMMAND_UNBAN_ACCOUNT, true, &HandleUnBanAccountCommand, "" },
+ { "character", rbac::RBAC_PERM_COMMAND_UNBAN_CHARACTER, true, &HandleUnBanCharacterCommand, "" },
+ { "playeraccount", rbac::RBAC_PERM_COMMAND_UNBAN_PLAYERACCOUNT, true, &HandleUnBanAccountByCharCommand, "" },
+ { "ip", rbac::RBAC_PERM_COMMAND_UNBAN_IP, true, &HandleUnBanIPCommand, "" },
};
- static ChatCommand banlistCommandTable[] =
+ static std::vector<ChatCommand> banlistCommandTable =
{
- { "account", rbac::RBAC_PERM_COMMAND_BANLIST_ACCOUNT, true, &HandleBanListAccountCommand, "", NULL },
- { "character", rbac::RBAC_PERM_COMMAND_BANLIST_CHARACTER, true, &HandleBanListCharacterCommand, "", NULL },
- { "ip", rbac::RBAC_PERM_COMMAND_BANLIST_IP, true, &HandleBanListIPCommand, "", NULL },
- { NULL, 0, false, NULL, "", NULL }
+ { "account", rbac::RBAC_PERM_COMMAND_BANLIST_ACCOUNT, true, &HandleBanListAccountCommand, "" },
+ { "character", rbac::RBAC_PERM_COMMAND_BANLIST_CHARACTER, true, &HandleBanListCharacterCommand, "" },
+ { "ip", rbac::RBAC_PERM_COMMAND_BANLIST_IP, true, &HandleBanListIPCommand, "" },
};
- static ChatCommand baninfoCommandTable[] =
+ static std::vector<ChatCommand> baninfoCommandTable =
{
- { "account", rbac::RBAC_PERM_COMMAND_BANINFO_ACCOUNT, true, &HandleBanInfoAccountCommand, "", NULL },
- { "character", rbac::RBAC_PERM_COMMAND_BANINFO_CHARACTER, true, &HandleBanInfoCharacterCommand, "", NULL },
- { "ip", rbac::RBAC_PERM_COMMAND_BANINFO_IP, true, &HandleBanInfoIPCommand, "", NULL },
- { NULL, 0, false, NULL, "", NULL }
+ { "account", rbac::RBAC_PERM_COMMAND_BANINFO_ACCOUNT, true, &HandleBanInfoAccountCommand, "" },
+ { "character", rbac::RBAC_PERM_COMMAND_BANINFO_CHARACTER, true, &HandleBanInfoCharacterCommand, "" },
+ { "ip", rbac::RBAC_PERM_COMMAND_BANINFO_IP, true, &HandleBanInfoIPCommand, "" },
};
- static ChatCommand banCommandTable[] =
+ static std::vector<ChatCommand> banCommandTable =
{
- { "account", rbac::RBAC_PERM_COMMAND_BAN_ACCOUNT, true, &HandleBanAccountCommand, "", NULL },
- { "character", rbac::RBAC_PERM_COMMAND_BAN_CHARACTER, true, &HandleBanCharacterCommand, "", NULL },
- { "playeraccount", rbac::RBAC_PERM_COMMAND_BAN_PLAYERACCOUNT, true, &HandleBanAccountByCharCommand, "", NULL },
- { "ip", rbac::RBAC_PERM_COMMAND_BAN_IP, true, &HandleBanIPCommand, "", NULL },
- { NULL, 0, false, NULL, "", NULL }
+ { "account", rbac::RBAC_PERM_COMMAND_BAN_ACCOUNT, true, &HandleBanAccountCommand, "" },
+ { "character", rbac::RBAC_PERM_COMMAND_BAN_CHARACTER, true, &HandleBanCharacterCommand, "" },
+ { "playeraccount", rbac::RBAC_PERM_COMMAND_BAN_PLAYERACCOUNT, true, &HandleBanAccountByCharCommand, "" },
+ { "ip", rbac::RBAC_PERM_COMMAND_BAN_IP, true, &HandleBanIPCommand, "" },
};
- static ChatCommand commandTable[] =
+ static std::vector<ChatCommand> commandTable =
{
{ "ban", rbac::RBAC_PERM_COMMAND_BAN, true, NULL, "", banCommandTable },
{ "baninfo", rbac::RBAC_PERM_COMMAND_BANINFO, true, NULL, "", baninfoCommandTable },
{ "banlist", rbac::RBAC_PERM_COMMAND_BANLIST, true, NULL, "", banlistCommandTable },
{ "unban", rbac::RBAC_PERM_COMMAND_UNBAN, true, NULL, "", unbanCommandTable },
- { NULL, 0, false, NULL, "", NULL }
};
return commandTable;
}
diff --git a/src/server/scripts/Commands/cs_bf.cpp b/src/server/scripts/Commands/cs_bf.cpp
index 830e801bcef..7101b89b5fa 100644
--- a/src/server/scripts/Commands/cs_bf.cpp
+++ b/src/server/scripts/Commands/cs_bf.cpp
@@ -31,21 +31,19 @@ class bf_commandscript : public CommandScript
public:
bf_commandscript() : CommandScript("bf_commandscript") { }
- ChatCommand* GetCommands() const override
+ std::vector<ChatCommand> GetCommands() const override
{
- static ChatCommand battlefieldcommandTable[] =
+ static std::vector<ChatCommand> battlefieldcommandTable =
{
- { "start", rbac::RBAC_PERM_COMMAND_BF_START, false, &HandleBattlefieldStart, "", NULL },
- { "stop", rbac::RBAC_PERM_COMMAND_BF_STOP, false, &HandleBattlefieldEnd, "", NULL },
- { "switch", rbac::RBAC_PERM_COMMAND_BF_SWITCH, false, &HandleBattlefieldSwitch, "", NULL },
- { "timer", rbac::RBAC_PERM_COMMAND_BF_TIMER, false, &HandleBattlefieldTimer, "", NULL },
- { "enable", rbac::RBAC_PERM_COMMAND_BF_ENABLE, false, &HandleBattlefieldEnable, "", NULL },
- { NULL, 0, false, NULL, "", NULL }
+ { "start", rbac::RBAC_PERM_COMMAND_BF_START, false, &HandleBattlefieldStart, "" },
+ { "stop", rbac::RBAC_PERM_COMMAND_BF_STOP, false, &HandleBattlefieldEnd, "" },
+ { "switch", rbac::RBAC_PERM_COMMAND_BF_SWITCH, false, &HandleBattlefieldSwitch, "" },
+ { "timer", rbac::RBAC_PERM_COMMAND_BF_TIMER, false, &HandleBattlefieldTimer, "" },
+ { "enable", rbac::RBAC_PERM_COMMAND_BF_ENABLE, false, &HandleBattlefieldEnable, "" },
};
- static ChatCommand commandTable[] =
+ static std::vector<ChatCommand> commandTable =
{
{ "bf", rbac::RBAC_PERM_COMMAND_BF, false, NULL, "", battlefieldcommandTable },
- { NULL, 0, false, NULL, "", NULL }
};
return commandTable;
}
diff --git a/src/server/scripts/Commands/cs_cast.cpp b/src/server/scripts/Commands/cs_cast.cpp
index dfd0bb36755..5252d5e368a 100644
--- a/src/server/scripts/Commands/cs_cast.cpp
+++ b/src/server/scripts/Commands/cs_cast.cpp
@@ -33,26 +33,43 @@ class cast_commandscript : public CommandScript
public:
cast_commandscript() : CommandScript("cast_commandscript") { }
- ChatCommand* GetCommands() const override
+ std::vector<ChatCommand> GetCommands() const override
{
- static ChatCommand castCommandTable[] =
+ static std::vector<ChatCommand> castCommandTable =
{
- { "back", rbac::RBAC_PERM_COMMAND_CAST_BACK, false, &HandleCastBackCommand, "", NULL },
- { "dist", rbac::RBAC_PERM_COMMAND_CAST_DIST, false, &HandleCastDistCommand, "", NULL },
- { "self", rbac::RBAC_PERM_COMMAND_CAST_SELF, false, &HandleCastSelfCommand, "", NULL },
- { "target", rbac::RBAC_PERM_COMMAND_CAST_TARGET, false, &HandleCastTargetCommad, "", NULL },
- { "dest", rbac::RBAC_PERM_COMMAND_CAST_DEST, false, &HandleCastDestCommand, "", NULL },
- { "", rbac::RBAC_PERM_COMMAND_CAST, false, &HandleCastCommand, "", NULL },
- { NULL, 0, false, NULL, "", NULL }
+ { "back", rbac::RBAC_PERM_COMMAND_CAST_BACK, false, &HandleCastBackCommand, "" },
+ { "dist", rbac::RBAC_PERM_COMMAND_CAST_DIST, false, &HandleCastDistCommand, "" },
+ { "self", rbac::RBAC_PERM_COMMAND_CAST_SELF, false, &HandleCastSelfCommand, "" },
+ { "target", rbac::RBAC_PERM_COMMAND_CAST_TARGET, false, &HandleCastTargetCommad, "" },
+ { "dest", rbac::RBAC_PERM_COMMAND_CAST_DEST, false, &HandleCastDestCommand, "" },
+ { "", rbac::RBAC_PERM_COMMAND_CAST, false, &HandleCastCommand, "" },
};
- static ChatCommand commandTable[] =
+ static std::vector<ChatCommand> commandTable =
{
{ "cast", rbac::RBAC_PERM_COMMAND_CAST, false, NULL, "", castCommandTable },
- { NULL, 0, false, NULL, "", NULL }
};
return commandTable;
}
+ static bool CheckSpellExistsAndIsValid(ChatHandler* handler, uint32 spellId)
+ {
+ SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellId);
+ if (!spellInfo)
+ {
+ handler->PSendSysMessage(LANG_COMMAND_NOSPELLFOUND);
+ handler->SetSentErrorMessage(true);
+ return false;
+ }
+
+ if (!SpellMgr::IsSpellValid(spellInfo, handler->GetSession()->GetPlayer()))
+ {
+ handler->PSendSysMessage(LANG_COMMAND_SPELL_BROKEN, spellId);
+ handler->SetSentErrorMessage(true);
+ return false;
+ }
+ return true;
+ }
+
static bool HandleCastCommand(ChatHandler* handler, char const* args)
{
if (!*args)
@@ -71,20 +88,8 @@ public:
if (!spellId)
return false;
- SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellId);
- if (!spellInfo)
- {
- handler->PSendSysMessage(LANG_COMMAND_NOSPELLFOUND);
- handler->SetSentErrorMessage(true);
- return false;
- }
-
- if (!SpellMgr::IsSpellValid(spellInfo, handler->GetSession()->GetPlayer()))
- {
- handler->PSendSysMessage(LANG_COMMAND_SPELL_BROKEN, spellId);
- handler->SetSentErrorMessage(true);
+ if (!CheckSpellExistsAndIsValid(handler, spellId))
return false;
- }
char* triggeredStr = strtok(NULL, " ");
if (triggeredStr)
@@ -111,15 +116,13 @@ public:
return false;
}
- // number or [name] Shift-click form |color|Hspell:spell_id|h[name]|h|r
// number or [name] Shift-click form |color|Hspell:spell_id|h[name]|h|r or Htalent form
uint32 spellId = handler->extractSpellIdFromLink((char*)args);
- if (!spellId || !sSpellMgr->GetSpellInfo(spellId))
- {
- handler->PSendSysMessage(LANG_COMMAND_NOSPELLFOUND);
- handler->SetSentErrorMessage(true);
+ if (!spellId)
+ return false;
+
+ if (!CheckSpellExistsAndIsValid(handler, spellId))
return false;
- }
char* triggeredStr = strtok(NULL, " ");
if (triggeredStr)
@@ -146,20 +149,8 @@ public:
if (!spellId)
return false;
- SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellId);
- if (!spellInfo)
- {
- handler->PSendSysMessage(LANG_COMMAND_NOSPELLFOUND);
- handler->SetSentErrorMessage(true);
- return false;
- }
-
- if (!SpellMgr::IsSpellValid(spellInfo, handler->GetSession()->GetPlayer()))
- {
- handler->PSendSysMessage(LANG_COMMAND_SPELL_BROKEN, spellId);
- handler->SetSentErrorMessage(true);
+ if (!CheckSpellExistsAndIsValid(handler, spellId))
return false;
- }
char* distStr = strtok(NULL, " ");
@@ -192,28 +183,14 @@ public:
return false;
Unit* target = handler->getSelectedUnit();
- if (!target)
- {
- handler->SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE);
- handler->SetSentErrorMessage(true);
- return false;
- }
// number or [name] Shift-click form |color|Hspell:spell_id|h[name]|h|r or Htalent form
uint32 spellId = handler->extractSpellIdFromLink((char*)args);
if (!spellId)
return false;
- SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellId);
- if (!spellInfo)
- return false;
-
- if (!SpellMgr::IsSpellValid(spellInfo, handler->GetSession()->GetPlayer()))
- {
- handler->PSendSysMessage(LANG_COMMAND_SPELL_BROKEN, spellId);
- handler->SetSentErrorMessage(true);
+ if (!CheckSpellExistsAndIsValid(handler, spellId))
return false;
- }
target->CastSpell(target, spellId, false);
@@ -239,12 +216,11 @@ public:
// number or [name] Shift-click form |color|Hspell:spell_id|h[name]|h|r or Htalent form
uint32 spellId = handler->extractSpellIdFromLink((char*)args);
- if (!spellId || !sSpellMgr->GetSpellInfo(spellId))
- {
- handler->PSendSysMessage(LANG_COMMAND_NOSPELLFOUND);
- handler->SetSentErrorMessage(true);
+ if (!spellId)
+ return false;
+
+ if (!CheckSpellExistsAndIsValid(handler, spellId))
return false;
- }
char* triggeredStr = strtok(NULL, " ");
if (triggeredStr)
@@ -273,12 +249,11 @@ public:
// number or [name] Shift-click form |color|Hspell:spell_id|h[name]|h|r or Htalent form
uint32 spellId = handler->extractSpellIdFromLink((char*)args);
- if (!spellId || !sSpellMgr->GetSpellInfo(spellId))
- {
- handler->PSendSysMessage(LANG_COMMAND_NOSPELLFOUND);
- handler->SetSentErrorMessage(true);
+ if (!spellId)
+ return false;
+
+ if (!CheckSpellExistsAndIsValid(handler, spellId))
return false;
- }
char* posX = strtok(NULL, " ");
char* posY = strtok(NULL, " ");
diff --git a/src/server/scripts/Commands/cs_character.cpp b/src/server/scripts/Commands/cs_character.cpp
index 8714838879f..65dd44f8563 100644
--- a/src/server/scripts/Commands/cs_character.cpp
+++ b/src/server/scripts/Commands/cs_character.cpp
@@ -35,43 +35,39 @@ class character_commandscript : public CommandScript
public:
character_commandscript() : CommandScript("character_commandscript") { }
- ChatCommand* GetCommands() const override
+ std::vector<ChatCommand> GetCommands() const override
{
- static ChatCommand pdumpCommandTable[] =
+ static std::vector<ChatCommand> pdumpCommandTable =
{
- { "load", rbac::RBAC_PERM_COMMAND_PDUMP_LOAD, true, &HandlePDumpLoadCommand, "", NULL },
- { "write", rbac::RBAC_PERM_COMMAND_PDUMP_WRITE, true, &HandlePDumpWriteCommand, "", NULL },
- { NULL, 0, false, NULL, "", NULL }
+ { "load", rbac::RBAC_PERM_COMMAND_PDUMP_LOAD, true, &HandlePDumpLoadCommand, "" },
+ { "write", rbac::RBAC_PERM_COMMAND_PDUMP_WRITE, true, &HandlePDumpWriteCommand, "" },
};
- static ChatCommand characterDeletedCommandTable[] =
+ static std::vector<ChatCommand> characterDeletedCommandTable =
{
- { "delete", rbac::RBAC_PERM_COMMAND_CHARACTER_DELETED_DELETE, true, &HandleCharacterDeletedDeleteCommand, "", NULL },
- { "list", rbac::RBAC_PERM_COMMAND_CHARACTER_DELETED_LIST, true, &HandleCharacterDeletedListCommand, "", NULL },
- { "restore", rbac::RBAC_PERM_COMMAND_CHARACTER_DELETED_RESTORE, true, &HandleCharacterDeletedRestoreCommand, "", NULL },
- { "old", rbac::RBAC_PERM_COMMAND_CHARACTER_DELETED_OLD, true, &HandleCharacterDeletedOldCommand, "", NULL },
- { NULL, 0, false, NULL, "", NULL }
+ { "delete", rbac::RBAC_PERM_COMMAND_CHARACTER_DELETED_DELETE, true, &HandleCharacterDeletedDeleteCommand, "" },
+ { "list", rbac::RBAC_PERM_COMMAND_CHARACTER_DELETED_LIST, true, &HandleCharacterDeletedListCommand, "" },
+ { "restore", rbac::RBAC_PERM_COMMAND_CHARACTER_DELETED_RESTORE, true, &HandleCharacterDeletedRestoreCommand, "" },
+ { "old", rbac::RBAC_PERM_COMMAND_CHARACTER_DELETED_OLD, true, &HandleCharacterDeletedOldCommand, "" },
};
- static ChatCommand characterCommandTable[] =
+ static std::vector<ChatCommand> characterCommandTable =
{
- { "customize", rbac::RBAC_PERM_COMMAND_CHARACTER_CUSTOMIZE, true, &HandleCharacterCustomizeCommand, "", NULL },
- { "changefaction", rbac::RBAC_PERM_COMMAND_CHARACTER_CHANGEFACTION, true, &HandleCharacterChangeFactionCommand, "", NULL },
- { "changerace", rbac::RBAC_PERM_COMMAND_CHARACTER_CHANGERACE, true, &HandleCharacterChangeRaceCommand, "", NULL },
+ { "customize", rbac::RBAC_PERM_COMMAND_CHARACTER_CUSTOMIZE, true, &HandleCharacterCustomizeCommand, "", },
+ { "changefaction", rbac::RBAC_PERM_COMMAND_CHARACTER_CHANGEFACTION, true, &HandleCharacterChangeFactionCommand, "", },
+ { "changerace", rbac::RBAC_PERM_COMMAND_CHARACTER_CHANGERACE, true, &HandleCharacterChangeRaceCommand, "", },
{ "deleted", rbac::RBAC_PERM_COMMAND_CHARACTER_DELETED, true, NULL, "", characterDeletedCommandTable },
- { "erase", rbac::RBAC_PERM_COMMAND_CHARACTER_ERASE, true, &HandleCharacterEraseCommand, "", NULL },
- { "level", rbac::RBAC_PERM_COMMAND_CHARACTER_LEVEL, true, &HandleCharacterLevelCommand, "", NULL },
- { "rename", rbac::RBAC_PERM_COMMAND_CHARACTER_RENAME, true, &HandleCharacterRenameCommand, "", NULL },
- { "reputation", rbac::RBAC_PERM_COMMAND_CHARACTER_REPUTATION, true, &HandleCharacterReputationCommand, "", NULL },
- { "titles", rbac::RBAC_PERM_COMMAND_CHARACTER_TITLES, true, &HandleCharacterTitlesCommand, "", NULL },
- { NULL, 0, false, NULL, "", NULL }
+ { "erase", rbac::RBAC_PERM_COMMAND_CHARACTER_ERASE, true, &HandleCharacterEraseCommand, "", },
+ { "level", rbac::RBAC_PERM_COMMAND_CHARACTER_LEVEL, true, &HandleCharacterLevelCommand, "", },
+ { "rename", rbac::RBAC_PERM_COMMAND_CHARACTER_RENAME, true, &HandleCharacterRenameCommand, "", },
+ { "reputation", rbac::RBAC_PERM_COMMAND_CHARACTER_REPUTATION, true, &HandleCharacterReputationCommand, "", },
+ { "titles", rbac::RBAC_PERM_COMMAND_CHARACTER_TITLES, true, &HandleCharacterTitlesCommand, "", },
};
- static ChatCommand commandTable[] =
+ static std::vector<ChatCommand> commandTable =
{
{ "character", rbac::RBAC_PERM_COMMAND_CHARACTER, true, NULL, "", characterCommandTable },
- { "levelup", rbac::RBAC_PERM_COMMAND_LEVELUP, false, &HandleLevelUpCommand, "", NULL },
+ { "levelup", rbac::RBAC_PERM_COMMAND_LEVELUP, false, &HandleLevelUpCommand, "" },
{ "pdump", rbac::RBAC_PERM_COMMAND_PDUMP, true, NULL, "", pdumpCommandTable },
- { NULL, 0, false, NULL, "", NULL }
};
return commandTable;
}
@@ -226,7 +222,7 @@ public:
stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHARACTER_NAME_DATA);
stmt->setUInt32(0, delInfo.guid.GetCounter());
if (PreparedQueryResult result = CharacterDatabase.Query(stmt))
- sWorld->AddCharacterNameData(delInfo.guid, delInfo.name, (*result)[2].GetUInt8(), (*result)[0].GetUInt8(), (*result)[1].GetUInt8(), (*result)[3].GetUInt8());
+ sWorld->AddCharacterInfo(delInfo.guid, delInfo.accountId, delInfo.name, (*result)[2].GetUInt8(), (*result)[0].GetUInt8(), (*result)[1].GetUInt8(), (*result)[3].GetUInt8());
}
static void HandleCharacterLevel(Player* player, ObjectGuid playerGuid, uint32 oldLevel, uint32 newLevel, ChatHandler* handler)
@@ -339,7 +335,7 @@ public:
return false;
}
- if (ObjectMgr::CheckPlayerName(newName, true) != CHAR_NAME_SUCCESS)
+ if (ObjectMgr::CheckPlayerName(newName, target ? target->GetSession()->GetSessionDbcLocale() : sWorld->GetDefaultDbcLocale(), true) != CHAR_NAME_SUCCESS)
{
handler->SendSysMessage(LANG_BAD_VALUE);
handler->SetSentErrorMessage(true);
@@ -386,7 +382,7 @@ public:
CharacterDatabase.Execute(stmt);
}
- sWorld->UpdateCharacterNameData(targetGuid, newName);
+ sWorld->UpdateCharacterInfo(targetGuid, newName);
handler->PSendSysMessage(LANG_RENAME_PLAYER_WITH_NEW_NAME, playerOldName.c_str(), newName.c_str());
@@ -899,7 +895,7 @@ public:
return false;
}
- if (ObjectMgr::CheckPlayerName(name, true) != CHAR_NAME_SUCCESS)
+ if (ObjectMgr::CheckPlayerName(name, sWorld->GetDefaultDbcLocale(), true) != CHAR_NAME_SUCCESS)
{
handler->PSendSysMessage(LANG_INVALID_CHARACTER_NAME);
handler->SetSentErrorMessage(true);
diff --git a/src/server/scripts/Commands/cs_cheat.cpp b/src/server/scripts/Commands/cs_cheat.cpp
index 78ba5a4dc74..2dc2c17bdc2 100644
--- a/src/server/scripts/Commands/cs_cheat.cpp
+++ b/src/server/scripts/Commands/cs_cheat.cpp
@@ -32,27 +32,24 @@ class cheat_commandscript : public CommandScript
public:
cheat_commandscript() : CommandScript("cheat_commandscript") { }
- ChatCommand* GetCommands() const override
+ std::vector<ChatCommand> GetCommands() const override
{
-
- static ChatCommand cheatCommandTable[] =
+ static std::vector<ChatCommand> cheatCommandTable =
{
- { "god", rbac::RBAC_PERM_COMMAND_CHEAT_GOD, false, &HandleGodModeCheatCommand, "", NULL },
- { "casttime", rbac::RBAC_PERM_COMMAND_CHEAT_CASTTIME, false, &HandleCasttimeCheatCommand, "", NULL },
- { "cooldown", rbac::RBAC_PERM_COMMAND_CHEAT_COOLDOWN, false, &HandleCoolDownCheatCommand, "", NULL },
- { "power", rbac::RBAC_PERM_COMMAND_CHEAT_POWER, false, &HandlePowerCheatCommand, "", NULL },
- { "waterwalk", rbac::RBAC_PERM_COMMAND_CHEAT_WATERWALK, false, &HandleWaterWalkCheatCommand, "", NULL },
- { "status", rbac::RBAC_PERM_COMMAND_CHEAT_STATUS, false, &HandleCheatStatusCommand, "", NULL },
- { "taxi", rbac::RBAC_PERM_COMMAND_CHEAT_TAXI, false, &HandleTaxiCheatCommand, "", NULL },
- { "explore", rbac::RBAC_PERM_COMMAND_CHEAT_EXPLORE, false, &HandleExploreCheatCommand, "", NULL },
- { NULL, 0, false, NULL, "", NULL }
+ { "god", rbac::RBAC_PERM_COMMAND_CHEAT_GOD, false, &HandleGodModeCheatCommand, "" },
+ { "casttime", rbac::RBAC_PERM_COMMAND_CHEAT_CASTTIME, false, &HandleCasttimeCheatCommand, "" },
+ { "cooldown", rbac::RBAC_PERM_COMMAND_CHEAT_COOLDOWN, false, &HandleCoolDownCheatCommand, "" },
+ { "power", rbac::RBAC_PERM_COMMAND_CHEAT_POWER, false, &HandlePowerCheatCommand, "" },
+ { "waterwalk", rbac::RBAC_PERM_COMMAND_CHEAT_WATERWALK, false, &HandleWaterWalkCheatCommand, "" },
+ { "status", rbac::RBAC_PERM_COMMAND_CHEAT_STATUS, false, &HandleCheatStatusCommand, "" },
+ { "taxi", rbac::RBAC_PERM_COMMAND_CHEAT_TAXI, false, &HandleTaxiCheatCommand, "" },
+ { "explore", rbac::RBAC_PERM_COMMAND_CHEAT_EXPLORE, false, &HandleExploreCheatCommand, "" },
};
- static ChatCommand commandTable[] =
+ static std::vector<ChatCommand> commandTable =
{
{ "cheat", rbac::RBAC_PERM_COMMAND_CHEAT, false, NULL, "", cheatCommandTable },
- { NULL, 0, false, NULL, "", NULL }
};
return commandTable;
}
diff --git a/src/server/scripts/Commands/cs_debug.cpp b/src/server/scripts/Commands/cs_debug.cpp
index 901043980c5..7f517d09e90 100644
--- a/src/server/scripts/Commands/cs_debug.cpp
+++ b/src/server/scripts/Commands/cs_debug.cpp
@@ -42,66 +42,62 @@ class debug_commandscript : public CommandScript
public:
debug_commandscript() : CommandScript("debug_commandscript") { }
- ChatCommand* GetCommands() const override
+ std::vector<ChatCommand> GetCommands() const override
{
- static ChatCommand debugPlayCommandTable[] =
+ static std::vector<ChatCommand> debugPlayCommandTable =
{
- { "cinematic", rbac::RBAC_PERM_COMMAND_DEBUG_PLAY_CINEMATIC, false, &HandleDebugPlayCinematicCommand, "", NULL },
- { "movie", rbac::RBAC_PERM_COMMAND_DEBUG_PLAY_MOVIE, false, &HandleDebugPlayMovieCommand, "", NULL },
- { "sound", rbac::RBAC_PERM_COMMAND_DEBUG_PLAY_SOUND, false, &HandleDebugPlaySoundCommand, "", NULL },
- { NULL, 0, false, NULL, "", NULL }
+ { "cinematic", rbac::RBAC_PERM_COMMAND_DEBUG_PLAY_CINEMATIC, false, &HandleDebugPlayCinematicCommand, "" },
+ { "movie", rbac::RBAC_PERM_COMMAND_DEBUG_PLAY_MOVIE, false, &HandleDebugPlayMovieCommand, "" },
+ { "sound", rbac::RBAC_PERM_COMMAND_DEBUG_PLAY_SOUND, false, &HandleDebugPlaySoundCommand, "" },
};
- static ChatCommand debugSendCommandTable[] =
+ static std::vector<ChatCommand> debugSendCommandTable =
{
- { "buyerror", rbac::RBAC_PERM_COMMAND_DEBUG_SEND_BUYERROR, false, &HandleDebugSendBuyErrorCommand, "", NULL },
- { "channelnotify", rbac::RBAC_PERM_COMMAND_DEBUG_SEND_CHANNELNOTIFY, false, &HandleDebugSendChannelNotifyCommand, "", NULL },
- { "chatmessage", rbac::RBAC_PERM_COMMAND_DEBUG_SEND_CHATMESSAGE, false, &HandleDebugSendChatMsgCommand, "", NULL },
- { "equiperror", rbac::RBAC_PERM_COMMAND_DEBUG_SEND_EQUIPERROR, false, &HandleDebugSendEquipErrorCommand, "", NULL },
- { "largepacket", rbac::RBAC_PERM_COMMAND_DEBUG_SEND_LARGEPACKET, false, &HandleDebugSendLargePacketCommand, "", NULL },
- { "opcode", rbac::RBAC_PERM_COMMAND_DEBUG_SEND_OPCODE, false, &HandleDebugSendOpcodeCommand, "", NULL },
- { "qpartymsg", rbac::RBAC_PERM_COMMAND_DEBUG_SEND_QPARTYMSG, false, &HandleDebugSendQuestPartyMsgCommand, "", NULL },
- { "qinvalidmsg", rbac::RBAC_PERM_COMMAND_DEBUG_SEND_QINVALIDMSG, false, &HandleDebugSendQuestInvalidMsgCommand, "", NULL },
- { "sellerror", rbac::RBAC_PERM_COMMAND_DEBUG_SEND_SELLERROR, false, &HandleDebugSendSellErrorCommand, "", NULL },
- { "setphaseshift", rbac::RBAC_PERM_COMMAND_DEBUG_SEND_SETPHASESHIFT, false, &HandleDebugSendSetPhaseShiftCommand, "", NULL },
- { "spellfail", rbac::RBAC_PERM_COMMAND_DEBUG_SEND_SPELLFAIL, false, &HandleDebugSendSpellFailCommand, "", NULL },
- { NULL, 0, false, NULL, "", NULL }
+ { "buyerror", rbac::RBAC_PERM_COMMAND_DEBUG_SEND_BUYERROR, false, &HandleDebugSendBuyErrorCommand, "" },
+ { "channelnotify", rbac::RBAC_PERM_COMMAND_DEBUG_SEND_CHANNELNOTIFY, false, &HandleDebugSendChannelNotifyCommand, "" },
+ { "chatmessage", rbac::RBAC_PERM_COMMAND_DEBUG_SEND_CHATMESSAGE, false, &HandleDebugSendChatMsgCommand, "" },
+ { "equiperror", rbac::RBAC_PERM_COMMAND_DEBUG_SEND_EQUIPERROR, false, &HandleDebugSendEquipErrorCommand, "" },
+ { "largepacket", rbac::RBAC_PERM_COMMAND_DEBUG_SEND_LARGEPACKET, false, &HandleDebugSendLargePacketCommand, "" },
+ { "opcode", rbac::RBAC_PERM_COMMAND_DEBUG_SEND_OPCODE, false, &HandleDebugSendOpcodeCommand, "" },
+ { "qpartymsg", rbac::RBAC_PERM_COMMAND_DEBUG_SEND_QPARTYMSG, false, &HandleDebugSendQuestPartyMsgCommand, "" },
+ { "qinvalidmsg", rbac::RBAC_PERM_COMMAND_DEBUG_SEND_QINVALIDMSG, false, &HandleDebugSendQuestInvalidMsgCommand, "" },
+ { "sellerror", rbac::RBAC_PERM_COMMAND_DEBUG_SEND_SELLERROR, false, &HandleDebugSendSellErrorCommand, "" },
+ { "setphaseshift", rbac::RBAC_PERM_COMMAND_DEBUG_SEND_SETPHASESHIFT, false, &HandleDebugSendSetPhaseShiftCommand, "" },
+ { "spellfail", rbac::RBAC_PERM_COMMAND_DEBUG_SEND_SPELLFAIL, false, &HandleDebugSendSpellFailCommand, "" },
};
- static ChatCommand debugCommandTable[] =
+ static std::vector<ChatCommand> debugCommandTable =
{
- { "setbit", rbac::RBAC_PERM_COMMAND_DEBUG_SETBIT, false, &HandleDebugSet32BitCommand, "", NULL },
- { "threat", rbac::RBAC_PERM_COMMAND_DEBUG_THREAT, false, &HandleDebugThreatListCommand, "", NULL },
- { "hostil", rbac::RBAC_PERM_COMMAND_DEBUG_HOSTIL, false, &HandleDebugHostileRefListCommand, "", NULL },
- { "anim", rbac::RBAC_PERM_COMMAND_DEBUG_ANIM, false, &HandleDebugAnimCommand, "", NULL },
- { "arena", rbac::RBAC_PERM_COMMAND_DEBUG_ARENA, false, &HandleDebugArenaCommand, "", NULL },
- { "bg", rbac::RBAC_PERM_COMMAND_DEBUG_BG, false, &HandleDebugBattlegroundCommand, "", NULL },
- { "getitemstate", rbac::RBAC_PERM_COMMAND_DEBUG_GETITEMSTATE, false, &HandleDebugGetItemStateCommand, "", NULL },
- { "lootrecipient", rbac::RBAC_PERM_COMMAND_DEBUG_LOOTRECIPIENT, false, &HandleDebugGetLootRecipientCommand, "", NULL },
- { "getvalue", rbac::RBAC_PERM_COMMAND_DEBUG_GETVALUE, false, &HandleDebugGetValueCommand, "", NULL },
- { "getitemvalue", rbac::RBAC_PERM_COMMAND_DEBUG_GETITEMVALUE, false, &HandleDebugGetItemValueCommand, "", NULL },
- { "Mod32Value", rbac::RBAC_PERM_COMMAND_DEBUG_MOD32VALUE, false, &HandleDebugMod32ValueCommand, "", NULL },
+ { "setbit", rbac::RBAC_PERM_COMMAND_DEBUG_SETBIT, false, &HandleDebugSet32BitCommand, "" },
+ { "threat", rbac::RBAC_PERM_COMMAND_DEBUG_THREAT, false, &HandleDebugThreatListCommand, "" },
+ { "hostil", rbac::RBAC_PERM_COMMAND_DEBUG_HOSTIL, false, &HandleDebugHostileRefListCommand, "" },
+ { "anim", rbac::RBAC_PERM_COMMAND_DEBUG_ANIM, false, &HandleDebugAnimCommand, "" },
+ { "arena", rbac::RBAC_PERM_COMMAND_DEBUG_ARENA, false, &HandleDebugArenaCommand, "" },
+ { "bg", rbac::RBAC_PERM_COMMAND_DEBUG_BG, false, &HandleDebugBattlegroundCommand, "" },
+ { "getitemstate", rbac::RBAC_PERM_COMMAND_DEBUG_GETITEMSTATE, false, &HandleDebugGetItemStateCommand, "" },
+ { "lootrecipient", rbac::RBAC_PERM_COMMAND_DEBUG_LOOTRECIPIENT, false, &HandleDebugGetLootRecipientCommand, "" },
+ { "getvalue", rbac::RBAC_PERM_COMMAND_DEBUG_GETVALUE, false, &HandleDebugGetValueCommand, "" },
+ { "getitemvalue", rbac::RBAC_PERM_COMMAND_DEBUG_GETITEMVALUE, false, &HandleDebugGetItemValueCommand, "" },
+ { "Mod32Value", rbac::RBAC_PERM_COMMAND_DEBUG_MOD32VALUE, false, &HandleDebugMod32ValueCommand, "" },
{ "play", rbac::RBAC_PERM_COMMAND_DEBUG_PLAY, false, NULL, "", debugPlayCommandTable },
{ "send", rbac::RBAC_PERM_COMMAND_DEBUG_SEND, false, NULL, "", debugSendCommandTable },
- { "setaurastate", rbac::RBAC_PERM_COMMAND_DEBUG_SETAURASTATE, false, &HandleDebugSetAuraStateCommand, "", NULL },
- { "setitemvalue", rbac::RBAC_PERM_COMMAND_DEBUG_SETITEMVALUE, false, &HandleDebugSetItemValueCommand, "", NULL },
- { "setvalue", rbac::RBAC_PERM_COMMAND_DEBUG_SETVALUE, false, &HandleDebugSetValueCommand, "", NULL },
- { "spawnvehicle", rbac::RBAC_PERM_COMMAND_DEBUG_SPAWNVEHICLE, false, &HandleDebugSpawnVehicleCommand, "", NULL },
- { "setvid", rbac::RBAC_PERM_COMMAND_DEBUG_SETVID, false, &HandleDebugSetVehicleIdCommand, "", NULL },
- { "entervehicle", rbac::RBAC_PERM_COMMAND_DEBUG_ENTERVEHICLE, false, &HandleDebugEnterVehicleCommand, "", NULL },
- { "uws", rbac::RBAC_PERM_COMMAND_DEBUG_UWS, false, &HandleDebugUpdateWorldStateCommand, "", NULL },
- { "update", rbac::RBAC_PERM_COMMAND_DEBUG_UPDATE, false, &HandleDebugUpdateCommand, "", NULL },
- { "itemexpire", rbac::RBAC_PERM_COMMAND_DEBUG_ITEMEXPIRE, false, &HandleDebugItemExpireCommand, "", NULL },
- { "areatriggers", rbac::RBAC_PERM_COMMAND_DEBUG_AREATRIGGERS, false, &HandleDebugAreaTriggersCommand, "", NULL },
- { "los", rbac::RBAC_PERM_COMMAND_DEBUG_LOS, false, &HandleDebugLoSCommand, "", NULL },
- { "moveflags", rbac::RBAC_PERM_COMMAND_DEBUG_MOVEFLAGS, false, &HandleDebugMoveflagsCommand, "", NULL },
- { "transport", rbac::RBAC_PERM_COMMAND_DEBUG_TRANSPORT, false, &HandleDebugTransportCommand, "", NULL },
- { "loadcells", rbac::RBAC_PERM_COMMAND_DEBUG_LOADCELLS, false, &HandleDebugLoadCellsCommand, "", NULL },
- { NULL, 0, false, NULL, "", NULL }
+ { "setaurastate", rbac::RBAC_PERM_COMMAND_DEBUG_SETAURASTATE, false, &HandleDebugSetAuraStateCommand, "" },
+ { "setitemvalue", rbac::RBAC_PERM_COMMAND_DEBUG_SETITEMVALUE, false, &HandleDebugSetItemValueCommand, "" },
+ { "setvalue", rbac::RBAC_PERM_COMMAND_DEBUG_SETVALUE, false, &HandleDebugSetValueCommand, "" },
+ { "spawnvehicle", rbac::RBAC_PERM_COMMAND_DEBUG_SPAWNVEHICLE, false, &HandleDebugSpawnVehicleCommand, "" },
+ { "setvid", rbac::RBAC_PERM_COMMAND_DEBUG_SETVID, false, &HandleDebugSetVehicleIdCommand, "" },
+ { "entervehicle", rbac::RBAC_PERM_COMMAND_DEBUG_ENTERVEHICLE, false, &HandleDebugEnterVehicleCommand, "" },
+ { "uws", rbac::RBAC_PERM_COMMAND_DEBUG_UWS, false, &HandleDebugUpdateWorldStateCommand, "" },
+ { "update", rbac::RBAC_PERM_COMMAND_DEBUG_UPDATE, false, &HandleDebugUpdateCommand, "" },
+ { "itemexpire", rbac::RBAC_PERM_COMMAND_DEBUG_ITEMEXPIRE, false, &HandleDebugItemExpireCommand, "" },
+ { "areatriggers", rbac::RBAC_PERM_COMMAND_DEBUG_AREATRIGGERS, false, &HandleDebugAreaTriggersCommand, "" },
+ { "los", rbac::RBAC_PERM_COMMAND_DEBUG_LOS, false, &HandleDebugLoSCommand, "" },
+ { "moveflags", rbac::RBAC_PERM_COMMAND_DEBUG_MOVEFLAGS, false, &HandleDebugMoveflagsCommand, "" },
+ { "transport", rbac::RBAC_PERM_COMMAND_DEBUG_TRANSPORT, false, &HandleDebugTransportCommand, "" },
+ { "loadcells", rbac::RBAC_PERM_COMMAND_DEBUG_LOADCELLS, false, &HandleDebugLoadCellsCommand, "" },
};
- static ChatCommand commandTable[] =
+ static std::vector<ChatCommand> commandTable =
{
{ "debug", rbac::RBAC_PERM_COMMAND_DEBUG, true, NULL, "", debugCommandTable },
- { "wpgps", rbac::RBAC_PERM_COMMAND_WPGPS, false, &HandleWPGPSCommand, "", NULL },
- { NULL, 0, false, NULL, "", NULL }
+ { "wpgps", rbac::RBAC_PERM_COMMAND_WPGPS, false, &HandleWPGPSCommand, "" },
};
return commandTable;
}
diff --git a/src/server/scripts/Commands/cs_deserter.cpp b/src/server/scripts/Commands/cs_deserter.cpp
index 2887ac8c134..9f461207707 100644
--- a/src/server/scripts/Commands/cs_deserter.cpp
+++ b/src/server/scripts/Commands/cs_deserter.cpp
@@ -43,31 +43,27 @@ public:
* @brief Returns the command structure for the system.
*/
- ChatCommand* GetCommands() const override
+ std::vector<ChatCommand> GetCommands() const override
{
- static ChatCommand deserterInstanceCommandTable[] =
+ static std::vector<ChatCommand> deserterInstanceCommandTable =
{
- { "add", rbac::RBAC_PERM_COMMAND_DESERTER_INSTANCE_ADD, false, &HandleDeserterInstanceAdd, "", NULL },
- { "remove", rbac::RBAC_PERM_COMMAND_DESERTER_INSTANCE_REMOVE, false, &HandleDeserterInstanceRemove, "", NULL },
- { NULL, 0, false, NULL, "", NULL }
+ { "add", rbac::RBAC_PERM_COMMAND_DESERTER_INSTANCE_ADD, false, &HandleDeserterInstanceAdd, "" },
+ { "remove", rbac::RBAC_PERM_COMMAND_DESERTER_INSTANCE_REMOVE, false, &HandleDeserterInstanceRemove, "" },
};
- static ChatCommand deserterBGCommandTable[] =
+ static std::vector<ChatCommand> deserterBGCommandTable =
{
- { "add", rbac::RBAC_PERM_COMMAND_DESERTER_BG_ADD, false, &HandleDeserterBGAdd, "", NULL },
- { "remove", rbac::RBAC_PERM_COMMAND_DESERTER_BG_REMOVE, false, &HandleDeserterBGRemove, "", NULL },
- { NULL, 0, false, NULL, "", NULL }
+ { "add", rbac::RBAC_PERM_COMMAND_DESERTER_BG_ADD, false, &HandleDeserterBGAdd, "" },
+ { "remove", rbac::RBAC_PERM_COMMAND_DESERTER_BG_REMOVE, false, &HandleDeserterBGRemove, "" },
};
- static ChatCommand deserterCommandTable[] =
+ static std::vector<ChatCommand> deserterCommandTable =
{
{ "instance", rbac::RBAC_PERM_COMMAND_DESERTER_INSTANCE, false, NULL, "", deserterInstanceCommandTable },
{ "bg", rbac::RBAC_PERM_COMMAND_DESERTER_BG, false, NULL, "", deserterBGCommandTable },
- { NULL, 0, false, NULL, "", NULL }
};
- static ChatCommand commandTable[] =
+ static std::vector<ChatCommand> commandTable =
{
{ "deserter", rbac::RBAC_PERM_COMMAND_DESERTER, false, NULL, "", deserterCommandTable },
- { NULL, 0, false, NULL, "", NULL }
};
return commandTable;
}
diff --git a/src/server/scripts/Commands/cs_disable.cpp b/src/server/scripts/Commands/cs_disable.cpp
index 14f76945a80..8c73f3f41de 100644
--- a/src/server/scripts/Commands/cs_disable.cpp
+++ b/src/server/scripts/Commands/cs_disable.cpp
@@ -37,42 +37,38 @@ class disable_commandscript : public CommandScript
public:
disable_commandscript() : CommandScript("disable_commandscript") { }
- ChatCommand* GetCommands() const override
+ std::vector<ChatCommand> GetCommands() const override
{
- static ChatCommand removeDisableCommandTable[] =
+ static std::vector<ChatCommand> removeDisableCommandTable =
{
- { "spell", rbac::RBAC_PERM_COMMAND_DISABLE_REMOVE_SPELL, true, &HandleRemoveDisableSpellCommand, "", NULL },
- { "quest", rbac::RBAC_PERM_COMMAND_DISABLE_REMOVE_QUEST, true, &HandleRemoveDisableQuestCommand, "", NULL },
- { "map", rbac::RBAC_PERM_COMMAND_DISABLE_REMOVE_MAP, true, &HandleRemoveDisableMapCommand, "", NULL },
- { "battleground", rbac::RBAC_PERM_COMMAND_DISABLE_REMOVE_BATTLEGROUND, true, &HandleRemoveDisableBattlegroundCommand, "", NULL },
- { "achievement_criteria", rbac::RBAC_PERM_COMMAND_DISABLE_REMOVE_ACHIEVEMENT_CRITERIA, true, &HandleRemoveDisableAchievementCriteriaCommand, "", NULL },
- { "outdoorpvp", rbac::RBAC_PERM_COMMAND_DISABLE_REMOVE_OUTDOORPVP, true, &HandleRemoveDisableOutdoorPvPCommand, "", NULL },
- { "vmap", rbac::RBAC_PERM_COMMAND_DISABLE_REMOVE_VMAP, true, &HandleRemoveDisableVmapCommand, "", NULL },
- { "mmap", rbac::RBAC_PERM_COMMAND_DISABLE_REMOVE_MMAP, true, &HandleRemoveDisableMMapCommand, "", NULL },
- { NULL, 0, false, NULL, "", NULL }
+ { "spell", rbac::RBAC_PERM_COMMAND_DISABLE_REMOVE_SPELL, true, &HandleRemoveDisableSpellCommand, "" },
+ { "quest", rbac::RBAC_PERM_COMMAND_DISABLE_REMOVE_QUEST, true, &HandleRemoveDisableQuestCommand, "" },
+ { "map", rbac::RBAC_PERM_COMMAND_DISABLE_REMOVE_MAP, true, &HandleRemoveDisableMapCommand, "" },
+ { "battleground", rbac::RBAC_PERM_COMMAND_DISABLE_REMOVE_BATTLEGROUND, true, &HandleRemoveDisableBattlegroundCommand, "" },
+ { "achievement_criteria", rbac::RBAC_PERM_COMMAND_DISABLE_REMOVE_ACHIEVEMENT_CRITERIA, true, &HandleRemoveDisableAchievementCriteriaCommand, "" },
+ { "outdoorpvp", rbac::RBAC_PERM_COMMAND_DISABLE_REMOVE_OUTDOORPVP, true, &HandleRemoveDisableOutdoorPvPCommand, "" },
+ { "vmap", rbac::RBAC_PERM_COMMAND_DISABLE_REMOVE_VMAP, true, &HandleRemoveDisableVmapCommand, "" },
+ { "mmap", rbac::RBAC_PERM_COMMAND_DISABLE_REMOVE_MMAP, true, &HandleRemoveDisableMMapCommand, "" },
};
- static ChatCommand addDisableCommandTable[] =
+ static std::vector<ChatCommand> addDisableCommandTable =
{
- { "spell", rbac::RBAC_PERM_COMMAND_DISABLE_ADD_SPELL, true, &HandleAddDisableSpellCommand, "", NULL },
- { "quest", rbac::RBAC_PERM_COMMAND_DISABLE_ADD_QUEST, true, &HandleAddDisableQuestCommand, "", NULL },
- { "map", rbac::RBAC_PERM_COMMAND_DISABLE_ADD_MAP, true, &HandleAddDisableMapCommand, "", NULL },
- { "battleground", rbac::RBAC_PERM_COMMAND_DISABLE_ADD_BATTLEGROUND, true, &HandleAddDisableBattlegroundCommand, "", NULL },
- { "achievement_criteria", rbac::RBAC_PERM_COMMAND_DISABLE_ADD_ACHIEVEMENT_CRITERIA, true, &HandleAddDisableAchievementCriteriaCommand, "", NULL },
- { "outdoorpvp", rbac::RBAC_PERM_COMMAND_DISABLE_ADD_OUTDOORPVP, true, &HandleAddDisableOutdoorPvPCommand, "", NULL },
- { "vmap", rbac::RBAC_PERM_COMMAND_DISABLE_ADD_VMAP, true, &HandleAddDisableVmapCommand, "", NULL },
- { "mmap", rbac::RBAC_PERM_COMMAND_DISABLE_ADD_MMAP, true, &HandleAddDisableMMapCommand, "", NULL },
- { NULL, 0, false, NULL, "", NULL }
+ { "spell", rbac::RBAC_PERM_COMMAND_DISABLE_ADD_SPELL, true, &HandleAddDisableSpellCommand, "" },
+ { "quest", rbac::RBAC_PERM_COMMAND_DISABLE_ADD_QUEST, true, &HandleAddDisableQuestCommand, "" },
+ { "map", rbac::RBAC_PERM_COMMAND_DISABLE_ADD_MAP, true, &HandleAddDisableMapCommand, "" },
+ { "battleground", rbac::RBAC_PERM_COMMAND_DISABLE_ADD_BATTLEGROUND, true, &HandleAddDisableBattlegroundCommand, "" },
+ { "achievement_criteria", rbac::RBAC_PERM_COMMAND_DISABLE_ADD_ACHIEVEMENT_CRITERIA, true, &HandleAddDisableAchievementCriteriaCommand, "" },
+ { "outdoorpvp", rbac::RBAC_PERM_COMMAND_DISABLE_ADD_OUTDOORPVP, true, &HandleAddDisableOutdoorPvPCommand, "" },
+ { "vmap", rbac::RBAC_PERM_COMMAND_DISABLE_ADD_VMAP, true, &HandleAddDisableVmapCommand, "" },
+ { "mmap", rbac::RBAC_PERM_COMMAND_DISABLE_ADD_MMAP, true, &HandleAddDisableMMapCommand, "" },
};
- static ChatCommand disableCommandTable[] =
+ static std::vector<ChatCommand> disableCommandTable =
{
{ "add", rbac::RBAC_PERM_COMMAND_DISABLE_ADD, true, NULL, "", addDisableCommandTable },
{ "remove", rbac::RBAC_PERM_COMMAND_DISABLE_REMOVE, true, NULL, "", removeDisableCommandTable },
- { NULL, 0, false, NULL, "", NULL }
};
- static ChatCommand commandTable[] =
+ static std::vector<ChatCommand> commandTable =
{
{ "disable", rbac::RBAC_PERM_COMMAND_DISABLE, false, NULL, "", disableCommandTable },
- { NULL, 0, false, NULL, "", NULL }
};
return commandTable;
}
diff --git a/src/server/scripts/Commands/cs_event.cpp b/src/server/scripts/Commands/cs_event.cpp
index 37495289149..352bce4e7f0 100644
--- a/src/server/scripts/Commands/cs_event.cpp
+++ b/src/server/scripts/Commands/cs_event.cpp
@@ -33,20 +33,18 @@ class event_commandscript : public CommandScript
public:
event_commandscript() : CommandScript("event_commandscript") { }
- ChatCommand* GetCommands() const override
+ std::vector<ChatCommand> GetCommands() const override
{
- static ChatCommand eventCommandTable[] =
+ static std::vector<ChatCommand> eventCommandTable =
{
- { "activelist", rbac::RBAC_PERM_COMMAND_EVENT_ACTIVELIST, true, &HandleEventActiveListCommand, "", NULL },
- { "start", rbac::RBAC_PERM_COMMAND_EVENT_START, true, &HandleEventStartCommand, "", NULL },
- { "stop", rbac::RBAC_PERM_COMMAND_EVENT_STOP, true, &HandleEventStopCommand, "", NULL },
- { "", rbac::RBAC_PERM_COMMAND_EVENT, true, &HandleEventInfoCommand, "", NULL },
- { NULL, 0, false, NULL, "", NULL }
+ { "activelist", rbac::RBAC_PERM_COMMAND_EVENT_ACTIVELIST, true, &HandleEventActiveListCommand, "" },
+ { "start", rbac::RBAC_PERM_COMMAND_EVENT_START, true, &HandleEventStartCommand, "" },
+ { "stop", rbac::RBAC_PERM_COMMAND_EVENT_STOP, true, &HandleEventStopCommand, "" },
+ { "", rbac::RBAC_PERM_COMMAND_EVENT, true, &HandleEventInfoCommand, "" },
};
- static ChatCommand commandTable[] =
+ static std::vector<ChatCommand> commandTable =
{
{ "event", rbac::RBAC_PERM_COMMAND_EVENT, false, NULL, "", eventCommandTable },
- { NULL, 0, false, NULL, "", NULL }
};
return commandTable;
}
diff --git a/src/server/scripts/Commands/cs_gm.cpp b/src/server/scripts/Commands/cs_gm.cpp
index 94e974bea0b..81b70603680 100644
--- a/src/server/scripts/Commands/cs_gm.cpp
+++ b/src/server/scripts/Commands/cs_gm.cpp
@@ -36,22 +36,20 @@ class gm_commandscript : public CommandScript
public:
gm_commandscript() : CommandScript("gm_commandscript") { }
- ChatCommand* GetCommands() const override
+ std::vector<ChatCommand> GetCommands() const override
{
- static ChatCommand gmCommandTable[] =
+ static std::vector<ChatCommand> gmCommandTable =
{
- { "chat", rbac::RBAC_PERM_COMMAND_GM_CHAT, false, &HandleGMChatCommand, "", NULL },
- { "fly", rbac::RBAC_PERM_COMMAND_GM_FLY, false, &HandleGMFlyCommand, "", NULL },
- { "ingame", rbac::RBAC_PERM_COMMAND_GM_INGAME, true, &HandleGMListIngameCommand, "", NULL },
- { "list", rbac::RBAC_PERM_COMMAND_GM_LIST, true, &HandleGMListFullCommand, "", NULL },
- { "visible", rbac::RBAC_PERM_COMMAND_GM_VISIBLE, false, &HandleGMVisibleCommand, "", NULL },
- { "", rbac::RBAC_PERM_COMMAND_GM, false, &HandleGMCommand, "", NULL },
- { NULL, 0, false, NULL, "", NULL }
+ { "chat", rbac::RBAC_PERM_COMMAND_GM_CHAT, false, &HandleGMChatCommand, "" },
+ { "fly", rbac::RBAC_PERM_COMMAND_GM_FLY, false, &HandleGMFlyCommand, "" },
+ { "ingame", rbac::RBAC_PERM_COMMAND_GM_INGAME, true, &HandleGMListIngameCommand, "" },
+ { "list", rbac::RBAC_PERM_COMMAND_GM_LIST, true, &HandleGMListFullCommand, "" },
+ { "visible", rbac::RBAC_PERM_COMMAND_GM_VISIBLE, false, &HandleGMVisibleCommand, "" },
+ { "", rbac::RBAC_PERM_COMMAND_GM, false, &HandleGMCommand, "" },
};
- static ChatCommand commandTable[] =
+ static std::vector<ChatCommand> commandTable =
{
{ "gm", rbac::RBAC_PERM_COMMAND_GM, false, NULL, "", gmCommandTable },
- { NULL, 0, false, NULL, "", NULL }
};
return commandTable;
}
diff --git a/src/server/scripts/Commands/cs_go.cpp b/src/server/scripts/Commands/cs_go.cpp
index ce1a42e6e78..a810106269e 100644
--- a/src/server/scripts/Commands/cs_go.cpp
+++ b/src/server/scripts/Commands/cs_go.cpp
@@ -36,27 +36,25 @@ class go_commandscript : public CommandScript
public:
go_commandscript() : CommandScript("go_commandscript") { }
- ChatCommand* GetCommands() const override
+ std::vector<ChatCommand> GetCommands() const override
{
- static ChatCommand goCommandTable[] =
- {
- { "creature", rbac::RBAC_PERM_COMMAND_GO_CREATURE, false, &HandleGoCreatureCommand, "", NULL },
- { "graveyard", rbac::RBAC_PERM_COMMAND_GO_GRAVEYARD, false, &HandleGoGraveyardCommand, "", NULL },
- { "grid", rbac::RBAC_PERM_COMMAND_GO_GRID, false, &HandleGoGridCommand, "", NULL },
- { "object", rbac::RBAC_PERM_COMMAND_GO_OBJECT, false, &HandleGoObjectCommand, "", NULL },
- { "taxinode", rbac::RBAC_PERM_COMMAND_GO_TAXINODE, false, &HandleGoTaxinodeCommand, "", NULL },
- { "trigger", rbac::RBAC_PERM_COMMAND_GO_TRIGGER, false, &HandleGoTriggerCommand, "", NULL },
- { "zonexy", rbac::RBAC_PERM_COMMAND_GO_ZONEXY, false, &HandleGoZoneXYCommand, "", NULL },
- { "xyz", rbac::RBAC_PERM_COMMAND_GO_XYZ, false, &HandleGoXYZCommand, "", NULL },
- { "ticket", rbac::RBAC_PERM_COMMAND_GO_TICKET, false, &HandleGoTicketCommand, "", NULL },
- { "", rbac::RBAC_PERM_COMMAND_GO, false, &HandleGoXYZCommand, "", NULL },
- { NULL, 0, false, NULL, "", NULL }
+ static std::vector<ChatCommand> goCommandTable =
+ {
+ { "creature", rbac::RBAC_PERM_COMMAND_GO_CREATURE, false, &HandleGoCreatureCommand, "" },
+ { "graveyard", rbac::RBAC_PERM_COMMAND_GO_GRAVEYARD, false, &HandleGoGraveyardCommand, "" },
+ { "grid", rbac::RBAC_PERM_COMMAND_GO_GRID, false, &HandleGoGridCommand, "" },
+ { "object", rbac::RBAC_PERM_COMMAND_GO_OBJECT, false, &HandleGoObjectCommand, "" },
+ { "taxinode", rbac::RBAC_PERM_COMMAND_GO_TAXINODE, false, &HandleGoTaxinodeCommand, "" },
+ { "trigger", rbac::RBAC_PERM_COMMAND_GO_TRIGGER, false, &HandleGoTriggerCommand, "" },
+ { "zonexy", rbac::RBAC_PERM_COMMAND_GO_ZONEXY, false, &HandleGoZoneXYCommand, "" },
+ { "xyz", rbac::RBAC_PERM_COMMAND_GO_XYZ, false, &HandleGoXYZCommand, "" },
+ { "ticket", rbac::RBAC_PERM_COMMAND_GO_TICKET, false, &HandleGoTicketCommand, "" },
+ { "", rbac::RBAC_PERM_COMMAND_GO, false, &HandleGoXYZCommand, "" },
};
- static ChatCommand commandTable[] =
+ static std::vector<ChatCommand> commandTable =
{
{ "go", rbac::RBAC_PERM_COMMAND_GO, false, NULL, "", goCommandTable },
- { NULL, 0, false, NULL, "", NULL }
};
return commandTable;
}
diff --git a/src/server/scripts/Commands/cs_gobject.cpp b/src/server/scripts/Commands/cs_gobject.cpp
index 9710a7e634c..fda9101fc3f 100644
--- a/src/server/scripts/Commands/cs_gobject.cpp
+++ b/src/server/scripts/Commands/cs_gobject.cpp
@@ -37,37 +37,33 @@ class gobject_commandscript : public CommandScript
public:
gobject_commandscript() : CommandScript("gobject_commandscript") { }
- ChatCommand* GetCommands() const override
+ std::vector<ChatCommand> GetCommands() const override
{
- static ChatCommand gobjectAddCommandTable[] =
+ static std::vector<ChatCommand> gobjectAddCommandTable =
{
- { "temp", rbac::RBAC_PERM_COMMAND_GOBJECT_ADD_TEMP, false, &HandleGameObjectAddTempCommand, "", NULL },
- { "", rbac::RBAC_PERM_COMMAND_GOBJECT_ADD, false, &HandleGameObjectAddCommand, "", NULL },
- { NULL, 0, false, NULL, "", NULL }
+ { "temp", rbac::RBAC_PERM_COMMAND_GOBJECT_ADD_TEMP, false, &HandleGameObjectAddTempCommand, "" },
+ { "", rbac::RBAC_PERM_COMMAND_GOBJECT_ADD, false, &HandleGameObjectAddCommand, "" },
};
- static ChatCommand gobjectSetCommandTable[] =
+ static std::vector<ChatCommand> gobjectSetCommandTable =
{
- { "phase", rbac::RBAC_PERM_COMMAND_GOBJECT_SET_PHASE, false, &HandleGameObjectSetPhaseCommand, "", NULL },
- { "state", rbac::RBAC_PERM_COMMAND_GOBJECT_SET_STATE, false, &HandleGameObjectSetStateCommand, "", NULL },
- { NULL, 0, false, NULL, "", NULL }
+ { "phase", rbac::RBAC_PERM_COMMAND_GOBJECT_SET_PHASE, false, &HandleGameObjectSetPhaseCommand, "" },
+ { "state", rbac::RBAC_PERM_COMMAND_GOBJECT_SET_STATE, false, &HandleGameObjectSetStateCommand, "" },
};
- static ChatCommand gobjectCommandTable[] =
- {
- { "activate", rbac::RBAC_PERM_COMMAND_GOBJECT_ACTIVATE, false, &HandleGameObjectActivateCommand, "", NULL },
- { "delete", rbac::RBAC_PERM_COMMAND_GOBJECT_DELETE, false, &HandleGameObjectDeleteCommand, "", NULL },
- { "info", rbac::RBAC_PERM_COMMAND_GOBJECT_INFO, false, &HandleGameObjectInfoCommand, "", NULL },
- { "move", rbac::RBAC_PERM_COMMAND_GOBJECT_MOVE, false, &HandleGameObjectMoveCommand, "", NULL },
- { "near", rbac::RBAC_PERM_COMMAND_GOBJECT_NEAR, false, &HandleGameObjectNearCommand, "", NULL },
- { "target", rbac::RBAC_PERM_COMMAND_GOBJECT_TARGET, false, &HandleGameObjectTargetCommand, "", NULL },
- { "turn", rbac::RBAC_PERM_COMMAND_GOBJECT_TURN, false, &HandleGameObjectTurnCommand, "", NULL },
+ static std::vector<ChatCommand> gobjectCommandTable =
+ {
+ { "activate", rbac::RBAC_PERM_COMMAND_GOBJECT_ACTIVATE, false, &HandleGameObjectActivateCommand, "" },
+ { "delete", rbac::RBAC_PERM_COMMAND_GOBJECT_DELETE, false, &HandleGameObjectDeleteCommand, "" },
+ { "info", rbac::RBAC_PERM_COMMAND_GOBJECT_INFO, false, &HandleGameObjectInfoCommand, "" },
+ { "move", rbac::RBAC_PERM_COMMAND_GOBJECT_MOVE, false, &HandleGameObjectMoveCommand, "" },
+ { "near", rbac::RBAC_PERM_COMMAND_GOBJECT_NEAR, false, &HandleGameObjectNearCommand, "" },
+ { "target", rbac::RBAC_PERM_COMMAND_GOBJECT_TARGET, false, &HandleGameObjectTargetCommand, "" },
+ { "turn", rbac::RBAC_PERM_COMMAND_GOBJECT_TURN, false, &HandleGameObjectTurnCommand, "" },
{ "add", rbac::RBAC_PERM_COMMAND_GOBJECT_ADD, false, NULL, "", gobjectAddCommandTable },
{ "set", rbac::RBAC_PERM_COMMAND_GOBJECT_SET, false, NULL, "", gobjectSetCommandTable },
- { NULL, 0, false, NULL, "", NULL }
};
- static ChatCommand commandTable[] =
+ static std::vector<ChatCommand> commandTable =
{
{ "gobject", rbac::RBAC_PERM_COMMAND_GOBJECT, false, NULL, "", gobjectCommandTable },
- { NULL, 0, false, NULL, "", NULL }
};
return commandTable;
}
diff --git a/src/server/scripts/Commands/cs_group.cpp b/src/server/scripts/Commands/cs_group.cpp
index 8152508c5df..054cff996f9 100644
--- a/src/server/scripts/Commands/cs_group.cpp
+++ b/src/server/scripts/Commands/cs_group.cpp
@@ -28,23 +28,21 @@ class group_commandscript : public CommandScript
public:
group_commandscript() : CommandScript("group_commandscript") { }
- ChatCommand* GetCommands() const override
+ std::vector<ChatCommand> GetCommands() const override
{
- static ChatCommand groupCommandTable[] =
+ static std::vector<ChatCommand> groupCommandTable =
{
- { "leader", rbac::RBAC_PERM_COMMAND_GROUP_LEADER, false, &HandleGroupLeaderCommand, "", NULL },
- { "disband", rbac::RBAC_PERM_COMMAND_GROUP_DISBAND, false, &HandleGroupDisbandCommand, "", NULL },
- { "remove", rbac::RBAC_PERM_COMMAND_GROUP_REMOVE, false, &HandleGroupRemoveCommand, "", NULL },
- { "join", rbac::RBAC_PERM_COMMAND_GROUP_JOIN, false, &HandleGroupJoinCommand, "", NULL },
- { "list", rbac::RBAC_PERM_COMMAND_GROUP_LIST, false, &HandleGroupListCommand, "", NULL },
- { "summon", rbac::RBAC_PERM_COMMAND_GROUP_SUMMON, false, &HandleGroupSummonCommand, "", NULL },
- { NULL, 0, false, NULL, "", NULL }
+ { "leader", rbac::RBAC_PERM_COMMAND_GROUP_LEADER, false, &HandleGroupLeaderCommand, "" },
+ { "disband", rbac::RBAC_PERM_COMMAND_GROUP_DISBAND, false, &HandleGroupDisbandCommand, "" },
+ { "remove", rbac::RBAC_PERM_COMMAND_GROUP_REMOVE, false, &HandleGroupRemoveCommand, "" },
+ { "join", rbac::RBAC_PERM_COMMAND_GROUP_JOIN, false, &HandleGroupJoinCommand, "" },
+ { "list", rbac::RBAC_PERM_COMMAND_GROUP_LIST, false, &HandleGroupListCommand, "" },
+ { "summon", rbac::RBAC_PERM_COMMAND_GROUP_SUMMON, false, &HandleGroupSummonCommand, "" },
};
- static ChatCommand commandTable[] =
+ static std::vector<ChatCommand> commandTable =
{
{ "group", rbac::RBAC_PERM_COMMAND_GROUP, false, NULL, "", groupCommandTable },
- { NULL, 0, false, NULL, "", NULL }
};
return commandTable;
}
diff --git a/src/server/scripts/Commands/cs_guild.cpp b/src/server/scripts/Commands/cs_guild.cpp
index c2b9076017a..04b633f6f40 100644
--- a/src/server/scripts/Commands/cs_guild.cpp
+++ b/src/server/scripts/Commands/cs_guild.cpp
@@ -34,23 +34,21 @@ class guild_commandscript : public CommandScript
public:
guild_commandscript() : CommandScript("guild_commandscript") { }
- ChatCommand* GetCommands() const override
+ std::vector<ChatCommand> GetCommands() const override
{
- static ChatCommand guildCommandTable[] =
+ static std::vector<ChatCommand> guildCommandTable =
{
- { "create", rbac::RBAC_PERM_COMMAND_GUILD_CREATE, true, &HandleGuildCreateCommand, "", NULL },
- { "delete", rbac::RBAC_PERM_COMMAND_GUILD_DELETE, true, &HandleGuildDeleteCommand, "", NULL },
- { "invite", rbac::RBAC_PERM_COMMAND_GUILD_INVITE, true, &HandleGuildInviteCommand, "", NULL },
- { "uninvite", rbac::RBAC_PERM_COMMAND_GUILD_UNINVITE, true, &HandleGuildUninviteCommand, "", NULL },
- { "rank", rbac::RBAC_PERM_COMMAND_GUILD_RANK, true, &HandleGuildRankCommand, "", NULL },
- { "rename", rbac::RBAC_PERM_COMMAND_GUILD_RENAME, true, &HandleGuildRenameCommand, "", NULL },
- { "info", rbac::RBAC_PERM_COMMAND_GUILD_INFO, true, &HandleGuildInfoCommand, "", NULL },
- { NULL, 0, false, NULL, "", NULL }
+ { "create", rbac::RBAC_PERM_COMMAND_GUILD_CREATE, true, &HandleGuildCreateCommand, "" },
+ { "delete", rbac::RBAC_PERM_COMMAND_GUILD_DELETE, true, &HandleGuildDeleteCommand, "" },
+ { "invite", rbac::RBAC_PERM_COMMAND_GUILD_INVITE, true, &HandleGuildInviteCommand, "" },
+ { "uninvite", rbac::RBAC_PERM_COMMAND_GUILD_UNINVITE, true, &HandleGuildUninviteCommand, "" },
+ { "rank", rbac::RBAC_PERM_COMMAND_GUILD_RANK, true, &HandleGuildRankCommand, "" },
+ { "rename", rbac::RBAC_PERM_COMMAND_GUILD_RENAME, true, &HandleGuildRenameCommand, "" },
+ { "info", rbac::RBAC_PERM_COMMAND_GUILD_INFO, true, &HandleGuildInfoCommand, "" },
};
- static ChatCommand commandTable[] =
+ static std::vector<ChatCommand> commandTable =
{
{ "guild", rbac::RBAC_PERM_COMMAND_GUILD, true, NULL, "", guildCommandTable },
- { NULL, 0, false, NULL, "", NULL }
};
return commandTable;
}
diff --git a/src/server/scripts/Commands/cs_honor.cpp b/src/server/scripts/Commands/cs_honor.cpp
index ad2c53415bb..e8b41309d47 100644
--- a/src/server/scripts/Commands/cs_honor.cpp
+++ b/src/server/scripts/Commands/cs_honor.cpp
@@ -33,26 +33,23 @@ class honor_commandscript : public CommandScript
public:
honor_commandscript() : CommandScript("honor_commandscript") { }
- ChatCommand* GetCommands() const override
+ std::vector<ChatCommand> GetCommands() const override
{
- static ChatCommand honorAddCommandTable[] =
+ static std::vector<ChatCommand> honorAddCommandTable =
{
- { "kill", rbac::RBAC_PERM_COMMAND_HONOR_ADD_KILL, false, &HandleHonorAddKillCommand, "", NULL },
- { "", rbac::RBAC_PERM_COMMAND_HONOR_ADD, false, &HandleHonorAddCommand, "", NULL },
- { NULL, 0, false, NULL, "", NULL }
+ { "kill", rbac::RBAC_PERM_COMMAND_HONOR_ADD_KILL, false, &HandleHonorAddKillCommand, "" },
+ { "", rbac::RBAC_PERM_COMMAND_HONOR_ADD, false, &HandleHonorAddCommand, "" },
};
- static ChatCommand honorCommandTable[] =
+ static std::vector<ChatCommand> honorCommandTable =
{
{ "add", rbac::RBAC_PERM_COMMAND_HONOR_ADD, false, NULL, "", honorAddCommandTable },
- { "update", rbac::RBAC_PERM_COMMAND_HONOR_UPDATE, false, &HandleHonorUpdateCommand, "", NULL },
- { NULL, 0, false, NULL, "", NULL }
+ { "update", rbac::RBAC_PERM_COMMAND_HONOR_UPDATE, false, &HandleHonorUpdateCommand, "" },
};
- static ChatCommand commandTable[] =
+ static std::vector<ChatCommand> commandTable =
{
{ "honor", rbac::RBAC_PERM_COMMAND_HONOR, false, NULL, "", honorCommandTable },
- { NULL, 0, false, NULL, "", NULL }
};
return commandTable;
}
diff --git a/src/server/scripts/Commands/cs_instance.cpp b/src/server/scripts/Commands/cs_instance.cpp
index aa7310e3c65..5651aaa12ee 100644
--- a/src/server/scripts/Commands/cs_instance.cpp
+++ b/src/server/scripts/Commands/cs_instance.cpp
@@ -36,23 +36,21 @@ class instance_commandscript : public CommandScript
public:
instance_commandscript() : CommandScript("instance_commandscript") { }
- ChatCommand* GetCommands() const override
+ std::vector<ChatCommand> GetCommands() const override
{
- static ChatCommand instanceCommandTable[] =
+ static std::vector<ChatCommand> instanceCommandTable =
{
- { "listbinds", rbac::RBAC_PERM_COMMAND_INSTANCE_LISTBINDS, false, &HandleInstanceListBindsCommand, "", NULL },
- { "unbind", rbac::RBAC_PERM_COMMAND_INSTANCE_UNBIND, false, &HandleInstanceUnbindCommand, "", NULL },
- { "stats", rbac::RBAC_PERM_COMMAND_INSTANCE_STATS, true, &HandleInstanceStatsCommand, "", NULL },
- { "savedata", rbac::RBAC_PERM_COMMAND_INSTANCE_SAVEDATA, false, &HandleInstanceSaveDataCommand, "", NULL },
- { "setbossstate", rbac::RBAC_PERM_COMMAND_INSTANCE_SET_BOSS_STATE, true, &HandleInstanceSetBossStateCommand, "", NULL },
- { "getbossstate", rbac::RBAC_PERM_COMMAND_INSTANCE_GET_BOSS_STATE, true, &HandleInstanceGetBossStateCommand, "", NULL },
- { NULL, 0, false, NULL, "", NULL }
+ { "listbinds", rbac::RBAC_PERM_COMMAND_INSTANCE_LISTBINDS, false, &HandleInstanceListBindsCommand, "" },
+ { "unbind", rbac::RBAC_PERM_COMMAND_INSTANCE_UNBIND, false, &HandleInstanceUnbindCommand, "" },
+ { "stats", rbac::RBAC_PERM_COMMAND_INSTANCE_STATS, true, &HandleInstanceStatsCommand, "" },
+ { "savedata", rbac::RBAC_PERM_COMMAND_INSTANCE_SAVEDATA, false, &HandleInstanceSaveDataCommand, "" },
+ { "setbossstate", rbac::RBAC_PERM_COMMAND_INSTANCE_SET_BOSS_STATE, true, &HandleInstanceSetBossStateCommand, "" },
+ { "getbossstate", rbac::RBAC_PERM_COMMAND_INSTANCE_GET_BOSS_STATE, true, &HandleInstanceGetBossStateCommand, "" },
};
- static ChatCommand commandTable[] =
+ static std::vector<ChatCommand> commandTable =
{
{ "instance", rbac::RBAC_PERM_COMMAND_INSTANCE, true, NULL, "", instanceCommandTable },
- { NULL, 0, false, NULL, "", NULL }
};
return commandTable;
@@ -170,22 +168,22 @@ public:
static bool HandleInstanceSaveDataCommand(ChatHandler* handler, char const* /*args*/)
{
Player* player = handler->GetSession()->GetPlayer();
- Map* map = player->GetMap();
- if (!map->IsDungeon())
+ InstanceMap* map = player->GetMap()->ToInstanceMap();
+ if (!map)
{
handler->PSendSysMessage(LANG_NOT_DUNGEON);
handler->SetSentErrorMessage(true);
return false;
}
- if (!((InstanceMap*)map)->GetInstanceScript())
+ if (!map->GetInstanceScript())
{
handler->PSendSysMessage(LANG_NO_INSTANCE_DATA);
handler->SetSentErrorMessage(true);
return false;
}
- ((InstanceMap*)map)->GetInstanceScript()->SaveToDB();
+ map->GetInstanceScript()->SaveToDB();
return true;
}
@@ -227,15 +225,15 @@ public:
return false;
}
- Map* map = player->GetMap();
- if (!map->IsDungeon())
+ InstanceMap* map = player->GetMap()->ToInstanceMap();
+ if (!map)
{
handler->PSendSysMessage(LANG_NOT_DUNGEON);
handler->SetSentErrorMessage(true);
return false;
}
- if (!map->ToInstanceMap()->GetInstanceScript())
+ if (!map->GetInstanceScript())
{
handler->PSendSysMessage(LANG_NO_INSTANCE_DATA);
handler->SetSentErrorMessage(true);
@@ -246,14 +244,14 @@ public:
state = atoi(param2);
// Reject improper values.
- if (state > TO_BE_DECIDED || encounterId > map->ToInstanceMap()->GetInstanceScript()->GetEncounterCount())
+ if (state > TO_BE_DECIDED || encounterId > map->GetInstanceScript()->GetEncounterCount())
{
handler->PSendSysMessage(LANG_BAD_VALUE);
handler->SetSentErrorMessage(true);
return false;
}
- map->ToInstanceMap()->GetInstanceScript()->SetBossState(encounterId, (EncounterState)state);
+ map->GetInstanceScript()->SetBossState(encounterId, EncounterState(state));
std::string stateName = InstanceScript::GetBossStateName(state);
handler->PSendSysMessage(LANG_COMMAND_INST_SET_BOSS_STATE, encounterId, state, stateName);
return true;
@@ -294,15 +292,15 @@ public:
return false;
}
- Map* map = player->GetMap();
- if (!map->IsDungeon())
+ InstanceMap* map = player->GetMap()->ToInstanceMap();
+ if (!map)
{
handler->PSendSysMessage(LANG_NOT_DUNGEON);
handler->SetSentErrorMessage(true);
return false;
}
- if (!map->ToInstanceMap()->GetInstanceScript())
+ if (!map->GetInstanceScript())
{
handler->PSendSysMessage(LANG_NO_INSTANCE_DATA);
handler->SetSentErrorMessage(true);
@@ -311,14 +309,14 @@ public:
encounterId = atoi(param1);
- if (encounterId > map->ToInstanceMap()->GetInstanceScript()->GetEncounterCount())
+ if (encounterId > map->GetInstanceScript()->GetEncounterCount())
{
handler->PSendSysMessage(LANG_BAD_VALUE);
handler->SetSentErrorMessage(true);
return false;
}
- uint8 state = map->ToInstanceMap()->GetInstanceScript()->GetBossState(encounterId);
+ uint32 state = map->GetInstanceScript()->GetBossState(encounterId);
std::string stateName = InstanceScript::GetBossStateName(state);
handler->PSendSysMessage(LANG_COMMAND_INST_GET_BOSS_STATE, encounterId, state, stateName);
return true;
diff --git a/src/server/scripts/Commands/cs_learn.cpp b/src/server/scripts/Commands/cs_learn.cpp
index 21211afad50..d7fd4e6664c 100644
--- a/src/server/scripts/Commands/cs_learn.cpp
+++ b/src/server/scripts/Commands/cs_learn.cpp
@@ -36,40 +36,36 @@ class learn_commandscript : public CommandScript
public:
learn_commandscript() : CommandScript("learn_commandscript") { }
- ChatCommand* GetCommands() const override
+ std::vector<ChatCommand> GetCommands() const override
{
- static ChatCommand learnAllMyCommandTable[] =
+ static std::vector<ChatCommand> learnAllMyCommandTable =
{
- { "class", rbac::RBAC_PERM_COMMAND_LEARN_ALL_MY_CLASS, false, &HandleLearnAllMyClassCommand, "", NULL },
- { "pettalents", rbac::RBAC_PERM_COMMAND_LEARN_ALL_MY_PETTALENTS, false, &HandleLearnAllMyPetTalentsCommand, "", NULL },
- { "spells", rbac::RBAC_PERM_COMMAND_LEARN_ALL_MY_SPELLS, false, &HandleLearnAllMySpellsCommand, "", NULL },
- { "talents", rbac::RBAC_PERM_COMMAND_LEARN_ALL_MY_TALENTS, false, &HandleLearnAllMyTalentsCommand, "", NULL },
- { NULL, 0, false, NULL, "", NULL }
+ { "class", rbac::RBAC_PERM_COMMAND_LEARN_ALL_MY_CLASS, false, &HandleLearnAllMyClassCommand, "" },
+ { "pettalents", rbac::RBAC_PERM_COMMAND_LEARN_ALL_MY_PETTALENTS, false, &HandleLearnAllMyPetTalentsCommand, "" },
+ { "spells", rbac::RBAC_PERM_COMMAND_LEARN_ALL_MY_SPELLS, false, &HandleLearnAllMySpellsCommand, "" },
+ { "talents", rbac::RBAC_PERM_COMMAND_LEARN_ALL_MY_TALENTS, false, &HandleLearnAllMyTalentsCommand, "" },
};
- static ChatCommand learnAllCommandTable[] =
+ static std::vector<ChatCommand> learnAllCommandTable =
{
{ "my", rbac::RBAC_PERM_COMMAND_LEARN_ALL_MY, false, NULL, "", learnAllMyCommandTable },
- { "gm", rbac::RBAC_PERM_COMMAND_LEARN_ALL_GM, false, &HandleLearnAllGMCommand, "", NULL },
- { "crafts", rbac::RBAC_PERM_COMMAND_LEARN_ALL_CRAFTS, false, &HandleLearnAllCraftsCommand, "", NULL },
- { "default", rbac::RBAC_PERM_COMMAND_LEARN_ALL_DEFAULT, false, &HandleLearnAllDefaultCommand, "", NULL },
- { "lang", rbac::RBAC_PERM_COMMAND_LEARN_ALL_LANG, false, &HandleLearnAllLangCommand, "", NULL },
- { "recipes", rbac::RBAC_PERM_COMMAND_LEARN_ALL_RECIPES, false, &HandleLearnAllRecipesCommand, "", NULL },
- { NULL, 0, false, NULL, "", NULL }
+ { "gm", rbac::RBAC_PERM_COMMAND_LEARN_ALL_GM, false, &HandleLearnAllGMCommand, "" },
+ { "crafts", rbac::RBAC_PERM_COMMAND_LEARN_ALL_CRAFTS, false, &HandleLearnAllCraftsCommand, "" },
+ { "default", rbac::RBAC_PERM_COMMAND_LEARN_ALL_DEFAULT, false, &HandleLearnAllDefaultCommand, "" },
+ { "lang", rbac::RBAC_PERM_COMMAND_LEARN_ALL_LANG, false, &HandleLearnAllLangCommand, "" },
+ { "recipes", rbac::RBAC_PERM_COMMAND_LEARN_ALL_RECIPES, false, &HandleLearnAllRecipesCommand, "" },
};
- static ChatCommand learnCommandTable[] =
+ static std::vector<ChatCommand> learnCommandTable =
{
{ "all", rbac::RBAC_PERM_COMMAND_LEARN_ALL, false, NULL, "", learnAllCommandTable },
- { "", rbac::RBAC_PERM_COMMAND_LEARN, false, &HandleLearnCommand, "", NULL },
- { NULL, 0, false, NULL, "", NULL }
+ { "", rbac::RBAC_PERM_COMMAND_LEARN, false, &HandleLearnCommand, "" },
};
- static ChatCommand commandTable[] =
+ static std::vector<ChatCommand> commandTable =
{
{ "learn", rbac::RBAC_PERM_COMMAND_LEARN, false, NULL, "", learnCommandTable },
- { "unlearn", rbac::RBAC_PERM_COMMAND_UNLEARN, false, &HandleUnLearnCommand, "", NULL },
- { NULL, 0, false, NULL, "", NULL }
+ { "unlearn", rbac::RBAC_PERM_COMMAND_UNLEARN, false, &HandleUnLearnCommand, "" },
};
return commandTable;
}
diff --git a/src/server/scripts/Commands/cs_lfg.cpp b/src/server/scripts/Commands/cs_lfg.cpp
index 2de22714a15..9287d5553e3 100644
--- a/src/server/scripts/Commands/cs_lfg.cpp
+++ b/src/server/scripts/Commands/cs_lfg.cpp
@@ -43,22 +43,20 @@ class lfg_commandscript : public CommandScript
public:
lfg_commandscript() : CommandScript("lfg_commandscript") { }
- ChatCommand* GetCommands() const override
+ std::vector<ChatCommand> GetCommands() const override
{
- static ChatCommand lfgCommandTable[] =
+ static std::vector<ChatCommand> lfgCommandTable =
{
- { "player", rbac::RBAC_PERM_COMMAND_LFG_PLAYER, false, &HandleLfgPlayerInfoCommand, "", NULL },
- { "group", rbac::RBAC_PERM_COMMAND_LFG_GROUP, false, &HandleLfgGroupInfoCommand, "", NULL },
- { "queue", rbac::RBAC_PERM_COMMAND_LFG_QUEUE, true, &HandleLfgQueueInfoCommand, "", NULL },
- { "clean", rbac::RBAC_PERM_COMMAND_LFG_CLEAN, true, &HandleLfgCleanCommand, "", NULL },
- { "options", rbac::RBAC_PERM_COMMAND_LFG_OPTIONS, true, &HandleLfgOptionsCommand, "", NULL },
- { NULL, 0, false, NULL, "", NULL }
+ { "player", rbac::RBAC_PERM_COMMAND_LFG_PLAYER, false, &HandleLfgPlayerInfoCommand, "" },
+ { "group", rbac::RBAC_PERM_COMMAND_LFG_GROUP, false, &HandleLfgGroupInfoCommand, "" },
+ { "queue", rbac::RBAC_PERM_COMMAND_LFG_QUEUE, true, &HandleLfgQueueInfoCommand, "" },
+ { "clean", rbac::RBAC_PERM_COMMAND_LFG_CLEAN, true, &HandleLfgCleanCommand, "" },
+ { "options", rbac::RBAC_PERM_COMMAND_LFG_OPTIONS, true, &HandleLfgOptionsCommand, "" },
};
- static ChatCommand commandTable[] =
+ static std::vector<ChatCommand> commandTable =
{
{ "lfg", rbac::RBAC_PERM_COMMAND_LFG, true, NULL, "", lfgCommandTable },
- { NULL, 0, false, NULL, "", NULL }
};
return commandTable;
}
diff --git a/src/server/scripts/Commands/cs_list.cpp b/src/server/scripts/Commands/cs_list.cpp
index 0de62f805de..a1b79a69605 100644
--- a/src/server/scripts/Commands/cs_list.cpp
+++ b/src/server/scripts/Commands/cs_list.cpp
@@ -36,21 +36,19 @@ class list_commandscript : public CommandScript
public:
list_commandscript() : CommandScript("list_commandscript") { }
- ChatCommand* GetCommands() const override
+ std::vector<ChatCommand> GetCommands() const override
{
- static ChatCommand listCommandTable[] =
+ static std::vector<ChatCommand> listCommandTable =
{
- { "creature", rbac::RBAC_PERM_COMMAND_LIST_CREATURE, true, &HandleListCreatureCommand, "", NULL },
- { "item", rbac::RBAC_PERM_COMMAND_LIST_ITEM, true, &HandleListItemCommand, "", NULL },
- { "object", rbac::RBAC_PERM_COMMAND_LIST_OBJECT, true, &HandleListObjectCommand, "", NULL },
- { "auras", rbac::RBAC_PERM_COMMAND_LIST_AURAS, false, &HandleListAurasCommand, "", NULL },
- { "mail", rbac::RBAC_PERM_COMMAND_LIST_MAIL, true, &HandleListMailCommand, "", NULL },
- { NULL, 0, false, NULL, "", NULL }
+ { "creature", rbac::RBAC_PERM_COMMAND_LIST_CREATURE, true, &HandleListCreatureCommand, "" },
+ { "item", rbac::RBAC_PERM_COMMAND_LIST_ITEM, true, &HandleListItemCommand, "" },
+ { "object", rbac::RBAC_PERM_COMMAND_LIST_OBJECT, true, &HandleListObjectCommand, "" },
+ { "auras", rbac::RBAC_PERM_COMMAND_LIST_AURAS, false, &HandleListAurasCommand, "" },
+ { "mail", rbac::RBAC_PERM_COMMAND_LIST_MAIL, true, &HandleListMailCommand, "" },
};
- static ChatCommand commandTable[] =
+ static std::vector<ChatCommand> commandTable =
{
{ "list", rbac::RBAC_PERM_COMMAND_LIST,true, NULL, "", listCommandTable },
- { NULL, 0, false, NULL, "", NULL }
};
return commandTable;
}
diff --git a/src/server/scripts/Commands/cs_lookup.cpp b/src/server/scripts/Commands/cs_lookup.cpp
index cb2d467f8d7..ec35c5a7b62 100644
--- a/src/server/scripts/Commands/cs_lookup.cpp
+++ b/src/server/scripts/Commands/cs_lookup.cpp
@@ -37,47 +37,43 @@ class lookup_commandscript : public CommandScript
public:
lookup_commandscript() : CommandScript("lookup_commandscript") { }
- ChatCommand* GetCommands() const override
+ std::vector<ChatCommand> GetCommands() const override
{
- static ChatCommand lookupPlayerCommandTable[] =
+ static std::vector<ChatCommand> lookupPlayerCommandTable =
{
- { "ip", rbac::RBAC_PERM_COMMAND_LOOKUP_PLAYER_IP, true, &HandleLookupPlayerIpCommand, "", NULL },
- { "account", rbac::RBAC_PERM_COMMAND_LOOKUP_PLAYER_ACCOUNT, true, &HandleLookupPlayerAccountCommand, "", NULL },
- { "email", rbac::RBAC_PERM_COMMAND_LOOKUP_PLAYER_EMAIL, true, &HandleLookupPlayerEmailCommand, "", NULL },
- { NULL, 0, false, NULL, "", NULL }
+ { "ip", rbac::RBAC_PERM_COMMAND_LOOKUP_PLAYER_IP, true, &HandleLookupPlayerIpCommand, "" },
+ { "account", rbac::RBAC_PERM_COMMAND_LOOKUP_PLAYER_ACCOUNT, true, &HandleLookupPlayerAccountCommand, "" },
+ { "email", rbac::RBAC_PERM_COMMAND_LOOKUP_PLAYER_EMAIL, true, &HandleLookupPlayerEmailCommand, "" },
};
- static ChatCommand lookupSpellCommandTable[] =
+ static std::vector<ChatCommand> lookupSpellCommandTable =
{
- { "id", rbac::RBAC_PERM_COMMAND_LOOKUP_SPELL_ID, true, &HandleLookupSpellIdCommand, "", NULL },
- { "", rbac::RBAC_PERM_COMMAND_LOOKUP_SPELL, true, &HandleLookupSpellCommand, "", NULL },
- { NULL, 0, false, NULL, "", NULL }
+ { "id", rbac::RBAC_PERM_COMMAND_LOOKUP_SPELL_ID, true, &HandleLookupSpellIdCommand, "" },
+ { "", rbac::RBAC_PERM_COMMAND_LOOKUP_SPELL, true, &HandleLookupSpellCommand, "" },
};
- static ChatCommand lookupCommandTable[] =
+ static std::vector<ChatCommand> lookupCommandTable =
{
- { "area", rbac::RBAC_PERM_COMMAND_LOOKUP_AREA, true, &HandleLookupAreaCommand, "", NULL },
- { "creature", rbac::RBAC_PERM_COMMAND_LOOKUP_CREATURE, true, &HandleLookupCreatureCommand, "", NULL },
- { "event", rbac::RBAC_PERM_COMMAND_LOOKUP_EVENT, true, &HandleLookupEventCommand, "", NULL },
- { "faction", rbac::RBAC_PERM_COMMAND_LOOKUP_FACTION, true, &HandleLookupFactionCommand, "", NULL },
- { "item", rbac::RBAC_PERM_COMMAND_LOOKUP_ITEM, true, &HandleLookupItemCommand, "", NULL },
- { "itemset", rbac::RBAC_PERM_COMMAND_LOOKUP_ITEMSET, true, &HandleLookupItemSetCommand, "", NULL },
- { "object", rbac::RBAC_PERM_COMMAND_LOOKUP_OBJECT, true, &HandleLookupObjectCommand, "", NULL },
- { "quest", rbac::RBAC_PERM_COMMAND_LOOKUP_QUEST, true, &HandleLookupQuestCommand, "", NULL },
+ { "area", rbac::RBAC_PERM_COMMAND_LOOKUP_AREA, true, &HandleLookupAreaCommand, "" },
+ { "creature", rbac::RBAC_PERM_COMMAND_LOOKUP_CREATURE, true, &HandleLookupCreatureCommand, "" },
+ { "event", rbac::RBAC_PERM_COMMAND_LOOKUP_EVENT, true, &HandleLookupEventCommand, "" },
+ { "faction", rbac::RBAC_PERM_COMMAND_LOOKUP_FACTION, true, &HandleLookupFactionCommand, "" },
+ { "item", rbac::RBAC_PERM_COMMAND_LOOKUP_ITEM, true, &HandleLookupItemCommand, "" },
+ { "itemset", rbac::RBAC_PERM_COMMAND_LOOKUP_ITEMSET, true, &HandleLookupItemSetCommand, "" },
+ { "object", rbac::RBAC_PERM_COMMAND_LOOKUP_OBJECT, true, &HandleLookupObjectCommand, "" },
+ { "quest", rbac::RBAC_PERM_COMMAND_LOOKUP_QUEST, true, &HandleLookupQuestCommand, "" },
{ "player", rbac::RBAC_PERM_COMMAND_LOOKUP_PLAYER, true, NULL, "", lookupPlayerCommandTable },
- { "skill", rbac::RBAC_PERM_COMMAND_LOOKUP_SKILL, true, &HandleLookupSkillCommand, "", NULL },
+ { "skill", rbac::RBAC_PERM_COMMAND_LOOKUP_SKILL, true, &HandleLookupSkillCommand, "" },
{ "spell", rbac::RBAC_PERM_COMMAND_LOOKUP_SPELL, true, NULL, "", lookupSpellCommandTable },
- { "taxinode", rbac::RBAC_PERM_COMMAND_LOOKUP_TAXINODE, true, &HandleLookupTaxiNodeCommand, "", NULL },
- { "tele", rbac::RBAC_PERM_COMMAND_LOOKUP_TELE, true, &HandleLookupTeleCommand, "", NULL },
- { "title", rbac::RBAC_PERM_COMMAND_LOOKUP_TITLE, true, &HandleLookupTitleCommand, "", NULL },
- { "map", rbac::RBAC_PERM_COMMAND_LOOKUP_MAP, true, &HandleLookupMapCommand, "", NULL },
- { NULL, 0, false, NULL, "", NULL }
+ { "taxinode", rbac::RBAC_PERM_COMMAND_LOOKUP_TAXINODE, true, &HandleLookupTaxiNodeCommand, "" },
+ { "tele", rbac::RBAC_PERM_COMMAND_LOOKUP_TELE, true, &HandleLookupTeleCommand, "" },
+ { "title", rbac::RBAC_PERM_COMMAND_LOOKUP_TITLE, true, &HandleLookupTitleCommand, "" },
+ { "map", rbac::RBAC_PERM_COMMAND_LOOKUP_MAP, true, &HandleLookupMapCommand, "" },
};
- static ChatCommand commandTable[] =
+ static std::vector<ChatCommand> commandTable =
{
{ "lookup", rbac::RBAC_PERM_COMMAND_LOOKUP, true, NULL, "", lookupCommandTable },
- { NULL, 0, false, NULL, "", NULL }
};
return commandTable;
}
diff --git a/src/server/scripts/Commands/cs_message.cpp b/src/server/scripts/Commands/cs_message.cpp
index 922958f7222..f3c1f4d7df8 100644
--- a/src/server/scripts/Commands/cs_message.cpp
+++ b/src/server/scripts/Commands/cs_message.cpp
@@ -34,29 +34,26 @@ class message_commandscript : public CommandScript
public:
message_commandscript() : CommandScript("message_commandscript") { }
- ChatCommand* GetCommands() const override
+ std::vector<ChatCommand> GetCommands() const override
{
- static ChatCommand channelSetCommandTable[] =
+ static std::vector<ChatCommand> channelSetCommandTable =
{
- { "ownership", rbac::RBAC_PERM_COMMAND_CHANNEL_SET_OWNERSHIP, false, &HandleChannelSetOwnership, "", NULL },
- { NULL, 0, false, NULL, "", NULL }
+ { "ownership", rbac::RBAC_PERM_COMMAND_CHANNEL_SET_OWNERSHIP, false, &HandleChannelSetOwnership, "" },
};
- static ChatCommand channelCommandTable[] =
+ static std::vector<ChatCommand> channelCommandTable =
{
{ "set", rbac::RBAC_PERM_COMMAND_CHANNEL_SET, true, NULL, "", channelSetCommandTable },
- { NULL, 0, false, NULL, "", NULL }
};
- static ChatCommand commandTable[] =
+ static std::vector<ChatCommand> commandTable =
{
{ "channel", rbac::RBAC_PERM_COMMAND_CHANNEL, true, NULL, "", channelCommandTable },
- { "nameannounce", rbac::RBAC_PERM_COMMAND_NAMEANNOUNCE, true, &HandleNameAnnounceCommand, "", NULL },
- { "gmnameannounce", rbac::RBAC_PERM_COMMAND_GMNAMEANNOUNCE, true, &HandleGMNameAnnounceCommand, "", NULL },
- { "announce", rbac::RBAC_PERM_COMMAND_ANNOUNCE, true, &HandleAnnounceCommand, "", NULL },
- { "gmannounce", rbac::RBAC_PERM_COMMAND_GMANNOUNCE, true, &HandleGMAnnounceCommand, "", NULL },
- { "notify", rbac::RBAC_PERM_COMMAND_NOTIFY, true, &HandleNotifyCommand, "", NULL },
- { "gmnotify", rbac::RBAC_PERM_COMMAND_GMNOTIFY, true, &HandleGMNotifyCommand, "", NULL },
- { "whispers", rbac::RBAC_PERM_COMMAND_WHISPERS, false, &HandleWhispersCommand, "", NULL },
- { NULL, 0, false, NULL, "", NULL }
+ { "nameannounce", rbac::RBAC_PERM_COMMAND_NAMEANNOUNCE, true, &HandleNameAnnounceCommand, "" },
+ { "gmnameannounce", rbac::RBAC_PERM_COMMAND_GMNAMEANNOUNCE, true, &HandleGMNameAnnounceCommand, "" },
+ { "announce", rbac::RBAC_PERM_COMMAND_ANNOUNCE, true, &HandleAnnounceCommand, "" },
+ { "gmannounce", rbac::RBAC_PERM_COMMAND_GMANNOUNCE, true, &HandleGMAnnounceCommand, "" },
+ { "notify", rbac::RBAC_PERM_COMMAND_NOTIFY, true, &HandleNotifyCommand, "" },
+ { "gmnotify", rbac::RBAC_PERM_COMMAND_GMNOTIFY, true, &HandleGMNotifyCommand, "" },
+ { "whispers", rbac::RBAC_PERM_COMMAND_WHISPERS, false, &HandleWhispersCommand, "" },
};
return commandTable;
}
diff --git a/src/server/scripts/Commands/cs_misc.cpp b/src/server/scripts/Commands/cs_misc.cpp
index 725fdd4c27d..b81d6152c03 100644
--- a/src/server/scripts/Commands/cs_misc.cpp
+++ b/src/server/scripts/Commands/cs_misc.cpp
@@ -42,62 +42,61 @@ class misc_commandscript : public CommandScript
public:
misc_commandscript() : CommandScript("misc_commandscript") { }
- ChatCommand* GetCommands() const override
+ std::vector<ChatCommand> GetCommands() const override
{
- static ChatCommand commandTable[] =
- {
- { "additem", rbac::RBAC_PERM_COMMAND_ADDITEM, false, &HandleAddItemCommand, "", NULL },
- { "additemset", rbac::RBAC_PERM_COMMAND_ADDITEMSET, false, &HandleAddItemSetCommand, "", NULL },
- { "appear", rbac::RBAC_PERM_COMMAND_APPEAR, false, &HandleAppearCommand, "", NULL },
- { "aura", rbac::RBAC_PERM_COMMAND_AURA, false, &HandleAuraCommand, "", NULL },
- { "bank", rbac::RBAC_PERM_COMMAND_BANK, false, &HandleBankCommand, "", NULL },
- { "bindsight", rbac::RBAC_PERM_COMMAND_BINDSIGHT, false, &HandleBindSightCommand, "", NULL },
- { "combatstop", rbac::RBAC_PERM_COMMAND_COMBATSTOP, true, &HandleCombatStopCommand, "", NULL },
- { "cometome", rbac::RBAC_PERM_COMMAND_COMETOME, false, &HandleComeToMeCommand, "", NULL },
- { "commands", rbac::RBAC_PERM_COMMAND_COMMANDS, true, &HandleCommandsCommand, "", NULL },
- { "cooldown", rbac::RBAC_PERM_COMMAND_COOLDOWN, false, &HandleCooldownCommand, "", NULL },
- { "damage", rbac::RBAC_PERM_COMMAND_DAMAGE, false, &HandleDamageCommand, "", NULL },
- { "dev", rbac::RBAC_PERM_COMMAND_DEV, false, &HandleDevCommand, "", NULL },
- { "die", rbac::RBAC_PERM_COMMAND_DIE, false, &HandleDieCommand, "", NULL },
- { "dismount", rbac::RBAC_PERM_COMMAND_DISMOUNT, false, &HandleDismountCommand, "", NULL },
- { "distance", rbac::RBAC_PERM_COMMAND_DISTANCE, false, &HandleGetDistanceCommand, "", NULL },
- { "flusharenapoints", rbac::RBAC_PERM_COMMAND_FLUSHARENAPOINTS, false, &HandleFlushArenaPointsCommand, "", NULL },
- { "freeze", rbac::RBAC_PERM_COMMAND_FREEZE, false, &HandleFreezeCommand, "", NULL },
- { "gps", rbac::RBAC_PERM_COMMAND_GPS, false, &HandleGPSCommand, "", NULL },
- { "guid", rbac::RBAC_PERM_COMMAND_GUID, false, &HandleGUIDCommand, "", NULL },
- { "help", rbac::RBAC_PERM_COMMAND_HELP, true, &HandleHelpCommand, "", NULL },
- { "hidearea", rbac::RBAC_PERM_COMMAND_HIDEAREA, false, &HandleHideAreaCommand, "", NULL },
- { "itemmove", rbac::RBAC_PERM_COMMAND_ITEMMOVE, false, &HandleItemMoveCommand, "", NULL },
- { "kick", rbac::RBAC_PERM_COMMAND_KICK, true, &HandleKickPlayerCommand, "", NULL },
- { "linkgrave", rbac::RBAC_PERM_COMMAND_LINKGRAVE, false, &HandleLinkGraveCommand, "", NULL },
- { "listfreeze", rbac::RBAC_PERM_COMMAND_LISTFREEZE, false, &HandleListFreezeCommand, "", NULL },
- { "maxskill", rbac::RBAC_PERM_COMMAND_MAXSKILL, false, &HandleMaxSkillCommand, "", NULL },
- { "movegens", rbac::RBAC_PERM_COMMAND_MOVEGENS, false, &HandleMovegensCommand, "", NULL },
- { "mute", rbac::RBAC_PERM_COMMAND_MUTE, true, &HandleMuteCommand, "", NULL },
- { "mutehistory", rbac::RBAC_PERM_COMMAND_MUTEHISTORY, true, &HandleMuteInfoCommand, "", NULL },
- { "neargrave", rbac::RBAC_PERM_COMMAND_NEARGRAVE, false, &HandleNearGraveCommand, "", NULL },
- { "pinfo", rbac::RBAC_PERM_COMMAND_PINFO, true, &HandlePInfoCommand, "", NULL },
- { "playall", rbac::RBAC_PERM_COMMAND_PLAYALL, false, &HandlePlayAllCommand, "", NULL },
- { "possess", rbac::RBAC_PERM_COMMAND_POSSESS, false, &HandlePossessCommand, "", NULL },
- { "pvpstats", rbac::RBAC_PERM_COMMAND_PVPSTATS, true, &HandlePvPstatsCommand, "", NULL },
- { "recall", rbac::RBAC_PERM_COMMAND_RECALL, false, &HandleRecallCommand, "", NULL },
- { "repairitems", rbac::RBAC_PERM_COMMAND_REPAIRITEMS, true, &HandleRepairitemsCommand, "", NULL },
- { "respawn", rbac::RBAC_PERM_COMMAND_RESPAWN, false, &HandleRespawnCommand, "", NULL },
- { "revive", rbac::RBAC_PERM_COMMAND_REVIVE, true, &HandleReviveCommand, "", NULL },
- { "saveall", rbac::RBAC_PERM_COMMAND_SAVEALL, true, &HandleSaveAllCommand, "", NULL },
- { "save", rbac::RBAC_PERM_COMMAND_SAVE, false, &HandleSaveCommand, "", NULL },
- { "setskill", rbac::RBAC_PERM_COMMAND_SETSKILL, false, &HandleSetSkillCommand, "", NULL },
- { "showarea", rbac::RBAC_PERM_COMMAND_SHOWAREA, false, &HandleShowAreaCommand, "", NULL },
- { "summon", rbac::RBAC_PERM_COMMAND_SUMMON, false, &HandleSummonCommand, "", NULL },
- { "unaura", rbac::RBAC_PERM_COMMAND_UNAURA, false, &HandleUnAuraCommand, "", NULL },
- { "unbindsight", rbac::RBAC_PERM_COMMAND_UNBINDSIGHT, false, HandleUnbindSightCommand, "", NULL },
- { "unfreeze", rbac::RBAC_PERM_COMMAND_UNFREEZE, false, &HandleUnFreezeCommand, "", NULL },
- { "unmute", rbac::RBAC_PERM_COMMAND_UNMUTE, true, &HandleUnmuteCommand, "", NULL },
- { "unpossess", rbac::RBAC_PERM_COMMAND_UNPOSSESS, false, &HandleUnPossessCommand, "", NULL },
- { "unstuck", rbac::RBAC_PERM_COMMAND_UNSTUCK, true, &HandleUnstuckCommand, "", NULL },
- { "wchange", rbac::RBAC_PERM_COMMAND_WCHANGE, false, &HandleChangeWeather, "", NULL },
- { "mailbox", rbac::RBAC_PERM_COMMAND_MAILBOX, false, &HandleMailBoxCommand, "", NULL },
- { NULL, 0, false, NULL, "", NULL }
+ static std::vector<ChatCommand> commandTable =
+ {
+ { "additem", rbac::RBAC_PERM_COMMAND_ADDITEM, false, &HandleAddItemCommand, "" },
+ { "additemset", rbac::RBAC_PERM_COMMAND_ADDITEMSET, false, &HandleAddItemSetCommand, "" },
+ { "appear", rbac::RBAC_PERM_COMMAND_APPEAR, false, &HandleAppearCommand, "" },
+ { "aura", rbac::RBAC_PERM_COMMAND_AURA, false, &HandleAuraCommand, "" },
+ { "bank", rbac::RBAC_PERM_COMMAND_BANK, false, &HandleBankCommand, "" },
+ { "bindsight", rbac::RBAC_PERM_COMMAND_BINDSIGHT, false, &HandleBindSightCommand, "" },
+ { "combatstop", rbac::RBAC_PERM_COMMAND_COMBATSTOP, true, &HandleCombatStopCommand, "" },
+ { "cometome", rbac::RBAC_PERM_COMMAND_COMETOME, false, &HandleComeToMeCommand, "" },
+ { "commands", rbac::RBAC_PERM_COMMAND_COMMANDS, true, &HandleCommandsCommand, "" },
+ { "cooldown", rbac::RBAC_PERM_COMMAND_COOLDOWN, false, &HandleCooldownCommand, "" },
+ { "damage", rbac::RBAC_PERM_COMMAND_DAMAGE, false, &HandleDamageCommand, "" },
+ { "dev", rbac::RBAC_PERM_COMMAND_DEV, false, &HandleDevCommand, "" },
+ { "die", rbac::RBAC_PERM_COMMAND_DIE, false, &HandleDieCommand, "" },
+ { "dismount", rbac::RBAC_PERM_COMMAND_DISMOUNT, false, &HandleDismountCommand, "" },
+ { "distance", rbac::RBAC_PERM_COMMAND_DISTANCE, false, &HandleGetDistanceCommand, "" },
+ { "flusharenapoints", rbac::RBAC_PERM_COMMAND_FLUSHARENAPOINTS, false, &HandleFlushArenaPointsCommand, "" },
+ { "freeze", rbac::RBAC_PERM_COMMAND_FREEZE, false, &HandleFreezeCommand, "" },
+ { "gps", rbac::RBAC_PERM_COMMAND_GPS, false, &HandleGPSCommand, "" },
+ { "guid", rbac::RBAC_PERM_COMMAND_GUID, false, &HandleGUIDCommand, "" },
+ { "help", rbac::RBAC_PERM_COMMAND_HELP, true, &HandleHelpCommand, "" },
+ { "hidearea", rbac::RBAC_PERM_COMMAND_HIDEAREA, false, &HandleHideAreaCommand, "" },
+ { "itemmove", rbac::RBAC_PERM_COMMAND_ITEMMOVE, false, &HandleItemMoveCommand, "" },
+ { "kick", rbac::RBAC_PERM_COMMAND_KICK, true, &HandleKickPlayerCommand, "" },
+ { "linkgrave", rbac::RBAC_PERM_COMMAND_LINKGRAVE, false, &HandleLinkGraveCommand, "" },
+ { "listfreeze", rbac::RBAC_PERM_COMMAND_LISTFREEZE, false, &HandleListFreezeCommand, "" },
+ { "maxskill", rbac::RBAC_PERM_COMMAND_MAXSKILL, false, &HandleMaxSkillCommand, "" },
+ { "movegens", rbac::RBAC_PERM_COMMAND_MOVEGENS, false, &HandleMovegensCommand, "" },
+ { "mute", rbac::RBAC_PERM_COMMAND_MUTE, true, &HandleMuteCommand, "" },
+ { "mutehistory", rbac::RBAC_PERM_COMMAND_MUTEHISTORY, true, &HandleMuteInfoCommand, "" },
+ { "neargrave", rbac::RBAC_PERM_COMMAND_NEARGRAVE, false, &HandleNearGraveCommand, "" },
+ { "pinfo", rbac::RBAC_PERM_COMMAND_PINFO, true, &HandlePInfoCommand, "" },
+ { "playall", rbac::RBAC_PERM_COMMAND_PLAYALL, false, &HandlePlayAllCommand, "" },
+ { "possess", rbac::RBAC_PERM_COMMAND_POSSESS, false, &HandlePossessCommand, "" },
+ { "pvpstats", rbac::RBAC_PERM_COMMAND_PVPSTATS, true, &HandlePvPstatsCommand, "" },
+ { "recall", rbac::RBAC_PERM_COMMAND_RECALL, false, &HandleRecallCommand, "" },
+ { "repairitems", rbac::RBAC_PERM_COMMAND_REPAIRITEMS, true, &HandleRepairitemsCommand, "" },
+ { "respawn", rbac::RBAC_PERM_COMMAND_RESPAWN, false, &HandleRespawnCommand, "" },
+ { "revive", rbac::RBAC_PERM_COMMAND_REVIVE, true, &HandleReviveCommand, "" },
+ { "saveall", rbac::RBAC_PERM_COMMAND_SAVEALL, true, &HandleSaveAllCommand, "" },
+ { "save", rbac::RBAC_PERM_COMMAND_SAVE, false, &HandleSaveCommand, "" },
+ { "setskill", rbac::RBAC_PERM_COMMAND_SETSKILL, false, &HandleSetSkillCommand, "" },
+ { "showarea", rbac::RBAC_PERM_COMMAND_SHOWAREA, false, &HandleShowAreaCommand, "" },
+ { "summon", rbac::RBAC_PERM_COMMAND_SUMMON, false, &HandleSummonCommand, "" },
+ { "unaura", rbac::RBAC_PERM_COMMAND_UNAURA, false, &HandleUnAuraCommand, "" },
+ { "unbindsight", rbac::RBAC_PERM_COMMAND_UNBINDSIGHT, false, HandleUnbindSightCommand, "" },
+ { "unfreeze", rbac::RBAC_PERM_COMMAND_UNFREEZE, false, &HandleUnFreezeCommand, "" },
+ { "unmute", rbac::RBAC_PERM_COMMAND_UNMUTE, true, &HandleUnmuteCommand, "" },
+ { "unpossess", rbac::RBAC_PERM_COMMAND_UNPOSSESS, false, &HandleUnPossessCommand, "" },
+ { "unstuck", rbac::RBAC_PERM_COMMAND_UNSTUCK, true, &HandleUnstuckCommand, "" },
+ { "wchange", rbac::RBAC_PERM_COMMAND_WCHANGE, false, &HandleChangeWeather, "" },
+ { "mailbox", rbac::RBAC_PERM_COMMAND_MAILBOX, false, &HandleMailBoxCommand, "" },
};
return commandTable;
}
@@ -1774,21 +1773,13 @@ public:
PreparedQueryResult result6 = CharacterDatabase.Query(stmt4);
if (result6)
{
- // Define the variables, so the compiler knows they exist
- uint32 rmailint = 0;
-
- // Fetch the fields - readmail is a SUM(x) and given out as char! Thus...
- // ... while totalmail is a COUNT(x), which is given out as INt64, which we just convert on fetch...
Field* fields = result6->Fetch();
- std::string readmail = fields[0].GetString();
+ uint32 readmail = uint32(fields[0].GetDouble());
uint32 totalmail = uint32(fields[1].GetUInt64());
- // ... we have to convert it from Char to int. We can use totalmail as it is
- rmailint = atoul(readmail.c_str());
-
// Output XXI. LANG_INFO_CHR_MAILS if at least one mail is given
if (totalmail >= 1)
- handler->PSendSysMessage(LANG_PINFO_CHR_MAILS, rmailint, totalmail);
+ handler->PSendSysMessage(LANG_PINFO_CHR_MAILS, readmail, totalmail);
}
return true;
diff --git a/src/server/scripts/Commands/cs_mmaps.cpp b/src/server/scripts/Commands/cs_mmaps.cpp
index e06159a6748..479c34dd90c 100644
--- a/src/server/scripts/Commands/cs_mmaps.cpp
+++ b/src/server/scripts/Commands/cs_mmaps.cpp
@@ -42,22 +42,20 @@ class mmaps_commandscript : public CommandScript
public:
mmaps_commandscript() : CommandScript("mmaps_commandscript") { }
- ChatCommand* GetCommands() const override
+ std::vector<ChatCommand> GetCommands() const override
{
- static ChatCommand mmapCommandTable[] =
+ static std::vector<ChatCommand> mmapCommandTable =
{
- { "loadedtiles", rbac::RBAC_PERM_COMMAND_MMAP_LOADEDTILES, false, &HandleMmapLoadedTilesCommand, "", NULL },
- { "loc", rbac::RBAC_PERM_COMMAND_MMAP_LOC, false, &HandleMmapLocCommand, "", NULL },
- { "path", rbac::RBAC_PERM_COMMAND_MMAP_PATH, false, &HandleMmapPathCommand, "", NULL },
- { "stats", rbac::RBAC_PERM_COMMAND_MMAP_STATS, false, &HandleMmapStatsCommand, "", NULL },
- { "testarea", rbac::RBAC_PERM_COMMAND_MMAP_TESTAREA, false, &HandleMmapTestArea, "", NULL },
- { NULL, 0, false, NULL, "", NULL }
+ { "loadedtiles", rbac::RBAC_PERM_COMMAND_MMAP_LOADEDTILES, false, &HandleMmapLoadedTilesCommand, "" },
+ { "loc", rbac::RBAC_PERM_COMMAND_MMAP_LOC, false, &HandleMmapLocCommand, "" },
+ { "path", rbac::RBAC_PERM_COMMAND_MMAP_PATH, false, &HandleMmapPathCommand, "" },
+ { "stats", rbac::RBAC_PERM_COMMAND_MMAP_STATS, false, &HandleMmapStatsCommand, "" },
+ { "testarea", rbac::RBAC_PERM_COMMAND_MMAP_TESTAREA, false, &HandleMmapTestArea, "" },
};
- static ChatCommand commandTable[] =
+ static std::vector<ChatCommand> commandTable =
{
- { "mmap", rbac::RBAC_PERM_COMMAND_MMAP, true, NULL, "", mmapCommandTable },
- { NULL, 0, false, NULL, "", NULL }
+ { "mmap", rbac::RBAC_PERM_COMMAND_MMAP, true, NULL, "", mmapCommandTable },
};
return commandTable;
}
diff --git a/src/server/scripts/Commands/cs_modify.cpp b/src/server/scripts/Commands/cs_modify.cpp
index bf82b81a8b7..a3eed4dfd5d 100644
--- a/src/server/scripts/Commands/cs_modify.cpp
+++ b/src/server/scripts/Commands/cs_modify.cpp
@@ -36,49 +36,46 @@ class modify_commandscript : public CommandScript
public:
modify_commandscript() : CommandScript("modify_commandscript") { }
- ChatCommand* GetCommands() const override
+ std::vector<ChatCommand> GetCommands() const override
{
- static ChatCommand modifyspeedCommandTable[] =
+ static std::vector<ChatCommand> modifyspeedCommandTable =
{
- { "all", rbac::RBAC_PERM_COMMAND_MODIFY_SPEED_ALL, false, &HandleModifyASpeedCommand, "", NULL },
- { "backwalk", rbac::RBAC_PERM_COMMAND_MODIFY_SPEED_BACKWALK, false, &HandleModifyBWalkCommand, "", NULL },
- { "fly", rbac::RBAC_PERM_COMMAND_MODIFY_SPEED_FLY, false, &HandleModifyFlyCommand, "", NULL },
- { "walk", rbac::RBAC_PERM_COMMAND_MODIFY_SPEED_WALK, false, &HandleModifySpeedCommand, "", NULL },
- { "swim", rbac::RBAC_PERM_COMMAND_MODIFY_SPEED_SWIM, false, &HandleModifySwimCommand, "", NULL },
- { "", rbac::RBAC_PERM_COMMAND_MODIFY_SPEED, false, &HandleModifyASpeedCommand, "", NULL },
- { NULL, 0, false, NULL, "", NULL }
+ { "all", rbac::RBAC_PERM_COMMAND_MODIFY_SPEED_ALL, false, &HandleModifyASpeedCommand, "" },
+ { "backwalk", rbac::RBAC_PERM_COMMAND_MODIFY_SPEED_BACKWALK, false, &HandleModifyBWalkCommand, "" },
+ { "fly", rbac::RBAC_PERM_COMMAND_MODIFY_SPEED_FLY, false, &HandleModifyFlyCommand, "" },
+ { "walk", rbac::RBAC_PERM_COMMAND_MODIFY_SPEED_WALK, false, &HandleModifySpeedCommand, "" },
+ { "swim", rbac::RBAC_PERM_COMMAND_MODIFY_SPEED_SWIM, false, &HandleModifySwimCommand, "" },
+ { "", rbac::RBAC_PERM_COMMAND_MODIFY_SPEED, false, &HandleModifyASpeedCommand, "" },
};
- static ChatCommand modifyCommandTable[] =
+ static std::vector<ChatCommand> modifyCommandTable =
{
- { "arenapoints", rbac::RBAC_PERM_COMMAND_MODIFY_ARENAPOINTS, false, &HandleModifyArenaCommand, "", NULL },
- { "bit", rbac::RBAC_PERM_COMMAND_MODIFY_BIT, false, &HandleModifyBitCommand, "", NULL },
- { "drunk", rbac::RBAC_PERM_COMMAND_MODIFY_DRUNK, false, &HandleModifyDrunkCommand, "", NULL },
- { "energy", rbac::RBAC_PERM_COMMAND_MODIFY_ENERGY, false, &HandleModifyEnergyCommand, "", NULL },
- { "faction", rbac::RBAC_PERM_COMMAND_MODIFY_FACTION, false, &HandleModifyFactionCommand, "", NULL },
- { "gender", rbac::RBAC_PERM_COMMAND_MODIFY_GENDER, false, &HandleModifyGenderCommand, "", NULL },
- { "honor", rbac::RBAC_PERM_COMMAND_MODIFY_HONOR, false, &HandleModifyHonorCommand, "", NULL },
- { "hp", rbac::RBAC_PERM_COMMAND_MODIFY_HP, false, &HandleModifyHPCommand, "", NULL },
- { "mana", rbac::RBAC_PERM_COMMAND_MODIFY_MANA, false, &HandleModifyManaCommand, "", NULL },
- { "money", rbac::RBAC_PERM_COMMAND_MODIFY_MONEY, false, &HandleModifyMoneyCommand, "", NULL },
- { "mount", rbac::RBAC_PERM_COMMAND_MODIFY_MOUNT, false, &HandleModifyMountCommand, "", NULL },
- { "phase", rbac::RBAC_PERM_COMMAND_MODIFY_PHASE, false, &HandleModifyPhaseCommand, "", NULL },
- { "rage", rbac::RBAC_PERM_COMMAND_MODIFY_RAGE, false, &HandleModifyRageCommand, "", NULL },
- { "reputation", rbac::RBAC_PERM_COMMAND_MODIFY_REPUTATION, false, &HandleModifyRepCommand, "", NULL },
- { "runicpower", rbac::RBAC_PERM_COMMAND_MODIFY_RUNICPOWER, false, &HandleModifyRunicPowerCommand, "", NULL },
- { "scale", rbac::RBAC_PERM_COMMAND_MODIFY_SCALE, false, &HandleModifyScaleCommand, "", NULL },
+ { "arenapoints", rbac::RBAC_PERM_COMMAND_MODIFY_ARENAPOINTS, false, &HandleModifyArenaCommand, "" },
+ { "bit", rbac::RBAC_PERM_COMMAND_MODIFY_BIT, false, &HandleModifyBitCommand, "" },
+ { "drunk", rbac::RBAC_PERM_COMMAND_MODIFY_DRUNK, false, &HandleModifyDrunkCommand, "" },
+ { "energy", rbac::RBAC_PERM_COMMAND_MODIFY_ENERGY, false, &HandleModifyEnergyCommand, "" },
+ { "faction", rbac::RBAC_PERM_COMMAND_MODIFY_FACTION, false, &HandleModifyFactionCommand, "" },
+ { "gender", rbac::RBAC_PERM_COMMAND_MODIFY_GENDER, false, &HandleModifyGenderCommand, "" },
+ { "honor", rbac::RBAC_PERM_COMMAND_MODIFY_HONOR, false, &HandleModifyHonorCommand, "" },
+ { "hp", rbac::RBAC_PERM_COMMAND_MODIFY_HP, false, &HandleModifyHPCommand, "" },
+ { "mana", rbac::RBAC_PERM_COMMAND_MODIFY_MANA, false, &HandleModifyManaCommand, "" },
+ { "money", rbac::RBAC_PERM_COMMAND_MODIFY_MONEY, false, &HandleModifyMoneyCommand, "" },
+ { "mount", rbac::RBAC_PERM_COMMAND_MODIFY_MOUNT, false, &HandleModifyMountCommand, "" },
+ { "phase", rbac::RBAC_PERM_COMMAND_MODIFY_PHASE, false, &HandleModifyPhaseCommand, "" },
+ { "rage", rbac::RBAC_PERM_COMMAND_MODIFY_RAGE, false, &HandleModifyRageCommand, "" },
+ { "reputation", rbac::RBAC_PERM_COMMAND_MODIFY_REPUTATION, false, &HandleModifyRepCommand, "" },
+ { "runicpower", rbac::RBAC_PERM_COMMAND_MODIFY_RUNICPOWER, false, &HandleModifyRunicPowerCommand, "" },
+ { "scale", rbac::RBAC_PERM_COMMAND_MODIFY_SCALE, false, &HandleModifyScaleCommand, "" },
{ "speed", rbac::RBAC_PERM_COMMAND_MODIFY_SPEED, false, NULL, "", modifyspeedCommandTable },
- { "spell", rbac::RBAC_PERM_COMMAND_MODIFY_SPELL, false, &HandleModifySpellCommand, "", NULL },
- { "standstate", rbac::RBAC_PERM_COMMAND_MODIFY_STANDSTATE, false, &HandleModifyStandStateCommand, "", NULL },
- { "talentpoints", rbac::RBAC_PERM_COMMAND_MODIFY_TALENTPOINTS, false, &HandleModifyTalentCommand, "", NULL },
- { "xp", rbac::RBAC_PERM_COMMAND_MODIFY_XP, false, &HandleModifyXPCommand, "", NULL },
- { NULL, 0, false, NULL, "", NULL }
+ { "spell", rbac::RBAC_PERM_COMMAND_MODIFY_SPELL, false, &HandleModifySpellCommand, "" },
+ { "standstate", rbac::RBAC_PERM_COMMAND_MODIFY_STANDSTATE, false, &HandleModifyStandStateCommand, "" },
+ { "talentpoints", rbac::RBAC_PERM_COMMAND_MODIFY_TALENTPOINTS, false, &HandleModifyTalentCommand, "" },
+ { "xp", rbac::RBAC_PERM_COMMAND_MODIFY_XP, false, &HandleModifyXPCommand, "" },
};
- static ChatCommand commandTable[] =
+ static std::vector<ChatCommand> commandTable =
{
- { "morph", rbac::RBAC_PERM_COMMAND_MORPH, false, &HandleModifyMorphCommand, "", NULL },
- { "demorph", rbac::RBAC_PERM_COMMAND_DEMORPH, false, &HandleDeMorphCommand, "", NULL },
+ { "morph", rbac::RBAC_PERM_COMMAND_MORPH, false, &HandleModifyMorphCommand, "" },
+ { "demorph", rbac::RBAC_PERM_COMMAND_DEMORPH, false, &HandleDeMorphCommand, "" },
{ "modify", rbac::RBAC_PERM_COMMAND_MODIFY, false, NULL, "", modifyCommandTable },
- { NULL, 0, false, NULL, "", NULL }
};
return commandTable;
}
diff --git a/src/server/scripts/Commands/cs_npc.cpp b/src/server/scripts/Commands/cs_npc.cpp
index 8e7a1387a32..99c10b074a0 100644
--- a/src/server/scripts/Commands/cs_npc.cpp
+++ b/src/server/scripts/Commands/cs_npc.cpp
@@ -170,69 +170,61 @@ class npc_commandscript : public CommandScript
public:
npc_commandscript() : CommandScript("npc_commandscript") { }
- ChatCommand* GetCommands() const override
+ std::vector<ChatCommand> GetCommands() const override
{
- static ChatCommand npcAddCommandTable[] =
- {
- { "formation", rbac::RBAC_PERM_COMMAND_NPC_ADD_FORMATION, false, &HandleNpcAddFormationCommand, "", NULL },
- { "item", rbac::RBAC_PERM_COMMAND_NPC_ADD_ITEM, false, &HandleNpcAddVendorItemCommand, "", NULL },
- { "move", rbac::RBAC_PERM_COMMAND_NPC_ADD_MOVE, false, &HandleNpcAddMoveCommand, "", NULL },
- { "temp", rbac::RBAC_PERM_COMMAND_NPC_ADD_TEMP, false, &HandleNpcAddTempSpawnCommand, "", NULL },
- //{ "weapon", rbac::RBAC_PERM_COMMAND_NPC_ADD_WEAPON, false, &HandleNpcAddWeaponCommand, "", NULL },
- { "", rbac::RBAC_PERM_COMMAND_NPC_ADD, false, &HandleNpcAddCommand, "", NULL },
- { NULL, 0, false, NULL, "", NULL }
+ static std::vector<ChatCommand> npcAddCommandTable =
+ {
+ { "formation", rbac::RBAC_PERM_COMMAND_NPC_ADD_FORMATION, false, &HandleNpcAddFormationCommand, "" },
+ { "item", rbac::RBAC_PERM_COMMAND_NPC_ADD_ITEM, false, &HandleNpcAddVendorItemCommand, "" },
+ { "move", rbac::RBAC_PERM_COMMAND_NPC_ADD_MOVE, false, &HandleNpcAddMoveCommand, "" },
+ { "temp", rbac::RBAC_PERM_COMMAND_NPC_ADD_TEMP, false, &HandleNpcAddTempSpawnCommand, "" },
+ //{ "weapon", rbac::RBAC_PERM_COMMAND_NPC_ADD_WEAPON, false, &HandleNpcAddWeaponCommand, "" },
+ { "", rbac::RBAC_PERM_COMMAND_NPC_ADD, false, &HandleNpcAddCommand, "" },
};
- static ChatCommand npcDeleteCommandTable[] =
+ static std::vector<ChatCommand> npcDeleteCommandTable =
{
- { "item", rbac::RBAC_PERM_COMMAND_NPC_DELETE_ITEM, false, &HandleNpcDeleteVendorItemCommand, "", NULL },
- { "", rbac::RBAC_PERM_COMMAND_NPC_DELETE, false, &HandleNpcDeleteCommand, "", NULL },
- { NULL, 0, false, NULL, "", NULL }
+ { "item", rbac::RBAC_PERM_COMMAND_NPC_DELETE_ITEM, false, &HandleNpcDeleteVendorItemCommand, "" },
+ { "", rbac::RBAC_PERM_COMMAND_NPC_DELETE, false, &HandleNpcDeleteCommand, "" },
};
- static ChatCommand npcFollowCommandTable[] =
+ static std::vector<ChatCommand> npcFollowCommandTable =
{
- { "stop", rbac::RBAC_PERM_COMMAND_NPC_FOLLOW_STOP, false, &HandleNpcUnFollowCommand, "", NULL },
- { "", rbac::RBAC_PERM_COMMAND_NPC_FOLLOW, false, &HandleNpcFollowCommand, "", NULL },
- { NULL, 0, false, NULL, "", NULL }
+ { "stop", rbac::RBAC_PERM_COMMAND_NPC_FOLLOW_STOP, false, &HandleNpcUnFollowCommand, "" },
+ { "", rbac::RBAC_PERM_COMMAND_NPC_FOLLOW, false, &HandleNpcFollowCommand, "" },
};
- static ChatCommand npcSetCommandTable[] =
- {
- { "allowmove", rbac::RBAC_PERM_COMMAND_NPC_SET_ALLOWMOVE, false, &HandleNpcSetAllowMovementCommand, "", NULL },
- { "entry", rbac::RBAC_PERM_COMMAND_NPC_SET_ENTRY, false, &HandleNpcSetEntryCommand, "", NULL },
- { "factionid", rbac::RBAC_PERM_COMMAND_NPC_SET_FACTIONID, false, &HandleNpcSetFactionIdCommand, "", NULL },
- { "flag", rbac::RBAC_PERM_COMMAND_NPC_SET_FLAG, false, &HandleNpcSetFlagCommand, "", NULL },
- { "level", rbac::RBAC_PERM_COMMAND_NPC_SET_LEVEL, false, &HandleNpcSetLevelCommand, "", NULL },
- { "link", rbac::RBAC_PERM_COMMAND_NPC_SET_LINK, false, &HandleNpcSetLinkCommand, "", NULL },
- { "model", rbac::RBAC_PERM_COMMAND_NPC_SET_MODEL, false, &HandleNpcSetModelCommand, "", NULL },
- { "movetype", rbac::RBAC_PERM_COMMAND_NPC_SET_MOVETYPE, false, &HandleNpcSetMoveTypeCommand, "", NULL },
- { "phase", rbac::RBAC_PERM_COMMAND_NPC_SET_PHASE, false, &HandleNpcSetPhaseCommand, "", NULL },
- { "spawndist", rbac::RBAC_PERM_COMMAND_NPC_SET_SPAWNDIST, false, &HandleNpcSetSpawnDistCommand, "", NULL },
- { "spawntime", rbac::RBAC_PERM_COMMAND_NPC_SET_SPAWNTIME, false, &HandleNpcSetSpawnTimeCommand, "", NULL },
- { "data", rbac::RBAC_PERM_COMMAND_NPC_SET_DATA, false, &HandleNpcSetDataCommand, "", NULL },
- //{ "name", rbac::RBAC_PERM_COMMAND_NPC_SET_NAME, false, &HandleNpcSetNameCommand, "", NULL },
- //{ "subname", rbac::RBAC_PERM_COMMAND_NPC_SET_SUBNAME, false, &HandleNpcSetSubNameCommand, "", NULL },
- { NULL, 0, false, NULL, "", NULL }
+ static std::vector<ChatCommand> npcSetCommandTable =
+ {
+ { "allowmove", rbac::RBAC_PERM_COMMAND_NPC_SET_ALLOWMOVE, false, &HandleNpcSetAllowMovementCommand, "" },
+ { "entry", rbac::RBAC_PERM_COMMAND_NPC_SET_ENTRY, false, &HandleNpcSetEntryCommand, "" },
+ { "factionid", rbac::RBAC_PERM_COMMAND_NPC_SET_FACTIONID, false, &HandleNpcSetFactionIdCommand, "" },
+ { "flag", rbac::RBAC_PERM_COMMAND_NPC_SET_FLAG, false, &HandleNpcSetFlagCommand, "" },
+ { "level", rbac::RBAC_PERM_COMMAND_NPC_SET_LEVEL, false, &HandleNpcSetLevelCommand, "" },
+ { "link", rbac::RBAC_PERM_COMMAND_NPC_SET_LINK, false, &HandleNpcSetLinkCommand, "" },
+ { "model", rbac::RBAC_PERM_COMMAND_NPC_SET_MODEL, false, &HandleNpcSetModelCommand, "" },
+ { "movetype", rbac::RBAC_PERM_COMMAND_NPC_SET_MOVETYPE, false, &HandleNpcSetMoveTypeCommand, "" },
+ { "phase", rbac::RBAC_PERM_COMMAND_NPC_SET_PHASE, false, &HandleNpcSetPhaseCommand, "" },
+ { "spawndist", rbac::RBAC_PERM_COMMAND_NPC_SET_SPAWNDIST, false, &HandleNpcSetSpawnDistCommand, "" },
+ { "spawntime", rbac::RBAC_PERM_COMMAND_NPC_SET_SPAWNTIME, false, &HandleNpcSetSpawnTimeCommand, "" },
+ { "data", rbac::RBAC_PERM_COMMAND_NPC_SET_DATA, false, &HandleNpcSetDataCommand, "" },
};
- static ChatCommand npcCommandTable[] =
- {
- { "info", rbac::RBAC_PERM_COMMAND_NPC_INFO, false, &HandleNpcInfoCommand, "", NULL },
- { "near", rbac::RBAC_PERM_COMMAND_NPC_NEAR, false, &HandleNpcNearCommand, "", NULL },
- { "move", rbac::RBAC_PERM_COMMAND_NPC_MOVE, false, &HandleNpcMoveCommand, "", NULL },
- { "playemote", rbac::RBAC_PERM_COMMAND_NPC_PLAYEMOTE, false, &HandleNpcPlayEmoteCommand, "", NULL },
- { "say", rbac::RBAC_PERM_COMMAND_NPC_SAY, false, &HandleNpcSayCommand, "", NULL },
- { "textemote", rbac::RBAC_PERM_COMMAND_NPC_TEXTEMOTE, false, &HandleNpcTextEmoteCommand, "", NULL },
- { "whisper", rbac::RBAC_PERM_COMMAND_NPC_WHISPER, false, &HandleNpcWhisperCommand, "", NULL },
- { "yell", rbac::RBAC_PERM_COMMAND_NPC_YELL, false, &HandleNpcYellCommand, "", NULL },
- { "tame", rbac::RBAC_PERM_COMMAND_NPC_TAME, false, &HandleNpcTameCommand, "", NULL },
+ static std::vector<ChatCommand> npcCommandTable =
+ {
+ { "info", rbac::RBAC_PERM_COMMAND_NPC_INFO, false, &HandleNpcInfoCommand, "" },
+ { "near", rbac::RBAC_PERM_COMMAND_NPC_NEAR, false, &HandleNpcNearCommand, "" },
+ { "move", rbac::RBAC_PERM_COMMAND_NPC_MOVE, false, &HandleNpcMoveCommand, "" },
+ { "playemote", rbac::RBAC_PERM_COMMAND_NPC_PLAYEMOTE, false, &HandleNpcPlayEmoteCommand, "" },
+ { "say", rbac::RBAC_PERM_COMMAND_NPC_SAY, false, &HandleNpcSayCommand, "" },
+ { "textemote", rbac::RBAC_PERM_COMMAND_NPC_TEXTEMOTE, false, &HandleNpcTextEmoteCommand, "" },
+ { "whisper", rbac::RBAC_PERM_COMMAND_NPC_WHISPER, false, &HandleNpcWhisperCommand, "" },
+ { "yell", rbac::RBAC_PERM_COMMAND_NPC_YELL, false, &HandleNpcYellCommand, "" },
+ { "tame", rbac::RBAC_PERM_COMMAND_NPC_TAME, false, &HandleNpcTameCommand, "" },
{ "add", rbac::RBAC_PERM_COMMAND_NPC_ADD, false, NULL, "", npcAddCommandTable },
{ "delete", rbac::RBAC_PERM_COMMAND_NPC_DELETE, false, NULL, "", npcDeleteCommandTable },
{ "follow", rbac::RBAC_PERM_COMMAND_NPC_FOLLOW, false, NULL, "", npcFollowCommandTable },
{ "set", rbac::RBAC_PERM_COMMAND_NPC_SET, false, NULL, "", npcSetCommandTable },
- { NULL, 0, false, NULL, "", NULL }
};
- static ChatCommand commandTable[] =
+ static std::vector<ChatCommand> commandTable =
{
{ "npc", rbac::RBAC_PERM_COMMAND_NPC, false, NULL, "", npcCommandTable },
- { NULL, 0, false, NULL, "", NULL }
};
return commandTable;
}
@@ -1563,98 +1555,6 @@ public:
*/
return true;
}
-
- static bool HandleNpcSetNameCommand(ChatHandler* /*handler*/, char const* /*args*/)
- {
- /* Temp. disabled
- if (!*args)
- return false;
-
- if (strlen((char*)args)>75)
- {
- handler->PSendSysMessage(LANG_TOO_LONG_NAME, strlen((char*)args)-75);
- return true;
- }
-
- for (uint8 i = 0; i < strlen(args); ++i)
- {
- if (!isalpha(args[i]) && args[i] != ' ')
- {
- handler->SendSysMessage(LANG_CHARS_ONLY);
- return false;
- }
- }
-
- uint64 guid;
- guid = handler->GetSession()->GetPlayer()->GetSelection();
- if (guid == 0)
- {
- handler->SendSysMessage(LANG_NO_SELECTION);
- return true;
- }
-
- Creature* creature = ObjectAccessor::GetCreature(*handler->GetSession()->GetPlayer(), guid);
-
- if (!creature)
- {
- handler->SendSysMessage(LANG_SELECT_CREATURE);
- return true;
- }
-
- creature->SetName(args);
- uint32 idname = sObjectMgr->AddCreatureTemplate(creature->GetName());
- creature->SetUInt32Value(OBJECT_FIELD_ENTRY, idname);
-
- creature->SaveToDB();
- */
-
- return true;
- }
-
- static bool HandleNpcSetSubNameCommand(ChatHandler* /*handler*/, char const* /*args*/)
- {
- /* Temp. disabled
-
- if (!*args)
- args = "";
-
- if (strlen((char*)args)>75)
- {
- handler->PSendSysMessage(LANG_TOO_LONG_SUBNAME, strlen((char*)args)-75);
- return true;
- }
-
- for (uint8 i = 0; i < strlen(args); i++)
- {
- if (!isalpha(args[i]) && args[i] != ' ')
- {
- handler->SendSysMessage(LANG_CHARS_ONLY);
- return false;
- }
- }
- uint64 guid;
- guid = handler->GetSession()->GetPlayer()->GetSelection();
- if (guid == 0)
- {
- handler->SendSysMessage(LANG_NO_SELECTION);
- return true;
- }
-
- Creature* creature = ObjectAccessor::GetCreature(*handler->GetSession()->GetPlayer(), guid);
-
- if (!creature)
- {
- handler->SendSysMessage(LANG_SELECT_CREATURE);
- return true;
- }
-
- uint32 idname = sObjectMgr->AddCreatureSubName(creature->GetName(), args, creature->GetUInt32Value(UNIT_FIELD_DISPLAYID));
- creature->SetUInt32Value(OBJECT_FIELD_ENTRY, idname);
-
- creature->SaveToDB();
- */
- return true;
- }
};
void AddSC_npc_commandscript()
diff --git a/src/server/scripts/Commands/cs_pet.cpp b/src/server/scripts/Commands/cs_pet.cpp
index fdac9d1a35f..e3046817821 100644
--- a/src/server/scripts/Commands/cs_pet.cpp
+++ b/src/server/scripts/Commands/cs_pet.cpp
@@ -27,20 +27,18 @@ class pet_commandscript : public CommandScript
public:
pet_commandscript() : CommandScript("pet_commandscript") { }
- ChatCommand* GetCommands() const override
+ std::vector<ChatCommand> GetCommands() const override
{
- static ChatCommand petCommandTable[] =
+ static std::vector<ChatCommand> petCommandTable =
{
- { "create", rbac::RBAC_PERM_COMMAND_PET_CREATE, false, &HandlePetCreateCommand, "", NULL },
- { "learn", rbac::RBAC_PERM_COMMAND_PET_LEARN, false, &HandlePetLearnCommand, "", NULL },
- { "unlearn", rbac::RBAC_PERM_COMMAND_PET_UNLEARN, false, &HandlePetUnlearnCommand, "", NULL },
- { NULL, 0, false, NULL, "", NULL }
+ { "create", rbac::RBAC_PERM_COMMAND_PET_CREATE, false, &HandlePetCreateCommand, "" },
+ { "learn", rbac::RBAC_PERM_COMMAND_PET_LEARN, false, &HandlePetLearnCommand, "" },
+ { "unlearn", rbac::RBAC_PERM_COMMAND_PET_UNLEARN, false, &HandlePetUnlearnCommand, "" },
};
- static ChatCommand commandTable[] =
+ static std::vector<ChatCommand> commandTable =
{
{ "pet", rbac::RBAC_PERM_COMMAND_PET, false, NULL, "", petCommandTable },
- { NULL, 0, false, NULL, "", NULL }
};
return commandTable;
}
diff --git a/src/server/scripts/Commands/cs_quest.cpp b/src/server/scripts/Commands/cs_quest.cpp
index 82904efc949..442950bca96 100644
--- a/src/server/scripts/Commands/cs_quest.cpp
+++ b/src/server/scripts/Commands/cs_quest.cpp
@@ -33,20 +33,18 @@ class quest_commandscript : public CommandScript
public:
quest_commandscript() : CommandScript("quest_commandscript") { }
- ChatCommand* GetCommands() const override
+ std::vector<ChatCommand> GetCommands() const override
{
- static ChatCommand questCommandTable[] =
+ static std::vector<ChatCommand> questCommandTable =
{
- { "add", rbac::RBAC_PERM_COMMAND_QUEST_ADD, false, &HandleQuestAdd, "", NULL },
- { "complete", rbac::RBAC_PERM_COMMAND_QUEST_COMPLETE, false, &HandleQuestComplete, "", NULL },
- { "remove", rbac::RBAC_PERM_COMMAND_QUEST_REMOVE, false, &HandleQuestRemove, "", NULL },
- { "reward", rbac::RBAC_PERM_COMMAND_QUEST_REWARD, false, &HandleQuestReward, "", NULL },
- { NULL, 0, false, NULL, "", NULL }
+ { "add", rbac::RBAC_PERM_COMMAND_QUEST_ADD, false, &HandleQuestAdd, "" },
+ { "complete", rbac::RBAC_PERM_COMMAND_QUEST_COMPLETE, false, &HandleQuestComplete, "" },
+ { "remove", rbac::RBAC_PERM_COMMAND_QUEST_REMOVE, false, &HandleQuestRemove, "" },
+ { "reward", rbac::RBAC_PERM_COMMAND_QUEST_REWARD, false, &HandleQuestReward, "" },
};
- static ChatCommand commandTable[] =
+ static std::vector<ChatCommand> commandTable =
{
{ "quest", rbac::RBAC_PERM_COMMAND_QUEST, false, NULL, "", questCommandTable },
- { NULL, 0, false, NULL, "", NULL }
};
return commandTable;
}
diff --git a/src/server/scripts/Commands/cs_rbac.cpp b/src/server/scripts/Commands/cs_rbac.cpp
index 03f35e6ba65..c28aa04175f 100644
--- a/src/server/scripts/Commands/cs_rbac.cpp
+++ b/src/server/scripts/Commands/cs_rbac.cpp
@@ -49,28 +49,25 @@ class rbac_commandscript : public CommandScript
public:
rbac_commandscript() : CommandScript("rbac_commandscript") { }
- ChatCommand* GetCommands() const
+ std::vector<ChatCommand> GetCommands() const
{
- static ChatCommand rbacAccountCommandTable[] =
+ static std::vector<ChatCommand> rbacAccountCommandTable =
{
- { "list", rbac::RBAC_PERM_COMMAND_RBAC_ACC_PERM_LIST, true, &HandleRBACPermListCommand, "", NULL },
- { "grant", rbac::RBAC_PERM_COMMAND_RBAC_ACC_PERM_GRANT, true, &HandleRBACPermGrantCommand, "", NULL },
- { "deny", rbac::RBAC_PERM_COMMAND_RBAC_ACC_PERM_DENY, true, &HandleRBACPermDenyCommand, "", NULL },
- { "revoke", rbac::RBAC_PERM_COMMAND_RBAC_ACC_PERM_REVOKE, true, &HandleRBACPermRevokeCommand, "", NULL },
- { NULL, 0, false, NULL, "", NULL }
+ { "list", rbac::RBAC_PERM_COMMAND_RBAC_ACC_PERM_LIST, true, &HandleRBACPermListCommand, "" },
+ { "grant", rbac::RBAC_PERM_COMMAND_RBAC_ACC_PERM_GRANT, true, &HandleRBACPermGrantCommand, "" },
+ { "deny", rbac::RBAC_PERM_COMMAND_RBAC_ACC_PERM_DENY, true, &HandleRBACPermDenyCommand, "" },
+ { "revoke", rbac::RBAC_PERM_COMMAND_RBAC_ACC_PERM_REVOKE, true, &HandleRBACPermRevokeCommand, "" },
};
- static ChatCommand rbacCommandTable[] =
+ static std::vector<ChatCommand> rbacCommandTable =
{
{ "account", rbac::RBAC_PERM_COMMAND_RBAC_ACC, true, NULL, "", rbacAccountCommandTable },
- { "list", rbac::RBAC_PERM_COMMAND_RBAC_LIST, true, &HandleRBACListPermissionsCommand, "", NULL },
- { NULL, 0, false, NULL, "", NULL }
+ { "list", rbac::RBAC_PERM_COMMAND_RBAC_LIST, true, &HandleRBACListPermissionsCommand, "" },
};
- static ChatCommand commandTable[] =
+ static std::vector<ChatCommand> commandTable =
{
{ "rbac", rbac::RBAC_PERM_COMMAND_RBAC, true, NULL, "", rbacCommandTable },
- { NULL, 0, false, NULL, "", NULL }
};
return commandTable;
diff --git a/src/server/scripts/Commands/cs_reload.cpp b/src/server/scripts/Commands/cs_reload.cpp
index 2863d2d4ede..44e34b8e2a9 100644
--- a/src/server/scripts/Commands/cs_reload.cpp
+++ b/src/server/scripts/Commands/cs_reload.cpp
@@ -47,122 +47,119 @@ class reload_commandscript : public CommandScript
public:
reload_commandscript() : CommandScript("reload_commandscript") { }
- ChatCommand* GetCommands() const override
+ std::vector<ChatCommand> GetCommands() const override
{
- static ChatCommand reloadAllCommandTable[] =
+ static std::vector<ChatCommand> reloadAllCommandTable =
{
- { "achievement", rbac::RBAC_PERM_COMMAND_RELOAD_ALL_ACHIEVEMENT, true, &HandleReloadAllAchievementCommand, "", NULL },
- { "area", rbac::RBAC_PERM_COMMAND_RELOAD_ALL_AREA, true, &HandleReloadAllAreaCommand, "", NULL },
- { "gossips", rbac::RBAC_PERM_COMMAND_RELOAD_ALL_GOSSIP, true, &HandleReloadAllGossipsCommand, "", NULL },
- { "item", rbac::RBAC_PERM_COMMAND_RELOAD_ALL_ITEM, true, &HandleReloadAllItemCommand, "", NULL },
- { "locales", rbac::RBAC_PERM_COMMAND_RELOAD_ALL_LOCALES, true, &HandleReloadAllLocalesCommand, "", NULL },
- { "loot", rbac::RBAC_PERM_COMMAND_RELOAD_ALL_LOOT, true, &HandleReloadAllLootCommand, "", NULL },
- { "npc", rbac::RBAC_PERM_COMMAND_RELOAD_ALL_NPC, true, &HandleReloadAllNpcCommand, "", NULL },
- { "quest", rbac::RBAC_PERM_COMMAND_RELOAD_ALL_QUEST, true, &HandleReloadAllQuestCommand, "", NULL },
- { "scripts", rbac::RBAC_PERM_COMMAND_RELOAD_ALL_SCRIPTS, true, &HandleReloadAllScriptsCommand, "", NULL },
- { "spell", rbac::RBAC_PERM_COMMAND_RELOAD_ALL_SPELL, true, &HandleReloadAllSpellCommand, "", NULL },
- { "", rbac::RBAC_PERM_COMMAND_RELOAD_ALL, true, &HandleReloadAllCommand, "", NULL },
- { NULL, 0, false, NULL, "", NULL }
+ { "achievement", rbac::RBAC_PERM_COMMAND_RELOAD_ALL_ACHIEVEMENT, true, &HandleReloadAllAchievementCommand, "" },
+ { "area", rbac::RBAC_PERM_COMMAND_RELOAD_ALL_AREA, true, &HandleReloadAllAreaCommand, "" },
+ { "gossips", rbac::RBAC_PERM_COMMAND_RELOAD_ALL_GOSSIP, true, &HandleReloadAllGossipsCommand, "" },
+ { "item", rbac::RBAC_PERM_COMMAND_RELOAD_ALL_ITEM, true, &HandleReloadAllItemCommand, "" },
+ { "locales", rbac::RBAC_PERM_COMMAND_RELOAD_ALL_LOCALES, true, &HandleReloadAllLocalesCommand, "" },
+ { "loot", rbac::RBAC_PERM_COMMAND_RELOAD_ALL_LOOT, true, &HandleReloadAllLootCommand, "" },
+ { "npc", rbac::RBAC_PERM_COMMAND_RELOAD_ALL_NPC, true, &HandleReloadAllNpcCommand, "" },
+ { "quest", rbac::RBAC_PERM_COMMAND_RELOAD_ALL_QUEST, true, &HandleReloadAllQuestCommand, "" },
+ { "scripts", rbac::RBAC_PERM_COMMAND_RELOAD_ALL_SCRIPTS, true, &HandleReloadAllScriptsCommand, "" },
+ { "spell", rbac::RBAC_PERM_COMMAND_RELOAD_ALL_SPELL, true, &HandleReloadAllSpellCommand, "" },
+ { "", rbac::RBAC_PERM_COMMAND_RELOAD_ALL, true, &HandleReloadAllCommand, "" },
};
- static ChatCommand reloadCommandTable[] =
+ static std::vector<ChatCommand> reloadCommandTable =
{
- { "auctions", rbac::RBAC_PERM_COMMAND_RELOAD_AUCTIONS, true, &HandleReloadAuctionsCommand, "", NULL },
- { "access_requirement", rbac::RBAC_PERM_COMMAND_RELOAD_ACCESS_REQUIREMENT, true, &HandleReloadAccessRequirementCommand, "", NULL },
- { "achievement_criteria_data", rbac::RBAC_PERM_COMMAND_RELOAD_ACHIEVEMENT_CRITERIA_DATA, true, &HandleReloadAchievementCriteriaDataCommand, "", NULL },
- { "achievement_reward", rbac::RBAC_PERM_COMMAND_RELOAD_ACHIEVEMENT_REWARD, true, &HandleReloadAchievementRewardCommand, "", NULL },
+ { "auctions", rbac::RBAC_PERM_COMMAND_RELOAD_AUCTIONS, true, &HandleReloadAuctionsCommand, "" },
+ { "access_requirement", rbac::RBAC_PERM_COMMAND_RELOAD_ACCESS_REQUIREMENT, true, &HandleReloadAccessRequirementCommand, "" },
+ { "achievement_criteria_data", rbac::RBAC_PERM_COMMAND_RELOAD_ACHIEVEMENT_CRITERIA_DATA, true, &HandleReloadAchievementCriteriaDataCommand, "" },
+ { "achievement_reward", rbac::RBAC_PERM_COMMAND_RELOAD_ACHIEVEMENT_REWARD, true, &HandleReloadAchievementRewardCommand, "" },
{ "all", rbac::RBAC_PERM_COMMAND_RELOAD_ALL, true, NULL, "", reloadAllCommandTable },
- { "areatrigger_involvedrelation", rbac::RBAC_PERM_COMMAND_RELOAD_AREATRIGGER_INVOLVEDRELATION, true, &HandleReloadQuestAreaTriggersCommand, "", NULL },
- { "areatrigger_tavern", rbac::RBAC_PERM_COMMAND_RELOAD_AREATRIGGER_TAVERN, true, &HandleReloadAreaTriggerTavernCommand, "", NULL },
- { "areatrigger_teleport", rbac::RBAC_PERM_COMMAND_RELOAD_AREATRIGGER_TELEPORT, true, &HandleReloadAreaTriggerTeleportCommand, "", NULL },
- { "autobroadcast", rbac::RBAC_PERM_COMMAND_RELOAD_AUTOBROADCAST, true, &HandleReloadAutobroadcastCommand, "", NULL },
- { "battleground_template", rbac::RBAC_PERM_COMMAND_RELOAD_BATTLEGROUND_TEMPLATE, true, &HandleReloadBattlegroundTemplate, "", NULL },
- { "broadcast_text", rbac::RBAC_PERM_COMMAND_RELOAD_BROADCAST_TEXT, true, &HandleReloadBroadcastTextCommand, "", NULL },
- { "command", rbac::RBAC_PERM_COMMAND_RELOAD_COMMAND, true, &HandleReloadCommandCommand, "", NULL },
- { "conditions", rbac::RBAC_PERM_COMMAND_RELOAD_CONDITIONS, true, &HandleReloadConditions, "", NULL },
- { "config", rbac::RBAC_PERM_COMMAND_RELOAD_CONFIG, true, &HandleReloadConfigCommand, "", NULL },
- { "creature_text", rbac::RBAC_PERM_COMMAND_RELOAD_CREATURE_TEXT, true, &HandleReloadCreatureText, "", NULL },
- { "creature_questender", rbac::RBAC_PERM_COMMAND_RELOAD_CREATURE_QUESTENDER, true, &HandleReloadCreatureQuestEnderCommand, "", NULL },
- { "creature_linked_respawn", rbac::RBAC_PERM_COMMAND_RELOAD_CREATURE_LINKED_RESPAWN, true, &HandleReloadLinkedRespawnCommand, "", NULL },
- { "creature_loot_template", rbac::RBAC_PERM_COMMAND_RELOAD_CREATURE_LOOT_TEMPLATE, true, &HandleReloadLootTemplatesCreatureCommand, "", NULL },
- { "creature_onkill_reputation", rbac::RBAC_PERM_COMMAND_RELOAD_CREATURE_ONKILL_REPUTATION, true, &HandleReloadOnKillReputationCommand, "", NULL },
- { "creature_queststarter", rbac::RBAC_PERM_COMMAND_RELOAD_CREATURE_QUESTSTARTER, true, &HandleReloadCreatureQuestStarterCommand, "", NULL },
- { "creature_summon_groups", rbac::RBAC_PERM_COMMAND_RELOAD_CREATURE_SUMMON_GROUPS, true, &HandleReloadCreatureSummonGroupsCommand, "", NULL },
- { "creature_template", rbac::RBAC_PERM_COMMAND_RELOAD_CREATURE_TEMPLATE, true, &HandleReloadCreatureTemplateCommand, "", NULL },
- { "disables", rbac::RBAC_PERM_COMMAND_RELOAD_DISABLES, true, &HandleReloadDisablesCommand, "", NULL },
- { "disenchant_loot_template", rbac::RBAC_PERM_COMMAND_RELOAD_DISENCHANT_LOOT_TEMPLATE, true, &HandleReloadLootTemplatesDisenchantCommand, "", NULL },
- { "event_scripts", rbac::RBAC_PERM_COMMAND_RELOAD_EVENT_SCRIPTS, true, &HandleReloadEventScriptsCommand, "", NULL },
- { "fishing_loot_template", rbac::RBAC_PERM_COMMAND_RELOAD_FISHING_LOOT_TEMPLATE, true, &HandleReloadLootTemplatesFishingCommand, "", NULL },
- { "game_graveyard_zone", rbac::RBAC_PERM_COMMAND_RELOAD_GAME_GRAVEYARD_ZONE, true, &HandleReloadGameGraveyardZoneCommand, "", NULL },
- { "game_tele", rbac::RBAC_PERM_COMMAND_RELOAD_GAME_TELE, true, &HandleReloadGameTeleCommand, "", NULL },
- { "gameobject_questender", rbac::RBAC_PERM_COMMAND_RELOAD_GAMEOBJECT_QUESTENDER, true, &HandleReloadGOQuestEnderCommand, "", NULL },
- { "gameobject_loot_template", rbac::RBAC_PERM_COMMAND_RELOAD_GAMEOBJECT_QUEST_LOOT_TEMPLATE, true, &HandleReloadLootTemplatesGameobjectCommand, "", NULL },
- { "gameobject_queststarter", rbac::RBAC_PERM_COMMAND_RELOAD_GAMEOBJECT_QUESTSTARTER, true, &HandleReloadGOQuestStarterCommand, "", NULL },
- { "gm_tickets", rbac::RBAC_PERM_COMMAND_RELOAD_GM_TICKETS, true, &HandleReloadGMTicketsCommand, "", NULL },
- { "gossip_menu", rbac::RBAC_PERM_COMMAND_RELOAD_GOSSIP_MENU, true, &HandleReloadGossipMenuCommand, "", NULL },
- { "gossip_menu_option", rbac::RBAC_PERM_COMMAND_RELOAD_GOSSIP_MENU_OPTION, true, &HandleReloadGossipMenuOptionCommand, "", NULL },
- { "item_enchantment_template", rbac::RBAC_PERM_COMMAND_RELOAD_ITEM_ENCHANTMENT_TEMPLATE, true, &HandleReloadItemEnchantementsCommand, "", NULL },
- { "item_loot_template", rbac::RBAC_PERM_COMMAND_RELOAD_ITEM_LOOT_TEMPLATE, true, &HandleReloadLootTemplatesItemCommand, "", NULL },
- { "item_set_names", rbac::RBAC_PERM_COMMAND_RELOAD_ITEM_SET_NAMES, true, &HandleReloadItemSetNamesCommand, "", NULL },
- { "lfg_dungeon_rewards", rbac::RBAC_PERM_COMMAND_RELOAD_LFG_DUNGEON_REWARDS, true, &HandleReloadLfgRewardsCommand, "", NULL },
- { "locales_achievement_reward", rbac::RBAC_PERM_COMMAND_RELOAD_LOCALES_ACHIEVEMENT_REWARD, true, &HandleReloadLocalesAchievementRewardCommand, "", NULL },
- { "locales_creature", rbac::RBAC_PERM_COMMAND_RELOAD_LOCALES_CRETURE, true, &HandleReloadLocalesCreatureCommand, "", NULL },
- { "locales_creature_text", rbac::RBAC_PERM_COMMAND_RELOAD_LOCALES_CRETURE_TEXT, true, &HandleReloadLocalesCreatureTextCommand, "", NULL },
- { "locales_gameobject", rbac::RBAC_PERM_COMMAND_RELOAD_LOCALES_GAMEOBJECT, true, &HandleReloadLocalesGameobjectCommand, "", NULL },
- { "locales_gossip_menu_option", rbac::RBAC_PERM_COMMAND_RELOAD_LOCALES_GOSSIP_MENU_OPTION, true, &HandleReloadLocalesGossipMenuOptionCommand, "", NULL },
- { "locales_item", rbac::RBAC_PERM_COMMAND_RELOAD_LOCALES_ITEM, true, &HandleReloadLocalesItemCommand, "", NULL },
- { "locales_item_set_name", rbac::RBAC_PERM_COMMAND_RELOAD_LOCALES_ITEM_SET_NAME, true, &HandleReloadLocalesItemSetNameCommand, "", NULL },
- { "locales_npc_text", rbac::RBAC_PERM_COMMAND_RELOAD_LOCALES_NPC_TEXT, true, &HandleReloadLocalesNpcTextCommand, "", NULL },
- { "locales_page_text", rbac::RBAC_PERM_COMMAND_RELOAD_LOCALES_PAGE_TEXT, true, &HandleReloadLocalesPageTextCommand, "", NULL },
- { "locales_points_of_interest", rbac::RBAC_PERM_COMMAND_RELOAD_LOCALES_POINTS_OF_INTEREST, true, &HandleReloadLocalesPointsOfInterestCommand, "", NULL },
- { "locales_quest", rbac::RBAC_PERM_COMMAND_RELOAD_LOCALES_QUEST, true, &HandleReloadLocalesQuestCommand, "", NULL },
- { "mail_level_reward", rbac::RBAC_PERM_COMMAND_RELOAD_MAIL_LEVEL_REWARD, true, &HandleReloadMailLevelRewardCommand, "", NULL },
- { "mail_loot_template", rbac::RBAC_PERM_COMMAND_RELOAD_MAIL_LOOT_TEMPLATE, true, &HandleReloadLootTemplatesMailCommand, "", NULL },
- { "milling_loot_template", rbac::RBAC_PERM_COMMAND_RELOAD_MILLING_LOOT_TEMPLATE, true, &HandleReloadLootTemplatesMillingCommand, "", NULL },
- { "npc_spellclick_spells", rbac::RBAC_PERM_COMMAND_RELOAD_NPC_SPELLCLICK_SPELLS, true, &HandleReloadSpellClickSpellsCommand, "", NULL },
- { "npc_trainer", rbac::RBAC_PERM_COMMAND_RELOAD_NPC_TRAINER, true, &HandleReloadNpcTrainerCommand, "", NULL },
- { "npc_vendor", rbac::RBAC_PERM_COMMAND_RELOAD_NPC_VENDOR, true, &HandleReloadNpcVendorCommand, "", NULL },
- { "page_text", rbac::RBAC_PERM_COMMAND_RELOAD_PAGE_TEXT, true, &HandleReloadPageTextsCommand, "", NULL },
- { "pickpocketing_loot_template", rbac::RBAC_PERM_COMMAND_RELOAD_PICKPOCKETING_LOOT_TEMPLATE, true, &HandleReloadLootTemplatesPickpocketingCommand, "", NULL },
- { "points_of_interest", rbac::RBAC_PERM_COMMAND_RELOAD_POINTS_OF_INTEREST, true, &HandleReloadPointsOfInterestCommand, "", NULL },
- { "prospecting_loot_template", rbac::RBAC_PERM_COMMAND_RELOAD_PROSPECTING_LOOT_TEMPLATE, true, &HandleReloadLootTemplatesProspectingCommand, "", NULL },
- { "quest_poi", rbac::RBAC_PERM_COMMAND_RELOAD_QUEST_POI, true, &HandleReloadQuestPOICommand, "", NULL },
- { "quest_template", rbac::RBAC_PERM_COMMAND_RELOAD_QUEST_TEMPLATE, true, &HandleReloadQuestTemplateCommand, "", NULL },
- { "rbac", rbac::RBAC_PERM_COMMAND_RELOAD_RBAC, true, &HandleReloadRBACCommand, "", NULL },
- { "reference_loot_template", rbac::RBAC_PERM_COMMAND_RELOAD_REFERENCE_LOOT_TEMPLATE, true, &HandleReloadLootTemplatesReferenceCommand, "", NULL },
- { "reserved_name", rbac::RBAC_PERM_COMMAND_RELOAD_RESERVED_NAME, true, &HandleReloadReservedNameCommand, "", NULL },
- { "reputation_reward_rate", rbac::RBAC_PERM_COMMAND_RELOAD_REPUTATION_REWARD_RATE, true, &HandleReloadReputationRewardRateCommand, "", NULL },
- { "reputation_spillover_template", rbac::RBAC_PERM_COMMAND_RELOAD_SPILLOVER_TEMPLATE, true, &HandleReloadReputationRewardRateCommand, "", NULL },
- { "skill_discovery_template", rbac::RBAC_PERM_COMMAND_RELOAD_SKILL_DISCOVERY_TEMPLATE, true, &HandleReloadSkillDiscoveryTemplateCommand, "", NULL },
- { "skill_extra_item_template", rbac::RBAC_PERM_COMMAND_RELOAD_SKILL_EXTRA_ITEM_TEMPLATE, true, &HandleReloadSkillExtraItemTemplateCommand, "", NULL },
- { "skill_fishing_base_level", rbac::RBAC_PERM_COMMAND_RELOAD_SKILL_FISHING_BASE_LEVEL, true, &HandleReloadSkillFishingBaseLevelCommand, "", NULL },
- { "skinning_loot_template", rbac::RBAC_PERM_COMMAND_RELOAD_SKINNING_LOOT_TEMPLATE, true, &HandleReloadLootTemplatesSkinningCommand, "", NULL },
- { "smart_scripts", rbac::RBAC_PERM_COMMAND_RELOAD_SMART_SCRIPTS, true, &HandleReloadSmartScripts, "", NULL },
- { "spell_required", rbac::RBAC_PERM_COMMAND_RELOAD_SPELL_REQUIRED, true, &HandleReloadSpellRequiredCommand, "", NULL },
- { "spell_area", rbac::RBAC_PERM_COMMAND_RELOAD_SPELL_AREA, true, &HandleReloadSpellAreaCommand, "", NULL },
- { "spell_bonus_data", rbac::RBAC_PERM_COMMAND_RELOAD_SPELL_BONUS_DATA, true, &HandleReloadSpellBonusesCommand, "", NULL },
- { "spell_group", rbac::RBAC_PERM_COMMAND_RELOAD_SPELL_GROUP, true, &HandleReloadSpellGroupsCommand, "", NULL },
- { "spell_learn_spell", rbac::RBAC_PERM_COMMAND_RELOAD_SPELL_LEARN_SPELL, true, &HandleReloadSpellLearnSpellCommand, "", NULL },
- { "spell_loot_template", rbac::RBAC_PERM_COMMAND_RELOAD_SPELL_LOOT_TEMPLATE, true, &HandleReloadLootTemplatesSpellCommand, "", NULL },
- { "spell_linked_spell", rbac::RBAC_PERM_COMMAND_RELOAD_SPELL_LINKED_SPELL, true, &HandleReloadSpellLinkedSpellCommand, "", NULL },
- { "spell_pet_auras", rbac::RBAC_PERM_COMMAND_RELOAD_SPELL_PET_AURAS, true, &HandleReloadSpellPetAurasCommand, "", NULL },
- { "spell_proc_event", rbac::RBAC_PERM_COMMAND_RELOAD_SPELL_PROC_EVENT, true, &HandleReloadSpellProcEventCommand, "", NULL },
- { "spell_proc", rbac::RBAC_PERM_COMMAND_RELOAD_SPELL_PROC, true, &HandleReloadSpellProcsCommand, "", NULL },
- { "spell_scripts", rbac::RBAC_PERM_COMMAND_RELOAD_SPELL_SCRIPTS, true, &HandleReloadSpellScriptsCommand, "", NULL },
- { "spell_target_position", rbac::RBAC_PERM_COMMAND_RELOAD_SPELL_TARGET_POSITION, true, &HandleReloadSpellTargetPositionCommand, "", NULL },
- { "spell_threats", rbac::RBAC_PERM_COMMAND_RELOAD_SPELL_THREATS, true, &HandleReloadSpellThreatsCommand, "", NULL },
- { "spell_group_stack_rules", rbac::RBAC_PERM_COMMAND_RELOAD_SPELL_GROUP_STACK_RULES, true, &HandleReloadSpellGroupStackRulesCommand, "", NULL },
- { "trinity_string", rbac::RBAC_PERM_COMMAND_RELOAD_TRINITY_STRING, true, &HandleReloadTrinityStringCommand, "", NULL },
- { "warden_action", rbac::RBAC_PERM_COMMAND_RELOAD_WARDEN_ACTION, true, &HandleReloadWardenactionCommand, "", NULL },
- { "waypoint_scripts", rbac::RBAC_PERM_COMMAND_RELOAD_WAYPOINT_SCRIPTS, true, &HandleReloadWpScriptsCommand, "", NULL },
- { "waypoint_data", rbac::RBAC_PERM_COMMAND_RELOAD_WAYPOINT_DATA, true, &HandleReloadWpCommand, "", NULL },
- { "vehicle_accessory", rbac::RBAC_PERM_COMMAND_RELOAD_VEHICLE_ACCESORY, true, &HandleReloadVehicleAccessoryCommand, "", NULL },
- { "vehicle_template_accessory", rbac::RBAC_PERM_COMMAND_RELOAD_VEHICLE_TEMPLATE_ACCESSORY, true, &HandleReloadVehicleTemplateAccessoryCommand, "", NULL },
- { NULL, 0, false, NULL, "", NULL }
+ { "areatrigger_involvedrelation", rbac::RBAC_PERM_COMMAND_RELOAD_AREATRIGGER_INVOLVEDRELATION, true, &HandleReloadQuestAreaTriggersCommand, "" },
+ { "areatrigger_tavern", rbac::RBAC_PERM_COMMAND_RELOAD_AREATRIGGER_TAVERN, true, &HandleReloadAreaTriggerTavernCommand, "" },
+ { "areatrigger_teleport", rbac::RBAC_PERM_COMMAND_RELOAD_AREATRIGGER_TELEPORT, true, &HandleReloadAreaTriggerTeleportCommand, "" },
+ { "autobroadcast", rbac::RBAC_PERM_COMMAND_RELOAD_AUTOBROADCAST, true, &HandleReloadAutobroadcastCommand, "" },
+ { "battleground_template", rbac::RBAC_PERM_COMMAND_RELOAD_BATTLEGROUND_TEMPLATE, true, &HandleReloadBattlegroundTemplate, "" },
+ { "broadcast_text", rbac::RBAC_PERM_COMMAND_RELOAD_BROADCAST_TEXT, true, &HandleReloadBroadcastTextCommand, "" },
+ { "command", rbac::RBAC_PERM_COMMAND_RELOAD_COMMAND, true, &HandleReloadCommandCommand, "" },
+ { "conditions", rbac::RBAC_PERM_COMMAND_RELOAD_CONDITIONS, true, &HandleReloadConditions, "" },
+ { "config", rbac::RBAC_PERM_COMMAND_RELOAD_CONFIG, true, &HandleReloadConfigCommand, "" },
+ { "creature_text", rbac::RBAC_PERM_COMMAND_RELOAD_CREATURE_TEXT, true, &HandleReloadCreatureText, "" },
+ { "creature_questender", rbac::RBAC_PERM_COMMAND_RELOAD_CREATURE_QUESTENDER, true, &HandleReloadCreatureQuestEnderCommand, "" },
+ { "creature_linked_respawn", rbac::RBAC_PERM_COMMAND_RELOAD_CREATURE_LINKED_RESPAWN, true, &HandleReloadLinkedRespawnCommand, "" },
+ { "creature_loot_template", rbac::RBAC_PERM_COMMAND_RELOAD_CREATURE_LOOT_TEMPLATE, true, &HandleReloadLootTemplatesCreatureCommand, "" },
+ { "creature_onkill_reputation", rbac::RBAC_PERM_COMMAND_RELOAD_CREATURE_ONKILL_REPUTATION, true, &HandleReloadOnKillReputationCommand, "" },
+ { "creature_queststarter", rbac::RBAC_PERM_COMMAND_RELOAD_CREATURE_QUESTSTARTER, true, &HandleReloadCreatureQuestStarterCommand, "" },
+ { "creature_summon_groups", rbac::RBAC_PERM_COMMAND_RELOAD_CREATURE_SUMMON_GROUPS, true, &HandleReloadCreatureSummonGroupsCommand, "" },
+ { "creature_template", rbac::RBAC_PERM_COMMAND_RELOAD_CREATURE_TEMPLATE, true, &HandleReloadCreatureTemplateCommand, "" },
+ { "disables", rbac::RBAC_PERM_COMMAND_RELOAD_DISABLES, true, &HandleReloadDisablesCommand, "" },
+ { "disenchant_loot_template", rbac::RBAC_PERM_COMMAND_RELOAD_DISENCHANT_LOOT_TEMPLATE, true, &HandleReloadLootTemplatesDisenchantCommand, "" },
+ { "event_scripts", rbac::RBAC_PERM_COMMAND_RELOAD_EVENT_SCRIPTS, true, &HandleReloadEventScriptsCommand, "" },
+ { "fishing_loot_template", rbac::RBAC_PERM_COMMAND_RELOAD_FISHING_LOOT_TEMPLATE, true, &HandleReloadLootTemplatesFishingCommand, "" },
+ { "game_graveyard_zone", rbac::RBAC_PERM_COMMAND_RELOAD_GAME_GRAVEYARD_ZONE, true, &HandleReloadGameGraveyardZoneCommand, "" },
+ { "game_tele", rbac::RBAC_PERM_COMMAND_RELOAD_GAME_TELE, true, &HandleReloadGameTeleCommand, "" },
+ { "gameobject_questender", rbac::RBAC_PERM_COMMAND_RELOAD_GAMEOBJECT_QUESTENDER, true, &HandleReloadGOQuestEnderCommand, "" },
+ { "gameobject_loot_template", rbac::RBAC_PERM_COMMAND_RELOAD_GAMEOBJECT_QUEST_LOOT_TEMPLATE, true, &HandleReloadLootTemplatesGameobjectCommand, "" },
+ { "gameobject_queststarter", rbac::RBAC_PERM_COMMAND_RELOAD_GAMEOBJECT_QUESTSTARTER, true, &HandleReloadGOQuestStarterCommand, "" },
+ { "gm_tickets", rbac::RBAC_PERM_COMMAND_RELOAD_GM_TICKETS, true, &HandleReloadGMTicketsCommand, "" },
+ { "gossip_menu", rbac::RBAC_PERM_COMMAND_RELOAD_GOSSIP_MENU, true, &HandleReloadGossipMenuCommand, "" },
+ { "gossip_menu_option", rbac::RBAC_PERM_COMMAND_RELOAD_GOSSIP_MENU_OPTION, true, &HandleReloadGossipMenuOptionCommand, "" },
+ { "item_enchantment_template", rbac::RBAC_PERM_COMMAND_RELOAD_ITEM_ENCHANTMENT_TEMPLATE, true, &HandleReloadItemEnchantementsCommand, "" },
+ { "item_loot_template", rbac::RBAC_PERM_COMMAND_RELOAD_ITEM_LOOT_TEMPLATE, true, &HandleReloadLootTemplatesItemCommand, "" },
+ { "item_set_names", rbac::RBAC_PERM_COMMAND_RELOAD_ITEM_SET_NAMES, true, &HandleReloadItemSetNamesCommand, "" },
+ { "lfg_dungeon_rewards", rbac::RBAC_PERM_COMMAND_RELOAD_LFG_DUNGEON_REWARDS, true, &HandleReloadLfgRewardsCommand, "" },
+ { "locales_achievement_reward", rbac::RBAC_PERM_COMMAND_RELOAD_LOCALES_ACHIEVEMENT_REWARD, true, &HandleReloadLocalesAchievementRewardCommand, "" },
+ { "locales_creature", rbac::RBAC_PERM_COMMAND_RELOAD_LOCALES_CRETURE, true, &HandleReloadLocalesCreatureCommand, "" },
+ { "locales_creature_text", rbac::RBAC_PERM_COMMAND_RELOAD_LOCALES_CRETURE_TEXT, true, &HandleReloadLocalesCreatureTextCommand, "" },
+ { "locales_gameobject", rbac::RBAC_PERM_COMMAND_RELOAD_LOCALES_GAMEOBJECT, true, &HandleReloadLocalesGameobjectCommand, "" },
+ { "locales_gossip_menu_option", rbac::RBAC_PERM_COMMAND_RELOAD_LOCALES_GOSSIP_MENU_OPTION, true, &HandleReloadLocalesGossipMenuOptionCommand, "" },
+ { "locales_item", rbac::RBAC_PERM_COMMAND_RELOAD_LOCALES_ITEM, true, &HandleReloadLocalesItemCommand, "" },
+ { "locales_item_set_name", rbac::RBAC_PERM_COMMAND_RELOAD_LOCALES_ITEM_SET_NAME, true, &HandleReloadLocalesItemSetNameCommand, "" },
+ { "locales_npc_text", rbac::RBAC_PERM_COMMAND_RELOAD_LOCALES_NPC_TEXT, true, &HandleReloadLocalesNpcTextCommand, "" },
+ { "locales_page_text", rbac::RBAC_PERM_COMMAND_RELOAD_LOCALES_PAGE_TEXT, true, &HandleReloadLocalesPageTextCommand, "" },
+ { "locales_points_of_interest", rbac::RBAC_PERM_COMMAND_RELOAD_LOCALES_POINTS_OF_INTEREST, true, &HandleReloadLocalesPointsOfInterestCommand, "" },
+ { "locales_quest", rbac::RBAC_PERM_COMMAND_RELOAD_LOCALES_QUEST, true, &HandleReloadLocalesQuestCommand, "" },
+ { "mail_level_reward", rbac::RBAC_PERM_COMMAND_RELOAD_MAIL_LEVEL_REWARD, true, &HandleReloadMailLevelRewardCommand, "" },
+ { "mail_loot_template", rbac::RBAC_PERM_COMMAND_RELOAD_MAIL_LOOT_TEMPLATE, true, &HandleReloadLootTemplatesMailCommand, "" },
+ { "milling_loot_template", rbac::RBAC_PERM_COMMAND_RELOAD_MILLING_LOOT_TEMPLATE, true, &HandleReloadLootTemplatesMillingCommand, "" },
+ { "npc_spellclick_spells", rbac::RBAC_PERM_COMMAND_RELOAD_NPC_SPELLCLICK_SPELLS, true, &HandleReloadSpellClickSpellsCommand, "" },
+ { "npc_trainer", rbac::RBAC_PERM_COMMAND_RELOAD_NPC_TRAINER, true, &HandleReloadNpcTrainerCommand, "" },
+ { "npc_vendor", rbac::RBAC_PERM_COMMAND_RELOAD_NPC_VENDOR, true, &HandleReloadNpcVendorCommand, "" },
+ { "page_text", rbac::RBAC_PERM_COMMAND_RELOAD_PAGE_TEXT, true, &HandleReloadPageTextsCommand, "" },
+ { "pickpocketing_loot_template", rbac::RBAC_PERM_COMMAND_RELOAD_PICKPOCKETING_LOOT_TEMPLATE, true, &HandleReloadLootTemplatesPickpocketingCommand, "" },
+ { "points_of_interest", rbac::RBAC_PERM_COMMAND_RELOAD_POINTS_OF_INTEREST, true, &HandleReloadPointsOfInterestCommand, "" },
+ { "prospecting_loot_template", rbac::RBAC_PERM_COMMAND_RELOAD_PROSPECTING_LOOT_TEMPLATE, true, &HandleReloadLootTemplatesProspectingCommand, "" },
+ { "quest_poi", rbac::RBAC_PERM_COMMAND_RELOAD_QUEST_POI, true, &HandleReloadQuestPOICommand, "" },
+ { "quest_template", rbac::RBAC_PERM_COMMAND_RELOAD_QUEST_TEMPLATE, true, &HandleReloadQuestTemplateCommand, "" },
+ { "rbac", rbac::RBAC_PERM_COMMAND_RELOAD_RBAC, true, &HandleReloadRBACCommand, "" },
+ { "reference_loot_template", rbac::RBAC_PERM_COMMAND_RELOAD_REFERENCE_LOOT_TEMPLATE, true, &HandleReloadLootTemplatesReferenceCommand, "" },
+ { "reserved_name", rbac::RBAC_PERM_COMMAND_RELOAD_RESERVED_NAME, true, &HandleReloadReservedNameCommand, "" },
+ { "reputation_reward_rate", rbac::RBAC_PERM_COMMAND_RELOAD_REPUTATION_REWARD_RATE, true, &HandleReloadReputationRewardRateCommand, "" },
+ { "reputation_spillover_template", rbac::RBAC_PERM_COMMAND_RELOAD_SPILLOVER_TEMPLATE, true, &HandleReloadReputationRewardRateCommand, "" },
+ { "skill_discovery_template", rbac::RBAC_PERM_COMMAND_RELOAD_SKILL_DISCOVERY_TEMPLATE, true, &HandleReloadSkillDiscoveryTemplateCommand, "" },
+ { "skill_extra_item_template", rbac::RBAC_PERM_COMMAND_RELOAD_SKILL_EXTRA_ITEM_TEMPLATE, true, &HandleReloadSkillExtraItemTemplateCommand, "" },
+ { "skill_fishing_base_level", rbac::RBAC_PERM_COMMAND_RELOAD_SKILL_FISHING_BASE_LEVEL, true, &HandleReloadSkillFishingBaseLevelCommand, "" },
+ { "skinning_loot_template", rbac::RBAC_PERM_COMMAND_RELOAD_SKINNING_LOOT_TEMPLATE, true, &HandleReloadLootTemplatesSkinningCommand, "" },
+ { "smart_scripts", rbac::RBAC_PERM_COMMAND_RELOAD_SMART_SCRIPTS, true, &HandleReloadSmartScripts, "" },
+ { "spell_required", rbac::RBAC_PERM_COMMAND_RELOAD_SPELL_REQUIRED, true, &HandleReloadSpellRequiredCommand, "" },
+ { "spell_area", rbac::RBAC_PERM_COMMAND_RELOAD_SPELL_AREA, true, &HandleReloadSpellAreaCommand, "" },
+ { "spell_bonus_data", rbac::RBAC_PERM_COMMAND_RELOAD_SPELL_BONUS_DATA, true, &HandleReloadSpellBonusesCommand, "" },
+ { "spell_group", rbac::RBAC_PERM_COMMAND_RELOAD_SPELL_GROUP, true, &HandleReloadSpellGroupsCommand, "" },
+ { "spell_learn_spell", rbac::RBAC_PERM_COMMAND_RELOAD_SPELL_LEARN_SPELL, true, &HandleReloadSpellLearnSpellCommand, "" },
+ { "spell_loot_template", rbac::RBAC_PERM_COMMAND_RELOAD_SPELL_LOOT_TEMPLATE, true, &HandleReloadLootTemplatesSpellCommand, "" },
+ { "spell_linked_spell", rbac::RBAC_PERM_COMMAND_RELOAD_SPELL_LINKED_SPELL, true, &HandleReloadSpellLinkedSpellCommand, "" },
+ { "spell_pet_auras", rbac::RBAC_PERM_COMMAND_RELOAD_SPELL_PET_AURAS, true, &HandleReloadSpellPetAurasCommand, "" },
+ { "spell_proc_event", rbac::RBAC_PERM_COMMAND_RELOAD_SPELL_PROC_EVENT, true, &HandleReloadSpellProcEventCommand, "" },
+ { "spell_proc", rbac::RBAC_PERM_COMMAND_RELOAD_SPELL_PROC, true, &HandleReloadSpellProcsCommand, "" },
+ { "spell_scripts", rbac::RBAC_PERM_COMMAND_RELOAD_SPELL_SCRIPTS, true, &HandleReloadSpellScriptsCommand, "" },
+ { "spell_target_position", rbac::RBAC_PERM_COMMAND_RELOAD_SPELL_TARGET_POSITION, true, &HandleReloadSpellTargetPositionCommand, "" },
+ { "spell_threats", rbac::RBAC_PERM_COMMAND_RELOAD_SPELL_THREATS, true, &HandleReloadSpellThreatsCommand, "" },
+ { "spell_group_stack_rules", rbac::RBAC_PERM_COMMAND_RELOAD_SPELL_GROUP_STACK_RULES, true, &HandleReloadSpellGroupStackRulesCommand, "" },
+ { "trinity_string", rbac::RBAC_PERM_COMMAND_RELOAD_TRINITY_STRING, true, &HandleReloadTrinityStringCommand, "" },
+ { "warden_action", rbac::RBAC_PERM_COMMAND_RELOAD_WARDEN_ACTION, true, &HandleReloadWardenactionCommand, "" },
+ { "waypoint_scripts", rbac::RBAC_PERM_COMMAND_RELOAD_WAYPOINT_SCRIPTS, true, &HandleReloadWpScriptsCommand, "" },
+ { "waypoint_data", rbac::RBAC_PERM_COMMAND_RELOAD_WAYPOINT_DATA, true, &HandleReloadWpCommand, "" },
+ { "vehicle_accessory", rbac::RBAC_PERM_COMMAND_RELOAD_VEHICLE_ACCESORY, true, &HandleReloadVehicleAccessoryCommand, "" },
+ { "vehicle_template_accessory", rbac::RBAC_PERM_COMMAND_RELOAD_VEHICLE_TEMPLATE_ACCESSORY, true, &HandleReloadVehicleTemplateAccessoryCommand, "" },
};
- static ChatCommand commandTable[] =
+ static std::vector<ChatCommand> commandTable =
{
{ "reload", rbac::RBAC_PERM_COMMAND_RELOAD, true, NULL, "", reloadCommandTable },
- { NULL, 0, false, NULL, "", NULL }
};
return commandTable;
}
diff --git a/src/server/scripts/Commands/cs_reset.cpp b/src/server/scripts/Commands/cs_reset.cpp
index b2bccfd884a..d1c7421b761 100644
--- a/src/server/scripts/Commands/cs_reset.cpp
+++ b/src/server/scripts/Commands/cs_reset.cpp
@@ -35,23 +35,21 @@ class reset_commandscript : public CommandScript
public:
reset_commandscript() : CommandScript("reset_commandscript") { }
- ChatCommand* GetCommands() const override
+ std::vector<ChatCommand> GetCommands() const override
{
- static ChatCommand resetCommandTable[] =
+ static std::vector<ChatCommand> resetCommandTable =
{
- { "achievements", rbac::RBAC_PERM_COMMAND_RESET_ACHIEVEMENTS, true, &HandleResetAchievementsCommand, "", NULL },
- { "honor", rbac::RBAC_PERM_COMMAND_RESET_HONOR, true, &HandleResetHonorCommand, "", NULL },
- { "level", rbac::RBAC_PERM_COMMAND_RESET_LEVEL, true, &HandleResetLevelCommand, "", NULL },
- { "spells", rbac::RBAC_PERM_COMMAND_RESET_SPELLS, true, &HandleResetSpellsCommand, "", NULL },
- { "stats", rbac::RBAC_PERM_COMMAND_RESET_STATS, true, &HandleResetStatsCommand, "", NULL },
- { "talents", rbac::RBAC_PERM_COMMAND_RESET_TALENTS, true, &HandleResetTalentsCommand, "", NULL },
- { "all", rbac::RBAC_PERM_COMMAND_RESET_ALL, true, &HandleResetAllCommand, "", NULL },
- { NULL, 0, false, NULL, "", NULL }
+ { "achievements", rbac::RBAC_PERM_COMMAND_RESET_ACHIEVEMENTS, true, &HandleResetAchievementsCommand, "" },
+ { "honor", rbac::RBAC_PERM_COMMAND_RESET_HONOR, true, &HandleResetHonorCommand, "" },
+ { "level", rbac::RBAC_PERM_COMMAND_RESET_LEVEL, true, &HandleResetLevelCommand, "" },
+ { "spells", rbac::RBAC_PERM_COMMAND_RESET_SPELLS, true, &HandleResetSpellsCommand, "" },
+ { "stats", rbac::RBAC_PERM_COMMAND_RESET_STATS, true, &HandleResetStatsCommand, "" },
+ { "talents", rbac::RBAC_PERM_COMMAND_RESET_TALENTS, true, &HandleResetTalentsCommand, "" },
+ { "all", rbac::RBAC_PERM_COMMAND_RESET_ALL, true, &HandleResetAllCommand, "" },
};
- static ChatCommand commandTable[] =
+ static std::vector<ChatCommand> commandTable =
{
{ "reset", rbac::RBAC_PERM_COMMAND_RESET, true, NULL, "", resetCommandTable },
- { NULL, 0, false, NULL, "", NULL }
};
return commandTable;
}
diff --git a/src/server/scripts/Commands/cs_send.cpp b/src/server/scripts/Commands/cs_send.cpp
index 57ea44a67bf..b7165ed339c 100644
--- a/src/server/scripts/Commands/cs_send.cpp
+++ b/src/server/scripts/Commands/cs_send.cpp
@@ -27,21 +27,19 @@ class send_commandscript : public CommandScript
public:
send_commandscript() : CommandScript("send_commandscript") { }
- ChatCommand* GetCommands() const override
+ std::vector<ChatCommand> GetCommands() const override
{
- static ChatCommand sendCommandTable[] =
+ static std::vector<ChatCommand> sendCommandTable =
{
- { "items", rbac::RBAC_PERM_COMMAND_SEND_ITEMS, true, &HandleSendItemsCommand, "", NULL },
- { "mail", rbac::RBAC_PERM_COMMAND_SEND_MAIL, true, &HandleSendMailCommand, "", NULL },
- { "message", rbac::RBAC_PERM_COMMAND_SEND_MESSAGE, true, &HandleSendMessageCommand, "", NULL },
- { "money", rbac::RBAC_PERM_COMMAND_SEND_MONEY, true, &HandleSendMoneyCommand, "", NULL },
- { NULL, 0, false, NULL, "", NULL }
+ { "items", rbac::RBAC_PERM_COMMAND_SEND_ITEMS, true, &HandleSendItemsCommand, "" },
+ { "mail", rbac::RBAC_PERM_COMMAND_SEND_MAIL, true, &HandleSendMailCommand, "" },
+ { "message", rbac::RBAC_PERM_COMMAND_SEND_MESSAGE, true, &HandleSendMessageCommand, "" },
+ { "money", rbac::RBAC_PERM_COMMAND_SEND_MONEY, true, &HandleSendMoneyCommand, "" },
};
- static ChatCommand commandTable[] =
+ static std::vector<ChatCommand> commandTable =
{
{ "send", rbac::RBAC_PERM_COMMAND_SEND, false, NULL, "", sendCommandTable },
- { NULL, 0, false, NULL, "", NULL }
};
return commandTable;
}
diff --git a/src/server/scripts/Commands/cs_server.cpp b/src/server/scripts/Commands/cs_server.cpp
index fe5ae940f88..e41a7d161d2 100644
--- a/src/server/scripts/Commands/cs_server.cpp
+++ b/src/server/scripts/Commands/cs_server.cpp
@@ -35,64 +35,57 @@ class server_commandscript : public CommandScript
public:
server_commandscript() : CommandScript("server_commandscript") { }
- ChatCommand* GetCommands() const override
+ std::vector<ChatCommand> GetCommands() const override
{
- static ChatCommand serverIdleRestartCommandTable[] =
+ static std::vector<ChatCommand> serverIdleRestartCommandTable =
{
- { "cancel", rbac::RBAC_PERM_COMMAND_SERVER_IDLERESTART_CANCEL, true, &HandleServerShutDownCancelCommand, "", NULL },
- { "" , rbac::RBAC_PERM_COMMAND_SERVER_IDLERESTART, true, &HandleServerIdleRestartCommand, "", NULL },
- { NULL, 0, false, NULL, "", NULL }
+ { "cancel", rbac::RBAC_PERM_COMMAND_SERVER_IDLERESTART_CANCEL, true, &HandleServerShutDownCancelCommand, "" },
+ { "" , rbac::RBAC_PERM_COMMAND_SERVER_IDLERESTART, true, &HandleServerIdleRestartCommand, "" },
};
- static ChatCommand serverIdleShutdownCommandTable[] =
+ static std::vector<ChatCommand> serverIdleShutdownCommandTable =
{
- { "cancel", rbac::RBAC_PERM_COMMAND_SERVER_IDLESHUTDOWN_CANCEL, true, &HandleServerShutDownCancelCommand, "", NULL },
- { "" , rbac::RBAC_PERM_COMMAND_SERVER_IDLESHUTDOWN, true, &HandleServerIdleShutDownCommand, "", NULL },
- { NULL, 0, false, NULL, "", NULL }
+ { "cancel", rbac::RBAC_PERM_COMMAND_SERVER_IDLESHUTDOWN_CANCEL, true, &HandleServerShutDownCancelCommand, "" },
+ { "" , rbac::RBAC_PERM_COMMAND_SERVER_IDLESHUTDOWN, true, &HandleServerIdleShutDownCommand, "" },
};
- static ChatCommand serverRestartCommandTable[] =
+ static std::vector<ChatCommand> serverRestartCommandTable =
{
- { "cancel", rbac::RBAC_PERM_COMMAND_SERVER_RESTART_CANCEL, true, &HandleServerShutDownCancelCommand, "", NULL },
- { "" , rbac::RBAC_PERM_COMMAND_SERVER_RESTART, true, &HandleServerRestartCommand, "", NULL },
- { NULL, 0, false, NULL, "", NULL }
+ { "cancel", rbac::RBAC_PERM_COMMAND_SERVER_RESTART_CANCEL, true, &HandleServerShutDownCancelCommand, "" },
+ { "" , rbac::RBAC_PERM_COMMAND_SERVER_RESTART, true, &HandleServerRestartCommand, "" },
};
- static ChatCommand serverShutdownCommandTable[] =
+ static std::vector<ChatCommand> serverShutdownCommandTable =
{
- { "cancel", rbac::RBAC_PERM_COMMAND_SERVER_SHUTDOWN_CANCEL, true, &HandleServerShutDownCancelCommand, "", NULL },
- { "" , rbac::RBAC_PERM_COMMAND_SERVER_SHUTDOWN, true, &HandleServerShutDownCommand, "", NULL },
- { NULL, 0, false, NULL, "", NULL }
+ { "cancel", rbac::RBAC_PERM_COMMAND_SERVER_SHUTDOWN_CANCEL, true, &HandleServerShutDownCancelCommand, "" },
+ { "" , rbac::RBAC_PERM_COMMAND_SERVER_SHUTDOWN, true, &HandleServerShutDownCommand, "" },
};
- static ChatCommand serverSetCommandTable[] =
+ static std::vector<ChatCommand> serverSetCommandTable =
{
- { "difftime", rbac::RBAC_PERM_COMMAND_SERVER_SET_DIFFTIME, true, &HandleServerSetDiffTimeCommand, "", NULL },
- { "loglevel", rbac::RBAC_PERM_COMMAND_SERVER_SET_LOGLEVEL, true, &HandleServerSetLogLevelCommand, "", NULL },
- { "motd", rbac::RBAC_PERM_COMMAND_SERVER_SET_MOTD, true, &HandleServerSetMotdCommand, "", NULL },
- { "closed", rbac::RBAC_PERM_COMMAND_SERVER_SET_CLOSED, true, &HandleServerSetClosedCommand, "", NULL },
- { NULL, 0, false, NULL, "", NULL }
+ { "difftime", rbac::RBAC_PERM_COMMAND_SERVER_SET_DIFFTIME, true, &HandleServerSetDiffTimeCommand, "" },
+ { "loglevel", rbac::RBAC_PERM_COMMAND_SERVER_SET_LOGLEVEL, true, &HandleServerSetLogLevelCommand, "" },
+ { "motd", rbac::RBAC_PERM_COMMAND_SERVER_SET_MOTD, true, &HandleServerSetMotdCommand, "" },
+ { "closed", rbac::RBAC_PERM_COMMAND_SERVER_SET_CLOSED, true, &HandleServerSetClosedCommand, "" },
};
- static ChatCommand serverCommandTable[] =
+ static std::vector<ChatCommand> serverCommandTable =
{
- { "corpses", rbac::RBAC_PERM_COMMAND_SERVER_CORPSES, true, &HandleServerCorpsesCommand, "", NULL },
- { "exit", rbac::RBAC_PERM_COMMAND_SERVER_EXIT, true, &HandleServerExitCommand, "", NULL },
+ { "corpses", rbac::RBAC_PERM_COMMAND_SERVER_CORPSES, true, &HandleServerCorpsesCommand, "" },
+ { "exit", rbac::RBAC_PERM_COMMAND_SERVER_EXIT, true, &HandleServerExitCommand, "" },
{ "idlerestart", rbac::RBAC_PERM_COMMAND_SERVER_IDLERESTART, true, NULL, "", serverIdleRestartCommandTable },
{ "idleshutdown", rbac::RBAC_PERM_COMMAND_SERVER_IDLESHUTDOWN, true, NULL, "", serverIdleShutdownCommandTable },
- { "info", rbac::RBAC_PERM_COMMAND_SERVER_INFO, true, &HandleServerInfoCommand, "", NULL },
- { "motd", rbac::RBAC_PERM_COMMAND_SERVER_MOTD, true, &HandleServerMotdCommand, "", NULL },
- { "plimit", rbac::RBAC_PERM_COMMAND_SERVER_PLIMIT, true, &HandleServerPLimitCommand, "", NULL },
+ { "info", rbac::RBAC_PERM_COMMAND_SERVER_INFO, true, &HandleServerInfoCommand, "" },
+ { "motd", rbac::RBAC_PERM_COMMAND_SERVER_MOTD, true, &HandleServerMotdCommand, "" },
+ { "plimit", rbac::RBAC_PERM_COMMAND_SERVER_PLIMIT, true, &HandleServerPLimitCommand, "" },
{ "restart", rbac::RBAC_PERM_COMMAND_SERVER_RESTART, true, NULL, "", serverRestartCommandTable },
{ "shutdown", rbac::RBAC_PERM_COMMAND_SERVER_SHUTDOWN, true, NULL, "", serverShutdownCommandTable },
{ "set", rbac::RBAC_PERM_COMMAND_SERVER_SET, true, NULL, "", serverSetCommandTable },
- { NULL, 0, false, NULL, "", NULL }
};
- static ChatCommand commandTable[] =
+ static std::vector<ChatCommand> commandTable =
{
{ "server", rbac::RBAC_PERM_COMMAND_SERVER, true, NULL, "", serverCommandTable },
- { NULL, 0, false, NULL, "", NULL }
};
return commandTable;
}
diff --git a/src/server/scripts/Commands/cs_tele.cpp b/src/server/scripts/Commands/cs_tele.cpp
index 8e82f9980d3..9ea516f0972 100644
--- a/src/server/scripts/Commands/cs_tele.cpp
+++ b/src/server/scripts/Commands/cs_tele.cpp
@@ -35,21 +35,19 @@ class tele_commandscript : public CommandScript
public:
tele_commandscript() : CommandScript("tele_commandscript") { }
- ChatCommand* GetCommands() const override
+ std::vector<ChatCommand> GetCommands() const override
{
- static ChatCommand teleCommandTable[] =
+ static std::vector<ChatCommand> teleCommandTable =
{
- { "add", rbac::RBAC_PERM_COMMAND_TELE_ADD, false, &HandleTeleAddCommand, "", NULL },
- { "del", rbac::RBAC_PERM_COMMAND_TELE_DEL, true, &HandleTeleDelCommand, "", NULL },
- { "name", rbac::RBAC_PERM_COMMAND_TELE_NAME, true, &HandleTeleNameCommand, "", NULL },
- { "group", rbac::RBAC_PERM_COMMAND_TELE_GROUP, false, &HandleTeleGroupCommand, "", NULL },
- { "", rbac::RBAC_PERM_COMMAND_TELE, false, &HandleTeleCommand, "", NULL },
- { NULL, 0, false, NULL, "", NULL }
+ { "add", rbac::RBAC_PERM_COMMAND_TELE_ADD, false, &HandleTeleAddCommand, "" },
+ { "del", rbac::RBAC_PERM_COMMAND_TELE_DEL, true, &HandleTeleDelCommand, "" },
+ { "name", rbac::RBAC_PERM_COMMAND_TELE_NAME, true, &HandleTeleNameCommand, "" },
+ { "group", rbac::RBAC_PERM_COMMAND_TELE_GROUP, false, &HandleTeleGroupCommand, "" },
+ { "", rbac::RBAC_PERM_COMMAND_TELE, false, &HandleTeleCommand, "" },
};
- static ChatCommand commandTable[] =
+ static std::vector<ChatCommand> commandTable =
{
{ "tele", rbac::RBAC_PERM_COMMAND_TELE, false, NULL, "", teleCommandTable },
- { NULL, 0, false, NULL, "", NULL }
};
return commandTable;
}
diff --git a/src/server/scripts/Commands/cs_ticket.cpp b/src/server/scripts/Commands/cs_ticket.cpp
index f7634381fc9..a9baa45f344 100644
--- a/src/server/scripts/Commands/cs_ticket.cpp
+++ b/src/server/scripts/Commands/cs_ticket.cpp
@@ -36,38 +36,35 @@ class ticket_commandscript : public CommandScript
public:
ticket_commandscript() : CommandScript("ticket_commandscript") { }
- ChatCommand* GetCommands() const override
+ std::vector<ChatCommand> GetCommands() const override
{
- static ChatCommand ticketResponseCommandTable[] =
+ static std::vector<ChatCommand> ticketResponseCommandTable =
{
- { "append", rbac::RBAC_PERM_COMMAND_TICKET_RESPONSE_APPEND, true, &HandleGMTicketResponseAppendCommand, "", NULL },
- { "appendln", rbac::RBAC_PERM_COMMAND_TICKET_RESPONSE_APPENDLN, true, &HandleGMTicketResponseAppendLnCommand, "", NULL },
- { NULL, 0, false, NULL, "", NULL }
+ { "append", rbac::RBAC_PERM_COMMAND_TICKET_RESPONSE_APPEND, true, &HandleGMTicketResponseAppendCommand, "" },
+ { "appendln", rbac::RBAC_PERM_COMMAND_TICKET_RESPONSE_APPENDLN, true, &HandleGMTicketResponseAppendLnCommand, "" },
};
- static ChatCommand ticketCommandTable[] =
+ static std::vector<ChatCommand> ticketCommandTable =
{
- { "assign", rbac::RBAC_PERM_COMMAND_TICKET_ASSIGN, true, &HandleGMTicketAssignToCommand, "", NULL },
- { "close", rbac::RBAC_PERM_COMMAND_TICKET_CLOSE, true, &HandleGMTicketCloseByIdCommand, "", NULL },
- { "closedlist", rbac::RBAC_PERM_COMMAND_TICKET_CLOSEDLIST, true, &HandleGMTicketListClosedCommand, "", NULL },
- { "comment", rbac::RBAC_PERM_COMMAND_TICKET_COMMENT, true, &HandleGMTicketCommentCommand, "", NULL },
- { "complete", rbac::RBAC_PERM_COMMAND_TICKET_COMPLETE, true, &HandleGMTicketCompleteCommand, "", NULL },
- { "delete", rbac::RBAC_PERM_COMMAND_TICKET_DELETE, true, &HandleGMTicketDeleteByIdCommand, "", NULL },
- { "escalate", rbac::RBAC_PERM_COMMAND_TICKET_ESCALATE, true, &HandleGMTicketEscalateCommand, "", NULL },
- { "escalatedlist", rbac::RBAC_PERM_COMMAND_TICKET_ESCALATEDLIST, true, &HandleGMTicketListEscalatedCommand, "", NULL },
- { "list", rbac::RBAC_PERM_COMMAND_TICKET_LIST, true, &HandleGMTicketListCommand, "", NULL },
- { "onlinelist", rbac::RBAC_PERM_COMMAND_TICKET_ONLINELIST, true, &HandleGMTicketListOnlineCommand, "", NULL },
- { "reset", rbac::RBAC_PERM_COMMAND_TICKET_RESET, true, &HandleGMTicketResetCommand, "", NULL },
+ { "assign", rbac::RBAC_PERM_COMMAND_TICKET_ASSIGN, true, &HandleGMTicketAssignToCommand, "" },
+ { "close", rbac::RBAC_PERM_COMMAND_TICKET_CLOSE, true, &HandleGMTicketCloseByIdCommand, "" },
+ { "closedlist", rbac::RBAC_PERM_COMMAND_TICKET_CLOSEDLIST, true, &HandleGMTicketListClosedCommand, "" },
+ { "comment", rbac::RBAC_PERM_COMMAND_TICKET_COMMENT, true, &HandleGMTicketCommentCommand, "" },
+ { "complete", rbac::RBAC_PERM_COMMAND_TICKET_COMPLETE, true, &HandleGMTicketCompleteCommand, "" },
+ { "delete", rbac::RBAC_PERM_COMMAND_TICKET_DELETE, true, &HandleGMTicketDeleteByIdCommand, "" },
+ { "escalate", rbac::RBAC_PERM_COMMAND_TICKET_ESCALATE, true, &HandleGMTicketEscalateCommand, "" },
+ { "escalatedlist", rbac::RBAC_PERM_COMMAND_TICKET_ESCALATEDLIST, true, &HandleGMTicketListEscalatedCommand, "" },
+ { "list", rbac::RBAC_PERM_COMMAND_TICKET_LIST, true, &HandleGMTicketListCommand, "" },
+ { "onlinelist", rbac::RBAC_PERM_COMMAND_TICKET_ONLINELIST, true, &HandleGMTicketListOnlineCommand, "" },
+ { "reset", rbac::RBAC_PERM_COMMAND_TICKET_RESET, true, &HandleGMTicketResetCommand, "" },
{ "response", rbac::RBAC_PERM_COMMAND_TICKET_RESPONSE, true, NULL, "", ticketResponseCommandTable },
- { "togglesystem", rbac::RBAC_PERM_COMMAND_TICKET_TOGGLESYSTEM, true, &HandleToggleGMTicketSystem, "", NULL },
- { "unassign", rbac::RBAC_PERM_COMMAND_TICKET_UNASSIGN, true, &HandleGMTicketUnAssignCommand, "", NULL },
- { "viewid", rbac::RBAC_PERM_COMMAND_TICKET_VIEWID, true, &HandleGMTicketGetByIdCommand, "", NULL },
- { "viewname", rbac::RBAC_PERM_COMMAND_TICKET_VIEWNAME, true, &HandleGMTicketGetByNameCommand, "", NULL },
- { NULL, 0, false, NULL, "", NULL }
+ { "togglesystem", rbac::RBAC_PERM_COMMAND_TICKET_TOGGLESYSTEM, true, &HandleToggleGMTicketSystem, "" },
+ { "unassign", rbac::RBAC_PERM_COMMAND_TICKET_UNASSIGN, true, &HandleGMTicketUnAssignCommand, "" },
+ { "viewid", rbac::RBAC_PERM_COMMAND_TICKET_VIEWID, true, &HandleGMTicketGetByIdCommand, "" },
+ { "viewname", rbac::RBAC_PERM_COMMAND_TICKET_VIEWNAME, true, &HandleGMTicketGetByNameCommand, "" },
};
- static ChatCommand commandTable[] =
+ static std::vector<ChatCommand> commandTable =
{
{ "ticket", rbac::RBAC_PERM_COMMAND_TICKET, false, NULL, "", ticketCommandTable },
- { NULL, 0, false, NULL, "", NULL }
};
return commandTable;
}
@@ -153,7 +150,7 @@ public:
return true;
}
- sTicketMgr->ResolveAndCloseTicket(ticket->GetId(), player ? player->GetGUID() : ObjectGuid(uint64(-1)));
+ sTicketMgr->ResolveAndCloseTicket(ticket->GetId(), player ? player->GetGUID() : ObjectGuid(uint64(0)));
sTicketMgr->UpdateLastChange();
std::string msg = ticket->FormatMessageString(*handler, player ? player->GetName().c_str() : "Console", NULL, NULL, NULL, NULL);
@@ -251,7 +248,7 @@ public:
Player* gm = handler->GetSession() ? handler->GetSession()->GetPlayer() : nullptr;
SQLTransaction trans = SQLTransaction(NULL);
- ticket->SetResolvedBy(gm ? gm->GetGUID() : ObjectGuid(uint64(-1)));
+ ticket->SetResolvedBy(gm ? gm->GetGUID() : ObjectGuid(uint64(0)));
ticket->SetCompleted();
ticket->SaveToDB(trans);
diff --git a/src/server/scripts/Commands/cs_titles.cpp b/src/server/scripts/Commands/cs_titles.cpp
index 74a2f9f5aaf..bc6027ce3c3 100644
--- a/src/server/scripts/Commands/cs_titles.cpp
+++ b/src/server/scripts/Commands/cs_titles.cpp
@@ -33,25 +33,22 @@ class titles_commandscript : public CommandScript
public:
titles_commandscript() : CommandScript("titles_commandscript") { }
- ChatCommand* GetCommands() const override
+ std::vector<ChatCommand> GetCommands() const override
{
- static ChatCommand titlesSetCommandTable[] =
+ static std::vector<ChatCommand> titlesSetCommandTable =
{
- { "mask", rbac::RBAC_PERM_COMMAND_TITLES_SET_MASK, false, &HandleTitlesSetMaskCommand, "", NULL },
- { NULL, 0, false, NULL, "", NULL }
+ { "mask", rbac::RBAC_PERM_COMMAND_TITLES_SET_MASK, false, &HandleTitlesSetMaskCommand, "" },
};
- static ChatCommand titlesCommandTable[] =
+ static std::vector<ChatCommand> titlesCommandTable =
{
- { "add", rbac::RBAC_PERM_COMMAND_TITLES_ADD, false, &HandleTitlesAddCommand, "", NULL },
- { "current", rbac::RBAC_PERM_COMMAND_TITLES_CURRENT, false, &HandleTitlesCurrentCommand, "", NULL },
- { "remove", rbac::RBAC_PERM_COMMAND_TITLES_REMOVE, false, &HandleTitlesRemoveCommand, "", NULL },
+ { "add", rbac::RBAC_PERM_COMMAND_TITLES_ADD, false, &HandleTitlesAddCommand, "" },
+ { "current", rbac::RBAC_PERM_COMMAND_TITLES_CURRENT, false, &HandleTitlesCurrentCommand, "" },
+ { "remove", rbac::RBAC_PERM_COMMAND_TITLES_REMOVE, false, &HandleTitlesRemoveCommand, "" },
{ "set", rbac::RBAC_PERM_COMMAND_TITLES_SET, false, NULL, "", titlesSetCommandTable },
- { NULL, 0, false, NULL, "", NULL }
};
- static ChatCommand commandTable[] =
+ static std::vector<ChatCommand> commandTable =
{
{ "titles", rbac::RBAC_PERM_COMMAND_TITLES, false, NULL, "", titlesCommandTable },
- { NULL, 0, false, NULL, "", NULL }
};
return commandTable;
}
diff --git a/src/server/scripts/Commands/cs_wp.cpp b/src/server/scripts/Commands/cs_wp.cpp
index 9db1e5d68d8..b35e71dbd50 100644
--- a/src/server/scripts/Commands/cs_wp.cpp
+++ b/src/server/scripts/Commands/cs_wp.cpp
@@ -34,23 +34,21 @@ class wp_commandscript : public CommandScript
public:
wp_commandscript() : CommandScript("wp_commandscript") { }
- ChatCommand* GetCommands() const override
+ std::vector<ChatCommand> GetCommands() const override
{
- static ChatCommand wpCommandTable[] =
+ static std::vector<ChatCommand> wpCommandTable =
{
- { "add", rbac::RBAC_PERM_COMMAND_WP_ADD, false, &HandleWpAddCommand, "", NULL },
- { "event", rbac::RBAC_PERM_COMMAND_WP_EVENT, false, &HandleWpEventCommand, "", NULL },
- { "load", rbac::RBAC_PERM_COMMAND_WP_LOAD, false, &HandleWpLoadCommand, "", NULL },
- { "modify", rbac::RBAC_PERM_COMMAND_WP_MODIFY, false, &HandleWpModifyCommand, "", NULL },
- { "unload", rbac::RBAC_PERM_COMMAND_WP_UNLOAD, false, &HandleWpUnLoadCommand, "", NULL },
- { "reload", rbac::RBAC_PERM_COMMAND_WP_RELOAD, false, &HandleWpReloadCommand, "", NULL },
- { "show", rbac::RBAC_PERM_COMMAND_WP_SHOW, false, &HandleWpShowCommand, "", NULL },
- { NULL, 0, false, NULL, "", NULL }
+ { "add", rbac::RBAC_PERM_COMMAND_WP_ADD, false, &HandleWpAddCommand, "" },
+ { "event", rbac::RBAC_PERM_COMMAND_WP_EVENT, false, &HandleWpEventCommand, "" },
+ { "load", rbac::RBAC_PERM_COMMAND_WP_LOAD, false, &HandleWpLoadCommand, "" },
+ { "modify", rbac::RBAC_PERM_COMMAND_WP_MODIFY, false, &HandleWpModifyCommand, "" },
+ { "unload", rbac::RBAC_PERM_COMMAND_WP_UNLOAD, false, &HandleWpUnLoadCommand, "" },
+ { "reload", rbac::RBAC_PERM_COMMAND_WP_RELOAD, false, &HandleWpReloadCommand, "" },
+ { "show", rbac::RBAC_PERM_COMMAND_WP_SHOW, false, &HandleWpShowCommand, "" },
};
- static ChatCommand commandTable[] =
+ static std::vector<ChatCommand> commandTable =
{
{ "wp", rbac::RBAC_PERM_COMMAND_WP, false, NULL, "", wpCommandTable },
- { NULL, 0, false, NULL, "", NULL }
};
return commandTable;
}
diff --git a/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockDepths/boss_anubshiah.cpp b/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockDepths/boss_anubshiah.cpp
deleted file mode 100644
index c2261785782..00000000000
--- a/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockDepths/boss_anubshiah.cpp
+++ /dev/null
@@ -1,116 +0,0 @@
-/*
- * Copyright (C) 2008-2015 TrinityCore <http://www.trinitycore.org/>
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "ScriptMgr.h"
-#include "ScriptedCreature.h"
-
-enum Spells
-{
- SPELL_SHADOWBOLT = 17228,
- SPELL_CURSEOFTONGUES = 15470,
- SPELL_CURSEOFWEAKNESS = 17227,
- SPELL_DEMONARMOR = 11735,
- SPELL_ENVELOPINGWEB = 15471
-};
-
-enum Events
-{
- EVENT_SHADOWBOLT = 1,
- EVENT_CURSE_OF_TONGUES = 2,
- EVENT_CURSE_OF_WEAKNESS = 3,
- EVENT_DEMON_ARMOR = 4,
- EVENT_ENVELOPING_WEB = 5
-};
-
-class boss_anubshiah : public CreatureScript
-{
- public:
- boss_anubshiah() : CreatureScript("boss_anubshiah") { }
-
- struct boss_anubshiahAI : public ScriptedAI
- {
- boss_anubshiahAI(Creature* creature) : ScriptedAI(creature) { }
-
- void Reset() override
- {
- _events.Reset();
- }
-
- void EnterCombat(Unit* /*who*/) override
- {
- _events.ScheduleEvent(EVENT_SHADOWBOLT, 7000);
- _events.ScheduleEvent(EVENT_CURSE_OF_TONGUES, 24000);
- _events.ScheduleEvent(EVENT_CURSE_OF_WEAKNESS, 12000);
- _events.ScheduleEvent(EVENT_DEMON_ARMOR, 3000);
- _events.ScheduleEvent(EVENT_ENVELOPING_WEB, 16000);
- }
-
- void UpdateAI(uint32 diff) override
- {
- if (!UpdateVictim())
- return;
-
- _events.Update(diff);
-
- while (uint32 eventId = _events.ExecuteEvent())
- {
- switch (eventId)
- {
- case EVENT_SHADOWBOLT:
- DoCast(me, SPELL_SHADOWBOLT);
- _events.ScheduleEvent(EVENT_SHADOWBOLT, 7000);
- break;
- case EVENT_CURSE_OF_TONGUES:
- if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 100, true))
- DoCast(target, SPELL_CURSEOFTONGUES);
- _events.ScheduleEvent(EVENT_CURSE_OF_TONGUES, 18000);
- break;
- case EVENT_CURSE_OF_WEAKNESS:
- DoCastVictim(SPELL_CURSEOFWEAKNESS);
- _events.ScheduleEvent(EVENT_CURSE_OF_WEAKNESS, 45000);
- break;
- case EVENT_DEMON_ARMOR:
- DoCast(me, SPELL_DEMONARMOR);
- _events.ScheduleEvent(EVENT_DEMON_ARMOR, 300000);
- break;
- case EVENT_ENVELOPING_WEB:
- if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 100, true))
- DoCast(target, SPELL_ENVELOPINGWEB);
- _events.ScheduleEvent(EVENT_ENVELOPING_WEB, 12000);
- break;
- default:
- break;
- }
- }
-
- DoMeleeAttackIfReady();
- }
-
- private:
- EventMap _events;
- };
-
- CreatureAI* GetAI(Creature* creature) const override
- {
- return new boss_anubshiahAI(creature);
- }
-};
-
-void AddSC_boss_anubshiah()
-{
- new boss_anubshiah();
-}
diff --git a/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockDepths/boss_gorosh_the_dervish.cpp b/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockDepths/boss_gorosh_the_dervish.cpp
deleted file mode 100644
index 83702ffb16d..00000000000
--- a/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockDepths/boss_gorosh_the_dervish.cpp
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * Copyright (C) 2008-2015 TrinityCore <http://www.trinitycore.org/>
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "ScriptMgr.h"
-#include "ScriptedCreature.h"
-
-enum Spells
-{
- SPELL_WHIRLWIND = 15589,
- SPELL_MORTALSTRIKE = 24573
-};
-
-enum Events
-{
- EVENT_WHIRLWIND = 1,
- EVENT_MORTALSTRIKE = 2
-};
-
-class boss_gorosh_the_dervish : public CreatureScript
-{
- public:
- boss_gorosh_the_dervish() : CreatureScript("boss_gorosh_the_dervish") { }
-
- struct boss_gorosh_the_dervishAI : public ScriptedAI
- {
- boss_gorosh_the_dervishAI(Creature* creature) : ScriptedAI(creature) { }
-
- void Reset() override
- {
- _events.Reset();
- }
-
- void EnterCombat(Unit* /*who*/) override
- {
- _events.ScheduleEvent(EVENT_WHIRLWIND, 12000);
- _events.ScheduleEvent(EVENT_MORTALSTRIKE, 22000);
- }
-
- void UpdateAI(uint32 diff) override
- {
- if (!UpdateVictim())
- return;
-
- _events.Update(diff);
-
- while (uint32 eventId = _events.ExecuteEvent())
- {
- switch (eventId)
- {
- case EVENT_WHIRLWIND:
- DoCast(me, SPELL_WHIRLWIND);
- _events.ScheduleEvent(EVENT_WHIRLWIND, 15000);
- break;
- case EVENT_MORTALSTRIKE:
- DoCastVictim(SPELL_MORTALSTRIKE);
- _events.ScheduleEvent(EVENT_MORTALSTRIKE, 15000);
- break;
- default:
- break;
- }
- }
-
- DoMeleeAttackIfReady();
- }
-
- private:
- EventMap _events;
- };
-
- CreatureAI* GetAI(Creature* creature) const override
- {
- return new boss_gorosh_the_dervishAI(creature);
- }
-};
-
-void AddSC_boss_gorosh_the_dervish()
-{
- new boss_gorosh_the_dervish();
-}
diff --git a/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockDepths/boss_grizzle.cpp b/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockDepths/boss_grizzle.cpp
deleted file mode 100644
index 44dbbe3f4c2..00000000000
--- a/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockDepths/boss_grizzle.cpp
+++ /dev/null
@@ -1,110 +0,0 @@
-/*
- * Copyright (C) 2008-2015 TrinityCore <http://www.trinitycore.org/>
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "ScriptMgr.h"
-#include "ScriptedCreature.h"
-
-enum Grizzle
-{
- SPELL_GROUNDTREMOR = 6524,
- SPELL_FRENZY = 28371,
- EMOTE_FRENZY_KILL = 0
-};
-
-enum Events
-{
- EVENT_GROUNDTREMOR = 1,
- EVENT_FRENZY = 2
-};
-
-enum Phases
-{
- PHASE_ONE = 1,
- PHASE_TWO = 2
-};
-
-class boss_grizzle : public CreatureScript
-{
- public:
- boss_grizzle() : CreatureScript("boss_grizzle") { }
-
- struct boss_grizzleAI : public ScriptedAI
- {
- boss_grizzleAI(Creature* creature) : ScriptedAI(creature) { }
-
- void Reset() override
- {
- _events.Reset();
- }
-
- void EnterCombat(Unit* /*who*/) override
- {
- _events.SetPhase(PHASE_ONE);
- _events.ScheduleEvent(EVENT_GROUNDTREMOR, 12000);
- }
-
- void DamageTaken(Unit* /*attacker*/, uint32& damage) override
- {
- if (me->HealthBelowPctDamaged(50, damage) && _events.IsInPhase(PHASE_ONE))
- {
- _events.SetPhase(PHASE_TWO);
- _events.ScheduleEvent(EVENT_FRENZY, 0, 0, PHASE_TWO);
- }
- }
-
- void UpdateAI(uint32 diff) override
- {
- if (!UpdateVictim())
- return;
-
- _events.Update(diff);
-
- while (uint32 eventId = _events.ExecuteEvent())
- {
- switch (eventId)
- {
- case EVENT_GROUNDTREMOR:
- DoCastVictim(SPELL_GROUNDTREMOR);
- _events.ScheduleEvent(EVENT_GROUNDTREMOR, 8000);
- break;
- case EVENT_FRENZY:
- DoCast(me, SPELL_FRENZY);
- Talk(EMOTE_FRENZY_KILL);
- _events.ScheduleEvent(EVENT_FRENZY, 15000, 0, PHASE_TWO);
- break;
- default:
- break;
- }
- }
-
- DoMeleeAttackIfReady();
- }
-
- private:
- EventMap _events;
- };
-
- CreatureAI* GetAI(Creature* creature) const override
- {
- return new boss_grizzleAI(creature);
- }
-};
-
-void AddSC_boss_grizzle()
-{
- new boss_grizzle();
-}
diff --git a/src/server/scripts/EasternKingdoms/CMakeLists.txt b/src/server/scripts/EasternKingdoms/CMakeLists.txt
index fdebfca7979..76e4d36e0a9 100644
--- a/src/server/scripts/EasternKingdoms/CMakeLists.txt
+++ b/src/server/scripts/EasternKingdoms/CMakeLists.txt
@@ -17,12 +17,9 @@ set(scripts_STAT_SRCS
EasternKingdoms/AlteracValley/boss_vanndar.cpp
EasternKingdoms/AlteracValley/alterac_valley.cpp
EasternKingdoms/BlackrockMountain/BlackrockDepths/boss_high_interrogator_gerstahn.cpp
- EasternKingdoms/BlackrockMountain/BlackrockDepths/boss_gorosh_the_dervish.cpp
EasternKingdoms/BlackrockMountain/BlackrockDepths/blackrock_depths.cpp
- EasternKingdoms/BlackrockMountain/BlackrockDepths/boss_anubshiah.cpp
EasternKingdoms/BlackrockMountain/BlackrockDepths/boss_tomb_of_seven.cpp
EasternKingdoms/BlackrockMountain/BlackrockDepths/boss_general_angerforge.cpp
- EasternKingdoms/BlackrockMountain/BlackrockDepths/boss_grizzle.cpp
EasternKingdoms/BlackrockMountain/BlackrockDepths/boss_ambassador_flamelash.cpp
EasternKingdoms/BlackrockMountain/BlackrockDepths/instance_blackrock_depths.cpp
EasternKingdoms/BlackrockMountain/BlackrockDepths/boss_moira_bronzebeard.cpp
diff --git a/src/server/scripts/EasternKingdoms/Gnomeregan/gnomeregan.cpp b/src/server/scripts/EasternKingdoms/Gnomeregan/gnomeregan.cpp
index 64513fece8b..c1470d3bc47 100644
--- a/src/server/scripts/EasternKingdoms/Gnomeregan/gnomeregan.cpp
+++ b/src/server/scripts/EasternKingdoms/Gnomeregan/gnomeregan.cpp
@@ -203,10 +203,6 @@ public:
void AggroAllPlayers(Creature* temp)
{
Map::PlayerList const &PlList = me->GetMap()->GetPlayers();
-
- if (PlList.isEmpty())
- return;
-
for (Map::PlayerList::const_iterator i = PlList.begin(); i != PlList.end(); ++i)
{
if (Player* player = i->GetSource())
diff --git a/src/server/scripts/EasternKingdoms/Karazhan/boss_netherspite.cpp b/src/server/scripts/EasternKingdoms/Karazhan/boss_netherspite.cpp
index 8965b64767a..0a287173ada 100644
--- a/src/server/scripts/EasternKingdoms/Karazhan/boss_netherspite.cpp
+++ b/src/server/scripts/EasternKingdoms/Karazhan/boss_netherspite.cpp
@@ -181,23 +181,21 @@ public:
// temporary store for the best suitable beam reciever
Unit* target = me;
- if (Map* map = me->GetMap())
- {
- Map::PlayerList const& players = map->GetPlayers();
+ Map::PlayerList const& players = me->GetMap()->GetPlayers();
- // get the best suitable target
- for (Map::PlayerList::const_iterator i = players.begin(); i != players.end(); ++i)
- {
- Player* p = i->GetSource();
- if (p && p->IsAlive() // alive
- && (!target || target->GetDistance2d(portal)>p->GetDistance2d(portal)) // closer than current best
- && !p->HasAura(PlayerDebuff[j]) // not exhausted
- && !p->HasAura(PlayerBuff[(j + 1) % 3]) // not on another beam
- && !p->HasAura(PlayerBuff[(j + 2) % 3])
- && IsBetween(me, p, portal)) // on the beam
- target = p;
- }
+ // get the best suitable target
+ for (Map::PlayerList::const_iterator i = players.begin(); i != players.end(); ++i)
+ {
+ Player* p = i->GetSource();
+ if (p && p->IsAlive() // alive
+ && (!target || target->GetDistance2d(portal)>p->GetDistance2d(portal)) // closer than current best
+ && !p->HasAura(PlayerDebuff[j]) // not exhausted
+ && !p->HasAura(PlayerBuff[(j + 1) % 3]) // not on another beam
+ && !p->HasAura(PlayerBuff[(j + 2) % 3])
+ && IsBetween(me, p, portal)) // on the beam
+ target = p;
}
+
// buff the target
if (target->GetTypeId() == TYPEID_PLAYER)
target->AddAura(PlayerBuff[j], target);
diff --git a/src/server/scripts/EasternKingdoms/Karazhan/karazhan.cpp b/src/server/scripts/EasternKingdoms/Karazhan/karazhan.cpp
index 87945ccf916..8aba0a15462 100644
--- a/src/server/scripts/EasternKingdoms/Karazhan/karazhan.cpp
+++ b/src/server/scripts/EasternKingdoms/Karazhan/karazhan.cpp
@@ -309,11 +309,7 @@ public:
{
if (WipeTimer <= diff)
{
- Map* map = me->GetMap();
- if (!map->IsDungeon())
- return;
-
- Map::PlayerList const &PlayerList = map->GetPlayers();
+ Map::PlayerList const &PlayerList = me->GetMap()->GetPlayers();
if (PlayerList.isEmpty())
return;
@@ -518,8 +514,6 @@ public:
uint32 NextStep(uint32 step)
{
- Creature* arca = ObjectAccessor::GetCreature(*me, ArcanagosGUID);
- Map* map = me->GetMap();
switch (step)
{
case 0: return 9999999;
@@ -527,21 +521,21 @@ public:
me->Yell(SAY_DIALOG_MEDIVH_1, LANG_UNIVERSAL);
return 10000;
case 2:
- if (arca)
+ if (Creature* arca = ObjectAccessor::GetCreature(*me, ArcanagosGUID))
arca->Yell(SAY_DIALOG_ARCANAGOS_2, LANG_UNIVERSAL);
return 20000;
case 3:
me->Yell(SAY_DIALOG_MEDIVH_3, LANG_UNIVERSAL);
return 10000;
case 4:
- if (arca)
+ if (Creature* arca = ObjectAccessor::GetCreature(*me, ArcanagosGUID))
arca->Yell(SAY_DIALOG_ARCANAGOS_4, LANG_UNIVERSAL);
return 20000;
case 5:
me->Yell(SAY_DIALOG_MEDIVH_5, LANG_UNIVERSAL);
return 20000;
case 6:
- if (arca)
+ if (Creature* arca = ObjectAccessor::GetCreature(*me, ArcanagosGUID))
arca->Yell(SAY_DIALOG_ARCANAGOS_6, LANG_UNIVERSAL);
return 10000;
case 7:
@@ -555,15 +549,15 @@ public:
me->TextEmote(EMOTE_DIALOG_MEDIVH_7);
return 10000;
case 10:
- if (arca)
+ if (Creature* arca = ObjectAccessor::GetCreature(*me, ArcanagosGUID))
DoCast(arca, SPELL_CONFLAGRATION_BLAST, false);
return 1000;
case 11:
- if (arca)
+ if (Creature* arca = ObjectAccessor::GetCreature(*me, ArcanagosGUID))
arca->Yell(SAY_DIALOG_ARCANAGOS_8, LANG_UNIVERSAL);
return 5000;
case 12:
- if (arca)
+ if (Creature* arca = ObjectAccessor::GetCreature(*me, ArcanagosGUID))
{
arca->GetMotionMaster()->MovePoint(0, -11010.82f, -1761.18f, 156.47f);
arca->setActive(true);
@@ -575,27 +569,27 @@ public:
me->Yell(SAY_DIALOG_MEDIVH_9, LANG_UNIVERSAL);
return 10000;
case 14:
+ {
me->SetVisible(false);
me->ClearInCombat();
- if (map->IsDungeon())
+ InstanceMap::PlayerList const &PlayerList = me->GetMap()->GetPlayers();
+ for (InstanceMap::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i)
{
- InstanceMap::PlayerList const &PlayerList = map->GetPlayers();
- for (InstanceMap::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i)
+ if (i->GetSource()->IsAlive())
{
- if (i->GetSource()->IsAlive())
- {
- if (i->GetSource()->GetQuestStatus(9645) == QUEST_STATUS_INCOMPLETE)
- i->GetSource()->CompleteQuest(9645);
- }
+ if (i->GetSource()->GetQuestStatus(9645) == QUEST_STATUS_INCOMPLETE)
+ i->GetSource()->CompleteQuest(9645);
}
}
return 50000;
+ }
case 15:
- if (arca)
+ if (Creature* arca = ObjectAccessor::GetCreature(*me, ArcanagosGUID))
arca->DealDamage(arca, arca->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false);
return 5000;
- default : return 9999999;
+ default:
+ return 9999999;
}
}
diff --git a/src/server/scripts/EasternKingdoms/MagistersTerrace/magisters_terrace.cpp b/src/server/scripts/EasternKingdoms/MagistersTerrace/magisters_terrace.cpp
index 9b303fce89d..9c904dcada9 100644
--- a/src/server/scripts/EasternKingdoms/MagistersTerrace/magisters_terrace.cpp
+++ b/src/server/scripts/EasternKingdoms/MagistersTerrace/magisters_terrace.cpp
@@ -145,39 +145,13 @@ public:
m_uiTransformTimer = MINUTE*IN_MILLISECONDS;
}
- // some targeting issues with the spell, so use this workaround as temporary solution
- void DoWorkaroundForQuestCredit()
- {
- Map* map = me->GetMap();
-
- if (!map || map->IsHeroic())
- return;
-
- Map::PlayerList const &lList = map->GetPlayers();
-
- if (lList.isEmpty())
- return;
-
- SpellInfo const* spell = sSpellMgr->GetSpellInfo(SPELL_ORB_KILL_CREDIT);
-
- for (Map::PlayerList::const_iterator i = lList.begin(); i != lList.end(); ++i)
- {
- if (Player* player = i->GetSource())
- {
- if (spell && spell->Effects[0].MiscValue)
- player->KilledMonsterCredit(spell->Effects[0].MiscValue);
- }
- }
- }
-
void UpdateAI(uint32 uiDiff) override
{
if (m_uiTransformTimer)
{
if (m_uiTransformTimer <= uiDiff)
{
- DoCast(me, SPELL_ORB_KILL_CREDIT, false);
- DoWorkaroundForQuestCredit();
+ DoCast(me, SPELL_ORB_KILL_CREDIT, true);
// Transform and update entry, now ready for quest/read gossip
DoCast(me, SPELL_TRANSFORM_TO_KAEL, false);
diff --git a/src/server/scripts/EasternKingdoms/ScarletEnclave/chapter5.cpp b/src/server/scripts/EasternKingdoms/ScarletEnclave/chapter5.cpp
index 3df07562d50..2714d65774f 100644
--- a/src/server/scripts/EasternKingdoms/ScarletEnclave/chapter5.cpp
+++ b/src/server/scripts/EasternKingdoms/ScarletEnclave/chapter5.cpp
@@ -1293,8 +1293,8 @@ public:
//if (GameObject* go = me->GetMap()->GetGameObject(uiDawnofLightGUID)) // Turn off dawn of light
// go->SetPhaseMask(0, true);
{
- Map* map = me->GetMap(); // search players with in 50 yards for quest credit
- Map::PlayerList const &PlayerList = map->GetPlayers();
+ // search players with in 50 yards for quest credit
+ Map::PlayerList const &PlayerList = me->GetMap()->GetPlayers();
if (!PlayerList.isEmpty())
{
for (Map::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i)
diff --git a/src/server/scripts/EasternKingdoms/ScarletMonastery/boss_headless_horseman.cpp b/src/server/scripts/EasternKingdoms/ScarletMonastery/boss_headless_horseman.cpp
index 14be8c51bc2..a78ad740c97 100644
--- a/src/server/scripts/EasternKingdoms/ScarletMonastery/boss_headless_horseman.cpp
+++ b/src/server/scripts/EasternKingdoms/ScarletMonastery/boss_headless_horseman.cpp
@@ -538,11 +538,7 @@ public:
Player* SelectRandomPlayer(float range = 0.0f, bool checkLoS = true)
{
- Map* map = me->GetMap();
- if (!map->IsDungeon())
- return NULL;
-
- Map::PlayerList const &PlayerList = map->GetPlayers();
+ Map::PlayerList const &PlayerList = me->GetMap()->GetPlayers();
if (PlayerList.isEmpty())
return NULL;
diff --git a/src/server/scripts/EasternKingdoms/Stratholme/boss_baron_rivendare.cpp b/src/server/scripts/EasternKingdoms/Stratholme/boss_baron_rivendare.cpp
index 8d7d43048b4..f6f6dab866d 100644
--- a/src/server/scripts/EasternKingdoms/Stratholme/boss_baron_rivendare.cpp
+++ b/src/server/scripts/EasternKingdoms/Stratholme/boss_baron_rivendare.cpp
@@ -106,7 +106,8 @@ public:
void AttackStart(Unit* who) override
{
//can't use entercombat(), boss' dmg aura sets near players in combat, before entering the room's door
- instance->SetData(TYPE_BARON, IN_PROGRESS);
+ if (instance->GetData(TYPE_BARON) == NOT_STARTED)
+ instance->SetData(TYPE_BARON, IN_PROGRESS);
ScriptedAI::AttackStart(who);
}
diff --git a/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_kalecgos.cpp b/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_kalecgos.cpp
index ae327dbb874..c8964b2ff31 100644
--- a/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_kalecgos.cpp
+++ b/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_kalecgos.cpp
@@ -551,13 +551,9 @@ public:
bool OnGossipHello(Player* player, GameObject* go) override
{
- Map* map = go->GetMap();
- if (!map->IsDungeon())
- return true;
-
#if MAX_PLAYERS_IN_SPECTRAL_REALM > 0
uint8 SpectralPlayers = 0;
- Map::PlayerList const &PlayerList = map->GetPlayers();
+ Map::PlayerList const &PlayerList = go->GetMap()->GetPlayers();
for (Map::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i)
{
if (i->GetSource() && i->GetSource()->GetPositionZ() < DEMON_REALM_Z + 5)
@@ -569,6 +565,8 @@ public:
player->GetSession()->SendNotification(GO_FAILED);
return true;
}
+#else
+ (void)go;
#endif
player->CastSpell(player, SPELL_TELEPORT_SPECTRAL, true);
@@ -688,12 +686,8 @@ public:
void TeleportAllPlayersBack()
{
- Map* map = me->GetMap();
- if (!map->IsDungeon())
- return;
-
- Map::PlayerList const &playerList = map->GetPlayers();
- Position homePos = me->GetHomePosition();
+ Map::PlayerList const &playerList = me->GetMap()->GetPlayers();
+ Position const& homePos = me->GetHomePosition();
for (Map::PlayerList::const_iterator itr = playerList.begin(); itr != playerList.end(); ++itr)
{
Player* player = itr->GetSource();
diff --git a/src/server/scripts/Kalimdor/CavernsOfTime/EscapeFromDurnholdeKeep/old_hillsbrad.cpp b/src/server/scripts/Kalimdor/CavernsOfTime/EscapeFromDurnholdeKeep/old_hillsbrad.cpp
index 780cf6646a3..33b8516657a 100644
--- a/src/server/scripts/Kalimdor/CavernsOfTime/EscapeFromDurnholdeKeep/old_hillsbrad.cpp
+++ b/src/server/scripts/Kalimdor/CavernsOfTime/EscapeFromDurnholdeKeep/old_hillsbrad.cpp
@@ -433,15 +433,11 @@ public:
}
//kill credit Creature for quest
- Map* map = me->GetMap();
- Map::PlayerList const& players = map->GetPlayers();
- if (!players.isEmpty() && map->IsDungeon())
+ Map::PlayerList const& players = me->GetMap()->GetPlayers();
+ for (Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr)
{
- for (Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr)
- {
- if (Player* player = itr->GetSource())
- player->KilledMonsterCredit(20156);
- }
+ if (Player* player = itr->GetSource())
+ player->KilledMonsterCredit(20156);
}
//alot will happen here, thrall and taretha talk, erozion appear at spot to explain
diff --git a/src/server/scripts/Kalimdor/RazorfenKraul/instance_razorfen_kraul.cpp b/src/server/scripts/Kalimdor/RazorfenKraul/instance_razorfen_kraul.cpp
index d8966ec76c1..b57d1b78de0 100644
--- a/src/server/scripts/Kalimdor/RazorfenKraul/instance_razorfen_kraul.cpp
+++ b/src/server/scripts/Kalimdor/RazorfenKraul/instance_razorfen_kraul.cpp
@@ -54,14 +54,10 @@ public:
Player* GetPlayerInMap()
{
Map::PlayerList const& players = instance->GetPlayers();
-
- if (!players.isEmpty())
+ for (Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr)
{
- for (Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr)
- {
- if (Player* player = itr->GetSource())
- return player;
- }
+ if (Player* player = itr->GetSource())
+ return player;
}
TC_LOG_DEBUG("scripts", "Instance Razorfen Kraul: GetPlayerInMap, but PlayerList is empty!");
return NULL;
diff --git a/src/server/scripts/Kalimdor/RuinsOfAhnQiraj/boss_ossirian.cpp b/src/server/scripts/Kalimdor/RuinsOfAhnQiraj/boss_ossirian.cpp
index 463d1ee7e0b..8ccc5f0b4ce 100644
--- a/src/server/scripts/Kalimdor/RuinsOfAhnQiraj/boss_ossirian.cpp
+++ b/src/server/scripts/Kalimdor/RuinsOfAhnQiraj/boss_ossirian.cpp
@@ -143,8 +143,6 @@ class boss_ossirian : public CreatureScript
Talk(SAY_AGGRO);
Map* map = me->GetMap();
- if (!map->IsDungeon())
- return;
WorldPacket data(SMSG_WEATHER, (4+4+4));
data << uint32(WEATHER_STATE_HEAVY_SANDSTORM) << float(1) << uint8(0);
@@ -153,7 +151,7 @@ class boss_ossirian : public CreatureScript
for (uint8 i = 0; i < NUM_TORNADOS; ++i)
{
Position Point = me->GetRandomPoint(RoomCenter, RoomRadius);
- if (Creature* Tornado = me->GetMap()->SummonCreature(NPC_SAND_VORTEX, Point))
+ if (Creature* Tornado = map->SummonCreature(NPC_SAND_VORTEX, Point))
Tornado->CastSpell(Tornado, SPELL_SAND_STORM, true);
}
diff --git a/src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_cthun.cpp b/src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_cthun.cpp
index f967bd6a217..8e84f1b4265 100644
--- a/src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_cthun.cpp
+++ b/src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_cthun.cpp
@@ -586,21 +586,10 @@ public:
//WisperTimer
if (WisperTimer <= diff)
{
- Map* map = me->GetMap();
- if (!map->IsDungeon())
- return;
-
//Play random sound to the zone
- Map::PlayerList const &PlayerList = map->GetPlayers();
-
- if (!PlayerList.isEmpty())
- {
- for (Map::PlayerList::const_iterator itr = PlayerList.begin(); itr != PlayerList.end(); ++itr)
- {
- if (Player* pPlr = itr->GetSource())
- pPlr->PlayDirectSound(RANDOM_SOUND_WHISPER, pPlr);
- }
- }
+ Map::PlayerList const &PlayerList = me->GetMap()->GetPlayers();
+ for (Map::PlayerList::const_iterator itr = PlayerList.begin(); itr != PlayerList.end(); ++itr)
+ me->PlayDirectSound(RANDOM_SOUND_WHISPER, itr->GetSource());
//One random wisper every 90 - 300 seconds
WisperTimer = urand(90000, 300000);
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 cfed13a8f38..d8ebfbbd743 100644
--- a/src/server/scripts/Northrend/AzjolNerub/Ahnkahet/boss_herald_volazj.cpp
+++ b/src/server/scripts/Northrend/AzjolNerub/Ahnkahet/boss_herald_volazj.cpp
@@ -230,11 +230,7 @@ public:
// Roll Insanity
uint32 spell = GetSpellForPhaseMask(phase);
uint32 spell2 = GetSpellForPhaseMask(nextPhase);
- Map* map = me->GetMap();
- if (!map)
- return;
-
- Map::PlayerList const &PlayerList = map->GetPlayers();
+ Map::PlayerList const &PlayerList = me->GetMap()->GetPlayers();
if (!PlayerList.isEmpty())
{
for (Map::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i)
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 7cb2c0e5178..5890b9cbec7 100644
--- a/src/server/scripts/Northrend/AzjolNerub/Ahnkahet/boss_jedoga_shadowseeker.cpp
+++ b/src/server/scripts/Northrend/AzjolNerub/Ahnkahet/boss_jedoga_shadowseeker.cpp
@@ -185,7 +185,7 @@ public:
who->RemoveAurasByType(SPELL_AURA_MOD_STEALTH);
AttackStart(who);
}
- else if (me->GetMap()->IsDungeon())
+ else
{
who->SetInCombatWith(me);
me->AddThreat(who, 0.0f);
diff --git a/src/server/scripts/Northrend/ChamberOfAspects/ObsidianSanctum/obsidian_sanctum.cpp b/src/server/scripts/Northrend/ChamberOfAspects/ObsidianSanctum/obsidian_sanctum.cpp
index b4627d7f941..eac84d1f6c9 100644
--- a/src/server/scripts/Northrend/ChamberOfAspects/ObsidianSanctum/obsidian_sanctum.cpp
+++ b/src/server/scripts/Northrend/ChamberOfAspects/ObsidianSanctum/obsidian_sanctum.cpp
@@ -652,23 +652,19 @@ class npc_acolyte_of_shadron : public CreatureScript
if (ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_SHADRON)))
instance->SetBossState(DATA_PORTAL_OPEN, NOT_STARTED);
- Map* map = me->GetMap();
- if (map->IsDungeon())
- {
- Map::PlayerList const& PlayerList = map->GetPlayers();
+ Map::PlayerList const& PlayerList = me->GetMap()->GetPlayers();
- if (PlayerList.isEmpty())
- return;
+ if (PlayerList.isEmpty())
+ return;
- for (Map::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i)
+ for (Map::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i)
+ {
+ if (i->GetSource()->IsAlive() && i->GetSource()->HasAura(SPELL_TWILIGHT_SHIFT) && !i->GetSource()->GetVictim())
{
- if (i->GetSource()->IsAlive() && i->GetSource()->HasAura(SPELL_TWILIGHT_SHIFT) && !i->GetSource()->GetVictim())
- {
- i->GetSource()->CastSpell(i->GetSource(), SPELL_TWILIGHT_SHIFT_REMOVAL_ALL, true);
- i->GetSource()->CastSpell(i->GetSource(), SPELL_TWILIGHT_RESIDUE, true);
- i->GetSource()->RemoveAurasDueToSpell(SPELL_TWILIGHT_SHIFT);
- i->GetSource()->RemoveAurasDueToSpell(SPELL_TWILIGHT_SHIFT_ENTER);
- }
+ i->GetSource()->CastSpell(i->GetSource(), SPELL_TWILIGHT_SHIFT_REMOVAL_ALL, true);
+ i->GetSource()->CastSpell(i->GetSource(), SPELL_TWILIGHT_RESIDUE, true);
+ i->GetSource()->RemoveAurasDueToSpell(SPELL_TWILIGHT_SHIFT);
+ i->GetSource()->RemoveAurasDueToSpell(SPELL_TWILIGHT_SHIFT_ENTER);
}
}
@@ -740,26 +736,22 @@ class npc_acolyte_of_vesperon : public CreatureScript
vesperon->RemoveAurasDueToSpell(SPELL_TWILIGHT_TORMENT_VESP);
}
- Map* map = me->GetMap();
- if (map->IsDungeon())
- {
- Map::PlayerList const &PlayerList = map->GetPlayers();
+ Map::PlayerList const &PlayerList = me->GetMap()->GetPlayers();
- if (PlayerList.isEmpty())
- return;
+ if (PlayerList.isEmpty())
+ return;
- for (Map::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i)
+ for (Map::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i)
+ {
+ if (i->GetSource()->IsAlive() && i->GetSource()->HasAura(SPELL_TWILIGHT_SHIFT) && !i->GetSource()->GetVictim())
{
- if (i->GetSource()->IsAlive() && i->GetSource()->HasAura(SPELL_TWILIGHT_SHIFT) && !i->GetSource()->GetVictim())
- {
- i->GetSource()->CastSpell(i->GetSource(), SPELL_TWILIGHT_SHIFT_REMOVAL_ALL, true);
- i->GetSource()->CastSpell(i->GetSource(), SPELL_TWILIGHT_RESIDUE, true);
- i->GetSource()->RemoveAurasDueToSpell(SPELL_TWILIGHT_SHIFT);
- i->GetSource()->RemoveAurasDueToSpell(SPELL_TWILIGHT_SHIFT_ENTER);
- }
- if (i->GetSource()->IsAlive() && i->GetSource()->HasAura(SPELL_TWILIGHT_TORMENT_VESP) && !i->GetSource()->GetVictim())
- i->GetSource()->RemoveAurasDueToSpell(SPELL_TWILIGHT_TORMENT_VESP);
+ i->GetSource()->CastSpell(i->GetSource(), SPELL_TWILIGHT_SHIFT_REMOVAL_ALL, true);
+ i->GetSource()->CastSpell(i->GetSource(), SPELL_TWILIGHT_RESIDUE, true);
+ i->GetSource()->RemoveAurasDueToSpell(SPELL_TWILIGHT_SHIFT);
+ i->GetSource()->RemoveAurasDueToSpell(SPELL_TWILIGHT_SHIFT_ENTER);
}
+ if (i->GetSource()->IsAlive() && i->GetSource()->HasAura(SPELL_TWILIGHT_TORMENT_VESP) && !i->GetSource()->GetVictim())
+ i->GetSource()->RemoveAurasDueToSpell(SPELL_TWILIGHT_TORMENT_VESP);
}
instance->DoRemoveAurasDueToSpellOnPlayers(SPELL_TWILIGHT_TORMENT_VESP_ACO);
diff --git a/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheChampion/boss_grand_champions.cpp b/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheChampion/boss_grand_champions.cpp
index c375e5c1b95..512016c6eeb 100644
--- a/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheChampion/boss_grand_champions.cpp
+++ b/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheChampion/boss_grand_champions.cpp
@@ -254,7 +254,7 @@ public:
if (uiChargeTimer <= uiDiff)
{
Map::PlayerList const& players = me->GetMap()->GetPlayers();
- if (me->GetMap()->IsDungeon() && !players.isEmpty())
+ if (!players.isEmpty())
{
for (Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr)
{
@@ -281,7 +281,7 @@ public:
if (Unit* pPassenger = pVehicle->GetPassenger(SEAT_ID_0))
{
Map::PlayerList const& players = me->GetMap()->GetPlayers();
- if (me->GetMap()->IsDungeon() && !players.isEmpty())
+ if (!players.isEmpty())
{
for (Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr)
{
@@ -400,7 +400,7 @@ public:
if (uiInterceptTimer <= uiDiff)
{
Map::PlayerList const& players = me->GetMap()->GetPlayers();
- if (me->GetMap()->IsDungeon() && !players.isEmpty())
+ if (!players.isEmpty())
{
for (Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr)
{
@@ -867,7 +867,7 @@ public:
else
{
Map::PlayerList const& players = me->GetMap()->GetPlayers();
- if (me->GetMap()->IsDungeon() && !players.isEmpty())
+ if (!players.isEmpty())
{
for (Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr)
{
diff --git a/src/server/scripts/Northrend/IcecrownCitadel/boss_blood_queen_lana_thel.cpp b/src/server/scripts/Northrend/IcecrownCitadel/boss_blood_queen_lana_thel.cpp
index efc24b94cdb..a7ac5d1227e 100644
--- a/src/server/scripts/Northrend/IcecrownCitadel/boss_blood_queen_lana_thel.cpp
+++ b/src/server/scripts/Northrend/IcecrownCitadel/boss_blood_queen_lana_thel.cpp
@@ -203,7 +203,7 @@ class boss_blood_queen_lana_thel : public CreatureScript
{
instance->SetData(DATA_BLOOD_QUICKENING_STATE, DONE);
if (Player* player = killer->ToPlayer())
- player->RewardPlayerAndGroupAtEvent(NPC_INFILTRATOR_MINCHAR_BQ, player);
+ player->RewardPlayerAndGroupAtEvent(Is25ManRaid() ? NPC_INFILTRATOR_MINCHAR_BQ_25 : NPC_INFILTRATOR_MINCHAR_BQ, player);
if (Creature* minchar = me->FindNearestCreature(NPC_INFILTRATOR_MINCHAR_BQ, 200.0f))
{
minchar->SetUInt32Value(UNIT_NPC_EMOTESTATE, 0);
diff --git a/src/server/scripts/Northrend/IcecrownCitadel/boss_festergut.cpp b/src/server/scripts/Northrend/IcecrownCitadel/boss_festergut.cpp
index db0fcee22fa..e3e89d865ff 100644
--- a/src/server/scripts/Northrend/IcecrownCitadel/boss_festergut.cpp
+++ b/src/server/scripts/Northrend/IcecrownCitadel/boss_festergut.cpp
@@ -470,21 +470,11 @@ class spell_festergut_blighted_spores : public SpellScriptLoader
if (target->HasAura(SPELL_ORANGE_BLIGHT_RESIDUE))
return;
- if (target->GetMap() && !target->GetMap()->Is25ManRaid())
- {
- if (target->GetQuestStatus(QUEST_RESIDUE_RENDEZVOUS_10) != QUEST_STATUS_INCOMPLETE)
- return;
-
- target->CastSpell(target, SPELL_ORANGE_BLIGHT_RESIDUE, TRIGGERED_FULL_MASK);
- }
-
- if (target->GetMap() && target->GetMap()->Is25ManRaid())
- {
- if (target->GetQuestStatus(QUEST_RESIDUE_RENDEZVOUS_25) != QUEST_STATUS_INCOMPLETE)
- return;
+ uint32 questId = target->GetMap()->Is25ManRaid() ? QUEST_RESIDUE_RENDEZVOUS_25 : QUEST_RESIDUE_RENDEZVOUS_10;
+ if (target->GetQuestStatus(questId) != QUEST_STATUS_INCOMPLETE)
+ return;
- target->CastSpell(target, SPELL_ORANGE_BLIGHT_RESIDUE, TRIGGERED_FULL_MASK);
- }
+ target->CastSpell(target, SPELL_ORANGE_BLIGHT_RESIDUE, TRIGGERED_FULL_MASK);
}
void Register() override
diff --git a/src/server/scripts/Northrend/IcecrownCitadel/boss_rotface.cpp b/src/server/scripts/Northrend/IcecrownCitadel/boss_rotface.cpp
index c1d930cb62c..1a2ebd179fe 100644
--- a/src/server/scripts/Northrend/IcecrownCitadel/boss_rotface.cpp
+++ b/src/server/scripts/Northrend/IcecrownCitadel/boss_rotface.cpp
@@ -892,21 +892,11 @@ class spell_rotface_slime_spray : public SpellScriptLoader
if (target->HasAura(SPELL_GREEN_BLIGHT_RESIDUE))
return;
- if (target->GetMap() && !target->GetMap()->Is25ManRaid())
- {
- if (target->GetQuestStatus(QUEST_RESIDUE_RENDEZVOUS_10) != QUEST_STATUS_INCOMPLETE)
- return;
-
- target->CastSpell(target, SPELL_GREEN_BLIGHT_RESIDUE, TRIGGERED_FULL_MASK);
- }
-
- if (target->GetMap() && target->GetMap()->Is25ManRaid())
- {
- if (target->GetQuestStatus(QUEST_RESIDUE_RENDEZVOUS_25) != QUEST_STATUS_INCOMPLETE)
- return;
+ uint32 questId = target->GetMap()->Is25ManRaid() ? QUEST_RESIDUE_RENDEZVOUS_25 : QUEST_RESIDUE_RENDEZVOUS_10;
+ if (target->GetQuestStatus(questId) != QUEST_STATUS_INCOMPLETE)
+ return;
- target->CastSpell(target, SPELL_GREEN_BLIGHT_RESIDUE, TRIGGERED_FULL_MASK);
- }
+ target->CastSpell(target, SPELL_GREEN_BLIGHT_RESIDUE, TRIGGERED_FULL_MASK);
}
void Register() override
diff --git a/src/server/scripts/Northrend/IcecrownCitadel/boss_valithria_dreamwalker.cpp b/src/server/scripts/Northrend/IcecrownCitadel/boss_valithria_dreamwalker.cpp
index f0835135890..4a76dc667e8 100644
--- a/src/server/scripts/Northrend/IcecrownCitadel/boss_valithria_dreamwalker.cpp
+++ b/src/server/scripts/Northrend/IcecrownCitadel/boss_valithria_dreamwalker.cpp
@@ -309,7 +309,7 @@ class boss_valithria_dreamwalker : public CreatureScript
{
me->SetHealth(_spawnHealth);
me->SetReactState(REACT_PASSIVE);
- me->LoadCreaturesAddon(true);
+ me->LoadCreaturesAddon();
// immune to percent heals
me->ApplySpellImmune(0, IMMUNITY_STATE, SPELL_AURA_OBS_MOD_HEALTH, true);
me->ApplySpellImmune(0, IMMUNITY_EFFECT, SPELL_EFFECT_HEAL_PCT, true);
@@ -1072,7 +1072,7 @@ class npc_dream_cloud : public CreatureScript
_events.Reset();
_events.ScheduleEvent(EVENT_CHECK_PLAYER, 1000);
me->SetCorpseDelay(0); // remove corpse immediately
- me->LoadCreaturesAddon(true);
+ me->LoadCreaturesAddon();
}
void UpdateAI(uint32 diff) override
@@ -1336,7 +1336,7 @@ class spell_dreamwalker_summon_dream_portal : public SpellScriptLoader
if (!GetHitUnit())
return;
- uint32 spellId = RAND<uint32>(71301, 72220, 72223, 72225);
+ uint32 spellId = RAND(71301, 72220, 72223, 72225);
GetHitUnit()->CastSpell(GetHitUnit(), spellId, true);
}
@@ -1367,7 +1367,7 @@ class spell_dreamwalker_summon_nightmare_portal : public SpellScriptLoader
if (!GetHitUnit())
return;
- uint32 spellId = RAND<uint32>(71977, 72481, 72482, 72483);
+ uint32 spellId = RAND(71977, 72481, 72482, 72483);
GetHitUnit()->CastSpell(GetHitUnit(), spellId, true);
}
diff --git a/src/server/scripts/Northrend/IcecrownCitadel/icecrown_citadel.h b/src/server/scripts/Northrend/IcecrownCitadel/icecrown_citadel.h
index 091190b6b4e..e739f5a5036 100644
--- a/src/server/scripts/Northrend/IcecrownCitadel/icecrown_citadel.h
+++ b/src/server/scripts/Northrend/IcecrownCitadel/icecrown_citadel.h
@@ -155,6 +155,7 @@ enum CreaturesIds
NPC_ALCHEMIST_ADRIANNA = 38501,
NPC_ALRIN_THE_AGILE = 38551,
NPC_INFILTRATOR_MINCHAR_BQ = 38558,
+ NPC_INFILTRATOR_MINCHAR_BQ_25 = 39123,
NPC_MINCHAR_BEAM_STALKER = 38557,
NPC_VALITHRIA_DREAMWALKER_QUEST = 38589,
diff --git a/src/server/scripts/Northrend/Naxxramas/boss_anubrekhan.cpp b/src/server/scripts/Northrend/Naxxramas/boss_anubrekhan.cpp
index 733647fdb66..47569a6b85f 100644
--- a/src/server/scripts/Northrend/Naxxramas/boss_anubrekhan.cpp
+++ b/src/server/scripts/Northrend/Naxxramas/boss_anubrekhan.cpp
@@ -17,39 +17,61 @@
#include "ScriptMgr.h"
#include "ScriptedCreature.h"
+#include "Player.h"
#include "naxxramas.h"
-enum Says
+enum AnubSays
{
SAY_AGGRO = 0,
SAY_GREET = 1,
- SAY_SLAY = 2
+ SAY_SLAY = 2,
+
+ EMOTE_LOCUST = 3
};
-Position const GuardSummonPos = {3333.72f, -3476.30f, 287.1f, 6.2801f};
+enum GuardSays
+{
+ EMOTE_FRENZY = 0,
+ EMOTE_SPAWN = 1,
+ EMOTE_SCARAB = 2
+};
enum Events
{
- EVENT_IMPALE = 1,
- EVENT_LOCUST,
- EVENT_SPAWN_GUARDIAN_NORMAL,
- EVENT_BERSERK
+ EVENT_IMPALE = 1, // Cast Impale on a random target
+ EVENT_LOCUST, // Begin channeling Locust Swarm
+ EVENT_LOCUST_ENDS, // Locust swarm dissipates
+ EVENT_SPAWN_GUARD, // 10-man only - crypt guard has delayed spawn; also used for the locust swarm crypt guard in both modes
+ EVENT_SCARABS, // spawn corpse scarabs
+ EVENT_BERSERK // Berserk
};
enum Spells
{
- SPELL_IMPALE = 28783,
- SPELL_LOCUST_SWARM = 28785,
+ SPELL_IMPALE = 28783, // 25-man: 56090
+ SPELL_LOCUST_SWARM = 28785, // 25-man: 54021
SPELL_SUMMON_CORPSE_SCARABS_PLR = 29105, // This spawns 5 corpse scarabs on top of player
SPELL_SUMMON_CORPSE_SCARABS_MOB = 28864, // This spawns 10 corpse scarabs on top of dead guards
SPELL_BERSERK = 27680
};
+enum SpawnGroups
+{
+ GROUP_INITIAL_25M = 1,
+ GROUP_SINGLE_SPAWN = 2
+};
+
enum Misc
{
ACHIEV_TIMED_START_EVENT = 9891
};
+enum Phases
+{
+ PHASE_NORMAL = 1,
+ PHASE_SWARM
+};
+
class boss_anubrekhan : public CreatureScript
{
public:
@@ -62,46 +84,64 @@ public:
struct boss_anubrekhanAI : public BossAI
{
- boss_anubrekhanAI(Creature* creature) : BossAI(creature, BOSS_ANUBREKHAN)
+ boss_anubrekhanAI(Creature* creature) : BossAI(creature, BOSS_ANUBREKHAN) { }
+
+ void SummonGuards()
{
- Initialize();
+ if (Is25ManRaid())
+ me->SummonCreatureGroup(GROUP_INITIAL_25M);
}
- void Initialize()
+ void InitializeAI() override
{
- hasTaunted = false;
+ if (!me->isDead())
+ {
+ Reset();
+ SummonGuards();
+ }
}
- bool hasTaunted;
-
void Reset() override
{
_Reset();
+ guardCorpses.clear();
+ }
- Initialize();
+ void JustReachedHome() override
+ {
+ _JustReachedHome();
+ SummonGuards();
+ }
- if (GetDifficulty() == RAID_DIFFICULTY_25MAN_NORMAL)
- {
- Position pos;
+ void JustSummoned(Creature* summon) override
+ {
+ BossAI::JustSummoned(summon);
- // respawn guard using home position,
- // otherwise, after a wipe, they respawn where boss was at wipe moment.
- pos = me->GetHomePosition();
- pos.m_positionY -= 10.0f;
- me->SummonCreature(NPC_CRYPT_GUARD, pos, TEMPSUMMON_CORPSE_DESPAWN);
+ if (me->IsInCombat())
+ if (summon->GetEntry() == NPC_CRYPT_GUARD)
+ summon->AI()->Talk(EMOTE_SPAWN, me);
+ }
- pos = me->GetHomePosition();
- pos.m_positionY += 10.0f;
- me->SummonCreature(NPC_CRYPT_GUARD, pos, TEMPSUMMON_CORPSE_DESPAWN);
- }
+ void SummonedCreatureDies(Creature* summon, Unit* killer) override
+ {
+ BossAI::SummonedCreatureDies(summon, killer);
+
+ if (summon->GetEntry() == NPC_CRYPT_GUARD)
+ guardCorpses.insert(summon->GetGUID());
+ }
+
+ void SummonedCreatureDespawn(Creature* summon) override
+ {
+ BossAI::SummonedCreatureDespawn(summon);
+
+ if (summon->GetEntry() == NPC_CRYPT_GUARD)
+ guardCorpses.erase(summon->GetGUID());
}
void KilledUnit(Unit* victim) override
{
- /// Force the player to spawn corpse scarabs via spell, @todo Check percent chance for scarabs, 20% at the moment
- if (!(rand32() % 5))
- if (victim->GetTypeId() == TYPEID_PLAYER)
- victim->CastSpell(victim, SPELL_SUMMON_CORPSE_SCARABS_PLR, true, NULL, NULL, me->GetGUID());
+ if (victim->GetTypeId() == TYPEID_PLAYER)
+ victim->CastSpell(victim, SPELL_SUMMON_CORPSE_SCARABS_PLR, true, nullptr, nullptr, me->GetGUID());
Talk(SAY_SLAY);
}
@@ -113,37 +153,22 @@ public:
// start achievement timer (kill Maexna within 20 min)
instance->DoStartTimedAchievement(ACHIEVEMENT_TIMED_TYPE_EVENT, ACHIEV_TIMED_START_EVENT);
}
+
void EnterCombat(Unit* /*who*/) override
{
_EnterCombat();
Talk(SAY_AGGRO);
- events.ScheduleEvent(EVENT_IMPALE, urand(10000, 20000));
- events.ScheduleEvent(EVENT_LOCUST, 90000);
- events.ScheduleEvent(EVENT_BERSERK, 600000);
-
- if (GetDifficulty() == RAID_DIFFICULTY_10MAN_NORMAL)
- events.ScheduleEvent(EVENT_SPAWN_GUARDIAN_NORMAL, urand(15000, 20000));
- }
-
- void MoveInLineOfSight(Unit* who) override
- {
- if (!hasTaunted && me->IsWithinDistInMap(who, 60.0f) && who->GetTypeId() == TYPEID_PLAYER)
- {
- Talk(SAY_GREET);
- hasTaunted = true;
- }
- ScriptedAI::MoveInLineOfSight(who);
- }
- void SummonedCreatureDespawn(Creature* summon) override
- {
- BossAI::SummonedCreatureDespawn(summon);
+ summons.DoZoneInCombat();
- // check if it is an actual killed guard
- if (!me->IsAlive() || summon->IsAlive() || summon->GetEntry() != NPC_CRYPT_GUARD)
- return;
+ events.SetPhase(PHASE_NORMAL);
+ events.ScheduleEvent(EVENT_IMPALE, urand(10 * IN_MILLISECONDS, 20 * IN_MILLISECONDS), 0, PHASE_NORMAL);
+ events.ScheduleEvent(EVENT_SCARABS, urand(20 * IN_MILLISECONDS, 30 * IN_MILLISECONDS), 0, PHASE_NORMAL);
+ events.ScheduleEvent(EVENT_LOCUST, urand(80,120) * IN_MILLISECONDS, 0, PHASE_NORMAL);
+ events.ScheduleEvent(EVENT_BERSERK, 10 * MINUTE * IN_MILLISECONDS);
- summon->CastSpell(summon, SPELL_SUMMON_CORPSE_SCARABS_MOB, true, NULL, NULL, me->GetGUID());
+ if (!Is25ManRaid())
+ events.ScheduleEvent(EVENT_SPAWN_GUARD, urand(15, 20) * IN_MILLISECONDS);
}
void UpdateAI(uint32 diff) override
@@ -158,22 +183,44 @@ public:
switch (eventId)
{
case EVENT_IMPALE:
- //Cast Impale on a random target
- //Do NOT cast it when we are afflicted by locust swarm
- if (!me->HasAura(sSpellMgr->GetSpellIdForDifficulty(SPELL_LOCUST_SWARM, me)))
- if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0))
- DoCast(target, SPELL_IMPALE);
- events.ScheduleEvent(EVENT_IMPALE, urand(10000, 20000));
+ if (events.GetTimeUntilEvent(EVENT_LOCUST) < 5 * IN_MILLISECONDS) break; // don't chain impale tank -> locust swarm
+ if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0))
+ DoCast(target, SPELL_IMPALE);
+ else
+ EnterEvadeMode();
+
+ events.ScheduleEvent(EVENT_IMPALE, urand(10 * IN_MILLISECONDS, 20 * IN_MILLISECONDS), 0, PHASE_NORMAL);
+ break;
+ case EVENT_SCARABS:
+ events.ScheduleEvent(EVENT_SCARABS, urand(40 * IN_MILLISECONDS, 60 * IN_MILLISECONDS), 0, PHASE_NORMAL);
+
+ if (!guardCorpses.empty())
+ {
+ if (ObjectGuid target = Trinity::Containers::SelectRandomContainerElement(guardCorpses))
+ if(Creature* creatureTarget = ObjectAccessor::GetCreature(*me, target))
+ {
+ creatureTarget->CastSpell(creatureTarget, SPELL_SUMMON_CORPSE_SCARABS_MOB, true, nullptr, nullptr, me->GetGUID());
+ creatureTarget->AI()->Talk(EMOTE_SCARAB);
+ creatureTarget->DespawnOrUnsummon();
+ }
+ }
break;
case EVENT_LOCUST:
- /// @todo Add Text
+ Talk(EMOTE_LOCUST);
DoCast(me, SPELL_LOCUST_SWARM);
- DoSummon(NPC_CRYPT_GUARD, GuardSummonPos, 0, TEMPSUMMON_CORPSE_DESPAWN);
+ events.ScheduleEvent(EVENT_SPAWN_GUARD, 3 * IN_MILLISECONDS);
+
+ events.ScheduleEvent(EVENT_LOCUST_ENDS, RAID_MODE(19, 23) * IN_MILLISECONDS);
events.ScheduleEvent(EVENT_LOCUST, 90000);
+ events.SetPhase(PHASE_SWARM);
+ break;
+ case EVENT_LOCUST_ENDS:
+ events.ScheduleEvent(EVENT_IMPALE, urand(10 * IN_MILLISECONDS, 20 * IN_MILLISECONDS), 0, PHASE_NORMAL);
+ events.ScheduleEvent(EVENT_SCARABS, urand(20 * IN_MILLISECONDS, 30 * IN_MILLISECONDS), 0, PHASE_NORMAL);
+ events.SetPhase(PHASE_NORMAL);
break;
- case EVENT_SPAWN_GUARDIAN_NORMAL:
- /// @todo Add Text
- DoSummon(NPC_CRYPT_GUARD, GuardSummonPos, 0, TEMPSUMMON_CORPSE_DESPAWN);
+ case EVENT_SPAWN_GUARD:
+ me->SummonCreatureGroup(GROUP_SINGLE_SPAWN);
break;
case EVENT_BERSERK:
DoCast(me, SPELL_BERSERK, true);
@@ -182,13 +229,37 @@ public:
}
}
- DoMeleeAttackIfReady();
+ if (events.IsInPhase(PHASE_NORMAL))
+ DoMeleeAttackIfReady();
}
+ private:
+ GuidSet guardCorpses;
};
};
+class at_anubrekhan_entrance : public AreaTriggerScript
+{
+ public:
+ at_anubrekhan_entrance() : AreaTriggerScript("at_anubrekhan_entrance") { }
+
+ bool OnTrigger(Player* player, AreaTriggerEntry const* /*areaTrigger*/) override
+ {
+ InstanceScript* instance = player->GetInstanceScript();
+ if (!instance || instance->GetData(DATA_HAD_ANUBREKHAN_GREET) || instance->GetBossState(BOSS_ANUBREKHAN) != NOT_STARTED)
+ return true;
+
+ if (Creature* anub = ObjectAccessor::GetCreature(*player, instance->GetGuidData(DATA_ANUBREKHAN)))
+ anub->AI()->Talk(SAY_GREET);
+ instance->SetData(DATA_HAD_ANUBREKHAN_GREET, 1u);
+
+ return true;
+ }
+};
+
void AddSC_boss_anubrekhan()
{
new boss_anubrekhan();
+
+ new at_anubrekhan_entrance();
}
diff --git a/src/server/scripts/Northrend/Naxxramas/boss_faerlina.cpp b/src/server/scripts/Northrend/Naxxramas/boss_faerlina.cpp
index a87501e885a..dd9061603c8 100644
--- a/src/server/scripts/Northrend/Naxxramas/boss_faerlina.cpp
+++ b/src/server/scripts/Northrend/Naxxramas/boss_faerlina.cpp
@@ -18,14 +18,20 @@
#include "ScriptMgr.h"
#include "ScriptedCreature.h"
#include "naxxramas.h"
+#include "Player.h"
+#include "SpellAuras.h"
#include "SpellInfo.h"
enum Yells
{
- SAY_GREET = 0,
- SAY_AGGRO = 1,
- SAY_SLAY = 2,
- SAY_DEATH = 3
+ SAY_GREET = 0,
+ SAY_AGGRO = 1,
+ SAY_SLAY = 2,
+ SAY_DEATH = 3,
+
+ EMOTE_WIDOW_EMBRACE = 4,
+ EMOTE_FRENZY = 5
+
};
enum Spells
@@ -33,7 +39,9 @@ enum Spells
SPELL_POISON_BOLT_VOLLEY = 28796,
SPELL_RAIN_OF_FIRE = 28794,
SPELL_FRENZY = 28798,
- SPELL_WIDOWS_EMBRACE = 28732
+ SPELL_WIDOWS_EMBRACE = 28732,
+
+ SPELL_ADD_FIREBALL = 54095 // 25-man: 54096
};
#define SPELL_WIDOWS_EMBRACE_HELPER RAID_MODE<uint32>(28732, 54097)
@@ -45,6 +53,12 @@ enum Events
EVENT_FRENZY = 3
};
+enum SummonGroups
+{
+ SUMMON_GROUP_WORSHIPPERS = 1,
+ SUMMON_GROUP_FOLLOWERS = 2
+};
+
enum Misc
{
DATA_FRENZY_DISPELS = 1
@@ -57,39 +71,46 @@ class boss_faerlina : public CreatureScript
struct boss_faerlinaAI : public BossAI
{
- boss_faerlinaAI(Creature* creature) : BossAI(creature, BOSS_FAERLINA),
- _frenzyDispels(0), _introDone(false), _delayFrenzy(false)
+ boss_faerlinaAI(Creature* creature) : BossAI(creature, BOSS_FAERLINA), _frenzyDispels(0) { }
+
+ void SummonAdds()
{
+ me->SummonCreatureGroup(SUMMON_GROUP_WORSHIPPERS);
+ if (Is25ManRaid())
+ me->SummonCreatureGroup(SUMMON_GROUP_FOLLOWERS);
}
+ void InitializeAI() override
+ {
+ if (!me->isDead())
+ {
+ Reset();
+ SummonAdds();
+ }
+ }
+
+ void JustReachedHome() override
+ {
+ _JustReachedHome();
+ SummonAdds();
+ }
void EnterCombat(Unit* /*who*/) override
{
_EnterCombat();
Talk(SAY_AGGRO);
- events.ScheduleEvent(EVENT_POISON, urand(10000, 15000));
- events.ScheduleEvent(EVENT_FIRE, urand(6000, 18000));
- events.ScheduleEvent(EVENT_FRENZY, urand(60000, 80000));
+ summons.DoZoneInCombat();
+ events.ScheduleEvent(EVENT_POISON, urand(10 * IN_MILLISECONDS, 15 * IN_MILLISECONDS));
+ events.ScheduleEvent(EVENT_FIRE, urand(6 * IN_MILLISECONDS, 18 * IN_MILLISECONDS));
+ events.ScheduleEvent(EVENT_FRENZY, urand(60 * IN_MILLISECONDS, 80 * IN_MILLISECONDS));
}
void Reset() override
{
_Reset();
- _delayFrenzy = false;
_frenzyDispels = 0;
}
- void MoveInLineOfSight(Unit* who) override
- {
- if (!_introDone && who->GetTypeId() == TYPEID_PLAYER)
- {
- Talk(SAY_GREET);
- _introDone = true;
- }
-
- BossAI::MoveInLineOfSight(who);
- }
-
void KilledUnit(Unit* /*victim*/) override
{
if (!urand(0, 2))
@@ -106,9 +127,8 @@ class boss_faerlina : public CreatureScript
{
if (spell->Id == SPELL_WIDOWS_EMBRACE_HELPER)
{
- /// @todo Add Text
++_frenzyDispels;
- _delayFrenzy = true;
+ Talk(EMOTE_WIDOW_EMBRACE, caster);
me->Kill(caster);
}
}
@@ -126,12 +146,6 @@ class boss_faerlina : public CreatureScript
if (!UpdateVictim())
return;
- if (_delayFrenzy && !me->HasAura(SPELL_WIDOWS_EMBRACE_HELPER))
- {
- _delayFrenzy = false;
- DoCast(me, SPELL_FRENZY, true);
- }
-
events.Update(diff);
if (me->HasUnitState(UNIT_STATE_CASTING))
@@ -152,13 +166,14 @@ class boss_faerlina : public CreatureScript
events.ScheduleEvent(EVENT_FIRE, urand(6000, 18000));
break;
case EVENT_FRENZY:
- /// @todo Add Text
- if (!me->HasAura(SPELL_WIDOWS_EMBRACE_HELPER))
- DoCast(me, SPELL_FRENZY);
+ if (Aura* widowsEmbrace = me->GetAura(SPELL_WIDOWS_EMBRACE_HELPER))
+ events.ScheduleEvent(EVENT_FRENZY, widowsEmbrace->GetDuration()+1 * IN_MILLISECONDS);
else
- _delayFrenzy = true;
-
- events.ScheduleEvent(EVENT_FRENZY, urand(60000, 80000));
+ {
+ DoCast(SPELL_FRENZY);
+ Talk(EMOTE_FRENZY);
+ events.ScheduleEvent(EVENT_FRENZY, urand(60 * IN_MILLISECONDS, 80 * IN_MILLISECONDS));
+ }
break;
}
}
@@ -168,8 +183,6 @@ class boss_faerlina : public CreatureScript
private:
uint32 _frenzyDispels;
- bool _introDone;
- bool _delayFrenzy;
};
CreatureAI* GetAI(Creature* creature) const override
@@ -192,19 +205,36 @@ class npc_faerlina_add : public CreatureScript
void Reset() override
{
- if (GetDifficulty() == RAID_DIFFICULTY_10MAN_NORMAL) {
+ if (!Is25ManRaid()) {
me->ApplySpellImmune(0, IMMUNITY_EFFECT, SPELL_EFFECT_BIND, true);
me->ApplySpellImmune(0, IMMUNITY_MECHANIC, MECHANIC_CHARM, true);
}
}
+ void EnterCombat(Unit* /*who*/) override
+ {
+ if (Creature* faerlina = ObjectAccessor::GetCreature(*me, _instance->GetGuidData(DATA_FAERLINA)))
+ faerlina->AI()->DoZoneInCombat(nullptr, 250.0f);
+ }
+
void JustDied(Unit* /*killer*/) override
{
- if (_instance && GetDifficulty() == RAID_DIFFICULTY_10MAN_NORMAL)
+ if (!Is25ManRaid())
if (Creature* faerlina = ObjectAccessor::GetCreature(*me, _instance->GetGuidData(DATA_FAERLINA)))
DoCast(faerlina, SPELL_WIDOWS_EMBRACE);
}
+ void UpdateAI(uint32 /*diff*/) override
+ {
+ if (!UpdateVictim())
+ return;
+ if (me->HasUnitState(UNIT_STATE_CASTING))
+ return;
+
+ DoCastVictim(SPELL_ADD_FIREBALL);
+ DoMeleeAttackIfReady(); // this will only happen if the fireball cast fails for some reason
+ }
+
private:
InstanceScript* const _instance;
};
@@ -226,9 +256,29 @@ class achievement_momma_said_knock_you_out : public AchievementCriteriaScript
}
};
+class at_faerlina_entrance : public AreaTriggerScript
+{
+ public:
+ at_faerlina_entrance() : AreaTriggerScript("at_faerlina_entrance") { }
+
+ bool OnTrigger(Player* player, AreaTriggerEntry const* /*areaTrigger*/) override
+ {
+ InstanceScript* instance = player->GetInstanceScript();
+ if (!instance || instance->GetData(DATA_HAD_FAERLINA_GREET) || instance->GetBossState(BOSS_FAERLINA) != NOT_STARTED)
+ return true;
+
+ if (Creature* faerlina = ObjectAccessor::GetCreature(*player, instance->GetGuidData(DATA_FAERLINA)))
+ faerlina->AI()->Talk(SAY_GREET);
+ instance->SetData(DATA_HAD_FAERLINA_GREET, 1u);
+
+ return true;
+ }
+};
+
void AddSC_boss_faerlina()
{
new boss_faerlina();
new npc_faerlina_add();
+ new at_faerlina_entrance();
new achievement_momma_said_knock_you_out();
}
diff --git a/src/server/scripts/Northrend/Naxxramas/boss_gothik.cpp b/src/server/scripts/Northrend/Naxxramas/boss_gothik.cpp
index dd67f2b1ac0..3778d8d25a0 100644
--- a/src/server/scripts/Northrend/Naxxramas/boss_gothik.cpp
+++ b/src/server/scripts/Northrend/Naxxramas/boss_gothik.cpp
@@ -317,37 +317,30 @@ class boss_gothik : public CreatureScript
bool CheckGroupSplitted()
{
- Map* map = me->GetMap();
- if (map && map->IsDungeon())
+ bool checklife = false;
+ bool checkdead = false;
+ Map::PlayerList const &PlayerList = me->GetMap()->GetPlayers();
+ for (Map::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i)
{
- Map::PlayerList const &PlayerList = map->GetPlayers();
- if (!PlayerList.isEmpty())
+ if (i->GetSource() && i->GetSource()->IsAlive() &&
+ i->GetSource()->GetPositionX() <= POS_X_NORTH &&
+ i->GetSource()->GetPositionX() >= POS_X_SOUTH &&
+ i->GetSource()->GetPositionY() <= POS_Y_GATE &&
+ i->GetSource()->GetPositionY() >= POS_Y_EAST)
{
- bool checklife = false;
- bool checkdead = false;
- for (Map::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i)
- {
- if (i->GetSource() && i->GetSource()->IsAlive() &&
- i->GetSource()->GetPositionX() <= POS_X_NORTH &&
- i->GetSource()->GetPositionX() >= POS_X_SOUTH &&
- i->GetSource()->GetPositionY() <= POS_Y_GATE &&
- i->GetSource()->GetPositionY() >= POS_Y_EAST)
- {
- checklife = true;
- }
- else if (i->GetSource() && i->GetSource()->IsAlive() &&
- i->GetSource()->GetPositionX() <= POS_X_NORTH &&
- i->GetSource()->GetPositionX() >= POS_X_SOUTH &&
- i->GetSource()->GetPositionY() >= POS_Y_GATE &&
- i->GetSource()->GetPositionY() <= POS_Y_WEST)
- {
- checkdead = true;
- }
-
- if (checklife && checkdead)
- return true;
- }
+ checklife = true;
}
+ else if (i->GetSource() && i->GetSource()->IsAlive() &&
+ i->GetSource()->GetPositionX() <= POS_X_NORTH &&
+ i->GetSource()->GetPositionX() >= POS_X_SOUTH &&
+ i->GetSource()->GetPositionY() >= POS_Y_GATE &&
+ i->GetSource()->GetPositionY() <= POS_Y_WEST)
+ {
+ checkdead = true;
+ }
+
+ if (checklife && checkdead)
+ return true;
}
return false;
@@ -555,20 +548,13 @@ class npc_gothik_minion : public CreatureScript
if (!_EnterEvadeMode())
return;
- Map* map = me->GetMap();
- if (map->IsDungeon())
+ Map::PlayerList const &PlayerList = me->GetMap()->GetPlayers();
+ for (Map::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i)
{
- Map::PlayerList const &PlayerList = map->GetPlayers();
- if (!PlayerList.isEmpty())
+ if (i->GetSource() && i->GetSource()->IsAlive() && isOnSameSide(i->GetSource()))
{
- for (Map::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i)
- {
- if (i->GetSource() && i->GetSource()->IsAlive() && isOnSameSide(i->GetSource()))
- {
- AttackStart(i->GetSource());
- return;
- }
- }
+ AttackStart(i->GetSource());
+ return;
}
}
diff --git a/src/server/scripts/Northrend/Naxxramas/boss_heigan.cpp b/src/server/scripts/Northrend/Naxxramas/boss_heigan.cpp
index 5248c48029c..36e48d068b5 100644
--- a/src/server/scripts/Northrend/Naxxramas/boss_heigan.cpp
+++ b/src/server/scripts/Northrend/Naxxramas/boss_heigan.cpp
@@ -103,7 +103,7 @@ public:
{
_EnterCombat();
Talk(SAY_AGGRO);
-
+
eruptSection = 3;
events.ScheduleEvent(EVENT_DISRUPT, urand(15 * IN_MILLISECONDS, 20 * IN_MILLISECONDS), 0, PHASE_FIGHT);
events.ScheduleEvent(EVENT_FEVER, urand(10 * IN_MILLISECONDS, 20 * IN_MILLISECONDS), 0, PHASE_FIGHT);
@@ -182,7 +182,7 @@ public:
private:
uint32 eruptSection;
bool eruptDirection;
-
+
bool safetyDance; // is achievement still possible? (= no player deaths yet)
};
diff --git a/src/server/scripts/Northrend/Naxxramas/boss_noth.cpp b/src/server/scripts/Northrend/Naxxramas/boss_noth.cpp
index 810d446111a..106661b70bf 100644
--- a/src/server/scripts/Northrend/Naxxramas/boss_noth.cpp
+++ b/src/server/scripts/Northrend/Naxxramas/boss_noth.cpp
@@ -172,13 +172,13 @@ public:
Talk(SAY_DEATH);
}
- void DamageTaken(Unit* /*who*/, uint32& damage) // prevent noth from somehow dying in the balcony phase
+ void DamageTaken(Unit* /*who*/, uint32& damage) override // prevent noth from somehow dying in the balcony phase
{
if (!events.IsInPhase(PHASE_BALCONY))
return;
if (damage < me->GetHealth())
return;
-
+
me->SetHealth(1u);
damage = 0u;
}
@@ -226,7 +226,7 @@ public:
case EVENT_WARRIOR:
Talk(SAY_SUMMON);
Talk(EMOTE_SUMMON);
-
+
CastSummon(RAID_MODE(2, 3), 0, 0);
events.ScheduleEvent(EVENT_WARRIOR, 40 * IN_MILLISECONDS, 0, PHASE_GROUND);
@@ -291,7 +291,7 @@ public:
break;
case EVENT_GROUND:
++balconyCount;
-
+
DoCastAOE(SPELL_TELEPORT_BACK);
Talk(EMOTE_TELEPORT_2);
@@ -308,7 +308,7 @@ public:
{
/* workaround for movechase breaking after blinking
without this noth would just stand there unless his current target moves */
- if (justBlinked && me->GetVictim() && !me->IsWithinMeleeRange(me->EnsureVictim()))
+ if (justBlinked && me->GetVictim() && !me->IsWithinMeleeRange(me->EnsureVictim()))
{
me->GetMotionMaster()->Clear();
me->GetMotionMaster()->MoveChase(me->EnsureVictim());
@@ -321,7 +321,7 @@ public:
private:
uint32 balconyCount;
-
+
bool justBlinked;
uint32 _SummonWarriorSpells[N_WARRIOR_SPELLS];
diff --git a/src/server/scripts/Northrend/Naxxramas/boss_thaddius.cpp b/src/server/scripts/Northrend/Naxxramas/boss_thaddius.cpp
index d74fd5a03f8..50077fe9dc1 100644
--- a/src/server/scripts/Northrend/Naxxramas/boss_thaddius.cpp
+++ b/src/server/scripts/Northrend/Naxxramas/boss_thaddius.cpp
@@ -19,48 +19,104 @@
#include "ScriptedCreature.h"
#include "SpellScript.h"
#include "Player.h"
+#include "ObjectGuid.h"
#include "naxxramas.h"
-//Stalagg
-enum StalaggYells
+
+enum Phases
+{
+ PHASE_NOT_ENGAGED = 1,
+ PHASE_PETS,
+ PHASE_TRANSITION,
+ PHASE_THADDIUS,
+ PHASE_RESETTING
+};
+
+enum AIActions
{
- SAY_STAL_AGGRO = 0,
- SAY_STAL_SLAY = 1,
- SAY_STAL_DEATH = 2
+ ACTION_RESET_ENCOUNTER_TIMER = -1, // sent from instance AI
+ ACTION_BEGIN_RESET_ENCOUNTER = 0, // sent from thaddius to pets to trigger despawn and encounter reset
+ ACTION_RESET_ENCOUNTER, // sent from thaddius to pets to trigger respawn and full reset
+ ACTION_FEUGEN_DIED, // sent from respective pet to thaddius to indicate death
+ ACTION_STALAGG_DIED, // ^
+ ACTION_FEUGEN_RESET, // pet to thaddius
+ ACTION_STALAGG_RESET, // ^
+ ACTION_FEUGEN_AGGRO, // pet to thaddius on combat start
+ ACTION_STALAGG_AGGRO, // ^
+ ACTION_FEUGEN_REVIVING_FX, // thaddius to pet when pet reports its death
+ ACTION_STALAGG_REVIVING_FX, // ^
+ ACTION_FEUGEN_REVIVED, // thaddius to pet when pet should revive
+ ACTION_STALAGG_REVIVED, // ^
+ ACTION_TRANSITION, // thaddius to pets when transition starts (coil overload anim)
+ ACTION_TRANSITION_2, // thaddius to pets to make the coils shock him
+ ACTION_TRANSITION_3, // thaddius to pets to disable coil GO after spawn
+
+ ACTION_POLARITY_CROSSED // triggers achievement failure, sent from spellscript
};
-enum StalagSpells
+enum Events
{
- SPELL_POWERSURGE = 28134,
- SPELL_MAGNETIC_PULL = 28338,
- SPELL_STALAGG_TESLA = 28097
+ EVENT_SHIFT = 1, // polarity shift
+ EVENT_SHIFT_TALK, // polarity shift yell (hack? couldn't find any event for cast finish)
+ EVENT_CHAIN, // chain lightning
+ EVENT_BERSERK, // enrage timer
+ EVENT_REVIVE_FEUGEN, // timer until feugen is revived (if stalagg still lives)
+ EVENT_REVIVE_STALAGG, // timer until stalagg is revived (if feugen still lives)
+ EVENT_TRANSITION_1, // timer until overload emote
+ EVENT_TRANSITION_2, // timer until thaddius gets zapped by the coils
+ EVENT_TRANSITION_3, // timer until thaddius engages
+ EVENT_ENABLE_BALL_LIGHTNING // grace period after thaddius aggro after which he starts being a baller (e.g. tossing ball lightning at out of range targets)
};
-//Feugen
-enum FeugenYells
+enum Misc
{
- SAY_FEUG_AGGRO = 0,
- SAY_FEUG_SLAY = 1,
- SAY_FEUG_DEATH = 2
+ MAX_POLARITY_10M = 5,
+ MAX_POLARITY_25M = 13,
+
+ DATA_POLARITY_CROSSED = 1,
+};
+
+// Feugen & Stalagg
+enum PetYells
+{
+ SAY_STALAGG_AGGRO = 0,
+ SAY_STALAGG_SLAY = 1,
+ SAY_STALAGG_DEATH = 2,
+
+ SAY_FEUGEN_AGGRO = 0,
+ SAY_FEUGEN_SLAY = 1,
+ SAY_FEUGEN_DEATH = 2,
+
+ EMOTE_FEIGN_DEATH = 3,
+ EMOTE_FEIGN_REVIVE = 4,
+
+ EMOTE_TESLA_LINK_BREAKS = 0,
+ EMOTE_TESLA_OVERLOAD = 1
};
-enum FeugenSpells
+enum PetSpells
{
- SPELL_STATICFIELD = 28135,
- SPELL_FEUGEN_TESLA = 28109
+ SPELL_STALAGG_POWERSURGE = 28134,
+ //SPELL_STALAGG_TESLA = 28097,
+ SPELL_STALAGG_TESLA_PERIODIC = 28098,
+ SPELL_STALAGG_CHAIN_VISUAL = 28096,
+
+ SPELL_FEUGEN_STATICFIELD = 28135,
+ //SPELL_FEUGEN_TESLA = 28109,
+ SPELL_FEUGEN_TESLA_PERIODIC = 28110,
+ SPELL_FEUGEN_CHAIN_VISUAL = 28111,
+
+ SPELL_MAGNETIC_PULL = 54517,
+ SPELL_MAGNETIC_PULL_EFFECT = 28337,
+
+ SPELL_TESLA_SHOCK = 28099
};
-// Thaddius DoAction
-enum ThaddiusActions
+enum PetMisc
{
- ACTION_FEUGEN_RESET,
- ACTION_FEUGEN_DIED,
- ACTION_STALAGG_RESET,
- ACTION_STALAGG_DIED
+ OVERLOAD_DISTANCE = 28
};
-//generic
-#define C_TESLA_COIL 16218 //the coils (emotes "Tesla Coil overloads!")
//Thaddius
enum ThaddiusYells
@@ -70,34 +126,31 @@ enum ThaddiusYells
SAY_SLAY = 2,
SAY_ELECT = 3,
SAY_DEATH = 4,
- SAY_SCREAM = 5
+ SAY_SCREAM = 5,
+
+ EMOTE_POLARITY_SHIFTED = 6
};
enum ThaddiusSpells
{
- SPELL_POLARITY_SHIFT = 28089,
- SPELL_BALL_LIGHTNING = 28299,
- SPELL_CHAIN_LIGHTNING = 28167,
- SPELL_BERSERK = 27680,
- SPELL_POSITIVE_CHARGE = 28062,
- SPELL_POSITIVE_CHARGE_STACK = 29659,
- SPELL_NEGATIVE_CHARGE = 28085,
- SPELL_NEGATIVE_CHARGE_STACK = 29660,
- SPELL_POSITIVE_POLARITY = 28059,
- SPELL_NEGATIVE_POLARITY = 28084,
-};
+ SPELL_THADDIUS_INACTIVE_VISUAL = 28160,
+ SPELL_THADDIUS_SPARK_VISUAL = 28136,
+ SPELL_SHOCK_VISUAL = 28159,
-enum Events
-{
- EVENT_NONE,
- EVENT_SHIFT,
- EVENT_CHAIN,
- EVENT_BERSERK,
-};
+ SPELL_BALL_LIGHTNING = 28299,
+ SPELL_CHAIN_LIGHTNING = 28167,
+ SPELL_BERSERK = 27680,
-enum Achievement
-{
- DATA_POLARITY_SWITCH = 76047605,
+ // polarity handling
+ SPELL_POLARITY_SHIFT = 28089,
+
+ SPELL_POSITIVE_CHARGE_APPLY = 28059,
+ SPELL_POSITIVE_CHARGE_TICK = 28062,
+ SPELL_POSITIVE_CHARGE_AMP = 29659,
+
+ SPELL_NEGATIVE_CHARGE_APPLY = 28084,
+ SPELL_NEGATIVE_CHARGE_TICK = 28085,
+ SPELL_NEGATIVE_CHARGE_AMP = 29660,
};
class boss_thaddius : public CreatureScript
@@ -112,166 +165,272 @@ public:
struct boss_thaddiusAI : public BossAI
{
- boss_thaddiusAI(Creature* creature) : BossAI(creature, BOSS_THADDIUS)
- {
- // init is a bit tricky because thaddius shall track the life of both adds, but not if there was a wipe
- // and, in particular, if there was a crash after both adds were killed (should not respawn)
-
- // Moreover, the adds may not yet be spawn. So just track down the status if mob is spawn
- // and each mob will send its status at reset (meaning that it is alive)
- checkFeugenAlive = false;
- if (Creature* pFeugen = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_FEUGEN)))
- checkFeugenAlive = pFeugen->IsAlive();
+ public:
+ boss_thaddiusAI(Creature* creature) : BossAI(creature, BOSS_THADDIUS), stalaggAlive(true), feugenAlive(true), ballLightningEnabled(false), shockingEligibility(true)
+ {
+ if (instance->GetBossState(BOSS_THADDIUS) != DONE)
+ {
+ events.SetPhase(PHASE_NOT_ENGAGED);
+ SetCombatMovement(false);
- checkStalaggAlive = false;
- if (Creature* pStalagg = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_STALAGG)))
- checkStalaggAlive = pStalagg->IsAlive();
+ BeginResetEncounter(); // initialize everything properly, and ensure that the coils are loaded by the time we initialize
+ }
+ }
- if (!checkFeugenAlive && !checkStalaggAlive)
+ void KilledUnit(Unit* victim) override
{
- me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_PC | UNIT_FLAG_NOT_SELECTABLE | UNIT_FLAG_STUNNED);
- me->SetReactState(REACT_AGGRESSIVE);
+ if (victim->GetTypeId() == TYPEID_PLAYER)
+ Talk(SAY_SLAY);
}
- else
+
+ void Reset() override
{
- me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_PC | UNIT_FLAG_NOT_SELECTABLE | UNIT_FLAG_STUNNED);
- me->SetReactState(REACT_PASSIVE);
+ if(events.IsInPhase(PHASE_TRANSITION) || events.IsInPhase(PHASE_THADDIUS))
+ BeginResetEncounter();
}
- polaritySwitch = false;
- uiAddsTimer = 0;
- }
-
- bool checkStalaggAlive;
- bool checkFeugenAlive;
- bool polaritySwitch;
- uint32 uiAddsTimer;
-
- void KilledUnit(Unit* /*victim*/) override
- {
- if (!(rand32() % 5))
- Talk(SAY_SLAY);
- }
-
- void JustDied(Unit* /*killer*/) override
- {
- _JustDied();
- Talk(SAY_DEATH);
- }
+ void JustDied(Unit* /*killer*/) override
+ {
+ _JustDied();
+ me->setActive(false);
+ if (Creature* stalagg = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_STALAGG)))
+ stalagg->setActive(false);
+ if (Creature* feugen = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_FEUGEN)))
+ feugen->setActive(false);
+ Talk(SAY_DEATH);
+ }
- void DoAction(int32 action) override
- {
- switch (action)
+ void DoAction(int32 action) override
{
- case ACTION_FEUGEN_RESET:
- checkFeugenAlive = true;
- break;
- case ACTION_FEUGEN_DIED:
- checkFeugenAlive = false;
- break;
- case ACTION_STALAGG_RESET:
- checkStalaggAlive = true;
- break;
- case ACTION_STALAGG_DIED:
- checkStalaggAlive = false;
- break;
+ switch (action)
+ {
+ case ACTION_RESET_ENCOUNTER_TIMER:
+ if (events.IsInPhase(PHASE_RESETTING))
+ ResetEncounter();
+ break;
+ case ACTION_FEUGEN_RESET:
+ case ACTION_STALAGG_RESET:
+ if (!events.IsInPhase(PHASE_NOT_ENGAGED) && !events.IsInPhase(PHASE_RESETTING))
+ BeginResetEncounter();
+ break;
+ case ACTION_FEUGEN_AGGRO:
+ case ACTION_STALAGG_AGGRO:
+ if (events.IsInPhase(PHASE_RESETTING))
+ return BeginResetEncounter();
+ if (!events.IsInPhase(PHASE_NOT_ENGAGED))
+ return;
+ events.SetPhase(PHASE_PETS);
+
+ shockingEligibility = true;
+
+ if (!instance->CheckRequiredBosses(BOSS_THADDIUS))
+ return BeginResetEncounter();
+ instance->SetBossState(BOSS_THADDIUS, IN_PROGRESS);
+
+ me->setActive(true);
+ if (Creature* stalagg = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_STALAGG)))
+ stalagg->setActive(true);
+ if (Creature* feugen = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_FEUGEN)))
+ feugen->setActive(true);
+ break;
+ case ACTION_FEUGEN_DIED:
+ if (Creature* feugen = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_FEUGEN)))
+ feugen->AI()->DoAction(ACTION_FEUGEN_REVIVING_FX);
+ feugenAlive = false;
+ if (stalaggAlive)
+ events.ScheduleEvent(EVENT_REVIVE_FEUGEN, 5 * IN_MILLISECONDS, 0, PHASE_PETS);
+ else
+ Transition();
+
+ break;
+ case ACTION_STALAGG_DIED:
+ if (Creature* stalagg = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_STALAGG)))
+ stalagg->AI()->DoAction(ACTION_STALAGG_REVIVING_FX);
+ stalaggAlive = false;
+ if (feugenAlive)
+ events.ScheduleEvent(EVENT_REVIVE_STALAGG, 5 * IN_MILLISECONDS, 0, PHASE_PETS);
+ else
+ Transition();
+
+ break;
+
+ case ACTION_POLARITY_CROSSED:
+ shockingEligibility = false;
+ break;
+ default:
+ break;
+ }
}
- if (!checkFeugenAlive && !checkStalaggAlive)
+ uint32 GetData(uint32 id) const override
{
- me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_PC | UNIT_FLAG_NOT_SELECTABLE | UNIT_FLAG_STUNNED);
- // REACT_AGGRESSIVE only reset when he takes damage.
- DoZoneInCombat();
+ return (id == DATA_POLARITY_CROSSED && shockingEligibility) ? 1u : 0u;
}
- else
+
+ void Transition() // initiate transition between pet phase and thaddius phase
{
- me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_PC | UNIT_FLAG_NOT_SELECTABLE | UNIT_FLAG_STUNNED);
- me->SetReactState(REACT_PASSIVE);
+ events.SetPhase(PHASE_TRANSITION);
+
+ me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
+
+ events.ScheduleEvent(EVENT_TRANSITION_1, 10 * IN_MILLISECONDS, 0, PHASE_TRANSITION);
+ events.ScheduleEvent(EVENT_TRANSITION_2, 12 * IN_MILLISECONDS, 0, PHASE_TRANSITION);
+ events.ScheduleEvent(EVENT_TRANSITION_3, 14 * IN_MILLISECONDS, 0, PHASE_TRANSITION);
}
- }
- void EnterCombat(Unit* /*who*/) override
- {
- _EnterCombat();
- Talk(SAY_AGGRO);
- events.ScheduleEvent(EVENT_SHIFT, 30000);
- events.ScheduleEvent(EVENT_CHAIN, urand(10000, 20000));
- events.ScheduleEvent(EVENT_BERSERK, 360000);
- }
+ void BeginResetEncounter()
+ {
+ if (!me->IsAlive())
+ return;
+ if (events.IsInPhase(PHASE_RESETTING))
+ return;
+
+ instance->ProcessEvent(me, EVENT_THADDIUS_BEGIN_RESET);
- void DamageTaken(Unit* /*pDoneBy*/, uint32 & /*uiDamage*/) override
- {
- me->SetReactState(REACT_AGGRESSIVE);
- }
+ instance->SetBossState(BOSS_THADDIUS, NOT_STARTED);
- void SetData(uint32 id, uint32 data) override
- {
- if (id == DATA_POLARITY_SWITCH)
- polaritySwitch = data ? true : false;
- }
+ // remove polarity shift debuffs on reset
+ instance->DoRemoveAurasDueToSpellOnPlayers(SPELL_POSITIVE_CHARGE_APPLY);
+ instance->DoRemoveAurasDueToSpellOnPlayers(SPELL_NEGATIVE_CHARGE_APPLY);
- uint32 GetData(uint32 id) const override
- {
- if (id != DATA_POLARITY_SWITCH)
- return 0;
+ me->DespawnOrUnsummon();
- return uint32(polaritySwitch);
- }
+ me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_PC | UNIT_FLAG_NOT_SELECTABLE | UNIT_FLAG_STUNNED);
+ events.SetPhase(PHASE_RESETTING);
+ if (Creature* feugen = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_FEUGEN)))
+ feugen->AI()->DoAction(ACTION_BEGIN_RESET_ENCOUNTER);
+ if (Creature* stalagg = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_STALAGG)))
+ stalagg->AI()->DoAction(ACTION_BEGIN_RESET_ENCOUNTER);
- void UpdateAI(uint32 diff) override
- {
- if (checkFeugenAlive && checkStalaggAlive)
- uiAddsTimer = 0;
+ me->setActive(false);
+ }
+
+ void ResetEncounter()
+ {
+ events.SetPhase(PHASE_NOT_ENGAGED);
+ feugenAlive = true;
+ stalaggAlive = true;
+ me->Respawn(true);
+ me->CastSpell(me, SPELL_THADDIUS_INACTIVE_VISUAL);
+
+ if (Creature* feugen = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_FEUGEN)))
+ feugen->AI()->DoAction(ACTION_RESET_ENCOUNTER);
+ if (Creature* stalagg = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_STALAGG)))
+ stalagg->AI()->DoAction(ACTION_RESET_ENCOUNTER);
+ _Reset();
+ }
- if (checkStalaggAlive != checkFeugenAlive)
+ void UpdateAI(uint32 diff) override
{
- uiAddsTimer += diff;
- if (uiAddsTimer > 5000)
+ if (events.IsInPhase(PHASE_NOT_ENGAGED))
+ return;
+ if (events.IsInPhase(PHASE_THADDIUS) && !UpdateVictim())
+ return;
+
+ events.Update(diff);
+ while (uint32 eventId = events.ExecuteEvent())
{
- if (!checkStalaggAlive)
+ switch (eventId)
{
- if (Creature* pStalagg = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_STALAGG)))
- pStalagg->Respawn();
- }
- else
- {
- if (Creature* pFeugen = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_FEUGEN)))
- pFeugen->Respawn();
+ case EVENT_REVIVE_FEUGEN:
+ feugenAlive = true;
+ if (Creature* feugen = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_FEUGEN)))
+ feugen->AI()->DoAction(ACTION_FEUGEN_REVIVED);
+ break;
+ case EVENT_REVIVE_STALAGG:
+ stalaggAlive = true;
+ if (Creature* stalagg = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_STALAGG)))
+ stalagg->AI()->DoAction(ACTION_STALAGG_REVIVED);
+ break;
+ case EVENT_TRANSITION_1: // tesla coils overload
+ if (Creature* feugen = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_FEUGEN)))
+ feugen->AI()->DoAction(ACTION_TRANSITION);
+ if (Creature* stalagg = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_STALAGG)))
+ stalagg->AI()->DoAction(ACTION_TRANSITION);
+ break;
+ case EVENT_TRANSITION_2: // tesla coils shock thaddius
+ me->CastSpell(me, SPELL_THADDIUS_SPARK_VISUAL, true);
+ if (Creature* feugen = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_FEUGEN)))
+ feugen->AI()->DoAction(ACTION_TRANSITION_2);
+ if (Creature* stalagg = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_STALAGG)))
+ stalagg->AI()->DoAction(ACTION_TRANSITION_2);
+ break;
+ case EVENT_TRANSITION_3: // thaddius becomes active
+ me->CastSpell(me, SPELL_THADDIUS_SPARK_VISUAL, true);
+ ballLightningEnabled = false;
+ me->RemoveAura(SPELL_THADDIUS_INACTIVE_VISUAL);
+ me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_STUNNED);
+ me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_PC);
+
+ DoZoneInCombat();
+ if (Unit* closest = SelectTarget(SELECT_TARGET_NEAREST, 0, 500.0f))
+ AttackStart(closest);
+ else // if there is no nearest target, then there is no target, meaning we should reset
+ return BeginResetEncounter();
+
+ if (Creature* feugen = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_FEUGEN)))
+ feugen->AI()->DoAction(ACTION_TRANSITION_3);
+ if (Creature* stalagg = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_STALAGG)))
+ stalagg->AI()->DoAction(ACTION_TRANSITION_3);
+
+ events.SetPhase(PHASE_THADDIUS);
+
+ Talk(SAY_AGGRO);
+
+ events.ScheduleEvent(EVENT_ENABLE_BALL_LIGHTNING, 5 * IN_MILLISECONDS, 0, PHASE_THADDIUS);
+ events.ScheduleEvent(EVENT_SHIFT, 10 * IN_MILLISECONDS, 0, PHASE_THADDIUS);
+ events.ScheduleEvent(EVENT_CHAIN, urand(10, 20) * IN_MILLISECONDS, 0, PHASE_THADDIUS);
+ events.ScheduleEvent(EVENT_BERSERK, 6 * MINUTE * IN_MILLISECONDS, 0, PHASE_THADDIUS);
+
+ break;
+ case EVENT_ENABLE_BALL_LIGHTNING:
+ ballLightningEnabled = true;
+ break;
+ case EVENT_SHIFT:
+ me->CastStop(); // shift overrides all other spells
+ DoCastAOE(SPELL_POLARITY_SHIFT);
+ events.ScheduleEvent(EVENT_SHIFT_TALK, 3 * IN_MILLISECONDS, PHASE_THADDIUS);
+ events.ScheduleEvent(EVENT_SHIFT, 30 * IN_MILLISECONDS, PHASE_THADDIUS);
+ break;
+ case EVENT_SHIFT_TALK:
+ Talk(SAY_ELECT);
+ Talk(EMOTE_POLARITY_SHIFTED);
+ break;
+ case EVENT_CHAIN:
+ if (me->FindCurrentSpellBySpellId(SPELL_POLARITY_SHIFT)) // delay until shift is over
+ events.ScheduleEvent(EVENT_CHAIN, 3 * IN_MILLISECONDS, 0, PHASE_THADDIUS);
+ else
+ {
+ me->CastStop();
+ DoCastVictim(SPELL_CHAIN_LIGHTNING);
+ events.ScheduleEvent(EVENT_CHAIN, urand(10, 20) * IN_MILLISECONDS, PHASE_THADDIUS);
+ }
+ break;
+ case EVENT_BERSERK:
+ me->CastStop();
+ DoCast(me, SPELL_BERSERK);
+ break;
+ default:
+ break;
}
}
- }
- if (!UpdateVictim())
- return;
-
- events.Update(diff);
-
- if (me->HasUnitState(UNIT_STATE_CASTING))
- return;
-
- while (uint32 eventId = events.ExecuteEvent())
- {
- switch (eventId)
+ if (events.IsInPhase(PHASE_THADDIUS))
{
- case EVENT_SHIFT:
- DoCastAOE(SPELL_POLARITY_SHIFT);
- events.ScheduleEvent(EVENT_SHIFT, 30000);
- return;
- case EVENT_CHAIN:
- DoCastVictim(SPELL_CHAIN_LIGHTNING);
- events.ScheduleEvent(EVENT_CHAIN, urand(10000, 20000));
- return;
- case EVENT_BERSERK:
- DoCast(me, SPELL_BERSERK);
- return;
+ if (me->IsWithinMeleeRange(me->GetVictim()))
+ DoMeleeAttackIfReady();
+ else
+ if (ballLightningEnabled)
+ if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM))
+ DoCast(target, SPELL_BALL_LIGHTNING);
}
}
- if (events.GetTimer() > 15000 && !me->IsWithinMeleeRange(me->GetVictim()))
- DoCastVictim(SPELL_BALL_LIGHTNING);
- else
- DoMeleeAttackIfReady();
- }
+ private:
+ bool stalaggAlive;
+ bool feugenAlive;
+ bool ballLightningEnabled;
+ bool shockingEligibility;
};
};
@@ -288,88 +447,257 @@ public:
struct npc_stalaggAI : public ScriptedAI
{
- npc_stalaggAI(Creature* creature) : ScriptedAI(creature)
- {
- Initialize();
- instance = creature->GetInstanceScript();
- }
+ public:
+ npc_stalaggAI(Creature* creature) : ScriptedAI(creature), _myCoil(ObjectGuid::Empty), _myCoilGO(ObjectGuid::Empty), isOverloading(false), refreshBeam(false), isFeignDeath(false)
+ {
+ Initialize();
+ instance = creature->GetInstanceScript();
+ }
- void Initialize()
- {
- powerSurgeTimer = urand(20000, 25000);
- magneticPullTimer = 20000;
- }
+ void Initialize()
+ {
+ if (GameObject* coil = myCoilGO())
+ coil->SetGoState(GO_STATE_ACTIVE);
- InstanceScript* instance;
+ // if the encounter reset while feigning death
+ me->SetStandState(UNIT_STAND_STATE_STAND);
+ me->SetReactState(REACT_AGGRESSIVE);
+ me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
+ isOverloading = false;
+ isFeignDeath = false;
- uint32 powerSurgeTimer;
- uint32 magneticPullTimer;
+ // force tesla coil state refresh
+ refreshBeam = true;
- void Reset() override
- {
- if (Creature* pThaddius = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_THADDIUS)))
- if (pThaddius->AI())
- pThaddius->AI()->DoAction(ACTION_STALAGG_RESET);
- Initialize();
- }
+ powerSurgeTimer = 10 * IN_MILLISECONDS;
+ }
- void KilledUnit(Unit* /*victim*/) override
- {
- if (!(rand32() % 5))
- Talk(SAY_STAL_SLAY);
- }
+ void Reset() override
+ {
+ if (isFeignDeath || !me->IsAlive())
+ return;
+ if (Creature* thaddius = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_THADDIUS)))
+ thaddius->AI()->DoAction(ACTION_STALAGG_RESET);
+ }
- void EnterCombat(Unit* /*who*/) override
- {
- Talk(SAY_STAL_AGGRO);
- DoCast(SPELL_STALAGG_TESLA);
- }
+ void BeginResetEncounter()
+ {
+ if (GameObject* coil = myCoilGO())
+ coil->SetGoState(GO_STATE_READY);
+ me->DespawnOrUnsummon();
+ me->setActive(false);
+ }
- void JustDied(Unit* /*killer*/) override
- {
- Talk(SAY_STAL_DEATH);
- if (Creature* pThaddius = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_THADDIUS)))
- if (pThaddius->AI())
- pThaddius->AI()->DoAction(ACTION_STALAGG_DIED);
- }
+ void ResetEncounter()
+ {
+ me->Respawn(true);
+ Initialize();
+ }
- void UpdateAI(uint32 uiDiff) override
- {
- if (!UpdateVictim())
- return;
+ void DoAction(int32 action) override
+ {
+ switch (action)
+ {
+ case ACTION_BEGIN_RESET_ENCOUNTER:
+ BeginResetEncounter();
+ break;
+ case ACTION_RESET_ENCOUNTER:
+ ResetEncounter();
+ break;
+ case ACTION_STALAGG_REVIVING_FX:
+ break;
+ case ACTION_STALAGG_REVIVED:
+ if (!isFeignDeath)
+ break;
+
+ me->SetFullHealth();
+ me->SetStandState(UNIT_STAND_STATE_STAND);
+ me->SetReactState(REACT_AGGRESSIVE);
+ me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
+ Talk(EMOTE_FEIGN_REVIVE);
+ isFeignDeath = false;
+
+ refreshBeam = true; // force beam refresh
+
+ if (Creature* feugen = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_FEUGEN)))
+ if (feugen->GetVictim())
+ {
+ me->AddThreat(feugen->EnsureVictim(), 0.0f);
+ me->SetInCombatWith(feugen->EnsureVictim());
+ }
+ break;
+ case ACTION_TRANSITION:
+ me->Kill(me); // true death
+ me->DespawnOrUnsummon();
+
+ if (Creature* coil = myCoil())
+ {
+ coil->CastStop();
+ coil->AI()->Talk(EMOTE_TESLA_OVERLOAD);
+ }
+ break;
+ case ACTION_TRANSITION_2:
+ if (Creature* coil = myCoil())
+ if (Creature* thaddius = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_THADDIUS)))
+ coil->CastSpell(thaddius, SPELL_SHOCK_VISUAL);
+ break;
+ case ACTION_TRANSITION_3:
+ if (GameObject* coil = myCoilGO())
+ coil->SetGoState(GO_STATE_READY);
+ break;
+ default:
+ break;
+ }
+ }
+
+ void KilledUnit(Unit* victim) override
+ {
+ if (victim->GetTypeId() == TYPEID_PLAYER)
+ Talk(SAY_STALAGG_SLAY);
+ }
- if (magneticPullTimer <= uiDiff)
+ void EnterCombat(Unit* who) override
{
- if (Creature* pFeugen = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_FEUGEN)))
+ Talk(SAY_STALAGG_AGGRO);
+
+ if (Creature* thaddius = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_THADDIUS)))
+ thaddius->AI()->DoAction(ACTION_STALAGG_AGGRO);
+
+ if (Creature* feugen = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_FEUGEN)))
+ if (!feugen->IsInCombat())
+ {
+ feugen->AddThreat(who, 0.0f);
+ feugen->SetInCombatWith(who);
+ }
+ }
+
+ void DamageTaken(Unit* /*who*/, uint32& damage) override
+ {
+ if (damage < me->GetHealth())
+ return;
+
+ if (isFeignDeath) // don't take damage while feigning death
{
- Unit* pStalaggVictim = me->GetVictim();
- Unit* pFeugenVictim = pFeugen->GetVictim();
+ damage = 0;
+ return;
+ }
+
+ isFeignDeath = true;
+ isOverloading = false;
+
+ Talk(EMOTE_FEIGN_DEATH);
+ if (Creature* thaddius = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_THADDIUS)))
+ thaddius->AI()->DoAction(ACTION_STALAGG_DIED);
+
+ me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
+ me->RemoveAllAuras();
+ me->SetReactState(REACT_PASSIVE);
+ me->AttackStop();
+ me->StopMoving();
+ me->SetStandState(UNIT_STAND_STATE_DEAD);
+
+ damage = 0;
- if (pFeugenVictim && pStalaggVictim)
+ // force beam refresh as we just removed auras
+ refreshBeam = true;
+ }
+
+ void SpellHit(Unit* caster, SpellInfo const* spell) override
+ {
+ if (!caster)
+ return;
+ if (spell->Id != SPELL_STALAGG_TESLA_PERIODIC)
+ return;
+ if (!isFeignDeath && me->IsInCombat() && !me->GetHomePosition().IsInDist(me, OVERLOAD_DISTANCE))
+ {
+ if (!isOverloading)
{
- // magnetic pull is not working. So just jump.
+ isOverloading = true;
+ caster->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_PC);
+ if (Creature* creatureCaster = caster->ToCreature())
+ creatureCaster->AI()->Talk(EMOTE_TESLA_LINK_BREAKS);
+ me->RemoveAura(SPELL_STALAGG_CHAIN_VISUAL);
+ }
+ if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM))
+ {
+ caster->CastStop(SPELL_TESLA_SHOCK);
+ caster->CastSpell(target, SPELL_TESLA_SHOCK,true);
+ }
+ }
+ else if (isOverloading || refreshBeam)
+ {
+ isOverloading = false;
+ refreshBeam = false;
+ caster->CastStop();
+ caster->CastSpell(me, SPELL_STALAGG_CHAIN_VISUAL, true);
+ caster->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_PC);
+ }
+ }
- // reset aggro to be sure that feugen will not follow the jump
- pFeugen->getThreatManager().modifyThreatPercent(pFeugenVictim, -100);
- pFeugenVictim->JumpTo(me, 0.3f);
+ void UpdateAI(uint32 uiDiff) override
+ {
+ if(!isFeignDeath)
+ if (!UpdateVictim())
+ return;
- me->getThreatManager().modifyThreatPercent(pStalaggVictim, -100);
- pStalaggVictim->JumpTo(pFeugen, 0.3f);
+ if (powerSurgeTimer <= uiDiff)
+ {
+ if (isFeignDeath) // delay until potential revive
+ powerSurgeTimer = 0u;
+ else
+ {
+ DoCast(me, SPELL_STALAGG_POWERSURGE);
+ powerSurgeTimer = urand(25, 30) * IN_MILLISECONDS;
}
}
+ else
+ powerSurgeTimer -= uiDiff;
- magneticPullTimer = 20000;
+ if(!isFeignDeath)
+ DoMeleeAttackIfReady();
}
- else magneticPullTimer -= uiDiff;
- if (powerSurgeTimer <= uiDiff)
+ private:
+ Creature* myCoil()
{
- DoCast(me, SPELL_POWERSURGE);
- powerSurgeTimer = urand(15000, 20000);
- } else powerSurgeTimer -= uiDiff;
+ Creature* coil = nullptr;
+ if (_myCoil)
+ coil = ObjectAccessor::GetCreature(*me, _myCoil);
+ if (!coil)
+ {
+ coil = me->FindNearestCreature(NPC_TESLA, 1000.0f, true);
+ if (coil)
+ {
+ _myCoil = coil->GetGUID();
+ coil->SetReactState(REACT_PASSIVE);
+ }
+ }
+ return coil;
+ }
- DoMeleeAttackIfReady();
- }
+ GameObject* myCoilGO()
+ {
+ GameObject* coil = nullptr;
+ if (_myCoilGO)
+ coil = ObjectAccessor::GetGameObject(*me, _myCoilGO);
+ if (!coil)
+ {
+ coil = me->FindNearestGameObject(GO_CONS_NOX_TESLA_STALAGG, 1000.0f);
+ if (coil)
+ _myCoilGO = coil->GetGUID();
+ }
+ return coil;
+ }
+
+ InstanceScript* instance;
+
+ uint32 powerSurgeTimer;
+
+ ObjectGuid _myCoil;
+ ObjectGuid _myCoilGO;
+ bool isOverloading;
+ bool refreshBeam;
+ bool isFeignDeath;
};
};
@@ -386,142 +714,381 @@ public:
struct npc_feugenAI : public ScriptedAI
{
- npc_feugenAI(Creature* creature) : ScriptedAI(creature)
- {
- Initialize();
- instance = creature->GetInstanceScript();
- }
-
- void Initialize()
- {
- staticFieldTimer = 5000;
- }
+ public:
+ npc_feugenAI(Creature* creature) : ScriptedAI(creature), _myCoil(ObjectGuid::Empty), _myCoilGO(ObjectGuid::Empty), isOverloading(false), refreshBeam(false), isFeignDeath(false)
+ {
+ Initialize();
+ instance = creature->GetInstanceScript();
+ }
- InstanceScript* instance;
+ void Initialize()
+ {
+ if (GameObject* coil = myCoilGO())
+ coil->SetGoState(GO_STATE_ACTIVE);
- uint32 staticFieldTimer;
+ // if the encounter reset while feigning death
+ me->SetStandState(UNIT_STAND_STATE_STAND);
+ me->SetReactState(REACT_AGGRESSIVE);
+ me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
+ isOverloading = false;
+ isFeignDeath = false;
- void Reset() override
- {
- if (Creature* pThaddius = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_THADDIUS)))
- if (pThaddius->AI())
- pThaddius->AI()->DoAction(ACTION_FEUGEN_RESET);
- Initialize();
- }
+ // force coil state to refresh
+ refreshBeam = true;
- void KilledUnit(Unit* /*victim*/) override
- {
- if (!(rand32() % 5))
- Talk(SAY_FEUG_SLAY);
- }
+ staticFieldTimer = 6 * IN_MILLISECONDS;
+ magneticPullTimer = 20 * IN_MILLISECONDS;
+ }
- void EnterCombat(Unit* /*who*/) override
- {
- Talk(SAY_FEUG_AGGRO);
- DoCast(SPELL_FEUGEN_TESLA);
- }
+ void Reset() override
+ {
+ if (isFeignDeath || !me->IsAlive())
+ return;
+ if (Creature* thaddius = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_THADDIUS)))
+ thaddius->AI()->DoAction(ACTION_FEUGEN_RESET);
+ }
- void JustDied(Unit* /*killer*/) override
- {
- Talk(SAY_FEUG_DEATH);
- if (Creature* pThaddius = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_THADDIUS)))
- if (pThaddius->AI())
- pThaddius->AI()->DoAction(ACTION_FEUGEN_DIED);
- }
+ void BeginResetEncounter()
+ {
+ if (GameObject* coil = myCoilGO())
+ coil->SetGoState(GO_STATE_READY);
+ me->DespawnOrUnsummon();
+ me->setActive(false);
+ }
- void UpdateAI(uint32 uiDiff) override
- {
- if (!UpdateVictim())
- return;
+ void ResetEncounter()
+ {
+ me->Respawn(true);
+ Initialize();
+ }
- if (staticFieldTimer <= uiDiff)
+ void DoAction(int32 action) override
{
- DoCast(me, SPELL_STATICFIELD);
- staticFieldTimer = 5000;
- } else staticFieldTimer -= uiDiff;
+ switch (action)
+ {
+ case ACTION_BEGIN_RESET_ENCOUNTER:
+ BeginResetEncounter();
+ break;
+ case ACTION_RESET_ENCOUNTER:
+ ResetEncounter();
+ break;
+ case ACTION_FEUGEN_REVIVING_FX:
+ break;
+ case ACTION_FEUGEN_REVIVED:
+ if (!isFeignDeath)
+ break;
+
+ me->SetFullHealth();
+ me->SetStandState(UNIT_STAND_STATE_STAND);
+ me->SetReactState(REACT_AGGRESSIVE);
+ me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
+ Talk(EMOTE_FEIGN_REVIVE);
+ isFeignDeath = false;
+
+ refreshBeam = true; // force beam refresh
+
+ if (Creature* stalagg = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_STALAGG)))
+ if (stalagg->GetVictim())
+ {
+ me->AddThreat(stalagg->EnsureVictim(), 0.0f);
+ me->SetInCombatWith(stalagg->EnsureVictim());
+ }
+ staticFieldTimer = 6 * IN_MILLISECONDS;
+ magneticPullTimer = 30 * IN_MILLISECONDS;
+ break;
+ case ACTION_TRANSITION:
+ me->Kill(me); // true death this time around
+ me->DespawnOrUnsummon();
+
+ if (Creature* coil = myCoil())
+ {
+ coil->CastStop();
+ coil->AI()->Talk(EMOTE_TESLA_OVERLOAD);
+ }
+ break;
+ case ACTION_TRANSITION_2:
+ if (Creature* coil = myCoil())
+ if (Creature* thaddius = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_THADDIUS)))
+ coil->CastSpell(thaddius, SPELL_SHOCK_VISUAL);
+ break;
+ case ACTION_TRANSITION_3:
+ if (GameObject* coil = myCoilGO())
+ coil->SetGoState(GO_STATE_READY);
+ default:
+ break;
+ }
+ }
- DoMeleeAttackIfReady();
- }
- };
+ void KilledUnit(Unit* victim) override
+ {
+ if(victim->GetTypeId() == TYPEID_PLAYER)
+ Talk(SAY_FEUGEN_SLAY);
+ }
-};
+ void EnterCombat(Unit* who) override
+ {
+ Talk(SAY_FEUGEN_AGGRO);
-class spell_thaddius_pos_neg_charge : public SpellScriptLoader
-{
- public:
- spell_thaddius_pos_neg_charge() : SpellScriptLoader("spell_thaddius_pos_neg_charge") { }
+ if (Creature* thaddius = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_THADDIUS)))
+ thaddius->AI()->DoAction(ACTION_STALAGG_AGGRO);
- class spell_thaddius_pos_neg_charge_SpellScript : public SpellScript
- {
- PrepareSpellScript(spell_thaddius_pos_neg_charge_SpellScript);
+ if (Creature* stalagg = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_STALAGG)))
+ if (!stalagg->IsInCombat())
+ {
+ stalagg->AddThreat(who, 0.0f);
+ stalagg->SetInCombatWith(who);
+ }
+ }
- bool Validate(SpellInfo const* /*spell*/) override
+ void DamageTaken(Unit* /*who*/, uint32& damage) override
{
- if (!sSpellMgr->GetSpellInfo(SPELL_POSITIVE_CHARGE))
- return false;
- if (!sSpellMgr->GetSpellInfo(SPELL_POSITIVE_CHARGE_STACK))
- return false;
- if (!sSpellMgr->GetSpellInfo(SPELL_NEGATIVE_CHARGE))
- return false;
- if (!sSpellMgr->GetSpellInfo(SPELL_NEGATIVE_CHARGE_STACK))
- return false;
- return true;
+ if (damage < me->GetHealth())
+ return;
+
+ if (isFeignDeath) // don't take damage while feigning death
+ {
+ damage = 0;
+ return;
+ }
+
+ isFeignDeath = true;
+ isOverloading = false;
+
+ Talk(EMOTE_FEIGN_DEATH);
+ if (Creature* thaddius = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_THADDIUS)))
+ thaddius->AI()->DoAction(ACTION_FEUGEN_DIED);
+
+ me->RemoveAllAuras();
+ me->SetReactState(REACT_PASSIVE);
+ me->AttackStop();
+ me->StopMoving();
+ me->SetStandState(UNIT_STAND_STATE_DEAD);
+ me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
+
+ damage = 0;
+
+ // force beam refresh as we just removed auras
+ refreshBeam = true;
}
- bool Load() override
+ void SpellHit(Unit* caster, SpellInfo const* spell) override
{
- return GetCaster()->GetTypeId() == TYPEID_UNIT;
+ if (!caster)
+ return;
+ if (spell->Id != SPELL_FEUGEN_TESLA_PERIODIC)
+ return;
+ if (!isFeignDeath && me->IsInCombat() && !me->GetHomePosition().IsInDist(me, OVERLOAD_DISTANCE))
+ {
+ if (!isOverloading)
+ {
+ isOverloading = true;
+ caster->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_PC);
+ if (Creature* creatureCaster = caster->ToCreature())
+ creatureCaster->AI()->Talk(EMOTE_TESLA_LINK_BREAKS);
+ me->RemoveAura(SPELL_STALAGG_CHAIN_VISUAL);
+ }
+ if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0))
+ {
+ caster->CastStop(SPELL_TESLA_SHOCK);
+ caster->CastSpell(target, SPELL_TESLA_SHOCK,true);
+ }
+ }
+ else if (isOverloading || refreshBeam)
+ {
+ isOverloading = false;
+ refreshBeam = false;
+ caster->CastStop();
+ caster->CastSpell(me, SPELL_FEUGEN_CHAIN_VISUAL, true);
+ caster->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_PC);
+ }
}
- void HandleTargets(std::list<WorldObject*>& targets)
+ void UpdateAI(uint32 uiDiff) override
{
- uint8 count = 0;
- for (std::list<WorldObject*>::iterator ihit = targets.begin(); ihit != targets.end(); ++ihit)
- if ((*ihit)->GetGUID() != GetCaster()->GetGUID())
- if (Player* target = (*ihit)->ToPlayer())
- if (target->HasAura(GetTriggeringSpell()->Id))
- ++count;
+ if (isFeignDeath)
+ return;
+ if (!UpdateVictim())
+ return;
- if (count)
+ if (magneticPullTimer <= uiDiff)
+ {
+ DoCast(me, SPELL_MAGNETIC_PULL);
+ magneticPullTimer = 20 * IN_MILLISECONDS;
+ }
+ else magneticPullTimer -= uiDiff;
+
+ if (staticFieldTimer <= uiDiff)
{
- uint32 spellId = 0;
+ DoCast(me, SPELL_FEUGEN_STATICFIELD);
+ staticFieldTimer = 6 * IN_MILLISECONDS;
+ }
+ else staticFieldTimer -= uiDiff;
- if (GetSpellInfo()->Id == SPELL_POSITIVE_CHARGE)
- spellId = SPELL_POSITIVE_CHARGE_STACK;
- else // if (GetSpellInfo()->Id == SPELL_NEGATIVE_CHARGE)
- spellId = SPELL_NEGATIVE_CHARGE_STACK;
+ DoMeleeAttackIfReady();
+ }
- GetCaster()->SetAuraStack(spellId, GetCaster(), count);
+ private:
+ Creature* myCoil()
+ {
+ Creature* coil = nullptr;
+ if (_myCoil)
+ coil = ObjectAccessor::GetCreature(*me, _myCoil);
+ if (!coil)
+ {
+ coil = me->FindNearestCreature(NPC_TESLA, 1000.0f, true);
+ if (coil)
+ {
+ _myCoil = coil->GetGUID();
+ coil->SetReactState(REACT_PASSIVE);
+ }
}
+ return coil;
+ }
+
+ GameObject* myCoilGO()
+ {
+ GameObject* coil = nullptr;
+ if (_myCoilGO)
+ coil = ObjectAccessor::GetGameObject(*me, _myCoilGO);
+ if (!coil)
+ {
+ coil = me->FindNearestGameObject(GO_CONS_NOX_TESLA_FEUGEN, 1000.0f);
+ if (coil)
+ _myCoilGO = coil->GetGUID();
+ }
+ return coil;
+ }
+ InstanceScript* instance;
+
+ uint32 magneticPullTimer;
+ uint32 staticFieldTimer;
+
+ ObjectGuid _myCoil;
+ ObjectGuid _myCoilGO;
+
+ bool isOverloading;
+ bool refreshBeam;
+ bool isFeignDeath;
+ };
+};
+
+class npc_tesla : public CreatureScript
+{
+public:
+ npc_tesla() : CreatureScript("npc_tesla") { }
+
+ CreatureAI* GetAI(Creature* creature) const override
+ {
+ return GetInstanceAI<npc_teslaAI>(creature);
+ }
+
+ struct npc_teslaAI : public ScriptedAI
+ {
+ npc_teslaAI(Creature* creature) : ScriptedAI(creature) { }
+
+ void EnterEvadeMode() override { } // never stop casting due to evade
+ void UpdateAI(uint32 /*diff*/) override { } // never do anything unless told
+ void EnterCombat(Unit* /*who*/) override { }
+ void DamageTaken(Unit* /*who*/, uint32& damage) override { damage = 0; } // no, you can't kill it
+ };
+};
+
+class spell_thaddius_polarity_charge : public SpellScriptLoader
+{
+ public:
+ spell_thaddius_polarity_charge() : SpellScriptLoader("spell_thaddius_polarity_charge") { }
+
+ class spell_thaddius_polarity_charge_SpellScript : public SpellScript
+ {
+ PrepareSpellScript(spell_thaddius_polarity_charge_SpellScript);
+
+ bool Validate(SpellInfo const* /*spell*/) override
+ {
+ return (
+ sSpellMgr->GetSpellInfo(SPELL_POLARITY_SHIFT) &&
+ sSpellMgr->GetSpellInfo(SPELL_POSITIVE_CHARGE_APPLY) &&
+ sSpellMgr->GetSpellInfo(SPELL_POSITIVE_CHARGE_TICK) &&
+ sSpellMgr->GetSpellInfo(SPELL_POSITIVE_CHARGE_AMP) &&
+ sSpellMgr->GetSpellInfo(SPELL_NEGATIVE_CHARGE_APPLY) &&
+ sSpellMgr->GetSpellInfo(SPELL_NEGATIVE_CHARGE_TICK) &&
+ sSpellMgr->GetSpellInfo(SPELL_NEGATIVE_CHARGE_AMP)
+ );
}
- void HandleDamage(SpellEffIndex /*effIndex*/)
+ void HandleTargets(std::list<WorldObject*>& targetList)
{
if (!GetTriggeringSpell())
return;
- Unit* target = GetHitUnit();
- Unit* caster = GetCaster();
+ uint32 triggeringId = GetTriggeringSpell()->Id;
+ uint32 ampId;
+ switch (triggeringId)
+ {
+ case SPELL_POSITIVE_CHARGE_APPLY:
+ ampId = SPELL_POSITIVE_CHARGE_AMP;
+ break;
+ case SPELL_NEGATIVE_CHARGE_APPLY:
+ ampId = SPELL_NEGATIVE_CHARGE_AMP;
+ break;
+ default:
+ return;
+ }
- if (target->HasAura(GetTriggeringSpell()->Id))
- SetHitDamage(0);
- else
+ uint8 maxStacks = 0;
+ if (GetCaster())
+ switch (GetCaster()->GetMap()->GetDifficulty())
+ {
+ case RAID_DIFFICULTY_10MAN_NORMAL:
+ maxStacks = MAX_POLARITY_10M;
+ break;
+ case RAID_DIFFICULTY_25MAN_NORMAL:
+ maxStacks = MAX_POLARITY_25M;
+ break;
+ default:
+ break;
+ }
+
+ uint8 stacksCount = 1; // do we get a stack for our own debuff?
+ std::list<WorldObject*>::iterator it = targetList.begin();
+ while(it != targetList.end())
+ {
+ if ((*it)->GetTypeId() != TYPEID_PLAYER)
+ {
+ it = targetList.erase(it);
+ continue;
+ }
+ if ((*it)->ToPlayer()->HasAura(triggeringId))
+ {
+ it = targetList.erase(it);
+ if (stacksCount < maxStacks)
+ stacksCount++;
+ continue;
+ }
+
+ // this guy will get hit - achievement failure trigger
+ if (Creature* thaddius = (*it)->FindNearestCreature(NPC_THADDIUS,200.0f))
+ thaddius->AI()->DoAction(ACTION_POLARITY_CROSSED);
+
+ ++it;
+ }
+
+ if (GetCaster() && GetCaster()->ToPlayer())
{
- if (target->GetTypeId() == TYPEID_PLAYER && caster->IsAIEnabled)
- caster->ToCreature()->AI()->SetData(DATA_POLARITY_SWITCH, 1);
+ if (!GetCaster()->ToPlayer()->HasAura(ampId))
+ GetCaster()->ToPlayer()->AddAura(ampId, GetCaster());
+ GetCaster()->ToPlayer()->SetAuraStack(ampId, GetCaster(), stacksCount);
}
}
void Register() override
{
- OnEffectHitTarget += SpellEffectFn(spell_thaddius_pos_neg_charge_SpellScript::HandleDamage, EFFECT_0, SPELL_EFFECT_SCHOOL_DAMAGE);
- OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_thaddius_pos_neg_charge_SpellScript::HandleTargets, EFFECT_0, TARGET_UNIT_SRC_AREA_ALLY);
+ OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_thaddius_polarity_charge_SpellScript::HandleTargets, EFFECT_0, TARGET_UNIT_SRC_AREA_ALLY);
}
};
SpellScript* GetSpellScript() const override
{
- return new spell_thaddius_pos_neg_charge_SpellScript();
+ return new spell_thaddius_polarity_charge_SpellScript;
}
};
@@ -536,16 +1103,33 @@ class spell_thaddius_polarity_shift : public SpellScriptLoader
bool Validate(SpellInfo const* /*spell*/) override
{
- if (!sSpellMgr->GetSpellInfo(SPELL_POSITIVE_POLARITY) || !sSpellMgr->GetSpellInfo(SPELL_NEGATIVE_POLARITY))
- return false;
- return true;
+ return (
+ sSpellMgr->GetSpellInfo(SPELL_POLARITY_SHIFT) &&
+ sSpellMgr->GetSpellInfo(SPELL_POSITIVE_CHARGE_APPLY) &&
+ sSpellMgr->GetSpellInfo(SPELL_POSITIVE_CHARGE_TICK) &&
+ sSpellMgr->GetSpellInfo(SPELL_POSITIVE_CHARGE_AMP) &&
+ sSpellMgr->GetSpellInfo(SPELL_NEGATIVE_CHARGE_APPLY) &&
+ sSpellMgr->GetSpellInfo(SPELL_NEGATIVE_CHARGE_TICK) &&
+ sSpellMgr->GetSpellInfo(SPELL_NEGATIVE_CHARGE_AMP)
+ );
}
- void HandleDummy(SpellEffIndex /* effIndex */)
+ void HandleDummy(SpellEffIndex /*effIndex*/)
{
- Unit* caster = GetCaster();
if (Unit* target = GetHitUnit())
- target->CastSpell(target, roll_chance_i(50) ? SPELL_POSITIVE_POLARITY : SPELL_NEGATIVE_POLARITY, true, NULL, NULL, caster->GetGUID());
+ if (target->GetTypeId() == TYPEID_PLAYER)
+ {
+ if (roll_chance_i(50))
+ { // positive
+ target->CastSpell(target, SPELL_POSITIVE_CHARGE_APPLY, true);
+ target->RemoveAura(SPELL_POSITIVE_CHARGE_AMP);
+ }
+ else
+ { // negative
+ target->CastSpell(target, SPELL_NEGATIVE_CHARGE_APPLY, true);
+ target->RemoveAura(SPELL_NEGATIVE_CHARGE_AMP);
+ }
+ }
}
void Register() override
@@ -560,23 +1144,131 @@ class spell_thaddius_polarity_shift : public SpellScriptLoader
}
};
-class achievement_polarity_switch : public AchievementCriteriaScript
+class spell_thaddius_magnetic_pull : public SpellScriptLoader
+{
+ public:
+ spell_thaddius_magnetic_pull() : SpellScriptLoader("spell_thaddius_magnetic_pull") { };
+
+ class spell_thaddius_magnetic_pull_SpellScript : public SpellScript
+ {
+ PrepareSpellScript(spell_thaddius_magnetic_pull_SpellScript);
+
+ bool Validate(SpellInfo const* /*spell*/) override
+ {
+ return sSpellMgr->GetSpellInfo(SPELL_MAGNETIC_PULL) ? true : false;
+ }
+
+ void HandleCast() // only feugen ever casts this according to wowhead data
+ {
+ Unit* feugen = GetCaster();
+ if (!feugen || feugen->GetEntry() != NPC_FEUGEN)
+ return;
+
+ Unit* stalagg = ObjectAccessor::GetCreature(*feugen, feugen->GetInstanceScript()->GetGuidData(DATA_STALAGG));
+ if (!stalagg)
+ return;
+
+ Unit* feugenTank = feugen->GetVictim();
+ Unit* stalaggTank = stalagg->GetVictim();
+
+ if (!feugenTank || !stalaggTank)
+ return;
+
+ ThreatManager& feugenThreat = feugen->getThreatManager();
+ ThreatManager& stalaggThreat = stalagg->getThreatManager();
+
+ if (feugenTank == stalaggTank) // special behavior if the tanks are the same (taken from retail)
+ {
+ float feugenTankThreat = feugenThreat.getThreat(feugenTank);
+ float stalaggTankThreat = stalaggThreat.getThreat(stalaggTank);
+
+ feugenThreat.addThreat(feugenTank, stalaggTankThreat - feugenTankThreat);
+ stalaggThreat.addThreat(stalaggTank, feugenTankThreat - stalaggTankThreat);
+
+ feugen->CastSpell(stalaggTank, SPELL_MAGNETIC_PULL_EFFECT, true);
+ }
+ else // normal case, two tanks
+ {
+ float feugenTankThreat = feugenThreat.getThreat(feugenTank);
+ float feugenOtherThreat = feugenThreat.getThreat(stalaggTank);
+ float stalaggTankThreat = stalaggThreat.getThreat(stalaggTank);
+ float stalaggOtherThreat = stalaggThreat.getThreat(feugenTank);
+
+ // set the two entries in feugen's threat table to be equal to the ones in stalagg's
+ feugenThreat.addThreat(stalaggTank, stalaggTankThreat - feugenOtherThreat);
+ feugenThreat.addThreat(feugenTank, stalaggOtherThreat - feugenTankThreat);
+
+ // set the two entries in stalagg's threat table to be equal to the ones in feugen's
+ stalaggThreat.addThreat(feugenTank, feugenTankThreat - stalaggOtherThreat);
+ stalaggThreat.addThreat(stalaggTank, feugenOtherThreat - stalaggTankThreat);
+
+ // pull the two tanks across
+ feugenTank->CastSpell(stalaggTank, SPELL_MAGNETIC_PULL_EFFECT, true);
+ stalaggTank->CastSpell(feugenTank, SPELL_MAGNETIC_PULL_EFFECT, true);
+
+ // and make both attack their respective new tanks
+ if (feugen->GetAI())
+ feugen->GetAI()->AttackStart(stalaggTank);
+ if (stalagg->GetAI())
+ stalagg->GetAI()->AttackStart(feugenTank);
+ }
+ }
+
+ void Register() override
+ {
+ OnCast += SpellCastFn(spell_thaddius_magnetic_pull_SpellScript::HandleCast);
+ }
+ };
+
+ SpellScript* GetSpellScript() const override
+ {
+ return new spell_thaddius_magnetic_pull_SpellScript();
+ }
+};
+
+class at_thaddius_entrance : public AreaTriggerScript
{
public:
- achievement_polarity_switch() : AchievementCriteriaScript("achievement_polarity_switch") { }
+ at_thaddius_entrance() : AreaTriggerScript("at_thaddius_entrance") { }
+
+ bool OnTrigger(Player* player, AreaTriggerEntry const* /*areaTrigger*/) override
+ {
+ InstanceScript* instance = player->GetInstanceScript();
+ if (!instance || instance->GetData(DATA_HAD_THADDIUS_GREET) || instance->GetBossState(BOSS_THADDIUS) == DONE)
+ return true;
+
+ if (Creature* thaddius = ObjectAccessor::GetCreature(*player, instance->GetGuidData(DATA_THADDIUS)))
+ thaddius->AI()->Talk(SAY_GREET);
+ instance->SetData(DATA_HAD_THADDIUS_GREET, 1u);
+
+ return true;
+ }
+};
+
+class achievement_thaddius_shocking : public AchievementCriteriaScript
+{
+ public:
+ achievement_thaddius_shocking() : AchievementCriteriaScript("achievement_thaddius_shocking") { }
bool OnCheck(Player* /*source*/, Unit* target) override
{
- return target && target->GetAI()->GetData(DATA_POLARITY_SWITCH);
+ return target && target->GetAI() && target->GetAI()->GetData(DATA_POLARITY_CROSSED);
}
};
+
void AddSC_boss_thaddius()
{
new boss_thaddius();
new npc_stalagg();
new npc_feugen();
- new spell_thaddius_pos_neg_charge();
+ new npc_tesla();
+
+ new spell_thaddius_polarity_charge();
new spell_thaddius_polarity_shift();
- new achievement_polarity_switch();
+ new spell_thaddius_magnetic_pull();
+
+ new at_thaddius_entrance();
+
+ new achievement_thaddius_shocking();
}
diff --git a/src/server/scripts/Northrend/Naxxramas/instance_naxxramas.cpp b/src/server/scripts/Northrend/Naxxramas/instance_naxxramas.cpp
index 692e6d8b589..60999d1d883 100644
--- a/src/server/scripts/Northrend/Naxxramas/instance_naxxramas.cpp
+++ b/src/server/scripts/Northrend/Naxxramas/instance_naxxramas.cpp
@@ -60,7 +60,6 @@ DoorData const doorData[] =
MinionData const minionData[] =
{
- { NPC_FOLLOWER_WORSHIPPER, BOSS_FAERLINA },
{ NPC_DK_UNDERSTUDY, BOSS_RAZUVIOUS },
{ NPC_SIR, BOSS_HORSEMEN },
{ NPC_THANE, BOSS_HORSEMEN },
@@ -126,6 +125,9 @@ class instance_naxxramas : public InstanceMapScript
minHorsemenDiedTime = 0;
maxHorsemenDiedTime = 0;
AbominationCount = 0;
+ hadAnubRekhanGreet = false;
+ hadFaerlinaGreet = false;
+ hadThaddiusGreet = false;
CurrentWingTaunt = SAY_KELTHUZAD_FIRST_WING_TAUNT;
playerDied = 0;
@@ -135,6 +137,9 @@ class instance_naxxramas : public InstanceMapScript
{
switch (creature->GetEntry())
{
+ case NPC_ANUBREKHAN:
+ AnubRekhanGUID = creature->GetGUID();
+ break;
case NPC_FAERLINA:
FaerlinaGUID = creature->GetGUID();
break;
@@ -150,12 +155,12 @@ class instance_naxxramas : public InstanceMapScript
case NPC_SIR:
SirGUID = creature->GetGUID();
break;
- case NPC_THADDIUS:
- ThaddiusGUID = creature->GetGUID();
- break;
case NPC_HEIGAN:
HeiganGUID = creature->GetGUID();
break;
+ case NPC_THADDIUS:
+ ThaddiusGUID = creature->GetGUID();
+ break;
case NPC_FEUGEN:
FeugenGUID = creature->GetGUID();
break;
@@ -183,6 +188,18 @@ class instance_naxxramas : public InstanceMapScript
AddMinion(creature, false);
}
+ void ProcessEvent(WorldObject* source, uint32 eventId) override
+ {
+ switch (eventId)
+ {
+ case EVENT_THADDIUS_BEGIN_RESET:
+ if (!source->ToCreature() || source->ToCreature()->GetEntry() != NPC_THADDIUS)
+ return;
+ events.ScheduleEvent(EVENT_THADDIUS_RESET, 30 * IN_MILLISECONDS);
+ break;
+ }
+ }
+
void OnGameObjectCreate(GameObject* go) override
{
if (go->GetGOInfo()->displayId == 6785 || go->GetGOInfo()->displayId == 1287)
@@ -319,6 +336,17 @@ class instance_naxxramas : public InstanceMapScript
case DATA_ABOMINATION_KILLED:
AbominationCount = value;
break;
+ case DATA_HAD_ANUBREKHAN_GREET:
+ hadAnubRekhanGreet = (value == 1u);
+ break;
+ case DATA_HAD_FAERLINA_GREET:
+ hadFaerlinaGreet = (value == 1u);
+ break;
+ case DATA_HAD_THADDIUS_GREET:
+ hadThaddiusGreet = (value == 1u);
+ break;
+ default:
+ break;
}
}
@@ -328,6 +356,12 @@ class instance_naxxramas : public InstanceMapScript
{
case DATA_ABOMINATION_KILLED:
return AbominationCount;
+ case DATA_HAD_ANUBREKHAN_GREET:
+ return hadAnubRekhanGreet ? 1u : 0u;
+ case DATA_HAD_FAERLINA_GREET:
+ return hadFaerlinaGreet ? 1u : 0u;
+ case DATA_HAD_THADDIUS_GREET:
+ return hadThaddiusGreet ? 1u : 0u;
default:
break;
}
@@ -339,6 +373,8 @@ class instance_naxxramas : public InstanceMapScript
{
switch (id)
{
+ case DATA_ANUBREKHAN:
+ return AnubRekhanGUID;
case DATA_FAERLINA:
return FaerlinaGUID;
case DATA_THANE:
@@ -349,14 +385,14 @@ class instance_naxxramas : public InstanceMapScript
return BaronGUID;
case DATA_SIR:
return SirGUID;
- case DATA_THADDIUS:
- return ThaddiusGUID;
case DATA_HEIGAN:
return HeiganGUID;
case DATA_FEUGEN:
return FeugenGUID;
case DATA_STALAGG:
return StalaggGUID;
+ case DATA_THADDIUS:
+ return ThaddiusGUID;
case DATA_KELTHUZAD:
return KelthuzadGUID;
case DATA_KELTHUZAD_PORTAL01:
@@ -525,6 +561,11 @@ class instance_naxxramas : public InstanceMapScript
kelthuzad->AI()->Talk(SAY_DIALOGUE_SAPPHIRON_KELTHUZAD4);
HandleGameObject(KelthuzadDoorGUID, true);
break;
+ case EVENT_THADDIUS_RESET:
+ if (GetBossState(BOSS_THADDIUS) != DONE)
+ if (Creature* thaddius = instance->GetCreature(ThaddiusGUID))
+ thaddius->AI()->DoAction(-1);
+ break;
default:
break;
}
@@ -599,6 +640,8 @@ class instance_naxxramas : public InstanceMapScript
protected:
/* The Arachnid Quarter */
+ // Anub'rekhan
+ ObjectGuid AnubRekhanGUID;
// Grand Widow Faerlina
ObjectGuid FaerlinaGUID;
@@ -635,6 +678,9 @@ class instance_naxxramas : public InstanceMapScript
ObjectGuid KelthuzadDoorGUID;
ObjectGuid LichKingGUID;
uint8 AbominationCount;
+ bool hadAnubRekhanGreet;
+ bool hadFaerlinaGreet;
+ bool hadThaddiusGreet;
uint8 CurrentWingTaunt;
/* The Immortal / The Undying */
diff --git a/src/server/scripts/Northrend/Naxxramas/naxxramas.h b/src/server/scripts/Northrend/Naxxramas/naxxramas.h
index 459903c4c86..9c5a4afba91 100644
--- a/src/server/scripts/Northrend/Naxxramas/naxxramas.h
+++ b/src/server/scripts/Northrend/Naxxramas/naxxramas.h
@@ -46,6 +46,9 @@ enum Data
DATA_HEIGAN_ERUPT,
DATA_GOTHIK_GATE,
DATA_SAPPHIRON_BIRTH,
+ DATA_HAD_ANUBREKHAN_GREET,
+ DATA_HAD_FAERLINA_GREET,
+ DATA_HAD_THADDIUS_GREET,
DATA_HORSEMEN0,
DATA_HORSEMEN1,
@@ -61,6 +64,7 @@ enum Data
enum Data64
{
+ DATA_ANUBREKHAN,
DATA_FAERLINA,
DATA_THANE,
DATA_LADY,
@@ -81,15 +85,17 @@ enum Data64
enum CreaturesIds
{
+ NPC_ANUBREKHAN = 15956,
NPC_FAERLINA = 15953,
NPC_THANE = 16064,
NPC_LADY = 16065,
NPC_BARON = 30549,
NPC_SIR = 16063,
- NPC_THADDIUS = 15928,
NPC_HEIGAN = 15936,
+ NPC_THADDIUS = 15928,
NPC_FEUGEN = 15930,
NPC_STALAGG = 15929,
+ NPC_TESLA = 16218,
NPC_SAPPHIRON = 15989,
NPC_KEL_THUZAD = 15990,
NPC_CRYPT_GUARD = 16573,
@@ -169,6 +175,10 @@ enum InstanceEvents
EVENT_DIALOGUE_GOTHIK_KORTHAZZ2,
EVENT_DIALOGUE_GOTHIK_RIVENDARE2,
+ // Thaddius AI requesting timed encounter respawn
+ EVENT_THADDIUS_BEGIN_RESET,
+ EVENT_THADDIUS_RESET,
+
// Dialogue that happens after each wing.
EVENT_KELTHUZAD_WING_TAUNT,
diff --git a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_algalon_the_observer.cpp b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_algalon_the_observer.cpp
index 25d1e214260..7618a0b9156 100644
--- a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_algalon_the_observer.cpp
+++ b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_algalon_the_observer.cpp
@@ -242,7 +242,7 @@ class ActivateLivingConstellation : public BasicEvent
{
}
- bool Execute(uint64 execTime, uint32 /*diff*/)
+ bool Execute(uint64 execTime, uint32 /*diff*/) override
{
if (!_instance || _instance->GetBossState(BOSS_ALGALON) != IN_PROGRESS)
return true; // delete event
@@ -264,7 +264,7 @@ class CosmicSmashDamageEvent : public BasicEvent
{
}
- bool Execute(uint64 /*execTime*/, uint32 /*diff*/)
+ bool Execute(uint64 /*execTime*/, uint32 /*diff*/) override
{
_caster->CastSpell((Unit*)NULL, SPELL_COSMIC_SMASH_TRIGGERED, TRIGGERED_FULL_MASK);
return true;
@@ -281,7 +281,7 @@ class SummonUnleashedDarkMatter : public BasicEvent
{
}
- bool Execute(uint64 execTime, uint32 /*diff*/)
+ bool Execute(uint64 execTime, uint32 /*diff*/) override
{
_caster->CastSpell((Unit*)NULL, SPELL_SUMMON_UNLEASHED_DARK_MATTER, TRIGGERED_FULL_MASK);
_caster->m_Events.AddEvent(this, execTime + 30000);
@@ -322,7 +322,7 @@ class boss_algalon_the_observer : public CreatureScript
void KilledUnit(Unit* victim) override
{
- if (victim->GetTypeId() == TYPEID_UNIT)
+ if (victim->GetTypeId() == TYPEID_PLAYER)
{
_fedOnTears = true;
if (!_hasYelled)
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 64403ad40ca..7e005eff303 100644
--- a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_general_vezax.cpp
+++ b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_general_vezax.cpp
@@ -234,16 +234,12 @@ class boss_general_vezax : public CreatureScript
void CheckShamanisticRage()
{
- Map* map = me->GetMap();
- if (map && map->IsDungeon())
- {
- // If Shaman has Shamanistic Rage and use it during the fight, it will cast Corrupted Rage on him
- Map::PlayerList const& Players = map->GetPlayers();
- for (Map::PlayerList::const_iterator itr = Players.begin(); itr != Players.end(); ++itr)
- if (Player* player = itr->GetSource())
- if (player->HasSpell(SPELL_SHAMANTIC_RAGE))
- player->CastSpell(player, SPELL_CORRUPTED_RAGE, false);
- }
+ // If Shaman has Shamanistic Rage and use it during the fight, it will cast Corrupted Rage on him
+ Map::PlayerList const& Players = me->GetMap()->GetPlayers();
+ for (Map::PlayerList::const_iterator itr = Players.begin(); itr != Players.end(); ++itr)
+ if (Player* player = itr->GetSource())
+ if (player->HasSpell(SPELL_SHAMANTIC_RAGE))
+ player->CastSpell(player, SPELL_CORRUPTED_RAGE, false);
}
uint32 GetData(uint32 type) const override
@@ -280,34 +276,28 @@ class boss_general_vezax : public CreatureScript
*/
Unit* CheckPlayersInRange(uint8 playersMin, float rangeMin, float rangeMax)
{
- Map* map = me->GetMap();
- if (map && map->IsDungeon())
+ std::list<Player*> PlayerList;
+ Map::PlayerList const& Players = me->GetMap()->GetPlayers();
+ for (Map::PlayerList::const_iterator itr = Players.begin(); itr != Players.end(); ++itr)
{
- std::list<Player*> PlayerList;
- Map::PlayerList const& Players = map->GetPlayers();
- for (Map::PlayerList::const_iterator itr = Players.begin(); itr != Players.end(); ++itr)
+ if (Player* player = itr->GetSource())
{
- if (Player* player = itr->GetSource())
- {
- float distance = player->GetDistance(me->GetPositionX(), me->GetPositionY(), me->GetPositionZ());
- if (rangeMin > distance || distance > rangeMax)
- continue;
+ float distance = player->GetDistance(me->GetPositionX(), me->GetPositionY(), me->GetPositionZ());
+ if (rangeMin > distance || distance > rangeMax)
+ continue;
- PlayerList.push_back(player);
- }
+ PlayerList.push_back(player);
}
+ }
- if (PlayerList.empty())
- return NULL;
-
- size_t size = PlayerList.size();
- if (size < playersMin)
- return NULL;
+ if (PlayerList.empty())
+ return NULL;
- return Trinity::Containers::SelectRandomContainerElement(PlayerList);
- }
+ size_t size = PlayerList.size();
+ if (size < playersMin)
+ return NULL;
- return NULL;
+ return Trinity::Containers::SelectRandomContainerElement(PlayerList);
}
};
diff --git a/src/server/scripts/Northrend/zone_sholazar_basin.cpp b/src/server/scripts/Northrend/zone_sholazar_basin.cpp
index d5d2eebda38..6e4a8df6f25 100644
--- a/src/server/scripts/Northrend/zone_sholazar_basin.cpp
+++ b/src/server/scripts/Northrend/zone_sholazar_basin.cpp
@@ -622,17 +622,17 @@ public:
enum MiscLifewarden
{
- NPC_PRESENCE = 28563, // Freya's Presence
- NPC_SABOTEUR = 28538, // Cultist Saboteur
- NPC_SERVANT = 28320, // Servant of Freya
+ NPC_PRESENCE = 28563, // Freya's Presence
+ NPC_SABOTEUR = 28538, // Cultist Saboteur
+ NPC_SERVANT = 28320, // Servant of Freya
- WHISPER_ACTIVATE = 0,
+ WHISPER_ACTIVATE = 0,
- SPELL_FREYA_DUMMY = 51318,
- SPELL_LIFEFORCE = 51395,
- SPELL_FREYA_DUMMY_TRIGGER = 51335,
- SPELL_LASHER_EMERGE = 48195,
- SPELL_WILD_GROWTH = 52948,
+ SPELL_FREYA_DUMMY = 51318,
+ SPELL_LIFEFORCE = 51395,
+ SPELL_FREYA_DUMMY_TRIGGER = 51335,
+ SPELL_LASHER_EMERGE = 48195,
+ SPELL_WILD_GROWTH = 52948,
};
class spell_q12620_the_lifewarden_wrath : public SpellScriptLoader
@@ -702,25 +702,25 @@ public:
enum KickWhatKick
{
- NPC_LUCKY_WILHELM = 28054,
- NPC_APPLE = 28053,
- NPC_DROSTAN = 28328,
- NPC_CRUNCHY = 28346,
- NPC_THICKBIRD = 28093,
-
- SPELL_HIT_APPLE = 51331,
- SPELL_MISS_APPLE = 51332,
- SPELL_MISS_BIRD_APPLE = 51366,
- SPELL_APPLE_FALL = 51371,
- SPELL_BIRD_FALL = 51369,
-
- EVENT_MISS = 0,
- EVENT_HIT = 1,
- EVENT_MISS_BIRD = 2,
-
- SAY_WILHELM_MISS = 0,
- SAY_WILHELM_HIT = 1,
- SAY_DROSTAN_REPLY_MISS = 0,
+ NPC_LUCKY_WILHELM = 28054,
+ NPC_APPLE = 28053,
+ NPC_DROSTAN = 28328,
+ NPC_CRUNCHY = 28346,
+ NPC_THICKBIRD = 28093,
+
+ SPELL_HIT_APPLE = 51331,
+ SPELL_MISS_APPLE = 51332,
+ SPELL_MISS_BIRD_APPLE = 51366,
+ SPELL_APPLE_FALL = 51371,
+ SPELL_BIRD_FALL = 51369,
+
+ EVENT_MISS = 0,
+ EVENT_HIT = 1,
+ EVENT_MISS_BIRD = 2,
+
+ SAY_WILHELM_MISS = 0,
+ SAY_WILHELM_HIT = 1,
+ SAY_DROSTAN_REPLY_MISS = 0,
};
class spell_q12589_shoot_rjr : public SpellScriptLoader
@@ -800,8 +800,6 @@ public:
wilhelm->AI()->Talk(SAY_WILHELM_HIT);
if (Player* player = shooter->ToPlayer())
player->KilledMonsterCredit(NPC_APPLE);
- apple->DespawnOrUnsummon();
-
break;
}
}
@@ -828,11 +826,11 @@ may be easily converted to SAI when they get.*/
enum SongOfWindAndWater
{
// Spells
- SPELL_DEVOUR_WIND = 52862,
- SPELL_DEVOUR_WATER = 52864,
+ SPELL_DEVOUR_WIND = 52862,
+ SPELL_DEVOUR_WATER = 52864,
// NPCs
- NPC_HAIPHOON_WATER = 28999,
- NPC_HAIPHOON_AIR = 28985
+ NPC_HAIPHOON_WATER = 28999,
+ NPC_HAIPHOON_AIR = 28985
};
class npc_haiphoon : public CreatureScript
@@ -883,7 +881,7 @@ enum ReconnaissanceFlight
VIC_SAY_6 = 6,
PLANE_EMOTE = 0,
- SPELL_ENGINE = 52255, // Engine on Fire
+ SPELL_ENGINE = 52255, // Engine on Fire
SPELL_LAND = 52226, // Land Flying Machine
SPELL_CREDIT = 53328 // Land Flying Machine Credit
diff --git a/src/server/scripts/OutdoorPvP/OutdoorPvPEP.cpp b/src/server/scripts/OutdoorPvP/OutdoorPvPEP.cpp
index 9224817b699..89f35457a44 100644
--- a/src/server/scripts/OutdoorPvP/OutdoorPvPEP.cpp
+++ b/src/server/scripts/OutdoorPvP/OutdoorPvPEP.cpp
@@ -75,7 +75,7 @@ void OPvPCapturePointEP_EWT::ChangeState()
auto bounds = map->GetGameObjectBySpawnIdStore().equal_range(m_capturePointSpawnId);
for (auto itr = bounds.first; itr != bounds.second; ++itr)
itr->second->SetGoArtKit(artkit);
-
+
bounds = map->GetGameObjectBySpawnIdStore().equal_range(m_Objects[EP_EWT_FLAGS]);
for (auto itr = bounds.first; itr != bounds.second; ++itr)
itr->second->SetGoArtKit(artkit);
diff --git a/src/server/scripts/OutdoorPvP/OutdoorPvPSI.cpp b/src/server/scripts/OutdoorPvP/OutdoorPvPSI.cpp
index 94ec7acba1f..d2892541373 100644
--- a/src/server/scripts/OutdoorPvP/OutdoorPvPSI.cpp
+++ b/src/server/scripts/OutdoorPvP/OutdoorPvPSI.cpp
@@ -162,11 +162,6 @@ bool OutdoorPvPSI::HandleDropFlag(Player* player, uint32 spellId)
// he dropped it further, summon mound
GameObject* go = new GameObject;
Map* map = player->GetMap();
- if (!map)
- {
- delete go;
- return true;
- }
if (!go->Create(map->GenerateLowGuid<HighGuid::GameObject>(), SI_SILITHYST_MOUND, map, player->GetPhaseMask(), player->GetPositionX(), player->GetPositionY(), player->GetPositionZ(), player->GetOrientation(), 0, 0, 0, 0, 100, GO_STATE_READY))
{
@@ -196,11 +191,6 @@ bool OutdoorPvPSI::HandleDropFlag(Player* player, uint32 spellId)
// he dropped it further, summon mound
GameObject* go = new GameObject;
Map* map = player->GetMap();
- if (!map)
- {
- delete go;
- return true;
- }
if (!go->Create(map->GenerateLowGuid<HighGuid::GameObject>(), SI_SILITHYST_MOUND, map, player->GetPhaseMask(), player->GetPositionX(), player->GetPositionY(), player->GetPositionZ(), player->GetOrientation(), 0, 0, 0, 0, 100, GO_STATE_READY))
{
diff --git a/src/server/scripts/Outland/Auchindoun/AuchenaiCrypts/boss_shirrak_the_dead_watcher.cpp b/src/server/scripts/Outland/Auchindoun/AuchenaiCrypts/boss_shirrak_the_dead_watcher.cpp
index 263fd8340b9..6e43cfa2d0f 100644
--- a/src/server/scripts/Outland/Auchindoun/AuchenaiCrypts/boss_shirrak_the_dead_watcher.cpp
+++ b/src/server/scripts/Outland/Auchindoun/AuchenaiCrypts/boss_shirrak_the_dead_watcher.cpp
@@ -109,8 +109,7 @@ public:
if (Inhibitmagic_Timer <= diff)
{
float dist;
- Map* map = me->GetMap();
- Map::PlayerList const &PlayerList = map->GetPlayers();
+ Map::PlayerList const &PlayerList = me->GetMap()->GetPlayers();
for (Map::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i)
if (Player* i_pl = i->GetSource())
if (i_pl->IsAlive() && (dist = i_pl->GetDistance(me)) < 45)
diff --git a/src/server/scripts/Outland/Auchindoun/ShadowLabyrinth/boss_grandmaster_vorpil.cpp b/src/server/scripts/Outland/Auchindoun/ShadowLabyrinth/boss_grandmaster_vorpil.cpp
index d0e12c87a55..b16a9630335 100644
--- a/src/server/scripts/Outland/Auchindoun/ShadowLabyrinth/boss_grandmaster_vorpil.cpp
+++ b/src/server/scripts/Outland/Auchindoun/ShadowLabyrinth/boss_grandmaster_vorpil.cpp
@@ -182,8 +182,7 @@ class boss_grandmaster_vorpil : public CreatureScript
break;
case EVENT_DRAW_SHADOWS:
{
- Map* map = me->GetMap();
- Map::PlayerList const &PlayerList = map->GetPlayers();
+ Map::PlayerList const &PlayerList = me->GetMap()->GetPlayers();
for (Map::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i)
if (Player* i_pl = i->GetSource())
if (i_pl->IsAlive() && !i_pl->HasAura(SPELL_BANISH))
diff --git a/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_lady_vashj.cpp b/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_lady_vashj.cpp
index d817c08d7f2..787b191e23d 100644
--- a/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_lady_vashj.cpp
+++ b/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_lady_vashj.cpp
@@ -257,8 +257,7 @@ public:
void EnterCombat(Unit* who) override
{
// remove old tainted cores to prevent cheating in phase 2
- Map* map = me->GetMap();
- Map::PlayerList const &PlayerList = map->GetPlayers();
+ Map::PlayerList const &PlayerList = me->GetMap()->GetPlayers();
for (Map::PlayerList::const_iterator itr = PlayerList.begin(); itr != PlayerList.end(); ++itr)
if (Player* player = itr->GetSource())
player->DestroyItemCount(31088, 1, true);
diff --git a/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_leotheras_the_blind.cpp b/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_leotheras_the_blind.cpp
index 5d967a3546f..253c601e228 100644
--- a/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_leotheras_the_blind.cpp
+++ b/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_leotheras_the_blind.cpp
@@ -788,8 +788,7 @@ public:
if (Earthshock_Timer <= diff)
{
- Map* map = me->GetMap();
- Map::PlayerList const &PlayerList = map->GetPlayers();
+ Map::PlayerList const &PlayerList = me->GetMap()->GetPlayers();
for (Map::PlayerList::const_iterator itr = PlayerList.begin(); itr != PlayerList.end(); ++itr)
{
if (Player* i_pl = itr->GetSource())
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 096777163a6..7c4dbdeaab1 100644
--- a/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_lurker_below.cpp
+++ b/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_lurker_below.cpp
@@ -259,8 +259,7 @@ public:
if (CheckTimer <= diff)//check if there are players in melee range
{
InRange = false;
- Map* map = me->GetMap();
- Map::PlayerList const &PlayerList = map->GetPlayers();
+ Map::PlayerList const &PlayerList = me->GetMap()->GetPlayers();
if (!PlayerList.isEmpty())
{
for (Map::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i)
@@ -274,15 +273,11 @@ public:
if (RotTimer)
{
- Map* map = me->GetMap();
- if (map->IsDungeon())
+ Map::PlayerList const &PlayerList = me->GetMap()->GetPlayers();
+ for (Map::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i)
{
- Map::PlayerList const &PlayerList = map->GetPlayers();
- for (Map::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i)
- {
- if (i->GetSource() && i->GetSource()->IsAlive() && me->HasInArc(diff/20000.f*float(M_PI)*2.f, i->GetSource()) && me->IsWithinDist(i->GetSource(), SPOUT_DIST) && !i->GetSource()->IsInWater())
- DoCast(i->GetSource(), SPELL_SPOUT, true); // only knock back players in arc, in 100yards, not in water
- }
+ if (i->GetSource() && i->GetSource()->IsAlive() && me->HasInArc(diff/20000.f*float(M_PI)*2.f, i->GetSource()) && me->IsWithinDist(i->GetSource(), SPOUT_DIST) && !i->GetSource()->IsInWater())
+ DoCast(i->GetSource(), SPELL_SPOUT, true); // only knock back players in arc, in 100yards, not in water
}
if (SpoutAnimTimer <= diff)
diff --git a/src/server/scripts/Outland/HellfireCitadel/ShatteredHalls/shattered_halls.cpp b/src/server/scripts/Outland/HellfireCitadel/ShatteredHalls/shattered_halls.cpp
index 500b0ae4bcb..f47e191c118 100644
--- a/src/server/scripts/Outland/HellfireCitadel/ShatteredHalls/shattered_halls.cpp
+++ b/src/server/scripts/Outland/HellfireCitadel/ShatteredHalls/shattered_halls.cpp
@@ -82,7 +82,7 @@ class boss_shattered_executioner : public CreatureScript
void Reset() override
{
_Reset();
-
+
// _Reset() resets the loot mode, so we add them again, if any
uint32 prisonersExecuted = instance->GetData(DATA_PRISONERS_EXECUTED);
if (prisonersExecuted == 0)
diff --git a/src/server/scripts/Outland/TempestKeep/Eye/boss_kaelthas.cpp b/src/server/scripts/Outland/TempestKeep/Eye/boss_kaelthas.cpp
index 0dc75ff8efa..872269fd19f 100644
--- a/src/server/scripts/Outland/TempestKeep/Eye/boss_kaelthas.cpp
+++ b/src/server/scripts/Outland/TempestKeep/Eye/boss_kaelthas.cpp
@@ -297,7 +297,7 @@ const float CAPERNIAN_DISTANCE = 20.0f; //she casts away fro
Position const afGravityPos = {795.0f, 0.0f, 70.0f};
-Position const TransitionPos[6] =
+Position const TransitionPos[6] =
{
// First two values are not static, they seem to differ on each sniff.
{ 794.0522f, -0.96732f, 48.97848f, 0.0f },
@@ -869,7 +869,7 @@ class boss_thaladred_the_darkener : public CreatureScript
public:
boss_thaladred_the_darkener() : CreatureScript("boss_thaladred_the_darkener") { }
-
+
struct boss_thaladred_the_darkenerAI : public advisorbase_ai
{
boss_thaladred_the_darkenerAI(Creature* creature) : advisorbase_ai(creature)
@@ -963,7 +963,7 @@ class boss_lord_sanguinar : public CreatureScript
public:
boss_lord_sanguinar() : CreatureScript("boss_lord_sanguinar") { }
-
+
struct boss_lord_sanguinarAI : public advisorbase_ai
{
boss_lord_sanguinarAI(Creature* creature) : advisorbase_ai(creature)
@@ -1027,7 +1027,7 @@ class boss_grand_astromancer_capernian : public CreatureScript
public:
boss_grand_astromancer_capernian() : CreatureScript("boss_grand_astromancer_capernian") { }
-
+
struct boss_grand_astromancer_capernianAI : public advisorbase_ai
{
boss_grand_astromancer_capernianAI(Creature* creature) : advisorbase_ai(creature)
@@ -1307,7 +1307,7 @@ class npc_phoenix_tk : public CreatureScript
public:
npc_phoenix_tk() : CreatureScript("npc_phoenix_tk") { }
-
+
struct npc_phoenix_tkAI : public ScriptedAI
{
npc_phoenix_tkAI(Creature* creature) : ScriptedAI(creature)
@@ -1366,7 +1366,7 @@ class npc_phoenix_egg_tk : public CreatureScript
public:
npc_phoenix_egg_tk() : CreatureScript("npc_phoenix_egg_tk") { }
-
+
struct npc_phoenix_egg_tkAI : public ScriptedAI
{
npc_phoenix_egg_tkAI(Creature* creature) : ScriptedAI(creature)
@@ -1464,7 +1464,7 @@ class spell_kael_gravity_lapse : public SpellScriptLoader
{
OnEffectHitTarget += SpellEffectFn(spell_kael_gravity_lapse_SpellScript::HandleScript, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT);
}
-
+
private:
uint8 _targetCount;
};
diff --git a/src/server/scripts/Outland/zone_hellfire_peninsula.cpp b/src/server/scripts/Outland/zone_hellfire_peninsula.cpp
index fcfa77bc2e0..0a9f8640ad2 100644
--- a/src/server/scripts/Outland/zone_hellfire_peninsula.cpp
+++ b/src/server/scripts/Outland/zone_hellfire_peninsula.cpp
@@ -483,7 +483,7 @@ class npc_barada : public CreatureScript
{
public:
npc_barada() : CreatureScript("npc_barada") { }
-
+
struct npc_baradaAI : public ScriptedAI
{
npc_baradaAI(Creature* creature) : ScriptedAI(creature)
@@ -779,7 +779,7 @@ public:
me->SetCanFly(true);
me->SetSpeed(MOVE_RUN, 0.2f);
-
+
me->SetFacingTo(3.207566f);
me->GetMotionMaster()->MoveJump(exorcismPos[2], 2.0f, 2.0f);
@@ -860,14 +860,14 @@ public:
}
}
}
-
+
private:
EventMap events;
SummonList summons;
-
+
uint8 circleRounds;
uint8 point;
-
+
bool wpreached;
};
diff --git a/src/server/scripts/Spells/spell_dk.cpp b/src/server/scripts/Spells/spell_dk.cpp
index cd0052c24bc..88271dc7139 100644
--- a/src/server/scripts/Spells/spell_dk.cpp
+++ b/src/server/scripts/Spells/spell_dk.cpp
@@ -1343,6 +1343,15 @@ class spell_dk_raise_dead : public SpellScriptLoader
GetCaster()->CastSpell(targets, spellInfo, NULL, TRIGGERED_FULL_MASK);
}
+ void OverrideCooldown()
+ {
+ // Because the ghoul is summoned by one of triggered spells SendCooldownEvent is not sent for this spell
+ // but the client has locked it by itself so we need some link between this spell and the real spell summoning.
+ // Luckily such link already exists - spell category
+ // This starts infinite category cooldown which can later be used by SendCooldownEvent to send packet for this spell
+ GetCaster()->GetSpellHistory()->StartCooldown(GetSpellInfo(), 0, nullptr, true);
+ }
+
void Register() override
{
OnCheckCast += SpellCheckCastFn(spell_dk_raise_dead_SpellScript::CheckCast);
@@ -1351,6 +1360,7 @@ class spell_dk_raise_dead : public SpellScriptLoader
OnCast += SpellCastFn(spell_dk_raise_dead_SpellScript::ConsumeReagents);
OnEffectHitTarget += SpellEffectFn(spell_dk_raise_dead_SpellScript::HandleRaiseDead, EFFECT_1, SPELL_EFFECT_SCRIPT_EFFECT);
OnEffectHitTarget += SpellEffectFn(spell_dk_raise_dead_SpellScript::HandleRaiseDead, EFFECT_2, SPELL_EFFECT_DUMMY);
+ AfterCast += SpellCastFn(spell_dk_raise_dead_SpellScript::OverrideCooldown);
}
private:
diff --git a/src/server/scripts/World/duel_reset.cpp b/src/server/scripts/World/duel_reset.cpp
index f08469d5bd5..9e720455692 100644
--- a/src/server/scripts/World/duel_reset.cpp
+++ b/src/server/scripts/World/duel_reset.cpp
@@ -17,6 +17,8 @@
#include "ScriptMgr.h"
#include "Player.h"
+#include "Pet.h"
+#include "SpellInfo.h"
class DuelResetScript : public PlayerScript
{
@@ -26,28 +28,89 @@ class DuelResetScript : public PlayerScript
// Called when a duel starts (after 3s countdown)
void OnDuelStart(Player* player1, Player* player2) override
{
+ // Cooldowns reset
if (sWorld->getBoolConfig(CONFIG_RESET_DUEL_COOLDOWNS))
{
player1->GetSpellHistory()->SaveCooldownStateBeforeDuel();
player2->GetSpellHistory()->SaveCooldownStateBeforeDuel();
- player1->RemoveArenaSpellCooldowns(true);
- player2->RemoveArenaSpellCooldowns(true);
+
+ ResetSpellCooldowns(player1);
+ ResetSpellCooldowns(player2);
+ }
+
+ // Health and mana reset
+ if (sWorld->getBoolConfig(CONFIG_RESET_DUEL_HEALTH_MANA))
+ {
+ player1->SaveHealthBeforeDuel();
+ player1->SetHealth(player1->GetMaxHealth());
+
+ player2->SaveHealthBeforeDuel();
+ player2->SetHealth(player2->GetMaxHealth());
+
+ // check if player1 class uses mana
+ if (player1->getPowerType() == POWER_MANA || player1->getClass() == CLASS_DRUID)
+ {
+ player1->SaveManaBeforeDuel();
+ player1->SetPower(POWER_MANA, player1->GetMaxPower(POWER_MANA));
+ }
+
+ // check if player2 class uses mana
+ if (player2->getPowerType() == POWER_MANA || player2->getClass() == CLASS_DRUID)
+ {
+ player2->SaveManaBeforeDuel();
+ player2->SetPower(POWER_MANA, player2->GetMaxPower(POWER_MANA));
+ }
}
}
// Called when a duel ends
- void OnDuelEnd(Player* winner, Player* loser, DuelCompleteType /*type*/) override
+ void OnDuelEnd(Player* winner, Player* loser, DuelCompleteType type) override
{
- if (sWorld->getBoolConfig(CONFIG_RESET_DUEL_COOLDOWNS))
+ // do not reset anything if DUEL_INTERRUPTED or DUEL_FLED
+ if (type == DUEL_WON)
{
- winner->RemoveArenaSpellCooldowns(true);
- loser->RemoveArenaSpellCooldowns(true);
+ // Cooldown restore
+ if (sWorld->getBoolConfig(CONFIG_RESET_DUEL_COOLDOWNS))
+ {
+
+ ResetSpellCooldowns(winner);
+ ResetSpellCooldowns(loser);
- winner->GetSpellHistory()->RestoreCooldownStateAfterDuel();
- loser->GetSpellHistory()->RestoreCooldownStateAfterDuel();
+ winner->GetSpellHistory()->RestoreCooldownStateAfterDuel();
+ loser->GetSpellHistory()->RestoreCooldownStateAfterDuel();
+ }
+
+ // Health and mana restore
+ if (sWorld->getBoolConfig(CONFIG_RESET_DUEL_HEALTH_MANA))
+ {
+ winner->RestoreHealthAfterDuel();
+ loser->RestoreHealthAfterDuel();
+
+ // check if player1 class uses mana
+ if (winner->getPowerType() == POWER_MANA || winner->getClass() == CLASS_DRUID)
+ winner->RestoreManaAfterDuel();
+
+ // check if player2 class uses mana
+ if (loser->getPowerType() == POWER_MANA || loser->getClass() == CLASS_DRUID)
+ loser->RestoreManaAfterDuel();
+ }
}
}
+
+ static void ResetSpellCooldowns(Player* player)
+ {
+ // remove cooldowns on spells that have < 10 min CD and has no onHold
+ player->GetSpellHistory()->ResetCooldowns([](SpellHistory::CooldownStorageType::iterator itr) -> bool
+ {
+ SpellInfo const* spellInfo = sSpellMgr->EnsureSpellInfo(itr->first);
+ return spellInfo->RecoveryTime < 10 * MINUTE * IN_MILLISECONDS && spellInfo->CategoryRecoveryTime < 10 * MINUTE * IN_MILLISECONDS && !itr->second.OnHold;
+ }, true);
+
+ // pet cooldowns
+ if (Pet* pet = player->GetPet())
+ pet->GetSpellHistory()->ResetAllCooldowns();
+ }
};
void AddSC_duel_reset()
diff --git a/src/server/shared/Dynamic/TypeContainer.h b/src/server/shared/Dynamic/TypeContainer.h
index b68dec00da7..7addf8028bf 100644
--- a/src/server/shared/Dynamic/TypeContainer.h
+++ b/src/server/shared/Dynamic/TypeContainer.h
@@ -47,7 +47,7 @@ template<>
struct ContainerMapList<TypeNull> /* nothing is in type null */
{
};
-template<class H, class T>
+template<class H, class T>
struct ContainerMapList<TypeList<H, T> >
{
ContainerMapList<H> _elements;
@@ -105,7 +105,7 @@ class TypeMapContainer
template<class SPECIFIC_TYPE> size_t Count() const { return Trinity::Count(i_elements, (SPECIFIC_TYPE*)NULL); }
/// inserts a specific object into the container
- template<class SPECIFIC_TYPE>
+ template<class SPECIFIC_TYPE>
bool insert(SPECIFIC_TYPE *obj)
{
SPECIFIC_TYPE* t = Trinity::Insert(i_elements, obj);
@@ -113,7 +113,7 @@ class TypeMapContainer
}
/// Removes the object from the container, and returns the removed object
- //template<class SPECIFIC_TYPE>
+ //template<class SPECIFIC_TYPE>
//bool remove(SPECIFIC_TYPE* obj)
//{
// SPECIFIC_TYPE* t = Trinity::Remove(i_elements, obj);
diff --git a/src/server/shared/Networking/MessageBuffer.h b/src/server/shared/Networking/MessageBuffer.h
index 95e26974626..5f9af33a45d 100644
--- a/src/server/shared/Networking/MessageBuffer.h
+++ b/src/server/shared/Networking/MessageBuffer.h
@@ -84,9 +84,9 @@ public:
// Ensures there's "some" free space, make sure to call Normalize() before this
void EnsureFreeSpace()
{
- // Double the size of the buffer if it's already full
+ // resize buffer if it's already full
if (GetRemainingSpace() == 0)
- _storage.resize(_storage.size() * 2);
+ _storage.resize(_storage.size() * 3 / 2);
}
void Write(void const* data, std::size_t size)
diff --git a/src/server/shared/Networking/Socket.h b/src/server/shared/Networking/Socket.h
index 1989411bccb..3f588298617 100644
--- a/src/server/shared/Networking/Socket.h
+++ b/src/server/shared/Networking/Socket.h
@@ -160,6 +160,8 @@ protected:
MessageBuffer _writeBuffer;
#endif
+ boost::asio::io_service& io_service() { return _socket.get_io_service(); }
+
private:
void ReadHandlerInternal(boost::system::error_code error, size_t transferredBytes)
{
diff --git a/src/server/worldserver/CommandLine/CliRunnable.cpp b/src/server/worldserver/CommandLine/CliRunnable.cpp
index ad9ae28f712..3901e17f9c2 100644
--- a/src/server/worldserver/CommandLine/CliRunnable.cpp
+++ b/src/server/worldserver/CommandLine/CliRunnable.cpp
@@ -36,9 +36,9 @@
char* command_finder(const char* text, int state)
{
- static int idx, len;
+ static size_t idx, len;
const char* ret;
- ChatCommand* cmd = ChatHandler::getCommandTable();
+ std::vector<ChatCommand> const& cmd = ChatHandler::getCommandTable();
if (!state)
{
@@ -46,20 +46,19 @@ char* command_finder(const char* text, int state)
len = strlen(text);
}
- while ((ret = cmd[idx].Name))
+ while (idx < cmd.size())
{
+ ret = cmd[idx].Name;
if (!cmd[idx].AllowConsole)
{
- idx++;
+ ++idx;
continue;
}
- idx++;
+ ++idx;
//printf("Checking %s \n", cmd[idx].Name);
if (strncmp(ret, text, len) == 0)
return strdup(ret);
- if (cmd[idx].Name == NULL)
- break;
}
return ((char*)NULL);
diff --git a/src/server/worldserver/worldserver.conf.dist b/src/server/worldserver/worldserver.conf.dist
index 221fea12399..8619a864998 100644
--- a/src/server/worldserver/worldserver.conf.dist
+++ b/src/server/worldserver/worldserver.conf.dist
@@ -1074,6 +1074,16 @@ Command.LookupMaxResults = 0
AllowTickets = 1
#
+# DeletedCharacterTicketTrace
+# Description: Keep trace of tickets opened by deleted characters
+# gm_ticket.playerGuid will be 0, old GUID and character name
+# will be included in gm_ticket.comment
+# Default: 0 - (Disabled)
+# 1 - (Enabled)
+
+DeletedCharacterTicketTrace = 0
+
+#
# DungeonFinder.OptionsMask
# Description: Dungeon and raid finder system.
# Value is a bitmask consisting of:
@@ -1132,11 +1142,11 @@ BirthdayTime = 1222964635
# DATABASE_CHARACTER = 2, // Character database
# DATABASE_WORLD = 4, // World database
#
-# Default: 0 - (All Disabled)
+# Default: 7 - (All enabled)
# 4 - (Enable world only)
-# 7 - (All enabled)
+# 0 - (All disabled)
-Updates.EnableDatabases = 0
+Updates.EnableDatabases = 7
#
# Updates.SourcePath
@@ -2199,6 +2209,14 @@ Battleground.QueueAnnouncer.PlayerOnly = 0
Battleground.StoreStatistics.Enable = 0
#
+# Battleground.TrackDeserters.Enable
+# Description: Track deserters of Battlegrounds.
+# Default: 0 - (Disabled)
+# 1 - (Enabled)
+
+Battleground.TrackDeserters.Enable = 0
+
+#
# Battleground.InvitationType
# Description: Set Battleground invitation type.
# Default: 0 - (Normal, Invite as much players to battlegrounds as queued,
@@ -2622,6 +2640,13 @@ HonorPointsAfterDuel = 0
ResetDuelCooldowns = 0
+# ResetDuelHealthMana
+# Description: Reset health and mana before duel starts and restore them when duel ends.
+# Default: 0 - (Disabled)
+# 1 - (Enabled)
+
+ResetDuelHealthMana = 0
+
#
# AlwaysMaxWeaponSkill
# Description: Players will automatically gain max weapon/defense skill when logging in,
diff --git a/src/tools/map_extractor/CMakeLists.txt b/src/tools/map_extractor/CMakeLists.txt
index 87d68cc7a2f..b10956b3264 100644
--- a/src/tools/map_extractor/CMakeLists.txt
+++ b/src/tools/map_extractor/CMakeLists.txt
@@ -9,13 +9,16 @@
# WITHOUT ANY WARRANTY, to the extent permitted by law; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-file(GLOB_RECURSE sources *.cpp *.h)
+file(GLOB_RECURSE mapextractor_SRCS *.cpp *.h)
set(include_Dirs
- ${CMAKE_SOURCE_DIR}/src/server/shared
- ${CMAKE_SOURCE_DIR}/dep/libmpq
- ${CMAKE_CURRENT_SOURCE_DIR}
- ${CMAKE_CURRENT_SOURCE_DIR}/loadlib
+ ${CMAKE_SOURCE_DIR}
+ ${CMAKE_SOURCE_DIR}/dep/cppformat
+ ${CMAKE_SOURCE_DIR}/dep/libmpq
+ ${CMAKE_SOURCE_DIR}/src/common
+ ${CMAKE_SOURCE_DIR}/src/common/Utilities
+ ${CMAKE_SOURCE_DIR}/src/server/shared
+ ${CMAKE_CURRENT_SOURCE_DIR}/loadlib
)
if( WIN32 )
@@ -28,13 +31,16 @@ endif()
include_directories(${include_Dirs})
add_executable(mapextractor
- ${sources}
+ ${mapextractor_SRCS}
)
target_link_libraries(mapextractor
+ common
+ format
mpq
${BZIP2_LIBRARIES}
${ZLIB_LIBRARIES}
+ ${Boost_LIBRARIES}
)
if( UNIX )
diff --git a/src/tools/map_extractor/System.cpp b/src/tools/map_extractor/System.cpp
index dcaa3ba0a76..c0497a1cefb 100644
--- a/src/tools/map_extractor/System.cpp
+++ b/src/tools/map_extractor/System.cpp
@@ -22,36 +22,17 @@
#include <deque>
#include <set>
#include <cstdlib>
-
-#ifdef _WIN32
-#include "direct.h"
-#else
-#include <sys/stat.h>
-#include <unistd.h>
-#endif
+#include <fstream>
#include "dbcfile.h"
#include "mpq_libmpq04.h"
+#include "StringFormat.h"
#include "adt.h"
#include "wdt.h"
-#include <fcntl.h>
-
-#if defined( __GNUC__ )
- #define _open open
- #define _close close
- #ifndef O_BINARY
- #define O_BINARY 0
- #endif
-#else
- #include <io.h>
-#endif
-
-#ifdef O_LARGEFILE
- #define OPEN_FLAGS (O_RDONLY | O_BINARY | O_LARGEFILE)
-#else
- #define OPEN_FLAGS (O_RDONLY | O_BINARY)
-#endif
+
+#include <boost/filesystem.hpp>
+
extern ArchiveSet gOpenArchives;
typedef struct
@@ -106,37 +87,14 @@ const char *CONF_mpq_list[]={
static const char* const langs[] = {"enGB", "enUS", "deDE", "esES", "frFR", "koKR", "zhCN", "zhTW", "enCN", "enTW", "esMX", "ruRU" };
#define LANG_COUNT 12
-void CreateDir( const std::string& Path )
-{
- if(chdir(Path.c_str()) == 0)
- {
- chdir("../");
- return;
- }
-
- int ret;
- #ifdef _WIN32
- ret = _mkdir( Path.c_str());
- #else
- ret = mkdir( Path.c_str(), 0777 );
- #endif
- if (ret != 0)
- {
- printf("Fatal Error: Could not create directory %s check your permissions", Path.c_str());
- exit(1);
- }
-}
-
-bool FileExists( const char* FileName )
+void CreateDir(boost::filesystem::path const& path)
{
- int fp = _open(FileName, OPEN_FLAGS);
- if(fp != -1)
- {
- _close(fp);
- return true;
- }
+ namespace fs = boost::filesystem;
+ if (fs::exists(path))
+ return;
- return false;
+ if (!fs::create_directory(path))
+ throw new std::runtime_error("Unable to create directory" + path.string());
}
void Usage(char* prg)
@@ -207,7 +165,7 @@ void HandleArgs(int argc, char * arg[])
uint32 ReadBuild(int locale)
{
// include build info file also
- std::string filename = std::string("component.wow-")+langs[locale]+".txt";
+ std::string filename = Trinity::StringFormat("component.wow-%s.txt", langs[locale]);
//printf("Read %s file... ", filename.c_str());
MPQFile m(filename.c_str());
@@ -269,7 +227,7 @@ uint32 ReadMapDBC()
strncpy(map_ids[x].name, map_name, max_map_name_length);
map_ids[x].name[max_map_name_length - 1] = '\0';
}
- printf("Done! (%u maps loaded)\n", (uint32)map_count);
+ printf("Done! (" SZFMTD "maps loaded)\n", map_count);
return map_count;
}
@@ -294,7 +252,7 @@ void ReadAreaTableDBC()
maxAreaId = dbc.getMaxId();
- printf("Done! (%u areas loaded)\n", (uint32)area_count);
+ printf("Done! (" SZFMTD " areas loaded)\n", area_count);
}
void ReadLiquidTypeTableDBC()
@@ -315,7 +273,7 @@ void ReadLiquidTypeTableDBC()
for(uint32 x = 0; x < liqTypeCount; ++x)
LiqType[dbc.getRecord(x).getUInt(0)] = dbc.getRecord(x).getUInt(3);
- printf("Done! (%u LiqTypes loaded)\n", (uint32)liqTypeCount);
+ printf("Done! (" SZFMTD " LiqTypes loaded)\n", liqTypeCount);
}
//
@@ -414,17 +372,17 @@ uint8 liquid_flags[ADT_CELLS_PER_GRID][ADT_CELLS_PER_GRID];
bool liquid_show[ADT_GRID_SIZE][ADT_GRID_SIZE];
float liquid_height[ADT_GRID_SIZE+1][ADT_GRID_SIZE+1];
-bool ConvertADT(char *filename, char *filename2, int /*cell_y*/, int /*cell_x*/, uint32 build)
+bool ConvertADT(std::string const& inputPath, std::string const& outputPath, int /*cell_y*/, int /*cell_x*/, uint32 build)
{
ADT_file adt;
- if (!adt.loadFile(filename))
+ if (!adt.loadFile(inputPath))
return false;
adt_MCIN *cells = adt.a_grid->getMCIN();
if (!cells)
{
- printf("Can't find cells in '%s'\n", filename);
+ printf("Can't find cells in '%s'\n", inputPath.c_str());
return false;
}
@@ -434,8 +392,8 @@ bool ConvertADT(char *filename, char *filename2, int /*cell_y*/, int /*cell_x*/,
// Prepare map header
map_fileheader map;
- map.mapMagic = *(uint32 const*)MAP_MAGIC;
- map.versionMagic = *(uint32 const*)MAP_VERSION_MAGIC;
+ map.mapMagic = *reinterpret_cast<uint32 const*>(MAP_MAGIC);
+ map.versionMagic = *reinterpret_cast<uint32 const*>(MAP_VERSION_MAGIC);
map.buildMagic = build;
// Get area flags data
@@ -452,7 +410,7 @@ bool ConvertADT(char *filename, char *filename2, int /*cell_y*/, int /*cell_x*/,
area_flags[i][j] = areas[areaid];
continue;
}
- printf("File: %s\nCan't find area flag for areaid %u [%d, %d].\n", filename, areaid, cell->ix, cell->iy);
+ printf("File: %s\nCan't find area flag for areaid %u [%d, %d].\n", inputPath.c_str(), areaid, cell->ix, cell->iy);
}
area_flags[i][j] = 0xffff;
}
@@ -478,7 +436,7 @@ bool ConvertADT(char *filename, char *filename2, int /*cell_y*/, int /*cell_x*/,
map.areaMapSize = sizeof(map_areaHeader);
map_areaHeader areaHeader;
- areaHeader.fourcc = *(uint32 const*)MAP_AREA_MAGIC;
+ areaHeader.fourcc = *reinterpret_cast<uint32 const*>(MAP_AREA_MAGIC);
areaHeader.flags = 0;
if (fullAreaData)
{
@@ -488,7 +446,7 @@ bool ConvertADT(char *filename, char *filename2, int /*cell_y*/, int /*cell_x*/,
else
{
areaHeader.flags |= MAP_AREA_NO_AREA;
- areaHeader.gridArea = (uint16)areaflag;
+ areaHeader.gridArea = static_cast<uint16>(areaflag);
}
//
@@ -607,7 +565,7 @@ bool ConvertADT(char *filename, char *filename2, int /*cell_y*/, int /*cell_x*/,
map.heightMapSize = sizeof(map_heightHeader);
map_heightHeader heightHeader;
- heightHeader.fourcc = *(uint32 const*)MAP_HEIGHT_MAGIC;
+ heightHeader.fourcc = *reinterpret_cast<uint32 const*>(MAP_HEIGHT_MAGIC);
heightHeader.flags = 0;
heightHeader.gridHeight = minHeight;
heightHeader.gridMaxHeight = maxHeight;
@@ -763,7 +721,7 @@ bool ConvertADT(char *filename, char *filename2, int /*cell_y*/, int /*cell_x*/,
case LIQUID_TYPE_MAGMA: liquid_flags[i][j] |= MAP_LIQUID_TYPE_MAGMA; break;
case LIQUID_TYPE_SLIME: liquid_flags[i][j] |= MAP_LIQUID_TYPE_SLIME; break;
default:
- printf("\nCan't find Liquid type %u for map %s\nchunk %d,%d\n", h->liquidType, filename, i, j);
+ printf("\nCan't find Liquid type %u for map %s\nchunk %d,%d\n", h->liquidType, inputPath.c_str(), i, j);
break;
}
// Dark water detect
@@ -848,7 +806,7 @@ bool ConvertADT(char *filename, char *filename2, int /*cell_y*/, int /*cell_x*/,
}
map.liquidMapOffset = map.heightMapOffset + map.heightMapSize;
map.liquidMapSize = sizeof(map_liquidHeader);
- liquidHeader.fourcc = *(uint32 const*)MAP_LIQUID_MAGIC;
+ liquidHeader.fourcc = *reinterpret_cast<uint32 const*>(MAP_LIQUID_MAGIC);
liquidHeader.flags = 0;
liquidHeader.liquidType = 0;
liquidHeader.offsetX = minX;
@@ -906,69 +864,72 @@ bool ConvertADT(char *filename, char *filename2, int /*cell_y*/, int /*cell_x*/,
map.holesSize = 0;
// Ok all data prepared - store it
- FILE* output = fopen(filename2, "wb");
- if (!output)
+
+ std::ofstream outFile(outputPath, std::ofstream::out | std::ofstream::binary);
+ if (!outFile)
{
- printf("Can't create the output file '%s'\n", filename2);
+ printf("Can't create the output file '%s'\n", outputPath.c_str());
return false;
}
- fwrite(&map, sizeof(map), 1, output);
+
+ outFile.write(reinterpret_cast<const char*>(&map), sizeof(map));
// Store area data
- fwrite(&areaHeader, sizeof(areaHeader), 1, output);
+ outFile.write(reinterpret_cast<const char*>(&areaHeader), sizeof(areaHeader));
if (!(areaHeader.flags&MAP_AREA_NO_AREA))
- fwrite(area_flags, sizeof(area_flags), 1, output);
+ outFile.write(reinterpret_cast<const char*>(area_flags), sizeof(area_flags));
// Store height data
- fwrite(&heightHeader, sizeof(heightHeader), 1, output);
+ outFile.write(reinterpret_cast<const char*>(&heightHeader), sizeof(heightHeader));
if (!(heightHeader.flags & MAP_HEIGHT_NO_HEIGHT))
{
if (heightHeader.flags & MAP_HEIGHT_AS_INT16)
{
- fwrite(uint16_V9, sizeof(uint16_V9), 1, output);
- fwrite(uint16_V8, sizeof(uint16_V8), 1, output);
+ outFile.write(reinterpret_cast<const char*>(uint16_V9), sizeof(uint16_V9));
+ outFile.write(reinterpret_cast<const char*>(uint16_V8), sizeof(uint16_V8));
}
else if (heightHeader.flags & MAP_HEIGHT_AS_INT8)
{
- fwrite(uint8_V9, sizeof(uint8_V9), 1, output);
- fwrite(uint8_V8, sizeof(uint8_V8), 1, output);
+ outFile.write(reinterpret_cast<const char*>(uint8_V9), sizeof(uint8_V9));
+ outFile.write(reinterpret_cast<const char*>(uint8_V8), sizeof(uint8_V8));
}
else
{
- fwrite(V9, sizeof(V9), 1, output);
- fwrite(V8, sizeof(V8), 1, output);
+ outFile.write(reinterpret_cast<const char*>(V9), sizeof(V9));
+ outFile.write(reinterpret_cast<const char*>(V8), sizeof(V8));
}
}
// Store liquid data if need
if (map.liquidMapOffset)
{
- fwrite(&liquidHeader, sizeof(liquidHeader), 1, output);
+ outFile.write(reinterpret_cast<const char*>(&liquidHeader), sizeof(liquidHeader));
+
if (!(liquidHeader.flags&MAP_LIQUID_NO_TYPE))
{
- fwrite(liquid_entry, sizeof(liquid_entry), 1, output);
- fwrite(liquid_flags, sizeof(liquid_flags), 1, output);
+ outFile.write(reinterpret_cast<const char*>(liquid_entry), sizeof(liquid_entry));
+ outFile.write(reinterpret_cast<const char*>(liquid_flags), sizeof(liquid_flags));
}
+
if (!(liquidHeader.flags&MAP_LIQUID_NO_HEIGHT))
{
- for (int y=0; y<liquidHeader.height;y++)
- fwrite(&liquid_height[y+liquidHeader.offsetY][liquidHeader.offsetX], sizeof(float), liquidHeader.width, output);
+ for (int y = 0; y < liquidHeader.height; y++)
+ outFile.write(reinterpret_cast<const char*>(&liquid_height[y + liquidHeader.offsetY][liquidHeader.offsetX]), sizeof(float) * liquidHeader.width);
}
}
// store hole data
if (hasHoles)
- fwrite(holes, map.holesSize, 1, output);
-
- fclose(output);
+ outFile.write(reinterpret_cast<const char*>(holes), map.holesSize);
+ outFile.close();
return true;
}
void ExtractMapsFromMpq(uint32 build)
{
- char mpq_filename[1024];
- char output_filename[1024];
- char mpq_map_name[1024];
+ std::string mpqFileName;
+ std::string outputFileName;
+ std::string mpqMapName;
printf("Extracting maps...\n");
@@ -986,9 +947,10 @@ void ExtractMapsFromMpq(uint32 build)
{
printf("Extract %s (%d/%u) \n", map_ids[z].name, z+1, map_count);
// Loadup map grid data
- sprintf(mpq_map_name, "World\\Maps\\%s\\%s.wdt", map_ids[z].name, map_ids[z].name);
+
+ mpqMapName = Trinity::StringFormat("World\\Maps\\%s\\%s.wdt", map_ids[z].name, map_ids[z].name);
WDT_file wdt;
- if (!wdt.loadFile(mpq_map_name, false))
+ if (!wdt.loadFile(mpqMapName, false))
{
// printf("Error loading %s map wdt data\n", map_ids[z].name);
continue;
@@ -1000,9 +962,10 @@ void ExtractMapsFromMpq(uint32 build)
{
if (!wdt.main->adt_list[y][x].exist)
continue;
- sprintf(mpq_filename, "World\\Maps\\%s\\%s_%u_%u.adt", map_ids[z].name, map_ids[z].name, x, y);
- sprintf(output_filename, "%s/maps/%03u%02u%02u.map", output_path, map_ids[z].id, y, x);
- ConvertADT(mpq_filename, output_filename, y, x, build);
+
+ mpqFileName = Trinity::StringFormat("World\\Maps\\%s\\%s_%u_%u.adt", map_ids[z].name, map_ids[z].name, x, y);
+ outputFileName = Trinity::StringFormat("%s/maps/%03u%02u%02u.map", output_path, map_ids[z].id, y, x);
+ ConvertADT(mpqFileName, outputFileName, y, x, build);
}
// draw progress bar
printf("Processing........................%d%%\r", (100 * (y+1)) / WDT_MAP_SIZE);
@@ -1038,9 +1001,9 @@ void ExtractDBCFiles(int locale, bool basicLocale)
// get DBC file list
for(ArchiveSet::iterator i = gOpenArchives.begin(); i != gOpenArchives.end();++i)
{
- vector<string> files;
+ std::vector<std::string> files;
(*i)->GetFileListTo(files);
- for (vector<string>::iterator iter = files.begin(); iter != files.end(); ++iter)
+ for (std::vector<std::string>::iterator iter = files.begin(); iter != files.end(); ++iter)
if (iter->rfind(".dbc") == iter->length() - strlen(".dbc"))
dbcfiles.insert(*iter);
}
@@ -1057,20 +1020,20 @@ void ExtractDBCFiles(int locale, bool basicLocale)
// extract Build info file
{
- string mpq_name = std::string("component.wow-") + langs[locale] + ".txt";
- string filename = path + mpq_name;
+ std::string mpq_name = std::string("component.wow-") + langs[locale] + ".txt";
+ std::string filename = path + mpq_name;
ExtractFile(mpq_name.c_str(), filename);
}
// extract DBCs
uint32 count = 0;
- for (set<string>::iterator iter = dbcfiles.begin(); iter != dbcfiles.end(); ++iter)
+ for (std::set<std::string>::iterator iter = dbcfiles.begin(); iter != dbcfiles.end(); ++iter)
{
- string filename = path;
+ std::string filename = path;
filename += (iter->c_str() + strlen("DBFilesClient\\"));
- if(FileExists(filename.c_str()))
+ if (boost::filesystem::exists(filename))
continue;
if (ExtractFile(iter->c_str(), filename))
@@ -1081,32 +1044,31 @@ void ExtractDBCFiles(int locale, bool basicLocale)
void LoadLocaleMPQFiles(int const locale)
{
- char filename[512];
+ std::string fileName = Trinity::StringFormat("%s/Data/%s/locale-%s.MPQ", input_path, langs[locale], langs[locale]);
- sprintf(filename,"%s/Data/%s/locale-%s.MPQ", input_path, langs[locale], langs[locale]);
- new MPQArchive(filename);
+ new MPQArchive(fileName.c_str());
for(int i = 1; i < 5; ++i)
{
- char ext[3] = "";
- if(i > 1)
- sprintf(ext, "-%i", i);
+ std::string ext;
+ if (i > 1)
+ ext = Trinity::StringFormat("-%i", i);
- sprintf(filename,"%s/Data/%s/patch-%s%s.MPQ", input_path, langs[locale], langs[locale], ext);
- if(FileExists(filename))
- new MPQArchive(filename);
+ fileName = Trinity::StringFormat("%s/Data/%s/patch-%s%s.MPQ", input_path, langs[locale], langs[locale], ext.c_str());
+ if (boost::filesystem::exists(fileName))
+ new MPQArchive(fileName.c_str());
}
}
void LoadCommonMPQFiles()
{
- char filename[512];
+ std::string fileName;
int count = sizeof(CONF_mpq_list)/sizeof(char*);
for(int i = 0; i < count; ++i)
{
- sprintf(filename, "%s/Data/%s", input_path, CONF_mpq_list[i]);
- if(FileExists(filename))
- new MPQArchive(filename);
+ fileName = Trinity::StringFormat("%s/Data/%s", input_path, CONF_mpq_list[i]);
+ if (boost::filesystem::exists(fileName))
+ new MPQArchive(fileName.c_str());
}
}
@@ -1128,9 +1090,8 @@ int main(int argc, char * arg[])
for (int i = 0; i < LANG_COUNT; i++)
{
- char tmp1[512];
- sprintf(tmp1, "%s/Data/%s/locale-%s.MPQ", input_path, langs[i], langs[i]);
- if (FileExists(tmp1))
+ std::string filename = Trinity::StringFormat("%s/Data/%s/locale-%s.MPQ", input_path, langs[i], langs[i]);
+ if (boost::filesystem::exists(filename))
{
printf("Detected locale: %s\n", langs[i]);
diff --git a/src/tools/map_extractor/loadlib.cpp b/src/tools/map_extractor/loadlib.cpp
index 936cdb72cfd..2f31b472b56 100644
--- a/src/tools/map_extractor/loadlib.cpp
+++ b/src/tools/map_extractor/loadlib.cpp
@@ -38,14 +38,14 @@ FileLoader::~FileLoader()
free();
}
-bool FileLoader::loadFile(char *filename, bool log)
+bool FileLoader::loadFile(std::string const& fileName, bool log)
{
free();
- MPQFile mf(filename);
+ MPQFile mf(fileName.c_str());
if(mf.isEof())
{
if (log)
- printf("No such file %s\n", filename);
+ printf("No such file %s\n", fileName.c_str());
return false;
}
@@ -57,7 +57,7 @@ bool FileLoader::loadFile(char *filename, bool log)
if (prepareLoadedData())
return true;
- printf("Error loading %s", filename);
+ printf("Error loading %s", fileName.c_str());
mf.close();
free();
return false;
diff --git a/src/tools/map_extractor/loadlib/loadlib.h b/src/tools/map_extractor/loadlib/loadlib.h
index a0b62a85983..6547704d885 100644
--- a/src/tools/map_extractor/loadlib/loadlib.h
+++ b/src/tools/map_extractor/loadlib/loadlib.h
@@ -19,31 +19,9 @@
#ifndef LOAD_LIB_H
#define LOAD_LIB_H
-#ifdef _WIN32
-typedef __int64 int64;
-typedef __int32 int32;
-typedef __int16 int16;
-typedef __int8 int8;
-typedef unsigned __int64 uint64;
-typedef unsigned __int32 uint32;
-typedef unsigned __int16 uint16;
-typedef unsigned __int8 uint8;
-#else
-#include <stdint.h>
-#ifndef uint64_t
-#ifdef __linux__
-#include <linux/types.h>
-#endif
-#endif
-typedef int64_t int64;
-typedef int32_t int32;
-typedef int16_t int16;
-typedef int8_t int8;
-typedef uint64_t uint64;
-typedef uint32_t uint32;
-typedef uint16_t uint16;
-typedef uint8_t uint8;
-#endif
+#include "Define.h"
+
+#include <string>
#define FILE_FORMAT_VERSION 18
@@ -79,7 +57,7 @@ public:
file_MVER *version;
FileLoader();
~FileLoader();
- bool loadFile(char *filename, bool log = true);
+ bool loadFile(std::string const& fileName, bool log = true);
virtual void free();
};
diff --git a/src/tools/map_extractor/mpq_libmpq04.h b/src/tools/map_extractor/mpq_libmpq04.h
index c6fe36a8221..b9b332f95b0 100644
--- a/src/tools/map_extractor/mpq_libmpq04.h
+++ b/src/tools/map_extractor/mpq_libmpq04.h
@@ -27,8 +27,6 @@
#include <iostream>
#include <deque>
-using namespace std;
-
class MPQArchive
{
@@ -39,7 +37,7 @@ public:
~MPQArchive() { close(); }
void close();
- void GetFileListTo(vector<string>& filelist) {
+ void GetFileListTo(std::vector<std::string>& filelist) {
uint32_t filenum;
if(libmpq__file_number(mpq_a, "(listfile)", &filenum)) return;
libmpq__off_t size, transferred;
@@ -58,7 +56,7 @@ public:
while ((token != NULL) && (counter < size)) {
//cout << token << endl;
token[strlen(token) - 1] = 0;
- string s = token;
+ std::string s = token;
filelist.push_back(s);
counter += strlen(token) + 2;
token = strtok(NULL, seps);
diff --git a/src/tools/mmaps_generator/IntermediateValues.h b/src/tools/mmaps_generator/IntermediateValues.h
index 95a651a2df8..580e9e43139 100644
--- a/src/tools/mmaps_generator/IntermediateValues.h
+++ b/src/tools/mmaps_generator/IntermediateValues.h
@@ -22,7 +22,6 @@
#include "PathCommon.h"
#include "TerrainBuilder.h"
#include "Recast.h"
-#include "DetourNavMesh.h"
namespace MMAP
{
diff --git a/src/tools/mmaps_generator/MapBuilder.cpp b/src/tools/mmaps_generator/MapBuilder.cpp
index 69ca5297024..ff2f72f3534 100644
--- a/src/tools/mmaps_generator/MapBuilder.cpp
+++ b/src/tools/mmaps_generator/MapBuilder.cpp
@@ -15,17 +15,15 @@
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#include <limits.h>
#include "PathCommon.h"
#include "MapBuilder.h"
-
#include "MapTree.h"
-#include "ModelInstance.h"
-
#include "DetourNavMeshBuilder.h"
#include "DetourNavMesh.h"
-#include "DetourCommon.h"
+#include "IntermediateValues.h"
+
+#include <limits.h>
#define MMAP_MAGIC 0x4d4d4150 // 'MMAP'
#define MMAP_VERSION 5
@@ -164,7 +162,7 @@ namespace MMAP
{
while (1)
{
- uint32 mapId;
+ uint32 mapId = 0;
_queue.WaitAndPop(mapId);
@@ -215,12 +213,12 @@ namespace MMAP
}
/**************************************************************************/
- void MapBuilder::getGridBounds(uint32 mapID, uint32 &minX, uint32 &minY, uint32 &maxX, uint32 &maxY)
+ void MapBuilder::getGridBounds(uint32 mapID, uint32 &minX, uint32 &minY, uint32 &maxX, uint32 &maxY) const
{
- maxX = INT_MAX;
- maxY = INT_MAX;
- minX = INT_MIN;
- minY = INT_MIN;
+ maxX = std::numeric_limits<uint32>::max();
+ maxY = std::numeric_limits<uint32>::max();
+ minX = 0;
+ minY = 0;
float bmin[3] = { 0, 0, 0 };
float bmax[3] = { 0, 0, 0 };
diff --git a/src/tools/mmaps_generator/MapBuilder.h b/src/tools/mmaps_generator/MapBuilder.h
index ced03d1dde8..432a0ee7489 100644
--- a/src/tools/mmaps_generator/MapBuilder.h
+++ b/src/tools/mmaps_generator/MapBuilder.h
@@ -19,20 +19,18 @@
#ifndef _MAP_BUILDER_H
#define _MAP_BUILDER_H
-#include <vector>
-#include <set>
-#include <map>
-#include <list>
-#include <atomic>
-#include <thread>
-
#include "TerrainBuilder.h"
-#include "IntermediateValues.h"
#include "Recast.h"
#include "DetourNavMesh.h"
#include "ProducerConsumerQueue.h"
+#include <vector>
+#include <set>
+#include <list>
+#include <atomic>
+#include <thread>
+
using namespace VMAP;
namespace MMAP
@@ -120,7 +118,7 @@ namespace MMAP
void getTileBounds(uint32 tileX, uint32 tileY,
float* verts, int vertCount,
float* bmin, float* bmax);
- void getGridBounds(uint32 mapID, uint32 &minX, uint32 &minY, uint32 &maxX, uint32 &maxY);
+ void getGridBounds(uint32 mapID, uint32 &minX, uint32 &minY, uint32 &maxX, uint32 &maxY) const;
bool shouldSkipMap(uint32 mapID);
bool isTransportMap(uint32 mapID);
diff --git a/src/tools/mmaps_generator/PathCommon.h b/src/tools/mmaps_generator/PathCommon.h
index 9451e9d03ba..aa9591fba22 100644
--- a/src/tools/mmaps_generator/PathCommon.h
+++ b/src/tools/mmaps_generator/PathCommon.h
@@ -19,11 +19,10 @@
#ifndef _MMAP_COMMON_H
#define _MMAP_COMMON_H
-#include <string>
-#include <vector>
-
#include "Common.h"
+#include <vector>
+
#ifndef _WIN32
#include <stddef.h>
#include <dirent.h>
diff --git a/src/tools/mmaps_generator/TerrainBuilder.cpp b/src/tools/mmaps_generator/TerrainBuilder.cpp
index 9043627994b..e525f24fced 100644
--- a/src/tools/mmaps_generator/TerrainBuilder.cpp
+++ b/src/tools/mmaps_generator/TerrainBuilder.cpp
@@ -764,12 +764,12 @@ namespace MMAP
}
uint32 liqOffset = meshData.liquidVerts.size() / 3;
- for (uint32 i = 0; i < liqVerts.size(); ++i)
- meshData.liquidVerts.append(liqVerts[i].y, liqVerts[i].z, liqVerts[i].x);
+ for (uint32 j = 0; j < liqVerts.size(); ++j)
+ meshData.liquidVerts.append(liqVerts[j].y, liqVerts[j].z, liqVerts[j].x);
- for (uint32 i = 0; i < liqTris.size() / 3; ++i)
+ for (uint32 j = 0; j < liqTris.size() / 3; ++j)
{
- meshData.liquidTris.append(liqTris[i*3+1] + liqOffset, liqTris[i*3+2] + liqOffset, liqTris[i*3] + liqOffset);
+ meshData.liquidTris.append(liqTris[j*3+1] + liqOffset, liqTris[j*3+2] + liqOffset, liqTris[j*3] + liqOffset);
meshData.liquidType.append(type);
}
}
diff --git a/src/tools/mmaps_generator/TerrainBuilder.h b/src/tools/mmaps_generator/TerrainBuilder.h
index 6c66ae45f46..f305bf0bd48 100644
--- a/src/tools/mmaps_generator/TerrainBuilder.h
+++ b/src/tools/mmaps_generator/TerrainBuilder.h
@@ -81,11 +81,13 @@ namespace MMAP
TerrainBuilder(bool skipLiquid);
~TerrainBuilder();
+ TerrainBuilder(const TerrainBuilder &tb) = delete;
+
void loadMap(uint32 mapID, uint32 tileX, uint32 tileY, MeshData &meshData);
bool loadVMap(uint32 mapID, uint32 tileX, uint32 tileY, MeshData &meshData);
void loadOffMeshConnections(uint32 mapID, uint32 tileX, uint32 tileY, MeshData &meshData, const char* offMeshFilePath);
- bool usesLiquids() { return !m_skipLiquid; }
+ bool usesLiquids() const { return !m_skipLiquid; }
// vert and triangle methods
static void transform(std::vector<G3D::Vector3> &original, std::vector<G3D::Vector3> &transformed,
@@ -104,9 +106,6 @@ namespace MMAP
/// Controls whether liquids are loaded
bool m_skipLiquid;
- /// Load the map terrain from file
- bool loadHeightMap(uint32 mapID, uint32 tileX, uint32 tileY, G3D::Array<float> &vertices, G3D::Array<int> &triangles, Spot portion);
-
/// Get the vector coordinate for a specific position
void getHeightCoord(int index, Grid grid, float xOffset, float yOffset, float* coord, float* v);
@@ -121,10 +120,6 @@ namespace MMAP
/// Get the liquid type for a specific position
uint8 getLiquidType(int square, const uint8 liquid_type[16][16]);
-
- // hide parameterless and copy constructor
- TerrainBuilder();
- TerrainBuilder(const TerrainBuilder &tb);
};
}
diff --git a/src/tools/mmaps_generator/VMapExtensions.cpp b/src/tools/mmaps_generator/VMapExtensions.cpp
deleted file mode 100644
index 63c8e524542..00000000000
--- a/src/tools/mmaps_generator/VMapExtensions.cpp
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Copyright (C) 2008-2015 TrinityCore <http://www.trinitycore.org/>
- * Copyright (C) 2005-2011 MaNGOS <http://getmangos.com/>
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include <vector>
-#include "MapTree.h"
-#include "VMapManager2.h"
-#include "WorldModel.h"
-#include "ModelInstance.h"
-
-namespace VMAP
-{
- // Need direct access to encapsulated VMAP data, so we add functions for MMAP generator
- // maybe add MapBuilder as friend to all of the below classes would be better?
-
- // declared in src/shared/vmap/MapTree.h
- void StaticMapTree::getModelInstances(ModelInstance* &models, uint32 &count)
- {
- models = iTreeValues;
- count = iNTreeValues;
- }
-
- // declared in src/shared/vmap/VMapManager2.h
- void VMapManager2::getInstanceMapTree(InstanceTreeMap &instanceMapTree)
- {
- instanceMapTree = iInstanceMapTrees;
- }
-
- // declared in src/shared/vmap/WorldModel.h
- void WorldModel::getGroupModels(std::vector<GroupModel> &groupModels)
- {
- groupModels = this->groupModels;
- }
-
- // declared in src/shared/vmap/WorldModel.h
- void GroupModel::getMeshData(std::vector<G3D::Vector3> &vertices, std::vector<MeshTriangle> &triangles, WmoLiquid* &liquid)
- {
- vertices = this->vertices;
- triangles = this->triangles;
- liquid = iLiquid;
- }
-
- // declared in src/shared/vmap/ModelInstance.h
- WorldModel* ModelInstance::getWorldModel()
- {
- return iModel;
- }
-
- // declared in src/shared/vmap/WorldModel.h
- void WmoLiquid::getPosInfo(uint32 &tilesX, uint32 &tilesY, G3D::Vector3 &corner) const
- {
- tilesX = iTilesX;
- tilesY = iTilesY;
- corner = iCorner;
- }
-}
diff --git a/src/tools/vmap4_extractor/adtfile.cpp b/src/tools/vmap4_extractor/adtfile.cpp
index 557511f6d1e..3a8b3495655 100644
--- a/src/tools/vmap4_extractor/adtfile.cpp
+++ b/src/tools/vmap4_extractor/adtfile.cpp
@@ -86,11 +86,11 @@ bool ADTFile::init(uint32 map_num, uint32 tileX, uint32 tileY)
uint32 size;
- string xMap;
- string yMap;
+ std::string xMap;
+ std::string yMap;
Adtfilename.erase(Adtfilename.find(".adt"),4);
- string TempMapNumber;
+ std::string TempMapNumber;
TempMapNumber = Adtfilename.substr(Adtfilename.length()-6,6);
xMap = TempMapNumber.substr(TempMapNumber.find("_")+1,(TempMapNumber.find_last_of("_")-1) - (TempMapNumber.find("_")));
yMap = TempMapNumber.substr(TempMapNumber.find_last_of("_")+1,(TempMapNumber.length()) - (TempMapNumber.find_last_of("_")));
@@ -134,7 +134,7 @@ bool ADTFile::init(uint32 map_num, uint32 tileX, uint32 tileY)
ADT.read(buf, size);
char *p=buf;
int t=0;
- ModelInstansName = new string[size];
+ ModelInstansName = new std::string[size];
while (p<buf+size)
{
fixnamen(p,strlen(p));
@@ -143,7 +143,7 @@ bool ADTFile::init(uint32 map_num, uint32 tileX, uint32 tileY)
ModelInstansName[t++] = s;
- string path(p);
+ std::string path(p);
ExtractSingleModel(path);
p = p+strlen(p)+1;
diff --git a/src/tools/vmap4_extractor/mpq_libmpq04.h b/src/tools/vmap4_extractor/mpq_libmpq04.h
index 6196285627d..4c8b4d376ca 100644
--- a/src/tools/vmap4_extractor/mpq_libmpq04.h
+++ b/src/tools/vmap4_extractor/mpq_libmpq04.h
@@ -21,14 +21,12 @@
#include "loadlib/loadlib.h"
#include "libmpq/mpq.h"
+
#include <string.h>
-#include <ctype.h>
+#include <string>
#include <vector>
-#include <iostream>
#include <deque>
-using namespace std;
-
class MPQArchive
{
@@ -38,7 +36,7 @@ public:
MPQArchive(const char* filename);
~MPQArchive() { close(); }
- void GetFileListTo(vector<string>& filelist) {
+ void GetFileListTo(std::vector<std::string>& filelist) {
uint32_t filenum;
if(libmpq__file_number(mpq_a, "(listfile)", &filenum)) return;
libmpq__off_t size, transferred;
@@ -57,7 +55,7 @@ public:
while ((token != NULL) && (counter < size)) {
//cout << token << endl;
token[strlen(token) - 1] = 0;
- string s = token;
+ std::string s = token;
filelist.push_back(s);
counter += strlen(token) + 2;
token = strtok(NULL, seps);
@@ -78,9 +76,8 @@ class MPQFile
char *buffer;
libmpq__off_t pointer,size;
- // disable copying
- MPQFile(const MPQFile& /*f*/) {}
- void operator=(const MPQFile& /*f*/) {}
+ MPQFile(const MPQFile& /*f*/) = delete;
+ void operator=(const MPQFile& /*f*/) = delete;
public:
MPQFile(const char* filename); // filenames are not case sensitive
diff --git a/src/tools/vmap4_extractor/vmapexport.cpp b/src/tools/vmap4_extractor/vmapexport.cpp
index 7a12897563e..78d6e86358f 100644
--- a/src/tools/vmap4_extractor/vmapexport.cpp
+++ b/src/tools/vmap4_extractor/vmapexport.cpp
@@ -17,14 +17,15 @@
*/
#define _CRT_SECURE_NO_DEPRECATE
-#include <cstdio>
-#include <iostream>
-#include <vector>
-#include <list>
-#include <errno.h>
+
+#include "adtfile.h"
+#include "wdtfile.h"
+#include "dbcfile.h"
+#include "wmo.h"
+#include "mpq_libmpq04.h"
+#include "vmapexport.h"
#ifdef WIN32
- #include <Windows.h>
#include <sys/stat.h>
#include <direct.h>
#define mkdir _mkdir
@@ -32,23 +33,14 @@
#include <sys/stat.h>
#endif
+#include <cstdio>
+#include <iostream>
+#include <vector>
+#include <errno.h>
+
#undef min
#undef max
-//#pragma warning(disable : 4505)
-//#pragma comment(lib, "Winmm.lib")
-
-#include <map>
-
-//From Extractor
-#include "adtfile.h"
-#include "wdtfile.h"
-#include "dbcfile.h"
-#include "wmo.h"
-#include "mpq_libmpq04.h"
-
-#include "vmapexport.h"
-
//------------------------------------------------------------------------------
// Defines
@@ -129,12 +121,12 @@ bool ExtractWmo()
for (ArchiveSet::const_iterator ar_itr = gOpenArchives.begin(); ar_itr != gOpenArchives.end() && success; ++ar_itr)
{
- vector<string> filelist;
+ std::vector<std::string> filelist;
(*ar_itr)->GetFileListTo(filelist);
- for (vector<string>::iterator fname = filelist.begin(); fname != filelist.end() && success; ++fname)
+ for (std::vector<std::string>::iterator fname = filelist.begin(); fname != filelist.end() && success; ++fname)
{
- if (fname->find(".wmo") != string::npos)
+ if (fname->find(".wmo") != std::string::npos)
success = ExtractSingleWmo(*fname);
}
}
@@ -203,7 +195,7 @@ bool ExtractSingleWmo(std::string& fname)
sprintf(groupFileName, "%s_%03u.wmo", temp, i);
//printf("Trying to open groupfile %s\n",groupFileName);
- string s = groupFileName;
+ std::string s = groupFileName;
WMOGroup fgroup(s);
if(!fgroup.open())
{
@@ -305,7 +297,7 @@ bool fillArchiveNameVector(std::vector<std::string>& pArchiveNames)
printf("\nGame path: %s\n", input_path);
char path[512];
- string in_path(input_path);
+ std::string in_path(input_path);
std::vector<std::string> locales, searchLocales;
searchLocales.push_back("enGB");
@@ -345,10 +337,10 @@ bool fillArchiveNameVector(std::vector<std::string>& pArchiveNames)
}
// open expansion and common files
- pArchiveNames.push_back(input_path + string("common.MPQ"));
- pArchiveNames.push_back(input_path + string("common-2.MPQ"));
- pArchiveNames.push_back(input_path + string("expansion.MPQ"));
- pArchiveNames.push_back(input_path + string("lichking.MPQ"));
+ pArchiveNames.push_back(input_path + std::string("common.MPQ"));
+ pArchiveNames.push_back(input_path + std::string("common-2.MPQ"));
+ pArchiveNames.push_back(input_path + std::string("expansion.MPQ"));
+ pArchiveNames.push_back(input_path + std::string("lichking.MPQ"));
// now, scan for the patch levels in the core dir
printf("Scanning patch levels from data directory.\n");
diff --git a/src/tools/vmap4_extractor/wdtfile.cpp b/src/tools/vmap4_extractor/wdtfile.cpp
index 877f49ce371..4e0b7b97705 100644
--- a/src/tools/vmap4_extractor/wdtfile.cpp
+++ b/src/tools/vmap4_extractor/wdtfile.cpp
@@ -19,6 +19,7 @@
#include "vmapexport.h"
#include "wdtfile.h"
#include "adtfile.h"
+
#include <cstdio>
char * wdtGetPlainName(char * FileName)
@@ -30,7 +31,7 @@ char * wdtGetPlainName(char * FileName)
return FileName;
}
-WDTFile::WDTFile(char* file_name, char* file_name1) : WDT(file_name), gWmoInstansName(NULL), gnWMO(0)
+WDTFile::WDTFile(char* file_name, char* file_name1) : gWmoInstansName(NULL), gnWMO(0), WDT(file_name)
{
filename.append(file_name1,strlen(file_name1));
}
@@ -77,7 +78,7 @@ bool WDTFile::init(char* /*map_id*/, unsigned int mapID)
WDT.read(buf, size);
char *p=buf;
int q = 0;
- gWmoInstansName = new string[size];
+ gWmoInstansName = new std::string[size];
while (p < buf + size)
{
char* s=wdtGetPlainName(p);
diff --git a/src/tools/vmap4_extractor/wdtfile.h b/src/tools/vmap4_extractor/wdtfile.h
index 22702133b95..81e84b36d1e 100644
--- a/src/tools/vmap4_extractor/wdtfile.h
+++ b/src/tools/vmap4_extractor/wdtfile.h
@@ -20,26 +20,25 @@
#define WDTFILE_H
#include "mpq_libmpq04.h"
-#include "wmo.h"
#include <string>
-#include "stdlib.h"
class ADTFile;
class WDTFile
{
-private:
- MPQFile WDT;
- string filename;
public:
WDTFile(char* file_name, char* file_name1);
~WDTFile(void);
+
bool init(char* map_id, unsigned int mapID);
+ ADTFile* GetMap(int x, int z);
- string* gWmoInstansName;
+ std::string* gWmoInstansName;
int gnWMO;
- ADTFile* GetMap(int x, int z);
+private:
+ MPQFile WDT;
+ std::string filename;
};
#endif
diff --git a/src/tools/vmap4_extractor/wmo.cpp b/src/tools/vmap4_extractor/wmo.cpp
index f6f59bbc475..80dfbb97c5a 100644
--- a/src/tools/vmap4_extractor/wmo.cpp
+++ b/src/tools/vmap4_extractor/wmo.cpp
@@ -19,16 +19,14 @@
#include "vmapexport.h"
#include "wmo.h"
#include "vec3d.h"
+#include "mpq_libmpq04.h"
+
#include <cstdio>
#include <cstdlib>
#include <cassert>
-#include <map>
-#include <fstream>
#undef min
#undef max
-#include "mpq_libmpq04.h"
-using namespace std;
extern uint16 *LiqType;
WMORoot::WMORoot(std::string &filename)