OSDN Git Service

[refactor] 意図したswitch-case文のfall throughをコメント
authorHabu <habu@users.sourceforge.jp>
Sun, 19 Apr 2020 14:41:49 +0000 (23:41 +0900)
committerHabu <habu@users.sourceforge.jp>
Sun, 19 Apr 2020 14:44:06 +0000 (23:44 +0900)
switch-case文で意図してfall throughしている部分に、/* Fall through */ というコメントを入れる。
これにより、以下の効果を得る:
 - 意図したfall throughである事を明示する
 - gccによる暗黙のfall through警告を抑制する

16 files changed:
src/autopick.c
src/cmd/cmd-gameoption.c
src/combat/melee1.c
src/dungeon-file.c
src/market/store-util.c
src/object-flavor.c
src/object2.c
src/player-inventory.c
src/racial.c
src/rooms.c
src/selfinfo.c
src/spells1.c
src/spells2.c
src/spells3.c
src/targeting.c
src/util.c

index fd0b46a..455d8f6 100644 (file)
@@ -3280,6 +3280,7 @@ static byte get_string_for_search(player_type *player_ptr, object_type **o_handl
 
                case KTRL('r'):
                        back = TRUE;
+                       /* Fall through */
 
                case '\n':
                case '\r':
@@ -3317,6 +3318,7 @@ static byte get_string_for_search(player_type *player_ptr, object_type **o_handl
 
                        pos = i;
                }
+                       /* Fall through */
 
                case 0x7F:
                case KTRL('d'):
index 6a3faa9..44de6e4 100644 (file)
@@ -954,9 +954,8 @@ static void do_cmd_options_win(void)
                        {
                                window_flag[x] &= ~(1L << i);
                        }
-
-                       /* Fall through */
                }
+                       /* Fall through */
 
                case 'y':
                case 'Y':
index fb2e81d..603f4c8 100644 (file)
@@ -2801,6 +2801,7 @@ bool make_attack_normal(player_type *target_ptr, MONSTER_IDX m_idx)
                                                break;
                                        }
                                }
