fix bad tile crash (#1237)

## Description:

Sending invalid coords can cause game to crash. Make sure to validate
tile ref.

## 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
- [x] I understand that submitting code with bugs that could have been
caught through manual testing blocks releases and new features for all
contributors

## Please put your Discord username so you can be contacted if a bug or
regression is found:
evan
This commit is contained in:
evanpelle
2025-06-20 09:49:55 -07:00
committed by GitHub
parent 0cd663df02
commit 9ae544595b
11 changed files with 57 additions and 54 deletions
+2 -7
View File
@@ -1,5 +1,4 @@
import { Execution, Game } from "../game/Game";
import { TileRef } from "../game/GameMap";
import { PseudoRandom } from "../PseudoRandom";
import { ClientID, GameID, Intent, Turn } from "../Schemas";
import { simpleHash } from "../Util";
@@ -72,16 +71,12 @@ export class Executor {
this.mg.ref(intent.x, intent.y),
);
case "boat":
let src: TileRef | null = null;
if (intent.srcX !== null && intent.srcY !== null) {
src = this.mg.ref(intent.srcX, intent.srcY);
}
return new TransportShipExecution(
player,
intent.targetID,
this.mg.ref(intent.dstX, intent.dstY),
intent.dst,
intent.troops,
src,
intent.src,
);
case "allianceRequest":
return new AllianceRequestExecution(player, intent.recipient);