Skip to content

Commit

Permalink
feat: misc (#270)
Browse files Browse the repository at this point in the history
  • Loading branch information
qudix authored Sep 19, 2024
1 parent 6d23c54 commit e36d209
Show file tree
Hide file tree
Showing 66 changed files with 393 additions and 315 deletions.
2 changes: 1 addition & 1 deletion include/RE/A/ActorValues.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ namespace RE
[[nodiscard]] static ActorValue* GetSingleton()
{
using func_t = decltype(&ActorValue::GetSingleton);
REL::Relocation<func_t> func{ ID::ActorValue::GetSingleton };
static REL::Relocation<func_t> func{ ID::ActorValue::GetSingleton };
return func();
}

Expand Down
4 changes: 2 additions & 2 deletions include/RE/B/BGSDefaultObjectManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ namespace RE

[[nodiscard]] inline std::span<DEFAULT_OBJECT_DATA, DEFAULT_OBJECT::kTotal> GetDefaultObjectData()
{
REL::Relocation<DEFAULT_OBJECT_DATA(*)[DEFAULT_OBJECT::kTotal]> data{ REL::ID(761776) };
static REL::Relocation<DEFAULT_OBJECT_DATA(*)[DEFAULT_OBJECT::kTotal]> data{ REL::ID(761776) };
return { *data };
}

Expand All @@ -419,7 +419,7 @@ namespace RE
[[nodiscard]] static BGSDefaultObjectManager* GetSingleton()
{
using func_t = decltype(&BGSDefaultObjectManager::GetSingleton);
REL::Relocation<func_t> func{ REL::ID(82283) };
static REL::Relocation<func_t> func{ REL::ID(82283) };
return func();
}

Expand Down
2 changes: 1 addition & 1 deletion include/RE/B/BGSEntryPoint.h
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ namespace RE
inline void HandleEntryPoint(ENTRY_POINT a_entryPoint, Actor* a_perkOwner, Args... a_args)
{
using func_t = decltype(&BGSEntryPoint::HandleEntryPoint<Args...>);
REL::Relocation<func_t> func{ REL::ID(110912) };
static REL::Relocation<func_t> func{ REL::ID(110912) };
return func(a_entryPoint, a_perkOwner, a_args...);
}
}
Expand Down
4 changes: 2 additions & 2 deletions include/RE/B/BGSInventoryInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,14 @@ namespace RE

[[nodiscard]] static BGSInventoryInterface* GetSingleton()
{
REL::Relocation<BGSInventoryInterface**> singleton{ ID::BGSInventoryInterface::singleton };
static REL::Relocation<BGSInventoryInterface**> singleton{ ID::BGSInventoryInterface::singleton };
return *singleton;
}

[[nodiscard]] TESBoundObject* GetInventoryObject(const std::uint32_t& a_handleID) const
{
using func_t = decltype(&BGSInventoryInterface::GetInventoryObject);
REL::Relocation<func_t> func{ ID::BGSInventoryInterface::GetInventoryObject };
static REL::Relocation<func_t> func{ ID::BGSInventoryInterface::GetInventoryObject };
return func(this, a_handleID);
}

Expand Down
2 changes: 1 addition & 1 deletion include/RE/B/BGSObjectInstance.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ namespace RE
BGSObjectInstance* ctor(TESForm* a_object, TBO_InstanceData* a_instanceData)
{
using func_t = decltype(&BGSObjectInstance::ctor);
REL::Relocation<func_t> func{ ID::BGSObjectInstance::ctor };
static REL::Relocation<func_t> func{ ID::BGSObjectInstance::ctor };
return func(this, a_object, a_instanceData);
}
};
Expand Down
4 changes: 2 additions & 2 deletions include/RE/B/BGSSaveLoadGame.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ namespace RE
void SaveGame(void* a_unk1, void* a_unk2, const char* a_name)
{
using func_t = decltype(&BGSSaveLoadGame::SaveGame);
REL::Relocation<func_t> func{ REL::ID(147515) };
static REL::Relocation<func_t> func{ REL::ID(147515) };
return func(this, a_unk1, a_unk2, a_name);
}

