Core/ArenaTeam: Use full captain guid instead of low guid on team creation and some code cleanup

This commit is contained in:
Spp-
2011-09-09 13:05:51 +02:00
parent 7a9cb4fdc7
commit c4c9165428
6 changed files with 74 additions and 83 deletions
+26 -34
View File
@@ -46,7 +46,7 @@ ArenaTeam::~ArenaTeam()
{
}
bool ArenaTeam::Create(uint32 captainGuid, uint8 type, std::string teamName, uint32 backgroundColor, uint8 emblemStyle, uint32 emblemColor, uint8 borderStyle, uint32 borderColor)
bool ArenaTeam::Create(uint64 captainGuid, uint8 type, std::string teamName, uint32 backgroundColor, uint8 emblemStyle, uint32 emblemColor, uint8 borderStyle, uint32 borderColor)
{
// Check if captain is present
if (!ObjectAccessor::FindPlayer(captainGuid))
@@ -56,7 +56,6 @@ bool ArenaTeam::Create(uint32 captainGuid, uint8 type, std::string teamName, uin
if (sArenaTeamMgr->GetArenaTeamByName(TeamName))
return false;
// Generate new arena team id
TeamId = sArenaTeamMgr->GenerateArenaTeamId();
@@ -69,14 +68,13 @@ bool ArenaTeam::Create(uint32 captainGuid, uint8 type, std::string teamName, uin
EmblemColor = emblemColor;
BorderStyle = borderStyle;
BorderColor = borderColor;
uint32 captainLowGuid = GUID_LOPART(captainGuid);
// Save arena team to db
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_ADD_ARENA_TEAM);
stmt->setUInt32(0, TeamId);
stmt->setString(1, TeamName);
stmt->setUInt32(2, GUID_LOPART(CaptainGuid));
stmt->setUInt32(2, captainLowGuid);
stmt->setUInt8(3, Type);
stmt->setUInt16(4, Stats.Rating);
stmt->setUInt32(5, BackgroundColor);
@@ -89,7 +87,7 @@ bool ArenaTeam::Create(uint32 captainGuid, uint8 type, std::string teamName, uin
// Add captain as member
AddMember(CaptainGuid);
sLog->outArena("New ArenaTeam created [Id: %u] [Type: %u] [Captain low GUID: %u]", GetId(), GetType(), GUID_LOPART(CaptainGuid));
sLog->outArena("New ArenaTeam created [Id: %u] [Type: %u] [Captain low GUID: %u]", GetId(), GetType(), captainLowGuid);
return true;
}
@@ -239,13 +237,13 @@ bool ArenaTeam::LoadMembersFromDB(QueryResult result)
break;
ArenaTeamMember newMember;
newMember.Guid = MAKE_NEW_GUID(fields[1].GetUInt32(), 0, HIGHGUID_PLAYER);
newMember.Guid = MAKE_NEW_GUID(fields[1].GetUInt32(), 0, HIGHGUID_PLAYER);
newMember.WeekGames = fields[2].GetUInt16();
newMember.WeekWins = fields[3].GetUInt16();
newMember.SeasonGames = fields[4].GetUInt16();
newMember.SeasonWins = fields[5].GetUInt16();
newMember.Name = fields[6].GetString();
newMember.Class = fields[7].GetUInt8();
newMember.Name = fields[6].GetString();
newMember.Class = fields[7].GetUInt8();
newMember.PersonalRating = fields[8].GetUInt16();
newMember.MatchMakerRating = fields[9].GetUInt16() > 0 ? fields[9].GetUInt16() : 1500;
@@ -293,7 +291,7 @@ void ArenaTeam::SetCaptain(uint64 guid)
CharacterDatabase.Execute(stmt);
// Enable remove/promote buttons
Player *newCaptain = ObjectAccessor::FindPlayer(guid);
Player* newCaptain = ObjectAccessor::FindPlayer(guid);
if (newCaptain)
{
newCaptain->SetArenaTeamInfoField(GetSlot(), ARENA_TEAM_MEMBER, 0);
@@ -366,7 +364,7 @@ void ArenaTeam::Disband(WorldSession* session)
void ArenaTeam::Roster(WorldSession* session)
{
Player* pl = NULL;
Player* player = NULL;
uint8 unk308 = 0;
@@ -378,13 +376,13 @@ void ArenaTeam::Roster(WorldSession* session)
for (MemberList::const_iterator itr = Members.begin(); itr != Members.end(); ++itr)
{
pl = ObjectAccessor::FindPlayer(itr->Guid);
player = ObjectAccessor::FindPlayer(itr->Guid);
data << uint64(itr->Guid); // guid
data << uint8((pl ? 1 : 0)); // online flag
data << uint8((player ? 1 : 0)); // online flag
data << itr->Name; // member name
data << uint32((itr->Guid == GetCaptain() ? 0 : 1));// captain flag 0 captain 1 member
data << uint8((pl ? pl->getLevel() : 0)); // unknown, level?
data << uint8((player ? player->getLevel() : 0)); // unknown, level?
data << uint8(itr->Class); // class
data << uint32(itr->WeekGames); // played this week
data << uint32(itr->WeekWins); // wins this week
@@ -408,11 +406,11 @@ void ArenaTeam::Query(WorldSession* session)
data << uint32(GetId()); // team id
data << GetName(); // team name
data << uint32(GetType()); // arena team type (2=2x2, 3=3x3 or 5=5x5)
data << uint32(BackgroundColor); // background color
data << uint32(EmblemStyle); // emblem style
data << uint32(EmblemColor); // emblem color
data << uint32(BorderStyle); // border style
data << uint32(BorderColor); // border color
data << uint32(BackgroundColor); // background color
data << uint32(EmblemStyle); // emblem style
data << uint32(EmblemColor); // emblem color
data << uint32(BorderStyle); // border style
data << uint32(BorderColor); // border color
session->SendPacket(&data);
sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Sent SMSG_ARENA_TEAM_QUERY_RESPONSE");
}
@@ -421,12 +419,12 @@ void ArenaTeam::SendStats(WorldSession* session)
{
WorldPacket data(SMSG_ARENA_TEAM_STATS, 4*7);
data << uint32(GetId()); // team id
data << uint32(Stats.Rating); // rating
data << uint32(Stats.WeekGames); // games this week
data << uint32(Stats.WeekWins); // wins this week
data << uint32(Stats.SeasonGames); // played this season
data << uint32(Stats.SeasonWins); // wins this season
data << uint32(Stats.Rank); // rank
data << uint32(Stats.Rating); // rating
data << uint32(Stats.WeekGames); // games this week
data << uint32(Stats.WeekWins); // wins this week
data << uint32(Stats.SeasonGames); // played this season
data << uint32(Stats.SeasonWins); // wins this season
data << uint32(Stats.Rank); // rank
session->SendPacket(&data);
}
@@ -435,11 +433,8 @@ void ArenaTeam::NotifyStatsChanged()
// This is called after a rated match ended
// Updates arena team stats for every member of the team (not only the ones who participated!)
for (MemberList::const_iterator itr = Members.begin(); itr != Members.end(); ++itr)
{
Player* plr = ObjectAccessor::FindPlayer(itr->Guid);
if (plr)
if (Player* plr = ObjectAccessor::FindPlayer(itr->Guid))
SendStats(plr->GetSession());
}
}
void ArenaTeam::Inspect(WorldSession* session, uint64 guid)
@@ -485,11 +480,8 @@ void ArenaTeamMember::ModifyMatchmakerRating(int32 mod, uint32 /*slot*/)
void ArenaTeam::BroadcastPacket(WorldPacket* packet)
{
for (MemberList::const_iterator itr = Members.begin(); itr != Members.end(); ++itr)
{
Player* player = ObjectAccessor::FindPlayer(itr->Guid);
if (player)
if (Player* player = ObjectAccessor::FindPlayer(itr->Guid))
player->GetSession()->SendPacket(packet);
}
}
void ArenaTeam::BroadcastEvent(ArenaTeamEvents event, uint64 guid, uint8 strCount, std::string str1, std::string str2, std::string str3)
@@ -525,7 +517,7 @@ void ArenaTeam::BroadcastEvent(ArenaTeamEvents event, uint64 guid, uint8 strCoun
uint8 ArenaTeam::GetSlotByType(uint32 type)
{
switch(type)
switch (type)
{
case ARENA_TEAM_2v2: return 0;
case ARENA_TEAM_3v3: return 1;
+7 -3
View File
@@ -20,10 +20,14 @@
#define TRINITYCORE_ARENATEAM_H
#include "QueryResult.h"
#include "Player.h"
#include "ObjectMgr.h"
#include <ace/Singleton.h>
#include <list>
#include <map>
class WorldSession;
class WorldPacket;
class Player;
class Group;
enum ArenaTeamCommandTypes
{
@@ -115,7 +119,7 @@ class ArenaTeam
ArenaTeam();
~ArenaTeam();
bool Create(uint32 captainGuid, uint8 type, std::string teamName, uint32 backgroundColor, uint8 emblemStyle, uint32 emblemColor, uint8 borderStyle, uint32 borderColor);
bool Create(uint64 captainGuid, uint8 type, std::string teamName, uint32 backgroundColor, uint8 emblemStyle, uint32 emblemColor, uint8 borderStyle, uint32 borderColor);
void Disband(WorldSession* session);
typedef std::list<ArenaTeamMember> MemberList;
@@ -15,8 +15,13 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "Common.h"
#include "Define.h"
#include "ArenaTeamMgr.h"
#include "World.h"
#include "Log.h"
#include "DatabaseEnv.h"
#include "Language.h"
#include "ObjectAccessor.h"
ArenaTeamMgr::ArenaTeamMgr()
{
-2
View File
@@ -6223,8 +6223,6 @@ void ObjectMgr::SetHighestGuids()
sGroupMgr->SetGroupDbStoreSize((*result)[0].GetUInt32()+1);
}
uint32 ObjectMgr::GenerateAuctionID()
{
if (m_auctionid >= 0xFFFFFFFE)
@@ -246,7 +246,6 @@ void WorldSession::HandleBattlemasterJoinOpcode(WorldPacket & recv_data)
void WorldSession::HandleBattlegroundPlayerPositionsOpcode(WorldPacket & /*recv_data*/)
{
// empty opcode
sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Recvd MSG_BATTLEGROUND_PLAYER_POSITIONS Message");
Battleground *bg = _player->GetBattleground();
@@ -256,56 +255,49 @@ void WorldSession::HandleBattlegroundPlayerPositionsOpcode(WorldPacket & /*recv_
switch(bg->GetTypeID(true))
{
case BATTLEGROUND_WS:
{
uint32 count = 0;
Player* aplr = ObjectAccessor::FindPlayer(((BattlegroundWS*)bg)->GetAllianceFlagPickerGUID());
if (aplr)
++count;
Player* hplr = ObjectAccessor::FindPlayer(((BattlegroundWS*)bg)->GetHordeFlagPickerGUID());
if (hplr)
++count;
WorldPacket data(MSG_BATTLEGROUND_PLAYER_POSITIONS, 4 + 4 + 16 * count);
data << 0;
data << count;
if (aplr)
{
uint32 count1 = 0; //always constant zero?
uint32 count2 = 0; //count of next fields
Player *ali_plr = ObjectAccessor::FindPlayer(((BattlegroundWS*)bg)->GetAllianceFlagPickerGUID());
if (ali_plr)
++count2;
Player *horde_plr = ObjectAccessor::FindPlayer(((BattlegroundWS*)bg)->GetHordeFlagPickerGUID());
if (horde_plr)
++count2;
WorldPacket data(MSG_BATTLEGROUND_PLAYER_POSITIONS, (4+4+16*count1+16*count2));
data << count1; // alliance flag holders count - obsolete, now always 0
/*for (uint8 i = 0; i < count1; ++i)
{
data << uint64(0); // guid
data << (float)0; // x
data << (float)0; // y
}*/
data << count2; // horde flag holders count - obsolete, now count of next fields
if (ali_plr)
{
data << (uint64)ali_plr->GetGUID();
data << (float)ali_plr->GetPositionX();
data << (float)ali_plr->GetPositionY();
}
if (horde_plr)
{
data << (uint64)horde_plr->GetGUID();
data << (float)horde_plr->GetPositionX();
data << (float)horde_plr->GetPositionY();
}
SendPacket(&data);
data << uint64(aplr->GetGUID());
data << float(aplr->GetPositionX());
data << float(aplr->GetPositionY());
}
if (hplr)
{
data << uint64(hplr->GetGUID());
data << float(hplr->GetPositionX());
data << float(hplr->GetPositionY());
}
SendPacket(&data);
break;
}
case BATTLEGROUND_EY:
//TODO : fix me!
break;
case BATTLEGROUND_AB:
case BATTLEGROUND_AV:
{
//for other BG types - send default
WorldPacket data(MSG_BATTLEGROUND_PLAYER_POSITIONS, (4+4));
data << uint32(0);
data << uint32(0);
SendPacket(&data);
}
{
WorldPacket data(MSG_BATTLEGROUND_PLAYER_POSITIONS, (4+4));
data << uint32(0);
data << uint32(0);
SendPacket(&data);
break;
}
default:
//maybe it is sent also in arena - do nothing
break;
@@ -835,7 +835,7 @@ void WorldSession::HandleTurnInPetitionOpcode(WorldPacket & recv_data)
// Create arena team
ArenaTeam* arenaTeam = new ArenaTeam();
if (!arenaTeam->Create(GUID_LOPART(_player->GetGUID()), type, name, background, icon, iconcolor, border, bordercolor))
if (!arenaTeam->Create(_player->GetGUID(), type, name, background, icon, iconcolor, border, bordercolor))
{
delete arenaTeam;
return;