Core/Battlefields: Refactor Battlefield creation to be linked to host map creation instead of having globally accessible objects

Port From (https://github.com/TrinityCore/TrinityCore/commit/073a036d84365dae60a70064eb67e68f0447bd72)
This commit is contained in:
hondacrx
2022-07-19 20:50:34 -04:00
parent ce16bc0611
commit a27a353d38
16 changed files with 113 additions and 78 deletions
@@ -27,7 +27,7 @@ namespace Game.Chat
[Command("enable", RBACPermissions.CommandBfEnable)]
static bool HandleBattlefieldEnable(CommandHandler handler, uint battleId)
{
BattleField bf = Global.BattleFieldMgr.GetBattlefieldByBattleId(battleId);
BattleField bf = Global.BattleFieldMgr.GetBattlefieldByBattleId(handler.GetPlayer().GetMap(), battleId);
if (bf == null)
return false;
@@ -50,7 +50,7 @@ namespace Game.Chat
[Command("start", RBACPermissions.CommandBfStart)]
static bool HandleBattlefieldStart(CommandHandler handler, uint battleId)
{
BattleField bf = Global.BattleFieldMgr.GetBattlefieldByBattleId(battleId);
BattleField bf = Global.BattleFieldMgr.GetBattlefieldByBattleId(handler.GetPlayer().GetMap(), battleId);
if (bf == null)
return false;
@@ -65,7 +65,7 @@ namespace Game.Chat
[Command("stop", RBACPermissions.CommandBfStop)]
static bool HandleBattlefieldEnd(CommandHandler handler, uint battleId)
{
BattleField bf = Global.BattleFieldMgr.GetBattlefieldByBattleId(battleId);
BattleField bf = Global.BattleFieldMgr.GetBattlefieldByBattleId(handler.GetPlayer().GetMap(), battleId);
if (bf == null)
return false;
@@ -80,7 +80,7 @@ namespace Game.Chat
[Command("switch", RBACPermissions.CommandBfSwitch)]
static bool HandleBattlefieldSwitch(CommandHandler handler, uint battleId)
{
BattleField bf = Global.BattleFieldMgr.GetBattlefieldByBattleId(battleId);
BattleField bf = Global.BattleFieldMgr.GetBattlefieldByBattleId(handler.GetPlayer().GetMap(), battleId);
if (bf == null)
return false;
@@ -94,7 +94,7 @@ namespace Game.Chat
[Command("timer", RBACPermissions.CommandBfTimer)]
static bool HandleBattlefieldTimer(CommandHandler handler, uint battleId, uint time)
{
BattleField bf = Global.BattleFieldMgr.GetBattlefieldByBattleId(battleId);
BattleField bf = Global.BattleFieldMgr.GetBattlefieldByBattleId(handler.GetPlayer().GetMap(), battleId);
if (bf == null)
return false;
+1 -1
View File
@@ -691,7 +691,7 @@ namespace Game.Chat
nearestLoc = bg.GetClosestGraveYard(player);
else
{
BattleField bf = Global.BattleFieldMgr.GetBattlefieldToZoneId(player.GetZoneId());
BattleField bf = Global.BattleFieldMgr.GetBattlefieldToZoneId(player.GetMap(), player.GetZoneId());
if (bf != null)
nearestLoc = bf.GetClosestGraveYard(player);
else