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 #24

Merged
merged 3 commits into from
Jul 1, 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
2 changes: 1 addition & 1 deletion CommonLibF4/include/RE/Bethesda/IMenu.h
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ namespace RE
bool menuCanBeVisible{ true }; // 61
bool hasQuadsForCumstomRenderer{ false }; // 62
bool hasDoneFirstAdvanceMovie{ false }; // 63
REX::EnumSet<UI_DEPTH_PRIORITY, std::uint8_t> depthPriority{ UI_DEPTH_PRIORITY::kStandard }; // 64
UI_DEPTH_PRIORITY depthPriority{ UI_DEPTH_PRIORITY::kStandard }; // 64
REX::EnumSet<UserEvents::INPUT_CONTEXT_ID, std::int32_t> inputContext{ UserEvents::INPUT_CONTEXT_ID::kNone }; // 68
};
static_assert(sizeof(IMenu) == 0x70);
Expand Down
19 changes: 17 additions & 2 deletions CommonLibF4/include/RE/Bethesda/PlayerControls.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ namespace RE
struct AutoMoveHandler;
struct GrabRotationHandler;
struct JumpHandler;
struct LookHandler;
struct MeleeThrowHandler;
struct MovementHandler;
struct ReadyWeaponHandler;
Expand Down Expand Up @@ -138,6 +137,22 @@ namespace RE
};
static_assert(sizeof(HeldStateHandler) == 0x28);

class LookHandler :
public PlayerInputHandler
{
public:
static constexpr auto RTTI{ RTTI::LookHandler };
static constexpr auto VTABLE{ VTABLE::LookHandler };

explicit constexpr LookHandler(PlayerControlsData& a_data) noexcept :
PlayerInputHandler(a_data)
{}

// members
float thumbstickMaxedSec{ 0.0f }; // 20
};
static_assert(sizeof(LookHandler) == 0x28);

class __declspec(novtable) PlayerControls :
BSInputEventReceiver, // 000
BSTEventSink<MenuOpenCloseEvent>, // 010
Expand All @@ -154,7 +169,7 @@ namespace RE

static PlayerControls* GetSingleton()
{
static REL::Relocation<PlayerControls**> singleton{ REL::ID(544871) };
static REL::Relocation<PlayerControls**> singleton{ REL::ID(2692013) };
return *singleton;
}

Expand Down
21 changes: 1 addition & 20 deletions CommonLibF4/include/REL/IDDB.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,26 +24,7 @@ namespace REL
return singleton;
}

[[nodiscard]] std::size_t id2offset(std::uint64_t a_id) const
{
if (_id2offset.empty()) {
stl::report_and_fail("data is empty"sv);
}

const mapping_t elem{ a_id, 0 };
const auto it = std::lower_bound(
_id2offset.begin(),
_id2offset.end(),
elem,
[](auto&& a_lhs, auto&& a_rhs) {
return a_lhs.id < a_rhs.id;
});
if (it == _id2offset.end()) {
stl::report_and_fail("id not found"sv);
}

return static_cast<std::size_t>(it->offset);
}
[[nodiscard]] std::size_t id2offset(std::uint64_t a_id) const;

protected:
friend class Offset2ID;
Expand Down
24 changes: 24 additions & 0 deletions CommonLibF4/src/REL/IDDB.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "REL/IDDB.h"
#include "REL/Module.h"
#include "REL/Version.h"

#include "REX/W32/BCRYPT.h"
Expand Down Expand Up @@ -105,4 +106,27 @@ namespace REL
*reinterpret_cast<const std::uint64_t*>(_mmap.data())
};
}

std::size_t IDDB::id2offset(std::uint64_t a_id) const
{
if (_id2offset.empty()) {
stl::report_and_fail("data is empty"sv);
}

const mapping_t elem{ a_id, 0 };
const auto it = std::lower_bound(
_id2offset.begin(),
_id2offset.end(),
elem,
[](auto&& a_lhs, auto&& a_rhs) {
return a_lhs.id < a_rhs.id;
});
if (it == _id2offset.end()) {
const auto version = Module::get().version();
const auto str = std::format("id {} not found!\ngame version: {}"sv, a_id, version.string());
stl::report_and_fail(str);
}

return static_cast<std::size_t>(it->offset);
}
}
Loading