mirror of
https://github.com/SapphireServer/Sapphire.git
synced 2025-04-26 22:37:45 +00:00
scripts are now built into common libs instead of seperate libs
This commit is contained in:
parent
c0fb85379c
commit
2868bfc69f
31 changed files with 225 additions and 225 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -111,3 +111,6 @@ src/common/Version\.cpp
|
||||||
|
|
||||||
# travis-ci build mtime cache
|
# travis-ci build mtime cache
|
||||||
.mtime_cache
|
.mtime_cache
|
||||||
|
|
||||||
|
# generated script loader files
|
||||||
|
scripts/native/*/ScriptLoader.cpp
|
|
@ -2,47 +2,66 @@ cmake_minimum_required(VERSION 3.0)
|
||||||
project(Sapphire_Script)
|
project(Sapphire_Script)
|
||||||
|
|
||||||
file(GLOB SCRIPT_INCLUDE_FILES "${CMAKE_CURRENT_SOURCE_DIR}/*.h")
|
file(GLOB SCRIPT_INCLUDE_FILES "${CMAKE_CURRENT_SOURCE_DIR}/*.h")
|
||||||
file(GLOB_RECURSE SCRIPT_FILES "${CMAKE_CURRENT_SOURCE_DIR}/*.cpp")
|
|
||||||
|
|
||||||
include_directories("${CMAKE_SOURCE_DIR}/src/servers/")
|
include_directories("${CMAKE_SOURCE_DIR}/src/servers/")
|
||||||
include_directories("${CMAKE_SOURCE_DIR}/src/servers/sapphire_zone/")
|
include_directories("${CMAKE_SOURCE_DIR}/src/servers/sapphire_zone/")
|
||||||
include_directories("${CMAKE_CURRENT_SOURCE_DIR}")
|
include_directories("${CMAKE_CURRENT_SOURCE_DIR}")
|
||||||
|
|
||||||
if(MSVC)
|
message("exec: ${EXECUTABLE_OUTPUT_DIRECTORY}")
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Yc\"${CMAKE_CURRENT_SOURCE_DIR}/ScriptObject.h\" /FI\"${CMAKE_CURRENT_SOURCE_DIR}/ScriptObject.h\"")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
message( "exec: ${EXECUTABLE_OUTPUT_DIRECTORY}" )
|
set(SCRIPT_LIB_DIR "${EXECUTABLE_OUTPUT_DIRECTORY}/compiledscripts/" )
|
||||||
|
set(EXECUTABLE_OUTPUT_PATH "${SCRIPT_LIB_DIR}")
|
||||||
|
set(LIBRARY_OUTPUT_PATH "${SCRIPT_LIB_DIR}")
|
||||||
|
set(RUNTIME_OUTPUT_DIRECTORY "${SCRIPT_LIB_DIR}")
|
||||||
|
|
||||||
set( SCRIPT_LIB_DIR "${EXECUTABLE_OUTPUT_DIRECTORY}/compiledscripts/" )
|
|
||||||
set( EXECUTABLE_OUTPUT_PATH "${SCRIPT_LIB_DIR}")
|
|
||||||
set( LIBRARY_OUTPUT_PATH "${SCRIPT_LIB_DIR}")
|
|
||||||
set( RUNTIME_OUTPUT_DIRECTORY "${SCRIPT_LIB_DIR}")
|
|
||||||
|
|
||||||
foreach(_sourcefile ${SCRIPT_FILES})
|
file(GLOB children "${CMAKE_CURRENT_SOURCE_DIR}/*" )
|
||||||
get_filename_component(_file "${_sourcefile}" NAME_WE)
|
foreach(_scriptDir ${children})
|
||||||
add_library("${_file}" MODULE "${_sourcefile}" "${SCRIPT_INCLUDE_FILES}")
|
get_filename_component(_name "${_scriptDir}" NAME_WE)
|
||||||
|
if(IS_DIRECTORY ${_scriptDir} AND NOT ${_name} MATCHES "CMakeFiles")
|
||||||
|
message("discovered plugin lib: ${_scriptDir} (${_name})")
|
||||||
|
|
||||||
if(MSVC)
|
file(GLOB_RECURSE SCRIPT_FILES "${_scriptDir}/*.cpp")
|
||||||
set_source_files_properties("${_file}" PROPERTIES
|
|
||||||
COMPILE_FLAGS "/YuScriptObject.h"
|
# build file list
|
||||||
)
|
foreach(_script ${SCRIPT_FILES})
|
||||||
set_target_properties(${_file} PROPERTIES
|
get_filename_component( _scriptname "${_script}" NAME_WE)
|
||||||
CXX_STANDARD 14
|
|
||||||
CXX_STANDARD_REQUIRED ON
|
if(NOT ${_scriptname} MATCHES "ScriptLoader")
|
||||||
CXX_EXTENSIONS ON
|
if(ScriptIncludes)
|
||||||
LIBRARY_OUTPUT_DIRECTORY_DEBUG "${SCRIPT_LIB_DIR}"
|
set(ScriptIncludes "${ScriptIncludes}\n#include \"${_script}\"")
|
||||||
LIBRARY_OUTPUT_DIRECTORY_RELEASE "${SCRIPT_LIB_DIR}"
|
else()
|
||||||
LIBRARY_OUTPUT_DIRECTORY_RELWITHDEBINFO "${SCRIPT_LIB_DIR}"
|
set(ScriptIncludes "#include \"${_script}\"")
|
||||||
LIBRARY_OUTPUT_DIRECTORY_MINSIZEREL "${SCRIPT_LIB_DIR}"
|
endif()
|
||||||
|
|
||||||
|
set(ScriptNames "${ScriptNames} static_cast< ScriptObject* >( new ${_scriptname} ),\n")
|
||||||
|
endif()
|
||||||
|
endforeach()
|
||||||
|
|
||||||
|
add_library("script_${_name}" MODULE "${SCRIPT_FILES}" "${SCRIPT_INCLUDE_FILES}" "${_scriptDir}/ScriptLoader.cpp")
|
||||||
|
target_link_libraries("script_${_name}" sapphire_zone)
|
||||||
|
|
||||||
|
if(MSVC)
|
||||||
|
set_target_properties("script_${_name}" PROPERTIES
|
||||||
|
CXX_STANDARD 14
|
||||||
|
CXX_STANDARD_REQUIRED ON
|
||||||
|
CXX_EXTENSIONS ON
|
||||||
|
LIBRARY_OUTPUT_DIRECTORY_DEBUG "${SCRIPT_LIB_DIR}"
|
||||||
|
LIBRARY_OUTPUT_DIRECTORY_RELEASE "${SCRIPT_LIB_DIR}"
|
||||||
|
LIBRARY_OUTPUT_DIRECTORY_RELWITHDEBINFO "${SCRIPT_LIB_DIR}"
|
||||||
|
LIBRARY_OUTPUT_DIRECTORY_MINSIZEREL "${SCRIPT_LIB_DIR}"
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/ScriptLoader.cpp.in" "${_scriptDir}/ScriptLoader.cpp")
|
||||||
|
|
||||||
|
add_custom_command(TARGET "script_${_name}" POST_BUILD
|
||||||
|
COMMAND ${CMAKE_COMMAND} -E remove "${SCRIPT_LIB_DIR}/script_${_name}.exp"
|
||||||
|
COMMAND ${CMAKE_COMMAND} -E remove "${SCRIPT_LIB_DIR}/script_${_name}.lib"
|
||||||
|
COMMAND ${CMAKE_COMMAND} -E remove "${SCRIPT_LIB_DIR}/script_${_name}.ilk"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
unset(ScriptIncludes)
|
||||||
|
unset(ScriptNames)
|
||||||
endif()
|
endif()
|
||||||
|
endforeach()
|
||||||
target_link_libraries("${_file}" sapphire_zone)
|
|
||||||
|
|
||||||
add_custom_command(TARGET "${_file}" POST_BUILD
|
|
||||||
COMMAND ${CMAKE_COMMAND} -E remove "${SCRIPT_LIB_DIR}/${_file}.exp"
|
|
||||||
COMMAND ${CMAKE_COMMAND} -E remove "${SCRIPT_LIB_DIR}/${_file}.lib"
|
|
||||||
COMMAND ${CMAKE_COMMAND} -E remove "${SCRIPT_LIB_DIR}/${_file}.ilk"
|
|
||||||
)
|
|
||||||
endforeach(_sourcefile ${SCRIPT_FILES})
|
|
||||||
|
|
|
@ -33,6 +33,4 @@ public:
|
||||||
{
|
{
|
||||||
Scene00000( player );
|
Scene00000( player );
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
EXPORT_SCRIPTOBJECT( CmnDefCutSceneReplay )
|
|
|
@ -53,6 +53,4 @@ public:
|
||||||
{
|
{
|
||||||
Scene00100( player );
|
Scene00100( player );
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
EXPORT_SCRIPTOBJECT( CmnDefInnBed )
|
|
|
@ -55,6 +55,4 @@ public:
|
||||||
{
|
{
|
||||||
Scene00001( player );
|
Scene00001( player );
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
EXPORT_SCRIPTOBJECT( CmnDefLinkShell )
|
|
|
@ -1,9 +1,9 @@
|
||||||
#include "../ScriptObject.h"
|
#include "../ScriptObject.h"
|
||||||
|
|
||||||
class HouFurOrchestrionDef : public EventScript
|
class HouFurOrchestrion : public EventScript
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
HouFurOrchestrionDef() : EventScript( "HouFurOrchestrionDef", 721226 )
|
HouFurOrchestrion() : EventScript( "HouFurOrchestrion", 721226 )
|
||||||
{}
|
{}
|
||||||
|
|
||||||
void Scene00000( Entity::Player& player )
|
void Scene00000( Entity::Player& player )
|
||||||
|
@ -15,6 +15,4 @@ public:
|
||||||
{
|
{
|
||||||
Scene00000( player );
|
Scene00000( player );
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
EXPORT_SCRIPTOBJECT( HouFurOrchestrionDef )
|
|
16
scripts/native/ScriptLoader.cpp.in
Normal file
16
scripts/native/ScriptLoader.cpp.in
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
class ScriptObject;
|
||||||
|
|
||||||
|
@ScriptIncludes@
|
||||||
|
|
||||||
|
const ScriptObject* ptrs[] =
|
||||||
|
{
|
||||||
|
@ScriptNames@
|
||||||
|
nullptr
|
||||||
|
};
|
||||||
|
|
||||||
|
extern "C" EXPORT const ScriptObject** getScripts()
|
||||||
|
{
|
||||||
|
return ptrs;
|
||||||
|
}
|
|
@ -10,6 +10,4 @@ public:
|
||||||
{
|
{
|
||||||
player.addStatusEffectByIdIfNotExist( 50, 20000, player, 30 );
|
player.addStatusEffectByIdIfNotExist( 50, 20000, player, 30 );
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
EXPORT_SCRIPTOBJECT( ActionSprint3 )
|
|
|
@ -43,6 +43,4 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
EXPORT_SCRIPTOBJECT( Aethernet )
|
|
|
@ -65,6 +65,4 @@ public:
|
||||||
{}, 0 );
|
{}, 0 );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
EXPORT_SCRIPTOBJECT( Aetheryte )
|
|
|
@ -1,31 +1,28 @@
|
||||||
#include "../ScriptObject.h"
|
#include "../ScriptObject.h"
|
||||||
|
|
||||||
#define ERANGE_HOWTO_ANN_AND_QUEST 2117539
|
|
||||||
#define ERANGE_HOWTO_QUEST_REWARD 2366417
|
|
||||||
#define ERANGE_SEQ_1_CLOSED_1 2351918
|
|
||||||
#define POS_SEQ_1_CLOSED_RETURN_1 2351921
|
|
||||||
#define ERANGE_SEQ_1_CLOSED_2 2351919
|
|
||||||
#define POS_SEQ_1_CLOSED_RETURN_2 2351921
|
|
||||||
#define ERANGE_ALWAYS_CLOSED_1 2280846
|
|
||||||
#define POS_ALWAYS_CLOSED_RETURN_1 2320804
|
|
||||||
#define ENPC_ALWAYS_CLOSED_1 2367988
|
|
||||||
#define ERANGE_ALWAYS_CLOSED_3 2280851
|
|
||||||
#define POS_ALWAYS_CLOSED_RETURN_3 2320811
|
|
||||||
#define ENPC_ALWAYS_CLOSED_3 2563491
|
|
||||||
#define BGM_MUSIC_ZONE_FST_TWN 1003
|
|
||||||
#define NCUT_FST_1 3
|
|
||||||
#define NCUT_FST_2 53
|
|
||||||
#define NCUT_FST_3 226
|
|
||||||
#define ENPC_QUEST_OFFER 1985150
|
|
||||||
#define NCUT_LIGHT_ALL 2
|
|
||||||
#define NCUT_LIGHT_FST_1 147
|
|
||||||
#define NCUT_LIGHT_FST_2 146
|
|
||||||
|
|
||||||
class OpeningGridania : public EventScript
|
class OpeningGridania : public EventScript
|
||||||
{
|
{
|
||||||
public:
|
private:
|
||||||
OpeningGridania() : EventScript( "OpeningGridania", 1245186 )
|
static constexpr auto ERANGE_HOWTO_ANN_AND_QUEST = 2117539;
|
||||||
{}
|
static constexpr auto ERANGE_HOWTO_QUEST_REWARD = 2366417;
|
||||||
|
static constexpr auto ERANGE_SEQ_1_CLOSED_1 = 2351918;
|
||||||
|
static constexpr auto POS_SEQ_1_CLOSED_RETURN_1 = 2351921;
|
||||||
|
static constexpr auto ERANGE_SEQ_1_CLOSED_2 = 2351919;
|
||||||
|
static constexpr auto POS_SEQ_1_CLOSED_RETURN_2 = 2351921;
|
||||||
|
static constexpr auto ERANGE_ALWAYS_CLOSED_1 = 2280846;
|
||||||
|
static constexpr auto POS_ALWAYS_CLOSED_RETURN_1 = 2320804;
|
||||||
|
static constexpr auto ENPC_ALWAYS_CLOSED_1 = 2367988;
|
||||||
|
static constexpr auto ERANGE_ALWAYS_CLOSED_3 = 2280851;
|
||||||
|
static constexpr auto POS_ALWAYS_CLOSED_RETURN_3 = 2320811;
|
||||||
|
static constexpr auto ENPC_ALWAYS_CLOSED_3 = 2563491;
|
||||||
|
static constexpr auto BGM_MUSIC_ZONE_FST_TWN = 1003;
|
||||||
|
static constexpr auto NCUT_FST_1 = 3;
|
||||||
|
static constexpr auto NCUT_FST_2 = 53;
|
||||||
|
static constexpr auto NCUT_FST_3 = 226;
|
||||||
|
static constexpr auto ENPC_QUEST_OFFER = 1985150;
|
||||||
|
static constexpr auto NCUT_LIGHT_ALL = 2;
|
||||||
|
static constexpr auto NCUT_LIGHT_FST_1 = 147;
|
||||||
|
static constexpr auto NCUT_LIGHT_FST_2 = 146;
|
||||||
|
|
||||||
void Scene00000( Entity::Player& player )
|
void Scene00000( Entity::Player& player )
|
||||||
{
|
{
|
||||||
|
@ -67,7 +64,9 @@ public:
|
||||||
player.eventPlay( getId(), 40, 1, 2, 1, callback );
|
player.eventPlay( getId(), 40, 1, 2, 1, callback );
|
||||||
}
|
}
|
||||||
|
|
||||||
///////////////////////////////
|
public:
|
||||||
|
OpeningGridania() : EventScript( "OpeningGridania", 1245186 )
|
||||||
|
{}
|
||||||
|
|
||||||
void onEnterZone( Entity::Player& player, uint32_t eventId, uint16_t param1, uint16_t param2 ) override
|
void onEnterZone( Entity::Player& player, uint32_t eventId, uint16_t param1, uint16_t param2 ) override
|
||||||
{
|
{
|
||||||
|
@ -88,6 +87,4 @@ public:
|
||||||
Scene00020( player );
|
Scene00020( player );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
EXPORT_SCRIPTOBJECT( OpeningGridania )
|
|
|
@ -95,6 +95,4 @@ public:
|
||||||
{
|
{
|
||||||
// todo: handle closed events
|
// todo: handle closed events
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
EXPORT_SCRIPTOBJECT( OpeningLimsa )
|
|
|
@ -88,6 +88,4 @@ public:
|
||||||
Scene00020( player );
|
Scene00020( player );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
EXPORT_SCRIPTOBJECT( OpeningUldah )
|
|
|
@ -6,29 +6,29 @@
|
||||||
// Start NPC: 1001148
|
// Start NPC: 1001148
|
||||||
// End NPC: 1001140
|
// End NPC: 1001140
|
||||||
|
|
||||||
#define SEQ_0 0
|
|
||||||
#define SEQ_FINISH 255
|
|
||||||
|
|
||||||
#define RewardExpFactor 50
|
|
||||||
#define RewardGil 103
|
|
||||||
|
|
||||||
#define ACTOR0 1001148
|
|
||||||
#define ACTOR1 1001140
|
|
||||||
#define CUT_EVENT 29
|
|
||||||
#define EOBJECT0 2001659
|
|
||||||
#define EOBJECT1 2001660
|
|
||||||
#define EOBJECT7 2616477
|
|
||||||
#define EVENT_ACTION_SEARCH 1
|
|
||||||
#define HOWTO_QUEST_ACCEPT 12
|
|
||||||
#define HOWTO_QUEST_ANNOUNCE 2
|
|
||||||
#define HOWTO_REWARD 11
|
|
||||||
#define HOWTO_TODO 3
|
|
||||||
#define OPENING_EVENT_HANDLER 1245186
|
|
||||||
#define SEQ_2_ACTOR1 2
|
|
||||||
|
|
||||||
class ManFst001 : public EventScript
|
class ManFst001 : public EventScript
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
|
static constexpr auto SEQ_0 = 0;
|
||||||
|
static constexpr auto SEQ_FINISH = 255;
|
||||||
|
|
||||||
|
static constexpr auto RewardExpFactor = 50;
|
||||||
|
static constexpr auto RewardGil = 103;
|
||||||
|
|
||||||
|
static constexpr auto ACTOR0 = 1001148;
|
||||||
|
static constexpr auto ACTOR1 = 1001140;
|
||||||
|
static constexpr auto CUT_EVENT = 29;
|
||||||
|
static constexpr auto EOBJECT0 = 2001659;
|
||||||
|
static constexpr auto EOBJECT1 = 2001660;
|
||||||
|
static constexpr auto EOBJECT7 = 2616477;
|
||||||
|
static constexpr auto EVENT_ACTION_SEARCH = 1;
|
||||||
|
static constexpr auto HOWTO_QUEST_ACCEPT = 12;
|
||||||
|
static constexpr auto HOWTO_QUEST_ANNOUNCE = 2;
|
||||||
|
static constexpr auto HOWTO_REWARD = 11;
|
||||||
|
static constexpr auto HOWTO_TODO = 3;
|
||||||
|
static constexpr auto OPENING_EVENT_HANDLER = 1245186;
|
||||||
|
static constexpr auto SEQ_2_ACTOR1 = 2;
|
||||||
|
|
||||||
void Scene00000( Entity::Player& player )
|
void Scene00000( Entity::Player& player )
|
||||||
{
|
{
|
||||||
auto callback = [&]( Entity::Player& player, uint32_t eventId, uint16_t param1, uint16_t param2, uint16_t param3 )
|
auto callback = [&]( Entity::Player& player, uint32_t eventId, uint16_t param1, uint16_t param2, uint16_t param3 )
|
||||||
|
@ -101,6 +101,4 @@ public:
|
||||||
else if( actor == ACTOR1 )
|
else if( actor == ACTOR1 )
|
||||||
Scene00004( player );
|
Scene00004( player );
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
EXPORT_SCRIPTOBJECT( ManFst001 )
|
|
|
@ -220,6 +220,4 @@ public:
|
||||||
else if( actor == ACTOR4 )
|
else if( actor == ACTOR4 )
|
||||||
Scene00005( player );
|
Scene00005( player );
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
EXPORT_SCRIPTOBJECT( ManFst002 )
|
|
|
@ -18,6 +18,4 @@ public:
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
EXPORT_SCRIPTOBJECT( ManFst003 )
|
|
|
@ -78,7 +78,7 @@ class ManFst004 : public EventScript
|
||||||
// Event Handlers
|
// Event Handlers
|
||||||
void onTalk( uint32_t eventId, Entity::Player& player, uint64_t actorId ) override
|
void onTalk( uint32_t eventId, Entity::Player& player, uint64_t actorId ) override
|
||||||
{
|
{
|
||||||
auto actor = Event::mapEventActorToRealActor( actorId );
|
auto actor = Event::mapEventActorToRealActor( static_cast< uint32_t >( actorId ) );
|
||||||
if( actor == ManFst004::Actor0 )
|
if( actor == ManFst004::Actor0 )
|
||||||
{
|
{
|
||||||
Scene00000( player );
|
Scene00000( player );
|
||||||
|
@ -254,6 +254,4 @@ class ManFst004 : public EventScript
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
EXPORT_SCRIPTOBJECT( ManFst004 );
|
|
|
@ -158,6 +158,4 @@ public:
|
||||||
else if( actor == ACTOR2 )
|
else if( actor == ACTOR2 )
|
||||||
Scene00011( player );
|
Scene00011( player );
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
EXPORT_SCRIPTOBJECT( ManSea001 );
|
|
|
@ -146,6 +146,4 @@ public:
|
||||||
if( actor == ACTOR0 )
|
if( actor == ACTOR0 )
|
||||||
Scene00000( player );
|
Scene00000( player );
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
EXPORT_SCRIPTOBJECT( ManSea002 )
|
|
|
@ -140,6 +140,4 @@ public:
|
||||||
else if( actor == ACTOR1 )
|
else if( actor == ACTOR1 )
|
||||||
Scene00004( player );
|
Scene00004( player );
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
EXPORT_SCRIPTOBJECT( ManWil001 )
|
|
|
@ -153,6 +153,4 @@ public:
|
||||||
if( actor == ACTOR0 )
|
if( actor == ACTOR0 )
|
||||||
Scene00000( player );
|
Scene00000( player );
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
EXPORT_SCRIPTOBJECT( ManWil002 )
|
|
|
@ -81,6 +81,4 @@ public:
|
||||||
Scene00100( player );
|
Scene00100( player );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
EXPORT_SCRIPTOBJECT( SubFst001 )
|
|
|
@ -53,6 +53,4 @@ public:
|
||||||
else if( actor == ACTOR1 )
|
else if( actor == ACTOR1 )
|
||||||
Scene00001( player );
|
Scene00001( player );
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
EXPORT_SCRIPTOBJECT( SubFst010 )
|
|
|
@ -181,6 +181,4 @@ public:
|
||||||
else if( actor == ACTOR1 && emoteId == 11 && player.getQuestSeq( getId() ) == SEQ_5 )
|
else if( actor == ACTOR1 && emoteId == 11 && player.getQuestSeq( getId() ) == SEQ_5 )
|
||||||
Scene00096( player );
|
Scene00096( player );
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
EXPORT_SCRIPTOBJECT( SubFst013 )
|
|
|
@ -1,10 +0,0 @@
|
||||||
#include "Version.h"
|
|
||||||
|
|
||||||
namespace Core {
|
|
||||||
namespace Version {
|
|
||||||
|
|
||||||
const std::string GIT_HASH = "d799f2e3c2d745f9d9e07d6e37664fc031b7c264";
|
|
||||||
const std::string VERSION = "-128-NOTFOUND";
|
|
||||||
|
|
||||||
} /* Version */
|
|
||||||
} /* Core */
|
|
|
@ -567,9 +567,9 @@ void Core::DebugCommandHandler::script( char* data, Entity::Player &player, boos
|
||||||
for( auto it = scripts.begin(); it != scripts.end(); ++it )
|
for( auto it = scripts.begin(); it != scripts.end(); ++it )
|
||||||
{
|
{
|
||||||
auto script = *it;
|
auto script = *it;
|
||||||
player.sendDebug( " - '" + script->script_name + "' loaded at @ 0x" +
|
player.sendDebug( " - '" + script->library_name + "' loaded at @ 0x" +
|
||||||
boost::str( boost::format( "%|X|" ) % script->handle ) +
|
boost::str( boost::format( "%|X|" ) % script->handle ) +
|
||||||
", script ptr: 0x" + boost::str( boost::format( "%|X|" ) % script->script ) );
|
", num scripts: " + std::to_string( script->scripts.size() ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -12,10 +12,6 @@
|
||||||
#define EXPORT __attribute__((visibility("default")))
|
#define EXPORT __attribute__((visibility("default")))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define EXPORT_SCRIPTOBJECT( type ) \
|
|
||||||
extern "C" EXPORT ScriptObject* getScript() \
|
|
||||||
{ return static_cast< ScriptObject* >( new type ); }
|
|
||||||
|
|
||||||
using namespace Core;
|
using namespace Core;
|
||||||
|
|
||||||
// constant script ids for certain events
|
// constant script ids for certain events
|
||||||
|
|
|
@ -57,38 +57,50 @@ namespace Core {
|
||||||
if( !module )
|
if( !module )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
auto script = m_loader.getScriptObject( module->handle );
|
auto scripts = m_loader.getScripts( module->handle );
|
||||||
if( !script )
|
if( !scripts )
|
||||||
{
|
{
|
||||||
m_loader.unloadScript( module );
|
m_loader.unloadScript( module );
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
module->script = script;
|
//
|
||||||
module->script_name = script->getName();
|
bool success = false;
|
||||||
module->type = script->getType();
|
|
||||||
|
|
||||||
switch( script->getType() )
|
for( int i = 0; ; i++ )
|
||||||
{
|
{
|
||||||
case ScriptType::StatusEffect:
|
if( scripts[i] == nullptr )
|
||||||
m_statusEffectScripts[ script->getId() ] = dynamic_cast< StatusEffectScript* >( script );
|
|
||||||
break;
|
|
||||||
case ScriptType::Action:
|
|
||||||
m_actionScripts[ script->getId() ] = dynamic_cast< ActionScript* >( script );
|
|
||||||
break;
|
|
||||||
case ScriptType::Quest:
|
|
||||||
m_eventScripts[ script->getId() ] = dynamic_cast< EventScript* >( script );
|
|
||||||
break;
|
|
||||||
case ScriptType::BattleNpc:
|
|
||||||
m_battleNpcScripts[ script->getId() ] = dynamic_cast< BattleNpcScript* >( script );
|
|
||||||
break;
|
|
||||||
case ScriptType::Zone:
|
|
||||||
m_zoneScripts[ script->getId() ] = dynamic_cast< ZoneScript* >( script );
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
auto script = scripts[i];
|
||||||
m_loader.unloadScript( module );
|
module->scripts.push_back( script );
|
||||||
return false;
|
|
||||||
|
switch( script->getType() )
|
||||||
|
{
|
||||||
|
case ScriptType::StatusEffect:
|
||||||
|
m_statusEffectScripts[ script->getId() ] = dynamic_cast< StatusEffectScript* >( script );
|
||||||
|
break;
|
||||||
|
case ScriptType::Action:
|
||||||
|
m_actionScripts[ script->getId() ] = dynamic_cast< ActionScript* >( script );
|
||||||
|
break;
|
||||||
|
case ScriptType::Quest:
|
||||||
|
m_eventScripts[ script->getId() ] = dynamic_cast< EventScript* >( script );
|
||||||
|
break;
|
||||||
|
case ScriptType::BattleNpc:
|
||||||
|
m_battleNpcScripts[ script->getId() ] = dynamic_cast< BattleNpcScript* >( script );
|
||||||
|
break;
|
||||||
|
case ScriptType::Zone:
|
||||||
|
m_zoneScripts[ script->getId() ] = dynamic_cast< ZoneScript* >( script );
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
success = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( !success )
|
||||||
|
{
|
||||||
|
m_loader.unloadScript( module->handle );
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -110,28 +122,29 @@ namespace Core {
|
||||||
|
|
||||||
bool NativeScriptManager::unloadScript( ScriptInfo* info )
|
bool NativeScriptManager::unloadScript( ScriptInfo* info )
|
||||||
{
|
{
|
||||||
auto ptr = info->script;
|
for( auto& script : info->scripts )
|
||||||
|
|
||||||
switch( info->type )
|
|
||||||
{
|
{
|
||||||
case ScriptType::StatusEffect:
|
switch( script->getType() )
|
||||||
removeValueFromMap< uint32_t, StatusEffectScript* >( ptr, m_statusEffectScripts );
|
{
|
||||||
break;
|
case ScriptType::StatusEffect:
|
||||||
case ScriptType::Action:
|
removeValueFromMap< uint32_t, StatusEffectScript* >( script, m_statusEffectScripts );
|
||||||
removeValueFromMap< uint32_t, ActionScript* >( ptr, m_actionScripts );
|
break;
|
||||||
break;
|
case ScriptType::Action:
|
||||||
case ScriptType::Quest:
|
removeValueFromMap< uint32_t, ActionScript* >( script, m_actionScripts );
|
||||||
removeValueFromMap< uint32_t, EventScript* >( ptr, m_eventScripts );
|
break;
|
||||||
break;
|
case ScriptType::Quest:
|
||||||
case ScriptType::BattleNpc:
|
removeValueFromMap< uint32_t, EventScript* >( script, m_eventScripts );
|
||||||
removeValueFromMap< uint32_t, BattleNpcScript* >( ptr, m_battleNpcScripts );
|
break;
|
||||||
break;
|
case ScriptType::BattleNpc:
|
||||||
case ScriptType::Zone:
|
removeValueFromMap< uint32_t, BattleNpcScript* >( script, m_battleNpcScripts );
|
||||||
removeValueFromMap< uint32_t, ZoneScript* >( ptr, m_zoneScripts );
|
break;
|
||||||
break;
|
case ScriptType::Zone:
|
||||||
|
removeValueFromMap< uint32_t, ZoneScript* >( script, m_zoneScripts );
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return false;
|
continue;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return m_loader.unloadScript( info );
|
return m_loader.unloadScript( info );
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
#ifndef SAPPHIRE_SCRIPTINFO_H
|
#ifndef SAPPHIRE_SCRIPTINFO_H
|
||||||
#define SAPPHIRE_SCRIPTINFO_H
|
#define SAPPHIRE_SCRIPTINFO_H
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
#include "NativeScriptApi.h"
|
#include "NativeScriptApi.h"
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
|
@ -22,9 +24,8 @@ namespace Scripting {
|
||||||
std::string cache_path;
|
std::string cache_path;
|
||||||
std::string library_path;
|
std::string library_path;
|
||||||
|
|
||||||
std::string script_name;
|
|
||||||
ModuleHandle handle;
|
ModuleHandle handle;
|
||||||
ScriptObject* script;
|
std::vector< ScriptObject* > scripts;
|
||||||
ScriptType type;
|
ScriptType type;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -100,22 +100,21 @@ Core::Scripting::ScriptInfo* Core::Scripting::ScriptLoader::loadModule( const st
|
||||||
return info;
|
return info;
|
||||||
}
|
}
|
||||||
|
|
||||||
ScriptObject* Core::Scripting::ScriptLoader::getScriptObject( ModuleHandle handle )
|
ScriptObject** Core::Scripting::ScriptLoader::getScripts( ModuleHandle handle )
|
||||||
{
|
{
|
||||||
using getScript = ScriptObject*(*)();
|
using getScripts = ScriptObject**(*)();
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
getScript func = reinterpret_cast< getScript >( GetProcAddress( handle, "getScript" ) );
|
getScripts func = reinterpret_cast< getScripts >( GetProcAddress( handle, "getScripts" ) );
|
||||||
#else
|
#else
|
||||||
getScript func = reinterpret_cast< getScript >( dlsym( handle, "getScript" ) );
|
getScripts func = reinterpret_cast< getScripts >( dlsym( handle, "getScripts" ) );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if( func )
|
if( func )
|
||||||
{
|
{
|
||||||
auto ptr = func();
|
auto ptr = func();
|
||||||
|
|
||||||
g_log.debug( "got ScriptObject @ 0x" + boost::str( boost::format( "%|08X|" ) % ptr ) );
|
g_log.debug( "got ScriptObject array @ 0x" + boost::str( boost::format( "%|08X|" ) % ptr ) );
|
||||||
g_log.debug( "script info -> name: " + std::string( ptr->getName() ) + ", id: " + std::to_string( ptr->getId() ) );
|
|
||||||
|
|
||||||
return ptr;
|
return ptr;
|
||||||
}
|
}
|
||||||
|
@ -171,7 +170,7 @@ Core::Scripting::ScriptInfo* Core::Scripting::ScriptLoader::getScriptInfo( std::
|
||||||
{
|
{
|
||||||
for( auto it = m_scriptMap.begin(); it != m_scriptMap.end(); ++it )
|
for( auto it = m_scriptMap.begin(); it != m_scriptMap.end(); ++it )
|
||||||
{
|
{
|
||||||
if( it->second->script_name == name )
|
if( it->second->library_name == name )
|
||||||
{
|
{
|
||||||
return it->second;
|
return it->second;
|
||||||
}
|
}
|
||||||
|
@ -184,7 +183,7 @@ void Core::Scripting::ScriptLoader::findScripts( std::set< Core::Scripting::Scri
|
||||||
{
|
{
|
||||||
for( auto it = m_scriptMap.begin(); it != m_scriptMap.end(); ++it )
|
for( auto it = m_scriptMap.begin(); it != m_scriptMap.end(); ++it )
|
||||||
{
|
{
|
||||||
if( it->second->script_name.find( search ) != std::string::npos )
|
if( it->second->library_name.find( search ) != std::string::npos )
|
||||||
{
|
{
|
||||||
scripts.insert( it->second );
|
scripts.insert( it->second );
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,24 +19,30 @@ typedef void* ModuleHandle;
|
||||||
namespace Core {
|
namespace Core {
|
||||||
namespace Scripting {
|
namespace Scripting {
|
||||||
|
|
||||||
class ScriptLoader {
|
class ScriptLoader
|
||||||
|
{
|
||||||
protected:
|
protected:
|
||||||
std::unordered_map< std::string, ScriptInfo* > m_scriptMap;
|
std::unordered_map< std::string, ScriptInfo* > m_scriptMap;
|
||||||
|
|
||||||
bool unloadModule( ModuleHandle );
|
bool unloadModule( ModuleHandle );
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ScriptLoader();
|
ScriptLoader();
|
||||||
|
|
||||||
const std::string getModuleExtension();
|
const std::string getModuleExtension();
|
||||||
ScriptInfo* loadModule( const std::string& );
|
ScriptInfo* loadModule( const std::string& );
|
||||||
bool unloadScript( ScriptInfo* );
|
|
||||||
bool unloadScript( ModuleHandle );
|
|
||||||
ScriptInfo* getScriptInfo( std::string name );
|
|
||||||
ScriptObject* getScriptObject( ModuleHandle handle );
|
|
||||||
bool isModuleLoaded( std::string name );
|
|
||||||
|
|
||||||
void findScripts( std::set< Core::Scripting::ScriptInfo* >& scripts, const std::string& search );
|
bool unloadScript( ScriptInfo* );
|
||||||
|
bool unloadScript( ModuleHandle );
|
||||||
|
|
||||||
|
ScriptInfo* getScriptInfo( std::string name );
|
||||||
|
|
||||||
|
ScriptObject** getScripts( ModuleHandle handle );
|
||||||
|
ScriptObject* getScriptObject( ModuleHandle handle );
|
||||||
|
|
||||||
|
bool isModuleLoaded( std::string name );
|
||||||
|
|
||||||
|
void findScripts( std::set< Core::Scripting::ScriptInfo* >& scripts, const std::string& search );
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue