Streamlining loading functions for server startup

- Added a couple of timer outputs
- Improved code consistency between loading functions
- Progess bars should look and behave similar on all OS now (sLog.outString() is not needed anymore to replace the progress bar in log files)

--HG--
branch : trunk
This commit is contained in:
leak
2010-12-19 17:06:33 +01:00
parent 9c35e10444
commit fd694cd232
36 changed files with 2645 additions and 2286 deletions
File diff suppressed because it is too large Load Diff
@@ -34,6 +34,8 @@
void SmartWaypointMgr::LoadFromDB()
{
uint32 oldMSTime = getMSTime();
waypoint_map.clear();
PreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_LOAD_SMARTAI_WP);
@@ -43,17 +45,17 @@ void SmartWaypointMgr::LoadFromDB()
{
barGoLink bar(1);
bar.step();
sLog.outString();
sLog.outString(">> Loaded 0 SmartAI Waypoint Paths. DB table `waypoints` is empty.");
sLog.outString();
return;
}
WPPath* path = NULL;
uint32 last_entry = 0;
uint32 last_id = 1;
barGoLink bar(result->GetRowCount());
uint32 count = 0;
uint32 total = 0;
WPPath* path = NULL;
uint32 last_entry = 0;
uint32 last_id = 1;
do
{
@@ -88,14 +90,17 @@ void SmartWaypointMgr::LoadFromDB()
}
last_entry = entry;
total++;
} while (result->NextRow());
}
while (result->NextRow());
sLog.outString(">> Loaded %u SmartAI waypoint paths (total %u waypoints) in %u ms", count, total, GetMSTimeDiffToNow(oldMSTime));
sLog.outString();
sLog.outString(">> Loaded %u SmartAI Waypoint Paths, total %u waypoints.", count, total);
}
void SmartAIMgr::LoadSmartAIFromDB()
{
uint32 oldMSTime = getMSTime();
for (uint8 i = 0; i < SMART_SCRIPT_TYPE_MAX; i++)
mEventMap[i].clear(); //Drop Existing SmartAI List
@@ -106,13 +111,13 @@ void SmartAIMgr::LoadSmartAIFromDB()
{
barGoLink bar(1);
bar.step();
sLog.outString();
sLog.outString(">> Loaded 0 SmartAI scripts. DB table `smartai_scripts` is empty.");
sLog.outString();
return;
}
barGoLink bar(result->GetRowCount());
uint32 ScriptCount = 0;
uint32 count = 0;
do
{
@@ -215,16 +220,17 @@ void SmartAIMgr::LoadSmartAIFromDB()
// creature entry / guid not found in storage, create empty event list for it and increase counters
if (mEventMap[source_type].find(temp.entryOrGuid) == mEventMap[source_type].end())
{
++ScriptCount;
++count;
SmartAIEventList eventList;
mEventMap[source_type][temp.entryOrGuid] = eventList;
}
// store the new event
mEventMap[source_type][temp.entryOrGuid].push_back(temp);
} while (result->NextRow());
}
while (result->NextRow());
sLog.outString(">> Loaded %u SmartAI scripts in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
sLog.outString();
sLog.outString(">> Loaded %u SmartAI scripts.", ScriptCount);
}
bool SmartAIMgr::IsTargetValid(SmartScriptHolder e)
+35 -26
View File
@@ -2095,13 +2095,14 @@ AchievementCriteriaEntryList const& AchievementGlobalMgr::GetTimedAchievementCri
void AchievementGlobalMgr::LoadAchievementCriteriaList()
{
uint32 oldMSTime = getMSTime();
if (sAchievementCriteriaStore.GetNumRows() == 0)
{
barGoLink bar(1);
bar.step();
sLog.outString();
sLog.outErrorDb(">> Loaded 0 achievement criteria.");
sLog.outString();
return;
}
@@ -2121,24 +2122,26 @@ void AchievementGlobalMgr::LoadAchievementCriteriaList()
m_AchievementCriteriasByTimedType[criteria->timedType].push_back(criteria);
}
sLog.outString(">> Loaded %lu achievement criteria in %u ms",(unsigned long)m_AchievementCriteriasByType->size(), GetMSTimeDiffToNow(oldMSTime));
sLog.outString();
sLog.outString(">> Loaded %lu achievement criteria.",(unsigned long)m_AchievementCriteriasByType->size());
}
void AchievementGlobalMgr::LoadAchievementReferenceList()
{
uint32 oldMSTime = getMSTime();
if (sAchievementStore.GetNumRows() == 0)
{
barGoLink bar(1);
bar.step();
sLog.outString(">> Loaded 0 achievement references.");
sLog.outString();
sLog.outErrorDb(">> Loaded 0 achievement references.");
return;
}
uint32 count = 0;
barGoLink bar(sAchievementStore.GetNumRows());
uint32 count = 0;
for (uint32 entryId = 0; entryId < sAchievementStore.GetNumRows(); ++entryId)
{
bar.step();
@@ -2151,12 +2154,14 @@ void AchievementGlobalMgr::LoadAchievementReferenceList()
++count;
}
sLog.outString(">> Loaded %u achievement references in %u ms",count, GetMSTimeDiffToNow(oldMSTime));
sLog.outString();
sLog.outString(">> Loaded %u achievement references.",count);
}
void AchievementGlobalMgr::LoadAchievementCriteriaData()
{
uint32 oldMSTime = getMSTime();
m_criteriaDataMap.clear(); // need for reload case
QueryResult result = WorldDatabase.Query("SELECT criteria_id, type, value1, value2, ScriptName FROM achievement_criteria_data");
@@ -2165,14 +2170,14 @@ void AchievementGlobalMgr::LoadAchievementCriteriaData()
{
barGoLink bar(1);
bar.step();
sLog.outString();
sLog.outString(">> Loaded 0 additional achievement criteria data. DB table `achievement_criteria_data` is empty.");
sLog.outString();
return;
}
uint32 count = 0;
barGoLink bar(result->GetRowCount());
uint32 count = 0;
do
{
bar.step();
@@ -2213,7 +2218,8 @@ void AchievementGlobalMgr::LoadAchievementCriteriaData()
// counting data by and data types
++count;
} while (result->NextRow());
}
while (result->NextRow());
// post loading checks
for (uint32 entryId = 0; entryId < sAchievementCriteriaStore.GetNumRows(); ++entryId)
@@ -2294,21 +2300,22 @@ void AchievementGlobalMgr::LoadAchievementCriteriaData()
sLog.outErrorDb("Table `achievement_criteria_data` does not have expected data for criteria (Entry: %u Type: %u) for achievement %u.", criteria->ID, criteria->requiredType, criteria->referredAchievement);
}
sLog.outString(">> Loaded %u additional achievement criteria data in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
sLog.outString();
sLog.outString(">> Loaded %u additional achievement criteria data.",count);
}
void AchievementGlobalMgr::LoadCompletedAchievements()
{
uint32 oldMSTime = getMSTime();
QueryResult result = CharacterDatabase.Query("SELECT achievement FROM character_achievement GROUP BY achievement");
if (!result)
{
barGoLink bar(1);
bar.step();
sLog.outString(">> Loaded 0 completed achievements. DB table `character_achievement` is empty.");
sLog.outString();
sLog.outString(">> Loaded 0 realm completed achievements . DB table `character_achievement` is empty.");
return;
}
@@ -2330,12 +2337,14 @@ void AchievementGlobalMgr::LoadCompletedAchievements()
m_allCompletedAchievements.insert(achievement_id);
} while (result->NextRow());
sLog.outString(">> Loaded %lu completed achievements in %u ms",(unsigned long)m_allCompletedAchievements.size(), GetMSTimeDiffToNow(oldMSTime));
sLog.outString();
sLog.outString(">> Loaded %lu realm completed achievements.",(unsigned long)m_allCompletedAchievements.size());
}
void AchievementGlobalMgr::LoadRewards()
{
uint32 oldMSTime = getMSTime();
m_achievementRewards.clear(); // need for reload case
// 0 1 2 3 4 5 6
@@ -2344,11 +2353,9 @@ void AchievementGlobalMgr::LoadRewards()
if (!result)
{
barGoLink bar(1);
bar.step();
sLog.outString();
sLog.outErrorDb(">> Loaded 0 achievement rewards. DB table `achievement_reward` is empty.");
sLog.outString();
return;
}
@@ -2439,27 +2446,29 @@ void AchievementGlobalMgr::LoadRewards()
m_achievementRewards[entry] = reward;
++count;
} while (result->NextRow());
}
while (result->NextRow());
sLog.outString(">> Loaded %u achievement rewards in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
sLog.outString();
sLog.outString(">> Loaded %u achievement rewards", count);
}
void AchievementGlobalMgr::LoadRewardLocales()
{
uint32 oldMSTime = getMSTime();
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");
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(">> Loaded 0 achievement reward locale strings. DB table `locales_achievement_reward` is empty");
sLog.outString();
sLog.outString(">> Loaded 0 achievement reward locale strings.");
sLog.outString(">> DB table `locales_achievement_reward` is empty.");
return;
}
@@ -2491,6 +2500,6 @@ void AchievementGlobalMgr::LoadRewardLocales()
}
} while (result->NextRow());
sLog.outString(">> Loaded %lu achievement reward locale strings in %u ms", (unsigned long)m_achievementRewardLocales.size(), GetMSTimeDiffToNow(oldMSTime));
sLog.outString();
sLog.outString(">> Loaded %lu achievement reward locale strings", (unsigned long)m_achievementRewardLocales.size());
}
+13 -6
View File
@@ -34,32 +34,39 @@ AddonMgr::~AddonMgr()
void AddonMgr::LoadFromDB()
{
uint32 oldMSTime = getMSTime();
QueryResult result = CharacterDatabase.Query("SELECT name, crc FROM addons");
if (!result)
{
sLog.outErrorDb("The table `addons` is empty");
barGoLink bar(1);
bar.step();
sLog.outString(">> Loaded 0 known addons. DB table `addons` is empty!");
sLog.outString();
return;
}
barGoLink bar(result->GetRowCount());
uint32 count = 0;
Field *fields;
do
{
fields = result->Fetch();
Field *fields = result->Fetch();
bar.step();
count++;
std::string name = fields[0].GetString();
uint32 crc = fields[1].GetUInt32();
SavedAddon addon(name, crc);
m_knownAddons.push_back(addon);
} while (result->NextRow());
++count;
}
while (result->NextRow());
sLog.outString(">> Loaded %u known addons in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
sLog.outString();
sLog.outString(">> Loaded %u known addons", count);
}
void AddonMgr::SaveAddon(AddonInfo const& addon)
@@ -308,6 +308,8 @@ void AuctionHouseMgr::SendAuctionCancelledToBidderMail(AuctionEntry* auction, SQ
void AuctionHouseMgr::LoadAuctionItems()
{
uint32 oldMSTime = getMSTime();
// data needs to be at first place for Item::LoadFromDB
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_LOAD_AUCTION_ITEMS);
PreparedQueryResult result = CharacterDatabase.Query(stmt);
@@ -316,14 +318,14 @@ void AuctionHouseMgr::LoadAuctionItems()
{
barGoLink bar(1);
bar.step();
sLog.outString(">> Loaded 0 auction items. DB table `auctionhouse` or `item_instance` is empty!");
sLog.outString();
sLog.outString(">> Loaded 0 auction items");
return;
}
barGoLink bar(result->GetRowCount());
uint32 count = 0;
do
{
bar.step();
@@ -352,36 +354,37 @@ void AuctionHouseMgr::LoadAuctionItems()
}
while (result->NextRow());
sLog.outString(">> Loaded %u auction items in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
sLog.outString();
sLog.outString(">> Loaded %u auction items", count);
}
void AuctionHouseMgr::LoadAuctions()
{
uint32 oldMSTime = getMSTime();
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_LOAD_AUCTIONS);
PreparedQueryResult result = CharacterDatabase.Query(stmt);
if (!result)
{
barGoLink bar(1);
bar.step();
sLog.outString();
sLog.outString(">> Loaded 0 auctions. DB table `auctionhouse` is empty.");
sLog.outString();
return;
}
barGoLink bar(result->GetRowCount());
uint32 count = 0;
SQLTransaction trans = CharacterDatabase.BeginTransaction();
uint32 count = 0;
AuctionEntry *aItem;
do
{
Field* fields = result->Fetch();
bar.step();
aItem = new AuctionEntry();
AuctionEntry *aItem = new AuctionEntry();
if (!aItem->LoadFromDB(fields))
{
aItem->DeleteFromDB(trans);
@@ -395,8 +398,8 @@ void AuctionHouseMgr::LoadAuctions()
CharacterDatabase.CommitTransaction(trans);
sLog.outString(">> Loaded %u auctions in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
sLog.outString();
sLog.outString(">> Loaded %u auctions", count);
}
void AuctionHouseMgr::AddAItem(Item* it)
@@ -661,6 +661,8 @@ uint32 BattlegroundMgr::CreateBattleground(BattlegroundTypeId bgTypeId, bool IsA
void BattlegroundMgr::CreateInitialBattlegrounds()
{
uint32 oldMSTime = getMSTime();
float AStartLoc[4];
float HStartLoc[4];
uint32 MaxPlayersPerTeam, MinPlayersPerTeam, MinLvl, MaxLvl, start1, start2;
@@ -670,23 +672,20 @@ void BattlegroundMgr::CreateInitialBattlegrounds()
bool IsArena;
uint32 scriptId = 0;
uint32 count = 0;
// 0 1 2 3 4 5 6 7 8 9 10
QueryResult result = WorldDatabase.Query("SELECT id, MinPlayersPerTeam,MaxPlayersPerTeam,MinLvl,MaxLvl,AllianceStartLoc,AllianceStartO,HordeStartLoc,HordeStartO,Weight,ScriptName FROM battleground_template");
if (!result)
{
barGoLink bar(1);
bar.step();
sLog.outString();
sLog.outErrorDb(">> Loaded 0 battlegrounds. DB table `battleground_template` is empty.");
sLog.outString();
return;
}
barGoLink bar(result->GetRowCount());
uint32 count = 0;
do
{
@@ -785,10 +784,11 @@ void BattlegroundMgr::CreateInitialBattlegrounds()
else if (bgTypeID != BATTLEGROUND_RB)
m_BGSelectionWeights[bgTypeID] = selectionWeight;
++count;
} while (result->NextRow());
}
while (result->NextRow());
sLog.outString(">> Loaded %u battlegrounds in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
sLog.outString();
sLog.outString(">> Loaded %u battlegrounds", count);
}
void BattlegroundMgr::InitAutomaticArenaPointDistribution()
@@ -1112,23 +1112,23 @@ uint32 BattlegroundMgr::GetPrematureFinishTime() const
void BattlegroundMgr::LoadBattleMastersEntry()
{
mBattleMastersMap.clear(); // need for reload case
uint32 oldMSTime = getMSTime();
QueryResult result = WorldDatabase.Query("SELECT entry,bg_template FROM battlemaster_entry");
mBattleMastersMap.clear(); // need for reload case
uint32 count = 0;
QueryResult result = WorldDatabase.Query("SELECT entry, bg_template FROM battlemaster_entry");
if (!result)
{
barGoLink bar(1);
bar.step();
sLog.outString(">> Loaded 0 battlemaster entries. DB table `battlemaster_entry` is empty!");
sLog.outString();
sLog.outString(">> Loaded 0 battlemaster entries - table is empty!");
return;
}
barGoLink bar(result->GetRowCount());
uint32 count = 0;
do
{
@@ -1147,10 +1147,11 @@ void BattlegroundMgr::LoadBattleMastersEntry()
mBattleMastersMap[entry] = BattlegroundTypeId(bgTypeId);
} while (result->NextRow());
}
while (result->NextRow());
sLog.outString(">> Loaded %u battlemaster entries in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
sLog.outString();
sLog.outString(">> Loaded %u battlemaster entries", count);
}
HolidayIds BattlegroundMgr::BGTypeToWeekendHolidayId(BattlegroundTypeId bgTypeId)
+8 -6
View File
@@ -348,6 +348,8 @@ ConditionList ConditionMgr::GetConditionsForVehicleSpell(uint32 creatureID, uint
void ConditionMgr::LoadConditions(bool isReload)
{
uint32 oldMSTime = getMSTime();
Clean();
//must clear all custom handled cases (groupped types) before reload
@@ -374,21 +376,21 @@ void ConditionMgr::LoadConditions(bool isReload)
sObjectMgr.LoadGossipMenuItems();
}
uint32 count = 0;
QueryResult result = WorldDatabase.Query("SELECT SourceTypeOrReferenceId, SourceGroup, SourceEntry, ElseGroup, ConditionTypeOrReference, ConditionValue1, ConditionValue2, ConditionValue3, ErrorTextId, ScriptName FROM conditions");
QueryResult result = WorldDatabase.Query("SELECT SourceTypeOrReferenceId, SourceGroup, SourceEntry, ElseGroup, ConditionTypeOrReference,"
" ConditionValue1, ConditionValue2, ConditionValue3, ErrorTextId, ScriptName FROM conditions");
if (!result)
{
barGoLink bar(1);
bar.step();
sLog.outErrorDb(">> Loaded 0 conditions. DB table `groups` is empty!");
sLog.outString();
sLog.outErrorDb(">> Loaded `conditions`, table is empty!");
return;
}
barGoLink bar(result->GetRowCount());
uint32 count = 0;
do
{
@@ -576,8 +578,8 @@ void ConditionMgr::LoadConditions(bool isReload)
}
while (result->NextRow());
sLog.outString(">> Loaded %u conditions in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
sLog.outString();
sLog.outString(">> Loaded %u conditions", count);
}
bool ConditionMgr::addToLootTemplate(Condition* cond, LootTemplate* loot)
+8 -5
View File
@@ -36,6 +36,8 @@ DisableMgr::~DisableMgr()
void DisableMgr::LoadDisables()
{
uint32 oldMSTime = getMSTime();
// reload case
for (DisableMap::iterator itr = m_DisableMap.begin(); itr != m_DisableMap.end(); ++itr)
itr->second.clear();
@@ -50,9 +52,8 @@ void DisableMgr::LoadDisables()
{
barGoLink bar(1);
bar.step();
sLog.outString(">> Loaded 0 disables. DB table `disables` is empty!");
sLog.outString();
sLog.outString(">> Loaded %u disables", total_count);
return;
}
@@ -182,19 +183,21 @@ void DisableMgr::LoadDisables()
}
while (result->NextRow());
sLog.outString(">> Loaded %u disables in %u ms", total_count, GetMSTimeDiffToNow(oldMSTime));
sLog.outString();
sLog.outString(">> Loaded %u disables.", total_count);
}
void DisableMgr::CheckQuestDisables()
{
uint32 oldMSTime = getMSTime();
uint32 count = m_DisableMap[DISABLE_TYPE_QUEST].size();
if (!count)
{
barGoLink bar(1);
bar.step();
sLog.outString(">> Checked 0 quest disables.");
sLog.outString();
sLog.outString(">> Done.");
return;
}
@@ -215,8 +218,8 @@ void DisableMgr::CheckQuestDisables()
++itr;
}
sLog.outString(">> Checked %u quest disables in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
sLog.outString();
sLog.outString(">> Done.");
}
bool DisableMgr::IsDisabledFor(DisableType type, uint32 entry, Unit const* pUnit)
+3 -1
View File
@@ -244,6 +244,8 @@ inline void LoadDBC(uint32& availableDbcLocales,barGoLink& bar, StoreProblemList
void LoadDBCStores(const std::string& dataPath)
{
uint32 oldMSTime = getMSTime();
std::string dbcPath = dataPath+"dbc/";
const uint32 DBCFilesCount = 90;
@@ -620,8 +622,8 @@ void LoadDBCStores(const std::string& dataPath)
sLog.outError("\nYou have _outdated_ DBC files. Please extract correct versions from current using client.");
exit(1);
}
sLog.outString(">> Initialized %d data stores in %u ms", DBCFilesCount, GetMSTimeDiffToNow(oldMSTime));
sLog.outString();
sLog.outString(">> Initialized %d data stores", DBCFilesCount);
}
SimpleFactionsList const* GetFactionTeamList(uint32 faction)
+9 -6
View File
@@ -75,9 +75,10 @@ LFGMgr::~LFGMgr()
/// Load achievement <-> encounter associations
void LFGMgr::LoadDungeonEncounters()
{
uint32 oldMSTime = getMSTime();
m_EncountersByAchievement.clear();
uint32 count = 0;
QueryResult result = WorldDatabase.Query("SELECT achievementId, dungeonId FROM lfg_dungeon_encounters");
if (!result)
@@ -91,6 +92,7 @@ void LFGMgr::LoadDungeonEncounters()
}
barGoLink bar(result->GetRowCount());
uint32 count = 0;
Field* fields = NULL;
do
@@ -124,19 +126,20 @@ void LFGMgr::LoadDungeonEncounters()
++count;
} while (result->NextRow());
sLog.outString(">> Loaded %u dungeon encounter lfg associations in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
sLog.outString();
sLog.outString(">> Loaded %u dungeon encounter lfg associations.", count);
}
/// Load rewards for completing dungeons
void LFGMgr::LoadRewards()
{
uint32 oldMSTime = getMSTime();
for (LfgRewardMap::iterator itr = m_RewardMap.begin(); itr != m_RewardMap.end(); ++itr)
delete itr->second;
m_RewardMap.clear();
uint32 count = 0;
// ORDER BY is very important for GetRandomDungeonReward!
QueryResult result = WorldDatabase.Query("SELECT dungeonId, maxLevel, firstQuestId, firstMoneyVar, firstXPVar, otherQuestId, otherMoneyVar, otherXPVar FROM lfg_dungeon_rewards ORDER BY dungeonId, maxLevel ASC");
@@ -144,13 +147,13 @@ void LFGMgr::LoadRewards()
{
barGoLink bar(1);
bar.step();
sLog.outString();
sLog.outErrorDb(">> Loaded 0 lfg dungeon rewards. DB table `lfg_dungeon_rewards` is empty!");
sLog.outString();
return;
}
barGoLink bar(result->GetRowCount());
uint32 count = 0;
Field* fields = NULL;
do
@@ -194,8 +197,8 @@ void LFGMgr::LoadRewards()
++count;
} while (result->NextRow());
sLog.outString(">> Loaded %u lfg dungeon rewards in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
sLog.outString();
sLog.outString(">> Loaded %u lfg dungeon rewards.", count);
}
void LFGMgr::Update(uint32 diff)
@@ -70,26 +70,21 @@ void CreatureGroupManager::RemoveCreatureFromGroup(CreatureGroup *group, Creatur
void CreatureGroupManager::LoadCreatureFormations()
{
//Clear existing map
for (CreatureGroupInfoType::iterator itr = CreatureGroupMap.begin(); itr != CreatureGroupMap.end(); ++itr)
delete itr->second;
uint32 oldMSTime = getMSTime();
for (CreatureGroupInfoType::iterator itr = CreatureGroupMap.begin(); itr != CreatureGroupMap.end(); ++itr) // for reload case
delete itr->second;
CreatureGroupMap.clear();
//Check Integrity of the table
QueryResult result = WorldDatabase.Query("SELECT MAX(leaderGUID) FROM creature_formations");
if (!result)
{
sLog.outErrorDb(" ...an error occured while loading the table creature_formations (maybe it doesn't exist ?)\n");
return;
}
//Get group data
result = WorldDatabase.Query("SELECT leaderGUID, memberGUID, dist, angle, groupAI FROM creature_formations ORDER BY leaderGUID");
QueryResult result = WorldDatabase.Query("SELECT leaderGUID, memberGUID, dist, angle, groupAI FROM creature_formations ORDER BY leaderGUID");
if (!result)
{
sLog.outErrorDb("The table creature_formations is empty or corrupted");
barGoLink bar(1);
bar.step();
sLog.outErrorDb(">> Loaded 0 creatures in formations. DB table `creature_formations` is empty!");
sLog.outString();
return;
}
@@ -108,12 +103,11 @@ void CreatureGroupManager::LoadCreatureFormations()
} while (guidResult->NextRow());
}
uint64 total_records = result->GetRowCount();
barGoLink bar(total_records);
barGoLink bar(result->GetRowCount());
uint32 count = 0;
Field *fields;
FormationInfo *group_member;
//Loading data...
do
{
fields = result->Fetch();
@@ -154,11 +148,11 @@ void CreatureGroupManager::LoadCreatureFormations()
}
CreatureGroupMap[memberGUID] = group_member;
++count;
}
while (result->NextRow()) ;
sLog.outString();
sLog.outString(">> Loaded " UI64FMTD " creatures in formations", total_records);
sLog.outString(">> Loaded %u creatures in formations in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
sLog.outString();
}
@@ -46,6 +46,8 @@ static EnchantmentStore RandomItemEnch;
void LoadRandomEnchantmentsTable()
{
uint32 oldMSTime = getMSTime();
RandomItemEnch.clear(); // for reload case
QueryResult result = WorldDatabase.Query("SELECT entry, ench, chance FROM item_enchantment_template");
@@ -70,13 +72,13 @@ void LoadRandomEnchantmentsTable()
++count;
} while (result->NextRow());
sLog.outString(">> Loaded %u Item Enchantment definitions in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
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.");
sLog.outString();
}
}
@@ -30,21 +30,21 @@
void MapManager::LoadTransports()
{
QueryResult result = WorldDatabase.Query("SELECT guid, entry, name, period, ScriptName FROM transports");
uint32 oldMSTime = getMSTime();
uint32 count = 0;
QueryResult result = WorldDatabase.Query("SELECT guid, entry, name, period, ScriptName FROM transports");
if (!result)
{
barGoLink bar(1);
bar.step();
sLog.outString(">> Loaded 0 transports. DB table `transports` is empty!");
sLog.outString();
sLog.outString(">> Loaded %u transports", count);
return;
}
barGoLink bar(result->GetRowCount());
uint32 count = 0;
do
{
@@ -113,9 +113,6 @@ void MapManager::LoadTransports()
}
while (result->NextRow());
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
@@ -131,26 +128,29 @@ void MapManager::LoadTransports()
}
while (result->NextRow());
}
sLog.outString(">> Loaded %u transports in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
sLog.outString();
}
void MapManager::LoadTransportNPCs()
{
// Spawn NPCs linked to the transport
uint32 oldMSTime = getMSTime();
// 0 1 2 3 4 5 6 7
QueryResult result = WorldDatabase.PQuery("SELECT guid, npc_entry, transport_entry, TransOffsetX, TransOffsetY, TransOffsetZ, TransOffsetO, emote FROM creature_transport");
uint32 count = 0;
if (!result)
{
barGoLink bar(1);
bar.step();
sLog.outString(">> Loaded 0 transport NPCs. DB table `creature_transport` is empty!");
sLog.outString();
sLog.outString(">> Loaded %u transport NPCs.", count);
return;
}
barGoLink bar(result->GetRowCount());
uint32 count = 0;
do
{
@@ -174,10 +174,12 @@ void MapManager::LoadTransportNPCs()
}
}
count++;
} while (result->NextRow());
++count;
}
while (result->NextRow());
sLog.outString(">> Loaded %u transport npcs in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
sLog.outString();
sLog.outString(">> Loaded %u transport npcs", count);
}
Transport::Transport(uint32 period, uint32 script) : GameObject(), m_period(period), ScriptId(script)
+189 -189
View File
@@ -194,109 +194,107 @@ void GameEventMgr::StopEvent(uint16 event_id, bool overwrite)
void GameEventMgr::LoadFromDB()
{
uint32 oldMSTime = getMSTime();
QueryResult result = WorldDatabase.Query("SELECT MAX(entry) FROM game_event");
if (!result)
{
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();
mGameEvent.resize(max_event_id+1);
barGoLink bar(1);
bar.step();
sLog.outString(">> Loaded 0 weather definitions. DB table `game_event` is empty.");
sLog.outString();
return;
}
QueryResult result = WorldDatabase.Query("SELECT entry,UNIX_TIMESTAMP(start_time),UNIX_TIMESTAMP(end_time),occurence,length,holiday,description,world_event FROM game_event");
Field *fields = result->Fetch();
uint32 max_event_id = fields[0].GetUInt16();
mGameEvent.resize(max_event_id+1);
result = WorldDatabase.Query("SELECT entry,UNIX_TIMESTAMP(start_time),UNIX_TIMESTAMP(end_time),occurence,length,holiday,description,world_event FROM game_event");
if (!result)
{
mGameEvent.clear();
sLog.outString(">> Table game_event is empty!");
sLog.outErrorDb(">> Loaded 0 game events. DB table `game_event` is empty.");
sLog.outString();
return;
}
uint32 count = 0;
barGoLink bar(result->GetRowCount());
do
{
barGoLink bar(result->GetRowCount());
do
++count;
Field *fields = result->Fetch();
bar.step();
uint16 event_id = fields[0].GetUInt16();
if (event_id == 0)
{
++count;
Field *fields = result->Fetch();
sLog.outErrorDb("`game_event` game event id (%i) is reserved and can't be used.",event_id);
continue;
}
bar.step();
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());
uint16 event_id = fields[0].GetUInt16();
if (event_id == 0)
pGameEvent.state = (GameEventState)(fields[7].GetUInt8());
pGameEvent.nextstart = 0;
if (pGameEvent.length == 0 && pGameEvent.state == GAMEEVENT_NORMAL) // length>0 is validity check
{
sLog.outErrorDb("`game_event` game event id (%i) isn't a world event and has length = 0, thus it 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) is reserved and can't be used.",event_id);
continue;
sLog.outErrorDb("`game_event` game event id (%i) have not existed holiday id %u.",event_id,pGameEvent.holiday_id);
pGameEvent.holiday_id = HOLIDAY_NONE;
}
}
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());
pGameEvent.description = fields[6].GetString();
pGameEvent.state = (GameEventState)(fields[7].GetUInt8());
pGameEvent.nextstart = 0;
} while (result->NextRow());
if (pGameEvent.length == 0 && pGameEvent.state == GAMEEVENT_NORMAL) // length>0 is validity check
{
sLog.outErrorDb("`game_event` game event id (%i) isn't a world event and has length = 0, thus it 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 not existed holiday id %u.",event_id,pGameEvent.holiday_id);
pGameEvent.holiday_id = HOLIDAY_NONE;
}
}
pGameEvent.description = fields[6].GetString();
} while (result->NextRow());
sLog.outString();
sLog.outString(">> Loaded %u game events", count);
}
sLog.outString(">> Loaded %u game events in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
sLog.outString();
// load game event saves
sLog.outString("Loading Game Event Saves Data...");
oldMSTime = getMSTime();
// 0 1 2
result = CharacterDatabase.Query("SELECT event_id, state, next_start FROM game_event_save");
count = 0;
if (!result)
{
barGoLink bar2(1);
bar2.step();
barGoLink bar(1);
bar.step();
sLog.outString(">> Loaded 0 game event saves in game events. DB table `game_event_save` is empty.");
sLog.outString();
sLog.outString(">> Loaded %u game event saves in game events", count);
}
else
{
barGoLink bar2(result->GetRowCount());
count = 0;
barGoLink bar(result->GetRowCount());
do
{
Field *fields = result->Fetch();
bar2.step();
bar.step();
uint16 event_id = fields[0].GetUInt16();
@@ -320,32 +318,33 @@ void GameEventMgr::LoadFromDB()
++count;
} while (result->NextRow());
sLog.outString(">> Loaded %u game event saves in game events in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
sLog.outString();
sLog.outString(">> Loaded %u game event saves in game events", count);
}
// load game event links (prerequisites)
sLog.outString("Loading Game Event Prerequisite Data...");
oldMSTime = getMSTime();
result = WorldDatabase.Query("SELECT event_id, prerequisite_event FROM game_event_prerequisite");
if (!result)
{
barGoLink bar2(1);
bar2.step();
barGoLink bar(1);
bar.step();
sLog.outString(">> Loaded 0 game event prerequisites in game events. DB table `game_event_prerequisite` is empty.");
sLog.outString();
sLog.outString(">> Loaded %u game event prerequisites in game events", count);
}
else
{
barGoLink bar2(result->GetRowCount());
count = 0;
barGoLink bar(result->GetRowCount());
do
{
Field *fields = result->Fetch();
bar2.step();
bar.step();
uint16 event_id = fields[0].GetUInt16();
@@ -374,31 +373,31 @@ void GameEventMgr::LoadFromDB()
++count;
} while (result->NextRow());
sLog.outString(">> Loaded %u game event prerequisites in game events in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
sLog.outString();
sLog.outString(">> Loaded %u game event prerequisites in game events", count);
}
// Creatures
sLog.outString("Loading Game Event Creature Data...");
oldMSTime = getMSTime();
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(">> Loaded 0 creatures in game events. DB table `game_event_creature` is empty");
sLog.outString();
sLog.outString(">> Loaded %u creatures in game events", count);
}
else
{
count = 0;
barGoLink bar(result->GetRowCount());
do
{
@@ -423,31 +422,30 @@ void GameEventMgr::LoadFromDB()
} while (result->NextRow());
sLog.outString(">> Loaded %u creatures in game events in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
sLog.outString();
sLog.outString(">> Loaded %u creatures in game events", count);
}
// Gameobjects
sLog.outString("Loading Game Event GO Data...");
oldMSTime = getMSTime();
mGameEventGameobjectGuids.resize(mGameEvent.size()*2-1);
// 1 2
result = WorldDatabase.Query("SELECT gameobject.guid, game_event_gameobject.event "
"FROM gameobject JOIN game_event_gameobject ON gameobject.guid=game_event_gameobject.guid");
count = 0;
if (!result)
{
barGoLink bar(1);
bar.step();
sLog.outString(">> Loaded 0 gameobjects in game events. DB table `game_event_gameobject` is empty.");
sLog.outString();
sLog.outString(">> Loaded %u gameobjects in game events", count);
}
else
{
count = 0;
barGoLink bar(result->GetRowCount());
do
{
@@ -472,13 +470,14 @@ void GameEventMgr::LoadFromDB()
} while (result->NextRow());
sLog.outString(">> Loaded %u gameobjects in game events in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
sLog.outString();
sLog.outString(">> Loaded %u gameobjects in game events", count);
}
// Model/Equipment Changes
sLog.outString("Loading Game Event Model/Equipment Change Data...");
oldMSTime = getMSTime();
mGameEventModelEquip.resize(mGameEvent.size());
// 0 1 2
@@ -487,18 +486,16 @@ void GameEventMgr::LoadFromDB()
"game_event_model_equip.equipment_id "
"FROM creature JOIN game_event_model_equip ON creature.guid=game_event_model_equip.guid");
count = 0;
if (!result)
{
barGoLink bar(1);
bar.step();
sLog.outString(">> Loaded 0 model/equipment changes in game events. DB table `game_event_model_equip` is empty.");
sLog.outString();
sLog.outString(">> Loaded %u model/equipment changes in game events", count);
}
else
{
count = 0;
barGoLink bar(result->GetRowCount());
do
{
@@ -535,30 +532,29 @@ void GameEventMgr::LoadFromDB()
} while (result->NextRow());
sLog.outString(">> Loaded %u model/equipment changes in game events in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
sLog.outString();
sLog.outString(">> Loaded %u model/equipment changes in game events", count);
}
// Quests
sLog.outString("Loading Game Event Quest Data...");
oldMSTime = getMSTime();
mGameEventCreatureQuests.resize(mGameEvent.size());
// 0 1 2
result = WorldDatabase.Query("SELECT id, quest, event FROM game_event_creature_quest");
count = 0;
if (!result)
{
barGoLink bar(1);
bar.step();
sLog.outString(">> Loaded 0 quests additions in game events. DB table `game_event_creature_quest` is empty.");
sLog.outString();
sLog.outString(">> Loaded %u quests additions in game events", count);
}
else
{
count = 0;
barGoLink bar(result->GetRowCount());
do
{
@@ -580,36 +576,36 @@ void GameEventMgr::LoadFromDB()
questlist.push_back(QuestRelation(id, quest));
} while (result->NextRow());
sLog.outString(">> Loaded %u quests additions in game events in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
sLog.outString();
sLog.outString(">> Loaded %u quests additions in game events", count);
}
// GO Quests
sLog.outString("Loading Game Event GO Quest Data...");
oldMSTime = getMSTime();
mGameEventGameObjectQuests.resize(mGameEvent.size());
// 0 1 2
result = WorldDatabase.Query("SELECT id, quest, event FROM game_event_gameobject_quest");
count = 0;
if (!result)
{
barGoLink bar3(1);
bar3.step();
barGoLink bar(1);
bar.step();
sLog.outString(">> Loaded 0 go quests additions in game events. DB table `game_event_gameobject_quest` is empty.");
sLog.outString();
sLog.outString(">> Loaded %u go quests additions in game events", count);
}
else
{
barGoLink bar3(result->GetRowCount());
count = 0;
barGoLink bar(result->GetRowCount());
do
{
Field *fields = result->Fetch();
bar3.step();
bar.step();
uint32 id = fields[0].GetUInt32();
uint32 quest = fields[1].GetUInt32();
uint16 event_id = fields[2].GetUInt16();
@@ -626,34 +622,34 @@ void GameEventMgr::LoadFromDB()
} while (result->NextRow());
sLog.outString(">> Loaded %u quests additions in game events in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
sLog.outString();
sLog.outString(">> Loaded %u quests additions in game events", count);
}
// Load quest to (event,condition) mapping
// 0 1 2 3
sLog.outString("Loading Game Event Quest Condition Data...");
oldMSTime = getMSTime();
result = WorldDatabase.Query("SELECT quest, event_id, condition_id, num FROM game_event_quest_condition");
count = 0;
if (!result)
{
barGoLink bar3(1);
bar3.step();
barGoLink bar(1);
bar.step();
sLog.outString(">> Loaded 0 quest event conditions in game events. DB table `game_event_quest_condition` is empty.");
sLog.outString();
sLog.outString(">> Loaded %u quest event conditions in game events", count);
}
else
{
barGoLink bar3(result->GetRowCount());
count = 0;
barGoLink bar(result->GetRowCount());
do
{
Field *fields = result->Fetch();
bar3.step();
bar.step();
uint32 quest = fields[0].GetUInt32();
uint16 event_id = fields[1].GetUInt16();
uint32 condition = fields[2].GetUInt32();
@@ -671,35 +667,35 @@ void GameEventMgr::LoadFromDB()
mQuestToEventConditions[quest].num = num;
} while (result->NextRow());
sLog.outString(">> Loaded %u quest event conditions in game events in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
sLog.outString();
sLog.outString(">> Loaded %u quest event conditions in game events", count);
}
// load conditions of the events
// 0 1 2 3 4
// Load conditions for events
sLog.outString("Loading Game Event Condition Data...");
oldMSTime = getMSTime();
// 0 1 2 3 4
result = WorldDatabase.Query("SELECT event_id, condition_id, req_num, max_world_state_field, done_world_state_field FROM game_event_condition");
count = 0;
if (!result)
{
barGoLink bar3(1);
bar3.step();
barGoLink bar(1);
bar.step();
sLog.outString(">> Loaded 0 conditions in game events. DB table `game_event_condition` is empty.");
sLog.outString();
sLog.outString(">> Loaded %u conditions in game events", count);
}
else
{
barGoLink bar3(result->GetRowCount());
count = 0;
barGoLink bar(result->GetRowCount());
do
{
Field *fields = result->Fetch();
bar3.step();
bar.step();
uint16 event_id = fields[0].GetUInt16();
uint32 condition = fields[1].GetUInt32();
@@ -717,35 +713,35 @@ void GameEventMgr::LoadFromDB()
++count;
} while (result->NextRow());
sLog.outString(">> Loaded %u conditions in game events in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
sLog.outString();
sLog.outString(">> Loaded %u conditions in game events", count);
}
// load condition saves
// Load condition saves
sLog.outString("Loading Game Event Condition Save Data...");
oldMSTime = getMSTime();
// 0 1 2
result = CharacterDatabase.Query("SELECT event_id, condition_id, done FROM game_event_condition_save");
count = 0;
if (!result)
{
barGoLink bar3(1);
bar3.step();
barGoLink bar(1);
bar.step();
sLog.outString(">> Loaded 0 condition saves in game events. DB table `game_event_condition_save` is empty.");
sLog.outString();
sLog.outString(">> Loaded %u condition saves in game events", count);
}
else
{
barGoLink bar3(result->GetRowCount());
count = 0;
barGoLink bar(result->GetRowCount());
do
{
Field *fields = result->Fetch();
bar3.step();
bar.step();
uint16 event_id = fields[0].GetUInt16();
uint32 condition = fields[1].GetUInt32();
@@ -769,36 +765,37 @@ void GameEventMgr::LoadFromDB()
++count;
} while (result->NextRow());
sLog.outString(">> Loaded %u condition saves in game events in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
sLog.outString();
sLog.outString(">> Loaded %u condition saves in game events", count);
}
mGameEventNPCFlags.resize(mGameEvent.size());
// load game event npcflag
// Load game event npcflag
sLog.outString("Loading Game Event NPCflag Data...");
oldMSTime = getMSTime();
mGameEventNPCFlags.resize(mGameEvent.size());
// 0 1 2
result = WorldDatabase.Query("SELECT guid, event_id, npcflag FROM game_event_npcflag");
count = 0;
if (!result)
{
barGoLink bar3(1);
bar3.step();
barGoLink bar(1);
bar.step();
sLog.outString(">> Loaded 0 npcflags in game events. DB table `game_event_npcflag` is empty.");
sLog.outString();
sLog.outString(">> Loaded %u npcflags in game events", count);
}
else
{
barGoLink bar3(result->GetRowCount());
count = 0;
barGoLink bar(result->GetRowCount());
do
{
Field *fields = result->Fetch();
bar3.step();
bar.step();
uint32 guid = fields[0].GetUInt32();
uint16 event_id = fields[1].GetUInt16();
uint32 npcflag = fields[2].GetUInt32();
@@ -814,36 +811,37 @@ void GameEventMgr::LoadFromDB()
++count;
} while (result->NextRow());
sLog.outString(">> Loaded %u npcflags in game events in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
sLog.outString();
sLog.outString(">> Loaded %u npcflags in game events", count);
}
// Vendor
mGameEventVendors.resize(mGameEvent.size());
// Load game event vendors
sLog.outString("Loading Game Event Vendor Additions Data...");
oldMSTime = getMSTime();
mGameEventVendors.resize(mGameEvent.size());
// 0 1 2 3 4 5
result = WorldDatabase.Query("SELECT event, guid, item, maxcount, incrtime, ExtendedCost FROM game_event_npc_vendor ORDER BY guid, slot ASC");
count = 0;
if (!result)
{
barGoLink bar3(1);
bar3.step();
barGoLink bar(1);
bar.step();
sLog.outString(">> Loaded 0 vendor additions in game events. DB table `game_event_npc_vendor` is empty.");
sLog.outString();
sLog.outString(">> Loaded %u vendor additions in game events", count);
}
else
{
barGoLink bar3(result->GetRowCount());
count = 0;
barGoLink bar(result->GetRowCount());
do
{
Field *fields = result->Fetch();
bar3.step();
bar.step();
uint16 event_id = fields[0].GetUInt16();
if (event_id >= mGameEventVendors.size())
@@ -883,35 +881,35 @@ void GameEventMgr::LoadFromDB()
vendors.push_back(newEntry);
} while (result->NextRow());
sLog.outString(">> Loaded %u vendor additions in game events in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
sLog.outString();
sLog.outString(">> Loaded %u vendor additions in game events", count);
}
// load game event npc gossip ids
// Load game event npc gossip ids
sLog.outString("Loading Game Event NPC Gossip Data...");
oldMSTime = getMSTime();
// 0 1 2
result = WorldDatabase.Query("SELECT guid, event_id, textid FROM game_event_npc_gossip");
count = 0;
if (!result)
{
barGoLink bar3(1);
bar3.step();
barGoLink bar(1);
bar.step();
sLog.outString(">> Loaded 0 npc gossip textids in game events. DB table `game_event_npc_gossip` is empty.");
sLog.outString();
sLog.outString(">> Loaded %u npc gossip textids in game events", count);
}
else
{
barGoLink bar3(result->GetRowCount());
count = 0;
barGoLink bar(result->GetRowCount());
do
{
Field *fields = result->Fetch();
bar3.step();
bar.step();
uint32 guid = fields[0].GetUInt32();
uint16 event_id = fields[1].GetUInt16();
uint32 textid = fields[2].GetUInt32();
@@ -927,37 +925,38 @@ void GameEventMgr::LoadFromDB()
++count;
} while (result->NextRow());
sLog.outString(">> Loaded %u npc gossip textids in game events in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
sLog.outString();
sLog.outString(">> Loaded %u npc gossip textids in game events", count);
}
// Load game event battleground flags
sLog.outString("Loading Game Event Battleground Data...");
oldMSTime = getMSTime();
// set all flags to 0
mGameEventBattlegroundHolidays.resize(mGameEvent.size(),0);
// load game event battleground flags
sLog.outString("Loading Game Event Battleground Data...");
// 0 1
result = WorldDatabase.Query("SELECT event, bgflag FROM game_event_battleground_holiday");
count = 0;
if (!result)
{
barGoLink bar3(1);
bar3.step();
barGoLink bar(1);
bar.step();
sLog.outString(">> Loaded 0 battleground holidays in game events. DB table `game_event_condition` is empty.");
sLog.outString();
sLog.outString(">> Loaded %u battleground holidays in game events", count);
}
else
{
barGoLink bar3(result->GetRowCount());
count = 0;
barGoLink bar(result->GetRowCount());
do
{
Field *fields = result->Fetch();
bar3.step();
bar.step();
uint16 event_id = fields[0].GetUInt16();
@@ -972,40 +971,40 @@ void GameEventMgr::LoadFromDB()
mGameEventBattlegroundHolidays[event_id] = fields[1].GetUInt32();
} while (result->NextRow());
sLog.outString(">> Loaded %u battleground holidays in game events in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
sLog.outString();
sLog.outString(">> Loaded %u battleground holidays in game events", count);
}
////////////////////////
// GameEventPool
////////////////////////
mGameEventPoolIds.resize(mGameEvent.size()*2-1);
sLog.outString("Loading Game Event Pool Data...");
oldMSTime = getMSTime();
mGameEventPoolIds.resize(mGameEvent.size()*2-1);
// 1 2
result = WorldDatabase.Query("SELECT pool_template.entry, game_event_pool.event "
"FROM pool_template JOIN game_event_pool ON pool_template.entry = game_event_pool.pool_entry");
count = 0;
if (!result)
{
barGoLink bar2(1);
bar2.step();
barGoLink bar(1);
bar.step();
sLog.outString(">> Loaded 0 pools for game events. DB table `game_event_pool` is empty.");
sLog.outString();
sLog.outString(">> Loaded %u pools in game events", count);
}
else
{
barGoLink bar2(result->GetRowCount());
count = 0;
barGoLink bar(result->GetRowCount());
do
{
Field *fields = result->Fetch();
bar2.step();
bar.step();
uint32 entry = fields[0].GetUInt32();
int16 event_id = fields[1].GetInt16();
@@ -1029,8 +1028,9 @@ void GameEventMgr::LoadFromDB()
poollist.push_back(entry);
} while (result->NextRow());
sLog.outString(">> Loaded %u pools for game events in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
sLog.outString();
sLog.outString(">> Loaded %u pools in game events", count);
}
}
@@ -1064,7 +1064,6 @@ uint32 GameEventMgr::Initialize() // return the next e
{
m_ActiveEvents.clear();
uint32 delay = Update();
sLog.outBasic("Game Event system initialized.");
isSystemInit = true;
return delay;
}
@@ -1085,6 +1084,7 @@ void GameEventMgr::StartArenaSeason()
StartEvent(eventId,true);
sLog.outString("Arena Season %i started...",sWorld.getIntConfig(CONFIG_ARENA_SEASON_ID));
sLog.outString();
}
uint32 GameEventMgr::Update() // return the next event delay in ms
File diff suppressed because it is too large Load Diff
+1 -1
View File
@@ -1282,7 +1282,7 @@ class ObjectMgr
private:
void LoadScripts(ScriptsType type);
void CheckScripts(ScriptsType type, std::set<int32>& ids);
void LoadCreatureAddons(SQLStorage& creatureaddons, char const* entryName, char const* comment);
uint32 LoadCreatureAddons(SQLStorage& creatureaddons, char const* entryName);
void ConvertCreatureAddonAuras(CreatureDataAddon* addon, char const* table, char const* guidEntryStr);
void LoadQuestRelationsHelper(QuestRelations& map, std::string table, bool starter, bool go);
void PlayerCreateInfoAddItemHelper(uint32 race_, uint32 class_, uint32 itemId, int32 count);
@@ -253,6 +253,8 @@ void InstanceSaveManager::_DelHelper(const char *fields, const char *table, cons
void InstanceSaveManager::CleanupAndPackInstances()
{
uint32 oldMSTime = getMSTime();
// load reset times and clean expired instances
sInstanceSaveMgr.LoadResetTimes();
@@ -291,7 +293,8 @@ void InstanceSaveManager::CleanupAndPackInstances()
CharacterDatabase.DirectExecute("ALTER TABLE instance DROP COLUMN newid");
// Bake some cookies for click
sLog.outString(">> Cleaned up and packed instances");
sLog.outString(">> Cleaned up and packed instances in %u ms", GetMSTimeDiffToNow(oldMSTime));
sLog.outString();
}
void InstanceSaveManager::LoadResetTimes()
+192 -68
View File
@@ -91,79 +91,75 @@ void LootStore::Verify() const
// Loads a *_loot_template DB table into loot store
// All checks of the loaded template are called from here, no error reports at loot generation required
void LootStore::LoadLootTable()
uint32 LootStore::LoadLootTable()
{
LootTemplateMap::const_iterator tab;
// Clearing store (for reloading case)
Clear();
sLog.outString("%s :", GetName());
// 0 1 2 3 4 5 6
QueryResult result = WorldDatabase.PQuery("SELECT entry, item, ChanceOrQuestChance, lootmode, groupid, mincountOrRef, maxcount FROM %s", GetName());
// 0 1 2 3 4 5 6
QueryResult result = WorldDatabase.PQuery("SELECT entry, item, ChanceOrQuestChance, lootmode, groupid, mincountOrRef, maxcount FROM %s",GetName());
if (result)
if (!result)
{
uint32 count = 0;
barGoLink bar(1);
bar.step();
return 0;
}
barGoLink bar(result->GetRowCount());
uint32 count = 0;
barGoLink bar(result->GetRowCount());
do
do
{
Field *fields = result->Fetch();
bar.step();
uint32 entry = fields[0].GetUInt32();
uint32 item = fields[1].GetUInt32();
float chanceOrQuestChance = fields[2].GetFloat();
uint16 lootmode = fields[3].GetUInt16();
uint8 group = fields[4].GetUInt8();
int32 mincountOrRef = fields[5].GetInt32();
int32 maxcount = fields[6].GetInt32();
if (maxcount > std::numeric_limits<uint8>::max())
{
Field *fields = result->Fetch();
bar.step();
sLog.outErrorDb("Table '%s' entry %d item %d: maxcount value (%u) to large. must be less %u - skipped", GetName(), entry, item, maxcount,std::numeric_limits<uint8>::max());
continue; // error already printed to log/console.
}
uint32 entry = fields[0].GetUInt32();
uint32 item = fields[1].GetUInt32();
float chanceOrQuestChance = fields[2].GetFloat();
uint16 lootmode = fields[3].GetUInt16();
uint8 group = fields[4].GetUInt8();
int32 mincountOrRef = fields[5].GetInt32();
int32 maxcount = fields[6].GetInt32();
LootStoreItem storeitem = LootStoreItem(item, chanceOrQuestChance, lootmode, group, mincountOrRef, maxcount);
if (maxcount > std::numeric_limits<uint8>::max())
if (!storeitem.IsValid(*this,entry)) // Validity checks
continue;
// Looking for the template of the entry
// often entries are put together
if (m_LootTemplates.empty() || tab->first != entry)
{
// Searching the template (in case template Id changed)
tab = m_LootTemplates.find(entry);
if (tab == m_LootTemplates.end())
{
sLog.outErrorDb("Table '%s' entry %d item %d: maxcount value (%u) to large. must be less %u - skipped", GetName(), entry, item, maxcount,std::numeric_limits<uint8>::max());
continue; // error already printed to log/console.
std::pair< LootTemplateMap::iterator, bool > pr = m_LootTemplates.insert(LootTemplateMap::value_type(entry, new LootTemplate));
tab = pr.first;
}
}
// else is empty - template Id and iter are the same
// finally iter refers to already existed or just created <entry, LootTemplate>
LootStoreItem storeitem = LootStoreItem(item, chanceOrQuestChance, lootmode, group, mincountOrRef, maxcount);
// Adds current row to the template
tab->second->AddEntry(storeitem);
++count;
if (!storeitem.IsValid(*this,entry)) // Validity checks
continue;
// Looking for the template of the entry
// often entries are put together
if (m_LootTemplates.empty() || tab->first != entry)
{
// Searching the template (in case template Id changed)
tab = m_LootTemplates.find(entry);
if (tab == m_LootTemplates.end())
{
std::pair< LootTemplateMap::iterator, bool > pr = m_LootTemplates.insert(LootTemplateMap::value_type(entry, new LootTemplate));
tab = pr.first;
}
}
// else is empty - template Id and iter are the same
// finally iter refers to already existed or just created <entry, LootTemplate>
// Adds current row to the template
tab->second->AddEntry(storeitem);
++count;
} while (result->NextRow());
Verify(); // Checks validity of the loot store
sLog.outString();
sLog.outString(">> Loaded %u loot definitions (%lu templates)", count, (unsigned long)m_LootTemplates.size());
}
else
{
sLog.outString();
sLog.outErrorDb(">> Loaded 0 loot definitions. DB table `%s` is empty.",GetName());
}
while (result->NextRow());
Verify(); // Checks validity of the loot store
return count;
}
bool LootStore::HaveQuestLootFor(uint32 loot_id) const
@@ -215,12 +211,14 @@ LootTemplate* LootStore::GetLootForConditionFill(uint32 loot_id)
return tab->second;
}
void LootStore::LoadAndCollectLootIds(LootIdSet& ids_set)
uint32 LootStore::LoadAndCollectLootIds(LootIdSet& ids_set)
{
LoadLootTable();
uint32 count = LoadLootTable();
for (LootTemplateMap::const_iterator tab = m_LootTemplates.begin(); tab != m_LootTemplates.end(); ++tab)
ids_set.insert(tab->first);
return count;
}
void LootStore::CheckLootRefs(LootIdSet* ref_set) const
@@ -1407,8 +1405,12 @@ bool LootTemplate::isReference(uint32 id)
void LoadLootTemplates_Creature()
{
sLog.outString("Loading creature loot templates...");
uint32 oldMSTime = getMSTime();
LootIdSet ids_set, ids_setUsed;
LootTemplates_Creature.LoadAndCollectLootIds(ids_set);
uint32 count = LootTemplates_Creature.LoadAndCollectLootIds(ids_set);
// remove real entries and check existence loot
for (uint32 i = 1; i < sCreatureStorage.MaxEntry; ++i)
@@ -1429,12 +1431,23 @@ void LoadLootTemplates_Creature()
// output error for any still listed (not referenced from appropriate table) ids
LootTemplates_Creature.ReportUnusedIds(ids_set);
if(count)
sLog.outString(">> Loaded %u creature loot templates in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
else
sLog.outErrorDb(">> Loaded 0 creature loot templates. DB table `creature_loot_template` is empty");
sLog.outString();
}
void LoadLootTemplates_Disenchant()
{
sLog.outString("Loading disenchanting loot templates...");
uint32 oldMSTime = getMSTime();
LootIdSet ids_set, ids_setUsed;
LootTemplates_Disenchant.LoadAndCollectLootIds(ids_set);
uint32 count = LootTemplates_Disenchant.LoadAndCollectLootIds(ids_set);
// remove real entries and check existence loot
for (uint32 i = 1; i < sItemStorage.MaxEntry; ++i)
@@ -1454,12 +1467,22 @@ void LoadLootTemplates_Disenchant()
ids_set.erase(*itr);
// output error for any still listed (not referenced from appropriate table) ids
LootTemplates_Disenchant.ReportUnusedIds(ids_set);
if(count)
sLog.outString(">> Loaded %u disenchanting loot templates in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
else
sLog.outErrorDb(">> Loaded 0 disenchanting loot templates. DB table `disenchant_loot_template` is empty");
sLog.outString();
}
void LoadLootTemplates_Fishing()
{
sLog.outString("Loading fishing loot templates...");
uint32 oldMSTime = getMSTime();
LootIdSet ids_set;
LootTemplates_Fishing.LoadAndCollectLootIds(ids_set);
uint32 count = LootTemplates_Fishing.LoadAndCollectLootIds(ids_set);
// remove real entries and check existence loot
for (uint32 i = 1; i < sAreaStore.GetNumRows(); ++i)
@@ -1469,12 +1492,23 @@ void LoadLootTemplates_Fishing()
// output error for any still listed (not referenced from appropriate table) ids
LootTemplates_Fishing.ReportUnusedIds(ids_set);
if(count)
sLog.outString(">> Loaded %u fishing loot templates in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
else
sLog.outErrorDb(">> Loaded 0 fishing loot templates. DB table `fishing_loot_template` is empty");
sLog.outString();
}
void LoadLootTemplates_Gameobject()
{
sLog.outString("Loading gameobject loot templates...");
uint32 oldMSTime = getMSTime();
LootIdSet ids_set, ids_setUsed;
LootTemplates_Gameobject.LoadAndCollectLootIds(ids_set);
uint32 count = LootTemplates_Gameobject.LoadAndCollectLootIds(ids_set);
// remove real entries and check existence loot
for (uint32 i = 1; i < sGOStorage.MaxEntry; ++i)
@@ -1495,12 +1529,23 @@ void LoadLootTemplates_Gameobject()
// output error for any still listed (not referenced from appropriate table) ids
LootTemplates_Gameobject.ReportUnusedIds(ids_set);
if(count)
sLog.outString(">> Loaded %u gameobject loot templates in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
else
sLog.outErrorDb(">> Loaded 0 gameobject loot templates. DB table `gameobject_loot_template` is empty");
sLog.outString();
}
void LoadLootTemplates_Item()
{
sLog.outString("Loading item loot templates...");
uint32 oldMSTime = getMSTime();
LootIdSet ids_set;
LootTemplates_Item.LoadAndCollectLootIds(ids_set);
uint32 count = LootTemplates_Item.LoadAndCollectLootIds(ids_set);
// remove real entries and check existence loot
for (uint32 i = 1; i < sItemStorage.MaxEntry; ++i)
@@ -1510,12 +1555,23 @@ void LoadLootTemplates_Item()
// output error for any still listed (not referenced from appropriate table) ids
LootTemplates_Item.ReportUnusedIds(ids_set);
if(count)
sLog.outString(">> Loaded %u prospecting loot templates in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
else
sLog.outErrorDb(">> Loaded 0 prospecting loot templates. DB table `item_loot_template` is empty");
sLog.outString();
}
void LoadLootTemplates_Milling()
{
sLog.outString("Loading milling loot templates...");
uint32 oldMSTime = getMSTime();
LootIdSet ids_set;
LootTemplates_Milling.LoadAndCollectLootIds(ids_set);
uint32 count = LootTemplates_Milling.LoadAndCollectLootIds(ids_set);
// remove real entries and check existence loot
for (uint32 i = 1; i < sItemStorage.MaxEntry; ++i)
@@ -1533,12 +1589,23 @@ void LoadLootTemplates_Milling()
// output error for any still listed (not referenced from appropriate table) ids
LootTemplates_Milling.ReportUnusedIds(ids_set);
if(count)
sLog.outString(">> Loaded %u milling loot templates in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
else
sLog.outErrorDb(">> Loaded 0 milling loot templates. DB table `milling_loot_template` is empty");
sLog.outString();
}
void LoadLootTemplates_Pickpocketing()
{
sLog.outString("Loading pickpocketing loot templates...");
uint32 oldMSTime = getMSTime();
LootIdSet ids_set, ids_setUsed;
LootTemplates_Pickpocketing.LoadAndCollectLootIds(ids_set);
uint32 count = LootTemplates_Pickpocketing.LoadAndCollectLootIds(ids_set);
// remove real entries and check existence loot
for (uint32 i = 1; i < sCreatureStorage.MaxEntry; ++i)
@@ -1559,12 +1626,23 @@ void LoadLootTemplates_Pickpocketing()
// output error for any still listed (not referenced from appropriate table) ids
LootTemplates_Pickpocketing.ReportUnusedIds(ids_set);
if(count)
sLog.outString(">> Loaded %u pickpocketing loot templates in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
else
sLog.outErrorDb(">> Loaded 0 pickpocketing loot templates. DB table `pickpocketing_loot_template` is empty");
sLog.outString();
}
void LoadLootTemplates_Prospecting()
{
sLog.outString("Loading prospecting loot templates...");
uint32 oldMSTime = getMSTime();
LootIdSet ids_set;
LootTemplates_Prospecting.LoadAndCollectLootIds(ids_set);
uint32 count = LootTemplates_Prospecting.LoadAndCollectLootIds(ids_set);
// remove real entries and check existence loot
for (uint32 i = 1; i < sItemStorage.MaxEntry; ++i)
@@ -1582,12 +1660,23 @@ void LoadLootTemplates_Prospecting()
// output error for any still listed (not referenced from appropriate table) ids
LootTemplates_Prospecting.ReportUnusedIds(ids_set);
if(count)
sLog.outString(">> Loaded %u prospecting loot templates in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
else
sLog.outErrorDb(">> Loaded 0 prospecting loot templates. DB table `prospecting_loot_template` is empty");
sLog.outString();
}
void LoadLootTemplates_Mail()
{
sLog.outString("Loading mail loot templates...");
uint32 oldMSTime = getMSTime();
LootIdSet ids_set;
LootTemplates_Mail.LoadAndCollectLootIds(ids_set);
uint32 count = LootTemplates_Mail.LoadAndCollectLootIds(ids_set);
// remove real entries and check existence loot
for (uint32 i = 1; i < sMailTemplateStore.GetNumRows(); ++i)
@@ -1597,12 +1686,23 @@ void LoadLootTemplates_Mail()
// output error for any still listed (not referenced from appropriate table) ids
LootTemplates_Mail.ReportUnusedIds(ids_set);
if(count)
sLog.outString(">> Loaded %u mail loot templates in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
else
sLog.outErrorDb(">> Loaded 0 mail loot templates. DB table `mail_loot_template` is empty");
sLog.outString();
}
void LoadLootTemplates_Skinning()
{
sLog.outString("Loading skinning loot templates...");
uint32 oldMSTime = getMSTime();
LootIdSet ids_set, ids_setUsed;
LootTemplates_Skinning.LoadAndCollectLootIds(ids_set);
uint32 count = LootTemplates_Skinning.LoadAndCollectLootIds(ids_set);
// remove real entries and check existence loot
for (uint32 i = 1; i < sCreatureStorage.MaxEntry; ++i)
@@ -1623,12 +1723,23 @@ void LoadLootTemplates_Skinning()
// output error for any still listed (not referenced from appropriate table) ids
LootTemplates_Skinning.ReportUnusedIds(ids_set);
if(count)
sLog.outString(">> Loaded %u skinning loot templates in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
else
sLog.outErrorDb(">> Loaded 0 skinning loot templates. DB table `skinning_loot_template` is empty");
sLog.outString();
}
void LoadLootTemplates_Spell()
{
sLog.outString("Loading spell loot templates...");
uint32 oldMSTime = getMSTime();
LootIdSet ids_set;
LootTemplates_Spell.LoadAndCollectLootIds(ids_set);
uint32 count = LootTemplates_Spell.LoadAndCollectLootIds(ids_set);
// remove real entries and check existence loot
for (uint32 spell_id = 1; spell_id < sSpellStore.GetNumRows(); ++spell_id)
@@ -1656,10 +1767,20 @@ void LoadLootTemplates_Spell()
// output error for any still listed (not referenced from appropriate table) ids
LootTemplates_Spell.ReportUnusedIds(ids_set);
if(count)
sLog.outString(">> Loaded %u spell loot templates in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
else
sLog.outErrorDb(">> Loaded 0 spell loot templates. DB table `spell_loot_template` is empty");
sLog.outString();
}
void LoadLootTemplates_Reference()
{
sLog.outString("Loading reference loot templates...");
uint32 oldMSTime = getMSTime();
LootIdSet ids_set;
LootTemplates_Reference.LoadAndCollectLootIds(ids_set);
@@ -1678,4 +1799,7 @@ void LoadLootTemplates_Reference()
// output error for any still listed ids (not referenced from any loot table)
LootTemplates_Reference.ReportUnusedIds(ids_set);
sLog.outString(">> Loaded refence loot templates in %u ms", GetMSTimeDiffToNow(oldMSTime));
sLog.outString();
}
+2 -2
View File
@@ -183,7 +183,7 @@ class LootStore
void Verify() const;
void LoadAndCollectLootIds(LootIdSet& ids_set);
uint32 LoadAndCollectLootIds(LootIdSet& ids_set);
void CheckLootRefs(LootIdSet* ref_set = NULL) const; // check existence reference and remove it from ref_set
void ReportUnusedIds(LootIdSet const& ids_set) const;
void ReportNotExistedId(uint32 id) const;
@@ -200,7 +200,7 @@ class LootStore
char const* GetEntryName() const { return m_entryName; }
bool IsRatesAllowed() const { return m_ratesAllowed; }
protected:
void LoadLootTable();
uint32 LoadLootTable();
void Clear();
private:
LootTemplateMap m_LootTemplates;
@@ -36,28 +36,24 @@ void WaypointStore::Free()
void WaypointStore::Load()
{
QueryResult result = WorldDatabase.Query("SELECT COUNT(id) FROM waypoint_data");
uint32 oldMSTime = getMSTime();
QueryResult result = WorldDatabase.Query("SELECT id,point,position_x,position_y,position_z,move_flag,delay,action,action_chance FROM waypoint_data ORDER BY id, point");
if (!result)
{
sLog.outError("an error occured while loading the table `waypoint_data` (maybe it doesn't exist ?)");
exit(1); // Stop server at loading non exited table or not accessable table
}
records = (*result)[0].GetUInt32();
result = WorldDatabase.Query("SELECT id,point,position_x,position_y,position_z,move_flag,delay,action,action_chance FROM waypoint_data ORDER BY id, point");
if (!result)
{
sLog.outErrorDb("The table `waypoint_data` is empty or corrupted");
barGoLink bar(1);
bar.step();
sLog.outErrorDb(">> Loaded 0 waypoints. DB table `waypoint_data` is empty!");
sLog.outString();
return;
}
WaypointPath* path_data = NULL;
barGoLink bar(result->GetRowCount());
uint32 count = 0;
Field *fields;
uint32 last_id = 0;
WaypointPath* path_data = NULL;
do
{
@@ -94,10 +90,11 @@ void WaypointStore::Load()
last_id = id;
} while (result->NextRow()) ;
}
while (result->NextRow()) ;
sLog.outString(">> Loaded %u waypoints in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
sLog.outString();
sLog.outString(">> Loaded %u waypoints", count);
}
void WaypointStore::UpdatePath(uint32 id)
+32 -38
View File
@@ -40,40 +40,7 @@ OutdoorPvPMgr::~OutdoorPvPMgr()
void OutdoorPvPMgr::InitOutdoorPvP()
{
LoadTemplates();
OutdoorPvP* pvp;
for (uint8 i = 1; i < MAX_OUTDOORPVP_TYPES; ++i)
{
OutdoorPvPDataMap::iterator iter = m_OutdoorPvPDatas.find(OutdoorPvPTypes(i));
if (iter == m_OutdoorPvPDatas.end())
{
sLog.outErrorDb("Could not initialize OutdoorPvP object for type ID %u; no entry in database.", uint32(i));
continue;
}
pvp = sScriptMgr.CreateOutdoorPvP(iter->second);
if (!pvp)
{
sLog.outError("Could not initialize OutdoorPvP object for type ID %u; got NULL pointer from script.", uint32(i));
continue;
}
if (!pvp->SetupOutdoorPvP())
{
sLog.outError("Could not initialize OutdoorPvP object for type ID %u; SetupOutdoorPvP failed.", uint32(i));
delete pvp;
continue;
}
m_OutdoorPvPSet.push_back(pvp);
}
}
void OutdoorPvPMgr::LoadTemplates()
{
uint32 typeId = 0;
uint32 count = 0;
uint32 oldMSTime = getMSTime();
// 0 1
QueryResult result = WorldDatabase.Query("SELECT TypeId, ScriptName FROM outdoorpvp_template");
@@ -81,15 +48,15 @@ void OutdoorPvPMgr::LoadTemplates()
if (!result)
{
barGoLink bar(1);
bar.step();
sLog.outString();
sLog.outErrorDb(">> Loaded 0 outdoor PvP definitions. DB table `outdoorpvp_template` is empty.");
sLog.outString();
return;
}
barGoLink bar(result->GetRowCount());
uint32 count = 0;
uint32 typeId = 0;
do
{
@@ -117,8 +84,35 @@ void OutdoorPvPMgr::LoadTemplates()
}
while (result->NextRow());
OutdoorPvP* pvp;
for (uint8 i = 1; i < MAX_OUTDOORPVP_TYPES; ++i)
{
OutdoorPvPDataMap::iterator iter = m_OutdoorPvPDatas.find(OutdoorPvPTypes(i));
if (iter == m_OutdoorPvPDatas.end())
{
sLog.outErrorDb("Could not initialize OutdoorPvP object for type ID %u; no entry in database.", uint32(i));
continue;
}
pvp = sScriptMgr.CreateOutdoorPvP(iter->second);
if (!pvp)
{
sLog.outError("Could not initialize OutdoorPvP object for type ID %u; got NULL pointer from script.", uint32(i));
continue;
}
if (!pvp->SetupOutdoorPvP())
{
sLog.outError("Could not initialize OutdoorPvP object for type ID %u; SetupOutdoorPvP failed.", uint32(i));
delete pvp;
continue;
}
m_OutdoorPvPSet.push_back(pvp);
}
sLog.outString(">> Loaded %u outdoor PvP definitions in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
sLog.outString();
sLog.outString(">> Loaded %u outdoor PvP definitions.", count);
}
void OutdoorPvPMgr::AddZone(uint32 zoneid, OutdoorPvP *handle)
@@ -49,9 +49,6 @@ class OutdoorPvPMgr
// create outdoor pvp events
void InitOutdoorPvP();
// loads outdoorpvp_template
void LoadTemplates();
// called when a player enters an outdoor pvp area
void HandlePlayerEnterZone(Player * plr, uint32 areaflag);
+20 -16
View File
@@ -543,10 +543,12 @@ PoolMgr::PoolMgr()
void PoolMgr::LoadFromDB()
{
uint32 oldMSTime = getMSTime();
QueryResult result = WorldDatabase.Query("SELECT MAX(entry) FROM pool_template");
if (!result)
{
sLog.outString(">> Table pool_template is empty.");
sLog.outString(">> Loaded 0 object pools. DB table `pool_template` is empty.");
sLog.outString();
return;
}
@@ -562,7 +564,7 @@ void PoolMgr::LoadFromDB()
if (!result)
{
mPoolTemplate.clear();
sLog.outString(">> Table pool_template is empty:");
sLog.outString(">> Loaded 0 object pools. DB table `pool_template` is empty.");
sLog.outString();
return;
}
@@ -584,13 +586,13 @@ void PoolMgr::LoadFromDB()
} while (result->NextRow());
sLog.outString(">> Loaded %u objects pools in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
sLog.outString();
sLog.outString(">> Loaded %u objects pools", count);
// Creatures
sLog.outString();
sLog.outString("Loading Creatures Pooling Data...");
oldMSTime = getMSTime();
mPoolCreatureGroups.resize(max_pool_id + 1);
mCreatureSearchMap.clear();
@@ -602,9 +604,8 @@ void PoolMgr::LoadFromDB()
{
barGoLink bar2(1);
bar2.step();
sLog.outString(">> Loaded 0 creatures in pools. DB table `pool_creature` is empty.");
sLog.outString();
sLog.outString(">> Loaded %u creatures in pools", count);
}
else
{
@@ -647,8 +648,10 @@ void PoolMgr::LoadFromDB()
mCreatureSearchMap.insert(p);
} while (result->NextRow());
sLog.outString(">> Loaded %u creatures in pools in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
sLog.outString();
sLog.outString(">> Loaded %u creatures in pools", count);
}
// Gameobjects
@@ -665,9 +668,8 @@ void PoolMgr::LoadFromDB()
{
barGoLink bar2(1);
bar2.step();
sLog.outString(">> Loaded 0 gameobjects in pools. DB table `pool_gameobject` is empty.");
sLog.outString();
sLog.outString(">> Loaded %u gameobject in pools", count);
}
else
{
@@ -719,13 +721,15 @@ void PoolMgr::LoadFromDB()
mGameobjectSearchMap.insert(p);
} while (result->NextRow());
sLog.outString(">> Loaded %u gameobject in pools in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
sLog.outString();
sLog.outString(">> Loaded %u gameobject in pools", count);
}
// Pool of pools
sLog.outString("Loading Mother Pooling Data...");
oldMSTime = getMSTime();
mPoolPoolGroups.resize(max_pool_id + 1);
// 1 2 3
@@ -736,9 +740,8 @@ void PoolMgr::LoadFromDB()
{
barGoLink bar2(1);
bar2.step();
sLog.outString(">> Loaded 0 pools in pools");
sLog.outString();
sLog.outString(">> Loaded %u pools in pools", count);
}
else
{
@@ -811,13 +814,15 @@ void PoolMgr::LoadFromDB()
}
}
sLog.outString(">> Loaded %u pools in mother pools in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
sLog.outString();
sLog.outString(">> Loaded %u pools in mother pools", count);
}
}
void PoolMgr::LoadQuestPools()
{
uint32 oldMSTime = getMSTime();
PreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_LOAD_QUEST_POOLS);
PreparedQueryResult result = WorldDatabase.Query(stmt);
@@ -829,9 +834,8 @@ void PoolMgr::LoadQuestPools()
{
barGoLink bar(1);
bar.step();
sLog.outString();
sLog.outString(">> Loaded 0 quests in pools");
sLog.outString();
return;
}
@@ -910,8 +914,8 @@ void PoolMgr::LoadQuestPools()
}
while (result->NextRow());
sLog.outString(">> Loaded %u quests in pools in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
sLog.outString();
sLog.outString(">> Loaded %u quests in pools", count);
}
// 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
+5 -3
View File
@@ -178,17 +178,19 @@ ScriptMgr::~ScriptMgr()
void ScriptMgr::Initialize()
{
uint32 oldMSTime = getMSTime();
LoadDatabase();
sLog.outString("Loading C++ scripts");
barGoLink bar(1);
bar.step();
sLog.outString();
FillSpellSummary();
AddScripts();
sLog.outString(">> Loaded %u C++ scripts", GetScriptCount());
sLog.outString(">> Loaded %u C++ scripts in %u ms", GetScriptCount(), GetMSTimeDiffToNow(oldMSTime));
sLog.outString();
}
void ScriptMgr::LoadDatabase()
+146 -146
View File
@@ -55,66 +55,66 @@ void SystemMgr::LoadScriptTexts()
{
sLog.outString("TSCR: Loading Script Texts...");
LoadTrinityStrings("script_texts",TEXT_SOURCE_RANGE,1+(TEXT_SOURCE_RANGE*2));
QueryResult Result = WorldDatabase.Query("SELECT entry, sound, type, language, emote FROM script_texts");
sLog.outString("TSCR: Loading Script Texts additional data...");
uint32 oldMSTime = getMSTime();
if (Result)
{
barGoLink bar(Result->GetRowCount());
uint32 uiCount = 0;
QueryResult result = WorldDatabase.Query("SELECT entry, sound, type, language, emote FROM script_texts");
do
{
bar.step();
Field* pFields = Result->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)
{
sLog.outErrorDb("TSCR: Entry %i in table `script_texts` is not a negative value.", iId);
continue;
}
if (iId > TEXT_SOURCE_RANGE || iId <= TEXT_SOURCE_RANGE*2)
{
sLog.outErrorDb("TSCR: Entry %i in table `script_texts` is out of accepted entry range for table.", iId);
continue;
}
if (pTemp.uiSoundId)
{
if (!GetSoundEntriesStore()->LookupEntry(pTemp.uiSoundId))
sLog.outErrorDb("TSCR: Entry %i in table `script_texts` has soundId %u but sound does not exist.", iId, pTemp.uiSoundId);
}
if (!GetLanguageDescByID(pTemp.uiLanguage))
sLog.outErrorDb("TSCR: Entry %i in table `script_texts` using Language %u but Language does not exist.", iId, pTemp.uiLanguage);
if (pTemp.uiType > CHAT_TYPE_ZONE_YELL)
sLog.outErrorDb("TSCR: 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 (Result->NextRow());
sLog.outString();
sLog.outString(">> Loaded %u additional Script Texts data.", uiCount);
}
else
if (!result)
{
barGoLink bar(1);
bar.step();
sLog.outString();
sLog.outString(">> Loaded 0 additional Script Texts data. DB table `script_texts` is empty.");
sLog.outString();
return;
}
barGoLink bar(result->GetRowCount());
uint32 uiCount = 0;
do
{
bar.step();
Field* pFields = result->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)
{
sLog.outErrorDb("TSCR: Entry %i in table `script_texts` is not a negative value.", iId);
continue;
}
if (iId > TEXT_SOURCE_RANGE || iId <= TEXT_SOURCE_RANGE*2)
{
sLog.outErrorDb("TSCR: Entry %i in table `script_texts` is out of accepted entry range for table.", iId);
continue;
}
if (pTemp.uiSoundId)
{
if (!GetSoundEntriesStore()->LookupEntry(pTemp.uiSoundId))
sLog.outErrorDb("TSCR: Entry %i in table `script_texts` has soundId %u but sound does not exist.", iId, pTemp.uiSoundId);
}
if (!GetLanguageDescByID(pTemp.uiLanguage))
sLog.outErrorDb("TSCR: Entry %i in table `script_texts` using Language %u but Language does not exist.", iId, pTemp.uiLanguage);
if (pTemp.uiType > CHAT_TYPE_ZONE_YELL)
sLog.outErrorDb("TSCR: 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 (result->NextRow());
sLog.outString(">> Loaded %u additional Script Texts data in %u ms", uiCount, GetMSTimeDiffToNow(oldMSTime));
sLog.outString();
}
void SystemMgr::LoadScriptTextsCustom()
@@ -122,125 +122,125 @@ void SystemMgr::LoadScriptTextsCustom()
sLog.outString("TSCR: Loading Custom Texts...");
LoadTrinityStrings("custom_texts",TEXT_SOURCE_RANGE*2,1+(TEXT_SOURCE_RANGE*3));
QueryResult Result = WorldDatabase.Query("SELECT entry, sound, type, language, emote FROM custom_texts");
sLog.outString("TSCR: Loading Custom Texts additional data...");
if (Result)
{
barGoLink bar(Result->GetRowCount());
uint32 uiCount = 0;
QueryResult result = WorldDatabase.Query("SELECT entry, sound, type, language, emote FROM custom_texts");
do
{
bar.step();
Field* pFields = Result->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)
{
sLog.outErrorDb("TSCR: Entry %i in table `custom_texts` is not a negative value.", iId);
continue;
}
if (iId > TEXT_SOURCE_RANGE*2 || iId <= TEXT_SOURCE_RANGE*3)
{
sLog.outErrorDb("TSCR: Entry %i in table `custom_texts` is out of accepted entry range for table.", iId);
continue;
}
if (pTemp.uiSoundId)
{
if (!GetSoundEntriesStore()->LookupEntry(pTemp.uiSoundId))
sLog.outErrorDb("TSCR: Entry %i in table `custom_texts` has soundId %u but sound does not exist.", iId, pTemp.uiSoundId);
}
if (!GetLanguageDescByID(pTemp.uiLanguage))
sLog.outErrorDb("TSCR: Entry %i in table `custom_texts` using Language %u but Language does not exist.", iId, pTemp.uiLanguage);
if (pTemp.uiType > CHAT_TYPE_ZONE_YELL)
sLog.outErrorDb("TSCR: Entry %i in table `custom_texts` has Type %u but this Chat Type does not exist.", iId, pTemp.uiType);
m_mTextDataMap[iId] = pTemp;
++uiCount;
} while (Result->NextRow());
sLog.outString();
sLog.outString(">> Loaded %u additional Custom Texts data.", uiCount);
}
else
if (!result)
{
barGoLink bar(1);
bar.step();
sLog.outString();
sLog.outString(">> Loaded 0 additional Custom Texts data. DB table `custom_texts` is empty.");
sLog.outString();
return;
}
barGoLink bar(result->GetRowCount());
uint32 uiCount = 0;
do
{
bar.step();
Field* pFields = result->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)
{
sLog.outErrorDb("TSCR: Entry %i in table `custom_texts` is not a negative value.", iId);
continue;
}
if (iId > TEXT_SOURCE_RANGE*2 || iId <= TEXT_SOURCE_RANGE*3)
{
sLog.outErrorDb("TSCR: Entry %i in table `custom_texts` is out of accepted entry range for table.", iId);
continue;
}
if (pTemp.uiSoundId)
{
if (!GetSoundEntriesStore()->LookupEntry(pTemp.uiSoundId))
sLog.outErrorDb("TSCR: Entry %i in table `custom_texts` has soundId %u but sound does not exist.", iId, pTemp.uiSoundId);
}
if (!GetLanguageDescByID(pTemp.uiLanguage))
sLog.outErrorDb("TSCR: Entry %i in table `custom_texts` using Language %u but Language does not exist.", iId, pTemp.uiLanguage);
if (pTemp.uiType > CHAT_TYPE_ZONE_YELL)
sLog.outErrorDb("TSCR: Entry %i in table `custom_texts` has Type %u but this Chat Type does not exist.", iId, pTemp.uiType);
m_mTextDataMap[iId] = pTemp;
++uiCount;
} while (result->NextRow());
sLog.outString(">> Loaded %u additional Custom Texts data.", uiCount);
sLog.outString();
}
void SystemMgr::LoadScriptWaypoints()
{
uint32 oldMSTime = getMSTime();
// Drop Existing Waypoint list
m_mPointMoveMap.clear();
uint64 uiCreatureCount = 0;
// Load Waypoints
QueryResult Result = WorldDatabase.Query("SELECT COUNT(entry) FROM script_waypoint GROUP BY entry");
if (Result)
uiCreatureCount = Result->GetRowCount();
QueryResult result = WorldDatabase.Query("SELECT COUNT(entry) FROM script_waypoint GROUP BY entry");
if (result)
uiCreatureCount = result->GetRowCount();
sLog.outString("TSCR: Loading Script Waypoints for " UI64FMTD " creature(s)...", uiCreatureCount);
Result = WorldDatabase.Query("SELECT entry, pointid, location_x, location_y, location_z, waittime FROM script_waypoint ORDER BY pointid");
result = WorldDatabase.Query("SELECT entry, pointid, location_x, location_y, location_z, waittime FROM script_waypoint ORDER BY pointid");
if (Result)
{
barGoLink bar(Result->GetRowCount());
uint32 uiNodeCount = 0;
do
{
bar.step();
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();
CreatureInfo 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
if (!result)
{
barGoLink bar(1);
bar.step();
sLog.outString();
sLog.outString(">> Loaded 0 Script Waypoints. DB table `script_waypoint` is empty.");
sLog.outString();
return;
}
barGoLink bar(result->GetRowCount());
uint32 count = 0;
do
{
bar.step();
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();
CreatureInfo 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);
++count;
} while (result->NextRow());
sLog.outString(">> Loaded %u Script Waypoint nodes in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
sLog.outString();
}
+8 -5
View File
@@ -46,22 +46,24 @@ static SkillDiscoveryMap SkillDiscoveryStore;
void LoadSkillDiscoveryTable()
{
uint32 oldMSTime = getMSTime();
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)
{
barGoLink bar(1);
bar.step();
sLog.outErrorDb(">> Loaded 0 skill discovery definitions. DB table `skill_discovery_template` is empty.");
sLog.outString();
sLog.outString(">> Loaded 0 skill discovery definitions. DB table `skill_discovery_template` is empty.");
return;
}
barGoLink bar(result->GetRowCount());
uint32 count = 0;
std::ostringstream ssNonDiscoverableEntries;
std::set<uint32> reportedReqSpells;
@@ -135,8 +137,6 @@ void LoadSkillDiscoveryTable()
++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());
@@ -154,6 +154,9 @@ void LoadSkillDiscoveryTable()
if (SkillDiscoveryStore.find(spell_id) == SkillDiscoveryStore.end())
sLog.outErrorDb("Spell (ID: %u) is 100%% chance random discovery ability but not have data in `skill_discovery_template` table",spell_id);
}
sLog.outString(">> Loaded %u skill discovery definitions in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
sLog.outString();
}
uint32 GetExplicitDiscoverySpell(uint32 spellId, Player* player)
+49 -46
View File
@@ -52,68 +52,71 @@ SkillExtraItemMap SkillExtraItemStore;
// loads the extra item creation info from DB
void LoadSkillExtraItemTable()
{
uint32 oldMSTime = getMSTime();
SkillExtraItemStore.clear(); // need for reload
// 0 1 2 3
QueryResult result = WorldDatabase.Query("SELECT spellId, requiredSpecialization, additionalCreateChance, additionalMaxNum FROM skill_extra_item_template");
if (result)
if (!result)
{
uint32 count = 0;
barGoLink bar(1);
bar.step();
sLog.outErrorDb(">> Loaded 0 spell specialization definitions. DB table `skill_extra_item_template` is empty.");
sLog.outString();
return;
}
barGoLink bar(result->GetRowCount());
barGoLink bar(result->GetRowCount());
uint32 count = 0;
do
do
{
Field *fields = result->Fetch();
bar.step();
uint32 spellId = fields[0].GetUInt32();
if (!sSpellStore.LookupEntry(spellId))
{
Field *fields = result->Fetch();
bar.step();
sLog.outError("Skill specialization %u has non-existent spell id in `skill_extra_item_template`!", spellId);
continue;
}
uint32 spellId = fields[0].GetUInt32();
uint32 requiredSpecialization = fields[1].GetUInt32();
if (!sSpellStore.LookupEntry(requiredSpecialization))
{
sLog.outError("Skill specialization %u have not existed required specialization spell id %u in `skill_extra_item_template`!", spellId,requiredSpecialization);
continue;
}
if (!sSpellStore.LookupEntry(spellId))
{
sLog.outError("Skill specialization %u has non-existent spell id in `skill_extra_item_template`!", spellId);
continue;
}
float additionalCreateChance = fields[2].GetFloat();
if (additionalCreateChance <= 0.0f)
{
sLog.outError("Skill specialization %u has too low additional create chance in `skill_extra_item_template`!", spellId);
continue;
}
uint32 requiredSpecialization = fields[1].GetUInt32();
if (!sSpellStore.LookupEntry(requiredSpecialization))
{
sLog.outError("Skill specialization %u have not existed required specialization spell id %u in `skill_extra_item_template`!", spellId,requiredSpecialization);
continue;
}
uint8 additionalMaxNum = fields[3].GetUInt8();
if (!additionalMaxNum)
{
sLog.outError("Skill specialization %u has 0 max number of extra items in `skill_extra_item_template`!", spellId);
continue;
}
float additionalCreateChance = fields[2].GetFloat();
if (additionalCreateChance <= 0.0f)
{
sLog.outError("Skill specialization %u has too low additional create chance in `skill_extra_item_template`!", spellId);
continue;
}
SkillExtraItemEntry& skillExtraItemEntry = SkillExtraItemStore[spellId];
uint8 additionalMaxNum = fields[3].GetUInt8();
if (!additionalMaxNum)
{
sLog.outError("Skill specialization %u has 0 max number of extra items in `skill_extra_item_template`!", spellId);
continue;
}
skillExtraItemEntry.requiredSpecialization = requiredSpecialization;
skillExtraItemEntry.additionalCreateChance = additionalCreateChance;
skillExtraItemEntry.additionalMaxNum = additionalMaxNum;
SkillExtraItemEntry& skillExtraItemEntry = SkillExtraItemStore[spellId];
skillExtraItemEntry.requiredSpecialization = requiredSpecialization;
skillExtraItemEntry.additionalCreateChance = additionalCreateChance;
skillExtraItemEntry.additionalMaxNum = additionalMaxNum;
++count;
} while (result->NextRow());
sLog.outString();
sLog.outString(">> Loaded %u spell specialization definitions", count);
}
else
{
sLog.outString();
sLog.outString(">> Loaded 0 spell specialization definitions. DB table `skill_extra_item_template` is empty.");
++count;
}
while (result->NextRow());
sLog.outString(">> Loaded %u spell specialization definitions in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
sLog.outString();
}
bool canCreateExtraItems(Player * player, uint32 spellId, float &additionalChance, uint8 &additionalMax)
+86 -51
View File
@@ -1114,25 +1114,23 @@ SpellCastResult GetErrorAtShapeshiftedCast (SpellEntry const *spellInfo, uint32
void SpellMgr::LoadSpellTargetPositions()
{
mSpellTargetPositions.clear(); // need for reload case
uint32 oldMSTime = getMSTime();
uint32 count = 0;
mSpellTargetPositions.clear(); // need for reload case
// 0 1 2 3 4 5
QueryResult result = WorldDatabase.Query("SELECT id, target_map, target_position_x, target_position_y, target_position_z, target_orientation FROM spell_target_position");
if (!result)
{
barGoLink bar(1);
bar.step();
sLog.outString(">> Loaded 0 spell target coordinates. DB table `spell_target_position` is empty.");
sLog.outString();
sLog.outString(">> Loaded %u spell target coordinates", count);
return;
}
barGoLink bar(result->GetRowCount());
uint32 count = 0;
do
{
@@ -1235,8 +1233,8 @@ void SpellMgr::LoadSpellTargetPositions()
}
}
sLog.outString(">> Loaded %u spell teleport coordinates in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
sLog.outString();
sLog.outString(">> Loaded %u spell teleport coordinates", count);
}
bool SpellMgr::IsAffectedByMod(SpellEntry const *spellInfo, SpellModifier *mod) const
@@ -1259,6 +1257,8 @@ bool SpellMgr::IsAffectedByMod(SpellEntry const *spellInfo, SpellModifier *mod)
void SpellMgr::LoadSpellProcEvents()
{
uint32 oldMSTime = getMSTime();
mSpellProcEventMap.clear(); // need for reload case
uint32 count = 0;
@@ -1269,8 +1269,8 @@ void SpellMgr::LoadSpellProcEvents()
{
barGoLink bar(1);
bar.step();
sLog.outString();
sLog.outString(">> Loaded %u spell proc event conditions", count);
sLog.outString();
return;
}
@@ -1318,15 +1318,17 @@ void SpellMgr::LoadSpellProcEvents()
++count;
} while (result->NextRow());
sLog.outString();
if (customProc)
sLog.outString(">> Loaded %u extra spell proc event conditions + %u custom", count, customProc);
sLog.outString(">> Loaded %u extra and %u custom spell proc event conditions in %u ms", count, customProc, GetMSTimeDiffToNow(oldMSTime));
else
sLog.outString(">> Loaded %u extra spell proc event conditions", count);
sLog.outString(">> Loaded %u extra spell proc event conditions in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
sLog.outString();
}
void SpellMgr::LoadSpellBonusess()
{
uint32 oldMSTime = getMSTime();
mSpellBonusMap.clear(); // need for reload case
uint32 count = 0;
// 0 1 2 3 4
@@ -1335,8 +1337,8 @@ void SpellMgr::LoadSpellBonusess()
{
barGoLink bar(1);
bar.step();
sLog.outString();
sLog.outString(">> Loaded %u spell bonus data", count);
sLog.outString();
return;
}
@@ -1365,8 +1367,8 @@ void SpellMgr::LoadSpellBonusess()
++count;
} while (result->NextRow());
sLog.outString(">> Loaded %u extra spell bonus data in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
sLog.outString();
sLog.outString(">> Loaded %u extra spell bonus data", count);
}
bool SpellMgr::IsSpellProcEventCanTriggeredBy(SpellProcEventEntry const* spellProcEvent, uint32 EventProcFlag, SpellEntry const * procSpell, uint32 procFlags, uint32 procExtra, bool active)
@@ -1500,6 +1502,8 @@ bool SpellMgr::IsSpellProcEventCanTriggeredBy(SpellProcEventEntry const* spellPr
void SpellMgr::LoadSpellGroups()
{
uint32 oldMSTime = getMSTime();
mSpellSpellGroup.clear(); // need for reload case
mSpellGroupSpell.clear();
@@ -1585,12 +1589,14 @@ void SpellMgr::LoadSpellGroups()
}
}
sLog.outString(">> Loaded %u spell group definitions in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
sLog.outString();
sLog.outString(">> Loaded %u spell group definitions", count);
}
void SpellMgr::LoadSpellGroupStackRules()
{
uint32 oldMSTime = getMSTime();
mSpellGroupStack.clear(); // need for reload case
uint32 count = 0;
@@ -1599,13 +1605,12 @@ void SpellMgr::LoadSpellGroupStackRules()
QueryResult result = WorldDatabase.Query("SELECT group_id, stack_rule FROM spell_group_stack_rules");
if (!result)
{
barGoLink bar(1);
bar.step();
sLog.outString(">> Loaded 0 spell group stack rules");
sLog.outString();
sLog.outString(">> Loaded %u spell group stack rules", count);
return;
}
@@ -1638,12 +1643,14 @@ void SpellMgr::LoadSpellGroupStackRules()
++count;
} while (result->NextRow());
sLog.outString(">> Loaded %u spell group stack rules in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
sLog.outString();
sLog.outString(">> Loaded %u spell group stack rules", count);
}
void SpellMgr::LoadSpellThreats()
{
uint32 oldMSTime = getMSTime();
mSpellThreatMap.clear(); // need for reload case
uint32 count = 0;
@@ -1657,8 +1664,8 @@ void SpellMgr::LoadSpellThreats()
bar.step();
sLog.outString();
sLog.outString(">> Loaded %u aggro generating spells", count);
sLog.outString();
return;
}
@@ -1684,8 +1691,8 @@ void SpellMgr::LoadSpellThreats()
++count;
} while (result->NextRow());
sLog.outString(">> Loaded %u aggro generating spells in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
sLog.outString();
sLog.outString(">> Loaded %u aggro generating spells", count);
}
bool SpellMgr::IsRankSpellDueToSpell(SpellEntry const *spellInfo_1,uint32 spellId_2) const
@@ -1962,6 +1969,8 @@ SpellEntry const* SpellMgr::SelectAuraRankForPlayerLevel(SpellEntry const* spell
void SpellMgr::LoadSpellLearnSkills()
{
uint32 oldMSTime = getMSTime();
mSpellLearnSkills.clear(); // need for reload case
// search auto-learned skills and add its to map also for use in unlearn spells/talents
@@ -1994,12 +2003,14 @@ void SpellMgr::LoadSpellLearnSkills()
}
}
sLog.outString(">> Loaded %u Spell Learn Skills from DBC in %u ms", dbc_count, GetMSTimeDiffToNow(oldMSTime));
sLog.outString();
sLog.outString(">> Loaded %u Spell Learn Skills from DBC", dbc_count);
}
void SpellMgr::LoadSpellLearnSpells()
{
uint32 oldMSTime = getMSTime();
mSpellLearnSpells.clear(); // need for reload case
// 0 1 2
@@ -2009,8 +2020,8 @@ void SpellMgr::LoadSpellLearnSpells()
barGoLink bar(1);
bar.step();
sLog.outString();
sLog.outString(">> Loaded 0 spell learn spells");
sLog.outString();
sLog.outErrorDb("`spell_learn_spell` table is empty!");
return;
}
@@ -2102,30 +2113,29 @@ void SpellMgr::LoadSpellLearnSpells()
}
}
sLog.outString(">> Loaded %u spell learn spells + %u found in DBC in %u ms", count, dbc_count, GetMSTimeDiffToNow(oldMSTime));
sLog.outString();
sLog.outString(">> Loaded %u spell learn spells + %u found in DBC", count, dbc_count);
}
void SpellMgr::LoadSpellPetAuras()
{
mSpellPetAuraMap.clear(); // need for reload case
uint32 oldMSTime = getMSTime();
uint32 count = 0;
mSpellPetAuraMap.clear(); // need for reload case
// 0 1 2 3
QueryResult result = WorldDatabase.Query("SELECT spell, effectId, pet, aura FROM spell_pet_auras");
if (!result)
{
barGoLink bar(1);
bar.step();
sLog.outString(">> Loaded 0 spell pet auras. DB table `spell_pet_auras` is empty.");
sLog.outString();
sLog.outString(">> Loaded %u spell pet auras", count);
return;
}
barGoLink bar(result->GetRowCount());
uint32 count = 0;
do
{
@@ -2171,12 +2181,14 @@ void SpellMgr::LoadSpellPetAuras()
++count;
} while (result->NextRow());
sLog.outString(">> Loaded %u spell pet auras in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
sLog.outString();
sLog.outString(">> Loaded %u spell pet auras", count);
}
void SpellMgr::LoadPetLevelupSpellMap()
{
uint32 oldMSTime = getMSTime();
mPetLevelupSpellMap.clear(); // need for reload case
uint32 count = 0;
@@ -2230,8 +2242,8 @@ void SpellMgr::LoadPetLevelupSpellMap()
}
}
sLog.outString(">> Loaded %u pet levelup and default spells for %u families in %u ms", count, family_count, GetMSTimeDiffToNow(oldMSTime));
sLog.outString();
sLog.outString(">> Loaded %u pet levelup and default spells for %u families", count, family_count);
}
bool LoadPetDefaultSpells_helper(CreatureInfo const* cInfo, PetDefaultSpellsEntry& petDefSpells)
@@ -2284,12 +2296,14 @@ bool LoadPetDefaultSpells_helper(CreatureInfo const* cInfo, PetDefaultSpellsEntr
void SpellMgr::LoadPetDefaultSpells()
{
uint32 oldMSTime = getMSTime();
mPetDefaultSpellsMap.clear();
uint32 countCreature = 0;
uint32 countData = 0;
barGoLink bar(sCreatureStorage.MaxEntry + sSpellStore.GetNumRows());
barGoLink bar(sCreatureStorage.MaxEntry);
for (uint32 i = 0; i < sCreatureStorage.MaxEntry; ++i)
{
@@ -2319,10 +2333,18 @@ void SpellMgr::LoadPetDefaultSpells()
}
}
sLog.outString(">> Loaded addition spells for %u pet spell data entries in %u ms", countData, GetMSTimeDiffToNow(oldMSTime));
sLog.outString();
sLog.outString("Loading summonable creature templates...");
oldMSTime = getMSTime();
barGoLink bar2(sSpellStore.GetNumRows());
// different summon spells
for (uint32 i = 0; i < sSpellStore.GetNumRows(); ++i)
{
bar.step();
bar2.step();
SpellEntry const* spellEntry = sSpellStore.LookupEntry(i);
if (!spellEntry)
@@ -2359,9 +2381,9 @@ void SpellMgr::LoadPetDefaultSpells()
}
}
sLog.outString(">> Loaded %u summonable creature templates in %u ms", countCreature, GetMSTimeDiffToNow(oldMSTime));
sLog.outString();
sLog.outString(">> Loaded addition spells for %u pet spell data entries.", countData);
sLog.outString(">> Loaded %u summonable creature templates.", countCreature);
}
/// Some checks for spells, to prevent adding deprecated/broken spells for trainers, spell book, etc
@@ -2459,29 +2481,28 @@ bool SpellMgr::IsSpellValid(SpellEntry const *spellInfo, Player *pl, bool msg)
void SpellMgr::LoadSpellAreas()
{
uint32 oldMSTime = getMSTime();
mSpellAreaMap.clear(); // need for reload case
mSpellAreaForQuestMap.clear();
mSpellAreaForActiveQuestMap.clear();
mSpellAreaForQuestEndMap.clear();
mSpellAreaForAuraMap.clear();
uint32 count = 0;
// 0 1 2 3 4 5 6 7 8
QueryResult result = WorldDatabase.Query("SELECT spell, area, quest_start, quest_start_active, quest_end, aura_spell, racemask, gender, autocast FROM spell_area");
if (!result)
{
barGoLink bar(1);
bar.step();
sLog.outString(">> Loaded 0 spell area requirements. DB table `spell_area` is empty.");
sLog.outString();
sLog.outString(">> Loaded %u spell area requirements", count);
return;
}
barGoLink bar(result->GetRowCount());
uint32 count = 0;
do
{
@@ -2660,8 +2681,8 @@ void SpellMgr::LoadSpellAreas()
++count;
} while (result->NextRow());
sLog.outString(">> Loaded %u spell area requirements in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
sLog.outString();
sLog.outString(">> Loaded %u spell area requirements", count);
}
SpellCastResult SpellMgr::GetSpellAllowedInLocationError(SpellEntry const *spellInfo, uint32 map_id, uint32 zone_id, uint32 area_id, Player const* player)
@@ -2799,6 +2820,8 @@ SpellCastResult SpellMgr::GetSpellAllowedInLocationError(SpellEntry const *spell
void SpellMgr::LoadSkillLineAbilityMap()
{
uint32 oldMSTime = getMSTime();
mSkillLineAbilityMap.clear();
barGoLink bar(sSkillLineAbilityStore.GetNumRows());
@@ -2815,8 +2838,8 @@ void SpellMgr::LoadSkillLineAbilityMap()
++count;
}
sLog.outString(">> Loaded %u SkillLineAbility MultiMap Data in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
sLog.outString();
sLog.outString(">> Loaded %u SkillLineAbility MultiMap Data", count);
}
DiminishingGroup GetDiminishingReturnsGroupForSpell(SpellEntry const* spellproto, bool triggered)
@@ -3227,6 +3250,8 @@ bool CanSpellPierceImmuneAura(SpellEntry const * pierceSpell, SpellEntry const *
void SpellMgr::LoadSpellEnchantProcData()
{
uint32 oldMSTime = getMSTime();
mSpellEnchantProcEventMap.clear(); // need for reload case
uint32 count = 0;
@@ -3239,8 +3264,8 @@ void SpellMgr::LoadSpellEnchantProcData()
bar.step();
sLog.outString();
sLog.outString(">> Loaded %u spell enchant proc event conditions", count);
sLog.outString();
return;
}
@@ -3271,12 +3296,14 @@ void SpellMgr::LoadSpellEnchantProcData()
++count;
} while (result->NextRow());
sLog.outString(">> Loaded %u enchant proc data definitions in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
sLog.outString();
sLog.outString(">> Loaded %u enchant proc data definitions", count);
}
void SpellMgr::LoadSpellRequired()
{
uint32 oldMSTime = getMSTime();
mSpellsReqSpell.clear(); // need for reload case
mSpellReq.clear(); // need for reload case
@@ -3287,8 +3314,8 @@ void SpellMgr::LoadSpellRequired()
barGoLink bar(1);
bar.step();
sLog.outString();
sLog.outString(">> Loaded 0 spell required records");
sLog.outString();
sLog.outErrorDb("`spell_required` table is empty!");
return;
}
@@ -3331,12 +3358,14 @@ void SpellMgr::LoadSpellRequired()
++rows;
} while (result->NextRow());
sLog.outString(">> Loaded %u spell required records in %u ms", rows, GetMSTimeDiffToNow(oldMSTime));
sLog.outString();
sLog.outString(">> Loaded %u spell required records", rows);
}
void SpellMgr::LoadSpellRanks()
{
uint32 oldMSTime = getMSTime();
mSpellChains.clear(); // need for reload case
QueryResult result = WorldDatabase.Query("SELECT first_spell_id, spell_id, rank from spell_ranks ORDER BY first_spell_id , rank");
@@ -3346,8 +3375,8 @@ void SpellMgr::LoadSpellRanks()
barGoLink bar(1);
bar.step();
sLog.outString();
sLog.outString(">> Loaded 0 spell rank records");
sLog.outString();
sLog.outErrorDb("`spell_ranks` table is empty!");
return;
}
@@ -3445,13 +3474,15 @@ void SpellMgr::LoadSpellRanks()
while (true);
} while (!finished);
sLog.outString(">> Loaded %u spell rank records in %u ms", rows, GetMSTimeDiffToNow(oldMSTime));
sLog.outString();
sLog.outString(">> Loaded %u spell rank records", rows);
}
// set data in core for now
void SpellMgr::LoadSpellCustomAttr()
{
uint32 oldMSTime = getMSTime();
mSpellCustomAttr.resize(GetSpellStore()->GetNumRows());
barGoLink bar(GetSpellStore()->GetNumRows());
@@ -4018,13 +4049,15 @@ void SpellMgr::LoadSpellCustomAttr()
CreatureAI::FillAISpellInfo();
sLog.outString(">> Loaded %u custom spell attributes in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
sLog.outString();
sLog.outString(">> Loaded %u custom spell attributes", count);
}
// Fill custom data about enchancments
void SpellMgr::LoadEnchantCustomAttr()
{
uint32 oldMSTime = getMSTime();
uint32 size = sSpellItemEnchantmentStore.GetNumRows();
mEnchantCustomAttr.resize(size);
@@ -4062,14 +4095,15 @@ void SpellMgr::LoadEnchantCustomAttr()
}
}
sLog.outString(">> Loaded %u custom enchant attributes in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
sLog.outString();
sLog.outString(">> Loaded %u custom enchant attributes", count);
}
void SpellMgr::LoadSpellLinked()
{
uint32 oldMSTime = getMSTime();
mSpellLinkedMap.clear(); // need for reload case
uint32 count = 0;
// 0 1 2
QueryResult result = WorldDatabase.Query("SELECT spell_trigger, spell_effect, type FROM spell_linked_spell");
@@ -4077,12 +4111,13 @@ void SpellMgr::LoadSpellLinked()
{
barGoLink bar(1);
bar.step();
sLog.outString(">> Loaded 0 linked spells. DB table `spell_linked_spell` is empty.");
sLog.outString();
sLog.outString(">> Loaded %u linked spells", count);
return;
}
barGoLink bar(result->GetRowCount());
uint32 count = 0;
do
{
@@ -4133,6 +4168,6 @@ void SpellMgr::LoadSpellLinked()
++count;
} while (result->NextRow());
sLog.outString(">> Loaded %u linked spells in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
sLog.outString();
sLog.outString(">> Loaded %u linked spells", count);
}
+8 -6
View File
@@ -24,6 +24,8 @@
void CreatureTextMgr::LoadCreatureTexts()
{
uint32 oldMSTime = getMSTime();
mTextMap.clear(); // for reload case
mTextRepeatMap.clear(); //reset all currently used temp texts
@@ -34,14 +36,14 @@ void CreatureTextMgr::LoadCreatureTexts()
{
barGoLink bar(1);
bar.step();
sLog.outString(">> Loaded 0 ceature texts. DB table `creature_texts` is empty.");
sLog.outString();
sLog.outString(">> Loaded 0 Creature Texts. DB table `creature_texts` is empty.");
return;
}
barGoLink bar(result->GetRowCount());
uint32 TextCount = 0;
uint32 CreatureCount = 0;
uint32 textCount = 0;
uint32 creatureCount = 0;
do
{
@@ -88,7 +90,7 @@ void CreatureTextMgr::LoadCreatureTexts()
//entry not yet added, add empty TextHolder (list of groups)
if (mTextMap.find(temp.entry) == mTextMap.end())
{
++CreatureCount;
++creatureCount;
CreatureTextHolder TextHolder;
mTextMap[temp.entry] = TextHolder;
}
@@ -101,11 +103,11 @@ void CreatureTextMgr::LoadCreatureTexts()
//add the text into our entry's group
mTextMap[temp.entry][temp.group].push_back(temp);
++TextCount;
++textCount;
} while (result->NextRow());
sLog.outString(">> Loaded %u creature texts for %u creatures in %u ms", textCount, creatureCount, GetMSTimeDiffToNow(oldMSTime));
sLog.outString();
sLog.outString(">> Loaded %u Creature Texts for %u Creatures.", TextCount, CreatureCount);
}
uint32 CreatureTextMgr::SendChat(Creature* source, uint8 textGroup, uint64 whisperGuid, ChatType msgtype, Language language, TextRange range, uint32 sound, Team team, bool gmOnly, Player* srcPlr)
+14 -7
View File
@@ -41,6 +41,8 @@ uint64 TicketMgr::GenerateGMTicketId()
void TicketMgr::LoadGMTickets()
{
uint32 oldMSTime = getMSTime();
if (!m_GMTicketList.empty())
for (GmTicketList::const_iterator itr = m_GMTicketList.begin(); itr != m_GMTicketList.end(); ++itr)
delete *itr;
@@ -49,24 +51,25 @@ void TicketMgr::LoadGMTickets()
m_GMticketid = 0;
m_openTickets = 0;
QueryResult result = CharacterDatabase.Query("SELECT guid, playerGuid, name, message, createtime, map, posX, posY, posZ, timestamp, closed, assignedto, comment, completed, escalated, viewed FROM gm_tickets");
QueryResult result = CharacterDatabase.Query("SELECT guid, playerGuid, name, message, createtime, map, posX, posY, posZ, timestamp, closed,"
"assignedto, comment, completed, escalated, viewed FROM gm_tickets");
if (!result)
{
barGoLink bar(1);
bar.step();
sLog.outString(">> Loaded 0 GM tickets. DB table `gm_tickets` is empty!");
sLog.outString();
sLog.outString(">> GM Tickets table is empty, no tickets were loaded.");
return;
}
uint16 count = 0;
barGoLink bar(result->GetRowCount());
GM_Ticket *ticket;
uint32 count = 0;
do
{
Field *fields = result->Fetch();
ticket = new GM_Ticket;
GM_Ticket *ticket = new GM_Ticket;
ticket->guid = fields[0].GetUInt64();
ticket->playerGuid = fields[1].GetUInt64();
ticket->name = fields[2].GetString();
@@ -100,11 +103,14 @@ void TicketMgr::LoadGMTickets()
m_GMticketid = fields[0].GetUInt64();
}
sLog.outString(">> Loaded %u GM Tickets from the database.", count);
sLog.outString(">> Loaded %u GM tickets in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
sLog.outString();
}
void TicketMgr::LoadGMSurveys()
{
uint32 oldMSTime = getMSTime();
// we don't actually load anything into memory here as there's no reason to
QueryResult result = CharacterDatabase.Query("SELECT MAX(surveyid) FROM gm_surveys");
if (result)
@@ -115,7 +121,8 @@ void TicketMgr::LoadGMSurveys()
else
m_GMSurveyID = 0;
sLog.outString(">> Loaded GM Survey count from database.");
sLog.outString(">> Loaded GM Survey count from database in %u ms", GetMSTimeDiffToNow(oldMSTime));
sLog.outString();
}
void TicketMgr::AddOrUpdateGMTicket(GM_Ticket &ticket, bool create)
@@ -31,6 +31,8 @@ void CharacterDatabaseCleaner::CleanDatabase()
sLog.outString("Cleaning character database...");
uint32 oldMSTime = getMSTime();
// check flags which clean ups are necessary
QueryResult result = CharacterDatabase.Query("SELECT value FROM worldstates WHERE entry=20004");
if(!result)
@@ -47,6 +49,9 @@ void CharacterDatabaseCleaner::CleanDatabase()
if(flags & CLEANING_FLAG_TALENTS)
CleanCharacterTalent();
CharacterDatabase.Query("UPDATE worldstates SET value = 0 WHERE entry=20004");
sLog.outString(">> Cleaned character database in %u ms", GetMSTimeDiffToNow(oldMSTime));
sLog.outString();
}
void CharacterDatabaseCleaner::CheckUnique(const char* column, const
+4 -4
View File
@@ -76,6 +76,8 @@ Weather* WeatherMgr::AddWeather(uint32 zone_id)
void WeatherMgr::LoadWeatherData()
{
uint32 oldMSTime = getMSTime();
uint32 count = 0;
// 0 1 2 3 4 5 6 7 8 9 10 11 12 13
@@ -84,11 +86,9 @@ void WeatherMgr::LoadWeatherData()
if (!result)
{
barGoLink bar(1);
bar.step();
sLog.outString();
sLog.outErrorDb(">> Loaded 0 weather definitions. DB table `game_weather` is empty.");
sLog.outString();
return;
}
@@ -134,8 +134,8 @@ void WeatherMgr::LoadWeatherData()
}
while (result->NextRow());
sLog.outString(">> Loaded %u weather definitions in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
sLog.outString();
sLog.outString(">> Loaded %u weather definitions", count);
}
void WeatherMgr::Update(uint32 diff)
+34 -28
View File
@@ -1193,6 +1193,9 @@ void World::LoadConfigSettings(bool reload)
/// Initialize the World
void World::SetInitialWorldSettings()
{
///- Server startup begin
uint32 startupBegin = getMSTime();
///- Initialize the random number generator
srand((unsigned int)time(NULL));
@@ -1260,6 +1263,7 @@ void World::SetInitialWorldSettings()
sInstanceSaveMgr.CleanupAndPackInstances(); // must be called before `creature_respawn`/`gameobject_respawn` tables
sLog.outString("Loading Localization strings...");
uint32 oldMSTime = getMSTime();
sObjectMgr.LoadCreatureLocales();
sObjectMgr.LoadGameObjectLocales();
sObjectMgr.LoadItemLocales();
@@ -1269,14 +1273,15 @@ void World::SetInitialWorldSettings()
sObjectMgr.LoadPageTextLocales();
sObjectMgr.LoadGossipMenuItemsLocales();
sObjectMgr.LoadPointOfInterestLocales();
sObjectMgr.SetDBCLocaleIndex(GetDefaultDbcLocale()); // Get once for all the locale index of DBC language (console/broadcasts)
sLog.outString(">>> Localization strings loaded");
sLog.outString(">> Localization strings loaded in %u ms", GetMSTimeDiffToNow(oldMSTime));
sLog.outString();
sLog.outString("Loading Page Texts...");
sObjectMgr.LoadPageTexts();
sLog.outString("Loading Game Object Templates..."); // must be after LoadPageTexts
sLog.outString("Loading Game Object Templates..."); // must be after LoadPageTexts
sObjectMgr.LoadGameobjectInfo();
sLog.outString("Loading Spell Rank Data...");
@@ -1289,7 +1294,7 @@ void World::SetInitialWorldSettings()
sSpellMgr.LoadSpellGroups();
sLog.outString("Loading Spell Learn Skills...");
sSpellMgr.LoadSpellLearnSkills(); // must be after LoadSpellRanks
sSpellMgr.LoadSpellLearnSkills(); // must be after LoadSpellRanks
sLog.outString("Loading Spell Learn Spells...");
sSpellMgr.LoadSpellLearnSpells();
@@ -1316,12 +1321,12 @@ void World::SetInitialWorldSettings()
LoadRandomEnchantmentsTable();
sLog.outString("Loading Disables");
sDisableMgr.LoadDisables(); // must be before loading quests and items
sDisableMgr.LoadDisables(); // must be before loading quests and items
sLog.outString("Loading Items..."); // must be after LoadRandomEnchantmentsTable and LoadPageTexts
sLog.outString("Loading Items..."); // must be after LoadRandomEnchantmentsTable and LoadPageTexts
sObjectMgr.LoadItemPrototypes();
sLog.outString("Loading Item set names..."); // must be after LoadItemPrototypes
sLog.outString("Loading Item set names..."); // must be after LoadItemPrototypes
sObjectMgr.LoadItemSetNames();
sLog.outString("Loading Creature Model Based Info Data...");
@@ -1360,7 +1365,7 @@ void World::SetInitialWorldSettings()
sLog.outString("Loading pet levelup spells...");
sSpellMgr.LoadPetLevelupSpellMap();
sLog.outString("Loading pet default spell additional to levelup spells...");
sLog.outString("Loading pet default spells additional to levelup spells...");
sSpellMgr.LoadPetDefaultSpells();
sLog.outString("Loading Creature Template Addon Data...");
@@ -1378,7 +1383,7 @@ void World::SetInitialWorldSettings()
sLog.outString("Loading Gameobject Respawn Data..."); // must be after PackInstances()
sObjectMgr.LoadGameobjectRespawnTimes();
sLog.outString("Loading Objects Pooling Data...");
sLog.outString("Loading Objects Pooling Data..."); // TODOLEAK: scope
sPoolMgr.LoadFromDB();
sLog.outString("Loading Weather Data...");
@@ -1400,7 +1405,7 @@ void World::SetInitialWorldSettings()
sPoolMgr.LoadQuestPools();
sLog.outString("Loading Game Event Data..."); // must be after loading pools fully
sGameEventMgr.LoadFromDB();
sGameEventMgr.LoadFromDB(); // TODOLEAK: add scopes
sLog.outString("Loading Dungeon boss data...");
sLFGMgr.LoadDungeonEncounters();
@@ -1411,7 +1416,7 @@ void World::SetInitialWorldSettings()
sLog.outString("Loading UNIT_NPC_FLAG_SPELLCLICK Data...");
sObjectMgr.LoadNPCSpellClickSpells();
sLog.outString("Loading SpellArea Data..."); // must be after quest load
sLog.outString("Loading SpellArea Data..."); // must be after quest load
sSpellMgr.LoadSpellAreas();
sLog.outString("Loading AreaTrigger definitions...");
@@ -1471,7 +1476,7 @@ void World::SetInitialWorldSettings()
sObjectMgr.LoadMailLevelRewards();
// Loot tables
LoadLootTables();
LoadLootTables(); //TODOLEAK: untangle that shit
sLog.outString("Loading Skill Discovery Table...");
LoadSkillDiscoveryTable();
@@ -1501,7 +1506,6 @@ void World::SetInitialWorldSettings()
sLog.outString("Loading Auctions...");
sAuctionMgr.LoadAuctions();
sLog.outString("***** GUILDS *****");
sObjectMgr.LoadGuilds();
sLog.outString("Loading ArenaTeams...");
@@ -1580,16 +1584,12 @@ void World::SetInitialWorldSettings()
LoadAutobroadcasts();
///- Load and initialize scripts
sLog.outString("Loading Scripts...");
sLog.outString();
sObjectMgr.LoadQuestStartScripts(); // must be after load Creature/Gameobject(Template/Data) and QuestTemplate
sObjectMgr.LoadQuestEndScripts(); // must be after load Creature/Gameobject(Template/Data) and QuestTemplate
sObjectMgr.LoadSpellScripts(); // must be after load Creature/Gameobject(Template/Data)
sObjectMgr.LoadGameObjectScripts(); // must be after load Creature/Gameobject(Template/Data)
sObjectMgr.LoadEventScripts(); // must be after load Creature/Gameobject(Template/Data)
sObjectMgr.LoadWaypointScripts();
sLog.outString(">>> Scripts loaded");
sLog.outString();
sLog.outString("Loading Scripts text locales..."); // must be after Load*Scripts calls
sObjectMgr.LoadDbScriptStrings();
@@ -1610,7 +1610,7 @@ void World::SetInitialWorldSettings()
sCreatureTextMgr.LoadCreatureTexts();
sLog.outString("Initializing Scripts...");
sScriptMgr.Initialize();
sScriptMgr.Initialize(); //LEAKTODO
sLog.outString("Validating spell scripts...");
sObjectMgr.ValidateSpellScripts();
@@ -1724,7 +1724,10 @@ void World::SetInitialWorldSettings()
else
sLog.SetLogDB(false);
sLog.outString("WORLD: World initialized");
uint32 startupDuration = GetMSTimeDiffToNow(startupBegin);
sLog.outString();
sLog.outString("WORLD: World initialized in %u minuntes %u seconds", (startupDuration / 60000), ((startupDuration % 60000) / 1000) );
sLog.outString();
}
void World::DetectDBCLang()
@@ -1799,6 +1802,8 @@ void World::RecordTimeDiff(const char *text, ...)
void World::LoadAutobroadcasts()
{
uint32 oldMSTime = getMSTime();
m_Autobroadcasts.clear();
QueryResult result = WorldDatabase.Query("SELECT text FROM autobroadcast");
@@ -1807,14 +1812,12 @@ void World::LoadAutobroadcasts()
{
barGoLink bar(1);
bar.step();
sLog.outString(">> Loaded 0 autobroadcasts definitions. DB table `autobroadcast` is empty!");
sLog.outString();
sLog.outString(">> Loaded 0 autobroadcasts definitions");
return;
}
barGoLink bar(result->GetRowCount());
uint32 count = 0;
do
@@ -1826,11 +1829,11 @@ void World::LoadAutobroadcasts()
m_Autobroadcasts.push_back(message);
count++;
++count;
} while (result->NextRow());
sLog.outString(">> Loaded %u autobroadcasts definitions in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
sLog.outString();
sLog.outString(">> Loaded %u autobroadcasts definitions", count);
}
/// Update the World !
@@ -2765,30 +2768,33 @@ void World::UpdateAreaDependentAuras()
void World::LoadWorldStates()
{
uint32 oldMSTime = getMSTime();
QueryResult result = CharacterDatabase.Query("SELECT entry, value FROM worldstates");
if (!result)
{
barGoLink bar(1);
bar.step();
sLog.outString(">> Loaded 0 world states. DB table `worldstates` is empty!");
sLog.outString();
sLog.outString(">> Loaded 0 world states.");
return;
}
barGoLink bar(result->GetRowCount());
uint32 counter = 0;
uint32 count = 0;
do
{
Field *fields = result->Fetch();
m_worldstates[fields[0].GetUInt32()] = fields[1].GetUInt64();
bar.step();
++counter;
} while (result->NextRow());
++count;
}
while (result->NextRow());
sLog.outString(">> Loaded %u world states in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
sLog.outString();
sLog.outString(">> Loaded %u world states.", counter);
}
// Setting a worldstate will save it to DB
+6 -26
View File
@@ -21,17 +21,7 @@
#include "ProgressBar.h"
char const* const barGoLink::empty = " ";
#ifdef _WIN32
char const* const barGoLink::full = "\x3D";
#else
char const* const barGoLink::full = "*";
#endif
barGoLink::~barGoLink()
{
printf( "\n" );
fflush(stdout);
}
barGoLink::barGoLink( uint64 row_count )
{
@@ -39,17 +29,9 @@ barGoLink::barGoLink( uint64 row_count )
rec_pos = 0;
indic_len = 50;
num_rec = row_count;
#ifdef _WIN32
printf( "\x3D" );
#else
printf( "[" );
#endif
for (uint64 i = 0; i < indic_len; ++i) printf( empty );
#ifdef _WIN32
printf( "\x3D 0%%\r\x3D" );
#else
printf( "] 0%%\r[" );
#endif
fflush(stdout);
}
@@ -62,22 +44,20 @@ void barGoLink::step( void )
n = rec_no * indic_len / num_rec;
if ( n != rec_pos )
{
#ifdef _WIN32
printf( "\r\x3D" );
#else
printf( "\r[" );
#endif
for (i = 0; i < n; i++ ) printf( full );
for (; i < indic_len; i++ ) printf( empty );
float percent = (((float)n/(float)indic_len)*100);
#ifdef _WIN32
printf( "\x3D %i%% \r\x3D", (int)percent);
#else
printf( "] %i%% \r[", (int)percent);
#endif
fflush(stdout);
rec_pos = n;
}
if( num_rec == rec_no)
{
printf( "\n" );
fflush(stdout);
}
}
@@ -34,6 +34,5 @@ class barGoLink
void step( void );
barGoLink( uint64 );
~barGoLink();
};
#endif
+5
View File
@@ -37,6 +37,11 @@ inline uint32 getMSTimeDiff(uint32 oldMSTime, uint32 newMSTime)
return newMSTime - oldMSTime;
}
inline uint32 GetMSTimeDiffToNow(uint32 oldMSTime)
{
return getMSTimeDiff(oldMSTime, getMSTime());
}
struct IntervalTimer
{
public: