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
+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