Clean up math functions

- Remove checking for standard functions from the build system
- Prefix all invocations with std::
- Replace suffixed functions with unprefixed versions
- Include <cmath> in all files that use it and remove the global include

e.g. floorf(x) -> std::floor(x)
This commit is contained in:
Martin Natano
2023-04-19 14:22:59 +02:00
parent f39ed52dbf
commit b68ca517e6
111 changed files with 1831 additions and 1785 deletions
-9
View File
@@ -106,15 +106,6 @@ check_cxx_symbol_exists(strcasecmp cstring HAVE_STRCASECMP)
check_function_exists(waitpid HAVE_WAITPID)
# Mostly universal symbols.
check_cxx_symbol_exists(powf cmath HAVE_POWF)
check_cxx_symbol_exists(sqrtf cmath HAVE_SQRTF)
check_cxx_symbol_exists(sinf cmath HAVE_SINF)
check_cxx_symbol_exists(tanf cmath HAVE_TANF)
check_cxx_symbol_exists(cosf cmath HAVE_COSF)
check_cxx_symbol_exists(acosf cmath HAVE_ACOSF)
check_cxx_symbol_exists(truncf cmath HAVE_TRUNCF)
check_cxx_symbol_exists(roundf cmath HAVE_ROUNDF)
check_cxx_symbol_exists(lrintf cmath HAVE_LRINTF)
check_cxx_symbol_exists(strtof cstdlib HAVE_STRTOF)
check_symbol_exists(M_PI math.h HAVE_M_PI)
check_symbol_exists(size_t stddef.h HAVE_SIZE_T_STDDEF)
+26 -24
View File
@@ -13,6 +13,8 @@
#include "LightsManager.h" // for NUM_CabinetLight
#include "ActorUtil.h"
#include "Preference.h"
#include <cmath>
#include <typeinfo>
static Preference<bool> g_bShowMasks("ShowMasks", false);
@@ -158,7 +160,7 @@ Actor::Actor()
lua_setfield( L, -2, "ctx" );
lua_pop( L, 1 );
LUA->Release( L );
m_size = RageVector2( 1, 1 );
InitState();
m_pParent = nullptr;
@@ -361,7 +363,7 @@ void Actor::LoadFromNode( const XNode* pNode )
LUA->Release( L );
// Don't recurse Init. It gets called once for every Actor when the
// Don't recurse Init. It gets called once for every Actor when the
// Actor is loaded, and we don't want to call it again.
PlayCommandNoRecurse( Message("Init") );
}
@@ -376,7 +378,7 @@ bool Actor::PartiallyOpaque()
void Actor::Draw()
{
if( !m_bVisible ||
m_fHibernateSecondsLeft > 0 ||
m_fHibernateSecondsLeft > 0 ||
this->EarlyAbortDraw() )
{
return; // early abort
@@ -536,7 +538,7 @@ void Actor::PreDraw() // calculate actor properties
{
fPercentThroughEffect = 0;
}
ASSERT_M( fPercentThroughEffect >= 0 && fPercentThroughEffect <= 1,
ASSERT_M( fPercentThroughEffect >= 0 && fPercentThroughEffect <= 1,
ssprintf("PercentThroughEffect: %f", fPercentThroughEffect) );
bool bBlinkOn = fPercentThroughEffect > 0.5f;
@@ -549,7 +551,7 @@ void Actor::PreDraw() // calculate actor properties
switch( m_Effect )
{
case diffuse_blink:
/* XXX: Should diffuse_blink and diffuse_shift multiply the m_current_with_effects color?
/* XXX: Should diffuse_blink and diffuse_shift multiply the m_current_with_effects color?
* (That would have the same effect with 1,1,1,1, and allow tweening the diffuse
* while blinking and shifting.) */
for(int i=0; i<NUM_DIFFUSE_COLORS; i++)
@@ -670,11 +672,11 @@ void Actor::BeginDraw() // set the world matrix
{
DISPLAY->PushMatrix();
if( m_pTempState->pos.x != 0 || m_pTempState->pos.y != 0 || m_pTempState->pos.z != 0 )
if( m_pTempState->pos.x != 0 || m_pTempState->pos.y != 0 || m_pTempState->pos.z != 0 )
{
RageMatrix m;
RageMatrixTranslate(
&m,
RageMatrixTranslate(
&m,
m_pTempState->pos.x,
m_pTempState->pos.y,
m_pTempState->pos.z
@@ -690,7 +692,7 @@ void Actor::BeginDraw() // set the world matrix
const float fRotateY = m_pTempState->rotation.y + m_baseRotation.y;
const float fRotateZ = m_pTempState->rotation.z + m_baseRotation.z;
if( fRotateX != 0 || fRotateY != 0 || fRotateZ != 0 )
if( fRotateX != 0 || fRotateY != 0 || fRotateZ != 0 )
{
RageMatrix m;
RageMatrixRotationXYZ( &m, fRotateX, fRotateY, fRotateZ );
@@ -707,7 +709,7 @@ void Actor::BeginDraw() // set the world matrix
if( fScaleX != 1 || fScaleY != 1 || fScaleZ != 1 )
{
RageMatrix m;
RageMatrixScale(
RageMatrixScale(
&m,
fScaleX,
fScaleY,
@@ -722,8 +724,8 @@ void Actor::BeginDraw() // set the world matrix
float fX = SCALE( m_fHorizAlign, 0.0f, 1.0f, +m_size.x/2.0f, -m_size.x/2.0f );
float fY = SCALE( m_fVertAlign, 0.0f, 1.0f, +m_size.y/2.0f, -m_size.y/2.0f );
RageMatrix m;
RageMatrixTranslate(
&m,
RageMatrixTranslate(
&m,
fX,
fY,
0
@@ -832,7 +834,7 @@ void Actor::UpdateTweening( float fDeltaTime )
m_start = m_current; // set the start position
SetCurrentTweenStart();
}
if( TI.m_fTimeLeftInTween == 0 ) // Current tween is over. Stop.
{
m_current = TS;
@@ -976,7 +978,7 @@ void Actor::UpdateInternal(float delta_time)
RString Actor::GetLineage() const
{
RString sPath;
if( m_pParent )
sPath = m_pParent->GetLineage() + '/';
sPath += ssprintf( "<type %s> %s", typeid(*this).name(), m_sName.c_str() );
@@ -1007,7 +1009,7 @@ void Actor::BeginTweening( float time, ITween *pTween )
{
ASSERT( time >= 0 );
// If the number of tweens to ever gets this large, there's probably an infinitely
// If the number of tweens to ever gets this large, there's probably an infinitely
// recursing ActorCommand.
if( m_Tweens.size() > 50 )
{
@@ -1080,8 +1082,8 @@ void Actor::ScaleTo( const RectF &rect, StretchType st )
if( rect_height < 0 ) SetRotationX( 180 );
// zoom fActor needed to scale the Actor to fill the rectangle
float fNewZoomX = fabsf(rect_width / m_size.x);
float fNewZoomY = fabsf(rect_height / m_size.y);
float fNewZoomX = std::abs(rect_width / m_size.x);
float fNewZoomY = std::abs(rect_height / m_size.y);
float fNewZoom = 0.f;
switch( st )
@@ -1400,9 +1402,9 @@ void Actor::SetGlobalDiffuseColor( RageColor c )
{
for( unsigned ts = 0; ts < m_Tweens.size(); ++ts )
{
m_Tweens[ts]->state.diffuse[i].r = c.r;
m_Tweens[ts]->state.diffuse[i].g = c.g;
m_Tweens[ts]->state.diffuse[i].b = c.b;
m_Tweens[ts]->state.diffuse[i].r = c.r;
m_Tweens[ts]->state.diffuse[i].g = c.g;
m_Tweens[ts]->state.diffuse[i].b = c.b;
}
m_current.diffuse[i].r = c.r;
m_current.diffuse[i].g = c.g;
@@ -1490,7 +1492,7 @@ void Actor::Sleep( float time )
ASSERT( time >= 0 );
BeginTweening( time, TWEEN_LINEAR );
BeginTweening( 0, TWEEN_LINEAR );
BeginTweening( 0, TWEEN_LINEAR );
}
void Actor::QueueCommand( const RString& sCommandName )
@@ -1610,7 +1612,7 @@ Actor::TweenInfo &Actor::TweenInfo::operator=( const TweenInfo &rhs )
// lua start
#include "LuaBinding.h"
/** @brief Allow Lua to have access to the Actor. */
/** @brief Allow Lua to have access to the Actor. */
class LunaActor : public Luna<Actor>
{
public:
@@ -2189,7 +2191,7 @@ LUA_REGISTER_INSTANCED_BASE_CLASS( Actor )
/*
* (c) 2001-2004 Chris Danford
* All rights reserved.
*
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
@@ -2199,7 +2201,7 @@ LUA_REGISTER_INSTANCED_BASE_CLASS( Actor )
* copyright notice(s) and this permission notice appear in all copies of
* the Software and that both the above copyright notice(s) and this
* permission notice appear in supporting documentation.
*
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
+13 -11
View File
@@ -8,8 +8,10 @@
#include "ActorUtil.h"
#include "LuaBinding.h"
#include <cmath>
/* Tricky: We need ActorFrames created in Lua to auto delete their children.
* We don't want classes that derive from ActorFrame to auto delete their
* We don't want classes that derive from ActorFrame to auto delete their
* children. The name "ActorFrame" is widely used in Lua, so we'll have
* that string instead create an ActorFrameAutoDeleteChildren object. */
//REGISTER_ACTOR_CLASS( ActorScroller );
@@ -116,7 +118,7 @@ float ActorScroller::GetSecondsForCompleteScrollThrough() const
float ActorScroller::GetSecondsToDestination() const
{
float fTotalItemsToMove = fabsf(m_fCurrentItem - m_fDestinationItem);
float fTotalItemsToMove = std::abs(m_fCurrentItem - m_fDestinationItem);
return fTotalItemsToMove * m_fSecondsPerItem;
}
@@ -195,7 +197,7 @@ void ActorScroller::UpdateInternal( float fDeltaTime )
float fApproachSpeed = fDeltaTime/m_fSecondsPerItem;
if( m_bFastCatchup )
{
float fDistanceToMove = fabsf(m_fCurrentItem - m_fDestinationItem);
float fDistanceToMove = std::abs(m_fCurrentItem - m_fDestinationItem);
if( fDistanceToMove > 1 )
fApproachSpeed *= fDistanceToMove*fDistanceToMove;
}
@@ -210,13 +212,13 @@ void ActorScroller::UpdateInternal( float fDeltaTime )
if( m_bWrap )
{
float Delta = m_fDestinationItem - m_fCurrentItem;
m_fCurrentItem = fmodf( m_fCurrentItem, (float) m_iNumItems );
m_fCurrentItem = std::fmod( m_fCurrentItem, (float) m_iNumItems );
m_fDestinationItem = m_fCurrentItem + Delta;
}
if( m_bLoop )
{
m_fCurrentItem = fmodf( m_fCurrentItem, (float) m_iNumItems );
m_fCurrentItem = std::fmod( m_fCurrentItem, (float) m_iNumItems );
}
}
@@ -261,8 +263,8 @@ void ActorScroller::PositionItemsAndDrawPrimitives( bool bDrawPrimitives )
float fFirstItemToDraw = m_fCurrentItem - fNumItemsToDraw/2.f;
float fLastItemToDraw = m_fCurrentItem + fNumItemsToDraw/2.f;
int iFirstItemToDraw = (int) ceilf( fFirstItemToDraw );
int iLastItemToDraw = (int) ceilf( fLastItemToDraw );
int iFirstItemToDraw = std::ceil( fFirstItemToDraw );
int iLastItemToDraw = std::ceil( fLastItemToDraw );
if( !m_bLoop && !m_bWrap )
{
iFirstItemToDraw = clamp( iFirstItemToDraw, 0, m_iNumItems );
@@ -320,7 +322,7 @@ void ActorScroller::PositionItemsAndDrawPrimitives( bool bDrawPrimitives )
// lua start
#include "LuaBinding.h"
/** @brief Allow Lua to have access to the ActorScroller. */
/** @brief Allow Lua to have access to the ActorScroller. */
class LunaActorScroller: public Luna<ActorScroller>
{
public:
@@ -354,7 +356,7 @@ public:
static int GetCurrentItem( T* p, lua_State *L ) { lua_pushnumber( L, p->GetCurrentItem() ); return 1; }
static int GetDestinationItem( T* p, lua_State *L ) { lua_pushnumber( L, p->GetDestinationItem() ); return 1; }
static int GetNumItems( T* p, lua_State *L ) { lua_pushnumber( L, p->GetNumItems() ); return 1; }
LunaActorScroller()
{
ADD_METHOD( PositionItems );
@@ -389,7 +391,7 @@ LUA_REGISTER_DERIVED_CLASS( ActorScroller, ActorFrame )
/*
* (c) 2003-2004 Chris Danford
* All rights reserved.
*
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
@@ -399,7 +401,7 @@ LUA_REGISTER_DERIVED_CLASS( ActorScroller, ActorFrame )
* copyright notice(s) and this permission notice appear in all copies of
* the Software and that both the above copyright notice(s) and this
* permission notice appear in supporting documentation.
*
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
+21 -19
View File
@@ -1,17 +1,17 @@
/*
* AdjustSync defines two methods for fixing the sync.
* AdjustSync defines two methods for fixing the sync.
*
* The first method adjusts either the song or the machine by the
* The first method adjusts either the song or the machine by the
* average offset of the user's steps. In other words, if the user
* averages to step early by 10 ms, either the song or the global
* offset is adjusted by 10 ms to compensate for that. These
* offset is adjusted by 10 ms to compensate for that. These
* adjustments only require a small set of data, so this method
* updates the offset while the song is playing.
*
* The second method adjusts both the offset and the tempo of an
* individual song. It records all of the steps during a play of
* the song and uses linear least squares regression to minimize the
* error of those steps. It makes one adjustment for the tempo of
* error of those steps. It makes one adjustment for the tempo of
* the entire song, rather than adding many different tempo segments
* to match the steps. If there are already several tempo segments
* in the stepfile, this method makes a proportional change to each
@@ -19,8 +19,8 @@
* also change 200 bpm to 202 bpm. This method also adjusts the stops.
* It assumes that a given stop is measured in terms of beats and makes
* the appropriate change.
*
* If we use this method on a small set of data late in the song, it
*
* If we use this method on a small set of data late in the song, it
* can have very chaotic effects on the early settings. For example,
* it may change the offset by several hundred milliseconds and make a
* large change to the BPM to compensate if that would minimize the
@@ -29,7 +29,7 @@
* perform the least squares regression once on all of the data
* collected, rather than adjusting the sync every time we get another
* 50 or so data points. In fact, if we are playing in edit mode and
* the user loops through the song more than once, we use all of the
* the user loops through the song more than once, we use all of the
* steps made.
*/
@@ -42,6 +42,8 @@
#include "PrefsManager.h"
#include "ScreenManager.h"
#include <cmath>
std::vector<TimingData> AdjustSync::s_vpTimingDataOriginal;
float AdjustSync::s_fGlobalOffsetSecondsOriginal = 0.0f;
@@ -161,7 +163,7 @@ void AdjustSync::HandleAutosync( float fNoteOffBySeconds, float fStepTime )
s_fAutosyncOffset[s_iAutosyncOffsetSample] = fNoteOffBySeconds;
++s_iAutosyncOffsetSample;
if( s_iAutosyncOffsetSample < OFFSET_SAMPLE_COUNT )
if( s_iAutosyncOffsetSample < OFFSET_SAMPLE_COUNT )
break; // need more
AutosyncOffset();
@@ -298,7 +300,7 @@ static LocalizedString GLOBAL_OFFSET_FROM ( "AdjustSync", "Global Offset from %+
// We need to limit the length of lines so each one fits on one line of the SM console.
// The tempo and stop change message can get very long in a complicated song, and at
// a low resolution, the keep/revert menu would be pushed off the bottom of the screen
// if we didn't limit the length of the message. Keeping the lines short lets us fit
// if we didn't limit the length of the message. Keeping the lines short lets us fit
// more information on the screen.
static LocalizedString SONG_OFFSET_FROM ( "AdjustSync", "Song offset from %+.3f to %+.3f (notes %s)" );
static LocalizedString TEMPO_SEGMENT_FROM ( "AdjustSync", "%s BPM from %.3f BPM to %.3f BPM." );
@@ -314,9 +316,9 @@ void AdjustSync::GetSyncChangeTextGlobal( std::vector<RString> &vsAddTo )
float fNew = Quantize( PREFSMAN->m_fGlobalOffsetSeconds, 0.001f ) ;
float fDelta = fNew - fOld;
if( fabsf(fDelta) > 0.0001f )
if( std::abs(fDelta) > 0.0001f )
{
vsAddTo.push_back( ssprintf(
vsAddTo.push_back( ssprintf(
GLOBAL_OFFSET_FROM.GetValue(),
fOld, fNew,
(fDelta > 0 ? EARLIER:LATER).GetValue().c_str() ));
@@ -344,11 +346,11 @@ void AdjustSync::GetSyncChangeTextSong( std::vector<RString> &vsAddTo )
float fNew = Quantize( testing.m_fBeat0OffsetInSeconds, 0.001f );
float fDelta = fNew - fOld;
if( fabsf(fDelta) > 0.0001f )
if( std::abs(fDelta) > 0.0001f )
{
vsAddTo.push_back( ssprintf(
vsAddTo.push_back( ssprintf(
SONG_OFFSET_FROM.GetValue(),
fOld,
fOld,
fNew,
(fDelta > 0 ? EARLIER:LATER).GetValue().c_str() ) );
}
@@ -362,7 +364,7 @@ void AdjustSync::GetSyncChangeTextSong( std::vector<RString> &vsAddTo )
float fNew = Quantize( ToBPM(bpmTest[i])->GetBPM(), 0.001f );
float fOld = Quantize( ToBPM(bpmOrig[i])->GetBPM(), 0.001f );
if( fabsf(fNew - fOld) < 1e-4 )
if( std::abs(fNew - fOld) < 1e-4 )
continue;
if ( i >= 4 )
@@ -387,7 +389,7 @@ void AdjustSync::GetSyncChangeTextSong( std::vector<RString> &vsAddTo )
float fNew = Quantize( ToStop(stopTest[i])->GetPause(), 0.001f );
float fDelta = fNew - fOld;
if( fabsf(fDelta) < 1e-4 )
if( std::abs(fDelta) < 1e-4 )
continue;
if ( i >= 4 )
@@ -413,7 +415,7 @@ void AdjustSync::GetSyncChangeTextSong( std::vector<RString> &vsAddTo )
float fNew = Quantize( ToDelay(delyTest[i])->GetPause(), 0.001f );
float fDelta = fNew - fOld;
if( fabsf(fDelta) < 1e-4 )
if( std::abs(fDelta) < 1e-4 )
continue;
if ( i >= 4 )
@@ -442,7 +444,7 @@ void AdjustSync::GetSyncChangeTextSong( std::vector<RString> &vsAddTo )
/*
* (c) 2003-2006 Chris Danford, John Bauer
* All rights reserved.
*
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
@@ -452,7 +454,7 @@ void AdjustSync::GetSyncChangeTextSong( std::vector<RString> &vsAddTo )
* copyright notice(s) and this permission notice appear in all copies of
* the Software and that both the above copyright notice(s) and this
* permission notice appear in supporting documentation.
*
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
+134 -132
View File
@@ -12,7 +12,9 @@
#include "GameState.h"
#include "Style.h"
#include "ThemeMetric.h"
#include <float.h>
#include <cfloat>
#include <cmath>
static char const dimension_names[4]= "XYZ";
@@ -84,7 +86,7 @@ float ArrowGetPercentVisible(float fYPosWithoutReverse, int iCol, float fYOffset
static float GetNoteFieldHeight()
{
return SCREEN_HEIGHT + fabsf(curr_options->m_fPerspectiveTilt)*200;
return SCREEN_HEIGHT + std::abs(curr_options->m_fPerspectiveTilt)*200;
}
float ArrowEffects::GetTime()
@@ -158,11 +160,11 @@ static float CalculateTornadoOffsetFromMagnitude(int dimension, int col_id,
data.m_MaxTornado[dimension][col_id] * field_zoom,
tornado_position_scale_to_low[dimension],
tornado_position_scale_to_high[dimension]);
float rads= acosf(position_between);
float rads= std::acos(position_between);
float frequency= tornado_offset_frequency[dimension];
rads+= (y_offset + effect_offset) * ((period * frequency) + frequency) / SCREEN_HEIGHT;
float processed_rads = is_tan ? SelectTanType(rads, curr_options->m_bCosecant) : RageFastCos(rads);
float processed_rads = is_tan ? SelectTanType(rads, curr_options->m_bCosecant) : RageFastCos(rads);
float const adjusted_pixel_offset= SCALE(processed_rads,
tornado_offset_scale_from_low[dimension],
tornado_offset_scale_from_high[dimension],
@@ -171,7 +173,7 @@ static float CalculateTornadoOffsetFromMagnitude(int dimension, int col_id,
return (adjusted_pixel_offset - real_pixel_offset) * magnitude;
}
static float CalculateDrunkAngle(float speed, int col, float offset,
static float CalculateDrunkAngle(float speed, int col, float offset,
float col_frequency, float y_offset, float period, float offset_frequency)
{
float time = ArrowEffects::GetTime();
@@ -201,9 +203,9 @@ static void UpdateBeat(int dimension, PerPlayerData &data, const SongPosition &p
return;
// -100.2 -> -0.2 -> 0.2
fBeat -= truncf( fBeat );
fBeat -= std::trunc( fBeat );
fBeat += 1;
fBeat -= truncf( fBeat );
fBeat -= std::trunc( fBeat );
if( fBeat >= fTotalTime )
return;
@@ -235,18 +237,18 @@ static void UpdateTipsy(float * tipsy_result, float * tipsy_offset_result, float
{
if (is_tan)
{
tipsy_result[col]= SelectTanType(time_times_timer + (col * ((offset *
tipsy_result[col]= SelectTanType(time_times_timer + (col * ((offset *
TIPSY_COLUMN_FREQUENCY) + TIPSY_COLUMN_FREQUENCY)), curr_options->m_bCosecant)
* arrow_times_mag;
tipsy_offset_result[col]= SelectTanType(time_times_offset_timer + (col *
tipsy_offset_result[col]= SelectTanType(time_times_offset_timer + (col *
TIPSY_OFFSET_COLUMN_FREQUENCY), curr_options->m_bCosecant)
* arrow_times_offset_mag;
}
else
{
tipsy_result[col]= RageFastCos(time_times_timer + (col * ((offset *
tipsy_result[col]= RageFastCos(time_times_timer + (col * ((offset *
TIPSY_COLUMN_FREQUENCY) + TIPSY_COLUMN_FREQUENCY))) * arrow_times_mag;
tipsy_offset_result[col]= RageFastCos(time_times_offset_timer + (col *
tipsy_offset_result[col]= RageFastCos(time_times_offset_timer + (col *
TIPSY_OFFSET_COLUMN_FREQUENCY)) * arrow_times_offset_mag;
}
}
@@ -312,7 +314,7 @@ void ArrowEffects::Update()
{
static float fLastTime = 0;
float fTime = RageTimer::GetTimeSinceStartFast();
FOREACH_EnabledPlayer( pn )
{
const Style* pStyle = GAMESTATE->GetCurrentStyle(pn);
@@ -323,19 +325,19 @@ void ArrowEffects::Update()
const float* accels= GAMESTATE->m_pPlayerState[pn]->m_PlayerOptions.GetCurrent().m_fAccels;
PerPlayerData &data = g_EffectData[pn];
if(pStyle != data.m_prev_style)
{
Init(pn);
data.m_prev_style= pStyle;
}
if( !position.m_bFreeze || !position.m_bDelay )
{
data.m_fExpandSeconds += fTime - fLastTime;
data.m_fExpandSeconds = fmodf( data.m_fExpandSeconds, (PI*2)/(accels[PlayerOptions::ACCEL_EXPAND_PERIOD]+1) );
data.m_fExpandSeconds = std::fmod( data.m_fExpandSeconds, (PI*2)/(accels[PlayerOptions::ACCEL_EXPAND_PERIOD]+1) );
data.m_fTanExpandSeconds += fTime - fLastTime;
data.m_fTanExpandSeconds = fmodf( data.m_fTanExpandSeconds, (PI*2)/(accels[PlayerOptions::ACCEL_TAN_EXPAND_PERIOD]+1) );
data.m_fTanExpandSeconds = std::fmod( data.m_fTanExpandSeconds, (PI*2)/(accels[PlayerOptions::ACCEL_TAN_EXPAND_PERIOD]+1) );
}
// Update Invert
@@ -385,8 +387,8 @@ void ArrowEffects::Update()
// Update Tipsy
if(effects[PlayerOptions::EFFECT_TIPSY] != 0)
{
UpdateTipsy(data.m_tipsy_result, data.m_tipsy_offset_result,
effects[PlayerOptions::EFFECT_TIPSY_OFFSET],
UpdateTipsy(data.m_tipsy_result, data.m_tipsy_offset_result,
effects[PlayerOptions::EFFECT_TIPSY_OFFSET],
effects[PlayerOptions::EFFECT_TIPSY_SPEED], false);
}
else
@@ -396,12 +398,12 @@ void ArrowEffects::Update()
data.m_tipsy_result[col]= 0;
}
}
// Update TanTipsy
if(effects[PlayerOptions::EFFECT_TAN_TIPSY] != 0)
{
UpdateTipsy(data.m_tan_tipsy_result, data.m_tan_tipsy_offset_result,
effects[PlayerOptions::EFFECT_TAN_TIPSY_OFFSET],
UpdateTipsy(data.m_tan_tipsy_result, data.m_tan_tipsy_offset_result,
effects[PlayerOptions::EFFECT_TAN_TIPSY_OFFSET],
effects[PlayerOptions::EFFECT_TAN_TIPSY_SPEED], true);
}
else
@@ -464,9 +466,9 @@ float ArrowEffects::GetYOffset( const PlayerState* pPlayerState, int iCol, float
float fYOffset = 0;
const SongPosition &position = pPlayerState->GetDisplayedPosition();
float fSongBeat = position.m_fSongBeatVisible;
Steps *pCurSteps = GAMESTATE->m_pCurSteps[pPlayerState->m_PlayerNumber];
/* Usually, fTimeSpacing is 0 or 1, in which case we use entirely beat spacing or
@@ -507,7 +509,7 @@ float ArrowEffects::GetYOffset( const PlayerState* pPlayerState, int iCol, float
fScrollSpeed= curr_options->m_fMaxScrollBPM /
(pPlayerState->m_fReadBPM * GAMESTATE->m_SongOptions.GetCurrent().m_fMusicRate);
}
// don't mess with the arrows after they've crossed 0
if( fYOffset < 0 )
{
@@ -516,7 +518,7 @@ float ArrowEffects::GetYOffset( const PlayerState* pPlayerState, int iCol, float
const float* fAccels = curr_options->m_fAccels;
const float* fEffects = curr_options->m_fEffects;
// TODO: Don't index by PlayerNumber.
PerPlayerData &data = g_EffectData[pPlayerState->m_PlayerNumber];
@@ -525,7 +527,7 @@ float ArrowEffects::GetYOffset( const PlayerState* pPlayerState, int iCol, float
if( fAccels[PlayerOptions::ACCEL_BOOST] != 0 )
{
float fEffectHeight = GetNoteFieldHeight();
float fNewYOffset = fYOffset * 1.5f / ((fYOffset+fEffectHeight/1.2f)/fEffectHeight);
float fNewYOffset = fYOffset * 1.5f / ((fYOffset+fEffectHeight/1.2f)/fEffectHeight);
float fAccelYAdjust = fAccels[PlayerOptions::ACCEL_BOOST] * (fNewYOffset - fYOffset);
// TRICKY: Clamp this value, or else BOOST+BOOMERANG will draw a ton of arrows on the screen.
CLAMP( fAccelYAdjust, BOOST_MOD_MIN_CLAMP, BOOST_MOD_MAX_CLAMP );
@@ -535,7 +537,7 @@ float ArrowEffects::GetYOffset( const PlayerState* pPlayerState, int iCol, float
{
float fEffectHeight = GetNoteFieldHeight();
float fScale = SCALE( fYOffset, 0.f, fEffectHeight, 0, 1.f );
float fNewYOffset = fYOffset * fScale;
float fNewYOffset = fYOffset * fScale;
float fBrakeYAdjust = fAccels[PlayerOptions::ACCEL_BRAKE] * (fNewYOffset - fYOffset);
// TRICKY: Clamp this value the same way as BOOST so that in BOOST+BRAKE, BRAKE doesn't overpower BOOST
CLAMP( fBrakeYAdjust, BRAKE_MOD_MIN_CLAMP, BRAKE_MOD_MAX_CLAMP );
@@ -543,7 +545,7 @@ float ArrowEffects::GetYOffset( const PlayerState* pPlayerState, int iCol, float
}
if( fAccels[PlayerOptions::ACCEL_WAVE] != 0 )
fYAdjust += fAccels[PlayerOptions::ACCEL_WAVE] * WAVE_MOD_MAGNITUDE *RageFastSin( fYOffset/((fAccels[PlayerOptions::ACCEL_WAVE_PERIOD]*WAVE_MOD_HEIGHT)+WAVE_MOD_HEIGHT) );
if( fEffects[PlayerOptions::EFFECT_PARABOLA_Y] != 0 )
fYAdjust += fEffects[PlayerOptions::EFFECT_PARABOLA_Y] * (fYOffset/ARROW_SIZE) * (fYOffset/ARROW_SIZE);
@@ -581,7 +583,7 @@ float ArrowEffects::GetYOffset( const PlayerState* pPlayerState, int iCol, float
float fExpandMultiplier = SCALE( RageFastCos(data.m_fExpandSeconds*EXPAND_MULTIPLIER_FREQUENCY*(fAccels[PlayerOptions::ACCEL_EXPAND_PERIOD]+1)),
EXPAND_MULTIPLIER_SCALE_FROM_LOW, EXPAND_MULTIPLIER_SCALE_FROM_HIGH,
EXPAND_MULTIPLIER_SCALE_TO_LOW, EXPAND_MULTIPLIER_SCALE_TO_HIGH );
fScrollSpeed *= SCALE( fAccels[PlayerOptions::ACCEL_EXPAND],
fScrollSpeed *= SCALE( fAccels[PlayerOptions::ACCEL_EXPAND],
EXPAND_SPEED_SCALE_FROM_LOW, EXPAND_SPEED_SCALE_FROM_HIGH,
EXPAND_SPEED_SCALE_TO_LOW, fExpandMultiplier );
}
@@ -591,7 +593,7 @@ float ArrowEffects::GetYOffset( const PlayerState* pPlayerState, int iCol, float
float fTanExpandMultiplier = SCALE( SelectTanType(data.m_fTanExpandSeconds*EXPAND_MULTIPLIER_FREQUENCY*(fAccels[PlayerOptions::ACCEL_TAN_EXPAND_PERIOD]+1), curr_options->m_bCosecant),
EXPAND_MULTIPLIER_SCALE_FROM_LOW, EXPAND_MULTIPLIER_SCALE_FROM_HIGH,
EXPAND_MULTIPLIER_SCALE_TO_LOW, EXPAND_MULTIPLIER_SCALE_TO_HIGH );
fScrollSpeed *= SCALE( fAccels[PlayerOptions::ACCEL_TAN_EXPAND],
fScrollSpeed *= SCALE( fAccels[PlayerOptions::ACCEL_TAN_EXPAND],
EXPAND_SPEED_SCALE_FROM_LOW, EXPAND_SPEED_SCALE_FROM_HIGH,
EXPAND_SPEED_SCALE_TO_LOW, fTanExpandMultiplier );
}
@@ -609,7 +611,7 @@ static void ArrowGetReverseShiftAndScale(int iCol, float fYReverseOffsetPixels,
float fZoom = 1 - fMiniPercent*0.5f;
// don't divide by 0
if( fabsf(fZoom) < 0.01 )
if( std::abs(fZoom) < 0.01 )
fZoom = 0.01f;
float fPercentReverse = curr_options->GetReversePercentForColumn(iCol);
@@ -637,20 +639,20 @@ float ArrowEffects::GetYPos( const PlayerState* pPlayerState, int iCol, float fY
const Style* pStyle = GAMESTATE->GetCurrentStyle(pPlayerState->m_PlayerNumber);
const Style::ColumnInfo* pCols = pStyle->m_ColumnInfo[pPlayerState->m_PlayerNumber];
const float* fEffects = curr_options->m_fEffects;
// Doing the math with a precalculated result of 0 should be faster than
// checking whether tipsy is on. -Kyz
// TODO: Don't index by PlayerNumber.
PerPlayerData& data= g_EffectData[curr_options->m_pn];
f+= fEffects[PlayerOptions::EFFECT_TIPSY] * data.m_tipsy_result[iCol];
f+= fEffects[PlayerOptions::EFFECT_TAN_TIPSY] * data.m_tan_tipsy_result[iCol];
if( fEffects[PlayerOptions::EFFECT_ATTENUATE_Y] != 0 )
{
const float fXOffset = pCols[iCol].fXOffset;
f += fEffects[PlayerOptions::EFFECT_ATTENUATE_Y] * (fYOffset/ARROW_SIZE) * (fYOffset/ARROW_SIZE) * (fXOffset/ARROW_SIZE);
}
if( fEffects[PlayerOptions::EFFECT_BEAT_Y] != 0 )
{
@@ -662,7 +664,7 @@ float ArrowEffects::GetYPos( const PlayerState* pPlayerState, int iCol, float fY
// floored, making arrows show on integer Y coordinates. Supposedly it makes
// the arrows look better, but testing needs to be done.
// todo: make this a noteskin metric instead of a theme metric? -aj
return QUANTIZE_ARROW_Y ? floor(f) : f;
return QUANTIZE_ARROW_Y ? std::floor(f) : f;
}
float ArrowEffects::GetYOffsetFromYPos(int iCol, float YPos, float fYReverseOffsetPixels)
@@ -676,7 +678,7 @@ float ArrowEffects::GetYOffsetFromYPos(int iCol, float YPos, float fYReverseOffs
PerPlayerData& data= g_EffectData[curr_options->m_pn];
f+= fEffects[PlayerOptions::EFFECT_TIPSY] * data.m_tipsy_offset_result[iCol];
f+= fEffects[PlayerOptions::EFFECT_TAN_TIPSY] * data.m_tan_tipsy_offset_result[iCol];
f+= fEffects[PlayerOptions::EFFECT_PARABOLA_Y] * (YPos/ARROW_SIZE) * (YPos/ARROW_SIZE);
float fShift, fScale;
@@ -689,7 +691,7 @@ float ArrowEffects::GetYOffsetFromYPos(int iCol, float YPos, float fYReverseOffs
return f;
}
float ArrowEffects::GetXPos( const PlayerState* pPlayerState, int iColNum, float fYOffset )
float ArrowEffects::GetXPos( const PlayerState* pPlayerState, int iColNum, float fYOffset )
{
float fPixelOffsetFromCenter = 0; // fill this in below
@@ -717,28 +719,28 @@ float ArrowEffects::GetXPos( const PlayerState* pPlayerState, int iColNum, float
fEffects[PlayerOptions::EFFECT_TAN_TORNADO_PERIOD],
pCols, pPlayerState->m_NotefieldZoom, data, fYOffset, true);
}
if( fEffects[PlayerOptions::EFFECT_BUMPY_X] != 0 )
fPixelOffsetFromCenter += fEffects[PlayerOptions::EFFECT_BUMPY_X] *
fPixelOffsetFromCenter += fEffects[PlayerOptions::EFFECT_BUMPY_X] *
40*RageFastSin( CalculateBumpyAngle(fYOffset,
fEffects[PlayerOptions::EFFECT_BUMPY_X_OFFSET],
fEffects[PlayerOptions::EFFECT_BUMPY_X_PERIOD]) );
if( fEffects[PlayerOptions::EFFECT_TAN_BUMPY_X] != 0 )
fPixelOffsetFromCenter += fEffects[PlayerOptions::EFFECT_TAN_BUMPY_X] *
fPixelOffsetFromCenter += fEffects[PlayerOptions::EFFECT_TAN_BUMPY_X] *
40*SelectTanType( CalculateBumpyAngle(fYOffset,
fEffects[PlayerOptions::EFFECT_TAN_BUMPY_X_OFFSET],
fEffects[PlayerOptions::EFFECT_TAN_BUMPY_X_PERIOD]), curr_options->m_bCosecant );
if( fEffects[PlayerOptions::EFFECT_DRUNK] != 0 )
fPixelOffsetFromCenter += fEffects[PlayerOptions::EFFECT_DRUNK] *
( RageFastCos( CalculateDrunkAngle(fEffects[PlayerOptions::EFFECT_DRUNK_SPEED], iColNum,
fPixelOffsetFromCenter += fEffects[PlayerOptions::EFFECT_DRUNK] *
( RageFastCos( CalculateDrunkAngle(fEffects[PlayerOptions::EFFECT_DRUNK_SPEED], iColNum,
fEffects[PlayerOptions::EFFECT_DRUNK_OFFSET], DRUNK_COLUMN_FREQUENCY,
fYOffset, fEffects[PlayerOptions::EFFECT_DRUNK_PERIOD],
DRUNK_OFFSET_FREQUENCY) ) * ARROW_SIZE*DRUNK_ARROW_MAGNITUDE );
if( fEffects[PlayerOptions::EFFECT_TAN_DRUNK] != 0 )
fPixelOffsetFromCenter += fEffects[PlayerOptions::EFFECT_TAN_DRUNK] *
fPixelOffsetFromCenter += fEffects[PlayerOptions::EFFECT_TAN_DRUNK] *
( SelectTanType( CalculateDrunkAngle(fEffects[PlayerOptions::EFFECT_TAN_DRUNK_SPEED],
iColNum, fEffects[PlayerOptions::EFFECT_TAN_DRUNK_OFFSET],
DRUNK_COLUMN_FREQUENCY, fYOffset,
@@ -763,23 +765,23 @@ float ArrowEffects::GetXPos( const PlayerState* pPlayerState, int iColNum, float
const float fShift = data.m_fBeatFactor[dim_x]*RageFastSin( fYOffset / ((fEffects[PlayerOptions::EFFECT_BEAT_PERIOD]*BEAT_OFFSET_HEIGHT)+BEAT_OFFSET_HEIGHT) + PI/BEAT_PI_HEIGHT );
fPixelOffsetFromCenter += fEffects[PlayerOptions::EFFECT_BEAT] * fShift;
}
if( fEffects[PlayerOptions::EFFECT_ZIGZAG] != 0 )
{
float fResult = RageTriangle( (PI * (1/(fEffects[PlayerOptions::EFFECT_ZIGZAG_PERIOD]+1)) *
float fResult = RageTriangle( (PI * (1/(fEffects[PlayerOptions::EFFECT_ZIGZAG_PERIOD]+1)) *
((fYOffset+(100.0f*(fEffects[PlayerOptions::EFFECT_ZIGZAG_OFFSET])))/ARROW_SIZE) ) );
fPixelOffsetFromCenter += (fEffects[PlayerOptions::EFFECT_ZIGZAG]*ARROW_SIZE/2) * fResult;
}
if( fEffects[PlayerOptions::EFFECT_SAWTOOTH] != 0 )
fPixelOffsetFromCenter += (fEffects[PlayerOptions::EFFECT_SAWTOOTH]*ARROW_SIZE) *
((0.5f / (fEffects[PlayerOptions::EFFECT_SAWTOOTH_PERIOD]+1) * fYOffset) / ARROW_SIZE -
floor((0.5f / (fEffects[PlayerOptions::EFFECT_SAWTOOTH_PERIOD]+1) * fYOffset) / ARROW_SIZE) );
fPixelOffsetFromCenter += (fEffects[PlayerOptions::EFFECT_SAWTOOTH]*ARROW_SIZE) *
((0.5f / (fEffects[PlayerOptions::EFFECT_SAWTOOTH_PERIOD]+1) * fYOffset) / ARROW_SIZE -
std::floor((0.5f / (fEffects[PlayerOptions::EFFECT_SAWTOOTH_PERIOD]+1) * fYOffset) / ARROW_SIZE) );
if( fEffects[PlayerOptions::EFFECT_PARABOLA_X] != 0 )
fPixelOffsetFromCenter += fEffects[PlayerOptions::EFFECT_PARABOLA_X] * (fYOffset/ARROW_SIZE) * (fYOffset/ARROW_SIZE);
if( fEffects[PlayerOptions::EFFECT_ATTENUATE_X] != 0 )
{
const float fXOffset = pCols[iColNum].fXOffset;
@@ -788,32 +790,32 @@ float ArrowEffects::GetXPos( const PlayerState* pPlayerState, int iColNum, float
if( fEffects[PlayerOptions::EFFECT_DIGITAL] != 0 )
fPixelOffsetFromCenter += (fEffects[PlayerOptions::EFFECT_DIGITAL] * ARROW_SIZE * 0.5f) *
round((fEffects[PlayerOptions::EFFECT_DIGITAL_STEPS]+1) * RageFastSin(
CalculateDigitalAngle(fYOffset,
fEffects[PlayerOptions::EFFECT_DIGITAL_OFFSET],
std::round((fEffects[PlayerOptions::EFFECT_DIGITAL_STEPS]+1) * RageFastSin(
CalculateDigitalAngle(fYOffset,
fEffects[PlayerOptions::EFFECT_DIGITAL_OFFSET],
fEffects[PlayerOptions::EFFECT_DIGITAL_PERIOD]) ) )/(fEffects[PlayerOptions::EFFECT_DIGITAL_STEPS]+1);
if( fEffects[PlayerOptions::EFFECT_TAN_DIGITAL] != 0 )
fPixelOffsetFromCenter += (fEffects[PlayerOptions::EFFECT_TAN_DIGITAL] * ARROW_SIZE * 0.5f) *
round((fEffects[PlayerOptions::EFFECT_TAN_DIGITAL_STEPS]+1) * SelectTanType(
CalculateDigitalAngle(fYOffset,
fEffects[PlayerOptions::EFFECT_TAN_DIGITAL_OFFSET],
std::round((fEffects[PlayerOptions::EFFECT_TAN_DIGITAL_STEPS]+1) * SelectTanType(
CalculateDigitalAngle(fYOffset,
fEffects[PlayerOptions::EFFECT_TAN_DIGITAL_OFFSET],
fEffects[PlayerOptions::EFFECT_TAN_DIGITAL_PERIOD]), curr_options->m_bCosecant ) )/(fEffects[PlayerOptions::EFFECT_TAN_DIGITAL_STEPS]+1);
if( fEffects[PlayerOptions::EFFECT_SQUARE] != 0 )
{
float fResult = RageSquare( (PI * (fYOffset+(1.0f*(fEffects[PlayerOptions::EFFECT_SQUARE_OFFSET]))) /
float fResult = RageSquare( (PI * (fYOffset+(1.0f*(fEffects[PlayerOptions::EFFECT_SQUARE_OFFSET]))) /
(ARROW_SIZE+(fEffects[PlayerOptions::EFFECT_SQUARE_PERIOD]*ARROW_SIZE))) );
fPixelOffsetFromCenter += (fEffects[PlayerOptions::EFFECT_SQUARE] * ARROW_SIZE * 0.5f) * fResult;
}
if( fEffects[PlayerOptions::EFFECT_BOUNCE] != 0 )
{
float fBounceAmt = fabsf( RageFastSin( ( (fYOffset + (1.0f * (fEffects[PlayerOptions::EFFECT_BOUNCE_OFFSET]) ) ) /
float fBounceAmt = std::abs( RageFastSin( ( (fYOffset + (1.0f * (fEffects[PlayerOptions::EFFECT_BOUNCE_OFFSET]) ) ) /
( 60 + (fEffects[PlayerOptions::EFFECT_BOUNCE_PERIOD]*60) ) ) ) );
fPixelOffsetFromCenter += fEffects[PlayerOptions::EFFECT_BOUNCE] * ARROW_SIZE * 0.5f * fBounceAmt;
}
@@ -828,7 +830,7 @@ float ArrowEffects::GetXPos( const PlayerState* pPlayerState, int iColNum, float
{
// find the middle, and split based on iColNum
// it's unknown if this will work for routine.
const int iMiddleColumn = static_cast<int>(floor(pStyle->m_iColsPerPlayer/2.0f));
const int iMiddleColumn = std::floor(pStyle->m_iColsPerPlayer/2.0f);
if( iColNum > iMiddleColumn-1 )
fPixelOffsetFromCenter += fEffects[PlayerOptions::EFFECT_XMODE]*-(fYOffset);
else
@@ -855,7 +857,7 @@ float ArrowEffects::GetXPos( const PlayerState* pPlayerState, int iColNum, float
{
// Allow Tiny to pull tracks together, but not to push them apart.
float fTinyPercent = fEffects[PlayerOptions::EFFECT_TINY];
fTinyPercent = std::min( powf(TINY_PERCENT_BASE, fTinyPercent), (float)TINY_PERCENT_GATE );
fTinyPercent = std::min( std::pow(TINY_PERCENT_BASE, fTinyPercent), (float)TINY_PERCENT_GATE );
fPixelOffsetFromCenter *= fTinyPercent;
}
@@ -892,7 +894,7 @@ float ArrowEffects::GetRotationY(const PlayerState* pPlayerState, float fYOffset
return fRotation;
}
float ArrowEffects::GetRotationZ( const PlayerState* pPlayerState, float fNoteBeat, bool bIsHoldHead, int iCol )
float ArrowEffects::GetRotationZ( const PlayerState* pPlayerState, float fNoteBeat, bool bIsHoldHead, int iCol )
{
const float* fEffects = curr_options->m_fEffects;
float fRotation = 0;
@@ -907,79 +909,79 @@ float ArrowEffects::GetRotationZ( const PlayerState* pPlayerState, float fNoteBe
const float fSongBeat = pPlayerState->m_Position.m_fSongBeatVisible;
float fDizzyRotation = fNoteBeat - fSongBeat;
fDizzyRotation *= fEffects[PlayerOptions::EFFECT_DIZZY];
fDizzyRotation = fmodf( fDizzyRotation, 2*PI );
fDizzyRotation = std::fmod( fDizzyRotation, 2*PI );
fDizzyRotation *= 180/PI;
fRotation += fDizzyRotation;
}
return fRotation;
}
float ArrowEffects::ReceptorGetRotationZ( const PlayerState* pPlayerState, int iCol )
float ArrowEffects::ReceptorGetRotationZ( const PlayerState* pPlayerState, int iCol )
{
const float* fEffects = curr_options->m_fEffects;
float fRotation = 0;
if( curr_options->m_fConfusionZ[iCol] != 0 )
fRotation += curr_options->m_fConfusionZ[iCol] * 180.0f/PI;
if( fEffects[PlayerOptions::EFFECT_CONFUSION_OFFSET] != 0 )
fRotation += fEffects[PlayerOptions::EFFECT_CONFUSION_OFFSET] * 180.0f/PI;
if( fEffects[PlayerOptions::EFFECT_CONFUSION] != 0 )
{
float fConfRotation = pPlayerState->m_Position.m_fSongBeatVisible;
fConfRotation *= fEffects[PlayerOptions::EFFECT_CONFUSION];
fConfRotation = fmodf( fConfRotation, 2*PI );
fConfRotation = std::fmod( fConfRotation, 2*PI );
fConfRotation *= -180/PI;
fRotation += fConfRotation;
}
return fRotation;
}
float ArrowEffects::ReceptorGetRotationX( const PlayerState* pPlayerState, int iCol )
float ArrowEffects::ReceptorGetRotationX( const PlayerState* pPlayerState, int iCol )
{
const float* fEffects = curr_options->m_fEffects;
float fRotation = 0;
if( curr_options->m_fConfusionX[iCol] != 0 )
fRotation += curr_options->m_fConfusionX[iCol] * 180.0f/PI;
if( fEffects[PlayerOptions::EFFECT_CONFUSION_X_OFFSET] != 0 )
fRotation += fEffects[PlayerOptions::EFFECT_CONFUSION_X_OFFSET] * 180.0f/PI;
if( fEffects[PlayerOptions::EFFECT_CONFUSION_X] != 0 )
{
float fConfRotation = pPlayerState->m_Position.m_fSongBeatVisible;
fConfRotation *= fEffects[PlayerOptions::EFFECT_CONFUSION_X];
fConfRotation = fmodf( fConfRotation, 2*PI );
fConfRotation = std::fmod( fConfRotation, 2*PI );
fConfRotation *= -180/PI;
fRotation += fConfRotation;
}
return fRotation;
}
float ArrowEffects::ReceptorGetRotationY( const PlayerState* pPlayerState, int iCol )
float ArrowEffects::ReceptorGetRotationY( const PlayerState* pPlayerState, int iCol )
{
const float* fEffects = curr_options->m_fEffects;
float fRotation = 0;
if( curr_options->m_fConfusionY[iCol] != 0 )
fRotation += curr_options->m_fConfusionY[iCol] * 180.0f/PI;
if( fEffects[PlayerOptions::EFFECT_CONFUSION_Y_OFFSET] != 0 )
fRotation += fEffects[PlayerOptions::EFFECT_CONFUSION_Y_OFFSET] * 180.0f/PI;
if( fEffects[PlayerOptions::EFFECT_CONFUSION_Y] != 0 )
{
float fConfRotation = pPlayerState->m_Position.m_fSongBeatVisible;
fConfRotation *= fEffects[PlayerOptions::EFFECT_CONFUSION_Y];
fConfRotation = fmodf( fConfRotation, 2*PI );
fConfRotation = std::fmod( fConfRotation, 2*PI );
fConfRotation *= -180/PI;
fRotation += fConfRotation;
}
return fRotation;
}
@@ -1031,7 +1033,7 @@ static float GetHiddenSudden()
//
// -gray arrows-
//
//
// ...invisible...
// -hidden end line-
// -hidden start line-
@@ -1079,8 +1081,8 @@ float ArrowGetPercentVisible(float fYPosWithoutReverse, int iCol, float fYOffset
fYPos = fYOffset;
else
fYPos = fYPosWithoutReverse;
if( fYPos < 0 && curr_options->m_bStealthPastReceptors == false) // past Gray Arrows
return 1; // totally visible
@@ -1115,7 +1117,7 @@ float ArrowGetPercentVisible(float fYPosWithoutReverse, int iCol, float fYOffset
if( fAppearances[PlayerOptions::APPEARANCE_RANDOMVANISH] != 0 )
{
const float fRealFadeDist = 80;
fVisibleAdjust += SCALE( fabsf(fDistFromCenterLine), fRealFadeDist, 2*fRealFadeDist, -1, 0 )
fVisibleAdjust += SCALE( std::abs(fDistFromCenterLine), fRealFadeDist, 2*fRealFadeDist, -1, 0 )
* fAppearances[PlayerOptions::APPEARANCE_RANDOMVANISH];
}
@@ -1152,7 +1154,7 @@ float ArrowEffects::GetGlow( const PlayerState* pPlayerState, int iCol, float fY
if( fPercentFadeToFail != -1 )
fPercentVisible = 1 - fPercentFadeToFail;
const float fDistFromHalf = fabsf( fPercentVisible - 0.5f );
const float fDistFromHalf = std::abs( fPercentVisible - 0.5f );
return SCALE( fDistFromHalf, 0, 0.5f, 1.3f, 0 );
}
@@ -1175,7 +1177,7 @@ float ArrowEffects::GetZPos( const PlayerState* pPlayerState, int iCol, float fY
float fZPos=0;
const float* fEffects = curr_options->m_fEffects;
const Style* pStyle = GAMESTATE->GetCurrentStyle(pPlayerState->m_PlayerNumber);
// TODO: Don't index by PlayerNumber.
const Style::ColumnInfo* pCols = pStyle->m_ColumnInfo[pPlayerState->m_PlayerNumber];
PerPlayerData &data = g_EffectData[pPlayerState->m_PlayerNumber];
@@ -1197,7 +1199,7 @@ float ArrowEffects::GetZPos( const PlayerState* pPlayerState, int iCol, float fY
fEffects[PlayerOptions::EFFECT_TAN_TORNADO_Z_PERIOD],
pCols, pPlayerState->m_NotefieldZoom, data, fYOffset, true);
}
if( fEffects[PlayerOptions::EFFECT_BUMPY] != 0 )
fZPos += fEffects[PlayerOptions::EFFECT_BUMPY] * 40*RageFastSin(
CalculateBumpyAngle(fYOffset,
@@ -1209,29 +1211,29 @@ float ArrowEffects::GetZPos( const PlayerState* pPlayerState, int iCol, float fY
CalculateBumpyAngle(fYOffset,
fEffects[PlayerOptions::EFFECT_BUMPY_OFFSET],
fEffects[PlayerOptions::EFFECT_BUMPY_PERIOD]) );
if( fEffects[PlayerOptions::EFFECT_TAN_BUMPY] != 0 )
fZPos += fEffects[PlayerOptions::EFFECT_TAN_BUMPY] * 40*SelectTanType(
CalculateBumpyAngle(fYOffset,
fEffects[PlayerOptions::EFFECT_TAN_BUMPY_OFFSET],
fEffects[PlayerOptions::EFFECT_TAN_BUMPY_PERIOD]), curr_options->m_bCosecant );
if( fEffects[PlayerOptions::EFFECT_ZIGZAG_Z] != 0 )
{
float fResult = RageTriangle( (PI * (1/(fEffects[PlayerOptions::EFFECT_ZIGZAG_Z_PERIOD]+1)) *
float fResult = RageTriangle( (PI * (1/(fEffects[PlayerOptions::EFFECT_ZIGZAG_Z_PERIOD]+1)) *
((fYOffset+(100.0f*(fEffects[PlayerOptions::EFFECT_ZIGZAG_Z_OFFSET])))/ARROW_SIZE) ) );
fZPos += (fEffects[PlayerOptions::EFFECT_ZIGZAG_Z]*ARROW_SIZE/2) * fResult;
}
if( fEffects[PlayerOptions::EFFECT_SAWTOOTH_Z] != 0 )
fZPos += (fEffects[PlayerOptions::EFFECT_SAWTOOTH_Z]*ARROW_SIZE) *
((0.5f/(fEffects[PlayerOptions::EFFECT_SAWTOOTH_Z_PERIOD]+1)*fYOffset)/ARROW_SIZE -
floor((0.5f/(fEffects[PlayerOptions::EFFECT_SAWTOOTH_Z_PERIOD]+1)*fYOffset)/ARROW_SIZE));
fZPos += (fEffects[PlayerOptions::EFFECT_SAWTOOTH_Z]*ARROW_SIZE) *
((0.5f/(fEffects[PlayerOptions::EFFECT_SAWTOOTH_Z_PERIOD]+1)*fYOffset)/ARROW_SIZE -
std::floor((0.5f/(fEffects[PlayerOptions::EFFECT_SAWTOOTH_Z_PERIOD]+1)*fYOffset)/ARROW_SIZE));
if( fEffects[PlayerOptions::EFFECT_PARABOLA_Z] != 0 )
fZPos += fEffects[PlayerOptions::EFFECT_PARABOLA_Z] * (fYOffset/ARROW_SIZE) * (fYOffset/ARROW_SIZE);
if( fEffects[PlayerOptions::EFFECT_ATTENUATE_Z] != 0 )
{
const float fXOffset = pCols[iCol].fXOffset;
@@ -1239,14 +1241,14 @@ float ArrowEffects::GetZPos( const PlayerState* pPlayerState, int iCol, float fY
}
if( fEffects[PlayerOptions::EFFECT_DRUNK_Z] != 0 )
fZPos += fEffects[PlayerOptions::EFFECT_DRUNK_Z] *
( RageFastCos( CalculateDrunkAngle(fEffects[PlayerOptions::EFFECT_DRUNK_Z_SPEED], iCol,
fZPos += fEffects[PlayerOptions::EFFECT_DRUNK_Z] *
( RageFastCos( CalculateDrunkAngle(fEffects[PlayerOptions::EFFECT_DRUNK_Z_SPEED], iCol,
fEffects[PlayerOptions::EFFECT_DRUNK_Z_OFFSET], DRUNK_Z_COLUMN_FREQUENCY,
fYOffset, fEffects[PlayerOptions::EFFECT_DRUNK_Z_PERIOD],
DRUNK_Z_OFFSET_FREQUENCY) ) * ARROW_SIZE*DRUNK_Z_ARROW_MAGNITUDE );
if( fEffects[PlayerOptions::EFFECT_TAN_DRUNK_Z] != 0 )
fZPos += fEffects[PlayerOptions::EFFECT_TAN_DRUNK_Z] *
fZPos += fEffects[PlayerOptions::EFFECT_TAN_DRUNK_Z] *
( SelectTanType( CalculateDrunkAngle(fEffects[PlayerOptions::EFFECT_TAN_DRUNK_Z_SPEED],
iCol, fEffects[PlayerOptions::EFFECT_TAN_DRUNK_Z_OFFSET],
DRUNK_Z_COLUMN_FREQUENCY, fYOffset,
@@ -1259,34 +1261,34 @@ float ArrowEffects::GetZPos( const PlayerState* pPlayerState, int iCol, float fY
const float fShift = data.m_fBeatFactor[dim_z]*RageFastSin( fYOffset / ((fEffects[PlayerOptions::EFFECT_BEAT_Z_PERIOD]*BEAT_Z_OFFSET_HEIGHT)+BEAT_Z_OFFSET_HEIGHT) + PI/BEAT_Z_PI_HEIGHT );
fZPos += fEffects[PlayerOptions::EFFECT_BEAT_Z] * fShift;
}
if( fEffects[PlayerOptions::EFFECT_DIGITAL_Z] != 0 )
fZPos += (fEffects[PlayerOptions::EFFECT_DIGITAL_Z] * ARROW_SIZE * 0.5f) *
round((fEffects[PlayerOptions::EFFECT_DIGITAL_Z_STEPS]+1) * RageFastSin(
CalculateDigitalAngle(fYOffset,
fEffects[PlayerOptions::EFFECT_DIGITAL_Z_OFFSET],
std::round((fEffects[PlayerOptions::EFFECT_DIGITAL_Z_STEPS]+1) * RageFastSin(
CalculateDigitalAngle(fYOffset,
fEffects[PlayerOptions::EFFECT_DIGITAL_Z_OFFSET],
fEffects[PlayerOptions::EFFECT_DIGITAL_Z_PERIOD]) ) ) /(fEffects[PlayerOptions::EFFECT_DIGITAL_Z_STEPS]+1);
if( fEffects[PlayerOptions::EFFECT_TAN_DIGITAL_Z] != 0 )
fZPos += (fEffects[PlayerOptions::EFFECT_TAN_DIGITAL_Z] * ARROW_SIZE * 0.5f) *
round((fEffects[PlayerOptions::EFFECT_TAN_DIGITAL_Z_STEPS]+1) * SelectTanType(
CalculateDigitalAngle(fYOffset,
fEffects[PlayerOptions::EFFECT_TAN_DIGITAL_Z_OFFSET],
std::round((fEffects[PlayerOptions::EFFECT_TAN_DIGITAL_Z_STEPS]+1) * SelectTanType(
CalculateDigitalAngle(fYOffset,
fEffects[PlayerOptions::EFFECT_TAN_DIGITAL_Z_OFFSET],
fEffects[PlayerOptions::EFFECT_TAN_DIGITAL_Z_PERIOD]), curr_options->m_bCosecant ) ) /(fEffects[PlayerOptions::EFFECT_TAN_DIGITAL_Z_STEPS]+1);
if( fEffects[PlayerOptions::EFFECT_SQUARE_Z] != 0 )
{
float fResult = RageSquare( (PI * (fYOffset+(1.0f*(fEffects[PlayerOptions::EFFECT_SQUARE_Z_OFFSET]))) /
float fResult = RageSquare( (PI * (fYOffset+(1.0f*(fEffects[PlayerOptions::EFFECT_SQUARE_Z_OFFSET]))) /
(ARROW_SIZE+(fEffects[PlayerOptions::EFFECT_SQUARE_Z_PERIOD]*ARROW_SIZE))) );
fZPos += (fEffects[PlayerOptions::EFFECT_SQUARE_Z] * ARROW_SIZE * 0.5f) * fResult;
}
if( fEffects[PlayerOptions::EFFECT_BOUNCE_Z] != 0 )
{
float fBounceAmt = fabsf( RageFastSin( ( (fYOffset + (1.0f * (fEffects[PlayerOptions::EFFECT_BOUNCE_Z_OFFSET]) ) ) /
float fBounceAmt = std::abs( RageFastSin( ( (fYOffset + (1.0f * (fEffects[PlayerOptions::EFFECT_BOUNCE_Z_OFFSET]) ) ) /
( 60 + (fEffects[PlayerOptions::EFFECT_BOUNCE_Z_PERIOD]*60) ) ) ) );
fZPos += fEffects[PlayerOptions::EFFECT_BOUNCE_Z] * ARROW_SIZE * 0.5f * fBounceAmt;
}
@@ -1338,18 +1340,18 @@ float ArrowEffects::GetZoom( const PlayerState* pPlayerState, float fYOffset, in
// calculates a zoom factor to apply to the notefield and puts it in the
// PlayerState. -Kyz
fZoom*= pPlayerState->m_NotefieldZoom;
fZoom = GetZoomVariable( fYOffset, iCol, fZoom);
float fTinyPercent = curr_options->m_fEffects[PlayerOptions::EFFECT_TINY];
if( fTinyPercent != 0 )
{
fTinyPercent = powf( 0.5f, fTinyPercent );
fTinyPercent = std::pow( 0.5f, fTinyPercent );
fZoom *= fTinyPercent;
}
if( curr_options->m_fTiny[iCol] != 0 )
{
fTinyPercent = powf( 0.5f, curr_options->m_fTiny[iCol] );
fTinyPercent = std::pow( 0.5f, curr_options->m_fTiny[iCol] );
fZoom *= fTinyPercent;
}
return fZoom;
@@ -1361,12 +1363,12 @@ float ArrowEffects::GetZoomVariable( float fYOffset, int iCol, float fCurZoom )
if( curr_options->m_fEffects[PlayerOptions::EFFECT_PULSE_INNER] != 0 || curr_options->m_fEffects[PlayerOptions::EFFECT_PULSE_OUTER] != 0 )
{
float sine = RageFastSin(((fYOffset+(100.0f*(curr_options->m_fEffects[PlayerOptions::EFFECT_PULSE_OFFSET])))/(0.4f*(ARROW_SIZE+(curr_options->m_fEffects[PlayerOptions::EFFECT_PULSE_PERIOD]*ARROW_SIZE)))));
fZoom *= (sine*(curr_options->m_fEffects[PlayerOptions::EFFECT_PULSE_OUTER]*0.5f))+GetPulseInner();
}
if( curr_options->m_fEffects[PlayerOptions::EFFECT_SHRINK_TO_MULT] !=0 && fYOffset >= 0 )
fZoom *= 1/(1+(fYOffset*(curr_options->m_fEffects[PlayerOptions::EFFECT_SHRINK_TO_MULT]/100.0f)));
if( curr_options->m_fEffects[PlayerOptions::EFFECT_SHRINK_TO_LINEAR] !=0 && fYOffset >= 0 )
fZoom += fYOffset*(0.5f*curr_options->m_fEffects[PlayerOptions::EFFECT_SHRINK_TO_LINEAR]/ARROW_SIZE);
return fZoom;
@@ -1423,7 +1425,7 @@ ThemeMetric<float> FADE_BEFORE_TARGETS_PERCENT( "NoteField", "FadeBeforeTargetsP
ThemeMetric<float> DRAW_DISTANCE_BEFORE_TARGET_PIXELS( "Player", "DrawDistanceBeforeTargetsPixels" );
ThemeMetric<float> GRAY_ARROWS_Y_STANDARD( "Player", "ReceptorArrowsYStandard" );
ThemeMetric<float> GRAY_ARROWS_Y_REVERSE( "Player", "ReceptorArrowsYReverse" );
// lua start
#include "LuaBinding.h"
@@ -1442,7 +1444,7 @@ namespace
}
return fYReverseOffsetPixels;
}
// ( PlayerState ps, int iCol, float fNoteBeat )
int GetYOffset( lua_State *L )
{
@@ -1564,14 +1566,14 @@ namespace
return 1;
}
//( PlayerState ps, int iCol, float fYOffset, float fPercentFadeToFail, float fYReverseOffsetPixels, float fDrawDistanceBeforeTargetsPixels, float fFadeInPercentOfDrawFar )
int GetGlow( lua_State *L )
{
PlayerState *ps = Luna<PlayerState>::check( L, 1 );
ArrowEffects::SetCurrentOptions(&ps->m_PlayerOptions.GetCurrent());
// Provide reasonable default values.
float fPercentFadeToFail = -1; //
float fPercentFadeToFail = -1; //
float fYReverseOffsetPixels = YReverseOffset( L, 5 );
float fDrawDistanceBeforeTargetsPixels = DRAW_DISTANCE_BEFORE_TARGET_PIXELS;
float fFadeInPercentOfDrawFar = FADE_BEFORE_TARGETS_PERCENT;
@@ -1590,7 +1592,7 @@ namespace
lua_pushnumber( L, ArrowEffects::GetGlow(ps, IArg(2)-1, FArg(3), fPercentFadeToFail, fYReverseOffsetPixels, fDrawDistanceBeforeTargetsPixels, fFadeInPercentOfDrawFar ) );
return 1;
}
// ( PlayerState ps, float fNoteBeat )
int GetBrightness( lua_State *L )
{
@@ -1608,7 +1610,7 @@ namespace
lua_pushboolean(L, ArrowEffects::NeedZBuffer());
return 1;
}
// ( PlayerState ps, float fYOffset, int iCol )
int GetZoom( lua_State *L )
{
@@ -1617,7 +1619,7 @@ namespace
lua_pushnumber( L, ArrowEffects::GetZoom( ps, FArg(2), IArg(3)-1 ) );
return 1;
}
// ( PlayerState ps, float fYOffset, fOverlappedTime )
int GetFrameWidthScale( lua_State *L )
{
@@ -1661,7 +1663,7 @@ LUA_REGISTER_NAMESPACE( ArrowEffects )
/*
* (c) 2001-2004 Chris Danford
* All rights reserved.
*
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
@@ -1671,7 +1673,7 @@ LUA_REGISTER_NAMESPACE( ArrowEffects )
* copyright notice(s) and this permission notice appear in all copies of
* the Software and that both the above copyright notice(s) and this
* permission notice appear in supporting documentation.
*
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
+8 -7
View File
@@ -3,15 +3,16 @@
#include "GameState.h"
#include "RageUtil.h"
#include "Song.h"
#include "PlayerOptions.h"
#include "PlayerState.h"
#include <cmath>
void Attack::GetAttackBeats( const Song *pSong, float &fStartBeat, float &fEndBeat ) const
{
ASSERT( pSong != nullptr );
ASSERT_M( fStartSecond >= 0, ssprintf("StartSecond: %f",fStartSecond) );
const TimingData &timing = pSong->m_SongTiming;
fStartBeat = timing.GetBeatFromElapsedTime( fStartSecond );
fEndBeat = timing.GetBeatFromElapsedTime( fStartSecond+fSecsRemaining );
@@ -34,13 +35,13 @@ void Attack::GetRealtimeAttackBeats( const Song *pSong, const PlayerState* pPlay
/* If reasonable, push the attack forward 8 beats so that notes on screen don't change suddenly. */
fStartBeat = std::min( GAMESTATE->m_Position.m_fSongBeat+8, pPlayerState->m_fLastDrawnBeat );
fStartBeat = truncf(fStartBeat)+1;
fStartBeat = std::trunc(fStartBeat) + 1;
const TimingData &timing = pSong->m_SongTiming;
const float lStartSecond = timing.GetElapsedTimeFromBeat( fStartBeat );
const float fEndSecond = lStartSecond + fSecsRemaining;
fEndBeat = timing.GetBeatFromElapsedTime( fEndSecond );
fEndBeat = truncf(fEndBeat)+1;
fEndBeat = std::trunc(fEndBeat) + 1;
// loading the course should have caught this.
ASSERT_M( fEndBeat >= fStartBeat, ssprintf("EndBeat %f >= StartBeat %f", fEndBeat, fStartBeat) );
@@ -49,7 +50,7 @@ void Attack::GetRealtimeAttackBeats( const Song *pSong, const PlayerState* pPlay
bool Attack::operator== ( const Attack &rhs ) const
{
#define EQUAL(a) (a==rhs.a)
return
return
EQUAL(level) &&
EQUAL(fStartSecond) &&
EQUAL(fSecsRemaining) &&
@@ -118,7 +119,7 @@ void AttackArray::UpdateStartTimes(float delta)
/*
* (c) 2003-2004 Chris Danford
* All rights reserved.
*
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
@@ -128,7 +129,7 @@ void AttackArray::UpdateStartTimes(float delta)
* copyright notice(s) and this permission notice appear in all copies of
* the Software and that both the above copyright notice(s) and this
* permission notice appear in supporting documentation.
*
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
+2 -2
View File
@@ -322,8 +322,8 @@ void AutoKeysounds::Update( float fDelta )
iRowNow = std::max( 0, iRowNow );
static int iRowLastCrossed = 0;
float fBeatLast = roundf(NoteRowToBeat(iRowLastCrossed));
float fBeatNow = roundf(NoteRowToBeat(iRowNow));
float fBeatLast = std::round(NoteRowToBeat(iRowLastCrossed));
float fBeatNow = std::round(NoteRowToBeat(iRowNow));
bCrossedABeat = fBeatLast != fBeatNow;
+5 -5
View File
@@ -107,14 +107,14 @@ void BGAnimation::LoadFromAniDir( const RString &_sAniDir )
// This is a 3.9-style BGAnimation (using .ini)
IniFile ini;
ini.ReadFile( sPathToIni );
AddLayersFromAniDir( sAniDir, &ini ); // TODO: Check for circular load
XNode* pBGAnimation = ini.GetChild( "BGAnimation" );
XNode dummy( "BGAnimation" );
if( pBGAnimation == nullptr )
pBGAnimation = &dummy;
LoadFromNode( pBGAnimation );
}
else // We don't officially support .ini files anymore.
@@ -180,7 +180,7 @@ void BGAnimation::LoadFromNode( const XNode* pNode )
/*
* (c) 2001-2004 Ben Nordstrom, Chris Danford
* All rights reserved.
*
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
@@ -190,7 +190,7 @@ void BGAnimation::LoadFromNode( const XNode* pNode )
* copyright notice(s) and this permission notice appear in all copies of
* the Software and that both the above copyright notice(s) and this
* permission notice appear in supporting documentation.
*
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
+17 -15
View File
@@ -14,6 +14,8 @@
#include "AutoActor.h"
#include "ThemeManager.h"
#include <cmath>
const float PARTICLE_SPEED = 300;
@@ -72,7 +74,7 @@ BGAnimationLayer::~BGAnimationLayer()
void BGAnimationLayer::LoadFromAniLayerFile( const RString& sPath )
{
/* Generic BGAs are new. Animation directories with no INI are old and obsolete.
/* Generic BGAs are new. Animation directories with no INI are old and obsolete.
* Don't combine them. */
RString lcPath = sPath;
lcPath.MakeLower();
@@ -404,16 +406,16 @@ void BGAnimationLayer::LoadFromNode( const XNode* pNode )
}
else if( StringToInt(type) == 1 )
{
m_Type = TYPE_SPRITE;
bStretch = true;
m_Type = TYPE_SPRITE;
bStretch = true;
}
else if( StringToInt(type) == 2 )
{
m_Type = TYPE_PARTICLES;
m_Type = TYPE_PARTICLES;
}
else if( StringToInt(type) == 3 )
{
m_Type = TYPE_TILES;
m_Type = TYPE_TILES;
}
else
{
@@ -488,7 +490,7 @@ void BGAnimationLayer::LoadFromNode( const XNode* pNode )
pActor->SetXY( randomf(float(FullScreenRectF.left),float(FullScreenRectF.right)),
randomf(float(FullScreenRectF.top),float(FullScreenRectF.bottom)) );
pActor->SetZoom( randomf(fZoomMin,fZoomMax) );
m_vParticleVelocity.push_back( RageVector3(
m_vParticleVelocity.push_back( RageVector3(
randomf(fVelocityXMin,fVelocityXMax),
randomf(fVelocityYMin,fVelocityYMax),
randomf(fVelocityZMin,fVelocityZMax) ) );
@@ -573,28 +575,28 @@ void BGAnimationLayer::UpdateInternal( float fDeltaTime )
pActor->SetZ( pActor->GetZ() + fDeltaTime*vel.z );
if( m_bParticlesBounce )
{
if( HitGuardRailLeft(pActor) )
if( HitGuardRailLeft(pActor) )
{
vel.x *= -1;
pActor->SetX( GetGuardRailLeft(pActor) );
}
if( HitGuardRailRight(pActor) )
if( HitGuardRailRight(pActor) )
{
vel.x *= -1;
pActor->SetX( GetGuardRailRight(pActor) );
}
if( HitGuardRailTop(pActor) )
if( HitGuardRailTop(pActor) )
{
vel.y *= -1;
pActor->SetY( GetGuardRailTop(pActor) );
}
if( HitGuardRailBottom(pActor) )
if( HitGuardRailBottom(pActor) )
{
vel.y *= -1;
pActor->SetY( GetGuardRailBottom(pActor) );
}
}
else // !m_bParticlesBounce
else // !m_bParticlesBounce
{
if( vel.x<0 && IsOffScreenLeft(pActor) )
pActor->SetX( GetOffScreenRight(pActor) );
@@ -627,8 +629,8 @@ void BGAnimationLayer::UpdateInternal( float fDeltaTime )
fX += m_fTilesSpacingX/2;
fY += m_fTilesSpacingY/2;
fX = fmodf( fX, fTotalWidth );
fY = fmodf( fY, fTotalHeight );
fX = std::fmod( fX, fTotalWidth );
fY = std::fmod( fY, fTotalHeight );
if( fX < 0 ) fX += fTotalWidth;
if( fY < 0 ) fY += fTotalHeight;
@@ -650,7 +652,7 @@ void BGAnimationLayer::UpdateInternal( float fDeltaTime )
/*
* (c) 2001-2004 Ben Nordstrom, Chris Danford, Glenn Maynard
* All rights reserved.
*
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
@@ -660,7 +662,7 @@ void BGAnimationLayer::UpdateInternal( float fDeltaTime )
* copyright notice(s) and this permission notice appear in all copies of
* the Software and that both the above copyright notice(s) and this
* permission notice appear in supporting documentation.
*
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
+11 -10
View File
@@ -11,6 +11,7 @@
#include "Song.h"
#include "Steps.h"
#include <cmath>
#include <limits.h>
REGISTER_ACTOR_CLASS( BPMDisplay );
@@ -56,9 +57,9 @@ float BPMDisplay::GetActiveBPM() const
return m_fBPMTo + (m_fBPMFrom-m_fBPMTo)*m_fPercentInState;
}
void BPMDisplay::Update( float fDeltaTime )
{
BitmapText::Update( fDeltaTime );
void BPMDisplay::Update( float fDeltaTime )
{
BitmapText::Update( fDeltaTime );
if( !(bool)CYCLE )
return;
@@ -117,8 +118,8 @@ void BPMDisplay::SetBPMRange( const DisplayBpms &bpms )
int MaxBPM = INT_MIN;
for( unsigned i = 0; i < BPMS.size(); ++i )
{
MinBPM = std::min( MinBPM, (int) lrintf(BPMS[i]) );
MaxBPM = std::max( MaxBPM, (int) lrintf(BPMS[i]) );
MinBPM = std::min( MinBPM, static_cast<int>(std::lrint(BPMS[i])) );
MaxBPM = std::max( MaxBPM, static_cast<int>(std::lrint(BPMS[i])) );
}
if( MinBPM == MaxBPM )
{
@@ -173,7 +174,7 @@ void BPMDisplay::CycleRandomly()
void BPMDisplay::NoBPM()
{
m_BPMS.clear();
SetText( NO_BPM_TEXT );
SetText( NO_BPM_TEXT );
RunCommands( SET_NO_BPM_COMMAND );
}
@@ -276,7 +277,7 @@ class SongBPMDisplay: public BPMDisplay
public:
SongBPMDisplay();
virtual SongBPMDisplay *Copy() const;
virtual void Update( float fDeltaTime );
virtual void Update( float fDeltaTime );
private:
float m_fLastGameStateBPM;
@@ -288,7 +289,7 @@ SongBPMDisplay::SongBPMDisplay()
m_fLastGameStateBPM = 0;
}
void SongBPMDisplay::Update( float fDeltaTime )
void SongBPMDisplay::Update( float fDeltaTime )
{
float fGameStateBPM = GAMESTATE->m_Position.m_fCurBPS * 60.0f;
if( m_fLastGameStateBPM != fGameStateBPM )
@@ -355,7 +356,7 @@ LUA_REGISTER_DERIVED_CLASS( BPMDisplay, BitmapText )
/*
* (c) 2001-2002 Chris Danford
* All rights reserved.
*
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
@@ -365,7 +366,7 @@ LUA_REGISTER_DERIVED_CLASS( BPMDisplay, BitmapText )
* copyright notice(s) and this permission notice appear in all copies of
* the Software and that both the above copyright notice(s) and this
* permission notice appear in supporting documentation.
*
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
+2 -1
View File
@@ -17,13 +17,14 @@
#include "ThemeMetric.h"
#include "PlayerState.h"
#include "ActorUtil.h"
#include <float.h>
#include "XmlFile.h"
#include "XmlFileUtil.h"
#include "BackgroundUtil.h"
#include "Song.h"
#include "AutoActor.h"
#include <cfloat>
static ThemeMetric<float> LEFT_EDGE ("Background","LeftEdge");
static ThemeMetric<float> TOP_EDGE ("Background","TopEdge");
static ThemeMetric<float> RIGHT_EDGE ("Background","RightEdge");
+21 -19
View File
@@ -10,6 +10,8 @@
#include "ActorUtil.h"
#include "LuaBinding.h"
#include <cmath>
REGISTER_ACTOR_CLASS( BitmapText );
@@ -19,7 +21,7 @@ REGISTER_ACTOR_CLASS( BitmapText );
*
* Better, we could go all the way, drop all of the actor-specific font aliases,
* and do "font=header2;valign=top;...". */
/* XXX: Changing a whole array of diffuse colors every frame (several times) is
* a waste, when we're usually setting them all to the same value. Rainbow and
* fading are annoying to optimize, but rarely used. Iterating over every
@@ -277,7 +279,7 @@ void BitmapText::BuildChars()
m_size.y += iPadding * int(m_wTextLines.size()-1);
// the top position of the first row of characters
int iY = lrintf(-m_size.y/2.0f);
int iY = std::lrint(-m_size.y/2.0f);
for( unsigned i=0; i<m_wTextLines.size(); i++ ) // foreach line
{
@@ -289,7 +291,7 @@ void BitmapText::BuildChars()
const int iLineWidth = m_iLineWidths[i];
float fX = SCALE( m_fHorizAlign, 0.0f, 1.0f, -m_size.x/2.0f, +m_size.x/2.0f - iLineWidth );
int iX = lrintf( fX );
int iX = std::lrint( fX );
for( unsigned j = 0; j < sLine.size(); ++j )
{
@@ -326,7 +328,7 @@ void BitmapText::BuildChars()
if( m_bUsingDistortion )
{
int iSeed = lrintf( RageTimer::GetTimeSinceStartFast()*500000.0f );
int iSeed = std::lrint( RageTimer::GetTimeSinceStartFast()*500000.0f );
RandomGen rnd( iSeed );
for(unsigned int i= 0; i < m_aVertices.size(); i+=4)
{
@@ -344,13 +346,13 @@ void BitmapText::BuildChars()
void BitmapText::DrawChars( bool bUseStrokeTexture )
{
// bail if cropped all the way
if( m_pTempState->crop.left + m_pTempState->crop.right >= 1 ||
m_pTempState->crop.top + m_pTempState->crop.bottom >= 1 )
return;
if( m_pTempState->crop.left + m_pTempState->crop.right >= 1 ||
m_pTempState->crop.top + m_pTempState->crop.bottom >= 1 )
return;
const int iNumGlyphs = m_vpFontPageTextures.size();
int iStartGlyph = lrintf( SCALE( m_pTempState->crop.left, 0.f, 1.f, 0, (float) iNumGlyphs ) );
int iEndGlyph = lrintf( SCALE( m_pTempState->crop.right, 0.f, 1.f, (float) iNumGlyphs, 0 ) );
int iStartGlyph = std::lrint( SCALE( m_pTempState->crop.left, 0.f, 1.f, 0, (float) iNumGlyphs ) );
int iEndGlyph = std::lrint( SCALE( m_pTempState->crop.right, 0.f, 1.f, (float) iNumGlyphs, 0 ) );
iStartGlyph = clamp( iStartGlyph, 0, iNumGlyphs );
iEndGlyph = clamp( iEndGlyph, 0, iNumGlyphs );
@@ -414,7 +416,7 @@ void BitmapText::DrawChars( bool bUseStrokeTexture )
m_aVertices[i+j].c.a = (unsigned char)( m_aVertices[i+j].c.a * fAlpha );
}
}
bool bDistanceField = m_pFont->IsDistanceField();
if( bDistanceField )
DISPLAY->SetEffectMode( EffectMode_DistanceField );
@@ -435,10 +437,10 @@ void BitmapText::DrawChars( bool bUseStrokeTexture )
DISPLAY->SetTexture( TextureUnit_1, m_vpFontPageTextures[start]->m_pTextureMain->GetTexHandle() );
// Don't bother setting texture render states for text. We never go outside of 0..1.
/* We should call SetTextureRenderStates because it does more than just setting
* the texture wrapping state. If setting the wrapping state is found to be slow,
/* We should call SetTextureRenderStates because it does more than just setting
* the texture wrapping state. If setting the wrapping state is found to be slow,
* there should probably be a "don't care" texture wrapping mode set in Actor. -Chris */
// This is SLOW. We need to do something else about this. -Colby
//Actor::SetTextureRenderStates();
@@ -612,7 +614,7 @@ void BitmapText::UpdateBaseZoom()
} \
if(dimension != 0) \
{ \
const float zoom= fmin(1, dimension_max / dimension); \
const float zoom= std::fmin(1, dimension_max / dimension); \
base_zoom_set(zoom); \
} \
}
@@ -766,7 +768,7 @@ void BitmapText::DrawPrimitives()
std::vector<RageVector3> vGlyphJitter;
if( m_bJitter )
{
int iSeed = lrintf( RageTimer::GetTimeSinceStartFast()*8 );
int iSeed = std::lrint( RageTimer::GetTimeSinceStartFast()*8 );
RandomGen rnd( iSeed );
for( unsigned i=0; i<m_aVertices.size(); i+=4 )
@@ -877,7 +879,7 @@ void BitmapText::AddAttribute( size_t iPos, const Attribute &attr )
// Fixup position for new lines.
int iLines = 0;
size_t iAdjustedPos = iPos;
for (std::wstring const & line : m_wTextLines)
{
size_t length = line.length();
@@ -940,7 +942,7 @@ void BitmapText::Attribute::FromStack( lua_State *L, int iPos )
// lua start
#include "FontCharAliases.h"
/** @brief Allow Lua to have access to the BitmapText. */
/** @brief Allow Lua to have access to the BitmapText. */
class LunaBitmapText: public Luna<BitmapText>
{
public:
@@ -1032,7 +1034,7 @@ LUA_REGISTER_DERIVED_CLASS( BitmapText, Actor )
/*
* (c) 2003-2007 Chris Danford, Charles Lohr, Steve Checkoway
* All rights reserved.
*
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
@@ -1042,7 +1044,7 @@ LUA_REGISTER_DERIVED_CLASS( BitmapText, Actor )
* copyright notice(s) and this permission notice appear in all copies of
* the Software and that both the above copyright notice(s) and this
* permission notice appear in supporting documentation.
*
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
+2 -2
View File
@@ -226,7 +226,7 @@ elseif(APPLE)
"${SM_ROOT_DIR}/Songs"
"${SM_ROOT_DIR}/Themes"
)
target_sources("${SM_EXE_NAME}" PUBLIC ${APPLE_BUNDLE_RESOURCES})
set_source_files_properties(${APPLE_BUNDLE_RESOURCES} PROPERTIES MACOSX_PACKAGE_LOCATION Resources)
@@ -433,7 +433,7 @@ else() # Unix / Linux TODO: Remember to find and locate the zip archive files.
if(X11_FOUND)
list(APPEND SMDATA_LINK_LIB ${X11_LIBRARIES})
endif()
if(LIBXTST_FOUND)
list(APPEND SMDATA_LINK_LIB ${LIBXTST_LIBRARY})
endif()
+6 -5
View File
@@ -14,7 +14,8 @@
#include "CourseWriterCRS.h"
#include "RageUtil.h"
#include "CourseUtil.h"
#include <float.h>
#include <cfloat>
/** @brief Edit courses can only be so big before they are rejected. */
const int MAX_EDIT_COURSE_SIZE_BYTES = 32*1024; // 32KB
@@ -417,7 +418,7 @@ bool CourseLoaderCRS::LoadFromCRSFile( const RString &_sPath, Course &out )
bUseCache = false;
// XXX: if !FastLoad, regen cache if the used songs have changed
if( !PREFSMAN->m_bFastLoad && GetHashForFile(out.m_sPath) != uHash )
bUseCache = false; // this cache is out of date
bUseCache = false; // this cache is out of date
}
if( bUseCache )
@@ -437,7 +438,7 @@ bool CourseLoaderCRS::LoadFromCRSFile( const RString &_sPath, Course &out )
LOG->UserLog( "Course file", sPath, "couldn't be opened: %s.", msd.GetError().c_str() );
return false;
}
if( !LoadFromMsd(sPath, msd, out, bUseCache) )
return false;
@@ -502,7 +503,7 @@ bool CourseLoaderCRS::LoadEditFromBuffer( const RString &sBuffer, const RString
/*
* (c) 2001-2004 Chris Danford, Glenn Maynard
* All rights reserved.
*
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
@@ -512,7 +513,7 @@ bool CourseLoaderCRS::LoadEditFromBuffer( const RString &sBuffer, const RString
* copyright notice(s) and this permission notice appear in all copies of
* the Software and that both the above copyright notice(s) and this
* permission notice appear in supporting documentation.
*
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
+5 -3
View File
@@ -7,6 +7,8 @@
#include "RageUtil.h"
#include "LuaBinding.h"
#include <cmath>
DynamicActorScroller *DynamicActorScroller::Copy() const { return new DynamicActorScroller(*this); }
void DynamicActorScroller::LoadFromNode( const XNode *pNode )
@@ -84,7 +86,7 @@ void DynamicActorScroller::ShiftSubActors( int iDist )
* reconfigures much fewer actors. */
int iWrapped = iDist;
wrap( iWrapped, m_iNumItems );
if( abs(iWrapped) < abs(iDist) )
if( std::abs(iWrapped) < std::abs(iDist) )
iDist = iWrapped;
}
@@ -137,7 +139,7 @@ REGISTER_ACTOR_CLASS_WITH_NAME( DynamicActorScrollerAutoDeleteChildren, DynamicA
/*
* (c) 2005 Glenn Maynard
* All rights reserved.
*
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
@@ -147,7 +149,7 @@ REGISTER_ACTOR_CLASS_WITH_NAME( DynamicActorScrollerAutoDeleteChildren, DynamicA
* copyright notice(s) and this permission notice appear in all copies of
* the Software and that both the above copyright notice(s) and this
* permission notice appear in supporting documentation.
*
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
+9 -7
View File
@@ -11,6 +11,8 @@
#include "FontCharAliases.h"
#include "arch/Dialog/Dialog.h"
#include <cmath>
FontPage::FontPage(): m_iHeight(0), m_iLineSpacing(0), m_fVshift(0),
m_iDrawExtraPixelsLeft(0), m_iDrawExtraPixelsRight(0),
m_FontPageTextures(), m_sTexturePath(""), m_aGlyphs(),
@@ -101,7 +103,7 @@ void FontPage::Load( const FontPageSettings &cfg )
if( cfg.m_fScaleAllWidthsBy != 1 )
{
for( int i=0; i<m_FontPageTextures.m_pTextureMain->GetNumFrames(); i++ )
aiFrameWidths[i] = lrintf( aiFrameWidths[i] * cfg.m_fScaleAllWidthsBy );
aiFrameWidths[i] = std::lrint( aiFrameWidths[i] * cfg.m_fScaleAllWidthsBy );
}
m_iCharToGlyphNo = cfg.CharToGlyphNo;
@@ -167,7 +169,7 @@ void FontPage::SetTextureCoords( const std::vector<int> &widths, int iAdvanceExt
if( (iSourcePixelsToChopOff % 2) == 1 )
{
/* We don't want to chop off an odd number of pixels, since that'll
* put our texture coordinates between texels and make things blurrier.
* put our texture coordinates between texels and make things blurrier.
* Note that, since we set m_iHadvance above, this merely expands what
* we render; it doesn't advance the cursor further. So, glyphs
* that have an odd width should err to being a pixel offcenter left,
@@ -358,10 +360,10 @@ const glyph &Font::GetGlyph( wchar_t c ) const
std::map<wchar_t, glyph*>::const_iterator it = m_iCharToGlyph.find(c);
// If that's missing, use the default glyph.
if(it == m_iCharToGlyph.end())
if(it == m_iCharToGlyph.end())
it = m_iCharToGlyph.find(FONT_DEFAULT_GLYPH);
if(it == m_iCharToGlyph.end())
if(it == m_iCharToGlyph.end())
RageException::Throw( "The default glyph is missing from the font \"%s\".", path.c_str() );
return *it->second;
@@ -673,7 +675,7 @@ RString FontPageSettings::MapRange( RString sMapping, int iMapOffset, int iGlyph
/* What's a practical limit? A 2048x2048 texture could contain 16x16
* characters, which is 16384 glyphs. (Use a grayscale map and that's
* only 4 megs.) Let's use that as a cap. (We don't want to go crazy
* only 4 megs.) Let's use that as a cap. (We don't want to go crazy
* if someone says "range Unicode #0-FFFFFFFF".) */
if( iCount > 16384 )
return ssprintf( "Can't map %i glyphs to one font page", iCount );
@@ -902,7 +904,7 @@ void Font::Load( const RString &sIniPath, RString sChars )
/*
* (c) 2001-2004 Glenn Maynard, Chris Danford
* All rights reserved.
*
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
@@ -912,7 +914,7 @@ void Font::Load( const RString &sIniPath, RString sChars )
* copyright notice(s) and this permission notice appear in all copies of
* the Software and that both the above copyright notice(s) and this
* permission notice appear in supporting documentation.
*
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
+8 -6
View File
@@ -9,7 +9,9 @@
#include "GameManager.h"
#include "LocalizedString.h"
#include "PlayerNumber.h"
#include <float.h>
#include <cfloat>
#include <cmath>
RString StepsTypeToString( StepsType st );
@@ -346,9 +348,9 @@ StringToX( StageAward );
LuaFunction( StageAwardToLocalizedString, StageAwardToLocalizedString(Enum::Check<StageAward>(L, 1)) );
LuaXType( StageAward );
// Numbers are intentionally not at the front of these strings so that the
// Numbers are intentionally not at the front of these strings so that the
// strings can be used as XML entity names.
// Numbers are intentionally not at the back so that "1000" and "10000" don't
// Numbers are intentionally not at the back so that "1000" and "10000" don't
// conflict when searching for theme elements.
static const char *PeakComboAwardNames[] = {
"1000",
@@ -406,7 +408,7 @@ float DisplayBpms::GetMaxWithin(float highest) const
bool DisplayBpms::BpmIsConstant() const
{
return fabsf( GetMin() - GetMax() ) < 0.001f;
return std::abs( GetMin() - GetMax() ) < 0.001f;
}
bool DisplayBpms::IsSecret() const
@@ -518,7 +520,7 @@ LuaXType( FailType );
/*
* (c) 2001-2004 Chris Danford
* All rights reserved.
*
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
@@ -528,7 +530,7 @@ LuaXType( FailType );
* copyright notice(s) and this permission notice appear in all copies of
* the Software and that both the above copyright notice(s) and this
* permission notice appear in supporting documentation.
*
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
+24 -23
View File
@@ -4,7 +4,8 @@
#define GAME_CONSTANTS_AND_TYPES_H
#include "EnumHelper.h"
#include <float.h> // need the max for default.
#include <cfloat>
// Note definitions
/** @brief Define the mininum difficulty value allowed. */
@@ -149,12 +150,12 @@ const RString& PlayModeToLocalizedString( PlayMode pm );
PlayMode StringToPlayMode( const RString& s );
LuaDeclareType( PlayMode );
/**
/**
* @brief The list of ways to sort songs and courses.
*
* All song sorts should be listed before course sorts.
*/
enum SortOrder
enum SortOrder
{
// song sorts
SORT_PREFERRED, /**< Sort by the user's preferred settings. */
@@ -216,7 +217,7 @@ LuaDeclareType( SortOrder );
inline bool IsSongSort( SortOrder so ) { return (so >= SORT_PREFERRED && so <= SORT_DOUBLE_CHALLENGE_METER) || so == SORT_LENGTH; }
/** @brief The list of tap note scores available during play. */
enum TapNoteScore {
enum TapNoteScore {
TNS_None, /**< There is no score involved with this one. */
TNS_HitMine, /**< A mine was hit successfully. */
TNS_AvoidMine, /**< A mine was avoided successfully. */
@@ -252,8 +253,8 @@ TapNoteScore StringToTapNoteScore( const RString& str );
LuaDeclareType( TapNoteScore );
/** @brief The list of hold note scores available during play. */
enum HoldNoteScore
{
enum HoldNoteScore
{
HNS_None, /**< The HoldNote was not scored yet. */
HNS_LetGo, /**< The HoldNote has passed, but the player missed it. */
HNS_Held, /**< The HoldNote has passed, and was successfully held all the way. */
@@ -352,11 +353,11 @@ LuaDeclareType( ProfileSlot );
/** @brief The states of the memory card during play. */
enum MemoryCardState
{
MemoryCardState_Ready,
MemoryCardState_Checking,
MemoryCardState_TooLate,
MemoryCardState_Error,
{
MemoryCardState_Ready,
MemoryCardState_Checking,
MemoryCardState_TooLate,
MemoryCardState_Error,
MemoryCardState_Removed,
MemoryCardState_NoCard,
NUM_MemoryCardState,
@@ -489,8 +490,8 @@ StageAward StringToStageAward( const RString& pma );
LuaDeclareType( StageAward );
/** @brief The various peak combo awards should such a combo be attained during play. */
enum PeakComboAward
{
enum PeakComboAward
{
PeakComboAward_1000,
PeakComboAward_2000,
PeakComboAward_3000,
@@ -565,10 +566,10 @@ StyleType StringToStyleType( const RString& s );
LuaDeclareType( StyleType );
/** @brief The different goal types, mainly meant for fitness modes. */
enum GoalType
enum GoalType
{
GoalType_Calories,
GoalType_Time,
GoalType_Calories,
GoalType_Time,
GoalType_None,
NUM_GoalType,
GoalType_Invalid,
@@ -606,8 +607,8 @@ LuaDeclareType( EditMode );
enum SampleMusicPreviewMode
{
SampleMusicPreviewMode_Normal, /**< Music is played as the song is highlighted. */
SampleMusicPreviewMode_StartToPreview,
SampleMusicPreviewMode_ScreenMusic, /**< No music plays. Select it once to preview the music,
SampleMusicPreviewMode_StartToPreview,
SampleMusicPreviewMode_ScreenMusic, /**< No music plays. Select it once to preview the music,
* then once more to select the song. */
SampleMusicPreviewMode_LastSong, /**< continue playing the last song */
NUM_SampleMusicPreviewMode,
@@ -630,7 +631,7 @@ enum Stage
Stage_4th, /**< The fourth stage. */
Stage_5th, /**< The fifth stage. */
Stage_6th, /**< The sixth stage. */
Stage_Next, /**< Somewhere between the sixth and final stage.
Stage_Next, /**< Somewhere between the sixth and final stage.
* This won't normally happen because 7 stages is the max in the UI. */
Stage_Final, /**< The last stage. */
Stage_Extra1, /**< The first bonus stage, AKA the extra stage. */
@@ -662,8 +663,8 @@ LuaDeclareType( EarnedExtraStage );
/** @brief The different results of loading a profile. */
enum ProfileLoadResult
{
ProfileLoadResult_Success,
ProfileLoadResult_FailedNoProfile,
ProfileLoadResult_Success,
ProfileLoadResult_FailedNoProfile,
ProfileLoadResult_FailedTampered
};
@@ -718,7 +719,7 @@ LuaDeclareType( FailType );
* @author Chris Danford, Chris Gomez (c) 2001-2004
* @section LICENSE
* All rights reserved.
*
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
@@ -728,7 +729,7 @@ LuaDeclareType( FailType );
* copyright notice(s) and this permission notice appear in all copies of
* the Software and that both the above copyright notice(s) and this
* permission notice appear in supporting documentation.
*
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
+6 -4
View File
@@ -21,6 +21,8 @@
#include "RageTimer.h"
#include "RageInput.h"
#include <cmath>
static RageTimer g_GameplayTimer;
static Preference<bool> g_bNeverBoostAppPriority( "NeverBoostAppPriority", false );
@@ -56,7 +58,7 @@ static void CheckGameLoopTimerSkips( float fDeltaTime )
const float fExpectedTime = 1.0f / iThisFPS;
const float fDifference = fDeltaTime - fExpectedTime;
if( fabsf(fDifference) > 0.002f && fabsf(fDifference) < 0.100f )
if( std::abs(fDifference) > 0.002f && std::abs(fDifference) < 0.100f )
LOG->Trace( "GameLoop timer skip: %i FPS, expected %.3f, got %.3f (%.3f difference)",
iThisFPS, fExpectedTime, fDeltaTime, fDifference );
}
@@ -256,7 +258,7 @@ void GameLoop::UpdateAllButDraw(bool bRunningFromVBLANK)
m_bUpdatedDuringVBLANK = false;
return; //would it kill us to run it again or do we want to draw asap?
}
//if vblank called us, we will tell the game loop we received an update for the frame it wants to process
if (bRunningFromVBLANK) m_bUpdatedDuringVBLANK = true;
else m_bUpdatedDuringVBLANK = false;
@@ -270,7 +272,7 @@ void GameLoop::UpdateAllButDraw(bool bRunningFromVBLANK)
CheckGameLoopTimerSkips(fDeltaTime);
fDeltaTime *= g_fUpdateRate;
// Update SOUNDMAN early (before any RageSound::GetPosition calls), to flush position data.
SOUNDMAN->Update();
@@ -290,7 +292,7 @@ void GameLoop::UpdateAllButDraw(bool bRunningFromVBLANK)
//bandaid for low max audio sample counter
SOUNDMAN->low_sample_count_workaround();
LIGHTSMAN->Update(fDeltaTime);
}
+20 -18
View File
@@ -20,13 +20,15 @@
#include "arch/Sound/RageSoundDriver.h"
#include <cmath>
GameSoundManager *SOUND = nullptr;
/*
* When playing music, automatically search for an SM file for timing data. If one is
* found, automatically handle GAMESTATE->m_fSongBeat, etc.
*
* modf(GAMESTATE->m_fSongBeat) should always be continuously moving from 0 to 1. To do
* std::modf(GAMESTATE->m_fSongBeat) should always be continuously moving from 0 to 1. To do
* this, wait before starting a sound until the fractional portion of the beat will be
* the same.
*
@@ -184,7 +186,7 @@ static void StartMusic( MusicToPlay &ToPlay )
float fStartBeat = NewMusic->m_NewTiming.GetBeatFromElapsedTimeNoOffset( ToPlay.fStartSecond );
float fEndSec = ToPlay.fStartSecond + ToPlay.fLengthSeconds;
float fEndBeat = NewMusic->m_NewTiming.GetBeatFromElapsedTimeNoOffset( fEndSec );
const float fStartBeatFraction = fmodfp( fStartBeat, 1 );
const float fEndBeatFraction = fmodfp( fEndBeat, 1 );
@@ -236,7 +238,7 @@ static void StartMusic( MusicToPlay &ToPlay )
const float fStartBeat = NewMusic->m_NewTiming.GetBeatFromElapsedTimeNoOffset( ToPlay.fStartSecond );
const float fStartBeatFraction = fmodfp( fStartBeat, 1 );
float fCurBeatToStartOn = truncf(fCurBeat) + fStartBeatFraction;
float fCurBeatToStartOn = std::trunc(fCurBeat) + fStartBeatFraction;
if( fCurBeatToStartOn < fCurBeat )
fCurBeatToStartOn += 1.0f;
@@ -503,7 +505,7 @@ float GameSoundManager::GetFrameTimingAdjustment( float fDeltaTime )
const float fExpectedDelay = 1.0f / iThisFPS;
const float fExtraDelay = fDeltaTime - fExpectedDelay;
if( fabsf(fExtraDelay) >= fExpectedDelay/2 )
if( std::abs(fExtraDelay) >= fExpectedDelay/2 )
return 0;
/* Subtract the extra delay. */
@@ -550,7 +552,7 @@ void GameSoundManager::Update( float fDeltaTime )
case FADE_NONE: break;
case FADE_OUT:
fapproach( fVolume, g_fDimVolume, fDeltaTime/fFadeOutSpeed );
if( fabsf(fVolume-g_fDimVolume) < 0.001f )
if( std::abs(fVolume-g_fDimVolume) < 0.001f )
g_FadeState = FADE_WAIT;
break;
case FADE_WAIT:
@@ -560,11 +562,11 @@ void GameSoundManager::Update( float fDeltaTime )
break;
case FADE_IN:
fapproach( fVolume, g_fOriginalVolume, fDeltaTime/fFadeInSpeed );
if( fabsf(fVolume-g_fOriginalVolume) < 0.001f )
if( std::abs(fVolume-g_fOriginalVolume) < 0.001f )
g_FadeState = FADE_NONE;
break;
}
RageSoundParams p = g_Playing->m_Music->GetParams();
if( p.m_Volume != fVolume )
{
@@ -604,7 +606,7 @@ void GameSoundManager::Update( float fDeltaTime )
const RString ThisFile = g_Playing->m_Music->GetLoadedFilePath();
/* If fSoundTimePassed < 0, the sound has probably looped. */
if( sLastFile == ThisFile && fSoundTimePassed >= 0 && fabsf(fDiff) > 0.003f )
if( sLastFile == ThisFile && fSoundTimePassed >= 0 && std::abs(fDiff) > 0.003f )
LOG->Trace("Song position skip in %s: expected %.3f, got %.3f (cur %f, prev %f) (%.3f difference)",
Basename(ThisFile).c_str(), fExpectedTimePassed, fSoundTimePassed, fSeconds, GAMESTATE->m_Position.m_fMusicSeconds, fDiff );
sLastFile = ThisFile;
@@ -662,7 +664,7 @@ void GameSoundManager::Update( float fDeltaTime )
static int iRowLastCrossed = 0;
FOREACH_CabinetLight( cl )
{
{
// Are we "holding" the light?
if( lights.IsHoldNoteAtRow( cl, iSongRow ) )
{
@@ -692,14 +694,14 @@ RString GameSoundManager::GetMusicPath() const
return g_Playing->m_Music->GetLoadedFilePath();
}
void GameSoundManager::PlayMusic(
RString sFile,
const TimingData *pTiming,
void GameSoundManager::PlayMusic(
RString sFile,
const TimingData *pTiming,
bool bForceLoop,
float fStartSecond,
float fLengthSeconds,
float fFadeInLengthSeconds,
float fFadeOutLengthSeconds,
float fStartSecond,
float fLengthSeconds,
float fFadeInLengthSeconds,
float fFadeOutLengthSeconds,
bool bAlignBeat,
bool bApplyMusicRate
)
@@ -812,7 +814,7 @@ float GameSoundManager::GetPlayerBalance( PlayerNumber pn )
#include "LuaBinding.h"
/** @brief Allow Lua to have access to the GameSoundManager. */
/** @brief Allow Lua to have access to the GameSoundManager. */
class LunaGameSoundManager: public Luna<GameSoundManager>
{
public:
@@ -882,7 +884,7 @@ public:
static int StopMusic( T* p, lua_State *L ) { p->StopMusic(); COMMON_RETURN_SELF; }
static int IsTimingDelayed( T* p, lua_State *L ) { lua_pushboolean( L, g_Playing->m_bTimingDelayed ); return 1; }
LunaGameSoundManager()
{
ADD_METHOD( DimMusic );
+5 -4
View File
@@ -42,6 +42,7 @@
#include "ScreenManager.h"
#include "Screen.h"
#include <cmath>
#include <ctime>
#include <set>
@@ -1853,7 +1854,7 @@ StageResult GameState::GetStageResult( PlayerNumber pn ) const
{
case PLAY_MODE_BATTLE:
case PLAY_MODE_RAVE:
if( fabsf(m_fTugLifePercentP1 - 0.5f) < 0.0001f )
if( std::abs(m_fTugLifePercentP1 - 0.5f) < 0.0001f )
return RESULT_DRAW;
switch( pn )
{
@@ -2073,7 +2074,7 @@ void GameState::GetRankingFeats( PlayerNumber pn, std::vector<RankingFeat> &asFe
// may have made high scores then switched modes.
PlayMode mode = m_PlayMode.Get();
char const *modeStr = PlayModeToString(mode).c_str();
CHECKPOINT_M( ssprintf("Getting the feats for %s", modeStr));
switch( mode )
{
@@ -2381,7 +2382,7 @@ void GameState::StoreRankingName( PlayerNumber pn, RString sName )
ASSERT( sas.pSteps != nullptr );
vSongAndSteps.push_back( sas );
}
std::vector<SongAndSteps>::iterator toDelete = std::unique( vSongAndSteps.begin(), vSongAndSteps.end() );
vSongAndSteps.erase(toDelete, vSongAndSteps.end());
@@ -2407,7 +2408,7 @@ void GameState::StoreRankingName( PlayerNumber pn, RString sName )
Trail *pTrail = m_pCurTrail[pn];
ASSERT( pTrail != nullptr );
CourseDifficulty cd = pTrail->m_CourseDifficulty;
HighScoreList &hsl = pProfile->GetCourseHighScoreList( pCourse, pTrail );
HighScoreList &hsl = pProfile->GetCourseHighScoreList( pCourse, pTrail );
if (!PREFSMAN->m_bAllowMultipleHighScoreWithSameName)
{
// erase all but the highest score for each name
+10 -8
View File
@@ -11,6 +11,8 @@
#include "Song.h"
#include "XmlFile.h"
#include <cmath>
//#define DIVIDE_LINE_WIDTH THEME->GetMetricI(m_sName,"TexturedBottomHalf")
REGISTER_ACTOR_CLASS( GraphDisplay );
@@ -27,7 +29,7 @@ public:
DISPLAY->ClearAllTextures();
// Must call this after setting the texture or else texture
// Must call this after setting the texture or else texture
// parameters have no effect.
Actor::SetTextureRenderStates();
@@ -66,7 +68,7 @@ public:
{
MakeCircle( m_LineStrip[i], &m_pCircles[0] + iCircleVertices*i, iSubdivisions, 1 );
}
int iNumLines = iSize-1;
m_Quads.resize( iNumLines * 4 );
for( int i = 0; i < iNumLines; ++i )
@@ -76,7 +78,7 @@ public:
float opp = p2.p.x - p1.p.x;
float adj = p2.p.y - p1.p.y;
float hyp = powf(opp*opp + adj*adj, 0.5f);
float hyp = std::pow(opp*opp + adj*adj, 0.5f);
float lsin = opp/hyp;
float lcos = adj/hyp;
@@ -88,7 +90,7 @@ public:
int iLineWidth = 2;
float ydist = lsin * iLineWidth/2;
float xdist = lcos * iLineWidth/2;
v[0].p.x += xdist;
v[0].p.y -= ydist;
v[1].p.x -= xdist;
@@ -135,7 +137,7 @@ public:
DISPLAY->ClearAllTextures();
DISPLAY->SetTexture( TextureUnit_1, m_pTexture->GetTexHandle() );
// Must call this after setting the texture or else texture
// Must call this after setting the texture or else texture
// parameters have no effect.
Actor::SetTextureRenderStates();
@@ -275,7 +277,7 @@ void GraphDisplay::UpdateVerts()
// lua start
#include "LuaBinding.h"
/** @brief Allow Lua to have access to the GraphDisplay. */
/** @brief Allow Lua to have access to the GraphDisplay. */
class LunaGraphDisplay: public Luna<GraphDisplay>
{
public:
@@ -313,7 +315,7 @@ LUA_REGISTER_DERIVED_CLASS( GraphDisplay, ActorFrame )
/*
* (c) 2003 Glenn Maynard
* All rights reserved.
*
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
@@ -323,7 +325,7 @@ LUA_REGISTER_DERIVED_CLASS( GraphDisplay, ActorFrame )
* copyright notice(s) and this permission notice appear in all copies of
* the Software and that both the above copyright notice(s) and this
* permission notice appear in supporting documentation.
*
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
+11 -10
View File
@@ -17,9 +17,10 @@
#include "RageSurfaceUtils_Dither.h"
#include "RageSurfaceUtils_Zoom.h"
#include "SpecialFiles.h"
#include "Banner.h"
#include <cmath>
static Preference<bool> g_bPalettedImageCache( "PalettedImageCache", false );
/* Neither a global or a file scope static can be used for this because
@@ -65,7 +66,7 @@ void ImageCache::Demand( RString sImageDir )
++g_iDemandRefcount;
if( g_iDemandRefcount > 1 )
return;
if( PREFSMAN->m_ImageCache != IMGCACHE_LOW_RES_LOAD_ON_DEMAND )
return;
@@ -93,7 +94,7 @@ void ImageCache::Undemand( RString sImageDir )
--g_iDemandRefcount;
if( g_iDemandRefcount != 0 )
return;
if( PREFSMAN->m_ImageCache != IMGCACHE_LOW_RES_LOAD_ON_DEMAND )
return;
@@ -199,10 +200,10 @@ struct ImageTexture: public RageTexture
}
~ImageTexture()
{
{
Destroy();
}
void Create()
{
ASSERT( m_pImage != nullptr );
@@ -213,10 +214,10 @@ struct ImageTexture: public RageTexture
m_iSourceWidth = m_iWidth;
m_iSourceHeight = m_iHeight;
/* The image width (within the texture) is always the entire texture.
/* The image width (within the texture) is always the entire texture.
* Only resize if the max texture size requires it; since these images
* are already scaled down, this shouldn't happen often. */
if( m_pImage->w > DISPLAY->GetMaxTextureSize() ||
if( m_pImage->w > DISPLAY->GetMaxTextureSize() ||
m_pImage->h > DISPLAY->GetMaxTextureSize() )
{
LOG->Warn( "Converted %s at runtime", GetID().filename.c_str() );
@@ -325,7 +326,7 @@ RageTextureID ImageCache::LoadCachedImage( RString sImageDir, RString sImagePath
static inline int closest( int num, int n1, int n2 )
{
if( abs(num - n1) > abs(num - n2) )
if( std::abs(num - n1) > std::abs(num - n2) )
return n2;
return n1;
}
@@ -471,7 +472,7 @@ void ImageCache::WriteToDisk()
/*
* (c) 2003 Glenn Maynard
* All rights reserved.
*
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
@@ -481,7 +482,7 @@ void ImageCache::WriteToDisk()
* copyright notice(s) and this permission notice appear in all copies of
* the Software and that both the above copyright notice(s) and this
* permission notice appear in supporting documentation.
*
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
+6 -4
View File
@@ -7,6 +7,8 @@
#include "Course.h"
#include "ActorUtil.h"
#include <cmath>
LifeMeterBattery::LifeMeterBattery()
{
m_iLivesLeft= 4;
@@ -144,7 +146,7 @@ void LifeMeterBattery::AddLives( int iLives )
void LifeMeterBattery::ChangeLives(int iLifeDiff)
{
if( iLifeDiff < 0 )
SubtractLives( abs(iLifeDiff) );
SubtractLives( std::abs(iLifeDiff) );
else if( iLifeDiff > 0 )
AddLives(iLifeDiff);
}
@@ -268,7 +270,7 @@ void LifeMeterBattery::Update( float fDeltaTime )
// lua start
#include "LuaBinding.h"
/** @brief Allow Lua to have access to the LifeMeterBattery. */
/** @brief Allow Lua to have access to the LifeMeterBattery. */
class LunaLifeMeterBattery: public Luna<LifeMeterBattery>
{
public:
@@ -289,7 +291,7 @@ LUA_REGISTER_DERIVED_CLASS( LifeMeterBattery, LifeMeter )
/*
* (c) 2001-2004 Chris Danford
* All rights reserved.
*
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
@@ -299,7 +301,7 @@ LUA_REGISTER_DERIVED_CLASS( LifeMeterBattery, LifeMeter )
* copyright notice(s) and this permission notice appear in all copies of
* the Software and that both the above copyright notice(s) and this
* permission notice appear in supporting documentation.
*
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
+6 -4
View File
@@ -14,6 +14,8 @@
#include "CommonMetrics.h"
#include "Style.h"
#include <cmath>
const RString DEFAULT_LIGHTS_DRIVER = "SystemMessage,Export";
static Preference<RString> g_sLightsDriver( "LightsDriver", "" ); // "" == DEFAULT_LIGHTS_DRIVER
Preference<float> g_fLightsFalloffSeconds( "LightsFalloffSeconds", 0.1f );
@@ -129,7 +131,7 @@ LightsManager::~LightsManager()
// XXX: Allow themer to change these. (rewritten; who wrote original? -aj)
static const float g_fLightEffectRiseSeconds = 0.075f;
static const float g_fLightEffectFalloffSeconds = 0.35f;
static const float g_fCoinPulseTime = 0.100f;
static const float g_fCoinPulseTime = 0.100f;
void LightsManager::BlinkActorLight( CabinetLight cl )
{
m_fSecsLeftInActorLightBlink[cl] = g_fLightEffectRiseSeconds;
@@ -203,7 +205,7 @@ void LightsManager::Update( float fDeltaTime )
if( m_LightsMode == LIGHTSMODE_TEST_AUTO_CYCLE )
{
m_fTestAutoCycleCurrentIndex += fDeltaTime;
m_fTestAutoCycleCurrentIndex = fmodf( m_fTestAutoCycleCurrentIndex, NUM_CabinetLight*100 );
m_fTestAutoCycleCurrentIndex = std::fmod( m_fTestAutoCycleCurrentIndex, NUM_CabinetLight*100 );
}
switch( m_LightsMode )
@@ -533,7 +535,7 @@ void LightsManager::TurnOffAllLights()
/*
* (c) 2003-2004 Chris Danford
* All rights reserved.
*
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
@@ -543,7 +545,7 @@ void LightsManager::TurnOffAllLights()
* copyright notice(s) and this permission notice appear in all copies of
* the Software and that both the above copyright notice(s) and this
* permission notice appear in supporting documentation.
*
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
+7 -6
View File
@@ -16,6 +16,7 @@
#include <sstream> // conversion for lua functions.
#include <csetjmp>
#include <cassert>
#include <cmath>
#include <map>
LuaManager *LUA = nullptr;
@@ -170,9 +171,9 @@ static int GetLuaStack( lua_State *L )
{
RString sErr;
LuaHelpers::Pop( L, sErr );
lua_Debug ar;
for( int iLevel = 0; lua_getstack(L, iLevel, &ar); ++iLevel )
{
if( !lua_getinfo(L, "nSluf", &ar) )
@@ -181,7 +182,7 @@ static int GetLuaStack( lua_State *L )
const char *file = ar.source[0] == '@' ? ar.source + 1 : ar.short_src;
const char *name;
std::vector<RString> vArgs;
if( !strcmp(ar.what, "C") )
{
for( int i = 1; i <= ar.nups && (name = lua_getupvalue(L, -1, i)) != nullptr; ++i )
@@ -740,7 +741,7 @@ XNode *LuaHelpers::GetLuaInformation()
XNode *pConstantNode = pConstantsNode->AppendChild( "Constant" );
pConstantNode->AppendAttr( "name", c.first );
if( c.second == truncf(c.second) )
if( c.second == std::trunc(c.second) )
pConstantNode->AppendAttr( "value", static_cast<int>(c.second) );
else
pConstantNode->AppendAttr( "value", c.second );
@@ -1177,7 +1178,7 @@ LUA_REGISTER_NAMESPACE( lua )
/*
* (c) 2004-2006 Glenn Maynard, Steve Checkoway
* All rights reserved.
*
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
@@ -1187,7 +1188,7 @@ LUA_REGISTER_NAMESPACE( lua )
* copyright notice(s) and this permission notice appear in all copies of
* the Software and that both the above copyright notice(s) and this
* permission notice appear in supporting documentation.
*
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
+8 -6
View File
@@ -9,6 +9,8 @@
#include "ThemeMetric.h"
#include "ActorUtil.h"
#include <cmath>
RString WARNING_COMMAND_NAME( size_t i ) { return ssprintf("Warning%dCommand",int(i)); }
static const float TIMER_PAUSE_SECONDS = 99.99f;
@@ -73,8 +75,8 @@ void MenuTimer::EnableStealth( bool bStealth )
}
}
void MenuTimer::Update( float fDeltaTime )
{
void MenuTimer::Update( float fDeltaTime )
{
ActorFrame::Update( fDeltaTime );
if( m_bPaused )
@@ -100,7 +102,7 @@ void MenuTimer::Update( float fDeltaTime )
SOUND->PlayOnceFromAnnouncer( "hurry up" );
int iCrossed = (int)floorf(fOldSecondsLeft);
int iCrossed = std::floor(fOldSecondsLeft);
if( fOldSecondsLeft > iCrossed && fNewSecondsLeft < iCrossed ) // crossed
{
if( iCrossed <= WARNING_START )
@@ -198,7 +200,7 @@ void MenuTimer::SetText( float fSeconds )
// lua start
#include "LuaBinding.h"
/** @brief Allow Lua to have access to the MenuTimer. */
/** @brief Allow Lua to have access to the MenuTimer. */
class LunaMenuTimer: public Luna<MenuTimer>
{
public:
@@ -230,7 +232,7 @@ LUA_REGISTER_DERIVED_CLASS( MenuTimer, ActorFrame )
/*
* (c) 2002-2004 Chris Danford
* All rights reserved.
*
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
@@ -240,7 +242,7 @@ LUA_REGISTER_DERIVED_CLASS( MenuTimer, ActorFrame )
* copyright notice(s) and this permission notice appear in all copies of
* the Software and that both the above copyright notice(s) and this
* permission notice appear in supporting documentation.
*
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
+6 -5
View File
@@ -9,6 +9,7 @@
#include "RageLog.h"
#include "RageDisplay.h"
#include <cmath>
#include <numeric>
#define MS_MAX_NAME 32
@@ -71,7 +72,7 @@ void AnimatedTexture::Load( const RString &sTexOrIniPath )
RString sFileName;
float fDelay = 0;
if( pAnimatedTexture->GetAttrValue( sFileKey, sFileName ) &&
pAnimatedTexture->GetAttrValue( sDelayKey, fDelay ) )
pAnimatedTexture->GetAttrValue( sDelayKey, fDelay ) )
{
RString sTranslateXKey = ssprintf( "TranslateX%04d", i );
RString sTranslateYKey = ssprintf( "TranslateY%04d", i );
@@ -85,7 +86,7 @@ void AnimatedTexture::Load( const RString &sTexOrIniPath )
ID.bStretch = true;
ID.bHotPinkColorKey = true;
ID.bMipMaps = true; // use mipmaps in Models
AnimatedTextureState state(
AnimatedTextureState state(
TEXTUREMAN->LoadTexture( ID ),
fDelay,
vOffset
@@ -155,7 +156,7 @@ float AnimatedTexture::GetAnimationLengthSeconds() const
void AnimatedTexture::SetSecondsIntoAnimation( float fSeconds )
{
fSeconds = fmodf( fSeconds, GetAnimationLengthSeconds() );
fSeconds = std::fmod( fSeconds, GetAnimationLengthSeconds() );
m_iCurState = 0;
for( unsigned i=0; i<vFrames.size(); i++ )
@@ -353,7 +354,7 @@ bool msAnimation::LoadMilkshapeAsciiBones( RString sAniName, RString sPath )
/*
* (c) 2003-2004 Chris Danford
* All rights reserved.
*
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
@@ -363,7 +364,7 @@ bool msAnimation::LoadMilkshapeAsciiBones( RString sAniName, RString sPath )
* copyright notice(s) and this permission notice appear in all copies of
* the Software and that both the above copyright notice(s) and this
* permission notice appear in supporting documentation.
*
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
+27 -25
View File
@@ -23,10 +23,12 @@
#include "MessageManager.h"
#include "LocalizedString.h"
#include <cmath>
static Preference<bool> g_bMoveRandomToEnd( "MoveRandomToEnd", false );
static Preference<bool> g_bPrecacheAllSorts( "PreCacheAllWheelSorts", false);
#define NUM_WHEEL_ITEMS ((int)ceil(NUM_WHEEL_ITEMS_TO_DRAW+2))
#define NUM_WHEEL_ITEMS ((int)std::ceil(NUM_WHEEL_ITEMS_TO_DRAW+2))
#define WHEEL_TEXT(s) THEME->GetString( "MusicWheel", ssprintf("%sText",s.c_str()) );
#define CUSTOM_ITEM_WHEEL_TEXT(s) THEME->GetString( "MusicWheel", ssprintf("CustomItem%sText",s.c_str()) );
@@ -63,7 +65,7 @@ static SortOrder ForceAppropriateSort( PlayMode pm, SortOrder so )
default:
break;
}
return so;
}
@@ -72,7 +74,7 @@ MusicWheelItem *MusicWheel::MakeItem()
return new MusicWheelItem;
}
void MusicWheel::Load( RString sType )
void MusicWheel::Load( RString sType )
{
ROULETTE_SWITCH_SECONDS .Load(sType,"RouletteSwitchSeconds");
ROULETTE_SLOW_DOWN_SWITCHES .Load(sType,"RouletteSlowDownSwitches");
@@ -124,7 +126,7 @@ void MusicWheel::Load( RString sType )
* to re-sort by title each time. */
SONGMAN->SortSongs();
FOREACH_ENUM( SortOrder, so ) {
m_WheelItemDatasStatus[so]=INVALID;
}
@@ -134,10 +136,10 @@ void MusicWheel::BeginScreen()
{
RageTimer timer;
RString times;
FOREACH_ENUM( SortOrder, so ) {
FOREACH_ENUM( SortOrder, so ) {
if(m_WheelItemDatasStatus[so]!=INVALID) {
m_WheelItemDatasStatus[so]=NEEDREFILTER;
}
if(g_bPrecacheAllSorts) {
@@ -150,7 +152,7 @@ void MusicWheel::BeginScreen()
}
// Set m_LastModeMenuItem to the first item that matches the current mode. (Do this
// after building wheel item data.)
// after building wheel item data.)
{
const std::vector<MusicWheelItemData *> &from = getWheelItemsData(SORT_MODE_MENU);
for( unsigned i=0; i<from.size(); i++ )
@@ -514,7 +516,7 @@ void MusicWheel::BuildWheelItemDatas( std::vector<MusicWheelItemData *> &arrayWh
{
case SORT_MODE_MENU:
{
arrayWheelItemDatas.clear(); // clear out the previous wheel items
arrayWheelItemDatas.clear(); // clear out the previous wheel items
std::vector<RString> vsNames;
split( MODE_MENU_CHOICE_NAMES, ",", vsNames );
for( unsigned i=0; i<vsNames.size(); ++i )
@@ -631,7 +633,7 @@ void MusicWheel::BuildWheelItemDatas( std::vector<MusicWheelItemData *> &arrayWh
}
// Build an array of WheelItemDatas from the sorted list of Song*'s
arrayWheelItemDatas.clear(); // clear out the previous wheel items
arrayWheelItemDatas.clear(); // clear out the previous wheel items
arrayWheelItemDatas.reserve( arraySongs.size() );
switch( PREFSMAN->m_MusicWheelUsesSections )
@@ -652,7 +654,7 @@ void MusicWheel::BuildWheelItemDatas( std::vector<MusicWheelItemData *> &arrayWh
// Sorting twice isn't necessary. Instead, modify the compatator
// functions in Song.cpp to have the desired effect. -Chris
/* Keeping groups together with the sorts is tricky and brittle; we
* keep getting OTHER split up without this. However, it puts the
* keep getting OTHER split up without this. However, it puts the
* Grade and BPM sorts in the wrong order, and they're already correct,
* so don't re-sort for them. */
/* We're using sections, so use the section name as the top-level sort. */
@@ -744,7 +746,7 @@ void MusicWheel::BuildWheelItemDatas( std::vector<MusicWheelItemData *> &arrayWh
Song* pSong;
Steps* pSteps;
SONGMAN->GetExtraStageInfo( GAMESTATE->IsExtraStage2(), GAMESTATE->GetCurrentStyle(PLAYER_INVALID), pSong, pSteps );
for( unsigned i=0; i<arrayWheelItemDatas.size(); i++ )
{
if( arrayWheelItemDatas[i]->m_pSong == pSong )
@@ -820,7 +822,7 @@ void MusicWheel::BuildWheelItemDatas( std::vector<MusicWheelItemData *> &arrayWh
if( so == SORT_ALL_COURSES )
CourseUtil::SortCoursePointerArrayByType( apCourses );
arrayWheelItemDatas.clear(); // clear out the previous wheel items
arrayWheelItemDatas.clear(); // clear out the previous wheel items
RString sLastSection = "";
int iSectionColorIndex = 0;
@@ -889,7 +891,7 @@ void MusicWheel::BuildWheelItemDatas( std::vector<MusicWheelItemData *> &arrayWh
std::vector<MusicWheelItemData *> & MusicWheel::getWheelItemsData(SortOrder so) {
// Update the popularity and init icons.
readyWheelItemsData(so);
readyWheelItemsData(so);
return m__WheelItemDatas[so];
}
@@ -1004,7 +1006,7 @@ void MusicWheel::FilterWheelItemDatas(std::vector<MusicWheelItemData *> &aUnFilt
aiRemove[i] = true;
continue;
}
// if AutoSetStyle, make sure the song is playable in the end.
if (!SongUtil::IsSongPlayable(pSong))
{
@@ -1021,7 +1023,7 @@ void MusicWheel::FilterWheelItemDatas(std::vector<MusicWheelItemData *> &aUnFilt
}
/* Filter out the songs we're removing. */
aFilteredData.reserve( unfilteredSize );
for( unsigned i=0; i< unfilteredSize; i++ )
{
@@ -1293,7 +1295,7 @@ bool MusicWheel::Select() // return true if this selection ends the screen
switch( m_CurWheelItemData[m_iSelection]->m_Type )
{
case WheelItemDataType_Roulette:
case WheelItemDataType_Roulette:
StartRoulette();
return false;
case WheelItemDataType_Random:
@@ -1314,7 +1316,7 @@ bool MusicWheel::Select() // return true if this selection ends the screen
}
}
void MusicWheel::StartRoulette()
void MusicWheel::StartRoulette()
{
MESSAGEMAN->Broadcast("StartRoulette");
m_WheelState = STATE_ROULETTE_SPINNING;
@@ -1408,7 +1410,7 @@ void MusicWheel::SetOpenSection( RString group )
}
// Only show tutorial songs in arcade
if( GAMESTATE->m_PlayMode!=PLAY_MODE_REGULAR &&
if( GAMESTATE->m_PlayMode!=PLAY_MODE_REGULAR &&
d.m_pSong &&
d.m_pSong->IsTutorial() )
continue;
@@ -1589,14 +1591,14 @@ Song* MusicWheel::GetSelectedSong()
}
/* Find a random song. If possible, find one that has the preferred difficulties of
* each player. Prefer songs in the active group, if any.
* each player. Prefer songs in the active group, if any.
*
* Note that if this is called, we *must* find a song. We will only be called if
* the active sort has at least one song, but there may be no open group. This means
* that any filters and preferences applied here must be optional. */
Song *MusicWheel::GetPreferredSelectionForRandomOrPortal()
{
// probe to find a song that has the preferred
// probe to find a song that has the preferred
// difficulties of each player
std::vector<Difficulty> vDifficultiesToRequire;
FOREACH_HumanPlayer(p)
@@ -1604,9 +1606,9 @@ Song *MusicWheel::GetPreferredSelectionForRandomOrPortal()
if( GAMESTATE->m_PreferredDifficulty[p] == Difficulty_Invalid )
continue; // skip
// TRICKY: Don't require that edits be present if perferred
// difficulty is Difficulty_Edit. Otherwise, players could use this
// to set up a 100% chance of getting a particular locked song by
// TRICKY: Don't require that edits be present if perferred
// difficulty is Difficulty_Edit. Otherwise, players could use this
// to set up a 100% chance of getting a particular locked song by
// having a single edit for a locked song.
if( GAMESTATE->m_PreferredDifficulty[p] == Difficulty_Edit )
continue; // skip
@@ -1737,7 +1739,7 @@ LUA_REGISTER_DERIVED_CLASS( MusicWheel, WheelBase )
/*
* (c) 2001-2004 Chris Danford, Chris Gomez, Glenn Maynard
* All rights reserved.
*
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
@@ -1747,7 +1749,7 @@ LUA_REGISTER_DERIVED_CLASS( MusicWheel, WheelBase )
* copyright notice(s) and this permission notice appear in all copies of
* the Software and that both the above copyright notice(s) and this
* permission notice appear in supporting documentation.
*
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
+59 -57
View File
@@ -9,6 +9,8 @@
#include "GameState.h"
#include "RadarValues.h"
#include "TimingData.h"
#include <cmath>
#include <utility>
// TODO: Remove these constants that aren't time signature-aware
@@ -29,7 +31,7 @@ NoteType NoteDataUtil::GetSmallestNoteTypeInRange( const NoteData &n, int iStart
FOREACH_ENUM(NoteType, nt)
{
float fBeatSpacing = NoteTypeToBeat( nt );
int iRowSpacing = lrintf( fBeatSpacing * ROWS_PER_BEAT );
int iRowSpacing = std::lrint( fBeatSpacing * ROWS_PER_BEAT );
bool bFoundSmallerNote = false;
// for each index in this measure
@@ -37,7 +39,7 @@ NoteType NoteDataUtil::GetSmallestNoteTypeInRange( const NoteData &n, int iStart
{
if( i % iRowSpacing == 0 )
continue; // skip
if( !n.IsRowEmpty(i) )
{
bFoundSmallerNote = true;
@@ -161,7 +163,7 @@ static void LoadFromSMNoteDataStringWithPlayer( NoteData& out, const RString &sS
case 'L': tn = TAP_ORIGINAL_LIFT; break;
case 'F': tn = TAP_ORIGINAL_FAKE; break;
// case 'I': tn = TAP_ORIGINAL_ITEM; break;
default:
default:
/* Invalid data. We don't want to assert, since there might
* simply be invalid data in an .SM, and we don't want to die
* due to invalid data. We should probably check for this when
@@ -375,7 +377,7 @@ void NoteDataUtil::GetSMNoteDataString( const NoteData &in, RString &sRet )
if( nt == NoteType_Invalid )
iRowSpacing = 1;
else
iRowSpacing = lrintf( NoteTypeToBeat(nt) * ROWS_PER_BEAT );
iRowSpacing = std::lrint( NoteTypeToBeat(nt) * ROWS_PER_BEAT );
// (verify first)
// iRowSpacing = BeatToNoteRow( NoteTypeToBeat(nt) );
@@ -408,7 +410,7 @@ void NoteDataUtil::GetSMNoteDataString( const NoteData &in, RString &sRet )
case TapNoteType_AutoKeysound: c = 'K'; break;
case TapNoteType_Lift: c = 'L'; break;
case TapNoteType_Fake: c = 'F'; break;
default:
default:
c = '\0';
FAIL_M(ssprintf("Invalid tap note type: %i", tn.type));
}
@@ -500,7 +502,7 @@ void NoteDataUtil::LoadTransformedSlidingWindow( const NoteData &in, NoteData &o
{
// reset all notes
out.Init();
if( in.GetNumTracks() > iNewNumTracks )
{
// Use a different algorithm for reducing tracks.
@@ -515,7 +517,7 @@ void NoteDataUtil::LoadTransformedSlidingWindow( const NoteData &in, NoteData &o
int iCurTrackOffset = 0;
int iTrackOffsetMin = 0;
int iTrackOffsetMax = abs( iNewNumTracks - in.GetNumTracks() );
int iTrackOffsetMax = std::abs( iNewNumTracks - in.GetNumTracks() );
int bOffsetIncreasing = true;
int iLastMeasure = 0;
@@ -574,7 +576,7 @@ void PlaceAutoKeysound( NoteData &out, int row, TapNote akTap )
int iNewNumTracks = out.GetNumTracks();
bool bFoundEmptyTrack = false;
int iRowsToLook[3] = {0, -1, 1};
for( int j = 0; j < 3; j ++ )
{
int r = iRowsToLook[j] + row;
@@ -593,7 +595,7 @@ void PlaceAutoKeysound( NoteData &out, int row, TapNote akTap )
if( bFoundEmptyTrack )
break;
}
if( iEmptyTrack != -1 )
{
akTap.type = TapNoteType_AutoKeysound;
@@ -670,14 +672,14 @@ void NoteDataUtil::LoadOverlapped( const NoteData &in, NoteData &out, int iNewNu
out.SetTapNote( iTrackTo, iEndIndex, tnTail );
}
}
// find empty track for autokeysounds in 2 next rows, so you can hear most autokeysounds
for( int iTrackFrom = 0; iTrackFrom < in.GetNumTracks(); ++iTrackFrom )
{
const TapNote &tnFrom = in.GetTapNote( iTrackFrom, row );
if( tnFrom.type != TapNoteType_AutoKeysound )
continue;
PlaceAutoKeysound( out, row, tnFrom );
}
}
@@ -1217,7 +1219,7 @@ void NoteDataUtil::RemoveSimultaneousNotes( NoteData &in, int iMaxSimultaneous,
{
// Do this per part.
std::vector<NoteData> vParts;
SplitCompositeNoteData( in, vParts );
for (NoteData &nd : vParts)
RemoveSimultaneousNotes( nd, iMaxSimultaneous, iStartIndex, iEndIndex );
@@ -1329,7 +1331,7 @@ void NoteDataUtil::RemoveAllButPlayer( NoteData &inout, PlayerNumber pn )
for( int track = 0; track < inout.GetNumTracks(); ++track )
{
NoteData::iterator i = inout.begin( track );
while( i != inout.end(track) )
{
if( i->second.pn != pn && i->second.pn != PLAYER_INVALID )
@@ -1804,7 +1806,7 @@ static void GetTrackMapping( StepsType st, NoteDataUtil::TrackMapping tt, int Nu
iTakeFromTrack[6]= 1;
iTakeFromTrack[7]= 0;
break;
default:
default:
break;
}
break;
@@ -1861,7 +1863,7 @@ static void HyperShuffleNotes( NoteData &inout, int iStartIndex, int iEndIndex)
int iNumTracks = inout.GetNumTracks();
std::vector<int> viHoldEndRows(iNumTracks, -1);
// A "free track" is a track that is not part of a hold and is therefore
// free to be shuffled into.
int iFreeTracks = iNumTracks;
@@ -1875,7 +1877,7 @@ static void HyperShuffleNotes( NoteData &inout, int iStartIndex, int iEndIndex)
{
int iTargetRow = iStartIndex;
if ( inout.GetPrevTapNoteRowForTrack(track, iTargetRow) )
if ( inout.GetPrevTapNoteRowForTrack(track, iTargetRow) )
{
const TapNote &tn = inout.GetTapNote(track, iTargetRow);
@@ -1889,7 +1891,7 @@ static void HyperShuffleNotes( NoteData &inout, int iStartIndex, int iEndIndex)
viHoldEndRows[track] = iHoldEndRow;
iFreeTracks--;
}
}
}
}
}
}
@@ -1983,7 +1985,7 @@ static void HyperShuffleNotes( NoteData &inout, int iStartIndex, int iEndIndex)
// If it's a hold, mark this track occupied by a hold until its end.
if( current_tn.type == TapNoteType_HoldHead )
{
ASSERT_M(viHoldEndRows[targetTrack] == -1,
ASSERT_M(viHoldEndRows[targetTrack] == -1,
ssprintf("Tried to insert a hold into another hold (row %d, track %d)", r, targetTrack));
iFreeTracks--;
viHoldEndRows[targetTrack] = r + current_tn.iDuration;
@@ -2062,7 +2064,7 @@ static void SuperShuffleTaps( NoteData &inout, int iStartIndex, int iEndIndex )
const TapNote tnTemp = tn1;
inout.SetTapNote( t1, r, tn2 );
inout.SetTapNote( t2, r, tnTemp );
break; // done swapping
}
}
@@ -2143,7 +2145,7 @@ void NoteDataUtil::SwapSides( NoteData &inout )
void NoteDataUtil::Little( NoteData &inout, int iStartIndex, int iEndIndex )
{
// filter out all non-quarter notes
for( int t=0; t<inout.GetNumTracks(); t++ )
for( int t=0; t<inout.GetNumTracks(); t++ )
{
FOREACH_NONEMPTY_ROW_IN_TRACK_RANGE( inout, t, i, iStartIndex, iEndIndex )
{
@@ -2183,12 +2185,12 @@ void NoteDataUtil::Wide( NoteData &inout, int iStartIndex, int iEndIndex )
bSpaceAroundIsEmpty = false;
break;
}
if( !bSpaceAroundIsEmpty )
continue; // skip
// add a note determinitsitcally
int iBeat = lrintf( NoteRowToBeat(i) );
int iBeat = std::lrint( NoteRowToBeat(i) );
int iTrackOfNote = inout.GetFirstTrackWithTap(i);
int iTrackToAdd = iTrackOfNote + (iBeat%5)-2; // won't be more than 2 tracks away from the existing note
CLAMP( iTrackToAdd, 0, inout.GetNumTracks()-1 );
@@ -2234,12 +2236,12 @@ void NoteDataUtil::Skippy( NoteData &inout, int iStartIndex, int iEndIndex )
InsertIntelligentTaps( inout, BeatToNoteRow(1.0f), BeatToNoteRow(0.75f),BeatToNoteRow(1.0f), true,iStartIndex,iEndIndex );
}
void NoteDataUtil::InsertIntelligentTaps(
NoteData &inout,
int iWindowSizeRows,
int iInsertOffsetRows,
int iWindowStrideRows,
bool bSkippy,
void NoteDataUtil::InsertIntelligentTaps(
NoteData &inout,
int iWindowSizeRows,
int iInsertOffsetRows,
int iWindowStrideRows,
bool bSkippy,
int iStartIndex,
int iEndIndex )
{
@@ -2271,7 +2273,7 @@ void NoteDataUtil::InsertIntelligentTaps(
if( inout.GetNumTapNonEmptyTracks(iRowLater)!=1 || inout.GetNumTracksWithTapOrHoldHead(iRowLater)!=1 )
continue;
// there is a 4th and 8th note surrounding iRowBetween
// don't insert a new note if there's already one within this interval
bool bNoteInMiddle = false;
for( int t = 0; t < inout.GetNumTracks(); ++t )
@@ -2294,7 +2296,7 @@ void NoteDataUtil::InsertIntelligentTaps(
{
iTrackOfNoteToAdd = iTrackOfNoteEarlier;
}
else if( abs(iTrackOfNoteEarlier-iTrackOfNoteLater) >= 2 )
else if( std::abs(iTrackOfNoteEarlier-iTrackOfNoteLater) >= 2 )
{
// try to choose a track between the earlier and later notes
iTrackOfNoteToAdd = std::min(iTrackOfNoteEarlier,iTrackOfNoteLater)+1;
@@ -2400,7 +2402,7 @@ void NoteDataUtil::AddMines( NoteData &inout, int iStartIndex, int iEndIndex )
for( int t=0; t<inout.GetNumTracks(); t++ )
if( inout.GetTapNote(t,r).type == TapNoteType_Tap )
inout.SetTapNote(t,r,TAP_ADDITION_MINE);
iRowCount = 0;
if( iPlaceEveryRows == 6 )
iPlaceEveryRows = 7;
@@ -2427,7 +2429,7 @@ void NoteDataUtil::AddMines( NoteData &inout, int iStartIndex, int iEndIndex )
int iMineRangeEnd = iMineRow + BeatToNoteRow( 0.5f ) - 1;
if( !inout.IsRangeEmpty(iTrack, iMineRangeBegin, iMineRangeEnd) )
continue;
// Add a mine right after the hold end.
inout.SetTapNote( iTrack, iMineRow, TAP_ADDITION_MINE );
@@ -2486,7 +2488,7 @@ void NoteDataUtil::Echo( NoteData &inout, int iStartIndex, int iEndIndex )
// don't lay if holding 2 already
if( viTracks.size() >= 2 )
continue; // don't lay
// don't lay echos on top of a HoldNote
if( find(viTracks.begin(),viTracks.end(),iEchoTrack) != viTracks.end() )
continue; // don't lay
@@ -2531,7 +2533,7 @@ void NoteDataUtil::ConvertTapsToHolds( NoteData &inout, int iSimultaneousHolds,
{
r2 = next_row;
// If there are two taps in a row on the same track,
// If there are two taps in a row on the same track,
// don't convert the earlier one to a hold.
if( inout.GetTapNote(t,r2).type != TapNoteType_Empty )
{
@@ -2609,7 +2611,7 @@ void NoteDataUtil::Stomp( NoteData &inout, StepsType st, int iStartIndex, int iE
inout.SetTapNote( iOppositeTrack, r, TAP_ADDITION_TAP );
}
}
}
}
inout.RevalidateATIs(std::vector<int>(), false);
}
@@ -2628,7 +2630,7 @@ void NoteDataUtil::SnapToNearestNoteType( NoteData &inout, NoteType nt1, NoteTyp
int iNewIndex1 = Quantize( iOldIndex, BeatToNoteRow(fSnapInterval1) );
int iNewIndex2 = Quantize( iOldIndex, BeatToNoteRow(fSnapInterval2) );
bool bNewBeat1IsCloser = abs(iNewIndex1-iOldIndex) < abs(iNewIndex2-iOldIndex);
bool bNewBeat1IsCloser = std::abs(iNewIndex1-iOldIndex) < std::abs(iNewIndex2-iOldIndex);
int iNewIndex = bNewBeat1IsCloser? iNewIndex1 : iNewIndex2;
for( int c=0; c<inout.GetNumTracks(); c++ )
@@ -2653,7 +2655,7 @@ void NoteDataUtil::SnapToNearestNoteType( NoteData &inout, NoteType nt1, NoteTyp
* downwards. Make sure there isn't anything else in the new range. */
inout.ClearRangeForTrack( iNewIndex, iNewIndex+tnNew.iDuration+1, c );
}
inout.SetTapNote( c, iNewIndex, tnNew );
}
}
@@ -2795,7 +2797,7 @@ struct ValidRow
};
#define T true
#define f false
const ValidRow g_ValidRows[] =
const ValidRow g_ValidRows[] =
{
{ StepsType_dance_double, { T,T,T,T,f,f,f,f } },
{ StepsType_dance_double, { f,T,T,T,T,f,f,f } },
@@ -2906,7 +2908,7 @@ void NoteDataUtil::TransformNoteData( NoteData &nd, TimingData const& timing_dat
if( po.m_bTransforms[PlayerOptions::TRANSFORM_QUICK] ) NoteDataUtil::Quick( nd, iStartIndex, iEndIndex );
if( po.m_bTransforms[PlayerOptions::TRANSFORM_BMRIZE] ) NoteDataUtil::BMRize( nd, iStartIndex, iEndIndex );
// Skippy will still add taps to places that the other
// Skippy will still add taps to places that the other
// AddIntelligentTaps above won't.
if( po.m_bTransforms[PlayerOptions::TRANSFORM_SKIPPY] ) NoteDataUtil::Skippy( nd, iStartIndex, iEndIndex );
@@ -2918,8 +2920,8 @@ void NoteDataUtil::TransformNoteData( NoteData &nd, TimingData const& timing_dat
if( po.m_bTransforms[PlayerOptions::TRANSFORM_WIDE] ) NoteDataUtil::Wide( nd, iStartIndex, iEndIndex );
if( po.m_bTransforms[PlayerOptions::TRANSFORM_STOMP] ) NoteDataUtil::Stomp( nd, st, iStartIndex, iEndIndex );
// Transforms that add holds go last. If they went first, most tap-adding
// transforms wouldn't do anything because tap-adding transforms skip areas
// Transforms that add holds go last. If they went first, most tap-adding
// transforms wouldn't do anything because tap-adding transforms skip areas
// where there's a hold.
if( po.m_bTransforms[PlayerOptions::TRANSFORM_PLANTED] ) NoteDataUtil::Planted( nd, iStartIndex, iEndIndex );
if( po.m_bTransforms[PlayerOptions::TRANSFORM_FLOORED] ) NoteDataUtil::Floored( nd, iStartIndex, iEndIndex );
@@ -2960,9 +2962,9 @@ void NoteDataUtil::AddTapAttacks( NoteData &nd, Song* pSong )
TapNote tn(
TapNoteType_Attack,
TapNoteSubType_Invalid,
TapNoteSource_Original,
TapNoteSource_Original,
szAttacks[RandomInt(ARRAYLEN(szAttacks))],
15.0f,
15.0f,
-1 );
nd.SetTapNote( iTrack, BeatToNoteRow(fBeat), tn );
}
@@ -2972,22 +2974,22 @@ void NoteDataUtil::AddTapAttacks( NoteData &nd, Song* pSong )
void NoteDataUtil::Scale( NoteData &nd, float fScale )
{
ASSERT( fScale > 0 );
NoteData ndOut;
ndOut.SetNumTracks( nd.GetNumTracks() );
for( int t=0; t<nd.GetNumTracks(); t++ )
{
for( NoteData::const_iterator iter = nd.begin(t); iter != nd.end(t); ++iter )
{
TapNote tn = iter->second;
int iNewRow = lrintf( fScale * iter->first );
int iNewDuration = lrintf( fScale * (iter->first + tn.iDuration) );
int iNewRow = std::lrint( fScale * iter->first );
int iNewDuration = std::lrint( fScale * (iter->first + tn.iDuration) );
tn.iDuration = iNewDuration;
ndOut.SetTapNote( t, iNewRow, tn );
}
}
nd.swap( ndOut );
nd.RevalidateATIs(std::vector<int>(), false);
}
@@ -2998,9 +3000,9 @@ static inline int GetScaledRow( float fScale, int iStartIndex, int iEndIndex, in
if( iRow < iStartIndex )
return iRow;
else if( iRow > iEndIndex )
return iRow + lrintf( (iEndIndex - iStartIndex) * (fScale - 1) );
return iRow + std::lrint( (iEndIndex - iStartIndex) * (fScale - 1) );
else
return lrintf( (iRow - iStartIndex) * fScale ) + iStartIndex;
return std::lrint( (iRow - iStartIndex) * fScale ) + iStartIndex;
}
void NoteDataUtil::ScaleRegion( NoteData &nd, float fScale, int iStartIndex, int iEndIndex )
@@ -3008,10 +3010,10 @@ void NoteDataUtil::ScaleRegion( NoteData &nd, float fScale, int iStartIndex, int
ASSERT( fScale > 0 );
ASSERT( iStartIndex < iEndIndex );
ASSERT( iStartIndex >= 0 );
NoteData ndOut;
ndOut.SetNumTracks( nd.GetNumTracks() );
for( int t=0; t<nd.GetNumTracks(); t++ )
{
for( NoteData::const_iterator iter = nd.begin(t); iter != nd.end(t); ++iter )
@@ -3023,7 +3025,7 @@ void NoteDataUtil::ScaleRegion( NoteData &nd, float fScale, int iStartIndex, int
ndOut.SetTapNote( t, iNewRow, tn );
}
}
nd.swap( ndOut );
nd.RevalidateATIs(std::vector<int>(), false);
}
@@ -3036,7 +3038,7 @@ void NoteDataUtil::InsertRows( NoteData &nd, int iStartIndex, int iRowsToAdd )
temp.SetNumTracks( nd.GetNumTracks() );
temp.CopyRange( nd, iStartIndex, MAX_NOTE_ROW );
nd.ClearRange( iStartIndex, MAX_NOTE_ROW );
nd.CopyRange( temp, 0, MAX_NOTE_ROW, iStartIndex + iRowsToAdd );
nd.CopyRange( temp, 0, MAX_NOTE_ROW, iStartIndex + iRowsToAdd );
nd.RevalidateATIs(std::vector<int>(), false);
}
@@ -3048,7 +3050,7 @@ void NoteDataUtil::DeleteRows( NoteData &nd, int iStartIndex, int iRowsToDelete
temp.SetNumTracks( nd.GetNumTracks() );
temp.CopyRange( nd, iStartIndex + iRowsToDelete, MAX_NOTE_ROW );
nd.ClearRange( iStartIndex, MAX_NOTE_ROW );
nd.CopyRange( temp, 0, MAX_NOTE_ROW, iStartIndex );
nd.CopyRange( temp, 0, MAX_NOTE_ROW, iStartIndex );
nd.RevalidateATIs(std::vector<int>(), false);
}
@@ -3213,7 +3215,7 @@ unsigned int NoteDataUtil::GetTotalHoldTicks( NoteData* nd, const TimingData* td
/*
* (c) 2001-2004 Chris Danford, Glenn Maynard
* All rights reserved.
*
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
@@ -3223,7 +3225,7 @@ unsigned int NoteDataUtil::GetTotalHoldTicks( NoteData* nd, const TimingData* td
* copyright notice(s) and this permission notice appear in all copies of
* the Software and that both the above copyright notice(s) and this
* permission notice appear in supporting documentation.
*
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
+23 -21
View File
@@ -19,6 +19,8 @@
#include "Sprite.h"
#include "Style.h"
#include <cmath>
static Preference<bool> g_bRenderEarlierNotesOnTop( "RenderEarlierNotesOnTop", false );
static const double PI_180= PI / 180.0;
@@ -664,13 +666,13 @@ void NoteDisplay::SetActiveFrame( float fNoteBeat, Actor &actorToSet, float fAni
/* -inf ... inf */
float fBeatOrSecond = cache->m_bAnimationBasedOnBeats ? m_pPlayerState->m_Position.m_fSongBeat : m_pPlayerState->m_Position.m_fMusicSeconds;
/* -len ... +len */
float fPercentIntoAnimation = fmodf( fBeatOrSecond, fAnimationLength );
float fPercentIntoAnimation = std::fmod( fBeatOrSecond, fAnimationLength );
/* -1 ... 1 */
fPercentIntoAnimation /= fAnimationLength;
if( bVivid )
{
float fNoteBeatFraction = fmodf( fNoteBeat, 1.0f );
float fNoteBeatFraction = std::fmod( fNoteBeat, 1.0f );
const float fInterval = 1.f / fAnimationLength;
fPercentIntoAnimation += QuantizeDown( fNoteBeatFraction, fInterval );
@@ -776,7 +778,7 @@ void NoteDisplay::DrawHoldPart(std::vector<Sprite*> &vpSpr,
float y_start_pos = (part_type == hpt_body) ? part_args.y_top : std::max(part_args.y_top, part_args.y_start_pos);
if (part_args.y_top < part_args.y_start_pos - unzoomed_frame_height)
{
y_start_pos = fmod((y_start_pos - part_args.y_start_pos), unzoomed_frame_height) + part_args.y_start_pos;
y_start_pos = std::fmod((y_start_pos - part_args.y_start_pos), unzoomed_frame_height) + part_args.y_start_pos;
}
float y_end_pos = std::min(part_args.y_bottom, part_args.y_end_pos);
const float color_scale= glow ? 1 : part_args.color_scale;
@@ -800,7 +802,7 @@ void NoteDisplay::DrawHoldPart(std::vector<Sprite*> &vpSpr,
{
float tex_coord_bottom= SCALE(part_args.y_bottom - part_args.y_top,
0, unzoomed_frame_height, rect.top, rect.bottom);
float want_tex_coord_bottom = ceilf(tex_coord_bottom - 0.0001f);
float want_tex_coord_bottom = std::ceil(tex_coord_bottom - 0.0001f);
add_to_tex_coord = want_tex_coord_bottom - tex_coord_bottom;
}
@@ -811,7 +813,7 @@ void NoteDisplay::DrawHoldPart(std::vector<Sprite*> &vpSpr,
const float fDistFromTop = y_start_pos - part_args.y_top;
float fTexCoordTop = SCALE(fDistFromTop, 0, unzoomed_frame_height, rect.top, rect.bottom);
fTexCoordTop += add_to_tex_coord;
add_to_tex_coord -= floorf(fTexCoordTop);
add_to_tex_coord -= std::floor(fTexCoordTop);
}
}
// The bottom caps mysteriously hate me and their texture coords need to be
@@ -855,7 +857,7 @@ void NoteDisplay::DrawHoldPart(std::vector<Sprite*> &vpSpr,
const float fYOffset= ArrowEffects::GetYOffsetFromYPos(column_args.column, fY, m_fYReverseOffsetPixels);
ae_zoom = ArrowEffects::GetZoom(m_pPlayerState, fYOffset, column_args.column);
float cur_beat= part_args.top_beat;
if(part_args.top_beat != part_args.bottom_beat)
{
@@ -1006,7 +1008,7 @@ void NoteDisplay::DrawHoldPart(std::vector<Sprite*> &vpSpr,
// or else hold ends don't look right.
const float fPulseInnerAdj = ArrowEffects::GetPulseInner();
const float fVariableZoom = ArrowEffects::GetZoomVariable(fYOffset, column_args.column, 1) / fPulseInnerAdj;
const float fDistFromTop = (fY - y_start_pos) / ae_zoom;
float fTexCoordTop = SCALE(fDistFromTop, 0, unzoomed_frame_height, rect.top, rect.bottom * fVariableZoom);
fTexCoordTop += add_to_tex_coord;
@@ -1078,7 +1080,7 @@ void NoteDisplay::DrawHoldBodyInternal(std::vector<Sprite*>& sprite_top,
part_args.y_top = y_tail + overlap_hack;
part_args.y_bottom = tail_plus_bottom + overlap_hack;
part_args.top_beat = bottom_beat;
part_args.y_start_pos = fmaxf(part_args.y_start_pos, y_head);
part_args.y_start_pos = std::fmax(part_args.y_start_pos, y_head);
part_args.wrapping = false;
DrawHoldPart(sprite_bottom, field_args, column_args, part_args, glow, hpt_bottom);
}
@@ -1199,18 +1201,18 @@ void NoteDisplay::DrawHold(const TapNote& tn,
; // use the default values filled in above
else
fStartYOffset = ArrowEffects::GetYOffset( m_pPlayerState, column_args.column, fStartBeat, fThrowAway, bStartIsPastPeak );
float fEndPeakYOffset = 0;
bool bEndIsPastPeak = false;
float fEndYOffset = ArrowEffects::GetYOffset( m_pPlayerState, column_args.column, NoteRowToBeat(iEndRow), fEndPeakYOffset, bEndIsPastPeak );
// In boomerang, the arrows reverse direction at Y offset value fPeakAtYOffset.
// If fPeakAtYOffset lies inside of the hold we're drawing, then the we
// want to draw the tail at that max Y offset, or else the hold will appear
// In boomerang, the arrows reverse direction at Y offset value fPeakAtYOffset.
// If fPeakAtYOffset lies inside of the hold we're drawing, then the we
// want to draw the tail at that max Y offset, or else the hold will appear
// to magically grow as the tail approaches the max Y offset.
if( bStartIsPastPeak && !bEndIsPastPeak )
fEndYOffset = fEndPeakYOffset; // use the calculated PeakYOffset so that long holds don't appear to grow
// Swap in reverse, so fStartYOffset is always the offset higher on the screen.
if( bReverse )
std::swap( fStartYOffset, fEndYOffset );
@@ -1352,15 +1354,15 @@ void NoteDisplay::DrawActor(const TapNote& tn, Actor* pActor, NotePart part,
color = clamp( color, 0.0f, (float) (cache->m_iNoteColorCount[part]-1) );
break;
case NoteColorType_Progress:
color = fmodf( ceilf( fBeat * cache->m_iNoteColorCount[part] ), (float)cache->m_iNoteColorCount[part] );
color = std::fmod( std::ceil( fBeat * cache->m_iNoteColorCount[part] ), (float)cache->m_iNoteColorCount[part] );
break;
case NoteColorType_ProgressAlternate:
fScaledBeat = fBeat * cache->m_iNoteColorCount[part];
if( fScaledBeat - int64_t(fScaledBeat) == 0.0f )
//we're on a boundary, so move to the previous frame.
//doing it this way ensures that fScaledBeat is never negative so fmodf works.
//doing it this way ensures that fScaledBeat is never negative so std::fmod works.
fScaledBeat += cache->m_iNoteColorCount[part] - 1;
color = fmodf( ceilf( fScaledBeat ), (float)cache->m_iNoteColorCount[part] );
color = std::fmod( std::ceil( fScaledBeat ), (float)cache->m_iNoteColorCount[part] );
break;
default:
FAIL_M(ssprintf("Invalid NoteColorType: %i", cache->m_NoteColorType[part]));
@@ -1429,17 +1431,17 @@ void NoteDisplay::DrawTap(const TapNote& tn,
pActor = GetHoldActor( m_HoldHead, NotePart_HoldHead, fBeat, true, false );
}
}
else if( bOnSameRowAsHoldStart && cache->m_bDrawHoldHeadForTapsOnSameRow )
{
pActor = GetHoldActor( m_HoldHead, NotePart_HoldHead, fBeat, false, false );
}
else if( bOnSameRowAsRollStart && cache->m_bDrawRollHeadForTapsOnSameRow )
{
pActor = GetHoldActor( m_HoldHead, NotePart_HoldHead, fBeat, true, false );
}
else
{
pActor = GetTapActor( m_TapNote, NotePart_Tap, fBeat );
@@ -1743,7 +1745,7 @@ LUA_REGISTER_DERIVED_CLASS(NoteColumnRenderer, Actor)
* NoteColumnRenderer and associated spline stuff (c) Eric Reese 2014-2015
* (c) 2001-2006 Brian Bugh, Ben Nordstrom, Chris Danford, Steve Checkoway
* All rights reserved.
*
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
@@ -1753,7 +1755,7 @@ LUA_REGISTER_DERIVED_CLASS(NoteColumnRenderer, Actor)
* copyright notice(s) and this permission notice appear in all copies of
* the Software and that both the above copyright notice(s) and this
* permission notice appear in supporting documentation.
*
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
+24 -22
View File
@@ -15,12 +15,14 @@
#include "PlayerState.h"
#include "Style.h"
#include "CommonMetrics.h"
#include <float.h>
#include "BackgroundUtil.h"
#include "Course.h"
#include "NoteData.h"
#include "RageDisplay.h"
#include <cfloat>
#include <cmath>
float FindFirstDisplayedBeat( const PlayerState* pPlayerState, int iDrawDistanceAfterTargetsPixels );
float FindLastDisplayedBeat( const PlayerState* pPlayerState, int iDrawDistanceBeforeTargetsPixels );
@@ -203,7 +205,7 @@ void NoteField::Init( const PlayerState* pPlayerState, float fYReverseOffsetPixe
HandleMessage(msg);
}
void NoteField::Load(
void NoteField::Load(
const NoteData *pNoteData,
int iDrawDistanceAfterTargetsPixels,
int iDrawDistanceBeforeTargetsPixels )
@@ -622,26 +624,26 @@ static int GetNumNotesRange( const PlayerState* pPlayerState, float fLow, float
float FindFirstDisplayedBeat( const PlayerState* pPlayerState, int iDrawDistanceAfterTargetsPixels )
{
float fLow = 0, fHigh = pPlayerState->GetDisplayedPosition().m_fSongBeat;
bool bHasCache = pPlayerState->m_CacheNoteStat.size() > 0;
if( !bHasCache )
{
fLow = fHigh - 4.0f;
}
const int NUM_ITERATIONS = 24;
const int MAX_NOTES_AFTER = 64;
float fFirstBeatToDraw = fLow;
for( int i = 0; i < NUM_ITERATIONS; i ++ )
{
float fMid = (fLow + fHigh) / 2.0f;
bool bIsPastPeakYOffset;
float fPeakYOffset;
float fYOffset = ArrowEffects::GetYOffset( pPlayerState, 0, fMid, fPeakYOffset, bIsPastPeakYOffset, true );
@@ -655,7 +657,7 @@ float FindFirstDisplayedBeat( const PlayerState* pPlayerState, int iDrawDistance
{
fHigh = fMid;
}
}
return fFirstBeatToDraw;
@@ -707,7 +709,7 @@ bool NoteField::IsOnScreen( float fBeat, int iCol, int iDrawDistanceAfterTargets
// IMPORTANT: Do not modify this function without also modifying the
// version that is in NoteDisplay.cpp or coming up with a good way to
// merge them. -Kyz
// TRICKY: If boomerang is on, then ones in the range
// TRICKY: If boomerang is on, then ones in the range
// [iFirstRowToDraw,iLastRowToDraw] aren't necessarily visible.
// Test to see if this beat is visible before drawing.
float fYOffset = ArrowEffects::GetYOffset( m_pPlayerState, iCol, fBeat );
@@ -724,7 +726,7 @@ void NoteField::CalcPixelsBeforeAndAfterTargets()
const PlayerOptions& curr_options= m_pPlayerState->m_PlayerOptions.GetCurrent();
// Adjust draw range depending on some effects
m_FieldRenderArgs.draw_pixels_after_targets= m_iDrawDistanceAfterTargetsPixels * (1.f + curr_options.m_fDrawSizeBack);
// HACK: If boomerang and centered are on, then we want to draw much
// HACK: If boomerang and centered are on, then we want to draw much
// earlier so that the notes don't pop on screen.
float centered_times_boomerang=
curr_options.m_fScrolls[PlayerOptions::SCROLL_CENTERED] *
@@ -735,8 +737,8 @@ void NoteField::CalcPixelsBeforeAndAfterTargets()
m_iDrawDistanceBeforeTargetsPixels * (1.f + curr_options.m_fDrawSize);
float draw_scale= 1;
draw_scale*= 1 + 0.5f * fabsf(curr_options.m_fPerspectiveTilt);
draw_scale*= 1 + fabsf(curr_options.m_fEffects[PlayerOptions::EFFECT_MINI]);
draw_scale*= 1 + 0.5f * std::abs(curr_options.m_fPerspectiveTilt);
draw_scale*= 1 + std::abs(curr_options.m_fEffects[PlayerOptions::EFFECT_MINI]);
m_FieldRenderArgs.draw_pixels_after_targets=
(int)(m_FieldRenderArgs.draw_pixels_after_targets * draw_scale);
@@ -881,7 +883,7 @@ void NoteField::DrawPrimitives()
const Course *pCourse = GAMESTATE->m_pCurCourse;
if( pCourse )
{
ASSERT_M( GAMESTATE->m_iEditCourseEntryIndex >= 0 && GAMESTATE->m_iEditCourseEntryIndex < (int)pCourse->m_vEntries.size(),
ASSERT_M( GAMESTATE->m_iEditCourseEntryIndex >= 0 && GAMESTATE->m_iEditCourseEntryIndex < (int)pCourse->m_vEntries.size(),
ssprintf("%i",GAMESTATE->m_iEditCourseEntryIndex.Get()) );
const CourseEntry &ce = pCourse->m_vEntries[GAMESTATE->m_iEditCourseEntryIndex];
for (Attack const &a : ce.attacks)
@@ -953,7 +955,7 @@ void NoteField::DrawPrimitives()
viLowestIndex.push_back( j );
}
}
if( viLowestIndex.empty() )
{
FOREACH_BackgroundLayer( j )
@@ -962,7 +964,7 @@ void NoteField::DrawPrimitives()
}
break;
}
if( IS_ON_SCREEN(fLowestBeat) )
{
std::vector<RString> vsBGChanges;
@@ -1019,8 +1021,8 @@ void NoteField::DrawPrimitives()
// lets us draw in big batches.
const Style* pStyle = GAMESTATE->GetCurrentStyle(m_pPlayerState->m_PlayerNumber);
ASSERT_M(m_pNoteData->GetNumTracks() == GAMESTATE->GetCurrentStyle(m_pPlayerState->m_PlayerNumber)->m_iColsPerPlayer,
ssprintf("NumTracks %d != ColsPerPlayer %d",m_pNoteData->GetNumTracks(),
ASSERT_M(m_pNoteData->GetNumTracks() == GAMESTATE->GetCurrentStyle(m_pPlayerState->m_PlayerNumber)->m_iColsPerPlayer,
ssprintf("NumTracks %d != ColsPerPlayer %d",m_pNoteData->GetNumTracks(),
GAMESTATE->GetCurrentStyle(m_pPlayerState->m_PlayerNumber)->m_iColsPerPlayer));
if(*m_FieldRenderArgs.selection_begin_marker != -1 &&
@@ -1282,7 +1284,7 @@ LUA_REGISTER_DERIVED_CLASS(NoteField, ActorFrame)
/*
* (c) 2001-2004 Chris Danford
* All rights reserved.
*
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
@@ -1292,7 +1294,7 @@ LUA_REGISTER_DERIVED_CLASS(NoteField, ActorFrame)
* copyright notice(s) and this permission notice appear in all copies of
* the Software and that both the above copyright notice(s) and this
* permission notice appear in supporting documentation.
*
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
+21 -19
View File
@@ -7,6 +7,8 @@
#include "PlayerNumber.h"
#include "RageLog.h"
#include <cmath>
class XNode;
/** @brief The result of hitting (or missing) a tap note. */
@@ -20,7 +22,7 @@ struct TapNoteResult
/**
* @brief Offset, in seconds, for a tap grade.
*
* Negative numbers mean the note was hit early; positive numbers mean
* Negative numbers mean the note was hit early; positive numbers mean
* it was hit late. These values are only meaningful for graded taps
* (tns >= TNS_W5). */
float fTapNoteOffset;
@@ -48,11 +50,11 @@ struct HoldNoteResult
/**
* @brief the current life of the hold.
*
*
* 1.0 means this HoldNote has full life.
*
*
* 0.0 means this HoldNote is dead.
*
*
* When this value hits 0.0 for the first time, m_HoldScore becomes HNS_LetGo.
* If the life is > 0.0 when the HoldNote ends, then m_HoldScore becomes HNS_Held. */
float fLife;
@@ -152,7 +154,7 @@ struct TapNote
// also used for hold_head only:
int iDuration;
HoldNoteResult HoldResult;
// XML
XNode* CreateNode() const;
void LoadFromNode( const XNode* pNode );
@@ -161,22 +163,22 @@ struct TapNote
void PushSelf( lua_State *L );
TapNote(): type(TapNoteType_Empty), subType(TapNoteSubType_Invalid),
source(TapNoteSource_Original), result(), pn(PLAYER_INVALID), sAttackModifiers(""),
source(TapNoteSource_Original), result(), pn(PLAYER_INVALID), sAttackModifiers(""),
fAttackDurationSeconds(0), iKeysoundIndex(-1), iDuration(0), HoldResult() {}
void Init()
{
type = TapNoteType_Empty;
subType = TapNoteSubType_Invalid;
source = TapNoteSource_Original;
pn = PLAYER_INVALID,
fAttackDurationSeconds = 0.f;
subType = TapNoteSubType_Invalid;
source = TapNoteSource_Original;
pn = PLAYER_INVALID,
fAttackDurationSeconds = 0.f;
iKeysoundIndex = -1;
iDuration = 0;
}
TapNote(
TapNote(
TapNoteType type_,
TapNoteSubType subType_,
TapNoteSource source_,
TapNoteSource source_,
RString sAttackModifiers_,
float fAttackDurationSeconds_,
int iKeysoundIndex_ ):
@@ -251,8 +253,8 @@ const int ROWS_PER_BEAT = 48;
const int MAX_NOTE_ROW = (1<<30);
/** @brief The list of quantized note types allowed at present. */
enum NoteType
{
enum NoteType
{
NOTE_TYPE_4TH, /**< quarter note */
NOTE_TYPE_8TH, /**< eighth note */
NOTE_TYPE_12TH, /**< quarter note triplet */
@@ -280,16 +282,16 @@ bool IsNoteOfType( int row, NoteType t );
/*
inline int BeatToNoteRow( float fBeatNum )
{
float fraction = fBeatNum - truncf(fBeatNum);
float fraction = fBeatNum - std::trunc(fBeatNum);
int integer = int(fBeatNum) * ROWS_PER_BEAT;
return integer + lrintf(fraction * ROWS_PER_BEAT);
return integer + std::lrint(fraction * ROWS_PER_BEAT);
}
*/
/**
* @brief Convert the beat into a note row.
* @param fBeatNum the beat to convert.
* @return the note row. */
inline int BeatToNoteRow( float fBeatNum ) { return lrintf( fBeatNum * ROWS_PER_BEAT ); } // round
inline int BeatToNoteRow( float fBeatNum ) { return std::lrint( fBeatNum * ROWS_PER_BEAT ); } // round
/**
* @brief Convert the beat into a note row without rounding.
* @param fBeatNum the beat to convert.
@@ -353,7 +355,7 @@ inline T ScalePosition( T start, T length, T newLength, T position )
* @author Chris Danford, Glenn Maynard (c) 2001-2004
* @section LICENSE
* All rights reserved.
*
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
@@ -363,7 +365,7 @@ inline T ScalePosition( T start, T length, T newLength, T position )
* copyright notice(s) and this permission notice appear in all copies of
* the Software and that both the above copyright notice(s) and this
* permission notice appear in supporting documentation.
*
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
+23 -21
View File
@@ -11,6 +11,8 @@
#include "Song.h"
#include "Steps.h"
#include <cmath>
RString OptimizeDWIString( RString holds, RString taps );
/**
@@ -43,13 +45,13 @@ static char OptimizeDWIPair( char c1, char c2 )
joins[ cpair('8', 'D') ] = 'K';
joins[ cpair('6', 'D') ] = 'L';
}
if( c1 > c2 )
std::swap( c1, c2 );
std::map<cpair, char>::const_iterator it = joins.find( cpair(c1, c2) );
ASSERT( it != joins.end() );
return it->second;
}
@@ -65,17 +67,17 @@ RString OptimizeDWIString( RString holds, RString taps )
* do eg. 1D, not 2I. */
sort( holds.begin(), holds.end() );
sort( taps.begin(), taps.end() );
/* Combine characters as much as possible. */
RString comb_taps, comb_holds;
/* 24 -> 1 */
while( taps.size() > 1 )
{
comb_taps += OptimizeDWIPair( taps[0], taps[1] );
taps.erase(0, 2);
}
/* 2!24!4 -> 1!1 */
while( holds.size() > 1 )
{
@@ -83,10 +85,10 @@ RString OptimizeDWIString( RString holds, RString taps )
holds.erase(0, 2);
comb_holds += ssprintf( "%c!%c", to, to );
}
ASSERT( taps.size() <= 1 );
ASSERT( holds.size() <= 1 );
/* 24!4 -> 1!4 */
while( holds.size() == 1 && taps.size() == 1 )
{
@@ -95,7 +97,7 @@ RString OptimizeDWIString( RString holds, RString taps )
taps.erase(0, 1);
holds.erase(0, 1);
}
/* Now we have at most one single tap and one hold remaining, and any
* number of taps and holds in comb_taps and comb_holds. */
RString ret;
@@ -104,7 +106,7 @@ RString OptimizeDWIString( RString holds, RString taps )
if( holds.size() == 1 )
ret += ssprintf( "%c!%c", holds[0], holds[0] );
ret += comb_holds;
if( ret.size() == 1 || (ret.size() == 3 && ret[1] == '!') )
return ret;
else
@@ -151,7 +153,7 @@ static RString NotesToDWIString( const TapNote tnCols[6] )
* @param tnCol5 the fifth column.
* @param tnCol6 the sisth column.
* @return the DWI'ed string. */
static RString NotesToDWIString( TapNote tnCol1, TapNote tnCol2, TapNote tnCol3,
static RString NotesToDWIString( TapNote tnCol1, TapNote tnCol2, TapNote tnCol3,
TapNote tnCol4, TapNote tnCol5, TapNote tnCol6 )
{
TapNote tnCols[6];
@@ -199,7 +201,7 @@ static void WriteDWINotesField( RageFile &f, const Steps &out, int start )
switch( nt )
{
case NOTE_TYPE_4TH:
case NOTE_TYPE_8TH:
case NOTE_TYPE_8TH:
fCurrentIncrementer = 1.0/8 * BEATS_PER_MEASURE;
break;
case NOTE_TYPE_12TH:
@@ -242,8 +244,8 @@ static void WriteDWINotesField( RageFile &f, const Steps &out, int start )
case StepsType_dance_single:
case StepsType_dance_couple:
case StepsType_dance_double:
str = NotesToDWIString(
notedata.GetTapNote(start+0, row),
str = NotesToDWIString(
notedata.GetTapNote(start+0, row),
notedata.GetTapNote(start+1, row),
notedata.GetTapNote(start+2, row),
notedata.GetTapNote(start+3, row) );
@@ -255,7 +257,7 @@ static void WriteDWINotesField( RageFile &f, const Steps &out, int start )
notedata.SetTapNote(start+3, row, TAP_EMPTY);
break;
case StepsType_dance_solo:
str = NotesToDWIString(
str = NotesToDWIString(
notedata.GetTapNote(0, row),
notedata.GetTapNote(1, row),
notedata.GetTapNote(2, row),
@@ -280,7 +282,7 @@ static void WriteDWINotesField( RageFile &f, const Steps &out, int start )
switch( nt )
{
case NOTE_TYPE_4TH:
case NOTE_TYPE_8TH:
case NOTE_TYPE_8TH:
break;
case NOTE_TYPE_12TH:
case NOTE_TYPE_24TH:
@@ -360,7 +362,7 @@ bool NotesWriterDWI::Write( RString sPath, const Song &out )
ssprintf("The first BPM Segment must be defined at row 0, not %d!", bpms[0]->GetRow()) );
f.PutLine( ssprintf("#FILE:%s;", DwiEscape(out.m_sMusicFile).c_str()) );
f.PutLine( ssprintf("#BPM:%.3f;", static_cast<BPMSegment *>(bpms[0])->GetBPM()) );
f.PutLine( ssprintf("#GAP:%ld;", -lrintf( out.m_SongTiming.m_fBeat0OffsetInSeconds*1000 )) );
f.PutLine( ssprintf("#GAP:%ld;", -std::lrint( out.m_SongTiming.m_fBeat0OffsetInSeconds*1000 )) );
f.PutLine( ssprintf("#SAMPLESTART:%.3f;", out.m_fMusicSampleStartSeconds) );
f.PutLine( ssprintf("#SAMPLELENGTH:%.3f;", out.m_fMusicSampleLengthSeconds) );
if( out.m_sCDTitleFile.size() )
@@ -393,7 +395,7 @@ bool NotesWriterDWI::Write( RString sPath, const Song &out )
{
const StopSegment *fs = static_cast<StopSegment *>(stops[i]);
f.Write( ssprintf("%.3f=%.3f", fs->GetRow() * 4.0f / ROWS_PER_BEAT,
roundf(fs->GetPause()*1000)) );
std::round(fs->GetPause()*1000)) );
if( i != stops.size()-1 )
f.Write( "," );
}
@@ -414,7 +416,7 @@ bool NotesWriterDWI::Write( RString sPath, const Song &out )
}
const std::vector<Steps*>& vpSteps = out.GetAllSteps();
for( unsigned i=0; i<vpSteps.size(); i++ )
for( unsigned i=0; i<vpSteps.size(); i++ )
{
const Steps* pSteps = vpSteps[i];
if( pSteps->IsAutogen() )
@@ -433,14 +435,14 @@ bool NotesWriterDWI::Write( RString sPath, const Song &out )
f.PutLine( ";" );
}
return true;
}
/*
* (c) 2001-2006 Chris Danford, Glenn Maynard
* All rights reserved.
*
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
@@ -450,7 +452,7 @@ bool NotesWriterDWI::Write( RString sPath, const Song &out )
* copyright notice(s) and this permission notice appear in all copies of
* the Software and that both the above copyright notice(s) and this
* permission notice appear in supporting documentation.
*
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
+14 -12
View File
@@ -11,6 +11,8 @@
#include "Style.h"
#include "ActorUtil.h"
#include <cmath>
const RString NEXT_ROW_NAME = "NextRow";
const RString EXIT_NAME = "Exit";
@@ -20,9 +22,9 @@ RString OptionRow::GetThemedItemText( int iChoice ) const
// HACK: Always theme the NEXT_ROW and EXIT items.
if( m_bFirstItemGoesDown && iChoice == 0 )
s = CommonMetrics::LocalizeOptionItem( NEXT_ROW_NAME, false );
s = CommonMetrics::LocalizeOptionItem( NEXT_ROW_NAME, false );
else if( m_RowType == OptionRow::RowType_Exit )
s = CommonMetrics::LocalizeOptionItem( EXIT_NAME, false );
s = CommonMetrics::LocalizeOptionItem( EXIT_NAME, false );
return s;
}
@@ -165,7 +167,7 @@ void OptionRow::ChoicesChanged( RowType type, bool reset_focus )
std::vector<bool> &vbSelected = m_vbSelected[p];
vbSelected.resize( 0 );
vbSelected.resize( m_pHand->m_Def.m_vsChoices.size(), false );
// set select the first item if a SELECT_ONE row
if( vbSelected.size() && m_pHand->m_Def.m_selectType == SELECT_ONE )
vbSelected[0] = true;
@@ -293,14 +295,14 @@ void OptionRow::InitText( RowType type )
bt.SetText( sText );
fWidth += bt.GetZoomedWidth();
if( c != m_pHand->m_Def.m_vsChoices.size()-1 )
fWidth += m_pParentType->ITEMS_GAP_X;
}
// Try to fit everything on one line.
float fTotalWidth = m_pParentType->ITEMS_END_X - m_pParentType->ITEMS_START_X;
if( fWidth > fTotalWidth )
if( fWidth > fTotalWidth )
{
float fPossibleBaseZoom = fTotalWidth / fWidth;
if( fPossibleBaseZoom >= m_pParentType->ITEMS_MIN_BASE_ZOOM )
@@ -602,7 +604,7 @@ void OptionRow::UpdateEnabledDisabled()
case LAYOUT_SHOW_ALL_IN_ROW:
for( unsigned j=0; j<m_textItems.size(); j++ )
{
if( m_textItems[j]->DestTweenState().diffuse[0] == color )
if( m_textItems[j]->DestTweenState().diffuse[0] == color )
continue;
m_textItems[j]->StopTweening();
@@ -681,9 +683,9 @@ void OptionRow::GetWidthXY( PlayerNumber pn, int iChoiceOnRow, int &iWidthOut, i
{
const BitmapText &text = GetTextItemForRow( pn, iChoiceOnRow );
iWidthOut = lrintf( text.GetZoomedWidth() );
iXOut = lrintf( text.GetDestX() );
iYOut = lrintf( m_Frame.GetDestY() );
iWidthOut = std::lrint( text.GetZoomedWidth() );
iXOut = std::lrint( text.GetDestX() );
iYOut = std::lrint( m_Frame.GetDestY() );
}
int OptionRow::GetOneSelection( PlayerNumber pn, bool bAllowFail ) const
@@ -787,7 +789,7 @@ const OptionRowDefinition &OptionRow::GetRowDef() const
return m_pHand->m_Def;
}
OptionRowDefinition &OptionRow::GetRowDef()
OptionRowDefinition &OptionRow::GetRowDef()
{
return m_pHand->m_Def;
}
@@ -1001,7 +1003,7 @@ LUA_REGISTER_DERIVED_CLASS( OptionRow, ActorFrame )
/*
* (c) 2001-2004 Chris Danford
* All rights reserved.
*
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
@@ -1011,7 +1013,7 @@ LUA_REGISTER_DERIVED_CLASS( OptionRow, ActorFrame )
* copyright notice(s) and this permission notice appear in all copies of
* the Software and that both the above copyright notice(s) and this
* permission notice appear in supporting documentation.
*
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
+5 -3
View File
@@ -4,6 +4,8 @@
#include "ThemeManager.h"
#include "ActorUtil.h"
#include <cmath>
OptionsCursor::OptionsCursor()
{
m_iOriginalLeftX = 0;
@@ -108,7 +110,7 @@ void OptionsCursor::BeginTweening( float fSecs, TweenType tt )
void OptionsCursor::SetBarWidth( int iWidth )
{
float fWidth = ceilf(iWidth/2.0f)*2.0f; // round up to nearest even number
float fWidth = std::ceil(iWidth/2.0f)*2.0f; // round up to nearest even number
m_sprMiddle->ZoomToWidth( fWidth );
@@ -130,7 +132,7 @@ int OptionsCursor::GetBarWidth() const
/*
* (c) 2001-2003 Chris Danford
* All rights reserved.
*
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
@@ -140,7 +142,7 @@ int OptionsCursor::GetBarWidth() const
* copyright notice(s) and this permission notice appear in all copies of
* the Software and that both the above copyright notice(s) and this
* permission notice appear in supporting documentation.
*
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
+71 -69
View File
@@ -41,6 +41,8 @@
#include "LocalizedString.h"
#include "AdjustSync.h"
#include <cmath>
RString ATTACK_DISPLAY_X_NAME( size_t p, size_t both_sides );
void TimingWindowSecondsInit( size_t /*TimingWindow*/ i, RString &sNameOut, float &defaultValueOut );
@@ -289,20 +291,20 @@ Player::~Player()
SAFE_DELETE( m_pIterUncrossedRows );
SAFE_DELETE( m_pIterUnjudgedRows );
SAFE_DELETE( m_pIterUnjudgedMineRows );
}
/* Init() does the expensive stuff: load sounds and noteskins. Load() just loads a NoteData. */
void Player::Init(
const RString &sType,
PlayerState* pPlayerState,
PlayerState* pPlayerState,
PlayerStageStats* pPlayerStageStats,
LifeMeter* pLM,
CombinedLifeMeter* pCombinedLM,
ScoreDisplay* pScoreDisplay,
ScoreDisplay* pSecondaryScoreDisplay,
Inventory* pInventory,
ScoreKeeper* pPrimaryScoreKeeper,
LifeMeter* pLM,
CombinedLifeMeter* pCombinedLM,
ScoreDisplay* pScoreDisplay,
ScoreDisplay* pSecondaryScoreDisplay,
Inventory* pInventory,
ScoreKeeper* pPrimaryScoreKeeper,
ScoreKeeper* pSecondaryScoreKeeper )
{
GRAY_ARROWS_Y_STANDARD.Load( sType, "ReceptorArrowsYStandard" );
@@ -393,7 +395,7 @@ void Player::Init(
m_iLastSeenCombo = 0;
m_bSeenComboYet = false;
// set initial life
if( m_pLifeMeter && m_pPlayerStageStats )
{
@@ -442,20 +444,20 @@ void Player::Init(
float fMaxBPM = 0;
/* TODO: Find a way to not go above a certain BPM range
/* TODO: Find a way to not go above a certain BPM range
* for getting the max BPM. Otherwise, you get songs
* like Tsuhsuixamush, M550, 0.18x speed. Even slow
* speed readers would not generally find this fun.
* -Wolfman2000
*/
// all BPMs are listed and available, so try them first.
// get the maximum listed value for the song or course.
// if the BPMs are < 0, reset and get the actual values.
if( !bpms.IsSecret() )
{
fMaxBPM = (M_MOD_HIGH_CAP > 0 ?
bpms.GetMaxWithin(M_MOD_HIGH_CAP) :
fMaxBPM = (M_MOD_HIGH_CAP > 0 ?
bpms.GetMaxWithin(M_MOD_HIGH_CAP) :
bpms.GetMax());
fMaxBPM = std::max( 0.0f, fMaxBPM );
}
@@ -472,7 +474,7 @@ void Player::Init(
float fMaxForEntry;
if (M_MOD_HIGH_CAP > 0)
e.pSong->m_SongTiming.GetActualBPM( fThrowAway, fMaxForEntry, M_MOD_HIGH_CAP );
else
else
e.pSong->m_SongTiming.GetActualBPM( fThrowAway, fMaxForEntry );
fMaxBPM = std::max( fMaxForEntry, fMaxBPM );
}
@@ -614,9 +616,9 @@ static void GenerateCacheDataStructure(PlayerState *pPlayerState, const NoteData
CacheDisplayedBeat c = { seg->GetBeat(), displayedBeat, seg->GetRatio() };
pPlayerState->m_CacheDisplayedBeat.push_back( c );
}
pPlayerState->m_CacheNoteStat.clear();
NoteData::all_tracks_const_iterator it = notes.GetTapNoteRangeAllTracks( 0, MAX_NOTE_ROW, true );
int count = 0, lastCount = 0;
for( ; !it.IsAtEnd(); ++it )
@@ -648,7 +650,7 @@ void Player::Load()
// TODO: Remove use of PlayerNumber.
PlayerNumber pn = m_pPlayerState->m_PlayerNumber;
bool bOniDead = m_pPlayerState->m_PlayerOptions.GetStage().m_LifeType == LifeType_Battery &&
bool bOniDead = m_pPlayerState->m_PlayerOptions.GetStage().m_LifeType == LifeType_Battery &&
(m_pPlayerStageStats == nullptr || m_pPlayerStageStats->m_bFailed);
/* The editor reuses Players ... so we really need to make sure everything
@@ -721,7 +723,7 @@ void Player::Load()
int iDrawDistanceBeforeTargetsPixels = GAMESTATE->IsEditing() ? 400 : DRAW_DISTANCE_BEFORE_TARGET_PIXELS;
float fNoteFieldMiddle = (GRAY_ARROWS_Y_STANDARD+GRAY_ARROWS_Y_REVERSE)/2;
if( m_pNoteField && !bOniDead )
{
m_pNoteField->SetY( fNoteFieldMiddle );
@@ -733,7 +735,7 @@ void Player::Load()
m_pAttackDisplay->SetX( ATTACK_DISPLAY_X.GetValue(pn, bPlayerUsingBothSides) - 40 );
// set this in Update //m_pAttackDisplay->SetY( bReverse ? ATTACK_DISPLAY_Y_REVERSE : ATTACK_DISPLAY_Y );
// set this in Update
// set this in Update
//m_pJudgment->SetX( JUDGMENT_X.GetValue(pn,bPlayerUsingBothSides) );
//m_pJudgment->SetY( bReverse ? JUDGMENT_Y_REVERSE : JUDGMENT_Y );
@@ -840,7 +842,7 @@ void Player::Update( float fDeltaTime )
ArrowEffects::SetCurrentOptions(&m_pPlayerState->m_PlayerOptions.GetCurrent());
// Optimization: Don't spend time processing the things below that won't show
// Optimization: Don't spend time processing the things below that won't show
// if the Player doesn't show anything on the screen.
if( HasVisibleParts() )
{
@@ -879,7 +881,7 @@ void Player::Update( float fDeltaTime )
float fMiniPercent = m_pPlayerState->m_PlayerOptions.GetCurrent().m_fEffects[PlayerOptions::EFFECT_MINI];
float fTinyPercent = m_pPlayerState->m_PlayerOptions.GetCurrent().m_fEffects[PlayerOptions::EFFECT_TINY];
float fJudgmentZoom = std::min( powf(0.5f, fMiniPercent+fTinyPercent), 1.0f );
float fJudgmentZoom = std::min( std::pow(0.5f, fMiniPercent+fTinyPercent), 1.0f );
// Update Y positions
{
@@ -1042,7 +1044,7 @@ void Player::Update( float fDeltaTime )
continue;
const float notePosition = m_Timing->GetElapsedTimeFromBeat(NoteRowToBeat(row));
const float offset = fabsf((notePosition - musicPosition) / rate);
const float offset = std::abs((notePosition - musicPosition) / rate);
// Skip if we are outside of the largest timing window
if (offset > largestWindow)
@@ -1088,7 +1090,7 @@ void Player::Update( float fDeltaTime )
int iRow = iter.Row();
TrackRowTapNote trtn = { iTrack, iRow, &tn };
/* All holds must be of the same subType because fLife is handled
/* All holds must be of the same subType because fLife is handled
* in different ways depending on the SubType. Handle Rolls one at
* a time and don't mix with holds. */
switch( tn.subType )
@@ -1201,7 +1203,7 @@ void Player::UpdateHoldNotes( int iSongRow, float fDeltaTime, std::vector<TrackR
if( subType == TapNoteSubType_Invalid )
subType = tn.subType;
/* All holds must be of the same subType because fLife is handled
/* All holds must be of the same subType because fLife is handled
* in different ways depending on the SubType. */
ASSERT( tn.subType == subType );
@@ -1264,12 +1266,12 @@ void Player::UpdateHoldNotes( int iSongRow, float fDeltaTime, std::vector<TrackR
TapNoteScore tns = tn.result.tns;
//LOG->Trace( ssprintf("[C++] tap note score: %s",StringConversion::ToString(tns).c_str()) );
// TODO: When using JUDGE_HOLD_NOTES_ON_SAME_ROW_TOGETHER, require that the whole row of
// TODO: When using JUDGE_HOLD_NOTES_ON_SAME_ROW_TOGETHER, require that the whole row of
// taps was hit before activating this group of holds.
/* Something about the logic in this section is causing 192nd steps to
* fail for some odd reason. -aj */
bSteppedOnHead &= (tns != TNS_Miss && tns != TNS_None); // did they step on the start of this hold?
bHeadJudged &= (tns != TNS_None); // has this hold really even started yet?
bHeadJudged &= (tns != TNS_None); // has this hold really even started yet?
/*
if(bSteppedOnHead)
@@ -1416,7 +1418,7 @@ void Player::UpdateHoldNotes( int iSongRow, float fDeltaTime, std::vector<TrackR
}
// TODO: Cap the active time passed to the score keeper to the actual start time and end time of the hold.
if( vTN[0].pTN->HoldResult.bActive )
if( vTN[0].pTN->HoldResult.bActive )
{
float fSecondsActiveSinceLastUpdate = fDeltaTime * GAMESTATE->m_SongOptions.GetCurrent().m_fMusicRate;
if( m_pPrimaryScoreKeeper )
@@ -1525,7 +1527,7 @@ void Player::UpdateHoldNotes( int iSongRow, float fDeltaTime, std::vector<TrackR
{
hns = HNS_LetGo;
}
else
else
{
hns = HNS_Missed;
}
@@ -1558,7 +1560,7 @@ void Player::UpdateHoldNotes( int iSongRow, float fDeltaTime, std::vector<TrackR
if ( (hns == HNS_LetGo) && COMBO_BREAK_ON_IMMEDIATE_HOLD_LET_GO )
IncrementMissCombo();
if( hns != HNS_None )
{
//LOG->Trace("tap note scoring time.");
@@ -1883,7 +1885,7 @@ int Player::GetClosestNote( int col, int iNoteRow, int iMaxRowsAhead, int iMaxRo
return iNextIndex;
/* Figure out which row is closer. */
if( abs(iNoteRow-iNextIndex) > abs(iNoteRow-iPrevIndex) )
if( std::abs(iNoteRow-iNextIndex) > std::abs(iNoteRow-iPrevIndex) )
return iPrevIndex;
else
return iNextIndex;
@@ -1948,7 +1950,7 @@ int Player::GetClosestNonEmptyRow( int iNoteRow, int iMaxRowsAhead, int iMaxRows
float fPrevTime = m_Timing->GetElapsedTimeFromBeat(NoteRowToBeat(iPrevRow));
/* Figure out which row is closer. */
if( fabsf(fNoteTime-fNextTime) > fabsf(fNoteTime-fPrevTime) )
if( std::abs(fNoteTime-fNextTime) > std::abs(fNoteTime-fPrevTime) )
return iPrevRow;
else
return iNextRow;
@@ -2065,15 +2067,15 @@ void Player::Step( int col, int row, const RageTimer &tm, bool bHeld, bool bRele
const float fTimeSinceStep = tm.Ago();
float fSongBeat = m_pPlayerState->m_Position.m_fSongBeat;
if( GAMESTATE->m_pCurSong )
{
fSongBeat = GAMESTATE->m_pCurSong->m_SongTiming.GetBeatFromElapsedTime( fPositionSeconds );
if( GAMESTATE->m_pCurSteps[m_pPlayerState->m_PlayerNumber] )
fSongBeat = m_Timing->GetBeatFromElapsedTime( fPositionSeconds );
}
const int iSongRow = row == -1 ? BeatToNoteRow( fSongBeat ) : row;
if( col != -1 && !bRelease )
@@ -2133,7 +2135,7 @@ void Player::Step( int col, int row, const RageTimer &tm, bool bHeld, bool bRele
if( ROLL_BODY_INCREMENTS_COMBO && m_pPlayerState->m_PlayerController != PC_AUTOPLAY )
{
IncrementCombo();
bool bBright = m_pPlayerStageStats && m_pPlayerStageStats->m_iCurCombo>(unsigned int)BRIGHT_GHOST_COMBO_THRESHOLD;
if( m_pNoteField )
m_pNoteField->DidHoldNote( col, HNS_Held, bBright );
@@ -2234,13 +2236,13 @@ void Player::Step( int col, int row, const RageTimer &tm, bool bHeld, bool bRele
// The offset from the actual step in seconds:
fNoteOffset = (fStepSeconds - fMusicSeconds) / GAMESTATE->m_SongOptions.GetCurrent().m_fMusicRate; // account for music rate
/*
LOG->Trace("step was %.3f ago, music is off by %f: %f vs %f, step was %f off",
LOG->Trace("step was %.3f ago, music is off by %f: %f vs %f, step was %f off",
fTimeSinceStep, GAMESTATE->m_LastBeatUpdate.Ago()/GAMESTATE->m_SongOptions.m_fMusicRate,
fStepSeconds, fMusicSeconds, fNoteOffset );
*/
}
const float fSecondsFromExact = fabsf( fNoteOffset );
const float fSecondsFromExact = std::abs( fNoteOffset );
TapNote tnDummy = TAP_ORIGINAL_TAP;
TapNote *pTN = nullptr;
@@ -2281,7 +2283,7 @@ void Player::Step( int col, int row, const RageTimer &tm, bool bHeld, bool bRele
score = TNS_W4;
else if (!disabledWindows[TW_W5])
score = TNS_W5;
break;
}
// Fall through to default.
@@ -2323,7 +2325,7 @@ void Player::Step( int col, int row, const RageTimer &tm, bool bHeld, bool bRele
if ( pTN->type == TapNoteType_Mine )
{
// The CPU hits a lot of mines. Only consider hitting the
// first mine for a row. We know we're the first mine if
// first mine for a row. We know we're the first mine if
// there are are no mines to the left of us.
for ( int t=0; t<col; t++ )
{
@@ -2331,7 +2333,7 @@ void Player::Step( int col, int row, const RageTimer &tm, bool bHeld, bool bRele
return; // avoid
}
// The CPU hits a lot of mines. Make it less likely to hit
// The CPU hits a lot of mines. Make it less likely to hit
// mines that don't have a tap note on the same row.
bool bTapsOnRow = m_NoteData.IsThereATapOrHoldHeadAtRow( iRowOfOverlappingNoteOrRow );
TapNoteScore get_to_avoid = bTapsOnRow ? TNS_W3 : TNS_W4;
@@ -2352,7 +2354,7 @@ void Player::Step( int col, int row, const RageTimer &tm, bool bHeld, bool bRele
if ( score == TNS_Miss )
return;
// Put some small, random amount in fNoteOffset so that demonstration
// Put some small, random amount in fNoteOffset so that demonstration
// show a mix of late and early. - Chris (StepMania r15628)
//fNoteOffset = randomf( -0.1f, 0.1f );
// Since themes may use the offset in a visual graph, the above
@@ -2455,7 +2457,7 @@ void Player::Step( int col, int row, const RageTimer &tm, bool bHeld, bool bRele
}
}
if( m_pPlayerState->m_PlayerController == PC_HUMAN && score >= TNS_W3 )
if( m_pPlayerState->m_PlayerController == PC_HUMAN && score >= TNS_W3 )
AdjustSync::HandleAutosync( fNoteOffset, fStepSeconds );
// Do game-specific and mode-specific score mapping.
@@ -3048,9 +3050,9 @@ void Player::HandleTapRowScore( unsigned row )
ChangeLife( scoreOfLastTap );
}
void Player::HandleHoldCheckpoint(int iRow,
int iNumHoldsHeldThisRow,
int iNumHoldsMissedThisRow,
void Player::HandleHoldCheckpoint(int iRow,
int iNumHoldsHeldThisRow,
int iNumHoldsMissedThisRow,
const std::vector<int> &viColsWithHold )
{
bool bNoCheating = true;
@@ -3070,14 +3072,14 @@ void Player::HandleHoldCheckpoint(int iRow,
const unsigned int iOldMissCombo = m_pPlayerStageStats ? m_pPlayerStageStats->m_iCurMissCombo : 0;
if( m_pPrimaryScoreKeeper )
m_pPrimaryScoreKeeper->HandleHoldCheckpointScore(m_NoteData,
iRow,
iNumHoldsHeldThisRow,
m_pPrimaryScoreKeeper->HandleHoldCheckpointScore(m_NoteData,
iRow,
iNumHoldsHeldThisRow,
iNumHoldsMissedThisRow );
if( m_pSecondaryScoreKeeper )
m_pSecondaryScoreKeeper->HandleHoldCheckpointScore(m_NoteData,
iRow,
iNumHoldsHeldThisRow,
m_pSecondaryScoreKeeper->HandleHoldCheckpointScore(m_NoteData,
iRow,
iNumHoldsHeldThisRow,
iNumHoldsMissedThisRow );
if( iNumHoldsMissedThisRow == 0 )
@@ -3087,7 +3089,7 @@ void Player::HandleHoldCheckpoint(int iRow,
{
for (int const &i : viColsWithHold)
{
bool bBright = m_pPlayerStageStats
bool bBright = m_pPlayerStageStats
&& m_pPlayerStageStats->m_iCurCombo>(unsigned int)BRIGHT_GHOST_COMBO_THRESHOLD;
if( m_pNoteField )
m_pNoteField->DidHoldNote( i, HNS_Held, bBright );
@@ -3130,13 +3132,13 @@ void Player::HandleHoldScore( const TapNote &tn )
if( m_pScoreDisplay )
{
if( m_pPlayerStageStats )
if( m_pPlayerStageStats )
m_pScoreDisplay->SetScore( m_pPlayerStageStats->m_iScore );
m_pScoreDisplay->OnJudgment( holdScore, tapScore );
}
if( m_pSecondaryScoreDisplay )
{
if( m_pPlayerStageStats )
if( m_pPlayerStageStats )
m_pSecondaryScoreDisplay->SetScore( m_pPlayerStageStats->m_iScore );
m_pSecondaryScoreDisplay->OnJudgment( holdScore, tapScore );
}
@@ -3186,7 +3188,7 @@ void Player::SetMineJudgment( TapNoteScore tns , int iTrack )
msg.SetParam( "FirstTrack", iTrack );
MESSAGEMAN->Broadcast( msg );
if( m_pPlayerStageStats &&
( ( tns == TNS_AvoidMine && AVOID_MINE_INCREMENTS_COMBO ) ||
( ( tns == TNS_AvoidMine && AVOID_MINE_INCREMENTS_COMBO ) ||
( tns == TNS_HitMine && MINE_HIT_INCREMENTS_MISS_COMBO ))
)
{
@@ -3273,7 +3275,7 @@ void Player::SetCombo( unsigned int iCombo, unsigned int iMisses )
m_bSeenComboYet = true;
m_iLastSeenCombo = iCombo;
}
bool b25Milestone = false;
bool b50Milestone = false;
bool b100Milestone = false;
@@ -3324,13 +3326,13 @@ void Player::SetCombo( unsigned int iCombo, unsigned int iMisses )
if( GAMESTATE->IsCourseMode() )
{
int iSongIndexStartColoring = GAMESTATE->m_pCurCourse->GetEstimatedNumStages();
iSongIndexStartColoring =
static_cast<int>(floor(iSongIndexStartColoring*PERCENT_UNTIL_COLOR_COMBO));
iSongIndexStartColoring =
static_cast<int>(std::floor(iSongIndexStartColoring*PERCENT_UNTIL_COLOR_COMBO));
bPastBeginning = GAMESTATE->GetCourseSongIndex() >= iSongIndexStartColoring;
}
else
{
bPastBeginning = m_pPlayerState->m_Position.m_fMusicSeconds
bPastBeginning = m_pPlayerState->m_Position.m_fMusicSeconds
> GAMESTATE->m_pCurSong->m_fMusicLengthSeconds * PERCENT_UNTIL_COLOR_COMBO;
}
@@ -3392,7 +3394,7 @@ RString Player::ApplyRandomAttack()
// lua start
#include "LuaBinding.h"
/** @brief Allow Lua to have access to the Player. */
/** @brief Allow Lua to have access to the Player. */
class LunaPlayer: public Luna<Player>
{
public:
@@ -3419,15 +3421,15 @@ public:
COMMON_RETURN_SELF;
}
static int SetActorWithJudgmentPosition( T* p, lua_State *L )
{
Actor *pActor = Luna<Actor>::check(L, 1);
p->SetActorWithJudgmentPosition(pActor);
{
Actor *pActor = Luna<Actor>::check(L, 1);
p->SetActorWithJudgmentPosition(pActor);
COMMON_RETURN_SELF;
}
static int SetActorWithComboPosition( T* p, lua_State *L )
{
Actor *pActor = Luna<Actor>::check(L, 1);
p->SetActorWithComboPosition(pActor);
{
Actor *pActor = Luna<Actor>::check(L, 1);
p->SetActorWithComboPosition(pActor);
COMMON_RETURN_SELF;
}
static int GetPlayerTimingData( T* p, lua_State *L )
@@ -3436,7 +3438,7 @@ public:
return 1;
}
GET_SET_BOOL_METHOD(oitg_zoom_mode, m_oitg_zoom_mode);
LunaPlayer()
{
ADD_METHOD(SetLife);
@@ -3454,7 +3456,7 @@ LUA_REGISTER_DERIVED_CLASS( Player, ActorFrame )
/*
* (c) 2001-2006 Chris Danford, Steve Checkoway
* All rights reserved.
*
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
@@ -3464,7 +3466,7 @@ LUA_REGISTER_DERIVED_CLASS( Player, ActorFrame )
* copyright notice(s) and this permission notice appear in all copies of
* the Software and that both the above copyright notice(s) and this
* permission notice appear in supporting documentation.
*
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
+9 -7
View File
@@ -9,7 +9,9 @@
#include "ThemeManager.h"
#include "Style.h"
#include "CommonMetrics.h"
#include <float.h>
#include <cfloat>
#include <cmath>
#include <sstream>
static const char *LifeTypeNames[] = {
@@ -199,7 +201,7 @@ static void AddPart( std::vector<RString> &AddTo, float level, RString name )
if( level == 0 )
return;
const RString LevelStr = (level == 1)? RString(""): ssprintf( "%ld%% ", lrintf(level*100) );
const RString LevelStr = (level == 1)? RString(""): ssprintf( "%ld%% ", std::lrint(level*100) );
AddTo.push_back( LevelStr + name );
}
@@ -540,11 +542,11 @@ void PlayerOptions::GetMods( std::vector<RString> &AddTo, bool bForceNoteSkin )
else
AddPart( AddTo, -m_fPerspectiveTilt, "Hallway" );
}
else if( fabsf(m_fSkew-m_fPerspectiveTilt) < 0.0001f )
else if( std::abs(m_fSkew-m_fPerspectiveTilt) < 0.0001f )
{
AddPart( AddTo, m_fSkew, "Space" );
}
else if( fabsf(m_fSkew+m_fPerspectiveTilt) < 0.0001f )
else if( std::abs(m_fSkew+m_fPerspectiveTilt) < 0.0001f )
{
AddPart( AddTo, m_fSkew, "Incoming" );
}
@@ -562,7 +564,7 @@ void PlayerOptions::GetMods( std::vector<RString> &AddTo, bool bForceNoteSkin )
AddTo.push_back( s );
}
if ( fabsf(m_fVisualDelay) > 0.0001f )
if ( std::abs(m_fVisualDelay) > 0.0001f )
{
// Format the string to be something like "10ms VisualDelay".
// Note that we don't process sub-millisecond visual delay.
@@ -1168,7 +1170,7 @@ bool PlayerOptions::FromOneModString( const RString &sOneMod, RString &sErrorOut
else if( sBit == "cosecant" ) m_bCosecant = on;
else if( sBit == "visualdelay" ) m_fVisualDelay = level;
else if( level == 0 && disabledWindows.Compare(sBit)) // "No w1" etc.
{
{
// We come into this condition if there is at least a single window present but there may be more.
// To get all of the windows, we go through in a loop to extract all of them.
static Regex allDisabledWindows("(w[1-5])(.*)$");
@@ -1393,7 +1395,7 @@ float PlayerOptions::GetReversePercentForColumn( int iCol ) const
f += m_fScrolls[SCROLL_CROSS];
if( f > 2 )
f = fmodf( f, 2 );
f = std::fmod( f, 2 );
if( f > 1 )
f = SCALE( f, 1.f, 2.f, 1.f, 0.f );
return f;
+20 -19
View File
@@ -3,7 +3,6 @@
#include "RageLog.h"
#include "ThemeManager.h"
#include "LuaManager.h"
#include <float.h>
#include "GameState.h"
#include "Course.h"
#include "Steps.h"
@@ -11,6 +10,8 @@
#include "PrefsManager.h"
#include "CommonMetrics.h"
#include <cfloat>
#include <cmath>
#include <numeric>
#define GRADE_PERCENT_TIER(i) THEME->GetMetricF("PlayerStageStats",ssprintf("GradePercent%s",GradeToString((Grade)i).c_str()))
@@ -151,7 +152,7 @@ void PlayerStageStats::AddStats( const PlayerStageStats& other )
Combo_t &combo = m_ComboList[i];
const float PrevComboEnd = prevcombo.m_fStartSecond + prevcombo.m_fSizeSeconds;
const float ThisComboStart = combo.m_fStartSecond;
if( fabsf(PrevComboEnd - ThisComboStart) > 0.001 )
if( std::abs(PrevComboEnd - ThisComboStart) > 0.001 )
continue;
// These are really the same combo.
@@ -261,7 +262,7 @@ float PlayerStageStats::MakePercentScore( int iActual, int iPossible )
// TRICKY: printf will round, but we want to truncate. Otherwise, we may display
// a percent score that's too high and doesn't match up with the calculated grade.
float fTruncInterval = powf( 0.1f, (float)iPercentTotalDigits-1 );
float fTruncInterval = std::pow( 0.1f, (float)iPercentTotalDigits-1 );
// TRICKY: ftruncf is rounding 1.0000000 to 0.99990004. Give a little boost
// to fPercentDancePoints to correct for this.
@@ -275,7 +276,7 @@ RString PlayerStageStats::FormatPercentScore( float fPercentDancePoints )
{
int iPercentTotalDigits = 3 + CommonMetrics::PERCENT_SCORE_DECIMAL_PLACES; // "100" + "." + "00"
RString s = ssprintf( "%*.*f%%", iPercentTotalDigits,
RString s = ssprintf( "%*.*f%%", iPercentTotalDigits,
(int)CommonMetrics::PERCENT_SCORE_DECIMAL_PLACES,
fPercentDancePoints*100 );
return s;
@@ -338,7 +339,7 @@ int PlayerStageStats::GetLessonScoreNeeded() const
{
float fScore = std::accumulate(m_vpPossibleSteps.begin(), m_vpPossibleSteps.end(), 0.f,
[](float total, Steps const *steps) { return total + steps->GetRadarValues(PLAYER_1)[RadarCategory_TapsAndHolds]; });
return lrintf( fScore * LESSON_PASS_THRESHOLD );
return std::lrint( fScore * LESSON_PASS_THRESHOLD );
}
void PlayerStageStats::ResetScoreForLesson()
@@ -398,8 +399,8 @@ void PlayerStageStats::SetLifeRecordAt( float fLife, float fStepsSecond )
// Memory optimization:
// If we have three consecutive records A, B, and C all with the same fLife,
// we can eliminate record B without losing data. Only check the last three
// records in the map since we're only inserting at the end, and we know all
// we can eliminate record B without losing data. Only check the last three
// records in the map since we're only inserting at the end, and we know all
// earlier redundant records have already been removed.
std::map<float, float>::iterator C = m_fLifeRecord.end();
--C;
@@ -471,7 +472,7 @@ float PlayerStageStats::GetCurrentLife() const
if( m_fLifeRecord.empty() )
return 0;
std::map<float, float>::const_iterator iter = m_fLifeRecord.end();
--iter;
--iter;
return iter->second;
}
@@ -557,7 +558,7 @@ bool PlayerStageStats::FullComboOfScore( TapNoteScore tnsAllGreaterOrEqual ) con
{
ASSERT( tnsAllGreaterOrEqual >= TNS_W5 );
ASSERT( tnsAllGreaterOrEqual <= TNS_W1 );
//if we've set MissCombo to anything besides 0, it's not a full combo
if( !m_bPlayerCanAchieveFullCombo )
return false;
@@ -724,7 +725,7 @@ LuaFunction( FormatPercentScore, PlayerStageStats::FormatPercentScore( FArg(1) )
// lua start
#include "LuaBinding.h"
/** @brief Allow Lua to have access to the PlayerStageStats. */
/** @brief Allow Lua to have access to the PlayerStageStats. */
class LunaPlayerStageStats: public Luna<PlayerStageStats>
{
public:
@@ -843,13 +844,13 @@ public:
static int GetRadarPossible( T* p, lua_State *L ) { p->m_radarPossible.PushSelf(L); return 1; }
static int GetRadarActual( T* p, lua_State *L ) { p->m_radarActual.PushSelf(L); return 1; }
static int SetScore( T* p, lua_State *L )
{
static int SetScore( T* p, lua_State *L )
{
if( IArg(1) >= 0 )
{
p->m_iScore = IArg(1);
return 1;
}
{
p->m_iScore = IArg(1);
return 1;
}
COMMON_RETURN_SELF;
}
static int SetCurMaxScore( T* p, lua_State *L )
@@ -880,7 +881,7 @@ public:
}
COMMON_RETURN_SELF;
}
static int FailPlayer( T* p, lua_State *L )
{
p->m_bFailed = true;
@@ -943,7 +944,7 @@ LUA_REGISTER_CLASS( PlayerStageStats )
/*
* (c) 2001-2004 Chris Danford, Glenn Maynard
* All rights reserved.
*
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
@@ -953,7 +954,7 @@ LUA_REGISTER_CLASS( PlayerStageStats )
* copyright notice(s) and this permission notice appear in all copies of
* the Software and that both the above copyright notice(s) and this
* permission notice appear in supporting documentation.
*
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
+13 -11
View File
@@ -13,6 +13,8 @@
#include "arch/Dialog/Dialog.h"
#include "StepMania.h"
#include <cmath>
static void GetResolutionFromFileName( RString sPath, int &iWidth, int &iHeight )
{
/* Match:
@@ -180,7 +182,7 @@ void RageBitmapTexture::Create()
m_iImageHeight = m_iTextureHeight;
}
if( pImg->w != m_iImageWidth || pImg->h != m_iImageHeight )
if( pImg->w != m_iImageWidth || pImg->h != m_iImageHeight )
RageSurfaceUtils::Zoom( pImg, m_iImageWidth, m_iImageHeight );
if( actualID.iGrayscaleBits != -1 && DISPLAY->SupportsTextureFormat(RagePixelFormat_PAL) )
@@ -244,7 +246,7 @@ void RageBitmapTexture::Create()
* We actually want to dither only if the destination has greater color depth
* on at least one color channel than the source. For example, it doesn't
* make sense to do this when pixfmt is RGBA5551 if the image is only RGBA555. */
if( actualID.bDither &&
if( actualID.bDither &&
(pixfmt==RagePixelFormat_RGBA4 || pixfmt==RagePixelFormat_RGB5A1) )
{
// Dither down to the destination format.
@@ -265,7 +267,7 @@ void RageBitmapTexture::Create()
/* Scale up to the texture size, if needed. */
RageSurfaceUtils::ConvertSurface( pImg, m_iTextureWidth, m_iTextureHeight,
pImg->fmt.BitsPerPixel, pImg->fmt.Mask[0], pImg->fmt.Mask[1], pImg->fmt.Mask[2], pImg->fmt.Mask[3] );
m_uTexHandle = DISPLAY->CreateTexture( pixfmt, pImg, actualID.bMipMaps );
CreateFrameRects();
@@ -302,8 +304,8 @@ void RageBitmapTexture::Create()
{
float fFrameWidth = this->GetSourceWidth() / (float)this->GetFramesWide();
float fFrameHeight = this->GetSourceHeight() / (float)this->GetFramesHigh();
float fBetterFrameWidth = ceilf(fFrameWidth/iDimensionMultiple) * iDimensionMultiple;
float fBetterFrameHeight = ceilf(fFrameHeight/iDimensionMultiple) * iDimensionMultiple;
float fBetterFrameWidth = std::ceil(fFrameWidth/iDimensionMultiple) * iDimensionMultiple;
float fBetterFrameHeight = std::ceil(fFrameHeight/iDimensionMultiple) * iDimensionMultiple;
float fBetterSourceWidth = this->GetFramesWide() * fBetterFrameWidth;
float fBetterSourceHeight = this->GetFramesHigh() * fBetterFrameHeight;
if( fFrameWidth!=fBetterFrameWidth || fFrameHeight!=fBetterFrameHeight )
@@ -311,10 +313,10 @@ void RageBitmapTexture::Create()
RString sWarning = ssprintf(
"The graphic '%s' has frame dimensions that aren't a multiple of %d.\n"
"The entire image is %dx%d and frame size is %.1fx%.1f.\n"
"Image quality will be much improved if you resize the graphic to %.0fx%.0f, which is a frame size of %.0fx%.0f.",
actualID.filename.c_str(),
"Image quality will be much improved if you resize the graphic to %.0fx%.0f, which is a frame size of %.0fx%.0f.",
actualID.filename.c_str(),
iDimensionMultiple,
this->GetSourceWidth(), this->GetSourceHeight(),
this->GetSourceWidth(), this->GetSourceHeight(),
fFrameWidth, fFrameHeight,
fBetterSourceWidth, fBetterSourceHeight,
fBetterFrameWidth, fBetterFrameHeight );
@@ -362,7 +364,7 @@ void RageBitmapTexture::Destroy()
/*
* Copyright (c) 2001-2004 Chris Danford, Glenn Maynard
* All rights reserved.
*
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
@@ -372,7 +374,7 @@ void RageBitmapTexture::Destroy()
* copyright notice(s) and this permission notice appear in all copies of
* the Software and that both the above copyright notice(s) and this
* permission notice appear in supporting documentation.
*
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
@@ -382,4 +384,4 @@ void RageBitmapTexture::Destroy()
* OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
*/
+44 -42
View File
@@ -15,6 +15,8 @@
#include "DisplaySpec.h"
#include "arch/ArchHooks/ArchHooks.h"
#include <cmath>
// Statistics stuff
RageTimer g_LastCheckTimer;
int g_iNumVerts;
@@ -63,7 +65,7 @@ static const char *RagePixelFormatNames[] = {
XToString( RagePixelFormat );
/* bNeedReloadTextures is set to true if the device was re-created and we need
* to reload textures. On failure, an error message is returned.
* to reload textures. On failure, an error message is returned.
* XXX: the renderer itself should probably be the one to try fallback modes */
static LocalizedString SETVIDEOMODE_FAILED ( "RageDisplay", "SetVideoMode failed:" );
RString RageDisplay::SetVideoMode( VideoModeParams p, bool &bNeedReloadTextures )
@@ -82,7 +84,7 @@ RString RageDisplay::SetVideoMode( VideoModeParams p, bool &bNeedReloadTextures
return RString();
vs.push_back( err );
// "Intel(R) 82810E Graphics Controller" won't accept a 16 bpp surface if
// "Intel(R) 82810E Graphics Controller" won't accept a 16 bpp surface if
// the desktop is 32 bpp, so try 32 bpp as well.
p.bpp = 32;
if( (err = this->TryVideoMode(p,bNeedReloadTextures)) == "" )
@@ -116,7 +118,7 @@ RString RageDisplay::SetVideoMode( VideoModeParams p, bool &bNeedReloadTextures
const DisplayMode supported = d.currentMode() != nullptr ? *d.currentMode() : *d.supportedModes().begin();
p.width = supported.width;
p.height = supported.height;
p.rate = static_cast<int> (round(supported.refreshRate));
p.rate = std::round(supported.refreshRate);
if( (err = this->TryVideoMode(p,bNeedReloadTextures)) == "" )
return RString();
vs.push_back( err );
@@ -133,9 +135,9 @@ void RageDisplay::ProcessStatsOnFlip()
{
float fActualTime = g_LastCheckTimer.GetDeltaTime();
g_iNumChecksSinceLastReset++;
g_iFPS = lrintf( g_iFramesRenderedSinceLastCheck / fActualTime );
g_iFPS = std::lrint( g_iFramesRenderedSinceLastCheck / fActualTime );
g_iCFPS = g_iFramesRenderedSinceLastReset / g_iNumChecksSinceLastReset;
g_iCFPS = lrintf( g_iCFPS / fActualTime );
g_iCFPS = std::lrint( g_iCFPS / fActualTime );
g_iVPF = g_iVertsRenderedSinceLastCheck / g_iFramesRenderedSinceLastCheck;
g_iFramesRenderedSinceLastCheck = g_iVertsRenderedSinceLastCheck = 0;
if( LOG_FPS )
@@ -199,7 +201,7 @@ void RageDisplay::DrawPolyLine(const RageSpriteVertex &p1, const RageSpriteVerte
// soh cah toa strikes strikes again!
float opp = p2.p.x - p1.p.x;
float adj = p2.p.y - p1.p.y;
float hyp = powf(opp*opp + adj*adj, 0.5f);
float hyp = std::pow(opp*opp + adj*adj, 0.5f);
float lsin = opp/hyp;
float lcos = adj/hyp;
@@ -246,7 +248,7 @@ void RageDisplay::DrawCircleInternal( const RageSpriteVertex &p, float radius )
RageSpriteVertex v[subdivisions+2];
v[0] = p;
for(int i = 0; i < subdivisions+1; ++i)
for(int i = 0; i < subdivisions+1; ++i)
{
const float fRotation = float(i) / subdivisions * 2*PI;
const float fX = RageFastCos(fRotation) * radius;
@@ -264,7 +266,7 @@ void RageDisplay::SetDefaultRenderStates()
{
SetLighting( false );
SetCullMode( CULL_NONE );
SetZWrite( false );
SetZWrite( false );
SetZTestMode( ZTEST_OFF );
SetAlphaTest( true );
SetBlendMode( BLEND_NORMAL );
@@ -412,7 +414,7 @@ public:
RageMatrixSkewX( &m, fAmount );
MultMatrixLocal( m );
}
void SkewY( float fAmount )
{
RageMatrix m;
@@ -482,13 +484,13 @@ const RageMatrix* RageDisplay::GetTextureTop() const
return g_TextureStack.GetTop();
}
void RageDisplay::PushMatrix()
{
void RageDisplay::PushMatrix()
{
g_WorldStack.Push();
}
void RageDisplay::PopMatrix()
{
void RageDisplay::PopMatrix()
{
g_WorldStack.Pop();
}
@@ -548,13 +550,13 @@ void RageDisplay::LoadIdentity()
}
void RageDisplay::TexturePushMatrix()
{
void RageDisplay::TexturePushMatrix()
{
g_TextureStack.Push();
}
void RageDisplay::TexturePopMatrix()
{
void RageDisplay::TexturePopMatrix()
{
g_TextureStack.Pop();
}
@@ -578,7 +580,7 @@ void RageDisplay::LoadMenuPerspective( float fovDegrees, float fWidth, float fHe
CLAMP( fovDegrees, 0.1f, 179.9f );
float fovRadians = fovDegrees / 180.f * PI;
float theta = fovRadians/2;
float fDistCameraFromImage = fWidth/2 / tanf( theta );
float fDistCameraFromImage = fWidth/2 / std::tan( theta );
fVanishPointX = SCALE( fVanishPointX, 0, fWidth, fWidth, 0 );
fVanishPointY = SCALE( fVanishPointY, 0, fHeight, fHeight, 0 );
@@ -596,7 +598,7 @@ void RageDisplay::LoadMenuPerspective( float fovDegrees, float fWidth, float fHe
1,
fDistCameraFromImage+1000 ) );
g_ViewStack.LoadMatrix(
g_ViewStack.LoadMatrix(
RageLookAt(
-fVanishPointX+fWidth/2, -fVanishPointY+fHeight/2, fDistCameraFromImage,
-fVanishPointX+fWidth/2, -fVanishPointY+fHeight/2, 0,
@@ -634,7 +636,7 @@ void RageDisplay::LoadLookAt( float fFOV, const RageVector3 &Eye, const RageVect
RageMatrix RageDisplay::GetPerspectiveMatrix(float fovy, float aspect, float zNear, float zFar)
{
float ymax = zNear * tanf(fovy * PI / 360.0f);
float ymax = zNear * std::tan(fovy * PI / 360.0f);
float ymin = -ymax;
float xmin = ymin * aspect;
float xmax = ymax * aspect;
@@ -648,7 +650,7 @@ RageSurface *RageDisplay::CreateSurfaceFromPixfmt( RagePixelFormat pixfmt,
const RagePixelFormatDesc *tpf = GetPixelFormatDesc(pixfmt);
RageSurface *surf = CreateSurfaceFrom(
width, height, tpf->bpp,
width, height, tpf->bpp,
tpf->masks[0], tpf->masks[1], tpf->masks[2], tpf->masks[3],
(uint8_t *) pixels, pitch );
@@ -739,15 +741,15 @@ RageMatrix RageDisplay::GetCenteringMatrix( float fTranslateX, float fTranslateY
RageMatrix m1;
RageMatrix m2;
RageMatrixTranslation(
&m1,
fPercentShiftX,
fPercentShiftY,
RageMatrixTranslation(
&m1,
fPercentShiftX,
fPercentShiftY,
0 );
RageMatrixScaling(
&m2,
fPercentScaleX,
fPercentScaleY,
RageMatrixScaling(
&m2,
fPercentScaleX,
fPercentScaleY,
1 );
RageMatrix mOut;
RageMatrixMultiply( &mOut, &m1, &m2 );
@@ -757,7 +759,7 @@ RageMatrix RageDisplay::GetCenteringMatrix( float fTranslateX, float fTranslateY
void RageDisplay::UpdateCentering()
{
const Centering &p = g_CenteringStack.back();
g_CenteringMatrix = GetCenteringMatrix(
g_CenteringMatrix = GetCenteringMatrix(
(float) p.m_iTranslateX, (float) p.m_iTranslateY, (float) p.m_iAddWidth, (float) p.m_iAddHeight );
}
@@ -766,13 +768,13 @@ bool RageDisplay::SaveScreenshot( RString sPath, GraphicsFileFormat format )
RageTimer timer;
RageSurface *surface = this->CreateScreenshot();
// LOG->Trace( "CreateScreenshot took %f seconds", timer.GetDeltaTime() );
if (nullptr == surface)
{
LOG->Trace("CreateScreenshot failed to return a surface");
return false;
}
/* Unless we're in lossless, resize the image to 640x480. If we're saving lossy,
* there's no sense in saving 1280x960 screenshots, and we don't want to output
* screenshots in a strange (non-1) sample aspect ratio. */
@@ -781,9 +783,9 @@ bool RageDisplay::SaveScreenshot( RString sPath, GraphicsFileFormat format )
// Maintain the DAR.
ASSERT( GetActualVideoModeParams().fDisplayAspectRatio > 0 );
int iHeight = 480;
// This used to be lrintf. However, lrintf causes odd resolutions like
// 639x480 (4:3) and 853x480 (16:9). ceilf gives correct values. -aj
int iWidth = static_cast<int>(ceilf( iHeight * GetActualVideoModeParams().fDisplayAspectRatio ));
// This used to be lrint. However, lrint causes odd resolutions like
// 639x480 (4:3) and 853x480 (16:9). ceil gives correct values. -aj
int iWidth = std::ceil( iHeight * GetActualVideoModeParams().fDisplayAspectRatio );
timer.Touch();
RageSurfaceUtils::Zoom( surface, iWidth, iHeight );
// LOG->Trace( "%ix%i -> %ix%i (%.3f) in %f seconds", surface->w, surface->h, iWidth, iHeight, GetActualVideoModeParams().fDisplayAspectRatio, timer.GetDeltaTime() );
@@ -868,7 +870,7 @@ void RageDisplay::DrawStrip( const RageSpriteVertex v[], int iNumVerts )
this->DrawStripInternal(v,iNumVerts);
StatsAddVerts(iNumVerts);
StatsAddVerts(iNumVerts);
}
void RageDisplay::DrawTriangles( const RageSpriteVertex v[], int iNumVerts )
@@ -887,7 +889,7 @@ void RageDisplay::DrawCompiledGeometry( const RageCompiledGeometry *p, int iMesh
{
this->DrawCompiledGeometryInternal( p, iMeshIndex );
StatsAddVerts( vMeshes[iMeshIndex].Triangles.size() );
StatsAddVerts( vMeshes[iMeshIndex].Triangles.size() );
}
void RageDisplay::DrawLineStrip( const RageSpriteVertex v[], int iNumVerts, float LineWidth )
@@ -1023,7 +1025,7 @@ static void register_REFRESH_DEFAULT(lua_State *L)
REGISTER_WITH_LUA_FUNCTION( register_REFRESH_DEFAULT );
/** @brief Allow Lua to have access to the RageDisplay. */
/** @brief Allow Lua to have access to the RageDisplay. */
class LunaRageDisplay: public Luna<RageDisplay>
{
public:
@@ -1040,19 +1042,19 @@ public:
LuaHelpers::Push( L, params.height );
return 1;
}
static int GetFPS( T* p, lua_State *L )
{
lua_pushnumber(L, p->GetFPS());
return 1;
}
static int GetVPF( T* p, lua_State *L )
{
lua_pushnumber(L, p->GetVPF());
return 1;
}
static int GetCumFPS( T* p, lua_State *L )
{
lua_pushnumber(L, p->GetCumFPS());
@@ -1079,7 +1081,7 @@ public:
return 1;
}
LunaRageDisplay()
LunaRageDisplay()
{
ADD_METHOD( GetDisplayWidth );
ADD_METHOD( GetDisplayHeight );
+27 -27
View File
@@ -24,7 +24,7 @@
#pragma comment(lib, "d3d9.lib")
#endif
#include <math.h>
#include <cmath>
#include <list>
// Globals
@@ -151,7 +151,7 @@ static const RageDisplay::RagePixelFormatDesc PIXEL_FORMAT_DESC[NUM_RagePixelFor
}
};
static D3DFORMAT D3DFORMATS[NUM_RagePixelFormat] =
static D3DFORMAT D3DFORMATS[NUM_RagePixelFormat] =
{
D3DFMT_A8R8G8B8,
D3DFMT_UNKNOWN,
@@ -179,7 +179,7 @@ RageDisplay_D3D::RageDisplay_D3D()
static LocalizedString D3D_NOT_INSTALLED ( "RageDisplay_D3D", "DirectX 9.0c or greater is not installed. You can download it from:" );
const RString D3D_URL = "http://www.microsoft.com/en-us/download/details.aspx?id=8109";
static LocalizedString HARDWARE_ACCELERATION_NOT_AVAILABLE ( "RageDisplay_D3D",
static LocalizedString HARDWARE_ACCELERATION_NOT_AVAILABLE ( "RageDisplay_D3D",
"Your system is reporting that Direct3D hardware acceleration is not available. Please obtain an updated driver from your video card manufacturer." );
RString RageDisplay_D3D::Init( const VideoModeParams &p, bool /* bAllowUnacceleratedRenderer */ )
{
@@ -197,17 +197,17 @@ RString RageDisplay_D3D::Init( const VideoModeParams &p, bool /* bAllowUnacceler
if( FAILED( g_pd3d->GetDeviceCaps(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, &g_DeviceCaps) ) )
return HARDWARE_ACCELERATION_NOT_AVAILABLE.GetValue();
D3DADAPTER_IDENTIFIER9 identifier;
g_pd3d->GetAdapterIdentifier( D3DADAPTER_DEFAULT, 0, &identifier );
LOG->Trace(
LOG->Trace(
"Driver: %s\n"
"Description: %s\n"
"Max texture size: %d\n"
"Alpha in palette: %s\n",
identifier.Driver,
identifier.Driver,
identifier.Description,
g_DeviceCaps.MaxTextureWidth,
(g_DeviceCaps.TextureCaps & D3DPTEXTURECAPS_ALPHAPALETTE) ? "yes" : "no" );
@@ -318,7 +318,7 @@ D3DFORMAT FindBackBufferType(bool bWindowed, int iBPP)
vBackBufferFormats.push_back( D3DFMT_X1R5G5B5 );
vBackBufferFormats.push_back( D3DFMT_A1R5G5B5 );
}
if( !bWindowed && iBPP != 16 && iBPP != 32 )
{
@@ -340,7 +340,7 @@ D3DFORMAT FindBackBufferType(bool bWindowed, int iBPP)
LOG->Trace( "Testing format: display %d, back buffer %d, windowed %d...",
fmtDisplay, fmtBackBuffer, bWindowed );
hr = g_pd3d->CheckDeviceType( D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL,
hr = g_pd3d->CheckDeviceType( D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL,
fmtDisplay, fmtBackBuffer, bWindowed );
if( FAILED(hr) )
@@ -361,11 +361,11 @@ RString SetD3DParams( bool &bNewDeviceOut )
{
bNewDeviceOut = true;
HRESULT hr = g_pd3d->CreateDevice(
D3DADAPTER_DEFAULT,
D3DDEVTYPE_HAL,
D3DADAPTER_DEFAULT,
D3DDEVTYPE_HAL,
GraphicsWindow::GetHwnd(),
D3DCREATE_HARDWARE_VERTEXPROCESSING | D3DCREATE_MULTITHREADED,
&g_d3dpp,
&g_d3dpp,
&g_pd3dDevice );
if( FAILED(hr) )
{
@@ -385,7 +385,7 @@ RString SetD3DParams( bool &bNewDeviceOut )
}
}
g_pd3dDevice->SetRenderState( D3DRS_NORMALIZENORMALS, TRUE );
g_pd3dDevice->SetRenderState( D3DRS_NORMALIZENORMALS, TRUE );
// Palettes were lost by Reset(), so mark them unloaded.
g_TexResourceToPaletteIndex.clear();
@@ -497,7 +497,7 @@ static void SetPresentParametersFromVideoModeParams( const VideoModeParams &p, D
pD3Dpp->Flags = 0;
LOG->Trace( "Present Parameters: %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d",
LOG->Trace( "Present Parameters: %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d",
pD3Dpp->BackBufferWidth, pD3Dpp->BackBufferHeight, pD3Dpp->BackBufferFormat,
pD3Dpp->BackBufferCount,
pD3Dpp->MultiSampleType, pD3Dpp->SwapEffect, pD3Dpp->hDeviceWindow,
@@ -616,7 +616,7 @@ bool RageDisplay_D3D::SupportsTextureFormat( RagePixelFormat pixfmt, bool realti
return false;
D3DFORMAT d3dfmt = D3DFORMATS[pixfmt];
HRESULT hr = g_pd3d->CheckDeviceFormat(
HRESULT hr = g_pd3d->CheckDeviceFormat(
D3DADAPTER_DEFAULT,
D3DDEVTYPE_HAL,
g_d3dpp.BackBufferFormat,
@@ -677,7 +677,7 @@ RageSurface* RageDisplay_D3D::CreateScreenshot()
default: pf = RagePixelFormat_Invalid; FAIL_M("Unknown pixel format"); break;
case D3DFMT_X8R8G8B8: pf = RagePixelFormat_RGBA8; break;
case D3DFMT_A8R8G8B8: pf = RagePixelFormat_RGBA8; break;
// 16-bit formats are not here. Does anybody actually use them?
// 16-bit formats are not here. Does anybody actually use them?
}
RageSurface *surface = CreateSurfaceFromPixfmt(pf, lr.pBits, desc.Width, desc.Height, lr.Pitch);
@@ -1086,7 +1086,7 @@ void RageDisplay_D3D::SetTextureMode( TextureUnit tu, TextureMode tm )
switch( tm )
{
case TextureMode_Modulate:
// Use D3DTA_CURRENT instead of diffuse so that multitexturing works
// Use D3DTA_CURRENT instead of diffuse so that multitexturing works
// properly. For stage 0, D3DTA_CURRENT is the diffuse color.
g_pd3dDevice->SetTextureStageState( tu, D3DTSS_COLORARG1, D3DTA_TEXTURE );
@@ -1261,7 +1261,7 @@ void RageDisplay_D3D::SetTextureWrapping( TextureUnit tu, bool b )
g_pd3dDevice->SetSamplerState( tu, D3DSAMP_ADDRESSV, mode );
}
void RageDisplay_D3D::SetMaterial(
void RageDisplay_D3D::SetMaterial(
const RageColor &emissive,
const RageColor &ambient,
const RageColor &diffuse,
@@ -1307,11 +1307,11 @@ void RageDisplay_D3D::SetLightOff( int index )
{
g_pd3dDevice->LightEnable( index, false );
}
void RageDisplay_D3D::SetLightDirectional(
int index,
const RageColor &ambient,
const RageColor &diffuse,
const RageColor &specular,
void RageDisplay_D3D::SetLightDirectional(
int index,
const RageColor &ambient,
const RageColor &diffuse,
const RageColor &specular,
const RageVector3 &dir )
{
g_pd3dDevice->LightEnable( index, true );
@@ -1372,7 +1372,7 @@ void RageDisplay_D3D::DeleteTexture( uintptr_t iTexHandle )
}
uintptr_t RageDisplay_D3D::CreateTexture(
uintptr_t RageDisplay_D3D::CreateTexture(
RagePixelFormat pixfmt,
RageSurface* img,
bool bGenerateMipMaps )
@@ -1382,7 +1382,7 @@ uintptr_t RageDisplay_D3D::CreateTexture(
hr = g_pd3dDevice->CreateTexture( power_of_two(img->w), power_of_two(img->h), 1, 0, D3DFORMATS[pixfmt], D3DPOOL_MANAGED, &pTex, nullptr );
if( FAILED(hr) )
RageException::Throw( "CreateTexture(%i,%i,%s) failed: %s",
RageException::Throw( "CreateTexture(%i,%i,%s) failed: %s",
img->w, img->h, RagePixelFormatToString(pixfmt).c_str(), GetErrorString(hr).c_str() );
uintptr_t uTexHandle = reinterpret_cast<uintptr_t>(pTex);
@@ -1410,15 +1410,15 @@ uintptr_t RageDisplay_D3D::CreateTexture(
return uTexHandle;
}
void RageDisplay_D3D::UpdateTexture(
uintptr_t uTexHandle,
void RageDisplay_D3D::UpdateTexture(
uintptr_t uTexHandle,
RageSurface* img,
int xoffset, int yoffset, int width, int height )
{
IDirect3DTexture9* pTex = reinterpret_cast<IDirect3DTexture9*>(uTexHandle);
ASSERT( pTex != nullptr );
RECT rect;
RECT rect;
rect.left = xoffset;
rect.top = yoffset;
rect.right = width - xoffset;
+73 -72
View File
@@ -19,6 +19,7 @@ using namespace RageDisplay_Legacy_Helpers;
#include "arch/LowLevelWindow/LowLevelWindow.h"
#include <cmath>
#include <set>
#if defined(WINDOWS)
@@ -291,7 +292,7 @@ GLhandleARB CompileShader( GLenum ShaderType, RString sFile, std::vector<RString
LOG->Warn("Fragment shaders not supported by driver. Some effects will not be available.");
return 0;
}
RString sBuffer;
{
RageFile file;
@@ -300,7 +301,7 @@ GLhandleARB CompileShader( GLenum ShaderType, RString sFile, std::vector<RString
LOG->Warn( "Error compiling shader %s: %s", sFile.c_str(), file.GetError().c_str() );
return 0;
}
if (file.Read(sBuffer, file.GetFileSize()) == -1)
{
LOG->Warn( "Error compiling shader %s: %s", sFile.c_str(), file.GetError().c_str() );
@@ -367,14 +368,14 @@ GLhandleARB LoadShader( GLenum ShaderType, RString sFile, std::vector<RString> a
secondaryShader = CompileShader( GL_FRAGMENT_SHADER_ARB, "Data/Shaders/GLSL/Shell.frag", asDefines);
else if (sFile == "Data/Shaders/GLSL/Distance field.vert")
secondaryShader = CompileShader( GL_FRAGMENT_SHADER_ARB, "Data/Shaders/GLSL/Distance field.frag", asDefines);
GLhandleARB hShader = CompileShader( ShaderType, sFile, asDefines );
if (hShader == 0)
return 0;
GLhandleARB hProgram = glCreateProgramObjectARB();
glAttachObjectARB( hProgram, hShader );
if (secondaryShader)
{
glAttachObjectARB( hProgram, secondaryShader );
@@ -416,15 +417,15 @@ void InitShaders()
// the shaders and determines shader type by file extension. -aj
// argh shaders in stepmania are painful -colby
std::vector<RString> asDefines;
// used for scrolling textures (I think)
g_bTextureMatrixShader = LoadShader( GL_VERTEX_SHADER_ARB, "Data/Shaders/GLSL/Texture matrix scaling.vert", asDefines );
// these two are for dancing characters and are both actually shader pairs
g_gShellShader = LoadShader( GL_VERTEX_SHADER_ARB, "Data/Shaders/GLSL/Shell.vert", asDefines );
g_gCelShader = LoadShader( GL_VERTEX_SHADER_ARB, "Data/Shaders/GLSL/Cel.vert", asDefines );
g_gDistanceFieldShader = LoadShader( GL_VERTEX_SHADER_ARB, "Data/Shaders/GLSL/Distance field.vert", asDefines );
// effects
g_bUnpremultiplyShader = LoadShader( GL_FRAGMENT_SHADER_ARB, "Data/Shaders/GLSL/Unpremultiply.frag", asDefines );
g_bColorBurnShader = LoadShader( GL_FRAGMENT_SHADER_ARB, "Data/Shaders/GLSL/Color burn.frag", asDefines );
@@ -434,7 +435,7 @@ void InitShaders()
g_hOverlayShader = LoadShader( GL_FRAGMENT_SHADER_ARB, "Data/Shaders/GLSL/Overlay.frag", asDefines );
g_hScreenShader = LoadShader( GL_FRAGMENT_SHADER_ARB, "Data/Shaders/GLSL/Screen.frag", asDefines );
g_hYUYV422Shader = LoadShader( GL_FRAGMENT_SHADER_ARB, "Data/Shaders/GLSL/YUYV422.frag", asDefines );
// Bind attributes.
if (g_bTextureMatrixShader)
{
@@ -602,7 +603,7 @@ static void CheckPalettedTextures()
}
glTexImage2D( GL_PROXY_TEXTURE_2D,
0, glTexFormat,
0, glTexFormat,
16, 16, 0,
glImageFormat, glImageType, nullptr );
GL_CHECK_ERROR( "glTexImage2D" );
@@ -666,7 +667,7 @@ static void CheckReversePackedPixels()
/* Try to create a texture. */
FlushGLErrors();
glTexImage2D( GL_PROXY_TEXTURE_2D,
0, GL_RGBA,
0, GL_RGBA,
16, 16, 0,
GL_BGRA, GL_UNSIGNED_SHORT_1_5_5_5_REV, nullptr );
@@ -686,15 +687,15 @@ static void CheckReversePackedPixels()
void SetupExtensions()
{
const float fGLVersion = StringToFloat( (const char *) glGetString(GL_VERSION) );
g_glVersion = lrintf( fGLVersion * 10 );
g_glVersion = std::lrint( fGLVersion * 10 );
const float fGLUVersion = StringToFloat( (const char *) gluGetString(GLU_VERSION) );
g_gluVersion = lrintf( fGLUVersion * 10 );
g_gluVersion = std::lrint( fGLUVersion * 10 );
#ifndef HAVE_X11 // LLW_X11 needs to init GLEW early for GLX exts
glewInit();
#endif
g_iMaxTextureUnits = 1;
if (GLEW_ARB_multitexture)
glGetIntegerv( GL_MAX_TEXTURE_UNITS_ARB, (GLint *) &g_iMaxTextureUnits );
@@ -816,7 +817,7 @@ RString RageDisplay_Legacy::TryVideoMode( const VideoModeParams &p, bool &bNewDe
else
return RString("The WGL_EXT_swap_control extension is not supported on your computer.");
#endif
ResolutionChanged();
return RString(); // successfully set mode
@@ -913,7 +914,7 @@ RageSurface* RageDisplay_Legacy::CreateScreenshot()
//TODO: revisit for MacOS, where backbuffer size can be less than window size
glReadBuffer( GL_FRONT );
DebugAssertNoGLError();
glReadPixels( 0, 0, g_pWind->GetActualVideoModeParams().width, g_pWind->GetActualVideoModeParams().height, GL_RGBA,
GL_UNSIGNED_BYTE, image->pixels );
DebugAssertNoGLError();
@@ -955,7 +956,7 @@ ActualVideoModeParams RageDisplay_Legacy::GetActualVideoModeParams() const
static void SetupVertices( const RageSpriteVertex v[], int iNumVerts )
{
static float *Vertex, *Texture, *Normal;
static float *Vertex, *Texture, *Normal;
static GLubyte *Color;
static int Size = 0;
if (iNumVerts > Size)
@@ -997,10 +998,10 @@ static void SetupVertices( const RageSpriteVertex v[], int iNumVerts )
if (GLEW_ARB_multitexture)
{
glClientActiveTextureARB( GL_TEXTURE1_ARB );
glClientActiveTextureARB( GL_TEXTURE1_ARB );
glEnableClientState( GL_TEXTURE_COORD_ARRAY );
glTexCoordPointer( 2, GL_FLOAT, 0, Texture );
glClientActiveTextureARB( GL_TEXTURE0_ARB );
glClientActiveTextureARB( GL_TEXTURE0_ARB );
}
glEnableClientState( GL_NORMAL_ARRAY );
@@ -1034,7 +1035,7 @@ void RageDisplay_Legacy::SendCurrentMatrices()
class RageCompiledGeometrySWOGL : public RageCompiledGeometry
{
public:
void Allocate( const std::vector<msMesh> &vMeshes )
{
/* Always allocate at least 1 entry, so &x[0] is valid. */
@@ -1114,10 +1115,10 @@ public:
glLoadMatrixf( (const float*)mat );
}
glDrawElements(
GL_TRIANGLES,
meshInfo.iTriangleCount*3,
GL_UNSIGNED_SHORT,
glDrawElements(
GL_TRIANGLES,
meshInfo.iTriangleCount*3,
GL_UNSIGNED_SHORT,
&m_vTriangles[0]+meshInfo.iTriangleStart );
}
@@ -1164,7 +1165,7 @@ public:
/* This is called when our OpenGL context is invalidated. */
void Invalidate();
void Allocate( const std::vector<msMesh> &vMeshes );
void Change( const std::vector<msMesh> &vMeshes );
void Draw( int iMeshIndex ) const;
@@ -1305,45 +1306,45 @@ void RageCompiledGeometryHWOGL::Allocate( const std::vector<msMesh> &vMeshes )
RageCompiledGeometrySWOGL::Allocate( vMeshes );
glBindBufferARB( GL_ARRAY_BUFFER_ARB, m_nPositions );
DebugAssertNoGLError();
glBufferDataARB(
GL_ARRAY_BUFFER_ARB,
GetTotalVertices()*sizeof(RageVector3),
nullptr,
glBufferDataARB(
GL_ARRAY_BUFFER_ARB,
GetTotalVertices()*sizeof(RageVector3),
nullptr,
GL_STATIC_DRAW_ARB );
DebugAssertNoGLError();
glBindBufferARB( GL_ARRAY_BUFFER_ARB, m_nTextureCoords );
DebugAssertNoGLError();
glBufferDataARB(
GL_ARRAY_BUFFER_ARB,
GetTotalVertices()*sizeof(RageVector2),
nullptr,
glBufferDataARB(
GL_ARRAY_BUFFER_ARB,
GetTotalVertices()*sizeof(RageVector2),
nullptr,
GL_STATIC_DRAW_ARB );
DebugAssertNoGLError();
glBindBufferARB( GL_ARRAY_BUFFER_ARB, m_nNormals );
DebugAssertNoGLError();
glBufferDataARB(
GL_ARRAY_BUFFER_ARB,
GetTotalVertices()*sizeof(RageVector3),
nullptr,
glBufferDataARB(
GL_ARRAY_BUFFER_ARB,
GetTotalVertices()*sizeof(RageVector3),
nullptr,
GL_STATIC_DRAW_ARB );
DebugAssertNoGLError();
glBindBufferARB( GL_ELEMENT_ARRAY_BUFFER_ARB, m_nTriangles );
DebugAssertNoGLError();
glBufferDataARB(
GL_ELEMENT_ARRAY_BUFFER_ARB,
GetTotalTriangles()*sizeof(msTriangle),
nullptr,
glBufferDataARB(
GL_ELEMENT_ARRAY_BUFFER_ARB,
GetTotalTriangles()*sizeof(msTriangle),
nullptr,
GL_STATIC_DRAW_ARB );
DebugAssertNoGLError();
glBindBufferARB( GL_ARRAY_BUFFER_ARB, m_nTextureMatrixScale );
DebugAssertNoGLError();
glBufferDataARB(
GL_ARRAY_BUFFER_ARB,
GetTotalVertices()*sizeof(RageVector2),
glBufferDataARB(
GL_ARRAY_BUFFER_ARB,
GetTotalVertices()*sizeof(RageVector2),
nullptr,
GL_STATIC_DRAW_ARB );
}
@@ -1380,7 +1381,7 @@ void RageCompiledGeometryHWOGL::Draw( int iMeshIndex ) const
glTexCoordPointer(2, GL_FLOAT, 0, nullptr);
DebugAssertNoGLError();
// TRICKY: Don't bind and send normals if lighting is disabled. This
// TRICKY: Don't bind and send normals if lighting is disabled. This
// will save some effort transforming these values.
// XXX: We should keep track of these ourself and avoid glGet*()
GLboolean bLighting;
@@ -1389,7 +1390,7 @@ void RageCompiledGeometryHWOGL::Draw( int iMeshIndex ) const
glGetBooleanv( GL_TEXTURE_GEN_S, &bTextureGenS );
GLboolean bTextureGenT;
glGetBooleanv( GL_TEXTURE_GEN_T, &bTextureGenT );
if (bLighting || bTextureGenS || bTextureGenT)
{
glEnableClientState(GL_NORMAL_ARRAY);
@@ -1455,8 +1456,8 @@ void RageCompiledGeometryHWOGL::Draw( int iMeshIndex ) const
#define BUFFER_OFFSET(o) ((char*)(o))
ASSERT( glDrawRangeElements != nullptr );
glDrawRangeElements(
GL_TRIANGLES,
glDrawRangeElements(
GL_TRIANGLES,
meshInfo.iVertexStart, // minimum array index contained in indices
meshInfo.iVertexStart+meshInfo.iVertexCount-1,
// maximum array index contained in indices
@@ -1535,10 +1536,10 @@ void RageDisplay_Legacy::DrawSymmetricQuadStripInternal( const RageSpriteVertex
SendCurrentMatrices();
SetupVertices( v, iNumVerts );
glDrawElements(
GL_TRIANGLES,
glDrawElements(
GL_TRIANGLES,
iNumIndices,
GL_UNSIGNED_SHORT,
GL_UNSIGNED_SHORT,
&vIndices[0] );
}
@@ -1744,7 +1745,7 @@ void RageDisplay_Legacy::SetTextureMode( TextureUnit tu, TextureMode tm )
void RageDisplay_Legacy::SetTextureFiltering( TextureUnit tu, bool b )
{
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, b ? GL_LINEAR : GL_NEAREST);
GLint iMinFilter;
if (b)
{
@@ -1984,13 +1985,13 @@ void RageDisplay_Legacy::SetTextureWrapping( TextureUnit tu, bool b )
* so we'll behave incorrectly if the same texture is used in more than one texture
* unit simultaneously with different wrapping. */
SetTextureUnit( tu );
GLenum mode = b ? GL_REPEAT : GL_CLAMP_TO_EDGE;
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, mode );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, mode );
}
void RageDisplay_Legacy::SetMaterial(
void RageDisplay_Legacy::SetMaterial(
const RageColor &emissive,
const RageColor &ambient,
const RageColor &diffuse,
@@ -1998,7 +1999,7 @@ void RageDisplay_Legacy::SetMaterial(
float shininess
)
{
// TRICKY: If lighting is off, then setting the material
// TRICKY: If lighting is off, then setting the material
// will have no effect. Even if lighting is off, we still
// want Models to have basic color and transparency.
// We can do this fake lighting by setting the vertex color.
@@ -2037,11 +2038,11 @@ void RageDisplay_Legacy::SetLightOff( int index )
glDisable( GL_LIGHT0+index );
}
void RageDisplay_Legacy::SetLightDirectional(
int index,
const RageColor &ambient,
const RageColor &diffuse,
const RageColor &specular,
void RageDisplay_Legacy::SetLightDirectional(
int index,
const RageColor &ambient,
const RageColor &diffuse,
const RageColor &specular,
const RageVector3 &dir )
{
// Light coordinates are transformed by the modelview matrix, but
@@ -2132,7 +2133,7 @@ void RageDisplay_Legacy::DeleteTexture( uintptr_t iTexture )
RagePixelFormat RageDisplay_Legacy::GetImgPixelFormat( RageSurface* &img, bool &bFreeImg, int width, int height, bool bPalettedTexture )
{
RagePixelFormat pixfmt = FindPixelFormat( img->format->BitsPerPixel, img->format->Rmask, img->format->Gmask, img->format->Bmask, img->format->Amask );
/* If img is paletted, we're setting up a non-paletted texture, and color indexes
* are too small, depalettize. */
bool bSupported = true;
@@ -2196,7 +2197,7 @@ void SetPixelMapForSurface( int glImageFormat, int glTexFormat, const RageSurfac
DebugAssertNoGLError();
}
uintptr_t RageDisplay_Legacy::CreateTexture(
uintptr_t RageDisplay_Legacy::CreateTexture(
RagePixelFormat pixfmt,
RageSurface* pImg,
bool bGenerateMipMaps )
@@ -2244,7 +2245,7 @@ uintptr_t RageDisplay_Legacy::CreateTexture(
uintptr_t iTexHandle;
glGenTextures( 1, reinterpret_cast<GLuint*>(&iTexHandle) );
ASSERT( iTexHandle != 0 );
glBindTexture( GL_TEXTURE_2D, static_cast<GLuint>(iTexHandle) );
if (g_pWind->GetActualVideoModeParams().bAnisotropicFiltering &&
@@ -2296,7 +2297,7 @@ uintptr_t RageDisplay_Legacy::CreateTexture(
if (bGenerateMipMaps)
{
GLenum error = gluBuild2DMipmaps(
GL_TEXTURE_2D, glTexFormat,
GL_TEXTURE_2D, glTexFormat,
pImg->w, pImg->h,
glImageFormat, glImageType, pImg->pixels );
ASSERT_M( error == 0, (char *) gluErrorString(error) );
@@ -2304,7 +2305,7 @@ uintptr_t RageDisplay_Legacy::CreateTexture(
else
{
glTexImage2D(
GL_TEXTURE_2D, 0, glTexFormat,
GL_TEXTURE_2D, 0, glTexFormat,
power_of_two(pImg->w), power_of_two(pImg->h), 0,
glImageFormat, glImageType, nullptr );
if (pImg->pixels)
@@ -2312,7 +2313,7 @@ uintptr_t RageDisplay_Legacy::CreateTexture(
0, 0,
pImg->w, pImg->h,
glImageFormat, glImageType, pImg->pixels );
DebugAssertNoGLError();
}
@@ -2414,8 +2415,8 @@ RageTextureLock *RageDisplay_Legacy::CreateTextureLock()
return new RageTextureLock_OGL;
}
void RageDisplay_Legacy::UpdateTexture(
uintptr_t iTexHandle,
void RageDisplay_Legacy::UpdateTexture(
uintptr_t iTexHandle,
RageSurface* pImg,
int iXOffset, int iYOffset, int iWidth, int iHeight )
{
@@ -2460,7 +2461,7 @@ public:
uintptr_t GetTexture() const { return m_iTexHandle; }
void StartRenderingTo();
void FinishRenderingTo();
virtual bool InvertY() const { return true; }
private:
@@ -2491,7 +2492,7 @@ void RenderTarget_FramebufferObject::Create( const RenderTargetParam &param, int
m_Param = param;
DebugFlushGLErrors();
// Allocate OpenGL texture resource
glGenTextures( 1, reinterpret_cast<GLuint*>(&m_iTexHandle) );
ASSERT( m_iTexHandle != 0 );
@@ -2509,7 +2510,7 @@ void RenderTarget_FramebufferObject::Create( const RenderTargetParam &param, int
internalformat = param.bWithAlpha? GL_RGBA16F_ARB:GL_RGB16F_ARB;
else
internalformat = param.bWithAlpha? GL_RGBA8:GL_RGB8;
glTexImage2D( GL_TEXTURE_2D, 0, internalformat,
iTextureWidth, iTextureHeight, 0, type, GL_UNSIGNED_BYTE, nullptr );
DebugAssertNoGLError();
@@ -2620,7 +2621,7 @@ void RageDisplay_Legacy::SetRenderTarget( uintptr_t iTexture, bool bPreserveText
{
g_bInvertY = false;
glFrontFace( GL_CCW );
/* Pop matrixes affected by SetDefaultRenderStates. */
DISPLAY->CameraPopMatrix();
@@ -2753,7 +2754,7 @@ void RageDisplay_Legacy::SetAlphaTest(bool b)
* everything supports packed pixels.
*
* Another case of this is incomplete packed pixels support. Some implementations
* neglect GL_UNSIGNED_SHORT_*_REV.
* neglect GL_UNSIGNED_SHORT_*_REV.
*/
bool RageDisplay_Legacy::SupportsSurfaceFormat(RagePixelFormat pixfmt)
{
+19 -16
View File
@@ -8,7 +8,10 @@
#include "RageLog.h"
#include "RageMath.h"
#include "RageTypes.h"
#include <float.h>
#include <cfloat>
#include <cmath>
void RageVec3ClearBounds( RageVector3 &mins, RageVector3 &maxs )
{
@@ -28,14 +31,14 @@ void RageVec3AddToBounds( const RageVector3 &p, RageVector3 &mins, RageVector3 &
void RageVec2Normalize( RageVector2* pOut, const RageVector2* pV )
{
float scale = 1.0f / sqrtf( pV->x*pV->x + pV->y*pV->y );
float scale = 1.0f / std::sqrt( pV->x*pV->x + pV->y*pV->y );
pOut->x = pV->x * scale;
pOut->y = pV->y * scale;
}
void RageVec3Normalize( RageVector3* pOut, const RageVector3* pV )
{
float scale = 1.0f / sqrtf( pV->x*pV->x + pV->y*pV->y + pV->z*pV->z );
float scale = 1.0f / std::sqrt( pV->x*pV->x + pV->y*pV->y + pV->z*pV->z );
pOut->x = pV->x * scale;
pOut->y = pV->y * scale;
pOut->z = pV->z * scale;
@@ -44,7 +47,7 @@ void RageVec3Normalize( RageVector3* pOut, const RageVector3* pV )
void VectorFloatNormalize(std::vector<float>& v)
{
ASSERT_M(v.size() == 3, "Can't normalize a non-3D vector.");
float scale = 1.0f / sqrtf(v[0]*v[0] + v[1]*v[1] + v[2]*v[2]);
float scale = 1.0f / std::sqrt(v[0]*v[0] + v[1]*v[1] + v[2]*v[2]);
v[0]*= scale;
v[1]*= scale;
v[2]*= scale;
@@ -152,7 +155,7 @@ void RageMatrixMultiply( RageMatrix* pOut, const RageMatrix* pA, const RageMatri
b.m30*a.m00+b.m31*a.m10+b.m32*a.m20+b.m33*a.m30,
b.m30*a.m01+b.m31*a.m11+b.m32*a.m21+b.m33*a.m31,
b.m30*a.m02+b.m31*a.m12+b.m32*a.m22+b.m33*a.m32,
b.m30*a.m03+b.m31*a.m13+b.m32*a.m23+b.m33*a.m33
b.m30*a.m03+b.m31*a.m13+b.m32*a.m23+b.m33*a.m33
);
// phew!
//#endif
@@ -356,9 +359,9 @@ void RageQuatMultiply( RageVector4* pOut, const RageVector4 &pA, const RageVecto
float dist, square;
square = out.x * out.x + out.y * out.y + out.z * out.z + out.w * out.w;
if (square > 0.0)
dist = 1.0f / sqrtf(square);
dist = 1.0f / std::sqrt(square);
else dist = 1;
out.x *= dist;
@@ -467,7 +470,7 @@ void RageMatrixFromQuat( RageMatrix* pOut, const RageVector4 q )
float yz = q.y * (q.z + q.z);
float zz = q.z * (q.z + q.z);
// careful. The param order is row-major, which is the
// careful. The param order is row-major, which is the
// transpose of the order shown in the OpenGL docs.
*pOut = RageMatrix(
1-(yy+zz), xy+wz, xz-wy, 0,
@@ -505,14 +508,14 @@ void RageQuatSlerp(RageVector4 *pOut, const RageVector4 &from, const RageVector4
if ( cosom < 0.9999f )
{
// standard case (slerp)
float omega = acosf(cosom);
float omega = std::acos(cosom);
float sinom = RageFastSin(omega);
scale0 = RageFastSin((1.0f - t) * omega) / sinom;
scale1 = RageFastSin(t * omega) / sinom;
}
else
{
// "from" and "to" quaternions are very close
// "from" and "to" quaternions are very close
// ... so we can do a linear interpolation
scale0 = 1.0f - t;
scale1 = t;
@@ -565,7 +568,7 @@ RageMatrix RageLookAt(
void RageMatrixAngles( RageMatrix* pOut, const RageVector3 &angles )
{
const RageVector3 angles_radians( angles * 2*PI / 360 );
const float sy = RageFastSin( angles_radians[2] );
const float cy = RageFastCos( angles_radians[2] );
const float sp = RageFastSin( angles_radians[1] );
@@ -606,7 +609,7 @@ struct sine_initter
for(unsigned int i= 0; i < sine_table_size; ++i)
{
float angle= SCALE(i, 0, sine_table_size, 0.0f, PI);
sine_table[i]= sinf(angle);
sine_table[i]= std::sin(angle);
}
}
};
@@ -654,7 +657,7 @@ float RageFastCsc( float x )
float RageSquare( float angle )
{
float fAngle = fmod( angle , (PI * 2) );
float fAngle = std::fmod( angle , (PI * 2) );
//Hack: This ensures the hold notes don't flicker right before they're hit.
if(fAngle < 0.01f)
{
@@ -665,7 +668,7 @@ float RageSquare( float angle )
float RageTriangle( float angle )
{
float fAngle= fmod(angle, PI * 2.0f);
float fAngle= std::fmod(angle, PI * 2.0f);
if(fAngle < 0.0)
{
fAngle+= PI * 2.0;
@@ -683,7 +686,7 @@ float RageTriangle( float angle )
{
return -4.0 + (result * 2.0);
}
}
float RageQuadratic::Evaluate( float fT ) const
@@ -742,7 +745,7 @@ float RageBezier2D::EvaluateYFromX( float fX ) const
float fError = fX-fGuessedX;
/* If our guess is good enough, evaluate the result Y and return. */
if( unlikely(fabsf(fError) < 0.0001f) )
if( unlikely(std::abs(fError) < 0.0001f) )
return m_Y.Evaluate( fT );
float fSlope = m_X.GetSlope( fT );
+7 -5
View File
@@ -36,6 +36,8 @@
#include "RageSoundReader_FileReader.h"
#include "RageSoundReader_ThreadedBuffer.h"
#include <cmath>
#define samplerate() m_pSource->GetSampleRate()
RageSoundParams::RageSoundParams():
@@ -48,7 +50,7 @@ RageSoundLoadParams::RageSoundLoadParams():
m_bSupportRateChanging(false), m_bSupportPan(false) {}
RageSound::RageSound():
m_Mutex( "RageSound" ), m_pSource(nullptr),
m_Mutex( "RageSound" ), m_pSource(nullptr),
m_sFilePath(""), m_Param(), m_iStreamFrame(0),
m_iStoppedSourceFrame(0), m_bPlaying(false),
m_bDeleteWhenFinished(false), m_sError("")
@@ -112,7 +114,7 @@ void RageSound::Unload()
delete m_pSource;
}
m_pSource = nullptr;
m_sFilePath = "";
}
@@ -263,7 +265,7 @@ void RageSound::LoadSoundReader( RageSoundReader *pSound )
*
* On underrun, if no data was read, returns WOULD_BLOCK. On end of file, if no
* data was read, returns END_OF_FILE. If any data is read, it is returned; these
* conditions are masked and will be seen on the next call. Otherwise, the requested
* conditions are masked and will be seen on the next call. Otherwise, the requested
* number of frames will always be returned.
*/
int RageSound::GetDataToPlay( float *pBuffer, int iFrames, int64_t &iStreamFrame, int &iFramesStored )
@@ -328,7 +330,7 @@ void RageSound::StartPlaying()
ASSERT( !m_bPlaying );
// Move to the start position.
SetPositionFrames( lrintf(m_Param.m_StartSecond * samplerate()) );
SetPositionFrames( std::lrint(m_Param.m_StartSecond * samplerate()) );
/* If m_StartTime is in the past, then we probably set a start time but took too
* long loading. We don't want that; log it, since it can be unobvious. */
@@ -647,7 +649,7 @@ void RageSound::SetStopModeFromString( const RString &sStopMode )
// lua start
#include "LuaBinding.h"
/** @brief Allow Lua to have access to the RageSound. */
/** @brief Allow Lua to have access to the RageSound. */
class LunaRageSound: public Luna<RageSound>
{
public:
+3 -1
View File
@@ -2,6 +2,8 @@
#include "RageSoundMixBuffer.h"
#include "RageUtil.h"
#include <cmath>
#if defined(MACOSX)
#include "archutils/Darwin/VectorHelper.h"
#ifdef USE_VEC
@@ -79,7 +81,7 @@ void RageSoundMixBuffer::read( int16_t *pBuf )
{
float iOut = m_pMixbuf[iPos];
iOut = clamp( iOut, -1.0f, +1.0f );
pBuf[iPos] = lrintf(iOut * 32767);
pBuf[iPos] = std::lrint(iOut * 32767);
}
m_iBufUsed = 0;
}
+8 -7
View File
@@ -4,7 +4,8 @@
#include "RageUtil.h"
#include "RageTimer.h"
#include <limits.h>
#include <climits>
#include <cmath>
#include <list>
/* The number of frames we should keep pos_map data for. This being too high
@@ -60,7 +61,7 @@ void pos_map_queue::Insert( int64_t iSourceFrame, int iFrames, int64_t iDestFram
pos_map_t &last = m_pImpl->m_Queue.back();
if( last.m_iSourceFrame + last.m_iFrames == iSourceFrame &&
last.m_fSourceToDestRatio == fSourceToDestRatio &&
llabs(last.m_iDestFrame + lrintf(last.m_iFrames * last.m_fSourceToDestRatio) - iDestFrame) <= 1 )
llabs(last.m_iDestFrame + std::lrint(last.m_iFrames * last.m_fSourceToDestRatio) - iDestFrame) <= 1 )
{
last.m_iFrames += iFrames;
@@ -82,7 +83,7 @@ void pos_map_queue::Insert( int64_t iSourceFrame, int iFrames, int64_t iDestFram
next.m_iSourceFrame += iDeleteFrames;
next.m_iFrames -= iDeleteFrames;
next.m_iDestFrame += lrintf( iDeleteFrames * next.m_fSourceToDestRatio );
next.m_iDestFrame += std::lrint( iDeleteFrames * next.m_fSourceToDestRatio );
m_pImpl->m_Queue.push_back( next );
}
@@ -99,7 +100,7 @@ void pos_map_queue::Insert( int64_t iSourceFrame, int iFrames, int64_t iDestFram
m.m_iDestFrame = iDestFrame;
m.m_iFrames = iFrames;
m.m_fSourceToDestRatio = fSourceToDestRatio;
m_pImpl->Cleanup();
}
@@ -143,7 +144,7 @@ int64_t pos_map_queue::Search( int64_t iSourceFrame, bool *bApproximate ) const
/* iSourceFrame lies in this block; it's an exact match. Figure
* out the exact position. */
int iDiff = int(iSourceFrame - pm.m_iSourceFrame);
iDiff = lrintf( iDiff * pm.m_fSourceToDestRatio );
iDiff = std::lrint( iDiff * pm.m_fSourceToDestRatio );
return pm.m_iDestFrame + iDiff;
}
@@ -162,7 +163,7 @@ int64_t pos_map_queue::Search( int64_t iSourceFrame, bool *bApproximate ) const
{
iClosestPositionDist = dist;
pClosestBlock = &pm;
iClosestPosition = pm.m_iDestFrame + lrintf( pm.m_iFrames * pm.m_fSourceToDestRatio );
iClosestPosition = pm.m_iDestFrame + std::lrint( pm.m_iFrames * pm.m_fSourceToDestRatio );
}
}
@@ -170,7 +171,7 @@ int64_t pos_map_queue::Search( int64_t iSourceFrame, bool *bApproximate ) const
* The frame is out of the range of data we've actually sent.
* Return the closest position.
*
* There are three cases when this happens:
* There are three cases when this happens:
* 1. Before the first CommitPlayingPosition call.
* 2. After GetDataToPlay returns EOF and the sound has flushed, but before
* SoundStopped has been called.
+4 -2
View File
@@ -9,6 +9,8 @@
#include "RageSoundMixBuffer.h"
#include "RageSoundUtil.h"
#include <cmath>
/*
* Keyed sounds should pass this object to SoundReader_Preload, to preprocess it.
@@ -53,7 +55,7 @@ void RageSoundReader_Chain::AddSound( int iIndex, float fOffsetSecs, float fPan
Sound s;
s.iIndex = iIndex;
s.iOffsetMS = lrintf( fOffsetSecs * 1000 );
s.iOffsetMS = std::lrint( fOffsetSecs * 1000 );
s.fPan = fPan;
s.pSound = nullptr;
m_aSounds.push_back( s );
@@ -85,7 +87,7 @@ int RageSoundReader_Chain::LoadSound( RString sPath )
}
m_apNamedSounds[sPath] = pReader;
m_apLoadedSounds.push_back( m_apNamedSounds[sPath] );
return m_apLoadedSounds.size()-1;
}
+6 -4
View File
@@ -4,6 +4,8 @@
#include "RageSoundUtil.h"
#include "RageUtil.h"
#include <cmath>
/*
* Add support for negative seeks (adding a delay), extending a sound
* beyond its end (m_LengthSeconds and M_CONTINUE), looping and fading.
@@ -153,7 +155,7 @@ bool RageSoundReader_Extend::SetProperty( const RString &sProperty, float fValue
{
if( sProperty == "StartSecond" )
{
m_iStartFrames = lrintf( fValue * this->GetSampleRate() );
m_iStartFrames = std::lrint( fValue * this->GetSampleRate() );
return true;
}
@@ -162,7 +164,7 @@ bool RageSoundReader_Extend::SetProperty( const RString &sProperty, float fValue
if( fValue == -1 )
m_iLengthFrames = -1;
else
m_iLengthFrames = lrintf( fValue * this->GetSampleRate() );
m_iLengthFrames = std::lrint( fValue * this->GetSampleRate() );
return true;
}
@@ -186,13 +188,13 @@ bool RageSoundReader_Extend::SetProperty( const RString &sProperty, float fValue
if( sProperty == "FadeInSeconds" )
{
m_iFadeInFrames = lrintf( fValue * this->GetSampleRate() );
m_iFadeInFrames = std::lrint( fValue * this->GetSampleRate() );
return true;
}
if( sProperty == "FadeSeconds" || sProperty == "FadeOutSeconds" )
{
m_iFadeOutFrames = lrintf( fValue * this->GetSampleRate() );
m_iFadeOutFrames = std::lrint( fValue * this->GetSampleRate() );
return true;
}
+11 -9
View File
@@ -7,6 +7,8 @@
#include "RageSoundMixBuffer.h"
#include "RageSoundUtil.h"
#include <cmath>
RageSoundReader_Merge::RageSoundReader_Merge()
{
@@ -140,8 +142,8 @@ bool RageSoundReader_Merge::SetProperty( const RString &sProperty, float fValue
return bRet;
}
static float Difference( float a, float b ) { return fabsf( a - b ); }
static int Difference( int a, int b ) { return abs( a - b ); }
static float Difference( float a, float b ) { return std::abs( a - b ); }
static int Difference( int a, int b ) { return std::abs( a - b ); }
/*
* If the audio position drifts apart further than ERROR_CORRECTION_THRESHOLD frames,
@@ -174,7 +176,7 @@ int RageSoundReader_Merge::Read( float *pBuffer, int iFrames )
/*
* All sounds which are active should stay aligned; each GetNextSourceFrame should not
* come out of sync. Accomodate small rounding errors. A larger inconsistency
* happens may be a bug, such as sounds at different speeds.
* happens may be a bug, such as sounds at different speeds.
*/
std::vector<int> aNextSourceFrames;
@@ -212,7 +214,7 @@ int RageSoundReader_Merge::Read( float *pBuffer, int iFrames )
/* A sound is being delayed to resync it; clamp the number of frames we
* read now, so we don't advance past it. */
int iMaxSourceFramesToRead = aNextSourceFrames[i] - iMinPosition;
int iMaxStreamFramesToRead = lrintf( iMaxSourceFramesToRead / m_fCurrentStreamToSourceRatio );
int iMaxStreamFramesToRead = std::lrint( iMaxSourceFramesToRead / m_fCurrentStreamToSourceRatio );
iFrames = std::min( iFrames, iMaxStreamFramesToRead );
// LOG->Warn( "RageSoundReader_Merge: sound positions moving at different rates" );
}
@@ -224,7 +226,7 @@ int RageSoundReader_Merge::Read( float *pBuffer, int iFrames )
RageSoundReader *pSound = m_aSounds.front();
iFrames = pSound->Read( pBuffer, iFrames );
if( iFrames > 0 )
m_iNextSourceFrame += lrintf( iFrames * m_fCurrentStreamToSourceRatio );
m_iNextSourceFrame += std::lrint( iFrames * m_fCurrentStreamToSourceRatio );
aNextSourceFrames.front() = pSound->GetNextSourceFrame();
aRatios.front() = pSound->GetStreamToSourceRatio();
return iFrames;
@@ -244,11 +246,11 @@ int RageSoundReader_Merge::Read( float *pBuffer, int iFrames )
while( iFramesRead < iFrames )
{
// if( i == 0 )
//LOG->Trace( "*** %i", Difference(aNextSourceFrames[i], m_iNextSourceFrame + lrintf(iFramesRead * aRatios[i])) );
//LOG->Trace( "*** %i", Difference(aNextSourceFrames[i], m_iNextSourceFrame + std::lrint(iFramesRead * aRatios[i])) );
if( Difference(aNextSourceFrames[i], m_iNextSourceFrame + lrintf(iFramesRead * aRatios[i])) > ERROR_CORRECTION_THRESHOLD )
if( Difference(aNextSourceFrames[i], m_iNextSourceFrame + std::lrint(iFramesRead * aRatios[i])) > ERROR_CORRECTION_THRESHOLD )
{
LOG->Trace( "*** hurk %i", Difference(aNextSourceFrames[i], m_iNextSourceFrame + lrintf(iFramesRead * aRatios[i])) );
LOG->Trace( "*** hurk %i", Difference(aNextSourceFrames[i], m_iNextSourceFrame + std::lrint(iFramesRead * aRatios[i])) );
break;
}
@@ -276,7 +278,7 @@ int RageSoundReader_Merge::Read( float *pBuffer, int iFrames )
int iMaxFramesRead = mix.size() / m_iChannels;
mix.read( pBuffer );
m_iNextSourceFrame += lrintf( iMaxFramesRead * m_fCurrentStreamToSourceRatio );
m_iNextSourceFrame += std::lrint( iMaxFramesRead * m_fCurrentStreamToSourceRatio );
return iMaxFramesRead;
}
+7 -5
View File
@@ -7,6 +7,8 @@
#include "RageSoundUtil.h"
#include "Preference.h"
#include <cmath>
/* If true, preloaded sounds are stored in 16-bit instead of floats. Most
* processing happens after preloading, and it's usually a waste to store high-
* resolution data for sound effects. */
@@ -53,14 +55,14 @@ bool RageSoundReader_Preload::Open( RageSoundReader *pSource )
m_fRate = pSource->GetStreamToSourceRatio();
int iMaxSamples = g_iSoundPreloadMaxSamples.Get();
/* Check the length, and see if we think it'll fit in the buffer. */
int iLen = pSource->GetLength_Fast();
if( iLen != -1 )
{
float fSecs = iLen / 1000.f;
int iFrames = lrintf( fSecs * m_iSampleRate ); /* seconds -> frames */
int iFrames = std::lrint( fSecs * m_iSampleRate ); /* seconds -> frames */
int iSamples = unsigned( iFrames * m_iChannels ); /* frames -> samples */
if( iSamples > iMaxSamples )
return false; /* Don't bother trying to preload it. */
@@ -123,7 +125,7 @@ int RageSoundReader_Preload::GetLength_Fast() const
int RageSoundReader_Preload::SetPosition( int iFrame )
{
m_iPosition = iFrame;
m_iPosition = lrintf(m_iPosition / m_fRate);
m_iPosition = std::lrint(m_iPosition / m_fRate);
if( m_iPosition >= int(m_Buffer->size() / framesize) )
{
@@ -136,7 +138,7 @@ int RageSoundReader_Preload::SetPosition( int iFrame )
int RageSoundReader_Preload::GetNextSourceFrame() const
{
return lrintf(m_iPosition * m_fRate);
return std::lrint(m_iPosition * m_fRate);
}
int RageSoundReader_Preload::Read( float *pBuffer, int iFrames )
@@ -157,7 +159,7 @@ int RageSoundReader_Preload::Read( float *pBuffer, int iFrames )
memcpy( pBuffer, m_Buffer->data() + (m_iPosition * framesize), iFrames * framesize );
}
m_iPosition += iFrames;
return iFrames;
}
+15 -14
View File
@@ -12,6 +12,7 @@
#include "RageMath.h"
#include "RageThreads.h"
#include <cmath>
#include <numeric>
/* Filter length. This must be a power of 2. */
@@ -23,14 +24,14 @@ namespace
{
if( f == 0 )
return 1;
return sinf(f)/f;
return std::sin(f) / f;
}
/* Modified Bessel function I0. From Abramowitz and Stegun "Handbook of Mathematical
* Functions", "Modified Bessel Functions I and K". */
float BesselI0( float fX )
{
float fAbsX = fabsf( fX );
float fAbsX = std::abs( fX );
if( fAbsX < 3.75f )
{
float y = fX / 3.75f;
@@ -41,16 +42,16 @@ namespace
else
{
float y = 3.75f/fAbsX;
float fRet = (exp(fAbsX)/sqrt(fAbsX)) *
float fRet = (std::exp(fAbsX)/std::sqrt(fAbsX)) *
(+0.39894228f+y*(+0.01328592f+y*(+0.00225319f+y*(-0.00157565f+y*(0.00916281f+
y*(-0.02057706f+y*(+0.02635537f+y*(-0.01647633f+y*+0.00392377f))))))));
return fRet;
}
}
/*
/*
* Kaiser window:
*
*
* K(n) = I0( B*sqrt(1-(n/p)^2) )
* -----------------------
* I0(B)
@@ -63,8 +64,8 @@ namespace
float p = (iLen-1)/2.0f;
for( int n = 0; n < iLen; ++n )
{
float fN1 = fabsf((n-p)/p);
float fNum = fBeta * sqrtf( std::max(1-fN1*fN1, 0.0f) );
float fN1 = std::abs((n-p)/p);
float fNum = fBeta * std::sqrt( std::max(1.0f - fN1*fN1, 0.0f) );
fNum = BesselI0( fNum );
float fVal = fNum/fDenom;
pBuf[n] *= fVal;
@@ -216,7 +217,7 @@ private:
* input first output sample (before decimation)
* sample second output sample
* third output sample
*
*
* 0 0
* 0 1 0
* 1592 2 1 0
@@ -290,7 +291,7 @@ int PolyphaseFilter::RunPolyphaseFilter(
float *pOutOrig = pOut;
const float *pInEnd = pIn + iSamplesIn*iSampleStride;
const float *pOutEnd = pOut + iSamplesOut*iSampleStride;
int iFilled = State.m_iFilled;
int iPolyIndex = State.m_iPolyIndex;
while( pOut != pOutEnd )
@@ -394,7 +395,7 @@ namespace PolyphaseFilterCache
typedef std::map<std::pair<int, float>, PolyphaseFilter*> FilterMap;
static RageMutex PolyphaseFiltersLock("PolyphaseFiltersLock");
static FilterMap g_mapPolyphaseFilters;
const PolyphaseFilter *MakePolyphaseFilter( int iUpFactor, float fCutoffFrequency )
{
PolyphaseFiltersLock.Lock();
@@ -452,7 +453,7 @@ public:
* too much filtering, by not having a LPF that's high enough. */
RageSoundResampler_Polyphase( int iUpFactor, int iMinDownFactor, int iMaxDownFactor )
{
/* Cache filters between iMinDownFactor and iMaxDownFactor. Do them in
/* Cache filters between iMinDownFactor and iMaxDownFactor. Do them in
* iFilterIncrement increments; we'll round down to the closest match
* when filtering. This will only cause the low-pass filter to be rounded;
* the conversion ratio will always be exact. */
@@ -527,7 +528,7 @@ private:
float fCutoffFrequency = GetCutoffFrequency( iDownFactor );
return PolyphaseFilterCache::FindNearestPolyphaseFilter( m_iUpFactor, fCutoffFrequency );
}
const PolyphaseFilter *m_pPolyphase;
PolyphaseFilter::State *m_pState;
int m_iUpFactor;
@@ -620,7 +621,7 @@ void RageSoundReader_Resample_Good::ReopenResampler()
}
if( m_fRate != -1 )
iDownFactor = lrintf( m_fRate * iDownFactor );
iDownFactor = std::lrint( m_fRate * iDownFactor );
for( size_t iChannel = 0; iChannel < m_apResamplers.size(); ++iChannel )
m_apResamplers[iChannel]->SetDownFactor( iDownFactor );
@@ -696,7 +697,7 @@ void RageSoundReader_Resample_Good::SetRate( float fRatio )
int iDownFactor, iUpFactor;
GetFactors( iDownFactor, iUpFactor );
if( m_fRate != -1 )
iDownFactor = lrintf( m_fRate * iDownFactor );
iDownFactor = std::lrint( m_fRate * iDownFactor );
/* Set m_fRate to the actual rate, after quantization by iUpFactor. */
m_fRate = float(iDownFactor) / iUpFactor;
+5 -3
View File
@@ -3,6 +3,8 @@
#include "RageUtil.h"
#include "RageLog.h"
#include <cmath>
static const int WINDOW_SIZE_MS = 30;
RageSoundReader_SpeedChange::RageSoundReader_SpeedChange( RageSoundReader *pSource ):
@@ -63,7 +65,7 @@ static int FindClosestMatch( const float *pBuffer, int iBufferSize, const float
for( int j = 0; j < iCorrelateBufferSize; j += iStride )
{
float fDiff = pFrames[j] - pCorrelateBuffer[j];
fScore += fabsf(fDiff);
fScore += std::abs(fDiff);
}
if( i == 0 || fScore < fBestScore )
@@ -163,7 +165,7 @@ int RageSoundReader_SpeedChange::Step()
* by 2.0 frames, and advance by 0.3 more the next time around. */
float fAdvanceFrames = GetWindowSizeFrames() * m_fTrailingSpeedRatio;
fAdvanceFrames += m_fErrorFrames;
int iTrailingDeltaFrames = lrintf( fAdvanceFrames );
int iTrailingDeltaFrames = std::lrint( fAdvanceFrames );
m_fErrorFrames = fAdvanceFrames - iTrailingDeltaFrames;
m_iUncorrelatedPos += iTrailingDeltaFrames;
@@ -312,7 +314,7 @@ int RageSoundReader_SpeedChange::GetNextSourceFrame() const
float fRatio = m_fTrailingSpeedRatio;
int iSourceFrame = RageSoundReader_Filter::GetNextSourceFrame();
int iPos = lrintf(m_iPos * fRatio);
int iPos = std::lrint(m_iPos * fRatio);
iSourceFrame -= m_iDataBufferAvailFrames;
iSourceFrame += m_iUncorrelatedPos + iPos;
+3 -1
View File
@@ -4,6 +4,8 @@
#include "RageTimer.h"
#include "RageLog.h"
#include <cmath>
/* Implement threaded read-ahead buffering.
*
* If a buffer is low on data, keep filling until it has a g_iMinFillFrames.
@@ -235,7 +237,7 @@ void RageSoundReader_ThreadedBuffer::BufferingThread()
else
{
m_Event.Unlock();
usleep( lrintf(fTimeToSleep * 1000000) );
usleep( std::lrint(fTimeToSleep * 1000000) );
m_Event.Lock();
}
}
+3 -1
View File
@@ -2,6 +2,8 @@
#include "RageSoundUtil.h"
#include "RageUtil.h"
#include <cmath>
void RageSoundUtil::Attenuate( float *pBuf, int iSamples, float fVolume )
{
while( iSamples-- )
@@ -91,7 +93,7 @@ void RageSoundUtil::ConvertFloatToNativeInt16( const float *pFrom, int16_t *pTo,
{
for( int i = 0; i < iSamples; ++i )
{
int iOut = lrintf( pFrom[i] * 32768.0f );
int iOut = std::lrint( pFrom[i] * 32768.0f );
pTo[i] = clamp( iOut, -32768, 32767 );
}
}
+7 -6
View File
@@ -2,7 +2,8 @@
#include "RageSurface.h"
#include "RageUtil.h"
#include <limits.h>
#include <climits>
#include <cmath>
int32_t RageSurfacePalette::FindColor( const RageSurfaceColor &color ) const
@@ -23,10 +24,10 @@ int32_t RageSurfacePalette::FindClosestColor( const RageSurfaceColor &color ) co
if( colors[i] == color )
return i;
int iDist = abs( colors[i].r - color.r ) +
abs( colors[i].g - color.g ) +
abs( colors[i].b - color.b ) +
abs( colors[i].a - color.a );
int iDist = std::abs( colors[i].r - color.r ) +
std::abs( colors[i].g - color.g ) +
std::abs( colors[i].b - color.b ) +
std::abs( colors[i].a - color.a );
if( iDist < iBestDist )
{
iBestDist = iDist ;
@@ -84,7 +85,7 @@ bool RageSurfaceFormat::MapRGBA( uint8_t r, uint8_t g, uint8_t b, uint8_t a, uin
return false;
val = (uint32_t) n;
} else {
val =
val =
(r >> Loss[0] << Shift[0]) |
(g >> Loss[1] << Shift[1]) |
(b >> Loss[2] << Shift[2]) |
+12 -10
View File
@@ -5,6 +5,8 @@
#include "RageLog.h"
#include "RageFile.h"
#include <cmath>
uint32_t RageSurfaceUtils::decodepixel( const uint8_t *p, int bpp )
{
switch(bpp)
@@ -278,7 +280,7 @@ static void SetAlphaRGB(const RageSurface *pImg, uint8_t r, uint8_t g, uint8_t b
*
* A few images don't. We can only make a guess here. After the above
* search, do the same in reverse (bottom-top-right-left). If the color
* we find is different, just set the border color to black.
* we find is different, just set the border color to black.
*/
void RageSurfaceUtils::FixHiddenAlpha( RageSurface *pImg )
{
@@ -356,7 +358,7 @@ int RageSurfaceUtils::FindSurfaceTraits( const RageSurface *img )
}
int ret = 0;
switch( alpha_type )
switch( alpha_type )
{
case NEEDS_NO_ALPHA: ret |= TRAIT_NO_TRANSPARENCY; break;
case NEEDS_BOOL_ALPHA: ret |= TRAIT_BOOL_TRANSPARENCY; break;
@@ -384,7 +386,7 @@ static inline float scale( float x, float l1, float h1, float l2, float h2 )
}
// Completely unoptimized.
void RageSurfaceUtils::BlitTransform( const RageSurface *src, RageSurface *dst,
void RageSurfaceUtils::BlitTransform( const RageSurface *src, RageSurface *dst,
const float fCoords[8] /* TL, BR, BL, TR */ )
{
ASSERT( src->format->BytesPerPixel == dst->format->BytesPerPixel );
@@ -420,10 +422,10 @@ void RageSurfaceUtils::BlitTransform( const RageSurface *src, RageSurface *dst,
* pixel[1]; 2 indicates 50% pixel[1], 50% pixel[2] (which is clamped
* to pixel[1]). */
int src_x[2], src_y[2];
src_x[0] = (int) truncf(src_xp - 0.5f);
src_x[0] = std::trunc(src_xp - 0.5f);
src_x[1] = src_x[0] + 1;
src_y[0] = (int) truncf(src_yp - 0.5f);
src_y[0] = std::trunc(src_yp - 0.5f);
src_y[1] = src_y[0] + 1;
// Emulate GL_REPEAT.
@@ -452,7 +454,7 @@ void RageSurfaceUtils::BlitTransform( const RageSurface *src, RageSurface *dst,
sum += v[1][i] * (1-weight_x) * (weight_y);
sum += v[2][i] * (weight_x) * (1-weight_y);
sum += v[3][i] * (weight_x) * (weight_y);
out[i] = (uint8_t) clamp( lrintf(sum), 0L, 255L );
out[i] = (uint8_t) clamp( std::lrint(sum), 0L, 255L );
}
// If the source has no alpha, set the destination to opaque.
@@ -547,7 +549,7 @@ static bool blit_rgba_to_rgba( const RageSurface *src_surf, const RageSurface *d
* { 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3 }
* SCALE( i, 0, max_src_val, 0, max_dst_val );
* { 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3 }
* lrintf( ((float) i / max_src_val) * max_dst_val )
* std::lrint( ((float) i / max_src_val) * max_dst_val )
* { 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3 }
*
* We use the first for increasing resolution, since it gives the most even
@@ -558,7 +560,7 @@ static bool blit_rgba_to_rgba( const RageSurface *src_surf, const RageSurface *d
* { 0, 4, 8, 12 }
* SCALE( i, 0, max_src_val, 0, max_dst_val );
* { 0, 5, 10, 15 }
* lrintf( ((float) i / max_src_val) * max_dst_val )
* std::lrint( ((float) i / max_src_val) * max_dst_val )
* { 0, 5, 10, 15 }
*
* The latter two are equivalent and give an even distribution; we use the
@@ -861,10 +863,10 @@ RageSurface *RageSurfaceUtils::PalettizeToGrayscale( const RageSurface *src_surf
const unsigned int A = (index & Amask) >> Ashift;
// if only one intensity value, always fullbright
const uint8_t ScaledI = Ivalues == 1 ? 255 : clamp( lrintf(I * (255.0f / (Ivalues-1))), 0L, 255L );
const uint8_t ScaledI = Ivalues == 1 ? 255 : clamp( std::lrint(I * (255.0f / (Ivalues-1))), 0L, 255L );
// if only one alpha value, always opaque
const uint8_t ScaledA = Avalues == 1 ? 255 : clamp( lrintf(A * (255.0f / (Avalues-1))), 0L, 255L );
const uint8_t ScaledA = Avalues == 1 ? 255 : clamp( std::lrint(A * (255.0f / (Avalues-1))), 0L, 255L );
RageSurfaceColor c;
c.r = ScaledI;
+11 -10
View File
@@ -4,11 +4,12 @@
#include "RageSurfaceUtils.h"
#include "RageUtil.h"
#include <cmath>
#include <vector>
/* Coordinate 0x0 represents the exact top-left corner of a bitmap. .5x.5
* represents the center of the top-left pixel; 1x1 is the center of the top
* square of pixels.
* square of pixels.
*
* (Look at a grid: map coordinates to the lines, not the squares between the
* lines.) */
@@ -72,7 +73,7 @@ static void InitVectors( std::vector<int> &s0, std::vector<int> &s1, std::vector
s0.push_back( clamp(int(sax), 0, src-1));
s1.push_back( clamp(int(sax+1), 0, src-1) );
const float p = (1.0f - (sax - floorf(sax))) * 16777216.0f;
const float p = (1.0f - (sax - std::floor(sax))) * 16777216.0f;
percent.push_back( uint32_t(p) );
}
}
@@ -95,7 +96,7 @@ static void ZoomSurface( const RageSurface * src, RageSurface * dst )
for( int y = 0; y < height; y++ )
{
uint8_t *dp = (uint8_t *) (dst->pixels + dst->pitch*y);
/* current source pointer and next source pointer (first and second
/* current source pointer and next source pointer (first and second
* rows sampled for this row): */
const uint8_t *csp = sp + esy0[y] * src->pitch;
const uint8_t *ncsp = sp + esy1[y] * src->pitch;
@@ -116,7 +117,7 @@ static void ZoomSurface( const RageSurface * src, RageSurface * dst )
uint32_t x1 = uint32_t(c10[c]) * ex0[x];
x1 += uint32_t(c11[c]) * (16777216 - ex0[x]);
x1 >>= 24;
const uint32_t res = ((x0 * ey0[y]) + (x1 * (16777216-ey0[y])) + 8388608) >> 24;
dp[c] = uint8_t(res);
}
@@ -156,8 +157,8 @@ void RageSurfaceUtils::Zoom( RageSurface *&src, int dstwidth, int dstheight )
xscale = clamp( xscale, .5f, 2.0f );
yscale = clamp( yscale, .5f, 2.0f );
int target_width = lrintf( src->w*xscale );
int target_height = lrintf( src->h*yscale );
int target_width = std::lrint( src->w*xscale );
int target_height = std::lrint( src->h*yscale );
RageSurface *dst =
CreateSurface(target_width, target_height, 32,
@@ -172,10 +173,10 @@ void RageSurfaceUtils::Zoom( RageSurface *&src, int dstwidth, int dstheight )
}
}
/*
/*
* (c) A. Schiffler, Glenn Maynard
* All rights reserved.
*
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
@@ -185,7 +186,7 @@ void RageSurfaceUtils::Zoom( RageSurface *&src, int dstwidth, int dstheight )
* copyright notice(s) and this permission notice appear in all copies of
* the Software and that both the above copyright notice(s) and this
* permission notice appear in supporting documentation.
*
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
@@ -195,7 +196,7 @@ void RageSurfaceUtils::Zoom( RageSurface *&src, int dstwidth, int dstheight )
* OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*
*
* This is based on code from SDL_rotozoom, under the above license with
* permission from Andreas Schiffler.
*/
+6 -4
View File
@@ -26,7 +26,9 @@
#include "RageUtil.h"
#include "arch/ArchHooks/ArchHooks.h"
#include <cmath>
#define TIMESTAMP_RESOLUTION 1000000
const RageTimer RageZeroTimer(0,0);
@@ -39,7 +41,7 @@ static uint64_t GetTime( bool /* bAccurate */ )
/* This isn't threadsafe, and locking it would undo any benefit of not
* calling GetMicrosecondsSinceStart. */
#if 0
// if !bAccurate, then don't call ArchHooks to find the current time. Just return the
// if !bAccurate, then don't call ArchHooks to find the current time. Just return the
// last calculated time. GetMicrosecondsSinceStart is slow on some archs.
static uint64_t usecs = 0;
if( bAccurate )
@@ -88,7 +90,7 @@ float RageTimer::GetDeltaTime()
/*
* Get a timer representing half of the time ago as this one. This is
* useful for averaging time. For example,
*
*
* RageTimer tm;
* ... do stuff ...
* RageTimer AverageTime = tm.Half();
@@ -122,7 +124,7 @@ RageTimer RageTimer::Sum(const RageTimer &lhs, float tm)
{
/* tm == 5.25 -> secs = 5, us = 5.25 - ( 5) = .25
* tm == -1.25 -> secs = -2, us = -1.25 - (-2) = .75 */
int seconds = (int) floorf(tm);
int seconds = std::floor(tm);
int us = int( (tm - seconds) * TIMESTAMP_RESOLUTION );
RageTimer ret(0,0); // Prevent unnecessarily checking the time
+6 -4
View File
@@ -2,6 +2,8 @@
#include "RageTypes.h"
#include "LuaManager.h"
#include <cmath>
void RageColor::PushTable( lua_State *L ) const
{
lua_newtable( L );
@@ -53,10 +55,10 @@ void RageColor::FromStackCompat( lua_State *L, int iPos )
RString RageColor::ToString() const
{
int iR = clamp( (int) lrintf(r * 255), 0, 255 );
int iG = clamp( (int) lrintf(g * 255), 0, 255 );
int iB = clamp( (int) lrintf(b * 255), 0, 255 );
int iA = clamp( (int) lrintf(a * 255), 0, 255 );
int iR = clamp( static_cast<int>(std::lrint(r * 255)), 0, 255 );
int iG = clamp( static_cast<int>(std::lrint(g * 255)), 0, 255 );
int iB = clamp( static_cast<int>(std::lrint(b * 255)), 0, 255 );
int iA = clamp( static_cast<int>(std::lrint(a * 255)), 0, 255 );
if( iA == 255 )
return ssprintf( "#%02X%02X%02X", iR, iG, iB );
+14 -14
View File
@@ -8,19 +8,19 @@
#include "LocalizedString.h"
#include "LuaBinding.h"
#include "LuaManager.h"
#include <float.h>
#include <json/json.h>
#include <pcre.h>
#include <numeric>
#include <cfloat>
#include <cmath>
#include <ctime>
#include <sstream>
#include <map>
#include <functional>
#include <map>
#include <numeric>
#include <sstream>
#include <sys/types.h>
#include <sys/stat.h>
#include <math.h>
const RString CUSTOM_SONG_PATH= "/@mem/";
@@ -38,7 +38,7 @@ namespace
MersenneTwister g_LuaPRNG;
/* To map from [0..2^31-1] to [0..1), we divide by 2^31. */
const double DIVISOR = pow( double(2), double(31) );
const double DIVISOR = std::pow( double(2), double(31) );
static int Seed( lua_State *L )
{
@@ -103,9 +103,9 @@ void fapproach( float& val, float other_val, float to_move )
if( val == other_val )
return;
float fDelta = other_val - val;
float fSign = fDelta / fabsf( fDelta );
float fSign = fDelta / std::abs( fDelta );
float fToMove = fSign*to_move;
if( fabsf(fToMove) > fabsf(fDelta) )
if( std::abs(fToMove) > std::abs(fDelta) )
fToMove = fDelta; // snap
val += fToMove;
}
@@ -113,9 +113,9 @@ void fapproach( float& val, float other_val, float to_move )
/* Return a positive x mod y. */
float fmodfp(float x, float y)
{
x = fmodf(x, y); /* x is [-y,y] */
x += y; /* x is [0,y*2] */
x = fmodf(x, y); /* x is [0,y] */
x = std::fmod(x, y); /* x is [-y,y] */
x += y; /* x is [0,y*2] */
x = std::fmod(x, y); /* x is [0,y] */
return x;
}
@@ -1180,7 +1180,7 @@ float calc_stddev( const float *pStart, const float *pEnd, bool bSample )
for( const float *i=pStart; i != pEnd; ++i )
fDev += (*i - fMean) * (*i - fMean);
fDev /= std::distance( pStart, pEnd ) - (bSample ? 1 : 0);
fDev = sqrtf( fDev );
fDev = std::sqrt( fDev );
return fDev;
}
@@ -1209,7 +1209,7 @@ bool CalcLeastSquares( const std::vector<std::pair<float, float>> &vCoordinates,
fError += fOneError * fOneError;
}
fError /= vCoordinates.size();
fError = sqrtf( fError );
fError = std::sqrt( fError );
return true;
}
@@ -1220,7 +1220,7 @@ void FilterHighErrorPoints( std::vector<std::pair<float, float>> &vCoordinates,
for( unsigned int iIn = 0; iIn < vCoordinates.size(); ++iIn )
{
const float fError = fIntercept + fSlope * vCoordinates[iIn].first - vCoordinates[iIn].second;
if( fabsf(fError) < fCutoff )
if( std::abs(fError) < fCutoff )
{
vCoordinates[iOut] = vCoordinates[iIn];
++iOut;
+7 -6
View File
@@ -4,6 +4,7 @@
#define RAGE_UTIL_H
#include <algorithm>
#include <cmath>
#include <map>
#include <random>
#include <vector>
@@ -73,16 +74,16 @@ inline void wrap( unsigned &x, unsigned n )
inline void wrap( float &x, float n )
{
if (x<0)
x += truncf(((-x/n)+1))*n;
x = fmodf(x,n);
x += std::trunc(((-x/n)+1))*n;
x = std::fmod(x,n);
}
inline float fracf( float f ) { return f - truncf(f); }
inline float fracf( float f ) { return f - std::trunc(f); }
template<class T>
void CircularShift( std::vector<T> &v, int dist )
{
for( int i = abs(dist); i>0; i-- )
for( int i = std::abs(dist); i>0; i-- )
{
if( dist > 0 )
{
@@ -313,7 +314,7 @@ inline int QuantizeUp( int i, int iInterval )
inline float QuantizeUp( float i, float iInterval )
{
return ceilf( i/iInterval ) * iInterval;
return std::ceil( i/iInterval ) * iInterval;
}
/* Return i rounded down to the nearest multiple of iInterval. */
@@ -324,7 +325,7 @@ inline int QuantizeDown( int i, int iInterval )
inline float QuantizeDown( float i, float iInterval )
{
return floorf( i/iInterval ) * iInterval;
return std::floor( i/iInterval ) * iInterval;
}
// Move val toward other_val by to_move.
+7 -4
View File
@@ -6,6 +6,9 @@
#include "ActorUtil.h"
#include "LuaManager.h"
#include "ThemeManager.h"
#include <cmath>
REGISTER_ACTOR_CLASS( RollingNumbers );
RollingNumbers::RollingNumbers()
@@ -90,7 +93,7 @@ void RollingNumbers::Update( float fDeltaTime )
{
if(m_fCurrentNumber != m_fTargetNumber)
{
fapproach( m_fCurrentNumber, m_fTargetNumber, fabsf(m_fScoreVelocity) * fDeltaTime );
fapproach( m_fCurrentNumber, m_fTargetNumber, std::abs(m_fScoreVelocity) * fDeltaTime );
UpdateText();
}
@@ -135,7 +138,7 @@ void RollingNumbers::UpdateText()
// lua start
#include "LuaBinding.h"
/** @brief Allow Lua to have access to the RollingNumbers. */
/** @brief Allow Lua to have access to the RollingNumbers. */
class LunaRollingNumbers: public Luna<RollingNumbers>
{
public:
@@ -156,7 +159,7 @@ LUA_REGISTER_DERIVED_CLASS( RollingNumbers, BitmapText )
/*
* (c) 2001-2004 Chris Danford
* All rights reserved.
*
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
@@ -166,7 +169,7 @@ LUA_REGISTER_DERIVED_CLASS( RollingNumbers, BitmapText )
* copyright notice(s) and this permission notice appear in all copies of
* the Software and that both the above copyright notice(s) and this
* permission notice appear in supporting documentation.
*
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
+7 -5
View File
@@ -3,6 +3,8 @@
#include "RageLog.h"
#include "RageUtil.h"
#include <cmath>
inline float sample_step_size(int samples_per_second)
{
@@ -16,7 +18,7 @@ SampleHistory::SampleHistory()
m_fHistorySeconds = 0.0f;
m_fToSample = sample_step_size(m_iHistorySamplesPerSecond);
m_fHistorySeconds = 10.0f;
int iSamples = lrintf( m_iHistorySamplesPerSecond * m_fHistorySeconds );
int iSamples = std::lrint( m_iHistorySamplesPerSecond * m_fHistorySeconds );
m_afHistory.resize( iSamples );
}
@@ -30,8 +32,8 @@ float SampleHistory::GetSampleNum( float fSamplesAgo ) const
float fSample = m_iLastHistory - fSamplesAgo - 1;
float f = floorf( fSample );
int iSample = lrintf(f);
float f = std::floor( fSample );
int iSample = std::lrint(f);
int iNextSample = iSample + 1;
wrap( iSample, m_afHistory.size() );
wrap( iNextSample, m_afHistory.size() );
@@ -70,7 +72,7 @@ void SampleHistory::AddSample( float fSample, float fDeltaTime )
/*
* (c) 2006-2007 Glenn Maynard
* All rights reserved.
*
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
@@ -80,7 +82,7 @@ void SampleHistory::AddSample( float fSample, float fDeltaTime )
* copyright notice(s) and this permission notice appear in all copies of
* the Software and that both the above copyright notice(s) and this
* permission notice appear in supporting documentation.
*
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
+6 -4
View File
@@ -8,6 +8,8 @@
#include "MenuTimer.h"
#include "MemoryCardManager.h"
#include <cmath>
REGISTER_SCREEN_CLASS( ScreenContinue );
@@ -25,7 +27,7 @@ void ScreenContinue::BeginScreen()
GAMESTATE->SetCurrentStyle( nullptr, PLAYER_INVALID );
// Unjoin human players with 0 stages left and reset non-human players.
// We need to reset non-human players because data in non-human (CPU)
// We need to reset non-human players because data in non-human (CPU)
// players will be filled, and there may be stale pointers to things like
// edit Steps.
FOREACH_ENUM( PlayerNumber, p )
@@ -69,7 +71,7 @@ bool ScreenContinue::Input( const InputEventPlus &input )
case GAME_BUTTON_LEFT:
case GAME_BUTTON_RIGHT:
{
float fSeconds = floorf(m_MenuTimer->GetSeconds()) - 0.0001f;
float fSeconds = std::floor(m_MenuTimer->GetSeconds()) - 0.0001f;
fSeconds = std::max( fSeconds, 0.0001f ); // don't set to 0
m_MenuTimer->SetSeconds( fSeconds );
Message msg("HurryTimer");
@@ -123,7 +125,7 @@ void ScreenContinue::HandleMessage( const Message &msg )
/*
* (c) 2004 Chris Danford
* All rights reserved.
*
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
@@ -133,7 +135,7 @@ void ScreenContinue::HandleMessage( const Message &msg )
* copyright notice(s) and this permission notice appear in all copies of
* the Software and that both the above copyright notice(s) and this
* permission notice appear in supporting documentation.
*
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
+10 -8
View File
@@ -5,11 +5,13 @@
#include "LuaManager.h"
#include "ThemeMetric.h"
#include <cmath>
static ThemeMetric<float> THEME_SCREEN_WIDTH("Common","ScreenWidth");
static ThemeMetric<float> THEME_SCREEN_HEIGHT("Common","ScreenHeight");
/* The theme's logical resolution specifies the minimum screen width and
* the minimum screen height with a 4:3 aspect ratio. Scale just one
* the minimum screen height with a 4:3 aspect ratio. Scale just one
* of the dimensions up to meet the requested aspect ratio. */
/* The theme resolution isn't necessarily 4:3; a natively widescreen
@@ -24,8 +26,8 @@ float ScreenDimensions::GetThemeAspectRatio()
return THEME_NATIVE_ASPECT;
}
/* ceilf was originally lrintf. However, lrintf causes odd resolutions like
* 639x480 (4:3) and 853x480 (16:9). ceilf gives the correct values of 640x480
/* ceil was originally lrint. However, lrint causes odd resolutions like
* 639x480 (4:3) and 853x480 (16:9). ceil gives the correct values of 640x480
* and 854x480 (should really be 852 so that SCREEN_CENTER_X == 426 and not 427)
* respectively. -aj */
float ScreenDimensions::GetScreenWidth()
@@ -35,9 +37,9 @@ float ScreenDimensions::GetScreenWidth()
if( fAspect > THEME_NATIVE_ASPECT )
fScale = fAspect / THEME_NATIVE_ASPECT;
ASSERT( fScale >= 1 );
// ceilf causes the width to come out odd when it shouldn't.
// ceil causes the width to come out odd when it shouldn't.
// 576 * 1.7778 = 1024.0128, which is rounded to 1025. -Kyz
int width= (int)ceilf(THEME_SCREEN_WIDTH * fScale);
int width= std::ceil(THEME_SCREEN_WIDTH * fScale);
width-= width % 2;
return (float)width;
}
@@ -49,7 +51,7 @@ float ScreenDimensions::GetScreenHeight()
if( fAspect < THEME_NATIVE_ASPECT )
fScale = THEME_NATIVE_ASPECT / fAspect;
ASSERT( fScale >= 1 );
return (float) ceilf(THEME_SCREEN_HEIGHT * fScale);
return std::ceil(THEME_SCREEN_HEIGHT * fScale);
}
void ScreenDimensions::ReloadScreenDimensions()
@@ -77,7 +79,7 @@ LuaFunction( GetThemeAspectRatio, ScreenDimensions::GetThemeAspectRatio() );
/*
* (c) 2001-2002 Chris Danford
* All rights reserved.
*
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
@@ -87,7 +89,7 @@ LuaFunction( GetThemeAspectRatio, ScreenDimensions::GetThemeAspectRatio() );
* copyright notice(s) and this permission notice appear in all copies of
* the Software and that both the above copyright notice(s) and this
* permission notice appear in supporting documentation.
*
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
+9 -7
View File
@@ -1,6 +1,4 @@
#include "global.h"
#include <utility>
#include <float.h>
#include "ScreenEdit.h"
#include "ActorUtil.h"
#include "AdjustSync.h"
@@ -40,6 +38,10 @@
#include "Game.h"
#include "RageSoundReader.h"
#include <cfloat>
#include <cmath>
#include <utility>
static Preference<float> g_iDefaultRecordLength( "DefaultRecordLength", 4 );
static Preference<bool> g_bEditorShowBGChangesPlay( "EditorShowBGChangesPlay", true );
@@ -1769,12 +1771,12 @@ void ScreenEdit::Update( float fDeltaTime )
// Update trailing beat
float fDelta = GetBeat() - m_fTrailingBeat;
if( fabsf(fDelta) < 10 )
if( std::abs(fDelta) < 10 )
fapproach( m_fTrailingBeat, GetBeat(),
fDeltaTime*40 / m_NoteFieldEdit.GetPlayerState()->m_PlayerOptions.GetCurrent().m_fScrollSpeed );
else
fapproach( m_fTrailingBeat, GetBeat(),
fabsf(fDelta) * fDeltaTime*5 );
std::abs(fDelta) * fDeltaTime*5 );
PlayTicks();
}
@@ -1784,7 +1786,7 @@ static std::vector<int> FindAllAttacksAtTime(const AttackArray& attacks, float f
std::vector<int> ret;
for (unsigned i = 0; i < attacks.size(); ++i)
{
if (fabs(attacks[i].fStartSecond - fStartTime) < 0.001f)
if (std::abs(attacks[i].fStartSecond - fStartTime) < 0.001f)
{
ret.push_back(i);
}
@@ -1796,7 +1798,7 @@ static int FindAttackAtTime( const AttackArray& attacks, float fStartTime )
{
for( unsigned i = 0; i < attacks.size(); ++i )
{
if( fabs(attacks[i].fStartSecond - fStartTime) < 0.001f )
if( std::abs(attacks[i].fStartSecond - fStartTime) < 0.001f )
return i;
}
return -1;
@@ -5272,7 +5274,7 @@ void ScreenEdit::HandleAlterMenuChoice(AlterMenuChoice c, const std::vector<int>
int iStartIndex = m_NoteFieldEdit.m_iBeginMarker;
int iEndIndex = m_NoteFieldEdit.m_iEndMarker;
int iNewEndIndex = iEndIndex + lrintf( (iEndIndex - iStartIndex) * (fScale - 1) );
int iNewEndIndex = iEndIndex + std::lrint( (iEndIndex - iStartIndex) * (fScale - 1) );
// scale currently editing notes
NoteDataUtil::ScaleRegion( m_NoteDataEdit, fScale, iStartIndex, iEndIndex );
+7 -5
View File
@@ -20,6 +20,8 @@
#include "CommonMetrics.h"
#include "InputEventPlus.h"
#include <cmath>
REGISTER_SCREEN_CLASS( ScreenEnding );
ScreenEnding::ScreenEnding()
@@ -51,11 +53,11 @@ ScreenEnding::ScreenEnding()
for( float f = 0; f < 100.0f; f += 1.0f )
{
float fP1 = fmodf(f/100*4+.3f,1);
float fP1 = std::fmod(f/100*4+.3f,1);
STATSMAN->m_CurStageStats.m_player[PLAYER_1].SetLifeRecordAt( fP1, f );
STATSMAN->m_CurStageStats.m_player[PLAYER_2].SetLifeRecordAt( 1-fP1, f );
}
STATSMAN->m_CurStageStats.m_player[PLAYER_1].m_iActualDancePoints = RandomInt( 3 );
STATSMAN->m_CurStageStats.m_player[PLAYER_1].m_iPossibleDancePoints = 2;
STATSMAN->m_CurStageStats.m_player[PLAYER_2].m_iActualDancePoints = RandomInt( 2 );
@@ -88,7 +90,7 @@ void ScreenEnding::Init()
{
if( !PROFILEMAN->IsPersistentProfile(p) )
continue;
m_sprRemoveMemoryCard[p].SetName( ssprintf("RemoveCardP%d",p+1) );
m_sprRemoveMemoryCard[p].Load( THEME->GetPathG("ScreenEnding",ssprintf("remove card P%d",p+1)) );
switch( MEMCARDMAN->GetCardState(p) )
@@ -130,7 +132,7 @@ bool ScreenEnding::Input( const InputEventPlus &input )
/*
* (c) 2004 Chris Danford
* All rights reserved.
*
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
@@ -140,7 +142,7 @@ bool ScreenEnding::Input( const InputEventPlus &input )
* copyright notice(s) and this permission notice appear in all copies of
* the Software and that both the above copyright notice(s) and this
* permission notice appear in supporting documentation.
*
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
+5 -3
View File
@@ -30,6 +30,8 @@
#include "ScoreKeeperNormal.h"
#include "InputEventPlus.h"
#include <cmath>
// metrics that are common to all ScreenEvaluation classes
#define BANNER_WIDTH THEME->GetMetricF(m_sName,"BannerWidth")
#define BANNER_HEIGHT THEME->GetMetricF(m_sName,"BannerHeight")
@@ -143,7 +145,7 @@ void ScreenEvaluation::Init()
for( float f = 0; f < 100.0f; f += 1.0f )
{
float fP1 = fmodf(f/100*4+.3f,1);
float fP1 = std::fmod(f/100*4+.3f,1);
ss.m_player[PLAYER_1].SetLifeRecordAt( fP1, f );
ss.m_player[PLAYER_2].SetLifeRecordAt( 1-fP1, f );
}
@@ -581,8 +583,8 @@ void ScreenEvaluation::Init()
RadarCategory_Hands, RadarCategory_Rolls, RadarCategory_Lifts, RadarCategory_Fakes
};
const int ind = indices[l];
const int iActual = lrintf(m_pStageStats->m_player[p].m_radarActual[ind]);
const int iPossible = lrintf(m_pStageStats->m_player[p].m_radarPossible[ind]);
const int iActual = std::lrint(m_pStageStats->m_player[p].m_radarActual[ind]);
const int iPossible = std::lrint(m_pStageStats->m_player[p].m_radarPossible[ind]);
// todo: check if format string is valid
// (two integer values in DETAILLINE_FORMAT) -aj
+3 -1
View File
@@ -61,6 +61,8 @@
#include "Profile.h" // for replay data stuff
#include "RageDisplay.h"
#include <cmath>
// Defines
#define SHOW_LIFE_METER_FOR_DISABLED_PLAYERS THEME->GetMetricB(m_sName,"ShowLifeMeterForDisabledPlayers")
#define SHOW_SCORE_IN_RAVE THEME->GetMetricB(m_sName,"ShowScoreInRave")
@@ -1701,7 +1703,7 @@ void ScreenGameplay::Update( float fDeltaTime )
fSpeed *= GetHasteRate();
RageSoundParams p = m_pSoundMusic->GetParams();
if( fabsf(p.m_fSpeed - fSpeed) > 0.01f && fSpeed >= 0.0f)
if( std::abs(p.m_fSpeed - fSpeed) > 0.01f && fSpeed >= 0.0f)
{
p.m_fSpeed = fSpeed;
m_pSoundMusic->SetParams( p );
+11 -9
View File
@@ -25,6 +25,8 @@
#include "Song.h"
#include "StatsManager.h"
#include <cmath>
// Defines specific to ScreenNameEntry
#define CATEGORY_Y THEME->GetMetricF(m_sName,"CategoryY")
#define CATEGORY_ZOOM THEME->GetMetricF(m_sName,"CategoryZoom")
@@ -43,7 +45,7 @@
// cache for frequently used metrics
static float g_fCharsZoomSmall;
static float g_fCharsZoomLarge;
static float g_fCharsZoomLarge;
static float g_fCharsSpacingY;
static float g_fReceptorArrowsY;
static int g_iNumCharsToDrawBehind;
@@ -62,7 +64,7 @@ void ScreenNameEntry::ScrollingText::Init( const RString &sName, const std::vect
void ScreenNameEntry::ScrollingText::DrawPrimitives()
{
const float fFakeBeat = GAMESTATE->m_Position.m_fSongBeat;
const size_t iClosestIndex = lrintf( fFakeBeat ) % CHARS_CHOICES.size();
const size_t iClosestIndex = std::lrint( fFakeBeat ) % CHARS_CHOICES.size();
const float fClosestYOffset = GetClosestCharYOffset( fFakeBeat );
size_t iCharIndex = ( iClosestIndex - NUM_CHARS_TO_DRAW_BEHIND + CHARS_CHOICES.size() ) % CHARS_CHOICES.size();
@@ -75,7 +77,7 @@ void ScreenNameEntry::ScrollingText::DrawPrimitives()
float fAlpha = 1.f;
if( iCharIndex == iClosestIndex )
fZoom = SCALE( fabs(fClosestYOffset), 0, 0.5f, g_fCharsZoomLarge, g_fCharsZoomSmall );
fZoom = SCALE( std::abs(fClosestYOffset), 0, 0.5f, g_fCharsZoomLarge, g_fCharsZoomSmall );
if( i == 0 )
fAlpha *= SCALE( fClosestYOffset, -0.5f, 0.f, 0.f, 1.f );
if( i == g_iNumCharsToDrawTotal-1 )
@@ -98,17 +100,17 @@ void ScreenNameEntry::ScrollingText::DrawPrimitives()
char ScreenNameEntry::ScrollingText::GetClosestChar( float fFakeBeat ) const
{
ASSERT( fFakeBeat >= 0.f );
return CHARS_CHOICES[lrintf(fFakeBeat) % CHARS_CHOICES.size()];
return CHARS_CHOICES[std::lrint(fFakeBeat) % CHARS_CHOICES.size()];
}
// return value is relative to gray arrows
float ScreenNameEntry::ScrollingText::GetClosestCharYOffset( float fFakeBeat ) const
{
float f = fmodf(fFakeBeat, 1.0f);
float f = std::fmod(fFakeBeat, 1.0f);
if( f > 0.5f )
f -= 1;
ASSERT( f>-0.5f && f<=0.5f );
return -f;
return -f;
}
REGISTER_SCREEN_CLASS( ScreenNameEntry );
@@ -215,7 +217,7 @@ void ScreenNameEntry::Init()
bool IsOnRanking = ( (GAMESTATE->m_PlayMode == PLAY_MODE_NONSTOP || GAMESTATE->m_PlayMode == PLAY_MODE_ONI)
&& !(GAMESTATE->m_pCurCourse->IsRanking()) );
if( PREFSMAN->m_GetRankingName == RANKING_OFF ||
if( PREFSMAN->m_GetRankingName == RANKING_OFF ||
(PREFSMAN->m_GetRankingName == RANKING_LIST && !IsOnRanking) )
{
// don't collect score due to ranking setting
@@ -409,7 +411,7 @@ bool ScreenNameEntry::MenuStart( const InputEventPlus &input )
/*
* (c) 2001-2006 Chris Danford, Steve Checkoway
* All rights reserved.
*
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
@@ -419,7 +421,7 @@ bool ScreenNameEntry::MenuStart( const InputEventPlus &input )
* copyright notice(s) and this permission notice appear in all copies of
* the Software and that both the above copyright notice(s) and this
* permission notice appear in supporting documentation.
*
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
+5 -3
View File
@@ -15,6 +15,8 @@
#include "LuaBinding.h"
#include "InputEventPlus.h"
#include <cmath>
/*
* These navigation types are provided:
@@ -504,7 +506,7 @@ bool ScreenOptions::Input( const InputEventPlus &input )
if (input.DeviceI == DeviceInput( DEVICE_MOUSE, (DeviceButton)i ))
mouse_evt = true;
}
if (mouse_evt)
if (mouse_evt)
{
return ScreenWithMenuElements::Input(input);
}
@@ -1210,7 +1212,7 @@ void ScreenOptions::AfterChangeRow( PlayerNumber pn )
{
int iWidth, iX, iY;
GetWidthXY( pn, m_iCurrentRow[pn], i, iWidth, iX, iY );
const int iDist = abs( iX-m_iFocusX[pn] );
const int iDist = std::abs( iX-m_iFocusX[pn] );
if( iSelectionDist == -1 || iDist < iSelectionDist )
{
iSelectionDist = iDist;
@@ -1355,7 +1357,7 @@ void ScreenOptions::SetOptionRowFromName( const RString& nombre )
// lua start
#include "LuaBinding.h"
/** @brief Allow Lua to have access to ScreenOptions. */
/** @brief Allow Lua to have access to ScreenOptions. */
class LunaScreenOptions: public Luna<ScreenOptions>
{
public:
+15 -13
View File
@@ -32,6 +32,8 @@
#include "OptionsList.h"
#include "RageFileManager.h"
#include <cmath>
static const char *SelectionStateNames[] = {
"SelectingSong",
"SelectingSteps",
@@ -413,7 +415,7 @@ bool ScreenSelectMusic::Input( const InputEventPlus &input )
if (input.DeviceI == DeviceInput( DEVICE_MOUSE, (DeviceButton)i ))
mouse_evt = true;
}
if (mouse_evt)
if (mouse_evt)
{
return ScreenWithMenuElements::Input(input);
}
@@ -426,7 +428,7 @@ bool ScreenSelectMusic::Input( const InputEventPlus &input )
// I just like being able to see untransliterated titles occasionally.
if( input.DeviceI.device == DEVICE_KEYBOARD && input.DeviceI.button == KEY_F9 )
{
if( input.type != IET_FIRST_PRESS )
if( input.type != IET_FIRST_PRESS )
return false;
PREFSMAN->m_bShowNativeLanguage.Set( !PREFSMAN->m_bShowNativeLanguage );
MESSAGEMAN->Broadcast( "DisplayLanguageChanged" );
@@ -436,7 +438,7 @@ bool ScreenSelectMusic::Input( const InputEventPlus &input )
if( !IsTransitioning() && m_SelectionState != SelectionState_Finalized )
{
bool bHoldingCtrl =
bool bHoldingCtrl =
INPUTFILTER->IsBeingPressed(DeviceInput(DEVICE_KEYBOARD, KEY_LCTRL)) ||
INPUTFILTER->IsBeingPressed(DeviceInput(DEVICE_KEYBOARD, KEY_RCTRL));
@@ -488,7 +490,7 @@ bool ScreenSelectMusic::Input( const InputEventPlus &input )
{
// Keyboard shortcut to delete a song from disk (ctrl + backspace)
Song* songToDelete = m_MusicWheel.GetSelectedSong();
if ( songToDelete && PREFSMAN->m_bAllowSongDeletion.Get() )
if ( songToDelete && PREFSMAN->m_bAllowSongDeletion.Get() )
{
m_pSongAwaitingDeletionConfirmation = songToDelete;
ScreenPrompt::Prompt(SM_ConfirmDeleteSong, ssprintf(PERMANENTLY_DELETE.GetValue(), songToDelete->m_sMainTitle.c_str(), songToDelete->GetSongDir().c_str()), PROMPT_YES_NO);
@@ -695,7 +697,7 @@ bool ScreenSelectMusic::Input( const InputEventPlus &input )
}
// Reset the repeat timer when the button is released.
// This fixes jumping when you release Left and Right after entering the sort
// This fixes jumping when you release Left and Right after entering the sort
// code at the same if L & R aren't released at the exact same time.
if( input.type == IET_RELEASE )
{
@@ -1290,7 +1292,7 @@ bool ScreenSelectMusic::MenuStart( const InputEventPlus &input )
else
SOUND->PlayOnceFromAnnouncer( "select music comment general" );
/* If we're in event mode, we may have just played a course (putting
/* If we're in event mode, we may have just played a course (putting
* us in course mode). Make sure we're in a single song mode. */
if( GAMESTATE->IsCourseMode() )
GAMESTATE->m_PlayMode.Set( PLAY_MODE_REGULAR );
@@ -1644,10 +1646,10 @@ void ScreenSelectMusic::SwitchToPreferredDifficulty()
if( GAMESTATE->m_PreferredDifficulty[pn] != Difficulty_Invalid )
{
int iDifficultyDifference = abs( s->GetDifficulty() - GAMESTATE->m_PreferredDifficulty[pn] );
int iDifficultyDifference = std::abs( s->GetDifficulty() - GAMESTATE->m_PreferredDifficulty[pn] );
int iStepsTypeDifference = 0;
if( GAMESTATE->m_PreferredStepsType != StepsType_Invalid )
iStepsTypeDifference = abs( s->m_StepsType - GAMESTATE->m_PreferredStepsType );
iStepsTypeDifference = std::abs( s->m_StepsType - GAMESTATE->m_PreferredStepsType );
int iTotalDifference = iStepsTypeDifference * NUM_Difficulty + iDifficultyDifference;
if( iCurDifference == -1 || iTotalDifference < iCurDifference )
@@ -1681,8 +1683,8 @@ void ScreenSelectMusic::SwitchToPreferredDifficulty()
if( GAMESTATE->m_PreferredCourseDifficulty[pn] != Difficulty_Invalid && GAMESTATE->m_PreferredStepsType != StepsType_Invalid )
{
int iDifficultyDifference = abs( t->m_CourseDifficulty - GAMESTATE->m_PreferredCourseDifficulty[pn] );
int iStepsTypeDifference = abs( t->m_StepsType - GAMESTATE->m_PreferredStepsType );
int iDifficultyDifference = std::abs( t->m_CourseDifficulty - GAMESTATE->m_PreferredCourseDifficulty[pn] );
int iStepsTypeDifference = std::abs( t->m_StepsType - GAMESTATE->m_PreferredStepsType );
int iTotalDifference = iStepsTypeDifference * NUM_CourseDifficulty + iDifficultyDifference;
if( iCurDifference == -1 || iTotalDifference < iCurDifference )
@@ -2042,7 +2044,7 @@ bool ScreenSelectMusic::can_open_options_list(PlayerNumber pn)
// lua start
#include "LuaBinding.h"
/** @brief Allow Lua to have access to the ScreenSelectMusic. */
/** @brief Allow Lua to have access to the ScreenSelectMusic. */
class LunaScreenSelectMusic: public Luna<ScreenSelectMusic>
{
public:
@@ -2082,7 +2084,7 @@ LUA_REGISTER_DERIVED_CLASS( ScreenSelectMusic, ScreenWithMenuElements )
/*
* (c) 2001-2004 Chris Danford
* All rights reserved.
*
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
@@ -2092,7 +2094,7 @@ LUA_REGISTER_DERIVED_CLASS( ScreenSelectMusic, ScreenWithMenuElements )
* copyright notice(s) and this permission notice appear in all copies of
* the Software and that both the above copyright notice(s) and this
* permission notice appear in supporting documentation.
*
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
+27 -25
View File
@@ -15,6 +15,8 @@
#include "LuaBinding.h"
#include "arch/ArchHooks/ArchHooks.h" // HOOKS->GetClipboard()
#include <cmath>
static const char* g_szKeys[NUM_KeyboardRow][KEYS_PER_ROW] =
{
{"A","B","C","D","E","F","G","H","I","J","K","L","M"},
@@ -50,18 +52,18 @@ namespace
LuaReference g_FormatAnswerForDisplayFunc;
};
void ScreenTextEntry::SetTextEntrySettings(
RString sQuestion,
RString sInitialAnswer,
void ScreenTextEntry::SetTextEntrySettings(
RString sQuestion,
RString sInitialAnswer,
int iMaxInputLength,
bool(*Validate)(const RString &sAnswer,RString &sErrorOut),
void(*OnOK)(const RString &sAnswer),
bool(*Validate)(const RString &sAnswer,RString &sErrorOut),
void(*OnOK)(const RString &sAnswer),
void(*OnCancel)(),
bool bPassword,
bool (*ValidateAppend)(const RString &sAnswerBeforeChar, RString &sAppend),
RString (*FormatAnswerForDisplay)(const RString &sAnswer)
)
{
{
g_sQuestion = sQuestion;
g_sInitialAnswer = sInitialAnswer;
g_iMaxInputLength = iMaxInputLength;
@@ -72,13 +74,13 @@ void ScreenTextEntry::SetTextEntrySettings(
g_pFormatAnswerForDisplay = FormatAnswerForDisplay;
}
void ScreenTextEntry::TextEntry(
ScreenMessage smSendOnPop,
RString sQuestion,
RString sInitialAnswer,
void ScreenTextEntry::TextEntry(
ScreenMessage smSendOnPop,
RString sQuestion,
RString sInitialAnswer,
int iMaxInputLength,
bool(*Validate)(const RString &sAnswer,RString &sErrorOut),
void(*OnOK)(const RString &sAnswer),
bool(*Validate)(const RString &sAnswer,RString &sErrorOut),
void(*OnOK)(const RString &sAnswer),
void(*OnCancel)(),
bool bPassword,
bool (*ValidateAppend)(const RString &sAnswerBeforeChar, RString &sAppend),
@@ -224,7 +226,7 @@ bool ScreenTextEntry::Input( const InputEventPlus &input )
break;
}
}
if( input.DeviceI == DeviceInput(DEVICE_KEYBOARD, KEY_RCTRL) )
{
switch( input.type )
@@ -239,7 +241,7 @@ bool ScreenTextEntry::Input( const InputEventPlus &input )
break;
}
}
bool bHandled = false;
if( input.DeviceI == DeviceInput(DEVICE_KEYBOARD, KEY_BACK) )
{
@@ -260,11 +262,11 @@ bool ScreenTextEntry::Input( const InputEventPlus &input )
if( ( c == L'v' || c == L'V' ) && ( bLCtrl || bRCtrl ) )
{
TryAppendToAnswer( HOOKS->GetClipboard() );
TextEnteredDirectly(); // XXX: This doesn't seem appropriate but there's no TextPasted()
bHandled = true;
}
else if( c >= L' ' )
else if( c >= L' ' )
{
// todo: handle caps lock -aj
TryAppendToAnswer( WStringToRString(std::wstring()+c) );
@@ -327,7 +329,7 @@ void ScreenTextEntry::End( bool bCancelled )
{
if( bCancelled )
{
if( g_pOnCancel )
if( g_pOnCancel )
g_pOnCancel();
Cancel( SM_GoToNextScreen );
@@ -684,8 +686,8 @@ void ScreenTextEntryVisual::BeginScreen()
for( int x=0; x<KEYS_PER_ROW; ++x )
{
BitmapText &bt = *m_ptextKeys[r][x];
float fX = roundf( SCALE( x, 0, KEYS_PER_ROW-1, ROW_START_X, ROW_END_X ) );
float fY = roundf( SCALE( r, 0, NUM_KeyboardRow-1, ROW_START_Y, ROW_END_Y ) );
float fX = std::round( SCALE( x, 0, KEYS_PER_ROW-1, ROW_START_X, ROW_END_X ) );
float fY = std::round( SCALE( r, 0, NUM_KeyboardRow-1, ROW_START_Y, ROW_END_Y ) );
bt.SetXY( fX, fY );
}
}
@@ -717,7 +719,7 @@ void ScreenTextEntryVisual::MoveX( int iDir )
m_iFocusX += iDir;
wrap( m_iFocusX, KEYS_PER_ROW );
sKey = g_szKeys[m_iFocusY][m_iFocusX];
sKey = g_szKeys[m_iFocusY][m_iFocusX];
}
while( sKey == "" );
@@ -733,13 +735,13 @@ void ScreenTextEntryVisual::MoveY( int iDir )
m_iFocusY = enum_add2( m_iFocusY, +iDir );
wrap( *ConvertValue<int>(&m_iFocusY), NUM_KeyboardRow );
// HACK: Round to nearest option so that we always stop
// HACK: Round to nearest option so that we always stop
// on KEYBOARD_ROW_SPECIAL.
if( m_iFocusY == KEYBOARD_ROW_SPECIAL )
{
for( int i=0; true; i++ )
{
sKey = g_szKeys[m_iFocusY][m_iFocusX];
sKey = g_szKeys[m_iFocusY][m_iFocusX];
if( sKey != "" )
break;
@@ -749,7 +751,7 @@ void ScreenTextEntryVisual::MoveY( int iDir )
}
}
sKey = g_szKeys[m_iFocusY][m_iFocusX];
sKey = g_szKeys[m_iFocusY][m_iFocusX];
}
while( sKey == "" );
@@ -820,7 +822,7 @@ bool ScreenTextEntryVisual::MenuStart( const InputEventPlus &input )
/*
* (c) 2001-2004 Chris Danford
* All rights reserved.
*
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
@@ -830,7 +832,7 @@ bool ScreenTextEntryVisual::MenuStart( const InputEventPlus &input )
* copyright notice(s) and this permission notice appear in all copies of
* the Software and that both the above copyright notice(s) and this
* permission notice appear in supporting documentation.
*
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
+15 -13
View File
@@ -3,6 +3,8 @@
#include "ThemeManager.h"
#include "RageUtil.h"
#include <cmath>
ScrollBar::ScrollBar()
{
@@ -52,7 +54,7 @@ void ScrollBar::SetPercentage( float fCenterPercent, float fSizePercent )
/* Set tick thumb */
{
float fY = SCALE( fCenterPercent, 0.0f, 1.0f, -iBarContentHeight/2.0f, iBarContentHeight/2.0f );
fY = roundf( fY );
fY = std::round( fY );
m_sprScrollTickThumb->SetY( fY );
}
@@ -61,25 +63,25 @@ void ScrollBar::SetPercentage( float fCenterPercent, float fSizePercent )
float fEndPercent = fCenterPercent + fSizePercent;
// make sure the percent numbers are between 0 and 1
fStartPercent = fmodf( fStartPercent+1, 1 );
fEndPercent = fmodf( fEndPercent+1, 1 );
fStartPercent = std::fmod( fStartPercent+1, 1 );
fEndPercent = std::fmod( fEndPercent+1, 1 );
CHECKPOINT_M("Percentages set.");
float fPartTopY[2], fPartBottomY[2];
if( fStartPercent < fEndPercent ) // we only need to one 1 stretch thumb part
{
fPartTopY[0] = SCALE( fStartPercent,0.0f, 1.0f, -iBarContentHeight/2.0f, +iBarContentHeight/2.0f );
fPartBottomY[0] = SCALE( fEndPercent, 0.0f, 1.0f, -iBarContentHeight/2.0f, +iBarContentHeight/2.0f );
fPartTopY[1] = 0;
fPartBottomY[1] = 0;
fPartTopY[0] = SCALE( fStartPercent,0.0f, 1.0f, -iBarContentHeight/2.0f, +iBarContentHeight/2.0f );
fPartBottomY[0] = SCALE( fEndPercent, 0.0f, 1.0f, -iBarContentHeight/2.0f, +iBarContentHeight/2.0f );
fPartTopY[1] = 0;
fPartBottomY[1] = 0;
}
else // we need two stretch thumb parts
{
fPartTopY[0] = SCALE( 0.0f, 0.0f, 1.0f, -iBarContentHeight/2.0f, +iBarContentHeight/2.0f );
fPartBottomY[0] = SCALE( fEndPercent, 0.0f, 1.0f, -iBarContentHeight/2.0f, +iBarContentHeight/2.0f );
fPartTopY[1] = SCALE( fStartPercent, 0.0f, 1.0f, -iBarContentHeight/2.0f, +iBarContentHeight/2.0f );
fPartBottomY[1] = SCALE( 1.0f, 0.0f, 1.0f, -iBarContentHeight/2.0f, +iBarContentHeight/2.0f );
fPartTopY[0] = SCALE( 0.0f, 0.0f, 1.0f, -iBarContentHeight/2.0f, +iBarContentHeight/2.0f );
fPartBottomY[0] = SCALE( fEndPercent, 0.0f, 1.0f, -iBarContentHeight/2.0f, +iBarContentHeight/2.0f );
fPartTopY[1] = SCALE( fStartPercent, 0.0f, 1.0f, -iBarContentHeight/2.0f, +iBarContentHeight/2.0f );
fPartBottomY[1] = SCALE( 1.0f, 0.0f, 1.0f, -iBarContentHeight/2.0f, +iBarContentHeight/2.0f );
}
for( unsigned i=0; i<ARRAYLEN(m_sprScrollStretchThumb); i++ )
@@ -97,7 +99,7 @@ void ScrollBar::SetPercentage( float fCenterPercent, float fSizePercent )
/*
* (c) 2001-2003 Chris Danford
* All rights reserved.
*
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
@@ -107,7 +109,7 @@ void ScrollBar::SetPercentage( float fCenterPercent, float fSizePercent )
* copyright notice(s) and this permission notice appear in all copies of
* the Software and that both the above copyright notice(s) and this
* permission notice appear in supporting documentation.
*
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
+15 -14
View File
@@ -37,9 +37,10 @@
#include "ActorUtil.h"
#include "CommonMetrics.h"
#include <cfloat>
#include <cmath>
#include <time.h>
#include <set>
#include <float.h>
//-Nick12 Used for song file hashing
#include <CryptManager.h>
@@ -166,7 +167,7 @@ void Song::SetSpecifiedLastSecond(const float f)
void Song::Reset()
{
for (Steps *s : m_vpSteps)
{
{
SAFE_DELETE( s );
}
m_vpSteps.clear();
@@ -438,7 +439,7 @@ bool Song::LoadFromSongDir(RString sDir, bool load_autosave, ProfileSlot from_pr
for( RString Image : ImageDir )
{
IMAGECACHE->LoadImage( Image, GetCacheFile( Image ) );
}
}
}
// Add AutoGen pointers. (These aren't cached.)
@@ -847,7 +848,7 @@ void Song::TidyUpData( bool from_cache, bool /* duringCache */ )
if(m_fMusicSampleStartSeconds+m_fMusicSampleLengthSeconds > this->m_fMusicLengthSeconds)
{
// Attempt to get a reasonable default.
int iBeat = lrintf(this->m_SongTiming.GetBeatFromElapsedTime(this->GetLastSecond())/2);
int iBeat = std::lrint(this->m_SongTiming.GetBeatFromElapsedTime(this->GetLastSecond())/2);
iBeat -= iBeat%4;
m_fMusicSampleStartSeconds = timing.GetElapsedTimeFromBeat((float)iBeat);
}
@@ -1443,7 +1444,7 @@ void Song::AddAutoGenNotes()
// has (non-autogen) Steps of this type
const int iNumTracks = GAMEMAN->GetStepsTypeInfo(st).iNumTracks;
const int iTrackDifference = abs(iNumTracks-iNumTracksOfMissing);
const int iTrackDifference = std::abs(iNumTracks-iNumTracksOfMissing);
if( iTrackDifference < iBestTrackDifference )
{
stBestMatch = st;
@@ -1657,11 +1658,11 @@ RString Song::GetCacheFile(RString sType)
PreDefs["Jacket"] = GetJacketPath();
PreDefs["CDImage"] = GetCDImagePath();
PreDefs["Disc"] = GetDiscPath();
// Check if Predefined images exist, And return function if they do.
if(PreDefs[sType.c_str()])
return PreDefs[sType.c_str()];
return PreDefs[sType.c_str()];
// Get all image files and put them into a vector.
std::vector<RString> song_dir_listing;
FILEMAN->GetDirListing(m_sSongDir + "*", song_dir_listing, false, false);
@@ -1669,7 +1670,7 @@ RString Song::GetCacheFile(RString sType)
std::vector<RString> fill_exts = ActorUtil::GetTypeExtensionList(FT_Bitmap);
for( RString Image : song_dir_listing )
{
RString FileExt = GetExtension(Image);
RString FileExt = GetExtension(Image);
transform(FileExt.begin(), FileExt.end(), FileExt.begin(),::tolower);
for ( RString FindExt : fill_exts )
{
@@ -1677,7 +1678,7 @@ RString Song::GetCacheFile(RString sType)
image_list.push_back(Image);
}
}
// Create a map that contains all the filenames to search for.
std::map<RString, std::map<int, RString>> PreSets;
PreSets["Banner"][1] = "bn";
@@ -1685,13 +1686,13 @@ RString Song::GetCacheFile(RString sType)
PreSets["Background"][1] = "bg";
PreSets["Background"][2] = "background";
PreSets["CDTitle"][1] = "cdtitle";
PreSets["Jacket"][1] = "jk_";
PreSets["Jacket"][1] = "jk_";
PreSets["Jacket"][2] = "jacket";
PreSets["Jacket"][3] = "albumart";
PreSets["CDImage"][1] = "-cd";
PreSets["Disc"][1] = " disc";
PreSets["Disc"][2] = " title";
PreSets["Disc"][2] = " title";
for( RString Image : image_list)
{
// We want to make it lower case.
@@ -1703,7 +1704,7 @@ RString Song::GetCacheFile(RString sType)
if(Found!=RString::npos)
return GetSongAssetPath( Image, m_sSongDir );
}
// Search for the image directly if it doesnt exist in PreSets,
// Search for the image directly if it doesnt exist in PreSets,
// Or incase we define our own stuff.
size_t Found = Image.find(sType.c_str());
if(Found!=RString::npos)
+6 -4
View File
@@ -4,6 +4,8 @@
#include "GameState.h"
#include "CommonMetrics.h"
#include <cmath>
static const char *AutosyncTypeNames[] = {
"Off",
"Song",
@@ -49,7 +51,7 @@ static void AddPart( std::vector<RString> &AddTo, float level, RString name )
if( level == 0 )
return;
const RString LevelStr = (level == 1)? RString(""): ssprintf( "%ld%% ", lrintf(level*100) );
const RString LevelStr = (level == 1)? RString(""): ssprintf( "%ld%% ", std::lrint(level*100) );
AddTo.push_back( LevelStr + name );
}
@@ -163,7 +165,7 @@ bool SongOptions::FromOneModString( const RString &sOneMod, RString &sErrorOut )
if( sBit == "clap" ) m_bAssistClap = on;
else if( sBit == "metronome" ) m_bAssistMetronome = on;
else if( sBit == "autosync" || sBit == "autosyncsong" ) m_AutosyncType = on ? AutosyncType_Song : AutosyncType_Off;
else if( sBit == "autosyncmachine" ) m_AutosyncType = on ? AutosyncType_Machine : AutosyncType_Off;
else if( sBit == "autosyncmachine" ) m_AutosyncType = on ? AutosyncType_Machine : AutosyncType_Off;
else if( sBit == "autosynctempo" ) m_AutosyncType = on ? AutosyncType_Tempo : AutosyncType_Off;
else if( sBit == "effect" && !on ) m_SoundEffectType = SoundEffectType_Off;
else if( sBit == "effectspeed" ) m_SoundEffectType = on ? SoundEffectType_Speed : SoundEffectType_Off;
@@ -238,7 +240,7 @@ LUA_REGISTER_CLASS( SongOptions )
/*
* (c) 2001-2004 Chris Danford, Glenn Maynard
* All rights reserved.
*
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
@@ -248,7 +250,7 @@ LUA_REGISTER_CLASS( SongOptions )
* copyright notice(s) and this permission notice appear in all copies of
* the Software and that both the above copyright notice(s) and this
* permission notice appear in supporting documentation.
*
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
+33 -31
View File
@@ -18,6 +18,8 @@
#include "LuaBinding.h"
#include "EnumHelper.h"
#include <cmath>
ThemeMetric<int> SORT_BPM_DIVISION ( "MusicWheel", "SortBPMDivision" );
ThemeMetric<int> SORT_LENGTH_DIVISION ( "MusicWheel", "SortLengthDivision" );
ThemeMetric<bool> SHOW_SECTIONS_IN_BPM_SORT ( "MusicWheel", "ShowSectionsInBPMSort" );
@@ -94,18 +96,18 @@ bool SongCriteria::Matches( const Song *pSong ) const
return true;
}
void SongUtil::GetSteps(
void SongUtil::GetSteps(
const Song *pSong,
std::vector<Steps*>& arrayAddTo,
StepsType st,
Difficulty dc,
int iMeterLow,
int iMeterHigh,
StepsType st,
Difficulty dc,
int iMeterLow,
int iMeterHigh,
const RString &sDescription,
const RString &sCredit,
bool bIncludeAutoGen,
bool bIncludeAutoGen,
unsigned uHash,
int iMaxToGet
int iMaxToGet
)
{
if( !iMaxToGet )
@@ -142,12 +144,12 @@ void SongUtil::GetSteps(
}
}
Steps* SongUtil::GetOneSteps(
const Song *pSong,
StepsType st,
Difficulty dc,
int iMeterLow,
int iMeterHigh,
Steps* SongUtil::GetOneSteps(
const Song *pSong,
StepsType st,
Difficulty dc,
int iMeterLow,
int iMeterHigh,
const RString &sDescription,
const RString &sCredit,
unsigned uHash,
@@ -204,7 +206,7 @@ Steps* SongUtil::GetStepsByDescription( const Song *pSong, StepsType st, RString
GetSteps( pSong, vNotes, st, Difficulty_Invalid, -1, -1, sDescription, "" );
if( vNotes.size() == 0 )
return nullptr;
else
else
return vNotes[0];
}
@@ -235,7 +237,7 @@ Steps* SongUtil::GetClosestNotes( const Song *pSong, StepsType st, Difficulty dc
if( bIgnoreLocked && UNLOCKMAN->StepsIsLocked(pSong,pSteps) )
continue;
int iDistance = abs(dc - pSteps->GetDifficulty());
int iDistance = std::abs(dc - pSteps->GetDifficulty());
if( iDistance < iClosestDistance )
{
pClosest = pSteps;
@@ -327,7 +329,7 @@ void SongUtil::DeleteDuplicateSteps( Song *pSong, std::vector<Steps*> &vSteps )
LOG->Trace("Removed %p duplicate steps in song \"%s\" with description \"%s\", step author \"%s\", and meter \"%i\"",
static_cast<const void*>(s2), pSong->GetSongDir().c_str(), s1->GetDescription().c_str(), s1->GetCredit().c_str(), s1->GetMeter() );
pSong->DeleteSteps( s2, false );
vSteps.erase(vSteps.begin()+j);
@@ -413,7 +415,7 @@ static bool CompareSongPointersByBPM( const Song *pSong1, const Song *pSong2 )
return true;
if( bpms1.GetMax() > bpms2.GetMax() )
return false;
return CompareRStringsAsc( pSong1->GetSongFilePath(), pSong2->GetSongFilePath() );
}
@@ -568,7 +570,7 @@ RString SongUtil::GetSectionNameFromSongAndSort( const Song* pSong, SortOrder so
case SORT_PREFERRED:
return SONGMAN->SongToPreferredSortSectionName( pSong );
case SORT_GROUP:
// guaranteed not empty
// guaranteed not empty
return pSong->m_sGroupName;
case SORT_TITLE:
case SORT_ARTIST:
@@ -807,7 +809,7 @@ bool SongUtil::ValidateCurrentEditStepsDescription( const RString &sAnswer, RStr
// Steps name must be unique for this song.
std::vector<Steps*> v;
GetSteps( pSong, v, StepsType_Invalid, Difficulty_Edit );
GetSteps( pSong, v, StepsType_Invalid, Difficulty_Edit );
for (Steps const *s : v)
{
if( pSteps == s )
@@ -847,20 +849,20 @@ bool SongUtil::ValidateCurrentStepsDescription( const RString &sAnswer, RString
bool SongUtil::ValidateCurrentStepsChartName(const RString &answer, RString &error)
{
if (answer.empty()) return true;
static const RString sInvalidChars = "\\/:*?\"<>|";
if( strpbrk(answer, sInvalidChars) != nullptr )
{
error = ssprintf( CHART_NAME_CANNOT_CONTAIN.GetValue(), sInvalidChars.c_str() );
return false;
}
/* Don't allow duplicate title names within the same StepsType.
* We need some way of identifying the unique charts. */
Steps *pSteps = GAMESTATE->m_pCurSteps[PLAYER_1];
if (pSteps->GetChartName() == answer) return true;
// TODO next commit: borrow code from EditStepsDescription.
bool result = SongUtil::IsChartNameUnique(GAMESTATE->m_pCurSong, pSteps->m_StepsType,
answer, pSteps);
@@ -875,12 +877,12 @@ bool SongUtil::ValidateCurrentStepsCredit( const RString &sAnswer, RString &sErr
{
if( sAnswer.empty() )
return true;
Steps *pSteps = GAMESTATE->m_pCurSteps[PLAYER_1];
// If unchanged:
if( pSteps->GetCredit() == sAnswer )
return true;
// Borrow from EditDescription testing. Perhaps this should be abstracted? -Wolfman2000
static const RString sInvalidChars = "\\/:*?\"<>|";
if( strpbrk(sAnswer, sInvalidChars) != nullptr )
@@ -888,7 +890,7 @@ bool SongUtil::ValidateCurrentStepsCredit( const RString &sAnswer, RString &sErr
sErrorOut = ssprintf( AUTHOR_NAME_CANNOT_CONTAIN.GetValue(), sInvalidChars.c_str() );
return false;
}
return true;
}
@@ -999,8 +1001,8 @@ void SongUtil::GetPlayableStepsTypes( const Song *pSong, std::set<StepsType> &vO
int iNumPlayers = GAMESTATE->GetNumPlayersEnabled();
iNumPlayers = std::max( iNumPlayers, 1 );
bool bEnoughStages = GAMESTATE->IsAnExtraStage() ||
GAMESTATE->GetSmallestNumStagesLeftForAnyHumanPlayer() >=
bool bEnoughStages = GAMESTATE->IsAnExtraStage() ||
GAMESTATE->GetSmallestNumStagesLeftForAnyHumanPlayer() >=
GAMESTATE->GetNumStagesMultiplierForSong(pSong);
if( bShowThisStepsType && bEnoughStages )
@@ -1136,7 +1138,7 @@ XNode* SongID::CreateNode() const
return pNode;
}
void SongID::LoadFromNode( const XNode* pNode )
void SongID::LoadFromNode( const XNode* pNode )
{
ASSERT( pNode->GetName() == "Song" );
pNode->GetAttrValue("Dir", sDir);
@@ -1200,7 +1202,7 @@ LUA_REGISTER_NAMESPACE( SongUtil )
/*
* (c) 2001-2004 Chris Danford, Glenn Maynard
* All rights reserved.
*
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
@@ -1210,7 +1212,7 @@ LUA_REGISTER_NAMESPACE( SongUtil )
* copyright notice(s) and this permission notice appear in all copies of
* the Software and that both the above copyright notice(s) and this
* permission notice appear in supporting documentation.
*
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
+49 -48
View File
@@ -1,7 +1,4 @@
#include "global.h"
#include <cassert>
#include <float.h>
#include "Sprite.h"
#include "RageTextureManager.h"
#include "XmlFile.h"
@@ -17,6 +14,10 @@
#include "ThemeMetric.h"
#include <numeric>
#include <cassert>
#include <cfloat>
#include <cmath>
REGISTER_ACTOR_CLASS( Sprite );
const float min_state_delay= 0.0001f;
@@ -32,7 +33,7 @@ Sprite::Sprite()
m_bSkipNextUpdate = true;
m_DecodeMovie= true;
m_EffectMode = EffectMode_Normal;
m_fRememberedClipWidth = -1;
m_fRememberedClipHeight = -1;
@@ -172,7 +173,7 @@ RageTextureID Sprite::SongBannerTexture( RageTextureID ID )
void Sprite::Load( RageTextureID ID )
{
if( !ID.filename.empty() )
if( !ID.filename.empty() )
LoadFromTexture( ID );
LoadStatesFromTexture();
@@ -194,7 +195,7 @@ void Sprite::LoadFromNode( const XNode* pNode )
LoadStatesFromTexture();
// Read in frames and delays from the sprite file,
// Read in frames and delays from the sprite file,
// overwriting the states that LoadFromTexture created.
// If the .sprite file doesn't define any states, leave
// frames and delays created during LoadFromTexture().
@@ -299,9 +300,9 @@ void Sprite::UnloadTexture()
}
void Sprite::EnableAnimation( bool bEnable )
{
{
bool bWasEnabled = m_bIsAnimating;
Actor::EnableAnimation( bEnable );
Actor::EnableAnimation( bEnable );
if( bEnable && !bWasEnabled )
{
@@ -373,7 +374,7 @@ void Sprite::LoadFromCached( const RString &sDir, const RString &sPath )
}
RageTextureID ID;
// Try to load the low quality version.
ID = IMAGECACHE->LoadCachedImage( sDir, sPath );
@@ -411,7 +412,7 @@ void Sprite::LoadStatesFromTexture()
void Sprite::UpdateAnimationState()
{
// Don't bother with state switching logic if there's only one state.
// Don't bother with state switching logic if there's only one state.
// We already know what's going to show.
if( m_States.size() > 1 )
{
@@ -483,7 +484,7 @@ void Sprite::Update( float fDelta )
}
float fTexCoords[8];
Sprite::GetActiveTextureCoords( fTexCoords );
// top left, bottom left, bottom right, top right
fTexCoords[0] += coord_delta * m_fTexCoordVelocityX;
fTexCoords[1] += coord_delta * m_fTexCoordVelocityY;
@@ -500,8 +501,8 @@ void Sprite::Update( float fDelta )
* coordinates by the same amount, this won't be visible. */
if( m_bTextureWrapping )
{
const float fXAdjust = floorf( fTexCoords[0] );
const float fYAdjust = floorf( fTexCoords[1] );
const float fXAdjust = std::floor( fTexCoords[0] );
const float fYAdjust = std::floor( fTexCoords[1] );
fTexCoords[0] -= fXAdjust;
fTexCoords[2] -= fXAdjust;
fTexCoords[4] -= fXAdjust;
@@ -529,10 +530,10 @@ void Sprite::DrawTexture( const TweenState *state )
Actor::SetGlobalRenderStates(); // set Actor-specified render states
RectF crop = state->crop;
// bail if cropped all the way
if( crop.left + crop.right >= 1 ||
crop.top + crop.bottom >= 1 )
return;
// bail if cropped all the way
if( crop.left + crop.right >= 1 ||
crop.top + crop.bottom >= 1 )
return;
// use m_temp_* variables to draw the object
RectF quadVerticies;
@@ -541,24 +542,24 @@ void Sprite::DrawTexture( const TweenState *state )
quadVerticies.top = -m_size.y/2.0f;
quadVerticies.bottom = +m_size.y/2.0f;
/* Don't draw anything outside of the texture's image area. Texels outside
/* Don't draw anything outside of the texture's image area. Texels outside
* of the image area aren't guaranteed to be initialized. */
/* HACK: Clamp the crop values. It would be more accurate to clip the
/* HACK: Clamp the crop values. It would be more accurate to clip the
* vertices so that the diffuse value is adjusted. */
CLAMP( crop.left, 0, 1 );
CLAMP( crop.right, 0, 1 );
CLAMP( crop.top, 0, 1 );
CLAMP( crop.bottom, 0, 1 );
RectF croppedQuadVerticies = quadVerticies;
RectF croppedQuadVerticies = quadVerticies;
#define IF_CROP_POS(side,opp_side) \
if(state->crop.side!=0) \
croppedQuadVerticies.side = \
SCALE( crop.side, 0.f, 1.f, quadVerticies.side, quadVerticies.opp_side )
IF_CROP_POS( left, right );
IF_CROP_POS( top, bottom );
IF_CROP_POS( right, left );
IF_CROP_POS( bottom, top );
IF_CROP_POS( left, right );
IF_CROP_POS( top, bottom );
IF_CROP_POS( right, left );
IF_CROP_POS( bottom, top );
static RageSpriteVertex v[4];
v[0].p = RageVector3( croppedQuadVerticies.left, croppedQuadVerticies.top, 0 ); // top left
@@ -577,7 +578,7 @@ void Sprite::DrawTexture( const TweenState *state )
DISPLAY->ClearAllTextures();
DISPLAY->SetTexture( TextureUnit_1, m_pTexture? m_pTexture->GetTexHandle():0 );
// Must call this after setting the texture or else texture
// Must call this after setting the texture or else texture
// parameters have no effect.
Actor::SetTextureRenderStates(); // set Actor-specified render states
DISPLAY->SetEffectMode( m_EffectMode );
@@ -625,7 +626,7 @@ void Sprite::DrawTexture( const TweenState *state )
}
// Draw if we're not fully transparent
if( state->diffuse[0].a > 0 ||
if( state->diffuse[0].a > 0 ||
state->diffuse[1].a > 0 ||
state->diffuse[2].a > 0 ||
state->diffuse[3].a > 0 )
@@ -800,13 +801,13 @@ void Sprite::DrawPrimitives()
int Sprite::GetNumStates() const
{
return m_States.size();
return m_States.size();
}
void Sprite::SetState( int iNewState )
{
/*
* This assert will likely trigger if the "missing" theme element graphic
* This assert will likely trigger if the "missing" theme element graphic
* is loaded in place of a multi-frame sprite. We want to know about these
* problems in debug builds, but they're not fatal.
*/
@@ -828,7 +829,7 @@ void Sprite::SetState( int iNewState )
*/
m_pTexture->GetID().filename.c_str(), this->m_sName.c_str(), iNewState+1, unsigned(m_States.size()));
else
sError = ssprintf("A Sprite (\"%s\") tried to set state index %d, but no texture is loaded.",
sError = ssprintf("A Sprite (\"%s\") tried to set state index %d, but no texture is loaded.",
this->m_sName.c_str(), iNewState );
LuaHelpers::ReportScriptError(sError, "SPRITE_INVALID_FRAME");
}
@@ -865,19 +866,19 @@ RString Sprite::GetTexturePath() const
return m_pTexture->GetID().filename;
}
void Sprite::SetCustomTextureRect( const RectF &new_texcoord_frect )
{
void Sprite::SetCustomTextureRect( const RectF &new_texcoord_frect )
{
m_bUsingCustomTexCoords = true;
m_bTextureWrapping = true;
TexCoordArrayFromRect( m_CustomTexCoords, new_texcoord_frect );
}
void Sprite::SetCustomTextureCoords( float fTexCoords[8] ) // order: top left, bottom left, bottom right, top right
{
{
m_bUsingCustomTexCoords = true;
m_bTextureWrapping = true;
for( int i=0; i<8; i++ )
m_CustomTexCoords[i] = fTexCoords[i];
m_CustomTexCoords[i] = fTexCoords[i];
}
void Sprite::SetCustomImageRect( RectF rectImageCoords )
@@ -885,8 +886,8 @@ void Sprite::SetCustomImageRect( RectF rectImageCoords )
// Convert to a rectangle in texture coordinate space.
rectImageCoords.left *= m_pTexture->GetImageWidth() / (float)m_pTexture->GetTextureWidth();
rectImageCoords.right *= m_pTexture->GetImageWidth() / (float)m_pTexture->GetTextureWidth();
rectImageCoords.top *= m_pTexture->GetImageHeight() / (float)m_pTexture->GetTextureHeight();
rectImageCoords.bottom *= m_pTexture->GetImageHeight() / (float)m_pTexture->GetTextureHeight();
rectImageCoords.top *= m_pTexture->GetImageHeight() / (float)m_pTexture->GetTextureHeight();
rectImageCoords.bottom *= m_pTexture->GetImageHeight() / (float)m_pTexture->GetTextureHeight();
SetCustomTextureRect( rectImageCoords );
}
@@ -896,8 +897,8 @@ void Sprite::SetCustomImageCoords( float fImageCoords[8] ) // order: top left, b
// convert image coords to texture coords in place
for( int i=0; i<8; i+=2 )
{
fImageCoords[i+0] *= m_pTexture->GetImageWidth() / (float)m_pTexture->GetTextureWidth();
fImageCoords[i+1] *= m_pTexture->GetImageHeight() / (float)m_pTexture->GetTextureHeight();
fImageCoords[i+0] *= m_pTexture->GetImageWidth() / (float)m_pTexture->GetTextureWidth();
fImageCoords[i+1] *= m_pTexture->GetImageHeight() / (float)m_pTexture->GetTextureHeight();
}
SetCustomTextureCoords( fImageCoords );
@@ -928,11 +929,11 @@ const RectF *Sprite::GetTextureCoordRectForState( int iState ) const
* coordinates for the current state. */
void Sprite::GetActiveTextureCoords( float fTexCoordsOut[8] ) const
{
if(m_bUsingCustomTexCoords)
if(m_bUsingCustomTexCoords)
{
// GetCustomTextureCoords
for( int i=0; i<8; i++ )
fTexCoordsOut[i] = m_CustomTexCoords[i];
fTexCoordsOut[i] = m_CustomTexCoords[i];
}
else
{
@@ -990,7 +991,7 @@ void Sprite::ScaleToClipped( float fWidth, float fHeight )
float fPercentageToCutOffEachSide = fPercentageToCutOff / 2;
// generate a rectangle with new texture coordinates
RectF fCustomImageRect(
RectF fCustomImageRect(
fPercentageToCutOffEachSide,
0,
1 - fPercentageToCutOffEachSide,
@@ -1004,7 +1005,7 @@ void Sprite::ScaleToClipped( float fWidth, float fHeight )
float fPercentageToCutOffEachSide = fPercentageToCutOff / 2;
// generate a rectangle with new texture coordinates
RectF fCustomImageRect(
RectF fCustomImageRect(
0,
fPercentageToCutOffEachSide,
1,
@@ -1050,7 +1051,7 @@ void Sprite::CropTo( float fWidth, float fHeight )
float fPercentageToCutOffEachSide = fPercentageToCutOff / 2;
// generate a rectangle with new texture coordinates
RectF fCustomImageRect(
RectF fCustomImageRect(
fPercentageToCutOffEachSide,
0,
1 - fPercentageToCutOffEachSide,
@@ -1063,7 +1064,7 @@ void Sprite::CropTo( float fWidth, float fHeight )
float fPercentageToCutOffEachSide = fPercentageToCutOff / 2;
// generate a rectangle with new texture coordinates
RectF fCustomImageRect(
RectF fCustomImageRect(
0,
fPercentageToCutOffEachSide,
1,
@@ -1111,7 +1112,7 @@ void Sprite::AddImageCoords( float fX, float fY )
// lua start
#include "LuaBinding.h"
/** @brief Allow Lua to have access to the Sprite. */
/** @brief Allow Lua to have access to the Sprite. */
class LunaSprite: public Luna<Sprite>
{
public:
@@ -1150,7 +1151,7 @@ public:
return 1;
}
/* Commands that go in the tweening queue:
/* Commands that go in the tweening queue:
* Commands that take effect immediately (ignoring the tweening queue): */
static int customtexturerect( T* p, lua_State *L ) { p->SetCustomTextureRect( RectF(FArg(1),FArg(2),FArg(3),FArg(4)) ); COMMON_RETURN_SELF; }
static int SetCustomImageRect( T* p, lua_State *L ) { p->SetCustomImageRect( RectF(FArg(1),FArg(2),FArg(3),FArg(4)) ); COMMON_RETURN_SELF; }
@@ -1300,7 +1301,7 @@ public:
COMMON_RETURN_SELF;
}
static int LoadFromCached( T* p, lua_State *L )
{
{
p->LoadFromCached( SArg(1), SArg(2) );
COMMON_RETURN_SELF;
}
@@ -1343,7 +1344,7 @@ LUA_REGISTER_DERIVED_CLASS( Sprite, Actor )
/*
* (c) 2001-2004 Chris Danford
* All rights reserved.
*
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
@@ -1353,7 +1354,7 @@ LUA_REGISTER_DERIVED_CLASS( Sprite, Actor )
* copyright notice(s) and this permission notice appear in all copies of
* the Software and that both the above copyright notice(s) and this
* permission notice appear in supporting documentation.
*
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
+4 -2
View File
@@ -1,4 +1,4 @@
#include "global.h"
#include "global.h"
#include "StatsManager.h"
#include "RageFileManager.h"
#include "GameState.h"
@@ -19,6 +19,8 @@
#include "PlayerState.h"
#include "Player.h"
#include <cmath>
StatsManager* STATSMAN = nullptr; // global object accessible from anywhere in the program
void AddPlayerStatsToProfile( Profile *pProfile, const StageStats &ss, PlayerNumber pn );
@@ -209,7 +211,7 @@ void StatsManager::CommitStatsToProfiles( const StageStats *pSS )
// Update profile stats
Profile* pMachineProfile = PROFILEMAN->GetMachineProfile();
int iGameplaySeconds = (int)truncf(pSS->m_fGameplaySeconds);
int iGameplaySeconds = std::trunc(pSS->m_fGameplaySeconds);
pMachineProfile->m_iTotalGameplaySeconds += iGameplaySeconds;
pMachineProfile->m_iNumTotalSongsPlayed += pSS->m_vpPlayedSongs.size();
+6 -4
View File
@@ -70,6 +70,8 @@
#include "ActorUtil.h"
#include "ver.h"
#include <cmath>
#if defined(WIN32)
#include <windows.h>
#endif
@@ -88,8 +90,8 @@ void StepMania::GetPreferredVideoModeParams( VideoModeParams &paramsOut )
{
//float fRatio = PREFSMAN->m_iDisplayHeight;
//iWidth = PREFSMAN->m_iDisplayHeight * fRatio;
iWidth = static_cast<int>(ceilf(PREFSMAN->m_iDisplayHeight * PREFSMAN->m_fDisplayAspectRatio));
// ceilf causes the width to come out odd when it shouldn't.
iWidth = std::ceil(PREFSMAN->m_iDisplayHeight * PREFSMAN->m_fDisplayAspectRatio);
// ceil causes the width to come out odd when it shouldn't.
// 576 * 1.7778 = 1024.0128, which is rounded to 1025. -Kyz
iWidth-= iWidth % 2;
}
@@ -733,7 +735,7 @@ void StepMania::InitializeCurrentGame( const Game* g )
GAMESTATE->SetCurGame(new_game);
}
}
// It doesn't matter if sTheme is blank or invalid, THEME->STAL will set
// a selectable theme for us. -Kyz
@@ -1111,7 +1113,7 @@ void StepMania::InsertCoin( int iNum, bool bCountInBookkeeping )
{
GAMESTATE->m_iCoins.Set( GAMESTATE->m_iCoins + iNum );
}
int iCredits = GAMESTATE->m_iCoins / PREFSMAN->m_iCoinsPerCredit;
bool bMaxCredits = iCredits >= PREFSMAN->m_iMaxNumCredits;
if( bMaxCredits )
+7 -5
View File
@@ -1,11 +1,13 @@
#include "global.h"
#include "StreamDisplay.h"
#include "GameState.h"
#include <float.h>
#include "RageDisplay.h"
#include "ThemeManager.h"
#include "EnumHelper.h"
#include <cfloat>
#include <cmath>
static const char *StreamTypeNames[] = {
"Normal",
"Passing",
@@ -75,10 +77,10 @@ void StreamDisplay::Update( float fDeltaSecs )
// Just move straight to either full or empty.
if( m_fPercent <= 0 || m_fPercent >= 1 )
{
if( fabsf(fDelta) < 0.00001f )
if( std::abs(fDelta) < 0.00001f )
m_fVelocity = 0; // prevent div/0
else
m_fVelocity = (fDelta / fabsf(fDelta)) * VELOCITY_MULTIPLIER;
m_fVelocity = (fDelta / std::abs(fDelta)) * VELOCITY_MULTIPLIER;
}
else
{
@@ -161,7 +163,7 @@ void StreamDisplay::SetPercent( float fPercent )
/*
* (c) 2003-2004 Chris Danford
* All rights reserved.
*
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
@@ -171,7 +173,7 @@ void StreamDisplay::SetPercent( float fPercent )
* copyright notice(s) and this permission notice appear in all copies of
* the Software and that both the above copyright notice(s) and this
* permission notice appear in supporting documentation.
*
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
+13 -12
View File
@@ -2,13 +2,13 @@
/*
* Styles define a set of columns for each player, and information about those
* columns, like what Instruments are used play those columns and what track
* columns, like what Instruments are used play those columns and what track
* to use to populate the column's notes.
* A "track" is the term used to descibe a particular vertical sting of note
* A "track" is the term used to descibe a particular vertical sting of note
* in NoteData.
* A "column" is the term used to describe the vertical string of notes that
* a player sees on the screen while they're playing. Column notes are
* picked from a track, but columns and tracks don't have a 1-to-1
* A "column" is the term used to describe the vertical string of notes that
* a player sees on the screen while they're playing. Column notes are
* picked from a track, but columns and tracks don't have a 1-to-1
* correspondance. For example, dance-versus has 8 columns but only 4 tracks
* because two players place from the same set of 4 tracks.
*/
@@ -19,7 +19,8 @@
#include "RageUtil.h"
#include "InputMapper.h"
#include "NoteData.h"
#include <float.h>
#include <cfloat>
bool Style::GetUsesCenteredArrows() const
{
@@ -138,7 +139,7 @@ RString Style::ColToButtonName( int iCol ) const
// Lua bindings
#include "LuaBinding.h"
/** @brief Allow Lua to have access to the Style. */
/** @brief Allow Lua to have access to the Style. */
class LunaStyle: public Luna<Style>
{
public:
@@ -179,8 +180,8 @@ public:
ret.Set( L, "XOffset" );
lua_pushstring( L, p->ColToButtonName(iCol) );
ret.Set( L, "Name" );
ret.PushSelf(L);
ret.PushSelf(L);
return 1;
}
@@ -195,7 +196,7 @@ public:
lua_pushnumber( L, p->m_iColumnDrawOrder[iCol]+1 );
return 1;
}
LunaStyle()
{
ADD_METHOD( GetName );
@@ -215,7 +216,7 @@ LUA_REGISTER_CLASS( Style )
/*
* (c) 2001-2002 Chris Danford
* All rights reserved.
*
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
@@ -225,7 +226,7 @@ LUA_REGISTER_CLASS( Style )
* copyright notice(s) and this permission notice appear in all copies of
* the Software and that both the above copyright notice(s) and this
* permission notice appear in supporting documentation.
*
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
@@ -4,10 +4,10 @@
#include "TextureFont.h"
#include "Utils.h"
#include <vector>
#include <cmath>
#include <fstream>
#include <set>
#include <math.h>
#include <vector>
static TextureFont *g_pTextureFont = NULL;
@@ -105,9 +105,9 @@ static const wchar_t map_iso_8859_2[] = {
* :x,
*/
static const wchar_t map_numbers[] = {
0x0030, 0x0031, 0x0032, 0x0033,
0x0034, 0x0035, 0x0036, 0x0037,
0x0038, 0x0039, 0x0025, 0x002E,
0x0030, 0x0031, 0x0032, 0x0033,
0x0034, 0x0035, 0x0036, 0x0037,
0x0038, 0x0039, 0x0025, 0x002E,
0x0020, 0x003A, 0x0078, 0x002C,
0
};
@@ -557,12 +557,12 @@ void CTextureFontGeneratorDlg::UpdateFont( bool bSavingDoubleRes )
CString sText;
m_FamilyList.GetWindowText( sText );
g_pTextureFont->m_sFamily = sText;
m_FontSize.GetWindowText(sText);
g_pTextureFont->m_fFontSizePixels = (float) atof(sText);
if( bSavingDoubleRes )
g_pTextureFont->m_fFontSizePixels *= 2;
m_Padding.GetWindowText(sText);
g_pTextureFont->m_iPadding = atoi(sText);
if( bSavingDoubleRes )
@@ -688,7 +688,7 @@ void CTextureFontGeneratorDlg::UpdateCloseUp()
hPen = CreatePen( PS_SOLID, 1, RGB(255, 255, 50) );
hOldPen = SelectObject( hZoomDC, hPen );
/* Align the line with the bottom of the unit, so, when correct, the line
* "sits" on the font. */
iY = iZoomFactor*g_pTextureFont->m_iCharTop - 1;
@@ -780,11 +780,11 @@ void CTextureFontGeneratorDlg::UpdateFontViewAndCloseUp()
HBITMAP hBitmap = g_pTextureFont->m_apPages[iSelectedPage]->m_hPage;
m_FontView.SetBitmap( hBitmap );
UpdateCloseUp();
CString sStr;
sStr.Format("Overlap: %i, %i\nMaximum size: %ix%i",
sStr.Format("Overlap: %i, %i\nMaximum size: %ix%i",
g_pTextureFont->m_iCharLeftOverlap, g_pTextureFont->m_iCharRightOverlap,
g_pTextureFont->m_BoundingRect.right - g_pTextureFont->m_BoundingRect.left,
g_pTextureFont->m_BoundingRect.bottom - g_pTextureFont->m_BoundingRect.top
@@ -798,7 +798,7 @@ void CTextureFontGeneratorDlg::OnDestroy()
CDialog::OnDestroy();
}
void CTextureFontGeneratorDlg::OnPaint()
void CTextureFontGeneratorDlg::OnPaint()
{
if( IsIconic() )
{
@@ -839,19 +839,19 @@ HCURSOR CTextureFontGeneratorDlg::OnQueryDragIcon()
}
void CTextureFontGeneratorDlg::OnClose()
void CTextureFontGeneratorDlg::OnClose()
{
if( CanExit() )
CDialog::OnClose();
}
void CTextureFontGeneratorDlg::OnOK()
void CTextureFontGeneratorDlg::OnOK()
{
if( CanExit() )
CDialog::OnOK();
}
void CTextureFontGeneratorDlg::OnCancel()
void CTextureFontGeneratorDlg::OnCancel()
{
if (CanExit())
CDialog::OnCancel();
@@ -1004,8 +1004,8 @@ void CTextureFontGeneratorDlg::OnFileSave()
{
CString sName = g_pTextureFont->m_sFamily;
sName.MakeLower();
_snprintf( szFile, 1023, "_%s%s %gpx",
(const char *) sName,
_snprintf( szFile, 1023, "_%s%s %gpx",
(const char *) sName,
g_pTextureFont->m_bBold ? " Bold" : "",
g_pTextureFont->m_fFontSizePixels );
}
+13 -13
View File
@@ -2,9 +2,9 @@
#include "TextureFont.h"
#include "Utils.h"
#include <fstream>
#include <math.h>
#include <cassert>
#include <cmath>
#include <fstream>
TextureFont::TextureFont()
{
@@ -33,7 +33,7 @@ void TextureFont::FormatFontPages()
ASSERT( b );
}
m_Characters.clear();
m_sError = m_sWarnings = "";
/*
@@ -151,9 +151,9 @@ void TextureFont::FormatCharacter( wchar_t c, HDC hDC )
ABCFLOAT abcf;
GetCharABCWidthsFloatW( hDC, c, c, &abcf );
abc.abcA = lrintf( abcf.abcfA );
abc.abcB = lrintf( abcf.abcfB );
abc.abcC = lrintf( abcf.abcfC );
abc.abcA = std::lrint( abcf.abcfA );
abc.abcB = std::lrint( abcf.abcfB );
abc.abcC = std::lrint( abcf.abcfC );
}
/*
@@ -289,14 +289,14 @@ void TextureFont::FormatFontPage( int iPage, HDC hDC )
pPage->m_iFrameWidth = (m_BoundingRect.right - m_BoundingRect.left) + m_iPadding;
pPage->m_iFrameHeight = (m_BoundingRect.bottom - m_BoundingRect.top) + m_iPadding;
int iDimensionMultiple = 4; // TODO: This only needs to be 4 for doubleres textures. It could be 2 otherwise and use less space
pPage->m_iFrameWidth = (int)ceil( pPage->m_iFrameWidth /(double)iDimensionMultiple ) * iDimensionMultiple;
pPage->m_iFrameHeight = (int)ceil( pPage->m_iFrameHeight /(double)iDimensionMultiple ) * iDimensionMultiple;
pPage->m_iFrameWidth = std::ceil( pPage->m_iFrameWidth /(double)iDimensionMultiple ) * iDimensionMultiple;
pPage->m_iFrameHeight = std::ceil( pPage->m_iFrameHeight /(double)iDimensionMultiple ) * iDimensionMultiple;
pPage->m_iNumFramesX = (int) ceil( powf( (float) Desc.chars.size(), 0.5f ) );
pPage->m_iNumFramesY = (int) ceil( (float) Desc.chars.size() / pPage->m_iNumFramesX );
pPage->m_iNumFramesX = std::ceil( std::pow( (float) Desc.chars.size(), 0.5f ) );
pPage->m_iNumFramesY = std::ceil( (float) Desc.chars.size() / pPage->m_iNumFramesX );
pPage->Create( pPage->m_iNumFramesX*pPage->m_iFrameWidth, pPage->m_iNumFramesY*pPage->m_iFrameHeight );
HGDIOBJ hOldBitmap = SelectObject( hDC, pPage->m_hPage );
HDC hSrcDC = CreateCompatibleDC( NULL );
@@ -306,7 +306,7 @@ void TextureFont::FormatFontPage( int iPage, HDC hDC )
{
const wchar_t c = Desc.chars[CurChar];
const ABC &abc = m_ABC[c];
/* The current frame is at fOffsetX/fOffsetY. Center the character
* horizontally in the frame. We can align it however we want
* vertically, as long as we align the baselines. */
@@ -505,7 +505,7 @@ void TextureFont::Save( CString sBasePath, CString sBitmapAppendBeforeExtension,
FontPage::FontPage()
{
{
m_hPage = NULL;
m_iFrameWidth = 0;
m_iFrameHeight = 0;
-24
View File
@@ -3,30 +3,6 @@
#include "config.hpp"
#if !defined(HAVE_TRUNCF)
inline float truncf( float f ) { return float(int(f)); };
#endif
#if !defined(HAVE_ROUNDF)
inline float roundf( float f ) { if(f < 0) return truncf(f-0.5f); return truncf(f+0.5f); };
#endif
#if !defined(HAVE_LRINTF)
#if defined(_MSC_VER) && defined(_X86_)
inline long int lrintf( float f )
{
int retval;
_asm fld f;
_asm fistp retval;
return retval;
}
#else
#define lrintf(x) ((int)rint(x))
#endif
#endif
struct Surface
{
Surface() { pRGBA = NULL; }
+7 -5
View File
@@ -6,7 +6,9 @@
#include "RageLog.h"
#include "ThemeManager.h"
#include "NoteTypes.h"
#include <float.h>
#include <cfloat>
#include <cmath>
static void EraseSegment(std::vector<TimingSegment*> &vSegs, int index, TimingSegment *cur);
static const int INVALID_INDEX = -1;
@@ -414,7 +416,7 @@ int TimingData::GetSegmentIndexAtRow(TimingSegmentType tst, int iRow ) const
r = m - 1;
}
}
// iRow is before the first segment of type tst
return INVALID_INDEX;
}
@@ -1030,7 +1032,7 @@ void TimingData::ScaleRegion( float fScale, int iStartIndex, int iEndIndex, bool
ASSERT( iStartIndex < iEndIndex );
int length = iEndIndex - iStartIndex;
int newLength = lrintf( fScale * length );
int newLength = std::lrint( fScale * length );
FOREACH_TimingSegmentType( tst )
for (unsigned j = 0; j < m_avpTimingSegments[tst].size(); j++)
@@ -1435,7 +1437,7 @@ LUA_REGISTER_CLASS( TimingData )
/*
* (c) 2001-2004 Chris Danford, Glenn Maynard
* All rights reserved.
*
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
@@ -1445,7 +1447,7 @@ LUA_REGISTER_CLASS( TimingData )
* copyright notice(s) and this permission notice appear in all copies of
* the Software and that both the above copyright notice(s) and this
* permission notice appear in supporting documentation.
*
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
+6 -4
View File
@@ -4,8 +4,10 @@
#include "NoteTypes.h"
#include "TimingSegments.h"
#include "PrefsManager.h"
#include <float.h> // max float
#include <cfloat>
#include <array>
struct lua_State;
/** @brief Compare a TimingData segment's properties with one another. */
@@ -401,7 +403,7 @@ public:
// optimization: check vector sizes before contents
if( us.size() != them.size() )
return false;
for( unsigned i = 0; i < us.size(); ++i )
{
/* UGLY: since TimingSegment's comparison compares base data,
@@ -479,7 +481,7 @@ protected:
* @author Chris Danford, Glenn Maynard (c) 2001-2004
* @section LICENSE
* All rights reserved.
*
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
@@ -489,7 +491,7 @@ protected:
* copyright notice(s) and this permission notice appear in all copies of
* the Software and that both the above copyright notice(s) and this
* permission notice appear in supporting documentation.
*
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
+5 -3
View File
@@ -3,6 +3,8 @@
#include "NoteTypes.h" // Converting rows to beats and vice~versa.
#include <cmath>
enum TimingSegmentType
{
SEGMENT_BPM,
@@ -37,7 +39,7 @@ const RString& TimingSegmentTypeToString( TimingSegmentType tst );
const int ROW_INVALID = -1;
#define COMPARE(x) if( this->x!=other.x ) return false
#define COMPARE_FLOAT(x) if( fabsf(this->x - other.x) > EPSILON ) return false
#define COMPARE_FLOAT(x) if( std::abs(this->x - other.x) > EPSILON ) return false
/**
* @brief The base timing segment for make glorious benefit wolfman
@@ -737,7 +739,7 @@ private:
* @author Jason Felds (c) 2011
* @section LICENSE
* All rights reserved.
*
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
@@ -747,7 +749,7 @@ private:
* copyright notice(s) and this permission notice appear in all copies of
* the Software and that both the above copyright notice(s) and this
* permission notice appear in supporting documentation.
*
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
+11 -9
View File
@@ -7,6 +7,8 @@
#include "NoteData.h"
#include "NoteDataUtil.h"
#include "CommonMetrics.h"
#include <cmath>
#include <numeric>
void TrailEntry::GetAttackArray( AttackArray &out ) const
@@ -20,7 +22,7 @@ void TrailEntry::GetAttackArray( AttackArray &out ) const
bool TrailEntry::operator== ( const TrailEntry &rhs ) const
{
#define EQUAL(a) (a==rhs.a)
return
return
EQUAL(pSong) &&
EQUAL(pSteps) &&
EQUAL(Modifiers) &&
@@ -45,7 +47,7 @@ bool TrailEntry::ContainsTransformOrTurn() const
// TrailEntry lua start
#include "LuaBinding.h"
/** @brief Allow Lua to have access to the TrailEntry. */
/** @brief Allow Lua to have access to the TrailEntry. */
class LunaTrailEntry: public Luna<TrailEntry>
{
public:
@@ -94,8 +96,8 @@ const RadarValues &Trail::GetRadarValues() const
}
if( IsSecret() )
{
// Don't calculate RadarValues for a non-fixed Course. They values are
// worthless because they'll change every time this Trail is
// Don't calculate RadarValues for a non-fixed Course. They values are
// worthless because they'll change every time this Trail is
// regenerated.
m_CachedRadarValues = RadarValues();
return m_CachedRadarValues;
@@ -131,7 +133,7 @@ const RadarValues &Trail::GetRadarValues() const
}
else
{
rv += pSteps->GetRadarValues( PLAYER_1 );
rv += pSteps->GetRadarValues( PLAYER_1 );
}
}
@@ -154,7 +156,7 @@ int Trail::GetMeter() const
float fMeter = GetTotalMeter() / (float)m_vEntries.size();
return lrintf( fMeter );
return std::lrint( fMeter );
}
int Trail::GetTotalMeter() const
@@ -214,7 +216,7 @@ bool Trail::ContainsSong( const Song *pSong ) const
// lua start
#include "LuaBinding.h"
/** @brief Allow Lua to have access to the Trail. */
/** @brief Allow Lua to have access to the Trail. */
class LunaTrail: public Luna<Trail>
{
public:
@@ -299,7 +301,7 @@ LUA_REGISTER_CLASS( Trail )
/*
* (c) 2001-2004 Chris Danford, Glenn Maynard
* All rights reserved.
*
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
@@ -309,7 +311,7 @@ LUA_REGISTER_CLASS( Trail )
* copyright notice(s) and this permission notice appear in all copies of
* the Software and that both the above copyright notice(s) and this
* permission notice appear in supporting documentation.
*
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
+34 -33
View File
@@ -12,12 +12,13 @@
#include "Profile.h"
#include "ThemeManager.h"
#include "Steps.h"
#include <float.h>
#include "CommonMetrics.h"
#include "LuaManager.h"
#include "GameManager.h"
#include "Style.h"
#include <cfloat>
UnlockManager* UNLOCKMAN = nullptr; // global and accessible from anywhere in our program
#define UNLOCK_NAMES THEME->GetMetric ("UnlockManager","UnlockNames")
@@ -90,7 +91,7 @@ void UnlockManager::UnlockSong( const Song *song )
RString UnlockManager::FindEntryID( const RString &sName ) const
{
const UnlockEntry *pEntry = nullptr;
const Song *pSong = SONGMAN->FindSong( sName );
if( pSong != nullptr )
pEntry = FindSong( pSong );
@@ -98,7 +99,7 @@ RString UnlockManager::FindEntryID( const RString &sName ) const
const Course *pCourse = SONGMAN->FindCourse( sName );
if( pCourse != nullptr )
pEntry = FindCourse( pCourse );
if( pEntry == nullptr )
pEntry = FindModifier( sName );
@@ -176,11 +177,11 @@ bool UnlockManager::StepsTypeIsLocked(const Song *pSong, const Steps *pSteps, co
{
if( !PREFSMAN->m_bUseUnlockSystem )
return false;
const UnlockEntry *p = FindStepsType( pSong, pSteps, pSType );
if( p == nullptr )
return false;
return p->IsLocked();
}
@@ -219,7 +220,7 @@ const UnlockEntry *UnlockManager::FindStepsType(const Song *pSong,
{
ASSERT( pSong && pSteps && pSType );
for (UnlockEntry const &e : m_UnlockEntries)
if(e.m_Song.ToSong() == pSong &&
if(e.m_Song.ToSong() == pSong &&
e.m_dc == pSteps->GetDifficulty() &&
e.m_StepsType == pSteps->m_StepsType)
return &e;
@@ -344,7 +345,7 @@ bool UnlockEntry::IsValid() const
{
return m_Song.IsValid() && m_dc != Difficulty_Invalid && m_StepsType != StepsType_Invalid;
}
case UnlockRewardType_Course:
return m_Course.IsValid();
@@ -360,7 +361,7 @@ bool UnlockEntry::IsValid() const
UnlockEntryStatus UnlockEntry::GetUnlockEntryStatus() const
{
std::set<RString> &ids = PROFILEMAN->GetMachineProfile()->m_UnlockedEntryIDs;
if(!m_sEntryID.empty() &&
if(!m_sEntryID.empty() &&
ids.find(m_sEntryID) != ids.end() )
return UnlockEntryStatus_Unlocked;
@@ -382,15 +383,15 @@ UnlockEntryStatus UnlockEntry::GetUnlockEntryStatus() const
std::vector<Steps*> vp;
SongUtil::GetSteps(
pSong,
vp,
StepsType_Invalid,
vp,
StepsType_Invalid,
Difficulty_Hard
);
for (Steps const *s : vp)
if( PROFILEMAN->GetMachineProfile()->HasPassedSteps(pSong, s) )
return UnlockEntryStatus_Unlocked;
}
if (m_bRequirePassChallengeSteps && m_Song.IsValid())
{
Song *pSong = m_Song.ToSong();
@@ -451,7 +452,7 @@ RString UnlockEntry::GetBannerFile() const
return m_Course.ToCourse() ? m_Course.ToCourse()->GetBannerPath() : RString("");
case UnlockRewardType_Modifier:
return "";
}
}
}
RString UnlockEntry::GetBackgroundFile() const
@@ -469,7 +470,7 @@ RString UnlockEntry::GetBackgroundFile() const
return "";
case UnlockRewardType_Modifier:
return "";
}
}
}
/////////////////////////////////////////////////////////
@@ -497,7 +498,7 @@ void UnlockManager::Load()
// 1st parameter
current.PushSelf( L );
// call function with 1 argument and 0 results
RString error= "Lua error in command: ";
LuaHelpers::RunScriptOnStack(L, error, 1, 0, true);
@@ -516,12 +517,12 @@ void UnlockManager::Load()
// If no hard steps to play to unlock, skip
if( SongUtil::GetOneSteps(s, StepsType_Invalid, Difficulty_Hard) == nullptr )
continue;
// If no challenge steps to unlock, skip
if( SongUtil::GetOneSteps(s, StepsType_Invalid, Difficulty_Challenge) == nullptr )
continue;
UnlockEntry ue;
UnlockEntry ue;
ue.m_sEntryID = "_challenge_" + s->GetSongDir();
ue.m_Type = UnlockRewardType_Steps;
ue.m_cmd.Load( s->m_sGroupName+"/"+ s->GetTranslitFullTitle()+",expert" );
@@ -530,7 +531,7 @@ void UnlockManager::Load()
m_UnlockEntries.push_back( ue );
}
}
if (AUTO_LOCK_EDIT_STEPS)
{
for (Song const *s : SONGMAN->GetAllSongs())
@@ -538,19 +539,19 @@ void UnlockManager::Load()
// no challenge steps to play: skip.
if (SongUtil::GetOneSteps(s, StepsType_Invalid, Difficulty_Challenge) == nullptr)
continue;
// no edit steps to unlock: skip.
if (SongUtil::GetOneSteps(s, StepsType_Invalid, Difficulty_Edit) == nullptr)
continue;
UnlockEntry ue;
ue.m_sEntryID = "_edit_" + s->GetSongDir();
ue.m_Type = UnlockRewardType_Steps;
ue.m_cmd.Load( s->m_sGroupName+"/"+ s->GetTranslitFullTitle()+",edit" );
ue.m_bRequirePassChallengeSteps = true;
m_UnlockEntries.push_back(ue);
}
}
@@ -567,7 +568,7 @@ void UnlockManager::Load()
UnlockEntry const &ue2 = m_UnlockEntries[j];
// at this point, these two are definitely different. Assert.
ASSERT_M( ue1.m_sEntryID != ue2.m_sEntryID, ssprintf("duplicate unlock entry id %s", ue1.m_sEntryID.c_str()));
}
}
}
@@ -605,14 +606,14 @@ void UnlockManager::Load()
LuaHelpers::ReportScriptErrorFmt( "Unlock: Cannot find song matching \"%s\"", e.m_cmd.GetArg(0).s.c_str() );
break;
}
e.m_dc = StringToDifficulty( e.m_cmd.GetArg(1).s );
if( e.m_dc == Difficulty_Invalid )
{
LuaHelpers::ReportScriptErrorFmt( "Unlock: Invalid difficulty \"%s\"", e.m_cmd.GetArg(1).s.c_str() );
break;
}
e.m_StepsType = GAMEMAN->StringToStepsType(e.m_cmd.GetArg(2).s);
if (e.m_StepsType == StepsType_Invalid)
{
@@ -654,7 +655,7 @@ void UnlockManager::Load()
str += ( " (found course)" );
LOG->Trace( "%s", str.c_str() );
}
return;
}
@@ -788,7 +789,7 @@ void UnlockManager::GetStepsUnlockedByEntryID( std::vector<Song *> &apSongsOut,
// lua start
#include "LuaBinding.h"
/** @brief Allow Lua to have access to the UnlockEntry. */
/** @brief Allow Lua to have access to the UnlockEntry. */
class LunaUnlockEntry: public Luna<UnlockEntry>
{
public:
@@ -798,7 +799,7 @@ public:
static int GetRequirement( T* p, lua_State *L ) { UnlockRequirement i = Enum::Check<UnlockRequirement>( L, 1 ); lua_pushnumber(L, p->m_fRequirement[i] ); return 1; }
static int GetRequirePassHardSteps( T* p, lua_State *L ){ lua_pushboolean(L, p->m_bRequirePassHardSteps); return 1; }
static int GetRequirePassChallengeSteps( T* p, lua_State *L )
{
{
lua_pushboolean(L, p->m_bRequirePassChallengeSteps);
return 1;
}
@@ -828,7 +829,7 @@ public:
}
return 0;
}
// TODO: Add a function to just get all steps.
static int GetStepByStepsType( T* p, lua_State *L )
{
@@ -846,7 +847,7 @@ public:
}
return 0;
}
static int GetCourse( T* p, lua_State *L )
{
Course *pCourse = p->m_Course.ToCourse();
@@ -914,7 +915,7 @@ public:
LUA_REGISTER_CLASS( UnlockEntry )
/** @brief Allow Lua to have access to the UnlockManager. */
/** @brief Allow Lua to have access to the UnlockManager. */
class LunaUnlockManager: public Luna<UnlockManager>
{
public:
@@ -977,7 +978,7 @@ public:
lua_pushnumber( L, fScores[Enum::Check<UnlockRequirement>(L, 2)] );
return 1;
}
static int IsSongLocked( T* p, lua_State *L )
{
Song *pSong = Luna<Song>::check(L,1);
@@ -1015,7 +1016,7 @@ LUA_REGISTER_CLASS( UnlockManager )
/*
* (c) 2001-2004 Kevin Slaughter, Andrew Wong, Glenn Maynard
* All rights reserved.
*
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
@@ -1025,7 +1026,7 @@ LUA_REGISTER_CLASS( UnlockManager )
* copyright notice(s) and this permission notice appear in all copies of
* the Software and that both the above copyright notice(s) and this
* permission notice appear in supporting documentation.
*
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
+16 -14
View File
@@ -15,6 +15,8 @@
#include "ThemeMetric.h"
#include "ScreenDimensions.h"
#include <cmath>
const int MAX_WHEEL_SOUND_SPEED = 15;
AutoScreenMessage( SM_SongChanged ); // TODO: Replace this with a Message and MESSAGEMAN
@@ -41,7 +43,7 @@ WheelBase::~WheelBase()
m_LastSelection = nullptr;
}
void WheelBase::Load( RString sType )
void WheelBase::Load( RString sType )
{
LOG->Trace( "WheelBase::Load('%s')", sType.c_str() );
ASSERT( this->GetNumChildren() == 0 ); // only load once
@@ -87,7 +89,7 @@ void WheelBase::Load( RString sType )
ActorUtil::LoadAllCommands( *m_sprHighlight, m_sName );
m_ScrollBar.SetName( "ScrollBar" );
m_ScrollBar.SetBarHeight( SCROLL_BAR_HEIGHT );
m_ScrollBar.SetBarHeight( SCROLL_BAR_HEIGHT );
this->AddChild( &m_ScrollBar );
ActorUtil::LoadAllCommands( m_ScrollBar, m_sName );
@@ -137,7 +139,7 @@ void WheelBase::SetPositions()
{
WheelItemBase *pDisplay = m_WheelBaseItems[i];
const float fOffsetFromSelection = i - NUM_WHEEL_ITEMS/2 + m_fPositionOffsetFromSelection;
if( fabsf(fOffsetFromSelection) > NUM_WHEEL_ITEMS_TO_DRAW/2 )
if( std::abs(fOffsetFromSelection) > NUM_WHEEL_ITEMS_TO_DRAW/2 )
pDisplay->SetVisible( false );
else
pDisplay->SetVisible( true );
@@ -198,7 +200,7 @@ void WheelBase::Update( float fDeltaTime )
m_fPositionOffsetFromSelection += m_fLockedWheelVelocity*t;
if( fabsf(m_fPositionOffsetFromSelection) < 0.01f && fabsf(m_fLockedWheelVelocity) < 0.01f )
if( std::abs(m_fPositionOffsetFromSelection) < 0.01f && std::abs(m_fLockedWheelVelocity) < 0.01f )
{
m_fPositionOffsetFromSelection = 0;
m_fLockedWheelVelocity = 0;
@@ -236,7 +238,7 @@ void WheelBase::Update( float fDeltaTime )
else
{
// "rotate" wheel toward selected song
float fSpinSpeed = 0.2f + fabsf( m_fPositionOffsetFromSelection ) / SWITCH_SECONDS;
float fSpinSpeed = 0.2f + std::abs( m_fPositionOffsetFromSelection ) / SWITCH_SECONDS;
if( m_fPositionOffsetFromSelection > 0 )
{
@@ -345,7 +347,7 @@ void WheelBase::ChangeMusicUnlessLocked( int n )
{
if(n)
{
int iSign = n/abs(n);
int iSign = n / std::abs(n);
m_fLockedWheelVelocity = iSign*LOCKED_INITIAL_VELOCITY;
m_soundLocked.Play(true);
}
@@ -364,7 +366,7 @@ void WheelBase::Move(int n)
{
if(n)
{
int iSign = n/abs(n);
int iSign = n / std::abs(n);
m_fLockedWheelVelocity = iSign*LOCKED_INITIAL_VELOCITY;
m_soundLocked.Play(true);
}
@@ -386,8 +388,8 @@ bool WheelBase::MoveSpecific( int n )
{
/* If we're not selecting, discard this. We won't ignore it; we'll
* get called again every time the key is repeated. */
/* Still process Move(0) so we sometimes continue moving immediate
* after the sort change finished and before the repeat event causes a
/* Still process Move(0) so we sometimes continue moving immediate
* after the sort change finished and before the repeat event causes a
* Move(0). -Chris */
switch( m_WheelState )
{
@@ -407,7 +409,7 @@ bool WheelBase::MoveSpecific( int n )
/* We were moving, and now we're stopping. If we're really close to
* the selection, move to the next one, so we have a chance to spin down
* smoothly. */
if(fabsf(m_fPositionOffsetFromSelection) < 0.25f )
if(std::abs(m_fPositionOffsetFromSelection) < 0.25f )
ChangeMusic(m_Moving);
/* Make sure the user always gets an SM_SongChanged when
@@ -500,7 +502,7 @@ int WheelBase::FirstVisibleIndex()
int iFirstVisibleIndex = m_iSelection;
if( m_iSelection >= int(m_CurWheelItemData.size()) )
m_iSelection = 0;
// find the first wheel item shown
iFirstVisibleIndex -= NUM_WHEEL_ITEMS/2;
@@ -511,7 +513,7 @@ int WheelBase::FirstVisibleIndex()
// lua start
#include "LuaBinding.h"
/** @brief Allow Lua to have access to the WheelBase. */
/** @brief Allow Lua to have access to the WheelBase. */
class LunaWheelBase: public Luna<WheelBase>
{
public:
@@ -562,7 +564,7 @@ LUA_REGISTER_DERIVED_CLASS( WheelBase, ActorFrame )
/*
* (c) 2001-2004 Chris Danford, Chris Gomez, Glenn Maynard, Josh Allen
* All rights reserved.
*
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
@@ -572,7 +574,7 @@ LUA_REGISTER_DERIVED_CLASS( WheelBase, ActorFrame )
* copyright notice(s) and this permission notice appear in all copies of
* the Software and that both the above copyright notice(s) and this
* permission notice appear in supporting documentation.
*
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
+8 -6
View File
@@ -12,12 +12,14 @@
#include "ThemeMetric.h"
#include "LuaExpressionTransform.h"
#define NUM_WHEEL_ITEMS ((int)ceil(NUM_WHEEL_ITEMS_TO_DRAW+2))
#include <cmath>
#define NUM_WHEEL_ITEMS ((int)std::ceil(NUM_WHEEL_ITEMS_TO_DRAW+2))
enum WheelState {
STATE_SELECTING,
STATE_FLYING_OFF_BEFORE_NEXT_SORT,
STATE_FLYING_ON_AFTER_NEXT_SORT,
STATE_FLYING_OFF_BEFORE_NEXT_SORT,
STATE_FLYING_ON_AFTER_NEXT_SORT,
STATE_ROULETTE_SPINNING,
STATE_ROULETTE_SLOWING_DOWN,
STATE_RANDOM_SPINNING,
@@ -89,7 +91,7 @@ protected:
std::vector<WheelItemBaseData *> m_CurWheelItemData;
std::vector<WheelItemBase *> m_WheelBaseItems;
WheelItemBaseData* m_LastSelection;
bool m_bEmpty;
int m_iSelection; // index into m_CurWheelItemBaseData
RString m_sExpandedSectionName;
@@ -127,7 +129,7 @@ protected:
/*
* (c) 2001-2004 Chris Danford, Chris Gomez, Glenn Maynard, Josh Allen
* All rights reserved.
*
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
@@ -137,7 +139,7 @@ protected:
* copyright notice(s) and this permission notice appear in all copies of
* the Software and that both the above copyright notice(s) and this
* permission notice appear in supporting documentation.
*
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
+6 -4
View File
@@ -7,6 +7,8 @@
#include "RageTimer.h"
#include "ThemeManager.h"
#include <cmath>
/* todo: replace this entire thing with a set of AutoActors and a Scroller.
* In reality, everything except the Beginner/Training icon can be replicated
* in Lua (in stock StepMania 4), so I'm not sure if we even need this... -aj
@@ -82,9 +84,9 @@ void WheelNotifyIcon::Update( float fDeltaTime )
if( m_vIconsToShow.size() > 0 )
{
/* We should probably end up parsing the vector and then dynamically
* insert flag icons based on "priority". Easy to do, hopefully
* insert flag icons based on "priority". Easy to do, hopefully
- Midiman */
const float fSecondFraction = fmodf( RageTimer::GetTimeSinceStartFast(), 1 );
const float fSecondFraction = std::fmod( RageTimer::GetTimeSinceStartFast(), 1 );
const int index = (int)(fSecondFraction*m_vIconsToShow.size());
Sprite::SetState( m_vIconsToShow[index] );
}
@@ -95,7 +97,7 @@ void WheelNotifyIcon::Update( float fDeltaTime )
/*
* (c) 2001-2004 Chris Danford
* All rights reserved.
*
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
@@ -105,7 +107,7 @@ void WheelNotifyIcon::Update( float fDeltaTime )
* copyright notice(s) and this permission notice appear in all copies of
* the Software and that both the above copyright notice(s) and this
* permission notice appear in supporting documentation.
*
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
@@ -20,6 +20,7 @@
#pragma comment(lib, "xinput.lib")
#endif
#include <cmath>
#include <XInput.h>
#include <WbemIdl.h>
#include <OleAuto.h>
@@ -72,13 +73,13 @@ static BOOL IsXInputDevice(const GUID* pGuidProductFromDirectInput)
bstrClassName = SysAllocString(L"Win32_PNPEntity"); if (bstrClassName == nullptr) goto LCleanup;
bstrDeviceID = SysAllocString(L"DeviceID"); if (bstrDeviceID == nullptr) goto LCleanup;
// Connect to WMI
// Connect to WMI
hr = pIWbemLocator->ConnectServer(bstrNamespace, nullptr, nullptr, 0L,
0L, nullptr, nullptr, &pIWbemServices);
if (FAILED(hr) || pIWbemServices == nullptr)
goto LCleanup;
// Switch security level to IMPERSONATE.
// Switch security level to IMPERSONATE.
CoSetProxyBlanket(pIWbemServices, RPC_C_AUTHN_WINNT, RPC_C_AUTHZ_NONE, nullptr,
RPC_C_AUTHN_LEVEL_CALL, RPC_C_IMP_LEVEL_IMPERSONATE, nullptr, EOAC_NONE);
@@ -103,7 +104,7 @@ static BOOL IsXInputDevice(const GUID* pGuidProductFromDirectInput)
if (SUCCEEDED(hr) && var.vt == VT_BSTR && var.bstrVal != nullptr)
{
// Check if the device ID contains "IG_". If it does, then it's an XInput device
// This information can not be found from DirectInput
// This information can not be found from DirectInput
if (wcsstr(var.bstrVal, L"IG_"))
{
// If it does, then get the VID/PID from var.bstrVal
@@ -499,7 +500,7 @@ void InputHandler_DInput::UpdatePolled( DIDevice &device, const RageTimer &tm )
{ neg = JOY_AUX_1; pos = JOY_AUX_2; val = state.rglSlider[0]; }
else if( in.ofs == DIJOFS_SLIDER(1) )
{ neg = JOY_AUX_3; pos = JOY_AUX_4; val = state.rglSlider[1]; }
else LOG->MapLog( "unknown input",
else LOG->MapLog( "unknown input",
"Controller '%s' is returning an unknown joystick offset, %i",
device.m_sName.c_str(), in.ofs );
@@ -586,7 +587,7 @@ void InputHandler_DInput::UpdatePolled( DIDevice &device, const RageTimer &tm )
ButtonPressed( DeviceInput(dev, pos, 0, tm) );
}
}
else LOG->MapLog( "unknown input",
else LOG->MapLog( "unknown input",
"Mouse '%s' is returning an unknown mouse offset, %i",
device.m_sName.c_str(), in.ofs );
break;
@@ -651,7 +652,7 @@ void InputHandler_DInput::UpdateBuffered( DIDevice &device, const RageTimer &tm
if( in.ofs == DIMOFS_BUTTON0 ) mouseInput = MOUSE_LEFT;
else if( in.ofs == DIMOFS_BUTTON1 ) mouseInput = MOUSE_RIGHT;
else if( in.ofs == DIMOFS_BUTTON2 ) mouseInput = MOUSE_MIDDLE;
else LOG->MapLog( "unknown input",
else LOG->MapLog( "unknown input",
"Mouse '%s' is returning an unknown mouse offset [button], %i",
device.m_sName.c_str(), in.ofs );
ButtonPressed( DeviceInput(dev, mouseInput, !!evtbuf[i].dwData, tm) );
@@ -723,7 +724,7 @@ void InputHandler_DInput::UpdateBuffered( DIDevice &device, const RageTimer &tm
}
}
}
else LOG->MapLog( "unknown input",
else LOG->MapLog( "unknown input",
"Mouse '%s' is returning an unknown mouse offset [axis], %i",
device.m_sName.c_str(), in.ofs );
}
@@ -738,10 +739,10 @@ void InputHandler_DInput::UpdateBuffered( DIDevice &device, const RageTimer &tm
else if( in.ofs == DIJOFS_RZ ) { up = JOY_ROT_Z_UP; down = JOY_ROT_Z_DOWN; }
else if( in.ofs == DIJOFS_SLIDER(0) ) { up = JOY_AUX_1; down = JOY_AUX_2; }
else if( in.ofs == DIJOFS_SLIDER(1) ) { up = JOY_AUX_3; down = JOY_AUX_4; }
else LOG->MapLog( "unknown input",
else LOG->MapLog( "unknown input",
"Controller '%s' is returning an unknown joystick offset, %i",
device.m_sName.c_str(), in.ofs );
float l = SCALE( int(evtbuf[i].dwData), 0.0f, 100.0f, 0.0f, 1.0f );
if(GamePreferences::m_AxisFix)
{
@@ -783,7 +784,7 @@ void InputHandler_DInput::UpdateXInput( XIDevice &device, const RageTimer &tm )
// map joysticks
float lx = 0.f;
float ly = 0.f;
if (sqrt(pow(state.Gamepad.sThumbLX, 2) + pow(state.Gamepad.sThumbLY, 2)) > XINPUT_GAMEPAD_LEFT_THUMB_DEADZONE)
if (std::sqrt(std::pow(state.Gamepad.sThumbLX, 2) + std::pow(state.Gamepad.sThumbLY, 2)) > XINPUT_GAMEPAD_LEFT_THUMB_DEADZONE)
{
lx = SCALE(state.Gamepad.sThumbLX + 0.f, XINPUT_GAMEPAD_THUMB_MIN + 0.f, XINPUT_GAMEPAD_THUMB_MAX + 0.f, -1.0f, 1.0f);
ly = SCALE(state.Gamepad.sThumbLY + 0.f, XINPUT_GAMEPAD_THUMB_MIN + 0.f, XINPUT_GAMEPAD_THUMB_MAX + 0.f, -1.0f, 1.0f);
@@ -795,7 +796,7 @@ void InputHandler_DInput::UpdateXInput( XIDevice &device, const RageTimer &tm )
float rx = 0.f;
float ry = 0.f;
if (sqrt(pow(state.Gamepad.sThumbRX, 2) + pow(state.Gamepad.sThumbRY, 2)) > XINPUT_GAMEPAD_RIGHT_THUMB_DEADZONE)
if (std::sqrt(std::pow(state.Gamepad.sThumbRX, 2) + std::pow(state.Gamepad.sThumbRY, 2)) > XINPUT_GAMEPAD_RIGHT_THUMB_DEADZONE)
{
rx = SCALE(state.Gamepad.sThumbRX + 0.f, XINPUT_GAMEPAD_THUMB_MIN + 0.f, XINPUT_GAMEPAD_THUMB_MAX + 0.f, -1.0f, 1.0f);
ry = SCALE(state.Gamepad.sThumbRY + 0.f, XINPUT_GAMEPAD_THUMB_MIN + 0.f, XINPUT_GAMEPAD_THUMB_MAX + 0.f, -1.0f, 1.0f);
@@ -816,7 +817,7 @@ void InputHandler_DInput::UpdateXInput( XIDevice &device, const RageTimer &tm )
ButtonPressed(DeviceInput(device.dev, JOY_BUTTON_8, !!(state.Gamepad.wButtons & XINPUT_GAMEPAD_RIGHT_THUMB), tm));
ButtonPressed(DeviceInput(device.dev, JOY_BUTTON_9, !!(state.Gamepad.wButtons & XINPUT_GAMEPAD_LEFT_SHOULDER), tm));
ButtonPressed(DeviceInput(device.dev, JOY_BUTTON_10, !!(state.Gamepad.wButtons & XINPUT_GAMEPAD_RIGHT_SHOULDER), tm));
// map triggers to buttons
ButtonPressed(DeviceInput(device.dev, JOY_BUTTON_11, !!(state.Gamepad.bLeftTrigger > XINPUT_GAMEPAD_TRIGGER_THRESHOLD), tm));
ButtonPressed(DeviceInput(device.dev, JOY_BUTTON_12, !!(state.Gamepad.bRightTrigger > XINPUT_GAMEPAD_TRIGGER_THRESHOLD), tm));
@@ -1087,7 +1088,7 @@ wchar_t InputHandler_DInput::DeviceButtonToChar( DeviceButton button, bool bUseC
/*
* (c) 2003-2004 Glenn Maynard
* All rights reserved.
*
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
@@ -1097,7 +1098,7 @@ wchar_t InputHandler_DInput::DeviceButtonToChar( DeviceButton button, bool bUseC
* copyright notice(s) and this permission notice appear in all copies of
* the Software and that both the above copyright notice(s) and this
* permission notice appear in supporting documentation.
*
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
@@ -9,6 +9,8 @@
#include "InputMapper.h"
#include "Game.h"
#include <cmath>
// xxx: don't hardcode the port address. -aj
static const int PORT_ADDRESS = 0x378;
static const bool SCREEN_DEBUG = false;
@@ -46,7 +48,7 @@ void LightsDriver_LinuxParallel::Set( const LightsState *ls )
{
s += ls->m_bCabinetLights[cl] ? '1' : '0';
if ( ls->m_bCabinetLights[cl] )
output += (unsigned char)pow((double)2,i);
output += std::pow((double)2,i);
i++;
}
s += "\n";
@@ -74,7 +76,7 @@ void LightsDriver_LinuxParallel::Set( const LightsState *ls )
/*
* (c) 2004 Hugo Hromic M. <hhromic@udec.cl>
* All rights reserved.
*
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
@@ -84,7 +86,7 @@ void LightsDriver_LinuxParallel::Set( const LightsState *ls )
* copyright notice(s) and this permission notice appear in all copies of
* the Software and that both the above copyright notice(s) and this
* permission notice appear in supporting documentation.
*
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
+11 -9
View File
@@ -12,11 +12,13 @@
#include "RageSurface_Load.h"
#include "RageSurface.h"
#include "RageSurfaceUtils.h"
#include "RageSurfaceUtils_Zoom.h"
#include "RageLog.h"
#include "ProductInfo.h"
#include "LocalizedString.h"
#include "RageSurfaceUtils_Zoom.h"
#include <cmath>
static HBITMAP g_hBitmap = nullptr;
/* Load a RageSurface into a GDI surface. */
@@ -34,7 +36,7 @@ static HBITMAP LoadWin32Surface( const RageSurface *pSplash, HWND hWnd )
int iWidth = r.right;
float fRatio = (float) iWidth / s->w;
int iHeight = lrintf( s->h * fRatio );
int iHeight = std::lrint( s->h * fRatio );
RageSurfaceUtils::Zoom( s, iWidth, iHeight );
}
@@ -55,7 +57,7 @@ static HBITMAP LoadWin32Surface( const RageSurface *pSplash, HWND hWnd )
for( int x = 0; x < s->w; ++x )
{
unsigned const char *data = line + (x*s->format->BytesPerPixel);
SetPixelV( BitmapDC, x, y, RGB( data[3], data[2], data[1] ) );
}
}
@@ -94,10 +96,10 @@ INT_PTR CALLBACK LoadingWindow_Win32::WndProc( HWND hWnd, UINT msg, WPARAM wPara
}
if( g_hBitmap == nullptr )
g_hBitmap = LoadWin32Surface( "Data/splash.bmp", hWnd );
SendMessage(
GetDlgItem(hWnd,IDC_SPLASH),
STM_SETIMAGE,
(WPARAM) IMAGE_BITMAP,
SendMessage(
GetDlgItem(hWnd,IDC_SPLASH),
STM_SETIMAGE,
(WPARAM) IMAGE_BITMAP,
(LPARAM) (HANDLE) g_hBitmap );
SetWindowTextA( hWnd, PRODUCT_ID );
break;
@@ -226,7 +228,7 @@ void LoadingWindow_Win32::SetIndeterminate(bool indeterminate)
/*
* (c) 2001-2004 Chris Danford, Glenn Maynard
* All rights reserved.
*
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
@@ -236,7 +238,7 @@ void LoadingWindow_Win32::SetIndeterminate(bool indeterminate)
* copyright notice(s) and this permission notice appear in all copies of
* the Software and that both the above copyright notice(s) and this
* permission notice appear in supporting documentation.
*
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
@@ -12,8 +12,8 @@
using namespace RageDisplay_Legacy_Helpers;
using namespace X11Helper;
#include <cmath>
#include <set>
#include <math.h> // ceil()
#include <GL/glxew.h>
#define GLX_GLXEXT_PROTOTYPES
#include <GL/glx.h> // All sorts of stuff...
@@ -410,7 +410,7 @@ RString LowLevelWindow_X11::TryVideoMode( const VideoModeParams &p, bool &bNewDe
}
}
}
rate = roundf(fRefreshRate);
rate = std::round(fRefreshRate);
g_usedCrtc = tgtOutCrtc;
g_originalRandRMode = oldConf->mode;
@@ -559,7 +559,7 @@ RString LowLevelWindow_X11::TryVideoMode( const VideoModeParams &p, bool &bNewDe
CurrentParams.windowHeight = windowHeight;
CurrentParams.renderOffscreen = renderOffscreen;
ASSERT( rate > 0 );
CurrentParams.rate = static_cast<int> (roundf(rate));
CurrentParams.rate = std::round(rate);
if (!p.windowed)
{
@@ -6,6 +6,8 @@
#include "PlayerNumber.h"
#include "MemoryCardManager.h"
#include <cmath>
MemoryCardDriverThreaded_Windows::MemoryCardDriverThreaded_Windows()
{
m_dwLastLogicalDrives = 0;
@@ -23,7 +25,7 @@ static bool TestReady( const RString &sDrive, RString &sVolumeLabelOut )
DWORD lpFileSystemFlags;
TCHAR szFileSystemNameBuffer[MAX_PATH];
if( !GetVolumeInformation(
if( !GetVolumeInformation(
sDrive,
szVolumeNameBuffer,
sizeof(szVolumeNameBuffer),
@@ -117,7 +119,7 @@ void MemoryCardDriverThreaded_Windows::GetUSBStorageDevices( std::vector<UsbStor
continue;
}
// Testing hack: Allow non-removable drive letters to be used if that
// Testing hack: Allow non-removable drive letters to be used if that
// driver letter is specified as a m_sMemoryCardOsMountPoint.
bool bIsSpecifiedMountPoint = false;
@@ -135,7 +137,7 @@ void MemoryCardDriverThreaded_Windows::GetUSBStorageDevices( std::vector<UsbStor
if( GetDriveType(sDrivePath) != DRIVE_REMOVABLE )
{
LOG->Trace( "not DRIVE_REMOVABLE" );
continue;
continue;
}
}
@@ -143,7 +145,7 @@ void MemoryCardDriverThreaded_Windows::GetUSBStorageDevices( std::vector<UsbStor
if( !TestReady(sDrivePath, sVolumeLabel) )
{
LOG->Trace( "not TestReady" );
continue;
continue;
}
vDevicesOut.push_back( UsbStorageDevice() );
@@ -172,7 +174,7 @@ void MemoryCardDriverThreaded_Windows::GetUSBStorageDevices( std::vector<UsbStor
&dwNumberOfFreeClusters,
&dwTotalNumberOfClusters ) )
{
usbd.iVolumeSizeMB = (int)roundf( dwTotalNumberOfClusters * (float)dwSectorsPerCluster * dwBytesPerSector / (1024*1024) );
usbd.iVolumeSizeMB = std::round( dwTotalNumberOfClusters * (float)dwSectorsPerCluster * dwBytesPerSector / (1024*1024) );
}
}
}
@@ -209,7 +211,7 @@ void MemoryCardDriverThreaded_Windows::Unmount( UsbStorageDevice* pDevice )
/*
* (c) 2003-2004 Chris Danford
* All rights reserved.
*
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
@@ -219,7 +221,7 @@ void MemoryCardDriverThreaded_Windows::Unmount( UsbStorageDevice* pDevice )
* copyright notice(s) and this permission notice appear in all copies of
* the Software and that both the above copyright notice(s) and this
* permission notice appear in supporting documentation.
*
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
@@ -4,6 +4,8 @@
#include "RageLog.h"
#include "archutils/Win32/DirectXHelpers.h"
#include <cmath>
//-----------------------------------------------------------------------------
// Define GUID for Texture Renderer
// {71771540-2017-11cf-AE26-0020AFD79767}
@@ -12,7 +14,7 @@ struct __declspec(uuid("{71771540-2017-11cf-ae26-0020afd79767}")) CLSID_TextureR
static HRESULT CBV_ret;
CTextureRenderer::CTextureRenderer():
CBaseVideoRenderer(__uuidof(CLSID_TextureRenderer),
CBaseVideoRenderer(__uuidof(CLSID_TextureRenderer),
NAME("Texture Renderer"), nullptr, &CBV_ret),
m_OneFrameDecoded( "m_OneFrameDecoded", 0 )
{
@@ -47,14 +49,14 @@ HRESULT CTextureRenderer::CheckMediaType(const CMediaType *pmt)
}
// SetMediaType: Graph connection has been made.
// SetMediaType: Graph connection has been made.
HRESULT CTextureRenderer::SetMediaType(const CMediaType *pmt)
{
// Retrive the size of this media type
VIDEOINFO *pviBmp; // Bitmap info header
pviBmp = (VIDEOINFO *)pmt->Format();
m_lVidWidth = pviBmp->bmiHeader.biWidth;
m_lVidHeight = abs(pviBmp->bmiHeader.biHeight);
m_lVidHeight = std::abs(pviBmp->bmiHeader.biHeight);
m_lVidPitch = (m_lVidWidth * 3 + 3) + ~3; // We are forcing RGB24
return S_OK;
@@ -98,7 +100,7 @@ void CTextureRenderer::OnReceiveFirstSample( IMediaSample * pSample )
/*
* (c) 2001-2004 Chris Danford, Glenn Maynard
* All rights reserved.
*
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
@@ -108,7 +110,7 @@ void CTextureRenderer::OnReceiveFirstSample( IMediaSample * pSample )
* copyright notice(s) and this permission notice appear in all copies of
* the Software and that both the above copyright notice(s) and this
* permission notice appear in supporting documentation.
*
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF

Some files were not shown because too many files have changed in this diff Show More