1
Fork 0
mirror of https://github.com/SapphireServer/Sapphire.git synced 2025-04-26 22:37:45 +00:00

fix templated getScriptObject not linking correctly

This commit is contained in:
GokuWeedLord 2017-12-10 16:49:01 +11:00
parent 2cd85c212f
commit e2bc55cd44
3 changed files with 39 additions and 36 deletions

View file

@ -53,36 +53,36 @@ namespace Core {
void NativeScript::loadScript( std::string path ) void NativeScript::loadScript( std::string path )
{ {
// auto handle = m_loader.loadModule( path ); auto handle = m_loader.loadModule( path );
// if( handle ) if( handle )
// { {
// // todo: this is shit // todo: this is shit
// if( auto script = m_loader.getScriptObject< StatusEffectScript >( handle ) ) if( auto script = m_loader.getScriptObject< StatusEffectScript >( handle ) )
// { {
// m_statusEffectScripts.insert( std::make_pair( script->getEffectId(), script ) ); m_statusEffectScripts.insert( std::make_pair( script->getEffectId(), script ) );
// } }
// else if( auto script = m_loader.getScriptObject< ActionScript >( handle ) ) else if( auto script = m_loader.getScriptObject< ActionScript >( handle ) )
// { {
// m_actionScripts.insert( std::make_pair( script->getActionId(), script ) ); m_actionScripts.insert( std::make_pair( script->getActionId(), script ) );
// } }
// else if( auto script = m_loader.getScriptObject< QuestScript >( handle ) ) else if( auto script = m_loader.getScriptObject< QuestScript >( handle ) )
// { {
// m_questScripts.insert( std::make_pair( script->getQuestId(), script ) ); m_questScripts.insert( std::make_pair( script->getQuestId(), script ) );
// } }
// else if( auto script = m_loader.getScriptObject< BattleNpcScript >( handle ) ) else if( auto script = m_loader.getScriptObject< BattleNpcScript >( handle ) )
// { {
// m_battleNpcScripts.insert( std::make_pair( script->getNpcId(), script ) ); m_battleNpcScripts.insert( std::make_pair( script->getNpcId(), script ) );
// } }
// else if( auto script = m_loader.getScriptObject< ZoneScript >( handle ) ) else if( auto script = m_loader.getScriptObject< ZoneScript >( handle ) )
// { {
// m_zoneScripts.insert( std::make_pair( script->getZoneId(), script ) ); m_zoneScripts.insert( std::make_pair( script->getZoneId(), script ) );
// } }
// else else
// { {
// // unload anything which doesn't have a suitable export // unload anything which doesn't have a suitable export
// m_loader.unloadScript( handle ); m_loader.unloadScript( handle );
// } }
// } }
} }

View file

@ -60,12 +60,11 @@ ModuleHandle Core::Scripting::ScriptLoader::loadModule( std::string path )
return handle; return handle;
} }
template< typename T > ScriptObject* Core::Scripting::ScriptLoader::getScriptObject( ModuleHandle handle, std::string name )
T* Core::Scripting::ScriptLoader::getScriptObject( ModuleHandle handle )
{ {
typedef T* (*getScriptObjectType)(); typedef ScriptObject* (*getScriptObjectType)();
auto fn = boost::str( boost::format( "get%1%" ) % name );
auto fn = boost::str( boost::format( "get%1%" ) % typeid( T ).name() );
g_log.info( "getting symbol: " + fn ); g_log.info( "getting symbol: " + fn );
#ifdef _WIN32 #ifdef _WIN32

View file

@ -7,7 +7,6 @@
#ifdef _WIN32 #ifdef _WIN32
#include <windows.h> #include <windows.h>
typedef HMODULE ModuleHandle; typedef HMODULE ModuleHandle;
#else #else
#include <dlfcn.h> #include <dlfcn.h>
@ -31,8 +30,13 @@ namespace Scripting {
bool unloadScript( std::string ); bool unloadScript( std::string );
bool unloadScript( ModuleHandle ); bool unloadScript( ModuleHandle );
ScriptObject* getScriptObject( ModuleHandle handle, std::string name );
template< typename T > template< typename T >
T* getScriptObject( ModuleHandle ); T* getScriptObject( ModuleHandle handle )
{
return static_cast< T* >( getScriptObject( handle, typeid( T ).name() ) );
}
}; };
} }