Skip to content

Commit 5540eff

Browse files
committed
Merge branch 'v26'
2 parents fee2f82 + 349e7ac commit 5540eff

File tree

10 files changed

+32
-9
lines changed

10 files changed

+32
-9
lines changed

resources/lang/en.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -500,7 +500,7 @@
500500
},
501501
"win_modal": {
502502
"support_openfront": "Support OpenFront!",
503-
"territory_pattern": "Purchase a territory pattern to support OpenFront!",
503+
"territory_pattern": "Purchase a territory skin to go ad-free!",
504504
"died": "You died",
505505
"your_team": "Your team won!",
506506
"other_team": "{team} team has won!",

src/client/GutterAds.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ export class GutterAds extends LitElement {
4949
}
5050

5151
public hide(): void {
52+
this.isVisible = false;
5253
console.log("hiding GutterAds");
5354
this.destroyAds();
5455
this.requestUpdate();

src/client/Main.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,13 @@ class Client {
350350
"Sharing this ID will allow others to view your game history and stats.",
351351
);
352352
this.patternsModal.onUserMe(userMeResponse);
353+
const flares = (userMeResponse.player.flares ?? []).filter((flare) =>
354+
flare.startsWith("pattern:"),
355+
);
356+
if (flares.length > 0) {
357+
console.log("Hiding gutter ads because you have patterns");
358+
this.gutterAds.hide();
359+
}
353360
}
354361
};
355362

src/client/Transport.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -496,7 +496,7 @@ export class Transport {
496496
type: "donate_gold",
497497
clientID: this.lobbyConfig.clientID,
498498
recipient: event.recipient.id(),
499-
gold: event.gold,
499+
gold: event.gold ? Number(event.gold) : null,
500500
});
501501
}
502502

src/core/Schemas.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ export const EmbargoIntentSchema = BaseIntentSchema.extend({
278278
export const DonateGoldIntentSchema = BaseIntentSchema.extend({
279279
type: z.literal("donate_gold"),
280280
recipient: ID,
281-
gold: z.bigint().nullable(),
281+
gold: z.number().nullable(),
282282
});
283283

284284
export const DonateTroopIntentSchema = BaseIntentSchema.extend({

src/core/execution/DonateGoldExecution.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,19 @@
11
import { Execution, Game, Gold, Player, PlayerID } from "../game/Game";
2+
import { toInt } from "../Util";
23

34
export class DonateGoldExecution implements Execution {
45
private recipient: Player;
56

67
private active = true;
8+
private gold: Gold;
79

810
constructor(
911
private sender: Player,
1012
private recipientID: PlayerID,
11-
private gold: Gold | null,
12-
) {}
13+
goldNum: number | null,
14+
) {
15+
this.gold = toInt(goldNum ?? 0);
16+
}
1317

1418
init(mg: Game, ticks: number): void {
1519
if (!mg.hasPlayer(this.recipientID)) {

src/core/execution/WarshipExecution.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,11 @@ export class WarshipExecution implements Execution {
5555
this.warship.delete();
5656
return;
5757
}
58+
if (this.warship.owner().isDisconnected()) {
59+
this.warship.delete();
60+
return;
61+
}
62+
5863
const hasPort = this.warship.owner().unitCount(UnitType.Port) > 0;
5964
if (hasPort) {
6065
this.warship.modifyHealth(1);

src/server/MapPlaylist.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,8 @@ export class MapPlaylist {
7979

8080
// Create the default public game config (from your GameManager)
8181
return {
82-
donateGold: false,
83-
donateTroops: false,
82+
donateGold: mode === GameMode.Team,
83+
donateTroops: mode === GameMode.Team,
8484
gameMap: map,
8585
maxPlayers: config.lobbyMaxPlayers(map, mode, playerTeams),
8686
gameType: GameType.Public,

src/server/Privilege.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,12 @@ export class PrivilegeCheckerImpl implements PrivilegeChecker {
4141
return { type: "forbidden", reason: "invalid color: " + e.message };
4242
}
4343
}
44+
if (refs.flag) {
45+
cosmetics.flag = cosmetics.flag = refs.flag.replace(
46+
/[^a-z0-9-_ ()]/gi,
47+
"",
48+
);
49+
}
4450

4551
return { type: "allowed", cosmetics };
4652
}

tests/Donate.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ describe("Donate gold to an ally", () => {
120120
donor.addGold(6000n);
121121
const donorGoldBefore = donor.gold();
122122
const recipientGoldBefore = recipient.gold();
123-
game.addExecution(new DonateGoldExecution(donor, recipientInfo.id, 5000n));
123+
game.addExecution(new DonateGoldExecution(donor, recipientInfo.id, 5000));
124124

125125
for (let i = 0; i < 5; i++) {
126126
game.executeNextTick();
@@ -242,7 +242,7 @@ describe("Donate Gold to a non ally", () => {
242242
const donorGoldBefore = donor.gold();
243243
const recipientGoldBefore = donor.gold();
244244

245-
game.addExecution(new DonateGoldExecution(donor, recipientInfo.id, 5000n));
245+
game.addExecution(new DonateGoldExecution(donor, recipientInfo.id, 5000));
246246
game.executeNextTick();
247247

248248
// Gold should not be donated since they are not allies

0 commit comments

Comments
 (0)