+                                       /* Fall through */
                                case RBE_HURT: /* AC軽減あり / Player armor reduces total damage */
                                {
                                        obvious = TRUE;
index d18a502..e9c4c68 100644 (file)
@@ -2808,11 +2808,11 @@ static errr parse_line_feature(floor_type *floor_ptr, char *buf)
        letter[index].special = 0;
        letter[index].random = RANDOM_NONE;
 
-       /* Fall through */
        switch (num)
        {
        case 9:
                letter[index].special = (s16b)atoi(zz[8]);
+               /* Fall through */
        case 8:
                if ((zz[7][0] == '*') && !zz[7][1])
                {
@@ -2823,6 +2823,7 @@ static errr parse_line_feature(floor_type *floor_ptr, char *buf)
                        letter[index].trap = f_tag_to_index(zz[7]);
                        if (letter[index].trap < 0) return PARSE_ERROR_UNDEFINED_TERRAIN_TAG;
                }
+               /* Fall through */
        case 7:
                if (zz[6][0] == '*')
                {
@@ -2840,6 +2841,7 @@ static errr parse_line_feature(floor_type *floor_ptr, char *buf)
                {
                        letter[index].artifact = (ARTIFACT_IDX)atoi(zz[6]);
                }
+               /* Fall through */
        case 6:
                if (zz[5][0] == '*')
                {
@@ -2850,6 +2852,7 @@ static errr parse_line_feature(floor_type *floor_ptr, char *buf)
                {
                        letter[index].ego = (EGO_IDX)atoi(zz[5]);
                }
+               /* Fall through */
        case 5:
                if (zz[4][0] == '*')
                {
@@ -2875,6 +2878,7 @@ static errr parse_line_feature(floor_type *floor_ptr, char *buf)
                {
                        letter[index].object = (IDX)atoi(zz[4]);
                }
+               /* Fall through */
        case 4:
                if (zz[3][0] == '*')
                {
@@ -2890,8 +2894,10 @@ static errr parse_line_feature(floor_type *floor_ptr, char *buf)
                {
                        letter[index].monster = (IDX)atoi(zz[3]);
                }
+               /* Fall through */
        case 3:
                letter[index].cave_info = atoi(zz[2]);
+               /* Fall through */
        case 2:
                if ((zz[1][0] == '*') && !zz[1][1])
                {
index 3436731..5c0ec2f 100644 (file)
@@ -427,11 +427,13 @@ bool store_will_buy(object_type *o_ptr)
                                if (my_strchr("?!", r_ptr->d_char)) break;
                        }
                }
+                       /* Fall through */
                case TV_POLEARM:
                case TV_SWORD:
                {
                        if (is_blessed_item(o_ptr)) break;
                }
+                       /* Fall through */
                default:
                        return FALSE;
                }
index e6167f8..aa88986 100644 (file)
@@ -560,6 +560,7 @@ char *object_desc_kosuu(char *t, object_type *o_ptr)
                        break;
                }
        }
+               /* Fall through */
        default:
        {
                if (o_ptr->number < 10)
index b8e9690..27df8dd 100644 (file)
@@ -1110,6 +1110,7 @@ int object_similar_part(object_type *o_ptr, object_type *j_ptr)
        {
                if (!object_is_known(o_ptr) || !object_is_known(j_ptr)) return 0;
        }
+               /* Fall through */
        case TV_BOLT:
        case TV_ARROW:
        case TV_SHOT:
index a832c93..1070f5c 100644 (file)
@@ -1425,9 +1425,8 @@ bool get_item(player_type *owner_ptr, OBJECT_IDX *cp, concptr pmt, concptr str,
                                done = TRUE;
                                break;
                        }
-
-                       /* Fall through */
                }
+                       /* Fall through */
 
                default:
                {
@@ -2655,9 +2654,8 @@ bool get_item_floor(player_type *owner_ptr, COMMAND_CODE *cp, concptr pmt, concp
                                done = TRUE;
                                break;
                        }
-
-                       /* Fall through */
                }
+                       /* Fall through */
 
                default:
                {
index e7380dc..60eec79 100644 (file)
@@ -399,6 +399,7 @@ static bool exe_racial_power(player_type *creature_ptr, s32b command)
                        if (retval) creature_ptr->energy_use = 10;
                        return (retval);
                }
+                       /* Fall through */
                case CLASS_MAGE:
                /* case CLASS_HIGH_MAGE: */
                case CLASS_SORCERER:
@@ -878,6 +879,7 @@ void do_cmd_racial_power(player_type *creature_ptr)
                        power_desc[num++].number = -3;
                        break;
                }
+               /* Fall through */
        case CLASS_MAGE:
                /* case CLASS_HIGH_MAGE: */
        case CLASS_SORCERER:
index d071c35..7f46466 100644 (file)
@@ -1838,9 +1838,9 @@ void build_recursive_room(player_type *player_ptr, POSITION x1, POSITION y1, POS
                xsize = x2 - x1;
                ysize = y2 - y1;
                power += 2;
-
-               /* Fall through */
        }
+               /* Fall through */
+
        case 4:
        {
                /* Try to build a room */
index 1ceeef0..1524bc0 100644 (file)
@@ -377,6 +377,7 @@ void self_knowledge(player_type *creature_ptr)
                break;
        case CLASS_HIGH_MAGE:
                if (creature_ptr->realm1 == REALM_HEX) break;
+               /* Fall through */
        case CLASS_MAGE:
        case CLASS_SORCERER:
                if (plev > 24)
index 6b7f3ee..dd4f053 100644 (file)
@@ -1967,6 +1967,7 @@ static bool project_m(player_type *caster_ptr, MONSTER_IDX who, POSITION r, POSI
                                break;
                        }
                }
+                       /* Fall through */
                case GF_OLD_HEAL:
                {
                        if (seen) obvious = TRUE;
index 9409663..e113e79 100644 (file)
@@ -2421,6 +2421,7 @@ bool activate_ty_curse(player_type *target_ptr, bool stop_ty, int *count)
                                earthquake(target_ptr, target_ptr->y, target_ptr->x, 5 + randint0(10), 0);
                                if (!one_in_(6)) break;
                        }
+                       /* Fall through */
                case 30: case 31:
                        if (!(*count))
                        {
@@ -2430,6 +2431,7 @@ bool activate_ty_curse(player_type *target_ptr, bool stop_ty, int *count)
                                take_hit(target_ptr, DAMAGE_NOESCAPE, dam, _("純粋な魔力の解放", "released pure mana"), -1);
                                if (!one_in_(6)) break;
                        }
+                       /* Fall through */
                case 32: case 33:
                        if (!(*count))
                        {
@@ -2438,6 +2440,7 @@ bool activate_ty_curse(player_type *target_ptr, bool stop_ty, int *count)
                                if (randint0(13)) (*count) += activate_hi_summon(target_ptr, target_ptr->y, target_ptr->x, FALSE);
                                if (!one_in_(6)) break;
                        }
+                       /* Fall through */
                case 34:
                        msg_print(_("エネルギーのうねりを感じた!", "You feel a surge of energy!"));
                        wall_breaker(target_ptr);
@@ -2448,19 +2451,24 @@ bool activate_ty_curse(player_type *target_ptr, bool stop_ty, int *count)
                        }
 
                        if (!one_in_(6)) break;
+                       /* Fall through */
                case 1: case 2: case 3: case 16: case 17:
                        aggravate_monsters(target_ptr, 0);
                        if (!one_in_(6)) break;
+                       /* Fall through */
                case 4: case 5: case 6:
                        (*count) += activate_hi_summon(target_ptr, target_ptr->y, target_ptr->x, FALSE);
                        if (!one_in_(6)) break;
+                       /* Fall through */
                case 7: case 8: case 9: case 18:
                        (*count) += summon_specific(target_ptr, 0, target_ptr->y, target_ptr->x, floor_ptr->dun_level, 0, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET));
                        if (!one_in_(6)) break;
+                       /* Fall through */
                case 10: case 11: case 12:
                        msg_print(_("経験値が体から吸い取られた気がする!", "You feel your experience draining away..."));
                        lose_exp(target_ptr, target_ptr->exp / 16);
                        if (!one_in_(6)) break;
