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<ARRAY_SSIZE(cvars_engine); i++)
-        OSD_RegisterCvar(&cvars_engine[i], (cvars_engine[i].flags & CVAR_FUNCPTR) ? osdcmd_cvar_set_baselayer : osdcmd_cvar_set);
+    for (auto & i : cvars_engine)
+        OSD_RegisterCvar(&i, (i.flags & CVAR_FUNCPTR) ? osdcmd_cvar_set_baselayer : osdcmd_cvar_set);
 
 #ifdef USE_OPENGL
     OSD_RegisterFunction("setrendermode","setrendermode <number>: 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; i<OSDMAXHISTORYDEPTH; i++)
-        DO_FREE_AND_NULL(osd->history.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<ARRAY_SIZE(cvars_osd); i++)
-        OSD_RegisterCvar(&cvars_osd[i], (cvars_osd[i].flags & CVAR_FUNCPTR) ? osdcmd_cvar_set_osd : osdcmd_cvar_set);
+    for (auto & i : cvars_osd)
+        OSD_RegisterCvar(&i, (i.flags & CVAR_FUNCPTR) ? osdcmd_cvar_set_osd : osdcmd_cvar_set);
 
     OSD_RegisterFunction("alias", "alias: creates an alias for calling multiple commands", osdfunc_alias);
     OSD_RegisterFunction("clear", "clear: clears the console text buffer", osdfunc_clear);
diff --git a/source/build/src/palette.cpp b/source/build/src/palette.cpp
index fa54cdb72..8f81d51af 100644
--- a/source/build/src/palette.cpp
+++ b/source/build/src/palette.cpp
@@ -139,8 +139,8 @@ void paletteLoadFromDisk(void)
     initfastcolorlookup_gridvectors();
 
 #ifdef USE_OPENGL
-    for (size_t x = 0; x < MAXBLENDTABS; ++x)
-        glblend[x] = defaultglblend;
+    for (auto & x : glblend)
+        x = defaultglblend;
 #endif
 
     int32_t fil;
@@ -153,8 +153,8 @@ void paletteLoadFromDisk(void)
     if (kread_and_test(fil, palette, 768))
         return kclose(fil);
 
-    for (bssize_t k = 0; k < 768; k++)
-        palette[k] <<= 2;
+    for (unsigned char & k : palette)
+        k <<= 2;
 
     initfastcolorlookup_palette(palette);
 
@@ -366,23 +366,19 @@ void palettePostLoadTables(void)
 
 void paletteFixTranslucencyMask(void)
 {
-    for (bssize_t i=0; i<MAXPALOOKUPS; i++)
+    for (auto *thispalookup : palookup)
     {
-        char * const thispalookup = palookup[i];
         if (thispalookup == NULL)
             continue;
 
         for (bssize_t j=0; j<numshades; j++)
-        {
             thispalookup[(j<<8) + 255] = 255;
-        }
     }
 
     // fix up translucency table so that transluc(255,x)
     // and transluc(x,255) is black instead of purple.
-    for (bssize_t i=0; i<MAXBLENDTABS; i++)
+    for (auto *transluc : blendtable)
     {
-        char * const transluc = blendtable[i];
         if (transluc == NULL)
             continue;
 
diff --git a/source/duke3d/src/actors.cpp b/source/duke3d/src/actors.cpp
index ab59aed88..5fe542e1b 100644
--- a/source/duke3d/src/actors.cpp
+++ b/source/duke3d/src/actors.cpp
@@ -184,9 +184,9 @@ SKIPWALLCHECK:
         STAT_PLAYER, STAT_FALLER, STAT_ZOMBIEACTOR, STAT_MISC
     };
 
-    for (native_t stati=0; stati < ARRAY_SSIZE(statnumList); stati++)
+    for (unsigned char stati : statnumList)
     {
-        int32_t otherSprite = headspritestat[statnumList[stati]];
+        int32_t otherSprite = headspritestat[stati];
 
         while (otherSprite >= 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<MAXUSERQUOTES; i++)
+    for (int & i : user_quote_time)
     {
-        if (user_quote_time[i])
+        if (i)
         {
-            if (--user_quote_time[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<MAXGAMEVARS; i++)
+    for (auto &aGameVar : aGameVars)
     {
-        if (aGameVars[i].szLabel != NULL)
-        Gv_NewVar(aGameVars[i].szLabel,
-                    (aGameVars[i].flags & GAMEVAR_NODEFAULT) ? aGameVars[i].global : aGameVars[i].defaultValue,
-                    aGameVars[i].flags);
+        if (aGameVar.szLabel != NULL)
+            Gv_NewVar(aGameVar.szLabel, (aGameVar.flags & GAMEVAR_NODEFAULT) ? aGameVar.global : aGameVar.defaultValue, aGameVar.flags);
     }
 
-    for (bssize_t i=0; i<MAXGAMEARRAYS; i++)
+    for (auto &aGameArray : aGameArrays)
     {
-        if (aGameArrays[i].szLabel != NULL)
-        if (aGameArrays[i].flags & GAMEARRAY_RESET)
-            Gv_NewArray(aGameArrays[i].szLabel,aGameArrays[i].pValues,aGameArrays[i].size,aGameArrays[i].flags);
+        if (aGameArray.szLabel != NULL && aGameArray.flags & GAMEARRAY_RESET)
+            Gv_NewArray(aGameArray.szLabel, aGameArray.pValues, aGameArray.size, aGameArray.flags);
     }
 }
 
@@ -1203,9 +1200,9 @@ void Gv_ResetSystemDefaults(void)
     g_structVarIDs   = Gv_GetVarIndex("sprite");
 #endif
 
-    for (bssize_t weaponNum = 0; weaponNum <= MAXTILES - 1; weaponNum++)
-        if (g_tile[weaponNum].defproj)
-            *g_tile[weaponNum].proj = *g_tile[weaponNum].defproj;
+    for (auto & tile : g_tile)
+        if (tile.defproj)
+            *tile.proj = *tile.defproj;
 
     //AddLog("EOF:ResetWeaponDefaults");
 }
diff --git a/source/duke3d/src/premap.cpp b/source/duke3d/src/premap.cpp
index 3ece24727..5ca2b4022 100644
--- a/source/duke3d/src/premap.cpp
+++ b/source/duke3d/src/premap.cpp
@@ -1711,11 +1711,11 @@ void G_SetupFilenameBasedMusic(char *nameBuf, const char *fileName, int levelNum
         p[0] = '.';
     }
 
-    for (unsigned int i = 0; i < ARRAY_SIZE(exts); i++)
+    for (auto & ext : exts)
     {
         int32_t kFile;
 
-        Bmemcpy(p+1, exts[i], Bstrlen(exts[i]) + 1);
+        Bmemcpy(p+1, ext, Bstrlen(ext) + 1);
 
         if ((kFile = kopen4loadfrommod(nameBuf, 0)) != -1)
         {
diff --git a/source/duke3d/src/savegame.cpp b/source/duke3d/src/savegame.cpp
index 9aeabfe7d..6deb1207d 100644
--- a/source/duke3d/src/savegame.cpp
+++ b/source/duke3d/src/savegame.cpp
@@ -1816,10 +1816,10 @@ void sv_postyaxload(void)
 static void sv_postactordata()
 {
 #ifdef POLYMER
-    for (int i = 0; i < MAXSPRITES; i++)
+    for (auto & i : actor)
     {
-        actor[i].lightptr = NULL;
-        actor[i].lightId = -1;
+        i.lightptr = NULL;
+        i.lightId = -1;
     }
 #endif
 }
@@ -1865,8 +1865,8 @@ static void sv_preprojectilesave()
     savegame_projectilecnt = 0;
     Bmemset(savegame_projectiles, 0, sizeof(savegame_projectiles));
 
-    for (int i = 0; i < MAXTILES; i++)
-        if (g_tile[i].proj)
+    for (auto & i : g_tile)
+        if (i.proj)
             savegame_projectilecnt++;
 
     if (savegame_projectilecnt > 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;
 }