Files
TCPlayerbotCore/src/server/game/Battlegrounds/BattlegroundMgr.h
T

153 lines
6.6 KiB
C++
Raw Normal View History

2010-10-07 15:54:07 +02:00
/*
2011-01-01 15:01:13 +01:00
* Copyright (C) 2008-2011 TrinityCore <http://www.trinitycore.org/>
2010-10-07 15:54:07 +02:00
* 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/>.
2008-10-02 16:23:55 -05:00
*/
2009-10-17 15:51:44 -07:00
2008-10-02 16:23:55 -05:00
#ifndef __BATTLEGROUNDMGR_H
#define __BATTLEGROUNDMGR_H
2009-10-17 15:51:44 -07:00
#include "Common.h"
#include "DBCEnums.h"
2010-08-08 04:37:24 +02:00
#include "Battleground.h"
#include "BattlegroundQueue.h"
#include <ace/Singleton.h>
2009-10-17 15:51:44 -07:00
2010-08-08 04:37:24 +02:00
typedef std::map<uint32, Battleground*> BattlegroundSet;
2009-10-17 15:51:44 -07:00
2010-08-08 04:37:24 +02:00
typedef UNORDERED_MAP<uint32, BattlegroundTypeId> BattleMastersMap;
2009-10-17 15:51:44 -07:00
#define BATTLEGROUND_ARENA_POINT_DISTRIBUTION_DAY 86400 // seconds in a day
2010-03-26 16:48:33 +01:00
#define WS_ARENA_DISTRIBUTION_TIME 20001 // Custom worldstate
2009-10-17 15:51:44 -07:00
struct CreateBattlegroundData
{
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;
};
2010-08-08 04:37:24 +02:00
class BattlegroundMgr
2008-10-02 16:23:55 -05:00
{
2010-08-08 04:37:24 +02:00
friend class ACE_Singleton<BattlegroundMgr, ACE_Null_Mutex>;
private:
BattlegroundMgr();
2010-08-08 04:37:24 +02:00
~BattlegroundMgr();
public:
2009-01-21 16:18:57 -06:00
void Update(uint32 diff);
2009-10-17 15:51:44 -07:00
2008-10-02 16:23:55 -05:00
/* Packet Building */
2010-08-08 04:37:24 +02:00
void BuildPlayerJoinedBattlegroundPacket(WorldPacket *data, Player *plr);
void BuildPlayerLeftBattlegroundPacket(WorldPacket *data, uint64 guid);
void BuildBattlegroundListPacket(WorldPacket *data, uint64 guid, Player *plr, BattlegroundTypeId bgTypeId, uint8 fromWhere);
void BuildGroupJoinedBattlegroundPacket(WorldPacket *data, GroupJoinBattlegroundResult result);
2008-10-02 16:23:55 -05:00
void BuildUpdateWorldStatePacket(WorldPacket *data, uint32 field, uint32 value);
2010-08-08 04:37:24 +02:00
void BuildPvpLogDataPacket(WorldPacket *data, Battleground *bg);
void BuildBattlegroundStatusPacket(WorldPacket *data, Battleground *bg, uint8 QueueSlot, uint8 StatusID, uint32 Time1, uint32 Time2, uint8 arenatype, uint8 uiFrame = 1);
2008-10-02 16:23:55 -05:00
void BuildPlaySoundPacket(WorldPacket *data, uint32 soundid);
void SendAreaSpiritHealerQueryOpcode(Player *pl, Battleground *bg, uint64 guid);
2009-10-17 15:51:44 -07:00
2008-10-02 16:23:55 -05:00
/* Battlegrounds */
2010-08-08 04:37:24 +02:00
Battleground* GetBattlegroundThroughClientInstance(uint32 instanceId, BattlegroundTypeId bgTypeId);
Battleground* GetBattleground(uint32 InstanceID, BattlegroundTypeId bgTypeId); //there must be uint32 because MAX_BATTLEGROUND_TYPE_ID means unknown
2009-10-17 15:51:44 -07:00
2010-08-08 04:37:24 +02:00
Battleground* GetBattlegroundTemplate(BattlegroundTypeId bgTypeId);
Battleground* CreateNewBattleground(BattlegroundTypeId bgTypeId, PvPDifficultyEntry const* bracketEntry, uint8 arenaType, bool isRated);
2009-10-17 15:51:44 -07:00
uint32 CreateBattleground(CreateBattlegroundData& data);
2009-10-17 15:51:44 -07:00
2010-08-08 04:37:24 +02:00
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);
2009-10-17 15:51:44 -07:00
2010-08-08 04:37:24 +02:00
void CreateInitialBattlegrounds();
void DeleteAllBattlegrounds();
2009-10-17 15:51:44 -07:00
2010-08-08 04:37:24 +02:00
void SendToBattleground(Player *pl, uint32 InstanceID, BattlegroundTypeId bgTypeId);
2009-10-17 15:51:44 -07:00
2008-10-02 16:23:55 -05:00
/* Battleground queues */
//these queues are instantiated when creating BattlegroundMrg
2010-08-08 04:37:24 +02:00
BattlegroundQueue m_BattlegroundQueues[MAX_BATTLEGROUND_QUEUE_TYPES]; // public, because we need to access them in BG handler code
2009-10-17 15:51:44 -07:00
BGFreeSlotQueueType BGFreeSlotQueue[MAX_BATTLEGROUND_TYPE_ID];
2009-10-17 15:51:44 -07:00
void ScheduleQueueUpdate(uint32 arenaMatchmakerRating, uint8 arenaType, BattlegroundQueueTypeId bgQueueTypeId, BattlegroundTypeId bgTypeId, BattlegroundBracketId bracket_id);
uint32 GetMaxRatingDifference() const;
uint32 GetRatingDiscardTimer() const;
uint32 GetPrematureFinishTime() const;
2009-10-17 15:51:44 -07:00
2008-10-05 08:48:32 -05:00
void InitAutomaticArenaPointDistribution();
void ToggleArenaTesting();
void ToggleTesting();
2009-10-17 15:51:44 -07:00
void SetHolidayWeekends(uint32 mask);
void LoadBattleMastersEntry();
2010-08-08 04:37:24 +02:00
BattlegroundTypeId GetBattleMasterBG(uint32 entry) const
{
BattleMastersMap::const_iterator itr = mBattleMastersMap.find(entry);
if (itr != mBattleMastersMap.end())
return itr->second;
return BATTLEGROUND_WS;
}
2009-10-17 15:51:44 -07:00
2009-01-18 19:01:41 -06:00
bool isArenaTesting() const { return m_ArenaTesting; }
bool isTesting() const { return m_Testing; }
2009-10-17 15:51:44 -07:00
2010-08-08 04:37:24 +02:00
static bool IsArenaType(BattlegroundTypeId bgTypeId);
2011-08-30 23:09:39 +03:00
static bool IsBattlegroundType(BattlegroundTypeId bgTypeId) { return !IsArenaType(bgTypeId); }
2010-08-08 04:37:24 +02:00
static BattlegroundQueueTypeId BGQueueTypeId(BattlegroundTypeId bgTypeId, uint8 arenaType);
static BattlegroundTypeId BGTemplateId(BattlegroundQueueTypeId bgQueueTypeId);
static uint8 BGArenaType(BattlegroundQueueTypeId bgQueueTypeId);
2009-10-17 15:51:44 -07:00
2010-08-08 04:37:24 +02:00
static HolidayIds BGTypeToWeekendHolidayId(BattlegroundTypeId bgTypeId);
static BattlegroundTypeId WeekendHolidayIdToBGType(HolidayIds holiday);
static bool IsBGWeekend(BattlegroundTypeId bgTypeId);
2008-10-02 16:23:55 -05:00
private:
BattleMastersMap mBattleMastersMap;
2009-10-17 15:51:44 -07:00
2010-08-08 04:37:24 +02:00
typedef std::map<BattlegroundTypeId, uint8> BattlegroundSelectionWeightMap; // TypeId and its selectionWeight
2008-10-02 16:23:55 -05:00
/* Battlegrounds */
2010-08-08 04:37:24 +02:00
BattlegroundSet m_Battlegrounds[MAX_BATTLEGROUND_TYPE_ID];
BattlegroundSelectionWeightMap m_ArenaSelectionWeights;
BattlegroundSelectionWeightMap m_BGSelectionWeights;
std::vector<uint64> m_QueueUpdateScheduler;
2010-08-08 04:37:24 +02:00
std::set<uint32> m_ClientBattlegroundIds[MAX_BATTLEGROUND_TYPE_ID][MAX_BATTLEGROUND_BRACKETS]; //the instanceids just visible for the client
2008-10-05 08:48:32 -05:00
uint32 m_NextRatingDiscardUpdate;
time_t m_NextAutoDistributionTime;
2008-10-05 08:48:32 -05:00
uint32 m_AutoDistributionTimeChecker;
bool m_ArenaTesting;
bool m_Testing;
2008-10-02 16:23:55 -05:00
};
2009-10-17 15:51:44 -07:00
#define sBattlegroundMgr ACE_Singleton<BattlegroundMgr, ACE_Null_Mutex>::instance()
2008-10-02 16:23:55 -05:00
#endif
2009-02-17 20:07:49 -06:00