[7250] Use bg type ids enum insted raw values and catch some bugs in result for fixing.

* Replace max bg type checks by DBC valid index check
    * Use in functions and fields BattlegroundTypeId type instead uint32
    * Fixed wrong use bg queue ids instead bg type ids in queue update/remove function calls.
      Many bg have same raw values for type id and queue id but some can be affected by this bug:
      BATTLEGROUND_EY, BATTLEGROUND_SA, and all areans (with small arena/team size exceptions)
    * Move Battlemaster to bg type ids map fron ObjectMgr to BatteleGroundMgr.
    * Remobe redundent for header itself includes for BG headers.
    * Use Auction location enum instead raw valus.
Author: VladimirMangos

--HG--
branch : trunk
This commit is contained in:
megamage
2009-02-09 22:08:06 -06:00
parent 99c8226216
commit d696381f32
33 changed files with 337 additions and 279 deletions
+13
View File
@@ -650,6 +650,19 @@ void ArenaTeam::FinishWeek()
} }
} }
bool ArenaTeam::IsFighting() const
{
for (MemberList::const_iterator itr = members.begin(); itr != members.end(); ++itr)
{
if (Player *p = objmgr.GetPlayer(itr->guid))
{
if (p->GetMap()->IsBattleArena())
return true;
}
}
return false;
}
/* /*
arenateam fields (id from 2.3.3 client): arenateam fields (id from 2.3.3 client):
1414 - arena team id 2v2 1414 - arena team id 2v2
+1 -12
View File
@@ -179,18 +179,7 @@ class ArenaTeam
return NULL; return NULL;
} }
bool IsFighting() const bool IsFighting() const;
{
for (MemberList::const_iterator itr = members.begin(); itr != members.end(); ++itr)
{
if (Player *p = objmgr.GetPlayer(itr->guid))
{
if (p->GetMap()->IsBattleArena())
return true;
}
}
return false;
}
bool LoadArenaTeamFromDB(uint32 ArenaTeamId); bool LoadArenaTeamFromDB(uint32 ArenaTeamId);
void LoadMembersFromDB(uint32 ArenaTeamId); void LoadMembersFromDB(uint32 ArenaTeamId);
+26 -27
View File
@@ -55,21 +55,21 @@ void WorldSession::HandleAuctionHelloOpcode( WorldPacket & recv_data )
SendAuctionHello(guid, unit); SendAuctionHello(guid, unit);
} }
static uint8 AuctioneerFactionToLocation(uint32 faction) static AuctionLocation AuctioneerFactionToLocation(uint32 faction)
{ {
if(sWorld.getConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_AUCTION)) if(sWorld.getConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_AUCTION))
return 7; // neutral return AUCTION_NEUTRAL;
FactionTemplateEntry const* u_entry = sFactionTemplateStore.LookupEntry(faction); FactionTemplateEntry const* u_entry = sFactionTemplateStore.LookupEntry(faction);
if(!u_entry) if(!u_entry)
return 7; // neutral return AUCTION_NEUTRAL;
if(u_entry->ourMask & FACTION_MASK_ALLIANCE) if(u_entry->ourMask & FACTION_MASK_ALLIANCE)
return 2; return AUCTION_ALLIANCE;
else if(u_entry->ourMask & FACTION_MASK_HORDE) else if(u_entry->ourMask & FACTION_MASK_HORDE)
return 6; return AUCTION_HORDE;
else else
return 7; return AUCTION_NEUTRAL;
} }
//this void causes that auction window is opened //this void causes that auction window is opened
@@ -132,13 +132,13 @@ void WorldSession::SendAuctionCommandResult(uint32 auctionId, uint32 Action, uin
void WorldSession::SendAuctionBidderNotification( uint32 location, uint32 auctionId, uint64 bidder, uint32 bidSum, uint32 diff, uint32 item_template) void WorldSession::SendAuctionBidderNotification( uint32 location, uint32 auctionId, uint64 bidder, uint32 bidSum, uint32 diff, uint32 item_template)
{ {
WorldPacket data(SMSG_AUCTION_BIDDER_NOTIFICATION, (8*4)); WorldPacket data(SMSG_AUCTION_BIDDER_NOTIFICATION, (8*4));
data << location; data << uint32(location);
data << auctionId; data << uint32(auctionId);
data << (uint64) bidder; data << uint64(bidder);
data << bidSum; data << uint32(bidSum);
data << (uint32) diff; data << uint32(diff);
data << item_template; data << uint32(item_template);
data << (uint32) 0; data << uint32(0);
SendPacket(&data); SendPacket(&data);
} }
@@ -268,7 +268,7 @@ void WorldSession::HandleAuctionSellItem( WorldPacket & recv_data )
return; return;
} }
uint32 location = AuctioneerFactionToLocation(pCreature->getFaction()); AuctionLocation location = AuctioneerFactionToLocation(pCreature->getFaction());
AuctionHouseObject * mAuctions; AuctionHouseObject * mAuctions;
mAuctions = objmgr.GetAuctionsMap( location ); mAuctions = objmgr.GetAuctionsMap( location );
@@ -347,7 +347,7 @@ void WorldSession::HandleAuctionPlaceBid( WorldPacket & recv_data )
if(GetPlayer()->hasUnitState(UNIT_STAT_DIED)) if(GetPlayer()->hasUnitState(UNIT_STAT_DIED))
GetPlayer()->RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH); GetPlayer()->RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH);
uint32 location = AuctioneerFactionToLocation(pCreature->getFaction()); AuctionLocation location = AuctioneerFactionToLocation(pCreature->getFaction());
AuctionHouseObject * mAuctions; AuctionHouseObject * mAuctions;
mAuctions = objmgr.GetAuctionsMap( location ); mAuctions = objmgr.GetAuctionsMap( location );
@@ -474,7 +474,7 @@ void WorldSession::HandleAuctionRemoveItem( WorldPacket & recv_data )
if(GetPlayer()->hasUnitState(UNIT_STAT_DIED)) if(GetPlayer()->hasUnitState(UNIT_STAT_DIED))
GetPlayer()->RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH); GetPlayer()->RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH);
uint32 location = AuctioneerFactionToLocation(pCreature->getFaction()); AuctionLocation location = AuctioneerFactionToLocation(pCreature->getFaction());
AuctionHouseObject * mAuctions; AuctionHouseObject * mAuctions;
mAuctions = objmgr.GetAuctionsMap( location ); mAuctions = objmgr.GetAuctionsMap( location );
@@ -562,7 +562,7 @@ void WorldSession::HandleAuctionListBidderItems( WorldPacket & recv_data )
if(GetPlayer()->hasUnitState(UNIT_STAT_DIED)) if(GetPlayer()->hasUnitState(UNIT_STAT_DIED))
GetPlayer()->RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH); GetPlayer()->RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH);
uint32 location = AuctioneerFactionToLocation(pCreature->getFaction()); AuctionLocation location = AuctioneerFactionToLocation(pCreature->getFaction());
AuctionHouseObject* mAuctions = objmgr.GetAuctionsMap( location ); AuctionHouseObject* mAuctions = objmgr.GetAuctionsMap( location );
WorldPacket data( SMSG_AUCTION_BIDDER_LIST_RESULT, (4+4+4) ); WorldPacket data( SMSG_AUCTION_BIDDER_LIST_RESULT, (4+4+4) );
@@ -620,7 +620,7 @@ void WorldSession::HandleAuctionListOwnerItems( WorldPacket & recv_data )
if(GetPlayer()->hasUnitState(UNIT_STAT_DIED)) if(GetPlayer()->hasUnitState(UNIT_STAT_DIED))
GetPlayer()->RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH); GetPlayer()->RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH);
uint32 location = AuctioneerFactionToLocation(pCreature->getFaction()); AuctionLocation location = AuctioneerFactionToLocation(pCreature->getFaction());
AuctionHouseObject* mAuctions = objmgr.GetAuctionsMap( location ); AuctionHouseObject* mAuctions = objmgr.GetAuctionsMap( location );
@@ -650,9 +650,9 @@ void WorldSession::HandleAuctionListItems( WorldPacket & recv_data )
{ {
CHECK_PACKET_SIZE(recv_data,8+4+1+1+1+4+4+4+4+1); CHECK_PACKET_SIZE(recv_data,8+4+1+1+1+4+4+4+4+1);
std::string searchedname, name; std::string searchedname;
uint8 levelmin, levelmax, usable, location; uint8 levelmin, levelmax, usable;
uint32 count, totalcount, listfrom, auctionSlotID, auctionMainCategory, auctionSubCategory, quality; uint32 listfrom, auctionSlotID, auctionMainCategory, auctionSubCategory, quality;
uint64 guid; uint64 guid;
recv_data >> guid; recv_data >> guid;
@@ -677,15 +677,14 @@ void WorldSession::HandleAuctionListItems( WorldPacket & recv_data )
if(GetPlayer()->hasUnitState(UNIT_STAT_DIED)) if(GetPlayer()->hasUnitState(UNIT_STAT_DIED))
GetPlayer()->RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH); GetPlayer()->RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH);
location = AuctioneerFactionToLocation(pCreature->getFaction()); AuctionLocation location = AuctioneerFactionToLocation(pCreature->getFaction());
AuctionHouseObject * mAuctions; AuctionHouseObject * mAuctions = objmgr.GetAuctionsMap( location );
mAuctions = objmgr.GetAuctionsMap( location );
//sLog.outDebug("Auctionhouse search guid: " I64FMTD ", list from: %u, searchedname: %s, levelmin: %u, levelmax: %u, auctionSlotID: %u, auctionMainCategory: %u, auctionSubCategory: %u, quality: %u, usable: %u", guid, listfrom, searchedname.c_str(), levelmin, levelmax, auctionSlotID, auctionMainCategory, auctionSubCategory, quality, usable); //sLog.outDebug("Auctionhouse search guid: " I64FMTD ", list from: %u, searchedname: %s, levelmin: %u, levelmax: %u, auctionSlotID: %u, auctionMainCategory: %u, auctionSubCategory: %u, quality: %u, usable: %u", guid, listfrom, searchedname.c_str(), levelmin, levelmax, auctionSlotID, auctionMainCategory, auctionSubCategory, quality, usable);
WorldPacket data( SMSG_AUCTION_LIST_RESULT, (4+4+4) ); WorldPacket data( SMSG_AUCTION_LIST_RESULT, (4+4+4) );
count = 0; uint32 count = 0;
totalcount = 0; uint32 totalcount = 0;
data << (uint32) 0; data << (uint32) 0;
// converting string that we try to find to lower case // converting string that we try to find to lower case
@@ -716,7 +715,7 @@ void WorldSession::HandleAuctionListItems( WorldPacket & recv_data )
{ {
if( ( levelmin == (0x00) || proto->RequiredLevel >= levelmin ) && ( levelmax == (0x00) || proto->RequiredLevel <= levelmax ) ) if( ( levelmin == (0x00) || proto->RequiredLevel >= levelmin ) && ( levelmax == (0x00) || proto->RequiredLevel <= levelmax ) )
{ {
name = proto->Name1; std::string name = proto->Name1;
// local name // local name
int loc_idx = GetSessionDbLocaleIndex(); int loc_idx = GetSessionDbLocaleIndex();
+8 -8
View File
@@ -1,4 +1,3 @@
#include "AuctionHouseBot.h"
#include "Bag.h" #include "Bag.h"
#include "Config/ConfigEnv.h" #include "Config/ConfigEnv.h"
#include "Database/DatabaseEnv.h" #include "Database/DatabaseEnv.h"
@@ -9,6 +8,7 @@
#include "World.h" #include "World.h"
#include "WorldSession.h" #include "WorldSession.h"
#include "time.h" #include "time.h"
#include "AuctionHouseBot.h"
#include <vector> #include <vector>
#include <iostream> #include <iostream>
@@ -40,9 +40,9 @@ static bool Bind_When_Equipped = 0;
static bool Bind_When_Use = 0; static bool Bind_When_Use = 0;
static bool Bind_Quest_Item = 0; static bool Bind_Quest_Item = 0;
static AHBConfig AllianceConfig = AHBConfig(2); static AHBConfig AllianceConfig = AHBConfig(AUCTION_ALLIANCE);
static AHBConfig HordeConfig = AHBConfig(6); static AHBConfig HordeConfig = AHBConfig(AUCTION_HORDE);
static AHBConfig NeutralConfig = AHBConfig(7); static AHBConfig NeutralConfig = AHBConfig(AUCTION_NEUTRAL);
time_t _lastrun_a; time_t _lastrun_a;
time_t _lastrun_h; time_t _lastrun_h;
time_t _lastrun_n; time_t _lastrun_n;
@@ -905,18 +905,18 @@ void AuctionHouseBotInit()
sLog.outString("AuctionHouseBot now includes AHBuyer by Kerbe and Paradox"); sLog.outString("AuctionHouseBot now includes AHBuyer by Kerbe and Paradox");
} }
void AuctionHouseBotCommands(uint32 command, uint32 ahMapID, uint32 col, char* args) void AuctionHouseBotCommands(uint32 command, AuctionLocation ahMapID, uint32 col, char* args)
{ {
AHBConfig *config; AHBConfig *config;
switch (ahMapID) switch (ahMapID)
{ {
case 2: case AUCTION_ALLIANCE:
config = &AllianceConfig; config = &AllianceConfig;
break; break;
case 6: case AUCTION_HORDE:
config = &HordeConfig; config = &HordeConfig;
break; break;
case 7: case AUCTION_NEUTRAL:
config = &NeutralConfig; config = &NeutralConfig;
break; break;
} }
+5 -4
View File
@@ -3,6 +3,7 @@
#include "Common.h" #include "Common.h"
#include "Log.h" #include "Log.h"
#include "Config/ConfigEnv.h" #include "Config/ConfigEnv.h"
#include "AuctionHouseObject.h"
#define AHB_GREY 0 #define AHB_GREY 0
#define AHB_WHITE 1 #define AHB_WHITE 1
#define AHB_GREEN 2 #define AHB_GREEN 2
@@ -27,7 +28,7 @@
class AHBConfig class AHBConfig
{ {
private: private:
uint32 AHID; AuctionLocation AHID;
uint32 minItems; uint32 minItems;
uint32 maxItems; uint32 maxItems;
uint32 minTime; uint32 minTime;
@@ -78,14 +79,14 @@ class AHBConfig
uint32 bip; uint32 bip;
uint32 pip; uint32 pip;
public: public:
AHBConfig(uint32 ahid) AHBConfig(AuctionLocation ahid)
{ {
AHID = ahid; AHID = ahid;
} }
AHBConfig() AHBConfig()
{ {
} }
uint32 GetAHID() AuctionLocation GetAHID()
{ {
return AHID; return AHID;
} }
@@ -683,5 +684,5 @@ class AHBConfig
void AuctionHouseBot(); void AuctionHouseBot();
void AuctionHouseBotInit(); void AuctionHouseBotInit();
void AuctionHouseBotLoadValues(AHBConfig*); void AuctionHouseBotLoadValues(AHBConfig*);
void AuctionHouseBotCommands(uint32, uint32, uint32, char*); void AuctionHouseBotCommands(uint32, AuctionLocation, uint32, char*);
#endif #endif
+10 -1
View File
@@ -41,6 +41,15 @@ enum AuctionAction
AUCTION_PLACE_BID = 2 AUCTION_PLACE_BID = 2
}; };
enum AuctionLocation
{
AUCTION_ALLIANCE = 2,
AUCTION_HORDE = 6,
AUCTION_NEUTRAL = 7
};
inline bool IsValidAuctionLocation(uint32 loc) { return loc == AUCTION_ALLIANCE || loc == AUCTION_HORDE || loc == AUCTION_NEUTRAL; }
struct AuctionEntry struct AuctionEntry
{ {
uint32 Id; uint32 Id;
@@ -54,7 +63,7 @@ struct AuctionEntry
time_t time; time_t time;
uint32 bidder; uint32 bidder;
uint32 deposit; //deposit can be calculated only when creating auction uint32 deposit; //deposit can be calculated only when creating auction
uint32 location; AuctionLocation location;
}; };
//this class is used as auctionhouse instance //this class is used as auctionhouse instance
+14 -2
View File
@@ -21,6 +21,7 @@
#include "Object.h" #include "Object.h"
#include "Player.h" #include "Player.h"
#include "BattleGround.h" #include "BattleGround.h"
#include "BattleGroundMgr.h"
#include "Creature.h" #include "Creature.h"
#include "MapManager.h" #include "MapManager.h"
#include "Language.h" #include "Language.h"
@@ -28,11 +29,14 @@
#include "SpellAuras.h" #include "SpellAuras.h"
#include "ArenaTeam.h" #include "ArenaTeam.h"
#include "World.h" #include "World.h"
#include "Group.h"
#include "ObjectMgr.h"
#include "WorldPacket.h"
#include "Util.h" #include "Util.h"
BattleGround::BattleGround() BattleGround::BattleGround()
{ {
m_TypeID = 0; m_TypeID = BattleGroundTypeId(0);
m_InstanceID = 0; m_InstanceID = 0;
m_Status = 0; m_Status = 0;
m_EndTime = 0; m_EndTime = 0;
@@ -789,7 +793,7 @@ void BattleGround::RemovePlayerAtLeave(uint64 guid, bool Transport, bool SendPac
{ {
if(!team) team = plr->GetTeam(); if(!team) team = plr->GetTeam();
uint32 bgTypeId = GetTypeID(); BattleGroundTypeId bgTypeId = GetTypeID();
uint32 bgQueueTypeId = BattleGroundMgr::BGQueueTypeId(GetTypeID(), GetArenaType()); uint32 bgQueueTypeId = BattleGroundMgr::BGQueueTypeId(GetTypeID(), GetArenaType());
// if arena, remove the specific arena auras // if arena, remove the specific arena auras
if(isArena()) if(isArena())
@@ -1568,3 +1572,11 @@ int32 BattleGround::GetObjectType(uint64 guid)
void BattleGround::HandleKillUnit(Creature *creature, Player *killer) void BattleGround::HandleKillUnit(Creature *creature, Player *killer)
{ {
} }
void BattleGround::SetBgRaid( uint32 TeamID, Group *bg_raid )
{
Group* &old_raid = TeamID == ALLIANCE ? m_BgRaids[BG_TEAM_ALLIANCE] : m_BgRaids[BG_TEAM_HORDE];
if(old_raid) old_raid->SetBattlegroundGroup(NULL);
if(bg_raid) bg_raid->SetBattlegroundGroup(this);
old_raid = bg_raid;
}
+12 -31
View File
@@ -22,13 +22,16 @@
#define __BATTLEGROUND_H #define __BATTLEGROUND_H
#include "Common.h" #include "Common.h"
#include "WorldPacket.h"
#include "WorldSession.h"
#include "Opcodes.h"
#include "ObjectMgr.h"
#include "BattleGroundMgr.h"
#include "SharedDefines.h" #include "SharedDefines.h"
class Creature;
class GameObject;
class Group;
class Player;
class WorldPacket;
struct WorldSafeLocsEntry;
enum BattleGroundSounds enum BattleGroundSounds
{ {
SOUND_HORDE_WINS = 8454, SOUND_HORDE_WINS = 8454,
@@ -132,22 +135,6 @@ struct BattleGroundObjectInfo
uint32 spellid; uint32 spellid;
}; };
enum BattleGroundTypeId
{
BATTLEGROUND_AV = 1,
BATTLEGROUND_WS = 2,
BATTLEGROUND_AB = 3,
BATTLEGROUND_NA = 4,
BATTLEGROUND_BE = 5,
BATTLEGROUND_AA = 6,
BATTLEGROUND_EY = 7,
BATTLEGROUND_RL = 8,
BATTLEGROUND_SA = 9,
BATTLEGROUND_DS = 10,
BATTLEGROUND_RV = 11
};
#define MAX_BATTLEGROUND_TYPE_ID 12
// handle the queue types and bg types separately to enable joining queue for different sized arenas at the same time // handle the queue types and bg types separately to enable joining queue for different sized arenas at the same time
enum BattleGroundQueueTypeId enum BattleGroundQueueTypeId
{ {
@@ -278,7 +265,7 @@ class BattleGround
/* Battleground */ /* Battleground */
// Get methods: // Get methods:
char const* GetName() const { return m_Name; } char const* GetName() const { return m_Name; }
uint32 GetTypeID() const { return m_TypeID; } BattleGroundTypeId GetTypeID() const { return m_TypeID; }
uint32 GetQueueType() const { return m_Queue_type; } uint32 GetQueueType() const { return m_Queue_type; }
uint32 GetInstanceID() const { return m_InstanceID; } uint32 GetInstanceID() const { return m_InstanceID; }
uint32 GetStatus() const { return m_Status; } uint32 GetStatus() const { return m_Status; }
@@ -301,7 +288,7 @@ class BattleGround
// Set methods: // Set methods:
void SetName(char const* Name) { m_Name = Name; } void SetName(char const* Name) { m_Name = Name; }
void SetTypeID(uint32 TypeID) { m_TypeID = TypeID; } void SetTypeID(BattleGroundTypeId TypeID) { m_TypeID = TypeID; }
void SetQueueType(uint32 ID) { m_Queue_type = ID; } void SetQueueType(uint32 ID) { m_Queue_type = ID; }
void SetInstanceID(uint32 InstanceID) { m_InstanceID = InstanceID; } void SetInstanceID(uint32 InstanceID) { m_InstanceID = InstanceID; }
void SetStatus(uint32 Status) { m_Status = Status; } void SetStatus(uint32 Status) { m_Status = Status; }
@@ -398,13 +385,7 @@ class BattleGround
/* Raid Group */ /* Raid Group */
Group *GetBgRaid(uint32 TeamID) const { return TeamID == ALLIANCE ? m_BgRaids[BG_TEAM_ALLIANCE] : m_BgRaids[BG_TEAM_HORDE]; } Group *GetBgRaid(uint32 TeamID) const { return TeamID == ALLIANCE ? m_BgRaids[BG_TEAM_ALLIANCE] : m_BgRaids[BG_TEAM_HORDE]; }
void SetBgRaid(uint32 TeamID, Group *bg_raid) void SetBgRaid(uint32 TeamID, Group *bg_raid);
{
Group* &old_raid = TeamID == ALLIANCE ? m_BgRaids[BG_TEAM_ALLIANCE] : m_BgRaids[BG_TEAM_HORDE];
if(old_raid) old_raid->SetBattlegroundGroup(NULL);
if(bg_raid) bg_raid->SetBattlegroundGroup(this);
old_raid = bg_raid;
}
virtual void UpdatePlayerScore(Player *Source, uint32 type, uint32 value); virtual void UpdatePlayerScore(Player *Source, uint32 type, uint32 value);
@@ -499,7 +480,7 @@ class BattleGround
BGHonorMode m_HonorMode; BGHonorMode m_HonorMode;
private: private:
/* Battleground */ /* Battleground */
uint32 m_TypeID; //Battleground type, defined in enum BattleGroundTypeId BattleGroundTypeId m_TypeID;
uint32 m_InstanceID; //BattleGround Instance's GUID! uint32 m_InstanceID; //BattleGround Instance's GUID!
uint32 m_Status; uint32 m_Status;
uint32 m_StartTime; uint32 m_StartTime;
+1
View File
@@ -29,6 +29,7 @@
#include "Language.h" #include "Language.h"
#include "World.h" #include "World.h"
#include "Util.h" #include "Util.h"
#include "WorldPacket.h"
// these variables aren't used outside of this file, so declare them only here // these variables aren't used outside of this file, so declare them only here
uint32 BG_AB_HonorScoreTicks[BG_HONOR_MODE_NUM] = { uint32 BG_AB_HonorScoreTicks[BG_HONOR_MODE_NUM] = {
+1
View File
@@ -30,6 +30,7 @@
#include "Language.h" #include "Language.h"
#include "SpellAuras.h" #include "SpellAuras.h"
#include "Formulas.h" #include "Formulas.h"
#include "WorldPacket.h"
BattleGroundAV::BattleGroundAV() BattleGroundAV::BattleGroundAV()
{ {
+1
View File
@@ -25,6 +25,7 @@
#include "Creature.h" #include "Creature.h"
#include "ObjectMgr.h" #include "ObjectMgr.h"
#include "MapManager.h" #include "MapManager.h"
#include "WorldPacket.h"
#include "Language.h" #include "Language.h"
BattleGroundBE::BattleGroundBE() BattleGroundBE::BattleGroundBE()
+2 -1
View File
@@ -27,7 +27,8 @@
#include "ObjectMgr.h" #include "ObjectMgr.h"
#include "MapManager.h" #include "MapManager.h"
#include "Language.h" #include "Language.h"
#include "World.h" #include "World.h" //music
#include "WorldPacket.h"
#include "Util.h" #include "Util.h"
// these variables aren't used outside of this file, so declare them only here // these variables aren't used outside of this file, so declare them only here
+21 -21
View File
@@ -53,7 +53,7 @@ void WorldSession::HandleBattleGroundHelloOpcode( WorldPacket & recv_data )
// Stop the npc if moving // Stop the npc if moving
unit->StopMoving(); unit->StopMoving();
uint32 bgTypeId = objmgr.GetBattleMasterBG(unit->GetEntry()); BattleGroundTypeId bgTypeId = sBattleGroundMgr.GetBattleMasterBG(unit->GetEntry());
if(!_player->GetBGAccessByLevel(bgTypeId)) if(!_player->GetBGAccessByLevel(bgTypeId))
{ {
@@ -65,7 +65,7 @@ void WorldSession::HandleBattleGroundHelloOpcode( WorldPacket & recv_data )
SendBattlegGroundList(guid, bgTypeId); SendBattlegGroundList(guid, bgTypeId);
} }
void WorldSession::SendBattlegGroundList( uint64 guid, uint32 bgTypeId ) void WorldSession::SendBattlegGroundList( uint64 guid, BattleGroundTypeId bgTypeId )
{ {
WorldPacket data; WorldPacket data;
sBattleGroundMgr.BuildBattleGroundListPacket(&data, guid, _player, bgTypeId); sBattleGroundMgr.BuildBattleGroundListPacket(&data, guid, _player, bgTypeId);
@@ -77,22 +77,24 @@ void WorldSession::HandleBattleGroundJoinOpcode( WorldPacket & recv_data )
CHECK_PACKET_SIZE(recv_data, 8+4+4+1); CHECK_PACKET_SIZE(recv_data, 8+4+4+1);
uint64 guid; uint64 guid;
uint32 bgTypeId; uint32 bgTypeId_;
uint32 instanceId; uint32 instanceId;
uint8 joinAsGroup; uint8 joinAsGroup;
Group * grp; Group * grp;
recv_data >> guid; // battlemaster guid recv_data >> guid; // battlemaster guid
recv_data >> bgTypeId; // battleground type id (DBC id) recv_data >> bgTypeId_; // battleground type id (DBC id)
recv_data >> instanceId; // instance id, 0 if First Available selected recv_data >> instanceId; // instance id, 0 if First Available selected
recv_data >> joinAsGroup; // join as group recv_data >> joinAsGroup; // join as group
if(bgTypeId >= MAX_BATTLEGROUND_TYPES) if(!sBattlemasterListStore.LookupEntry(bgTypeId_))
{ {
sLog.outError("Battleground: invalid bgtype received. possible cheater? player guid %u",_player->GetGUIDLow()); sLog.outError("Battleground: invalid bgtype (%u) received. possible cheater? player guid %u",bgTypeId_,_player->GetGUIDLow());
return; return;
} }
BattleGroundTypeId bgTypeId = BattleGroundTypeId(bgTypeId_);
sLog.outDebug( "WORLD: Recvd CMSG_BATTLEMASTER_JOIN Message from: " I64FMT, guid); sLog.outDebug( "WORLD: Recvd CMSG_BATTLEMASTER_JOIN Message from: " I64FMT, guid);
// can do this, since it's battleground, not arena // can do this, since it's battleground, not arena
@@ -274,19 +276,15 @@ void WorldSession::HandleBattleGroundListOpcode( WorldPacket &recv_data )
uint32 bgTypeId; uint32 bgTypeId;
recv_data >> bgTypeId; // id from DBC recv_data >> bgTypeId; // id from DBC
if(bgTypeId >= MAX_BATTLEGROUND_TYPES) BattlemasterListEntry const* bl = sBattlemasterListStore.LookupEntry(bgTypeId);
if(!bl)
{ {
sLog.outError("Battleground: invalid bgtype received."); sLog.outError("Battleground: invalid bgtype received.");
return; return;
} }
BattlemasterListEntry const* bl = sBattlemasterListStore.LookupEntry(bgTypeId);
if(!bl)
return;
WorldPacket data; WorldPacket data;
sBattleGroundMgr.BuildBattleGroundListPacket(&data, _player->GetGUID(), _player, bgTypeId); sBattleGroundMgr.BuildBattleGroundListPacket(&data, _player->GetGUID(), _player, BattleGroundTypeId(bgTypeId));
SendPacket( &data ); SendPacket( &data );
} }
@@ -299,15 +297,15 @@ void WorldSession::HandleBattleGroundPlayerPortOpcode( WorldPacket &recv_data )
uint8 type; // arenatype if arena uint8 type; // arenatype if arena
uint8 unk2; // unk, can be 0x0 (may be if was invited?) and 0x1 uint8 unk2; // unk, can be 0x0 (may be if was invited?) and 0x1
uint32 instanceId; uint32 instanceId;
uint32 bgTypeId; // type id from dbc uint32 bgTypeId_; // type id from dbc
uint16 unk; // 0x1F90 constant? uint16 unk; // 0x1F90 constant?
uint8 action; // enter battle 0x1, leave queue 0x0 uint8 action; // enter battle 0x1, leave queue 0x0
recv_data >> type >> unk2 >> bgTypeId >> unk >> action; recv_data >> type >> unk2 >> bgTypeId_ >> unk >> action;
if(bgTypeId >= MAX_BATTLEGROUND_TYPES) if(!sBattlemasterListStore.LookupEntry(bgTypeId_))
{ {
sLog.outError("Battleground: invalid bgtype received."); sLog.outError("Battleground: invalid bgtype (%u) received.",bgTypeId_);
// update battleground slots for the player to fix his UI and sent data. // update battleground slots for the player to fix his UI and sent data.
// this is a HACK, I don't know why the client starts sending invalid packets in the first place. // this is a HACK, I don't know why the client starts sending invalid packets in the first place.
// it usually happens with extremely high latency (if debugging / stepping in the code for example) // it usually happens with extremely high latency (if debugging / stepping in the code for example)
@@ -331,7 +329,7 @@ void WorldSession::HandleBattleGroundPlayerPortOpcode( WorldPacket &recv_data )
BattleGround * bg = NULL; BattleGround * bg = NULL;
// get possibly needed data from groupinfo // get possibly needed data from groupinfo
bgTypeId = itrPlayerStatus->second.GroupInfo->BgTypeId; BattleGroundTypeId bgTypeId = itrPlayerStatus->second.GroupInfo->BgTypeId;
uint8 arenatype = itrPlayerStatus->second.GroupInfo->ArenaType; uint8 arenatype = itrPlayerStatus->second.GroupInfo->ArenaType;
uint8 israted = itrPlayerStatus->second.GroupInfo->IsRated; uint8 israted = itrPlayerStatus->second.GroupInfo->IsRated;
uint8 status = 0; uint8 status = 0;
@@ -367,6 +365,8 @@ void WorldSession::HandleBattleGroundPlayerPortOpcode( WorldPacket &recv_data )
return; return;
} }
BattleGroundTypeId bgTypeId = BattleGroundTypeId(bgTypeId_);
uint32 bgQueueTypeId = 0; uint32 bgQueueTypeId = 0;
// get the bg what we were invited to // get the bg what we were invited to
BattleGroundQueue::QueuedPlayersMap::iterator itrPlayerStatus; BattleGroundQueue::QueuedPlayersMap::iterator itrPlayerStatus;
@@ -395,7 +395,7 @@ void WorldSession::HandleBattleGroundPlayerPortOpcode( WorldPacket &recv_data )
if(!bg) if(!bg)
{ {
sLog.outError("Battleground: bg not found."); sLog.outError("Battleground: bg not found for type id %u.",bgTypeId);
return; return;
} }
@@ -572,7 +572,7 @@ void WorldSession::HandleBattlefieldStatusOpcode( WorldPacket & /*recv_data*/ )
uint32 queue_id = _player->GetBattleGroundQueueId(i); uint32 queue_id = _player->GetBattleGroundQueueId(i);
if(!queue_id) if(!queue_id)
continue; continue;
uint32 bgTypeId = BattleGroundMgr::BGTemplateId(queue_id); BattleGroundTypeId bgTypeId = BattleGroundMgr::BGTemplateId(queue_id);
uint8 arenatype = BattleGroundMgr::BGArenaType(queue_id); uint8 arenatype = BattleGroundMgr::BGArenaType(queue_id);
uint8 isRated = 0; uint8 isRated = 0;
BattleGround *bg = sBattleGroundMgr.GetBattleGroundTemplate(bgTypeId); BattleGround *bg = sBattleGroundMgr.GetBattleGroundTemplate(bgTypeId);
@@ -700,7 +700,7 @@ void WorldSession::HandleBattleGroundArenaJoin( WorldPacket & recv_data )
return; return;
} }
uint8 bgTypeId = bg->GetTypeID(); BattleGroundTypeId bgTypeId = bg->GetTypeID();
uint32 bgQueueTypeId = BattleGroundMgr::BGQueueTypeId(bgTypeId, arenatype); uint32 bgQueueTypeId = BattleGroundMgr::BGQueueTypeId(bgTypeId, arenatype);
// check queueing conditions // check queueing conditions
+95 -35
View File
@@ -19,6 +19,7 @@
*/ */
#include "Common.h" #include "Common.h"
#include "SharedDefines.h"
#include "Player.h" #include "Player.h"
#include "BattleGroundMgr.h" #include "BattleGroundMgr.h"
#include "BattleGroundAV.h" #include "BattleGroundAV.h"
@@ -32,8 +33,6 @@
#include "BattleGroundSA.h" #include "BattleGroundSA.h"
#include "BattleGroundDS.h" #include "BattleGroundDS.h"
#include "BattleGroundRV.h" #include "BattleGroundRV.h"
#include "SharedDefines.h"
#include "Policies/SingletonImp.h"
#include "MapManager.h" #include "MapManager.h"
#include "Map.h" #include "Map.h"
#include "MapInstanced.h" #include "MapInstanced.h"
@@ -41,6 +40,11 @@
#include "ProgressBar.h" #include "ProgressBar.h"
#include "Chat.h" #include "Chat.h"
#include "ArenaTeam.h" #include "ArenaTeam.h"
#include "World.h"
#include "WorldPacket.h"
#include "ProgressBar.h"
#include "Policies/SingletonImp.h"
INSTANTIATE_SINGLETON_1( BattleGroundMgr ); INSTANTIATE_SINGLETON_1( BattleGroundMgr );
@@ -73,7 +77,7 @@ BattleGroundQueue::~BattleGroundQueue()
} }
// initialize eligible groups from the given source matching the given specifications // initialize eligible groups from the given source matching the given specifications
void BattleGroundQueue::EligibleGroups::Init(BattleGroundQueue::QueuedGroupsList *source, uint32 BgTypeId, uint32 side, uint32 MaxPlayers, uint8 ArenaType, bool IsRated, uint32 MinRating, uint32 MaxRating, uint32 DisregardTime, uint32 excludeTeam) void BattleGroundQueue::EligibleGroups::Init(BattleGroundQueue::QueuedGroupsList *source, BattleGroundTypeId BgTypeId, uint32 side, uint32 MaxPlayers, uint8 ArenaType, bool IsRated, uint32 MinRating, uint32 MaxRating, uint32 DisregardTime, uint32 excludeTeam)
{ {
// clear from prev initialization // clear from prev initialization
clear(); clear();
@@ -138,7 +142,7 @@ void BattleGroundQueue::SelectionPool::AddGroup(GroupQueueInfo * ginfo)
} }
// add group to bg queue with the given leader and bg specifications // add group to bg queue with the given leader and bg specifications
GroupQueueInfo * BattleGroundQueue::AddGroup(Player *leader, uint32 BgTypeId, uint8 ArenaType, bool isRated, uint32 arenaRating, uint32 arenateamid) GroupQueueInfo * BattleGroundQueue::AddGroup(Player *leader, BattleGroundTypeId BgTypeId, uint8 ArenaType, bool isRated, uint32 arenaRating, uint32 arenateamid)
{ {
uint32 queue_id = leader->GetBattleGroundQueueIdFromLevel(); uint32 queue_id = leader->GetBattleGroundQueueIdFromLevel();
@@ -340,7 +344,7 @@ void BattleGroundQueue::AnnounceWorld(GroupQueueInfo *ginfo, const uint64& playe
uint8 qHorde = 0; uint8 qHorde = 0;
uint8 qAlliance = 0; uint8 qAlliance = 0;
uint32 bgTypeId = ginfo->BgTypeId; BattleGroundTypeId bgTypeId = ginfo->BgTypeId;
QueuedPlayersMap::iterator itr; QueuedPlayersMap::iterator itr;
for(itr = m_QueuedPlayers[queue_id].begin(); itr!= m_QueuedPlayers[queue_id].end(); ++itr) for(itr = m_QueuedPlayers[queue_id].begin(); itr!= m_QueuedPlayers[queue_id].end(); ++itr)
{ {
@@ -448,7 +452,7 @@ bool BattleGroundQueue::SelectionPool::Build(uint32 MinPlayers, uint32 MaxPlayer
} }
// this function is responsible for the selection of queued groups when trying to create new battlegrounds // this function is responsible for the selection of queued groups when trying to create new battlegrounds
bool BattleGroundQueue::BuildSelectionPool(uint32 bgTypeId, uint32 queue_id, uint32 MinPlayers, uint32 MaxPlayers, SelectionPoolBuildMode mode, uint8 ArenaType, bool isRated, uint32 MinRating, uint32 MaxRating, uint32 DisregardTime, uint32 excludeTeam) bool BattleGroundQueue::BuildSelectionPool(BattleGroundTypeId bgTypeId, uint32 queue_id, uint32 MinPlayers, uint32 MaxPlayers, SelectionPoolBuildMode mode, uint8 ArenaType, bool isRated, uint32 MinRating, uint32 MaxRating, uint32 DisregardTime, uint32 excludeTeam)
{ {
uint32 side; uint32 side;
switch(mode) switch(mode)
@@ -467,7 +471,6 @@ bool BattleGroundQueue::BuildSelectionPool(uint32 bgTypeId, uint32 queue_id, uin
//unknown mode, return false //unknown mode, return false
sLog.outDebug("Battleground: unknown selection pool build mode, returning..."); sLog.outDebug("Battleground: unknown selection pool build mode, returning...");
return false; return false;
break;
} }
// initiate the groups eligible to create the bg // initiate the groups eligible to create the bg
@@ -541,7 +544,7 @@ void BattleGroundQueue::BGEndedRemoveInvites(BattleGround *bg)
RemovePlayer(itr2->first, true); RemovePlayer(itr2->first, true);
// this is probably unneeded, since this player was already invited -> does not fit when initing eligible groups // this is probably unneeded, since this player was already invited -> does not fit when initing eligible groups
// but updating the queue can't hurt // but updating the queue can't hurt
Update(bgQueueTypeId, bg->GetQueueType()); Update(bg->GetTypeID(), bg->GetQueueType());
// send info to client // send info to client
WorldPacket data; WorldPacket data;
sBattleGroundMgr.BuildBattleGroundStatusPacket(&data, bg, team, queueSlot, STATUS_NONE, 0, 0); sBattleGroundMgr.BuildBattleGroundStatusPacket(&data, bg, team, queueSlot, STATUS_NONE, 0, 0);
@@ -557,7 +560,7 @@ this method is called when group is inserted, or player / group is removed from
it must be called after fully adding the members of a group to ensure group joining it must be called after fully adding the members of a group to ensure group joining
should be called after removeplayer functions in some cases should be called after removeplayer functions in some cases
*/ */
void BattleGroundQueue::Update(uint32 bgTypeId, uint32 queue_id, uint8 arenatype, bool isRated, uint32 arenaRating) void BattleGroundQueue::Update(BattleGroundTypeId bgTypeId, uint32 queue_id, uint8 arenatype, bool isRated, uint32 arenaRating)
{ {
if (queue_id >= MAX_BATTLEGROUND_QUEUES) if (queue_id >= MAX_BATTLEGROUND_QUEUES)
{ {
@@ -679,7 +682,7 @@ void BattleGroundQueue::Update(uint32 bgTypeId, uint32 queue_id, uint8 arenatype
if(bg_template->isArena()) if(bg_template->isArena())
{ {
// Find a random arena, that can be created // Find a random arena, that can be created
uint8 arenas[] = {BATTLEGROUND_NA, BATTLEGROUND_BE, BATTLEGROUND_RL}; BattleGroundTypeId arenas[] = {BATTLEGROUND_NA, BATTLEGROUND_BE, BATTLEGROUND_RL};
uint32 arena_num = urand(0,2); uint32 arena_num = urand(0,2);
if( !(bg2 = sBattleGroundMgr.CreateNewBattleGround(arenas[arena_num%3])) && if( !(bg2 = sBattleGroundMgr.CreateNewBattleGround(arenas[arena_num%3])) &&
!(bg2 = sBattleGroundMgr.CreateNewBattleGround(arenas[(arena_num+1)%3])) && !(bg2 = sBattleGroundMgr.CreateNewBattleGround(arenas[(arena_num+1)%3])) &&
@@ -843,7 +846,7 @@ void BattleGroundQueue::Update(uint32 bgTypeId, uint32 queue_id, uint8 arenatype
} }
// create random arena // create random arena
uint8 arenas[] = {BATTLEGROUND_NA, BATTLEGROUND_BE, BATTLEGROUND_RL}; BattleGroundTypeId arenas[] = {BATTLEGROUND_NA, BATTLEGROUND_BE, BATTLEGROUND_RL};
uint32 arena_num = urand(0,2); uint32 arena_num = urand(0,2);
BattleGround* bg2 = NULL; BattleGround* bg2 = NULL;
if( !(bg2 = sBattleGroundMgr.CreateNewBattleGround(arenas[arena_num%3])) && if( !(bg2 = sBattleGroundMgr.CreateNewBattleGround(arenas[arena_num%3])) &&
@@ -945,9 +948,6 @@ bool BGQueueInviteEvent::Execute(uint64 /*e_time*/, uint32 /*p_time*/)
if (!bg) if (!bg)
return true; return true;
uint32 queueSlot = plr->GetBattleGroundQueueIndex(bg->GetTypeID());
if (queueSlot < PLAYER_MAX_BATTLEGROUND_QUEUES) // player is in queue
{
uint32 bgQueueTypeId = BattleGroundMgr::BGQueueTypeId(bg->GetTypeID(), bg->GetArenaType()); uint32 bgQueueTypeId = BattleGroundMgr::BGQueueTypeId(bg->GetTypeID(), bg->GetArenaType());
uint32 queueSlot = plr->GetBattleGroundQueueIndex(bgQueueTypeId); uint32 queueSlot = plr->GetBattleGroundQueueIndex(bgQueueTypeId);
if (queueSlot < PLAYER_MAX_BATTLEGROUND_QUEUES) // player is in queue if (queueSlot < PLAYER_MAX_BATTLEGROUND_QUEUES) // player is in queue
@@ -962,7 +962,6 @@ bool BGQueueInviteEvent::Execute(uint64 /*e_time*/, uint32 /*p_time*/)
plr->GetSession()->SendPacket(&data); plr->GetSession()->SendPacket(&data);
} }
} }
}
return true; //event will be deleted return true; //event will be deleted
} }
@@ -1005,7 +1004,7 @@ bool BGQueueRemoveEvent::Execute(uint64 /*e_time*/, uint32 /*p_time*/)
} }
plr->RemoveBattleGroundQueueId(bgQueueTypeId); plr->RemoveBattleGroundQueueId(bgQueueTypeId);
sBattleGroundMgr.m_BattleGroundQueues[bgQueueTypeId].RemovePlayer(m_PlayerGuid, true); sBattleGroundMgr.m_BattleGroundQueues[bgQueueTypeId].RemovePlayer(m_PlayerGuid, true);
sBattleGroundMgr.m_BattleGroundQueues[bgQueueTypeId].Update(bgQueueTypeId, bg->GetQueueType()); sBattleGroundMgr.m_BattleGroundQueues[bgQueueTypeId].Update(bg->GetTypeID(),bg->GetQueueType());
WorldPacket data; WorldPacket data;
sBattleGroundMgr.BuildBattleGroundStatusPacket(&data, bg, m_PlayersTeam, queueSlot, STATUS_NONE, 0, 0); sBattleGroundMgr.BuildBattleGroundStatusPacket(&data, bg, m_PlayersTeam, queueSlot, STATUS_NONE, 0, 0);
plr->GetSession()->SendPacket(&data); plr->GetSession()->SendPacket(&data);
@@ -1297,7 +1296,7 @@ void BattleGroundMgr::BuildPvpLogDataPacket(WorldPacket *data, BattleGround *bg)
} }
} }
void BattleGroundMgr::BuildGroupJoinedBattlegroundPacket(WorldPacket *data, uint32 bgTypeId) void BattleGroundMgr::BuildGroupJoinedBattlegroundPacket(WorldPacket *data, BattleGroundTypeId bgTypeId)
{ {
/*bgTypeId is: /*bgTypeId is:
0 - Your group has joined a battleground queue, but you are not eligible 0 - Your group has joined a battleground queue, but you are not eligible
@@ -1374,25 +1373,24 @@ void BattleGroundMgr::InvitePlayer(Player* plr, uint32 bgInstanceGUID, uint32 te
plr->m_Events.AddEvent(removeEvent, plr->m_Events.CalculateTime(INVITE_ACCEPT_WAIT_TIME)); plr->m_Events.AddEvent(removeEvent, plr->m_Events.CalculateTime(INVITE_ACCEPT_WAIT_TIME));
} }
BattleGround * BattleGroundMgr::GetBattleGroundTemplate(uint32 bgTypeId) BattleGround * BattleGroundMgr::GetBattleGroundTemplate(BattleGroundTypeId bgTypeId)
{ {
return BGFreeSlotQueue[bgTypeId].empty() ? NULL : BGFreeSlotQueue[bgTypeId].back(); return BGFreeSlotQueue[bgTypeId].empty() ? NULL : BGFreeSlotQueue[bgTypeId].back();
} }
// create a new battleground that will really be used to play // create a new battleground that will really be used to play
BattleGround * BattleGroundMgr::CreateNewBattleGround(uint32 bgTypeId) BattleGround * BattleGroundMgr::CreateNewBattleGround(BattleGroundTypeId bgTypeId)
{ {
BattleGround *bg = NULL;
// get the template BG // get the template BG
BattleGround *bg_template = GetBattleGroundTemplate(bgTypeId); BattleGround *bg_template = GetBattleGroundTemplate(bgTypeId);
if(!bg_template) if(!bg_template)
{ {
sLog.outError("BattleGround: CreateNewBattleGround - bg template not found for %u", bgTypeId); sLog.outError("BattleGround: CreateNewBattleGround - bg template not found for %u", bgTypeId);
return 0; return NULL;
} }
BattleGround *bg = NULL;
// create a copy of the BG template // create a copy of the BG template
switch(bgTypeId) switch(bgTypeId)
{ {
@@ -1460,7 +1458,7 @@ BattleGround * BattleGroundMgr::CreateNewBattleGround(uint32 bgTypeId)
} }
// used to create the BG templates // used to create the BG templates
uint32 BattleGroundMgr::CreateBattleGround(uint32 bgTypeId, 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 BattleGroundMgr::CreateBattleGround(BattleGroundTypeId bgTypeId, 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)
{ {
// Create the BG // Create the BG
BattleGround *bg = NULL; BattleGround *bg = NULL;
@@ -1543,16 +1541,18 @@ void BattleGroundMgr::CreateInitialBattleGrounds()
Field *fields = result->Fetch(); Field *fields = result->Fetch();
bar.step(); bar.step();
uint32 bgTypeID = fields[0].GetUInt32(); uint32 bgTypeID_ = fields[0].GetUInt32();
// can be overwrited by values from DB // can be overwrite by values from DB
bl = sBattlemasterListStore.LookupEntry(bgTypeID); bl = sBattlemasterListStore.LookupEntry(bgTypeID_);
if(!bl) if(!bl)
{ {
sLog.outError("Battleground ID %u not found in BattlemasterList.dbc. Battleground not created.",bgTypeID); sLog.outError("Battleground ID %u not found in BattlemasterList.dbc. Battleground not created.",bgTypeID_);
continue; continue;
} }
BattleGroundTypeId bgTypeID = BattleGroundTypeId(bgTypeID_);
MaxPlayersPerTeam = bl->maxplayersperteam; MaxPlayersPerTeam = bl->maxplayersperteam;
MinPlayersPerTeam = bl->maxplayersperteam/2; MinPlayersPerTeam = bl->maxplayersperteam/2;
MinLvl = bl->minlvl; MinLvl = bl->minlvl;
@@ -1700,7 +1700,7 @@ void BattleGroundMgr::DistributeArenaPoints()
sWorld.SendGlobalText("Done flushing Arena points.", NULL); sWorld.SendGlobalText("Done flushing Arena points.", NULL);
} }
void BattleGroundMgr::BuildBattleGroundListPacket(WorldPacket *data, const uint64& guid, Player* plr, uint32 bgTypeId) void BattleGroundMgr::BuildBattleGroundListPacket(WorldPacket *data, const uint64& guid, Player* plr, BattleGroundTypeId bgTypeId)
{ {
uint32 PlayerLevel = 10; uint32 PlayerLevel = 10;
@@ -1766,7 +1766,7 @@ void BattleGroundMgr::SendAreaSpiritHealerQueryOpcode(Player *pl, BattleGround *
pl->GetSession()->SendPacket(&data); pl->GetSession()->SendPacket(&data);
} }
bool BattleGroundMgr::IsArenaType(uint32 bgTypeId) bool BattleGroundMgr::IsArenaType(BattleGroundTypeId bgTypeId)
{ {
return ( bgTypeId == BATTLEGROUND_AA || return ( bgTypeId == BATTLEGROUND_AA ||
bgTypeId == BATTLEGROUND_BE || bgTypeId == BATTLEGROUND_BE ||
@@ -1774,7 +1774,7 @@ bool BattleGroundMgr::IsArenaType(uint32 bgTypeId)
bgTypeId == BATTLEGROUND_RL ); bgTypeId == BATTLEGROUND_RL );
} }
uint32 BattleGroundMgr::BGQueueTypeId(uint32 bgTypeId, uint8 arenaType) uint32 BattleGroundMgr::BGQueueTypeId(BattleGroundTypeId bgTypeId, uint8 arenaType)
{ {
switch(bgTypeId) switch(bgTypeId)
{ {
@@ -1810,7 +1810,7 @@ uint32 BattleGroundMgr::BGQueueTypeId(uint32 bgTypeId, uint8 arenaType)
} }
} }
uint32 BattleGroundMgr::BGTemplateId(uint32 bgQueueTypeId) BattleGroundTypeId BattleGroundMgr::BGTemplateId(uint32 bgQueueTypeId)
{ {
switch(bgQueueTypeId) switch(bgQueueTypeId)
{ {
@@ -1829,7 +1829,7 @@ uint32 BattleGroundMgr::BGTemplateId(uint32 bgQueueTypeId)
case BATTLEGROUND_QUEUE_5v5: case BATTLEGROUND_QUEUE_5v5:
return BATTLEGROUND_AA; return BATTLEGROUND_AA;
default: default:
return 0; return BattleGroundTypeId(0); // used for unknown template (it existed and do nothing)
} }
} }
@@ -1859,11 +1859,71 @@ void BattleGroundMgr::ToggleArenaTesting()
void BattleGroundMgr::SetHolidayWeekends(uint32 mask) void BattleGroundMgr::SetHolidayWeekends(uint32 mask)
{ {
for(uint32 bgtype = 1; bgtype <= 8; ++bgtype) for(uint32 bgtype = 1; bgtype < MAX_BATTLEGROUND_TYPE_ID; ++bgtype)
{ {
if(BattleGround * bg = GetBattleGroundTemplate(bgtype)) if(BattleGround * bg = GetBattleGroundTemplate(BattleGroundTypeId(bgtype)))
{ {
bg->SetHoliday(mask & (1 << bgtype)); bg->SetHoliday(mask & (1 << bgtype));
} }
} }
} }
uint32 BattleGroundMgr::GetMaxRatingDifference() const
{
return sWorld.getConfig(CONFIG_ARENA_MAX_RATING_DIFFERENCE);
}
uint32 BattleGroundMgr::GetRatingDiscardTimer() const
{
return sWorld.getConfig(CONFIG_ARENA_RATING_DISCARD_TIMER);
}
uint32 BattleGroundMgr::GetPrematureFinishTime() const
{
return sWorld.getConfig(CONFIG_BATTLEGROUND_PREMATURE_FINISH_TIMER);
}
void BattleGroundMgr::LoadBattleMastersEntry()
{
mBattleMastersMap.clear(); // need for reload case
QueryResult *result = WorldDatabase.Query( "SELECT entry,bg_template FROM battlemaster_entry" );
uint32 count = 0;
if( !result )
{
barGoLink bar( 1 );
bar.step();
sLog.outString();
sLog.outString( ">> Loaded 0 battlemaster entries - table is empty!" );
return;
}
barGoLink bar( result->GetRowCount() );
do
{
++count;
bar.step();
Field *fields = result->Fetch();
uint32 entry = fields[0].GetUInt32();
uint32 bgTypeId = fields[1].GetUInt32();
if (!sBattlemasterListStore.LookupEntry(bgTypeId))
{
sLog.outErrorDb("Table `battlemaster_entry` contain entry %u for not existed battleground type %u, ignored.",entry,bgTypeId);
continue;
}
mBattleMastersMap[entry] = BattleGroundTypeId(bgTypeId);
} while( result->NextRow() );
delete result;
sLog.outString();
sLog.outString( ">> Loaded %u battlemaster entries", count );
}
+34 -27
View File
@@ -21,10 +21,8 @@
#ifndef __BATTLEGROUNDMGR_H #ifndef __BATTLEGROUNDMGR_H
#define __BATTLEGROUNDMGR_H #define __BATTLEGROUNDMGR_H
#include "Common.h"
#include "BattleGround.h" #include "BattleGround.h"
#include "World.h"
class BattleGround;
//TODO it is not possible to have this structure, because we should have BattlegroundSet for each queue //TODO it is not possible to have this structure, because we should have BattlegroundSet for each queue
//so i propose to change this type to array 1..MAX_BATTLEGROUND_TYPES of sets or maps.. //so i propose to change this type to array 1..MAX_BATTLEGROUND_TYPES of sets or maps..
@@ -32,9 +30,9 @@ typedef std::map<uint32, BattleGround*> BattleGroundSet;
//typedef std::map<uint32, BattleGroundQueue*> BattleGroundQueueSet; //typedef std::map<uint32, BattleGroundQueue*> BattleGroundQueueSet;
typedef std::deque<BattleGround*> BGFreeSlotQueueType; typedef std::deque<BattleGround*> BGFreeSlotQueueType;
#define MAX_BATTLEGROUND_QUEUES 8 // for level ranges 10-19, 20-29, 30-39, 40-49, 50-59, 60-69, 70-79, 80+ typedef UNORDERED_MAP<uint32, BattleGroundTypeId> BattleMastersMap;
#define MAX_BATTLEGROUND_TYPES 12 // each BG type will be in array #define MAX_BATTLEGROUND_QUEUES 8 // for level ranges 10-19, 20-29, 30-39, 40-49, 50-59, 60-69, 70-79, 80+
#define MAX_BATTLEGROUND_QUEUE_TYPES 9 #define MAX_BATTLEGROUND_QUEUE_TYPES 9
@@ -53,7 +51,7 @@ struct GroupQueueInfo // stores informatio
{ {
std::map<uint64, PlayerQueueInfo*> Players; // player queue info map std::map<uint64, PlayerQueueInfo*> Players; // player queue info map
uint32 Team; // Player team (ALLIANCE/HORDE) uint32 Team; // Player team (ALLIANCE/HORDE)
uint32 BgTypeId; // battleground type id BattleGroundTypeId BgTypeId; // battleground type id
bool IsRated; // rated bool IsRated; // rated
uint8 ArenaType; // 2v2, 3v3, 5v5 or 0 when BG uint8 ArenaType; // 2v2, 3v3, 5v5 or 0 when BG
uint32 ArenaTeamId; // team id if rated match uint32 ArenaTeamId; // team id if rated match
@@ -70,9 +68,9 @@ class BattleGroundQueue
BattleGroundQueue(); BattleGroundQueue();
~BattleGroundQueue(); ~BattleGroundQueue();
void Update(uint32 bgTypeId, uint32 queue_id, uint8 arenatype = 0, bool isRated = false, uint32 minRating = 0); void Update(BattleGroundTypeId bgTypeId, uint32 queue_id, uint8 arenatype = 0, bool isRated = false, uint32 minRating = 0);
GroupQueueInfo * AddGroup(Player * leader, uint32 BgTypeId, uint8 ArenaType, bool isRated, uint32 ArenaRating, uint32 ArenaTeamId = 0); GroupQueueInfo * AddGroup(Player * leader, BattleGroundTypeId bgTypeId, uint8 ArenaType, bool isRated, uint32 ArenaRating, uint32 ArenaTeamId = 0);
void AddPlayer(Player *plr, GroupQueueInfo *ginfo); void AddPlayer(Player *plr, GroupQueueInfo *ginfo);
void RemovePlayer(const uint64& guid, bool decreaseInvitedCount); void RemovePlayer(const uint64& guid, bool decreaseInvitedCount);
void DecreaseGroupLength(uint32 queueId, uint32 AsGroup); void DecreaseGroupLength(uint32 queueId, uint32 AsGroup);
@@ -89,7 +87,7 @@ class BattleGroundQueue
class EligibleGroups : public std::list<GroupQueueInfo *> class EligibleGroups : public std::list<GroupQueueInfo *>
{ {
public: public:
void Init(QueuedGroupsList * source, uint32 BgTypeId, uint32 side, uint32 MaxPlayers, uint8 ArenaType = 0, bool IsRated = false, uint32 MinRating = 0, uint32 MaxRating = 0, uint32 DisregardTime = 0, uint32 excludeTeam = 0); void Init(QueuedGroupsList * source, BattleGroundTypeId BgTypeId, uint32 side, uint32 MaxPlayers, uint8 ArenaType = 0, bool IsRated = false, uint32 MinRating = 0, uint32 MaxRating = 0, uint32 DisregardTime = 0, uint32 excludeTeam = 0);
}; };
EligibleGroups m_EligibleGroups; EligibleGroups m_EligibleGroups;
@@ -124,7 +122,7 @@ class BattleGroundQueue
SelectionPool m_SelectionPools[NUM_SELECTION_POOL_TYPES]; SelectionPool m_SelectionPools[NUM_SELECTION_POOL_TYPES];
bool BuildSelectionPool(uint32 bgTypeId, uint32 queue_id, uint32 MinPlayers, uint32 MaxPlayers, SelectionPoolBuildMode mode, uint8 ArenaType = 0, bool isRated = false, uint32 MinRating = 0, uint32 MaxRating = 0, uint32 DisregardTime = 0, uint32 excludeTeam = 0); bool BuildSelectionPool(BattleGroundTypeId bgTypeId, uint32 queue_id, uint32 MinPlayers, uint32 MaxPlayers, SelectionPoolBuildMode mode, uint8 ArenaType = 0, bool isRated = false, uint32 MinRating = 0, uint32 MaxRating = 0, uint32 DisregardTime = 0, uint32 excludeTeam = 0);
private: private:
@@ -179,8 +177,8 @@ class BattleGroundMgr
/* Packet Building */ /* Packet Building */
void BuildPlayerJoinedBattleGroundPacket(WorldPacket *data, Player *plr); void BuildPlayerJoinedBattleGroundPacket(WorldPacket *data, Player *plr);
void BuildPlayerLeftBattleGroundPacket(WorldPacket *data, Player *plr); void BuildPlayerLeftBattleGroundPacket(WorldPacket *data, Player *plr);
void BuildBattleGroundListPacket(WorldPacket *data, const uint64& guid, Player *plr, uint32 bgTypeId); void BuildBattleGroundListPacket(WorldPacket *data, const uint64& guid, Player *plr, BattleGroundTypeId bgTypeId);
void BuildGroupJoinedBattlegroundPacket(WorldPacket *data, uint32 bgTypeId); void BuildGroupJoinedBattlegroundPacket(WorldPacket *data, BattleGroundTypeId bgTypeId);
void BuildUpdateWorldStatePacket(WorldPacket *data, uint32 field, uint32 value); void BuildUpdateWorldStatePacket(WorldPacket *data, uint32 field, uint32 value);
void BuildPvpLogDataPacket(WorldPacket *data, BattleGround *bg); void BuildPvpLogDataPacket(WorldPacket *data, BattleGround *bg);
void BuildBattleGroundStatusPacket(WorldPacket *data, BattleGround *bg, uint32 team, uint8 QueueSlot, uint8 StatusID, uint32 Time1, uint32 Time2, uint32 arenatype = 0, uint8 israted = 0); void BuildBattleGroundStatusPacket(WorldPacket *data, BattleGround *bg, uint32 team, uint8 QueueSlot, uint8 StatusID, uint32 Time1, uint32 Time2, uint32 arenatype = 0, uint8 israted = 0);
@@ -195,48 +193,57 @@ class BattleGroundMgr
BattleGroundSet::iterator GetBattleGroundsBegin() { return m_BattleGrounds.begin(); }; BattleGroundSet::iterator GetBattleGroundsBegin() { return m_BattleGrounds.begin(); };
BattleGroundSet::iterator GetBattleGroundsEnd() { return m_BattleGrounds.end(); }; BattleGroundSet::iterator GetBattleGroundsEnd() { return m_BattleGrounds.end(); };
BattleGround* GetBattleGround(uint32 ID) BattleGround* GetBattleGround(uint32 InstanceID)
{ {
BattleGroundSet::iterator i = m_BattleGrounds.find(ID); BattleGroundSet::iterator i = m_BattleGrounds.find(InstanceID);
return ( (i != m_BattleGrounds.end()) ? i->second : NULL ); return ( (i != m_BattleGrounds.end()) ? i->second : NULL );
}; };
BattleGround * GetBattleGroundTemplate(uint32 bgTypeId); BattleGround * GetBattleGroundTemplate(BattleGroundTypeId bgTypeId);
BattleGround * CreateNewBattleGround(uint32 bgTypeId); BattleGround * CreateNewBattleGround(BattleGroundTypeId bgTypeId);
uint32 CreateBattleGround(uint32 bgTypeId, 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 CreateBattleGround(BattleGroundTypeId bgTypeId, 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);
void AddBattleGround(uint32 ID, BattleGround* BG) { m_BattleGrounds[ID] = BG; }; void AddBattleGround(uint32 InstanceID, BattleGround* BG) { m_BattleGrounds[InstanceID] = BG; };
void RemoveBattleGround(uint32 instanceID) { m_BattleGrounds.erase(instanceID); } void RemoveBattleGround(uint32 instanceID) { m_BattleGrounds.erase(instanceID); }
void CreateInitialBattleGrounds(); void CreateInitialBattleGrounds();
void SendToBattleGround(Player *pl, uint32 bgTypeId); void SendToBattleGround(Player *pl, uint32 InstanceID);
/* Battleground queues */ /* Battleground queues */
//these queues are instantiated when creating BattlegroundMrg //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 BattleGroundQueue m_BattleGroundQueues[MAX_BATTLEGROUND_QUEUE_TYPES]; // public, because we need to access them in BG handler code
BGFreeSlotQueueType BGFreeSlotQueue[MAX_BATTLEGROUND_TYPES]; BGFreeSlotQueueType BGFreeSlotQueue[MAX_BATTLEGROUND_TYPE_ID];
uint32 GetMaxRatingDifference() const { return sWorld.getConfig(CONFIG_ARENA_MAX_RATING_DIFFERENCE); } uint32 GetMaxRatingDifference() const;
uint32 GetRatingDiscardTimer() const { return sWorld.getConfig(CONFIG_ARENA_RATING_DISCARD_TIMER); } uint32 GetRatingDiscardTimer() const;
uint32 GetPrematureFinishTime() const { return sWorld.getConfig(CONFIG_BATTLEGROUND_PREMATURE_FINISH_TIMER); } uint32 GetPrematureFinishTime() const;
void InitAutomaticArenaPointDistribution(); void InitAutomaticArenaPointDistribution();
void DistributeArenaPoints(); void DistributeArenaPoints();
void ToggleArenaTesting(); void ToggleArenaTesting();
void SetHolidayWeekends(uint32 mask); 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 isArenaTesting() const { return m_ArenaTesting; }
static bool IsArenaType(uint32 bgTypeId); static bool IsArenaType(BattleGroundTypeId bgTypeId);
static bool IsBattleGroundType(uint32 bgTypeId) { return !BattleGroundMgr::IsArenaType(bgTypeId); } static bool IsBattleGroundType(BattleGroundTypeId bgTypeId) { return !BattleGroundMgr::IsArenaType(bgTypeId); }
static uint32 BGQueueTypeId(uint32 bgTypeId, uint8 arenaType); static uint32 BGQueueTypeId(BattleGroundTypeId bgTypeId, uint8 arenaType);
static uint32 BGTemplateId(uint32 bgQueueTypeId); static BattleGroundTypeId BGTemplateId(uint32 bgQueueTypeId);
static uint8 BGArenaType(uint32 bgQueueTypeId); static uint8 BGArenaType(uint32 bgQueueTypeId);
private: private:
BattleMastersMap mBattleMastersMap;
/* Battlegrounds */ /* Battlegrounds */
BattleGroundSet m_BattleGrounds; BattleGroundSet m_BattleGrounds;
+1
View File
@@ -25,6 +25,7 @@
#include "Creature.h" #include "Creature.h"
#include "ObjectMgr.h" #include "ObjectMgr.h"
#include "MapManager.h" #include "MapManager.h"
#include "WorldPacket.h"
#include "Language.h" #include "Language.h"
BattleGroundNA::BattleGroundNA() BattleGroundNA::BattleGroundNA()
+1
View File
@@ -26,6 +26,7 @@
#include "ObjectMgr.h" #include "ObjectMgr.h"
#include "MapManager.h" #include "MapManager.h"
#include "Language.h" #include "Language.h"
#include "WorldPacket.h"
BattleGroundRL::BattleGroundRL() BattleGroundRL::BattleGroundRL()
{ {
+1
View File
@@ -18,6 +18,7 @@
#include "BattleGround.h" #include "BattleGround.h"
#include "BattleGroundSA.h" #include "BattleGroundSA.h"
#include "Player.h"
BattleGroundSA::BattleGroundSA() BattleGroundSA::BattleGroundSA()
{ {
+2
View File
@@ -26,6 +26,8 @@
#include "GameObject.h" #include "GameObject.h"
#include "Chat.h" #include "Chat.h"
#include "MapManager.h" #include "MapManager.h"
#include "ObjectMgr.h"
#include "WorldPacket.h"
#include "Language.h" #include "Language.h"
#include "World.h" #include "World.h"
+3 -3
View File
@@ -39,7 +39,7 @@
#include "SpellAuras.h" #include "SpellAuras.h"
#include "WaypointMovementGenerator.h" #include "WaypointMovementGenerator.h"
#include "InstanceData.h" #include "InstanceData.h"
#include "BattleGround.h" #include "BattleGroundMgr.h"
#include "Util.h" #include "Util.h"
#include "GridNotifiers.h" #include "GridNotifiers.h"
#include "GridNotifiersImpl.h" #include "GridNotifiersImpl.h"
@@ -760,7 +760,7 @@ bool Creature::isCanInteractWithBattleMaster(Player* pPlayer, bool msg) const
if(!isBattleMaster()) if(!isBattleMaster())
return false; return false;
uint32 bgTypeId = objmgr.GetBattleMasterBG(GetEntry()); BattleGroundTypeId bgTypeId = sBattleGroundMgr.GetBattleMasterBG(GetEntry());
if(!msg) if(!msg)
return pPlayer->GetBGAccessByLevel(bgTypeId); return pPlayer->GetBGAccessByLevel(bgTypeId);
@@ -1027,7 +1027,7 @@ void Creature::OnGossipSelect(Player* player, uint32 option)
break; break;
case GOSSIP_OPTION_BATTLEFIELD: case GOSSIP_OPTION_BATTLEFIELD:
{ {
uint32 bgTypeId = objmgr.GetBattleMasterBG(GetEntry()); BattleGroundTypeId bgTypeId = sBattleGroundMgr.GetBattleMasterBG(GetEntry());
player->GetSession()->SendBattlegGroundList( GetGUID(), bgTypeId ); player->GetSession()->SendBattlegGroundList( GetGUID(), bgTypeId );
break; break;
} }
+1 -1
View File
@@ -1333,7 +1333,7 @@ void Group::UpdateLooterGuid( Creature* creature, bool ifneed )
SendUpdate(); SendUpdate();
} }
uint32 Group::CanJoinBattleGroundQueue(uint32 bgTypeId, uint32 bgQueueType, uint32 MinPlayerCount, uint32 MaxPlayerCount, bool isRated, uint32 arenaSlot) uint32 Group::CanJoinBattleGroundQueue(BattleGroundTypeId bgTypeId, uint32 bgQueueType, uint32 MinPlayerCount, uint32 MaxPlayerCount, bool isRated, uint32 arenaSlot)
{ {
// check for min / max count // check for min / max count
uint32 memberscount = GetMembersCount(); uint32 memberscount = GetMembersCount();
+1 -1
View File
@@ -250,7 +250,7 @@ class TRINITY_DLL_SPEC Group
void ConvertToRaid(); void ConvertToRaid();
void SetBattlegroundGroup(BattleGround *bg) { m_bgGroup = bg; } void SetBattlegroundGroup(BattleGround *bg) { m_bgGroup = bg; }
uint32 CanJoinBattleGroundQueue(uint32 bgTypeId, uint32 bgQueueType, uint32 MinPlayerCount, uint32 MaxPlayerCount, bool isRated, uint32 arenaSlot); uint32 CanJoinBattleGroundQueue(BattleGroundTypeId bgTypeId, uint32 bgQueueType, uint32 MinPlayerCount, uint32 MaxPlayerCount, bool isRated, uint32 arenaSlot);
void ChangeMembersGroup(const uint64 &guid, const uint8 &group); void ChangeMembersGroup(const uint64 &guid, const uint8 &group);
void ChangeMembersGroup(Player *player, const uint8 &group); void ChangeMembersGroup(Player *player, const uint8 &group);
+2 -2
View File
@@ -56,12 +56,12 @@
bool ChatHandler::HandleAHBotOptionsCommand(const char* args) bool ChatHandler::HandleAHBotOptionsCommand(const char* args)
{ {
uint32 ahMapID = 0; AuctionLocation ahMapID = AUCTION_NEUTRAL;
char * opt = strtok((char*)args, " "); char * opt = strtok((char*)args, " ");
char * ahMapIdStr = strtok(NULL, " "); char * ahMapIdStr = strtok(NULL, " ");
if (ahMapIdStr) if (ahMapIdStr)
{ {
ahMapID = (uint32) strtoul(ahMapIdStr, NULL, 0); ahMapID = (AuctionLocation) strtoul(ahMapIdStr, NULL, 0);
} }
if (!opt) if (!opt)
{ {
+1
View File
@@ -31,6 +31,7 @@
#include "BattleGround.h" #include "BattleGround.h"
#include "WaypointMovementGenerator.h" #include "WaypointMovementGenerator.h"
#include "InstanceSaveMgr.h" #include "InstanceSaveMgr.h"
#include "ObjectMgr.h"
void WorldSession::HandleMoveWorldportAckOpcode( WorldPacket & /*recv_data*/ ) void WorldSession::HandleMoveWorldportAckOpcode( WorldPacket & /*recv_data*/ )
{ {
+25 -57
View File
@@ -327,14 +327,14 @@ void ObjectMgr::RemoveArenaTeam(ArenaTeam* arenaTeam)
mArenaTeamMap.erase( arenaTeam->GetId() ); mArenaTeamMap.erase( arenaTeam->GetId() );
} }
AuctionHouseObject * ObjectMgr::GetAuctionsMap( uint32 location ) AuctionHouseObject * ObjectMgr::GetAuctionsMap( AuctionLocation location )
{ {
switch ( location ) switch ( location )
{ {
case 6: //horde case AUCTION_HORDE:
return & mHordeAuctions; return & mHordeAuctions;
break; break;
case 2: //alliance case AUCTION_ALLIANCE:
return & mAllianceAuctions; return & mAllianceAuctions;
break; break;
default: //neutral default: //neutral
@@ -342,18 +342,18 @@ AuctionHouseObject * ObjectMgr::GetAuctionsMap( uint32 location )
} }
} }
uint32 ObjectMgr::GetAuctionCut(uint32 location, uint32 highBid) uint32 ObjectMgr::GetAuctionCut(AuctionLocation location, uint32 highBid)
{ {
if (location == 7 && !sWorld.getConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_AUCTION)) if (location == AUCTION_NEUTRAL && !sWorld.getConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_AUCTION))
return (uint32) (0.15f * highBid * sWorld.getRate(RATE_AUCTION_CUT)); return (uint32) (0.15f * highBid * sWorld.getRate(RATE_AUCTION_CUT));
else else
return (uint32) (0.05f * highBid * sWorld.getRate(RATE_AUCTION_CUT)); return (uint32) (0.05f * highBid * sWorld.getRate(RATE_AUCTION_CUT));
} }
uint32 ObjectMgr::GetAuctionDeposit(uint32 location, uint32 time, Item *pItem) uint32 ObjectMgr::GetAuctionDeposit(AuctionLocation location, uint32 time, Item *pItem)
{ {
float percentance; // in 0..1 float percentance; // in 0..1
if ( location == 7 && !sWorld.getConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_AUCTION)) if (location == AUCTION_NEUTRAL && !sWorld.getConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_AUCTION))
percentance = 0.75f; percentance = 0.75f;
else else
percentance = 0.15f; percentance = 0.15f;
@@ -1660,18 +1660,31 @@ void ObjectMgr::LoadAuctions()
aItem->bid = fields[8].GetUInt32(); aItem->bid = fields[8].GetUInt32();
aItem->startbid = fields[9].GetUInt32(); aItem->startbid = fields[9].GetUInt32();
aItem->deposit = fields[10].GetUInt32(); aItem->deposit = fields[10].GetUInt32();
aItem->location = fields[11].GetUInt8();
//check if sold item exists uint32 loc = fields[11].GetUInt8();
if ( GetAItem( aItem->item_guidlow ) ) if(!IsValidAuctionLocation(loc))
{ {
GetAuctionsMap( aItem->location )->AddAuction(aItem); CharacterDatabase.PExecute("DELETE FROM auctionhouse WHERE id = '%u'",aItem->Id);
sLog.outError("Auction %u has wrong auction location (%u)", aItem->Id, loc);
delete aItem;
continue;
} }
else aItem->location = AuctionLocation(loc);
// check if sold item exists for guid
// and item_template in fact (GetAItem will fail if problematic in result check in ObjectMgr::LoadAuctionItems)
if ( !GetAItem( aItem->item_guidlow ) )
{ {
CharacterDatabase.PExecute("DELETE FROM auctionhouse WHERE id = '%u'",aItem->Id); CharacterDatabase.PExecute("DELETE FROM auctionhouse WHERE id = '%u'",aItem->Id);
sLog.outError("Auction %u has not a existing item : %u", aItem->Id, aItem->item_guidlow); sLog.outError("Auction %u has not a existing item : %u", aItem->Id, aItem->item_guidlow);
delete aItem; delete aItem;
continue;
} }
if(aItem->location)
GetAuctionsMap( aItem->location )->AddAuction(aItem);
} while (result->NextRow()); } while (result->NextRow());
delete result; delete result;
@@ -6721,51 +6734,6 @@ int ObjectMgr::GetOrNewIndexForLocale( LocaleConstant loc )
return m_LocalForIndex.size()-1; return m_LocalForIndex.size()-1;
} }
void ObjectMgr::LoadBattleMastersEntry()
{
mBattleMastersMap.clear(); // need for reload case
QueryResult *result = WorldDatabase.Query( "SELECT entry,bg_template FROM battlemaster_entry" );
uint32 count = 0;
if( !result )
{
barGoLink bar( 1 );
bar.step();
sLog.outString();
sLog.outString( ">> Loaded 0 battlemaster entries - table is empty!" );
return;
}
barGoLink bar( result->GetRowCount() );
do
{
++count;
bar.step();
Field *fields = result->Fetch();
uint32 entry = fields[0].GetUInt32();
uint32 bgTypeId = fields[1].GetUInt32();
if (bgTypeId >= MAX_BATTLEGROUND_TYPE_ID)
{
sLog.outErrorDb("Table `battlemaster_entry` contain entry %u for not existed battleground type %u, ignored.",entry,bgTypeId);
continue;
}
mBattleMastersMap[entry] = bgTypeId;
} while( result->NextRow() );
delete result;
sLog.outString();
sLog.outString( ">> Loaded %u battlemaster entries", count );
}
void ObjectMgr::LoadGameObjectForQuests() void ObjectMgr::LoadGameObjectForQuests()
{ {
mGameObjectForQuestSet.clear(); // need for reload case mGameObjectForQuestSet.clear(); // need for reload case
+3 -14
View File
@@ -399,15 +399,15 @@ class ObjectMgr
mAitems.erase(i); mAitems.erase(i);
return true; return true;
} }
AuctionHouseObject * GetAuctionsMap( uint32 location ); AuctionHouseObject * GetAuctionsMap( AuctionLocation location );
//auction messages //auction messages
void SendAuctionWonMail( AuctionEntry * auction ); void SendAuctionWonMail( AuctionEntry * auction );
void SendAuctionSalePendingMail( AuctionEntry * auction ); void SendAuctionSalePendingMail( AuctionEntry * auction );
void SendAuctionSuccessfulMail( AuctionEntry * auction ); void SendAuctionSuccessfulMail( AuctionEntry * auction );
void SendAuctionExpiredMail( AuctionEntry * auction ); void SendAuctionExpiredMail( AuctionEntry * auction );
static uint32 GetAuctionCut( uint32 location, uint32 highBid ); static uint32 GetAuctionCut( AuctionLocation location, uint32 highBid );
static uint32 GetAuctionDeposit(uint32 location, uint32 time, Item *pItem); static uint32 GetAuctionDeposit(AuctionLocation location, uint32 time, Item *pItem);
static uint32 GetAuctionOutBid(uint32 currentBid); static uint32 GetAuctionOutBid(uint32 currentBid);
PetLevelInfo const* GetPetLevelInfo(uint32 creature_id, uint32 level) const; PetLevelInfo const* GetPetLevelInfo(uint32 creature_id, uint32 level) const;
@@ -465,14 +465,6 @@ class ObjectMgr
return false; return false;
} }
uint32 GetBattleMasterBG(uint32 entry) const
{
BattleMastersMap::const_iterator itr = mBattleMastersMap.find(entry);
if(itr != mBattleMastersMap.end())
return itr->second;
return 2; //BATTLEGROUND_WS - i will not add include only for constant usage!
}
void AddGossipText(GossipText *pGText); void AddGossipText(GossipText *pGText);
GossipText *GetGossipText(uint32 Text_ID); GossipText *GetGossipText(uint32 Text_ID);
@@ -569,7 +561,6 @@ class ObjectMgr
void LoadQuestAreaTriggers(); void LoadQuestAreaTriggers();
void LoadAreaTriggerScripts(); void LoadAreaTriggerScripts();
void LoadTavernAreaTriggers(); void LoadTavernAreaTriggers();
void LoadBattleMastersEntry();
void LoadGameObjectForQuests(); void LoadGameObjectForQuests();
void LoadItemTexts(); void LoadItemTexts();
@@ -836,7 +827,6 @@ class ObjectMgr
typedef UNORDERED_MAP<uint32, GossipText*> GossipTextMap; typedef UNORDERED_MAP<uint32, GossipText*> GossipTextMap;
typedef UNORDERED_MAP<uint32, uint32> QuestAreaTriggerMap; typedef UNORDERED_MAP<uint32, uint32> QuestAreaTriggerMap;
typedef UNORDERED_MAP<uint32, uint32> BattleMastersMap;
typedef UNORDERED_MAP<uint32, std::string> ItemTextMap; typedef UNORDERED_MAP<uint32, std::string> ItemTextMap;
typedef std::set<uint32> TavernAreaTriggerSet; typedef std::set<uint32> TavernAreaTriggerSet;
typedef std::set<uint32> GameObjectForQuestSet; typedef std::set<uint32> GameObjectForQuestSet;
@@ -855,7 +845,6 @@ class ObjectMgr
AuctionHouseObject mNeutralAuctions; AuctionHouseObject mNeutralAuctions;
QuestAreaTriggerMap mQuestAreaTriggerMap; QuestAreaTriggerMap mQuestAreaTriggerMap;
BattleMastersMap mBattleMastersMap;
TavernAreaTriggerSet mTavernAreaTriggerSet; TavernAreaTriggerSet mTavernAreaTriggerSet;
GameObjectForQuestSet mGameObjectForQuestSet; GameObjectForQuestSet mGameObjectForQuestSet;
GossipTextMap mGossipText; GossipTextMap mGossipText;
+1 -1
View File
@@ -18958,7 +18958,7 @@ bool Player::InArena() const
return true; return true;
} }
bool Player::GetBGAccessByLevel(uint32 bgTypeId) const bool Player::GetBGAccessByLevel(BattleGroundTypeId bgTypeId) const
{ {
// get a template bg instead of running one // get a template bg instead of running one
BattleGround *bg = sBattleGroundMgr.GetBattleGroundTemplate(bgTypeId); BattleGround *bg = sBattleGroundMgr.GetBattleGroundTemplate(bgTypeId);
+1 -1
View File
@@ -1962,7 +1962,7 @@ class TRINITY_DLL_SPEC Player : public Unit
void ReportedAfkBy(Player* reporter); void ReportedAfkBy(Player* reporter);
void ClearAfkReports() { m_bgAfkReporter.clear(); } void ClearAfkReports() { m_bgAfkReporter.clear(); }
bool GetBGAccessByLevel(uint32 bgTypeId) const; bool GetBGAccessByLevel(BattleGroundTypeId bgTypeId) const;
bool isAllowUseBattleGroundObject(); bool isAllowUseBattleGroundObject();
bool isTotalImmunity(); bool isTotalImmunity();
+18
View File
@@ -2292,4 +2292,22 @@ enum BanReturn
BAN_SYNTAX_ERROR, BAN_SYNTAX_ERROR,
BAN_NOTFOUND BAN_NOTFOUND
}; };
// indexes of BattlemasterList.dbc
enum BattleGroundTypeId
{
BATTLEGROUND_AV = 1,
BATTLEGROUND_WS = 2,
BATTLEGROUND_AB = 3,
BATTLEGROUND_NA = 4,
BATTLEGROUND_BE = 5,
BATTLEGROUND_AA = 6,
BATTLEGROUND_EY = 7,
BATTLEGROUND_RL = 8,
BATTLEGROUND_SA = 9,
BATTLEGROUND_DS = 10,
BATTLEGROUND_RV = 11
};
#define MAX_BATTLEGROUND_TYPE_ID 12
#endif #endif
+1
View File
@@ -47,6 +47,7 @@
#include "Creature.h" #include "Creature.h"
#include "Totem.h" #include "Totem.h"
#include "CreatureAI.h" #include "CreatureAI.h"
#include "BattleGroundMgr.h"
#include "BattleGround.h" #include "BattleGround.h"
#include "BattleGroundEY.h" #include "BattleGroundEY.h"
#include "BattleGroundWS.h" #include "BattleGroundWS.h"
+4 -4
View File
@@ -1338,7 +1338,7 @@ void World::SetInitialWorldSettings()
objmgr.LoadGameObjectForQuests(); objmgr.LoadGameObjectForQuests();
sLog.outString( "Loading BattleMasters..." ); sLog.outString( "Loading BattleMasters..." );
objmgr.LoadBattleMastersEntry(); sBattleGroundMgr.LoadBattleMastersEntry();
sLog.outString( "Loading GameTeleports..." ); sLog.outString( "Loading GameTeleports..." );
objmgr.LoadGameTele(); objmgr.LoadGameTele();
@@ -1585,13 +1585,13 @@ void World::Update(uint32 diff)
switch (i) switch (i)
{ {
case 0: case 0:
AuctionMap = objmgr.GetAuctionsMap( 6 );//horde AuctionMap = objmgr.GetAuctionsMap(AUCTION_HORDE);
break; break;
case 1: case 1:
AuctionMap = objmgr.GetAuctionsMap( 2 );//alliance AuctionMap = objmgr.GetAuctionsMap(AUCTION_ALLIANCE);
break; break;
case 2: case 2:
AuctionMap = objmgr.GetAuctionsMap( 7 );//neutral AuctionMap = objmgr.GetAuctionsMap(AUCTION_NEUTRAL);
break; break;
} }
+2 -1
View File
@@ -26,6 +26,7 @@
#define __WORLDSESSION_H #define __WORLDSESSION_H
#include "Common.h" #include "Common.h"
#include "SharedDefines.h"
class MailItemsInfo; class MailItemsInfo;
struct ItemPrototype; struct ItemPrototype;
@@ -153,7 +154,7 @@ class TRINITY_DLL_SPEC WorldSession
void SendAttackStop(Unit const* enemy); void SendAttackStop(Unit const* enemy);
void SendBattlegGroundList( uint64 guid, uint32 bgTypeId ); void SendBattlegGroundList( uint64 guid, BattleGroundTypeId bgTypeId );
void SendTradeStatus(uint32 status); void SendTradeStatus(uint32 status);
void SendCancelTrade(); void SendCancelTrade();
+1 -1
View File
@@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__ #ifndef __REVISION_NR_H__
#define __REVISION_NR_H__ #define __REVISION_NR_H__
#define REVISION_NR "7249" #define REVISION_NR "7250"
#endif // __REVISION_NR_H__ #endif // __REVISION_NR_H__