diff --git a/src/client/graphics/TransformHandler.ts b/src/client/graphics/TransformHandler.ts
index d3aa2a07a..ae4371a6e 100644
--- a/src/client/graphics/TransformHandler.ts
+++ b/src/client/graphics/TransformHandler.ts
@@ -190,7 +190,7 @@ export class TransformHandler {
this.scale /= zoomFactor;
// Clamp the scale to prevent extreme zooming
- this.scale = Math.max(0.5, Math.min(20, this.scale));
+ this.scale = Math.max(0.2, Math.min(20, this.scale));
const canvasRect = this.boundingRect();
const canvasX = event.x - canvasRect.left;
diff --git a/src/client/graphics/layers/EventsDisplay.ts b/src/client/graphics/layers/EventsDisplay.ts
index c6646edea..1cdd1ff7e 100644
--- a/src/client/graphics/layers/EventsDisplay.ts
+++ b/src/client/graphics/layers/EventsDisplay.ts
@@ -379,6 +379,7 @@ export class EventsDisplay extends LitElement implements Layer {
>
${this.events.map(
diff --git a/src/client/graphics/layers/TerritoryLayer.ts b/src/client/graphics/layers/TerritoryLayer.ts
index 68eea6138..890fd2cac 100644
--- a/src/client/graphics/layers/TerritoryLayer.ts
+++ b/src/client/graphics/layers/TerritoryLayer.ts
@@ -66,7 +66,7 @@ export class TerritoryLayer implements Layer {
this.game.updatesSinceLastTick()[GameUpdateType.Unit].forEach((u) => {
const update = u as UnitUpdate;
if (update.unitType == UnitType.DefensePost && update.isActive) {
- const tile = this.game.ref(update.pos.x, update.pos.y);
+ const tile = update.pos;
this.game
.bfs(
tile,
diff --git a/src/core/execution/MIRVExecution.ts b/src/core/execution/MIRVExecution.ts
index b6095ba80..430df2e59 100644
--- a/src/core/execution/MIRVExecution.ts
+++ b/src/core/execution/MIRVExecution.ts
@@ -27,7 +27,7 @@ export class MirvExecution implements Execution {
private nuke: Unit;
private mirvRange = 1500;
- private warheadCount = 500;
+ private warheadCount = 350;
private random: PseudoRandom;
@@ -94,10 +94,10 @@ export class MirvExecution implements Execution {
private separate() {
const dsts: TileRef[] = [this.dst];
- let attempts = 10000;
+ let attempts = 1000;
while (attempts > 0 && dsts.length < this.warheadCount) {
attempts--;
- const potential = this.randomLand(this.dst);
+ const potential = this.randomLand(this.dst, dsts);
if (potential == null) {
continue;
}
@@ -135,9 +135,9 @@ export class MirvExecution implements Execution {
this.nuke.delete(false);
}
- randomLand(ref: TileRef): TileRef | null {
+ randomLand(ref: TileRef, taken: TileRef[]): TileRef | null {
let tries = 0;
- while (tries < 25) {
+ while (tries < 100) {
tries++;
const x = this.random.nextInt(
this.mg.x(ref) - this.mirvRange,
@@ -150,6 +150,7 @@ export class MirvExecution implements Execution {
if (!this.mg.isValidCoord(x, y)) {
continue;
}
+ console.log(`got coord ${x}, ${y}`);
const tile = this.mg.ref(x, y);
if (!this.mg.isLand(tile)) {
continue;
@@ -160,8 +161,14 @@ export class MirvExecution implements Execution {
if (this.mg.owner(tile) != this.targetPlayer) {
continue;
}
+ for (const t of taken) {
+ if (this.mg.manhattanDist(tile, t) < 25) {
+ continue;
+ }
+ }
return tile;
}
+ console.log("could find place giving up");
return null;
}
diff --git a/src/core/execution/NukeExecution.ts b/src/core/execution/NukeExecution.ts
index 2bb387c0c..1dfda2eef 100644
--- a/src/core/execution/NukeExecution.ts
+++ b/src/core/execution/NukeExecution.ts
@@ -104,13 +104,13 @@ export class NukeExecution implements Execution {
let magnitude;
switch (this.type) {
case UnitType.MIRVWarhead:
- magnitude = { inner: 20, outer: 25 };
+ magnitude = { inner: 25, outer: 30 };
break;
case UnitType.AtomBomb:
- magnitude = { inner: 15, outer: 40 };
+ magnitude = { inner: 12, outer: 30 };
break;
case UnitType.HydrogenBomb:
- magnitude = { inner: 120, outer: 140 };
+ magnitude = { inner: 110, outer: 130 };
break;
}
diff --git a/src/core/game/GameUpdates.ts b/src/core/game/GameUpdates.ts
index c7f7faafe..815136884 100644
--- a/src/core/game/GameUpdates.ts
+++ b/src/core/game/GameUpdates.ts
@@ -10,7 +10,7 @@ import {
Tick,
UnitType,
} from "./Game";
-import { TileUpdate } from "./GameMap";
+import { TileRef, TileUpdate } from "./GameMap";
export interface GameUpdateViewData {
tick: number;
@@ -63,8 +63,8 @@ export interface UnitUpdate {
id: number;
ownerID: number;
// TODO: make these tilerefs
- pos: MapPos;
- lastPos: MapPos;
+ pos: TileRef;
+ lastPos: TileRef;
isActive: boolean;
health?: number;
constructionType?: UnitType;
diff --git a/src/core/game/GameView.ts b/src/core/game/GameView.ts
index c62c4b5ad..ba33c03b3 100644
--- a/src/core/game/GameView.ts
+++ b/src/core/game/GameView.ts
@@ -34,7 +34,7 @@ import { DefenseGrid } from "./DefensePostGrid";
export class UnitView {
public _wasUpdated = true;
- public lastPos: MapPos[] = [];
+ public lastPos: TileRef[] = [];
constructor(
private gameView: GameView,
@@ -48,14 +48,14 @@ export class UnitView {
}
lastTiles(): TileRef[] {
- return this.lastPos.map((pos) => this.gameView.ref(pos.x, pos.y));
+ return this.lastPos;
}
lastTile(): TileRef {
if (this.lastPos.length == 0) {
- return this.gameView.ref(this.data.pos.x, this.data.pos.y);
+ return this.data.pos;
}
- return this.gameView.ref(this.lastPos[0].x, this.lastPos[0].y);
+ return this.lastPos[0];
}
update(data: UnitUpdate) {
@@ -75,7 +75,7 @@ export class UnitView {
return this.data.troops;
}
tile(): TileRef {
- return this.gameView.ref(this.data.pos.x, this.data.pos.y);
+ return this.data.pos;
}
owner(): PlayerView {
return this.gameView.playerBySmallID(this.data.ownerID) as PlayerView;
diff --git a/src/core/game/UnitImpl.ts b/src/core/game/UnitImpl.ts
index 5c398ead3..7c3de09a0 100644
--- a/src/core/game/UnitImpl.ts
+++ b/src/core/game/UnitImpl.ts
@@ -35,8 +35,8 @@ export class UnitImpl implements Unit {
troops: this._troops,
ownerID: this._owner.smallID(),
isActive: this._active,
- pos: { x: this.mg.x(this._tile), y: this.mg.y(this._tile) },
- lastPos: { x: this.mg.x(this._lastTile), y: this.mg.y(this._lastTile) },
+ pos: this._tile,
+ lastPos: this._lastTile,
health: this.hasHealth() ? this._health : undefined,
constructionType: this._constructionType,
};
diff --git a/src/server/GameServer.ts b/src/server/GameServer.ts
index ddf0b5b87..1b77e274b 100644
--- a/src/server/GameServer.ts
+++ b/src/server/GameServer.ts
@@ -131,6 +131,11 @@ export class GameServer {
(c) => c.clientID != client.clientID,
);
});
+ client.ws.on("error", (error: Error) => {
+ if ((error as any).code === "WS_ERR_UNEXPECTED_RSV_1") {
+ client.ws.close(1002);
+ }
+ });
// In case a client joined the game late and missed the start message.
if (this._hasStarted) {
diff --git a/src/server/Server.ts b/src/server/Server.ts
index 2e8dddbe3..f1df564bf 100644
--- a/src/server/Server.ts
+++ b/src/server/Server.ts
@@ -183,6 +183,11 @@ wss.on("connection", (ws, req) => {
console.log(`errror handling websocket message: ${error}`);
}
});
+ ws.on("error", (error: Error) => {
+ if ((error as any).code === "WS_ERR_UNEXPECTED_RSV_1") {
+ ws.close(1002);
+ }
+ });
});
function runGame() {