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 19:31:40 +02:00
parent f39ed52dbf
commit b68ca517e6
111 changed files with 1831 additions and 1785 deletions
+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