Browse Source

Update numeric literals to use appropriate suffix

Mainly things like .F for floats instead of doubles in float context.
pull/2307/head
ephphatha 5 years ago committed by Anders Jenbo
parent
commit
3520dc4201
  1. 8
      Source/controls/controller_motion.cpp
  2. 10
      Source/engine/animationinfo.cpp
  3. 2
      Source/options.cpp
  4. 2
      Source/player.cpp
  5. 10
      Source/storm/storm_svid.cpp
  6. 2
      Source/utils/push_aulib_decoder.cpp
  7. 11
      Source/utils/soundsample.cpp

8
Source/controls/controller_motion.cpp

@ -76,16 +76,16 @@ bool SimulateRightStickWithDpad(ControllerButtonEvent ctrlEvent)
return false;
switch (ctrlEvent.button) {
case ControllerButton_BUTTON_DPAD_LEFT:
rightStickX = ctrlEvent.up ? 0 : -1;
rightStickX = ctrlEvent.up ? 0.F : -1.F;
break;
case ControllerButton_BUTTON_DPAD_RIGHT:
rightStickX = ctrlEvent.up ? 0 : 1;
rightStickX = ctrlEvent.up ? 0.F : 1.F;
break;
case ControllerButton_BUTTON_DPAD_UP:
rightStickY = ctrlEvent.up ? 0 : 1;
rightStickY = ctrlEvent.up ? 0.F : 1.F;
break;
case ControllerButton_BUTTON_DPAD_DOWN:
rightStickY = ctrlEvent.up ? 0 : -1;
rightStickY = ctrlEvent.up ? 0.F : -1.F;
break;
default:
return false;

10
Source/engine/animationinfo.cpp

@ -61,15 +61,15 @@ float AnimationInfo::GetAnimationProgress() const
if (RelevantFramesForDistributing <= 0) {
// This logic is used if animation distrubtion is not active (see GetFrameToUseForRendering).
// In this case the variables calculated with animation distribution are not initialized and we have to calculate them on the fly with the given information.
float ticksPerFrame = (TicksPerFrame + 1);
float totalTicksForCurrentAnimationSequence = GetProgressToNextGameTick() + (float)CurrentFrame + (TickCounterOfCurrentFrame / ticksPerFrame);
float fAnimationFraction = totalTicksForCurrentAnimationSequence / ((float)NumberOfFrames * ticksPerFrame);
float ticksPerFrame = TicksPerFrame + 1.F;
float totalTicksForCurrentAnimationSequence = GetProgressToNextGameTick() + CurrentFrame + (TickCounterOfCurrentFrame / ticksPerFrame);
float fAnimationFraction = totalTicksForCurrentAnimationSequence / (NumberOfFrames * ticksPerFrame);
return fAnimationFraction;
}
float totalTicksForCurrentAnimationSequence = GetProgressToNextGameTick() + (float)TicksSinceSequenceStarted;
float totalTicksForCurrentAnimationSequence = GetProgressToNextGameTick() + TicksSinceSequenceStarted;
float fProgressInAnimationFrames = totalTicksForCurrentAnimationSequence * TickModifier;
float fAnimationFraction = fProgressInAnimationFrames / (float)NumberOfFrames;
float fAnimationFraction = fProgressInAnimationFrames / NumberOfFrames;
return fAnimationFraction;
}

2
Source/options.cpp

@ -207,7 +207,7 @@ void LoadOptions()
GetIniValue("Controller", "Mapping", sgOptions.Controller.szMapping, sizeof(sgOptions.Controller.szMapping), "");
sgOptions.Controller.bSwapShoulderButtonMode = GetIniBool("Controller", "Swap Shoulder Button Mode", false);
sgOptions.Controller.bDpadHotkeys = GetIniBool("Controller", "Dpad Hotkeys", false);
sgOptions.Controller.fDeadzone = GetIniFloat("Controller", "deadzone", 0.07);
sgOptions.Controller.fDeadzone = GetIniFloat("Controller", "deadzone", 0.07F);
#ifdef __vita__
sgOptions.Controller.bRearTouch = GetIniBool("Controller", "Enable Rear Touchpad", true);
#endif

