Skip to content

[GEN][ZH] Fix compiler warnings for signed/unsigned mismatch of loop indices #804

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 19, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Core/Libraries/Source/WWVegas/WW3D2/pointgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1695,7 +1695,7 @@ void PointGroupClass::RenderVolumeParticle(RenderInfoClass &rinfo, unsigned int


//// VOLUME_PARTICLE LOOP ///////////////
for ( int t = 0; t < depth; ++t )
for ( unsigned int t = 0; t < depth; ++t )
{


Expand Down
2 changes: 1 addition & 1 deletion Generals/Code/GameEngine/Source/Common/PartitionSolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ void PartitionSolver::solve(void)

Int minSizeForAllData = 0;
Int slotsAllotted = 0;
Int i, j;
size_t i, j;

// first, determine whether there is an actual solution, or we're going to have to fudge it.
for (i = 0; i < m_data.size(); ++i) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ void ProductionPrerequisite::init()
//=============================================================================
void ProductionPrerequisite::resolveNames()
{
for (Int i = 0; i < m_prereqUnits.size(); i++)
for (size_t i = 0; i < m_prereqUnits.size(); i++)
{

//
Expand Down Expand Up @@ -118,7 +118,7 @@ Int ProductionPrerequisite::calcNumPrereqUnitsOwned(const Player *player, Int co
Int ProductionPrerequisite::getAllPossibleBuildFacilityTemplates(const ThingTemplate* tmpls[], Int maxtmpls) const
{
Int count = 0;
for (int i = 0; i < m_prereqUnits.size(); i++)
for (size_t i = 0; i < m_prereqUnits.size(); i++)
{
if (i > 0 && !(m_prereqUnits[i].flags & UNIT_OR_WITH_PREV))
break;
Expand Down Expand Up @@ -213,7 +213,7 @@ void ProductionPrerequisite::addUnitPrereq( AsciiString unit, Bool orUnitWithPre
void ProductionPrerequisite::addUnitPrereq( const std::vector<AsciiString>& units )
{
Bool orWithPrevious = false;
for (int i = 0; i < units.size(); ++i)
for (size_t i = 0; i < units.size(); ++i)
{
addUnitPrereq(units[i], orWithPrevious);
orWithPrevious = true;
Expand Down
6 changes: 3 additions & 3 deletions Generals/Code/GameEngine/Source/Common/RTS/SpecialPower.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ SpecialPowerStore::~SpecialPowerStore( void )
{

// delete all templates
for( Int i = 0; i < m_specialPowerTemplates.size(); ++i )
for( size_t i = 0; i < m_specialPowerTemplates.size(); ++i )
deleteInstance(m_specialPowerTemplates[ i ]);

// erase the list
Expand All @@ -242,7 +242,7 @@ SpecialPowerTemplate* SpecialPowerStore::findSpecialPowerTemplatePrivate( AsciiS
{

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

Expand All @@ -257,7 +257,7 @@ const SpecialPowerTemplate *SpecialPowerStore::findSpecialPowerTemplateByID( Uns
{

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@ static void findHighFileNumber( AsciiString filename, void *userData )

// strip off the extension at the end of the filename
AsciiString nameOnly = filename;
for( Int count = 0; count < strlen( SAVE_GAME_EXTENSION ); count++ )
for( size_t count = 0; count < strlen( SAVE_GAME_EXTENSION ); count++ )
nameOnly.removeLastChar();

// convert filename (which is only numbers) to a number
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3309,7 +3309,7 @@ void ControlBar::populateSpecialPowerShortcut( Player *player)
//button specifying a vector of sciences in the command button.
Int bestIndex = -1;
ScienceType science;
for( Int scienceIndex = 0; scienceIndex < commandButton->getScienceVec().size(); ++scienceIndex )
for( size_t scienceIndex = 0; scienceIndex < commandButton->getScienceVec().size(); ++scienceIndex )
{
science = commandButton->getScienceVec()[ scienceIndex ];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ void ControlBar::populateCommand( Object *obj )
//button specifying a vector of sciences in the command button.
Int bestIndex = -1;
ScienceType science;
for( Int scienceIndex = 0; scienceIndex < commandButton->getScienceVec().size(); ++scienceIndex )
for( size_t scienceIndex = 0; scienceIndex < commandButton->getScienceVec().size(); ++scienceIndex )
{
science = commandButton->getScienceVec()[ scienceIndex ];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -699,7 +699,7 @@ CBCommandStatus ControlBar::processCommandUI( GameWindow *control,

ScienceType st = SCIENCE_INVALID;
Player *player = ThePlayerList->getLocalPlayer();
for(Int i = 0; i < commandButton->getScienceVec().size(); ++i)
for(size_t i = 0; i < commandButton->getScienceVec().size(); ++i)
{
st = commandButton->getScienceVec()[ i ];
if(!player->hasScience(st) && TheScienceStore->playerHasPrereqsForScience(player, st) && TheScienceStore->getSciencePurchaseCost(st) <= player->getSciencePurchasePoints())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ void ControlBar::populateBuildTooltipLayout( const CommandButton *commandButton,
ScienceType st = SCIENCE_INVALID;
if(commandButton->getScienceVec().size() > 1)
{
for(Int j = 0; j < commandButton->getScienceVec().size(); ++j)
for(size_t j = 0; j < commandButton->getScienceVec().size(); ++j)
{
st = commandButton->getScienceVec()[ j ];

Expand Down
4 changes: 2 additions & 2 deletions Generals/Code/GameEngine/Source/GameClient/GameClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ GameClient::~GameClient()
TheVideoPlayer = NULL;

// destroy all translators
for( Int i = 0; i < m_numTranslators; i++ )
for( UnsignedInt i = 0; i < m_numTranslators; i++ )
TheMessageStream->removeTranslator( m_translators[ i ] );
m_numTranslators = 0;
m_commandTranslator = NULL;
Expand Down Expand Up @@ -1079,7 +1079,7 @@ void GameClient::preloadAssets( TimeOfDay timeOfDay )

GlobalMemoryStatus(&before);
extern std::vector<AsciiString> debrisModelNamesGlobalHack;
Int i=0;
size_t i=0;
for (; i<debrisModelNamesGlobalHack.size(); ++i)
{
TheDisplay->preloadModelAssets(debrisModelNamesGlobalHack[i]);
Expand Down
4 changes: 2 additions & 2 deletions Generals/Code/GameEngine/Source/GameClient/InGameUI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3416,7 +3416,7 @@ void InGameUI::postDraw( void )
UnsignedByte r, g, b, a;
GameGetColorComponents( m_militarySubtitle->color, &r, &g, &b, &a );
dropColor = GameMakeColor( 0, 0, 0, a );
for(Int i = 0; i <= m_militarySubtitle->currentDisplayString; i++)
for(UnsignedInt i = 0; i <= m_militarySubtitle->currentDisplayString; i++)
{
m_militarySubtitle->displayStrings[i]->draw(pos.x,pos.y, m_militarySubtitle->color,dropColor );
Int height;
Expand Down Expand Up @@ -3984,7 +3984,7 @@ void InGameUI::removeMilitarySubtitle( void )
TheInGameUI->clearTooltipsDisabled();

// loop through and free up the display strings
for(Int i = 0; i <= m_militarySubtitle->currentDisplayString; i ++)
for(UnsignedInt i = 0; i <= m_militarySubtitle->currentDisplayString; i ++)
{
TheDisplayStringManager->freeDisplayString(m_militarySubtitle->displayStrings[i]);
m_militarySubtitle->displayStrings[i] = NULL;
Expand Down
2 changes: 1 addition & 1 deletion Generals/Code/GameEngine/Source/GameClient/MapUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -577,7 +577,7 @@ Bool MapCache::loadUserMaps()
{
AsciiString endingStr;
AsciiString fname = s+1;
for (Int i=0; i<strlen(mapExtension); ++i)
for (size_t i=0; i<strlen(mapExtension); ++i)
fname.removeLastChar();

endingStr.format("%s\\%s%s", fname.str(), fname.str(), mapExtension);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4270,7 +4270,7 @@ GameMessageDisposition CommandTranslator::translateGameMessage(const GameMessage
{
// cheese festival: do NOT imitate this code. it is for debug purposes only.
std::vector<AsciiString> v = TheScienceStore->friend_getScienceNames();
for (int i = 0; i < v.size(); ++i)
for (size_t i = 0; i < v.size(); ++i)
{
ScienceType st = TheScienceStore->getScienceFromInternalName(v[i]);
if (st != SCIENCE_INVALID && TheScienceStore->isScienceGrantable(st))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -678,7 +678,7 @@ UpdateSleepTime DumbProjectileBehavior::update()
void DumbProjectileBehavior::displayFlightPath()
{
extern void addIcon(const Coord3D *pos, Real width, Int numFramesDuration, RGBColor color);
for( Int pointIndex = 0; pointIndex < m_flightPath.size(); ++pointIndex )
for( size_t pointIndex = 0; pointIndex < m_flightPath.size(); ++pointIndex )
{
addIcon(&m_flightPath[pointIndex], TheGlobalData->m_debugProjectileTileWidth,
TheGlobalData->m_debugProjectileTileDuration,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,12 +136,12 @@ void InstantDeathBehavior::onDie( const DamageInfo *damageInfo )

const InstantDeathBehaviorModuleData* d = getInstantDeathBehaviorModuleData();

Int idx, listSize;
size_t idx, listSize;

listSize = d->m_fx.size();
if (listSize > 0)
{
idx = GameLogicRandomValue(0, listSize-1);
idx = (size_t)GameLogicRandomValue(0, listSize-1);
const FXListVec& v = d->m_fx;
DEBUG_ASSERTCRASH(idx>=0&&idx<v.size(),("bad idx"));
const FXList* fxl = v[idx];
Expand All @@ -151,7 +151,7 @@ void InstantDeathBehavior::onDie( const DamageInfo *damageInfo )
listSize = d->m_ocls.size();
if (listSize > 0)
{
idx = GameLogicRandomValue(0, listSize-1);
idx = (size_t)GameLogicRandomValue(0, listSize-1);
const OCLVec& v = d->m_ocls;
DEBUG_ASSERTCRASH(idx>=0&&idx<v.size(),("bad idx"));
const ObjectCreationList* ocl = v[idx];
Expand All @@ -161,7 +161,7 @@ void InstantDeathBehavior::onDie( const DamageInfo *damageInfo )
listSize = d->m_weapons.size();
if (listSize > 0)
{
idx = GameLogicRandomValue(0, listSize-1);
idx = (size_t)GameLogicRandomValue(0, listSize-1);
const WeaponTemplateVec& v = d->m_weapons;
DEBUG_ASSERTCRASH(idx>=0&&idx<v.size(),("bad idx"));
const WeaponTemplate* wt = v[idx];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ Bool UnitCrateCollide::executeCrateBehavior( Object *other )
return FALSE;
}

for( Int unitIndex = 0; unitIndex < unitCount; unitIndex++ )
for( UnsignedInt unitIndex = 0; unitIndex < unitCount; unitIndex++ )
{
Team *creationTeam = other->getControllingPlayer()->getDefaultTeam();
Object *newObj = TheThingFactory->newObject( unitType, creationTeam );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2706,7 +2706,7 @@ void LocomotorSet::xferSelfAndCurLocoPtr(Xfer *xfer, Locomotor** loco)
}
else
{
for (int i = 0; i < m_locomotors.size(); ++i)
for (size_t i = 0; i < m_locomotors.size(); ++i)
{
if (m_locomotors[i]->getTemplateName() == name)
{
Expand All @@ -2724,7 +2724,7 @@ void LocomotorSet::xferSelfAndCurLocoPtr(Xfer *xfer, Locomotor** loco)
//-------------------------------------------------------------------------------------------------
void LocomotorSet::clear()
{
for (int i = 0; i < m_locomotors.size(); ++i)
for (size_t i = 0; i < m_locomotors.size(); ++i)
{
if (m_locomotors[i])
deleteInstance(m_locomotors[i]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ class DeliverPayloadNugget : public ObjectCreationNugget
}

Object *firstTransport = NULL;
for( Int formationIndex = 0; formationIndex < m_formationSize; formationIndex++ )
for( UnsignedInt formationIndex = 0; formationIndex < m_formationSize; formationIndex++ )
{
Coord3D offset;
offset.zero();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -835,7 +835,7 @@ Bool AIUpdateInterface::chooseLocomotorSetExplicit(LocomotorSetType wst)
{
m_locomotorSet.clear();
m_curLocomotor = NULL;
for (Int i = 0; i < set->size(); ++i)
for (size_t i = 0; i < set->size(); ++i)
{
const LocomotorTemplate* lt = set->at(i);
if (lt)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -656,7 +656,7 @@ class ChinookCombatDropState : public State
}

UnsignedInt now = TheGameLogic->getFrame();
for (Int i = 0; i < m_ropes.size(); ++i)
for (size_t i = 0; i < m_ropes.size(); ++i)
{
if (m_ropes[i].ropeDrawable)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ DockUpdate::DockUpdate( Thing *thing, const ModuleData* moduleData ) : UpdateMod
m_approachPositionReached.resize(DEFAULT_APPROACH_VECTOR_SIZE);
}

for( Int vectorIndex = 0; vectorIndex < m_approachPositions.size(); ++vectorIndex )
for( size_t vectorIndex = 0; vectorIndex < m_approachPositions.size(); ++vectorIndex )
{
// Whatever size we are, init everything.
m_approachPositions[vectorIndex].zero();
Expand All @@ -118,7 +118,7 @@ Bool DockUpdate::isClearToApproach( Object const* docker ) const

ObjectID dockerID = docker->getID();

for( Int positionIndex = 0; positionIndex < m_approachPositionOwners.size(); ++positionIndex )
for( size_t positionIndex = 0; positionIndex < m_approachPositionOwners.size(); ++positionIndex )
{
if( m_approachPositionOwners[positionIndex] == INVALID_ID )
{
Expand Down Expand Up @@ -315,7 +315,7 @@ void DockUpdate::getExitPosition( Object* docker, Coord3D *position )
void DockUpdate::onApproachReached( Object* docker )
{
ObjectID dockerID = docker->getID();
for( Int positionIndex = 0; positionIndex < m_approachPositionOwners.size(); ++positionIndex )
for( size_t positionIndex = 0; positionIndex < m_approachPositionOwners.size(); ++positionIndex )
{
if( m_approachPositionOwners[positionIndex] == dockerID )
{
Expand All @@ -335,7 +335,7 @@ void DockUpdate::onEnterReached( Object* docker )
m_dockerInside = TRUE;

ObjectID dockerID = docker->getID();
for( Int positionIndex = 0; positionIndex < m_approachPositionOwners.size(); ++positionIndex )
for( size_t positionIndex = 0; positionIndex < m_approachPositionOwners.size(); ++positionIndex )
{
if( m_approachPositionOwners[positionIndex] == dockerID )
{
Expand Down Expand Up @@ -381,7 +381,7 @@ void DockUpdate::onExitReached( Object* docker )
void DockUpdate::cancelDock( Object* docker )
{
ObjectID dockerID = docker->getID();
for( Int positionIndex = 0; positionIndex < m_approachPositionOwners.size(); ++positionIndex )
for( size_t positionIndex = 0; positionIndex < m_approachPositionOwners.size(); ++positionIndex )
{
if( m_approachPositionOwners[positionIndex] == dockerID )
{
Expand Down Expand Up @@ -418,7 +418,7 @@ UpdateSleepTime DockUpdate::update()
if( m_activeDocker == INVALID_ID && !m_dockCrippled )
{
// if setDockCrippled has been called, I will never give enterance permission.
for( Int positionIndex = 0; positionIndex < m_approachPositionReached.size(); ++positionIndex )
for( size_t positionIndex = 0; positionIndex < m_approachPositionReached.size(); ++positionIndex )
{
if( m_approachPositionReached[positionIndex] )
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ void EMPUpdate::doDisableAttack( void )

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

for (Int e = 0 ; e < emitterCount; ++e)
for (UnsignedInt e = 0 ; e < emitterCount; ++e)
{

ParticleSystem *sys = TheParticleSystemManager->createParticleSystem(tmp);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -728,7 +728,7 @@ void ParticleUplinkCannonUpdate::createOuterNodeParticleSystems( IntensityTypes
if( tmp )
{
ParticleSystem *system;
for( int i = 0; i < data->m_outerEffectNumBones; i++ )
for( UnsignedInt i = 0; i < data->m_outerEffectNumBones; i++ )
{
system = TheParticleSystemManager->createParticleSystem( tmp );
if( system )
Expand Down Expand Up @@ -773,7 +773,7 @@ void ParticleUplinkCannonUpdate::createConnectorLasers( IntensityTypes intensity
const ThingTemplate *thingTemplate = TheThingFactory->findTemplate( str );
if( thingTemplate )
{
for( int i = 0; i < data->m_outerEffectNumBones; i++ )
for( UnsignedInt i = 0; i < data->m_outerEffectNumBones; i++ )
{
Drawable *beam = TheThingFactory->newDrawable( thingTemplate );
if( beam )
Expand Down Expand Up @@ -950,7 +950,7 @@ void ParticleUplinkCannonUpdate::createGroundHitParticleSystem( IntensityTypes i
void ParticleUplinkCannonUpdate::removeAllEffects()
{
const ParticleUplinkCannonUpdateModuleData *data = getParticleUplinkCannonUpdateModuleData();
for( int i = 0; i < data->m_outerEffectNumBones; i++ )
for( UnsignedInt i = 0; i < data->m_outerEffectNumBones; i++ )
{
if( m_outerSystemIDs && m_outerSystemIDs[ i ] )
{
Expand Down Expand Up @@ -1003,7 +1003,7 @@ Bool ParticleUplinkCannonUpdate::calculateDefaultInformation()
return false;
}

for( int i = 0; i < data->m_outerEffectNumBones; i++ )
for( UnsignedInt i = 0; i < data->m_outerEffectNumBones; i++ )
{
m_laserBeamIDs[ i ] = INVALID_DRAWABLE_ID;
m_outerSystemIDs[ i ] = INVALID_PARTICLE_SYSTEM_ID;
Expand Down
Loading
Loading