本文整理汇总了C++中QueryResult::GetRowCount方法的典型用法代码示例。如果您正苦于以下问题:C++ QueryResult::GetRowCount方法的具体用法?C++ QueryResult::GetRowCount怎么用?C++ QueryResult::GetRowCount使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QueryResult
的用法示例。
在下文中一共展示了QueryResult::GetRowCount方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: LoadRewardLocales
void AchievementGlobalMgr::LoadRewardLocales()
{
m_achievementRewardLocales.clear(); // need for reload case
QueryResult *result = WorldDatabase.Query("SELECT entry,subject_loc1,text_loc1,subject_loc2,text_loc2,subject_loc3,text_loc3,subject_loc4,text_loc4,subject_loc5,text_loc5,subject_loc6,text_loc6,subject_loc7,text_loc7,subject_loc8,text_loc8 FROM locales_achievement_reward");
if(!result)
{
barGoLink bar(1);
bar.step();
sLog.outString("");
sLog.outString(">> Loaded 0 achievement reward locale strings. DB table `locales_achievement_reward` is empty.");
return;
}
barGoLink bar(result->GetRowCount());
do
{
Field *fields = result->Fetch();
bar.step();
uint32 entry = fields[0].GetUInt32();
if(m_achievementRewards.find(entry)==m_achievementRewards.end())
{
sLog.outErrorDb( "Table `locales_achievement_reward` (Entry: %u) has locale strings for not existed achievement reward .", entry);
continue;
}
AchievementRewardLocale& data = m_achievementRewardLocales[entry];
for(int i = 1; i < MAX_LOCALE; ++i)
{
std::string str = fields[1+2*(i-1)].GetCppString();
if(!str.empty())
{
int idx = objmgr.GetOrNewIndexForLocale(LocaleConstant(i));
if(idx >= 0)
{
if(data.subject.size() <= idx)
data.subject.resize(idx+1);
data.subject[idx] = str;
}
}
str = fields[1+2*(i-1)+1].GetCppString();
if(!str.empty())
{
int idx = objmgr.GetOrNewIndexForLocale(LocaleConstant(i));
if(idx >= 0)
{
if(data.text.size() <= idx)
data.text.resize(idx+1);
data.text[idx] = str;
}
}
}
} while (result->NextRow());
delete result;
sLog.outString();
sLog.outString( ">> Loaded %u achievement reward locale strings", m_achievementRewardLocales.size() );
}
示例2: LoadScriptTexts
void SystemMgr::LoadScriptTexts()
{
outstring_log("SD2: Loading Script Texts...");
LoadMangosStrings(SD2Database, "script_texts", TEXT_SOURCE_TEXT_START, TEXT_SOURCE_TEXT_END);
QueryResult* pResult = SD2Database.PQuery("SELECT entry, sound, type, language, emote FROM script_texts WHERE entry BETWEEN %i AND %i", TEXT_SOURCE_GOSSIP_END, TEXT_SOURCE_TEXT_START);
outstring_log("SD2: Loading Script Texts additional data...");
if (pResult)
{
BarGoLink bar(pResult->GetRowCount());
uint32 uiCount = 0;
do
{
bar.step();
Field* pFields = pResult->Fetch();
StringTextData pTemp;
int32 iId = pFields[0].GetInt32();
pTemp.uiSoundId = pFields[1].GetUInt32();
pTemp.uiType = pFields[2].GetUInt32();
pTemp.uiLanguage = pFields[3].GetUInt32();
pTemp.uiEmote = pFields[4].GetUInt32();
if (iId >= 0)
{
error_db_log("SD2: Entry %i in table `script_texts` is not a negative value.", iId);
continue;
}
if (pTemp.uiSoundId)
{
if (!GetSoundEntriesStore()->LookupEntry(pTemp.uiSoundId))
error_db_log("SD2: Entry %i in table `script_texts` has soundId %u but sound does not exist.", iId, pTemp.uiSoundId);
}
if (!GetLanguageDescByID(pTemp.uiLanguage))
error_db_log("SD2: Entry %i in table `script_texts` using Language %u but Language does not exist.", iId, pTemp.uiLanguage);
if (pTemp.uiType > CHAT_TYPE_ZONE_YELL)
error_db_log("SD2: Entry %i in table `script_texts` has Type %u but this Chat Type does not exist.", iId, pTemp.uiType);
m_mTextDataMap[iId] = pTemp;
++uiCount;
}
while (pResult->NextRow());
delete pResult;
// outstring_log("");
outstring_log(">> Loaded %u additional Script Texts data.", uiCount);
}
else
{
BarGoLink bar(1);
bar.step();
// outstring_log("");
outstring_log(">> Loaded 0 additional Script Texts data. DB table `script_texts` is empty.");
}
}
示例3: HandleTurnInPetitionOpcode
void WorldSession::HandleTurnInPetitionOpcode(WorldPacket& recv_data)
{
DEBUG_LOG("Received opcode CMSG_TURN_IN_PETITION"); // ok
// recv_data.hexlike();
ObjectGuid petitionGuid;
recv_data >> petitionGuid;
DEBUG_LOG("Petition %s turned in by %s", petitionGuid.GetString().c_str(), _player->GetGuidStr().c_str());
/// Collect petition info data
ObjectGuid ownerGuid;
uint32 type;
std::string name;
// data
QueryResult* result = CharacterDatabase.PQuery("SELECT ownerguid, name, type FROM petition WHERE petitionguid = '%u'", petitionGuid.GetCounter());
if (result)
{
Field* fields = result->Fetch();
ownerGuid = ObjectGuid(HIGHGUID_PLAYER, fields[0].GetUInt32());
name = fields[1].GetCppString();
type = fields[2].GetUInt32();
delete result;
}
else
{
sLog.outError("CMSG_TURN_IN_PETITION: petition table not have data for guid %u!", petitionGuid.GetCounter());
return;
}
if (type == 9)
{
if (_player->GetGuildId())
{
WorldPacket data(SMSG_TURN_IN_PETITION_RESULTS, 4);
data << uint32(PETITION_TURN_ALREADY_IN_GUILD); // already in guild
_player->GetSession()->SendPacket(data);
return;
}
}
else
{
if (!IsArenaTypeValid(ArenaType(type)))
return;
uint8 slot = ArenaTeam::GetSlotByType(ArenaType(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->GetObjectGuid() != ownerGuid)
return;
// signs
result = CharacterDatabase.PQuery("SELECT playerguid FROM petition_sign WHERE petitionguid = '%u'", petitionGuid.GetCounter());
uint8 signs = result ? (uint8)result->GetRowCount() : 0;
uint32 count = type == 9 ? sWorld.getConfig(CONFIG_UINT32_MIN_PETITION_SIGNS) : type - 1;
if (signs < count)
{
WorldPacket data(SMSG_TURN_IN_PETITION_RESULTS, 4);
data << uint32(PETITION_TURN_NEED_MORE_SIGNATURES); // need more signatures...
SendPacket(data);
delete result;
return;
}
if (type == 9)
{
if (sGuildMgr.GetGuildByName(name))
{
SendGuildCommandResult(GUILD_CREATE_S, name, ERR_GUILD_NAME_EXISTS_S);
delete result;
return;
}
}
else
{
if (sObjectMgr.GetArenaTeamByName(name))
{
SendArenaTeamCommandResult(ERR_ARENA_TEAM_CREATE_S, name, "", ERR_ARENA_TEAM_NAME_EXISTS_S);
delete result;
return;
}
}
// and at last charter item check
Item* item = _player->GetItemByGuid(petitionGuid);
if (!item)
//.........这里部分代码省略.........
示例4: LoadSkillDiscoveryTable
void LoadSkillDiscoveryTable()
{
SkillDiscoveryStore.clear(); // need for reload
uint32 count = 0;
// 0 1 2 3
QueryResult *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((int)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 = sSpellMgr.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());
delete result;
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)
//.........这里部分代码省略.........
示例5: LoadTransports
void MapManager::LoadTransports()
{
QueryResult* result = WorldDatabase.Query("SELECT entry, name, period FROM transports");
uint32 count = 0;
if (!result)
{
BarGoLink bar(1);
bar.step();
sLog.outString();
sLog.outString(">> Loaded %u transports", count);
return;
}
BarGoLink bar(result->GetRowCount());
do
{
bar.step();
Transport* t = new Transport;
Field* fields = result->Fetch();
uint32 entry = fields[0].GetUInt32();
std::string name = fields[1].GetCppString();
t->m_period = fields[2].GetUInt32();
const GameObjectInfo* goinfo = ObjectMgr::GetGameObjectInfo(entry);
if (!goinfo)
{
sLog.outErrorDb("Transport ID:%u, Name: %s, will not be loaded, gameobject_template missing", entry, name.c_str());
delete t;
continue;
}
if (goinfo->type != GAMEOBJECT_TYPE_MO_TRANSPORT)
{
sLog.outErrorDb("Transport ID:%u, Name: %s, will not be loaded, gameobject_template type wrong", entry, name.c_str());
delete t;
continue;
}
// sLog.outString("Loading transport %d between %s, %s", entry, name.c_str(), goinfo->name);
std::set<uint32> mapsUsed;
if (!t->GenerateWaypoints(goinfo->moTransport.taxiPathId, mapsUsed))
// skip transports with empty waypoints list
{
sLog.outErrorDb("Transport (path id %u) path size = 0. Transport ignored, check DBC files or transport GO data0 field.", goinfo->moTransport.taxiPathId);
delete t;
continue;
}
float x, y, z, o;
uint32 mapid;
x = t->m_WayPoints[0].x; y = t->m_WayPoints[0].y; z = t->m_WayPoints[0].z; mapid = t->m_WayPoints[0].mapid; o = 1;
// current code does not support transports in dungeon!
const MapEntry* pMapInfo = sMapStore.LookupEntry(mapid);
if (!pMapInfo || pMapInfo->Instanceable())
{
delete t;
continue;
}
// creates the Gameobject
if (!t->Create(entry, mapid, x, y, z, o, GO_ANIMPROGRESS_DEFAULT))
{
delete t;
continue;
}
m_Transports.insert(t);
for (std::set<uint32>::const_iterator i = mapsUsed.begin(); i != mapsUsed.end(); ++i)
m_TransportsByMap[*i].insert(t);
// If we someday decide to use the grid to track transports, here:
t->SetMap(sMapMgr.CreateMap(mapid, t));
// t->GetMap()->Add<GameObject>((GameObject *)t);
++count;
}
while (result->NextRow());
delete result;
sLog.outString();
sLog.outString(">> Loaded %u transports", count);
// check transport data DB integrity
result = WorldDatabase.Query("SELECT gameobject.guid,gameobject.id,transports.name FROM gameobject,transports WHERE gameobject.id = transports.entry");
if (result) // wrong data found
{
do
{
//.........这里部分代码省略.........
示例6: LoadFromDB
void GameEventMgr::LoadFromDB()
{
{
QueryResult *result = WorldDatabase.Query("SELECT MAX(entry) FROM game_event");
if( !result )
{
sLog.outString(">> Table game_event is empty.");
sLog.outString();
return;
}
Field *fields = result->Fetch();
uint32 max_event_id = fields[0].GetUInt16();
delete result;
mGameEvent.resize(max_event_id+1);
}
QueryResult *result = WorldDatabase.Query("SELECT entry,UNIX_TIMESTAMP(start_time),UNIX_TIMESTAMP(end_time),occurence,length,holiday,description FROM game_event");
if (!result)
{
mGameEvent.clear();
sLog.outString(">> Table game_event is empty!");
sLog.outString();
return;
}
uint32 count = 0;
{
BarGoLink bar(result->GetRowCount());
do
{
++count;
Field *fields = result->Fetch();
bar.step();
uint16 event_id = fields[0].GetUInt16();
if (event_id == 0)
{
sLog.outErrorDb("`game_event` game event id (%i) is reserved and can't be used.",event_id);
continue;
}
GameEventData& pGameEvent = mGameEvent[event_id];
uint64 starttime = fields[1].GetUInt64();
pGameEvent.start = time_t(starttime);
uint64 endtime = fields[2].GetUInt64();
pGameEvent.end = time_t(endtime);
pGameEvent.occurence = fields[3].GetUInt32();
pGameEvent.length = fields[4].GetUInt32();
pGameEvent.holiday_id = HolidayIds(fields[5].GetUInt32());
if(pGameEvent.length==0) // length>0 is validity check
{
sLog.outErrorDb("`game_event` game event id (%i) have length 0 and can't be used.",event_id);
continue;
}
if(pGameEvent.holiday_id != HOLIDAY_NONE)
{
if(!sHolidaysStore.LookupEntry(pGameEvent.holiday_id))
{
sLog.outErrorDb("`game_event` game event id (%i) have nonexistent holiday id %u.",event_id,pGameEvent.holiday_id);
pGameEvent.holiday_id = HOLIDAY_NONE;
}
}
pGameEvent.description = fields[6].GetCppString();
} while( result->NextRow() );
delete result;
sLog.outString();
sLog.outString( ">> Loaded %u game events", count );
}
std::map<uint16,int16> pool2event; // for check unique spawn event associated with pool
std::map<uint32,int16> creature2event; // for check unique spawn event associated with creature
std::map<uint32,int16> go2event; // for check unique spawn event associated with gameobject
// list only positive event top pools, filled at creature/gameobject loading
mGameEventSpawnPoolIds.resize(mGameEvent.size());
mGameEventCreatureGuids.resize(mGameEvent.size()*2-1);
// 1 2
result = WorldDatabase.Query("SELECT creature.guid, game_event_creature.event "
"FROM creature JOIN game_event_creature ON creature.guid = game_event_creature.guid");
count = 0;
if (!result)
{
BarGoLink bar(1);
bar.step();
sLog.outString();
sLog.outString(">> Loaded %u creatures in game events", count );
//.........这里部分代码省略.........
示例7: LoadCreatureRespawnTimes
void MapPersistentStateManager::LoadCreatureRespawnTimes()
{
// remove outdated data
CharacterDatabase.DirectExecute("DELETE FROM creature_respawn WHERE respawntime <= UNIX_TIMESTAMP(NOW())");
uint32 count = 0;
// 0 1 2 3 4 5 6
QueryResult* result = CharacterDatabase.Query("SELECT guid, respawntime, map, instance, difficulty, resettime, encountersMask FROM creature_respawn LEFT JOIN instance ON instance = id");
if (!result)
{
BarGoLink bar(1);
bar.step();
sLog.outString();
sLog.outString(">> Loaded 0 creature respawn time.");
return;
}
BarGoLink bar(result->GetRowCount());
do
{
Field* fields = result->Fetch();
bar.step();
uint32 loguid = fields[0].GetUInt32();
uint64 respawn_time = fields[1].GetUInt64();
uint32 mapId = fields[2].GetUInt32();
uint32 instanceId = fields[3].GetUInt32();
uint8 difficulty = fields[4].GetUInt8();
time_t resetTime = (time_t)fields[5].GetUInt64();
uint32 completedEncounters = fields[6].GetUInt32();
CreatureData const* data = sObjectMgr.GetCreatureData(loguid);
if (!data)
continue;
if (mapId != data->mapid)
continue;
MapEntry const* mapEntry = sMapStore.LookupEntry(mapId);
if (!mapEntry || (mapEntry->Instanceable() != (instanceId != 0)))
continue;
if (difficulty >= (!mapEntry->Instanceable() ? REGULAR_DIFFICULTY : (mapEntry->IsRaid() ? MAX_RAID_DIFFICULTY : MAX_DUNGEON_DIFFICULTY)))
continue;
MapPersistentState* state = AddPersistentState(mapEntry, instanceId, Difficulty(difficulty), resetTime, mapEntry->IsDungeon(), true, true, completedEncounters);
if (!state)
continue;
state->SetCreatureRespawnTime(loguid, time_t(respawn_time));
++count;
}
while (result->NextRow());
delete result;
sLog.outString(">> Loaded %u creature respawn times", count);
sLog.outString();
}
示例8: LoadConfig
bool IRCClient::LoadConfig()
{
if (!MCConfig.SetSource(CfgFile))
sLog.outString("MangChat: Unable to open configuration file (%s), All default options are being used.", CfgFile);
else
sLog.outString("MangChat: Found the configuration file, %s", CfgFile);
int ConfCnt = 0;
sIRC._chan_count = 0;
if (MCConfig.GetIntDefault("irc.active", 0))
sIRC.Active = true;
else
sIRC.Active = false;
sIRC._Host = MCConfig.GetStringDefault("irc.host", "irc.freenode.net");
if (sIRC._Host.size() > 0)
ConfCnt++;
sIRC._Mver = MCConfig.GetStringDefault("irc.mver", "Version 1.8.1");
sIRC._Port = MCConfig.GetIntDefault("irc.port", 6667);
sIRC._User = MCConfig.GetStringDefault("irc.user", "MangChat");
sIRC._Pass = MCConfig.GetStringDefault("irc.pass", "MyDumbPass");
sIRC._Nick = MCConfig.GetStringDefault("irc.nick", "MangChat");
sIRC._Auth = MCConfig.GetIntDefault("irc.auth", 0);
sIRC._Auth_Nick = MCConfig.GetStringDefault("irc.auth.nick", "AuthNick");
sIRC._ICC = MCConfig.GetStringDefault("irc.icc", "001");
sIRC._defchan = MCConfig.GetStringDefault("irc.defchan", "lobby");
sIRC._ldefc = MCConfig.GetIntDefault("irc.ldef", 0);
sIRC._wct = MCConfig.GetIntDefault("irc.wct", 30000);
sIRC.ajoin = MCConfig.GetIntDefault("irc.ajoin", 1);
sIRC.ajchan = MCConfig.GetStringDefault("irc.ajchan", "world");
sIRC.onlrslt = MCConfig.GetIntDefault("irc.online.result", 10);
sIRC.BOTMASK = MCConfig.GetIntDefault("Botmask", 0);
sIRC.logfile = MCConfig.GetStringDefault("irc.logfile.prefix", "IRC_");
for (int i = 1; i < MAX_CONF_CHANNELS;i++)
{
std::ostringstream ss;
ss << i;
std::string ci = "irc.chan_" + ss.str();
std::string t_chan = MCConfig.GetStringDefault(ci.c_str(), "");
if (t_chan.size() > 0)
{
sIRC._chan_count++;
sIRC._irc_chan[sIRC._chan_count] = t_chan;
ci = "wow.chan_" + ss.str();
sIRC._wow_chan[sIRC._chan_count] = MCConfig.GetStringDefault(ci.c_str(), t_chan.c_str());
}
}
sIRC.JoinMsg = MCConfig.GetStringDefault("irc.joinmsg", "Whhaaazzzzaaaa, MangChat $Ver Baby!!");
sIRC.RstMsg = MCConfig.GetStringDefault("irc.rstmsg", "MangChat Is Restarting, I Will Be Right Back!");
sIRC.kikmsg = MCConfig.GetStringDefault("irc.kickmsg", "Do Not Kick Me Again, Severe Actions Will Be Taken!");
// IRC LINES
sIRC.ILINES[WOW_IRC] = MCConfig.GetStringDefault("chat.wow_irc", "\003<WoW>[\002$Name($Level)\002\003] $Msg");
sIRC.ILINES[IRC_WOW] = MCConfig.GetStringDefault("chat.irc_wow", "\003<IRC>[$Name]: $Msg");
sIRC.ILINES[JOIN_WOW] = MCConfig.GetStringDefault("chat.join_wow", "\00312>>\00304 $Name \003Joined The Channel!");
sIRC.ILINES[JOIN_IRC] = MCConfig.GetStringDefault("chat.join_irc", "\003[$Name]: Has Joined IRC!");
sIRC.ILINES[LEAVE_WOW] = MCConfig.GetStringDefault("chat.leave_wow", "\00312<<\00304 $Name \003Left The Channel!");
sIRC.ILINES[LEAVE_IRC] = MCConfig.GetStringDefault("chat.leave_irc", "\003[$Name]: Has Left IRC!");
sIRC.ILINES[CHANGE_NICK] = MCConfig.GetStringDefault("chat.change_nick", "\003<> $Name Is Now Known As $NewName!");
// MangChat Options
sIRC._MCA = MCConfig.GetIntDefault("irc.maxattempt", 10);
sIRC._autojoinkick = MCConfig.GetIntDefault("irc.autojoin_kick", 1);
sIRC._cmd_prefx = MCConfig.GetStringDefault("irc.command_prefix", ".");
sIRC._op_gm = MCConfig.GetIntDefault("irc.op_gm_login", 0);
sIRC._op_gm_lev = MCConfig.GetIntDefault("irc.op_gm_level", 3);
// Misc Options
sIRC.games = MCConfig.GetIntDefault("irc.fun.games", 0);
sIRC.gmlog = MCConfig.GetIntDefault("irc.gmlog", 1);
sIRC.BOTMASK = MCConfig.GetIntDefault("BotMask", 0);
sIRC.Status = MCConfig.GetIntDefault("irc.StatusChannel", 1);
sIRC.anchn = MCConfig.GetIntDefault("irc.AnnounceChannel", 1);
sIRC.autoanc = MCConfig.GetIntDefault("irc.auto.announce", 30);
for (uint16 i = 0; i<SEC_ADMINISTRATOR; i++)
{
std::stringstream ircKeyWord, defaultEntry;
ircKeyWord << "irc.gm" << i;
if (!i)
defaultEntry << "";
else
defaultEntry << "[GM" << i << "]";
sIRC.ojGM[i] = MCConfig.GetStringDefault(ircKeyWord.str().c_str(), defaultEntry.str().c_str());
}
// REQUIRED GM LEVEL
QueryResult *result = WorldDatabase.PQuery("SELECT `Command`, `gmlevel` FROM `IRC_Commands` ORDER BY `Command`");
if (result)
{
Field *fields = result->Fetch();
for (uint64 i=0; i < result->GetRowCount(); i++)
{
std::string command = fields[0].GetCppString();
uint32 gmlvl = fields[1].GetUInt32();
if (command == "acct") sIRC.CACCT = gmlvl;
if (command == "ban") sIRC.CBAN = gmlvl;
if (command == "char") sIRC.CCHAN = gmlvl;
if (command == "char") sIRC.CCHAR = gmlvl;
//.........这里部分代码省略.........
示例9: LoadFromDB
void PoolManager::LoadFromDB()
{
QueryResult *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();
delete result;
}
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 );
delete result;
// Creatures
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];
cregroup.AddEntry(plObject, pPoolTemplate->MaxLimit);
//.........这里部分代码省略.........
示例10: LoadWeatherZoneChances
/// Load Weather chanced from table game_weather
void WeatherMgr::LoadWeatherZoneChances()
{
uint32 count = 0;
// 0 1 2 3 4 5 6 7 8 9 10 11 12
QueryResult* result = WorldDatabase.Query("SELECT zone, spring_rain_chance, spring_snow_chance, spring_storm_chance, summer_rain_chance, summer_snow_chance, summer_storm_chance, fall_rain_chance, fall_snow_chance, fall_storm_chance, winter_rain_chance, winter_snow_chance, winter_storm_chance FROM game_weather");
if (!result)
{
BarGoLink bar(1);
bar.step();
sLog.outErrorDb(">> Loaded 0 weather definitions. DB table `game_weather` is empty.");
sLog.outString();
return;
}
BarGoLink bar(result->GetRowCount());
do
{
Field* fields = result->Fetch();
bar.step();
uint32 zone_id = fields[0].GetUInt32();
WeatherZoneChances& wzc = mWeatherZoneMap[zone_id];
for (int season = 0; season < WEATHER_SEASONS; ++season)
{
wzc.data[season].rainChance = fields[season * (MAX_WEATHER_TYPE - 1) + 1].GetUInt32();
wzc.data[season].snowChance = fields[season * (MAX_WEATHER_TYPE - 1) + 2].GetUInt32();
wzc.data[season].stormChance = fields[season * (MAX_WEATHER_TYPE - 1) + 3].GetUInt32();
if (wzc.data[season].rainChance > 100)
{
wzc.data[season].rainChance = 25;
sLog.outErrorDb("Weather for zone %u season %u has wrong rain chance > 100%%", zone_id, season);
}
if (wzc.data[season].snowChance > 100)
{
wzc.data[season].snowChance = 25;
sLog.outErrorDb("Weather for zone %u season %u has wrong snow chance > 100%%", zone_id, season);
}
if (wzc.data[season].stormChance > 100)
{
wzc.data[season].stormChance = 25;
sLog.outErrorDb("Weather for zone %u season %u has wrong storm chance > 100%%", zone_id, season);
}
}
++count;
}
while (result->NextRow());
delete result;
sLog.outString(">> Loaded %u weather definitions", count);
sLog.outString();
}
示例11: Load
void WaypointManager::Load()
{
Cleanup();
uint32 total_paths = 0;
uint32 total_nodes = 0;
uint32 total_behaviors = 0;
QueryResult *result = WorldDatabase.Query("SELECT id, COUNT(point) FROM creature_movement GROUP BY id");
if(!result)
{
barGoLink bar(1);
bar.step();
sLog.outString();
sLog.outString( ">> Loaded 0 paths. DB table `creature_movement` is empty." );
return;
} else {
total_paths = result->GetRowCount();
barGoLink bar( total_paths );
do
{
bar.step();
Field *fields = result->Fetch();
uint32 id = fields[0].GetUInt32();
uint32 count = fields[1].GetUInt32();
m_pathMap[id].resize(count);
total_nodes += count;
} while( result->NextRow() );
delete result;
sLog.outString();
sLog.outString( ">> Paths loaded" );
}
// 0 1 2 3 4 5
result = WorldDatabase.Query("SELECT position_x, position_y, position_z, orientation, model1, model2,"
// 6 7 8 9 10 11 12 13 14 15
"waittime, emote, spell, textid1, textid2, textid3, textid4, textid5, id, point FROM creature_movement");
barGoLink bar( result->GetRowCount() );
do
{
bar.step();
Field *fields = result->Fetch();
uint32 point = fields[15].GetUInt32();
uint32 id = fields[14].GetUInt32();
if (!sObjectMgr.GetCreatureData(id))
{
sLog.outErrorDb("Table creature_movement references unknown creature %u. Deleted.", id);
WorldDatabase.PExecute("DELETE FROM creature_movement where id=%u",id);
continue;
}
WaypointPath &path = m_pathMap[id];
// the cleanup queries make sure the following is true
ASSERT(point >= 1 && point <= path.size());
WaypointNode &node = path[point-1];
node.x = fields[0].GetFloat();
node.y = fields[1].GetFloat();
node.z = fields[2].GetFloat();
node.orientation = fields[3].GetFloat();
node.delay = fields[6].GetUInt32();
// prevent using invalid coordinates
if(!MaNGOS::IsValidMapCoord(node.x, node.y, node.z, node.orientation))
{
QueryResult *result1 = WorldDatabase.PQuery("SELECT id, map FROM creature WHERE guid = '%u'", id);
if(result1)
sLog.outErrorDb("Creature (guidlow %d, entry %d) have invalid coordinates in his waypoint %d (X: %f, Y: %f).",
id, result1->Fetch()[0].GetUInt32(), point, node.x, node.y);
else
sLog.outErrorDb("Waypoint path %d, have invalid coordinates in his waypoint %d (X: %f, Y: %f).",
id, point, node.x, node.y);
MaNGOS::NormalizeMapCoord(node.x);
MaNGOS::NormalizeMapCoord(node.y);
if(result1)
{
node.z = MapManager::Instance ().CreateBaseMap(result1->Fetch()[1].GetUInt32())->GetHeight(node.x, node.y, node.z);
delete result1;
}
WorldDatabase.PExecute("UPDATE creature_movement SET position_x = '%f', position_y = '%f', position_z = '%f' WHERE id = '%u' AND point = '%u'", node.x, node.y, node.z, id, point);
}
WaypointBehavior be;
be.model1 = fields[4].GetUInt32();
be.model2 = fields[5].GetUInt32();
be.emote = fields[7].GetUInt32();
be.spell = fields[8].GetUInt32();
for(int i = 0; i < MAX_WAYPOINT_TEXT; ++i)
{
be.textid[i] = fields[9+i].GetUInt32();
if(be.textid[i])
{
if (be.textid[i] < MIN_DB_SCRIPT_STRING_ID || be.textid[i] >= MAX_DB_SCRIPT_STRING_ID)
{
sLog.outErrorDb( "Table `db_script_string` not have string id %u", be.textid[i]);
continue;
}
//.........这里部分代码省略.........
示例12: Creature
//-----------------------------------------------//
void
WaypointMovementGenerator<Creature>::LoadPath(Creature &c)
{
QueryResult *result = NULL;
sLog.outDebug("DEBUG: WaypointMovementGenerator::_load: GUID - %d", c.GetGUIDLow());
// Identify by GUID
result = sDatabase.PQuery("SELECT `position_x`, `position_y`, `position_z`, `orientation`, `model1`, `model2`, `waittime`, `emote`, `spell`, `text1`, `text2`, `text3`, `text4`, `text5`, `aiscript` FROM `creature_movement` WHERE `id` = '%u' ORDER BY `point`", c.GetDBTableGUIDLow());
/*
if( result ) {
sLog.outDebug("DEBUG: Number of hits: %d", result->GetRowCount());
} else {
sLog.outDebug("DEBUG: Nothing found");
}
*/
if( result )
{
unsigned int count = 0;
const unsigned int sz = result->GetRowCount();
i_path.Resize( sz );
i_delays.resize( sz );
i_wpBehaviour.resize( sz );
do
{
//sLog.outDebug("DEBUG: _load");
Field *fields = result->Fetch();
i_path[count].x = fields[0].GetFloat();
i_path[count].y = fields[1].GetFloat();
i_path[count].z = fields[2].GetFloat();
float orientation = fields[3].GetFloat();
uint32 model1 = fields[4].GetUInt32();
uint32 model2 = fields[5].GetUInt32();
i_delays[count] = fields[6].GetUInt16();
uint32 emote = fields[7].GetUInt32();
uint32 spell = fields[8].GetUInt32();
std::string text1 = fields[9].GetCppString();
std::string text2 = fields[10].GetCppString();
std::string text3 = fields[11].GetCppString();
std::string text4 = fields[12].GetCppString();
std::string text5 = fields[13].GetCppString();
std::string aiscript = fields[14].GetCppString();
if( (emote != 0) || (spell != 0)
|| (text1 != "") || (text2 != "") || (text3 != "") || (text4 != "") || (text5 != "")
|| (aiscript != "")
|| (model1 != 0) || (model2 != 0) || (orientation != 100))
{
WaypointBehavior *tmpWPB = new WaypointBehavior;
// sLog.outDebug("DEBUG: _load --- Adding WaypointBehavior");
tmpWPB->text[0] = text1;
tmpWPB->text[1] = text2;
tmpWPB->text[2] = text3;
tmpWPB->text[3] = text4;
tmpWPB->text[4] = text5;
tmpWPB->aiscript = aiscript;
tmpWPB->orientation = orientation;
tmpWPB->emote = emote;
tmpWPB->spell = spell;
tmpWPB->model1 = model1;
tmpWPB->model2 = model2;
tmpWPB->HasDone = false;
i_wpBehaviour[count] = tmpWPB;
}
else
{
i_wpBehaviour[count] = NULL;
}
if(!MaNGOS::IsValidMapCoord(i_path[count].x,i_path[count].y))
{
sLog.outErrorDb("ERROR: Creature (guidlow %d,entry %d) have invalid coordinates in his waypoint %d (X: %d, Y: %d).",
c.GetGUIDLow(),c.GetEntry(),count,i_path[count].x,i_path[count].y
);
// prevent invalid coordinates using
MaNGOS::NormalizeMapCoord(i_path[count].x);
MaNGOS::NormalizeMapCoord(i_path[count].y);
i_path[count].z = MapManager::Instance ().GetMap(c.GetMapId(), &c)->GetHeight(i_path[count].x,i_path[count].y, i_path[count].z);
}
// to prevent a misbehaviour inside "update"
// update is alway called with the next wp - but the wpSys needs the current
// so when the routine is called the first time, wpSys gets the last waypoint
// and this prevents the system from performing text/emote, etc
if( count == (sz-1) )
{
if( i_wpBehaviour[count] != NULL )
{
i_wpBehaviour[count]->HasDone = true;
}
}
//if( i_delays[count] < 30 /* millisecond */ )
// i_delays[count] = (rand() % 5000);
++count;
} while( result->NextRow() );
//.........这里部分代码省略.........
示例13: LoadWardenDataResult
void CWardenDataStorage::LoadWardenDataResult()
{
QueryResult *result = LoginDatabase.Query("SELECT `check`, `data`, `result`, `address`, `length`, `str` FROM warden_data_result");
uint32 count = 0;
if (!result)
{
BarGoLink bar(1);
bar.step();
sLog.outString();
sLog.outString(">> Loaded %u warden data and results", count);
return;
}
BarGoLink bar((int)result->GetRowCount());
do
{
++count;
bar.step();
Field *fields = result->Fetch();
uint8 type = fields[0].GetUInt8();
uint32 id = GenerateInternalDataID();
WardenData *wd = new WardenData();
wd->Type = type;
if (type == PAGE_CHECK_A || type == PAGE_CHECK_B || type == DRIVER_CHECK)
{
std::string data = fields[1].GetCppString();
wd->i.SetHexStr(data.c_str());
int len = data.size() / 2;
if (wd->i.GetNumBytes() < len)
{
uint8 temp[24];
memset(temp, 0, len);
memcpy(temp, wd->i.AsByteArray(), wd->i.GetNumBytes());
std::reverse(temp, temp + len);
wd->i.SetBinary((uint8*)temp, len);
}
}
if (type == MEM_CHECK || type == MODULE_CHECK)
MemCheckIds.push_back(id);
if (type == MEM_CHECK || type == PAGE_CHECK_A || type == PAGE_CHECK_B || type == PROC_CHECK)
{
wd->Address = fields[3].GetUInt32();
wd->Length = fields[4].GetUInt8();
}
// PROC_CHECK support missing
if (type == MEM_CHECK || type == MPQ_CHECK || type == LUA_STR_CHECK || type == DRIVER_CHECK || type == MODULE_CHECK)
wd->str = fields[5].GetCppString();
_data_map[id] = wd;
if (type == MPQ_CHECK || type == MEM_CHECK)
{
std::string result = fields[2].GetCppString();
WardenDataResult *wr = new WardenDataResult();
wr->res.SetHexStr(result.c_str());
int len = result.size() / 2;
if (wr->res.GetNumBytes() < len)
{
uint8 *temp = new uint8[len];
memset(temp, 0, len);
memcpy(temp, wr->res.AsByteArray(), wr->res.GetNumBytes());
std::reverse(temp, temp + len);
wr->res.SetBinary((uint8*)temp, len);
delete [] temp;
}
_result_map[id] = wr;
}
} while (result->NextRow());
delete result;
sLog.outString();
sLog.outString(">> Loaded %u warden data and results", count);
}
示例14: LoadRewards
void AchievementGlobalMgr::LoadRewards()
{
m_achievementRewards.clear(); // need for reload case
// 0 1 2 3 4 5 6
QueryResult *result = WorldDatabase.Query("SELECT entry, title_A, title_H, item, sender, subject, text FROM achievement_reward");
if(!result)
{
barGoLink bar(1);
bar.step();
sLog.outString("");
sLog.outErrorDb(">> Loaded 0 achievement rewards. DB table `achievement_reward` is empty.");
return;
}
barGoLink bar(result->GetRowCount());
do
{
bar.step();
Field *fields = result->Fetch();
uint32 entry = fields[0].GetUInt32();
if (!sAchievementStore.LookupEntry(entry))
{
sLog.outErrorDb( "Table `achievement_reward` has wrong achievement (Entry: %u), ignore", entry);
continue;
}
AchievementReward reward;
reward.titleId[0] = fields[1].GetUInt32();
reward.titleId[1] = fields[2].GetUInt32();
reward.itemId = fields[3].GetUInt32();
reward.sender = fields[4].GetUInt32();
reward.subject = fields[5].GetCppString();
reward.text = fields[6].GetCppString();
if ((reward.titleId[0]==0)!=(reward.titleId[1]==0))
sLog.outErrorDb( "Table `achievement_reward` (Entry: %u) has title (A: %u H: %u) only for one from teams.", entry, reward.titleId[0], reward.titleId[1]);
// must be title or mail at least
if (!reward.titleId[0] && !reward.titleId[1] && !reward.sender)
{
sLog.outErrorDb( "Table `achievement_reward` (Entry: %u) not have title or item reward data, ignore.", entry);
continue;
}
if (reward.titleId[0])
{
CharTitlesEntry const* titleEntry = sCharTitlesStore.LookupEntry(reward.titleId[0]);
if (!titleEntry)
{
sLog.outErrorDb( "Table `achievement_reward` (Entry: %u) has invalid title id (%u) in `title_A`, set to 0", entry, reward.titleId[0]);
reward.titleId[0] = 0;
}
}
if (reward.titleId[1])
{
CharTitlesEntry const* titleEntry = sCharTitlesStore.LookupEntry(reward.titleId[1]);
if (!titleEntry)
{
sLog.outErrorDb( "Table `achievement_reward` (Entry: %u) has invalid title id (%u) in `title_A`, set to 0", entry, reward.titleId[1]);
reward.titleId[1] = 0;
}
}
//check mail data before item for report including wrong item case
if (reward.sender)
{
if (!objmgr.GetCreatureTemplate(reward.sender))
{
sLog.outErrorDb( "Table `achievement_reward` (Entry: %u) has invalid creature entry %u as sender, mail reward skipped.", entry, reward.sender);
reward.sender = 0;
}
}
else
{
if (reward.itemId)
sLog.outErrorDb( "Table `achievement_reward` (Entry: %u) not have sender data but have item reward, item will not rewarded", entry);
if (!reward.subject.empty())
sLog.outErrorDb( "Table `achievement_reward` (Entry: %u) not have sender data but have mail subject.", entry);
if (!reward.text.empty())
sLog.outErrorDb( "Table `achievement_reward` (Entry: %u) not have sender data but have mail text.", entry);
}
if (reward.itemId)
{
if (!objmgr.GetItemPrototype(reward.itemId))
{
sLog.outErrorDb( "Table `achievement_reward` (Entry: %u) has invalid item id %u, reward mail will be without item.", entry, reward.itemId);
reward.itemId = 0;
}
}
//.........这里部分代码省略.........
示例15: LoadFromDB
void GameEventMgr::LoadFromDB()
{
{
QueryResult *result = WorldDatabase.Query("SELECT MAX(entry) FROM game_event");
if( !result )
{
sLog.outString(">> Table game_event is empty.");
sLog.outString();
return;
}
Field *fields = result->Fetch();
uint32 max_event_id = fields[0].GetUInt16();
delete result;
mGameEvent.resize(max_event_id+1);
}
QueryResult *result = WorldDatabase.Query("SELECT entry,UNIX_TIMESTAMP(start_time),UNIX_TIMESTAMP(end_time),occurence,length,holiday,description FROM game_event");
if( !result )
{
mGameEvent.clear();
sLog.outString(">> Table game_event is empty!");
sLog.outString();
return;
}
uint32 count = 0;
{
barGoLink bar( result->GetRowCount() );
do
{
++count;
Field *fields = result->Fetch();
bar.step();
uint16 event_id = fields[0].GetUInt16();
if(event_id==0)
{
sLog.outErrorDb("`game_event` game event id (%i) is reserved and can't be used.",event_id);
continue;
}
GameEventData& pGameEvent = mGameEvent[event_id];
uint64 starttime = fields[1].GetUInt64();
pGameEvent.start = time_t(starttime);
uint64 endtime = fields[2].GetUInt64();
pGameEvent.end = time_t(endtime);
pGameEvent.occurence = fields[3].GetUInt32();
pGameEvent.length = fields[4].GetUInt32();
pGameEvent.holiday_id = fields[5].GetUInt32();
if(pGameEvent.length==0) // length>0 is validity check
{
sLog.outErrorDb("`game_event` game event id (%i) have length 0 and can't be used.",event_id);
continue;
}
if(pGameEvent.holiday_id)
{
if(!sHolidaysStore.LookupEntry(pGameEvent.holiday_id))
{
sLog.outErrorDb("`game_event` game event id (%i) have not existed holiday id %u.",event_id,pGameEvent.holiday_id);
pGameEvent.holiday_id = 0;
}
}
pGameEvent.description = fields[6].GetCppString();
} while( result->NextRow() );
delete result;
sLog.outString();
sLog.outString( ">> Loaded %u game events", count );
}
mGameEventCreatureGuids.resize(mGameEvent.size()*2-1);
// 1 2
result = WorldDatabase.Query("SELECT creature.guid, game_event_creature.event "
"FROM creature JOIN game_event_creature ON creature.guid = game_event_creature.guid");
count = 0;
if( !result )
{
barGoLink bar(1);
bar.step();
sLog.outString();
sLog.outString(">> Loaded %u creatures in game events", count );
}
else
{
barGoLink bar( result->GetRowCount() );
do
{
//.........这里部分代码省略.........