Skip to content

Commit

Permalink
Fixed MSVC warnings, added Windows build script.
Browse files Browse the repository at this point in the history
  • Loading branch information
k4zmu2a committed Sep 5, 2023
1 parent 6ab7b3e commit 350651d
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 6 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -298,3 +298,5 @@ _deps
.ninja_deps
.ninja_log
build.ninja
# Build directory
/build
20 changes: 20 additions & 0 deletions BuildForWindows.ps1
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion SpaceCadetPinball/GroupData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<int>(Groups.size()) - 1; groupIndex >= 0; --groupIndex)
{
auto groupName = field(groupIndex, FieldTypes::GroupName);
if (!groupName)
Expand Down
2 changes: 1 addition & 1 deletion SpaceCadetPinball/Sound.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<int>(std::distance(Channels.begin(), min));
Mix_HaltChannel(oldestChannel);
}

Expand Down
2 changes: 1 addition & 1 deletion SpaceCadetPinball/TFlagSpinner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ void TFlagSpinner::NextFrame()
{
BmpIndex += SpinDirection;
int bmpIndex = BmpIndex;
int bmpCount = ListBitmap->size();
int bmpCount = static_cast<int>(ListBitmap->size());
if (bmpIndex >= bmpCount)
BmpIndex = 0;
else if (bmpIndex < 0)
Expand Down
3 changes: 1 addition & 2 deletions SpaceCadetPinball/TFlipper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<int>(ListBitmap->size()) - 1;
auto newBmpIndex = static_cast<int>(floor(FlipperEdge->CurrentAngle / FlipperEdge->AngleMax * bmpCountSub1 + 0.5f));
newBmpIndex = Clamp(newBmpIndex, 0, bmpCountSub1);
if (BmpIndex == newBmpIndex)
Expand Down
2 changes: 1 addition & 1 deletion SpaceCadetPinball/winmain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<int>(gfrDisplay.size()),
scrollPlot ? gfrOffset : 0, overlay, 0, yMax, region);
}
}
Expand Down

0 comments on commit 350651d

Please sign in to comment.