X-Git-Url: http://git.osdn.net/view?a=blobdiff_plain;f=src%2Fcore%2Fgame-play.cpp;h=88858e8a6024cc0f4f8c66bd156c8810e3159511;hb=613e3c767869a96d7ef620ae26c94c83e1f48c37;hp=38df28af5c5a0f613cfd3410167f1ffecc45a644;hpb=d077de03c37d8fa89dc93964082e0cc527ad9680;p=hengbandforosx%2Fhengbandosx.git diff --git a/src/core/game-play.cpp b/src/core/game-play.cpp index 38df28af5..88858e8a6 100644 --- a/src/core/game-play.cpp +++ b/src/core/game-play.cpp @@ -19,6 +19,7 @@ #include "core/game-closer.h" #include "core/player-processor.h" #include "core/player-update-types.h" +#include "core/score-util.h" #include "core/scores.h" #include "core/speed-table.h" #include "core/stuff-handler.h" @@ -31,6 +32,7 @@ #include "floor/floor-events.h" #include "floor/floor-leaver.h" #include "floor/floor-mode-changer.h" +#include "floor/floor-save.h" #include "floor/floor-util.h" #include "floor/wild.h" #include "game-option/cheat-options.h" @@ -60,10 +62,11 @@ #include "monster-race/monster-race.h" #include "monster-race/race-indice-types.h" #include "monster/monster-util.h" -#include "player/player-class.h" -#include "player/player-personalities-types.h" -#include "player/player-race-types.h" +#include "player-info/class-info.h" +#include "player-info/race-types.h" +#include "player/player-personality-types.h" #include "player/player-skill.h" +#include "player/player-status.h" #include "player/process-name.h" #include "racial/racial-android.h" #include "realm/realm-names-table.h" @@ -77,7 +80,10 @@ #include "sv-definition/sv-weapon-types.h" #include "system/angband-version.h" #include "system/floor-type-definition.h" -#include "system/system-variables.h" +#include "system/monster-race-definition.h" +#include "system/monster-type-definition.h" +#include "system/object-type-definition.h" +#include "system/player-type-definition.h" #include "target/target-checker.h" #include "term/gameterm.h" #include "term/screen-processor.h" @@ -90,8 +96,8 @@ static void restore_windows(player_type *player_ptr) { - player_ptr->hack_mutation = FALSE; - current_world_ptr->character_icky_depth = 1; + player_ptr->hack_mutation = false; + w_ptr->character_icky_depth = 1; term_activate(angband_term[0]); angband_term[0]->resize_hook = resize_map; for (MONSTER_IDX i = 1; i < 8; i++) @@ -112,21 +118,21 @@ static void send_waiting_record(player_type *player_ptr) player_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS); update_creature(player_ptr); - player_ptr->is_dead = TRUE; - current_world_ptr->start_time = (u32b)time(NULL); + player_ptr->is_dead = true; + w_ptr->start_time = (uint32_t)time(nullptr); signals_ignore_tstp(); - current_world_ptr->character_icky_depth = 1; + w_ptr->character_icky_depth = 1; path_build(buf, sizeof(buf), ANGBAND_DIR_APEX, "scores.raw"); highscore_fd = fd_open(buf, O_RDWR); /* 町名消失バグ対策(#38205)のためここで世界マップ情報を読み出す */ - parse_fixed_map(player_ptr, "w_info.txt", 0, 0, current_world_ptr->max_wild_y, current_world_ptr->max_wild_x); - bool success = send_world_score(player_ptr, TRUE, display_player); + parse_fixed_map(player_ptr, "w_info.txt", 0, 0, w_ptr->max_wild_y, w_ptr->max_wild_x); + bool success = send_world_score(player_ptr, true, display_player); if (!success && !get_check_strict(player_ptr, _("スコア登録を諦めますか?", "Do you give up score registration? "), CHECK_NO_HISTORY)) { prt(_("引き続き待機します。", "standing by for future registration..."), 0, 0); (void)inkey(); } else { - player_ptr->wait_report_score = FALSE; + player_ptr->wait_report_score = false; top_twenty(player_ptr); if (!save_player(player_ptr, SAVE_TYPE_CLOSE_GAME)) msg_print(_("セーブ失敗!", "death save failed!")); @@ -140,14 +146,14 @@ static void send_waiting_record(player_type *player_ptr) static void init_random_seed(player_type *player_ptr, bool new_game) { - bool init_random_seed = FALSE; - if (!current_world_ptr->character_loaded) { - new_game = TRUE; - current_world_ptr->character_dungeon = FALSE; - init_random_seed = TRUE; - init_saved_floors(player_ptr, FALSE); + bool init_random_seed = false; + if (!w_ptr->character_loaded) { + new_game = true; + w_ptr->character_dungeon = false; + init_random_seed = true; + init_saved_floors(player_ptr, false); } else if (new_game) - init_saved_floors(player_ptr, TRUE); + init_saved_floors(player_ptr, true); if (!new_game) process_player_name(player_ptr); @@ -158,33 +164,33 @@ static void init_random_seed(player_type *player_ptr, bool new_game) static void init_world_floor_info(player_type *player_ptr) { - current_world_ptr->character_dungeon = FALSE; + w_ptr->character_dungeon = false; floor_type *floor_ptr = player_ptr->current_floor_ptr; floor_ptr->dun_level = 0; floor_ptr->inside_quest = 0; - floor_ptr->inside_arena = FALSE; - player_ptr->phase_out = FALSE; - write_level = TRUE; - current_world_ptr->seed_flavor = randint0(0x10000000); - current_world_ptr->seed_town = randint0(0x10000000); + floor_ptr->inside_arena = false; + player_ptr->phase_out = false; + write_level = true; + w_ptr->seed_flavor = randint0(0x10000000); + w_ptr->seed_town = randint0(0x10000000); player_birth(player_ptr); counts_write(player_ptr, 2, 0); player_ptr->count = 0; - load = FALSE; + load = false; determine_bounty_uniques(player_ptr); - determine_daily_bounty(player_ptr, FALSE); + determine_daily_bounty(player_ptr, false); wipe_o_list(floor_ptr); } /*! - * @brief フロア情報をゲームロード時に復帰 + * @brief フロア情報をゲームロード時に復帰 * @todo 3.0.Xで削除予定 * 1.0.9 以前はセーブ前に player_ptr->riding = -1 としていたので、再設定が必要だった。 * もう不要だが、以前のセーブファイルとの互換のために残しておく。 */ static void restore_world_floor_info(player_type *player_ptr) { - write_level = FALSE; + write_level = false; exe_write_diary(player_ptr, DIARY_GAMESTART, 1, _(" ----ゲーム再開----", " --- Restarted Game ---")); if (player_ptr->riding == -1) { @@ -201,43 +207,23 @@ static void restore_world_floor_info(player_type *player_ptr) static void reset_world_info(player_type *player_ptr) { - current_world_ptr->creating_savefile = FALSE; - player_ptr->teleport_town = FALSE; - player_ptr->sutemi = FALSE; - current_world_ptr->timewalk_m_idx = 0; - player_ptr->now_damaged = FALSE; + w_ptr->creating_savefile = false; + player_ptr->teleport_town = false; + player_ptr->sutemi = false; + w_ptr->timewalk_m_idx = 0; + player_ptr->now_damaged = false; now_message = 0; - current_world_ptr->start_time = time(NULL) - 1; + w_ptr->start_time = time(nullptr) - 1; record_o_name[0] = '\0'; } -static void set_wizard_mode_by_argument(player_type *player_ptr) -{ - if (!arg_wizard) - return; - - if (enter_wizard_mode(player_ptr)) { - current_world_ptr->wizard = TRUE; - if (player_ptr->is_dead || !player_ptr->y || !player_ptr->x) { - init_saved_floors(player_ptr, TRUE); - player_ptr->current_floor_ptr->inside_quest = 0; - player_ptr->y = player_ptr->x = 10; - } - - return; - } - - if (player_ptr->is_dead) - quit("Already dead."); -} - static void generate_wilderness(player_type *player_ptr) { floor_type *floor_ptr = player_ptr->current_floor_ptr; if ((floor_ptr->dun_level == 0) && floor_ptr->inside_quest) return; - parse_fixed_map(player_ptr, "w_info.txt", 0, 0, current_world_ptr->max_wild_y, current_world_ptr->max_wild_x); + parse_fixed_map(player_ptr, "w_info.txt", 0, 0, w_ptr->max_wild_y, w_ptr->max_wild_x); init_flags = INIT_ONLY_BUILDINGS; parse_fixed_map(player_ptr, "t_info.txt", 0, 0, MAX_HGT, MAX_WID); select_floor_music(player_ptr); @@ -245,7 +231,7 @@ static void generate_wilderness(player_type *player_ptr) static void change_floor_if_error(player_type *player_ptr) { - if (!current_world_ptr->character_dungeon) { + if (!w_ptr->character_dungeon) { change_floor(player_ptr); return; } @@ -271,12 +257,13 @@ static void generate_world(player_type *player_ptr, bool new_game) panel_row_min = floor_ptr->height; panel_col_min = floor_ptr->width; - if (player_ptr->pclass != CLASS_SORCERER) { - if (player_ptr->pseikaku == PERSONALITY_SEXY) - s_info[player_ptr->pclass].w_max[TV_HAFTED - TV_WEAPON_BEGIN][SV_WHIP] = WEAPON_EXP_MASTER; - if (player_ptr->prace == RACE_MERFOLK) { - s_info[player_ptr->pclass].w_max[TV_POLEARM - TV_WEAPON_BEGIN][SV_TRIDENT] = WEAPON_EXP_MASTER; - s_info[player_ptr->pclass].w_max[TV_POLEARM - TV_WEAPON_BEGIN][SV_TRIFURCATE_SPEAR] = WEAPON_EXP_MASTER; + if (player_ptr->pclass != PlayerClassType::SORCERER) { + auto pclass = enum2i(player_ptr->pclass); + if (player_ptr->ppersonality == PERSONALITY_SEXY) + s_info[pclass].w_max[ItemKindType::HAFTED][SV_WHIP] = PlayerSkill::weapon_exp_at(PlayerSkillRank::MASTER); + if (player_ptr->prace == PlayerRaceType::MERFOLK) { + s_info[pclass].w_max[ItemKindType::POLEARM][SV_TRIDENT] = PlayerSkill::weapon_exp_at(PlayerSkillRank::MASTER); + s_info[pclass].w_max[ItemKindType::POLEARM][SV_TRIFURCATE_SPEAR] = PlayerSkill::weapon_exp_at(PlayerSkillRank::MASTER); } } @@ -284,11 +271,10 @@ static void generate_world(player_type *player_ptr, bool new_game) flavor_init(); prt(_("お待ち下さい...", "Please wait..."), 0, 0); term_fresh(); - set_wizard_mode_by_argument(player_ptr); generate_wilderness(player_ptr); change_floor_if_error(player_ptr); - current_world_ptr->character_generated = TRUE; - current_world_ptr->character_icky_depth = 0; + w_ptr->character_generated = true; + w_ptr->character_icky_depth = 0; if (!new_game) return; @@ -303,18 +289,18 @@ static void init_io(player_type *player_ptr) player_ptr->window_flags = PW_ALL; handle_stuff(player_ptr); if (arg_force_original) - rogue_like_commands = FALSE; + rogue_like_commands = false; if (arg_force_roguelike) - rogue_like_commands = TRUE; + rogue_like_commands = true; } static void init_riding_pet(player_type *player_ptr, bool new_game) { - if (!new_game || ((player_ptr->pclass != CLASS_CAVALRY) && (player_ptr->pclass != CLASS_BEASTMASTER))) + if (!new_game || ((player_ptr->pclass != PlayerClassType::CAVALRY) && (player_ptr->pclass != PlayerClassType::BEASTMASTER))) return; - MONRACE_IDX pet_r_idx = ((player_ptr->pclass == CLASS_CAVALRY) ? MON_HORSE : MON_YASE_HORSE); + MONRACE_IDX pet_r_idx = ((player_ptr->pclass == PlayerClassType::CAVALRY) ? MON_HORSE : MON_YASE_HORSE); monster_race *r_ptr = &r_info[pet_r_idx]; place_monster_aux(player_ptr, 0, player_ptr->y, player_ptr->x - 1, pet_r_idx, (PM_FORCE_PET | PM_NO_KAGE)); monster_type *m_ptr = &player_ptr->current_floor_ptr->m_list[hack_m_idx_ii]; @@ -333,22 +319,23 @@ static void decide_arena_death(player_type *player_ptr) floor_type *floor_ptr = player_ptr->current_floor_ptr; if (!floor_ptr->inside_arena) { - if ((current_world_ptr->wizard || cheat_live) && !get_check(_("死にますか? ", "Die? "))) + if (cheat_live && !get_check(_("死にますか? ", "Die? "))) { cheat_death(player_ptr); + } return; } - floor_ptr->inside_arena = FALSE; + floor_ptr->inside_arena = false; if (player_ptr->arena_number > MAX_ARENA_MONS) player_ptr->arena_number++; else player_ptr->arena_number = -1 - player_ptr->arena_number; - player_ptr->is_dead = FALSE; + player_ptr->is_dead = false; player_ptr->chp = 0; player_ptr->chp_frac = 0; - player_ptr->exit_bldg = TRUE; + player_ptr->exit_bldg = true; reset_tim_flags(player_ptr); prepare_change_floor_mode(player_ptr, CFM_SAVE_FLOORS | CFM_RAND_CONNECT); leave_floor(player_ptr); @@ -356,13 +343,13 @@ static void decide_arena_death(player_type *player_ptr) static void process_game_turn(player_type *player_ptr) { - bool load_game = TRUE; + bool load_game = true; floor_type *floor_ptr = player_ptr->current_floor_ptr; - while (TRUE) { + while (true) { process_dungeon(player_ptr, load_game); - current_world_ptr->character_xtra = TRUE; + w_ptr->character_xtra = true; handle_stuff(player_ptr); - current_world_ptr->character_xtra = FALSE; + w_ptr->character_xtra = false; target_who = 0; health_track(player_ptr, 0); forget_lite(floor_ptr); @@ -375,8 +362,8 @@ static void process_game_turn(player_type *player_ptr) if (!player_ptr->is_dead) wipe_monsters_list(player_ptr); - msg_print(NULL); - load_game = FALSE; + msg_print(nullptr); + load_game = false; decide_arena_death(player_ptr); if (player_ptr->is_dead) break; @@ -387,10 +374,9 @@ static void process_game_turn(player_type *player_ptr) /*! * @brief 1ゲームプレイの主要ルーチン / Actually play a game - * @param player_ptr プレーヤーへの参照ポインタ + * @param player_ptr プレイヤーへの参照ポインタ * @param new_game 新規にゲームを始めたかどうか * @param browsing_movie ムービーモードか - * @return なし * @note * If the "new_game" parameter is true, then, after loading the * savefile, we will commit suicide, if necessary, to allow the @@ -410,7 +396,7 @@ void play_game(player_type *player_ptr, bool new_game, bool browsing_movie) extract_option_vars(); send_waiting_record(player_ptr); - current_world_ptr->creating_savefile = new_game; + w_ptr->creating_savefile = new_game; init_random_seed(player_ptr, new_game); if (new_game) init_world_floor_info(player_ptr); @@ -418,7 +404,7 @@ void play_game(player_type *player_ptr, bool new_game, bool browsing_movie) restore_world_floor_info(player_ptr); generate_world(player_ptr, new_game); - player_ptr->playing = TRUE; + player_ptr->playing = true; reset_visuals(player_ptr); load_all_pref_files(player_ptr); if (new_game) @@ -426,16 +412,16 @@ void play_game(player_type *player_ptr, bool new_game, bool browsing_movie) init_io(player_ptr); if (player_ptr->chp < 0 && !cheat_immortal) - player_ptr->is_dead = TRUE; + player_ptr->is_dead = true; - if (player_ptr->prace == RACE_ANDROID) + if (player_ptr->prace == PlayerRaceType::ANDROID) calc_android_exp(player_ptr); init_riding_pet(player_ptr, new_game); - (void)combine_and_reorder_home(player_ptr, STORE_HOME); - (void)combine_and_reorder_home(player_ptr, STORE_MUSEUM); + (void)combine_and_reorder_home(player_ptr, StoreSaleType::HOME); + (void)combine_and_reorder_home(player_ptr, StoreSaleType::MUSEUM); select_floor_music(player_ptr); process_game_turn(player_ptr); close_game(player_ptr); - quit(NULL); + quit(nullptr); }