#!/usr/bin/env node // Local patch for the Adventure Land game server (applied at image build time). // // The upstream DRM check in node/server.js (start_character) treats every // account created after 2019-02-01 as unverified unless it carries a Steam or // Mac App Store auth id. A self-hosted server cannot issue those ids (Steam // tickets need the game's private publisher key, and Steam OpenID sign-in needs // a publisher web API key), so every login gets the "authfail" condition: // gold/luck -85%, xp -20%. // // AL_DRM_CHECK=0 disables the check. Unset or any other value keeps the // upstream behaviour. The script fails loudly when the upstream line is gone, // so a code update cannot silently skip the patch. const fs = require("node:fs"); const file = process.argv[2] || "/app/node/server.js"; const original = 'if (owner.created > new Date(2019, 1, 1) && !gf(owner, "legacy_override")) drm = true;'; const patched = 'if (process.env.AL_DRM_CHECK !== "0" && owner.created > new Date(2019, 1, 1) && !gf(owner, "legacy_override")) drm = true;'; const source = fs.readFileSync(file, "utf8"); if (source.includes(patched)) { console.log("patch-drm-check: already applied"); process.exit(0); } if (source.split(original).length !== 2) { console.error( "patch-drm-check: expected exactly one occurrence of the upstream DRM check in " + file, ); process.exit(1); } fs.writeFileSync(file, source.replace(original, patched)); console.log("patch-drm-check: applied to " + file);