1 #ifndef SENT_H__ 2 #define SENT_H__ 1 3 4 /*--------------------------------------------------------------------------- 5 * Dynamic data structures used to annotate objects. 6 * 7 *--------------------------------------------------------------------------- 8 * This include file defines two types of annotation structures: actions 9 * and shadow structures. A third type, interactive structures, which are 10 * a special case of shadow structures, is defined in comm.h. All annotations 11 * structures are derived from the same sentence base structure. 12 * 13 * Sentences annotate an object with information about actions (verbs 14 * and functions), and shadows, and network connection data ('interactive 15 * sentences'). In fact, the shadow sentence serves as anchor point for 16 * all annotations but actions. 17 * 18 * The sentences are kept in a single-linked list, originating at 19 * object->sent. Within this list, there can be only one shadow 20 * sentence, and it is always placed at the head of the list. This very 21 * instance forms the head of an independent double-linked list should there 22 * be more than one shadow for the object. 23 * 24 * The different types of sentences are distinguished by their '.type' 25 * member. The following types are defined: 26 * 27 * SENT_PLAIN, SENT_SHORT_VERB, SENT_NO_SPACE 28 * The sentence is of type 'action_t' and holds information 29 * about an action (verb + function) available to one object. 30 * 31 * SENT_MARKER 32 * A special case of 'action_t' sentence which is used to 33 * control the search for a command. 34 * 35 * SENT_SHADOW: 36 * The sentence is of type 'shadow_sentence' and describes 37 * an object shadow. 38 * 39 *--------------------------------------------------------------------------- 40 */ 41 42 #include "driver.h" 43 #include "typedefs.h" 44 45 enum sent_type_e { 46 SENT_PLAIN = 0 /* Normal action */ 47 , SENT_SHORT_VERB /* Action with abbreviatable verb */ 48 , SENT_OLD_NO_SPACE /* Action with embedded verb (old style) */ 49 , SENT_NO_SPACE /* Action with embedded verb */ 50 , SENT_MARKER /* Internal: marker for a command search */ 51 , SENT_SHADOW /* Internal: shadow data */ 52 }; 53 54 typedef enum sent_type_e sent_type_t; 55 56 #define SENT_IS_INTERNAL(x) ((x) >= SENT_MARKER) 57 58 /* --- struct sentence_s: the basic sentence structure --- 59 */ 60 61 struct sentence_s 62 { 63 sentence_t * next; /* Next sentence in the list */ 64 sent_type_t type; /* Type of this sentence */ 65 }; 66 67 68 /* --- struct action_s: the action sentence structure --- 69 * 70 * Sentences of this type are used to hold the actions (verbs+functions) 71 * available to one object. 72 * 73 * A special case are SENT_MARKER sentences which are used to 74 * mark the progress of a command search. 75 */ 76 77 struct action_s 78 { 79 sentence_t sent; /* The basic sentence */ 80 string_t *verb; 81 /* Shared string: the defined verb. 82 * For SENT_PLAIN and SENT_SHORT_VERB, this is the whole verb. 83 * For SENT_NO_SPACE, only the first letters of the command have 84 * to match this verb. 85 */ 86 object_t *ob; 87 /* Object defining this sentence. This value is used for comparisons 88 * only, and in case of SENT_MARKER it is in fact a *rt_context_t. 89 * The reference is not counted. 90 */ 91 object_t *shadow_ob; 92 /* If the action originates from an object shadow, .ob will be the 93 * shadowed object (as the action has to seem to come from there), 94 * and this will be the actual shadow object defining the object. 95 * The reference is not counted. 96 * Otherwise, this entry is NULL. 97 */ 98 string_t *function; /* the name of the action function */ 99 unsigned short short_verb; 100 /* SENT_SHORT_VERB: the number of characters which have to 101 * match at minimum. 102 */ 103 }; 104 105 /* --- struct shadow_s: the action sentence structure --- 106 * 107 * Main purpose of the shadow sentence is to link together the shadowing 108 * object with the shadowee. Multi-level shadows are this way (indirectly 109 * through the object and object->sent pointers) kept in a double-linked 110 * list. 111 * 112 * Additionally the shadow sentence is used to hold additionally information 113 * used by the object for short time. Such information is the interactive_t 114 * for interactive objects. 115 */ 116 struct shadow_s 117 { 118 sentence_t sent; /* The basic sentence */ 119 object_t *shadowing; /* "prev": the shadowed object */ 120 object_t *shadowed_by; /* "next": the shadowing object */ 121 122 interactive_t *ip; /* the information for interactive objects */ 123 }; 124 125 /* --- Macros --- */ 126 127 #define O_GET_SHADOW(ob) ((shadow_t *)(ob)->sent) 128 #define O_GET_INTERACTIVE(ob) (O_GET_SHADOW(ob)->ip) 129 130 /* Expand to an expression suitable to query or set the 131 * indicated attribute. No checks are performed. 132 */ 133 134 /* --- Prototypes --- */ 135 136 /* In actions.c: */ 137 extern void remove_action_sent(object_t *ob, object_t *player); 138 extern void remove_environment_sent(object_t *player); 139 140 /* In simulate.c */ 141 extern void check_shadow_sent (object_t *ob); 142 extern void assert_shadow_sent (object_t *ob); 143 144 #endif /* SENT_H__ */ 145