--- deliantra/server/random_maps/treasure.C 2008/09/29 09:04:51 1.43
+++ deliantra/server/random_maps/treasure.C 2009/11/29 17:41:07 1.48
@@ -5,18 +5,19 @@
* Copyright (©) 2001,2007 Mark Wedel & Crossfire Development Team
* Copyright (©) 1992,2007 Frank Tore Johansen
*
- * Deliantra is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
+ * 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 GNU General Public License
- * along with this program. If not, see .
+ * 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
*/
@@ -42,6 +43,16 @@
#define NO_PASS_DOORS 0
#define PASS_DOORS 1
+static object *find_closest_monster (maptile *map, int x, int y, random_map_params *RP);
+static object *find_monster_in_room (maptile *map, int x, int y, random_map_params *RP);
+static void find_spot_in_room_recursive (char **layout, int x, int y, random_map_params *RP);
+static void find_spot_in_room (maptile *map, int x, int y, int *kx, int *ky, random_map_params *RP);
+static object *place_chest (int treasureoptions, int x, int y, maptile *map, maptile *style_map, int n_treasures, random_map_params *RP);
+static object **find_doors_in_room (maptile *map, int x, int y, random_map_params *RP);
+static void lock_and_hide_doors (object **doorlist, maptile *map, int opts, random_map_params *RP);
+static void find_enclosed_spot (maptile *map, int *cx, int *cy, random_map_params *RP);
+static object **surround_by_doors (maptile *map, char **layout, int x, int y, int opts);
+
/* a macro to get a strongly centered random distribution,
from 0 to x, centered at x/2 */
static int
@@ -119,7 +130,7 @@
{
if (wall_blocked (map, x, y))
{
- the_key->destroy (true);
+ the_key->destroy ();
return 0;
}
@@ -145,7 +156,7 @@
keyplace (map, x - 1, y - 1, keycode, NO_PASS_DOORS, 1, RP);
}
- the_key->destroy (true);
+ the_key->destroy ();
return 1;
}
}
@@ -324,7 +335,7 @@
/* put a chest into the map, near x and y, with the treasure style
determined (may be null, or may be a treasure list from lib/treasures,
if the global variable "treasurestyle" is set to that treasure list's name */
-object *
+static object *
place_chest (int treasureoptions, int x, int y, maptile *map, maptile *style_map, int n_treasures, random_map_params *RP)
{
object *the_chest = archetype::get (shstr_chest); /* was "chest_2" */
@@ -333,7 +344,7 @@
int i = find_first_free_spot (the_chest, map, x, y); // this call uses the main rng
if (i == -1)
{
- the_chest->destroy (true);
+ the_chest->destroy ();
return NULL;
}
@@ -357,7 +368,7 @@
{ /* use the treasure list */
object *new_treasure = style_map->pick_random_object (rmg_rndm);
- insert_ob_in_ob (arch_to_object (new_treasure->arch), the_chest);
+ insert_ob_in_ob (new_treasure->arch->instance (), the_chest);
}
else
{ /* use the style map */
@@ -411,10 +422,8 @@
return the_chest;
}
-
-/* finds the closest monster and returns him, regardless of doors
- or walls */
-object *
+/* finds the closest monster and returns him, regardless of doors or walls */
+static object *
find_closest_monster (maptile *map, int x, int y, random_map_params *RP)
{
int i;
@@ -442,12 +451,11 @@
/* both find_monster_in_room routines need to have access to this. */
-object *theMonsterToFind;
+static object *theMonsterToFind;
/* a recursive routine which will return a monster, eventually,if there is one.
it does a check-off on the layout, converting 0's to 1's */
-
-object *
+static object *
find_monster_in_room_recursive (char **layout, maptile *map, int x, int y, random_map_params *RP)
{
int i, j;
@@ -493,7 +501,7 @@
/* sets up some data structures: the _recursive form does the
real work. */
-object *
+static object *
find_monster_in_room (maptile *map, int x, int y, random_map_params *RP)
{
Layout layout2 (RP);
@@ -515,14 +523,14 @@
}
/* a datastructure needed by find_spot_in_room and find_spot_in_room_recursive */
-int *room_free_spots_x;
-int *room_free_spots_y;
-int number_of_free_spots_in_room;
+static int *room_free_spots_x;
+static int *room_free_spots_y;
+static int number_of_free_spots_in_room;
/* the workhorse routine, which finds the free spots in a room:
a datastructure of free points is set up, and a position chosen from
that datastructure. */
-void
+static void
find_spot_in_room_recursive (char **layout, int x, int y, random_map_params *RP)
{
int i, j;
@@ -550,7 +558,7 @@
}
/* find a random non-blocked spot in this room to drop a key. */
-void
+static void
find_spot_in_room (maptile *map, int x, int y, int *kx, int *ky, random_map_params *RP)
{
char **layout2;
@@ -593,7 +601,7 @@
/* searches the map for a spot with walls around it. The more
walls the better, but it'll settle for 1 wall, or even 0, but
it'll return 0 if no FREE spots are found.*/
-void
+static void
find_enclosed_spot (maptile *map, int *cx, int *cy, random_map_params *RP)
{
int x, y;
@@ -668,7 +676,7 @@
}
}
-void
+static void
remove_monsters (int x, int y, maptile *map)
{
for (object *tmp = GET_MAP_OB (map, x, y); tmp; )
@@ -676,7 +684,7 @@
object *next = tmp->above;
if (tmp->flag [FLAG_ALIVE])
- tmp->head_ ()->destroy (true);
+ tmp->head_ ()->destroy ();
tmp = next;
}
@@ -685,7 +693,7 @@
/* surrounds the point x,y by doors, so as to enclose something, like
a chest. It only goes as far as the 8 squares surrounding, and
it'll remove any monsters it finds.*/
-object **
+static object **
surround_by_doors (maptile *map, char **layout, int x, int y, int opts)
{
int i;
@@ -725,21 +733,19 @@
return doorlist;
}
-
/* returns the first door in this square, or NULL if there isn't a door. */
-object *
+static object *
door_in_square (maptile *map, int x, int y)
{
- object *tmp;
-
- for (tmp = GET_MAP_OB (map, x, y); tmp != NULL; tmp = tmp->above)
+ for (object *tmp = GET_MAP_OB (map, x, y); tmp; tmp = tmp->above)
if (tmp->type == DOOR || tmp->type == LOCKED_DOOR)
return tmp;
+
return NULL;
}
/* the workhorse routine, which finds the doors in a room */
-void
+static void
find_doors_in_room_recursive (char **layout, maptile *map, int x, int y, object **doorlist, int *ndoors, random_map_params *RP)
{
int i, j;
@@ -784,7 +790,7 @@
}
/* find a random non-blocked spot in this room to drop a key. */
-object **
+static object **
find_doors_in_room (maptile *map, int x, int y, random_map_params *RP)
{
int i, j;
@@ -808,7 +814,7 @@
/* locks and/or hides all the doors in doorlist, or does nothing if
opts doesn't say to lock/hide doors. */
-void
+static void
lock_and_hide_doors (object **doorlist, maptile *map, int opts, random_map_params *RP)
{
object *door;
@@ -826,7 +832,7 @@
new_door->face = door->face;
new_door->x = door->x;
new_door->y = door->y;
- door->destroy (true);
+ door->destroy ();
doorlist[i] = new_door;
insert_ob_in_map (new_door, map, NULL, 0);
new_door->slaying = format ("RMG-%d-%d", (int)rmg_rndm (1000000000), (int)rmg_rndm (1000000000));
@@ -852,7 +858,7 @@
door->face = wallface->face;
- wallface->destroy (true);
+ wallface->destroy ();
}
}
}