mirror of
https://github.com/burrow-dev/burrow-server.git
synced 2026-11-18 17:27:50 -05:00
fix(world): replay active actions for late room joins
Remember a standing avatar's valid action and mirror marker, replay it after avatar creation for players entering or reloading a room, and clear it on movement or exit. Add an end-to-end regression test for late join animation sync.
This commit is contained in:
1 parent
08780d7e69
commit
8e7b193621
2 files changed
+40
No files matched your search
@@ -138,6 +138,11 @@ const LANG_ENG = 0;
|
||||
const IDLE_ANIM_LAND = 14;
|
||||
const IDLE_ANIM_OCEAN = 29;
|
||||
const MAX_PATH_POINTS = 12;
|
||||
// Action messages are client-side animation names (":dance:", ":sitNW:",
|
||||
// etc.). Keep the currently playing one only while the avatar is standing
|
||||
// still, so someone who enters the room can see it once their client has
|
||||
// created that avatar.
|
||||
const ACTION_NAME = /^:[A-Za-z][A-Za-z0-9]*:$/;
|
||||
const TYPED_NAME = /^[A-Za-z0-9][A-Za-z0-9 '.-]{0,19}$/; // an animal's or pet's name typed by its owner
|
||||
const MAX_BLOCKED = 1000; // from the account page; the game's own button has no limit
|
||||
const TYPED_CHAT_TYPES = ["0", "9"];
|
||||
@@ -467,6 +472,12 @@ const sendAvatarCreate = (to, target) => {
|
||||
if (target.petPlayerMode) {
|
||||
to.sendXt("uc", room.id, target.id, "on", "13");
|
||||
}
|
||||
// `ac` only creates the avatar. Actions normally travel as live `uc`
|
||||
// type-3 packets, so replay a standing player's current action after `ac`
|
||||
// for a player who has just entered (or reloaded) the room.
|
||||
if (target.activeAction) {
|
||||
to.sendXt("uc", room.id, target.id, target.activeAction.name, "3", target.activeAction.extra);
|
||||
}
|
||||
minigames.showBubble(to, target);
|
||||
};
|
||||
|
||||
@@ -671,6 +682,9 @@ const handlers = {
|
||||
const teleport = params[params.length - 1] === "1" ? 1 : 0;
|
||||
const firstUpdate = !session.pos;
|
||||
session.pos = {x: coords[coords.length - 2], y: coords[coords.length - 1]};
|
||||
// Walking, swimming, or a teleport replaces a looping action on every
|
||||
// client. Do not replay it to somebody entering later.
|
||||
delete session.activeAction;
|
||||
if (!session.greeted) {
|
||||
// the first room has loaded: the client can show a popup now.
|
||||
session.greeted = true;
|
||||
@@ -1302,6 +1316,7 @@ const leaveRoom = session => {
|
||||
room.sessions.delete(session);
|
||||
session.room = null;
|
||||
session.pos = null;
|
||||
delete session.activeAction;
|
||||
minigames.roomLeft(session);
|
||||
for (const other of room.sessions) {
|
||||
// AvatarManager.avatarRemoveResponse
|
||||
@@ -1768,6 +1783,16 @@ module.exports = {
|
||||
}
|
||||
return;
|
||||
}
|
||||
// Type 3 is the action packet. It used to be sent only to people
|
||||
// already in the room, leaving late arrivals with an idle avatar
|
||||
// until the player performed the action again. Save the safe action
|
||||
// name and its mirror marker for the next avatar-create packet.
|
||||
if (fields[1] === "3") {
|
||||
if (!ACTION_NAME.test(fields[0])) {
|
||||
return;
|
||||
}
|
||||
session.activeAction = {name: fields[0], extra: fields[2] || ""};
|
||||
}
|
||||
// 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
|
||||
|
||||
Reference in new issue
Block a user