Files
ReSkate/Extension/Console/commands.cpp
T
Krischan-KlugandClaude Opus 5.5 c7d2ca3601 Add Hall of Meat: the bones a bail hurt and its Meat score
As in skate. 3: when the local skater bails, the bones it hurt show over
the world through the body, yellow where a hit bruised one and red where
one broke it, with the bail's Meat card in the bottom left corner in the
place of skate.'s own HUD there: its time, hits (head hits double,
vehicles half again), broken bones, road rash, airtime, fall, top speed
and rotations, each scoring, and the map's best. A bone breaking pulses
the screen's edges red and, in single player, slows the game down a
moment. Off until switched on, as in skate.: in skate.'s menu (Custom
Stuff > Player) or with `hallofmeat 0|1`, saved with the profile.

Everything it draws is skate.'s own, read from the installed game: its
skeleton mesh (the Dem Bones costume) posed with the renderer's own
skinning matrices, its scoring icons, the THRASHER wordmark and its UI
brush strokes. Nothing is shipped.

How it works: No Bail already hooks the skeleton response, which runs
once a physics step right after the body contacts; it now hands that step
on, with the local skater it follows, but only while Hall of Meat is on.
Each step reads what every ragdoll body hit and how hard, and whether the
skater is a ragdoll; the bail runs on the game's own clock so slow motion
measures what the body did. The feature's own hooks, on the renderer's
skinned draw packets and main view and on the UI model's write, are
prepared at startup and switched on only with the feature, and off again
once the HUD corner and the game's speed are given back: switched off, the
game never calls them and the physics step pays nothing. The skeleton mesh
is read the first time it is on; only the images are read at startup,
since the overlay builds its atlas once. The renderer's picture of the
skater is read only while a bail shows. The menu's switch reads the
overlay model like the others. Every address is in the build table with a
fingerprint checked before use. Extension/HallOfMeat/README.md describes
the parts; its tests build with DINGOSDK_BUILD_HALL_OF_MEAT_TESTS.

The slow motion changes SimulationTime's rate, frame cap and time scale as
a session override and steps the local skater along, since skate. sets a
skater's step only when it builds its core. It runs the same at every
break, but never faster than the game ran: with the trainer's game speed
below 1 it only takes the part that is slower still. Afterwards it writes
back what it found, each setting only while it still holds what the slow
motion wrote, so the trainer's speed comes back as it was; a setting
changed from elsewhere meanwhile is left as it is and ends that slow
motion. named_setting_value reads a setting's value for it.

Tuned in play: a bruise from 7 m/s and a break from 12 m/s along the
contact normal (raised twice: a hard fall on flat ground broke bones), a
break worth ten of the lightest hits (a heavy bail's hits and breaks
outweighed the rest of the card) and a fall half of skate. 3's rate.

Fix: the overlay now draws in the back buffer's pixels, not the window's,
so it lines up on displays Windows scales (1920x1080 borderless on 4K).

The skater's render hooks, its skeleton and its body maps were first
found by gBGYo's ReSkate fork (github.com/gBGYo/ReSkate).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-09 15:29:38 +02:00

233 lines
10 KiB
C++

