X-Git-Url: http://git.osdn.net/view?a=blobdiff_plain;f=src%2Fxtra1.c;h=242b1f33a7ef8bff43b95f18db317628123a151a;hb=e70ba712cf4b753e7d3876f60980c87cfeec09e3;hp=2d4cccdd25fea697aa68e1149916297e42e0673d;hpb=e11d638b260e9641c3691822b55e8e54f9e96024;p=hengband%2Fhengband.git diff --git a/src/xtra1.c b/src/xtra1.c index 2d4cccdd2..242b1f33a 100644 --- a/src/xtra1.c +++ b/src/xtra1.c @@ -11,6 +11,7 @@ */ #include "angband.h" +#include "world.h" /*! * @brief 現在の修正後能力値を3~17及び18/xxx形式に変換する / Converts stat num into a six-char (right justified) string @@ -109,7 +110,7 @@ s16b modify_stat_value(int value, int amount) * @param col 描画行 * @return なし */ -static void prt_field(cptr info, int row, int col) +static void prt_field(cptr info, TERM_LEN row, TERM_LEN col) { /* Dump 13 spaces to clear */ c_put_str(TERM_WHITE, " ", row, col); @@ -118,49 +119,6 @@ static void prt_field(cptr info, int row, int col) c_put_str(TERM_L_BLUE, info, row, col); } - -/*! - * @brief ゲーム時間が日中かどうかを返す / - * Whether daytime or not - * @return 日中ならばTRUE、夜ならばFALSE - */ -bool is_daytime(void) -{ - s32b len = TURNS_PER_TICK * TOWN_DAWN; - if ((turn % len) < (len / 2)) - return TRUE; - else - return FALSE; -} - -/*! - * @brief 現在の日数、時刻を返す / - * Extract day, hour, min - * @param day 日数を返すための参照ポインタ - * @param hour 時数を返すための参照ポインタ - * @param min 分数を返すための参照ポインタ - */ -void extract_day_hour_min(int *day, int *hour, int *min) -{ - const s32b A_DAY = TURNS_PER_TICK * TOWN_DAWN; - s32b turn_in_today = (turn + A_DAY / 4) % A_DAY; - - switch (p_ptr->start_race) - { - case RACE_VAMPIRE: - case RACE_SKELETON: - case RACE_ZOMBIE: - case RACE_SPECTRE: - *day = (turn - A_DAY * 3 / 4) / A_DAY + 1; - break; - default: - *day = (turn + A_DAY / 4) / A_DAY + 1; - break; - } - *hour = (24 * turn_in_today / A_DAY) % 24; - *min = (1440 * turn_in_today / A_DAY) % 60; -} - /*! * @brief ゲーム時刻を表示する / * Print time @@ -210,7 +168,7 @@ cptr map_name(void) static void prt_dungeon(void) { cptr dungeon_name; - int col; + TERM_LEN col; /* Dump 13 spaces to clear */ c_put_str(TERM_WHITE, " ", ROW_DUNGEON, COL_DUNGEON); @@ -337,7 +295,7 @@ static void prt_stat(int stat) #define BAR_ESP_EVIL 66 /*!< 下部ステータス表示: 邪悪感知 */ static struct { - byte attr; + TERM_COLOR attr; cptr sstr; cptr lstr; } bar[] @@ -508,9 +466,10 @@ static struct { */ static void prt_status(void) { - u32b bar_flags[3]; - int wid, hgt, row_statbar, max_col_statbar; - int i, col = 0, num = 0; + BIT_FLAGS bar_flags[3]; + TERM_LEN wid, hgt, row_statbar, max_col_statbar; + int i; + TERM_LEN col = 0, num = 0; int space = 2; Term_get_size(&wid, &hgt); @@ -742,40 +701,21 @@ static void prt_status(void) static void prt_title(void) { cptr p = ""; - char str[14]; + GAME_TEXT str[14]; - /* Wizard */ if (p_ptr->wizard) { -#ifdef JP - /* 英日切り替え機能 称号 */ - p = "[ウィザード]"; -#else - p = "[=-WIZARD-=]"; -#endif - + p = _("[ウィザード]", "[=-WIZARD-=]"); } - - /* Winner */ else if (p_ptr->total_winner || (p_ptr->lev > PY_MAX_LEVEL)) { if (p_ptr->arena_number > MAX_ARENA_MONS + 2) { -#ifdef JP - /* 英日切り替え機能 称号 */ - p = "*真・勝利者*"; -#else - p = "*TRUEWINNER*"; -#endif + p = _("*真・勝利者*", "*TRUEWINNER*"); } else { -#ifdef JP - /* 英日切り替え機能 称号 */ - p = "***勝利者***"; -#else - p = "***WINNER***"; -#endif + p = _("***勝利者***", "***WINNER***"); } } @@ -802,25 +742,13 @@ static void prt_level(void) if (p_ptr->lev >= p_ptr->max_plv) { -#ifdef JP - put_str("レベル ", ROW_LEVEL, 0); + put_str(_("レベル ", "LEVEL "), ROW_LEVEL, 0); c_put_str(TERM_L_GREEN, tmp, ROW_LEVEL, COL_LEVEL + 7); -#else - put_str("LEVEL ", ROW_LEVEL, 0); - c_put_str(TERM_L_GREEN, tmp, ROW_LEVEL, COL_LEVEL + 6); -#endif - } else { -#ifdef JP - put_str("xレベル", ROW_LEVEL, 0); + put_str(_("xレベル", "Level "), ROW_LEVEL, 0); c_put_str(TERM_YELLOW, tmp, ROW_LEVEL, COL_LEVEL + 7); -#else - put_str("Level ", ROW_LEVEL, 0); - c_put_str(TERM_YELLOW, tmp, ROW_LEVEL, COL_LEVEL + 6); -#endif - } } @@ -835,7 +763,7 @@ static void prt_exp(void) if ((!exp_need)||(p_ptr->prace == RACE_ANDROID)) { - (void)sprintf(out_val, _("%7ld", "%8ld"), (long)p_ptr->exp); + (void)sprintf(out_val, "%8ld", (long)p_ptr->exp); } else { @@ -845,37 +773,20 @@ static void prt_exp(void) } else { -#ifdef JP - (void)sprintf(out_val, "%7ld", (long)(player_exp [p_ptr->lev - 1] * p_ptr->expfact / 100L) - p_ptr->exp); -#else (void)sprintf(out_val, "%8ld", (long)(player_exp [p_ptr->lev - 1] * p_ptr->expfact / 100L) - p_ptr->exp); -#endif } } if (p_ptr->exp >= p_ptr->max_exp) { -#ifdef JP - if (p_ptr->prace == RACE_ANDROID) put_str("強化 ", ROW_EXP, 0); - else put_str("経験 ", ROW_EXP, 0); - c_put_str(TERM_L_GREEN, out_val, ROW_EXP, COL_EXP + 5); -#else - if (p_ptr->prace == RACE_ANDROID) put_str("Cst ", ROW_EXP, 0); - else put_str("EXP ", ROW_EXP, 0); + if (p_ptr->prace == RACE_ANDROID) put_str(_("強化 ", "Cst "), ROW_EXP, 0); + else put_str(_("経験 ", "EXP "), ROW_EXP, 0); c_put_str(TERM_L_GREEN, out_val, ROW_EXP, COL_EXP + 4); -#endif - } else { -#ifdef JP - put_str("x経験", ROW_EXP, 0); - c_put_str(TERM_YELLOW, out_val, ROW_EXP, COL_EXP + 5); -#else - put_str("Exp ", ROW_EXP, 0); + put_str(_("x経験", "Exp "), ROW_EXP, 0); c_put_str(TERM_YELLOW, out_val, ROW_EXP, COL_EXP + 4); -#endif - } } @@ -920,14 +831,12 @@ static void prt_ac(void) */ static void prt_hp(void) { -/* ヒットポイントの表示方法を変更 */ + /* ヒットポイントの表示方法を変更 */ char tmp[32]; - byte color; + TERM_COLOR color; /* タイトル */ -/* put_str(" HP・MP", ROW_HPMP, COL_HPMP); */ - put_str("HP", ROW_CURHP, COL_CURHP); /* 現在のヒットポイント */ @@ -974,7 +883,6 @@ static void prt_sp(void) if (!mp_ptr->spell_book) return; /* タイトル */ -/* put_str(" MP / 最大", ROW_MAXSP, COL_MAXSP); */ put_str(_("MP", "SP"), ROW_CURSP, COL_CURSP); /* 現在のマジックポイント */ @@ -1013,8 +921,8 @@ static void prt_sp(void) static void prt_depth(void) { char depths[32]; - int wid, hgt, row_depth, col_depth; - byte attr = TERM_WHITE; + TERM_LEN wid, hgt, row_depth, col_depth; + TERM_COLOR attr = TERM_WHITE; Term_get_size(&wid, &hgt); col_depth = wid + COL_DEPTH; @@ -1111,9 +1019,8 @@ static void prt_hunger(void) */ static void prt_state(void) { - byte attr = TERM_WHITE; - - char text[16]; + TERM_COLOR attr = TERM_WHITE; + GAME_TEXT text[16]; /* Repeating */ if (command_rep) @@ -1264,9 +1171,9 @@ static void prt_speed(void) int i = p_ptr->pspeed; bool is_fast = IS_FAST(); - byte attr = TERM_WHITE; + TERM_COLOR attr = TERM_WHITE; char buf[32] = ""; - int wid, hgt, row_speed, col_speed; + TERM_LEN wid, hgt, row_speed, col_speed; Term_get_size(&wid, &hgt); col_speed = wid + COL_SPEED; @@ -1332,7 +1239,7 @@ static void prt_speed(void) */ static void prt_study(void) { - int wid, hgt, row_study, col_study; + TERM_LEN wid, hgt, row_study, col_study; Term_get_size(&wid, &hgt); col_study = wid + COL_STUDY; @@ -1355,7 +1262,7 @@ static void prt_study(void) */ static void prt_imitation(void) { - int wid, hgt, row_study, col_study; + TERM_LEN wid, hgt, row_study, col_study; Term_get_size(&wid, &hgt); col_study = wid + COL_STUDY; @@ -1365,7 +1272,7 @@ static void prt_imitation(void) { if (p_ptr->mane_num) { - byte attr; + TERM_COLOR attr; if (new_mane) attr = TERM_L_RED; else attr = TERM_WHITE; c_put_str(attr, _("まね", "Imit"), row_study, col_study); @@ -1562,14 +1469,14 @@ static void health_redraw(bool riding) else { /* Extract the "percent" of health */ - int pct = 100L * m_ptr->hp / m_ptr->maxhp; - int pct2 = 100L * m_ptr->hp / m_ptr->max_maxhp; + int pct = m_ptr->maxhp > 0 ? 100L * m_ptr->hp / m_ptr->maxhp : 0; + int pct2 = m_ptr->maxhp > 0 ? 100L * m_ptr->hp / m_ptr->max_maxhp: 0; /* Convert percent into "health" */ int len = (pct2 < 10) ? 1 : (pct2 < 90) ? (pct2 / 10 + 1) : 10; /* Default to almost dead */ - byte attr = TERM_RED; + TERM_COLOR attr = TERM_RED; /* Invulnerable */ if (MON_INVULNER(m_ptr)) attr = TERM_WHITE; @@ -1632,7 +1539,7 @@ static void prt_frame_basic(void) prt_exp(); /* All Stats */ - for (i = 0; i < 6; i++) prt_stat(i); + for (i = 0; i < A_MAX; i++) prt_stat(i); /* Armor */ prt_ac(); @@ -1963,8 +1870,6 @@ static void fix_player(void) Term_activate(angband_term[j]); update_playtime(); - - /* Display player */ display_player(0); Term_fresh(); @@ -2038,7 +1943,7 @@ static void fix_overhead(void) for (j = 0; j < 8; j++) { term *old = Term; - int wid, hgt; + TERM_LEN wid, hgt; /* No window */ if (!angband_term[j]) continue; @@ -3221,7 +3126,7 @@ void calc_bonuses(void) extra_blows[0] = extra_blows[1] = 0; /* Clear the stat modifiers */ - for (i = 0; i < 6; i++) p_ptr->stat_add[i] = 0; + for (i = 0; i < A_MAX; i++) p_ptr->stat_add[i] = 0; /* Clear the Displayed/Real armor class */ @@ -3886,7 +3791,7 @@ void calc_bonuses(void) /* Hack -- apply racial/class stat maxes */ /* Apply the racial modifiers */ - for (i = 0; i < 6; i++) + for (i = 0; i < A_MAX; i++) { /* Modify the stats for "race" */ p_ptr->stat_add[i] += (tmp_rp_ptr->r_adj[i] + cp_ptr->c_adj[i] + ap_ptr->a_adj[i]); @@ -4447,7 +4352,7 @@ void calc_bonuses(void) if (p_ptr->special_defense & KATA_KOUKIJIN) { - for (i = 0; i < 6; i++) + for (i = 0; i < A_MAX; i++) p_ptr->stat_add[i] += 5; p_ptr->to_a -= 50; p_ptr->dis_to_a -= 50; @@ -4507,7 +4412,7 @@ void calc_bonuses(void) } /* Calculate stats */ - for (i = 0; i < 6; i++) + for (i = 0; i < A_MAX; i++) { int top, use, ind; @@ -5450,13 +5355,10 @@ void calc_bonuses(void) /* Redraw armor (if needed) */ if ((p_ptr->dis_ac != old_dis_ac) || (p_ptr->dis_to_a != old_dis_to_a)) { - /* Redraw */ p_ptr->redraw |= (PR_ARMOR); - p_ptr->window |= (PW_PLAYER); } - if (p_ptr->ryoute && !omoi) { int bonus_to_h=0, bonus_to_d=0; @@ -5727,7 +5629,6 @@ void calc_bonuses(void) for (this_o_idx = cave[p_ptr->y][p_ptr->x].o_idx; this_o_idx; this_o_idx = next_o_idx) { - /* Acquire object */ o_ptr = &o_list[this_o_idx]; /* Acquire next object */ @@ -5769,175 +5670,21 @@ void calc_bonuses(void) } - -/*! - * @brief p_ptr->notice のフラグに応じた更新をまとめて行う / Handle "p_ptr->notice" - * @return なし - * @details 更新処理の対象はアイテムの自動破壊/アイテムの結合/アイテムの並び替え。 - */ -void notice_stuff(void) -{ - /* Notice stuff */ - if (!p_ptr->notice) return; - - - /* Actually do auto-destroy */ - if (p_ptr->notice & (PN_AUTODESTROY)) - { - p_ptr->notice &= ~(PN_AUTODESTROY); - autopick_delayed_alter(); - } - - /* Combine the pack */ - if (p_ptr->notice & (PN_COMBINE)) - { - p_ptr->notice &= ~(PN_COMBINE); - combine_pack(); - } - - /* Reorder the pack */ - if (p_ptr->notice & (PN_REORDER)) - { - p_ptr->notice &= ~(PN_REORDER); - reorder_pack(); - } -} - - -/*! - * @brief p_ptr->update のフラグに応じた更新をまとめて行う / Handle "p_ptr->update" - * @return なし - * @details 更新処理の対象はプレイヤーの能力修正/光源寿命/HP/MP/魔法の学習状態、他多数の外界の状態判定。 - */ -void update_stuff(void) -{ - if (!p_ptr->update) return; - - - if (p_ptr->update & (PU_BONUS)) - { - p_ptr->update &= ~(PU_BONUS); - calc_bonuses(); - } - - if (p_ptr->update & (PU_TORCH)) - { - p_ptr->update &= ~(PU_TORCH); - calc_torch(); - } - - if (p_ptr->update & (PU_HP)) - { - p_ptr->update &= ~(PU_HP); - calc_hitpoints(); - } - - if (p_ptr->update & (PU_MANA)) - { - p_ptr->update &= ~(PU_MANA); - calc_mana(); - } - - if (p_ptr->update & (PU_SPELLS)) - { - p_ptr->update &= ~(PU_SPELLS); - calc_spells(); - } - - - /* Character is not ready yet, no screen updates */ - if (!character_generated) return; - - - /* Character is in "icky" mode, no screen updates */ - if (character_icky) return; - - - if (p_ptr->update & (PU_UN_LITE)) - { - p_ptr->update &= ~(PU_UN_LITE); - forget_lite(); - } - - if (p_ptr->update & (PU_UN_VIEW)) - { - p_ptr->update &= ~(PU_UN_VIEW); - forget_view(); - } - - if (p_ptr->update & (PU_VIEW)) - { - p_ptr->update &= ~(PU_VIEW); - update_view(); - } - - if (p_ptr->update & (PU_LITE)) - { - p_ptr->update &= ~(PU_LITE); - update_lite(); - } - - - if (p_ptr->update & (PU_FLOW)) - { - p_ptr->update &= ~(PU_FLOW); - update_flow(); - } - - if (p_ptr->update & (PU_DISTANCE)) - { - p_ptr->update &= ~(PU_DISTANCE); - - /* Still need to call update_monsters(FALSE) after update_mon_lite() */ - /* p_ptr->update &= ~(PU_MONSTERS); */ - - update_monsters(TRUE); - } - - if (p_ptr->update & (PU_MON_LITE)) - { - p_ptr->update &= ~(PU_MON_LITE); - update_mon_lite(); - } - - /* - * Mega-Hack -- Delayed visual update - * Only used if update_view(), update_lite() or update_mon_lite() was called - */ - if (p_ptr->update & (PU_DELAY_VIS)) - { - p_ptr->update &= ~(PU_DELAY_VIS); - delayed_visual_update(); - } - - if (p_ptr->update & (PU_MONSTERS)) - { - p_ptr->update &= ~(PU_MONSTERS); - update_monsters(FALSE); - } -} - - /*! * @brief p_ptr->redraw のフラグに応じた更新をまとめて行う / Handle "p_ptr->redraw" * @return なし * @details 更新処理の対象はゲーム中の全描画処理 */ -void redraw_stuff(void) +static void redraw_stuff(void) { - /* Redraw stuff */ if (!p_ptr->redraw) return; - /* Character is not ready yet, no screen updates */ if (!character_generated) return; - /* Character is in "icky" mode, no screen updates */ if (character_icky) return; - - /* Hack -- clear the screen */ if (p_ptr->redraw & (PR_WIPE)) { @@ -5946,14 +5693,12 @@ void redraw_stuff(void) Term_clear(); } - if (p_ptr->redraw & (PR_MAP)) { p_ptr->redraw &= ~(PR_MAP); prt_map(); } - if (p_ptr->redraw & (PR_BASIC)) { p_ptr->redraw &= ~(PR_BASIC); @@ -5977,7 +5722,6 @@ void redraw_stuff(void) p_ptr->redraw &= ~(PR_MISC); prt_field(rp_ptr->title, ROW_RACE, COL_RACE); /* prt_field(cp_ptr->title, ROW_CLASS, COL_CLASS); */ - } if (p_ptr->redraw & (PR_TITLE)) @@ -6057,7 +5801,6 @@ void redraw_stuff(void) health_redraw(TRUE); } - if (p_ptr->redraw & (PR_EXTRA)) { p_ptr->redraw &= ~(PR_EXTRA); @@ -6112,18 +5855,15 @@ void redraw_stuff(void) } } - /*! * @brief p_ptr->window のフラグに応じた更新をまとめて行う / Handle "p_ptr->window" * @return なし * @details 更新処理の対象はサブウィンドウ全般 */ -void window_stuff(void) +static void window_stuff(void) { int j; - - u32b mask = 0L; - + BIT_FLAGS mask = 0L; /* Nothing to do */ if (!p_ptr->window) return; @@ -6141,7 +5881,6 @@ void window_stuff(void) /* Nothing to do */ if (!p_ptr->window) return; - /* Display inventory */ if (p_ptr->window & (PW_INVEN)) { @@ -6221,22 +5960,155 @@ void window_stuff(void) */ void handle_stuff(void) { - if (p_ptr->update) update_stuff(); - - /* Redraw stuff */ + if (p_ptr->update) update_creature(p_ptr); if (p_ptr->redraw) redraw_stuff(); + if (p_ptr->window) window_stuff(); +} +void update_output(void) +{ + if (p_ptr->redraw) redraw_stuff(); if (p_ptr->window) window_stuff(); } /*! + * @brief p_ptr->update のフラグに応じた更新をまとめて行う / Handle "p_ptr->update" + * @return なし + * @details 更新処理の対象はプレイヤーの能力修正/光源寿命/HP/MP/魔法の学習状態、他多数の外界の状態判定。 + */ +void update_creature(player_type *creature_ptr) +{ + if (!creature_ptr->update) return; + + /* Actually do auto-destroy */ + if (creature_ptr->update & (PU_AUTODESTROY)) + { + creature_ptr->update &= ~(PU_AUTODESTROY); + autopick_delayed_alter(); + } + + /* Combine the pack */ + if (creature_ptr->update & (PU_COMBINE)) + { + creature_ptr->update &= ~(PU_COMBINE); + combine_pack(); + } + + /* Reorder the pack */ + if (creature_ptr->update & (PU_REORDER)) + { + creature_ptr->update &= ~(PU_REORDER); + reorder_pack(); + } + + if (creature_ptr->update & (PU_BONUS)) + { + creature_ptr->update &= ~(PU_BONUS); + calc_bonuses(); + } + + if (creature_ptr->update & (PU_TORCH)) + { + creature_ptr->update &= ~(PU_TORCH); + calc_torch(); + } + + if (creature_ptr->update & (PU_HP)) + { + creature_ptr->update &= ~(PU_HP); + calc_hitpoints(); + } + + if (creature_ptr->update & (PU_MANA)) + { + creature_ptr->update &= ~(PU_MANA); + calc_mana(); + } + + if (creature_ptr->update & (PU_SPELLS)) + { + creature_ptr->update &= ~(PU_SPELLS); + calc_spells(); + } + + /* Character is not ready yet, no screen updates */ + if (!character_generated) return; + + /* Character is in "icky" mode, no screen updates */ + if (character_icky) return; + + if (creature_ptr->update & (PU_UN_LITE)) + { + creature_ptr->update &= ~(PU_UN_LITE); + forget_lite(); + } + + if (creature_ptr->update & (PU_UN_VIEW)) + { + creature_ptr->update &= ~(PU_UN_VIEW); + forget_view(); + } + + if (creature_ptr->update & (PU_VIEW)) + { + creature_ptr->update &= ~(PU_VIEW); + update_view(); + } + + if (creature_ptr->update & (PU_LITE)) + { + creature_ptr->update &= ~(PU_LITE); + update_lite(); + } + + + if (creature_ptr->update & (PU_FLOW)) + { + creature_ptr->update &= ~(PU_FLOW); + update_flow(); + } + + if (creature_ptr->update & (PU_DISTANCE)) + { + creature_ptr->update &= ~(PU_DISTANCE); + + /* Still need to call update_monsters(FALSE) after update_mon_lite() */ + /* creature_ptr->update &= ~(PU_MONSTERS); */ + + update_monsters(TRUE); + } + + if (creature_ptr->update & (PU_MON_LITE)) + { + creature_ptr->update &= ~(PU_MON_LITE); + update_mon_lite(); + } + + /* + * Mega-Hack -- Delayed visual update + * Only used if update_view(), update_lite() or update_mon_lite() was called + */ + if (creature_ptr->update & (PU_DELAY_VIS)) + { + creature_ptr->update &= ~(PU_DELAY_VIS); + delayed_visual_update(); + } + + if (creature_ptr->update & (PU_MONSTERS)) + { + creature_ptr->update &= ~(PU_MONSTERS); + update_monsters(FALSE); + } +} + +/*! * @brief プレイヤーの現在開いている手の状態を返す * @param riding_control 乗馬中により片手を必要としている状態ならばTRUEを返す。 * @return 開いている手のビットフラグ */ -s16b empty_hands(bool riding_control) +BIT_FLAGS16 empty_hands(bool riding_control) { - s16b status = EMPTY_HAND_NONE; + BIT_FLAGS16 status = EMPTY_HAND_NONE; if (!inventory[INVEN_RARM].k_idx) status |= EMPTY_HAND_RARM; if (!inventory[INVEN_LARM].k_idx) status |= EMPTY_HAND_LARM;