… | |
… | |
61 | const char *nonuse_name; /* Name to describe objects we can't use */ |
61 | const char *nonuse_name; /* Name to describe objects we can't use */ |
62 | } Body_Locations; |
62 | } Body_Locations; |
63 | |
63 | |
64 | extern Body_Locations body_locations[NUM_BODY_LOCATIONS]; |
64 | extern Body_Locations body_locations[NUM_BODY_LOCATIONS]; |
65 | |
65 | |
|
|
66 | // for each set of directions (1 == up, 2 == right, 4 == down, 8 == left) |
|
|
67 | // contains the wall suffix (0, 1_3, 1_4 and so on). |
|
|
68 | extern const char *wall_suffix[16]; |
|
|
69 | |
66 | #define NUM_COINS 4 /* number of coin types */ |
70 | #define NUM_COINS 4 /* number of coin types */ |
67 | extern const char *const coins[NUM_COINS + 1]; |
71 | extern const char *const coins[NUM_COINS + 1]; |
|
|
72 | |
|
|
73 | // restart server when object_count reaches this value |
|
|
74 | #define RESTART_COUNT 0xe0000000 |
68 | |
75 | |
69 | /* |
76 | /* |
70 | * Each object (this also means archetypes!) could have a few of these |
77 | * Each object (this also means archetypes!) could have a few of these |
71 | * "dangling" from it; this could also end up containing 'parse errors'. |
78 | * "dangling" from it; this could also end up containing 'parse errors'. |
72 | * |
79 | * |
… | |
… | |
293 | sint16 SP_level_spellpoint_cost (object *caster, object *spell, int flags); |
300 | sint16 SP_level_spellpoint_cost (object *caster, object *spell, int flags); |
294 | int SP_level_dam_adjust (object *caster, object *spob); |
301 | int SP_level_dam_adjust (object *caster, object *spob); |
295 | int SP_level_duration_adjust (object *caster, object *spob); |
302 | int SP_level_duration_adjust (object *caster, object *spob); |
296 | int SP_level_range_adjust (object *caster, object *spob); |
303 | int SP_level_range_adjust (object *caster, object *spob); |
297 | |
304 | |
|
|
305 | struct freelist_item |
|
|
306 | { |
|
|
307 | freelist_item *next; |
|
|
308 | uint32_t count; |
|
|
309 | }; |
|
|
310 | |
298 | struct object : zero_initialised, object_copy |
311 | struct object : object_copy |
299 | { |
312 | { |
300 | // These variables are not changed by ->copy_to |
313 | // These variables are not changed by ->copy_to |
301 | maptile *ACC (RW, map); /* Pointer to the map in which this object is present */ |
314 | maptile *ACC (RW, map); /* Pointer to the map in which this object is present */ |
302 | |
315 | |
303 | UUID ACC (RW, uuid); // Unique Identifier, survives saves etc. |
316 | UUID ACC (RW, uuid); // Unique Identifier, survives saves etc. |
304 | int ACC (RO, count); |
317 | uint32_t ACC (RO, count); |
305 | object_vector_index ACC (RO, index); // index into objects |
318 | object_vector_index ACC (RO, index); // index into objects |
306 | object_vector_index ACC (RO, active); // index into actives |
319 | object_vector_index ACC (RO, active); // index into actives |
307 | |
320 | |
308 | player_ptr ACC (RW, contr); /* Pointer to the player which control this object, ALWAYS set *iff* type == PLAYER */ |
321 | player_ptr ACC (RW, contr); /* Pointer to the player which control this object, ALWAYS set *iff* type == PLAYER */ |
309 | |
322 | |
… | |
… | |
321 | */ |
334 | */ |
322 | 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 */ |
323 | 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 |
324 | key_value *key_values; /* Fields not explictly known by the loader. */ |
337 | key_value *key_values; /* Fields not explictly known by the loader. */ |
325 | |
338 | |
|
|
339 | MTH void set_flag (int flagnum) |
|
|
340 | { |
|
|
341 | flag [flagnum] = true; |
|
|
342 | } |
|
|
343 | |
|
|
344 | MTH void clr_flag (int flagnum) |
|
|
345 | { |
|
|
346 | flag [flagnum] = false; |
|
|
347 | } |
|
|
348 | |
326 | // privates / perl |
349 | // privates / perl |
327 | shstr_tmp kv_get (shstr_tmp key) const; |
350 | shstr_tmp kv_get (shstr_tmp key) const; |
328 | void kv_del (shstr_tmp key); |
351 | void kv_del (shstr_tmp key); |
329 | void kv_set (shstr_tmp key, shstr_tmp value); |
352 | void kv_set (shstr_tmp key, shstr_tmp value); |
330 | |
353 | |
… | |
… | |
432 | } |
455 | } |
433 | |
456 | |
434 | MTH void set_owner (object *owner); |
457 | MTH void set_owner (object *owner); |
435 | MTH void set_speed (float speed); |
458 | MTH void set_speed (float speed); |
436 | MTH void set_glow_radius (sint8 rad); |
459 | MTH void set_glow_radius (sint8 rad); |
437 | MTH bool change_skill (object *ob); // deprecated? |
|
|
438 | |
460 | |
439 | MTH void open_container (object *new_container); |
461 | MTH void open_container (object *new_container); |
440 | MTH void close_container () |
462 | MTH void close_container () |
441 | { |
463 | { |
442 | open_container (0); |
464 | open_container (0); |
… | |
… | |
552 | |
574 | |
553 | static bool msg_has_dialogue (const char *msg) { return *msg == '@'; } |
575 | static bool msg_has_dialogue (const char *msg) { return *msg == '@'; } |
554 | |
576 | |
555 | MTH bool has_dialogue () const { return msg_has_dialogue (&msg); } |
577 | MTH bool has_dialogue () const { return msg_has_dialogue (&msg); } |
556 | |
578 | |
|
|
579 | /* need_identify returns true if the item should be identified. This |
|
|
580 | * function really should not exist - by default, any item not identified |
|
|
581 | * should need it. |
|
|
582 | */ |
|
|
583 | MTH bool need_identify () const; |
|
|
584 | |
557 | // returns the outermost owner, never returns 0 |
585 | // returns the outermost owner, never returns 0 |
558 | MTH object *outer_owner () |
586 | MTH object *outer_owner () |
559 | { |
587 | { |
560 | object *op; |
588 | object *op; |
561 | |
589 | |
… | |
… | |
628 | MTH bool has_carried_lights () const |
656 | MTH bool has_carried_lights () const |
629 | { |
657 | { |
630 | return glow_radius; |
658 | return glow_radius; |
631 | } |
659 | } |
632 | |
660 | |
633 | // returns the player that cna see this object, if any |
661 | // returns the player that can see this object, if any |
634 | MTH object *visible_to () const; |
662 | MTH object *visible_to () const; |
635 | |
663 | |
636 | MTH std::string long_desc (object *who = 0); // query_name . " " . describe |
664 | MTH std::string long_desc (object *who = 0); // query_name . " " . describe |
637 | MTH std::string describe_monster (object *who = 0); |
665 | MTH std::string describe_monster (object *who = 0); |
638 | MTH std::string describe_item (object *who = 0); |
666 | MTH std::string describe_item (object *who = 0); |
… | |
… | |
648 | // objects. This method only works on objects not inserted |
676 | // objects. This method only works on objects not inserted |
649 | // anywhere. |
677 | // anywhere. |
650 | MTH void expand_tail (); |
678 | MTH void expand_tail (); |
651 | |
679 | |
652 | MTH void create_treasure (treasurelist *tl, int flags = 0); |
680 | MTH void create_treasure (treasurelist *tl, int flags = 0); |
|
|
681 | |
|
|
682 | // makes sure the player has the named skill, |
|
|
683 | // and also makes it innate if can_use is true. |
|
|
684 | // returns the new skill or 0 if no such skill exists. |
|
|
685 | MTH object *give_skill (shstr_cmp name, bool can_use = false); |
|
|
686 | MTH void become_follower (object *new_god); |
653 | |
687 | |
654 | // insert object at same map position as 'where' |
688 | // insert object at same map position as 'where' |
655 | // handles both inventory and map "positions" |
689 | // handles both inventory and map "positions" |
656 | MTH object *insert_at (object *where, object *originator = 0, int flags = 0); |
690 | MTH object *insert_at (object *where, object *originator = 0, int flags = 0); |
657 | // check whether we can put this into the map, respect max_nrof, max_volume, max_items |
691 | // check whether we can put this into the map, respect max_nrof, max_volume, max_items |
… | |
… | |
664 | MTH void deactivate_recursive (); |
698 | MTH void deactivate_recursive (); |
665 | |
699 | |
666 | // set the given flag on all objects in the inventory recursively |
700 | // set the given flag on all objects in the inventory recursively |
667 | MTH void set_flag_inv (int flag, int value = 1); |
701 | MTH void set_flag_inv (int flag, int value = 1); |
668 | |
702 | |
669 | void enter_exit (object *exit);//Perl |
703 | void enter_exit (object *exit); // perl |
670 | MTH void enter_map (maptile *newmap, int x, int y); |
704 | MTH bool enter_map (maptile *newmap, int x, int y); |
671 | void player_goto (const_utf8_string path, int x, int y); // only for players |
705 | void player_goto (const_utf8_string path, int x, int y); // only for players |
672 | MTH bool apply (object *ob, int aflags = AP_APPLY); // ob may be 0 |
706 | MTH bool apply (object *ob, int aflags = AP_APPLY); // ob may be 0 |
|
|
707 | |
|
|
708 | MTH object *mark () const; |
|
|
709 | MTH void splay_marked (); |
673 | |
710 | |
674 | // returns the mapspace this object is in |
711 | // returns the mapspace this object is in |
675 | mapspace &ms () const; |
712 | mapspace &ms () const; |
676 | |
713 | |
677 | // fully recursive iterator |
714 | // fully recursive iterator |
… | |
… | |
728 | return weight + carrying; |
765 | return weight + carrying; |
729 | } |
766 | } |
730 | |
767 | |
731 | MTH struct region *region () const; |
768 | MTH struct region *region () const; |
732 | |
769 | |
733 | void statusmsg (const_utf8_string msg, int color = NDI_BLACK); |
770 | MTH void statusmsg (const_utf8_string msg, int color = NDI_BLACK); |
734 | void failmsg (const_utf8_string msg, int color = NDI_RED); |
771 | MTH void failmsg (const_utf8_string msg, int color = NDI_RED); |
|
|
772 | void failmsgf (const_utf8_string format, ...); // always NDI_RED... |
735 | |
773 | |
736 | const_utf8_string query_inventory (object *who = 0, const_utf8_string indent = ""); |
774 | MTH const_utf8_string query_inventory (object *who = 0, const_utf8_string indent = ""); |
737 | |
775 | |
738 | MTH const_octet_string ref () const; // creates and returns a consistent persistent object reference |
776 | MTH const_octet_string ref () const; // creates and returns a consistent persistent object reference |
739 | static object *deref (const_octet_string ref); // returns the object from the generated refreence, if possible |
777 | static object *deref (const_octet_string ref); // returns the object from the generated reference, if possible |
740 | |
778 | |
741 | // make some noise with given item into direction dir, |
779 | // make some noise with given item into direction dir, |
742 | // currently only used for players to make them temporarily visible |
780 | // currently only used for players to make them temporarily visible |
743 | // when they are invisible. |
781 | // when they are invisible. |
744 | MTH void make_noise (); |
782 | MTH void make_noise (); |
… | |
… | |
756 | MTH int anim_frames () const { return anim ().num_animations; } |
794 | MTH int anim_frames () const { return anim ().num_animations; } |
757 | MTH int anim_facings () const { return anim ().facings; } |
795 | MTH int anim_facings () const { return anim ().facings; } |
758 | |
796 | |
759 | MTH utf8_string as_string (); |
797 | MTH utf8_string as_string (); |
760 | |
798 | |
|
|
799 | // low-level management, statistics, ... |
|
|
800 | static uint32_t ACC (RW, object_count); |
|
|
801 | static uint32_t ACC (RW, free_count); |
|
|
802 | static uint32_t ACC (RW, create_count); |
|
|
803 | static uint32_t ACC (RW, destroy_count); |
|
|
804 | static freelist_item *freelist; |
|
|
805 | MTH static void freelist_free (int count); |
|
|
806 | |
761 | protected: |
807 | protected: |
762 | void link (); |
808 | void link (); |
763 | void unlink (); |
809 | void unlink (); |
|
|
810 | |
|
|
811 | void do_delete (); |
764 | |
812 | |
765 | object (); |
813 | object (); |
766 | ~object (); |
814 | ~object (); |
767 | |
815 | |
768 | private: |
816 | private: |
… | |
… | |
805 | */ |
853 | */ |
806 | |
854 | |
807 | //-GPL |
855 | //-GPL |
808 | |
856 | |
809 | INTERFACE_CLASS (archetype) |
857 | INTERFACE_CLASS (archetype) |
810 | struct archetype : object |
858 | struct archetype : object, zero_initialised |
811 | { |
859 | { |
812 | static arch_ptr empty; // the empty_archetype |
860 | static arch_ptr empty; // the empty_archetype |
813 | MTH static void gc (); |
861 | MTH static void gc (); |
814 | |
862 | |
815 | archetype (const_utf8_string name); |
863 | archetype (const_utf8_string name); |
… | |
… | |
833 | |
881 | |
834 | // support for archetype loading |
882 | // support for archetype loading |
835 | static archetype *read (object_thawer &f); |
883 | static archetype *read (object_thawer &f); |
836 | MTH static void commit_load (); // commit any objects loaded, resolves cyclic dependencies and more |
884 | MTH static void commit_load (); // commit any objects loaded, resolves cyclic dependencies and more |
837 | static void postpone_arch_ref (arch_ptr &ref, const_utf8_string other_arch); /* postpone other_arch reference */ |
885 | static void postpone_arch_ref (arch_ptr &ref, const_utf8_string other_arch); /* postpone other_arch reference */ |
|
|
886 | |
|
|
887 | protected: |
|
|
888 | void do_delete (); |
838 | }; |
889 | }; |
839 | |
890 | |
840 | // returns whether the object is a dragon player, which are often specialcased |
891 | // returns whether the object is a dragon player, which are often specialcased |
841 | inline bool |
892 | inline bool |
842 | object::is_dragon () const |
893 | object::is_dragon () const |
… | |
… | |
915 | #define INS_NO_MERGE 0x0001 |
966 | #define INS_NO_MERGE 0x0001 |
916 | #define INS_ABOVE_FLOOR_ONLY 0x0002 |
967 | #define INS_ABOVE_FLOOR_ONLY 0x0002 |
917 | #define INS_NO_WALK_ON 0x0004 |
968 | #define INS_NO_WALK_ON 0x0004 |
918 | #define INS_ON_TOP 0x0008 |
969 | #define INS_ON_TOP 0x0008 |
919 | #define INS_BELOW_ORIGINATOR 0x0010 |
970 | #define INS_BELOW_ORIGINATOR 0x0010 |
|
|
971 | #define INS_NO_AUTO_EXIT 0x0020 // temporary, fix exits instead |
920 | |
972 | |
921 | //-GPL |
973 | //-GPL |
922 | |
974 | |
923 | #endif |
975 | #endif |
924 | |
976 | |