From 535fc79c0f3611a6dd2884880ffa832ee74a31ca Mon Sep 17 00:00:00 2001 From: Sven Eberhardt Date: Sat, 29 Aug 2015 08:33:00 -0400 Subject: [PATCH] Silence a few compiler warnings. --- cmake/FindAudio.cmake | 2 +- src/gui/C4Gui.cpp | 2 +- src/gui/C4GuiDialogs.cpp | 2 -- src/gui/C4MessageInput.cpp | 2 +- src/gui/C4PlayerInfoListBox.cpp | 4 +--- src/gui/C4StartupNetDlg.cpp | 6 ++++-- src/gui/C4StartupOptionsDlg.cpp | 1 - src/gui/C4StartupScenSelDlg.cpp | 3 +-- src/landscape/fow/C4FoWLightSection.cpp | 8 ++++---- src/lib/StdMeshLoaderXml.cpp | 2 +- src/platform/C4CrashHandlerWin32.cpp | 9 +++++++-- src/platform/PlatformAbstraction.h | 2 ++ 12 files changed, 23 insertions(+), 20 deletions(-) diff --git a/cmake/FindAudio.cmake b/cmake/FindAudio.cmake index 140a509bd..b63dfb5d0 100644 --- a/cmake/FindAudio.cmake +++ b/cmake/FindAudio.cmake @@ -40,7 +40,7 @@ macro(__FINDAUDIO_FINDOPENAL) pkg_check_modules(OggVorbis "vorbisfile>=1.3.2" "vorbis>=1.3.2" "ogg>=1.2.2") else() if(MSVC OR APPLE) - # We need OpenAL preferrably with alext.h. + # We need OpenAL preferably with alext.h. find_path(OpenALExt_INCLUDE_DIRS alext.h PATH_SUFFIXES include/AL include/OpenAL include OpenAL) if(OpenALExt_INCLUDE_DIRS) set(HAVE_ALEXT TRUE) diff --git a/src/gui/C4Gui.cpp b/src/gui/C4Gui.cpp index e43240415..a2572deda 100644 --- a/src/gui/C4Gui.cpp +++ b/src/gui/C4Gui.cpp @@ -702,7 +702,7 @@ namespace C4GUI // get dialog with matching handle Dialog *pDlg; for (Element *pEl = pLast; pEl; pEl = pEl->GetPrev()) - if (pDlg = pEl->GetDlg()) + if ((pDlg = pEl->GetDlg())) if (pDlg->pWindow && pDlg->pWindow->hWindow == hWindow) return pDlg; return NULL; diff --git a/src/gui/C4GuiDialogs.cpp b/src/gui/C4GuiDialogs.cpp index 33e42b555..675f1d70d 100644 --- a/src/gui/C4GuiDialogs.cpp +++ b/src/gui/C4GuiDialogs.cpp @@ -814,8 +814,6 @@ namespace C4GUI void FullscreenDialog::DrawBackground(C4TargetFacet &cgo, C4Facet &rFromFct) { // draw across fullscreen bounds - zoom 1px border to prevent flashing borders by blit offsets - Screen *pScr = GetScreen(); - C4Rect &rcScreenBounds = pScr ? pScr->GetBounds() : GetBounds(); rFromFct.DrawFullScreen(cgo); } diff --git a/src/gui/C4MessageInput.cpp b/src/gui/C4MessageInput.cpp index f10b1ca52..5df95fbdb 100644 --- a/src/gui/C4MessageInput.cpp +++ b/src/gui/C4MessageInput.cpp @@ -779,7 +779,7 @@ bool C4MessageInput::ProcessCommand(const char *szCommand) // try writing main file (usually {SCENARIO}/TODO.txt); if access is not possible, e.g. because scenario is packed, write to alternate file const char *todo_filenames[] = { ::Config.Developer.TodoFilename, ::Config.Developer.AltTodoFilename }; bool success = false; - for (int i = 0; i < std::extent::value; ++i) + for (int i = 0; i < static_cast(std::extent::value); ++i) { StdCopyStrBuf todo_filename(todo_filenames[i]); int replacements = todo_filename.Replace("{SCENARIO}", Game.ScenarioFile.GetFullName().getData()); diff --git a/src/gui/C4PlayerInfoListBox.cpp b/src/gui/C4PlayerInfoListBox.cpp index f1e543721..4cca990ec 100644 --- a/src/gui/C4PlayerInfoListBox.cpp +++ b/src/gui/C4PlayerInfoListBox.cpp @@ -1365,6 +1365,7 @@ void C4PlayerInfoListBox::UpdateSavegamePlayers(ListItem **ppCurrInList) new PlayerListItem(this, -1, iInfoID, true, *ppCurrInList); } // 2do: none-label + (void) fAnyPlayers; } } @@ -1375,14 +1376,11 @@ void C4PlayerInfoListBox::UpdateReplayPlayers(ListItem **ppCurrInList) if (!PlrListItemUpdate(ListItem::ID::PLI_REPLAY, 0, ppCurrInList)) new ReplayPlayersListItem(this, *ppCurrInList); // players - bool fAnyPlayers = false; C4PlayerInfo *pInfo; int32_t iInfoID=0; while ((pInfo = Game.PlayerInfos.GetNextPlayerInfoByID(iInfoID))) { if (pInfo->IsInvisible()) continue; iInfoID = pInfo->GetID(); - // players are in the list - fAnyPlayers = true; // show them if (!PlrListItemUpdate(ListItem::ID::PLI_PLAYER, iInfoID, ppCurrInList)) new PlayerListItem(this, -1, iInfoID, false, *ppCurrInList); diff --git a/src/gui/C4StartupNetDlg.cpp b/src/gui/C4StartupNetDlg.cpp index a869a7df1..3064aa615 100644 --- a/src/gui/C4StartupNetDlg.cpp +++ b/src/gui/C4StartupNetDlg.cpp @@ -184,7 +184,7 @@ bool C4StartupNetListEntry::Execute() { fError = false; sError.Clear(); - ((C4Facet &) pIcon->GetFacet()) = (const C4Facet &) C4Startup::Get()->Graphics.fctNetGetRef; + pIcon->SetFacet(C4Startup::Get()->Graphics.fctNetGetRef); pIcon->SetAnimated(true, 1); pIcon->SetBounds(rctIconLarge); sInfoText[1].Copy(LoadResStr("IDS_NET_INFOQUERY")); @@ -820,7 +820,9 @@ void C4StartupNetDlg::OnBtnInternet(C4GUI::Control *btn) void C4StartupNetDlg::OnBtnRecord(C4GUI::Control *btn) { // toggle league signup flag - bool fCheck = Config.General.DefRec = Game.Record = !Game.Record; + bool fCheck = !Game.Record; + Game.Record = fCheck; + Config.General.DefRec = fCheck; btnRecord->SetIcon(fCheck ? C4GUI::Ico_Ex_RecordOn : C4GUI::Ico_Ex_RecordOff); } diff --git a/src/gui/C4StartupOptionsDlg.cpp b/src/gui/C4StartupOptionsDlg.cpp index 6b1040d8d..460d2cb63 100644 --- a/src/gui/C4StartupOptionsDlg.cpp +++ b/src/gui/C4StartupOptionsDlg.cpp @@ -375,7 +375,6 @@ void C4StartupOptionsDlg::ControlConfigListBox::SetUserKey(class C4PlayerControl C4StartupOptionsDlg::ControlConfigArea::ControlConfigArea(const C4Rect &rcArea, int32_t iHMargin, int32_t iVMargin, bool fGamepad, C4StartupOptionsDlg *pOptionsDlg) : C4GUI::Window(), fGamepad(fGamepad), pGamepadOpener(NULL), pOptionsDlg(pOptionsDlg), pGUICtrl(NULL) { - CStdFont *pUseFont = &(C4Startup::Get()->Graphics.BookFont); CStdFont *pUseFontSmall = &(C4Startup::Get()->Graphics.BookSmallFont); SetBounds(rcArea); C4GUI::ComponentAligner caArea(rcArea, iHMargin, iVMargin, true); diff --git a/src/gui/C4StartupScenSelDlg.cpp b/src/gui/C4StartupScenSelDlg.cpp index 7c2fd4fd8..121a4f2ff 100644 --- a/src/gui/C4StartupScenSelDlg.cpp +++ b/src/gui/C4StartupScenSelDlg.cpp @@ -682,7 +682,7 @@ bool C4ScenarioListLoader::Scenario::LoadCustomPre(C4Group &rGrp) const C4ScenarioParameterDefs *deflist = deflists[def_list_idx]; if (!deflist) continue; const C4ScenarioParameterDef *def; size_t idx=0; - while (def = deflist->GetParameterDefByIndex(idx++)) + while ((def = deflist->GetParameterDefByIndex(idx++))) { if (def->IsAchievement()) { @@ -1402,7 +1402,6 @@ C4StartupScenSelDlg::C4StartupScenSelDlg(bool fNetwork) : C4StartupDlg(LoadResSt int iButtonHeight = C4GUI_ButtonHgt; int iBookPageWidth; int iExtraHPadding = rcBounds.Wdt >= 700 ? rcBounds.Wdt/50 : 0; - int iExtraVPadding = rcBounds.Hgt >= 540 ? rcBounds.Hgt/20 : 0; ::GraphicsResource.CaptionFont.GetTextExtent("<< BACK", iButtonWidth, iCaptionFontHgt, true); iButtonWidth *= 3; C4GUI::ComponentAligner caMain(GetClientRect(), 0,0, true); diff --git a/src/landscape/fow/C4FoWLightSection.cpp b/src/landscape/fow/C4FoWLightSection.cpp index b50777e1b..853626779 100644 --- a/src/landscape/fow/C4FoWLightSection.cpp +++ b/src/landscape/fow/C4FoWLightSection.cpp @@ -661,7 +661,7 @@ std::list C4FoWLightSection::CalculateTriangles(C4FoWRegion * #ifdef FAN_STEP_DEBUG LogSilentF("Descend, b=%.010f, cross=%.010f/%.010f", b, crossX, crossY); #endif - assert(f); + assert(f); (void) f; if (b <= threshold) { if (nextIt == --result.end()) @@ -702,14 +702,14 @@ std::list C4FoWLightSection::CalculateTriangles(C4FoWRegion * } // We should only reach this place with a descend collision - assert(descendCollision); + assert(descendCollision); (void) descendCollision; // Should never be parallel -- otherwise we wouldn't be here // in the first place. bool f = find_cross(lightLX, lightLY, tri.fanRX, tri.fanRY, lightRX, lightRY, nextTri.fanLX, nextTri.fanLY, &crossX, &crossY); - assert(f); + assert(f); (void) f; #ifdef FAN_STEP_DEBUG LogSilentF("Collision, cross=%.02f/%.02f", crossX, crossY); #endif @@ -722,7 +722,7 @@ std::list C4FoWLightSection::CalculateTriangles(C4FoWRegion * continue; // This should always follow an elimination, but better check - assert(beamCount > result.size()); + assert(beamCount > static_cast(result.size())); C4FoWBeamTriangle newTriangle; newTriangle.fanLX = crossX; diff --git a/src/lib/StdMeshLoaderXml.cpp b/src/lib/StdMeshLoaderXml.cpp index 9a3565281..2b00c6753 100644 --- a/src/lib/StdMeshLoaderXml.cpp +++ b/src/lib/StdMeshLoaderXml.cpp @@ -230,7 +230,7 @@ void StdMeshLoader::StdMeshXML::LoadBoneAssignments(StdMesh& mesh, std::vector(StdMeshVertex::MaxBoneWeightCount)), vertexboneassignment_elem); } for (size_t weight_index = 0; weight_index < StdMeshVertex::MaxBoneWeightCount; ++weight_index) { diff --git a/src/platform/C4CrashHandlerWin32.cpp b/src/platform/C4CrashHandlerWin32.cpp index b6e5fd8ab..3a68b74af 100644 --- a/src/platform/C4CrashHandlerWin32.cpp +++ b/src/platform/C4CrashHandlerWin32.cpp @@ -164,11 +164,15 @@ namespace { } #ifdef __CRT_WIDE # define ASSERTION_INFO_FORMAT "%ls" +# define ASSERTION_INFO_TYPE wchar_t * #else # define ASSERTION_INFO_FORMAT "%s" +# define ASSERTION_INFO_TYPE char * #endif LOG_DYNAMIC_TEXT("Additional information for the exception:\n Assertion that failed: " ASSERTION_INFO_FORMAT "\n File: " ASSERTION_INFO_FORMAT "\n Line: %d\n", - exc->ExceptionRecord->ExceptionInformation[0], exc->ExceptionRecord->ExceptionInformation[1], exc->ExceptionRecord->ExceptionInformation[2]); + reinterpret_cast(exc->ExceptionRecord->ExceptionInformation[0]), + reinterpret_cast(exc->ExceptionRecord->ExceptionInformation[1]), + exc->ExceptionRecord->ExceptionInformation[2]); break; } @@ -267,7 +271,8 @@ namespace { if (SymInitialize(process, 0, true)) { LOG_STATIC_TEXT("\nStack trace:\n"); - STACKFRAME64 frame = {0}; + STACKFRAME64 frame; + memset(&frame, 0, sizeof(STACKFRAME64)); DWORD image_type; CONTEXT context = *exc->ContextRecord; // Setup frame info diff --git a/src/platform/PlatformAbstraction.h b/src/platform/PlatformAbstraction.h index e0eb5db6f..fc9f48b3e 100644 --- a/src/platform/PlatformAbstraction.h +++ b/src/platform/PlatformAbstraction.h @@ -67,6 +67,8 @@ #pragma warning(disable: 4521) // multiple copy constructors specified // Get non-standard constants (M_PI etc.) # define _USE_MATH_DEFINES +// Use IPv4 functions (inet_ntoa) since we don't support IPv6 yet. +#define _WINSOCK_DEPRECATED_NO_WARNINGS #endif