mirror of
https://github.com/djdevin/recflare.git
synced 2026-10-25 23:18:51 -07:00
[match] on 2023 do not room switch
This commit is contained in:
+2
-1
@@ -117,7 +117,8 @@ RECFLARE_DOMAIN=rec.example.com
|
|||||||
# it came through the room list, a club's clubhouse, or a party. Substitution is a single
|
# it came through the room list, a club's clubhouse, or a party. Substitution is a single
|
||||||
# hop (2=3,3=2 swaps the two rooms), a requested subroom is dropped in favour of the
|
# hop (2=3,3=2 swaps the two rooms), a requested subroom is dropped in favour of the
|
||||||
# substitute's default one, and a target that doesn't exist leaves the original room in
|
# substitute's default one, and a target that doesn't exist leaves the original room in
|
||||||
# place. Following a friend or joining a specific instance is unaffected — those join a
|
# place. Only client builds newer than 20230414 are switched; the 2023 client and older
|
||||||
|
# enter the room they asked for. Following a friend or joining a specific instance is unaffected — those join a
|
||||||
# live instance, which is already in whichever room it was created in.
|
# live instance, which is already in whichever room it was created in.
|
||||||
# RECFLARE_ROOM_REDIRECTS=2=MyHub
|
# RECFLARE_ROOM_REDIRECTS=2=MyHub
|
||||||
|
|
||||||
|
|||||||
@@ -112,6 +112,8 @@ substitutes the same as asking by id.
|
|||||||
- **One hop only** — `2=3,3=2` swaps the two rooms rather than looping.
|
- **One hop only** — `2=3,3=2` swaps the two rooms rather than looping.
|
||||||
- **An unresolvable target leaves the original room in place** (logged), so a typo doesn't
|
- **An unresolvable target leaves the original room in place** (logged), so a typo doesn't
|
||||||
make a room unreachable.
|
make a room unreachable.
|
||||||
|
- **Only builds newer than `20230414` are substituted** — a caller on the 2023 client or
|
||||||
|
an older one (or on a token that names no build) enters the room they asked for.
|
||||||
- **Following a friend and joining a specific instance are unaffected** — those enter a
|
- **Following a friend and joining a specific instance are unaffected** — those enter a
|
||||||
live instance, which is already in whichever room it was created in.
|
live instance, which is already in whichever room it was created in.
|
||||||
|
|
||||||
|
|||||||
@@ -1389,6 +1389,10 @@ function roomRedirects(env: Env): Map<number, string> {
|
|||||||
* default subroom. Substitution is a single hop — `2=3,3=2` swaps the two rooms rather
|
* default subroom. Substitution is a single hop — `2=3,3=2` swaps the two rooms rather
|
||||||
* than looping — and an unresolvable target leaves the original room in place, so a
|
* than looping — and an unresolvable target leaves the original room in place, so a
|
||||||
* typo'd knob degrades to "no substitution" instead of a dead hub.
|
* typo'd knob degrades to "no substitution" instead of a dead hub.
|
||||||
|
*
|
||||||
|
* Only builds NEWER than the 2023 client ({@link BUILD_2023}) are substituted. A caller on
|
||||||
|
* that build or an older one — or on a token that names none, which matchmakes as
|
||||||
|
* `GAME_VERSION` (see {@link callerGameVersion}) — enters the room they asked for.
|
||||||
*/
|
*/
|
||||||
async function substituteRoom(
|
async function substituteRoom(
|
||||||
c: Context<App>,
|
c: Context<App>,
|
||||||
@@ -1399,6 +1403,9 @@ async function substituteRoom(
|
|||||||
const to = roomRedirects(c.env).get(fromId)
|
const to = roomRedirects(c.env).get(fromId)
|
||||||
if (to === undefined) return { room, subRoomId }
|
if (to === undefined) return { room, subRoomId }
|
||||||
|
|
||||||
|
const build = buildNumber(await callerGameVersion(c))
|
||||||
|
if (build === null || build <= BUILD_2023) return { room, subRoomId }
|
||||||
|
|
||||||
const toId = Number.parseInt(to, 10)
|
const toId = Number.parseInt(to, 10)
|
||||||
const target = Number.isNaN(toId)
|
const target = Number.isNaN(toId)
|
||||||
? await getRoomByName(c.env.DB, to)
|
? await getRoomByName(c.env.DB, to)
|
||||||
|
|||||||
@@ -1132,12 +1132,14 @@ describe('public endpoints', () => {
|
|||||||
test('ROOM_REDIRECTS switches a matchmake out to another room', async () => {
|
test('ROOM_REDIRECTS switches a matchmake out to another room', async () => {
|
||||||
// `env` is shared by every test in this file, so restore the knob in `finally`.
|
// `env` is shared by every test in this file, so restore the knob in `finally`.
|
||||||
const original = env.ROOM_REDIRECTS
|
const original = env.ROOM_REDIRECTS
|
||||||
const matchmake = async (path: string, player: string) =>
|
// Substitution only applies to builds newer than 20230414, so matchmake as the 2025 one
|
||||||
|
// unless the case says otherwise.
|
||||||
|
const matchmake = async (path: string, player: string, version = '20250718.01') =>
|
||||||
(await (
|
(await (
|
||||||
await exports.default.fetch(`${ORIGIN}${path}`, {
|
await exports.default.fetch(`${ORIGIN}${path}`, {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
...(await bearer(player)),
|
...(await bearer(player, version)),
|
||||||
'Content-Type': 'application/x-www-form-urlencoded',
|
'Content-Type': 'application/x-www-form-urlencoded',
|
||||||
},
|
},
|
||||||
// Private, so each call gets a fresh instance of whatever room it landed in.
|
// Private, so each call gets a fresh instance of whatever room it landed in.
|
||||||
@@ -1174,6 +1176,21 @@ describe('public endpoints', () => {
|
|||||||
roomId: 77,
|
roomId: 77,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// The 2023 build and anything older is never substituted, nor is a token naming no
|
||||||
|
// build (it matchmakes as GAME_VERSION): they enter the room they asked for.
|
||||||
|
for (const [player, version] of [
|
||||||
|
['8808', '20230414'],
|
||||||
|
['8809', '20230414.01'],
|
||||||
|
['8810', '20221117'],
|
||||||
|
]) {
|
||||||
|
expect((await matchmake('/matchmake/room/2', player, version)).roomInstance).toMatchObject(
|
||||||
|
{ roomId: 2, name: '^RecCenter' }
|
||||||
|
)
|
||||||
|
}
|
||||||
|
expect((await matchmake('/matchmake/room/2', '8811', '')).roomInstance).toMatchObject({
|
||||||
|
roomId: 2,
|
||||||
|
})
|
||||||
|
|
||||||
// Targeting by id works the same, and substitution is a single hop: 2 and 77
|
// Targeting by id works the same, and substitution is a single hop: 2 and 77
|
||||||
// swap rather than bouncing between each other.
|
// swap rather than bouncing between each other.
|
||||||
env.ROOM_REDIRECTS = '2=77,77=2'
|
env.ROOM_REDIRECTS = '2=77,77=2'
|
||||||
|
|||||||
Reference in New Issue
Block a user