Skip to content

Commit

Permalink
Add [[fallthrough]];.
Browse files Browse the repository at this point in the history
  • Loading branch information
Jarod42 committed Mar 3, 2024
1 parent 88ced16 commit b1da2b0
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/action/action_board.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ void COrder_Board::Execute(CUnit &unit) /* override */
return;
}
this->State = 1;
// FALL THROUGH
[[fallthrough]];
default: { // Move to transporter
if (this->State <= State_MoveToTransporterMax) {
const int pathRet = MoveToTransporter(unit);
Expand Down
2 changes: 1 addition & 1 deletion src/action/action_follow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ void COrder_Follow::Execute(CUnit &unit) /* override */
this->goalPos = goal->tilePos;
this->State = State_TargetReached;
}
// FALL THROUGH
[[fallthrough]];
default:
break;
}
Expand Down
4 changes: 1 addition & 3 deletions src/action/action_repair.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -243,9 +243,7 @@ void COrder_Repair::Execute(CUnit &unit) /* override */
Assert(this->ReparableTarget == this->GetGoal());

switch (this->State) {
case 0:
this->State = 1;
// FALL THROUGH
case 0: this->State = 1; [[fallthrough]];
case 1: { // Move near to target.
// FIXME: RESET FIRST!! Why? We move first and than check if
// something is in sight.
Expand Down
4 changes: 2 additions & 2 deletions src/action/action_spellcast.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ void COrder_SpellCast::Execute(CUnit &unit) /* override */
// FIXME FIXME FIXME: Check if already in range and skip straight to 2(casting)
unit.ReCast = 0; // repeat spell on next pass? (defaults to `no')
this->State = 1;
// FALL THROUGH
[[fallthrough]];
case 1: // Move to the target.
if (spell.Range != INFINITE_RANGE) {
if (SpellMoveToTarget(unit) == true) {
Expand All @@ -364,7 +364,7 @@ void COrder_SpellCast::Execute(CUnit &unit) /* override */
} else {
this->State = 2;
}
// FALL THROUGH
[[fallthrough]];
case 2: // Cast spell on the target.
if (!spell.IsCasterOnly() || spell.ForceUseAnimation) {
AnimateActionSpellCast(unit, *this);
Expand Down
2 changes: 1 addition & 1 deletion src/ui/botpanel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -883,7 +883,7 @@ bool IsButtonAllowed(const CUnit &unit, const ButtonAction &buttonaction)
if (!EnableTrainingQueue && unit.CurrentAction() == UnitAction::Train) {
break;
}
// FALL THROUGH
[[fallthrough]];
case ButtonCmd::UpgradeTo:
case ButtonCmd::Research:
case ButtonCmd::Build:
Expand Down
6 changes: 3 additions & 3 deletions src/ui/interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -660,7 +660,7 @@ static bool CommandKey(int key)
if (!(KeyModifiers & (ModifierAlt | ModifierControl))) {
break;
}
// FALL THROUGH
[[fallthrough]];
case SDLK_PERIOD: // ., ALT+I, CTRL+I: Find idle worker
UiFindIdleWorker();
break;
Expand All @@ -677,7 +677,7 @@ static bool CommandKey(int key)
if (!(KeyModifiers & (ModifierAlt | ModifierControl))) {
break;
}
// FALL THROUGH (CTRL+P, ALT+P)
[[fallthrough]]; // (CTRL+P, ALT+P)
case SDLK_PAUSE:
UiTogglePause();
break;
Expand Down Expand Up @@ -887,7 +887,7 @@ static void InputKey(int key)
NetworkSendChatMessage(chatMessage);
}
}
// FALL THROUGH
[[fallthrough]];
case SDLK_ESCAPE:
KeyState = EKeyState::Command;
UI.StatusLine.Clear();
Expand Down

0 comments on commit b1da2b0

Please sign in to comment.