Battlefield: Make sBattlefieldMgr a pointer. By Subv.
This commit is contained in:
@@ -494,7 +494,7 @@ void Battlefield::SendUpdateWorldState(uint32 field, uint32 value)
|
|||||||
|
|
||||||
void Battlefield::RegisterZone(uint32 zoneId)
|
void Battlefield::RegisterZone(uint32 zoneId)
|
||||||
{
|
{
|
||||||
sBattlefieldMgr.AddZone(zoneId, this);
|
sBattlefieldMgr->AddZone(zoneId, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Battlefield::HideNpc(Creature *p_Creature)
|
void Battlefield::HideNpc(Creature *p_Creature)
|
||||||
|
|||||||
@@ -102,7 +102,7 @@ void WorldSession::HandleBfQueueInviteResponse(WorldPacket & recv_data)
|
|||||||
|
|
||||||
recv_data >> BattleId >> Accepted;
|
recv_data >> BattleId >> Accepted;
|
||||||
sLog->outError("HandleQueueInviteResponse: BattleID:%u Accepted:%u", BattleId, Accepted);
|
sLog->outError("HandleQueueInviteResponse: BattleID:%u Accepted:%u", BattleId, Accepted);
|
||||||
Battlefield* Bf = sBattlefieldMgr.GetBattlefieldByBattleId(BattleId);
|
Battlefield* Bf = sBattlefieldMgr->GetBattlefieldByBattleId(BattleId);
|
||||||
if (!Bf)
|
if (!Bf)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -120,7 +120,7 @@ void WorldSession::HandleBfEntryInviteResponse(WorldPacket & recv_data)
|
|||||||
|
|
||||||
recv_data >> BattleId >> Accepted;
|
recv_data >> BattleId >> Accepted;
|
||||||
sLog->outError("HandleBattlefieldInviteResponse: BattleID:%u Accepted:%u", BattleId, Accepted);
|
sLog->outError("HandleBattlefieldInviteResponse: BattleID:%u Accepted:%u", BattleId, Accepted);
|
||||||
Battlefield* Bf = sBattlefieldMgr.GetBattlefieldByBattleId(BattleId);
|
Battlefield* Bf = sBattlefieldMgr->GetBattlefieldByBattleId(BattleId);
|
||||||
if (!Bf)
|
if (!Bf)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -142,7 +142,7 @@ void WorldSession::HandleBfExitRequest(WorldPacket & recv_data)
|
|||||||
|
|
||||||
recv_data >> BattleId;
|
recv_data >> BattleId;
|
||||||
sLog->outError("HandleBfExitRequest: BattleID:%u ", BattleId);
|
sLog->outError("HandleBfExitRequest: BattleID:%u ", BattleId);
|
||||||
Battlefield* Bf = sBattlefieldMgr.GetBattlefieldByBattleId(BattleId);
|
Battlefield* Bf = sBattlefieldMgr->GetBattlefieldByBattleId(BattleId);
|
||||||
if (!Bf)
|
if (!Bf)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,79 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2008-2010 TrinityCore <http://www.trinitycore.org/>
|
||||||
|
* Copyright (C) 2005-2009 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/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef BATTLEFIELD_MGR_H_
|
||||||
|
#define BATTLEFIELD_MGR_H_
|
||||||
|
|
||||||
|
#include "Battlefield.h"
|
||||||
|
#include "ace/Singleton.h"
|
||||||
|
|
||||||
|
class Player;
|
||||||
|
class GameObject;
|
||||||
|
class Creature;
|
||||||
|
class ZoneScript;
|
||||||
|
struct GossipMenuItems;
|
||||||
|
|
||||||
|
// class to handle player enter / leave / areatrigger / GO use events
|
||||||
|
class BattlefieldMgr
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
// ctor
|
||||||
|
BattlefieldMgr();
|
||||||
|
// dtor
|
||||||
|
~BattlefieldMgr();
|
||||||
|
|
||||||
|
// create battlefield events
|
||||||
|
void InitBattlefield();
|
||||||
|
// called when a player enters an battlefield area
|
||||||
|
void HandlePlayerEnterZone(Player * plr, uint32 areaflag);
|
||||||
|
// called when player leaves an battlefield area
|
||||||
|
void HandlePlayerLeaveZone(Player * plr, uint32 areaflag);
|
||||||
|
// called when player resurrects
|
||||||
|
void HandlePlayerResurrects(Player * plr, uint32 areaflag);
|
||||||
|
// return assigned battlefield
|
||||||
|
Battlefield *GetBattlefieldToZoneId(uint32 zoneid);
|
||||||
|
Battlefield *GetBattlefieldByBattleId(uint32 battleid);
|
||||||
|
|
||||||
|
ZoneScript *GetZoneScript(uint32 zoneId);
|
||||||
|
|
||||||
|
void AddZone(uint32 zoneid, Battlefield * handle);
|
||||||
|
|
||||||
|
void Update(uint32 diff);
|
||||||
|
|
||||||
|
void HandleGossipOption(Player * player, uint64 guid, uint32 gossipid);
|
||||||
|
|
||||||
|
bool CanTalkTo(Player * player, Creature * creature, GossipMenuItems gso);
|
||||||
|
|
||||||
|
void HandleDropFlag(Player * plr, uint32 spellId);
|
||||||
|
|
||||||
|
typedef std::vector < Battlefield * >BattlefieldSet;
|
||||||
|
typedef std::map < uint32 /* zoneid */ , Battlefield * >BattlefieldMap;
|
||||||
|
private:
|
||||||
|
// contains all initiated battlefield events
|
||||||
|
// used when initing / cleaning up
|
||||||
|
BattlefieldSet m_BattlefieldSet;
|
||||||
|
// maps the zone ids to an battlefield event
|
||||||
|
// used in player event handling
|
||||||
|
BattlefieldMap m_BattlefieldMap;
|
||||||
|
// update interval
|
||||||
|
uint32 m_UpdateTimer;
|
||||||
|
};
|
||||||
|
|
||||||
|
#define sBattlefieldMgr ACE_Singleton<BattlefieldMgr, ACE_Null_Mutex>::instance()
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -2329,9 +2329,17 @@ void WorldObject::SetZoneScript()
|
|||||||
if (map->IsDungeon())
|
if (map->IsDungeon())
|
||||||
m_zoneScript = (ZoneScript*)((InstanceMap*)map)->GetInstanceScript();
|
m_zoneScript = (ZoneScript*)((InstanceMap*)map)->GetInstanceScript();
|
||||||
else if (!map->IsBattlegroundOrArena())
|
else if (!map->IsBattlegroundOrArena())
|
||||||
|
{
|
||||||
|
if (Battlefield* bf = sBattlefieldMgr->GetBattlefieldToZoneId(GetZoneId()))
|
||||||
m_zoneScript = sOutdoorPvPMgr->GetZoneScript(GetZoneId());
|
m_zoneScript = sOutdoorPvPMgr->GetZoneScript(GetZoneId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
m_zoneScript = bf;
|
||||||
|
else
|
||||||
|
m_zoneScript = sOutdoorPvPMgr->GetZoneScript(GetZoneId());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
TempSummon* WorldObject::SummonCreature(uint32 entry, const Position &pos, TempSummonType spwtype, uint32 duration, uint32 /*vehId*/) const
|
TempSummon* WorldObject::SummonCreature(uint32 entry, const Position &pos, TempSummonType spwtype, uint32 duration, uint32 /*vehId*/) const
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -2405,6 +2405,7 @@ void Player::RemoveFromWorld()
|
|||||||
StopCastingBindSight();
|
StopCastingBindSight();
|
||||||
UnsummonPetTemporaryIfAny();
|
UnsummonPetTemporaryIfAny();
|
||||||
sOutdoorPvPMgr->HandlePlayerLeaveZone(this, m_zoneUpdateId);
|
sOutdoorPvPMgr->HandlePlayerLeaveZone(this, m_zoneUpdateId);
|
||||||
|
sBattlefieldMgr->HandlePlayerLeaveZone(this, m_zoneUpdateId);
|
||||||
}
|
}
|
||||||
|
|
||||||
///- Do not add/remove the player from the object storage
|
///- Do not add/remove the player from the object storage
|
||||||
@@ -5492,8 +5493,13 @@ void Player::RepopAtGraveyard()
|
|||||||
// Special handle for battleground maps
|
// Special handle for battleground maps
|
||||||
if (Battleground* bg = GetBattleground())
|
if (Battleground* bg = GetBattleground())
|
||||||
ClosestGrave = bg->GetClosestGraveYard(this);
|
ClosestGrave = bg->GetClosestGraveYard(this);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (sBattlefieldMgr->GetBattlefieldToZoneId(GetZoneId()))
|
||||||
|
ClosestGrave = sBattlefieldMgr->GetBattlefieldToZoneId(GetZoneId())->GetClosestGraveYard(this);
|
||||||
else
|
else
|
||||||
ClosestGrave = sObjectMgr->GetClosestGraveYard(GetPositionX(), GetPositionY(), GetPositionZ(), GetMapId(), GetTeam());
|
ClosestGrave = sObjectMgr->GetClosestGraveYard(GetPositionX(), GetPositionY(), GetPositionZ(), GetMapId(), GetTeam());
|
||||||
|
}
|
||||||
|
|
||||||
// stop countdown until repop
|
// stop countdown until repop
|
||||||
m_deathTimer = 0;
|
m_deathTimer = 0;
|
||||||
@@ -7413,6 +7419,8 @@ void Player::UpdateZone(uint32 newZone, uint32 newArea)
|
|||||||
{
|
{
|
||||||
sOutdoorPvPMgr->HandlePlayerLeaveZone(this, m_zoneUpdateId);
|
sOutdoorPvPMgr->HandlePlayerLeaveZone(this, m_zoneUpdateId);
|
||||||
sOutdoorPvPMgr->HandlePlayerEnterZone(this, newZone);
|
sOutdoorPvPMgr->HandlePlayerEnterZone(this, newZone);
|
||||||
|
sBattlefieldMgr->HandlePlayerLeaveZone(this, m_zoneUpdateId);
|
||||||
|
sBattlefieldMgr->HandlePlayerEnterZone(this, newZone);
|
||||||
SendInitWorldStates(newZone, newArea); // only if really enters to new zone, not just area change, works strange...
|
SendInitWorldStates(newZone, newArea); // only if really enters to new zone, not just area change, works strange...
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -15675,9 +15675,14 @@ void Unit::Kill(Unit* victim, bool durabilityLoss)
|
|||||||
// outdoor pvp things, do these after setting the death state, else the player activity notify won't work... doh...
|
// outdoor pvp things, do these after setting the death state, else the player activity notify won't work... doh...
|
||||||
// handle player kill only if not suicide (spirit of redemption for example)
|
// handle player kill only if not suicide (spirit of redemption for example)
|
||||||
if (player && this != victim)
|
if (player && this != victim)
|
||||||
|
{
|
||||||
if (OutdoorPvP* pvp = player->GetOutdoorPvP())
|
if (OutdoorPvP* pvp = player->GetOutdoorPvP())
|
||||||
pvp->HandleKill(player, victim);
|
pvp->HandleKill(player, victim);
|
||||||
|
|
||||||
|
if (Battlefield* bf = sBattlefieldMgr->GetBattlefieldToZoneId(player->GetZoneId()))
|
||||||
|
bf->HandleKill(player, victim);
|
||||||
|
}
|
||||||
|
|
||||||
//if (victim->GetTypeId() == TYPEID_PLAYER)
|
//if (victim->GetTypeId() == TYPEID_PLAYER)
|
||||||
// if (OutdoorPvP* pvp = victim->ToPlayer()->GetOutdoorPvP())
|
// if (OutdoorPvP* pvp = victim->ToPlayer()->GetOutdoorPvP())
|
||||||
// pvp->HandlePlayerActivityChangedpVictim->ToPlayer();
|
// pvp->HandlePlayerActivityChangedpVictim->ToPlayer();
|
||||||
|
|||||||
@@ -1687,11 +1687,64 @@ void WorldSession::SendSetPhaseShift(uint32 PhaseShift)
|
|||||||
SendPacket(&data);
|
SendPacket(&data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Battlefield and Battleground
|
||||||
|
void WorldSession::HandleAreaSpiritHealerQueryOpcode(WorldPacket & recv_data)
|
||||||
|
{
|
||||||
|
sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: CMSG_AREA_SPIRIT_HEALER_QUERY");
|
||||||
|
|
||||||
|
Battleground* bg = _player->GetBattleground();
|
||||||
|
|
||||||
|
uint64 guid;
|
||||||
|
recv_data >> guid;
|
||||||
|
|
||||||
|
Creature* unit = GetPlayer()->GetMap()->GetCreature(guid);
|
||||||
|
if (!unit)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (!unit->isSpiritService()) // it's not spirit service
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (bg)
|
||||||
|
sBattlegroundMgr->SendAreaSpiritHealerQueryOpcode(_player, bg, guid);
|
||||||
|
|
||||||
|
if (Battlefield* bf = sBattlefieldMgr->GetBattlefieldToZoneId(_player->GetZoneId()))
|
||||||
|
bf->SendAreaSpiritHealerQueryOpcode(_player,guid);
|
||||||
|
}
|
||||||
|
|
||||||
|
void WorldSession::HandleAreaSpiritHealerQueueOpcode(WorldPacket & recv_data)
|
||||||
|
{
|
||||||
|
sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: CMSG_AREA_SPIRIT_HEALER_QUEUE");
|
||||||
|
|
||||||
|
Battleground* bg = _player->GetBattleground();
|
||||||
|
|
||||||
|
uint64 guid;
|
||||||
|
recv_data >> guid;
|
||||||
|
|
||||||
|
Creature* unit = GetPlayer()->GetMap()->GetCreature(guid);
|
||||||
|
if (!unit)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (!unit->isSpiritService()) // it's not spirit service
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (bg)
|
||||||
|
bg->AddPlayerToResurrectQueue(guid, _player->GetGUID());
|
||||||
|
|
||||||
|
if (Battlefield* bf = sBattlefieldMgr->GetBattlefieldToZoneId(_player->GetZoneId()))
|
||||||
|
bf->AddPlayerToResurrectQueue(guid, _player->GetGUID());
|
||||||
|
}
|
||||||
|
|
||||||
void WorldSession::HandleHearthAndResurrect(WorldPacket& /*recv_data*/)
|
void WorldSession::HandleHearthAndResurrect(WorldPacket& /*recv_data*/)
|
||||||
{
|
{
|
||||||
if (_player->isInFlight())
|
if (_player->isInFlight())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if(Battlefield* bf = sBattlefieldMgr->GetBattlefieldToZoneId(_player->GetZoneId()))
|
||||||
|
{
|
||||||
|
// bf->PlayerAskToLeave(_player); FIXME
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
AreaTableEntry const* atEntry = GetAreaEntryByAreaID(_player->GetAreaId());
|
AreaTableEntry const* atEntry = GetAreaEntryByAreaID(_player->GetAreaId());
|
||||||
if (!atEntry || !(atEntry->flags & AREA_FLAG_WINTERGRASP_2))
|
if (!atEntry || !(atEntry->flags & AREA_FLAG_WINTERGRASP_2))
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -5016,8 +5016,12 @@ void AuraEffect::HandleAuraDummy(AuraApplication const* aurApp, uint8 mode, bool
|
|||||||
case 2584: // Waiting to Resurrect
|
case 2584: // Waiting to Resurrect
|
||||||
// Waiting to resurrect spell cancel, we must remove player from resurrect queue
|
// Waiting to resurrect spell cancel, we must remove player from resurrect queue
|
||||||
if (target->GetTypeId() == TYPEID_PLAYER)
|
if (target->GetTypeId() == TYPEID_PLAYER)
|
||||||
|
{
|
||||||
if (Battleground* bg = target->ToPlayer()->GetBattleground())
|
if (Battleground* bg = target->ToPlayer()->GetBattleground())
|
||||||
bg->RemovePlayerFromResurrectQueue(target->GetGUID());
|
bg->RemovePlayerFromResurrectQueue(target->GetGUID());
|
||||||
|
if(Battlefield* bf = sBattlefieldMgr->GetBattlefieldToZoneId(target->GetZoneId()))
|
||||||
|
bf->RemovePlayerFromResurrectQueue(target->GetGUID());
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 36730: // Flame Strike
|
case 36730: // Flame Strike
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -5442,6 +5442,7 @@ SpellCastResult Spell::CheckCast(bool strict)
|
|||||||
// allow always ghost flight spells
|
// allow always ghost flight spells
|
||||||
if (m_originalCaster && m_originalCaster->GetTypeId() == TYPEID_PLAYER && m_originalCaster->isAlive())
|
if (m_originalCaster && m_originalCaster->GetTypeId() == TYPEID_PLAYER && m_originalCaster->isAlive())
|
||||||
{
|
{
|
||||||
|
Battlefield* Bf = sBattlefieldMgr->GetBattlefieldToZoneId(m_originalCaster->GetZoneId());
|
||||||
if (AreaTableEntry const* pArea = GetAreaEntryByAreaID(m_originalCaster->GetAreaId()))
|
if (AreaTableEntry const* pArea = GetAreaEntryByAreaID(m_originalCaster->GetAreaId()))
|
||||||
if (pArea->flags & AREA_FLAG_NO_FLY_ZONE)
|
if (pArea->flags & AREA_FLAG_NO_FLY_ZONE)
|
||||||
return (_triggeredCastFlags & TRIGGERED_DONT_REPORT_CAST_ERROR) ? SPELL_FAILED_DONT_REPORT : SPELL_FAILED_NOT_HERE;
|
return (_triggeredCastFlags & TRIGGERED_DONT_REPORT_CAST_ERROR) ? SPELL_FAILED_DONT_REPORT : SPELL_FAILED_NOT_HERE;
|
||||||
|
|||||||
@@ -1127,7 +1127,7 @@ bool SpellArea::IsFitToRequirements(Player const* player, uint32 newZone, uint32
|
|||||||
if (!player)
|
if (!player)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
Battlefield* Bf = sBattlefieldMgr.GetBattlefieldToZoneId(player->GetZoneId());
|
Battlefield* Bf = sBattlefieldMgr->GetBattlefieldToZoneId(player->GetZoneId());
|
||||||
if (!Bf || Bf->CanFlyIn() || (!player->HasAuraType(SPELL_AURA_MOD_INCREASE_MOUNTED_FLIGHT_SPEED) && !player->HasAuraType(SPELL_AURA_FLY)))
|
if (!Bf || Bf->CanFlyIn() || (!player->HasAuraType(SPELL_AURA_MOD_INCREASE_MOUNTED_FLIGHT_SPEED) && !player->HasAuraType(SPELL_AURA_FLY)))
|
||||||
return false;
|
return false;
|
||||||
break;
|
break;
|
||||||
@@ -1153,7 +1153,7 @@ bool SpellArea::IsFitToRequirements(Player const* player, uint32 newZone, uint32
|
|||||||
if (!player)
|
if (!player)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
Battlefield* bf = sBattlefieldMgr.GetBattlefieldToZoneId(player->GetZoneId());
|
Battlefield* bf = sBattlefieldMgr->GetBattlefieldToZoneId(player->GetZoneId());
|
||||||
|
|
||||||
if (!bf || bf->GetTypeId() != BATTLEFIELD_WG)
|
if (!bf || bf->GetTypeId() != BATTLEFIELD_WG)
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -1729,6 +1729,10 @@ void World::SetInitialWorldSettings()
|
|||||||
sLog->outInfo(LOG_FILTER_SERVER_LOADING, "Starting Outdoor PvP System");
|
sLog->outInfo(LOG_FILTER_SERVER_LOADING, "Starting Outdoor PvP System");
|
||||||
sOutdoorPvPMgr->InitOutdoorPvP();
|
sOutdoorPvPMgr->InitOutdoorPvP();
|
||||||
|
|
||||||
|
///- Initialize Battlefield
|
||||||
|
sLog->outString("Starting Battlefield System");
|
||||||
|
sBattlefieldMgr->InitBattlefield();
|
||||||
|
|
||||||
sLog->outInfo(LOG_FILTER_SERVER_LOADING, "Loading Transports...");
|
sLog->outInfo(LOG_FILTER_SERVER_LOADING, "Loading Transports...");
|
||||||
sMapMgr->LoadTransports();
|
sMapMgr->LoadTransports();
|
||||||
|
|
||||||
@@ -1993,6 +1997,9 @@ void World::Update(uint32 diff)
|
|||||||
sOutdoorPvPMgr->Update(diff);
|
sOutdoorPvPMgr->Update(diff);
|
||||||
RecordTimeDiff("UpdateOutdoorPvPMgr");
|
RecordTimeDiff("UpdateOutdoorPvPMgr");
|
||||||
|
|
||||||
|
sBattlefieldMgr->Update(diff);
|
||||||
|
RecordTimeDiff("BattlefieldMgr");
|
||||||
|
|
||||||
///- Delete all characters which have been deleted X days before
|
///- Delete all characters which have been deleted X days before
|
||||||
if (m_timers[WUPDATE_DELETECHARS].Passed())
|
if (m_timers[WUPDATE_DELETECHARS].Passed())
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -0,0 +1,180 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2008-2011 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/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* ScriptData
|
||||||
|
Name: bf_commandscript
|
||||||
|
%Complete: 100
|
||||||
|
Comment: All bf related commands
|
||||||
|
Category: commandscripts
|
||||||
|
EndScriptData */
|
||||||
|
|
||||||
|
#include "ScriptMgr.h"
|
||||||
|
#include "Chat.h"
|
||||||
|
#include "BattlefieldMgr.h"
|
||||||
|
|
||||||
|
class bf_commandscript : public CommandScript
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
bf_commandscript() : CommandScript("bf_commandscript") { }
|
||||||
|
|
||||||
|
ChatCommand* GetCommands() const
|
||||||
|
{
|
||||||
|
static ChatCommand battlefieldcommandTable[] =
|
||||||
|
{
|
||||||
|
{ "start", SEC_ADMINISTRATOR, false, &HandleBattlefieldStart, "", NULL },
|
||||||
|
{ "stop", SEC_ADMINISTRATOR, false, &HandleBattlefieldEnd, "", NULL },
|
||||||
|
{ "switch", SEC_ADMINISTRATOR, false, &HandleBattlefieldSwitch, "", NULL },
|
||||||
|
{ "timer", SEC_ADMINISTRATOR, false, &HandleBattlefieldTimer, "", NULL },
|
||||||
|
{ "enable", SEC_ADMINISTRATOR, false, &HandleBattlefieldEnable, "", NULL },
|
||||||
|
{ NULL, 0, false, NULL, "", NULL }
|
||||||
|
};
|
||||||
|
static ChatCommand commandTable[] =
|
||||||
|
{
|
||||||
|
{ "bf", SEC_ADMINISTRATOR, false, NULL, "", battlefieldcommandTable },
|
||||||
|
{ NULL, 0, false, NULL, "", NULL }
|
||||||
|
};
|
||||||
|
return commandTable;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool HandleBattlefieldStart(ChatHandler* handler, const char* args)
|
||||||
|
{
|
||||||
|
uint32 battleid = 0;
|
||||||
|
char* battleid_str = strtok((char*)args, " ");
|
||||||
|
if (!battleid_str)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
battleid = atoi(battleid_str);
|
||||||
|
|
||||||
|
Battlefield* bf = sBattlefieldMgr->GetBattlefieldByBattleId(battleid);
|
||||||
|
|
||||||
|
if (!bf)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
bf->StartBattle();
|
||||||
|
|
||||||
|
if (battleid == 1)
|
||||||
|
handler->SendGlobalGMSysMessage("Wintergrasp (Command start used)");
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool HandleBattlefieldEnd(ChatHandler* handler, const char* args)
|
||||||
|
{
|
||||||
|
uint32 battleid = 0;
|
||||||
|
char* battleid_str = strtok((char*)args, " ");
|
||||||
|
if (!battleid_str)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
battleid = atoi(battleid_str);
|
||||||
|
|
||||||
|
Battlefield* bf = sBattlefieldMgr->GetBattlefieldByBattleId(battleid);
|
||||||
|
|
||||||
|
if (!bf)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
bf->EndBattle(true);
|
||||||
|
|
||||||
|
if (battleid == 1)
|
||||||
|
handler->SendGlobalGMSysMessage("Wintergrasp (Command stop used)");
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool HandleBattlefieldEnable(ChatHandler* handler, const char* args)
|
||||||
|
{
|
||||||
|
uint32 battleid = 0;
|
||||||
|
char* battleid_str = strtok((char*)args, " ");
|
||||||
|
if (!battleid_str)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
battleid = atoi(battleid_str);
|
||||||
|
|
||||||
|
Battlefield* bf = sBattlefieldMgr->GetBattlefieldByBattleId(battleid);
|
||||||
|
|
||||||
|
if (!bf)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (bf->GetEnable())
|
||||||
|
{
|
||||||
|
bf->SetEnable(false);
|
||||||
|
if (battleid == 1)
|
||||||
|
handler->SendGlobalGMSysMessage("Wintergrasp is disabled");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
bf->SetEnable(true);
|
||||||
|
if (battleid == 1)
|
||||||
|
handler->SendGlobalGMSysMessage("Wintergrasp is enabled");
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool HandleBattlefieldSwitch(ChatHandler* handler, const char* args)
|
||||||
|
{
|
||||||
|
uint32 battleid = 0;
|
||||||
|
char* battleid_str = strtok((char*)args, " ");
|
||||||
|
if (!battleid_str)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
battleid = atoi(battleid_str);
|
||||||
|
|
||||||
|
Battlefield* bf = sBattlefieldMgr->GetBattlefieldByBattleId(battleid);
|
||||||
|
|
||||||
|
if (!bf)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
bf->EndBattle(false);
|
||||||
|
if (battleid == 1)
|
||||||
|
handler->SendGlobalGMSysMessage("Wintergrasp (Command switch used)");
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool HandleBattlefieldTimer(ChatHandler* handler, const char* args)
|
||||||
|
{
|
||||||
|
uint32 battleid = 0;
|
||||||
|
uint32 time = 0;
|
||||||
|
char* battleid_str = strtok((char*)args, " ");
|
||||||
|
if (!battleid_str)
|
||||||
|
return false;
|
||||||
|
char* time_str = strtok(NULL, " ");
|
||||||
|
if (!time_str)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
battleid = atoi(battleid_str);
|
||||||
|
|
||||||
|
time = atoi(time_str);
|
||||||
|
|
||||||
|
Battlefield* bf = sBattlefieldMgr->GetBattlefieldByBattleId(battleid);
|
||||||
|
|
||||||
|
if (!bf)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
bf->SetTimer(time * IN_MILLISECONDS);
|
||||||
|
bf->SendInitWorldStatesToAll();
|
||||||
|
if (battleid == 1)
|
||||||
|
handler->SendGlobalGMSysMessage("Wintergrasp (Command timer used)");
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
void AddSC_bf_commandscript()
|
||||||
|
{
|
||||||
|
new bf_commandscript();
|
||||||
|
}
|
||||||
@@ -63,7 +63,7 @@ class npc_wg_demolisher_engineer : public CreatureScript
|
|||||||
if (pCreature->isQuestGiver())
|
if (pCreature->isQuestGiver())
|
||||||
pPlayer->PrepareQuestMenu(pCreature->GetGUID());
|
pPlayer->PrepareQuestMenu(pCreature->GetGUID());
|
||||||
|
|
||||||
Battlefield* BfWG = sBattlefieldMgr.GetBattlefieldByBattleId(1);
|
Battlefield* BfWG = sBattlefieldMgr->GetBattlefieldByBattleId(1);
|
||||||
|
|
||||||
if (!BfWG)
|
if (!BfWG)
|
||||||
return true;
|
return true;
|
||||||
@@ -91,7 +91,7 @@ class npc_wg_demolisher_engineer : public CreatureScript
|
|||||||
{
|
{
|
||||||
pPlayer->CLOSE_GOSSIP_MENU();
|
pPlayer->CLOSE_GOSSIP_MENU();
|
||||||
|
|
||||||
Battlefield* BfWG = sBattlefieldMgr.GetBattlefieldByBattleId(1);
|
Battlefield* BfWG = sBattlefieldMgr->GetBattlefieldByBattleId(1);
|
||||||
|
|
||||||
if (!BfWG)
|
if (!BfWG)
|
||||||
return true;
|
return true;
|
||||||
@@ -132,7 +132,7 @@ class npc_wg_spirit_guide : public CreatureScript
|
|||||||
if (pCreature->isQuestGiver())
|
if (pCreature->isQuestGiver())
|
||||||
pPlayer->PrepareQuestMenu(pCreature->GetGUID());
|
pPlayer->PrepareQuestMenu(pCreature->GetGUID());
|
||||||
|
|
||||||
Battlefield* BfWG = sBattlefieldMgr.GetBattlefieldByBattleId(BATTLEFIELD_BATTLEID_WG);
|
Battlefield* BfWG = sBattlefieldMgr->GetBattlefieldByBattleId(BATTLEFIELD_BATTLEID_WG);
|
||||||
if (BfWG)
|
if (BfWG)
|
||||||
{
|
{
|
||||||
GraveYardVect gy = BfWG->GetGraveYardVect();
|
GraveYardVect gy = BfWG->GetGraveYardVect();
|
||||||
@@ -154,7 +154,7 @@ class npc_wg_spirit_guide : public CreatureScript
|
|||||||
{
|
{
|
||||||
pPlayer->CLOSE_GOSSIP_MENU();
|
pPlayer->CLOSE_GOSSIP_MENU();
|
||||||
|
|
||||||
Battlefield* BfWG = sBattlefieldMgr.GetBattlefieldByBattleId(BATTLEFIELD_BATTLEID_WG);
|
Battlefield* BfWG = sBattlefieldMgr->GetBattlefieldByBattleId(BATTLEFIELD_BATTLEID_WG);
|
||||||
if (BfWG)
|
if (BfWG)
|
||||||
{
|
{
|
||||||
GraveYardVect gy = BfWG->GetGraveYardVect();
|
GraveYardVect gy = BfWG->GetGraveYardVect();
|
||||||
@@ -183,7 +183,7 @@ class npc_wg_queue : public CreatureScript
|
|||||||
if (pCreature->isQuestGiver())
|
if (pCreature->isQuestGiver())
|
||||||
pPlayer->PrepareQuestMenu(pCreature->GetGUID());
|
pPlayer->PrepareQuestMenu(pCreature->GetGUID());
|
||||||
|
|
||||||
Battlefield* BfWG = sBattlefieldMgr.GetBattlefieldByBattleId(BATTLEFIELD_BATTLEID_WG);
|
Battlefield* BfWG = sBattlefieldMgr->GetBattlefieldByBattleId(BATTLEFIELD_BATTLEID_WG);
|
||||||
if (BfWG)
|
if (BfWG)
|
||||||
{
|
{
|
||||||
|
|
||||||
@@ -214,7 +214,7 @@ class npc_wg_queue : public CreatureScript
|
|||||||
{
|
{
|
||||||
pPlayer->CLOSE_GOSSIP_MENU();
|
pPlayer->CLOSE_GOSSIP_MENU();
|
||||||
|
|
||||||
Battlefield* BfWG = sBattlefieldMgr.GetBattlefieldByBattleId(BATTLEFIELD_BATTLEID_WG);
|
Battlefield* BfWG = sBattlefieldMgr->GetBattlefieldByBattleId(BATTLEFIELD_BATTLEID_WG);
|
||||||
if (BfWG)
|
if (BfWG)
|
||||||
{
|
{
|
||||||
if (BfWG->IsWarTime())
|
if (BfWG->IsWarTime())
|
||||||
@@ -302,7 +302,7 @@ class npc_wg_quest_giver : public CreatureScript
|
|||||||
if (pCreature->isQuestGiver())
|
if (pCreature->isQuestGiver())
|
||||||
pPlayer->PrepareQuestMenu(pCreature->GetGUID());
|
pPlayer->PrepareQuestMenu(pCreature->GetGUID());
|
||||||
|
|
||||||
Battlefield* BfWG = sBattlefieldMgr.GetBattlefieldByBattleId(BATTLEFIELD_BATTLEID_WG);
|
Battlefield* BfWG = sBattlefieldMgr->GetBattlefieldByBattleId(BATTLEFIELD_BATTLEID_WG);
|
||||||
if (BfWG)
|
if (BfWG)
|
||||||
{
|
{
|
||||||
if (pCreature->isQuestGiver())
|
if (pCreature->isQuestGiver())
|
||||||
|
|||||||
Reference in New Issue
Block a user