Skip to content

Commit 812d386

Browse files
committed
[GEN][ZH] Annotate fallthrough between various switch case labels
1 parent ef5fea1 commit 812d386

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;

Generals/Code/GameEngine/Source/GameLogic/ScriptEngine/Scripts.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1776,7 +1776,7 @@ void Parameter::qualify(const AsciiString& qualifier,
17761776
if (m_string == THIS_TEAM) {
17771777
break;
17781778
}
1779-
/// otherwise drop down & qualify.
1779+
FALLTHROUGH; /// otherwise drop down & qualify.
17801780
case SCRIPT:
17811781
case COUNTER:
17821782
case FLAG:

Generals/Code/Libraries/Source/WWVegas/WW3D2/meshmdlio.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -344,23 +344,23 @@ WW3DErrorType MeshModelClass::Load_W3D(ChunkLoadClass & cload)
344344
Set_Flag (PRELIT_LIGHTMAP_MULTI_TEXTURE, true);
345345
break;
346346
}
347-
// Else fall thru...
347+
FALLTHROUGH; // Else fall thru...
348348

349349
case WW3D::PRELIT_MODE_LIGHTMAP_MULTI_PASS:
350350
if (context->Header.Attributes & W3D_MESH_FLAG_PRELIT_LIGHTMAP_MULTI_PASS) {
351351
context->PrelitChunkID = W3D_CHUNK_PRELIT_LIGHTMAP_MULTI_PASS;
352352
Set_Flag (PRELIT_LIGHTMAP_MULTI_PASS, true);
353353
break;
354354
}
355-
// Else fall thru...
355+
FALLTHROUGH; // Else fall thru...
356356

357357
case WW3D::PRELIT_MODE_VERTEX:
358358
if (context->Header.Attributes & W3D_MESH_FLAG_PRELIT_VERTEX) {
359359
context->PrelitChunkID = W3D_CHUNK_PRELIT_VERTEX;
360360
Set_Flag (PRELIT_VERTEX, true);
361361
break;
362362
}
363-
// Else fall thru...
363+
FALLTHROUGH; // Else fall thru...
364364

365365
default:
366366

GeneralsMD/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 );

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2145,20 +2145,23 @@ void grabSinglePlayerInfo( void )
21452145
{
21462146
Bool isFriend = TRUE;
21472147

2148-
// set the string we'll be compairing to
2148+
// set the string we'll be comparing to
21492149
switch (j) {
21502150
case USA_ENEMY:
21512151
isFriend = FALSE;
2152+
FALLTHROUGH;
21522153
case USA_FRIEND:
21532154
side.set("USA");
21542155
break;
21552156
case CHINA_ENEMY:
21562157
isFriend = FALSE;
2158+
FALLTHROUGH;
21572159
case CHINA_FRIEND:
21582160
side.set("China");
21592161
break;
21602162
case GLA_ENEMY:
2161-
isFriend = FALSE;
2163+
isFriend = FALSE;
2164+
FALLTHROUGH;
21622165
case GLA_FRIEND:
21632166
side.set("GLA");
21642167
break;

GeneralsMD/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:

GeneralsMD/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
}

GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/CommandXlat.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3704,7 +3704,7 @@ GameMessageDisposition CommandTranslator::translateGameMessage(const GameMessage
37043704

37053705
break;
37063706
}
3707-
//intentional fall through
3707+
FALLTHROUGH; //intentional fall through
37083708
}
37093709
case GameMessage::MSG_MOUSE_RIGHT_CLICK:
37103710
{
@@ -3767,7 +3767,7 @@ GameMessageDisposition CommandTranslator::translateGameMessage(const GameMessage
37673767

37683768
break;
37693769
}
3770-
//intentional fall through
3770+
FALLTHROUGH; //intentional fall through
37713771
}
37723772
case GameMessage::MSG_MOUSE_LEFT_CLICK:
37733773
{

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ GameMessageDisposition WindowTranslator::translateGameMessage(const GameMessage
222222
//If we release the button outside
223223
forceKeepMessage = TRUE;
224224
}
225-
//FALL THROUGH INTENTIONALLY!
225+
FALLTHROUGH; //FALL THROUGH INTENTIONALLY!
226226
}
227227
case GameMessage::MSG_RAW_MOUSE_POSITION:
228228
case GameMessage::MSG_RAW_MOUSE_LEFT_BUTTON_DOWN:

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -506,28 +506,28 @@ StateReturnType HackInternetState::update()
506506
{
507507
break;
508508
}
509-
//If entry missing, fall through!
509+
FALLTHROUGH; //If entry missing, fall through!
510510
case LEVEL_ELITE:
511511
amount = ai->getEliteCashAmount();
512512
if( amount )
513513
{
514514
break;
515515
}
516-
//If entry missing, fall through!
516+
FALLTHROUGH; //If entry missing, fall through!
517517
case LEVEL_VETERAN:
518518
amount = ai->getVeteranCashAmount();
519519
if( amount )
520520
{
521521
break;
522522
}
523-
//If entry missing, fall through!
523+
FALLTHROUGH; //If entry missing, fall through!
524524
case LEVEL_REGULAR:
525525
amount = ai->getRegularCashAmount();
526526
if( amount )
527527
{
528528
break;
529529
}
530-
//If entry missing, fall through!
530+
FALLTHROUGH; //If entry missing, fall through!
531531
default:
532532
amount = 1;
533533
break;

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

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

2453-
// else fall thru to the default case!
2453+
FALLTHROUGH; // else fall thru to the default case!
24542454

24552455
default:
24562456
{

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -707,6 +707,8 @@ UpdateSleepTime MissileAIUpdate::update()
707707
{
708708
break;
709709
}
710+
FALLTHROUGH;
711+
710712
case IGNITION:
711713
doIgnitionState();
712714
break;

GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/SpecialAbilityUpdate.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ UpdateSleepTime SpecialAbilityUpdate::update( void )
280280
// it's been captured by a colleague! we should stop.
281281
shouldAbort = TRUE;
282282
}
283-
//deliberately falling through...
283+
FALLTHROUGH; //deliberately falling through...
284284
}
285285
case SPECIAL_BLACKLOTUS_STEAL_CASH_HACK:
286286
case SPECIAL_BOOBY_TRAP:
@@ -309,7 +309,7 @@ UpdateSleepTime SpecialAbilityUpdate::update( void )
309309
{
310310
if ( target->isKindOf( KINDOF_STRUCTURE ) )
311311
shouldAbort = TRUE;
312-
//deliberately falling through
312+
FALLTHROUGH; //deliberately falling through
313313
}
314314
case SPECIAL_BLACKLOTUS_DISABLE_VEHICLE_HACK:
315315
{

0 commit comments

Comments
 (0)