Skip to content

Commit e09fa72

Browse files
authored
Merge pull request #83 from neogeek/hotfix/switched-to-static-cast
[hotfix] Switched to static cast for int and float values.
2 parents e40dd00 + 5a3ef85 commit e09fa72

File tree

2 files changed

+11
-10
lines changed

2 files changed

+11
-10
lines changed

include/RhythmGameUtilities/Audio.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ extern "C"
4040

4141
for (auto j = 0; j < step; j += 1)
4242
{
43-
auto index = (int)(x * step + j);
43+
auto index = static_cast<int>(x * step + j);
4444

4545
auto datum = samples[index];
4646

@@ -55,8 +55,8 @@ extern "C"
5555
}
5656
}
5757

58-
auto minY = (int)((1 + min) * amp);
59-
auto maxY = (int)((1 + max) * amp);
58+
auto minY = static_cast<int>((1 + min) * amp);
59+
auto maxY = static_cast<int>((1 + max) * amp);
6060

6161
for (auto y = 0; y < height; y += 1)
6262
{

include/RhythmGameUtilities/Utilities.hpp

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ int ConvertSecondsToTicks(float seconds, int resolution,
4444

4545
if (remainingSeconds <= timeForSegment)
4646
{
47-
totalTicks += (int)(remainingSeconds * previousBPM /
48-
SECONDS_PER_MINUTE * resolution);
47+
totalTicks += static_cast<int>(remainingSeconds * previousBPM /
48+
SECONDS_PER_MINUTE * resolution);
4949

5050
return totalTicks;
5151
}
@@ -56,8 +56,8 @@ int ConvertSecondsToTicks(float seconds, int resolution,
5656
previousBPM = value / 1000;
5757
}
5858

59-
totalTicks +=
60-
(int)(remainingSeconds * previousBPM / SECONDS_PER_MINUTE * resolution);
59+
totalTicks += static_cast<int>(remainingSeconds * previousBPM /
60+
SECONDS_PER_MINUTE * resolution);
6161

6262
return totalTicks;
6363
}
@@ -161,7 +161,7 @@ extern "C"
161161

162162
PACKAGE_API float ConvertTickToPosition(int tick, int resolution)
163163
{
164-
return tick / (float)resolution;
164+
return tick / static_cast<float>(resolution);
165165
}
166166

167167
/**
@@ -176,7 +176,7 @@ extern "C"
176176
PACKAGE_API bool IsOnTheBeat(int bpm, float currentTime,
177177
float delta = 0.05f)
178178
{
179-
auto beatInterval = SECONDS_PER_MINUTE / (float)bpm;
179+
auto beatInterval = SECONDS_PER_MINUTE / static_cast<float>(bpm);
180180

181181
auto beatFraction = currentTime / beatInterval;
182182

@@ -197,7 +197,8 @@ extern "C"
197197

198198
PACKAGE_API int RoundUpToTheNearestMultiplier(int value, int multiplier)
199199
{
200-
return (int)std::ceil((float)value / multiplier) * multiplier;
200+
return static_cast<int>(
201+
std::ceil(static_cast<float>(value) / multiplier) * multiplier);
201202
}
202203

203204
/**

0 commit comments

Comments
 (0)