… | |
… | |
250 | "spell_cause_rabies", /* 204 */ |
250 | "spell_cause_rabies", /* 204 */ |
251 | "spell_glyph", /* 205 */ |
251 | "spell_glyph", /* 205 */ |
252 | NULL |
252 | NULL |
253 | }; |
253 | }; |
254 | |
254 | |
255 | extern int arch_init; |
255 | extern bool loading_arch; |
256 | |
256 | |
257 | /* This function checks the object after it has been loaded (when we |
257 | /* This function checks the object after it has been loaded (when we |
258 | * get the 'end' in the input stream). This function can be used to |
258 | * get the 'end' in the input stream). This function can be used to |
259 | * deal with legacy objects where fields may have changed. It can also be used |
259 | * deal with legacy objects where fields may have changed. It can also be used |
260 | * to check for objects to make sure there are no common errors. |
260 | * to check for objects to make sure there are no common errors. |
… | |
… | |
289 | /* only do these when program is first run - a bit |
289 | /* only do these when program is first run - a bit |
290 | * excessive to do this at every run - most of this is |
290 | * excessive to do this at every run - most of this is |
291 | * really just to catch any errors - program will still run, but |
291 | * really just to catch any errors - program will still run, but |
292 | * not in the ideal fashion. |
292 | * not in the ideal fashion. |
293 | */ |
293 | */ |
294 | if ((op->type == WEAPON || op->type == BOW) && arch_init) |
294 | if ((op->type == WEAPON || op->type == BOW) && loading_arch) |
295 | { |
295 | { |
296 | if (!op->skill) |
296 | if (!op->skill) |
297 | LOG (llevError, "Weapon %s lacks a skill.\n", op->debug_desc ()); |
297 | LOG (llevError, "Weapon %s lacks a skill.\n", op->debug_desc ()); |
298 | else if ((!strcmp (op->skill, "one handed weapons") && op->body_info[1] != -1) || |
298 | else if ((!strcmp (op->skill, "one handed weapons") && op->body_info[1] != -1) || |
299 | (!strcmp (op->skill, "two handed weapons") && op->body_info[1] != -2)) |
299 | (!strcmp (op->skill, "two handed weapons") && op->body_info[1] != -2)) |
… | |
… | |
340 | } |
340 | } |
341 | |
341 | |
342 | /* Old spellcasting object - need to load in the appropiate object */ |
342 | /* Old spellcasting object - need to load in the appropiate object */ |
343 | if ((op->type == ROD || op->type == WAND || op->type == SCROLL || op->type == HORN || op->type == FIREWALL || |
343 | if ((op->type == ROD || op->type == WAND || op->type == SCROLL || op->type == HORN || op->type == FIREWALL || |
344 | /* POTIONS and ALTARS don't always cast spells, but if they do, update them */ |
344 | /* POTIONS and ALTARS don't always cast spells, but if they do, update them */ |
345 | ((op->type == POTION || op->type == ALTAR) && op->stats.sp)) && !op->inv && !arch_init) |
345 | ((op->type == POTION || op->type == ALTAR) && op->stats.sp)) && !op->inv && !loading_arch) |
346 | { |
346 | { |
347 | /* Fireall is bizarre in that spell type was stored in dam. Rest are 'normal' |
347 | /* Fireall is bizarre in that spell type was stored in dam. Rest are 'normal' |
348 | * in that spell was stored in sp. |
348 | * in that spell was stored in sp. |
349 | */ |
349 | */ |
350 | object *tmp = get_archetype (spell_mapping[op->type == FIREWALL ? op->stats.dam : op->stats.sp]); |
350 | object *tmp = get_archetype (spell_mapping[op->type == FIREWALL ? op->stats.dam : op->stats.sp]); |
351 | insert_ob_in_ob (tmp, op); |
351 | insert_ob_in_ob (tmp, op); |
352 | op->randomitems = NULL; /* So another spell isn't created for this object */ |
352 | op->randomitems = NULL; /* So another spell isn't created for this object */ |
353 | } |
353 | } |
354 | |
354 | |
355 | /* spellbooks & runes use slaying. But not to arch name, but to spell name */ |
355 | /* spellbooks & runes use slaying. But not to arch name, but to spell name */ |
356 | if ((op->type == SPELLBOOK || op->type == RUNE) && op->slaying && !op->inv && !arch_init) |
356 | if ((op->type == SPELLBOOK || op->type == RUNE) && op->slaying && !op->inv && !loading_arch) |
357 | { |
357 | { |
358 | object *tmp = get_archetype_by_object_name (op->slaying); |
358 | object *tmp = get_archetype_by_object_name (op->slaying); |
359 | insert_ob_in_ob (tmp, op); |
359 | insert_ob_in_ob (tmp, op); |
360 | op->randomitems = NULL; /* So another spell isn't created for this object */ |
360 | op->randomitems = NULL; /* So another spell isn't created for this object */ |
361 | /* without this, value is all screwed up */ |
361 | /* without this, value is all screwed up */ |
… | |
… | |
551 | } |
551 | } |
552 | } |
552 | } |
553 | continue; |
553 | continue; |
554 | |
554 | |
555 | case KW_other_arch: |
555 | case KW_other_arch: |
|
|
556 | other_arch = |
|
|
557 | loading_arch |
|
|
558 | ? archetype::get (f.get_str ()) |
556 | other_arch = archetype::find (f.get_str ()); |
559 | : archetype::find (f.get_str ()); |
|
|
560 | |
|
|
561 | if (!other_arch) |
|
|
562 | LOG (llevError, "%s uses unknown other_arch '%s'.\n", debug_desc (), f.get_str ()); |
557 | break; |
563 | break; |
558 | |
564 | |
559 | case KW_animation: |
565 | case KW_animation: |
560 | { |
566 | { |
561 | CLEAR_FLAG (this, FLAG_ANIMATE); |
567 | CLEAR_FLAG (this, FLAG_ANIMATE); |
… | |
… | |
908 | case KW_connected: |
914 | case KW_connected: |
909 | add_button_link (this, map, f.get_sint32 ()); |
915 | add_button_link (this, map, f.get_sint32 ()); |
910 | break; |
916 | break; |
911 | |
917 | |
912 | case KW_randomitems: |
918 | case KW_randomitems: |
913 | randomitems = find_treasurelist (f.get_str ()); |
919 | if (f.get_str ()) |
|
|
920 | { |
|
|
921 | randomitems = |
|
|
922 | loading_arch |
|
|
923 | ? treasurelist::get (f.get_str ()) |
|
|
924 | : treasurelist::find (f.get_str ()); |
|
|
925 | |
914 | //if (!randomitems) |
926 | if (!randomitems) |
915 | // LOG (llevError, "%s uses unknown randomitems '%s'.\n", debug_desc (), f.get_str ()); |
927 | LOG (llevError, "%s uses unknown randomitems '%s'.\n", debug_desc (), f.get_str ()); |
|
|
928 | } |
916 | break; |
929 | break; |
917 | |
930 | |
918 | case KW_msg: |
931 | case KW_msg: |
919 | f.get_ml (KW_endmsg, msg); |
932 | f.get_ml (KW_endmsg, msg); |
920 | //TODO: allow longer messages |
933 | //TODO: allow longer messages |
… | |
… | |
941 | break; |
954 | break; |
942 | |
955 | |
943 | case KW_end: |
956 | case KW_end: |
944 | check_loaded_object (this); |
957 | check_loaded_object (this); |
945 | |
958 | |
946 | if (!arch_init) |
959 | if (!loading_arch) |
947 | instantiate (); |
960 | instantiate (); |
948 | |
961 | |
949 | f.next (); |
962 | f.next (); |
950 | return true; |
963 | return true; |
951 | |
964 | |
… | |
… | |
980 | assert (arch); //D maybe use exception handling of sorts? |
993 | assert (arch); //D maybe use exception handling of sorts? |
981 | |
994 | |
982 | object *op = object::create (); |
995 | object *op = object::create (); |
983 | |
996 | |
984 | op->map = map; |
997 | op->map = map; |
985 | op->arch = arch; |
|
|
986 | arch->clone.copy_to (op); |
998 | arch->clone.copy_to (op); |
987 | // copy_to activates, this should be fixed properly |
999 | // copy_to activates, this should be fixed properly |
988 | op->deactivate (); |
1000 | op->deactivate (); |
989 | |
1001 | |
990 | if (!op->parse_kv (f)) |
1002 | if (!op->parse_kv (f)) |
991 | { |
1003 | { |
992 | delete op; |
1004 | op->destroy (true); |
993 | return 0; |
1005 | return 0; |
994 | } |
1006 | } |
995 | |
1007 | |
996 | return op; |
1008 | return op; |
997 | } |
1009 | } |