2020-02-22 20:47:17 -05:00
|
|
|
#pragma once
|
|
|
|
#include "common.hpp"
|
|
|
|
|
|
|
|
namespace big
|
|
|
|
{
|
|
|
|
class script_local
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
explicit script_local(rage::scrThread* thread, std::size_t index);
|
|
|
|
explicit script_local(PVOID stack, std::size_t index);
|
2023-07-11 23:53:15 +02:00
|
|
|
explicit script_local(std::size_t index);
|
|
|
|
|
|
|
|
script_local set(rage::scrThread* thread);
|
|
|
|
script_local set(void* stack);
|
2020-02-22 20:47:17 -05:00
|
|
|
|
|
|
|
script_local at(std::ptrdiff_t index);
|
|
|
|
script_local at(std::ptrdiff_t index, std::size_t size);
|
|
|
|
|
2023-03-01 21:27:15 +00:00
|
|
|
template<typename T>
|
2020-02-22 20:47:17 -05:00
|
|
|
std::enable_if_t<std::is_pointer_v<T>, T> as()
|
|
|
|
{
|
|
|
|
return static_cast<T>(get());
|
|
|
|
}
|
|
|
|
|
2023-03-01 21:27:15 +00:00
|
|
|
template<typename T>
|
2020-02-22 20:47:17 -05:00
|
|
|
std::enable_if_t<std::is_lvalue_reference_v<T>, T> as()
|
|
|
|
{
|
|
|
|
return *static_cast<std::add_pointer_t<std::remove_reference_t<T>>>(get());
|
|
|
|
}
|
2023-03-01 21:27:15 +00:00
|
|
|
|
2020-02-22 20:47:17 -05:00
|
|
|
private:
|
2023-03-01 21:27:15 +00:00
|
|
|
void* get();
|
2020-02-22 20:47:17 -05:00
|
|
|
std::size_t m_index;
|
|
|
|
PVOID m_stack;
|
|
|
|
};
|
|
|
|
}
|