mirror of
https://github.com/rei-2/Amalgam
synced 2026-10-10 21:03:09 +08:00
4bf5afe9b3
misc fixes and changes remove radar, steam rpc
132 lines
5.3 KiB
Plaintext
132 lines
5.3 KiB
Plaintext
#define TICK_INTERVAL I::GlobalVars->interval_per_tick
|
|
#define TIME_TO_TICKS(dt) (static_cast<int>(0.5f + static_cast<float>(dt) / TICK_INTERVAL))
|
|
#define TICKS_TO_TIME(t) (TICK_INTERVAL * (t))
|
|
#define ROUND_TO_TICKS(t) (TICKS_TO_TIME(TIME_TO_TICKS(t)))
|
|
|
|
#define MAKE_SIGNATURE(name, dll, sig, offset) namespace S { inline CSignature name(dll, sig, offset, #name); }
|
|
#define MAKE_HOOK(name, address, type, callconvo, ...) namespace Hooks \
|
|
{\
|
|
namespace name\
|
|
{\
|
|
void Init(); \
|
|
inline CHook Hook(Init); \
|
|
using FN = type(callconvo *)(__VA_ARGS__); \
|
|
type callconvo Func(__VA_ARGS__); \
|
|
}\
|
|
} \
|
|
void Hooks::name::Init() { Hook.Create(reinterpret_cast<void *>(address), Func); } \
|
|
type callconvo Hooks::name::Func(__VA_ARGS__)
|
|
#define CALL_ORIGINAL Hook.Original<FN>()
|
|
#define MAKE_INTERFACE_VERSION(type, name, dll, version) namespace I { inline type *name = nullptr; } \
|
|
namespace MAKE_INTERFACE_SCOPE \
|
|
{\
|
|
inline InterfaceInit_t name##InterfaceInit_t(reinterpret_cast<void **>(&I::name), dll, version, -1, 0); \
|
|
}
|
|
#define MAKE_INTERFACE_SIGNATURE(type, name, dll, version, offset, deref) namespace I { inline type *name = nullptr; } \
|
|
namespace MAKE_INTERFACE_SCOPE \
|
|
{\
|
|
inline InterfaceInit_t name##InterfaceInit_t(reinterpret_cast<void **>(&I::name), dll, version, offset, deref); \
|
|
}
|
|
#define MAKE_INTERFACE_NULL(type, name) namespace I { inline type *name = nullptr; }
|
|
#define MAKE_INTERFACE_VERSION_SEARCH(type, name, dll, version) namespace I { inline type *name = nullptr; } \
|
|
namespace MAKE_INTERFACE_SCOPE \
|
|
{\
|
|
inline InterfaceInit_t name##InterfaceInit_t(reinterpret_cast<void **>(&I::name), dll, version, -1, 0, true); \
|
|
}
|
|
#define MAKE_INTERFACE_SIGNATURE_SEARCH(type, name, dll, signature, offset, deref) namespace I { inline type *name = nullptr; } \
|
|
namespace MAKE_INTERFACE_SCOPE \
|
|
{\
|
|
inline InterfaceInit_t name##InterfaceInit_t(reinterpret_cast<void **>(&I::name), dll, signature, offset, deref, true); \
|
|
}
|
|
|
|
#define NETVAR(_name, type, table, name) inline type& _name() \
|
|
{ \
|
|
static int nOffset = U::NetVars.GetNetVar(table, name); \
|
|
return *reinterpret_cast<type*>(uintptr_t(this) + nOffset); \
|
|
}
|
|
#define NETVAR_OFF(_name, type, table, name, offset) inline type& _name() \
|
|
{ \
|
|
static int nOffset = U::NetVars.GetNetVar(table, name) + offset; \
|
|
return *reinterpret_cast<type*>(uintptr_t(this) + nOffset); \
|
|
}
|
|
#define NETVAR_ARRAY(_name, type, table, size, name) inline type& _name(int iIndex) \
|
|
{ \
|
|
static int nOffset = U::NetVars.GetNetVar(table, name); \
|
|
return *reinterpret_cast<type*>(uintptr_t(this) + nOffset + iIndex * sizeof(type)); \
|
|
}
|
|
#define NETVAR_ARRAY_OFF(_name, type, table, name, size, offset) inline type& _name(int iIndex) \
|
|
{ \
|
|
static int nOffset = U::NetVars.GetNetVar(table, name) + offset; \
|
|
return *reinterpret_cast<type*>(uintptr_t(this) + nOffset + iIndex * sizeof(type)); \
|
|
}
|
|
#define OFFSET(name, type, offset) inline type& name() \
|
|
{ \
|
|
return *reinterpret_cast<type*>(uintptr_t(this) + offset); \
|
|
}
|
|
#define CONDGET(name, conditions, cond) inline bool name() \
|
|
{ \
|
|
return conditions & cond; \
|
|
}
|
|
#define VIRTUAL(name, type, index, ...) inline type name() \
|
|
{ \
|
|
return U::Memory.CallVirtual<index, type>(##__VA_ARGS__); \
|
|
}
|
|
#define VIRTUAL_ARGS(name, type, index, args, ...) inline type name##args \
|
|
{ \
|
|
return U::Memory.CallVirtual<index, type>(##__VA_ARGS__); \
|
|
}
|
|
#define SIGNATURE(name, type, sig, ...) inline type name() \
|
|
{ \
|
|
return S::sig##_##name.Call<type>(##__VA_ARGS__); \
|
|
}
|
|
#define SIGNATURE_ARGS(name, type, sig, args, ...) inline type name##args \
|
|
{ \
|
|
return S::sig##_##name.Call<type>(##__VA_ARGS__); \
|
|
}
|
|
|
|
#define NAMESPACE_BEGIN(name, ...)\
|
|
namespace name {\
|
|
inline const char* GetNamespace() { return "Vars::"#name"::"; }\
|
|
inline const char* GetSubname() { return ""; }\
|
|
inline const char* GetSection() { return !std::string(#__VA_ARGS__).empty() ? ""#__VA_ARGS__ : #name; }
|
|
|
|
#define SUBNAMESPACE_BEGIN(name, ...)\
|
|
namespace name {\
|
|
inline const char* GetSubname() { return #name"::"; }\
|
|
inline const char* GetSection() { return !std::string(#__VA_ARGS__).empty() ? ""#__VA_ARGS__ : #name; }
|
|
|
|
#define NAMESPACE_END(name)\
|
|
}
|
|
#define SUBNAMESPACE_END(name)\
|
|
}
|
|
|
|
#define CVar(name, title, value, ...)\
|
|
inline ConfigVar<decltype(value)> name = { value, std::format("{}{}{}", GetNamespace(), GetSubname(), #name), GetSection(), { title }, __VA_ARGS__ }
|
|
#define CVarValues(name, title, value, flags, none, ...)\
|
|
inline ConfigVar<decltype(value)> name = { value, std::format("{}{}{}", GetNamespace(), GetSubname(), #name), GetSection(), { title }, flags, { __VA_ARGS__ }, none }
|
|
#define Enum(name, ...)\
|
|
namespace name##Enum { enum name##Enum { __VA_ARGS__ }; }
|
|
#define CVarEnum(name, title, value, flags, none, values, ...)\
|
|
CVarValues(name, title, value, flags, none, values);\
|
|
Enum(name, __VA_ARGS__);
|
|
|
|
#define NONE 0
|
|
#define VISUAL (1 << 31)
|
|
#define NOSAVE (1 << 30)
|
|
#define NOBIND (1 << 29)
|
|
#define DEBUGVAR (1 << 28)
|
|
|
|
#define SLIDER_CLAMP (1 << 2)
|
|
#define SLIDER_MIN (1 << 3)
|
|
#define SLIDER_MAX (1 << 4)
|
|
#define SLIDER_PRECISION (1 << 5)
|
|
#define SLIDER_NOAUTOUPDATE (1 << 6)
|
|
#define DROPDOWN_MULTI (1 << 2)
|
|
#define DROPDOWN_MODIFIABLE (1 << 3)
|
|
#define DROPDOWN_CUSTOM (1 << 2)
|
|
#define DROPDOWN_AUTOUPDATE (1 << 3)
|
|
|
|
#define DEFAULT_BIND -1
|
|
|
|
#define ADD_FEATURE_CUSTOM(type, name, scope) namespace scope { inline type name; }
|
|
#define ADD_FEATURE(type, name) ADD_FEATURE_CUSTOM(type, name, F) |