--- deliantra/server/random_maps/treasure.C 2010/07/04 22:12:26 1.58 +++ deliantra/server/random_maps/treasure.C 2018/11/17 23:40:02 1.67 @@ -1,31 +1,32 @@ /* * This file is part of Deliantra, the Roguelike Realtime MMORPG. - * - * Copyright (©) 2005,2006,2007,2008,2009,2010 Marc Alexander Lehmann / Robin Redeker / the Deliantra team + * + * 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 - * + * * Deliantra is free software: you can redistribute it and/or modify it under * the terms of the Affero GNU General Public License as published by the * Free Software Foundation, either version 3 of the License, or (at your * option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the Affero GNU General Public License * and the GNU General Public License along with this program. If not, see * . - * + * * The authors can be reached via e-mail to */ /* placing treasure in maps, where appropriate. */ #include -#include +#include #include /* some defines for various options which can be set. */ @@ -69,7 +70,7 @@ return key; } -/* places keys in the map, preferably in something alive. +/* places keys in the map, preferably in something alive. keycode is the key's code, door_flag is either PASS_DOORS or NO_PASS_DOORS. NO_PASS_DOORS won't cross doors or walls to keyplace, PASS_DOORS will. @@ -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); } } } @@ -186,7 +187,7 @@ return GET_MAP_MOVE_BLOCK (m, x, y) & MOVE_WALK; } -/* place treasures in the map, given the +/* place treasures in the map, given the map, (required) maze, (required) treasure style (may be empty or NULL, or "none" to cause no treasure.) @@ -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 = get_archetype (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); } } @@ -793,7 +794,7 @@ { for (i = 0, door = doorlist[0]; doorlist[i]; i++) { - object *new_door = get_archetype (shstr_locked_door1); + object *new_door = archetype::get (shstr_locked_door1); door = doorlist[i]; new_door->face = door->face;