mirror of
https://github.com/SapphireServer/Sapphire.git
synced 2025-04-25 14:07:46 +00:00
Merge pull request #285 from NotAdam/actor_rewrite
fix crash when starting the server with no scripts, fixes #284
This commit is contained in:
commit
16b25ce3c5
3 changed files with 24 additions and 5 deletions
|
@ -40,7 +40,6 @@ namespace Scripting {
|
||||||
ScriptInfo* getScriptInfo( std::string name );
|
ScriptInfo* getScriptInfo( std::string name );
|
||||||
|
|
||||||
ScriptObject** getScripts( ModuleHandle handle );
|
ScriptObject** getScripts( ModuleHandle handle );
|
||||||
ScriptObject* getScriptObject( ModuleHandle handle );
|
|
||||||
|
|
||||||
bool isModuleLoaded( std::string name );
|
bool isModuleLoaded( std::string name );
|
||||||
|
|
||||||
|
|
|
@ -54,9 +54,15 @@ bool Core::Scripting::ScriptMgr::init()
|
||||||
auto pConfig = g_fw.get< XMLConfig >();
|
auto pConfig = g_fw.get< XMLConfig >();
|
||||||
auto pLog = g_fw.get< Logger >();
|
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() );
|
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 scriptsFound = 0;
|
||||||
uint32_t scriptsLoaded = 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<std::string> &files, const std::string& ext )
|
bool Core::Scripting::ScriptMgr::loadDir( const std::string& dirname, std::set<std::string>& files, const std::string& ext )
|
||||||
{
|
{
|
||||||
|
|
||||||
auto pLog = g_fw.get< Logger >();
|
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 );
|
boost::filesystem::path targetDir( dirname );
|
||||||
|
|
||||||
|
@ -132,6 +144,14 @@ void Core::Scripting::ScriptMgr::loadDir( const std::string& dirname, std::set<s
|
||||||
files.insert( i.string() );
|
files.insert( i.string() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if( files.size() )
|
||||||
|
return true;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
pLog->error( "ScriptMgr: couldn't find any script modules" );
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Core::Scripting::ScriptMgr::onPlayerFirstEnterWorld( Entity::Player& player )
|
void Core::Scripting::ScriptMgr::onPlayerFirstEnterWorld( Entity::Player& player )
|
||||||
|
|
|
@ -61,7 +61,7 @@ namespace Core
|
||||||
bool onInstanceUpdate( InstanceContentPtr instance, uint32_t currTime );
|
bool onInstanceUpdate( InstanceContentPtr instance, uint32_t currTime );
|
||||||
bool onInstanceEnterTerritory( InstanceContentPtr instance, Entity::Player& player, uint32_t eventId, uint16_t param1, uint16_t param2 );
|
bool onInstanceEnterTerritory( InstanceContentPtr instance, Entity::Player& player, uint32_t eventId, uint16_t param1, uint16_t param2 );
|
||||||
|
|
||||||
void loadDir( const std::string& dirname, std::set<std::string> &files, const std::string& ext );
|
bool loadDir( const std::string& dirname, std::set<std::string> &files, const std::string& ext );
|
||||||
|
|
||||||
NativeScriptMgr& getNativeScriptHandler();
|
NativeScriptMgr& getNativeScriptHandler();
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Reference in a new issue