diff --git a/config.js b/config.js
index 40cfe32..0261323 100644
--- a/config.js
+++ b/config.js
@@ -114,7 +114,9 @@ module.exports = {
// game no longer open to SWFs from other addresses.
// 40: the chat filter's window laid out again.
// 41: the game's text says "Burrow" where it said Animal Jam.
- buildVersion: env.AJ_BUILD_VERSION || "41",
+ // 48: the item giver (the item finder renamed) with previews and hex colours;
+ // 49 and 50: its link to a colour picker.
+ buildVersion: env.AJ_BUILD_VERSION || "55",
// what the official CDN is asked for; not ours to change.
upstreamBuildVersion: "3",
@@ -147,7 +149,7 @@ module.exports = {
// are written into both pages. the emails and the host's country are
// placeholders until set; the operator is, at the owner's word, said to
// be in the EU without a name or a country.
- termsVersion: "2026-10-13",
+ termsVersion: "2026-10-17",
legalEmail: env.AJ_LEGAL_EMAIL || "legal@burrow.moe",
adminEmail: env.AJ_ADMIN_EMAIL || "admin@burrow.moe",
operator: env.AJ_OPERATOR || "an individual based in the European Union",
diff --git a/lib/accounts.js b/lib/accounts.js
index 6e2be27..50387dc 100644
--- a/lib/accounts.js
+++ b/lib/accounts.js
@@ -56,6 +56,10 @@ const MIN_LETTERS = 3; // the client's own rule (SbiConstants.USERNAME_REGEX)
const MIN_PASSWORD_LENGTH = 10;
const MAX_DEN_SLOTS = 200; // DenSwitch.nextFreeSlotIdx
const DEN_OPEN = 2; // den privacy: 0 locked, 1 buddies only, 2 everyone
+const USER_VAR_SETTINGS = 363; // the settings menu's switches, a bit each (gui.MySettings)
+// the chat filter an account starts with: level 1 slurs and threats, mode 1
+// the whole message left out (see account.filter below).
+const DEFAULT_FILTER = {level: 1, mode: 1, words: ""};
const MAX_PASSWORD_LENGTH = 100;
// parts of the game a player can switch off for their own account, each
// enforced where the game asks for it (featureOn below).
@@ -109,7 +113,7 @@ const newAvatar = (ids, name, type, customAvId) => {
customAvId: custom ? Number(customAvId) : -1,
colors: [def.colorLayer1, Number(custom && custom.overrideColorLayer2) || def.colorLayer2, def.colorLayer3].map(Number),
eyes: Number(def.baseEyesId) || 0,
- pattern: Number(custom ? custom.patternRefId : def.basePatternId) || 0,
+ pattern: Number(custom ? defpacks.customPattern(customAvId) : def.basePatternId) || 0,
petInvId: 0,
};
};
@@ -153,6 +157,10 @@ const normalize = account => {
account.outfitUndo.avInvId = avatar.avInvId;
}
}
+ // custom animals made while their pattern list was a 0 (lib/defpacks.js)
+ for (const avatar of account.avatars.filter(candidate => candidate.customAvId !== -1 && !candidate.pattern)) {
+ avatar.pattern = defpacks.customPattern(avatar.customAvId);
+ }
account.pets = account.pets || []; // {inv, lBits, uBits, eBits, name, createdAt}
account.dens = account.dens || [{inv: 0, def: config.denDefId}]; // den rooms owned
account.activeDen = account.activeDen || 0; // inv of the den in use
@@ -174,14 +182,34 @@ const normalize = account => {
account.activeDen = moved.has(account.activeDen) ? moved.get(account.activeDen) : account.activeDen;
for (const item of account.denItems || []) {
item.den = moved.has(item.den) ? moved.get(item.den) : item.den;
+ if (item.spots) {
+ item.spots = Object.fromEntries(Object.entries(item.spots).map(([den, spot]) => [moved.has(Number(den)) ? moved.get(Number(den)) : den, spot]));
+ }
}
}
account.denPrivacy = account.denPrivacy === undefined ? DEN_OPEN : account.denPrivacy;
- account.denItems = account.denItems || []; // {inv, def, version, placed, den, x, y, flip, mannequin?, image?}: lib/dens.js
+ // {inv, def, version, spots, mannequin?, image?}: lib/dens.js. spots: where
+ // it stands, {den inventory id: {cat, x, y, flip}}, as many dens as it is in.
+ account.denItems = account.denItems || [];
for (const item of account.denItems) {
- item.den = item.den === undefined ? account.activeDen : item.den; // which den it is placed in
+ // from when an item stood in one den at most: {placed, den, x, y, flip, cat}.
+ if (!item.spots) {
+ const den = item.den === undefined ? account.activeDen : item.den;
+ item.spots = item.placed ? {[den]: {cat: item.cat || 1, x: item.x || 0, y: item.y || 0, flip: item.flip || 0}} : {};
+ }
+ for (const old of ["placed", "den", "x", "y", "flip", "cat"]) {
+ delete item[old];
+ }
}
account.userVars = account.userVars || {};
+ // the settings menu's switches (user var 363) were once stored as the
+ // number of the last switch touched rather than as bits: such a value
+ // cannot be told from a real one, so every account starts again from the
+ // game's defaults, once.
+ if (!account.settingsBitsFixed) {
+ delete account.userVars[USER_VAR_SETTINGS];
+ account.settingsBitsFixed = true;
+ }
account.theme = account.theme || ""; // seasonal look of the lands, see themes in config.js
account.lastSeen = account.lastSeen || 0; // when they last left the game, in seconds; 0 = never recorded
// what the player set on the account page (lib/manage.js).
@@ -219,12 +247,25 @@ const normalize = account => {
account.discord = typeof account.discord === "string" ? account.discord : ""; // their Discord username, as they gave it
account.badges = Array.isArray(account.badges) ? account.badges : []; // badge ids, given in the admin panel
account.bio = typeof account.bio === "string" ? account.bio : ""; // their own words, for the card's Bio tab
+ // seconds spent in the game in all (lib/world.js counts it), and whether
+ // their card shows it to others: theirs to choose on the account page.
+ account.playtime = Number.isFinite(account.playtime) && account.playtime > 0 ? Math.floor(account.playtime) : 0;
+ account.playtimePublic = account.playtimePublic === true;
// the chat filter, which the player's own game applies (AJClient in the
// patched SWF; "xfl" in lib/world.js): {level: 1 slurs and threats, 2
// swearing too, 0 off; mode: 0 stars over the words, 1 the message left
// out; words: their own, commas between; chosen: have they been asked}.
- // an account that has not chosen has no filter: that is the start.
- account.filter = account.filter && typeof account.filter === "object" && account.filter.chosen ? account.filter : {level: 0, mode: 0, words: "", chosen: false};
+ // an account starts with slurs and threats hidden, and may turn it off.
+ account.filter = account.filter && typeof account.filter === "object" && account.filter.chosen ? account.filter : {...DEFAULT_FILTER, chosen: false};
+ // that default came after accounts that had none, or had turned it off:
+ // they get it too, once. a stricter level, and the way it is shown when
+ // they had one, stay as they were.
+ if (!account.filterDefaultApplied) {
+ if (!(account.filter.level >= DEFAULT_FILTER.level)) {
+ Object.assign(account.filter, {level: DEFAULT_FILTER.level, mode: DEFAULT_FILTER.mode});
+ }
+ account.filterDefaultApplied = true;
+ }
// two-step sign-in: lib/totp.js.
account.totp = account.totp || null;
account.totpSetup = account.totpSetup || null;
@@ -245,11 +286,13 @@ 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 is the player's own choice on any server, the rest only
- // with config.loginChoices: another account type shows to everyone.
- const type = choices && typeof choices === "object" && MEMBERSHIP_TYPES.includes(choices.accountType) ? choices.accountType : asked.accountType;
+ // 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.
+ 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 = asked.isGuide === true;
+ account.isGuide = own.isGuide === 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
@@ -277,6 +320,7 @@ const insert = (username, salt, hash, createdAt, state) => {
account.id = Number(result.lastInsertRowid);
savedState.set(account.id, json);
remember(account);
+ touch(account);
return account;
};
@@ -371,20 +415,101 @@ const load = () => {
console.log(`[accounts] ${byKey.size} accounts in ${path.join(config.dataDir, "game.sqlite")}`);
};
+// Which accounts the save after a message looks at. turning an account into
+// JSON to see whether it changed costs, and doing it for every account there
+// is, a second after nearly every message, held the whole server up for
+// longer the more accounts there were: a second and more, for everyone. so
+// it looks at the accounts in play: online ones (hold, from lib/world.js),
+// and ones looked up lately (by name, id, token, password: how the admin
+// panel, buddies and the like get at an offline account), until a save
+// finds them written and WARM_MS has gone by. the rest are looked at a few
+// at a time behind those (SWEEP_BUDGET_MS a save), round and round, for
+// what reached an account some other way (accounts.all()). a stop of the
+// server, and every flush() called by name, looks at all of them.
+const WARM_MS = 10 * 60 * 1000;
+const SWEEP_BUDGET_MS = 5;
+const held = new Set(); // accounts online
+const warm = new Map(); // account -> when last looked up
+let sweepOrder = [];
+let sweepAt = 0;
+let sweepLeft = 0; // accounts the sweep still has to look at since the last save()
+const touch = account => {
+ if (account) {
+ warm.set(account, Date.now());
+ }
+ return account;
+};
+const hold = account => {
+ held.add(account);
+ touch(account);
+};
+const release = account => {
+ held.delete(account);
+ touch(account);
+};
+
+const changedState = (account, changed) => {
+ const json = stateJson(account);
+ if (savedState.get(account.id) !== json) {
+ changed.push([account.id, json]);
+ return true;
+ }
+ return false;
+};
+
// writes every account whose state changed since it was last written, in
-// one transaction.
-const flush = () => {
+// one transaction; with {some: true}, of the accounts in play and the
+// sweep's next few (above).
+const flush = ({some = false} = {}) => {
clearTimeout(saveTimer);
saveTimer = null;
if (!db) {
return;
}
const changed = [];
- for (const account of byId.values()) {
- const json = stateJson(account);
- if (savedState.get(account.id) !== json) {
- changed.push([account.id, json]);
+ if (some) {
+ const now = Date.now();
+ const looked = new Set();
+ for (const account of held) {
+ looked.add(account);
+ changedState(account, changed);
}
+ for (const [account, at] of warm) {
+ if (looked.has(account)) {
+ continue;
+ }
+ looked.add(account);
+ if (byId.get(account.id) !== account) {
+ warm.delete(account); // removed
+ }
+ else if (!changedState(account, changed) && now - at > WARM_MS && !held.has(account)) {
+ warm.delete(account);
+ }
+ }
+ const started = process.hrtime.bigint();
+ while (sweepLeft > 0 && Number(process.hrtime.bigint() - started) / 1e6 < SWEEP_BUDGET_MS) {
+ if (sweepAt >= sweepOrder.length) {
+ sweepOrder = [...byId.values()];
+ sweepAt = 0;
+ if (sweepOrder.length === 0) {
+ break;
+ }
+ }
+ const account = sweepOrder[sweepAt++];
+ sweepLeft--;
+ if (!looked.has(account) && byId.get(account.id) === account) {
+ changedState(account, changed);
+ }
+ }
+ }
+ else {
+ for (const account of byId.values()) {
+ changedState(account, changed);
+ }
+ sweepLeft = 0;
+ }
+ if (sweepLeft > 0) {
+ save(); // the sweep goes on in a moment
}
if (changed.length === 0) {
return;
@@ -415,10 +540,11 @@ const flush = () => {
const SAVE_DELAY_MS = 1000;
let saveTimer = null;
const save = () => {
+ sweepLeft = byId.size;
if (saveTimer === null) {
saveTimer = setTimeout(() => {
try {
- flush();
+ flush({some: true});
}
catch (err) {
console.error(`[accounts] could not save: ${err.message}`);
@@ -512,7 +638,7 @@ const register = (username, password, avatar = {}) => {
const authenticate = (username, password) => {
// "name" and "name " are the same account.
- const account = typeof username === "string" ? byKey.get(username.trim().toLowerCase()) : null;
+ const account = typeof username === "string" ? touch(byKey.get(username.trim().toLowerCase())) : null;
if (typeof password !== "string" || !password) {
return null;
}
@@ -534,7 +660,7 @@ const authenticate = (username, password) => {
// the same, with the password worked out off the main thread (above).
const authenticateAsync = async (username, password) => {
- const account = typeof username === "string" ? byKey.get(username.trim().toLowerCase()) : null;
+ const account = typeof username === "string" ? touch(byKey.get(username.trim().toLowerCase())) : null;
if (typeof password !== "string" || !password || password.length > MAX_PASSWORD_LENGTH) {
return null;
}
@@ -684,15 +810,15 @@ const issueToken = account => {
const byToken = token => {
const entry = typeof token === "string" && token.length === TOKEN_HEX_LENGTH ? tokens.get(tokenHash(token)) : null;
- return entry && !tokenExpired(entry.createdAt) ? byId.get(entry.id) || null : null;
+ return entry && !tokenExpired(entry.createdAt) ? touch(byId.get(entry.id)) || null : null;
};
-const byName = username => byKey.get(String(username).toLowerCase()) || null;
+const byName = username => touch(byKey.get(String(username).toLowerCase())) || null;
-const accountById = id => byId.get(Number(id)) || null;
+const accountById = id => touch(byId.get(Number(id))) || null;
const all = () => [...byId.values()];
const database = () => db;
-module.exports = {FEATURES, featureOn, recordLogin, revokeTokens, load, save, flush, startBackups, database, setLoginChoices, setPassword, rename, remove, setting, setSetting, hashPassword, register, usernameProblem, authenticate, authenticateAsync, issueToken, byToken, byName, byId: accountById, newAvatar, freeAvatarSlot, all};
+module.exports = {FEATURES, featureOn, recordLogin, revokeTokens, load, save, flush, hold, release, startBackups, database, setLoginChoices, setPassword, rename, remove, setting, setSetting, hashPassword, register, usernameProblem, authenticate, authenticateAsync, issueToken, byToken, byName, byId: accountById, newAvatar, freeAvatarSlot, all};
diff --git a/lib/admin.js b/lib/admin.js
index 87951eb..7361ba7 100644
--- a/lib/admin.js
+++ b/lib/admin.js
@@ -53,6 +53,10 @@ const search = (params, favourites = null) => {
};
};
+// one to four "#RRGGBB", spaces or commas between. the # is wanted: six
+// digits alone are a colour id
+const HEX_COLOURS = /^#[0-9a-f]{6}([\s,]+#[0-9a-f]{6}){0,3}$/i;
+
const give = body => {
const account = accounts.byName(body.username);
if (!account) {
@@ -62,13 +66,28 @@ const give = body => {
if (body.kind === "clothing") {
const def = defpacks.itemDef(body.id);
const colors = def ? String(def.colors).split(",") : [];
- // `color` is a raw colour id of the caller's choosing; otherwise one of
- // the item's own colours is picked by `colorIndex`.
- const custom = body.color !== undefined && body.color !== "";
- if (custom && !isUint(String(body.color))) {
- return {status: 400, body: {error: "The colour id must be a whole number from 0 to 4294967295"}};
+ // `color` is a raw colour id of the caller's choosing, or one to four hex
+ // colours ("#FF8800", "#FF0000 #FFFFFF") for the item's four colour bands
+ // in order, the last filling the rest: a custom colour (lib/colours.js),
+ // made as the animal editor's hex box makes one. otherwise one of the
+ // item's own colours is picked by `colorIndex`.
+ let custom = body.color !== undefined && body.color !== "" ? String(body.color).trim() : "";
+ const hexes = custom.match(HEX_COLOURS) ? custom.split(/[\s,]+/).filter(Boolean) : null;
+ if (hexes) {
+ const rgbs = [0, 1, 2, 3].map(slot => parseInt(hexes[Math.min(slot, hexes.length - 1)].replace("#", ""), 16));
+ const entry = world.makeColour(account, rgbs, session);
+ if (!entry) {
+ return {status: 400, body: {error: "Bad colour"}};
+ }
+ if (entry.full) {
+ return {status: 429, body: {error: "No more new colours today. Colours made before can still be used."}};
+ }
+ custom = String(entry.id);
}
- const color = custom ? String(body.color) : colors[Number(body.colorIndex) || 0];
+ if (custom && !isUint(custom)) {
+ return {status: 400, body: {error: "Colour: an id, or #RRGGBB"}};
+ }
+ const color = custom || colors[Number(body.colorIndex) || 0];
if (!def || !defpacks.clothingIds().includes(Number(def.id)) || color === undefined) {
return {status: 400, body: {error: "No such clothing item or colour"}};
}
diff --git a/lib/commands.js b/lib/commands.js
index 60424e9..46e2122 100644
--- a/lib/commands.js
+++ b/lib/commands.js
@@ -166,22 +166,22 @@ module.exports = ({findOnline, players, watchers, sendItemList, blocks, setHideB
const activeDenDef = account => (account.dens.find(den => den.inv === account.activeDen) || account.dens[0]).def;
const layoutOf = owner => owner.denItems
- .filter(item => item.placed && item.den === owner.activeDen)
- .map(item => ({def: item.def, version: item.version, x: item.x, y: item.y, flip: item.flip}));
+ .filter(item => dens.spotOf(item, owner.activeDen))
+ .map(item => ({def: item.def, version: item.version, ...dens.spotOf(item, owner.activeDen)}));
- // lays the account's den in use out as `layout` says, with its own items.
- // with `giveMissing`, items it lacks are added to its inventory first.
- // returns how many of the layout's items could not be placed.
+ // lays the account's den in use out as `layout` says, with its own items
+ // (whether or not they stand in other dens too). with `giveMissing`, items
+ // it lacks are added to its inventory first. returns how many of the
+ // layout's items could not be placed.
const applyLayout = (session, layout, giveMissing) => {
const {account} = session;
- for (const item of account.denItems.filter(candidate => candidate.den === account.activeDen)) {
- item.placed = false;
- item.x = item.y = item.flip = 0;
+ for (const item of account.denItems.filter(candidate => dens.spotOf(candidate, account.activeDen))) {
+ delete item.spots[account.activeDen];
}
const used = new Set();
let missing = 0;
for (const spot of layout) {
- let item = account.denItems.find(candidate => !used.has(candidate) && !candidate.placed
+ let item = account.denItems.find(candidate => !used.has(candidate)
&& candidate.def === spot.def && candidate.version === spot.version);
if (!item && giveMissing && account.denItems.length < MAX_DEN_ITEMS && defpacks.denItemIds().includes(spot.def)) {
item = dens.giveDenItem(account, spot.def, spot.version);
@@ -191,7 +191,8 @@ module.exports = ({findOnline, players, watchers, sendItemList, blocks, setHideB
continue;
}
used.add(item);
- Object.assign(item, {placed: true, den: account.activeDen, x: spot.x, y: spot.y, flip: spot.flip});
+ item.spots = item.spots || {};
+ item.spots[account.activeDen] = {cat: spot.cat || 1, x: spot.x, y: spot.y, flip: spot.flip};
}
accounts.save();
dens.sendDenItems(session);
diff --git a/lib/defpacks.js b/lib/defpacks.js
index 3d1749e..ceeabbc 100644
--- a/lib/defpacks.js
+++ b/lib/defpacks.js
@@ -19,6 +19,19 @@ const DEF_DEN_ROOM = 1040;
const DEF_DIAMOND = 1054;
const DEF_PET = 1046;
const DEF_AVATAR_CUSTOM = 1057;
+// custom animals whose def has no pattern (patternRefId 0): their patterns
+// were only in the generic list the official server sent. these are the
+// pattern items locked to a special animal (bLockAvatarFlags) made after
+// the last def that names its own, in release order; 2121 starts with the
+// raccoon's overrideColorLayer2. a list of 0 made the avatar editor throw
+// (#1009 in AvatarEditor.setCustomPatternColorIdx) and never open.
+const CUSTOM_PATTERNS = new Map([
+ [8, [1963, 1964, 1965, 1966]], // Legendary Eagle
+ [9, [1976]], // Fearsome Falcon
+ [10, [1981]], // Royal Red Panda
+ [11, [2073]], // Frolicking Fox
+ [12, [2121]], // Rainbow Raccoon
+]);
const DEF_ACHIEVEMENTS = 1042;
const DEF_PARTY = 1047;
const DEF_CURRENCY_EXCHANGE = 1051;
@@ -398,7 +411,8 @@ const init = async () => {
customAvatarDefs = new Map((await load(DEF_AVATAR_CUSTOM)).map(def => [Number(def.id), def]));
for (const def of await load(DEF_AVATAR_CUSTOM)) {
const listId = Number(def.patternListRefId);
- patternLists.set(listId, [...(patternLists.get(listId) || []), Number(def.patternRefId)]);
+ const patterns = Number(def.patternRefId) ? [Number(def.patternRefId)] : CUSTOM_PATTERNS.get(Number(def.id)) || [];
+ patternLists.set(listId, [...(patternLists.get(listId) || []), ...patterns]);
}
roomDefsById = new Map((await load(DEF_ROOM)).map(def => [Number(def.id), def]));
// typeCat 4 is music (the jukebox tracks; also what a hosted party plays)
@@ -487,6 +501,11 @@ module.exports = {
extraMusicIds: () => extraMusic.ids,
roomDefById: id => roomDefsById.get(Number(id)),
patternList: listId => patternLists.get(Number(listId)),
+ // the pattern a custom animal starts with
+ customPattern: id => {
+ const def = customAvatarDefs.get(Number(id));
+ return def ? (patternLists.get(Number(def.patternListRefId)) || [0])[0] : 0;
+ },
avatarTypes: () => [...avatarDefs.keys()],
// first non-member land animal, falling back to whatever the pack lists
// first.
diff --git a/lib/dens.js b/lib/dens.js
index def728f..ddd50c8 100644
--- a/lib/dens.js
+++ b/lib/dens.js
@@ -30,7 +30,10 @@ const canEnter = (owner, visitor) => owner === visitor || owner.denPrivacy === D
|| (owner.denPrivacy === DEN_BUDDIES_ONLY && owner.buddies.includes(visitor.username.toLowerCase()));
const RECYCLE_FRACTION = 0.3; // matches recyclePercentage sent at login
const FIELDS_PER_SAVED_ITEM = 17;
-const REF_DEN_ITEM = "0"; // "1" would be a pet placed in the den
+const REF_DEN_ITEM = "0";
+const REF_PET = "1";
+const PET_CATEGORY = 1; // DenItem.getInWorldId for pets (sort category 99)
+const MAX_CATEGORY = 1000;
const CURRENCY_DIAMONDS = 3;
// mannequins: den items (special type 4) that stand as an animal in clothes
@@ -88,28 +91,54 @@ const readMannequin = (account, fields) => {
};
};
-// DenXtCommManager.denItemsResponse: [activeDenIdx, count, ?, (invIdx, defId,
-// placed, version, approved, imageId, creatorDbId, creatorUuid, [mannequin],
-// denStoreInvId)...]. the three after "approved" are a masterpiece's
+// where an item stands: `spots` has a place for each den it is in, by the
+// den's inventory id ({cat, x, y, flip}), so one item can be in several dens
+// at once. the client is only ever told about the den in use.
+const spotOf = (item, den) => (item.spots ? item.spots[den] : undefined);
+const isPlaced = item => Boolean(item.spots) && Object.keys(item.spots).length > 0;
+const itemsInDen = account => account.denItems.filter(item => spotOf(item, account.activeDen));
+
+// the pets standing in the owner's den in use: `inDen` is {den, x, y, flip}.
+const petsInDen = account => account.pets.filter(pet => pet.inDen && pet.inDen.den === account.activeDen);
+
+// DenXtCommManager.denItemsResponse: [activeDenIdx, count, petCount, (invIdx,
+// defId, placed, version, approved, imageId, creatorDbId, creatorUuid,
+// [mannequin], denStoreInvId)..., petInvIdx...]. "placed" is the category the
+// den editor gave the item (DenItem.getInWorldId) in the den in use, 0 when
+// it is not placed there. the three after "approved" are a masterpiece's
// (lib/masterpieces.js); one not approved yet the client keeps out of dens,
// trades and the recycler.
const sendDenItems = session => {
const {account} = session;
const {denItems} = account;
- session.sendXt("di", -1, account.activeDen, denItems.length, 0,
- ...denItems.flatMap(item => [item.inv, item.def, item.placed ? 1 : 0, item.version, masterpieces.itemApproved(item), ...masterpieces.itemFields(item),
- ...mannequinOwnFields(account, item), 0]));
+ const pets = petsInDen(account);
+ session.sendXt("di", -1, account.activeDen, denItems.length, pets.length,
+ ...denItems.flatMap(item => {
+ const spot = spotOf(item, account.activeDen);
+ return [item.inv, item.def, spot ? spot.cat || 1 : 0, item.version, masterpieces.itemApproved(item), ...masterpieces.itemFields(item),
+ ...mannequinOwnFields(account, item), 0];
+ }),
+ ...pets.map(pet => pet.inv));
};
// DenXtCommManager.denStateResponse: [itemCount, petCount, forceReload,
// (invIdx, defId, placed, x, y, version, flipped, userNameLink, imageId,
-// creatorDbId, creatorUuid, [mannequin], ?)...]. forceReload makes the client finish a
-// pending room change, so it is set when the den has just been entered.
+// creatorDbId, creatorUuid, [mannequin], ?)..., (invIdx, lBits, uBits, eBits,
+// category, x, y, flipped, createdTs, personality, toy, food, name)...].
+// forceReload makes the client finish a pending room change, so it is set
+// when the den has just been entered.
const sendDenState = (session, room, forceReload = true) => {
- const placed = room.denOwner.denItems.filter(item => item.placed && item.den === room.denOwner.activeDen && masterpieces.itemApproved(item));
- session.sendXt("ds", room.id, placed.length, 0, forceReload ? 1 : 0,
- ...placed.flatMap(item => [item.inv, item.def, 1, item.x, item.y, item.version, item.flip, "", ...masterpieces.itemFields(item),
- ...mannequinShownFields(room.denOwner, item), 0]));
+ const owner = room.denOwner;
+ const placed = itemsInDen(owner).filter(item => masterpieces.itemApproved(item));
+ const pets = petsInDen(owner);
+ session.sendXt("ds", room.id, placed.length, pets.length, forceReload ? 1 : 0,
+ ...placed.flatMap(item => {
+ const spot = spotOf(item, owner.activeDen);
+ return [item.inv, item.def, 1, spot.x, spot.y, item.version, spot.flip, "", ...masterpieces.itemFields(item),
+ ...mannequinShownFields(owner, item), 0];
+ }),
+ ...pets.flatMap(pet => [pet.inv, pet.lBits, pet.uBits, pet.eBits, PET_CATEGORY, pet.inDen.x, pet.inDen.y, pet.inDen.flip,
+ pet.createdAt, pet.personality || 0, pet.toy || 0, pet.food || 0, pet.name]));
};
// adds a den item to an account; used by purchases, prizes and the item
@@ -118,7 +147,7 @@ const giveDenItem = (account, defId, version = 0) => {
if (!hasRoom(account, "denItems")) {
return null;
}
- const item = {inv: account.nextInv++, def: Number(defId), version: Number(version) || 0, placed: false, den: account.activeDen, x: 0, y: 0, flip: 0};
+ const item = {inv: account.nextInv++, def: Number(defId), version: Number(version) || 0, spots: {}};
account.denItems.push(item);
accounts.save();
return item;
@@ -128,13 +157,15 @@ const giveDenItem = (account, defId, version = 0) => {
// on the screens of everyone inside it (DenXtCommManager.denEmptyResponse).
const clearDen = (owner, findOnline) => {
// kept so that "!den undo" can put it back (lib/commands.js).
- const placed = owner.denItems.filter(item => item.placed && item.den === owner.activeDen);
+ const placed = itemsInDen(owner);
if (placed.length) {
- owner.denUndo = {den: owner.activeDen, items: placed.map(item => ({def: item.def, version: item.version, x: item.x, y: item.y, flip: item.flip}))};
+ owner.denUndo = {den: owner.activeDen, items: placed.map(item => ({def: item.def, version: item.version, ...spotOf(item, owner.activeDen)}))};
}
- for (const item of owner.denItems.filter(candidate => candidate.den === owner.activeDen)) {
- item.placed = false;
- item.x = item.y = item.flip = 0;
+ for (const item of placed) {
+ delete item.spots[owner.activeDen];
+ }
+ for (const pet of petsInDen(owner)) {
+ delete pet.inDen;
}
accounts.save();
const ownerSession = findOnline(owner.username);
@@ -234,6 +265,39 @@ const handlers = ({others, findOnline}) => {
sendDenItems(session);
};
+ // den rooms recycled from the den switcher (DenSwitch.removeDen): never the
+ // den in use, nor slot 0. what stood in one goes back to the inventory,
+ // and a den bought for gems gives back the share den items do. the reply
+ // is the same as for items.
+ const recycleDens = (session, invList) => {
+ const {account} = session;
+ const recycled = [];
+ for (const invIdx of new Set(String(invList).split(",", MAX_DENS).map(Number))) {
+ const den = account.dens.find(candidate => candidate.inv === invIdx);
+ if (!den || den.inv === 0 || den.inv === account.activeDen || account.dens.length <= 1) {
+ continue;
+ }
+ account.dens.splice(account.dens.indexOf(den), 1);
+ for (const item of account.denItems.filter(candidate => spotOf(candidate, den.inv))) {
+ delete item.spots[den.inv];
+ }
+ for (const pet of account.pets.filter(candidate => candidate.inDen && candidate.inDen.den === den.inv)) {
+ delete pet.inDen;
+ }
+ const refund = Math.floor(Number((defpacks.denRoomDef(den.def) || {}).cost || 0) * RECYCLE_FRACTION);
+ account.currency.gems += refund;
+ achievements.currencyChanged(account, "gems", refund);
+ recycled.push(den.inv);
+ }
+ accounts.save();
+ session.sendXt("dr", -1, recycled.length, account.currency.gems, ...recycled);
+ // the switcher empties the slot itself; the items that come back need
+ // the inventory's list.
+ if (recycled.length) {
+ sendDenItems(session);
+ }
+ };
+
return {
di(session) {
sendDenItems(session);
@@ -289,9 +353,12 @@ const handlers = ({others, findOnline}) => {
sendDenItems(session);
},
- // DenXtCommManager.requestDenStateChange: [count, (refType, invIdx, placed,
- // x, y, flipped, userNameLink, 10 mannequin fields)...]. the reply
- // (DenEditor.onDenSaveSet) lists the inventory ids that were applied.
+ // DenXtCommManager.requestDenStateChange: [count, (refType, invIdx,
+ // category, x, y, flipped, userNameLink, 10 mannequin fields)...]. the
+ // category is DenItem.getInWorldId: 1 furniture, toys, plants and pets,
+ // 2 wall items, 3 music, the room's denCatId floors and wallpapers; 0 not
+ // placed. the reply (DenEditor.onDenSaveSet) lists the inventory ids
+ // that were applied.
ds(session, roomId, params) {
const {account} = session;
const count = Number(params[0]);
@@ -302,18 +369,40 @@ const handlers = ({others, findOnline}) => {
const applied = [];
const byInv = new Map(account.denItems.map(candidate => [candidate.inv, candidate]));
const mannequins = account.denItems.filter(candidate => candidate.mannequin);
+ const activePet = activeAvatar(account).petInvId;
for (let i = 0; i < count; i++) {
- const [refType, invIdx, placed, x, y, flip, , ...outfit] = params.slice(1 + i * FIELDS_PER_SAVED_ITEM, 1 + (i + 1) * FIELDS_PER_SAVED_ITEM);
- const item = byInv.get(Number(invIdx));
- if (refType !== REF_DEN_ITEM || !item || ![x, y, flip].every(value => Number.isInteger(Number(value)))
- || (placed === "1" && !masterpieces.itemApproved(item))) {
+ const [refType, invIdx, category, x, y, flip, , ...outfit] = params.slice(1 + i * FIELDS_PER_SAVED_ITEM, 1 + (i + 1) * FIELDS_PER_SAVED_ITEM);
+ const cat = Number(category);
+ if (![x, y, flip].every(value => Number.isInteger(Number(value))) || !Number.isInteger(cat) || Math.abs(cat) > MAX_CATEGORY) {
continue;
}
- item.placed = placed === "1";
- item.den = account.activeDen;
- item.x = item.placed ? Number(x) : 0;
- item.y = item.placed ? Number(y) : 0;
- item.flip = item.placed ? Number(flip) : 0;
+ const placed = cat !== 0;
+ if (refType === REF_PET) {
+ // the pet that follows its owner about is not put down (DenEditor says so).
+ const pet = account.pets.find(candidate => candidate.inv === Number(invIdx));
+ if (pet && !(placed && pet.inv === activePet)) {
+ if (placed) {
+ pet.inDen = {den: account.activeDen, x: Number(x), y: Number(y), flip: Number(flip)};
+ }
+ else if (pet.inDen && pet.inDen.den === account.activeDen) {
+ delete pet.inDen;
+ }
+ applied.push(pet.inv);
+ }
+ continue;
+ }
+ const item = byInv.get(Number(invIdx));
+ if (refType !== REF_DEN_ITEM || !item || (placed && !masterpieces.itemApproved(item))) {
+ continue;
+ }
+ // only the den in use changes: the item stays wherever else it stands.
+ item.spots = item.spots || {};
+ if (placed) {
+ item.spots[account.activeDen] = {cat, x: Number(x), y: Number(y), flip: Number(flip)};
+ }
+ else {
+ delete item.spots[account.activeDen];
+ }
const mannequin = isMannequin(item) && readMannequin(account, outfit);
if (mannequin) {
// A piece of clothing is on one mannequin at a time.
@@ -344,6 +433,10 @@ const handlers = ({others, findOnline}) => {
// recycleDiCallback) before it lets go of its spinner.
dr(session, roomId, [kind, invList]) {
const {account} = session;
+ if (kind === "-1") {
+ recycleDens(session, invList);
+ return;
+ }
const recycled = [];
for (const invIdx of kind === "0" ? new Set(String(invList).split(",", MAX_RECYCLED_AT_ONCE).map(Number)) : []) {
const index = account.denItems.findIndex(item => item.inv === invIdx);
@@ -396,6 +489,8 @@ const handlers = ({others, findOnline}) => {
accounts.save();
const avatar = activeAvatar(account);
session.sendXt("dc", -1, den.def, avatar.perUserAvId, avatar.petInvId);
+ // what is free and what is placed differs from den to den.
+ sendDenItems(session);
if (inOwnDen(session)) {
const {room} = session;
Object.assign(room, denRoom(account));
@@ -431,4 +526,4 @@ const handlers = ({others, findOnline}) => {
};
};
-module.exports = {handlers, sendDenState, sendDenItems, sendRoomProperties, giveDenItem, clearDen, denRoom, canEnter, DEF_DEN_ROOM};
+module.exports = {handlers, sendDenState, sendDenItems, sendRoomProperties, giveDenItem, clearDen, denRoom, canEnter, spotOf, isPlaced, DEF_DEN_ROOM};
diff --git a/lib/ecards.js b/lib/ecards.js
index 0ac5ef4..2082126 100644
--- a/lib/ecards.js
+++ b/lib/ecards.js
@@ -73,6 +73,14 @@ module.exports = ({findOnline, blocks}) => {
// kept by the name on them.
const senderOf = card => (card.fromId ? accounts.byId(card.fromId) : accounts.byName(card.from));
+ // the card's gift id: for clothing the id of its picture (ECardInbox hands
+ // it to SimpleIcon as an accId, which is the def's layerDefId), for the
+ // rest the def id or the amount.
+ const giftId = gift => {
+ const def = gift.type === TYPE_CLOTHING && defpacks.itemDef(gift.def);
+ return def ? Number(def.layerDefId) : gift.def;
+ };
+
// the 17 fields ECard.init takes, for one card. A secret valentine's
// sender is known here (reports about it reach them) but not sent.
const fields = card => {
@@ -81,7 +89,7 @@ module.exports = ({findOnline, blocks}) => {
const name = card.secret ? "" : senderType === FROM_HQ ? HQ_NAME_STRING : card.hq ? HQ_NAME : card.from;
return [
card.id, name, card.card, card.stamp, card.read ? 1 : 0, card.msg, card.gift ? card.gift.type : TYPE_PLAIN,
- card.gift ? card.gift.def : 0, card.gift ? card.gift.color : 0, card.gift ? card.gift.name : 0,
+ card.gift ? giftId(card.gift) : 0, card.gift ? card.gift.color : 0, card.gift ? card.gift.name : 0,
card.hq || card.secret ? MEMBER : sender ? sender.accountType : 0,
0, // name bar data
0, // secondary type
diff --git a/lib/manage.js b/lib/manage.js
index 67d7f0d..cda4436 100644
--- a/lib/manage.js
+++ b/lib/manage.js
@@ -142,6 +142,8 @@ const profile = (account, from) => {
lastSeen: account.lastSeen || account.lastLogin || null,
online: Boolean(world.findOnline(account.username)),
logins: account.numLogins || 0,
+ playtime: account.playtime,
+ playtimePublic: account.playtimePublic,
animals: account.avatars.length,
animalType: avatar ? avatar.type : null,
items: account.items.length,
@@ -362,6 +364,11 @@ const act = (account, body, req, from, res) => {
accounts.save();
return {ok: bio ? "Saved." : "Removed."};
}
+ // whether their card in the game shows how long they have played.
+ case "playtimePublic":
+ account.playtimePublic = body.on === true;
+ accounts.save();
+ return {ok: account.playtimePublic ? "Others can see your playtime on your card." : "Your playtime is private."};
// their Discord username, for their card in the game. empty takes it off.
case "discord": {
const name = badges.discordName(body.name);
diff --git a/lib/modpanel.js b/lib/modpanel.js
index c293193..7cb2c34 100644
--- a/lib/modpanel.js
+++ b/lib/modpanel.js
@@ -14,6 +14,7 @@ const masterpieces = require("./masterpieces.js");
const modlog = require("./modlog.js");
const reports = require("./reports.js");
const staff = require("./staff.js");
+const stats = require("./stats.js");
const support = require("./support.js");
const totp = require("./totp.js");
const world = require("./world.js");
@@ -28,10 +29,13 @@ const world = require("./world.js");
// cannot sign in at all, and a trusted device is not taken for a code.
// being a moderator gives the account nothing in the game itself.
//
-// what it does not give: addresses, sign-in histories, the server's log,
-// what an account owns, passwords, renaming, deleting, gifts. an address
-// can be banned through its player (the one they last signed in from) and
-// shows here with its end left out. another moderator cannot be acted on.
+// what it does not give: sign-in histories, the server's log, what an
+// account owns, passwords, renaming, deleting, gifts. a moderator may look
+// up which players signed in from an address they already have (a search
+// written down under their name, below), but is shown no others; an
+// address can be banned through its player (the one they last signed in
+// from) and shows here with its end left out. another moderator cannot be
+// acted on.
// everything done here is written down (lib/modlog.js) under the
// moderator's name, for the admin panel.
@@ -46,6 +50,7 @@ const failuresByAddress = limits.limiter(config.failedLoginsPerTenMinutes, TEN_M
const actionsPerTenMinutes = limits.limiter(300, TEN_MINUTES_MS); // per moderator
const sessions = new Map(); // SHA-256 of a session token -> {id: account id, expiry: ms}
+const addressSearched = new Map(); // moderator's account id -> the address they last searched for
const sha256 = text => crypto.createHash("sha256").update(text).digest("hex");
@@ -91,6 +96,7 @@ const playerRow = (account, playing) => {
silenced: world.moderation.silenceRemaining(account),
nameRejected: Boolean(account.nameRejected),
moderator: Boolean(account.moderator),
+ playtime: account.playtime,
bio: account.bio,
discord: account.discord,
};
@@ -230,7 +236,7 @@ const handle = async (req, res, url, from, web) => {
const route = `${req.method} ${url.pathname.replace(/\/$/, "") || "/mod"}`;
if (route === "GET /mod") {
- web.send(res, 200, captcha.withScriptVersion(await fs.promises.readFile(path.join(config.publicDir, "mod.html"))), "text/html; charset=utf-8");
+ web.send(res, 200, captcha.withScriptVersion(await stats.withView(await fs.promises.readFile(path.join(config.publicDir, "mod.html")))), "text/html; charset=utf-8");
return;
}
if (req.method === "POST" && !limits.originAllowed(req)) {
@@ -333,8 +339,30 @@ const handle = async (req, res, url, from, web) => {
paintings: masterpieces.list(masterpieces.PENDING).length});
return;
- case "GET /mod/api/players":
- reply(200, {players: findPlayers(url.searchParams.get("q"))});
+ case "GET /mod/api/players": {
+ if (url.searchParams.get("by") !== "address") {
+ reply(200, {players: findPlayers(url.searchParams.get("q"))});
+ return;
+ }
+ // by address: only the address typed, which is written down (once
+ // for each address, though the page asks again every few seconds).
+ const query = String(url.searchParams.get("q") || "").trim().toLowerCase();
+ const found = staff.byAddress(query);
+ if (found.error) {
+ reply(400, found);
+ return;
+ }
+ if (addressSearched.get(mod.id) !== query) {
+ addressSearched.set(mod.id, query);
+ modlog.record(mod.username, "searched by address", "", `${query} ยท ${found.players.length} found`);
+ }
+ const online = playing();
+ reply(200, {players: found.players.map(entry => ({...playerRow(accounts.byName(entry.username), online), matchedAt: entry.lastAt}))});
+ return;
+ }
+
+ case "GET /mod/api/stats":
+ reply(200, stats.report(Number(url.searchParams.get("days")), Number(url.searchParams.get("offset"))));
return;
case "GET /mod/api/player": {
diff --git a/lib/names.js b/lib/names.js
index 80e4691..397d76a 100644
--- a/lib/names.js
+++ b/lib/names.js
@@ -12,10 +12,13 @@ const config = require("../config.js");
// the admin panel). the lists are files, read again when they change:
// lib/reserved-names.txt staff-like names
// public/filter/level1.txt the chat filter's first level: slurs, threats
+// lib/sexual-names.txt sexual words, refused anywhere in a name
+// (bar the short ones marked "=", see the file)
// and the names of the Epic Dens, which are how a showcase den is asked for.
const RESERVED_FILE = path.join(__dirname, "reserved-names.txt");
const SLURS_FILE = path.join(config.publicDir, "filter", "level1.txt");
+const SEXUAL_FILE = path.join(__dirname, "sexual-names.txt");
const DIGITS = {0: "o", 1: "i", 3: "e", 4: "a", 5: "s", 7: "t"};
// A word as it is compared: small letters, digits at either end dropped
@@ -28,7 +31,9 @@ const plain = word => word.toLowerCase().replace(/^\d+|\d+$/g, "").replace(/\d/g
const squash = word => word.replace(/(.)\1+/g, "$1");
const stretched = word => /(.)\1\1/.test(word);
-// the entries of a list file: [{text, prefix}], text made plain as above.
+// the entries of a list file: [{text, prefix, word}], text made plain as
+// above. "word" is for a line marked "=": in lib/sexual-names.txt the rest
+// are matched anywhere in a name.
const lists = new Map(); // file -> {mtime, entries}
const read = file => {
let mtime = 0;
@@ -43,7 +48,8 @@ const read = file => {
return kept.entries;
}
const entries = fs.readFileSync(file, "utf8").split(/\r?\n/).map(line => line.trim()).filter(line => line && !line.startsWith("#"))
- .map(line => ({text: line.replace(/\*$/, "").split(/\s+/).map(plain).join(""), prefix: line.endsWith("*")})).filter(entry => entry.text.length >= 2);
+ .map(line => ({text: line.replace(/^=/, "").replace(/\*$/, "").split(/\s+/).map(plain).join(""), prefix: line.endsWith("*"), word: line.startsWith("=")}))
+ .filter(entry => entry.text.length >= 2);
lists.set(file, {mtime, entries});
return entries;
};
@@ -71,7 +77,11 @@ const refused = username => {
const same = (word, entry) => word === entry.text || (entry.prefix && word.startsWith(entry.text))
|| (stretched(word) && (squash(word) === squash(entry.text) || (entry.prefix && squash(word).startsWith(squash(entry.text)))));
const hit = entry => same(whole, entry) || words.some(word => same(word, entry));
- return read(RESERVED_FILE).some(hit) || read(SLURS_FILE).some(hit) || denNames().includes(whole);
+ // anywhere in the name, with a letter drawn out three times or more read
+ // as two and as one ("booooobs"; "Bobbby" is not "boob").
+ const drawnOut = [whole, whole.replace(/(.)\1{2,}/g, "$1$1"), whole.replace(/(.)\1{2,}/g, "$1")];
+ const inside = entry => (entry.word ? hit(entry) : drawnOut.some(form => form.includes(entry.text)));
+ return read(RESERVED_FILE).some(hit) || read(SLURS_FILE).some(hit) || read(SEXUAL_FILE).some(inside) || denNames().includes(whole);
};
module.exports = {refused, plain};
diff --git a/lib/panel.js b/lib/panel.js
index 95c6afa..1d769a8 100644
--- a/lib/panel.js
+++ b/lib/panel.js
@@ -19,6 +19,7 @@ const modpanel = require("./modpanel.js");
const erase = require("./erase.js");
const reports = require("./reports.js");
const sales = require("./sales.js");
+const stats = require("./stats.js");
const staff = require("./staff.js");
const support = require("./support.js");
const totp = require("./totp.js");
@@ -140,6 +141,8 @@ const accountRow = (account, playing) => {
badges: account.badges,
featuresOff: accounts.FEATURES.filter(name => !accounts.featureOn(account, name)),
logins: account.numLogins,
+ playtime: account.playtime,
+ playtimePublic: account.playtimePublic,
online: playing.has(account.username),
room: playing.get(account.username) || null,
// seconds left, -1 for permanent, 0 for not banned
@@ -563,7 +566,7 @@ const handle = async (req, res, url, from, web) => {
const route = `${req.method} ${url.pathname.replace(/\/$/, "") || "/admin"}`;
if (route === "GET /admin") {
- web.send(res, 200, await fs.promises.readFile(path.join(config.publicDir, "admin.html")), "text/html; charset=utf-8");
+ web.send(res, 200, await stats.withView(await fs.promises.readFile(path.join(config.publicDir, "admin.html"))), "text/html; charset=utf-8");
return;
}
if (req.method === "POST" && !sameOrigin(req)) {
@@ -646,6 +649,18 @@ const handle = async (req, res, url, from, web) => {
return;
}
+ // the graphs (lib/stats.js): the last `days` days, by the viewer's clock.
+ case "GET /admin/api/stats":
+ reply(200, stats.report(Number(url.searchParams.get("days")), Number(url.searchParams.get("offset"))));
+ return;
+
+ // who signed in from an address, or from addresses starting so.
+ case "GET /admin/api/address-search": {
+ const found = staff.byAddress(url.searchParams.get("q"));
+ reply(found.error ? 400 : 200, found);
+ return;
+ }
+
case "GET /admin/api/logs": {
const lines = log.recent(Number(url.searchParams.get("after")) || 0, (url.searchParams.get("filter") || "").slice(0, 100));
reply(200, {lines, newest: log.count()});
diff --git a/lib/sexual-names.txt b/lib/sexual-names.txt
new file mode 100644
index 0000000..eff33ed
--- /dev/null
+++ b/lib/sexual-names.txt
@@ -0,0 +1,59 @@
+porn
+boob
+dick
+penis
+vagina
+pussy
+clit
+cunt
+dildo
+vibrator
+hentai
+horny
+slut
+whore
+milf
+blowjob
+handjob
+orgasm
+orgy
+fetish
+bdsm
+nsfw
+onlyfans
+nude
+naked
+nipple
+erotic
+semen
+sperm
+jizz
+titty
+titties
+tits
+boner
+sexy
+ejaculat
+masturbat
+condom
+genital
+testicle
+scrotum
+=sex*
+=cock
+=cocks
+=cum*
+=anal
+=anus
+=ass
+=asses
+=butt
+=butts
+=xxx
+=thot
+=tit
+=rape*
+=rapist
+=pedo*
+=loli
+=shota
diff --git a/lib/staff.js b/lib/staff.js
index 5094518..eec6784 100644
--- a/lib/staff.js
+++ b/lib/staff.js
@@ -25,6 +25,34 @@ const disciplined = () => accounts.all()
.filter(entry => entry.banned !== 0 || entry.silenced !== 0)
.sort((a, b) => a.username.localeCompare(b.username));
+// the accounts that signed in from an address, or from any address that
+// starts with what was typed ("203.0.113." for the lot): from the sign-in
+// histories, which hold the last 90 days (lib/accounts.js). failed tries
+// are left out, being anyone's. returns {error} or {players: [{username,
+// online, addresses: [{address, at}], lastAt}]}, the latest first.
+const MIN_ADDRESS_QUERY = 3;
+const MAX_ADDRESS_FOUND = 100;
+const byAddress = query => {
+ const wanted = String(query || "").trim().toLowerCase().replace(/^::ffff:/, "").slice(0, 60);
+ if (wanted.length < MIN_ADDRESS_QUERY || !/^[0-9a-f.:]+$/.test(wanted) || !/[.:]/.test(wanted)) {
+ return {error: "Type at least the start of an IP address, like 203.0.113."};
+ }
+ const players = [];
+ for (const account of accounts.all()) {
+ const seen = new Map();
+ for (const login of account.logins) {
+ if (login.ok && login.address && login.address.toLowerCase().startsWith(wanted)) {
+ seen.set(login.address, Math.max(seen.get(login.address) || 0, login.at));
+ }
+ }
+ if (seen.size > 0) {
+ const addresses = [...seen].map(([address, at]) => ({address, at})).sort((one, other) => other.at - one.at);
+ players.push({username: account.username, online: Boolean(world.findOnline(account.username)), addresses, lastAt: addresses[0].at});
+ }
+ }
+ return {players: players.sort((one, other) => other.lastAt - one.lastAt).slice(0, MAX_ADDRESS_FOUND)};
+};
+
const ADDRESS_ERRORS = {
not_an_address: "Not an IP address.",
own_address: "That is this machine's own address: with a proxy or a tunnel in front, everyone's.",
@@ -94,4 +122,4 @@ const answerNameRequest = (id, approve) => {
return {ok: `${oldName} is now called ${account.username}. They log in with the new name and the same password.`, username: account.username};
};
-module.exports = {disciplined, banAddress, appealsFor, answerAppeal, answerNameRequest};
+module.exports = {disciplined, byAddress, banAddress, appealsFor, answerAppeal, answerNameRequest};
diff --git a/lib/stats.js b/lib/stats.js
new file mode 100644
index 0000000..a5c0ddb
--- /dev/null
+++ b/lib/stats.js
@@ -0,0 +1,209 @@
+"use strict";
+
+const fs = require("fs");
+const path = require("path");
+const accounts = require("./accounts.js");
+const config = require("../config.js");
+
+// the game's numbers over time, for the graphs on the admin and moderator
+// panels: how many were playing (a sample a minute, written as one row per
+// five minutes with its average and its most), every login to the game, and
+// every stretch of play when it ends. the logins and the stretches name the
+// account, so they go after a year (as the privacy policy says of the
+// records kept about players); the head-counts name nobody and stay.
+
+const DAY_SECONDS = 86400;
+const SAMPLE_MS = 60000;
+const ROW_SECONDS = 300;
+const KEPT_DAYS = 365;
+const RANGES = [1, 7, 30, 90, 365]; // days a graph can cover
+const TOP_PLAYERS = 10;
+
+const SCHEMA = `
+ CREATE TABLE IF NOT EXISTS stats_online (at INTEGER PRIMARY KEY, average REAL NOT NULL, most INTEGER NOT NULL);
+ CREATE TABLE IF NOT EXISTS stats_logins (at INTEGER NOT NULL, account_id INTEGER NOT NULL, first INTEGER NOT NULL);
+ CREATE INDEX IF NOT EXISTS stats_logins_at ON stats_logins (at);
+ CREATE TABLE IF NOT EXISTS stats_sessions (ended INTEGER NOT NULL, account_id INTEGER NOT NULL, seconds INTEGER NOT NULL);
+ CREATE INDEX IF NOT EXISTS stats_sessions_ended ON stats_sessions (ended);
+`;
+
+const now = () => Math.floor(Date.now() / 1000);
+const db = () => accounts.database();
+
+let countOnline = () => 0;
+let row = null; // the five minutes being counted: {at, sum, samples, most}
+
+const writeRow = () => {
+ if (row && row.samples > 0) {
+ db().prepare("INSERT INTO stats_online (at, average, most) VALUES (?, ?, ?) ON CONFLICT(at) DO UPDATE SET average = excluded.average, most = excluded.most")
+ .run(row.at, row.sum / row.samples, row.most);
+ }
+};
+
+const sample = () => {
+ const count = countOnline();
+ const at = Math.floor(now() / ROW_SECONDS) * ROW_SECONDS;
+ if (row && row.at !== at) {
+ writeRow();
+ row = null;
+ }
+ row = row || {at, sum: 0, samples: 0, most: 0};
+ row.sum += count;
+ row.samples++;
+ row.most = Math.max(row.most, count);
+};
+
+const prune = () => {
+ const before = now() - KEPT_DAYS * DAY_SECONDS;
+ db().prepare("DELETE FROM stats_logins WHERE at < ?").run(before);
+ db().prepare("DELETE FROM stats_sessions WHERE ended < ?").run(before);
+};
+
+// `online` counts the players in the game now (lib/world.js).
+const load = online => {
+ db().exec(SCHEMA);
+ countOnline = online;
+ prune();
+ sample();
+ setInterval(() => {
+ try {
+ sample();
+ }
+ catch (err) {
+ console.error(`[stats] could not count: ${err.message}`);
+ }
+ }, SAMPLE_MS).unref();
+ setInterval(prune, DAY_SECONDS * 1000).unref();
+};
+
+// the row being counted is written before the server stops (server.js).
+const flush = () => {
+ try {
+ writeRow();
+ }
+ catch (err) {
+ // the database is closing
+ }
+};
+
+const login = (account, first) => {
+ db().prepare("INSERT INTO stats_logins (at, account_id, first) VALUES (?, ?, ?)").run(now(), account.id, first ? 1 : 0);
+};
+
+const session = (account, seconds) => {
+ if (seconds > 0) {
+ db().prepare("INSERT INTO stats_sessions (ended, account_id, seconds) VALUES (?, ?, ?)").run(now(), account.id, Math.round(seconds));
+ }
+};
+
+// the numbers for the last `days` days, in buckets of an hour (a day or
+// two) or of a day, the days as the viewer's clock has them: `offset` is
+// their minutes ahead of UTC. the hours of the day and the days of the week
+// are theirs too.
+const report = (days, offset) => {
+ days = RANGES.includes(days) ? days : 7;
+ offset = Number.isInteger(offset) && Math.abs(offset) <= 14 * 60 ? offset * 60 : 0;
+ const end = now();
+ const start = end - days * DAY_SECONDS;
+ const size = days <= 2 ? 3600 : DAY_SECONDS;
+ // the bucket a moment falls in, by the viewer's clock.
+ const bucketOf = at => Math.floor((at + offset) / size) * size - offset;
+ const first = bucketOf(start);
+ const buckets = new Map();
+ for (let at = first; at <= end; at += size) {
+ buckets.set(at, {at, average: 0, most: 0, logins: 0, players: 0, newAccounts: 0, samples: 0, sum: 0, who: new Set()});
+ }
+ const hours = Array.from({length: 24}, () => ({sum: 0, samples: 0, logins: 0}));
+ const week = Array.from({length: 7}, () => Array.from({length: 24}, () => ({sum: 0, samples: 0})));
+ const local = at => new Date((at + offset) * 1000);
+
+ let most = {count: 0, at: null};
+ for (const sampled of db().prepare("SELECT at, average, most FROM stats_online WHERE at >= ? ORDER BY at").all(start)) {
+ const bucket = buckets.get(bucketOf(sampled.at));
+ if (bucket) {
+ bucket.sum += sampled.average;
+ bucket.samples++;
+ bucket.most = Math.max(bucket.most, sampled.most);
+ }
+ const when = local(sampled.at);
+ hours[when.getUTCHours()].sum += sampled.average;
+ hours[when.getUTCHours()].samples++;
+ week[when.getUTCDay()][when.getUTCHours()].sum += sampled.average;
+ week[when.getUTCDay()][when.getUTCHours()].samples++;
+ if (sampled.most > most.count) {
+ most = {count: sampled.most, at: sampled.at};
+ }
+ }
+ if (row && row.at >= start && row.most > most.count) {
+ most = {count: row.most, at: row.at};
+ }
+
+ const everyone = new Set();
+ let logins = 0;
+ let firstLogins = 0;
+ for (const entry of db().prepare("SELECT at, account_id, first FROM stats_logins WHERE at >= ?").all(start)) {
+ const bucket = buckets.get(bucketOf(entry.at));
+ if (bucket) {
+ bucket.logins++;
+ bucket.who.add(entry.account_id);
+ }
+ hours[local(entry.at).getUTCHours()].logins++;
+ everyone.add(entry.account_id);
+ logins++;
+ firstLogins += entry.first;
+ }
+
+ const all = accounts.all();
+ let newAccounts = 0;
+ for (const account of all) {
+ if (account.createdAt >= start) {
+ newAccounts++;
+ const bucket = buckets.get(bucketOf(account.createdAt));
+ if (bucket) {
+ bucket.newAccounts++;
+ }
+ }
+ }
+
+ const played = db().prepare("SELECT COUNT(*) AS count, COALESCE(SUM(seconds), 0) AS total FROM stats_sessions WHERE ended >= ?").get(start);
+ const ever = db().prepare("SELECT at, most FROM stats_online ORDER BY most DESC, at DESC LIMIT 1").get();
+
+ return {
+ days,
+ bucketSeconds: size,
+ summary: {
+ online: countOnline(),
+ accounts: all.length,
+ newAccounts,
+ logins,
+ players: everyone.size,
+ firstLogins,
+ peak: most,
+ peakEver: ever && (!row || ever.most >= row.most) ? {count: ever.most, at: ever.at} : row ? {count: row.most, at: row.at} : {count: 0, at: null},
+ sessions: played.count,
+ averageSessionSeconds: played.count ? Math.round(played.total / played.count) : 0,
+ playedSeconds: played.total,
+ },
+ series: [...buckets.values()].map(bucket => ({
+ at: bucket.at,
+ average: bucket.samples ? Math.round(bucket.sum / bucket.samples * 10) / 10 : null,
+ most: bucket.samples ? bucket.most : null,
+ logins: bucket.logins,
+ players: bucket.who.size,
+ newAccounts: bucket.newAccounts,
+ })),
+ hours: hours.map(hour => ({average: hour.samples ? Math.round(hour.sum / hour.samples * 10) / 10 : null, logins: hour.logins})),
+ week: week.map(day => day.map(hour => (hour.samples ? Math.round(hour.sum / hour.samples * 10) / 10 : null))),
+ topPlaytime: all.filter(account => account.playtime > 0).sort((one, other) => other.playtime - one.playtime).slice(0, TOP_PLAYERS)
+ .map(account => ({username: account.username, seconds: account.playtime})),
+ };
+};
+
+// A panel's page with the Stats tab (public/stats-view.html) where it says
+// : the admin and the moderator panels show the same one.
+const withView = async page => {
+ const view = await fs.promises.readFile(path.join(config.publicDir, "stats-view.html"), "utf8");
+ return Buffer.from(String(page).replace("", () => view));
+};
+
+module.exports = {load, flush, login, session, report, withView, RANGES};
diff --git a/lib/trades.js b/lib/trades.js
index 012b46d..a2e5c5e 100644
--- a/lib/trades.js
+++ b/lib/trades.js
@@ -91,7 +91,8 @@ module.exports = ({findOnline, blocks}) => {
return [DONE_CLOTHING, entry.def, entry.inv, entry.color];
}
if (type === TYPE_DEN_ITEM) {
- return [DONE_DEN_ITEM, entry.def, entry.inv, entry.version, "true", ...masterpieces.itemFields(entry)];
+ // the inventory id first here, unlike clothing (TradeManager.displayTradeDone).
+ return [DONE_DEN_ITEM, entry.inv, entry.def, entry.version, "true", ...masterpieces.itemFields(entry)];
}
return [DONE_PET, entry.createdAt, entry.inv, entry.lBits & 0xFF, entry.lBits, entry.uBits, entry.eBits, 0, 0, 0, entry.name];
};
@@ -154,8 +155,11 @@ module.exports = ({findOnline, blocks}) => {
if (type === TYPE_CLOTHING) {
moved.on = [];
}
+ else if (type === TYPE_PET) {
+ delete moved.inDen; // it was standing in the giver's den
+ }
else if (type === TYPE_DEN_ITEM) {
- Object.assign(moved, {placed: false, x: 0, y: 0, flip: 0});
+ moved.spots = {}; // it stood in the giver's dens
delete moved.mannequin; // a mannequin changes hands bare
}
collectionOf(to, type).push(moved);
@@ -346,7 +350,7 @@ module.exports = ({findOnline, blocks}) => {
const offers = {
// what `account` could give: its clothing and den items, by name.
owned: account => [TYPE_CLOTHING, TYPE_DEN_ITEM].flatMap(type => collectionOf(account, type)
- .filter(entry => type !== TYPE_DEN_ITEM || (masterpieces.itemApproved(entry) && !entry.placed))
+ .filter(entry => type !== TYPE_DEN_ITEM || (masterpieces.itemApproved(entry) && Object.keys(entry.spots || {}).length === 0))
.map(entry => ({type, inv: entry.inv, name: nameOf(type, entry)})))
.sort((one, other) => one.name.localeCompare(other.name)),
diff --git a/lib/world.js b/lib/world.js
index 120913a..4c334dc 100644
--- a/lib/world.js
+++ b/lib/world.js
@@ -32,6 +32,7 @@ const tradeHandlers = require("./trades.js");
const stubHandlers = require("./stubs.js");
const wallModule = require("./walls.js");
const worldItems = require("./worlditems.js");
+const stats = require("./stats.js");
const {CURRENCIES, DIAMOND_TYPES, activeAvatar, avatarById, activePet, equippedBits, wornItems, lastSeenField} = require("./player.js");
// game logic behind the socket. field orders below mirror the client's
@@ -86,6 +87,9 @@ const USER_VAR_DEN_TUTORIAL = 379;
const USER_VAR_TRADE_TUTORIAL = 129;
const TUTORIALS_ALL_SEEN = 65535;
const BIT_FLAG_VARS = [USER_VAR_DEN_TUTORIAL, USER_VAR_TRADE_TUTORIAL];
+// the settings menu's switches, a bit each (gui.MySettings): the client sends
+// the bit's number and 1 to set it or 0 to clear it. unset is -1, every bit clear.
+const USER_VAR_SETTINGS = 363;
const GEM_BONUS_NEVER_DUE = 65535;
// pets the pet picker must not offer (PetCreator.onNotViewablePetDefsLoaded); none here.
const GENERIC_LIST_HIDDEN_PETS = 574;
@@ -276,7 +280,11 @@ const login = (session, msg) => {
leaveWorld(existing);
}
session.account = account;
+ accounts.hold(account);
account.numLogins++;
+ session.playingSince = Date.now();
+ session.playStarted = Date.now();
+ stats.login(account, account.numLogins === 1);
accounts.recordLogin(account, "game", session.address);
account.lastLogin = Math.floor(Date.now() / 1000);
session.recentChat = [];
@@ -440,6 +448,27 @@ const sendUserVars = session => {
const findOnline = username => online.get(String(username).toLowerCase());
+// a custom colour (lib/colours.js) for these four RGB values, made if it is
+// new and the account has not made its day's worth; everyone online is told
+// of a new one before anybody can be given it, and `asker` (a session) of an
+// old one. returns what colours.allocate does.
+const makeColour = (account, rgbs, asker = null) => {
+ const today = Math.floor(Date.now() / 86400000);
+ const made = account.coloursMade && account.coloursMade.day === today ? account.coloursMade.count : 0;
+ const entry = colours.allocate(rgbs, made < config.customColoursPerDay);
+ if (!entry || entry.full) {
+ return entry;
+ }
+ if (entry.created) {
+ account.coloursMade = {day: today, count: made + 1};
+ accounts.save();
+ }
+ for (const recipient of entry.created ? online.values() : asker ? [asker] : []) {
+ recipient.sendXt("xcc", -1, 1, entry.id, ...entry.rgbs);
+ }
+ return entry;
+};
+
// the account's chat filter, for its game to apply: [chosen, level, mode, own words].
const sendFilter = session => {
const {filter} = session.account;
@@ -478,23 +507,9 @@ const handlers = {
// A colour somebody made before is anybody's to use; a new one counts
// against the day's allowance of whoever asks (config.customColoursPerDay).
xcc(session, roomId, params) {
- const {account} = session;
- const today = Math.floor(Date.now() / 86400000);
- const made = account.coloursMade && account.coloursMade.day === today ? account.coloursMade.count : 0;
- const entry = colours.allocate(params.slice(0, 4).map(Number), made < config.customColoursPerDay);
- if (!entry) {
- return;
- }
- if (entry.full) {
+ const entry = makeColour(session.account, params.slice(0, 4).map(Number), session);
+ if (entry && entry.full) {
tell(session, "No more new colours today. Colours made before can still be used.");
- return;
- }
- if (entry.created) {
- account.coloursMade = {day: today, count: made + 1};
- accounts.save();
- }
- for (const recipient of entry.created ? online.values() : [session]) {
- recipient.sendXt("xcc", -1, 1, entry.id, ...entry.rgbs);
}
},
@@ -714,7 +729,7 @@ const handlers = {
// AchievementXtCommManager.requestSetUserVar: [varId, value, ?]. the reply
// (setUserVarResponse) is [varId, value, newAchievementCount].
- zs(session, roomId, [id, value]) {
+ zs(session, roomId, [id, value, set]) {
if (!/^\d{1,4}$/.test(id) || !Number.isFinite(Number(value))) {
return;
}
@@ -731,6 +746,14 @@ const handlers = {
else if (BIT_FLAG_VARS.includes(Number(id))) {
vars[id] = TUTORIALS_ALL_SEEN;
}
+ else if (Number(id) === USER_VAR_SETTINGS) {
+ const bit = Number(value);
+ if (!Number.isInteger(bit) || bit < 0 || bit > 30) {
+ return;
+ }
+ const bits = Math.max(0, Number(vars[id]) || 0);
+ vars[id] = set === "0" ? bits & ~(1 << bit) : bits | (1 << bit);
+ }
else if (achievements.counts(id)) {
// A var that achievements count in: the games report "one more" as 1
// and a best score as the score, and the official server knew which
@@ -818,7 +841,7 @@ const handlers = {
// the icons after the name, and their bio, for the Bio tab
// (lib/badges.js).
session.sendXt("xbn", -1, account.username, moderation.banRemaining(account), account.createdAt,
- account.discord, badges.cardField(account), account.bio);
+ account.discord, badges.cardField(account), cardBio(account));
}
},
@@ -931,6 +954,46 @@ const leaveRoom = session => {
}
};
+// the Bio tab's words: the bio, under the time played when the player
+// shows it (their account page). the card makes the words smaller to fit.
+const playedText = seconds => {
+ const hours = Math.floor(seconds / 3600);
+ if (hours >= 1) {
+ return `Played ${hours.toLocaleString("en-US")} hour${hours === 1 ? "" : "s"}`;
+ }
+ const minutes = Math.floor(seconds / 60);
+ return `Played ${minutes} minute${minutes === 1 ? "" : "s"}`;
+};
+const cardBio = account => {
+ if (!account.playtimePublic) {
+ return account.bio;
+ }
+ const session = online.get(account.username.toLowerCase());
+ if (session) {
+ countPlaytime(session);
+ }
+ return account.bio ? `${playedText(account.playtime)}\n\n${account.bio}` : playedText(account.playtime);
+};
+
+// the time since it was last counted, added to the account's playtime.
+const countPlaytime = session => {
+ if (session.account && session.playingSince) {
+ const elapsed = Date.now() - session.playingSince;
+ session.account.playtime += Math.floor(elapsed / 1000);
+ session.playingSince = Date.now() - (elapsed % 1000);
+ }
+};
+// counted every minute too, so that a server that stops without warning
+// loses no more than that, and what others see is never far behind.
+setInterval(() => {
+ for (const session of online.values()) {
+ countPlaytime(session);
+ }
+ if (online.size > 0) {
+ accounts.save();
+ }
+}, 60000).unref();
+
const leaveWorld = session => {
minigames.leave(session);
trades.forget(session);
@@ -938,6 +1001,9 @@ const leaveWorld = session => {
if (session.account && online.get(session.account.username.toLowerCase()) === session) {
online.delete(session.account.username.toLowerCase());
session.account.lastSeen = Math.floor(Date.now() / 1000);
+ countPlaytime(session);
+ stats.session(session.account, (Date.now() - session.playStarted) / 1000);
+ accounts.release(session.account);
accounts.save();
buddies.announce(session.account);
}
@@ -1023,7 +1089,8 @@ const enterRoom = (session, name, base, displayName, shardId, props = {}) => {
if (room && room === session.room) {
return;
}
- if (room && room.sessions.size >= config.maxUsersPerRoom) {
+ // moderators (marked so in the admin panel) are let into a full room.
+ if (room && room.sessions.size >= config.maxUsersPerRoom && !session.account.moderator) {
joinFailed(session, "This room is currently full");
return;
}
@@ -1151,6 +1218,11 @@ const joinRoom = (session, requested) => {
// reply says; a starting room in the flashvars it does not honour).
if (!session.arrived) {
session.arrived = true;
+ // the client asks for its buddy list only when a window wants it
+ // (BuddyList.requestBuddyListIfNeeded), and draws every name tag as a
+ // non-buddy's until then: it is sent ahead of the first room, as the
+ // client takes it unasked (BuddyManager.buddyListResponseHandler).
+ handlers.bl(session);
const {startInDen, startRoom, username} = session.account;
const den = startInDen ? username : /^den/i.test(startRoom || "") ? startRoom.slice(3) : null;
if (den !== null && accounts.byName(den)) {
@@ -1317,6 +1389,7 @@ module.exports = {
close: leaveWorld,
findOnline,
+ makeColour,
sendItemList,
setTheme,
// offers left on the account page (lib/trades.js); `refresh` shows a
@@ -1447,7 +1520,7 @@ module.exports = {
continue;
}
changed.add(account);
- if (held.some(item => item.placed)) {
+ if (held.some(dens.isPlaced)) {
shownIn.push(rooms.get(`den${account.username}`));
}
account.denItems = account.denItems.filter(item => item.image !== painting.id);
diff --git a/public/account.html b/public/account.html
index c15eb80..5b4e4a7 100644
--- a/public/account.html
+++ b/public/account.html
@@ -338,6 +338,16 @@
+
+ Playtime
+
+
+
Show on my cardAt the top of the Bio tab, for anyone who opens your card in the game.
+
+
+
+
+
Discord
@@ -610,6 +620,7 @@
[account.online ? "Playing now" : account.lastSeen ? when(account.lastSeen) : "Not played yet", "Last seen"],
[when(account.createdAt), "Created"],
[account.logins.toLocaleString(), "Logins"],
+ [played(account.playtime), "Playtime"],
[`${account.animals}${ANIMALS[account.animalType] ? ` ยท ${ANIMALS[account.animalType]} in use` : ""}`, "Animals"],
[account.pets.toLocaleString(), "Pets"],
[account.items.toLocaleString(), "Clothing"],
@@ -638,6 +649,12 @@
return row;
}));
+ $("playtime-text").textContent = `You have played for ${played(account.playtime)}.`;
+ $("playtime-public").textContent = account.playtimePublic ? "Public" : "Private";
+ $("playtime-public").setAttribute("aria-pressed", String(account.playtimePublic));
+ $("playtime-public").setAttribute("aria-label", `Show playtime on my card: ${account.playtimePublic ? "public" : "private"}`);
+ $("playtime-public").disabled = false;
+
if (document.activeElement !== $("bio-text")) {
$("bio-text").value = account.bio;
}
@@ -1148,6 +1165,26 @@
});
$("forget-devices").addEventListener("click", () => act({action: "forgetDevices"}, "two-step-status"));
+ // time played, in the largest units that say it: "3 days 4 hours".
+ const played = seconds => {
+ const days = Math.floor(seconds / 86400);
+ const hours = Math.floor(seconds % 86400 / 3600);
+ const minutes = Math.floor(seconds % 3600 / 60);
+ const unit = (count, name) => `${count.toLocaleString()} ${name}${count === 1 ? "" : "s"}`;
+ if (days > 0) {
+ return hours > 0 ? `${unit(days, "day")} ${unit(hours, "hour")}` : unit(days, "day");
+ }
+ if (hours > 0) {
+ return minutes > 0 ? `${unit(hours, "hour")} ${unit(minutes, "minute")}` : unit(hours, "hour");
+ }
+ return unit(minutes, "minute");
+ };
+ $("playtime-public").addEventListener("click", async () => {
+ $("playtime-public").disabled = true;
+ await act({action: "playtimePublic", on: !account.playtimePublic}, "playtime-status");
+ $("playtime-public").disabled = false;
+ });
+
const bioCount = () => {
$("bio-count").textContent = `${[...$("bio-text").value.trim()].length} / ${account ? account.bioLimit : 200}`;
};
diff --git a/public/admin.html b/public/admin.html
index 22916b6..7b4fd99 100644
--- a/public/admin.html
+++ b/public/admin.html
@@ -245,6 +245,7 @@