1
Fork 0
mirror of https://github.com/SapphireServer/Sapphire.git synced 2025-04-27 14:57:44 +00:00

change reload -> queue reload & some minor refactoring

This commit is contained in:
GokuWeedLord 2017-12-14 23:05:53 +11:00
parent 6e345a265b
commit c60b680a27
6 changed files with 21 additions and 20 deletions

View file

@ -8,16 +8,16 @@
<DataPath>H:\\SteamLibrary\\steamapps\\common\\FINAL FANTASY XIV - A Realm Reborn\\game\\sqpack\\ffxiv</DataPath> <DataPath>H:\\SteamLibrary\\steamapps\\common\\FINAL FANTASY XIV - A Realm Reborn\\game\\sqpack\\ffxiv</DataPath>
<Scripts> <Scripts>
<!-- where compiled scripts are placed --> <!-- where compiled scripts are placed -->
<Path>./compiledscripts/</Path> <Path>./compiledscripts/</Path>
<CachePath>./cache/</CachePath> <CachePath>./cache/</CachePath>
<HotSwap> <HotSwap>
<Enabled>1</Enabled> <Enabled>1</Enabled>
<ScriptsDir>../scripts/native/</ScriptsDir> <ScriptsDir>../scripts/native/</ScriptsDir>
<BuildDir>../cmake-build-debug/</BuildDir> <BuildDir>../cmake-build-debug/</BuildDir>
<BuildCmd>cmake --build %1% --target %2%</BuildCmd> <BuildCmd>cmake --build %1% --target %2%</BuildCmd>
</HotSwap> </HotSwap>
</Scripts> </Scripts>
<!-- Path of Chai script files --> <!-- Path of Chai script files -->
@ -29,13 +29,13 @@
<Username>root</Username> <Username>root</Username>
<Pass></Pass> <Pass></Pass>
<Database>sapphire</Database> <Database>sapphire</Database>
<SyncThreads>2</SyncThreads> <SyncThreads>2</SyncThreads>
<AsyncThreads>2</AsyncThreads> <AsyncThreads>2</AsyncThreads>
</Mysql> </Mysql>
</General> </General>
<Parameters> <Parameters>
<!-- Messages players see upon logging in - These *must* be smaller than 307 characters --> <!-- Messages players see upon logging in - These *must* be smaller than 307 characters -->
<MotDArray> <MotDArray>
<MotD>&lt;&lt;&lt;Welcome to Sapphire&gt;&gt;&gt;</MotD> <MotD>&lt;&lt;&lt;Welcome to Sapphire&gt;&gt;&gt;</MotD>
<MotD>This is a very good server</MotD> <MotD>This is a very good server</MotD>

View file

@ -589,14 +589,14 @@ void Core::DebugCommandHandler::script( char* data, Entity::Player &player, boos
} }
} }
else if( subCommand == "reload" || subCommand == "rl" ) else if( subCommand == "queuereload" || subCommand == "qrl" )
{ {
if( subCommand == params ) if( subCommand == params )
player.sendDebug( "Command failed: requires name of script to reload" ); player.sendDebug( "Command failed: requires name of script to reload" );
else else
{ {
g_scriptMgr.getNativeScriptHandler().reloadScript( params ); g_scriptMgr.getNativeScriptHandler( ).queueScriptReload( params );
player.sendDebug( "Attempting to reload script: " + params ); player.sendDebug( "Queued script reload for script: " + params );
} }
} }
else if( subCommand == "build" || subCommand == "b" ) else if( subCommand == "build" || subCommand == "b" )

View file

@ -137,7 +137,7 @@ namespace Core {
return m_loader.unloadScript( info ); return m_loader.unloadScript( info );
} }
void NativeScriptManager::reloadScript( const std::string &name ) void NativeScriptManager::queueScriptReload( const std::string &name )
{ {
auto info = m_loader.getScriptInfo( name ); auto info = m_loader.getScriptInfo( name );
if( !info ) if( !info )

View file

@ -42,7 +42,7 @@ namespace Scripting {
bool loadScript( const std::string& path ); bool loadScript( const std::string& path );
bool unloadScript( const std::string& name ); bool unloadScript( const std::string& name );
void reloadScript( const std::string &name ); void queueScriptReload( const std::string& name );
void findScripts( std::set< Core::Scripting::ScriptInfo* >& scripts, const std::string& search ); void findScripts( std::set< Core::Scripting::ScriptInfo* >& scripts, const std::string& search );
void processLoadQueue(); void processLoadQueue();

View file

@ -91,7 +91,7 @@ void Core::Scripting::ScriptManager::watchDirectories()
{ {
g_log.debug( "Reloading changed script: " + path.stem().string() ); g_log.debug( "Reloading changed script: " + path.stem().string() );
m_nativeScriptManager->reloadScript( path.stem().string() ); m_nativeScriptManager->queueScriptReload( path.stem( ).string( ));
} }
else else
{ {
@ -103,14 +103,15 @@ void Core::Scripting::ScriptManager::watchDirectories()
}); });
} }
void Core::Scripting::ScriptManager::loadDir( std::string dirname, std::set<std::string>& files, std::string ext ) void Core::Scripting::ScriptManager::loadDir( const std::string& dirname, std::set<std::string> &files, const std::string& ext )
{ {
g_log.info( "ScriptEngine: loading scripts from " + dirname ); g_log.info( "ScriptEngine: loading scripts from " + dirname );
boost::filesystem::path targetDir( dirname ); boost::filesystem::path targetDir( dirname );
boost::filesystem::directory_iterator iter( targetDir ), eod; boost::filesystem::directory_iterator iter( targetDir );
boost::filesystem::directory_iterator eod;
BOOST_FOREACH( boost::filesystem::path const& i, make_pair( iter, eod ) ) BOOST_FOREACH( boost::filesystem::path const& i, make_pair( iter, eod ) )
{ {

View file

@ -60,7 +60,7 @@ namespace Core
bool onEventHandlerTradeReturn( Entity::Player& player, uint32_t eventId, uint16_t subEvent, uint16_t param, uint32_t catalogId ); bool onEventHandlerTradeReturn( Entity::Player& player, uint32_t eventId, uint16_t subEvent, uint16_t param, uint32_t catalogId );
void loadDir( std::string dirname, std::set<std::string>& files, std::string ext ); void loadDir( const std::string& dirname, std::set<std::string> &files, const std::string& ext );
NativeScriptManager& getNativeScriptHandler(); NativeScriptManager& getNativeScriptHandler();
}; };