#!/usr/bin/env node // Local patch: make the platform auth-id requirement for rewards optional. // // Adventure Land's tutorial (ureward) and class (creward) handlers require // player.verified and player.auth_id. auth_id is only populated for Steam/MAS // accounts; plain web accounts have an empty pid/auth_id and therefore can // never claim these rewards. On a self-hosted server that requirement is // usually unnecessary. // // options.tutorial_reward_requires_auth_id: // true/absent -> upstream behaviour (auth_id required) // false -> verified web accounts may claim the rewards too // // The patch is idempotent and fails loudly if the two anchors are gone. const fs = require("node:fs"); const path = require("node:path"); const app = path.resolve(process.argv[2] || "/app"); const file = path.join(app, "node", "server.js"); let source = fs.readFileSync(file, "utf8"); const from = `\t\t\tif (!player.verified || !player.auth_id) {`; const to = `\t\t\tif ( \t\t\t\t!player.verified || \t\t\t\t((typeof options === "undefined" || options.tutorial_reward_requires_auth_id !== false) && !player.auth_id) \t\t\t) {`; function fail(message) { console.error("patch-tutorial-reward-auth: " + message); process.exit(1); } const unpatched = source.split(from).length - 1; const patched = source.split(to).length - 1; if (unpatched === 2) { source = source.split(from).join(to); console.log("patch-tutorial-reward-auth: patched ureward and creward gates"); } else if (unpatched === 0 && patched === 2) { console.log("patch-tutorial-reward-auth: already patched"); } else { fail("expected 2 reward gates, found " + unpatched + " unpatched and " + patched + " patched; refusing partial patch"); } fs.writeFileSync(file, source); console.log("patch-tutorial-reward-auth: wrote " + file);