T端数据库使用
--------SQL DEMO 01--------
void LFGMgr::LoadRequiredLevels() { uint32 oldMSTime = getMSTime(); m_RequiredIlvlMap.clear(); // ORDER BY is very important for GetRandomDungeonReward! QueryResult result = WorldDatabase.Query("SELECT ID, ItemLevel FROM lfg_required_ilevel ORDER BY ID"); if (!result) { sLog->outError(LOG_FILTER_SERVER_LOADING, ">> Loaded 0 lfg required item levels for instances"); return; } uint32 count = 0; Field* fields = NULL; do { fields = result->Fetch(); uint32 dungeonId = fields[0].GetUInt32(); uint32 itemLevel = fields[1].GetUInt32(); const LFGDungeonEntry* dungeon = sLFGDungeonStore.LookupEntry(dungeonId); if (!sLFGDungeonStore.LookupEntry(dungeonId)) { sLog->outError(LOG_FILTER_SQL, "Dungeon %u specified in table `lfg_required_ilevel` does not exist!", dungeonId); continue; } m_RequiredIlvlMap.insert(LfgRequiredIlvlMap::value_type(dungeonId, itemLevel)); ++count; } while (result->NextRow()); sLog->outInfo(LOG_FILTER_SERVER_LOADING, ">> Loaded %u lfg required itemlevels in %u ms", count, GetMSTimeDiffToNow(oldMSTime)); }
------SQL DEMO 02------
void LFGMgr::LoadRequiredLevels() { uint32 oldMSTime = getMSTime(); m_RequiredIlvlMap.clear(); // ORDER BY is very important for GetRandomDungeonReward! QueryResult result = WorldDatabase.Query("SELECT ID, ItemLevel FROM lfg_required_ilevel ORDER BY ID"); if (!result) { sLog->outError(LOG_FILTER_SERVER_LOADING, ">> Loaded 0 lfg required item levels for instances"); return; } uint32 count = 0; Field* fields = NULL; do { fields = result->Fetch(); uint32 dungeonId = fields[0].GetUInt32(); uint32 itemLevel = fields[1].GetUInt32(); const LFGDungeonEntry* dungeon = sLFGDungeonStore.LookupEntry(dungeonId); if (!sLFGDungeonStore.LookupEntry(dungeonId)) { sLog->outError(LOG_FILTER_SQL, "Dungeon %u specified in table `lfg_required_ilevel` does not exist!", dungeonId); continue; } m_RequiredIlvlMap.insert(LfgRequiredIlvlMap::value_type(dungeonId, itemLevel)); ++count; } while (result->NextRow()); sLog->outInfo(LOG_FILTER_SERVER_LOADING, ">> Loaded %u lfg required itemlevels in %u ms", count, GetMSTimeDiffToNow(oldMSTime)); }
------String Demo 01------
//void World::SendWorldText(int32 string_id, ...)
std::string str = "[|cffff0000"; //"|cfff0ff00[世界][|r" std::string name = handler->GetSession()->GetPlayer()->GetName(); str += name; str += "|r]:"; str += args; sWorld->SendWorldText(1000000, str, args);
------.conf Demo 01------
ConfigMgr::GetStringDefault //获取字符串