when the server ships a new build, the mods should keep working and the only thing you touch is the loader. here’s how that goes.
loader/src/net/binding.js.mixKey and
BUILD_SALT from the page’s moomoo-protocol module every connection, so a plain
redeploy needs no change at all.loader/src/net/protocol.js and
loader/src/net/binding.js. the current server does all of the above; the loader
mirrors it (tables built base-shuffle + hashed-extension, the seal read off the
page’s moomoo-seal import, telemetry answered as the probe reply).install the loader, open the console, and watch the raw packet stream:
MooMooLoader.onRaw((dir, name, args) => console.log(dir, name, args));
do something in game (take a hit, chat, place an item) and watch which wire letter carries it and what order its arguments come in. that tells you how to fix the binding.
loader/src/net/binding.js is where the two halves meet. to re-point an event:
// before: health was packet "O"
incoming["O"] = { event: "health", parse: (a) => ({ sid: a[0], value: a[1] }) };
// after: the server moved health to "Q" and swapped the args
incoming["Q"] = { event: "health", parse: (a) => ({ sid: a[1], value: a[0] }) };
the left side (the wire letter, the argument order) is what changes. the
right side (the name health, the field names sid/value) does not, because
that’s the thing mods depend on. do the same for outgoing actions in the outgoing
map.
if the server adds a packet you want a name for:
shared/vocabulary.js (events or actions) with its field names.loader/src/net/binding.js.npm run build).existing mods don’t care, and new mods can use the new name right away.
npm run build # loader/dist/moomoo-loader.user.js
npm test # make sure the codec still matches the server
re-host the new moomoo-loader.user.js at the same url. since every mod
@requires that url, they all pick up the fix on the next load and nobody has to
republish anything.
every build is pinned to the client bundle it was made for. loader/build.mjs reads
the server’s current dist/official/assets/index-<stem>.js (via $MOOMOO_SERVER_DIR
or a sibling moomoo-clone-main checkout) and bakes that <stem> — the content hash
FRVR puts in the file name — into the loader. at runtime the loader compares it to the
bundle the page actually loaded:
so when you ship a new client and rebuild + re-host the loader, anyone still on the old one is told to update (and to report it, if they’re already current). the check is off until a build pins a stem — the readable source and Node test runs leave it unpinned — and it keys on the file name, which the server’s IS_SANDBOX byte transform never touches, so a dev server never false-alarms. none of it reaches the wire; it’s a local heads-up, invisible to the server.
the test suite round-trips the loader’s codec against the real server protocol when
the server is checked out next to this repo (or at $MOOMOO_SERVER_DIR). keep it
green and you know the wire layer is right.