mirror of
https://github.com/mangosfour/server.git
synced 2025-12-18 19:37:01 +00:00
Refactored db_scripts
The unity! - Based on the original work of H0zen for Zero.
This commit is contained in:
parent
a92011c6bf
commit
695651324c
15 changed files with 415 additions and 482 deletions
|
|
@ -76,11 +76,12 @@
|
|||
#include "Calendar.h"
|
||||
#include "Weather.h"
|
||||
#include "LFGMgr.h"
|
||||
|
||||
#ifdef ENABLE_ELUNA
|
||||
#include "LuaEngine.h"
|
||||
#endif /*ENABLE_ELUNA*/
|
||||
#endif /* ENABLE_ELUNA */
|
||||
|
||||
// Warden
|
||||
// WARDEN
|
||||
#include "WardenCheckMgr.h"
|
||||
|
||||
#include <iostream>
|
||||
|
|
@ -932,14 +933,15 @@ void World::LoadConfigSettings(bool reload)
|
|||
setConfig(CONFIG_BOOL_MMAP_ENABLED, "mmap.enabled", true);
|
||||
std::string ignoreMapIds = sConfig.GetStringDefault("mmap.ignoreMapIds", "");
|
||||
MMAP::MMapFactory::preventPathfindingOnMaps(ignoreMapIds.c_str());
|
||||
sLog.outString("WORLD: mmap pathfinding %sabled", getConfig(CONFIG_BOOL_MMAP_ENABLED) ? "en" : "dis");
|
||||
sLog.outString("WORLD: MMap pathfinding %sabled", getConfig(CONFIG_BOOL_MMAP_ENABLED) ? "en" : "dis");
|
||||
|
||||
setConfig(CONFIG_BOOL_ELUNA_ENABLED, "Eluna.Enabled", true);
|
||||
|
||||
|
||||
#ifdef ENABLE_ELUNA
|
||||
if (reload)
|
||||
sEluna->OnConfigLoad(reload);
|
||||
#endif /* ENABLE_ELUNA */
|
||||
sLog.outString();
|
||||
}
|
||||
|
||||
/// Initialize the World
|
||||
|
|
@ -1095,7 +1097,7 @@ void World::SetInitialWorldSettings()
|
|||
sLog.outString("Loading Creature Stats...");
|
||||
sObjectMgr.LoadCreatureClassLvlStats();
|
||||
|
||||
sLog.outErrorDb("Loading Creature templates...");
|
||||
sLog.outString("Loading Creature templates...");
|
||||
sObjectMgr.LoadCreatureTemplates();
|
||||
|
||||
sLog.outString("Loading Creature template spells...");
|
||||
|
|
@ -1179,6 +1181,7 @@ void World::SetInitialWorldSettings()
|
|||
|
||||
sLog.outString("Creating map persistent states for non-instanceable maps..."); // must be after PackInstances(), LoadCreatures(), sPoolMgr.LoadFromDB(), sGameEventMgr.LoadFromDB();
|
||||
sMapPersistentStateMgr.InitWorldMaps();
|
||||
sLog.outString();
|
||||
|
||||
sLog.outString("Loading Creature Respawn Data..."); // must be after LoadCreatures(), and sMapPersistentStateMgr.InitWorldMaps()
|
||||
sMapPersistentStateMgr.LoadCreatureRespawnTimes();
|
||||
|
|
@ -1228,6 +1231,7 @@ void World::SetInitialWorldSettings()
|
|||
sObjectMgr.LoadPetNames();
|
||||
|
||||
CharacterDatabaseCleaner::CleanDatabase();
|
||||
sLog.outString();
|
||||
|
||||
sLog.outString("Loading the max pet number...");
|
||||
sObjectMgr.LoadPetNumber();
|
||||
|
|
@ -1274,7 +1278,7 @@ void World::SetInitialWorldSettings()
|
|||
sObjectMgr.LoadNpcGossips(); // must be after load Creature and LoadGossipText
|
||||
|
||||
sLog.outString("Loading Gossip scripts...");
|
||||
sScriptMgr.LoadGossipScripts(); // must be before gossip menu options
|
||||
sScriptMgr.LoadDbScripts(DBS_ON_GOSSIP); // must be before gossip menu options
|
||||
|
||||
sObjectMgr.LoadGossipMenus();
|
||||
|
||||
|
|
@ -1287,7 +1291,7 @@ void World::SetInitialWorldSettings()
|
|||
sObjectMgr.LoadTrainers(); // must be after load CreatureTemplate, TrainerTemplate
|
||||
|
||||
sLog.outString("Loading Waypoint scripts..."); // before loading from creature_movement
|
||||
sScriptMgr.LoadCreatureMovementScripts();
|
||||
sScriptMgr.LoadDbScripts(DBS_ON_CREATURE_MOVEMENT);
|
||||
|
||||
sLog.outString("Loading Waypoints...");
|
||||
sLog.outString();
|
||||
|
|
@ -1356,22 +1360,22 @@ void World::SetInitialWorldSettings()
|
|||
sLog.outString("Returning old mails...");
|
||||
sObjectMgr.ReturnOrDeleteOldMails(false);
|
||||
|
||||
///- Load and initialize scripts
|
||||
sLog.outString("Loading Scripts...");
|
||||
sLog.outString();
|
||||
sScriptMgr.LoadQuestStartScripts(); // must be after load Creature/Gameobject(Template/Data) and QuestTemplate
|
||||
sScriptMgr.LoadQuestEndScripts(); // must be after load Creature/Gameobject(Template/Data) and QuestTemplate
|
||||
sScriptMgr.LoadSpellScripts(); // must be after load Creature/Gameobject(Template/Data)
|
||||
sScriptMgr.LoadGameObjectScripts(); // must be after load Creature/Gameobject(Template/Data)
|
||||
sScriptMgr.LoadGameObjectTemplateScripts(); // must be after load Creature/Gameobject(Template/Data)
|
||||
sScriptMgr.LoadEventScripts(); // must be after load Creature/Gameobject(Template/Data)
|
||||
sScriptMgr.LoadCreatureDeathScripts(); // must be after load Creature/Gameobject(Template/Data)
|
||||
sLog.outString(">>> Scripts loaded");
|
||||
///- Load and initialize DBScripts Engine
|
||||
sLog.outString("Loading DB-Scripts Engine...");
|
||||
sScriptMgr.LoadDbScripts(DBS_ON_QUEST_START); // must be after load Creature/Gameobject(Template/Data) and QuestTemplate
|
||||
sScriptMgr.LoadDbScripts(DBS_ON_QUEST_END); // must be after load Creature/Gameobject(Template/Data) and QuestTemplate
|
||||
sScriptMgr.LoadDbScripts(DBS_ON_SPELL); // must be after load Creature/Gameobject(Template/Data)
|
||||
sScriptMgr.LoadDbScripts(DBS_ON_GO_USE); // must be after load Creature/Gameobject(Template/Data)
|
||||
sScriptMgr.LoadDbScripts(DBS_ON_GOT_USE); // must be after load Creature/Gameobject(Template/Data)
|
||||
sScriptMgr.LoadDbScripts(DBS_ON_EVENT); // must be after load Creature/Gameobject(Template/Data)
|
||||
sScriptMgr.LoadDbScripts(DBS_ON_CREATURE_DEATH); // must be after load Creature/Gameobject(Template/Data)
|
||||
sLog.outString(">>> DB Scripts loaded");
|
||||
sLog.outString();
|
||||
|
||||
sLog.outString("Loading Scripts text locales..."); // must be after Load*Scripts calls
|
||||
sScriptMgr.LoadDbScriptStrings();
|
||||
|
||||
///- Load and initialize EventAI Scripts
|
||||
sLog.outString("Loading CreatureEventAI Texts...");
|
||||
sEventAIMgr.LoadCreatureEventAI_Texts(false); // false, will checked in LoadCreatureEventAI_Scripts
|
||||
|
||||
|
|
@ -1385,25 +1389,26 @@ void World::SetInitialWorldSettings()
|
|||
#ifdef ENABLE_SD3
|
||||
switch (sScriptMgr.LoadScriptLibrary(MANGOS_SCRIPT_NAME))
|
||||
{
|
||||
case SCRIPT_LOAD_OK:
|
||||
sLog.outString("Scripting library loaded.");
|
||||
break;
|
||||
case SCRIPT_LOAD_ERR_NOT_FOUND:
|
||||
sLog.outError("Scripting library not found or not accessible.");
|
||||
break;
|
||||
case SCRIPT_LOAD_ERR_WRONG_API:
|
||||
sLog.outError("Scripting library has wrong list functions (outdated?).");
|
||||
break;
|
||||
case SCRIPT_LOAD_ERR_OUTDATED:
|
||||
sLog.outError("Scripting library build for old mangosd revision. You need rebuild it.");
|
||||
break;
|
||||
case SCRIPT_LOAD_OK:
|
||||
sLog.outString("Scripting library loaded.");
|
||||
break;
|
||||
case SCRIPT_LOAD_ERR_NOT_FOUND:
|
||||
sLog.outError("Scripting library not found or not accessible.");
|
||||
break;
|
||||
case SCRIPT_LOAD_ERR_WRONG_API:
|
||||
sLog.outError("Scripting library has wrong list functions (outdated?).");
|
||||
break;
|
||||
case SCRIPT_LOAD_ERR_OUTDATED:
|
||||
sLog.outError("Scripting library build for old mangosd revision. You need rebuild it.");
|
||||
break;
|
||||
}
|
||||
#else /* ENABLE_SD3 */
|
||||
sLog.outError("SD3 was not included in compilation, not using it.");
|
||||
#endif /* ENABLE_SD3 */
|
||||
sLog.outString();
|
||||
|
||||
///- Initialize game time and timers
|
||||
sLog.outString("DEBUG:: Initialize game time and timers");
|
||||
sLog.outString("Initialize game time and timers");
|
||||
m_gameTime = time(NULL);
|
||||
m_startTime = m_gameTime;
|
||||
|
||||
|
|
@ -1413,10 +1418,10 @@ void World::SetInitialWorldSettings()
|
|||
local = *(localtime(&curr)); // dereference and assign
|
||||
char isoDate[128];
|
||||
sprintf(isoDate, "%04d-%02d-%02d %02d:%02d:%02d",
|
||||
local.tm_year + 1900, local.tm_mon + 1, local.tm_mday, local.tm_hour, local.tm_min, local.tm_sec);
|
||||
local.tm_year + 1900, local.tm_mon + 1, local.tm_mday, local.tm_hour, local.tm_min, local.tm_sec);
|
||||
|
||||
LoginDatabase.PExecute("INSERT INTO uptime (realmid, starttime, startstring, uptime) VALUES('%u', " UI64FMTD ", '%s', 0)",
|
||||
realmID, uint64(m_startTime), isoDate);
|
||||
realmID, uint64(m_startTime), isoDate);
|
||||
|
||||
m_timers[WUPDATE_AUCTIONS].SetInterval(MINUTE * IN_MILLISECONDS);
|
||||
m_timers[WUPDATE_UPTIME].SetInterval(getConfig(CONFIG_UINT32_UPTIME_UPDATE)*MINUTE * IN_MILLISECONDS);
|
||||
|
|
@ -1445,6 +1450,7 @@ void World::SetInitialWorldSettings()
|
|||
///- Initialize MapManager
|
||||
sLog.outString("Starting Map System");
|
||||
sMapMgr.Initialize();
|
||||
sLog.outString();
|
||||
|
||||
///- Initialize Battlegrounds
|
||||
sLog.outString("Starting BattleGround System");
|
||||
|
|
@ -1470,6 +1476,7 @@ void World::SetInitialWorldSettings()
|
|||
|
||||
sLog.outString("Deleting expired bans...");
|
||||
LoginDatabase.Execute("DELETE FROM ip_banned WHERE unbandate<=UNIX_TIMESTAMP() AND unbandate<>bandate");
|
||||
sLog.outString();
|
||||
|
||||
sLog.outString("Calculate next daily quest and dungeon reset time...");
|
||||
InitDailyQuestResetTime();
|
||||
|
|
@ -1497,7 +1504,7 @@ void World::SetInitialWorldSettings()
|
|||
|
||||
sLog.outString("Initialize AuctionHouseBot...");
|
||||
sAuctionBot.Initialize();
|
||||
|
||||
sLog.outString();
|
||||
#ifdef ENABLE_ELUNA
|
||||
///- Run eluna scripts.
|
||||
// in multithread foreach: run scripts
|
||||
|
|
@ -1505,10 +1512,14 @@ void World::SetInitialWorldSettings()
|
|||
sEluna->OnConfigLoad(false); // Must be done after Eluna is initialized and scripts have run.
|
||||
#endif
|
||||
|
||||
sLog.outString("------------------------");
|
||||
sLog.outString("WORLD: World initialized");
|
||||
sLog.outString("------------------------");
|
||||
sLog.outString();
|
||||
|
||||
uint32 uStartInterval = WorldTimer::getMSTimeDiff(uStartTime, WorldTimer::getMSTime());
|
||||
sLog.outString("SERVER STARTUP TIME: %i minutes %i seconds", uStartInterval / 60000, (uStartInterval % 60000) / 1000);
|
||||
sLog.outString();
|
||||
}
|
||||
|
||||
void World::DetectDBCLang()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue