More fixes for int compare sign mismatch warnings in Qt TAS Editor.

This commit is contained in:
harry 2023-01-28 16:24:04 -05:00
parent 7910da7805
commit 213f4e2579
3 changed files with 30 additions and 25 deletions

View File

@ -359,7 +359,8 @@ void GREENZONE::save(EMUFILE *os, int save_type)
// returns true if couldn't load // returns true if couldn't load
bool GREENZONE::load(EMUFILE *is, unsigned int offset) bool GREENZONE::load(EMUFILE *is, unsigned int offset)
{ {
int frame = 0, prev_frame = -1, size = 0; int frame = 0, prev_frame = -1;
unsigned int size = 0;
int last_tick = -1; int last_tick = -1;
char save_id[GREENZONE_ID_LEN]; char save_id[GREENZONE_ID_LEN];
@ -375,7 +376,7 @@ bool GREENZONE::load(EMUFILE *is, unsigned int offset)
return false; return false;
} }
// read "GREENZONE" string // read "GREENZONE" string
if ((int)is->fread(save_id, GREENZONE_ID_LEN) < GREENZONE_ID_LEN) goto error; if (is->fread(save_id, GREENZONE_ID_LEN) < GREENZONE_ID_LEN) goto error;
if (!strcmp(greenzone_skipsave_id, save_id)) if (!strcmp(greenzone_skipsave_id, save_id))
{ {
// string says to skip loading Greenzone // string says to skip loading Greenzone
@ -419,7 +420,7 @@ bool GREENZONE::load(EMUFILE *is, unsigned int offset)
// read LagLog // read LagLog
lagLog.load(is); lagLog.load(is);
// read size // read size
if (read32le(&size, is) && size >= 0 && size <= currMovieData.getNumRecords()) if (read32le(&size, is) && size <= currMovieData.getNumRecords())
{ {
greenzoneSize = size; greenzoneSize = size;
savestates.resize(greenzoneSize); savestates.resize(greenzoneSize);
@ -461,7 +462,7 @@ bool GREENZONE::load(EMUFILE *is, unsigned int offset)
if ((int)savestates.size() <= frame) if ((int)savestates.size() <= frame)
savestates.resize(frame + 1); savestates.resize(frame + 1);
savestates[frame].resize(size); savestates[frame].resize(size);
if ((int)is->fread(&savestates[frame][0], size) < size) break; if (is->fread(&savestates[frame][0], size) < size) break;
prev_frame = frame; // successfully read one Greenzone frame info prev_frame = frame; // successfully read one Greenzone frame info
} }
} }

View File

