Compare commits

...
6 Commits
Author SHA1 Message Date
Snipzil 422719dade feat(minigames): implement buddy game bubbles
Introduce a bubble system that allows players to signal availability for
specific buddy games. Other players in the same room can click the
bubble to initiate a game. The implementation handles bubble visibility
for new arrivals and ensures bubbles are cleared when players leave
rooms or start other activities.
2026-10-18 00:43:12 -04:00
Snipzil bb532a78bb Merge branch 'main' of https://github.com/burrow-dev/burrow-server 2026-10-18 00:04:41 -04:00
Snipzil 3c2053f434 fix(avatar): prevent player displacement when sitting or sleeping
Replace AvatarManager.checkIfAnimatingOnTopOf with P-code to fix an
issue where players were pushed off others within 100 pixels. This
also bypasses decompilation errors in the original class loops.
2026-10-18 00:04:23 -04:00
Burrowdev b551a587a9 feat: custom pictures setting, to hide the pictures players give items
A "Custom pictures" row in the game's settings menu, as Blocked players:
shown by default; hidden, every custom item is drawn with its base item's
art (icons, worn, placed in dens, Jam-A-Grams). Kept in user var 9006 (1 for
hidden), which the server stores like the other settings. buildVersion 62.
2026-10-18 06:22:17 +03:00
Burrowdev 6db96325dd fix: two worlds by default again
PR #5 made one world the default (AJ_WORLDS unset), which undid 31cbd87 on prod. Back to two; the tests still ask for one.
2026-10-18 05:53:23 +03:00
Burrowdev 408b7d4864 feat: owner, moderator and verified name tag badges seen by everyone
The game shows a name tag's badge to buddies only, except the News Crew
camera. AvatarWorldView now shows the Owner, Moderator and Verified badges
(def ids 63, 64, 76) to everyone too. ajclient.swf rebuilt with
tools/build-client.sh; buildVersion 61, so clients fetch it (PR #5's client
changes went out under 60 and may still be cached).
2026-10-18 05:44:09 +03:00
12 changed files with 257 additions and 17 deletions

No files matched your search

