X-Git-Url: http://git.osdn.net/view?a=blobdiff_plain;f=src%2Fcore.c;h=c4fc41399a41771256161c9da892a85b3d648494;hb=19c6df448420700670f3db3e9d4ece7910cf27c4;hp=c3c43210d30a8a81e356e326c9d680e78f4c843a;hpb=7e939a29537b211d3e81cda1d98c8fc0d3f55a9b;p=hengband%2Fhengband.git diff --git a/src/core.c b/src/core.c index c3c43210d..c4fc41399 100644 --- a/src/core.c +++ b/src/core.c @@ -11,30 +11,40 @@ */ #include "angband.h" +#include "signal-handlers.h" #include "util.h" +#include "main/music-definitions-table.h" #include "core.h" #include "inet.h" -#include "term.h" +#include "gameterm.h" +#include "chuukei.h" #include "creature.h" #include "birth.h" -#include "bldg.h" -#include "cmd-activate.h" -#include "cmd-dump.h" -#include "cmd-eat.h" -#include "cmd-hissatsu.h" -#include "cmd-item.h" -#include "cmd-magiceat.h" -#include "cmd-mane.h" -#include "cmd-quaff.h" -#include "cmd-read.h" -#include "cmd-smith.h" -#include "cmd-usestaff.h" -#include "cmd-zaprod.h" -#include "cmd-zapwand.h" -#include "cmd-pet.h" -#include "cmd-basic.h" +#include "market/building.h" +#include "io/write-diary.h" +#include "cmd/cmd-activate.h" +#include "cmd/cmd-diary.h" +#include "cmd/cmd-draw.h" +#include "cmd/cmd-dump.h" +#include "cmd/cmd-eat.h" +#include "cmd/cmd-help.h" +#include "cmd/cmd-hissatsu.h" +#include "cmd/cmd-item.h" +#include "cmd/cmd-magiceat.h" +#include "cmd/cmd-mane.h" +#include "cmd/cmd-macro.h" +#include "cmd/cmd-quaff.h" +#include "cmd/cmd-read.h" +#include "cmd/cmd-save.h" +#include "cmd/cmd-smith.h" +#include "cmd/cmd-usestaff.h" +#include "cmd/cmd-zaprod.h" +#include "cmd/cmd-zapwand.h" +#include "cmd/cmd-pet.h" +#include "cmd/cmd-basic.h" +#include "cmd/cmd-visuals.h" #include "racial.h" #include "snipe.h" #include "dungeon.h" @@ -46,7 +56,7 @@ #include "object-ego.h" #include "object-curse.h" #include "object-flavor.h" -#include "store.h" +#include "market/store.h" #include "spells.h" #include "spells-summon.h" #include "spells-object.h" @@ -56,9 +66,13 @@ #include "mind.h" #include "world.h" #include "mutation.h" +#include "market/arena-info-table.h" +#include "market/store-util.h" #include "quest.h" #include "artifact.h" #include "avatar.h" +#include "view/display-player.h" +#include "player/process-name.h" #include "player-move.h" #include "player-status.h" #include "player-class.h" @@ -81,6 +95,9 @@ #include "view-mainwindow.h" #include "dungeon-file.h" +#include "uid-checker.h" +#include "player/process-death.h" +#include "io/read-pref-file.h" #include "files.h" #include "scores.h" #include "autopick.h" @@ -102,22 +119,22 @@ const concptr copyright[5] = "are included in all such copies." }; -bool can_save = FALSE; /* Game can be saved */ +bool can_save = FALSE; COMMAND_CODE now_message; -bool repair_monsters; /* Hack -- optimize detect monsters */ -bool repair_objects; /* Hack -- optimize detect objects */ +bool repair_monsters; +bool repair_objects; -concptr ANGBAND_SYS = "xxx"; //!< Hack -- The special Angband "System Suffix" This variable is used to choose an appropriate "pref-xxx" file +concptr ANGBAND_SYS = "xxx"; #ifdef JP -concptr ANGBAND_KEYBOARD = "JAPAN"; //!< Hack -- The special Angband "Keyboard Suffix" This variable is used to choose an appropriate macro-trigger definition +concptr ANGBAND_KEYBOARD = "JAPAN"; #else concptr ANGBAND_KEYBOARD = "0"; #endif -concptr ANGBAND_GRAF = "ascii"; //!< Hack -- The special Angband "Graphics Suffix" This variable is used to choose an appropriate "graf-xxx" file +concptr ANGBAND_GRAF = "ascii"; static bool load = TRUE; /*!<ロード処理中の分岐フラグ*/ static int wild_regen = 20; /*!<広域マップ移動時の自然回復処理カウンタ(広域マップ1マス毎に20回処理を基本とする)*/ @@ -139,20 +156,12 @@ static void sense_inventory_aux(player_type *creature_ptr, INVENTORY_IDX slot, b byte feel; object_type *o_ptr = &creature_ptr->inventory_list[slot]; GAME_TEXT o_name[MAX_NLEN]; - - /* We know about it already, do not tell us again */ if (o_ptr->ident & (IDENT_SENSE))return; - - /* It is fully known, no information needed */ if (object_is_known(o_ptr)) return; - /* Check for a feeling */ feel = (heavy ? value_check_aux1(o_ptr) : value_check_aux2(o_ptr)); - - /* Skip non-feelings */ if (!feel) return; - /* Bad luck */ if ((creature_ptr->muta3 & MUT3_BAD_LUCK) && !randint0(13)) { switch (feel) @@ -201,13 +210,9 @@ static void sense_inventory_aux(player_type *creature_ptr, INVENTORY_IDX slot, b } } - /* Stop everything */ if (disturb_minor) disturb(creature_ptr, FALSE, FALSE); - /* Get an object description */ object_desc(creature_ptr, o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY)); - - /* Message (equipment) */ if (slot >= INVEN_RARM) { #ifdef JP @@ -236,11 +241,8 @@ static void sense_inventory_aux(player_type *creature_ptr, INVENTORY_IDX slot, b } o_ptr->ident |= (IDENT_SENSE); - - /* Set the "inscription" */ o_ptr->feeling = feel; - /* Auto-inscription/destroy */ autopick_alter_item(creature_ptr, slot, destroy_feeling); creature_ptr->update |= (PU_COMBINE | PU_REORDER); creature_ptr->window |= (PW_INVEN | PW_EQUIP); @@ -262,18 +264,11 @@ static void sense_inventory_aux(player_type *creature_ptr, INVENTORY_IDX slot, b */ static void sense_inventory1(player_type *creature_ptr) { - INVENTORY_IDX i; PLAYER_LEVEL plev = creature_ptr->lev; bool heavy = FALSE; object_type *o_ptr; - - - /*** Check for "sensing" ***/ - - /* No sensing when confused */ if (creature_ptr->confused) return; - /* Analyze the class */ switch (creature_ptr->pclass) { case CLASS_WARRIOR: @@ -281,163 +276,117 @@ static void sense_inventory1(player_type *creature_ptr) case CLASS_SAMURAI: case CLASS_CAVALRY: { - /* Good sensing */ if (0 != randint0(9000L / (plev * plev + 40))) return; - /* Heavy sensing */ heavy = TRUE; - break; } - case CLASS_SMITH: { - /* Good sensing */ if (0 != randint0(6000L / (plev * plev + 50))) return; - /* Heavy sensing */ heavy = TRUE; - break; } - case CLASS_MAGE: case CLASS_HIGH_MAGE: case CLASS_SORCERER: case CLASS_MAGIC_EATER: { - /* Very bad (light) sensing */ if (0 != randint0(240000L / (plev + 5))) return; break; } - case CLASS_PRIEST: case CLASS_BARD: { - /* Good (light) sensing */ if (0 != randint0(10000L / (plev * plev + 40))) return; break; } - case CLASS_ROGUE: case CLASS_NINJA: { - /* Okay sensing */ if (0 != randint0(20000L / (plev * plev + 40))) return; - /* Heavy sensing */ heavy = TRUE; - break; } - case CLASS_RANGER: { - /* Bad sensing */ if (0 != randint0(95000L / (plev * plev + 40))) return; - /* Changed! */ heavy = TRUE; - break; } - case CLASS_PALADIN: case CLASS_SNIPER: { - /* Bad sensing */ if (0 != randint0(77777L / (plev * plev + 40))) return; - /* Heavy sensing */ heavy = TRUE; - break; } - case CLASS_WARRIOR_MAGE: case CLASS_RED_MAGE: { - /* Bad sensing */ if (0 != randint0(75000L / (plev * plev + 40))) return; break; } - case CLASS_MINDCRAFTER: case CLASS_IMITATOR: case CLASS_BLUE_MAGE: case CLASS_MIRROR_MASTER: { - /* Bad sensing */ if (0 != randint0(55000L / (plev * plev + 40))) return; break; } - case CLASS_CHAOS_WARRIOR: { - /* Bad sensing */ if (0 != randint0(80000L / (plev * plev + 40))) return; - /* Changed! */ heavy = TRUE; - break; } - case CLASS_MONK: case CLASS_FORCETRAINER: { - /* Okay sensing */ if (0 != randint0(20000L / (plev * plev + 40))) return; break; } - case CLASS_TOURIST: { - /* Good sensing */ if (0 != randint0(20000L / ((plev + 50)*(plev + 50)))) return; - /* Heavy sensing */ heavy = TRUE; - break; } - case CLASS_BEASTMASTER: { - /* Bad sensing */ if (0 != randint0(65000L / (plev * plev + 40))) return; break; } case CLASS_BERSERKER: { - /* Heavy sensing */ heavy = TRUE; - break; } } if (compare_virtue(creature_ptr, V_KNOWLEDGE, 100, VIRTUE_LARGE)) heavy = TRUE; - /*** Sense everything ***/ - - /* Check everything */ - for (i = 0; i < INVEN_TOTAL; i++) + for (INVENTORY_IDX i = 0; i < INVEN_TOTAL; i++) { bool okay = FALSE; o_ptr = &creature_ptr->inventory_list[i]; - /* Skip empty slots */ if (!o_ptr->k_idx) continue; - /* Valid "tval" codes */ switch (o_ptr->tval) { case TV_SHOT: @@ -464,13 +413,9 @@ static void sense_inventory1(player_type *creature_ptr) } } - /* Skip non-sense machines */ if (!okay) continue; - - /* Occasional failure on creature_ptr->inventory_list items */ if ((i < INVEN_RARM) && (0 != randint0(5))) continue; - /* Good luck */ if ((creature_ptr->muta3 & MUT3_GOOD_LUCK) && !randint0(13)) { heavy = TRUE; @@ -480,23 +425,18 @@ static void sense_inventory1(player_type *creature_ptr) } } + /*! * @brief 1プレイヤーターン毎に武器、防具以外の擬似鑑定が行われるかを判定する。 * @return なし */ static void sense_inventory2(player_type *creature_ptr) { - INVENTORY_IDX i; PLAYER_LEVEL plev = creature_ptr->lev; object_type *o_ptr; - - /*** Check for "sensing" ***/ - - /* No sensing when confused */ if (creature_ptr->confused) return; - /* Analyze the class */ switch (creature_ptr->pclass) { case CLASS_WARRIOR: @@ -508,7 +448,6 @@ static void sense_inventory2(player_type *creature_ptr) { return; } - case CLASS_SMITH: case CLASS_PALADIN: case CLASS_CHAOS_WARRIOR: @@ -516,35 +455,29 @@ static void sense_inventory2(player_type *creature_ptr) case CLASS_BEASTMASTER: case CLASS_NINJA: { - /* Very bad (light) sensing */ if (0 != randint0(240000L / (plev + 5))) return; break; } - case CLASS_RANGER: case CLASS_WARRIOR_MAGE: case CLASS_RED_MAGE: case CLASS_MONK: { - /* Bad sensing */ if (0 != randint0(95000L / (plev * plev + 40))) return; break; } - case CLASS_PRIEST: case CLASS_BARD: case CLASS_ROGUE: case CLASS_FORCETRAINER: case CLASS_MINDCRAFTER: { - /* Good sensing */ if (0 != randint0(20000L / (plev * plev + 40))) return; break; } - case CLASS_MAGE: case CLASS_HIGH_MAGE: case CLASS_SORCERER: @@ -552,34 +485,24 @@ static void sense_inventory2(player_type *creature_ptr) case CLASS_MIRROR_MASTER: case CLASS_BLUE_MAGE: { - /* Good sensing */ if (0 != randint0(9000L / (plev * plev + 40))) return; break; } - case CLASS_TOURIST: { - /* Good sensing */ if (0 != randint0(20000L / ((plev + 50)*(plev + 50)))) return; break; } } - /*** Sense everything ***/ - - /* Check everything */ - for (i = 0; i < INVEN_TOTAL; i++) + for (INVENTORY_IDX i = 0; i < INVEN_TOTAL; i++) { bool okay = FALSE; - o_ptr = &creature_ptr->inventory_list[i]; - - /* Skip empty slots */ if (!o_ptr->k_idx) continue; - /* Valid "tval" codes */ switch (o_ptr->tval) { case TV_RING: @@ -592,10 +515,7 @@ static void sense_inventory2(player_type *creature_ptr) } } - /* Skip non-sense machines */ if (!okay) continue; - - /* Occasional failure on creature_ptr->inventory_list items */ if ((i < INVEN_RARM) && (0 != randint0(5))) continue; sense_inventory_aux(creature_ptr, i, TRUE); @@ -613,17 +533,14 @@ static void pattern_teleport(player_type *creature_ptr) DEPTH min_level = 0; DEPTH max_level = 99; - /* Ask for level */ if (get_check(_("他の階にテレポートしますか?", "Teleport level? "))) { char ppp[80]; char tmp_val[160]; - /* Only downward in ironman mode */ if (ironman_downward) min_level = creature_ptr->current_floor_ptr->dun_level; - /* Maximum level */ if (creature_ptr->dungeon_idx == DUNGEON_ANGBAND) { if (creature_ptr->current_floor_ptr->dun_level > 100) @@ -637,16 +554,10 @@ static void pattern_teleport(player_type *creature_ptr) min_level = d_info[creature_ptr->dungeon_idx].mindepth; } - /* Prompt */ sprintf(ppp, _("テレポート先:(%d-%d)", "Teleport to level (%d-%d): "), (int)min_level, (int)max_level); - - /* Default */ sprintf(tmp_val, "%d", (int)creature_ptr->current_floor_ptr->dun_level); - - /* Ask for a level */ if (!get_string(ppp, tmp_val, 10)) return; - /* Extract request */ command_arg = (COMMAND_ARG)atoi(tmp_val); } else if (get_check(_("通常テレポート?", "Normal teleport? "))) @@ -658,19 +569,15 @@ static void pattern_teleport(player_type *creature_ptr) { return; } + if (command_arg < min_level) command_arg = (COMMAND_ARG)min_level; if (command_arg > max_level) command_arg = (COMMAND_ARG)max_level; - /* Accept request */ msg_format(_("%d 階にテレポートしました。", "You teleport to dungeon level %d."), command_arg); - if (autosave_l) do_cmd_save_game(creature_ptr, TRUE); - /* Change level */ creature_ptr->current_floor_ptr->dun_level = command_arg; - leave_quest_check(creature_ptr); - if (record_stair) exe_write_diary(creature_ptr, DIARY_PAT_TELE, 0, NULL); creature_ptr->current_floor_ptr->inside_quest = 0; @@ -684,14 +591,13 @@ static void pattern_teleport(player_type *creature_ptr) creature_ptr->leaving = TRUE; } + /*! * @brief 各種パターン地形上の特別な処理 / Returns TRUE if we are on the Pattern... * @return 実際にパターン地形上にプレイヤーが居た場合はTRUEを返す。 */ static bool pattern_effect(player_type *creature_ptr) { - int pattern_type; - floor_type *floor_ptr = creature_ptr->current_floor_ptr; if (!pattern_tile(floor_ptr, creature_ptr->y, creature_ptr->x)) return FALSE; @@ -701,8 +607,7 @@ static bool pattern_effect(player_type *creature_ptr) wreck_the_pattern(creature_ptr); } - pattern_type = f_info[floor_ptr->grid_array[creature_ptr->y][creature_ptr->x].feat].subtype; - + int pattern_type = f_info[floor_ptr->grid_array[creature_ptr->y][creature_ptr->x].feat].subtype; switch (pattern_type) { case PATTERN_TILE_END: @@ -754,39 +659,26 @@ static bool pattern_effect(player_type *creature_ptr) */ static void regenhp(player_type *creature_ptr, int percent) { - HIT_POINT new_chp; - u32b new_chp_frac; - HIT_POINT old_chp; - if (creature_ptr->special_defense & KATA_KOUKIJIN) return; if (creature_ptr->action == ACTION_HAYAGAKE) return; - /* Save the old hitpoints */ - old_chp = creature_ptr->chp; + HIT_POINT old_chp = creature_ptr->chp; /* * Extract the new hitpoints * * 'percent' is the Regen factor in unit (1/2^16) */ - new_chp = 0; - new_chp_frac = (creature_ptr->mhp * percent + PY_REGEN_HPBASE); - - /* Convert the unit (1/2^16) to (1/2^32) */ + HIT_POINT new_chp = 0; + u32b new_chp_frac = (creature_ptr->mhp * percent + PY_REGEN_HPBASE); s64b_LSHIFT(new_chp, new_chp_frac, 16); - - /* Regenerating */ s64b_add(&(creature_ptr->chp), &(creature_ptr->chp_frac), new_chp, new_chp_frac); - - - /* Fully healed */ if (0 < s64b_cmp(creature_ptr->chp, creature_ptr->chp_frac, creature_ptr->mhp, 0)) { creature_ptr->chp = creature_ptr->mhp; creature_ptr->chp_frac = 0; } - /* Notice changes */ if (old_chp != creature_ptr->chp) { creature_ptr->redraw |= (PR_HP); @@ -813,17 +705,10 @@ static void regenmana(player_type *creature_ptr, MANA_POINT upkeep_factor, MANA_ */ if (creature_ptr->csp > creature_ptr->msp) { - /* PY_REGEN_NORMAL is the Regen factor in unit (1/2^16) */ s32b decay = 0; u32b decay_frac = (creature_ptr->msp * 32 * PY_REGEN_NORMAL + PY_REGEN_MNBASE); - - /* Convert the unit (1/2^16) to (1/2^32) */ s64b_LSHIFT(decay, decay_frac, 16); - - /* Decay */ s64b_sub(&(creature_ptr->csp), &(creature_ptr->csp_frac), decay, decay_frac); - - /* Stop decaying */ if (creature_ptr->csp < creature_ptr->msp) { creature_ptr->csp = creature_ptr->msp; @@ -834,17 +719,10 @@ static void regenmana(player_type *creature_ptr, MANA_POINT upkeep_factor, MANA_ /* Regenerating mana (unless the player has excess mana) */ else if (regen_rate > 0) { - /* (percent/100) is the Regen factor in unit (1/2^16) */ MANA_POINT new_mana = 0; u32b new_mana_frac = (creature_ptr->msp * regen_rate / 100 + PY_REGEN_MNBASE); - - /* Convert the unit (1/2^16) to (1/2^32) */ s64b_LSHIFT(new_mana, new_mana_frac, 16); - - /* Regenerate */ s64b_add(&(creature_ptr->csp), &(creature_ptr->csp_frac), new_mana, new_mana_frac); - - /* Must set frac to zero even if equal */ if (creature_ptr->csp >= creature_ptr->msp) { creature_ptr->csp = creature_ptr->msp; @@ -852,21 +730,13 @@ static void regenmana(player_type *creature_ptr, MANA_POINT upkeep_factor, MANA_ } } - /* Reduce mana (even when the player has excess mana) */ if (regen_rate < 0) { - /* PY_REGEN_NORMAL is the Regen factor in unit (1/2^16) */ s32b reduce_mana = 0; u32b reduce_mana_frac = (creature_ptr->msp * (-1) * regen_rate / 100 + PY_REGEN_MNBASE); - - /* Convert the unit (1/2^16) to (1/2^32) */ s64b_LSHIFT(reduce_mana, reduce_mana_frac, 16); - - /* Reduce mana */ s64b_sub(&(creature_ptr->csp), &(creature_ptr->csp_frac), reduce_mana, reduce_mana_frac); - - /* Check overflow */ if (creature_ptr->csp < 0) { creature_ptr->csp = 0; @@ -883,6 +753,7 @@ static void regenmana(player_type *creature_ptr, MANA_POINT upkeep_factor, MANA_ } } + /*! * @brief プレイヤーのMP自然回復処理 / Regenerate magic regen_amount: PY_REGEN_NORMAL * 2 (if resting) * 2 (if having regenarate) * @param regen_amount 回復量 @@ -891,11 +762,10 @@ static void regenmana(player_type *creature_ptr, MANA_POINT upkeep_factor, MANA_ static void regenmagic(player_type *creature_ptr, int regen_amount) { MANA_POINT new_mana; - int i; int dev = 30; int mult = (dev + adj_mag_mana[creature_ptr->stat_ind[A_INT]]); /* x1 to x2 speed bonus for recharging */ - for (i = 0; i < EATER_EXT * 2; i++) + for (int i = 0; i < EATER_EXT * 2; i++) { if (!creature_ptr->magic_num2[i]) continue; if (creature_ptr->magic_num1[i] == ((long)creature_ptr->magic_num2[i] << 16)) continue; @@ -909,9 +779,11 @@ static void regenmagic(player_type *creature_ptr, int regen_amount) { creature_ptr->magic_num1[i] = ((long)creature_ptr->magic_num2[i] << 16); } + wild_regen = 20; } - for (i = EATER_EXT * 2; i < EATER_EXT * 3; i++) + + for (int i = EATER_EXT * 2; i < EATER_EXT * 3; i++) { if (!creature_ptr->magic_num1[i]) continue; if (!creature_ptr->magic_num2[i]) continue; @@ -938,31 +810,21 @@ static void regenerate_monsters(player_type *player_ptr) { for (int i = 1; i < player_ptr->current_floor_ptr->m_max; i++) { - /* Check the i'th monster */ monster_type *m_ptr = &player_ptr->current_floor_ptr->m_list[i]; monster_race *r_ptr = &r_info[m_ptr->r_idx]; if (!monster_is_valid(m_ptr)) continue; - /* Allow regeneration (if needed) */ if (m_ptr->hp < m_ptr->maxhp) { - /* Hack -- Base regeneration */ int frac = m_ptr->maxhp / 100; - - /* Hack -- Minimal regeneration rate */ if (!frac) if (one_in_(2)) frac = 1; - /* Hack -- Some monsters regenerate quickly */ if (r_ptr->flags2 & RF2_REGENERATE) frac *= 2; - /* Hack -- Regenerate */ m_ptr->hp += frac; - - /* Do not over-regenerate */ if (m_ptr->hp > m_ptr->maxhp) m_ptr->hp = m_ptr->maxhp; - /* Redraw (later) if needed */ if (player_ptr->health_who == i) player_ptr->redraw |= (PR_HEALTH); if (player_ptr->riding == i) player_ptr->redraw |= (PR_UHEALTH); } @@ -978,46 +840,31 @@ static void regenerate_monsters(player_type *player_ptr) */ static void regenerate_captured_monsters(player_type *creature_ptr) { - int i, frac; bool heal = FALSE; - - /* Regenerate everyone */ - for (i = 0; i < INVEN_TOTAL; i++) + for (int i = 0; i < INVEN_TOTAL; i++) { monster_race *r_ptr; object_type *o_ptr = &creature_ptr->inventory_list[i]; - if (!o_ptr->k_idx) continue; if (o_ptr->tval != TV_CAPTURE) continue; if (!o_ptr->pval) continue; heal = TRUE; - r_ptr = &r_info[o_ptr->pval]; - - /* Allow regeneration (if needed) */ if (o_ptr->xtra4 < o_ptr->xtra5) { - /* Hack -- Base regeneration */ - frac = o_ptr->xtra5 / 100; - - /* Hack -- Minimal regeneration rate */ + int frac = o_ptr->xtra5 / 100; if (!frac) if (one_in_(2)) frac = 1; - /* Hack -- Some monsters regenerate quickly */ if (r_ptr->flags2 & RF2_REGENERATE) frac *= 2; - /* Hack -- Regenerate */ o_ptr->xtra4 += (XTRA16)frac; - - /* Do not over-regenerate */ if (o_ptr->xtra4 > o_ptr->xtra5) o_ptr->xtra4 = o_ptr->xtra5; } } if (heal) { - /* Combine pack */ creature_ptr->update |= (PU_COMBINE); creature_ptr->window |= (PW_INVEN); creature_ptr->window |= (PW_EQUIP); @@ -1025,6 +872,7 @@ static void regenerate_captured_monsters(player_type *creature_ptr) } } + /*! * @brief 寿命つき光源の警告メッセージ処理 * @param creature_ptr プレーヤーへの参照ポインタ @@ -1033,33 +881,22 @@ static void regenerate_captured_monsters(player_type *creature_ptr) */ static void notice_lite_change(player_type *creature_ptr, object_type *o_ptr) { - /* Hack -- notice interesting fuel steps */ if ((o_ptr->xtra4 < 100) || (!(o_ptr->xtra4 % 100))) { creature_ptr->window |= (PW_EQUIP); } - /* Hack -- Special treatment when blind */ if (creature_ptr->blind) { - /* Hack -- save some light for later */ if (o_ptr->xtra4 == 0) o_ptr->xtra4++; } - - /* The light is now out */ else if (o_ptr->xtra4 == 0) { disturb(creature_ptr, FALSE, TRUE); msg_print(_("明かりが消えてしまった!", "Your light has gone out!")); - - /* Recalculate torch radius */ creature_ptr->update |= (PU_TORCH); - - /* Some ego light lose its effects without fuel */ creature_ptr->update |= (PU_BONUS); } - - /* The light is getting dim */ else if (o_ptr->name2 == EGO_LITE_LONG) { if ((o_ptr->xtra4 < 50) && (!(o_ptr->xtra4 % 5)) @@ -1069,8 +906,6 @@ static void notice_lite_change(player_type *creature_ptr, object_type *o_ptr) msg_print(_("明かりが微かになってきている。", "Your light is growing faint.")); } } - - /* The light is getting dim */ else if ((o_ptr->xtra4 < 100) && (!(o_ptr->xtra4 % 10))) { if (disturb_minor) disturb(creature_ptr, FALSE, TRUE); @@ -1086,26 +921,15 @@ static void notice_lite_change(player_type *creature_ptr, object_type *o_ptr) */ static void recharged_notice(player_type *owner_ptr, object_type *o_ptr) { - GAME_TEXT o_name[MAX_NLEN]; - - concptr s; - - /* No inscription */ if (!o_ptr->inscription) return; - /* Find a '!' */ - s = my_strchr(quark_str(o_ptr->inscription), '!'); - - /* Process notification request. */ + concptr s = my_strchr(quark_str(o_ptr->inscription), '!'); while (s) { - /* Find another '!' */ if (s[1] == '!') { - /* Describe (briefly) */ + GAME_TEXT o_name[MAX_NLEN]; object_desc(owner_ptr, o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY)); - - /* Notify the player */ #ifdef JP msg_format("%sは再充填された。", o_name); #else @@ -1114,30 +938,21 @@ static void recharged_notice(player_type *owner_ptr, object_type *o_ptr) else msg_format("Your %s is recharged.", o_name); #endif - disturb(owner_ptr, FALSE, FALSE); - - /* Done. */ return; } - /* Keep looking for '!'s */ s = my_strchr(s + 1, '!'); } } + /*! * @brief プレイヤーの歌に関する継続処理 * @return なし */ static void check_music(player_type *caster_ptr) { - const magic_type *s_ptr; - int spell; - MANA_POINT need_mana; - u32b need_mana_frac; - - /* Music singed by player */ if (caster_ptr->pclass != CLASS_BARD) return; if (!SINGING_SONG_EFFECT(caster_ptr) && !INTERUPTING_SONG_EFFECT(caster_ptr)) return; @@ -1147,15 +962,14 @@ static void check_music(player_type *caster_ptr) return; } - spell = SINGING_SONG_ID(caster_ptr); + int spell = SINGING_SONG_ID(caster_ptr); + const magic_type *s_ptr; s_ptr = &technic_info[REALM_MUSIC - MIN_TECHNIC][spell]; - need_mana = mod_need_mana(caster_ptr, s_ptr->smana, spell, REALM_MUSIC); - need_mana_frac = 0; + MANA_POINT need_mana = mod_need_mana(caster_ptr, s_ptr->smana, spell, REALM_MUSIC); + u32b need_mana_frac = 0; - /* Divide by 2 */ s64b_RSHIFT(need_mana, need_mana_frac, 1); - if (s64b_cmp(caster_ptr->csp, caster_ptr->csp_frac, need_mana, need_mana_frac) < 0) { stop_singing(caster_ptr); @@ -1177,6 +991,7 @@ static void check_music(player_type *caster_ptr) caster_ptr->window |= (PW_OVERHEAD | PW_DUNGEON); } } + if (caster_ptr->spell_exp[spell] < SPELL_EXP_BEGINNER) caster_ptr->spell_exp[spell] += 5; else if (caster_ptr->spell_exp[spell] < SPELL_EXP_SKILLED) @@ -1192,10 +1007,10 @@ static void check_music(player_type *caster_ptr) if (one_in_(5) && ((caster_ptr->current_floor_ptr->dun_level + 5) > caster_ptr->lev) && (caster_ptr->current_floor_ptr->dun_level > s_ptr->slevel)) caster_ptr->spell_exp[spell] += 1; } - /* Do any effects of continual song */ exe_spell(caster_ptr, REALM_MUSIC, spell, SPELL_CONT); } + /*! * @brief 現在呪いを保持している装備品を一つランダムに探し出す / Choose one of items that have cursed flag * @param flag 探し出したい呪いフラグ配列 @@ -1204,18 +1019,13 @@ static void check_music(player_type *caster_ptr) */ static object_type *choose_cursed_obj_name(player_type *player_ptr, BIT_FLAGS flag) { - int i; int choices[INVEN_TOTAL - INVEN_RARM]; int number = 0; - - /* Paranoia -- Player has no warning-item */ if (!(player_ptr->cursed & flag)) return NULL; - /* Search Inventry */ - for (i = INVEN_RARM; i < INVEN_TOTAL; i++) + for (int i = INVEN_RARM; i < INVEN_TOTAL; i++) { object_type *o_ptr = &player_ptr->inventory_list[i]; - if (o_ptr->curse_flags & flag) { choices[number] = i; @@ -1269,70 +1079,55 @@ static object_type *choose_cursed_obj_name(player_type *player_ptr, BIT_FLAGS fl } +/*! + * @brief 10ゲームターンが進行するごとにプレイヤーの空腹状態を飢餓方向に向かわせる + * @param creature_ptr プレーヤーへの参照ポインタ + * @return なし + */ static void process_world_aux_digestion(player_type *creature_ptr) { - if (!creature_ptr->phase_out) - { - /* Digest quickly when gorged */ - if (creature_ptr->food >= PY_FOOD_MAX) - { - /* Digest a lot of food */ - (void)set_food(creature_ptr, creature_ptr->food - 100); - } - - /* Digest normally -- Every 50 game turns */ - else if (!(current_world_ptr->game_turn % (TURNS_PER_TICK * 5))) - { - /* Basic digestion rate based on speed */ - int digestion = SPEED_TO_ENERGY(creature_ptr->pspeed); - - /* Regeneration takes more food */ - if (creature_ptr->regenerate) - digestion += 20; - if (creature_ptr->special_defense & (KAMAE_MASK | KATA_MASK)) - digestion += 20; - if (creature_ptr->cursed & TRC_FAST_DIGEST) - digestion += 30; - - /* Slow digestion takes less food */ - if (creature_ptr->slow_digest) - digestion -= 5; + if (creature_ptr->phase_out) return; - /* Minimal digestion */ - if (digestion < 1) digestion = 1; - /* Maximal digestion */ - if (digestion > 100) digestion = 100; + if (creature_ptr->food >= PY_FOOD_MAX) + { + (void)set_food(creature_ptr, creature_ptr->food - 100); + } + else if (!(current_world_ptr->game_turn % (TURNS_PER_TICK * 5))) + { + int digestion = SPEED_TO_ENERGY(creature_ptr->pspeed); + if (creature_ptr->regenerate) + digestion += 20; + if (creature_ptr->special_defense & (KAMAE_MASK | KATA_MASK)) + digestion += 20; + if (creature_ptr->cursed & TRC_FAST_DIGEST) + digestion += 30; - /* Digest some food */ - (void)set_food(creature_ptr, creature_ptr->food - digestion); - } + if (creature_ptr->slow_digest) + digestion -= 5; + if (digestion < 1) digestion = 1; + if (digestion > 100) digestion = 100; - /* Getting Faint */ - if ((creature_ptr->food < PY_FOOD_FAINT)) - { - /* Faint occasionally */ - if (!creature_ptr->paralyzed && (randint0(100) < 10)) - { - msg_print(_("あまりにも空腹で気絶してしまった。", "You faint from the lack of food.")); - disturb(creature_ptr, TRUE, TRUE); + (void)set_food(creature_ptr, creature_ptr->food - digestion); + } - /* Hack -- faint (bypass free action) */ - (void)set_paralyzed(creature_ptr, creature_ptr->paralyzed + 1 + randint0(5)); - } + if ((creature_ptr->food >= PY_FOOD_FAINT)) return; - /* Starve to death (slowly) */ - if (creature_ptr->food < PY_FOOD_STARVE) - { - /* Calculate damage */ - HIT_POINT dam = (PY_FOOD_STARVE - creature_ptr->food) / 10; + if (!creature_ptr->paralyzed && (randint0(100) < 10)) + { + msg_print(_("あまりにも空腹で気絶してしまった。", "You faint from the lack of food.")); + disturb(creature_ptr, TRUE, TRUE); + (void)set_paralyzed(creature_ptr, creature_ptr->paralyzed + 1 + randint0(5)); + } - if (!IS_INVULN(creature_ptr)) take_hit(creature_ptr, DAMAGE_LOSELIFE, dam, _("空腹", "starvation"), -1); - } - } + if (creature_ptr->food < PY_FOOD_STARVE) + { + HIT_POINT dam = (PY_FOOD_STARVE - creature_ptr->food) / 10; + if (!IS_INVULN(creature_ptr)) take_hit(creature_ptr, DAMAGE_LOSELIFE, dam, _("空腹", "starvation"), -1); } } + /*! * @brief 10ゲームターンが進行するごとにプレイヤーのHPとMPの増減処理を行う。 * / Handle timed damage and regeneration every 10 game turns @@ -1343,57 +1138,39 @@ static void process_world_aux_hp_and_sp(player_type *creature_ptr) feature_type *f_ptr = &f_info[creature_ptr->current_floor_ptr->grid_array[creature_ptr->y][creature_ptr->x].feat]; bool cave_no_regen = FALSE; int upkeep_factor = 0; - - /* Default regeneration */ int regen_amount = PY_REGEN_NORMAL; - - - /*** Damage over Time ***/ - - /* Take damage from poison */ if (creature_ptr->poisoned && !IS_INVULN(creature_ptr)) { take_hit(creature_ptr, DAMAGE_NOESCAPE, 1, _("毒", "poison"), -1); } - /* Take damage from cuts */ if (creature_ptr->cut && !IS_INVULN(creature_ptr)) { HIT_POINT dam; - - /* Mortal wound or Deep Gash */ if (creature_ptr->cut > 1000) { dam = 200; } - else if (creature_ptr->cut > 200) { dam = 80; } - - /* Severe cut */ else if (creature_ptr->cut > 100) { dam = 32; } - else if (creature_ptr->cut > 50) { dam = 16; } - else if (creature_ptr->cut > 25) { dam = 7; } - else if (creature_ptr->cut > 10) { dam = 3; } - - /* Other cuts */ else { dam = 1; @@ -1402,7 +1179,6 @@ static void process_world_aux_hp_and_sp(player_type *creature_ptr) take_hit(creature_ptr, DAMAGE_NOESCAPE, dam, _("致命傷", "a fatal wound"), -1); } - /* (Vampires) Take damage from sunlight */ if (PRACE_IS_(creature_ptr, RACE_VAMPIRE) || (creature_ptr->mimic_form == MIMIC_VAMPIRE)) { if (!creature_ptr->current_floor_ptr->dun_level && !creature_ptr->resist_lite && !IS_INVULN(creature_ptr) && is_daytime()) @@ -1421,14 +1197,10 @@ static void process_world_aux_hp_and_sp(player_type *creature_ptr) object_type *o_ptr = &creature_ptr->inventory_list[INVEN_LITE]; GAME_TEXT o_name[MAX_NLEN]; char ouch[MAX_NLEN + 40]; - - /* Get an object description */ object_desc(creature_ptr, o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY)); msg_format(_("%sがあなたのアンデッドの肉体を焼き焦がした!", "The %s scorches your undead flesh!"), o_name); cave_no_regen = TRUE; - - /* Get an object description */ object_desc(creature_ptr, o_name, o_ptr, OD_NAME_ONLY); sprintf(ouch, _("%sを装備したダメージ", "wielding %s"), o_name); @@ -1536,7 +1308,7 @@ static void process_world_aux_hp_and_sp(player_type *creature_ptr) if (creature_ptr->levitation) { - msg_print(_("電撃を受けた!", "The electric shocks you!")); + msg_print(_("電撃を受けた!", "The electricity shocks you!")); take_hit(creature_ptr, DAMAGE_NOESCAPE, damage, format(_("%sの上に浮遊したダメージ", "flying over %s"), f_name + f_info[get_feat_mimic(&creature_ptr->current_floor_ptr->grid_array[creature_ptr->y][creature_ptr->x])].name), -1); } @@ -1574,7 +1346,7 @@ static void process_world_aux_hp_and_sp(player_type *creature_ptr) if (creature_ptr->levitation) { - msg_print(_("酸が飛び散った!", "The acid melt you!")); + msg_print(_("酸が飛び散った!", "The acid melts you!")); take_hit(creature_ptr, DAMAGE_NOESCAPE, damage, format(_("%sの上に浮遊したダメージ", "flying over %s"), f_name + f_info[get_feat_mimic(&creature_ptr->current_floor_ptr->grid_array[creature_ptr->y][creature_ptr->x])].name), -1); } @@ -1700,13 +1472,8 @@ static void process_world_aux_hp_and_sp(player_type *creature_ptr) } } - - /*** handle regeneration ***/ - - /* Getting Weak */ if (creature_ptr->food < PY_FOOD_WEAK) { - /* Lower regeneration */ if (creature_ptr->food < PY_FOOD_STARVE) { regen_amount = 0; @@ -1721,14 +1488,12 @@ static void process_world_aux_hp_and_sp(player_type *creature_ptr) } } - /* Are we walking the pattern? */ if (pattern_effect(creature_ptr)) { cave_no_regen = TRUE; } else { - /* Regeneration ability */ if (creature_ptr->regenerate) { regen_amount = regen_amount * 2; @@ -1743,16 +1508,12 @@ static void process_world_aux_hp_and_sp(player_type *creature_ptr) } } - - /* Searching or Resting */ if ((creature_ptr->action == ACTION_SEARCH) || (creature_ptr->action == ACTION_REST)) { regen_amount = regen_amount * 2; } upkeep_factor = calculate_upkeep(creature_ptr); - - /* No regeneration while special action */ if ((creature_ptr->action == ACTION_LEARN) || (creature_ptr->action == ACTION_HAYAGAKE) || (creature_ptr->special_defense & KATA_KOUKIJIN)) @@ -1760,11 +1521,7 @@ static void process_world_aux_hp_and_sp(player_type *creature_ptr) upkeep_factor += 100; } - /* Regenerate the mana */ regenmana(creature_ptr, upkeep_factor, regen_amount); - - - /* Recharge magic eater's power */ if (creature_ptr->pclass == CLASS_MAGIC_EATER) { regenmagic(creature_ptr, regen_amount); @@ -1785,22 +1542,18 @@ static void process_world_aux_hp_and_sp(player_type *creature_ptr) } } - /* Poisoned or cut yields no healing */ if (creature_ptr->poisoned) regen_amount = 0; if (creature_ptr->cut) regen_amount = 0; - - /* Special floor -- Pattern, in a wall -- yields no healing */ if (cave_no_regen) regen_amount = 0; regen_amount = (regen_amount * creature_ptr->mutant_regenerate_mod) / 100; - - /* Regenerate Hit Points if needed */ if ((creature_ptr->chp < creature_ptr->mhp) && !cave_no_regen) { regenhp(creature_ptr, regen_amount); } } + /*! * @brief 10ゲームターンが進行するごとに魔法効果の残りターンを減らしていく処理 * / Handle timeout every 10 game turns @@ -1809,28 +1562,21 @@ static void process_world_aux_hp_and_sp(player_type *creature_ptr) static void process_world_aux_timeout(player_type *creature_ptr) { const int dec_count = (easy_band ? 2 : 1); - - /*** Timeout Various Things ***/ - - /* Mimic */ if (creature_ptr->tim_mimic) { (void)set_mimic(creature_ptr, creature_ptr->tim_mimic - 1, creature_ptr->mimic_form, TRUE); } - /* Hack -- Hallucinating */ if (creature_ptr->image) { (void)set_image(creature_ptr, creature_ptr->image - dec_count); } - /* Blindness */ if (creature_ptr->blind) { (void)set_blind(creature_ptr, creature_ptr->blind - dec_count); } - /* Times see-invisible */ if (creature_ptr->tim_invis) { (void)set_tim_invis(creature_ptr, creature_ptr->tim_invis - 1, TRUE); @@ -1841,235 +1587,193 @@ static void process_world_aux_timeout(player_type *creature_ptr) creature_ptr->suppress_multi_reward = FALSE; } - /* Timed esp */ if (creature_ptr->tim_esp) { (void)set_tim_esp(creature_ptr, creature_ptr->tim_esp - 1, TRUE); } - /* Timed temporary elemental brands. -LM- */ if (creature_ptr->ele_attack) { creature_ptr->ele_attack--; - - /* Clear all temporary elemental brands. */ if (!creature_ptr->ele_attack) set_ele_attack(creature_ptr, 0, 0); } - /* Timed temporary elemental immune. -LM- */ if (creature_ptr->ele_immune) { creature_ptr->ele_immune--; - - /* Clear all temporary elemental brands. */ if (!creature_ptr->ele_immune) set_ele_immune(creature_ptr, 0, 0); } - /* Timed infra-vision */ if (creature_ptr->tim_infra) { (void)set_tim_infra(creature_ptr, creature_ptr->tim_infra - 1, TRUE); } - /* Timed stealth */ if (creature_ptr->tim_stealth) { (void)set_tim_stealth(creature_ptr, creature_ptr->tim_stealth - 1, TRUE); } - /* Timed levitation */ if (creature_ptr->tim_levitation) { (void)set_tim_levitation(creature_ptr, creature_ptr->tim_levitation - 1, TRUE); } - /* Timed sh_touki */ if (creature_ptr->tim_sh_touki) { (void)set_tim_sh_touki(creature_ptr, creature_ptr->tim_sh_touki - 1, TRUE); } - /* Timed sh_fire */ if (creature_ptr->tim_sh_fire) { (void)set_tim_sh_fire(creature_ptr, creature_ptr->tim_sh_fire - 1, TRUE); } - /* Timed sh_holy */ if (creature_ptr->tim_sh_holy) { (void)set_tim_sh_holy(creature_ptr, creature_ptr->tim_sh_holy - 1, TRUE); } - /* Timed eyeeye */ if (creature_ptr->tim_eyeeye) { (void)set_tim_eyeeye(creature_ptr, creature_ptr->tim_eyeeye - 1, TRUE); } - /* Timed resist-magic */ if (creature_ptr->resist_magic) { (void)set_resist_magic(creature_ptr, creature_ptr->resist_magic - 1, TRUE); } - /* Timed regeneration */ if (creature_ptr->tim_regen) { (void)set_tim_regen(creature_ptr, creature_ptr->tim_regen - 1, TRUE); } - /* Timed resist nether */ if (creature_ptr->tim_res_nether) { (void)set_tim_res_nether(creature_ptr, creature_ptr->tim_res_nether - 1, TRUE); } - /* Timed resist time */ if (creature_ptr->tim_res_time) { (void)set_tim_res_time(creature_ptr, creature_ptr->tim_res_time - 1, TRUE); } - /* Timed reflect */ if (creature_ptr->tim_reflect) { (void)set_tim_reflect(creature_ptr, creature_ptr->tim_reflect - 1, TRUE); } - /* Multi-shadow */ if (creature_ptr->multishadow) { (void)set_multishadow(creature_ptr, creature_ptr->multishadow - 1, TRUE); } - /* Timed Robe of dust */ if (creature_ptr->dustrobe) { (void)set_dustrobe(creature_ptr, creature_ptr->dustrobe - 1, TRUE); } - /* Timed infra-vision */ if (creature_ptr->kabenuke) { (void)set_kabenuke(creature_ptr, creature_ptr->kabenuke - 1, TRUE); } - /* Paralysis */ if (creature_ptr->paralyzed) { (void)set_paralyzed(creature_ptr, creature_ptr->paralyzed - dec_count); } - /* Confusion */ if (creature_ptr->confused) { (void)set_confused(creature_ptr, creature_ptr->confused - dec_count); } - /* Afraid */ if (creature_ptr->afraid) { (void)set_afraid(creature_ptr, creature_ptr->afraid - dec_count); } - /* Fast */ if (creature_ptr->fast) { (void)set_fast(creature_ptr, creature_ptr->fast - 1, TRUE); } - /* Slow */ if (creature_ptr->slow) { (void)set_slow(creature_ptr, creature_ptr->slow - dec_count, TRUE); } - /* Protection from evil */ if (creature_ptr->protevil) { (void)set_protevil(creature_ptr, creature_ptr->protevil - 1, TRUE); } - /* Invulnerability */ if (creature_ptr->invuln) { (void)set_invuln(creature_ptr, creature_ptr->invuln - 1, TRUE); } - /* Wraith form */ if (creature_ptr->wraith_form) { (void)set_wraith_form(creature_ptr, creature_ptr->wraith_form - 1, TRUE); } - /* Heroism */ if (creature_ptr->hero) { (void)set_hero(creature_ptr, creature_ptr->hero - 1, TRUE); } - /* Super Heroism */ if (creature_ptr->shero) { (void)set_shero(creature_ptr, creature_ptr->shero - 1, TRUE); } - /* Blessed */ if (creature_ptr->blessed) { (void)set_blessed(creature_ptr, creature_ptr->blessed - 1, TRUE); } - /* Shield */ if (creature_ptr->shield) { (void)set_shield(creature_ptr, creature_ptr->shield - 1, TRUE); } - /* Tsubureru */ if (creature_ptr->tsubureru) { (void)set_tsubureru(creature_ptr, creature_ptr->tsubureru - 1, TRUE); } - /* Magicdef */ if (creature_ptr->magicdef) { (void)set_magicdef(creature_ptr, creature_ptr->magicdef - 1, TRUE); } - /* Tsuyoshi */ if (creature_ptr->tsuyoshi) { (void)set_tsuyoshi(creature_ptr, creature_ptr->tsuyoshi - 1, TRUE); } - /* Oppose Acid */ if (creature_ptr->oppose_acid) { (void)set_oppose_acid(creature_ptr, creature_ptr->oppose_acid - 1, TRUE); } - /* Oppose Lightning */ if (creature_ptr->oppose_elec) { (void)set_oppose_elec(creature_ptr, creature_ptr->oppose_elec - 1, TRUE); } - /* Oppose Fire */ if (creature_ptr->oppose_fire) { (void)set_oppose_fire(creature_ptr, creature_ptr->oppose_fire - 1, TRUE); } - /* Oppose Cold */ if (creature_ptr->oppose_cold) { (void)set_oppose_cold(creature_ptr, creature_ptr->oppose_cold - 1, TRUE); } - /* Oppose Poison */ if (creature_ptr->oppose_pois) { (void)set_oppose_pois(creature_ptr, creature_ptr->oppose_pois - 1, TRUE); @@ -2080,35 +1784,22 @@ static void process_world_aux_timeout(player_type *creature_ptr) (void)set_ultimate_res(creature_ptr, creature_ptr->ult_res - 1, TRUE); } - /*** Poison and Stun and Cut ***/ - - /* Poison */ if (creature_ptr->poisoned) { int adjust = adj_con_fix[creature_ptr->stat_ind[A_CON]] + 1; - - /* Apply some healing */ (void)set_poisoned(creature_ptr, creature_ptr->poisoned - adjust); } - /* Stun */ if (creature_ptr->stun) { int adjust = adj_con_fix[creature_ptr->stat_ind[A_CON]] + 1; - - /* Apply some healing */ (void)set_stun(creature_ptr, creature_ptr->stun - adjust); } - /* Cut */ if (creature_ptr->cut) { int adjust = adj_con_fix[creature_ptr->stat_ind[A_CON]] + 1; - - /* Hack -- Truly "mortal" wound */ if (creature_ptr->cut > 1000) adjust = 0; - - /* Apply some healing */ (void)set_cut(creature_ptr, creature_ptr->cut - adjust); } } @@ -2121,23 +1812,17 @@ static void process_world_aux_timeout(player_type *creature_ptr) */ static void process_world_aux_light(player_type *creature_ptr) { - /* Check for light being wielded */ object_type *o_ptr = &creature_ptr->inventory_list[INVEN_LITE]; - - /* Burn some fuel in the current lite */ if (o_ptr->tval == TV_LITE) { - /* Hack -- Use some fuel (except on artifacts) */ if (!(object_is_fixed_artifact(o_ptr) || o_ptr->sval == SV_LITE_FEANOR) && (o_ptr->xtra4 > 0)) { - /* Decrease life-span */ if (o_ptr->name2 == EGO_LITE_LONG) { if (current_world_ptr->game_turn % (TURNS_PER_TICK * 2)) o_ptr->xtra4--; } else o_ptr->xtra4--; - /* Notice interesting fuel steps */ notice_lite_change(creature_ptr, o_ptr); } } @@ -2151,13 +1836,8 @@ static void process_world_aux_light(player_type *creature_ptr) */ static void process_world_aux_mutation(player_type *creature_ptr) { - /* No mutation with effects */ if (!creature_ptr->muta2) return; - - /* No effect on monster arena */ if (creature_ptr->phase_out) return; - - /* No effect on the global map */ if (creature_ptr->wild_mode) return; if ((creature_ptr->muta2 & MUT2_BERS_RAGE) && one_in_(3000)) @@ -2211,10 +1891,10 @@ static void process_world_aux_mutation(player_type *creature_ptr) msg_print(NULL); if (one_in_(3)) lose_all_info(creature_ptr); else wiz_dark(creature_ptr); - (void)teleport_player_aux(creature_ptr, 100, TELEPORT_NONMAGICAL | TELEPORT_PASSIVE); + (void)teleport_player_aux(creature_ptr, 100, FALSE, TELEPORT_NONMAGICAL | TELEPORT_PASSIVE); wiz_dark(creature_ptr); msg_print(_("あなたは見知らぬ場所で目が醒めた...頭が痛い。", "You wake up somewhere with a sore head...")); - msg_print(_("何も覚えていない。どうやってここに来たかも分からない!", "You can't remember a thing, or how you got here!")); + msg_print(_("何も覚えていない。どうやってここに来たかも分からない!", "You can't remember a thing or how you got here!")); } else { @@ -2314,8 +1994,6 @@ static void process_world_aux_mutation(player_type *creature_ptr) if (!creature_ptr->current_floor_ptr->dun_level && creature_ptr->town_num) { int n; - - /* Pick a random shop (except home) */ do { n = randint0(MAX_STORES); @@ -2334,7 +2012,6 @@ static void process_world_aux_mutation(player_type *creature_ptr) msg_print(_("影につつまれた。", "A shadow passes over you.")); msg_print(NULL); - /* Absorb light from the current possition */ if ((creature_ptr->current_floor_ptr->grid_array[creature_ptr->y][creature_ptr->x].info & (CAVE_GLOW | CAVE_MNDK)) == CAVE_GLOW) { hp_player(creature_ptr, 10); @@ -2342,20 +2019,13 @@ static void process_world_aux_mutation(player_type *creature_ptr) o_ptr = &creature_ptr->inventory_list[INVEN_LITE]; - /* Absorb some fuel in the current lite */ if (o_ptr->tval == TV_LITE) { - /* Use some fuel (except on artifacts) */ if (!object_is_fixed_artifact(o_ptr) && (o_ptr->xtra4 > 0)) { - /* Heal the player a bit */ hp_player(creature_ptr, o_ptr->xtra4 / 20); - - /* Decrease life-span of lite */ o_ptr->xtra4 /= 2; msg_print(_("光源からエネルギーを吸収した!", "You absorb energy from your light!")); - - /* Notice interesting fuel steps */ notice_lite_change(creature_ptr, o_ptr); } } @@ -2390,11 +2060,13 @@ static void process_world_aux_mutation(player_type *creature_ptr) msg_print(NULL); fire_ball(creature_ptr, GF_CHAOS, 0, creature_ptr->lev, 8); } + if ((creature_ptr->muta2 & MUT2_NORMALITY) && one_in_(5000)) { if (!lose_mutation(creature_ptr, 0)) msg_print(_("奇妙なくらい普通になった気がする。", "You feel oddly normal.")); } + if ((creature_ptr->muta2 & MUT2_WRAITH) && !creature_ptr->anti_magic && one_in_(3000)) { disturb(creature_ptr, FALSE, TRUE); @@ -2403,10 +2075,12 @@ static void process_world_aux_mutation(player_type *creature_ptr) msg_print(NULL); set_wraith_form(creature_ptr, randint1(creature_ptr->lev / 2) + (creature_ptr->lev / 2), FALSE); } + if ((creature_ptr->muta2 & MUT2_POLY_WOUND) && one_in_(3000)) { do_poly_wounds(creature_ptr); } + if ((creature_ptr->muta2 & MUT2_WASTING) && one_in_(3000)) { int which_stat = randint0(A_MAX); @@ -2445,6 +2119,7 @@ static void process_world_aux_mutation(player_type *creature_ptr) (void)dec_stat(creature_ptr, which_stat, randint1(6) + 6, one_in_(3)); } } + if ((creature_ptr->muta2 & MUT2_ATT_DRAGON) && !creature_ptr->anti_magic && one_in_(3000)) { bool pet = one_in_(5); @@ -2459,6 +2134,7 @@ static void process_world_aux_mutation(player_type *creature_ptr) disturb(creature_ptr, FALSE, TRUE); } } + if ((creature_ptr->muta2 & MUT2_WEIRD_MIND) && !creature_ptr->anti_magic && one_in_(3000)) { if (creature_ptr->tim_esp > 0) @@ -2472,6 +2148,7 @@ static void process_world_aux_mutation(player_type *creature_ptr) set_tim_esp(creature_ptr, creature_ptr->lev, FALSE); } } + if ((creature_ptr->muta2 & MUT2_NAUSEA) && !creature_ptr->slow_digest && one_in_(9000)) { disturb(creature_ptr, FALSE, TRUE); @@ -2490,9 +2167,7 @@ static void process_world_aux_mutation(player_type *creature_ptr) if ((creature_ptr->muta2 & MUT2_WARNING) && one_in_(1000)) { int danger_amount = 0; - MONSTER_IDX monster; - - for (monster = 0; monster < creature_ptr->current_floor_ptr->m_max; monster++) + for (MONSTER_IDX monster = 0; monster < creature_ptr->current_floor_ptr->m_max; monster++) { monster_type *m_ptr = &creature_ptr->current_floor_ptr->m_list[monster]; monster_race *r_ptr = &r_info[m_ptr->r_idx]; @@ -2558,39 +2233,14 @@ static void process_world_aux_mutation(player_type *creature_ptr) if ((creature_ptr->muta2 & MUT2_DISARM) && one_in_(10000)) { - INVENTORY_IDX slot = 0; - object_type *o_ptr = NULL; - disturb(creature_ptr, FALSE, TRUE); msg_print(_("足がもつれて転んだ!", "You trip over your own feet!")); take_hit(creature_ptr, DAMAGE_NOESCAPE, randint1(creature_ptr->wt / 6), _("転倒", "tripping"), -1); - - msg_print(NULL); - if (has_melee_weapon(creature_ptr, INVEN_RARM)) - { - slot = INVEN_RARM; - o_ptr = &creature_ptr->inventory_list[INVEN_RARM]; - - if (has_melee_weapon(creature_ptr, INVEN_LARM) && one_in_(2)) - { - o_ptr = &creature_ptr->inventory_list[INVEN_LARM]; - slot = INVEN_LARM; - } - } - else if (has_melee_weapon(creature_ptr, INVEN_LARM)) - { - o_ptr = &creature_ptr->inventory_list[INVEN_LARM]; - slot = INVEN_LARM; - } - if (slot && !object_is_cursed(o_ptr)) - { - msg_print(_("武器を落としてしまった!", "You drop your weapon!")); - drop_from_inventory(creature_ptr, slot, 1); - } + drop_weapons(creature_ptr); } - } + /*! * @brief 10ゲームターンが進行するごとに装備効果の発動判定を行う処理 * / Handle curse effects once every 10 game turns @@ -2608,10 +2258,8 @@ static void process_world_aux_curse(player_type *creature_ptr) { GAME_TEXT o_name[MAX_NLEN]; object_type *o_ptr; - int i, i_keep = 0, count = 0; - - /* Scan the equipment with random teleport ability */ - for (i = INVEN_RARM; i < INVEN_TOTAL; i++) + int i_keep = 0, count = 0; + for (int i = INVEN_RARM; i < INVEN_TOTAL; i++) { BIT_FLAGS flgs[TR_FLAG_SIZE]; o_ptr = &creature_ptr->inventory_list[i]; @@ -2645,7 +2293,7 @@ static void process_world_aux_curse(player_type *creature_ptr) disturb(creature_ptr, TRUE, TRUE); } } - /* Make a chainsword noise */ + if ((creature_ptr->cursed & TRC_CHAINSWORD) && one_in_(CHAINSWORD_NOISE)) { char noise[1024]; @@ -2653,13 +2301,13 @@ static void process_world_aux_curse(player_type *creature_ptr) msg_print(noise); disturb(creature_ptr, FALSE, FALSE); } - /* TY Curse */ + if ((creature_ptr->cursed & TRC_TY_CURSE) && one_in_(TY_CURSE_CHANCE)) { int count = 0; (void)activate_ty_curse(creature_ptr, FALSE, &count); } - /* Handle experience draining */ + if (creature_ptr->prace != RACE_ANDROID && ((creature_ptr->cursed & TRC_DRAIN_EXP) && one_in_(4))) { creature_ptr->exp -= (creature_ptr->lev + 1) / 2; @@ -2668,38 +2316,28 @@ static void process_world_aux_curse(player_type *creature_ptr) if (creature_ptr->max_exp < 0) creature_ptr->max_exp = 0; check_experience(creature_ptr); } - /* Add light curse (Later) */ + if ((creature_ptr->cursed & TRC_ADD_L_CURSE) && one_in_(2000)) { - BIT_FLAGS new_curse; object_type *o_ptr; - o_ptr = choose_cursed_obj_name(creature_ptr, TRC_ADD_L_CURSE); - - new_curse = get_curse(0, o_ptr); + BIT_FLAGS new_curse = get_curse(0, o_ptr); if (!(o_ptr->curse_flags & new_curse)) { GAME_TEXT o_name[MAX_NLEN]; - object_desc(creature_ptr, o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY)); - o_ptr->curse_flags |= new_curse; msg_format(_("悪意に満ちた黒いオーラが%sをとりまいた...", "There is a malignant black aura surrounding your %s..."), o_name); - o_ptr->feeling = FEEL_NONE; - creature_ptr->update |= (PU_BONUS); } } - /* Add heavy curse (Later) */ + if ((creature_ptr->cursed & TRC_ADD_H_CURSE) && one_in_(2000)) { - BIT_FLAGS new_curse; object_type *o_ptr; - o_ptr = choose_cursed_obj_name(creature_ptr, TRC_ADD_H_CURSE); - - new_curse = get_curse(1, o_ptr); + BIT_FLAGS new_curse = get_curse(1, o_ptr); if (!(o_ptr->curse_flags & new_curse)) { GAME_TEXT o_name[MAX_NLEN]; @@ -2713,56 +2351,53 @@ static void process_world_aux_curse(player_type *creature_ptr) creature_ptr->update |= (PU_BONUS); } } - /* Call animal */ + if ((creature_ptr->cursed & TRC_CALL_ANIMAL) && one_in_(2500)) { if (summon_specific(creature_ptr, 0, creature_ptr->y, creature_ptr->x, creature_ptr->current_floor_ptr->dun_level, SUMMON_ANIMAL, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET))) { GAME_TEXT o_name[MAX_NLEN]; - object_desc(creature_ptr, o_name, choose_cursed_obj_name(creature_ptr, TRC_CALL_ANIMAL), (OD_OMIT_PREFIX | OD_NAME_ONLY)); msg_format(_("%sが動物を引き寄せた!", "Your %s has attracted an animal!"), o_name); disturb(creature_ptr, FALSE, TRUE); } } - /* Call demon */ + if ((creature_ptr->cursed & TRC_CALL_DEMON) && one_in_(1111)) { if (summon_specific(creature_ptr, 0, creature_ptr->y, creature_ptr->x, creature_ptr->current_floor_ptr->dun_level, SUMMON_DEMON, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET))) { GAME_TEXT o_name[MAX_NLEN]; - object_desc(creature_ptr, o_name, choose_cursed_obj_name(creature_ptr, TRC_CALL_DEMON), (OD_OMIT_PREFIX | OD_NAME_ONLY)); msg_format(_("%sが悪魔を引き寄せた!", "Your %s has attracted a demon!"), o_name); disturb(creature_ptr, FALSE, TRUE); } } - /* Call dragon */ + if ((creature_ptr->cursed & TRC_CALL_DRAGON) && one_in_(800)) { if (summon_specific(creature_ptr, 0, creature_ptr->y, creature_ptr->x, creature_ptr->current_floor_ptr->dun_level, SUMMON_DRAGON, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET))) { GAME_TEXT o_name[MAX_NLEN]; - object_desc(creature_ptr, o_name, choose_cursed_obj_name(creature_ptr, TRC_CALL_DRAGON), (OD_OMIT_PREFIX | OD_NAME_ONLY)); msg_format(_("%sがドラゴンを引き寄せた!", "Your %s has attracted an dragon!"), o_name); disturb(creature_ptr, FALSE, TRUE); } } - /* Call undead */ + if ((creature_ptr->cursed & TRC_CALL_UNDEAD) && one_in_(1111)) { if (summon_specific(creature_ptr, 0, creature_ptr->y, creature_ptr->x, creature_ptr->current_floor_ptr->dun_level, SUMMON_UNDEAD, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET))) { GAME_TEXT o_name[MAX_NLEN]; - object_desc(creature_ptr, o_name, choose_cursed_obj_name(creature_ptr, TRC_CALL_UNDEAD), (OD_OMIT_PREFIX | OD_NAME_ONLY)); msg_format(_("%sが死霊を引き寄せた!", "Your %s has attracted an undead!"), o_name); disturb(creature_ptr, FALSE, TRUE); } } + if ((creature_ptr->cursed & TRC_COWARDICE) && one_in_(1500)) { if (!creature_ptr->resist_fear) @@ -2772,28 +2407,24 @@ static void process_world_aux_curse(player_type *creature_ptr) set_afraid(creature_ptr, creature_ptr->afraid + 13 + randint1(26)); } } - /* Teleport player */ + if ((creature_ptr->cursed & TRC_TELEPORT) && one_in_(200) && !creature_ptr->anti_tele) { disturb(creature_ptr, FALSE, TRUE); - - /* Teleport player */ teleport_player(creature_ptr, 40, TELEPORT_PASSIVE); } - /* Handle HP draining */ + if ((creature_ptr->cursed & TRC_DRAIN_HP) && one_in_(666)) { GAME_TEXT o_name[MAX_NLEN]; - object_desc(creature_ptr, o_name, choose_cursed_obj_name(creature_ptr, TRC_DRAIN_HP), (OD_OMIT_PREFIX | OD_NAME_ONLY)); msg_format(_("%sはあなたの体力を吸収した!", "Your %s drains HP from you!"), o_name); take_hit(creature_ptr, DAMAGE_LOSELIFE, MIN(creature_ptr->lev * 2, 100), o_name, -1); } - /* Handle mana draining */ + if ((creature_ptr->cursed & TRC_DRAIN_MANA) && creature_ptr->csp && one_in_(666)) { GAME_TEXT o_name[MAX_NLEN]; - object_desc(creature_ptr, o_name, choose_cursed_obj_name(creature_ptr, TRC_DRAIN_MANA), (OD_OMIT_PREFIX | OD_NAME_ONLY)); msg_format(_("%sはあなたの魔力を吸収した!", "Your %s drains mana from you!"), o_name); creature_ptr->csp -= MIN(creature_ptr->lev, 50); @@ -2802,15 +2433,14 @@ static void process_world_aux_curse(player_type *creature_ptr) creature_ptr->csp = 0; creature_ptr->csp_frac = 0; } + creature_ptr->redraw |= PR_MANA; } } - /* Rarely, take damage from the Jewel of Judgement */ if (one_in_(999) && !creature_ptr->anti_magic) { object_type *o_ptr = &creature_ptr->inventory_list[INVEN_LITE]; - if (o_ptr->name1 == ART_JUDGE) { if (object_is_known(o_ptr)) @@ -2833,20 +2463,14 @@ static void process_world_aux_recharge(player_type *creature_ptr) int i; bool changed; - /* Process equipment */ for (changed = FALSE, i = INVEN_RARM; i < INVEN_TOTAL; i++) { - /* Get the object */ object_type *o_ptr = &creature_ptr->inventory_list[i]; if (!o_ptr->k_idx) continue; - /* Recharge activatable objects */ if (o_ptr->timeout > 0) { - /* Recharge */ o_ptr->timeout--; - - /* Notice changes */ if (!o_ptr->timeout) { recharged_notice(creature_ptr, o_ptr); @@ -2855,7 +2479,6 @@ static void process_world_aux_recharge(player_type *creature_ptr) } } - /* Notice changes */ if (changed) { creature_ptr->window |= (PW_EQUIP); @@ -2873,27 +2496,19 @@ static void process_world_aux_recharge(player_type *creature_ptr) object_kind *k_ptr = &k_info[o_ptr->k_idx]; if (!o_ptr->k_idx) continue; - /* Examine all charging rods or stacks of charging rods. */ if ((o_ptr->tval == TV_ROD) && (o_ptr->timeout)) { - /* Determine how many rods are charging. */ TIME_EFFECT temp = (o_ptr->timeout + (k_ptr->pval - 1)) / k_ptr->pval; if (temp > o_ptr->number) temp = (TIME_EFFECT)o_ptr->number; - /* Decrease timeout by that number. */ o_ptr->timeout -= temp; - - /* Boundary control. */ if (o_ptr->timeout < 0) o_ptr->timeout = 0; - /* Notice changes, provide message if object is inscribed. */ if (!(o_ptr->timeout)) { recharged_notice(creature_ptr, o_ptr); changed = TRUE; } - - /* One of the stack of rod is charged */ else if (o_ptr->timeout % k_ptr->pval) { changed = TRUE; @@ -2901,27 +2516,20 @@ static void process_world_aux_recharge(player_type *creature_ptr) } } - /* Notice changes */ if (changed) { creature_ptr->window |= (PW_INVEN); wild_regen = 20; } - /* Process objects on floor */ for (i = 1; i < creature_ptr->current_floor_ptr->o_max; i++) { object_type *o_ptr = &creature_ptr->current_floor_ptr->o_list[i]; - if (!OBJECT_IS_VALID(o_ptr)) continue; - /* Recharge rods on the ground. No messages. */ if ((o_ptr->tval == TV_ROD) && (o_ptr->timeout)) { - /* Charge it */ o_ptr->timeout -= (TIME_EFFECT)o_ptr->number; - - /* Boundary control. */ if (o_ptr->timeout < 0) o_ptr->timeout = 0; } } @@ -2936,7 +2544,6 @@ static void process_world_aux_recharge(player_type *creature_ptr) static void process_world_aux_movement(player_type *creature_ptr) { floor_type *floor_ptr = creature_ptr->current_floor_ptr; - /* Delayed Word-of-Recall */ if (creature_ptr->word_recall) { /* @@ -2947,50 +2554,34 @@ static void process_world_aux_movement(player_type *creature_ptr) if (autosave_l && (creature_ptr->word_recall == 1) && !creature_ptr->phase_out) do_cmd_save_game(creature_ptr, TRUE); - /* Count down towards recall */ creature_ptr->word_recall--; - creature_ptr->redraw |= (PR_STATUS); - - /* Activate the recall */ if (!creature_ptr->word_recall) { - /* Disturbing! */ disturb(creature_ptr, FALSE, TRUE); - - /* Determine the level */ if (floor_ptr->dun_level || creature_ptr->current_floor_ptr->inside_quest || creature_ptr->enter_dungeon) { msg_print(_("上に引っ張りあげられる感じがする!", "You feel yourself yanked upwards!")); - if (creature_ptr->dungeon_idx) creature_ptr->recall_dungeon = creature_ptr->dungeon_idx; if (record_stair) exe_write_diary(creature_ptr, DIARY_RECALL, floor_ptr->dun_level, NULL); floor_ptr->dun_level = 0; creature_ptr->dungeon_idx = 0; - leave_quest_check(creature_ptr); leave_tower_check(creature_ptr); - creature_ptr->current_floor_ptr->inside_quest = 0; - creature_ptr->leaving = TRUE; } else { msg_print(_("下に引きずり降ろされる感じがする!", "You feel yourself yanked downwards!")); - creature_ptr->dungeon_idx = creature_ptr->recall_dungeon; - if (record_stair) exe_write_diary(creature_ptr, DIARY_RECALL, floor_ptr->dun_level, NULL); - /* New depth */ floor_ptr->dun_level = max_dlv[creature_ptr->dungeon_idx]; if (floor_ptr->dun_level < 1) floor_ptr->dun_level = 1; - - /* Nightmare mode makes recall more dangerous */ if (ironman_nightmare && !randint0(666) && (creature_ptr->dungeon_idx == DUNGEON_ANGBAND)) { if (floor_ptr->dun_level < 50) @@ -3014,10 +2605,10 @@ static void process_world_aux_movement(player_type *creature_ptr) } else { - /* Save player position */ creature_ptr->oldpx = creature_ptr->x; creature_ptr->oldpy = creature_ptr->y; } + creature_ptr->wild_mode = FALSE; /* @@ -3029,13 +2620,9 @@ static void process_world_aux_movement(player_type *creature_ptr) if (creature_ptr->dungeon_idx == DUNGEON_ANGBAND) { - int i; - - for (i = MIN_RANDOM_QUEST; i < MAX_RANDOM_QUEST + 1; i++) + for (int i = MIN_RANDOM_QUEST; i < MAX_RANDOM_QUEST + 1; i++) { quest_type* const q_ptr = &quest[i]; - - if ((q_ptr->type == QUEST_TYPE_RANDOM) && (q_ptr->status == QUEST_STATUS_TAKEN) && (q_ptr->level < floor_ptr->dun_level)) @@ -3054,25 +2641,16 @@ static void process_world_aux_movement(player_type *creature_ptr) } } - - /* Delayed Alter reality */ if (creature_ptr->alter_reality) { if (autosave_l && (creature_ptr->alter_reality == 1) && !creature_ptr->phase_out) do_cmd_save_game(creature_ptr, TRUE); - /* Count down towards alter */ creature_ptr->alter_reality--; - creature_ptr->redraw |= (PR_STATUS); - - /* Activate the alter reality */ if (!creature_ptr->alter_reality) { - /* Disturbing! */ disturb(creature_ptr, FALSE, TRUE); - - /* Determine the level */ if (!quest_number(creature_ptr, floor_ptr->dun_level) && floor_ptr->dun_level) { msg_print(_("世界が変わった!", "The world changes!")); @@ -3094,6 +2672,7 @@ static void process_world_aux_movement(player_type *creature_ptr) } } + /*! * @brief 10ゲームターンが進行する毎にゲーム世界全体の処理を行う。 * / Handle certain things once every 10 game turns @@ -3101,15 +2680,12 @@ static void process_world_aux_movement(player_type *creature_ptr) */ static void process_world(player_type *player_ptr) { - int day, hour, min; - const s32b A_DAY = TURNS_PER_TICK * TOWN_DAWN; s32b prev_turn_in_today = ((current_world_ptr->game_turn - TURNS_PER_TICK) % A_DAY + A_DAY / 4) % A_DAY; int prev_min = (1440 * prev_turn_in_today / A_DAY) % 60; + int day, hour, min; extract_day_hour_min(player_ptr, &day, &hour, &min); - - /* Update dungeon feeling, and announce it if changed */ update_dungeon_feeling(player_ptr); /* 帰還無しモード時のレベルテレポバグ対策 / Fix for level teleport bugs on ironman_downward.*/ @@ -3124,29 +2700,26 @@ static void process_world(player_type *player_ptr) player_ptr->leaving = TRUE; } - /*** Check monster arena ***/ if (player_ptr->phase_out && !player_ptr->leaving) { - int i2, j2; int win_m_idx = 0; int number_mon = 0; - - /* Count all hostile monsters */ - for (i2 = 0; i2 < floor_ptr->width; ++i2) - for (j2 = 0; j2 < floor_ptr->height; j2++) + for (int i2 = 0; i2 < floor_ptr->width; ++i2) + { + for (int j2 = 0; j2 < floor_ptr->height; j2++) { grid_type *g_ptr = &floor_ptr->grid_array[j2][i2]; - if ((g_ptr->m_idx > 0) && (g_ptr->m_idx != player_ptr->riding)) { number_mon++; win_m_idx = g_ptr->m_idx; } } + } if (number_mon == 0) { - msg_print(_("相打ちに終わりました。", "They have kill each other at the same time.")); + msg_print(_("相打ちに終わりました。", "Nothing survived.")); msg_print(NULL); player_ptr->energy_need = 0; update_gambling_monsters(player_ptr); @@ -3155,11 +2728,9 @@ static void process_world(player_type *player_ptr) { GAME_TEXT m_name[MAX_NLEN]; monster_type *wm_ptr; - wm_ptr = &floor_ptr->m_list[win_m_idx]; - monster_desc(player_ptr, m_name, wm_ptr, 0); - msg_format(_("%sが勝利した!", "%s is winner!"), m_name); + msg_format(_("%sが勝利した!", "%s won!"), m_name); msg_print(NULL); if (win_m_idx == (sel_monster + 1)) @@ -3172,13 +2743,14 @@ static void process_world(player_type *player_ptr) { msg_print(_("残念でした。", "You lost gold.")); } + msg_print(NULL); player_ptr->energy_need = 0; update_gambling_monsters(player_ptr); } else if (current_world_ptr->game_turn - floor_ptr->generated_turn == 150 * TURNS_PER_TICK) { - msg_print(_("申し分けありませんが、この勝負は引き分けとさせていただきます。", "This battle have ended in a draw.")); + msg_print(_("申し分けありませんが、この勝負は引き分けとさせていただきます。", "This battle ended in a draw.")); player_ptr->au += kakekin; msg_print(NULL); player_ptr->energy_need = 0; @@ -3186,10 +2758,8 @@ static void process_world(player_type *player_ptr) } } - /* Every 10 game turns */ if (current_world_ptr->game_turn % TURNS_PER_TICK) return; - /*** Attempt timed autosave ***/ if (autosave_t && autosave_freq && !player_ptr->phase_out) { if (!(current_world_ptr->game_turn % ((s32b)autosave_freq * TURNS_PER_TICK))) @@ -3201,64 +2771,40 @@ static void process_world(player_type *player_ptr) msg_print(_("何かが聞こえた。", "You hear noise.")); } - /*** Handle the wilderness/town (sunshine) ***/ - - /* While in town/wilderness */ if (!floor_ptr->dun_level && !floor_ptr->inside_quest && !player_ptr->phase_out && !floor_ptr->inside_arena) { - /* Hack -- Daybreak/Nighfall in town */ if (!(current_world_ptr->game_turn % ((TURNS_PER_TICK * TOWN_DAWN) / 2))) { - bool dawn; - - /* Check for dawn */ - dawn = (!(current_world_ptr->game_turn % (TURNS_PER_TICK * TOWN_DAWN))); - + bool dawn = (!(current_world_ptr->game_turn % (TURNS_PER_TICK * TOWN_DAWN))); if (dawn) day_break(player_ptr); else night_falls(player_ptr); } } - - /* While in the dungeon (vanilla_town or lite_town mode only) */ else if ((vanilla_town || (lite_town && !floor_ptr->inside_quest && !player_ptr->phase_out && !floor_ptr->inside_arena)) && floor_ptr->dun_level) { - /*** Shuffle the Storekeepers ***/ - - /* Chance is only once a day (while in dungeon) */ if (!(current_world_ptr->game_turn % (TURNS_PER_TICK * STORE_TICKS))) { - /* Sometimes, shuffle the shop-keepers */ if (one_in_(STORE_SHUFFLE)) { int n; - FEAT_IDX i; - - /* Pick a random shop (except home and museum) */ do { n = randint0(MAX_STORES); } while ((n == STORE_HOME) || (n == STORE_MUSEUM)); - /* Check every feature */ - for (i = 1; i < max_f_idx; i++) + for (FEAT_IDX i = 1; i < max_f_idx; i++) { feature_type *f_ptr = &f_info[i]; - - /* Skip empty index */ if (!f_ptr->name) continue; - - /* Skip non-store features */ if (!have_flag(f_ptr->flags, FF_STORE)) continue; - /* Verify store type */ if (f_ptr->subtype == n) { - if (cheat_xtra) msg_format(_("%sの店主をシャッフルします。", "Shuffle a Shopkeeper of %s."), f_name + f_ptr->name); + if (cheat_xtra) + msg_format(_("%sの店主をシャッフルします。", "Shuffle a Shopkeeper of %s."), f_name + f_ptr->name); - /* Shuffle it */ store_shuffle(player_ptr, n); - break; } } @@ -3266,32 +2812,25 @@ static void process_world(player_type *player_ptr) } } - /*** Process the monsters ***/ - - /* Check for creature generation. */ if (one_in_(d_info[player_ptr->dungeon_idx].max_m_alloc_chance) && !floor_ptr->inside_arena && !floor_ptr->inside_quest && !player_ptr->phase_out) { - /* Make a new monster */ (void)alloc_monster(player_ptr, MAX_SIGHT + 5, 0); } - /* Hack -- Check for creature regeneration */ - if (!(current_world_ptr->game_turn % (TURNS_PER_TICK * 10)) && !player_ptr->phase_out) regenerate_monsters(player_ptr); - if (!(current_world_ptr->game_turn % (TURNS_PER_TICK * 3))) regenerate_captured_monsters(player_ptr); + if (!(current_world_ptr->game_turn % (TURNS_PER_TICK * 10)) && !player_ptr->phase_out) + regenerate_monsters(player_ptr); + if (!(current_world_ptr->game_turn % (TURNS_PER_TICK * 3))) + regenerate_captured_monsters(player_ptr); if (!player_ptr->leaving) { - int i; - - /* Hack -- Process the counters of monsters if needed */ - for (i = 0; i < MAX_MTIMED; i++) + for (int i = 0; i < MAX_MTIMED; i++) { if (floor_ptr->mproc_max[i] > 0) process_monsters_mtimed(player_ptr, i); } } - /* Date changes */ if (!hour && !min) { if (min != prev_min) @@ -3305,15 +2844,11 @@ static void process_world(player_type *player_ptr) * Nightmare mode activates the TY_CURSE at midnight * Require exact minute -- Don't activate multiple times in a minute */ - if (ironman_nightmare && (min != prev_min)) { - - /* Every 15 minutes after 11:00 pm */ if ((hour == 23) && !(min % 15)) { disturb(player_ptr, FALSE, TRUE); - switch (min / 15) { case 0: @@ -3334,21 +2869,15 @@ static void process_world(player_type *player_ptr) } } - /* TY_CURSE activates at midnight! */ if (!hour && !min) { - disturb(player_ptr, TRUE, TRUE); msg_print(_("遠くで鐘が何回も鳴り、死んだような静けさの中へ消えていった。", "A distant bell tolls many times, fading into an deathly silence.")); - if (player_ptr->wild_mode) { - /* Go into large wilderness view */ player_ptr->oldpy = randint1(MAX_HGT - 2); player_ptr->oldpx = randint1(MAX_WID - 2); change_wild_mode(player_ptr, TRUE); - - /* Give first move to monsters */ take_turn(player_ptr, 100); } @@ -3369,6 +2898,7 @@ static void process_world(player_type *player_ptr) process_world_aux_movement(player_ptr); } + /*! * @brief ウィザードモードへの導入処理 * / Verify use of "wizard" mode @@ -3377,39 +2907,30 @@ static void process_world(player_type *player_ptr) */ static bool enter_wizard_mode(player_type *player_ptr) { - /* Ask first time */ if (!current_world_ptr->noscore) { - /* Wizard mode is not permitted */ if (!allow_debug_opts || arg_wizard) { msg_print(_("ウィザードモードは許可されていません。 ", "Wizard mode is not permitted.")); return FALSE; } - /* Mention effects */ msg_print(_("ウィザードモードはデバッグと実験のためのモードです。 ", "Wizard mode is for debugging and experimenting.")); msg_print(_("一度ウィザードモードに入るとスコアは記録されません。", "The game will not be scored if you enter wizard mode.")); msg_print(NULL); - - /* Verify request */ if (!get_check(_("本当にウィザードモードに入りたいのですか? ", "Are you sure you want to enter wizard mode? "))) { return FALSE; } - exe_write_diary(player_ptr, DIARY_DESCRIPTION, 0, _("ウィザードモードに突入してスコアを残せなくなった。", "give up recording score to enter wizard mode.")); - /* Mark savefile */ + exe_write_diary(player_ptr, DIARY_DESCRIPTION, 0, _("ウィザードモードに突入してスコアを残せなくなった。", "gave up recording score to enter wizard mode.")); current_world_ptr->noscore |= 0x0002; } - /* Success */ return TRUE; } -#ifdef ALLOW_WIZARD - /*! * @brief デバッグコマンドへの導入処理 * / Verify use of "debug" commands @@ -3418,86 +2939,35 @@ static bool enter_wizard_mode(player_type *player_ptr) */ static bool enter_debug_mode(player_type *player_ptr) { - /* Ask first time */ if (!current_world_ptr->noscore) { - /* Debug mode is not permitted */ if (!allow_debug_opts) { msg_print(_("デバッグコマンドは許可されていません。 ", "Use of debug command is not permitted.")); return FALSE; } - /* Mention effects */ msg_print(_("デバッグ・コマンドはデバッグと実験のためのコマンドです。 ", "The debug commands are for debugging and experimenting.")); msg_print(_("デバッグ・コマンドを使うとスコアは記録されません。", "The game will not be scored if you use debug commands.")); - msg_print(NULL); - - /* Verify request */ if (!get_check(_("本当にデバッグ・コマンドを使いますか? ", "Are you sure you want to use debug commands? "))) { return FALSE; } - exe_write_diary(player_ptr, DIARY_DESCRIPTION, 0, _("デバッグモードに突入してスコアを残せなくなった。", "give up sending score to use debug commands.")); - /* Mark savefile */ + exe_write_diary(player_ptr, DIARY_DESCRIPTION, 0, _("デバッグモードに突入してスコアを残せなくなった。", "gave up sending score to use debug commands.")); current_world_ptr->noscore |= 0x0008; } - /* Success */ return TRUE; } /* + * todo これが多重インクルード問題の原因 (の1つ)かもしれない、wizard2.cに同名の関数が存在する * Hack -- Declare the Debug Routines */ extern void do_cmd_debug(player_type *creature_ptr); -#endif /* ALLOW_WIZARD */ - - -#ifdef ALLOW_BORG - -/*! - * @brief ボーグコマンドへの導入処理 - * / Verify use of "borg" commands - * @return 実際にボーグコマンドへ移行したらTRUEを返す。 - */ -static bool enter_borg_mode(void) -{ - /* Ask first time */ - if (!(current_world_ptr->noscore & 0x0010)) - { - /* Mention effects */ - msg_print(_("ボーグ・コマンドはデバッグと実験のためのコマンドです。 ", "The borg commands are for debugging and experimenting.")); - msg_print(_("ボーグ・コマンドを使うとスコアは記録されません。", "The game will not be scored if you use borg commands.")); - - msg_print(NULL); - - /* Verify request */ - if (!get_check(_("本当にボーグ・コマンドを使いますか? ", "Are you sure you want to use borg commands? "))) - { - return FALSE; - } - - exe_write_diary(p_ptr, NIKKI_BUNSHOU, 0, _("ボーグ・コマンドを使用してスコアを残せなくなった。", "give up recording score to use borg commands.")); - /* Mark savefile */ - current_world_ptr->noscore |= 0x0010; - } - - /* Success */ - return TRUE; -} - -/* - * Hack -- Declare the Ben Borg - */ -extern void do_cmd_borg(void); - -#endif /* ALLOW_BORG */ - - /*! * @brief プレイヤーから受けた入力コマンドの分岐処理。 * / Parse and execute the current command Give "Warning" on illegal commands. @@ -3507,35 +2977,28 @@ extern void do_cmd_borg(void); static void process_command(player_type *creature_ptr) { COMMAND_CODE old_now_message = now_message; - - /* Handle repeating the last command */ repeat_check(); - now_message = 0; - - /* Sniper */ if ((creature_ptr->pclass == CLASS_SNIPER) && (creature_ptr->concent)) creature_ptr->reset_concent = TRUE; - /* Parse the command */ floor_type *floor_ptr = creature_ptr->current_floor_ptr; switch (command_cmd) { - /* Ignore */ case ESCAPE: case ' ': { + /* Ignore */ break; } - - /* Ignore return */ case '\r': case '\n': { + /* todo 嘘。returnしていない + * Ignore return + */ break; } - - /*** Wizard Commands ***/ case KTRL('W'): { if (current_world_ptr->wizard) @@ -3553,11 +3016,6 @@ static void process_command(player_type *creature_ptr) break; } - - -#ifdef ALLOW_WIZARD - - /* Special "debug" commands */ case KTRL('A'): { if (enter_debug_mode(creature_ptr)) @@ -3566,74 +3024,36 @@ static void process_command(player_type *creature_ptr) } break; } - -#endif /* ALLOW_WIZARD */ - - -#ifdef ALLOW_BORG - - /* Special "borg" commands */ - case KTRL('Z'): - { - if (enter_borg_mode()) - { - if (!creature_ptr->wild_mode) do_cmd_borg(); - } - break; - } - -#endif /* ALLOW_BORG */ - - - - /*** Inventory Commands ***/ - - /* Wear/wield equipment */ case 'w': { if (!creature_ptr->wild_mode) do_cmd_wield(creature_ptr); break; } - - /* Take off equipment */ case 't': { if (!creature_ptr->wild_mode) do_cmd_takeoff(creature_ptr); break; } - - /* Drop an item */ case 'd': { if (!creature_ptr->wild_mode) do_cmd_drop(creature_ptr); break; } - - /* Destroy an item */ case 'k': { do_cmd_destroy(creature_ptr); break; } - - /* Equipment list */ case 'e': { do_cmd_equip(creature_ptr); break; } - - /* Inventory list */ case 'i': { do_cmd_inven(creature_ptr); break; } - - - /*** Various commands ***/ - - /* Identify an object */ case 'I': { do_cmd_observe(creature_ptr); @@ -3645,108 +3065,72 @@ static void process_command(player_type *creature_ptr) toggle_inventory_equipment(creature_ptr); break; } - - - /*** Standard "Movement" Commands ***/ - - /* Alter a grid */ case '+': { if (!creature_ptr->wild_mode) do_cmd_alter(creature_ptr); break; } - - /* Dig a tunnel */ case 'T': { if (!creature_ptr->wild_mode) do_cmd_tunnel(creature_ptr); break; } - - /* Move (usually pick up things) */ case ';': { do_cmd_walk(creature_ptr, FALSE); break; } - - /* Move (usually do not pick up) */ case '-': { do_cmd_walk(creature_ptr, TRUE); break; } - - - /*** Running, Resting, Searching, Staying */ - - /* Begin Running -- Arg is Max Distance */ case '.': { if (!creature_ptr->wild_mode) do_cmd_run(creature_ptr); break; } - - /* Stay still (usually pick things up) */ case ',': { do_cmd_stay(creature_ptr, always_pickup); break; } - - /* Stay still (usually do not pick up) */ case 'g': { do_cmd_stay(creature_ptr, !always_pickup); break; } - - /* Rest -- Arg is time */ case 'R': { do_cmd_rest(creature_ptr); break; } - - /* Search for traps/doors */ case 's': { do_cmd_search(creature_ptr); break; } - case 'S': { if (creature_ptr->action == ACTION_SEARCH) set_action(creature_ptr, ACTION_NONE); else set_action(creature_ptr, ACTION_SEARCH); break; } - - - /*** Stairs and Doors and Chests and Traps ***/ - - /* Enter store */ case SPECIAL_KEY_STORE: { do_cmd_store(creature_ptr); break; } - - /* Enter building -KMW- */ case SPECIAL_KEY_BUILDING: { do_cmd_bldg(creature_ptr); break; } - - /* Enter quest level -KMW- */ case SPECIAL_KEY_QUEST: { do_cmd_quest(creature_ptr); break; } - - /* Go up staircase */ case '<': { if (!creature_ptr->wild_mode && !floor_ptr->dun_level && !floor_ptr->inside_arena && !floor_ptr->inside_quest) @@ -3769,10 +3153,9 @@ static void process_command(player_type *creature_ptr) } else do_cmd_go_up(creature_ptr); + break; } - - /* Go down staircase */ case '>': { if (creature_ptr->wild_mode) @@ -3781,46 +3164,31 @@ static void process_command(player_type *creature_ptr) do_cmd_go_down(creature_ptr); break; } - - /* Open a door or chest */ case 'o': { do_cmd_open(creature_ptr); break; } - - /* Close a door */ case 'c': { do_cmd_close(creature_ptr); break; } - - /* Jam a door with spikes */ case 'j': { do_cmd_spike(creature_ptr); break; } - - /* Bash a door */ case 'B': { do_cmd_bash(creature_ptr); break; } - - /* Disarm a trap or chest */ case 'D': { do_cmd_disarm(creature_ptr); break; } - - - /*** Magic and Prayers ***/ - - /* Gain new spells/prayers */ case 'G': { if ((creature_ptr->pclass == CLASS_SORCERER) || (creature_ptr->pclass == CLASS_RED_MAGE)) @@ -3833,8 +3201,6 @@ static void process_command(player_type *creature_ptr) do_cmd_study(creature_ptr); break; } - - /* Browse a book */ case 'b': { if ((creature_ptr->pclass == CLASS_MINDCRAFTER) || @@ -3851,11 +3217,8 @@ static void process_command(player_type *creature_ptr) else do_cmd_browse(creature_ptr); break; } - - /* Cast a spell */ case 'm': { - /* -KMW- */ if (!creature_ptr->wild_mode) { if ((creature_ptr->pclass == CLASS_WARRIOR) || (creature_ptr->pclass == CLASS_ARCHER) || (creature_ptr->pclass == CLASS_CAVALRY)) @@ -3915,75 +3278,54 @@ static void process_command(player_type *creature_ptr) do_cmd_cast(creature_ptr); } } + break; } - - /* Issue a pet command */ case 'p': { do_cmd_pet(creature_ptr); break; } - - /*** Use various objects ***/ - - /* Inscribe an object */ case '{': { do_cmd_inscribe(creature_ptr); break; } - - /* Uninscribe an object */ case '}': { do_cmd_uninscribe(creature_ptr); break; } - - /* Activate an artifact */ case 'A': { do_cmd_activate(creature_ptr); break; } - - /* Eat some food */ case 'E': { do_cmd_eat_food(creature_ptr); break; } - - /* Fuel your lantern/torch */ case 'F': { do_cmd_refill(creature_ptr); break; } - - /* Fire an item */ case 'f': { do_cmd_fire(creature_ptr, SP_NONE); break; } - - /* Throw an item */ case 'v': { do_cmd_throw(creature_ptr, 1, FALSE, -1); break; } - - /* Aim a wand */ case 'a': { do_cmd_aim_wand(creature_ptr); break; } - - /* Zap a rod */ case 'z': { if (use_command && rogue_like_commands) @@ -3996,22 +3338,16 @@ static void process_command(player_type *creature_ptr) } break; } - - /* Quaff a potion */ case 'q': { do_cmd_quaff_potion(creature_ptr); break; } - - /* Read a scroll */ case 'r': { do_cmd_read_scroll(creature_ptr); break; } - - /* Use a staff */ case 'u': { if (use_command && !rogue_like_commands) @@ -4020,123 +3356,83 @@ static void process_command(player_type *creature_ptr) do_cmd_use_staff(creature_ptr); break; } - - /* Use racial power */ case 'U': { do_cmd_racial_power(creature_ptr); break; } - - - /*** Looking at Things (nearby or on map) ***/ - - /* Full dungeon map */ case 'M': { do_cmd_view_map(creature_ptr); break; } - - /* Locate player on map */ case 'L': { do_cmd_locate(creature_ptr); break; } - - /* Look around */ case 'l': { do_cmd_look(creature_ptr); break; } - - /* Target monster or location */ case '*': { do_cmd_target(creature_ptr); break; } - - - - /*** Help and Such ***/ - - /* Help */ case '?': { do_cmd_help(creature_ptr); break; } - - /* Identify symbol */ case '/': { do_cmd_query_symbol(creature_ptr); break; } - - /* Character description */ case 'C': { do_cmd_player_status(creature_ptr); break; } - - - /*** System Commands ***/ - - /* Hack -- User interface */ case '!': { (void)Term_user(0); break; } - - /* Single line from a pref file */ case '"': { do_cmd_pref(creature_ptr); break; } - case '$': { do_cmd_reload_autopick(creature_ptr); break; } - case '_': { do_cmd_edit_autopick(creature_ptr); break; } - - /* Interact with macros */ case '@': { do_cmd_macros(creature_ptr); break; } - - /* Interact with visuals */ case '%': { do_cmd_visuals(creature_ptr); do_cmd_redraw(creature_ptr); break; } - - /* Interact with colors */ case '&': { do_cmd_colors(creature_ptr); do_cmd_redraw(creature_ptr); break; } - - /* Interact with options */ case '=': { do_cmd_options(); @@ -4144,133 +3440,93 @@ static void process_command(player_type *creature_ptr) do_cmd_redraw(creature_ptr); break; } - - /*** Misc Commands ***/ - - /* Take notes */ case ':': { do_cmd_note(); break; } - - /* Version info */ case 'V': { do_cmd_version(); break; } - - /* Repeat level feeling */ case KTRL('F'): { do_cmd_feeling(creature_ptr); break; } - - /* Show previous message */ case KTRL('O'): { do_cmd_message_one(); break; } - - /* Show previous messages */ case KTRL('P'): { do_cmd_messages(old_now_message); break; } - - /* Show quest status -KMW- */ case KTRL('Q'): { do_cmd_checkquest(creature_ptr); break; } - - /* Redraw the screen */ case KTRL('R'): { now_message = old_now_message; do_cmd_redraw(creature_ptr); break; } - -#ifndef VERIFY_SAVEFILE - - /* Hack -- Save and don't quit */ case KTRL('S'): { do_cmd_save_game(creature_ptr, FALSE); break; } - -#endif /* VERIFY_SAVEFILE */ - case KTRL('T'): { do_cmd_time(creature_ptr); break; } - - /* Save and quit */ case KTRL('X'): case SPECIAL_KEY_QUIT: { do_cmd_save_and_exit(creature_ptr); break; } - - /* Quit (commit suicide) */ case 'Q': { do_cmd_suicide(creature_ptr); break; } - case '|': { do_cmd_diary(creature_ptr); break; } - - /* Check artifacts, uniques, objects */ case '~': { do_cmd_knowledge(creature_ptr); break; } - - /* Load "screen dump" */ case '(': { do_cmd_load_screen(); break; } - - /* Save "screen dump" */ case ')': { do_cmd_save_screen(creature_ptr); break; } - - /* Record/stop "Movie" */ case ']': { prepare_movie_hooks(); break; } - - /* Make random artifact list */ case KTRL('V'): { spoil_random_artifact(creature_ptr, "randifact.txt"); break; } - -#ifdef TRAVEL case '`': { if (!creature_ptr->wild_mode) do_cmd_travel(creature_ptr); @@ -4280,9 +3536,6 @@ static void process_command(player_type *creature_ptr) } break; } -#endif - - /* Hack -- Unknown command */ default: { if (flush_failure) flush(); @@ -4301,10 +3554,12 @@ static void process_command(player_type *creature_ptr) break; } } + if (!creature_ptr->energy_use && !now_message) now_message = old_now_message; } + /*! * @brief アイテムの所持種類数が超えた場合にアイテムを床に落とす処理 / Hack -- Pack Overflow * @return なし @@ -4315,58 +3570,46 @@ static void pack_overflow(player_type *owner_ptr) GAME_TEXT o_name[MAX_NLEN]; object_type *o_ptr; - - /* Is auto-destroy done? */ update_creature(owner_ptr); if (!owner_ptr->inventory_list[INVEN_PACK].k_idx) return; - /* Access the slot to be dropped */ o_ptr = &owner_ptr->inventory_list[INVEN_PACK]; - disturb(owner_ptr, FALSE, TRUE); - - /* Warning */ msg_print(_("ザックからアイテムがあふれた!", "Your pack overflows!")); - object_desc(owner_ptr, o_name, o_ptr, 0); + object_desc(owner_ptr, o_name, o_ptr, 0); msg_format(_("%s(%c)を落とした。", "You drop %s (%c)."), o_name, index_to_label(INVEN_PACK)); - - /* Drop it (carefully) near the player */ (void)drop_near(owner_ptr, o_ptr, 0, owner_ptr->y, owner_ptr->x); vary_item(owner_ptr, INVEN_PACK, -255); handle_stuff(owner_ptr); } + /*! * @brief プレイヤーの行動エネルギーが充填される(=プレイヤーのターンが回る)毎に行われる処理 / process the effects per 100 energy at player speed. * @return なし */ static void process_upkeep_with_speed(player_type *creature_ptr) { - /* Give the player some energy */ if (!load && creature_ptr->enchant_energy_need > 0 && !creature_ptr->leaving) { creature_ptr->enchant_energy_need -= SPEED_TO_ENERGY(creature_ptr->pspeed); } - /* No turn yet */ if (creature_ptr->enchant_energy_need > 0) return; while (creature_ptr->enchant_energy_need <= 0) { - /* Handle the player song */ if (!load) check_music(creature_ptr); - - /* Hex - Handle the hex spells */ if (!load) check_hex(creature_ptr); if (!load) revenge_spell(creature_ptr); - /* There is some randomness of needed energy */ creature_ptr->enchant_energy_need += ENERGY_NEED(); } } + static void process_fishing(player_type *creature_ptr) { Term_xtra(TERM_XTRA_DELAY, 10); @@ -4375,7 +3618,7 @@ static void process_fishing(player_type *creature_ptr) MONRACE_IDX r_idx; bool success = FALSE; get_mon_num_prep(creature_ptr, monster_is_fishing_target, NULL); - r_idx = get_mon_num(creature_ptr, creature_ptr->current_floor_ptr->dun_level ? creature_ptr->current_floor_ptr->dun_level : wilderness[creature_ptr->wilderness_y][creature_ptr->wilderness_x].level); + r_idx = get_mon_num(creature_ptr, creature_ptr->current_floor_ptr->dun_level ? creature_ptr->current_floor_ptr->dun_level : wilderness[creature_ptr->wilderness_y][creature_ptr->wilderness_x].level, 0); msg_print(NULL); if (r_idx && one_in_(2)) { @@ -4390,14 +3633,17 @@ static void process_fishing(player_type *creature_ptr) success = TRUE; } } + if (!success) { msg_print(_("餌だけ食われてしまった!くっそ~!", "Damn! The fish stole your bait!")); } + disturb(creature_ptr, FALSE, TRUE); } } + /*! * @brief プレイヤーの行動処理 / Process the player * @return なし @@ -4408,10 +3654,6 @@ static void process_fishing(player_type *creature_ptr) */ static void process_player(player_type *creature_ptr) { - MONSTER_IDX m_idx; - - /*** Apply energy ***/ - if (creature_ptr->hack_mutation) { msg_print(_("何か変わった気がする!", "You feel different!")); @@ -4429,10 +3671,9 @@ static void process_player(player_type *creature_ptr) if (creature_ptr->phase_out) { - for (m_idx = 1; m_idx < creature_ptr->current_floor_ptr->m_max; m_idx++) + for (MONSTER_IDX m_idx = 1; m_idx < creature_ptr->current_floor_ptr->m_max; m_idx++) { monster_type *m_ptr = &creature_ptr->current_floor_ptr->m_list[m_idx]; - if (!monster_is_valid(m_ptr)) continue; m_ptr->mflag2 |= (MFLAG2_MARK | MFLAG2_SHOW); @@ -4441,37 +3682,26 @@ static void process_player(player_type *creature_ptr) print_time(creature_ptr); } - - /* Give the player some energy */ else if (!(load && creature_ptr->energy_need <= 0)) { creature_ptr->energy_need -= SPEED_TO_ENERGY(creature_ptr->pspeed); } - /* No turn yet */ if (creature_ptr->energy_need > 0) return; if (!command_rep) print_time(creature_ptr); - /*** Check for interupts ***/ - - /* Complete resting */ if (creature_ptr->resting < 0) { - /* Basic resting */ if (creature_ptr->resting == COMMAND_ARG_REST_FULL_HEALING) { - /* Stop resting */ if ((creature_ptr->chp == creature_ptr->mhp) && (creature_ptr->csp >= creature_ptr->msp)) { set_action(creature_ptr, ACTION_NONE); } } - - /* Complete resting */ else if (creature_ptr->resting == COMMAND_ARG_REST_UNTIL_DONE) { - /* Stop resting */ if ((creature_ptr->chp == creature_ptr->mhp) && (creature_ptr->csp >= creature_ptr->msp) && !creature_ptr->blind && !creature_ptr->confused && @@ -4488,23 +3718,15 @@ static void process_player(player_type *creature_ptr) if (creature_ptr->action == ACTION_FISH) process_fishing(creature_ptr); - /* Handle "abort" */ if (check_abort) { - /* Check for "player abort" (semi-efficiently for resting) */ if (creature_ptr->running || travel.run || command_rep || (creature_ptr->action == ACTION_REST) || (creature_ptr->action == ACTION_FISH)) { - /* Do not wait */ inkey_scan = TRUE; - - /* Check for a key */ if (inkey()) { - flush(); /* Flush input */ - + flush(); disturb(creature_ptr, FALSE, TRUE); - - /* Hack -- Show a Message */ msg_print(_("中断しました。", "Canceled.")); } } @@ -4514,12 +3736,9 @@ static void process_player(player_type *creature_ptr) { monster_type *m_ptr = &creature_ptr->current_floor_ptr->m_list[creature_ptr->riding]; monster_race *r_ptr = &r_info[m_ptr->r_idx]; - if (MON_CSLEEP(m_ptr)) { GAME_TEXT m_name[MAX_NLEN]; - - /* Recover fully */ (void)set_monster_csleep(creature_ptr, creature_ptr->riding, 0); monster_desc(creature_ptr, m_name, m_ptr, 0); msg_format(_("%^sを起こした。", "You have woken %s up."), m_name); @@ -4527,7 +3746,6 @@ static void process_player(player_type *creature_ptr) if (MON_STUNNED(m_ptr)) { - /* Hack -- Recover from stun */ if (set_monster_stunned(creature_ptr, creature_ptr->riding, (randint0(r_ptr->level) < creature_ptr->skill_exp[GINOU_RIDING]) ? 0 : (MON_STUNNED(m_ptr) - 1))) { @@ -4539,7 +3757,6 @@ static void process_player(player_type *creature_ptr) if (MON_CONFUSED(m_ptr)) { - /* Hack -- Recover from confusion */ if (set_monster_confused(creature_ptr, creature_ptr->riding, (randint0(r_ptr->level) < creature_ptr->skill_exp[GINOU_RIDING]) ? 0 : (MON_CONFUSED(m_ptr) - 1))) { @@ -4551,7 +3768,6 @@ static void process_player(player_type *creature_ptr) if (MON_MONFEAR(m_ptr)) { - /* Hack -- Recover from fear */ if (set_monster_monfear(creature_ptr, creature_ptr->riding, (randint0(r_ptr->level) < creature_ptr->skill_exp[GINOU_RIDING]) ? 0 : (MON_MONFEAR(m_ptr) - 1))) { @@ -4565,38 +3781,34 @@ static void process_player(player_type *creature_ptr) } load = FALSE; - - /* Fast */ if (creature_ptr->lightspeed) { (void)set_lightspeed(creature_ptr, creature_ptr->lightspeed - 1, TRUE); } + if ((creature_ptr->pclass == CLASS_FORCETRAINER) && P_PTR_KI) { if (P_PTR_KI < 40) P_PTR_KI = 0; else P_PTR_KI -= 40; creature_ptr->update |= (PU_BONUS); } + if (creature_ptr->action == ACTION_LEARN) { s32b cost = 0L; u32b cost_frac = (creature_ptr->msp + 30L) * 256L; - - /* Convert the unit (1/2^16) to (1/2^32) */ s64b_LSHIFT(cost, cost_frac, 16); - if (s64b_cmp(creature_ptr->csp, creature_ptr->csp_frac, cost, cost_frac) < 0) { - /* Mana run out */ creature_ptr->csp = 0; creature_ptr->csp_frac = 0; set_action(creature_ptr, ACTION_NONE); } else { - /* Reduce mana */ s64b_sub(&(creature_ptr->csp), &(creature_ptr->csp_frac), cost, cost_frac); } + creature_ptr->redraw |= PR_MANA; } @@ -4617,8 +3829,6 @@ static void process_player(player_type *creature_ptr) } /*** Handle actual user input ***/ - - /* Repeat until out of energy */ while (creature_ptr->energy_need <= 0) { creature_ptr->window |= PW_PLAYER; @@ -4627,225 +3837,144 @@ static void process_player(player_type *creature_ptr) creature_ptr->now_damaged = FALSE; handle_stuff(creature_ptr); - - /* Place the cursor on the player */ move_cursor_relative(creature_ptr->y, creature_ptr->x); - - /* Refresh (optional) */ if (fresh_before) Term_fresh(); - /* Hack -- Pack Overflow */ pack_overflow(creature_ptr); - - /* Hack -- cancel "lurking browse mode" */ if (!command_new) command_see = FALSE; - /* Assume free turn */ free_turn(creature_ptr); - if (creature_ptr->phase_out) { - /* Place the cursor on the player */ move_cursor_relative(creature_ptr->y, creature_ptr->x); - command_cmd = SPECIAL_KEY_BUILDING; - - /* Process the command */ process_command(creature_ptr); } - - /* Paralyzed or Knocked Out */ else if (creature_ptr->paralyzed || (creature_ptr->stun >= 100)) { take_turn(creature_ptr, 100); } - - /* Resting */ else if (creature_ptr->action == ACTION_REST) { - /* Timed rest */ if (creature_ptr->resting > 0) { - /* Reduce rest count */ creature_ptr->resting--; - if (!creature_ptr->resting) set_action(creature_ptr, ACTION_NONE); creature_ptr->redraw |= (PR_STATE); } take_turn(creature_ptr, 100); } - - /* Fishing */ else if (creature_ptr->action == ACTION_FISH) { take_turn(creature_ptr, 100); } - - /* Running */ else if (creature_ptr->running) { - /* Take a step */ run_step(creature_ptr, 0); } - -#ifdef TRAVEL - /* Traveling */ else if (travel.run) { - /* Take a step */ travel_step(creature_ptr); } -#endif - - /* Repeated command */ else if (command_rep) { - /* Count this execution */ command_rep--; - creature_ptr->redraw |= (PR_STATE); handle_stuff(creature_ptr); - - /* Hack -- Assume messages were seen */ msg_flag = FALSE; - - /* Clear the top line */ prt("", 0, 0); - - /* Process the command */ process_command(creature_ptr); } - - /* Normal command */ else { - /* Place the cursor on the player */ move_cursor_relative(creature_ptr->y, creature_ptr->x); - can_save = TRUE; - /* Get a command (normal) */ request_command(creature_ptr, FALSE); can_save = FALSE; - - /* Process the command */ process_command(creature_ptr); } - /* Hack -- Pack Overflow */ pack_overflow(creature_ptr); - - /*** Clean up ***/ - - /* Significant */ if (creature_ptr->energy_use) { - /* Use some energy */ if (creature_ptr->timewalk || creature_ptr->energy_use > 400) { - /* The Randomness is irrelevant */ creature_ptr->energy_need += creature_ptr->energy_use * TURNS_PER_TICK / 10; } else { - /* There is some randomness of needed energy */ creature_ptr->energy_need += (s16b)((s32b)creature_ptr->energy_use * ENERGY_NEED() / 100L); } - /* Hack -- constant hallucination */ if (creature_ptr->image) creature_ptr->redraw |= (PR_MAP); - /* Shimmer multi-hued monsters */ - for (m_idx = 1; m_idx < creature_ptr->current_floor_ptr->m_max; m_idx++) + for (MONSTER_IDX m_idx = 1; m_idx < creature_ptr->current_floor_ptr->m_max; m_idx++) { monster_type *m_ptr; monster_race *r_ptr; - m_ptr = &creature_ptr->current_floor_ptr->m_list[m_idx]; if (!monster_is_valid(m_ptr)) continue; - - /* Skip unseen monsters */ if (!m_ptr->ml) continue; - /* Access the monster race */ r_ptr = &r_info[m_ptr->ap_r_idx]; - - /* Skip non-multi-hued monsters */ if (!(r_ptr->flags1 & (RF1_ATTR_MULTI | RF1_SHAPECHANGER))) continue; - /* Redraw regardless */ lite_spot(creature_ptr, m_ptr->fy, m_ptr->fx); } - - /* Handle monster detection */ if (repair_monsters) { - /* Reset the flag */ repair_monsters = FALSE; - - /* Rotate detection flags */ - for (m_idx = 1; m_idx < creature_ptr->current_floor_ptr->m_max; m_idx++) + for (MONSTER_IDX m_idx = 1; m_idx < creature_ptr->current_floor_ptr->m_max; m_idx++) { monster_type *m_ptr; m_ptr = &creature_ptr->current_floor_ptr->m_list[m_idx]; if (!monster_is_valid(m_ptr)) continue; - /* Nice monsters get mean */ if (m_ptr->mflag & MFLAG_NICE) { - /* Nice monsters get mean */ m_ptr->mflag &= ~(MFLAG_NICE); } - /* Handle memorized monsters */ if (m_ptr->mflag2 & MFLAG2_MARK) { - /* Maintain detection */ if (m_ptr->mflag2 & MFLAG2_SHOW) { - /* Forget flag */ m_ptr->mflag2 &= ~(MFLAG2_SHOW); - - /* Still need repairs */ repair_monsters = TRUE; } - - /* Remove detection */ else { - /* Forget flag */ m_ptr->mflag2 &= ~(MFLAG2_MARK); - - /* Assume invisible */ m_ptr->ml = FALSE; update_monster(creature_ptr, m_idx, FALSE); - if (creature_ptr->health_who == m_idx) creature_ptr->redraw |= (PR_HEALTH); if (creature_ptr->riding == m_idx) creature_ptr->redraw |= (PR_UHEALTH); - /* Redraw regardless */ lite_spot(creature_ptr, m_ptr->fy, m_ptr->fx); } } } } + if (creature_ptr->pclass == CLASS_IMITATOR) { - int j; if (creature_ptr->mane_num > (creature_ptr->lev > 44 ? 3 : creature_ptr->lev > 29 ? 2 : 1)) { creature_ptr->mane_num--; - for (j = 0; j < creature_ptr->mane_num; j++) + for (int j = 0; j < creature_ptr->mane_num; j++) { creature_ptr->mane_spell[j] = creature_ptr->mane_spell[j + 1]; creature_ptr->mane_dam[j] = creature_ptr->mane_dam[j + 1]; } } + creature_ptr->new_mane = FALSE; creature_ptr->redraw |= (PR_IMITATION); } + if (creature_ptr->action == ACTION_LEARN) { creature_ptr->new_mane = FALSE; @@ -4868,24 +3997,22 @@ static void process_player(player_type *creature_ptr) } } - /* Hack -- notice death */ if (!creature_ptr->playing || creature_ptr->is_dead) { creature_ptr->timewalk = FALSE; break; } - /* Sniper */ - if (creature_ptr->energy_use && creature_ptr->reset_concent) reset_concentration(creature_ptr, TRUE); + if (creature_ptr->energy_use && creature_ptr->reset_concent) + reset_concentration(creature_ptr, TRUE); - /* Handle "leaving" */ if (creature_ptr->leaving) break; } - /* Update scent trail */ update_smell(creature_ptr->current_floor_ptr, creature_ptr); } + /*! * @brief 現在プレイヤーがいるダンジョンの全体処理 / Interact with the current dungeon level. * @return なし @@ -4901,57 +4028,36 @@ static void process_player(player_type *creature_ptr) */ static void dungeon(player_type *player_ptr, bool load_game) { - int quest_num = 0; - - /* Set the base level */ floor_type *floor_ptr = player_ptr->current_floor_ptr; floor_ptr->base_level = floor_ptr->dun_level; - - /* Reset various flags */ current_world_ptr->is_loading_now = FALSE; - - /* Not leaving */ player_ptr->leaving = FALSE; - /* Reset the "command" vars */ command_cmd = 0; command_rep = 0; command_arg = 0; command_dir = 0; - /* Cancel the target */ target_who = 0; player_ptr->pet_t_m_idx = 0; player_ptr->riding_t_m_idx = 0; player_ptr->ambush_flag = FALSE; - health_track(player_ptr, 0); - - /* Check visual effects */ repair_monsters = TRUE; repair_objects = TRUE; - disturb(player_ptr, TRUE, TRUE); - - /* Get index of current quest (if any) */ - quest_num = quest_number(player_ptr, floor_ptr->dun_level); - - /* Inside a quest? */ + int quest_num = quest_num = quest_number(player_ptr, floor_ptr->dun_level); if (quest_num) { - /* Mark the quest monster */ r_info[quest[quest_num].r_idx].flags1 |= RF1_QUESTOR; } - /* Track maximum player level */ if (player_ptr->max_plv < player_ptr->lev) { player_ptr->max_plv = player_ptr->lev; } - - /* Track maximum dungeon level (if not in quest -KMW-) */ if ((max_dlv[player_ptr->dungeon_idx] < floor_ptr->dun_level) && !floor_ptr->inside_quest) { max_dlv[player_ptr->dungeon_idx] = floor_ptr->dun_level; @@ -4959,28 +4065,17 @@ static void dungeon(player_type *player_ptr, bool load_game) } (void)calculate_upkeep(player_ptr); - - /* Validate the panel */ panel_bounds_center(); - - /* Verify the panel */ verify_panel(player_ptr); - msg_erase(); - - /* Enter "xtra" mode */ current_world_ptr->character_xtra = TRUE; - player_ptr->window |= (PW_INVEN | PW_EQUIP | PW_SPELL | PW_PLAYER | PW_MONSTER | PW_OVERHEAD | PW_DUNGEON); player_ptr->redraw |= (PR_WIPE | PR_BASIC | PR_EXTRA | PR_EQUIPPY | PR_MAP); player_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS | PU_VIEW | PU_LITE | PU_MON_LITE | PU_TORCH | PU_MONSTERS | PU_DISTANCE | PU_FLOW); - handle_stuff(player_ptr); - /* Leave "xtra" mode */ current_world_ptr->character_xtra = FALSE; - player_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS); player_ptr->update |= (PU_COMBINE | PU_REORDER); handle_stuff(player_ptr); @@ -4988,7 +4083,8 @@ static void dungeon(player_type *player_ptr, bool load_game) if (quest_num && (is_fixed_quest_idx(quest_num) && !((quest_num == QUEST_OBERON) || (quest_num == QUEST_SERPENT) || - !(quest[quest_num].flags & QUEST_FLAG_PRESET)))) do_cmd_feeling(player_ptr); + !(quest[quest_num].flags & QUEST_FLAG_PRESET)))) + do_cmd_feeling(player_ptr); if (player_ptr->phase_out) { @@ -5007,10 +4103,8 @@ static void dungeon(player_type *player_ptr, bool load_game) if ((player_ptr->pclass == CLASS_BARD) && (SINGING_SONG_EFFECT(player_ptr) > MUSIC_DETECT)) SINGING_SONG_EFFECT(player_ptr) = MUSIC_DETECT; - /* Hack -- notice death or departure */ if (!player_ptr->playing || player_ptr->is_dead) return; - /* Print quest message if appropriate */ if (!floor_ptr->inside_quest && (player_ptr->dungeon_idx == DUNGEON_ANGBAND)) { quest_discovery(random_quest_number(player_ptr, floor_ptr->dun_level)); @@ -5032,88 +4126,56 @@ static void dungeon(player_type *player_ptr, bool load_game) if (!load_game && (player_ptr->special_defense & NINJA_S_STEALTH)) set_superstealth(player_ptr, FALSE); - /*** Process this dungeon level ***/ - - /* Reset the monster generation level */ floor_ptr->monster_level = floor_ptr->base_level; - - /* Reset the object generation level */ floor_ptr->object_level = floor_ptr->base_level; - current_world_ptr->is_loading_now = TRUE; - if (player_ptr->energy_need > 0 && !player_ptr->phase_out && (floor_ptr->dun_level || player_ptr->leaving_dungeon || floor_ptr->inside_arena)) player_ptr->energy_need = 0; - /* Not leaving dungeon */ player_ptr->leaving_dungeon = FALSE; - - /* Initialize monster process */ mproc_init(floor_ptr); - /* Main loop */ while (TRUE) { - /* Hack -- Compact the monster list occasionally */ - if ((floor_ptr->m_cnt + 32 > current_world_ptr->max_m_idx) && !player_ptr->phase_out) compact_monsters(player_ptr, 64); - - /* Hack -- Compress the monster list occasionally */ - if ((floor_ptr->m_cnt + 32 < floor_ptr->m_max) && !player_ptr->phase_out) compact_monsters(player_ptr, 0); + if ((floor_ptr->m_cnt + 32 > current_world_ptr->max_m_idx) && !player_ptr->phase_out) + compact_monsters(player_ptr, 64); + if ((floor_ptr->m_cnt + 32 < floor_ptr->m_max) && !player_ptr->phase_out) + compact_monsters(player_ptr, 0); - /* Hack -- Compact the object list occasionally */ - if (floor_ptr->o_cnt + 32 > current_world_ptr->max_o_idx) compact_objects(player_ptr, 64); + if (floor_ptr->o_cnt + 32 > current_world_ptr->max_o_idx) + compact_objects(player_ptr, 64); - /* Hack -- Compress the object list occasionally */ - if (floor_ptr->o_cnt + 32 < floor_ptr->o_max) compact_objects(player_ptr, 0); + if (floor_ptr->o_cnt + 32 < floor_ptr->o_max) + compact_objects(player_ptr, 0); - /* Process the player */ process_player(player_ptr); process_upkeep_with_speed(player_ptr); - handle_stuff(player_ptr); - /* Hack -- Hilite the player */ move_cursor_relative(player_ptr->y, player_ptr->x); - - /* Optional fresh */ if (fresh_after) Term_fresh(); - /* Hack -- Notice death or departure */ if (!player_ptr->playing || player_ptr->is_dead) break; - /* Process all of the monsters */ process_monsters(player_ptr); - handle_stuff(player_ptr); - /* Hack -- Hilite the player */ move_cursor_relative(player_ptr->y, player_ptr->x); - - /* Optional fresh */ if (fresh_after) Term_fresh(); - /* Hack -- Notice death or departure */ if (!player_ptr->playing || player_ptr->is_dead) break; - /* Process the world */ process_world(player_ptr); - handle_stuff(player_ptr); - /* Hack -- Hilite the player */ move_cursor_relative(player_ptr->y, player_ptr->x); - - /* Optional fresh */ if (fresh_after) Term_fresh(); - /* Hack -- Notice death or departure */ if (!player_ptr->playing || player_ptr->is_dead) break; - /* Count game turns */ current_world_ptr->game_turn++; - if (current_world_ptr->dungeon_turn < current_world_ptr->dungeon_turn_limit) { if (!player_ptr->wild_mode || wild_regen) current_world_ptr->dungeon_turn++; @@ -5122,20 +4184,16 @@ static void dungeon(player_type *player_ptr, bool load_game) prevent_turn_overflow(player_ptr); - /* Handle "leaving" */ if (player_ptr->leaving) break; if (wild_regen) wild_regen--; } - /* Inside a quest and non-unique questor? */ if (quest_num && !(r_info[quest[quest_num].r_idx].flags1 & RF1_UNIQUE)) { - /* Un-mark the quest monster */ r_info[quest[quest_num].r_idx].flags1 &= ~RF1_QUESTOR; } - /* Not save-and-quit and not dead? */ if (player_ptr->playing && !player_ptr->is_dead) { /* @@ -5143,12 +4201,9 @@ static void dungeon(player_type *player_ptr, bool load_game) * floor, then prepare next floor */ leave_floor(player_ptr); - - /* Forget the flag */ reinit_wilderness = FALSE; } - /* Write about current level on the play record once per level */ write_level = TRUE; } @@ -5164,57 +4219,28 @@ static void dungeon(player_type *player_ptr, bool load_game) static void load_all_pref_files(player_type *player_ptr) { char buf[1024]; - - /* Access the "user" pref file */ sprintf(buf, "user.prf"); - - /* Process that file */ process_pref_file(player_ptr, buf); - - /* Access the "user" system pref file */ sprintf(buf, "user-%s.prf", ANGBAND_SYS); - - /* Process that file */ process_pref_file(player_ptr, buf); - - /* Access the "race" pref file */ sprintf(buf, "%s.prf", rp_ptr->title); - - /* Process that file */ process_pref_file(player_ptr, buf); - - /* Access the "class" pref file */ sprintf(buf, "%s.prf", cp_ptr->title); - - /* Process that file */ process_pref_file(player_ptr, buf); - - /* Access the "character" pref file */ sprintf(buf, "%s.prf", player_ptr->base_name); - - /* Process that file */ process_pref_file(player_ptr, buf); - - /* Access the "realm 1" pref file */ if (player_ptr->realm1 != REALM_NONE) { sprintf(buf, "%s.prf", realm_names[player_ptr->realm1]); - - /* Process that file */ process_pref_file(player_ptr, buf); } - /* Access the "realm 2" pref file */ if (player_ptr->realm2 != REALM_NONE) { sprintf(buf, "%s.prf", realm_names[player_ptr->realm2]); - - /* Process that file */ process_pref_file(player_ptr, buf); } - - /* Load an autopick preference file */ autopick_load_pref(player_ptr, FALSE); } @@ -5229,7 +4255,6 @@ static void load_all_pref_files(player_type *player_ptr) */ void play_game(player_type *player_ptr, bool new_game) { - MONSTER_IDX i; bool load_game = TRUE; bool init_random_seed = FALSE; @@ -5255,40 +4280,24 @@ void play_game(player_type *player_ptr, bool new_game) } player_ptr->hack_mutation = FALSE; - - /* Hack -- Character is "icky" */ current_world_ptr->character_icky = TRUE; - - /* Make sure main term is active */ Term_activate(angband_term[0]); - - /* Initialise the resize hooks */ angband_term[0]->resize_hook = resize_map; - - for (i = 1; i < 8; i++) + for (MONSTER_IDX i = 1; i < 8; i++) { - /* Does the term exist? */ if (angband_term[i]) { - /* Add the redraw on resize hook */ angband_term[i]->resize_hook = redraw_window; } } - /* Hack -- turn off the cursor */ (void)Term_set_cursor(0); - - - /* Attempt to load */ if (!load_player(player_ptr)) { quit(_("セーブファイルが壊れています", "broken savefile")); } - /* Extract the options */ extract_option_vars(); - - /* Report waited score */ if (player_ptr->wait_report_score) { char buf[1024]; @@ -5299,26 +4308,16 @@ void play_game(player_type *player_ptr, bool new_game) 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); - - /* No suspending now */ signals_ignore_tstp(); - - /* Hack -- Character is now "icky" */ current_world_ptr->character_icky = TRUE; path_build(buf, sizeof(buf), ANGBAND_DIR_APEX, "scores.raw"); - - /* Open the high score file, for reading/writing */ highscore_fd = fd_open(buf, O_RDWR); /* 町名消失バグ対策(#38205)のためここで世界マップ情報を読み出す */ process_dungeon_file(player_ptr, "w_info.txt", 0, 0, current_world_ptr->max_wild_y, current_world_ptr->max_wild_x); - - /* Handle score, show Top scores */ - success = send_world_score(player_ptr, TRUE); + success = send_world_score(player_ptr, TRUE, update_playtime, display_player, map_name); if (!success && !get_check_strict(_("スコア登録を諦めますか?", "Do you give up score registration? "), CHECK_NO_HISTORY)) { @@ -5331,13 +4330,9 @@ void play_game(player_type *player_ptr, bool new_game) top_twenty(player_ptr); if (!save_player(player_ptr)) msg_print(_("セーブ失敗!", "death save failed!")); } - /* Shut the high score file */ - (void)fd_close(highscore_fd); - /* Forget the high score fd */ + (void)fd_close(highscore_fd); highscore_fd = -1; - - /* Allow suspending now */ signals_handle_tstp(); quit(0); @@ -5345,93 +4340,66 @@ void play_game(player_type *player_ptr, bool new_game) current_world_ptr->creating_savefile = new_game; - /* Nothing loaded */ if (!current_world_ptr->character_loaded) { - /* Make new player */ new_game = TRUE; - - /* The dungeon is not ready */ current_world_ptr->character_dungeon = FALSE; - - /* Prepare to init the RNG */ init_random_seed = TRUE; - - /* Initialize the saved floors data */ init_saved_floors(player_ptr, FALSE); } - - /* Old game is loaded. But new game is requested. */ else if (new_game) { - /* Initialize the saved floors data */ init_saved_floors(player_ptr, TRUE); } - /* Process old character */ if (!new_game) { - /* Process the player name */ process_player_name(player_ptr, FALSE); } - /* Init the RNG */ if (init_random_seed) { Rand_state_init(); } - /* Roll new character */ floor_type *floor_ptr = player_ptr->current_floor_ptr; if (new_game) { - /* The dungeon is not ready */ current_world_ptr->character_dungeon = FALSE; - /* Start in town */ floor_ptr->dun_level = 0; floor_ptr->inside_quest = 0; floor_ptr->inside_arena = FALSE; player_ptr->phase_out = FALSE; - write_level = TRUE; - /* Hack -- seed for flavors */ current_world_ptr->seed_flavor = randint0(0x10000000); - - /* Hack -- seed for town layout */ current_world_ptr->seed_town = randint0(0x10000000); - /* Roll up a new character */ player_birth(player_ptr); - counts_write(player_ptr, 2, 0); player_ptr->count = 0; - load = FALSE; - determine_bounty_uniques(player_ptr); determine_daily_bounty(player_ptr, FALSE); - - /* Initialize object array */ wipe_o_list(floor_ptr); } else { write_level = FALSE; - exe_write_diary(player_ptr, DIARY_GAMESTART, 1, _(" ----ゲーム再開----", - " ---- Restart Game ----")); + " --- Restarted Game ---")); /* + * todo もう2.2.Xなので互換性は打ち切ってもいいのでは? * 1.0.9 以前はセーブ前に player_ptr->riding = -1 としていたので、再設定が必要だった。 * もう不要だが、以前のセーブファイルとの互換のために残しておく。 */ if (player_ptr->riding == -1) { player_ptr->riding = 0; - for (i = floor_ptr->m_max; i > 0; i--) + for (MONSTER_IDX i = floor_ptr->m_max; i > 0; i--) { if (player_bold(player_ptr, floor_ptr->m_list[i].fy, floor_ptr->m_list[i].fx)) { @@ -5452,28 +4420,16 @@ void play_game(player_type *player_ptr, bool new_game) current_world_ptr->start_time = time(NULL) - 1; record_o_name[0] = '\0'; - /* Reset map panel */ panel_row_min = floor_ptr->height; panel_col_min = floor_ptr->width; - - /* Sexy gal gets bonus to maximum weapon skill of whip */ if (player_ptr->pseikaku == SEIKAKU_SEXY) s_info[player_ptr->pclass].w_max[TV_HAFTED - TV_WEAPON_BEGIN][SV_WHIP] = WEAPON_EXP_MASTER; - /* Fill the arrays of floors and walls in the good proportions */ set_floor_and_wall(player_ptr->dungeon_idx); - - /* Flavor the objects */ flavor_init(); - - /* Flash a message */ prt(_("お待ち下さい...", "Please wait..."), 0, 0); - - /* Flush the message */ Term_fresh(); - - /* Hack -- Enter wizard mode */ if (arg_wizard) { if (enter_wizard_mode(player_ptr)) @@ -5482,13 +4438,8 @@ void play_game(player_type *player_ptr, bool new_game) if (player_ptr->is_dead || !player_ptr->y || !player_ptr->x) { - /* Initialize the saved floors data */ init_saved_floors(player_ptr, TRUE); - - /* Avoid crash */ floor_ptr->inside_quest = 0; - - /* Avoid crash in update_view() */ player_ptr->y = player_ptr->x = 10; } } @@ -5498,7 +4449,6 @@ void play_game(player_type *player_ptr, bool new_game) } } - /* Initialize the town-buildings if necessary */ if (!floor_ptr->dun_level && !floor_ptr->inside_quest) { process_dungeon_file(player_ptr, "w_info.txt", 0, 0, current_world_ptr->max_wild_y, current_world_ptr->max_wild_x); @@ -5507,71 +4457,53 @@ void play_game(player_type *player_ptr, bool new_game) select_floor_music(player_ptr); } - /* Generate a dungeon level if needed */ if (!current_world_ptr->character_dungeon) { change_floor(player_ptr); } else { - /* HACK -- Restore from panic-save */ if (player_ptr->panic_save) { - /* No player? -- Try to regenerate floor */ if (!player_ptr->y || !player_ptr->x) { - msg_print(_("プレイヤーの位置がおかしい。フロアを再生成します。", "What a strange player location. Regenerate the dungeon floor.")); + msg_print(_("プレイヤーの位置がおかしい。フロアを再生成します。", "What a strange player location, regenerate the dungeon floor.")); change_floor(player_ptr); } - /* Still no player? -- Try to locate random place */ if (!player_ptr->y || !player_ptr->x) player_ptr->y = player_ptr->x = 10; - /* No longer in panic */ player_ptr->panic_save = 0; } } - /* Character is now "complete" */ current_world_ptr->character_generated = TRUE; - - /* Hack -- Character is no longer "icky" */ current_world_ptr->character_icky = FALSE; if (new_game) { char buf[80]; - sprintf(buf, _("%sに降り立った。", "You are standing in the %s."), map_name(player_ptr)); + sprintf(buf, _("%sに降り立った。", "arrived in %s."), map_name(player_ptr)); exe_write_diary(player_ptr, DIARY_DESCRIPTION, 0, buf); } - /* Start game */ player_ptr->playing = TRUE; - - /* Reset the visual mappings */ reset_visuals(player_ptr); - - /* Load the "pref" files */ load_all_pref_files(player_ptr); - - /* Give startup outfit (after loading pref files) */ if (new_game) { player_outfit(player_ptr); } - /* React to changes */ Term_xtra(TERM_XTRA_REACT, 0); player_ptr->window |= (PW_INVEN | PW_EQUIP | PW_SPELL | PW_PLAYER); player_ptr->window |= (PW_MESSAGE | PW_OVERHEAD | PW_DUNGEON | PW_MONSTER | PW_OBJECT); handle_stuff(player_ptr); - /* Set or clear "rogue_like_commands" if requested */ if (arg_force_original) rogue_like_commands = FALSE; if (arg_force_roguelike) rogue_like_commands = TRUE; - /* Hack -- Enforce "delayed death" */ if (player_ptr->chp < 0) player_ptr->is_dead = TRUE; if (player_ptr->prace == RACE_ANDROID) calc_android_exp(player_ptr); @@ -5594,43 +4526,27 @@ void play_game(player_type *player_ptr, bool new_game) (void)combine_and_reorder_home(STORE_HOME); (void)combine_and_reorder_home(STORE_MUSEUM); - select_floor_music(player_ptr); - /* Process */ while (TRUE) { - /* Process the level */ dungeon(player_ptr, load_game); - - /* Hack -- prevent "icky" message */ current_world_ptr->character_xtra = TRUE; - handle_stuff(player_ptr); current_world_ptr->character_xtra = FALSE; - - /* Cancel the target */ target_who = 0; - health_track(player_ptr, 0); - forget_lite(floor_ptr); forget_view(floor_ptr); clear_mon_lite(floor_ptr); - - /* Handle "quit and save" */ if (!player_ptr->playing && !player_ptr->is_dead) break; wipe_o_list(floor_ptr); if (!player_ptr->is_dead) wipe_monsters_list(player_ptr); - msg_print(NULL); - load_game = FALSE; - - /* Accidental Death */ if (player_ptr->playing && player_ptr->is_dead) { if (floor_ptr->inside_arena) @@ -5645,16 +4561,11 @@ void play_game(player_type *player_ptr, bool new_game) player_ptr->chp_frac = 0; player_ptr->exit_bldg = TRUE; reset_tim_flags(player_ptr); - - /* Leave through the exit */ prepare_change_floor_mode(player_ptr, CFM_SAVE_FLOORS | CFM_RAND_CONNECT); - - /* prepare next floor */ leave_floor(player_ptr); } else { - /* Mega-Hack -- Allow player to cheat death */ if ((current_world_ptr->wizard || cheat_live) && !get_check(_("死にますか? ", "Die? "))) { cheat_death(player_ptr); @@ -5662,20 +4573,16 @@ void play_game(player_type *player_ptr, bool new_game) } } - /* Handle "death" */ if (player_ptr->is_dead) break; - /* Make a new level */ change_floor(player_ptr); } - /* Close stuff */ close_game(player_ptr); - - /* Quit */ quit(NULL); } + /*! * @brief ゲームターンからの実時間換算を行うための補正をかける * @param hoge ゲームターン @@ -5705,13 +4612,10 @@ s32b turn_real(player_type *player_ptr, s32b hoge) */ void prevent_turn_overflow(player_type *player_ptr) { - int rollback_days, i, j; - s32b rollback_turns; - if (current_world_ptr->game_turn < current_world_ptr->game_turn_limit) return; - rollback_days = 1 + (current_world_ptr->game_turn - current_world_ptr->game_turn_limit) / (TURNS_PER_TICK * TOWN_DAWN); - rollback_turns = TURNS_PER_TICK * TOWN_DAWN * rollback_days; + int rollback_days = 1 + (current_world_ptr->game_turn - current_world_ptr->game_turn_limit) / (TURNS_PER_TICK * TOWN_DAWN); + s32b rollback_turns = TURNS_PER_TICK * TOWN_DAWN * rollback_days; if (current_world_ptr->game_turn > rollback_turns) current_world_ptr->game_turn -= rollback_turns; else current_world_ptr->game_turn = 1; @@ -5723,22 +4627,22 @@ void prevent_turn_overflow(player_type *player_ptr) if (player_ptr->feeling_turn > rollback_turns) player_ptr->feeling_turn -= rollback_turns; else player_ptr->feeling_turn = 1; - for (i = 1; i < max_towns; i++) + for (int i = 1; i < max_towns; i++) { - for (j = 0; j < MAX_STORES; j++) + for (int j = 0; j < MAX_STORES; j++) { - store_type *st_ptr = &town_info[i].store[j]; + store_type *store_ptr = &town_info[i].store[j]; - if (st_ptr->last_visit > -10L * TURNS_PER_TICK * STORE_TICKS) + if (store_ptr->last_visit > -10L * TURNS_PER_TICK * STORE_TICKS) { - st_ptr->last_visit -= rollback_turns; - if (st_ptr->last_visit < -10L * TURNS_PER_TICK * STORE_TICKS) st_ptr->last_visit = -10L * TURNS_PER_TICK * STORE_TICKS; + store_ptr->last_visit -= rollback_turns; + if (store_ptr->last_visit < -10L * TURNS_PER_TICK * STORE_TICKS) store_ptr->last_visit = -10L * TURNS_PER_TICK * STORE_TICKS; } - if (st_ptr->store_open) + if (store_ptr->store_open) { - st_ptr->store_open -= rollback_turns; - if (st_ptr->store_open < 1) st_ptr->store_open = 1; + store_ptr->store_open -= rollback_turns; + if (store_ptr->store_open < 1) store_ptr->store_open = 1; } } } @@ -5759,60 +4663,38 @@ void close_game(player_type *player_ptr) { char buf[1024]; bool do_send = TRUE; - - /* concptr p = "[i:キャラクタの情報, f:ファイル書き出し, t:スコア, x:*鑑定*, ESC:ゲーム終了]"; */ handle_stuff(player_ptr); - /* Flush the messages */ msg_print(NULL); - - /* Flush the input */ flush(); - - /* No suspending now */ signals_ignore_tstp(); - - /* Hack -- Character is now "icky" */ current_world_ptr->character_icky = TRUE; - path_build(buf, sizeof(buf), ANGBAND_DIR_APEX, "scores.raw"); - - /* Grab permissions */ safe_setuid_grab(); - - /* Open the high score file, for reading/writing */ highscore_fd = fd_open(buf, O_RDWR); - - /* Drop permissions */ safe_setuid_drop(); - /* Handle death */ if (player_ptr->is_dead) { - /* Handle retirement */ if (current_world_ptr->total_winner) kingly(player_ptr); - /* Save memories */ if (!cheat_save || get_check(_("死んだデータをセーブしますか? ", "Save death? "))) { if (!save_player(player_ptr)) msg_print(_("セーブ失敗!", "death save failed!")); } else do_send = FALSE; - /* You are dead */ print_tomb(player_ptr); - flush(); - /* Show more info */ - show_info(player_ptr); + show_info(player_ptr, handle_stuff, update_playtime, display_player, map_name); Term_clear(); if (check_score(player_ptr)) { - if ((!send_world_score(player_ptr, do_send))) + if ((!send_world_score(player_ptr, do_send, update_playtime, display_player, map_name))) { if (get_check_strict(_("後でスコアを登録するために待機しますか?", "Stand by for later score registration? "), (CHECK_NO_ESCAPE | CHECK_NO_HISTORY))) @@ -5830,32 +4712,17 @@ void close_game(player_type *player_ptr) display_scores_aux(0, 10, -1, NULL); } } - - /* Still alive */ else { - /* Save the game */ do_cmd_save_game(player_ptr, FALSE); - - /* Prompt for scores */ prt(_("リターンキーか ESC キーを押して下さい。", "Press Return (or Escape)."), 0, 40); play_music(TERM_XTRA_MUSIC_BASIC, MUSIC_BASIC_EXIT); - - /* Predict score (or ESCAPE) */ if (inkey() != ESCAPE) predict_score(player_ptr); } - - /* Shut the high score file */ (void)fd_close(highscore_fd); - - /* Forget the high score fd */ highscore_fd = -1; - - /* Kill all temporary files */ clear_saved_floor_files(player_ptr); - - /* Allow suspending now */ signals_handle_tstp(); }