Skip to content

Commit 1c8b33d

Browse files
authored
[GEN][ZH] Annotate fallthrough between various switch case labels (#1085)
1 parent a6e408b commit 1c8b33d

File tree

25 files changed

+62
-40
lines changed

25 files changed

+62
-40
lines changed

Core/Libraries/Source/WWVegas/WWLib/always.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@
4646
// TheSuperHackers @compile feliwir 17/04/2025 include utility macros for cross-platform compatibility
4747
#include <Utility/compat.h>
4848
#include <Utility/stdint_adapter.h>
49-
5049
#include <Utility/CppMacros.h>
5150

5251
// Disable warning about exception handling not being enabled. It's used as part of STL - in a part of STL we don't use.

Dependencies/Utility/Utility/CppMacros.h

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,12 @@
2121

2222
#if __cplusplus >= 201703L
2323
#define NOEXCEPT_17 noexcept
24+
#define REGISTER
25+
#define FALLTHROUGH [[fallthrough]]
2426
#else
2527
#define NOEXCEPT_17
28+
#define REGISTER register
29+
#define FALLTHROUGH
2630
#endif
2731

2832
// noexcept for methods of IUNKNOWN interface
@@ -38,12 +42,6 @@
3842
#define CPP_11(code)
3943
#endif
4044

41-
#if __cplusplus >= 201703L
42-
#define REGISTER
43-
#else
44-
#define REGISTER register
45-
#endif
46-
4745
#if __cplusplus < 201103L
4846
#define static_assert(expr, msg)
4947
#endif

Generals/Code/GameEngine/Source/Common/RandomValue.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -383,6 +383,7 @@ Real GameClientRandomVariable::getValue( void ) const
383383
if (m_low == m_high) {
384384
return m_low;
385385
} // else return as though a UNIFORM.
386+
FALLTHROUGH;
386387

387388
case UNIFORM:
388389
return GameClientRandomValueReal( m_low, m_high );
@@ -427,6 +428,7 @@ Real GameLogicRandomVariable::getValue( void ) const
427428
if (m_low == m_high) {
428429
return m_low;
429430
} // else return as though a UNIFORM.
431+
FALLTHROUGH;
430432

431433
case UNIFORM:
432434
return GameLogicRandomValueReal( m_low, m_high );

Generals/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/ScoreScreen.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1877,20 +1877,23 @@ void grabSinglePlayerInfo( void )
18771877
{
18781878
Bool isFriend = TRUE;
18791879

1880-
// set the string we'll be compairing to
1880+
// set the string we'll be comparing to
18811881
switch (j) {
18821882
case USA_ENEMY:
18831883
isFriend = FALSE;
1884+
FALLTHROUGH;
18841885
case USA_FRIEND:
18851886
side.set("America");
18861887
break;
18871888
case CHINA_ENEMY:
18881889
isFriend = FALSE;
1890+
FALLTHROUGH;
18891891
case CHINA_FRIEND:
18901892
side.set("China");
18911893
break;
18921894
case GLA_ENEMY:
1893-
isFriend = FALSE;
1895+
isFriend = FALSE;
1896+
FALLTHROUGH;
18941897
case GLA_FRIEND:
18951898
side.set("GLA");
18961899
break;

Generals/Code/GameEngine/Source/GameClient/GUI/GameWindowTransitionsStyles.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,8 @@ void FlashTransition::update( Int frame )
142142
} // end if
143143

144144
}
145+
FALLTHROUGH;
146+
145147
case FLASHTRANSITION_FADE_IN_2:
146148
case FLASHTRANSITION_FADE_IN_3:
147149
{
@@ -810,8 +812,8 @@ void ScaleUpTransition::update( Int frame )
810812
TheAudio->addAudioEvent( &buttonClick );
811813
} // end if
812814

813-
814815
}
816+
FALLTHROUGH;
815817

816818
case SCALEUPTRANSITION_2:
817819
case SCALEUPTRANSITION_3:
@@ -933,8 +935,8 @@ void ScoreScaleUpTransition::update( Int frame )
933935
TheAudio->addAudioEvent( &buttonClick );
934936
} // end if
935937

936-
937938
}
939+
FALLTHROUGH;
938940

939941
case SCORESCALEUPTRANSITION_2:
940942
case SCORESCALEUPTRANSITION_3:

Generals/Code/GameEngine/Source/GameClient/GameText.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -630,6 +630,7 @@ void GameTextManager::readToEndOfQuote( File *file, Char *in, Char *out, Char *w
630630
}
631631

632632
state = 1;
633+
FALLTHROUGH;
633634
case 1:
634635
if ( ( ch >= 'a' && ch <= 'z') || ( ch >= 'A' && ch <='Z') || (ch >= '0' && ch <= '9') || ch == '_' )
635636
{
@@ -638,6 +639,7 @@ void GameTextManager::readToEndOfQuote( File *file, Char *in, Char *out, Char *w
638639
break;
639640
}
640641
state = 2;
642+
FALLTHROUGH;
641643
case 2:
642644
break;
643645
}

Generals/Code/GameEngine/Source/GameClient/MessageStream/WindowXlat.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ GameMessageDisposition WindowTranslator::translateGameMessage(const GameMessage
204204
//If we release the button outside
205205
forceKeepMessage = TRUE;
206206
}
207-
//FALL THROUGH INTENTIONALLY!
207+
FALLTHROUGH; //FALL THROUGH INTENTIONALLY!
208208
}
209209
case GameMessage::MSG_RAW_MOUSE_POSITION:
210210
case GameMessage::MSG_RAW_MOUSE_LEFT_BUTTON_DOWN:

Generals/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate/HackInternetAIUpdate.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -494,28 +494,28 @@ StateReturnType HackInternetState::update()
494494
{
495495
break;
496496
}
497-
//If entry missing, fall through!
497+
FALLTHROUGH; //If entry missing, fall through!
498498
case LEVEL_ELITE:
499499
amount = ai->getEliteCashAmount();
500500
if( amount )
501501
{
502502
break;
503503
}
504-
//If entry missing, fall through!
504+
FALLTHROUGH; //If entry missing, fall through!
505505
case LEVEL_VETERAN:
506506
amount = ai->getVeteranCashAmount();
507507
if( amount )
508508
{
509509
break;
510510
}
511-
//If entry missing, fall through!
511+
FALLTHROUGH; //If entry missing, fall through!
512512
case LEVEL_REGULAR:
513513
amount = ai->getRegularCashAmount();
514514
if( amount )
515515
{
516516
break;
517517
}
518-
//If entry missing, fall through!
518+
FALLTHROUGH; //If entry missing, fall through!
519519
default:
520520
amount = 1;
521521
break;

Generals/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate/JetAIUpdate.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2216,7 +2216,7 @@ void JetAIUpdate::aiDoCommand(const AICommandParms* parms)
22162216
if (isParkedAt(parms->m_obj))
22172217
return;
22182218

2219-
// else fall thru to the default case!
2219+
FALLTHROUGH; // else fall thru to the default case!
22202220

22212221
default:
22222222
{

Generals/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate/MissileAIUpdate.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -652,6 +652,8 @@ UpdateSleepTime MissileAIUpdate::update()
652652
{
653653
break;
654654
}
655+
FALLTHROUGH;
656+
655657
case IGNITION:
656658
doIgnitionState();
657659
break;

0 commit comments

Comments
 (0)