ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/server/build_map.C
(Generate patch)

Comparing deliantra/server/server/build_map.C (file contents):
Revision 1.28 by root, Sun Jul 1 05:00:19 2007 UTC vs.
Revision 1.31 by root, Tue Apr 15 03:16:02 2008 UTC

1/* 1/*
2 * This file is part of Crossfire TRT, the Roguelike Realtime MORPG. 2 * This file is part of Deliantra, the Roguelike Realtime MMORPG.
3 * 3 *
4 * Copyright (©) 2005,2006,2007 Marc Alexander Lehmann / Robin Redeker / the Crossfire TRT team 4 * Copyright (©) 2005,2006,2007 Marc Alexander Lehmann / Robin Redeker / the Deliantra team
5 * Copyright (©) 2001,2007 Mark Wedel & Crossfire Development Team 5 * Copyright (©) 2001,2007 Mark Wedel & Crossfire Development Team
6 * Copyright (©) 1992,2007 Frank Tore Johansen 6 * Copyright (©) 1992,2007 Frank Tore Johansen
7 * 7 *
8 * Crossfire TRT is free software: you can redistribute it and/or modify 8 * Deliantra is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by 9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation, either version 3 of the License, or 10 * the Free Software Foundation, either version 3 of the License, or
11 * (at your option) any later version. 11 * (at your option) any later version.
12 * 12 *
13 * This program is distributed in the hope that it will be useful, 13 * This program is distributed in the hope that it will be useful,
16 * GNU General Public License for more details. 16 * GNU General Public License for more details.
17 * 17 *
18 * You should have received a copy of the GNU General Public License 18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>. 19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 * 20 *
21 * The authors can be reached via e-mail to <crossfire@schmorp.de> 21 * The authors can be reached via e-mail to <support@deliantra.net>
22 */ 22 */
23 23
24#include <global.h> 24#include <global.h>
25#include <living.h> 25#include <living.h>
26#include <spells.h> 26#include <spells.h>
106 int itest = 0; 106 int itest = 0;
107 oblinkpt *obp; 107 oblinkpt *obp;
108 108
109 while (itest++ < 1000) 109 while (itest++ < 1000)
110 { 110 {
111 connected = 1 + rand () % 20000; 111 connected = rndm (0x20000000UL) + 0x60000000UL;
112
112 for (obp = map->buttons; obp && (obp->value != connected); obp = obp->next); 113 for (obp = map->buttons; obp && (obp->value != connected); obp = obp->next)
114 ;
113 115
114 if (!obp) 116 if (!obp)
115 return connected; 117 return connected;
116 } 118 }
117 119
118 return -1; 120 return -1;
119} 121}
120
121 122
122/** 123/**
123 * Helper function for door/button/connected item building. 124 * Helper function for door/button/connected item building.
124 * 125 *
125 * Will search the specified spot for a marking rune. 126 * Will search the specified spot for a marking rune.
180 * Returns the marking rune on the square, for purposes of building connections 181 * Returns the marking rune on the square, for purposes of building connections
181 */ 182 */
182object * 183object *
183get_connection_rune (object *pl, short x, short y) 184get_connection_rune (object *pl, short x, short y)
184{ 185{
185 object *rune;
186
187 rune = GET_MAP_OB (pl->map, x, y); 186 object *rune = GET_MAP_OB (pl->map, x, y);
187
188 while (rune && ((rune->type != SIGN) || (strcmp (rune->arch->archname, "rune_mark")))) 188 while (rune && ((rune->type != SIGN) || (strcmp (rune->arch->archname, "rune_mark"))))
189 rune = rune->above; 189 rune = rune->above;
190
190 return rune; 191 return rune;
191} 192}
192 193
193/** 194/**
194 * Returns the book/scroll on the current square, for purposes of building 195 * Returns the book/scroll on the current square, for purposes of building
195 */ 196 */
196object * 197object *
197get_msg_book (object *pl, short x, short y) 198get_msg_book (object *pl, short x, short y)
198{ 199{
199 object *book;
200
201 book = GET_MAP_OB (pl->map, x, y); 200 object *book = GET_MAP_OB (pl->map, x, y);
201
202 while (book && (book->type != BOOK)) 202 while (book && (book->type != BOOK))
203 book = book->above; 203 book = book->above;
204
204 return book; 205 return book;
205} 206}
206 207
207/** 208/**
208 * Returns first item of type BUILDABLE_WALL. 209 * Returns first item of type BUILDABLE_WALL.
209 */ 210 */
210object * 211object *
211get_wall (maptile *map, int x, int y) 212get_wall (maptile *map, int x, int y)
212{ 213{
213 object *wall;
214
215 wall = GET_MAP_OB (map, x, y); 214 object *wall = GET_MAP_OB (map, x, y);
215
216 while (wall && (BUILDABLE_WALL != wall->type)) 216 while (wall && (BUILDABLE_WALL != wall->type))
217 wall = wall->above; 217 wall = wall->above;
218 218
219 return wall; 219 return wall;
220} 220}
231 * Note: x & y must be valid map coordinates. 231 * Note: x & y must be valid map coordinates.
232 */ 232 */
233void 233void
234fix_walls (maptile *map, int x, int y) 234fix_walls (maptile *map, int x, int y)
235{ 235{
236 object *wall;
237 char archetype[MAX_BUF]; 236 char archetype[MAX_BUF];
238 char *underscore; 237 char *underscore;
239 struct archetype *new_arch; 238 struct archetype *new_arch;
240 239
241
242 /* First, find the wall on that spot */ 240 /* First, find the wall on that spot */
243 wall = get_wall (map, x, y); 241 object *wall = get_wall (map, x, y);
244 if (!wall) 242 if (!wall)
245 /* Nothing -> bail out */ 243 /* Nothing -> bail out */
246 return; 244 return;
247 245
248 /* Find base name */ 246 /* Find base name */
609 if (!arch) 607 if (!arch)
610 return; 608 return;
611 609
612 tmp = arch_to_object (arch); 610 tmp = arch_to_object (arch);
613 611
614 if ((floor->above) && (!can_build_over (pl->map, tmp, x, y))) 612 if (!floor->flag[FLAG_IS_BUILDABLE] || (floor->above) && (!can_build_over (pl->map, tmp, x, y)))
615 /* Floor has something on top that interferes with building */ 613 /* Floor has something on top that interferes with building */
616 { 614 {
617 new_draw_info (NDI_UNIQUE, 0, pl, "You can't build here."); 615 new_draw_info (NDI_UNIQUE, 0, pl, "You can't build here.");
618 return; 616 return;
619 } 617 }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines