mirror of
https://github.com/YimMenu/RDR-Classes.git
synced 2024-12-22 22:47:31 +08:00
a2a74e151a
* feat: initialize classes repo * feat(script): stuff for native invoker * feat: add some more classes * feat(player): complete CNetworkPlayerMgr * feat(network): add some more stuff * feat(network): add rlGamerInfo * feat(player): add CPlayerInfo
61 lines
1.7 KiB
C++
61 lines
1.7 KiB
C++
#pragma once
|
|
#include <cstddef>
|
|
#include <cstdint>
|
|
#include <utility>
|
|
|
|
namespace rage
|
|
{
|
|
class scrNativeCallContext
|
|
{
|
|
public:
|
|
constexpr void reset()
|
|
{
|
|
m_arg_count = 0;
|
|
m_data_count = 0;
|
|
}
|
|
|
|
template <typename T>
|
|
constexpr void push_arg(T&& value)
|
|
{
|
|
static_assert(sizeof(T) <= sizeof(std::uint64_t));
|
|
*reinterpret_cast<std::remove_cv_t<std::remove_reference_t<T>>*>(reinterpret_cast<std::uint64_t*>(m_args) + (m_arg_count++)) = std::forward<T>(value);
|
|
}
|
|
|
|
template <typename T>
|
|
constexpr T& get_arg(std::size_t index)
|
|
{
|
|
static_assert(sizeof(T) <= sizeof(std::uint64_t));
|
|
return *reinterpret_cast<T*>(reinterpret_cast<std::uint64_t*>(m_args) + index);
|
|
}
|
|
|
|
template <typename T>
|
|
constexpr void set_arg(std::size_t index, T&& value)
|
|
{
|
|
static_assert(sizeof(T) <= sizeof(std::uint64_t));
|
|
*reinterpret_cast<std::remove_cv_t<std::remove_reference_t<T>>*>(reinterpret_cast<std::uint64_t*>(m_args) + index) = std::forward<T>(value);
|
|
}
|
|
|
|
template <typename T>
|
|
constexpr T* get_return_value()
|
|
{
|
|
return reinterpret_cast<T*>(m_return_value);
|
|
}
|
|
|
|
template <typename T>
|
|
constexpr void set_return_value(T&& value)
|
|
{
|
|
*reinterpret_cast<std::remove_cv_t<std::remove_reference_t<T>>*>(m_return_value) = std::forward<T>(value);
|
|
}
|
|
protected:
|
|
void* m_return_value;
|
|
std::uint32_t m_arg_count;
|
|
void* m_args;
|
|
std::int32_t m_data_count;
|
|
std::uint32_t m_data[48];
|
|
};
|
|
static_assert(sizeof(scrNativeCallContext) == 0xE0);
|
|
|
|
using scrNativeHash = std::int64_t;
|
|
using scrNativePair = std::pair<scrNativeHash, scrNativeHash>;
|
|
using scrNativeHandler = void(*)(scrNativeCallContext*);
|
|
} |