|
|
|
|
@@ -37,8 +37,10 @@ const HARNESS_STALL_MS = 5 * 60000 // no new line in its file for this long: it
|
|
|
|
|
// Kits' own file, and never again, so a file kept from an older build keeps that build's kits; the drill
|
|
|
|
|
// starts from none of it. Files, never directories: a directory the panel's file API creates is not
|
|
|
|
|
// writable by the game (docs/runicnpc/PLAN.md §1.5), and the game makes these itself on its first boot.
|
|
|
|
|
// Kits' file is not deleted but replaced by one holding only the harness's kit (KITS_FILE, harnessKits):
|
|
|
|
|
// Kits reads it at boot and RunicNPC adds its examples beside it, so no reload is needed for it (#22).
|
|
|
|
|
const KITS_FILE = '/oxide/data/Kits/kits_data.json'
|
|
|
|
|
const FRESH_DATA = [
|
|
|
|
|
'/oxide/data/Kits/kits_data.json',
|
|
|
|
|
'/oxide/data/RunicNPC/profiles.json',
|
|
|
|
|
'/oxide/data/RunicNPC/placements.json',
|
|
|
|
|
'/oxide/data/RunicNPC/routes.json',
|
|
|
|
|
@@ -277,6 +279,7 @@ async function live(a) {
|
|
|
|
|
await p.rm(rig, '/oxide/data/RunicNpcTest.json')
|
|
|
|
|
await p.rm(rig, '/staging-drill.json')
|
|
|
|
|
for (const f of FRESH_DATA) await p.rm(rig, f) // already gone is fine: rm swallows it
|
|
|
|
|
await p.write(rig, KITS_FILE, JSON.stringify(harnessKits(), null, 2))
|
|
|
|
|
|
|
|
|
|
log(`starting ${RIG} on ${branch}`)
|
|
|
|
|
const started = Date.now()
|
|
|
|
|
@@ -309,7 +312,7 @@ async function live(a) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// The harness needs the hidden Kits kit rnhrevolver (tools/RunicNpcTest.cs).
|
|
|
|
|
await ensureKit(p, rig)
|
|
|
|
|
await ensureKit(p, rig, finding)
|
|
|
|
|
|
|
|
|
|
await p.write(rig, '/oxide/plugins/RunicNpcTest.cs', fs.readFileSync(path.join(ROOT, 'tools', 'RunicNpcTest.cs'), 'utf8'))
|
|
|
|
|
let accepted = false
|
|
|
|
|
@@ -387,8 +390,18 @@ async function waitStatus(p, id, timeoutMs) {
|
|
|
|
|
return last
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function ensureKit(p, id) {
|
|
|
|
|
const file = '/oxide/data/Kits/kits_data.json'
|
|
|
|
|
/** Kits' data file holding only the harness's hidden kit, which the drill lays down before the start. */
|
|
|
|
|
function harnessKits() {
|
|
|
|
|
return { _kits: { rnhrevolver: harnessKit() } }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* The harness's kit is laid down before the start (harnessKits), so it is normally there. If it is not
|
|
|
|
|
* (RunicNPC rewrote the file without it), it is added and Kits reloaded through the console's websocket:
|
|
|
|
|
* the panel's fire-and-forget command left no reload in run 48 (#22), so the reply is logged.
|
|
|
|
|
*/
|
|
|
|
|
async function ensureKit(p, id, finding) {
|
|
|
|
|
const file = KITS_FILE
|
|
|
|
|
let data = null
|
|
|
|
|
for (let i = 0; i < 12 && !data; i++) {
|
|
|
|
|
data = readJsonText(await p.readOr(id, file, null))
|
|
|
|
|
@@ -396,9 +409,21 @@ async function ensureKit(p, id) {
|
|
|
|
|
}
|
|
|
|
|
if (!data) throw new Error(`Kits wrote no ${file}`)
|
|
|
|
|
data._kits = data._kits || {}
|
|
|
|
|
if (data._kits.rnhrevolver) return
|
|
|
|
|
if (data._kits.rnhrevolver) {
|
|
|
|
|
log('the rnhrevolver kit is in Kits\' file, laid down before the start')
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
data._kits.rnhrevolver = harnessKit()
|
|
|
|
|
await p.write(id, file, JSON.stringify(data, null, 2))
|
|
|
|
|
const reply = await p.console(id, 'oxide.reload Kits', 15)
|
|
|
|
|
const loaded = reply.some((l) => /Loaded plugin Kits/.test(l))
|
|
|
|
|
log(`added the rnhrevolver kit and reloaded Kits: ${loaded ? 'Kits loaded again' : `no "Loaded plugin Kits" in 15 s (${reply.length} console line(s))`}`)
|
|
|
|
|
if (!loaded) finding('Kits did not reload after the drill added the harness\'s rnhrevolver kit; the harness\'s profiles may be refused.')
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function harnessKit() {
|
|
|
|
|
const item = (Shortname, Amount, Position, Condition = 0) => ({ Shortname, Skin: 0, Amount, Condition, MaxCondition: Condition, Ammo: 0, Position, Frequency: -1 })
|
|
|
|
|
data._kits.rnhrevolver = {
|
|
|
|
|
return {
|
|
|
|
|
Name: 'rnhrevolver',
|
|
|
|
|
Description: 'RunicNPC test harness: revolver + burlap (staging drill)',
|
|
|
|
|
RequiredPermission: '',
|
|
|
|
|
@@ -413,10 +438,6 @@ async function ensureKit(p, id) {
|
|
|
|
|
WearItems: [item('burlap.shirt', 1, 0), item('burlap.trousers', 1, 1), item('hat.boonie', 1, 2)],
|
|
|
|
|
BeltItems: [item('pistol.revolver', 1, 0, 100)],
|
|
|
|
|
}
|
|
|
|
|
await p.write(id, file, JSON.stringify(data, null, 2))
|
|
|
|
|
await p.command(id, 'oxide.reload Kits')
|
|
|
|
|
await sleep(10000)
|
|
|
|
|
log('added the rnhrevolver kit and reloaded Kits')
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function readJsonText(t) {
|
|
|
|
|
@@ -621,7 +642,7 @@ async function fileIssue(title, body) {
|
|
|
|
|
// ---------------------------------------------------------------- main
|
|
|
|
|
|
|
|
|
|
// The pure parts, for drill.test.js; run as a script, it is the command line.
|
|
|
|
|
module.exports = { harnessProgress, unfinishedFinding, FRESH_DATA, HARNESS_STALL_MS }
|
|
|
|
|
module.exports = { harnessProgress, unfinishedFinding, FRESH_DATA, KITS_FILE, harnessKits, HARNESS_STALL_MS }
|
|
|
|
|
|
|
|
|
|
if (require.main === module) {
|
|
|
|
|
const a = args()
|
|
|
|
|
|