1 | /* |
1 | /* |
2 | * CrossFire, A Multiplayer game for X-windows |
2 | * CrossFire, A Multiplayer game |
3 | * |
3 | * |
4 | * Copyright (C) 2005, 2006, 2007 Marc Lehmann & Crossfire+ Development Team |
4 | * Copyright (C) 2005, 2006, 2007 Marc Lehmann & Crossfire+ Development Team |
5 | * Copyright (C) 2002 Mark Wedel & Crossfire Development Team |
5 | * Copyright (C) 2002 Mark Wedel & Crossfire Development Team |
6 | * Copyright (C) 1992 Frank Tore Johansen |
6 | * Copyright (C) 1992 Frank Tore Johansen |
7 | * |
7 | * |
… | |
… | |
29 | #include <global.h> |
29 | #include <global.h> |
30 | #include <loader.h> |
30 | #include <loader.h> |
31 | #include <sproto.h> |
31 | #include <sproto.h> |
32 | |
32 | |
33 | ///////////////////////////////////////////////////////////////////////////// |
33 | ///////////////////////////////////////////////////////////////////////////// |
34 | |
|
|
35 | /* Maps the MOVE_* values to names */ |
|
|
36 | static const char *const move_name[] = { "walk", "fly_low", "fly_high", "swim", "boat", NULL }; |
|
|
37 | |
34 | |
38 | /* This table is only necessary to convert objects that existed before the |
35 | /* This table is only necessary to convert objects that existed before the |
39 | * spell object conversion to the new object. It was not practical |
36 | * spell object conversion to the new object. It was not practical |
40 | * to go through every mapping looking for every potion, rod, wand, etc |
37 | * to go through every mapping looking for every potion, rod, wand, etc |
41 | * that had a sp set and update to the new value. So this maps the |
38 | * that had a sp set and update to the new value. So this maps the |
… | |
… | |
253 | "spell_cause_rabies", /* 204 */ |
250 | "spell_cause_rabies", /* 204 */ |
254 | "spell_glyph", /* 205 */ |
251 | "spell_glyph", /* 205 */ |
255 | NULL |
252 | NULL |
256 | }; |
253 | }; |
257 | |
254 | |
258 | extern int arch_init; |
255 | extern bool loading_arch; |
259 | |
256 | |
260 | /* 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 |
261 | * 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 |
262 | * 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 |
263 | * 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. |
… | |
… | |
292 | /* only do these when program is first run - a bit |
289 | /* only do these when program is first run - a bit |
293 | * excessive to do this at every run - most of this is |
290 | * excessive to do this at every run - most of this is |
294 | * really just to catch any errors - program will still run, but |
291 | * really just to catch any errors - program will still run, but |
295 | * not in the ideal fashion. |
292 | * not in the ideal fashion. |
296 | */ |
293 | */ |
297 | if ((op->type == WEAPON || op->type == BOW) && arch_init) |
294 | if ((op->type == WEAPON || op->type == BOW) && loading_arch) |
298 | { |
295 | { |
299 | if (!op->skill) |
296 | if (!op->skill) |
300 | LOG (llevError, "Weapon %s lacks a skill.\n", op->debug_desc ()); |
297 | LOG (llevError, "Weapon %s lacks a skill.\n", op->debug_desc ()); |
301 | else if ((!strcmp (op->skill, "one handed weapons") && op->body_info[1] != -1) || |
298 | else if ((!strcmp (op->skill, "one handed weapons") && op->slot[1].info != -1) || |
302 | (!strcmp (op->skill, "two handed weapons") && op->body_info[1] != -2)) |
299 | (!strcmp (op->skill, "two handed weapons") && op->slot[1].info != -2)) |
303 | LOG (llevError, "weapon %s arm usage does not match skill: %d, %s\n", op->debug_desc (), op->body_info[1], &op->skill); |
300 | LOG (llevError, "weapon %s arm usage does not match skill: %d, %s\n", op->debug_desc (), op->slot[1].info, &op->skill); |
304 | } |
301 | } |
305 | |
302 | |
306 | /* We changed last_heal to gen_sp_armour, which is what it |
303 | /* We changed last_heal to gen_sp_armour, which is what it |
307 | * really does for many objects. Need to catch any in maps |
304 | * really does for many objects. Need to catch any in maps |
308 | * that may have an old value. |
305 | * that may have an old value. |
… | |
… | |
343 | } |
340 | } |
344 | |
341 | |
345 | /* Old spellcasting object - need to load in the appropiate object */ |
342 | /* Old spellcasting object - need to load in the appropiate object */ |
346 | 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 || |
347 | /* 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 */ |
348 | ((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) |
349 | { |
346 | { |
350 | /* 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' |
351 | * in that spell was stored in sp. |
348 | * in that spell was stored in sp. |
352 | */ |
349 | */ |
353 | 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]); |
354 | insert_ob_in_ob (tmp, op); |
351 | insert_ob_in_ob (tmp, op); |
355 | 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 */ |
356 | } |
353 | } |
357 | |
354 | |
358 | /* 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 */ |
359 | 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) |
360 | { |
357 | { |
361 | object *tmp = get_archetype_by_object_name (op->slaying); |
358 | object *tmp = get_archetype_by_object_name (op->slaying); |
362 | insert_ob_in_ob (tmp, op); |
359 | insert_ob_in_ob (tmp, op); |
363 | 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 */ |
364 | /* without this, value is all screwed up */ |
361 | /* without this, value is all screwed up */ |
… | |
… | |
409 | } |
406 | } |
410 | |
407 | |
411 | } |
408 | } |
412 | |
409 | |
413 | static void |
410 | static void |
414 | set_move (MoveType & mt, const char *str) |
411 | set_move (MoveType &mt, const char *str) |
415 | { |
412 | { |
|
|
413 | static const struct flagstr { |
|
|
414 | const char *name; |
|
|
415 | MoveType flags; |
|
|
416 | } move_flags[] = { |
|
|
417 | { "walk" , MOVE_WALK }, |
|
|
418 | { "flying" , MOVE_FLY_LOW | MOVE_FLY_HIGH }, |
|
|
419 | { "fly_low" , MOVE_FLY_LOW }, |
|
|
420 | { "fly_high", MOVE_FLY_HIGH }, |
|
|
421 | { "swim" , MOVE_SWIM }, |
|
|
422 | { "boat" , MOVE_BOAT }, |
|
|
423 | { "ship" , MOVE_SHIP }, |
|
|
424 | { "all" , MOVE_ALL }, |
|
|
425 | }; |
|
|
426 | |
416 | if (!str) |
427 | if (!str) |
417 | { |
428 | { |
418 | mt = 0; |
429 | mt = 0; |
419 | return; |
430 | return; |
420 | } |
431 | } |
… | |
… | |
427 | |
438 | |
428 | mt = 0; |
439 | mt = 0; |
429 | |
440 | |
430 | for (str = strtok ((char *) str, " "); str; str = strtok (0, " ")) |
441 | for (str = strtok ((char *) str, " "); str; str = strtok (0, " ")) |
431 | { |
442 | { |
432 | if (!strcasecmp (str, "all")) |
443 | bool negate = 0; |
433 | mt |= MOVE_ALL; |
444 | |
434 | else |
445 | if (*str == '-') |
435 | { |
446 | { |
436 | int i, negate = 0; |
447 | negate = 1; |
|
|
448 | str++; |
|
|
449 | } |
437 | |
450 | |
438 | if (*str == '-') |
451 | for (const flagstr *f = move_flags; f < move_flags + sizeof (move_flags) / sizeof (move_flags [0]); ++f) |
|
|
452 | { |
|
|
453 | if (!strcmp (f->name, str)) |
439 | { |
454 | { |
440 | negate = 1; |
|
|
441 | str++; |
|
|
442 | } |
|
|
443 | |
|
|
444 | for (i = 0; move_name[i]; i++) |
|
|
445 | { |
|
|
446 | if (!strcasecmp (move_name[i], str)) |
|
|
447 | { |
|
|
448 | if (negate) |
455 | if (negate) |
449 | mt &= ~(1 << i); |
456 | mt &= ~f->flags; |
450 | else |
|
|
451 | mt |= (1 << i); |
|
|
452 | |
|
|
453 | break; |
|
|
454 | } |
|
|
455 | } |
|
|
456 | |
|
|
457 | if (!move_name[i]) |
|
|
458 | { |
|
|
459 | /* fly is a special case - covers both fly_low and |
|
|
460 | * fly_high - since it doesn't match to a specific |
|
|
461 | * single bit, have to special case it. |
|
|
462 | */ |
|
|
463 | if (!strcasecmp (str, "flying")) |
|
|
464 | { |
|
|
465 | if (negate) |
|
|
466 | mt &= ~MOVE_FLYING; |
|
|
467 | else |
|
|
468 | mt |= MOVE_FLYING; |
|
|
469 | } |
|
|
470 | else |
457 | else |
471 | LOG (llevDebug, "common/loader.l: set_move - unknown move string '%s'\n", str); |
458 | mt |= f->flags; |
|
|
459 | |
|
|
460 | goto next; |
472 | } |
461 | } |
473 | } |
462 | } |
|
|
463 | |
|
|
464 | LOG (llevDebug, "common/loader.C: set_move - unknown move string '%s'\n", str); |
|
|
465 | |
|
|
466 | next: ; |
474 | } |
467 | } |
475 | } |
468 | } |
476 | |
469 | |
477 | #define GET_FLAG(op,flag) \ |
470 | #define GET_FLAG(op,flag) \ |
478 | if (f.get_sint32 ()) \ |
471 | if (f.get_sint32 ()) \ |
… | |
… | |
481 | CLEAR_FLAG (op, flag) \ |
474 | CLEAR_FLAG (op, flag) \ |
482 | |
475 | |
483 | bool |
476 | bool |
484 | object::parse_kv (object_thawer &f) |
477 | object::parse_kv (object_thawer &f) |
485 | { |
478 | { |
486 | assert (f.kw == KW_object || f.kw == KW_arch); |
|
|
487 | |
|
|
488 | if (f.kw == KW_object) |
|
|
489 | f.get (name); // preset name from object name |
|
|
490 | |
|
|
491 | f.next (); |
|
|
492 | |
|
|
493 | object *op_inv = inv; |
479 | object *op_inv = inv; |
494 | |
480 | |
495 | for (;;) |
481 | for (;;) |
496 | { |
482 | { |
497 | switch (f.kw) |
483 | switch (f.kw) |
… | |
… | |
559 | } |
545 | } |
560 | } |
546 | } |
561 | continue; |
547 | continue; |
562 | |
548 | |
563 | case KW_other_arch: |
549 | case KW_other_arch: |
|
|
550 | other_arch = |
|
|
551 | loading_arch |
|
|
552 | ? archetype::get (f.get_str ()) |
564 | other_arch = archetype::find (f.get_str ()); |
553 | : archetype::find (f.get_str ()); |
|
|
554 | |
|
|
555 | if (!other_arch) |
|
|
556 | LOG (llevError, "%s uses unknown other_arch '%s'.\n", debug_desc (), f.get_str ()); |
565 | break; |
557 | break; |
566 | |
558 | |
567 | case KW_animation: |
559 | case KW_animation: |
568 | { |
560 | { |
569 | CLEAR_FLAG (this, FLAG_ANIMATE); |
561 | CLEAR_FLAG (this, FLAG_ANIMATE); |
… | |
… | |
595 | move_slow |= MOVE_WALK; |
587 | move_slow |= MOVE_WALK; |
596 | f.get (move_slow_penalty); |
588 | f.get (move_slow_penalty); |
597 | break; |
589 | break; |
598 | |
590 | |
599 | case KW_face: |
591 | case KW_face: |
600 | face = &new_faces[FindFace (f.get_str (), 0)]; |
592 | face = face_find (f.get_str ()); |
601 | break; |
593 | break; |
602 | |
594 | |
603 | case KW_x: f.get (x); break; |
595 | case KW_x: f.get (x); break; |
604 | case KW_y: f.get (y); break; |
596 | case KW_y: f.get (y); break; |
605 | |
597 | |
… | |
… | |
841 | case KW_no_steal: GET_FLAG (this, FLAG_NO_STEAL); break; |
833 | case KW_no_steal: GET_FLAG (this, FLAG_NO_STEAL); break; |
842 | case KW_one_hit: GET_FLAG (this, FLAG_ONE_HIT); break; |
834 | case KW_one_hit: GET_FLAG (this, FLAG_ONE_HIT); break; |
843 | case KW_berserk: GET_FLAG (this, FLAG_BERSERK); break; |
835 | case KW_berserk: GET_FLAG (this, FLAG_BERSERK); break; |
844 | case KW_is_buildable: GET_FLAG (this, FLAG_IS_BUILDABLE); break; |
836 | case KW_is_buildable: GET_FLAG (this, FLAG_IS_BUILDABLE); break; |
845 | case KW_destroy_on_death: GET_FLAG (this, FLAG_DESTROY_ON_DEATH); break; |
837 | case KW_destroy_on_death: GET_FLAG (this, FLAG_DESTROY_ON_DEATH); break; |
|
|
838 | case KW_treasure_env: GET_FLAG (this, FLAG_TREASURE_ENV); break; |
|
|
839 | case KW_precious: GET_FLAG (this, FLAG_PRECIOUS); break; |
846 | |
840 | |
847 | case KW_armour: f.get (resist[ATNR_PHYSICAL]); break; |
841 | case KW_armour: f.get (resist[ATNR_PHYSICAL]); break; |
848 | case KW_resist_physical: f.get (resist[ATNR_PHYSICAL]); break; |
842 | case KW_resist_physical: f.get (resist[ATNR_PHYSICAL]); break; |
849 | case KW_resist_magic: f.get (resist[ATNR_MAGIC]); break; |
843 | case KW_resist_magic: f.get (resist[ATNR_MAGIC]); break; |
850 | case KW_resist_fire: f.get (resist[ATNR_FIRE]); break; |
844 | case KW_resist_fire: f.get (resist[ATNR_FIRE]); break; |
… | |
… | |
886 | case KW_glow_radius: f.get (glow_radius); break; |
880 | case KW_glow_radius: f.get (glow_radius); break; |
887 | case KW_weapontype: f.get (weapontype); break; |
881 | case KW_weapontype: f.get (weapontype); break; |
888 | case KW_tooltype: f.get (tooltype); break; |
882 | case KW_tooltype: f.get (tooltype); break; |
889 | case KW_casting_time: f.get (casting_time); break; |
883 | case KW_casting_time: f.get (casting_time); break; |
890 | case KW_elevation: f.get (elevation); break; |
884 | case KW_elevation: f.get (elevation); break; |
891 | case KW_smoothlevel: f.get (smoothlevel); break; |
885 | case KW_smoothlevel: f.get (smoothlevel); smoothlevel = clamp (smoothlevel, 0, 255); break; |
892 | case KW_client_type: f.get (client_type); break; |
886 | case KW_client_type: f.get (client_type); break; |
893 | case KW_duration: f.get (duration); break; |
887 | case KW_duration: f.get (duration); break; |
894 | case KW_range: f.get (range); break; |
888 | case KW_range: f.get (range); break; |
895 | case KW_range_modifier: f.get (range_modifier); break; |
889 | case KW_range_modifier: f.get (range_modifier); break; |
896 | case KW_dam_modifier: f.get (dam_modifier); break; |
890 | case KW_dam_modifier: f.get (dam_modifier); break; |
897 | case KW_duration_modifier: f.get (duration_modifier); break; |
891 | case KW_duration_modifier: f.get (duration_modifier); break; |
898 | |
892 | |
899 | //TODO: mechanism to ensure that KW_xxx is consecutive needed from include/preprocess |
893 | //TODO: mechanism to ensure that KW_xxx is consecutive needed from include/preprocess |
900 | //TODO: parse from other include files |
894 | //TODO: parse from other include files |
901 | case KW_body_range: f.get (body_info[0]); break; |
895 | case KW_body_range: slot[ 0].info = f.get_sint32 (); break; |
902 | case KW_body_arm: f.get (body_info[1]); break; |
896 | case KW_body_arm: slot[ 1].info = f.get_sint32 (); break; |
903 | case KW_body_torso: f.get (body_info[2]); break; |
897 | case KW_body_torso: slot[ 2].info = f.get_sint32 (); break; |
904 | case KW_body_head: f.get (body_info[3]); break; |
898 | case KW_body_head: slot[ 3].info = f.get_sint32 (); break; |
905 | case KW_body_neck: f.get (body_info[4]); break; |
899 | case KW_body_neck: slot[ 4].info = f.get_sint32 (); break; |
906 | case KW_body_skill: f.get (body_info[5]); break; |
900 | case KW_body_skill: slot[ 5].info = f.get_sint32 (); break; |
907 | case KW_body_finger: f.get (body_info[6]); break; |
901 | case KW_body_finger: slot[ 6].info = f.get_sint32 (); break; |
908 | case KW_body_shoulder: f.get (body_info[7]); break; |
902 | case KW_body_shoulder: slot[ 7].info = f.get_sint32 (); break; |
909 | case KW_body_foot: f.get (body_info[8]); break; |
903 | case KW_body_foot: slot[ 8].info = f.get_sint32 (); break; |
910 | case KW_body_hand: f.get (body_info[9]); break; |
904 | case KW_body_hand: slot[ 9].info = f.get_sint32 (); break; |
911 | case KW_body_wrist: f.get (body_info[10]); break; |
905 | case KW_body_wrist: slot[10].info = f.get_sint32 (); break; |
912 | case KW_body_waist: f.get (body_info[11]); break; |
906 | case KW_body_waist: slot[11].info = f.get_sint32 (); break; |
913 | case KW_can_apply: |
907 | case KW_can_apply: |
914 | break; |
908 | break; |
915 | |
909 | |
916 | case KW_connected: |
910 | case KW_connected: |
917 | add_button_link (this, map, f.get_sint32 ()); |
911 | add_button_link (this, map, f.get_sint32 ()); |
918 | break; |
912 | break; |
919 | |
913 | |
920 | case KW_randomitems: |
914 | case KW_randomitems: |
921 | randomitems = find_treasurelist (f.get_str ()); |
915 | if (f.get_str ()) |
|
|
916 | { |
|
|
917 | randomitems = |
|
|
918 | loading_arch |
|
|
919 | ? treasurelist::get (f.get_str ()) |
|
|
920 | : treasurelist::find (f.get_str ()); |
|
|
921 | |
922 | //if (!randomitems) |
922 | if (!randomitems) |
923 | // LOG (llevError, "%s uses unknown randomitems '%s'.\n", debug_desc (), f.get_str ()); |
923 | LOG (llevError, "%s uses unknown randomitems '%s'.\n", debug_desc (), f.get_str ()); |
|
|
924 | } |
|
|
925 | else |
|
|
926 | randomitems = 0; |
924 | break; |
927 | break; |
925 | |
928 | |
926 | case KW_msg: |
929 | case KW_msg: |
927 | f.get_ml (KW_endmsg, msg); |
930 | f.get_ml (KW_endmsg, msg); |
928 | //TODO: allow longer messages |
931 | //TODO: allow longer messages |
… | |
… | |
949 | break; |
952 | break; |
950 | |
953 | |
951 | case KW_end: |
954 | case KW_end: |
952 | check_loaded_object (this); |
955 | check_loaded_object (this); |
953 | |
956 | |
954 | if (!arch_init) |
957 | if (!loading_arch) |
955 | instantiate (); |
958 | instantiate (); |
956 | |
959 | |
957 | f.next (); |
960 | f.next (); |
958 | return true; |
961 | return true; |
959 | |
962 | |
… | |
… | |
985 | arch = archetype::find ("earthwall"); |
988 | arch = archetype::find ("earthwall"); |
986 | } |
989 | } |
987 | |
990 | |
988 | assert (arch); //D maybe use exception handling of sorts? |
991 | assert (arch); //D maybe use exception handling of sorts? |
989 | |
992 | |
|
|
993 | f.next (); |
|
|
994 | |
990 | object *op = object::create (); |
995 | object *op = object::create (); |
991 | |
996 | |
992 | op->map = map; |
997 | op->map = map; |
993 | op->arch = arch; |
|
|
994 | arch->clone.copy_to (op); |
998 | arch->clone.copy_to (op); |
995 | // copy_to activates, this should be fixed properly |
999 | // copy_to activates, this should be fixed properly |
996 | op->deactivate (); |
1000 | op->deactivate (); |
997 | |
1001 | |
998 | if (!op->parse_kv (f)) |
1002 | if (!op->parse_kv (f)) |
999 | { |
1003 | { |
1000 | delete op; |
1004 | op->destroy (true); |
1001 | return 0; |
1005 | return 0; |
1002 | } |
1006 | } |
1003 | |
1007 | |
1004 | return op; |
1008 | return op; |
1005 | } |
1009 | } |
… | |
… | |
1013 | int |
1017 | int |
1014 | set_variable (object *op, char *buf) |
1018 | set_variable (object *op, char *buf) |
1015 | { |
1019 | { |
1016 | object_thawer f (buf, (AV *)0); |
1020 | object_thawer f (buf, (AV *)0); |
1017 | |
1021 | |
|
|
1022 | f.next (); |
1018 | return op->parse_kv (f); |
1023 | return op->parse_kv (f); |
1019 | } |
1024 | } |
1020 | |
1025 | |
1021 | /* This returns a string of the integer movement type */ |
1026 | /* This returns a string of the integer movement type */ |
1022 | #if 0 |
1027 | #if 0 |
… | |
… | |
1103 | KW_monster, |
1108 | KW_monster, |
1104 | KW_friendly, |
1109 | KW_friendly, |
1105 | KW_generator, |
1110 | KW_generator, |
1106 | KW_is_thrown, |
1111 | KW_is_thrown, |
1107 | KW_auto_apply, |
1112 | KW_auto_apply, |
1108 | KW_NULL, // was KW_treasure |
1113 | KW_treasure_env, |
1109 | KW_player_sold, |
1114 | KW_player_sold, |
1110 | /* 20 */ |
1115 | /* 20 */ |
1111 | KW_see_invisible, |
1116 | KW_see_invisible, |
1112 | KW_can_roll, |
1117 | KW_can_roll, |
1113 | KW_overlay_floor, |
1118 | KW_overlay_floor, |
… | |
… | |
1174 | KW_can_use_skill, |
1179 | KW_can_use_skill, |
1175 | KW_been_applied, |
1180 | KW_been_applied, |
1176 | /* 80 */ |
1181 | /* 80 */ |
1177 | KW_has_ready_scroll, |
1182 | KW_has_ready_scroll, |
1178 | KW_can_use_rod, |
1183 | KW_can_use_rod, |
1179 | KW_NULL, |
1184 | KW_precious, |
1180 | KW_can_use_horn, |
1185 | KW_can_use_horn, |
1181 | KW_make_invisible, |
1186 | KW_make_invisible, |
1182 | KW_inv_locked, |
1187 | KW_inv_locked, |
1183 | KW_is_wooded, |
1188 | KW_is_wooded, |
1184 | KW_is_hilly, |
1189 | KW_is_hilly, |
… | |
… | |
1250 | f.put (KW_msg, KW_endmsg, op->msg); |
1255 | f.put (KW_msg, KW_endmsg, op->msg); |
1251 | if (op->lore != tmp->lore) |
1256 | if (op->lore != tmp->lore) |
1252 | f.put (KW_lore, KW_endlore, op->lore); |
1257 | f.put (KW_lore, KW_endlore, op->lore); |
1253 | |
1258 | |
1254 | CMP_OUT (other_arch); |
1259 | CMP_OUT (other_arch); |
1255 | CMP_OUT (face); |
1260 | |
|
|
1261 | if (op->face != tmp->face) f.put (KW_face, op->face ? &faces [op->face] : 0); |
1256 | |
1262 | |
1257 | if (op->animation_id != tmp->animation_id) |
1263 | if (op->animation_id != tmp->animation_id) |
1258 | if (op->animation_id) |
1264 | if (op->animation_id) |
1259 | { |
1265 | { |
1260 | f.put (KW_animation, animations[GET_ANIM_ID (op)].name); |
1266 | f.put (KW_animation, animations[GET_ANIM_ID (op)].name); |
… | |
… | |
1357 | if (op->flag != tmp->flag) |
1363 | if (op->flag != tmp->flag) |
1358 | for (i = 0; i <= NUM_FLAGS; i++) |
1364 | for (i = 0; i <= NUM_FLAGS; i++) |
1359 | if (flag_names [i] && op->flag [i] != tmp->flag [i]) |
1365 | if (flag_names [i] && op->flag [i] != tmp->flag [i]) |
1360 | f.put (flag_names [i], op->flag [i] ? "1" : "0"); |
1366 | f.put (flag_names [i], op->flag [i] ? "1" : "0"); |
1361 | |
1367 | |
1362 | /* Save body locations */ |
1368 | // save body locations |
1363 | for (i = 0; i < NUM_BODY_LOCATIONS; i++) |
1369 | for (i = 0; i < NUM_BODY_LOCATIONS; i++) |
1364 | if (op->body_info[i] != tmp->body_info[i]) |
1370 | if (op->slot[i].info != tmp->slot[i].info) |
1365 | f.put (body_locations[i].save_name, op->body_info[i]); |
1371 | f.put (body_locations[i].save_name, op->slot[i].info); |
1366 | } |
1372 | } |
1367 | |
1373 | |
1368 | /* |
1374 | /* |
1369 | * Dumps all variables in an object to a file. |
1375 | * Dumps all variables in an object to a file. |
1370 | * If bit 0 of flag is set, unpaid objects will be saved. As of now, |
1376 | * If bit 0 of flag is set, unpaid objects will be saved. As of now, |
… | |
… | |
1393 | return true; |
1399 | return true; |
1394 | } |
1400 | } |
1395 | |
1401 | |
1396 | ///////////////////////////////////////////////////////////////////////////// |
1402 | ///////////////////////////////////////////////////////////////////////////// |
1397 | |
1403 | |
|
|
1404 | // generic resource file load, |
|
|
1405 | // currently supports: region, treasures, archetypes |
1398 | bool load_resource_file (const char *filename) |
1406 | bool load_resource_file (const char *filename) |
1399 | { |
1407 | { |
1400 | object_thawer f (filename); |
1408 | object_thawer f (filename); |
|
|
1409 | |
|
|
1410 | bool success = false; |
|
|
1411 | bool seen_arch = false; |
1401 | |
1412 | |
1402 | f.next (); |
1413 | f.next (); |
1403 | |
1414 | |
1404 | for (;;) |
1415 | for (;;) |
1405 | { |
1416 | { |
1406 | switch (f.kw) |
1417 | switch (f.kw) |
1407 | { |
1418 | { |
1408 | case KW_region: |
1419 | case KW_region: |
1409 | if (!region::read (f)) |
1420 | if (!region::read (f)) |
1410 | return false; |
1421 | goto finish; |
|
|
1422 | break; |
|
|
1423 | |
|
|
1424 | case KW_treasure: |
|
|
1425 | case KW_treasureone: |
|
|
1426 | if (!treasurelist::read (f)) |
|
|
1427 | goto finish; |
|
|
1428 | break; |
|
|
1429 | |
|
|
1430 | case KW_object: |
|
|
1431 | seen_arch = true; |
|
|
1432 | if (!archetype::read (f)) |
|
|
1433 | goto finish; |
1411 | break; |
1434 | break; |
1412 | |
1435 | |
1413 | case KW_EOF: |
1436 | case KW_EOF: |
1414 | return true; |
1437 | success = true; |
|
|
1438 | goto finish; |
1415 | |
1439 | |
1416 | default: |
1440 | default: |
1417 | if (!f.parse_error ("resource file")) |
1441 | if (!f.parse_error ("resource file")) |
1418 | return false; |
1442 | goto finish; |
|
|
1443 | |
|
|
1444 | f.next (); |
|
|
1445 | break; |
1419 | } |
1446 | } |
1420 | |
|
|
1421 | f.next (); |
|
|
1422 | } |
1447 | } |
|
|
1448 | |
|
|
1449 | finish: |
|
|
1450 | if (seen_arch) |
|
|
1451 | init_archetype_pointers (); |
|
|
1452 | |
|
|
1453 | return success; |
1423 | } |
1454 | } |
1424 | |
1455 | |