bool LoadGame(const char* a_name, void* a_unk1, void* a_unk2)
{
using func_t = decltype(&BGSSaveLoadGame::LoadGame);
REL::Relocation<func_t> func{ REL::ID(147564) };
static REL::Relocation<func_t> func{ REL::ID(147564) };
return func(this, a_name, a_unk1, a_unk2);
}
};
Expand Down
2 changes: 1 addition & 1 deletion include/RE/B/BGSSaveLoadManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ namespace RE
bool DeleteSaveFile(const char* a_filename, void* a_unk1, bool a_unk2)
{
using func_t = decltype(&BGSSaveLoadManager::DeleteSaveFile);
REL::Relocation<func_t> func{ REL::ID(147844) };
static REL::Relocation<func_t> func{ REL::ID(147844) };
return func(this, a_filename, a_unk1, a_unk2);
}
};
Expand Down
6 changes: 3 additions & 3 deletions include/RE/B/BSInputEnableLayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,14 @@ namespace RE
uint64_t SetUserFlags(uint64_t flags, bool enabled)
{
using func_t = decltype(&BSInputEnableLayer::SetUserFlags);
REL::Relocation<func_t> func(REL::ID(106486));
static REL::Relocation<func_t> func(REL::ID(106486));
return func(this, flags, enabled);
}

uint64_t SetOtherFlags(uint64_t flags, bool enabled)
{
using func_t = decltype(&BSInputEnableLayer::SetOtherFlags);
REL::Relocation<func_t> func(REL::ID(109447));
static REL::Relocation<func_t> func(REL::ID(109447));
return func(this, flags, enabled);
}
};
Expand Down Expand Up @@ -96,7 +96,7 @@ namespace RE
bool result = true;
if (data) {
using func_t = decltype(&InputEnableLayer::Free);
REL::Relocation<func_t> func(REL::ID(36626));
static REL::Relocation<func_t> func(REL::ID(36626));
result = func(this);
data = nullptr;
}
Expand Down
4 changes: 2 additions & 2 deletions include/RE/B/BSInputEnableManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ namespace RE

static BSInputEnableManager* GetSingleton()
{
REL::Relocation<BSInputEnableManager**> singleton{ REL::ID(878792) };
static REL::Relocation<BSInputEnableManager**> singleton{ REL::ID(878792) };
return *singleton;
}

bool CreateLayer(InputEnableLayer* a_layer, const char* a_layerName)
{
using func_t = decltype(&BSInputEnableManager::CreateLayer);
REL::Relocation<func_t> func(REL::ID(179101));
static REL::Relocation<func_t> func(REL::ID(179101));
return func(this, a_layer, a_layerName);
}
};
Expand Down
151 changes: 99 additions & 52 deletions include/RE/B/BSInputEventUser.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,67 +17,113 @@ namespace RE
class InputEvent
{
public:
enum DeviceType : uint32_t
SF_RTTI(InputEvent);

enum class DeviceType : std::uint32_t
{
DeviceKeyboard = 0,
DeviceMouse,
DeviceGamepad,
DeviceKinect,
kNone = static_cast<std::underlying_type_t<DeviceType>>(-1),

kKeyboard = 0,
kMouse,
kGamepad,
kKinect,
};

enum EventType : uint32_t
enum class EventType : std::uint32_t
{
Button = 0,
MouseMove,
CursorMove,
Char,
Thumbstick,
DeviceConnect,
Kinect,
None,
kButton = 0,
kMouseMove,
kCursorMove,
kChar,
kThumbstick,
kDeviceConnect,
kKinect,
kNone,
};

enum Status : uint32_t
enum class Status : std::uint32_t
{
Unhandled = 0,
Continue,
Stop,
kUnhandled = 0,
kContinue,
kStop,
};

virtual ~InputEvent() = default; //00
virtual bool Unk01() { return false; }
virtual BSFixedString GetUserEventOrDisabled() { return ""; }

uint32_t deviceType; //08
uint32_t deviceId;
uint32_t eventType; //10
uint32_t pad14;
InputEvent* next; //18
uint32_t timeCode; //20
uint32_t status;
virtual ~InputEvent() = default; // 00

// add
virtual bool HasIDCode() const { return false; }
virtual const BSFixedString QUserEvent() const { return ""; }

// members
DeviceType deviceType{ DeviceType::kNone }; // 08
std::uint32_t deviceID{ 0 }; // 0C
EventType eventType{ EventType::kNone }; // 10
std::uint32_t pad14; // 14
InputEvent* next{ nullptr }; // 18
std::uint32_t timeCode{ static_cast<std::uint32_t>(-1) }; // 20
Status status{ Status::kUnhandled }; // 24
};
static_assert(sizeof(InputEvent) == 0x28);

