From de826da3c11b2eb96d72aa411c5cd5823a8c993b Mon Sep 17 00:00:00 2001 From: Joseph Manley Date: Fri, 21 Aug 2020 00:48:47 -0400 Subject: [PATCH] Ignore out of bounds --- server/plugin/gamemap/gamemap.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/server/plugin/gamemap/gamemap.go b/server/plugin/gamemap/gamemap.go index 437e284..3e6da2a 100644 --- a/server/plugin/gamemap/gamemap.go +++ b/server/plugin/gamemap/gamemap.go @@ -3,6 +3,7 @@ package gamemap import ( "encoding/json" "fmt" + "math" ) // WorldMap is the data structure used game world @@ -14,7 +15,7 @@ type WorldMap struct { // GetTile method is used to grab a tile value with error checking func (m WorldMap) GetTile(x int, y int) (int, error) { - if x > m.max_x || y > m.max_y { + if x > m.max_x || y > m.max_y || x < 0 || y < 0 { return -1, fmt.Errorf("Map out of bounds error: %d, %d", x, y) } return m.data[x][y], nil