static void wr_monster(monster_type *m_ptr)
{
u32b flags = 0x00000000;
+ byte tmp8u;
- if (m_ptr->ap_r_idx != m_ptr->r_idx) flags |= SAVE_MON_AP_R_IDX;
+ if (!is_original_ap(m_ptr)) flags |= SAVE_MON_AP_R_IDX;
if (m_ptr->sub_align) flags |= SAVE_MON_SUB_ALIGN;
- if (m_ptr->csleep) flags |= SAVE_MON_CSLEEP;
- if (m_ptr->fast) flags |= SAVE_MON_FAST;
- if (m_ptr->slow) flags |= SAVE_MON_SLOW;
- if (m_ptr->stunned) flags |= SAVE_MON_STUNNED;
- if (m_ptr->confused) flags |= SAVE_MON_CONFUSED;
- if (m_ptr->monfear) flags |= SAVE_MON_MONFEAR;
+ if (MON_CSLEEP(m_ptr)) flags |= SAVE_MON_CSLEEP;
+ if (MON_FAST(m_ptr)) flags |= SAVE_MON_FAST;
+ if (MON_SLOW(m_ptr)) flags |= SAVE_MON_SLOW;
+ if (MON_STUNNED(m_ptr)) flags |= SAVE_MON_STUNNED;
+ if (MON_CONFUSED(m_ptr)) flags |= SAVE_MON_CONFUSED;
+ if (MON_MONFEAR(m_ptr)) flags |= SAVE_MON_MONFEAR;
if (m_ptr->target_y) flags |= SAVE_MON_TARGET_Y;
if (m_ptr->target_x) flags |= SAVE_MON_TARGET_X;
- if (m_ptr->invulner) flags |= SAVE_MON_INVULNER;
+ if (MON_INVULNER(m_ptr)) flags |= SAVE_MON_INVULNER;
if (m_ptr->smart) flags |= SAVE_MON_SMART;
if (m_ptr->exp) flags |= SAVE_MON_EXP;
if (m_ptr->mflag2) flags |= SAVE_MON_MFLAG2;
wr_s16b(m_ptr->hp);
wr_s16b(m_ptr->maxhp);
wr_s16b(m_ptr->max_maxhp);
+ wr_u32b(m_ptr->dealt_damage);
+
/* Monster race index of its appearance */
if (flags & SAVE_MON_AP_R_IDX) wr_s16b(m_ptr->ap_r_idx);
if (flags & SAVE_MON_SUB_ALIGN) wr_byte(m_ptr->sub_align);
- if (flags & SAVE_MON_CSLEEP) wr_s16b(m_ptr->csleep);
+ if (flags & SAVE_MON_CSLEEP) wr_s16b(m_ptr->mtimed[MTIMED_CSLEEP]);
wr_byte(m_ptr->mspeed);
wr_s16b(m_ptr->energy_need);
- if (flags & SAVE_MON_FAST) wr_byte(m_ptr->fast);
- if (flags & SAVE_MON_SLOW) wr_byte(m_ptr->slow);
- if (flags & SAVE_MON_STUNNED) wr_byte(m_ptr->stunned);
- if (flags & SAVE_MON_CONFUSED) wr_byte(m_ptr->confused);
- if (flags & SAVE_MON_MONFEAR) wr_byte(m_ptr->monfear);
+ if (flags & SAVE_MON_FAST)
+ {
+ tmp8u = (byte)m_ptr->mtimed[MTIMED_FAST];
+ wr_byte(tmp8u);
+ }
+ if (flags & SAVE_MON_SLOW)
+ {
+ tmp8u = (byte)m_ptr->mtimed[MTIMED_SLOW];
+ wr_byte(tmp8u);
+ }
+ if (flags & SAVE_MON_STUNNED)
+ {
+ tmp8u = (byte)m_ptr->mtimed[MTIMED_STUNNED];
+ wr_byte(tmp8u);
+ }
+ if (flags & SAVE_MON_CONFUSED)
+ {
+ tmp8u = (byte)m_ptr->mtimed[MTIMED_CONFUSED];
+ wr_byte(tmp8u);
+ }
+ if (flags & SAVE_MON_MONFEAR)
+ {
+ tmp8u = (byte)m_ptr->mtimed[MTIMED_MONFEAR];
+ wr_byte(tmp8u);
+ }
if (flags & SAVE_MON_TARGET_Y) wr_s16b(m_ptr->target_y);
if (flags & SAVE_MON_TARGET_X) wr_s16b(m_ptr->target_x);
- if (flags & SAVE_MON_INVULNER) wr_byte(m_ptr->invulner);
+ if (flags & SAVE_MON_INVULNER)
+ {
+ tmp8u = (byte)m_ptr->mtimed[MTIMED_INVULNER];
+ wr_byte(tmp8u);
+ }
if (flags & SAVE_MON_SMART) wr_u32b(m_ptr->smart);
if (flags & SAVE_MON_EXP) wr_u32b(m_ptr->exp);
if (flags & SAVE_MON_MFLAG2) wr_byte(m_ptr->mflag2);
wr_s16b(r_ptr->r_sights);
wr_s16b(r_ptr->r_deaths);
wr_s16b(r_ptr->r_pkills);
+ wr_s16b(r_ptr->r_akills);
wr_s16b(r_ptr->r_tkills);
/* Count wakes and ignores */
for (i = 0; i < 4; i++) wr_string(previous_char.history[i]);
- wr_byte(previous_char.quests);
+ /* UNUSED : Was number of random quests */
+ wr_byte(0);
/* No quick start after using debug mode or cheat options */
if (p_ptr->noscore) previous_char.quick_ok = FALSE;
wr_string(p_ptr->died_from);
+ wr_string(p_ptr->last_message ? p_ptr->last_message : "");
+
save_quick_start();
for (i = 0; i < 4; i++)
wr_u32b(p_ptr->max_exp);
wr_u32b(p_ptr->max_max_exp);
wr_u32b(p_ptr->exp);
- wr_u16b(p_ptr->exp_frac);
+ wr_u32b(p_ptr->exp_frac);
wr_s16b(p_ptr->lev);
for (i = 0; i < 64; i++) wr_s16b(p_ptr->spell_exp[i]);
wr_s16b(p_ptr->oldpx);
wr_s16b(p_ptr->oldpy);
- /* Save builing rewards */
- wr_s16b(MAX_BACT);
-
- for (i = 0; i < MAX_BACT; i++) wr_s16b(p_ptr->rewards[i]);
+ /* Was number of p_ptr->rewards[] */
+ wr_s16b(0);
- wr_s16b(p_ptr->mhp);
- wr_s16b(p_ptr->chp);
- wr_u16b(p_ptr->chp_frac);
+ wr_s32b(p_ptr->mhp);
+ wr_s32b(p_ptr->chp);
+ wr_u32b(p_ptr->chp_frac);
- wr_s16b(p_ptr->msp);
- wr_s16b(p_ptr->csp);
- wr_u16b(p_ptr->csp_frac);
+ wr_s32b(p_ptr->msp);
+ wr_s32b(p_ptr->csp);
+ wr_u32b(p_ptr->csp_frac);
/* Max Player and Dungeon Levels */
wr_s16b(p_ptr->max_plv);
wr_s16b(0); /* oops */
wr_s16b(0); /* oops */
wr_s16b(p_ptr->sc);
- wr_s16b(0); /* oops */
+ wr_s16b(p_ptr->concent);
wr_s16b(0); /* old "rest" */
wr_s16b(p_ptr->blind);
wr_s16b(0); /* old "food_digested" */
wr_s16b(0); /* old "protection" */
wr_s16b(p_ptr->energy_need);
+ wr_s16b(p_ptr->enchant_energy_need);
wr_s16b(p_ptr->fast);
wr_s16b(p_ptr->slow);
wr_s16b(p_ptr->afraid);
wr_s16b(p_ptr->tim_regen);
wr_s16b(p_ptr->kabenuke);
wr_s16b(p_ptr->tim_stealth);
- wr_s16b(p_ptr->tim_ffall);
+ wr_s16b(p_ptr->tim_levitation);
wr_s16b(p_ptr->tim_sh_touki);
wr_s16b(p_ptr->lightspeed);
wr_s16b(p_ptr->tsubureru);
wr_s16b(p_ptr->ele_immune);
wr_u32b(p_ptr->special_defense);
wr_byte(p_ptr->knowledge);
- wr_byte(0); /* oops */
+ wr_byte(p_ptr->autopick_autoregister);
wr_byte(0); /* oops */
wr_byte(p_ptr->action);
wr_byte(0);
wr_byte(p_ptr->is_dead);
/* Write feeling */
- wr_byte(feeling);
+ wr_byte(p_ptr->feeling);
- /* Turn of last "feeling" */
+ /* Turn when level began */
wr_s32b(old_turn);
+ /* Turn of last "feeling" */
+ wr_s32b(p_ptr->feeling_turn);
+
/* Current turn */
wr_s32b(turn);
*/
static void wr_saved_floor(saved_floor_type *sf_ptr)
{
- cave_template_type *template;
+ cave_template_type *templates;
u16b max_num_temp;
u16b num_temp = 0;
int dummy_why;
wr_u16b((u16b)px);
wr_u16b(cur_hgt);
wr_u16b(cur_wid);
- wr_byte(feeling);
+ wr_byte(p_ptr->feeling);
max_num_temp = 255;
/* Allocate the "template" array */
- C_MAKE(template, max_num_temp, cave_template_type);
+ C_MAKE(templates, max_num_temp, cave_template_type);
/* Extract template array */
for (y = 0; y < cur_hgt; y++)
for (i = 0; i < num_temp; i++)
{
- if (template[i].info == c_ptr->info &&
- template[i].feat == c_ptr->feat &&
- template[i].mimic == c_ptr->mimic &&
- template[i].special == c_ptr->special)
+ if (templates[i].info == c_ptr->info &&
+ templates[i].feat == c_ptr->feat &&
+ templates[i].mimic == c_ptr->mimic &&
+ templates[i].special == c_ptr->special)
{
/* Same terrain is exist */
- template[i].occurrence++;
+ templates[i].occurrence++;
break;
}
}
/* If the max_num_temp is too small, increase it. */
if (num_temp >= max_num_temp)
{
- cave_template_type *old_template = template;
+ cave_template_type *old_template = templates;
/* Re-allocate the "template" array */
- C_MAKE(template, max_num_temp + 255, cave_template_type);
- C_COPY(template, old_template, max_num_temp, cave_template_type);
- C_FREE(old_template, max_num_temp, cave_template_type);
+ C_MAKE(templates, max_num_temp + 255, cave_template_type);
+ (void)C_COPY(templates, old_template, max_num_temp, cave_template_type);
+ C_KILL(old_template, max_num_temp, cave_template_type);
max_num_temp += 255;
}
/* Add new template */
- template[num_temp].info = c_ptr->info;
- template[num_temp].feat = c_ptr->feat;
- template[num_temp].mimic = c_ptr->mimic;
- template[num_temp].special = c_ptr->special;
- template[num_temp].occurrence = 1;
+ templates[num_temp].info = c_ptr->info;
+ templates[num_temp].feat = c_ptr->feat;
+ templates[num_temp].mimic = c_ptr->mimic;
+ templates[num_temp].special = c_ptr->special;
+ templates[num_temp].occurrence = 1;
/* Increase number of template */
num_temp++;
ang_sort_swap = ang_sort_swap_cave_temp;
/* Sort by occurrence */
- ang_sort(template, &dummy_why, num_temp);
+ ang_sort(templates, &dummy_why, num_temp);
/*** Dump templates ***/
/* Dump the templates */
for (i = 0; i < num_temp; i++)
{
- cave_template_type *ct_ptr = &template[i];
+ cave_template_type *ct_ptr = &templates[i];
/* Dump it */
wr_u16b(ct_ptr->info);
- wr_byte(ct_ptr->feat);
- wr_byte(ct_ptr->mimic);
+ wr_s16b(ct_ptr->feat);
+ wr_s16b(ct_ptr->mimic);
wr_s16b(ct_ptr->special);
}
for (i = 0; i < num_temp; i++)
{
- if (template[i].info == c_ptr->info &&
- template[i].feat == c_ptr->feat &&
- template[i].mimic == c_ptr->mimic &&
- template[i].special == c_ptr->special)
+ if (templates[i].info == c_ptr->info &&
+ templates[i].feat == c_ptr->feat &&
+ templates[i].mimic == c_ptr->mimic &&
+ templates[i].special == c_ptr->special)
break;
}
/* Free the "template" array */
- C_FREE(template, max_num_temp, cave_template_type);
+ C_KILL(templates, max_num_temp, cave_template_type);
/*** Dump objects ***/
/*** Meta info ***/
- /* Number of floor_id used from birth */
+ /* Number of floor_id used from birth */
wr_s16b(max_floor_id);
/* Current dungeon type */
/* Space */
wr_u32b(0L);
- wr_u32b(0L);
+ wr_u16b(0);
+ wr_byte(0);
+#ifdef JP
+# ifdef EUC
+ /* EUC kanji code */
+ wr_byte(2);
+# endif
+# ifdef SJIS
+ /* SJIS kanji code */
+ wr_byte(3);
+# endif
+#else
+ /* ASCII */
+ wr_byte(1);
+#endif
/* Write the RNG state */
wr_randomizer();
for (i = 0; i < max_quests; i++)
{
+ quest_type* const q_ptr = &quest[i];
+
/* Save status for every quest */
- wr_s16b(quest[i].status);
+ wr_s16b(q_ptr->status);
/* And the dungeon level too */
/* (prevents problems with multi-level quests) */
- wr_s16b(quest[i].level);
+ wr_s16b(q_ptr->level);
- wr_byte(quest[i].complev);
+ wr_byte(q_ptr->complev);
+ wr_u32b(q_ptr->comptime);
/* Save quest status if quest is running */
- if (quest[i].status == QUEST_STATUS_TAKEN || quest[i].status == QUEST_STATUS_COMPLETED || !is_fixed_quest_idx(i))
+ if (q_ptr->status == QUEST_STATUS_TAKEN || q_ptr->status == QUEST_STATUS_COMPLETED || !is_fixed_quest_idx(i))
{
- wr_s16b(quest[i].cur_num);
- wr_s16b(quest[i].max_num);
- wr_s16b(quest[i].type);
- wr_s16b(quest[i].r_idx);
- wr_s16b(quest[i].k_idx);
- wr_byte(quest[i].flags);
- wr_byte(quest[i].dungeon);
+ wr_s16b(q_ptr->cur_num);
+ wr_s16b(q_ptr->max_num);
+ wr_s16b(q_ptr->type);
+ wr_s16b(q_ptr->r_idx);
+ wr_s16b(q_ptr->k_idx);
+ wr_byte(q_ptr->flags);
+ wr_byte(q_ptr->dungeon);
}
}
/* Count lives */
sf_lives++;
- /* Forget turns */
- turn = old_turn = 0;
-
/* Done */
return (TRUE);
}
/* New savefile */
sprintf(floor_savefile, "%s.F%02d", savefile, (int)sf_ptr->savefile_id);
+ /* Grab permissions */
+ safe_setuid_grab();
+
/* Remove it */
fd_kill(floor_savefile);
+ /* Drop permissions */
+ safe_setuid_drop();
+
+
/* Attempt to save the player */
/* No file yet */
/* File type is "SAVE" */
FILE_TYPE(FILE_TYPE_SAVE);
+ /* Grab permissions */
+ safe_setuid_grab();
+
/* Create the savefile */
fd = fd_make(floor_savefile, 0644);
+ /* Drop permissions */
+ safe_setuid_drop();
+
/* File is okay */
if (fd >= 0)
{
/* Close the "fd" */
(void)fd_close(fd);
+ /* Grab permissions */
+ safe_setuid_grab();
+
/* Open the savefile */
fff = my_fopen(floor_savefile, "wb");
+ /* Drop permissions */
+ safe_setuid_drop();
+
/* Successful open */
if (fff)
{
}
/* Remove "broken" files */
- if (!ok) (void)fd_kill(floor_savefile);
+ if (!ok)
+ {
+ /* Grab permissions */
+ safe_setuid_grab();
+
+ (void)fd_kill(floor_savefile);
+
+ /* Drop permissions */
+ safe_setuid_drop();
+ }
}
if (!(mode & SLF_SECOND))