From b0a4b6a1ee423a96941526ea13e3a1c48bec351d Mon Sep 17 00:00:00 2001 From: terminx Date: Sun, 19 May 2019 03:56:13 +0000 Subject: [PATCH] Convert loops using unsigned integers as iterators to use regular signed ints instead https://kristerw.blogspot.com/2016/02/how-undefined-signed-overflow-enables.html Doing this as cleanly as possible involved demoting several function parameters concerning object sizes and counts from size_t to int--I'm fine with this change as the functions in question are not actually capable of handling input with sizes larger than what can be stored in a signed 32-bit integer, making the use of size_t here misleading at best. git-svn-id: https://svn.eduke32.com/eduke32@7673 1a8010ca-5511-0410-912e-c29ae57300e0 # Conflicts: # source/build/src/polymost.cpp # source/build/src/texcache.cpp # source/build/src/tilepacker.cpp --- source/audiolib/src/flac.cpp | 6 +++--- source/audiolib/src/vorbis.cpp | 14 +++++++------- source/build/include/cache1d.h | 14 +++++--------- source/build/include/crc32.h | 2 +- source/build/include/klzw.h | 4 ++-- source/build/include/osd.h | 2 +- source/build/include/pngwrite.h | 2 +- source/build/include/print.h | 20 ++++++++++---------- source/build/src/cache1d.cpp | 20 ++++++++++---------- source/build/src/crc32.cpp | 2 +- source/build/src/klzw.cpp | 20 +++++++++----------- source/build/src/osd.cpp | 4 ++-- source/build/src/pngwrite.cpp | 12 ++++++------ source/build/src/screenshot.cpp | 2 +- source/duke3d/src/actors.cpp | 12 ++++++------ source/duke3d/src/anim.cpp | 4 ++-- source/duke3d/src/game.cpp | 6 +++--- source/duke3d/src/network.cpp | 2 +- source/duke3d/src/screentext.cpp | 2 +- source/duke3d/src/sector.cpp | 2 +- 20 files changed, 73 insertions(+), 79 deletions(-) diff --git a/source/audiolib/src/flac.cpp b/source/audiolib/src/flac.cpp index 7fe7c6439..36f5f445f 100644 --- a/source/audiolib/src/flac.cpp +++ b/source/audiolib/src/flac.cpp @@ -547,21 +547,21 @@ int32_t MV_PlayFLAC(char *ptr, uint32_t length, int32_t loopstart, int32_t loope const size_t field = value - entry; value += 1; - for (size_t t = 0; t < loopStartTagCount && vc_loopstart == NULL; ++t) + for (int t = 0; t < loopStartTagCount && vc_loopstart == NULL; ++t) { char const * const tag = loopStartTags[t]; if (field == strlen(tag) && Bstrncasecmp(entry, tag, field) == 0) vc_loopstart = Xstrdup(value); } - for (size_t t = 0; t < loopEndTagCount && vc_loopend == NULL; ++t) + for (int t = 0; t < loopEndTagCount && vc_loopend == NULL; ++t) { char const * const tag = loopEndTags[t]; if (field == strlen(tag) && Bstrncasecmp(entry, tag, field) == 0) vc_loopend = Xstrdup(value); } - for (size_t t = 0; t < loopLengthTagCount && vc_looplength == NULL; ++t) + for (int t = 0; t < loopLengthTagCount && vc_looplength == NULL; ++t) { char const * const tag = loopLengthTags[t]; if (field == strlen(tag) && Bstrncasecmp(entry, tag, field) == 0) diff --git a/source/audiolib/src/vorbis.cpp b/source/audiolib/src/vorbis.cpp index b12354a61..a186fa748 100644 --- a/source/audiolib/src/vorbis.cpp +++ b/source/audiolib/src/vorbis.cpp @@ -78,21 +78,21 @@ static void MV_GetVorbisCommentLoops(VoiceNode *voice, vorbis_comment *vc) const size_t field = value - entry; value += 1; - for (size_t t = 0; t < loopStartTagCount && vc_loopstart == NULL; ++t) + for (int t = 0; t < loopStartTagCount && vc_loopstart == NULL; ++t) { auto tag = loopStartTags[t]; if (field == Bstrlen(tag) && Bstrncasecmp(entry, tag, field) == 0) vc_loopstart = value; } - for (size_t t = 0; t < loopEndTagCount && vc_loopend == NULL; ++t) + for (int t = 0; t < loopEndTagCount && vc_loopend == NULL; ++t) { auto tag = loopEndTags[t]; if (field == Bstrlen(tag) && Bstrncasecmp(entry, tag, field) == 0) vc_loopend = value; } - for (size_t t = 0; t < loopLengthTagCount && vc_looplength == NULL; ++t) + for (int t = 0; t < loopLengthTagCount && vc_looplength == NULL; ++t) { auto tag = loopLengthTags[t]; if (field == Bstrlen(tag) && Bstrncasecmp(entry, tag, field) == 0) @@ -141,14 +141,14 @@ static size_t read_vorbis(void *ptr, size_t size, size_t nmemb, void *datasource if (vorb->length == vorb->pos) return 0; - size_t nread = 0; + int32_t nread = 0; for (; nmemb > 0; nmemb--, nread++) { - size_t bytes = vorb->length - vorb->pos; + int32_t bytes = vorb->length - vorb->pos; - if (size < bytes) - bytes = size; + if ((signed)size < bytes) + bytes = (int32_t)size; memcpy(ptr, (uint8_t *)vorb->ptr + vorb->pos, bytes); vorb->pos += bytes; diff --git a/source/build/include/cache1d.h b/source/build/include/cache1d.h index e9b08b883..d4da089ee 100644 --- a/source/build/include/cache1d.h +++ b/source/build/include/cache1d.h @@ -149,17 +149,13 @@ typedef struct _CACHE1D_FIND_REC { } CACHE1D_FIND_REC; int32_t klistaddentry(CACHE1D_FIND_REC **rec, const char *name, int32_t type, int32_t source); void klistfree(CACHE1D_FIND_REC *rec); -CACHE1D_FIND_REC *klistpath(const char *path, const char *mask, int32_t type); +CACHE1D_FIND_REC *klistpath(const char *path, const char *mask, int type); extern int32_t lz4CompressionLevel; -int32_t kdfread(void *buffer, bsize_t dasizeof, bsize_t count, buildvfs_kfd fil); -int32_t kdfread_LZ4(void *buffer, bsize_t dasizeof, bsize_t count, buildvfs_kfd fil); -#if 0 -int32_t dfread(void *buffer, bsize_t dasizeof, bsize_t count, buildvfs_FILE fil); -void kdfwrite(const void *buffer, bsize_t dasizeof, bsize_t count, buildvfs_kfd fil); -#endif -void dfwrite(const void *buffer, bsize_t dasizeof, bsize_t count, buildvfs_FILE fil); -void dfwrite_LZ4(const void *buffer, bsize_t dasizeof, bsize_t count, buildvfs_FILE fil); +int32_t kdfread(void *buffer, int dasizeof, int count, buildvfs_kfd fil); +int32_t kdfread_LZ4(void *buffer, int dasizeof, int count, buildvfs_kfd fil); +void dfwrite(const void *buffer, int dasizeof, int count, buildvfs_FILE fil); +void dfwrite_LZ4(const void *buffer, int dasizeof, int count, buildvfs_FILE fil); #ifdef __cplusplus } diff --git a/source/build/include/crc32.h b/source/build/include/crc32.h index 28ae39d43..897f54d36 100644 --- a/source/build/include/crc32.h +++ b/source/build/include/crc32.h @@ -15,7 +15,7 @@ extern uint32_t crc32table[8][256]; extern uint32_t crc32table[4][256]; #endif -extern uint32_t Bcrc32(const void* data, size_t length, uint32_t crc); +extern uint32_t Bcrc32(const void* data, int length, uint32_t crc); extern void initcrc32table(void); #ifdef __cplusplus diff --git a/source/build/include/klzw.h b/source/build/include/klzw.h index 76939c185..331526f39 100644 --- a/source/build/include/klzw.h +++ b/source/build/include/klzw.h @@ -20,8 +20,8 @@ extern "C" { typedef int32_t (*klzw_readfunc)(intptr_t, void *, int32_t); typedef void (*klzw_writefunc)(intptr_t, void const *, int32_t); -int32_t klzw_read_compressed(void *buffer, bsize_t dasizeof, bsize_t count, intptr_t f, klzw_readfunc readfunc); -void klzw_write_compressed(const void *buffer, bsize_t dasizeof, bsize_t count, intptr_t f, klzw_writefunc writefunc); +int32_t klzw_read_compressed(void *buffer, int dasizeof, int count, intptr_t const f, klzw_readfunc readfunc); +void klzw_write_compressed(const void * const buffer, int dasizeof, int count, intptr_t const f, klzw_writefunc writefunc); #ifdef __cplusplus } diff --git a/source/build/include/osd.h b/source/build/include/osd.h index eed27ce43..c04f25e64 100644 --- a/source/build/include/osd.h +++ b/source/build/include/osd.h @@ -176,7 +176,7 @@ typedef struct uint32_t flags; // controls initialization, etc osdcvar_t *cvars; - uint32_t numcvars; + int32_t numcvars; osdsymbol_t *symbols; osdsymbol_t *symbptrs[OSDMAXSYMBOLS]; diff --git a/source/build/include/pngwrite.h b/source/build/include/pngwrite.h index 23125d1b7..7423dd3ed 100644 --- a/source/build/include/pngwrite.h +++ b/source/build/include/pngwrite.h @@ -34,6 +34,6 @@ typedef struct void png_set_pal(uint8_t const * data, int numentries); void png_set_text(char const * keyword, char const * text); -void png_write(buildvfs_FILE file, uint32_t width, uint32_t height, uint8_t type, uint8_t const * data); +void png_write(buildvfs_FILE const file, int const width, int const height, uint8_t const type, uint8_t const * const data); #endif diff --git a/source/build/include/print.h b/source/build/include/print.h index c3362fd8c..7f02db5dc 100644 --- a/source/build/include/print.h +++ b/source/build/include/print.h @@ -99,11 +99,11 @@ enable_if_t::value, size_t> buildprintpiece(binwrap x) { make_unsigned_t const data = x.data; - size_t constexpr numChars = sizeof(x)*CHAR_BIT; + int constexpr numChars = sizeof(x)*CHAR_BIT; char str[numChars+1]; str[numChars] = '\0'; - for (size_t p = 0; p < numChars; ++p) + for (int p = 0; p < numChars; ++p) str[numChars - 1 - p] = '0' + (char)((data >> p) & 1); initputs(str); @@ -115,11 +115,11 @@ enable_if_t::value, size_t> buildprintpiece(octwrap x) { make_unsigned_t const data = x.data; - size_t constexpr numChars = (sizeof(x)*CHAR_BIT + 2) / 3; + int constexpr numChars = (sizeof(x)*CHAR_BIT + 2) / 3; char str[numChars+1]; str[numChars] = '\0'; - for (size_t p = 0; p < numChars; ++p) + for (int p = 0; p < numChars; ++p) str[numChars - 1 - p] = '0' + (char)((data >> (p*3)) & 7); initputs(str); @@ -133,12 +133,12 @@ enable_if_t::value, size_t> buildprintpiece(hexwrap x) make_unsigned_t const data = x.data; - size_t constexpr numChars = (sizeof(x)*CHAR_BIT + 3) / 4; + int constexpr numChars = (sizeof(x)*CHAR_BIT + 3) >> 2; char str[numChars+1]; str[numChars] = '\0'; - for (size_t p = 0; p < numChars; ++p) - str[numChars - 1 - p] = hexletters[(size_t)((data >> (p*4)) & 0xF)]; + for (int p = 0; p < numChars; ++p) + str[numChars - 1 - p] = hexletters[(int)((data >> (p<<2)) & 0xF)]; initputs(str); return numChars; @@ -151,12 +151,12 @@ enable_if_t::value, size_t> buildprintpiece(HEXwrap x) make_unsigned_t const data = x.data; - size_t constexpr numChars = (sizeof(x)*CHAR_BIT + 3) / 4; + int constexpr numChars = (sizeof(x)*CHAR_BIT + 3) >> 2; char str[numChars+1]; str[numChars] = '\0'; - for (size_t p = 0; p < numChars; ++p) - str[numChars - 1 - p] = HEXletters[(size_t)((data >> (p*4)) & 0xF)]; + for (int p = 0; p < numChars; ++p) + str[numChars - 1 - p] = HEXletters[(int)((data >> (p<<2)) & 0xF)]; initputs(str); return numChars; diff --git a/source/build/src/cache1d.cpp b/source/build/src/cache1d.cpp index 1bba638bd..14e5e6c96 100644 --- a/source/build/src/cache1d.cpp +++ b/source/build/src/cache1d.cpp @@ -817,7 +817,7 @@ int initgroupfile(const char *filename) } temp2 = 0; - for (uint8_t i=0;i<3;i++) + for (int i=0;i<3;i++) { // get the string length kread_grp(numgroupfiles, &temp, 1); @@ -1430,7 +1430,7 @@ CACHE1D_FIND_REC *klistpath(const char *_path, const char *mask, int32_t type) if ((name[0] == '.' && name[1] == 0) || (name[0] == '.' && name[1] == '.' && name[2] == 0)) continue; - + bool const isdir = buildvfs_isdir(name); if ((type & CACHE1D_FIND_DIR) && !isdir) continue; if ((type & CACHE1D_FIND_FILE) && isdir) continue; @@ -1657,7 +1657,7 @@ static void dfwrite_func(intptr_t fp, const void *inbuf, int32_t length) } -int32_t kdfread(void *buffer, bsize_t dasizeof, bsize_t count, buildvfs_kfd fil) +int32_t kdfread(void *buffer, int dasizeof, int count, buildvfs_kfd fil) { return klzw_read_compressed(buffer, dasizeof, count, (intptr_t)fil, kdfread_func); } @@ -1669,7 +1669,7 @@ int32_t kdfread(void *buffer, bsize_t dasizeof, bsize_t count, buildvfs_kfd fil) static char compressedDataStackBuf[131072]; int32_t lz4CompressionLevel = LZ4_COMPRESSION_ACCELERATION_VALUE; -int32_t kdfread_LZ4(void *buffer, bsize_t dasizeof, bsize_t count, buildvfs_kfd fil) +int32_t kdfread_LZ4(void *buffer, int dasizeof, int count, buildvfs_kfd fil) { int32_t leng; @@ -1696,21 +1696,21 @@ int32_t kdfread_LZ4(void *buffer, bsize_t dasizeof, bsize_t count, buildvfs_kfd } -void dfwrite(const void *buffer, bsize_t dasizeof, bsize_t count, buildvfs_FILE fil) +void dfwrite(const void *buffer, int dasizeof, int count, buildvfs_FILE fil) { klzw_write_compressed(buffer, dasizeof, count, (intptr_t)fil, dfwrite_func); } -void dfwrite_LZ4(const void *buffer, bsize_t dasizeof, bsize_t count, buildvfs_FILE fil) +void dfwrite_LZ4(const void *buffer, int dasizeof, int count, buildvfs_FILE fil) { - char * pCompressedData = compressedDataStackBuf; - int32_t const maxCompressedSize = LZ4_compressBound(dasizeof * count); + char * pCompressedData = compressedDataStackBuf; + int const maxCompressedSize = LZ4_compressBound(dasizeof * count); if (maxCompressedSize > ARRAY_SSIZE(compressedDataStackBuf)) pCompressedData = (char *)Xaligned_alloc(16, maxCompressedSize); - int32_t const leng = LZ4_compress_fast((const char*) buffer, pCompressedData, dasizeof*count, maxCompressedSize, lz4CompressionLevel); - int32_t const swleng = B_LITTLE32(leng); + int const leng = LZ4_compress_fast((const char*) buffer, pCompressedData, dasizeof*count, maxCompressedSize, lz4CompressionLevel); + int const swleng = B_LITTLE32(leng); buildvfs_fwrite(&swleng, sizeof(swleng), 1, fil); buildvfs_fwrite(pCompressedData, leng, 1, fil); diff --git a/source/build/src/crc32.cpp b/source/build/src/crc32.cpp index c889d7cbc..81636ba5c 100644 --- a/source/build/src/crc32.cpp +++ b/source/build/src/crc32.cpp @@ -3,7 +3,7 @@ #include "compat.h" #include "crc32.h" -uint32_t Bcrc32(const void* data, size_t length, uint32_t crc) +uint32_t Bcrc32(const void* data, int length, uint32_t crc) { const uint32_t* current = (const uint32_t*) data; uint8_t const * currentChar; diff --git a/source/build/src/klzw.cpp b/source/build/src/klzw.cpp index ca385c75b..3583445fd 100644 --- a/source/build/src/klzw.cpp +++ b/source/build/src/klzw.cpp @@ -213,10 +213,10 @@ struct decompress_info { klzw_readfunc readfunc; intptr_t f; - uint32_t kgoal; + int32_t kgoal; }; -static uint32_t decompress_part(struct decompress_info * x) +static int decompress_part(struct decompress_info * x) { intptr_t const f = x->f; auto readfunc = x->readfunc; @@ -236,7 +236,7 @@ static uint32_t decompress_part(struct decompress_info * x) } // Read from 'f' into 'buffer'. -int32_t klzw_read_compressed(void *buffer, bsize_t dasizeof, bsize_t count, intptr_t f, klzw_readfunc readfunc) +int32_t klzw_read_compressed(void *buffer, int dasizeof, int count, intptr_t const f, klzw_readfunc readfunc) { char *ptr = (char *)buffer; @@ -255,9 +255,7 @@ int32_t klzw_read_compressed(void *buffer, bsize_t dasizeof, bsize_t count, intp Bmemcpy(ptr, lzwrawbuf, (int32_t)dasizeof); - uint32_t k = (int32_t)dasizeof; - - for (uint32_t i=1; i= x.kgoal) { @@ -265,7 +263,7 @@ int32_t klzw_read_compressed(void *buffer, bsize_t dasizeof, bsize_t count, intp if (k) return -1; } - uint32_t j = 0; + int j = 0; if (dasizeof >= 4) { @@ -295,7 +293,7 @@ struct compress_info { klzw_writefunc writefunc; intptr_t f; - uint32_t k; + int32_t k; }; static void compress_part(struct compress_info * x) @@ -313,7 +311,7 @@ static void compress_part(struct compress_info * x) } // Write from 'buffer' to 'f'. -void klzw_write_compressed(const void *buffer, bsize_t dasizeof, bsize_t count, intptr_t f, klzw_writefunc writefunc) +void klzw_write_compressed(const void * const buffer, int dasizeof, int count, intptr_t const f, klzw_writefunc writefunc) { char const *ptr = (char const *)buffer; @@ -332,9 +330,9 @@ void klzw_write_compressed(const void *buffer, bsize_t dasizeof, bsize_t count, if ((x.k = dasizeof) > LZWSIZE-dasizeof) compress_part(&x); - for (uint32_t i=1; i= 4) { diff --git a/source/build/src/osd.cpp b/source/build/src/osd.cpp index cd18c6bff..892f65653 100644 --- a/source/build/src/osd.cpp +++ b/source/build/src/osd.cpp @@ -528,7 +528,7 @@ static int osdfunc_listsymbols(osdcmdptr_t parm) int const var = hash_find(&h_cvars, symb->name); - if ((unsigned)var < osd->numcvars && OSD_CvarModified(&osd->cvars[var])) + if ((unsigned)var < OSDMAXSYMBOLS && OSD_CvarModified(&osd->cvars[var])) { OSD_Printf("%s*", osd->draw.highlight); OSD_Printf("%-*s", maxwidth-1, symb->name); @@ -2203,7 +2203,7 @@ void OSD_WriteCvars(buildvfs_FILE fp) char buf[64]; - for (unsigned i = 0; i < osd->numcvars; i++) + for (int i = 0; i < osd->numcvars; i++) { osdcvardata_t const &pData = *osd->cvars[i].pData; diff --git a/source/build/src/pngwrite.cpp b/source/build/src/pngwrite.cpp index 1e5e5ae80..58735bf17 100644 --- a/source/build/src/pngwrite.cpp +++ b/source/build/src/pngwrite.cpp @@ -59,14 +59,14 @@ void png_set_text(char const * const keyword, char const * const text) Bmemcpy(png.text + keylen + 1, text, textlen); } -void png_write(buildvfs_FILE const file, uint32_t const width, uint32_t const height, +void png_write(buildvfs_FILE const file, int const width, int const height, uint8_t const type, uint8_t const * const data) { png.file = file; png_write_buf("\x89\x50\x4E\x47\x0D\x0A\x1A\x0A", 8); - png_ihdr_t const png_header = { B_BIG32(width), B_BIG32(height), 8, type, 0 }; + png_ihdr_t const png_header = { B_BIG32((unsigned)width), B_BIG32((unsigned)height), 8, type, 0 }; png_write_chunk(sizeof(png_ihdr_t), "IHDR", (uint8_t const *)&png_header, 0); if (png.text) @@ -75,8 +75,8 @@ void png_write(buildvfs_FILE const file, uint32_t const width, uint32_t const he DO_FREE_AND_NULL(png.text); } - uint32_t const bytesPerPixel = (type == PNG_TRUECOLOR ? 3 : 1); - uint32_t const bytesPerLine = width * bytesPerPixel; + int const bytesPerPixel = (type == PNG_TRUECOLOR ? 3 : 1); + int const bytesPerLine = width * bytesPerPixel; if (png.pal_data) { @@ -84,10 +84,10 @@ void png_write(buildvfs_FILE const file, uint32_t const width, uint32_t const he DO_FREE_AND_NULL(png.pal_data); } - unsigned const linesiz = height * bytesPerLine + height; + int const linesiz = height * bytesPerLine + height; uint8_t *lines = (uint8_t *) Xcalloc(1, linesiz); - for (unative_t i = 0; i < height; i++) + for (int i = 0; i < height; i++) Bmemcpy(lines + i * bytesPerLine + i + 1, data + i * bytesPerLine, bytesPerLine); png_write_chunk(linesiz, "IDAT", lines, CHUNK_COMPRESSED); diff --git a/source/build/src/screenshot.cpp b/source/build/src/screenshot.cpp index a071f9a7e..e3ffd71ce 100644 --- a/source/build/src/screenshot.cpp +++ b/source/build/src/screenshot.cpp @@ -77,7 +77,7 @@ int videoCaptureScreen(const char *filename, char inverseit) if (inverseit) { - for (bsize_t i=0, j = ydim * bytesPerLine; iz) < ZOFFSET2) { #ifndef EDUKE32_STANDALONE - for (size_t x = 0, x_end = 1+(krand()&7); x < x_end; ++x) + for (int x = 0, x_end = 1+(krand()&7); x < x_end; ++x) RANDOMSCRAP(pSprite, spriteNum); #endif DELETE_SPRITE_AND_CONTINUE(spriteNum); @@ -2136,7 +2136,7 @@ crack_default: if (A_IncurDamage(spriteNum) < 0) goto next_sprite; - for (bsize_t k=0; k<16; k++) + for (int k=0; k<16; k++) { j = A_InsertSprite(SECT(spriteNum), SX(spriteNum), SY(spriteNum), SZ(spriteNum) - (krand() % (48 << 8)), SCRAP3 + (krand() & 3), -8, 48, 48, krand() & 2047, (krand() & 63) + 64, @@ -2265,7 +2265,7 @@ DETONATE: #ifndef EDUKE32_STANDALONE if (pSprite->xrepeat) - for (bsize_t x=0; x<8; x++) + for (int x=0; x<8; x++) RANDOMSCRAP(pSprite, spriteNum); #endif @@ -5240,7 +5240,7 @@ ACTOR_STATIC void G_MoveMisc(void) // STATNUM 5 pSprite->yrepeat = forceRepeat; pSprite->shade = (forceRepeat >> 1) - 48; - for (bsize_t j = pData[0]; j > 0; j--) + for (int j = pData[0]; j > 0; j--) A_SetSprite(spriteNum, CLIPMASK0); goto next_sprite; } @@ -6602,7 +6602,7 @@ ACTOR_STATIC void G_MoveEffectors(void) //STATNUM 3 walltype *pWall = &wall[sector[sectNum].wallptr]; - for (bsize_t l=sector[sectNum].wallnum; l>0; l--, pWall++) + for (int l=sector[sectNum].wallnum; l>0; l--, pWall++) { if (pWall->hitag == 1) continue; @@ -8109,7 +8109,7 @@ static void A_DoLight(int spriteNum) return; #ifndef EDUKE32_STANDALONE - for (bsize_t ii=0; ii<2; ii++) + for (int ii=0; ii<2; ii++) { if (pSprite->picnum <= 0) // oob safety break; diff --git a/source/duke3d/src/anim.cpp b/source/duke3d/src/anim.cpp index 6896c5d66..1c1f95d6f 100644 --- a/source/duke3d/src/anim.cpp +++ b/source/duke3d/src/anim.cpp @@ -207,8 +207,8 @@ void Anim_Init(void) if (anm.numsounds) { anim->sounds = (animsound_t *)Xmalloc(anm.numsounds * sizeof(animsound_t)); - size_t const numsounds = anm.numsounds; - for (size_t i = 0; i < numsounds; ++i) + int const numsounds = anm.numsounds; + for (int i = 0; i < numsounds; ++i) { defaultanmsound const & src = anm.sounds[i]; animsound_t & dst = anim->sounds[i]; diff --git a/source/duke3d/src/game.cpp b/source/duke3d/src/game.cpp index 1244ab026..2249a4722 100644 --- a/source/duke3d/src/game.cpp +++ b/source/duke3d/src/game.cpp @@ -7047,7 +7047,7 @@ void A_SpawnWallGlass(int spriteNum, int wallNum, int glassCnt) int16_t sect = -1; - for (bsize_t j = glassCnt; j > 0; --j) + for (int j = glassCnt; j > 0; --j) { v1.x += v.x; v1.y += v.y; @@ -7088,7 +7088,7 @@ void A_SpawnCeilingGlass(int spriteNum, int sectNum, int glassCnt) vec2_t v = { tabledivide32_noinline(wall[wallNum + 1].x - v1.x, glassCnt + 1), tabledivide32_noinline(wall[wallNum + 1].y - v1.y, glassCnt + 1) }; - for (bsize_t j = glassCnt; j > 0; j--) + for (int j = glassCnt; j > 0; j--) { v1.x += v.x; v1.y += v.y; @@ -7117,7 +7117,7 @@ void A_SpawnRandomGlass(int spriteNum, int wallNum, int glassCnt) tabledivide32_noinline(wall[wall[wallNum].point2].y - wall[wallNum].y, glassCnt + 1) }; int16_t sectNum = sprite[spriteNum].sectnum; - for (bsize_t j = glassCnt; j > 0; j--) + for (int j = glassCnt; j > 0; j--) { v1.x += v.x; v1.y += v.y; diff --git a/source/duke3d/src/network.cpp b/source/duke3d/src/network.cpp index 08ff5963e..4489159bd 100644 --- a/source/duke3d/src/network.cpp +++ b/source/duke3d/src/network.cpp @@ -2281,7 +2281,7 @@ static void Net_ReceiveServerUpdate(ENetEvent *event) ticrandomseed = serverupdate.seed; - for (uint32_t playerIndex = 0; playerIndex < serverupdate.numplayers; ++playerIndex) + for (int playerIndex = 0; playerIndex < serverupdate.numplayers; ++playerIndex) { Bmemcpy(&playerupdate, updatebuf, sizeof(serverplayerupdate_t)); updatebuf += sizeof(serverplayerupdate_t); diff --git a/source/duke3d/src/screentext.cpp b/source/duke3d/src/screentext.cpp index 8187efa13..62911d739 100644 --- a/source/duke3d/src/screentext.cpp +++ b/source/duke3d/src/screentext.cpp @@ -1112,7 +1112,7 @@ void G_PrintGameQuotes(int32_t snum) if (k > 1 && !reserved_quote) y += k <= 8 ? (height * (k-1))>>3 : height; - for (size_t i = MAXUSERQUOTES-1; i < MAXUSERQUOTES; --i) + for (int i = 0; i < MAXUSERQUOTES; i++) { k = user_quote_time[i]; diff --git a/source/duke3d/src/sector.cpp b/source/duke3d/src/sector.cpp index a483dfb51..c28a05ef7 100644 --- a/source/duke3d/src/sector.cpp +++ b/source/duke3d/src/sector.cpp @@ -1039,7 +1039,7 @@ void G_OperateActivators(int lotag, int playerNum) sector[pCycler[0]].ceilingshade = pCycler[3]; walltype *pWall = &wall[sector[pCycler[0]].wallptr]; - for (bsize_t j = sector[pCycler[0]].wallnum; j > 0; j--, pWall++) + for (int j = sector[pCycler[0]].wallnum; j > 0; j--, pWall++) pWall->shade = pCycler[3]; } }