本文整理汇总了C++中QueryResultAutoPtr::Fetch方法的典型用法代码示例。如果您正苦于以下问题:C++ QueryResultAutoPtr::Fetch方法的具体用法?C++ QueryResultAutoPtr::Fetch怎么用?C++ QueryResultAutoPtr::Fetch使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QueryResultAutoPtr
的用法示例。
在下文中一共展示了QueryResultAutoPtr::Fetch方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: HandlePetitionShowSignOpcode
void WorldSession::HandlePetitionShowSignOpcode(WorldPacket & recv_data)
{
CHECK_PACKET_SIZE(recv_data, 8);
// ok
sLog.outDebug("Received opcode CMSG_PETITION_SHOW_SIGNATURES");
//recv_data.hexlike();
uint8 signs = 0;
uint64 petitionguid;
recv_data >> petitionguid; // petition guid
// solve (possible) some strange compile problems with explicit use GUID_LOPART(petitionguid) at some GCC versions (wrong code optimization in compiler?)
uint32 petitionguid_low = GUID_LOPART(petitionguid);
QueryResultAutoPtr result = RealmDataDatabase.PQuery("SELECT type FROM petition WHERE petitionguid = '%u'", petitionguid_low);
if (!result)
{
sLog.outLog(LOG_DEFAULT, "ERROR: any petition on server...");
return;
}
Field *fields = result->Fetch();
uint32 type = fields[0].GetUInt32();
// if guild petition and has guild => error, return;
if (type==9 && _player->GetGuildId())
return;
result = RealmDataDatabase.PQuery("SELECT playerguid FROM petition_sign WHERE petitionguid = '%u'", petitionguid_low);
// result==NULL also correct in case no sign yet
if (result)
signs = result->GetRowCount();
sLog.outDebug("CMSG_PETITION_SHOW_SIGNATURES petition entry: '%u'", petitionguid_low);
WorldPacket data(SMSG_PETITION_SHOW_SIGNATURES, (8+8+4+1+signs*12));
data << petitionguid; // petition guid
data << _player->GetGUID(); // owner guid
data << petitionguid_low; // guild guid (in Trinity always same as GUID_LOPART(petitionguid)
data << signs; // sign's count
for (uint8 i = 1; i <= signs; i++)
{
Field *fields2 = result->Fetch();
uint64 plguid = fields2[0].GetUInt64();
data << plguid; // Player GUID
data << (uint32)0; // there 0 ...
result->NextRow();
}
SendPacket(&data);
}
示例2: Reset
void Reset()
{
events.Reset();
ClearCastQueue();
events.ScheduleEvent(EVENT_SHADOW_VOLLEY, 3000);
events.ScheduleEvent(EVENT_CLEAVE, 5000);
events.ScheduleEvent(EVENT_THUNDER_CLAP, urand(12000, 20000));
events.ScheduleEvent(EVENT_VOID_BOLT, 30000);
events.ScheduleEvent(EVENT_MARKOFKAZZAK, 25000);
events.ScheduleEvent(EVENT_TWIST_REFLECT, 33000);
events.ScheduleEvent(EVENT_ENRAGE, 60000);
QueryResultAutoPtr resultWorldBossRespawn = QueryResultAutoPtr(NULL);
resultWorldBossRespawn = GameDataDatabase.PQuery("SELECT RespawnTime FROM worldboss_respawn WHERE BossEntry = %i", m_creature->GetEntry());
if (resultWorldBossRespawn)
{
Field* fieldsWBR = resultWorldBossRespawn->Fetch();
uint64 last_time_killed = fieldsWBR[0].GetUInt64();
last_time_killed += 259200;
if (last_time_killed >= time(0))
me->DisappearAndDie();
}
}
示例3: HandlePetitionDeclineOpcode
void WorldSession::HandlePetitionDeclineOpcode(WorldPacket & recv_data)
{
CHECK_PACKET_SIZE(recv_data, 8);
sLog.outDebug("Received opcode MSG_PETITION_DECLINE"); // ok
//recv_data.hexlike();
uint64 petitionguid;
uint64 ownerguid;
recv_data >> petitionguid; // petition guid
sLog.outDebug("Petition %u declined by %u", GUID_LOPART(petitionguid), _player->GetGUIDLow());
QueryResultAutoPtr result = RealmDataDatabase.PQuery("SELECT ownerguid FROM petition WHERE petitionguid = '%u'", GUID_LOPART(petitionguid));
if (!result)
return;
Field *fields = result->Fetch();
ownerguid = MAKE_NEW_GUID(fields[0].GetUInt32(), 0, HIGHGUID_PLAYER);
Player *owner = sObjectMgr.GetPlayer(ownerguid);
if (owner) // petition owner online
{
WorldPacket data(MSG_PETITION_DECLINE, 8);
data << _player->GetGUID();
owner->SendPacketToSelf(&data);
}
}
示例4: _HandleReconnectChallenge
/// Reconnect Challenge command handler
bool AuthSocket::_HandleReconnectChallenge()
{
DEBUG_LOG("Entering _HandleReconnectChallenge");
if (recv_len() < sizeof(sAuthLogonChallenge_C))
return false;
///- Read the first 4 bytes (header) to get the length of the remaining of the packet
std::vector<uint8> buf;
buf.resize(4);
recv((char *)&buf[0], 4);
EndianConvert(*((uint16*)(buf[0])));
uint16 remaining = ((sAuthLogonChallenge_C *)&buf[0])->size;
DEBUG_LOG("[ReconnectChallenge] got header, body is %#04x bytes", remaining);
if ((remaining < sizeof(sAuthLogonChallenge_C) - buf.size()) || (recv_len() < remaining))
return false;
//No big fear of memory outage (size is int16, i.e. < 65536)
buf.resize(remaining + buf.size() + 1);
buf[buf.size() - 1] = 0;
sAuthLogonChallenge_C *ch = (sAuthLogonChallenge_C*)&buf[0];
///- Read the remaining of the packet
recv((char *)&buf[4], remaining);
DEBUG_LOG("[ReconnectChallenge] got full packet, %#04x bytes", ch->size);
DEBUG_LOG("[ReconnectChallenge] name(%d): '%s'", ch->I_len, ch->I);
_login = (const char*)ch->I;
_safelogin = _login;
AccountsDatabase.escape_string(_safelogin);
EndianConvert(ch->build);
_build = ch->build;
QueryResultAutoPtr result = AccountsDatabase.PQuery("SELECT session_key FROM account JOIN account_session ON account.account_id = account_session.account_id WHERE username = '%s'", _safelogin.c_str());
// Stop if the account is not found
if (!result)
{
sLog.outLog(LOG_DEFAULT, "ERROR: [ERROR] user %s tried to login and we cannot find his session key in the database.", _login.c_str());
close_connection();
return false;
}
Field* fields = result->Fetch ();
K.SetHexStr (fields[0].GetString ());
///- Sending response
ByteBuffer pkt;
pkt << uint8(CMD_AUTH_RECONNECT_CHALLENGE);
pkt << uint8(0x00);
_reconnectProof.SetRand(16 * 8);
pkt.append(_reconnectProof.AsByteArray(16),16); // 16 bytes random
pkt << uint64(0x00) << uint64(0x00); // 16 bytes zeros
send((char const*)pkt.contents(), pkt.size());
return true;
}
示例5: LoadGuildAnnCooldowns
void GuildMgr::LoadGuildAnnCooldowns()
{
uint32 count = 0;
QueryResultAutoPtr result = RealmDataDatabase.Query("SELECT guild_id, cooldown_end FROM guild_announce_cooldown");
if (!result)
{
BarGoLink bar(1);
bar.step();
sLog.outString();
sLog.outString(">> Loaded 0 guildann_cooldowns.");
return;
}
BarGoLink bar(result->GetRowCount());
do
{
Field *fields = result->Fetch();
bar.step();
uint32 guild_id = fields[0].GetUInt32();
uint64 respawn_time = fields[1].GetUInt64();
m_guildCooldownTimes[guild_id] = time_t(respawn_time);
++count;
} while (result->NextRow());
sLog.outString(">> Loaded %u guild ann cooldowns.", m_guildCooldownTimes.size());
sLog.outString();
}
示例6: SendPetitionQueryOpcode
void WorldSession::SendPetitionQueryOpcode(uint64 petitionguid)
{
uint64 ownerguid = 0;
uint32 type;
std::string name = "NO_NAME_FOR_GUID";
uint8 signs = 0;
QueryResultAutoPtr result = RealmDataDatabase.PQuery(
"SELECT ownerguid, name, "
" (SELECT COUNT(playerguid) FROM petition_sign WHERE petition_sign.petitionguid = '%u') AS signs, "
" type "
"FROM petition WHERE petitionguid = '%u'", GUID_LOPART(petitionguid), GUID_LOPART(petitionguid));
if (result)
{
Field* fields = result->Fetch();
ownerguid = MAKE_NEW_GUID(fields[0].GetUInt32(), 0, HIGHGUID_PLAYER);
name = fields[1].GetCppString();
signs = fields[2].GetUInt8();
type = fields[3].GetUInt32();
}
else
{
sLog.outDebug("CMSG_PETITION_QUERY failed for petition (GUID: %u)", GUID_LOPART(petitionguid));
return;
}
WorldPacket data(SMSG_PETITION_QUERY_RESPONSE, (4+8+name.size()+1+1+4*13));
data << GUID_LOPART(petitionguid); // guild/team guid (in Trinity always same as GUID_LOPART(petition guid)
data << ownerguid; // charter owner guid
data << name; // name (guild/arena team)
data << uint8(0); // 1
if (type == 9)
{
data << uint32(9);
data << uint32(9);
data << uint32(0); // bypass client - side limitation, a different value is needed here for each petition
}
else
{
data << type-1;
data << type-1;
data << type; // bypass client - side limitation, a different value is needed here for each petition
}
data << uint32(0); // 5
data << uint32(0); // 6
data << uint32(0); // 7
data << uint32(0); // 8
data << uint16(0); // 9 2 bytes field
data << uint32(0); // 10
data << uint32(0); // 11
data << uint32(0); // 13 count of next strings?
data << uint32(0); // 14
if (type == 9)
data << uint32(0); // 15 0 - guild, 1 - arena team
else
data << uint32(1);
SendPacket(&data);
}
示例7: InitMaxInstanceId
void MapManager::InitMaxInstanceId()
{
i_MaxInstanceId = 0;
QueryResultAutoPtr result = RealmDataDatabase.Query("SELECT MAX(id) FROM instance");
if (result)
i_MaxInstanceId = result->Fetch()[0].GetUInt32();
}
示例8: HandleChangePlayerNameOpcodeCallBack
void WorldSession::HandleChangePlayerNameOpcodeCallBack(QueryResultAutoPtr result, uint32 accountId, std::string newname)
{
WorldSession * session = sWorld.FindSession(accountId);
if (!session)
return;
if (!result)
{
WorldPacket data(SMSG_CHAR_RENAME, 1);
data << uint8(CHAR_CREATE_ERROR);
session->SendPacket(&data);
return;
}
uint32 guidLow = result->Fetch()[0].GetUInt32();
uint64 guid = MAKE_NEW_GUID(guidLow, 0, HIGHGUID_PLAYER);
std::string oldname = result->Fetch()[1].GetCppString();
static SqlStatementID changeCharName;
static SqlStatementID deleteDeclinedName;
RealmDataDatabase.BeginTransaction();
SqlStatement stmt = RealmDataDatabase.CreateStatement(changeCharName, "UPDATE characters set name = ?, at_login = at_login & ~ ? WHERE guid = ?");
stmt.addString(newname);
stmt.addUInt32(uint32(AT_LOGIN_RENAME));
stmt.addUInt32(guidLow);
stmt.Execute();
stmt = RealmDataDatabase.CreateStatement(deleteDeclinedName, "DELETE FROM character_declinedname WHERE guid = ?");
stmt.PExecute(guidLow);
RealmDataDatabase.CommitTransaction();
sLog.outLog(LOG_CHAR, "Account: %d (IP: %s) Character:[%s] (guid:%u) Changed name to: %s", session->GetAccountId(), session->GetRemoteAddress().c_str(), oldname.c_str(), guidLow, newname.c_str());
WorldPacket data(SMSG_CHAR_RENAME, 1+8+(newname.size()+1));
data << uint8(RESPONSE_SUCCESS);
data << uint64(guid);
data << newname;
session->SendPacket(&data);
}
示例9: HandleCharDeleteOpcode
void WorldSession::HandleCharDeleteOpcode(WorldPacket & recv_data)
{
CHECK_PACKET_SIZE(recv_data,8);
uint64 guid;
recv_data >> guid;
// can't delete loaded character
if (sObjectMgr.GetPlayer(guid))
return;
uint32 accountId = 0;
std::string name;
// is guild leader
if (sGuildMgr.GetGuildByLeader(guid))
{
WorldPacket data(SMSG_CHAR_DELETE, 1);
data << (uint8)CHAR_DELETE_FAILED_GUILD_LEADER;
SendPacket(&data);
return;
}
// is arena team captain
if (sObjectMgr.GetArenaTeamByCaptain(guid))
{
WorldPacket data(SMSG_CHAR_DELETE, 1);
data << (uint8)CHAR_DELETE_FAILED_ARENA_CAPTAIN;
SendPacket(&data);
return;
}
QueryResultAutoPtr result = RealmDataDatabase.PQuery("SELECT account,name FROM characters WHERE guid='%u'", GUID_LOPART(guid));
if (result)
{
Field *fields = result->Fetch();
accountId = fields[0].GetUInt32();
name = fields[1].GetCppString();
}
// prevent deleting other players' characters using cheating tools
if (accountId != GetAccountId())
return;
std::string IP_str = GetRemoteAddress();
sLog.outDetail("Account: %d (IP: %s) Delete Character:[%s] (guid:%u)",GetAccountId(),IP_str.c_str(),name.c_str(),GUID_LOPART(guid));
sLog.outLog(LOG_CHAR, "Account: %d (IP: %s) Delete Character:[%s] (guid: %u)",GetAccountId(),IP_str.c_str(),name.c_str(),GUID_LOPART(guid));
Player::DeleteFromDB(guid, GetAccountId());
WorldPacket data(SMSG_CHAR_DELETE, 1);
data << (uint8)CHAR_DELETE_SUCCESS;
SendPacket(&data);
}
示例10: HandleAccountOnlineListCommand
/// Display info on users currently in the realm
bool ChatHandler::HandleAccountOnlineListCommand(const char* args)
{
///- Get the list of accounts ID logged to the realm
QueryResultAutoPtr resultDB = RealmDataDatabase.Query("SELECT name, account FROM characters WHERE online > 0");
if (!resultDB)
return true;
///- Display the list of account/characters online
SendSysMessage("=====================================================================");
SendSysMessage(LANG_ACCOUNT_LIST_HEADER);
SendSysMessage("=====================================================================");
///- Circle through accounts
do
{
Field *fieldsDB = resultDB->Fetch();
std::string name = fieldsDB[0].GetCppString();
uint32 account = fieldsDB[1].GetUInt32();
///- Get the username, last IP and GM level of each account
// No SQL injection. account is uint32.
// 0 1 2 3
QueryResultAutoPtr resultLogin = AccountsDatabase.PQuery("SELECT username, last_ip, permission_mask, expansion_id "
"FROM account JOIN account_permissions ON account.account_id = account_permissions.account_id "
"WHERE account_id = '%u' AND realm_id = '%u'", account, realmID);
if(resultLogin)
{
Field *fieldsLogin = resultLogin->Fetch();
PSendSysMessage("|%15s| %20s | %15s |%4d|%5d|",
fieldsLogin[0].GetString(),name.c_str(),fieldsLogin[1].GetString(),fieldsLogin[2].GetUInt32(),fieldsLogin[3].GetUInt32());
}
else
PSendSysMessage(LANG_ACCOUNT_LIST_ERROR, name.c_str());
}
while(resultDB->NextRow());
SendSysMessage("=====================================================================");
return true;
}
示例11: LoadFromDB
void ReputationMgr::LoadFromDB(QueryResultAutoPtr result)
{
// Set initial reputations (so everything is nifty before DB data load)
Initialize();
//QueryResult *result = CharacterDatabase.PQuery("SELECT faction,standing,flags FROM character_reputation WHERE guid = '%u'",GetGUIDLow());
if (result)
{
do
{
Field *fields = result->Fetch();
FactionEntry const *factionEntry = sFactionStore.LookupEntry(fields[0].GetUInt32());
if (factionEntry && (factionEntry->reputationListID >= 0))
{
FactionState* faction = &m_factions[factionEntry->reputationListID];
// update standing to current
faction->Standing = int32(fields[1].GetUInt32());
uint32 dbFactionFlags = fields[2].GetUInt32();
if (dbFactionFlags & FACTION_FLAG_VISIBLE)
SetVisible(faction); // have internal checks for forced invisibility
if (dbFactionFlags & FACTION_FLAG_INACTIVE)
SetInactive(faction, true); // have internal checks for visibility requirement
if (dbFactionFlags & FACTION_FLAG_AT_WAR) // DB at war
SetAtWar(faction, true); // have internal checks for FACTION_FLAG_PEACE_FORCED
else // DB not at war
{
// allow remove if visible (and then not FACTION_FLAG_INVISIBLE_FORCED or FACTION_FLAG_HIDDEN)
if (faction->Flags & FACTION_FLAG_VISIBLE)
SetAtWar(faction, false); // have internal checks for FACTION_FLAG_PEACE_FORCED
}
// set atWar for hostile
if (GetRank(factionEntry) <= REP_HOSTILE)
SetAtWar(faction,true);
// reset changed flag if values similar to saved in DB
if (faction->Flags==dbFactionFlags)
{
faction->needSend = false;
faction->needSave = false;
}
}
}
while(result->NextRow());
}
}
示例12: UpdatePath
void WaypointMgr::UpdatePath(uint32 id)
{
if (_waypointPathMap.find(id)!= _waypointPathMap.end())
_waypointPathMap[id]->clear();
QueryResultAutoPtr result = GameDataDatabase.PQuery("SELECT `id`,`point`,`position_x`,`position_y`,`position_z`,`move_type`,`delay`,`action`,`action_chance` FROM `waypoint_data` WHERE id = %u ORDER BY `point`", id);
if (!result)
return;
WaypointPath* path_data;
path_data = new WaypointPath;
Field *fields;
do
{
fields = result->Fetch();
uint32 id = fields[0].GetUInt32();
WaypointData *wp = new WaypointData;
float x,y,z;
x = fields[2].GetFloat();
y = fields[3].GetFloat();
z = fields[4].GetFloat();
Looking4group::NormalizeMapCoord(x);
Looking4group::NormalizeMapCoord(y);
wp->id = fields[1].GetUInt32();
wp->x = x;
wp->y = y;
wp->z = z;
wp->moveType = WaypointMoveType(fields[5].GetUInt8());
wp->delay = fields[6].GetUInt32();
wp->event_id = fields[7].GetUInt32();
wp->event_chance = fields[8].GetUInt8();
path_data->push_back(wp);
}
while (result->NextRow());
_waypointPathMap[id] = path_data;
}
示例13: LoadGuilds
void GuildMgr::LoadGuilds()
{
Guild *newguild;
uint32 count = 0;
QueryResultAutoPtr result = RealmDataDatabase.Query("SELECT guildid FROM guild");
if (!result)
{
BarGoLink bar(1);
bar.step();
sLog.outString();
sLog.outString(">> Loaded %u guild definitions", count);
return;
}
BarGoLink bar(result->GetRowCount());
do
{
Field *fields = result->Fetch();
bar.step();
++count;
newguild = new Guild;
if ( !newguild->LoadGuildFromDB( fields[0].GetUInt32() ) )
{
newguild->Disband();
delete newguild;
continue;
}
AddGuild(newguild);
}
while ( result->NextRow( ));
result = RealmDataDatabase.Query("SELECT MAX(guildid) FROM guild");
if (result)
m_guildId = (*result)[0].GetUInt32()+1;
sLog.outString();
sLog.outString(">> Loaded %u guild definitions, next guild ID: %u", count, m_guildId);
}
示例14: HandleAccountWhispLogCommand
bool ChatHandler::HandleAccountWhispLogCommand(const char* args)
{
if(!*args)
return false;
if (uint32 account_id = AccountMgr::GetId(args))
{
QueryResultAutoPtr result = AccountsDatabase.PQuery("SELECT account_flags FROM account WHERE account_id = '%u'", account_id);
if (!result)
return false;
Field * fields = result->Fetch();
uint64 accFlags = fields[0].GetUInt64();
if (WorldSession *session = sWorld.FindSession(account_id))
{
if (accFlags & ACC_WHISPER_LOG)
session->RemoveAccountFlag(ACC_WHISPER_LOG);
else
session->AddAccountFlag(ACC_WHISPER_LOG);
}
else
{
if (accFlags & ACC_WHISPER_LOG)
WorldSession::SaveAccountFlags(account_id, accFlags &= ~ACC_WHISPER_LOG);
else
WorldSession::SaveAccountFlags(account_id, accFlags |= ACC_WHISPER_LOG);
}
if (accFlags & ACC_WHISPER_LOG)
PSendSysMessage("WhispLog have been disabled for account: %u.", account_id);
else
PSendSysMessage("WhispLog have been enabled for account: %u.", account_id);
}
else
{
PSendSysMessage("Specified account not found.");
SetSentErrorMessage(true);
return false;
}
return true;
}
示例15: LoadFromDB
bool Corpse::LoadFromDB(uint32 guid, QueryResultAutoPtr result, uint32 InstanceId)
{
if (! result)
// 0 1 2 3 4 5 6 7 8
result = RealmDataDatabase.PQuery("SELECT position_x,position_y,position_z,orientation,map,data,time,corpse_type,instance FROM corpse WHERE guid = '%u'",guid);
if (! result)
{
sLog.outLog(LOG_DEFAULT, "ERROR: Corpse (GUID: %u) not found in table `corpse`, can't load. ",guid);
return false;
}
Field *fields = result->Fetch();
if (!LoadFromDB(guid,fields))
return false;
return true;
}