… | |
… | |
101 | |
101 | |
102 | typedef char BUF [32]; |
102 | typedef char BUF [32]; |
103 | |
103 | |
104 | bool parse (const char *s) |
104 | bool parse (const char *s) |
105 | { |
105 | { |
106 | return sscanf (s, "<1%*[,.]%" SCNx64 ">", &seq) == 1; |
106 | return sscanf (s, "<1.%" SCNx64 ">", &seq) == 1; |
107 | } |
107 | } |
108 | |
108 | |
109 | const char *c_str (char *buf, int len) const |
109 | const char *c_str (char *buf, int len) const |
110 | { |
110 | { |
111 | snprintf (buf, len, "<1.%" PRIx64 ">", seq); |
111 | snprintf (buf, len, "<1.%" PRIx64 ">", seq); |
… | |
… | |
384 | return nrof ? nrof : 1; |
384 | return nrof ? nrof : 1; |
385 | } |
385 | } |
386 | |
386 | |
387 | uint64 total_weight () const |
387 | uint64 total_weight () const |
388 | { |
388 | { |
389 | return weight * number_of (); |
389 | return weight * number_of () + carrying; |
390 | } |
390 | } |
391 | |
391 | |
392 | // return the dominant material of this item, always return something |
392 | // return the dominant material of this item, always return something |
393 | const materialtype_t *dominant_material () const; |
393 | const materialtype_t *dominant_material () const; |
394 | |
394 | |
… | |
… | |
469 | MTH void activate (); |
469 | MTH void activate (); |
470 | MTH void deactivate (); |
470 | MTH void deactivate (); |
471 | MTH void activate_recursive (); |
471 | MTH void activate_recursive (); |
472 | MTH void deactivate_recursive (); |
472 | MTH void deactivate_recursive (); |
473 | |
473 | |
474 | // set the givne flag on all objects in the inventory recursively |
474 | // set the given flag on all objects in the inventory recursively |
475 | MTH void set_flag_inv (int flag, int value = 1); |
475 | MTH void set_flag_inv (int flag, int value = 1); |
476 | |
476 | |
477 | void enter_exit (object *exit);//Perl |
477 | void enter_exit (object *exit);//Perl |
478 | MTH void enter_map (maptile *newmap, int x, int y); |
478 | MTH void enter_map (maptile *newmap, int x, int y); |
479 | |
479 | |
… | |
… | |
572 | } objectlink; |
572 | } objectlink; |
573 | |
573 | |
574 | typedef struct oblinkpt |
574 | typedef struct oblinkpt |
575 | { /* Used to link together several object links */ |
575 | { /* Used to link together several object links */ |
576 | struct oblnk *link; |
576 | struct oblnk *link; |
577 | long value; /* Used as connected value in buttons/gates */ |
577 | sint32 value; /* Used as connected value in buttons/gates */ |
578 | struct oblinkpt *next; |
578 | struct oblinkpt *next; |
579 | } oblinkpt; |
579 | } oblinkpt; |
580 | |
580 | |
581 | object *find_skill_by_name (object *who, const char *name); |
581 | object *find_skill_by_name (object *who, const char *name); |
582 | object *find_skill_by_name (object *who, const shstr &sh); |
582 | object *find_skill_by_name (object *who, const shstr &sh); |
… | |
… | |
592 | */ |
592 | */ |
593 | |
593 | |
594 | INTERFACE_CLASS (archetype) |
594 | INTERFACE_CLASS (archetype) |
595 | struct archetype : object |
595 | struct archetype : object |
596 | { |
596 | { |
|
|
597 | static arch_ptr empty; // the empty_archetype |
|
|
598 | MTH static void gc (); |
|
|
599 | |
597 | archetype (const char *name); |
600 | archetype (const char *name); |
598 | ~archetype (); |
601 | ~archetype (); |
599 | void gather_callbacks (AV *&callbacks, event_type event) const; |
602 | void gather_callbacks (AV *&callbacks, event_type event) const; |
600 | |
603 | |
601 | static archetype *read (object_thawer &f); |
|
|
602 | |
|
|
603 | MTH static archetype *get (const_utf8_string name); // find or create |
|
|
604 | MTH static archetype *find (const_utf8_string name); |
604 | MTH static archetype *find (const_utf8_string name); |
605 | |
605 | |
606 | MTH void link (); |
606 | MTH void link (); |
607 | MTH void unlink (); |
607 | MTH void unlink (); |
608 | |
608 | |
609 | MTH object *instance (); |
609 | MTH object *instance (); |
610 | |
610 | |
611 | object_vector_index ACC (RW, archid); // index in archvector |
611 | object_vector_index ACC (RW, archid); // index in archvector |
612 | shstr ACC (RW, archname); /* More definite name, like "generate_kobold" */ |
612 | shstr ACC (RW, archname); /* More definite name, like "generate_kobold" */ |
613 | bool ACC (RW, stub); // if true, this is an invalid archetype |
|
|
614 | |
613 | |
615 | sint8 ACC (RW, min_x), ACC (RW, min_y); /* extents, compared to the head (min_x, min_y should be zero, but aren't...) */ |
614 | sint8 ACC (RW, min_x), ACC (RW, min_y); /* extents, compared to the head (min_x, min_y should be zero, but aren't...) */ |
616 | sint8 ACC (RW, max_x), ACC (RW, max_y); |
615 | sint8 ACC (RW, max_x), ACC (RW, max_y); |
|
|
616 | |
|
|
617 | // support for archetype loading |
|
|
618 | static archetype *read (object_thawer &f); |
|
|
619 | MTH static void commit_load (); // commit any objects loaded, resolves cyclic dependencies and more |
|
|
620 | static void postpone_arch_ref (arch_ptr &ref, const_utf8_string other_arch); /* postpone other_arch reference */ |
617 | }; |
621 | }; |
618 | |
622 | |
619 | inline void |
623 | inline void |
620 | object_freezer::put (keyword k, archetype *v) |
624 | object_freezer::put (keyword k, archetype *v) |
621 | { |
625 | { |