1 | |
|
|
2 | /* |
1 | /* |
3 | * static char *rcsid_build_map = |
|
|
4 | * "$Id: build_map.C,v 1.6 2006/09/14 21:16:12 root Exp $"; |
|
|
5 | */ |
|
|
6 | |
|
|
7 | /* |
|
|
8 | CrossFire, A Multiplayer game for X-windows |
2 | * CrossFire, A Multiplayer game for X-windows |
9 | |
3 | * |
|
|
4 | * Copyright (C) 2005, 2006, 2007 Marc Lehmann & Crossfire+ Development Team |
10 | Copyright (C) 2001 Mark Wedel & Crossfire Development Team |
5 | * Copyright (C) 2001 Mark Wedel & Crossfire Development Team |
11 | Copyright (C) 1992 Frank Tore Johansen |
6 | * Copyright (C) 1992 Frank Tore Johansen |
12 | |
7 | * |
13 | This program is free software; you can redistribute it and/or modify |
8 | * This program is free software; you can redistribute it and/or modify |
14 | 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 |
15 | the Free Software Foundation; either version 2 of the License, or |
10 | * the Free Software Foundation; either version 2 of the License, or |
16 | (at your option) any later version. |
11 | * (at your 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 GNU General Public License |
24 | along with this program; if not, write to the Free Software |
19 | * along with this program; if not, write to the Free Software |
25 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
20 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
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 <crossfire@schmorp.de> |
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> |
… | |
… | |
36 | |
31 | |
37 | /** |
32 | /** |
38 | * Check if objects on a square interfere with building |
33 | * Check if objects on a square interfere with building |
39 | */ |
34 | */ |
40 | int |
35 | int |
41 | can_build_over (mapstruct *map, object *tmp, short x, short y) |
36 | can_build_over (maptile *map, object *tmp, short x, short y) |
42 | { |
37 | { |
43 | object *ob; |
38 | object *ob; |
44 | |
39 | |
45 | ob = GET_MAP_OB (map, x, y); |
40 | ob = GET_MAP_OB (map, x, y); |
46 | while (ob) |
41 | while (ob) |
… | |
… | |
79 | |
74 | |
80 | /** |
75 | /** |
81 | * Erases marking runes at specified location |
76 | * Erases marking runes at specified location |
82 | */ |
77 | */ |
83 | void |
78 | void |
84 | remove_marking_runes (mapstruct *map, short x, short y) |
79 | remove_marking_runes (maptile *map, short x, short y) |
85 | { |
80 | { |
86 | object *rune; |
81 | object *rune; |
87 | object *next; |
82 | object *next; |
88 | |
83 | |
89 | rune = GET_MAP_OB (map, x, y); |
84 | rune = GET_MAP_OB (map, x, y); |
90 | while (rune) |
85 | while (rune) |
91 | { |
86 | { |
92 | next = rune->above; |
87 | next = rune->above; |
|
|
88 | |
93 | if ((rune->type == SIGN) && (!strcmp (rune->arch->name, "rune_mark"))) |
89 | if ((rune->type == SIGN) && (!strcmp (rune->arch->name, "rune_mark"))) |
94 | { |
90 | rune->destroy (); |
95 | remove_ob (rune); |
91 | |
96 | free_object (rune); |
|
|
97 | } |
|
|
98 | rune = next; |
92 | rune = next; |
99 | } |
93 | } |
100 | } |
94 | } |
101 | |
95 | |
102 | /** |
96 | /** |
… | |
… | |
105 | * \return 'connected' value with no item, or -1 if failure. |
99 | * \return 'connected' value with no item, or -1 if failure. |
106 | * |
100 | * |
107 | * Tries 1000 random values, then returns -1. |
101 | * Tries 1000 random values, then returns -1. |
108 | */ |
102 | */ |
109 | int |
103 | int |
110 | find_unused_connected_value (mapstruct *map) |
104 | find_unused_connected_value (maptile *map) |
111 | { |
105 | { |
112 | int connected = 0; |
106 | int connected = 0; |
113 | int itest = 0; |
107 | int itest = 0; |
114 | oblinkpt *obp; |
108 | oblinkpt *obp; |
115 | |
109 | |
… | |
… | |
152 | } |
146 | } |
153 | |
147 | |
154 | /* Now, find force in player's inventory */ |
148 | /* Now, find force in player's inventory */ |
155 | force = pl->inv; |
149 | force = pl->inv; |
156 | while (force |
150 | while (force |
157 | && ((force->type != FORCE) || (!force->slaying) || (strcmp (force->slaying, pl->map->path)) || (!force->msg) |
151 | && ((force->type != FORCE) || !force->slaying || force->slaying != pl->map->path || !force->msg |
158 | || (strcmp (force->msg, rune->msg)))) |
152 | || force->msg != rune->msg)) |
159 | force = force->below; |
153 | force = force->below; |
160 | |
154 | |
161 | if (!force) |
155 | if (!force) |
162 | /* No force, need to create & insert one */ |
156 | /* No force, need to create & insert one */ |
163 | { |
157 | { |
… | |
… | |
168 | new_draw_info (NDI_UNIQUE, 0, pl, "Could not create more groups."); |
162 | new_draw_info (NDI_UNIQUE, 0, pl, "Could not create more groups."); |
169 | return -1; |
163 | return -1; |
170 | } |
164 | } |
171 | |
165 | |
172 | force = get_archetype (FORCE_NAME); |
166 | force = get_archetype (FORCE_NAME); |
173 | force->speed = 0; |
|
|
174 | update_ob_speed (force); |
|
|
175 | force->slaying = pl->map->path; |
167 | force->slaying = pl->map->path; |
176 | force->msg = rune->msg; |
168 | force->msg = rune->msg; |
177 | force->path_attuned = connected; |
169 | force->path_attuned = connected; |
|
|
170 | force->set_speed (0); |
178 | insert_ob_in_ob (force, pl); |
171 | insert_ob_in_ob (force, pl); |
179 | |
172 | |
180 | return connected; |
173 | return connected; |
181 | } |
174 | } |
182 | |
175 | |
… | |
… | |
211 | book = book->above; |
204 | book = book->above; |
212 | return book; |
205 | return book; |
213 | } |
206 | } |
214 | |
207 | |
215 | /** |
208 | /** |
216 | * Returns first item of type WALL. |
209 | * Returns first item of type BUILDABLE_WALL. |
217 | */ |
210 | */ |
218 | object * |
211 | object * |
219 | get_wall (mapstruct *map, int x, int y) |
212 | get_wall (maptile *map, int x, int y) |
220 | { |
213 | { |
221 | object *wall; |
214 | object *wall; |
222 | |
215 | |
223 | wall = GET_MAP_OB (map, x, y); |
216 | wall = GET_MAP_OB (map, x, y); |
224 | while (wall && (WALL != wall->type)) |
217 | while (wall && (BUILDABLE_WALL != wall->type)) |
225 | wall = wall->above; |
218 | wall = wall->above; |
226 | |
219 | |
227 | return wall; |
220 | return wall; |
228 | } |
221 | } |
229 | |
222 | |
… | |
… | |
237 | * Basically it ensures the correct wall is put where needed. |
230 | * Basically it ensures the correct wall is put where needed. |
238 | * |
231 | * |
239 | * Note: x & y must be valid map coordinates. |
232 | * Note: x & y must be valid map coordinates. |
240 | */ |
233 | */ |
241 | void |
234 | void |
242 | fix_walls (mapstruct *map, int x, int y) |
235 | fix_walls (maptile *map, int x, int y) |
243 | { |
236 | { |
244 | int connect; |
|
|
245 | object *wall; |
237 | object *wall; |
246 | char archetype[MAX_BUF]; |
238 | char archetype[MAX_BUF]; |
247 | char *underscore; |
239 | char *underscore; |
248 | uint32 old_flags[4]; |
|
|
249 | struct archetype *new_arch; |
240 | struct archetype *new_arch; |
250 | int flag; |
241 | |
251 | |
242 | |
252 | /* First, find the wall on that spot */ |
243 | /* First, find the wall on that spot */ |
253 | wall = get_wall (map, x, y); |
244 | wall = get_wall (map, x, y); |
254 | if (!wall) |
245 | if (!wall) |
255 | /* Nothing -> bail out */ |
246 | /* Nothing -> bail out */ |
256 | return; |
247 | return; |
257 | |
248 | |
258 | /* Find base name */ |
249 | /* Find base name */ |
259 | strcpy (archetype, wall->arch->name); |
250 | assign (archetype, wall->arch->name); |
260 | underscore = strchr (archetype, '_'); |
251 | underscore = strchr (archetype, '_'); |
261 | |
252 | |
|
|
253 | /* search for the first _ before a number */ |
|
|
254 | while (underscore && !isdigit (*(underscore + 1))) |
|
|
255 | underscore = strchr (underscore + 1, '_'); |
|
|
256 | |
262 | if (!underscore || (!isdigit (*(underscore + 1)))) |
257 | if (!underscore || !isdigit (*(underscore + 1))) |
263 | /* Not in a format we can change, bail out */ |
258 | /* Not in a format we can change, bail out */ |
264 | return; |
259 | return; |
265 | |
260 | |
266 | underscore++; |
261 | underscore++; |
267 | *underscore = '\0'; |
262 | *underscore = '\0'; |
268 | |
263 | |
269 | connect = 0; |
264 | int connect = 0; |
270 | |
265 | |
271 | if ((x > 0) && get_wall (map, x - 1, y)) |
266 | if ((x > 0) && get_wall (map, x - 1, y)) |
272 | connect |= 1; |
267 | connect |= 1; |
273 | if ((x < MAP_WIDTH (map) - 1) && get_wall (map, x + 1, y)) |
268 | if ((x < map->width - 1) && get_wall (map, x + 1, y)) |
274 | connect |= 2; |
269 | connect |= 2; |
275 | |
270 | |
276 | if ((y > 0) && get_wall (map, x, y - 1)) |
271 | if ((y > 0) && get_wall (map, x, y - 1)) |
277 | connect |= 4; |
272 | connect |= 4; |
278 | |
273 | |
279 | if ((y < MAP_HEIGHT (map) - 1) && get_wall (map, x, y + 1)) |
274 | if ((y < map->height - 1) && get_wall (map, x, y + 1)) |
280 | connect |= 8; |
275 | connect |= 8; |
281 | |
276 | |
282 | switch (connect) |
277 | switch (connect) |
283 | { |
278 | { |
284 | case 0: |
279 | case 0: |
… | |
… | |
357 | return; |
352 | return; |
358 | |
353 | |
359 | /* Now delete current wall, and insert new one |
354 | /* Now delete current wall, and insert new one |
360 | * We save flags to avoid any trouble with buildable/non buildable, and so on |
355 | * We save flags to avoid any trouble with buildable/non buildable, and so on |
361 | */ |
356 | */ |
362 | for (flag = 0; flag < 4; flag++) |
357 | object::flags_t old_flags = wall->flag; // elmex: this is where C++ pays off |
363 | old_flags[flag] = wall->flags[flag]; |
358 | |
364 | remove_ob (wall); |
359 | wall->destroy (); |
365 | free_object (wall); |
|
|
366 | |
360 | |
367 | wall = arch_to_object (new_arch); |
361 | wall = arch_to_object (new_arch); |
368 | wall->type = WALL; |
362 | wall->type = BUILDABLE_WALL; |
369 | insert_ob_in_map_at (wall, map, NULL, INS_ABOVE_FLOOR_ONLY, x, y); |
363 | 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]; |
364 | wall->flag = old_flags; |
372 | } |
365 | } |
373 | |
366 | |
374 | /** |
367 | /** |
375 | * \brief Floor building function |
368 | * \brief Floor building function |
376 | * |
369 | * |
… | |
… | |
404 | if (tmp) |
397 | if (tmp) |
405 | { |
398 | { |
406 | while (tmp) |
399 | while (tmp) |
407 | { |
400 | { |
408 | above = tmp->above; |
401 | above = tmp->above; |
409 | if (WALL == tmp->type) |
402 | if (BUILDABLE_WALL == tmp->type) |
410 | { |
403 | { |
411 | /* There was a wall, remove it & keep its archetype to make new walls */ |
404 | /* There was a wall, remove it & keep its archetype to make new walls */ |
412 | new_wall = tmp->arch; |
405 | new_wall = tmp->arch; |
413 | remove_ob (tmp); |
406 | tmp->destroy (); |
414 | free_object (tmp); |
|
|
415 | sprintf (message, "You destroy the wall and redo the floor."); |
407 | sprintf (message, "You destroy the wall and redo the floor."); |
416 | } |
408 | } |
417 | else if ((FLOOR == tmp->type) || (QUERY_FLAG (tmp, FLAG_IS_FLOOR))) |
409 | else if ((FLOOR == tmp->type) || (QUERY_FLAG (tmp, FLAG_IS_FLOOR))) |
418 | { |
410 | { |
419 | remove_ob (tmp); |
411 | tmp->destroy (); |
420 | free_object (tmp); |
|
|
421 | floor_removed = 1; |
412 | floor_removed = 1; |
422 | } |
413 | } |
423 | else |
414 | else |
424 | { |
415 | { |
425 | if (floor_removed) |
416 | if (floor_removed) |
… | |
… | |
467 | /* Insert wall if exists. Note: if it doesn't, the map is weird... */ |
458 | /* Insert wall if exists. Note: if it doesn't, the map is weird... */ |
468 | if (new_wall) |
459 | if (new_wall) |
469 | { |
460 | { |
470 | tmp = arch_to_object (new_wall); |
461 | tmp = arch_to_object (new_wall); |
471 | SET_FLAG (tmp, FLAG_IS_BUILDABLE); |
462 | SET_FLAG (tmp, FLAG_IS_BUILDABLE); |
472 | tmp->type = WALL; |
463 | tmp->type = BUILDABLE_WALL; |
473 | insert_ob_in_map_at (tmp, pl->map, 0, 0, xt, yt); |
464 | insert_ob_in_map_at (tmp, pl->map, 0, 0, xt, yt); |
474 | } |
465 | } |
475 | } |
466 | } |
476 | } |
467 | } |
477 | |
468 | |
… | |
… | |
492 | /* And tell player about the fix */ |
483 | /* And tell player about the fix */ |
493 | new_draw_info (NDI_UNIQUE, 0, pl, message); |
484 | new_draw_info (NDI_UNIQUE, 0, pl, message); |
494 | } |
485 | } |
495 | |
486 | |
496 | /** |
487 | /** |
|
|
488 | * Wall radius fix function |
|
|
489 | */ |
|
|
490 | void fix_walls_around (maptile *map, int x, int y) |
|
|
491 | { |
|
|
492 | for (int xt = x - 1; xt <= x + 1; xt++) |
|
|
493 | for (int yt = y - 1; yt <= y + 1; yt++) |
|
|
494 | { |
|
|
495 | if (OUT_OF_REAL_MAP (map, xt, yt)) |
|
|
496 | continue; |
|
|
497 | |
|
|
498 | fix_walls (map, xt, yt); |
|
|
499 | } |
|
|
500 | } |
|
|
501 | |
|
|
502 | /** |
497 | * Wall building function |
503 | * Wall building function |
498 | * |
504 | * |
499 | * Walls can be build: |
505 | * Walls can be build: |
500 | * - on a floor without anything else |
506 | * - on a floor without anything else |
501 | * - on an existing wall, with or without a floor |
507 | * - on an existing wall, with or without a floor |
… | |
… | |
514 | /* Grab existing wall, if any */ |
520 | /* Grab existing wall, if any */ |
515 | current_wall = NULL; |
521 | current_wall = NULL; |
516 | tmp = GET_MAP_OB (pl->map, x, y); |
522 | tmp = GET_MAP_OB (pl->map, x, y); |
517 | while (tmp && !current_wall) |
523 | while (tmp && !current_wall) |
518 | { |
524 | { |
519 | if (WALL == tmp->type) |
525 | if (BUILDABLE_WALL == tmp->type) |
520 | current_wall = tmp; |
526 | current_wall = tmp; |
521 | |
527 | |
522 | tmp = tmp->above; |
528 | tmp = tmp->above; |
523 | } |
529 | } |
524 | |
530 | |
… | |
… | |
532 | LOG (llevError, "apply_builder_wall: unable to find archetype %s\n", &material->slaying); |
538 | LOG (llevError, "apply_builder_wall: unable to find archetype %s\n", &material->slaying); |
533 | return; |
539 | return; |
534 | } |
540 | } |
535 | |
541 | |
536 | tmp = arch_to_object (new_wall); |
542 | tmp = arch_to_object (new_wall); |
537 | tmp->type = WALL; |
543 | tmp->type = BUILDABLE_WALL; |
538 | SET_FLAG (tmp, FLAG_IS_BUILDABLE); |
544 | SET_FLAG (tmp, FLAG_IS_BUILDABLE); |
539 | insert_ob_in_map_at (tmp, pl->map, 0, INS_ABOVE_FLOOR_ONLY, x, y); |
545 | insert_ob_in_map_at (tmp, pl->map, 0, INS_ABOVE_FLOOR_ONLY, x, y); |
540 | |
546 | |
541 | /* If existing wall, remove it, no need to fix other walls */ |
547 | /* If existing wall, remove it, no need to fix other walls */ |
542 | if (current_wall) |
548 | if (current_wall) |
543 | { |
549 | { |
544 | remove_ob (current_wall); |
550 | current_wall->destroy (); |
545 | free_object (current_wall); |
|
|
546 | fix_walls (pl->map, x, y); |
551 | fix_walls (pl->map, x, y); |
547 | sprintf (message, "You redecorate the wall to better suit your tastes."); |
552 | sprintf (message, "You redecorate the wall to better suit your tastes."); |
548 | } |
553 | } |
549 | else |
554 | else |
550 | { |
555 | { |
… | |
… | |
641 | con_rune = get_connection_rune (pl, x, y); |
646 | con_rune = get_connection_rune (pl, x, y); |
642 | connected = find_or_create_connection_for_map (pl, x, y, con_rune); |
647 | connected = find_or_create_connection_for_map (pl, x, y, con_rune); |
643 | if (connected == -1) |
648 | if (connected == -1) |
644 | { |
649 | { |
645 | /* Player already informed of failure by the previous function */ |
650 | /* Player already informed of failure by the previous function */ |
646 | free_object (tmp); |
651 | tmp->destroy (); |
647 | return; |
652 | return; |
648 | } |
653 | } |
649 | /* Remove marking rune */ |
654 | /* Remove marking rune */ |
650 | remove_ob (con_rune); |
655 | con_rune->destroy (); |
651 | free_object (con_rune); |
|
|
652 | } |
656 | } |
653 | |
657 | |
654 | /* For magic mouths/ears, and signs, take the msg from a book of scroll */ |
658 | /* For magic mouths/ears, and signs, take the msg from a book of scroll */ |
655 | if ((tmp->type == SIGN) || (tmp->type == MAGIC_EAR)) |
659 | if ((tmp->type == SIGN) || (tmp->type == MAGIC_EAR)) |
656 | { |
660 | { |
657 | if (adjust_sign_msg (pl, x, y, tmp) == -1) |
661 | if (adjust_sign_msg (pl, x, y, tmp) == -1) |
658 | { |
662 | { |
659 | free_object (tmp); |
663 | tmp->destroy (); |
660 | return; |
664 | return; |
661 | } |
665 | } |
662 | } |
666 | } |
663 | |
667 | |
664 | insert_ob_in_map_at (tmp, pl->map, floor, insert_flag, x, y); |
668 | insert_ob_in_map_at (tmp, pl->map, floor, insert_flag, x, y); |
… | |
… | |
687 | item = GET_MAP_OB (pl->map, x, y); |
691 | item = GET_MAP_OB (pl->map, x, y); |
688 | if (!item) |
692 | if (!item) |
689 | { |
693 | { |
690 | /* Should not happen with previous tests, but we never know */ |
694 | /* Should not happen with previous tests, but we never know */ |
691 | new_draw_info (NDI_UNIQUE, 0, pl, "Invalid square."); |
695 | 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); |
696 | LOG (llevError, "apply_builder_remove: (null) square at (%d, %d, %s)\n", x, y, &pl->map->path); |
693 | return; |
697 | return; |
694 | } |
698 | } |
695 | |
699 | |
696 | if (item->type == FLOOR || QUERY_FLAG (item, FLAG_IS_FLOOR)) |
700 | if (item->type == FLOOR || QUERY_FLAG (item, FLAG_IS_FLOOR)) |
697 | item = item->above; |
701 | item = item->above; |
698 | |
702 | |
699 | if (!item) |
703 | if (!item) |
700 | { |
|
|
701 | new_draw_info (NDI_UNIQUE, 0, pl, "Nothing to remove."); |
704 | new_draw_info (NDI_UNIQUE, 0, pl, "Nothing to remove."); |
702 | return; |
705 | else if (item->type == BUILDABLE_WALL) |
703 | } |
|
|
704 | |
|
|
705 | /* Now remove object, with special cases (buttons & such) */ |
|
|
706 | switch (item->type) |
|
|
707 | { |
|
|
708 | case WALL: |
|
|
709 | new_draw_info (NDI_UNIQUE, 0, pl, "Can't remove a wall with that, build a floor."); |
706 | new_draw_info (NDI_UNIQUE, 0, pl, "Can't remove a wall with that, build a floor."); |
710 | return; |
707 | else if (!item->flag [FLAG_IS_BUILDABLE]) |
711 | |
708 | new_draw_info_format (NDI_UNIQUE, 0, pl, "You can't remove the %s, it's not buildable!", query_name (item)); |
712 | case DOOR: |
709 | else |
713 | case BUTTON: |
710 | { |
714 | case GATE: |
|
|
715 | case TIMED_GATE: |
|
|
716 | case DETECTOR: |
|
|
717 | case PEDESTAL: |
|
|
718 | case CF_HANDLE: |
|
|
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 | |
|
|
725 | /* Fall through */ |
|
|
726 | |
|
|
727 | default: |
|
|
728 | /* Remove generic item */ |
|
|
729 | new_draw_info_format (NDI_UNIQUE, 0, pl, "You remove the %s", query_name (item)); |
711 | new_draw_info_format (NDI_UNIQUE, 0, pl, "You remove the %s", query_name (item)); |
730 | remove_ob (item); |
712 | item->destroy (); |
731 | free_object (item); |
|
|
732 | } |
713 | } |
733 | } |
714 | } |
734 | |
715 | |
735 | /** |
716 | /** |
736 | * Global building function |
717 | * Global building function |
… | |
… | |
762 | } |
743 | } |
763 | |
744 | |
764 | x = pl->x + freearr_x[dir]; |
745 | x = pl->x + freearr_x[dir]; |
765 | y = pl->y + freearr_y[dir]; |
746 | y = pl->y + freearr_y[dir]; |
766 | |
747 | |
767 | if ((1 > x) || (1 > y) || ((MAP_WIDTH (pl->map) - 2) < x) || ((MAP_HEIGHT (pl->map) - 2) < y)) |
748 | if ((1 > x) || (1 > y) || ((pl->map->width - 2) < x) || ((pl->map->height - 2) < y)) |
768 | { |
749 | { |
769 | new_draw_info (NDI_UNIQUE, 0, pl, "Can't build on map edge..."); |
750 | new_draw_info (NDI_UNIQUE, 0, pl, "Can't build on map edge..."); |
770 | return; |
751 | return; |
771 | } |
752 | } |
772 | |
753 | |
… | |
… | |
779 | |
760 | |
780 | tmp = GET_MAP_OB (pl->map, x, y); |
761 | tmp = GET_MAP_OB (pl->map, x, y); |
781 | if (!tmp) |
762 | if (!tmp) |
782 | { |
763 | { |
783 | /* Nothing, meaning player is standing next to an undefined square... */ |
764 | /* Nothing, meaning player is standing next to an undefined square... */ |
784 | LOG (llevError, "apply_map_builder: undefined square at (%d, %d, %s)\n", x, y, pl->map->path); |
765 | LOG (llevError, "apply_map_builder: undefined square at (%d, %d, %s)\n", x, y, &pl->map->path); |
785 | new_draw_info (NDI_UNIQUE, 0, pl, "You'd better not build here, it looks weird."); |
766 | new_draw_info (NDI_UNIQUE, 0, pl, "You'd better not build here, it looks weird."); |
786 | return; |
767 | return; |
787 | } |
768 | } |
788 | tmp2 = find_marked_object (pl); |
769 | tmp2 = find_marked_object (pl); |
789 | while (tmp) |
770 | while (tmp) |
… | |
… | |
897 | } |
878 | } |
898 | |
879 | |
899 | tmp->face = book->face; |
880 | tmp->face = book->face; |
900 | tmp->invisible = 0; |
881 | tmp->invisible = 0; |
901 | } |
882 | } |
902 | remove_ob (book); |
883 | |
903 | free_object (book); |
884 | book->destroy (); |
904 | return 0; |
885 | return 0; |
905 | } |
886 | } |