diff --git a/src/map.c b/src/map.c
index c9cae463071b113893051a0519414b0eb299d956..c82680f445438db497ab53d056ffd70e46bbe4cd 100644
--- a/src/map.c
+++ b/src/map.c
@@ -50,7 +50,7 @@ void free_map(map m)
 
 void map_delete_grid_all(map m, int x, int y)
 {
-	grid g = m->grids[i + j * m->w];
+	grid g = m->grids[x + y * m->w];
 	while (g)
 	{
 		grid next = g->next;