Skip to content

Instantly share code, notes, and snippets.

View Ryan-rsm-McKenzie's full-sized avatar

Ryan McKenzie Ryan-rsm-McKenzie

View GitHub Profile
@Ryan-rsm-McKenzie
Ryan-rsm-McKenzie / main.cpp
Created January 15, 2021 02:22
f4se papyrus back end reimplementation
namespace Papyrus
{
#define BIND(a_method, ...) a_vm.BindNativeMethod(obj, #a_method##sv, a_method __VA_OPT__(, ) __VA_ARGS__)
using RE::BSScript::structure_wrapper;
namespace Actor
{
std::optional<structure_wrapper<"Actor", "WornItem">> GetWornItem(const RE::Actor& a_self, RE::BIPED_OBJECT a_slotIndex, bool a_firstPerson)
{
if (a_slotIndex >= RE::BIPED_OBJECT::kTotal) {
@Ryan-rsm-McKenzie
Ryan-rsm-McKenzie / main.cpp
Created December 20, 2020 09:37
commonlibsse move files
#include <algorithm>
#include <array>
#include <cassert>
#include <cstddef>
#include <cstdlib>
#include <cstring>
#include <filesystem>
#include <fstream>
#include <iostream>
#include <span>
@Ryan-rsm-McKenzie
Ryan-rsm-McKenzie / test.cpp
Created June 7, 2020 02:51
invoke level-up notification
auto task = SKSE::GetTaskInterface();
task->AddUITask([]() {
enum
{
QUEST_UPDATE,
SKILL_LEVEL_UPDATE,
PLAYER_LEVEL_UPDATE,
SHOUT_UPDATE
};
@Ryan-rsm-McKenzie
Ryan-rsm-McKenzie / memory.h
Last active May 5, 2020 03:52
reverse engineered reimplementation of VS 2011's `std::unique_ptr`
#include <cassert>
#include <cstdint>
#include <functional>
#include <memory>
#include <type_traits>
#include <utility>
namespace stl
{
template <class T>
@Ryan-rsm-McKenzie
Ryan-rsm-McKenzie / rtti.cpp
Created February 25, 2020 06:04
rtti dump
void DumpRTTI()
{
std::vector<std::pair<std::string, std::uint64_t>> results;
REL::VTable typeInfo(".?AVtype_info@@");
auto baseAddr = REL::Module::BaseAddr();
auto data = REL::Module::GetSection(REL::Module::ID::kData);
auto beg = data.BasePtr<std::uintptr_t>();
auto end = reinterpret_cast<std::uintptr_t*>(data.BaseAddr() + data.Size());
for (auto iter = beg; iter < end; ++iter) {
@Ryan-rsm-McKenzie
Ryan-rsm-McKenzie / main.cpp
Last active March 31, 2024 08:42
CommonLibSSE Serialization Interface Implementation
#include "version.h"
void SaveCallback(SKSE::SerializationInterface* a_intfc)
{
SInt32 num = 42;
std::vector<SInt32> arr;
for (std::size_t i = 0; i < 10; ++i) {
arr.push_back(i);
}
@Ryan-rsm-McKenzie
Ryan-rsm-McKenzie / main.cpp
Last active July 10, 2019 07:42
Native SKSE64 Serialization Interface Implementation
#include "common/IDebugLog.h" // IDebugLog
#include "skse64_common/skse_version.h" // RUNTIME_VERSION
#include "skse64/PluginAPI.h" // PluginHandle, SKSESerializationInterface, SKSEInterface, PluginInfo
#include <ShlObj.h> // CSIDL_MYDOCUMENTS
#include <vector> // vector
#include "version.h" // VERSION_VERSTRING, VERSION_MAJOR
@Ryan-rsm-McKenzie
Ryan-rsm-McKenzie / main.cpp
Last active June 28, 2020 04:47
CommonLibSSE Task Interface Implementation
#include "version.h"
void MyCallback()
{
_MESSAGE("This task was implemented with a free function!");
}
extern "C" DLLEXPORT bool APIENTRY SKSEPlugin_Query(const SKSE::QueryInterface* a_skse, SKSE::PluginInfo* a_info)
@Ryan-rsm-McKenzie
Ryan-rsm-McKenzie / main.cpp
Last active May 7, 2019 09:59
Native SKSE64 Task Interface Implementation
#include "common/IDebugLog.h" // IDebugLog
#include "skse64_common/skse_version.h" // RUNTIME_VERSION
#include "skse64/gamethreads.h" // TaskDelegate
#include "skse64/PluginAPI.h" // SKSETaskInterface, SKSEInterface, PluginInfo
#include <ShlObj.h> // CSIDL_MYDOCUMENTS
#include "version.h" // VERSION_VERSTRING, VERSION_MAJOR
@Ryan-rsm-McKenzie
Ryan-rsm-McKenzie / MyClass.psc
Last active March 22, 2024 05:19
CommonLibSSE Papyrus Interface Implementation
ScriptName MyClass
String Function HelloWorld() Global Native
Int Function Sum(Int a_num1, Int a_num2) Global Native