3 /* Purpose: support for loading savefiles -BEN- */
9 * This file loads savefiles from Angband 2.7.X and 2.8.X
11 * Ancient savefiles (pre-2.7.0) are loaded by another file.
13 * Note that Angband 2.7.0 through 2.7.3 are now officially obsolete,
14 * and savefiles from those versions may not be successfully converted.
16 * We attempt to prevent corrupt savefiles from inducing memory errors.
18 * Note that this file should not use the random number generator, the
19 * object flavors, the visual attr/char mappings, or anything else which
20 * is initialized *after* or *during* the "load character" function.
22 * This file assumes that the monster/object records are initialized
23 * to zero, and the race/kind tables have been loaded correctly. The
24 * order of object stacks is currently not saved in the savefiles, but
25 * the "next" pointers are saved, so all necessary knowledge is present.
27 * We should implement simple "savefile extenders" using some form of
28 * "sized" chunks of bytes, with a {size,type,data} format, so everyone
29 * can know the size, interested people can know the type, and the actual
30 * data is available to the parsing routines that acknowledge the type.
32 * Consider changing the "globe of invulnerability" code so that it
33 * takes some form of "maximum damage to protect from" in addition to
34 * the existing "number of turns to protect for", and where each hit
35 * by a monster will reduce the shield by that amount.
43 * Maximum number of tries for selection of a proper quest monster
49 * Local "savefile" pointer
54 * Hack -- old "encryption" byte
59 * Hack -- simple "checksum" on the actual values
61 static u32b v_check = 0L;
64 * Hack -- simple "checksum" on the encoded bytes
66 static u32b x_check = 0L;
71 * This function determines if the version of the savefile
72 * currently being read is older than version "major.minor.patch.extra".
74 static bool h_older_than(byte major, byte minor, byte patch, byte extra)
76 /* Much older, or much more recent */
77 if (h_ver_major < major) return (TRUE);
78 if (h_ver_major > major) return (FALSE);
80 /* Distinctly older, or distinctly more recent */
81 if (h_ver_minor < minor) return (TRUE);
82 if (h_ver_minor > minor) return (FALSE);
84 /* Barely older, or barely more recent */
85 if (h_ver_patch < patch) return (TRUE);
86 if (h_ver_patch > patch) return (FALSE);
88 /* Barely older, or barely more recent */
89 if (h_ver_extra < extra) return (TRUE);
90 if (h_ver_extra > extra) return (FALSE);
92 /* Identical versions */
98 * The above function, adapted for Zangband
100 static bool z_older_than(byte x, byte y, byte z)
102 /* Much older, or much more recent */
103 if (z_major < x) return (TRUE);
104 if (z_major > x) return (FALSE);
106 /* Distinctly older, or distinctly more recent */
107 if (z_minor < y) return (TRUE);
108 if (z_minor > y) return (FALSE);
110 /* Barely older, or barely more recent */
111 if (z_patch < z) return (TRUE);
112 if (z_patch > z) return (FALSE);
114 /* Identical versions */
120 * Hack -- Show information on the screen, one line at a time.
122 * Avoid the top two lines, to avoid interference with "msg_print()".
124 static void note(cptr msg)
128 /* Draw the message */
131 /* Advance one line (wrap if needed) */
132 if (++y >= 24) y = 2;
140 * The following functions are used to load the basic building blocks
141 * of savefiles. They also maintain the "checksum" info for 2.7.0+
144 static byte sf_get(void)
148 /* Get a character, decode the value */
149 c = getc(fff) & 0xFF;
153 /* Maintain the checksum info */
157 /* Return the value */
161 static void rd_byte(byte *ip)
166 static void rd_u16b(u16b *ip)
169 (*ip) |= ((u16b)(sf_get()) << 8);
172 static void rd_s16b(s16b *ip)
177 static void rd_u32b(u32b *ip)
180 (*ip) |= ((u32b)(sf_get()) << 8);
181 (*ip) |= ((u32b)(sf_get()) << 16);
182 (*ip) |= ((u32b)(sf_get()) << 24);
185 static void rd_s32b(s32b *ip)
192 * Hack -- read a string
194 static void rd_string(char *str, int max)
198 /* Read the string */
199 for (i = 0; TRUE; i++)
206 /* Collect string while legal */
207 if (i < max) str[i] = tmp8u;
222 * Hack -- strip some bytes
224 static void strip_bytes(int n)
228 /* Strip the bytes */
229 while (n--) rd_byte(&tmp8u);
232 #define OLD_MAX_MANE 22
237 * This function attempts to "repair" old savefiles, and to extract
238 * the most up to date values for various object fields.
240 * Note that Angband 2.7.9 introduced a new method for object "flags"
241 * in which the "flags" on an object are actually extracted when they
242 * are needed from the object kind, artifact index, ego-item index,
243 * and two special "xtra" fields which are used to encode any "extra"
244 * power of certain ego-items. This had the side effect that items
245 * imported from pre-2.7.9 savefiles will lose any "extra" powers they
246 * may have had, and also, all "uncursed" items will become "cursed"
247 * again, including Calris, even if it is being worn at the time. As
248 * a complete hack, items which are inscribed with "uncursed" will be
249 * "uncursed" when imported from pre-2.7.9 savefiles.
251 static void rd_item(object_type *o_ptr)
257 rd_s16b(&o_ptr->k_idx);
264 rd_byte(&o_ptr->tval);
265 rd_byte(&o_ptr->sval);
267 if (z_older_than(10, 4, 4))
269 if (o_ptr->tval == 100) o_ptr->tval = TV_GOLD;
270 if (o_ptr->tval == 98) o_ptr->tval = TV_MUSIC_BOOK;
271 if (o_ptr->tval == 110) o_ptr->tval = TV_HISSATSU_BOOK;
275 rd_s16b(&o_ptr->pval);
277 rd_byte(&o_ptr->discount);
278 rd_byte(&o_ptr->number);
279 rd_s16b(&o_ptr->weight);
281 rd_byte(&o_ptr->name1);
282 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);
299 rd_u32b(&o_ptr->art_flags[0]);
300 rd_u32b(&o_ptr->art_flags[1]);
301 rd_u32b(&o_ptr->art_flags[2]);
302 if (h_older_than(1, 3, 0, 0)) o_ptr->art_flags[3] = 0L;
303 else rd_u32b(&o_ptr->art_flags[3]);
305 if (h_older_than(1, 3, 0, 0))
307 if (o_ptr->name2 == EGO_TELEPATHY)
308 add_flag(o_ptr->art_flags, TR_TELEPATHY);
311 if (z_older_than(11, 0, 11))
313 o_ptr->curse_flags = 0L;
314 if (o_ptr->ident & 0x40)
316 o_ptr->curse_flags |= TRC_CURSED;
317 if (o_ptr->art_flags[2] & 0x40000000L) o_ptr->curse_flags |= TRC_HEAVY_CURSE;
318 if (o_ptr->art_flags[2] & 0x80000000L) o_ptr->curse_flags |= TRC_PERMA_CURSE;
321 artifact_type *a_ptr = &a_info[o_ptr->name1];
322 if (a_ptr->gen_flags & (TRG_HEAVY_CURSE)) o_ptr->curse_flags |= TRC_HEAVY_CURSE;
323 if (a_ptr->gen_flags & (TRG_PERMA_CURSE)) o_ptr->curse_flags |= TRC_PERMA_CURSE;
325 else if (o_ptr->name2)
327 ego_item_type *e_ptr = &e_info[o_ptr->name2];
328 if (e_ptr->gen_flags & (TRG_HEAVY_CURSE)) o_ptr->curse_flags |= TRC_HEAVY_CURSE;
329 if (e_ptr->gen_flags & (TRG_PERMA_CURSE)) o_ptr->curse_flags |= TRC_PERMA_CURSE;
332 o_ptr->art_flags[2] &= (0x1FFFFFFFL);
336 rd_u32b(&o_ptr->curse_flags);
339 /* Monster holding object */
340 rd_s16b(&o_ptr->held_m_idx);
343 rd_byte(&o_ptr->xtra1);
344 rd_byte(&o_ptr->xtra2);
346 if (z_older_than(11, 0, 10))
348 if (o_ptr->xtra1 == EGO_XTRA_SUSTAIN)
350 switch (o_ptr->xtra2 % 6)
352 case 0: add_flag(o_ptr->art_flags, TR_SUST_STR); break;
353 case 1: add_flag(o_ptr->art_flags, TR_SUST_INT); break;
354 case 2: add_flag(o_ptr->art_flags, TR_SUST_WIS); break;
355 case 3: add_flag(o_ptr->art_flags, TR_SUST_DEX); break;
356 case 4: add_flag(o_ptr->art_flags, TR_SUST_CON); break;
357 case 5: add_flag(o_ptr->art_flags, TR_SUST_CHR); break;
361 else if (o_ptr->xtra1 == EGO_XTRA_POWER)
363 switch (o_ptr->xtra2 % 11)
365 case 0: add_flag(o_ptr->art_flags, TR_RES_BLIND); break;
366 case 1: add_flag(o_ptr->art_flags, TR_RES_CONF); break;
367 case 2: add_flag(o_ptr->art_flags, TR_RES_SOUND); break;
368 case 3: add_flag(o_ptr->art_flags, TR_RES_SHARDS); break;
369 case 4: add_flag(o_ptr->art_flags, TR_RES_NETHER); break;
370 case 5: add_flag(o_ptr->art_flags, TR_RES_NEXUS); break;
371 case 6: add_flag(o_ptr->art_flags, TR_RES_CHAOS); break;
372 case 7: add_flag(o_ptr->art_flags, TR_RES_DISEN); break;
373 case 8: add_flag(o_ptr->art_flags, TR_RES_POIS); break;
374 case 9: add_flag(o_ptr->art_flags, TR_RES_DARK); break;
375 case 10: add_flag(o_ptr->art_flags, TR_RES_LITE); break;
379 else if (o_ptr->xtra1 == EGO_XTRA_ABILITY)
381 switch (o_ptr->xtra2 % 8)
383 case 0: add_flag(o_ptr->art_flags, TR_FEATHER); break;
384 case 1: add_flag(o_ptr->art_flags, TR_LITE); break;
385 case 2: add_flag(o_ptr->art_flags, TR_SEE_INVIS); break;
386 case 3: add_flag(o_ptr->art_flags, TR_WARNING); break;
387 case 4: add_flag(o_ptr->art_flags, TR_SLOW_DIGEST); break;
388 case 5: add_flag(o_ptr->art_flags, TR_REGEN); break;
389 case 6: add_flag(o_ptr->art_flags, TR_FREE_ACT); break;
390 case 7: add_flag(o_ptr->art_flags, TR_HOLD_LIFE); break;
397 if (z_older_than(10, 2, 3))
402 if ((o_ptr->tval == TV_CHEST) || (o_ptr->tval == TV_CAPTURE))
404 o_ptr->xtra3 = o_ptr->xtra1;
407 if (o_ptr->tval == TV_CAPTURE)
409 if (r_info[o_ptr->pval].flags1 & RF1_FORCE_MAXHP)
410 o_ptr->xtra5 = maxroll(r_info[o_ptr->pval].hdice, r_info[o_ptr->pval].hside);
412 o_ptr->xtra5 = damroll(r_info[o_ptr->pval].hdice, r_info[o_ptr->pval].hside);
413 if (ironman_nightmare)
415 o_ptr->xtra5 = (s16b)MIN(30000, o_ptr->xtra5*2L);
417 o_ptr->xtra4 = o_ptr->xtra5;
422 rd_byte(&o_ptr->xtra3);
423 if (h_older_than(1, 3, 0, 1))
425 if (o_ptr->tval > TV_CAPTURE && o_ptr->xtra3 >= 1+96)
426 o_ptr->xtra3 += -96 + MIN_SPECIAL_ESSENCE;
429 rd_s16b(&o_ptr->xtra4);
430 rd_s16b(&o_ptr->xtra5);
433 if (z_older_than(11, 0, 5) && (((o_ptr->tval == TV_LITE) && ((o_ptr->sval == SV_LITE_TORCH) || (o_ptr->sval == SV_LITE_LANTERN))) || (o_ptr->tval == TV_FLASK)))
435 o_ptr->xtra4 = o_ptr->pval;
439 rd_byte(&o_ptr->feeling);
442 rd_string(buf, sizeof(buf));
444 /* Save the inscription */
445 if (buf[0]) o_ptr->inscription = quark_add(buf);
447 rd_string(buf, sizeof(buf));
448 if (buf[0]) o_ptr->art_name = quark_add(buf);
450 /* The Python object */
458 /* Mega-Hack -- handle "dungeon objects" later */
459 if ((o_ptr->k_idx >= 445) && (o_ptr->k_idx <= 479)) return;
461 if (z_older_than(10, 4, 10) && (o_ptr->name2 == EGO_YOIYAMI)) o_ptr->k_idx = lookup_kind(TV_SOFT_ARMOR, SV_YOIYAMI_ROBE);
463 if (z_older_than(10, 4, 9))
465 if (have_flag(o_ptr->art_flags, TR_MAGIC_MASTERY))
467 remove_flag(o_ptr->art_flags, TR_MAGIC_MASTERY);
468 add_flag(o_ptr->art_flags, TR_DEC_MANA);
475 artifact_type *a_ptr;
477 /* Obtain the artifact info */
478 a_ptr = &a_info[o_ptr->name1];
480 /* Verify that artifact */
481 if (!a_ptr->name) o_ptr->name1 = 0;
487 ego_item_type *e_ptr;
489 /* Obtain the ego-item info */
490 e_ptr = &e_info[o_ptr->name2];
492 /* Verify that ego-item */
493 if (!e_ptr->name) o_ptr->name2 = 0;
504 static void rd_monster(monster_type *m_ptr)
509 /* Read the monster race */
510 rd_s16b(&m_ptr->r_idx);
512 if (z_older_than(11, 0, 12))
513 m_ptr->ap_r_idx = m_ptr->r_idx;
515 rd_s16b(&m_ptr->ap_r_idx);
517 if (z_older_than(11, 0, 14))
519 monster_race *r_ptr = &r_info[m_ptr->r_idx];
521 m_ptr->sub_align = SUB_ALIGN_NEUTRAL;
522 if (r_ptr->flags3 & RF3_EVIL) m_ptr->sub_align |= SUB_ALIGN_EVIL;
523 if (r_ptr->flags3 & RF3_GOOD) m_ptr->sub_align |= SUB_ALIGN_GOOD;
526 rd_byte(&m_ptr->sub_align);
528 /* Read the other information */
532 rd_s16b(&m_ptr->maxhp);
533 if (z_older_than(11, 0, 5))
535 m_ptr->max_maxhp = m_ptr->maxhp;
539 rd_s16b(&m_ptr->max_maxhp);
541 rd_s16b(&m_ptr->csleep);
542 rd_byte(&m_ptr->mspeed);
543 if (z_older_than(10, 4, 2))
546 m_ptr->energy_need = (s16b)tmp8u;
548 else rd_s16b(&m_ptr->energy_need);
550 if (z_older_than(11, 0, 13))
551 m_ptr->energy_need = 100 - m_ptr->energy_need;
553 if (z_older_than(10,0,7))
560 rd_byte(&m_ptr->fast);
561 rd_byte(&m_ptr->slow);
563 rd_byte(&m_ptr->stunned);
564 rd_byte(&m_ptr->confused);
565 rd_byte(&m_ptr->monfear);
567 if (z_older_than(10,0,10))
571 else if (z_older_than(10,0,11))
579 rd_s16b(&m_ptr->target_y);
580 rd_s16b(&m_ptr->target_x);
583 rd_byte(&m_ptr->invulner);
585 if (!(z_major == 2 && z_minor == 0 && z_patch == 6))
586 rd_u32b(&m_ptr->smart);
590 if (z_older_than(10, 4, 5))
593 rd_u32b(&m_ptr->exp);
595 if (z_older_than(10, 2, 2))
597 if (m_ptr->r_idx < 0)
599 m_ptr->r_idx = (0-m_ptr->r_idx);
600 m_ptr->mflag2 |= MFLAG_KAGE;
605 rd_byte(&m_ptr->mflag2);
608 if (z_older_than(11, 0, 12))
610 if (m_ptr->mflag2 & MFLAG_KAGE)
611 m_ptr->ap_r_idx = MON_KAGE;
614 if (z_older_than(10, 1, 3))
620 rd_string(buf, sizeof(buf));
621 if (buf[0]) m_ptr->nickname = quark_add(buf);
632 * Read the monster lore
634 static void rd_lore(int r_idx)
638 monster_race *r_ptr = &r_info[r_idx];
640 /* Count sights/deaths/kills */
641 rd_s16b(&r_ptr->r_sights);
642 rd_s16b(&r_ptr->r_deaths);
643 rd_s16b(&r_ptr->r_pkills);
644 rd_s16b(&r_ptr->r_tkills);
646 /* Count wakes and ignores */
647 rd_byte(&r_ptr->r_wake);
648 rd_byte(&r_ptr->r_ignore);
651 rd_byte(&r_ptr->r_xtra1);
652 rd_byte(&r_ptr->r_xtra2);
655 rd_byte(&r_ptr->r_drop_gold);
656 rd_byte(&r_ptr->r_drop_item);
659 rd_byte(&r_ptr->r_cast_inate);
660 rd_byte(&r_ptr->r_cast_spell);
662 /* Count blows of each type */
663 rd_byte(&r_ptr->r_blows[0]);
664 rd_byte(&r_ptr->r_blows[1]);
665 rd_byte(&r_ptr->r_blows[2]);
666 rd_byte(&r_ptr->r_blows[3]);
669 rd_u32b(&r_ptr->r_flags1);
670 rd_u32b(&r_ptr->r_flags2);
671 rd_u32b(&r_ptr->r_flags3);
672 rd_u32b(&r_ptr->r_flags4);
673 rd_u32b(&r_ptr->r_flags5);
674 rd_u32b(&r_ptr->r_flags6);
676 /* Read the "Racial" monster limit per level */
677 rd_byte(&r_ptr->max_num);
684 /* Repair the lore flags */
685 r_ptr->r_flags1 &= r_ptr->flags1;
686 r_ptr->r_flags2 &= r_ptr->flags2;
687 r_ptr->r_flags3 &= r_ptr->flags3;
688 r_ptr->r_flags4 &= r_ptr->flags4;
689 r_ptr->r_flags5 &= r_ptr->flags5;
690 r_ptr->r_flags6 &= r_ptr->flags6;
697 * Add the item "o_ptr" to the inventory of the "Home"
699 * In all cases, return the slot (or -1) where the object was placed
701 * Note that this is a hacked up version of "inven_carry()".
703 * Also note that it may not correctly "adapt" to "knowledge" bacoming
704 * known, the player may have to pick stuff up and drop it again.
706 static void home_carry(store_type *st_ptr, object_type *o_ptr)
714 /* Check each existing item (try to combine) */
715 for (slot = 0; slot < st_ptr->stock_num; slot++)
717 /* Get the existing item */
718 j_ptr = &st_ptr->stock[slot];
720 /* The home acts just like the player */
721 if (object_similar(j_ptr, o_ptr))
723 /* Save the new number of items */
724 object_absorb(j_ptr, o_ptr);
732 if (st_ptr->stock_num >= STORE_INVEN_MAX * 10) {
736 /* Determine the "value" of the item */
737 value = object_value(o_ptr);
739 /* Check existing slots to see if we must "slide" */
740 for (slot = 0; slot < st_ptr->stock_num; slot++)
743 j_ptr = &st_ptr->stock[slot];
745 /* Hack -- readable books always come first */
746 if ((o_ptr->tval == mp_ptr->spell_book) &&
747 (j_ptr->tval != mp_ptr->spell_book)) break;
748 if ((j_ptr->tval == mp_ptr->spell_book) &&
749 (o_ptr->tval != mp_ptr->spell_book)) continue;
751 /* Objects sort by decreasing type */
752 if (o_ptr->tval > j_ptr->tval) break;
753 if (o_ptr->tval < j_ptr->tval) continue;
755 /* Can happen in the home */
756 if (!object_aware_p(o_ptr)) continue;
757 if (!object_aware_p(j_ptr)) break;
759 /* Objects sort by increasing sval */
760 if (o_ptr->sval < j_ptr->sval) break;
761 if (o_ptr->sval > j_ptr->sval) continue;
763 /* Objects in the home can be unknown */
764 if (!object_known_p(o_ptr)) continue;
765 if (!object_known_p(j_ptr)) break;
768 * Hack: otherwise identical rods sort by
769 * increasing recharge time --dsb
771 if (o_ptr->tval == TV_ROD)
773 if (o_ptr->pval < j_ptr->pval) break;
774 if (o_ptr->pval > j_ptr->pval) continue;
777 /* Objects sort by decreasing value */
778 j_value = object_value(j_ptr);
779 if (value > j_value) break;
780 if (value < j_value) continue;
783 /* Slide the others up */
784 for (i = st_ptr->stock_num; i > slot; i--)
786 st_ptr->stock[i] = st_ptr->stock[i-1];
792 /* Insert the new item */
793 st_ptr->stock[slot] = *o_ptr;
795 chg_virtue(V_SACRIFICE, -1);
797 /* Return the location */
805 static errr rd_store(int town_number, int store_number)
817 if (z_older_than(10, 3, 3) && (store_number == STORE_HOME))
819 st_ptr = &town[1].store[store_number];
820 if (st_ptr->stock_num) sort = TRUE;
824 st_ptr = &town[town_number].store[store_number];
827 /* Read the basic info */
828 rd_s32b(&st_ptr->store_open);
829 rd_s16b(&st_ptr->insult_cur);
831 if (z_older_than(11, 0, 4))
840 rd_s16b(&st_ptr->good_buy);
841 rd_s16b(&st_ptr->bad_buy);
843 /* Read last visit */
844 rd_s32b(&st_ptr->last_visit);
846 /* Extract the owner (see above) */
850 for (j = 0; j < num; j++)
855 /* Get local object */
858 /* Wipe the object */
864 /* Acquire valid items */
865 if (st_ptr->stock_num < (store_number == STORE_HOME ? (STORE_INVEN_MAX) * 10 : (store_number == STORE_MUSEUM ? (STORE_INVEN_MAX) * 50 : STORE_INVEN_MAX)))
870 home_carry(st_ptr, q_ptr);
874 k = st_ptr->stock_num++;
876 /* Acquire the item */
877 object_copy(&st_ptr->stock[k], q_ptr);
889 * Read RNG state (added in 2.8.0)
891 static void rd_randomizer(void)
901 rd_u16b(&Rand_place);
904 for (i = 0; i < RAND_DEG; i++)
906 rd_u32b(&Rand_state[i]);
916 * Read options (ignore most pre-2.8.0 options)
918 * Note that the normal options are now stored as a set of 256 bit flags,
919 * plus a set of 256 bit masks to indicate which bit flags were defined
920 * at the time the savefile was created. This will allow new options
921 * to be added, and old options to be removed, at any time, without
922 * hurting old savefiles.
924 * The window options are stored in the same way, but note that each
925 * window gets 32 options, and their order is fixed by certain defines.
927 static void rd_options(void)
941 /* Ignore old options */
947 /* Read "delay_factor" */
951 /* Read "hitpoint_warn" */
956 /*** Cheating options ***/
960 if (c & 0x0002) p_ptr->wizard = TRUE;
962 cheat_peek = (c & 0x0100) ? TRUE : FALSE;
963 cheat_hear = (c & 0x0200) ? TRUE : FALSE;
964 cheat_room = (c & 0x0400) ? TRUE : FALSE;
965 cheat_xtra = (c & 0x0800) ? TRUE : FALSE;
966 cheat_know = (c & 0x1000) ? TRUE : FALSE;
967 cheat_live = (c & 0x2000) ? TRUE : FALSE;
968 cheat_save = (c & 0x4000) ? TRUE : FALSE;
970 rd_byte((byte *)&autosave_l);
971 rd_byte((byte *)&autosave_t);
972 rd_s16b(&autosave_freq);
975 /*** Normal Options ***/
977 /* Read the option flags */
978 for (n = 0; n < 8; n++) rd_u32b(&flag[n]);
980 /* Read the option masks */
981 for (n = 0; n < 8; n++) rd_u32b(&mask[n]);
983 /* Analyze the options */
984 for (n = 0; n < 8; n++)
986 /* Analyze the options */
987 for (i = 0; i < 32; i++)
989 /* Process valid flags */
990 if (mask[n] & (1L << i))
992 /* Process valid flags */
993 if (option_mask[n] & (1L << i))
996 if (flag[n] & (1L << i))
999 option_flag[n] |= (1L << i);
1006 option_flag[n] &= ~(1L << i);
1013 if (z_older_than(10, 4, 5))
1015 if (option_flag[5] & (0x00000001 << 4)) option_flag[5] &= ~(0x00000001 << 4);
1016 else option_flag[5] |= (0x00000001 << 4);
1017 if (option_flag[2] & (0x00000001 << 5)) option_flag[2] &= ~(0x00000001 << 5);
1018 else option_flag[2] |= (0x00000001 << 5);
1019 if (option_flag[4] & (0x00000001 << 5)) option_flag[4] &= ~(0x00000001 << 5);
1020 else option_flag[4] |= (0x00000001 << 5);
1021 if (option_flag[5] & (0x00000001 << 0)) option_flag[5] &= ~(0x00000001 << 0);
1022 else option_flag[5] |= (0x00000001 << 0);
1023 if (option_flag[5] & (0x00000001 << 12)) option_flag[5] &= ~(0x00000001 << 12);
1024 else option_flag[5] |= (0x00000001 << 12);
1025 if (option_flag[1] & (0x00000001 << 0)) option_flag[1] &= ~(0x00000001 << 0);
1026 else option_flag[1] |= (0x00000001 << 0);
1027 if (option_flag[1] & (0x00000001 << 18)) option_flag[1] &= ~(0x00000001 << 18);
1028 else option_flag[1] |= (0x00000001 << 18);
1029 if (option_flag[1] & (0x00000001 << 19)) option_flag[1] &= ~(0x00000001 << 19);
1030 else option_flag[1] |= (0x00000001 << 19);
1031 if (option_flag[5] & (0x00000001 << 3)) option_flag[1] &= ~(0x00000001 << 3);
1032 else option_flag[5] |= (0x00000001 << 3);
1036 /*** Window Options ***/
1038 /* Read the window flags */
1039 for (n = 0; n < 8; n++) rd_u32b(&flag[n]);
1041 /* Read the window masks */
1042 for (n = 0; n < 8; n++) rd_u32b(&mask[n]);
1044 /* Analyze the options */
1045 for (n = 0; n < 8; n++)
1047 /* Analyze the options */
1048 for (i = 0; i < 32; i++)
1050 /* Process valid flags */
1051 if (mask[n] & (1L << i))
1053 /* Process valid flags */
1054 if (window_mask[n] & (1L << i))
1057 if (flag[n] & (1L << i))
1060 window_flag[n] |= (1L << i);
1067 window_flag[n] &= ~(1L << i);
1080 * Hack -- strip the "ghost" info
1082 * XXX XXX XXX This is such a nasty hack it hurts.
1084 static void rd_ghost(void)
1089 rd_string(buf, sizeof(buf));
1091 /* Strip old data */
1097 * Save quick start data
1099 static void load_quick_start(void)
1104 if (z_older_than(11, 0, 13))
1106 previous_char.quick_ok = FALSE;
1110 rd_byte(&previous_char.psex);
1111 rd_byte(&previous_char.prace);
1112 rd_byte(&previous_char.pclass);
1113 rd_byte(&previous_char.pseikaku);
1114 rd_byte(&previous_char.realm1);
1115 rd_byte(&previous_char.realm2);
1117 rd_s16b(&previous_char.age);
1118 rd_s16b(&previous_char.ht);
1119 rd_s16b(&previous_char.wt);
1120 rd_s16b(&previous_char.sc);
1121 rd_s32b(&previous_char.au);
1123 for (i = 0; i < 6; i++) rd_s16b(&previous_char.stat_max[i]);
1124 for (i = 0; i < 6; i++) rd_s16b(&previous_char.stat_max_max[i]);
1126 for (i = 0; i < PY_MAX_LEVEL; i++) rd_s16b(&previous_char.player_hp[i]);
1128 rd_s16b(&previous_char.chaos_patron);
1130 for (i = 0; i < 8; i++) rd_s16b(&previous_char.vir_types[i]);
1132 for (i = 0; i < 4; i++) rd_string(previous_char.history[i], sizeof(previous_char.history[i]));
1134 rd_byte(&previous_char.quests);
1137 previous_char.quick_ok = (bool)tmp8u;
1141 * Read the "extra" information
1143 static void rd_extra(void)
1150 rd_string(player_name, sizeof(player_name));
1152 rd_string(p_ptr->died_from, sizeof(p_ptr->died_from));
1156 for (i = 0; i < 4; i++)
1158 rd_string(p_ptr->history[i], sizeof(p_ptr->history[i]));
1161 /* Class/Race/Seikaku/Gender/Spells */
1162 rd_byte(&p_ptr->prace);
1163 rd_byte(&p_ptr->pclass);
1164 rd_byte(&p_ptr->pseikaku);
1165 rd_byte(&p_ptr->psex);
1166 rd_byte(&p_ptr->realm1);
1167 rd_byte(&p_ptr->realm2);
1168 rd_byte(&tmp8u); /* oops */
1170 if (z_older_than(10, 4, 4))
1172 if (p_ptr->realm1 == 9) p_ptr->realm1 = REALM_MUSIC;
1173 if (p_ptr->realm2 == 9) p_ptr->realm2 = REALM_MUSIC;
1174 if (p_ptr->realm1 == 10) p_ptr->realm1 = REALM_HISSATSU;
1175 if (p_ptr->realm2 == 10) p_ptr->realm2 = REALM_HISSATSU;
1178 /* Special Race/Class info */
1179 rd_byte(&p_ptr->hitdie);
1180 rd_u16b(&p_ptr->expfact);
1182 /* Age/Height/Weight */
1183 rd_s16b(&p_ptr->age);
1184 rd_s16b(&p_ptr->ht);
1185 rd_s16b(&p_ptr->wt);
1187 /* Read the stat info */
1188 for (i = 0; i < 6; i++) rd_s16b(&p_ptr->stat_max[i]);
1189 for (i = 0; i < 6; i++) rd_s16b(&p_ptr->stat_max_max[i]);
1190 for (i = 0; i < 6; i++) rd_s16b(&p_ptr->stat_cur[i]);
1192 strip_bytes(24); /* oops */
1194 rd_s32b(&p_ptr->au);
1196 rd_s32b(&p_ptr->max_exp);
1197 rd_s32b(&p_ptr->exp);
1198 rd_u16b(&p_ptr->exp_frac);
1200 rd_s16b(&p_ptr->lev);
1202 for (i = 0; i < 64; i++) rd_s16b(&p_ptr->spell_exp[i]);
1203 if ((p_ptr->pclass == CLASS_SORCERER) && z_older_than(10, 4, 2))
1205 for (i = 0; i < 64; i++) p_ptr->spell_exp[i] = 1600;
1207 if (z_older_than(10, 3, 6))
1208 for (i = 0; i < 5; i++) for (j = 0; j < 60; j++) rd_s16b(&p_ptr->weapon_exp[i][j]);
1210 for (i = 0; i < 5; i++) for (j = 0; j < 64; j++) rd_s16b(&p_ptr->weapon_exp[i][j]);
1211 for (i = 0; i < 10; i++) rd_s16b(&p_ptr->skill_exp[i]);
1212 if (z_older_than(10, 4, 1))
1214 if (p_ptr->pclass != CLASS_BEASTMASTER) p_ptr->skill_exp[GINOU_RIDING] /= 2;
1215 p_ptr->skill_exp[GINOU_RIDING] = MIN(p_ptr->skill_exp[GINOU_RIDING], s_info[p_ptr->pclass].s_max[GINOU_RIDING]);
1217 if (z_older_than(10, 3, 14))
1219 for (i = 0; i < 108; i++) p_ptr->magic_num1[i] = 0;
1220 for (i = 0; i < 108; i++) p_ptr->magic_num2[i] = 0;
1224 for (i = 0; i < 108; i++) rd_s32b(&p_ptr->magic_num1[i]);
1225 for (i = 0; i < 108; i++) rd_byte(&p_ptr->magic_num2[i]);
1226 if (h_older_than(1, 3, 0, 1))
1228 if (p_ptr->pclass == CLASS_SMITH)
1230 p_ptr->magic_num1[TR_ES_ATTACK] = p_ptr->magic_num1[96];
1231 p_ptr->magic_num1[96] = 0;
1232 p_ptr->magic_num1[TR_ES_AC] = p_ptr->magic_num1[97];
1233 p_ptr->magic_num1[97] = 0;
1237 if ((p_ptr->pclass == CLASS_BARD) && p_ptr->magic_num1[0]) p_ptr->action = ACTION_SING;
1239 if (z_older_than(11, 0, 7))
1241 p_ptr->start_race = p_ptr->prace;
1242 p_ptr->old_race1 = 0L;
1243 p_ptr->old_race2 = 0L;
1244 p_ptr->old_realm = 0;
1248 rd_byte(&p_ptr->start_race);
1249 rd_s32b(&p_ptr->old_race1);
1250 rd_s32b(&p_ptr->old_race2);
1251 rd_s16b(&p_ptr->old_realm);
1254 if (z_older_than(10, 0, 1))
1256 for (i = 0; i < OLD_MAX_MANE; i++)
1258 p_ptr->mane_spell[i] = -1;
1259 p_ptr->mane_dam[i] = 0;
1261 p_ptr->mane_num = 0;
1263 else if (z_older_than(10, 2, 3))
1265 for (i = 0; i < OLD_MAX_MANE; i++)
1270 for (i = 0; i < MAX_MANE; i++)
1272 p_ptr->mane_spell[i] = -1;
1273 p_ptr->mane_dam[i] = 0;
1276 p_ptr->mane_num = 0;
1280 for (i = 0; i < MAX_MANE; i++)
1282 rd_s16b(&p_ptr->mane_spell[i]);
1283 rd_s16b(&p_ptr->mane_dam[i]);
1285 rd_s16b(&p_ptr->mane_num);
1288 if (z_older_than(10, 0, 3))
1290 get_mon_num_prep(NULL, NULL);
1291 for (i = 0; i < MAX_KUBI; i++)
1293 monster_race *r_ptr;
1298 kubi_r_idx[i] = get_mon_num(MAX_DEPTH - 1);
1299 r_ptr = &r_info[kubi_r_idx[i]];
1301 if(!(r_ptr->flags1 & RF1_UNIQUE)) continue;
1303 if(!(r_ptr->flags9 & RF9_DROP_CORPSE)) continue;
1305 if(r_ptr->flags6 & RF6_SPECIAL) continue;
1307 for (j = 0; j < i; j++)
1308 if (kubi_r_idx[i] == kubi_r_idx[j])break;
1313 for (i = 0; i < MAX_KUBI -1; i++)
1316 for (j = i; j < MAX_KUBI; j++)
1318 if (r_info[kubi_r_idx[i]].level > r_info[kubi_r_idx[j]].level)
1320 tmp = kubi_r_idx[i];
1321 kubi_r_idx[i] = kubi_r_idx[j];
1322 kubi_r_idx[j] = tmp;
1326 for (i = 0; i < MAX_KUBI; i++)
1328 if(!r_info[kubi_r_idx[i]].max_num)
1329 kubi_r_idx[i] += 10000;
1334 for (i = 0; i < MAX_KUBI; i++)
1336 rd_s16b(&kubi_r_idx[i]);
1340 if (z_older_than(10, 0, 3))
1346 for (i = 0; i < 4; i++)
1348 rd_s16b(&battle_mon[i]);
1349 if (z_older_than(10, 3, 4))
1352 mon_odds[i] = tmp16s;
1354 else rd_u32b(&mon_odds[i]);
1358 rd_s16b(&p_ptr->town_num);
1360 /* Read arena and rewards information */
1361 rd_s16b(&p_ptr->arena_number);
1363 p_ptr->inside_arena = (bool)tmp16s;
1364 rd_s16b(&p_ptr->inside_quest);
1365 if (z_older_than(10, 3, 5)) p_ptr->inside_battle = FALSE;
1369 p_ptr->inside_battle = (bool)tmp16s;
1371 rd_byte(&p_ptr->exit_bldg);
1372 rd_byte(&p_ptr->leftbldg);
1374 rd_s16b(&p_ptr->oldpx);
1375 rd_s16b(&p_ptr->oldpy);
1376 if (z_older_than(10, 3, 13) && !dun_level && !p_ptr->inside_arena) {p_ptr->oldpy = 33;p_ptr->oldpx = 131;}
1380 if (tmp16s > MAX_BACT)
1383 note(format("¤ÎÃæ", tmp16s));
1385 note(format("Too many (%d) building rewards!", tmp16s));
1390 for (i = 0; i < tmp16s; i++) rd_s16b(&p_ptr->rewards[i]);
1392 rd_s16b(&p_ptr->mhp);
1393 rd_s16b(&p_ptr->chp);
1394 rd_u16b(&p_ptr->chp_frac);
1396 rd_s16b(&p_ptr->msp);
1397 rd_s16b(&p_ptr->csp);
1398 rd_u16b(&p_ptr->csp_frac);
1400 rd_s16b(&p_ptr->max_plv);
1401 if (z_older_than(10, 3, 8))
1403 rd_s16b(&max_dlv[DUNGEON_ANGBAND]);
1407 byte max = (byte)max_d_idx;
1411 for(i = 0; i < max; i++)
1413 rd_s16b(&max_dlv[i]);
1414 if (max_dlv[i] > d_info[i].maxdepth) max_dlv[i] = d_info[i].maxdepth;
1418 /* Repair maximum player level XXX XXX XXX */
1419 if (p_ptr->max_plv < p_ptr->lev) p_ptr->max_plv = p_ptr->lev;
1423 rd_s16b(&p_ptr->sc);
1426 /* Read the flags */
1427 strip_bytes(2); /* Old "rest" */
1428 rd_s16b(&p_ptr->blind);
1429 rd_s16b(&p_ptr->paralyzed);
1430 rd_s16b(&p_ptr->confused);
1431 rd_s16b(&p_ptr->food);
1432 strip_bytes(4); /* Old "food_digested" / "protection" */
1434 rd_s16b(&p_ptr->energy_need);
1435 if (z_older_than(11, 0, 13))
1436 p_ptr->energy_need = 100 - p_ptr->energy_need;
1438 rd_s16b(&p_ptr->fast);
1439 rd_s16b(&p_ptr->slow);
1440 rd_s16b(&p_ptr->afraid);
1441 rd_s16b(&p_ptr->cut);
1442 rd_s16b(&p_ptr->stun);
1443 rd_s16b(&p_ptr->poisoned);
1444 rd_s16b(&p_ptr->image);
1445 rd_s16b(&p_ptr->protevil);
1446 rd_s16b(&p_ptr->invuln);
1447 if(z_older_than(10, 0, 0))
1450 rd_s16b(&p_ptr->ult_res);
1451 rd_s16b(&p_ptr->hero);
1452 rd_s16b(&p_ptr->shero);
1453 rd_s16b(&p_ptr->shield);
1454 rd_s16b(&p_ptr->blessed);
1455 rd_s16b(&p_ptr->tim_invis);
1456 rd_s16b(&p_ptr->word_recall);
1457 if (z_older_than(10, 3, 8))
1458 p_ptr->recall_dungeon = DUNGEON_ANGBAND;
1462 p_ptr->recall_dungeon = (byte)tmp16s;
1464 rd_s16b(&p_ptr->see_infra);
1465 rd_s16b(&p_ptr->tim_infra);
1466 rd_s16b(&p_ptr->oppose_fire);
1467 rd_s16b(&p_ptr->oppose_cold);
1468 rd_s16b(&p_ptr->oppose_acid);
1469 rd_s16b(&p_ptr->oppose_elec);
1470 rd_s16b(&p_ptr->oppose_pois);
1471 if (z_older_than(10,0,2)) p_ptr->tsuyoshi = 0;
1472 else rd_s16b(&p_ptr->tsuyoshi);
1474 /* Old savefiles do not have the following fields... */
1475 if ((z_major == 2) && (z_minor == 0) && (z_patch == 6))
1478 p_ptr->wraith_form = 0;
1479 p_ptr->resist_magic = 0;
1480 p_ptr->tim_regen = 0;
1481 p_ptr->kabenuke = 0;
1482 p_ptr->tim_stealth = 0;
1483 p_ptr->tim_ffall = 0;
1484 p_ptr->tim_sh_touki = 0;
1485 p_ptr->lightspeed = 0;
1486 p_ptr->tsubureru = 0;
1487 p_ptr->tim_res_nether = 0;
1488 p_ptr->tim_res_time = 0;
1489 p_ptr->mimic_form = 0;
1490 p_ptr->tim_mimic = 0;
1491 p_ptr->tim_sh_fire = 0;
1494 p_ptr->tim_reflect = 0;
1495 p_ptr->multishadow = 0;
1496 p_ptr->dustrobe = 0;
1498 p_ptr->chaos_patron = get_chaos_patron();
1506 rd_s16b(&p_ptr->tim_esp);
1507 rd_s16b(&p_ptr->wraith_form);
1508 rd_s16b(&p_ptr->resist_magic);
1509 rd_s16b(&p_ptr->tim_regen);
1510 rd_s16b(&p_ptr->kabenuke);
1511 rd_s16b(&p_ptr->tim_stealth);
1512 rd_s16b(&p_ptr->tim_ffall);
1513 rd_s16b(&p_ptr->tim_sh_touki);
1514 rd_s16b(&p_ptr->lightspeed);
1515 rd_s16b(&p_ptr->tsubureru);
1516 if (z_older_than(10, 4, 7))
1517 p_ptr->magicdef = 0;
1519 rd_s16b(&p_ptr->magicdef);
1520 rd_s16b(&p_ptr->tim_res_nether);
1521 if (z_older_than(10, 4, 11))
1523 p_ptr->tim_res_time = 0;
1524 p_ptr->mimic_form = 0;
1525 p_ptr->tim_mimic = 0;
1526 p_ptr->tim_sh_fire = 0;
1530 rd_s16b(&p_ptr->tim_res_time);
1531 rd_byte(&p_ptr->mimic_form);
1532 rd_s16b(&p_ptr->tim_mimic);
1533 rd_s16b(&p_ptr->tim_sh_fire);
1536 if (z_older_than(11, 0, 99))
1538 p_ptr->tim_sh_holy = 0;
1539 p_ptr->tim_eyeeye = 0;
1543 rd_s16b(&p_ptr->tim_sh_holy);
1544 rd_s16b(&p_ptr->tim_eyeeye);
1548 if ( z_older_than(11,0,3) ){
1549 p_ptr->tim_reflect=0;
1550 p_ptr->multishadow=0;
1554 rd_s16b(&p_ptr->tim_reflect);
1555 rd_s16b(&p_ptr->multishadow);
1556 rd_s16b(&p_ptr->dustrobe);
1559 rd_s16b(&p_ptr->chaos_patron);
1560 rd_u32b(&p_ptr->muta1);
1561 rd_u32b(&p_ptr->muta2);
1562 rd_u32b(&p_ptr->muta3);
1564 for (i = 0; i < 8; i++)
1565 rd_s16b(&p_ptr->virtues[i]);
1566 for (i = 0; i < 8; i++)
1567 rd_s16b(&p_ptr->vir_types[i]);
1570 /* Calc the regeneration modifier for mutations */
1571 mutant_regenerate_mod = calc_mutant_regenerate_mod();
1573 if (z_older_than(10,0,9))
1576 if (tmp8u) p_ptr->special_attack = ATTACK_CONFUSE;
1577 p_ptr->ele_attack = 0;
1581 rd_s16b(&p_ptr->ele_attack);
1582 rd_u32b(&p_ptr->special_attack);
1584 if (p_ptr->special_attack & KAMAE_MASK) p_ptr->action = ACTION_KAMAE;
1585 else if (p_ptr->special_attack & KATA_MASK) p_ptr->action = ACTION_KATA;
1586 if (z_older_than(10,0,12))
1588 p_ptr->ele_immune = 0;
1589 p_ptr->special_defense = 0;
1593 rd_s16b(&p_ptr->ele_immune);
1594 rd_u32b(&p_ptr->special_defense);
1596 rd_byte(&p_ptr->knowledge);
1597 rd_byte(&tmp8u); /* oops */
1598 rd_byte(&tmp8u); /* oops */
1599 rd_byte(&p_ptr->action);
1600 if (!z_older_than(10, 4, 3))
1603 if (tmp8u) p_ptr->action = ACTION_LEARN;
1605 rd_byte((byte *)&preserve_mode);
1606 rd_byte((byte *)&p_ptr->wait_report_score);
1609 for (i = 0; i < 48; i++) rd_byte(&tmp8u);
1611 /* Skip the flags */
1615 /* Hack -- the two "special seeds" */
1616 rd_u32b(&seed_flavor);
1617 rd_u32b(&seed_town);
1621 rd_u16b(&p_ptr->panic_save);
1622 rd_u16b(&p_ptr->total_winner);
1623 rd_u16b(&p_ptr->noscore);
1628 p_ptr->is_dead = tmp8u;
1630 /* Read "feeling" */
1634 /* Turn of last "feeling" */
1640 if (z_older_than(10, 3, 12))
1642 dungeon_turn = turn;
1644 else rd_s32b(&dungeon_turn);
1646 if (z_older_than(11, 0, 13))
1653 if (z_older_than(10, 3, 13))
1657 else rd_s32b(&old_battle);
1659 if (z_older_than(10,0,3))
1661 monster_race *r_ptr;
1665 today_mon = get_mon_num(MAX(max_dlv[DUNGEON_ANGBAND], 3));
1666 r_ptr = &r_info[today_mon];
1668 if (r_ptr->flags1 & RF1_UNIQUE) continue;
1669 if (r_ptr->flags2 & (RF2_MULTIPLY)) continue;
1670 if (!(r_ptr->flags9 & RF9_DROP_CORPSE) || !(r_ptr->flags9 & RF9_DROP_SKELETON)) continue;
1671 if (r_ptr->level < MIN(max_dlv[DUNGEON_ANGBAND], 40)) continue;
1672 if (r_ptr->rarity > 10) continue;
1673 if (r_ptr->level == 0) continue;
1677 p_ptr->today_mon = 0;
1681 rd_s16b(&today_mon);
1682 rd_s16b(&p_ptr->today_mon);
1685 if (z_older_than(10,0,7))
1691 rd_s16b(&p_ptr->riding);
1694 if (z_older_than(10,1,2))
1703 if (z_older_than(10,3,9))
1707 else if (z_older_than(10, 3, 10))
1715 rd_s32b(&p_ptr->visit);
1717 if (!z_older_than(11, 0, 5))
1719 rd_u32b(&p_ptr->count);
1727 * Read the player inventory
1729 * Note that the inventory changed in Angband 2.7.4. Two extra
1730 * pack slots were added and the equipment was rearranged. Note
1731 * that these two features combine when parsing old save-files, in
1732 * which items from the old "aux" slot are "carried", perhaps into
1733 * one of the two new "inventory" slots.
1735 * Note that the inventory is "re-sorted" later by "dungeon()".
1737 static errr rd_inventory(void)
1745 p_ptr->total_weight = 0;
1751 /* Read until done */
1756 /* Get the next item index */
1759 /* Nope, we reached the end */
1760 if (n == 0xFFFF) break;
1762 /* Get local object */
1765 /* Wipe the object */
1771 /* Hack -- verify item */
1772 if (!q_ptr->k_idx) return (53);
1774 /* Wield equipment */
1775 if (n >= INVEN_RARM)
1778 object_copy(&inventory[n], q_ptr);
1780 /* Add the weight */
1781 p_ptr->total_weight += (q_ptr->number * q_ptr->weight);
1787 /* Warning -- backpack is full */
1788 else if (inven_cnt == INVEN_PACK)
1792 note("»ý¤Áʪ¤ÎÃæ¤Î¥¢¥¤¥Æ¥à¤¬Â¿¤¹¤®¤ë¡ª");
1794 note("Too many items in the inventory!");
1802 /* Carry inventory */
1809 object_copy(&inventory[n], q_ptr);
1811 /* Add the weight */
1812 p_ptr->total_weight += (q_ptr->number * q_ptr->weight);
1826 * Read the saved messages
1828 static void rd_messages(void)
1838 /* Read the messages */
1839 for (i = 0; i < num; i++)
1841 /* Read the message */
1842 rd_string(buf, sizeof(buf));
1844 /* Save the message */
1851 /* Old hidden trap flag */
1852 #define CAVE_TRAP 0x8000
1857 * The monsters/objects must be loaded in the same order
1858 * that they were stored, since the actual indexes matter.
1860 static errr rd_dungeon(void)
1871 /*** Basic info ***/
1874 rd_s16b(&dun_level);
1875 if (z_older_than(10, 3, 8)) dungeon_type = DUNGEON_ANGBAND;
1876 else rd_byte(&dungeon_type);
1878 /* Set the base level for old versions */
1879 base_level = dun_level;
1881 rd_s16b(&base_level);
1883 rd_s16b(&num_repro);
1888 if (z_older_than(10, 3, 13) && !dun_level && !p_ptr->inside_arena) {py = 33;px = 131;}
1891 rd_s16b(&tmp16s); /* max_panel_rows */
1892 rd_s16b(&tmp16s); /* max_panel_cols */
1895 if (!py || !px) {py = 10;px = 10;}/* ¥À¥ó¥¸¥ç¥óÀ¸À®¤Ë¼ºÇÔ¤·¤Æ¥»¥°¥á¥ó¥Æ¤Ã¤¿¤È¤¤ÎÉüµìÍÑ */
1903 /*** Run length decoding ***/
1905 /* Load the dungeon data */
1906 for (x = y = 0; y < ymax; )
1912 if (z_older_than(10,3,6))
1921 /* Decline invalid flags */
1922 info &= ~(CAVE_LITE | CAVE_VIEW | CAVE_MNLT);
1925 /* Apply the RLE info */
1926 for (i = count; i > 0; i--)
1928 /* Access the cave */
1929 c_ptr = &cave[y][x];
1931 /* Extract "info" */
1941 if (++y >= ymax) break;
1947 /*** Run length decoding ***/
1949 /* Load the dungeon data */
1950 for (x = y = 0; y < ymax; )
1956 /* Apply the RLE info */
1957 for (i = count; i > 0; i--)
1959 /* Access the cave */
1960 c_ptr = &cave[y][x];
1962 /* Extract "feat" */
1963 c_ptr->feat = tmp8u;
1972 if (++y >= ymax) break;
1977 /*** Run length decoding ***/
1979 /* Load the dungeon data */
1980 for (x = y = 0; y < ymax; )
1986 /* Apply the RLE info */
1987 for (i = count; i > 0; i--)
1989 /* Access the cave */
1990 c_ptr = &cave[y][x];
1992 /* Extract "feat" */
1993 c_ptr->mimic = tmp8u;
2002 if (++y >= ymax) break;
2007 /*** Run length decoding ***/
2009 /* Load the dungeon data */
2010 for (x = y = 0; y < ymax; )
2016 /* Apply the RLE info */
2017 for (i = count; i > 0; i--)
2019 /* Access the cave */
2020 c_ptr = &cave[y][x];
2022 /* Extract "feat" */
2023 c_ptr->special = tmp16s;
2032 if (++y >= ymax) break;
2037 /* Convert cave data */
2038 if (z_older_than(11, 0, 99))
2040 for (y = 0; y < ymax; y++) for (x = 0; x < xmax; x++)
2042 /* Wipe old unused flags */
2043 cave[y][x].info &= ~(CAVE_MASK);
2047 if (h_older_than(1, 1, 1, 0))
2049 for (y = 0; y < ymax; y++) for (x = 0; x < xmax; x++)
2051 /* Access the cave */
2052 c_ptr = &cave[y][x];
2055 if (c_ptr->feat == FEAT_INVIS)
2057 c_ptr->feat = FEAT_FLOOR;
2058 c_ptr->info |= CAVE_TRAP;
2061 /* Older than 1.1.1 */
2062 if (c_ptr->feat == FEAT_MIRROR)
2064 c_ptr->feat = FEAT_FLOOR;
2065 c_ptr->info |= CAVE_OBJECT;
2070 if (h_older_than(1, 3, 1, 0))
2072 for (y = 0; y < ymax; y++) for (x = 0; x < xmax; x++)
2074 /* Access the cave */
2075 c_ptr = &cave[y][x];
2077 /* Old CAVE_IN_MIRROR flag */
2078 if (c_ptr->info & CAVE_OBJECT)
2080 c_ptr->mimic = FEAT_MIRROR;
2083 /* Runes will be mimics and flags */
2084 else if (c_ptr->feat == FEAT_MINOR_GLYPH ||
2085 c_ptr->feat == FEAT_GLYPH)
2087 c_ptr->info |= CAVE_OBJECT;
2088 c_ptr->mimic = c_ptr->feat;
2089 c_ptr->feat = FEAT_FLOOR;
2092 /* Hidden traps will be trap terrains mimicing floor */
2093 else if (c_ptr->info & CAVE_TRAP)
2095 c_ptr->info &= ~CAVE_TRAP;
2096 c_ptr->mimic = c_ptr->feat;
2097 c_ptr->feat = choose_random_trap();
2100 /* Another hidden trap */
2101 else if (c_ptr->feat == FEAT_INVIS)
2103 c_ptr->mimic = FEAT_FLOOR;
2104 c_ptr->feat = FEAT_TRAP_OPEN;
2107 /* Hidden doors will be closed doors mimicing wall */
2108 else if (c_ptr->feat == FEAT_SECRET)
2110 place_closed_door(y, x);
2111 c_ptr->mimic = FEAT_WALL_EXTRA;
2118 /* Read the item count */
2121 /* Verify maximum */
2122 if (limit > max_o_idx)
2125 note(format("¥¢¥¤¥Æ¥à¤ÎÇÛÎó¤¬Â礤¹¤®¤ë(%d)¡ª", limit));
2127 note(format("Too many (%d) object entries!", limit));
2133 /* Read the dungeon items */
2134 for (i = 1; i < limit; i++)
2141 /* Get a new record */
2148 note(format("¥¢¥¤¥Æ¥àÇÛÃÖ¥¨¥é¡¼ (%d <> %d)", i, o_idx));
2150 note(format("Object allocation error (%d <> %d)", i, o_idx));
2158 o_ptr = &o_list[o_idx];
2164 /* XXX XXX XXX XXX XXX */
2167 if (o_ptr->held_m_idx)
2169 monster_type *m_ptr;
2172 m_ptr = &m_list[o_ptr->held_m_idx];
2175 o_ptr->next_o_idx = m_ptr->hold_o_idx;
2177 /* Place the object */
2178 m_ptr->hold_o_idx = o_idx;
2184 /* Access the item location */
2185 c_ptr = &cave[o_ptr->iy][o_ptr->ix];
2188 o_ptr->next_o_idx = c_ptr->o_idx;
2190 /* Place the object */
2191 c_ptr->o_idx = o_idx;
2198 /* Read the monster count */
2201 /* Hack -- verify */
2202 if (limit > max_m_idx)
2205 note(format("¥â¥ó¥¹¥¿¡¼¤ÎÇÛÎó¤¬Â礤¹¤®¤ë(%d)¡ª", limit));
2207 note(format("Too many (%d) monster entries!", limit));
2213 /* Read the monsters */
2214 for (i = 1; i < limit; i++)
2218 monster_type *m_ptr;
2220 monster_race *r_ptr;
2223 /* Get a new record */
2230 note(format("¥â¥ó¥¹¥¿¡¼ÇÛÃÖ¥¨¥é¡¼ (%d <> %d)", i, m_idx));
2232 note(format("Monster allocation error (%d <> %d)", i, m_idx));
2239 /* Acquire monster */
2240 m_ptr = &m_list[m_idx];
2242 /* Read the monster */
2247 c_ptr = &cave[m_ptr->fy][m_ptr->fx];
2249 /* Mark the location */
2250 c_ptr->m_idx = m_idx;
2253 /* Access real race */
2254 r_ptr = &r_info[m_ptr->r_idx];
2256 if (m_ptr->mflag2 & MFLAG_CHAMELEON)
2258 if (r_ptr->flags1 & RF1_UNIQUE)
2259 r_ptr = &r_info[MON_CHAMELEON_K];
2261 r_ptr = &r_info[MON_CHAMELEON];
2264 /* Count XXX XXX XXX */
2270 /* The dungeon is ready */
2271 if (z_older_than(10, 3, 13) && !dun_level && !p_ptr->inside_arena)
2272 character_dungeon = FALSE;
2274 character_dungeon = TRUE;
2283 * Actually read the savefile
2285 static errr rd_savefile_new_aux(void)
2297 #ifdef VERIFY_CHECKSUMS
2298 u32b n_x_check, n_v_check;
2299 u32b o_x_check, o_v_check;
2303 /* Mention the savefile version */
2306 "¥Ð¡¼¥¸¥ç¥ó %d.%d.%d ¤Î¥»¡¼¥Ö¡¦¥Õ¥¡¥¤¥ë¤ò¥í¡¼¥ÉÃæ...",
2308 "Loading a %d.%d.%d savefile...",
2310 (z_major > 9) ? z_major - 10 : z_major, z_minor, z_patch));
2313 /* Strip the version bytes */
2316 /* Hack -- decrypt */
2317 xor_byte = sf_extra;
2320 /* Clear the checksums */
2324 /* Read the version number of the savefile */
2325 /* Old savefile will be version 0.0.0.3 */
2326 rd_byte(&h_ver_extra);
2327 rd_byte(&h_ver_patch);
2328 rd_byte(&h_ver_minor);
2329 rd_byte(&h_ver_major);
2331 /* Operating system info */
2332 rd_u32b(&sf_system);
2334 /* Time of savefile creation */
2337 /* Number of resurrections */
2340 /* Number of times played */
2344 /* Later use (always zero) */
2347 /* Later use (always zero) */
2351 /* Read RNG state */
2354 if (arg_fiddle) note("Íð¿ô¾ðÊó¤ò¥í¡¼¥É¤·¤Þ¤·¤¿");
2356 if (arg_fiddle) note("Loaded Randomizer Info");
2361 /* Then the options */
2364 if (arg_fiddle) note("¥ª¥×¥·¥ç¥ó¤ò¥í¡¼¥É¤·¤Þ¤·¤¿");
2366 if (arg_fiddle) note("Loaded Option Flags");
2369 /* Then the "messages" */
2372 if (arg_fiddle) note("¥á¥Ã¥»¡¼¥¸¤ò¥í¡¼¥É¤·¤Þ¤·¤¿");
2374 if (arg_fiddle) note("Loaded Messages");
2379 for (i = 0; i < max_r_idx; i++)
2381 monster_race *r_ptr;
2382 /* Access that monster */
2385 /* Hack -- Reset the death counter */
2386 r_ptr->max_num = 100;
2387 if (r_ptr->flags1 & RF1_UNIQUE) r_ptr->max_num = 1;
2388 if (r_ptr->flags7 & RF7_UNIQUE_7) r_ptr->max_num = 7;
2391 /* Monster Memory */
2394 /* Incompatible save files */
2395 if (tmp16u > max_r_idx)
2398 note(format("¥â¥ó¥¹¥¿¡¼¤Î¼ï²¤¬Â¿¤¹¤®¤ë(%u)¡ª", tmp16u));
2400 note(format("Too many (%u) monster races!", tmp16u));
2406 /* Read the available records */
2407 for (i = 0; i < tmp16u; i++)
2409 monster_race *r_ptr;
2414 /* Access that monster */
2419 if (arg_fiddle) note("¥â¥ó¥¹¥¿¡¼¤Î»×¤¤½Ð¤ò¥í¡¼¥É¤·¤Þ¤·¤¿");
2421 if (arg_fiddle) note("Loaded Monster Memory");
2429 /* Incompatible save files */
2430 if (tmp16u > max_k_idx)
2433 note(format("¥¢¥¤¥Æ¥à¤Î¼ïÎब¿¤¹¤®¤ë(%u)¡ª", tmp16u));
2435 note(format("Too many (%u) object kinds!", tmp16u));
2441 /* Read the object memory */
2442 for (i = 0; i < tmp16u; i++)
2445 object_kind *k_ptr = &k_info[i];
2449 k_ptr->aware = (tmp8u & 0x01) ? TRUE: FALSE;
2450 k_ptr->tried = (tmp8u & 0x02) ? TRUE: FALSE;
2453 if (arg_fiddle) note("¥¢¥¤¥Æ¥à¤ÎµÏ¿¤ò¥í¡¼¥É¤·¤Þ¤·¤¿");
2455 if (arg_fiddle) note("Loaded Object Memory");
2461 * Initialize arena and rewards information
2463 p_ptr->arena_number = 0;
2464 p_ptr->inside_arena = 0;
2465 p_ptr->inside_quest = 0;
2466 p_ptr->leftbldg = FALSE;
2467 p_ptr->exit_bldg = TRUE;
2469 /* Start in town 1 */
2470 p_ptr->town_num = 1;
2472 p_ptr->wilderness_x = 4;
2473 p_ptr->wilderness_y = 4;
2477 /* Init the wilderness seeds */
2478 for (i = 0; i < max_wild_x; i++)
2480 for (j = 0; j < max_wild_y; j++)
2482 wilderness[j][i].seed = randint0(0x10000000);
2486 /* 2.1.3 or newer version */
2488 u16b max_towns_load;
2489 u16b max_quests_load;
2490 byte max_rquests_load;
2491 s16b old_inside_quest = p_ptr->inside_quest;
2493 /* Number of towns */
2494 rd_u16b(&max_towns_load);
2496 /* Incompatible save files */
2497 if (max_towns_load > max_towns)
2500 note(format("Ä®¤¬Â¿¤¹¤®¤ë(%u)¡ª", max_towns_load));
2502 note(format("Too many (%u) towns!", max_towns_load));
2508 /* Number of quests */
2509 rd_u16b(&max_quests_load);
2511 if (z_older_than(11, 0, 7))
2513 max_rquests_load = 10;
2517 rd_byte(&max_rquests_load);
2520 /* Incompatible save files */
2521 if (max_quests_load > max_quests)
2524 note(format("¥¯¥¨¥¹¥È¤¬Â¿¤¹¤®¤ë(%u)¡ª", max_quests_load));
2526 note(format("Too many (%u) quests!", max_quests_load));
2532 for (i = 0; i < max_quests_load; i++)
2536 rd_s16b(&quest[i].status);
2537 rd_s16b(&quest[i].level);
2539 if (z_older_than(11, 0, 6))
2541 quest[i].complev = 0;
2545 rd_byte(&quest[i].complev);
2548 /* Load quest status if quest is running */
2549 if (quest[i].status == QUEST_STATUS_TAKEN || (!z_older_than(10, 3, 14) && (quest[i].status == QUEST_STATUS_COMPLETED)) || (!z_older_than(11, 0, 7) && (i >= MIN_RANDOM_QUEST) && (i <= (MIN_RANDOM_QUEST+max_rquests_load))))
2551 rd_s16b(&quest[i].cur_num);
2552 rd_s16b(&quest[i].max_num);
2553 rd_s16b(&quest[i].type);
2555 /* Load quest monster index */
2556 rd_s16b(&quest[i].r_idx);
2558 if ((quest[i].type == QUEST_TYPE_RANDOM) && (!quest[i].r_idx))
2563 monster_race *r_ptr;
2566 * Random monster 5 - 10 levels out of depth
2567 * (depending on level)
2569 r_idx = get_mon_num(quest[i].level + 5 + randint1(quest[i].level / 10));
2570 r_ptr = &r_info[r_idx];
2572 if(!(r_ptr->flags1 & RF1_UNIQUE)) continue;
2574 if(r_ptr->flags6 & RF6_SPECIAL) continue;
2576 if(r_ptr->flags7 & RF7_FRIENDLY) continue;
2578 if(r_ptr->flags7 & RF7_AQUATIC) continue;
2580 if(r_ptr->flags8 & RF8_WILD_ONLY) continue;
2583 * Accept monsters that are 2 - 6 levels
2584 * out of depth depending on the quest level
2586 if (r_ptr->level > (quest[i].level + (quest[i].level / 20))) break;
2589 quest[i].r_idx = r_idx;
2592 /* Load quest item index */
2593 rd_s16b(&quest[i].k_idx);
2596 a_info[quest[i].k_idx].gen_flags |= TRG_QUESTITEM;
2598 rd_byte(&quest[i].flags);
2600 if (z_older_than(10, 3, 11))
2602 if (quest[i].flags & QUEST_FLAG_PRESET)
2604 quest[i].dungeon = 0;
2608 init_flags = INIT_ASSIGN;
2609 p_ptr->inside_quest = i;
2611 process_dungeon_file("q_info.txt", 0, 0, 0, 0);
2612 p_ptr->inside_quest = old_inside_quest;
2617 rd_byte(&quest[i].dungeon);
2620 if (quest[i].status == QUEST_STATUS_TAKEN || quest[i].status == QUEST_STATUS_UNTAKEN)
2621 if (r_info[quest[i].r_idx].flags1 & RF1_UNIQUE)
2622 r_info[quest[i].r_idx].flags1 |= RF1_QUESTOR;
2625 /* Ignore the empty quests from old versions */
2628 /* Ignore quest status */
2631 /* Ignore quest level */
2635 * We don't have to care about the other info,
2636 * since status should be 0 for these quests anyway
2641 /* Position in the wilderness */
2642 rd_s32b(&p_ptr->wilderness_x);
2643 rd_s32b(&p_ptr->wilderness_y);
2644 if (z_older_than(10, 3, 13))
2646 p_ptr->wilderness_x = 5;
2647 p_ptr->wilderness_y = 48;
2650 if (z_older_than(10, 3, 7)) p_ptr->wild_mode = FALSE;
2651 else rd_byte((byte *)&p_ptr->wild_mode);
2652 if (z_older_than(10, 3, 7)) ambush_flag = FALSE;
2653 else rd_byte((byte *)&ambush_flag);
2655 /* Size of the wilderness */
2656 rd_s32b(&wild_x_size);
2657 rd_s32b(&wild_y_size);
2659 /* Incompatible save files */
2660 if ((wild_x_size > max_wild_x) || (wild_y_size > max_wild_y))
2663 note(format("¹ÓÌÂ礤¹¤®¤ë(%u/%u)¡ª", wild_x_size, wild_y_size));
2665 note(format("Wilderness is too big (%u/%u)!", wild_x_size, wild_y_size));
2671 /* Load the wilderness seeds */
2672 for (i = 0; i < wild_x_size; i++)
2674 for (j = 0; j < wild_y_size; j++)
2676 rd_u32b(&wilderness[j][i].seed);
2682 if (arg_fiddle) note("¥¯¥¨¥¹¥È¾ðÊó¤ò¥í¡¼¥É¤·¤Þ¤·¤¿");
2684 if (arg_fiddle) note("Loaded Quests");
2687 /* Load the Artifacts */
2690 /* Incompatible save files */
2691 if (tmp16u > max_a_idx)
2694 note(format("ÅÁÀâ¤Î¥¢¥¤¥Æ¥à¤¬Â¿¤¹¤®¤ë(%u)¡ª", tmp16u));
2696 note(format("Too many (%u) artifacts!", tmp16u));
2702 /* Read the artifact flags */
2703 for (i = 0; i < tmp16u; i++)
2706 a_info[i].cur_num = tmp8u;
2712 if (arg_fiddle) note("ÅÁÀâ¤Î¥¢¥¤¥Æ¥à¤ò¥í¡¼¥É¤·¤Þ¤·¤¿");
2714 if (arg_fiddle) note("Loaded Artifacts");
2719 /* Read the extra stuff */
2721 if (p_ptr->energy_need < -999) world_player = TRUE;
2724 if (arg_fiddle) note("ÆÃÊ̾ðÊó¤ò¥í¡¼¥É¤·¤Þ¤·¤¿");
2726 if (arg_fiddle) note("Loaded extra information");
2730 /* Read the player_hp array */
2733 /* Incompatible save files */
2734 if (tmp16u > PY_MAX_LEVEL)
2737 note(format("¥Ò¥Ã¥È¥Ý¥¤¥ó¥ÈÇÛÎó¤¬Â礤¹¤®¤ë(%u)¡ª", tmp16u));
2739 note(format("Too many (%u) hitpoint entries!", tmp16u));
2745 /* Read the player_hp array */
2746 for (i = 0; i < tmp16u; i++)
2748 rd_s16b(&p_ptr->player_hp[i]);
2751 /* Important -- Initialize the sex */
2752 sp_ptr = &sex_info[p_ptr->psex];
2754 /* Important -- Initialize the race/class */
2755 rp_ptr = &race_info[p_ptr->prace];
2756 cp_ptr = &class_info[p_ptr->pclass];
2757 ap_ptr = &seikaku_info[p_ptr->pseikaku];
2759 if(z_older_than(10, 2, 2) && (p_ptr->pclass == CLASS_BEASTMASTER) && !p_ptr->is_dead)
2761 p_ptr->hitdie = rp_ptr->r_mhp + cp_ptr->c_mhp + ap_ptr->a_mhp;
2762 do_cmd_rerate(FALSE);
2764 if(z_older_than(10, 3, 2) && (p_ptr->pclass == CLASS_ARCHER) && !p_ptr->is_dead)
2766 p_ptr->hitdie = rp_ptr->r_mhp + cp_ptr->c_mhp + ap_ptr->a_mhp;
2767 do_cmd_rerate(FALSE);
2769 if(z_older_than(10, 2, 6) && (p_ptr->pclass == CLASS_SORCERER) && !p_ptr->is_dead)
2771 p_ptr->hitdie = rp_ptr->r_mhp/2 + cp_ptr->c_mhp + ap_ptr->a_mhp;
2772 do_cmd_rerate(FALSE);
2774 if(z_older_than(10, 4, 7) && (p_ptr->pclass == CLASS_BLUE_MAGE) && !p_ptr->is_dead)
2776 p_ptr->hitdie = rp_ptr->r_mhp + cp_ptr->c_mhp + ap_ptr->a_mhp;
2777 do_cmd_rerate(FALSE);
2780 /* Important -- Initialize the magic */
2781 mp_ptr = &m_info[p_ptr->pclass];
2784 /* Read spell info */
2785 rd_u32b(&p_ptr->spell_learned1);
2786 rd_u32b(&p_ptr->spell_learned2);
2787 rd_u32b(&p_ptr->spell_worked1);
2788 rd_u32b(&p_ptr->spell_worked2);
2789 rd_u32b(&p_ptr->spell_forgotten1);
2790 rd_u32b(&p_ptr->spell_forgotten2);
2792 if (z_older_than(10,0,5))
2794 p_ptr->learned_spells = 0;
2795 for (i = 0; i < 64; i++)
2797 /* Count known spells */
2799 (p_ptr->spell_learned1 & (1L << i)) :
2800 (p_ptr->spell_learned2 & (1L << (i - 32))))
2802 p_ptr->learned_spells++;
2806 else rd_s16b(&p_ptr->learned_spells);
2808 if (z_older_than(10,0,6))
2810 p_ptr->add_spells = 0;
2812 else rd_s16b(&p_ptr->add_spells);
2813 if (p_ptr->pclass == CLASS_MINDCRAFTER) p_ptr->add_spells = 0;
2815 for (i = 0; i < 64; i++)
2817 rd_byte(&p_ptr->spell_order[i]);
2821 /* Read the inventory */
2825 note("»ý¤Áʪ¾ðÊó¤òÆɤ߹þ¤à¤³¤È¤¬¤Ç¤¤Þ¤»¤ó");
2827 note("Unable to read inventory");
2833 /* Read number of towns */
2835 town_count = tmp16u;
2837 /* Read the stores */
2839 for (i = 1; i < town_count; i++)
2841 for (j = 0; j < tmp16u; j++)
2843 if (rd_store(i, j)) return (22);
2847 rd_s16b(&p_ptr->pet_follow_distance);
2848 if (z_older_than(10, 4, 10))
2850 p_ptr->pet_extra_flags = 0;
2852 if (tmp8u) p_ptr->pet_extra_flags |= PF_OPEN_DOORS;
2854 if (tmp8u) p_ptr->pet_extra_flags |= PF_PICKUP_ITEMS;
2856 if (z_older_than(10,0,4)) p_ptr->pet_extra_flags |= PF_TELEPORT;
2860 if (tmp8u) p_ptr->pet_extra_flags |= PF_TELEPORT;
2863 if (z_older_than(10,0,7)) p_ptr->pet_extra_flags |= PF_ATTACK_SPELL;
2867 if (tmp8u) p_ptr->pet_extra_flags |= PF_ATTACK_SPELL;
2870 if (z_older_than(10,0,8)) p_ptr->pet_extra_flags |= PF_SUMMON_SPELL;
2874 if (tmp8u) p_ptr->pet_extra_flags |= PF_SUMMON_SPELL;
2877 if (!z_older_than(10,0,8))
2880 if (tmp8u) p_ptr->pet_extra_flags |= PF_BALL_SPELL;
2885 rd_s16b(&p_ptr->pet_extra_flags);
2888 if (!z_older_than(11, 0, 9))
2890 char buf[SCREEN_BUF_SIZE];
2891 rd_string(buf, sizeof(buf));
2892 if (buf[0]) screen_dump = string_make(buf);
2897 for (i = MIN_RANDOM_QUEST; i < MAX_RANDOM_QUEST + 1; i++)
2899 r_info[quest[i].r_idx].flags1 &= ~(RF1_QUESTOR);
2904 /* I'm not dead yet... */
2905 if (!p_ptr->is_dead)
2907 /* Dead players have no dungeon */
2909 note("¥À¥ó¥¸¥ç¥óÉü¸µÃæ...");
2911 note("Restoring Dungeon...");
2917 note("¥À¥ó¥¸¥ç¥ó¥Ç¡¼¥¿Æɤ߹þ¤ß¼ºÇÔ");
2919 note("Error reading dungeon data");
2925 /* Read the ghost info */
2932 strip_bytes(tmp32s);
2937 #ifdef VERIFY_CHECKSUMS
2939 /* Save the checksum */
2940 n_v_check = v_check;
2942 /* Read the old checksum */
2943 rd_u32b(&o_v_check);
2946 if (o_v_check != n_v_check)
2949 note("¥Á¥§¥Ã¥¯¥µ¥à¤¬¤ª¤«¤·¤¤");
2951 note("Invalid checksum");
2958 /* Save the encoded checksum */
2959 n_x_check = x_check;
2961 /* Read the checksum */
2962 rd_u32b(&o_x_check);
2966 if (o_x_check != n_x_check)
2969 note("¥¨¥ó¥³¡¼¥É¤µ¤ì¤¿¥Á¥§¥Ã¥¯¥µ¥à¤¬¤ª¤«¤·¤¤");
2971 note("Invalid encoded checksum");
2985 * Actually read the savefile
2987 errr rd_savefile_new(void)
2991 /* The savefile is a binary file */
2992 fff = my_fopen(savefile, "rb");
2995 if (!fff) return (-1);
2997 /* Call the sub-function */
2998 err = rd_savefile_new_aux();
3000 /* Check for errors */
3001 if (ferror(fff)) err = -1;
3003 /* Close the file */