1 | %{ |
1 | %{ |
2 | /* |
2 | /* |
3 | * static char *rcsid_object_c = |
3 | * static char *rcsid_object_c = |
4 | * "$Id: loader.l,v 1.13 2006/08/28 14:05:23 root Exp $"; |
4 | * "$Id: loader.l,v 1.18 2006/08/31 17:54:14 root Exp $"; |
5 | */ |
5 | */ |
6 | |
6 | |
7 | /* |
7 | /* |
8 | CrossFire, A Multiplayer game for X-windows |
8 | CrossFire, A Multiplayer game for X-windows |
9 | |
9 | |
… | |
… | |
58 | * new spell won't have been used, and thus won't have any legacy object. |
58 | * new spell won't have been used, and thus won't have any legacy object. |
59 | * NULL entries in this table are valid - to denote objects that should |
59 | * NULL entries in this table are valid - to denote objects that should |
60 | * not be updated for whatever reason. |
60 | * not be updated for whatever reason. |
61 | */ |
61 | */ |
62 | const char *spell_mapping[] = { |
62 | const char *spell_mapping[] = { |
63 | "spell_magic_bullet", /* 0 */ |
63 | "spell_magic_bullet", /* 0 */ |
64 | "spell_small_fireball", /* 1 */ |
64 | "spell_small_fireball", /* 1 */ |
65 | "spell_medium_fireball", /* 2 */ |
65 | "spell_medium_fireball", /* 2 */ |
66 | "spell_large_fireball", /* 3 */ |
66 | "spell_large_fireball", /* 3 */ |
67 | "spell_burning_hands", /* 4 */ |
67 | "spell_burning_hands", /* 4 */ |
68 | "spell_sm_lightning", /* 5 */ |
68 | "spell_sm_lightning", /* 5 */ |
69 | "spell_large_lightning", /* 6 */ |
69 | "spell_large_lightning", /* 6 */ |
70 | "spell_magic_missile", /* 7 */ |
70 | "spell_magic_missile", /* 7 */ |
71 | "spell_create_bomb", /* 8 */ |
71 | "spell_create_bomb", /* 8 */ |
72 | "spell_summon_golem", /* 9 */ |
72 | "spell_summon_golem", /* 9 */ |
73 | "spell_summon_fire_elemental", /* 10 */ |
73 | "spell_summon_fire_elemental", /* 10 */ |
74 | "spell_summon_earth_elemental", /* 11 */ |
74 | "spell_summon_earth_elemental", /* 11 */ |
75 | "spell_summon_water_elemental", /* 12 */ |
75 | "spell_summon_water_elemental", /* 12 */ |
76 | "spell_summon_air_elemental", /* 13 */ |
76 | "spell_summon_air_elemental", /* 13 */ |
77 | "spell_dimension_door", /* 14 */ |
77 | "spell_dimension_door", /* 14 */ |
78 | "spell_create_earth_wall", /* 15 */ |
78 | "spell_create_earth_wall", /* 15 */ |
79 | "spell_paralyze", /* 16 */ |
79 | "spell_paralyze", /* 16 */ |
80 | "spell_icestorm", /* 17 */ |
80 | "spell_icestorm", /* 17 */ |
81 | "spell_magic_mapping", /* 18 */ |
81 | "spell_magic_mapping", /* 18 */ |
82 | "spell_turn_undead", /* 19 */ |
82 | "spell_turn_undead", /* 19 */ |
83 | "spell_fear", /* 20 */ |
83 | "spell_fear", /* 20 */ |
84 | "spell_poison_cloud", /* 21 */ |
84 | "spell_poison_cloud", /* 21 */ |
85 | "spell_wonder", /* 22 */ |
85 | "spell_wonder", /* 22 */ |
86 | "spell_destruction", /* 23 */ |
86 | "spell_destruction", /* 23 */ |
87 | "spell_perceive_self", /* 24 */ |
87 | "spell_perceive_self", /* 24 */ |
88 | "spell_word_of_recall", /* 25 */ |
88 | "spell_word_of_recall", /* 25 */ |
89 | "spell_invisible", /* 26 */ |
89 | "spell_invisible", /* 26 */ |
90 | "spell_invisible_to_undead", /* 27 */ |
90 | "spell_invisible_to_undead", /* 27 */ |
91 | "spell_probe", /* 28 */ |
91 | "spell_probe", /* 28 */ |
92 | "spell_lg_magic_bullet", /* 29 */ |
92 | "spell_lg_magic_bullet", /* 29 */ |
93 | "spell_improved_invisibility", /* 30 */ |
93 | "spell_improved_invisibility", /* 30 */ |
94 | "spell_holy_word", /* 31 */ |
94 | "spell_holy_word", /* 31 */ |
95 | "spell_minor_healing", /* 32 */ |
95 | "spell_minor_healing", /* 32 */ |
96 | "spell_medium_healing", /* 33 */ |
96 | "spell_medium_healing", /* 33 */ |
97 | "spell_major_healing", /* 34 */ |
97 | "spell_major_healing", /* 34 */ |
98 | "spell_heal", /* 35 */ |
98 | "spell_heal", /* 35 */ |
99 | "spell_create_food", /* 36 */ |
99 | "spell_create_food", /* 36 */ |
100 | "spell_earth_to_dust", /* 37 */ |
100 | "spell_earth_to_dust", /* 37 */ |
101 | "spell_armour", /* 38 */ |
101 | "spell_armour", /* 38 */ |
102 | "spell_strength", /* 39 */ |
102 | "spell_strength", /* 39 */ |
103 | "spell_dexterity", /* 40 */ |
103 | "spell_dexterity", /* 40 */ |
104 | "spell_constitution", /* 41 */ |
104 | "spell_constitution", /* 41 */ |
105 | "spell_charisma", /* 42 */ |
105 | "spell_charisma", /* 42 */ |
106 | "spell_create_fire_wall", /* 43 */ |
106 | "spell_create_fire_wall", /* 43 */ |
107 | "spell_create_frost_wall", /* 44 */ |
107 | "spell_create_frost_wall", /* 44 */ |
108 | "spell_protection_from_cold", /* 45 */ |
108 | "spell_protection_from_cold", /* 45 */ |
109 | "spell_protection_from_electricity", /* 46 */ |
109 | "spell_protection_from_electricity", /* 46 */ |
110 | "spell_protection_from_fire", /* 47 */ |
110 | "spell_protection_from_fire", /* 47 */ |
111 | "spell_protection_from_poison", /* 48 */ |
111 | "spell_protection_from_poison", /* 48 */ |
112 | "spell_protection_from_slow", /* 49 */ |
112 | "spell_protection_from_slow", /* 49 */ |
113 | "spell_protection_from_paralysis", /* 50 */ |
113 | "spell_protection_from_paralysis", /* 50 */ |
114 | "spell_protection_from_draining", /* 51 */ |
114 | "spell_protection_from_draining", /* 51 */ |
115 | "spell_protection_from_magic", /* 52 */ |
115 | "spell_protection_from_magic", /* 52 */ |
116 | "spell_protection_from_attack", /* 53 */ |
116 | "spell_protection_from_attack", /* 53 */ |
117 | "spell_levitate", /* 54 */ |
117 | "spell_levitate", /* 54 */ |
118 | "spell_small_speedball", /* 55 */ |
118 | "spell_small_speedball", /* 55 */ |
119 | "spell_large_speedball", /* 56 */ |
119 | "spell_large_speedball", /* 56 */ |
120 | "spell_hellfire", /* 57 */ |
120 | "spell_hellfire", /* 57 */ |
121 | "spell_dragonbreath", /* 58 */ |
121 | "spell_dragonbreath", /* 58 */ |
122 | "spell_large_icestorm", /* 59 */ |
122 | "spell_large_icestorm", /* 59 */ |
123 | "spell_charging", /* 60 */ |
123 | "spell_charging", /* 60 */ |
124 | "spell_polymorph", /* 61 */ |
124 | "spell_polymorph", /* 61 */ |
125 | "spell_cancellation", /* 62 */ |
125 | "spell_cancellation", /* 62 */ |
126 | "spell_confusion", /* 63 */ |
126 | "spell_confusion", /* 63 */ |
127 | "spell_mass_confusion", /* 64 */ |
127 | "spell_mass_confusion", /* 64 */ |
128 | "spell_summon_pet_monster", /* 65 */ |
128 | "spell_summon_pet_monster", /* 65 */ |
129 | "spell_slow", /* 66 */ |
129 | "spell_slow", /* 66 */ |
130 | "spell_regenerate_spellpoints", /* 67 */ |
130 | "spell_regenerate_spellpoints", /* 67 */ |
131 | "spell_cure_poison", /* 68 */ |
131 | "spell_cure_poison", /* 68 */ |
132 | "spell_protection_from_confusion", /* 69 */ |
132 | "spell_protection_from_confusion", /* 69 */ |
133 | "spell_protection_from_cancellation", /* 70 */ |
133 | "spell_protection_from_cancellation", /* 70 */ |
134 | "spell_protection_from_depletion", /* 71 */ |
134 | "spell_protection_from_depletion", /* 71 */ |
135 | "spell_alchemy", /* 72 */ |
135 | "spell_alchemy", /* 72 */ |
136 | "spell_remove_curse", /* 73 */ |
136 | "spell_remove_curse", /* 73 */ |
137 | "spell_remove_damnation", /* 74 */ |
137 | "spell_remove_damnation", /* 74 */ |
138 | "spell_identify", /* 75*/ |
138 | "spell_identify", /* 75*/ |
139 | "spell_detect_magic", /* 76 */ |
139 | "spell_detect_magic", /* 76 */ |
140 | "spell_detect_monster", /* 77 */ |
140 | "spell_detect_monster", /* 77 */ |
141 | "spell_detect_evil", /* 78 */ |
141 | "spell_detect_evil", /* 78 */ |
142 | "spell_detect_curse", /* 79 */ |
142 | "spell_detect_curse", /* 79 */ |
143 | "spell_heroism", /* 80 */ |
143 | "spell_heroism", /* 80 */ |
144 | "spell_aggravation", /* 81 */ |
144 | "spell_aggravation", /* 81 */ |
145 | "spell_firebolt", /* 82 */ |
145 | "spell_firebolt", /* 82 */ |
146 | "spell_frostbolt", /* 83 */ |
146 | "spell_frostbolt", /* 83 */ |
147 | "spell_shockwave", /* 84 */ |
147 | "spell_shockwave", /* 84 */ |
148 | "spell_color_spray", /* 85 */ |
148 | "spell_color_spray", /* 85 */ |
149 | "spell_haste", /* 86 */ |
149 | "spell_haste", /* 86 */ |
150 | "spell_face_of_death", /* 87 */ |
150 | "spell_face_of_death", /* 87 */ |
151 | "spell_ball_lightning", /* 88 */ |
151 | "spell_ball_lightning", /* 88 */ |
152 | "spell_meteor_swarm", /* 89 */ |
152 | "spell_meteor_swarm", /* 89 */ |
153 | "spell_comet", /* 90 */ |
153 | "spell_comet", /* 90 */ |
154 | "spell_mystic_fist", /* 91 */ |
154 | "spell_mystic_fist", /* 91 */ |
155 | "spell_raise_dead", /* 92 */ |
155 | "spell_raise_dead", /* 92 */ |
156 | "spell_resurrection", /* 93 */ |
156 | "spell_resurrection", /* 93 */ |
157 | "spell_reincarnation", /* 94 */ |
157 | "spell_reincarnation", /* 94 */ |
158 | "spell_immunity_to_cold", /* 95 */ |
158 | "spell_immunity_to_cold", /* 95 */ |
159 | "spell_immunity_to_electricity",/* 96 */ |
159 | "spell_immunity_to_electricity",/* 96 */ |
160 | "spell_immunity_to_fire", /* 97 */ |
160 | "spell_immunity_to_fire", /* 97 */ |
161 | "spell_immunity_to_poison", /* 98 */ |
161 | "spell_immunity_to_poison", /* 98 */ |
162 | "spell_immunity_to_slow", /* 99 */ |
162 | "spell_immunity_to_slow", /* 99 */ |
163 | "spell_immunity_to_paralysis", /* 100 */ |
163 | "spell_immunity_to_paralysis", /* 100 */ |
164 | "spell_immunity_to_draining", /* 101 */ |
164 | "spell_immunity_to_draining", /* 101 */ |
165 | "spell_immunity_to_magic", /* 102 */ |
165 | "spell_immunity_to_magic", /* 102 */ |
166 | "spell_immunity_to_attack", /* 103 */ |
166 | "spell_immunity_to_attack", /* 103 */ |
167 | "spell_invulnerability", /* 104 */ |
167 | "spell_invulnerability", /* 104 */ |
168 | "spell_defense", /* 105 */ |
168 | "spell_defense", /* 105 */ |
169 | "spell_rune_of_fire", /* 106 */ |
169 | "spell_rune_of_fire", /* 106 */ |
170 | "spell_rune_of_frost", /* 107 */ |
170 | "spell_rune_of_frost", /* 107 */ |
171 | "spell_rune_of_shocking", /* 108 */ |
171 | "spell_rune_of_shocking", /* 108 */ |
172 | "spell_rune_of_blasting", /* 109 */ |
172 | "spell_rune_of_blasting", /* 109 */ |
173 | "spell_rune_of_death", /* 110 */ |
173 | "spell_rune_of_death", /* 110 */ |
174 | "spell_marking_rune", /* 111 */ |
174 | "spell_marking_rune", /* 111 */ |
175 | "spell_build_director", /* 112 */ |
175 | "spell_build_director", /* 112 */ |
176 | "spell_create_pool_of_chaos", /* 113 */ |
176 | "spell_create_pool_of_chaos", /* 113 */ |
177 | "spell_build_bullet_wall", /* 114 */ |
177 | "spell_build_bullet_wall", /* 114 */ |
178 | "spell_build_lightning_wall", /* 115 */ |
178 | "spell_build_lightning_wall", /* 115 */ |
179 | "spell_build_fireball_wall", /* 116 */ |
179 | "spell_build_fireball_wall", /* 116 */ |
180 | "spell_magic_rune", /* 117 */ |
180 | "spell_magic_rune", /* 117 */ |
181 | "spell_rune_of_magic_drain", /* 118 */ |
181 | "spell_rune_of_magic_drain", /* 118 */ |
182 | "spell_antimagic_rune", /* 119 */ |
182 | "spell_antimagic_rune", /* 119 */ |
183 | "spell_rune_of_transference", /* 120 */ |
183 | "spell_rune_of_transference", /* 120 */ |
184 | "spell_transference", /* 121 */ |
184 | "spell_transference", /* 121 */ |
185 | "spell_magic_drain", /* 122 */ |
185 | "spell_magic_drain", /* 122 */ |
186 | "spell_counterspell", /* 123 */ |
186 | "spell_counterspell", /* 123 */ |
187 | "spell_disarm", /* 124 */ |
187 | "spell_disarm", /* 124 */ |
188 | "spell_cure_confusion", /* 125 */ |
188 | "spell_cure_confusion", /* 125 */ |
189 | "spell_restoration", /* 126 */ |
189 | "spell_restoration", /* 126 */ |
190 | "was summon evil monster", /* 127 */ /* Not implenented as nothing used it */ |
190 | "was summon evil monster", /* 127 */ /* Not implenented as nothing used it */ |
191 | "spell_counterwall", /* 128 */ |
191 | "spell_counterwall", /* 128 */ |
192 | "spell_cause_light_wounds", /* 129 */ |
192 | "spell_cause_light_wounds", /* 129 */ |
193 | "spell_cause_medium_wounds", /* 130 */ |
193 | "spell_cause_medium_wounds", /* 130 */ |
194 | "spell_cause_heavy_wounds", /* 131 */ |
194 | "spell_cause_heavy_wounds", /* 131 */ |
195 | "spell_charm_monsters", /* 132 */ |
195 | "spell_charm_monsters", /* 132 */ |
196 | "spell_banishment", /* 133 */ |
196 | "spell_banishment", /* 133 */ |
197 | "spell_create_missile", /* 134 */ |
197 | "spell_create_missile", /* 134 */ |
198 | "spell_show_invisible", /* 135 */ |
198 | "spell_show_invisible", /* 135 */ |
199 | "spell_xray", /* 136 */ |
199 | "spell_xray", /* 136 */ |
200 | "spell_pacify", /* 137 */ |
200 | "spell_pacify", /* 137 */ |
201 | "spell_summon_fog", /* 138 */ |
201 | "spell_summon_fog", /* 138 */ |
202 | "spell_steambolt", /* 139 */ |
202 | "spell_steambolt", /* 139 */ |
203 | "spell_command_undead", /* 140 */ |
203 | "spell_command_undead", /* 140 */ |
204 | "spell_holy_orb", /* 141 */ |
204 | "spell_holy_orb", /* 141 */ |
205 | "spell_summon_avatar", /* 142 */ |
205 | "spell_summon_avatar", /* 142 */ |
206 | "spell_holy_possession", /* 143 */ |
206 | "spell_holy_possession", /* 143 */ |
207 | "spell_bless", /* 144 */ |
207 | "spell_bless", /* 144 */ |
208 | "spell_curse", /* 145 */ |
208 | "spell_curse", /* 145 */ |
209 | "spell_regeneration", /* 146 */ |
209 | "spell_regeneration", /* 146 */ |
210 | "spell_consecrate", /* 147 */ |
210 | "spell_consecrate", /* 147 */ |
211 | "spell_summon_cult_monsters", /* 148 */ |
211 | "spell_summon_cult_monsters", /* 148 */ |
212 | "spell_cause_critical_wounds", /* 149 */ |
212 | "spell_cause_critical_wounds", /* 149 */ |
213 | "spell_holy_wrath", /* 150 */ |
213 | "spell_holy_wrath", /* 150 */ |
214 | "spell_retributive_strike", /* 151 */ |
214 | "spell_retributive_strike", /* 151 */ |
215 | "spell_finger_of_death", /* 152 */ |
215 | "spell_finger_of_death", /* 152 */ |
216 | "spell_insect_plague", /* 153 */ |
216 | "spell_insect_plague", /* 153 */ |
217 | "spell_call_holy_servant", /* 154 */ |
217 | "spell_call_holy_servant", /* 154 */ |
218 | "spell_wall_of_thorns", /* 155 */ |
218 | "spell_wall_of_thorns", /* 155 */ |
219 | "spell_staff_to_snake", /* 156 */ |
219 | "spell_staff_to_snake", /* 156 */ |
220 | "spell_light", /* 157 */ |
220 | "spell_light", /* 157 */ |
221 | "spell_darkness", /* 158 */ |
221 | "spell_darkness", /* 158 */ |
222 | "spell_nightfall", /* 159 */ |
222 | "spell_nightfall", /* 159 */ |
223 | "spell_daylight", /* 160 */ |
223 | "spell_daylight", /* 160 */ |
224 | "spell_sunspear", /* 161 */ |
224 | "spell_sunspear", /* 161 */ |
225 | "spell_faery_fire", /* 162 */ |
225 | "spell_faery_fire", /* 162 */ |
226 | "spell_cure_blindness", /* 163 */ |
226 | "spell_cure_blindness", /* 163 */ |
227 | "spell_dark_vision", /* 164 */ |
227 | "spell_dark_vision", /* 164 */ |
228 | "spell_bullet_swarm", /* 165 */ |
228 | "spell_bullet_swarm", /* 165 */ |
229 | "spell_bullet_storm", /* 166 */ |
229 | "spell_bullet_storm", /* 166 */ |
230 | "spell_cause_many_wounds", /* 167 */ |
230 | "spell_cause_many_wounds", /* 167 */ |
231 | "spell_small_snowstorm", /* 168 */ |
231 | "spell_small_snowstorm", /* 168 */ |
232 | "spell_medium_snowstorm", /* 169 */ |
232 | "spell_medium_snowstorm", /* 169 */ |
233 | "spell_large_snowstorm", /* 170 */ |
233 | "spell_large_snowstorm", /* 170 */ |
234 | "spell_cure_disease", /* 171 */ |
234 | "spell_cure_disease", /* 171 */ |
235 | "spell_cause_red_death", /* 172 */ |
235 | "spell_cause_red_death", /* 172 */ |
236 | "spell_cause_flu", /* 173 */ |
236 | "spell_cause_flu", /* 173 */ |
237 | "spell_cause_black_death", /* 174 */ |
237 | "spell_cause_black_death", /* 174 */ |
238 | "spell_cause_leprosy", /* 175 */ |
238 | "spell_cause_leprosy", /* 175 */ |
239 | "spell_cause_smallpox", /* 176 */ |
239 | "spell_cause_smallpox", /* 176 */ |
240 | "spell_cause_white_death", /* 177 */ |
240 | "spell_cause_white_death", /* 177 */ |
241 | "spell_cause_anthrax", /* 178 */ |
241 | "spell_cause_anthrax", /* 178 */ |
242 | "spell_cause_typhoid", /* 179 */ |
242 | "spell_cause_typhoid", /* 179 */ |
243 | "spell_mana_blast", /* 180 */ |
243 | "spell_mana_blast", /* 180 */ |
244 | "spell_small_manaball", /* 181 */ |
244 | "spell_small_manaball", /* 181 */ |
245 | "spell_medium_manaball", /* 182 */ |
245 | "spell_medium_manaball", /* 182 */ |
246 | "spell_large_manaball", /* 183 */ |
246 | "spell_large_manaball", /* 183 */ |
247 | "spell_manabolt", /* 184 */ |
247 | "spell_manabolt", /* 184 */ |
248 | "spell_dancing_sword", /* 185 */ |
248 | "spell_dancing_sword", /* 185 */ |
249 | "spell_animate_weapon", /* 186 */ |
249 | "spell_animate_weapon", /* 186 */ |
250 | "spell_cause_cold", /* 187 */ |
250 | "spell_cause_cold", /* 187 */ |
251 | "spell_divine_shock", /* 188 */ |
251 | "spell_divine_shock", /* 188 */ |
252 | "spell_windstorm", /* 189 */ |
252 | "spell_windstorm", /* 189 */ |
253 | "spell_sanctuary", /* 190 */ |
253 | "spell_sanctuary", /* 190 */ |
254 | "spell_peace", /* 191 */ |
254 | "spell_peace", /* 191 */ |
255 | "spell_spiderweb", /* 192 */ |
255 | "spell_spiderweb", /* 192 */ |
256 | "spell_conflict", /* 193 */ |
256 | "spell_conflict", /* 193 */ |
257 | "spell_rage", /* 194 */ |
257 | "spell_rage", /* 194 */ |
258 | "spell_forked_lightning", /* 195 */ |
258 | "spell_forked_lightning", /* 195 */ |
259 | "spell_poison_fog", /* 196 */ |
259 | "spell_poison_fog", /* 196 */ |
260 | "spell_flaming_aura", /* 197 */ |
260 | "spell_flaming_aura", /* 197 */ |
261 | "spell_vitriol", /* 198 */ |
261 | "spell_vitriol", /* 198 */ |
262 | "spell_vitriol_splash", /* 199 */ |
262 | "spell_vitriol_splash", /* 199 */ |
263 | "spell_iron_skin", /* 200 */ |
263 | "spell_iron_skin", /* 200 */ |
264 | "spell_wrathful_eye", /* 201 */ |
264 | "spell_wrathful_eye", /* 201 */ |
265 | "spell_town_portal", /* 202 */ |
265 | "spell_town_portal", /* 202 */ |
266 | "spell_missile_swarm", /* 203 */ |
266 | "spell_missile_swarm", /* 203 */ |
267 | "spell_cause_rabies", /* 204 */ |
267 | "spell_cause_rabies", /* 204 */ |
268 | "spell_glyph", /* 205 */ |
268 | "spell_glyph", /* 205 */ |
269 | NULL |
269 | NULL |
270 | }; |
270 | }; |
271 | |
271 | |
272 | #define SET_OR_CLEAR_FLAG(op, flag, val) \ |
272 | #define SET_OR_CLEAR_FLAG(op, flag, val) \ |
273 | { if (val) SET_FLAG(op, flag); else CLEAR_FLAG(op, flag); } |
273 | { if (val) SET_FLAG(op, flag); else CLEAR_FLAG(op, flag); } |
274 | |
274 | |
275 | /* SET_RESIST is really only really needed for transition code. We normally |
275 | /* SET_RESIST is really only really needed for transition code. We normally |
276 | * don't care about multiple values overwriting each other, but this is |
276 | * don't care about multiple values overwriting each other, but this is |
277 | * to catch items that have multiple protection/immune/vulnerable. |
277 | * to catch items that have multiple protection/immune/vulnerable. |
278 | * This can be simplified later on to just do the set after all the archs |
278 | * This can be simplified later on to just do the set after all the archs |
… | |
… | |
280 | * We always keep the last value because otherwise the value from the |
280 | * We always keep the last value because otherwise the value from the |
281 | * arch may take precedence. |
281 | * arch may take precedence. |
282 | * Unfortunately, we will report warnings here simply because an object has |
282 | * Unfortunately, we will report warnings here simply because an object has |
283 | * been modified from the arch. |
283 | * been modified from the arch. |
284 | */ |
284 | */ |
285 | #if 0 /* #if's don't work in #define macros */ |
285 | #if 0 /* #if's don't work in #define macros */ |
286 | #define SET_RESIST(op, type, val) \ |
286 | #define SET_RESIST(op, type, val) \ |
287 | {if (op->resist[type]!=0) { \ |
287 | {if (op->resist[type]!=0) { \ |
288 | LOG(llevInfo, "object %s having multiple resistances set, type=%s, old=%d, new=%d\n", \ |
288 | LOG(llevInfo, "object %s having multiple resistances set, type=%s, old=%d, new=%d\n", \ |
289 | op->name?op->name:(op->arch?op->arch->name:"unknown"), \ |
289 | op->name?op->name:(op->arch?op->arch->name:"unknown"), \ |
290 | resist_plus[type], op->resist[type], val); \ |
290 | resist_plus[type], op->resist[type], val); \ |
291 | } op->resist[type] = val; } |
291 | } op->resist[type] = val; } |
292 | #else |
292 | #else |
293 | #define SET_RESIST(op, type, val) op->resist[type] = val; |
293 | #define SET_RESIST(op, type, val) op->resist[type] = val; |
294 | #endif |
294 | #endif |
295 | |
295 | |
296 | #define IVAL atoi(yval()) |
296 | #define IVAL atoi(yval()) |
297 | #define FVAL atof(yval()) |
297 | #define FVAL atof(yval()) |
298 | extern int arch_init; |
298 | extern int arch_init; |
299 | |
299 | |
300 | /* Put this here since it is used below */ |
300 | /* Put this here since it is used below */ |
301 | static void set_protection(object *op, uint32 mask, uint16 pro_val) |
301 | static void set_protection(object *op, uint32 mask, uint16 pro_val) |
302 | { |
302 | { |
303 | int i; |
303 | int i; |
304 | |
304 | |
305 | if (!mask) return; /* Unlikely, but might as well check */ |
305 | if (!mask) return; /* Unlikely, but might as well check */ |
306 | for (i=0; i<NROFATTACKS; i++) { |
306 | for (i=0; i<NROFATTACKS; i++) { |
307 | if (mask & (1<<i)) SET_RESIST(op, i, pro_val); |
307 | if (mask & (1<<i)) SET_RESIST(op, i, pro_val); |
308 | } |
308 | } |
309 | } |
309 | } |
310 | |
310 | |
311 | |
311 | |
312 | static void set_body_info(object *op, char *params) { |
312 | static void set_body_info(object *op, char *params) { |
… | |
… | |
314 | char *cp; |
314 | char *cp; |
315 | |
315 | |
316 | /* go to first space character */ |
316 | /* go to first space character */ |
317 | for (cp=params; !isspace(*cp); cp++) ; |
317 | for (cp=params; !isspace(*cp); cp++) ; |
318 | |
318 | |
319 | *cp++ = 0; /* null it out */ |
319 | *cp++ = 0; /* null it out */ |
320 | |
320 | |
321 | for (i=0; i<NUM_BODY_LOCATIONS; i++) { |
321 | for (i=0; i<NUM_BODY_LOCATIONS; i++) { |
322 | if (!strcmp(params, body_locations[i].save_name)) { |
322 | if (!strcmp(params, body_locations[i].save_name)) { |
323 | op->body_info[i] = atoi(cp); |
323 | op->body_info[i] = atoi(cp); |
324 | return; /* Only one line passed in params */ |
324 | return; /* Only one line passed in params */ |
325 | } |
325 | } |
326 | } |
326 | } |
327 | LOG(llevError,"set_body_info called with bogus params: %s\n", params); |
327 | LOG(llevError,"set_body_info called with bogus params: %s\n", params); |
328 | } |
328 | } |
329 | |
329 | |
330 | // return a suitable strign describign an objetc in enough detail to find it |
330 | // return a suitable strign describign an objetc in enough detail to find it |
… | |
… | |
335 | char info2[256 * 3]; |
335 | char info2[256 * 3]; |
336 | char *p = info; |
336 | char *p = info; |
337 | |
337 | |
338 | p += snprintf (p, 256, "%d=\"%s%s%s\"", |
338 | p += snprintf (p, 256, "%d=\"%s%s%s\"", |
339 | op->count, |
339 | op->count, |
340 | op->name ? op->name : "(anon)", |
340 | op->name ? (const char *)op->name : "(anon)", |
341 | op->title ? " " : "", |
341 | op->title ? " " : "", |
342 | op->title ? op->title : ""); |
342 | op->title ? (const char *)op->title : ""); |
343 | |
343 | |
344 | if (op->env) |
344 | if (op->env) |
345 | p += snprintf (p, 256, "(in %s)", op_debug_info_ (op->env, info2)); |
345 | p += snprintf (p, 256, "(in %s)", op_debug_info_ (op->env, info2)); |
346 | |
346 | |
347 | if (op->map) |
347 | if (op->map) |
… | |
… | |
373 | * the object. In that case, we also want to use the loaded name. |
373 | * the object. In that case, we also want to use the loaded name. |
374 | * Otherwise, what happens is that the the plural name will lose |
374 | * Otherwise, what happens is that the the plural name will lose |
375 | * information (appear as just 'hearts' and not 'goblins heart') |
375 | * information (appear as just 'hearts' and not 'goblins heart') |
376 | */ |
376 | */ |
377 | if (op->arch && op->name != op->arch->clone.name && op->name_pl == op->arch->clone.name_pl) { |
377 | if (op->arch && op->name != op->arch->clone.name && op->name_pl == op->arch->clone.name_pl) { |
378 | if (op->name_pl) free_string(op->name_pl); |
378 | if (op->name_pl) free_string(op->name_pl); |
379 | op->name_pl = NULL; |
379 | op->name_pl = NULL; |
380 | } |
380 | } |
381 | if (!op->name_pl) op->name_pl = add_string(op->name); |
381 | if (!op->name_pl) op->name_pl = add_string(op->name); |
382 | |
382 | |
383 | /* objects now have a materialname. try to patch it in */ |
383 | /* objects now have a materialname. try to patch it in */ |
384 | if (!(IS_WEAPON(op) && op->level > 0)) { |
384 | if (!(IS_WEAPON(op) && op->level > 0)) { |
… | |
… | |
391 | * excessive to do this at every run - most of this is |
391 | * excessive to do this at every run - most of this is |
392 | * really just to catch any errors - program will still run, but |
392 | * really just to catch any errors - program will still run, but |
393 | * not in the ideal fashion. |
393 | * not in the ideal fashion. |
394 | */ |
394 | */ |
395 | if ((op->type == WEAPON || op->type==BOW) && arch_init) { |
395 | if ((op->type == WEAPON || op->type==BOW) && arch_init) { |
396 | if (!op->skill) { |
396 | if (!op->skill) { |
397 | LOG(llevError,"Weapon %s lacks a skill.\n", op_debug_info (op)); |
397 | LOG(llevError,"Weapon %s lacks a skill.\n", op_debug_info (op)); |
398 | } else if ((!strcmp(op->skill,"one handed weapons") && op->body_info[1] != -1) || |
398 | } else if ((!strcmp(op->skill,"one handed weapons") && op->body_info[1] != -1) || |
399 | (!strcmp(op->skill,"two handed weapons") && op->body_info[1] != -2)) { |
399 | (!strcmp(op->skill,"two handed weapons") && op->body_info[1] != -2)) { |
400 | LOG(llevError,"weapon %s arm usage does not match skill: %d, %s\n", |
400 | LOG(llevError,"weapon %s arm usage does not match skill: %d, %s\n", |
401 | op_debug_info (op), op->body_info[1], op->skill); |
401 | op_debug_info (op), op->body_info[1], op->skill); |
402 | } |
402 | } |
403 | } |
403 | } |
404 | |
404 | |
405 | /* We changed last_heal to gen_sp_armour, which is what it |
405 | /* We changed last_heal to gen_sp_armour, which is what it |
406 | * really does for many objects. Need to catch any in maps |
406 | * really does for many objects. Need to catch any in maps |
407 | * that may have an old value. |
407 | * that may have an old value. |
… | |
… | |
410 | (op->type == ARMOUR) || (op->type == HELMET) || |
410 | (op->type == ARMOUR) || (op->type == HELMET) || |
411 | (op->type == SHIELD) || (op->type == RING) || |
411 | (op->type == SHIELD) || (op->type == RING) || |
412 | (op->type == BOOTS) || (op->type == GLOVES) || |
412 | (op->type == BOOTS) || (op->type == GLOVES) || |
413 | (op->type == AMULET ) || (op->type == GIRDLE) || |
413 | (op->type == AMULET ) || (op->type == GIRDLE) || |
414 | (op->type == BRACERS ) || (op->type == CLOAK)) { |
414 | (op->type == BRACERS ) || (op->type == CLOAK)) { |
415 | if (op->last_heal) { |
415 | if (op->last_heal) { |
416 | LOG(llevDebug,"Object %s still has last_heal set, not gen_sp_armour\n", op_debug_info (op)); |
416 | LOG(llevDebug,"Object %s still has last_heal set, not gen_sp_armour\n", op_debug_info (op)); |
417 | op->gen_sp_armour = op->last_heal; |
417 | op->gen_sp_armour = op->last_heal; |
418 | op->last_heal = 0; |
418 | op->last_heal = 0; |
419 | } |
419 | } |
420 | if (editor) ip =0; |
420 | if (editor) ip =0; |
421 | else ip = calc_item_power(op, 0); |
421 | else ip = calc_item_power(op, 0); |
422 | /* Legacy objects from before item power was in the game */ |
422 | /* Legacy objects from before item power was in the game */ |
423 | if (!op->item_power && ip) { |
423 | if (!op->item_power && ip) { |
424 | if (ip > 3) { |
424 | if (ip > 3) { |
425 | LOG(llevDebug,"Object %s had no item power, using %d\n", op_debug_info (op), ip); |
425 | LOG(llevDebug,"Object %s had no item power, using %d\n", op_debug_info (op), ip); |
426 | } |
426 | } |
427 | op->item_power = ip; |
427 | op->item_power = ip; |
428 | } |
428 | } |
429 | /* Check for possibly bogus values. Has to meet both these criteria - |
429 | /* Check for possibly bogus values. Has to meet both these criteria - |
430 | * something that has item_power 1 is probably just fine if our calculated |
430 | * something that has item_power 1 is probably just fine if our calculated |
431 | * value is 1 or 2 - these values are small enough that hard to be precise. |
431 | * value is 1 or 2 - these values are small enough that hard to be precise. |
432 | * similarly, it item_power is 0, the first check will always pass, |
432 | * similarly, it item_power is 0, the first check will always pass, |
433 | * but not the second one. |
433 | * but not the second one. |
434 | */ |
434 | */ |
435 | if (ip > 2 *op->item_power && ip > (op->item_power + 3)) { |
435 | if (ip > 2 *op->item_power && ip > (op->item_power + 3)) { |
436 | LOG(llevDebug,"Object %s seems to have too low item power? %d > %d\n", |
436 | LOG(llevDebug,"Object %s seems to have too low item power? %d > %d\n", |
437 | op_debug_info (op), ip, op->item_power); |
437 | op_debug_info (op), ip, op->item_power); |
438 | } |
438 | } |
439 | |
439 | |
440 | } |
440 | } |
441 | /* Old spellcasting object - need to load in the appropiate object */ |
441 | /* Old spellcasting object - need to load in the appropiate object */ |
442 | if ((op->type == ROD || op->type == WAND || op->type == SCROLL || op->type == HORN |
442 | if ((op->type == ROD || op->type == WAND || op->type == SCROLL || op->type == HORN |
443 | || op->type == FIREWALL || |
443 | || op->type == FIREWALL || |
444 | /* POTIONS and ALTARS don't always cast spells, but if they do, update them */ |
444 | /* POTIONS and ALTARS don't always cast spells, but if they do, update them */ |
445 | ((op->type == POTION || op->type == ALTAR) && op->stats.sp)) && !op->inv && !arch_init) { |
445 | ((op->type == POTION || op->type == ALTAR) && op->stats.sp)) && !op->inv && !arch_init) { |
446 | object *tmp; |
446 | object *tmp; |
447 | |
447 | |
448 | /* Fireall is bizarre in that spell type was stored in dam. Rest are 'normal' |
448 | /* Fireall is bizarre in that spell type was stored in dam. Rest are 'normal' |
449 | * in that spell was stored in sp. |
449 | * in that spell was stored in sp. |
450 | */ |
450 | */ |
451 | tmp = get_archetype(spell_mapping[op->type == FIREWALL?op->stats.dam:op->stats.sp]); |
451 | tmp = get_archetype(spell_mapping[op->type == FIREWALL?op->stats.dam:op->stats.sp]); |
452 | insert_ob_in_ob(tmp, op); |
452 | insert_ob_in_ob(tmp, op); |
453 | op->randomitems = NULL; /* So another spell isn't created for this object */ |
453 | op->randomitems = NULL; /* So another spell isn't created for this object */ |
454 | } |
454 | } |
455 | /* spellbooks & runes use slaying. But not to arch name, but to spell name */ |
455 | /* spellbooks & runes use slaying. But not to arch name, but to spell name */ |
456 | |
456 | |
457 | if ((op->type == SPELLBOOK || op->type == RUNE) && op->slaying && !op->inv && !arch_init) { |
457 | if ((op->type == SPELLBOOK || op->type == RUNE) && op->slaying && !op->inv && !arch_init) { |
458 | object *tmp; |
458 | object *tmp; |
459 | |
459 | |
460 | tmp = get_archetype_by_object_name(op->slaying); |
460 | tmp = get_archetype_by_object_name(op->slaying); |
461 | insert_ob_in_ob(tmp, op); |
461 | insert_ob_in_ob(tmp, op); |
462 | op->randomitems = NULL; /* So another spell isn't created for this object */ |
462 | op->randomitems = NULL; /* So another spell isn't created for this object */ |
463 | /* without this, value is all screwed up */ |
463 | /* without this, value is all screwed up */ |
464 | op->value = op->arch->clone.value * op->inv->value; |
464 | op->value = op->arch->clone.value * op->inv->value; |
465 | } |
465 | } |
466 | |
466 | |
467 | if (QUERY_FLAG(op, FLAG_MONSTER)) { |
467 | if (QUERY_FLAG(op, FLAG_MONSTER)) { |
468 | if (op->stats.hp > op->stats.maxhp) |
468 | if (op->stats.hp > op->stats.maxhp) |
469 | LOG(llevDebug,"Monster %s has hp set higher than maxhp (%d>%d)\n", |
469 | LOG(llevDebug,"Monster %s has hp set higher than maxhp (%d>%d)\n", |
470 | op_debug_info (op), |
470 | op_debug_info (op), |
471 | op->stats.hp, op->stats.maxhp); |
471 | op->stats.hp, op->stats.maxhp); |
472 | |
472 | |
473 | /* The archs just need to be updated for this */ |
473 | /* The archs just need to be updated for this */ |
474 | if (op->move_type ==0) op->move_type = MOVE_WALK; |
474 | if (op->move_type ==0) op->move_type = MOVE_WALK; |
475 | } |
475 | } |
476 | if ((QUERY_FLAG(op,FLAG_GENERATOR) && QUERY_FLAG(op,FLAG_CONTENT_ON_GEN)) |
476 | if ((QUERY_FLAG(op,FLAG_GENERATOR) && QUERY_FLAG(op,FLAG_CONTENT_ON_GEN)) |
477 | || op->type == CREATOR |
477 | || op->type == CREATOR |
478 | || op->type == CONVERTER) { |
478 | || op->type == CONVERTER) { |
479 | /* Object will duplicate it's content as part of the |
479 | /* Object will duplicate it's content as part of the |
… | |
… | |
489 | * would potentially cause them to be triggered when someone steps |
489 | * would potentially cause them to be triggered when someone steps |
490 | * on them). If move_type is set, presume person knows what they |
490 | * on them). If move_type is set, presume person knows what they |
491 | * are doing, otherwise, set move_type based on maxhp value. |
491 | * are doing, otherwise, set move_type based on maxhp value. |
492 | */ |
492 | */ |
493 | if (op->type == PLAYERMOVER) { |
493 | if (op->type == PLAYERMOVER) { |
494 | if (!op->move_type) { |
494 | if (!op->move_type) { |
495 | if (op->stats.maxhp) { |
495 | if (op->stats.maxhp) { |
496 | op->move_type = MOVE_ALL; |
496 | op->move_type = MOVE_ALL; |
497 | op->stats.maxhp=0; |
497 | op->stats.maxhp=0; |
498 | } else { |
498 | } else { |
499 | op->move_type = MOVE_WALK; |
499 | op->move_type = MOVE_WALK; |
500 | } |
500 | } |
501 | } |
501 | } |
502 | } |
502 | } |
503 | |
503 | |
504 | } |
504 | } |
505 | |
505 | |
506 | /* This extracts the key/value from the yytext field - |
506 | /* This extracts the key/value from the yytext field - |
… | |
… | |
556 | |
556 | |
557 | /* Got last character before null and strip |
557 | /* Got last character before null and strip |
558 | * off tailing whitespace |
558 | * off tailing whitespace |
559 | */ |
559 | */ |
560 | for (end = value + (strlen(cp)-1); isspace(*end); end--) { |
560 | for (end = value + (strlen(cp)-1); isspace(*end); end--) { |
561 | if (end == value) { |
561 | if (end == value) { |
562 | /* *blink blink* Still no value? */ |
562 | /* *blink blink* Still no value? */ |
563 | set_ob_key_value(op, key, NULL, TRUE); |
563 | set_ob_key_value(op, key, NULL, TRUE); |
564 | return; |
564 | return; |
565 | } |
565 | } |
566 | *end='\0'; |
566 | *end='\0'; |
567 | } |
567 | } |
568 | set_ob_key_value(op, key, value, TRUE); |
568 | set_ob_key_value(op, key, value, TRUE); |
569 | } |
569 | } |
570 | |
570 | |
571 | static void set_move(MoveType *mt, char *params) { |
571 | static void set_move(MoveType *mt, char *params) { |
572 | char *str; |
572 | char *str; |
573 | int i, negate; |
573 | int i, negate; |
574 | |
574 | |
575 | if (isdigit(*params)) { |
575 | if (isdigit(*params)) { |
576 | *mt = atoi(params); |
576 | *mt = atoi(params); |
577 | } else { |
577 | } else { |
578 | *mt=0; |
578 | *mt=0; |
579 | for (str=strtok(params, " "); str; str=strtok(NULL, " ")) { |
579 | for (str=strtok(params, " "); str; str=strtok(NULL, " ")) { |
580 | negate=0; |
580 | negate=0; |
581 | if (!strcasecmp(str, "all")) |
581 | if (!strcasecmp(str, "all")) |
582 | *mt |= MOVE_ALL; |
582 | *mt |= MOVE_ALL; |
583 | else { |
583 | else { |
584 | if (*str=='-') { |
584 | if (*str=='-') { |
585 | negate = 1; |
585 | negate = 1; |
586 | str++; |
586 | str++; |
587 | } |
587 | } |
588 | for (i=0; move_name[i] != NULL; i++) { |
588 | for (i=0; move_name[i] != NULL; i++) { |
589 | if (!strcasecmp(move_name[i], str)) { |
589 | if (!strcasecmp(move_name[i], str)) { |
590 | if (negate) { |
590 | if (negate) { |
591 | *mt &= ~(1<<i); |
591 | *mt &= ~(1<<i); |
592 | } else { |
592 | } else { |
593 | *mt |= (1<<i); |
593 | *mt |= (1<<i); |
594 | } |
594 | } |
595 | break; |
595 | break; |
596 | } |
596 | } |
597 | } |
597 | } |
598 | if (move_name[i] == NULL) { |
598 | if (move_name[i] == NULL) { |
599 | /* fly is a special case - covers both fly_low and |
599 | /* fly is a special case - covers both fly_low and |
600 | * fly_high - since it doesn't match to a specific |
600 | * fly_high - since it doesn't match to a specific |
601 | * single bit, have to special case it. |
601 | * single bit, have to special case it. |
602 | */ |
602 | */ |
603 | if (!strcasecmp(str,"flying")) { |
603 | if (!strcasecmp(str,"flying")) { |
604 | if (negate) { |
604 | if (negate) { |
605 | *mt &= ~MOVE_FLYING; |
605 | *mt &= ~MOVE_FLYING; |
606 | } else { |
606 | } else { |
607 | *mt |= MOVE_FLYING; |
607 | *mt |= MOVE_FLYING; |
608 | } |
608 | } |
609 | } else { |
609 | } else { |
610 | LOG(llevDebug, "common/loader.l: set_move - unknown move string '%s'\n", str); |
610 | LOG(llevDebug, "common/loader.l: set_move - unknown move string '%s'\n", str); |
611 | } |
611 | } |
612 | } |
612 | } |
613 | } /* Else not all move types */ |
613 | } /* Else not all move types */ |
614 | } /* for strtok */ |
614 | } /* for strtok */ |
615 | } /* Else not a numeric value */ |
615 | } /* Else not a numeric value */ |
616 | } |
616 | } |
617 | |
617 | |
618 | %} |
618 | %} |
619 | |
619 | |
620 | |
620 | |
621 | |
621 | |
622 | S [ \t]+.+ |
622 | S [ \t]+.* |
623 | WS [ \t]* |
623 | WS [ \t]* |
624 | A .+ |
624 | A .+ |
625 | |
625 | |
626 | %x MESSAGE |
626 | %x MESSAGE |
627 | %x LORE |
627 | %x LORE |
628 | %x SCRIPT |
628 | %x SCRIPT |
629 | |
629 | |
… | |
… | |
641 | |
641 | |
642 | lex_error=0; |
642 | lex_error=0; |
643 | |
643 | |
644 | %} |
644 | %} |
645 | |
645 | |
646 | ^msg{WS}$ { BEGIN( MESSAGE ); msgbuf[0]='\0'; } |
646 | ^msg{WS}$ { BEGIN( MESSAGE ); msgbuf[0]='\0'; } |
647 | <MESSAGE>^endmsg{WS}$ { BEGIN( INITIAL ); |
647 | <MESSAGE>^endmsg{WS}$ { BEGIN( INITIAL ); |
648 | /* Just print a warning so we can be reasonably safe |
648 | /* Just print a warning so we can be reasonably safe |
649 | * about not overflowing the buffer. |
649 | * about not overflowing the buffer. |
650 | */ |
650 | */ |
651 | if (strlen(msgbuf) >= HUGE_BUF) |
651 | if (strlen(msgbuf) >= HUGE_BUF) |
652 | { |
652 | { |
653 | LOG(llevDebug, "\n\tError message length >= %d: %d\n>%.80s<\n", |
653 | LOG(llevDebug, "\n\tError message length >= %d: %d\n>%.80s<\n", |
654 | HUGE_BUF, strlen(op->msg),op->msg); |
654 | HUGE_BUF, strlen(op->msg),op->msg); |
655 | op->msg = add_string ("ERROR, please report: string too long, winged.\n"); |
655 | op->msg = add_string ("ERROR, please report: string too long, winged.\n"); |
656 | } |
656 | } |
657 | else |
657 | else |
658 | op->msg = add_string (msgbuf); |
658 | op->msg = add_string (msgbuf); |
659 | } |
659 | } |
660 | <MESSAGE>.* {strcat(msgbuf, yytext); strcat(msgbuf,"\n"); } |
660 | <MESSAGE>.* {strcat(msgbuf, yytext); strcat(msgbuf,"\n"); } |
661 | |
661 | |
662 | ^lore{WS}$ { BEGIN( LORE ); lorebuf[0]='\0'; } |
662 | ^lore{WS}$ { BEGIN( LORE ); lorebuf[0]='\0'; } |
663 | <LORE>^endlore{WS}$ { BEGIN( INITIAL ); |
663 | <LORE>^endlore{WS}$ { BEGIN( INITIAL ); |
664 | op->lore=add_string(lorebuf); |
664 | op->lore=add_string(lorebuf); |
665 | /* Just print a warning so we can be reasonably safe |
665 | /* Just print a warning so we can be reasonably safe |
666 | * about not overflowing the buffer. |
666 | * about not overflowing the buffer. |
667 | */ |
667 | */ |
668 | if (strlen(op->lore) > (HUGE_BUF/2)) |
668 | if (strlen(op->lore) > (HUGE_BUF/2)) |
669 | LOG(llevDebug, "\n\tWarning lore length > %d (max allowed=%d): %d\n>%.80s<\n", |
669 | LOG(llevDebug, "\n\tWarning lore length > %d (max allowed=%d): %d\n>%.80s<\n", |
670 | HUGE_BUF/2, HUGE_BUF, strlen(op->lore),op->lore); |
670 | HUGE_BUF/2, HUGE_BUF, strlen(op->lore),op->lore); |
671 | } |
671 | } |
672 | <LORE>.* {strcat(lorebuf, yytext); strcat(lorebuf,"\n"); } |
672 | <LORE>.* {strcat(lorebuf, yytext); strcat(lorebuf,"\n"); } |
673 | |
673 | |
674 | ^object{S} { char *yv=yval(); |
674 | ^object{S} { char *yv=yval(); |
675 | |
675 | |
676 | if (*yv=='\0') { |
676 | if (*yv=='\0') { |
677 | LOG(llevError,"Object lacks name.\n"); |
677 | LOG(llevError,"Object lacks name.\n"); |
678 | return LL_IGNORED; |
678 | return LL_IGNORED; |
679 | } |
679 | } |
680 | if (!arch_init) { |
680 | if (!arch_init) { |
681 | LOG(llevError,"Got object info when not in arch_init (%s)?\n", yv); |
681 | LOG(llevError,"Got object info when not in arch_init (%s)?\n", yv); |
682 | } else { |
682 | } else { |
683 | if (op->arch!=NULL) op->arch->name=add_string(yv); |
683 | if (op->arch!=NULL) op->arch->name=add_string(yv); |
684 | op->name = add_string(yv); |
684 | op->name = add_string(yv); |
685 | } |
685 | } |
686 | } |
686 | } |
687 | |
687 | |
688 | ^name{S} { char *yv=yval(); |
688 | ^name{S} { char *yv=yval(); |
689 | |
689 | |
690 | if (*yv=='\0') LOG(llevError,"Name without val\n"); |
690 | if (*yv=='\0') LOG(llevError,"Name without val\n"); |
691 | else FREE_AND_COPY(op->name, yv); |
691 | else FREE_AND_COPY(op->name, yv); |
692 | } |
692 | } |
693 | ^name_pl{S} { char *yv=yval(); |
693 | ^name_pl{S} { char *yv=yval(); |
694 | |
694 | |
695 | if (*yv=='\0') LOG(llevError,"Name without val\n"); |
695 | if (*yv=='\0') LOG(llevError,"Name without val\n"); |
696 | else FREE_AND_COPY(op->name_pl, yv); |
696 | else FREE_AND_COPY(op->name_pl, yv); |
697 | } |
697 | } |
698 | ^attach{S} { char *yv=yval(); |
698 | ^attach{S} { char *yv=yval(); |
699 | if (*yv) |
699 | if (*yv) |
700 | op->attach = add_string (yv); |
700 | op->attach = add_string (yv); |
701 | } |
701 | } |
702 | ^skill{S} FREE_AND_COPY(op->skill,yval()); |
702 | ^skill{S} FREE_AND_COPY(op->skill,yval()); |
703 | ^custom_name{S} { char *yv=yval(); |
703 | ^custom_name{S} { char *yv=yval(); |
704 | |
704 | |
705 | if (*yv=='\0') LOG(llevError,"Custom name without val\n"); |
705 | if (*yv=='\0') LOG(llevError,"Custom name without val\n"); |
706 | else FREE_AND_COPY(op->custom_name, yv); |
706 | else FREE_AND_COPY(op->custom_name, yv); |
707 | } |
707 | } |
708 | ^race{S} FREE_AND_COPY(op->race,yval()); |
708 | ^race{S} FREE_AND_COPY(op->race,yval()); |
709 | ^slaying{S} FREE_AND_COPY(op->slaying, yval()); |
709 | ^slaying{S} FREE_AND_COPY(op->slaying, yval()); |
710 | ^inventory.*$ LOG(llevError,"Got depreciated Inventory command?\n"); |
710 | ^inventory.*$ LOG(llevError,"Got depreciated Inventory command?\n"); |
711 | |
711 | |
712 | |
712 | |
713 | ^arch{S} { /* If op->arch has been set, then this new object |
713 | ^arch{S} { /* If op->arch has been set, then this new object |
714 | * must be part of the inventory. So process |
714 | * must be part of the inventory. So process |
715 | * appropriately. |
715 | * appropriately. |
716 | */ |
716 | */ |
717 | if (op->arch) { |
717 | if (op->arch) { |
718 | object *tmp; |
718 | object *tmp; |
719 | char *yv=yval(); |
719 | char *yv=yval(); |
720 | |
720 | |
721 | archetype *arch = find_archetype(yv); |
721 | archetype *arch = find_archetype(yv); |
722 | if (arch!=NULL) |
722 | if (arch!=NULL) |
723 | tmp = arch_to_object (arch); |
723 | tmp = arch_to_object (arch); |
724 | else { |
724 | else { |
725 | tmp = get_object (); |
725 | tmp = get_object (); |
726 | if (tmp->name) free_string(tmp->name); |
726 | if (tmp->name) free_string(tmp->name); |
727 | /* record the name of the broken object */ |
727 | /* record the name of the broken object */ |
728 | tmp->name = add_string(yv); |
728 | tmp->name = add_string(yv); |
729 | } |
729 | } |
730 | strcpy(msgbuf, ""); |
730 | strcpy(msgbuf, ""); |
731 | strcpy(lorebuf, ""); |
731 | strcpy(lorebuf, ""); |
732 | lex_load(tmp, thawer, map_flags); |
732 | lex_load(tmp, thawer, map_flags); |
733 | if (tmp->arch) { |
733 | if (tmp->arch) { |
734 | insert_ob_in_ob(tmp,op); |
734 | insert_ob_in_ob(tmp,op); |
735 | } |
735 | } |
736 | else { |
736 | else { |
737 | LOG(llevDebug,"Discarding object without arch: %s\n", tmp->name?tmp->name:"(null)"); |
737 | LOG(llevDebug,"Discarding object without arch: %s\n", tmp->name?(const char *)tmp->name:"(null)"); |
738 | free_object(tmp); |
738 | free_object(tmp); |
739 | } |
739 | } |
740 | } |
740 | } |
741 | /* This is the actual archetype definition then */ |
741 | /* This is the actual archetype definition then */ |
742 | else { |
742 | else { |
743 | char *yv=yval(); |
743 | char *yv=yval(); |
744 | |
744 | |
745 | op->arch=find_archetype(yv); |
745 | op->arch=find_archetype(yv); |
746 | if (op->arch!=NULL) { |
746 | if (op->arch!=NULL) { |
747 | copy_object(&op->arch->clone,op); |
747 | copy_object(&op->arch->clone,op); |
748 | } else if (!arch_init) { |
748 | } else if (!arch_init) { |
749 | if (op->name) free_string(op->name); |
749 | if (op->name) free_string(op->name); |
750 | /* record the name of the broken object */ |
750 | /* record the name of the broken object */ |
751 | op->name = add_string(yv); |
751 | op->name = add_string(yv); |
752 | } |
752 | } |
753 | } |
753 | } |
754 | } |
754 | } |
755 | |
755 | |
756 | ^other_arch{S} op->other_arch=find_archetype(yval()); |
756 | ^other_arch{S} op->other_arch=find_archetype(yval()); |
757 | ^animation{S} { |
757 | ^animation{S} { |
758 | if (strcmp (yval(), "NONE") == 0) { |
758 | if (strcmp (yval(), "NONE") == 0) { |
759 | op->animation_id = 0; |
759 | op->animation_id = 0; |
760 | CLEAR_FLAG (op, FLAG_ANIMATE); |
760 | CLEAR_FLAG (op, FLAG_ANIMATE); |
761 | } else { |
761 | } else { |
762 | op->animation_id = find_animation (yval()); |
762 | op->animation_id = find_animation (yval()); |
763 | SET_FLAG (op, FLAG_ANIMATE); |
763 | SET_FLAG (op, FLAG_ANIMATE); |
764 | } |
764 | } |
765 | } |
765 | } |
766 | |
766 | |
767 | ^more{WS}$ { /* We need to record that this is a multipart object, |
767 | ^more{WS}$ { /* We need to record that this is a multipart object, |
768 | * so the calling function can glue things back together |
768 | * so the calling function can glue things back together |
769 | */ |
769 | */ |
770 | ismore=1; |
770 | ismore=1; |
771 | } |
771 | } |
772 | ^end{WS}$ { check_loaded_object(op); |
772 | ^end{WS}$ { check_loaded_object(op); |
773 | |
773 | |
774 | if (!arch_init) |
774 | if (!arch_init) |
775 | op->instantiate (); |
775 | op->instantiate (); |
776 | |
776 | |
777 | if (ismore) return LL_MORE; |
777 | if (ismore) return LL_MORE; |
778 | else return LL_NORMAL; |
778 | else return LL_NORMAL; |
779 | } |
779 | } |
780 | ^oid{S} { |
780 | ^oid{S} { |
781 | thawer.get (op, IVAL); |
781 | thawer.get (op, IVAL); |
782 | } |
782 | } |
783 | ^last_heal{S} op->last_heal = IVAL; |
783 | ^last_heal{S} op->last_heal = IVAL; |
784 | ^last_sp{S} op->last_sp = IVAL; |
784 | ^last_sp{S} op->last_sp = IVAL; |
785 | ^last_grace{S} op->last_grace = IVAL; |
785 | ^last_grace{S} op->last_grace = IVAL; |
786 | ^last_eat{S} op->last_eat = IVAL; |
786 | ^last_eat{S} op->last_eat = IVAL; |
787 | ^speed{S} { op->speed = FVAL; |
787 | ^speed{S} { op->speed = FVAL; |
788 | if (!(map_flags & MAP_STYLE)) { |
788 | if (!(map_flags & MAP_STYLE)) { |
789 | if (op->speed<0) op->speed_left = op->speed_left-RANDOM()%100/100.0; |
789 | if (op->speed<0) op->speed_left = op->speed_left-RANDOM()%100/100.0; |
790 | update_ob_speed(op); |
790 | update_ob_speed(op); |
791 | } |
791 | } |
792 | } |
792 | } |
793 | ^speed_left{S} op->speed_left = FVAL; |
793 | ^speed_left{S} op->speed_left = FVAL; |
794 | ^slow_move{S} { op->move_slow |= MOVE_WALK; |
794 | ^slow_move{S} { op->move_slow |= MOVE_WALK; |
795 | op->move_slow_penalty = FVAL; |
795 | op->move_slow_penalty = FVAL; |
796 | } |
796 | } |
797 | ^title{S} { char *y=yval(); |
797 | ^title{S} { char *y=yval(); |
798 | if (*y=='\0') LOG(llevError,"Title without value.\n"); |
798 | if (*y=='\0') LOG(llevError,"Title without value.\n"); |
799 | else FREE_AND_COPY(op->title, y); |
799 | else FREE_AND_COPY(op->title, y); |
800 | } |
800 | } |
801 | |
801 | |
802 | ^face{S} op->face = &new_faces[FindFace(yval(), 0)]; |
802 | ^face{S} op->face = &new_faces[FindFace(yval(), 0)]; |
803 | ^str{S} op->stats.Str = IVAL; |
803 | ^str{S} op->stats.Str = IVAL; |
804 | ^dex{S} op->stats.Dex = IVAL; |
804 | ^dex{S} op->stats.Dex = IVAL; |
805 | ^con{S} op->stats.Con = IVAL; |
805 | ^con{S} op->stats.Con = IVAL; |
806 | ^wis{S} op->stats.Wis = IVAL; |
806 | ^wis{S} op->stats.Wis = IVAL; |
807 | ^cha{S} op->stats.Cha = IVAL; |
807 | ^cha{S} op->stats.Cha = IVAL; |
808 | ^int{S} op->stats.Int = IVAL; |
808 | ^int{S} op->stats.Int = IVAL; |
809 | ^pow{S} op->stats.Pow = IVAL; |
809 | ^pow{S} op->stats.Pow = IVAL; |
810 | ^hp{S} op->stats.hp = IVAL; |
810 | ^hp{S} op->stats.hp = IVAL; |
811 | ^maxhp{S} op->stats.maxhp = IVAL; |
811 | ^maxhp{S} op->stats.maxhp = IVAL; |
812 | ^sp{S} op->stats.sp = IVAL; |
812 | ^sp{S} op->stats.sp = IVAL; |
813 | ^maxsp{S} op->stats.maxsp = IVAL; |
813 | ^maxsp{S} op->stats.maxsp = IVAL; |
814 | ^grace{S} op->stats.grace = IVAL; |
814 | ^grace{S} op->stats.grace = IVAL; |
815 | ^maxgrace{S} op->stats.maxgrace = IVAL; |
815 | ^maxgrace{S} op->stats.maxgrace = IVAL; |
816 | ^exp{S} op->stats.exp = atoll(yval()); |
816 | ^exp{S} op->stats.exp = atoll(yval()); |
817 | ^perm_exp{S} op->perm_exp = atoll(yval()); |
817 | ^perm_exp{S} op->perm_exp = atoll(yval()); |
818 | ^food{S} op->stats.food = IVAL; |
818 | ^food{S} op->stats.food = IVAL; |
819 | ^dam{S} op->stats.dam = IVAL; |
819 | ^dam{S} op->stats.dam = IVAL; |
820 | ^wc{S} op->stats.wc = IVAL; |
820 | ^wc{S} op->stats.wc = IVAL; |
821 | ^ac{S} op->stats.ac = IVAL; |
821 | ^ac{S} op->stats.ac = IVAL; |
822 | ^x{S} {op->x = IVAL; op->ox= op->x; } |
822 | ^x{S} {op->x = IVAL; op->ox= op->x; } |
823 | ^y{S} {op->y = IVAL; op->oy= op->y; } |
823 | ^y{S} {op->y = IVAL; op->oy= op->y; } |
824 | ^nrof{S} op->nrof= atol(yval()); |
824 | ^nrof{S} op->nrof= atol(yval()); |
825 | ^level{S} op->level = IVAL; |
825 | ^level{S} op->level = IVAL; |
826 | ^direction{S} op->direction = IVAL; |
826 | ^direction{S} op->direction = IVAL; |
827 | ^type{S} op->type = IVAL; |
827 | ^type{S} op->type = IVAL; |
828 | ^subtype{S} op->subtype = IVAL; |
828 | ^subtype{S} op->subtype = IVAL; |
829 | ^material{S} op->material = IVAL; |
829 | ^material{S} op->material = IVAL; |
830 | ^materialname{S} { char *yv=yval(); |
830 | ^materialname{S} { char *yv=yval(); |
831 | if (*yv=='\0') |
831 | if (*yv=='\0') |
832 | LOG(llevError,"Materialname without val\n"); |
832 | LOG(llevError,"Materialname without val\n"); |
833 | else |
833 | else |
834 | FREE_AND_COPY(op->materialname, yv); |
834 | FREE_AND_COPY(op->materialname, yv); |
835 | } |
835 | } |
836 | |
836 | |
837 | ^value{S} op->value = IVAL; |
837 | ^value{S} op->value = IVAL; |
838 | ^weight{S} op->weight = atol(yval()); |
838 | ^weight{S} op->weight = atol(yval()); |
839 | ^carrying{S} op->carrying = atol(yval()); |
839 | ^carrying{S} op->carrying = atol(yval()); |
840 | ^attacktype{S} op->attacktype = IVAL; |
840 | ^attacktype{S} op->attacktype = IVAL; |
841 | ^path_attuned{S} op->path_attuned = IVAL; |
841 | ^path_attuned{S} op->path_attuned = IVAL; |
842 | ^path_repelled{S} op->path_repelled = IVAL; |
842 | ^path_repelled{S} op->path_repelled = IVAL; |
843 | ^path_denied{S} op->path_denied = IVAL; |
843 | ^path_denied{S} op->path_denied = IVAL; |
844 | ^invisible{S} op->invisible = IVAL; |
844 | ^invisible{S} op->invisible = IVAL; |
845 | ^magic{S} op->magic = IVAL; |
845 | ^magic{S} op->magic = IVAL; |
846 | ^state{S} op->state = IVAL; |
846 | ^state{S} op->state = IVAL; |
847 | ^alive{S} SET_OR_CLEAR_FLAG(op, FLAG_ALIVE, IVAL); |
847 | ^alive{S} SET_OR_CLEAR_FLAG(op, FLAG_ALIVE, IVAL); |
848 | ^applied{S} SET_OR_CLEAR_FLAG(op, FLAG_APPLIED, IVAL); |
848 | ^applied{S} SET_OR_CLEAR_FLAG(op, FLAG_APPLIED, IVAL); |
849 | ^unpaid{S} SET_OR_CLEAR_FLAG(op, FLAG_UNPAID, IVAL); |
849 | ^unpaid{S} SET_OR_CLEAR_FLAG(op, FLAG_UNPAID, IVAL); |
850 | ^need_an{S} { /* not used - just ignore */ } |
850 | ^need_an{S} { /* not used - just ignore */ } |
851 | ^need_ie{S} { /* not used - jsut ignore */ } |
851 | ^need_ie{S} { /* not used - jsut ignore */ } |
852 | ^is_animated{S} SET_OR_CLEAR_FLAG(op, FLAG_ANIMATE, IVAL); |
852 | ^is_animated{S} SET_OR_CLEAR_FLAG(op, FLAG_ANIMATE, IVAL); |
853 | ^no_pick{S} SET_OR_CLEAR_FLAG(op, FLAG_NO_PICK, IVAL); |
853 | ^no_pick{S} SET_OR_CLEAR_FLAG(op, FLAG_NO_PICK, IVAL); |
854 | |
854 | |
855 | %{ /* These are all legacy - any new objects should use the move_ .. values */ |
855 | %{ /* These are all legacy - any new objects should use the move_ .. values */ |
856 | %} |
856 | %} |
857 | ^no_pass{S} { if (IVAL) op->move_block = MOVE_ALL; else op->move_block=0; } |
857 | ^no_pass{S} { if (IVAL) op->move_block = MOVE_ALL; else op->move_block=0; } |
858 | ^walk_on{S} { if (IVAL) op->move_on |= MOVE_WALK; else op->move_on &= ~MOVE_WALK; } |
858 | ^walk_on{S} { if (IVAL) op->move_on |= MOVE_WALK; else op->move_on &= ~MOVE_WALK; } |
859 | ^walk_off{S} { if (IVAL) op->move_off |= MOVE_WALK; else op->move_off &= ~MOVE_WALK; } |
859 | ^walk_off{S} { if (IVAL) op->move_off |= MOVE_WALK; else op->move_off &= ~MOVE_WALK; } |
860 | ^fly_on{S} { if (IVAL) op->move_on |= MOVE_FLY_LOW; else op->move_on &= ~MOVE_FLY_LOW; } |
860 | ^fly_on{S} { if (IVAL) op->move_on |= MOVE_FLY_LOW; else op->move_on &= ~MOVE_FLY_LOW; } |
861 | ^fly_off{S} { if (IVAL) op->move_off |= MOVE_FLY_LOW; else op->move_off &= ~MOVE_FLY_LOW; } |
861 | ^fly_off{S} { if (IVAL) op->move_off |= MOVE_FLY_LOW; else op->move_off &= ~MOVE_FLY_LOW; } |
862 | ^flying{S} { if (IVAL) op->move_type |= MOVE_FLY_LOW; else op->move_type &= ~MOVE_FLY_LOW; } |
862 | ^flying{S} { if (IVAL) op->move_type |= MOVE_FLY_LOW; else op->move_type &= ~MOVE_FLY_LOW; } |
863 | |
863 | |
864 | %{ /* These are the new values */ |
864 | %{ /* These are the new values */ |
865 | %} |
865 | %} |
866 | ^move_block{S} set_move(&op->move_block, yval()); |
866 | ^move_block{S} set_move(&op->move_block, yval()); |
867 | ^move_allow{S} set_move(&op->move_allow, yval()); |
867 | ^move_allow{S} set_move(&op->move_allow, yval()); |
868 | ^move_type{S} set_move(&op->move_type, yval()); |
868 | ^move_type{S} set_move(&op->move_type, yval()); |
869 | ^move_on{S} set_move(&op->move_on, yval()); |
869 | ^move_on{S} set_move(&op->move_on, yval()); |
870 | ^move_off{S} set_move(&op->move_off, yval()); |
870 | ^move_off{S} set_move(&op->move_off, yval()); |
871 | ^move_slow{S} set_move(&op->move_slow, yval()); |
871 | ^move_slow{S} set_move(&op->move_slow, yval()); |
872 | ^move_slow_penalty{S} op->move_slow_penalty = FVAL; |
872 | ^move_slow_penalty{S} op->move_slow_penalty = FVAL; |
873 | |
873 | |
874 | |
874 | |
875 | ^monster{S} SET_OR_CLEAR_FLAG(op, FLAG_MONSTER, IVAL); |
875 | ^monster{S} SET_OR_CLEAR_FLAG(op, FLAG_MONSTER, IVAL); |
876 | ^neutral{S} SET_OR_CLEAR_FLAG(op, FLAG_NEUTRAL, IVAL); |
876 | ^neutral{S} SET_OR_CLEAR_FLAG(op, FLAG_NEUTRAL, IVAL); |
877 | ^no_attack{S} SET_OR_CLEAR_FLAG(op, FLAG_NO_ATTACK, IVAL); |
877 | ^no_attack{S} SET_OR_CLEAR_FLAG(op, FLAG_NO_ATTACK, IVAL); |
878 | ^no_damage{S} SET_OR_CLEAR_FLAG(op, FLAG_NO_DAMAGE, IVAL); |
878 | ^no_damage{S} SET_OR_CLEAR_FLAG(op, FLAG_NO_DAMAGE, IVAL); |
879 | ^friendly{S} { if (IVAL) { |
879 | ^friendly{S} { if (IVAL) { |
880 | SET_FLAG(op, FLAG_FRIENDLY); |
880 | SET_FLAG(op, FLAG_FRIENDLY); |
881 | if (op->type != PLAYER) |
881 | if (op->type != PLAYER) |
882 | add_friendly_object (op); |
882 | add_friendly_object (op); |
883 | } |
883 | } |
884 | else CLEAR_FLAG(op, FLAG_FRIENDLY); |
884 | else CLEAR_FLAG(op, FLAG_FRIENDLY); |
885 | } |
885 | } |
886 | ^generator{S} SET_OR_CLEAR_FLAG(op, FLAG_GENERATOR, IVAL); |
886 | ^generator{S} SET_OR_CLEAR_FLAG(op, FLAG_GENERATOR, IVAL); |
887 | ^use_content_on_gen{S} SET_OR_CLEAR_FLAG (op,FLAG_CONTENT_ON_GEN, IVAL); |
887 | ^use_content_on_gen{S} SET_OR_CLEAR_FLAG (op,FLAG_CONTENT_ON_GEN, IVAL); |
888 | ^is_thrown{S} SET_OR_CLEAR_FLAG(op, FLAG_IS_THROWN, IVAL); |
888 | ^is_thrown{S} SET_OR_CLEAR_FLAG(op, FLAG_IS_THROWN, IVAL); |
889 | ^auto_apply{S} SET_OR_CLEAR_FLAG(op, FLAG_AUTO_APPLY, IVAL); |
889 | ^auto_apply{S} SET_OR_CLEAR_FLAG(op, FLAG_AUTO_APPLY, IVAL); |
890 | ^treasure{S} SET_OR_CLEAR_FLAG(op, FLAG_TREASURE, IVAL); |
890 | ^treasure{S} SET_OR_CLEAR_FLAG(op, FLAG_TREASURE, IVAL); |
891 | ^see_invisible{S} SET_OR_CLEAR_FLAG(op, FLAG_SEE_INVISIBLE, IVAL); |
891 | ^see_invisible{S} SET_OR_CLEAR_FLAG(op, FLAG_SEE_INVISIBLE, IVAL); |
892 | ^can_roll{S} SET_OR_CLEAR_FLAG(op, FLAG_CAN_ROLL, IVAL); |
892 | ^can_roll{S} SET_OR_CLEAR_FLAG(op, FLAG_CAN_ROLL, IVAL); |
893 | ^overlay_floor{S} SET_OR_CLEAR_FLAG(op, FLAG_OVERLAY_FLOOR, IVAL); |
893 | ^overlay_floor{S} SET_OR_CLEAR_FLAG(op, FLAG_OVERLAY_FLOOR, IVAL); |
894 | ^is_turnable{S} SET_OR_CLEAR_FLAG(op, FLAG_IS_TURNABLE, IVAL); |
894 | ^is_turnable{S} SET_OR_CLEAR_FLAG(op, FLAG_IS_TURNABLE, IVAL); |
895 | ^is_used_up{S} SET_OR_CLEAR_FLAG(op, FLAG_IS_USED_UP, IVAL); |
895 | ^is_used_up{S} SET_OR_CLEAR_FLAG(op, FLAG_IS_USED_UP, IVAL); |
896 | ^identified{S} { if (IVAL) { |
896 | ^identified{S} { if (IVAL) { |
897 | SET_FLAG(op, FLAG_IDENTIFIED); |
897 | SET_FLAG(op, FLAG_IDENTIFIED); |
898 | CLEAR_FLAG(op, FLAG_KNOWN_MAGICAL); |
898 | CLEAR_FLAG(op, FLAG_KNOWN_MAGICAL); |
899 | } |
899 | } |
900 | else CLEAR_FLAG(op, FLAG_IDENTIFIED); |
900 | else CLEAR_FLAG(op, FLAG_IDENTIFIED); |
901 | } |
901 | } |
902 | ^reflecting{S} SET_OR_CLEAR_FLAG(op, FLAG_REFLECTING, IVAL); |
902 | ^reflecting{S} SET_OR_CLEAR_FLAG(op, FLAG_REFLECTING, IVAL); |
903 | ^changing{S} SET_OR_CLEAR_FLAG(op, FLAG_CHANGING, IVAL); |
903 | ^changing{S} SET_OR_CLEAR_FLAG(op, FLAG_CHANGING, IVAL); |
904 | ^splitting{S} SET_OR_CLEAR_FLAG(op, FLAG_SPLITTING, IVAL); |
904 | ^splitting{S} SET_OR_CLEAR_FLAG(op, FLAG_SPLITTING, IVAL); |
905 | ^hitback{S} SET_OR_CLEAR_FLAG(op, FLAG_HITBACK, IVAL); |
905 | ^hitback{S} SET_OR_CLEAR_FLAG(op, FLAG_HITBACK, IVAL); |
906 | ^startequip{S} SET_OR_CLEAR_FLAG(op, FLAG_STARTEQUIP, IVAL); |
906 | ^startequip{S} SET_OR_CLEAR_FLAG(op, FLAG_STARTEQUIP, IVAL); |
907 | ^blocksview{S} SET_OR_CLEAR_FLAG(op, FLAG_BLOCKSVIEW, IVAL); |
907 | ^blocksview{S} SET_OR_CLEAR_FLAG(op, FLAG_BLOCKSVIEW, IVAL); |
908 | ^editable{S} op->arch->editable = IVAL; |
908 | ^editable{S} op->arch->editable = IVAL; |
909 | ^editor_folder{S} { } |
909 | ^editor_folder{S} { } |
910 | ^undead{S} SET_OR_CLEAR_FLAG(op, FLAG_UNDEAD, IVAL); |
910 | ^undead{S} SET_OR_CLEAR_FLAG(op, FLAG_UNDEAD, IVAL); |
911 | ^scared{S} SET_OR_CLEAR_FLAG(op, FLAG_SCARED, IVAL); |
911 | ^scared{S} SET_OR_CLEAR_FLAG(op, FLAG_SCARED, IVAL); |
912 | ^unaggressive{S} SET_OR_CLEAR_FLAG(op, FLAG_UNAGGRESSIVE, IVAL); |
912 | ^unaggressive{S} SET_OR_CLEAR_FLAG(op, FLAG_UNAGGRESSIVE, IVAL); |
913 | ^reflect_missile{S} SET_OR_CLEAR_FLAG(op, FLAG_REFL_MISSILE, IVAL); |
913 | ^reflect_missile{S} SET_OR_CLEAR_FLAG(op, FLAG_REFL_MISSILE, IVAL); |
914 | ^reflect_spell{S} SET_OR_CLEAR_FLAG(op, FLAG_REFL_SPELL, IVAL); |
914 | ^reflect_spell{S} SET_OR_CLEAR_FLAG(op, FLAG_REFL_SPELL, IVAL); |
915 | ^no_magic{S} SET_OR_CLEAR_FLAG(op, FLAG_NO_MAGIC, IVAL); |
915 | ^no_magic{S} SET_OR_CLEAR_FLAG(op, FLAG_NO_MAGIC, IVAL); |
916 | ^wiz{S} { if (IVAL) { |
916 | ^wiz{S} { if (IVAL) { |
917 | SET_FLAG(op, FLAG_WIZ); |
917 | SET_FLAG(op, FLAG_WIZ); |
918 | SET_FLAG(op, FLAG_WAS_WIZ); |
918 | SET_FLAG(op, FLAG_WAS_WIZ); |
919 | SET_FLAG(op, FLAG_WIZPASS); |
919 | SET_FLAG(op, FLAG_WIZPASS); |
920 | SET_FLAG(op, FLAG_WIZCAST); |
920 | SET_FLAG(op, FLAG_WIZCAST); |
921 | } |
921 | } |
922 | else { |
922 | else { |
923 | CLEAR_FLAG(op, FLAG_WIZ); |
923 | CLEAR_FLAG(op, FLAG_WIZ); |
924 | CLEAR_FLAG(op, FLAG_WIZPASS); |
924 | CLEAR_FLAG(op, FLAG_WIZPASS); |
925 | CLEAR_FLAG(op, FLAG_WIZCAST); |
925 | CLEAR_FLAG(op, FLAG_WIZCAST); |
926 | } |
926 | } |
927 | } |
927 | } |
928 | ^was_wiz{S} SET_OR_CLEAR_FLAG(op, FLAG_WAS_WIZ, IVAL); |
928 | ^was_wiz{S} SET_OR_CLEAR_FLAG(op, FLAG_WAS_WIZ, IVAL); |
929 | ^no_fix_player{S} SET_OR_CLEAR_FLAG(op, FLAG_NO_FIX_PLAYER, IVAL); |
929 | ^no_fix_player{S} SET_OR_CLEAR_FLAG(op, FLAG_NO_FIX_PLAYER, IVAL); |
930 | ^is_lightable{S} SET_OR_CLEAR_FLAG(op, FLAG_IS_LIGHTABLE, IVAL); |
930 | ^is_lightable{S} SET_OR_CLEAR_FLAG(op, FLAG_IS_LIGHTABLE, IVAL); |
931 | ^tear_down{S} SET_OR_CLEAR_FLAG(op, FLAG_TEAR_DOWN, IVAL); |
931 | ^tear_down{S} SET_OR_CLEAR_FLAG(op, FLAG_TEAR_DOWN, IVAL); |
932 | ^luck{S} op->stats.luck = IVAL; |
932 | ^luck{S} op->stats.luck = IVAL; |
933 | ^run_away{S} op->run_away = IVAL; |
933 | ^run_away{S} op->run_away = IVAL; |
934 | ^pick_up{S} op->pick_up = IVAL; |
934 | ^pick_up{S} op->pick_up = IVAL; |
935 | ^item_power{S} op->item_power = IVAL; |
935 | ^item_power{S} op->item_power = IVAL; |
936 | ^gen_sp_armour{S} op->gen_sp_armour = IVAL; |
936 | ^gen_sp_armour{S} op->gen_sp_armour = IVAL; |
937 | ^anim_speed{S} op->anim_speed = IVAL; |
937 | ^anim_speed{S} op->anim_speed = IVAL; |
938 | ^container{S} op->weight_limit = IVAL; |
938 | ^container{S} op->weight_limit = IVAL; |
939 | ^no_drop{S} SET_OR_CLEAR_FLAG(op, FLAG_NO_DROP, IVAL); |
939 | ^no_drop{S} SET_OR_CLEAR_FLAG(op, FLAG_NO_DROP, IVAL); |
940 | ^will_apply{S} op->will_apply = IVAL; |
940 | ^will_apply{S} op->will_apply = IVAL; |
941 | ^random_movement{S} SET_OR_CLEAR_FLAG(op, FLAG_RANDOM_MOVE, IVAL); |
941 | ^random_movement{S} SET_OR_CLEAR_FLAG(op, FLAG_RANDOM_MOVE, IVAL); |
942 | ^can_apply{S} { } |
942 | ^can_apply{S} { } |
943 | ^can_use_shield{S} SET_OR_CLEAR_FLAG(op, FLAG_USE_SHIELD, IVAL); |
943 | ^can_use_shield{S} SET_OR_CLEAR_FLAG(op, FLAG_USE_SHIELD, IVAL); |
944 | ^can_cast_spell{S} SET_OR_CLEAR_FLAG(op, FLAG_CAST_SPELL, IVAL); |
944 | ^can_cast_spell{S} SET_OR_CLEAR_FLAG(op, FLAG_CAST_SPELL, IVAL); |
945 | ^can_use_scroll{S} SET_OR_CLEAR_FLAG(op, FLAG_USE_SCROLL, IVAL); |
945 | ^can_use_scroll{S} SET_OR_CLEAR_FLAG(op, FLAG_USE_SCROLL, IVAL); |
946 | ^can_use_range{S} SET_OR_CLEAR_FLAG(op, FLAG_USE_RANGE, IVAL); |
946 | ^can_use_range{S} SET_OR_CLEAR_FLAG(op, FLAG_USE_RANGE, IVAL); |
947 | ^can_use_bow{S} SET_OR_CLEAR_FLAG(op, FLAG_USE_BOW, IVAL); |
947 | ^can_use_bow{S} SET_OR_CLEAR_FLAG(op, FLAG_USE_BOW, IVAL); |
948 | ^can_use_armour{S} SET_OR_CLEAR_FLAG(op, FLAG_USE_ARMOUR, IVAL); |
948 | ^can_use_armour{S} SET_OR_CLEAR_FLAG(op, FLAG_USE_ARMOUR, IVAL); |
949 | ^can_use_weapon{S} SET_OR_CLEAR_FLAG(op, FLAG_USE_WEAPON, IVAL); |
949 | ^can_use_weapon{S} SET_OR_CLEAR_FLAG(op, FLAG_USE_WEAPON, IVAL); |
950 | ^can_use_ring{S} SET_OR_CLEAR_FLAG(op, FLAG_USE_RING, IVAL); |
950 | ^can_use_ring{S} SET_OR_CLEAR_FLAG(op, FLAG_USE_RING, IVAL); |
951 | ^has_ready_bow{S} SET_OR_CLEAR_FLAG(op, FLAG_READY_BOW, IVAL); |
951 | ^has_ready_bow{S} SET_OR_CLEAR_FLAG(op, FLAG_READY_BOW, IVAL); |
952 | ^xrays{S} SET_OR_CLEAR_FLAG(op, FLAG_XRAYS, IVAL); |
952 | ^xrays{S} SET_OR_CLEAR_FLAG(op, FLAG_XRAYS, IVAL); |
953 | ^is_floor{S} SET_OR_CLEAR_FLAG(op, FLAG_IS_FLOOR, IVAL); |
953 | ^is_floor{S} SET_OR_CLEAR_FLAG(op, FLAG_IS_FLOOR, IVAL); |
954 | ^lifesave{S} SET_OR_CLEAR_FLAG(op, FLAG_LIFESAVE, IVAL); |
954 | ^lifesave{S} SET_OR_CLEAR_FLAG(op, FLAG_LIFESAVE, IVAL); |
955 | ^no_strength{S} SET_OR_CLEAR_FLAG(op, FLAG_NO_STRENGTH, IVAL); |
955 | ^no_strength{S} SET_OR_CLEAR_FLAG(op, FLAG_NO_STRENGTH, IVAL); |
956 | ^sleep{S} { |
956 | ^sleep{S} { |
957 | SET_OR_CLEAR_FLAG(op, FLAG_SLEEP, IVAL); |
957 | SET_OR_CLEAR_FLAG(op, FLAG_SLEEP, IVAL); |
958 | /*(LOG(llevDebug," Warning: Object %s has sleep set in arch.\n",op->name);*/ |
958 | /*(LOG(llevDebug," Warning: Object %s has sleep set in arch.\n",op->name);*/ |
959 | } |
959 | } |
960 | ^stand_still{S} SET_OR_CLEAR_FLAG(op, FLAG_STAND_STILL, IVAL); |
960 | ^stand_still{S} SET_OR_CLEAR_FLAG(op, FLAG_STAND_STILL, IVAL); |
961 | ^random_move{S} SET_OR_CLEAR_FLAG(op, FLAG_RANDOM_MOVE, IVAL); |
961 | ^random_move{S} SET_OR_CLEAR_FLAG(op, FLAG_RANDOM_MOVE, IVAL); |
962 | ^only_attack{S} SET_OR_CLEAR_FLAG(op, FLAG_ONLY_ATTACK, IVAL); |
962 | ^only_attack{S} SET_OR_CLEAR_FLAG(op, FLAG_ONLY_ATTACK, IVAL); |
963 | |
963 | |
964 | ^activate_on_push{S} SET_OR_CLEAR_FLAG(op, FLAG_ACTIVATE_ON_PUSH, IVAL); |
964 | ^activate_on_push{S} SET_OR_CLEAR_FLAG(op, FLAG_ACTIVATE_ON_PUSH, IVAL); |
965 | ^activate_on_release{S} SET_OR_CLEAR_FLAG(op, FLAG_ACTIVATE_ON_RELEASE, IVAL); |
965 | ^activate_on_release{S} SET_OR_CLEAR_FLAG(op, FLAG_ACTIVATE_ON_RELEASE, IVAL); |
966 | |
966 | |
967 | /* armour is loaded for compatiblity reasons */ |
967 | /* armour is loaded for compatiblity reasons */ |
968 | ^armour{S} SET_RESIST(op, ATNR_PHYSICAL, IVAL); |
968 | ^armour{S} SET_RESIST(op, ATNR_PHYSICAL, IVAL); |
969 | /* Start of various attacktypes */ |
969 | /* Start of various attacktypes */ |
970 | ^resist_physical{S} SET_RESIST(op, ATNR_PHYSICAL, IVAL); |
970 | ^resist_physical{S} SET_RESIST(op, ATNR_PHYSICAL, IVAL); |
971 | ^resist_magic{S} SET_RESIST(op, ATNR_MAGIC, IVAL); |
971 | ^resist_magic{S} SET_RESIST(op, ATNR_MAGIC, IVAL); |
972 | ^resist_fire{S} SET_RESIST(op, ATNR_FIRE, IVAL); |
972 | ^resist_fire{S} SET_RESIST(op, ATNR_FIRE, IVAL); |
973 | ^resist_electricity{S} SET_RESIST(op, ATNR_ELECTRICITY, IVAL); |
973 | ^resist_electricity{S} SET_RESIST(op, ATNR_ELECTRICITY, IVAL); |
974 | ^resist_cold{S} SET_RESIST(op, ATNR_COLD, IVAL); |
974 | ^resist_cold{S} SET_RESIST(op, ATNR_COLD, IVAL); |
975 | ^resist_confusion{S} SET_RESIST(op, ATNR_CONFUSION, IVAL); |
975 | ^resist_confusion{S} SET_RESIST(op, ATNR_CONFUSION, IVAL); |
976 | ^resist_acid{S} SET_RESIST(op, ATNR_ACID, IVAL); |
976 | ^resist_acid{S} SET_RESIST(op, ATNR_ACID, IVAL); |
977 | ^resist_drain{S} SET_RESIST(op, ATNR_DRAIN, IVAL); |
977 | ^resist_drain{S} SET_RESIST(op, ATNR_DRAIN, IVAL); |
978 | ^resist_weaponmagic{S} SET_RESIST(op, ATNR_WEAPONMAGIC, IVAL); |
978 | ^resist_weaponmagic{S} SET_RESIST(op, ATNR_WEAPONMAGIC, IVAL); |
979 | ^resist_ghosthit{S} SET_RESIST(op, ATNR_GHOSTHIT, IVAL); |
979 | ^resist_ghosthit{S} SET_RESIST(op, ATNR_GHOSTHIT, IVAL); |
980 | ^resist_poison{S} SET_RESIST(op, ATNR_POISON, IVAL); |
980 | ^resist_poison{S} SET_RESIST(op, ATNR_POISON, IVAL); |
981 | ^resist_slow{S} SET_RESIST(op, ATNR_SLOW, IVAL); |
981 | ^resist_slow{S} SET_RESIST(op, ATNR_SLOW, IVAL); |
982 | ^resist_paralyze{S} SET_RESIST(op, ATNR_PARALYZE, IVAL); |
982 | ^resist_paralyze{S} SET_RESIST(op, ATNR_PARALYZE, IVAL); |
983 | ^resist_turn_undead{S} SET_RESIST(op, ATNR_TURN_UNDEAD, IVAL); |
983 | ^resist_turn_undead{S} SET_RESIST(op, ATNR_TURN_UNDEAD, IVAL); |
984 | ^resist_fear{S} SET_RESIST(op, ATNR_FEAR, IVAL); |
984 | ^resist_fear{S} SET_RESIST(op, ATNR_FEAR, IVAL); |
985 | ^resist_cancellation{S} SET_RESIST(op, ATNR_CANCELLATION, IVAL); |
985 | ^resist_cancellation{S} SET_RESIST(op, ATNR_CANCELLATION, IVAL); |
986 | ^resist_deplete{S} SET_RESIST(op, ATNR_DEPLETE, IVAL); |
986 | ^resist_deplete{S} SET_RESIST(op, ATNR_DEPLETE, IVAL); |
987 | ^resist_death{S} SET_RESIST(op, ATNR_DEATH, IVAL); |
987 | ^resist_death{S} SET_RESIST(op, ATNR_DEATH, IVAL); |
988 | ^resist_chaos{S} SET_RESIST(op, ATNR_CHAOS, IVAL); |
988 | ^resist_chaos{S} SET_RESIST(op, ATNR_CHAOS, IVAL); |
989 | ^resist_counterspell{S} SET_RESIST(op, ATNR_COUNTERSPELL, IVAL); |
989 | ^resist_counterspell{S} SET_RESIST(op, ATNR_COUNTERSPELL, IVAL); |
990 | ^resist_godpower{S} SET_RESIST(op, ATNR_GODPOWER, IVAL); |
990 | ^resist_godpower{S} SET_RESIST(op, ATNR_GODPOWER, IVAL); |
991 | ^resist_holyword{S} SET_RESIST(op, ATNR_HOLYWORD, IVAL); |
991 | ^resist_holyword{S} SET_RESIST(op, ATNR_HOLYWORD, IVAL); |
992 | ^resist_blind{S} SET_RESIST(op, ATNR_BLIND, IVAL); |
992 | ^resist_blind{S} SET_RESIST(op, ATNR_BLIND, IVAL); |
993 | ^resist_internal{S} SET_RESIST(op, ATNR_INTERNAL, IVAL); |
993 | ^resist_internal{S} SET_RESIST(op, ATNR_INTERNAL, IVAL); |
994 | ^resist_life_stealing{S} SET_RESIST(op, ATNR_LIFE_STEALING, IVAL); |
994 | ^resist_life_stealing{S} SET_RESIST(op, ATNR_LIFE_STEALING, IVAL); |
995 | ^resist_disease{S} SET_RESIST(op, ATNR_DISEASE, IVAL); |
995 | ^resist_disease{S} SET_RESIST(op, ATNR_DISEASE, IVAL); |
996 | |
996 | |
997 | /* Old style resistances */ |
997 | /* Old style resistances */ |
998 | ^immune{S} set_protection(op, IVAL, RESIST_IMMUNE); |
998 | ^immune{S} set_protection(op, IVAL, RESIST_IMMUNE); |
999 | ^protected{S} set_protection(op, IVAL, RESIST_PROT); |
999 | ^protected{S} set_protection(op, IVAL, RESIST_PROT); |
1000 | ^vulnerable{S} set_protection(op, IVAL, (uint16) RESIST_VULN); |
1000 | ^vulnerable{S} set_protection(op, IVAL, (uint16) RESIST_VULN); |
1001 | |
1001 | |
1002 | /* old values - keep them around for now, but they should be removed at some point */ |
1002 | /* old values - keep them around for now, but they should be removed at some point */ |
1003 | ^has_ready_rod{S} SET_OR_CLEAR_FLAG(op, FLAG_READY_RANGE, IVAL); |
1003 | ^has_ready_rod{S} SET_OR_CLEAR_FLAG(op, FLAG_READY_RANGE, IVAL); |
1004 | ^has_ready_horn{S} SET_OR_CLEAR_FLAG(op, FLAG_READY_RANGE, IVAL); |
1004 | ^has_ready_horn{S} SET_OR_CLEAR_FLAG(op, FLAG_READY_RANGE, IVAL); |
1005 | ^has_ready_wand{S} SET_OR_CLEAR_FLAG(op, FLAG_READY_RANGE, IVAL); |
1005 | ^has_ready_wand{S} SET_OR_CLEAR_FLAG(op, FLAG_READY_RANGE, IVAL); |
1006 | ^can_use_wand{S} SET_OR_CLEAR_FLAG(op, FLAG_USE_RANGE, IVAL); |
1006 | ^can_use_wand{S} SET_OR_CLEAR_FLAG(op, FLAG_USE_RANGE, IVAL); |
1007 | |
1007 | |
1008 | ^attack_movement{S} op->attack_movement = IVAL; |
1008 | ^attack_movement{S} op->attack_movement = IVAL; |
1009 | ^move_state{S} op->move_status = IVAL; |
1009 | ^move_state{S} op->move_status = IVAL; |
1010 | ^confused{S} SET_OR_CLEAR_FLAG(op, FLAG_CONFUSED, IVAL); |
1010 | ^confused{S} SET_OR_CLEAR_FLAG(op, FLAG_CONFUSED, IVAL); |
1011 | ^stealth{S} SET_OR_CLEAR_FLAG(op, FLAG_STEALTH, IVAL); |
1011 | ^stealth{S} SET_OR_CLEAR_FLAG(op, FLAG_STEALTH, IVAL); |
1012 | ^connected{S} add_button_link(op, op->map, IVAL); |
1012 | ^connected{S} add_button_link(op, op->map, IVAL); |
1013 | ^cursed{S} SET_OR_CLEAR_FLAG(op, FLAG_CURSED, IVAL); |
1013 | ^cursed{S} SET_OR_CLEAR_FLAG(op, FLAG_CURSED, IVAL); |
1014 | ^damned{S} SET_OR_CLEAR_FLAG(op, FLAG_DAMNED, IVAL); |
1014 | ^damned{S} SET_OR_CLEAR_FLAG(op, FLAG_DAMNED, IVAL); |
1015 | ^see_anywhere{S} SET_OR_CLEAR_FLAG(op, FLAG_SEE_ANYWHERE, IVAL); |
1015 | ^see_anywhere{S} SET_OR_CLEAR_FLAG(op, FLAG_SEE_ANYWHERE, IVAL); |
1016 | ^known_magical{S} SET_OR_CLEAR_FLAG(op, FLAG_KNOWN_MAGICAL, IVAL); |
1016 | ^known_magical{S} SET_OR_CLEAR_FLAG(op, FLAG_KNOWN_MAGICAL, IVAL); |
1017 | ^known_cursed{S} SET_OR_CLEAR_FLAG(op, FLAG_KNOWN_CURSED, IVAL); |
1017 | ^known_cursed{S} SET_OR_CLEAR_FLAG(op, FLAG_KNOWN_CURSED, IVAL); |
1018 | ^can_use_skill{S} SET_OR_CLEAR_FLAG(op, FLAG_CAN_USE_SKILL, IVAL); |
1018 | ^can_use_skill{S} SET_OR_CLEAR_FLAG(op, FLAG_CAN_USE_SKILL, IVAL); |
1019 | ^been_applied{S} SET_OR_CLEAR_FLAG(op, FLAG_BEEN_APPLIED, IVAL); |
1019 | ^been_applied{S} SET_OR_CLEAR_FLAG(op, FLAG_BEEN_APPLIED, IVAL); |
1020 | ^has_ready_scroll{S} SET_OR_CLEAR_FLAG(op, FLAG_READY_SCROLL, IVAL); |
1020 | ^has_ready_scroll{S} SET_OR_CLEAR_FLAG(op, FLAG_READY_SCROLL, IVAL); |
1021 | ^can_use_rod{S} SET_OR_CLEAR_FLAG(op, FLAG_USE_ROD, IVAL); |
1021 | ^can_use_rod{S} SET_OR_CLEAR_FLAG(op, FLAG_USE_ROD, IVAL); |
1022 | ^can_use_horn{S} SET_OR_CLEAR_FLAG(op, FLAG_USE_HORN, IVAL); |
1022 | ^can_use_horn{S} SET_OR_CLEAR_FLAG(op, FLAG_USE_HORN, IVAL); |
1023 | ^expmul{S} op->expmul = FVAL; |
1023 | ^expmul{S} op->expmul = FVAL; |
1024 | ^unique{S} SET_OR_CLEAR_FLAG(op, FLAG_UNIQUE, IVAL); |
1024 | ^unique{S} SET_OR_CLEAR_FLAG(op, FLAG_UNIQUE, IVAL); |
1025 | ^make_invisible{S} SET_OR_CLEAR_FLAG(op, FLAG_MAKE_INVIS, IVAL); |
1025 | ^make_invisible{S} SET_OR_CLEAR_FLAG(op, FLAG_MAKE_INVIS, IVAL); |
1026 | ^inv_locked{S} SET_OR_CLEAR_FLAG(op, FLAG_INV_LOCKED, IVAL); |
1026 | ^inv_locked{S} SET_OR_CLEAR_FLAG(op, FLAG_INV_LOCKED, IVAL); |
1027 | ^is_wooded{S} SET_OR_CLEAR_FLAG(op, FLAG_IS_WOODED, IVAL); |
1027 | ^is_wooded{S} SET_OR_CLEAR_FLAG(op, FLAG_IS_WOODED, IVAL); |
1028 | ^is_hilly{S} SET_OR_CLEAR_FLAG(op, FLAG_IS_HILLY, IVAL); |
1028 | ^is_hilly{S} SET_OR_CLEAR_FLAG(op, FLAG_IS_HILLY, IVAL); |
1029 | ^is_water{S} SET_OR_CLEAR_FLAG(op, FLAG_IS_WATER, IVAL); |
1029 | ^is_water{S} SET_OR_CLEAR_FLAG(op, FLAG_IS_WATER, IVAL); |
1030 | ^has_ready_skill{S} SET_OR_CLEAR_FLAG(op, FLAG_READY_SKILL, IVAL); |
1030 | ^has_ready_skill{S} SET_OR_CLEAR_FLAG(op, FLAG_READY_SKILL, IVAL); |
1031 | ^has_ready_weapon{S} SET_OR_CLEAR_FLAG(op, FLAG_READY_WEAPON, IVAL); |
1031 | ^has_ready_weapon{S} SET_OR_CLEAR_FLAG(op, FLAG_READY_WEAPON, IVAL); |
1032 | ^no_skill_ident{S} SET_OR_CLEAR_FLAG(op, FLAG_NO_SKILL_IDENT, IVAL); |
1032 | ^no_skill_ident{S} SET_OR_CLEAR_FLAG(op, FLAG_NO_SKILL_IDENT, IVAL); |
1033 | ^glow_radius{S} op->glow_radius = IVAL; |
1033 | ^glow_radius{S} op->glow_radius = IVAL; |
1034 | ^is_blind{S} SET_OR_CLEAR_FLAG(op, FLAG_BLIND, IVAL); |
1034 | ^is_blind{S} SET_OR_CLEAR_FLAG(op, FLAG_BLIND, IVAL); |
1035 | ^can_see_in_dark{S} SET_OR_CLEAR_FLAG(op, FLAG_SEE_IN_DARK, IVAL); |
1035 | ^can_see_in_dark{S} SET_OR_CLEAR_FLAG(op, FLAG_SEE_IN_DARK, IVAL); |
1036 | ^is_cauldron{S} SET_OR_CLEAR_FLAG(op, FLAG_IS_CAULDRON, IVAL); |
1036 | ^is_cauldron{S} SET_OR_CLEAR_FLAG(op, FLAG_IS_CAULDRON, IVAL); |
1037 | ^randomitems{S} op->randomitems = find_treasurelist(yval()); |
1037 | ^randomitems{S} op->randomitems = find_treasurelist(yval()); |
1038 | ^no_steal{S} SET_OR_CLEAR_FLAG(op, FLAG_NO_STEAL, IVAL); |
1038 | ^no_steal{S} SET_OR_CLEAR_FLAG(op, FLAG_NO_STEAL, IVAL); |
1039 | ^one_hit{S} SET_OR_CLEAR_FLAG(op, FLAG_ONE_HIT, IVAL); |
1039 | ^one_hit{S} SET_OR_CLEAR_FLAG(op, FLAG_ONE_HIT, IVAL); |
1040 | ^berserk{S} SET_OR_CLEAR_FLAG(op, FLAG_BERSERK, IVAL); |
1040 | ^berserk{S} SET_OR_CLEAR_FLAG(op, FLAG_BERSERK, IVAL); |
1041 | |
1041 | |
1042 | ^can_knockback{S} { /* Some archetypes have these values in them */ } |
1042 | ^can_knockback{S} { /* Some archetypes have these values in them */ } |
1043 | ^can_parry{S} { /* Probably the pupland archetypes - I imagined */ } |
1043 | ^can_parry{S} { /* Probably the pupland archetypes - I imagined */ } |
1044 | ^can_impale{S} { /* That these are for the new combat code */ } |
1044 | ^can_impale{S} { /* That these are for the new combat code */ } |
1045 | ^can_cut{S} { /* just ignore for now */ } |
1045 | ^can_cut{S} { /* just ignore for now */ } |
1046 | ^can_dam_armour{S} { } |
1046 | ^can_dam_armour{S} { } |
1047 | ^weapontype{S} op->weapontype = IVAL; |
1047 | ^weapontype{S} op->weapontype = IVAL; |
1048 | ^tooltype{S} op->tooltype = IVAL; |
1048 | ^tooltype{S} op->tooltype = IVAL; |
1049 | ^casting_time{S} op->casting_time = (sint16) FVAL; |
1049 | ^casting_time{S} op->casting_time = (sint16) FVAL; |
1050 | ^elevation{S} op->elevation = IVAL; |
1050 | ^elevation{S} op->elevation = IVAL; |
1051 | ^smoothlevel{S} op->smoothlevel = IVAL; |
1051 | ^smoothlevel{S} op->smoothlevel = IVAL; |
1052 | ^client_type{S} op->client_type = IVAL; |
1052 | ^client_type{S} op->client_type = IVAL; |
1053 | ^body_{A} set_body_info(op, yytext); |
1053 | ^body_{A} set_body_info(op, yytext); |
1054 | ^duration{S} op->duration = IVAL; |
1054 | ^duration{S} op->duration = IVAL; |
1055 | ^range{S} op->range = IVAL; |
1055 | ^range{S} op->range = IVAL; |
1056 | ^range_modifier{S} op->range_modifier = IVAL; |
1056 | ^range_modifier{S} op->range_modifier = IVAL; |
1057 | ^dam_modifier{S} op->dam_modifier = IVAL; |
1057 | ^dam_modifier{S} op->dam_modifier = IVAL; |
1058 | ^duration_modifier{S} op->duration_modifier = IVAL; |
1058 | ^duration_modifier{S} op->duration_modifier = IVAL; |
1059 | ^is_buildable{S} SET_OR_CLEAR_FLAG( op, FLAG_IS_BUILDABLE, IVAL ); |
1059 | ^is_buildable{S} SET_OR_CLEAR_FLAG( op, FLAG_IS_BUILDABLE, IVAL ); |
1060 | |
1060 | |
1061 | ^event_apply{S} { |
1061 | ^event_ { |
1062 | char *yv=yval(); |
1062 | LOG (llevError, "stray event_* in map file, skipping."); |
1063 | if (*yv=='\0') |
|
|
1064 | LOG(llevError,"Event (apply) without val\n"); |
|
|
1065 | else |
|
|
1066 | insert_event(op,EVENT_APPLY,yv,NULL,NULL); |
|
|
1067 | } |
1063 | } |
1068 | |
1064 | |
1069 | ^event_apply_plugin{S} { |
|
|
1070 | char *yv=yval(); |
|
|
1071 | if (*yv=='\0') |
|
|
1072 | LOG(llevError,"Event (apply) without plugin\n"); |
|
|
1073 | else |
|
|
1074 | insert_event(op,EVENT_APPLY,NULL,yv,NULL); |
|
|
1075 | } |
|
|
1076 | |
|
|
1077 | ^event_apply_options{S} { |
|
|
1078 | char *yv=yval(); |
|
|
1079 | if (*yv=='\0') |
|
|
1080 | LOG(llevError,"Event (apply) without options\n"); |
|
|
1081 | else |
|
|
1082 | insert_event(op,EVENT_APPLY,NULL,NULL,yv); |
|
|
1083 | } |
|
|
1084 | |
|
|
1085 | ^event_attack{S} { |
|
|
1086 | char *yv=yval(); |
|
|
1087 | if (*yv=='\0') |
|
|
1088 | LOG(llevError,"Event (attack) without val\n"); |
|
|
1089 | else |
|
|
1090 | insert_event(op,EVENT_ATTACK,yv,NULL,NULL); |
|
|
1091 | } |
|
|
1092 | |
|
|
1093 | ^event_attack_plugin{S} { |
|
|
1094 | char *yv=yval(); |
|
|
1095 | if (*yv=='\0') |
|
|
1096 | LOG(llevError,"Event (attack) without plugin\n"); |
|
|
1097 | else |
|
|
1098 | insert_event(op,EVENT_ATTACK,NULL,yv,NULL); |
|
|
1099 | } |
|
|
1100 | |
|
|
1101 | ^event_attack_options{S} { |
|
|
1102 | char *yv=yval(); |
|
|
1103 | if (*yv=='\0') |
|
|
1104 | LOG(llevError,"Event (attack) without options\n"); |
|
|
1105 | else |
|
|
1106 | insert_event(op,EVENT_ATTACK,NULL,NULL,yv); |
|
|
1107 | } |
|
|
1108 | ^event_death{S} { |
|
|
1109 | char *yv=yval(); |
|
|
1110 | if (*yv=='\0') |
|
|
1111 | LOG(llevError,"Event (death) without val\n"); |
|
|
1112 | else |
|
|
1113 | insert_event(op,EVENT_DEATH,yv,NULL,NULL); |
|
|
1114 | } |
|
|
1115 | |
|
|
1116 | ^event_death_plugin{S} { |
|
|
1117 | char *yv=yval(); |
|
|
1118 | if (*yv=='\0') |
|
|
1119 | LOG(llevError,"Event (death) without plugin\n"); |
|
|
1120 | else |
|
|
1121 | insert_event(op,EVENT_DEATH,NULL,yv,NULL); |
|
|
1122 | } |
|
|
1123 | |
|
|
1124 | ^event_death_options{S} { |
|
|
1125 | char *yv=yval(); |
|
|
1126 | if (*yv=='\0') |
|
|
1127 | LOG(llevError,"Event (death) without options\n"); |
|
|
1128 | else |
|
|
1129 | insert_event(op,EVENT_DEATH,NULL,NULL,yv); |
|
|
1130 | } |
|
|
1131 | ^event_drop{S} { |
|
|
1132 | char *yv=yval(); |
|
|
1133 | if (*yv=='\0') |
|
|
1134 | LOG(llevError,"Event (drop) without val\n"); |
|
|
1135 | else |
|
|
1136 | insert_event(op,EVENT_DROP,yv,NULL,NULL); |
|
|
1137 | } |
|
|
1138 | |
|
|
1139 | ^event_drop_plugin{S} { |
|
|
1140 | char *yv=yval(); |
|
|
1141 | if (*yv=='\0') |
|
|
1142 | LOG(llevError,"Event (drop) without plugin\n"); |
|
|
1143 | else |
|
|
1144 | insert_event(op,EVENT_DROP,NULL,yv,NULL); |
|
|
1145 | } |
|
|
1146 | |
|
|
1147 | ^event_drop_options{S} { |
|
|
1148 | char *yv=yval(); |
|
|
1149 | if (*yv=='\0') |
|
|
1150 | LOG(llevError,"Event (drop) without options\n"); |
|
|
1151 | else |
|
|
1152 | insert_event(op,EVENT_DROP,NULL,NULL,yv); |
|
|
1153 | } |
|
|
1154 | ^event_pickup{S} { |
|
|
1155 | char *yv=yval(); |
|
|
1156 | if (*yv=='\0') |
|
|
1157 | LOG(llevError,"Event (pickup) without val\n"); |
|
|
1158 | else |
|
|
1159 | insert_event(op,EVENT_PICKUP,yv,NULL,NULL); |
|
|
1160 | } |
|
|
1161 | |
|
|
1162 | ^event_pickup_plugin{S} { |
|
|
1163 | char *yv=yval(); |
|
|
1164 | if (*yv=='\0') |
|
|
1165 | LOG(llevError,"Event (pickup) without plugin\n"); |
|
|
1166 | else |
|
|
1167 | insert_event(op,EVENT_PICKUP,NULL,yv,NULL); |
|
|
1168 | } |
|
|
1169 | |
|
|
1170 | ^event_pickup_options{S} { |
|
|
1171 | char *yv=yval(); |
|
|
1172 | if (*yv=='\0') |
|
|
1173 | LOG(llevError,"Event (pickup) without options\n"); |
|
|
1174 | else |
|
|
1175 | insert_event(op,EVENT_PICKUP,NULL,NULL,yv); |
|
|
1176 | } |
|
|
1177 | ^event_say{S} { |
|
|
1178 | char *yv=yval(); |
|
|
1179 | if (*yv=='\0') |
|
|
1180 | LOG(llevError,"Event (say) without val\n"); |
|
|
1181 | else |
|
|
1182 | insert_event(op,EVENT_SAY,yv,NULL,NULL); |
|
|
1183 | } |
|
|
1184 | |
|
|
1185 | ^event_say_plugin{S} { |
|
|
1186 | char *yv=yval(); |
|
|
1187 | if (*yv=='\0') |
|
|
1188 | LOG(llevError,"Event (say) without plugin\n"); |
|
|
1189 | else |
|
|
1190 | insert_event(op,EVENT_SAY,NULL,yv,NULL); |
|
|
1191 | } |
|
|
1192 | |
|
|
1193 | ^event_say_options{S} { |
|
|
1194 | char *yv=yval(); |
|
|
1195 | if (*yv=='\0') |
|
|
1196 | LOG(llevError,"Event (say) without options\n"); |
|
|
1197 | else |
|
|
1198 | insert_event(op,EVENT_SAY,NULL,NULL,yv); |
|
|
1199 | } |
|
|
1200 | ^event_stop{S} { |
|
|
1201 | char *yv=yval(); |
|
|
1202 | if (*yv=='\0') |
|
|
1203 | LOG(llevError,"Event (stop) without val\n"); |
|
|
1204 | else |
|
|
1205 | insert_event(op,EVENT_STOP,yv,NULL,NULL); |
|
|
1206 | } |
|
|
1207 | |
|
|
1208 | ^event_stop_plugin{S} { |
|
|
1209 | char *yv=yval(); |
|
|
1210 | if (*yv=='\0') |
|
|
1211 | LOG(llevError,"Event (stop) without plugin\n"); |
|
|
1212 | else |
|
|
1213 | insert_event(op,EVENT_STOP,NULL,yv,NULL); |
|
|
1214 | } |
|
|
1215 | |
|
|
1216 | ^event_stop_options{S} { |
|
|
1217 | char *yv=yval(); |
|
|
1218 | if (*yv=='\0') |
|
|
1219 | LOG(llevError,"Event (stop) without options\n"); |
|
|
1220 | else |
|
|
1221 | insert_event(op,EVENT_STOP,NULL,NULL,yv); |
|
|
1222 | } |
|
|
1223 | ^event_time{S} { |
|
|
1224 | char *yv=yval(); |
|
|
1225 | if (*yv=='\0') |
|
|
1226 | LOG(llevError,"Event (time) without val\n"); |
|
|
1227 | else |
|
|
1228 | insert_event(op,EVENT_TIME,yv,NULL,NULL); |
|
|
1229 | } |
|
|
1230 | |
|
|
1231 | ^event_time_plugin{S} { |
|
|
1232 | char *yv=yval(); |
|
|
1233 | if (*yv=='\0') |
|
|
1234 | LOG(llevError,"Event (time) without plugin\n"); |
|
|
1235 | else |
|
|
1236 | insert_event(op,EVENT_TIME,NULL,yv,NULL); |
|
|
1237 | } |
|
|
1238 | |
|
|
1239 | ^event_time_options{S} { |
|
|
1240 | char *yv=yval(); |
|
|
1241 | if (*yv=='\0') |
|
|
1242 | LOG(llevError,"Event (time) without options\n"); |
|
|
1243 | else |
|
|
1244 | insert_event(op,EVENT_TIME,NULL,NULL,yv); |
|
|
1245 | } |
|
|
1246 | ^event_throw{S} { |
|
|
1247 | char *yv=yval(); |
|
|
1248 | if (*yv=='\0') |
|
|
1249 | LOG(llevError,"Event (throw) without val\n"); |
|
|
1250 | else |
|
|
1251 | insert_event(op,EVENT_THROW,yv,NULL,NULL); |
|
|
1252 | } |
|
|
1253 | |
|
|
1254 | ^event_throw_plugin{S} { |
|
|
1255 | char *yv=yval(); |
|
|
1256 | if (*yv=='\0') |
|
|
1257 | LOG(llevError,"Event (throw) without plugin\n"); |
|
|
1258 | else |
|
|
1259 | insert_event(op,EVENT_THROW,NULL,yv,NULL); |
|
|
1260 | } |
|
|
1261 | |
|
|
1262 | ^event_throw_options{S} { |
|
|
1263 | char *yv=yval(); |
|
|
1264 | if (*yv=='\0') |
|
|
1265 | LOG(llevError,"Event (apply) without options\n"); |
|
|
1266 | else |
|
|
1267 | insert_event(op,EVENT_THROW,NULL,NULL,yv); |
|
|
1268 | } |
|
|
1269 | ^event_trigger{S} { |
|
|
1270 | char *yv=yval(); |
|
|
1271 | if (*yv=='\0') |
|
|
1272 | LOG(llevError,"Event (trigger) without val\n"); |
|
|
1273 | else |
|
|
1274 | insert_event(op,EVENT_TRIGGER,yv,NULL,NULL); |
|
|
1275 | } |
|
|
1276 | |
|
|
1277 | ^event_trigger_plugin{S} { |
|
|
1278 | char *yv=yval(); |
|
|
1279 | if (*yv=='\0') |
|
|
1280 | LOG(llevError,"Event (trigger) without plugin\n"); |
|
|
1281 | else |
|
|
1282 | insert_event(op,EVENT_TRIGGER,NULL,yv,NULL); |
|
|
1283 | } |
|
|
1284 | |
|
|
1285 | ^event_trigger_options{S} { |
|
|
1286 | char *yv=yval(); |
|
|
1287 | if (*yv=='\0') |
|
|
1288 | LOG(llevError,"Event (trigger) without options\n"); |
|
|
1289 | else |
|
|
1290 | insert_event(op,EVENT_TRIGGER,NULL,NULL,yv); |
|
|
1291 | } |
|
|
1292 | ^event_close{S} { |
|
|
1293 | char *yv=yval(); |
|
|
1294 | if (*yv=='\0') |
|
|
1295 | LOG(llevError,"Event (close) without val\n"); |
|
|
1296 | else |
|
|
1297 | insert_event(op,EVENT_CLOSE,yv,NULL,NULL); |
|
|
1298 | } |
|
|
1299 | |
|
|
1300 | ^event_close_plugin{S} { |
|
|
1301 | char *yv=yval(); |
|
|
1302 | if (*yv=='\0') |
|
|
1303 | LOG(llevError,"Event (close) without plugin\n"); |
|
|
1304 | else |
|
|
1305 | insert_event(op,EVENT_CLOSE,NULL,yv,NULL); |
|
|
1306 | } |
|
|
1307 | |
|
|
1308 | ^event_close_options{S} { |
|
|
1309 | char *yv=yval(); |
|
|
1310 | if (*yv=='\0') |
|
|
1311 | LOG(llevError,"Event (close) without options\n"); |
|
|
1312 | else |
|
|
1313 | insert_event(op,EVENT_CLOSE,NULL,NULL,yv); |
|
|
1314 | } |
|
|
1315 | ^event_timer{S} { |
|
|
1316 | char *yv=yval(); |
|
|
1317 | if (*yv=='\0') |
|
|
1318 | LOG(llevError,"Event (timer) without val\n"); |
|
|
1319 | else |
|
|
1320 | insert_event(op,EVENT_TIMER,yv,NULL,NULL); |
|
|
1321 | } |
|
|
1322 | |
|
|
1323 | ^event_timer_plugin{S} { |
|
|
1324 | char *yv=yval(); |
|
|
1325 | if (*yv=='\0') |
|
|
1326 | LOG(llevError,"Event (timer) without plugin\n"); |
|
|
1327 | else |
|
|
1328 | insert_event(op,EVENT_TIMER,NULL,yv,NULL); |
|
|
1329 | } |
|
|
1330 | |
|
|
1331 | ^event_timer_options{S} { |
|
|
1332 | char *yv=yval(); |
|
|
1333 | if (*yv=='\0') |
|
|
1334 | LOG(llevError,"Event (timer) without options\n"); |
|
|
1335 | else |
|
|
1336 | insert_event(op,EVENT_TIMER,NULL,NULL,yv); |
|
|
1337 | } |
|
|
1338 | |
|
|
1339 | ^current_weapon_script{S} { char *yv=yval(); |
|
|
1340 | |
|
|
1341 | if (*yv=='\0') LOG(llevError,"Script (current weapon) without val\n"); |
|
|
1342 | else |
|
|
1343 | { |
|
|
1344 | FREE_AND_COPY(op->current_weapon_script, yv); |
|
|
1345 | }; |
|
|
1346 | } |
|
|
1347 | |
|
|
1348 | <*>(^{WS}$)|\n {/* ignore empty lines, newlines we don't do above */} |
1065 | <*>(^{WS}$)|\n {/* ignore empty lines, newlines we don't do above */} |
1349 | #.*\n {} |
1066 | #.*\n {} |
1350 | |
1067 | |
1351 | <<EOF>> {/* If we got an error, return the error. Otherwise, return that we got EOF */ |
1068 | <<EOF>> {/* If we got an error, return the error. Otherwise, return that we got EOF */ |
1352 | if (lex_error!=0) return lex_error; else return LL_EOF;} |
1069 | if (lex_error!=0) return lex_error; else return LL_EOF;} |
1353 | .* { add_key_value(op); } |
1070 | .* { add_key_value(op); } |
1354 | %% |
1071 | %% |
1355 | |
1072 | |
1356 | |
1073 | |
1357 | int yyerror(char *s) |
1074 | int yyerror(char *s) |
1358 | { |
1075 | { |
… | |
… | |
1372 | static char *em=""; |
1089 | static char *em=""; |
1373 | char *cp,*end; |
1090 | char *cp,*end; |
1374 | |
1091 | |
1375 | /* First skip over start of line, like animation or name */ |
1092 | /* First skip over start of line, like animation or name */ |
1376 | for (cp=yytext; *cp!=' '; cp++) { |
1093 | for (cp=yytext; *cp!=' '; cp++) { |
1377 | if (*cp=='\0') { |
1094 | if (*cp=='\0') { |
1378 | return em; |
1095 | return em; |
1379 | } |
1096 | } |
1380 | } |
1097 | } |
1381 | |
1098 | |
1382 | /* Skip over whitespace */ |
1099 | /* Skip over whitespace */ |
1383 | for (; *cp==' '; cp++) { |
1100 | for (; *cp==' '; cp++) { |
1384 | if (*cp=='\0') { |
1101 | if (*cp=='\0') { |
1385 | return em; |
1102 | return em; |
1386 | } |
1103 | } |
1387 | } |
1104 | } |
1388 | /* Got last character before null and strip |
1105 | /* Got last character before null and strip |
1389 | * off tailing whitespace |
1106 | * off tailing whitespace |
1390 | */ |
1107 | */ |
1391 | for (end=cp+strlen(cp)-1; *end==' '; end--) { |
1108 | for (end=cp+strlen(cp)-1; *end==' '; end--) { |
1392 | if (end==cp) return em; |
1109 | if (end==cp) return em; |
1393 | *end='\0'; |
1110 | *end='\0'; |
1394 | } |
1111 | } |
1395 | return cp; |
1112 | return cp; |
1396 | } |
1113 | } |
1397 | |
1114 | |
1398 | |
1115 | |
… | |
… | |
1402 | * until the string "end" is reached, or the end of the file. |
1119 | * until the string "end" is reached, or the end of the file. |
1403 | * |
1120 | * |
1404 | * bufstat is used to determine various file attributes: |
1121 | * bufstat is used to determine various file attributes: |
1405 | * LO_REPATE (0): We are reading from the same buffer as the last call. |
1122 | * LO_REPATE (0): We are reading from the same buffer as the last call. |
1406 | * LO_LINEMODE (1): file that is being read from is multi purpose (ie, other functions |
1123 | * LO_LINEMODE (1): file that is being read from is multi purpose (ie, other functions |
1407 | * will also be reading from this (treasure file, artifacts.) |
1124 | * will also be reading from this (treasure file, artifacts.) |
1408 | * LO_NEWFILE (2): This is the first read from a particular file, so the buffers should |
1125 | * LO_NEWFILE (2): This is the first read from a particular file, so the buffers should |
1409 | * be reset. |
1126 | * be reset. |
1410 | * LO_NOREAD (3): Reset the buffers, but don't read from it. (op can be null) |
1127 | * LO_NOREAD (3): Reset the buffers, but don't read from it. (op can be null) |
1411 | * |
1128 | * |
1412 | */ |
1129 | */ |
1413 | |
1130 | |
1414 | int load_object(object_thawer &fp, object *op, int bufstate, int map_flags) { |
1131 | int load_object(object_thawer &fp, object *op, int bufstate, int map_flags) { |
… | |
… | |
1416 | char inbuf[MAX_BUF]; |
1133 | char inbuf[MAX_BUF]; |
1417 | |
1134 | |
1418 | strcpy(msgbuf, ""); |
1135 | strcpy(msgbuf, ""); |
1419 | strcpy(lorebuf, ""); |
1136 | strcpy(lorebuf, ""); |
1420 | if (bufstate==LO_NEWFILE || bufstate==LO_NOREAD) { |
1137 | if (bufstate==LO_NEWFILE || bufstate==LO_NOREAD) { |
1421 | /* LOG(llevDebug,"Switching lex buffers\n");*/ |
1138 | /* LOG(llevDebug,"Switching lex buffers\n");*/ |
1422 | yy_delete_buffer(YY_CURRENT_BUFFER); |
1139 | yy_delete_buffer(YY_CURRENT_BUFFER); |
1423 | yy_switch_to_buffer(yy_create_buffer(fp, YY_BUF_SIZE)); |
1140 | yy_switch_to_buffer(yy_create_buffer(fp, YY_BUF_SIZE)); |
1424 | if (bufstate==LO_NOREAD) return LL_NORMAL; |
1141 | if (bufstate==LO_NOREAD) return LL_NORMAL; |
1425 | } |
1142 | } |
1426 | if (bufstate==LO_LINEMODE) { |
1143 | if (bufstate==LO_LINEMODE) { |
1427 | YY_BUFFER_STATE yybufstate; |
1144 | YY_BUFFER_STATE yybufstate; |
1428 | while (fgets(inbuf, MAX_BUF-3, fp)) { |
1145 | while (fgets(inbuf, MAX_BUF-3, fp)) { |
1429 | yybufstate=yy_scan_string(inbuf); |
1146 | yybufstate=yy_scan_string(inbuf); |
1430 | retval=lex_load(op, fp, map_flags); |
1147 | retval=lex_load(op, fp, map_flags); |
1431 | yy_delete_buffer(yybufstate); |
1148 | yy_delete_buffer(yybufstate); |
1432 | if (retval==LL_NORMAL) return retval; |
1149 | if (retval==LL_NORMAL) return retval; |
1433 | } |
1150 | } |
1434 | LOG(llevDebug,"Got eof while scanning strings\n"); |
1151 | LOG(llevDebug,"Got eof while scanning strings\n"); |
1435 | return LL_EOF; |
1152 | return LL_EOF; |
1436 | } |
1153 | } |
1437 | |
1154 | |
1438 | retval=lex_load(op, fp, map_flags); |
1155 | retval=lex_load(op, fp, map_flags); |
1439 | if (op->current_weapon_script != NULL) |
|
|
1440 | { |
|
|
1441 | op->current_weapon = find_best_weapon_used_match(op, op->current_weapon_script); |
|
|
1442 | LOG(llevDebug, "CurrentWeapon Loaded !\n"); |
|
|
1443 | }; |
|
|
1444 | |
1156 | |
1445 | /* LOG(llevDebug," load completed, object=%s\n",op->name);*/ |
1157 | /* LOG(llevDebug," load completed, object=%s\n",op->name);*/ |
1446 | return retval; |
1158 | return retval; |
1447 | } |
1159 | } |
1448 | |
1160 | |
… | |
… | |
1486 | "is_animated", NULL /* slow_move */, |
1198 | "is_animated", NULL /* slow_move */, |
1487 | NULL /* flying */, "monster", "friendly", "generator", |
1199 | NULL /* flying */, "monster", "friendly", "generator", |
1488 | "is_thrown", "auto_apply", "treasure", "player sold", /* 20 */ |
1200 | "is_thrown", "auto_apply", "treasure", "player sold", /* 20 */ |
1489 | "see_invisible", "can_roll", "overlay_floor", |
1201 | "see_invisible", "can_roll", "overlay_floor", |
1490 | "is_turnable", NULL /* walk_off */, NULL /* fly_on */, |
1202 | "is_turnable", NULL /* walk_off */, NULL /* fly_on */, |
1491 | NULL /*fly_off*/, "is_used_up", "identified", "reflecting", /* 30 */ |
1203 | NULL /*fly_off*/, "is_used_up", "identified", "reflecting", /* 30 */ |
1492 | "changing", "splitting", "hitback", "startequip", |
1204 | "changing", "splitting", "hitback", "startequip", |
1493 | "blocksview", "undead", "scared", "unaggressive", |
1205 | "blocksview", "undead", "scared", "unaggressive", |
1494 | "reflect_missile", "reflect_spell", /* 40 */ |
1206 | "reflect_missile", "reflect_spell", /* 40 */ |
1495 | "no_magic", "no_fix_player", "is_lightable", "tear_down", |
1207 | "no_magic", "no_fix_player", "is_lightable", "tear_down", |
1496 | "run_away", NULL /*pass_thru */, NULL /*can_pass_thru*/, |
1208 | "run_away", NULL /*pass_thru */, NULL /*can_pass_thru*/, |
1497 | "pick_up", "unique", "no_drop", /* 50 */ |
1209 | "pick_up", "unique", "no_drop", /* 50 */ |
1498 | NULL /* wizcast*/, "can_cast_spell", "can_use_scroll", "can_use_range", |
1210 | NULL /* wizcast*/, "can_cast_spell", "can_use_scroll", "can_use_range", |
1499 | "can_use_bow", "can_use_armour", "can_use_weapon", |
1211 | "can_use_bow", "can_use_armour", "can_use_weapon", |
1500 | "can_use_ring", "has_ready_range", "has_ready_bow", /* 60 */ |
1212 | "can_use_ring", "has_ready_range", "has_ready_bow", /* 60 */ |
1501 | "xrays", NULL, "is_floor", "lifesave", "no_strength", "sleep", |
1213 | "xrays", NULL, "is_floor", "lifesave", "no_strength", "sleep", |
1502 | "stand_still", "random_move", "only_attack", "confused", /* 70 */ |
1214 | "stand_still", "random_move", "only_attack", "confused", /* 70 */ |
… | |
… | |
1505 | "can_use_skill", "been_applied", /* 80 */ |
1217 | "can_use_skill", "been_applied", /* 80 */ |
1506 | "has_ready_scroll", "can_use_rod", NULL, |
1218 | "has_ready_scroll", "can_use_rod", NULL, |
1507 | "can_use_horn", "make_invisible", "inv_locked", "is_wooded", |
1219 | "can_use_horn", "make_invisible", "inv_locked", "is_wooded", |
1508 | "is_hilly", "has_ready_skill", "has_ready_weapon", /* 90 */ |
1220 | "is_hilly", "has_ready_skill", "has_ready_weapon", /* 90 */ |
1509 | "no_skill_ident", "is_blind", "can_see_in_dark", "is_cauldron", |
1221 | "no_skill_ident", "is_blind", "can_see_in_dark", "is_cauldron", |
1510 | "is_dust", "no_steal", "one_hit", NULL, "berserk", "neutral", /* 100 */ |
1222 | "is_dust", "no_steal", "one_hit", NULL, "berserk", "neutral", /* 100 */ |
1511 | "no_attack", "no_damage", NULL, NULL, "activate_on_push", |
1223 | "no_attack", "no_damage", NULL, NULL, "activate_on_push", |
1512 | "activate_on_release", "is_water", "use_content_on_gen", NULL, "is_buildable", /* 110 */ |
1224 | "activate_on_release", "is_water", "use_content_on_gen", NULL, "is_buildable", /* 110 */ |
1513 | NULL |
1225 | NULL |
1514 | }; |
1226 | }; |
1515 | |
1227 | |
… | |
… | |
1520 | */ |
1232 | */ |
1521 | |
1233 | |
1522 | void init_vars() { |
1234 | void init_vars() { |
1523 | } |
1235 | } |
1524 | |
1236 | |
1525 | /*For get_ob_diff speed reason*/ |
|
|
1526 | typedef struct { |
|
|
1527 | const char *name; |
|
|
1528 | int length; |
|
|
1529 | }genericname; |
|
|
1530 | static genericname evtnames[13]= |
|
|
1531 | { |
|
|
1532 | {"event_none ",11}, |
|
|
1533 | {"event_apply ",12}, |
|
|
1534 | {"event_attack ",13}, |
|
|
1535 | {"event_death ",12}, |
|
|
1536 | {"event_drop ",11}, |
|
|
1537 | {"event_pickup ",13}, |
|
|
1538 | {"event_say ",10}, |
|
|
1539 | {"event_stop ",11}, |
|
|
1540 | {"event_time ",11}, |
|
|
1541 | {"event_throw ",12}, |
|
|
1542 | {"event_trigger ",14}, |
|
|
1543 | {"event_close ",12}, |
|
|
1544 | {"event_timer ",12} |
|
|
1545 | } ; |
|
|
1546 | |
|
|
1547 | static genericname plgnames[13]= |
|
|
1548 | { |
|
|
1549 | {"event_none_plugin ",18}, |
|
|
1550 | {"event_apply_plugin ",19}, |
|
|
1551 | {"event_attack_plugin ",20}, |
|
|
1552 | {"event_death_plugin ",19}, |
|
|
1553 | {"event_drop_plugin ",18}, |
|
|
1554 | {"event_pickup_plugin ",20}, |
|
|
1555 | {"event_say_plugin ",17}, |
|
|
1556 | {"event_stop_plugin ",18}, |
|
|
1557 | {"event_time_plugin ",18}, |
|
|
1558 | {"event_throw_plugin ",19}, |
|
|
1559 | {"event_trigger_plugin ",21}, |
|
|
1560 | {"event_close_plugin ",19}, |
|
|
1561 | {"event_timer_plugin ",19} |
|
|
1562 | }; |
|
|
1563 | |
|
|
1564 | static genericname plgoptions[13]= |
|
|
1565 | { |
|
|
1566 | {"event_none_options ",19}, |
|
|
1567 | {"event_apply_options ",20}, |
|
|
1568 | {"event_attack_options ",21}, |
|
|
1569 | {"event_death_options ",20}, |
|
|
1570 | {"event_drop_options ",19}, |
|
|
1571 | {"event_pickup_options ",21}, |
|
|
1572 | {"event_say_options ",18}, |
|
|
1573 | {"event_stop_options ",19}, |
|
|
1574 | {"event_time_options ",19}, |
|
|
1575 | {"event_throw_options ",20}, |
|
|
1576 | {"event_trigger_options ",22}, |
|
|
1577 | {"event_close_options ",20}, |
|
|
1578 | {"event_timer_options ",20} |
|
|
1579 | }; |
|
|
1580 | |
|
|
1581 | /* This returns a string of the integer movement type */ |
1237 | /* This returns a string of the integer movement type */ |
1582 | static char* get_string_move_type(MoveType mt) |
1238 | static char* get_string_move_type(MoveType mt) |
1583 | { |
1239 | { |
1584 | static char retbuf[MAX_BUF], retbuf_all[MAX_BUF]; |
1240 | static char retbuf[MAX_BUF], retbuf_all[MAX_BUF]; |
1585 | int i, all_count=0, count; |
1241 | int i, all_count=0, count; |
1586 | |
1242 | |
1587 | strcpy(retbuf,""); |
1243 | strcpy(retbuf,""); |
1588 | strcpy(retbuf_all," all"); |
1244 | strcpy(retbuf_all," all"); |
1589 | |
1245 | |
1590 | /* Quick check, and probably fairly common */ |
1246 | /* Quick check, and probably fairly common */ |
1591 | if (mt == MOVE_ALL) return retbuf_all+1; |
1247 | if (mt == MOVE_ALL) return retbuf_all+1; |
1592 | if (mt == 0) { |
1248 | if (mt == 0) { |
1593 | strcpy(retbuf,"0"); |
1249 | strcpy(retbuf,"0"); |
1594 | return retbuf; |
1250 | return retbuf; |
1595 | } |
1251 | } |
1596 | |
1252 | |
1597 | /* We basically slide the bits down. Why look at MOVE_ALL? |
1253 | /* We basically slide the bits down. Why look at MOVE_ALL? |
1598 | * because we may want to return a string like 'all -swim', |
1254 | * because we may want to return a string like 'all -swim', |
1599 | * and if we just looked at mt, we couldn't get that. |
1255 | * and if we just looked at mt, we couldn't get that. |
1600 | */ |
1256 | */ |
1601 | for (i=MOVE_ALL, count=0; i!=0; i >>= 1, count++) { |
1257 | for (i=MOVE_ALL, count=0; i!=0; i >>= 1, count++) { |
1602 | if (mt & (1<<count)) { |
1258 | if (mt & (1<<count)) { |
1603 | strcat(retbuf, " "); |
1259 | strcat(retbuf, " "); |
1604 | strcat(retbuf, move_name[count]); |
1260 | strcat(retbuf, move_name[count]); |
1605 | } else { |
1261 | } else { |
1606 | strcat(retbuf_all, " -"); |
1262 | strcat(retbuf_all, " -"); |
1607 | strcat(retbuf_all, move_name[count]); |
1263 | strcat(retbuf_all, move_name[count]); |
1608 | all_count++; |
1264 | all_count++; |
1609 | } |
1265 | } |
1610 | } |
1266 | } |
1611 | /* Basically, if there is a single negation, return it, eg |
1267 | /* Basically, if there is a single negation, return it, eg |
1612 | * 'all -swim'. But more than that, just return the |
1268 | * 'all -swim'. But more than that, just return the |
1613 | * enumerated values. It doesn't make sense to return |
1269 | * enumerated values. It doesn't make sense to return |
1614 | * 'all -walk -fly_low' - it is shorter to return 'fly_high swim' |
1270 | * 'all -walk -fly_low' - it is shorter to return 'fly_high swim' |
… | |
… | |
1628 | * we should use strlen entryname instead. Any smart compiler should |
1284 | * we should use strlen entryname instead. Any smart compiler should |
1629 | * optimize that out. |
1285 | * optimize that out. |
1630 | */ |
1286 | */ |
1631 | |
1287 | |
1632 | |
1288 | |
1633 | /*static int eol_size=strlen("\n");*/ |
|
|
1634 | static int eol_size=sizeof("\n")-1; /*Substract 1 to suppress terminal 0*/ |
|
|
1635 | #define ADD_STRINGLINE_ENTRY(buf__,entryname__,entryvalue__,entrysize__){\ |
1289 | #define ADD_STRINGLINE_ENTRY(buf__,entryname__,entryvalue__,entrysize__){\ |
1636 | FAST_STRNCAT(buf__,entryname__,entrysize__);\ |
1290 | FAST_STRNCAT(buf__,entryname__,entrysize__);\ |
1637 | FAST_STRCAT(buf__,entryvalue__);\ |
1291 | FAST_STRCAT(buf__,entryvalue__);\ |
1638 | FAST_STRNCAT(buf__,"\n",eol_size);} |
1292 | FAST_STRNCAT(buf__,"\n",1);} |
1639 | #define FAST_SAVE_LONG(buf__,entryname__,entryvalue__,entrysize__) \ |
1293 | #define FAST_SAVE_LONG(buf__,entryname__,entryvalue__,entrysize__) \ |
1640 | ADD_STRINGLINE_ENTRY(buf__,entryname__,ltostr10(entryvalue__),entrysize__) |
1294 | ADD_STRINGLINE_ENTRY(buf__,entryname__,ltostr10(entryvalue__),entrysize__) |
1641 | #define FAST_SAVE_DOUBLE(buf__,entryname__,entryvalue__,entrysize__) \ |
1295 | #define FAST_SAVE_DOUBLE(buf__,entryname__,entryvalue__,entrysize__) \ |
1642 | ADD_STRINGLINE_ENTRY(buf__,entryname__,doubletostr10(entryvalue__),entrysize__) |
1296 | ADD_STRINGLINE_ENTRY(buf__,entryname__,doubletostr10(entryvalue__),entrysize__) |
1643 | |
1297 | |
1644 | |
1298 | |
1645 | |
1299 | |
1646 | char *get_ob_diff(object *op,object *op2) {/* I plan to optimize this heavily */ |
1300 | // compare *op against *tmp and output differences |
1647 | |
1301 | void |
1648 | /* Too late, have done it already :P |
1302 | put (object_freezer &f, object *op, object *tmp) |
1649 | * Tchize |
1303 | { |
1650 | */ |
|
|
1651 | |
|
|
1652 | /* |
|
|
1653 | * A bit of explantion on strings handling in this function: |
|
|
1654 | * buf is never null terminated until the end. So |
|
|
1655 | * works only with buf2 and fastbuf. What concern fastbuf, |
|
|
1656 | * use ONLY through the FAST macros. Classical C string handling |
|
|
1657 | * functions will fail since it is a pointer to the end of the |
|
|
1658 | * string. |
|
|
1659 | * NEVER touch buf between PREPARE_FASTCAT(buf) and |
|
|
1660 | * FINISH_FASTCAT(buf) |
|
|
1661 | */ |
|
|
1662 | static int already_run = 0; |
|
|
1663 | static int flag_lens[NUM_FLAGS]; |
|
|
1664 | char buf2[4096]; // / was HUFE_BUF, which was hugely incorrect, as is this value, but much less so |
|
|
1665 | static char buf[128*1024]; // < the assumption is that every object always fits. fixing this bug, however |
|
|
1666 | char* fastbuf; // \ requires a large rewrite of the code, so its left to the next total rewrite. |
|
|
1667 | int tmp; |
|
|
1668 | int i; |
1304 | int i; |
1669 | event *etmp; |
|
|
1670 | event *etmp2; |
|
|
1671 | key_value * my_field; |
|
|
1672 | key_value * arch_field; |
|
|
1673 | |
|
|
1674 | /*first init this function if first call*/ |
|
|
1675 | if (!already_run){ |
|
|
1676 | for (i=0;i<NUM_FLAGS;i++) |
|
|
1677 | flag_lens[i]=flag_names[i]?strlen(flag_names[i]):0; /* some flags may be null? :/*/ |
|
|
1678 | already_run=1; |
|
|
1679 | } |
|
|
1680 | buf[0]='\0'; |
|
|
1681 | fastbuf=PREPARE_FASTCAT(buf); |
|
|
1682 | |
1305 | |
1683 | /* This saves the key/value lists. We do it first so that any |
1306 | /* This saves the key/value lists. We do it first so that any |
1684 | * keys that match field names will be overwritten by the loader. |
1307 | * keys that match field names will be overwritten by the loader. |
1685 | */ |
1308 | */ |
1686 | for (my_field = op->key_values; my_field != NULL; my_field = my_field->next) { |
1309 | for (key_value *my_field = op->key_values; my_field != NULL; my_field = my_field->next) |
|
|
1310 | { |
1687 | /* Find the field in the opposing member. */ |
1311 | /* Find the field in the opposing member. */ |
1688 | arch_field = get_ob_key_link(op2, my_field->key); |
1312 | key_value *arch_field = get_ob_key_link (tmp, my_field->key); |
1689 | |
1313 | |
1690 | /* If there's no partnering field, or it's got a different value, save our field. */ |
1314 | /* If there's no partnering field, or it's got a different value, save our field. */ |
1691 | if (arch_field == NULL || my_field->value != arch_field->value) { |
1315 | if (arch_field == NULL || my_field->value != arch_field->value) |
1692 | FAST_STRCAT(fastbuf, my_field->key); |
1316 | f.put (my_field->key, my_field->value); |
1693 | FAST_STRNCAT(fastbuf, " ", 1); |
|
|
1694 | /* If this is null, then saving it as a space should |
|
|
1695 | * cause it to be null again. |
|
|
1696 | */ |
|
|
1697 | if (my_field->value) FAST_STRCAT(fastbuf, my_field->value); |
|
|
1698 | FAST_STRNCAT(fastbuf, "\n", eol_size); |
|
|
1699 | } |
1317 | } |
1700 | } |
1318 | |
1701 | /* We don't need to worry about the arch's extra fields - they |
1319 | /* We don't need to worry about the arch's extra fields - they |
1702 | * will get taken care of the copy_object function. |
1320 | * will get taken care of the copy_object function. |
1703 | */ |
1321 | */ |
1704 | |
1322 | |
|
|
1323 | # define CMP_OUT(v) if (op->v != tmp->v) f.put (KW_ ## v, op->v) |
|
|
1324 | # define CMP_OUT2(k,v) if (op->v != tmp->v) f.put (KW_ ## k, op->v) |
1705 | |
1325 | |
1706 | if(op->name && op->name!=op2->name) { |
1326 | CMP_OUT (name); |
1707 | ADD_STRINGLINE_ENTRY(fastbuf,"name ",op->name,5); |
1327 | CMP_OUT (name_pl); |
1708 | } |
1328 | CMP_OUT (custom_name); |
1709 | if(op->name_pl && op->name_pl!=op2->name_pl) { |
1329 | CMP_OUT (title); |
1710 | ADD_STRINGLINE_ENTRY(fastbuf,"name_pl ",op->name_pl,8); |
1330 | CMP_OUT (race); |
1711 | } |
1331 | CMP_OUT (slaying); |
1712 | if(op->custom_name && op->custom_name!=op2->custom_name) { |
|
|
1713 | ADD_STRINGLINE_ENTRY(fastbuf,"custom_name ",op->custom_name,12); |
|
|
1714 | } |
|
|
1715 | if(op->title && op->title!=op2->title) { |
|
|
1716 | ADD_STRINGLINE_ENTRY(fastbuf,"title ",op->title,6); |
|
|
1717 | } |
|
|
1718 | if(op->race && op->race!=op2->race) { |
|
|
1719 | ADD_STRINGLINE_ENTRY(fastbuf,"race ",op->race,5); |
|
|
1720 | } |
|
|
1721 | if(op->slaying && op->slaying!=op2->slaying) { |
|
|
1722 | ADD_STRINGLINE_ENTRY(fastbuf,"slaying ",op->slaying,8); |
|
|
1723 | } |
|
|
1724 | if(op->skill && op->skill!=op2->skill) { |
|
|
1725 | ADD_STRINGLINE_ENTRY(fastbuf,"skill ",op->skill,6); |
|
|
1726 | } |
|
|
1727 | if(op->msg && op->msg!=op2->msg) { |
|
|
1728 | FAST_STRNCAT(fastbuf,"msg\n",3+eol_size); |
|
|
1729 | FAST_STRCAT(fastbuf,op->msg); |
|
|
1730 | FAST_STRNCAT(fastbuf,"endmsg\n",6+eol_size); |
|
|
1731 | } |
|
|
1732 | if(op->lore && op->lore!=op2->lore) { |
|
|
1733 | FAST_STRNCAT(fastbuf,"lore\n",4+eol_size); |
|
|
1734 | FAST_STRCAT(fastbuf,op->lore); |
|
|
1735 | FAST_STRNCAT(fastbuf,"endlore\n",7+eol_size); |
|
|
1736 | |
1332 | |
1737 | } |
1333 | if (op->msg != tmp->msg ) f.put (KW_msg , KW_endmsg , op->msg); |
1738 | if(op->other_arch!=op2->other_arch&&op->other_arch!=NULL && |
1334 | if (op->lore != tmp->lore) f.put (KW_lore, KW_endlore, op->lore); |
1739 | op->other_arch->name) { |
|
|
1740 | ADD_STRINGLINE_ENTRY(fastbuf,"other_arch ",op->other_arch->name,11); |
|
|
1741 | } |
|
|
1742 | if(op->face!=op2->face) { |
|
|
1743 | ADD_STRINGLINE_ENTRY(fastbuf,"face ",op->face->name,5); |
|
|
1744 | } |
|
|
1745 | |
1335 | |
1746 | for(etmp=op->events;etmp!=NULL;etmp=etmp->next) |
1336 | CMP_OUT (other_arch); |
1747 | { |
1337 | CMP_OUT (face); |
1748 | /* First we find the event for the reference object */ |
1338 | |
1749 | etmp2=find_event(op2,etmp->type); |
1339 | if (op->animation_id != tmp->animation_id) |
1750 | if ((etmp->hook != NULL) && ((etmp2 == NULL) || (etmp2->hook == NULL) || (strcmp(etmp2->hook,etmp->hook)))) |
1340 | if (op->animation_id) |
1751 | /* Either there's no matching event in the reference object, |
|
|
1752 | * or the hook is different */ |
|
|
1753 | { |
1341 | { |
1754 | ADD_STRINGLINE_ENTRY(fastbuf,evtnames[etmp->type].name,etmp->hook,evtnames[etmp->type].length); |
1342 | f.put (KW_animation, animations[GET_ANIM_ID (op)].name); |
|
|
1343 | |
|
|
1344 | if (!QUERY_FLAG (op, FLAG_ANIMATE)) |
|
|
1345 | f.put (KW_is_animated, 0); |
1755 | } |
1346 | } |
1756 | if ((etmp->plugin != NULL) && ((etmp2 == NULL) || (etmp2->plugin == NULL) || (strcmp(etmp2->plugin,etmp->plugin)))) |
|
|
1757 | { |
|
|
1758 | |
|
|
1759 | ADD_STRINGLINE_ENTRY(fastbuf,plgnames[etmp->type].name,etmp->plugin,plgnames[etmp->type].length); |
|
|
1760 | } |
|
|
1761 | if ((etmp->options != NULL) && ((etmp2 == NULL) || (etmp2->options == NULL) || (strcmp(etmp2->options,etmp->options)))) |
|
|
1762 | { |
|
|
1763 | ADD_STRINGLINE_ENTRY(fastbuf,plgoptions[etmp->type].name,etmp->options,plgoptions[etmp->type].length); |
|
|
1764 | } |
|
|
1765 | |
|
|
1766 | } |
|
|
1767 | |
|
|
1768 | if (op->animation_id != op2->animation_id) { |
|
|
1769 | if (op->animation_id) { |
|
|
1770 | ADD_STRINGLINE_ENTRY(fastbuf,"animation ",animations[GET_ANIM_ID(op)].name,10); |
|
|
1771 | if ( ! QUERY_FLAG (op, FLAG_ANIMATE)) { |
|
|
1772 | FAST_STRNCAT(fastbuf,"is_animated 0\n",13+eol_size); |
|
|
1773 | } |
|
|
1774 | } else { |
1347 | else |
1775 | FAST_STRNCAT(fastbuf,"animation NONE\n",14+eol_size); |
1348 | f.put (KW_animation, "NONE"); |
1776 | } |
|
|
1777 | } |
|
|
1778 | if(op->stats.Str!=op2->stats.Str) |
|
|
1779 | FAST_SAVE_LONG(fastbuf,"Str ",op->stats.Str,4); |
|
|
1780 | if(op->stats.Dex!=op2->stats.Dex) |
|
|
1781 | FAST_SAVE_LONG(fastbuf,"Dex ",op->stats.Dex,4); |
|
|
1782 | if(op->stats.Con!=op2->stats.Con) |
|
|
1783 | FAST_SAVE_LONG(fastbuf,"Con ",op->stats.Con,4); |
|
|
1784 | if(op->stats.Wis!=op2->stats.Wis) |
|
|
1785 | FAST_SAVE_LONG(fastbuf,"Wis ",op->stats.Wis,4); |
|
|
1786 | if(op->stats.Pow!=op2->stats.Pow) |
|
|
1787 | FAST_SAVE_LONG(fastbuf,"Pow ",op->stats.Pow,4); |
|
|
1788 | if(op->stats.Cha!=op2->stats.Cha) |
|
|
1789 | FAST_SAVE_LONG(fastbuf,"Cha ",op->stats.Cha,4); |
|
|
1790 | if(op->stats.Int!=op2->stats.Int) |
|
|
1791 | FAST_SAVE_LONG(fastbuf,"Int ",op->stats.Int,4); |
|
|
1792 | if(op->stats.hp!=op2->stats.hp) |
|
|
1793 | FAST_SAVE_LONG(fastbuf,"hp ",op->stats.hp,3); |
|
|
1794 | if(op->stats.maxhp!=op2->stats.maxhp) |
|
|
1795 | FAST_SAVE_LONG(fastbuf,"maxhp ",op->stats.maxhp,6); |
|
|
1796 | if(op->stats.sp!=op2->stats.sp) |
|
|
1797 | FAST_SAVE_LONG(fastbuf,"sp ",op->stats.sp,3); |
|
|
1798 | if(op->stats.maxsp!=op2->stats.maxsp) |
|
|
1799 | FAST_SAVE_LONG(fastbuf,"maxsp ",op->stats.maxsp,6); |
|
|
1800 | if(op->stats.grace!=op2->stats.grace) |
|
|
1801 | FAST_SAVE_LONG(fastbuf,"grace ",op->stats.grace,6); |
|
|
1802 | if(op->stats.maxgrace!=op2->stats.maxgrace) |
|
|
1803 | FAST_SAVE_LONG(fastbuf,"maxgrace ",op->stats.maxgrace,9); |
|
|
1804 | |
1349 | |
1805 | if(op->stats.exp!=op2->stats.exp) { |
1350 | CMP_OUT2 (str , stats.Str); |
1806 | #ifndef WIN32 |
1351 | CMP_OUT2 (dex , stats.Dex); |
1807 | sprintf(buf2,"%lld", op->stats.exp); |
1352 | CMP_OUT2 (con , stats.Con); |
1808 | #else |
1353 | CMP_OUT2 (wis , stats.Wis); |
1809 | sprintf(buf2,"%I64d", op->stats.exp); |
1354 | CMP_OUT2 (pow , stats.Pow); |
1810 | #endif |
1355 | CMP_OUT2 (cha , stats.Cha); |
1811 | ADD_STRINGLINE_ENTRY(fastbuf,"exp ", buf2, 4); |
1356 | CMP_OUT2 (int , stats.Int); |
1812 | } |
1357 | CMP_OUT2 (hp , stats.hp); |
|
|
1358 | CMP_OUT2 (maxhp , stats.maxhp); |
|
|
1359 | CMP_OUT2 (sp , stats.sp); |
|
|
1360 | CMP_OUT2 (maxsp , stats.maxsp); |
|
|
1361 | CMP_OUT2 (grace , stats.grace); |
|
|
1362 | CMP_OUT2 (maxgrace, stats.maxgrace); |
|
|
1363 | CMP_OUT2 (exp , stats.exp); |
1813 | |
1364 | |
1814 | if(op->perm_exp!=op2->perm_exp) { |
1365 | CMP_OUT (perm_exp); |
1815 | #ifndef WIN32 |
1366 | CMP_OUT (expmul); |
1816 | sprintf(buf2,"%lld", op->perm_exp); |
|
|
1817 | #else |
|
|
1818 | sprintf(buf2,"%I64d", op->perm_exp); |
|
|
1819 | #endif |
|
|
1820 | ADD_STRINGLINE_ENTRY(fastbuf,"perm_exp ", buf2, 9); |
|
|
1821 | } |
|
|
1822 | |
1367 | |
1823 | if(op->expmul!=op2->expmul) |
1368 | CMP_OUT2 (food , stats.food); |
1824 | FAST_SAVE_DOUBLE(fastbuf,"expmul ",op->expmul,7); |
1369 | CMP_OUT2 (dam , stats.dam); |
1825 | if(op->stats.food!=op2->stats.food) |
1370 | CMP_OUT2 (luck , stats.luck); |
1826 | FAST_SAVE_LONG(fastbuf,"food ",op->stats.food,5); |
1371 | CMP_OUT2 (wc , stats.wc); |
1827 | if(op->stats.dam!=op2->stats.dam) |
1372 | CMP_OUT2 (ac , stats.ac); |
1828 | FAST_SAVE_LONG(fastbuf,"dam ",op->stats.dam,4); |
|
|
1829 | if(op->stats.luck!=op2->stats.luck) |
|
|
1830 | FAST_SAVE_LONG(fastbuf,"luck ",op->stats.luck,5); |
|
|
1831 | if(op->stats.wc!=op2->stats.wc) |
|
|
1832 | FAST_SAVE_LONG(fastbuf,"wc ",op->stats.wc,3); |
|
|
1833 | if(op->stats.ac!=op2->stats.ac) |
|
|
1834 | FAST_SAVE_LONG(fastbuf,"ac ",op->stats.ac,3); |
|
|
1835 | if(op->x!=op2->x) |
|
|
1836 | FAST_SAVE_LONG(fastbuf,"x ",op->x,2); |
|
|
1837 | if(op->y!=op2->y) |
|
|
1838 | FAST_SAVE_LONG(fastbuf,"y ",op->y,2); |
|
|
1839 | if(op->speed!=op2->speed) { |
|
|
1840 | FAST_SAVE_DOUBLE(fastbuf,"speed ",op->speed,6); |
|
|
1841 | } |
|
|
1842 | if(op->speed > 0 && op->speed_left!=op2->speed_left) { |
|
|
1843 | FAST_SAVE_DOUBLE(fastbuf,"speed_left ",op->speed_left,11); |
|
|
1844 | } |
|
|
1845 | if(op->move_status != op2->move_status) |
|
|
1846 | FAST_SAVE_LONG(fastbuf,"move_state ",op->move_status,11); |
|
|
1847 | if(op->attack_movement != op2->attack_movement) |
|
|
1848 | FAST_SAVE_LONG(fastbuf,"attack_movement ",op->attack_movement,16); |
|
|
1849 | if(op->nrof!=op2->nrof) |
|
|
1850 | FAST_SAVE_LONG(fastbuf,"nrof ",op->nrof,5); |
|
|
1851 | if(op->level!=op2->level) |
|
|
1852 | FAST_SAVE_LONG(fastbuf,"level ",op->level,6); |
|
|
1853 | if(op->direction!=op2->direction) |
|
|
1854 | FAST_SAVE_LONG(fastbuf,"direction ",op->direction,10); |
|
|
1855 | if(op->type!=op2->type) |
|
|
1856 | FAST_SAVE_LONG(fastbuf,"type ",op->type,5); |
|
|
1857 | if(op->subtype!=op2->subtype) |
|
|
1858 | FAST_SAVE_LONG(fastbuf,"subtype ",op->subtype,8); |
|
|
1859 | if(op->attacktype!=op2->attacktype) |
|
|
1860 | FAST_SAVE_LONG(fastbuf,"attacktype ",op->attacktype,11); |
|
|
1861 | |
1373 | |
|
|
1374 | CMP_OUT (x); |
|
|
1375 | CMP_OUT (y); |
|
|
1376 | CMP_OUT (speed); |
|
|
1377 | CMP_OUT (speed_left); |
|
|
1378 | CMP_OUT2 (move_state, move_status); |
|
|
1379 | CMP_OUT (attack_movement); |
|
|
1380 | CMP_OUT (nrof); |
|
|
1381 | CMP_OUT (level); |
|
|
1382 | CMP_OUT (direction); |
|
|
1383 | CMP_OUT (type); |
|
|
1384 | CMP_OUT (subtype); |
|
|
1385 | CMP_OUT (attacktype); |
|
|
1386 | |
1862 | for (tmp=0; tmp < NROFATTACKS; tmp++) { |
1387 | for (i = 0; i < NROFATTACKS; i++) |
1863 | if (op->resist[tmp] != op2->resist[tmp]) { |
1388 | if (op->resist [i] != tmp->resist [i]) |
1864 | FAST_STRNCAT(fastbuf,"resist_",7); |
1389 | f.put (resist_save [i], op->resist [i]); |
1865 | FAST_SAVE_LONG(fastbuf,resist_save[tmp],op->resist[tmp],strlen(resist_save[tmp])); |
|
|
1866 | } |
|
|
1867 | } |
|
|
1868 | |
1390 | |
1869 | if(op->path_attuned!=op2->path_attuned) |
1391 | CMP_OUT (path_attuned); |
1870 | FAST_SAVE_LONG(fastbuf,"path_attuned ",op->path_attuned,13); |
1392 | CMP_OUT (path_repelled); |
1871 | if(op->path_repelled!=op2->path_repelled) |
1393 | CMP_OUT (path_denied); |
1872 | FAST_SAVE_LONG(fastbuf,"path_repelled ",op->path_repelled,14); |
1394 | CMP_OUT (material); |
1873 | if(op->path_denied!=op2->path_denied) |
1395 | CMP_OUT (materialname); |
1874 | FAST_SAVE_LONG(fastbuf,"path_denied ",op->path_denied,12); |
1396 | CMP_OUT (value); |
1875 | if(op->material!=op2->material) |
1397 | CMP_OUT (carrying); |
1876 | FAST_SAVE_LONG(fastbuf,"material ",op->material,9); |
1398 | CMP_OUT (weight); |
1877 | if(op->materialname && op->materialname!=op2->materialname) { |
1399 | CMP_OUT (invisible); |
1878 | ADD_STRINGLINE_ENTRY(fastbuf,"materialname ",op->materialname,13); |
1400 | CMP_OUT (state); |
1879 | } |
1401 | CMP_OUT (magic); |
1880 | if(op->value!=op2->value) |
1402 | CMP_OUT (last_heal); |
1881 | FAST_SAVE_LONG(fastbuf,"value ",op->value,6); |
1403 | CMP_OUT (last_sp); |
1882 | if(op->carrying!=op2->carrying) |
1404 | CMP_OUT (last_grace); |
1883 | FAST_SAVE_LONG(fastbuf,"carrying ",op->carrying,9); |
1405 | CMP_OUT (last_eat); |
1884 | if(op->weight!=op2->weight) |
1406 | CMP_OUT (glow_radius); |
1885 | FAST_SAVE_LONG(fastbuf,"weight ",op->weight,7); |
1407 | |
1886 | if(op->invisible!=op2->invisible) |
|
|
1887 | FAST_SAVE_LONG(fastbuf,"invisible ",op->invisible,10); |
|
|
1888 | if(op->state!=op2->state) |
|
|
1889 | FAST_SAVE_LONG(fastbuf,"state ",op->state,6); |
|
|
1890 | if(op->magic!=op2->magic) |
|
|
1891 | FAST_SAVE_LONG(fastbuf,"magic ",op->magic,6); |
|
|
1892 | if(op->last_heal!=op2->last_heal) |
|
|
1893 | FAST_SAVE_LONG(fastbuf,"last_heal ",op->last_heal,10); |
|
|
1894 | if(op->last_sp!=op2->last_sp) |
|
|
1895 | FAST_SAVE_LONG(fastbuf,"last_sp ",op->last_sp,8); |
|
|
1896 | if(op->last_grace!=op2->last_grace) |
|
|
1897 | FAST_SAVE_LONG(fastbuf,"last_grace ",op->last_grace,11); |
|
|
1898 | if(op->last_eat!=op2->last_eat) |
|
|
1899 | FAST_SAVE_LONG(fastbuf,"last_eat ",op->last_eat,9); |
|
|
1900 | if(QUERY_FLAG(op,FLAG_IS_LINKED) && (tmp = get_button_value(op))) |
1408 | if (QUERY_FLAG (op, FLAG_IS_LINKED) && (i = get_button_value (op))) |
1901 | FAST_SAVE_LONG(fastbuf,"connected ",tmp,10); |
1409 | f.put (KW_connected, i); |
1902 | if(op->glow_radius!=op2->glow_radius) |
|
|
1903 | FAST_SAVE_LONG(fastbuf,"glow_radius ",op->glow_radius,12); |
|
|
1904 | if (op->randomitems!=op2->randomitems) { |
|
|
1905 | ADD_STRINGLINE_ENTRY(fastbuf,"randomitems ",(op->randomitems?op->randomitems->name:"none"),12); |
|
|
1906 | } |
|
|
1907 | #ifdef NPC_PROG |
|
|
1908 | if(op->npc_status!=op2->npc_status) |
|
|
1909 | FAST_SAVE_LONG(fastbuf,"npc_status ",op->npc_status,11); |
|
|
1910 | if(op->npc_program!=op2->npc_program) |
|
|
1911 | FAST_SAVE_LONG(fastbuf,"npc_program ",op->npc_program,12); |
|
|
1912 | #endif |
|
|
1913 | |
1410 | |
|
|
1411 | CMP_OUT (randomitems); |
|
|
1412 | CMP_OUT2 (container, weight_limit); |
1914 | |
1413 | |
1915 | if(op->run_away!=op2->run_away) |
1414 | CMP_OUT (run_away); |
1916 | FAST_SAVE_LONG(fastbuf,"run_away ",op->run_away,9); |
1415 | CMP_OUT (pick_up); |
1917 | if(op->pick_up!=op2->pick_up) |
1416 | CMP_OUT (will_apply); |
1918 | FAST_SAVE_LONG(fastbuf,"pick_up ",op->pick_up,8); |
1417 | CMP_OUT (smoothlevel); |
1919 | if(op->weight_limit!=op2->weight_limit) |
1418 | CMP_OUT (weapontype); |
1920 | FAST_SAVE_LONG(fastbuf,"container ",op->weight_limit,10); |
1419 | CMP_OUT (tooltype); |
1921 | if (op->will_apply!=op2->will_apply) |
1420 | CMP_OUT (elevation); |
1922 | FAST_SAVE_LONG(fastbuf,"will_apply ",op->will_apply,11); |
1421 | CMP_OUT (client_type); |
1923 | if(op->smoothlevel!=op2->smoothlevel) |
1422 | CMP_OUT (item_power); |
1924 | FAST_SAVE_LONG(fastbuf,"smoothlevel ",op->smoothlevel,12); |
1423 | CMP_OUT (duration); |
|
|
1424 | CMP_OUT (range); |
|
|
1425 | CMP_OUT (range_modifier); |
|
|
1426 | CMP_OUT (duration_modifier); |
|
|
1427 | CMP_OUT (dam_modifier); |
|
|
1428 | CMP_OUT (gen_sp_armour); |
1925 | |
1429 | |
1926 | if (op->current_weapon_script!=op2->current_weapon_script){ |
1430 | CMP_OUT (move_type); |
1927 | ADD_STRINGLINE_ENTRY(fastbuf,"current_weapon_script ",op->current_weapon_script,22); |
1431 | CMP_OUT (move_block); |
1928 | }; |
1432 | CMP_OUT (move_allow); |
|
|
1433 | CMP_OUT (move_on); |
|
|
1434 | CMP_OUT (move_off); |
|
|
1435 | CMP_OUT (move_slow); |
|
|
1436 | CMP_OUT (move_slow_penalty); |
1929 | |
1437 | |
1930 | if(op->weapontype && op->weapontype!=op2->weapontype) { |
|
|
1931 | FAST_SAVE_LONG(fastbuf,"weapontype ",op->weapontype,11); |
|
|
1932 | } |
|
|
1933 | if(op->tooltype && op->tooltype!=op2->tooltype) { |
|
|
1934 | FAST_SAVE_LONG(fastbuf,"tooltype ",op->tooltype,9); |
|
|
1935 | } |
|
|
1936 | if (op->elevation && op->elevation != op2->elevation) { |
|
|
1937 | FAST_SAVE_LONG(fastbuf,"elevation ",op->elevation,10); |
|
|
1938 | } |
|
|
1939 | if (op->client_type && op->client_type != op2->client_type) { |
|
|
1940 | FAST_SAVE_LONG(fastbuf,"client_type ",op->client_type,12); |
|
|
1941 | } |
|
|
1942 | |
|
|
1943 | if (op->item_power != op2->item_power) { |
|
|
1944 | FAST_SAVE_LONG(fastbuf,"item_power ",op->item_power,11); |
|
|
1945 | } |
|
|
1946 | |
|
|
1947 | if (op->duration != op2->duration) |
|
|
1948 | FAST_SAVE_LONG(fastbuf,"duration ",op->duration,9); |
|
|
1949 | |
|
|
1950 | if (op->range != op2->range) |
|
|
1951 | FAST_SAVE_LONG(fastbuf,"range ",op->range,6); |
|
|
1952 | |
|
|
1953 | if (op->range_modifier != op2->range_modifier) |
|
|
1954 | FAST_SAVE_LONG(fastbuf,"range_modifier ",op->range_modifier,15); |
|
|
1955 | |
|
|
1956 | if (op->duration_modifier != op2->duration_modifier) |
|
|
1957 | FAST_SAVE_LONG(fastbuf,"duration_modifier ", op->duration_modifier,18); |
|
|
1958 | |
|
|
1959 | if (op->dam_modifier != op2->dam_modifier) |
|
|
1960 | FAST_SAVE_LONG(fastbuf,"dam_modifier ", op->dam_modifier,13); |
|
|
1961 | |
|
|
1962 | if (op->gen_sp_armour != op2->gen_sp_armour) { |
|
|
1963 | FAST_SAVE_LONG(fastbuf,"gen_sp_armour ",op->gen_sp_armour,14); |
|
|
1964 | } |
|
|
1965 | |
|
|
1966 | /* I've kept the old int move type saving code commented out. |
|
|
1967 | * In an ideal world, we'd know if we want to do a quick |
|
|
1968 | * save (say to a temp map, where we don't care about strings), |
|
|
1969 | * or a slower save/dm dump, where printing out strings is handy. |
|
|
1970 | */ |
|
|
1971 | if (op->move_type != op2->move_type) { |
|
|
1972 | /*FAST_SAVE_LONG(fastbuf,"move_type ",op->move_type,10)*/ |
|
|
1973 | ADD_STRINGLINE_ENTRY(fastbuf,"move_type ", |
|
|
1974 | get_string_move_type(op->move_type), |
|
|
1975 | 10); |
|
|
1976 | } |
|
|
1977 | if (op->move_block != op2->move_block) { |
|
|
1978 | /*FAST_SAVE_LONG(fastbuf,"move_block ",op->move_block,11)*/ |
|
|
1979 | ADD_STRINGLINE_ENTRY(fastbuf,"move_block ", |
|
|
1980 | get_string_move_type(op->move_block), |
|
|
1981 | 11); |
|
|
1982 | } |
|
|
1983 | if (op->move_allow != op2->move_allow) { |
|
|
1984 | /*FAST_SAVE_LONG(fastbuf,"move_allow ",op->move_allow,11);*/ |
|
|
1985 | ADD_STRINGLINE_ENTRY(fastbuf,"move_allow ", |
|
|
1986 | get_string_move_type(op->move_allow), |
|
|
1987 | 11); |
|
|
1988 | } |
|
|
1989 | if (op->move_on != op2->move_on) { |
|
|
1990 | /*FAST_SAVE_LONG(fastbuf,"move_on ",op->move_on,8);*/ |
|
|
1991 | ADD_STRINGLINE_ENTRY(fastbuf,"move_on ", |
|
|
1992 | get_string_move_type(op->move_on), |
|
|
1993 | 8); |
|
|
1994 | } |
|
|
1995 | if (op->move_off != op2->move_off) { |
|
|
1996 | /*FAST_SAVE_LONG(fastbuf,"move_off ",op->move_off,9);*/ |
|
|
1997 | ADD_STRINGLINE_ENTRY(fastbuf,"move_off ", |
|
|
1998 | get_string_move_type(op->move_off), |
|
|
1999 | 9); |
|
|
2000 | } |
|
|
2001 | if (op->move_slow != op2->move_slow) { |
|
|
2002 | /*FAST_SAVE_LONG(fastbuf,"move_slow ",op->move_slow,10);*/ |
|
|
2003 | ADD_STRINGLINE_ENTRY(fastbuf,"move_slow ", |
|
|
2004 | get_string_move_type(op->move_slow), |
|
|
2005 | 10); |
|
|
2006 | } |
|
|
2007 | |
|
|
2008 | if (op->move_slow_penalty != op2->move_slow_penalty) { |
|
|
2009 | FAST_SAVE_LONG(fastbuf,"move_slow_penalty ",(long) op->move_slow_penalty,18); |
|
|
2010 | } |
|
|
2011 | |
|
|
2012 | if (!COMPARE_FLAGS(op,op2)) { |
1438 | if (!COMPARE_FLAGS (op, tmp)) |
2013 | for (tmp=0; tmp <= NUM_FLAGS; tmp++) { |
1439 | for (i = 0; i <= NUM_FLAGS; i++) |
2014 | if (flag_names[tmp] && (QUERY_FLAG(op, tmp) != QUERY_FLAG(op2, tmp))) { |
1440 | if (flag_names [i] |
2015 | ADD_STRINGLINE_ENTRY(fastbuf,flag_names[tmp],QUERY_FLAG(op, tmp)?" 1":" 0",flag_lens[tmp]); |
1441 | && (QUERY_FLAG (op, i) != QUERY_FLAG (tmp, i))) |
2016 | } |
1442 | f.put (flag_names [i], QUERY_FLAG (op, i) ? "1" : 0); |
2017 | } |
|
|
2018 | } |
|
|
2019 | |
1443 | |
2020 | /* Save body locations */ |
1444 | /* Save body locations */ |
2021 | for (i=0; i<NUM_BODY_LOCATIONS; i++) { |
1445 | for (i = 0; i < NUM_BODY_LOCATIONS; i++) |
2022 | if (op->body_info[i] != op2->body_info[i]) { |
1446 | if (op->body_info[i] != tmp->body_info[i]) |
2023 | FAST_STRCAT(fastbuf,body_locations[i].save_name); |
1447 | f.put (body_locations[i].save_name, op->body_info[i]); |
2024 | FAST_SAVE_LONG(fastbuf," ",op->body_info[i],1); |
|
|
2025 | } |
|
|
2026 | } |
|
|
2027 | FINISH_FASTCAT(fastbuf); |
|
|
2028 | if(buf[0]=='\0') /*did not cat anything...*/ |
|
|
2029 | return NULL; |
|
|
2030 | |
|
|
2031 | return buf; |
|
|
2032 | } |
1448 | } |
2033 | |
1449 | |
2034 | /* |
1450 | /* |
2035 | * Dumps all variables in an object to a file. |
1451 | * Dumps all variables in an object to a file. |
2036 | * If bit 0 of flag is set, unpaid objects will be saved. As of now, |
1452 | * If bit 0 of flag is set, unpaid objects will be saved. As of now, |
2037 | * the only place this is not set is when saving the player. |
1453 | * the only place this is not set is when saving the player. |
2038 | * If bit 1 of flag is set, don't remove the object after save. As of now, |
1454 | * If bit 1 of flag is set, don't remove the object after save. As of now, |
2039 | * all of the callers are setting this. |
1455 | * all of the callers are setting this. |
2040 | */ |
1456 | */ |
2041 | |
1457 | |
|
|
1458 | void |
2042 | void save_object(object_freezer &fp,object *op, int flag) { |
1459 | save_object (object_freezer &fp, object *op, int flag) |
|
|
1460 | { |
2043 | archetype *at; |
1461 | archetype *at; |
2044 | char *cp; |
|
|
2045 | object *tmp,*old; |
1462 | object *tmp, *old; |
2046 | |
1463 | |
2047 | /* Even if the object does have an owner, it would seem that we should |
1464 | /* Even if the object does have an owner, it would seem that we should |
2048 | * still save it. |
1465 | * still save it. |
2049 | */ |
1466 | */ |
2050 | if(op->owner!=NULL || fp == NULL) |
1467 | if (op->owner != NULL) |
2051 | return; |
1468 | return; |
2052 | |
1469 | |
2053 | /* If it is unpaid and we don't want to save those, just return. */ |
1470 | /* If it is unpaid and we don't want to save those, just return. */ |
2054 | if(!(flag&1)&&(QUERY_FLAG(op, FLAG_UNPAID))) { |
1471 | if (!(flag & 1) && (QUERY_FLAG (op, FLAG_UNPAID))) |
2055 | return; |
1472 | return; |
2056 | } |
|
|
2057 | |
1473 | |
2058 | if((at=op->arch)==NULL) at=empty_archetype; |
1474 | if ((at = op->arch) == NULL) |
2059 | fprintf(fp,"arch %s\n",at->name); |
1475 | at = empty_archetype; |
2060 | |
1476 | |
2061 | if((cp=get_ob_diff(op,&at->clone))!=NULL) |
1477 | fp.put (KW_arch, at->name); |
2062 | fputs(cp,fp); /* We really should do some status checking on this */ |
|
|
2063 | |
1478 | |
|
|
1479 | put (fp, op, &at->clone); |
|
|
1480 | |
2064 | /* Eneq(@csd.uu.se): Added this to allow containers being saved with contents*/ |
1481 | /* Eneq(@csd.uu.se): Added this to allow containers being saved with contents */ |
2065 | |
1482 | |
2066 | old=NULL; |
1483 | old = NULL; |
2067 | |
1484 | |
2068 | if (flag & 2 ) |
1485 | if (flag & 2) |
2069 | for(tmp=op->inv;tmp!=NULL;tmp=tmp->below) |
1486 | for (tmp = op->inv; tmp != NULL; tmp = tmp->below) |
2070 | save_object(fp,tmp,flag); |
1487 | save_object (fp, tmp, flag); |
2071 | |
1488 | else |
2072 | /* Slightly different logic because tmp/op will be removed by |
1489 | /* Slightly different logic because tmp/op will be removed by |
2073 | * the save_object we call. So we just keep looking at op->inv |
1490 | * the save_object we call. So we just keep looking at op->inv |
2074 | * until there is nothing left. In theory, the variable old |
1491 | * until there is nothing left. In theory, the variable old |
2075 | * should not be needed, as recursive loops shouldn't happen. |
1492 | * should not be needed, as recursive loops shouldn't happen. |
2076 | */ |
1493 | */ |
2077 | else while ((tmp=op->inv)!=NULL) { |
1494 | while ((tmp = op->inv) != NULL) |
2078 | if(old==tmp) { |
1495 | { |
|
|
1496 | if (old == tmp) |
|
|
1497 | { |
2079 | LOG(llevError," Recursive loop in inventory\n"); |
1498 | LOG (llevError, " Recursive loop in inventory\n"); |
2080 | break; |
1499 | break; |
2081 | } |
1500 | } |
|
|
1501 | |
2082 | save_object(fp,tmp,flag); |
1502 | save_object (fp, tmp, flag); |
2083 | old=tmp; |
1503 | old = tmp; |
2084 | } |
1504 | } |
2085 | |
1505 | |
2086 | if (!(flag&2)) { |
1506 | if (!(flag & 2)) |
|
|
1507 | { |
2087 | remove_ob(op); |
1508 | remove_ob (op); |
2088 | free_object (op); |
1509 | free_object (op); |
2089 | } |
1510 | } |
2090 | |
1511 | |
2091 | fp.put (op); |
1512 | fp.put (op); |
2092 | fprintf(fp,"end\n"); |
1513 | fprintf (fp, "end\n"); |
2093 | } |
1514 | } |
2094 | |
1515 | |
2095 | void insert_event(object* op, int etype, char *ehook, char *eplug, char *eoptions) |
1516 | event * |
|
|
1517 | find_event (object *op, int etype) |
2096 | { |
1518 | { |
2097 | event *evt; |
|
|
2098 | event *tmp; |
|
|
2099 | |
|
|
2100 | evt = find_event(op,etype); |
|
|
2101 | if (evt == NULL) |
|
|
2102 | { |
|
|
2103 | evt = (event *)malloc(sizeof(event)); |
|
|
2104 | evt->next = NULL; |
|
|
2105 | evt->type = etype; |
|
|
2106 | evt->hook = NULL; |
|
|
2107 | evt->plugin = NULL; |
|
|
2108 | evt->options = NULL; |
|
|
2109 | if (op->events==NULL) |
|
|
2110 | { |
|
|
2111 | op->events=evt; |
|
|
2112 | } |
|
|
2113 | else |
|
|
2114 | { |
|
|
2115 | for(tmp=op->events;;tmp=tmp->next) |
|
|
2116 | { |
|
|
2117 | if (tmp->next == NULL) |
|
|
2118 | { |
|
|
2119 | tmp->next = evt; |
|
|
2120 | break; |
|
|
2121 | } |
|
|
2122 | } |
|
|
2123 | } |
|
|
2124 | } |
|
|
2125 | if (ehook != NULL) |
|
|
2126 | FREE_AND_COPY(evt->hook,ehook); |
|
|
2127 | if (eplug != NULL) |
|
|
2128 | FREE_AND_COPY(evt->plugin,eplug); |
|
|
2129 | if (eoptions != NULL) |
|
|
2130 | FREE_AND_COPY(evt->options,eoptions); |
|
|
2131 | } |
|
|
2132 | |
|
|
2133 | event* find_event(object* op, int etype) |
|
|
2134 | { |
|
|
2135 | event *found; |
|
|
2136 | for(found=op->events;found!=NULL;found=found->next) |
1519 | for (event *found = op->events; found != NULL; found = found->next) |
2137 | { |
|
|
2138 | if (found->type == etype) |
1520 | if (found->type == etype) |
2139 | return found; |
1521 | return found; |
2140 | } |
1522 | |
2141 | return NULL; |
1523 | return NULL; |
2142 | } |
1524 | } |