Skip to content

Commit

Permalink
chore: style formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
shad0wshayd3 authored and github-actions[bot] committed May 11, 2024
1 parent 0279a56 commit f540e01
Show file tree
Hide file tree
Showing 7 changed files with 476 additions and 479 deletions.
134 changes: 67 additions & 67 deletions Plugin/src/Forms/Forms.h
Original file line number Diff line number Diff line change
@@ -1,67 +1,67 @@
#pragma once

class Forms
{
private:
static std::uint32_t HookInitializer_DefaultObject()
{
// Initializer Override
UnarmedPlayerWeapon_DO =
RE::DefaultObjectFormFactory::Create(
"UnarmedPlayerWeapon_DO",
"The unarmed weapon used to calculate the player's displayed attack stats when no weapon is equipped.",
RE::ENUM_FORM_ID::kWEAP);

// Add new
BWA_bEnabled_DO =
RE::DefaultObjectFormFactory::Create(
"BWA_bEnabled_DO",
RE::ENUM_FORM_ID::kGLOB);

BWA_bOverrideInAir_DO =
RE::DefaultObjectFormFactory::Create(
"BWA_bOverrideInAir_DO",
RE::ENUM_FORM_ID::kGLOB);

BWA_bOverrideInCombat_DO =
RE::DefaultObjectFormFactory::Create(
"BWA_bOverrideInCombat_DO",
RE::ENUM_FORM_ID::kGLOB);

BWA_bOverrideTrespassing_DO =
RE::DefaultObjectFormFactory::Create(
"BWA_bOverrideTrespassing_DO",
RE::ENUM_FORM_ID::kGLOB);

BWA_bOverrideTakingHealthDamage_DO =
RE::DefaultObjectFormFactory::Create(
"BWA_bOverrideTakingHealthDamage_DO",
RE::ENUM_FORM_ID::kGLOB);

BWA_bOverrideTakingRadDamage_DO =
RE::DefaultObjectFormFactory::Create(
"BWA_bOverrideTakingRadDamage_DO",
RE::ENUM_FORM_ID::kGLOB);

logger::debug("Injected DefaultObjects"sv);
return 1;
}

// members
inline static RE::BGSDefaultObject* UnarmedPlayerWeapon_DO{ nullptr };

public:
static void InstallHooks()
{
REL::Relocation<std::uintptr_t> targetDefault{ REL::ID(1158572) };
stl::asm_replace(targetDefault.address(), 0x31, reinterpret_cast<std::uintptr_t>(HookInitializer_DefaultObject));
}

// members
inline static RE::BGSDefaultObject* BWA_bEnabled_DO{ nullptr };
inline static RE::BGSDefaultObject* BWA_bOverrideInAir_DO{ nullptr };
inline static RE::BGSDefaultObject* BWA_bOverrideInCombat_DO{ nullptr };
inline static RE::BGSDefaultObject* BWA_bOverrideTrespassing_DO{ nullptr };
inline static RE::BGSDefaultObject* BWA_bOverrideTakingHealthDamage_DO{ nullptr };
inline static RE::BGSDefaultObject* BWA_bOverrideTakingRadDamage_DO{ nullptr };
};
#pragma once

class Forms
{
private:
static std::uint32_t HookInitializer_DefaultObject()
{
// Initializer Override
UnarmedPlayerWeapon_DO =
RE::DefaultObjectFormFactory::Create(
"UnarmedPlayerWeapon_DO",
"The unarmed weapon used to calculate the player's displayed attack stats when no weapon is equipped.",
RE::ENUM_FORM_ID::kWEAP);

// Add new
BWA_bEnabled_DO =
RE::DefaultObjectFormFactory::Create(
"BWA_bEnabled_DO",
RE::ENUM_FORM_ID::kGLOB);

BWA_bOverrideInAir_DO =
RE::DefaultObjectFormFactory::Create(
"BWA_bOverrideInAir_DO",
RE::ENUM_FORM_ID::kGLOB);

BWA_bOverrideInCombat_DO =
RE::DefaultObjectFormFactory::Create(
"BWA_bOverrideInCombat_DO",
RE::ENUM_FORM_ID::kGLOB);

BWA_bOverrideTrespassing_DO =
RE::DefaultObjectFormFactory::Create(
"BWA_bOverrideTrespassing_DO",
RE::ENUM_FORM_ID::kGLOB);

BWA_bOverrideTakingHealthDamage_DO =
RE::DefaultObjectFormFactory::Create(
"BWA_bOverrideTakingHealthDamage_DO",
RE::ENUM_FORM_ID::kGLOB);

BWA_bOverrideTakingRadDamage_DO =
RE::DefaultObjectFormFactory::Create(
"BWA_bOverrideTakingRadDamage_DO",
RE::ENUM_FORM_ID::kGLOB);

logger::debug("Injected DefaultObjects"sv);
return 1;
}

// members
inline static RE::BGSDefaultObject* UnarmedPlayerWeapon_DO{ nullptr };

public:
static void InstallHooks()
{
REL::Relocation<std::uintptr_t> targetDefault{ REL::ID(1158572) };
stl::asm_replace(targetDefault.address(), 0x31, reinterpret_cast<std::uintptr_t>(HookInitializer_DefaultObject));
}

// members
inline static RE::BGSDefaultObject* BWA_bEnabled_DO{ nullptr };
inline static RE::BGSDefaultObject* BWA_bOverrideInAir_DO{ nullptr };
inline static RE::BGSDefaultObject* BWA_bOverrideInCombat_DO{ nullptr };
inline static RE::BGSDefaultObject* BWA_bOverrideTrespassing_DO{ nullptr };
inline static RE::BGSDefaultObject* BWA_bOverrideTakingHealthDamage_DO{ nullptr };
inline static RE::BGSDefaultObject* BWA_bOverrideTakingRadDamage_DO{ nullptr };
};
74 changes: 37 additions & 37 deletions Plugin/src/PCH.cpp
Original file line number Diff line number Diff line change
@@ -1,37 +1,37 @@
#include "PCH.h"

