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.6 by root, Thu Sep 14 21:16:12 2006 UTC vs.
Revision 1.68 by root, Mon Oct 29 23:55:55 2012 UTC

1
2/* 1/*
3 * static char *rcsid_build_map = 2 * This file is part of Deliantra, the Roguelike Realtime MMORPG.
4 * "$Id: build_map.C,v 1.6 2006/09/14 21:16:12 root Exp $";
5 */ 3 *
6 4 * Copyright (©) 2005,2006,2007,2008,2009,2010,2011,2012 Marc Alexander Lehmann / Robin Redeker / the Deliantra team
7/*
8 CrossFire, A Multiplayer game for X-windows
9
10 Copyright (C) 2001 Mark Wedel & Crossfire Development Team 5 * Copyright (©) 2001 Mark Wedel & Crossfire Development Team
11 Copyright (C) 1992 Frank Tore Johansen 6 * Copyright (©) 1992 Frank Tore Johansen
12 7 *
13 This program is free software; you can redistribute it and/or modify 8 * Deliantra is free software: you can redistribute it and/or modify it under
14 it under the terms of the GNU General Public License as published by 9 * the terms of the Affero GNU General Public License as published by the
15 the Free Software Foundation; either version 2 of the License, or 10 * Free Software Foundation, either version 3 of the License, or (at your
16 (at your option) any later version. 11 * option) any later version.
17 12 *
18 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,
19 but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 GNU General Public License for more details. 16 * GNU General Public License for more details.
22 17 *
23 You should have received a copy of the GNU General Public License 18 * You should have received a copy of the Affero GNU General Public License
24 along with this program; if not, write to the Free Software 19 * and the GNU General Public License along with this program. If not, see
25 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 20 * <http://www.gnu.org/licenses/>.
26 21 *
27 The authors can be reached via e-mail to crossfire-devel@real-time.com 22 * The authors can be reached via e-mail to <support@deliantra.net>
28*/ 23 */
29 24
30#include <global.h> 25#include <global.h>
31#include <living.h> 26#include <living.h>
32#include <spells.h> 27#include <spells.h>
33#include <skills.h> 28#include <skills.h>
34#include <tod.h> 29#include <tod.h>
35#include <sproto.h> 30#include <sproto.h>
36 31
32// macro for this check, it had been inconsistent in this file.
33#define IS_FLOOR(x) x->flag [FLAG_IS_FLOOR]
34
37/** 35/**
38 * Check if objects on a square interfere with building 36 * Check if objects on a square interfere with building
39 */ 37 */
40int 38static int
41can_build_over (mapstruct *map, object *tmp, short x, short y) 39can_build_over (maptile *map, object *tmp, int x, int y)
42{ 40{
43 object *ob; 41 object *ob;
44 42
45 ob = GET_MAP_OB (map, x, y); 43 ob = GET_MAP_OB (map, x, y);
46 while (ob) 44 while (ob)
47 { 45 {
48 /* if ob is not a marking rune or floor, then check special cases */ 46 /* if ob is not a marking rune or floor, then check special cases */
49 if (strcmp (ob->arch->name, "rune_mark") && ob->type != FLOOR) 47 if (ob->arch->archname != shstr_rune_mark && !IS_FLOOR (ob))
50 { 48 {
51 switch (tmp->type) 49 switch (tmp->type)
52 { 50 {
53 case SIGN: 51 case SIGN:
54 case MAGIC_EAR: 52 case MAGIC_EAR:
55 /* Allow signs and magic ears to be built on books */ 53 /* Allow signs and magic ears to be built on books */
56 if (ob->type != BOOK) 54 if (ob->type != BOOK)
57 {
58 return 0;
59 }
60 break;
61 case BUTTON:
62 case DETECTOR:
63 case PEDESTAL:
64 case CF_HANDLE:
65 /* Allow buttons and levers to be built under gates */
66 if (ob->type != GATE && ob->type != DOOR)
67 {
68 return 0;
69 }
70 break;
71 default:
72 return 0; 55 return 0;
56 break;
57 case BUTTON:
58 case DETECTOR:
59 case PEDESTAL:
60 case T_HANDLE:
61 /* Allow buttons and levers to be built under gates */
62 if (ob->type != GATE && ob->type != DOOR)
63 return 0;
64 break;
65 default:
66 return 0;
73 } 67 }
74 } 68 }
69
75 ob = ob->above; 70 ob = ob->above;
76 } 71 }
72
77 return 1; 73 return 1;
78} 74}
79 75
80/** 76/**
81 * Erases marking runes at specified location 77 * Erases marking runes at specified location
82 */ 78 */
83void 79static void
84remove_marking_runes (mapstruct *map, short x, short y) 80remove_marking_runes (maptile *map, int x, int y)
85{ 81{
86 object *rune; 82 object *rune;
87 object *next; 83 object *next;
88 84
89 rune = GET_MAP_OB (map, x, y); 85 rune = GET_MAP_OB (map, x, y);
90 while (rune) 86 while (rune)
91 { 87 {
92 next = rune->above; 88 next = rune->above;
89
93 if ((rune->type == SIGN) && (!strcmp (rune->arch->name, "rune_mark"))) 90 if (rune->type == SIGN && rune->arch->archname == shstr_rune_mark)
94 { 91 rune->destroy ();
95 remove_ob (rune); 92
96 free_object (rune);
97 }
98 rune = next; 93 rune = next;
99 } 94 }
100} 95}
101 96
102/** 97/**
104 * \param map: map for which to find a value 99 * \param map: map for which to find a value
105 * \return 'connected' value with no item, or -1 if failure. 100 * \return 'connected' value with no item, or -1 if failure.
106 * 101 *
107 * Tries 1000 random values, then returns -1. 102 * Tries 1000 random values, then returns -1.
108 */ 103 */
109int 104static shstr_tmp
110find_unused_connected_value (mapstruct *map) 105find_unused_connected_value (maptile *map)
111{ 106{
112 int connected = 0; 107 for (int i = 1000; --i; )
113 int itest = 0;
114 oblinkpt *obp;
115
116 while (itest++ < 1000)
117 {
118 connected = 1 + rand () % 20000;
119 for (obp = map->buttons; obp && (obp->value != connected); obp = obp->next);
120
121 if (!obp)
122 return connected;
123 } 108 {
109 char buf[64];
124 110
111 snprintf (buf, sizeof (buf), "built-%x", rndm (0xf0000000U) + 0x10000000U);
112
113 shstr id (buf);
114
115 if (!map->find_link (id))
116 return id;
117 }
118
119 return shstr_tmp ();
120}
121
122/**
123 * Returns the marking rune on the square, for purposes of building connections
124 */
125static object *
126get_connection_rune (object *pl, int x, int y)
127{
128 object *rune = GET_MAP_OB (pl->map, x, y);
129
130 while (rune && (rune->type != SIGN || rune->arch->archname != shstr_rune_mark))
131 rune = rune->above;
132
125 return -1; 133 return rune;
126} 134}
127
128 135
129/** 136/**
130 * Helper function for door/button/connected item building. 137 * Helper function for door/button/connected item building.
131 * 138 *
132 * Will search the specified spot for a marking rune. 139 * Will search the specified spot for a marking rune.
134 * Else, searches a force in op's inventory matching the map's name 141 * Else, searches a force in op's inventory matching the map's name
135 * and the rune's text. 142 * and the rune's text.
136 * If found, returns the connection value associated 143 * If found, returns the connection value associated
137 * else searches a new connection value, and adds the force to the player. 144 * else searches a new connection value, and adds the force to the player.
138 */ 145 */
139int 146static shstr_tmp
140find_or_create_connection_for_map (object *pl, short x, short y, object *rune) 147find_or_create_connection_for_map (object *pl, int x, int y, object *rune)
141{ 148{
142 object *force; 149 object *force;
143 int connected;
144 150
145 if (!rune) 151 if (!rune)
146 rune = get_connection_rune (pl, x, y); 152 rune = get_connection_rune (pl, x, y);
147 153
148 if (!rune) 154 if (!rune)
149 { 155 {
150 new_draw_info (NDI_UNIQUE, 0, pl, "You need to put a marking rune with the group name."); 156 new_draw_info (NDI_UNIQUE, 0, pl, "You need to put a marking rune with the group name.");
151 return -1; 157 return shstr_tmp ();
152 } 158 }
153 159
154 /* Now, find force in player's inventory */ 160 /* Now, find force in player's inventory */
155 force = pl->inv; 161 force = pl->inv;
156 while (force 162 while (force
157 && ((force->type != FORCE) || (!force->slaying) || (strcmp (force->slaying, pl->map->path)) || (!force->msg) 163 && ((force->type != FORCE) || !force->slaying || force->slaying != pl->map->path || !force->msg
158 || (strcmp (force->msg, rune->msg)))) 164 || force->msg != rune->msg))
159 force = force->below; 165 force = force->below;
160 166
161 if (!force) 167 if (!force)
162 /* No force, need to create & insert one */ 168 /* No force, need to create & insert one */
163 { 169 {
164 /* Find unused value */ 170 /* Find unused value */
165 connected = find_unused_connected_value (pl->map); 171 shstr_tmp id = find_unused_connected_value (pl->map);
166 if (connected == -1) 172
173 if (!id)
167 { 174 {
168 new_draw_info (NDI_UNIQUE, 0, pl, "Could not create more groups."); 175 new_draw_info (NDI_UNIQUE, 0, pl, "Could not create more groups.");
169 return -1; 176 return shstr_tmp ();
170 } 177 }
171 178
172 force = get_archetype (FORCE_NAME); 179 force = archetype::get (FORCE_NAME);
173 force->speed = 0;
174 update_ob_speed (force);
175 force->slaying = pl->map->path; 180 force->slaying = pl->map->path;
176 force->msg = rune->msg; 181 force->msg = rune->msg;
177 force->path_attuned = connected; 182 force->race = id;
183 force->set_speed (0);
184
178 insert_ob_in_ob (force, pl); 185 insert_ob_in_ob (force, pl);
179 186
180 return connected; 187 return id;
181 } 188 }
182 189
183 /* Found the force, everything's easy. */ 190 /* Found the force, everything's easy. */
184 return force->path_attuned; 191 return force->race;
185}
186
187/**
188 * Returns the marking rune on the square, for purposes of building connections
189 */
190object *
191get_connection_rune (object *pl, short x, short y)
192{
193 object *rune;
194
195 rune = GET_MAP_OB (pl->map, x, y);
196 while (rune && ((rune->type != SIGN) || (strcmp (rune->arch->name, "rune_mark"))))
197 rune = rune->above;
198 return rune;
199} 192}
200 193
201/** 194/**
202 * 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
203 */ 196 */
204object * 197static object *
205get_msg_book (object *pl, short x, short y) 198get_msg_book (object *pl, int x, int y)
206{ 199{
207 object *book;
208
209 book = GET_MAP_OB (pl->map, x, y); 200 object *book = GET_MAP_OB (pl->map, x, y);
201
210 while (book && (book->type != BOOK)) 202 while (book && (book->type != BOOK))
211 book = book->above; 203 book = book->above;
204
212 return book; 205 return book;
213} 206}
214 207
215/** 208/**
209 * Make the built object inherit the msg of books that are used with it.
210 * For objects already invisible (i.e. magic mouths & ears), also make it
211 * it inherit the face and the name with "talking " prepended.
212 */
213static int
214adjust_sign_msg (object *pl, int x, int y, object *tmp)
215{
216 object *book;
217 char buf[MAX_BUF];
218 char buf2[MAX_BUF];
219
220 book = get_msg_book (pl, x, y);
221 if (!book)
222 {
223 new_draw_info (NDI_UNIQUE, 0, pl, "You need to put a book or scroll with the message.");
224 return -1;
225 }
226
227 if (tmp->type == MAGIC_EAR)
228 {
229 snprintf (buf, sizeof (buf), "@match %s", &(book->msg));
230 tmp->msg = buf;
231 }
232 else
233 tmp->msg = book->msg;
234
235 if (tmp->invisible)
236 {
237 if (book->custom_name)
238 snprintf (buf, sizeof (buf), "talking %s", &book->custom_name);
239 else
240 snprintf (buf, sizeof (buf), "talking %s", &book->name);
241
242 tmp->name = buf;
243
244 if (book->name_pl)
245 {
246 snprintf (buf2, sizeof (buf2), "talking %s", &book->name_pl);
247 tmp->name_pl = buf2;
248 }
249
250 tmp->face = book->face;
251 tmp->invisible = 0;
252 }
253
254 book->destroy ();
255 return 0;
256}
257
258/**
216 * Returns first item of type WALL. 259 * Returns first item of type BUILDABLE_WALL.
217 */ 260 */
218object * 261static object *
219get_wall (mapstruct *map, int x, int y) 262get_wall (maptile *map, int x, int y)
220{ 263{
221 object *wall;
222
223 wall = GET_MAP_OB (map, x, y); 264 object *wall = GET_MAP_OB (map, x, y);
265
224 while (wall && (WALL != wall->type)) 266 while (wall && (BUILDABLE_WALL != wall->type))
225 wall = wall->above; 267 wall = wall->above;
226 268
227 return wall; 269 return wall;
228} 270}
229 271
236 * 278 *
237 * Basically it ensures the correct wall is put where needed. 279 * Basically it ensures the correct wall is put where needed.
238 * 280 *
239 * Note: x & y must be valid map coordinates. 281 * Note: x & y must be valid map coordinates.
240 */ 282 */
241void 283static void
242fix_walls (mapstruct *map, int x, int y) 284fix_walls (maptile *map, int x, int y)
243{ 285{
244 int connect;
245 object *wall;
246 char archetype[MAX_BUF]; 286 char archetype[MAX_BUF];
247 char *underscore; 287 char *underscore;
248 uint32 old_flags[4];
249 struct archetype *new_arch; 288 struct archetype *new_arch;
250 int flag;
251 289
252 /* First, find the wall on that spot */ 290 /* First, find the wall on that spot */
253 wall = get_wall (map, x, y); 291 object *wall = get_wall (map, x, y);
254 if (!wall) 292 if (!wall)
255 /* Nothing -> bail out */ 293 /* Nothing -> bail out */
256 return; 294 return;
257 295
258 /* Find base name */ 296 /* Find base name */
259 strcpy (archetype, wall->arch->name); 297 assign (archetype, wall->arch->archname);
260 underscore = strchr (archetype, '_'); 298 underscore = strchr (archetype, '_');
261 299
300 /* search for the first _ before a number */
301 while (underscore && !isdigit (*(underscore + 1)))
302 underscore = strchr (underscore + 1, '_');
303
262 if (!underscore || (!isdigit (*(underscore + 1)))) 304 if (!underscore || !isdigit (*(underscore + 1)))
263 /* Not in a format we can change, bail out */ 305 /* Not in a format we can change, bail out */
264 return; 306 return;
265 307
266 underscore++; 308 underscore++;
267 *underscore = '\0'; 309 *underscore = '\0';
268 310
269 connect = 0; 311 int connect = 0;
270 312
271 if ((x > 0) && get_wall (map, x - 1, y)) 313 if (x > 0 && get_wall (map, x - 1, y)) connect |= 1;
272 connect |= 1; 314 if (x < map->width - 1 && get_wall (map, x + 1, y)) connect |= 2;
273 if ((x < MAP_WIDTH (map) - 1) && get_wall (map, x + 1, y)) 315 if (y > 0 && get_wall (map, x, y - 1)) connect |= 4;
274 connect |= 2; 316 if (y < map->height - 1 && get_wall (map, x, y + 1)) connect |= 8;
275 317
276 if ((y > 0) && get_wall (map, x, y - 1)) 318 strcat (archetype, wall_suffix [connect]);
277 connect |= 4;
278
279 if ((y < MAP_HEIGHT (map) - 1) && get_wall (map, x, y + 1))
280 connect |= 8;
281
282 switch (connect)
283 {
284 case 0:
285 strcat (archetype, "0");
286
287 break;
288 case 1:
289 strcat (archetype, "1_3");
290
291 break;
292 case 2:
293 strcat (archetype, "1_4");
294
295 break;
296 case 3:
297 strcat (archetype, "2_1_2");
298
299 break;
300 case 4:
301 strcat (archetype, "1_2");
302
303 break;
304 case 5:
305 strcat (archetype, "2_2_4");
306
307 break;
308 case 6:
309 strcat (archetype, "2_2_1");
310
311 break;
312 case 7:
313 strcat (archetype, "3_1");
314
315 break;
316 case 8:
317 strcat (archetype, "1_1");
318
319 break;
320 case 9:
321 strcat (archetype, "2_2_3");
322
323 break;
324 case 10:
325 strcat (archetype, "2_2_2");
326
327 break;
328 case 11:
329 strcat (archetype, "3_3");
330
331 break;
332 case 12:
333 strcat (archetype, "2_1_1");
334
335 break;
336 case 13:
337 strcat (archetype, "3_4");
338
339 break;
340 case 14:
341 strcat (archetype, "3_2");
342
343 break;
344 case 15:
345 strcat (archetype, "4");
346
347 break;
348 }
349 319
350 /* 320 /*
351 * Before anything, make sure the archetype does exist... 321 * Before anything, make sure the archetype does exist...
352 * If not, prolly an error... 322 * If not, prolly an error...
353 */ 323 */
357 return; 327 return;
358 328
359 /* Now delete current wall, and insert new one 329 /* Now delete current wall, and insert new one
360 * We save flags to avoid any trouble with buildable/non buildable, and so on 330 * We save flags to avoid any trouble with buildable/non buildable, and so on
361 */ 331 */
362 for (flag = 0; flag < 4; flag++) 332 object::flags_t old_flags = wall->flag; // elmex: this is where C++ pays off
363 old_flags[flag] = wall->flags[flag];
364 remove_ob (wall);
365 free_object (wall);
366 333
367 wall = arch_to_object (new_arch); 334 wall->destroy ();
335
336 wall = new_arch->instance ();
368 wall->type = WALL; 337 wall->type = BUILDABLE_WALL;
369 insert_ob_in_map_at (wall, map, NULL, INS_ABOVE_FLOOR_ONLY, x, y); 338 insert_ob_in_map_at (wall, map, NULL, INS_ABOVE_FLOOR_ONLY, x, y);
370 for (flag = 0; flag < 4; flag++)
371 wall->flags[flag] = old_flags[flag]; 339 wall->flag = old_flags;
372} 340}
373 341
374/** 342/**
375 * \brief Floor building function 343 * \brief Floor building function
376 * 344 *
379 * - on an existing wall, with or without a floor under it 347 * - on an existing wall, with or without a floor under it
380 * 348 *
381 * Note: this function will inconditionally change squares around (x, y) 349 * Note: this function will inconditionally change squares around (x, y)
382 * so don't call it with x == 0 for instance! 350 * so don't call it with x == 0 for instance!
383 */ 351 */
384void 352static void
385apply_builder_floor (object *pl, object *material, short x, short y) 353apply_builder_floor (object *pl, object *material, int x, int y)
386{ 354{
387 object *tmp, *above; 355 object *tmp, *above;
388 object *above_floor; /* Item above floor, if any */ 356 object *above_floor; /* Item above floor, if any */
389 struct archetype *new_floor; 357 struct archetype *new_floor;
390 struct archetype *new_wall; 358 struct archetype *new_wall;
404 if (tmp) 372 if (tmp)
405 { 373 {
406 while (tmp) 374 while (tmp)
407 { 375 {
408 above = tmp->above; 376 above = tmp->above;
409 if (WALL == tmp->type) 377 if (BUILDABLE_WALL == tmp->type)
410 { 378 {
411 /* There was a wall, remove it & keep its archetype to make new walls */ 379 /* There was a wall, remove it & keep its archetype to make new walls */
412 new_wall = tmp->arch; 380 new_wall = tmp->arch;
413 remove_ob (tmp); 381 tmp->destroy ();
414 free_object (tmp);
415 sprintf (message, "You destroy the wall and redo the floor."); 382 sprintf (message, "You destroy the wall and redo the floor.");
416 } 383 }
417 else if ((FLOOR == tmp->type) || (QUERY_FLAG (tmp, FLAG_IS_FLOOR))) 384 else if (IS_FLOOR (tmp))
418 { 385 {
419 remove_ob (tmp); 386 tmp->destroy ();
420 free_object (tmp);
421 floor_removed = 1; 387 floor_removed = 1;
422 } 388 }
423 else 389 else
424 { 390 {
425 if (floor_removed) 391 if (floor_removed)
392 {
393 /* This is the first item that was above the floor */
426 above_floor = tmp; 394 above_floor = tmp;
395 floor_removed = 0;
396 }
427 } 397 }
428 398
429 tmp = above; 399 tmp = above;
430 } 400 }
431 } 401 }
437 /* Not found, log & bail out */ 407 /* Not found, log & bail out */
438 LOG (llevError, "apply_builder_floor: unable to find archetype %s.\n", &material->slaying); 408 LOG (llevError, "apply_builder_floor: unable to find archetype %s.\n", &material->slaying);
439 return; 409 return;
440 } 410 }
441 411
442 tmp = arch_to_object (new_floor); 412 tmp = new_floor->instance ();
443 SET_FLAG (tmp, FLAG_IS_BUILDABLE); 413 tmp->set_flag (FLAG_IS_BUILDABLE);
444 SET_FLAG (tmp, FLAG_UNIQUE); 414 tmp->set_flag (FLAG_UNIQUE);
445 SET_FLAG (tmp, FLAG_IS_FLOOR); 415 tmp->set_flag (FLAG_IS_FLOOR);
446 tmp->type = FLOOR; 416 //tmp->type = FLOOR;
447 insert_ob_in_map_at (tmp, pl->map, above_floor, above_floor ? INS_BELOW_ORIGINATOR : INS_ON_TOP, x, y); 417 insert_ob_in_map_at (tmp, pl->map, above_floor, above_floor ? INS_BELOW_ORIGINATOR : INS_ON_TOP, x, y);
448 418
449 /* 419 /*
450 * Next step: make sure there are either walls or floors around the new square 420 * Next step: make sure there are either walls or floors around the new square
451 * Since building, you can have: blocking view / floor / wall / nothing 421 * Since building, you can have: blocking view / floor / wall / nothing
456 yt = y + freearr_y[i]; 426 yt = y + freearr_y[i];
457 tmp = GET_MAP_OB (pl->map, xt, yt); 427 tmp = GET_MAP_OB (pl->map, xt, yt);
458 if (!tmp) 428 if (!tmp)
459 { 429 {
460 /* Must insert floor & wall */ 430 /* Must insert floor & wall */
461 tmp = arch_to_object (new_floor); 431 tmp = new_floor->instance ();
462 /* Better make the floor unique */ 432 /* Better make the floor unique */
463 SET_FLAG (tmp, FLAG_UNIQUE); 433 tmp->set_flag (FLAG_UNIQUE);
464 SET_FLAG (tmp, FLAG_IS_BUILDABLE); 434 tmp->set_flag (FLAG_IS_BUILDABLE);
465 tmp->type = FLOOR; 435 //tmp->type = FLOOR;
466 insert_ob_in_map_at (tmp, pl->map, 0, 0, xt, yt); 436 insert_ob_in_map_at (tmp, pl->map, 0, 0, xt, yt);
467 /* Insert wall if exists. Note: if it doesn't, the map is weird... */ 437 /* Insert wall if exists. Note: if it doesn't, the map is weird... */
468 if (new_wall) 438 if (new_wall)
469 { 439 {
470 tmp = arch_to_object (new_wall); 440 tmp = new_wall->instance ();
471 SET_FLAG (tmp, FLAG_IS_BUILDABLE); 441 tmp->set_flag (FLAG_IS_BUILDABLE);
472 tmp->type = WALL; 442 tmp->type = BUILDABLE_WALL;
473 insert_ob_in_map_at (tmp, pl->map, 0, 0, xt, yt); 443 insert_ob_in_map_at (tmp, pl->map, 0, 0, xt, yt);
474 } 444 }
475 } 445 }
476 } 446 }
477 447
479 * Note: 2 squares around are checked, because potentially we added walls around the building 449 * Note: 2 squares around are checked, because potentially we added walls around the building
480 * spot, so need to check that those new walls connect correctly 450 * spot, so need to check that those new walls connect correctly
481 */ 451 */
482 for (xt = x - 2; xt <= x + 2; xt++) 452 for (xt = x - 2; xt <= x + 2; xt++)
483 for (yt = y - 2; yt <= y + 2; yt++) 453 for (yt = y - 2; yt <= y + 2; yt++)
484 {
485 if (!OUT_OF_REAL_MAP (pl->map, xt, yt)) 454 if (!OUT_OF_REAL_MAP (pl->map, xt, yt))
486 fix_walls (pl->map, xt, yt); 455 fix_walls (pl->map, xt, yt);
487 }
488 456
489 /* Now remove raw item from inventory */ 457 /* Now remove raw item from inventory */
490 decrease_ob (material); 458 material->decrease ();
491 459
492 /* And tell player about the fix */ 460 /* And tell player about the fix */
493 new_draw_info (NDI_UNIQUE, 0, pl, message); 461 new_draw_info (NDI_UNIQUE, 0, pl, message);
494} 462}
495 463
498 * 466 *
499 * Walls can be build: 467 * Walls can be build:
500 * - on a floor without anything else 468 * - on a floor without anything else
501 * - on an existing wall, with or without a floor 469 * - on an existing wall, with or without a floor
502 */ 470 */
503void 471static void
504apply_builder_wall (object *pl, object *material, short x, short y) 472apply_builder_wall (object *pl, object *material, int x, int y)
505{ 473{
506 object *current_wall; 474 object *current_wall;
507 object *tmp; 475 object *tmp;
508 int xt, yt; 476 int xt, yt;
509 struct archetype *new_wall; 477 struct archetype *new_wall;
514 /* Grab existing wall, if any */ 482 /* Grab existing wall, if any */
515 current_wall = NULL; 483 current_wall = NULL;
516 tmp = GET_MAP_OB (pl->map, x, y); 484 tmp = GET_MAP_OB (pl->map, x, y);
517 while (tmp && !current_wall) 485 while (tmp && !current_wall)
518 { 486 {
519 if (WALL == tmp->type) 487 if (BUILDABLE_WALL == tmp->type)
520 current_wall = tmp; 488 current_wall = tmp;
521 489
522 tmp = tmp->above; 490 tmp = tmp->above;
523 } 491 }
524 492
531 { 499 {
532 LOG (llevError, "apply_builder_wall: unable to find archetype %s\n", &material->slaying); 500 LOG (llevError, "apply_builder_wall: unable to find archetype %s\n", &material->slaying);
533 return; 501 return;
534 } 502 }
535 503
536 tmp = arch_to_object (new_wall); 504 tmp = new_wall->instance ();
537 tmp->type = WALL; 505 tmp->type = BUILDABLE_WALL;
538 SET_FLAG (tmp, FLAG_IS_BUILDABLE); 506 tmp->set_flag (FLAG_IS_BUILDABLE);
539 insert_ob_in_map_at (tmp, pl->map, 0, INS_ABOVE_FLOOR_ONLY, x, y); 507 insert_ob_in_map_at (tmp, pl->map, 0, INS_ABOVE_FLOOR_ONLY, x, y);
540 508
541 /* If existing wall, remove it, no need to fix other walls */ 509 /* If existing wall, remove it, no need to fix other walls */
542 if (current_wall) 510 if (current_wall)
543 { 511 {
544 remove_ob (current_wall); 512 current_wall->destroy ();
545 free_object (current_wall);
546 fix_walls (pl->map, x, y); 513 fix_walls (pl->map, x, y);
547 sprintf (message, "You redecorate the wall to better suit your tastes."); 514 sprintf (message, "You redecorate the wall to better suit your tastes.");
548 } 515 }
549 else 516 else
550 { 517 {
558 fix_walls (pl->map, xt, yt); 525 fix_walls (pl->map, xt, yt);
559 } 526 }
560 } 527 }
561 528
562 /* Now remove item from inventory */ 529 /* Now remove item from inventory */
563 decrease_ob (material); 530 material->decrease ();
564 531
565 /* And tell player what happened */ 532 /* And tell player what happened */
566 new_draw_info (NDI_UNIQUE, 0, pl, message); 533 new_draw_info (NDI_UNIQUE, 0, pl, message);
567} 534}
568 535
572 * Item must be put on a square with a floor, you can have something under. 539 * Item must be put on a square with a floor, you can have something under.
573 * Archetype of created object is item->slaying (raw material). 540 * Archetype of created object is item->slaying (raw material).
574 * Type of inserted item is tested for specific cases (doors & such). 541 * Type of inserted item is tested for specific cases (doors & such).
575 * Item is inserted above the floor, unless Str == 1 (only for detectors i guess) 542 * Item is inserted above the floor, unless Str == 1 (only for detectors i guess)
576 */ 543 */
577void 544static void
578apply_builder_item (object *pl, object *item, short x, short y) 545apply_builder_item (object *pl, object *item, int x, int y)
579{ 546{
580 object *tmp; 547 object *tmp;
581 struct archetype *arch; 548 struct archetype *arch;
582 int insert_flag; 549 int insert_flag;
583 object *floor; 550 object *floor;
584 object *con_rune; 551 object *con_rune;
585 int connected;
586 552
587 /* Find floor */ 553 /* Find floor */
588 floor = GET_MAP_OB (pl->map, x, y); 554 floor = GET_MAP_OB (pl->map, x, y);
589 if (!floor) 555 if (!floor)
590 { 556 {
591 new_draw_info (NDI_UNIQUE, 0, pl, "Invalid square."); 557 new_draw_info (NDI_UNIQUE, 0, pl, "Invalid square.");
592 return; 558 return;
593 } 559 }
594 560
595 while (floor && (floor->type != FLOOR) && (!QUERY_FLAG (floor, FLAG_IS_FLOOR))) 561 while (floor && !IS_FLOOR (floor))
596 floor = floor->above; 562 floor = floor->above;
597 563
598 if (!floor) 564 if (!floor)
599 { 565 {
600 new_draw_info (NDI_UNIQUE, 0, pl, "This square has no floor, you can't build here."); 566 new_draw_info (NDI_UNIQUE, 0, pl, "This square has no floor, you can't build here.");
603 /* Create item, set flag, insert in map */ 569 /* Create item, set flag, insert in map */
604 arch = archetype::find (item->slaying); 570 arch = archetype::find (item->slaying);
605 if (!arch) 571 if (!arch)
606 return; 572 return;
607 573
608 tmp = arch_to_object (arch); 574 tmp = arch->instance ();
609 575
610 if ((floor->above) && (!can_build_over (pl->map, tmp, x, y))) 576 if (!floor->flag[FLAG_IS_BUILDABLE] || floor->above && !can_build_over (pl->map, tmp, x, y))
611 /* Floor has something on top that interferes with building */ 577 /* Floor has something on top that interferes with building */
612 { 578 {
613 new_draw_info (NDI_UNIQUE, 0, pl, "You can't build here."); 579 new_draw_info (NDI_UNIQUE, 0, pl, "You can't build here.");
614 return; 580 return;
615 } 581 }
616 582
617 SET_FLAG (tmp, FLAG_IS_BUILDABLE); 583 tmp->set_flag (FLAG_IS_BUILDABLE);
618 SET_FLAG (tmp, FLAG_NO_PICK); 584 tmp->set_flag (FLAG_NO_PICK);
619 585
620 /* 586 /*
621 * This doesn't work on non unique maps. pedestals under floor will not be saved... 587 * Str 1 is a flag that the item [pedestal] should go below the floor.
622 insert_flag = ( item->stats.Str == 1 ) ? INS_BELOW_ORIGINATOR : INS_ABOVE_FLOOR_ONLY; 588 * Items under the floor on non-unique maps will not be saved,
589 * so make the item itself unique in this situation.
623 */ 590 */
624 insert_flag = INS_ABOVE_FLOOR_ONLY; 591 insert_flag = item->stats.Str == 1 ? INS_BELOW_ORIGINATOR : INS_ABOVE_FLOOR_ONLY;
592 if (insert_flag == INS_BELOW_ORIGINATOR && !pl->map->no_reset)
593 tmp->set_flag (FLAG_UNIQUE);
625 594
626 connected = 0; 595 shstr_tmp connected;
596
627 switch (tmp->type) 597 switch (tmp->type)
628 { 598 {
629 case DOOR: 599 case DOOR:
630 case GATE: 600 case GATE:
631 case BUTTON: 601 case BUTTON:
632 case DETECTOR: 602 case DETECTOR:
633 case TIMED_GATE: 603 case TIMED_GATE:
634 case PEDESTAL: 604 case PEDESTAL:
635 case CF_HANDLE: 605 case T_HANDLE:
636 case MAGIC_EAR: 606 case MAGIC_EAR:
637 case SIGN: 607 case SIGN:
638 /* Signs don't need a connection, but but magic mouths do. */ 608 /* Signs don't need a connection, but but magic mouths do. */
639 if (tmp->type == SIGN && strcmp (tmp->arch->name, "magic_mouth")) 609 if (tmp->type == SIGN && tmp->arch->archname != shstr_magic_mouth)
640 break; 610 break;
611
641 con_rune = get_connection_rune (pl, x, y); 612 con_rune = get_connection_rune (pl, x, y);
642 connected = find_or_create_connection_for_map (pl, x, y, con_rune); 613 connected = find_or_create_connection_for_map (pl, x, y, con_rune);
643 if (connected == -1) 614 if (!connected)
644 { 615 {
645 /* Player already informed of failure by the previous function */ 616 /* Player already informed of failure by the previous function */
646 free_object (tmp); 617 tmp->destroy ();
647 return; 618 return;
648 } 619 }
620
649 /* Remove marking rune */ 621 /* Remove marking rune */
650 remove_ob (con_rune); 622 con_rune->destroy ();
651 free_object (con_rune);
652 } 623 }
653 624
654 /* For magic mouths/ears, and signs, take the msg from a book of scroll */ 625 /* For magic mouths/ears, and signs, take the msg from a book of scroll */
655 if ((tmp->type == SIGN) || (tmp->type == MAGIC_EAR)) 626 if ((tmp->type == SIGN) || (tmp->type == MAGIC_EAR))
656 {
657 if (adjust_sign_msg (pl, x, y, tmp) == -1) 627 if (adjust_sign_msg (pl, x, y, tmp) == -1)
658 { 628 {
659 free_object (tmp); 629 tmp->destroy ();
660 return; 630 return;
661 } 631 }
662 }
663 632
664 insert_ob_in_map_at (tmp, pl->map, floor, insert_flag, x, y); 633 insert_ob_in_map_at (tmp, pl->map, floor, insert_flag, x, y);
665 if (connected != 0) 634 if (connected)
666 add_button_link (tmp, pl->map, connected); 635 tmp->add_link (pl->map, connected);
667 636
668 new_draw_info_format (NDI_UNIQUE, 0, pl, "You build the %s", query_name (tmp)); 637 new_draw_info_format (NDI_UNIQUE, 0, pl, "You build the %s", query_name (tmp));
669 decrease_ob_nr (item, 1); 638 item->decrease ();
670} 639}
671 640
672/** 641/**
673 * Item remover. 642 * Item remover.
674 * 643 *
675 * Removes first buildable item, either under or above the floor 644 * Removes first buildable item, either under or above the floor
676 */ 645 */
677void 646static void
678apply_builder_remove (object *pl, int dir) 647apply_builder_remove (object *pl, int dir)
679{ 648{
680 object *item; 649 object *item;
681 short x, y; 650 int x, y;
682 651
683 x = pl->x + freearr_x[dir]; 652 x = pl->x + freearr_x[dir];
684 y = pl->y + freearr_y[dir]; 653 y = pl->y + freearr_y[dir];
685 654
686 /* Check square */ 655 /* Check square */
687 item = GET_MAP_OB (pl->map, x, y); 656 item = GET_MAP_OB (pl->map, x, y);
688 if (!item) 657 if (!item)
689 { 658 {
690 /* Should not happen with previous tests, but we never know */ 659 /* Should not happen with previous tests, but we never know */
691 new_draw_info (NDI_UNIQUE, 0, pl, "Invalid square."); 660 new_draw_info (NDI_UNIQUE, 0, pl, "Invalid square.");
692 LOG (llevError, "apply_builder_remove: (null) square at (%d, %d, %s)\n", x, y, pl->map->path); 661 LOG (llevError, "apply_builder_remove: (null) square at (%d, %d, %s)\n", x, y, &pl->map->path);
693 return; 662 return;
694 } 663 }
695 664
696 if (item->type == FLOOR || QUERY_FLAG (item, FLAG_IS_FLOOR)) 665 if (IS_FLOOR (item))
697 item = item->above; 666 item = item->above;
698 667
699 if (!item) 668 if (!item)
700 {
701 new_draw_info (NDI_UNIQUE, 0, pl, "Nothing to remove."); 669 new_draw_info (NDI_UNIQUE, 0, pl, "Nothing to remove.");
670 else if (item->type == BUILDABLE_WALL)
671 new_draw_info (NDI_UNIQUE, 0, pl, "Can't remove a wall with that, build a floor.");
672 else if (!item->flag [FLAG_IS_BUILDABLE])
673 new_draw_info_format (NDI_UNIQUE, 0, pl, "You can't remove the %s, it's not buildable!", query_name (item));
674 else
675 {
676 new_draw_info_format (NDI_UNIQUE, 0, pl, "You remove the %s", query_name (item));
677 item->destroy ();
678 }
679}
680
681
682static void
683replace_open_space_floor (object *os, object *material)
684{
685 object *new_floor = archetype::get (material->slaying);
686 insert_ob_in_map_at (new_floor, os->map, os,
687 INS_BELOW_ORIGINATOR, os->x, os->y);
688 os->destroy ();
689 material->decrease ();
690}
691
692/**
693 * Quad building.
694 */
695void
696apply_builder_quad (object *pl, object *material, mapxy &pos)
697{
698 object *open_space = 0;
699 object *floor = 0;
700
701 object *tmp = pos.ms ().bot;
702 bool floor_exists = false;
703 while (tmp)
704 {
705 if (floor_exists && tmp->flag [FLAG_IS_QUAD])
706 {
707 pl->failmsg (
708 "You can't build there, there is a block in the way.");
709 return;
710 }
711
712 if (IS_FLOOR (tmp))
713 {
714 floor = tmp;
715 floor_exists = true;
716
717 if (floor->arch->archname == shstr_quad_open_space)
718 {
719 open_space = floor;
720 }
721 else if (!floor->flag [FLAG_IS_QUAD])
722 {
723 pl->failmsg (
724 "You can't build there, the floor is not suited.");
725 return;
726 }
727 }
728
729 tmp = tmp->above;
730 }
731
732 if (open_space)
733 {
734 if (!material->slaying)
735 {
736 pl->failmsg (
737 "The floor is open and you can't fill it with that material."
738 "H<Use another material to fill the ceiling.>");
739 return;
740 }
741
742 replace_open_space_floor (open_space, material);
743 pl->contr->fire_on = 0; // TODO: stopgap, do not add more than one per keypress
702 return; 744 return;
703 } 745 }
704 746 else if (floor)
705 /* Now remove object, with special cases (buttons & such) */
706 switch (item->type)
707 { 747 {
708 case WALL: 748
709 new_draw_info (NDI_UNIQUE, 0, pl, "Can't remove a wall with that, build a floor."); 749 maptile *upper_floor = pos.m->tile_available (TILE_UP);
750 if (!upper_floor)
751 {
752 pl->failmsg (
753 "Whoops, you can't see the ceiling.. H<You may try again.>");
710 return; 754 return;
755 }
711 756
712 case DOOR: 757 mapxy above_pos (upper_floor, pos.x, pos.y);
713 case BUTTON: 758 if (!above_pos.normalise ())
714 case GATE: 759 {
715 case TIMED_GATE: 760 pl->failmsg (
716 case DETECTOR: 761 "Whoops, you can't access the ceiling. H<You may try again.>");
717 case PEDESTAL: 762 return;
718 case CF_HANDLE: 763 }
719 case MAGIC_EAR:
720 case SIGN:
721 /* Special case: must unconnect */
722 if (QUERY_FLAG (item, FLAG_IS_LINKED))
723 remove_button_link (item);
724 764
725 /* Fall through */ 765 mapspace &above_ms = above_pos.ms ();
766 for (object *quad_obj = above_ms.top; quad_obj; quad_obj = quad_obj->below)
767 {
768 if (quad_obj->arch->archname == shstr_quad_open_space)
769 {
770 if (!material->slaying)
771 {
772 pl->failmsg (
773 "The ceiling is open and you can't fill it with that material."
774 "H<Use another material to fill the ceiling.>");
775 return;
776 }
726 777
727 default: 778 replace_open_space_floor (quad_obj, material);
728 /* Remove generic item */ 779 break;
729 new_draw_info_format (NDI_UNIQUE, 0, pl, "You remove the %s", query_name (item)); 780 }
730 remove_ob (item); 781 }
731 free_object (item); 782
783 if (material->destroyed ())
784 {
785 pl->failmsg (
786 "You don't have enough build material to build a wall here.");
787 return;
788 }
789
790 object *quad_wall = material->other_arch->instance ();
791 material->decrease ();
792
793 insert_ob_in_map_at (quad_wall, floor->map, 0,
794 INS_ABOVE_FLOOR_ONLY, floor->x, floor->y);
795 }
796 else
797 {
798 pl->failmsg ("You can't build a quad block here.");
732 } 799 }
733} 800}
734 801
735/** 802/**
736 * Global building function 803 * Global building function
739 * or remover object. 806 * or remover object.
740 */ 807 */
741void 808void
742apply_map_builder (object *pl, int dir) 809apply_map_builder (object *pl, int dir)
743{ 810{
744 object *builder;
745 object *tmp;
746 object *tmp2;
747 short x, y;
748
749 if (!pl->type == PLAYER) 811 if (!pl->type == PLAYER)
750 return; 812 return;
751 813
752 /*if ( !player->map->unique )
753 {
754 new_draw_info( NDI_UNIQUE, 0, player, "You can't build outside a unique map." );
755 return;
756 } */
757
758 if (dir == 0) 814 if (dir == 0)
759 { 815 {
760 new_draw_info (NDI_UNIQUE, 0, pl, "You can't build or destroy under yourself."); 816 new_draw_info (NDI_UNIQUE, 0, pl, "You can't build or destroy under yourself.");
761 return; 817 return;
762 } 818 }
763 819
764 x = pl->x + freearr_x[dir]; 820 mapxy pos (pl); pos.move (dir);
765 y = pl->y + freearr_y[dir];
766 821
767 if ((1 > x) || (1 > y) || ((MAP_WIDTH (pl->map) - 2) < x) || ((MAP_HEIGHT (pl->map) - 2) < y)) 822 if (!pos.normalise ())
768 { 823 {
769 new_draw_info (NDI_UNIQUE, 0, pl, "Can't build on map edge..."); 824 pl->failmsg ("You can't build here. H<There is nothing in this direction.>");
770 return; 825 return;
771 } 826 }
772 827
773 /* 828 /*
774 * Check specified square 829 * Check specified square
775 * The square must have only buildable items 830 * The square must have only buildable items
776 * Exception: marking runes are all right, 831 * Exception: marking runes are all right,
777 * since they are used for special things like connecting doors / buttons 832 * since they are used for special things like connecting doors / buttons
778 */ 833 */
779 834
780 tmp = GET_MAP_OB (pl->map, x, y); 835 object *builder = pl->contr->ranged_ob;
781 if (!tmp) 836
782 { 837 object *tmp2 = pl->mark ();
783 /* Nothing, meaning player is standing next to an undefined square... */ 838
784 LOG (llevError, "apply_map_builder: undefined square at (%d, %d, %s)\n", x, y, pl->map->path); 839 object *tmp = 0;
785 new_draw_info (NDI_UNIQUE, 0, pl, "You'd better not build here, it looks weird."); 840 for (tmp = pos.ms ().bot; tmp; tmp = tmp->above)
786 return;
787 } 841 {
788 tmp2 = find_marked_object (pl); 842 if (!tmp->flag [FLAG_IS_BUILDABLE]
789 while (tmp) 843 && (tmp->type != SIGN || tmp->arch->archname != shstr_rune_mark))
790 {
791 if (!QUERY_FLAG (tmp, FLAG_IS_BUILDABLE) && ((tmp->type != SIGN) || (strcmp (tmp->arch->name, "rune_mark"))))
792 { 844 {
793 /* The item building function already has it's own special 845 /* The item building function already has it's own special
794 * checks for this 846 * checks for this. And so does the quad building function.
795 */ 847 */
796 if ((!tmp2) || (tmp2->subtype != ST_MAT_ITEM)) 848 if (!tmp2 || (tmp2->subtype != ST_MAT_ITEM && tmp2->subtype != ST_MAT_QUAD))
797 { 849 {
850 if (!INVOKE_PLAYER (BUILD, pl->contr, ARG_OBJECT (builder),
851 ARG_MAP (pl->map),
852 ARG_INT (pos.y), ARG_INT (pos.y),
853 ARG_INT (0)))
798 new_draw_info (NDI_UNIQUE, 0, pl, "You can't build here."); 854 new_draw_info (NDI_UNIQUE, 0, pl, "You can't build here.");
855
799 return; 856 return;
800 } 857 }
801 } 858 }
802 tmp = tmp->above;
803 } 859 }
804 860
805 /* Now we know the square is ok */ 861 /* Now we know the square is ok */
806 builder = pl->contr->ranges[range_builder]; 862 if (INVOKE_PLAYER (BUILD, pl->contr, ARG_OBJECT (builder),
863 ARG_MAP (pl->map), ARG_INT (pos.x), ARG_INT (pos.y), ARG_INT (1)))
864 return;
807 865
808 if (builder->subtype == ST_BD_REMOVE) 866 if (builder->subtype == ST_BD_REMOVE)
809 /* Remover -> call specific function and bail out */ 867 /* Remover -> call specific function and bail out */
810 { 868 {
811 apply_builder_remove (pl, dir); 869 apply_builder_remove (pl, dir);
831 return; 889 return;
832 } 890 }
833 891
834 switch (tmp->subtype) 892 switch (tmp->subtype)
835 { 893 {
836 case ST_MAT_FLOOR: 894 case ST_MAT_FLOOR:
837 apply_builder_floor (pl, tmp, x, y); 895 apply_builder_floor (pl, tmp, pos.x, pos.y);
838 return; 896 return;
839 897
840 case ST_MAT_WALL: 898 case ST_MAT_WALL:
841 apply_builder_wall (pl, tmp, x, y); 899 apply_builder_wall (pl, tmp, pos.x, pos.y);
842 return; 900 return;
843 901
844 case ST_MAT_ITEM: 902 case ST_MAT_ITEM:
845 apply_builder_item (pl, tmp, x, y); 903 apply_builder_item (pl, tmp, pos.x, pos.y);
846 return; 904 return;
847 905
906 case ST_MAT_QUAD:
907 apply_builder_quad (pl, tmp, pos);
908 return;
909
848 default: 910 default:
849 new_draw_info (NDI_UNIQUE, 0, pl, "Don't know how to apply this material, sorry."); 911 new_draw_info (NDI_UNIQUE, 0, pl, "Don't know how to apply this material, sorry.");
850 LOG (llevError, "apply_map_builder: invalid material subtype %d\n", tmp->subtype); 912 LOG (llevError, "apply_map_builder: invalid material subtype %d\n", tmp->subtype);
851 return; 913 return;
852 } 914 }
853 } 915 }
854 916
855 /* Here, it means the builder has an invalid type */ 917 /* Here, it means the builder has an invalid type */
856 new_draw_info (NDI_UNIQUE, 0, pl, "Don't know how to apply this tool, sorry."); 918 new_draw_info (NDI_UNIQUE, 0, pl, "Don't know how to apply this tool, sorry.");
857 LOG (llevError, "apply_map_builder: invalid builder subtype %d\n", builder->subtype); 919 LOG (llevError, "apply_map_builder: invalid builder subtype %d\n", builder->subtype);
858} 920}
859 921
860/**
861 * Make the built object inherit the msg of books that are used with it.
862 * For objects already invisible (i.e. magic mouths & ears), also make it
863 * it inherit the face and the name with "talking " prepended.
864 */
865int
866adjust_sign_msg (object *pl, short x, short y, object *tmp)
867{
868 object *book;
869 char buf[MAX_BUF];
870 char buf2[MAX_BUF];
871
872 book = get_msg_book (pl, x, y);
873 if (!book)
874 {
875 new_draw_info (NDI_UNIQUE, 0, pl, "You need to put a book or scroll with the message.");
876 return -1;
877 }
878
879 tmp->msg = book->msg;
880
881 if (tmp->invisible)
882 {
883 if (book->custom_name != NULL)
884 {
885 snprintf (buf, sizeof (buf), "talking %s", &book->custom_name);
886 }
887 else
888 {
889 snprintf (buf, sizeof (buf), "talking %s", &book->name);
890 }
891 tmp->name = buf;
892
893 if (book->name_pl != NULL)
894 {
895 snprintf (buf2, sizeof (buf2), "talking %s", &book->name_pl);
896 tmp->name_pl = buf2;
897 }
898
899 tmp->face = book->face;
900 tmp->invisible = 0;
901 }
902 remove_ob (book);
903 free_object (book);
904 return 0;
905}

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines