diff --git a/src/servers/sapphire_zone/Script/ScriptMgr.cpp b/src/servers/sapphire_zone/Script/ScriptMgr.cpp index 57d24893..00437d22 100644 --- a/src/servers/sapphire_zone/Script/ScriptMgr.cpp +++ b/src/servers/sapphire_zone/Script/ScriptMgr.cpp @@ -54,9 +54,15 @@ bool Core::Scripting::ScriptMgr::init() auto pConfig = g_fw.get< XMLConfig >(); auto pLog = g_fw.get< Logger >(); - loadDir( pConfig->getValue< std::string >( "Settings.General.Scripts.Path", "./compiledscripts/" ), + auto status = loadDir( pConfig->getValue< std::string >( "Settings.General.Scripts.Path", "./compiledscripts/" ), files, m_nativeScriptMgr->getModuleExtension() ); + if( !status ) + { + pLog->error( std::string( __func__ ) + ": failed to load scripts, the server will not function correctly without scripts loaded." ); + return false; + } + uint32_t scriptsFound = 0; uint32_t scriptsLoaded = 0; @@ -114,11 +120,17 @@ void Core::Scripting::ScriptMgr::watchDirectories() }); } -void Core::Scripting::ScriptMgr::loadDir( const std::string& dirname, std::set &files, const std::string& ext ) +bool Core::Scripting::ScriptMgr::loadDir( const std::string& dirname, std::set& files, const std::string& ext ) { auto pLog = g_fw.get< Logger >(); - pLog->info( "ScriptEngine: loading scripts from " + dirname ); + pLog->info( "ScriptMgr: loading scripts from " + dirname ); + + if( !boost::filesystem::exists( dirname ) ) + { + pLog->error( "ScriptMgr: scripts directory doesn't exist" ); + return false; + } boost::filesystem::path targetDir( dirname ); @@ -132,6 +144,14 @@ void Core::Scripting::ScriptMgr::loadDir( const std::string& dirname, std::seterror( "ScriptMgr: couldn't find any script modules" ); + return false; + } } void Core::Scripting::ScriptMgr::onPlayerFirstEnterWorld( Entity::Player& player ) diff --git a/src/servers/sapphire_zone/Script/ScriptMgr.h b/src/servers/sapphire_zone/Script/ScriptMgr.h index 8c1e1f02..4af842bf 100644 --- a/src/servers/sapphire_zone/Script/ScriptMgr.h +++ b/src/servers/sapphire_zone/Script/ScriptMgr.h @@ -61,7 +61,7 @@ namespace Core bool onInstanceUpdate( InstanceContentPtr instance, uint32_t currTime ); bool onInstanceEnterTerritory( InstanceContentPtr instance, Entity::Player& player, uint32_t eventId, uint16_t param1, uint16_t param2 ); - void loadDir( const std::string& dirname, std::set &files, const std::string& ext ); + bool loadDir( const std::string& dirname, std::set &files, const std::string& ext ); NativeScriptMgr& getNativeScriptHandler(); };