From 783b94f9220a8e4d655663ead66113f2da9e98e8 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 12 May 2021 01:55:06 +0200 Subject: [PATCH] - more warning fixes in 'core'. --- source/common/engine/sc_man.h | 6 ++++++ source/core/console/c_notifybuffer.cpp | 4 ++-- source/core/defparser.cpp | 12 ++++++------ source/core/gamefuncs.h | 4 ++++ source/core/menu/razemenu.cpp | 4 ++-- source/core/movie/movieplayer.cpp | 11 +++++------ source/core/movie/playmve.cpp | 12 ++++++------ source/core/rendering/scene/hw_drawstructs.h | 2 ++ source/libsmackerdec/src/HuffmanVLC.cpp | 2 +- 9 files changed, 34 insertions(+), 23 deletions(-) diff --git a/source/common/engine/sc_man.h b/source/common/engine/sc_man.h index 56a4a8d82..1caa177a2 100644 --- a/source/common/engine/sc_man.h +++ b/source/common/engine/sc_man.h @@ -145,6 +145,12 @@ public: return true; } + bool GetFloat(float& var, bool evaluate = false) + { + if (!GetFloat(evaluate)) return false; + var = float(Float); + return true; + } void MustGetFloat(bool evaluate = false); bool CheckFloat(bool evaluate = false); diff --git a/source/core/console/c_notifybuffer.cpp b/source/core/console/c_notifybuffer.cpp index 9eacdfdb7..ffbd945c0 100644 --- a/source/core/console/c_notifybuffer.cpp +++ b/source/core/console/c_notifybuffer.cpp @@ -116,10 +116,10 @@ void FNotifyBuffer::DrawNative() FFont* font = isBlood() ? SmallFont2 : SmallFont; - int line = isBlood() ? Top : (g_gameType & GAMEFLAG_SW) ? 40 : font->GetDisplacement(); + double line = isBlood() ? Top : (g_gameType & GAMEFLAG_SW) ? 40 : font->GetDisplacement(); bool canskip = isBlood(); double scale = 1 / (NotifyFontScale * con_notifyscale); - int lineadv = font->GetHeight() / NotifyFontScale; + double lineadv = font->GetHeight() / NotifyFontScale; for (unsigned i = topline; i < Text.Size(); ++i) { diff --git a/source/core/defparser.cpp b/source/core/defparser.cpp index 3ef142a4d..baa8480ab 100644 --- a/source/core/defparser.cpp +++ b/source/core/defparser.cpp @@ -135,7 +135,7 @@ static void parseTexturePaletteBlock(FScanner& sc, int tile) int pal = -1, xsiz = 0, ysiz = 0; FString fn; - double alphacut = -1.0, xscale = 1.0, yscale = 1.0, specpower = 1.0, specfactor = 1.0; + float alphacut = -1.0, xscale = 1.0, yscale = 1.0, specpower = 1.0, specfactor = 1.0; if (!sc.GetNumber(pal, true)) return; @@ -178,7 +178,7 @@ static void parseTextureSpecialBlock(FScanner& sc, int tile, int pal) FScriptPosition pos = sc; FString fn; - double xscale = 1.0, yscale = 1.0, specpower = 1.0, specfactor = 1.0; + float xscale = 1.0, yscale = 1.0, specpower = 1.0, specfactor = 1.0; if (sc.StartBraces(&blockend)) return; while (!sc.FoundEndBrace(blockend)) @@ -837,7 +837,7 @@ void parseMapinfo(FScanner& sc, FScriptPosition& pos) for (int i = 0; i < 16; i++) { char smallbuf[3] = { sc.String[2 * i], sc.String[2 * i + 1], 0 }; - mhk.md4[i] = strtol(smallbuf, nullptr, 16); + mhk.md4[i] = (uint8_t)strtol(smallbuf, nullptr, 16); } } } @@ -1775,7 +1775,7 @@ static bool parseModelFrameBlock(FScanner& sc, FixedBitArray<1024>& usedframes) bool ok = true; int pal = -1; int starttile = -1, endtile = -1; - double smoothduration = 0.1f; + float smoothduration = 0.1f; if (sc.StartBraces(&blockend)) return false; while (!sc.FoundEndBrace(blockend)) @@ -1858,7 +1858,7 @@ static bool parseModelSkinBlock(FScanner& sc, int pal) FString filename; int surface = 0; - double param = 1.0, specpower = 1.0, specfactor = 1.0; + float param = 1.0, specpower = 1.0, specfactor = 1.0; int flags = 0; if (sc.StartBraces(&blockend)) return false; @@ -1890,7 +1890,7 @@ static bool parseModelSkinBlock(FScanner& sc, int pal) return false; } - if (pal == DETAILPAL) param = 1. / param; + if (pal == DETAILPAL) param = 1.f / param; int res = md_defineskin(mdglobal.lastmodelid, filename, pal, max(0, mdglobal.modelskin), surface, param, specpower, specfactor, flags); if (res < 0) { diff --git a/source/core/gamefuncs.h b/source/core/gamefuncs.h index 26265ae26..0f5d0a8a8 100644 --- a/source/core/gamefuncs.h +++ b/source/core/gamefuncs.h @@ -10,6 +10,10 @@ void loaddefinitionsfile(const char* fn, bool cumulative = false); bool calcChaseCamPos(int* px, int* py, int* pz, spritetype* pspr, short *psectnum, binangle ang, fixedhoriz horiz, double const smoothratio); void PlanesAtPoint(const sectortype* sec, int dax, int day, float* ceilz, float* florz); +inline void PlanesAtPoint(const sectortype* sec, float dax, float day, float* ceilz, float* florz) // this is just for warning evasion. +{ + PlanesAtPoint(sec, int(dax), int(day), ceilz, florz); +} void setWallSectors(); void GetWallSpritePosition(const spritetype* spr, vec2_t pos, vec2_t* out, bool render = false); void GetFlatSpritePosition(const spritetype* spr, vec2_t pos, vec2_t* out, bool render = false); diff --git a/source/core/menu/razemenu.cpp b/source/core/menu/razemenu.cpp index cc2f4f156..2c03da68f 100644 --- a/source/core/menu/razemenu.cpp +++ b/source/core/menu/razemenu.cpp @@ -415,7 +415,7 @@ static void BuildEpisodeMenu() } ld->mSelectedItem = gDefaultVolume + ld->mItems.Size(); // account for pre-added items - int y = ld->mYpos; + double y = ld->mYpos; // Volume definitions should be sorted by intended menu order. for (auto &vol : volumes) @@ -471,7 +471,7 @@ static void BuildEpisodeMenu() } if (isBlood()) gDefaultSkill = 2; ld->mSelectedItem = gDefaultSkill + ld->mItems.Size(); // account for pre-added items - int y = ld->mYpos; + double y = ld->mYpos; for (int i = 0; i < MAXSKILLS; i++) { diff --git a/source/core/movie/movieplayer.cpp b/source/core/movie/movieplayer.cpp index f5dfbe0b0..579c2d84c 100644 --- a/source/core/movie/movieplayer.cpp +++ b/source/core/movie/movieplayer.cpp @@ -419,7 +419,7 @@ public: { if (soundtrack > 0) { - Mus_Play(nullptr, fileSystem.GetFileFullName(soundtrack, false), false); + Mus_Play(fileSystem.GetFileFullName(soundtrack, false), false); } animtex.SetSize(AnimTexture::YUV, width, height); } @@ -519,7 +519,6 @@ class SmkPlayer : public MoviePlayer AnimTextures animtex; TArray pFrame; TArray audioBuffer; - int nFrameRate; int nFrames; bool fullscreenScale; uint64_t nFrameNs; @@ -571,8 +570,8 @@ public: flags = flags_; Smacker_GetFrameSize(hSMK, nWidth, nHeight); pFrame.Resize(nWidth * nHeight + std::max(nWidth, nHeight)); - nFrameRate = Smacker_GetFrameRate(hSMK); - nFrameNs = 1'000'000'000 / nFrameRate; + float frameRate = Smacker_GetFrameRate(hSMK); + nFrameNs = uint64_t(1'000'000'000 / frameRate); nFrames = Smacker_GetNumFrames(hSMK); Smacker_GetPalette(hSMK, palette); @@ -617,7 +616,7 @@ public: bool Frame(uint64_t clock) override { - int frame = clock / nFrameNs; + int frame = int(clock / nFrameNs); twod->ClearScreen(); if (frame > nFrame) @@ -698,7 +697,7 @@ MoviePlayer* OpenMovie(const char* filename, TArray& ans, const int* framet if (!fr.isOpen()) fr = fileSystem.OpenFileReader(filename); if (!fr.isOpen()) { - int nLen = strlen(filename); + size_t nLen = strlen(filename); // Strip the drive letter and retry. if (nLen >= 3 && isalpha(filename[0]) && filename[1] == ':' && filename[2] == '/') { diff --git a/source/core/movie/playmve.cpp b/source/core/movie/playmve.cpp index 03f77f378..4967d2ccc 100644 --- a/source/core/movie/playmve.cpp +++ b/source/core/movie/playmve.cpp @@ -252,7 +252,7 @@ bool InterplayDecoder::RunFrame(uint64_t clock) { nTimerRate = fr.ReadUInt32(); nTimerDiv = fr.ReadUInt16(); - nFrameDuration = ((double)nTimerRate * nTimerDiv) * 1000; + nFrameDuration = ((uint64_t)nTimerRate * nTimerDiv) * 1000; break; } @@ -346,7 +346,7 @@ bool InterplayDecoder::RunFrame(uint64_t clock) case OPCODE_AUDIO_FRAME: { - int nStart = fr.Tell(); + int nStart = (int)fr.Tell(); uint16_t seqIndex = fr.ReadUInt16(); uint16_t streamMask = fr.ReadUInt16(); uint16_t nSamples = fr.ReadUInt16(); // number of samples this chunk @@ -380,7 +380,7 @@ bool InterplayDecoder::RunFrame(uint64_t clock) ch ^= audio.nChannels - 1; } - int nEnd = fr.Tell(); + int nEnd = (int)fr.Tell(); int nRead = nEnd - nStart; assert(opcodeSize == nRead); break; @@ -449,14 +449,14 @@ bool InterplayDecoder::RunFrame(uint64_t clock) } } - int nRead = fr.Read(decodeMap.pData, opcodeSize); + int nRead = (int)fr.Read(decodeMap.pData, opcodeSize); assert(nRead == opcodeSize); break; } case OPCODE_VIDEO_DATA: { - int nStart = fr.Tell(); + int nStart = (int)fr.Tell(); // need to skip 14 bytes fr.Seek(14, FileReader::SeekCur); @@ -536,7 +536,7 @@ bool InterplayDecoder::RunFrame(uint64_t clock) } } - int nEnd = fr.Tell(); + int nEnd = (int)fr.Tell(); int nSkipBytes = opcodeSize - (nEnd - nStart); // we can end up with 1 byte left we need to skip assert(nSkipBytes <= 1); diff --git a/source/core/rendering/scene/hw_drawstructs.h b/source/core/rendering/scene/hw_drawstructs.h index e888a8794..762a2d4cc 100644 --- a/source/core/rendering/scene/hw_drawstructs.h +++ b/source/core/rendering/scene/hw_drawstructs.h @@ -15,6 +15,8 @@ #include "hw_renderstate.h" #include "hw_cvars.h" +#pragma warning(disable:4244) // this gets a bit annoying in the renderer... + struct HWHorizonInfo; struct HWSkyInfo; class FMaterial; diff --git a/source/libsmackerdec/src/HuffmanVLC.cpp b/source/libsmackerdec/src/HuffmanVLC.cpp index 3f7fd45f8..400e622f8 100644 --- a/source/libsmackerdec/src/HuffmanVLC.cpp +++ b/source/libsmackerdec/src/HuffmanVLC.cpp @@ -65,7 +65,7 @@ void VLC_InitTable(VLCtable &table, uint32_t maxLength, uint32_t size, int *leng uint32_t VLC_GetSize(VLCtable &table) { - return table.size(); + return uint32_t(table.size()); } } // close namespace SmackerCommon