1 | |
|
|
2 | /* |
1 | /* |
3 | CrossFire, A Multiplayer game for X-windows |
2 | CrossFire, A Multiplayer game for X-windows |
4 | |
3 | |
5 | Copyright (C) 2001 Mark Wedel & Crossfire Development Team |
4 | Copyright (C) 2001 Mark Wedel & Crossfire Development Team |
6 | Copyright (C) 1992 Frank Tore Johansen |
5 | Copyright (C) 1992 Frank Tore Johansen |
… | |
… | |
17 | |
16 | |
18 | You should have received a copy of the GNU General Public License |
17 | You should have received a copy of the GNU General Public License |
19 | along with this program; if not, write to the Free Software |
18 | along with this program; if not, write to the Free Software |
20 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
19 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
21 | |
20 | |
22 | The authors can be reached via e-mail at crossfire-devel@real-time.com |
21 | The authors can be reached via e-mail at <crossfire@schmorp.de> |
23 | */ |
22 | */ |
24 | |
23 | |
25 | /* Eneq(@csd.uu.se): Added weight-modifiers in environment of objects. |
24 | /* Eneq(@csd.uu.se): Added weight-modifiers in environment of objects. |
26 | sub/add_weight will transcend the environment updating the carrying |
25 | sub/add_weight will transcend the environment updating the carrying |
27 | variable. */ |
26 | variable. */ |
… | |
… | |
32 | #include <object.h> |
31 | #include <object.h> |
33 | #include <funcpoint.h> |
32 | #include <funcpoint.h> |
34 | #include <loader.h> |
33 | #include <loader.h> |
35 | |
34 | |
36 | int nrofallocobjects = 0; |
35 | int nrofallocobjects = 0; |
|
|
36 | static UUID uuid; |
|
|
37 | const uint64 UUID_SKIP = 1<<19; |
37 | |
38 | |
38 | object *objects; /* Pointer to the list of used objects */ |
|
|
39 | object *active_objects; /* List of active objects that need to be processed */ |
39 | object *active_objects; /* List of active objects that need to be processed */ |
40 | |
40 | |
41 | short freearr_x[SIZEOFFREE] = { 0, 0, 1, 1, 1, 0, -1, -1, -1, 0, 1, 2, 2, 2, 2, 2, 1, 0, -1, -2, -2, -2, -2, -2, -1, |
41 | short freearr_x[SIZEOFFREE] = { 0, 0, 1, 1, 1, 0, -1, -1, -1, 0, 1, 2, 2, 2, 2, 2, 1, 0, -1, -2, -2, -2, -2, -2, -1, |
42 | 0, 1, 2, 3, 3, 3, 3, 3, 3, 3, 2, 1, 0, -1, -2, -3, -3, -3, -3, -3, -3, -3, -2, -1 |
42 | 0, 1, 2, 3, 3, 3, 3, 3, 3, 3, 2, 1, 0, -1, -2, -3, -3, -3, -3, -3, -3, -3, -2, -1 |
43 | }; |
43 | }; |
… | |
… | |
49 | }; |
49 | }; |
50 | int freedir[SIZEOFFREE] = { |
50 | int freedir[SIZEOFFREE] = { |
51 | 0, 1, 2, 3, 4, 5, 6, 7, 8, 1, 2, 2, 2, 3, 4, 4, 4, 5, 6, 6, 6, 7, 8, 8, 8, |
51 | 0, 1, 2, 3, 4, 5, 6, 7, 8, 1, 2, 2, 2, 3, 4, 4, 4, 5, 6, 6, 6, 7, 8, 8, 8, |
52 | 1, 2, 2, 2, 2, 2, 3, 4, 4, 4, 4, 4, 5, 6, 6, 6, 6, 6, 7, 8, 8, 8, 8, 8 |
52 | 1, 2, 2, 2, 2, 2, 3, 4, 4, 4, 4, 4, 5, 6, 6, 6, 6, 6, 7, 8, 8, 8, 8, 8 |
53 | }; |
53 | }; |
|
|
54 | |
|
|
55 | static void |
|
|
56 | write_uuid (void) |
|
|
57 | { |
|
|
58 | char filename1[MAX_BUF], filename2[MAX_BUF]; |
|
|
59 | |
|
|
60 | sprintf (filename1, "%s/uuid", settings.localdir); |
|
|
61 | sprintf (filename2, "%s/uuid~", settings.localdir); |
|
|
62 | |
|
|
63 | FILE *fp; |
|
|
64 | |
|
|
65 | if (!(fp = fopen (filename2, "w"))) |
|
|
66 | { |
|
|
67 | LOG (llevError, "ERROR: cannot open %s for writing, unable to write UUID!\n", filename2); |
|
|
68 | return; |
|
|
69 | } |
|
|
70 | |
|
|
71 | fprintf (fp, "<1,%llx>\n", (unsigned long long)uuid.seq + UUID_SKIP * 2); |
|
|
72 | fclose (fp); |
|
|
73 | rename (filename2, filename1); |
|
|
74 | } |
|
|
75 | |
|
|
76 | static void |
|
|
77 | read_uuid (void) |
|
|
78 | { |
|
|
79 | char filename[MAX_BUF]; |
|
|
80 | |
|
|
81 | sprintf (filename, "%s/uuid", settings.localdir); |
|
|
82 | |
|
|
83 | FILE *fp; |
|
|
84 | |
|
|
85 | if (!(fp = fopen (filename, "r"))) |
|
|
86 | { |
|
|
87 | if (errno == ENOENT) |
|
|
88 | { |
|
|
89 | LOG (llevInfo, "RESET uid to 1\n"); |
|
|
90 | uuid.seq = 0; |
|
|
91 | write_uuid (); |
|
|
92 | return; |
|
|
93 | } |
|
|
94 | |
|
|
95 | LOG (llevError, "FATAL: cannot open %s for reading!\n", filename); |
|
|
96 | _exit (1); |
|
|
97 | } |
|
|
98 | |
|
|
99 | int version; |
|
|
100 | unsigned long long uid; |
|
|
101 | if (2 != fscanf (fp, "<%d,%llx>\n", &version, &uid) || version != 1) |
|
|
102 | { |
|
|
103 | LOG (llevError, "FATAL: error reading uid from %s!\n", filename); |
|
|
104 | _exit (1); |
|
|
105 | } |
|
|
106 | |
|
|
107 | uuid.seq = uid; |
|
|
108 | write_uuid (); |
|
|
109 | LOG (llevDebug, "read UID: %" PRId64 "\n", uid); |
|
|
110 | fclose (fp); |
|
|
111 | } |
|
|
112 | |
|
|
113 | UUID |
|
|
114 | gen_uuid () |
|
|
115 | { |
|
|
116 | UUID uid; |
|
|
117 | |
|
|
118 | uid.seq = ++uuid.seq; |
|
|
119 | |
|
|
120 | if (!(uuid.seq & (UUID_SKIP - 1))) |
|
|
121 | write_uuid (); |
|
|
122 | |
|
|
123 | return uid; |
|
|
124 | } |
|
|
125 | |
|
|
126 | void |
|
|
127 | init_uuid () |
|
|
128 | { |
|
|
129 | read_uuid (); |
|
|
130 | } |
54 | |
131 | |
55 | /* Returns TRUE if every key_values in wants has a partner with the same value in has. */ |
132 | /* Returns TRUE if every key_values in wants has a partner with the same value in has. */ |
56 | static int |
133 | static int |
57 | compare_ob_value_lists_one (const object *wants, const object *has) |
134 | compare_ob_value_lists_one (const object *wants, const object *has) |
58 | { |
135 | { |
… | |
… | |
254 | { |
331 | { |
255 | if (inv->inv) |
332 | if (inv->inv) |
256 | sum_weight (inv); |
333 | sum_weight (inv); |
257 | sum += inv->carrying + inv->weight * (inv->nrof ? inv->nrof : 1); |
334 | sum += inv->carrying + inv->weight * (inv->nrof ? inv->nrof : 1); |
258 | } |
335 | } |
|
|
336 | |
259 | if (op->type == CONTAINER && op->stats.Str) |
337 | if (op->type == CONTAINER && op->stats.Str) |
260 | sum = (sum * (100 - op->stats.Str)) / 100; |
338 | sum = (sum * (100 - op->stats.Str)) / 100; |
|
|
339 | |
261 | if (op->carrying != sum) |
340 | if (op->carrying != sum) |
262 | op->carrying = sum; |
341 | op->carrying = sum; |
|
|
342 | |
263 | return sum; |
343 | return sum; |
264 | } |
344 | } |
265 | |
345 | |
266 | /** |
346 | /** |
267 | * Return the outermost environment object for a given object. |
347 | * Return the outermost environment object for a given object. |
… | |
… | |
294 | * Used by: Crossedit: dump. Server DM commands: dumpbelow, dump. |
374 | * Used by: Crossedit: dump. Server DM commands: dumpbelow, dump. |
295 | * Some error messages. |
375 | * Some error messages. |
296 | * The result of the dump is stored in the static global errmsg array. |
376 | * The result of the dump is stored in the static global errmsg array. |
297 | */ |
377 | */ |
298 | |
378 | |
299 | void |
379 | char * |
300 | dump_object2 (object *op) |
|
|
301 | { |
|
|
302 | errmsg[0] = 0; |
|
|
303 | return; |
|
|
304 | //TODO//D#d# |
|
|
305 | #if 0 |
|
|
306 | char *cp; |
|
|
307 | |
|
|
308 | /* object *tmp;*/ |
|
|
309 | |
|
|
310 | if (op->arch != NULL) |
|
|
311 | { |
|
|
312 | strcat (errmsg, "arch "); |
|
|
313 | strcat (errmsg, op->arch->name ? op->arch->name : "(null)"); |
|
|
314 | strcat (errmsg, "\n"); |
|
|
315 | if ((cp = get_ob_diff (op, &empty_archetype->clone)) != NULL) |
|
|
316 | strcat (errmsg, cp); |
|
|
317 | # if 0 |
|
|
318 | /* Don't dump player diffs - they are too long, mostly meaningless, and |
|
|
319 | * will overflow the buffer. |
|
|
320 | * Changed so that we don't dump inventory either. This may |
|
|
321 | * also overflow the buffer. |
|
|
322 | */ |
|
|
323 | if (op->type != PLAYER && (cp = get_ob_diff (op, &empty_archetype->clone)) != NULL) |
|
|
324 | strcat (errmsg, cp); |
|
|
325 | for (tmp = op->inv; tmp; tmp = tmp->below) |
|
|
326 | dump_object2 (tmp); |
|
|
327 | # endif |
|
|
328 | strcat (errmsg, "end\n"); |
|
|
329 | } |
|
|
330 | else |
|
|
331 | { |
|
|
332 | strcat (errmsg, "Object "); |
|
|
333 | if (op->name == NULL) |
|
|
334 | strcat (errmsg, "(null)"); |
|
|
335 | else |
|
|
336 | strcat (errmsg, op->name); |
|
|
337 | strcat (errmsg, "\n"); |
|
|
338 | # if 0 |
|
|
339 | if ((cp = get_ob_diff (op, &empty_archetype->clone)) != NULL) |
|
|
340 | strcat (errmsg, cp); |
|
|
341 | for (tmp = op->inv; tmp; tmp = tmp->below) |
|
|
342 | dump_object2 (tmp); |
|
|
343 | # endif |
|
|
344 | strcat (errmsg, "end\n"); |
|
|
345 | } |
|
|
346 | #endif |
|
|
347 | } |
|
|
348 | |
|
|
349 | /* |
|
|
350 | * Dumps an object. Returns output in the static global errmsg array. |
|
|
351 | */ |
|
|
352 | |
|
|
353 | void |
|
|
354 | dump_object (object *op) |
380 | dump_object (object *op) |
355 | { |
381 | { |
356 | if (op == NULL) |
382 | if (!op) |
357 | { |
383 | return strdup ("[NULLOBJ]"); |
358 | strcpy (errmsg, "[NULL pointer]"); |
|
|
359 | return; |
|
|
360 | } |
|
|
361 | errmsg[0] = '\0'; |
|
|
362 | dump_object2 (op); |
|
|
363 | } |
|
|
364 | |
384 | |
365 | void |
385 | object_freezer freezer; |
366 | dump_all_objects (void) |
386 | save_object (freezer, op, 3); |
367 | { |
387 | return freezer.as_string (); |
368 | object *op; |
|
|
369 | |
|
|
370 | for (op = objects; op != NULL; op = op->next) |
|
|
371 | { |
|
|
372 | dump_object (op); |
|
|
373 | fprintf (logfile, "Object %d\n:%s\n", op->count, errmsg); |
|
|
374 | } |
|
|
375 | } |
388 | } |
376 | |
389 | |
377 | /* |
390 | /* |
378 | * get_nearest_part(multi-object, object 2) returns the part of the |
391 | * get_nearest_part(multi-object, object 2) returns the part of the |
379 | * multi-object 1 which is closest to the second object. |
392 | * multi-object 1 which is closest to the second object. |
… | |
… | |
399 | */ |
412 | */ |
400 | |
413 | |
401 | object * |
414 | object * |
402 | find_object (tag_t i) |
415 | find_object (tag_t i) |
403 | { |
416 | { |
404 | object *op; |
417 | for (object *op = object::first; op; op = op->next) |
405 | |
|
|
406 | for (op = objects; op != NULL; op = op->next) |
|
|
407 | if (op->count == i) |
418 | if (op->count == i) |
408 | break; |
419 | return op; |
|
|
420 | |
409 | return op; |
421 | return 0; |
410 | } |
422 | } |
411 | |
423 | |
412 | /* |
424 | /* |
413 | * Returns the first object which has a name equal to the argument. |
425 | * Returns the first object which has a name equal to the argument. |
414 | * Used only by the patch command, but not all that useful. |
426 | * Used only by the patch command, but not all that useful. |
… | |
… | |
419 | find_object_name (const char *str) |
431 | find_object_name (const char *str) |
420 | { |
432 | { |
421 | shstr_cmp str_ (str); |
433 | shstr_cmp str_ (str); |
422 | object *op; |
434 | object *op; |
423 | |
435 | |
424 | for (op = objects; op != NULL; op = op->next) |
436 | for (op = object::first; op != NULL; op = op->next) |
425 | if (op->name == str_) |
437 | if (op->name == str_) |
426 | break; |
438 | break; |
427 | |
439 | |
428 | return op; |
440 | return op; |
429 | } |
441 | } |
430 | |
442 | |
431 | void |
443 | void |
432 | free_all_object_data () |
444 | free_all_object_data () |
433 | { |
445 | { |
434 | LOG (llevDebug, "%d allocated objects\n", nrofallocobjects); |
446 | LOG (llevDebug, "%d allocated objects\n", nrofallocobjects); |
435 | } |
|
|
436 | |
|
|
437 | /* |
|
|
438 | * Returns the object which this object marks as being the owner. |
|
|
439 | * A id-scheme is used to avoid pointing to objects which have been |
|
|
440 | * freed and are now reused. If this is detected, the owner is |
|
|
441 | * set to NULL, and NULL is returned. |
|
|
442 | * Changed 2004-02-12 - if the player is setting at the play again |
|
|
443 | * prompt, he is removed, and we don't want to treat him as an owner of |
|
|
444 | * anything, so check removed flag. I don't expect that this should break |
|
|
445 | * anything - once an object is removed, it is basically dead anyways. |
|
|
446 | */ |
|
|
447 | object * |
|
|
448 | object::get_owner () |
|
|
449 | { |
|
|
450 | if (!owner |
|
|
451 | || QUERY_FLAG (owner, FLAG_FREED) |
|
|
452 | || QUERY_FLAG (owner, FLAG_REMOVED)) |
|
|
453 | owner = 0; |
|
|
454 | |
|
|
455 | return owner; |
|
|
456 | } |
447 | } |
457 | |
448 | |
458 | /* |
449 | /* |
459 | * Sets the owner and sets the skill and exp pointers to owner's current |
450 | * Sets the owner and sets the skill and exp pointers to owner's current |
460 | * skill and experience objects. |
451 | * skill and experience objects. |
… | |
… | |
530 | |
521 | |
531 | /* What is not cleared is next, prev, and count */ |
522 | /* What is not cleared is next, prev, and count */ |
532 | |
523 | |
533 | expmul = 1.0; |
524 | expmul = 1.0; |
534 | face = blank_face; |
525 | face = blank_face; |
535 | attacked_by_count = -1; |
|
|
536 | |
526 | |
537 | if (settings.casting_time) |
527 | if (settings.casting_time) |
538 | casting_time = -1; |
528 | casting_time = -1; |
539 | } |
529 | } |
540 | |
530 | |
… | |
… | |
563 | |
553 | |
564 | op2->clone (op); |
554 | op2->clone (op); |
565 | |
555 | |
566 | if (is_freed) |
556 | if (is_freed) |
567 | SET_FLAG (op, FLAG_FREED); |
557 | SET_FLAG (op, FLAG_FREED); |
|
|
558 | |
568 | if (is_removed) |
559 | if (is_removed) |
569 | SET_FLAG (op, FLAG_REMOVED); |
560 | SET_FLAG (op, FLAG_REMOVED); |
570 | |
561 | |
571 | if (op2->speed < 0) |
562 | if (op2->speed < 0) |
572 | op->speed_left = op2->speed_left - RANDOM () % 200 / 100.0; |
563 | op->speed_left = op2->speed_left - RANDOM () % 200 / 100.0; |
… | |
… | |
814 | update_now = 1; |
805 | update_now = 1; |
815 | |
806 | |
816 | if ((move_slow | op->move_slow) != move_slow) |
807 | if ((move_slow | op->move_slow) != move_slow) |
817 | update_now = 1; |
808 | update_now = 1; |
818 | } |
809 | } |
|
|
810 | |
819 | /* if the object is being removed, we can't make intelligent |
811 | /* if the object is being removed, we can't make intelligent |
820 | * decisions, because remove_ob can't really pass the object |
812 | * decisions, because remove_ob can't really pass the object |
821 | * that is being removed. |
813 | * that is being removed. |
822 | */ |
814 | */ |
823 | else if (action == UP_OBJ_CHANGE || action == UP_OBJ_REMOVE) |
815 | else if (action == UP_OBJ_CHANGE || action == UP_OBJ_REMOVE) |
… | |
… | |
835 | |
827 | |
836 | if (op->more != NULL) |
828 | if (op->more != NULL) |
837 | update_object (op->more, action); |
829 | update_object (op->more, action); |
838 | } |
830 | } |
839 | |
831 | |
840 | static unordered_vector<object *> mortals; |
832 | object::vector object::mortals; |
841 | static std::vector<object *> freed; |
833 | object::vector object::objects; // not yet used |
|
|
834 | object *object::first; |
842 | |
835 | |
843 | void object::free_mortals () |
836 | void object::free_mortals () |
844 | { |
837 | { |
845 | for (unordered_vector<object *>::iterator i = mortals.begin (); i != mortals.end ();) |
838 | for (AUTODECL (i, mortals.begin ()); i != mortals.end ();) |
846 | if ((*i)->refcnt) |
839 | if ((*i)->refcnt) |
847 | ++i; // further delay freeing |
840 | ++i; // further delay freeing |
848 | else |
841 | else |
849 | { |
842 | { |
850 | freed.push_back (*i);//D |
|
|
851 | //delete *i; |
843 | delete *i; |
852 | mortals.erase (i); |
844 | mortals.erase (i); |
853 | } |
845 | } |
854 | |
|
|
855 | if (mortals.size() && 0)//D |
|
|
856 | LOG (llevDebug, "%d objects in mortal queue\n", mortals.size());//D |
|
|
857 | } |
846 | } |
858 | |
847 | |
859 | object::object () |
848 | object::object () |
860 | { |
849 | { |
861 | SET_FLAG (this, FLAG_REMOVED); |
850 | SET_FLAG (this, FLAG_REMOVED); |
862 | |
851 | |
863 | expmul = 1.0; |
852 | expmul = 1.0; |
864 | face = blank_face; |
853 | face = blank_face; |
865 | attacked_by_count = -1; |
|
|
866 | } |
854 | } |
867 | |
855 | |
868 | object::~object () |
856 | object::~object () |
869 | { |
857 | { |
870 | free_key_values (this); |
858 | free_key_values (this); |
871 | } |
859 | } |
872 | |
860 | |
873 | void object::link () |
861 | void object::link () |
874 | { |
862 | { |
875 | count = ++ob_count; |
863 | count = ++ob_count; |
|
|
864 | uuid = gen_uuid (); |
876 | |
865 | |
877 | prev = 0; |
866 | prev = 0; |
878 | next = objects; |
867 | next = object::first; |
879 | |
868 | |
880 | if (objects) |
869 | if (object::first) |
881 | objects->prev = this; |
870 | object::first->prev = this; |
882 | |
871 | |
883 | objects = this; |
872 | object::first = this; |
884 | } |
873 | } |
885 | |
874 | |
886 | void object::unlink () |
875 | void object::unlink () |
887 | { |
876 | { |
888 | count = 0; |
877 | if (this == object::first) |
|
|
878 | object::first = next; |
889 | |
879 | |
890 | /* Remove this object from the list of used objects */ |
880 | /* Remove this object from the list of used objects */ |
891 | if (prev) |
|
|
892 | { |
|
|
893 | prev->next = next; |
881 | if (prev) prev->next = next; |
|
|
882 | if (next) next->prev = prev; |
|
|
883 | |
894 | prev = 0; |
884 | prev = 0; |
895 | } |
|
|
896 | |
|
|
897 | if (next) |
|
|
898 | { |
|
|
899 | next->prev = prev; |
|
|
900 | next = 0; |
885 | next = 0; |
901 | } |
|
|
902 | |
|
|
903 | if (this == objects) |
|
|
904 | objects = next; |
|
|
905 | } |
886 | } |
906 | |
887 | |
907 | object *object::create () |
888 | object *object::create () |
908 | { |
889 | { |
909 | object *op; |
|
|
910 | |
|
|
911 | if (freed.empty ()) |
|
|
912 | op = new object; |
890 | object *op = new object; |
913 | else |
|
|
914 | { |
|
|
915 | // highly annoying, but the only way to get it stable right now |
|
|
916 | op = freed.back (); |
|
|
917 | freed.pop_back (); |
|
|
918 | op->~object (); |
|
|
919 | new ((void *) op) object; |
|
|
920 | } |
|
|
921 | |
|
|
922 | op->link (); |
891 | op->link (); |
923 | return op; |
892 | return op; |
924 | } |
893 | } |
925 | |
894 | |
926 | /* |
895 | /* |
… | |
… | |
928 | * it from the list of used objects, and puts it on the list of |
897 | * it from the list of used objects, and puts it on the list of |
929 | * free objects. The IS_FREED() flag is set in the object. |
898 | * free objects. The IS_FREED() flag is set in the object. |
930 | * The object must have been removed by remove_ob() first for |
899 | * The object must have been removed by remove_ob() first for |
931 | * this function to succeed. |
900 | * this function to succeed. |
932 | * |
901 | * |
933 | * If free_inventory is set, free inventory as well. Else drop items in |
902 | * If destroy_inventory is set, free inventory as well. Else drop items in |
934 | * inventory to the ground. |
903 | * inventory to the ground. |
935 | */ |
904 | */ |
936 | void object::free (bool free_inventory) |
905 | void object::destroy (bool destroy_inventory) |
937 | { |
906 | { |
938 | if (QUERY_FLAG (this, FLAG_FREED)) |
907 | if (QUERY_FLAG (this, FLAG_FREED)) |
939 | return; |
908 | return; |
940 | |
909 | |
941 | if (QUERY_FLAG (this, FLAG_FRIENDLY)) |
910 | if (QUERY_FLAG (this, FLAG_FRIENDLY)) |
… | |
… | |
946 | |
915 | |
947 | SET_FLAG (this, FLAG_FREED); |
916 | SET_FLAG (this, FLAG_FREED); |
948 | |
917 | |
949 | if (more) |
918 | if (more) |
950 | { |
919 | { |
951 | more->free (free_inventory); |
920 | more->destroy (destroy_inventory); |
952 | more = 0; |
921 | more = 0; |
953 | } |
922 | } |
954 | |
923 | |
955 | if (inv) |
924 | if (inv) |
956 | { |
925 | { |
957 | /* Only if the space blocks everything do we not process - |
926 | /* Only if the space blocks everything do we not process - |
958 | * if some form of movement is allowed, let objects |
927 | * if some form of movement is allowed, let objects |
959 | * drop on that space. |
928 | * drop on that space. |
960 | */ |
929 | */ |
961 | if (free_inventory || !map || map->in_memory != MAP_IN_MEMORY || GET_MAP_MOVE_BLOCK (map, x, y) == MOVE_ALL) |
930 | if (destroy_inventory || !map || map->in_memory != MAP_IN_MEMORY || GET_MAP_MOVE_BLOCK (map, x, y) == MOVE_ALL) |
962 | { |
931 | { |
963 | object *op = inv; |
932 | object *op = inv; |
964 | |
933 | |
965 | while (op) |
934 | while (op) |
966 | { |
935 | { |
967 | object *tmp = op->below; |
936 | object *tmp = op->below; |
968 | op->free (free_inventory); |
937 | op->destroy (destroy_inventory); |
969 | op = tmp; |
938 | op = tmp; |
970 | } |
939 | } |
971 | } |
940 | } |
972 | else |
941 | else |
973 | { /* Put objects in inventory onto this space */ |
942 | { /* Put objects in inventory onto this space */ |
… | |
… | |
992 | op = tmp; |
961 | op = tmp; |
993 | } |
962 | } |
994 | } |
963 | } |
995 | } |
964 | } |
996 | |
965 | |
|
|
966 | // hack to ensure that freed objects still have a valid map |
|
|
967 | { |
|
|
968 | static maptile *freed_map; // freed objects are moved here to avoid crashes |
|
|
969 | |
|
|
970 | if (!freed_map) |
|
|
971 | { |
|
|
972 | freed_map = new maptile; |
|
|
973 | |
|
|
974 | freed_map->name = "/internal/freed_objects_map"; |
|
|
975 | freed_map->width = 3; |
|
|
976 | freed_map->height = 3; |
|
|
977 | |
|
|
978 | freed_map->allocate (); |
|
|
979 | } |
|
|
980 | |
|
|
981 | map = freed_map; |
|
|
982 | x = 1; |
|
|
983 | y = 1; |
|
|
984 | } |
|
|
985 | |
|
|
986 | // clear those pointers that likely might have circular references to us |
997 | owner = 0; |
987 | owner = 0; |
|
|
988 | enemy = 0; |
|
|
989 | attacked_by = 0; |
|
|
990 | |
|
|
991 | // only relevant for players(?), but make sure of it anyways |
|
|
992 | contr = 0; |
998 | |
993 | |
999 | /* Remove object from the active list */ |
994 | /* Remove object from the active list */ |
1000 | speed = 0; |
995 | speed = 0; |
1001 | update_ob_speed (this); |
996 | update_ob_speed (this); |
1002 | |
997 | |
… | |
… | |
1007 | |
1002 | |
1008 | /* |
1003 | /* |
1009 | * sub_weight() recursively (outwards) subtracts a number from the |
1004 | * sub_weight() recursively (outwards) subtracts a number from the |
1010 | * weight of an object (and what is carried by it's environment(s)). |
1005 | * weight of an object (and what is carried by it's environment(s)). |
1011 | */ |
1006 | */ |
1012 | |
|
|
1013 | void |
1007 | void |
1014 | sub_weight (object *op, signed long weight) |
1008 | sub_weight (object *op, signed long weight) |
1015 | { |
1009 | { |
1016 | while (op != NULL) |
1010 | while (op != NULL) |
1017 | { |
1011 | { |
1018 | if (op->type == CONTAINER) |
1012 | if (op->type == CONTAINER) |
1019 | { |
|
|
1020 | weight = (signed long) (weight * (100 - op->stats.Str) / 100); |
1013 | weight = (signed long) (weight * (100 - op->stats.Str) / 100); |
1021 | } |
1014 | |
1022 | op->carrying -= weight; |
1015 | op->carrying -= weight; |
1023 | op = op->env; |
1016 | op = op->env; |
1024 | } |
1017 | } |
1025 | } |
1018 | } |
1026 | |
1019 | |
… | |
… | |
1030 | * object will have no environment. If the object previously had an |
1023 | * object will have no environment. If the object previously had an |
1031 | * environment, the x and y coordinates will be updated to |
1024 | * environment, the x and y coordinates will be updated to |
1032 | * the previous environment. |
1025 | * the previous environment. |
1033 | * Beware: This function is called from the editor as well! |
1026 | * Beware: This function is called from the editor as well! |
1034 | */ |
1027 | */ |
1035 | |
|
|
1036 | void |
1028 | void |
1037 | remove_ob (object *op) |
1029 | object::remove () |
1038 | { |
1030 | { |
|
|
1031 | object *tmp, *last = 0; |
1039 | object * |
1032 | object *otmp; |
1040 | tmp, * |
|
|
1041 | last = NULL; |
|
|
1042 | object * |
|
|
1043 | otmp; |
|
|
1044 | |
1033 | |
1045 | tag_t |
|
|
1046 | tag; |
|
|
1047 | int |
|
|
1048 | check_walk_off; |
1034 | int check_walk_off; |
1049 | mapstruct * |
|
|
1050 | m; |
|
|
1051 | |
1035 | |
1052 | sint16 |
|
|
1053 | x, |
|
|
1054 | y; |
|
|
1055 | |
|
|
1056 | if (QUERY_FLAG (op, FLAG_REMOVED)) |
1036 | if (QUERY_FLAG (this, FLAG_REMOVED)) |
1057 | return; |
1037 | return; |
1058 | |
1038 | |
1059 | SET_FLAG (op, FLAG_REMOVED); |
1039 | SET_FLAG (this, FLAG_REMOVED); |
1060 | |
1040 | |
1061 | if (op->more != NULL) |
1041 | if (more) |
1062 | remove_ob (op->more); |
1042 | more->remove (); |
1063 | |
1043 | |
1064 | /* |
1044 | /* |
1065 | * In this case, the object to be removed is in someones |
1045 | * In this case, the object to be removed is in someones |
1066 | * inventory. |
1046 | * inventory. |
1067 | */ |
1047 | */ |
1068 | if (op->env != NULL) |
1048 | if (env) |
1069 | { |
1049 | { |
1070 | if (op->nrof) |
1050 | if (nrof) |
1071 | sub_weight (op->env, op->weight * op->nrof); |
1051 | sub_weight (env, weight * nrof); |
1072 | else |
1052 | else |
1073 | sub_weight (op->env, op->weight + op->carrying); |
1053 | sub_weight (env, weight + carrying); |
1074 | |
1054 | |
1075 | /* NO_FIX_PLAYER is set when a great many changes are being |
1055 | /* NO_FIX_PLAYER is set when a great many changes are being |
1076 | * made to players inventory. If set, avoiding the call |
1056 | * made to players inventory. If set, avoiding the call |
1077 | * to save cpu time. |
1057 | * to save cpu time. |
1078 | */ |
1058 | */ |
1079 | if ((otmp = is_player_inv (op->env)) != NULL && otmp->contr && !QUERY_FLAG (otmp, FLAG_NO_FIX_PLAYER)) |
1059 | if ((otmp = is_player_inv (env)) != NULL && otmp->contr && !QUERY_FLAG (otmp, FLAG_NO_FIX_PLAYER)) |
1080 | fix_player (otmp); |
1060 | fix_player (otmp); |
1081 | |
1061 | |
1082 | if (op->above != NULL) |
1062 | if (above != NULL) |
1083 | op->above->below = op->below; |
1063 | above->below = below; |
1084 | else |
1064 | else |
1085 | op->env->inv = op->below; |
1065 | env->inv = below; |
1086 | |
1066 | |
1087 | if (op->below != NULL) |
1067 | if (below != NULL) |
1088 | op->below->above = op->above; |
1068 | below->above = above; |
1089 | |
1069 | |
1090 | /* we set up values so that it could be inserted into |
1070 | /* we set up values so that it could be inserted into |
1091 | * the map, but we don't actually do that - it is up |
1071 | * the map, but we don't actually do that - it is up |
1092 | * to the caller to decide what we want to do. |
1072 | * to the caller to decide what we want to do. |
1093 | */ |
1073 | */ |
1094 | op->x = op->env->x, op->y = op->env->y; |
1074 | x = env->x, y = env->y; |
1095 | op->map = op->env->map; |
1075 | map = env->map; |
1096 | op->above = NULL, op->below = NULL; |
1076 | above = 0, below = 0; |
1097 | op->env = NULL; |
1077 | env = 0; |
1098 | } |
1078 | } |
1099 | else if (op->map) |
1079 | else if (map) |
1100 | { |
1080 | { |
1101 | x = op->x; |
|
|
1102 | y = op->y; |
|
|
1103 | m = get_map_from_coord (op->map, &x, &y); |
|
|
1104 | |
|
|
1105 | if (!m) |
|
|
1106 | { |
|
|
1107 | LOG (llevError, "remove_ob called when object was on map but appears to not be within valid coordinates? %s (%d,%d)\n", |
|
|
1108 | op->map->path, op->x, op->y); |
|
|
1109 | /* in old days, we used to set x and y to 0 and continue. |
|
|
1110 | * it seems if we get into this case, something is probablye |
|
|
1111 | * screwed up and should be fixed. |
|
|
1112 | */ |
|
|
1113 | abort (); |
|
|
1114 | } |
|
|
1115 | |
|
|
1116 | if (op->map != m) |
|
|
1117 | LOG (llevDebug, "remove_ob: Object not really on map it claimed to be on? %s != %s, %d,%d != %d,%d\n", |
|
|
1118 | op->map->path, m->path, op->x, op->y, x, y); |
|
|
1119 | |
|
|
1120 | /* Re did the following section of code - it looks like it had |
1081 | /* Re did the following section of code - it looks like it had |
1121 | * lots of logic for things we no longer care about |
1082 | * lots of logic for things we no longer care about |
1122 | */ |
1083 | */ |
1123 | |
1084 | |
1124 | /* link the object above us */ |
1085 | /* link the object above us */ |
1125 | if (op->above) |
1086 | if (above) |
1126 | op->above->below = op->below; |
1087 | above->below = below; |
1127 | else |
1088 | else |
1128 | SET_MAP_TOP (m, x, y, op->below); /* we were top, set new top */ |
1089 | SET_MAP_TOP (map, x, y, below); /* we were top, set new top */ |
1129 | |
1090 | |
1130 | /* Relink the object below us, if there is one */ |
1091 | /* Relink the object below us, if there is one */ |
1131 | if (op->below) |
1092 | if (below) |
1132 | op->below->above = op->above; |
1093 | below->above = above; |
1133 | else |
1094 | else |
1134 | { |
1095 | { |
1135 | /* Nothing below, which means we need to relink map object for this space |
1096 | /* Nothing below, which means we need to relink map object for this space |
1136 | * use translated coordinates in case some oddness with map tiling is |
1097 | * use translated coordinates in case some oddness with map tiling is |
1137 | * evident |
1098 | * evident |
1138 | */ |
1099 | */ |
1139 | if (GET_MAP_OB (m, x, y) != op) |
1100 | if (GET_MAP_OB (map, x, y) != this) |
1140 | { |
1101 | { |
1141 | dump_object (op); |
1102 | char *dump = dump_object (this); |
1142 | LOG (llevError, |
1103 | LOG (llevError, |
1143 | "remove_ob: GET_MAP_OB does not return object to be removed even though it appears to be on the bottom?\n%s\n", errmsg); |
1104 | "remove_ob: GET_MAP_OB does not return object to be removed even though it appears to be on the bottom?\n%s\n", dump); |
|
|
1105 | free (dump); |
1144 | dump_object (GET_MAP_OB (m, x, y)); |
1106 | dump = dump_object (GET_MAP_OB (map, x, y)); |
1145 | LOG (llevError, "%s\n", errmsg); |
1107 | LOG (llevError, "%s\n", dump); |
|
|
1108 | free (dump); |
1146 | } |
1109 | } |
1147 | |
1110 | |
1148 | SET_MAP_OB (m, x, y, op->above); /* goes on above it. */ |
1111 | SET_MAP_OB (map, x, y, above); /* goes on above it. */ |
1149 | } |
1112 | } |
1150 | |
1113 | |
1151 | op->above = 0; |
1114 | above = 0; |
1152 | op->below = 0; |
1115 | below = 0; |
1153 | |
1116 | |
1154 | if (op->map->in_memory == MAP_SAVING) |
1117 | if (map->in_memory == MAP_SAVING) |
1155 | return; |
1118 | return; |
1156 | |
1119 | |
1157 | tag = op->count; |
|
|
1158 | check_walk_off = !QUERY_FLAG (op, FLAG_NO_APPLY); |
1120 | check_walk_off = !QUERY_FLAG (this, FLAG_NO_APPLY); |
1159 | |
1121 | |
1160 | for (tmp = GET_MAP_OB (m, x, y); tmp != NULL; tmp = tmp->above) |
1122 | for (tmp = GET_MAP_OB (map, x, y); tmp; tmp = tmp->above) |
1161 | { |
1123 | { |
1162 | /* No point updating the players look faces if he is the object |
1124 | /* No point updating the players look faces if he is the object |
1163 | * being removed. |
1125 | * being removed. |
1164 | */ |
1126 | */ |
1165 | |
1127 | |
1166 | if (tmp->type == PLAYER && tmp != op) |
1128 | if (tmp->type == PLAYER && tmp != this) |
1167 | { |
1129 | { |
1168 | /* If a container that the player is currently using somehow gets |
1130 | /* If a container that the player is currently using somehow gets |
1169 | * removed (most likely destroyed), update the player view |
1131 | * removed (most likely destroyed), update the player view |
1170 | * appropriately. |
1132 | * appropriately. |
1171 | */ |
1133 | */ |
1172 | if (tmp->container == op) |
1134 | if (tmp->container == this) |
1173 | { |
1135 | { |
1174 | CLEAR_FLAG (op, FLAG_APPLIED); |
1136 | CLEAR_FLAG (this, FLAG_APPLIED); |
1175 | tmp->container = NULL; |
1137 | tmp->container = 0; |
1176 | } |
1138 | } |
1177 | |
1139 | |
1178 | tmp->contr->socket.update_look = 1; |
1140 | tmp->contr->socket.update_look = 1; |
1179 | } |
1141 | } |
1180 | |
1142 | |
1181 | /* See if player moving off should effect something */ |
1143 | /* See if player moving off should effect something */ |
1182 | if (check_walk_off && ((op->move_type & tmp->move_off) && (op->move_type & ~tmp->move_off & ~tmp->move_block) == 0)) |
1144 | if (check_walk_off |
|
|
1145 | && ((move_type & tmp->move_off) |
|
|
1146 | && (move_type & ~tmp->move_off & ~tmp->move_block) == 0)) |
1183 | { |
1147 | { |
1184 | move_apply (tmp, op, NULL); |
1148 | move_apply (tmp, this, 0); |
1185 | |
1149 | |
1186 | if (was_destroyed (op, tag)) |
1150 | if (destroyed ()) |
1187 | { |
|
|
1188 | LOG (llevError, "BUG: remove_ob(): name %s, archname %s destroyed " "leaving object\n", &tmp->name, &tmp->arch->name); |
1151 | LOG (llevError, "BUG: remove_ob(): name %s, destroyed leaving object\n", tmp->debug_desc ()); |
1189 | } |
|
|
1190 | } |
1152 | } |
1191 | |
1153 | |
1192 | /* Eneq(@csd.uu.se): Fixed this to skip tmp->above=tmp */ |
1154 | /* Eneq(@csd.uu.se): Fixed this to skip tmp->above=tmp */ |
1193 | |
1155 | |
1194 | if (tmp->above == tmp) |
1156 | if (tmp->above == tmp) |
1195 | tmp->above = NULL; |
1157 | tmp->above = 0; |
1196 | |
1158 | |
1197 | last = tmp; |
1159 | last = tmp; |
1198 | } |
1160 | } |
1199 | |
1161 | |
1200 | /* last == NULL of there are no objects on this space */ |
1162 | /* last == NULL of there are no objects on this space */ |
1201 | if (last == NULL) |
1163 | if (!last) |
1202 | { |
1164 | { |
1203 | /* set P_NEED_UPDATE, otherwise update_position will complain. In theory, |
1165 | /* set P_NEED_UPDATE, otherwise update_position will complain. In theory, |
1204 | * we could preserve the flags (GET_MAP_FLAGS), but update_position figures |
1166 | * we could preserve the flags (GET_MAP_FLAGS), but update_position figures |
1205 | * those out anyways, and if there are any flags set right now, they won't |
1167 | * those out anyways, and if there are any flags set right now, they won't |
1206 | * be correct anyways. |
1168 | * be correct anyways. |
1207 | */ |
1169 | */ |
1208 | SET_MAP_FLAGS (op->map, op->x, op->y, P_NEED_UPDATE); |
1170 | SET_MAP_FLAGS (map, x, y, P_NEED_UPDATE); |
1209 | update_position (op->map, op->x, op->y); |
1171 | update_position (map, x, y); |
1210 | } |
1172 | } |
1211 | else |
1173 | else |
1212 | update_object (last, UP_OBJ_REMOVE); |
1174 | update_object (last, UP_OBJ_REMOVE); |
1213 | |
1175 | |
1214 | if (QUERY_FLAG (op, FLAG_BLOCKSVIEW) || (op->glow_radius != 0)) |
1176 | if (QUERY_FLAG (this, FLAG_BLOCKSVIEW) || glow_radius) |
1215 | update_all_los (op->map, op->x, op->y); |
1177 | update_all_los (map, x, y); |
1216 | } |
1178 | } |
1217 | } |
1179 | } |
1218 | |
1180 | |
1219 | /* |
1181 | /* |
1220 | * merge_ob(op,top): |
1182 | * merge_ob(op,top): |
… | |
… | |
1222 | * This function goes through all objects below and including top, and |
1184 | * This function goes through all objects below and including top, and |
1223 | * merges op to the first matching object. |
1185 | * merges op to the first matching object. |
1224 | * If top is NULL, it is calculated. |
1186 | * If top is NULL, it is calculated. |
1225 | * Returns pointer to object if it succeded in the merge, otherwise NULL |
1187 | * Returns pointer to object if it succeded in the merge, otherwise NULL |
1226 | */ |
1188 | */ |
1227 | |
|
|
1228 | object * |
1189 | object * |
1229 | merge_ob (object *op, object *top) |
1190 | merge_ob (object *op, object *top) |
1230 | { |
1191 | { |
1231 | if (!op->nrof) |
1192 | if (!op->nrof) |
1232 | return 0; |
1193 | return 0; |
… | |
… | |
1248 | free_object (op); |
1209 | free_object (op); |
1249 | return top; |
1210 | return top; |
1250 | } |
1211 | } |
1251 | } |
1212 | } |
1252 | |
1213 | |
1253 | return NULL; |
1214 | return 0; |
1254 | } |
1215 | } |
1255 | |
1216 | |
1256 | /* |
1217 | /* |
1257 | * same as insert_ob_in_map except it handle separate coordinates and do a clean |
1218 | * same as insert_ob_in_map except it handle separate coordinates and do a clean |
1258 | * job preparing multi-part monsters |
1219 | * job preparing multi-part monsters |
1259 | */ |
1220 | */ |
1260 | object * |
1221 | object * |
1261 | insert_ob_in_map_at (object *op, mapstruct *m, object *originator, int flag, int x, int y) |
1222 | insert_ob_in_map_at (object *op, maptile *m, object *originator, int flag, int x, int y) |
1262 | { |
1223 | { |
1263 | object *tmp; |
1224 | object *tmp; |
1264 | |
1225 | |
1265 | if (op->head) |
1226 | if (op->head) |
1266 | op = op->head; |
1227 | op = op->head; |
… | |
… | |
1294 | * NULL if 'op' was destroyed |
1255 | * NULL if 'op' was destroyed |
1295 | * just 'op' otherwise |
1256 | * just 'op' otherwise |
1296 | */ |
1257 | */ |
1297 | |
1258 | |
1298 | object * |
1259 | object * |
1299 | insert_ob_in_map (object *op, mapstruct *m, object *originator, int flag) |
1260 | insert_ob_in_map (object *op, maptile *m, object *originator, int flag) |
1300 | { |
1261 | { |
1301 | object *tmp, *top, *floor = NULL; |
1262 | object *tmp, *top, *floor = NULL; |
1302 | sint16 x, y; |
1263 | sint16 x, y; |
1303 | |
1264 | |
1304 | if (QUERY_FLAG (op, FLAG_FREED)) |
1265 | if (QUERY_FLAG (op, FLAG_FREED)) |
… | |
… | |
1307 | return NULL; |
1268 | return NULL; |
1308 | } |
1269 | } |
1309 | |
1270 | |
1310 | if (m == NULL) |
1271 | if (m == NULL) |
1311 | { |
1272 | { |
1312 | dump_object (op); |
1273 | char *dump = dump_object (op); |
1313 | LOG (llevError, "Trying to insert in null-map!\n%s\n", errmsg); |
1274 | LOG (llevError, "Trying to insert in null-map!\n%s\n", dump); |
|
|
1275 | free (dump); |
1314 | return op; |
1276 | return op; |
1315 | } |
1277 | } |
1316 | |
1278 | |
1317 | if (out_of_map (m, op->x, op->y)) |
1279 | if (out_of_map (m, op->x, op->y)) |
1318 | { |
1280 | { |
1319 | dump_object (op); |
1281 | char *dump = dump_object (op); |
1320 | LOG (llevError, "Trying to insert object outside the map.\n%s\n", errmsg); |
1282 | LOG (llevError, "Trying to insert object outside the map.\n%s\n", dump); |
1321 | #ifdef MANY_CORES |
1283 | #ifdef MANY_CORES |
1322 | /* Better to catch this here, as otherwise the next use of this object |
1284 | /* Better to catch this here, as otherwise the next use of this object |
1323 | * is likely to cause a crash. Better to find out where it is getting |
1285 | * is likely to cause a crash. Better to find out where it is getting |
1324 | * improperly inserted. |
1286 | * improperly inserted. |
1325 | */ |
1287 | */ |
1326 | abort (); |
1288 | abort (); |
1327 | #endif |
1289 | #endif |
|
|
1290 | free (dump); |
1328 | return op; |
1291 | return op; |
1329 | } |
1292 | } |
1330 | |
1293 | |
1331 | if (!QUERY_FLAG (op, FLAG_REMOVED)) |
1294 | if (!QUERY_FLAG (op, FLAG_REMOVED)) |
1332 | { |
1295 | { |
1333 | dump_object (op); |
1296 | char *dump = dump_object (op); |
1334 | LOG (llevError, "Trying to insert (map) inserted object.\n%s\n", errmsg); |
1297 | LOG (llevError, "Trying to insert (map) inserted object.\n%s\n", dump); |
|
|
1298 | free (dump); |
1335 | return op; |
1299 | return op; |
1336 | } |
1300 | } |
1337 | |
1301 | |
1338 | if (op->more != NULL) |
1302 | if (op->more != NULL) |
1339 | { |
1303 | { |
… | |
… | |
1585 | remove_ob (tmp); |
1549 | remove_ob (tmp); |
1586 | free_object (tmp); |
1550 | free_object (tmp); |
1587 | } |
1551 | } |
1588 | } |
1552 | } |
1589 | |
1553 | |
1590 | tmp1 = arch_to_object (find_archetype (arch_string)); |
1554 | tmp1 = arch_to_object (archetype::find (arch_string)); |
1591 | |
1555 | |
1592 | tmp1->x = op->x; |
1556 | tmp1->x = op->x; |
1593 | tmp1->y = op->y; |
1557 | tmp1->y = op->y; |
1594 | insert_ob_in_map (tmp1, op->map, op, 0); |
1558 | insert_ob_in_map (tmp1, op->map, op, 0); |
1595 | } |
1559 | } |
… | |
… | |
1753 | op->carrying += weight; |
1717 | op->carrying += weight; |
1754 | op = op->env; |
1718 | op = op->env; |
1755 | } |
1719 | } |
1756 | } |
1720 | } |
1757 | |
1721 | |
|
|
1722 | object * |
|
|
1723 | insert_ob_in_ob (object *op, object *where) |
|
|
1724 | { |
|
|
1725 | if (!where) |
|
|
1726 | { |
|
|
1727 | char *dump = dump_object (op); |
|
|
1728 | LOG (llevError, "Trying to put object in NULL.\n%s\n", dump); |
|
|
1729 | free (dump); |
|
|
1730 | return op; |
|
|
1731 | } |
|
|
1732 | |
|
|
1733 | if (where->head) |
|
|
1734 | { |
|
|
1735 | LOG (llevDebug, "Warning: Tried to insert object into wrong part of multipart object.\n"); |
|
|
1736 | where = where->head; |
|
|
1737 | } |
|
|
1738 | |
|
|
1739 | return where->insert (op); |
|
|
1740 | } |
|
|
1741 | |
1758 | /* |
1742 | /* |
1759 | * insert_ob_in_ob(op,environment): |
1743 | * env->insert (op) |
1760 | * This function inserts the object op in the linked list |
1744 | * This function inserts the object op in the linked list |
1761 | * inside the object environment. |
1745 | * inside the object environment. |
1762 | * |
1746 | * |
1763 | * Eneq(@csd.uu.se): Altered insert_ob_in_ob to make things picked up enter |
|
|
1764 | * the inventory at the last position or next to other objects of the same |
|
|
1765 | * type. |
|
|
1766 | * Frank: Now sorted by type, archetype and magic! |
|
|
1767 | * |
|
|
1768 | * The function returns now pointer to inserted item, and return value can |
1747 | * The function returns now pointer to inserted item, and return value can |
1769 | * be != op, if items are merged. -Tero |
1748 | * be != op, if items are merged. -Tero |
1770 | */ |
1749 | */ |
1771 | |
1750 | |
1772 | object * |
1751 | object * |
1773 | insert_ob_in_ob (object *op, object *where) |
1752 | object::insert (object *op) |
1774 | { |
1753 | { |
1775 | object * |
1754 | object *tmp, *otmp; |
1776 | tmp, * |
|
|
1777 | otmp; |
|
|
1778 | |
1755 | |
1779 | if (!QUERY_FLAG (op, FLAG_REMOVED)) |
1756 | if (!QUERY_FLAG (op, FLAG_REMOVED)) |
1780 | { |
1757 | op->remove (); |
1781 | dump_object (op); |
|
|
1782 | LOG (llevError, "Trying to insert (ob) inserted object.\n%s\n", errmsg); |
|
|
1783 | return op; |
|
|
1784 | } |
|
|
1785 | |
|
|
1786 | if (where == NULL) |
|
|
1787 | { |
|
|
1788 | dump_object (op); |
|
|
1789 | LOG (llevError, "Trying to put object in NULL.\n%s\n", errmsg); |
|
|
1790 | return op; |
|
|
1791 | } |
|
|
1792 | |
|
|
1793 | if (where->head) |
|
|
1794 | { |
|
|
1795 | LOG (llevDebug, "Warning: Tried to insert object wrong part of multipart object.\n"); |
|
|
1796 | where = where->head; |
|
|
1797 | } |
|
|
1798 | |
1758 | |
1799 | if (op->more) |
1759 | if (op->more) |
1800 | { |
1760 | { |
1801 | LOG (llevError, "Tried to insert multipart object %s (%d)\n", &op->name, op->count); |
1761 | LOG (llevError, "Tried to insert multipart object %s (%d)\n", &op->name, op->count); |
1802 | return op; |
1762 | return op; |
… | |
… | |
1804 | |
1764 | |
1805 | CLEAR_FLAG (op, FLAG_OBJ_ORIGINAL); |
1765 | CLEAR_FLAG (op, FLAG_OBJ_ORIGINAL); |
1806 | CLEAR_FLAG (op, FLAG_REMOVED); |
1766 | CLEAR_FLAG (op, FLAG_REMOVED); |
1807 | if (op->nrof) |
1767 | if (op->nrof) |
1808 | { |
1768 | { |
1809 | for (tmp = where->inv; tmp != NULL; tmp = tmp->below) |
1769 | for (tmp = inv; tmp != NULL; tmp = tmp->below) |
1810 | if (CAN_MERGE (tmp, op)) |
1770 | if (CAN_MERGE (tmp, op)) |
1811 | { |
1771 | { |
1812 | /* return the original object and remove inserted object |
1772 | /* return the original object and remove inserted object |
1813 | (client needs the original object) */ |
1773 | (client needs the original object) */ |
1814 | tmp->nrof += op->nrof; |
1774 | tmp->nrof += op->nrof; |
1815 | /* Weight handling gets pretty funky. Since we are adding to |
1775 | /* Weight handling gets pretty funky. Since we are adding to |
1816 | * tmp->nrof, we need to increase the weight. |
1776 | * tmp->nrof, we need to increase the weight. |
1817 | */ |
1777 | */ |
1818 | add_weight (where, op->weight * op->nrof); |
1778 | add_weight (this, op->weight * op->nrof); |
1819 | SET_FLAG (op, FLAG_REMOVED); |
1779 | SET_FLAG (op, FLAG_REMOVED); |
1820 | free_object (op); /* free the inserted object */ |
1780 | op->destroy (); /* free the inserted object */ |
1821 | op = tmp; |
1781 | op = tmp; |
1822 | remove_ob (op); /* and fix old object's links */ |
1782 | op->remove (); /* and fix old object's links */ |
1823 | CLEAR_FLAG (op, FLAG_REMOVED); |
1783 | CLEAR_FLAG (op, FLAG_REMOVED); |
1824 | break; |
1784 | break; |
1825 | } |
1785 | } |
1826 | |
1786 | |
1827 | /* I assume combined objects have no inventory |
1787 | /* I assume combined objects have no inventory |
1828 | * We add the weight - this object could have just been removed |
1788 | * We add the weight - this object could have just been removed |
1829 | * (if it was possible to merge). calling remove_ob will subtract |
1789 | * (if it was possible to merge). calling remove_ob will subtract |
1830 | * the weight, so we need to add it in again, since we actually do |
1790 | * the weight, so we need to add it in again, since we actually do |
1831 | * the linking below |
1791 | * the linking below |
1832 | */ |
1792 | */ |
1833 | add_weight (where, op->weight * op->nrof); |
1793 | add_weight (this, op->weight * op->nrof); |
1834 | } |
1794 | } |
1835 | else |
1795 | else |
1836 | add_weight (where, (op->weight + op->carrying)); |
1796 | add_weight (this, (op->weight + op->carrying)); |
1837 | |
1797 | |
1838 | otmp = is_player_inv (where); |
1798 | otmp = is_player_inv (this); |
1839 | if (otmp && otmp->contr != NULL) |
1799 | if (otmp && otmp->contr) |
1840 | { |
|
|
1841 | if (!QUERY_FLAG (otmp, FLAG_NO_FIX_PLAYER)) |
1800 | if (!QUERY_FLAG (otmp, FLAG_NO_FIX_PLAYER)) |
1842 | fix_player (otmp); |
1801 | fix_player (otmp); |
1843 | } |
|
|
1844 | |
1802 | |
1845 | op->map = NULL; |
1803 | op->map = NULL; |
1846 | op->env = where; |
1804 | op->env = this; |
1847 | op->above = NULL; |
1805 | op->above = NULL; |
1848 | op->below = NULL; |
1806 | op->below = NULL; |
1849 | op->x = 0, op->y = 0; |
1807 | op->x = 0, op->y = 0; |
1850 | |
1808 | |
1851 | /* reset the light list and los of the players on the map */ |
1809 | /* reset the light list and los of the players on the map */ |
1852 | if ((op->glow_radius != 0) && where->map) |
1810 | if ((op->glow_radius != 0) && map) |
1853 | { |
1811 | { |
1854 | #ifdef DEBUG_LIGHTS |
1812 | #ifdef DEBUG_LIGHTS |
1855 | LOG (llevDebug, " insert_ob_in_ob(): got %s to insert in map/op\n", op->name); |
1813 | LOG (llevDebug, " insert_ob_in_ob(): got %s to insert in map/op\n", op->name); |
1856 | #endif /* DEBUG_LIGHTS */ |
1814 | #endif /* DEBUG_LIGHTS */ |
1857 | if (MAP_DARKNESS (where->map)) |
1815 | if (MAP_DARKNESS (map)) |
1858 | update_all_los (where->map, where->x, where->y); |
1816 | update_all_los (map, x, y); |
1859 | } |
1817 | } |
1860 | |
1818 | |
1861 | /* Client has no idea of ordering so lets not bother ordering it here. |
1819 | /* Client has no idea of ordering so lets not bother ordering it here. |
1862 | * It sure simplifies this function... |
1820 | * It sure simplifies this function... |
1863 | */ |
1821 | */ |
1864 | if (where->inv == NULL) |
1822 | if (!inv) |
1865 | where->inv = op; |
1823 | inv = op; |
1866 | else |
1824 | else |
1867 | { |
1825 | { |
1868 | op->below = where->inv; |
1826 | op->below = inv; |
1869 | op->below->above = op; |
1827 | op->below->above = op; |
1870 | where->inv = op; |
1828 | inv = op; |
1871 | } |
1829 | } |
|
|
1830 | |
1872 | return op; |
1831 | return op; |
1873 | } |
1832 | } |
1874 | |
1833 | |
1875 | /* |
1834 | /* |
1876 | * Checks if any objects has a move_type that matches objects |
1835 | * Checks if any objects has a move_type that matches objects |
… | |
… | |
1894 | */ |
1853 | */ |
1895 | |
1854 | |
1896 | int |
1855 | int |
1897 | check_move_on (object *op, object *originator) |
1856 | check_move_on (object *op, object *originator) |
1898 | { |
1857 | { |
1899 | object * |
1858 | object *tmp; |
1900 | tmp; |
1859 | maptile *m = op->map; |
1901 | tag_t |
|
|
1902 | tag; |
|
|
1903 | mapstruct * |
|
|
1904 | m = op->map; |
|
|
1905 | int |
|
|
1906 | x = op->x, y = op->y; |
1860 | int x = op->x, y = op->y; |
1907 | |
1861 | |
1908 | MoveType |
1862 | MoveType move_on, move_slow, move_block; |
1909 | move_on, |
|
|
1910 | move_slow, |
|
|
1911 | move_block; |
|
|
1912 | |
1863 | |
1913 | if (QUERY_FLAG (op, FLAG_NO_APPLY)) |
1864 | if (QUERY_FLAG (op, FLAG_NO_APPLY)) |
1914 | return 0; |
1865 | return 0; |
1915 | |
|
|
1916 | tag = op->count; |
|
|
1917 | |
1866 | |
1918 | move_on = GET_MAP_MOVE_ON (op->map, op->x, op->y); |
1867 | move_on = GET_MAP_MOVE_ON (op->map, op->x, op->y); |
1919 | move_slow = GET_MAP_MOVE_SLOW (op->map, op->x, op->y); |
1868 | move_slow = GET_MAP_MOVE_SLOW (op->map, op->x, op->y); |
1920 | move_block = GET_MAP_MOVE_BLOCK (op->map, op->x, op->y); |
1869 | move_block = GET_MAP_MOVE_BLOCK (op->map, op->x, op->y); |
1921 | |
1870 | |
… | |
… | |
1982 | if ((!op->move_type && tmp->move_on & MOVE_WALK) || |
1931 | if ((!op->move_type && tmp->move_on & MOVE_WALK) || |
1983 | ((op->move_type & tmp->move_on) && (op->move_type & ~tmp->move_on & ~tmp->move_block) == 0)) |
1932 | ((op->move_type & tmp->move_on) && (op->move_type & ~tmp->move_on & ~tmp->move_block) == 0)) |
1984 | { |
1933 | { |
1985 | move_apply (tmp, op, originator); |
1934 | move_apply (tmp, op, originator); |
1986 | |
1935 | |
1987 | if (was_destroyed (op, tag)) |
1936 | if (op->destroyed ()) |
1988 | return 1; |
1937 | return 1; |
1989 | |
1938 | |
1990 | /* what the person/creature stepped onto has moved the object |
1939 | /* what the person/creature stepped onto has moved the object |
1991 | * someplace new. Don't process any further - if we did, |
1940 | * someplace new. Don't process any further - if we did, |
1992 | * have a feeling strange problems would result. |
1941 | * have a feeling strange problems would result. |
… | |
… | |
2004 | * a matching archetype at the given map and coordinates. |
1953 | * a matching archetype at the given map and coordinates. |
2005 | * The first matching object is returned, or NULL if none. |
1954 | * The first matching object is returned, or NULL if none. |
2006 | */ |
1955 | */ |
2007 | |
1956 | |
2008 | object * |
1957 | object * |
2009 | present_arch (const archetype *at, mapstruct *m, int x, int y) |
1958 | present_arch (const archetype *at, maptile *m, int x, int y) |
2010 | { |
1959 | { |
2011 | object * |
1960 | object * |
2012 | tmp; |
1961 | tmp; |
2013 | |
1962 | |
2014 | if (m == NULL || out_of_map (m, x, y)) |
1963 | if (m == NULL || out_of_map (m, x, y)) |
… | |
… | |
2027 | * a matching type variable at the given map and coordinates. |
1976 | * a matching type variable at the given map and coordinates. |
2028 | * The first matching object is returned, or NULL if none. |
1977 | * The first matching object is returned, or NULL if none. |
2029 | */ |
1978 | */ |
2030 | |
1979 | |
2031 | object * |
1980 | object * |
2032 | present (unsigned char type, mapstruct *m, int x, int y) |
1981 | present (unsigned char type, maptile *m, int x, int y) |
2033 | { |
1982 | { |
2034 | object * |
1983 | object * |
2035 | tmp; |
1984 | tmp; |
2036 | |
1985 | |
2037 | if (out_of_map (m, x, y)) |
1986 | if (out_of_map (m, x, y)) |
… | |
… | |
2177 | * the archetype because that isn't correct if the monster has been |
2126 | * the archetype because that isn't correct if the monster has been |
2178 | * customized, changed states, etc. |
2127 | * customized, changed states, etc. |
2179 | */ |
2128 | */ |
2180 | |
2129 | |
2181 | int |
2130 | int |
2182 | find_free_spot (const object *ob, mapstruct *m, int x, int y, int start, int stop) |
2131 | find_free_spot (const object *ob, maptile *m, int x, int y, int start, int stop) |
2183 | { |
2132 | { |
2184 | int |
2133 | int |
2185 | i, |
2134 | i, |
2186 | index = 0, flag; |
2135 | index = 0, flag; |
2187 | static int |
2136 | static int |
… | |
… | |
2208 | return -1; |
2157 | return -1; |
2209 | return altern[RANDOM () % index]; |
2158 | return altern[RANDOM () % index]; |
2210 | } |
2159 | } |
2211 | |
2160 | |
2212 | /* |
2161 | /* |
2213 | * find_first_free_spot(archetype, mapstruct, x, y) works like |
2162 | * find_first_free_spot(archetype, maptile, x, y) works like |
2214 | * find_free_spot(), but it will search max number of squares. |
2163 | * find_free_spot(), but it will search max number of squares. |
2215 | * But it will return the first available spot, not a random choice. |
2164 | * But it will return the first available spot, not a random choice. |
2216 | * Changed 0.93.2: Have it return -1 if there is no free spot available. |
2165 | * Changed 0.93.2: Have it return -1 if there is no free spot available. |
2217 | */ |
2166 | */ |
2218 | |
2167 | |
2219 | int |
2168 | int |
2220 | find_first_free_spot (const object *ob, mapstruct *m, int x, int y) |
2169 | find_first_free_spot (const object *ob, maptile *m, int x, int y) |
2221 | { |
2170 | { |
2222 | int |
2171 | int |
2223 | i; |
2172 | i; |
2224 | |
2173 | |
2225 | for (i = 0; i < SIZEOFFREE; i++) |
2174 | for (i = 0; i < SIZEOFFREE; i++) |
… | |
… | |
2289 | * because we have to know what movement the thing looking to move |
2238 | * because we have to know what movement the thing looking to move |
2290 | * there is capable of. |
2239 | * there is capable of. |
2291 | */ |
2240 | */ |
2292 | |
2241 | |
2293 | int |
2242 | int |
2294 | find_dir (mapstruct *m, int x, int y, object *exclude) |
2243 | find_dir (maptile *m, int x, int y, object *exclude) |
2295 | { |
2244 | { |
2296 | int |
2245 | int |
2297 | i, |
2246 | i, |
2298 | max = SIZEOFFREE, mflags; |
2247 | max = SIZEOFFREE, mflags; |
2299 | |
2248 | |
2300 | sint16 nx, ny; |
2249 | sint16 nx, ny; |
2301 | object * |
2250 | object * |
2302 | tmp; |
2251 | tmp; |
2303 | mapstruct * |
2252 | maptile * |
2304 | mp; |
2253 | mp; |
2305 | |
2254 | |
2306 | MoveType blocked, move_type; |
2255 | MoveType blocked, move_type; |
2307 | |
2256 | |
2308 | if (exclude && exclude->head) |
2257 | if (exclude && exclude->head) |
… | |
… | |
2516 | * Modified to be map tile aware -.MSW |
2465 | * Modified to be map tile aware -.MSW |
2517 | */ |
2466 | */ |
2518 | |
2467 | |
2519 | |
2468 | |
2520 | int |
2469 | int |
2521 | can_see_monsterP (mapstruct *m, int x, int y, int dir) |
2470 | can_see_monsterP (maptile *m, int x, int y, int dir) |
2522 | { |
2471 | { |
2523 | sint16 dx, dy; |
2472 | sint16 dx, dy; |
2524 | int |
2473 | int |
2525 | mflags; |
2474 | mflags; |
2526 | |
2475 | |
… | |
… | |
2575 | * create clone from object to another |
2524 | * create clone from object to another |
2576 | */ |
2525 | */ |
2577 | object * |
2526 | object * |
2578 | object_create_clone (object *asrc) |
2527 | object_create_clone (object *asrc) |
2579 | { |
2528 | { |
2580 | object * |
|
|
2581 | dst = NULL, *tmp, *src, *part, *prev, *item; |
2529 | object *dst = 0, *tmp, *src, *part, *prev, *item; |
2582 | |
2530 | |
2583 | if (!asrc) |
2531 | if (!asrc) |
2584 | return NULL; |
2532 | return 0; |
|
|
2533 | |
2585 | src = asrc; |
2534 | src = asrc; |
2586 | if (src->head) |
2535 | if (src->head) |
2587 | src = src->head; |
2536 | src = src->head; |
2588 | |
2537 | |
2589 | prev = NULL; |
2538 | prev = 0; |
2590 | for (part = src; part; part = part->more) |
2539 | for (part = src; part; part = part->more) |
2591 | { |
2540 | { |
2592 | tmp = get_object (); |
2541 | tmp = get_object (); |
2593 | copy_object (part, tmp); |
2542 | copy_object (part, tmp); |
2594 | tmp->x -= src->x; |
2543 | tmp->x -= src->x; |
2595 | tmp->y -= src->y; |
2544 | tmp->y -= src->y; |
|
|
2545 | |
2596 | if (!part->head) |
2546 | if (!part->head) |
2597 | { |
2547 | { |
2598 | dst = tmp; |
2548 | dst = tmp; |
2599 | tmp->head = NULL; |
2549 | tmp->head = 0; |
2600 | } |
2550 | } |
2601 | else |
2551 | else |
2602 | { |
2552 | { |
2603 | tmp->head = dst; |
2553 | tmp->head = dst; |
2604 | } |
2554 | } |
|
|
2555 | |
2605 | tmp->more = NULL; |
2556 | tmp->more = 0; |
|
|
2557 | |
2606 | if (prev) |
2558 | if (prev) |
2607 | prev->more = tmp; |
2559 | prev->more = tmp; |
|
|
2560 | |
2608 | prev = tmp; |
2561 | prev = tmp; |
2609 | } |
2562 | } |
2610 | |
2563 | |
2611 | /*** copy inventory ***/ |
|
|
2612 | for (item = src->inv; item; item = item->below) |
2564 | for (item = src->inv; item; item = item->below) |
2613 | { |
|
|
2614 | (void) insert_ob_in_ob (object_create_clone (item), dst); |
2565 | insert_ob_in_ob (object_create_clone (item), dst); |
2615 | } |
|
|
2616 | |
2566 | |
2617 | return dst; |
2567 | return dst; |
2618 | } |
2568 | } |
2619 | |
2569 | |
2620 | /* return true if the object was destroyed, 0 otherwise */ |
|
|
2621 | int |
|
|
2622 | was_destroyed (const object *op, tag_t old_tag) |
|
|
2623 | { |
|
|
2624 | /* checking for FLAG_FREED isn't necessary, but makes this function more |
|
|
2625 | * robust */ |
|
|
2626 | return op->count != old_tag || QUERY_FLAG (op, FLAG_FREED); |
|
|
2627 | } |
|
|
2628 | |
|
|
2629 | /* GROS - Creates an object using a string representing its content. */ |
2570 | /* GROS - Creates an object using a string representing its content. */ |
2630 | |
|
|
2631 | /* Basically, we save the content of the string to a temp file, then call */ |
2571 | /* Basically, we save the content of the string to a temp file, then call */ |
2632 | |
|
|
2633 | /* load_object on it. I admit it is a highly inefficient way to make things, */ |
2572 | /* load_object on it. I admit it is a highly inefficient way to make things, */ |
2634 | |
|
|
2635 | /* but it was simple to make and allows reusing the load_object function. */ |
2573 | /* but it was simple to make and allows reusing the load_object function. */ |
2636 | |
|
|
2637 | /* Remember not to use load_object_str in a time-critical situation. */ |
2574 | /* Remember not to use load_object_str in a time-critical situation. */ |
2638 | |
|
|
2639 | /* Also remember that multiparts objects are not supported for now. */ |
2575 | /* Also remember that multiparts objects are not supported for now. */ |
2640 | |
2576 | |
2641 | object * |
2577 | object * |
2642 | load_object_str (const char *obstr) |
2578 | load_object_str (const char *obstr) |
2643 | { |
2579 | { |
2644 | object * |
2580 | object *op; |
2645 | op; |
|
|
2646 | char |
|
|
2647 | filename[MAX_BUF]; |
2581 | char filename[MAX_BUF]; |
2648 | |
2582 | |
2649 | sprintf (filename, "%s/cfloadobstr2044", settings.tmpdir); |
2583 | sprintf (filename, "%s/cfloadobstr2044", settings.tmpdir); |
2650 | |
2584 | |
2651 | FILE * |
|
|
2652 | tempfile = fopen (filename, "w"); |
2585 | FILE *tempfile = fopen (filename, "w"); |
2653 | |
2586 | |
2654 | if (tempfile == NULL) |
2587 | if (tempfile == NULL) |
2655 | { |
2588 | { |
2656 | LOG (llevError, "Error - Unable to access load object temp file\n"); |
2589 | LOG (llevError, "Error - Unable to access load object temp file\n"); |
2657 | return NULL; |
2590 | return NULL; |
2658 | }; |
2591 | } |
|
|
2592 | |
2659 | fprintf (tempfile, obstr); |
2593 | fprintf (tempfile, obstr); |
2660 | fclose (tempfile); |
2594 | fclose (tempfile); |
2661 | |
2595 | |
2662 | op = get_object (); |
2596 | op = get_object (); |
2663 | |
2597 | |
… | |
… | |
2677 | * returns NULL if no match. |
2611 | * returns NULL if no match. |
2678 | */ |
2612 | */ |
2679 | object * |
2613 | object * |
2680 | find_obj_by_type_subtype (const object *who, int type, int subtype) |
2614 | find_obj_by_type_subtype (const object *who, int type, int subtype) |
2681 | { |
2615 | { |
2682 | object * |
2616 | object *tmp; |
2683 | tmp; |
|
|
2684 | |
2617 | |
2685 | for (tmp = who->inv; tmp; tmp = tmp->below) |
2618 | for (tmp = who->inv; tmp; tmp = tmp->below) |
2686 | if (tmp->type == type && tmp->subtype == subtype) |
2619 | if (tmp->type == type && tmp->subtype == subtype) |
2687 | return tmp; |
2620 | return tmp; |
2688 | |
2621 | |
… | |
… | |
2696 | * do the desired thing. |
2629 | * do the desired thing. |
2697 | */ |
2630 | */ |
2698 | key_value * |
2631 | key_value * |
2699 | get_ob_key_link (const object *ob, const char *key) |
2632 | get_ob_key_link (const object *ob, const char *key) |
2700 | { |
2633 | { |
2701 | key_value * |
2634 | key_value *link; |
2702 | link; |
|
|
2703 | |
2635 | |
2704 | for (link = ob->key_values; link != NULL; link = link->next) |
2636 | for (link = ob->key_values; link != NULL; link = link->next) |
2705 | { |
|
|
2706 | if (link->key == key) |
2637 | if (link->key == key) |
2707 | { |
|
|
2708 | return link; |
2638 | return link; |
2709 | } |
|
|
2710 | } |
|
|
2711 | |
2639 | |
2712 | return NULL; |
2640 | return NULL; |
2713 | } |
2641 | } |
2714 | |
2642 | |
2715 | /* |
2643 | /* |
… | |
… | |
2857 | } |
2785 | } |
2858 | else |
2786 | else |
2859 | item = item->env; |
2787 | item = item->env; |
2860 | } |
2788 | } |
2861 | |
2789 | |
|
|
2790 | // return a suitable string describing an objetc in enough detail to find it |
|
|
2791 | const char * |
|
|
2792 | object::debug_desc (char *info) const |
|
|
2793 | { |
|
|
2794 | char info2[256 * 3]; |
|
|
2795 | char *p = info; |
|
|
2796 | |
|
|
2797 | p += snprintf (p, 256, "%d=\"%s%s%s\"", |
|
|
2798 | count, |
|
|
2799 | &name, |
|
|
2800 | title ? " " : "", |
|
|
2801 | title ? (const char *)title : ""); |
|
|
2802 | |
|
|
2803 | if (env) |
|
|
2804 | p += snprintf (p, 256, "(in %s)", env->debug_desc (info2)); |
|
|
2805 | |
|
|
2806 | if (map) |
|
|
2807 | p += snprintf (p, 256, "(on %s@%d+%d)", map->path, x, y); |
|
|
2808 | |
|
|
2809 | return info; |
|
|
2810 | } |
|
|
2811 | |
|
|
2812 | const char * |
|
|
2813 | object::debug_desc () const |
|
|
2814 | { |
|
|
2815 | static char info[256 * 3]; |
|
|
2816 | return debug_desc (info); |
|
|
2817 | } |
|
|
2818 | |