#include "commands.h"
#include "Engine/Core/Log/logging.h"
#include "Engine/Core/Platform/path_text.h"
#include <memory>
namespace dingosdk::console {
Argument argument(std::string name, Type type, bool optional) {
Argument result;
result.name = std::move(name);
result.type = type;
result.optional = optional;
return result;
}
Entry action(std::string name, std::string description, Group group, std::vector<Argument> args) {
Entry entry;
entry.name = std::move(name);
entry.description = std::move(description);
entry.group = group;
entry.arguments = std::move(args);
return entry;
}
Entry variable(std::string name, std::string description, Group group, Argument arg) {
auto entry = action(std::move(name), std::move(description), group, {std::move(arg)});
entry.kind = Kind::variable;
return entry;
}
State boolean_state(bool available, bool value, std::string reason, std::string detail) {
return {available, available ? std::optional<std::string>(value ? "1" : "0") : std::nullopt, std::move(reason),
std::move(detail), false};
}
namespace {
void register_console_commands(Commands &registry) {
auto topic = argument("command", Type::text, true);
topic.rest = true;
topic.complete = [&registry](const Model &, auto) {
std::vector<std::string> names;
for (const auto &e : registry.entries())
names.push_back(e.name);
return names;
};
auto help = action("help", "Show command syntax, values, restrictions, and availability", Group::console, {topic});
help.execution = Execution::local;
help.run = [&registry](const Model &model, const Values &args, const Output &out) {
if (args.empty()) {
out("Enter a variable by itself to read it, or follow it with a value: "
"noclip 1, nobail 0, flyspeed 60.");
out("Use commands [prefix] to list entries, help <command> for details, "
"and Tab to complete names and "
"arguments.");
out("Groups: Movement, Gameplay, World, Graphics, Progression, Objects, "
"Engine, Console.");
return;
}
const auto &name = std::get<std::string>(args[0]);
const auto *entry = registry.find(name);
if (!entry) {
bool found = false;
for (const auto &item : registry.entries())
if (ascii_case_insensitive_starts_with(item.name, name + " ")) {
out(Commands::usage(item) + (item.description.empty() ? "" : " - " + item.description));
found = true;
}
if (!found)
out("error: Unknown help topic.");
return;
}
out(Commands::usage(*entry));
out(registry.describe(*entry, model));
out(std::string("Group: ") + group_name(entry->group));
for (const auto &arg : entry->arguments) {
if (!arg.choices.empty()) {
std::string choices = arg.name + ": ";
for (const auto &choice : arg.choices) {
if (choices.back() != ' ')
choices += ", ";
choices += choice;
}
out(choices);
}
if (arg.minimum || arg.maximum)
out(arg.name + " range: " + (arg.minimum ? value_text(*arg.minimum) : "unbounded") + " to " +
(arg.maximum ? value_text(*arg.maximum) : "unbounded"));
}
if (entry->reset)
out("Restore: reset " + entry->name);
};
registry.add(std::move(help));
auto list = action("commands", "List commands and variables, optionally filtered by prefix", Group::console,
{argument("prefix", Type::text, true)});
list.execution = Execution::local;
list.run = [&registry](const Model &model, const Values &args, const Output &out) {
const auto prefix = args.empty() ? std::string{} : std::get<std::string>(args[0]);
std::vector<const Entry *> rows;
for (const auto &e : registry.entries())
if (ascii_case_insensitive_starts_with(e.name, prefix))
rows.push_back(&e);
std::sort(rows.begin(), rows.end(), [](auto *a, auto *b) { return lower(a->name) < lower(b->name); });
for (const auto *e : rows)
out(registry.describe(*e, model));
out(std::to_string(rows.size()) + " matching entries.");
};
registry.add(std::move(list));
for (const auto &name : {"clear", "history"}) {
auto entry =
action(name, equal(name, "clear") ? "Clear console scrollback" : "Show recent commands", Group::console);
entry.execution = Execution::local;
entry.echo_input = !equal(name, "clear");
entry.run = [clear = equal(name, "clear")](const Model &, const Values &, const Output &out) {
const auto &callback = clear ? out.clear : out.history;
if (callback)
callback();
else
out("This command belongs to the overlay console.");
};
registry.add(std::move(entry));
}
auto text = argument("text", Type::text, true);
text.rest = true;
auto echo = action("echo", "Print text to the console", Group::console, {text});
echo.execution = Execution::local;
echo.run = [](const Model &, const Values &args, const Output &out) {
out(args.empty() ? "" : std::get<std::string>(args[0]));
};
registry.add(std::move(echo));
auto status = action("status", "Show current game state", Group::console);
status.execution = Execution::local;
status.run = [](const Model &model, const Values &, const Output &out) {
out("state: " + model.state);
out("freecam=" + value_text(model.debug.free_camera) + " noclip=" + value_text(model.debug.noclip) +
" nobail=" + value_text(model.debug.no_bail) +
" flyspeed=" + value_text(static_cast<double>(model.debug.camera_speed)));
if (!model.offline.status.empty())
out(model.offline.status);
};
registry.add(std::move(status));
auto reset_arg = argument("command");
reset_arg.rest = true;
reset_arg.complete = [&registry](const Model &, auto) {
std::vector<std::string> names{"all", "movement", "features", "engine"};
for (const auto &e : registry.entries())
if (e.reset)
names.push_back(e.name);
return names;
};
auto reset = action("reset", "Restore a variable or a group of session overrides", Group::console, {reset_arg});
reset.run = [&registry](const Model &model, const Values &args, const Output &out) {
const auto &name = std::get<std::string>(args[0]);
const auto *entry = registry.find(name);
if (!entry || !entry->reset) {
out("error: This entry has no restore operation. Use help reset.");
return;
}
entry->reset(model, out);
};
registry.add(std::move(reset));
for (const auto &name : {"movement", "features", "engine", "all"}) {
auto entry = action(std::string("reset ") + name, "Restore the selected runtime overrides", Group::console);
entry.run = [scope = std::string(name)](const Model &model, const Values &, const Output &out) {
// Restore native fields before queuing other changes; the runtime
// reservation intentionally rejects competing setting transactions.
if (scope == "engine" || scope == "all") {
out(request_reset_named_settings());
if (scope == "engine")
for (const auto &v : model.offline.variables)
if (v.override_active)
request_engine_variable(v.name, true, false);
}
if (scope == "movement" || scope == "all")
request_debug(overlay::DebugAction::restore_debug);
if (scope == "features" || scope == "all")
request_feature(overlay::OfflineFeatureGroup::restore_all, false);
};
if (equal(name, "movement"))
entry.aliases = {"reset debug"};
registry.add(std::move(entry));
}
auto log = action("log", "Show logging level and output path", Group::console);
log.execution = Execution::local;
log.aliases = {"log status"};
log.run = [](const Model &, const Values &, const Output &out) {
const auto s = logging::status();
out(std::string("Logging level: ") + std::string(logging::name(s.level)));
out(path_utf8(s.directory / L"ReSkate.log"));
};
registry.add(std::move(log));
auto level = argument("level");
level.choices = {"trace", "debug", "info", "warning", "error", "critical", "off"};
auto loglevel = variable("loglevel", "Set the shared logging level", Group::console, level);
loglevel.execution = Execution::local;
loglevel.aliases = {"log level"};
loglevel.inspect = [](const Model &) {
return State{true, std::string(logging::name(logging::status().level)), {}, {}, false};
};
loglevel.run = [](const Model &, const Values &args, const Output &out) {
const auto &text = std::get<std::string>(args[0]);
const auto parsed = logging::parse_level(text);
if (parsed) {
logging::set_level(*parsed);
out("Logging level: " + text);
}
};
registry.add(std::move(loglevel));
auto flush = action("log flush", "Flush the log file", Group::console);
flush.execution = Execution::local;
flush.run = [](const Model &, const Values &, const Output &out) {
logging::flush();
out("Log flushed.");
};
registry.add(std::move(flush));
}
} // namespace
const Commands &game_commands() {
static const auto registry = [] {
auto result = std::make_unique<Commands>();
register_console_commands(*result);
register_movement_commands(*result);
register_ai_commands(*result);
register_settings_commands(*result);
register_world_commands(*result);
register_graphics_commands(*result);
register_progression_commands(*result);
register_object_commands(*result);
register_park_editor_commands(*result);
register_multiplayer_commands(*result);
register_perf_commands(*result);
register_trainer_commands(*result);
register_hall_of_meat_commands(*result);
return result;
}();
return *registry;
}
} // namespace dingosdk::console