fix(examples): a Kits reload owed for the example kits survives an interrupted load (D329)
All checks were successful
PR Checks / plugin-checks (pull_request) Successful in -1m52s
All checks were successful
PR Checks / plugin-checks (pull_request) Successful in -1m52s
The first load writes the example kits into Kits' file and asked for a Kits
reload on a one-second timer. A timer dies with its plugin, so a second load of
RunicNPC inside that second (the 9d session's, on Carbon) lost the reload, and
examplesWritten was already set: the examples stayed refused ("no kit
rnpc_juggernaut") until Kits was reloaded by hand.
The kits written are now owed a reload in data/RunicNPC/state.json
(kitsReloadOwed). SettleKitsReload, on every load and when Kits comes back,
clears the debt once Kits knows every kit owed, and otherwise asks for the
reload again, at most three times, then warns with the command to run.
Oxide never showed it: loading RunicNPC recompiles and reloads Kits there
(// Requires: Kits). Carbon does not.
Walked on both rigs (Rust 25797215, Oxide 2.0.7815, Carbon 2.0.262): a first
install landing on a running server, the interrupted state, and a debt for a
kit that never exists (three reloads, the warning, no loop). The harness gains
s6.examples.reloadSettled (0.7.3; compiled on the Carbon rig).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01E14m6SuuY6i1vASFeGDBeY
This commit is contained in:
@@ -45,7 +45,7 @@ namespace Oxide.Plugins
|
||||
/// a made-up user id (11400000001 and up), so <c>IsNpc</c> is false. They take no damage.
|
||||
/// </para>
|
||||
/// </summary>
|
||||
[Info("RunicNpcTest", "Runic Gateway", "0.7.2")]
|
||||
[Info("RunicNpcTest", "Runic Gateway", "0.7.3")]
|
||||
[Description("RunicNPC stage 2 to 7 tests, the stage 6 spike and stage 9's cost check. A developer tool: never ship it.")]
|
||||
internal class RunicNpcTest : RustPlugin
|
||||
{
|
||||
@@ -2422,6 +2422,9 @@ namespace Oxide.Plugins
|
||||
"each needs kits.runicnpc, which nobody is granted");
|
||||
JObject state = Interface.Oxide.DataFileSystem.ReadObject<JObject>("RunicNPC/state");
|
||||
Check("s6.examples.once", state?["examplesWritten"]?.Type == JTokenType.Boolean && (bool)state["examplesWritten"], "state.json: " + state?.ToString(Formatting.None));
|
||||
// D329: once Kits knows the examples, no reload is owed (a state from before D329 has no list at all).
|
||||
JArray owed = state?["kitsReloadOwed"] as JArray;
|
||||
Check("s6.examples.reloadSettled", owed == null || owed.Count == 0, "kitsReloadOwed: " + (owed?.ToString(Formatting.None) ?? "absent"));
|
||||
JObject items = kitFile?["_kits"]?["rnpc_juggernaut"] as JObject;
|
||||
int itemCount = items == null ? 0 : ((JArray)items["MainItems"]).Count + ((JArray)items["WearItems"]).Count + ((JArray)items["BeltItems"]).Count;
|
||||
Check("s6.examples.items", itemCount == 6, $"rnpc_juggernaut carries {itemCount} of its 6 items (a short name this Rust lacks would be left out)");
|
||||
|
||||
Reference in New Issue
Block a user