Skip to content

Commit

Permalink
rework plugin manager version check and enable plugins
Browse files Browse the repository at this point in the history
  • Loading branch information
ianpatt committed Nov 13, 2021
1 parent f2e27d7 commit 0de11e1
Show file tree
Hide file tree
Showing 6 changed files with 264 additions and 108 deletions.
99 changes: 65 additions & 34 deletions skse64/PluginAPI.h
Original file line number Diff line number Diff line change
Expand Up @@ -134,10 +134,6 @@ struct SKSETaskInterface
void (* AddUITask)(UIDelegate_v1 * task);
};

//#ifdef _PPAPI

// ### this code is unsupported and will be changed in the future

class VMClassRegistry;

struct SKSEPapyrusInterface
Expand All @@ -151,9 +147,6 @@ struct SKSEPapyrusInterface
bool (* Register)(RegisterFunctions callback);
};

//#endif


/**** Messaging API docs ********************************************************************
*
* Messaging API allows inter-plugin communication at run-time. A plugin may register
Expand Down Expand Up @@ -262,39 +255,77 @@ struct SKSETrampolineInterface
void* (*AllocateFromLocalPool)(PluginHandle plugin, size_t size);
};

typedef bool(*_SKSEPlugin_Query)(const SKSEInterface * skse, PluginInfo * info);
typedef bool(*_SKSEPlugin_Load)(const SKSEInterface * skse);

/**** plugin API docs **********************************************************
*
* The base API is pretty simple. Create a project based on the
* skse_plugin_example project included with the SKSE source code, then define
* and export these functions:
*
* bool SKSEPlugin_Query(const SKSEInterface * skse, PluginInfo * info)
/**** plugin versioning ********************************************************
*
* The AE version of Skyrim SE broke plugin versioning as many were written
* with the assumption that the Address Library would always be valid.
* These always report that they are compatible, then exit on startup because
* they cannot find their address library file.
*
* This primary purposes of this function are to fill out the PluginInfo
* structure, and to perform basic version checks based on the info in the
* SKSEInterface structure. Return false if your plugin is incompatible with
* the version of SKSE or the runtime passed in, otherwise return true. In
* either case, fill out the PluginInfo structure.
* To work around this problem, version checking has been reimplemented and
* no longer calls any code. Plugins declare their compatibility, and SKSE
* determines whether to load the plugin. Setting this up is simple, just
* add something like this to your project:
*
* Do not do anything other than fill out the PluginInfo structure and return
* true/false in this callback.
extern "C" {
__declspec(dllexport) SKSEPluginVersionData SKSEPlugin_Version =
{
SKSEPluginVersionData::kVersion,
1,
"my awesome plugin",
"my name",
"support@example.com",
0, // not version independent
{ RUNTIME_VERSION_1_6_318, 0 }, // compatible with 1.6.318
0, // works with any version of the script extender. you probably do not need to put anything here
};
};
*
* If the plugin is being loaded in the context of the editor, isEditor will be
* non-zero, editorVersion will contain the current editor version, and
* runtimeVersion will be zero. In this case you can probably just return
* true, however if you have multiple DLLs implementing the same behavior, for
* example one for each version of ther runtime, only one of them should return
* true.
******************************************************************************/

struct SKSEPluginVersionData
{
enum
{
kVersion = 1,
};

enum
{
// set this if you are using a (potential at this time of writing) post-AE version of the Address Library
kVersionIndependent_AddressLibraryPostAE = 1 << 0,
// set this if you exclusively use signature matching to find your addresses and have NO HARDCODED ADDRESSES
kVersionIndependent_Signatures = 1 << 1,
};

UInt32 dataVersion; // set to kVersion

UInt32 pluginVersion; // version number of your plugin
char name[256]; // null-terminated ASCII plugin name

char author[256]; // null-terminated ASCII plugin author name (can be empty)
char supportEmail[256]; // null-terminated ASCII support email address (can be empty)

// version compatibility
UInt32 versionIndependence; // set to one of the kVersionIndependent_ enums or zero
UInt32 compatibleVersions[16]; // zero-terminated list of RUNTIME_VERSION_ defines your plugin is compatible with

UInt32 seVersionRequired; // minimum version of the script extender required, compared against PACKED_SKSE_VERSION
// you probably should just set this to 0 unless you know what you are doing
};

/**** plugin API docs **********************************************************
*
* The PluginInfo fields should be filled out as follows:
* - infoVersion should be set to PluginInfo::kInfoVersion
* - name should be a pointer to a null-terminated string uniquely identifying
* your plugin, it will be used in the plugin querying API
* - version is only used by the plugin query API, and will be returned to
* scripts requesting the current version of your plugin
* The base API is pretty simple. Add version data as shown in the
* SKSEPluginVersionData docs above, and export this function:
*
* bool SKSEPlugin_Load(const SKSEInterface * skse)
*
Expand Down
Loading

0 comments on commit 0de11e1

Please sign in to comment.