*/
static u32b x_check = 0L;
-
+/*
+ * Hack -- Japanese Kanji code
+ * 0: Unknown
+ * 1: ASCII
+ * 2: EUC
+ * 3: SJIS
+ */
+static byte kanji_code = 0;
/*
* This function determines if the version of the savefile
/* Terminate */
str[max-1] = '\0';
+
+
#ifdef JP
- codeconv(str);
+ /* Convert Kanji code */
+ switch (kanji_code)
+ {
+#ifdef SJIS
+ case 2:
+ /* EUC to SJIS */
+ euc2sjis(str);
+ break;
+#endif
+
+#ifdef EUC
+ case 3:
+ /* SJIS to EUC */
+ sjis2euc(str);
+ break;
+#endif
+
+ case 0:
+ {
+ /* ÉÔÌÀ¤Î´Á»ú¥³¡¼¥É¤«¤é¥·¥¹¥Æ¥à¤Î´Á»ú¥³¡¼¥É¤ËÊÑ´¹ */
+ byte code = codeconv(str);
+
+ /* ´Á»ú¥³¡¼¥É¤¬È½ÌÀ¤·¤¿¤é¡¢¤½¤ì¤òµÏ¿ */
+ if (code) kanji_code = code;
+
+ break;
+ }
+ default:
+ /* No conversion needed */
+ break;
+ }
#endif
}
else m_ptr->nickname = 0;
}
else m_ptr->nickname = 0;
+
+ if (flags & SAVE_MON_PARENT) rd_s16b(&m_ptr->parent_m_idx);
+ else m_ptr->parent_m_idx = 0;
}
+/*
+ * Old monster bit flags of racial resistances
+ */
+#define RF3_IM_ACID 0x00010000 /* Resist acid a lot */
+#define RF3_IM_ELEC 0x00020000 /* Resist elec a lot */
+#define RF3_IM_FIRE 0x00040000 /* Resist fire a lot */
+#define RF3_IM_COLD 0x00080000 /* Resist cold a lot */
+#define RF3_IM_POIS 0x00100000 /* Resist poison a lot */
+#define RF3_RES_TELE 0x00200000 /* Resist teleportation */
+#define RF3_RES_NETH 0x00400000 /* Resist nether a lot */
+#define RF3_RES_WATE 0x00800000 /* Resist water */
+#define RF3_RES_PLAS 0x01000000 /* Resist plasma */
+#define RF3_RES_NEXU 0x02000000 /* Resist nexus */
+#define RF3_RES_DISE 0x04000000 /* Resist disenchantment */
+#define RF3_RES_ALL 0x08000000 /* Resist all */
+
+#define MOVE_RF3_TO_RFR(R_PTR,RF3,RFR) \
+{\
+ if ((R_PTR)->r_flags3 & (RF3)) \
+ { \
+ (R_PTR)->r_flags3 &= ~(RF3); \
+ (R_PTR)->r_flagsr |= (RFR); \
+ } \
+}
+
+#define RF4_BR_TO_RFR(R_PTR,RF4_BR,RFR) \
+{\
+ if ((R_PTR)->r_flags4 & (RF4_BR)) \
+ { \
+ (R_PTR)->r_flagsr |= (RFR); \
+ } \
+}
+#define RF4_BR_LITE 0x00004000 /* Breathe Lite */
+#define RF4_BR_DARK 0x00008000 /* Breathe Dark */
+#define RF4_BR_CONF 0x00010000 /* Breathe Confusion */
+#define RF4_BR_SOUN 0x00020000 /* Breathe Sound */
+#define RF4_BR_CHAO 0x00040000 /* Breathe Chaos */
+#define RF4_BR_TIME 0x00200000 /* Breathe Time */
+#define RF4_BR_INER 0x00400000 /* Breathe Inertia */
+#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
*/
rd_u32b(&r_ptr->r_flags4);
rd_u32b(&r_ptr->r_flags5);
rd_u32b(&r_ptr->r_flags6);
+ if (h_older_than(1, 5, 0, 3))
+ {
+ r_ptr->r_flagsr = 0L;
+
+ /* Move RF3 resistance flags to RFR */
+ MOVE_RF3_TO_RFR(r_ptr, RF3_IM_ACID, RFR_IM_ACID);
+ MOVE_RF3_TO_RFR(r_ptr, RF3_IM_ELEC, RFR_IM_ELEC);
+ MOVE_RF3_TO_RFR(r_ptr, RF3_IM_FIRE, RFR_IM_FIRE);
+ MOVE_RF3_TO_RFR(r_ptr, RF3_IM_COLD, RFR_IM_COLD);
+ MOVE_RF3_TO_RFR(r_ptr, RF3_IM_POIS, RFR_IM_POIS);
+ MOVE_RF3_TO_RFR(r_ptr, RF3_RES_TELE, RFR_RES_TELE);
+ MOVE_RF3_TO_RFR(r_ptr, RF3_RES_NETH, RFR_RES_NETH);
+ MOVE_RF3_TO_RFR(r_ptr, RF3_RES_WATE, RFR_RES_WATE);
+ MOVE_RF3_TO_RFR(r_ptr, RF3_RES_PLAS, RFR_RES_PLAS);
+ MOVE_RF3_TO_RFR(r_ptr, RF3_RES_NEXU, RFR_RES_NEXU);
+ MOVE_RF3_TO_RFR(r_ptr, RF3_RES_DISE, RFR_RES_DISE);
+ MOVE_RF3_TO_RFR(r_ptr, RF3_RES_ALL, RFR_RES_ALL);
+
+ /* Separate breathers resistance from RF4 to RFR */
+ RF4_BR_TO_RFR(r_ptr, RF4_BR_LITE, RFR_RES_LITE);
+ RF4_BR_TO_RFR(r_ptr, RF4_BR_DARK, RFR_RES_DARK);
+ RF4_BR_TO_RFR(r_ptr, RF4_BR_SOUN, RFR_RES_SOUN);
+ RF4_BR_TO_RFR(r_ptr, RF4_BR_CHAO, RFR_RES_CHAO);
+ RF4_BR_TO_RFR(r_ptr, RF4_BR_TIME, RFR_RES_TIME);
+ RF4_BR_TO_RFR(r_ptr, RF4_BR_INER, RFR_RES_INER);
+ RF4_BR_TO_RFR(r_ptr, RF4_BR_GRAV, RFR_RES_GRAV);
+ RF4_BR_TO_RFR(r_ptr, RF4_BR_SHAR, RFR_RES_SHAR);
+ RF4_BR_TO_RFR(r_ptr, RF4_BR_WALL, RFR_RES_WALL);
+
+ /* Resist confusion is merged to RF3_NO_CONF */
+ if (r_ptr->r_flags4 & RF4_BR_CONF) r_ptr->r_flags3 |= RF3_NO_CONF;
+
+ /* Misc resistance hack to RFR */
+ if (r_idx == MON_STORMBRINGER) r_ptr->r_flagsr |= RFR_RES_CHAO;
+ if (r_ptr->r_flags3 & RF3_ORC) r_ptr->r_flagsr |= RFR_RES_DARK;
+ }
+ else
+ {
+ rd_u32b(&r_ptr->r_flagsr);
+ }
/* Read the "Racial" monster limit per level */
rd_byte(&r_ptr->max_num);
r_ptr->r_flags4 &= r_ptr->flags4;
r_ptr->r_flags5 &= r_ptr->flags5;
r_ptr->r_flags6 &= r_ptr->flags6;
+ r_ptr->r_flagsr &= r_ptr->flagsr;
}
rd_byte(&b);
hitpoint_warn = b;
+ /* Read "mana_warn" */
+ if(h_older_than(1, 7, 0, 0))
+ {
+ mana_warn=2;
+ }
+ else
+ {
+ rd_byte(&b);
+ mana_warn = b;
+ }
+
/*** Cheating options ***/
rd_s32b(&p_ptr->au);
rd_s32b(&p_ptr->max_exp);
+ if (h_older_than(1, 5, 4, 1)) p_ptr->max_max_exp = p_ptr->max_exp;
+ else rd_s32b(&p_ptr->max_max_exp);
rd_s32b(&p_ptr->exp);
rd_u16b(&p_ptr->exp_frac);
if (z_older_than(10, 0, 3))
{
- get_mon_num_prep(NULL, NULL);
- for (i = 0; i < MAX_KUBI; i++)
- {
- monster_race *r_ptr;
- while (1)
- {
- int j;
+ determine_bounty_uniques();
- kubi_r_idx[i] = get_mon_num(MAX_DEPTH - 1);
- r_ptr = &r_info[kubi_r_idx[i]];
-
- if(!(r_ptr->flags1 & RF1_UNIQUE)) continue;
-
- if(!(r_ptr->flags9 & RF9_DROP_CORPSE)) continue;
-
- if(r_ptr->flags6 & RF6_SPECIAL) continue;
-
- for (j = 0; j < i; j++)
- if (kubi_r_idx[i] == kubi_r_idx[j])break;
-
- if (j == i) break;
- }
- }
- for (i = 0; i < MAX_KUBI -1; i++)
- {
- int j,tmp;
- for (j = i; j < MAX_KUBI; j++)
- {
- if (r_info[kubi_r_idx[i]].level > r_info[kubi_r_idx[j]].level)
- {
- tmp = kubi_r_idx[i];
- kubi_r_idx[i] = kubi_r_idx[j];
- kubi_r_idx[j] = tmp;
- }
- }
- }
for (i = 0; i < MAX_KUBI; i++)
{
- if(!r_info[kubi_r_idx[i]].max_num)
- kubi_r_idx[i] += 10000;
+ /* Is this bounty unique already dead? */
+ if (!r_info[kubi_r_idx[i]].max_num) kubi_r_idx[i] += 10000;
}
}
else
p_ptr->inside_battle = (bool)tmp16s;
}
rd_byte(&p_ptr->exit_bldg);
- rd_byte(&p_ptr->leftbldg);
+ rd_byte(&tmp8u);
rd_s16b(&p_ptr->oldpx);
rd_s16b(&p_ptr->oldpy);
rd_u32b(&p_ptr->special_defense);
}
rd_byte(&p_ptr->knowledge);
- rd_byte(&tmp8u); /* oops */
+
+ rd_byte(&tmp8u);
+ p_ptr->autopick_autoregister = tmp8u ? TRUE : FALSE;
+
rd_byte(&tmp8u); /* oops */
rd_byte(&p_ptr->action);
if (!z_older_than(10, 4, 3))
if (z_older_than(10,0,3))
{
- monster_race *r_ptr;
-
- while (1)
- {
- today_mon = get_mon_num(MAX(max_dlv[DUNGEON_ANGBAND], 3));
- r_ptr = &r_info[today_mon];
-
- if (r_ptr->flags1 & RF1_UNIQUE) continue;
- if (r_ptr->flags2 & (RF2_MULTIPLY)) continue;
- if (!(r_ptr->flags9 & RF9_DROP_CORPSE) || !(r_ptr->flags9 & RF9_DROP_SKELETON)) continue;
- if (r_ptr->level < MIN(max_dlv[DUNGEON_ANGBAND], 40)) continue;
- if (r_ptr->rarity > 10) continue;
- if (r_ptr->level == 0) continue;
- break;
- }
-
- p_ptr->today_mon = 0;
+ determine_today_mon(TRUE);
}
else
{
if (h_older_than(1, 5, 0, 2))
{
- C_WIPE(&party_mon[i], MAX_PARTY_MON, monster_type);
+ /* Nothing to do */
}
else
{
- s16b max_num;
- monster_type dummy_mon;
-
+ /* Get number of party_mon array */
rd_s16b(&tmp16s);
- if (tmp16s > MAX_PARTY_MON)
- {
-#ifdef JP
- note("°ì»þÊݸ¥Ú¥Ã¥È¤¬Â¿¤¹¤®¤ë¤Î¤Ç°ìÉôºï½ü¤·¤Þ¤¹¡£");
-#else
- note("Temporary pets are too many, so some are removed.");
-#endif
- max_num = MAX_PARTY_MON;
- }
- else max_num = tmp16s;
- /* Load temporary preserved pets */
- for (i = 0; i < max_num; i++)
+ /* Strip old temporary preserved pets */
+ for (i = 0; i < tmp16s; i++)
{
- rd_monster(&party_mon[i]);
+ monster_type dummy_mon;
- /* Count */
- real_r_ptr(&party_mon[i])->cur_num++;
- }
-
- /* Remove excess pets */
- for (i = max_num; i < tmp16s; i++)
- {
rd_monster(&dummy_mon);
-
- if (record_named_pet && dummy_mon.nickname)
- {
- char m_name[80];
- monster_desc(m_name, &dummy_mon, 0x08);
- do_cmd_write_nikki(NIKKI_NAMED_PET, 5, m_name);
- }
}
}
rd_u16b(&info);
/* Decline invalid flags */
- info &= ~(CAVE_LITE | CAVE_VIEW | CAVE_MNLT);
+ info &= ~(CAVE_LITE | CAVE_VIEW | CAVE_MNLT | CAVE_MNDK);
}
/* Apply the RLE info */
int i;
/* Initialize saved_floors array and temporal files */
- init_saved_floors();
+ init_saved_floors(FALSE);
/* Older method */
if (h_older_than(1, 5, 0, 0))
rd_byte(&dungeon_type);
- /*** On the surface ***/
- if (!p_ptr->floor_id)
- {
- /* Number of array elements?? */
- rd_byte(&num);
-
- /* It should be 0 */
- if (num) err = 181;
+ /* Number of the saved_floors array elements */
+ rd_byte(&num);
+ /*** No saved floor (On the surface etc.) ***/
+ if (!num)
+ {
/* Read the current floor data */
err = rd_saved_floor(NULL);
}
/*** In the dungeon ***/
else
{
- /* Number of array elements */
- rd_byte(&num);
/* Read the saved_floors array */
for (i = 0; i < num; i++)
#endif
break;
- case 181:
-#ifdef JP
- note("Error 181");
-#else
- note("Error 181");
-#endif
- break;
-
case 182:
#ifdef JP
note("¥Æ¥ó¥Ý¥é¥ê¡¦¥Õ¥¡¥¤¥ë¤òºîÀ®¤Ç¤¤Þ¤»¤ó¡ª");
rd_u32b(&tmp32u);
/* Later use (always zero) */
- rd_u32b(&tmp32u);
+ rd_u16b(&tmp16u);
+ /* Later use (always zero) */
+ rd_byte(&tmp8u);
+
+ /* Kanji code */
+ rd_byte(&kanji_code);
/* Read RNG state */
rd_randomizer();
/* Hack -- Reset the death counter */
r_ptr->max_num = 100;
+
if (r_ptr->flags1 & RF1_UNIQUE) r_ptr->max_num = 1;
- if (r_ptr->flags7 & RF7_UNIQUE_7) r_ptr->max_num = 7;
+
+ /* Hack -- Non-unique Nazguls are semi-unique */
+ else if (r_ptr->flags7 & RF7_NAZGUL) r_ptr->max_num = MAX_NAZGUL_NUM;
}
/* Monster Memory */
#endif
-#if 0
- /*
- * Initialize arena and rewards information
- */
- p_ptr->arena_number = 0;
- p_ptr->inside_arena = 0;
- p_ptr->inside_quest = 0;
- p_ptr->leftbldg = FALSE;
- p_ptr->exit_bldg = TRUE;
-
- /* Start in town 1 */
- p_ptr->town_num = 1;
-
- p_ptr->wilderness_x = 4;
- p_ptr->wilderness_y = 4;
-
-#endif
-
/* Init the wilderness seeds */
for (i = 0; i < max_wild_x; i++)
{
if ((quest[i].type == QUEST_TYPE_RANDOM) && (!quest[i].r_idx))
{
- int r_idx;
- while (1)
- {
- monster_race *r_ptr;
-
- /*
- * Random monster 5 - 10 levels out of depth
- * (depending on level)
- */
- r_idx = get_mon_num(quest[i].level + 5 + randint1(quest[i].level / 10));
- r_ptr = &r_info[r_idx];
-
- if(!(r_ptr->flags1 & RF1_UNIQUE)) continue;
-
- if(r_ptr->flags6 & RF6_SPECIAL) continue;
-
- if(r_ptr->flags7 & RF7_FRIENDLY) continue;
-
- if(r_ptr->flags7 & RF7_AQUATIC) continue;
-
- if(r_ptr->flags8 & RF8_WILD_ONLY) continue;
-
- /*
- * Accept monsters that are 2 - 6 levels
- * out of depth depending on the quest level
- */
- if (r_ptr->level > (quest[i].level + (quest[i].level / 20))) break;
- }
-
- quest[i].r_idx = r_idx;
+ determine_random_questor(&quest[i]);
}
/* Load quest item index */
byte old_h_ver_minor = 0;
byte old_h_ver_patch = 0;
byte old_h_ver_extra = 0;
-
+
bool ok = TRUE;
char floor_savefile[1024];
+ byte old_kanji_code = kanji_code;
+
+ /*
+ * Temporal files are always written in system depended kanji
+ * code.
+ */
+#ifdef JP
+# ifdef EUC
+ /* EUC kanji code */
+ kanji_code = 2;
+# endif
+# ifdef SJIS
+ /* SJIS kanji code */
+ kanji_code = 3;
+# endif
+#else
+ /* ASCII */
+ kanji_code = 1;
+#endif
+
+
/* We have one file already opened */
if (mode & SLF_SECOND)
{
h_ver_extra = old_h_ver_extra;
}
+ /* Restore old knowledge */
+ kanji_code = old_kanji_code;
+
/* Result */
return ok;
}