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,2008 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 it under |
9 | * 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 |
10 | * the Free Software Foundation, either version 3 of the License, or |
10 | * Free Software Foundation, either version 3 of the License, or (at your |
11 | * (at your option) any later version. |
11 | * 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, |
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
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 Affero GNU General Public License |
19 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
19 | * and the GNU General Public License along with this program. If not, see |
|
|
20 | * <http://www.gnu.org/licenses/>. |
20 | * |
21 | * |
21 | * The authors can be reached via e-mail to <crossfire@schmorp.de> |
22 | * The authors can be reached via e-mail to <support@deliantra.net> |
22 | */ |
23 | */ |
23 | |
24 | |
24 | #include <global.h> |
25 | #include <global.h> |
25 | #include <living.h> |
26 | #include <living.h> |
26 | #include <spells.h> |
27 | #include <spells.h> |
… | |
… | |
38 | |
39 | |
39 | ob = GET_MAP_OB (map, x, y); |
40 | ob = GET_MAP_OB (map, x, y); |
40 | while (ob) |
41 | while (ob) |
41 | { |
42 | { |
42 | /* if ob is not a marking rune or floor, then check special cases */ |
43 | /* if ob is not a marking rune or floor, then check special cases */ |
43 | if (strcmp (ob->arch->archname, "rune_mark") && ob->type != FLOOR) |
44 | if (ob->arch->archname != shstr_rune_mark && ob->type != FLOOR) |
44 | { |
45 | { |
45 | switch (tmp->type) |
46 | switch (tmp->type) |
46 | { |
47 | { |
47 | case SIGN: |
48 | case SIGN: |
48 | case MAGIC_EAR: |
49 | case MAGIC_EAR: |
49 | /* Allow signs and magic ears to be built on books */ |
50 | /* Allow signs and magic ears to be built on books */ |
50 | if (ob->type != BOOK) |
51 | if (ob->type != BOOK) |
51 | { |
|
|
52 | return 0; |
|
|
53 | } |
|
|
54 | break; |
|
|
55 | case BUTTON: |
|
|
56 | case DETECTOR: |
|
|
57 | case PEDESTAL: |
|
|
58 | case CF_HANDLE: |
|
|
59 | /* Allow buttons and levers to be built under gates */ |
|
|
60 | if (ob->type != GATE && ob->type != DOOR) |
|
|
61 | { |
|
|
62 | return 0; |
|
|
63 | } |
|
|
64 | break; |
|
|
65 | default: |
|
|
66 | return 0; |
52 | return 0; |
|
|
53 | break; |
|
|
54 | case BUTTON: |
|
|
55 | case DETECTOR: |
|
|
56 | case PEDESTAL: |
|
|
57 | case T_HANDLE: |
|
|
58 | /* Allow buttons and levers to be built under gates */ |
|
|
59 | if (ob->type != GATE && ob->type != DOOR) |
|
|
60 | return 0; |
|
|
61 | break; |
|
|
62 | default: |
|
|
63 | return 0; |
67 | } |
64 | } |
68 | } |
65 | } |
|
|
66 | |
69 | ob = ob->above; |
67 | ob = ob->above; |
70 | } |
68 | } |
71 | return 1; |
69 | return 1; |
72 | } |
70 | } |
73 | |
71 | |
… | |
… | |
83 | rune = GET_MAP_OB (map, x, y); |
81 | rune = GET_MAP_OB (map, x, y); |
84 | while (rune) |
82 | while (rune) |
85 | { |
83 | { |
86 | next = rune->above; |
84 | next = rune->above; |
87 | |
85 | |
88 | if ((rune->type == SIGN) && (!strcmp (rune->arch->archname, "rune_mark"))) |
86 | if (rune->type == SIGN && rune->arch->archname == shstr_rune_mark) |
89 | rune->destroy (); |
87 | rune->destroy (); |
90 | |
88 | |
91 | rune = next; |
89 | rune = next; |
92 | } |
90 | } |
93 | } |
91 | } |
… | |
… | |
97 | * \param map: map for which to find a value |
95 | * \param map: map for which to find a value |
98 | * \return 'connected' value with no item, or -1 if failure. |
96 | * \return 'connected' value with no item, or -1 if failure. |
99 | * |
97 | * |
100 | * Tries 1000 random values, then returns -1. |
98 | * Tries 1000 random values, then returns -1. |
101 | */ |
99 | */ |
102 | int |
100 | static shstr_tmp |
103 | find_unused_connected_value (maptile *map) |
101 | find_unused_connected_value (maptile *map) |
104 | { |
102 | { |
105 | int connected = 0; |
103 | for (int i = 1000; --i; ) |
106 | int itest = 0; |
|
|
107 | oblinkpt *obp; |
|
|
108 | |
|
|
109 | while (itest++ < 1000) |
|
|
110 | { |
|
|
111 | connected = 1 + rand () % 20000; |
|
|
112 | for (obp = map->buttons; obp && (obp->value != connected); obp = obp->next); |
|
|
113 | |
|
|
114 | if (!obp) |
|
|
115 | return connected; |
|
|
116 | } |
104 | { |
|
|
105 | char buf[64]; |
117 | |
106 | |
118 | return -1; |
107 | snprintf (buf, sizeof (buf), "built-%x", rndm (0xf0000000U) + 0x10000000U); |
119 | } |
|
|
120 | |
108 | |
|
|
109 | shstr id (buf); |
|
|
110 | |
|
|
111 | if (!map->find_link (id)) |
|
|
112 | return id; |
|
|
113 | } |
|
|
114 | |
|
|
115 | return shstr_tmp (); |
|
|
116 | } |
121 | |
117 | |
122 | /** |
118 | /** |
123 | * Helper function for door/button/connected item building. |
119 | * Helper function for door/button/connected item building. |
124 | * |
120 | * |
125 | * Will search the specified spot for a marking rune. |
121 | * Will search the specified spot for a marking rune. |
… | |
… | |
127 | * Else, searches a force in op's inventory matching the map's name |
123 | * Else, searches a force in op's inventory matching the map's name |
128 | * and the rune's text. |
124 | * and the rune's text. |
129 | * If found, returns the connection value associated |
125 | * If found, returns the connection value associated |
130 | * else searches a new connection value, and adds the force to the player. |
126 | * else searches a new connection value, and adds the force to the player. |
131 | */ |
127 | */ |
132 | int |
128 | static shstr_tmp |
133 | find_or_create_connection_for_map (object *pl, short x, short y, object *rune) |
129 | find_or_create_connection_for_map (object *pl, short x, short y, object *rune) |
134 | { |
130 | { |
135 | object *force; |
131 | object *force; |
136 | int connected; |
|
|
137 | |
132 | |
138 | if (!rune) |
133 | if (!rune) |
139 | rune = get_connection_rune (pl, x, y); |
134 | rune = get_connection_rune (pl, x, y); |
140 | |
135 | |
141 | if (!rune) |
136 | if (!rune) |
142 | { |
137 | { |
143 | new_draw_info (NDI_UNIQUE, 0, pl, "You need to put a marking rune with the group name."); |
138 | new_draw_info (NDI_UNIQUE, 0, pl, "You need to put a marking rune with the group name."); |
144 | return -1; |
139 | return shstr_tmp (); |
145 | } |
140 | } |
146 | |
141 | |
147 | /* Now, find force in player's inventory */ |
142 | /* Now, find force in player's inventory */ |
148 | force = pl->inv; |
143 | force = pl->inv; |
149 | while (force |
144 | while (force |
… | |
… | |
153 | |
148 | |
154 | if (!force) |
149 | if (!force) |
155 | /* No force, need to create & insert one */ |
150 | /* No force, need to create & insert one */ |
156 | { |
151 | { |
157 | /* Find unused value */ |
152 | /* Find unused value */ |
158 | connected = find_unused_connected_value (pl->map); |
153 | shstr_tmp id = find_unused_connected_value (pl->map); |
159 | if (connected == -1) |
154 | |
|
|
155 | if (!id) |
160 | { |
156 | { |
161 | new_draw_info (NDI_UNIQUE, 0, pl, "Could not create more groups."); |
157 | new_draw_info (NDI_UNIQUE, 0, pl, "Could not create more groups."); |
162 | return -1; |
158 | return shstr_tmp (); |
163 | } |
159 | } |
164 | |
160 | |
165 | force = get_archetype (FORCE_NAME); |
161 | force = get_archetype (FORCE_NAME); |
166 | force->slaying = pl->map->path; |
162 | force->slaying = pl->map->path; |
167 | force->msg = rune->msg; |
163 | force->msg = rune->msg; |
168 | force->path_attuned = connected; |
164 | force->race = id; |
169 | force->set_speed (0); |
165 | force->set_speed (0); |
|
|
166 | |
170 | insert_ob_in_ob (force, pl); |
167 | insert_ob_in_ob (force, pl); |
171 | |
168 | |
172 | return connected; |
169 | return id; |
173 | } |
170 | } |
174 | |
171 | |
175 | /* Found the force, everything's easy. */ |
172 | /* Found the force, everything's easy. */ |
176 | return force->path_attuned; |
173 | return force->race; |
177 | } |
174 | } |
178 | |
175 | |
179 | /** |
176 | /** |
180 | * Returns the marking rune on the square, for purposes of building connections |
177 | * Returns the marking rune on the square, for purposes of building connections |
181 | */ |
178 | */ |
182 | object * |
179 | object * |
183 | get_connection_rune (object *pl, short x, short y) |
180 | get_connection_rune (object *pl, short x, short y) |
184 | { |
181 | { |
185 | object *rune; |
|
|
186 | |
|
|
187 | rune = GET_MAP_OB (pl->map, x, y); |
182 | object *rune = GET_MAP_OB (pl->map, x, y); |
|
|
183 | |
188 | while (rune && ((rune->type != SIGN) || (strcmp (rune->arch->archname, "rune_mark")))) |
184 | while (rune && (rune->type != SIGN || rune->arch->archname != shstr_rune_mark)) |
189 | rune = rune->above; |
185 | rune = rune->above; |
|
|
186 | |
190 | return rune; |
187 | return rune; |
191 | } |
188 | } |
192 | |
189 | |
193 | /** |
190 | /** |
194 | * Returns the book/scroll on the current square, for purposes of building |
191 | * Returns the book/scroll on the current square, for purposes of building |
195 | */ |
192 | */ |
196 | object * |
193 | object * |
197 | get_msg_book (object *pl, short x, short y) |
194 | get_msg_book (object *pl, short x, short y) |
198 | { |
195 | { |
199 | object *book; |
|
|
200 | |
|
|
201 | book = GET_MAP_OB (pl->map, x, y); |
196 | object *book = GET_MAP_OB (pl->map, x, y); |
|
|
197 | |
202 | while (book && (book->type != BOOK)) |
198 | while (book && (book->type != BOOK)) |
203 | book = book->above; |
199 | book = book->above; |
|
|
200 | |
204 | return book; |
201 | return book; |
205 | } |
202 | } |
206 | |
203 | |
207 | /** |
204 | /** |
208 | * Returns first item of type BUILDABLE_WALL. |
205 | * Returns first item of type BUILDABLE_WALL. |
209 | */ |
206 | */ |
210 | object * |
207 | object * |
211 | get_wall (maptile *map, int x, int y) |
208 | get_wall (maptile *map, int x, int y) |
212 | { |
209 | { |
213 | object *wall; |
|
|
214 | |
|
|
215 | wall = GET_MAP_OB (map, x, y); |
210 | object *wall = GET_MAP_OB (map, x, y); |
|
|
211 | |
216 | while (wall && (BUILDABLE_WALL != wall->type)) |
212 | while (wall && (BUILDABLE_WALL != wall->type)) |
217 | wall = wall->above; |
213 | wall = wall->above; |
218 | |
214 | |
219 | return wall; |
215 | return wall; |
220 | } |
216 | } |
… | |
… | |
231 | * Note: x & y must be valid map coordinates. |
227 | * Note: x & y must be valid map coordinates. |
232 | */ |
228 | */ |
233 | void |
229 | void |
234 | fix_walls (maptile *map, int x, int y) |
230 | fix_walls (maptile *map, int x, int y) |
235 | { |
231 | { |
236 | object *wall; |
|
|
237 | char archetype[MAX_BUF]; |
232 | char archetype[MAX_BUF]; |
238 | char *underscore; |
233 | char *underscore; |
239 | struct archetype *new_arch; |
234 | struct archetype *new_arch; |
240 | |
235 | |
241 | |
|
|
242 | /* First, find the wall on that spot */ |
236 | /* First, find the wall on that spot */ |
243 | wall = get_wall (map, x, y); |
237 | object *wall = get_wall (map, x, y); |
244 | if (!wall) |
238 | if (!wall) |
245 | /* Nothing -> bail out */ |
239 | /* Nothing -> bail out */ |
246 | return; |
240 | return; |
247 | |
241 | |
248 | /* Find base name */ |
242 | /* Find base name */ |
… | |
… | |
260 | underscore++; |
254 | underscore++; |
261 | *underscore = '\0'; |
255 | *underscore = '\0'; |
262 | |
256 | |
263 | int connect = 0; |
257 | int connect = 0; |
264 | |
258 | |
265 | if ((x > 0) && get_wall (map, x - 1, y)) |
259 | if (x > 0 && get_wall (map, x - 1, y)) connect |= 1; |
266 | connect |= 1; |
|
|
267 | if ((x < map->width - 1) && get_wall (map, x + 1, y)) |
260 | if (x < map->width - 1 && get_wall (map, x + 1, y)) connect |= 2; |
268 | connect |= 2; |
261 | if (y > 0 && get_wall (map, x, y - 1)) connect |= 4; |
269 | |
|
|
270 | if ((y > 0) && get_wall (map, x, y - 1)) |
|
|
271 | connect |= 4; |
|
|
272 | |
|
|
273 | if ((y < map->height - 1) && get_wall (map, x, y + 1)) |
262 | if (y < map->height - 1 && get_wall (map, x, y + 1)) connect |= 8; |
274 | connect |= 8; |
|
|
275 | |
263 | |
276 | switch (connect) |
264 | // one bit per dir, 1 left, 2 right, 4 up, 8 down |
277 | { |
265 | static const char *walltype[16] = { |
278 | case 0: |
266 | "0", |
279 | strcat (archetype, "0"); |
267 | "1_3", |
|
|
268 | "1_4", |
|
|
269 | "2_1_2", |
|
|
270 | "1_2", |
|
|
271 | "2_2_4", |
|
|
272 | "2_2_1", |
|
|
273 | "3_1", |
|
|
274 | "1_1", |
|
|
275 | "2_2_3", |
|
|
276 | "2_2_2", |
|
|
277 | "3_3", |
|
|
278 | "2_1_1", |
|
|
279 | "3_4", |
|
|
280 | "3_2", |
|
|
281 | "4" |
|
|
282 | }; |
280 | |
283 | |
281 | break; |
284 | strcat (archetype, walltype [connect]); |
282 | case 1: |
|
|
283 | strcat (archetype, "1_3"); |
|
|
284 | |
|
|
285 | break; |
|
|
286 | case 2: |
|
|
287 | strcat (archetype, "1_4"); |
|
|
288 | |
|
|
289 | break; |
|
|
290 | case 3: |
|
|
291 | strcat (archetype, "2_1_2"); |
|
|
292 | |
|
|
293 | break; |
|
|
294 | case 4: |
|
|
295 | strcat (archetype, "1_2"); |
|
|
296 | |
|
|
297 | break; |
|
|
298 | case 5: |
|
|
299 | strcat (archetype, "2_2_4"); |
|
|
300 | |
|
|
301 | break; |
|
|
302 | case 6: |
|
|
303 | strcat (archetype, "2_2_1"); |
|
|
304 | |
|
|
305 | break; |
|
|
306 | case 7: |
|
|
307 | strcat (archetype, "3_1"); |
|
|
308 | |
|
|
309 | break; |
|
|
310 | case 8: |
|
|
311 | strcat (archetype, "1_1"); |
|
|
312 | |
|
|
313 | break; |
|
|
314 | case 9: |
|
|
315 | strcat (archetype, "2_2_3"); |
|
|
316 | |
|
|
317 | break; |
|
|
318 | case 10: |
|
|
319 | strcat (archetype, "2_2_2"); |
|
|
320 | |
|
|
321 | break; |
|
|
322 | case 11: |
|
|
323 | strcat (archetype, "3_3"); |
|
|
324 | |
|
|
325 | break; |
|
|
326 | case 12: |
|
|
327 | strcat (archetype, "2_1_1"); |
|
|
328 | |
|
|
329 | break; |
|
|
330 | case 13: |
|
|
331 | strcat (archetype, "3_4"); |
|
|
332 | |
|
|
333 | break; |
|
|
334 | case 14: |
|
|
335 | strcat (archetype, "3_2"); |
|
|
336 | |
|
|
337 | break; |
|
|
338 | case 15: |
|
|
339 | strcat (archetype, "4"); |
|
|
340 | |
|
|
341 | break; |
|
|
342 | } |
|
|
343 | |
285 | |
344 | /* |
286 | /* |
345 | * Before anything, make sure the archetype does exist... |
287 | * Before anything, make sure the archetype does exist... |
346 | * If not, prolly an error... |
288 | * If not, prolly an error... |
347 | */ |
289 | */ |
… | |
… | |
411 | floor_removed = 1; |
353 | floor_removed = 1; |
412 | } |
354 | } |
413 | else |
355 | else |
414 | { |
356 | { |
415 | if (floor_removed) |
357 | if (floor_removed) |
|
|
358 | { |
|
|
359 | /* This is the first item that was above the floor */ |
416 | above_floor = tmp; |
360 | above_floor = tmp; |
|
|
361 | floor_removed = 0; |
|
|
362 | } |
417 | } |
363 | } |
418 | |
364 | |
419 | tmp = above; |
365 | tmp = above; |
420 | } |
366 | } |
421 | } |
367 | } |
… | |
… | |
475 | if (!OUT_OF_REAL_MAP (pl->map, xt, yt)) |
421 | if (!OUT_OF_REAL_MAP (pl->map, xt, yt)) |
476 | fix_walls (pl->map, xt, yt); |
422 | fix_walls (pl->map, xt, yt); |
477 | } |
423 | } |
478 | |
424 | |
479 | /* Now remove raw item from inventory */ |
425 | /* Now remove raw item from inventory */ |
480 | decrease_ob (material); |
426 | material->decrease (); |
481 | |
427 | |
482 | /* And tell player about the fix */ |
428 | /* And tell player about the fix */ |
483 | new_draw_info (NDI_UNIQUE, 0, pl, message); |
429 | new_draw_info (NDI_UNIQUE, 0, pl, message); |
484 | } |
430 | } |
485 | |
431 | |
… | |
… | |
562 | fix_walls (pl->map, xt, yt); |
508 | fix_walls (pl->map, xt, yt); |
563 | } |
509 | } |
564 | } |
510 | } |
565 | |
511 | |
566 | /* Now remove item from inventory */ |
512 | /* Now remove item from inventory */ |
567 | decrease_ob (material); |
513 | material->decrease (); |
568 | |
514 | |
569 | /* And tell player what happened */ |
515 | /* And tell player what happened */ |
570 | new_draw_info (NDI_UNIQUE, 0, pl, message); |
516 | new_draw_info (NDI_UNIQUE, 0, pl, message); |
571 | } |
517 | } |
572 | |
518 | |
… | |
… | |
584 | object *tmp; |
530 | object *tmp; |
585 | struct archetype *arch; |
531 | struct archetype *arch; |
586 | int insert_flag; |
532 | int insert_flag; |
587 | object *floor; |
533 | object *floor; |
588 | object *con_rune; |
534 | object *con_rune; |
589 | int connected; |
|
|
590 | |
535 | |
591 | /* Find floor */ |
536 | /* Find floor */ |
592 | floor = GET_MAP_OB (pl->map, x, y); |
537 | floor = GET_MAP_OB (pl->map, x, y); |
593 | if (!floor) |
538 | if (!floor) |
594 | { |
539 | { |
… | |
… | |
609 | if (!arch) |
554 | if (!arch) |
610 | return; |
555 | return; |
611 | |
556 | |
612 | tmp = arch_to_object (arch); |
557 | tmp = arch_to_object (arch); |
613 | |
558 | |
614 | if ((floor->above) && (!can_build_over (pl->map, tmp, x, y))) |
559 | 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 */ |
560 | /* Floor has something on top that interferes with building */ |
616 | { |
561 | { |
617 | new_draw_info (NDI_UNIQUE, 0, pl, "You can't build here."); |
562 | new_draw_info (NDI_UNIQUE, 0, pl, "You can't build here."); |
618 | return; |
563 | return; |
619 | } |
564 | } |
620 | |
565 | |
621 | SET_FLAG (tmp, FLAG_IS_BUILDABLE); |
566 | SET_FLAG (tmp, FLAG_IS_BUILDABLE); |
622 | SET_FLAG (tmp, FLAG_NO_PICK); |
567 | SET_FLAG (tmp, FLAG_NO_PICK); |
623 | |
568 | |
624 | /* |
569 | /* |
625 | * This doesn't work on non unique maps. pedestals under floor will not be saved... |
570 | * Str 1 is a flag that the item [pedestal] should go below the floor. |
626 | insert_flag = ( item->stats.Str == 1 ) ? INS_BELOW_ORIGINATOR : INS_ABOVE_FLOOR_ONLY; |
571 | * Items under the floor on non-unique maps will not be saved, |
|
|
572 | * so make the item itself unique in this situation. |
627 | */ |
573 | */ |
628 | insert_flag = INS_ABOVE_FLOOR_ONLY; |
574 | insert_flag = ( item->stats.Str == 1 ) ? INS_BELOW_ORIGINATOR : INS_ABOVE_FLOOR_ONLY; |
|
|
575 | if (insert_flag == INS_BELOW_ORIGINATOR && !pl->map->no_reset) |
|
|
576 | SET_FLAG (tmp, FLAG_UNIQUE); |
629 | |
577 | |
630 | connected = 0; |
578 | shstr_tmp connected; |
|
|
579 | |
631 | switch (tmp->type) |
580 | switch (tmp->type) |
632 | { |
581 | { |
633 | case DOOR: |
582 | case DOOR: |
634 | case GATE: |
583 | case GATE: |
635 | case BUTTON: |
584 | case BUTTON: |
636 | case DETECTOR: |
585 | case DETECTOR: |
637 | case TIMED_GATE: |
586 | case TIMED_GATE: |
638 | case PEDESTAL: |
587 | case PEDESTAL: |
639 | case CF_HANDLE: |
588 | case T_HANDLE: |
640 | case MAGIC_EAR: |
589 | case MAGIC_EAR: |
641 | case SIGN: |
590 | case SIGN: |
642 | /* Signs don't need a connection, but but magic mouths do. */ |
591 | /* Signs don't need a connection, but but magic mouths do. */ |
643 | if (tmp->type == SIGN && strcmp (tmp->arch->archname, "magic_mouth")) |
592 | if (tmp->type == SIGN && tmp->arch->archname != shstr_magic_mouth) |
644 | break; |
593 | break; |
|
|
594 | |
645 | con_rune = get_connection_rune (pl, x, y); |
595 | con_rune = get_connection_rune (pl, x, y); |
646 | connected = find_or_create_connection_for_map (pl, x, y, con_rune); |
596 | connected = find_or_create_connection_for_map (pl, x, y, con_rune); |
647 | if (connected == -1) |
597 | if (!connected) |
648 | { |
598 | { |
649 | /* Player already informed of failure by the previous function */ |
599 | /* Player already informed of failure by the previous function */ |
650 | tmp->destroy (); |
600 | tmp->destroy (); |
651 | return; |
601 | return; |
652 | } |
602 | } |
|
|
603 | |
653 | /* Remove marking rune */ |
604 | /* Remove marking rune */ |
654 | con_rune->destroy (); |
605 | con_rune->destroy (); |
655 | } |
606 | } |
656 | |
607 | |
657 | /* For magic mouths/ears, and signs, take the msg from a book of scroll */ |
608 | /* For magic mouths/ears, and signs, take the msg from a book of scroll */ |
658 | if ((tmp->type == SIGN) || (tmp->type == MAGIC_EAR)) |
609 | if ((tmp->type == SIGN) || (tmp->type == MAGIC_EAR)) |
659 | { |
610 | { |
… | |
… | |
663 | return; |
614 | return; |
664 | } |
615 | } |
665 | } |
616 | } |
666 | |
617 | |
667 | insert_ob_in_map_at (tmp, pl->map, floor, insert_flag, x, y); |
618 | insert_ob_in_map_at (tmp, pl->map, floor, insert_flag, x, y); |
668 | if (connected != 0) |
619 | if (connected) |
669 | add_button_link (tmp, pl->map, connected); |
620 | tmp->add_link (pl->map, connected); |
670 | |
621 | |
671 | new_draw_info_format (NDI_UNIQUE, 0, pl, "You build the %s", query_name (tmp)); |
622 | new_draw_info_format (NDI_UNIQUE, 0, pl, "You build the %s", query_name (tmp)); |
672 | decrease_ob_nr (item, 1); |
623 | item->decrease (); |
673 | } |
624 | } |
674 | |
625 | |
675 | /** |
626 | /** |
676 | * Item remover. |
627 | * Item remover. |
677 | * |
628 | * |
… | |
… | |
767 | } |
718 | } |
768 | |
719 | |
769 | tmp2 = find_marked_object (pl); |
720 | tmp2 = find_marked_object (pl); |
770 | while (tmp) |
721 | while (tmp) |
771 | { |
722 | { |
772 | if (!QUERY_FLAG (tmp, FLAG_IS_BUILDABLE) && ((tmp->type != SIGN) || (strcmp (tmp->arch->archname, "rune_mark")))) |
723 | if (!QUERY_FLAG (tmp, FLAG_IS_BUILDABLE) && (tmp->type != SIGN || tmp->arch->archname != shstr_rune_mark)) |
773 | { |
724 | { |
774 | /* The item building function already has it's own special |
725 | /* The item building function already has it's own special |
775 | * checks for this |
726 | * checks for this |
776 | */ |
727 | */ |
777 | if ((!tmp2) || (tmp2->subtype != ST_MAT_ITEM)) |
728 | if ((!tmp2) || (tmp2->subtype != ST_MAT_ITEM)) |
… | |
… | |
860 | tmp->msg = book->msg; |
811 | tmp->msg = book->msg; |
861 | |
812 | |
862 | if (tmp->invisible) |
813 | if (tmp->invisible) |
863 | { |
814 | { |
864 | if (book->custom_name != NULL) |
815 | if (book->custom_name != NULL) |
865 | { |
|
|
866 | snprintf (buf, sizeof (buf), "talking %s", &book->custom_name); |
816 | snprintf (buf, sizeof (buf), "talking %s", &book->custom_name); |
867 | } |
|
|
868 | else |
817 | else |
869 | { |
|
|
870 | snprintf (buf, sizeof (buf), "talking %s", &book->name); |
818 | snprintf (buf, sizeof (buf), "talking %s", &book->name); |
871 | } |
819 | |
872 | tmp->name = buf; |
820 | tmp->name = buf; |
873 | |
821 | |
874 | if (book->name_pl != NULL) |
822 | if (book->name_pl != NULL) |
875 | { |
823 | { |
876 | snprintf (buf2, sizeof (buf2), "talking %s", &book->name_pl); |
824 | snprintf (buf2, sizeof (buf2), "talking %s", &book->name_pl); |