Skip to content

Commit 8aa4016

Browse files
committed
[ZH] Fix loop index type for unsigned integer comparison warnings (#804)
1 parent 979c3ed commit 8aa4016

File tree

18 files changed

+28
-28
lines changed

18 files changed

+28
-28
lines changed

GeneralsMD/Code/GameEngine/Source/Common/RTS/AcademyStats.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1081,7 +1081,7 @@ Bool AcademyStats::calculateAcademyAdvice( AcademyAdviceInfo *info )
10811081
info->numTips = 0;
10821082

10831083
//Build the header for each string.
1084-
for( Int i = 0; i < maxAdviceTips; i++ )
1084+
for( UnsignedInt i = 0; i < maxAdviceTips; i++ )
10851085
{
10861086
info->advice[ i ].format( UnicodeString( L"\n\n" ) );
10871087
}

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -1511,7 +1511,7 @@ void populatePlayerInfo( Player *player, Int pos)
15111511
AcademyAdviceInfo info;
15121512
if( player->getAcademyStats()->calculateAcademyAdvice( &info ) )
15131513
{
1514-
for( Int i = 0; i < info.numTips; i++ )
1514+
for( UnsignedInt i = 0; i < info.numTips; i++ )
15151515
{
15161516
GadgetListBoxAddEntryText( listboxAcademyWindowScoreScreen, info.advice[ i ], GameSpyColor[GSCOLOR_DEFAULT], -1 );
15171517
}

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ GameClient::~GameClient()
218218
TheVideoPlayer = NULL;
219219

220220
// destroy all translators
221-
for( Int i = 0; i < m_numTranslators; i++ )
221+
for( UnsignedInt i = 0; i < m_numTranslators; i++ )
222222
TheMessageStream->removeTranslator( m_translators[ i ] );
223223
m_numTranslators = 0;
224224
m_commandTranslator = NULL;

GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -3491,7 +3491,7 @@ void InGameUI::postDraw( void )
34913491
UnsignedByte r, g, b, a;
34923492
GameGetColorComponents( m_militarySubtitle->color, &r, &g, &b, &a );
34933493
dropColor = GameMakeColor( 0, 0, 0, a );
3494-
for(Int i = 0; i <= m_militarySubtitle->currentDisplayString; i++)
3494+
for(UnsignedInt i = 0; i <= m_militarySubtitle->currentDisplayString; i++)
34953495
{
34963496
m_militarySubtitle->displayStrings[i]->draw(pos.x,pos.y, m_militarySubtitle->color,dropColor );
34973497
Int height;
@@ -4123,7 +4123,7 @@ void InGameUI::removeMilitarySubtitle( void )
41234123
TheInGameUI->clearTooltipsDisabled();
41244124

41254125
// loop through and free up the display strings
4126-
for(Int i = 0; i <= m_militarySubtitle->currentDisplayString; i ++)
4126+
for(UnsignedInt i = 0; i <= m_militarySubtitle->currentDisplayString; i ++)
41274127
{
41284128
TheDisplayStringManager->freeDisplayString(m_militarySubtitle->displayStrings[i]);
41294129
m_militarySubtitle->displayStrings[i] = NULL;

GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Behavior/CountermeasuresBehavior.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ void CountermeasuresBehavior::launchVolley()
301301
Object *obj = getObject();
302302

303303
Real volleySize = (Real)data->m_volleySize;
304-
for( int i = 0; i < data->m_volleySize; i++ )
304+
for( UnsignedInt i = 0; i < data->m_volleySize; i++ )
305305
{
306306
//Each flare in a volley will calculate a different vector to fly out. We have a +/- angle to
307307
//spread out equally. With only one flare, it'll come straight out the back. Two flares will

GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Collide/CrateCollide/UnitCrateCollide.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ Bool UnitCrateCollide::executeCrateBehavior( Object *other )
6363
return FALSE;
6464
}
6565

66-
for( Int unitIndex = 0; unitIndex < unitCount; unitIndex++ )
66+
for( UnsignedInt unitIndex = 0; unitIndex < unitCount; unitIndex++ )
6767
{
6868
Team *creationTeam = other->getControllingPlayer()->getDefaultTeam();
6969
Object *newObj = TheThingFactory->newObject( unitType, creationTeam );

GeneralsMD/Code/GameEngine/Source/GameLogic/Object/ObjectCreationList.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ class DeliverPayloadNugget : public ObjectCreationNugget
322322
}
323323

324324
Object *firstTransport = NULL;
325-
for( Int formationIndex = 0; formationIndex < m_formationSize; formationIndex++ )
325+
for( UnsignedInt formationIndex = 0; formationIndex < m_formationSize; formationIndex++ )
326326
{
327327
Coord3D offset;
328328
offset.zero();

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ void EMPUpdate::doDisableAttack( void )
307307

308308
UnsignedInt emitterCount = MAX(15, REAL_TO_INT_CEIL(data->m_sparksPerCubicFoot * victimVolume));
309309

310-
for (Int e = 0 ; e < emitterCount; ++e)
310+
for (UnsignedInt e = 0 ; e < emitterCount; ++e)
311311
{
312312

313313
ParticleSystem *sys = TheParticleSystemManager->createParticleSystem(tmp);

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

+4-4
Original file line numberDiff line numberDiff line change
@@ -799,7 +799,7 @@ void ParticleUplinkCannonUpdate::createOuterNodeParticleSystems( IntensityTypes
799799
if( tmp )
800800
{
801801
ParticleSystem *system;
802-
for( int i = 0; i < data->m_outerEffectNumBones; i++ )
802+
for( UnsignedInt i = 0; i < data->m_outerEffectNumBones; i++ )
803803
{
804804
system = TheParticleSystemManager->createParticleSystem( tmp );
805805
if( system )
@@ -844,7 +844,7 @@ void ParticleUplinkCannonUpdate::createConnectorLasers( IntensityTypes intensity
844844
const ThingTemplate *thingTemplate = TheThingFactory->findTemplate( str );
845845
if( thingTemplate )
846846
{
847-
for( int i = 0; i < data->m_outerEffectNumBones; i++ )
847+
for( UnsignedInt i = 0; i < data->m_outerEffectNumBones; i++ )
848848
{
849849
Drawable *beam = TheThingFactory->newDrawable( thingTemplate );
850850
if( beam )
@@ -1021,7 +1021,7 @@ void ParticleUplinkCannonUpdate::createGroundHitParticleSystem( IntensityTypes i
10211021
void ParticleUplinkCannonUpdate::removeAllEffects()
10221022
{
10231023
const ParticleUplinkCannonUpdateModuleData *data = getParticleUplinkCannonUpdateModuleData();
1024-
for( int i = 0; i < data->m_outerEffectNumBones; i++ )
1024+
for( UnsignedInt i = 0; i < data->m_outerEffectNumBones; i++ )
10251025
{
10261026
if( m_outerSystemIDs && m_outerSystemIDs[ i ] )
10271027
{
@@ -1074,7 +1074,7 @@ Bool ParticleUplinkCannonUpdate::calculateDefaultInformation()
10741074
return FALSE;
10751075
}
10761076

1077-
for( int i = 0; i < data->m_outerEffectNumBones; i++ )
1077+
for( UnsignedInt i = 0; i < data->m_outerEffectNumBones; i++ )
10781078
{
10791079
m_laserBeamIDs[ i ] = INVALID_DRAWABLE_ID;
10801080
m_outerSystemIDs[ i ] = INVALID_PARTICLE_SYSTEM_ID;

GeneralsMD/Code/GameEngine/Source/GameLogic/System/GameLogic.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -764,7 +764,7 @@ static void populateRandomSideAndColor( GameInfo *game )
764764
// get a few values at random to get rid of the dreck.
765765
// there's no mathematical basis for this, but empirically, it helps a lot.
766766
UnsignedInt silly = GetGameLogicRandomSeed() % 7;
767-
for (Int poo = 0; poo < silly; ++poo)
767+
for (UnsignedInt poo = 0; poo < silly; ++poo)
768768
{
769769
GameLogicRandomValue(0, 1); // ignore result
770770
}

GeneralsMD/Code/GameEngine/Source/GameNetwork/ConnectionManager.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -231,8 +231,8 @@ void ConnectionManager::reset()
231231
m_transport = NULL;
232232
}
233233

234-
Int i = 0;
235-
for (; i < NUM_CONNECTIONS; ++i) {
234+
UnsignedInt i = 0;
235+
for (; i < (UnsignedInt)NUM_CONNECTIONS; ++i) {
236236
if (m_connections[i] != NULL) {
237237
m_connections[i]->deleteInstance();
238238
m_connections[i] = NULL;
@@ -278,7 +278,7 @@ void ConnectionManager::reset()
278278
m_latencyAverages[i] = 0.0;
279279
}
280280

281-
for (i = 0; i < MAX_SLOTS; ++i) {
281+
for (i = 0; i < (UnsignedInt)MAX_SLOTS; ++i) {
282282
m_packetRouterFallback[i] = -1;
283283
}
284284

GeneralsMD/Code/GameEngine/Source/GameNetwork/FrameMetrics.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ void FrameMetrics::init() {
7272
m_averageLatency = (Real)0.2;
7373
m_minimumCushion = -1;
7474

75-
Int i = 0;
75+
UnsignedInt i = 0;
7676
for (; i < TheGlobalData->m_networkFPSHistoryLength; ++i) {
7777
m_fpsList[i] = 30.0;
7878
}

GeneralsMD/Code/GameEngine/Source/GameNetwork/NAT.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ NATConnectionState NAT::connectionUpdate() {
317317

318318
// check to see if its time to send out our keepalives.
319319
if (timeGetTime() >= m_nextKeepaliveTime) {
320-
for (Int node = 0; node < m_numNodes; ++node) {
320+
for (UnsignedInt node = 0; node < m_numNodes; ++node) {
321321
if (m_myConnections[node] == TRUE) {
322322
// we've made this connection, send a keepalive.
323323
Int slotIndex = m_connectionNodes[node].m_slotIndex;
@@ -637,7 +637,7 @@ Int NAT::getSlotPort(Int slot) {
637637
}
638638

639639
void NAT::generatePortNumbers(GameSlot *slotList[], Int localSlot) {
640-
for (Int i = 0; i < MAX_SLOTS; ++i) {
640+
for (UnsignedInt i = 0; i < (UnsignedInt)MAX_SLOTS; ++i) {
641641
if (slotList[i] != NULL) {
642642
if ((i == localSlot) && (TheWritableGlobalData->m_firewallPortOverride != 0)) {
643643
slotList[i]->setPort(TheWritableGlobalData->m_firewallPortOverride);
@@ -950,7 +950,7 @@ Bool NAT::allConnectionsDone() {
950950

951951
Bool NAT::allConnectionsDoneThisRound() {
952952
Bool retval = TRUE;
953-
for (Int i = 0; (i < m_numNodes) && (retval == TRUE); ++i) {
953+
for (UnsignedInt i = 0; (i < m_numNodes) && (retval == TRUE); ++i) {
954954
if ((m_connectionStates[i] != NATCONNECTIONSTATE_DONE) && (m_connectionStates[i] != NATCONNECTIONSTATE_FAILED)) {
955955
retval = FALSE;
956956
}

GeneralsMD/Code/GameEngine/Source/GameNetwork/NetCommandWrapperList.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ NetCommandWrapperListNode::NetCommandWrapperListNode(NetWrapperCommandMsg *msg)
4646
m_chunksPresent = NEW Bool[m_numChunks]; // pool[]ify
4747
m_numChunksPresent = 0;
4848

49-
for (Int i = 0; i < m_numChunks; ++i) {
49+
for (UnsignedInt i = 0; i < m_numChunks; ++i) {
5050
m_chunksPresent[i] = FALSE;
5151
}
5252

GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DLaserDraw.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ W3DLaserDraw::W3DLaserDraw( Thing *thing, const ModuleData* moduleData ) :
156156
//Allocate an array of lines equal to the number of beams * segments
157157
m_line3D = NEW SegmentedLineClass *[ data->m_numBeams * data->m_segments ];
158158

159-
for( int segment = 0; segment < data->m_segments; segment++ )
159+
for( UnsignedInt segment = 0; segment < data->m_segments; segment++ )
160160
{
161161
//We don't care about segment positioning yet until we actually set the position
162162

@@ -225,7 +225,7 @@ W3DLaserDraw::~W3DLaserDraw( void )
225225
{
226226
const W3DLaserDrawModuleData *data = getW3DLaserDrawModuleData();
227227

228-
for( int i = 0; i < data->m_numBeams * data->m_segments; i++ )
228+
for( UnsignedInt i = 0; i < data->m_numBeams * data->m_segments; i++ )
229229
{
230230

231231
// remove line from scene
@@ -272,7 +272,7 @@ void W3DLaserDraw::doDrawModule(const Matrix3D* transformMtx)
272272

273273
Vector3 laserPoints[ 2 ];
274274

275-
for( int segment = 0; segment < data->m_segments; segment++ )
275+
for( UnsignedInt segment = 0; segment < data->m_segments; segment++ )
276276
{
277277
if( data->m_arcHeight > 0.0f && data->m_segments > 1 )
278278
{

GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DModelDraw.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -3962,7 +3962,7 @@ void W3DModelDraw::doHideShowProjectileObjects( UnsignedInt showCount, UnsignedI
39623962
ModelConditionInfo::HideShowSubObjInfo oneEntry;
39633963
if (m_curState->m_weaponProjectileHideShowName[slot].isEmpty())
39643964
{
3965-
for( Int projectileIndex = 0; projectileIndex < maxCount; projectileIndex++ )
3965+
for( UnsignedInt projectileIndex = 0; projectileIndex < maxCount; projectileIndex++ )
39663966
{
39673967
oneEntry.subObjName.format("%s%02d", m_curState->m_weaponProjectileLaunchBoneName[slot].str(), (projectileIndex + 1));
39683968
oneEntry.hide = ((projectileIndex + 1) <= hideCount);

GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Water/W3DWater.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -3475,7 +3475,7 @@ void WaterRenderObjClass::xfer( Xfer *xfer )
34753475
} // end if
34763476

34773477
// xfer each of the mesh data points
3478-
for( Int i = 0; i < m_meshDataSize; ++i )
3478+
for( UnsignedInt i = 0; i < m_meshDataSize; ++i )
34793479
{
34803480

34813481
// height

GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/pointgr.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1695,7 +1695,7 @@ void PointGroupClass::RenderVolumeParticle(RenderInfoClass &rinfo, unsigned int
16951695

16961696

16971697
//// VOLUME_PARTICLE LOOP ///////////////
1698-
for ( int t = 0; t < depth; ++t )
1698+
for ( unsigned int t = 0; t < depth; ++t )
16991699
{
17001700

17011701

0 commit comments

Comments
 (0)