Fix spelling typos and improve code quality (#2186)

## Description:
  This PR fixes several bugs and improves code quality:

- Fix spelling typos: "recieved" → "received" in Transport.ts and
GameServer.ts
  - Fix comment typo: "isn'te" → "isn't" in TerrainLayer.ts
- Improve WebSocket cleanup in Transport.ts leaveGame() by replacing
empty onclose handler with proper
   killExistingSocket() call
- Add console.warn for image decode failures in StructureLayer.ts
instead of silent catch
  - Remove commented dead code in DevConfig.ts

  ## Testing
All 288 tests pass. Development build completes successfully. No
breaking changes.

  ## Files Changed
  - src/client/Transport.ts
  - src/server/GameServer.ts
  - src/client/graphics/layers/TerrainLayer.ts
  - src/client/graphics/layers/StructureLayer.ts
  - src/core/configuration/DevConfig.ts

## Checklist:
- [x] I have added screenshots for all UI updates (N/A - no UI changes)
- [x] I process any text displayed to the user through translateText()
and I've added it to the en.json file (N/A - no user-facing text)
- [x] I have added relevant tests to the test directory (All 288
existing tests pass - no new tests needed for typo fixes)
- [x] I confirm I have thoroughly tested these changes and take full
responsibility for any bugs introduced

  Discord: hiphex_33496

Hiphex

Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
Hiphex
2025-10-14 18:07:49 -04:00
committed by GitHub
parent 5f6b85ebfc
commit fee2f822ed
5 changed files with 8 additions and 11 deletions
+3 -3
View File
@@ -353,7 +353,7 @@ export class Transport {
// TODO: make this a modal
alert(`connection refused: ${event.reason}`);
} else if (event.code !== 1000) {
console.log(`recieved error code ${event.code}, reconnecting`);
console.log(`received error code ${event.code}, reconnecting`);
this.reconnect();
}
};
@@ -390,15 +390,15 @@ export class Transport {
if (this.socket === null) return;
if (this.socket.readyState === WebSocket.OPEN) {
console.log("on stop: leaving game");
this.socket.close();
this.killExistingSocket();
} else {
console.log(
"WebSocket is not open. Current state:",
this.socket.readyState,
);
console.error("attempting reconnect");
this.killExistingSocket();
}
this.socket.onclose = (event: CloseEvent) => {};
}
private onSendAllianceRequest(event: SendAllianceRequestIntentEvent) {
+3 -1
View File
@@ -138,7 +138,9 @@ export class StructureLayer implements Layer {
Promise.all(
Array.from(this.unitIcons.values()).map((img) =>
img.decode?.().catch(() => {}),
img.decode?.().catch((err) => {
console.warn("Failed to decode unit icon image:", err);
}),
),
).finally(() => {
this.game.units().forEach((u) => this.handleUnitRendering(u));
+1 -1
View File
@@ -49,7 +49,7 @@ export class TerrainLayer implements Layer {
this.theme = this.game.config().theme();
this.game.forEachTile((tile) => {
const terrainColor = this.theme.terrainColor(this.game, tile);
// TODO: isn'te tileref and index the same?
// TODO: isn't tileref and index the same?
const index = this.game.y(tile) * this.game.width() + this.game.x(tile);
const offset = index * 4;
this.imageData.data[offset] = terrainColor.rgba.r;
-5
View File
@@ -58,11 +58,6 @@ export class DevConfig extends DefaultConfig {
super(sc, gc, us, isReplay);
}
// numSpawnPhaseTurns(): number {
// return this.gameConfig().gameType == GameType.Singleplayer ? 70 : 100;
// // return 100
// }
unitInfo(type: UnitType): UnitInfo {
const info = super.unitInfo(type);
// eslint-disable-next-line @typescript-eslint/no-unused-vars
+1 -1
View File
@@ -826,7 +826,7 @@ export class GameServer {
const ratio = `${potentialWinner.ips.size}/${activeUniqueIPs.size}`;
this.log.info(
`recieved winner vote ${clientMsg.winner}, ${ratio} votes for this winner`,
`received winner vote ${clientMsg.winner}, ${ratio} votes for this winner`,
{
clientID: client.clientID,
},