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

Change how scripts init and are exposed during compile time

This commit is contained in:
NotAdam 2019-02-20 17:37:34 +11:00
parent eca4337443
commit 16fa522ca9
5 changed files with 14 additions and 10 deletions

View file

@ -32,12 +32,12 @@ foreach(_scriptDir ${children})
if(NOT ${_scriptname} MATCHES "ScriptLoader")
if(ScriptIncludes)
set(ScriptIncludes "${ScriptIncludes}\n#include \"${_script}\"")
set(ScriptIncludes "${ScriptIncludes}\nextern Sapphire::ScriptAPI::ScriptObject* makeScript${_scriptname}();")
else()
set(ScriptIncludes "#include \"${_script}\"")
set(ScriptIncludes "extern Sapphire::ScriptAPI::ScriptObject* makeScript${_scriptname}();")
endif()
set(ScriptNames "${ScriptNames} static_cast< Sapphire::ScriptAPI::ScriptObject* >( new ${_scriptname} ),\n")
set(ScriptNames "${ScriptNames} makeScript${_scriptname}(),\n")
endif()
endforeach()

View file

@ -6,4 +6,6 @@
#include <Event/EventDefs.h>
#define EXPOSE_SCRIPT( x ) Sapphire::ScriptAPI::ScriptObject* makeScript##x() { return new x; }
#endif //SAPPHIRE_SCRIPTOBJECT_H

View file

@ -22,4 +22,6 @@ public:
}
};
};
EXPOSE_SCRIPT( INSTANCE_NAME );

View file

@ -33,7 +33,7 @@ namespace fs = std::experimental::filesystem;
// garbage to ignore models
bool ignoreModels = false;
std::string gamePath( "C:\\SquareEnix\\FINAL FANTASY XIV - A Realm Reborn\\game\\sqpack" );
std::string gamePath( "/mnt/c/Program Files (x86)/Steam/steamapps/common/FINAL FANTASY XIV Online/game/sqpack" );
std::unordered_map< uint32_t, std::string > eobjNameMap;
std::unordered_map< uint16_t, std::string > zoneNameMap;
std::unordered_map< uint16_t, std::vector< std::pair< uint16_t, std::string > > > zoneInstanceMap;
@ -319,21 +319,21 @@ void loadAllInstanceContentEntries()
if( name.empty() )
continue;
auto type = std::get< uint8_t >( fields.at( 0 ) );
auto teri = std::get< uint32_t >( fields.at( 9 ) );
auto teri = std::get< std::string >( fields.at( 3 ) );
auto i = 0;
while( ( i = name.find( ' ' ) ) != std::string::npos )
name = name.replace( name.begin() + i, name.begin() + i + 1, { '_' } );
std::string outStr(
std::to_string( id ) + ", \"" + name + "\", \"" + zoneNameMap[ teri ] + "\"," + std::to_string( teri ) + "\n"
std::to_string( id ) + ", \"" + name + "\", \"" + teri + "\"," + teri + "\n"
);
out.write( outStr.c_str(), outStr.size() );
//zoneInstanceMap[zoneId].push_back( std::make_pair( id, name ) );
zoneDumpList.emplace( zoneNameMap[ teri ] );
zoneDumpList.emplace( teri );
std::string remove = "★_ '()[]-\x1a\x1\x2\x1f\x1\x3.:";
Sapphire::Util::eraseAllIn( name, remove );
name[ 0 ] = toupper( name[ 0 ] );
contentList.push_back( { id, name, zoneNameMap[ teri ], type } );
contentList.push_back( { id, name, teri, type } );
}
out.close();
}

View file

@ -314,7 +314,7 @@ createScript( std::shared_ptr< Sapphire::Data::Quest >& pQuestData, std::set< st
scriptEntry +
" private:\n" +
sceneStr +
"};\n\n"
"};\n\nEXPOSE_SCRIPT( " + className + " );"
);
std::ofstream outputFile;