Skip to content

Comments

New Ai#268

Merged
1brucben merged 2 commits intov0.2.3aifrom
newai3
Feb 23, 2026
Merged

New Ai#268
1brucben merged 2 commits intov0.2.3aifrom
newai3

Conversation

@1brucben
Copy link
Owner

This pull request introduces several new features and improvements related to AI calibration, player filtering, and peace request handling, along with some dependency and UI updates. The most significant changes are the addition of AI calibration support for headless matches, enhanced player filtering to include AI players, and new peace request/reply events in the client transport layer.

AI Calibration Feature

  • Added AICalibrationModal and associated UI logic to allow launching AI-vs-AI calibration matches from the main menu, including support for calibration data in LobbyConfig and JoinLobbyEvent. (src/client/Main.ts, src/client/ClientGameRunner.ts) [1] [2] [3] [4] [5] [6] [7]
  • Introduced CalibrationWorker.ts for running headless calibration matches in a web worker, enabling fast, background AI benchmarking. (src/client/CalibrationWorker.ts)
  • Added ai-profiles.json resource file for specifying multiple AI behavior profiles used in calibration. (resources/ai-profiles.json)

Player Filtering Improvements

  • Updated player filtering logic throughout the client to include PlayerType.AI instead of PlayerType.FakeHuman, affecting statistics and UI components. (src/client/ClientGameRunner.ts, src/client/StatisticsModal.ts) [1] [2] [3] [4] [5]

Peace Request Handling

  • Added new peace request and reply events (SendPeaceReplyIntentEvent) and integrated them into the client transport event bus for improved multiplayer negotiation flows. (src/client/Transport.ts) [1] [2]
  • Updated English language resource with new peace request and reply strings for UI feedback. (resources/lang/en.json)

Dependency and UI Updates

  • Added @swc/core to package.json dependencies for improved build performance. (package.json)
  • Removed unused optional dependencies from package.json. (package.json)

Miscellaneous

  • Removed legacy bomber upgrade mode event and related code, simplifying input handling and transport logic. (src/client/InputHandler.ts, src/client/Transport.ts) [1] [2] [3] [4]
  • Updated tooltip for land roads/hospitals tech to clarify unlocks. (src/client/TechTooltips.ts)

const searchBox = `
<div style="margin-bottom: 8px;">
<input data-demand-filter type="text" placeholder="Filter by country name…"
value="${this.esc(this.demandFilter)}"

Check warning

Code scanning / CodeQL

Incomplete HTML attribute sanitization Medium

Cross-site scripting vulnerability as the output of
this final HTML sanitizer step
may contain double quotes when it reaches this attribute definition.

Copilot Autofix

AI about 14 hours ago

In general, when constructing HTML dynamically and placing untrusted data into HTML attributes, the data must be properly HTML-encoded for the attribute context, including escaping at least &, <, >, and the attribute’s delimiter character (" in this case). The current esc function escapes only &, <, and >, which is adequate for text nodes but insufficient for attributes enclosed in double quotes.

The best fix with minimal functional change is to strengthen the existing esc function so that it also escapes double quotes. All current call sites will continue to work as before, except that any double quotes in the input will now be rendered as &quot;, which is the correct, safe representation in HTML attributes and text. No changes are needed where esc is used; only the sanitizer must be updated.

Concretely, in src/client/graphics/layers/TradeDebugOverlay.ts, modify the esc method at lines 404–406 to add a replacement for ". The method should replace & first, then <, >, and then ", returning a fully sanitized string suitable for use in the attribute contexts shown. No new imports or helper methods are required.

Suggested changeset 1
src/client/graphics/layers/TradeDebugOverlay.ts

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/src/client/graphics/layers/TradeDebugOverlay.ts b/src/client/graphics/layers/TradeDebugOverlay.ts
--- a/src/client/graphics/layers/TradeDebugOverlay.ts
+++ b/src/client/graphics/layers/TradeDebugOverlay.ts
@@ -402,6 +402,10 @@
   }
 
   private esc(s: string): string {
-    return s.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
+    return s
+      .replace(/&/g, "&amp;")
+      .replace(/</g, "&lt;")
+      .replace(/>/g, "&gt;")
+      .replace(/"/g, "&quot;");
   }
 }
EOF
@@ -402,6 +402,10 @@
}

private esc(s: string): string {
return s.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
return s
.replace(/&/g, "&amp;")
.replace(/</g, "&lt;")
.replace(/>/g, "&gt;")
.replace(/"/g, "&quot;");
}
}
Copilot is powered by AI and may make mistakes. Always verify output.
@1brucben 1brucben merged commit 43ef399 into v0.2.3ai Feb 23, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant