--- deliantra/server/random_maps/treasure.C 2017/01/29 02:47:05 1.65 +++ deliantra/server/random_maps/treasure.C 2018/11/17 23:40:02 1.67 @@ -1,6 +1,7 @@ /* * This file is part of Deliantra, the Roguelike Realtime MMORPG. * + * Copyright (©) 2017,2018 Marc Alexander Lehmann / the Deliantra team * Copyright (©) 2005,2006,2007,2008,2009,2010,2011,2012,2013,2014,2015,2016 Marc Alexander Lehmann / Robin Redeker / the Deliantra team * Copyright (©) 2001 Mark Wedel & Crossfire Development Team * Copyright (©) 1992 Frank Tore Johansen @@ -116,8 +117,8 @@ // can freeindex ever be < 0? if (freeindex >= 0) { - kx += freearr_x [freeindex]; - ky += freearr_y [freeindex]; + kx += DIRX (freeindex); + ky += DIRY (freeindex); } } } @@ -343,8 +344,8 @@ return NULL; } - int xl = x + freearr_x[i]; - int yl = y + freearr_y[i]; + int xl = x + DIRX (i); + int yl = y + DIRY (i); /* if the placement is blocked, return a fail. */ if (wall_blocked (map, xl, yl)) @@ -427,8 +428,8 @@ { int lx, ly; - lx = x + freearr_x[i]; - ly = y + freearr_y[i]; + lx = x + DIRX (i); + ly = y + DIRY (i); /* boundscheck */ if (lx >= 0 && ly >= 0 && lx < map->width && ly < map->height) /* don't bother searching this square unless the map says life exists. */ @@ -488,7 +489,7 @@ /* now search all the 8 squares around recursively for a monster,in random order */ for (i = rmg_rndm (8), j = 0; j < 8 && !theMonsterToFind; i++, j++) { - theMonsterToFind = find_monster_in_room_recursive (maze, map, x + freearr_x[i % 8 + 1], y + freearr_y[i % 8 + 1]); + theMonsterToFind = find_monster_in_room_recursive (maze, map, x + DIRX (i % 8 + 1), y + DIRY (i % 8 + 1)); if (theMonsterToFind) return theMonsterToFind; } @@ -536,7 +537,7 @@ /* now search all the 8 squares around recursively for free spots,in random order */ for (int i = rmg_rndm (8), j = 0; j < 8 && !theMonsterToFind; i++, j++) - find_spot_in_room_recursive (maze, spots, x + freearr_x[i % 8 + 1], y + freearr_y[i % 8 + 1]); + find_spot_in_room_recursive (maze, spots, x + DIRX (i % 8 + 1), y + DIRY (i % 8 + 1)); } @@ -581,8 +582,8 @@ { int lx, ly, sindex; - lx = x + freearr_x[i]; - ly = y + freearr_y[i]; + lx = x + DIRX (i); + ly = y + DIRY (i); sindex = surround_flag3 (map, lx, ly); /* if it's blocked on 3 sides, it's enclosed */ if (sindex == 7 || sindex == 11 || sindex == 13 || sindex == 14) @@ -599,8 +600,8 @@ { int lx, ly, sindex; - lx = x + freearr_x[i]; - ly = y + freearr_y[i]; + lx = x + DIRX (i); + ly = y + DIRY (i); sindex = surround_flag3 (map, lx, ly); /* if it's blocked on 3 sides, it's enclosed */ if (sindex == 3 || sindex == 5 || sindex == 9 || sindex == 6 || sindex == 10 || sindex == 12) @@ -616,8 +617,8 @@ { int lx, ly, sindex; - lx = x + freearr_x[i]; - ly = y + freearr_y[i]; + lx = x + DIRX (i); + ly = y + DIRY (i); sindex = surround_flag3 (map, lx, ly); /* if it's blocked on 3 sides, it's enclosed */ if (sindex) @@ -632,8 +633,8 @@ if (i != -1) { - *cx = x + freearr_x[i]; - *cy = y + freearr_y[i]; + *cx = x + DIRX (i); + *cy = y + DIRY (i); } else { @@ -684,13 +685,13 @@ /* place doors in all the 8 adjacent unblocked squares. */ for (i = 1; i < 9; i++) { - int x1 = x + freearr_x[i], y1 = y + freearr_y[i]; + int x1 = x + DIRX (i), y1 = y + DIRY (i); if (!wall_blocked (map, x1, y1) && maze[x1][y1] == '>') { /* place a door */ remove_monsters (x1, y1, map); - object *new_door = archetype::get (freearr_x[i] == 0 ? doors[1] : doors[0]); + object *new_door = archetype::get (DIRX (i) == 0 ? doors[1] : doors[0]); map->insert (new_door, x1, y1); doorlist[ndoors_made] = new_door; ndoors_made++; @@ -751,7 +752,7 @@ /* now search all the 8 squares around recursively for free spots,in random order */ for (i = rmg_rndm (8), j = 0; j < 8 && !theMonsterToFind; i++, j++) find_doors_in_room_recursive (maze, map, - x + freearr_x[i % 8 + 1], y + freearr_y[i % 8 + 1], + x + DIRX (i % 8 + 1), y + DIRY (i % 8 + 1), doorlist, ndoors); } }