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

WarpMgr exposed in scripts

This commit is contained in:
Mordred 2022-02-07 23:08:29 +01:00
parent b337aa2d63
commit 57a25d7df0
3 changed files with 26 additions and 0 deletions

View file

@ -23,6 +23,7 @@ namespace Sapphire::World::Manager
{
class TerritoryMgr;
class LinkshellMgr;
class WarpMgr;
}
extern "C" EXPORT void win32initExd( std::shared_ptr< Sapphire::Data::ExdData > exdData )
@ -38,6 +39,11 @@ extern "C" EXPORT void win32initLinkshell( std::shared_ptr< Sapphire::World::Man
{
Sapphire::Common::Service< Sapphire::World::Manager::LinkshellMgr >::set( lsMgr );
}
extern "C" EXPORT void win32initWarpMgr( std::shared_ptr< Sapphire::World::Manager::WarpMgr > warpMgr )
{
Sapphire::Common::Service< Sapphire::World::Manager::WarpMgr >::set( warpMgr );
}
#endif
extern "C" EXPORT const Sapphire::ScriptAPI::ScriptObject** getScripts()

View file

@ -8,6 +8,7 @@
#include "Manager/LinkshellMgr.h"
#include "Manager/PlayerMgr.h"
#include "Manager/TerritoryMgr.h"
#include "Manager/WarpMgr.h"
#include "Service.h"
#ifdef _MSC_VER
@ -249,6 +250,11 @@ namespace Sapphire::ScriptAPI
{
return Common::Service< World::Manager::TerritoryMgr >::ref();
}
World::Manager::WarpMgr& warpMgr()
{
return Common::Service< World::Manager::WarpMgr >::ref();
}
};
/*!

View file

@ -19,6 +19,7 @@ namespace Sapphire::World::Manager
#include <filesystem>
#include <Manager/TerritoryMgr.h>
#include <Manager/WarpMgr.h>
namespace fs = std::filesystem;
@ -116,9 +117,11 @@ Sapphire::ScriptAPI::ScriptObject** Sapphire::Scripting::ScriptLoader::getScript
using win32initFunc = void(*)( std::shared_ptr< Sapphire::Data::ExdData > );
using win32initFuncTeri = void(*)( std::shared_ptr< Sapphire::World::Manager::TerritoryMgr > );
using win32initFuncLinkshell = void(*)( std::shared_ptr< Sapphire::World::Manager::LinkshellMgr > );
using win32initFuncWarpMgr = void(*)( std::shared_ptr< Sapphire::World::Manager::WarpMgr > );
auto win32init = reinterpret_cast< win32initFunc >( GetProcAddress( handle, "win32initExd" ) );
auto win32initTeri = reinterpret_cast< win32initFuncTeri >( GetProcAddress( handle, "win32initTeri" ) );
auto win32initLinkshell = reinterpret_cast< win32initFuncLinkshell >( GetProcAddress( handle, "win32initLinkshell" ) );
auto win32initWarp = reinterpret_cast< win32initFuncWarpMgr >( GetProcAddress( handle, "win32initWarpMgr" ) );
if( win32init )
{
@ -153,6 +156,17 @@ Sapphire::ScriptAPI::ScriptObject** Sapphire::Scripting::ScriptLoader::getScript
{
Logger::warn( "did not find a win32initLinkshell export on a windows script target - the server will likely crash!" );
}
if( win32initWarp )
{
auto warpMgr = Common::Service< Sapphire::World::Manager::WarpMgr >::get();
auto wptr = warpMgr.lock();
win32initWarp( wptr );
}
else
{
Logger::warn( "did not find a win32initLinkshell export on a windows script target - the server will likely crash!" );
}
#else
auto func = reinterpret_cast< getScripts >( dlsym( handle, "getScripts" ) );
#endif