本文整理汇总了C++中QueryResult_AutoPtr::NextRow方法的典型用法代码示例。如果您正苦于以下问题:C++ QueryResult_AutoPtr::NextRow方法的具体用法?C++ QueryResult_AutoPtr::NextRow怎么用?C++ QueryResult_AutoPtr::NextRow使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QueryResult_AutoPtr
的用法示例。
在下文中一共展示了QueryResult_AutoPtr::NextRow方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: UpdateRealms
void RealmList::UpdateRealms(bool init)
{
sLog.outDetail("Updating Realm List...");
// 0 1 2 3 4 5 6 7 8 9
QueryResult_AutoPtr result = LoginDatabase.Query( "SELECT id, name, address, port, icon, flag, timezone, allowedSecurityLevel, population, gamebuild FROM realmlist WHERE (flag & 1) = 0 ORDER BY name" );
// Circle through results and add them to the realm map
if (result)
{
do
{
Field *fields = result->Fetch();
uint8 allowedSecurityLevel = fields[7].GetUInt8();
uint8 realmflags = fields[5].GetUInt8();
if (realmflags & ~(REALM_FLAG_OFFLINE|REALM_FLAG_NEW_PLAYERS|REALM_FLAG_RECOMMENDED|REALM_FLAG_SPECIFYBUILD))
{
sLog.outError("Realm allowed have only OFFLINE Mask 0x2), or NEWPLAYERS (mask 0x20), or RECOMENDED (mask 0x40), or SPECIFICBUILD (mask 0x04) flags in DB");
realmflags &= (REALM_FLAG_OFFLINE|REALM_FLAG_NEW_PLAYERS|REALM_FLAG_RECOMMENDED|REALM_FLAG_SPECIFYBUILD);
}
UpdateRealm(
fields[0].GetUInt32(), fields[1].GetCppString(),fields[2].GetCppString(),fields[3].GetUInt32(),
fields[4].GetUInt8(), RealmFlags(realmflags), fields[6].GetUInt8(),
(allowedSecurityLevel <= SEC_ADMINISTRATOR ? AccountTypes(allowedSecurityLevel) : SEC_ADMINISTRATOR),
fields[8].GetFloat(), fields[9].GetString());
if (init)
sLog.outString("Added realm \"%s\"", fields[1].GetString());
} while ( result->NextRow() );
}
}
示例2: showBuyList
bool showBuyList(Player *player, Creature *_creature, uint32 showFromId = 0)
{
//show not occupied guildhouses
QueryResult_AutoPtr result;
result = WorldDatabase.PQuery("SELECT `id`, `comment` FROM `guildhouses` WHERE `guildId` = 0 AND `id` > %u ORDER BY `id` ASC LIMIT %u",showFromId, GOSSIP_COUNT_MAX);
// QueryResult_AutoPtr result2;
// result2 = WorldDatabase.PQuery("SELECT count(id) FROM `guildhouses` WHERE `guildId` = 0 ");
// if (result2)
// {
if (result)
{
uint32 guildhouseId = 0;
std::string comment = "";
do
{
Field *fields = result->Fetch();
guildhouseId = fields[0].GetInt32();
comment = fields[1].GetString();
//send comment as a gossip item
//transmit guildhouseId in Action variable
player->ADD_GOSSIP_ITEM(ICON_GOSSIP_TABARD, comment, GOSSIP_SENDER_MAIN,
guildhouseId + OFFSET_GH_ID_TO_ACTION);
} while (result->NextRow());
if (result->GetRowCount() == GOSSIP_COUNT_MAX)
{
//assume that we have additional page
//add link to next GOSSIP_COUNT_MAX items
player->ADD_GOSSIP_ITEM(ICON_GOSSIP_BALOONDOTS, MSG_GOSSIP_NEXTPAGE, GOSSIP_SENDER_MAIN,
guildhouseId + OFFSET_SHOWBUY_FROM);
}
//delete result;
player->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE, _creature->GetGUID());
return true;
} else
{
if (showFromId == 0)
{
//all guildhouses are occupied
_creature->MonsterWhisper(MSG_NOFREEGH, player->GetGUID());
player->CLOSE_GOSSIP_MENU();
} else
{
//this condition occurs when COUNT(guildhouses) % GOSSIP_COUNT_MAX == 0
//just show GHs from beginning
//showBuyList(player, _creature, 0);
}
}
return false;
}
示例3: Update
void AuctionHouseObject::Update()
{
time_t curTime = sWorld.GetGameTime();
// Handle expired auctions
// If storage is empty, no need to update. next == NULL in this case.
if (AuctionsMap.empty())
return;
QueryResult_AutoPtr result = CharacterDatabase.PQuery("SELECT id FROM auctionhouse WHERE time <= %u ORDER BY TIME ASC", (uint32)curTime+60);
if (!result)
return;
if (result->GetRowCount() == 0)
return;
vector<uint32> expiredAuctions;
do
{
uint32 tmpdata = result->Fetch()->GetUInt32();
expiredAuctions.push_back(tmpdata);
} while (result->NextRow());
while (!expiredAuctions.empty())
{
vector<uint32>::iterator iter = expiredAuctions.begin();
// from auctionhousehandler.cpp, creates auction pointer & player pointer
AuctionEntry* auction = GetAuction(*iter);
// Erase the auction from the vector.
expiredAuctions.erase(iter);
if (!auction)
continue;
///- Either cancel the auction if there was no bidder
if (auction->bidder == 0)
sAuctionMgr->SendAuctionExpiredMail(auction);
///- Or perform the transaction
else
{
//we should send an "item sold" message if the seller is online
//we send the item to the winner
//we send the money to the seller
sAuctionMgr->SendAuctionSuccessfulMail(auction);
sAuctionMgr->SendAuctionWonMail(auction);
}
///- In any case clear the auction
CharacterDatabase.BeginTransaction();
auction->DeleteFromDB();
uint32 item_template = auction->item_template;
sAuctionMgr->RemoveAItem(auction->item_guidlow);
RemoveAuction(auction, item_template);
CharacterDatabase.CommitTransaction();
}
}
示例4: LoadMembersFromDB
void ArenaTeam::LoadMembersFromDB(uint32 ArenaTeamId)
{
// 0 1 2 3 4 5 6 7
QueryResult_AutoPtr result = CharacterDatabase.PQuery("SELECT member.guid,played_week,wons_week,played_season,wons_season,personal_rating,name,class "
"FROM arena_team_member member "
"INNER JOIN characters chars on member.guid = chars.guid "
"WHERE member.arenateamid = '%u'", ArenaTeamId);
if (!result)
return;
do
{
Field *fields = result->Fetch();
ArenaTeamMember newmember;
newmember.guid = MAKE_NEW_GUID(fields[0].GetUInt32(), 0, HIGHGUID_PLAYER);
newmember.games_week = fields[1].GetUInt32();
newmember.wins_week = fields[2].GetUInt32();
newmember.games_season = fields[3].GetUInt32();
newmember.wins_season = fields[4].GetUInt32();
newmember.personal_rating = fields[5].GetUInt32();
newmember.name = fields[6].GetCppString();
newmember.Class = fields[7].GetUInt8();
m_members.push_back(newmember);
}while (result->NextRow());
}
示例5: Initialize
// The initialize method will spawn all pools not in an event and not in another pool, this is why there is 2 left joins with 2 null checks
void PoolHandler::Initialize()
{
QueryResult_AutoPtr result = WorldDatabase.Query("SELECT DISTINCT pool_template.entry FROM pool_template LEFT JOIN game_event_pool ON pool_template.entry=game_event_pool.pool_entry LEFT JOIN pool_pool ON pool_template.entry=pool_pool.pool_id WHERE game_event_pool.pool_entry IS NULL AND pool_pool.pool_id IS NULL");
uint32 count=0;
if (result)
{
do
{
Field *fields = result->Fetch();
uint16 pool_entry = fields[0].GetUInt16();
if (!CheckPool(pool_entry))
{
sLog.outErrorDb("Pool Id (%u) has all creatures or gameobjects with explicit chance sum <>100 and no equal chance defined. The pool system cannot pick one to spawn.", pool_entry);
continue;
}
SpawnPool(pool_entry, 0, 0);
SpawnPool(pool_entry, 0, TYPEID_GAMEOBJECT);
SpawnPool(pool_entry, 0, TYPEID_UNIT);
count++;
} while (result->NextRow());
}
sLog.outBasic("Pool handling system initialized, %u pools spawned.", count);
m_IsPoolSystemStarted = true;
}
示例6: LoadFromDB
void AddonMgr::LoadFromDB()
{
QueryResult_AutoPtr result = CharacterDatabase.PQuery("SELECT name, crc FROM addons");
if(!result)
{
sLog.outErrorDb("The table `addons` is empty");
return;
}
barGoLink bar(result->GetRowCount());
uint32 count = 0;
Field *fields;
do
{
fields = result->Fetch();
bar.step();
count++;
std::string name = fields[0].GetCppString();
uint32 crc = fields[1].GetUInt32();
SavedAddon addon(name, crc);
m_knownAddons.push_back(addon);
} while(result->NextRow());
sLog.outString();
sLog.outString(">> Loaded %u known addons", count);
}
示例7: HandleCharEnum
void WorldSession::HandleCharEnum(QueryResult_AutoPtr result)
{
// keys can be non cleared if player open realm list and close it by 'cancel'
LoginDatabase.PExecute("UPDATE account SET v = '0', s = '0' WHERE id = '%u'", GetAccountId());
WorldPacket data(SMSG_CHAR_ENUM, 100); // we guess size
uint8 num = 0;
data << num;
if (result )
{
Player *plr = new Player(this);
do
{
uint32 guidlow = (*result)[0].GetUInt32();
sLog.outDetail("Loading char guid %u from account %u.",guidlow,GetAccountId());
if (plr->MinimalLoadFromDB(result, guidlow ))
{
plr->BuildEnumData(result, &data);
++num;
}
}
while (result->NextRow());
delete plr;
}
data.put<uint8>(0, num);
SendPacket(&data);
}
示例8: LoadCreatureTextLocales
void CreatureTextMgr::LoadCreatureTextLocales()
{
uint32 oldMSTime = getMSTime();
mLocaleTextMap.clear(); // for reload case
QueryResult_AutoPtr result = WorldDatabase.Query("SELECT entry, groupid, id, text_loc1, text_loc2, text_loc3, text_loc4, text_loc5, text_loc6, text_loc7, text_loc8 FROM locales_creature_text");
if (!result)
return;
uint32 textCount = 0;
do
{
Field* fields = result->Fetch();
CreatureTextLocale& loc = mLocaleTextMap[CreatureTextId(fields[0].GetUInt32(), uint32(fields[1].GetUInt8()), uint32(fields[2].GetUInt8()))];
for (uint8 i = MAX_LOCALE - 1; i > 0; --i)
{
LocaleConstant locale = LocaleConstant(i);
ObjectMgr::AddLocaleString(fields[3 + i - 1].GetString(), locale, loc.Text);
}
++textCount;
} while (result->NextRow());
sLog.outString(">> Loaded %u creature localized texts in %u ms", textCount, GetMSTimeDiffToNow(oldMSTime));
}
示例9: UpdateRealms
void RealmList::UpdateRealms(bool init)
{
sLog->outDetail("Updating Realm List...");
QueryResult_AutoPtr result = LoginDatabase.Query("SELECT id, name, address, port, icon, color, timezone, allowedSecurityLevel, population, gamebuild FROM realmlist WHERE color <> 3 ORDER BY name");
// Circle through results and add them to the realm map
if (result)
{
do
{
Field* fields = result->Fetch();
uint32 realmId = fields[0].GetUInt32();
const std::string& name = fields[1].GetString();
const std::string& address = fields[2].GetString();
uint32 port = fields[3].GetUInt32();
uint8 icon = fields[4].GetUInt8();
uint8 color = fields[5].GetUInt8();
uint8 timezone = fields[6].GetUInt8();
uint8 allowedSecurityLevel = fields[7].GetUInt8();
float pop = fields[8].GetFloat();
uint32 build = fields[9].GetUInt32();
UpdateRealm(realmId, name, address, port, icon, color, timezone, (allowedSecurityLevel <= SEC_ADMINISTRATOR ? AccountTypes(allowedSecurityLevel) : SEC_ADMINISTRATOR), pop, build);
if (init)
sLog->outString("Added realm \"%s\".", fields[1].GetString());
}
while (result->NextRow());
}
}
示例10: _DelHelper
void InstanceSaveManager::_DelHelper(DatabaseType &db, const char *fields, const char *table, const char *queryTail,...)
{
Tokens fieldTokens = StrSplit(fields, ", ");
ASSERT(fieldTokens.size() != 0);
va_list ap;
char szQueryTail [MAX_QUERY_LEN];
va_start(ap, queryTail);
vsnprintf(szQueryTail, MAX_QUERY_LEN, queryTail, ap);
va_end(ap);
QueryResult_AutoPtr result = db.PQuery("SELECT %s FROM %s %s", fields, table, szQueryTail);
if (result)
{
do
{
Field *fields = result->Fetch();
std::ostringstream ss;
for (size_t i = 0; i < fieldTokens.size(); i++)
{
std::string fieldValue = fields[i].GetCppString();
db.escape_string(fieldValue);
ss << (i != 0 ? " AND " : "") << fieldTokens[i] << " = '" << fieldValue << "'";
}
db.DirectPExecute("DELETE FROM %s WHERE %s", table, ss.str().c_str());
} while (result->NextRow());
}
}
示例11: Initialize
// The initialize method will spawn all pools not in an event and not in another pool, this is why there is 2 left joins with 2 null checks
void PoolMgr::Initialize()
{
QueryResult_AutoPtr result = WorldDatabase.Query("SELECT DISTINCT pool_template.entry, pool_pool.pool_id, pool_pool.mother_pool FROM pool_template LEFT JOIN game_event_pool ON pool_template.entry=game_event_pool.pool_entry LEFT JOIN pool_pool ON pool_template.entry=pool_pool.pool_id WHERE game_event_pool.pool_entry IS NULL");
uint32 count = 0;
if (result)
{
do
{
Field *fields = result->Fetch();
uint16 pool_entry = fields[0].GetUInt16();
uint16 pool_pool_id = fields[1].GetUInt16();
if (!CheckPool(pool_entry))
{
if (pool_pool_id)
// The pool is a child pool in pool_pool table. Ideally we should remove it from the pool handler to ensure it never gets spawned,
// however that could recursively invalidate entire chain of mother pools. It can be done in the future but for now we'll do nothing.
sLog->outErrorDb("Pool Id %u has no equal chance pooled entites defined and explicit chance sum is not 100. This broken pool is a child pool of Id %u and cannot be safely removed.", pool_entry, fields[2].GetUInt16());
else
sLog->outErrorDb("Pool Id %u has no equal chance pooled entites defined and explicit chance sum is not 100. The pool will not be spawned.", pool_entry);
continue;
}
// Don't spawn child pools, they are spawned recursively by their parent pools
if (!pool_pool_id)
{
SpawnPool(pool_entry);;
count++;
}
} while (result->NextRow());
}
sLog->outBasic("Pool handling system initialized, %u pools spawned.", count);
}
示例12: LoadMembersFromDB
bool ArenaTeam::LoadMembersFromDB(QueryResult_AutoPtr arenaTeamMembersResult)
{
if (!arenaTeamMembersResult)
return false;
bool captainPresentInTeam = false;
do
{
Field* fields = arenaTeamMembersResult->Fetch();
// prevent crash if db records are broken, when all members in result are already processed and current team hasn't got any members
if (!fields)
break;
uint32 arenaTeamId = fields[0].GetUInt32();
if (arenaTeamId < m_TeamId)
{
// there is in table arena_team_member record which doesn't have arenateamid in arena_team table, report error
sLog.outErrorDb("ArenaTeam %u does not exist but it has record in arena_team_member table, deleting it!", arenaTeamId);
CharacterDatabase.PExecute("DELETE FROM arena_team_member WHERE arenateamid = '%u'", arenaTeamId);
continue;
}
if (arenaTeamId > m_TeamId)
// we loaded all members for this arena_team already, break cycle
break;
ArenaTeamMember newmember;
newmember.guid = MAKE_NEW_GUID(fields[1].GetUInt32(), 0, HIGHGUID_PLAYER);
newmember.games_week = fields[2].GetUInt32();
newmember.wins_week = fields[3].GetUInt32();
newmember.games_season = fields[4].GetUInt32();
newmember.wins_season = fields[5].GetUInt32();
newmember.personal_rating = fields[6].GetUInt32();
newmember.name = fields[7].GetCppString();
newmember.Class = fields[8].GetUInt8();
//check if member exists in characters table
if (newmember.name.empty())
{
sLog.outErrorDb("ArenaTeam %u has member with empty name - probably player %u doesn't exist, deleting him from memberlist!", arenaTeamId, GUID_LOPART(newmember.guid));
this->DelMember(newmember.guid);
continue;
}
if (newmember.guid == GetCaptain())
captainPresentInTeam = true;
m_members.push_back(newmember);
}
while (arenaTeamMembersResult->NextRow());
if (Empty() || !captainPresentInTeam)
{
// arena team is empty or captain is not in team, delete from db
sLog.outErrorDb("ArenaTeam %u does not have any members or its captain is not in team, disbanding it...", m_TeamId);
return false;
}
return true;
}
示例13: LoadAccountData
void WorldSession::LoadAccountData(QueryResult_AutoPtr result, uint32 mask)
{
for (uint32 i = 0; i < NUM_ACCOUNT_DATA_TYPES; ++i)
if (mask & (1 << i))
m_accountData[i] = AccountData();
if (!result)
return;
do
{
Field *fields = result->Fetch();
uint32 type = fields[0].GetUInt32();
if (type >= NUM_ACCOUNT_DATA_TYPES)
{
sLog.outError("Table `%s` have invalid account data type (%u), ignore.",
mask == GLOBAL_CACHE_MASK ? "account_data" : "character_account_data", type);
continue;
}
if ((mask & (1 << type)) == 0)
{
sLog.outError("Table `%s` have non appropriate for table account data type (%u), ignore.",
mask == GLOBAL_CACHE_MASK ? "account_data" : "character_account_data", type);
continue;
}
m_accountData[type].Time = fields[1].GetUInt32();
m_accountData[type].Data = fields[2].GetCppString();
} while (result->NextRow());
}
示例14: HandleStablePet
void WorldSession::HandleStablePet(WorldPacket& recv_data)
{
sLog->outDebug("WORLD: Recv CMSG_STABLE_PET");
uint64 npcGUID;
recv_data >> npcGUID;
if (!GetPlayer()->isAlive())
return;
Creature *unit = GetPlayer()->GetNPCIfCanInteractWith(npcGUID, UNIT_NPC_FLAG_STABLEMASTER);
if (!unit)
{
sLog->outDebug("WORLD: HandleStablePet - Unit (GUID: %u) not found or you can not interact with him.", uint32(GUID_LOPART(npcGUID)));
return;
}
// remove fake death
if (GetPlayer()->hasUnitState(UNIT_STAT_DIED))
GetPlayer()->RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH);
Pet *pet = _player->GetPet();
WorldPacket data(SMSG_STABLE_RESULT, 200); // guess size
// can't place in stable dead pet
if (!pet||!pet->isAlive()||pet->getPetType() != HUNTER_PET)
{
data << uint8(0x06);
SendPacket(&data);
return;
}
uint32 free_slot = 1;
QueryResult_AutoPtr result = CharacterDatabase.PQuery("SELECT owner, slot, id FROM character_pet WHERE owner = '%u' AND slot > 0 AND slot < 3 ORDER BY slot ", _player->GetGUIDLow());
if (result)
{
do
{
Field *fields = result->Fetch();
uint32 slot = fields[1].GetUInt32();
if (slot == free_slot) // this slot not free
++free_slot;
}while (result->NextRow());
}
if (free_slot > 0 && free_slot <= GetPlayer()->m_stableSlots)
{
_player->RemovePet(pet, PetSaveMode(free_slot));
data << uint8(0x08);
}
else
data << uint8(0x06);
SendPacket(&data);
}
示例15: LoadFromDB
void ReputationMgr::LoadFromDB(QueryResult_AutoPtr 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 = &_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
ForcedReactions::const_iterator forceItr = _forcedReactions.find(factionEntry->ID);
if (forceItr != _forcedReactions.end())
{
if (forceItr->second <= REP_HOSTILE)
SetAtWar(faction, true);
}
else 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());
}
}