@ -180,14 +180,14 @@ bool INPUTLOG::load(EMUFILE *is)
inputType = tmp; inputType = tmp;
// read data // read data
alreadyCompressed = true; alreadyCompressed = true;
int comprlen; unsigned int comprlen;
uLongf destlen; uLongf destlen;
// read and uncompress joysticks data // read and uncompress joysticks data
destlen = size * BYTES_PER_JOYSTICK * joysticksPerFrame[inputType]; destlen = size * BYTES_PER_JOYSTICK * joysticksPerFrame[inputType];
joysticks.resize(destlen); joysticks.resize(destlen);
// read size // read size
if (!read32le(&comprlen, is)) return true; if (!read32le(&comprlen, is)) return true;
if (comprlen <= 0) return true; if (comprlen == 0) return true;
compressedJoysticks.resize(comprlen); compressedJoysticks.resize(comprlen);
if (is->fread(&compressedJoysticks[0], comprlen) != comprlen) return true; if (is->fread(&compressedJoysticks[0], comprlen) != comprlen) return true;
int e = uncompress(&joysticks[0], &destlen, &compressedJoysticks[0], comprlen); int e = uncompress(&joysticks[0], &destlen, &compressedJoysticks[0], comprlen);
@ -212,7 +212,7 @@ bool INPUTLOG::load(EMUFILE *is)
hotChanges.resize(destlen); hotChanges.resize(destlen);
// read size // read size
if (!read32le(&comprlen, is)) return true; if (!read32le(&comprlen, is)) return true;
if (comprlen <= 0) return true; if (comprlen == 0) return true;
compressedHotChanges.resize(comprlen); compressedHotChanges.resize(comprlen);
if (is->fread(&compressedHotChanges[0], comprlen) != comprlen) return true; if (is->fread(&compressedHotChanges[0], comprlen) != comprlen) return true;
e = uncompress(&hotChanges[0], &destlen, &compressedHotChanges[0], comprlen); e = uncompress(&hotChanges[0], &destlen, &compressedHotChanges[0], comprlen);
@ -222,7 +222,7 @@ bool INPUTLOG::load(EMUFILE *is)
} }
bool INPUTLOG::skipLoad(EMUFILE *is) bool INPUTLOG::skipLoad(EMUFILE *is)
{ {
int tmp; unsigned int tmp;
uint8 tmp1; uint8 tmp1;
// skip vars // skip vars
if (is->fseek(sizeof(int) + // size if (is->fseek(sizeof(int) + // size

View File

@ -33,14 +33,15 @@ void LAGLOG::reset(void)
void LAGLOG::compressData(void) void LAGLOG::compressData(void)
{ {
int len = lagLog.size() * sizeof(uint8); unsigned int len = lagLog.size() * sizeof(uint8);
if (len) if (len)
{ {
uLongf comprlen = (len>>9)+12 + len; uLongf comprlen = (len>>9)+12 + len;
compressedLagLog.resize(comprlen, LAGGED_UNKNOWN); compressedLagLog.resize(comprlen, LAGGED_UNKNOWN);
compress(&compressedLagLog[0], &comprlen, (uint8*)&lagLog[0], len); compress(&compressedLagLog[0], &comprlen, (uint8*)&lagLog[0], len);
compressedLagLog.resize(comprlen); compressedLagLog.resize(comprlen);
} else }
else
{ {
// LagLog can even be empty // LagLog can even be empty
compressedLagLog.resize(0); compressedLagLog.resize(0);
@ -59,7 +60,7 @@ void LAGLOG::resetCompressedStatus(void)
void LAGLOG::save(EMUFILE *os) void LAGLOG::save(EMUFILE *os)
{ {
// write size // write size
int size = lagLog.size(); unsigned int size = lagLog.size();
write32le(size, os); write32le(size, os);
if (size) if (size)
{ {
@ -73,7 +74,7 @@ void LAGLOG::save(EMUFILE *os)
// returns true if couldn't load // returns true if couldn't load
bool LAGLOG::load(EMUFILE *is) bool LAGLOG::load(EMUFILE *is)
{ {
int size; unsigned int size;
if (read32le(&size, is)) if (read32le(&size, is))
{ {
alreadyCompressed = true; alreadyCompressed = true;
@ -81,15 +82,16 @@ bool LAGLOG::load(EMUFILE *is)
if (size) if (size)
{ {
// read and uncompress array // read and uncompress array
int comprlen; unsigned int comprlen;
uLongf destlen = size * sizeof(int); uLongf destlen = size * sizeof(int);
if (!read32le(&comprlen, is)) return true; if (!read32le(&comprlen, is)) return true;
if (comprlen <= 0) return true; if (comprlen == 0) return true;
compressedLagLog.resize(comprlen); compressedLagLog.resize(comprlen);
if (is->fread(&compressedLagLog[0], comprlen) != comprlen) return true; if (is->fread(&compressedLagLog[0], comprlen) != comprlen) return true;
int e = uncompress((uint8*)&lagLog[0], &destlen, &compressedLagLog[0], comprlen); int e = uncompress((uint8*)&lagLog[0], &destlen, &compressedLagLog[0], comprlen);
if (e != Z_OK && e != Z_BUF_ERROR) return true; if (e != Z_OK && e != Z_BUF_ERROR) return true;
} else }
else
{ {
compressedLagLog.resize(0); compressedLagLog.resize(0);
} }
@ -100,7 +102,7 @@ bool LAGLOG::load(EMUFILE *is)
} }
bool LAGLOG::skipLoad(EMUFILE *is) bool LAGLOG::skipLoad(EMUFILE *is)
{ {
int size; unsigned int size;
if (read32le(&size, is)) if (read32le(&size, is))
{ {
if (size) if (size)
@ -117,7 +119,7 @@ bool LAGLOG::skipLoad(EMUFILE *is)
// ------------------------------------------------------------------------------------------------- // -------------------------------------------------------------------------------------------------
void LAGLOG::invalidateFromFrame(int frame) void LAGLOG::invalidateFromFrame(int frame)
{ {
if (frame >= 0 && frame < (int)lagLog.size()) if (frame >= 0 && static_cast<size_t>(frame) < lagLog.size())
{ {
lagLog.resize(frame); lagLog.resize(frame);
alreadyCompressed = false; alreadyCompressed = false;
@ -126,7 +128,7 @@ void LAGLOG::invalidateFromFrame(int frame)
void LAGLOG::setLagInfo(int frame, bool lagFlag) void LAGLOG::setLagInfo(int frame, bool lagFlag)
{ {
if ((int)lagLog.size() <= frame) if (lagLog.size() <= static_cast<size_t>(frame))
lagLog.resize(frame + 1, LAGGED_UNKNOWN); lagLog.resize(frame + 1, LAGGED_UNKNOWN);
if (lagFlag) if (lagFlag)
@ -138,18 +140,19 @@ void LAGLOG::setLagInfo(int frame, bool lagFlag)
} }
void LAGLOG::eraseFrame(int frame, int numFrames) void LAGLOG::eraseFrame(int frame, int numFrames)
{ {
if (frame < (int)lagLog.size()) if ( static_cast<size_t>(frame) < lagLog.size())
{ {
if (numFrames == 1) if (numFrames == 1)
{ {
// erase 1 frame // erase 1 frame
lagLog.erase(lagLog.begin() + frame); lagLog.erase(lagLog.begin() + frame);
alreadyCompressed = false; alreadyCompressed = false;
} else if (numFrames > 1) }
else if (numFrames > 1)
{ {
// erase many frames // erase many frames
if (frame + numFrames > (int)lagLog.size()) if ( static_cast<size_t>(frame + numFrames) > lagLog.size())
numFrames = (int)lagLog.size() - frame; numFrames = static_cast<int>(lagLog.size()) - frame;
lagLog.erase(lagLog.begin() + frame, lagLog.begin() + (frame + numFrames)); lagLog.erase(lagLog.begin() + frame, lagLog.begin() + (frame + numFrames));
alreadyCompressed = false; alreadyCompressed = false;
} }
@ -157,11 +160,12 @@ void LAGLOG::eraseFrame(int frame, int numFrames)
} }
void LAGLOG::insertFrame(int frame, bool lagFlag, int numFrames) void LAGLOG::insertFrame(int frame, bool lagFlag, int numFrames)
{ {
if (frame < (int)lagLog.size()) if ( static_cast<size_t>(frame) < lagLog.size())
{ {
// insert // insert
lagLog.insert(lagLog.begin() + frame, numFrames, (lagFlag) ? LAGGED_YES : LAGGED_NO); lagLog.insert(lagLog.begin() + frame, numFrames, (lagFlag) ? LAGGED_YES : LAGGED_NO);
} else }
else
{ {
// append // append
lagLog.resize(frame + 1, LAGGED_UNKNOWN); lagLog.resize(frame + 1, LAGGED_UNKNOWN);
@ -180,7 +184,7 @@ int LAGLOG::getSize(void)
} }
int LAGLOG::getLagInfoAtFrame(int frame) int LAGLOG::getLagInfoAtFrame(int frame)
{ {
if (frame < (int)lagLog.size()) if (static_cast<size_t>(frame) < lagLog.size())
return lagLog[frame]; return lagLog[frame];
else else
return LAGGED_UNKNOWN; return LAGGED_UNKNOWN;