--HG-- branch : trunk rename : src/server/game/BattleGrounds/ArenaTeam.cpp => src/server/game/Battlegrounds/ArenaTeam.cpp rename : src/server/game/BattleGrounds/ArenaTeam.h => src/server/game/Battlegrounds/ArenaTeam.h rename : src/server/game/BattleGrounds/BattleGround.cpp => src/server/game/Battlegrounds/Battleground.cpp rename : src/server/game/BattleGrounds/BattleGround.h => src/server/game/Battlegrounds/Battleground.h rename : src/server/game/BattleGrounds/Zones/BattleGroundAA.cpp => src/server/game/Battlegrounds/Zones/BattlegroundAA.cpp rename : src/server/game/BattleGrounds/Zones/BattleGroundAA.h => src/server/game/Battlegrounds/Zones/BattlegroundAA.h rename : src/server/game/BattleGrounds/Zones/BattleGroundAB.cpp => src/server/game/Battlegrounds/Zones/BattlegroundAB.cpp rename : src/server/game/BattleGrounds/Zones/BattleGroundAB.h => src/server/game/Battlegrounds/Zones/BattlegroundAB.h rename : src/server/game/BattleGrounds/Zones/BattleGroundAV.cpp => src/server/game/Battlegrounds/Zones/BattlegroundAV.cpp rename : src/server/game/BattleGrounds/Zones/BattleGroundAV.h => src/server/game/Battlegrounds/Zones/BattlegroundAV.h rename : src/server/game/BattleGrounds/Zones/BattleGroundBE.cpp => src/server/game/Battlegrounds/Zones/BattlegroundBE.cpp rename : src/server/game/BattleGrounds/Zones/BattleGroundBE.h => src/server/game/Battlegrounds/Zones/BattlegroundBE.h rename : src/server/game/BattleGrounds/Zones/BattleGroundDS.cpp => src/server/game/Battlegrounds/Zones/BattlegroundDS.cpp rename : src/server/game/BattleGrounds/Zones/BattleGroundDS.h => src/server/game/Battlegrounds/Zones/BattlegroundDS.h rename : src/server/game/BattleGrounds/Zones/BattleGroundEY.cpp => src/server/game/Battlegrounds/Zones/BattlegroundEY.cpp rename : src/server/game/BattleGrounds/Zones/BattleGroundEY.h => src/server/game/Battlegrounds/Zones/BattlegroundEY.h rename : src/server/game/BattleGrounds/Zones/BattleGroundIC.cpp => src/server/game/Battlegrounds/Zones/BattlegroundIC.cpp rename : src/server/game/BattleGrounds/Zones/BattleGroundIC.h => src/server/game/Battlegrounds/Zones/BattlegroundIC.h rename : src/server/game/BattleGrounds/Zones/BattleGroundNA.cpp => src/server/game/Battlegrounds/Zones/BattlegroundNA.cpp rename : src/server/game/BattleGrounds/Zones/BattleGroundNA.h => src/server/game/Battlegrounds/Zones/BattlegroundNA.h rename : src/server/game/BattleGrounds/Zones/BattleGroundRB.cpp => src/server/game/Battlegrounds/Zones/BattlegroundRB.cpp rename : src/server/game/BattleGrounds/Zones/BattleGroundRB.h => src/server/game/Battlegrounds/Zones/BattlegroundRB.h rename : src/server/game/BattleGrounds/Zones/BattleGroundRL.cpp => src/server/game/Battlegrounds/Zones/BattlegroundRL.cpp rename : src/server/game/BattleGrounds/Zones/BattleGroundRL.h => src/server/game/Battlegrounds/Zones/BattlegroundRL.h rename : src/server/game/BattleGrounds/Zones/BattleGroundRV.cpp => src/server/game/Battlegrounds/Zones/BattlegroundRV.cpp rename : src/server/game/BattleGrounds/Zones/BattleGroundRV.h => src/server/game/Battlegrounds/Zones/BattlegroundRV.h rename : src/server/game/BattleGrounds/Zones/BattleGroundSA.cpp => src/server/game/Battlegrounds/Zones/BattlegroundSA.cpp rename : src/server/game/BattleGrounds/Zones/BattleGroundSA.h => src/server/game/Battlegrounds/Zones/BattlegroundSA.h rename : src/server/game/BattleGrounds/Zones/BattleGroundWS.cpp => src/server/game/Battlegrounds/Zones/BattlegroundWS.cpp rename : src/server/game/BattleGrounds/Zones/BattleGroundWS.h => src/server/game/Battlegrounds/Zones/BattlegroundWS.h
136 lines
6.7 KiB
C++
136 lines
6.7 KiB
C++
/*
|
|
* Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/>
|
|
*
|
|
* Copyright (C) 2008-2010 Trinity <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, write to the Free Software
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
*/
|
|
|
|
#ifndef __BATTLEGROUNDMGR_H
|
|
#define __BATTLEGROUNDMGR_H
|
|
|
|
#include "Common.h"
|
|
#include "DBCEnums.h"
|
|
#include "BattleGround.h"
|
|
#include "BattleGroundQueue.h"
|
|
#include "ace/Singleton.h"
|
|
|
|
typedef std::map<uint32, BattleGround*> BattleGroundSet;
|
|
|
|
typedef UNORDERED_MAP<uint32, BattleGroundTypeId> BattleMastersMap;
|
|
|
|
#define BATTLEGROUND_ARENA_POINT_DISTRIBUTION_DAY 86400 // seconds in a day
|
|
#define WS_ARENA_DISTRIBUTION_TIME 20001 // Custom worldstate
|
|
|
|
class BattleGroundMgr
|
|
{
|
|
/// Todo: Thread safety?
|
|
/* Construction */
|
|
friend class ACE_Singleton<BattleGroundMgr, ACE_Null_Mutex>;
|
|
BattleGroundMgr();
|
|
|
|
public:
|
|
~BattleGroundMgr();
|
|
void Update(uint32 diff);
|
|
|
|
/* Packet Building */
|
|
void BuildPlayerJoinedBattleGroundPacket(WorldPacket *data, Player *plr);
|
|
void BuildPlayerLeftBattleGroundPacket(WorldPacket *data, const uint64& guid);
|
|
void BuildBattleGroundListPacket(WorldPacket *data, const uint64& guid, Player *plr, BattleGroundTypeId bgTypeId, uint8 fromWhere);
|
|
void BuildGroupJoinedBattlegroundPacket(WorldPacket *data, GroupJoinBattlegroundResult result);
|
|
void BuildUpdateWorldStatePacket(WorldPacket *data, uint32 field, uint32 value);
|
|
void BuildPvpLogDataPacket(WorldPacket *data, BattleGround *bg);
|
|
void BuildBattleGroundStatusPacket(WorldPacket *data, BattleGround *bg, uint8 QueueSlot, uint8 StatusID, uint32 Time1, uint32 Time2, uint8 arenatype);
|
|
void BuildPlaySoundPacket(WorldPacket *data, uint32 soundid);
|
|
void SendAreaSpiritHealerQueryOpcode(Player *pl, BattleGround *bg, const uint64& guid);
|
|
|
|
/* Battlegrounds */
|
|
BattleGround* GetBattleGroundThroughClientInstance(uint32 instanceId, BattleGroundTypeId bgTypeId);
|
|
BattleGround* GetBattleGround(uint32 InstanceID, BattleGroundTypeId bgTypeId); //there must be uint32 because MAX_BATTLEGROUND_TYPE_ID means unknown
|
|
|
|
BattleGround* GetBattleGroundTemplate(BattleGroundTypeId bgTypeId);
|
|
BattleGround* CreateNewBattleGround(BattleGroundTypeId bgTypeId, PvPDifficultyEntry const* bracketEntry, uint8 arenaType, bool isRated);
|
|
|
|
uint32 CreateBattleGround(BattleGroundTypeId bgTypeId, bool IsArena, uint32 MinPlayersPerTeam, uint32 MaxPlayersPerTeam, uint32 LevelMin, uint32 LevelMax, char* BattleGroundName, uint32 MapID, float Team1StartLocX, float Team1StartLocY, float Team1StartLocZ, float Team1StartLocO, float Team2StartLocX, float Team2StartLocY, float Team2StartLocZ, float Team2StartLocO, uint32 scriptId);
|
|
|
|
void AddBattleGround(uint32 InstanceID, BattleGroundTypeId bgTypeId, BattleGround* BG) { m_BattleGrounds[bgTypeId][InstanceID] = BG; };
|
|
void RemoveBattleGround(uint32 instanceID, BattleGroundTypeId bgTypeId) { m_BattleGrounds[bgTypeId].erase(instanceID); }
|
|
uint32 CreateClientVisibleInstanceId(BattleGroundTypeId bgTypeId, BattleGroundBracketId bracket_id);
|
|
|
|
void CreateInitialBattleGrounds();
|
|
void DeleteAllBattleGrounds();
|
|
|
|
void SendToBattleGround(Player *pl, uint32 InstanceID, BattleGroundTypeId bgTypeId);
|
|
|
|
/* Battleground queues */
|
|
//these queues are instantiated when creating BattlegroundMrg
|
|
BattleGroundQueue m_BattleGroundQueues[MAX_BATTLEGROUND_QUEUE_TYPES]; // public, because we need to access them in BG handler code
|
|
|
|
BGFreeSlotQueueType BGFreeSlotQueue[MAX_BATTLEGROUND_TYPE_ID];
|
|
|
|
void ScheduleQueueUpdate(uint32 arenaRating, uint8 arenaType, BattleGroundQueueTypeId bgQueueTypeId, BattleGroundTypeId bgTypeId, BattleGroundBracketId bracket_id);
|
|
uint32 GetMaxRatingDifference() const;
|
|
uint32 GetRatingDiscardTimer() const;
|
|
uint32 GetPrematureFinishTime() const;
|
|
|
|
void InitAutomaticArenaPointDistribution();
|
|
void DistributeArenaPoints();
|
|
void ToggleArenaTesting();
|
|
void ToggleTesting();
|
|
|
|
void SetHolidayWeekends(uint32 mask);
|
|
void LoadBattleMastersEntry();
|
|
BattleGroundTypeId GetBattleMasterBG(uint32 entry) const
|
|
{
|
|
BattleMastersMap::const_iterator itr = mBattleMastersMap.find(entry);
|
|
if (itr != mBattleMastersMap.end())
|
|
return itr->second;
|
|
return BATTLEGROUND_WS;
|
|
}
|
|
|
|
bool isArenaTesting() const { return m_ArenaTesting; }
|
|
bool isTesting() const { return m_Testing; }
|
|
|
|
static bool IsArenaType(BattleGroundTypeId bgTypeId);
|
|
static bool IsBattleGroundType(BattleGroundTypeId bgTypeId) { return !BattleGroundMgr::IsArenaType(bgTypeId); }
|
|
static BattleGroundQueueTypeId BGQueueTypeId(BattleGroundTypeId bgTypeId, uint8 arenaType);
|
|
static BattleGroundTypeId BGTemplateId(BattleGroundQueueTypeId bgQueueTypeId);
|
|
static uint8 BGArenaType(BattleGroundQueueTypeId bgQueueTypeId);
|
|
|
|
static HolidayIds BGTypeToWeekendHolidayId(BattleGroundTypeId bgTypeId);
|
|
static BattleGroundTypeId WeekendHolidayIdToBGType(HolidayIds holiday);
|
|
static bool IsBGWeekend(BattleGroundTypeId bgTypeId);
|
|
void DoCompleteAchievement(uint32 achievement, Player * player = NULL);
|
|
private:
|
|
BattleMastersMap mBattleMastersMap;
|
|
|
|
typedef std::map<BattleGroundTypeId, uint8> BattleGroundSelectionWeightMap; // TypeId and its selectionWeight
|
|
/* Battlegrounds */
|
|
BattleGroundSet m_BattleGrounds[MAX_BATTLEGROUND_TYPE_ID];
|
|
BattleGroundSelectionWeightMap m_ArenaSelectionWeights;
|
|
BattleGroundSelectionWeightMap m_BGSelectionWeights;
|
|
std::vector<uint64> m_QueueUpdateScheduler;
|
|
std::set<uint32> m_ClientBattleGroundIds[MAX_BATTLEGROUND_TYPE_ID][MAX_BATTLEGROUND_BRACKETS]; //the instanceids just visible for the client
|
|
uint32 m_NextRatingDiscardUpdate;
|
|
time_t m_NextAutoDistributionTime;
|
|
uint32 m_AutoDistributionTimeChecker;
|
|
bool m_ArenaTesting;
|
|
bool m_Testing;
|
|
};
|
|
|
|
#define sBattleGroundMgr (*ACE_Singleton<BattleGroundMgr, ACE_Null_Mutex>::instance())
|
|
#endif
|
|
|