本文整理汇总了C++中PreparedQueryResult::GetRowCount方法的典型用法代码示例。如果您正苦于以下问题:C++ PreparedQueryResult::GetRowCount方法的具体用法?C++ PreparedQueryResult::GetRowCount怎么用?C++ PreparedQueryResult::GetRowCount使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PreparedQueryResult
的用法示例。
在下文中一共展示了PreparedQueryResult::GetRowCount方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: HandleOfferPetitionOpcode
void WorldSession::HandleOfferPetitionOpcode(WorldPacket& recvData)
{
TC_LOG_DEBUG(LOG_FILTER_NETWORKIO, "Received opcode CMSG_OFFER_PETITION"); // ok
uint8 signs = 0;
uint64 petitionguid, plguid;
uint32 type, junk;
Player* player;
recvData >> junk; // this is not petition type!
recvData >> petitionguid; // petition guid
recvData >> plguid; // player guid
player = ObjectAccessor::FindPlayer(plguid);
if (!player)
return;
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_PETITION_TYPE);
stmt->setUInt32(0, GUID_LOPART(petitionguid));
PreparedQueryResult result = CharacterDatabase.Query(stmt);
if (!result)
return;
Field* fields = result->Fetch();
type = fields[0].GetUInt8();
TC_LOG_DEBUG(LOG_FILTER_NETWORKIO, "OFFER PETITION: type %u, GUID1 %u, to player id: %u", type, GUID_LOPART(petitionguid), GUID_LOPART(plguid));
if (!sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_GUILD) && GetPlayer()->GetTeam() != player->GetTeam())
{
if (type != GUILD_CHARTER_TYPE)
SendArenaTeamCommandResult(ERR_ARENA_TEAM_INVITE_SS, "", "", ERR_ARENA_TEAM_NOT_ALLIED);
else
Guild::SendCommandResult(this, GUILD_COMMAND_CREATE, ERR_GUILD_NOT_ALLIED);
return;
}
if (type != GUILD_CHARTER_TYPE)
{
if (player->getLevel() < sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL))
{
// player is too low level to join an arena team
SendArenaTeamCommandResult(ERR_ARENA_TEAM_CREATE_S, player->GetName().c_str(), "", ERR_ARENA_TEAM_TARGET_TOO_LOW_S);
return;
}
uint8 slot = ArenaTeam::GetSlotByType(type);
if (slot >= MAX_ARENA_SLOT)
return;
if (player->GetArenaTeamId(slot))
{
// player is already in an arena team
SendArenaTeamCommandResult(ERR_ARENA_TEAM_CREATE_S, player->GetName().c_str(), "", ERR_ALREADY_IN_ARENA_TEAM_S);
return;
}
if (player->GetArenaTeamIdInvited())
{
SendArenaTeamCommandResult(ERR_ARENA_TEAM_INVITE_SS, "", _player->GetName().c_str(), ERR_ALREADY_INVITED_TO_ARENA_TEAM_S);
return;
}
}
else
{
if (player->GetGuildId())
{
Guild::SendCommandResult(this, GUILD_COMMAND_INVITE, ERR_ALREADY_IN_GUILD_S, _player->GetName());
return;
}
if (player->GetGuildIdInvited())
{
Guild::SendCommandResult(this, GUILD_COMMAND_INVITE, ERR_ALREADY_INVITED_TO_GUILD_S, _player->GetName());
return;
}
}
stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_PETITION_SIGNATURE);
stmt->setUInt32(0, GUID_LOPART(petitionguid));
result = CharacterDatabase.Query(stmt);
// result == NULL also correct charter without signs
if (result)
signs = uint8(result->GetRowCount());
WorldPacket data(SMSG_PETITION_SHOW_SIGNATURES, (8+8+4+signs+signs*12));
data << uint64(petitionguid); // petition guid
data << uint64(_player->GetGUID()); // owner guid
data << uint32(GUID_LOPART(petitionguid)); // guild guid
data << uint8(signs); // sign's count
for (uint8 i = 1; i <= signs; ++i)
{
Field* fields2 = result->Fetch();
//.........这里部分代码省略.........
示例2: HandleListItemCommand
static bool HandleListItemCommand(ChatHandler* handler, char const* args)
{
if (!*args)
return false;
char* id = handler->extractKeyFromLink((char*)args, "Hitem");
if (!id)
return false;
uint32 itemId = atol(id);
if (!itemId)
{
handler->PSendSysMessage(LANG_COMMAND_ITEMIDINVALID, itemId);
handler->SetSentErrorMessage(true);
return false;
}
ItemTemplate const* itemTemplate = sObjectMgr->GetItemTemplate(itemId);
if (!itemTemplate)
{
handler->PSendSysMessage(LANG_COMMAND_ITEMIDINVALID, itemId);
handler->SetSentErrorMessage(true);
return false;
}
char* countStr = strtok(NULL, " ");
uint32 count = countStr ? atol(countStr) : 10;
if (count == 0)
return false;
PreparedQueryResult result;
// inventory case
uint32 inventoryCount = 0;
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHAR_INVENTORY_COUNT_ITEM);
stmt->setUInt32(0, itemId);
result = CharacterDatabase.Query(stmt);
if (result)
inventoryCount = (*result)[0].GetUInt64();
stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHAR_INVENTORY_ITEM_BY_ENTRY);
stmt->setUInt32(0, itemId);
stmt->setUInt32(1, count);
result = CharacterDatabase.Query(stmt);
if (result)
{
do
{
Field* fields = result->Fetch();
uint32 itemGuid = fields[0].GetUInt32();
uint32 itemBag = fields[1].GetUInt32();
uint8 itemSlot = fields[2].GetUInt8();
uint32 ownerGuid = fields[3].GetUInt32();
uint32 ownerAccountId = fields[4].GetUInt32();
std::string ownerName = fields[5].GetString();
char const* itemPos = 0;
if (Player::IsEquipmentPos(itemBag, itemSlot))
itemPos = "[equipped]";
else if (Player::IsInventoryPos(itemBag, itemSlot))
itemPos = "[in inventory]";
else if (Player::IsBankPos(itemBag, itemSlot))
itemPos = "[in bank]";
else
itemPos = "";
handler->PSendSysMessage(LANG_ITEMLIST_SLOT, itemGuid, ownerName.c_str(), ownerGuid, ownerAccountId, itemPos);
}
while (result->NextRow());
uint32 resultCount = uint32(result->GetRowCount());
if (count > resultCount)
count -= resultCount;
else if (count)
count = 0;
}
// mail case
uint32 mailCount = 0;
stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_MAIL_COUNT_ITEM);
stmt->setUInt32(0, itemId);
result = CharacterDatabase.Query(stmt);
if (result)
mailCount = (*result)[0].GetUInt64();
if (count > 0)
{
stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_MAIL_ITEMS_BY_ENTRY);
stmt->setUInt32(0, itemId);
stmt->setUInt32(1, count);
result = CharacterDatabase.Query(stmt);
}
else
//.........这里部分代码省略.........
示例3: sizeof
char* DB2DatabaseLoader::Load(uint32& records, char**& indexTable, char*& stringHolders, std::vector<char*>& stringPool)
{
// Even though this query is executed only once, prepared statement is used to send data from mysql server in binary format
PreparedQueryResult result = HotfixDatabase.Query(HotfixDatabase.GetPreparedStatement(_loadInfo->Statement));
if (!result)
return nullptr;
if (_loadInfo->Meta->GetDbFieldCount() != result->GetFieldCount())
return nullptr;
// get struct size and index pos
uint32 indexField = _loadInfo->Meta->GetDbIndexField();
uint32 recordSize = _loadInfo->Meta->GetRecordSize();
// we store flat holders pool as single memory block
std::size_t stringFields = _loadInfo->GetStringFieldCount(false);
std::size_t localizedStringFields = _loadInfo->GetStringFieldCount(true);
// each string field at load have array of string for each locale
std::size_t stringHoldersRecordPoolSize = localizedStringFields * sizeof(LocalizedString) + (stringFields - localizedStringFields) * sizeof(char*);
if (stringFields)
{
std::size_t stringHoldersPoolSize = stringHoldersRecordPoolSize * result->GetRowCount();
stringHolders = new char[stringHoldersPoolSize];
// DB2 strings expected to have at least empty string
for (std::size_t i = 0; i < stringHoldersPoolSize / sizeof(char*); ++i)
((char const**)stringHolders)[i] = nullStr;
}
else
stringHolders = nullptr;
// Resize index table
// database query *MUST* contain ORDER BY `index_field` DESC clause
uint32 indexTableSize = (*result)[indexField].GetUInt32() + 1;
if (indexTableSize < records)
indexTableSize = records;
if (indexTableSize > records)
{
char** tmpIdxTable = new char*[indexTableSize];
memset(tmpIdxTable, 0, indexTableSize * sizeof(char*));
memcpy(tmpIdxTable, indexTable, records * sizeof(char*));
delete[] indexTable;
indexTable = tmpIdxTable;
}
char* tempDataTable = new char[result->GetRowCount() * recordSize];
uint32* newIndexes = new uint32[result->GetRowCount()];
uint32 rec = 0;
uint32 newRecords = 0;
do
{
Field* fields = result->Fetch();
uint32 offset = 0;
uint32 stringFieldOffset = 0;
uint32 indexValue = fields[indexField].GetUInt32();
// Attempt to overwrite existing data
char* dataValue = indexTable[indexValue];
if (!dataValue)
{
newIndexes[newRecords] = indexValue;
dataValue = &tempDataTable[newRecords++ * recordSize];
}
uint32 f = 0;
if (!_loadInfo->Meta->HasIndexFieldInData())
{
*((uint32*)(&dataValue[offset])) = indexValue;
offset += 4;
++f;
}
for (uint32 x = 0; x < _loadInfo->Meta->FieldCount; ++x)
{
for (uint32 z = 0; z < _loadInfo->Meta->ArraySizes[x]; ++z)
{
switch (_loadInfo->TypesString[f])
{
case FT_FLOAT:
*((float*)(&dataValue[offset])) = fields[f].GetFloat();
offset += 4;
break;
case FT_INT:
*((int32*)(&dataValue[offset])) = fields[f].GetInt32();
offset += 4;
break;
case FT_BYTE:
*((int8*)(&dataValue[offset])) = fields[f].GetInt8();
offset += 1;
break;
case FT_SHORT:
*((int16*)(&dataValue[offset])) = fields[f].GetInt16();
offset += 2;
break;
case FT_LONG:
//.........这里部分代码省略.........
示例4: 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("entities.player.cheat", "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;
//.........这里部分代码省略.........
示例5: LoadSmartAIFromDB
void SmartAIMgr::LoadSmartAIFromDB()
{
for (uint8 i = 0; i < SMART_SCRIPT_TYPE_MAX; i++)
mEventMap[i].clear(); //Drop Existing SmartAI List
PreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_LOAD_SMART_SCRIPTS);
PreparedQueryResult result = WorldDatabase.Query(stmt);
if (!result)
{
barGoLink bar(1);
bar.step();
sLog.outString();
sLog.outString(">> Loaded 0 SmartAI scripts. DB table `smartai_scripts` is empty.");
return;
}
barGoLink bar(result->GetRowCount());
uint32 ScriptCount = 0;
do
{
bar.step();
Field* fields = result->Fetch();
SmartScriptHolder temp;
temp.entryOrGuid = fields[0].GetInt32();
SmartScriptType source_type = (SmartScriptType)fields[1].GetUInt32();
if (source_type >= SMART_SCRIPT_TYPE_MAX)
{
sLog.outErrorDb("SmartAIMgr::LoadSmartAIFromDB: invalid source_type (%u), skipped loading.", uint32(source_type));
continue;
}
if (temp.entryOrGuid >= 0)
{
switch(source_type)
{
case SMART_SCRIPT_TYPE_CREATURE:
{
if (!sCreatureStorage.LookupEntry<CreatureInfo>((uint32)temp.entryOrGuid))
{
sLog.outErrorDb("SmartAIMgr::LoadSmartAIFromDB: Creature entry (%u) does not exist, skipped loading.", uint32(temp.entryOrGuid));
continue;
}
break;
}
case SMART_SCRIPT_TYPE_GAMEOBJECT:
{
if (!sGOStorage.LookupEntry<GameObjectInfo>((uint32)temp.entryOrGuid))
{
sLog.outErrorDb("SmartAIMgr::LoadSmartAIFromDB: GameObject entry (%u) does not exist, skipped loading.", uint32(temp.entryOrGuid));
continue;
}
break;
}
case SMART_SCRIPT_TYPE_AREATRIGGER:
{
if (!sAreaTriggerStore.LookupEntry((uint32)temp.entryOrGuid))
{
sLog.outErrorDb("SmartAIMgr::LoadSmartAIFromDB: AreaTrigger entry (%u) does not exist, skipped loading.", uint32(temp.entryOrGuid));
continue;
}
break;
}
case SMART_SCRIPT_TYPE_TIMED_ACTIONLIST:
break;//nothing to check, really
default:
sLog.outErrorDb("SmartAIMgr::LoadSmartAIFromDB: not yet implemented source_type %u", (uint32)source_type);
continue;
}
}else
{
if (!sObjectMgr.GetCreatureData(uint32(abs(temp.entryOrGuid))))
{
sLog.outErrorDb("SmartAIMgr::LoadSmartAIFromDB: Creature guid (%u) does not exist, skipped loading.", uint32(abs(temp.entryOrGuid)));
continue;
}
}
temp.source_type = source_type;
temp.event_id = fields[2].GetUInt32();
temp.link = fields[3].GetUInt32();
temp.event.type = (SMART_EVENT)fields[4].GetUInt32();
temp.event.event_phase_mask = fields[5].GetUInt32();
temp.event.event_chance = fields[6].GetUInt32();
temp.event.event_flags = fields[7].GetUInt32();
temp.event.raw.param1 = fields[8].GetUInt32();
temp.event.raw.param2 = fields[9].GetUInt32();
temp.event.raw.param3 = fields[10].GetUInt32();
temp.event.raw.param4 = fields[11].GetUInt32();
temp.action.type = (SMART_ACTION)fields[12].GetUInt32();
temp.action.raw.param1 = fields[13].GetUInt32();
temp.action.raw.param2 = fields[14].GetUInt32();
temp.action.raw.param3 = fields[15].GetUInt32();
temp.action.raw.param4 = fields[16].GetUInt32();
temp.action.raw.param5 = fields[17].GetUInt32();
temp.action.raw.param6 = fields[18].GetUInt32();
//.........这里部分代码省略.........
示例6: HandleTurnInPetitionOpcode
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;
petitionGuid[1] = recvData.ReadBit();
petitionGuid[2] = recvData.ReadBit();
petitionGuid[3] = recvData.ReadBit();
petitionGuid[0] = recvData.ReadBit();
petitionGuid[5] = recvData.ReadBit();
petitionGuid[7] = recvData.ReadBit();
petitionGuid[4] = recvData.ReadBit();
petitionGuid[6] = recvData.ReadBit();
recvData.ReadByteSeq(petitionGuid[2]);
recvData.ReadByteSeq(petitionGuid[1]);
recvData.ReadByteSeq(petitionGuid[4]);
recvData.ReadByteSeq(petitionGuid[6]);
recvData.ReadByteSeq(petitionGuid[0]);
recvData.ReadByteSeq(petitionGuid[7]);
recvData.ReadByteSeq(petitionGuid[5]);
recvData.ReadByteSeq(petitionGuid[3]);
// 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 << (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
//.........这里部分代码省略.........
示例7: ReplaceResponse
//.........这里部分代码省略.........
hash[i] ^= sha.GetDigest()[i];
SHA256Hash shaI;
shaI.UpdateData(ByteArrayToHexStr(I.AsByteArray().get(), 32));
shaI.Finalize();
// Concat all variables for M1 hash
sha.Initialize();
sha.UpdateData(hash, SHA256_DIGEST_LENGTH);
sha.UpdateData(shaI.GetDigest(), shaI.GetLength());
sha.UpdateBigNumbers(&s, &A, &B, &K, NULL);
sha.Finalize();
M1.SetBinary(sha.GetDigest(), sha.GetLength());
if (memcmp(M1.AsByteArray().get(), clientM1.AsByteArray().get(), 32))
{
PreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_UPD_BNET_FAILED_LOGINS);
stmt->setString(0, _accountName);
LoginDatabase.Execute(stmt);
Authentication::LogonResponse* logonResponse = new Authentication::LogonResponse();
logonResponse->SetAuthResult(AUTH_UNKNOWN_ACCOUNT);
ReplaceResponse(response, logonResponse);
TC_LOG_DEBUG("session", "[Battlenet::Password] %s attempted to log in with invalid password!", GetClientInfo().c_str());
return false;
}
uint64 numAccounts = 0;
PreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_SEL_BNET_GAME_ACCOUNTS);
stmt->setUInt32(0, _accountId);
PreparedQueryResult result = LoginDatabase.Query(stmt);
if (result)
numAccounts = result->GetRowCount();
if (!numAccounts)
{
Authentication::LogonResponse* logonResponse = new Authentication::LogonResponse();
logonResponse->SetAuthResult(LOGIN_NO_GAME_ACCOUNT);
ReplaceResponse(response, logonResponse);
TC_LOG_DEBUG("session", "[Battlenet::Password] %s does not have any linked game accounts!", GetClientInfo().c_str());
return false;
}
Field* fields = result->Fetch();
//set expired game account bans to inactive
LoginDatabase.DirectExecute(LoginDatabase.GetPreparedStatement(LOGIN_UPD_EXPIRED_ACCOUNT_BANS));
BigNumber M;
sha.Initialize();
sha.UpdateBigNumbers(&A, &M1, &K, NULL);
sha.Finalize();
M.SetBinary(sha.GetDigest(), sha.GetLength());
BigNumber serverProof;
serverProof.SetRand(128 * 8); // just send garbage, server signature check is patched out in client
BitStream stream;
ModuleInfo* password = sModuleMgr->CreateModule(_os, "Password");
uint8 state = 3;
stream.WriteBytes(&state, 1);
stream.WriteBytes(M.AsByteArray(32).get(), 32);
stream.WriteBytes(serverProof.AsByteArray(128).get(), 128);
示例8: HandlePetitionShowSignOpcode
void WorldSession::HandlePetitionShowSignOpcode(WorldPacket& recvData)
{
sLog->outDebug(LOG_FILTER_NETWORKIO, "Received opcode CMSG_PETITION_SHOW_SIGNATURES");
uint8 playerCount = 0;
ObjectGuid petitionGuid;
petitionGuid[3] = recvData.ReadBit();
petitionGuid[7] = recvData.ReadBit();
petitionGuid[2] = recvData.ReadBit();
petitionGuid[4] = recvData.ReadBit();
petitionGuid[5] = recvData.ReadBit();
petitionGuid[6] = recvData.ReadBit();
petitionGuid[0] = recvData.ReadBit();
petitionGuid[1] = recvData.ReadBit();
recvData.ReadByteSeq(petitionGuid[2]);
recvData.ReadByteSeq(petitionGuid[4]);
recvData.ReadByteSeq(petitionGuid[5]);
recvData.ReadByteSeq(petitionGuid[7]);
recvData.ReadByteSeq(petitionGuid[1]);
recvData.ReadByteSeq(petitionGuid[0]);
recvData.ReadByteSeq(petitionGuid[3]);
recvData.ReadByteSeq(petitionGuid[6]);
// solve (possible) some strange compile problems with explicit use GUID_LOPART(petitionguid) at some GCC versions (wrong code optimization in compiler?)
uint32 petitionGuidLow = GUID_LOPART(petitionGuid);
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_PETITION_TYPE);
stmt->setUInt32(0, petitionGuidLow);
PreparedQueryResult result = CharacterDatabase.Query(stmt);
if (!result)
{
sLog->outDebug(LOG_FILTER_PLAYER_ITEMS, "Petition %u is not found for player %u %s", GUID_LOPART(petitionGuid), GetPlayer()->GetGUIDLow(), GetPlayer()->GetName());
return;
}
Field* fields = result->Fetch();
uint32 type = fields[0].GetUInt8();
// if guild petition and has guild => error, return;
if (type == GUILD_CHARTER_TYPE && _player->GetGuildId())
return;
stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_PETITION_SIGNATURE);
stmt->setUInt32(0, petitionGuidLow);
result = CharacterDatabase.Query(stmt);
// result == NULL also correct in case no sign yet
if (result)
playerCount = uint8(result->GetRowCount());
sLog->outDebug(LOG_FILTER_NETWORKIO, "CMSG_PETITION_SHOW_SIGNATURES petition entry: '%u'", petitionGuidLow);
ObjectGuid playerGuid = _player->GetGUID();
ObjectGuid* playerGuids = new ObjectGuid[playerCount];
for (uint8 i = 0; i < playerCount; ++i)
{
Field* fields2 = result->Fetch();
uint32 lowGuid = fields2[0].GetUInt32();
playerGuids[i] = MAKE_NEW_GUID(lowGuid, 0, HIGHGUID_PLAYER);
result->NextRow();
}
WorldPacket data(SMSG_PETITION_SHOW_SIGNATURES, (9 + 9 + 3 + 4 + playerCount * (9 + 4)));
data.WriteBit(playerGuid[1]);
data.WriteBit(petitionGuid[3]);
data.WriteBit(playerGuid[3]);
data.WriteBit(petitionGuid[4]);
data.WriteBit(petitionGuid[0]);
data.WriteBit(playerGuid[7]);
data.WriteBit(playerGuid[5]);
data.WriteBit(petitionGuid[1]);
data.WriteBit(petitionGuid[5]);
data.WriteBit(petitionGuid[7]);
data.WriteBit(playerGuid[0]);
data.WriteBit(playerGuid[6]);
data.WriteBit(petitionGuid[6]);
data.WriteBit(playerGuid[2]);
data.WriteBit(playerGuid[4]);
data.WriteBits(playerCount, 21);
for (int i = 0; i < playerCount; i++)
{
data.WriteBit(playerGuids[i][2]);
data.WriteBit(playerGuids[i][0]);
data.WriteBit(playerGuids[i][4]);
data.WriteBit(playerGuids[i][7]);
data.WriteBit(playerGuids[i][5]);
data.WriteBit(playerGuids[i][1]);
data.WriteBit(playerGuids[i][6]);
data.WriteBit(playerGuids[i][3]);
}
data.WriteBit(petitionGuid[2]);
//.........这里部分代码省略.........
示例9: HandleOfferPetitionOpcode
void WorldSession::HandleOfferPetitionOpcode(WorldPacket& recvData)
{
TC_LOG_DEBUG("network", "Received opcode CMSG_OFFER_PETITION"); // ok
uint8 playerCount = 0;
ObjectGuid petitionGuid, playerGuid;
uint32 type;
Player* player;
recvData.read_skip<uint32>();
recvData.ReadGuidMask(playerGuid, 4, 1);
petitionGuid[2] = recvData.ReadBit();
playerGuid[6] = recvData.ReadBit();
petitionGuid[1] = recvData.ReadBit();
playerGuid[2] = recvData.ReadBit();
petitionGuid[4] = recvData.ReadBit();
recvData.ReadGuidMask(playerGuid, 3, 7);
recvData.ReadGuidMask(petitionGuid, 0, 6);
recvData.ReadGuidMask(playerGuid, 5, 0);
recvData.ReadGuidMask(petitionGuid, 3, 5, 7);
recvData.ReadByteSeq(playerGuid[7]);
recvData.ReadGuidBytes(petitionGuid, 1, 4, 2);
recvData.ReadByteSeq(playerGuid[6]);
recvData.ReadGuidBytes(petitionGuid, 3, 0, 5);
recvData.ReadGuidBytes(playerGuid, 0, 2, 5, 3, 4);
recvData.ReadByteSeq(petitionGuid[7]);
recvData.ReadByteSeq(playerGuid[1]);
recvData.ReadByteSeq(petitionGuid[6]);
player = ObjectAccessor::FindPlayer(playerGuid);
if (!player)
return;
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_PETITION_TYPE);
stmt->setUInt32(0, GUID_LOPART(petitionGuid));
PreparedQueryResult result = CharacterDatabase.Query(stmt);
if (!result)
return;
Field* fields = result->Fetch();
type = fields[0].GetUInt8();
TC_LOG_DEBUG("network", "OFFER PETITION: type %u, GUID1 %u, to player id: %u", type, GUID_LOPART(petitionGuid), GUID_LOPART(playerGuid));
if (!sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_GUILD) && GetPlayer()->GetTeam() != player->GetTeam())
{
Guild::SendCommandResult(this, GUILD_COMMAND_CREATE, ERR_GUILD_NOT_ALLIED);
return;
}
if (player->GetGuildId())
{
Guild::SendCommandResult(this, GUILD_COMMAND_INVITE, ERR_ALREADY_IN_GUILD_S, _player->GetName());
return;
}
if (player->GetGuildIdInvited())
{
Guild::SendCommandResult(this, GUILD_COMMAND_INVITE, ERR_ALREADY_INVITED_TO_GUILD_S, _player->GetName());
return;
}
stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_PETITION_SIGNATURE);
stmt->setUInt32(0, GUID_LOPART(petitionGuid));
result = CharacterDatabase.Query(stmt);
// result == NULL also correct charter without signs
if (result)
playerCount = uint8(result->GetRowCount());
ObjectGuid* playerGuids = new ObjectGuid[playerCount];
for (uint8 i = 0; i < playerCount; ++i)
{
Field* fields2 = result->Fetch();
uint32 lowGuid = fields2[0].GetUInt32();
playerGuids[i] = MAKE_NEW_GUID(lowGuid, 0, HIGHGUID_PLAYER);
result->NextRow();
}
WorldPacket data(SMSG_PETITION_SHOW_SIGNATURES, (9 + 9 + 3 + 4 + playerCount * (9 + 4)));
data.WriteBit(playerGuid[1]);
data.WriteBit(petitionGuid[3]);
data.WriteBit(playerGuid[3]);
data.WriteGuidMask(petitionGuid, 4, 0);
data.WriteGuidMask(playerGuid, 7, 5);
data.WriteGuidMask(petitionGuid, 1, 5, 7);
data.WriteGuidMask(playerGuid, 0, 6);
data.WriteBit(petitionGuid[6]);
data.WriteGuidMask(playerGuid, 2, 4);
data.WriteBits(playerCount, 21);
for (int i = 0; i < playerCount; i++)
//.........这里部分代码省略.........
示例10: LoadGuilds
//.........这里部分代码省略.........
}
while (result->NextRow());
TC_LOG_INFO("server.loading", ">> Loaded %u guild bank tabs in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
}
}
// 9. Fill all guild bank tabs
TC_LOG_INFO("server.loading", "Filling bank tabs with items...");
{
uint32 oldMSTime = getMSTime();
// Delete orphan guild bank items
CharacterDatabase.DirectExecute("DELETE gbi FROM guild_bank_item gbi LEFT JOIN guild g ON gbi.guildId = g.guildId WHERE g.guildId IS NULL");
// 0 1 2 3 4 5 6 7 8 9 10 11 12 13
// SELECT guid, itemEntry, creatorGuid, giftCreatorGuid, count, duration, charges, flags, enchantments, randomPropertyType, randomPropertyId, durability, playedTime, text,
// 14 15 16 17 18 19 20
// upgradeId, battlePetSpeciesId, battlePetBreedData, battlePetLevel, battlePetDisplayId, context, bonusListIDs,
// 21 22 23 24 25
// itemModifiedAppearanceAllSpecs, itemModifiedAppearanceSpec1, itemModifiedAppearanceSpec2, itemModifiedAppearanceSpec3, itemModifiedAppearanceSpec4,
// 26 27 28 29 30
// spellItemEnchantmentAllSpecs, spellItemEnchantmentSpec1, spellItemEnchantmentSpec2, spellItemEnchantmentSpec3, spellItemEnchantmentSpec4,
// 31 32 33 34 35 36 37 38 39 40 41 42
// gemItemId1, gemBonuses1, gemContext1, gemScalingLevel1, gemItemId2, gemBonuses2, gemContext2, gemScalingLevel2, gemItemId3, gemBonuses3, gemContext3, gemScalingLevel3
// 43 44
// fixedScalingLevel, artifactKnowledgeLevel
// 45 46 47
// guildid, TabId, SlotId FROM guild_bank_item gbi INNER JOIN item_instance ii ON gbi.item_guid = ii.guid
PreparedQueryResult result = CharacterDatabase.Query(CharacterDatabase.GetPreparedStatement(CHAR_SEL_GUILD_BANK_ITEMS));
if (!result)
{
TC_LOG_INFO("server.loading", ">> Loaded 0 guild bank tab items. DB table `guild_bank_item` or `item_instance` is empty.");
}
else
{
uint32 count = 0;
do
{
Field* fields = result->Fetch();
uint64 guildId = fields[45].GetUInt64();
if (Guild* guild = GetGuildById(guildId))
guild->LoadBankItemFromDB(fields);
++count;
}
while (result->NextRow());
TC_LOG_INFO("server.loading", ">> Loaded %u guild bank tab items in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
}
}
// 10. Load guild achievements
TC_LOG_INFO("server.loading", "Loading guild achievements...");
{
uint32 oldMSTime = getMSTime();
uint64 achievementCount = 0;
uint64 criteriaCount = 0;
PreparedQueryResult achievementResult;
PreparedQueryResult criteriaResult;
for (GuildContainer::const_iterator itr = GuildStore.begin(); itr != GuildStore.end(); ++itr)
{
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_GUILD_ACHIEVEMENT);
stmt->setUInt64(0, itr->first);
achievementResult = CharacterDatabase.Query(stmt);
stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_GUILD_ACHIEVEMENT_CRITERIA);
stmt->setUInt64(0, itr->first);
criteriaResult = CharacterDatabase.Query(stmt);
if (achievementResult)
achievementCount += achievementResult->GetRowCount();
if (criteriaResult)
criteriaCount += criteriaResult->GetRowCount();
itr->second->GetAchievementMgr().LoadFromDB(achievementResult, criteriaResult);
}
TC_LOG_INFO("server.loading", ">> Loaded " UI64FMTD " guild achievements and " UI64FMTD " criterias in %u ms", achievementCount, criteriaCount, GetMSTimeDiffToNow(oldMSTime));
}
// 11. Validate loaded guild data
TC_LOG_INFO("misc", "Validating data of loaded guilds...");
{
uint32 oldMSTime = getMSTime();
for (GuildContainer::iterator itr = GuildStore.begin(); itr != GuildStore.end();)
{
Guild* guild = itr->second;
++itr;
if (guild && !guild->Validate())
delete guild;
}
TC_LOG_INFO("server.loading", ">> Validated data of loaded guilds in %u ms", GetMSTimeDiffToNow(oldMSTime));
}
}
示例11: strlen
char* DB2DatabaseLoader::Load(const char* format, uint32 preparedStatement, uint32& records, char**& indexTable, char*& stringHolders, std::list<char*>& stringPool)
{
// Even though this query is executed only once, prepared statement is used to send data from mysql server in binary format
PreparedQueryResult result = HotfixDatabase.Query(HotfixDatabase.GetPreparedStatement(preparedStatement));
if (!result)
return nullptr;
uint32 const fieldCount = strlen(format);
if (fieldCount != result->GetFieldCount())
return nullptr;
// get struct size and index pos
int32 indexField;
uint32 recordSize = DB2FileLoader::GetFormatRecordSize(format, &indexField);
// we store flat holders pool as single memory block
size_t stringFields = DB2FileLoader::GetFormatStringFieldCount(format);
// each string field at load have array of string for each locale
size_t stringHolderSize = sizeof(char*) * TOTAL_LOCALES;
size_t stringHoldersRecordPoolSize = stringFields * stringHolderSize;
if (stringFields)
{
size_t stringHoldersPoolSize = stringHoldersRecordPoolSize * result->GetRowCount();
stringHolders = new char[stringHoldersPoolSize];
// DB2 strings expected to have at least empty string
for (size_t i = 0; i < stringHoldersPoolSize / sizeof(char*); ++i)
((char const**)stringHolders)[i] = nullStr;
}
else
stringHolders = nullptr;
// Resize index table
// database query *MUST* contain ORDER BY `index_field` DESC clause
uint32 indexTableSize;
if (indexField >= 0)
{
indexTableSize = (*result)[indexField].GetUInt32() + 1;
if (indexTableSize < records)
indexTableSize = records;
}
else
indexTableSize = records + result->GetRowCount();
if (indexTableSize > records)
{
char** tmpIdxTable = new char*[indexTableSize];
memset(tmpIdxTable, 0, indexTableSize * sizeof(char*));
memcpy(tmpIdxTable, indexTable, records * sizeof(char*));
delete[] indexTable;
indexTable = tmpIdxTable;
}
char* tempDataTable = new char[result->GetRowCount() * recordSize];
uint32* newIndexes = new uint32[result->GetRowCount()];
uint32 rec = 0;
uint32 newRecords = 0;
do
{
Field* fields = result->Fetch();
uint32 offset = 0;
uint32 stringFieldNumInRecord = 0;
uint32 indexValue;
if (indexField >= 0)
indexValue = fields[indexField].GetUInt32();
else
indexValue = records + rec;
// Attempt to overwrite existing data
char* dataValue = indexTable[indexValue];
if (!dataValue)
{
newIndexes[newRecords] = indexValue;
dataValue = &tempDataTable[newRecords++ * recordSize];
}
for (uint32 f = 0; f < fieldCount; f++)
{
switch (format[f])
{
case FT_FLOAT:
*((float*)(&dataValue[offset])) = fields[f].GetFloat();
offset += 4;
break;
case FT_IND:
case FT_INT:
*((int32*)(&dataValue[offset])) = fields[f].GetInt32();
offset += 4;
break;
case FT_BYTE:
*((int8*)(&dataValue[offset])) = fields[f].GetInt8();
offset += 1;
break;
case FT_STRING:
{
LocalizedString** slot = (LocalizedString**)(&dataValue[offset]);
//.........这里部分代码省略.........
示例12: HandlePetitionShowSignOpcode
void WorldSession::HandlePetitionShowSignOpcode(WorldPacket& recvData)
{
sLog->outDebug(LOG_FILTER_NETWORKIO, "Received opcode CMSG_PETITION_SHOW_SIGNATURES");
uint8 signs = 0;
ObjectGuid petitionguid;
uint8 bitsOrder[8] = { 4, 3, 5, 6, 2, 1, 0, 7 };
recvData.ReadBitInOrder(petitionguid, bitsOrder);
recvData.FlushBits();
uint8 bytesOrder[8] = { 2, 0, 3, 7, 4, 1, 5, 6 };
recvData.ReadBytesSeq(petitionguid, bytesOrder);
// solve (possible) some strange compile problems with explicit use GUID_LOPART(petitionguid) at some GCC versions (wrong code optimization in compiler?)
uint32 petitionGuidLow = GUID_LOPART(petitionguid);
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_PETITION_TYPE);
stmt->setUInt32(0, petitionGuidLow);
PreparedQueryResult result = CharacterDatabase.Query(stmt);
if (!result)
{
sLog->outDebug(LOG_FILTER_PLAYER_ITEMS, "Petition %u is not found for player %u %s", GUID_LOPART(petitionguid), GetPlayer()->GetGUIDLow(), GetPlayer()->GetName());
return;
}
Field* fields = result->Fetch();
uint32 type = fields[0].GetUInt8();
// if guild petition and has guild => error, return;
if (type == GUILD_CHARTER_TYPE && _player->GetGuildId())
return;
stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_PETITION_SIGNATURE);
stmt->setUInt32(0, petitionGuidLow);
result = CharacterDatabase.Query(stmt);
// result == NULL also correct in case no sign yet
if (result)
signs = uint8(result->GetRowCount());
sLog->outDebug(LOG_FILTER_NETWORKIO, "CMSG_PETITION_SHOW_SIGNATURES petition entry: '%u'", petitionGuidLow);
WorldPacket data(SMSG_PETITION_SHOW_SIGNATURES);
ByteBuffer signsBuffer;
ObjectGuid guid2 = _player->GetGUID();
ObjectGuid guid1 = petitionguid;
data.WriteBit(guid2[4]);
data.WriteBit(guid1[4]);
data.WriteBit(guid2[5]);
data.WriteBit(guid2[0]);
data.WriteBit(guid2[6]);
data.WriteBit(guid1[7]);
data.WriteBit(guid2[7]);
data.WriteBit(guid1[0]);
data.WriteBit(guid2[2]);
data.WriteBit(guid2[3]);
data.WriteBits(signs, 21);
for (uint8 i = 1; i <= signs; ++i)
{
Field* fields2 = result->Fetch();
uint32 lowGuid = fields2[0].GetUInt32();
ObjectGuid signerGuid = MAKE_NEW_GUID(lowGuid, 0, HIGHGUID_PLAYER);
uint8 bitsSendOrder[8] = { 6, 2, 4, 5, 3, 0, 7, 1 };
data.WriteBitInOrder(signerGuid, bitsSendOrder);
signsBuffer.WriteByteSeq(signerGuid[4]);
signsBuffer.WriteByteSeq(signerGuid[7]);
signsBuffer.WriteByteSeq(signerGuid[5]);
signsBuffer.WriteByteSeq(signerGuid[3]);
signsBuffer.WriteByteSeq(signerGuid[2]);
signsBuffer << uint32(0);
signsBuffer.WriteByteSeq(signerGuid[6]);
signsBuffer.WriteByteSeq(signerGuid[1]);
signsBuffer.WriteByteSeq(signerGuid[0]);
result->NextRow();
}
data.WriteBit(guid1[5]);
data.WriteBit(guid1[6]);
data.WriteBit(guid1[1]);
data.WriteBit(guid1[3]);
data.WriteBit(guid2[1]);
data.WriteBit(guid1[2]);
data.FlushBits();
data << uint32(petitionGuidLow);
if (signsBuffer.size())
//.........这里部分代码省略.........
示例13: HandleTurnInPetitionOpcode
void WorldSession::HandleTurnInPetitionOpcode(WorldPacket& recvData)
{
TC_LOG_DEBUG(LOG_FILTER_NETWORKIO, "Received opcode CMSG_TURN_IN_PETITION");
// Get petition guid from packet
WorldPacket data;
uint64 petitionGuid;
recvData >> petitionGuid;
// Check if player really has the required petition charter
Item* item = _player->GetItemByGuid(petitionGuid);
if (!item)
return;
TC_LOG_DEBUG(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
{
TC_LOG_ERROR(LOG_FILTER_NETWORKIO, "Player %s (guid: %u) tried to turn in petition (guid: %u) that is not present in the database", _player->GetName().c_str(), _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_COMMAND_CREATE, 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_SEL_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
//.........这里部分代码省略.........
示例14: HandleOfferPetitionOpcode
//.........这里部分代码省略.........
return;
}
if (player->GetArenaTeamIdInvited())
{
SendArenaTeamCommandResult(ERR_ARENA_TEAM_INVITE_SS, "", _player->GetName(), ERR_ALREADY_INVITED_TO_ARENA_TEAM_S);
return;
}
}
else
{
if (player->GetGuildId())
{
Guild::SendCommandResult(this, GUILD_INVITE_S, ERR_ALREADY_IN_GUILD_S, _player->GetName());
return;
}
if (player->GetGuildIdInvited())
{
Guild::SendCommandResult(this, GUILD_INVITE_S, ERR_ALREADY_INVITED_TO_GUILD_S, _player->GetName());
return;
}
}
stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_PETITION_SIGNATURE);
stmt->setUInt32(0, GUID_LOPART(petitionGuid));
result = CharacterDatabase.Query(stmt);
// result == NULL also correct charter without signs
if (result)
playerCount = uint8(result->GetRowCount());
ObjectGuid* playerGuids = new ObjectGuid[playerCount];
for (uint8 i = 0; i < playerCount; ++i)
{
Field* fields2 = result->Fetch();
uint32 lowGuid = fields2[0].GetUInt32();
playerGuids[i] = MAKE_NEW_GUID(lowGuid, 0, HIGHGUID_PLAYER);
result->NextRow();
}
WorldPacket data(SMSG_PETITION_SHOW_SIGNATURES, (9 + 9 + 3 + 4 + playerCount * (9 + 4)));
data.WriteBit(playerGuid[1]);
data.WriteBit(petitionGuid[3]);
data.WriteBit(playerGuid[3]);
data.WriteBit(petitionGuid[4]);
data.WriteBit(petitionGuid[0]);
data.WriteBit(playerGuid[7]);
data.WriteBit(playerGuid[5]);
data.WriteBit(petitionGuid[1]);
data.WriteBit(petitionGuid[5]);
data.WriteBit(petitionGuid[7]);
data.WriteBit(playerGuid[0]);
data.WriteBit(playerGuid[6]);
data.WriteBit(petitionGuid[6]);
data.WriteBit(playerGuid[2]);
data.WriteBit(playerGuid[4]);
data.WriteBits(playerCount, 21);
for (int i = 0; i < playerCount; i++)
{
data.WriteBit(playerGuids[i][2]);
示例15: if
void Battlenet::Session::HandleLogonRequestCallback(PreparedQueryResult result)
{
if (!result)
{
Authentication::LogonResponse* logonResponse = new Authentication::LogonResponse();
logonResponse->SetAuthResult(AUTH_UNKNOWN_ACCOUNT);
AsyncWrite(logonResponse);
TC_LOG_DEBUG("session", "[Battlenet::LogonRequest] %s is trying to log in from unknown account!", GetClientInfo().c_str());
return;
}
Field* fields = result->Fetch();
_accountInfo->LoadResult(fields);
std::string pStr = fields[8].GetString();
std::string databaseV = fields[9].GetString();
std::string databaseS = fields[10].GetString();
_gameAccounts.resize(result->GetRowCount());
uint32 i = 0;
do
{
_gameAccounts[i++].LoadResult(result->Fetch() + 11);
} while (result->NextRow());
std::string ip_address = GetRemoteIpAddress().to_string();
// If the IP is 'locked', check that the player comes indeed from the correct IP address
if (_accountInfo->IsLockedToIP)
{
TC_LOG_DEBUG("session", "[Battlenet::LogonRequest] Account '%s' is locked to IP - '%s' is logging in from '%s'", _accountInfo->Login.c_str(), _accountInfo->LastIP.c_str(), ip_address.c_str());
if (_accountInfo->LastIP != ip_address)
{
Authentication::LogonResponse* logonResponse = new Authentication::LogonResponse();
logonResponse->SetAuthResult(AUTH_ACCOUNT_LOCKED);
AsyncWrite(logonResponse);
return;
}
}
else
{
TC_LOG_DEBUG("session", "[Battlenet::LogonRequest] Account '%s' is not locked to ip", _accountInfo->Login.c_str());
if (_accountInfo->LockCountry.empty() || _accountInfo->LockCountry == "00")
TC_LOG_DEBUG("session", "[Battlenet::LogonRequest] Account '%s' is not locked to country", _accountInfo->Login.c_str());
else if (!_accountInfo->LockCountry.empty() && !_ipCountry.empty())
{
TC_LOG_DEBUG("session", "[Battlenet::LogonRequest] Account '%s' is locked to country: '%s' Player country is '%s'", _accountInfo->Login.c_str(), _accountInfo->LockCountry.c_str(), _ipCountry.c_str());
if (_ipCountry != _accountInfo->LockCountry)
{
Authentication::LogonResponse* logonResponse = new Authentication::LogonResponse();
logonResponse->SetAuthResult(AUTH_ACCOUNT_LOCKED);
AsyncWrite(logonResponse);
return;
}
}
}
// If the account is banned, reject the logon attempt
if (_accountInfo->IsBanned)
{
if (_accountInfo->IsPermanentlyBanned)
{
Authentication::LogonResponse* logonResponse = new Authentication::LogonResponse();
logonResponse->SetAuthResult(LOGIN_BANNED);
AsyncWrite(logonResponse);
TC_LOG_DEBUG("session", "'%s:%d' [Battlenet::LogonRequest] Banned account %s tried to login!", ip_address.c_str(), GetRemotePort(), _accountInfo->Login.c_str());
return;
}
else
{
Authentication::LogonResponse* logonResponse = new Authentication::LogonResponse();
logonResponse->SetAuthResult(LOGIN_SUSPENDED);
AsyncWrite(logonResponse);
TC_LOG_DEBUG("session", "'%s:%d' [Battlenet::LogonRequest] Temporarily banned account %s tried to login!", ip_address.c_str(), GetRemotePort(), _accountInfo->Login.c_str());
return;
}
}
SHA256Hash sha;
sha.UpdateData(_accountInfo->Login);
sha.Finalize();
I.SetBinary(sha.GetDigest(), sha.GetLength());
ModuleInfo* password = sModuleMgr->CreateModule(_os, "Password");
ModuleInfo* thumbprint = sModuleMgr->CreateModule(_os, "Thumbprint");
if (databaseV.size() != size_t(BufferSizes::SRP_6_V) * 2 || databaseS.size() != size_t(BufferSizes::SRP_6_S) * 2)
_SetVSFields(pStr);
else
{
s.SetHexStr(databaseS.c_str());
v.SetHexStr(databaseV.c_str());
}
b.SetRand(128 * 8);
B = ((v * k) + g.ModExp(b, N)) % N;
BigNumber unk;
unk.SetRand(128 * 8);
//.........这里部分代码省略.........