class IDEvent : public InputEvent
class IDEvent :
public InputEvent
{
public:
virtual ~IDEvent() = default;
BSFixedString userEvent; //28
uint32_t idCode; //30
bool disabled; //34
SF_RTTI_VTABLE(IDEvent);

virtual ~IDEvent() = default; // 00

// override (InputEvent)
virtual bool HasIDCode() const override { return true; }

virtual const BSFixedString QUserEvent() const override
{
return disabled ? "DISABLED" : strUserEvent;
}

// members
BSFixedString strUserEvent; // 28
std::int32_t idCode{ -1 }; // 30
bool disabled{ false }; // 34
};
static_assert(sizeof(IDEvent) == 0x38);

class ButtonEvent : public IDEvent
class ICanBeChorded
{
public:
virtual ~ButtonEvent() = default;
void* iCanBeDebounced; //38
void* iCanBeChorded; //40
float value; //48
float held; //4C
void* unk50;
void* bsDebounceManager;
SF_RTTI(ICanBeChorded);

// members
std::uint64_t pad00;
};

class ICanBeDebounced :
public ICanBeChorded
{
public:
SF_RTTI(ICanBeDebounced);

// members
std::uint64_t pad00;
};

class ButtonEvent :
public IDEvent,
public ICanBeDebounced
{
public:
SF_RTTI_VTABLE(ButtonEvent);

virtual ~ButtonEvent() = default; // 00

// members
float value{ 0.0f }; // 48
float heldDownSecs{ 0.0f }; // 4C
void* unk50; // 50
void* debounceManager; // 58
};
static_assert(sizeof(ButtonEvent) == 0x60);

class BSInputEventUser
{
public:
Expand All @@ -86,18 +132,19 @@ namespace RE
virtual ~BSInputEventUser() = default; // 00

// add
virtual bool ShouldHandleEvent(const InputEvent*) { return false; } // 01
virtual void HandleEvent(const KinectEvent*) { return; } // 02
virtual void HandleEvent(const DeviceConnectEvent*) { return; } // 03
virtual void HandleEvent(const ThumbstickEvent*) { return; } // 04
virtual void HandleEvent(const CursorMoveEvent*) { return; } // 05
virtual void HandleEvent(const MouseMoveEvent*) { return; } // 06
virtual void HandleEvent(const CharacterEvent*) { return; } // 07
virtual void HandleEvent(const ButtonEvent*) { return; } // 08
virtual void InputEventUser_Unk_09(const InputEvent* a_event) // 09
virtual bool ShouldHandleEvent(const InputEvent*) { return false; } // 01
virtual void OnKinectEvent(const KinectEvent*) { return; } // 02
virtual void OnDeviceConnectEvent(const DeviceConnectEvent*) { return; } // 03
virtual void OnThumbstickEvent(const ThumbstickEvent*) { return; } // 04
virtual void OnCursorMoveEvent(const CursorMoveEvent*) { return; } // 05
virtual void OnMouseMoveEvent(const MouseMoveEvent*) { return; } // 06
virtual void OnCharacterEvent(const CharacterEvent*) { return; } // 07
virtual void OnButtonEvent(const ButtonEvent*) { return; } // 08

virtual void InputEventUser_Unk_09(const InputEvent* a_event) // 09
{
using func_t = decltype(&BSInputEventUser::InputEventUser_Unk_09);
REL::Relocation<func_t> func(REL::ID(178899));
static REL::Relocation<func_t> func(REL::ID(178899));
return func(this, a_event);
}

Expand Down
6 changes: 0 additions & 6 deletions include/RE/B/BSScriptUtil.h
Original file line number Diff line number Diff line change
Expand Up @@ -782,12 +782,6 @@ namespace RE::BSScript
return T();
}

if (!a_var.value.v) {
a_var.~Variable();
assert(false);
return T();
}

using value_type = typename T::value_type;

T out;
Expand Down
6 changes: 3 additions & 3 deletions include/RE/B/BSStorage.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,21 +80,21 @@ namespace RE
BSStorageDefs::ErrorCode WriteString(const char* a_string, bool use32bitLength)
{
using func_t = decltype(&BSStorage::WriteString);
REL::Relocation<func_t> func{ ID::BSStorage::WriteString };
static REL::Relocation<func_t> func{ ID::BSStorage::WriteString };
return func(this, a_string, use32bitLength);
}

BSStorageDefs::ErrorCode PrepareStreamBuffer(std::size_t a_size)
{
using func_t = decltype(&BSStorage::PrepareStreamBuffer);
REL::Relocation<func_t> func{ ID::BSStorage::PrepareStreamBuffer };
static REL::Relocation<func_t> func{ ID::BSStorage::PrepareStreamBuffer };
return func(this, a_size);
}

BSStorageDefs::ErrorCode FlushStreamBuffer()
{
using func_t = decltype(&BSStorage::FlushStreamBuffer);
REL::Relocation<func_t> func{ ID::BSStorage::FlushStreamBuffer };
static REL::Relocation<func_t> func{ ID::BSStorage::FlushStreamBuffer };
return func(this);
}

Expand Down
8 changes: 4 additions & 4 deletions include/RE/B/BSStringPool.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ namespace RE
static void release(Entry*& a_entry)
{
using func_t = decltype(&Entry::release);
REL::Relocation<func_t> func{ ID::BSStringPool::Entry::release };
static REL::Relocation<func_t> func{ ID::BSStringPool::Entry::release };
return func(a_entry);
}

Expand Down Expand Up @@ -85,7 +85,7 @@ namespace RE
static BucketTable& GetSingleton()
{
using func_t = decltype(&BucketTable::GetSingleton);
REL::Relocation<func_t> func{ ID::BSStringPool::BucketTable::GetSingleton };
static REL::Relocation<func_t> func{ ID::BSStringPool::BucketTable::GetSingleton };
return func();
}

Expand All @@ -103,15 +103,15 @@ namespace RE
inline void GetEntry<char>(BSStringPool::Entry*& a_result, const char* a_string, bool a_caseSensitive)
{
using func_t = decltype(&GetEntry<char>);
REL::Relocation<func_t> func{ ID::BSStringPool::GetEntry_char_ };
static REL::Relocation<func_t> func{ ID::BSStringPool::GetEntry_char_ };
return func(a_result, a_string, a_caseSensitive);
}

template <>
inline void GetEntry<wchar_t>(BSStringPool::Entry*& a_result, const wchar_t* a_string, bool a_caseSensitive)
{
using func_t = decltype(&GetEntry<wchar_t>);
REL::Relocation<func_t> func{ ID::BSStringPool::GetEntry_wchar_t_ };
static REL::Relocation<func_t> func{ ID::BSStringPool::GetEntry_wchar_t_ };
return func(a_result, a_string, a_caseSensitive);
}
}
Loading

0 comments on commit e36d209

Please sign in to comment.