2
Source/player.cpp

@ -1106,7 +1106,7 @@ void AddPlrExperience(int pnum, int lvl, int exp)
}
// Adjust xp based on difference in level between player and monster
exp *= 1 + ((double)lvl - player._pLevel) / 10;
exp = static_cast<int>(exp * (1 + (lvl - player._pLevel) / 10.0));
if (exp < 0) {
exp = 0;
}

10
Source/storm/storm_svid.cpp

@ -244,7 +244,7 @@ bool SVidPlayBegin(const char *filename, int flags)
ErrSdl();
}
SVidFrameEnd = SDL_GetTicks() * 1000 + SVidFrameLength;
SVidFrameEnd = SDL_GetTicks() * 1000.0 + SVidFrameLength;
SDL_FillRect(GetOutputSurface(), nullptr, 0x000000);
return true;
}
@ -275,7 +275,7 @@ bool SVidPlayContinue()
}
}
if (SDL_GetTicks() * 1000 >= SVidFrameEnd) {
if (SDL_GetTicks() * 1000.0 >= SVidFrameEnd) {
return SVidLoadNextFrame(); // Skip video and audio if the system is to slow
}
@ -291,7 +291,7 @@ bool SVidPlayContinue()
}
#endif
if (SDL_GetTicks() * 1000 >= SVidFrameEnd) {
if (SDL_GetTicks() * 1000.0 >= SVidFrameEnd) {
return SVidLoadNextFrame(); // Skip video if the system is to slow
}
@ -349,9 +349,9 @@ bool SVidPlayContinue()
RenderPresent();
double now = SDL_GetTicks() * 1000;
double now = SDL_GetTicks() * 1000.0;
if (now < SVidFrameEnd) {
SDL_Delay((SVidFrameEnd - now) / 1000); // wait with next frame if the system is too fast
SDL_Delay(static_cast<Uint32>((SVidFrameEnd - now) / 1000.0)); // wait with next frame if the system is too fast
}
return SVidLoadNextFrame();

2
Source/utils/push_aulib_decoder.cpp

@ -68,7 +68,7 @@ int PushAulibDecoder::doDecoding(float buf[], int len, bool &callAgain)
callAgain = false;
const auto writeFloats = [&buf](const std::int16_t *samples, unsigned count) {
constexpr float Scale = std::numeric_limits<std::int16_t>::max() + 1;
constexpr float Scale = std::numeric_limits<std::int16_t>::max() + 1.F;
for (unsigned i = 0; i < count; ++i) {
buf[i] = static_cast<float>(samples[i]) / Scale;
}

11
Source/utils/soundsample.cpp

@ -37,15 +37,15 @@ constexpr float VolumeScale = 3321.9281;
* Min and max volume range, in millibel.
* -100 dB (muted) to 0 dB (max. loudness).
*/
constexpr float MillibelMin = -10000.0;
constexpr float MillibelMax = 0.0;
constexpr float MillibelMin = -10000.F;
constexpr float MillibelMax = 0.F;
/**
* Stereo separation factor for left/right speaker panning. Lower values increase separation, moving
* sounds further left/right, while higher values will pull sounds more towards the middle, reducing separation.
* Current value is tuned to have ~2:1 mix for sounds that happen on the edge of a 640x480 screen.
*/
constexpr float StereoSeparation = 6000.0;
constexpr float StereoSeparation = 6000.F;
float PanLogToLinear(int logPan)
{
@ -61,9 +61,8 @@ float PanLogToLinear(int logPan)
float VolumeLogToLinear(int logVolume, int logMin, int logMax)
{
const auto logScaled = math::Remap<float>(logMin, logMax, MillibelMin, MillibelMax, logVolume);
const auto linVolume = std::pow(LogBase, static_cast<float>(logScaled) / VolumeScale);
return linVolume;
const auto logScaled = math::Remap(static_cast<float>(logMin), static_cast<float>(logMax), MillibelMin, MillibelMax, static_cast<float>(logVolume));
return std::pow(LogBase, logScaled / VolumeScale); // linVolume
}
///// SoundSample /////

Loading…
Cancel
Save