Skip to content

Commit

Permalink
Merge branch 'dev' of https://github.com/powerof3/CommonLibSSE into vr
Browse files Browse the repository at this point in the history
  • Loading branch information
alandtse committed Nov 19, 2023
2 parents 92c4029 + f18a645 commit d9e5470
Show file tree
Hide file tree
Showing 26 changed files with 313 additions and 80 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/maintenance.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
python-version: '3.9'

- name: Run clang-format
run: find -type f \( -name *.h -o -name *.cpp \) | xargs clang-format-12 -style=file -i
run: find -type f \( -name *.h -o -name *.cpp \) | xargs clang-format-14 -style=file -i

- name: Glob files
run: python ${{ github.workspace }}/scripts/cmake_generate.py
Expand Down
36 changes: 18 additions & 18 deletions include/RE/A/AIProcess.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ namespace RE
{
public:
// members
bool dirty; // 0
std::uint8_t pad1; // 1
std::uint16_t pad2; // 2
float value; // 4
float value; // 0
bool invalid; // 4
std::uint8_t pad5; // 5
std::uint16_t pad6; // 6
};
static_assert(sizeof(CachedValueData) == 0x8);

Expand Down Expand Up @@ -80,20 +80,20 @@ namespace RE
kOwnerIsInCombatantFaction = 1 << 3
};

float cachedRadius; // 00
float cachedWidth; // 04
float cachedLength; // 08
float cachedForwardLength; // 0C
float cachedDPS; // 10
float cachedEyeLevel; // 14
float cachedWalkSpeed; // 18
float cachedRunSpeed; // 1C
float cachedJogSpeed; // 20
float cachedFastWalkSpeed; // 24
stl::enumeration<BooleanValue, std::uint32_t> booleanValues; // 28
stl::enumeration<Flags, std::uint32_t> flags; // 2C
BSTArray<CachedValueData> actorValueCache; // 30
BSTArray<CachedValueData> permanentActorValueCache; // 48
float cachedRadius; // 00
float cachedWidth; // 04
float cachedLength; // 08
float cachedForwardLength; // 0C
float cachedDPS; // 10
float cachedEyeLevel; // 14
float cachedWalkSpeed; // 18
float cachedRunSpeed; // 1C
float cachedJogSpeed; // 20
float cachedFastWalkSpeed; // 24
stl::enumeration<BooleanValue, std::uint32_t> booleanValues; // 28
stl::enumeration<Flags, std::uint32_t> flags; // 2C
BSTArray<CachedValueData> actorValueCache; // 30
BSTArray<CachedValueData> maxActorValueCache; // 48
};
static_assert(sizeof(CachedValues) == 0x60);

Expand Down
2 changes: 2 additions & 0 deletions include/RE/A/Actor.h
Original file line number Diff line number Diff line change
Expand Up @@ -708,6 +708,7 @@ namespace RE
[[nodiscard]] TESObjectARMO* GetSkin() const;
[[nodiscard]] TESObjectARMO* GetSkin(BGSBipedObjectForm::BipedObjectSlot a_slot, bool a_noInit = false);
[[nodiscard]] SOUL_LEVEL GetSoulSize() const;
float GetTotalCarryWeight();
TESFaction* GetVendorFaction();
const TESFaction* GetVendorFaction() const;
float GetVoiceRecoveryTime();
Expand Down Expand Up @@ -760,6 +761,7 @@ namespace RE
void RemoveAnimationGraphEventSink(BSTEventSink<BSAnimationGraphEvent>* a_sink) const;
void RemoveCastScroll(SpellItem* a_spell, MagicSystem::CastingSource a_source);
void RemoveExtraArrows3D();
void RemoveFromFaction(TESFaction* a_faction);
void RemoveOutfitItems(BGSOutfit* a_outfit);
bool RemoveSpell(SpellItem* a_spell);
std::int32_t RequestDetectionLevel(Actor* a_target, DETECTION_PRIORITY a_priority = DETECTION_PRIORITY::kNormal);
Expand Down
8 changes: 4 additions & 4 deletions include/RE/B/BSFixedString.h
Original file line number Diff line number Diff line change
Expand Up @@ -205,15 +205,15 @@ namespace RE
[[nodiscard]] inline BSStringPool::Entry* get_proxy() noexcept
{
return _data ?
reinterpret_cast<BSStringPool::Entry*>(const_cast<pointer>(_data)) - 1 :
nullptr;
reinterpret_cast<BSStringPool::Entry*>(const_cast<pointer>(_data)) - 1 :
nullptr;
}

[[nodiscard]] inline const BSStringPool::Entry* get_proxy() const noexcept
{
return _data ?
reinterpret_cast<const BSStringPool::Entry*>(_data) - 1 :
nullptr;
reinterpret_cast<const BSStringPool::Entry*>(_data) - 1 :
nullptr;
}

inline void try_acquire()
Expand Down
2 changes: 1 addition & 1 deletion include/RE/B/BSTTuple.h
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ namespace RE
return a_lhs.first < a_rhs.first ? true :
a_rhs.first < a_lhs.first ? false :
a_lhs.second < a_rhs.second ? true :
false;
false;
}

template <class T1, class T2>
Expand Down
4 changes: 2 additions & 2 deletions include/RE/C/ColorUtil.h
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ namespace RE
inline float softLight(float a_src, float a_dest)
{
return (a_src < 0.5f) ? a_dest - (1.0f - 2.0f * a_src) * a_dest * (1.0f - a_dest) : (a_dest < 0.25f) ? a_dest + (2.0f * a_src - 1.0f) * a_dest * ((16.0f * a_dest - 12.0f) * a_dest + 3.0f) :
a_dest + (2.0f * a_src - 1.0f) * (sqrt(a_dest) - a_dest);
a_dest + (2.0f * a_src - 1.0f) * (sqrt(a_dest) - a_dest);
}

inline NiColor softLight(const NiColor& a_src, const NiColor& a_dest)
Expand Down Expand Up @@ -177,7 +177,7 @@ namespace RE
inline float pinLight(float a_src, float a_dest)
{
return (2.0f * a_src - 1.0f > a_dest) ? 2.0f * a_src - 1.0f : (a_src < 0.5f * a_dest) ? 2.0f * a_src :
a_dest;
a_dest;
}

inline NiColor pinLight(const NiColor& a_src, const NiColor& a_dest)
Expand Down
4 changes: 2 additions & 2 deletions include/RE/D/DualValueModifierEffect.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ namespace RE
virtual float GetSecondaryAVWeight() const; // 22

// members
ActorValue secondaryActorValue; // 98
float secondaryAVWeight; // 9C
float secondaryAVWeight; // 98
std::uint32_t pad9C; // 9C
};
static_assert(sizeof(DualValueModifierEffect) == 0xA0);
}
4 changes: 2 additions & 2 deletions include/RE/G/GridCellArray.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ namespace RE
[[nodiscard]] TESObjectCELL* GetCell(std::uint32_t a_x, std::uint32_t a_y) const noexcept
{
return (a_x < length && a_y < length) ?
cells[(a_x * length) + a_y] :
nullptr;
cells[(a_x * length) + a_y] :
nullptr;
};

// members
Expand Down
1 change: 1 addition & 0 deletions include/RE/I/InventoryChanges.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ namespace RE
void AddEntryData(InventoryEntryData* a_entry);
void GenerateLeveledListChanges();
TESObjectARMO* GetArmorInSlot(std::int32_t a_slot);
float GetInventoryWeight();
std::int16_t GetItemCount(RE::TESBoundObject* a_obj);
std::uint16_t GetNextUniqueID();
std::uint32_t GetWornMask();
Expand Down
16 changes: 8 additions & 8 deletions include/RE/M/MemoryManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,8 @@ namespace RE
{
auto heap = MemoryManager::GetSingleton();
return heap ?
heap->Allocate(a_size, 0, false) :
nullptr;
heap->Allocate(a_size, 0, false) :
nullptr;
}

template <class T>
Expand All @@ -119,8 +119,8 @@ namespace RE
{
auto heap = MemoryManager::GetSingleton();
return heap ?
heap->Allocate(a_size, static_cast<std::int32_t>(a_alignment), true) :
nullptr;
heap->Allocate(a_size, static_cast<std::int32_t>(a_alignment), true) :
nullptr;
}

template <class T>
Expand Down Expand Up @@ -160,8 +160,8 @@ namespace RE
{
auto heap = MemoryManager::GetSingleton();
return heap ?
heap->Reallocate(a_ptr, a_newSize, 0, false) :
nullptr;
heap->Reallocate(a_ptr, a_newSize, 0, false) :
nullptr;
}

