Skip to content

Commit

Permalink
Update template
Browse files Browse the repository at this point in the history
  • Loading branch information
ThirdEyeSqueegee committed Sep 14, 2023
1 parent 5dcc38a commit 7fd2574
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 52 deletions.
17 changes: 16 additions & 1 deletion cmake/Plugin.h.in
Original file line number Diff line number Diff line change
@@ -1,12 +1,27 @@
#pragma once

using namespace std::string_view_literals;
#define SFSEPluginVersion extern "C" __declspec(dllexport) constinit SFSE::PluginVersionData SFSEPlugin_Version

namespace Plugin
{
using namespace std::string_view_literals;

static constexpr auto Name{ "@PROJECT_NAME@"sv };
static constexpr auto Author{ "AuthorName"sv };
static constexpr auto Version{
REL::Version{@PROJECT_VERSION_MAJOR@, @PROJECT_VERSION_MINOR@, @PROJECT_VERSION_PATCH@, 0}
};
} // namespace Plugin

SFSEPluginVersion = []() noexcept {
SFSE::PluginVersionData data{};

data.PluginVersion(Plugin::Version.pack());
data.PluginName(Plugin::Name);
data.AuthorName(Plugin::Author);
data.UsesSigScanning(true);
data.HasNoStructUse(true);
data.CompatibleVersions({ SFSE::RUNTIME_LATEST });

return data;
}();
32 changes: 0 additions & 32 deletions include/PCH.h
Original file line number Diff line number Diff line change
Expand Up @@ -150,11 +150,6 @@

#include "Plugin.h"

#include <spdlog/sinks/basic_file_sink.h>
#include <spdlog/sinks/msvc_sink.h>

#define SFSEPluginVersion extern "C" __declspec(dllexport) constinit SFSE::PluginVersionData SFSEPlugin_Version

using namespace std::literals;
using namespace REL::literals;

Expand All @@ -179,30 +174,3 @@ class Singleton
return std::addressof(singleton);
}
};

namespace stl
{
using namespace SFSE::stl;

template <typename T>
constexpr void write_thunk_call() noexcept
{
SFSE::AllocTrampoline(14);
auto& trampoline{ SFSE::GetTrampoline() };
T::func = trampoline.write_call<5>(T::address, T::Thunk);
}

template <typename TDest, typename TSource>
constexpr void write_vfunc() noexcept
{
REL::Relocation vtbl{ TDest::VTABLE[0] };
TSource::func = vtbl.write_vfunc(TSource::idx, TSource::Thunk);
}

template <typename T>
constexpr void write_vfunc(const REL::Offset a_offset) noexcept
{
REL::Relocation vtbl{ a_offset };
T::func = vtbl.write_vfunc(T::idx, T::Thunk);
}
} // namespace stl
17 changes: 16 additions & 1 deletion include/Plugin.h
Original file line number Diff line number Diff line change
@@ -1,12 +1,27 @@
#pragma once

using namespace std::string_view_literals;
#define SFSEPluginVersion extern "C" __declspec(dllexport) constinit SFSE::PluginVersionData SFSEPlugin_Version

namespace Plugin
{
using namespace std::string_view_literals;

static constexpr auto Name{ "PluginName"sv };
static constexpr auto Author{ "AuthorName"sv };
static constexpr auto Version{
REL::Version{0, 0, 1, 0}
};
} // namespace Plugin

SFSEPluginVersion = []() noexcept {
SFSE::PluginVersionData data{};

data.PluginVersion(Plugin::Version.pack());
data.PluginName(Plugin::Name);
data.AuthorName(Plugin::Author);
data.UsesSigScanning(true);
data.HasNoStructUse(true);
data.CompatibleVersions({ SFSE::RUNTIME_LATEST });

return data;
}();
1 change: 0 additions & 1 deletion src/Hooks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace Hooks
{
// See PCH.h for some helper functions for writing call site hooks and virtual method swaps
void Install() noexcept
{
}
Expand Down
18 changes: 2 additions & 16 deletions src/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,28 +15,14 @@ void Listener(SFSE::MessagingInterface::Message* message) noexcept
// Main SFSE plugin entry point, initialize everything here
SFSEPluginLoad(const SFSE::LoadInterface* sfse)
{
logger::info("{} {} is loading...", Plugin::Name, Plugin::Version.string("."sv));

Init(sfse);

logger::info("{} {} is loading...", Plugin::Name, Plugin::Version.string("."sv));

if (const auto messaging{ SFSE::GetMessagingInterface() }; !messaging->RegisterListener(Listener))
return false;

logger::info("{} has finished loading.", Plugin::Name);

return true;
}

// Tell SFSE about this plugin
SFSEPluginVersion = []() noexcept {
SFSE::PluginVersionData data{};

data.PluginVersion(Plugin::Version.pack());
data.PluginName(Plugin::Name);
data.AuthorName(Plugin::Author);
data.UsesSigScanning(true);
data.HasNoStructUse(true);
data.CompatibleVersions({ SFSE::RUNTIME_LATEST });

return data;
}();
2 changes: 1 addition & 1 deletion vcpkg.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
{
"kind": "git",
"repository": "https://github.com/Starfield-Reverse-Engineering/Starfield-RE-vcpkg",
"baseline": "3ea44709cc42b68eae2fe5ba374ee6596940cfc7",
"baseline": "24784d22716d637e9b78e2de764044b00d1f5e83",
"packages": ["commonlibsf"]
}
]
Expand Down

0 comments on commit 7fd2574

Please sign in to comment.