Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: misc #19

Merged
merged 6 commits into from
Jun 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 2 additions & 11 deletions CommonLibF4/cmake/sourcelist.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ set(SOURCES
include/RE/Bethesda/BSBTreeFile.h
include/RE/Bethesda/BSBound.h
include/RE/Bethesda/BSContainer.h
include/RE/Bethesda/BSCoreTypes.h
include/RE/Bethesda/BSExtraData.h
include/RE/Bethesda/BSFadeNode.h
include/RE/Bethesda/BSFixedString.h
Expand Down Expand Up @@ -442,15 +443,5 @@ set(SOURCES
src/REL/Module.cpp
src/REL/Relocation.cpp
src/REL/Version.cpp
src/REX/W32/ADVAPI32.cpp
src/REX/W32/BCRYPT.cpp
src/REX/W32/D3D11.cpp
src/REX/W32/D3DCOMPILER.cpp
src/REX/W32/DBGHELP.cpp
src/REX/W32/DXGI.cpp
src/REX/W32/KERNEL32.cpp
src/REX/W32/OLE32.cpp
src/REX/W32/SHELL32.cpp
src/REX/W32/USER32.cpp
src/REX/W32/VERSION.cpp
src/REX/W32.cpp
)
2 changes: 2 additions & 0 deletions CommonLibF4/include/F4SE/Impl/PCH.h
Original file line number Diff line number Diff line change
Expand Up @@ -535,5 +535,7 @@ namespace REL
#include "RE/RTTI_IDs.h"
#include "RE/VTABLE_IDs.h"

#include "RE/Bethesda/BSCoreTypes.h"

#include "RE/msvc/memory.h"
#include "RE/msvc/typeinfo.h"
4 changes: 2 additions & 2 deletions CommonLibF4/include/RE/Bethesda/BGSMod.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ namespace RE::BGSMod
{
public:
// members
std::uint32_t formID; // 0
float value; // 4
TESFormID formID; // 0
float value; // 4
};
static_assert(sizeof(FormValuePair) == 0x8);

Expand Down
6 changes: 6 additions & 0 deletions CommonLibF4/include/RE/Bethesda/BSCoreTypes.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#pragma once

namespace RE
{
using TESFormID = std::uint32_t;
}
2 changes: 1 addition & 1 deletion CommonLibF4/include/RE/Bethesda/BSExtraData.h
Original file line number Diff line number Diff line change
Expand Up @@ -654,7 +654,7 @@ namespace RE
{
public:
// members
std::uint32_t formID; // 0
TESFormID formID; // 0
std::uint32_t linkType; // 4
};
static_assert(sizeof(Element) == 0x8);
Expand Down
40 changes: 27 additions & 13 deletions CommonLibF4/include/RE/Bethesda/Events.h
Original file line number Diff line number Diff line change
Expand Up @@ -534,7 +534,7 @@ namespace RE
[[nodiscard]] static BSTEventSource<TerminalHacked::Event>* GetEventSource()
{
using func_t = decltype(&TerminalHacked::GetEventSource);
REL::Relocation<func_t> func{ REL::ID(425579) };
static REL::Relocation<func_t> func{ REL::ID(425579) };
return func();
}
};
Expand All @@ -546,7 +546,7 @@ namespace RE
[[nodiscard]] static BSTEventSource<TESActivateEvent>* GetEventSource()
{
using func_t = decltype(&TESActivateEvent::GetEventSource);
REL::Relocation<func_t> func{ REL::ID(166230) };
static REL::Relocation<func_t> func{ REL::ID(166230) };
return func();
}

Expand All @@ -562,7 +562,7 @@ namespace RE
[[nodiscard]] static BSTEventSource<TESContainerChangedEvent>* GetEventSource()
{
using func_t = decltype(&TESContainerChangedEvent::GetEventSource);
REL::Relocation<func_t> func{ REL::ID(242538) };
static REL::Relocation<func_t> func{ REL::ID(242538) };
return func();
}

Expand All @@ -582,7 +582,7 @@ namespace RE
[[nodiscard]] static BSTEventSource<TESDeathEvent>* GetEventSource()
{
using func_t = decltype(&TESDeathEvent::GetEventSource);
REL::Relocation<func_t> func{ REL::ID(2201833) };
static REL::Relocation<func_t> func{ REL::ID(2201833) };
return func();
}

Expand All @@ -599,7 +599,7 @@ namespace RE
[[nodiscard]] static BSTEventSource<TESEquipEvent>* GetEventSource()
{
using func_t = decltype(&TESEquipEvent::GetEventSource);
REL::Relocation<func_t> func{ REL::ID(1251703) };
static REL::Relocation<func_t> func{ REL::ID(2201837) };
return func();
}

Expand All @@ -618,12 +618,12 @@ namespace RE
[[nodiscard]] static BSTEventSource<TESFormDeleteEvent>* GetEventSource()
{
using func_t = decltype(&TESFormDeleteEvent::GetEventSource);
REL::Relocation<func_t> func{ REL::ID(2201842) };
static REL::Relocation<func_t> func{ REL::ID(2201842) };
return func();
}

