本文整理汇总了C++中ArenaTeam::Create方法的典型用法代码示例。如果您正苦于以下问题:C++ ArenaTeam::Create方法的具体用法?C++ ArenaTeam::Create怎么用?C++ ArenaTeam::Create使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ArenaTeam
的用法示例。
在下文中一共展示了ArenaTeam::Create方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: HandleArenaCreateCommand
static bool HandleArenaCreateCommand(ChatHandler* handler, char const* args)
{
if (!*args)
return false;
Player* target;
if (!handler->extractPlayerTarget(*args != '"' ? (char*)args : NULL, &target))
return false;
char* tailStr = *args != '"' ? strtok(NULL, "") : (char*)args;
if (!tailStr)
return false;
char* name = handler->extractQuotedArg(tailStr);
if (!name)
return false;
char* typeStr = strtok(NULL, "");
if (!typeStr)
return false;
int8 type = atoi(typeStr);
if (sArenaTeamMgr->GetArenaTeamByName(name))
{
handler->PSendSysMessage(LANG_ARENA_ERROR_NAME_EXISTS, name);
handler->SetSentErrorMessage(true);
return false;
}
if (type == 2 || type == 3 || type == 5 )
{
if (Player::GetArenaTeamIdFromDB(target->GetGUID(), type) != 0)
{
handler->PSendSysMessage(LANG_ARENA_ERROR_SIZE, target->GetName().c_str());
handler->SetSentErrorMessage(true);
return false;
}
ArenaTeam* arena = new ArenaTeam();
if (!arena->Create(target->GetGUID(), type, name, 4293102085, 101, 4293253939, 4, 4284049911))
{
delete arena;
handler->SendSysMessage(LANG_BAD_VALUE);
handler->SetSentErrorMessage(true);
return false;
}
sArenaTeamMgr->AddArenaTeam(arena);
handler->PSendSysMessage(LANG_ARENA_CREATE, arena->GetName().c_str(), arena->GetId(), arena->GetType(), arena->GetCaptain().GetCounter());
}
else
{
handler->SendSysMessage(LANG_BAD_VALUE);
handler->SetSentErrorMessage(true);
return false;
}
return true;
}
示例2: HandleArenaTeamCreateOpcode
void WorldSession::HandleArenaTeamCreateOpcode(WorldPacket & recvData)
{
sLog->outDebug(LOG_FILTER_NETWORKIO, "CMSG_ARENA_TEAM_CREATE"); // empty opcode
uint32 slot;
uint32 background;
uint32 icon;
uint32 iconcolor;
uint32 border;
uint32 bordercolor;
uint8 strLeng;
std::string name;
recvData >> slot >> icon >> iconcolor >> border >> bordercolor >> background;
recvData >> strLeng >> name;
// Check for valid arena bracket (2v2, 3v3, 5v5)
if (slot >= MAX_ARENA_SLOT)
return;
uint32 type = ArenaTeam::GetTypeBySlot(slot);
if (type >= MAX_ARENA_TYPE)
return;
// Check if player is already in an arena team
if (_player->GetArenaTeamId(slot))
{
SendArenaTeamCommandResult(ERR_ARENA_TEAM_CREATE_S, name, "", ERR_ALREADY_IN_ARENA_TEAM);
return;
}
// Check if arena team name is already taken
if (sArenaTeamMgr->GetArenaTeamByName(name))
{
SendArenaTeamCommandResult(ERR_ARENA_TEAM_CREATE_S, name, "", ERR_ARENA_TEAM_NAME_EXISTS_S);
return;
}
// Create arena team
ArenaTeam* arenaTeam = new ArenaTeam();
if (!arenaTeam->Create(_player->GetGUID(), type, name, background, icon, iconcolor, border, bordercolor))
{
delete arenaTeam;
return;
}
// Register arena team
sArenaTeamMgr->AddArenaTeam(arenaTeam);
sLog->outDebug(LOG_FILTER_NETWORKIO, "ArenaTeamHandler: Arena team (guid: %u) added to ObjectMgr", arenaTeam->GetId());
// Broadcast event
arenaTeam->BroadcastEvent(ERR_ARENA_TEAM_JOIN_SS, _player->GetGUID(), 2, _player->GetName(), arenaTeam->GetName(), "");
}
示例3: CreateArenateam
bool CreateArenateam(Player* player, Creature* me)
{
if (!player || !me)
return false;
uint8 slot = ArenaTeam::GetSlotByType(ARENA_TEAM_5v5);
if (slot >= MAX_ARENA_SLOT)
return false;
// Check if player is already in an arena team
if (player->GetArenaTeamId(slot))
{
player->GetSession()->SendArenaTeamCommandResult(ERR_ARENA_TEAM_CREATE_S, player->GetName(), "", ERR_ALREADY_IN_ARENA_TEAM);
return false;
}
// Teamname = playername
// if team name exist, we have to choose another name (playername + number)
int i = 1;
std::stringstream teamName;
//teamName << "3vs3 Solo - " << player->GetName();
teamName << player->GetName();
do
{
if (sArenaTeamMgr->GetArenaTeamByName(teamName.str()) != NULL) // teamname exist, so choose another name
{
teamName.str(std::string());
teamName << player->GetName() << i++;
}
else
break;
} while (i < 100); // should never happen
// Create arena team
ArenaTeam* arenaTeam = new ArenaTeam();
if (!arenaTeam->Create(player->GetGUID(), ARENA_TEAM_5v5, teamName.str(), 4283124816, 45, 4294242303, 5, 4294705149))
{
delete arenaTeam;
return false;
}
// Register arena team
sArenaTeamMgr->AddArenaTeam(arenaTeam);
arenaTeam->AddMember(player->GetGUID());
ChatHandler(player->GetSession()).SendSysMessage("Arena team successful created!");
return true;
}
示例4: HandleArenaTeamCreateOpcode
void WorldSession::HandleArenaTeamCreateOpcode(WorldPacket & recvData)
{
sLog->outDebug(LOG_FILTER_NETWORKIO, "CMSG_ARENA_TEAM_CREATE");
uint32 icon, backgroundColor, borderColor, iconColor, border, slot;
std::string name;
recvData >> icon;
recvData >> backgroundColor;
recvData >> borderColor;
recvData >> iconColor;
recvData >> border;
recvData >> slot;
recvData >> name;
// Perform checks
if (_player->getLevel() < sWorld->getIntConfig(CONFIG_ARENA_MIN_LEVEL)) // TODO: implement error message
return;
if (_player->GetArenaTeamId(slot))
{
SendArenaTeamCommandResult(ERR_ARENA_TEAM_CREATE_S, name, "", ERR_ALREADY_IN_ARENA_TEAM);
return;
}
if (sArenaTeamMgr->GetArenaTeamByName(name))
{
SendArenaTeamCommandResult(ERR_ARENA_TEAM_CREATE_S, name, "", ERR_ARENA_TEAM_NAME_EXISTS_S);
return;
}
if (sObjectMgr->IsReservedName(name) || !ObjectMgr::IsValidCharterName(name))
{
SendArenaTeamCommandResult(ERR_ARENA_TEAM_CREATE_S, name, "", ERR_ARENA_TEAM_NAME_INVALID);
return;
}
// Create arena team
ArenaTeam* arenaTeam = new ArenaTeam();
if (!arenaTeam->Create(_player->GetGUID(), ArenaTeam::GetTypeBySlot(slot), name, backgroundColor, icon, iconColor, border, borderColor))
{
delete arenaTeam;
return;
}
// Register arena team
sArenaTeamMgr->AddArenaTeam(arenaTeam);
sLog->outDebug(LOG_FILTER_NETWORKIO, "PetitonsHandler: Arena team (guid: %u) added to ObjectMgr", arenaTeam->GetId());
}
示例5: HandleArenaTeamCreateOpcode
void WorldSession::HandleArenaTeamCreateOpcode(WorldPacket & recvData)
{
sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Received CMSG_ARENA_TEAM_CREATE");
uint32 slot, icon, iconcolor, border, bordercolor, background;
std::string name;
recvData >> slot;
recvData >> icon;
recvData >> bordercolor;
recvData >> border;
recvData >> background;
recvData >> iconcolor;
name = recvData.ReadString(recvData.ReadBits(8));
uint8 type = ArenaTeam::GetTypeBySlot(slot);
if (_player->GetArenaTeamId(slot))
{
SendArenaTeamCommandResult(ERR_ARENA_TEAM_INVITE_SS, "", _player->GetName(), ERR_ALREADY_IN_ARENA_TEAM_S);
return;
}
if (sObjectMgr->IsReservedName(name) || !ObjectMgr::IsValidCharterName(name))
{
SendArenaTeamCommandResult(ERR_ARENA_TEAM_CREATE_S, name, "", ERR_ARENA_TEAM_NAME_INVALID);
return;
}
if (sArenaTeamMgr->GetArenaTeamByName(name))
{
SendArenaTeamCommandResult(ERR_ARENA_TEAM_CREATE_S, name, "", ERR_ARENA_TEAM_NAME_EXISTS_S);
return;
}
ArenaTeam* arenaTeam = new ArenaTeam;
if (!arenaTeam->Create(GUID_LOPART(_player->GetGUID()), type, name, background, icon, iconcolor, border, bordercolor))
{
sLog->outError(LOG_FILTER_ARENAS, "Arena team create failed.");
delete arenaTeam;
return;
}
sArenaTeamMgr->AddArenaTeam(arenaTeam);
SendArenaTeamCommandResult(ERR_ARENA_TEAM_CREATE_S, name, "", ERR_ARENA_TEAM_CREATED);
}
示例6: HandleArenaTeamCreate
void WorldSession::HandleArenaTeamCreate(WorldPacket & recv_data)
{
sLog->outDebug(LOG_FILTER_NETWORKIO, "CMSG_ARENA_TEAM_CREATE");
uint32 type, icon, iconcolor, border, bordercolor, background;
std::string name;
recv_data >> background >> icon >> iconcolor >> border >> bordercolor;
recv_data >> type;
recv_data >> name;
ArenaTeam* at = new ArenaTeam;
if (!at->Create(GUID_LOPART(_player->GetGUIDLow()), type, name, background, icon, iconcolor, border, bordercolor))
{
sLog->outError("ArenaTeamHandler: arena team create failed.");
delete at;
return;
}
// register team and add captain
sArenaTeamMgr->AddArenaTeam(at);
}
示例7: HandleTurnInPetitionOpcode
//.........这里部分代码省略.........
if (sGuildMgr.GetGuildByName(name))
{
SendGuildCommandResult(GUILD_CREATE_S, name, ERR_GUILD_NAME_EXISTS_S);
delete result;
return;
}
}
else
{
if (sObjectMgr.GetArenaTeamByName(name))
{
SendArenaTeamCommandResult(ERR_ARENA_TEAM_CREATE_S, name, "", ERR_ARENA_TEAM_NAME_EXISTS_S);
delete result;
return;
}
}
// and at last charter item check
Item* item = _player->GetItemByGuid(petitionGuid);
if (!item)
{
delete result;
return;
}
// OK!
// delete charter item
_player->DestroyItem(item->GetBagSlot(), item->GetSlot(), true);
if (type == 9) // create guild
{
Guild* guild = new Guild;
if (!guild->Create(_player, name))
{
delete guild;
delete result;
return;
}
// register guild and add guildmaster
sGuildMgr.AddGuild(guild);
// add members
for (uint8 i = 0; i < signs; ++i)
{
Field* fields = result->Fetch();
ObjectGuid signGuid = ObjectGuid(HIGHGUID_PLAYER, fields[0].GetUInt32());
if (!signGuid)
continue;
guild->AddMember(signGuid, guild->GetLowestRank());
result->NextRow();
}
}
else // or arena team
{
ArenaTeam* at = new ArenaTeam;
if (!at->Create(_player->GetObjectGuid(), ArenaType(type), name))
{
sLog.outError("PetitionsHandler: arena team create failed.");
delete at;
delete result;
return;
}
示例8: HandleTurnInPetitionOpcode
//.........这里部分代码省略.........
if(type == 9)
{
if(objmgr.GetGuildByName(name))
{
SendGuildCommandResult(GUILD_CREATE_S, name, GUILD_NAME_EXISTS);
delete result;
return;
}
}
else
{
if(objmgr.GetArenaTeamByName(name))
{
SendArenaTeamCommandResult(ERR_ARENA_TEAM_CREATE_S, name, "", ERR_ARENA_TEAM_NAME_EXISTS_S);
delete result;
return;
}
}
// and at last charter item check
Item *item = _player->GetItemByGuid(petitionguid);
if(!item)
{
delete result;
return;
}
// OK!
// delete charter item
_player->DestroyItem(item->GetBagSlot(),item->GetSlot(), true);
if(type == 9) // create guild
{
Guild* guild = new Guild;
if(!guild->create(_player->GetGUID(), name))
{
delete guild;
delete result;
return;
}
// register guild and add guildmaster
objmgr.AddGuild(guild);
// add members
for(uint8 i = 0; i < signs; ++i)
{
Field* fields = result->Fetch();
guild->AddMember(fields[0].GetUInt64(), guild->GetLowestRank());
result->NextRow();
}
}
else // or arena team
{
ArenaTeam* at = new ArenaTeam;
if(!at->Create(_player->GetGUID(), type, name))
{
sLog.outError("PetitionsHandler: arena team create failed.");
delete at;
delete result;
return;
}
CHECK_PACKET_SIZE(recv_data, 8+5*4);
uint32 icon, iconcolor, border, bordercolor, backgroud;
recv_data >> backgroud >> icon >> iconcolor >> border >> bordercolor;
at->SetEmblem(backgroud, icon, iconcolor, border, bordercolor);
// register team and add captain
objmgr.AddArenaTeam(at);
sLog.outDebug("PetitonsHandler: arena team added to objmrg");
// add members
for(uint8 i = 0; i < signs; ++i)
{
Field* fields = result->Fetch();
uint64 memberGUID = fields[0].GetUInt64();
sLog.outDebug("PetitionsHandler: adding arena member %u", GUID_LOPART(memberGUID));
at->AddMember(memberGUID);
result->NextRow();
}
}
delete result;
CharacterDatabase.BeginTransaction();
CharacterDatabase.PExecute("DELETE FROM petition WHERE petitionguid = '%u'", GUID_LOPART(petitionguid));
CharacterDatabase.PExecute("DELETE FROM petition_sign WHERE petitionguid = '%u'", GUID_LOPART(petitionguid));
CharacterDatabase.CommitTransaction();
// created
sLog.outDebug("TURN IN PETITION GUID %u", GUID_LOPART(petitionguid));
data.Initialize(SMSG_TURN_IN_PETITION_RESULTS, 4);
data << (uint32)PETITION_TURN_OK;
SendPacket(&data);
}