Skip to content
Draft
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
15 changes: 6 additions & 9 deletions Core/GameEngine/Source/Common/INI/INI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1828,7 +1828,7 @@ void INI::parseAccelerationReal( INI *ini, void * /*instance*/, void *store, con
void INI::parseVeterancyLevelFlags(INI* ini, void* /*instance*/, void* store, const void* /*userData*/)
{
VeterancyLevelFlags flags = VETERANCY_LEVEL_FLAGS_ALL;
for (const char* token = ini->getNextToken(); token; token = ini->getNextTokenOrNull())
for (const char* token = ini->getNextTokenOrNull(); token; token = ini->getNextTokenOrNull())
{
if (stricmp(token, "ALL") == 0)
{
Expand Down Expand Up @@ -1867,12 +1867,10 @@ void INI::parseSoundsList( INI* ini, void *instance, void *store, const void* /*
std::vector<AsciiString> *vec = (std::vector<AsciiString>*) store;
vec->clear();

const char* SEPS = " \t,=";
const char *c = ini->getNextTokenOrNull(SEPS);
while ( c )
constexpr const char* SEPS = " \t,=";
for (const char* token = ini->getNextTokenOrNull(SEPS); token; token = ini->getNextTokenOrNull(SEPS))
{
vec->push_back( c );
c = ini->getNextTokenOrNull(SEPS);
vec->push_back(token);
}
}

Expand All @@ -1881,8 +1879,7 @@ void INI::parseSoundsList( INI* ini, void *instance, void *store, const void* /*
void INI::parseDamageTypeFlags(INI* ini, void* /*instance*/, void* store, const void* /*userData*/)
{
DamageTypeFlags flags = DAMAGE_TYPE_FLAGS_ALL;

for (const char* token = ini->getNextToken(); token; token = ini->getNextTokenOrNull())
for (const char* token = ini->getNextTokenOrNull(); token; token = ini->getNextTokenOrNull())
{
if (stricmp(token, "ALL") == 0)
{
Expand Down Expand Up @@ -1916,7 +1913,7 @@ void INI::parseDamageTypeFlags(INI* ini, void* /*instance*/, void* store, const
void INI::parseDeathTypeFlags(INI* ini, void* /*instance*/, void* store, const void* /*userData*/)
{
DeathTypeFlags flags = DEATH_TYPE_FLAGS_ALL;
for (const char* token = ini->getNextToken(); token; token = ini->getNextTokenOrNull())
for (const char* token = ini->getNextTokenOrNull(); token; token = ini->getNextTokenOrNull())
{
if (stricmp(token, "ALL") == 0)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -548,7 +548,7 @@ static void parsePrerequisiteUnit( INI* ini, void *instance, void * /*store*/, c

ProductionPrerequisite prereq;
Bool orUnitWithPrevious = FALSE;
for (const char *token = ini->getNextToken(); token != nullptr; token = ini->getNextTokenOrNull())
for (const char *token = ini->getNextTokenOrNull(); token != nullptr; token = ini->getNextTokenOrNull())
{
prereq.addUnitPrereq( AsciiString( token ), orUnitWithPrevious );
orUnitWithPrevious = TRUE;
Expand Down
4 changes: 1 addition & 3 deletions Generals/Code/GameEngine/Source/GameLogic/AI/TurretAI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -202,12 +202,10 @@ TurretAIData::TurretAIData()
static void parseTWS(INI* ini, void * /*instance*/, void * store, const void* /*userData*/)
{
UnsignedInt* tws = (UnsignedInt*)store;
const char* token = ini->getNextToken();
while (token != nullptr)
for (const char* token = ini->getNextTokenOrNull(); token; token = ini->getNextTokenOrNull())
{
WeaponSlotType wslot = (WeaponSlotType)INI::scanIndexList(token, TheWeaponSlotTypeNames);
*tws |= (1 << wslot);
token = ini->getNextTokenOrNull();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ InstantDeathBehaviorModuleData::InstantDeathBehaviorModuleData()
static void parseFX( INI* ini, void *instance, void * /*store*/, const void* /*userData*/ )
{
InstantDeathBehaviorModuleData* self = (InstantDeathBehaviorModuleData*)instance;
for (const char* token = ini->getNextToken(); token != nullptr; token = ini->getNextTokenOrNull())
for (const char* token = ini->getNextTokenOrNull(); token != nullptr; token = ini->getNextTokenOrNull())
{
const FXList *fxl = TheFXListStore->findFXList((token)); // could be null! this is OK!
self->m_fx.push_back(fxl);
Expand All @@ -73,7 +73,7 @@ static void parseFX( INI* ini, void *instance, void * /*store*/, const void* /*u
static void parseOCL( INI* ini, void *instance, void * /*store*/, const void* /*userData*/ )
{
InstantDeathBehaviorModuleData* self = (InstantDeathBehaviorModuleData*)instance;
for (const char* token = ini->getNextToken(); token != nullptr; token = ini->getNextTokenOrNull())
for (const char* token = ini->getNextTokenOrNull(); token != nullptr; token = ini->getNextTokenOrNull())
{
const ObjectCreationList *ocl = TheObjectCreationListStore->findObjectCreationList(token); // could be null! this is OK!
self->m_ocls.push_back(ocl);
Expand All @@ -84,7 +84,7 @@ static void parseOCL( INI* ini, void *instance, void * /*store*/, const void* /*
static void parseWeapon( INI* ini, void *instance, void * /*store*/, const void* /*userData*/ )
{
InstantDeathBehaviorModuleData* self = (InstantDeathBehaviorModuleData*)instance;
for (const char* token = ini->getNextToken(); token != nullptr; token = ini->getNextTokenOrNull())
for (const char* token = ini->getNextTokenOrNull(); token != nullptr; token = ini->getNextTokenOrNull())
{
const WeaponTemplate *wt = TheWeaponStore->findWeaponTemplate(token); // could be null! this is OK!
self->m_weapons.push_back(wt);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ static void parseFX( INI* ini, void *instance, void * /*store*/, const void* /*u
{
SlowDeathBehaviorModuleData* self = (SlowDeathBehaviorModuleData*)instance;
SlowDeathPhaseType sdphase = (SlowDeathPhaseType)INI::scanIndexList(ini->getNextToken(), TheSlowDeathPhaseNames);
for (const char* token = ini->getNextToken(); token != nullptr; token = ini->getNextTokenOrNull())
for (const char* token = ini->getNextTokenOrNull(); token != nullptr; token = ini->getNextTokenOrNull())
{
const FXList *fxl = TheFXListStore->findFXList((token)); // could be null! this is OK!
self->m_fx[sdphase].push_back(fxl);
Expand All @@ -95,7 +95,7 @@ static void parseOCL( INI* ini, void *instance, void * /*store*/, const void* /*
{
SlowDeathBehaviorModuleData* self = (SlowDeathBehaviorModuleData*)instance;
SlowDeathPhaseType sdphase = (SlowDeathPhaseType)INI::scanIndexList(ini->getNextToken(), TheSlowDeathPhaseNames);
for (const char* token = ini->getNextToken(); token != nullptr; token = ini->getNextTokenOrNull())
for (const char* token = ini->getNextTokenOrNull(); token != nullptr; token = ini->getNextTokenOrNull())
{
const ObjectCreationList *ocl = TheObjectCreationListStore->findObjectCreationList(token); // could be null! this is OK!
self->m_ocls[sdphase].push_back(ocl);
Expand All @@ -109,7 +109,7 @@ static void parseWeapon( INI* ini, void *instance, void * /*store*/, const void*
{
SlowDeathBehaviorModuleData* self = (SlowDeathBehaviorModuleData*)instance;
SlowDeathPhaseType sdphase = (SlowDeathPhaseType)INI::scanIndexList(ini->getNextToken(), TheSlowDeathPhaseNames);
for (const char* token = ini->getNextToken(); token != nullptr; token = ini->getNextTokenOrNull())
for (const char* token = ini->getNextTokenOrNull(); token != nullptr; token = ini->getNextTokenOrNull())
{
const WeaponTemplate *wt = TheWeaponStore->findWeaponTemplate(token); // could be null! this is OK!
self->m_weapons[sdphase].push_back(wt);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1351,12 +1351,11 @@ class GenericObjectCreationNugget : public ObjectCreationNugget
static void parseDebrisObjectNames( INI* ini, void *instance, void *store, const void* /*userData*/ )
{
GenericObjectCreationNugget* debrisNugget = (GenericObjectCreationNugget*)instance;
for (const char* debrisName = ini->getNextToken(); debrisName; debrisName = ini->getNextTokenOrNull())
for (const char* token = ini->getNextTokenOrNull(); token; token = ini->getNextTokenOrNull())
{
if (TheGlobalData->m_preloadAssets)
debrisModelNamesGlobalHack.push_back(debrisName);
debrisNugget->m_names.push_back(AsciiString(debrisName));
debrisName = ini->getNextTokenOrNull();
debrisModelNamesGlobalHack.push_back(token);
debrisNugget->m_names.push_back(AsciiString(token));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,16 +172,16 @@ const LocomotorTemplateVector* AIUpdateModuleData::findLocomotorTemplateVector(L
}

self->m_locomotorTemplates[set].clear();
for (const char* locoName = ini->getNextToken(); locoName; locoName = ini->getNextTokenOrNull())
for (const char* token = ini->getNextTokenOrNull(); token; token = ini->getNextTokenOrNull())
{
if (!*locoName || stricmp(locoName, "None") == 0)
if (!*token || stricmp(token, "None") == 0)
continue;

NameKeyType locoKey = NAMEKEY(locoName);
NameKeyType locoKey = NAMEKEY(token);
const LocomotorTemplate* lt = TheLocomotorStore->findLocomotorTemplate(locoKey);
if (!lt)
{
DEBUG_CRASH(("Locomotor %s not found!",locoName));
DEBUG_CRASH(("Locomotor %s not found!",token));
throw INI_INVALID_DATA;
}
self->m_locomotorTemplates[set].push_back(lt);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ static void parseFX( INI* ini, void *instance, void * /*store*/, const void* /*u
{
StructureCollapseUpdateModuleData* self = (StructureCollapseUpdateModuleData*)instance;
StructureCollapsePhaseType scphase = (StructureCollapsePhaseType)INI::scanIndexList(ini->getNextToken(), TheStructureCollapsePhaseNames);
for (const char* token = ini->getNextToken(); token != nullptr; token = ini->getNextTokenOrNull())
for (const char* token = ini->getNextTokenOrNull(); token != nullptr; token = ini->getNextTokenOrNull())
{
const FXList *fxl = TheFXListStore->findFXList((token)); // could be null! this is OK!
self->m_fxs[scphase].push_back(fxl);
Expand All @@ -96,7 +96,7 @@ static void parseOCL( INI* ini, void *instance, void * /*store*/, const void* /*
{
StructureCollapseUpdateModuleData* self = (StructureCollapseUpdateModuleData*)instance;
StructureCollapsePhaseType stphase = (StructureCollapsePhaseType)INI::scanIndexList(ini->getNextToken(), TheStructureCollapsePhaseNames);
for (const char* token = ini->getNextToken(); token != nullptr; token = ini->getNextTokenOrNull())
for (const char* token = ini->getNextTokenOrNull(); token != nullptr; token = ini->getNextTokenOrNull())
{
const ObjectCreationList *ocl = TheObjectCreationListStore->findObjectCreationList(token); // could be null! this is OK!
self->m_ocls[stphase].push_back(ocl);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ static void parseOCL( INI* ini, void *instance, void * /*store*/, const void* /*
{
StructureToppleUpdateModuleData* self = (StructureToppleUpdateModuleData*)instance;
StructureTopplePhaseType stphase = (StructureTopplePhaseType)INI::scanIndexList(ini->getNextToken(), TheStructureTopplePhaseNames);
for (const char* token = ini->getNextToken(); token != nullptr; token = ini->getNextTokenOrNull())
for (const char* token = ini->getNextTokenOrNull(); token != nullptr; token = ini->getNextTokenOrNull())
{
const ObjectCreationList *ocl = TheObjectCreationListStore->findObjectCreationList(token); // could be null! this is OK!
self->m_ocls[stphase].push_back(ocl);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -630,7 +630,7 @@ static void parsePrerequisiteUnit( INI* ini, void *instance, void * /*store*/, c

ProductionPrerequisite prereq;
Bool orUnitWithPrevious = FALSE;
for (const char *token = ini->getNextToken(); token != nullptr; token = ini->getNextTokenOrNull())
for (const char *token = ini->getNextTokenOrNull(); token != nullptr; token = ini->getNextTokenOrNull())
{
prereq.addUnitPrereq( AsciiString( token ), orUnitWithPrevious );
orUnitWithPrevious = TRUE;
Expand Down
4 changes: 1 addition & 3 deletions GeneralsMD/Code/GameEngine/Source/GameLogic/AI/TurretAI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -202,12 +202,10 @@ TurretAIData::TurretAIData()
static void parseTWS(INI* ini, void * /*instance*/, void * store, const void* /*userData*/)
{
UnsignedInt* tws = (UnsignedInt*)store;
const char* token = ini->getNextToken();
while (token != nullptr)
for (const char* token = ini->getNextTokenOrNull(); token; token = ini->getNextTokenOrNull())
{
WeaponSlotType wslot = (WeaponSlotType)INI::scanIndexList(token, TheWeaponSlotTypeNames);
*tws |= (1 << wslot);
token = ini->getNextTokenOrNull();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ InstantDeathBehaviorModuleData::InstantDeathBehaviorModuleData()
static void parseFX( INI* ini, void *instance, void * /*store*/, const void* /*userData*/ )
{
InstantDeathBehaviorModuleData* self = (InstantDeathBehaviorModuleData*)instance;
for (const char* token = ini->getNextToken(); token != nullptr; token = ini->getNextTokenOrNull())
for (const char* token = ini->getNextTokenOrNull(); token != nullptr; token = ini->getNextTokenOrNull())
{
const FXList *fxl = TheFXListStore->findFXList((token)); // could be null! this is OK!
self->m_fx.push_back(fxl);
Expand All @@ -73,7 +73,7 @@ static void parseFX( INI* ini, void *instance, void * /*store*/, const void* /*u
static void parseOCL( INI* ini, void *instance, void * /*store*/, const void* /*userData*/ )
{
InstantDeathBehaviorModuleData* self = (InstantDeathBehaviorModuleData*)instance;
for (const char* token = ini->getNextToken(); token != nullptr; token = ini->getNextTokenOrNull())
for (const char* token = ini->getNextTokenOrNull(); token != nullptr; token = ini->getNextTokenOrNull())
{
const ObjectCreationList *ocl = TheObjectCreationListStore->findObjectCreationList(token); // could be null! this is OK!
self->m_ocls.push_back(ocl);
Expand All @@ -84,7 +84,7 @@ static void parseOCL( INI* ini, void *instance, void * /*store*/, const void* /*
static void parseWeapon( INI* ini, void *instance, void * /*store*/, const void* /*userData*/ )
{
InstantDeathBehaviorModuleData* self = (InstantDeathBehaviorModuleData*)instance;
for (const char* token = ini->getNextToken(); token != nullptr; token = ini->getNextTokenOrNull())
for (const char* token = ini->getNextTokenOrNull(); token != nullptr; token = ini->getNextTokenOrNull())
{
const WeaponTemplate *wt = TheWeaponStore->findWeaponTemplate(token); // could be null! this is OK!
self->m_weapons.push_back(wt);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ static void parseFX( INI* ini, void *instance, void * /*store*/, const void* /*u
{
SlowDeathBehaviorModuleData* self = (SlowDeathBehaviorModuleData*)instance;
SlowDeathPhaseType sdphase = (SlowDeathPhaseType)INI::scanIndexList(ini->getNextToken(), TheSlowDeathPhaseNames);
for (const char* token = ini->getNextToken(); token != nullptr; token = ini->getNextTokenOrNull())
for (const char* token = ini->getNextTokenOrNull(); token != nullptr; token = ini->getNextTokenOrNull())
{
const FXList *fxl = TheFXListStore->findFXList((token)); // could be null! this is OK!
self->m_fx[sdphase].push_back(fxl);
Expand All @@ -95,7 +95,7 @@ static void parseOCL( INI* ini, void *instance, void * /*store*/, const void* /*
{
SlowDeathBehaviorModuleData* self = (SlowDeathBehaviorModuleData*)instance;
SlowDeathPhaseType sdphase = (SlowDeathPhaseType)INI::scanIndexList(ini->getNextToken(), TheSlowDeathPhaseNames);
for (const char* token = ini->getNextToken(); token != nullptr; token = ini->getNextTokenOrNull())
for (const char* token = ini->getNextTokenOrNull(); token != nullptr; token = ini->getNextTokenOrNull())
{
const ObjectCreationList *ocl = TheObjectCreationListStore->findObjectCreationList(token); // could be null! this is OK!
self->m_ocls[sdphase].push_back(ocl);
Expand All @@ -109,7 +109,7 @@ static void parseWeapon( INI* ini, void *instance, void * /*store*/, const void*
{
SlowDeathBehaviorModuleData* self = (SlowDeathBehaviorModuleData*)instance;
SlowDeathPhaseType sdphase = (SlowDeathPhaseType)INI::scanIndexList(ini->getNextToken(), TheSlowDeathPhaseNames);
for (const char* token = ini->getNextToken(); token != nullptr; token = ini->getNextTokenOrNull())
for (const char* token = ini->getNextTokenOrNull(); token != nullptr; token = ini->getNextTokenOrNull())
{
const WeaponTemplate *wt = TheWeaponStore->findWeaponTemplate(token); // could be null! this is OK!
self->m_weapons[sdphase].push_back(wt);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1439,12 +1439,11 @@ class GenericObjectCreationNugget : public ObjectCreationNugget
static void parseDebrisObjectNames( INI* ini, void *instance, void *store, const void* /*userData*/ )
{
GenericObjectCreationNugget* debrisNugget = (GenericObjectCreationNugget*)instance;
for (const char* debrisName = ini->getNextToken(); debrisName; debrisName = ini->getNextTokenOrNull())
for (const char* token = ini->getNextTokenOrNull(); token; token = ini->getNextTokenOrNull())
{
if (TheGlobalData->m_preloadAssets)
debrisModelNamesGlobalHack.push_back(debrisName);
debrisNugget->m_names.push_back(AsciiString(debrisName));
debrisName = ini->getNextTokenOrNull();
debrisModelNamesGlobalHack.push_back(token);
debrisNugget->m_names.push_back(AsciiString(token));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,16 +177,16 @@ const LocomotorTemplateVector* AIUpdateModuleData::findLocomotorTemplateVector(L
}

self->m_locomotorTemplates[set].clear();
for (const char* locoName = ini->getNextToken(); locoName; locoName = ini->getNextTokenOrNull())
for (const char* token = ini->getNextTokenOrNull(); token; token = ini->getNextTokenOrNull())
{
if (!*locoName || stricmp(locoName, "None") == 0)
if (!*token || stricmp(token, "None") == 0)
continue;

NameKeyType locoKey = NAMEKEY(locoName);
NameKeyType locoKey = NAMEKEY(token);
const LocomotorTemplate* lt = TheLocomotorStore->findLocomotorTemplate(locoKey);
if (!lt)
{
DEBUG_CRASH(("Locomotor %s not found!",locoName));
DEBUG_CRASH(("Locomotor %s not found!",token));
throw INI_INVALID_DATA;
}
self->m_locomotorTemplates[set].push_back(lt);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ static void parseFX( INI* ini, void *instance, void * /*store*/, const void* /*u
{
StructureCollapseUpdateModuleData* self = (StructureCollapseUpdateModuleData*)instance;
StructureCollapsePhaseType scphase = (StructureCollapsePhaseType)INI::scanIndexList(ini->getNextToken(), TheStructureCollapsePhaseNames);
for (const char* token = ini->getNextToken(); token != nullptr; token = ini->getNextTokenOrNull())
for (const char* token = ini->getNextTokenOrNull(); token != nullptr; token = ini->getNextTokenOrNull())
{
const FXList *fxl = TheFXListStore->findFXList((token)); // could be null! this is OK!
self->m_fxs[scphase].push_back(fxl);
Expand All @@ -96,7 +96,7 @@ static void parseOCL( INI* ini, void *instance, void * /*store*/, const void* /*
{
StructureCollapseUpdateModuleData* self = (StructureCollapseUpdateModuleData*)instance;
StructureCollapsePhaseType stphase = (StructureCollapsePhaseType)INI::scanIndexList(ini->getNextToken(), TheStructureCollapsePhaseNames);
for (const char* token = ini->getNextToken(); token != nullptr; token = ini->getNextTokenOrNull())
for (const char* token = ini->getNextTokenOrNull(); token != nullptr; token = ini->getNextTokenOrNull())
{
const ObjectCreationList *ocl = TheObjectCreationListStore->findObjectCreationList(token); // could be null! this is OK!
self->m_ocls[stphase].push_back(ocl);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ static void parseOCL( INI* ini, void *instance, void * /*store*/, const void* /*
{
StructureToppleUpdateModuleData* self = (StructureToppleUpdateModuleData*)instance;
StructureTopplePhaseType stphase = (StructureTopplePhaseType)INI::scanIndexList(ini->getNextToken(), TheStructureTopplePhaseNames);
for (const char* token = ini->getNextToken(); token != nullptr; token = ini->getNextTokenOrNull())
for (const char* token = ini->getNextTokenOrNull(); token != nullptr; token = ini->getNextTokenOrNull())
{
const ObjectCreationList *ocl = TheObjectCreationListStore->findObjectCreationList(token); // could be null! this is OK!
self->m_ocls[stphase].push_back(ocl);
Expand Down
Loading