Skip to content

Commit 16b9de1

Browse files
author
Bart Roossien
committed
[ZH] Fixed warnings about signed/unsigned integer comparison (TheSuperHackers#534)
1 parent 3046c42 commit 16b9de1

File tree

10 files changed

+17
-18
lines changed

10 files changed

+17
-18
lines changed

GeneralsMD/Code/GameEngine/Include/GameClient/GameClient.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ inline Drawable* GameClient::findDrawableByID( const DrawableID id )
249249
//
250250
// return (*it).second;
251251

252-
if( (Int)id < m_drawableVector.size() )
252+
if( static_cast<size_t>(id) < m_drawableVector.size() )
253253
return m_drawableVector[(Int)id];
254254

255255
return NULL;

GeneralsMD/Code/GameEngine/Include/GameLogic/GameLogic.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,7 @@ inline Object* GameLogic::findObjectByID( ObjectID id )
417417
// return NULL;
418418
//
419419
// return (*it).second;
420-
if( (Int)id < m_objVector.size() )
420+
if( static_cast<size_t>(id) < m_objVector.size() )
421421
return m_objVector[(Int)id];
422422

423423
return NULL;

GeneralsMD/Code/GameEngine/Source/Common/PartitionSolver.cpp

+4-5
Original file line numberDiff line numberDiff line change
@@ -77,14 +77,13 @@ void PartitionSolver::solve(void)
7777

7878
Int minSizeForAllData = 0;
7979
Int slotsAllotted = 0;
80-
Int i, j;
8180

8281
// first, determine whether there is an actual solution, or we're going to have to fudge it.
83-
for (i = 0; i < m_data.size(); ++i) {
82+
for (size_t i = 0; i < m_data.size(); ++i) {
8483
minSizeForAllData += m_data[i].second;
8584
}
8685

87-
for (i = 0; i < m_spacesForData.size(); ++i) {
86+
for (size_t i = 0; i < m_spacesForData.size(); ++i) {
8887
slotsAllotted += m_spacesForData[i].second;
8988
}
9089

@@ -103,9 +102,9 @@ void PartitionSolver::solve(void)
103102
{
104103
// we prefer the fast, but not necessarily correct solution
105104
// simply start placing the stuff. Skip things you can't place.
106-
for (i = 0; i < m_data.size(); ++i)
105+
for (size_t i = 0; i < m_data.size(); ++i)
107106
{
108-
for (j = 0; j < spacesStillAvailable.size(); ++j)
107+
for (size_t j = 0; j < spacesStillAvailable.size(); ++j)
109108
{
110109
if (m_data[i].second <= spacesStillAvailable[j].second)
111110
{

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( size_t i = 0; i < maxAdviceTips; i++ )
10851085
{
10861086
info->advice[ i ].format( UnicodeString( L"\n\n" ) );
10871087
}

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ void PlayerTemplateStore::update()
294294

295295
Int PlayerTemplateStore::getTemplateNumByName(AsciiString name) const
296296
{
297-
for (Int num = 0; num < m_playerTemplates.size(); num++)
297+
for (size_t num = 0; num < m_playerTemplates.size(); num++)
298298
{
299299
if (m_playerTemplates[num].getName().compareNoCase(name.str()) == 0)
300300
return num;

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

+3-3
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ SpecialPowerStore::~SpecialPowerStore( void )
255255
{
256256

257257
// delete all templates
258-
for( Int i = 0; i < m_specialPowerTemplates.size(); ++i )
258+
for( size_t i = 0; i < m_specialPowerTemplates.size(); ++i )
259259
m_specialPowerTemplates[ i ]->deleteInstance();
260260

261261
// erase the list
@@ -272,7 +272,7 @@ SpecialPowerTemplate* SpecialPowerStore::findSpecialPowerTemplatePrivate( AsciiS
272272
{
273273

274274
// search the template list for matching name
275-
for( Int i = 0; i < m_specialPowerTemplates.size(); ++i )
275+
for( size_t i = 0; i < m_specialPowerTemplates.size(); ++i )
276276
if( m_specialPowerTemplates[ i ]->getName() == name )
277277
return m_specialPowerTemplates[ i ];
278278

@@ -287,7 +287,7 @@ const SpecialPowerTemplate *SpecialPowerStore::findSpecialPowerTemplateByID( Uns
287287
{
288288

289289
// search the template list for matching name
290-
for( Int i = 0; i < m_specialPowerTemplates.size(); ++i )
290+
for( size_t i = 0; i < m_specialPowerTemplates.size(); ++i )
291291
if( m_specialPowerTemplates[ i ]->getID() == id )
292292
return m_specialPowerTemplates[ i ];
293293

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -3368,7 +3368,7 @@ void ControlBar::populateSpecialPowerShortcut( Player *player)
33683368
//button specifying a vector of sciences in the command button.
33693369
Int bestIndex = -1;
33703370
ScienceType science;
3371-
for( Int scienceIndex = 0; scienceIndex < commandButton->getScienceVec().size(); ++scienceIndex )
3371+
for( size_t scienceIndex = 0; scienceIndex < commandButton->getScienceVec().size(); ++scienceIndex )
33723372
{
33733373
science = commandButton->getScienceVec()[ scienceIndex ];
33743374

GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBarCommand.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@ void ControlBar::populateCommand( Object *obj )
372372
//button specifying a vector of sciences in the command button.
373373
Int bestIndex = -1;
374374
ScienceType science;
375-
for( Int scienceIndex = 0; scienceIndex < commandButton->getScienceVec().size(); ++scienceIndex )
375+
for( size_t scienceIndex = 0; scienceIndex < commandButton->getScienceVec().size(); ++scienceIndex )
376376
{
377377
science = commandButton->getScienceVec()[ scienceIndex ];
378378

@@ -1240,7 +1240,7 @@ CommandAvailability ControlBar::getCommandAvailability( const CommandButton *com
12401240
if( TheUpgradeCenter->canAffordUpgrade( player, command->getUpgradeTemplate() ) == FALSE )
12411241
return COMMAND_RESTRICTED;//COMMAND_CANT_AFFORD;
12421242

1243-
for( Int i = 0; i < command->getScienceVec().size(); i++ )
1243+
for( size_t i = 0; i < command->getScienceVec().size(); i++ )
12441244
{
12451245
ScienceType st = command->getScienceVec()[ i ];
12461246
if( !player->hasScience( st ) )
@@ -1276,7 +1276,7 @@ CommandAvailability ControlBar::getCommandAvailability( const CommandButton *com
12761276
if( TheUpgradeCenter->canAffordUpgrade( player, command->getUpgradeTemplate() ) == FALSE )
12771277
return COMMAND_RESTRICTED;//COMMAND_CANT_AFFORD;
12781278

1279-
for( Int i = 0; i < command->getScienceVec().size(); i++ )
1279+
for( size_t i = 0; i < command->getScienceVec().size(); i++ )
12801280
{
12811281
ScienceType st = command->getScienceVec()[ i ];
12821282
if( !player->hasScience( st ) )

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -3332,7 +3332,7 @@ Bool W3DModelDraw::getProjectileLaunchOffset(
33323332
}
33333333
else
33343334
{
3335-
if (specificBarrelToUse < 0 || specificBarrelToUse >= wbvec.size())
3335+
if (specificBarrelToUse < 0 || specificBarrelToUse >= static_cast<long>(wbvec.size()))
33363336
specificBarrelToUse = 0;
33373337

33383338
if (launchPos)

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)