// members
std::uint32_t formID; // 00
TESFormID formID; // 00
};
static_assert(sizeof(TESFormDeleteEvent) == 0x04);

Expand All @@ -639,7 +639,7 @@ namespace RE
[[nodiscard]] static BSTEventSource<TESFurnitureEvent>* GetEventSource()
{
using func_t = decltype(&TESFurnitureEvent::GetEventSource);
REL::Relocation<func_t> func{ REL::ID(678665) };
static REL::Relocation<func_t> func{ REL::ID(2201844) };
return func();
}

Expand Down Expand Up @@ -727,7 +727,7 @@ namespace RE
[[nodiscard]] static BSTEventSource<TESHitEvent>* GetEventSource()
{
using func_t = decltype(&TESHitEvent::GetEventSource);
REL::Relocation<func_t> func{ REL::ID(1411899) };
static REL::Relocation<func_t> func{ REL::ID(1411899) };
return func();
}

Expand All @@ -748,7 +748,7 @@ namespace RE
[[nodiscard]] static BSTEventSource<TESMagicEffectApplyEvent>* GetEventSource()
{
using func_t = decltype(&TESMagicEffectApplyEvent::GetEventSource);
REL::Relocation<func_t> func{ REL::ID(1327824) };
static REL::Relocation<func_t> func{ REL::ID(1327824) };
return func();
}

Expand All @@ -765,16 +765,30 @@ namespace RE
[[nodiscard]] static BSTEventSource<TESObjectLoadedEvent>* GetEventSource()
{
using func_t = decltype(&TESObjectLoadedEvent::GetEventSource);
REL::Relocation<func_t> func{ REL::ID(609604) };
static REL::Relocation<func_t> func{ REL::ID(2201853) };
return func();
}

// members
std::uint32_t formId; // 00
bool loaded; // 04
TESFormID formID; // 00
bool loaded; // 04
};
static_assert(sizeof(TESObjectLoadedEvent) == 0x8);

struct TESSwitchRaceCompleteEvent
{
[[nodiscard]] static BSTEventSource<TESSwitchRaceCompleteEvent>* GetEventSource()
{
using func_t = decltype(&TESSwitchRaceCompleteEvent::GetEventSource);
static REL::Relocation<func_t> func{ REL::ID(2201874) };
return func();
}

// members
NiPointer<TESObjectREFR> actor; // 00
};
static_assert(sizeof(TESSwitchRaceCompleteEvent) == 0x8);

class TutorialEvent
{
public:
Expand Down
2 changes: 1 addition & 1 deletion CommonLibF4/include/RE/Bethesda/FormComponents.h
Original file line number Diff line number Diff line change
Expand Up @@ -913,7 +913,7 @@ namespace RE
bool AddKeywords(const std::vector<BGSKeyword*>& a_keywords);

[[nodiscard]] bool ContainsKeywordString(std::string_view a_editorID) const;
[[nodiscard]] bool HasKeywordID(std::uint32_t a_formID) const;
[[nodiscard]] bool HasKeywordID(TESFormID a_formID) const;
[[nodiscard]] bool HasKeywordString(std::string_view a_editorID) const;

void ForEachKeyword(std::function<BSContainer::ForEachResult(BGSKeyword*)> a_callback) const
Expand Down
2 changes: 1 addition & 1 deletion CommonLibF4/include/RE/Bethesda/PlayerCharacter.h
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ namespace RE
return func(this);
}

