… | |
… | |
28 | #include <bitset> |
28 | #include <bitset> |
29 | |
29 | |
30 | #include "cfperl.h" |
30 | #include "cfperl.h" |
31 | #include "shstr.h" |
31 | #include "shstr.h" |
32 | |
32 | |
|
|
33 | //+GPL |
|
|
34 | |
33 | typedef int tag_t; |
35 | typedef int tag_t; |
34 | |
36 | |
35 | enum { |
37 | enum { |
36 | body_skill, |
38 | body_skill, |
37 | body_combat, |
39 | body_combat, |
… | |
… | |
85 | { |
87 | { |
86 | key_value *next; |
88 | key_value *next; |
87 | shstr key, value; |
89 | shstr key, value; |
88 | }; |
90 | }; |
89 | |
91 | |
|
|
92 | //-GPL |
|
|
93 | |
90 | struct UUID |
94 | struct UUID |
91 | { |
95 | { |
92 | uint64 seq; |
96 | uint64 seq; |
93 | |
97 | |
94 | static UUID cur; // last uuid generated |
98 | static UUID cur; // last uuid generated |
… | |
… | |
119 | static BUF buf; |
123 | static BUF buf; |
120 | |
124 | |
121 | return c_str (buf, sizeof (buf)); |
125 | return c_str (buf, sizeof (buf)); |
122 | } |
126 | } |
123 | }; |
127 | }; |
|
|
128 | |
|
|
129 | //+GPL |
124 | |
130 | |
125 | /* Definition for WILL_APPLY values. Replaces having harcoded values |
131 | /* Definition for WILL_APPLY values. Replaces having harcoded values |
126 | * sprinkled in the code. Note that some of these also replace fields |
132 | * sprinkled in the code. Note that some of these also replace fields |
127 | * that were in the can_apply area. What is the point of having both |
133 | * that were in the can_apply area. What is the point of having both |
128 | * can_apply and will_apply? |
134 | * can_apply and will_apply? |
… | |
… | |
133 | #define WILL_APPLY_DOOR 0x08 |
139 | #define WILL_APPLY_DOOR 0x08 |
134 | #define WILL_APPLY_FOOD 0x10 |
140 | #define WILL_APPLY_FOOD 0x10 |
135 | |
141 | |
136 | struct body_slot |
142 | struct body_slot |
137 | { |
143 | { |
|
|
144 | signed char used:4; /* Calculated value based on items equipped */ |
138 | signed char info:4; /* body info as loaded from the file */ |
145 | signed char info:4; /* body info as loaded from the file */ |
139 | signed char used:4; /* Calculated value based on items equipped */ |
|
|
140 | }; |
146 | }; |
141 | |
147 | |
142 | typedef struct oblnk |
148 | typedef struct oblnk |
143 | { /* Used to link together several objects */ |
149 | { /* Used to link together several objects */ |
144 | object_ptr ob; |
150 | object_ptr ob; |
… | |
… | |
221 | uint8 ACC (RW, pick_up); /* See crossfire.doc */ |
227 | uint8 ACC (RW, pick_up); /* See crossfire.doc */ |
222 | sint8 ACC (RW, gen_sp_armour);/* sp regen penalty this object has (was last_heal) */ |
228 | sint8 ACC (RW, gen_sp_armour);/* sp regen penalty this object has (was last_heal) */ |
223 | sint8 ACC (RW, glow_radius); /* indicates the glow radius of the object */ |
229 | sint8 ACC (RW, glow_radius); /* indicates the glow radius of the object */ |
224 | uint8 ACC (RW, weapontype); /* type of weapon */ |
230 | uint8 ACC (RW, weapontype); /* type of weapon */ |
225 | |
231 | |
|
|
232 | body_slot slot [NUM_BODY_LOCATIONS]; |
|
|
233 | |
226 | faceidx ACC (RW, face); /* the graphical face */ |
234 | faceidx ACC (RW, face); /* the graphical face */ |
227 | |
235 | |
228 | faceidx ACC (RW, sound); /* the sound face */ |
236 | faceidx ACC (RW, sound); /* the sound face */ |
229 | faceidx ACC (RW, sound_destroy); /* played on destroy */ |
237 | faceidx ACC (RW, sound_destroy); /* played on destroy */ |
230 | |
|
|
231 | body_slot slot [NUM_BODY_LOCATIONS]; |
|
|
232 | |
238 | |
233 | sint32 ACC (RW, weight); /* Attributes of the object */ |
239 | sint32 ACC (RW, weight); /* Attributes of the object */ |
234 | sint32 ACC (RW, weight_limit);/* Weight-limit of object */ |
240 | sint32 ACC (RW, weight_limit);/* Weight-limit of object */ |
235 | |
241 | |
236 | sint32 ACC (RW, carrying); /* How much weight this object contains, must be 0 if nrof == 0 */ |
242 | sint32 ACC (RW, carrying); /* How much weight this object contains, must be 0 if nrof == 0 */ |
… | |
… | |
318 | object *ACC (RW, above); /* Pointer to the object stacked above this one */ |
324 | object *ACC (RW, above); /* Pointer to the object stacked above this one */ |
319 | /* Note: stacked in the *same* environment */ |
325 | /* Note: stacked in the *same* environment */ |
320 | object *inv; /* Pointer to the first object in the inventory */ |
326 | object *inv; /* Pointer to the first object in the inventory */ |
321 | |
327 | |
322 | //TODO: container must move into client |
328 | //TODO: container must move into client |
323 | object_ptr ACC (RW, container); /* Current container being used. I think this |
329 | object_ptr ACC (RW, container);/* Currently opened container. I think this |
324 | * is only used by the player right now. |
330 | * is only used by the player right now. |
325 | */ |
331 | */ |
326 | object *ACC (RW, env); /* Pointer to the object which is the environment. |
332 | object *ACC (RW, env); /* Pointer to the object which is the environment. |
327 | * This is typically the container that the object is in. |
333 | * This is typically the container that the object is in. |
328 | */ |
334 | */ |
329 | object *ACC (RW, more); /* Pointer to the rest of a large body of objects */ |
335 | object *ACC (RW, more); /* Pointer to the rest of a large body of objects */ |
330 | object *head; /* Points to the main object of a large body */ // NO ACC, perl semantics are different |
336 | object *head; /* Points to the main object of a large body */ // NO ACC, perl semantics are different |
331 | client_container *seen_by; // seen by which player/container currently? |
|
|
332 | key_value *key_values; /* Fields not explictly known by the loader. */ |
337 | key_value *key_values; /* Fields not explictly known by the loader. */ |
333 | |
338 | |
334 | // privates / perl |
339 | // privates / perl |
335 | shstr_tmp kv_get (shstr_tmp key) const; |
340 | shstr_tmp kv_get (shstr_tmp key) const; |
336 | void kv_del (shstr_tmp key); |
341 | void kv_del (shstr_tmp key); |
337 | void kv_set (shstr_tmp key, shstr_tmp value); |
342 | void kv_set (shstr_tmp key, shstr_tmp value); |
|
|
343 | |
|
|
344 | //-GPL |
338 | |
345 | |
339 | // custom extra fields management |
346 | // custom extra fields management |
340 | struct key_value_access_proxy |
347 | struct key_value_access_proxy |
341 | { |
348 | { |
342 | object &ob; |
349 | object &ob; |
… | |
… | |
434 | |
441 | |
435 | MTH void open_container (object *new_container); |
442 | MTH void open_container (object *new_container); |
436 | MTH void close_container () |
443 | MTH void close_container () |
437 | { |
444 | { |
438 | open_container (0); |
445 | open_container (0); |
|
|
446 | } |
|
|
447 | |
|
|
448 | // potential future accessor for "container" |
|
|
449 | MTH object *container_ () const |
|
|
450 | { |
|
|
451 | return container; |
|
|
452 | } |
|
|
453 | |
|
|
454 | MTH bool is_open_container () const |
|
|
455 | { |
|
|
456 | // strangely enough, using ?: here causes code to inflate |
|
|
457 | return type == CONTAINER |
|
|
458 | && ((env && env->container_ () == this) |
|
|
459 | || (!env && flag [FLAG_APPLIED])); |
439 | } |
460 | } |
440 | |
461 | |
441 | MTH object *force_find (shstr_tmp name); |
462 | MTH object *force_find (shstr_tmp name); |
442 | MTH void force_set_timer (int duration); |
463 | MTH void force_set_timer (int duration); |
443 | MTH object *force_add (shstr_tmp name, int duration = 0); |
464 | MTH object *force_add (shstr_tmp name, int duration = 0); |
… | |
… | |
510 | MTH bool is_arrow () const { return type == ARROW |
531 | MTH bool is_arrow () const { return type == ARROW |
511 | || (type == SPELL_EFFECT |
532 | || (type == SPELL_EFFECT |
512 | && (subtype == SP_BULLET || subtype == SP_MAGIC_MISSILE)); } |
533 | && (subtype == SP_BULLET || subtype == SP_MAGIC_MISSILE)); } |
513 | MTH bool is_range () const { return type == BOW || type == ROD || type == WAND || type == HORN; } |
534 | MTH bool is_range () const { return type == BOW || type == ROD || type == WAND || type == HORN; } |
514 | |
535 | |
515 | MTH bool has_active_speed () const { return FABS(speed) >= MIN_ACTIVE_SPEED; } |
536 | MTH bool has_active_speed () const { return fabs (speed) >= MIN_ACTIVE_SPEED; } |
516 | |
537 | |
517 | // temporary: wether the object can be saved in a map file |
538 | // temporary: wether the object can be saved in a map file |
518 | // contr => is a player |
539 | // contr => is a player |
519 | // head => only save head of a multitile object |
540 | // head => only save head of a multitile object |
520 | // owner => can not reference owner yet |
541 | // owner => can not reference owner yet |
… | |
… | |
624 | MTH void create_treasure (treasurelist *tl, int flags = 0); |
645 | MTH void create_treasure (treasurelist *tl, int flags = 0); |
625 | |
646 | |
626 | // insert object at same map position as 'where' |
647 | // insert object at same map position as 'where' |
627 | // handles both inventory and map "positions" |
648 | // handles both inventory and map "positions" |
628 | MTH object *insert_at (object *where, object *originator = 0, int flags = 0); |
649 | MTH object *insert_at (object *where, object *originator = 0, int flags = 0); |
|
|
650 | // check whether we can put this into the map, respect max_nrof, max_volume, max_items |
|
|
651 | MTH bool can_drop_at (maptile *m, int x, int y, object *originator = 0); |
629 | MTH void drop_unpaid_items (); |
652 | MTH void drop_unpaid_items (); |
630 | |
653 | |
631 | MTH void activate (); |
654 | MTH void activate (); |
632 | MTH void deactivate (); |
655 | MTH void deactivate (); |
633 | MTH void activate_recursive (); |
656 | MTH void activate_recursive (); |
… | |
… | |
739 | object (const object &); |
762 | object (const object &); |
740 | }; |
763 | }; |
741 | |
764 | |
742 | // move this object to the top of its env's inventory to speed up |
765 | // move this object to the top of its env's inventory to speed up |
743 | // searches for it. |
766 | // searches for it. |
744 | static object * |
767 | static inline object * |
745 | splay (object *ob) |
768 | splay (object *ob) |
746 | { |
769 | { |
747 | if (ob->above && ob->env) |
770 | if (ob->above && ob->env) |
748 | { |
771 | { |
749 | if (ob->above) ob->above->below = ob->below; |
772 | if (ob->above) ob->above->below = ob->below; |
… | |
… | |
755 | ob->env->inv = ob; |
778 | ob->env->inv = ob; |
756 | } |
779 | } |
757 | |
780 | |
758 | return ob; |
781 | return ob; |
759 | } |
782 | } |
|
|
783 | |
|
|
784 | //+GPL |
760 | |
785 | |
761 | object *find_skill_by_name_fuzzy (object *who, const char *name); |
786 | object *find_skill_by_name_fuzzy (object *who, const char *name); |
762 | object *find_skill_by_name (object *who, shstr_cmp sh); |
787 | object *find_skill_by_name (object *who, shstr_cmp sh); |
763 | object *find_skill_by_number (object *who, int skillno); |
788 | object *find_skill_by_number (object *who, int skillno); |
764 | |
789 | |
… | |
… | |
769 | * be much left in the archetype - all it really is is a holder for the |
794 | * be much left in the archetype - all it really is is a holder for the |
770 | * object and pointers. This structure should get removed, and just replaced |
795 | * object and pointers. This structure should get removed, and just replaced |
771 | * by the object structure |
796 | * by the object structure |
772 | */ |
797 | */ |
773 | |
798 | |
|
|
799 | //-GPL |
|
|
800 | |
774 | INTERFACE_CLASS (archetype) |
801 | INTERFACE_CLASS (archetype) |
775 | struct archetype : object |
802 | struct archetype : object |
776 | { |
803 | { |
777 | static arch_ptr empty; // the empty_archetype |
804 | static arch_ptr empty; // the empty_archetype |
778 | MTH static void gc (); |
805 | MTH static void gc (); |
… | |
… | |
786 | MTH void link (); |
813 | MTH void link (); |
787 | MTH void unlink (); |
814 | MTH void unlink (); |
788 | |
815 | |
789 | MTH static object *get (const char *name); // (find() || singularity)->instance() |
816 | MTH static object *get (const char *name); // (find() || singularity)->instance() |
790 | MTH object *instance (); |
817 | MTH object *instance (); |
|
|
818 | |
|
|
819 | MTH void post_load_check (); // do some adjustments after parsing |
791 | |
820 | |
792 | object_vector_index ACC (RW, archid); // index in archvector |
821 | object_vector_index ACC (RW, archid); // index in archvector |
793 | shstr ACC (RW, archname); /* More definite name, like "generate_kobold" */ |
822 | shstr ACC (RW, archname); /* More definite name, like "generate_kobold" */ |
794 | |
823 | |
795 | sint8 ACC (RW, min_x), ACC (RW, min_y); /* extents, compared to the head (min_x, min_y should be zero, but aren't...) */ |
824 | sint8 ACC (RW, min_x), ACC (RW, min_y); /* extents, compared to the head (min_x, min_y should be zero, but aren't...) */ |
… | |
… | |
836 | statementvar (object *, var, actives [_i]) |
865 | statementvar (object *, var, actives [_i]) |
837 | |
866 | |
838 | #define for_all_archetypes(var) \ |
867 | #define for_all_archetypes(var) \ |
839 | for (unsigned _i = 0; _i < archetypes.size (); ++_i) \ |
868 | for (unsigned _i = 0; _i < archetypes.size (); ++_i) \ |
840 | statementvar (archetype *, var, archetypes [_i]) |
869 | statementvar (archetype *, var, archetypes [_i]) |
|
|
870 | |
|
|
871 | //+GPL |
841 | |
872 | |
842 | /* Used by update_object to know if the object being passed is |
873 | /* Used by update_object to know if the object being passed is |
843 | * being added or removed. |
874 | * being added or removed. |
844 | */ |
875 | */ |
845 | #define UP_OBJ_INSERT 1 |
876 | #define UP_OBJ_INSERT 1 |
… | |
… | |
875 | #define INS_ABOVE_FLOOR_ONLY 0x0002 |
906 | #define INS_ABOVE_FLOOR_ONLY 0x0002 |
876 | #define INS_NO_WALK_ON 0x0004 |
907 | #define INS_NO_WALK_ON 0x0004 |
877 | #define INS_ON_TOP 0x0008 |
908 | #define INS_ON_TOP 0x0008 |
878 | #define INS_BELOW_ORIGINATOR 0x0010 |
909 | #define INS_BELOW_ORIGINATOR 0x0010 |
879 | |
910 | |
880 | #define ARCH_DEPLETION "depletion" |
911 | //-GPL |
881 | |
912 | |
882 | #endif |
913 | #endif |
883 | |
914 | |