template <class T>
Expand All @@ -174,8 +174,8 @@ namespace RE
{
auto heap = MemoryManager::GetSingleton();
return heap ?
heap->Reallocate(a_ptr, a_newSize, static_cast<std::int32_t>(a_alignment), true) :
nullptr;
heap->Reallocate(a_ptr, a_newSize, static_cast<std::int32_t>(a_alignment), true) :
nullptr;
}

template <class T>
Expand Down
92 changes: 73 additions & 19 deletions include/RE/R/Renderer.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,25 +39,23 @@ namespace RE
{
public:
// members
std::uint32_t uiAdapter; // 0000
std::uint32_t unk04; // 0004 - refreshRate?
std::uint32_t unk08; // 0008
std::uint32_t unk0C; // 000C
std::uint32_t unk10; // 0010
std::uint32_t unk14; // 0014
std::uint32_t unk18; // 0018
std::uint32_t unk1C; // 001C
bool fullScreen; // 0020
bool borderlessDisplay; // 0021
bool readOnlyDepth; // 0022
std::uint8_t unk23; // 0023
std::uint8_t unk24; // 0024
std::uint32_t unk28; // 0028
std::uint32_t unk30; // 0030
std::uint32_t presentInterval; // 0034
ID3D11Device* forwarder; // 0038
ID3D11DeviceContext* context; // 0040
RendererWindow renderWindows[32]; // 0048
std::uint32_t uiAdapter; // 0000
DirectX::DXGI_RATIONAL desiredRefreshRate; // 0004 - refreshRate?
DirectX::DXGI_RATIONAL actualRefreshRate; // 000C
DirectX::DXGI_MODE_SCALING scaleMode; // 0014
DirectX::DXGI_MODE_SCANLINE_ORDER scanlineOrdering; // 0018
std::uint32_t isNotWindowed; // 001C
bool fullScreen; // 0020
bool borderlessDisplay; // 0021
bool readOnlyDepth; // 0022
bool instantiated; // 0023
bool requestedWindowSizeChange; // 0024
std::uint32_t newWidth; // 0028
std::uint32_t newHeight; // 002C
std::uint32_t presentInterval; // 0030
ID3D11Device* forwarder; // 0038
ID3D11DeviceContext* context; // 0040
RendererWindow renderWindows[32]; // 0048
#ifndef SKYRIMVR
RenderTargetData renderTargets[RENDER_TARGET::kTOTAL]; // 0A48
DepthStencilData depthStencils[RENDER_TARGET_DEPTHSTENCIL::kTOTAL]; // 1FA8
Expand All @@ -84,14 +82,70 @@ namespace RE
static_assert(offsetof(RendererData, lock) == 0x2EE8);
#endif

struct RendererInitOSData
{
WinAPI::HWND hwnd; // 00
WinAPI::HINSTANCE instance; // 08
WinAPI::WNDPROC windowProcFunction; // 10
WinAPI::HICON icon; // 18
const char* className; // 20
uint32_t adapter; // 28
uint32_t unk2C; // 2C
};
static_assert(sizeof(RendererInitOSData) == 0x30);

struct ScreenSize
{
uint32_t width; // 00
uint32_t height; // 04
};
static_assert(sizeof(ScreenSize) == 0x8);

struct ApplicationWindowProperties
{
ScreenSize screenSize; // 00
int windowX; // 08
int windowY; // 0C
int refreshRate; // 10
int presentInterval; // 14
bool appFullScreen; // 18
bool borderlessWindow; // 19
bool vsync; // 1A
};
static_assert(sizeof(ApplicationWindowProperties) == 0x1C);

class Renderer
{
public:
[[nodiscard]] static Renderer* GetSingleton() noexcept;

void CreateSwapChain(WinAPI::HWND* window, bool setCurrent);
void KillWindow(std::uint32_t windowID);
void Lock();
void Unlock();
void ResizeWindow(std::uint32_t windowID, std::uint32_t width, std::uint32_t height, bool fullscreen, bool borderless);
void RequestWindowResize(std::uint32_t width, std::uint32_t height);
void SetWindowPosition(std::uint32_t windowID, std::int32_t x, std::int32_t y);
void SetWindowActiveState(bool show);
void WindowSizeChanged(std::uint32_t windowID);
void ResetWindow(std::uint32_t windowID);
void UpdateViewPort(std::uint32_t a_unk, std::uint32_t b_unk, bool c_unk);

[[nodiscard]] NiTexture::RendererData* CreateRenderTexture(std::uint32_t a_width, std::uint32_t a_height);
void SaveRenderTargetToFile(RENDER_TARGET a_renderTarget, const char* a_filePath, TextureFileFormat a_textureFileFormat);

[[nodiscard]] static RendererData* GetRendererData();
[[nodiscard]] static ScreenSize GetScreenSize();
[[nodiscard]] static ID3D11Device* GetDevice();
[[nodiscard]] static RendererWindow* GetCurrentRenderWindow();

private:
void Begin(std::uint32_t windowID);
void Init(RendererInitOSData* a_data, ApplicationWindowProperties* windowProps, WinAPI::HWND window);
void End();
void Shutdown();

public:
// members
std::uint64_t unk00; // 00
std::uint64_t unk08; // 08
Expand Down
2 changes: 2 additions & 0 deletions include/RE/T/TESForm.h
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,8 @@ namespace RE
[[nodiscard]] bool IsSoulGem() const noexcept { return Is(FormType::SoulGem); }
[[nodiscard]] bool IsWeapon() const noexcept { return Is(FormType::Weapon); }

void SetPlayerKnows(bool a_known);

// members
TESFileContainer sourceFiles; // 08
std::uint32_t formFlags; // 10
Expand Down
10 changes: 5 additions & 5 deletions include/REL/Relocation.h
Original file line number Diff line number Diff line change
Expand Up @@ -589,10 +589,10 @@ namespace REL
{
const mapping_t elem{ 0, a_offset };
const auto it = std::lower_bound(
_offset2id.begin(),
_offset2id.end(),
elem,
[](auto&& a_lhs, auto&& a_rhs) {
_offset2id.begin(),
_offset2id.end(),
elem,
[](auto&& a_lhs, auto&& a_rhs) {
return a_lhs.offset < a_rhs.offset;
});
if (it == _offset2id.end()) {
Expand Down Expand Up @@ -1047,7 +1047,7 @@ namespace REL
return write_vfunc(a_idx, stl::unrestricted_cast<std::uintptr_t>(a_newFunc));
}

private :
private:
// clang-format off
[[nodiscard]] static std::uintptr_t base() { return Module::get().base(); }
// clang-format on
Expand Down
2 changes: 1 addition & 1 deletion include/SKSE/Impl/PCH.h
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ namespace SKSE
return (_impl & (static_cast<underlying_type>(a_args) | ...)) == static_cast<underlying_type>(0);
}

private :
private:
underlying_type _impl{ 0 };
};

Expand Down
29 changes: 29 additions & 0 deletions include/SKSE/Impl/WinAPI.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@ namespace SKSE::WinAPI
struct HINSTANCE__;
using HINSTANCE = HINSTANCE__*;

struct HICON__;
using HICON = HICON__*;

using WNDPROC = std::int32_t(__stdcall*)(HWND, std::uint32_t, std::uint64_t, std::int64_t);

struct _WIN32_FIND_DATAA
{
public:
Expand Down Expand Up @@ -524,4 +529,28 @@ namespace RE::DirectX
float m[4][4];
};
static_assert(sizeof(XMFLOAT4X4) == 0x40);

struct DXGI_RATIONAL
{
public:
// members
std::uint32_t numerator; // 00
std::uint32_t denominator; // 04
};
static_assert(sizeof(DXGI_RATIONAL) == 0x08);

enum DXGI_MODE_SCALING : std::uint32_t
{
DXGI_MODE_SCALING_UNSPECIFIED = 0,
DXGI_MODE_SCALING_CENTERED = 1,
DXGI_MODE_SCALING_STRETCHED = 2
};

enum DXGI_MODE_SCANLINE_ORDER : std::uint32_t
{
DXGI_MODE_SCANLINE_ORDER_UNSPECIFIED = 0,
DXGI_MODE_SCANLINE_ORDER_PROGRESSIVE = 1,
DXGI_MODE_SCANLINE_ORDER_UPPER_FIELD_FIRST = 2,
DXGI_MODE_SCANLINE_ORDER_LOWER_FIELD_FIRST = 3
};
}
Loading

0 comments on commit d9e5470

Please sign in to comment.