4 * Copyright (c) 1997 Ben Harrison, and others
6 * This software may be copied and distributed for educational, research,
7 * and not for profit purposes provided that this copyright and statement
8 * are included in all such copies. Other copyrights may also apply.
15 * This file loads savefiles from Angband 2.9.X.
17 * We attempt to prevent corrupt savefiles from inducing memory errors.
19 * Note that this file should not use the random number generator, the
20 * object flavors, the visual attr/char mappings, or anything else which
21 * is initialized *after* or *during* the "load character" function.
23 * This file assumes that the monster/object records are initialized
24 * to zero, and the race/kind tables have been loaded correctly. The
25 * order of object stacks is currently not saved in the savefiles, but
26 * the "next" pointers are saved, so all necessary knowledge is present.
28 * We should implement simple "savefile extenders" using some form of
29 * "sized" chunks of bytes, with a {size,type,data} format, so everyone
30 * can know the size, interested people can know the type, and the actual
31 * data is available to the parsing routines that acknowledge the type.
33 * Consider changing the "globe of invulnerability" code so that it
34 * takes some form of "maximum damage to protect from" in addition to
35 * the existing "number of turns to protect for", and where each hit
36 * by a monster will reduce the shield by that amount. XXX XXX XXX
44 * Local "savefile" pointer
49 * Hack -- old "encryption" byte
54 * Hack -- simple "checksum" on the actual values
56 static u32b v_check
= 0L;
59 * Hack -- simple "checksum" on the encoded bytes
61 static u32b x_check
= 0L;
65 * Hack -- Show information on the screen, one line at a time.
67 * Avoid the top two lines, to avoid interference with "msg_print()".
69 static void note(cptr msg
)
73 /* Draw the message */
76 /* Advance one line (wrap if needed) */
85 * This function determines if the version of the savefile
86 * currently being read is older than version "x.y.z".
88 static bool older_than(int x
, int y
, int z
)
90 /* Much older, or much more recent */
91 if (sf_major
< x
) return (TRUE
);
92 if (sf_major
> x
) return (FALSE
);
94 /* Distinctly older, or distinctly more recent */
95 if (sf_minor
< y
) return (TRUE
);
96 if (sf_minor
> y
) return (FALSE
);
98 /* Barely older, or barely more recent */
99 if (sf_patch
< z
) return (TRUE
);
100 if (sf_patch
> z
) return (FALSE
);
102 /* Identical versions */
108 * Hack -- determine if an item is "wearable" (or a missile)
110 static bool wearable_p(const object_type
*o_ptr
)
112 /* Valid "tval" codes */
146 * The following functions are used to load the basic building blocks
147 * of savefiles. They also maintain the "checksum" info.
150 static byte
sf_get(void)
154 /* Get a character, decode the value */
155 c
= getc(fff
) & 0xFF;
159 /* Maintain the checksum info */
163 /* Return the value */
167 static void rd_byte(byte
*ip
)
172 static void rd_u16b(u16b
*ip
)
175 (*ip
) |= ((u16b
)(sf_get()) << 8);
178 static void rd_s16b(s16b
*ip
)
183 static void rd_u32b(u32b
*ip
)
186 (*ip
) |= ((u32b
)(sf_get()) << 8);
187 (*ip
) |= ((u32b
)(sf_get()) << 16);
188 (*ip
) |= ((u32b
)(sf_get()) << 24);
191 static void rd_s32b(s32b
*ip
)
198 * Hack -- read a string
200 static void rd_string(char *str
, int max
)
204 /* Read the string */
205 for (i
= 0; TRUE
; i
++)
212 /* Collect string while legal */
213 if (i
< max
) str
[i
] = tmp8u
;
225 * Hack -- strip some bytes
227 static void strip_bytes(int n
)
231 /* Strip the bytes */
232 while (n
--) rd_byte(&tmp8u
);
239 * This function attempts to "repair" old savefiles, and to extract
240 * the most up to date values for various object fields.
242 static errr
rd_item(object_type
*o_ptr
)
255 rd_s16b(&o_ptr
->k_idx
);
258 if ((o_ptr
->k_idx
< 0) || (o_ptr
->k_idx
>= z_info
->k_max
))
266 rd_byte(&o_ptr
->tval
);
267 rd_byte(&o_ptr
->sval
);
268 rd_s16b(&o_ptr
->pval
);
271 rd_byte(&o_ptr
->pseudo
);
274 if (o_ptr
->pseudo
> 99)
275 o_ptr
->pseudo
-= 100;
277 rd_byte(&o_ptr
->number
);
278 rd_s16b(&o_ptr
->weight
);
280 rd_byte(&o_ptr
->name1
);
281 rd_byte(&o_ptr
->name2
);
283 rd_s16b(&o_ptr
->timeout
);
285 rd_s16b(&o_ptr
->to_h
);
286 rd_s16b(&o_ptr
->to_d
);
287 rd_s16b(&o_ptr
->to_a
);
294 rd_byte(&o_ptr
->ident
);
296 rd_byte(&o_ptr
->marked
);
301 /* Monster holding object */
302 rd_s16b(&o_ptr
->held_m_idx
);
305 rd_byte(&o_ptr
->xtra1
);
306 rd_byte(&o_ptr
->xtra2
);
309 rd_string(buf
, sizeof(buf
));
311 /* Save the inscription */
312 if (buf
[0]) o_ptr
->note
= quark_add(buf
);
314 /* Obtain the "kind" template */
315 k_ptr
= &k_info
[o_ptr
->k_idx
];
317 /* Obtain tval/sval from k_info */
318 o_ptr
->tval
= k_ptr
->tval
;
319 o_ptr
->sval
= k_ptr
->sval
;
322 /* Hack -- notice "broken" items */
323 if (k_ptr
->cost
<= 0) o_ptr
->ident
|= (IDENT_BROKEN
);
327 * Ensure that rods and wands get the appropriate pvals,
328 * and transfer rod charges to timeout.
329 * this test should only be passed once, the first
330 * time the file is open with ROD/WAND stacking code
331 * It could change the timeout improperly if the PVAL (time a rod
332 * takes to charge after use) is changed in object.txt.
333 * But this is nothing a little resting won't solve.
337 if ((o_ptr
->tval
== TV_ROD
) &&
338 (o_ptr
->pval
- (k_ptr
->pval
* o_ptr
->number
) != 0))
340 o_ptr
->timeout
= o_ptr
->pval
;
341 o_ptr
->pval
= k_ptr
->pval
* o_ptr
->number
;
344 if (older_than(3, 0, 4))
346 /* Recalculate charges of stacked wands and staves */
347 if ((o_ptr
->tval
== TV_WAND
) || (o_ptr
->tval
== TV_STAFF
))
349 o_ptr
->pval
= o_ptr
->pval
* o_ptr
->number
;
353 /* Repair non "wearable" items */
354 if (!wearable_p(o_ptr
))
356 /* Get the correct fields */
357 o_ptr
->to_h
= k_ptr
->to_h
;
358 o_ptr
->to_d
= k_ptr
->to_d
;
359 o_ptr
->to_a
= k_ptr
->to_a
;
361 /* Get the correct fields */
362 o_ptr
->ac
= k_ptr
->ac
;
363 o_ptr
->dd
= k_ptr
->dd
;
364 o_ptr
->ds
= k_ptr
->ds
;
366 /* Get the correct weight */
367 o_ptr
->weight
= k_ptr
->weight
;
370 o_ptr
->name1
= o_ptr
->name2
= 0;
377 /* Extract the flags */
378 object_flags(o_ptr
, &f1
, &f2
, &f3
);
384 artifact_type
*a_ptr
;
387 if (o_ptr
->name1
>= z_info
->a_max
) return (-1);
389 /* Obtain the artifact info */
390 a_ptr
= &a_info
[o_ptr
->name1
];
392 /* Verify that artifact */
393 if (!a_ptr
->name
) o_ptr
->name1
= 0;
399 ego_item_type
*e_ptr
;
402 if (o_ptr
->name2
>= z_info
->e_max
) return (-1);
404 /* Obtain the ego-item info */
405 e_ptr
= &e_info
[o_ptr
->name2
];
407 /* Verify that ego-item */
408 if (!e_ptr
->name
) o_ptr
->name2
= 0;
412 /* Get the standard fields */
413 o_ptr
->ac
= k_ptr
->ac
;
414 o_ptr
->dd
= k_ptr
->dd
;
415 o_ptr
->ds
= k_ptr
->ds
;
417 /* Get the standard weight */
418 o_ptr
->weight
= k_ptr
->weight
;
420 /* Hack -- extract the "broken" flag */
421 if (o_ptr
->pval
< 0) o_ptr
->ident
|= (IDENT_BROKEN
);
427 artifact_type
*a_ptr
;
429 /* Obtain the artifact info */
430 a_ptr
= &a_info
[o_ptr
->name1
];
432 /* Get the new artifact "pval" */
433 o_ptr
->pval
= a_ptr
->pval
;
435 /* Get the new artifact fields */
436 o_ptr
->ac
= a_ptr
->ac
;
437 o_ptr
->dd
= a_ptr
->dd
;
438 o_ptr
->ds
= a_ptr
->ds
;
440 /* Get the new artifact weight */
441 o_ptr
->weight
= a_ptr
->weight
;
443 /* Hack -- extract the "broken" flag */
444 if (!a_ptr
->cost
) o_ptr
->ident
|= (IDENT_BROKEN
);
450 ego_item_type
*e_ptr
;
452 /* Obtain the ego-item info */
453 e_ptr
= &e_info
[o_ptr
->name2
];
455 /* Hack -- keep some old fields */
456 if ((o_ptr
->dd
< old_dd
) && (o_ptr
->ds
== old_ds
))
458 /* Keep old boosted damage dice */
462 /* Hack -- extract the "broken" flag */
463 if (!e_ptr
->cost
) o_ptr
->ident
|= (IDENT_BROKEN
);
465 /* Hack -- enforce legal pval */
466 if (e_ptr
->flags1
& (TR1_PVAL_MASK
))
468 /* Force a meaningful pval */
469 if (!o_ptr
->pval
) o_ptr
->pval
= 1;
472 /* Mega-Hack - Enforce the special broken items */
473 if ((o_ptr
->name2
== EGO_BLASTED
) ||
474 (o_ptr
->name2
== EGO_SHATTERED
))
476 /* These were set to k_info values by preceding code */
483 if (older_than(3, 0, 9) &&
484 o_ptr
->tval
== TV_LITE
&&
485 !artifact_p(o_ptr
) &&
486 !ego_item_p(o_ptr
) &&
489 o_ptr
->timeout
= o_ptr
->pval
;
504 static void rd_monster(monster_type
*m_ptr
)
508 /* Read the monster race */
509 rd_s16b(&m_ptr
->r_idx
);
511 /* Read the other information */
515 rd_s16b(&m_ptr
->maxhp
);
516 rd_s16b(&m_ptr
->csleep
);
517 rd_byte(&m_ptr
->mspeed
);
518 rd_byte(&m_ptr
->energy
);
519 rd_byte(&m_ptr
->stunned
);
520 rd_byte(&m_ptr
->confused
);
521 rd_byte(&m_ptr
->monfear
);
530 * Read the monster lore
532 static void rd_lore(int r_idx
)
537 monster_race
*r_ptr
= &r_info
[r_idx
];
538 monster_lore
*l_ptr
= &l_list
[r_idx
];
541 /* Count sights/deaths/kills */
542 rd_s16b(&l_ptr
->sights
);
543 rd_s16b(&l_ptr
->deaths
);
544 rd_s16b(&l_ptr
->pkills
);
545 rd_s16b(&l_ptr
->tkills
);
547 /* Count wakes and ignores */
548 rd_byte(&l_ptr
->wake
);
549 rd_byte(&l_ptr
->ignore
);
552 rd_byte(&l_ptr
->xtra1
);
553 rd_byte(&l_ptr
->xtra2
);
556 rd_byte(&l_ptr
->drop_gold
);
557 rd_byte(&l_ptr
->drop_item
);
560 rd_byte(&l_ptr
->cast_innate
);
561 rd_byte(&l_ptr
->cast_spell
);
563 /* Count blows of each type */
564 for (i
= 0; i
< MONSTER_BLOW_MAX
; i
++)
565 rd_byte(&l_ptr
->blows
[i
]);
568 rd_u32b(&l_ptr
->flags1
);
569 rd_u32b(&l_ptr
->flags2
);
570 rd_u32b(&l_ptr
->flags3
);
571 rd_u32b(&l_ptr
->flags4
);
572 rd_u32b(&l_ptr
->flags5
);
573 rd_u32b(&l_ptr
->flags6
);
576 /* Read the "Racial" monster limit per level */
577 rd_byte(&r_ptr
->max_num
);
585 /* Repair the lore flags */
586 l_ptr
->flags1
&= r_ptr
->flags1
;
587 l_ptr
->flags2
&= r_ptr
->flags2
;
588 l_ptr
->flags3
&= r_ptr
->flags3
;
589 l_ptr
->flags4
&= r_ptr
->flags4
;
590 l_ptr
->flags5
&= r_ptr
->flags5
;
591 l_ptr
->flags6
&= r_ptr
->flags6
;
600 static errr
rd_store(int n
)
602 store_type
*st_ptr
= &store
[n
];
611 /* Read the basic info */
619 if (own
>= z_info
->b_max
)
621 note("Illegal store owner!");
628 for (j
= 0; j
< num
; j
++)
631 object_type object_type_body
;
633 /* Get local object */
634 i_ptr
= &object_type_body
;
636 /* Wipe the object */
642 note("Error reading item");
646 /* Pre-3.0.2 objects in store inventories need to be marked */
647 if (older_than(3, 0, 2))
649 if (n
!= STORE_HOME
) i_ptr
->ident
|= IDENT_STORE
;
652 /* Accept any valid items */
653 if (st_ptr
->stock_num
< STORE_INVEN_MAX
)
655 int k
= st_ptr
->stock_num
++;
657 /* Accept the item */
658 object_copy(&st_ptr
->stock
[k
], i_ptr
);
671 static void rd_randomizer(void)
682 rd_u16b(&Rand_place
);
685 for (i
= 0; i
< RAND_DEG
; i
++)
687 rd_u32b(&Rand_state
[i
]);
699 * Note that the normal options are stored as a set of 256 bit flags,
700 * plus a set of 256 bit masks to indicate which bit flags were defined
701 * at the time the savefile was created. This will allow new options
702 * to be added, and old options to be removed, at any time, without
703 * hurting old savefiles.
705 * The window options are stored in the same way, but note that each
706 * window gets 32 options, and their order is fixed by certain defines.
708 static void rd_options(void)
718 u32b window_flag
[ANGBAND_TERM_MAX
];
719 u32b window_mask
[ANGBAND_TERM_MAX
];
724 /* Ignore old options */
730 /* Read "delay_factor" */
732 op_ptr
->delay_factor
= b
;
734 /* Read "hitpoint_warn" */
736 op_ptr
->hitpoint_warn
= b
;
738 /* Old cheating options */
742 /*** Normal Options ***/
744 /* Read the option flags */
745 for (n
= 0; n
< 8; n
++) rd_u32b(&flag
[n
]);
747 /* Read the option masks */
748 for (n
= 0; n
< 8; n
++) rd_u32b(&mask
[n
]);
750 /* Analyze the options */
751 for (i
= 0; i
< OPT_MAX
; i
++)
756 /* Process saved entries */
757 if (mask
[os
] & (1L << ob
))
760 if (flag
[os
] & (1L << ob
))
761 op_ptr
->opt
[i
] = TRUE
;
765 op_ptr
->opt
[i
] = FALSE
;
769 /* Load savefiles pre-reorganisation */
770 if (older_than(3, 0, 8))
773 * Slot Old layout: New layout:
776 * 2 maximise autoscum
778 * 4 ironman no_stores
779 * 5 no_stores no_artifacts
780 * 6 no_artifats no_stacking
781 * 7 randarts no_preserve
782 * 8 no_stacking no_stairs
785 /* We #define this so it's obvious what we're doing */
786 #define OLD_OPT(n) op_ptr->opt[n]
789 for (i
= 0; i
<= 8; i
++)
790 old_birth
[i
] = OLD_OPT(OPT_BIRTH
+ i
);
792 if (arg_fiddle
) note("Loading pre-3.0.7 options...");
794 birth_maximize
= adult_maximize
= old_birth
[2];
795 birth_no_preserve
= adult_no_preserve
= !old_birth
[3];
796 birth_ironman
= adult_ironman
= old_birth
[4];
797 birth_no_stores
= adult_no_stores
= old_birth
[5];
798 birth_no_artifacts
= adult_no_artifacts
= old_birth
[6];
799 birth_randarts
= adult_randarts
= old_birth
[7];
800 birth_no_stacking
= adult_no_stacking
= old_birth
[8];
802 birth_no_stairs
= adult_no_stairs
= !OLD_OPT(41);
803 birth_autoscum
= adult_autoscum
= OLD_OPT(33);
804 birth_ai_sound
= adult_ai_sound
= OLD_OPT(42);
805 birth_ai_smell
= adult_ai_smell
= OLD_OPT(43);
806 birth_ai_packs
= adult_ai_packs
= OLD_OPT(73);
807 birth_ai_learn
= adult_ai_learn
= OLD_OPT(46);
808 birth_ai_cheat
= adult_ai_cheat
= OLD_OPT(47);
809 birth_ai_smart
= adult_ai_smart
= OLD_OPT(72);
814 /*** Window Options ***/
816 /* Read the window flags */
817 for (n
= 0; n
< ANGBAND_TERM_MAX
; n
++)
819 rd_u32b(&window_flag
[n
]);
822 /* Read the window masks */
823 for (n
= 0; n
< ANGBAND_TERM_MAX
; n
++)
825 rd_u32b(&window_mask
[n
]);
828 /* Analyze the options */
829 for (n
= 0; n
< ANGBAND_TERM_MAX
; n
++)
831 /* Analyze the options */
832 for (i
= 0; i
< 32; i
++)
834 /* Process valid flags */
835 if (window_flag_desc
[i
])
837 /* Process valid flags */
838 if (window_mask
[n
] & (1L << i
))
841 if (window_flag
[n
] & (1L << i
))
844 op_ptr
->window_flag
[n
] |= (1L << i
);
857 * Hack -- strip the "ghost" info
859 * XXX XXX XXX This is such a nasty hack it hurts.
861 static void rd_ghost(void)
873 static u32b randart_version
;
876 static errr
rd_player_spells(void)
881 if (older_than(2, 9, 8))
883 /* The magic spells were changed drastically in Angband 2.9.7 */
884 if (older_than(2, 9, 7) &&
885 (c_info
[p_ptr
->pclass
].spell_book
== TV_MAGIC_BOOK
))
887 /* Discard old spell info */
890 /* Discard old spell order */
893 /* None of the spells have been learned yet */
894 for (i
= 0; i
< 64; i
++)
895 p_ptr
->spell_order
[i
] = 99;
899 u32b spell_learned1
, spell_learned2
;
900 u32b spell_worked1
, spell_worked2
;
901 u32b spell_forgotten1
, spell_forgotten2
;
903 /* Read spell info */
904 rd_u32b(&spell_learned1
);
905 rd_u32b(&spell_learned2
);
906 rd_u32b(&spell_worked1
);
907 rd_u32b(&spell_worked2
);
908 rd_u32b(&spell_forgotten1
);
909 rd_u32b(&spell_forgotten2
);
911 for (i
= 0; i
< 64; i
++)
915 if (spell_learned1
& (1L << i
))
916 p_ptr
->spell_flags
[i
] |= PY_SPELL_LEARNED
;
917 if (spell_worked1
& (1L << i
))
918 p_ptr
->spell_flags
[i
] |= PY_SPELL_WORKED
;
919 if (spell_forgotten1
& (1L << i
))
920 p_ptr
->spell_flags
[i
] |= PY_SPELL_FORGOTTEN
;
924 if (spell_learned2
& (1L << (i
- 32)))
925 p_ptr
->spell_flags
[i
] |= PY_SPELL_LEARNED
;
926 if (spell_worked2
& (1L << (i
- 32)))
927 p_ptr
->spell_flags
[i
] |= PY_SPELL_WORKED
;
928 if (spell_forgotten2
& (1L << (i
- 32)))
929 p_ptr
->spell_flags
[i
] |= PY_SPELL_FORGOTTEN
;
933 for (i
= 0; i
< 64; i
++)
935 rd_byte(&p_ptr
->spell_order
[i
]);
941 /* Read the number of spells */
943 if (tmp16u
> PY_MAX_SPELLS
)
945 note(format("Too many player spells (%d).", tmp16u
));
949 /* Read the spell flags */
950 for (i
= 0; i
< tmp16u
; i
++)
952 rd_byte(&p_ptr
->spell_flags
[i
]);
955 /* Read the spell order */
956 for (i
= 0; i
< tmp16u
; i
++)
958 rd_byte(&p_ptr
->spell_order
[i
]);
967 * Read squelch and autoinscription submenu for all known objects
969 static int rd_squelch(void)
974 /* Handle old versions, and Pete Mack's patch */
975 if (older_than(3, 0, 6))
979 /* Read how many squelch bytes we have */
980 if (!older_than(3, 0, 9))
983 /* Check against current number */
984 if (tmp8u
!= SQUELCH_BYTES
)
990 for (i
= 0; i
< SQUELCH_BYTES
; i
++)
991 rd_byte(&squelch_level
[i
]);
994 /* Handle ego-item squelch */
995 if ((sf_major
== 3) && (sf_minor
== 0) && (sf_patch
!= 9))
999 /* Read the number of saved ego-item */
1000 rd_u16b(&file_e_max
);
1002 for (i
= 0; i
< file_e_max
; i
++)
1004 if (i
< z_info
->e_max
)
1008 /* Read and extract the flag */
1010 e_info
[i
].everseen
|= (flags
& 0x02);
1018 /* Read the current number of auto-inscriptions */
1019 rd_u16b(&inscriptions_count
);
1021 /* Write the autoinscriptions array*/
1022 for (i
= 0; i
< inscriptions_count
; i
++)
1026 rd_s16b(&inscriptions
[i
].kind_idx
);
1027 rd_string(tmp
, sizeof(tmp
));
1029 inscriptions
[i
].inscription_idx
= quark_add(tmp
);
1037 * Read the "extra" information
1039 static errr
rd_extra(void)
1047 rd_string(op_ptr
->full_name
, sizeof(op_ptr
->full_name
));
1049 rd_string(p_ptr
->died_from
, 80);
1051 if (older_than(3, 0, 1))
1053 char *hist
= p_ptr
->history
;
1055 for (i
= 0; i
< 4; i
++)
1057 /* Read a part of the history */
1058 rd_string(hist
, 60);
1061 hist
+= strlen(hist
);
1063 /* Separate by spaces */
1068 /* Make sure it is terminated */
1073 rd_string(p_ptr
->history
, 250);
1077 rd_byte(&p_ptr
->prace
);
1079 /* Verify player race */
1080 if (p_ptr
->prace
>= z_info
->p_max
)
1082 note(format("Invalid player race (%d).", p_ptr
->prace
));
1087 rd_byte(&p_ptr
->pclass
);
1089 /* Verify player class */
1090 if (p_ptr
->pclass
>= z_info
->c_max
)
1092 note(format("Invalid player class (%d).", p_ptr
->pclass
));
1097 rd_byte(&p_ptr
->psex
);
1101 /* Special Race/Class info */
1102 rd_byte(&p_ptr
->hitdie
);
1103 rd_byte(&p_ptr
->expfact
);
1105 /* Age/Height/Weight */
1106 rd_s16b(&p_ptr
->age
);
1107 rd_s16b(&p_ptr
->ht
);
1108 rd_s16b(&p_ptr
->wt
);
1110 /* Read the stat info */
1111 for (i
= 0; i
< A_MAX
; i
++) rd_s16b(&p_ptr
->stat_max
[i
]);
1112 for (i
= 0; i
< A_MAX
; i
++) rd_s16b(&p_ptr
->stat_cur
[i
]);
1114 strip_bytes(24); /* oops */
1116 rd_s32b(&p_ptr
->au
);
1118 rd_s32b(&p_ptr
->max_exp
);
1119 rd_s32b(&p_ptr
->exp
);
1120 rd_u16b(&p_ptr
->exp_frac
);
1122 rd_s16b(&p_ptr
->lev
);
1124 /* Verify player level */
1125 if ((p_ptr
->lev
< 1) || (p_ptr
->lev
> PY_MAX_LEVEL
))
1127 note(format("Invalid player level (%d).", p_ptr
->lev
));
1131 rd_s16b(&p_ptr
->mhp
);
1132 rd_s16b(&p_ptr
->chp
);
1133 rd_u16b(&p_ptr
->chp_frac
);
1135 rd_s16b(&p_ptr
->msp
);
1136 rd_s16b(&p_ptr
->csp
);
1137 rd_u16b(&p_ptr
->csp_frac
);
1139 rd_s16b(&p_ptr
->max_lev
);
1140 rd_s16b(&p_ptr
->max_depth
);
1142 /* Hack -- Repair maximum player level */
1143 if (p_ptr
->max_lev
< p_ptr
->lev
) p_ptr
->max_lev
= p_ptr
->lev
;
1145 /* Hack -- Repair maximum dungeon level */
1146 if (p_ptr
->max_depth
< 0) p_ptr
->max_depth
= 1;
1150 rd_s16b(&p_ptr
->sc
);
1153 /* Read the flags */
1154 if (older_than(3, 0, 7))
1156 strip_bytes(2); /* Old "rest" */
1157 rd_s16b(&p_ptr
->timed
[TMD_BLIND
]);
1158 rd_s16b(&p_ptr
->timed
[TMD_PARALYZED
]);
1159 rd_s16b(&p_ptr
->timed
[TMD_CONFUSED
]);
1160 rd_s16b(&p_ptr
->food
);
1161 strip_bytes(4); /* Old "food_digested" / "protection" */
1162 rd_s16b(&p_ptr
->energy
);
1163 rd_s16b(&p_ptr
->timed
[TMD_FAST
]);
1164 rd_s16b(&p_ptr
->timed
[TMD_SLOW
]);
1165 rd_s16b(&p_ptr
->timed
[TMD_AFRAID
]);
1166 rd_s16b(&p_ptr
->timed
[TMD_CUT
]);
1167 rd_s16b(&p_ptr
->timed
[TMD_STUN
]);
1168 rd_s16b(&p_ptr
->timed
[TMD_POISONED
]);
1169 rd_s16b(&p_ptr
->timed
[TMD_IMAGE
]);
1170 rd_s16b(&p_ptr
->timed
[TMD_PROTEVIL
]);
1171 rd_s16b(&p_ptr
->timed
[TMD_INVULN
]);
1172 rd_s16b(&p_ptr
->timed
[TMD_HERO
]);
1173 rd_s16b(&p_ptr
->timed
[TMD_SHERO
]);
1174 rd_s16b(&p_ptr
->timed
[TMD_SHIELD
]);
1175 rd_s16b(&p_ptr
->timed
[TMD_BLESSED
]);
1176 rd_s16b(&p_ptr
->timed
[TMD_SINVIS
]);
1177 rd_s16b(&p_ptr
->word_recall
);
1178 rd_s16b(&p_ptr
->see_infra
);
1179 rd_s16b(&p_ptr
->timed
[TMD_SINFRA
]);
1180 rd_s16b(&p_ptr
->timed
[TMD_OPP_FIRE
]);
1181 rd_s16b(&p_ptr
->timed
[TMD_OPP_COLD
]);
1182 rd_s16b(&p_ptr
->timed
[TMD_OPP_ACID
]);
1183 rd_s16b(&p_ptr
->timed
[TMD_OPP_ELEC
]);
1184 rd_s16b(&p_ptr
->timed
[TMD_OPP_POIS
]);
1186 rd_byte(&p_ptr
->confusing
);
1187 rd_byte(&tmp8u
); /* oops */
1188 rd_byte(&tmp8u
); /* oops */
1189 rd_byte(&tmp8u
); /* oops */
1190 rd_byte(&p_ptr
->searching
);
1191 rd_byte(&tmp8u
); /* oops */
1192 rd_byte(&tmp8u
); /* oops */
1193 rd_byte(&tmp8u
); /* oops */
1200 rd_s16b(&p_ptr
->food
);
1201 rd_s16b(&p_ptr
->energy
);
1202 rd_s16b(&p_ptr
->word_recall
);
1203 rd_s16b(&p_ptr
->see_infra
);
1204 rd_byte(&p_ptr
->confusing
);
1205 rd_byte(&p_ptr
->searching
);
1207 /* Find the number of timed effects */
1212 /* Read all the effects */
1213 for (i
= 0; i
< num
; i
++)
1214 rd_s16b(&p_ptr
->timed
[i
]);
1216 /* Initialize any entries not read */
1218 C_WIPE(p_ptr
->timed
+ num
, TMD_MAX
- num
, s16b
);
1222 /* Probably in trouble anyway */
1223 for (i
= 0; i
< TMD_MAX
; i
++)
1224 rd_s16b(&p_ptr
->timed
[i
]);
1226 /* Discard unused entries */
1227 strip_bytes(2 * (num
- TMD_MAX
));
1228 note("Discarded unsupported timed effects");
1235 /* Read item-quality squelch sub-menu */
1236 if (rd_squelch()) return -1;
1238 /* Read the randart version */
1239 rd_u32b(&randart_version
);
1241 /* Read the randart seed */
1242 rd_u32b(&seed_randart
);
1244 /* Skip the flags */
1248 /* Hack -- the two "special seeds" */
1249 rd_u32b(&seed_flavor
);
1250 rd_u32b(&seed_town
);
1254 rd_u16b(&p_ptr
->panic_save
);
1255 rd_u16b(&p_ptr
->total_winner
);
1256 rd_u16b(&p_ptr
->noscore
);
1261 p_ptr
->is_dead
= tmp8u
;
1263 /* Read "feeling" */
1267 /* Turn of last "feeling" */
1274 /* Read the player_hp array */
1277 /* Incompatible save files */
1278 if (tmp16u
> PY_MAX_LEVEL
)
1280 note(format("Too many (%u) hitpoint entries!", tmp16u
));
1284 /* Read the player_hp array */
1285 for (i
= 0; i
< tmp16u
; i
++)
1287 rd_s16b(&p_ptr
->player_hp
[i
]);
1290 /* Read the player spells */
1291 if (rd_player_spells()) return (-1);
1298 * Read the random artifacts
1300 static errr
rd_randarts(void)
1306 u16b artifact_count
;
1311 if (older_than(2, 9, 3))
1315 * Importing old savefiles with random artifacts is dangerous
1316 * since the randart-generators differ and produce different
1317 * artifacts from the same random seed.
1319 * Switching off the check for incompatible randart versions
1320 * allows to import such a savefile - do it at your own risk.
1323 /* Check for incompatible randart version */
1324 if (randart_version
!= RANDART_VERSION
)
1326 note(format("Incompatible random artifacts version!"));
1330 /* Initialize randarts */
1331 do_randart(seed_randart
, TRUE
);
1335 /* Read the number of artifacts */
1336 rd_u16b(&artifact_count
);
1338 /* Alive or cheating death */
1339 if (!p_ptr
->is_dead
|| arg_wizard
)
1341 /* Incompatible save files */
1342 if (artifact_count
> z_info
->a_max
)
1344 note(format("Too many (%u) random artifacts!", artifact_count
));
1348 /* Mark the old artifacts as "empty" */
1349 for (i
= 0; i
< z_info
->a_max
; i
++)
1351 artifact_type
*a_ptr
= &a_info
[i
];
1357 /* Read the artifacts */
1358 for (i
= 0; i
< artifact_count
; i
++)
1360 artifact_type
*a_ptr
= &a_info
[i
];
1362 rd_byte(&a_ptr
->tval
);
1363 rd_byte(&a_ptr
->sval
);
1364 rd_s16b(&a_ptr
->pval
);
1366 rd_s16b(&a_ptr
->to_h
);
1367 rd_s16b(&a_ptr
->to_d
);
1368 rd_s16b(&a_ptr
->to_a
);
1369 rd_s16b(&a_ptr
->ac
);
1371 rd_byte(&a_ptr
->dd
);
1372 rd_byte(&a_ptr
->ds
);
1374 rd_s16b(&a_ptr
->weight
);
1376 rd_s32b(&a_ptr
->cost
);
1378 rd_u32b(&a_ptr
->flags1
);
1379 rd_u32b(&a_ptr
->flags2
);
1380 rd_u32b(&a_ptr
->flags3
);
1382 rd_byte(&a_ptr
->level
);
1383 rd_byte(&a_ptr
->rarity
);
1385 rd_byte(&a_ptr
->activation
);
1386 rd_u16b(&a_ptr
->time
);
1387 rd_u16b(&a_ptr
->randtime
);
1392 /* Read the artifacts */
1393 for (i
= 0; i
< artifact_count
; i
++)
1395 rd_byte(&tmp8u
); /* a_ptr->tval */
1396 rd_byte(&tmp8u
); /* a_ptr->sval */
1397 rd_s16b(&tmp16s
); /* a_ptr->pval */
1399 rd_s16b(&tmp16s
); /* a_ptr->to_h */
1400 rd_s16b(&tmp16s
); /* a_ptr->to_d */
1401 rd_s16b(&tmp16s
); /* a_ptr->to_a */
1402 rd_s16b(&tmp16s
); /* a_ptr->ac */
1404 rd_byte(&tmp8u
); /* a_ptr->dd */
1405 rd_byte(&tmp8u
); /* a_ptr->ds */
1407 rd_s16b(&tmp16s
); /* a_ptr->weight */
1409 rd_s32b(&tmp32s
); /* a_ptr->cost */
1411 rd_u32b(&tmp32u
); /* a_ptr->flags1 */
1412 rd_u32b(&tmp32u
); /* a_ptr->flags2 */
1413 rd_u32b(&tmp32u
); /* a_ptr->flags3 */
1415 rd_byte(&tmp8u
); /* a_ptr->level */
1416 rd_byte(&tmp8u
); /* a_ptr->rarity */
1418 rd_byte(&tmp8u
); /* a_ptr->activation */
1419 rd_u16b(&tmp16u
); /* a_ptr->time */
1420 rd_u16b(&tmp16u
); /* a_ptr->randtime */
1424 /* Initialize only the randart names */
1425 do_randart(seed_randart
, FALSE
);
1435 * Read the player inventory
1437 * Note that the inventory is "re-sorted" later by "dungeon()".
1439 static errr
rd_inventory(void)
1444 object_type object_type_body
;
1446 /* Read until done */
1451 /* Get the next item index */
1454 /* Nope, we reached the end */
1455 if (n
== 0xFFFF) break;
1457 /* Get local object */
1458 i_ptr
= &object_type_body
;
1460 /* Wipe the object */
1466 note("Error reading item");
1470 /* Hack -- verify item */
1471 if (!i_ptr
->k_idx
) return (-1);
1474 if (n
>= INVEN_TOTAL
) return (-1);
1476 /* Wield equipment */
1477 if (n
>= INVEN_WIELD
)
1480 object_copy(&inventory
[n
], i_ptr
);
1482 /* Add the weight */
1483 p_ptr
->total_weight
+= (i_ptr
->number
* i_ptr
->weight
);
1489 /* Warning -- backpack is full */
1490 else if (p_ptr
->inven_cnt
== INVEN_PACK
)
1493 note("Too many items in the inventory!");
1499 /* Carry inventory */
1506 object_copy(&inventory
[n
], i_ptr
);
1508 /* Add the weight */
1509 p_ptr
->total_weight
+= (i_ptr
->number
* i_ptr
->weight
);
1523 * Read the saved messages
1525 static void rd_messages(void)
1536 /* Read the messages */
1537 for (i
= 0; i
< num
; i
++)
1539 /* Read the message */
1540 rd_string(buf
, sizeof(buf
));
1542 /* Read the message type */
1543 if (!older_than(2, 9, 1))
1546 tmp16u
= MSG_GENERIC
;
1548 /* Save the message */
1549 message_add(buf
, tmp16u
);
1557 * The monsters/objects must be loaded in the same order
1558 * that they were stored, since the actual indexes matter.
1560 * Note that the size of the dungeon is now hard-coded to
1561 * DUNGEON_HGT by DUNGEON_WID, and any dungeon with another
1562 * size will be silently discarded by this routine.
1564 * Note that dungeon objects, including objects held by monsters, are
1565 * placed directly into the dungeon, using "object_copy()", which will
1566 * copy "iy", "ix", and "held_m_idx", leaving "next_o_idx" blank for
1567 * objects held by monsters, since it is not saved in the savefile.
1569 * After loading the monsters, the objects being held by monsters are
1570 * linked directly into those monsters.
1572 static errr
rd_dungeon(void)
1587 /*** Basic info ***/
1600 /* Ignore illegal dungeons */
1601 if ((depth
< 0) || (depth
>= MAX_DEPTH
))
1603 note(format("Ignoring illegal dungeon depth (%d)", depth
));
1607 /* Ignore illegal dungeons */
1608 if ((ymax
!= DUNGEON_HGT
) || (xmax
!= DUNGEON_WID
))
1611 note(format("Ignoring illegal dungeon size (%d,%d).", ymax
, xmax
));
1615 /* Ignore illegal dungeons */
1616 if ((px
< 0) || (px
>= DUNGEON_WID
) ||
1617 (py
< 0) || (py
>= DUNGEON_HGT
))
1619 note(format("Ignoring illegal player location (%d,%d).", py
, px
));
1624 /*** Run length decoding ***/
1626 /* Load the dungeon data */
1627 for (x
= y
= 0; y
< DUNGEON_HGT
; )
1633 /* Apply the RLE info */
1634 for (i
= count
; i
> 0; i
--)
1636 /* Extract "info" */
1637 cave_info
[y
][x
] = tmp8u
;
1640 if (++x
>= DUNGEON_WID
)
1646 if (++y
>= DUNGEON_HGT
) break;
1652 /*** Run length decoding ***/
1654 /* Load the dungeon data */
1655 for (x
= y
= 0; y
< DUNGEON_HGT
; )
1661 /* Apply the RLE info */
1662 for (i
= count
; i
> 0; i
--)
1664 /* Extract "feat" */
1665 cave_set_feat(y
, x
, tmp8u
);
1668 if (++x
>= DUNGEON_WID
)
1674 if (++y
>= DUNGEON_HGT
) break;
1683 p_ptr
->depth
= depth
;
1686 /* Place player in dungeon */
1687 if (!player_place(py
, px
))
1689 note(format("Cannot place player (%d,%d)!", py
, px
));
1696 /* Read the item count */
1699 /* Verify maximum */
1700 if (limit
> z_info
->o_max
)
1702 note(format("Too many (%d) object entries!", limit
));
1706 /* Read the dungeon items */
1707 for (i
= 1; i
< limit
; i
++)
1710 object_type object_type_body
;
1716 /* Get the object */
1717 i_ptr
= &object_type_body
;
1719 /* Wipe the object */
1725 note("Error reading item");
1729 /* Make an object */
1735 note(format("Cannot place object %d!", i
));
1739 /* Get the object */
1740 o_ptr
= &o_list
[o_idx
];
1742 /* Structure Copy */
1743 object_copy(o_ptr
, i_ptr
);
1746 if (!i_ptr
->held_m_idx
)
1751 /* ToDo: Verify coordinates */
1753 /* Link the object to the pile */
1754 o_ptr
->next_o_idx
= cave_o_idx
[y
][x
];
1756 /* Link the floor to the object */
1757 cave_o_idx
[y
][x
] = o_idx
;
1764 /* Read the monster count */
1767 /* Hack -- verify */
1768 if (limit
> z_info
->m_max
)
1770 note(format("Too many (%d) monster entries!", limit
));
1774 /* Read the monsters */
1775 for (i
= 1; i
< limit
; i
++)
1777 monster_type
*n_ptr
;
1778 monster_type monster_type_body
;
1781 /* Get local monster */
1782 n_ptr
= &monster_type_body
;
1784 /* Clear the monster */
1785 (void)WIPE(n_ptr
, monster_type
);
1787 /* Read the monster */
1791 /* Place monster in dungeon */
1792 if (monster_place(n_ptr
->fy
, n_ptr
->fx
, n_ptr
) != i
)
1794 note(format("Cannot place monster %d", i
));
1802 /* Reacquire objects */
1803 for (i
= 1; i
< o_max
; ++i
)
1807 monster_type
*m_ptr
;
1809 /* Get the object */
1812 /* Ignore dungeon objects */
1813 if (!o_ptr
->held_m_idx
) continue;
1815 /* Verify monster index */
1816 if (o_ptr
->held_m_idx
> z_info
->m_max
)
1818 note("Invalid monster index");
1822 /* Get the monster */
1823 m_ptr
= &mon_list
[o_ptr
->held_m_idx
];
1825 /* Link the object to the pile */
1826 o_ptr
->next_o_idx
= m_ptr
->hold_o_idx
;
1828 /* Link the monster to the object */
1829 m_ptr
->hold_o_idx
= i
;
1835 /* The dungeon is ready */
1836 character_dungeon
= TRUE
;
1838 /* Regenerate town in post 2.9.3 versions */
1839 if (older_than(2, 9, 4) && (p_ptr
->depth
== 0))
1840 character_dungeon
= FALSE
;
1849 * Actually read the savefile
1851 static errr
rd_savefile_new_aux(void)
1859 u32b n_x_check
, n_v_check
;
1860 u32b o_x_check
, o_v_check
;
1863 /* Mention the savefile version */
1864 note(format("Loading a %d.%d.%d savefile...",
1865 sf_major
, sf_minor
, sf_patch
));
1867 /* Strip the version bytes */
1870 /* Hack -- decrypt */
1871 xor_byte
= sf_extra
;
1874 /* Clear the checksums */
1879 /* Operating system info */
1882 /* Time of savefile creation */
1885 /* Number of resurrections */
1888 /* Number of times played */
1892 /* Later use (always zero) */
1895 /* Later use (always zero) */
1899 /* Read RNG state */
1901 if (arg_fiddle
) note("Loaded Randomizer Info");
1904 /* Then the options */
1906 if (arg_fiddle
) note("Loaded Option Flags");
1909 /* Then the "messages" */
1911 if (arg_fiddle
) note("Loaded Messages");
1914 /* Monster Memory */
1917 /* Incompatible save files */
1918 if (tmp16u
> z_info
->r_max
)
1920 note(format("Too many (%u) monster races!", tmp16u
));
1924 /* Read the available records */
1925 for (i
= 0; i
< tmp16u
; i
++)
1930 if (arg_fiddle
) note("Loaded Monster Memory");
1936 /* Incompatible save files */
1937 if (tmp16u
> z_info
->k_max
)
1939 note(format("Too many (%u) object kinds!", tmp16u
));
1943 /* Read the object memory */
1944 for (i
= 0; i
< tmp16u
; i
++)
1947 object_kind
*k_ptr
= &k_info
[i
];
1951 k_ptr
->aware
= (tmp8u
& 0x01) ? TRUE
: FALSE
;
1952 k_ptr
->tried
= (tmp8u
& 0x02) ? TRUE
: FALSE
;
1953 k_ptr
->squelch
= (tmp8u
& 0x04) ? TRUE
: FALSE
;
1954 k_ptr
->everseen
= (tmp8u
& 0x08) ? TRUE
: FALSE
;
1956 /* Read the (old) squelch bit */
1957 if (older_than(3, 0, 9) && !older_than(3, 0, 6))
1962 k_ptr
->squelch
= TRUE
;
1964 k_ptr
->squelch
= FALSE
;
1968 if (arg_fiddle
) note("Loaded Object Memory");
1971 /* Load the Quests */
1974 /* Incompatible save files */
1975 if (tmp16u
> MAX_Q_IDX
)
1977 note(format("Too many (%u) quests!", tmp16u
));
1981 /* Load the Quests */
1982 for (i
= 0; i
< tmp16u
; i
++)
1985 q_list
[i
].level
= tmp8u
;
1990 if (arg_fiddle
) note("Loaded Quests");
1993 /* Load the Artifacts */
1996 /* Incompatible save files */
1997 if (tmp16u
> z_info
->a_max
)
1999 note(format("Too many (%u) artifacts!", tmp16u
));
2003 /* Read the artifact flags */
2004 for (i
= 0; i
< tmp16u
; i
++)
2007 a_info
[i
].cur_num
= tmp8u
;
2012 if (arg_fiddle
) note("Loaded Artifacts");
2015 /* Read the extra stuff */
2016 if (rd_extra()) return (-1);
2017 if (arg_fiddle
) note("Loaded extra information");
2020 /* Read random artifacts */
2023 if (rd_randarts()) return (-1);
2024 if (arg_fiddle
) note("Loaded Random Artifacts");
2028 /* Important -- Initialize the sex */
2029 sp_ptr
= &sex_info
[p_ptr
->psex
];
2031 /* Important -- Initialize the race/class */
2032 rp_ptr
= &p_info
[p_ptr
->prace
];
2033 cp_ptr
= &c_info
[p_ptr
->pclass
];
2035 /* Important -- Initialize the magic */
2036 mp_ptr
= &cp_ptr
->spells
;
2039 /* Read the inventory */
2042 note("Unable to read inventory");
2047 /* Read the stores */
2049 for (i
= 0; i
< tmp16u
; i
++)
2051 if (rd_store(i
)) return (-1);
2055 /* I'm not dead yet... */
2056 if (!p_ptr
->is_dead
)
2058 /* Dead players have no dungeon */
2059 note("Restoring Dungeon...");
2062 note("Error reading dungeon data");
2066 /* Read the ghost info */
2071 /* Save the checksum */
2072 n_v_check
= v_check
;
2074 /* Read the old checksum */
2075 rd_u32b(&o_v_check
);
2078 if (o_v_check
!= n_v_check
)
2080 note("Invalid checksum");
2084 /* Save the encoded checksum */
2085 n_x_check
= x_check
;
2087 /* Read the checksum */
2088 rd_u32b(&o_x_check
);
2091 if (o_x_check
!= n_x_check
)
2093 note("Invalid encoded checksum");
2098 /* Hack -- no ghosts */
2099 r_info
[z_info
->r_max
-1].max_num
= 0;
2108 * Actually read the savefile
2110 static errr
rd_savefile(void)
2114 /* Grab permissions */
2117 /* The savefile is a binary file */
2118 fff
= my_fopen(savefile
, "rb");
2120 /* Drop permissions */
2124 if (!fff
) return (-1);
2126 /* Call the sub-function */
2127 err
= rd_savefile_new_aux();
2129 /* Check for errors */
2130 if (ferror(fff
)) err
= -1;
2132 /* Close the file */
2141 * Attempt to Load a "savefile"
2143 * On multi-user systems, you may only "read" a savefile if you will be
2144 * allowed to "write" it later, this prevents painful situations in which
2145 * the player loads a savefile belonging to someone else, and then is not
2146 * allowed to save his game when he quits.
2148 * We return "TRUE" if the savefile was usable, and we set the
2149 * flag "character_loaded" if a real, living, character was loaded.
2151 * Note that we always try to load the "current" savefile, even if
2152 * there is no such file, so we must check for "empty" savefile names.
2154 bool load_player(bool *character_loaded
, bool *reusing_savefile
)
2162 cptr what
= "generic";
2167 p_ptr
->is_dead
= FALSE
;
2169 *character_loaded
= FALSE
;
2170 *reusing_savefile
= FALSE
;
2172 /* Allow empty savefile name */
2173 if (!savefile
[0]) return (TRUE
);
2175 /* Grab permissions */
2178 /* Open the savefile */
2179 fd
= fd_open(savefile
, O_RDONLY
);
2181 /* Drop permissions */
2187 /* Give a message */
2188 msg_print("Savefile does not exist.");
2195 /* Close the file */
2202 /* Grab permissions */
2205 /* Open the savefile */
2206 fd
= fd_open(savefile
, O_RDONLY
);
2208 /* Drop permissions */
2212 if (fd
< 0) err
= -1;
2214 /* Message (below) */
2215 if (err
) what
= "Cannot open savefile";
2221 /* Read the first four bytes */
2222 if (fd_read(fd
, (char*)(vvv
), sizeof(vvv
))) err
= -1;
2225 if (err
) what
= "Cannot read savefile";
2227 /* Close the file */
2234 /* Extract version */
2243 if (older_than(OLD_VERSION_MAJOR
, OLD_VERSION_MINOR
, OLD_VERSION_PATCH
))
2246 what
= "Savefile is too old";
2248 else if (!older_than(VERSION_MAJOR
, VERSION_MINOR
, VERSION_PATCH
+ 1))
2251 what
= "Savefile is from the future";
2255 /* Attempt to load */
2256 err
= rd_savefile();
2258 /* Message (below) */
2259 if (err
) what
= "Cannot parse savefile";
2267 if (!turn
) err
= -1;
2269 /* Message (below) */
2270 if (err
) what
= "Broken savefile";
2277 *reusing_savefile
= TRUE
;
2279 /* Give a conversion warning */
2280 if ((version_major
!= sf_major
) ||
2281 (version_minor
!= sf_minor
) ||
2282 (version_patch
!= sf_patch
))
2285 msg_format("Converted a %d.%d.%d savefile.",
2286 sf_major
, sf_minor
, sf_patch
);
2290 /* Player is dead */
2293 /* Cheat death (unless the character retired) */
2296 /* A character was loaded */
2297 *character_loaded
= TRUE
;
2299 /* Mark the savefile */
2300 p_ptr
->noscore
|= NOSCORE_WIZARD
;
2307 p_ptr
->is_dead
= FALSE
;
2313 turn
= old_turn
= 0;
2319 /* A character was loaded */
2320 *character_loaded
= TRUE
;
2323 if (p_ptr
->chp
>= 0)
2325 /* Reset cause of death */
2326 my_strcpy(p_ptr
->died_from
, "(alive and well)", sizeof(p_ptr
->died_from
));
2335 msg_format("Error (%s) reading %d.%d.%d savefile.",
2336 what
, sf_major
, sf_minor
, sf_patch
);