File tree Expand file tree Collapse file tree 1 file changed +6
-2
lines changed
Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Original file line number Diff line number Diff line change @@ -300,8 +300,12 @@ export class GameMapImpl implements GameMap {
300300 ) : Set < TileRef > {
301301 const center = { x : this . x ( tile ) , y : this . y ( tile ) } ;
302302 const tiles : Set < TileRef > = new Set < TileRef > ( ) ;
303- for ( let i = center . x - radius ; i <= center . x + radius ; ++ i ) {
304- for ( let j = center . y - radius ; j <= center . y + radius ; j ++ ) {
303+ const minX = Math . max ( 0 , center . x - radius ) ;
304+ const maxX = Math . min ( this . width_ - 1 , center . x + radius ) ;
305+ const minY = Math . max ( 0 , center . y - radius ) ;
306+ const maxY = Math . min ( this . height_ - 1 , center . y + radius ) ;
307+ for ( let i = minX ; i <= maxX ; ++ i ) {
308+ for ( let j = minY ; j <= maxY ; j ++ ) {
305309 const t = this . ref ( i , j ) ;
306310 const d2 = this . euclideanDistSquared ( tile , t ) ;
307311 if ( d2 > radius * radius ) continue ;
You can’t perform that action at this time.
0 commit comments