Memory (constructor)
Declaration
explicit Memory(std::uint8_t* base);You are reading the docs of SDK 1.1.0, an older release. See the latest (1.11.0).
Reference · SDK 1.1.0
openrac/mod.hpp. It is compiled into your mod; the game still sees only the C table#include "openrac/mod.hpp"
#include "openrac/games/rac1.hpp"static void load(openrac::Mod& mod) {
if (mod.game() != "rac1") throw openrac::Error("this mod is for Ratchet & Clank");
const bool trace = mod.setting<bool>("trace");
mod.hook<openrac::rac1::Hero_TurnToHeading>(
[](auto original, int32_t m, float accel, float damping, float limit) {
original(m, accel, damping, limit); // the game's own, or a mod's loaded earlier
});
mod.on_frame([] { /* once a game tick */ });
}
OPENRAC_MOD_CPP("my-mod", "0.1.0", load)explicit Memory(std::uint8_t* base);template <class T> T read(gaddr address) const;template <class T> void write(gaddr address, const T& value) const;template <class T> T& ref(gaddr address) const;void* pointer(gaddr address) const;std::uint8_t* base() const;template <class R, class... A>using fn = R (*)(A...);explicit Original(fn f);R operator()(A... args) const;fn get() const;Mod(const openrac_api* api, openrac_mod* handle);const openrac_api& api() const;openrac_mod* handle() const;std::string_view game() const;static void load(openrac::Mod& mod) {
if (mod.game() != "rac1") throw openrac::Error("this mod is for Ratchet & Clank");void load(openrac::Mod& mod) {
if (mod.game() != "rac1") {
throw openrac::Error("this mod is for Ratchet & Clank");
}
const bool extra = mod.setting<bool>("enabled_extra");std::string_view version() const;std::string_view platform() const;std::string_view openrac_version() const;unsigned api_major() const;unsigned api_minor() const;void log(LogLevel level, const std::string& text) const;void debug(const std::string& text) const;void info(const std::string& text) const;mod.hook<openrac::rac1::Hero_TurnToHeading>(
[trace, &mod](auto original, int32_t m, float accel, float damping, float limit) {
if (trace) mod.info("turning");
original(m, accel, damping, limit);
}); mod.info(extra ? "loaded, with the extra" : "loaded");
}void warn(const std::string& text) const;void error(const std::string& text) const;void fail(const std::string& reason) const;template <class T> T setting(const char* key) const;const bool trace = mod.setting<bool>("trace");void load(openrac::Mod& mod) {
if (mod.game() != "rac1") {
throw openrac::Error("this mod is for Ratchet & Clank");
}
const bool extra = mod.setting<bool>("enabled_extra");template <class HookPoint, class F> void hook(F&& callable);callable, called as callable(original, args...). Throws openrac::Error when the port has no such hook point, a different signature, or the mod already took it. Only during load.mod.hook<openrac::rac1::Hero_TurnToHeading>(
[trace, &mod](auto original, int32_t m, float accel, float damping, float limit) {
if (trace) mod.info("turning");
original(m, accel, damping, limit);
});// A hook: the lambda gets the way on (the game's function, or a mod's loaded earlier) first,
// then the hook point's arguments. An exception thrown here is logged, and the original runs.
mod.hook<openrac::rac1::Hero_SetPlanarVelocity>([](auto original, float angle) {
// ... before the game's own ...
original(angle);
// ... after it ...
});template <class HookPoint> typename HookPoint::fn original() const;original), for calling it from elsewhere in the mod (another hook, a callback); nullptr before the hook is taken.template <class F> void on_frame(F&& callable); mod.on_frame([] { /* after each game tick */ });
}// Once a game tick: read or change game memory through mod.memory().
mod.on_frame([] {});template <class F> void on_pad(F&& callable);template <class Fn> Fn function(const char* name) const;template <class Fn> Fn required_function(const char* name) const;template <class Fn> Fn function_at(gaddr address) const;Memory memory() const;// Once a game tick: read or change game memory through mod.memory().
mod.on_frame([] {});gaddr relocate(gaddr address) const;gaddr relocate_level(int level, gaddr address) const;int loaded_level() const;StackFrame(const Mod& mod, std::uint32_t size);~StackFrame();gaddr address() const;OPENRAC_MOD_CPP("my-mod", "0.1.0", load)Generated from sdk/include/openrac/mod.hpp at sdk-v1.1.0. Edit this page or report a problem.