| 8 | | /* |
|---|
| 9 | | * The "message memorization" package. |
|---|
| 10 | | * |
|---|
| 11 | | * Each call to "message_add(s)" will add a new "most recent" message |
|---|
| 12 | | * to the "message recall list", using the contents of the string "s". |
|---|
| 13 | | * |
|---|
| 14 | | * The number of memorized messages is available as "message_num()". |
|---|
| 15 | | * |
|---|
| 16 | | * Old messages can be retrieved by "message_str(age)", where the "age" |
|---|
| 17 | | * of the most recently memorized message is zero, and the oldest "age" |
|---|
| 18 | | * which is available is "message_num() - 1". Messages outside this |
|---|
| 19 | | * range are returned as the empty string. |
|---|
| 20 | | */ |
|---|
| 21 | | |
|---|
| | 6 | /*** Constants ***/ |
|---|
| | 7 | |
|---|
| | 8 | |
|---|
| | 9 | /*** Message constants ***/ |
|---|
| | 10 | |
|---|
| | 11 | enum |
|---|
| | 12 | { |
|---|
| | 13 | MSG_GENERIC = 0, |
|---|
| | 14 | MSG_HIT = 1, |
|---|
| | 15 | MSG_MISS = 2, |
|---|
| | 16 | MSG_FLEE = 3, |
|---|
| | 17 | MSG_DROP = 4, |
|---|
| | 18 | MSG_KILL = 5, |
|---|
| | 19 | MSG_LEVEL = 6, |
|---|
| | 20 | MSG_DEATH = 7, |
|---|
| | 21 | MSG_STUDY = 8, |
|---|
| | 22 | MSG_TELEPORT = 9, |
|---|
| | 23 | MSG_SHOOT = 10, |
|---|
| | 24 | MSG_QUAFF = 11, |
|---|
| | 25 | MSG_ZAP_ROD = 12, |
|---|
| | 26 | MSG_WALK = 13, |
|---|
| | 27 | MSG_TPOTHER = 14, |
|---|
| | 28 | MSG_HITWALL = 15, |
|---|
| | 29 | MSG_EAT = 16, |
|---|
| | 30 | MSG_STORE1 = 17, |
|---|
| | 31 | MSG_STORE2 = 18, |
|---|
| | 32 | MSG_STORE3 = 19, |
|---|
| | 33 | MSG_STORE4 = 20, |
|---|
| | 34 | MSG_DIG = 21, |
|---|
| | 35 | MSG_OPENDOOR = 22, |
|---|
| | 36 | MSG_SHUTDOOR = 23, |
|---|
| | 37 | MSG_TPLEVEL = 24, |
|---|
| | 38 | MSG_BELL = 25, |
|---|
| | 39 | MSG_NOTHING_TO_OPEN = 26, |
|---|
| | 40 | MSG_LOCKPICK_FAIL = 27, |
|---|
| | 41 | MSG_STAIRS_DOWN = 28, |
|---|
| | 42 | MSG_HITPOINT_WARN = 29, |
|---|
| | 43 | MSG_ACT_ARTIFACT = 30, |
|---|
| | 44 | MSG_USE_STAFF = 31, |
|---|
| | 45 | MSG_DESTROY = 32, |
|---|
| | 46 | MSG_MON_HIT = 33, |
|---|
| | 47 | MSG_MON_TOUCH = 34, |
|---|
| | 48 | MSG_MON_PUNCH = 35, |
|---|
| | 49 | MSG_MON_KICK = 36, |
|---|
| | 50 | MSG_MON_CLAW = 37, |
|---|
| | 51 | MSG_MON_BITE = 38, |
|---|
| | 52 | MSG_MON_STING = 39, |
|---|
| | 53 | MSG_MON_BUTT = 40, |
|---|
| | 54 | MSG_MON_CRUSH = 41, |
|---|
| | 55 | MSG_MON_ENGULF = 42, |
|---|
| | 56 | MSG_MON_CRAWL = 43, |
|---|
| | 57 | MSG_MON_DROOL = 44, |
|---|
| | 58 | MSG_MON_SPIT = 45, |
|---|
| | 59 | MSG_MON_GAZE = 46, |
|---|
| | 60 | MSG_MON_WAIL = 47, |
|---|
| | 61 | MSG_MON_SPORE = 48, |
|---|
| | 62 | MSG_MON_BEG = 49, |
|---|
| | 63 | MSG_MON_INSULT = 50, |
|---|
| | 64 | MSG_MON_MOAN = 51, |
|---|
| | 65 | MSG_RECOVER = 52, |
|---|
| | 66 | MSG_BLIND = 53, |
|---|
| | 67 | MSG_CONFUSED = 54, |
|---|
| | 68 | MSG_POISONED = 55, |
|---|
| | 69 | MSG_AFRAID = 56, |
|---|
| | 70 | MSG_PARALYZED = 57, |
|---|
| | 71 | MSG_DRUGGED = 58, |
|---|
| | 72 | MSG_SPEED = 59, |
|---|
| | 73 | MSG_SLOW = 60, |
|---|
| | 74 | MSG_SHIELD = 61, |
|---|
| | 75 | MSG_BLESSED = 62, |
|---|
| | 76 | MSG_HERO = 63, |
|---|
| | 77 | MSG_BERSERK = 64, |
|---|
| | 78 | MSG_PROT_EVIL = 65, |
|---|
| | 79 | MSG_INVULN = 66, |
|---|
| | 80 | MSG_SEE_INVIS = 67, |
|---|
| | 81 | MSG_INFRARED = 68, |
|---|
| | 82 | MSG_RES_ACID = 69, |
|---|
| | 83 | MSG_RES_ELEC = 70, |
|---|
| | 84 | MSG_RES_FIRE = 71, |
|---|
| | 85 | MSG_RES_COLD = 72, |
|---|
| | 86 | MSG_RES_POIS = 73, |
|---|
| | 87 | MSG_STUN = 74, |
|---|
| | 88 | MSG_CUT = 75, |
|---|
| | 89 | MSG_STAIRS_UP = 76, |
|---|
| | 90 | MSG_STORE_ENTER = 77, |
|---|
| | 91 | MSG_STORE_LEAVE = 78, |
|---|
| | 92 | MSG_STORE_HOME = 79, |
|---|
| | 93 | MSG_MONEY1 = 80, |
|---|
| | 94 | MSG_MONEY2 = 81, |
|---|
| | 95 | MSG_MONEY3 = 82, |
|---|
| | 96 | MSG_SHOOT_HIT = 83, |
|---|
| | 97 | MSG_STORE5 = 84, |
|---|
| | 98 | MSG_LOCKPICK = 85, |
|---|
| | 99 | MSG_DISARM = 86, |
|---|
| | 100 | MSG_IDENT_BAD = 87, |
|---|
| | 101 | MSG_IDENT_EGO = 88, |
|---|
| | 102 | MSG_IDENT_ART = 89, |
|---|
| | 103 | MSG_BR_ELEMENTS = 90, |
|---|
| | 104 | MSG_BR_FROST = 91, |
|---|
| | 105 | MSG_BR_ELEC = 92, |
|---|
| | 106 | MSG_BR_ACID = 93, |
|---|
| | 107 | MSG_BR_GAS = 94, |
|---|
| | 108 | MSG_BR_FIRE = 95, |
|---|
| | 109 | MSG_BR_CONF = 96, |
|---|
| | 110 | MSG_BR_DISENCHANT = 97, |
|---|
| | 111 | MSG_BR_CHAOS = 98, |
|---|
| | 112 | MSG_BR_SHARDS = 99, |
|---|
| | 113 | MSG_BR_SOUND = 100, |
|---|
| | 114 | MSG_BR_LIGHT = 101, |
|---|
| | 115 | MSG_BR_DARK = 102, |
|---|
| | 116 | MSG_BR_NETHER = 103, |
|---|
| | 117 | MSG_BR_NEXUS = 104, |
|---|
| | 118 | MSG_BR_TIME = 105, |
|---|
| | 119 | MSG_BR_INERTIA = 106, |
|---|
| | 120 | MSG_BR_GRAVITY = 107, |
|---|
| | 121 | MSG_BR_PLASMA = 108, |
|---|
| | 122 | MSG_BR_FORCE = 109, |
|---|
| | 123 | MSG_SUM_MONSTER = 110, |
|---|
| | 124 | MSG_SUM_ANGEL = 111, |
|---|
| | 125 | MSG_SUM_UNDEAD = 112, |
|---|
| | 126 | MSG_SUM_ANIMAL = 113, |
|---|
| | 127 | MSG_SUM_SPIDER = 114, |
|---|
| | 128 | MSG_SUM_HOUND = 115, |
|---|
| | 129 | MSG_SUM_HYDRA = 116, |
|---|
| | 130 | MSG_SUM_DEMON = 117, |
|---|
| | 131 | MSG_SUM_DRAGON = 118, |
|---|
| | 132 | MSG_SUM_HI_UNDEAD = 119, |
|---|
| | 133 | MSG_SUM_HI_DRAGON = 120, |
|---|
| | 134 | MSG_SUM_HI_DEMON = 121, |
|---|
| | 135 | MSG_SUM_WRAITH = 122, |
|---|
| | 136 | MSG_SUM_UNIQUE = 123, |
|---|
| | 137 | MSG_WIELD = 124, |
|---|
| | 138 | MSG_CURSED = 125, |
|---|
| | 139 | MSG_PSEUDOID = 126, |
|---|
| | 140 | MSG_HUNGRY = 127, |
|---|
| | 141 | MSG_NOTICE = 128, |
|---|
| | 142 | MSG_AMBIENT_DAY = 129, |
|---|
| | 143 | MSG_AMBIENT_NITE = 130, |
|---|
| | 144 | MSG_AMBIENT_DNG1 = 131, |
|---|
| | 145 | MSG_AMBIENT_DNG2 = 132, |
|---|
| | 146 | MSG_AMBIENT_DNG3 = 133, |
|---|
| | 147 | MSG_AMBIENT_DNG4 = 134, |
|---|
| | 148 | MSG_AMBIENT_DNG5 = 135, |
|---|
| | 149 | MSG_CREATE_TRAP = 136, |
|---|
| | 150 | MSG_SHRIEK = 137, |
|---|
| | 151 | MSG_CAST_FEAR = 138, |
|---|
| | 152 | MSG_HIT_GOOD = 139, |
|---|
| | 153 | MSG_HIT_GREAT = 140, |
|---|
| | 154 | MSG_HIT_SUPERB = 141, |
|---|
| | 155 | MSG_HIT_HI_GREAT = 142, |
|---|
| | 156 | MSG_HIT_HI_SUPERB = 143, |
|---|
| | 157 | MSG_SPELL = 144, |
|---|
| | 158 | MSG_PRAYER = 145, |
|---|
| | 159 | MSG_KILL_UNIQUE = 146, |
|---|
| | 160 | MSG_KILL_KING = 147, |
|---|
| | 161 | MSG_DRAIN_STAT = 148, |
|---|
| | 162 | MSG_MULTIPLY = 149, |
|---|
| | 163 | |
|---|
| | 164 | MSG_MAX = 150, |
|---|
| | 165 | SOUND_MAX = MSG_MAX |
|---|
| | 166 | }; |
|---|
| | 167 | |
|---|
| | 168 | |
|---|
| | 169 | /*** Functions ***/ |
|---|
| | 170 | |
|---|
| | 171 | /** Initialisation/exit **/ |
|---|
| | 172 | |
|---|
| | 173 | /* |
|---|
| | 174 | * Initialise the messages package. Should be called before using any other |
|---|
| | 175 | * functions in the package. |
|---|
| | 176 | */ |
|---|
| | 192 | |
|---|
| | 193 | /** Individual message handling **/ |
|---|
| | 194 | |
|---|
| | 195 | /* |
|---|
| | 196 | * Save a new message into the memory buffer, with text `str` and type `type`. |
|---|
| | 197 | * The type should be one of the MSG_ constants defined above. |
|---|
| | 198 | * |
|---|
| | 199 | * The new message may not be saved if it is identical to the one saved before |
|---|
| | 200 | * it, in which case the "count" of the message will be increased instead. |
|---|
| | 201 | * This count can be fetched using the message_count() function. |
|---|
| | 202 | */ |
|---|
| | 203 | void message_add(const char *str, u16b type); |
|---|
| | 204 | |
|---|
| | 205 | |
|---|
| | 206 | /* |
|---|
| | 207 | * Returns the text of the message of age `age`. The age of the most recently |
|---|
| | 208 | * saved message is 0, the one before that is of age 1, etc. |
|---|
| | 209 | * |
|---|
| | 210 | * Returns the empty string if the no messages of the age specified are |
|---|
| | 211 | * available. |
|---|
| | 212 | */ |
|---|
| 33 | | void message_add(const char *str, u16b type); |
|---|
| 34 | | |
|---|
| 35 | | |
|---|
| 36 | | |
|---|
| 37 | | |
|---|
| 38 | | /*** Message constants ***/ |
|---|
| 39 | | |
|---|
| 40 | | #define MSG_GENERIC 0 |
|---|
| 41 | | #define MSG_HIT 1 |
|---|
| 42 | | #define MSG_MISS 2 |
|---|
| 43 | | #define MSG_FLEE 3 |
|---|
| 44 | | #define MSG_DROP 4 |
|---|
| 45 | | #define MSG_KILL 5 |
|---|
| 46 | | #define MSG_LEVEL 6 |
|---|
| 47 | | #define MSG_DEATH 7 |
|---|
| 48 | | #define MSG_STUDY 8 |
|---|
| 49 | | #define MSG_TELEPORT 9 |
|---|
| 50 | | #define MSG_SHOOT 10 |
|---|
| 51 | | #define MSG_QUAFF 11 |
|---|
| 52 | | #define MSG_ZAP_ROD 12 |
|---|
| 53 | | #define MSG_WALK 13 |
|---|
| 54 | | #define MSG_TPOTHER 14 |
|---|
| 55 | | #define MSG_HITWALL 15 |
|---|
| 56 | | #define MSG_EAT 16 |
|---|
| 57 | | #define MSG_STORE1 17 |
|---|
| 58 | | #define MSG_STORE2 18 |
|---|
| 59 | | #define MSG_STORE3 19 |
|---|
| 60 | | #define MSG_STORE4 20 |
|---|
| 61 | | #define MSG_DIG 21 |
|---|
| 62 | | #define MSG_OPENDOOR 22 |
|---|
| 63 | | #define MSG_SHUTDOOR 23 |
|---|
| 64 | | #define MSG_TPLEVEL 24 |
|---|
| 65 | | #define MSG_BELL 25 |
|---|
| 66 | | #define MSG_NOTHING_TO_OPEN 26 |
|---|
| 67 | | #define MSG_LOCKPICK_FAIL 27 |
|---|
| 68 | | #define MSG_STAIRS_DOWN 28 |
|---|
| 69 | | #define MSG_HITPOINT_WARN 29 |
|---|
| 70 | | #define MSG_ACT_ARTIFACT 30 |
|---|
| 71 | | #define MSG_USE_STAFF 31 |
|---|
| 72 | | #define MSG_DESTROY 32 |
|---|
| 73 | | #define MSG_MON_HIT 33 |
|---|
| 74 | | #define MSG_MON_TOUCH 34 |
|---|
| 75 | | #define MSG_MON_PUNCH 35 |
|---|
| 76 | | #define MSG_MON_KICK 36 |
|---|
| 77 | | #define MSG_MON_CLAW 37 |
|---|
| 78 | | #define MSG_MON_BITE 38 |
|---|
| 79 | | #define MSG_MON_STING 39 |
|---|
| 80 | | #define MSG_MON_BUTT 40 |
|---|
| 81 | | #define MSG_MON_CRUSH 41 |
|---|
| 82 | | #define MSG_MON_ENGULF 42 |
|---|
| 83 | | #define MSG_MON_CRAWL 43 |
|---|
| 84 | | #define MSG_MON_DROOL 44 |
|---|
| 85 | | #define MSG_MON_SPIT 45 |
|---|
| 86 | | #define MSG_MON_GAZE 46 |
|---|
| 87 | | #define MSG_MON_WAIL 47 |
|---|
| 88 | | #define MSG_MON_SPORE 48 |
|---|
| 89 | | #define MSG_MON_BEG 49 |
|---|
| 90 | | #define MSG_MON_INSULT 50 |
|---|
| 91 | | #define MSG_MON_MOAN 51 |
|---|
| 92 | | #define MSG_RECOVER 52 |
|---|
| 93 | | #define MSG_BLIND 53 |
|---|
| 94 | | #define MSG_CONFUSED 54 |
|---|
| 95 | | #define MSG_POISONED 55 |
|---|
| 96 | | #define MSG_AFRAID 56 |
|---|
| 97 | | #define MSG_PARALYZED 57 |
|---|
| 98 | | #define MSG_DRUGGED 58 |
|---|
| 99 | | #define MSG_SPEED 59 |
|---|
| 100 | | #define MSG_SLOW 60 |
|---|
| 101 | | #define MSG_SHIELD 61 |
|---|
| 102 | | #define MSG_BLESSED 62 |
|---|
| 103 | | #define MSG_HERO 63 |
|---|
| 104 | | #define MSG_BERSERK 64 |
|---|
| 105 | | #define MSG_PROT_EVIL 65 |
|---|
| 106 | | #define MSG_INVULN 66 |
|---|
| 107 | | #define MSG_SEE_INVIS 67 |
|---|
| 108 | | #define MSG_INFRARED 68 |
|---|
| 109 | | #define MSG_RES_ACID 69 |
|---|
| 110 | | #define MSG_RES_ELEC 70 |
|---|
| 111 | | #define MSG_RES_FIRE 71 |
|---|
| 112 | | #define MSG_RES_COLD 72 |
|---|
| 113 | | #define MSG_RES_POIS 73 |
|---|
| 114 | | #define MSG_STUN 74 |
|---|
| 115 | | #define MSG_CUT 75 |
|---|
| 116 | | #define MSG_STAIRS_UP 76 |
|---|
| 117 | | #define MSG_STORE_ENTER 77 |
|---|
| 118 | | #define MSG_STORE_LEAVE 78 |
|---|
| 119 | | #define MSG_STORE_HOME 79 |
|---|
| 120 | | #define MSG_MONEY1 80 |
|---|
| 121 | | #define MSG_MONEY2 81 |
|---|
| 122 | | #define MSG_MONEY3 82 |
|---|
| 123 | | #define MSG_SHOOT_HIT 83 |
|---|
| 124 | | #define MSG_STORE5 84 |
|---|
| 125 | | #define MSG_LOCKPICK 85 |
|---|
| 126 | | #define MSG_DISARM 86 |
|---|
| 127 | | #define MSG_IDENT_BAD 87 |
|---|
| 128 | | #define MSG_IDENT_EGO 88 |
|---|
| 129 | | #define MSG_IDENT_ART 89 |
|---|
| 130 | | #define MSG_BR_ELEMENTS 90 |
|---|
| 131 | | #define MSG_BR_FROST 91 |
|---|
| 132 | | #define MSG_BR_ELEC 92 |
|---|
| 133 | | #define MSG_BR_ACID 93 |
|---|
| 134 | | #define MSG_BR_GAS 94 |
|---|
| 135 | | #define MSG_BR_FIRE 95 |
|---|
| 136 | | #define MSG_BR_CONF 96 |
|---|
| 137 | | #define MSG_BR_DISENCHANT 97 |
|---|
| 138 | | #define MSG_BR_CHAOS 98 |
|---|
| 139 | | #define MSG_BR_SHARDS 99 |
|---|
| 140 | | #define MSG_BR_SOUND 100 |
|---|
| 141 | | #define MSG_BR_LIGHT 101 |
|---|
| 142 | | #define MSG_BR_DARK 102 |
|---|
| 143 | | #define MSG_BR_NETHER 103 |
|---|
| 144 | | #define MSG_BR_NEXUS 104 |
|---|
| 145 | | #define MSG_BR_TIME 105 |
|---|
| 146 | | #define MSG_BR_INERTIA 106 |
|---|
| 147 | | #define MSG_BR_GRAVITY 107 |
|---|
| 148 | | #define MSG_BR_PLASMA 108 |
|---|
| 149 | | #define MSG_BR_FORCE 109 |
|---|
| 150 | | #define MSG_SUM_MONSTER 110 |
|---|
| 151 | | #define MSG_SUM_ANGEL 111 |
|---|
| 152 | | #define MSG_SUM_UNDEAD 112 |
|---|
| 153 | | #define MSG_SUM_ANIMAL 113 |
|---|
| 154 | | #define MSG_SUM_SPIDER 114 |
|---|
| 155 | | #define MSG_SUM_HOUND 115 |
|---|
| 156 | | #define MSG_SUM_HYDRA 116 |
|---|
| 157 | | #define MSG_SUM_DEMON 117 |
|---|
| 158 | | #define MSG_SUM_DRAGON 118 |
|---|
| 159 | | #define MSG_SUM_HI_UNDEAD 119 |
|---|
| 160 | | #define MSG_SUM_HI_DRAGON 120 |
|---|
| 161 | | #define MSG_SUM_HI_DEMON 121 |
|---|
| 162 | | #define MSG_SUM_WRAITH 122 |
|---|
| 163 | | #define MSG_SUM_UNIQUE 123 |
|---|
| 164 | | #define MSG_WIELD 124 |
|---|
| 165 | | #define MSG_CURSED 125 |
|---|
| 166 | | #define MSG_PSEUDOID 126 |
|---|
| 167 | | #define MSG_HUNGRY 127 |
|---|
| 168 | | #define MSG_NOTICE 128 |
|---|
| 169 | | #define MSG_AMBIENT_DAY 129 |
|---|
| 170 | | #define MSG_AMBIENT_NITE 130 |
|---|
| 171 | | #define MSG_AMBIENT_DNG1 131 |
|---|
| 172 | | #define MSG_AMBIENT_DNG2 132 |
|---|
| 173 | | #define MSG_AMBIENT_DNG3 133 |
|---|
| 174 | | #define MSG_AMBIENT_DNG4 134 |
|---|
| 175 | | #define MSG_AMBIENT_DNG5 135 |
|---|
| 176 | | #define MSG_CREATE_TRAP 136 |
|---|
| 177 | | #define MSG_SHRIEK 137 |
|---|
| 178 | | #define MSG_CAST_FEAR 138 |
|---|
| 179 | | #define MSG_HIT_GOOD 139 |
|---|
| 180 | | #define MSG_HIT_GREAT 140 |
|---|
| 181 | | #define MSG_HIT_SUPERB 141 |
|---|
| 182 | | #define MSG_HIT_HI_GREAT 142 |
|---|
| 183 | | #define MSG_HIT_HI_SUPERB 143 |
|---|
| 184 | | #define MSG_SPELL 144 |
|---|
| 185 | | #define MSG_PRAYER 145 |
|---|
| 186 | | #define MSG_KILL_UNIQUE 146 |
|---|
| 187 | | #define MSG_KILL_KING 147 |
|---|
| 188 | | #define MSG_DRAIN_STAT 148 |
|---|
| 189 | | #define MSG_MULTIPLY 149 |
|---|
| 190 | | |
|---|
| 191 | | #define MSG_MAX 150 |
|---|
| 192 | | |
|---|
| 193 | | /* |
|---|
| 194 | | * Hack -- maximum known sounds |
|---|
| 195 | | * |
|---|
| 196 | | * Should be the same as MSG_MAX for compatibility reasons. |
|---|
| 197 | | */ |
|---|
| 198 | | #define SOUND_MAX MSG_MAX |
|---|