1
Fork 0
mirror of https://github.com/SapphireServer/Sapphire.git synced 2025-05-01 08:27:46 +00:00

Some more Fc testing code.

This commit is contained in:
Mordred 2023-02-04 23:40:58 +01:00
parent 54f3ffa063
commit 28e0d33921
4 changed files with 43 additions and 1 deletions

View file

@ -35,6 +35,7 @@ namespace Sapphire::World::Manager
class WarpMgr; class WarpMgr;
class RNGMgr; class RNGMgr;
class HousingMgr; class HousingMgr;
class FreeCompanyMgr;
} }
extern "C" EXPORT void win32initServerMgr( std::shared_ptr< Sapphire::World::WorldServer > rngMgr ) extern "C" EXPORT void win32initServerMgr( std::shared_ptr< Sapphire::World::WorldServer > rngMgr )
@ -75,6 +76,10 @@ extern "C" EXPORT void win32initIObjectCache( std::shared_ptr< Sapphire::Instanc
{ {
Sapphire::Common::Service< Sapphire::InstanceObjectCache >::set( ioCache ); Sapphire::Common::Service< Sapphire::InstanceObjectCache >::set( ioCache );
} }
extern "C" EXPORT void win32initFc( std::shared_ptr< Sapphire::World::Manager::FreeCompanyMgr > fcMgr )
{
Sapphire::Common::Service< Sapphire::World::Manager::FreeCompanyMgr >::set( fcMgr );
}
#endif #endif
extern "C" EXPORT const Sapphire::ScriptAPI::ScriptObject** getScripts() extern "C" EXPORT const Sapphire::ScriptAPI::ScriptObject** getScripts()

View file

@ -3,7 +3,9 @@
// In order for this script to be loaded, move it to the correct folder in <root>/scripts/ // In order for this script to be loaded, move it to the correct folder in <root>/scripts/
#include <Actor/Player.h> #include <Actor/Player.h>
#include "FreeCompany/FreeCompany.h"
#include "Manager/EventMgr.h" #include "Manager/EventMgr.h"
#include "Manager/FreeCompanyMgr.h"
#include <ScriptObject.h> #include <ScriptObject.h>
#include <Service.h> #include <Service.h>
@ -47,8 +49,12 @@ class ComDefFreeCompany : public Sapphire::ScriptAPI::EventScript
{ {
if( sceneId == 0 ) if( sceneId == 0 )
eventMgr().resumeScene( player, eventId, sceneId, yieldId, { 0, 0, 0, 0, 0, 0, 0, 1, 1, 1 } ); eventMgr().resumeScene( player, eventId, sceneId, yieldId, { 0, 0, 0, 0, 0, 0, 0, 1, 1, 1 } );
else if( sceneId == 5 ) else if( sceneId == 5 && yieldId == 17 )
{ {
// auto& pFcMgr = Common::Service< Sapphire::World::Manager::FreeCompanyMgr >::ref();
// auto pFc = pFcMgr.createFreeCompany( resultString, resultString, player );
// pFcMgr.writeFreeCompany( pFc->getId() );
/* /*
* GetFcStatusResult * GetFcStatusResult
{ {
@ -74,6 +80,13 @@ class ComDefFreeCompany : public Sapphire::ScriptAPI::EventScript
// { 0, 0, 0, 0, 0, 1, 0, 0, 0, 0 } not in company yet and able to get a petition // { 0, 0, 0, 0, 0, 1, 0, 0, 0, 0 } not in company yet and able to get a petition
eventMgr().resumeScene( player, eventId, sceneId, yieldId, { 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 } ); eventMgr().resumeScene( player, eventId, sceneId, yieldId, { 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 } );
} }
else if( sceneId == 5 && yieldId == 18 )
{
auto& pFcMgr = Common::Service< Sapphire::World::Manager::FreeCompanyMgr >::ref();
auto pFc = pFcMgr.createFreeCompany( resultString, resultString, player );
pFcMgr.writeFreeCompany( pFc->getId() );
eventMgr().resumeScene( player, eventId, sceneId, yieldId, { 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 } );
}
} }

View file

@ -19,6 +19,7 @@ namespace Sapphire::World::Manager
{ {
class TerritoryMgr; class TerritoryMgr;
class RNGMgr; class RNGMgr;
class FreeCompanyMgr;
} }
#endif #endif
@ -131,6 +132,7 @@ Sapphire::ScriptAPI::ScriptObject** Sapphire::Scripting::ScriptLoader::getScript
using win32initRngMgr = void(*)( std::shared_ptr< Sapphire::World::Manager::RNGMgr > ); using win32initRngMgr = void(*)( std::shared_ptr< Sapphire::World::Manager::RNGMgr > );
using win32initHouMgr = void(*)( std::shared_ptr< Sapphire::World::Manager::HousingMgr > ); using win32initHouMgr = void(*)( std::shared_ptr< Sapphire::World::Manager::HousingMgr > );
using win32initServerMgr = void(*)( std::shared_ptr< Sapphire::World::WorldServer > ); using win32initServerMgr = void(*)( std::shared_ptr< Sapphire::World::WorldServer > );
using win32initFuncFc = void(*)( std::shared_ptr< Sapphire::World::Manager::FreeCompanyMgr > );
auto win32init = reinterpret_cast< win32initFunc >( GetProcAddress( handle, "win32initExd" ) ); auto win32init = reinterpret_cast< win32initFunc >( GetProcAddress( handle, "win32initExd" ) );
auto win32initTeri = reinterpret_cast< win32initFuncTeri >( GetProcAddress( handle, "win32initTeri" ) ); auto win32initTeri = reinterpret_cast< win32initFuncTeri >( GetProcAddress( handle, "win32initTeri" ) );
@ -140,6 +142,7 @@ Sapphire::ScriptAPI::ScriptObject** Sapphire::Scripting::ScriptLoader::getScript
auto win32initRng = reinterpret_cast< win32initRngMgr >( GetProcAddress( handle, "win32initRngMgr" ) ); auto win32initRng = reinterpret_cast< win32initRngMgr >( GetProcAddress( handle, "win32initRngMgr" ) );
auto win32initHou = reinterpret_cast< win32initHouMgr >( GetProcAddress( handle, "win32initHouMgr" ) ); auto win32initHou = reinterpret_cast< win32initHouMgr >( GetProcAddress( handle, "win32initHouMgr" ) );
auto win32initServer = reinterpret_cast< win32initServerMgr >( GetProcAddress( handle, "win32initServerMgr" ) ); auto win32initServer = reinterpret_cast< win32initServerMgr >( GetProcAddress( handle, "win32initServerMgr" ) );
auto win32initFc = reinterpret_cast< win32initFuncFc >( GetProcAddress( handle, "win32initFc" ) );
if( win32initServer ) if( win32initServer )
{ {
@ -219,6 +222,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!" ); Logger::warn( "did not find a win32initLinkshell export on a windows script target - the server will likely crash!" );
} }
if( win32initFc )
{
auto fcMgr = Common::Service< Sapphire::World::Manager::FreeCompanyMgr >::get();
auto fcptr = fcMgr.lock();
win32initFc( fcptr );
}
else
{
Logger::warn( "did not find a win32initFc export on a windows script target - the server will likely crash!" );
}
if( win32initWarp ) if( win32initWarp )
{ {
auto warpMgr = Common::Service< Sapphire::World::Manager::WarpMgr >::get(); auto warpMgr = Common::Service< Sapphire::World::Manager::WarpMgr >::get();

View file

@ -48,6 +48,7 @@
#include "Manager/FriendListMgr.h" #include "Manager/FriendListMgr.h"
#include "Manager/BlacklistMgr.h" #include "Manager/BlacklistMgr.h"
#include "Manager/WarpMgr.h" #include "Manager/WarpMgr.h"
#include "Manager/FreeCompanyMgr.h"
#include "ContentFinder/ContentFinder.h" #include "ContentFinder/ContentFinder.h"
@ -186,6 +187,15 @@ void WorldServer::run( int32_t argc, char* argv[] )
} }
Common::Service< Manager::LinkshellMgr >::set( pLsMgr ); Common::Service< Manager::LinkshellMgr >::set( pLsMgr );
auto pFcMgr = std::make_shared< Manager::FreeCompanyMgr >();
Logger::info( "FreeCompanyMgr: Caching free companies" );
if( !pFcMgr->loadFreeCompanies() )
{
Logger::fatal( "Unable to load free companies!" );
return;
}
Common::Service< Manager::FreeCompanyMgr >::set( pFcMgr );
auto pAchvMgr = std::make_shared< Manager::AchievementMgr >(); auto pAchvMgr = std::make_shared< Manager::AchievementMgr >();
Logger::info( "AchievementMgr: Caching data" ); Logger::info( "AchievementMgr: Caching data" );