ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/common/loader.l
(Generate patch)

Comparing deliantra/server/common/loader.l (file contents):
Revision 1.7 by elmex, Sun Aug 13 17:16:00 2006 UTC vs.
Revision 1.19 by root, Sun Sep 3 00:18:40 2006 UTC

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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines