本文整理汇总了C++中Guild::Create方法的典型用法代码示例。如果您正苦于以下问题:C++ Guild::Create方法的具体用法?C++ Guild::Create怎么用?C++ Guild::Create使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Guild
的用法示例。
在下文中一共展示了Guild::Create方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: HandleGuildCreateOpcode
void WorldSession::HandleGuildCreateOpcode(WorldPacket& recvPacket)
{
DEBUG_LOG("WORLD: Received CMSG_GUILD_CREATE");
std::string gname;
recvPacket >> gname;
if (!GetPlayer()->isGameMaster())
{
sLog.outError("WorldSession::HandleGuildCreateOpcode Possible hacking-attempt: %s tried to create a guild [Name: %s] using cheats!", GetPlayer()->GetObjectGuid().GetString().c_str(), gname.c_str());
return;
}
if (GetPlayer()->GetGuildId()) // already in guild
return;
Guild* guild = new Guild;
if (!guild->Create(GetPlayer(), gname))
{
delete guild;
return;
}
sGuildMgr.AddGuild(guild);
}
示例2: HandleGuildCreateOpcode
// Cata status: Not used.
void WorldSession::HandleGuildCreateOpcode(WorldPacket& recvPacket) {
sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Received CMSG_GUILD_CREATE");
std::string name;
recvPacket >> name;
if (!GetPlayer()->GetGuildId()) // Player cannot be in guild
{
Guild* pGuild = new Guild();
if (pGuild->Create(GetPlayer(), name))
sObjectMgr->AddGuild(pGuild);
else
delete pGuild;
}
}
示例3: HandleGuildCreateOpcode
void WorldSession::HandleGuildCreateOpcode(WorldPacket& recvPacket)
{
DEBUG_LOG("WORLD: Received opcode CMSG_GUILD_CREATE");
std::string gname;
recvPacket >> gname;
if (GetPlayer()->GetGuildId()) // already in guild
{ return; }
Guild* guild = new Guild;
if (!guild->Create(GetPlayer(), gname))
{
delete guild;
return;
}
sGuildMgr.AddGuild(guild);
}
示例4: HandleGuildCreateCommand
/** \brief GM command level 3 - Create a guild.
*
* This command allows a GM (level 3) to create a guild.
*
* The "args" parameter contains the name of the guild leader
* and then the name of the guild.
*
*/
static bool HandleGuildCreateCommand(ChatHandler* handler, char const* args)
{
if (!*args)
return false;
// if not guild name only (in "") then player name
Player* target;
if (!handler->extractPlayerTarget(*args != '"' ? (char*)args : NULL, &target))
return false;
char* tailStr = *args != '"' ? strtok(NULL, "") : (char*)args;
if (!tailStr)
return false;
char* guildStr = handler->extractQuotedArg(tailStr);
if (!guildStr)
return false;
std::string guildName = guildStr;
if (target->GetGuildId())
{
handler->SendSysMessage(LANG_PLAYER_IN_GUILD);
return true;
}
Guild* guild = new Guild;
if (!guild->Create(target, guildName))
{
delete guild;
handler->SendSysMessage(LANG_GUILD_NOT_CREATED);
handler->SetSentErrorMessage(true);
return false;
}
sGuildMgr->AddGuild(guild);
return true;
}
示例5: HandleTurnInPetition
void WorldSession::HandleTurnInPetition(WorldPackets::Petition::TurnInPetition& packet)
{
// Check if player really has the required petition charter
Item* item = _player->GetItemByGuid(packet.Item);
if (!item)
return;
TC_LOG_DEBUG("network", "Petition %s turned in by %s", packet.Item.ToString().c_str(), _player->GetGUID().ToString().c_str());
// Get petition data from db
ObjectGuid ownerguid;
std::string name;
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_PETITION);
stmt->setUInt64(0, packet.Item.GetCounter());
PreparedQueryResult result = CharacterDatabase.Query(stmt);
if (result)
{
Field* fields = result->Fetch();
ownerguid = ObjectGuid::Create<HighGuid::Player>(fields[0].GetUInt64());
name = fields[1].GetString();
}
else
{
TC_LOG_ERROR("network", "Player %s (%s) tried to turn in petition (%s) that is not present in the database", _player->GetName().c_str(), _player->GetGUID().ToString().c_str(), packet.Item.ToString().c_str());
return;
}
// Only the petition owner can turn in the petition
if (_player->GetGUID() != ownerguid)
return;
// Check if player is already in a guild
if (_player->GetGuildId())
{
WorldPackets::Petition::TurnInPetitionResult resultPacket;
resultPacket.Result = int32(PETITION_TURN_ALREADY_IN_GUILD);
_player->GetSession()->SendPacket(resultPacket.Write());
return;
}
// Check if guild name is already taken
if (sGuildMgr->GetGuildByName(name))
{
Guild::SendCommandResult(this, GUILD_COMMAND_CREATE_GUILD, ERR_GUILD_NAME_EXISTS_S, name);
return;
}
// Get petition signatures from db
uint8 signatures;
stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_PETITION_SIGNATURE);
stmt->setUInt64(0, packet.Item.GetCounter());
result = CharacterDatabase.Query(stmt);
if (result)
signatures = uint8(result->GetRowCount());
else
signatures = 0;
uint32 requiredSignatures = sWorld->getIntConfig(CONFIG_MIN_PETITION_SIGNS);
// Notify player if signatures are missing
if (signatures < requiredSignatures)
{
WorldPackets::Petition::TurnInPetitionResult resultPacket;
resultPacket.Result = int32(PETITION_TURN_NEED_MORE_SIGNATURES);
SendPacket(resultPacket.Write());
return;
}
// Proceed with guild creation
// Delete charter item
_player->DestroyItem(item->GetBagSlot(), item->GetSlot(), true);
// Create guild
Guild* guild = new Guild;
if (!guild->Create(_player, name))
{
delete guild;
return;
}
// Register guild and add guild master
sGuildMgr->AddGuild(guild);
Guild::SendCommandResult(this, GUILD_COMMAND_CREATE_GUILD, ERR_GUILD_COMMAND_SUCCESS, name);
// Add members from signatures
for (uint8 i = 0; i < signatures; ++i)
{
Field* fields = result->Fetch();
guild->AddMember(ObjectGuid::Create<HighGuid::Player>(fields[0].GetUInt64()));
// Checking the return value just to be double safe
if (!result->NextRow())
break;
//.........这里部分代码省略.........
示例6: 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;
}
示例7: HandleTurnInPetitionOpcode
//.........这里部分代码省略.........
count = sWorld.getConfig(CONFIG_MIN_PETITION_SIGNS);
else
count = type-1;
if (signs < count)
{
data.Initialize(SMSG_TURN_IN_PETITION_RESULTS, 4);
data << (uint32)PETITION_TURN_NEED_MORE_SIGNATURES; // need more signatures...
SendPacket(&data);
return;
}
if (type == 9)
{
if (objmgr.GetGuildByName(name))
{
SendGuildCommandResult(GUILD_CREATE_S, name, ERR_GUILD_NAME_EXISTS_S);
return;
}
}
else
{
if (objmgr.GetArenaTeamByName(name))
{
SendArenaTeamCommandResult(ERR_ARENA_TEAM_CREATE_S, name, "", ERR_ARENA_TEAM_NAME_EXISTS_S);
return;
}
}
// and at last charter item check
Item *item = _player->GetItemByGuid(petitionguid);
if (!item)
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;
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;
return;
}
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();
}
}
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);
}
示例8: HandleTurnInPetitionOpcode
void WorldSession::HandleTurnInPetitionOpcode(WorldPacket & recv_data) {
sLog->outDebug(LOG_FILTER_NETWORKIO,
"Received opcode CMSG_TURN_IN_PETITION"); // ok
WorldPacket data;
uint64 petitionguid;
uint32 ownerguidlo;
std::string name;
recv_data >> petitionguid;
sLog->outDebug(LOG_FILTER_NETWORKIO, "Petition %u turned in by %u",
GUID_LOPART(petitionguid), _player->GetGUIDLow());
// data
QueryResult result = CharacterDatabase.PQuery(
"SELECT ownerguid, name FROM petition WHERE petitionguid = '%u'",
GUID_LOPART(petitionguid));
if (result) {
Field *fields = result->Fetch();
ownerguidlo = fields[0].GetUInt32();
name = fields[1].GetString();
} else {
sLog->outError("petition table has broken data!");
return;
}
if (_player->GetGuildId()) {
data.Initialize(SMSG_TURN_IN_PETITION_RESULTS, 4);
data << (uint32) PETITION_TURN_ALREADY_IN_GUILD; // already in guild
_player->GetSession()->SendPacket(&data);
return;
}
if (_player->GetGUIDLow() != ownerguidlo)
return;
// signs
uint8 signs;
result = CharacterDatabase.PQuery(
"SELECT playerguid FROM petition_sign WHERE petitionguid = '%u'",
GUID_LOPART(petitionguid));
if (result)
signs = uint8(result->GetRowCount());
else
signs = 0;
if (signs < sWorld->getIntConfig(CONFIG_MIN_PETITION_SIGNS)) {
data.Initialize(SMSG_TURN_IN_PETITION_RESULTS, 4);
data << (uint32) PETITION_TURN_NEED_MORE_SIGNATURES; // need more signatures...
SendPacket(&data);
return;
}
if (sObjectMgr->GetGuildByName(name)) {
Guild::SendCommandResult(this, GUILD_CREATE_S, ERR_GUILD_NAME_EXISTS_S,
name);
return;
}
// and at last charter item check
Item *item = _player->GetItemByGuid(petitionguid);
if (!item)
return;
// delete charter item
_player->DestroyItem(item->GetBagSlot(), item->GetSlot(), true);
Guild* guild = new Guild;
if (!guild->Create(_player, name)) {
delete guild;
return;
}
// register guild and add guildmaster
sObjectMgr->AddGuild(guild);
// add members
for (uint8 i = 0; i < signs; ++i) {
Field* fields = result->Fetch();
guild->AddMember(fields[0].GetUInt64());
result->NextRow();
}
SQLTransaction trans = CharacterDatabase.BeginTransaction();
trans->PAppend("DELETE FROM petition WHERE petitionguid = '%u'",
GUID_LOPART(petitionguid));
trans->PAppend("DELETE FROM petition_sign WHERE petitionguid = '%u'",
GUID_LOPART(petitionguid));
CharacterDatabase.CommitTransaction(trans);
// created
sLog->outDebug(LOG_FILTER_NETWORKIO, "TURN IN PETITION GUID %u",
GUID_LOPART(petitionguid));
data.Initialize(SMSG_TURN_IN_PETITION_RESULTS, 4);
data << (uint32) PETITION_TURN_OK;
SendPacket(&data);
}
示例9: HandleTurnInPetitionOpcode
//.........这里部分代码省略.........
{
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 << (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;
}
// 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 << (uint32)PETITION_TURN_NEED_MORE_SIGNATURES;
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))
{
delete guild;
return;
}
// Register guild and add guild master
sGuildMgr->AddGuild(guild);
// Add members from signatures
for (uint8 i = 0; i < signatures; ++i)
{
Field* fields = result->Fetch();
guild->AddMember(MAKE_NEW_GUID(fields[0].GetUInt32(), 0, HIGHGUID_PLAYER));
result->NextRow();
}
SQLTransaction trans = CharacterDatabase.BeginTransaction();
stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_PETITION_BY_GUID);
stmt->setUInt32(0, GUID_LOPART(petitionGuid));
trans->Append(stmt);
stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_PETITION_SIGNATURE_BY_GUID);
stmt->setUInt32(0, GUID_LOPART(petitionGuid));
trans->Append(stmt);
CharacterDatabase.CommitTransaction(trans);
// created
sLog->outDebug(LOG_FILTER_NETWORKIO, "TURN IN PETITION GUID %u", GUID_LOPART(petitionGuid));
data.Initialize(SMSG_TURN_IN_PETITION_RESULTS, 4);
data << (uint32)PETITION_TURN_OK;
SendPacket(&data);
}
示例10: HandleTurnInPetitionOpcode
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;
std::string name;
// data
QueryResult* result = CharacterDatabase.PQuery("SELECT ownerguid, name FROM petition WHERE petitionguid = '%u'", petitionGuid.GetCounter());
if (result)
{
Field* fields = result->Fetch();
ownerGuid = ObjectGuid(HIGHGUID_PLAYER, fields[0].GetUInt32());
name = fields[1].GetCppString();
delete result;
}
else
{
sLog.outError("CMSG_TURN_IN_PETITION: petition table not have data for guid %u!", petitionGuid.GetCounter());
return;
}
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;
}
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 = sWorld.getConfig(CONFIG_UINT32_MIN_PETITION_SIGNS);
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 (sGuildMgr.GetGuildByName(name))
{
SendGuildCommandResult(GUILD_CREATE_S, name, ERR_GUILD_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);
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.IsEmpty())
continue;
guild->AddMember(signGuid, guild->GetLowestRank());
result->NextRow();
}
delete result;
//.........这里部分代码省略.........