diff options
| author | Florian Fischer <florian.fischer@muhq.space> | 2023-01-20 03:25:14 +0100 |
|---|---|---|
| committer | Florian Fischer <florian.fischer@muhq.space> | 2023-01-26 22:17:17 +0100 |
| commit | b0625b49ef265ca42df81fcea7fbbd6b4dbf8a5b (patch) | |
| tree | 8492ea7e0b71b777e6b73d7026eeb5443e9931a9 /go/ui/mapView.go | |
| parent | ebff1227019adf923a812513bf1ae3688a8e75ca (diff) | |
| download | muhqs-game-b0625b49ef265ca42df81fcea7fbbd6b4dbf8a5b.tar.gz muhqs-game-b0625b49ef265ca42df81fcea7fbbd6b4dbf8a5b.zip | |
sanity check calculated x and y before using it as slice index
Diffstat (limited to 'go/ui/mapView.go')
| -rw-r--r-- | go/ui/mapView.go | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/go/ui/mapView.go b/go/ui/mapView.go index c292d526..43ea0f01 100644 --- a/go/ui/mapView.go +++ b/go/ui/mapView.go @@ -173,6 +173,10 @@ func (vw *MapView) FindObjectAt(x_px, y_px int) interface{} { x := x_px / TILE_WIDTH y := y_px / TILE_HEIGHT + if x < 0 || y < 0 { + return nil + } + // TODO: detect if a permanent or the containing tile was selected for _, u := range vw.gameState.Permanents { pos := u.GetTile().Position |
