mirror of
https://github.com/Dingo-Shenanigans/ReSkate.git
synced 2026-10-23 18:45:57 +02:00
Plugins: a command ReSkate does not know goes to the game thread, where plugins have theirs
The console answered every command missing from ReSkate's own list itself, as unknown, so a plugin's command (ptest) never reached the plugins on the game thread. Now only ReSkate's local commands run there; anything else is queued, and the game thread tries the plugins first and answers unknown as before when none has it. Checked in game: ptest all, 45 passed, 0 failed.
This commit is contained in:
1 parent
a3e75ba10e
commit
fc4308b682
3 files changed
+6
-2
No files matched your search
@@ -188,6 +188,8 @@ template <class Context> class Registry {
|
||||
const auto [entry, consumed] = resolve(words);
|
||||
return !entry || entry->echo_input || consumed != words.size();
|
||||
}
|
||||
// Whether the words start with one of its commands.
|
||||
bool knows(std::span<const std::string> words) const { return resolve(words).first != nullptr; }
|
||||
bool local(std::span<const std::string> words, const Context &context) const {
|
||||
const auto [entry, consumed] = resolve(words);
|
||||
return !entry || entry->execution == Execution::local ||
|
||||
|
||||
@@ -220,7 +220,9 @@ void submit_console_command() {
|
||||
try {
|
||||
const auto& registry = dingosdk::console::game_commands();
|
||||
if (registry.echoes(parsed.arguments)) output("> " + command);
|
||||
if (!parsed || registry.local(parsed.arguments, s.model)) {
|
||||
// A command ReSkate does not know may be a plugin's, which run on the game thread
|
||||
// (Extension/Plugins); one no plugin has either is answered there as unknown.
|
||||
if (!parsed || (registry.knows(parsed.arguments) && registry.local(parsed.arguments, s.model))) {
|
||||
registry.execute(command, s.model, output);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ local h = require("harness")
|
||||
local t = h.module("console")
|
||||
|
||||
-- Try it by hand: ptest echo a b c
|
||||
reskate.console.command("ptest echo", "Prints its words back (reskate-test)", function(args)
|
||||
reskate.console.command("ptest echo", "Prints its words back", function(args)
|
||||
reskate.console.print("ptest echo: " .. table.concat(args, " "))
|
||||
end)
|
||||
|
||||
|
||||
Reference in new issue
Block a user