namespace stl
{
namespace detail
{
struct asm_patch :
Xbyak::CodeGenerator
{
asm_patch(std::uintptr_t a_dst)
{
Xbyak::Label dst;

jmp(ptr[rip + dst]);

L(dst);
dq(a_dst);
}
};
}

void asm_jump(std::uintptr_t a_from, [[maybe_unused]] std::size_t a_size, std::uintptr_t a_to)
{
detail::asm_patch p{ a_to };
p.ready();
assert(p.getSize() <= a_size);
REL::safe_write(
a_from,
std::span{ p.getCode<const std::byte*>(), p.getSize() });
}

void asm_replace(std::uintptr_t a_from, std::size_t a_size, std::uintptr_t a_to)
{
REL::safe_fill(a_from, REL::INT3, a_size);
asm_jump(a_from, a_size, a_to);
}
}
#include "PCH.h"

namespace stl
{
namespace detail
{
struct asm_patch :
Xbyak::CodeGenerator
{
asm_patch(std::uintptr_t a_dst)
{
Xbyak::Label dst;

jmp(ptr[rip + dst]);

L(dst);
dq(a_dst);
}
};
}

void asm_jump(std::uintptr_t a_from, [[maybe_unused]] std::size_t a_size, std::uintptr_t a_to)
{
detail::asm_patch p{ a_to };
p.ready();
assert(p.getSize() <= a_size);
REL::safe_write(
a_from,
std::span{ p.getCode<const std::byte*>(), p.getSize() });
}

void asm_replace(std::uintptr_t a_from, std::size_t a_size, std::uintptr_t a_to)
{
REL::safe_fill(a_from, REL::INT3, a_size);
asm_jump(a_from, a_size, a_to);
}
}
54 changes: 27 additions & 27 deletions Plugin/src/PCH.h
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
#pragma once

#define WIN32_LEAN_AND_MEAN
#define NOMINMAX

#include "F4SE/F4SE.h"
#include "RE/Fallout.h"

#include <AutoTOML.hpp>
#include <spdlog/sinks/basic_file_sink.h>
#include <xbyak/xbyak.h>

#define DLLEXPORT __declspec(dllexport)

using namespace std::literals;

namespace logger = F4SE::log;

namespace stl
{
using namespace F4SE::stl;

void asm_replace(std::uintptr_t a_from, std::size_t a_size, std::uintptr_t a_to);
}

#pragma once

#define WIN32_LEAN_AND_MEAN
#define NOMINMAX

#include "F4SE/F4SE.h"
#include "RE/Fallout.h"

#include <AutoTOML.hpp>
#include <spdlog/sinks/basic_file_sink.h>
#include <xbyak/xbyak.h>

#define DLLEXPORT __declspec(dllexport)

using namespace std::literals;

namespace logger = F4SE::log;

namespace stl
{
using namespace F4SE::stl;

void asm_replace(std::uintptr_t a_from, std::size_t a_size, std::uintptr_t a_to);
}

// clang-format off
#include "Version.h"
#include "Settings.h"
// clang-format on
#include "Settings.h"
// clang-format on
24 changes: 12 additions & 12 deletions Plugin/src/Scripts/Papyrus.h
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#pragma once

#include "Papyrus/BakaWaitAnywhere.h"

namespace Papyrus
{
bool RegisterFunctions(RE::BSScript::IVirtualMachine* a_VM)
{
a_VM->BindNativeMethod("BakaWaitAnywhere", "Wait", BakaWaitAnywhere::Wait, true);
return true;
}
}
#pragma once

#include "Papyrus/BakaWaitAnywhere.h"

namespace Papyrus
{
bool RegisterFunctions(RE::BSScript::IVirtualMachine* a_VM)
{
a_VM->BindNativeMethod("BakaWaitAnywhere", "Wait", BakaWaitAnywhere::Wait, true);
return true;
}
}
Loading

0 comments on commit f540e01

Please sign in to comment.