From 2ad9c6f302a2993f89bce7d6b02d1237de844122 Mon Sep 17 00:00:00 2001 From: Evan Date: Tue, 14 Oct 2025 21:50:50 -0700 Subject: [PATCH 1/4] bugfix: sending alliance to afk crashes game (#2202) ## Description: Afk players are marked as not friendly, the canSendAllianceRequest was returning true even if already allied because isFriendly was false. This was allowing alliance requests to people we were already allied with. ## Please complete the following: - [x] I have added screenshots for all UI updates - [x] I process any text displayed to the user through translateText() and I've added it to the en.json file - [x] I have added relevant tests to the test directory - [x] I confirm I have thoroughly tested these changes and take full responsibility for any bugs introduced ## Please put your Discord username so you can be contacted if a bug or regression is found: evan --- src/core/game/PlayerImpl.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/core/game/PlayerImpl.ts b/src/core/game/PlayerImpl.ts index d9ba8ba7c72..75a3afcf9f4 100644 --- a/src/core/game/PlayerImpl.ts +++ b/src/core/game/PlayerImpl.ts @@ -390,6 +390,13 @@ export class PlayerImpl implements Player { if (other === this) { return false; } + if (this.isDisconnected() || other.isDisconnected()) { + // Disconnected players are marked as not-friendly even if they are allies, + // so we need to return early if either player is disconnected. + // Otherise we could end up sending an alliance request to someone + // we are already allied with. + return false; + } if (this.isFriendly(other) || !this.isAlive()) { return false; } From f552b006613c2dee52209801fe2875c64923fcc8 Mon Sep 17 00:00:00 2001 From: evanpelle Date: Wed, 15 Oct 2025 09:46:34 -0700 Subject: [PATCH 2/4] bugfix: use FlagSchema to validate flag --- src/server/Privilege.ts | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/server/Privilege.ts b/src/server/Privilege.ts index 402b4c3c7bc..fece2849e0c 100644 --- a/src/server/Privilege.ts +++ b/src/server/Privilege.ts @@ -1,6 +1,7 @@ import { Cosmetics } from "../core/CosmeticSchemas"; import { decodePatternData } from "../core/PatternDecoder"; import { + FlagSchema, PlayerColor, PlayerCosmeticRefs, PlayerCosmetics, @@ -42,10 +43,14 @@ export class PrivilegeCheckerImpl implements PrivilegeChecker { } } if (refs.flag) { - cosmetics.flag = cosmetics.flag = refs.flag.replace( - /[^a-z0-9-_ ()]/gi, - "", - ); + const result = FlagSchema.safeParse(refs.flag); + if (!result.success) { + return { + type: "forbidden", + reason: "invalid flag: " + result.error.message, + }; + } + cosmetics.flag = result.data; } return { type: "allowed", cosmetics }; From fe1d3e7ef5a31eb55d13de57d1b6838f730fb0e8 Mon Sep 17 00:00:00 2001 From: abdallahbahrawi1 Date: Thu, 16 Oct 2025 17:48:23 +0300 Subject: [PATCH 3/4] fix stuck request alliance icon for nations --- src/core/execution/FakeHumanExecution.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/core/execution/FakeHumanExecution.ts b/src/core/execution/FakeHumanExecution.ts index edeab741763..3b8a7e94d81 100644 --- a/src/core/execution/FakeHumanExecution.ts +++ b/src/core/execution/FakeHumanExecution.ts @@ -17,6 +17,7 @@ import { TileRef, euclDistFN } from "../game/GameMap"; import { PseudoRandom } from "../PseudoRandom"; import { GameID } from "../Schemas"; import { boundingBoxTiles, calculateBoundingBox, simpleHash } from "../Util"; +import { AllianceRequestExecution } from "./alliance/AllianceRequestExecution"; import { ConstructionExecution } from "./ConstructionExecution"; import { EmojiExecution } from "./EmojiExecution"; import { structureSpawnTileValue } from "./nation/structureSpawnTileValue"; @@ -221,7 +222,9 @@ export class FakeHumanExecution implements Execution { if (this.random.chance(20)) { const toAlly = this.random.randElement(enemies); if (this.player.canSendAllianceRequest(toAlly)) { - this.player.createAllianceRequest(toAlly); + this.mg.addExecution( + new AllianceRequestExecution(this.player, toAlly.id()), + ); } } From 144920eb53451f2652c1e2860b9b741e368a2ba7 Mon Sep 17 00:00:00 2001 From: VariableVince <24507472+VariableVince@users.noreply.github.com> Date: Fri, 17 Oct 2025 04:49:46 +0200 Subject: [PATCH 4/4] Fix 100% owned in team stats (#2217) ## Description: When a team owns 100% of the land, it would show "1.0e2%" because of toPrecision(2). Fix this by keeping the same precision as for other numbers, but just returning 100 for 100%. It probably wasn't really noticed before since full land ownership doesn't occur much. Chances of 100% in team stats are a bit higher since fallout is now taken into account. Only a picture of the before situation: 100 percent ## Please complete the following: - [x] I have added screenshots for all UI updates - [x] I process any text displayed to the user through translateText() and I've added it to the en.json file - [x] I have added relevant tests to the test directory - [x] I confirm I have thoroughly tested these changes and take full responsibility for any bugs introduced ## Please put your Discord username so you can be contacted if a bug or regression is found: tryout33 --- src/client/graphics/layers/TeamStats.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/client/graphics/layers/TeamStats.ts b/src/client/graphics/layers/TeamStats.ts index ba8e9dbe759..a8503c22984 100644 --- a/src/client/graphics/layers/TeamStats.ts +++ b/src/client/graphics/layers/TeamStats.ts @@ -221,5 +221,6 @@ export class TeamStats extends LitElement implements Layer { function formatPercentage(value: number): string { const perc = value * 100; if (Number.isNaN(perc)) return "0%"; + if (perc === 100) return "100%"; return perc.toPrecision(2) + "%"; }