Add selection weights to BG and Arenas. Will determine the selected BG/Arena chosen using random BG/Arenas from the enabled list.
Closes issue 2843 --HG-- branch : trunk
This commit is contained in:
+15
-14
@@ -241,6 +241,7 @@ CREATE TABLE `battleground_template` (
|
|||||||
`AllianceStartO` float NOT NULL,
|
`AllianceStartO` float NOT NULL,
|
||||||
`HordeStartLoc` mediumint(8) unsigned NOT NULL,
|
`HordeStartLoc` mediumint(8) unsigned NOT NULL,
|
||||||
`HordeStartO` float NOT NULL,
|
`HordeStartO` float NOT NULL,
|
||||||
|
`Weight` tinyint(2) unsigned NOT NULL DEFAULT 1,
|
||||||
`Comment` char(32) NOT NULL,
|
`Comment` char(32) NOT NULL,
|
||||||
PRIMARY KEY (`id`)
|
PRIMARY KEY (`id`)
|
||||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
|
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
|
||||||
@@ -252,20 +253,20 @@ CREATE TABLE `battleground_template` (
|
|||||||
|
|
||||||
LOCK TABLES `battleground_template` WRITE;
|
LOCK TABLES `battleground_template` WRITE;
|
||||||
/*!40000 ALTER TABLE `battleground_template` DISABLE KEYS */;
|
/*!40000 ALTER TABLE `battleground_template` DISABLE KEYS */;
|
||||||
INSERT INTO `battleground_template` (`id`,`MinPlayersPerTeam`,`MaxPlayersPerTeam`,`MinLvl`,`MaxLvl`,`AllianceStartLoc`,`AllianceStartO`,`HordeStartLoc`,`HordeStartO`) VALUES
|
INSERT INTO `battleground_template` (`id`,`MinPlayersPerTeam`,`MaxPlayersPerTeam`,`MinLvl`,`MaxLvl`,`AllianceStartLoc`,`AllianceStartO`,`HordeStartLoc`,`HordeStartO`, `Weight`) VALUES
|
||||||
(1,20,40,51,80,611,2.72532,610,2.27452),
|
(1,20,40,51,80,611,2.72532,610,2.27452,1),
|
||||||
(2,5,10,10,80,769,3.14159,770,3.14159),
|
(2,5,10,10,80,769,3.14159,770,3.14159,1),
|
||||||
(3,8,15,20,80,890,3.40156,889,0.263892),
|
(3,8,15,20,80,890,3.40156,889,0.263892,1),
|
||||||
(4,0,2,10,80,929,0,936,3.14159),
|
(4,0,2,10,80,929,0,936,3.14159,1),
|
||||||
(5,0,2,10,80,939,0,940,3.14159),
|
(5,0,2,10,80,939,0,940,3.14159,1),
|
||||||
(6,0,2,10,80,0,0,0,0),
|
(6,0,2,10,80,0,0,0,0,1),
|
||||||
(7,8,15,61,80,1103,3.40156,1104,0.263892),
|
(7,8,15,61,80,1103,3.40156,1104,0.263892,1),
|
||||||
(8,0,2,10,80,1258,0,1259,3.14159),
|
(8,0,2,10,80,1258,0,1259,3.14159,1),
|
||||||
(9,7,15,71,80,1367,0,1368,0),
|
(9,7,15,71,80,1367,0,1368,0,1),
|
||||||
(10,5,5,10,80,1362,0,1363,0),
|
(10,5,5,10,80,1362,0,1363,0,1),
|
||||||
(11,5,5,10,80,1364,0,1365,0),
|
(11,5,5,10,80,1364,0,1365,0,1),
|
||||||
(30,20,40,71,80,1485,0,1486,0),
|
(30,20,40,71,80,1485,0,1486,0,1),
|
||||||
(32,10,10,0,80,0,0,0,0);
|
(32,10,10,0,80,0,0,0,0,1);
|
||||||
/*!40000 ALTER TABLE `battleground_template` ENABLE KEYS */;
|
/*!40000 ALTER TABLE `battleground_template` ENABLE KEYS */;
|
||||||
UNLOCK TABLES;
|
UNLOCK TABLES;
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
ALTER TABLE `battleground_template` ADD `Weight` tinyint(2) UNSIGNED NOT NULL DEFAULT 1 AFTER `HordeStartO`;
|
||||||
@@ -1551,7 +1551,7 @@ BattleGround * BattleGroundMgr::CreateNewBattleGround(BattleGroundTypeId bgTypeI
|
|||||||
{
|
{
|
||||||
// get the template BG
|
// get the template BG
|
||||||
BattleGround *bg_template = GetBattleGroundTemplate(bgTypeId);
|
BattleGround *bg_template = GetBattleGroundTemplate(bgTypeId);
|
||||||
BattleGroundTypeIdList *enabledBGsOrArenas = NULL;
|
BattleGroundSelectionWeightMap *selectionWeights = NULL;
|
||||||
|
|
||||||
if (!bg_template)
|
if (!bg_template)
|
||||||
{
|
{
|
||||||
@@ -1561,19 +1561,39 @@ BattleGround * BattleGroundMgr::CreateNewBattleGround(BattleGroundTypeId bgTypeI
|
|||||||
bool isRandom = false;
|
bool isRandom = false;
|
||||||
|
|
||||||
if (bg_template->isArena())
|
if (bg_template->isArena())
|
||||||
enabledBGsOrArenas = &m_EnabledArenas;
|
selectionWeights = &m_ArenaSelectionWeights;
|
||||||
else if (bgTypeId == BATTLEGROUND_RB)
|
else if (bgTypeId == BATTLEGROUND_RB)
|
||||||
{
|
{
|
||||||
enabledBGsOrArenas = &m_EnabledBGs;
|
selectionWeights = &m_BGSelectionWeights;
|
||||||
isRandom = true;
|
isRandom = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (enabledBGsOrArenas)
|
if (selectionWeights)
|
||||||
{
|
{
|
||||||
if (!enabledBGsOrArenas->size())
|
if (!selectionWeights->size())
|
||||||
return NULL;
|
return NULL;
|
||||||
uint8 size = enabledBGsOrArenas->size() - 1;
|
uint32 Weight = 0;
|
||||||
bgTypeId = enabledBGsOrArenas->at(urand(0,size));
|
uint32 selectedWeight = 0;
|
||||||
|
bgTypeId = BATTLEGROUND_TYPE_NONE;
|
||||||
|
// Get sum of all weights
|
||||||
|
for (BattleGroundSelectionWeightMap::const_iterator it = selectionWeights->begin(); it != selectionWeights->end(); ++it)
|
||||||
|
Weight += it->second;
|
||||||
|
if (!Weight)
|
||||||
|
return NULL;
|
||||||
|
// Select a random value
|
||||||
|
selectedWeight = urand(0, Weight);
|
||||||
|
|
||||||
|
// Select the correct bg (if we have in DB A(10), B(20), C(10), D(15) --> [0---A---9|10---B---29|30---C---39|40---D---54])
|
||||||
|
Weight = 0;
|
||||||
|
for (BattleGroundSelectionWeightMap::const_iterator it = selectionWeights->begin(); it != selectionWeights->end(); ++it)
|
||||||
|
{
|
||||||
|
Weight += it->second;
|
||||||
|
if (selectedWeight < Weight)
|
||||||
|
{
|
||||||
|
bgTypeId = it->first;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
bg_template = GetBattleGroundTemplate(bgTypeId);
|
bg_template = GetBattleGroundTemplate(bgTypeId);
|
||||||
if (!bg_template)
|
if (!bg_template)
|
||||||
{
|
{
|
||||||
@@ -1701,14 +1721,15 @@ void BattleGroundMgr::CreateInitialBattleGrounds()
|
|||||||
float AStartLoc[4];
|
float AStartLoc[4];
|
||||||
float HStartLoc[4];
|
float HStartLoc[4];
|
||||||
uint32 MaxPlayersPerTeam, MinPlayersPerTeam, MinLvl, MaxLvl, start1, start2;
|
uint32 MaxPlayersPerTeam, MinPlayersPerTeam, MinLvl, MaxLvl, start1, start2;
|
||||||
|
uint8 selectionWeight;
|
||||||
BattlemasterListEntry const *bl;
|
BattlemasterListEntry const *bl;
|
||||||
WorldSafeLocsEntry const *start;
|
WorldSafeLocsEntry const *start;
|
||||||
bool IsArena;
|
bool IsArena;
|
||||||
|
|
||||||
uint32 count = 0;
|
uint32 count = 0;
|
||||||
|
|
||||||
// 0 1 2 3 4 5 6 7 8
|
// 0 1 2 3 4 5 6 7 8 9
|
||||||
QueryResult_AutoPtr result = WorldDatabase.Query("SELECT id, MinPlayersPerTeam,MaxPlayersPerTeam,MinLvl,MaxLvl,AllianceStartLoc,AllianceStartO,HordeStartLoc,HordeStartO FROM battleground_template");
|
QueryResult_AutoPtr result = WorldDatabase.Query("SELECT id, MinPlayersPerTeam,MaxPlayersPerTeam,MinLvl,MaxLvl,AllianceStartLoc,AllianceStartO,HordeStartLoc,HordeStartO,Weight FROM battleground_template");
|
||||||
|
|
||||||
if (!result)
|
if (!result)
|
||||||
{
|
{
|
||||||
@@ -1806,6 +1827,7 @@ void BattleGroundMgr::CreateInitialBattleGrounds()
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
selectionWeight = fields[9].GetUInt8();
|
||||||
//sLog.outDetail("Creating battleground %s, %u-%u", bl->name[sWorld.GetDBClang()], MinLvl, MaxLvl);
|
//sLog.outDetail("Creating battleground %s, %u-%u", bl->name[sWorld.GetDBClang()], MinLvl, MaxLvl);
|
||||||
if (!CreateBattleGround(bgTypeID, IsArena, MinPlayersPerTeam, MaxPlayersPerTeam, MinLvl, MaxLvl, bl->name[sWorld.GetDefaultDbcLocale()], bl->mapid[0], AStartLoc[0], AStartLoc[1], AStartLoc[2], AStartLoc[3], HStartLoc[0], HStartLoc[1], HStartLoc[2], HStartLoc[3]))
|
if (!CreateBattleGround(bgTypeID, IsArena, MinPlayersPerTeam, MaxPlayersPerTeam, MinLvl, MaxLvl, bl->name[sWorld.GetDefaultDbcLocale()], bl->mapid[0], AStartLoc[0], AStartLoc[1], AStartLoc[2], AStartLoc[3], HStartLoc[0], HStartLoc[1], HStartLoc[2], HStartLoc[3]))
|
||||||
continue;
|
continue;
|
||||||
@@ -1813,10 +1835,10 @@ void BattleGroundMgr::CreateInitialBattleGrounds()
|
|||||||
if (IsArena)
|
if (IsArena)
|
||||||
{
|
{
|
||||||
if (bgTypeID != BATTLEGROUND_AA)
|
if (bgTypeID != BATTLEGROUND_AA)
|
||||||
m_EnabledArenas.push_back(bgTypeID);
|
m_ArenaSelectionWeights[bgTypeID] = selectionWeight;
|
||||||
}
|
}
|
||||||
else if (bgTypeID != BATTLEGROUND_RB)
|
else if (bgTypeID != BATTLEGROUND_RB)
|
||||||
m_EnabledBGs.push_back(bgTypeID);
|
m_BGSelectionWeights[bgTypeID] = selectionWeight;
|
||||||
++count;
|
++count;
|
||||||
} while (result->NextRow());
|
} while (result->NextRow());
|
||||||
|
|
||||||
|
|||||||
@@ -260,11 +260,11 @@ class BattleGroundMgr
|
|||||||
private:
|
private:
|
||||||
BattleMastersMap mBattleMastersMap;
|
BattleMastersMap mBattleMastersMap;
|
||||||
|
|
||||||
typedef std::vector<BattleGroundTypeId> BattleGroundTypeIdList;
|
typedef std::map<BattleGroundTypeId, uint8> BattleGroundSelectionWeightMap; // TypeId and its selectionWeight
|
||||||
/* Battlegrounds */
|
/* Battlegrounds */
|
||||||
BattleGroundSet m_BattleGrounds[MAX_BATTLEGROUND_TYPE_ID];
|
BattleGroundSet m_BattleGrounds[MAX_BATTLEGROUND_TYPE_ID];
|
||||||
BattleGroundTypeIdList m_EnabledArenas;
|
BattleGroundSelectionWeightMap m_ArenaSelectionWeights;
|
||||||
BattleGroundTypeIdList m_EnabledBGs;
|
BattleGroundSelectionWeightMap m_BGSelectionWeights;
|
||||||
std::vector<uint64> m_QueueUpdateScheduler;
|
std::vector<uint64> m_QueueUpdateScheduler;
|
||||||
std::set<uint32> m_ClientBattleGroundIds[MAX_BATTLEGROUND_TYPE_ID][MAX_BATTLEGROUND_BRACKETS]; //the instanceids just visible for the client
|
std::set<uint32> m_ClientBattleGroundIds[MAX_BATTLEGROUND_TYPE_ID][MAX_BATTLEGROUND_BRACKETS]; //the instanceids just visible for the client
|
||||||
uint32 m_NextRatingDiscardUpdate;
|
uint32 m_NextRatingDiscardUpdate;
|
||||||
|
|||||||
Reference in New Issue
Block a user