mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-16 07:30:42 +01:00
Conflicts: dep/libmpq/CMakeLists.txt src/server/game/AI/EventAI/CreatureEventAI.cpp src/server/game/AI/EventAI/CreatureEventAI.h src/server/game/AI/EventAI/CreatureEventAIMgr.cpp src/server/game/AI/EventAI/CreatureEventAIMgr.h src/server/game/Entities/Creature/Creature.h src/server/game/Entities/Item/ItemPrototype.h src/server/game/Entities/Object/ObjectDefines.h src/server/game/Entities/Player/Player.cpp src/server/game/Handlers/ReferAFriendHandler.cpp src/server/game/Movement/Spline/MoveSplineInit.h src/server/game/World/World.h src/server/scripts/EasternKingdoms/ZulGurub/boss_arlokk.cpp src/server/scripts/EasternKingdoms/ZulGurub/boss_gahzranka.cpp src/server/scripts/EasternKingdoms/ZulGurub/boss_grilek.cpp src/server/scripts/EasternKingdoms/ZulGurub/boss_hakkar.cpp src/server/scripts/EasternKingdoms/ZulGurub/boss_hazzarah.cpp src/server/scripts/EasternKingdoms/ZulGurub/boss_jeklik.cpp src/server/scripts/EasternKingdoms/ZulGurub/boss_jindo.cpp src/server/scripts/EasternKingdoms/ZulGurub/boss_mandokir.cpp src/server/scripts/EasternKingdoms/ZulGurub/boss_marli.cpp src/server/scripts/EasternKingdoms/ZulGurub/boss_renataki.cpp src/server/scripts/EasternKingdoms/ZulGurub/boss_thekal.cpp src/server/scripts/EasternKingdoms/ZulGurub/boss_wushoolay.cpp src/server/scripts/EasternKingdoms/ZulGurub/instance_zulgurub.cpp src/server/scripts/EasternKingdoms/ZulGurub/zulgurub.h src/server/scripts/EasternKingdoms/boss_kruul.cpp src/server/scripts/OutdoorPvP/OutdoorPvPEP.cpp src/server/scripts/OutdoorPvP/OutdoorPvPEP.h src/server/shared/Database/Implementation/CharacterDatabase.cpp src/server/shared/Database/Implementation/CharacterDatabase.h src/server/shared/Database/Implementation/WorldDatabase.cpp
149 lines
4.5 KiB
C++
149 lines
4.5 KiB
C++
/*
|
|
* Copyright (C) 2008-2013 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 "BattlefieldMgr.h"
|
|
#include "Zones/BattlefieldWG.h"
|
|
#include "ObjectMgr.h"
|
|
#include "Player.h"
|
|
|
|
BattlefieldMgr::BattlefieldMgr()
|
|
{
|
|
m_UpdateTimer = 0;
|
|
//sLog->outDebug(LOG_FILTER_BATTLEFIELD, "Instantiating BattlefieldMgr");
|
|
}
|
|
|
|
BattlefieldMgr::~BattlefieldMgr()
|
|
{
|
|
//sLog->outDebug(LOG_FILTER_BATTLEFIELD, "Deleting BattlefieldMgr");
|
|
for (BattlefieldSet::iterator itr = m_BattlefieldSet.begin(); itr != m_BattlefieldSet.end(); ++itr)
|
|
delete *itr;
|
|
}
|
|
|
|
void BattlefieldMgr::InitBattlefield()
|
|
{
|
|
Battlefield* pBf = new BattlefieldWG;
|
|
// respawn, init variables
|
|
if (!pBf->SetupBattlefield())
|
|
{
|
|
sLog->outInfo(LOG_FILTER_GENERAL, "Battlefield : Wintergrasp init failed.");
|
|
delete pBf;
|
|
}
|
|
else
|
|
{
|
|
m_BattlefieldSet.push_back(pBf);
|
|
sLog->outInfo(LOG_FILTER_GENERAL, "Battlefield : Wintergrasp successfully initiated.");
|
|
}
|
|
|
|
/* For Cataclysm: Tol Barad
|
|
pBf = new BattlefieldTB;
|
|
// respawn, init variables
|
|
if(!pBf->SetupBattlefield())
|
|
{
|
|
sLog->outDebug(LOG_FILTER_BATTLEFIELD, "Battlefield : Tol Barad init failed.");
|
|
delete pBf;
|
|
}
|
|
else
|
|
{
|
|
m_BattlefieldSet.push_back(pBf);
|
|
sLog->outDebug(LOG_FILTER_BATTLEFIELD, "Battlefield : Tol Barad successfully initiated.");
|
|
} */
|
|
}
|
|
|
|
void BattlefieldMgr::AddZone(uint32 zoneid, Battlefield *handle)
|
|
{
|
|
m_BattlefieldMap[zoneid] = handle;
|
|
}
|
|
|
|
void BattlefieldMgr::HandlePlayerEnterZone(Player * player, uint32 zoneid)
|
|
{
|
|
BattlefieldMap::iterator itr = m_BattlefieldMap.find(zoneid);
|
|
if (itr == m_BattlefieldMap.end())
|
|
return;
|
|
|
|
if (itr->second->HasPlayer(player) || !itr->second->IsEnabled())
|
|
return;
|
|
|
|
itr->second->HandlePlayerEnterZone(player, zoneid);
|
|
sLog->outDebug(LOG_FILTER_BATTLEFIELD, "Player %u entered outdoorpvp id %u", player->GetGUIDLow(), itr->second->GetTypeId());
|
|
}
|
|
|
|
void BattlefieldMgr::HandlePlayerLeaveZone(Player * player, uint32 zoneid)
|
|
{
|
|
BattlefieldMap::iterator itr = m_BattlefieldMap.find(zoneid);
|
|
if (itr == m_BattlefieldMap.end())
|
|
return;
|
|
|
|
// teleport: remove once in removefromworld, once in updatezone
|
|
if (!itr->second->HasPlayer(player))
|
|
return;
|
|
itr->second->HandlePlayerLeaveZone(player, zoneid);
|
|
sLog->outDebug(LOG_FILTER_BATTLEFIELD, "Player %u left outdoorpvp id %u", player->GetGUIDLow(), itr->second->GetTypeId());
|
|
}
|
|
|
|
Battlefield *BattlefieldMgr::GetBattlefieldToZoneId(uint32 zoneid)
|
|
{
|
|
BattlefieldMap::iterator itr = m_BattlefieldMap.find(zoneid);
|
|
if (itr == m_BattlefieldMap.end())
|
|
{
|
|
// no handle for this zone, return
|
|
return NULL;
|
|
}
|
|
if (!itr->second->IsEnabled())
|
|
return NULL;
|
|
return itr->second;
|
|
}
|
|
|
|
Battlefield *BattlefieldMgr::GetBattlefieldByBattleId(uint32 battleid)
|
|
{
|
|
for (BattlefieldSet::iterator itr = m_BattlefieldSet.begin(); itr != m_BattlefieldSet.end(); ++itr)
|
|
{
|
|
if ((*itr)->GetBattleId() == battleid)
|
|
return (*itr);
|
|
}
|
|
return NULL;
|
|
}
|
|
|
|
Battlefield* BattlefieldMgr::GetBattlefieldByGUID(uint64 guid)
|
|
{
|
|
for (BattlefieldSet::iterator itr = m_BattlefieldSet.begin(); itr != m_BattlefieldSet.end(); ++itr)
|
|
if ((*itr)->GetGUID() == guid)
|
|
return (*itr);
|
|
|
|
return NULL;
|
|
}
|
|
|
|
void BattlefieldMgr::Update(uint32 diff)
|
|
{
|
|
m_UpdateTimer += diff;
|
|
if (m_UpdateTimer > BATTLEFIELD_OBJECTIVE_UPDATE_INTERVAL)
|
|
{
|
|
for (BattlefieldSet::iterator itr = m_BattlefieldSet.begin(); itr != m_BattlefieldSet.end(); ++itr)
|
|
if ((*itr)->IsEnabled())
|
|
(*itr)->Update(m_UpdateTimer);
|
|
m_UpdateTimer = 0;
|
|
}
|
|
}
|
|
|
|
ZoneScript *BattlefieldMgr::GetZoneScript(uint32 zoneId)
|
|
{
|
|
BattlefieldMap::iterator itr = m_BattlefieldMap.find(zoneId);
|
|
if (itr != m_BattlefieldMap.end())
|
|
return itr->second;
|
|
else
|
|
return NULL;
|
|
}
|