mirror of
https://github.com/SapphireServer/Sapphire.git
synced 2025-04-26 14:37:44 +00:00
fix templated getScriptObject not linking correctly
This commit is contained in:
parent
2cd85c212f
commit
e2bc55cd44
3 changed files with 39 additions and 36 deletions
|
@ -53,36 +53,36 @@ namespace Core {
|
|||
|
||||
void NativeScript::loadScript( std::string path )
|
||||
{
|
||||
// auto handle = m_loader.loadModule( path );
|
||||
// if( handle )
|
||||
// {
|
||||
// // todo: this is shit
|
||||
// if( auto script = m_loader.getScriptObject< StatusEffectScript >( handle ) )
|
||||
// {
|
||||
// m_statusEffectScripts.insert( std::make_pair( script->getEffectId(), script ) );
|
||||
// }
|
||||
// else if( auto script = m_loader.getScriptObject< ActionScript >( handle ) )
|
||||
// {
|
||||
// m_actionScripts.insert( std::make_pair( script->getActionId(), script ) );
|
||||
// }
|
||||
// else if( auto script = m_loader.getScriptObject< QuestScript >( handle ) )
|
||||
// {
|
||||
// m_questScripts.insert( std::make_pair( script->getQuestId(), script ) );
|
||||
// }
|
||||
// else if( auto script = m_loader.getScriptObject< BattleNpcScript >( handle ) )
|
||||
// {
|
||||
// m_battleNpcScripts.insert( std::make_pair( script->getNpcId(), script ) );
|
||||
// }
|
||||
// else if( auto script = m_loader.getScriptObject< ZoneScript >( handle ) )
|
||||
// {
|
||||
// m_zoneScripts.insert( std::make_pair( script->getZoneId(), script ) );
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// // unload anything which doesn't have a suitable export
|
||||
// m_loader.unloadScript( handle );
|
||||
// }
|
||||
// }
|
||||
auto handle = m_loader.loadModule( path );
|
||||
if( handle )
|
||||
{
|
||||
// todo: this is shit
|
||||
if( auto script = m_loader.getScriptObject< StatusEffectScript >( handle ) )
|
||||
{
|
||||
m_statusEffectScripts.insert( std::make_pair( script->getEffectId(), script ) );
|
||||
}
|
||||
else if( auto script = m_loader.getScriptObject< ActionScript >( handle ) )
|
||||
{
|
||||
m_actionScripts.insert( std::make_pair( script->getActionId(), script ) );
|
||||
}
|
||||
else if( auto script = m_loader.getScriptObject< QuestScript >( handle ) )
|
||||
{
|
||||
m_questScripts.insert( std::make_pair( script->getQuestId(), script ) );
|
||||
}
|
||||
else if( auto script = m_loader.getScriptObject< BattleNpcScript >( handle ) )
|
||||
{
|
||||
m_battleNpcScripts.insert( std::make_pair( script->getNpcId(), script ) );
|
||||
}
|
||||
else if( auto script = m_loader.getScriptObject< ZoneScript >( handle ) )
|
||||
{
|
||||
m_zoneScripts.insert( std::make_pair( script->getZoneId(), script ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
// unload anything which doesn't have a suitable export
|
||||
m_loader.unloadScript( handle );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -60,12 +60,11 @@ ModuleHandle Core::Scripting::ScriptLoader::loadModule( std::string path )
|
|||
return handle;
|
||||
}
|
||||
|
||||
template< typename T >
|
||||
T* Core::Scripting::ScriptLoader::getScriptObject( ModuleHandle handle )
|
||||
ScriptObject* Core::Scripting::ScriptLoader::getScriptObject( ModuleHandle handle, std::string name )
|
||||
{
|
||||
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 );
|
||||
|
||||
#ifdef _WIN32
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
|
||||
#ifdef _WIN32
|
||||
#include <windows.h>
|
||||
|
||||
typedef HMODULE ModuleHandle;
|
||||
#else
|
||||
#include <dlfcn.h>
|
||||
|
@ -31,8 +30,13 @@ namespace Scripting {
|
|||
bool unloadScript( std::string );
|
||||
bool unloadScript( ModuleHandle );
|
||||
|
||||
ScriptObject* getScriptObject( ModuleHandle handle, std::string name );
|
||||
|
||||
template< typename T >
|
||||
T* getScriptObject( ModuleHandle );
|
||||
T* getScriptObject( ModuleHandle handle )
|
||||
{
|
||||
return static_cast< T* >( getScriptObject( handle, typeid( T ).name() ) );
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue