本文整理汇总了C++中QueryResult_AutoPtr::GetRowCount方法的典型用法代码示例。如果您正苦于以下问题:C++ QueryResult_AutoPtr::GetRowCount方法的具体用法?C++ QueryResult_AutoPtr::GetRowCount怎么用?C++ QueryResult_AutoPtr::GetRowCount使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QueryResult_AutoPtr
的用法示例。
在下文中一共展示了QueryResult_AutoPtr::GetRowCount方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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();
}
}
示例2: 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);
}
示例3: 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;
}
示例4: LoadScriptWaypoints
void SystemMgr::LoadScriptWaypoints()
{
// Drop Existing Waypoint list
m_mPointMoveMap.clear();
uint64 uiCreatureCount = 0;
// Load Waypoints
QueryResult_AutoPtr Result = WorldDatabase.Query("SELECT COUNT(entry) FROM script_waypoint GROUP BY entry");
if (Result)
uiCreatureCount = Result->GetRowCount();
sLog->outString("TSCR: Loading Script Waypoints for %u creature(s)...", uiCreatureCount);
Result = WorldDatabase.Query("SELECT entry, pointid, location_x, location_y, location_z, waittime FROM script_waypoint ORDER BY pointid");
if (Result)
{
uint32 uiNodeCount = 0;
do
{
Field* pFields = Result->Fetch();
ScriptPointMove pTemp;
pTemp.uiCreatureEntry = pFields[0].GetUInt32();
uint32 uiEntry = pTemp.uiCreatureEntry;
pTemp.uiPointId = pFields[1].GetUInt32();
pTemp.fX = pFields[2].GetFloat();
pTemp.fY = pFields[3].GetFloat();
pTemp.fZ = pFields[4].GetFloat();
pTemp.uiWaitTime = pFields[5].GetUInt32();
CreatureTemplate const* pCInfo = GetCreatureTemplateStore(pTemp.uiCreatureEntry);
if (!pCInfo)
{
sLog->outErrorDb("TSCR: DB table script_waypoint has waypoint for non-existant creature entry %u", pTemp.uiCreatureEntry);
continue;
}
if (!pCInfo->ScriptID)
sLog->outErrorDb("TSCR: DB table script_waypoint has waypoint for creature entry %u, but creature does not have ScriptName defined and then useless.", pTemp.uiCreatureEntry);
m_mPointMoveMap[uiEntry].push_back(pTemp);
++uiNodeCount;
} while (Result->NextRow());
sLog->outString("");
sLog->outString(">> Loaded %u Script Waypoint nodes.", uiNodeCount);
}
else
{
sLog->outString("");
sLog->outString(">> Loaded 0 Script Waypoints. DB table script_waypoint is empty.");
}
}
示例5: LoadCreatureEventAI_Summons
// -------------------
void CreatureEventAIMgr::LoadCreatureEventAI_Summons(bool check_entry_use)
{
//Drop Existing EventSummon Map
m_CreatureEventAI_Summon_Map.clear();
// Gather additional data for EventAI
QueryResult_AutoPtr result = WorldDatabase.Query("SELECT id, position_x, position_y, position_z, orientation, spawntimesecs FROM creature_ai_summons");
if (result)
{
barGoLink bar(result->GetRowCount());
uint32 Count = 0;
do
{
bar.step();
Field *fields = result->Fetch();
CreatureEventAI_Summon temp;
uint32 i = fields[0].GetUInt32();
temp.position_x = fields[1].GetFloat();
temp.position_y = fields[2].GetFloat();
temp.position_z = fields[3].GetFloat();
temp.orientation = fields[4].GetFloat();
temp.SpawnTimeSecs = fields[5].GetUInt32();
if (!Oregon::IsValidMapCoord(temp.position_x,temp.position_y,temp.position_z,temp.orientation))
{
sLog.outErrorDb("CreatureEventAI: Summon id %u has invalid coordinates (%f,%f,%f,%f), skipping.", i,temp.position_x,temp.position_y,temp.position_z,temp.orientation);
continue;
}
//Add to map
m_CreatureEventAI_Summon_Map[i] = temp;
++Count;
} while (result->NextRow());
if (check_entry_use)
CheckUnusedAISummons();
sLog.outString();
sLog.outString(">> Loaded %u CreatureEventAI summon definitions", Count);
}
else
{
barGoLink bar(1);
bar.step();
sLog.outString();
sLog.outString(">> Loaded 0 CreatureEventAI Summon definitions. DB table creature_ai_summons is empty.");
}
}
示例6: HandlePetitionShowSignOpcode
void WorldSession::HandlePetitionShowSignOpcode(WorldPacket & recv_data)
{
// ok
sLog.outDebug("Received opcode CMSG_PETITION_SHOW_SIGNATURES");
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);
QueryResult_AutoPtr result = CharacterDatabase.PQuery("SELECT type FROM petition WHERE petitionguid = '%u'", petitionguid_low);
if (!result)
{
sLog.outError("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 = CharacterDatabase.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 Oregon always same as GUID_LOPART(petitionguid)
data << signs; // sign's count
for (uint8 i = 1; i <= signs; ++i)
{
Field *fields = result->Fetch();
uint64 plguid = fields[0].GetUInt64();
data << plguid; // Player GUID
data << (uint32)0; // there 0 ...
result->NextRow();
}
SendPacket(&data);
}
示例7: LoadAuctionItems
void AuctionHouseMgr::LoadAuctionItems()
{
// data needs to be at first place for Item::LoadFromDB
QueryResult_AutoPtr result = CharacterDatabase.Query("SELECT data,itemguid,item_template FROM auctionhouse JOIN item_instance ON itemguid = guid");
if (!result)
{
barGoLink bar(1);
bar.step();
sLog.outString();
sLog.outString(">> Loaded 0 auction items");
return;
}
barGoLink bar(result->GetRowCount());
uint32 count = 0;
Field *fields;
do
{
bar.step();
fields = result->Fetch();
uint32 item_guid = fields[1].GetUInt32();
uint32 item_template = fields[2].GetUInt32();
ItemPrototype const *proto = objmgr.GetItemPrototype(item_template);
if (!proto)
{
sLog.outError("AuctionHouseMgr::LoadAuctionItems: Unknown item (GUID: %u id: #%u) in auction, skipped.", item_guid,item_template);
continue;
}
Item *item = NewItemOrBag(proto);
if (!item->LoadFromDB(item_guid,0, result))
{
delete item;
continue;
}
AddAItem(item);
++count;
}
while (result->NextRow());
sLog.outString();
sLog.outString(">> Loaded %u auction items", count);
}
示例8: LoadGMTickets
void TicketMgr::LoadGMTickets()
{
// Delete all out of object holder
GM_TicketList.clear();
QueryResult_AutoPtr result = CharacterDatabase.Query("SELECT guid, playerGuid, name, message, createtime, map, posX, posY, posZ, timestamp, closed, assignedto, comment, escalated, viewed FROM gm_tickets");
GM_Ticket *ticket;
if (!result)
{
ticketmgr.InitTicketID();
sLog.outString();
sLog.outString(">> GM Tickets table is empty, no tickets were loaded.");
return;
}
// Assign values from SQL to the object holder
do
{
Field *fields = result->Fetch();
ticket = new GM_Ticket;
ticket->guid = fields[0].GetUInt64();
ticket->playerGuid = fields[1].GetUInt64();
ticket->name = fields[2].GetString();
ticket->message = fields[3].GetString();
ticket->createtime = fields[4].GetUInt64();
ticket->map = fields[5].GetUInt32();
ticket->pos_x = fields[6].GetFloat();
ticket->pos_y = fields[7].GetFloat();
ticket->pos_z = fields[8].GetFloat();
ticket->timestamp = fields[9].GetUInt64();
ticket->closed = fields[10].GetUInt64();
ticket->assignedToGM = fields[11].GetUInt64();
ticket->comment = fields[12].GetString();
ticket->escalated = fields[13].GetUInt64();
ticket->viewed = fields[14].GetBool();
AddGMTicket(ticket, true);
} while (result->NextRow());
sWorld.SendGMText(LANG_COMMAND_TICKETRELOAD, result->GetRowCount());
}
示例9: CheckUnique
void CharacterDatabaseCleaner::CheckUnique(const char* column, const
char* table, bool (*check)(uint32))
{
QueryResult_AutoPtr result = CharacterDatabase.PQuery("SELECT DISTINCT %s FROM %s", column, table);
if(!result)
{
sLog.outString( "Table %s is empty.", table );
return;
}
bool found = false;
std::ostringstream ss;
barGoLink bar( (int)result->GetRowCount() );
do
{
bar.step();
Field *fields = result->Fetch();
uint32 id = fields[0].GetUInt32();
if(!check(id))
{
if(!found)
{
ss << "DELETE FROM " << table << " WHERE " << column << " IN (";
found = true;
}
else
ss << ",";
ss << id;
}
}
while( result->NextRow() );
if (found)
{
ss << ")";
CharacterDatabase.Execute( ss.str().c_str() );
}
}
示例10: LoadRandomEnchantmentsTable
void LoadRandomEnchantmentsTable()
{
RandomItemEnch.clear(); // for reload case
EnchantmentStore::const_iterator tab;
uint32 entry, ench;
float chance;
uint32 count = 0;
QueryResult_AutoPtr result = WorldDatabase.Query("SELECT entry, ench, chance FROM item_enchantment_template");
if (result)
{
barGoLink bar(result->GetRowCount());
do
{
Field *fields = result->Fetch();
bar.step();
entry = fields[0].GetUInt32();
ench = fields[1].GetUInt32();
chance = fields[2].GetFloat();
if (chance > 0.000001f && chance <= 100.0f)
RandomItemEnch[entry].push_back(EnchStoreItem(ench, chance));
++count;
} while (result->NextRow());
sLog.outString();
sLog.outString(">> Loaded %u Item Enchantment definitions", count);
}
else
{
sLog.outString();
sLog.outErrorDb(">> Loaded 0 Item Enchantment definitions. DB table `item_enchantment_template` is empty.");
}
}
示例11: LoadFromDB
void PoolHandler::LoadFromDB()
{
QueryResult_AutoPtr result = WorldDatabase.Query("SELECT MAX(entry) FROM pool_template");
if (!result)
{
sLog.outString(">> Table pool_template is empty.");
sLog.outString();
return;
}
else
{
Field *fields = result->Fetch();
max_pool_id = fields[0].GetUInt16();
}
mPoolTemplate.resize(max_pool_id + 1);
result = WorldDatabase.Query("SELECT entry,max_limit FROM pool_template");
if (!result)
{
mPoolTemplate.clear();
sLog.outString(">> Table pool_template is empty:");
sLog.outString();
return;
}
uint32 count = 0;
barGoLink bar(result->GetRowCount());
do
{
++count;
Field *fields = result->Fetch();
bar.step();
uint16 pool_id = fields[0].GetUInt16();
PoolTemplateData& pPoolTemplate = mPoolTemplate[pool_id];
pPoolTemplate.MaxLimit = fields[1].GetUInt32();
} while (result->NextRow());
sLog.outString();
sLog.outString(">> Loaded %u objects pools", count);
// Creatures
sLog.outString();
sLog.outString("Loading Creatures Pooling Data...");
mPoolCreatureGroups.resize(max_pool_id + 1);
mCreatureSearchMap.clear();
// 1 2 3
result = WorldDatabase.Query("SELECT guid, pool_entry, chance FROM pool_creature");
count = 0;
if (!result)
{
barGoLink bar2(1);
bar2.step();
sLog.outString();
sLog.outString(">> Loaded %u creatures in pools", count);
}
else
{
barGoLink bar2(result->GetRowCount());
do
{
Field *fields = result->Fetch();
bar2.step();
uint32 guid = fields[0].GetUInt32();
uint16 pool_id = fields[1].GetUInt16();
float chance = fields[2].GetFloat();
CreatureData const* data = objmgr.GetCreatureData(guid);
if (!data)
{
sLog.outErrorDb("`pool_creature` has a non existing creature spawn (GUID: %u) defined for pool id (%u), skipped.", guid, pool_id);
continue;
}
if (pool_id > max_pool_id)
{
sLog.outErrorDb("`pool_creature` pool id (%i) is out of range compared to max pool id in `pool_template`, skipped.",pool_id);
continue;
}
if (chance < 0 || chance > 100)
{
sLog.outErrorDb("`pool_creature` has an invalid chance (%f) for creature guid (%u) in pool id (%i), skipped.", chance, guid, pool_id);
continue;
}
PoolTemplateData *pPoolTemplate = &mPoolTemplate[pool_id];
++count;
PoolObject plObject = PoolObject(guid, chance);
PoolGroup<Creature>& cregroup = mPoolCreatureGroups[pool_id];
//.........这里部分代码省略.........
示例12: LoadCreatureEventAI_Scripts
// -------------------
void CreatureEventAIMgr::LoadCreatureEventAI_Scripts()
{
//Drop Existing EventAI List
m_CreatureEventAI_Event_Map.clear();
// Gather event data
QueryResult_AutoPtr result = WorldDatabase.Query("SELECT id, creature_id, event_type, event_inverse_phase_mask, event_chance, event_flags, "
"event_param1, event_param2, event_param3, event_param4, "
"action1_type, action1_param1, action1_param2, action1_param3, "
"action2_type, action2_param1, action2_param2, action2_param3, "
"action3_type, action3_param1, action3_param2, action3_param3 "
"FROM creature_ai_scripts");
if (result)
{
barGoLink bar(result->GetRowCount());
uint32 Count = 0;
do
{
bar.step();
Field *fields = result->Fetch();
CreatureEventAI_Event temp;
temp.event_id = EventAI_Type(fields[0].GetUInt32());
uint32 i = temp.event_id;
temp.creature_id = fields[1].GetUInt32();
uint32 creature_id = temp.creature_id;
uint32 e_type = fields[2].GetUInt32();
//Report any errors in event
if (e_type >= EVENT_T_END)
{
sLog.outErrorDb("CreatureEventAI: Event %u has incorrect type (%u), skipping.", i,e_type);
continue;
}
temp.event_type = EventAI_Type(e_type);
temp.event_inverse_phase_mask = fields[3].GetUInt32();
temp.event_chance = fields[4].GetUInt8();
temp.event_flags = fields[5].GetUInt8();
temp.raw.param1 = fields[6].GetUInt32();
temp.raw.param2 = fields[7].GetUInt32();
temp.raw.param3 = fields[8].GetUInt32();
temp.raw.param4 = fields[9].GetUInt32();
//Creature does not exist in database
if (!sCreatureStorage.LookupEntry<CreatureInfo>(temp.creature_id))
{
sLog.outErrorDb("CreatureEventAI: Event %u has script for invalid creature entry (%u), skipping.", i, temp.creature_id);
continue;
}
//No chance of this event occuring
if (temp.event_chance == 0)
sLog.outErrorDb("CreatureEventAI: Event %u has 0 percent chance. Event will never trigger!", i);
//Chance above 100, force it to be 100
else if (temp.event_chance > 100)
{
sLog.outErrorDb("CreatureEventAI: Creature %u is using event %u with more than 100 percent chance. Adjusting to 100 percent.", temp.creature_id, i);
temp.event_chance = 100;
}
//Individual event checks
switch (temp.event_type)
{
case EVENT_T_TIMER:
case EVENT_T_TIMER_OOC:
if (temp.timer.initialMax < temp.timer.initialMin)
sLog.outErrorDb("CreatureEventAI: Creature %u is using timed event(%u) with param2 < param1 (InitialMax < InitialMin). Event will never repeat.", temp.creature_id, i);
if (temp.timer.repeatMax < temp.timer.repeatMin)
sLog.outErrorDb("CreatureEventAI: Creature %u is using repeatable event(%u) with param4 < param3 (RepeatMax < RepeatMin). Event will never repeat.", temp.creature_id, i);
break;
case EVENT_T_HP:
case EVENT_T_MANA:
case EVENT_T_TARGET_HP:
case EVENT_T_TARGET_MANA:
if (temp.percent_range.percentMax > 100)
sLog.outErrorDb("CreatureEventAI: Creature %u is using percentage event(%u) with param2 (MinPercent) > 100. Event will never trigger! ", temp.creature_id, i);
if (temp.percent_range.percentMax <= temp.percent_range.percentMin)
sLog.outErrorDb("CreatureEventAI: Creature %u is using percentage event(%u) with param1 <= param2 (MaxPercent <= MinPercent). Event will never trigger! ", temp.creature_id, i);
if (temp.event_flags & EFLAG_REPEATABLE && !temp.percent_range.repeatMin && !temp.percent_range.repeatMax)
{
sLog.outErrorDb("CreatureEventAI: Creature %u has param3 and param4=0 (RepeatMin/RepeatMax) but cannot be repeatable without timers. Removing EFLAG_REPEATABLE for event %u.", temp.creature_id, i);
temp.event_flags &= ~EFLAG_REPEATABLE;
}
break;
case EVENT_T_SPELLHIT:
if (temp.spell_hit.spellId)
{
SpellEntry const* pSpell = sSpellStore.LookupEntry(temp.spell_hit.spellId);
if (!pSpell)
{
sLog.outErrorDb("CreatureEventAI: Creature %u has non-existant SpellID(%u) defined in event %u.", temp.creature_id, temp.spell_hit.spellId, i);
continue;
}
//.........这里部分代码省略.........
示例13: LoadNpcTele
void LoadNpcTele(void)
{
const char *Table[] =
{
"custom_npc_tele_category",
"custom_npc_tele_destination",
"custom_npc_tele_association",
};
QueryResult_AutoPtr result = WorldDatabase.PQuery(
"SELECT `flag`, `data0`, `data1`, `cat_id`, C.`name` `namecat`, D.`name` `namedest`, "
// 0 1 2 3 4 5
"`pos_X`, `pos_Y`, `pos_Z`, `orientation`, `map`, `level`, `cost` "
// 6 7 8 9 10 11 12
"FROM `%s` C, `%s` D, `%s` A "
"WHERE C.`id` = `cat_id` AND D.`id` = `dest_id` "
"ORDER BY `namecat`, `cat_id`, `namedest`", Table[0], Table[1], Table[2]);
nsNpcTel::TabCatDest.clear();
if (result)
{
outstring_log("TSCR: Loading %s, %s and %s...", Table[0], Table[1], Table[2]);
barGoLink bar(result->GetRowCount());
uint32 catid = 0;
uint32 nbDest = 0;
bool IsValidCat = true;
bool FirstTime = true;
do
{
bar.step();
Field *fields = result->Fetch();
if (!IsValidCat && catid == fields[3].GetUInt32() && !FirstTime)
continue;
IsValidCat = true;
FirstTime = false;
if (!nsNpcTel::IsValidData(fields[3].GetUInt32(), (nsNpcTel::Flag)fields[0].GetUInt8(),
fields[1].GetUInt64(), fields[2].GetUInt32()))
{
IsValidCat = false;
catid = fields[3].GetUInt32();
continue;
}
if (catid != fields[3].GetUInt32())
{
catid = fields[3].GetUInt32();
nsNpcTel::CatDest categorie (catid, fields[4].GetCppString(), (nsNpcTel::Flag)fields[0].GetUInt8(),
fields[1].GetUInt64(), fields[2].GetUInt32());
nsNpcTel::TabCatDest.push_back(categorie);
}
nsNpcTel::Dest item =
{
fields[5].GetCppString(), // Name
fields[6].GetFloat(), // X
fields[7].GetFloat(), // Y
fields[8].GetFloat(), // Z
fields[9].GetFloat(), // Orientation
fields[10].GetUInt16(), // Map
fields[11].GetUInt8(), // Level
fields[12].GetUInt32(), // Cost
};
nsNpcTel::TabCatDest.back().AddDest(item);
++nbDest;
} while (result->NextRow());
outstring_log("");
outstring_log("TSCR: >> Loaded %u npc_teleport.", nbDest);
} else outstring_log("TSCR: WARNING >> Loaded 0 npc_teleport.");
}
示例14: HandleTurnInPetitionOpcode
void WorldSession::HandleTurnInPetitionOpcode(WorldPacket & recv_data)
{
sLog.outDebug("Received opcode CMSG_TURN_IN_PETITION");
WorldPacket data;
uint64 petitionguid;
uint32 ownerguidlo;
uint32 type;
std::string name;
recv_data >> petitionguid;
sLog.outDebug("Petition %u turned in by %u", GUID_LOPART(petitionguid), _player->GetGUIDLow());
// data
QueryResult_AutoPtr result = CharacterDatabase.PQuery("SELECT ownerguid, name, type FROM petition WHERE petitionguid = '%u'", GUID_LOPART(petitionguid));
if (result)
{
Field *fields = result->Fetch();
ownerguidlo = fields[0].GetUInt32();
name = fields[1].GetCppString();
type = fields[2].GetUInt32();
}
else
{
sLog.outError("petition table has broken data!");
return;
}
if (type == 9)
{
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;
}
}
else
{
uint8 slot = ArenaTeam::GetSlotByType(type);
if (slot >= MAX_ARENA_SLOT)
return;
if (_player->GetArenaTeamId(slot))
{
//data.Initialize(SMSG_TURN_IN_PETITION_RESULTS, 4);
//data << (uint32)PETITION_TURN_ALREADY_IN_GUILD; // already in guild
//_player->GetSession()->SendPacket(&data);
SendArenaTeamCommandResult(ERR_ARENA_TEAM_CREATE_S, name, "", ERR_ALREADY_IN_ARENA_TEAM);
return;
}
}
if (_player->GetGUIDLow() != ownerguidlo)
return;
// signs
uint8 signs;
result = CharacterDatabase.PQuery("SELECT playerguid FROM petition_sign WHERE petitionguid = '%u'", GUID_LOPART(petitionguid));
if (result)
signs = result->GetRowCount();
else
signs = 0;
uint32 count;
//if (signs < sWorld.getConfig(CONFIG_MIN_PETITION_SIGNS))
if (type == 9)
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);
//.........这里部分代码省略.........
示例15: LoadSkillDiscoveryTable
void LoadSkillDiscoveryTable()
{
SkillDiscoveryStore.clear(); // need for reload
uint32 count = 0;
// 0 1 2 3
QueryResult_AutoPtr result = WorldDatabase.Query("SELECT spellId, reqSpell, reqSkillValue, chance FROM skill_discovery_template");
if (!result)
{
sLog.outString();
sLog.outString( ">> Loaded 0 skill discovery definitions. DB table `skill_discovery_template` is empty." );
return;
}
barGoLink bar(result->GetRowCount());
std::ostringstream ssNonDiscoverableEntries;
std::set<uint32> reportedReqSpells;
do
{
Field *fields = result->Fetch();
bar.step();
uint32 spellId = fields[0].GetUInt32();
int32 reqSkillOrSpell = fields[1].GetInt32();
uint32 reqSkillValue = fields[2].GetInt32();
float chance = fields[3].GetFloat();
if (chance <= 0) // chance
{
ssNonDiscoverableEntries << "spellId = " << spellId << " reqSkillOrSpell = " << reqSkillOrSpell
<< " reqSkillValue = " << reqSkillValue << " chance = " << chance << "(chance problem)\n";
continue;
}
if (reqSkillOrSpell > 0) // spell case
{
SpellEntry const* reqSpellEntry = sSpellStore.LookupEntry(reqSkillOrSpell);
if (!reqSpellEntry)
{
if (reportedReqSpells.find(reqSkillOrSpell) == reportedReqSpells.end())
{
sLog.outErrorDb("Spell (ID: %u) have not existed spell (ID: %i) in `reqSpell` field in `skill_discovery_template` table",spellId,reqSkillOrSpell);
reportedReqSpells.insert(reqSkillOrSpell);
}
continue;
}
// mechanic discovery
if (reqSpellEntry->Mechanic != MECHANIC_DISCOVERY &&
// explicit discovery ability
!IsExplicitDiscoverySpell(reqSpellEntry))
{
if (reportedReqSpells.find(reqSkillOrSpell) == reportedReqSpells.end())
{
sLog.outErrorDb("Spell (ID: %u) not have MECHANIC_DISCOVERY (28) value in Mechanic field in spell.dbc"
" and not 100%% chance random discovery ability but listed for spellId %u (and maybe more) in `skill_discovery_template` table",
reqSkillOrSpell,spellId);
reportedReqSpells.insert(reqSkillOrSpell);
}
continue;
}
SkillDiscoveryStore[reqSkillOrSpell].push_back( SkillDiscoveryEntry(spellId, reqSkillValue, chance) );
}
else if (reqSkillOrSpell == 0) // skill case
{
SkillLineAbilityMapBounds bounds = spellmgr.GetSkillLineAbilityMapBounds(spellId);
if (bounds.first==bounds.second)
{
sLog.outErrorDb("Spell (ID: %u) not listed in `SkillLineAbility.dbc` but listed with `reqSpell`=0 in `skill_discovery_template` table",spellId);
continue;
}
for (SkillLineAbilityMap::const_iterator _spell_idx = bounds.first; _spell_idx != bounds.second; ++_spell_idx)
SkillDiscoveryStore[-int32(_spell_idx->second->skillId)].push_back( SkillDiscoveryEntry(spellId, reqSkillValue, chance) );
}
else
{
sLog.outErrorDb("Spell (ID: %u) have negative value in `reqSpell` field in `skill_discovery_template` table",spellId);
continue;
}
++count;
} while (result->NextRow());
sLog.outString();
sLog.outString( ">> Loaded %u skill discovery definitions", count );
if (!ssNonDiscoverableEntries.str().empty())
sLog.outErrorDb("Some items can't be successfully discovered: have in chance field value < 0.000001 in `skill_discovery_template` DB table . List:\n%s",ssNonDiscoverableEntries.str().c_str());
// report about empty data for explicit discovery spells
for (uint32 spell_id = 1; spell_id < sSpellStore.GetNumRows(); ++spell_id)
{
SpellEntry const* spellEntry = sSpellStore.LookupEntry(spell_id);
//.........这里部分代码省略.........