+5 -5
View File
@@ -132,7 +132,9 @@ module.exports = {
// 41: the game's text says "Burrow" where it said Animal Jam.
// 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 || "60",
// 61: the Owner, Moderator and Verified name tag badges seen by everyone.
// 62: "Custom pictures" in the settings menu, to hide players' item pictures.
buildVersion: env.AJ_BUILD_VERSION || "62",
// what the official CDN is asked for; not ours to change.
upstreamBuildVersion: "3",
@@ -273,11 +275,9 @@ module.exports = {
// can switch in the settings menu (gui.ServerSelector). the game names
// world N after the Nth name of its own list (551 Aldan, 552 Congo...,
// generic list 16), so the names here are only for the panels and logs.
// AJ_WORLDS: how many. A local server starts with one shared world so two
// players in the same land can always see one another; set AJ_WORLDS=2 or
// more to opt into separate copies of every land.
// AJ_WORLDS: how many (the tests' is one).
shards: ["Aldan", "Congo", "Draa", "Grande", "Kama", "Nile", "Pecos", "Ramu", "Tigris", "Zambezi"]
.slice(0, Math.min(10, Math.max(1, Number(env.AJ_WORLDS) || 1))).map((name, i) => ({id: i + 1, name})),
.slice(0, Math.min(10, Math.max(1, Number(env.AJ_WORLDS) || 2))).map((name, i) => ({id: i + 1, name})),
maxUsersPerRoom: 40,
// everything in every shop for nothing (AJ_FREE_SHOPS=1). off unless
// asked for: what the game's shops make of a price of 0 has not been seen.
+3 -1
View File
@@ -33,7 +33,9 @@ const cdn = require("./cdn.js");
// there are no more than a hundred (lib/accounts.js); the admin may give
// it and take it away like any other.
// in the order they are listed and drawn.
// in the order they are listed and drawn. the Verified, Owner and Moderator
// name tags show their badge to everyone, not only to buddies: their def ids
// are in PUBLIC_BADGE_IDS of swf-src/AvatarWorldView.as.
const BADGES = [
// first, so its tick comes straight after the name, as on other sites.
{id: "verified", label: "Verified", tag: {def: 76, media: 20014, bit: 21}},
+94 -5
View File
@@ -103,7 +103,7 @@ function serial() {
let nextGameRoomId = 500000; // well clear of the world's room ids
module.exports = ({tell, leaveRoom, findOnline, blocks}) => {
module.exports = ({tell, leaveRoom, findOnline, blocks, watchers}) => {
// MinigameInfo.init, the 19 fields the "mi" reply carries for a game.
const info = game => [
game.id,
@@ -145,6 +145,65 @@ module.exports = ({tell, leaveRoom, findOnline, blocks}) => {
}
};
// A buddy game's bubble over a player's head, which anyone else in the
// room can click to play them (UserCommXtCommManager.sendCustomPVPMessage:
// a chat line "on|off" of type 12 with the game's id after it). the client
// reads it back as "on|<gameDefId>" or "off", and its sender waits for
// their own before going on. `session.pvpBubble` is the game's id.
const BUBBLE = "12";
const bubbleLine = session => [`on|${session.pvpBubble}`, BUBBLE, 0];
const bubbleSeers = session => watchers(session).filter(other => !blocks.either(other.account, session.account));
// the bubble goes for everyone else. the player's own "off" waits, when
// they are in a game, till they are out of it: it would end the game the
// client has only just set up (MinigameManager.readySelfForPvpGame).
const dropBubble = session => {
if (!session.pvpBubble) {
return;
}
session.pvpBubble = null;
if (session.room) {
for (const other of bubbleSeers(session)) {
other.sendXt("uc", session.room.id, session.id, "off", BUBBLE);
}
}
};
const bubbleOff = session => {
if (session.game) {
session.bubbleOffOwed = true;
}
else if (session.room) {
session.bubbleOffOwed = false;
session.sendXt("uc", session.room.id, session.id, "off", BUBBLE);
}
};
const bubble = (session, word, gameDefId) => {
if (word !== "on") {
dropBubble(session);
bubbleOff(session);
return;
}
const def = games.get(Number(gameDefId));
if (!def || !def.buddy || !Object.hasOwn(buddyGames, def.swf) || !session.room || session.game || session.invite
|| session.invisible || !accounts.featureOn(session.account, "gameInvites")) {
if (session.room && !session.game) {
tell(session, session.invisible ? "Nobody can see you to play with you." : "You cannot ask for a game right now.");
}
dropBubble(session);
bubbleOff(session);
return;
}
session.pvpBubble = def.id;
for (const other of [session, ...bubbleSeers(session)]) {
other.sendXt("uc", session.room.id, session.id, ...bubbleLine(session));
}
};
// a bubble that is up, for a player who has just been shown its owner.
const showBubble = (to, owner) => {
if (owner.pvpBubble && owner.room && to !== owner && !blocks.either(to.account, owner.account)) {
to.sendXt("uc", owner.room.id, owner.id, ...bubbleLine(owner));
}
};
// takes the player out of the game they are in, if any, and out of an
// invitation.
const leave = session => {
@@ -154,6 +213,9 @@ module.exports = ({tell, leaveRoom, findOnline, blocks}) => {
return;
}
session.game = null;
if (session.bubbleOffOwed) {
bubbleOff(session);
}
game.players = game.players.filter(player => player !== session);
if (game.lobby) {
if (game.players.length === 0) {
@@ -208,6 +270,11 @@ module.exports = ({tell, leaveRoom, findOnline, blocks}) => {
// minigamePetMastery) and who is in the game (joinGameResponse).
const seat = (session, game, music) => {
const avatar = activeAvatar(session.account);
// off to a game: a bubble still up goes (and its owner is told after).
if (session.pvpBubble) {
dropBubble(session);
session.bubbleOffOwed = true;
}
session.game = game;
session.sendXt("rj", -1, 1, `game${game.def.id}_${game.roomId}`, game.roomId, game.players.length, game.players.length, 0, 0,
0, 1, 0, 1, game.def.type === IN_ROOM ? 1 : 0, // isPrivate, isGame, isLimbo, isTemp, isSubRoom
@@ -683,13 +750,29 @@ module.exports = ({tell, leaveRoom, findOnline, blocks}) => {
session.invite = target.invite = {def, sender: session, target};
target.sendXt("mp", -1, def.id, 0, session.account.username, 1);
},
// an open challenge to whoever walks up (UserCommXtCommManager.sendCustomPVPMessage); not offered.
mcp() {},
// a click on another player's game bubble (MinigameXtCommManager
// .sendMinigameCustomPvpJoinMsg): [gameDefId, 0, their username]. the
// game starts at once, as an invitation said yes to; a bubble that is
// gone by now is answered as an invitation said no to
// (MinigameManager.pvpResponse), which puts the clicker back as they were.
mcp(session, roomId, [gameDefId, , username]) {
const def = games.get(Number(gameDefId));
const host = findOnline(String(username || ""));
const free = player => player && player.room && !player.game && !player.invite;
if (!def || !host || host === session || host.pvpBubble !== def.id || host.room !== session.room
|| !free(session) || !free(host) || blocks.either(session.account, host.account)
|| !accounts.featureOn(session.account, "gameInvites")) {
session.sendXt("mp", -1, def ? def.id : Number(gameDefId) || 0, 1);
return;
}
startMatch(def, host, session);
},
};
// the HUD's Games window (GameJoinPopup, generic list 341): the playable
// games that have a picture for it, by name.
const library = [...games.values()].filter(game => game.icon && game.ready !== false)
// games that have a picture for it, by name. A buddy game's card picture
// is drawn the same way, and picking one there puts its bubble up.
const library = [...games.values()].filter(game => (game.icon || (game.buddy && game.card)) && game.ready !== false)
.sort((one, other) => one.title.localeCompare(other.title)).map(game => game.id);
// the buddy games' descriptions, sent unasked when a player arrives: a
@@ -704,6 +787,12 @@ module.exports = ({tell, leaveRoom, findOnline, blocks}) => {
handlers,
leave,
greet,
bubble,
showBubble,
// out of the room: nobody there is left to see the bubble.
roomLeft: session => {
session.pvpBubble = null;
},
library: () => library,
// the room a player in a room-replacing game came from, for the panel.
playing: session => (session.game ? session.game.def.title : null),
+7
View File
@@ -436,6 +436,7 @@ const sendAvatarCreate = (to, target) => {
if (target.invisible) {
to.sendXt("xiv", -1, target.id, 1);
}
minigames.showBubble(to, target);
};
// redraws `session`'s animal for everyone else in the room, for changes the
@@ -1190,6 +1191,7 @@ const leaveRoom = session => {
room.sessions.delete(session);
session.room = null;
session.pos = null;
minigames.roomLeft(session);
for (const other of room.sessions) {
// AvatarManager.avatarRemoveResponse
if (sees(other, session)) {
@@ -1629,6 +1631,11 @@ module.exports = {
return;
}
fields[1] = String(Number(fields[1]));
// A buddy game's bubble over the player's head (lib/minigames.js).
if (fields[1] === "12") {
minigames.bubble(session, fields[0], fields[2]);
return;
}
// typed chat shows as "..." over the sender until the server sends
// it back (UserCommXtCommManager.sendChatMessage); everything else
// the sender has already shown themselves.
+18 -4
View File
@@ -579,17 +579,31 @@ package
// the pictures as bitmaps, for wearing: "kind:id" -> {bmp, art, waiting}
private static var _artBitmaps:Object = {};
// "Custom pictures" in the settings menu (gui.ItemWindowToggle): the
// pictures players give their items, shown (the default) or not, when
// every item is drawn with its base's art. user var 9006, 1 for hidden.
public static function customArtOn() : Boolean
{
return settingOf(9006) != 1;
}
// an item's picture version, or null for none or with them hidden
private static function artOf(param1:String, param2:int) : String
{
return customArtOn() ? _customArt[param1 + ":" + param2] : null;
}
// the look a worn item has, or null for one drawn as the game draws it
public static function customArtMode(param1:String, param2:int) : String
{
return _customArt[param1 + ":" + param2] == null ? null : _customArtMode[param1 + ":" + param2];
return artOf(param1,param2) == null ? null : _customArtMode[param1 + ":" + param2];
}
// what makes a painted frame of it different from its base's, for a
// cache key ("" for none)
public static function customArtKey(param1:String, param2:int) : String
{
var _loc3_:String = _customArt[param1 + ":" + param2];
var _loc3_:String = artOf(param1,param2);
return _loc3_ == null ? "" : param2 + ":" + _loc3_ + ":" + _customArtMode[param1 + ":" + param2];
}
@@ -598,7 +612,7 @@ package
public static function customArtBitmap(param1:String, param2:int, param3:Object = null) : BitmapData
{
var _loc4_:String = param1 + ":" + param2;
var _loc5_:String = _customArt[_loc4_];
var _loc5_:String = artOf(param1,param2);
var _loc6_:Object = _artBitmaps[_loc4_];
if(_loc5_ == null)
{
@@ -653,7 +667,7 @@ package
// the picture's address, or null when the item has none.
public static function customArtUrl(param1:String, param2:int) : String
{
var _loc3_:String = _customArt[param1 + ":" + param2];
var _loc3_:String = artOf(param1,param2);
return _loc3_ == null ? null : gMainFrame.clientInfo.websiteURL + "itemart/" + param1 + "/" + param2 + ".png?v=" + encodeURIComponent(_loc3_);
}
@@ -0,0 +1,20 @@
method
name "checkIfAnimatingOnTopOf"
flag HAS_PARAM_NAMES
param QName(PackageNamespace(""),"int")
paramname "userId"
returns QName(PackageNamespace(""),"void")
body
maxstack 1
localcount 2
initscopedepth 0
maxscopedepth 1
code
getlocal0
pushscope
returnvoid
end ; code
end ; body
end ; method
+6 -1
View File
@@ -63,6 +63,11 @@ package avatar
private static const ATTACHMENT_Y_OFFSET:int = -320;
private static const SLIDE_FRAME_TIME:Number = 41.666666666666664;
// name tag badges everyone sees, buddy or not, as the game shows its
// News Crew camera (NameBar.isVIPBadge): the Owner, Moderator and
// Verified badges of lib/badges.js, by their def ids.
private static const PUBLIC_BADGE_IDS:Array = [63,64,76];
private static const GLOW_LAND_DEFAULT_COLOR:int = 5586479;
@@ -2185,7 +2190,7 @@ package avatar
{
_loc2_ = param1;
}
if(BuddyManager.isBuddy(_avatar.userName) || isSelf || _isMember && NameBar.isVIPBadge(_loc2_))
if(BuddyManager.isBuddy(_avatar.userName) || isSelf || _isMember && (NameBar.isVIPBadge(_loc2_) || PUBLIC_BADGE_IDS.indexOf((_loc2_ >> 8 & 0xFF) + 1) != -1))
{
_namebar.setNubType(NameBar.BUDDY);
}
+24
View File
@@ -179,6 +179,9 @@ package gui.itemWindows
case "hideBlocked":
showHideBlocked();
break;
case "customArt":
showCustomArt();
break;
case "wasd":
showWasd();
break;
@@ -457,6 +460,24 @@ package gui.itemWindows
showHideBlocked();
}
// "Custom pictures": the pictures players give their items, or every
// item with its base's art (AJClient.customArtOn). user var 9006.
private function showCustomArt() : void
{
var _loc1_:String = AJClient.customArtOn() ? "Hide" : "Show";
_window.goNowBtn.down.txt.text = _loc1_;
_window.goNowBtn.mouse.mouse.txt.text = _loc1_;
_window.goNowBtn.mouse.up.txt.text = _loc1_;
_window.labelTxtCont.labelTxt.text = AJClient.customArtOn() ? "Custom pictures: shown" : "Custom pictures: hidden";
}
private function setCustomArt(param1:Boolean) : void
{
gMainFrame.userInfo.userVarCache.updateUserVar(9006,param1 ? 0 : 1);
AchievementXtCommManager.requestSetUserVar(9006,param1 ? 0 : 1);
showCustomArt();
}
private function handleMouseDown(param1:MouseEvent) : void
{
var _loc2_:Number = NaN;
@@ -682,6 +703,9 @@ package gui.itemWindows
case "hideBlocked":
setHideBlocked(!blockedAreHidden());
break;
case "customArt":
setCustomArt(!AJClient.customArtOn());
break;
case "wasd":
setWasd(!AJClient.wasdOn());
break;
+5
View File
@@ -220,6 +220,11 @@ package gui
"type":TOGGLE_TYPE_JOIN,
"frame":"hideBlocked",
"iconFrame":"buddyRequest"
},{
// the pictures players give their items (AJClient.customArtOn)
"type":TOGGLE_TYPE_JOIN,
"frame":"customArt",
"iconFrame":"redeemCode"
},{
"type":TOGGLE_TYPE_JOIN,
"frame":"redeemCode",
BIN
View File
Binary file not shown.
+68
View File
@@ -295,6 +295,74 @@ const run = async () => {
b.xt("rl", room, room);
}
// --- game bubbles: Ann puts up Pairs over her head (a chat line of type
// 12), everyone in the room sees it as "on|<game>", and whoever clicks it
// plays her
const bubble = (client, me, word, game) => client.send(`<msg t='sys'><body action='pubMsg' r='${me.roomId}'><txt><![CDATA[${word}%12%${game}]]></txt></body></msg>`);
bubble(a, ann, "on", GAMES.pairs);
for (const client of [a, b, c]) {
assert.deepStrictEqual((await client.untilXt("uc")).slice(1), [ann.roomId, ann.id, "on|93", "12", "0"]);
}
// A game that is not the one in the bubble, or a bubble nobody has up: "no".
c.xt("mcp", cat.roomId, GAMES.ticTacToe, 0, "Ann");
assert.deepStrictEqual((await c.untilXt("mp")).slice(2), ["89", "1"]);
c.xt("mcp", cat.roomId, GAMES.pairs, 0, "Ben");
assert.deepStrictEqual((await c.untilXt("mp")).slice(2), ["93", "1"]);
// Ben clicks it: the game starts for the two of them and the bubble goes
// for Cat. Ann hears her own "off" only once the game is over.
b.xt("mcp", ben.roomId, GAMES.pairs, 0, "Ann");
assert.deepStrictEqual((await c.untilXt("uc")).slice(1), [ann.roomId, ann.id, "off", "12"]);
let pairsRoom;
for (const client of [a, b]) {
pairsRoom = (await client.untilXt("rj"))[4];
assert.deepStrictEqual((await client.untilXt("ms")).slice(1, 5), [pairsRoom, "2", ann.id, ben.id]);
}
// too late for Cat
c.xt("mcp", cat.roomId, GAMES.pairs, 0, "Ann");
assert.deepStrictEqual((await c.untilXt("mp")).slice(2), ["93", "1"]);
// while in it, Ann's client turning the bubble off is not answered yet
bubble(a, ann, "off", 0);
b.xt("rl", pairsRoom, pairsRoom);
a.xt("rl", pairsRoom, pairsRoom);
assert.deepStrictEqual((await a.untilXt("uc")).slice(1), [ann.roomId, ann.id, "off", "12"]);
// put up and taken down again outside a game: answered at once
bubble(a, ann, "on", GAMES.bowling);
assert.deepStrictEqual((await a.untilXt("uc")).slice(3), ["on|98", "12", "0"]);
assert.deepStrictEqual((await c.untilXt("uc")).slice(3), ["on|98", "12", "0"]);
bubble(a, ann, "off", 0);
assert.deepStrictEqual((await a.untilXt("uc")).slice(3), ["off", "12"]);
assert.deepStrictEqual((await c.untilXt("uc")).slice(3), ["off", "12"]);
// not a buddy game: refused, and the client is put back with an "off"
bubble(a, ann, "on", 4);
assert.deepStrictEqual((await a.untilXt("uc")).slice(3), ["off", "12"]);
await b.untilXt("uc"); // the bowling bubble's two lines, which Ben saw as well
await b.untilXt("uc");
// somebody who walks in sees a bubble that is already up, with its owner
bubble(a, ann, "on", GAMES.shellGame);
await a.untilXt("uc");
for (const client of [b, c]) {
await client.untilXt("uc");
}
const reg = await fetch(`${BASE}/api/register`, {method: "POST", headers: {"Content-Type": "application/json"}, body: JSON.stringify({username: "Dee", password: "KettlePass01", avatarType: 1, agreed: true})});
assert.strictEqual(reg.status, 200);
const dee = await arrive("Dee");
let seen;
do {
seen = await dee.client.untilXt("uc");
} while (seen[2] !== ann.id);
assert.deepStrictEqual(seen.slice(3), ["on|92", "12", "0"]);
bubble(a, ann, "off", 0);
await a.untilXt("uc");
dee.client.socket.destroy();
// --- the HUD's Games window lists the buddy games too, Pairs among them
a.xt("gl", ann.roomId, 341);
const gameList = await a.untilXt("gl");
for (const id of Object.values(GAMES)) {
assert.ok(gameList.includes(String(id)), `game ${id} in the Games window`);
}
// --- a player who logs off takes their invitation with them
a.xt("mp", ann.roomId, GAMES.marbles, 0, "Ben");
await b.untilXt("mp");
+7 -1
View File
@@ -18,6 +18,11 @@
# of its methods are replaced as P-code: the tutorial and "what's new" video
# lists return at once when empty, as this server sends them (they threw).
# 3830 and 3832 are those method bodies' places in the untouched client.
#
# avatar.AvatarManager's checkIfAnimatingOnTopOf is replaced as P-code too
# (the class's loops decompile wrong): it pushed a player off another who was
# sitting, sleeping or the like within 100 pixels, so players can sit and
# sleep side by side now. 2394 is that method body's place.
set -e
cd "$(dirname "$(readlink -f "$0")")/.."
out=${1:-swf/ajclient.swf}
@@ -103,5 +108,6 @@ java -cp "tools/ffdec/lib/*" tools/AddClass.java swf/ajclient.before-finder.swf
java -jar tools/ffdec/ffdec-cli.jar -replace "$base" "$out" \
gui.EmoticonUtility swf-src/EmoticonUtility.cinit.pcode 4839 \
gui.BulletinBoard swf-src/BulletinBoard.onTutorialGLReceived.pcode 3830 \
gui.BulletinBoard swf-src/BulletinBoard.onWhatsNewVideosLoaded.pcode 3832 $args | grep -v "^Replac\|EXPERIMENTAL" || true
gui.BulletinBoard swf-src/BulletinBoard.onWhatsNewVideosLoaded.pcode 3832 \
avatar.AvatarManager swf-src/AvatarManager.checkIfAnimatingOnTopOf.pcode 2394 $args | grep -v "^Replac\|EXPERIMENTAL" || true
ls -l "$out"