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