From 158826ed633732068c685040723e07b6fa16d801 Mon Sep 17 00:00:00 2001 From: Alexander Batalov Date: Thu, 7 Jul 2022 10:52:54 +0300 Subject: [PATCH] Fix some msvc x86 warnings --- src/animation.cc | 6 +++--- src/character_editor.cc | 2 +- src/combat_ai.cc | 6 +++--- src/core.cc | 2 +- src/interface.cc | 4 ++-- src/interpreter.cc | 11 ++++++----- src/movie_lib.cc | 24 +++++++++++++----------- src/sound_effects_cache.cc | 5 +++-- src/tile.cc | 3 --- src/window_manager_private.cc | 2 +- 10 files changed, 33 insertions(+), 32 deletions(-) diff --git a/src/animation.cc b/src/animation.cc index 6461531..80ad0c7 100644 --- a/src/animation.cc +++ b/src/animation.cc @@ -89,8 +89,8 @@ typedef struct STRUCT_530014 { Object* obj; int fid; // fid int field_C; - int field_10; - int field_14; // animation speed? + unsigned int field_10; + unsigned int field_14; // animation speed? int animationSequenceIndex; int field_1C; // length of field_28 int field_20; // current index in field_28 @@ -2404,7 +2404,7 @@ void _object_animate() Object* object = p530014->obj; - int time = _get_time(); + unsigned int time = _get_time(); if (getTicksBetween(time, p530014->field_10) < p530014->field_14) { continue; } diff --git a/src/character_editor.cc b/src/character_editor.cc index 4b2ce2e..5b8a04b 100644 --- a/src/character_editor.cc +++ b/src/character_editor.cc @@ -5060,7 +5060,7 @@ static void characterEditorHandleInfoButtonPressed(int eventCode) offset = 0; } - gCharacterEditorCurrentSkill = offset * 0.092307694; + gCharacterEditorCurrentSkill = (int)(offset * 0.092307694); if (gCharacterEditorCurrentSkill >= 18) { gCharacterEditorCurrentSkill = 17; } diff --git a/src/combat_ai.cc b/src/combat_ai.cc index ac37ab7..ede87ad 100644 --- a/src/combat_ai.cc +++ b/src/combat_ai.cc @@ -3380,13 +3380,13 @@ static int aiMessageListFree() // 0x42BBF0 void aiMessageListReloadIfNeeded() { - bool languageFilter = false; - configGetBool(&gGameConfig, GAME_CONFIG_PREFERENCES_KEY, GAME_CONFIG_LANGUAGE_FILTER_KEY, &languageFilter); + int languageFilter = 0; + configGetInt(&gGameConfig, GAME_CONFIG_PREFERENCES_KEY, GAME_CONFIG_LANGUAGE_FILTER_KEY, &languageFilter); if (languageFilter != gLanguageFilter) { gLanguageFilter = languageFilter; - if (languageFilter) { + if (languageFilter == 1) { messageListFilterBadwords(&gCombatAiMessageList); } else { // NOTE: Uninline. diff --git a/src/core.cc b/src/core.cc index 144427f..d90b12c 100644 --- a/src/core.cc +++ b/src/core.cc @@ -2376,7 +2376,7 @@ void _GNW95_zero_vid_mem() SDL_LockSurface(gSdlSurface); unsigned char* surface = (unsigned char*)gSdlSurface->pixels; - for (unsigned int y = 0; y < gSdlSurface->h; y++) { + for (int y = 0; y < gSdlSurface->h; y++) { memset(surface, 0, gSdlSurface->w); surface += gSdlSurface->pitch; } diff --git a/src/interface.cc b/src/interface.cc index 3845bdc..0e914d4 100644 --- a/src/interface.cc +++ b/src/interface.cc @@ -917,8 +917,8 @@ int interfaceLoad(File* stream) int interfaceCurrentHand; if (fileReadInt32(stream, &interfaceCurrentHand) == -1) return -1; - int interfaceBarEndButtonsIsVisible; - if (fileReadInt32(stream, &interfaceBarEndButtonsIsVisible) == -1) return -1; + bool interfaceBarEndButtonsIsVisible; + if (fileReadBool(stream, &interfaceBarEndButtonsIsVisible) == -1) return -1; if (!gInterfaceBarEnabled) { interfaceBarEnable(); diff --git a/src/interpreter.cc b/src/interpreter.cc index 1619a53..286009b 100644 --- a/src/interpreter.cc +++ b/src/interpreter.cc @@ -607,7 +607,7 @@ int programPushString(Program* program, char* string) } else { program->dynamicStrings = (unsigned char*)internal_malloc_safe(8, __FILE__, __LINE__); // "..\\int\\INTRPRET.C", 631 *(int*)(program->dynamicStrings) = 0; - *(short*)(program->dynamicStrings + 4) = 0x8000; + *(unsigned short*)(program->dynamicStrings + 4) = 0x8000; *(short*)(program->dynamicStrings + 6) = 1; } @@ -627,7 +627,7 @@ int programPushString(Program* program, char* string) v23 = v20 + v27; *(v23 + 3) = '\0'; - *(short*)(v23 + 4) = 0x8000; + *(unsigned short*)(v23 + 4) = 0x8000; *(short*)(v23 + 6) = 1; return v20 + 4 - (program->dynamicStrings + 4); @@ -2857,9 +2857,10 @@ void _updatePrograms() ProgramListNode* next = curr->next; if (curr->program != NULL) { _interpret(curr->program, _cpuBurstSize); - } - if (curr->program->exited) { - programListNodeFree(curr); + + if (curr->program->exited) { + programListNodeFree(curr); + } } curr = next; } diff --git a/src/movie_lib.cc b/src/movie_lib.cc index ccaa6aa..df59d34 100644 --- a/src/movie_lib.cc +++ b/src/movie_lib.cc @@ -12,7 +12,7 @@ typedef struct STRUCT_6B3690 { void* field_0; - int field_4; + unsigned int field_4; int field_8; } STRUCT_6B3690; @@ -375,7 +375,7 @@ static int _io_next_hdr; static int dword_6B36A0; // 0x6B36A4 -static int dword_6B36A4; +static unsigned int dword_6B36A4; // 0x6B36A8 static int _rm_FrameCount; @@ -739,7 +739,11 @@ static void* _ioRead(int size) return NULL; } - return gMovieLibReadProc(_io_handle, buf, size) < 1 ? NULL : buf; + if (!gMovieLibReadProc(_io_handle, buf, size)) { + return NULL; + } + + return buf; } // 0x4F4D40 @@ -851,7 +855,6 @@ int _MVE_rmStepMovie() int v13; unsigned short* v3; unsigned short* v21; - unsigned short v22; int v18; int v19; int v20; @@ -1228,16 +1231,16 @@ static void _MVE_sndSync() DWORD dwCurrentWriteCursor; bool v10; DWORD dwStatus; - int v1; + unsigned int v1; bool v2; int v3; - int v4; + unsigned int v4; bool v5; bool v0; - int v6; + unsigned int v6; int v7; int v8; - int v9; + unsigned int v9; v0 = false; @@ -1323,7 +1326,8 @@ static void _MVE_sndSync() } v8 = stru_6B3668.dwBufferBytes - v7 - 1; - if (stru_6B3668.dwBufferBytes / 2 < v8) { + // NOTE: Original code uses signed comparison. + if ((int)stru_6B3668.dwBufferBytes / 2 < v8) { v8 = stru_6B3668.dwBufferBytes >> 1; } @@ -1458,8 +1462,6 @@ static void _CallsSndBuff_Loc(unsigned char* a1, int a2) // 0x4F5B70 static int _MVE_sndAdd(unsigned char* dest, unsigned char** src_ptr, int a3, int a4, int a5) { - int v5; - int v7; unsigned char* src; int v9; unsigned short* v10; diff --git a/src/sound_effects_cache.cc b/src/sound_effects_cache.cc index eaae80c..80d8f25 100644 --- a/src/sound_effects_cache.cc +++ b/src/sound_effects_cache.cc @@ -230,7 +230,8 @@ int soundEffectsCacheFileRead(int handle, void* buf, unsigned int size) } size_t bytesToRead; - if (size < (soundEffect->dataSize - soundEffect->position)) { + // NOTE: Original code uses signed comparison. + if ((int)size < (soundEffect->dataSize - soundEffect->position)) { bytesToRead = size; } else { bytesToRead = soundEffect->dataSize - soundEffect->position; @@ -512,7 +513,7 @@ static int _sfxc_ad_reader(int handle, void* buf, unsigned int size) SoundEffect* soundEffect = &(gSoundEffects[handle]); - int bytesToRead = soundEffect->fileSize - soundEffect->dataPosition; + unsigned int bytesToRead = soundEffect->fileSize - soundEffect->dataPosition; if (size <= bytesToRead) { bytesToRead = size; } diff --git a/src/tile.cc b/src/tile.cc index e7f49d2..e07bca7 100644 --- a/src/tile.cc +++ b/src/tile.cc @@ -16,9 +16,6 @@ #include #include -#define _USE_MATH_DEFINES -#include - typedef struct STRUCT_51D99C { int field_0; int field_4; diff --git a/src/window_manager_private.cc b/src/window_manager_private.cc index 4907264..7e5d937 100644 --- a/src/window_manager_private.cc +++ b/src/window_manager_private.cc @@ -55,7 +55,7 @@ static int _tm_h; static STRUCT_6B2370 _tm_queue[5]; // 0x6B23AC -static int _tm_persistence; +static unsigned int _tm_persistence; // 0x6B23B0 static int _scr_center_x;