From 350651dae6987a924178804795e50cb394cb488d Mon Sep 17 00:00:00 2001 From: Muzychenko Andrey <33288308+k4zmu2a@users.noreply.github.com> Date: Tue, 5 Sep 2023 10:51:19 +0300 Subject: [PATCH] Fixed MSVC warnings, added Windows build script. --- .gitignore | 2 ++ BuildForWindows.ps1 | 20 ++++++++++++++++++++ SpaceCadetPinball/GroupData.cpp | 2 +- SpaceCadetPinball/Sound.cpp | 2 +- SpaceCadetPinball/TFlagSpinner.cpp | 2 +- SpaceCadetPinball/TFlipper.cpp | 3 +-- SpaceCadetPinball/winmain.cpp | 2 +- 7 files changed, 27 insertions(+), 6 deletions(-) create mode 100644 BuildForWindows.ps1 diff --git a/.gitignore b/.gitignore index f83ee98..6239eab 100644 --- a/.gitignore +++ b/.gitignore @@ -298,3 +298,5 @@ _deps .ninja_deps .ninja_log build.ninja +# Build directory +/build diff --git a/BuildForWindows.ps1 b/BuildForWindows.ps1 new file mode 100644 index 0000000..bd7a402 --- /dev/null +++ b/BuildForWindows.ps1 @@ -0,0 +1,20 @@ +#Run this script from Developer Command Prompt for VS * +$artefacts = ".\bin\Release\SpaceCadetPinball.exe", ".\bin\Release\SDL2.dll", ".\bin\Release\SDL2_mixer.dll" + +#X86 build +Remove-Item -Path .\build\CMakeCache.txt -ErrorAction SilentlyContinue +cmake -S . -B build -A Win32 -DCMAKE_WIN32_EXECUTABLE:BOOL=1 +cmake --build build --config Release +Compress-Archive -Path $artefacts -DestinationPath ".\bin\SpaceCadetPinballx86Win.zip" -Force + +#X64 build +Remove-Item -Path .\build\CMakeCache.txt +cmake -S . -B build -A x64 -DCMAKE_WIN32_EXECUTABLE:BOOL=1 +cmake --build build --config Release +Compress-Archive -Path $artefacts -DestinationPath ".\bin\SpaceCadetPinballx64Win.zip" -Force + +#86 XP build, requires special XP MSVC toolset +Remove-Item -Path .\build\CMakeCache.txt +cmake -S . -B build -A Win32 -DCMAKE_WIN32_EXECUTABLE:BOOL=1 -T v141_xp +cmake --build build --config Release +Compress-Archive -Path $artefacts -DestinationPath ".\bin\SpaceCadetPinballx86WinXP.zip" -Force \ No newline at end of file diff --git a/SpaceCadetPinball/GroupData.cpp b/SpaceCadetPinball/GroupData.cpp index ef96427..7e22d08 100644 --- a/SpaceCadetPinball/GroupData.cpp +++ b/SpaceCadetPinball/GroupData.cpp @@ -245,7 +245,7 @@ int DatFile::field_size(int groupIndex, FieldTypes targetEntryType) int DatFile::record_labeled(LPCSTR targetGroupName) { auto targetLength = strlen(targetGroupName); - for (int groupIndex = Groups.size() - 1; groupIndex >= 0; --groupIndex) + for (int groupIndex = static_cast(Groups.size()) - 1; groupIndex >= 0; --groupIndex) { auto groupName = field(groupIndex, FieldTypes::GroupName); if (!groupName) diff --git a/SpaceCadetPinball/Sound.cpp b/SpaceCadetPinball/Sound.cpp index 3673e0a..2cd6983 100644 --- a/SpaceCadetPinball/Sound.cpp +++ b/SpaceCadetPinball/Sound.cpp @@ -53,7 +53,7 @@ void Sound::PlaySound(Mix_Chunk* wavePtr, int time, TPinballComponent* soundSour return a.TimeStamp < b.TimeStamp; }; auto min = std::min_element(Channels.begin(), Channels.end(), cmp); - auto oldestChannel = std::distance(Channels.begin(), min); + auto oldestChannel = static_cast(std::distance(Channels.begin(), min)); Mix_HaltChannel(oldestChannel); } diff --git a/SpaceCadetPinball/TFlagSpinner.cpp b/SpaceCadetPinball/TFlagSpinner.cpp index 751d6a1..2e9994c 100644 --- a/SpaceCadetPinball/TFlagSpinner.cpp +++ b/SpaceCadetPinball/TFlagSpinner.cpp @@ -89,7 +89,7 @@ void TFlagSpinner::NextFrame() { BmpIndex += SpinDirection; int bmpIndex = BmpIndex; - int bmpCount = ListBitmap->size(); + int bmpCount = static_cast(ListBitmap->size()); if (bmpIndex >= bmpCount) BmpIndex = 0; else if (bmpIndex < 0) diff --git a/SpaceCadetPinball/TFlipper.cpp b/SpaceCadetPinball/TFlipper.cpp index 063dc05..2f07d83 100644 --- a/SpaceCadetPinball/TFlipper.cpp +++ b/SpaceCadetPinball/TFlipper.cpp @@ -115,8 +115,7 @@ void TFlipper::Collision(TBall* ball, vector2* nextPosition, vector2* direction, void TFlipper::UpdateSprite() { - int bmpCountSub1 = ListBitmap->size() - 1; - + auto bmpCountSub1 = static_cast(ListBitmap->size()) - 1; auto newBmpIndex = static_cast(floor(FlipperEdge->CurrentAngle / FlipperEdge->AngleMax * bmpCountSub1 + 0.5f)); newBmpIndex = Clamp(newBmpIndex, 0, bmpCountSub1); if (BmpIndex == newBmpIndex) diff --git a/SpaceCadetPinball/winmain.cpp b/SpaceCadetPinball/winmain.cpp index 7791ad5..28bdba6 100644 --- a/SpaceCadetPinball/winmain.cpp +++ b/SpaceCadetPinball/winmain.cpp @@ -1366,7 +1366,7 @@ void winmain::RenderFrameTimeDialog() sprintf(overlay, "avg %.3fms, dev %.3fms", average, dev); auto region = ImGui::GetContentRegionAvail(); - ImGui::PlotLines("Lines", gfrDisplay.data(), gfrDisplay.size(), + ImGui::PlotLines("Lines", gfrDisplay.data(), static_cast(gfrDisplay.size()), scrollPlot ? gfrOffset : 0, overlay, 0, yMax, region); } }