void SelectPerk(std::uint32_t a_formID, std::int8_t a_rank = 0)
void SelectPerk(TESFormID a_formID, std::int8_t a_rank = 0)
{
using func_t = decltype(&PlayerCharacter::SelectPerk);
REL::Relocation<func_t> func{ REL::ID(1397326) };
Expand Down
18 changes: 9 additions & 9 deletions CommonLibF4/include/RE/Bethesda/PowerArmor.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ namespace RE
[[nodiscard]] inline bool ActorInPowerArmor(const Actor& a_actor)
{
using func_t = decltype(&ActorInPowerArmor);
REL::Relocation<func_t> func{ REL::ID(1176757) };
static REL::Relocation<func_t> func{ REL::ID(2219437) };
return func(a_actor);
}

Expand All @@ -34,35 +34,35 @@ namespace RE
[[nodiscard]] inline BGSKeyword* GetArmorKeyword()
{
using func_t = decltype(&GetArmorKeyword);
REL::Relocation<func_t> func{ REL::ID(961172) };
static REL::Relocation<func_t> func{ REL::ID(961172) };
return func();
}

[[nodiscard]] inline BGSKeyword* GetBatteryKeyword()
{
using func_t = decltype(&GetBatteryKeyword);
REL::Relocation<func_t> func{ REL::ID(1493537) };
static REL::Relocation<func_t> func{ REL::ID(1493537) };
return func();
}

[[nodiscard]] inline TESAmmo* GetDefaultBatteryObject()
{
using func_t = decltype(&GetDefaultBatteryObject);
REL::Relocation<func_t> func{ REL::ID(1279247) };
static REL::Relocation<func_t> func{ REL::ID(1279247) };
return func();
}

[[nodiscard]] inline bool IsPowerArmorBattery(const TESBoundObject* a_itemData)
{
using func_t = decltype(&IsPowerArmorBattery);
REL::Relocation<func_t> func{ REL::ID(1012910) };
static REL::Relocation<func_t> func{ REL::ID(1012910) };
return func(a_itemData);
}

inline void SyncFurnitureVisualsToInventory(TESObjectREFR* a_furniture, bool a_force3DUpdate, BGSInventoryItem* a_tempItemToAdd, bool a_hideCore)
{
using func_t = decltype(&SyncFurnitureVisualsToInventory);
REL::Relocation<func_t> func{ REL::ID(1078979) };
static REL::Relocation<func_t> func{ REL::ID(1078979) };
return func(a_furniture, a_force3DUpdate, a_tempItemToAdd, a_hideCore);
}

Expand All @@ -89,21 +89,21 @@ namespace RE

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

void HidePipboyPAGeometry()
{
using func_t = decltype(&PowerArmorGeometry::HidePipboyPAGeometry);
REL::Relocation<func_t> func{ REL::ID(976332) };
static REL::Relocation<func_t> func{ REL::ID(976332) };
return func(this);
}

void ShowPipboyPAGeometry()
{
using func_t = decltype(&PowerArmorGeometry::ShowPipboyPAGeometry);
REL::Relocation<func_t> func{ REL::ID(19066) };
static REL::Relocation<func_t> func{ REL::ID(19066) };
return func(this);
}

Expand Down
11 changes: 10 additions & 1 deletion CommonLibF4/include/RE/Bethesda/TESBoundAnimObjects.h
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,15 @@ namespace RE
};
static_assert(sizeof(CreatureSounds) == 0x20);

enum class SEX : std::uint32_t
{
kNone = static_cast<std::underlying_type_t<SEX>>(-1),
kMale = 0,
kFemale = 1,

kTotal = 2
};

class __declspec(novtable) TESNPC :
public TESActorBase, // 000
public TESRaceForm, // 1B0
Expand Down Expand Up @@ -440,7 +449,7 @@ namespace RE
return root;
}

[[nodiscard]] uint32_t GetSex() noexcept
[[nodiscard]] SEX GetSex() noexcept
{
using func_t = decltype(&TESNPC::GetSex);
REL::Relocation<func_t> func{ REL::ID(2207107) };
Expand Down
10 changes: 5 additions & 5 deletions CommonLibF4/include/RE/Bethesda/TESDataHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,28 +100,28 @@ namespace RE
return reinterpret_cast<BSTArray<T*>&>(formArrays[std::to_underlying(T::FORM_ID)]);
}

std::uint32_t LookupFormID(std::uint32_t a_rawFormID, std::string_view a_modName)
TESFormID LookupFormID(TESFormID a_rawFormID, std::string_view a_modName)
{
auto file = LookupModByName(a_modName);
if (!file || file->compileIndex == 0xFF) {
return 0;
}

std::uint32_t formID = file->compileIndex << 24;
TESFormID formID = file->compileIndex << 24;
formID += file->smallFileCompileIndex << 12;
formID += a_rawFormID;

return formID;
}

TESForm* LookupForm(std::uint32_t a_rawFormID, std::string_view a_modName)
TESForm* LookupForm(TESFormID a_rawFormID, std::string_view a_modName)
{
auto formID = LookupFormID(a_rawFormID, a_modName);
return formID != 0 ? TESForm::GetFormByID(formID) : nullptr;
}

template <class T>
T* LookupForm(std::uint32_t a_rawFormID, std::string_view a_modName)
T* LookupForm(TESFormID a_rawFormID, std::string_view a_modName)
{
auto form = LookupForm(a_rawFormID, a_modName);
if (!form) {
Expand Down Expand Up @@ -202,7 +202,7 @@ namespace RE
return mod ? std::make_optional(mod->smallFileCompileIndex) : std::nullopt;
}

bool IsFormIDInuse(std::uint32_t a_formID)
bool IsFormIDInuse(TESFormID a_formID)
{
using func_t = decltype(&TESDataHandler::IsFormIDInuse);
REL::Relocation<func_t> func{ REL::ID(2192351) };
Expand Down
4 changes: 2 additions & 2 deletions CommonLibF4/include/RE/Bethesda/TESFile.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ namespace RE
std::uint32_t form; // 00
std::uint32_t length; // 04
std::uint32_t flags; // 08
std::uint32_t formID; // 0C
TESFormID formID; // 0C
std::uint32_t versionControl; // 10
std::uint16_t formVersion; // 14
std::uint16_t vcVersion; // 16
Expand Down Expand Up @@ -117,7 +117,7 @@ namespace RE
return GetChunkData(a_data, 0);
}

[[nodiscard]] bool IsFormInMod(std::uint32_t a_formID) const
[[nodiscard]] bool IsFormInMod(TESFormID a_formID) const
{
if (!IsLight() && (a_formID >> 24) == compileIndex) {
return true;
Expand Down
Loading
Loading