mirror of
https://github.com/burrow-dev/burrow-server.git
synced 2026-11-18 17:27:50 -05:00
feat(world): expand events, rewards, and den behavior
Add owner/developer room-effect controls and chat shortcuts, staff movement that bypasses full or locked destinations, in-game moderation entry points, theatre video synchronization, and shared room effects. Restore game and trade popups, reliably award refreshments and game rewards, support pet play outside parties, correct den placement categories, improve den item persistence, and refresh custom-item and masterpiece behavior. Harden room, party, pet, minigame, and item state handling with matching feature and restored-system regression coverage.
This commit is contained in:
1 parent
7dee29010a
commit
5c9b2e0066
11 files changed
+389
-29
No files matched your search
+128
-17
@@ -404,7 +404,7 @@ const sendItemList = (to, target, full, perUserAvId) => {
|
||||
const {account} = target;
|
||||
const avatar = avatarById(account, perUserAvId);
|
||||
const items = full
|
||||
? account.items.flatMap(item => [item.def, item.inv, item.color, equippedBits(item), 0])
|
||||
? account.items.flatMap(item => [item.def, item.inv, item.color, equippedBits(item, account), 0])
|
||||
: wornItems(account, avatar).flatMap(item => [item.def, item.inv, item.color]);
|
||||
const count = full ? account.items.length : wornItems(account, avatar).length;
|
||||
to.sendXt("il", -1, full ? "0" : "1", 0, avatar.perUserAvId, account.username, avatar.eyes, avatar.pattern, count, ...items);
|
||||
@@ -464,6 +464,9 @@ const sendAvatarCreate = (to, target) => {
|
||||
if (target.invisible) {
|
||||
to.sendXt("xiv", -1, target.id, 1);
|
||||
}
|
||||
if (target.petPlayerMode) {
|
||||
to.sendXt("uc", room.id, target.id, "on", "13");
|
||||
}
|
||||
minigames.showBubble(to, target);
|
||||
};
|
||||
|
||||
@@ -538,7 +541,7 @@ const sendUserVars = session => {
|
||||
};
|
||||
|
||||
const findOnline = username => online.get(String(username).toLowerCase());
|
||||
const STAFF_WINDOW_COMMANDS = ["warn", "unwarn", "message", "silence", "kick", "summon", "goto", "warnings"];
|
||||
const STAFF_WINDOW_COMMANDS = ["warn", "unwarn", "message", "silence", "kick", "summon", "goto", "warnings", "reject"];
|
||||
const MAX_STAFF_WINDOW_WORDS = 3; // username, then a reason, hours or the message (each one field)
|
||||
|
||||
// a custom colour (lib/colours.js) for these four RGB values, made if it is
|
||||
@@ -923,6 +926,47 @@ const handlers = {
|
||||
}
|
||||
},
|
||||
|
||||
// The host/event overlay only sends one of these fixed room effects. Its
|
||||
// permission check lives here as well, so a forged client packet cannot
|
||||
// change a room.
|
||||
xrc(session, roomId, [effect]) {
|
||||
const choice = String(effect || "").toLowerCase();
|
||||
if (roles.isActiveStaff(session.account) && roles.can(session.account, "room.effects")
|
||||
&& ["small", "normal", "big", "rainbow", "clear"].includes(choice)) {
|
||||
commands.run(session, `!roomfx ${choice}`);
|
||||
}
|
||||
},
|
||||
|
||||
// The browser host renders the YouTube iframe; the game receives only a
|
||||
// validated video id and keeps it shared by the people in this theatre.
|
||||
xtv(session, roomId, [action, value = ""]) {
|
||||
const {room} = session;
|
||||
// Some theatre maps report an internal room path which has no "theatre"
|
||||
// in it (the visible room title does). Staff permission is the boundary;
|
||||
// restricting by that unreliable path made Play for room silently fail.
|
||||
if (!roles.isActiveStaff(session.account) || !roles.can(session.account, "theater.control") || !room) {
|
||||
return;
|
||||
}
|
||||
let videoId = "";
|
||||
if (action === "play") {
|
||||
const text = String(value).trim();
|
||||
const match = text.match(/^(?:[A-Za-z0-9_-]{11}|(?:https?:\/\/)?(?:www\.)?(?:youtube\.com\/(?:watch\?v=|embed\/|shorts\/)|youtu\.be\/)([A-Za-z0-9_-]{11})(?:[?&#].*)?)$/i);
|
||||
videoId = match ? (match[1] || text) : "";
|
||||
if (!videoId) {
|
||||
session.sendXt("xtl", -1, "Paste a YouTube watch, share, or embed link.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if (action !== "stop") {
|
||||
return;
|
||||
}
|
||||
room.theatreVideo = videoId;
|
||||
for (const viewer of room.sessions) {
|
||||
viewer.sendXt("xtv", room.id, videoId);
|
||||
}
|
||||
modlog.record(session.account.username, videoId ? "played theatre video" : "stopped theatre video", "", room.name);
|
||||
},
|
||||
|
||||
// the patched client's chat box: whether its player is typing, for a
|
||||
// "..." over their animal in everyone else's game (gui.ChatHistory):
|
||||
// xty [1 | 0], passed on as "xty" [.., .., sfsId, 1 | 0]. a client says
|
||||
@@ -1138,10 +1182,31 @@ const itemsTaken = (account, kind, invs, worn) => {
|
||||
}
|
||||
};
|
||||
|
||||
// A dashboard clothing rule can affect several animals and mannequins at
|
||||
// once. Their persisted references have already been removed by
|
||||
// itemcontrol.js; refresh both the owner's full inventory and anyone seeing
|
||||
// their animal or den so an open game cannot keep displaying the old outfit.
|
||||
const wearRulesChanged = (account, mannequinChanged = false) => {
|
||||
const session = findOnline(account.username);
|
||||
if (session) {
|
||||
sendItemList(session, session, true);
|
||||
refreshForOthers(session);
|
||||
if (mannequinChanged) {
|
||||
dens.sendDenItems(session);
|
||||
}
|
||||
}
|
||||
if (mannequinChanged) {
|
||||
const den = rooms.get(`den${account.username}`);
|
||||
for (const visitor of den ? den.sessions : []) {
|
||||
dens.sendDenState(visitor, den, false);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// staff moving a player: `whoName` to the room `toName` is in (summon is
|
||||
// the player to the staff member, goto the staff member to the player). both
|
||||
// online, `toName` in a room. the room's own rules still apply: a full room
|
||||
// or a locked den keeps them out.
|
||||
// online, `toName` in a room. This privileged movement deliberately bypasses
|
||||
// a full room, locked den, or hosted-party block; regular joins do not.
|
||||
// they land where `toName` stands (the patched client's "xgt": [x, y,
|
||||
// "1" same room, teleported now | "0" the spot to spawn on in the next
|
||||
// room], or [] to forget a spot not used). with nobody's spot known yet,
|
||||
@@ -1165,13 +1230,15 @@ const staffMove = (whoName, toName) => {
|
||||
who.sendXt("xgt", -1, ...spot, 1);
|
||||
return {ok: true, room: shown};
|
||||
}
|
||||
if (room.sessions.size >= config.maxUsersPerRoom) {
|
||||
return {error: `${shown} is full.`};
|
||||
}
|
||||
if (spot) {
|
||||
who.sendXt("xgt", -1, ...spot, 0);
|
||||
}
|
||||
// staffMove is only reached through permission-checked commands. The flag
|
||||
// is consumed by enterRoom/joinDen, preserving normal rules for all other
|
||||
// joins.
|
||||
who.staffTravel = true;
|
||||
joinRoom(who, room.name);
|
||||
delete who.staffTravel;
|
||||
if (who.room !== room) {
|
||||
if (spot) {
|
||||
who.sendXt("xgt", -1);
|
||||
@@ -1385,11 +1452,13 @@ const enterRoom = (session, name, base, displayName, shardId, props = {}) => {
|
||||
if (room && room === session.room) {
|
||||
return;
|
||||
}
|
||||
// moderators (marked so in the admin panel) are let into a full room, and
|
||||
// so is a player arriving when every spawn room is full (spawnRoom).
|
||||
// Moderators, a one-use staff teleport, and a player arriving when every
|
||||
// spawn room is full (spawnRoom) may enter a full room.
|
||||
const overflow = session.spawnOverflow;
|
||||
const staffTravel = session.staffTravel === true;
|
||||
session.spawnOverflow = false;
|
||||
if (room && room.sessions.size >= config.maxUsersPerRoom && !roles.isActiveStaff(session.account) && !overflow) {
|
||||
delete session.staffTravel;
|
||||
if (room && room.sessions.size >= config.maxUsersPerRoom && !roles.isActiveStaff(session.account) && !staffTravel && !overflow) {
|
||||
joinFailed(session, "This room is currently full");
|
||||
return;
|
||||
}
|
||||
@@ -1432,6 +1501,9 @@ const enterRoom = (session, name, base, displayName, shardId, props = {}) => {
|
||||
room.customMusicDef,
|
||||
worldId);
|
||||
dens.sendRoomProperties(session, roomAsSeenBy(session, room));
|
||||
if (room.theatreVideo !== undefined) {
|
||||
session.sendXt("xtv", room.id, room.theatreVideo);
|
||||
}
|
||||
|
||||
for (const other of others(session)) {
|
||||
if (other.pos && sees(session, other)) {
|
||||
@@ -1592,7 +1664,7 @@ const joinRoom = (session, requested) => {
|
||||
let shard = config.shards.find(s => s.id === Number(shardText)) || config.shards.find(s => s.id === session.worldId) || config.shards[0];
|
||||
// full there: with "Find Open World" on, the same room in a world that
|
||||
// has space (moderators get into a full room anyway).
|
||||
if (roomFull(`${base}#${shard.id}`) && !session.account.moderator && findOpenWorld(session.account)) {
|
||||
if (roomFull(`${base}#${shard.id}`) && !roles.isActiveStaff(session.account) && findOpenWorld(session.account)) {
|
||||
shard = config.shards.find(other => !roomFull(`${base}#${other.id}`)) || shard;
|
||||
}
|
||||
enterRoom(session, `${base}#${shard.id}`, base, roomInfo.name(base), shard.id);
|
||||
@@ -1614,7 +1686,8 @@ const joinDen = (session, requested) => {
|
||||
joinFailed(session, `Den "${requested}" does not exist`);
|
||||
return;
|
||||
}
|
||||
if (!dens.canEnter(owner, session.account) || blocks.has(owner, session.account)) {
|
||||
const staffTravel = session.staffTravel === true;
|
||||
if ((!dens.canEnter(owner, session.account) || blocks.has(owner, session.account)) && !staffTravel) {
|
||||
joinFailed(session, "This den is locked");
|
||||
return;
|
||||
}
|
||||
@@ -1661,7 +1734,11 @@ module.exports = {
|
||||
case "pubMsg": {
|
||||
// UserCommXtCommManager sends "<text>%<type>[%<extra>]" and reads it
|
||||
// back in userCommChatResponse as [sfsUserId, text, type, extra].
|
||||
if (session.room && session.room.id === msg.roomId) {
|
||||
// An in-room minigame keeps the player in their world room, but its
|
||||
// embedded SWF labels outgoing user messages with the minigame's
|
||||
// temporary sub-room id. Accept that id as well so its attachment
|
||||
// reward can make the normal round trip back to the avatar.
|
||||
if (session.room && (session.room.id === msg.roomId || (session.game && session.game.roomId === Number(msg.roomId)))) {
|
||||
// at most text, type and one extra field, and no essays.
|
||||
const fields = decodeEntities(msg.cdata("txt") || "").split("%").slice(0, 3);
|
||||
if (fields[0].length > config.maxChatLength || (fields[2] || "").length > MAX_CHAT_EXTRA) {
|
||||
@@ -1680,10 +1757,42 @@ module.exports = {
|
||||
minigames.bubble(session, fields[0], fields[2]);
|
||||
return;
|
||||
}
|
||||
// Per-player pet form. It is deliberately a user-communication
|
||||
// message so every client already in the room updates the same
|
||||
// avatar, while the normal pet-out state stays unchanged.
|
||||
if (fields[1] === "13") {
|
||||
const enabled = fields[0] === "on" && Boolean(activePet(session.account));
|
||||
session.petPlayerMode = enabled;
|
||||
for (const other of [session, ...watchers(session)]) {
|
||||
other.sendXt("uc", session.room.id, session.id, enabled ? "on" : "off", "13");
|
||||
}
|
||||
return;
|
||||
}
|
||||
// Attachment messages carry an emoticon *definition* id from the
|
||||
// sender, while the recipient's avatar view needs that definition's
|
||||
// media id. This is the normal path used by den attachments and
|
||||
// the food-machine minigames.
|
||||
if (fields[1] === "4") {
|
||||
const [defId, ...extra] = fields[0].split(",");
|
||||
if (defId === "0") {
|
||||
fields[0] = "0,";
|
||||
}
|
||||
else {
|
||||
const mediaId = defpacks.emoticonMediaId(defId);
|
||||
if (!mediaId) {
|
||||
return;
|
||||
}
|
||||
fields[0] = `${mediaId},${extra.join(",").replace(/[\r\n%,]/g, "").slice(0, 128)}`;
|
||||
}
|
||||
}
|
||||
// typed chat shows as "..." over the sender until the server sends
|
||||
// it back (UserCommXtCommManager.sendChatMessage); everything else
|
||||
// the sender has already shown themselves.
|
||||
const echo = TYPED_CHAT_TYPES.includes(fields[1]);
|
||||
// An attachment is only drawn after the server sends it back. The
|
||||
// local client deliberately does not draw it optimistically, unlike
|
||||
// typed chat and normal emotes.
|
||||
const attachmentEcho = fields[1] === "4";
|
||||
// silenced, or chat switched off on the account page: the line
|
||||
// goes nowhere.
|
||||
if (echo && (moderation.isSilenced(session.account) || !accounts.featureOn(session.account, "chat"))) {
|
||||
@@ -1737,7 +1846,7 @@ module.exports = {
|
||||
// nobody hears a player they have blocked, and with chat switched
|
||||
// off nobody's typed lines arrive at all.
|
||||
// an invisible staff member's emotes and the like reach staff only.
|
||||
for (const recipient of echo ? session.room.sessions : others(session)) {
|
||||
for (const recipient of (echo || attachmentEcho) ? session.room.sessions : others(session)) {
|
||||
if (session.invisible && recipient !== session && !roles.isActiveStaff(recipient.account)) {
|
||||
continue;
|
||||
}
|
||||
@@ -1780,6 +1889,7 @@ module.exports = {
|
||||
findOnline,
|
||||
makeColour,
|
||||
sendItemList,
|
||||
wearRulesChanged,
|
||||
setTheme,
|
||||
// offers left on the account page (lib/trades.js); `refresh` shows a
|
||||
// playing account its inventories as they are now.
|
||||
@@ -1880,10 +1990,11 @@ module.exports = {
|
||||
|
||||
// the panel's Masterpieces page. A painting waiting for review is an
|
||||
// item its maker cannot use yet; approving it tells them so, by a
|
||||
// Jam-A-Gram from Animal Jam HQ and at once if they are playing.
|
||||
approveMasterpiece(id) {
|
||||
// Jam-A-Gram from Animal Jam HQ and at once if they are playing. `by`
|
||||
// is who approved it: a moderator's username, or "admin".
|
||||
approveMasterpiece(id, by) {
|
||||
const maker = masterpieces.creatorOf(id);
|
||||
if (!masterpieces.approve(id)) {
|
||||
if (!masterpieces.approve(id, by)) {
|
||||
return false;
|
||||
}
|
||||
if (maker) {
|
||||
|
||||
Reference in new issue
Block a user