void wr_misc(void) { int i; /* Write the "object seeds" */ wr_u32b(seed_flavor); wr_byte(NUM_TOWNS); for (i = 0; i < NUM_TOWNS; i++) wr_u32b(seed_town[i]); /* Special stuff */ wr_u16b(p_ptr->quests); wr_u32b(p_ptr->score); wr_u16b(p_ptr->total_winner); wr_u16b(p_ptr->noscore); /* Write death */ wr_byte(p_ptr->is_dead); /* Write feeling */ wr_byte((byte) feeling); /* Turn of last "feeling" */ wr_byte(do_feeling); /* Current turn */ wr_s32b(turn); }
/*! * @brief 店舗情報を書き込む / Write a "store" record * @param st_ptr 店舗情報の参照ポインタ * @return なし */ static void wr_store(store_type *st_ptr) { int j; /* Save the "open" counter */ wr_u32b(st_ptr->store_open); /* Save the "insults" */ wr_s16b(st_ptr->insult_cur); /* Save the current owner */ wr_byte(st_ptr->owner); /* Save the stock size */ wr_s16b(st_ptr->stock_num); /* Save the "haggle" info */ wr_s16b(st_ptr->good_buy); wr_s16b(st_ptr->bad_buy); wr_s32b(st_ptr->last_visit); /* Save the stock */ for (j = 0; j < st_ptr->stock_num; j++) { /* Save each item in stock */ wr_item(&st_ptr->stock[j]); } }
/* * Dump the random artifacts */ void wr_randarts(void) { size_t i, j, k; if (!OPT(birth_randarts)) return; wr_u16b(z_info->a_max); for (i = 0; i < z_info->a_max; i++) { artifact_type *a_ptr = &a_info[i]; wr_byte(a_ptr->tval); wr_byte(a_ptr->sval); for (j = 0; j < MAX_PVALS; j++) wr_s16b(a_ptr->pval[j]); wr_byte(a_ptr->num_pvals); wr_s16b(a_ptr->to_h); wr_s16b(a_ptr->to_d); wr_s16b(a_ptr->to_a); wr_s16b(a_ptr->ac); wr_byte(a_ptr->dd); wr_byte(a_ptr->ds); wr_s16b(a_ptr->weight); wr_s32b(a_ptr->cost); for (j = 0; j < OF_BYTES && j < OF_SIZE; j++) wr_byte(a_ptr->flags[j]); if (j < OF_BYTES) pad_bytes(OF_BYTES - j); for (k = 0; k < MAX_PVALS; k++) { for (j = 0; j < OF_BYTES && j < OF_SIZE; j++) wr_byte(a_ptr->pval_flags[k][j]); if (j < OF_BYTES) pad_bytes(OF_BYTES - j); } wr_byte(a_ptr->level); wr_byte(a_ptr->rarity); wr_byte(a_ptr->alloc_prob); wr_byte(a_ptr->alloc_min); wr_byte(a_ptr->alloc_max); wr_u16b(a_ptr->effect); wr_u16b(a_ptr->time.base); wr_u16b(a_ptr->time.dice); wr_u16b(a_ptr->time.sides); } }
void wr_misc(void) { /* XXX Old random artifact version, remove after 3.3 */ wr_u32b(63); /* Random artifact seed */ wr_u32b(seed_randart); /* XXX Ignore some flags */ wr_u32b(0L); wr_u32b(0L); wr_u32b(0L); /* Write the "object seeds" */ wr_u32b(seed_flavor); wr_u32b(seed_town); /* Special stuff */ wr_u16b(p_ptr->panic_save); wr_u16b(p_ptr->total_winner); wr_u16b(p_ptr->noscore); /* Write death */ wr_byte(p_ptr->is_dead); /* Write feeling */ wr_byte(cave->feeling); wr_u16b(cave->feeling_squares); wr_s32b(cave->created_at); /* Current turn */ wr_s32b(turn); }
void wr_history(void) { size_t i; u32b tmp32u = history_get_num(); wr_u32b(tmp32u); for (i = 0; i < tmp32u; i++) { wr_u16b(history_list[i].type); wr_s32b(history_list[i].turn); wr_s16b(history_list[i].dlev); wr_s16b(history_list[i].clev); wr_byte(history_list[i].a_idx); wr_string(history_list[i].event); } }
/* * Dump the random artefacts */ static void wr_randarts(void) { int i, begin; if (adult_rand_artefacts) begin = 0; else begin = z_info->art_norm_max; wr_u16b(begin); wr_u16b(z_info->art_max); wr_u16b(z_info->art_norm_max); for (i = begin; i < z_info->art_max; i++) { artefact_type *a_ptr = &a_info[i]; wr_string(a_ptr->name); wr_byte(a_ptr->tval); wr_byte(a_ptr->sval); wr_s16b(a_ptr->pval); wr_s16b(a_ptr->att); wr_byte(a_ptr->dd); wr_byte(a_ptr->ds); wr_s16b(a_ptr->evn); wr_byte(a_ptr->pd); wr_byte(a_ptr->ps); wr_s16b(a_ptr->weight); wr_s32b(a_ptr->cost); wr_u32b(a_ptr->flags1); wr_u32b(a_ptr->flags2); wr_u32b(a_ptr->flags3); wr_byte(a_ptr->level); wr_byte(a_ptr->rarity); wr_byte(a_ptr->activation); wr_u16b(a_ptr->time); wr_u16b(a_ptr->randtime); } }
/*! * @brief クイック・スタート情報を書き込む / Save quick start data * @return なし */ static void save_quick_start(void) { int i; wr_byte(previous_char.psex); wr_byte(previous_char.prace); wr_byte(previous_char.pclass); wr_byte(previous_char.pseikaku); wr_byte(previous_char.realm1); wr_byte(previous_char.realm2); wr_s16b(previous_char.age); wr_s16b(previous_char.ht); wr_s16b(previous_char.wt); wr_s16b(previous_char.sc); wr_s32b(previous_char.au); for (i = 0; i < 6; i++) wr_s16b(previous_char.stat_max[i]); for (i = 0; i < 6; i++) wr_s16b(previous_char.stat_max_max[i]); for (i = 0; i < PY_MAX_LEVEL; i++) wr_s16b(previous_char.player_hp[i]); wr_s16b(previous_char.chaos_patron); for (i = 0; i < 8; i++) wr_s16b(previous_char.vir_types[i]); for (i = 0; i < 4; i++) wr_string(previous_char.history[i]); /* 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_byte((byte)previous_char.quick_ok); }
/*! * @brief 保存フロアの書き込み / Actually write a saved floor data using effectively compressed format. * @param sf_ptr 保存したいフロアの参照ポインタ * @return なし */ static void wr_saved_floor(saved_floor_type *sf_ptr) { cave_template_type *templates; u16b max_num_temp; u16b num_temp = 0; int dummy_why; int i, y, x; u16b tmp16u; byte count; u16b prev_u16b; /*** Basic info ***/ /* Dungeon floor specific info follows */ if (!sf_ptr) { /*** Not a saved floor ***/ wr_s16b(dun_level); } else { /*** The saved floor ***/ wr_s16b(sf_ptr->floor_id); wr_byte(sf_ptr->savefile_id); wr_s16b(sf_ptr->dun_level); wr_s32b(sf_ptr->last_visit); wr_u32b(sf_ptr->visit_mark); wr_s16b(sf_ptr->upper_floor_id); wr_s16b(sf_ptr->lower_floor_id); } wr_u16b(base_level); wr_u16b(num_repro); wr_u16b((u16b)py); wr_u16b((u16b)px); wr_u16b(cur_hgt); wr_u16b(cur_wid); wr_byte(p_ptr->feeling); /*********** Make template for cave_type **********/ /* * Usually number of templates are fewer than 255. Even if * more than 254 are exist, the occurrence of each template * with larger ID is very small when we sort templates by * occurrence. So we will use two (or more) bytes for * templete ID larger than 254. * * Ex: 256 will be "0xff" "0x01". * 515 will be "0xff" "0xff" "0x03" */ /* Fake max number */ max_num_temp = 255; /* Allocate the "template" array */ C_MAKE(templates, max_num_temp, cave_template_type); /* Extract template array */ for (y = 0; y < cur_hgt; y++) { for (x = 0; x < cur_wid; x++) { cave_type *c_ptr = &cave[y][x]; for (i = 0; i < num_temp; i++) { 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 */ templates[i].occurrence++; break; } } /* Are there same one? */ if (i < num_temp) continue; /* If the max_num_temp is too small, increase it. */ if (num_temp >= max_num_temp) { cave_template_type *old_template = templates; /* Re-allocate the "template" array */ 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 */ 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++; } } /* Select the sort method */ ang_sort_comp = ang_sort_comp_cave_temp; ang_sort_swap = ang_sort_swap_cave_temp; /* Sort by occurrence */ ang_sort(templates, &dummy_why, num_temp); /*** Dump templates ***/ /* Total templates */ wr_u16b(num_temp); /* Dump the templates */ for (i = 0; i < num_temp; i++) { cave_template_type *ct_ptr = &templates[i]; /* Dump it */ wr_u16b(ct_ptr->info); wr_s16b(ct_ptr->feat); wr_s16b(ct_ptr->mimic); wr_s16b(ct_ptr->special); } /*** "Run-Length-Encoding" of cave ***/ /* Note that this will induce two wasted bytes */ count = 0; prev_u16b = 0; /* Dump the cave */ for (y = 0; y < cur_hgt; y++) { for (x = 0; x < cur_wid; x++) { cave_type *c_ptr = &cave[y][x]; for (i = 0; i < num_temp; i++) { 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; } /* Extract an ID */ tmp16u = i; /* If the run is broken, or too full, flush it */ if ((tmp16u != prev_u16b) || (count == MAX_UCHAR)) { wr_byte((byte)count); while (prev_u16b >= MAX_UCHAR) { /* Mark as actual data is larger than 254 */ wr_byte(MAX_UCHAR); prev_u16b -= MAX_UCHAR; } wr_byte((byte)prev_u16b); prev_u16b = tmp16u; count = 1; } /* Continue the run */ else { count++; } } } /* Flush the data (if any) */ if (count) { wr_byte((byte)count); while (prev_u16b >= MAX_UCHAR) { /* Mark as actual data is larger than 254 */ wr_byte(MAX_UCHAR); prev_u16b -= MAX_UCHAR; } wr_byte((byte)prev_u16b); } /* Free the "template" array */ C_KILL(templates, max_num_temp, cave_template_type); /*** Dump objects ***/ /* Total objects */ wr_u16b(o_max); /* Dump the objects */ for (i = 1; i < o_max; i++) { object_type *o_ptr = &o_list[i]; /* Dump it */ wr_item(o_ptr); } /*** Dump the monsters ***/ /* Total monsters */ wr_u16b(m_max); /* Dump the monsters */ for (i = 1; i < m_max; i++) { monster_type *m_ptr = &m_list[i]; /* Dump it */ wr_monster(m_ptr); } }
/*! * @brief その他の情報を書き込む / Write some "extra" info * @return なし */ static void wr_extra(void) { int i,j; byte tmp8u; wr_string(player_name); 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_string(p_ptr->history[i]); } /* Race/Class/Gender/Spells */ wr_byte(p_ptr->prace); wr_byte(p_ptr->pclass); wr_byte(p_ptr->pseikaku); wr_byte(p_ptr->psex); wr_byte(p_ptr->realm1); wr_byte(p_ptr->realm2); wr_byte(0); /* oops */ wr_byte(p_ptr->hitdie); wr_u16b(p_ptr->expfact); wr_s16b(p_ptr->age); wr_s16b(p_ptr->ht); wr_s16b(p_ptr->wt); /* Dump the stats (maximum and current) */ for (i = 0; i < 6; ++i) wr_s16b(p_ptr->stat_max[i]); for (i = 0; i < 6; ++i) wr_s16b(p_ptr->stat_max_max[i]); for (i = 0; i < 6; ++i) wr_s16b(p_ptr->stat_cur[i]); /* Ignore the transient stats */ for (i = 0; i < 12; ++i) wr_s16b(0); wr_u32b(p_ptr->au); wr_u32b(p_ptr->max_exp); wr_u32b(p_ptr->max_max_exp); wr_u32b(p_ptr->exp); wr_u32b(p_ptr->exp_frac); wr_s16b(p_ptr->lev); for (i = 0; i < 64; i++) wr_s16b(p_ptr->spell_exp[i]); for (i = 0; i < 5; i++) for (j = 0; j < 64; j++) wr_s16b(p_ptr->weapon_exp[i][j]); for (i = 0; i < 10; i++) wr_s16b(p_ptr->skill_exp[i]); for (i = 0; i < 108; i++) wr_s32b(p_ptr->magic_num1[i]); for (i = 0; i < 108; i++) wr_byte(p_ptr->magic_num2[i]); wr_byte(p_ptr->start_race); wr_s32b(p_ptr->old_race1); wr_s32b(p_ptr->old_race2); wr_s16b(p_ptr->old_realm); for (i = 0; i < MAX_MANE; i++) { wr_s16b(p_ptr->mane_spell[i]); wr_s16b(p_ptr->mane_dam[i]); } wr_s16b(p_ptr->mane_num); for (i = 0; i < MAX_KUBI; i++) { wr_s16b(kubi_r_idx[i]); } for (i = 0; i < 4; i++) { wr_s16b(battle_mon[i]); wr_u32b(mon_odds[i]); } wr_s16b(p_ptr->town_num); /* -KMW- */ /* Write arena and rewards information -KMW- */ wr_s16b(p_ptr->arena_number); wr_s16b(p_ptr->inside_arena); wr_s16b(p_ptr->inside_quest); wr_s16b(p_ptr->inside_battle); wr_byte(p_ptr->exit_bldg); wr_byte(0); /* Unused */ wr_s16b(p_ptr->oldpx); wr_s16b(p_ptr->oldpy); /* Was number of p_ptr->rewards[] */ wr_s16b(0); wr_s32b(p_ptr->mhp); wr_s32b(p_ptr->chp); wr_u32b(p_ptr->chp_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); tmp8u = (byte)max_d_idx; wr_byte(tmp8u); for (i = 0; i < tmp8u; i++) wr_s16b(max_dlv[i]); /* More info */ wr_s16b(0); /* oops */ wr_s16b(0); /* oops */ wr_s16b(0); /* oops */ wr_s16b(0); /* oops */ wr_s16b(p_ptr->sc); wr_s16b(p_ptr->concent); wr_s16b(0); /* old "rest" */ wr_s16b(p_ptr->blind); wr_s16b(p_ptr->paralyzed); wr_s16b(p_ptr->confused); wr_s16b(p_ptr->food); 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->cut); wr_s16b(p_ptr->stun); wr_s16b(p_ptr->poisoned); wr_s16b(p_ptr->image); wr_s16b(p_ptr->protevil); wr_s16b(p_ptr->invuln); wr_s16b(p_ptr->ult_res); wr_s16b(p_ptr->hero); wr_s16b(p_ptr->shero); wr_s16b(p_ptr->shield); wr_s16b(p_ptr->blessed); wr_s16b(p_ptr->tim_invis); wr_s16b(p_ptr->word_recall); wr_s16b(p_ptr->recall_dungeon); wr_s16b(p_ptr->alter_reality); wr_s16b(p_ptr->see_infra); wr_s16b(p_ptr->tim_infra); wr_s16b(p_ptr->oppose_fire); wr_s16b(p_ptr->oppose_cold); wr_s16b(p_ptr->oppose_acid); wr_s16b(p_ptr->oppose_elec); wr_s16b(p_ptr->oppose_pois); wr_s16b(p_ptr->tsuyoshi); wr_s16b(p_ptr->tim_esp); wr_s16b(p_ptr->wraith_form); wr_s16b(p_ptr->resist_magic); wr_s16b(p_ptr->tim_regen); wr_s16b(p_ptr->kabenuke); wr_s16b(p_ptr->tim_stealth); 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->magicdef); wr_s16b(p_ptr->tim_res_nether); wr_s16b(p_ptr->tim_res_time); wr_byte(p_ptr->mimic_form); wr_s16b(p_ptr->tim_mimic); wr_s16b(p_ptr->tim_sh_fire); wr_s16b(p_ptr->tim_sh_holy); wr_s16b(p_ptr->tim_eyeeye); /* by henkma */ wr_s16b(p_ptr->tim_reflect); wr_s16b(p_ptr->multishadow); wr_s16b(p_ptr->dustrobe); wr_s16b(p_ptr->chaos_patron); wr_u32b(p_ptr->muta1); wr_u32b(p_ptr->muta2); wr_u32b(p_ptr->muta3); for (i = 0; i<8; i++) wr_s16b(p_ptr->virtues[i]); for (i = 0; i<8; i++) wr_s16b(p_ptr->vir_types[i]); wr_s16b(p_ptr->ele_attack); wr_u32b(p_ptr->special_attack); wr_s16b(p_ptr->ele_immune); wr_u32b(p_ptr->special_defense); wr_byte(p_ptr->knowledge); wr_byte(p_ptr->autopick_autoregister); wr_byte(0); /* oops */ wr_byte(p_ptr->action); wr_byte(0); wr_byte(preserve_mode); wr_byte(p_ptr->wait_report_score); /* Future use */ for (i = 0; i < 12; i++) wr_u32b(0L); /* Ignore some flags */ wr_u32b(0L); /* oops */ wr_u32b(0L); /* oops */ wr_u32b(0L); /* oops */ /* Write the "object seeds" */ wr_u32b(seed_flavor); wr_u32b(seed_town); /* Special stuff */ wr_u16b(p_ptr->panic_save); wr_u16b(p_ptr->total_winner); wr_u16b(p_ptr->noscore); /* Write death */ wr_byte(p_ptr->is_dead); /* Write feeling */ wr_byte(p_ptr->feeling); /* Turn when level began */ wr_s32b(old_turn); /* Turn of last "feeling" */ wr_s32b(p_ptr->feeling_turn); /* Current turn */ wr_s32b(turn); wr_s32b(dungeon_turn); wr_s32b(old_battle); wr_s16b(today_mon); wr_s16b(p_ptr->today_mon); wr_s16b(p_ptr->riding); /* Current floor_id */ wr_s16b(p_ptr->floor_id); /* Save temporary preserved pets (obsolated) */ wr_s16b(0); wr_u32b(playtime); wr_s32b(p_ptr->visit); wr_u32b(p_ptr->count); }
/*! * @brief セーブデータの書き込み / * Actually write a save-file * @return 成功すればtrue */ static bool wr_savefile_new(void) { int i, j; u32b now; byte tmp8u; u16b tmp16u; /* Compact the objects */ compact_objects(0); /* Compact the monsters */ compact_monsters(0); /* Guess at the current time */ now = time((time_t *)0); /* Note the operating system */ sf_system = 0L; /* Note when the file was saved */ sf_when = now; /* Note the number of saves */ sf_saves++; /*** Actually write the file ***/ /* Dump the file header */ xor_byte = 0; wr_byte(FAKE_VER_MAJOR); xor_byte = 0; wr_byte(FAKE_VER_MINOR); xor_byte = 0; wr_byte(FAKE_VER_PATCH); xor_byte = 0; /* Initial value of xor_byte */ tmp8u = (byte)Rand_external(256); wr_byte(tmp8u); /* Reset the checksum */ v_stamp = 0L; x_stamp = 0L; /* Write the savefile version for Hengband 1.1.1 and later */ wr_byte(H_VER_EXTRA); wr_byte(H_VER_PATCH); wr_byte(H_VER_MINOR); wr_byte(H_VER_MAJOR); /* Operating system */ wr_u32b(sf_system); /* Time file last saved */ wr_u32b(sf_when); /* Number of past lives */ wr_u16b(sf_lives); /* Number of times saved */ wr_u16b(sf_saves); /* Space */ 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(); /* Write the boolean "options" */ wr_options(); /* Dump the number of "messages" */ tmp16u = message_num(); if (compress_savefile && (tmp16u > 40)) tmp16u = 40; wr_u16b(tmp16u); /* Dump the messages (oldest first!) */ for (i = tmp16u - 1; i >= 0; i--) { wr_string(message_str((s16b)i)); } /* Dump the monster lore */ tmp16u = max_r_idx; wr_u16b(tmp16u); for (i = 0; i < tmp16u; i++) wr_lore(i); /* Dump the object memory */ tmp16u = max_k_idx; wr_u16b(tmp16u); for (i = 0; i < tmp16u; i++) wr_xtra(i); /* Dump the towns */ tmp16u = max_towns; wr_u16b(tmp16u); /* Dump the quests */ tmp16u = max_quests; wr_u16b(tmp16u); /* Dump the quests */ tmp8u = MAX_RANDOM_QUEST-MIN_RANDOM_QUEST; wr_byte(tmp8u); for (i = 0; i < max_quests; i++) { quest_type* const q_ptr = &quest[i]; /* Save status for every quest */ wr_s16b(q_ptr->status); /* And the dungeon level too */ /* (prevents problems with multi-level quests) */ wr_s16b(q_ptr->level); wr_byte(q_ptr->complev); wr_u32b(q_ptr->comptime); /* Save quest status if quest is running */ if (q_ptr->status == QUEST_STATUS_TAKEN || q_ptr->status == QUEST_STATUS_COMPLETED || !is_fixed_quest_idx(i)) { 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); } } /* Dump the position in the wilderness */ wr_s32b(p_ptr->wilderness_x); wr_s32b(p_ptr->wilderness_y); wr_byte(p_ptr->wild_mode); wr_byte(ambush_flag); wr_s32b(max_wild_x); wr_s32b(max_wild_y); /* Dump the wilderness seeds */ for (i = 0; i < max_wild_x; i++) { for (j = 0; j < max_wild_y; j++) { wr_u32b(wilderness[j][i].seed); } } /* Hack -- Dump the artifacts */ tmp16u = max_a_idx; wr_u16b(tmp16u); for (i = 0; i < tmp16u; i++) { artifact_type *a_ptr = &a_info[i]; wr_byte(a_ptr->cur_num); wr_s16b(a_ptr->floor_id); } /* Write the "extra" information */ wr_extra(); /* Dump the "player hp" entries */ tmp16u = PY_MAX_LEVEL; wr_u16b(tmp16u); for (i = 0; i < tmp16u; i++) { wr_s16b(p_ptr->player_hp[i]); } /* Write spell data */ wr_u32b(p_ptr->spell_learned1); wr_u32b(p_ptr->spell_learned2); wr_u32b(p_ptr->spell_worked1); wr_u32b(p_ptr->spell_worked2); wr_u32b(p_ptr->spell_forgotten1); wr_u32b(p_ptr->spell_forgotten2); wr_s16b(p_ptr->learned_spells); wr_s16b(p_ptr->add_spells); /* Dump the ordered spells */ for (i = 0; i < 64; i++) { wr_byte(p_ptr->spell_order[i]); } /* Write the inventory */ for (i = 0; i < INVEN_TOTAL; i++) { object_type *o_ptr = &inventory[i]; /* Skip non-objects */ if (!o_ptr->k_idx) continue; /* Dump index */ wr_u16b((u16b)i); /* Dump object */ wr_item(o_ptr); } /* Add a sentinel */ wr_u16b(0xFFFF); /* Note the towns */ tmp16u = max_towns; wr_u16b(tmp16u); /* Note the stores */ tmp16u = MAX_STORES; wr_u16b(tmp16u); /* Dump the stores of all towns */ for (i = 1; i < max_towns; i++) { for (j = 0; j < MAX_STORES; j++) { wr_store(&town[i].store[j]); } } /* Write the pet command settings */ wr_s16b(p_ptr->pet_follow_distance); wr_s16b(p_ptr->pet_extra_flags); /* Write screen dump for sending score */ if (screen_dump && (p_ptr->wait_report_score || !p_ptr->is_dead)) { wr_string(screen_dump); } else { wr_string(""); } /* Player is not dead, write the dungeon */ if (!p_ptr->is_dead) { /* Dump the dungeon */ if (!wr_dungeon()) return FALSE; /* Dump the ghost */ wr_ghost(); /* No scripts */ wr_s32b(0); } /* Write the "value check-sum" */ wr_u32b(v_stamp); /* Write the "encoded checksum" */ wr_u32b(x_stamp); /* Error in save */ if (ferror(fff) || (fflush(fff) == EOF)) return FALSE; /* Successful save */ return TRUE; }
/*! * @brief 現在フロアの書き込み / * Write the current dungeon (new method) * @return なし */ static bool wr_dungeon(void) { saved_floor_type *cur_sf_ptr; int i; /* Forget the lite */ forget_lite(); /* Forget the view */ forget_view(); /* Forget the view */ clear_mon_lite(); /* Update lite/view */ p_ptr->update |= (PU_VIEW | PU_LITE | PU_MON_LITE); /* Update monsters */ p_ptr->update |= (PU_MONSTERS | PU_DISTANCE | PU_FLOW); /*** Meta info ***/ /* Number of floor_id used from birth */ wr_s16b(max_floor_id); /* Current dungeon type */ wr_byte(dungeon_type); /*** No saved floor (On the surface etc.) ***/ if (!p_ptr->floor_id) { /* No array elements */ wr_byte(0); /* Write the current floor data */ wr_saved_floor(NULL); /* Success */ return TRUE; } /*** In the dungeon ***/ /* Number of array elements */ wr_byte(MAX_SAVED_FLOORS); /* Write the saved_floors array */ for (i = 0; i < MAX_SAVED_FLOORS; i++) { saved_floor_type *sf_ptr = &saved_floors[i]; wr_s16b(sf_ptr->floor_id); wr_byte(sf_ptr->savefile_id); wr_s16b(sf_ptr->dun_level); wr_s32b(sf_ptr->last_visit); wr_u32b(sf_ptr->visit_mark); wr_s16b(sf_ptr->upper_floor_id); wr_s16b(sf_ptr->lower_floor_id); } /* Extract pointer to current floor */ cur_sf_ptr = get_sf_ptr(p_ptr->floor_id); /* Save current floor to temporal file */ if (!save_floor(cur_sf_ptr, (SLF_SECOND))) return FALSE; /* Move data in temporal files to the savefile */ for (i = 0; i < MAX_SAVED_FLOORS; i++) { saved_floor_type *sf_ptr = &saved_floors[i]; /* Unused element */ if (!sf_ptr->floor_id) continue; /* Load temporal saved floor file */ if (load_floor(sf_ptr, (SLF_SECOND | SLF_NO_KILL))) { /* Mark success */ wr_byte(0); /* Write saved floor data to the save file */ wr_saved_floor(sf_ptr); } else { /* Mark failure */ wr_byte(1); } } /* Restore current floor */ if (!load_floor(cur_sf_ptr, (SLF_SECOND))) return FALSE; /* Success */ return TRUE; }
/* * Write some "extra" info */ static void wr_extra(void) { int i, j; wr_string(op_ptr->full_name); wr_string(p_ptr->died_from); wr_string(p_ptr->history); /* Race/House/Sex */ wr_byte(p_ptr->prace); wr_byte(p_ptr->phouse); wr_byte(p_ptr->psex); wr_s16b(p_ptr->game_type); /* Age/Height/Weight */ wr_s16b(p_ptr->age); wr_s16b(p_ptr->ht); wr_s16b(p_ptr->wt); /* Dump the stats (maximum and current) */ for (i = 0; i < A_MAX; ++i) wr_s16b(p_ptr->stat_base[i]); for (i = 0; i < A_MAX; ++i) wr_s16b(p_ptr->stat_drain[i]); /* Dump the skill bases */ for (i = 0; i < S_MAX; ++i) wr_s16b(p_ptr->skill_base[i]); for (i = 0; i < S_MAX; ++i) { for (j = 0; j < ABILITIES_MAX; ++j) { wr_byte(p_ptr->innate_ability[i][j]); wr_byte(p_ptr->active_ability[i][j]); } } wr_s16b(p_ptr->last_attack_m_idx); wr_s16b(p_ptr->consecutive_attacks); wr_s16b(p_ptr->bane_type); for (i = 0; i < ACTION_MAX; ++i) { wr_byte(p_ptr->previous_action[i]); } wr_byte(p_ptr->focused); wr_s32b(p_ptr->new_exp); wr_s32b(p_ptr->exp); wr_s32b(p_ptr->encounter_exp); wr_s32b(p_ptr->kill_exp); wr_s32b(p_ptr->descent_exp); wr_s32b(p_ptr->ident_exp); wr_s16b(p_ptr->mhp); wr_s16b(p_ptr->chp); wr_u16b(p_ptr->chp_frac); wr_s16b(p_ptr->msp); wr_s16b(p_ptr->csp); wr_u16b(p_ptr->csp_frac); /* Max Dungeon Level */ wr_s16b(p_ptr->max_depth); wr_u16b(p_ptr->staircasiness); /* More info */ wr_s16b(p_ptr->sc); wr_byte(p_ptr->song1); wr_byte(p_ptr->song2); wr_s16b(p_ptr->song_duration); wr_s16b(p_ptr->wrath); wr_s16b(p_ptr->blind); wr_s16b(p_ptr->entranced); wr_s16b(p_ptr->confused); wr_s16b(p_ptr->food); wr_u16b(p_ptr->stairs_taken); wr_u16b(p_ptr->forge_drought); wr_u16b(p_ptr->forge_count); wr_s16b(p_ptr->energy); wr_s16b(p_ptr->fast); wr_s16b(p_ptr->slow); wr_s16b(p_ptr->afraid); wr_s16b(p_ptr->cut); wr_s16b(p_ptr->stun); wr_s16b(p_ptr->poisoned); wr_s16b(p_ptr->image); wr_s16b(p_ptr->rage); wr_s16b(p_ptr->tmp_str); wr_s16b(p_ptr->tmp_dex); wr_s16b(p_ptr->tmp_con); wr_s16b(p_ptr->tmp_gra); wr_s16b(p_ptr->tim_invis); wr_s16b(p_ptr->word_recall); wr_s16b(p_ptr->darkened); wr_s16b(p_ptr->oppose_fire); wr_s16b(p_ptr->oppose_cold); wr_s16b(p_ptr->oppose_pois); wr_byte(p_ptr->stealth_mode); wr_byte(p_ptr->self_made_arts); // 20 spare bytes wr_byte(0); wr_byte(0); wr_byte(0); wr_byte(0); wr_u32b(0L); wr_u32b(0L); wr_u32b((p_ptr->loglive.i)[0]); //mortality info wr_u32b((p_ptr->loglive.i)[1]); /* Save item-quality squelch sub-menu */ for (i = 0; i < SQUELCH_BYTES; i++) wr_byte(squelch_level[i]); /* Store the name of the current greater vault */ wr_string(g_vault_name); /* Save the current number of special item types */ wr_u16b(z_info->e_max); /* Save special item squelch settings */ for (i = 0; i < z_info->e_max; i++) { ego_item_type *e_ptr = &e_info[i]; byte tmp8u = 0; if (e_ptr->squelch) tmp8u |= 0x01; if (e_ptr->everseen) tmp8u |= 0x02; if (e_ptr->aware) tmp8u |= 0x04; wr_byte(tmp8u); } /*Write the current number of auto-inscriptions*/ wr_u16b(inscriptionsCount); /*Write the autoinscriptions array*/ for(i = 0; i < inscriptionsCount; i++) { wr_s16b(inscriptions[i].kindIdx); wr_string(quark_str(inscriptions[i].inscriptionIdx)); } // Greater vaults seen for (i = 0; i < MAX_GREATER_VAULTS; i++) { wr_s16b(p_ptr->greater_vaults[i]); } /* Random artefact version */ wr_u32b(RANDART_VERSION); /* Random artefact seed */ wr_u32b(seed_randart); /* Write the "object seeds" */ wr_u32b(seed_flavor); /* Special stuff */ wr_u16b(p_ptr->panic_save); wr_byte(p_ptr->truce); wr_byte(p_ptr->morgoth_hits); wr_byte(p_ptr->crown_hint); wr_byte(p_ptr->crown_shatter); wr_byte(p_ptr->cursed); wr_byte(p_ptr->on_the_run); wr_byte(p_ptr->morgoth_slain); wr_u16b(p_ptr->escaped); wr_u16b(p_ptr->noscore); wr_u16b(p_ptr->smithing_leftover); wr_byte(p_ptr->unique_forge_made); wr_byte(p_ptr->unique_forge_seen); /* Write death */ wr_byte(p_ptr->is_dead); /* Write feeling */ wr_byte(feeling); /* Turn of last "feeling" */ wr_byte(do_feeling); /* Current turn */ wr_s32b(turn); wr_s32b(playerturn); }