… | |
… | |
88 | |
88 | |
89 | struct UUID |
89 | struct UUID |
90 | { |
90 | { |
91 | uint64 seq; |
91 | uint64 seq; |
92 | |
92 | |
|
|
93 | static UUID cur; // last uuid generated |
|
|
94 | static void init (); |
|
|
95 | static UUID gen (); |
|
|
96 | |
93 | UUID () { } |
97 | UUID () { } |
94 | UUID (uint64 seq) : seq(seq) { } |
98 | UUID (uint64 seq) : seq(seq) { } |
95 | operator uint64() { return seq; } |
99 | operator uint64() { return seq; } |
96 | void operator =(uint64 seq) { this->seq = seq; } |
100 | void operator =(uint64 seq) { this->seq = seq; } |
97 | }; |
|
|
98 | |
101 | |
99 | extern void init_uuid (); |
102 | typedef char BUF [32]; |
100 | extern UUID gen_uuid (); |
103 | |
101 | extern const uint64 UUID_SKIP; |
104 | bool parse (const char *s) |
|
|
105 | { |
|
|
106 | return sscanf (s, "<1.%" SCNx64 ">", &seq) == 1; |
|
|
107 | } |
|
|
108 | |
|
|
109 | const char *c_str (char *buf, int len) const |
|
|
110 | { |
|
|
111 | snprintf (buf, len, "<1.%" PRIx64 ">", seq); |
|
|
112 | |
|
|
113 | return buf; |
|
|
114 | } |
|
|
115 | |
|
|
116 | const char *c_str () const |
|
|
117 | { |
|
|
118 | static BUF buf; |
|
|
119 | |
|
|
120 | return c_str (buf, sizeof (buf)); |
|
|
121 | } |
|
|
122 | }; |
102 | |
123 | |
103 | /* Definition for WILL_APPLY values. Replaces having harcoded values |
124 | /* Definition for WILL_APPLY values. Replaces having harcoded values |
104 | * sprinkled in the code. Note that some of these also replace fields |
125 | * sprinkled in the code. Note that some of these also replace fields |
105 | * that were in the can_apply area. What is the point of having both |
126 | * that were in the can_apply area. What is the point of having both |
106 | * can_apply and will_apply? |
127 | * can_apply and will_apply? |
… | |
… | |
448 | MTH void activate (); |
469 | MTH void activate (); |
449 | MTH void deactivate (); |
470 | MTH void deactivate (); |
450 | MTH void activate_recursive (); |
471 | MTH void activate_recursive (); |
451 | MTH void deactivate_recursive (); |
472 | MTH void deactivate_recursive (); |
452 | |
473 | |
453 | // set the givne flag on all objects in the inventory recursively |
474 | // set the given flag on all objects in the inventory recursively |
454 | MTH void set_flag_inv (int flag, int value = 1); |
475 | MTH void set_flag_inv (int flag, int value = 1); |
455 | |
476 | |
456 | void enter_exit (object *exit);//Perl |
477 | void enter_exit (object *exit);//Perl |
457 | MTH void enter_map (maptile *newmap, int x, int y); |
478 | MTH void enter_map (maptile *newmap, int x, int y); |
458 | |
479 | |
… | |
… | |
551 | } objectlink; |
572 | } objectlink; |
552 | |
573 | |
553 | typedef struct oblinkpt |
574 | typedef struct oblinkpt |
554 | { /* Used to link together several object links */ |
575 | { /* Used to link together several object links */ |
555 | struct oblnk *link; |
576 | struct oblnk *link; |
556 | long value; /* Used as connected value in buttons/gates */ |
577 | sint32 value; /* Used as connected value in buttons/gates */ |
557 | struct oblinkpt *next; |
578 | struct oblinkpt *next; |
558 | } oblinkpt; |
579 | } oblinkpt; |
559 | |
580 | |
560 | object *find_skill_by_name (object *who, const char *name); |
581 | object *find_skill_by_name (object *who, const char *name); |
561 | object *find_skill_by_name (object *who, const shstr &sh); |
582 | object *find_skill_by_name (object *who, const shstr &sh); |
… | |
… | |
571 | */ |
592 | */ |
572 | |
593 | |
573 | INTERFACE_CLASS (archetype) |
594 | INTERFACE_CLASS (archetype) |
574 | struct archetype : object |
595 | struct archetype : object |
575 | { |
596 | { |
|
|
597 | static archetype *empty; // the empty_archetype |
|
|
598 | |
576 | archetype (const char *name); |
599 | archetype (const char *name); |
577 | ~archetype (); |
600 | ~archetype (); |
578 | void gather_callbacks (AV *&callbacks, event_type event) const; |
601 | void gather_callbacks (AV *&callbacks, event_type event) const; |
579 | |
602 | |
580 | static archetype *read (object_thawer &f); |
|
|
581 | |
|
|
582 | MTH static archetype *get (const_utf8_string name); // find or create |
|
|
583 | MTH static archetype *find (const_utf8_string name); |
603 | MTH static archetype *find (const_utf8_string name); |
584 | |
604 | |
585 | MTH void link (); |
605 | MTH void link (); |
586 | MTH void unlink (); |
606 | MTH void unlink (); |
587 | |
607 | |
588 | MTH object *instance (); |
608 | MTH object *instance (); |
589 | |
609 | |
590 | object_vector_index ACC (RW, archid); // index in archvector |
610 | object_vector_index ACC (RW, archid); // index in archvector |
591 | shstr ACC (RW, archname); /* More definite name, like "generate_kobold" */ |
611 | shstr ACC (RW, archname); /* More definite name, like "generate_kobold" */ |
592 | bool ACC (RW, stub); // if true, this is an invalid archetype |
|
|
593 | |
612 | |
594 | sint8 ACC (RW, min_x), ACC (RW, min_y); /* extents, compared to the head (min_x, min_y should be zero, but aren't...) */ |
613 | sint8 ACC (RW, min_x), ACC (RW, min_y); /* extents, compared to the head (min_x, min_y should be zero, but aren't...) */ |
595 | sint8 ACC (RW, max_x), ACC (RW, max_y); |
614 | sint8 ACC (RW, max_x), ACC (RW, max_y); |
|
|
615 | |
|
|
616 | // support for archetype loading |
|
|
617 | static archetype *read (object_thawer &f); |
|
|
618 | MTH static void commit_load (); // commit any objects loaded, resolves cyclic dependencies and more |
|
|
619 | static void postpone_arch_ref (arch_ptr &ref, const_utf8_string other_arch); /* postpone other_arch reference */ |
596 | }; |
620 | }; |
597 | |
621 | |
598 | inline void |
622 | inline void |
599 | object_freezer::put (keyword k, archetype *v) |
623 | object_freezer::put (keyword k, archetype *v) |
600 | { |
624 | { |