+                       /* Fall through */
                case 13: case 14: case 15: case 19: case 20:
                {
                        bool is_statue = stop_ty;
@@ -2478,13 +2486,16 @@ bool activate_ty_curse(player_type *target_ptr, bool stop_ty, int *count)
 
                        if (!one_in_(6)) break;
                }
+                       /* Fall through */
                case 21: case 22: case 23:
                        (void)do_dec_stat(target_ptr, randint0(6));
                        if (!one_in_(6)) break;
+                       /* Fall through */
                case 24:
                        msg_print(_("ほえ?私は誰?ここで何してる?", "Huh? Who am I? What am I doing here?"));
                        lose_all_info(target_ptr);
                        if (!one_in_(6)) break;
+                       /* Fall through */
                case 25:
                        if ((floor_ptr->dun_level > 65) && !stop_ty)
                        {
@@ -2494,6 +2505,7 @@ bool activate_ty_curse(player_type *target_ptr, bool stop_ty, int *count)
                        }
 
                        if (!one_in_(6)) break;
+                       /* Fall through */
                default:
                        for (int i = 0; i < A_MAX; i++)
                        {
index 51618b3..3d42a80 100644 (file)
@@ -2958,6 +2958,7 @@ void blood_curse_to_enemy(player_type *caster_ptr, MONSTER_IDX m_idx)
                                earthquake(caster_ptr, m_ptr->fy, m_ptr->fx, 4 + randint0(4), 0);
                                if (!one_in_(6)) break;
                        }
+                       /* Fall through */
                case 3: case 4: case 5: case 6:
                        if (!count)
                        {
@@ -2967,6 +2968,7 @@ void blood_curse_to_enemy(player_type *caster_ptr, MONSTER_IDX m_idx)
                                project(caster_ptr, 0, 8, m_ptr->fy, m_ptr->fx, extra_dam, GF_MANA, curse_flg, -1);
                                if (!one_in_(6)) break;
                        }
+                       /* Fall through */
                case 7: case 8:
                        if (!count)
                        {
@@ -2976,16 +2978,20 @@ void blood_curse_to_enemy(player_type *caster_ptr, MONSTER_IDX m_idx)
                                if (one_in_(13)) count += activate_hi_summon(caster_ptr, m_ptr->fy, m_ptr->fx, TRUE);
                                if (!one_in_(6)) break;
                        }
+                       /* Fall through */
                case 9: case 10: case 11:
                        msg_print(_("エネルギーのうねりを感じた!", "You feel a surge of energy!"));
                        project(caster_ptr, 0, 7, m_ptr->fy, m_ptr->fx, 50, GF_DISINTEGRATE, curse_flg, -1);
                        if (!one_in_(6)) break;
+                       /* Fall through */
                case 12: case 13: case 14: case 15: case 16:
                        aggravate_monsters(caster_ptr, 0);
                        if (!one_in_(6)) break;
+                       /* Fall through */
                case 17: case 18:
                        count += activate_hi_summon(caster_ptr, m_ptr->fy, m_ptr->fx, TRUE);
                        if (!one_in_(6)) break;
+                       /* Fall through */
                case 19: case 20: case 21: case 22:
                {
                        bool pet = !one_in_(3);
@@ -2997,6 +3003,7 @@ void blood_curse_to_enemy(player_type *caster_ptr, MONSTER_IDX m_idx)
                        count += summon_specific(caster_ptr, (pet ? -1 : 0), caster_ptr->y, caster_ptr->x, (pet ? caster_ptr->lev * 2 / 3 + randint1(caster_ptr->lev / 2) : caster_ptr->current_floor_ptr->dun_level), 0, mode);
                        if (!one_in_(6)) break;
                }
+                       /* Fall through */
                case 23: case 24: case 25:
                        if (caster_ptr->hold_exp && (randint0(100) < 75)) break;
                        msg_print(_("経験値が体から吸い取られた気がする!", "You feel your experience draining away..."));
@@ -3004,6 +3011,7 @@ void blood_curse_to_enemy(player_type *caster_ptr, MONSTER_IDX m_idx)
                        if (caster_ptr->hold_exp) lose_exp(caster_ptr, caster_ptr->exp / 160);
                        else lose_exp(caster_ptr, caster_ptr->exp / 16);
                        if (!one_in_(6)) break;
+                       /* Fall through */
                case 26: case 27: case 28:
                {
                        if (one_in_(13))
index 4f99834..6a6e547 100644 (file)
@@ -1183,6 +1183,7 @@ bool target_set(player_type *creature_ptr, BIT_FLAGS mode)
                                y = creature_ptr->y;
                                x = creature_ptr->x;
                        }
+                               /* Fall through */
 
                        case 'o':
                        {
index 8111697..6c5f3f5 100644 (file)
@@ -2622,6 +2622,7 @@ bool askfor_aux(char *buf, int len, bool numpad_cursor)
 
                        pos = i;
                }
+                       /* Fall through */
 
                case 0x7F:
                case KTRL('d'):