feat(guide): guides only by the admin, and seen by everyone

The login's Guide option made a player a guide on their own screen only:
the room's avatar packet never said so, so everyone else drew a plain
player. "ac" now sends the guide field (bit 4, after a blend colour of 0),
which gives the guide's name tag and chat bubble on every client.

Guide is now given in the admin panel (Make guide / Remove guide, logged).
Asked for at login by anyone else, it is refused, with a plain message on
arrival. A guide's custom client can still leave it off; the official
launcher asks nothing, and a guide shows as one.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
BurrowdevandClaude Opus 5.5 committed 2026-10-20 23:44:11 +03:00
1 parent da9f2fd5a6
commit a860a67626
4 files changed
+32 -8

No files matched your search

+9 -5
View File
@@ -46,7 +46,7 @@ const SCHEMA = `
// fields stored in their own columns rather than in `state`.
const COLUMN_FIELDS = ["id", "username", "salt", "hash", "createdAt"];
// how the game treats the account this session; set again at every login.
const SESSION_FIELDS = ["accountType", "isGuide", "isModerator", "membershipDays", "startInDen", "startRoom"];
const SESSION_FIELDS = ["accountType", "isGuide", "guideRefused", "isModerator", "membershipDays", "startInDen", "startRoom"];
const DEFAULT_MEMBERSHIP_DAYS = 9999;
const MAX_ACCOUNT_TYPE = 5;
const MEMBERSHIP_TYPES = [0, 2]; // non-member, member
@@ -302,13 +302,17 @@ const MAX_START_ROOM = 80;
function setLoginChoices(account, choices) {
const asked = config.loginChoices && choices && typeof choices === "object" ? choices : {};
const whole = (value, max) => Number.isInteger(value) && value >= 0 && value <= max;
// member or not, and guide or not, are the player's own choice on any
// server; the rest only with config.loginChoices: another account type
// shows to everyone.
// member or not is the player's own choice on any server; the rest only
// with config.loginChoices: another account type shows to everyone.
const own = choices && typeof choices === "object" ? choices : {};
const type = MEMBERSHIP_TYPES.includes(own.accountType) ? own.accountType : asked.accountType;
account.accountType = whole(type, MAX_ACCOUNT_TYPE) ? type : config.defaultAccountType;
account.isGuide = own.isGuide === true;
// guide (the name tag, the chat bubble, what others see) only for an
// account the admin made one (lib/panel.js); asked for without that, it is
// refused. a guide's own client may leave it off; the official launcher
// asks nothing, and a guide is one.
account.isGuide = account.guideGiven === true && (choices && typeof choices === "object" ? own.isGuide === true : true);
account.guideRefused = own.isGuide === true && account.guideGiven !== true;
account.isModerator = asked.isModerator === true;
account.membershipDays = whole(asked.membershipDays, MAX_MEMBERSHIP_DAYS) ? asked.membershipDays : DEFAULT_MEMBERSHIP_DAYS;
// where to start is the player's to say on any server: their own den in