diff --git a/source/build/src/baselayer.cpp b/source/build/src/baselayer.cpp index faf1a6940..32ca5c96a 100644 --- a/source/build/src/baselayer.cpp +++ b/source/build/src/baselayer.cpp @@ -468,8 +468,8 @@ int32_t baselayer_init(void) #endif }; - for (native_t i=0; i: sets the engine's rendering mode.\n" diff --git a/source/build/src/osd.cpp b/source/build/src/osd.cpp index 9526c02af..92b97d4ad 100644 --- a/source/build/src/osd.cpp +++ b/source/build/src/osd.cpp @@ -598,8 +598,8 @@ void OSD_Cleanup(void) DO_FREE_AND_NULL(osd->cvars); DO_FREE_AND_NULL(osd->editor.buf); DO_FREE_AND_NULL(osd->editor.tmp); - for (bssize_t i=0; ihistory.buf[i]); + for (auto & i : osd->history.buf) + DO_FREE_AND_NULL(i); DO_FREE_AND_NULL(osd->text.buf); DO_FREE_AND_NULL(osd->text.fmt); DO_FREE_AND_NULL(osd->version.buf); @@ -699,8 +699,8 @@ void OSD_Init(void) { "osdhistorydepth", "sets the history depth, in lines", (void *) &osd->history.maxlines, CVAR_INT|CVAR_FUNCPTR, OSDMINHISTORYDEPTH, OSDMAXHISTORYDEPTH }, }; - for (unsigned i=0; i= 0) { @@ -194,7 +194,7 @@ SKIPWALLCHECK: spritetype *const pOther = &sprite[otherSprite]; // DEFAULT, ZOMBIEACTOR, MISC - if (statnumList[stati] == STAT_DEFAULT || statnumList[stati] == STAT_ZOMBIEACTOR || statnumList[stati] == STAT_MISC || AFLAMABLE(pOther->picnum)) + if (stati == STAT_DEFAULT || stati == STAT_ZOMBIEACTOR || stati == STAT_MISC || AFLAMABLE(pOther->picnum)) { #ifndef EDUKE32_STANDALONE if (pSprite->picnum != SHRINKSPARK || (pOther->cstat&257)) diff --git a/source/duke3d/src/cheats.cpp b/source/duke3d/src/cheats.cpp index f2edca896..7e10c0133 100644 --- a/source/duke3d/src/cheats.cpp +++ b/source/duke3d/src/cheats.cpp @@ -614,8 +614,8 @@ void G_DoCheats(void) case CHEAT_SHOWMAP: // SHOW ALL OF THE MAP TOGGLE; ud.showallmap = !ud.showallmap; - for (bssize_t i=0; i<(MAXSECTORS>>3); i++) - show2dsector[i] = ud.showallmap*255; + for (char & i : show2dsector) + i = ud.showallmap*255; P_DoQuote(ud.showallmap ? QUOTE_SHOW_MAP_ON : QUOTE_SHOW_MAP_OFF, pPlayer); diff --git a/source/duke3d/src/common.cpp b/source/duke3d/src/common.cpp index 292ae7354..8d2260682 100644 --- a/source/duke3d/src/common.cpp +++ b/source/duke3d/src/common.cpp @@ -522,10 +522,10 @@ static int G_ReadRegistryValue(char const * const SubKey, char const * const Val // KEY_WOW64_32KEY gets us around Wow6432Node on 64-bit builds REGSAM const wow64keys[] = { KEY_WOW64_32KEY, KEY_WOW64_64KEY }; - for (size_t k = 0; k < ARRAY_SIZE(wow64keys); ++k) + for (auto &wow64key : wow64keys) { HKEY hkey; - LONG keygood = RegOpenKeyEx(HKEY_LOCAL_MACHINE, NULL, 0, KEY_READ | wow64keys[k], &hkey); + LONG keygood = RegOpenKeyEx(HKEY_LOCAL_MACHINE, NULL, 0, KEY_READ | wow64key, &hkey); if (keygood != ERROR_SUCCESS) continue; @@ -997,11 +997,11 @@ void G_LoadGroupsInDir(const char *dirname) char buf[BMAX_PATH]; fnlist_t fnlist = FNLIST_INITIALIZER; - for (unsigned i=0; i<(sizeof(extensions)/sizeof(extensions[0])); i++) + for (auto & extension : extensions) { CACHE1D_FIND_REC *rec; - fnlist_getnames(&fnlist, dirname, extensions[i], -1, 0); + fnlist_getnames(&fnlist, dirname, extension, -1, 0); for (rec=fnlist.findfiles; rec; rec=rec->next) { @@ -1052,8 +1052,8 @@ void G_LoadLookups(void) if (kread_and_test(fp, paldata, 768)) return kclose(fp); - for (bssize_t k = 0; k < 768; k++) - paldata[k] <<= 2; + for (unsigned char & k : paldata) + k <<= 2; paletteSetColorTable(basepalnum, paldata); } diff --git a/source/duke3d/src/game.cpp b/source/duke3d/src/game.cpp index 66da36598..cc07b0172 100644 --- a/source/duke3d/src/game.cpp +++ b/source/duke3d/src/game.cpp @@ -6637,8 +6637,8 @@ MAIN_LOOP_RESTART: lockclock = 0; g_player[myconnectindex].ps->fta = 0; - for (size_t q = 0; q < MAXUSERQUOTES; ++q) - user_quote_time[q] = 0; + for (int & q : user_quote_time) + q = 0; Menu_Change(MENU_MAIN); @@ -6889,13 +6889,13 @@ int G_DoMoveThings(void) if (g_RTSPlaying > 0) g_RTSPlaying--; - for (bssize_t i=0; i ud.msgdisptime) - user_quote_time[i] = ud.msgdisptime; - if (!user_quote_time[i]) pub = NUMPAGES; + if (--i > ud.msgdisptime) + i = ud.msgdisptime; + if (!i) pub = NUMPAGES; } } diff --git a/source/duke3d/src/gamedef.cpp b/source/duke3d/src/gamedef.cpp index cccae545d..b0d109671 100644 --- a/source/duke3d/src/gamedef.cpp +++ b/source/duke3d/src/gamedef.cpp @@ -6511,8 +6511,8 @@ static void C_AddDefaultDefinitions(void) { "GAMEARRAY_BOOLEAN", GAMEARRAY_BITMAP }, }; - for (unsigned i = 0; i < ARRAY_SIZE(predefined); i++) - C_AddDefinition(predefined[i].token, predefined[i].val, LABEL_DEFINE); + for (auto & i : predefined) + C_AddDefinition(i.token, i.val, LABEL_DEFINE); C_AddDefinition("NO", 0, LABEL_DEFINE | LABEL_ACTION | LABEL_AI | LABEL_MOVE); } @@ -6708,12 +6708,12 @@ void C_Compile(const char *fileName) G_GameExit(buf); } - for (int i = 0; i < MAXEVENTS; ++i) + for (intptr_t i : apScriptGameEventEnd) { - if (!apScriptGameEventEnd[i]) + if (!i) continue; - intptr_t *eventEnd = apScript + apScriptGameEventEnd[i]; + intptr_t *eventEnd = apScript + i; // C_FillEventBreakStackWithEndEvent intptr_t *breakPtr = (intptr_t*)*(eventEnd + 2); while (breakPtr) @@ -6731,8 +6731,8 @@ void C_Compile(const char *fileName) initprintf("Script compiled in %dms, %ld bytes%s\n", timerGetTicks() - startcompiletime, (unsigned long)(g_scriptPtr-apScript), C_ScriptVersionString(g_scriptVersion)); - for (unsigned i=0; i < ARRAY_SIZE(tables_free); i++) - hash_free(tables_free[i]); + for (auto *i : tables_free) + hash_free(i); freehashnames(); freesoundhashnames(); diff --git a/source/duke3d/src/gameexec.cpp b/source/duke3d/src/gameexec.cpp index 579a90910..361475ec3 100644 --- a/source/duke3d/src/gameexec.cpp +++ b/source/duke3d/src/gameexec.cpp @@ -3728,8 +3728,8 @@ GAMEEXEC_STATIC void VM_Execute(native_t loop) int32_t values[8]; G_GetTimeDate(values); - for (native_t i = 0; i < 8; i++) - Gv_SetVarX(*insptr++, values[i]); + for (int value : values) + Gv_SetVarX(*insptr++, value); continue; } diff --git a/source/duke3d/src/gamevars.cpp b/source/duke3d/src/gamevars.cpp index 3c964a879..54f7c9f49 100644 --- a/source/duke3d/src/gamevars.cpp +++ b/source/duke3d/src/gamevars.cpp @@ -340,19 +340,16 @@ void Gv_ResetVars(void) /* this is called during a new game and nowhere else */ osd->log.errors = 0; - for (bssize_t i=0; i 0) diff --git a/source/mact/src/keyboard.cpp b/source/mact/src/keyboard.cpp index 9bf5af1e4..24e2749eb 100644 --- a/source/mact/src/keyboard.cpp +++ b/source/mact/src/keyboard.cpp @@ -67,18 +67,18 @@ static struct // this is horrible! const char *KB_ScanCodeToString(kb_scancode scancode) { - for (size_t s = 0; s < ARRAY_SIZE(sctokeylut); s++) - if (sctokeylut[s].sc == scancode) - return sctokeylut[s].key; + for (auto &s : sctokeylut) + if (s.sc == scancode) + return s.key; return ""; } kb_scancode KB_StringToScanCode(const char * string) { - for (size_t s = 0; s < ARRAY_SIZE(sctokeylut); s++) - if (!Bstrcasecmp(sctokeylut[s].key, string)) - return sctokeylut[s].sc; + for (auto &s : sctokeylut) + if (!Bstrcasecmp(s.key, string)) + return s.sc; return 0; }