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:
+23
-21
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user