本文整理汇总了C++中Guild类的典型用法代码示例。如果您正苦于以下问题:C++ Guild类的具体用法?C++ Guild怎么用?C++ Guild使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Guild类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: throw
////////////////////////////////////////////////////////////////////////////////
// 액션을 실행한다.
////////////////////////////////////////////////////////////////////////////////
void ActionModifyTaxRatio::execute (Creature * pCreature1 , Creature * pCreature2)
throw(Error)
{
__BEGIN_TRY
Assert(pCreature1 != NULL);
Assert(pCreature2 != NULL);
Assert(pCreature1->isNPC());
Assert(pCreature2->isPC());
bool bSuccess = true;
PlayerCreature* pPC = dynamic_cast<PlayerCreature*>(pCreature2);
Player* pPlayer = pPC->getPlayer();
Assert(pPlayer != NULL);
GuildID_t guildID = pPC->getGuildID();
GCNPCResponse deny;
Guild* pGuild = g_pGuildManager->getGuild(guildID);
if(bSuccess && pGuild == NULL )
{
// 길드가 없다.
bSuccess = false;
deny.setCode(NPC_RESPONSE_NO_GUILD);
}
if(bSuccess && pGuild->getMaster() != pPC->getName() )
{
// 길드 마스터가 아니다.
bSuccess = false;
deny.setCode(NPC_RESPONSE_NOT_GUILD_MASTER);
}
// 길드 마스터이다.
list<CastleInfo*> pCastleInfoList = g_pCastleInfoManager->getGuildCastleInfos(guildID);
if(bSuccess && pCastleInfoList.empty() )
{
// 길드가 소유한 성이 없다.
bSuccess = false;
deny.setCode(NPC_RESPONSE_HAS_NO_CASTLE);
}
list<CastleInfo*>::iterator itr = pCastleInfoList.begin();
CastleInfo* pCastleInfo = NULL;
for (; itr != pCastleInfoList.end() ; itr++ )
{
if ((*itr)->getZoneID() == pCreature1->getZoneID() )
{
pCastleInfo = (*itr);
break;
}
}
if(bSuccess && pCastleInfo == NULL)
{
bSuccess = false;
deny.setCode(NPC_RESPONSE_NOT_YOUR_CASTLE);
}
if (bSuccess )
{
GCNPCResponse response;
response.setCode(NPC_RESPONSE_SHOW_TAX_RATIO);
response.setParameter((uint)pCastleInfo->getItemTaxRatio());
pPlayer->sendPacket(&response);
}
else
{
pPlayer->sendPacket(&deny);
}
GCNPCResponse quit;
quit.setCode(NPC_RESPONSE_QUIT_DIALOGUE);
pPlayer->sendPacket(&quit);
__END_CATCH
}
示例2: bar
void GuildMgr::LoadGuilds()
{
Guild* newGuild;
uint32 count = 0;
// 0 1 2 3 4 5 6
QueryResult* result = CharacterDatabase.Query("SELECT guild.guildid,guild.name,leaderguid,EmblemStyle,EmblemColor,BorderStyle,BorderColor,"
// 7 8 9 10
"BackgroundColor,info,motd,createdate FROM guild ORDER BY guildid ASC");
if (!result)
{
BarGoLink bar(1);
bar.step();
sLog.outString();
sLog.outString(">> Loaded %u guild definitions", count);
return;
}
// load guild ranks
// 0 1 2 3
QueryResult* guildRanksResult = CharacterDatabase.Query("SELECT guildid,rid,rname,rights FROM guild_rank ORDER BY guildid ASC, rid ASC");
// load guild members
// 0 1 2 3 4
QueryResult* guildMembersResult = CharacterDatabase.Query("SELECT guildid,guild_member.guid,rank,pnote,offnote,"
// 5 6 7 8 9 10
"characters.name, characters.level, characters.class, characters.zone, characters.logout_time, characters.account "
"FROM guild_member LEFT JOIN characters ON characters.guid = guild_member.guid ORDER BY guildid ASC");
BarGoLink bar(result->GetRowCount());
do
{
// Field *fields = result->Fetch();
bar.step();
++count;
newGuild = new Guild;
if (!newGuild->LoadGuildFromDB(result) ||
!newGuild->LoadRanksFromDB(guildRanksResult) ||
!newGuild->LoadMembersFromDB(guildMembersResult) ||
!newGuild->CheckGuildStructure()
)
{
newGuild->Disband();
delete newGuild;
continue;
}
newGuild->LoadGuildEventLogFromDB();
AddGuild(newGuild);
}
while (result->NextRow());
delete result;
delete guildRanksResult;
delete guildMembersResult;
// delete unused LogGuid records in guild_eventlog table
// you can comment these lines if you don't plan to change CONFIG_UINT32_GUILD_EVENT_LOG_COUNT
CharacterDatabase.PExecute("DELETE FROM guild_eventlog WHERE LogGuid > '%u'", sWorld.getConfig(CONFIG_UINT32_GUILD_EVENT_LOG_COUNT));
sLog.outString();
sLog.outString(">> Loaded %u guild definitions", count);
}
示例3: while
//.........这里部分代码省略.........
if(!GetPlayer()->m_InstanceValid && !GetPlayer()->isGameMaster())
{
GetPlayer()->TeleportToHomebind();
//this is a bad place to call for far teleport because we need player to be in world for successful logout
//maybe we should implement delayed far teleport logout?
}
// FG: finish pending transfers after starting the logout
// this should fix players beeing able to logout and login back with full hp at death position
while(GetPlayer()->IsBeingTeleportedFar())
HandleMoveWorldportAckOpcode();
for (int i=0; i < PLAYER_MAX_BATTLEGROUND_QUEUES; ++i)
{
if(BattleGroundQueueTypeId bgQueueTypeId = GetPlayer()->GetBattleGroundQueueTypeId(i))
{
GetPlayer()->RemoveBattleGroundQueueId(bgQueueTypeId);
sBattleGroundMgr.m_BattleGroundQueues[ bgQueueTypeId ].RemovePlayer(GetPlayer()->GetObjectGuid(), true);
}
}
///- Reset the online field in the account table
// no point resetting online in character table here as Player::SaveToDB() will set it to 1 since player has not been removed from world at this stage
// No SQL injection as AccountID is uint32
if (!GetPlayer()->GetPlayerbotAI())
{
static SqlStatementID id;
SqlStatement stmt = LoginDatabase.CreateStatement(id, "UPDATE account SET active_realm_id = ? WHERE id = ?");
stmt.PExecute(uint32(0), GetAccountId());
}
///- If the player is in a guild, update the guild roster and broadcast a logout message to other guild members
Guild* guild = sGuildMgr.GetGuildById(GetPlayer()->GetGuildId());
if (guild)
{
if (MemberSlot* slot = guild->GetMemberSlot(GetPlayer()->GetObjectGuid()))
{
slot->SetMemberStats(GetPlayer());
slot->UpdateLogoutTime();
}
guild->BroadcastEvent(GE_SIGNED_OFF, GetPlayer()->GetObjectGuid(), GetPlayer()->GetName());
}
///- Remove pet
GetPlayer()->RemovePet(PET_SAVE_AS_CURRENT);
GetPlayer()->InterruptNonMeleeSpells(true);
if (VehicleKitPtr vehicle = GetPlayer()->GetVehicle())
{
if (Creature* base = ((Creature*)vehicle->GetBase()))
{
bool dismiss = true;
if (!base->IsTemporarySummon() ||
(base->GetVehicleInfo()->GetEntry()->m_flags & (VEHICLE_FLAG_NOT_DISMISS | VEHICLE_FLAG_ACCESSORY)))
dismiss = false;
if (!base->RemoveSpellsCausingAuraByCaster(SPELL_AURA_CONTROL_VEHICLE, GetPlayer()->GetObjectGuid()))
GetPlayer()->ExitVehicle();
if (base->HasAuraType(SPELL_AURA_CONTROL_VEHICLE))
dismiss = false;
if (dismiss)
示例4: CHECK_PACKET_SIZE
//.........这里部分代码省略.........
}
}
GetPlayer()->Whisper(player->GetGUID(), msg, lang);
GetPlayer()->UpdateSpeakTime();
} break;
case CHAT_MSG_PARTY:
{
std::string msg = "";
recv_data >> msg;
if (sChatHandler.ParseCommands(msg.c_str(), this) > 0)
break;
Group *group = GetPlayer()->groupInfo.group;
if(!group)
return;
WorldPacket data;
sChatHandler.FillMessageData(&data, this, CHAT_MSG_PARTY, lang, NULL, 0, msg.c_str());
group->BroadcastPacket(&data, group->GetMemberGroup(GetPlayer()->GetGUID()));
GetPlayer()->UpdateSpeakTime();
}
break;
case CHAT_MSG_GUILD:
{
std::string msg = "";
recv_data >> msg;
if (sChatHandler.ParseCommands(msg.c_str(), this) > 0)
break;
if (GetPlayer()->GetGuildId())
{
Guild *guild = objmgr.GetGuildById(GetPlayer()->GetGuildId());
if (guild)
{
guild->BroadcastToGuild(this, msg);
GetPlayer()->UpdateSpeakTime();
}
}
break;
}
case CHAT_MSG_OFFICER:
{
std::string msg = "";
recv_data >> msg;
if (sChatHandler.ParseCommands(msg.c_str(), this) > 0)
break;
if (GetPlayer()->GetGuildId())
{
Guild *guild = objmgr.GetGuildById(GetPlayer()->GetGuildId());
if (guild)
{
guild->BroadcastToOfficers(this, msg);
GetPlayer()->UpdateSpeakTime();
}
}
break;
}
case CHAT_MSG_RAID:
{
示例5: COUNT
void GuildMgr::LoadGuilds()
{
uint32 count = 0;
// 0 1 2 3 4 5 6
QueryResult* result = CharacterDatabase.Query("SELECT guild.guildid,guild.name,leaderguid,EmblemStyle,EmblemColor,BorderStyle,BorderColor,"
// 7 8 9 10 11 12
"BackgroundColor,info,motd,createdate,BankMoney,(SELECT COUNT(guild_bank_tab.guildid) FROM guild_bank_tab WHERE guild_bank_tab.guildid = guild.guildid) "
"FROM guild ORDER BY guildid ASC");
if (!result)
{
sLog.outString(">> Loaded %u guild definitions", count);
sLog.outString();
return;
}
// load guild ranks
// 0 1 2 3 4
QueryResult* guildRanksResult = CharacterDatabase.Query("SELECT guildid,rid,rname,rights,BankMoneyPerDay FROM guild_rank ORDER BY guildid ASC, rid ASC");
// load guild members
// 0 1 2 3 4 5 6
QueryResult* guildMembersResult = CharacterDatabase.Query("SELECT guildid,guild_member.guid,rank,pnote,offnote,BankResetTimeMoney,BankRemMoney,"
// 7 8 9 10 11 12
"BankResetTimeTab0,BankRemSlotsTab0,BankResetTimeTab1,BankRemSlotsTab1,BankResetTimeTab2,BankRemSlotsTab2,"
// 13 14 15 16 17 18
"BankResetTimeTab3,BankRemSlotsTab3,BankResetTimeTab4,BankRemSlotsTab4,BankResetTimeTab5,BankRemSlotsTab5,"
// 19 20 21 22 23 24
"characters.name, characters.level, characters.class, characters.zone, characters.logout_time, characters.account "
"FROM guild_member LEFT JOIN characters ON characters.guid = guild_member.guid ORDER BY guildid ASC");
// load guild bank tab rights
// 0 1 2 3 4
QueryResult* guildBankTabRightsResult = CharacterDatabase.Query("SELECT guildid,TabId,rid,gbright,SlotPerDay FROM guild_bank_right ORDER BY guildid ASC, TabId ASC");
do
{
// Field *fields = result->Fetch();
++count;
Guild* newGuild = new Guild;
if (!newGuild->LoadGuildFromDB(result) ||
!newGuild->LoadRanksFromDB(guildRanksResult) ||
!newGuild->LoadMembersFromDB(guildMembersResult) ||
!newGuild->LoadBankRightsFromDB(guildBankTabRightsResult) ||
!newGuild->CheckGuildStructure()
)
{
newGuild->Disband();
delete newGuild;
continue;
}
newGuild->LoadGuildEventLogFromDB();
newGuild->LoadGuildBankEventLogFromDB();
newGuild->LoadGuildBankFromDB();
AddGuild(newGuild);
}
while (result->NextRow());
delete result;
delete guildRanksResult;
delete guildMembersResult;
delete guildBankTabRightsResult;
// delete unused LogGuid records in guild_eventlog and guild_bank_eventlog table
// you can comment these lines if you don't plan to change CONFIG_UINT32_GUILD_EVENT_LOG_COUNT and CONFIG_UINT32_GUILD_BANK_EVENT_LOG_COUNT
CharacterDatabase.PExecute("DELETE FROM guild_eventlog WHERE LogGuid > '%u'", sWorld.getConfig(CONFIG_UINT32_GUILD_EVENT_LOG_COUNT));
CharacterDatabase.PExecute("DELETE FROM guild_bank_eventlog WHERE LogGuid > '%u'", sWorld.getConfig(CONFIG_UINT32_GUILD_BANK_EVENT_LOG_COUNT));
sLog.outString(">> Loaded %u guild definitions", count);
sLog.outString();
}
示例6: DEBUG_LOG
void WorldSession::HandleTurnInPetitionOpcode(WorldPacket& recv_data)
{
DEBUG_LOG("Received opcode CMSG_TURN_IN_PETITION"); // ok
// recv_data.hexlike();
ObjectGuid petitionGuid;
recv_data >> petitionGuid;
DEBUG_LOG("Petition %s turned in by %s", petitionGuid.GetString().c_str(), _player->GetGuidStr().c_str());
/// Collect petition info data
ObjectGuid ownerGuid;
uint32 type;
std::string name;
// data
QueryResult* result = CharacterDatabase.PQuery("SELECT ownerguid, name, type FROM petition WHERE petitionguid = '%u'", petitionGuid.GetCounter());
if (result)
{
Field* fields = result->Fetch();
ownerGuid = ObjectGuid(HIGHGUID_PLAYER, fields[0].GetUInt32());
name = fields[1].GetCppString();
type = fields[2].GetUInt32();
delete result;
}
else
{
sLog.outError("CMSG_TURN_IN_PETITION: petition table not have data for guid %u!", petitionGuid.GetCounter());
return;
}
if (type == 9)
{
if (_player->GetGuildId())
{
WorldPacket data(SMSG_TURN_IN_PETITION_RESULTS, 4);
data << uint32(PETITION_TURN_ALREADY_IN_GUILD); // already in guild
_player->GetSession()->SendPacket(&data);
return;
}
}
else
{
if (!IsArenaTypeValid(ArenaType(type)))
return;
uint8 slot = ArenaTeam::GetSlotByType(ArenaType(type));
if (slot >= MAX_ARENA_SLOT)
return;
if (_player->GetArenaTeamId(slot))
{
// data.Initialize(SMSG_TURN_IN_PETITION_RESULTS, 4);
// data << (uint32)PETITION_TURN_ALREADY_IN_GUILD; // already in guild
//_player->GetSession()->SendPacket(&data);
SendArenaTeamCommandResult(ERR_ARENA_TEAM_CREATE_S, name, "", ERR_ALREADY_IN_ARENA_TEAM);
return;
}
}
if (_player->GetObjectGuid() != ownerGuid)
return;
// signs
result = CharacterDatabase.PQuery("SELECT playerguid FROM petition_sign WHERE petitionguid = '%u'", petitionGuid.GetCounter());
uint8 signs = result ? (uint8)result->GetRowCount() : 0;
uint32 count = type == 9 ? sWorld.getConfig(CONFIG_UINT32_MIN_PETITION_SIGNS) : type - 1;
if (signs < count)
{
WorldPacket data(SMSG_TURN_IN_PETITION_RESULTS, 4);
data << uint32(PETITION_TURN_NEED_MORE_SIGNATURES); // need more signatures...
SendPacket(&data);
delete result;
return;
}
if (type == 9)
{
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)
//.........这里部分代码省略.........
示例7: GetPlayer
void WorldSession::LogoutPlayer(bool Save)
{
Player* pPlayer = GetPlayer();
if( _loggingOut )
return;
_loggingOut = true;
if( _player != NULL )
{
sHookInterface.OnLogout( pPlayer );
if( _player->DuelingWith )
_player->EndDuel( DUEL_WINNER_RETREAT );
if( _player->m_currentLoot && _player->IsInWorld() )
{
Object* obj = _player->GetMapMgr()->_GetObject( _player->m_currentLoot );
if( obj != NULL )
{
switch( obj->GetTypeId() )
{
case TYPEID_UNIT:
static_cast< Creature* >( obj )->loot.looters.erase( _player->GetGUIDLow() );
break;
case TYPEID_GAMEOBJECT:
static_cast< GameObject* >( obj )->loot.looters.erase( _player->GetGUIDLow() );
break;
}
}
}
// part channels
_player->CleanupChannels();
if( _player->m_CurrentTransporter != NULL )
_player->m_CurrentTransporter->RemovePlayer( _player );
// cancel current spell
if( _player->m_currentSpell != NULL )
_player->m_currentSpell->cancel();
sSocialMgr.LoggedOut( _player );
if( _player->GetTeam() == 1 )
{
if( sWorld.HordePlayers )
sWorld.HordePlayers--;
}
else
{
if( sWorld.AlliancePlayers )
sWorld.AlliancePlayers--;
}
if( _player->m_bg )
_player->m_bg->RemovePlayer( _player, true );
if( _player->m_bgIsQueued )
BattlegroundManager.RemovePlayerFromQueues( _player );
//Duel Cancel on Leave
if( _player->DuelingWith != NULL )
_player->EndDuel( DUEL_WINNER_RETREAT );
//Issue a message telling all guild members that this player signed off
if( _player->IsInGuild() )
{
Guild* pGuild = _player->m_playerInfo->guild;
if( pGuild != NULL )
pGuild->LogGuildEvent( GUILD_EVENT_HASGONEOFFLINE, 1, _player->GetName() );
}
_player->GetItemInterface()->EmptyBuyBack();
sLfgMgr.RemovePlayerFromLfgQueues( _player );
// Save HP/Mana
_player->load_health = _player->GetUInt32Value( UNIT_FIELD_HEALTH );
_player->load_mana = _player->GetUInt32Value( UNIT_FIELD_POWER1 );
objmgr.RemovePlayer( _player );
_player->ok_to_remove = true;
if( _player->GetSummon() != NULL )
_player->GetSummon()->Remove( false, true, false );
//_player->SaveAuras();
if( Save )
_player->SaveToDB(false);
_player->RemoveAllAuras();
if( _player->IsInWorld() )
_player->RemoveFromWorld();
_player->m_playerInfo->m_loggedInPlayer = NULL;
if( _player->m_playerInfo->m_Group != NULL )
_player->m_playerInfo->m_Group->Update();
//.........这里部分代码省略.........
示例8: loadAccount
//.........这里部分代码省略.........
player->lastLoginSaved = result->getDataLong("lastlogin");
player->lastLogout = result->getDataLong("lastlogout");
player->offlineTrainingTime = result->getDataInt("offlinetraining_time") * 1000;
player->offlineTrainingSkill = result->getDataInt("offlinetraining_skill");
player->town = result->getDataInt("town_id");
Town* town = Towns::getInstance().getTown(player->town);
if (town) {
player->masterPos = town->getTemplePosition();
}
Position loginPos = player->loginPosition;
if (loginPos.x == 0 && loginPos.y == 0 && loginPos.z == 0) {
player->loginPosition = player->masterPos;
}
player->staminaMinutes = result->getDataInt("stamina");
db->freeResult(result);
query.str("");
query << "SELECT `guild_id`, `rank_id`, `nick` FROM `guild_membership` WHERE `player_id` = " << player->getGUID();
if ((result = db->storeQuery(query.str()))) {
uint32_t guildId = result->getDataInt("guild_id");
uint32_t playerRankId = result->getDataInt("rank_id");
player->guildNick = result->getDataString("nick");
db->freeResult(result);
Guild* guild = g_game.getGuild(guildId);
if (!guild) {
query.str("");
query << "SELECT `name` FROM `guilds` WHERE `id` = " << guildId;
if ((result = db->storeQuery(query.str()))) {
guild = new Guild(guildId, result->getDataString("name"));
db->freeResult(result);
g_game.addGuild(guild);
query.str("");
query << "SELECT `id`, `name`, `level` FROM `guild_ranks` WHERE `guild_id` = " << guildId << " LIMIT 3";
if ((result = db->storeQuery(query.str()))) {
do {
guild->addRank(result->getDataInt("id"), result->getDataString("name"), result->getDataInt("level"));
} while (result->next());
db->freeResult(result);
}
}
}
if (guild) {
player->guild = guild;
GuildRank* rank = guild->getRankById(playerRankId);
if (rank) {
player->guildLevel = rank->level;
} else {
player->guildLevel = 1;
}
示例9: GUID_LOPART
void WorldSession::HandleTurnInPetitionOpcode(WorldPacket& recvData)
{
sLog->outDebug(LOG_FILTER_NETWORKIO, "Received opcode CMSG_TURN_IN_PETITION");
// Get petition guid from packet
WorldPacket data;
ObjectGuid petitionGuid;
uint8 bitsOrder[8] = { 2, 3, 5, 0, 7, 1, 4, 6 };
recvData.ReadBitInOrder(petitionGuid, bitsOrder);
recvData.FlushBits();
uint8 bytesOrder[8] = { 7, 5, 1, 3, 6, 4, 2, 0 };
recvData.ReadBytesSeq(petitionGuid, bytesOrder);
// Check if player really has the required petition charter
Item* item = _player->GetItemByGuid(petitionGuid);
if (!item)
return;
sLog->outDebug(LOG_FILTER_NETWORKIO, "Petition %u turned in by %u", GUID_LOPART(petitionGuid), _player->GetGUIDLow());
// Get petition data from db
uint32 ownerguidlo;
uint32 type;
std::string name;
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_PETITION);
stmt->setUInt32(0, GUID_LOPART(petitionGuid));
PreparedQueryResult result = CharacterDatabase.Query(stmt);
if (result)
{
Field* fields = result->Fetch();
ownerguidlo = fields[0].GetUInt32();
name = fields[1].GetString();
type = fields[2].GetUInt8();
}
else
{
sLog->outError(LOG_FILTER_NETWORKIO, "Player %s (guid: %u) tried to turn in petition (guid: %u) that is not present in the database", _player->GetName(), _player->GetGUIDLow(), GUID_LOPART(petitionGuid));
return;
}
// Only the petition owner can turn in the petition
if (_player->GetGUIDLow() != ownerguidlo)
return;
// Check if player is already in a guild
if (_player->GetGuildId())
{
data.Initialize(SMSG_TURN_IN_PETITION_RESULTS, 4);
data.WriteBits(PETITION_TURN_ALREADY_IN_GUILD, 4);
data.FlushBits();
SendPacket(&data);
return;
}
// Check if guild name is already taken
if (sGuildMgr->GetGuildByName(name))
{
Guild::SendCommandResult(this, GUILD_COMMAND_CREATE, ERR_GUILD_NAME_EXISTS_S, name);
return;
}
// Get petition signatures from db
uint8 signatures;
stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_PETITION_SIGNATURE);
stmt->setUInt32(0, GUID_LOPART(petitionGuid));
result = CharacterDatabase.Query(stmt);
if (result)
signatures = uint8(result->GetRowCount());
else
signatures = 0;
uint32 requiredSignatures;
requiredSignatures = sWorld->getIntConfig(CONFIG_MIN_PETITION_SIGNS);
// Notify player if signatures are missing
if (signatures < requiredSignatures)
{
data.Initialize(SMSG_TURN_IN_PETITION_RESULTS, 4);
data.WriteBits(PETITION_TURN_NEED_MORE_SIGNATURES, 4);
data.FlushBits();
SendPacket(&data);
return;
}
// Proceed with guild/arena team creation
// Delete charter item
_player->DestroyItem(item->GetBagSlot(), item->GetSlot(), true);
// Create guild
Guild* guild = new Guild;
if (!guild->Create(_player, name))
//.........这里部分代码省略.........
示例10: printf
void WorldSession::HandleGuildRankOpcode(WorldPacket& recvPacket)
{
uint32 BankStacks[GUILD_BANK_MAX_TABS];
for (uint32 i = 0; i < GUILD_BANK_MAX_TABS; i++)
recvPacket >> BankStacks[i];
uint32 new_rights;
recvPacket >> new_rights;
uint32 new_rankId;
recvPacket >> new_rankId;
uint32 old_rankId;
recvPacket >> old_rankId;
uint32 BankRights[GUILD_BANK_MAX_TABS];
for (uint32 i = 0; i < GUILD_BANK_MAX_TABS; i++)
recvPacket >> BankRights[i];
uint64 guildId;
recvPacket >> guildId;
uint32 old_rights;
recvPacket >> old_rights;
uint32 money;
recvPacket >> money;
uint64 playerGuid;
recvPacket >> playerGuid;
std::string rankName;
recvPacket >> rankName;
sLog->outDebug(LOG_FILTER_GUILD, "WORLD: Received CMSG_GUILD_RANK");
if (GetPlayer()->GetGUID() != playerGuid)
{
printf("CMSG_GUILD_RANK: The playerGUID in the packet does not match the current player!\n");
recvPacket.rpos(recvPacket.wpos());
Guild::SendCommandResult(this, GUILD_CREATE_S, ERR_GUILD_PLAYER_NOT_IN_GUILD);
return;
}
if (GetPlayer()->GetGuildId() != GUID_LOPART(guildId))
{
printf("CMSG_GUILD_RANK: This player is not in the guild.\n");
recvPacket.rpos(recvPacket.wpos());
Guild::SendCommandResult(this, GUILD_CREATE_S, ERR_GUILD_PLAYER_NOT_IN_GUILD);
return;
}
Guild* guild = _GetPlayerGuild(this, true);
if (!guild)
{
recvPacket.rpos(recvPacket.wpos());
return;
}
GuildBankRightsAndSlotsVec rightsAndSlots(GUILD_BANK_MAX_TABS);
if (old_rankId != GR_GUILDMASTER)
{
for (uint8 tabId = 0; tabId < GUILD_BANK_MAX_TABS; ++tabId)
{
rightsAndSlots[tabId] = GuildBankRightsAndSlots(BankRights[tabId], BankStacks[tabId]);
}
money *= GOLD; // In game is in gold, in core set in bronze
guild->HandleSetRankInfo(this, new_rankId, rankName, new_rights, money, rightsAndSlots);
}
if (old_rankId != new_rankId && old_rankId != GR_GUILDMASTER && new_rankId != GR_GUILDMASTER)
guild->ChangeMemberRank(old_rankId, new_rankId);
}
示例11: Player
void WorldSession::HandlePlayerLogin(LoginQueryHolder * holder)
{
uint64 playerGuid = holder->GetGuid();
Player* pCurrChar = new Player(this);
pCurrChar->GetMotionMaster()->Initialize();
// "GetAccountId()==db stored account id" checked in LoadFromDB (prevent login not own character using cheating tools)
if(!pCurrChar->LoadFromDB(GUID_LOPART(playerGuid), holder))
{
KickPlayer(); // disconnect client, player no set to session and it will not deleted or saved at kick
delete pCurrChar; // delete it manually
delete holder; // delete all unprocessed queries
m_playerLoading = false;
return;
}
SetPlayer(pCurrChar);
pCurrChar->SendDungeonDifficulty(false);
WorldPacket data( SMSG_LOGIN_VERIFY_WORLD, 20 );
data << pCurrChar->GetMapId();
data << pCurrChar->GetPositionX();
data << pCurrChar->GetPositionY();
data << pCurrChar->GetPositionZ();
data << pCurrChar->GetOrientation();
SendPacket(&data);
data.Initialize( SMSG_ACCOUNT_DATA_TIMES, 4+1+8*4 ); // changed in WotLK
data << uint32(time(NULL)); // unix time of something
data << uint8(1);
for(int i = 0; i < NUM_ACCOUNT_DATA_TYPES; ++i)
data << uint32(GetAccountData(i)->Time); // also unix time
SendPacket(&data);
data.Initialize(SMSG_FEATURE_SYSTEM_STATUS, 2); // added in 2.2.0
data << uint8(2); // unknown value
data << uint8(0); // enable(1)/disable(0) voice chat interface in client
SendPacket(&data);
// Send MOTD
{
data.Initialize(SMSG_MOTD, 50); // new in 2.0.1
data << (uint32)0;
uint32 linecount=0;
std::string str_motd = sWorld.GetMotd();
std::string::size_type pos, nextpos;
pos = 0;
while ( (nextpos= str_motd.find('@',pos)) != std::string::npos )
{
if (nextpos != pos)
{
data << str_motd.substr(pos,nextpos-pos);
++linecount;
}
pos = nextpos+1;
}
if (pos<str_motd.length())
{
data << str_motd.substr(pos);
++linecount;
}
data.put(0, linecount);
SendPacket( &data );
DEBUG_LOG( "WORLD: Sent motd (SMSG_MOTD)" );
}
data.Initialize(SMSG_LEARNED_DANCE_MOVES, 4+4);
data << uint32(0);
data << uint32(0);
SendPacket(&data);
//QueryResult *result = CharacterDatabase.PQuery("SELECT guildid,rank FROM guild_member WHERE guid = '%u'",pCurrChar->GetGUIDLow());
QueryResult *resultGuild = holder->GetResult(PLAYER_LOGIN_QUERY_LOADGUILD);
if(resultGuild)
{
Field *fields = resultGuild->Fetch();
pCurrChar->SetInGuild(fields[0].GetUInt32());
pCurrChar->SetRank(fields[1].GetUInt32());
delete resultGuild;
}
else if(pCurrChar->GetGuildId()) // clear guild related fields in case wrong data about non existed membership
{
pCurrChar->SetInGuild(0);
pCurrChar->SetRank(0);
}
if(pCurrChar->GetGuildId() != 0)
{
Guild* guild = objmgr.GetGuildById(pCurrChar->GetGuildId());
if(guild)
{
data.Initialize(SMSG_GUILD_EVENT, (2+guild->GetMOTD().size()+1));
//.........这里部分代码省略.........
示例12: TC_LOG_DEBUG
void WorldSession::HandleCalendarGetCalendar(WorldPacket& /*recvData*/)
{
uint64 guid = _player->GetGUID();
TC_LOG_DEBUG(LOG_FILTER_NETWORKIO, "CMSG_CALENDAR_GET_CALENDAR [" UI64FMTD "]", guid);
time_t currTime = time(NULL);
WorldPacket data(SMSG_CALENDAR_SEND_CALENDAR, 1000); // Average size if no instance
CalendarInviteStore invites = sCalendarMgr->GetPlayerInvites(guid);
data << uint32(invites.size());
for (CalendarInviteStore::const_iterator itr = invites.begin(); itr != invites.end(); ++itr)
{
data << uint64((*itr)->GetEventId());
data << uint64((*itr)->GetInviteId());
data << uint8((*itr)->GetStatus());
data << uint8((*itr)->GetRank());
if (CalendarEvent* calendarEvent = sCalendarMgr->GetEvent((*itr)->GetEventId()))
{
data << uint8(calendarEvent->IsGuildEvent());
data.appendPackGUID(calendarEvent->GetCreatorGUID());
}
else
{
data << uint8(0);
data.appendPackGUID((*itr)->GetSenderGUID());
}
}
CalendarEventStore playerEvents = sCalendarMgr->GetPlayerEvents(guid);
data << uint32(playerEvents.size());
for (CalendarEventStore::const_iterator itr = playerEvents.begin(); itr != playerEvents.end(); ++itr)
{
CalendarEvent* calendarEvent = *itr;
data << uint64(calendarEvent->GetEventId());
data << calendarEvent->GetTitle();
data << uint32(calendarEvent->GetType());
data.AppendPackedTime(calendarEvent->GetEventTime());
data << uint32(calendarEvent->GetFlags());
data << int32(calendarEvent->GetDungeonId());
Guild* guild = sGuildMgr->GetGuildById(calendarEvent->GetGuildId());
data << uint64(guild ? guild->GetGUID() : 0);
data.appendPackGUID(calendarEvent->GetCreatorGUID());
}
data << uint32(currTime); // server time
data.AppendPackedTime(currTime); // zone time
ByteBuffer dataBuffer;
uint32 boundCounter = 0;
for (uint8 i = 0; i < MAX_DIFFICULTY; ++i)
{
Player::BoundInstancesMap boundInstances = _player->GetBoundInstances(Difficulty(i));
for (Player::BoundInstancesMap::const_iterator itr = boundInstances.begin(); itr != boundInstances.end(); ++itr)
{
if (itr->second.perm)
{
InstanceSave const* save = itr->second.save;
dataBuffer << uint32(save->GetMapId());
dataBuffer << uint32(save->GetDifficulty());
dataBuffer << uint32(save->GetResetTime() - currTime);
dataBuffer << uint64(save->GetInstanceId()); // instance save id as unique instance copy id
++boundCounter;
}
}
}
data << uint32(boundCounter);
data.append(dataBuffer);
data << uint32(1135753200); // Constant date, unk (28.12.2005 07:00)
// Reuse variables
boundCounter = 0;
std::set<uint32> sentMaps;
dataBuffer.clear();
ResetTimeByMapDifficultyMap const& resets = sInstanceSaveMgr->GetResetTimeMap();
for (ResetTimeByMapDifficultyMap::const_iterator itr = resets.begin(); itr != resets.end(); ++itr)
{
uint32 mapId = PAIR32_LOPART(itr->first);
if (sentMaps.find(mapId) != sentMaps.end())
continue;
MapEntry const* mapEntry = sMapStore.LookupEntry(mapId);
if (!mapEntry || !mapEntry->IsRaid())
continue;
sentMaps.insert(mapId);
dataBuffer << int32(mapId);
dataBuffer << int32(itr->second - currTime);
dataBuffer << int32(0); // Never seen anything else in sniffs - still unknown
++boundCounter;
}
//.........这里部分代码省略.........
示例13: TC_LOG_DEBUG
void WorldSession::HandleGuildFinderBrowse(WorldPacket& recvPacket)
{
TC_LOG_DEBUG("network", "WORLD: Received CMSG_LF_GUILD_BROWSE");
uint32 classRoles = 0;
uint32 availability = 0;
uint32 guildInterests = 0;
uint32 playerLevel = 0; // Raw player level (1-85), do they use MAX_FINDER_LEVEL when on level 85 ?
recvPacket >> classRoles >> availability >> guildInterests >> playerLevel;
if (!(classRoles & GUILDFINDER_ALL_ROLES) || classRoles > GUILDFINDER_ALL_ROLES)
return;
if (!(availability & AVAILABILITY_ALWAYS) || availability > AVAILABILITY_ALWAYS)
return;
if (!(guildInterests & ALL_INTERESTS) || guildInterests > ALL_INTERESTS)
return;
if (playerLevel > sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL) || playerLevel < 1)
return;
Player* player = GetPlayer();
LFGuildPlayer settings(player->GetGUIDLow(), classRoles, availability, guildInterests, ANY_FINDER_LEVEL);
LFGuildStore guildList = sGuildFinderMgr->GetGuildsMatchingSetting(settings, player->GetTeamId());
uint32 guildCount = guildList.size();
if (guildCount == 0)
{
WorldPacket packet(SMSG_LF_GUILD_BROWSE_UPDATED, 0);
player->SendDirectMessage(&packet);
return;
}
ByteBuffer bufferData(65 * guildCount);
WorldPacket data(SMSG_LF_GUILD_BROWSE_UPDATED, 3 + guildCount * 65); // Estimated size
data.WriteBits(guildCount, 19);
for (LFGuildStore::const_iterator itr = guildList.begin(); itr != guildList.end(); ++itr)
{
LFGuildSettings guildSettings = itr->second;
Guild* guild = sGuildMgr->GetGuildById(itr->first);
ObjectGuid guildGUID = ObjectGuid(guild->GetGUID());
data.WriteBit(guildGUID[7]);
data.WriteBit(guildGUID[5]);
data.WriteBits(guild->GetName().size(), 8);
data.WriteBit(guildGUID[0]);
data.WriteBits(guildSettings.GetComment().size(), 11);
data.WriteBit(guildGUID[4]);
data.WriteBit(guildGUID[1]);
data.WriteBit(guildGUID[2]);
data.WriteBit(guildGUID[6]);
data.WriteBit(guildGUID[3]);
bufferData << uint32(guild->GetEmblemInfo().GetColor());
bufferData << uint32(guild->GetEmblemInfo().GetBorderStyle()); // Guessed
bufferData << uint32(guild->GetEmblemInfo().GetStyle());
bufferData.WriteString(guildSettings.GetComment());
bufferData << uint8(0); // Unk
bufferData.WriteByteSeq(guildGUID[5]);
bufferData << uint32(guildSettings.GetInterests());
bufferData.WriteByteSeq(guildGUID[6]);
bufferData.WriteByteSeq(guildGUID[4]);
bufferData << uint32(guild->GetLevel());
bufferData.WriteString(guild->GetName());
bufferData << uint32(guild->GetAchievementMgr().GetAchievementPoints());
bufferData.WriteByteSeq(guildGUID[7]);
bufferData << uint8(sGuildFinderMgr->HasRequest(player->GetGUIDLow(), guild->GetGUID())); // Request pending
bufferData.WriteByteSeq(guildGUID[2]);
bufferData.WriteByteSeq(guildGUID[0]);
bufferData << uint32(guildSettings.GetAvailability());
bufferData.WriteByteSeq(guildGUID[1]);
bufferData << uint32(guild->GetEmblemInfo().GetBackgroundColor());
bufferData << uint32(0); // Unk Int 2 (+ 128) // Always 0 or 1
bufferData << uint32(guild->GetEmblemInfo().GetBorderColor());
bufferData << uint32(guildSettings.GetClassRoles());
bufferData.WriteByteSeq(guildGUID[3]);
bufferData << uint32(guild->GetMembersCount());
}
data.FlushBits();
data.append(bufferData);
player->SendDirectMessage(&data);
}
示例14: Player
void WorldSession::HandlePlayerLogin(LoginQueryHolder *holder)
{
uint64 playerGuid = holder->GetGuid();
Player *pCurrChar = new Player(this);
pCurrChar->GetMotionMaster()->Initialize();
// "GetAccountId()==db stored account id" checked in LoadFromDB (prevent login not own character using cheating tools)
if(!pCurrChar->LoadFromDB(GUID_LOPART(playerGuid), holder))
{
KickPlayer(); // disconnect client, player no set to session and it will not deleted or saved at kick
delete pCurrChar; // delete it manually
delete holder; // delete all unprocessed queries
m_playerLoading = false;
return;
}
SetPlayer(pCurrChar);
pCurrChar->SendDungeonDifficulty(false);
WorldPacket data( SMSG_LOGIN_VERIFY_WORLD, 20 );
data << pCurrChar->GetMapId();
data << pCurrChar->GetPositionX();
data << pCurrChar->GetPositionY();
data << pCurrChar->GetPositionZ();
data << pCurrChar->GetOrientation();
SendPacket(&data);
// load player specific part before send times
LoadAccountData(holder->GetResult(PLAYER_LOGIN_QUERY_LOADACCOUNTDATA),PER_CHARACTER_CACHE_MASK);
SendAccountDataTimes(PER_CHARACTER_CACHE_MASK);
data.Initialize(SMSG_FEATURE_SYSTEM_STATUS, 2); // added in 2.2.0
data << uint8(2); // unknown value
data << uint8(0); // enable(1)/disable(0) voice chat interface in client
SendPacket(&data);
// Send MOTD
{
data.Initialize(SMSG_MOTD, 50); // new in 2.0.1
data << (uint32)0;
uint32 linecount=0;
std::string str_motd = sWorld.GetMotd();
std::string::size_type pos, nextpos;
pos = 0;
while ( (nextpos= str_motd.find('@',pos)) != std::string::npos )
{
if (nextpos != pos)
{
data << str_motd.substr(pos, nextpos-pos);
++linecount;
}
pos = nextpos + 1;
}
if (pos < str_motd.length())
{
data << str_motd.substr(pos);
++linecount;
}
data.put(0, linecount);
SendPacket( &data );
DEBUG_LOG( "WORLD: Sent motd (SMSG_MOTD)" );
}
//QueryResult *result = CharacterDatabase.PQuery("SELECT guildid,rank FROM guild_member WHERE guid = '%u'",pCurrChar->GetGUIDLow());
QueryResult *resultGuild = holder->GetResult(PLAYER_LOGIN_QUERY_LOADGUILD);
if(resultGuild)
{
Field *fields = resultGuild->Fetch();
pCurrChar->SetInGuild(fields[0].GetUInt32());
pCurrChar->SetRank(fields[1].GetUInt32());
delete resultGuild;
}
else if(pCurrChar->GetGuildId()) // clear guild related fields in case wrong data about non existed membership
{
pCurrChar->SetInGuild(0);
pCurrChar->SetRank(0);
}
if(pCurrChar->GetGuildId() != 0)
{
Guild* guild = sObjectMgr.GetGuildById(pCurrChar->GetGuildId());
if(guild)
{
data.Initialize(SMSG_GUILD_EVENT, (1+1+guild->GetMOTD().size()+1));
data << uint8(GE_MOTD);
data << uint8(1);
data << guild->GetMOTD();
SendPacket(&data);
DEBUG_LOG( "WORLD: Sent guild-motd (SMSG_GUILD_EVENT)" );
guild->DisplayGuildBankTabsInfo(this);
//.........这里部分代码省略.........
示例15: GUID_LOPART
void WorldSession::HandleTurnInPetitionOpcode(WorldPacket & recv_data)
{
sLog->outDebug(LOG_FILTER_NETWORKIO, "Received opcode CMSG_TURN_IN_PETITION");
// Get petition guid from packet
WorldPacket data;
uint64 petitionGuid;
recv_data >> petitionGuid;
// Check if player really has the required petition charter
Item* item = _player->GetItemByGuid(petitionGuid);
if (!item)
return;
sLog->outDebug(LOG_FILTER_NETWORKIO, "Petition %u turned in by %u", GUID_LOPART(petitionGuid), _player->GetGUIDLow());
// Get petition data from db
uint32 ownerguidlo;
uint32 type;
std::string name;
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_LOAD_PETITION);
stmt->setUInt32(0, GUID_LOPART(petitionGuid));
PreparedQueryResult result = CharacterDatabase.Query(stmt);
if (result)
{
Field* fields = result->Fetch();
ownerguidlo = fields[0].GetUInt32();
name = fields[1].GetString();
type = fields[2].GetUInt8();
}
else
{
sLog->outError("Player %s (guid: %u) tried to turn in petition (guid: %u) that is not present in the database", _player->GetName(), _player->GetGUIDLow(), GUID_LOPART(petitionGuid));
return;
}
// Only the petition owner can turn in the petition
if (_player->GetGUIDLow() != ownerguidlo)
return;
// Petition type (guild/arena) specific checks
if (type == GUILD_CHARTER_TYPE)
{
// Check if player is already in a guild
if (_player->GetGuildId())
{
data.Initialize(SMSG_TURN_IN_PETITION_RESULTS, 4);
data << (uint32)PETITION_TURN_ALREADY_IN_GUILD;
_player->GetSession()->SendPacket(&data);
return;
}
// Check if guild name is already taken
if (sGuildMgr->GetGuildByName(name))
{
Guild::SendCommandResult(this, GUILD_CREATE_S, ERR_GUILD_NAME_EXISTS_S, name);
return;
}
}
else
{
// Check for valid arena bracket (2v2, 3v3, 5v5)
uint8 slot = ArenaTeam::GetSlotByType(type);
if (slot >= MAX_ARENA_SLOT)
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;
}
}
// Get petition signatures from db
uint8 signatures;
stmt = CharacterDatabase.GetPreparedStatement(CHAR_LOAD_PETITION_SIGNATURE);
stmt->setUInt32(0, GUID_LOPART(petitionGuid));
result = CharacterDatabase.Query(stmt);
if (result)
signatures = uint8(result->GetRowCount());
else
signatures = 0;
uint32 requiredSignatures;
if (type == GUILD_CHARTER_TYPE)
requiredSignatures = sWorld->getIntConfig(CONFIG_MIN_PETITION_SIGNS);
else
//.........这里部分代码省略.........