Added enum for SMSG_GROUP_JOINED_BATTLEGROUND opcode.

Use this enum where possible.
Some misc fixes.
This commit is contained in:
tomrus88 2010-04-03 22:22:30 +04:00
parent 4f6006b9db
commit 9836bcbbaa
9 changed files with 135 additions and 137 deletions

View file

@ -80,9 +80,9 @@ bool Group::Create(const uint64 &guid, const char * name)
m_leaderGuid = guid;
m_leaderName = name;
m_groupType = isBGGroup() ? GROUPTYPE_RAID : GROUPTYPE_NORMAL;
m_groupType = isBGGroup() ? GROUPTYPE_BGRAID : GROUPTYPE_NORMAL;
if (m_groupType == GROUPTYPE_RAID)
if (m_groupType & GROUPTYPE_RAID)
_initRaidSubGroupsCounter();
m_lootMethod = GROUP_LOOT;
@ -111,7 +111,7 @@ bool Group::Create(const uint64 &guid, const char * name)
CharacterDatabase.PExecute("INSERT INTO groups (groupId,leaderGuid,mainTank,mainAssistant,lootMethod,looterGuid,lootThreshold,icon1,icon2,icon3,icon4,icon5,icon6,icon7,icon8,isRaid,difficulty,raiddifficulty) "
"VALUES ('%u','%u','%u','%u','%u','%u','%u','" UI64FMTD "','" UI64FMTD "','" UI64FMTD "','" UI64FMTD "','" UI64FMTD "','" UI64FMTD "','" UI64FMTD "','" UI64FMTD "','%u','%u','%u')",
m_Id, GUID_LOPART(m_leaderGuid), GUID_LOPART(m_mainTank), GUID_LOPART(m_mainAssistant), uint32(m_lootMethod),
GUID_LOPART(m_looterGuid), uint32(m_lootThreshold), m_targetIcons[0], m_targetIcons[1], m_targetIcons[2], m_targetIcons[3], m_targetIcons[4], m_targetIcons[5], m_targetIcons[6], m_targetIcons[7], isRaidGroup(), uint32(m_dungeonDifficulty), m_raidDifficulty);
GUID_LOPART(m_looterGuid), uint32(m_lootThreshold), m_targetIcons[0], m_targetIcons[1], m_targetIcons[2], m_targetIcons[3], m_targetIcons[4], m_targetIcons[5], m_targetIcons[6], m_targetIcons[7], uint8(m_groupType), uint32(m_dungeonDifficulty), m_raidDifficulty);
}
if(!AddMember(guid, name))
@ -135,9 +135,9 @@ bool Group::LoadGroupFromDB(Field* fields)
if(!sObjectMgr.GetPlayerNameByGUID(m_leaderGuid, m_leaderName))
return false;
m_groupType = fields[13].GetBool() ? GROUPTYPE_RAID : GROUPTYPE_NORMAL;
m_groupType = GroupType(fields[13].GetUInt8());
if (m_groupType == GROUPTYPE_RAID)
if (m_groupType & GROUPTYPE_RAID)
_initRaidSubGroupsCounter();
uint32 diff = fields[14].GetUInt8();
@ -182,7 +182,7 @@ bool Group::LoadMemberFromDB(uint32 guidLow, uint8 subgroup, bool assistant)
void Group::ConvertToRaid()
{
m_groupType = GROUPTYPE_RAID;
m_groupType = GroupType(m_groupType | GROUPTYPE_RAID);
_initRaidSubGroupsCounter();
@ -1457,24 +1457,31 @@ void Group::UpdateLooterGuid( Creature* creature, bool ifneed )
SendUpdate();
}
uint32 Group::CanJoinBattleGroundQueue(BattleGround const* bgOrTemplate, BattleGroundQueueTypeId bgQueueTypeId, uint32 MinPlayerCount, uint32 MaxPlayerCount, bool isRated, uint32 arenaSlot)
GroupJoinBattlegroundResult Group::CanJoinBattleGroundQueue(BattleGround const* bgOrTemplate, BattleGroundQueueTypeId bgQueueTypeId, uint32 MinPlayerCount, uint32 MaxPlayerCount, bool isRated, uint32 arenaSlot)
{
BattlemasterListEntry const* bgEntry = sBattlemasterListStore.LookupEntry(bgOrTemplate->GetTypeID());
if(!bgEntry)
return ERR_GROUP_JOIN_BATTLEGROUND_FAIL; // shouldn't happen
// check for min / max count
uint32 memberscount = GetMembersCount();
if(memberscount < MinPlayerCount)
return BG_JOIN_ERR_GROUP_NOT_ENOUGH;
if(memberscount > MaxPlayerCount)
return BG_JOIN_ERR_GROUP_TOO_MANY;
// only check for MinPlayerCount since MinPlayerCount == MaxPlayerCount for arenas...
if(bgOrTemplate->isArena() && memberscount != MinPlayerCount)
return ERR_ARENA_TEAM_PARTY_SIZE;
if(memberscount > bgEntry->maxGroupSize) // no MinPlayerCount for battlegrounds
return ERR_BATTLEGROUND_NONE; // ERR_GROUP_JOIN_BATTLEGROUND_TOO_MANY handled on client side
// get a player as reference, to compare other players' stats to (arena team id, queue id based on level, etc.)
Player * reference = GetFirstMember()->getSource();
// no reference found, can't join this way
if(!reference)
return BG_JOIN_ERR_OFFLINE_MEMBER;
return ERR_BATTLEGROUND_JOIN_FAILED;
PvPDifficultyEntry const* bracketEntry = GetBattlegroundBracketByLevel(bgOrTemplate->GetMapId(),reference->getLevel());
PvPDifficultyEntry const* bracketEntry = GetBattlegroundBracketByLevel(bgOrTemplate->GetMapId(), reference->getLevel());
if(!bracketEntry)
return BG_JOIN_ERR_OFFLINE_MEMBER;
return ERR_BATTLEGROUND_JOIN_FAILED;
uint32 arenaTeamId = reference->GetArenaTeamId(arenaSlot);
uint32 team = reference->GetTeam();
@ -1485,28 +1492,28 @@ uint32 Group::CanJoinBattleGroundQueue(BattleGround const* bgOrTemplate, BattleG
Player *member = itr->getSource();
// offline member? don't let join
if(!member)
return BG_JOIN_ERR_OFFLINE_MEMBER;
return ERR_BATTLEGROUND_JOIN_FAILED;
// don't allow cross-faction join as group
if(member->GetTeam() != team)
return BG_JOIN_ERR_MIXED_FACTION;
// not in the same battleground level braket, don't let join
PvPDifficultyEntry const* memberBracketEntry = GetBattlegroundBracketByLevel(bracketEntry->mapId,member->getLevel());
return ERR_BATTLEGROUND_JOIN_TIMED_OUT;
// not in the same battleground level bracket, don't let join
PvPDifficultyEntry const* memberBracketEntry = GetBattlegroundBracketByLevel(bracketEntry->mapId, member->getLevel());
if(memberBracketEntry != bracketEntry)
return BG_JOIN_ERR_MIXED_LEVELS;
return ERR_BATTLEGROUND_JOIN_RANGE_INDEX;
// don't let join rated matches if the arena team id doesn't match
if(isRated && member->GetArenaTeamId(arenaSlot) != arenaTeamId)
return BG_JOIN_ERR_MIXED_ARENATEAM;
return ERR_BATTLEGROUND_JOIN_FAILED;
// don't let join if someone from the group is already in that bg queue
if(member->InBattleGroundQueueForBattleGroundQueueType(bgQueueTypeId))
return BG_JOIN_ERR_GROUP_MEMBER_ALREADY_IN_QUEUE;
return ERR_BATTLEGROUND_JOIN_FAILED; // not blizz-like
// check for deserter debuff in case not arena queue
if(bgOrTemplate->GetTypeID() != BATTLEGROUND_AA && !member->CanJoinToBattleground())
return BG_JOIN_ERR_GROUP_DESERTER;
return ERR_GROUP_JOIN_BATTLEGROUND_DESERTERS;
// check if member can join any more battleground queues
if(!member->HasFreeBattleGroundQueueId())
return BG_JOIN_ERR_ALL_QUEUES_USED;
return ERR_BATTLEGROUND_TOO_MANY_QUEUES; // not blizz-like
}
return BG_JOIN_ERR_OK;
return GroupJoinBattlegroundResult(bgOrTemplate->GetTypeID());
}
//===================================================