1 | /* |
1 | /* |
2 | * This file is part of Deliantra, the Roguelike Realtime MMORPG. |
2 | * This file is part of Deliantra, the Roguelike Realtime MMORPG. |
3 | * |
3 | * |
4 | * Copyright (©) 2005,2006,2007,2008 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
4 | * Copyright (©) 2005,2006,2007,2008,2009,2010,2011,2012 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
5 | * Copyright (©) 2001,2007 Mark Wedel & Crossfire Development Team |
5 | * Copyright (©) 2001 Mark Wedel & Crossfire Development Team |
6 | * Copyright (©) 1992,2007 Frank Tore Johansen |
6 | * Copyright (©) 1992 Frank Tore Johansen |
7 | * |
7 | * |
8 | * Deliantra is free software: you can redistribute it and/or modify it under |
8 | * Deliantra is free software: you can redistribute it and/or modify it under |
9 | * the terms of the Affero GNU General Public License as published by the |
9 | * the terms of the Affero GNU General Public License as published by the |
10 | * Free Software Foundation, either version 3 of the License, or (at your |
10 | * Free Software Foundation, either version 3 of the License, or (at your |
11 | * 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 Affero GNU General Public License |
18 | * You should have received a copy of the Affero GNU General Public License |
19 | * and the GNU General Public License along with this program. If not, see |
19 | * and the GNU General Public License along with this program. If not, see |
20 | * <http://www.gnu.org/licenses/>. |
20 | * <http://www.gnu.org/licenses/>. |
21 | * |
21 | * |
22 | * The authors can be reached via e-mail to <support@deliantra.net> |
22 | * The authors can be reached via e-mail to <support@deliantra.net> |
23 | */ |
23 | */ |
24 | |
24 | |
25 | #include <global.h> |
25 | #include <global.h> |
26 | #include <living.h> |
26 | #include <living.h> |
27 | #include <spells.h> |
27 | #include <spells.h> |
28 | #include <skills.h> |
28 | #include <skills.h> |
29 | #include <tod.h> |
29 | #include <tod.h> |
30 | #include <sproto.h> |
30 | #include <sproto.h> |
31 | |
31 | |
|
|
32 | // macro for this check, it had been inconsistent in this file. |
|
|
33 | #define IS_FLOOR(x) x->flag [FLAG_IS_FLOOR] |
|
|
34 | |
32 | /** |
35 | /** |
33 | * Check if objects on a square interfere with building |
36 | * Check if objects on a square interfere with building |
34 | */ |
37 | */ |
35 | int |
38 | static int |
36 | can_build_over (maptile *map, object *tmp, short x, short y) |
39 | can_build_over (maptile *map, object *tmp, int x, int y) |
37 | { |
40 | { |
38 | object *ob; |
41 | object *ob; |
39 | |
42 | |
40 | ob = GET_MAP_OB (map, x, y); |
43 | ob = GET_MAP_OB (map, x, y); |
41 | while (ob) |
44 | while (ob) |
42 | { |
45 | { |
43 | /* 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 */ |
44 | if (ob->arch->archname != shstr_rune_mark && ob->type != FLOOR) |
47 | if (ob->arch->archname != shstr_rune_mark && !IS_FLOOR (ob)) |
45 | { |
48 | { |
46 | switch (tmp->type) |
49 | switch (tmp->type) |
47 | { |
50 | { |
48 | case SIGN: |
51 | case SIGN: |
49 | case MAGIC_EAR: |
52 | case MAGIC_EAR: |
… | |
… | |
64 | } |
67 | } |
65 | } |
68 | } |
66 | |
69 | |
67 | ob = ob->above; |
70 | ob = ob->above; |
68 | } |
71 | } |
|
|
72 | |
69 | return 1; |
73 | return 1; |
70 | } |
74 | } |
71 | |
75 | |
72 | /** |
76 | /** |
73 | * Erases marking runes at specified location |
77 | * Erases marking runes at specified location |
74 | */ |
78 | */ |
75 | void |
79 | static void |
76 | remove_marking_runes (maptile *map, short x, short y) |
80 | remove_marking_runes (maptile *map, int x, int y) |
77 | { |
81 | { |
78 | object *rune; |
82 | object *rune; |
79 | object *next; |
83 | object *next; |
80 | |
84 | |
81 | rune = GET_MAP_OB (map, x, y); |
85 | rune = GET_MAP_OB (map, x, y); |
… | |
… | |
111 | if (!map->find_link (id)) |
115 | if (!map->find_link (id)) |
112 | return id; |
116 | return id; |
113 | } |
117 | } |
114 | |
118 | |
115 | return shstr_tmp (); |
119 | return shstr_tmp (); |
|
|
120 | } |
|
|
121 | |
|
|
122 | /** |
|
|
123 | * Returns the marking rune on the square, for purposes of building connections |
|
|
124 | */ |
|
|
125 | static object * |
|
|
126 | get_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 | |
|
|
133 | return rune; |
116 | } |
134 | } |
117 | |
135 | |
118 | /** |
136 | /** |
119 | * Helper function for door/button/connected item building. |
137 | * Helper function for door/button/connected item building. |
120 | * |
138 | * |
… | |
… | |
124 | * and the rune's text. |
142 | * and the rune's text. |
125 | * If found, returns the connection value associated |
143 | * If found, returns the connection value associated |
126 | * 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. |
127 | */ |
145 | */ |
128 | static shstr_tmp |
146 | static shstr_tmp |
129 | find_or_create_connection_for_map (object *pl, short x, short y, object *rune) |
147 | find_or_create_connection_for_map (object *pl, int x, int y, object *rune) |
130 | { |
148 | { |
131 | object *force; |
149 | object *force; |
132 | |
150 | |
133 | if (!rune) |
151 | if (!rune) |
134 | rune = get_connection_rune (pl, x, y); |
152 | rune = get_connection_rune (pl, x, y); |
… | |
… | |
156 | { |
174 | { |
157 | 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."); |
158 | return shstr_tmp (); |
176 | return shstr_tmp (); |
159 | } |
177 | } |
160 | |
178 | |
161 | force = get_archetype (FORCE_NAME); |
179 | force = archetype::get (FORCE_NAME); |
162 | force->slaying = pl->map->path; |
180 | force->slaying = pl->map->path; |
163 | force->msg = rune->msg; |
181 | force->msg = rune->msg; |
164 | force->race = id; |
182 | force->race = id; |
165 | force->set_speed (0); |
183 | force->set_speed (0); |
166 | |
184 | |
… | |
… | |
172 | /* Found the force, everything's easy. */ |
190 | /* Found the force, everything's easy. */ |
173 | return force->race; |
191 | return force->race; |
174 | } |
192 | } |
175 | |
193 | |
176 | /** |
194 | /** |
177 | * Returns the marking rune on the square, for purposes of building connections |
|
|
178 | */ |
|
|
179 | object * |
|
|
180 | get_connection_rune (object *pl, short x, short y) |
|
|
181 | { |
|
|
182 | object *rune = GET_MAP_OB (pl->map, x, y); |
|
|
183 | |
|
|
184 | while (rune && (rune->type != SIGN || rune->arch->archname != shstr_rune_mark)) |
|
|
185 | rune = rune->above; |
|
|
186 | |
|
|
187 | return rune; |
|
|
188 | } |
|
|
189 | |
|
|
190 | /** |
|
|
191 | * 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 |
192 | */ |
196 | */ |
193 | object * |
197 | static object * |
194 | get_msg_book (object *pl, short x, short y) |
198 | get_msg_book (object *pl, int x, int y) |
195 | { |
199 | { |
196 | object *book = GET_MAP_OB (pl->map, x, y); |
200 | object *book = GET_MAP_OB (pl->map, x, y); |
197 | |
201 | |
198 | while (book && (book->type != BOOK)) |
202 | while (book && (book->type != BOOK)) |
199 | book = book->above; |
203 | book = book->above; |
200 | |
204 | |
201 | return book; |
205 | return book; |
202 | } |
206 | } |
203 | |
207 | |
204 | /** |
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 | */ |
|
|
213 | static int |
|
|
214 | adjust_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 | /** |
205 | * Returns first item of type BUILDABLE_WALL. |
259 | * Returns first item of type BUILDABLE_WALL. |
206 | */ |
260 | */ |
207 | object * |
261 | static object * |
208 | get_wall (maptile *map, int x, int y) |
262 | get_wall (maptile *map, int x, int y) |
209 | { |
263 | { |
210 | object *wall = GET_MAP_OB (map, x, y); |
264 | object *wall = GET_MAP_OB (map, x, y); |
211 | |
265 | |
212 | while (wall && (BUILDABLE_WALL != wall->type)) |
266 | while (wall && (BUILDABLE_WALL != wall->type)) |
… | |
… | |
224 | * |
278 | * |
225 | * Basically it ensures the correct wall is put where needed. |
279 | * Basically it ensures the correct wall is put where needed. |
226 | * |
280 | * |
227 | * Note: x & y must be valid map coordinates. |
281 | * Note: x & y must be valid map coordinates. |
228 | */ |
282 | */ |
229 | void |
283 | static void |
230 | fix_walls (maptile *map, int x, int y) |
284 | fix_walls (maptile *map, int x, int y) |
231 | { |
285 | { |
232 | char archetype[MAX_BUF]; |
286 | char archetype[MAX_BUF]; |
233 | char *underscore; |
287 | char *underscore; |
234 | struct archetype *new_arch; |
288 | struct archetype *new_arch; |
… | |
… | |
254 | underscore++; |
308 | underscore++; |
255 | *underscore = '\0'; |
309 | *underscore = '\0'; |
256 | |
310 | |
257 | int connect = 0; |
311 | int connect = 0; |
258 | |
312 | |
259 | if ((x > 0) && get_wall (map, x - 1, y)) |
313 | if (x > 0 && get_wall (map, x - 1, y)) connect |= 1; |
260 | connect |= 1; |
|
|
261 | if ((x < map->width - 1) && get_wall (map, x + 1, y)) |
314 | if (x < map->width - 1 && get_wall (map, x + 1, y)) connect |= 2; |
262 | connect |= 2; |
315 | if (y > 0 && get_wall (map, x, y - 1)) connect |= 4; |
263 | |
|
|
264 | if ((y > 0) && get_wall (map, x, y - 1)) |
|
|
265 | connect |= 4; |
|
|
266 | |
|
|
267 | if ((y < map->height - 1) && get_wall (map, x, y + 1)) |
316 | if (y < map->height - 1 && get_wall (map, x, y + 1)) connect |= 8; |
268 | connect |= 8; |
|
|
269 | |
317 | |
270 | switch (connect) |
318 | strcat (archetype, wall_suffix [connect]); |
271 | { |
|
|
272 | case 0: |
|
|
273 | strcat (archetype, "0"); |
|
|
274 | |
|
|
275 | break; |
|
|
276 | case 1: |
|
|
277 | strcat (archetype, "1_3"); |
|
|
278 | |
|
|
279 | break; |
|
|
280 | case 2: |
|
|
281 | strcat (archetype, "1_4"); |
|
|
282 | |
|
|
283 | break; |
|
|
284 | case 3: |
|
|
285 | strcat (archetype, "2_1_2"); |
|
|
286 | |
|
|
287 | break; |
|
|
288 | case 4: |
|
|
289 | strcat (archetype, "1_2"); |
|
|
290 | |
|
|
291 | break; |
|
|
292 | case 5: |
|
|
293 | strcat (archetype, "2_2_4"); |
|
|
294 | |
|
|
295 | break; |
|
|
296 | case 6: |
|
|
297 | strcat (archetype, "2_2_1"); |
|
|
298 | |
|
|
299 | break; |
|
|
300 | case 7: |
|
|
301 | strcat (archetype, "3_1"); |
|
|
302 | |
|
|
303 | break; |
|
|
304 | case 8: |
|
|
305 | strcat (archetype, "1_1"); |
|
|
306 | |
|
|
307 | break; |
|
|
308 | case 9: |
|
|
309 | strcat (archetype, "2_2_3"); |
|
|
310 | |
|
|
311 | break; |
|
|
312 | case 10: |
|
|
313 | strcat (archetype, "2_2_2"); |
|
|
314 | |
|
|
315 | break; |
|
|
316 | case 11: |
|
|
317 | strcat (archetype, "3_3"); |
|
|
318 | |
|
|
319 | break; |
|
|
320 | case 12: |
|
|
321 | strcat (archetype, "2_1_1"); |
|
|
322 | |
|
|
323 | break; |
|
|
324 | case 13: |
|
|
325 | strcat (archetype, "3_4"); |
|
|
326 | |
|
|
327 | break; |
|
|
328 | case 14: |
|
|
329 | strcat (archetype, "3_2"); |
|
|
330 | |
|
|
331 | break; |
|
|
332 | case 15: |
|
|
333 | strcat (archetype, "4"); |
|
|
334 | |
|
|
335 | break; |
|
|
336 | } |
|
|
337 | |
319 | |
338 | /* |
320 | /* |
339 | * Before anything, make sure the archetype does exist... |
321 | * Before anything, make sure the archetype does exist... |
340 | * If not, prolly an error... |
322 | * If not, prolly an error... |
341 | */ |
323 | */ |
… | |
… | |
349 | */ |
331 | */ |
350 | object::flags_t old_flags = wall->flag; // elmex: this is where C++ pays off |
332 | object::flags_t old_flags = wall->flag; // elmex: this is where C++ pays off |
351 | |
333 | |
352 | wall->destroy (); |
334 | wall->destroy (); |
353 | |
335 | |
354 | wall = arch_to_object (new_arch); |
336 | wall = new_arch->instance (); |
355 | wall->type = BUILDABLE_WALL; |
337 | wall->type = BUILDABLE_WALL; |
356 | 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); |
357 | wall->flag = old_flags; |
339 | wall->flag = old_flags; |
358 | } |
340 | } |
359 | |
341 | |
… | |
… | |
365 | * - on an existing wall, with or without a floor under it |
347 | * - on an existing wall, with or without a floor under it |
366 | * |
348 | * |
367 | * Note: this function will inconditionally change squares around (x, y) |
349 | * Note: this function will inconditionally change squares around (x, y) |
368 | * so don't call it with x == 0 for instance! |
350 | * so don't call it with x == 0 for instance! |
369 | */ |
351 | */ |
370 | void |
352 | static void |
371 | apply_builder_floor (object *pl, object *material, short x, short y) |
353 | apply_builder_floor (object *pl, object *material, int x, int y) |
372 | { |
354 | { |
373 | object *tmp, *above; |
355 | object *tmp, *above; |
374 | object *above_floor; /* Item above floor, if any */ |
356 | object *above_floor; /* Item above floor, if any */ |
375 | struct archetype *new_floor; |
357 | struct archetype *new_floor; |
376 | struct archetype *new_wall; |
358 | struct archetype *new_wall; |
… | |
… | |
397 | /* 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 */ |
398 | new_wall = tmp->arch; |
380 | new_wall = tmp->arch; |
399 | tmp->destroy (); |
381 | tmp->destroy (); |
400 | sprintf (message, "You destroy the wall and redo the floor."); |
382 | sprintf (message, "You destroy the wall and redo the floor."); |
401 | } |
383 | } |
402 | else if ((FLOOR == tmp->type) || (QUERY_FLAG (tmp, FLAG_IS_FLOOR))) |
384 | else if (IS_FLOOR (tmp)) |
403 | { |
385 | { |
404 | tmp->destroy (); |
386 | tmp->destroy (); |
405 | floor_removed = 1; |
387 | floor_removed = 1; |
406 | } |
388 | } |
407 | else |
389 | else |
… | |
… | |
425 | /* Not found, log & bail out */ |
407 | /* Not found, log & bail out */ |
426 | 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); |
427 | return; |
409 | return; |
428 | } |
410 | } |
429 | |
411 | |
430 | tmp = arch_to_object (new_floor); |
412 | tmp = new_floor->instance (); |
431 | SET_FLAG (tmp, FLAG_IS_BUILDABLE); |
413 | tmp->set_flag (FLAG_IS_BUILDABLE); |
432 | SET_FLAG (tmp, FLAG_UNIQUE); |
414 | tmp->set_flag (FLAG_UNIQUE); |
433 | SET_FLAG (tmp, FLAG_IS_FLOOR); |
415 | tmp->set_flag (FLAG_IS_FLOOR); |
434 | tmp->type = FLOOR; |
416 | //tmp->type = FLOOR; |
435 | 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); |
436 | |
418 | |
437 | /* |
419 | /* |
438 | * 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 |
439 | * Since building, you can have: blocking view / floor / wall / nothing |
421 | * Since building, you can have: blocking view / floor / wall / nothing |
… | |
… | |
444 | yt = y + freearr_y[i]; |
426 | yt = y + freearr_y[i]; |
445 | tmp = GET_MAP_OB (pl->map, xt, yt); |
427 | tmp = GET_MAP_OB (pl->map, xt, yt); |
446 | if (!tmp) |
428 | if (!tmp) |
447 | { |
429 | { |
448 | /* Must insert floor & wall */ |
430 | /* Must insert floor & wall */ |
449 | tmp = arch_to_object (new_floor); |
431 | tmp = new_floor->instance (); |
450 | /* Better make the floor unique */ |
432 | /* Better make the floor unique */ |
451 | SET_FLAG (tmp, FLAG_UNIQUE); |
433 | tmp->set_flag (FLAG_UNIQUE); |
452 | SET_FLAG (tmp, FLAG_IS_BUILDABLE); |
434 | tmp->set_flag (FLAG_IS_BUILDABLE); |
453 | tmp->type = FLOOR; |
435 | //tmp->type = FLOOR; |
454 | 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); |
455 | /* 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... */ |
456 | if (new_wall) |
438 | if (new_wall) |
457 | { |
439 | { |
458 | tmp = arch_to_object (new_wall); |
440 | tmp = new_wall->instance (); |
459 | SET_FLAG (tmp, FLAG_IS_BUILDABLE); |
441 | tmp->set_flag (FLAG_IS_BUILDABLE); |
460 | tmp->type = BUILDABLE_WALL; |
442 | tmp->type = BUILDABLE_WALL; |
461 | 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); |
462 | } |
444 | } |
463 | } |
445 | } |
464 | } |
446 | } |
… | |
… | |
467 | * 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 |
468 | * spot, so need to check that those new walls connect correctly |
450 | * spot, so need to check that those new walls connect correctly |
469 | */ |
451 | */ |
470 | for (xt = x - 2; xt <= x + 2; xt++) |
452 | for (xt = x - 2; xt <= x + 2; xt++) |
471 | for (yt = y - 2; yt <= y + 2; yt++) |
453 | for (yt = y - 2; yt <= y + 2; yt++) |
472 | { |
|
|
473 | if (!OUT_OF_REAL_MAP (pl->map, xt, yt)) |
454 | if (!OUT_OF_REAL_MAP (pl->map, xt, yt)) |
474 | fix_walls (pl->map, xt, yt); |
455 | fix_walls (pl->map, xt, yt); |
475 | } |
|
|
476 | |
456 | |
477 | /* Now remove raw item from inventory */ |
457 | /* Now remove raw item from inventory */ |
478 | material->decrease (); |
458 | material->decrease (); |
479 | |
459 | |
480 | /* And tell player about the fix */ |
460 | /* And tell player about the fix */ |
481 | new_draw_info (NDI_UNIQUE, 0, pl, message); |
461 | new_draw_info (NDI_UNIQUE, 0, pl, message); |
482 | } |
|
|
483 | |
|
|
484 | /** |
|
|
485 | * Wall radius fix function |
|
|
486 | */ |
|
|
487 | void fix_walls_around (maptile *map, int x, int y) |
|
|
488 | { |
|
|
489 | for (int xt = x - 1; xt <= x + 1; xt++) |
|
|
490 | for (int yt = y - 1; yt <= y + 1; yt++) |
|
|
491 | { |
|
|
492 | if (OUT_OF_REAL_MAP (map, xt, yt)) |
|
|
493 | continue; |
|
|
494 | |
|
|
495 | fix_walls (map, xt, yt); |
|
|
496 | } |
|
|
497 | } |
462 | } |
498 | |
463 | |
499 | /** |
464 | /** |
500 | * Wall building function |
465 | * Wall building function |
501 | * |
466 | * |
502 | * Walls can be build: |
467 | * Walls can be build: |
503 | * - on a floor without anything else |
468 | * - on a floor without anything else |
504 | * - on an existing wall, with or without a floor |
469 | * - on an existing wall, with or without a floor |
505 | */ |
470 | */ |
506 | void |
471 | static void |
507 | apply_builder_wall (object *pl, object *material, short x, short y) |
472 | apply_builder_wall (object *pl, object *material, int x, int y) |
508 | { |
473 | { |
509 | object *current_wall; |
474 | object *current_wall; |
510 | object *tmp; |
475 | object *tmp; |
511 | int xt, yt; |
476 | int xt, yt; |
512 | struct archetype *new_wall; |
477 | struct archetype *new_wall; |
… | |
… | |
534 | { |
499 | { |
535 | 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); |
536 | return; |
501 | return; |
537 | } |
502 | } |
538 | |
503 | |
539 | tmp = arch_to_object (new_wall); |
504 | tmp = new_wall->instance (); |
540 | tmp->type = BUILDABLE_WALL; |
505 | tmp->type = BUILDABLE_WALL; |
541 | SET_FLAG (tmp, FLAG_IS_BUILDABLE); |
506 | tmp->set_flag (FLAG_IS_BUILDABLE); |
542 | 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); |
543 | |
508 | |
544 | /* If existing wall, remove it, no need to fix other walls */ |
509 | /* If existing wall, remove it, no need to fix other walls */ |
545 | if (current_wall) |
510 | if (current_wall) |
546 | { |
511 | { |
… | |
… | |
574 | * 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. |
575 | * Archetype of created object is item->slaying (raw material). |
540 | * Archetype of created object is item->slaying (raw material). |
576 | * Type of inserted item is tested for specific cases (doors & such). |
541 | * Type of inserted item is tested for specific cases (doors & such). |
577 | * 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) |
578 | */ |
543 | */ |
579 | void |
544 | static void |
580 | apply_builder_item (object *pl, object *item, short x, short y) |
545 | apply_builder_item (object *pl, object *item, int x, int y) |
581 | { |
546 | { |
582 | object *tmp; |
547 | object *tmp; |
583 | struct archetype *arch; |
548 | struct archetype *arch; |
584 | int insert_flag; |
549 | int insert_flag; |
585 | object *floor; |
550 | object *floor; |
… | |
… | |
591 | { |
556 | { |
592 | new_draw_info (NDI_UNIQUE, 0, pl, "Invalid square."); |
557 | new_draw_info (NDI_UNIQUE, 0, pl, "Invalid square."); |
593 | return; |
558 | return; |
594 | } |
559 | } |
595 | |
560 | |
596 | while (floor && (floor->type != FLOOR) && (!QUERY_FLAG (floor, FLAG_IS_FLOOR))) |
561 | while (floor && !IS_FLOOR (floor)) |
597 | floor = floor->above; |
562 | floor = floor->above; |
598 | |
563 | |
599 | if (!floor) |
564 | if (!floor) |
600 | { |
565 | { |
601 | 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."); |
… | |
… | |
604 | /* Create item, set flag, insert in map */ |
569 | /* Create item, set flag, insert in map */ |
605 | arch = archetype::find (item->slaying); |
570 | arch = archetype::find (item->slaying); |
606 | if (!arch) |
571 | if (!arch) |
607 | return; |
572 | return; |
608 | |
573 | |
609 | tmp = arch_to_object (arch); |
574 | tmp = arch->instance (); |
610 | |
575 | |
611 | if (!floor->flag[FLAG_IS_BUILDABLE] || (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)) |
612 | /* Floor has something on top that interferes with building */ |
577 | /* Floor has something on top that interferes with building */ |
613 | { |
578 | { |
614 | 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."); |
615 | return; |
580 | return; |
616 | } |
581 | } |
617 | |
582 | |
618 | SET_FLAG (tmp, FLAG_IS_BUILDABLE); |
583 | tmp->set_flag (FLAG_IS_BUILDABLE); |
619 | SET_FLAG (tmp, FLAG_NO_PICK); |
584 | tmp->set_flag (FLAG_NO_PICK); |
620 | |
585 | |
621 | /* |
586 | /* |
622 | * Str 1 is a flag that the item [pedestal] should go below the floor. |
587 | * Str 1 is a flag that the item [pedestal] should go below the floor. |
623 | * Items under the floor on non-unique maps will not be saved, |
588 | * Items under the floor on non-unique maps will not be saved, |
624 | * so make the item itself unique in this situation. |
589 | * so make the item itself unique in this situation. |
625 | */ |
590 | */ |
626 | insert_flag = ( item->stats.Str == 1 ) ? INS_BELOW_ORIGINATOR : INS_ABOVE_FLOOR_ONLY; |
591 | insert_flag = item->stats.Str == 1 ? INS_BELOW_ORIGINATOR : INS_ABOVE_FLOOR_ONLY; |
627 | if (insert_flag == INS_BELOW_ORIGINATOR && !pl->map->no_reset) |
592 | if (insert_flag == INS_BELOW_ORIGINATOR && !pl->map->no_reset) |
628 | SET_FLAG (tmp, FLAG_UNIQUE); |
593 | tmp->set_flag (FLAG_UNIQUE); |
629 | |
594 | |
630 | shstr_tmp connected; |
595 | shstr_tmp connected; |
631 | |
596 | |
632 | switch (tmp->type) |
597 | switch (tmp->type) |
633 | { |
598 | { |
… | |
… | |
657 | con_rune->destroy (); |
622 | con_rune->destroy (); |
658 | } |
623 | } |
659 | |
624 | |
660 | /* 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 */ |
661 | if ((tmp->type == SIGN) || (tmp->type == MAGIC_EAR)) |
626 | if ((tmp->type == SIGN) || (tmp->type == MAGIC_EAR)) |
662 | { |
|
|
663 | if (adjust_sign_msg (pl, x, y, tmp) == -1) |
627 | if (adjust_sign_msg (pl, x, y, tmp) == -1) |
664 | { |
628 | { |
665 | tmp->destroy (); |
629 | tmp->destroy (); |
666 | return; |
630 | return; |
667 | } |
631 | } |
668 | } |
|
|
669 | |
632 | |
670 | 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); |
671 | if (connected) |
634 | if (connected) |
672 | tmp->add_link (pl->map, connected); |
635 | tmp->add_link (pl->map, connected); |
673 | |
636 | |
… | |
… | |
678 | /** |
641 | /** |
679 | * Item remover. |
642 | * Item remover. |
680 | * |
643 | * |
681 | * Removes first buildable item, either under or above the floor |
644 | * Removes first buildable item, either under or above the floor |
682 | */ |
645 | */ |
683 | void |
646 | static void |
684 | apply_builder_remove (object *pl, int dir) |
647 | apply_builder_remove (object *pl, int dir) |
685 | { |
648 | { |
686 | object *item; |
649 | object *item; |
687 | short x, y; |
650 | int x, y; |
688 | |
651 | |
689 | x = pl->x + freearr_x[dir]; |
652 | x = pl->x + freearr_x[dir]; |
690 | y = pl->y + freearr_y[dir]; |
653 | y = pl->y + freearr_y[dir]; |
691 | |
654 | |
692 | /* Check square */ |
655 | /* Check square */ |
… | |
… | |
697 | new_draw_info (NDI_UNIQUE, 0, pl, "Invalid square."); |
660 | new_draw_info (NDI_UNIQUE, 0, pl, "Invalid square."); |
698 | 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); |
699 | return; |
662 | return; |
700 | } |
663 | } |
701 | |
664 | |
702 | if (item->type == FLOOR || QUERY_FLAG (item, FLAG_IS_FLOOR)) |
665 | if (IS_FLOOR (item)) |
703 | item = item->above; |
666 | item = item->above; |
704 | |
667 | |
705 | if (!item) |
668 | if (!item) |
706 | new_draw_info (NDI_UNIQUE, 0, pl, "Nothing to remove."); |
669 | new_draw_info (NDI_UNIQUE, 0, pl, "Nothing to remove."); |
707 | else if (item->type == BUILDABLE_WALL) |
670 | else if (item->type == BUILDABLE_WALL) |
… | |
… | |
713 | new_draw_info_format (NDI_UNIQUE, 0, pl, "You remove the %s", query_name (item)); |
676 | new_draw_info_format (NDI_UNIQUE, 0, pl, "You remove the %s", query_name (item)); |
714 | item->destroy (); |
677 | item->destroy (); |
715 | } |
678 | } |
716 | } |
679 | } |
717 | |
680 | |
|
|
681 | |
|
|
682 | static void |
|
|
683 | replace_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 | */ |
|
|
695 | void |
|
|
696 | apply_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 |
|
|
744 | return; |
|
|
745 | } |
|
|
746 | else if (floor) |
|
|
747 | { |
|
|
748 | |
|
|
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.>"); |
|
|
754 | return; |
|
|
755 | } |
|
|
756 | |
|
|
757 | mapxy above_pos (upper_floor, pos.x, pos.y); |
|
|
758 | if (!above_pos.normalise ()) |
|
|
759 | { |
|
|
760 | pl->failmsg ( |
|
|
761 | "Whoops, you can't access the ceiling. H<You may try again.>"); |
|
|
762 | return; |
|
|
763 | } |
|
|
764 | |
|
|
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 | } |
|
|
777 | |
|
|
778 | replace_open_space_floor (quad_obj, material); |
|
|
779 | break; |
|
|
780 | } |
|
|
781 | } |
|
|
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."); |
|
|
799 | } |
|
|
800 | } |
|
|
801 | |
718 | /** |
802 | /** |
719 | * Global building function |
803 | * Global building function |
720 | * |
804 | * |
721 | * This is the general map building function. Called when the player 'fires' a builder |
805 | * This is the general map building function. Called when the player 'fires' a builder |
722 | * or remover object. |
806 | * or remover object. |
723 | */ |
807 | */ |
724 | void |
808 | void |
725 | apply_map_builder (object *pl, int dir) |
809 | apply_map_builder (object *pl, int dir) |
726 | { |
810 | { |
727 | object *builder; |
|
|
728 | object *tmp; |
|
|
729 | object *tmp2; |
|
|
730 | short x, y; |
|
|
731 | |
|
|
732 | if (!pl->type == PLAYER) |
811 | if (!pl->type == PLAYER) |
733 | return; |
812 | return; |
734 | |
813 | |
735 | /*if ( !player->map->unique ) |
|
|
736 | { |
|
|
737 | new_draw_info( NDI_UNIQUE, 0, player, "You can't build outside a unique map." ); |
|
|
738 | return; |
|
|
739 | } */ |
|
|
740 | |
|
|
741 | if (dir == 0) |
814 | if (dir == 0) |
742 | { |
815 | { |
743 | 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."); |
744 | return; |
817 | return; |
745 | } |
818 | } |
746 | |
819 | |
747 | x = pl->x + freearr_x[dir]; |
820 | mapxy pos (pl); pos.move (dir); |
748 | y = pl->y + freearr_y[dir]; |
|
|
749 | |
821 | |
750 | if ((1 > x) || (1 > y) || ((pl->map->width - 2) < x) || ((pl->map->height - 2) < y)) |
822 | if (!pos.normalise ()) |
751 | { |
823 | { |
752 | 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.>"); |
753 | return; |
825 | return; |
754 | } |
826 | } |
755 | |
827 | |
756 | /* |
828 | /* |
757 | * Check specified square |
829 | * Check specified square |
758 | * The square must have only buildable items |
830 | * The square must have only buildable items |
759 | * Exception: marking runes are all right, |
831 | * Exception: marking runes are all right, |
760 | * since they are used for special things like connecting doors / buttons |
832 | * since they are used for special things like connecting doors / buttons |
761 | */ |
833 | */ |
762 | |
834 | |
763 | tmp = GET_MAP_OB (pl->map, x, y); |
835 | object *builder = pl->contr->ranged_ob; |
764 | if (!tmp) |
836 | |
765 | { |
837 | object *tmp2 = pl->mark (); |
766 | /* Nothing, meaning player is standing next to an undefined square... */ |
838 | |
767 | LOG (llevError, "apply_map_builder: undefined square at (%d, %d, %s)\n", x, y, &pl->map->path); |
839 | object *tmp = 0; |
768 | 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) |
769 | return; |
|
|
770 | } |
841 | { |
771 | |
842 | if (!tmp->flag [FLAG_IS_BUILDABLE] |
772 | tmp2 = find_marked_object (pl); |
|
|
773 | while (tmp) |
|
|
774 | { |
|
|
775 | if (!QUERY_FLAG (tmp, FLAG_IS_BUILDABLE) && (tmp->type != SIGN || tmp->arch->archname != shstr_rune_mark)) |
843 | && (tmp->type != SIGN || tmp->arch->archname != shstr_rune_mark)) |
776 | { |
844 | { |
777 | /* The item building function already has it's own special |
845 | /* The item building function already has it's own special |
778 | * checks for this |
846 | * checks for this. And so does the quad building function. |
779 | */ |
847 | */ |
780 | if ((!tmp2) || (tmp2->subtype != ST_MAT_ITEM)) |
848 | if (!tmp2 || (tmp2->subtype != ST_MAT_ITEM && tmp2->subtype != ST_MAT_QUAD)) |
781 | { |
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))) |
782 | 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 | |
783 | return; |
856 | return; |
784 | } |
857 | } |
785 | } |
858 | } |
786 | tmp = tmp->above; |
|
|
787 | } |
859 | } |
788 | |
860 | |
789 | /* Now we know the square is ok */ |
861 | /* Now we know the square is ok */ |
790 | builder = pl->contr->ranged_ob; |
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; |
791 | |
865 | |
792 | if (builder->subtype == ST_BD_REMOVE) |
866 | if (builder->subtype == ST_BD_REMOVE) |
793 | /* Remover -> call specific function and bail out */ |
867 | /* Remover -> call specific function and bail out */ |
794 | { |
868 | { |
795 | apply_builder_remove (pl, dir); |
869 | apply_builder_remove (pl, dir); |
… | |
… | |
815 | return; |
889 | return; |
816 | } |
890 | } |
817 | |
891 | |
818 | switch (tmp->subtype) |
892 | switch (tmp->subtype) |
819 | { |
893 | { |
820 | case ST_MAT_FLOOR: |
894 | case ST_MAT_FLOOR: |
821 | apply_builder_floor (pl, tmp, x, y); |
895 | apply_builder_floor (pl, tmp, pos.x, pos.y); |
822 | return; |
896 | return; |
823 | |
897 | |
824 | case ST_MAT_WALL: |
898 | case ST_MAT_WALL: |
825 | apply_builder_wall (pl, tmp, x, y); |
899 | apply_builder_wall (pl, tmp, pos.x, pos.y); |
826 | return; |
900 | return; |
827 | |
901 | |
828 | case ST_MAT_ITEM: |
902 | case ST_MAT_ITEM: |
829 | apply_builder_item (pl, tmp, x, y); |
903 | apply_builder_item (pl, tmp, pos.x, pos.y); |
830 | return; |
904 | return; |
831 | |
905 | |
|
|
906 | case ST_MAT_QUAD: |
|
|
907 | apply_builder_quad (pl, tmp, pos); |
|
|
908 | return; |
|
|
909 | |
832 | default: |
910 | default: |
833 | 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."); |
834 | 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); |
835 | return; |
913 | return; |
836 | } |
914 | } |
837 | } |
915 | } |
838 | |
916 | |
839 | /* Here, it means the builder has an invalid type */ |
917 | /* Here, it means the builder has an invalid type */ |
840 | 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."); |
841 | 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); |
842 | } |
920 | } |
843 | |
921 | |
844 | /** |
|
|
845 | * Make the built object inherit the msg of books that are used with it. |
|
|
846 | * For objects already invisible (i.e. magic mouths & ears), also make it |
|
|
847 | * it inherit the face and the name with "talking " prepended. |
|
|
848 | */ |
|
|
849 | int |
|
|
850 | adjust_sign_msg (object *pl, short x, short y, object *tmp) |
|
|
851 | { |
|
|
852 | object *book; |
|
|
853 | char buf[MAX_BUF]; |
|
|
854 | char buf2[MAX_BUF]; |
|
|
855 | |
|
|
856 | book = get_msg_book (pl, x, y); |
|
|
857 | if (!book) |
|
|
858 | { |
|
|
859 | new_draw_info (NDI_UNIQUE, 0, pl, "You need to put a book or scroll with the message."); |
|
|
860 | return -1; |
|
|
861 | } |
|
|
862 | |
|
|
863 | tmp->msg = book->msg; |
|
|
864 | |
|
|
865 | if (tmp->invisible) |
|
|
866 | { |
|
|
867 | if (book->custom_name != NULL) |
|
|
868 | snprintf (buf, sizeof (buf), "talking %s", &book->custom_name); |
|
|
869 | else |
|
|
870 | snprintf (buf, sizeof (buf), "talking %s", &book->name); |
|
|
871 | |
|
|
872 | tmp->name = buf; |
|
|
873 | |
|
|
874 | if (book->name_pl != NULL) |
|
|
875 | { |
|
|
876 | snprintf (buf2, sizeof (buf2), "talking %s", &book->name_pl); |
|
|
877 | tmp->name_pl = buf2; |
|
|
878 | } |
|
|
879 | |
|
|
880 | tmp->face = book->face; |
|
|
881 | tmp->invisible = 0; |
|
|
882 | } |
|
|
883 | |
|
|
884 | book->destroy (); |
|
|
885 | return 0; |
|
|
886 | } |
|
|