X-Git-Url: http://git.osdn.net/view?a=blobdiff_plain;f=src%2Fload.c;h=3ce463eb9f0363d809de06a0819f2986e7b93530;hb=6ab40036f862c33829d4a5fbe66cda44214db2ad;hp=5b950a03c3367e8d15e94ea6602931a6b90ded0c;hpb=274047d714b89bda4b069372ace7f762817f1ab5;p=hengband%2Fhengband.git diff --git a/src/load.c b/src/load.c index 5b950a03c..3ce463eb9 100644 --- a/src/load.c +++ b/src/load.c @@ -37,10 +37,12 @@ * the existing "number of turns to protect for", and where each hit * by a monster will reduce the shield by that amount. * - * XXX XXX XXX + * */ #include "angband.h" +#include "generate.h" +#include "trap.h" /* @@ -137,14 +139,14 @@ static bool z_older_than(byte x, byte y, byte z) /*! * @brief ã²ã¼ã ã¹ã¯ãªã¼ã³ã«ã¡ãã»ã¼ã¸ã表示ãã / Hack -- Show information on the screen, one line at a time. - * @param cptr 表示æåå + * @param msg 表示æåå * @return ãªã * @details * Avoid the top two lines, to avoid interference with "msg_print()". */ static void note(cptr msg) { - static int y = 2; + static TERM_LEN y = 2; /* Draw the message */ prt(msg, y, 0); @@ -157,11 +159,13 @@ static void note(cptr msg) } -/* +/*! + * @brief ãã¼ããã¡ã¤ã«ãã¤ã³ã¿ãã1ãã¤ããèªã¿è¾¼ã + * @return èªã¿è¾¼ãã ãã¤ãå¤ + * @details * The following functions are used to load the basic building blocks * of savefiles. They also maintain the "checksum" info for 2.7.0+ */ - static byte sf_get(void) { byte c, v; @@ -179,22 +183,42 @@ static byte sf_get(void) return (v); } +/*! + * @brief ãã¼ããã¡ã¤ã«ãã¤ã³ã¿ãã1ãã¤ããèªã¿è¾¼ãã§ãã¤ã³ã¿ã«æ¸¡ã + * @param ip èªã¿è¾¼ã¿ãã¤ã³ã¿ + * @return ãªã + */ static void rd_byte(byte *ip) { *ip = sf_get(); } +/*! + * @brief ãã¼ããã¡ã¤ã«ãã¤ã³ã¿ãã符å·ãªã16bitå¤ãèªã¿è¾¼ãã§ãã¤ã³ã¿ã«æ¸¡ã + * @param ip èªã¿è¾¼ã¿ãã¤ã³ã¿ + * @return ãªã + */ static void rd_u16b(u16b *ip) { (*ip) = sf_get(); (*ip) |= ((u16b)(sf_get()) << 8); } +/*! + * @brief ãã¼ããã¡ã¤ã«ãã¤ã³ã¿ãã符å·ã¤ã16bitå¤ãèªã¿è¾¼ãã§ãã¤ã³ã¿ã«æ¸¡ã + * @param ip èªã¿è¾¼ã¿ãã¤ã³ã¿ + * @return ãªã + */ static void rd_s16b(s16b *ip) { rd_u16b((u16b*)ip); } +/*! + * @brief ãã¼ããã¡ã¤ã«ãã¤ã³ã¿ãã符å·ãªã32bitå¤ãèªã¿è¾¼ãã§ãã¤ã³ã¿ã«æ¸¡ã + * @param ip èªã¿è¾¼ã¿ãã¤ã³ã¿ + * @return ãªã + */ static void rd_u32b(u32b *ip) { (*ip) = sf_get(); @@ -203,14 +227,22 @@ static void rd_u32b(u32b *ip) (*ip) |= ((u32b)(sf_get()) << 24); } +/*! + * @brief ãã¼ããã¡ã¤ã«ãã¤ã³ã¿ãã符å·ã¤ã32bitå¤ãèªã¿è¾¼ãã§ãã¤ã³ã¿ã«æ¸¡ã + * @param ip èªã¿è¾¼ã¿ãã¤ã³ã¿ + * @return ãªã + */ static void rd_s32b(s32b *ip) { rd_u32b((u32b*)ip); } -/* - * Hack -- read a string +/*! + * @brief ãã¼ããã¡ã¤ã«ãã¤ã³ã¿ããæååãèªã¿è¾¼ãã§ãã¤ã³ã¿ã«æ¸¡ã / Hack -- read a string + * @param str èªã¿è¾¼ã¿ãã¤ã³ã¿ + * @param max æ大èªã¿åããã¤ãæ° + * @return ãªã */ static void rd_string(char *str, int max) { @@ -271,8 +303,10 @@ static void rd_string(char *str, int max) } -/* - * Hack -- strip some bytes +/*! + * @brief ãã¼ããã¡ã¤ã«ãã¤ã³ã¿ãæå®ãã¤ãåé£ã°ãã¦é²ãã / Hack -- strip some bytes + * @param n ã¹ããããã¤ãæ° + * @return ãªã */ static void strip_bytes(int n) { @@ -284,9 +318,11 @@ static void strip_bytes(int n) #define OLD_MAX_MANE 22 -/* - * Read an object (Old method) - * +/*! + * @brief ã¢ã¤ãã ãªãã¸ã§ã¯ãï¼ä»¶ãèªã¿è¾¼ã(å¤æver1.5.0以å) / Read an object (Old method) + * @param o_ptr ã¢ã¤ãã ãªãã¸ã§ã¯ãèªã¿åãå ãã¤ã³ã¿ + * @return ãªã + * @details * This function attempts to "repair" old savefiles, and to extract * the most up to date values for various object fields. * @@ -304,18 +340,23 @@ static void strip_bytes(int n) static void rd_item_old(object_type *o_ptr) { char buf[128]; + byte_hack tmp8u; + s16b tmp16s; /* Kind */ rd_s16b(&o_ptr->k_idx); - /* Location */ - rd_byte(&o_ptr->iy); - rd_byte(&o_ptr->ix); + rd_byte(&tmp8u); + o_ptr->iy = (POSITION)tmp8u; + rd_byte(&tmp8u); + o_ptr->ix = (POSITION)tmp8u; /* Type/Subtype */ - rd_byte(&o_ptr->tval); - rd_byte(&o_ptr->sval); + rd_byte(&tmp8u); + o_ptr->tval = tmp8u; + rd_byte(&tmp8u); + o_ptr->sval = tmp8u; if (z_older_than(10, 4, 4)) { @@ -328,21 +369,32 @@ static void rd_item_old(object_type *o_ptr) rd_s16b(&o_ptr->pval); rd_byte(&o_ptr->discount); - rd_byte(&o_ptr->number); - rd_s16b(&o_ptr->weight); + rd_byte(&tmp8u); + o_ptr->number = (ITEM_NUMBER)tmp8u; + + rd_s16b(&tmp16s); + o_ptr->weight = tmp16s; + + rd_byte(&tmp8u); + o_ptr->name1 = tmp8u; + + rd_byte(&tmp8u); + o_ptr->name2 = tmp8u; - rd_byte(&o_ptr->name1); - rd_byte(&o_ptr->name2); rd_s16b(&o_ptr->timeout); rd_s16b(&o_ptr->to_h); - rd_s16b(&o_ptr->to_d); + + rd_s16b(&tmp16s); + o_ptr->to_d = tmp16s; rd_s16b(&o_ptr->to_a); rd_s16b(&o_ptr->ac); - rd_byte(&o_ptr->dd); - rd_byte(&o_ptr->ds); + rd_byte(&tmp8u); + o_ptr->dd = tmp8u; + rd_byte(&tmp8u); + o_ptr->ds = tmp8u; rd_byte(&o_ptr->ident); @@ -549,14 +601,18 @@ static void rd_item_old(object_type *o_ptr) } -/* - * Read an object (New method) +/*! + * @brief ã¢ã¤ãã ãªãã¸ã§ã¯ããèªã¿è¾¼ã(ç¾ç) / Read an object (New method) + * @param o_ptr ã¢ã¤ãã ãªãã¸ã§ã¯ãä¿åå ãã¤ã³ã¿ + * @return ãªã */ static void rd_item(object_type *o_ptr) { object_kind *k_ptr; - u32b flags; + BIT_FLAGS flags; char buf[128]; + byte_hack tmp8u; + s16b tmp16s; if (h_older_than(1, 5, 0, 0)) { @@ -571,9 +627,10 @@ static void rd_item(object_type *o_ptr) /* Kind */ rd_s16b(&o_ptr->k_idx); - /* Location */ - rd_byte(&o_ptr->iy); - rd_byte(&o_ptr->ix); + rd_byte(&tmp8u); + o_ptr->iy = (POSITION)tmp8u; + rd_byte(&tmp8u); + o_ptr->ix = (POSITION)tmp8u; /* Type/Subtype */ k_ptr = &k_info[o_ptr->k_idx]; @@ -586,21 +643,37 @@ static void rd_item(object_type *o_ptr) if (flags & SAVE_ITEM_DISCOUNT) rd_byte(&o_ptr->discount); else o_ptr->discount = 0; - if (flags & SAVE_ITEM_NUMBER) rd_byte(&o_ptr->number); + if (flags & SAVE_ITEM_NUMBER) { + rd_byte(&tmp8u); + o_ptr->number = tmp8u; + } else o_ptr->number = 1; - rd_s16b(&o_ptr->weight); + rd_s16b(&tmp16s); + o_ptr->weight = tmp16s; - if (flags & SAVE_ITEM_NAME1) rd_byte(&o_ptr->name1); + if (flags & SAVE_ITEM_NAME1) + { + rd_byte(&tmp8u); + o_ptr->name1 = tmp8u; + } else o_ptr->name1 = 0; - if (flags & SAVE_ITEM_NAME2) rd_byte(&o_ptr->name2); + if (flags & SAVE_ITEM_NAME2) + { + rd_byte(&tmp8u); + o_ptr->name2 = tmp8u; + } else o_ptr->name2 = 0; if (flags & SAVE_ITEM_TIMEOUT) rd_s16b(&o_ptr->timeout); else o_ptr->timeout = 0; if (flags & SAVE_ITEM_TO_H) rd_s16b(&o_ptr->to_h); else o_ptr->to_h = 0; - if (flags & SAVE_ITEM_TO_D) rd_s16b(&o_ptr->to_d); + if (flags & SAVE_ITEM_TO_D) + { + rd_s16b(&tmp16s); + o_ptr->to_d = tmp16s; + } else o_ptr->to_d = 0; if (flags & SAVE_ITEM_TO_A) rd_s16b(&o_ptr->to_a); else o_ptr->to_a = 0; @@ -608,9 +681,17 @@ static void rd_item(object_type *o_ptr) if (flags & SAVE_ITEM_AC) rd_s16b(&o_ptr->ac); else o_ptr->ac = 0; - if (flags & SAVE_ITEM_DD) rd_byte(&o_ptr->dd); + if (flags & SAVE_ITEM_DD) + { + rd_byte(&tmp8u); + o_ptr->dd = tmp8u; + } else o_ptr->dd = 0; - if (flags & SAVE_ITEM_DS) rd_byte(&o_ptr->ds); + if (flags & SAVE_ITEM_DS) + { + rd_byte(&tmp8u); + o_ptr->ds = tmp8u; + } else o_ptr->ds = 0; if (flags & SAVE_ITEM_IDENT) rd_byte(&o_ptr->ident); @@ -671,7 +752,7 @@ static void rd_item(object_type *o_ptr) if(h_older_than(2,1,2,4)) { - u32b flgs[TR_FLAG_SIZE]; + BIT_FLAGS flgs[TR_FLAG_SIZE]; object_flags(o_ptr, flgs); if ((o_ptr->name2 == EGO_DARK) || (o_ptr->name2 == EGO_ANCIENT_CURSE) || (o_ptr->name1 == ART_NIGHT)) @@ -729,12 +810,16 @@ static void rd_item(object_type *o_ptr) } -/* - * Read a monster (Old method) +/*! + * @brief ã¢ã³ã¹ã¿ã¼ãèªã¿è¾¼ã(å¤æver1.5.0以å) / Read a monster (Old method) + * @param m_ptr ã¢ã³ã¹ã¿ã¼ä¿åå ãã¤ã³ã¿ + * @return ãªã */ static void rd_monster_old(monster_type *m_ptr) { byte tmp8u; + s16b tmp16s; + u32b tmp32u; char buf[128]; /* Read the monster race */ @@ -757,17 +842,24 @@ static void rd_monster_old(monster_type *m_ptr) rd_byte(&m_ptr->sub_align); /* Read the other information */ - rd_byte(&m_ptr->fy); - rd_byte(&m_ptr->fx); - rd_s16b(&m_ptr->hp); - rd_s16b(&m_ptr->maxhp); + rd_byte(&tmp8u); + m_ptr->fy = (POSITION)tmp8u; + rd_byte(&tmp8u); + m_ptr->fx = (POSITION)tmp8u; + + rd_s16b(&tmp16s); + m_ptr->hp = tmp16s; + rd_s16b(&tmp16s); + m_ptr->maxhp = tmp16s; + if (z_older_than(11, 0, 5)) { m_ptr->max_maxhp = m_ptr->maxhp; } else { - rd_s16b(&m_ptr->max_maxhp); + rd_s16b(&tmp16s); + m_ptr->max_maxhp = (HIT_POINT)tmp16s; } if(h_older_than(2, 1, 2, 1)) { @@ -775,7 +867,7 @@ static void rd_monster_old(monster_type *m_ptr) } else { - rd_u32b(&m_ptr->dealt_damage); + rd_s32b(&m_ptr->dealt_damage); } rd_s16b(&m_ptr->mtimed[MTIMED_CSLEEP]); @@ -815,14 +907,15 @@ static void rd_monster_old(monster_type *m_ptr) } else if (z_older_than(10,0,11)) { - s16b tmp16s; rd_s16b(&tmp16s); reset_target(m_ptr); } else { - rd_s16b(&m_ptr->target_y); - rd_s16b(&m_ptr->target_x); + rd_s16b(&tmp16s); + m_ptr->target_y = (POSITION)tmp16s; + rd_s16b(&tmp16s); + m_ptr->target_x = (POSITION)tmp16s; } rd_byte(&tmp8u); @@ -833,10 +926,12 @@ static void rd_monster_old(monster_type *m_ptr) else m_ptr->smart = 0; - if (z_older_than(10, 4, 5)) + if (z_older_than(10, 4, 5)) { m_ptr->exp = 0; - else - rd_u32b(&m_ptr->exp); + } else { + rd_u32b(&tmp32u); + m_ptr->exp = tmp32u; + } if (z_older_than(10, 2, 2)) { @@ -871,14 +966,18 @@ static void rd_monster_old(monster_type *m_ptr) } -/* - * Read a monster (New method) +/*! + * @brief ã¢ã³ã¹ã¿ã¼ãèªã¿è¾¼ã(ç¾ç) / Read a monster (New method) + * @param m_ptr ã¢ã³ã¹ã¿ã¼ä¿åå ãã¤ã³ã¿ + * @return ãªã */ static void rd_monster(monster_type *m_ptr) { - u32b flags; + BIT_FLAGS flags; char buf[128]; byte tmp8u; + s16b tmp16s; + u32b tmp32u; if (h_older_than(1, 5, 0, 0)) { @@ -895,18 +994,25 @@ static void rd_monster(monster_type *m_ptr) rd_s16b(&m_ptr->r_idx); /* Read the other information */ - rd_byte(&m_ptr->fy); - rd_byte(&m_ptr->fx); - rd_s16b(&m_ptr->hp); - rd_s16b(&m_ptr->maxhp); - rd_s16b(&m_ptr->max_maxhp); + rd_byte(&tmp8u); + m_ptr->fy = (POSITION)tmp8u; + rd_byte(&tmp8u); + m_ptr->fx = (POSITION)tmp8u; + + rd_s16b(&tmp16s); + m_ptr->hp = (HIT_POINT)tmp16s; + rd_s16b(&tmp16s); + m_ptr->maxhp = (HIT_POINT)tmp16s; + rd_s16b(&tmp16s); + m_ptr->max_maxhp = (HIT_POINT)tmp16s; + if(h_older_than(2, 1, 2, 1)) { m_ptr->dealt_damage = 0; } else { - rd_u32b(&m_ptr->dealt_damage); + rd_s32b(&m_ptr->dealt_damage); } /* Monster race index of its appearance */ @@ -954,9 +1060,17 @@ static void rd_monster(monster_type *m_ptr) } else m_ptr->mtimed[MTIMED_MONFEAR] = 0; - if (flags & SAVE_MON_TARGET_Y) rd_s16b(&m_ptr->target_y); + if (flags & SAVE_MON_TARGET_Y) + { + rd_s16b(&tmp16s); + m_ptr->target_y = (POSITION)tmp16s; + } else m_ptr->target_y = 0; - if (flags & SAVE_MON_TARGET_X) rd_s16b(&m_ptr->target_x); + if (flags & SAVE_MON_TARGET_X) + { + rd_s16b(&tmp16s); + m_ptr->target_x = (POSITION)tmp16s; + } else m_ptr->target_x = 0; if (flags & SAVE_MON_INVULNER) @@ -969,7 +1083,11 @@ static void rd_monster(monster_type *m_ptr) if (flags & SAVE_MON_SMART) rd_u32b(&m_ptr->smart); else m_ptr->smart = 0; - if (flags & SAVE_MON_EXP) rd_u32b(&m_ptr->exp); + if (flags & SAVE_MON_EXP) + { + rd_u32b(&tmp32u); + m_ptr->exp = (EXP)tmp32u; + } else m_ptr->exp = 0; m_ptr->mflag = 0; /* Not saved */ @@ -1032,28 +1150,37 @@ static void rd_monster(monster_type *m_ptr) #define RF4_BR_GRAV 0x00800000 /* Breathe Gravity */ #define RF4_BR_SHAR 0x01000000 /* Breathe Shards */ #define RF4_BR_WALL 0x04000000 /* Breathe Force */ -/* - * Read the monster lore + +/*! + * @brief ã¢ã³ã¹ã¿ã¼ã®æãåºãèªã¿è¾¼ã / Read the monster lore + * @param r_idx èªã¿è¾¼ã¿å ã¢ã³ã¹ã¿ã¼ID + * @return ãªã */ -static void rd_lore(int r_idx) +static void rd_lore(MONRACE_IDX r_idx) { byte tmp8u; + s16b tmp16s; monster_race *r_ptr = &r_info[r_idx]; /* Count sights/deaths/kills */ - rd_s16b(&r_ptr->r_sights); - rd_s16b(&r_ptr->r_deaths); - rd_s16b(&r_ptr->r_pkills); + rd_s16b(&tmp16s); + r_ptr->r_sights = (MONSTER_NUMBER)tmp16s; + rd_s16b(&tmp16s); + r_ptr->r_deaths = (MONSTER_NUMBER)tmp16s; + rd_s16b(&tmp16s); + r_ptr->r_pkills = (MONSTER_NUMBER)tmp16s; if (h_older_than(1, 7, 0, 5)) { r_ptr->r_akills = r_ptr->r_pkills; } else { - rd_s16b(&r_ptr->r_akills); + rd_s16b(&tmp16s); + r_ptr->r_akills = (MONSTER_NUMBER)tmp16s; } - rd_s16b(&r_ptr->r_tkills); + rd_s16b(&tmp16s); + r_ptr->r_tkills = (MONSTER_NUMBER)tmp16s; /* Count wakes and ignores */ rd_byte(&r_ptr->r_wake); @@ -1064,8 +1191,10 @@ static void rd_lore(int r_idx) rd_byte(&r_ptr->r_xtra2); /* Count drops */ - rd_byte(&r_ptr->r_drop_gold); - rd_byte(&r_ptr->r_drop_item); + rd_byte(&tmp8u); + r_ptr->r_drop_gold = (ITEM_NUMBER)tmp8u; + rd_byte(&tmp8u); + r_ptr->r_drop_item = (ITEM_NUMBER)tmp8u; /* Count spells */ rd_byte(&tmp8u); @@ -1126,7 +1255,8 @@ static void rd_lore(int r_idx) } /* Read the "Racial" monster limit per level */ - rd_byte(&r_ptr->max_num); + rd_byte(&tmp8u); + r_ptr->max_num = (MONSTER_NUMBER)tmp8u; /* Location in saved floor */ rd_s16b(&r_ptr->floor_id); @@ -1139,17 +1269,17 @@ static void rd_lore(int r_idx) r_ptr->r_flags2 &= r_ptr->flags2; r_ptr->r_flags3 &= r_ptr->flags3; r_ptr->r_flags4 &= r_ptr->flags4; - r_ptr->r_flags5 &= r_ptr->flags5; - r_ptr->r_flags6 &= r_ptr->flags6; + r_ptr->r_flags5 &= r_ptr->a_ability_flags1; + r_ptr->r_flags6 &= r_ptr->a_ability_flags2; r_ptr->r_flagsr &= r_ptr->flagsr; } - - - -/* - * Add the item "o_ptr" to the inventory of the "Home" - * +/*! + * @brief åºç½®ãã®ã¢ã¤ãã ãªãã¸ã§ã¯ããèªã¿è¾¼ã / Add the item "o_ptr" to the inventory of the "Home" + * @param st_ptr åºèã®åç §ãã¤ã³ã¿ + * @param o_ptr ã¢ã¤ãã ãªãã¸ã§ã¯ãåç §ãã¤ã³ã¿ + * @return ãªã + * @details * In all cases, return the slot (or -1) where the object was placed * * Note that this is a hacked up version of "inven_carry()". @@ -1214,9 +1344,11 @@ static void home_carry(store_type *st_ptr, object_type *o_ptr) return; } - -/* - * Read a store +/*! + * @brief åºèæ å ±ãèªã¿è¾¼ã / Read a store + * @param town_number è¡ID + * @param store_number åºèID + * @return ã¨ã©ã¼ID */ static errr rd_store(int town_number, int store_number) { @@ -1270,8 +1402,6 @@ static errr rd_store(int town_number, int store_number) /* Get local object */ q_ptr = &forge; - - /* Wipe the object */ object_wipe(q_ptr); /* Read the item */ @@ -1300,9 +1430,9 @@ static errr rd_store(int town_number, int store_number) } - -/* - * Read RNG state (added in 2.8.0) +/*! + * @brief ä¹±æ°ç¶æ ãèªã¿è¾¼ã / Read RNG state (added in 2.8.0) + * @return ãªã */ static void rd_randomizer(void) { @@ -1325,9 +1455,10 @@ static void rd_randomizer(void) -/* - * Read options (ignore most pre-2.8.0 options) - * +/*! + * @brief ã²ã¼ã ãªãã·ã§ã³ãèªã¿è¾¼ã / Read options (ignore most pre-2.8.0 options) + * @return ãªã + * @details * Note that the normal options are now stored as a set of 256 bit flags, * plus a set of 256 bit masks to indicate which bit flags were defined * at the time the savefile was created. This will allow new options @@ -1340,21 +1471,15 @@ static void rd_randomizer(void) static void rd_options(void) { int i, n; - byte b; - u16b c; - u32b flag[8]; - u32b mask[8]; - - - /*** Oops ***/ + BIT_FLAGS flag[8]; + BIT_FLAGS mask[8]; /* Ignore old options */ strip_bytes(16); - /*** Special info */ /* Read "delay_factor" */ @@ -1376,7 +1501,6 @@ static void rd_options(void) mana_warn = b; } - /*** Cheating options ***/ rd_u16b(&c); @@ -1390,6 +1514,9 @@ static void rd_options(void) cheat_know = (c & 0x1000) ? TRUE : FALSE; cheat_live = (c & 0x2000) ? TRUE : FALSE; cheat_save = (c & 0x4000) ? TRUE : FALSE; + cheat_diary_output = (c & 0x8000) ? TRUE : FALSE; + cheat_turn = (c & 0x0080) ? TRUE : FALSE; + cheat_sight = (c & 0x0040) ? TRUE : FALSE; rd_byte((byte *)&autosave_l); rd_byte((byte *)&autosave_t); @@ -1501,12 +1628,11 @@ static void rd_options(void) - - -/* - * Hack -- strip the "ghost" info - * - * XXX XXX XXX This is such a nasty hack it hurts. +/*! + * @brief ããã¼æ å ±ã¹ããã / Hack -- strip the "ghost" info + * @return ãªã + * @details + * This is such a nasty hack it hurts. */ static void rd_ghost(void) { @@ -1520,12 +1646,14 @@ static void rd_ghost(void) } -/* - * Save quick start data +/*! + * @brief ã¯ã¤ãã¯ã¹ã¿ã¼ãæ å ±ãèªã¿è¾¼ã / Load quick start data + * @return ãªã */ static void load_quick_start(void) { byte tmp8u; + s16b tmp16s; int i; if (z_older_than(11, 0, 13)) @@ -1538,8 +1666,10 @@ static void load_quick_start(void) rd_byte(&previous_char.prace); rd_byte(&previous_char.pclass); rd_byte(&previous_char.pseikaku); - rd_byte(&previous_char.realm1); - rd_byte(&previous_char.realm2); + rd_byte(&tmp8u); + previous_char.realm1 = (REALM_IDX)tmp8u; + rd_byte(&tmp8u); + previous_char.realm2 = (REALM_IDX)tmp8u; rd_s16b(&previous_char.age); rd_s16b(&previous_char.ht); @@ -1550,7 +1680,11 @@ static void load_quick_start(void) for (i = 0; i < 6; i++) rd_s16b(&previous_char.stat_max[i]); for (i = 0; i < 6; i++) rd_s16b(&previous_char.stat_max_max[i]); - for (i = 0; i < PY_MAX_LEVEL; i++) rd_s16b(&previous_char.player_hp[i]); + for (i = 0; i < PY_MAX_LEVEL; i++) + { + rd_s16b(&tmp16s); + previous_char.player_hp[i] = (HIT_POINT)tmp16s; + } rd_s16b(&previous_char.chaos_patron); @@ -1565,8 +1699,9 @@ static void load_quick_start(void) previous_char.quick_ok = (bool)tmp8u; } -/* - * Read the "extra" information +/*! + * @brief ãã®ä»ã®æ å ±ãèªã¿è¾¼ã / Read the "extra" information + * @return ãªã */ static void rd_extra(void) { @@ -1574,9 +1709,10 @@ static void rd_extra(void) byte tmp8u; s16b tmp16s; + s32b tmp32s; u16b tmp16u; - rd_string(player_name, sizeof(player_name)); + rd_string(p_ptr->name, sizeof(p_ptr->name)); rd_string(p_ptr->died_from, sizeof(p_ptr->died_from)); @@ -1601,9 +1737,11 @@ static void rd_extra(void) rd_byte(&p_ptr->pclass); rd_byte(&p_ptr->pseikaku); rd_byte(&p_ptr->psex); - rd_byte(&p_ptr->realm1); - rd_byte(&p_ptr->realm2); - rd_byte(&tmp8u); /* oops */ + rd_byte(&tmp8u); + p_ptr->realm1 = (REALM_IDX)tmp8u; + rd_byte(&tmp8u); + p_ptr->realm2 = (REALM_IDX)tmp8u; + rd_byte(&tmp8u); if (z_older_than(10, 4, 4)) { @@ -1614,7 +1752,8 @@ static void rd_extra(void) } /* Special Race/Class info */ - rd_byte(&p_ptr->hitdie); + rd_byte(&tmp8u); + p_ptr->hitdie = tmp8u; rd_u16b(&p_ptr->expfact); /* Age/Height/Weight */ @@ -1627,8 +1766,7 @@ static void rd_extra(void) for (i = 0; i < 6; i++) rd_s16b(&p_ptr->stat_max_max[i]); for (i = 0; i < 6; i++) rd_s16b(&p_ptr->stat_cur[i]); - strip_bytes(24); /* oops */ - + strip_bytes(24); rd_s32b(&p_ptr->au); rd_s32b(&p_ptr->max_exp); @@ -1657,7 +1795,7 @@ static void rd_extra(void) for (i = 0; i < 5; i++) for (j = 0; j < 60; j++) rd_s16b(&p_ptr->weapon_exp[i][j]); else for (i = 0; i < 5; i++) for (j = 0; j < 64; j++) rd_s16b(&p_ptr->weapon_exp[i][j]); - for (i = 0; i < 10; i++) rd_s16b(&p_ptr->skill_exp[i]); + for (i = 0; i < GINOU_MAX; i++) rd_s16b(&p_ptr->skill_exp[i]); if (z_older_than(10, 4, 1)) { if (p_ptr->pclass != CLASS_BEASTMASTER) p_ptr->skill_exp[GINOU_RIDING] /= 2; @@ -1695,14 +1833,16 @@ static void rd_extra(void) else { rd_byte(&p_ptr->start_race); - rd_s32b(&p_ptr->old_race1); - rd_s32b(&p_ptr->old_race2); + rd_s32b(&tmp32s); + p_ptr->old_race1 = (BIT_FLAGS)tmp32s; + rd_s32b(&tmp32s); + p_ptr->old_race2 = (BIT_FLAGS)tmp32s; rd_s16b(&p_ptr->old_realm); } if (z_older_than(10, 0, 1)) { - for (i = 0; i < OLD_MAX_MANE; i++) + for (i = 0; i < MAX_MANE; i++) { p_ptr->mane_spell[i] = -1; p_ptr->mane_dam[i] = 0; @@ -1728,8 +1868,10 @@ static void rd_extra(void) { for (i = 0; i < MAX_MANE; i++) { - rd_s16b(&p_ptr->mane_spell[i]); - rd_s16b(&p_ptr->mane_dam[i]); + rd_s16b(&tmp16s); + p_ptr->mane_spell[i] = (SPELL_IDX)tmp16s; + rd_s16b(&tmp16s); + p_ptr->mane_dam[i] = (SPELL_IDX)tmp16s; } rd_s16b(&p_ptr->mane_num); } @@ -1791,8 +1933,11 @@ static void rd_extra(void) rd_byte(&p_ptr->exit_bldg); rd_byte(&tmp8u); - rd_s16b(&p_ptr->oldpx); - rd_s16b(&p_ptr->oldpy); + rd_s16b(&tmp16s); + p_ptr->oldpx = (POSITION)tmp16s; + rd_s16b(&tmp16s); + p_ptr->oldpy = (POSITION)tmp16s; + if (z_older_than(10, 3, 13) && !dun_level && !p_ptr->inside_arena) {p_ptr->oldpy = 33;p_ptr->oldpx = 131;} /* Was p_ptr->rewards[MAX_BACT] */ @@ -1842,7 +1987,8 @@ static void rd_extra(void) rd_s16b(&p_ptr->max_plv); if (z_older_than(10, 3, 8)) { - rd_s16b(&max_dlv[DUNGEON_ANGBAND]); + rd_s16b(&tmp16s); + max_dlv[DUNGEON_ANGBAND] = tmp16s; } else { @@ -1852,12 +1998,13 @@ static void rd_extra(void) for(i = 0; i < max; i++) { - rd_s16b(&max_dlv[i]); + rd_s16b(&tmp16s); + max_dlv[i] = tmp16s; if (max_dlv[i] > d_info[i].maxdepth) max_dlv[i] = d_info[i].maxdepth; } } - /* Repair maximum player level XXX XXX XXX */ + /* Repair maximum player level */ if (p_ptr->max_plv < p_ptr->lev) p_ptr->max_plv = p_ptr->lev; /* More info */ @@ -1980,7 +2127,8 @@ static void rd_extra(void) else { rd_s16b(&p_ptr->tim_res_time); - rd_byte(&p_ptr->mimic_form); + rd_byte(&tmp8u); + p_ptr->mimic_form = (IDX)tmp8u; rd_s16b(&p_ptr->tim_mimic); rd_s16b(&p_ptr->tim_sh_fire); } @@ -2050,8 +2198,9 @@ static void rd_extra(void) rd_byte(&tmp8u); p_ptr->autopick_autoregister = tmp8u ? TRUE : FALSE; - rd_byte(&tmp8u); /* oops */ - rd_byte(&p_ptr->action); + rd_byte(&tmp8u); + rd_byte(&tmp8u); + p_ptr->action = (ACTION_IDX)tmp8u; if (!z_older_than(10, 4, 3)) { rd_byte(&tmp8u); @@ -2197,13 +2346,13 @@ static void rd_extra(void) } else if (z_older_than(10, 3, 10)) { - s32b tmp32s; rd_s32b(&tmp32s); p_ptr->visit = 1L; } else { - rd_s32b(&p_ptr->visit); + rd_s32b(&tmp32s); + p_ptr->visit = (BIT_FLAGS)tmp32s; } if (!z_older_than(11, 0, 5)) { @@ -2212,11 +2361,10 @@ static void rd_extra(void) } - - -/* - * Read the player inventory - * +/*! + * @brief ãã¬ã¤ã¤ã¼ã®ææåæ å ±ãèªã¿è¾¼ã / Read the player inventory + * @return ãªã + * @details * Note that the inventory changed in Angband 2.7.4. Two extra * pack slots were added and the equipment was rearranged. Note * that these two features combine when parsing old save-files, in @@ -2252,8 +2400,6 @@ static errr rd_inventory(void) /* Get local object */ q_ptr = &forge; - - /* Wipe the object */ object_wipe(q_ptr); /* Read the item */ @@ -2281,7 +2427,6 @@ static errr rd_inventory(void) /* Warning -- backpack is full */ else if (inven_cnt == INVEN_PACK) { - /* Oops */ note(_("æã¡ç©ã®ä¸ã®ã¢ã¤ãã ãå¤ãããï¼", "Too many items in the inventory!")); /* Fail */ @@ -2313,29 +2458,52 @@ static errr rd_inventory(void) } - -/* - * Read the saved messages +/*! + * @brief ã¡ãã»ã¼ã¸ãã°ãèªã¿è¾¼ã / Read the saved messages + * @return ãªã */ static void rd_messages(void) { int i; char buf[128]; + int message_max; - s16b num; - /* Total */ - rd_s16b(&num); + if (h_older_than(2, 2, 0, 75)) + { + u16b num; + /* Total */ + rd_u16b(&num); + message_max = (int)num; + + /* Read the messages */ + for (i = 0; i < message_max; i++) + { + /* Read the message */ + rd_string(buf, sizeof(buf)); - /* Read the messages */ - for (i = 0; i < num; i++) + /* Save the message */ + message_add(buf); + } + } + else { - /* Read the message */ - rd_string(buf, sizeof(buf)); + u32b num; + /* Total */ + rd_u32b(&num); + message_max = (int)num; + + /* Read the messages */ + for (i = 0; i < message_max; i++) + { + /* Read the message */ + rd_string(buf, sizeof(buf)); - /* Save the message */ - message_add(buf); + /* Save the message */ + message_add(buf); + } } + } @@ -2359,9 +2527,10 @@ static void rd_messages(void) #define QUEST_OLD_CASTLE 27 #define QUEST_ROYAL_CRYPT 28 -/* - * Read the dungeon (old method) - * +/*! + * @brief ã¡ãã»ã¼ã¸ãã°ãèªã¿è¾¼ã / Read the dungeon (old method) + * @return ãªã + * @details * The monsters/objects must be loaded in the same order * that they were stored, since the actual indexes matter. */ @@ -2379,28 +2548,37 @@ static errr rd_dungeon_old(void) /*** Basic info ***/ /* Header info */ - rd_s16b(&dun_level); + rd_s16b(&tmp16s); + dun_level = (DEPTH)tmp16s; if (z_older_than(10, 3, 8)) dungeon_type = DUNGEON_ANGBAND; - else rd_byte(&dungeon_type); + else + { + rd_byte(&tmp8u); + dungeon_type = (IDX)tmp8u; + } /* Set the base level for old versions */ base_level = dun_level; - rd_s16b(&base_level); + rd_s16b(&tmp16s); + base_level = (DEPTH)tmp16s; - rd_s16b(&num_repro); rd_s16b(&tmp16s); - py = (int)tmp16s; + num_repro = (MONSTER_NUMBER)tmp16s; + rd_s16b(&tmp16s); + p_ptr->y = (POSITION)tmp16s; + rd_s16b(&tmp16s); + p_ptr->x = (POSITION)tmp16s; + if (z_older_than(10, 3, 13) && !dun_level && !p_ptr->inside_arena) {p_ptr->y = 33;p_ptr->x = 131;} + rd_s16b(&tmp16s); + cur_hgt = (POSITION)tmp16s; rd_s16b(&tmp16s); - px = (int)tmp16s; - if (z_older_than(10, 3, 13) && !dun_level && !p_ptr->inside_arena) {py = 33;px = 131;} - rd_s16b(&cur_hgt); - rd_s16b(&cur_wid); + cur_wid = (POSITION)tmp16s; rd_s16b(&tmp16s); /* max_panel_rows */ rd_s16b(&tmp16s); /* max_panel_cols */ #if 0 - if (!py || !px) {py = 10;px = 10;}/* ãã³ã¸ã§ã³çæã«å¤±æãã¦ã»ã°ã¡ã³ãã£ãã¨ãã®å¾©æ§ç¨ */ + if (!p_ptr->y || !p_ptr->x) {p_ptr->y = 10;p_ptr->x = 10;}/* ãã³ã¸ã§ã³çæã«å¤±æãã¦ã»ã°ã¡ã³ãã£ãã¨ãã®å¾©æ§ç¨ */ #endif /* Maximal size */ @@ -2658,7 +2836,7 @@ static errr rd_dungeon_old(void) /* Read the dungeon items */ for (i = 1; i < limit; i++) { - int o_idx; + OBJECT_IDX o_idx; object_type *o_ptr; @@ -2666,7 +2844,6 @@ static errr rd_dungeon_old(void) /* Get a new record */ o_idx = o_pop(); - /* Oops */ if (i != o_idx) { note(format(_("ã¢ã¤ãã é ç½®ã¨ã©ã¼ (%d <> %d)", "Object allocation error (%d <> %d)"), i, o_idx)); @@ -2681,7 +2858,7 @@ static errr rd_dungeon_old(void) rd_item(o_ptr); - /* XXX XXX XXX XXX XXX */ + /* XXX XXX */ /* Monster */ if (o_ptr->held_m_idx) @@ -2728,13 +2905,12 @@ static errr rd_dungeon_old(void) /* Read the monsters */ for (i = 1; i < limit; i++) { - int m_idx; + MONSTER_IDX m_idx; monster_type *m_ptr; /* Get a new record */ m_idx = m_pop(); - /* Oops */ if (i != m_idx) { note(format(_("ã¢ã³ã¹ã¿ã¼é ç½®ã¨ã©ã¼ (%d <> %d)", "Monster allocation error (%d <> %d)"), i, m_idx)); @@ -2772,17 +2948,24 @@ static errr rd_dungeon_old(void) } - -/* - * Read the saved floor - * +/*! + * @brief ä¿åãããããã¢ãèªã¿è¾¼ã / Read the saved floor + * @return infoèªã¿è¾¼ã¿ã¨ã©ã¼ã³ã¼ã + * @details + * ãã®é¢æ°ã¯ãã»ã¼ããã¼ã¿ã®äºææ§ãä¿ã¤ããã«å¤ãã®ãã¼ã¿æ¹å¤å¦çãåãã¦ããã + * ç¾å¨ç¢ºèªãã¦ããå¦çã¯ä»¥ä¸ã®éãã + *