Merge pull request #1837 from teejusb/5_1-new

Integrate C++11 Branch into 5_1-new
This commit is contained in:
dguzek
2019-06-30 17:41:20 -04:00
committed by GitHub
444 changed files with 19506 additions and 21002 deletions
+3 -3
View File
@@ -111,7 +111,7 @@ std::string valueToString( bool value )
std::string valueToQuotedString( const char *value ) std::string valueToQuotedString( const char *value )
{ {
// Not sure how to handle unicode... // Not sure how to handle unicode...
if (strpbrk(value, "\"\\\b\f\n\r\t") == NULL && !containsControlCharacter( value )) if (strpbrk(value, "\"\\\b\f\n\r\t") == nullptr && !containsControlCharacter( value ))
return std::string("\"") + value + "\""; return std::string("\"") + value + "\"";
// We have to walk value and escape any special characters. // We have to walk value and escape any special characters.
// Appending to std::string is not efficient, but this should be rare. // Appending to std::string is not efficient, but this should be rare.
@@ -542,7 +542,7 @@ StyledWriter::normalizeEOL( const std::string &text )
// ////////////////////////////////////////////////////////////////// // //////////////////////////////////////////////////////////////////
StyledStreamWriter::StyledStreamWriter( std::string indentation ) StyledStreamWriter::StyledStreamWriter( std::string indentation )
: document_(NULL) : document_(nullptr)
, rightMargin_( 74 ) , rightMargin_( 74 )
, indentation_( indentation ) , indentation_( indentation )
{ {
@@ -559,7 +559,7 @@ StyledStreamWriter::write( std::ostream &out, const Value &root )
writeValue( root ); writeValue( root );
writeCommentAfterValueOnSameLine( root ); writeCommentAfterValueOnSameLine( root );
*document_ << "\n"; *document_ << "\n";
document_ = NULL; // Forget the stream, for safety. document_ = nullptr; // Forget the stream, for safety.
} }
+21 -22
View File
@@ -5,7 +5,6 @@
#include "RageUtil.h" #include "RageUtil.h"
#include "RageMath.h" #include "RageMath.h"
#include "RageLog.h" #include "RageLog.h"
#include "Foreach.h"
#include "XmlFile.h" #include "XmlFile.h"
#include "LuaBinding.h" #include "LuaBinding.h"
#include "ThemeManager.h" #include "ThemeManager.h"
@@ -87,7 +86,7 @@ void Actor::InitState()
{ {
this->StopTweening(); this->StopTweening();
m_pTempState = NULL; m_pTempState = nullptr;
m_baseRotation = RageVector3( 0, 0, 0 ); m_baseRotation = RageVector3( 0, 0, 0 );
m_baseScale = RageVector3( 1, 1, 1 ); m_baseScale = RageVector3( 1, 1, 1 );
@@ -162,8 +161,8 @@ Actor::Actor()
m_size = RageVector2( 1, 1 ); m_size = RageVector2( 1, 1 );
InitState(); InitState();
m_pParent = NULL; m_pParent = nullptr;
m_FakeParent= NULL; m_FakeParent= nullptr;
m_bFirstUpdate = true; m_bFirstUpdate = true;
m_tween_uses_effect_delta= false; m_tween_uses_effect_delta= false;
} }
@@ -183,8 +182,8 @@ Actor::Actor( const Actor &cpy ):
MessageSubscriber( cpy ) MessageSubscriber( cpy )
{ {
/* Don't copy an Actor in the middle of rendering. */ /* Don't copy an Actor in the middle of rendering. */
ASSERT( cpy.m_pTempState == NULL ); ASSERT( cpy.m_pTempState == nullptr );
m_pTempState = NULL; m_pTempState = nullptr;
#define CPY(x) x = cpy.x #define CPY(x) x = cpy.x
CPY( m_sName ); CPY( m_sName );
@@ -457,7 +456,7 @@ void Actor::Draw()
this->SetInternalGlow(last_glow); this->SetInternalGlow(last_glow);
} }
this->PreDraw(); this->PreDraw();
ASSERT( m_pTempState != NULL ); ASSERT( m_pTempState != nullptr );
if(PartiallyOpaque()) if(PartiallyOpaque())
{ {
this->BeginDraw(); this->BeginDraw();
@@ -475,16 +474,16 @@ void Actor::Draw()
} }
abort_with_end_draw= true; abort_with_end_draw= true;
state->PostDraw(); state->PostDraw();
state->m_pTempState= NULL; state->m_pTempState= nullptr;
} }
if(m_FakeParent) if(m_FakeParent)
{ {
m_FakeParent->EndDraw(); m_FakeParent->EndDraw();
m_FakeParent->PostDraw(); m_FakeParent->PostDraw();
m_FakeParent->m_pTempState= NULL; m_FakeParent->m_pTempState= nullptr;
} }
m_pTempState = NULL; m_pTempState = nullptr;
} }
void Actor::PostDraw() // reset internal diffuse and glow void Actor::PostDraw() // reset internal diffuse and glow
@@ -1364,7 +1363,7 @@ void Actor::RunCommands( const LuaReference& cmds, const LuaReference *pParamTab
this->PushSelf( L ); this->PushSelf( L );
// 2nd parameter // 2nd parameter
if( pParamTable == NULL ) if( pParamTable == nullptr )
lua_pushnil( L ); lua_pushnil( L );
else else
pParamTable->PushSelf( L ); pParamTable->PushSelf( L );
@@ -1533,14 +1532,14 @@ void Actor::AddCommand( const RString &sCmdName, apActorCommands apac, bool warn
bool Actor::HasCommand( const RString &sCmdName ) const bool Actor::HasCommand( const RString &sCmdName ) const
{ {
return GetCommand(sCmdName) != NULL; return GetCommand(sCmdName) != nullptr;
} }
const apActorCommands *Actor::GetCommand( const RString &sCommandName ) const const apActorCommands *Actor::GetCommand( const RString &sCommandName ) const
{ {
map<RString, apActorCommands>::const_iterator it = m_mapNameToCommands.find( sCommandName ); map<RString, apActorCommands>::const_iterator it = m_mapNameToCommands.find( sCommandName );
if( it == m_mapNameToCommands.end() ) if( it == m_mapNameToCommands.end() )
return NULL; return nullptr;
return &it->second; return &it->second;
} }
@@ -1552,7 +1551,7 @@ void Actor::HandleMessage( const Message &msg )
void Actor::PlayCommandNoRecurse( const Message &msg ) void Actor::PlayCommandNoRecurse( const Message &msg )
{ {
const apActorCommands *pCmd = GetCommand( msg.GetName() ); const apActorCommands *pCmd = GetCommand( msg.GetName() );
if(pCmd != NULL && (*pCmd)->IsSet() && !(*pCmd)->IsNil()) if(pCmd != nullptr && (*pCmd)->IsSet() && !(*pCmd)->IsNil())
{ {
RunCommands( *pCmd, &msg.GetParamTable() ); RunCommands( *pCmd, &msg.GetParamTable() );
} }
@@ -1584,7 +1583,7 @@ void Actor::SetParent( Actor *pParent )
Actor::TweenInfo::TweenInfo() Actor::TweenInfo::TweenInfo()
{ {
m_pTween = NULL; m_pTween = nullptr;
} }
Actor::TweenInfo::~TweenInfo() Actor::TweenInfo::~TweenInfo()
@@ -1594,14 +1593,14 @@ Actor::TweenInfo::~TweenInfo()
Actor::TweenInfo::TweenInfo( const TweenInfo &cpy ) Actor::TweenInfo::TweenInfo( const TweenInfo &cpy )
{ {
m_pTween = NULL; m_pTween = nullptr;
*this = cpy; *this = cpy;
} }
Actor::TweenInfo &Actor::TweenInfo::operator=( const TweenInfo &rhs ) Actor::TweenInfo &Actor::TweenInfo::operator=( const TweenInfo &rhs )
{ {
delete m_pTween; delete m_pTween;
m_pTween = (rhs.m_pTween? rhs.m_pTween->Copy():NULL); m_pTween = (rhs.m_pTween? rhs.m_pTween->Copy():nullptr);
m_fTimeLeftInTween = rhs.m_fTimeLeftInTween; m_fTimeLeftInTween = rhs.m_fTimeLeftInTween;
m_fTweenTime = rhs.m_fTweenTime; m_fTweenTime = rhs.m_fTweenTime;
m_sCommandName = rhs.m_sCommandName; m_sCommandName = rhs.m_sCommandName;
@@ -1680,7 +1679,7 @@ public:
COMMON_RETURN_SELF; COMMON_RETURN_SELF;
} }
ITween *pTween = ITween::CreateFromStack( L, 2 ); ITween *pTween = ITween::CreateFromStack( L, 2 );
if(pTween != NULL) if(pTween != nullptr)
{ {
p->BeginTweening(fTime, pTween); p->BeginTweening(fTime, pTween);
} }
@@ -1875,7 +1874,7 @@ public:
static int GetCommand( T* p, lua_State *L ) static int GetCommand( T* p, lua_State *L )
{ {
const apActorCommands *pCommand = p->GetCommand(SArg(1)); const apActorCommands *pCommand = p->GetCommand(SArg(1));
if( pCommand == NULL ) if( pCommand == nullptr )
lua_pushnil( L ); lua_pushnil( L );
else else
(*pCommand)->PushSelf(L); (*pCommand)->PushSelf(L);
@@ -1933,7 +1932,7 @@ public:
static int GetParent( T* p, lua_State *L ) static int GetParent( T* p, lua_State *L )
{ {
Actor *pParent = p->GetParent(); Actor *pParent = p->GetParent();
if( pParent == NULL ) if( pParent == nullptr )
lua_pushnil( L ); lua_pushnil( L );
else else
pParent->PushSelf(L); pParent->PushSelf(L);
@@ -1942,7 +1941,7 @@ public:
static int GetFakeParent(T* p, lua_State *L) static int GetFakeParent(T* p, lua_State *L)
{ {
Actor* fake= p->GetFakeParent(); Actor* fake= p->GetFakeParent();
if(fake == NULL) if(fake == nullptr)
{ {
lua_pushnil(L); lua_pushnil(L);
} }
@@ -1956,7 +1955,7 @@ public:
{ {
if(lua_isnoneornil(L, 1)) if(lua_isnoneornil(L, 1))
{ {
p->SetFakeParent(NULL); p->SetFakeParent(nullptr);
} }
else else
{ {
+4 -4
View File
@@ -602,11 +602,11 @@ public:
void PlayCommandNoRecurse( const Message &msg ); void PlayCommandNoRecurse( const Message &msg );
// Commands by reference // Commands by reference
virtual void RunCommands( const LuaReference& cmds, const LuaReference *pParamTable = NULL ); virtual void RunCommands( const LuaReference& cmds, const LuaReference *pParamTable = nullptr );
void RunCommands( const apActorCommands& cmds, const LuaReference *pParamTable = NULL ) { this->RunCommands( *cmds, pParamTable ); } // convenience void RunCommands( const apActorCommands& cmds, const LuaReference *pParamTable = nullptr ) { this->RunCommands( *cmds, pParamTable ); } // convenience
virtual void RunCommandsRecursively( const LuaReference& cmds, const LuaReference *pParamTable = NULL ) { RunCommands(cmds, pParamTable); } virtual void RunCommandsRecursively( const LuaReference& cmds, const LuaReference *pParamTable = nullptr ) { RunCommands(cmds, pParamTable); }
// If we're a leaf, then execute this command. // If we're a leaf, then execute this command.
virtual void RunCommandsOnLeaves( const LuaReference& cmds, const LuaReference *pParamTable = NULL ) { RunCommands(cmds, pParamTable); } virtual void RunCommandsOnLeaves( const LuaReference& cmds, const LuaReference *pParamTable = nullptr ) { RunCommands(cmds, pParamTable); }
// Messages // Messages
virtual void HandleMessage( const Message &msg ); virtual void HandleMessage( const Message &msg );
+24 -26
View File
@@ -9,7 +9,7 @@
#include "ActorUtil.h" #include "ActorUtil.h"
#include "RageDisplay.h" #include "RageDisplay.h"
#include "ScreenDimensions.h" #include "ScreenDimensions.h"
#include "Foreach.h"
/* Tricky: We need ActorFrames created in Lua to auto delete their children. /* 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
@@ -82,8 +82,7 @@ ActorFrame::ActorFrame( const ActorFrame &cpy ):
void ActorFrame::InitState() void ActorFrame::InitState()
{ {
FOREACH( Actor*, m_SubActors, a ) std::for_each(m_SubActors.begin(), m_SubActors.end(), [](Actor *a) { a->InitState(); });
(*a)->InitState();
Actor::InitState(); Actor::InitState();
} }
@@ -119,7 +118,7 @@ void ActorFrame::LoadChildrenFromNode( const XNode* pNode )
// Load children // Load children
const XNode* pChildren = pNode->GetChild("children"); const XNode* pChildren = pNode->GetChild("children");
bool bArrayOnly = false; bool bArrayOnly = false;
if( pChildren == NULL ) if( pChildren == nullptr )
{ {
bArrayOnly = true; bArrayOnly = true;
pChildren = pNode; pChildren = pNode;
@@ -146,7 +145,7 @@ void ActorFrame::AddChild( Actor *pActor )
Dialog::OK( ssprintf("Actor \"%s\" adds child \"%s\" more than once", GetLineage().c_str(), pActor->GetName().c_str()) ); Dialog::OK( ssprintf("Actor \"%s\" adds child \"%s\" more than once", GetLineage().c_str(), pActor->GetName().c_str()) );
#endif #endif
ASSERT( pActor != NULL ); ASSERT( pActor != nullptr );
ASSERT( (void*)pActor != (void*)0xC0000005 ); ASSERT( (void*)pActor != (void*)0xC0000005 );
m_SubActors.push_back( pActor ); m_SubActors.push_back( pActor );
@@ -162,19 +161,18 @@ void ActorFrame::RemoveChild( Actor *pActor )
void ActorFrame::TransferChildren( ActorFrame *pTo ) void ActorFrame::TransferChildren( ActorFrame *pTo )
{ {
FOREACH( Actor*, m_SubActors, i ) std::for_each(m_SubActors.begin(), m_SubActors.end(), [&](Actor *a) { pTo->AddChild(a); });
pTo->AddChild( *i );
RemoveAllChildren(); RemoveAllChildren();
} }
Actor* ActorFrame::GetChild( const RString &sName ) Actor* ActorFrame::GetChild( const RString &sName )
{ {
FOREACH( Actor*, m_SubActors, a ) for (Actor *a : m_SubActors)
{ {
if( (*a)->GetName() == sName ) if( a->GetName() == sName )
return *a; return a;
} }
return NULL; return nullptr;
} }
void ActorFrame::RemoveAllChildren() void ActorFrame::RemoveAllChildren()
@@ -374,15 +372,15 @@ static void AddToChildTable(lua_State* L, Actor* a)
void ActorFrame::PushChildrenTable( lua_State *L ) void ActorFrame::PushChildrenTable( lua_State *L )
{ {
lua_newtable( L ); // stack: all_actors lua_newtable( L ); // stack: all_actors
FOREACH( Actor*, m_SubActors, a ) for (Actor *a: m_SubActors)
{ {
LuaHelpers::Push( L, (*a)->GetName() ); // stack: all_actors, name LuaHelpers::Push( L, a->GetName() ); // stack: all_actors, name
lua_gettable(L, -2); // stack: all_actors, entry lua_gettable(L, -2); // stack: all_actors, entry
if(lua_isnil(L, -1)) if(lua_isnil(L, -1))
{ {
lua_pop(L, 1); // stack: all_actors lua_pop(L, 1); // stack: all_actors
LuaHelpers::Push( L, (*a)->GetName() ); // stack: all_actors, name LuaHelpers::Push( L, a->GetName() ); // stack: all_actors, name
(*a)->PushSelf( L ); // stack: all_actors, name, actor a->PushSelf( L ); // stack: all_actors, name, actor
lua_rawset( L, -3 ); // stack: all_actors lua_rawset( L, -3 ); // stack: all_actors
} }
else else
@@ -391,14 +389,14 @@ void ActorFrame::PushChildrenTable( lua_State *L )
if(lua_objlen(L, -1) > 0) if(lua_objlen(L, -1) > 0)
{ {
// stack: all_actors, table_entry // stack: all_actors, table_entry
AddToChildTable(L, *a); // stack: all_actors, table_entry AddToChildTable(L, a); // stack: all_actors, table_entry
lua_pop(L, 1); // stack: all_actors lua_pop(L, 1); // stack: all_actors
} }
else else
{ {
// stack: all_actors, old_entry // stack: all_actors, old_entry
CreateChildTable(L, *a); // stack: all_actors, table_entry CreateChildTable(L, a); // stack: all_actors, table_entry
LuaHelpers::Push(L, (*a)->GetName()); // stack: all_actors, table_entry, name LuaHelpers::Push(L, a->GetName()); // stack: all_actors, table_entry, name
lua_insert(L, -2); // stack: all_actors, name, table_entry lua_insert(L, -2); // stack: all_actors, name, table_entry
lua_rawset(L, -3); // stack: all_actors lua_rawset(L, -3); // stack: all_actors
} }
@@ -409,20 +407,20 @@ void ActorFrame::PushChildrenTable( lua_State *L )
void ActorFrame::PushChildTable(lua_State* L, const RString &sName) void ActorFrame::PushChildTable(lua_State* L, const RString &sName)
{ {
int found= 0; int found= 0;
FOREACH(Actor*, m_SubActors, a) for (Actor *a: m_SubActors)
{ {
if((*a)->GetName() == sName) if(a->GetName() == sName)
{ {
switch(found) switch(found)
{ {
case 0: case 0:
(*a)->PushSelf(L); a->PushSelf(L);
break; break;
case 1: case 1:
CreateChildTable(L, *a); CreateChildTable(L, a);
break; break;
default: default:
AddToChildTable(L, *a); AddToChildTable(L, a);
break; break;
} }
++found; ++found;
@@ -437,14 +435,14 @@ void ActorFrame::PushChildTable(lua_State* L, const RString &sName)
void ActorFrame::PlayCommandOnChildren( const RString &sCommandName, const LuaReference *pParamTable ) void ActorFrame::PlayCommandOnChildren( const RString &sCommandName, const LuaReference *pParamTable )
{ {
const apActorCommands *pCmd = GetCommand( sCommandName ); const apActorCommands *pCmd = GetCommand( sCommandName );
if( pCmd != NULL ) if( pCmd != nullptr )
RunCommandsOnChildren( *pCmd, pParamTable ); RunCommandsOnChildren( *pCmd, pParamTable );
} }
void ActorFrame::PlayCommandOnLeaves( const RString &sCommandName, const LuaReference *pParamTable ) void ActorFrame::PlayCommandOnLeaves( const RString &sCommandName, const LuaReference *pParamTable )
{ {
const apActorCommands *pCmd = GetCommand( sCommandName ); const apActorCommands *pCmd = GetCommand( sCommandName );
if( pCmd != NULL ) if( pCmd != nullptr )
RunCommandsOnLeaves( **pCmd, pParamTable ); RunCommandsOnLeaves( **pCmd, pParamTable );
} }
@@ -720,7 +718,7 @@ public:
{ {
// this one is tricky, we need to get an Actor from Lua. // this one is tricky, we need to get an Actor from Lua.
Actor *pActor = ActorUtil::MakeActor( SArg(1) ); Actor *pActor = ActorUtil::MakeActor( SArg(1) );
if ( pActor == NULL ) if ( pActor == nullptr )
{ {
lua_pushboolean( L, 0 ); lua_pushboolean( L, 0 );
return 1; return 1;
+8 -8
View File
@@ -56,13 +56,13 @@ public:
virtual void PushSelf( lua_State *L ); virtual void PushSelf( lua_State *L );
void PushChildrenTable( lua_State *L ); void PushChildrenTable( lua_State *L );
void PushChildTable( lua_State *L, const RString &sName ); void PushChildTable( lua_State *L, const RString &sName );
void PlayCommandOnChildren( const RString &sCommandName, const LuaReference *pParamTable = NULL ); void PlayCommandOnChildren( const RString &sCommandName, const LuaReference *pParamTable = nullptr );
void PlayCommandOnLeaves( const RString &sCommandName, const LuaReference *pParamTable = NULL ); void PlayCommandOnLeaves( const RString &sCommandName, const LuaReference *pParamTable = nullptr );
virtual void RunCommandsRecursively( const LuaReference& cmds, const LuaReference *pParamTable = NULL ); virtual void RunCommandsRecursively( const LuaReference& cmds, const LuaReference *pParamTable = nullptr );
virtual void RunCommandsOnChildren( const LuaReference& cmds, const LuaReference *pParamTable = NULL ); /* but not on self */ virtual void RunCommandsOnChildren( const LuaReference& cmds, const LuaReference *pParamTable = nullptr ); /* but not on self */
void RunCommandsOnChildren( const apActorCommands& cmds, const LuaReference *pParamTable = NULL ) { this->RunCommandsOnChildren( *cmds, pParamTable ); } // convenience void RunCommandsOnChildren( const apActorCommands& cmds, const LuaReference *pParamTable = nullptr ) { this->RunCommandsOnChildren( *cmds, pParamTable ); } // convenience
virtual void RunCommandsOnLeaves( const LuaReference& cmds, const LuaReference *pParamTable = NULL ); /* but not on self */ virtual void RunCommandsOnLeaves( const LuaReference& cmds, const LuaReference *pParamTable = nullptr ); /* but not on self */
virtual void UpdateInternal( float fDeltaTime ); virtual void UpdateInternal( float fDeltaTime );
virtual void BeginDraw(); virtual void BeginDraw();
@@ -92,8 +92,8 @@ public:
virtual float GetTweenTimeLeft() const; virtual float GetTweenTimeLeft() const;
virtual void HandleMessage( const Message &msg ); virtual void HandleMessage( const Message &msg );
virtual void RunCommands( const LuaReference& cmds, const LuaReference *pParamTable = NULL ); virtual void RunCommands( const LuaReference& cmds, const LuaReference *pParamTable = nullptr );
void RunCommands( const apActorCommands& cmds, const LuaReference *pParamTable = NULL ) { this->RunCommands( *cmds, pParamTable ); } // convenience void RunCommands( const apActorCommands& cmds, const LuaReference *pParamTable = nullptr ) { this->RunCommands( *cmds, pParamTable ); } // convenience
protected: protected:
void LoadChildrenFromNode( const XNode* pNode ); void LoadChildrenFromNode( const XNode* pNode );
+4 -4
View File
@@ -18,7 +18,7 @@ ActorFrameTexture::ActorFrameTexture()
++i; ++i;
m_sTextureName = ssprintf( ConvertI64FormatString("ActorFrameTexture %lli"), i ); m_sTextureName = ssprintf( ConvertI64FormatString("ActorFrameTexture %lli"), i );
m_pRenderTarget = NULL; m_pRenderTarget = nullptr;
} }
ActorFrameTexture::ActorFrameTexture( const ActorFrameTexture &cpy ): ActorFrameTexture::ActorFrameTexture( const ActorFrameTexture &cpy ):
@@ -35,7 +35,7 @@ ActorFrameTexture::~ActorFrameTexture()
void ActorFrameTexture::Create() void ActorFrameTexture::Create()
{ {
if( m_pRenderTarget != NULL ) if( m_pRenderTarget != nullptr )
{ {
LuaHelpers::ReportScriptError( "Can't Create an already created ActorFrameTexture" ); LuaHelpers::ReportScriptError( "Can't Create an already created ActorFrameTexture" );
return; return;
@@ -71,7 +71,7 @@ void ActorFrameTexture::Create()
void ActorFrameTexture::DrawPrimitives() void ActorFrameTexture::DrawPrimitives()
{ {
if( m_pRenderTarget == NULL ) if( m_pRenderTarget == nullptr )
return; return;
m_pRenderTarget->BeginRenderingTo( m_bPreserveTexture ); m_pRenderTarget->BeginRenderingTo( m_bPreserveTexture );
@@ -97,7 +97,7 @@ public:
static int GetTexture( T* p, lua_State *L ) static int GetTexture( T* p, lua_State *L )
{ {
RageTexture *pTexture = p->GetTexture(); RageTexture *pTexture = p->GetTexture();
if( pTexture == NULL ) if( pTexture == nullptr )
{ {
lua_pushnil(L); lua_pushnil(L);
} }
+6 -6
View File
@@ -9,7 +9,7 @@
#include "RageTexture.h" #include "RageTexture.h"
#include "RageUtil.h" #include "RageUtil.h"
#include "ActorUtil.h" #include "ActorUtil.h"
#include "Foreach.h"
#include "LuaBinding.h" #include "LuaBinding.h"
#include "LuaManager.h" #include "LuaManager.h"
@@ -35,8 +35,8 @@ ActorMultiTexture::ActorMultiTexture( const ActorMultiTexture &cpy ):
CPY( m_aTextureUnits ); CPY( m_aTextureUnits );
#undef CPY #undef CPY
FOREACH( TextureUnitState, m_aTextureUnits, tex ) for (TextureUnitState &tex : m_aTextureUnits)
tex->m_pTexture = TEXTUREMAN->CopyTexture( tex->m_pTexture ); tex.m_pTexture = TEXTUREMAN->CopyTexture( tex.m_pTexture );
} }
void ActorMultiTexture::SetTextureCoords( const RectF &r ) void ActorMultiTexture::SetTextureCoords( const RectF &r )
@@ -58,14 +58,14 @@ void ActorMultiTexture::SetSizeFromTexture( RageTexture *pTexture )
void ActorMultiTexture::ClearTextures() void ActorMultiTexture::ClearTextures()
{ {
FOREACH( TextureUnitState, m_aTextureUnits, tex ) for (TextureUnitState &tex : m_aTextureUnits)
TEXTUREMAN->UnloadTexture( tex->m_pTexture ); TEXTUREMAN->UnloadTexture( tex.m_pTexture );
m_aTextureUnits.clear(); m_aTextureUnits.clear();
} }
int ActorMultiTexture::AddTexture( RageTexture *pTexture ) int ActorMultiTexture::AddTexture( RageTexture *pTexture )
{ {
if( pTexture == NULL ) if( pTexture == nullptr )
{ {
LOG->Warn( "Can't add nil texture to ActorMultiTexture" ); LOG->Warn( "Can't add nil texture to ActorMultiTexture" );
return m_aTextureUnits.size(); return m_aTextureUnits.size();
+1 -1
View File
@@ -35,7 +35,7 @@ private:
EffectMode m_EffectMode; EffectMode m_EffectMode;
struct TextureUnitState struct TextureUnitState
{ {
TextureUnitState(): m_pTexture(NULL), m_TextureMode(TextureMode_Modulate) {} TextureUnitState(): m_pTexture(nullptr), m_TextureMode(TextureMode_Modulate) {}
RageTexture *m_pTexture; RageTexture *m_pTexture;
TextureMode m_TextureMode; TextureMode m_TextureMode;
}; };
+17 -18
View File
@@ -10,11 +10,12 @@
#include "RageTimer.h" #include "RageTimer.h"
#include "RageUtil.h" #include "RageUtil.h"
#include "ActorUtil.h" #include "ActorUtil.h"
#include "Foreach.h"
#include "LuaBinding.h" #include "LuaBinding.h"
#include "LuaManager.h" #include "LuaManager.h"
#include "LocalizedString.h" #include "LocalizedString.h"
#include <numeric>
const float min_state_delay= 0.0001f; const float min_state_delay= 0.0001f;
static const char *DrawModeNames[] = { static const char *DrawModeNames[] = {
@@ -100,13 +101,13 @@ ActorMultiVertex::ActorMultiVertex( const ActorMultiVertex &cpy ):
CPY(_states); CPY(_states);
#undef CPY #undef CPY
if( cpy._Texture != NULL ) if( cpy._Texture != nullptr )
{ {
_Texture = TEXTUREMAN->CopyTexture( cpy._Texture ); _Texture = TEXTUREMAN->CopyTexture( cpy._Texture );
} }
else else
{ {
_Texture = NULL; _Texture = nullptr;
} }
} }
@@ -137,7 +138,7 @@ void ActorMultiVertex::SetTexture( RageTexture *Texture )
void ActorMultiVertex::LoadFromTexture( RageTextureID ID ) void ActorMultiVertex::LoadFromTexture( RageTextureID ID )
{ {
RageTexture *Texture = NULL; RageTexture *Texture = nullptr;
if( _Texture && _Texture->GetID() == ID ) if( _Texture && _Texture->GetID() == ID )
{ {
return; return;
@@ -148,10 +149,10 @@ void ActorMultiVertex::LoadFromTexture( RageTextureID ID )
void ActorMultiVertex::UnloadTexture() void ActorMultiVertex::UnloadTexture()
{ {
if( _Texture != NULL ) if( _Texture != nullptr )
{ {
TEXTUREMAN->UnloadTexture( _Texture ); TEXTUREMAN->UnloadTexture( _Texture );
_Texture = NULL; _Texture = nullptr;
} }
} }
@@ -409,20 +410,18 @@ void ActorMultiVertex::SetState(size_t i)
void ActorMultiVertex::SetAllStateDelays(float delay) void ActorMultiVertex::SetAllStateDelays(float delay)
{ {
FOREACH(State, _states, s) for (State &s : _states)
{ {
s->delay= delay; s.delay= delay;
} }
} }
float ActorMultiVertex::GetAnimationLengthSeconds() const float ActorMultiVertex::GetAnimationLengthSeconds() const
{ {
float tot= 0.0f; auto calcDelay = [](float total, State const &s) {
FOREACH_CONST(State, _states, s) return total + s.delay;
{ };
tot+= s->delay; return std::accumulate(_states.begin(), _states.end(), 0.f, calcDelay);
}
return tot;
} }
void ActorMultiVertex::SetSecondsIntoAnimation(float seconds) void ActorMultiVertex::SetSecondsIntoAnimation(float seconds)
@@ -958,7 +957,7 @@ public:
static void FillStateFromLua(lua_State *L, ActorMultiVertex::State& state, static void FillStateFromLua(lua_State *L, ActorMultiVertex::State& state,
RageTexture* tex, int index) RageTexture* tex, int index)
{ {
if(tex == NULL) if(tex == nullptr)
{ {
luaL_error(L, "The texture must be set before adding states."); luaL_error(L, "The texture must be set before adding states.");
} }
@@ -1027,7 +1026,7 @@ public:
static int GetStateData(T* p, lua_State *L) static int GetStateData(T* p, lua_State *L)
{ {
RageTexture* tex= p->GetTexture(); RageTexture* tex= p->GetTexture();
if(tex == NULL) if(tex == nullptr)
{ {
luaL_error(L, "The texture must be set before adding states."); luaL_error(L, "The texture must be set before adding states.");
} }
@@ -1065,7 +1064,7 @@ public:
luaL_error(L, "The states must be inside a table."); luaL_error(L, "The states must be inside a table.");
} }
RageTexture* tex= p->GetTexture(); RageTexture* tex= p->GetTexture();
if(tex == NULL) if(tex == nullptr)
{ {
luaL_error(L, "The texture must be set before adding states."); luaL_error(L, "The texture must be set before adding states.");
} }
@@ -1148,7 +1147,7 @@ public:
static int GetTexture(T* p, lua_State *L) static int GetTexture(T* p, lua_State *L)
{ {
RageTexture *texture = p->GetTexture(); RageTexture *texture = p->GetTexture();
if(texture != NULL) if(texture != nullptr)
{ {
texture->PushSelf(L); texture->PushSelf(L);
} }
+4 -4
View File
@@ -6,17 +6,17 @@ REGISTER_ACTOR_CLASS( ActorProxy );
ActorProxy::ActorProxy() ActorProxy::ActorProxy()
{ {
m_pActorTarget = NULL; m_pActorTarget = nullptr;
} }
bool ActorProxy::EarlyAbortDraw() const bool ActorProxy::EarlyAbortDraw() const
{ {
return m_pActorTarget == NULL || Actor::EarlyAbortDraw(); return m_pActorTarget == nullptr || Actor::EarlyAbortDraw();
} }
void ActorProxy::DrawPrimitives() void ActorProxy::DrawPrimitives()
{ {
if( m_pActorTarget != NULL ) if( m_pActorTarget != nullptr )
{ {
bool bVisible = m_pActorTarget->GetVisible(); bool bVisible = m_pActorTarget->GetVisible();
m_pActorTarget->SetVisible( true ); m_pActorTarget->SetVisible( true );
@@ -47,7 +47,7 @@ public:
static int GetTarget( T* p, lua_State *L ) static int GetTarget( T* p, lua_State *L )
{ {
Actor *pTarget = p->GetTarget(); Actor *pTarget = p->GetTarget();
if( pTarget != NULL ) if( pTarget != nullptr )
pTarget->PushSelf( L ); pTarget->PushSelf( L );
else else
lua_pushnil( L ); lua_pushnil( L );
+3 -3
View File
@@ -1,6 +1,6 @@
#include "global.h" #include "global.h"
#include "ActorScroller.h" #include "ActorScroller.h"
#include "Foreach.h"
#include "RageUtil.h" #include "RageUtil.h"
#include "XmlFile.h" #include "XmlFile.h"
#include "arch/Dialog/Dialog.h" #include "arch/Dialog/Dialog.h"
@@ -312,8 +312,8 @@ void ActorScroller::PositionItemsAndDrawPrimitives( bool bDrawPrimitives )
if( m_bDrawByZPosition ) if( m_bDrawByZPosition )
{ {
ActorUtil::SortByZPosition( subs ); ActorUtil::SortByZPosition( subs );
FOREACH( Actor*, subs, a ) for (Actor *a : subs)
(*a)->Draw(); a->Draw();
} }
} }
+16 -18
View File
@@ -10,7 +10,6 @@
#include "XmlFileUtil.h" #include "XmlFileUtil.h"
#include "IniFile.h" #include "IniFile.h"
#include "LuaManager.h" #include "LuaManager.h"
#include "Foreach.h"
#include "Song.h" #include "Song.h"
#include "Course.h" #include "Course.h"
#include "GameState.h" #include "GameState.h"
@@ -19,7 +18,7 @@
// Actor registration // Actor registration
static map<RString,CreateActorFn> *g_pmapRegistrees = NULL; static map<RString,CreateActorFn> *g_pmapRegistrees = nullptr;
static bool IsRegistered( const RString& sClassName ) static bool IsRegistered( const RString& sClassName )
{ {
@@ -28,7 +27,7 @@ static bool IsRegistered( const RString& sClassName )
void ActorUtil::Register( const RString& sClassName, CreateActorFn pfn ) void ActorUtil::Register( const RString& sClassName, CreateActorFn pfn )
{ {
if( g_pmapRegistrees == NULL ) if( g_pmapRegistrees == nullptr )
g_pmapRegistrees = new map<RString,CreateActorFn>; g_pmapRegistrees = new map<RString,CreateActorFn>;
map<RString,CreateActorFn>::iterator iter = g_pmapRegistrees->find( sClassName ); map<RString,CreateActorFn>::iterator iter = g_pmapRegistrees->find( sClassName );
@@ -123,7 +122,7 @@ namespace
// The non-legacy LoadFromNode has already checked the Class and // The non-legacy LoadFromNode has already checked the Class and
// Type attributes. // Type attributes.
if (pActor->GetAttr("Text") != NULL) if (pActor->GetAttr("Text") != nullptr)
return "BitmapText"; return "BitmapText";
RString sFile; RString sFile;
@@ -172,7 +171,7 @@ namespace
Actor *ActorUtil::LoadFromNode( const XNode* _pNode, Actor *pParentActor ) Actor *ActorUtil::LoadFromNode( const XNode* _pNode, Actor *pParentActor )
{ {
ASSERT( _pNode != NULL ); ASSERT( _pNode != nullptr );
XNode node = *_pNode; XNode node = *_pNode;
@@ -182,7 +181,7 @@ Actor *ActorUtil::LoadFromNode( const XNode* _pNode, Actor *pParentActor )
{ {
bool bCond; bool bCond;
if( node.GetAttrValue("Condition", bCond) && !bCond ) if( node.GetAttrValue("Condition", bCond) && !bCond )
return NULL; return nullptr;
} }
RString sClass; RString sClass;
@@ -190,7 +189,7 @@ Actor *ActorUtil::LoadFromNode( const XNode* _pNode, Actor *pParentActor )
if( !bHasClass ) if( !bHasClass )
bHasClass = node.GetAttrValue( "Type", sClass ); bHasClass = node.GetAttrValue( "Type", sClass );
bool bLegacy = (node.GetAttr( "_LegacyXml" ) != NULL); bool bLegacy = (node.GetAttr( "_LegacyXml" ) != nullptr);
if( !bHasClass && bLegacy ) if( !bHasClass && bLegacy )
sClass = GetLegacyActorClass( &node ); sClass = GetLegacyActorClass( &node );
@@ -209,8 +208,8 @@ Actor *ActorUtil::LoadFromNode( const XNode* _pNode, Actor *pParentActor )
if (ResolvePath(sPath, GetWhere(&node))) if (ResolvePath(sPath, GetWhere(&node)))
{ {
Actor *pNewActor = MakeActor(sPath, pParentActor); Actor *pNewActor = MakeActor(sPath, pParentActor);
if (pNewActor == NULL) if (pNewActor == nullptr)
return NULL; return nullptr;
if (pParentActor) if (pParentActor)
pNewActor->SetParent(pParentActor); pNewActor->SetParent(pParentActor);
pNewActor->LoadFromNode(&node); pNewActor->LoadFromNode(&node);
@@ -241,7 +240,7 @@ namespace
{ {
RString sScript; RString sScript;
if( !GetFileContents(sFile, sScript) ) if( !GetFileContents(sFile, sScript) )
return NULL; return nullptr;
Lua *L = LUA->Get(); Lua *L = LUA->Get();
@@ -251,10 +250,10 @@ namespace
LUA->Release( L ); LUA->Release( L );
sError = ssprintf( "Lua runtime error: %s", sError.c_str() ); sError = ssprintf( "Lua runtime error: %s", sError.c_str() );
LuaHelpers::ReportScriptError(sError); LuaHelpers::ReportScriptError(sError);
return NULL; return nullptr;
} }
XNode *pRet = NULL; XNode *pRet = nullptr;
if( ActorUtil::LoadTableFromStackShowErrors(L) ) if( ActorUtil::LoadTableFromStackShowErrors(L) )
pRet = XmlFileUtil::XNodeFromTable( L ); pRet = XmlFileUtil::XNodeFromTable( L );
@@ -295,7 +294,7 @@ bool ActorUtil::LoadTableFromStackShowErrors( Lua *L )
return true; return true;
} }
// NOTE: This function can return NULL if the actor should not be displayed. // NOTE: This function can return nullptr if the actor should not be displayed.
// Callers should be aware of this and handle it appropriately. // Callers should be aware of this and handle it appropriately.
Actor* ActorUtil::MakeActor( const RString &sPath_, Actor *pParentActor ) Actor* ActorUtil::MakeActor( const RString &sPath_, Actor *pParentActor )
{ {
@@ -306,8 +305,8 @@ Actor* ActorUtil::MakeActor( const RString &sPath_, Actor *pParentActor )
{ {
case FT_Lua: case FT_Lua:
{ {
auto_ptr<XNode> pNode( LoadXNodeFromLuaShowErrors(sPath) ); unique_ptr<XNode> pNode( LoadXNodeFromLuaShowErrors(sPath) );
if( pNode.get() == NULL ) if( pNode.get() == nullptr )
{ {
// XNode will warn about the error // XNode will warn about the error
return new Actor; return new Actor;
@@ -475,9 +474,8 @@ void ActorUtil::LoadAllCommandsFromName( Actor& actor, const RString &sMetricsGr
set<RString> vsValueNames; set<RString> vsValueNames;
THEME->GetMetricsThatBeginWith( sMetricsGroup, sName, vsValueNames ); THEME->GetMetricsThatBeginWith( sMetricsGroup, sName, vsValueNames );
FOREACHS_CONST( RString, vsValueNames, v ) for (RString const & sv : vsValueNames)
{ {
const RString &sv = *v;
static const RString sEnding = "Command"; static const RString sEnding = "Command";
if( EndsWith(sv,sEnding) ) if( EndsWith(sv,sEnding) )
{ {
@@ -680,7 +678,7 @@ namespace
LIST_METHOD( LoadAllCommands ), LIST_METHOD( LoadAllCommands ),
LIST_METHOD( LoadAllCommandsFromName ), LIST_METHOD( LoadAllCommandsFromName ),
LIST_METHOD( LoadAllCommandsAndSetXY ), LIST_METHOD( LoadAllCommandsAndSetXY ),
{ NULL, NULL } { nullptr, nullptr }
}; };
} }
+2 -2
View File
@@ -115,8 +115,8 @@ namespace ActorUtil
inline void LoadAllCommandsAndSetXYAndOnCommand( Actor* pActor, const RString &sMetricsGroup ) { if(pActor) LoadAllCommandsAndSetXYAndOnCommand( *pActor, sMetricsGroup ); } inline void LoadAllCommandsAndSetXYAndOnCommand( Actor* pActor, const RString &sMetricsGroup ) { if(pActor) LoadAllCommandsAndSetXYAndOnCommand( *pActor, sMetricsGroup ); }
// Return a Sprite, BitmapText, or Model depending on the file type // Return a Sprite, BitmapText, or Model depending on the file type
Actor* LoadFromNode( const XNode* pNode, Actor *pParentActor = NULL ); Actor* LoadFromNode( const XNode* pNode, Actor *pParentActor = nullptr );
Actor* MakeActor( const RString &sPath, Actor *pParentActor = NULL ); Actor* MakeActor( const RString &sPath, Actor *pParentActor = nullptr );
RString GetSourcePath( const XNode *pNode ); RString GetSourcePath( const XNode *pNode );
RString GetWhere( const XNode *pNode ); RString GetWhere( const XNode *pNode );
bool GetAttrPath( const XNode *pNode, const RString &sName, RString &sOut, bool optional= false ); bool GetAttrPath( const XNode *pNode, const RString &sName, RString &sOut, bool optional= false );
+8 -8
View File
@@ -41,7 +41,7 @@
#include "LocalizedString.h" #include "LocalizedString.h"
#include "PrefsManager.h" #include "PrefsManager.h"
#include "ScreenManager.h" #include "ScreenManager.h"
#include "Foreach.h"
vector<TimingData> AdjustSync::s_vpTimingDataOriginal; vector<TimingData> AdjustSync::s_vpTimingDataOriginal;
float AdjustSync::s_fGlobalOffsetSecondsOriginal = 0.0f; float AdjustSync::s_fGlobalOffsetSecondsOriginal = 0.0f;
@@ -61,9 +61,9 @@ void AdjustSync::ResetOriginalSyncData()
{ {
s_vpTimingDataOriginal.push_back(GAMESTATE->m_pCurSong->m_SongTiming); s_vpTimingDataOriginal.push_back(GAMESTATE->m_pCurSong->m_SongTiming);
const vector<Steps *>& vpSteps = GAMESTATE->m_pCurSong->GetAllSteps(); const vector<Steps *>& vpSteps = GAMESTATE->m_pCurSong->GetAllSteps();
FOREACH( Steps*, const_cast<vector<Steps *>&>(vpSteps), s ) for (Steps const *s : vpSteps)
{ {
s_vpTimingDataOriginal.push_back((*s)->m_Timing); s_vpTimingDataOriginal.push_back(s->m_Timing);
} }
} }
else else
@@ -128,9 +128,9 @@ void AdjustSync::RevertSyncChanges()
unsigned location = 1; unsigned location = 1;
const vector<Steps *>& vpSteps = GAMESTATE->m_pCurSong->GetAllSteps(); const vector<Steps *>& vpSteps = GAMESTATE->m_pCurSong->GetAllSteps();
FOREACH( Steps*, const_cast<vector<Steps *>&>(vpSteps), s ) for (Steps *s : vpSteps)
{ {
(*s)->m_Timing = s_vpTimingDataOriginal[location]; s->m_Timing = s_vpTimingDataOriginal[location];
location++; location++;
} }
@@ -199,13 +199,13 @@ void AdjustSync::AutosyncOffset()
{ {
GAMESTATE->m_pCurSong->m_SongTiming.m_fBeat0OffsetInSeconds += mean; GAMESTATE->m_pCurSong->m_SongTiming.m_fBeat0OffsetInSeconds += mean;
const vector<Steps *>& vpSteps = GAMESTATE->m_pCurSong->GetAllSteps(); const vector<Steps *>& vpSteps = GAMESTATE->m_pCurSong->GetAllSteps();
FOREACH( Steps*, const_cast<vector<Steps *>&>(vpSteps), s ) for (Steps *s : vpSteps)
{ {
// Empty TimingData means it's inherited // Empty TimingData means it's inherited
// from the song and is already changed. // from the song and is already changed.
if( (*s)->m_Timing.empty() ) if( s->m_Timing.empty() )
continue; continue;
(*s)->m_Timing.m_fBeat0OffsetInSeconds += mean; s->m_Timing.m_fBeat0OffsetInSeconds += mean;
} }
break; break;
} }
+3 -3
View File
@@ -5,7 +5,7 @@
#include "RageFile.h" #include "RageFile.h"
#include <cstring> #include <cstring>
AnnouncerManager* ANNOUNCER = NULL; // global and accessible from anywhere in our program AnnouncerManager* ANNOUNCER = nullptr; // global and accessible from anywhere in our program
const RString EMPTY_ANNOUNCER_NAME = "Empty"; const RString EMPTY_ANNOUNCER_NAME = "Empty";
@@ -101,7 +101,7 @@ static const char *aliases[][2] = {
{ "gameplay combo 900", "gameplay 900 combo" }, { "gameplay combo 900", "gameplay 900 combo" },
{ "gameplay combo 1000", "gameplay 1000 combo" }, { "gameplay combo 1000", "gameplay 1000 combo" },
{ NULL, NULL } { nullptr, nullptr }
}; };
/* Find an announcer directory with sounds in it. First search sFolderName, /* Find an announcer directory with sounds in it. First search sFolderName,
@@ -120,7 +120,7 @@ RString AnnouncerManager::GetPathTo( RString sAnnouncerName, RString sFolderName
/* Search for the announcer folder in the list of aliases. */ /* Search for the announcer folder in the list of aliases. */
int i; int i;
for(i = 0; aliases[i][0] != NULL; ++i) for(i = 0; aliases[i][0] != nullptr; ++i)
{ {
if(!sFolderName.EqualsNoCase(aliases[i][0])) if(!sFolderName.EqualsNoCase(aliases[i][0]))
continue; /* no match */ continue; /* no match */
+2 -2
View File
@@ -78,7 +78,7 @@ static ThemeMetric<float> BEAT_Z_PI_HEIGHT( "ArrowEffects", "BeatZPIHeight" );
static ThemeMetric<float> TINY_PERCENT_BASE( "ArrowEffects", "TinyPercentBase" ); static ThemeMetric<float> TINY_PERCENT_BASE( "ArrowEffects", "TinyPercentBase" );
static ThemeMetric<float> TINY_PERCENT_GATE( "ArrowEffects", "TinyPercentGate" ); static ThemeMetric<float> TINY_PERCENT_GATE( "ArrowEffects", "TinyPercentGate" );
static const PlayerOptions* curr_options= NULL; static const PlayerOptions* curr_options= nullptr;
float ArrowGetPercentVisible(float fYPosWithoutReverse, int iCol, float fYOffset); float ArrowGetPercentVisible(float fYPosWithoutReverse, int iCol, float fYOffset);
@@ -1653,7 +1653,7 @@ namespace
LIST_METHOD( NeedZBuffer ), LIST_METHOD( NeedZBuffer ),
LIST_METHOD( GetZoom ), LIST_METHOD( GetZoom ),
LIST_METHOD( GetFrameWidthScale ), LIST_METHOD( GetFrameWidthScale ),
{ NULL, NULL } { nullptr, nullptr }
}; };
} }
+11 -16
View File
@@ -3,13 +3,13 @@
#include "GameState.h" #include "GameState.h"
#include "RageUtil.h" #include "RageUtil.h"
#include "Song.h" #include "Song.h"
#include "Foreach.h"
#include "PlayerOptions.h" #include "PlayerOptions.h"
#include "PlayerState.h" #include "PlayerState.h"
void Attack::GetAttackBeats( const Song *pSong, float &fStartBeat, float &fEndBeat ) const void Attack::GetAttackBeats( const Song *pSong, float &fStartBeat, float &fEndBeat ) const
{ {
ASSERT( pSong != NULL ); ASSERT( pSong != nullptr );
ASSERT_M( fStartSecond >= 0, ssprintf("StartSecond: %f",fStartSecond) ); ASSERT_M( fStartSecond >= 0, ssprintf("StartSecond: %f",fStartSecond) );
const TimingData &timing = pSong->m_SongTiming; const TimingData &timing = pSong->m_SongTiming;
@@ -22,7 +22,7 @@ void Attack::GetAttackBeats( const Song *pSong, float &fStartBeat, float &fEndBe
* prevent popping when the attack has note modifers. */ * prevent popping when the attack has note modifers. */
void Attack::GetRealtimeAttackBeats( const Song *pSong, const PlayerState* pPlayerState, float &fStartBeat, float &fEndBeat ) const void Attack::GetRealtimeAttackBeats( const Song *pSong, const PlayerState* pPlayerState, float &fStartBeat, float &fEndBeat ) const
{ {
ASSERT( pSong != NULL ); ASSERT( pSong != nullptr );
if( fStartSecond >= 0 ) if( fStartSecond >= 0 )
{ {
@@ -30,7 +30,7 @@ void Attack::GetRealtimeAttackBeats( const Song *pSong, const PlayerState* pPlay
return; return;
} }
ASSERT( pPlayerState != NULL ); ASSERT( pPlayerState != nullptr );
/* If reasonable, push the attack forward 8 beats so that notes on screen don't change suddenly. */ /* If reasonable, push the attack forward 8 beats so that notes on screen don't change suddenly. */
fStartBeat = min( GAMESTATE->m_Position.m_fSongBeat+8, pPlayerState->m_fLastDrawnBeat ); fStartBeat = min( GAMESTATE->m_Position.m_fSongBeat+8, pPlayerState->m_fLastDrawnBeat );
@@ -91,32 +91,27 @@ int Attack::GetNumAttacks() const
bool AttackArray::ContainsTransformOrTurn() const bool AttackArray::ContainsTransformOrTurn() const
{ {
FOREACH_CONST( Attack, *this, a ) return std::any_of((*this).begin(), (*this).end(), [](Attack const &a) { return a.ContainsTransformOrTurn(); });
{
if( a->ContainsTransformOrTurn() )
return true;
}
return false;
} }
vector<RString> AttackArray::ToVectorString() const vector<RString> AttackArray::ToVectorString() const
{ {
vector<RString> ret; vector<RString> ret;
FOREACH_CONST( Attack, *this, a ) for (Attack const &a : *this)
{ {
ret.push_back(ssprintf("TIME=%f:LEN=%f:MODS=%s", ret.push_back(ssprintf("TIME=%f:LEN=%f:MODS=%s",
a->fStartSecond, a.fStartSecond,
a->fSecsRemaining, a.fSecsRemaining,
a->sModifiers.c_str())); a.sModifiers.c_str()));
} }
return ret; return ret;
} }
void AttackArray::UpdateStartTimes(float delta) void AttackArray::UpdateStartTimes(float delta)
{ {
FOREACH(Attack, *this, a) for (Attack &a : *this)
{ {
a->fStartSecond += delta; a.fStartSecond += delta;
} }
} }
+1 -1
View File
@@ -46,7 +46,7 @@ void AttackDisplay::Init( const PlayerState* pPlayerState )
for( int al=0; al<NUM_ATTACK_LEVELS; al++ ) for( int al=0; al<NUM_ATTACK_LEVELS; al++ )
{ {
const Character *ch = GAMESTATE->m_pCurCharacters[pn]; const Character *ch = GAMESTATE->m_pCurCharacters[pn];
ASSERT( ch != NULL ); ASSERT( ch != nullptr );
const RString* asAttacks = ch->m_sAttacks[al]; const RString* asAttacks = ch->m_sAttacks[al];
for( int att = 0; att < NUM_ATTACKS_PER_LEVEL; ++att ) for( int att = 0; att < NUM_ATTACKS_PER_LEVEL; ++att )
attacks.insert( asAttacks[att] ); attacks.insert( asAttacks[att] );
+8 -8
View File
@@ -6,17 +6,17 @@
void AutoActor::Unload() void AutoActor::Unload()
{ {
if(m_pActor != NULL) if(m_pActor != nullptr)
{ {
delete m_pActor; delete m_pActor;
} }
m_pActor=NULL; m_pActor=nullptr;
} }
AutoActor::AutoActor( const AutoActor &cpy ) AutoActor::AutoActor( const AutoActor &cpy )
{ {
if( cpy.m_pActor == NULL ) if( cpy.m_pActor == nullptr )
m_pActor = NULL; m_pActor = nullptr;
else else
m_pActor = cpy.m_pActor->Copy(); m_pActor = cpy.m_pActor->Copy();
} }
@@ -25,8 +25,8 @@ AutoActor &AutoActor::operator=( const AutoActor &cpy )
{ {
Unload(); Unload();
if( cpy.m_pActor == NULL ) if( cpy.m_pActor == nullptr )
m_pActor = NULL; m_pActor = nullptr;
else else
m_pActor = cpy.m_pActor->Copy(); m_pActor = cpy.m_pActor->Copy();
return *this; return *this;
@@ -43,8 +43,8 @@ void AutoActor::Load( const RString &sPath )
Unload(); Unload();
m_pActor = ActorUtil::MakeActor( sPath ); m_pActor = ActorUtil::MakeActor( sPath );
// If a Condition is false, MakeActor will return NULL. // If a Condition is false, MakeActor will return nullptr.
if( m_pActor == NULL ) if( m_pActor == nullptr )
m_pActor = new Actor; m_pActor = new Actor;
} }
+2 -2
View File
@@ -12,7 +12,7 @@ class XNode;
class AutoActor class AutoActor
{ {
public: public:
AutoActor(): m_pActor(NULL) {} AutoActor(): m_pActor(nullptr) {}
~AutoActor() { Unload(); } ~AutoActor() { Unload(); }
AutoActor( const AutoActor &cpy ); AutoActor( const AutoActor &cpy );
AutoActor &operator =( const AutoActor &cpy ); AutoActor &operator =( const AutoActor &cpy );
@@ -24,7 +24,7 @@ public:
/** /**
* @brief Determine if this actor is presently loaded. * @brief Determine if this actor is presently loaded.
* @return true if it is loaded, or false otherwise. */ * @return true if it is loaded, or false otherwise. */
bool IsLoaded() const { return m_pActor != NULL; } bool IsLoaded() const { return m_pActor != nullptr; }
void Load( Actor *pActor ); // transfer pointer void Load( Actor *pActor ); // transfer pointer
void Load( const RString &sPath ); void Load( const RString &sPath );
void LoadB( const RString &sMetricsGroup, const RString &sElement ); // load a background and set up LuaThreadVariables for recursive loading void LoadB( const RString &sMetricsGroup, const RString &sElement ); // load a background and set up LuaThreadVariables for recursive loading
+13 -13
View File
@@ -30,7 +30,7 @@
#include "RageSoundManager.h" #include "RageSoundManager.h"
#include "RageLog.h" #include "RageLog.h"
#include "RageSoundReader_FileReader.h" #include "RageSoundReader_FileReader.h"
#include "Foreach.h"
void AutoKeysounds::Load( PlayerNumber pn, const NoteData& ndAutoKeysoundsOnly ) void AutoKeysounds::Load( PlayerNumber pn, const NoteData& ndAutoKeysoundsOnly )
{ {
@@ -107,9 +107,9 @@ void AutoKeysounds::LoadTracks( const Song *pSong, RageSoundReader *&pShared, Ra
// two-track sound. // two-track sound.
//bool bTwoPlayers = GAMESTATE->GetNumPlayersEnabled() == 2; //bool bTwoPlayers = GAMESTATE->GetNumPlayersEnabled() == 2;
pPlayer1 = NULL; pPlayer1 = nullptr;
pPlayer2 = NULL; pPlayer2 = nullptr;
pShared = NULL; pShared = nullptr;
vector<RString> vsMusicFile; vector<RString> vsMusicFile;
const RString sMusicPath = GAMESTATE->m_pCurSteps[GAMESTATE->GetMasterPlayerNumber()]->GetMusicPath(); const RString sMusicPath = GAMESTATE->m_pCurSteps[GAMESTATE->GetMasterPlayerNumber()]->GetMusicPath();
@@ -127,10 +127,10 @@ void AutoKeysounds::LoadTracks( const Song *pSong, RageSoundReader *&pShared, Ra
vector<RageSoundReader *> vpSounds; vector<RageSoundReader *> vpSounds;
FOREACH( RString, vsMusicFile, s ) for (RString const &s : vsMusicFile)
{ {
RString sError; RString sError;
RageSoundReader *pSongReader = RageSoundReader_FileReader::OpenFile( *s, sError ); RageSoundReader *pSongReader = RageSoundReader_FileReader::OpenFile( s, sError );
vpSounds.push_back( pSongReader ); vpSounds.push_back( pSongReader );
} }
@@ -147,8 +147,8 @@ void AutoKeysounds::LoadTracks( const Song *pSong, RageSoundReader *&pShared, Ra
{ {
RageSoundReader_Merge *pMerge = new RageSoundReader_Merge; RageSoundReader_Merge *pMerge = new RageSoundReader_Merge;
FOREACH( RageSoundReader *, vpSounds, so ) for (RageSoundReader *so : vpSounds)
pMerge->AddSound( *so ); pMerge->AddSound( so );
pMerge->Finish( SOUNDMAN->GetDriverSampleRate() ); pMerge->Finish( SOUNDMAN->GetDriverSampleRate() );
RageSoundReader *pSongReader = pMerge; RageSoundReader *pSongReader = pMerge;
@@ -263,14 +263,14 @@ void AutoKeysounds::FinishLoading()
delete pChain; delete pChain;
} }
} }
ASSERT_M( m_pSharedSound != NULL, ssprintf("No keysounds were loaded for the song %s!", pSong->m_sMainTitle.c_str() )); ASSERT_M( m_pSharedSound != nullptr, ssprintf("No keysounds were loaded for the song %s!", pSong->m_sMainTitle.c_str() ));
m_pSharedSound = new RageSoundReader_PitchChange( m_pSharedSound ); m_pSharedSound = new RageSoundReader_PitchChange( m_pSharedSound );
m_pSharedSound = new RageSoundReader_PostBuffering( m_pSharedSound ); m_pSharedSound = new RageSoundReader_PostBuffering( m_pSharedSound );
m_pSharedSound = new RageSoundReader_Pan( m_pSharedSound ); m_pSharedSound = new RageSoundReader_Pan( m_pSharedSound );
apSounds.push_back( m_pSharedSound ); apSounds.push_back( m_pSharedSound );
if( m_pPlayerSounds[0] != NULL ) if( m_pPlayerSounds[0] != nullptr )
{ {
m_pPlayerSounds[0] = new RageSoundReader_PitchChange( m_pPlayerSounds[0] ); m_pPlayerSounds[0] = new RageSoundReader_PitchChange( m_pPlayerSounds[0] );
m_pPlayerSounds[0] = new RageSoundReader_PostBuffering( m_pPlayerSounds[0] ); m_pPlayerSounds[0] = new RageSoundReader_PostBuffering( m_pPlayerSounds[0] );
@@ -278,7 +278,7 @@ void AutoKeysounds::FinishLoading()
apSounds.push_back( m_pPlayerSounds[0] ); apSounds.push_back( m_pPlayerSounds[0] );
} }
if( m_pPlayerSounds[1] != NULL ) if( m_pPlayerSounds[1] != nullptr )
{ {
m_pPlayerSounds[1] = new RageSoundReader_PitchChange( m_pPlayerSounds[1] ); m_pPlayerSounds[1] = new RageSoundReader_PitchChange( m_pPlayerSounds[1] );
m_pPlayerSounds[1] = new RageSoundReader_PostBuffering( m_pPlayerSounds[1] ); m_pPlayerSounds[1] = new RageSoundReader_PostBuffering( m_pPlayerSounds[1] );
@@ -293,8 +293,8 @@ void AutoKeysounds::FinishLoading()
{ {
RageSoundReader_Merge *pMerge = new RageSoundReader_Merge; RageSoundReader_Merge *pMerge = new RageSoundReader_Merge;
FOREACH( RageSoundReader *, apSounds, ps ) for (RageSoundReader *ps : apSounds)
pMerge->AddSound( *ps ); pMerge->AddSound( ps );
pMerge->Finish( SOUNDMAN->GetDriverSampleRate() ); pMerge->Finish( SOUNDMAN->GetDriverSampleRate() );
+1 -1
View File
@@ -18,7 +18,7 @@ public:
void FinishLoading(); void FinishLoading();
RageSound *GetSound() { return &m_sSound; } RageSound *GetSound() { return &m_sSound; }
RageSoundReader *GetSharedSound() { return m_pSharedSound; } RageSoundReader *GetSharedSound() { return m_pSharedSound; }
RageSoundReader *GetPlayerSound( PlayerNumber pn ) { if( pn == PLAYER_INVALID ) return NULL; return m_pPlayerSounds[pn]; } RageSoundReader *GetPlayerSound( PlayerNumber pn ) { if( pn == PLAYER_INVALID ) return nullptr; return m_pPlayerSounds[pn]; }
protected: protected:
void LoadAutoplaySoundsInto( RageSoundReader_Chain *pChain ); void LoadAutoplaySoundsInto( RageSoundReader_Chain *pChain );
+4 -5
View File
@@ -4,7 +4,7 @@
#include "BGAnimationLayer.h" #include "BGAnimationLayer.h"
#include "RageUtil.h" #include "RageUtil.h"
#include "ActorUtil.h" #include "ActorUtil.h"
#include "Foreach.h"
#include "LuaManager.h" #include "LuaManager.h"
#include "PrefsManager.h" #include "PrefsManager.h"
@@ -46,11 +46,10 @@ void BGAnimation::AddLayersFromAniDir( const RString &_sAniDir, const XNode *pNo
sort( vsLayerNames.begin(), vsLayerNames.end(), CompareLayerNames ); sort( vsLayerNames.begin(), vsLayerNames.end(), CompareLayerNames );
FOREACH_CONST( RString, vsLayerNames, s ) for (RString const &sLayer : vsLayerNames)
{ {
const RString &sLayer = *s;
const XNode* pKey = pNode->GetChild( sLayer ); const XNode* pKey = pNode->GetChild( sLayer );
ASSERT( pKey != NULL ); ASSERT( pKey != nullptr );
RString sImportDir; RString sImportDir;
if( pKey->GetAttrValue("Import", sImportDir) ) if( pKey->GetAttrValue("Import", sImportDir) )
@@ -113,7 +112,7 @@ void BGAnimation::LoadFromAniDir( const RString &_sAniDir )
XNode* pBGAnimation = ini.GetChild( "BGAnimation" ); XNode* pBGAnimation = ini.GetChild( "BGAnimation" );
XNode dummy( "BGAnimation" ); XNode dummy( "BGAnimation" );
if( pBGAnimation == NULL ) if( pBGAnimation == nullptr )
pBGAnimation = &dummy; pBGAnimation = &dummy;
LoadFromNode( pBGAnimation ); LoadFromNode( pBGAnimation );
+5 -5
View File
@@ -402,16 +402,16 @@ void BGAnimationLayer::LoadFromNode( const XNode* pNode )
{ {
m_Type = TYPE_TILES; m_Type = TYPE_TILES;
} }
else if( StringToInt(type) == 1 ) else if( std::stoi(type) == 1 )
{ {
m_Type = TYPE_SPRITE; m_Type = TYPE_SPRITE;
bStretch = true; bStretch = true;
} }
else if( StringToInt(type) == 2 ) else if( std::stoi(type) == 2 )
{ {
m_Type = TYPE_PARTICLES; m_Type = TYPE_PARTICLES;
} }
else if( StringToInt(type) == 3 ) else if( std::stoi(type) == 3 )
{ {
m_Type = TYPE_TILES; m_Type = TYPE_TILES;
} }
@@ -482,7 +482,7 @@ void BGAnimationLayer::LoadFromNode( const XNode* pNode )
for( int i=0; i<iNumParticles; i++ ) for( int i=0; i<iNumParticles; i++ )
{ {
Actor* pActor = ActorUtil::MakeActor( sFile, this ); Actor* pActor = ActorUtil::MakeActor( sFile, this );
if( pActor == NULL ) if( pActor == nullptr )
continue; continue;
this->AddChild( pActor ); this->AddChild( pActor );
pActor->SetXY( randomf(float(FullScreenRectF.left),float(FullScreenRectF.right)), pActor->SetXY( randomf(float(FullScreenRectF.left),float(FullScreenRectF.right)),
@@ -520,7 +520,7 @@ void BGAnimationLayer::LoadFromNode( const XNode* pNode )
for( unsigned i=0; i<NumSprites; i++ ) for( unsigned i=0; i<NumSprites; i++ )
{ {
Actor* pSprite = ActorUtil::MakeActor( sFile, this ); Actor* pSprite = ActorUtil::MakeActor( sFile, this );
if( pSprite == NULL ) if( pSprite == nullptr )
continue; continue;
this->AddChild( pSprite ); this->AddChild( pSprite );
pSprite->SetTextureWrapping( true ); // gets rid of some "cracks" pSprite->SetTextureWrapping( true ); // gets rid of some "cracks"
+6 -6
View File
@@ -179,7 +179,7 @@ void BPMDisplay::NoBPM()
void BPMDisplay::SetBpmFromSong( const Song* pSong ) void BPMDisplay::SetBpmFromSong( const Song* pSong )
{ {
ASSERT( pSong != NULL ); ASSERT( pSong != nullptr );
switch( pSong->m_DisplayBPMType ) switch( pSong->m_DisplayBPMType )
{ {
case DISPLAY_BPM_ACTUAL: case DISPLAY_BPM_ACTUAL:
@@ -201,7 +201,7 @@ void BPMDisplay::SetBpmFromSong( const Song* pSong )
void BPMDisplay::SetBpmFromSteps( const Steps* pSteps ) void BPMDisplay::SetBpmFromSteps( const Steps* pSteps )
{ {
ASSERT( pSteps != NULL ); ASSERT( pSteps != nullptr );
DisplayBpms bpms; DisplayBpms bpms;
float fMinBPM, fMaxBPM; float fMinBPM, fMaxBPM;
pSteps->GetTimingData()->GetActualBPM( fMinBPM, fMaxBPM ); pSteps->GetTimingData()->GetActualBPM( fMinBPM, fMaxBPM );
@@ -212,13 +212,13 @@ void BPMDisplay::SetBpmFromSteps( const Steps* pSteps )
void BPMDisplay::SetBpmFromCourse( const Course* pCourse ) void BPMDisplay::SetBpmFromCourse( const Course* pCourse )
{ {
ASSERT( pCourse != NULL ); ASSERT( pCourse != nullptr );
ASSERT( GAMESTATE->GetCurrentStyle(PLAYER_INVALID) != NULL ); ASSERT( GAMESTATE->GetCurrentStyle(PLAYER_INVALID) != nullptr );
StepsType st = GAMESTATE->GetCurrentStyle(PLAYER_INVALID)->m_StepsType; StepsType st = GAMESTATE->GetCurrentStyle(PLAYER_INVALID)->m_StepsType;
Trail *pTrail = pCourse->GetTrail( st ); Trail *pTrail = pCourse->GetTrail( st );
// GetTranslitFullTitle because "Crashinfo.txt is garbled because of the ANSI output as usual." -f // GetTranslitFullTitle because "Crashinfo.txt is garbled because of the ANSI output as usual." -f
ASSERT_M( pTrail != NULL, ssprintf("Course '%s' has no trail for StepsType '%s'", pCourse->GetTranslitFullTitle().c_str(), StringConversion::ToString(st).c_str() ) ); ASSERT_M( pTrail != nullptr, ssprintf("Course '%s' has no trail for StepsType '%s'", pCourse->GetTranslitFullTitle().c_str(), StringConversion::ToString(st).c_str() ) );
m_fCycleTime = (float)COURSE_CYCLE_SPEED; m_fCycleTime = (float)COURSE_CYCLE_SPEED;
@@ -259,7 +259,7 @@ void BPMDisplay::SetFromGameState()
} }
if( GAMESTATE->m_pCurCourse.Get() ) if( GAMESTATE->m_pCurCourse.Get() )
{ {
if( GAMESTATE->GetCurrentStyle(PLAYER_INVALID) == NULL ) if( GAMESTATE->GetCurrentStyle(PLAYER_INVALID) == nullptr )
; // This is true when backing out from ScreenSelectCourse to ScreenTitleMenu. So, don't call SetBpmFromCourse where an assert will fire. ; // This is true when backing out from ScreenSelectCourse to ScreenTitleMenu. So, don't call SetBpmFromCourse where an assert will fire.
else else
SetBpmFromCourse( GAMESTATE->m_pCurCourse ); SetBpmFromCourse( GAMESTATE->m_pCurCourse );
+18 -18
View File
@@ -151,15 +151,15 @@ static RageColor GetBrightnessColor( float fBrightnessPercent )
BackgroundImpl::BackgroundImpl() BackgroundImpl::BackgroundImpl()
{ {
m_bInitted = false; m_bInitted = false;
m_pDancingCharacters = NULL; m_pDancingCharacters = nullptr;
m_pSong = NULL; m_pSong = nullptr;
} }
BackgroundImpl::Layer::Layer() BackgroundImpl::Layer::Layer()
{ {
m_iCurBGChangeIndex = -1; m_iCurBGChangeIndex = -1;
m_pCurrentBGA = NULL; m_pCurrentBGA = nullptr;
m_pFadingBGA = NULL; m_pFadingBGA = nullptr;
} }
void BackgroundImpl::Init() void BackgroundImpl::Init()
@@ -246,20 +246,20 @@ void BackgroundImpl::Unload()
{ {
FOREACH_BackgroundLayer( i ) FOREACH_BackgroundLayer( i )
m_Layer[i].Unload(); m_Layer[i].Unload();
m_pSong = NULL; m_pSong = nullptr;
m_fLastMusicSeconds = -9999; m_fLastMusicSeconds = -9999;
m_RandomBGAnimations.clear(); m_RandomBGAnimations.clear();
} }
void BackgroundImpl::Layer::Unload() void BackgroundImpl::Layer::Unload()
{ {
FOREACHM( BackgroundDef, Actor*, m_BGAnimations, iter ) for (std::pair<BackgroundDef const &, Actor *> iter : m_BGAnimations)
delete iter->second; delete iter.second;
m_BGAnimations.clear(); m_BGAnimations.clear();
m_aBGChanges.clear(); m_aBGChanges.clear();
m_pCurrentBGA = NULL; m_pCurrentBGA = nullptr;
m_pFadingBGA = NULL; m_pFadingBGA = nullptr;
m_iCurBGChangeIndex = -1; m_iCurBGChangeIndex = -1;
} }
@@ -386,7 +386,7 @@ bool BackgroundImpl::Layer::CreateBackground( const Song *pSong, const Backgroun
Actor *pActor = ActorUtil::MakeActor( sEffectFile ); Actor *pActor = ActorUtil::MakeActor( sEffectFile );
if( pActor == NULL ) if( pActor == nullptr )
pActor = new Actor; pActor = new Actor;
m_BGAnimations[bd] = pActor; m_BGAnimations[bd] = pActor;
@@ -542,10 +542,10 @@ void BackgroundImpl::LoadFromSong( const Song* pSong )
int iSize = min( (int)g_iNumBackgrounds, (int)vsNames.size() ); int iSize = min( (int)g_iNumBackgrounds, (int)vsNames.size() );
vsNames.resize( iSize ); vsNames.resize( iSize );
FOREACH_CONST( RString, vsNames, s ) for (RString const &s : vsNames)
{ {
BackgroundDef bd; BackgroundDef bd;
bd.m_sFile1 = *s; bd.m_sFile1 = s;
m_RandomBGAnimations.push_back( bd ); m_RandomBGAnimations.push_back( bd );
} }
} }
@@ -574,9 +574,9 @@ void BackgroundImpl::LoadFromSong( const Song* pSong )
Layer &layer = m_Layer[i]; Layer &layer = m_Layer[i];
// Load all song-specified backgrounds // Load all song-specified backgrounds
FOREACH_CONST( BackgroundChange, pSong->GetBackgroundChanges(i), bgc ) for (BackgroundChange const &bgc : pSong->GetBackgroundChanges(i))
{ {
BackgroundChange change = *bgc; BackgroundChange change = bgc;
BackgroundDef &bd = change.m_def; BackgroundDef &bd = change.m_def;
bool bIsAlreadyLoaded = layer.m_BGAnimations.find(bd) != layer.m_BGAnimations.end(); bool bIsAlreadyLoaded = layer.m_BGAnimations.find(bd) != layer.m_BGAnimations.end();
@@ -643,9 +643,9 @@ void BackgroundImpl::LoadFromSong( const Song* pSong )
FOREACH_BackgroundLayer( i ) FOREACH_BackgroundLayer( i )
{ {
Layer &layer = m_Layer[i]; Layer &layer = m_Layer[i];
FOREACH_CONST( BackgroundChange, layer.m_aBGChanges, bgc ) for (BackgroundChange const &bgc : layer.m_aBGChanges)
{ {
const BackgroundDef &bd = bgc->m_def; const BackgroundDef &bd = bgc.m_def;
if( bd == m_StaticBackgroundDef ) if( bd == m_StaticBackgroundDef )
{ {
bStaticBackgroundUsed = true; bStaticBackgroundUsed = true;
@@ -765,7 +765,7 @@ void BackgroundImpl::Layer::UpdateCurBGChange( const Song *pSong, float fLastMus
if( m_pFadingBGA == m_pCurrentBGA ) if( m_pFadingBGA == m_pCurrentBGA )
{ {
m_pFadingBGA = NULL; m_pFadingBGA = nullptr;
//LOG->Trace( "bg didn't actually change. Ignoring." ); //LOG->Trace( "bg didn't actually change. Ignoring." );
} }
else else
@@ -807,7 +807,7 @@ void BackgroundImpl::Layer::UpdateCurBGChange( const Song *pSong, float fLastMus
if( m_pFadingBGA ) if( m_pFadingBGA )
{ {
if( m_pFadingBGA->GetTweenTimeLeft() == 0 ) if( m_pFadingBGA->GetTweenTimeLeft() == 0 )
m_pFadingBGA = NULL; m_pFadingBGA = nullptr;
} }
/* This is unaffected by the music rate. */ /* This is unaffected by the music rate. */
+24 -24
View File
@@ -2,7 +2,7 @@
#include "BackgroundUtil.h" #include "BackgroundUtil.h"
#include "RageUtil.h" #include "RageUtil.h"
#include "Song.h" #include "Song.h"
#include "Foreach.h"
#include "IniFile.h" #include "IniFile.h"
#include "RageLog.h" #include "RageLog.h"
#include <set> #include <set>
@@ -148,8 +148,8 @@ void BackgroundUtil::GetBackgroundEffects( const RString &_sName, vector<RString
GetDirListing( BACKGROUND_EFFECTS_DIR+sName+".lua", vsPathsOut, false, true ); GetDirListing( BACKGROUND_EFFECTS_DIR+sName+".lua", vsPathsOut, false, true );
vsNamesOut.clear(); vsNamesOut.clear();
FOREACH_CONST( RString, vsPathsOut, s ) for (RString const &s : vsPathsOut)
vsNamesOut.push_back( GetFileNameWithoutExtension(*s) ); vsNamesOut.push_back( GetFileNameWithoutExtension(s) );
StripCvsAndSvn( vsPathsOut, vsNamesOut ); StripCvsAndSvn( vsPathsOut, vsNamesOut );
} }
@@ -166,8 +166,8 @@ void BackgroundUtil::GetBackgroundTransitions( const RString &_sName, vector<RSt
GetDirListing( BACKGROUND_TRANSITIONS_DIR+sName+".lua", vsPathsOut, false, true ); GetDirListing( BACKGROUND_TRANSITIONS_DIR+sName+".lua", vsPathsOut, false, true );
vsNamesOut.clear(); vsNamesOut.clear();
FOREACH_CONST( RString, vsPathsOut, s ) for (RString const &s : vsPathsOut)
vsNamesOut.push_back( GetFileNameWithoutExtension(*s) ); vsNamesOut.push_back( GetFileNameWithoutExtension(s) );
StripCvsAndSvn( vsPathsOut, vsNamesOut ); StripCvsAndSvn( vsPathsOut, vsNamesOut );
} }
@@ -185,8 +185,8 @@ void BackgroundUtil::GetSongBGAnimations( const Song *pSong, const RString &sMat
} }
vsNamesOut.clear(); vsNamesOut.clear();
FOREACH_CONST( RString, vsPathsOut, s ) for (RString const &s : vsPathsOut)
vsNamesOut.push_back( Basename(*s) ); vsNamesOut.push_back( Basename(s) );
StripCvsAndSvn( vsPathsOut, vsNamesOut ); StripCvsAndSvn( vsPathsOut, vsNamesOut );
} }
@@ -205,8 +205,8 @@ void BackgroundUtil::GetSongMovies( const Song *pSong, const RString &sMatch, ve
} }
vsNamesOut.clear(); vsNamesOut.clear();
FOREACH_CONST( RString, vsPathsOut, s ) for (RString const &s : vsPathsOut)
vsNamesOut.push_back( Basename(*s) ); vsNamesOut.push_back( Basename(s) );
StripCvsAndSvn( vsPathsOut, vsNamesOut ); StripCvsAndSvn( vsPathsOut, vsNamesOut );
} }
@@ -225,8 +225,8 @@ void BackgroundUtil::GetSongBitmaps( const Song *pSong, const RString &sMatch, v
} }
vsNamesOut.clear(); vsNamesOut.clear();
FOREACH_CONST( RString, vsPathsOut, s ) for (RString const &s : vsPathsOut)
vsNamesOut.push_back( Basename(*s) ); vsNamesOut.push_back( Basename(s) );
StripCvsAndSvn( vsPathsOut, vsNamesOut ); StripCvsAndSvn( vsPathsOut, vsNamesOut );
} }
@@ -252,7 +252,7 @@ static void GetFilterToFileNames( const RString sBaseDir, const Song *pSong, set
} }
XNode *pSection = ini.GetChild( sSection ); XNode *pSection = ini.GetChild( sSection );
if( pSection == NULL ) if( pSection == nullptr )
{ {
ASSERT_M( 0, ssprintf("File '%s' refers to a section '%s' that is missing.", sPath.c_str(), sSection.c_str()) ); ASSERT_M( 0, ssprintf("File '%s' refers to a section '%s' that is missing.", sPath.c_str(), sSection.c_str()) );
return; return;
@@ -270,8 +270,8 @@ void BackgroundUtil::GetGlobalBGAnimations( const Song *pSong, const RString &sM
GetDirListing( BG_ANIMS_DIR+sMatch+"*.xml", vsPathsOut, false, true ); GetDirListing( BG_ANIMS_DIR+sMatch+"*.xml", vsPathsOut, false, true );
vsNamesOut.clear(); vsNamesOut.clear();
FOREACH_CONST( RString, vsPathsOut, s ) for (RString const &s : vsPathsOut)
vsNamesOut.push_back( Basename(*s) ); vsNamesOut.push_back( Basename(s) );
StripCvsAndSvn( vsPathsOut, vsNamesOut ); StripCvsAndSvn( vsPathsOut, vsNamesOut );
} }
@@ -313,22 +313,22 @@ namespace {
} }
vsDirsToTry.push_back( RANDOMMOVIES_DIR ); vsDirsToTry.push_back( RANDOMMOVIES_DIR );
FOREACH_CONST( RString, vsDirsToTry, sDir ) for (RString const &sDir : vsDirsToTry)
{ {
GetDirListing( *sDir+"*.ogv", vsPathsOut, false, true ); GetDirListing( sDir+"*.ogv", vsPathsOut, false, true );
GetDirListing( *sDir+"*.avi", vsPathsOut, false, true ); GetDirListing( sDir+"*.avi", vsPathsOut, false, true );
GetDirListing( *sDir+"*.mpg", vsPathsOut, false, true ); GetDirListing( sDir+"*.mpg", vsPathsOut, false, true );
GetDirListing( *sDir+"*.mpeg", vsPathsOut, false, true ); GetDirListing( sDir+"*.mpeg", vsPathsOut, false, true );
if( !ssFileNameWhitelist.empty() ) if( !ssFileNameWhitelist.empty() )
{ {
vector<RString> vsMatches; vector<RString> vsMatches;
FOREACH_CONST( RString, vsPathsOut, s ) for (RString const &s : vsPathsOut)
{ {
RString sBasename = Basename( *s ); RString sBasename = Basename( s );
bool bFound = ssFileNameWhitelist.find(sBasename) != ssFileNameWhitelist.end(); bool bFound = ssFileNameWhitelist.find(sBasename) != ssFileNameWhitelist.end();
if( bFound ) if( bFound )
vsMatches.push_back(*s); vsMatches.push_back(s);
} }
// If we found any that match the whitelist, use only them. // If we found any that match the whitelist, use only them.
// If none match the whitelist, ignore the whitelist.. // If none match the whitelist, ignore the whitelist..
@@ -359,9 +359,9 @@ void BackgroundUtil::GetGlobalRandomMovies(
GetGlobalRandomMoviePaths( pSong, sMatch, vsPathsOut, bTryInsideOfSongGroupAndGenreFirst, bTryInsideOfSongGroupFirst ); GetGlobalRandomMoviePaths( pSong, sMatch, vsPathsOut, bTryInsideOfSongGroupAndGenreFirst, bTryInsideOfSongGroupFirst );
FOREACH_CONST( RString, vsPathsOut, s ) for (RString const &s : vsPathsOut)
{ {
RString sName = s->Right( s->size() - RANDOMMOVIES_DIR.size() - 1 ); RString sName = s.Right( s.size() - RANDOMMOVIES_DIR.size() - 1 );
vsNamesOut.push_back( sName ); vsNamesOut.push_back( sName );
} }
StripCvsAndSvn( vsPathsOut, vsNamesOut ); StripCvsAndSvn( vsPathsOut, vsNamesOut );
+15 -15
View File
@@ -107,9 +107,9 @@ void Banner::SetScrolling( bool bScroll, float Percent)
Update(0); Update(0);
} }
void Banner::LoadFromSong( Song* pSong ) // NULL means no song void Banner::LoadFromSong( Song* pSong ) // nullptr means no song
{ {
if( pSong == NULL ) LoadFallback(); if( pSong == nullptr ) LoadFallback();
else if( pSong->HasBanner() ) Load( pSong->GetBannerPath() ); else if( pSong->HasBanner() ) Load( pSong->GetBannerPath() );
else LoadFallback(); else LoadFallback();
@@ -130,9 +130,9 @@ void Banner::LoadFromSongGroup( RString sSongGroup )
m_bScrolling = false; m_bScrolling = false;
} }
void Banner::LoadFromCourse( const Course *pCourse ) // NULL means no course void Banner::LoadFromCourse( const Course *pCourse ) // nullptr means no course
{ {
if( pCourse == NULL ) LoadFallback(); if( pCourse == nullptr ) LoadFallback();
else if( pCourse->GetBannerPath() != "" ) Load( pCourse->GetBannerPath() ); else if( pCourse->GetBannerPath() != "" ) Load( pCourse->GetBannerPath() );
else LoadCourseFallback(); else LoadCourseFallback();
@@ -141,7 +141,7 @@ void Banner::LoadFromCourse( const Course *pCourse ) // NULL means no course
void Banner::LoadCardFromCharacter( const Character *pCharacter ) void Banner::LoadCardFromCharacter( const Character *pCharacter )
{ {
if( pCharacter == NULL ) LoadFallback(); if( pCharacter == nullptr ) LoadFallback();
else if( pCharacter->GetCardPath() != "" ) Load( pCharacter->GetCardPath() ); else if( pCharacter->GetCardPath() != "" ) Load( pCharacter->GetCardPath() );
else LoadFallback(); else LoadFallback();
@@ -150,7 +150,7 @@ void Banner::LoadCardFromCharacter( const Character *pCharacter )
void Banner::LoadIconFromCharacter( const Character *pCharacter ) void Banner::LoadIconFromCharacter( const Character *pCharacter )
{ {
if( pCharacter == NULL ) LoadFallbackCharacterIcon(); if( pCharacter == nullptr ) LoadFallbackCharacterIcon();
else if( pCharacter->GetIconPath() != "" ) Load( pCharacter->GetIconPath(), false ); else if( pCharacter->GetIconPath() != "" ) Load( pCharacter->GetIconPath(), false );
else LoadFallbackCharacterIcon(); else LoadFallbackCharacterIcon();
@@ -159,7 +159,7 @@ void Banner::LoadIconFromCharacter( const Character *pCharacter )
void Banner::LoadBannerFromUnlockEntry( const UnlockEntry* pUE ) void Banner::LoadBannerFromUnlockEntry( const UnlockEntry* pUE )
{ {
if( pUE == NULL ) if( pUE == nullptr )
LoadFallback(); LoadFallback();
else else
{ {
@@ -171,7 +171,7 @@ void Banner::LoadBannerFromUnlockEntry( const UnlockEntry* pUE )
void Banner::LoadBackgroundFromUnlockEntry( const UnlockEntry* pUE ) void Banner::LoadBackgroundFromUnlockEntry( const UnlockEntry* pUE )
{ {
if( pUE == NULL ) if( pUE == nullptr )
LoadFallback(); LoadFallback();
else else
{ {
@@ -224,7 +224,7 @@ void Banner::LoadRandom()
void Banner::LoadFromSortOrder( SortOrder so ) void Banner::LoadFromSortOrder( SortOrder so )
{ {
// TODO: See if the check for NULL/PREFERRED(?) is needed. // TODO: See if the check for nullptr/PREFERRED(?) is needed.
if( so == SortOrder_Invalid ) if( so == SortOrder_Invalid )
{ {
LoadFallback(); LoadFallback();
@@ -248,13 +248,13 @@ public:
static int ScaleToClipped( T* p, lua_State *L ) { p->ScaleToClipped(FArg(1),FArg(2)); COMMON_RETURN_SELF; } static int ScaleToClipped( T* p, lua_State *L ) { p->ScaleToClipped(FArg(1),FArg(2)); COMMON_RETURN_SELF; }
static int LoadFromSong( T* p, lua_State *L ) static int LoadFromSong( T* p, lua_State *L )
{ {
if( lua_isnil(L,1) ) { p->LoadFromSong( NULL ); } if( lua_isnil(L,1) ) { p->LoadFromSong(nullptr); }
else { Song *pS = Luna<Song>::check(L,1); p->LoadFromSong( pS ); } else { Song *pS = Luna<Song>::check(L,1); p->LoadFromSong( pS ); }
COMMON_RETURN_SELF; COMMON_RETURN_SELF;
} }
static int LoadFromCourse( T* p, lua_State *L ) static int LoadFromCourse( T* p, lua_State *L )
{ {
if( lua_isnil(L,1) ) { p->LoadFromCourse( NULL ); } if( lua_isnil(L,1) ) { p->LoadFromCourse(nullptr); }
else { Course *pC = Luna<Course>::check(L,1); p->LoadFromCourse( pC ); } else { Course *pC = Luna<Course>::check(L,1); p->LoadFromCourse( pC ); }
COMMON_RETURN_SELF; COMMON_RETURN_SELF;
} }
@@ -265,25 +265,25 @@ public:
} }
static int LoadIconFromCharacter( T* p, lua_State *L ) static int LoadIconFromCharacter( T* p, lua_State *L )
{ {
if( lua_isnil(L,1) ) { p->LoadIconFromCharacter( NULL ); } if( lua_isnil(L,1) ) { p->LoadIconFromCharacter(nullptr); }
else { Character *pC = Luna<Character>::check(L,1); p->LoadIconFromCharacter( pC ); } else { Character *pC = Luna<Character>::check(L,1); p->LoadIconFromCharacter( pC ); }
COMMON_RETURN_SELF; COMMON_RETURN_SELF;
} }
static int LoadCardFromCharacter( T* p, lua_State *L ) static int LoadCardFromCharacter( T* p, lua_State *L )
{ {
if( lua_isnil(L,1) ) { p->LoadIconFromCharacter( NULL ); } if( lua_isnil(L,1) ) { p->LoadIconFromCharacter(nullptr); }
else { Character *pC = Luna<Character>::check(L,1); p->LoadIconFromCharacter( pC ); } else { Character *pC = Luna<Character>::check(L,1); p->LoadIconFromCharacter( pC ); }
COMMON_RETURN_SELF; COMMON_RETURN_SELF;
} }
static int LoadBannerFromUnlockEntry( T* p, lua_State *L ) static int LoadBannerFromUnlockEntry( T* p, lua_State *L )
{ {
if( lua_isnil(L,1) ) { p->LoadBannerFromUnlockEntry( NULL ); } if( lua_isnil(L,1) ) { p->LoadBannerFromUnlockEntry(nullptr); }
else { UnlockEntry *pUE = Luna<UnlockEntry>::check(L,1); p->LoadBannerFromUnlockEntry( pUE ); } else { UnlockEntry *pUE = Luna<UnlockEntry>::check(L,1); p->LoadBannerFromUnlockEntry( pUE ); }
COMMON_RETURN_SELF; COMMON_RETURN_SELF;
} }
static int LoadBackgroundFromUnlockEntry( T* p, lua_State *L ) static int LoadBackgroundFromUnlockEntry( T* p, lua_State *L )
{ {
if( lua_isnil(L,1) ) { p->LoadBackgroundFromUnlockEntry( NULL ); } if( lua_isnil(L,1) ) { p->LoadBackgroundFromUnlockEntry(nullptr); }
else { UnlockEntry *pUE = Luna<UnlockEntry>::check(L,1); p->LoadBackgroundFromUnlockEntry( pUE ); } else { UnlockEntry *pUE = Luna<UnlockEntry>::check(L,1); p->LoadBackgroundFromUnlockEntry( pUE ); }
COMMON_RETURN_SELF; COMMON_RETURN_SELF;
} }
+1 -1
View File
@@ -27,7 +27,7 @@ public:
/** /**
* @brief Attempt to load the banner from a song. * @brief Attempt to load the banner from a song.
* @param pSong the song in question. If NULL, there is no song. * @param pSong the song in question. If nullptr, there is no song.
*/ */
void LoadFromSong( Song* pSong ); void LoadFromSong( Song* pSong );
void LoadMode(); void LoadMode();
+3 -3
View File
@@ -149,7 +149,7 @@ bool BeginnerHelper::Init( int iDancePadType )
// Load character data // Load character data
const Character *Character = GAMESTATE->m_pCurCharacters[pl]; const Character *Character = GAMESTATE->m_pCurCharacters[pl];
ASSERT( Character != NULL ); ASSERT( Character != nullptr );
m_pDancer[pl]->SetName( ssprintf("PlayerP%d",pl+1) ); m_pDancer[pl]->SetName( ssprintf("PlayerP%d",pl+1) );
@@ -204,7 +204,7 @@ void BeginnerHelper::AddPlayer( PlayerNumber pn, const NoteData &ns )
return; return;
const Character *Character = GAMESTATE->m_pCurCharacters[pn]; const Character *Character = GAMESTATE->m_pCurCharacters[pn];
ASSERT( Character != NULL ); ASSERT( Character != nullptr );
if( !DoesFileExist(Character->GetModelPath()) ) if( !DoesFileExist(Character->GetModelPath()) )
return; return;
@@ -219,7 +219,7 @@ bool BeginnerHelper::CanUse(PlayerNumber pn)
return false; return false;
// This does not pass PLAYER_INVALID to GetCurrentStyle because that would // This does not pass PLAYER_INVALID to GetCurrentStyle because that would
// only check the first non-NULL style. Both styles need to be checked. -Kyz // only check the first non-nullptr style. Both styles need to be checked. -Kyz
if(pn == PLAYER_INVALID) if(pn == PLAYER_INVALID)
{ {
return GAMESTATE->GetCurrentStyle(PLAYER_1)->m_bCanUseBeginnerHelper || return GAMESTATE->GetCurrentStyle(PLAYER_1)->m_bCanUseBeginnerHelper ||
+7 -4
View File
@@ -8,6 +8,9 @@
#include "PlayerNumber.h" #include "PlayerNumber.h"
#include "NoteData.h" #include "NoteData.h"
#include "ThemeMetric.h" #include "ThemeMetric.h"
#include <array>
class Model; class Model;
/** @brief A dancing character that follows the steps of the Song. */ /** @brief A dancing character that follows the steps of the Song. */
class BeginnerHelper : public ActorFrame class BeginnerHelper : public ActorFrame
@@ -29,13 +32,13 @@ public:
protected: protected:
void Step( PlayerNumber pn, int CSTEP ); void Step( PlayerNumber pn, int CSTEP );
NoteData m_NoteData[NUM_PLAYERS]; std::array<NoteData, NUM_PLAYERS> m_NoteData;
bool m_bPlayerEnabled[NUM_PLAYERS]; std::array<bool, NUM_PLAYERS> m_bPlayerEnabled;
Model *m_pDancer[NUM_PLAYERS]; std::array<Model *, NUM_PLAYERS> m_pDancer;
Model *m_pDancePad; Model *m_pDancePad;
Sprite m_sFlash; Sprite m_sFlash;
AutoActor m_sBackground; AutoActor m_sBackground;
Sprite m_sStepCircle[NUM_PLAYERS][4]; // More memory, but much easier to manage std::array<std::array<Sprite, 4>, NUM_PLAYERS> m_sStepCircle; // More memory, but much easier to manage.
int m_iLastRowChecked; int m_iLastRowChecked;
int m_iLastRowFlashed; int m_iLastRowFlashed;
+13 -13
View File
@@ -9,7 +9,7 @@
#include "Font.h" #include "Font.h"
#include "ActorUtil.h" #include "ActorUtil.h"
#include "LuaBinding.h" #include "LuaBinding.h"
#include "Foreach.h"
REGISTER_ACTOR_CLASS( BitmapText ); REGISTER_ACTOR_CLASS( BitmapText );
@@ -42,7 +42,7 @@ BitmapText::BitmapText()
} }
iReloadCounter++; iReloadCounter++;
m_pFont = NULL; m_pFont = nullptr;
m_bUppercase = false; m_bUppercase = false;
m_bRainbowScroll = false; m_bRainbowScroll = false;
@@ -102,10 +102,10 @@ BitmapText & BitmapText::operator=(const BitmapText &cpy)
if( m_pFont ) if( m_pFont )
FONT->UnloadFont( m_pFont ); FONT->UnloadFont( m_pFont );
if( cpy.m_pFont != NULL ) if( cpy.m_pFont != nullptr )
m_pFont = FONT->CopyFont( cpy.m_pFont ); m_pFont = FONT->CopyFont( cpy.m_pFont );
else else
m_pFont = NULL; m_pFont = nullptr;
return *this; return *this;
} }
@@ -113,7 +113,7 @@ BitmapText & BitmapText::operator=(const BitmapText &cpy)
BitmapText::BitmapText( const BitmapText &cpy ): BitmapText::BitmapText( const BitmapText &cpy ):
Actor( cpy ) Actor( cpy )
{ {
m_pFont = NULL; m_pFont = nullptr;
*this = cpy; *this = cpy;
} }
@@ -212,7 +212,7 @@ bool BitmapText::LoadFromFont( const RString& sFontFilePath )
if( m_pFont ) if( m_pFont )
{ {
FONT->UnloadFont( m_pFont ); FONT->UnloadFont( m_pFont );
m_pFont = NULL; m_pFont = nullptr;
} }
m_pFont = FONT->LoadFont( sFontFilePath ); m_pFont = FONT->LoadFont( sFontFilePath );
@@ -231,7 +231,7 @@ bool BitmapText::LoadFromTextureAndChars( const RString& sTexturePath, const RSt
if( m_pFont ) if( m_pFont )
{ {
FONT->UnloadFont( m_pFont ); FONT->UnloadFont( m_pFont );
m_pFont = NULL; m_pFont = nullptr;
} }
m_pFont = FONT->LoadFont( sTexturePath, sChars ); m_pFont = FONT->LoadFont( sTexturePath, sChars );
@@ -244,7 +244,7 @@ bool BitmapText::LoadFromTextureAndChars( const RString& sTexturePath, const RSt
void BitmapText::BuildChars() void BitmapText::BuildChars()
{ {
// If we don't have a font yet, we'll do this when it loads. // If we don't have a font yet, we'll do this when it loads.
if( m_pFont == NULL ) if( m_pFont == nullptr )
return; return;
// calculate line lengths and widths // calculate line lengths and widths
@@ -456,7 +456,7 @@ void BitmapText::DrawChars( bool bUseStrokeTexture )
* in sAlternateText, too, just use sText. */ * in sAlternateText, too, just use sText. */
void BitmapText::SetText( const RString& _sText, const RString& _sAlternateText, int iWrapWidthPixels ) void BitmapText::SetText( const RString& _sText, const RString& _sAlternateText, int iWrapWidthPixels )
{ {
ASSERT( m_pFont != NULL ); ASSERT( m_pFont != nullptr );
RString sNewText = StringWillUseAlternate(_sText,_sAlternateText) ? _sAlternateText : _sText; RString sNewText = StringWillUseAlternate(_sText,_sAlternateText) ? _sAlternateText : _sText;
@@ -624,7 +624,7 @@ void BitmapText::UpdateBaseZoom()
bool BitmapText::StringWillUseAlternate( const RString& sText, const RString& sAlternateText ) const bool BitmapText::StringWillUseAlternate( const RString& sText, const RString& sAlternateText ) const
{ {
ASSERT( m_pFont != NULL ); ASSERT( m_pFont != nullptr );
// Can't use the alternate if there isn't one. // Can't use the alternate if there isn't one.
if( !sAlternateText.size() ) if( !sAlternateText.size() )
@@ -856,7 +856,7 @@ void BitmapText::SetHorizAlign( float f )
void BitmapText::SetWrapWidthPixels( int iWrapWidthPixels ) void BitmapText::SetWrapWidthPixels( int iWrapWidthPixels )
{ {
ASSERT( m_pFont != NULL ); // always load a font first ASSERT( m_pFont != nullptr ); // always load a font first
if( m_iWrapWidthPixels == iWrapWidthPixels ) if( m_iWrapWidthPixels == iWrapWidthPixels )
return; return;
m_iWrapWidthPixels = iWrapWidthPixels; m_iWrapWidthPixels = iWrapWidthPixels;
@@ -878,9 +878,9 @@ void BitmapText::AddAttribute( size_t iPos, const Attribute &attr )
int iLines = 0; int iLines = 0;
size_t iAdjustedPos = iPos; size_t iAdjustedPos = iPos;
FOREACH_CONST( wstring, m_wTextLines, line ) for (wstring const & line : m_wTextLines)
{ {
size_t length = line->length(); size_t length = line.length();
if( length >= iAdjustedPos ) if( length >= iAdjustedPos )
break; break;
iAdjustedPos -= length; iAdjustedPos -= length;
+6 -6
View File
@@ -12,7 +12,7 @@
#include "SpecialFiles.h" #include "SpecialFiles.h"
#include <ctime> #include <ctime>
Bookkeeper* BOOKKEEPER = NULL; // global and accessible from anywhere in our program Bookkeeper* BOOKKEEPER = nullptr; // global and accessible from anywhere in our program
static const RString COINS_DAT = "Save/Coins.xml"; static const RString COINS_DAT = "Save/Coins.xml";
@@ -67,7 +67,7 @@ void Bookkeeper::LoadFromNode( const XNode *pNode )
} }
const XNode *pData = pNode->GetChild( "Data" ); const XNode *pData = pNode->GetChild( "Data" );
if( pData == NULL ) if( pData == nullptr )
{ {
LOG->Warn( "Error loading bookkeeping: Data node missing" ); LOG->Warn( "Error loading bookkeeping: Data node missing" );
return; return;
@@ -146,14 +146,14 @@ void Bookkeeper::WriteToDisk()
return; return;
} }
auto_ptr<XNode> xml( CreateNode() ); std::unique_ptr<XNode> xml( CreateNode() );
XmlFileUtil::SaveToFile( xml.get(), f ); XmlFileUtil::SaveToFile( xml.get(), f );
} }
void Bookkeeper::CoinInserted() void Bookkeeper::CoinInserted()
{ {
Date d; Date d;
d.Set( time(NULL) ); d.Set( time(nullptr) );
++m_mapCoinsForHour[d]; ++m_mapCoinsForHour[d];
} }
@@ -199,7 +199,7 @@ int Bookkeeper::GetCoinsTotal() const
void Bookkeeper::GetCoinsLastDays( int coins[NUM_LAST_DAYS] ) const void Bookkeeper::GetCoinsLastDays( int coins[NUM_LAST_DAYS] ) const
{ {
time_t lOldTime = time(NULL); time_t lOldTime = time(nullptr);
tm time; tm time;
localtime_r( &lOldTime, &time ); localtime_r( &lOldTime, &time );
@@ -215,7 +215,7 @@ void Bookkeeper::GetCoinsLastDays( int coins[NUM_LAST_DAYS] ) const
void Bookkeeper::GetCoinsLastWeeks( int coins[NUM_LAST_WEEKS] ) const void Bookkeeper::GetCoinsLastWeeks( int coins[NUM_LAST_WEEKS] ) const
{ {
time_t lOldTime = time(NULL); time_t lOldTime = time(nullptr);
tm time; tm time;
localtime_r( &lOldTime, &time ); localtime_r( &lOldTime, &time );
-1
View File
@@ -231,7 +231,6 @@ list(APPEND SM_DATA_REST_HPP
"Difficulty.h" "Difficulty.h"
"EnumHelper.h" "EnumHelper.h"
"FileDownload.h" "FileDownload.h"
"Foreach.h"
"Game.h" "Game.h"
"GameCommand.h" "GameCommand.h"
"GameConstantsAndTypes.h" "GameConstantsAndTypes.h"
+1 -1
View File
@@ -40,7 +40,7 @@ public:
void PushSelf( Lua *L ); void PushSelf( Lua *L );
// smart accessor // smart accessor
const RString &GetDisplayName() { return !m_sDisplayName.empty() ? m_sDisplayName : m_sCharacterID; } const RString &GetDisplayName() const { return !m_sDisplayName.empty() ? m_sDisplayName : m_sCharacterID; }
RString m_sCharDir; RString m_sCharDir;
RString m_sCharacterID; RString m_sCharacterID;
+13 -13
View File
@@ -2,12 +2,12 @@
#include "CharacterManager.h" #include "CharacterManager.h"
#include "Character.h" #include "Character.h"
#include "GameState.h" #include "GameState.h"
#include "Foreach.h"
#include "LuaManager.h" #include "LuaManager.h"
#define CHARACTERS_DIR "/Characters/" #define CHARACTERS_DIR "/Characters/"
CharacterManager* CHARMAN = NULL; // global object accessible from anywhere in the program CharacterManager* CHARMAN = nullptr; // global object accessible from anywhere in the program
CharacterManager::CharacterManager() CharacterManager::CharacterManager()
{ {
@@ -82,27 +82,27 @@ Character* CharacterManager::GetRandomCharacter()
Character* CharacterManager::GetDefaultCharacter() Character* CharacterManager::GetDefaultCharacter()
{ {
for( unsigned i=0; i<m_pCharacters.size(); i++ ) for (Character *c : m_pCharacters)
{ {
if( m_pCharacters[i]->IsDefaultCharacter() ) if( c->IsDefaultCharacter() )
return m_pCharacters[i]; return c;
} }
/* We always have the default character. */ /* We always have the default character. */
FAIL_M("There must be a default character available!"); FAIL_M("There must be a default character available!");
return NULL; return nullptr;
} }
void CharacterManager::DemandGraphics() void CharacterManager::DemandGraphics()
{ {
FOREACH( Character*, m_pCharacters, c ) for (Character *c : m_pCharacters)
(*c)->DemandGraphics(); c->DemandGraphics();
} }
void CharacterManager::UndemandGraphics() void CharacterManager::UndemandGraphics()
{ {
FOREACH( Character*, m_pCharacters, c ) for (Character *c : m_pCharacters)
(*c)->UndemandGraphics(); c->UndemandGraphics();
} }
Character* CharacterManager::GetCharacterFromID( RString sCharacterID ) Character* CharacterManager::GetCharacterFromID( RString sCharacterID )
@@ -113,7 +113,7 @@ Character* CharacterManager::GetCharacterFromID( RString sCharacterID )
return m_pCharacters[i]; return m_pCharacters[i];
} }
return NULL; return nullptr;
} }
@@ -127,7 +127,7 @@ public:
static int GetCharacter( T* p, lua_State *L ) static int GetCharacter( T* p, lua_State *L )
{ {
Character *pCharacter = p->GetCharacterFromID(SArg(1)); Character *pCharacter = p->GetCharacterFromID(SArg(1));
if( pCharacter != NULL ) if( pCharacter != nullptr )
pCharacter->PushSelf( L ); pCharacter->PushSelf( L );
else else
lua_pushnil( L ); lua_pushnil( L );
@@ -137,7 +137,7 @@ public:
static int GetRandomCharacter( T* p, lua_State *L ) static int GetRandomCharacter( T* p, lua_State *L )
{ {
Character *pCharacter = p->GetRandomCharacter(); Character *pCharacter = p->GetRandomCharacter();
if( pCharacter != NULL ) if( pCharacter != nullptr )
pCharacter->PushSelf( L ); pCharacter->PushSelf( L );
else else
lua_pushnil( L ); lua_pushnil( L );
+2 -1
View File
@@ -3,6 +3,7 @@
#include "CombinedLifeMeter.h" #include "CombinedLifeMeter.h"
#include "MeterDisplay.h" #include "MeterDisplay.h"
#include <array>
/** @brief Dance Magic-like tug-o-war life meter. */ /** @brief Dance Magic-like tug-o-war life meter. */
class CombinedLifeMeterTug : public CombinedLifeMeter class CombinedLifeMeterTug : public CombinedLifeMeter
@@ -19,7 +20,7 @@ public:
protected: protected:
MeterDisplay m_Stream[NUM_PLAYERS]; std::array<MeterDisplay, NUM_PLAYERS> m_Stream;
AutoActor m_sprSeparator; AutoActor m_sprSeparator;
AutoActor m_sprFrame; AutoActor m_sprFrame;
}; };
+9 -9
View File
@@ -14,9 +14,9 @@ ComboGraph::ComboGraph()
{ {
DeleteChildrenWhenDone( true ); DeleteChildrenWhenDone( true );
m_pNormalCombo = NULL; m_pNormalCombo = nullptr;
m_pMaxCombo = NULL; m_pMaxCombo = nullptr;
m_pComboNumber = NULL; m_pComboNumber = nullptr;
} }
void ComboGraph::Load( RString sMetricsGroup ) void ComboGraph::Load( RString sMetricsGroup )
@@ -28,10 +28,10 @@ void ComboGraph::Load( RString sMetricsGroup )
this->SetWidth(BODY_WIDTH); this->SetWidth(BODY_WIDTH);
this->SetHeight(BODY_HEIGHT); this->SetHeight(BODY_HEIGHT);
Actor *pActor = NULL; Actor *pActor = nullptr;
m_pBacking = ActorUtil::MakeActor( THEME->GetPathG(sMetricsGroup,"Backing") ); m_pBacking = ActorUtil::MakeActor( THEME->GetPathG(sMetricsGroup,"Backing") );
if( m_pBacking != NULL ) if( m_pBacking != nullptr )
{ {
m_pBacking->ZoomToWidth( BODY_WIDTH ); m_pBacking->ZoomToWidth( BODY_WIDTH );
m_pBacking->ZoomToHeight( BODY_HEIGHT ); m_pBacking->ZoomToHeight( BODY_HEIGHT );
@@ -39,7 +39,7 @@ void ComboGraph::Load( RString sMetricsGroup )
} }
m_pNormalCombo = ActorUtil::MakeActor( THEME->GetPathG(sMetricsGroup,"NormalCombo") ); m_pNormalCombo = ActorUtil::MakeActor( THEME->GetPathG(sMetricsGroup,"NormalCombo") );
if( m_pNormalCombo != NULL ) if( m_pNormalCombo != nullptr )
{ {
m_pNormalCombo->ZoomToWidth( BODY_WIDTH ); m_pNormalCombo->ZoomToWidth( BODY_WIDTH );
m_pNormalCombo->ZoomToHeight( BODY_HEIGHT ); m_pNormalCombo->ZoomToHeight( BODY_HEIGHT );
@@ -47,7 +47,7 @@ void ComboGraph::Load( RString sMetricsGroup )
} }
m_pMaxCombo = ActorUtil::MakeActor( THEME->GetPathG(sMetricsGroup,"MaxCombo") ); m_pMaxCombo = ActorUtil::MakeActor( THEME->GetPathG(sMetricsGroup,"MaxCombo") );
if( m_pMaxCombo != NULL ) if( m_pMaxCombo != nullptr )
{ {
m_pMaxCombo->ZoomToWidth( BODY_WIDTH ); m_pMaxCombo->ZoomToWidth( BODY_WIDTH );
m_pMaxCombo->ZoomToHeight( BODY_HEIGHT ); m_pMaxCombo->ZoomToHeight( BODY_HEIGHT );
@@ -55,10 +55,10 @@ void ComboGraph::Load( RString sMetricsGroup )
} }
pActor = ActorUtil::MakeActor( THEME->GetPathG(sMetricsGroup,"ComboNumber") ); pActor = ActorUtil::MakeActor( THEME->GetPathG(sMetricsGroup,"ComboNumber") );
if( pActor != NULL ) if( pActor != nullptr )
{ {
m_pComboNumber = dynamic_cast<BitmapText *>( pActor ); m_pComboNumber = dynamic_cast<BitmapText *>( pActor );
if( m_pComboNumber != NULL ) if( m_pComboNumber != nullptr )
this->AddChild( m_pComboNumber ); this->AddChild( m_pComboNumber );
else else
LuaHelpers::ReportScriptErrorFmt( "ComboGraph: \"sMetricsGroup\" \"ComboNumber\" must be a BitmapText" ); LuaHelpers::ReportScriptErrorFmt( "ComboGraph: \"sMetricsGroup\" \"ComboNumber\" must be a BitmapText" );
+2 -11
View File
@@ -3,8 +3,8 @@
#include "RageUtil.h" #include "RageUtil.h"
#include "RageLog.h" #include "RageLog.h"
#include "arch/Dialog/Dialog.h" #include "arch/Dialog/Dialog.h"
#include "Foreach.h"
#include <numeric>
RString Command::GetName() const RString Command::GetName() const
{ {
@@ -81,16 +81,7 @@ static void SplitWithQuotes( const RString sSource, const char Delimitor, vector
RString Commands::GetOriginalCommandString() const RString Commands::GetOriginalCommandString() const
{ {
RString s; return std::accumulate(v.begin(), v.end(), RString(), [](RString &res, Command const &c) { return res + c.GetOriginalCommandString(); });
FOREACH_CONST( Command, v, c )
{
if(s != "")
{
s += ";";
}
s += c->GetOriginalCommandString();
}
return s;
} }
void ParseCommands( const RString &sCommands, Commands &vCommandsOut, bool bLegacy ) void ParseCommands( const RString &sCommands, Commands &vCommandsOut, bool bLegacy )
+4 -4
View File
@@ -8,7 +8,7 @@
#include "LuaManager.h" #include "LuaManager.h"
#include "ProductInfo.h" #include "ProductInfo.h"
#include "DateTime.h" #include "DateTime.h"
#include "Foreach.h"
#include "arch/Dialog/Dialog.h" #include "arch/Dialog/Dialog.h"
#include "RageFileManager.h" #include "RageFileManager.h"
#include "SpecialFiles.h" #include "SpecialFiles.h"
@@ -38,17 +38,17 @@ static void Nsis()
vector<RString> vs; vector<RString> vs;
GetDirListing(INSTALLER_LANGUAGES_DIR + "*.ini", vs, false, false); GetDirListing(INSTALLER_LANGUAGES_DIR + "*.ini", vs, false, false);
FOREACH_CONST(RString, vs, s) for (RString const &s : vs)
{ {
RString sThrowAway, sLangCode; RString sThrowAway, sLangCode;
splitpath(*s, sThrowAway, sLangCode, sThrowAway); splitpath(s, sThrowAway, sLangCode, sThrowAway);
const LanguageInfo *pLI = GetLanguageInfo(sLangCode); const LanguageInfo *pLI = GetLanguageInfo(sLangCode);
RString sLangNameUpper = pLI->szEnglishName; RString sLangNameUpper = pLI->szEnglishName;
sLangNameUpper.MakeUpper(); sLangNameUpper.MakeUpper();
IniFile ini; IniFile ini;
if(!ini.ReadFile(INSTALLER_LANGUAGES_DIR + *s)) if(!ini.ReadFile(INSTALLER_LANGUAGES_DIR + s))
RageException::Throw("Error opening file for read."); RageException::Throw("Error opening file for read.");
FOREACH_CONST_Child(&ini, child) FOREACH_CONST_Child(&ini, child)
{ {
+10 -10
View File
@@ -1,7 +1,7 @@
#include "global.h" #include "global.h"
#include "CommonMetrics.h" #include "CommonMetrics.h"
#include "RageUtil.h" #include "RageUtil.h"
#include "Foreach.h"
#include "GameManager.h" #include "GameManager.h"
#include "RageLog.h" #include "RageLog.h"
#include "GameState.h" #include "GameState.h"
@@ -45,12 +45,12 @@ void ThemeMetricDifficultiesToShow::Read()
return; return;
} }
FOREACH_CONST( RString, v, i ) for (RString const &i : v)
{ {
Difficulty d = StringToDifficulty( *i ); Difficulty d = StringToDifficulty( i );
if( d == Difficulty_Invalid ) if( d == Difficulty_Invalid )
{ {
LuaHelpers::ReportScriptErrorFmt("Unknown difficulty \"%s\" in CourseDifficultiesToShow.", i->c_str()); LuaHelpers::ReportScriptErrorFmt("Unknown difficulty \"%s\" in CourseDifficultiesToShow.", i.c_str());
} }
else else
{ {
@@ -84,12 +84,12 @@ void ThemeMetricCourseDifficultiesToShow::Read()
return; return;
} }
FOREACH_CONST( RString, v, i ) for (RString const &i : v)
{ {
CourseDifficulty d = StringToDifficulty( *i ); CourseDifficulty d = StringToDifficulty( i );
if( d == Difficulty_Invalid ) if( d == Difficulty_Invalid )
{ {
LuaHelpers::ReportScriptErrorFmt("Unknown CourseDifficulty \"%s\" in CourseDifficultiesToShow.", i->c_str()); LuaHelpers::ReportScriptErrorFmt("Unknown CourseDifficulty \"%s\" in CourseDifficultiesToShow.", i.c_str());
} }
else else
{ {
@@ -106,12 +106,12 @@ static void RemoveStepsTypes( vector<StepsType>& inout, RString sStepsTypesToRem
if( v.size() == 0 ) return; // Nothing to do! if( v.size() == 0 ) return; // Nothing to do!
// subtract StepsTypes // subtract StepsTypes
FOREACH_CONST( RString, v, i ) for (RString const &i : v)
{ {
StepsType st = GAMEMAN->StringToStepsType(*i); StepsType st = GAMEMAN->StringToStepsType(i);
if( st == StepsType_Invalid ) if( st == StepsType_Invalid )
{ {
LuaHelpers::ReportScriptErrorFmt( "Invalid StepsType value '%s' in '%s'", i->c_str(), sStepsTypesToRemove.c_str() ); LuaHelpers::ReportScriptErrorFmt( "Invalid StepsType value '%s' in '%s'", i.c_str(), sStepsTypesToRemove.c_str() );
continue; continue;
} }
+44 -54
View File
@@ -2,7 +2,7 @@
#include "global.h" #include "global.h"
#include "Course.h" #include "Course.h"
#include "CourseLoaderCRS.h" #include "CourseLoaderCRS.h"
#include "Foreach.h"
#include "GameManager.h" #include "GameManager.h"
#include "GameState.h" #include "GameState.h"
#include "LocalizedString.h" #include "LocalizedString.h"
@@ -266,7 +266,7 @@ RString Course::GetTranslitFullTitle() const
/* This is called by many simple functions, like Course::GetTotalSeconds, and may /* This is called by many simple functions, like Course::GetTotalSeconds, and may
* be called on all songs to sort. It can take time to execute, so we cache the * be called on all songs to sort. It can take time to execute, so we cache the
* results. Returned pointers remain valid for the lifetime of the Course. If the * results. Returned pointers remain valid for the lifetime of the Course. If the
* course difficulty doesn't exist, NULL is returned. */ * course difficulty doesn't exist, nullptr is returned. */
Trail* Course::GetTrail( StepsType st, CourseDifficulty cd ) const Trail* Course::GetTrail( StepsType st, CourseDifficulty cd ) const
{ {
ASSERT( cd != Difficulty_Invalid ); ASSERT( cd != Difficulty_Invalid );
@@ -285,7 +285,7 @@ Trail* Course::GetTrail( StepsType st, CourseDifficulty cd ) const
{ {
CacheData &cache = it->second; CacheData &cache = it->second;
if( cache.null ) if( cache.null )
return NULL; return nullptr;
return &cache.trail; return &cache.trail;
} }
} }
@@ -303,7 +303,7 @@ Trail* Course::GetTrailForceRegenCache( StepsType st, CourseDifficulty cd ) cons
{ {
// This course difficulty doesn't exist. // This course difficulty doesn't exist.
cache.null = true; cache.null = true;
return NULL; return nullptr;
} }
// If we have cached RadarValues for this trail, insert them. // If we have cached RadarValues for this trail, insert them.
@@ -455,7 +455,7 @@ bool Course::GetTrailUnsorted( StepsType st, CourseDifficulty cd, Trail &trail )
else else
{ {
vector<SongAndSteps> vSongAndSteps; vector<SongAndSteps> vSongAndSteps;
FOREACH_CONST( CourseEntry, entries, e ) for (std::vector<CourseEntry>::const_iterator e = entries.begin(); e != entries.end(); ++e)
{ {
SongAndSteps resolved; // fill this in SongAndSteps resolved; // fill this in
SongCriteria soc = e->songCriteria; SongCriteria soc = e->songCriteria;
@@ -504,7 +504,7 @@ bool Course::GetTrailUnsorted( StepsType st, CourseDifficulty cd, Trail &trail )
vector<Song*> vpSongs; vector<Song*> vpSongs;
typedef vector<Steps*> StepsVector; typedef vector<Steps*> StepsVector;
map<Song*, StepsVector> mapSongToSteps; map<Song*, StepsVector> mapSongToSteps;
FOREACH_CONST( SongAndSteps, vSongAndSteps, sas ) for (std::vector<SongAndSteps>::const_iterator sas = vSongAndSteps.begin(); sas != vSongAndSteps.end(); ++sas)
{ {
StepsVector &v = mapSongToSteps[ sas->pSong ]; StepsVector &v = mapSongToSteps[ sas->pSong ];
@@ -658,7 +658,8 @@ void Course::GetTrailUnsortedEndless( const vector<CourseEntry> &entries, Trail
map<Song*, StepsVector> mapSongToSteps; map<Song*, StepsVector> mapSongToSteps;
int songIndex = 0; int songIndex = 0;
bool vpSongsSorted = false; bool vpSongsSorted = false;
FOREACH_CONST( CourseEntry, entries, e ) // Resolve each entry to a Song and Steps.
for (std::vector<CourseEntry>::const_iterator e = entries.begin(); e != entries.end(); ++e)
{ {
SongAndSteps resolved; // fill this in SongAndSteps resolved; // fill this in
@@ -698,12 +699,15 @@ void Course::GetTrailUnsortedEndless( const vector<CourseEntry> &entries, Trail
continue; continue;
if( !vpSongsSorted && !vSongAndSteps.empty() ) { if( !vpSongsSorted && !vSongAndSteps.empty() ) {
FOREACH_CONST( SongAndSteps, vSongAndSteps, sas ) vector<Song*> vpSongs;
typedef vector<Steps*> StepsVector;
map<Song*,StepsVector> mapSongToSteps;
for (SongAndSteps const &sas : vSongAndSteps)
{ {
StepsVector &v = mapSongToSteps[ sas->pSong ]; StepsVector &v = mapSongToSteps[sas.pSong];
v.push_back( sas->pSteps ); v.push_back( sas.pSteps );
if( v.size() == 1 ) if( v.size() == 1 )
vpSongs.push_back( sas->pSong ); vpSongs.push_back( sas.pSong );
} }
vpSongsSorted = true; vpSongsSorted = true;
CourseSortSongs( e->songSort, vpSongs, rnd ); CourseSortSongs( e->songSort, vpSongs, rnd );
@@ -711,7 +715,7 @@ void Course::GetTrailUnsortedEndless( const vector<CourseEntry> &entries, Trail
} }
ASSERT( e->iChooseIndex >= 0 ); ASSERT( e->iChooseIndex >= 0 );
if( e->iChooseIndex < int( vSongAndSteps.size() ) ) if( e->iChooseIndex < static_cast<int>(vSongAndSteps.size()) )
{ {
if( songIndex >= int(vpSongs.size()) ) { if( songIndex >= int(vpSongs.size()) ) {
songIndex = 0; songIndex = 0;
@@ -841,7 +845,7 @@ void Course::GetTrails( vector<Trail*> &AddTo, StepsType st ) const
FOREACH_ShownCourseDifficulty( cd ) FOREACH_ShownCourseDifficulty( cd )
{ {
Trail *pTrail = GetTrail( st, cd ); Trail *pTrail = GetTrail( st, cd );
if( pTrail == NULL ) if( pTrail == nullptr )
continue; continue;
AddTo.push_back( pTrail ); AddTo.push_back( pTrail );
} }
@@ -851,9 +855,9 @@ void Course::GetAllTrails( vector<Trail*> &AddTo ) const
{ {
vector<StepsType> vStepsTypesToShow; vector<StepsType> vStepsTypesToShow;
GAMEMAN->GetStepsTypesForGame( GAMESTATE->m_pCurGame, vStepsTypesToShow ); GAMEMAN->GetStepsTypesForGame( GAMESTATE->m_pCurGame, vStepsTypesToShow );
FOREACH( StepsType, vStepsTypesToShow, st ) for (StepsType const &st : vStepsTypesToShow)
{ {
GetTrails( AddTo, *st ); GetTrails( AddTo, st );
} }
} }
@@ -862,20 +866,14 @@ int Course::GetMeter( StepsType st, CourseDifficulty cd ) const
if( m_iCustomMeter[cd] != -1 ) if( m_iCustomMeter[cd] != -1 )
return m_iCustomMeter[cd]; return m_iCustomMeter[cd];
const Trail* pTrail = GetTrail( st ); const Trail* pTrail = GetTrail( st );
if( pTrail != NULL ) if( pTrail != nullptr )
return pTrail->GetMeter(); return pTrail->GetMeter();
return 0; return 0;
} }
bool Course::HasMods() const bool Course::HasMods() const
{ {
FOREACH_CONST( CourseEntry, m_vEntries, e ) return std::any_of(m_vEntries.begin(), m_vEntries.end(), [](CourseEntry const &e) { return !e.attacks.empty(); });
{
if( !e->attacks.empty() )
return true;
}
return false;
} }
bool Course::HasTimedMods() const bool Course::HasTimedMods() const
@@ -884,16 +882,15 @@ bool Course::HasTimedMods() const
// HasTimedMods now searches for bGlobal in the attacks; if one of // HasTimedMods now searches for bGlobal in the attacks; if one of
// them is false, it has timed mods. Also returning false will probably // them is false, it has timed mods. Also returning false will probably
// take longer than expected. -aj // take longer than expected. -aj
FOREACH_CONST( CourseEntry, m_vEntries, e ) for (CourseEntry const &e : m_vEntries)
{ {
if( !e->attacks.empty() ) if( e.attacks.empty() )
{ {
for( unsigned s=0; s < e->attacks.size(); s++ ) continue;
{
const Attack attack = e->attacks[s];
if(!attack.bGlobal)
return true;
} }
if (std::any_of(e.attacks.begin(), e.attacks.end(), [](Attack const &a) { return !a.bGlobal; }))
{
return true;
} }
} }
return false; return false;
@@ -901,12 +898,7 @@ bool Course::HasTimedMods() const
bool Course::AllSongsAreFixed() const bool Course::AllSongsAreFixed() const
{ {
FOREACH_CONST( CourseEntry, m_vEntries, e ) return std::all_of(m_vEntries.begin(), m_vEntries.end(), [](CourseEntry const &e) { return e.IsFixedSong(); });
{
if( !e->IsFixedSong() )
return false;
}
return true;
} }
const Style *Course::GetCourseStyle( const Game *pGame, int iNumPlayers ) const const Style *Course::GetCourseStyle( const Game *pGame, int iNumPlayers ) const
@@ -914,16 +906,15 @@ const Style *Course::GetCourseStyle( const Game *pGame, int iNumPlayers ) const
vector<const Style*> vpStyles; vector<const Style*> vpStyles;
GAMEMAN->GetCompatibleStyles( pGame, iNumPlayers, vpStyles ); GAMEMAN->GetCompatibleStyles( pGame, iNumPlayers, vpStyles );
for( int s=0; s < (int) vpStyles.size(); ++s ) for (Style const *pStyle : vpStyles)
{ {
const Style *pStyle = vpStyles[s]; for (RString const &style : m_setStyles)
FOREACHS_CONST( RString, m_setStyles, style )
{ {
if( !style->CompareNoCase(pStyle->m_szName) ) if( !style.CompareNoCase(pStyle->m_szName) )
return pStyle; return pStyle;
} }
} }
return NULL; return nullptr;
} }
void Course::InvalidateTrailCache() void Course::InvalidateTrailCache()
@@ -933,9 +924,9 @@ void Course::InvalidateTrailCache()
void Course::Invalidate( const Song *pStaleSong ) void Course::Invalidate( const Song *pStaleSong )
{ {
FOREACH_CONST( CourseEntry, m_vEntries, e ) for (CourseEntry const &e : m_vEntries)
{ {
Song *pSong = e->songID.ToSong(); Song *pSong = e.songID.ToSong();
if( pSong == pStaleSong ) // a fixed entry that references the stale Song if( pSong == pStaleSong ) // a fixed entry that references the stale Song
{ {
RevertFromDisk(); RevertFromDisk();
@@ -971,9 +962,9 @@ void Course::RegenerateNonFixedTrails() const
if( AllSongsAreFixed() ) if( AllSongsAreFixed() )
return; return;
FOREACHM( CacheEntry, CacheData, m_TrailCache, e ) for (auto const & e: m_TrailCache)
{ {
const CacheEntry &ce = e->first; const CacheEntry &ce = e.first;
GetTrailForceRegenCache( ce.first, ce.second ); GetTrailForceRegenCache( ce.first, ce.second );
} }
} }
@@ -1046,11 +1037,11 @@ bool Course::GetTotalSeconds( StepsType st, float& fSecondsOut ) const
bool Course::CourseHasBestOrWorst() const bool Course::CourseHasBestOrWorst() const
{ {
FOREACH_CONST( CourseEntry, m_vEntries, e ) for (CourseEntry const &e : m_vEntries)
{ {
if( e->songSort == SongSort_MostPlays && e->iChooseIndex != -1 ) if( e.songSort == SongSort_MostPlays && e.iChooseIndex != -1 )
return true; return true;
if( e->songSort == SongSort_FewestPlays && e->iChooseIndex != -1 ) if( e.songSort == SongSort_FewestPlays && e.iChooseIndex != -1 )
return true; return true;
} }
@@ -1093,7 +1084,7 @@ void Course::UpdateCourseStats( StepsType st )
for(unsigned i = 0; i < m_vEntries.size(); i++) for(unsigned i = 0; i < m_vEntries.size(); i++)
{ {
Song *pSong = m_vEntries[i].songID.ToSong(); Song *pSong = m_vEntries[i].songID.ToSong();
if( pSong != NULL ) if( pSong != nullptr )
continue; continue;
if ( m_SortOrder_Ranking == 2 ) if ( m_SortOrder_Ranking == 2 )
@@ -1104,7 +1095,7 @@ void Course::UpdateCourseStats( StepsType st )
const Trail* pTrail = GetTrail( st, Difficulty_Medium ); const Trail* pTrail = GetTrail( st, Difficulty_Medium );
m_SortOrder_TotalDifficulty += pTrail != NULL? pTrail->GetTotalMeter():0; m_SortOrder_TotalDifficulty += pTrail != nullptr? pTrail->GetTotalMeter():0;
// OPTIMIZATION: Ranking info isn't dependent on style, so call it // OPTIMIZATION: Ranking info isn't dependent on style, so call it
// sparingly. It's handled on startup and when themes change. // sparingly. It's handled on startup and when themes change.
@@ -1129,15 +1120,14 @@ bool Course::IsRanking() const
const CourseEntry *Course::FindFixedSong( const Song *pSong ) const const CourseEntry *Course::FindFixedSong( const Song *pSong ) const
{ {
FOREACH_CONST( CourseEntry, m_vEntries, e ) for (CourseEntry const &entry : m_vEntries)
{ {
const CourseEntry &entry = *e;
Song *lSong = entry.songID.ToSong(); Song *lSong = entry.songID.ToSong();
if( pSong == lSong ) if( pSong == lSong )
return &entry; return &entry;
} }
return NULL; return nullptr;
} }
void Course::GetAllCachedTrails( vector<Trail *> &out ) void Course::GetAllCachedTrails( vector<Trail *> &out )
@@ -1169,7 +1159,7 @@ void Course::CalculateRadarValues()
if( AllSongsAreFixed() ) if( AllSongsAreFixed() )
{ {
Trail *pTrail = GetTrail( st, cd ); Trail *pTrail = GetTrail( st, cd );
if( pTrail == NULL ) if( pTrail == nullptr )
continue; continue;
RadarValues rv = pTrail->GetRadarValues(); RadarValues rv = pTrail->GetRadarValues();
m_RadarCache[CacheEntry(st, cd)] = rv; m_RadarCache[CacheEntry(st, cd)] = rv;
+7 -7
View File
@@ -14,8 +14,8 @@ REGISTER_ACTOR_CLASS( CourseContentsList );
CourseContentsList::~CourseContentsList() CourseContentsList::~CourseContentsList()
{ {
FOREACH( Actor *, m_vpDisplay, d ) for (Actor *d : m_vpDisplay)
delete *d; delete d;
m_vpDisplay.clear(); m_vpDisplay.clear();
} }
@@ -25,7 +25,7 @@ void CourseContentsList::LoadFromNode( const XNode* pNode )
pNode->GetAttrValue( "MaxSongs", iMaxSongs ); pNode->GetAttrValue( "MaxSongs", iMaxSongs );
const XNode *pDisplayNode = pNode->GetChild( "Display" ); const XNode *pDisplayNode = pNode->GetChild( "Display" );
if( pDisplayNode == NULL ) if( pDisplayNode == nullptr )
{ {
LuaHelpers::ReportScriptErrorFmt("%s: CourseContentsList: missing the Display child", ActorUtil::GetWhere(pNode).c_str()); LuaHelpers::ReportScriptErrorFmt("%s: CourseContentsList: missing the Display child", ActorUtil::GetWhere(pNode).c_str());
return; return;
@@ -48,7 +48,7 @@ void CourseContentsList::SetFromGameState()
if( GAMESTATE->GetMasterPlayerNumber() == PlayerNumber_Invalid ) if( GAMESTATE->GetMasterPlayerNumber() == PlayerNumber_Invalid )
return; return;
const Trail *pMasterTrail = GAMESTATE->m_pCurTrail[GAMESTATE->GetMasterPlayerNumber()]; const Trail *pMasterTrail = GAMESTATE->m_pCurTrail[GAMESTATE->GetMasterPlayerNumber()];
if( pMasterTrail == NULL ) if( pMasterTrail == nullptr )
return; return;
unsigned uNumEntriesToShow = pMasterTrail->m_vEntries.size(); unsigned uNumEntriesToShow = pMasterTrail->m_vEntries.size();
CLAMP( uNumEntriesToShow, 0, m_vpDisplay.size() ); CLAMP( uNumEntriesToShow, 0, m_vpDisplay.size() );
@@ -81,21 +81,21 @@ void CourseContentsList::SetItemFromGameState( Actor *pActor, int iCourseEntryIn
FOREACH_HumanPlayer(pn) FOREACH_HumanPlayer(pn)
{ {
const Trail *pTrail = GAMESTATE->m_pCurTrail[pn]; const Trail *pTrail = GAMESTATE->m_pCurTrail[pn];
if( pTrail == NULL if( pTrail == nullptr
|| iCourseEntryIndex >= (int) pTrail->m_vEntries.size() || iCourseEntryIndex >= (int) pTrail->m_vEntries.size()
|| iCourseEntryIndex >= (int) pCourse->m_vEntries.size() ) || iCourseEntryIndex >= (int) pCourse->m_vEntries.size() )
continue; continue;
const TrailEntry *te = &pTrail->m_vEntries[iCourseEntryIndex]; const TrailEntry *te = &pTrail->m_vEntries[iCourseEntryIndex];
const CourseEntry *ce = &pCourse->m_vEntries[iCourseEntryIndex]; const CourseEntry *ce = &pCourse->m_vEntries[iCourseEntryIndex];
if( te == NULL ) if( te == nullptr )
continue; continue;
RString s; RString s;
Difficulty dc; Difficulty dc;
if( te->bSecret ) if( te->bSecret )
{ {
if( ce == NULL ) if( ce == nullptr )
continue; continue;
int iLow = ce->stepsCriteria.m_iLowMeter; int iLow = ce->stepsCriteria.m_iLowMeter;
+14 -14
View File
@@ -87,7 +87,7 @@ bool CourseLoaderCRS::LoadFromMsd( const RString &sPath, const MsdFile &msd, Cou
} }
else if( sValueName.EqualsNoCase("LIVES") ) else if( sValueName.EqualsNoCase("LIVES") )
{ {
out.m_iLives = max( StringToInt(sParams[1]), 0 ); out.m_iLives = max( std::stoi(sParams[1]), 0 );
} }
else if( sValueName.EqualsNoCase("GAINSECONDS") ) else if( sValueName.EqualsNoCase("GAINSECONDS") )
{ {
@@ -97,7 +97,7 @@ bool CourseLoaderCRS::LoadFromMsd( const RString &sPath, const MsdFile &msd, Cou
{ {
if( sParams.params.size() == 2 ) if( sParams.params.size() == 2 )
{ {
out.m_iCustomMeter[Difficulty_Medium] = max( StringToInt(sParams[1]), 0 ); /* compat */ out.m_iCustomMeter[Difficulty_Medium] = max( std::stoi(sParams[1]), 0 ); /* compat */
} }
else if( sParams.params.size() == 3 ) else if( sParams.params.size() == 3 )
{ {
@@ -107,7 +107,7 @@ bool CourseLoaderCRS::LoadFromMsd( const RString &sPath, const MsdFile &msd, Cou
LOG->UserLog( "Course file", sPath, "contains an invalid #METER string: \"%s\"", sParams[1].c_str() ); LOG->UserLog( "Course file", sPath, "contains an invalid #METER string: \"%s\"", sParams[1].c_str() );
continue; continue;
} }
out.m_iCustomMeter[cd] = max( StringToInt(sParams[2]), 0 ); out.m_iCustomMeter[cd] = max( std::stoi(sParams[2]), 0 );
} }
} }
@@ -168,7 +168,7 @@ bool CourseLoaderCRS::LoadFromMsd( const RString &sPath, const MsdFile &msd, Cou
// most played // most played
if( sParams[1].Left(strlen("BEST")) == "BEST" ) if( sParams[1].Left(strlen("BEST")) == "BEST" )
{ {
int iChooseIndex = StringToInt( sParams[1].Right(sParams[1].size()-strlen("BEST")) ) - 1; int iChooseIndex = std::stoi( sParams[1].Right(sParams[1].size()-strlen("BEST")) ) - 1;
if( iChooseIndex > iNumSongs ) if( iChooseIndex > iNumSongs )
{ {
// looking up a song that doesn't exist. // looking up a song that doesn't exist.
@@ -185,7 +185,7 @@ bool CourseLoaderCRS::LoadFromMsd( const RString &sPath, const MsdFile &msd, Cou
// least played // least played
else if( sParams[1].Left(strlen("WORST")) == "WORST" ) else if( sParams[1].Left(strlen("WORST")) == "WORST" )
{ {
int iChooseIndex = StringToInt( sParams[1].Right(sParams[1].size()-strlen("WORST")) ) - 1; int iChooseIndex = std::stoi( sParams[1].Right(sParams[1].size()-strlen("WORST")) ) - 1;
if( iChooseIndex > iNumSongs ) if( iChooseIndex > iNumSongs )
{ {
// looking up a song that doesn't exist. // looking up a song that doesn't exist.
@@ -202,14 +202,14 @@ bool CourseLoaderCRS::LoadFromMsd( const RString &sPath, const MsdFile &msd, Cou
// best grades // best grades
else if( sParams[1].Left(strlen("GRADEBEST")) == "GRADEBEST" ) else if( sParams[1].Left(strlen("GRADEBEST")) == "GRADEBEST" )
{ {
new_entry.iChooseIndex = StringToInt( sParams[1].Right(sParams[1].size()-strlen("GRADEBEST")) ) - 1; new_entry.iChooseIndex = std::stoi( sParams[1].Right(sParams[1].size()-strlen("GRADEBEST")) ) - 1;
CLAMP( new_entry.iChooseIndex, 0, 500 ); CLAMP( new_entry.iChooseIndex, 0, 500 );
new_entry.songSort = SongSort_TopGrades; new_entry.songSort = SongSort_TopGrades;
} }
// worst grades // worst grades
else if( sParams[1].Left(strlen("GRADEWORST")) == "GRADEWORST" ) else if( sParams[1].Left(strlen("GRADEWORST")) == "GRADEWORST" )
{ {
new_entry.iChooseIndex = StringToInt( sParams[1].Right(sParams[1].size()-strlen("GRADEWORST")) ) - 1; new_entry.iChooseIndex = std::stoi( sParams[1].Right(sParams[1].size()-strlen("GRADEWORST")) ) - 1;
CLAMP( new_entry.iChooseIndex, 0, 500 ); CLAMP( new_entry.iChooseIndex, 0, 500 );
new_entry.songSort = SongSort_LowestGrades; new_entry.songSort = SongSort_LowestGrades;
} }
@@ -250,7 +250,7 @@ bool CourseLoaderCRS::LoadFromMsd( const RString &sPath, const MsdFile &msd, Cou
vector<RString> bits; vector<RString> bits;
split( sSong, "/", bits ); split( sSong, "/", bits );
Song *pSong = NULL; Song *pSong = nullptr;
if( bits.size() == 2 ) if( bits.size() == 2 )
{ {
new_entry.songCriteria.m_sGroupName = bits[0]; new_entry.songCriteria.m_sGroupName = bits[0];
@@ -262,7 +262,7 @@ bool CourseLoaderCRS::LoadFromMsd( const RString &sPath, const MsdFile &msd, Cou
} }
new_entry.songID.FromSong( pSong ); new_entry.songID.FromSong( pSong );
if( pSong == NULL ) if( pSong == nullptr )
{ {
LOG->UserLog( "Course file", sPath, "contains a fixed song entry \"%s\" that does not exist. " LOG->UserLog( "Course file", sPath, "contains a fixed song entry \"%s\" that does not exist. "
"This entry will be ignored.", sSong.c_str()); "This entry will be ignored.", sSong.c_str());
@@ -308,7 +308,7 @@ bool CourseLoaderCRS::LoadFromMsd( const RString &sPath, const MsdFile &msd, Cou
else if( !sMod.CompareNoCase("nodifficult") ) else if( !sMod.CompareNoCase("nodifficult") )
new_entry.bNoDifficult = true; new_entry.bNoDifficult = true;
else if( sMod.length() > 5 && !sMod.Left(5).CompareNoCase("award") ) else if( sMod.length() > 5 && !sMod.Left(5).CompareNoCase("award") )
new_entry.iGainLives = StringToInt( sMod.substr(5) ); new_entry.iGainLives = std::stoi( sMod.substr(5) );
else else
continue; continue;
mods.erase( mods.begin() + j ); mods.erase( mods.begin() + j );
@@ -330,8 +330,8 @@ bool CourseLoaderCRS::LoadFromMsd( const RString &sPath, const MsdFile &msd, Cou
else if( bFromCache && !sValueName.EqualsNoCase("RADAR") ) else if( bFromCache && !sValueName.EqualsNoCase("RADAR") )
{ {
StepsType st = (StepsType) StringToInt(sParams[1]); StepsType st = (StepsType) std::stoi(sParams[1]);
CourseDifficulty cd = (CourseDifficulty) StringToInt( sParams[2] ); CourseDifficulty cd = (CourseDifficulty) std::stoi( sParams[2] );
RadarValues rv; RadarValues rv;
rv.FromString( sParams[3] ); rv.FromString( sParams[3] );
@@ -342,8 +342,8 @@ bool CourseLoaderCRS::LoadFromMsd( const RString &sPath, const MsdFile &msd, Cou
RString sStyles = sParams[1]; RString sStyles = sParams[1];
vector<RString> asStyles; vector<RString> asStyles;
split( sStyles, ",", asStyles ); split( sStyles, ",", asStyles );
FOREACH( RString, asStyles, s ) for (RString const &s : asStyles)
out.m_setStyles.insert( *s ); out.m_setStyles.insert( s );
} }
else else
+25 -34
View File
@@ -8,7 +8,7 @@
#include "XmlFile.h" #include "XmlFile.h"
#include "GameState.h" #include "GameState.h"
#include "Style.h" #include "Style.h"
#include "Foreach.h"
#include "GameState.h" #include "GameState.h"
#include "LocalizedString.h" #include "LocalizedString.h"
#include "RageLog.h" #include "RageLog.h"
@@ -110,7 +110,7 @@ void CourseUtil::SortCoursePointerArrayByTotalDifficulty( vector<Course*> &vpCou
#if 0 #if 0
RString GetSectionNameFromCourseAndSort( const Course *pCourse, SortOrder so ) RString GetSectionNameFromCourseAndSort( const Course *pCourse, SortOrder so )
{ {
if( pCourse == NULL ) if( pCourse == nullptr )
return RString(); return RString();
// more code here // more code here
} }
@@ -195,7 +195,7 @@ void CourseUtil::SortCoursePointerArrayByNumPlays( vector<Course*> &vpCoursesInO
void CourseUtil::SortCoursePointerArrayByNumPlays( vector<Course*> &vpCoursesInOut, const Profile* pProfile, bool bDescending ) void CourseUtil::SortCoursePointerArrayByNumPlays( vector<Course*> &vpCoursesInOut, const Profile* pProfile, bool bDescending )
{ {
ASSERT( pProfile != NULL ); ASSERT( pProfile != nullptr );
for(unsigned i = 0; i < vpCoursesInOut.size(); ++i) for(unsigned i = 0; i < vpCoursesInOut.size(); ++i)
course_sort_val[vpCoursesInOut[i]] = ssprintf( "%09i", pProfile->GetCourseNumTimesPlayed(vpCoursesInOut[i]) ); course_sort_val[vpCoursesInOut[i]] = ssprintf( "%09i", pProfile->GetCourseNumTimesPlayed(vpCoursesInOut[i]) );
stable_sort( vpCoursesInOut.begin(), vpCoursesInOut.end(), bDescending ? CompareCoursePointersBySortValueDescending : CompareCoursePointersBySortValueAscending ); stable_sort( vpCoursesInOut.begin(), vpCoursesInOut.end(), bDescending ? CompareCoursePointersBySortValueDescending : CompareCoursePointersBySortValueAscending );
@@ -206,11 +206,11 @@ void CourseUtil::SortByMostRecentlyPlayedForMachine( vector<Course*> &vpCoursesI
{ {
Profile *pProfile = PROFILEMAN->GetMachineProfile(); Profile *pProfile = PROFILEMAN->GetMachineProfile();
FOREACH_CONST( Course*, vpCoursesInOut, c ) for (Course const * c: vpCoursesInOut)
{ {
int iNumTimesPlayed = pProfile->GetCourseNumTimesPlayed( *c ); int iNumTimesPlayed = pProfile->GetCourseNumTimesPlayed( c );
RString val = iNumTimesPlayed ? pProfile->GetCourseLastPlayedDateTime(*c).GetString() : "9999999999999"; RString val = iNumTimesPlayed ? pProfile->GetCourseLastPlayedDateTime(c).GetString() : "9999999999999";
course_sort_val[*c] = val; course_sort_val[c] = val;
} }
stable_sort( vpCoursesInOut.begin(), vpCoursesInOut.end(), CompareCoursePointersBySortValueAscending ); stable_sort( vpCoursesInOut.begin(), vpCoursesInOut.end(), CompareCoursePointersBySortValueAscending );
@@ -327,12 +327,12 @@ void CourseUtil::WarnOnInvalidMods( RString sMods )
SongOptions so; SongOptions so;
vector<RString> vs; vector<RString> vs;
split( sMods, ",", vs, true ); split( sMods, ",", vs, true );
FOREACH_CONST( RString, vs, s ) for (RString const &s : vs)
{ {
bool bValid = false; bool bValid = false;
RString sErrorDetail; RString sErrorDetail;
bValid |= po.FromOneModString( *s, sErrorDetail ); bValid |= po.FromOneModString( s, sErrorDetail );
bValid |= so.FromOneModString( *s, sErrorDetail ); bValid |= so.FromOneModString( s, sErrorDetail );
/* ==Invalid options that used to be valid== /* ==Invalid options that used to be valid==
* all noteskins (solo, note, foon, &c.) * all noteskins (solo, note, foon, &c.)
* protiming (done in Lua now) * protiming (done in Lua now)
@@ -346,7 +346,7 @@ void CourseUtil::WarnOnInvalidMods( RString sMods )
*/ */
if( !bValid ) if( !bValid )
{ {
RString sFullError = ssprintf("Error processing '%s' in '%s'", (*s).c_str(), sMods.c_str() ); RString sFullError = ssprintf("Error processing '%s' in '%s'", s.c_str(), sMods.c_str() );
if( !sErrorDetail.empty() ) if( !sErrorDetail.empty() )
sFullError += ": " + sErrorDetail; sFullError += ": " + sErrorDetail;
LOG->UserLog( "", "", "%s", sFullError.c_str() ); LOG->UserLog( "", "", "%s", sFullError.c_str() );
@@ -422,7 +422,7 @@ bool EditCourseUtil::ValidateEditCourseName( const RString &sAnswer, RString &sE
} }
static const RString sInvalidChars = "\\/:*?\"<>|"; static const RString sInvalidChars = "\\/:*?\"<>|";
if( strpbrk(sAnswer, sInvalidChars) != NULL ) if( strpbrk(sAnswer, sInvalidChars) != nullptr )
{ {
sErrorOut = ssprintf( EDIT_NAME_CANNOT_CONTAIN.GetValue(), sInvalidChars.c_str() ); sErrorOut = ssprintf( EDIT_NAME_CANNOT_CONTAIN.GetValue(), sInvalidChars.c_str() );
return false; return false;
@@ -431,12 +431,12 @@ bool EditCourseUtil::ValidateEditCourseName( const RString &sAnswer, RString &sE
// Check for name conflicts // Check for name conflicts
vector<Course*> vpCourses; vector<Course*> vpCourses;
EditCourseUtil::GetAllEditCourses( vpCourses ); EditCourseUtil::GetAllEditCourses( vpCourses );
FOREACH_CONST( Course*, vpCourses, p ) for (Course const *p : vpCourses)
{ {
if( GAMESTATE->m_pCurCourse == *p ) if( GAMESTATE->m_pCurCourse == p )
continue; // don't comepare name against ourself continue; // don't comepare name against ourself
if( (*p)->GetDisplayFullTitle() == sAnswer ) if( p->GetDisplayFullTitle() == sAnswer )
{ {
sErrorOut = EDIT_NAME_CONFLICTS; sErrorOut = EDIT_NAME_CONFLICTS;
return false; return false;
@@ -448,9 +448,9 @@ bool EditCourseUtil::ValidateEditCourseName( const RString &sAnswer, RString &sE
void EditCourseUtil::UpdateAndSetTrail() void EditCourseUtil::UpdateAndSetTrail()
{ {
ASSERT( GAMESTATE->GetCurrentStyle(PLAYER_INVALID) != NULL ); ASSERT( GAMESTATE->GetCurrentStyle(PLAYER_INVALID) != nullptr );
StepsType st = GAMESTATE->GetCurrentStyle(PLAYER_INVALID)->m_StepsType; StepsType st = GAMESTATE->GetCurrentStyle(PLAYER_INVALID)->m_StepsType;
Trail *pTrail = NULL; Trail *pTrail = nullptr;
if( GAMESTATE->m_pCurCourse ) if( GAMESTATE->m_pCurCourse )
pTrail = GAMESTATE->m_pCurCourse->GetTrailForceRegenCache( st ); pTrail = GAMESTATE->m_pCurCourse->GetTrailForceRegenCache( st );
GAMESTATE->m_pCurTrail[PLAYER_1].Set( pTrail ); GAMESTATE->m_pCurTrail[PLAYER_1].Set( pTrail );
@@ -458,7 +458,7 @@ void EditCourseUtil::UpdateAndSetTrail()
void EditCourseUtil::PrepareForPlay() void EditCourseUtil::PrepareForPlay()
{ {
GAMESTATE->m_pCurSong.Set( NULL ); // CurSong will be set if we back out. Set it back to NULL so that ScreenStage won't show the last song. GAMESTATE->m_pCurSong.Set(nullptr); // CurSong will be set if we back out. Set it back to nullptr so that ScreenStage won't show the last song.
GAMESTATE->m_PlayMode.Set( PLAY_MODE_ENDLESS ); GAMESTATE->m_PlayMode.Set( PLAY_MODE_ENDLESS );
GAMESTATE->m_bSideIsJoined[0] = true; GAMESTATE->m_bSideIsJoined[0] = true;
@@ -471,10 +471,10 @@ void EditCourseUtil::GetAllEditCourses( vector<Course*> &vpCoursesOut )
{ {
vector<Course*> vpCoursesTemp; vector<Course*> vpCoursesTemp;
SONGMAN->GetAllCourses( vpCoursesTemp, false ); SONGMAN->GetAllCourses( vpCoursesTemp, false );
FOREACH_CONST( Course*, vpCoursesTemp, c ) for (Course *c : vpCoursesTemp)
{ {
if( (*c)->GetLoadedFromProfileSlot() != ProfileSlot_Invalid ) if( c->GetLoadedFromProfileSlot() != ProfileSlot_Invalid )
vpCoursesOut.push_back( *c ); vpCoursesOut.push_back( c );
} }
} }
@@ -489,20 +489,11 @@ void EditCourseUtil::LoadDefaults( Course &out )
for( int i=0; i<10000; i++ ) for( int i=0; i<10000; i++ )
{ {
out.m_sMainTitle = ssprintf("Workout %d", i+1); out.m_sMainTitle = ssprintf("Workout %d", i+1);
bool bNameInUse = false;
vector<Course*> vpCourses; vector<Course*> vpCourses;
EditCourseUtil::GetAllEditCourses( vpCourses ); EditCourseUtil::GetAllEditCourses( vpCourses );
FOREACH_CONST( Course*, vpCourses, p )
{
if( out.m_sMainTitle == (*p)->m_sMainTitle )
{
bNameInUse = true;
break;
}
}
if( !bNameInUse ) if (std::any_of(vpCourses.begin(), vpCourses.end(), [&](Course const *p) { return out.m_sMainTitle == p->m_sMainTitle; }))
break; break;
} }
@@ -552,7 +543,7 @@ void CourseID::FromCourse( const Course *p )
Course *CourseID::ToCourse() const Course *CourseID::ToCourse() const
{ {
Course *pCourse = NULL; Course *pCourse = nullptr;
if(m_Cache.Get(&pCourse)) if(m_Cache.Get(&pCourse))
{ {
return pCourse; return pCourse;
@@ -567,13 +558,13 @@ Course *CourseID::ToCourse() const
slash_path = "/" + slash_path; slash_path = "/" + slash_path;
} }
if(pCourse == NULL) if(pCourse == nullptr)
{ {
pCourse = SONGMAN->GetCourseFromPath(slash_path); pCourse = SONGMAN->GetCourseFromPath(slash_path);
} }
} }
if( pCourse == NULL && !sFullTitle.empty() ) if( pCourse == nullptr && !sFullTitle.empty() )
{ {
pCourse = SONGMAN->GetCourseFromName( sFullTitle ); pCourse = SONGMAN->GetCourseFromName( sFullTitle );
} }
+1 -1
View File
@@ -73,7 +73,7 @@ class CourseID
{ {
public: public:
CourseID(): sPath(""), sFullTitle(""), m_Cache() { Unset(); } CourseID(): sPath(""), sFullTitle(""), m_Cache() { Unset(); }
void Unset() { FromCourse(NULL); } void Unset() { FromCourse(nullptr); }
void FromCourse( const Course *p ); void FromCourse( const Course *p );
Course *ToCourse() const; Course *ToCourse() const;
const RString &GetPath() const { return sPath; } const RString &GetPath() const { return sPath; }
+14 -14
View File
@@ -532,7 +532,7 @@ const ulg crc_table[256] = {
ulg crc32(ulg crc, const uch *buf, size_t len) ulg crc32(ulg crc, const uch *buf, size_t len)
{ {
if (buf==NULL) return 0L; if (buf== nullptr) return 0L;
crc = crc ^ 0xffffffffL; crc = crc ^ 0xffffffffL;
while (len >= 8) {DO8(buf); len -= 8;} while (len >= 8) {DO8(buf); len -= 8;}
if (len) do {DO1(buf);} while (--len); if (len) do {DO1(buf);} while (--len);
@@ -543,7 +543,7 @@ ulg crc32(ulg crc, const uch *buf, size_t len)
class TZip class TZip
{ {
public: public:
TZip() : pfout(NULL),ooffset(0),oerr(false),writ(0),hasputcen(false),zfis(0),hfin(0) TZip() : pfout(nullptr),ooffset(0),oerr(false),writ(0),hasputcen(false),zfis(0),hfin(0)
{ {
} }
~TZip() ~TZip()
@@ -631,7 +631,7 @@ unsigned TZip::swrite(void *param,const char *buf, unsigned size)
unsigned int TZip::write(const char *buf,unsigned int size) unsigned int TZip::write(const char *buf,unsigned int size)
{ {
const char *srcbuf=buf; const char *srcbuf=buf;
if (pfout != NULL) if (pfout != nullptr)
{ {
unsigned long writ = pfout->Write( srcbuf, size ); unsigned long writ = pfout->Write( srcbuf, size );
return writ; return writ;
@@ -717,7 +717,7 @@ ZRESULT TZip::set_times()
unsigned short dosdate,dostime; unsigned short dosdate,dostime;
filetime2dosdatetime(*ptm,&dosdate,&dostime); filetime2dosdatetime(*ptm,&dosdate,&dostime);
times.atime = time(NULL); times.atime = time(nullptr);
times.mtime = times.atime; times.mtime = times.atime;
times.ctime = times.atime; times.ctime = times.atime;
timestamp = (unsigned short)dostime | (((unsigned long)dosdate)<<16); timestamp = (unsigned short)dostime | (((unsigned long)dosdate)<<16);
@@ -826,7 +826,7 @@ ZRESULT TZip::Add(const TCHAR *odstzn, const TCHAR *src,unsigned long flags)
// then the compressed data, and possibly an extended local header. // then the compressed data, and possibly an extended local header.
// Initialize the local header // Initialize the local header
TZipFileInfo zfi; zfi.nxt=NULL; TZipFileInfo zfi; zfi.nxt=nullptr;
strcpy(zfi.name,""); strcpy(zfi.name,"");
#ifdef UNICODE #ifdef UNICODE
WideCharToMultiByte(CP_UTF8,0,dstzn,-1,zfi.iname,MAX_PATH,0,0); WideCharToMultiByte(CP_UTF8,0,dstzn,-1,zfi.iname,MAX_PATH,0,0);
@@ -840,9 +840,9 @@ ZRESULT TZip::Add(const TCHAR *odstzn, const TCHAR *src,unsigned long flags)
zfi.nam++; zfi.nam++;
} }
strcpy(zfi.zname,""); strcpy(zfi.zname,"");
zfi.extra=NULL; zfi.ext=0; // extra header to go after this compressed data, and its length zfi.extra=nullptr; zfi.ext=0; // extra header to go after this compressed data, and its length
zfi.cextra=NULL; zfi.cext=0; // extra header to go in the central end-of-zip directory, and its length zfi.cextra=nullptr; zfi.cext=0; // extra header to go in the central end-of-zip directory, and its length
zfi.comment=NULL; zfi.com=0; // comment, and its length zfi.comment=nullptr; zfi.com=0; // comment, and its length
zfi.mark = 1; zfi.mark = 1;
zfi.dosflag = 0; zfi.dosflag = 0;
zfi.att = (ush)BINARY; zfi.att = (ush)BINARY;
@@ -935,12 +935,12 @@ ZRESULT TZip::Add(const TCHAR *odstzn, const TCHAR *src,unsigned long flags)
// Keep a copy of the zipfileinfo, for our end-of-zip directory // Keep a copy of the zipfileinfo, for our end-of-zip directory
char *cextra = new char[zfi.cext]; memcpy(cextra,zfi.cextra,zfi.cext); zfi.cextra=cextra; char *cextra = new char[zfi.cext]; memcpy(cextra,zfi.cextra,zfi.cext); zfi.cextra=cextra;
TZipFileInfo *pzfi = new TZipFileInfo; memcpy(pzfi,&zfi,sizeof(zfi)); TZipFileInfo *pzfi = new TZipFileInfo; memcpy(pzfi,&zfi,sizeof(zfi));
if (zfis==NULL) if (zfis==nullptr)
zfis=pzfi; zfis=pzfi;
else else
{ {
TZipFileInfo *z=zfis; TZipFileInfo *z=zfis;
while (z->nxt!=NULL) while (z->nxt!=nullptr)
z=z->nxt; z=z->nxt;
z->nxt=pzfi; z->nxt=pzfi;
} }
@@ -954,7 +954,7 @@ ZRESULT TZip::AddCentral()
ulg pos_at_start_of_central = writ; ulg pos_at_start_of_central = writ;
//ulg tot_unc_size=0, tot_compressed_size=0; //ulg tot_unc_size=0, tot_compressed_size=0;
bool okay=true; bool okay=true;
for (TZipFileInfo *zfi=zfis; zfi!=NULL; ) for (TZipFileInfo *zfi=zfis; zfi!= nullptr; )
{ {
if (okay) if (okay)
{ {
@@ -975,7 +975,7 @@ ZRESULT TZip::AddCentral()
ulg center_size = writ - pos_at_start_of_central; ulg center_size = writ - pos_at_start_of_central;
if (okay) if (okay)
{ {
int res = putend(numentries, center_size, pos_at_start_of_central+ooffset, 0, NULL, swrite,this); int res = putend(numentries, center_size, pos_at_start_of_central+ooffset, 0, nullptr, swrite,this);
if (res!=ZE_OK) if (res!=ZE_OK)
okay=false; okay=false;
writ += 4 + ENDHEAD + 0; writ += 4 + ENDHEAD + 0;
@@ -994,7 +994,7 @@ ZRESULT lasterrorZ=ZR_OK;
CreateZip::CreateZip() CreateZip::CreateZip()
{ {
hz=NULL; hz=nullptr;
} }
bool CreateZip::Start( RageFile *f) bool CreateZip::Start( RageFile *f)
@@ -1016,7 +1016,7 @@ bool CreateZip::AddFile(RString fn)
} }
bool CreateZip::AddDir(RString fn) bool CreateZip::AddDir(RString fn)
{ {
lasterrorZ = hz->Add(MakeDestZipFileName(fn),NULL,ZIP_FOLDER); lasterrorZ = hz->Add(MakeDestZipFileName(fn),nullptr,ZIP_FOLDER);
return lasterrorZ == ZR_OK; return lasterrorZ == ZR_OK;
} }
bool CreateZip::Finish() bool CreateZip::Finish()
+4 -4
View File
@@ -49,7 +49,7 @@ public:
// char buf[1000]; for (int i=0; i<1000; i++) buf[i]=(char)(i&0x7F); // char buf[1000]; for (int i=0; i<1000; i++) buf[i]=(char)(i&0x7F);
// ZipAdd(hz,"file.dat", buf,1000); // ZipAdd(hz,"file.dat", buf,1000);
// // adding something from a pipe... // // adding something from a pipe...
// HANDLE hread,hwrite; CreatePipe(&hread,&hwrite,NULL,0); // HANDLE hread,hwrite; CreatePipe(&hread,&hwrite,nullptr,0);
// HANDLE hthread = CreateThread(0,0,ThreadFunc,(void*)hwrite,0,0); // HANDLE hthread = CreateThread(0,0,ThreadFunc,(void*)hwrite,0,0);
// ZipAdd(hz,"unz3.dat", hread,1000); // the '1000' is optional. // ZipAdd(hz,"unz3.dat", hread,1000); // the '1000' is optional.
// WaitForSingleObject(hthread,INFINITE); // WaitForSingleObject(hthread,INFINITE);
@@ -57,14 +57,14 @@ public:
// ... meanwhile DWORD WINAPI ThreadFunc(void *dat) // ... meanwhile DWORD WINAPI ThreadFunc(void *dat)
// { HANDLE hwrite = (HANDLE)dat; // { HANDLE hwrite = (HANDLE)dat;
// char buf[1000]={17}; // char buf[1000]={17};
// DWORD writ; WriteFile(hwrite,buf,1000,&writ,NULL); // DWORD writ; WriteFile(hwrite,buf,1000,&writ,nullptr);
// CloseHandle(hwrite); // CloseHandle(hwrite);
// return 0; // return 0;
// } // }
// // and now that the zip is created, let's do something with it: // // and now that the zip is created, let's do something with it:
// void *zbuf; unsigned long zlen; ZipGetMemory(hz,&zbuf,&zlen); // void *zbuf; unsigned long zlen; ZipGetMemory(hz,&zbuf,&zlen);
// HANDLE hfz = CreateFile("test2.zip",GENERIC_WRITE,0,0,CREATE_ALWAYS,FILE_ATTRIBUTE_NORMAL,0); // HANDLE hfz = CreateFile("test2.zip",GENERIC_WRITE,0,0,CREATE_ALWAYS,FILE_ATTRIBUTE_NORMAL,0);
// DWORD writ; WriteFile(hfz,zbuf,zlen,&writ,NULL); // DWORD writ; WriteFile(hfz,zbuf,zlen,&writ,nullptr);
// CloseHandle(hfz); // CloseHandle(hfz);
// CloseZip(hz); // CloseZip(hz);
// //
@@ -81,7 +81,7 @@ public:
// { HANDLE hread = (HANDLE)dat; // { HANDLE hread = (HANDLE)dat;
// char buf[1000]; // char buf[1000];
// for(;;) // for(;;)
// { DWORD red; ReadFile(hread,buf,1000,&red,NULL); // { DWORD red; ReadFile(hread,buf,1000,&red,nullptr);
// // ... and do something with this zip data we're receiving // // ... and do something with this zip data we're receiving
// if (red==0) break; // if (red==0) break;
// } // }
+2 -2
View File
@@ -6,7 +6,7 @@ PRNGWrapper::PRNGWrapper( const struct ltc_prng_descriptor *pPRNGDescriptor )
m_iPRNG = register_prng( pPRNGDescriptor ); m_iPRNG = register_prng( pPRNGDescriptor );
ASSERT( m_iPRNG >= 0 ); ASSERT( m_iPRNG >= 0 );
int iRet = rng_make_prng( 128, m_iPRNG, &m_PRNG, NULL ); int iRet = rng_make_prng( 128, m_iPRNG, &m_PRNG, nullptr );
ASSERT_M( iRet == CRYPT_OK, error_to_string(iRet) ); ASSERT_M( iRet == CRYPT_OK, error_to_string(iRet) );
} }
@@ -28,7 +28,7 @@ void PRNGWrapper::AddEntropy( const void *pData, int iSize )
void PRNGWrapper::AddRandomEntropy() void PRNGWrapper::AddRandomEntropy()
{ {
unsigned char buf[256]; unsigned char buf[256];
int iRet = rng_get_bytes( buf, sizeof(buf), NULL ); int iRet = rng_get_bytes( buf, sizeof(buf), nullptr );
ASSERT( iRet == sizeof(buf) ); ASSERT( iRet == sizeof(buf) );
AddEntropy( buf, sizeof(buf) ); AddEntropy( buf, sizeof(buf) );
+2 -2
View File
@@ -11,7 +11,7 @@
#include "libtomcrypt/src/headers/tomcrypt.h" #include "libtomcrypt/src/headers/tomcrypt.h"
CryptManager* CRYPTMAN = NULL; // global and accessible from anywhere in our program CryptManager* CRYPTMAN = nullptr; // global and accessible from anywhere in our program
static const RString PRIVATE_KEY_PATH = "Data/private.rsa"; static const RString PRIVATE_KEY_PATH = "Data/private.rsa";
static const RString PUBLIC_KEY_PATH = "Data/public.rsa"; static const RString PUBLIC_KEY_PATH = "Data/public.rsa";
@@ -79,7 +79,7 @@ static const int KEY_LENGTH = 1024;
* *
*/ */
static PRNGWrapper *g_pPRNG = NULL; static PRNGWrapper *g_pPRNG = nullptr;
ltc_math_descriptor ltc_mp = ltm_desc; ltc_math_descriptor ltc_mp = ltm_desc;
CryptManager::CryptManager() CryptManager::CryptManager()
+3 -4
View File
@@ -3,7 +3,6 @@
#include "RageUtil.h" #include "RageUtil.h"
#include "RageFile.h" #include "RageFile.h"
#include "RageLog.h" #include "RageLog.h"
#include "Foreach.h"
CsvFile::CsvFile() CsvFile::CsvFile()
{ {
@@ -114,15 +113,15 @@ bool CsvFile::WriteFile( const RString &sPath ) const
bool CsvFile::WriteFile( RageFileBasic &f ) const bool CsvFile::WriteFile( RageFileBasic &f ) const
{ {
FOREACH_CONST( StringVector, m_vvs, line ) for (StringVector const &line : m_vvs)
{ {
RString sLine; RString sLine;
FOREACH_CONST( RString, *line, value ) for (auto value = line.begin(); value != line.end(); ++value)
{ {
RString sVal = *value; RString sVal = *value;
sVal.Replace( "\"", "\"\"" ); // escape quotes to double-quotes sVal.Replace( "\"", "\"\"" ); // escape quotes to double-quotes
sLine += "\"" + sVal + "\""; sLine += "\"" + sVal + "\"";
if( value != line->end()-1 ) if( value != line.end()-1 )
sLine += ","; sLine += ",";
} }
if( f.PutLine(sLine) == -1 ) if( f.PutLine(sLine) == -1 )
+1 -1
View File
@@ -187,7 +187,7 @@ void DancingCharacters::LoadNextSong()
m_fThisCameraStartBeat = 0; m_fThisCameraStartBeat = 0;
m_fThisCameraEndBeat = 0; m_fThisCameraEndBeat = 0;
ASSERT( GAMESTATE->m_pCurSong != NULL ); ASSERT( GAMESTATE->m_pCurSong != nullptr );
m_fThisCameraEndBeat = GAMESTATE->m_pCurSong->GetFirstBeat(); m_fThisCameraEndBeat = GAMESTATE->m_pCurSong->GetFirstBeat();
FOREACH_PlayerNumber( p ) FOREACH_PlayerNumber( p )
+14 -12
View File
@@ -6,6 +6,7 @@
#include "ThemeManager.h" #include "ThemeManager.h"
#include "RageTimer.h" #include "RageTimer.h"
#include "AutoActor.h" #include "AutoActor.h"
#include <array>
class Model; class Model;
/** @brief The different animation states for the dancer. */ /** @brief The different animation states for the dancer. */
@@ -38,7 +39,7 @@ public:
void Change2DAnimState( PlayerNumber pn, int iState ); void Change2DAnimState( PlayerNumber pn, int iState );
protected: protected:
Model *m_pCharacter[NUM_PLAYERS]; std::array<Model *, NUM_PLAYERS> m_pCharacter;
/** @brief How far away is the camera from the dancer? */ /** @brief How far away is the camera from the dancer? */
float m_CameraDistance; float m_CameraDistance;
@@ -50,19 +51,20 @@ protected:
float m_fThisCameraStartBeat; float m_fThisCameraStartBeat;
float m_fThisCameraEndBeat; float m_fThisCameraEndBeat;
bool m_bHas2DElements[NUM_PLAYERS]; std::array<bool, NUM_PLAYERS> m_bHas2DElements;
AutoActor m_bgIdle[NUM_PLAYERS];
AutoActor m_bgMiss[NUM_PLAYERS];
AutoActor m_bgGood[NUM_PLAYERS];
AutoActor m_bgGreat[NUM_PLAYERS];
AutoActor m_bgFever[NUM_PLAYERS];
AutoActor m_bgFail[NUM_PLAYERS];
AutoActor m_bgWin[NUM_PLAYERS];
AutoActor m_bgWinFever[NUM_PLAYERS];
RageTimer m_2DIdleTimer[NUM_PLAYERS];
int m_i2DAnimState[NUM_PLAYERS]; std::array<AutoActor, NUM_PLAYERS> m_bgIdle;
std::array<AutoActor, NUM_PLAYERS> m_bgMiss;
std::array<AutoActor, NUM_PLAYERS> m_bgGood;
std::array<AutoActor, NUM_PLAYERS> m_bgGreat;
std::array<AutoActor, NUM_PLAYERS> m_bgFever;
std::array<AutoActor, NUM_PLAYERS> m_bgFail;
std::array<AutoActor, NUM_PLAYERS> m_bgWin;
std::array<AutoActor, NUM_PLAYERS> m_bgWinFever;
std::array<RageTimer, NUM_PLAYERS> m_2DIdleTimer;
std::array<int, NUM_PLAYERS> m_i2DAnimState;
}; };
#endif #endif
+1 -1
View File
@@ -58,7 +58,7 @@ bool DateTime::operator>( const DateTime& other ) const
DateTime DateTime::GetNowDateTime() DateTime DateTime::GetNowDateTime()
{ {
time_t now = time(NULL); time_t now = time(nullptr);
tm tNow; tm tNow;
localtime_r( &now, &tNow ); localtime_r( &now, &tNow );
DateTime dtNow; DateTime dtNow;
+9 -9
View File
@@ -23,13 +23,13 @@ LuaXType( Difficulty );
const RString &CourseDifficultyToLocalizedString( CourseDifficulty x ) const RString &CourseDifficultyToLocalizedString( CourseDifficulty x )
{ {
static auto_ptr<LocalizedString> g_CourseDifficultyName[NUM_Difficulty]; static unique_ptr<LocalizedString> g_CourseDifficultyName[NUM_Difficulty];
if( g_CourseDifficultyName[0].get() == NULL ) if( g_CourseDifficultyName[0].get() == nullptr )
{ {
FOREACH_ENUM( Difficulty,i) FOREACH_ENUM( Difficulty,i)
{ {
auto_ptr<LocalizedString> ap( new LocalizedString("CourseDifficulty", DifficultyToString(i)) ); unique_ptr<LocalizedString> ap( new LocalizedString("CourseDifficulty", DifficultyToString(i)) );
g_CourseDifficultyName[i] = ap; g_CourseDifficultyName[i] = move(ap);
} }
} }
return g_CourseDifficultyName[x]->GetValue(); return g_CourseDifficultyName[x]->GetValue();
@@ -114,18 +114,18 @@ RString GetCustomDifficulty( StepsType st, Difficulty dc, CourseType ct )
// OPTIMIZATION OPPORTUNITY: cache these metrics and cache the splitting // OPTIMIZATION OPPORTUNITY: cache these metrics and cache the splitting
vector<RString> vsNames; vector<RString> vsNames;
split( NAMES, ",", vsNames ); split( NAMES, ",", vsNames );
FOREACH( RString, vsNames, sName ) for (RString const &sName: vsNames)
{ {
ThemeMetric<StepsType> STEPS_TYPE("CustomDifficulty",(*sName)+"StepsType"); ThemeMetric<StepsType> STEPS_TYPE("CustomDifficulty",sName + "StepsType");
if( STEPS_TYPE == StepsType_Invalid || st == STEPS_TYPE ) // match if( STEPS_TYPE == StepsType_Invalid || st == STEPS_TYPE ) // match
{ {
ThemeMetric<Difficulty> DIFFICULTY("CustomDifficulty",(*sName)+"Difficulty"); ThemeMetric<Difficulty> DIFFICULTY("CustomDifficulty",sName + "Difficulty");
if( DIFFICULTY == Difficulty_Invalid || dc == DIFFICULTY ) // match if( DIFFICULTY == Difficulty_Invalid || dc == DIFFICULTY ) // match
{ {
ThemeMetric<CourseType> COURSE_TYPE("CustomDifficulty",(*sName)+"CourseType"); ThemeMetric<CourseType> COURSE_TYPE("CustomDifficulty",sName + "CourseType");
if( COURSE_TYPE == CourseType_Invalid || ct == COURSE_TYPE ) // match if( COURSE_TYPE == CourseType_Invalid || ct == COURSE_TYPE ) // match
{ {
ThemeMetric<RString> STRING("CustomDifficulty",(*sName)+"String"); ThemeMetric<RString> STRING("CustomDifficulty",sName + "String");
return STRING.GetValue(); return STRING.GetValue();
} }
} }
+2 -2
View File
@@ -62,7 +62,7 @@ void DifficultyIcon::SetPlayer( PlayerNumber pn )
void DifficultyIcon::SetFromSteps( PlayerNumber pn, const Steps* pSteps ) void DifficultyIcon::SetFromSteps( PlayerNumber pn, const Steps* pSteps )
{ {
SetPlayer( pn ); SetPlayer( pn );
if( pSteps == NULL ) if( pSteps == nullptr )
Unset(); Unset();
else else
SetFromDifficulty( pSteps->GetDifficulty() ); SetFromDifficulty( pSteps->GetDifficulty() );
@@ -71,7 +71,7 @@ void DifficultyIcon::SetFromSteps( PlayerNumber pn, const Steps* pSteps )
void DifficultyIcon::SetFromTrail( PlayerNumber pn, const Trail* pTrail ) void DifficultyIcon::SetFromTrail( PlayerNumber pn, const Trail* pTrail )
{ {
SetPlayer( pn ); SetPlayer( pn );
if( pTrail == NULL ) if( pTrail == nullptr )
Unset(); Unset();
else else
SetFromDifficulty( pTrail->m_CourseDifficulty ); SetFromDifficulty( pTrail->m_CourseDifficulty );
+13 -13
View File
@@ -7,7 +7,7 @@
#include "StepsDisplay.h" #include "StepsDisplay.h"
#include "StepsUtil.h" #include "StepsUtil.h"
#include "CommonMetrics.h" #include "CommonMetrics.h"
#include "Foreach.h"
#include "SongUtil.h" #include "SongUtil.h"
#include "XmlFile.h" #include "XmlFile.h"
@@ -49,12 +49,12 @@ void StepsDisplayList::LoadFromNode( const XNode* pNode )
MOVE_COMMAND.Load( m_sName, "MoveCommand" ); MOVE_COMMAND.Load( m_sName, "MoveCommand" );
m_Lines.resize( MAX_METERS ); m_Lines.resize( MAX_METERS );
m_CurSong = NULL; m_CurSong = nullptr;
FOREACH_ENUM( PlayerNumber, pn ) FOREACH_ENUM( PlayerNumber, pn )
{ {
const XNode *pChild = pNode->GetChild( ssprintf("CursorP%i",pn+1) ); const XNode *pChild = pNode->GetChild( ssprintf("CursorP%i",pn+1) );
if( pChild == NULL ) if( pChild == nullptr )
{ {
LuaHelpers::ReportScriptErrorFmt("%s: StepsDisplayList: missing the node \"CursorP%d\"", ActorUtil::GetWhere(pNode).c_str(), pn+1); LuaHelpers::ReportScriptErrorFmt("%s: StepsDisplayList: missing the node \"CursorP%d\"", ActorUtil::GetWhere(pNode).c_str(), pn+1);
} }
@@ -70,7 +70,7 @@ void StepsDisplayList::LoadFromNode( const XNode* pNode )
* in separate tweening stacks. This means the Cursor command can't change diffuse * in separate tweening stacks. This means the Cursor command can't change diffuse
* colors; I think we do need a diffuse color stack ... */ * colors; I think we do need a diffuse color stack ... */
pChild = pNode->GetChild( ssprintf("CursorP%iFrame",pn+1) ); pChild = pNode->GetChild( ssprintf("CursorP%iFrame",pn+1) );
if( pChild == NULL ) if( pChild == nullptr )
{ {
LuaHelpers::ReportScriptErrorFmt("%s: StepsDisplayList: missing the node \"CursorP%dFrame\"", ActorUtil::GetWhere(pNode).c_str(), pn+1); LuaHelpers::ReportScriptErrorFmt("%s: StepsDisplayList: missing the node \"CursorP%dFrame\"", ActorUtil::GetWhere(pNode).c_str(), pn+1);
} }
@@ -86,7 +86,7 @@ void StepsDisplayList::LoadFromNode( const XNode* pNode )
{ {
// todo: Use Row1, Row2 for names? also m_sName+"Row" -aj // todo: Use Row1, Row2 for names? also m_sName+"Row" -aj
m_Lines[m].m_Meter.SetName( "Row" ); m_Lines[m].m_Meter.SetName( "Row" );
m_Lines[m].m_Meter.Load( "StepsDisplayListRow", NULL ); m_Lines[m].m_Meter.Load( "StepsDisplayListRow", nullptr );
this->AddChild( &m_Lines[m].m_Meter ); this->AddChild( &m_Lines[m].m_Meter );
} }
@@ -102,7 +102,7 @@ int StepsDisplayList::GetCurrentRowIndex( PlayerNumber pn ) const
{ {
const Row &row = m_Rows[i]; const Row &row = m_Rows[i];
if( GAMESTATE->m_pCurSteps[pn] == NULL ) if( GAMESTATE->m_pCurSteps[pn] == nullptr )
{ {
if( row.m_dc == ClosestDifficulty ) if( row.m_dc == ClosestDifficulty )
return i; return i;
@@ -267,17 +267,17 @@ void StepsDisplayList::SetFromGameState()
const Song *pSong = GAMESTATE->m_pCurSong; const Song *pSong = GAMESTATE->m_pCurSong;
unsigned i = 0; unsigned i = 0;
if( pSong == NULL ) if( pSong == nullptr )
{ {
// FIXME: This clamps to between the min and the max difficulty, but // FIXME: This clamps to between the min and the max difficulty, but
// it really should round to the nearest difficulty that's in // it really should round to the nearest difficulty that's in
// DIFFICULTIES_TO_SHOW. // DIFFICULTIES_TO_SHOW.
const vector<Difficulty>& difficulties = CommonMetrics::DIFFICULTIES_TO_SHOW.GetValue(); const vector<Difficulty>& difficulties = CommonMetrics::DIFFICULTIES_TO_SHOW.GetValue();
m_Rows.resize( difficulties.size() ); m_Rows.resize( difficulties.size() );
FOREACH_CONST( Difficulty, difficulties, d ) for (Difficulty const &d : difficulties)
{ {
m_Rows[i].m_dc = *d; m_Rows[i].m_dc = d;
m_Lines[i].m_Meter.SetFromStepsTypeAndMeterAndDifficultyAndCourseType( GAMESTATE->GetCurrentStyle(PLAYER_INVALID)->m_StepsType, 0, *d, CourseType_Invalid ); m_Lines[i].m_Meter.SetFromStepsTypeAndMeterAndDifficultyAndCourseType( GAMESTATE->GetCurrentStyle(PLAYER_INVALID)->m_StepsType, 0, d, CourseType_Invalid );
++i; ++i;
} }
} }
@@ -288,11 +288,11 @@ void StepsDisplayList::SetFromGameState()
// Should match the sort in ScreenSelectMusic::AfterMusicChange. // Should match the sort in ScreenSelectMusic::AfterMusicChange.
m_Rows.resize( vpSteps.size() ); m_Rows.resize( vpSteps.size() );
FOREACH_CONST( Steps*, vpSteps, s ) for (Steps const * s: vpSteps)
{ {
//LOG->Trace(ssprintf("setting steps for row %i",i)); //LOG->Trace(ssprintf("setting steps for row %i",i));
m_Rows[i].m_Steps = *s; m_Rows[i].m_Steps = s;
m_Lines[i].m_Meter.SetFromSteps( *s ); m_Lines[i].m_Meter.SetFromSteps( s );
++i; ++i;
} }
} }
+1 -1
View File
@@ -56,7 +56,7 @@ private:
{ {
Row() Row()
{ {
m_Steps = NULL; m_Steps = nullptr;
m_dc = Difficulty_Invalid; m_dc = Difficulty_Invalid;
m_fY = 0; m_fY = 0;
m_bHidden = false; m_bHidden = false;
+3 -3
View File
@@ -37,7 +37,7 @@ public:
} }
static int GetCurrentMode( T *p, lua_State *L ) static int GetCurrentMode( T *p, lua_State *L )
{ {
if (p->currentMode() != NULL) { if (p->currentMode() != nullptr) {
DisplayMode *m = const_cast<DisplayMode *>( p->currentMode() ); DisplayMode *m = const_cast<DisplayMode *>( p->currentMode() );
m->PushSelf( L ); m->PushSelf( L );
} else { } else {
@@ -65,7 +65,7 @@ namespace
DisplaySpecs *check_DisplaySpecs(lua_State *L) DisplaySpecs *check_DisplaySpecs(lua_State *L)
{ {
void *ud = luaL_checkudata( L, 1, DISPLAYSPECS ); void *ud = luaL_checkudata( L, 1, DISPLAYSPECS );
luaL_argcheck( L, ud != NULL, 1, "`DisplaySpecs` expected" ); luaL_argcheck( L, ud != nullptr, 1, "`DisplaySpecs` expected" );
return static_cast<DisplaySpecs *>(ud); return static_cast<DisplaySpecs *>(ud);
} }
@@ -126,7 +126,7 @@ namespace
{"__index", DisplaySpecs_get}, {"__index", DisplaySpecs_get},
{"__len", DisplaySpecs_len}, {"__len", DisplaySpecs_len},
{"__tostring", DisplaySpecs_tostring}, {"__tostring", DisplaySpecs_tostring},
{NULL, NULL} {nullptr, nullptr}
}; };
+1 -1
View File
@@ -114,7 +114,7 @@ public:
} }
/* /*
* Return a pointer to the currently active display mode, or NULL if * Return a pointer to the currently active display mode, or nullptr if
* display is inactive * display is inactive
* *
* Note that inactive *does not* necessarily mean unusable. E.g., in X11, * Note that inactive *does not* necessarily mean unusable. E.g., in X11,
+25 -24
View File
@@ -8,7 +8,7 @@
#include "Steps.h" #include "Steps.h"
#include "Song.h" #include "Song.h"
#include "StepsUtil.h" #include "StepsUtil.h"
#include "Foreach.h"
#include "CommonMetrics.h" #include "CommonMetrics.h"
#include "ImageCache.h" #include "ImageCache.h"
#include "UnlockManager.h" #include "UnlockManager.h"
@@ -171,12 +171,12 @@ void EditMenu::Load( const RString &sType )
this->AddChild( &m_SongTextBanner ); this->AddChild( &m_SongTextBanner );
m_StepsDisplay.SetName( "StepsDisplay" ); m_StepsDisplay.SetName( "StepsDisplay" );
m_StepsDisplay.Load( "StepsDisplayEdit", NULL ); m_StepsDisplay.Load( "StepsDisplayEdit", nullptr );
ActorUtil::SetXY( m_StepsDisplay, sType ); ActorUtil::SetXY( m_StepsDisplay, sType );
this->AddChild( &m_StepsDisplay ); this->AddChild( &m_StepsDisplay );
m_StepsDisplaySource.SetName( "StepsDisplaySource" ); m_StepsDisplaySource.SetName( "StepsDisplaySource" );
m_StepsDisplaySource.Load( "StepsDisplayEdit", NULL ); m_StepsDisplaySource.Load( "StepsDisplayEdit", nullptr );
ActorUtil::SetXY( m_StepsDisplaySource, sType ); ActorUtil::SetXY( m_StepsDisplaySource, sType );
this->AddChild( &m_StepsDisplaySource ); this->AddChild( &m_StepsDisplaySource );
@@ -411,11 +411,11 @@ void EditMenu::OnRowValueChanged( EditMenuRow row )
vector<Song*> vtSongs; vector<Song*> vtSongs;
GetSongsToShowForGroup(GetSelectedGroup(), vtSongs); GetSongsToShowForGroup(GetSelectedGroup(), vtSongs);
// Filter out songs that aren't playable. // Filter out songs that aren't playable.
FOREACH(Song*, vtSongs, s) for (Song *s :vtSongs)
{ {
if(SongUtil::IsSongPlayable(*s)) if(SongUtil::IsSongPlayable(s))
{ {
m_pSongs.push_back(*s); m_pSongs.push_back(s);
} }
} }
} }
@@ -428,7 +428,7 @@ void EditMenu::OnRowValueChanged( EditMenuRow row )
m_iSelection[ROW_SONG] = 0; m_iSelection[ROW_SONG] = 0;
// fall through // fall through
case ROW_SONG: case ROW_SONG:
if(GetSelectedSong() == NULL) if(GetSelectedSong() == nullptr)
{ {
m_textValue[ROW_SONG].SetText(""); m_textValue[ROW_SONG].SetText("");
m_SongBanner.LoadFallback(); m_SongBanner.LoadFallback();
@@ -462,13 +462,13 @@ void EditMenu::OnRowValueChanged( EditMenuRow row )
// Only show StepsTypes for which we have valid Steps. // Only show StepsTypes for which we have valid Steps.
vector<StepsType> vSts = CommonMetrics::STEPS_TYPES_TO_SHOW.GetValue(); vector<StepsType> vSts = CommonMetrics::STEPS_TYPES_TO_SHOW.GetValue();
FOREACH( StepsType, vSts, st ) for (StepsType &st : vSts)
{ {
if(SongUtil::GetStepsByDifficulty( GetSelectedSong(), *st, Difficulty_Invalid, false) != NULL) if(SongUtil::GetStepsByDifficulty( GetSelectedSong(), st, Difficulty_Invalid, false) != nullptr)
m_StepsTypes.push_back(*st); m_StepsTypes.push_back(st);
// Try to preserve the user's StepsType selection. // Try to preserve the user's StepsType selection.
if(*st == orgSel) if(st == orgSel)
m_iSelection[ROW_STEPS_TYPE] = m_StepsTypes.size() - 1; m_iSelection[ROW_STEPS_TYPE] = m_StepsTypes.size() - 1;
} }
} }
@@ -506,8 +506,8 @@ void EditMenu::OnRowValueChanged( EditMenuRow row )
vector<Steps*> v; vector<Steps*> v;
SongUtil::GetSteps( GetSelectedSong(), v, GetSelectedStepsType(), Difficulty_Edit ); SongUtil::GetSteps( GetSelectedSong(), v, GetSelectedStepsType(), Difficulty_Edit );
StepsUtil::SortStepsByDescription( v ); StepsUtil::SortStepsByDescription( v );
FOREACH_CONST( Steps*, v, p ) for (Steps *p : v)
m_vpSteps.push_back( StepsAndDifficulty(*p,dc) ); m_vpSteps.push_back( StepsAndDifficulty(p,dc) );
} }
break; break;
case EditMode_Home: case EditMode_Home:
@@ -524,7 +524,7 @@ void EditMenu::OnRowValueChanged( EditMenuRow row )
break; break;
case EditMode_Home: case EditMode_Home:
case EditMode_Full: case EditMode_Full:
m_vpSteps.push_back( StepsAndDifficulty(NULL,dc) ); // "New Edit" m_vpSteps.push_back( StepsAndDifficulty(nullptr,dc) ); // "New Edit"
break; break;
default: default:
FAIL_M(ssprintf("Invalid edit mode: %i", mode)); FAIL_M(ssprintf("Invalid edit mode: %i", mode));
@@ -534,7 +534,7 @@ void EditMenu::OnRowValueChanged( EditMenuRow row )
{ {
Steps *pSteps = SongUtil::GetStepsByDifficulty( GetSelectedSong(), GetSelectedStepsType(), dc ); Steps *pSteps = SongUtil::GetStepsByDifficulty( GetSelectedSong(), GetSelectedStepsType(), dc );
if( pSteps && UNLOCKMAN->StepsIsLocked( GetSelectedSong(), pSteps ) ) if( pSteps && UNLOCKMAN->StepsIsLocked( GetSelectedSong(), pSteps ) )
pSteps = NULL; pSteps = nullptr;
switch( mode ) switch( mode )
{ {
@@ -558,11 +558,12 @@ void EditMenu::OnRowValueChanged( EditMenuRow row )
} }
StripLockedStepsAndDifficulty( m_vpSteps ); StripLockedStepsAndDifficulty( m_vpSteps );
FOREACH( StepsAndDifficulty, m_vpSteps, s ) int i = 0;
for (StepsAndDifficulty const &s : m_vpSteps)
{ {
if( s->dc == dcOld ) if( s.dc == dcOld )
{ {
m_iSelection[ROW_STEPS] = s - m_vpSteps.begin(); m_iSelection[ROW_STEPS] = i;
break; break;
} }
} }
@@ -570,7 +571,7 @@ void EditMenu::OnRowValueChanged( EditMenuRow row )
} }
// fall through // fall through
case ROW_STEPS: case ROW_STEPS:
if(GetSelectedSteps() == NULL && mode == EditMode_Practice) if(GetSelectedSteps() == nullptr && mode == EditMode_Practice)
{ {
m_textValue[ROW_STEPS].SetText(THEME->GetString(m_sName, "No Steps selected.")); m_textValue[ROW_STEPS].SetText(THEME->GetString(m_sName, "No Steps selected."));
m_StepsDisplay.Unset(); m_StepsDisplay.Unset();
@@ -602,7 +603,7 @@ void EditMenu::OnRowValueChanged( EditMenuRow row )
m_textValue[ROW_SOURCE_STEPS_TYPE].SetVisible( GetSelectedSteps() ? false : true ); m_textValue[ROW_SOURCE_STEPS_TYPE].SetVisible( GetSelectedSteps() ? false : true );
m_textValue[ROW_SOURCE_STEPS_TYPE].SetText( GAMEMAN->GetStepsTypeInfo(GetSelectedSourceStepsType()).GetLocalizedString() ); m_textValue[ROW_SOURCE_STEPS_TYPE].SetText( GAMEMAN->GetStepsTypeInfo(GetSelectedSourceStepsType()).GetLocalizedString() );
m_vpSourceSteps.clear(); m_vpSourceSteps.clear();
m_vpSourceSteps.push_back( StepsAndDifficulty(NULL,Difficulty_Invalid) ); // "blank" m_vpSourceSteps.push_back( StepsAndDifficulty(nullptr,Difficulty_Invalid) ); // "blank"
FOREACH_ENUM( Difficulty, dc ) FOREACH_ENUM( Difficulty, dc )
{ {
@@ -610,7 +611,7 @@ void EditMenu::OnRowValueChanged( EditMenuRow row )
if( dc != Difficulty_Edit ) if( dc != Difficulty_Edit )
{ {
Steps *pSteps = SongUtil::GetStepsByDifficulty( GetSelectedSong(), GetSelectedSourceStepsType(), dc ); Steps *pSteps = SongUtil::GetStepsByDifficulty( GetSelectedSong(), GetSelectedSourceStepsType(), dc );
if( pSteps != NULL ) if( pSteps != nullptr )
m_vpSourceSteps.push_back( StepsAndDifficulty(pSteps,dc) ); m_vpSourceSteps.push_back( StepsAndDifficulty(pSteps,dc) );
} }
else else
@@ -618,8 +619,8 @@ void EditMenu::OnRowValueChanged( EditMenuRow row )
vector<Steps*> v; vector<Steps*> v;
SongUtil::GetSteps( GetSelectedSong(), v, GetSelectedSourceStepsType(), dc ); SongUtil::GetSteps( GetSelectedSong(), v, GetSelectedSourceStepsType(), dc );
StepsUtil::SortStepsByDescription( v ); StepsUtil::SortStepsByDescription( v );
FOREACH_CONST( Steps*, v, pSteps ) for (Steps *pSteps : v)
m_vpSourceSteps.push_back( StepsAndDifficulty(*pSteps,dc) ); m_vpSourceSteps.push_back( StepsAndDifficulty(pSteps,dc) );
} }
} }
StripLockedStepsAndDifficulty( m_vpSteps ); StripLockedStepsAndDifficulty( m_vpSteps );
@@ -662,7 +663,7 @@ void EditMenu::OnRowValueChanged( EditMenuRow row )
m_Actions.clear(); m_Actions.clear();
// Stick autosave in the list first so that people will see it. -Kyz // Stick autosave in the list first so that people will see it. -Kyz
Song* cur_song= GetSelectedSong(); Song* cur_song= GetSelectedSong();
if(cur_song != NULL && cur_song->HasAutosaveFile() && !cur_song->WasLoadedFromAutosave()) if(cur_song != nullptr && cur_song->HasAutosaveFile() && !cur_song->WasLoadedFromAutosave())
{ {
m_Actions.push_back(EditMenuAction_LoadAutosave); m_Actions.push_back(EditMenuAction_LoadAutosave);
} }
+3 -3
View File
@@ -121,7 +121,7 @@ public:
Song* GetSelectedSong() const Song* GetSelectedSong() const
{ {
RETURN_IF_INVALID(m_pSongs.empty() || RETURN_IF_INVALID(m_pSongs.empty() ||
m_iSelection[ROW_SONG] >= (int)m_pSongs.size(), NULL); m_iSelection[ROW_SONG] >= (int)m_pSongs.size(), nullptr);
return m_pSongs[m_iSelection[ROW_SONG]]; return m_pSongs[m_iSelection[ROW_SONG]];
} }
/** @brief Retrieve the currently selected steps type. /** @brief Retrieve the currently selected steps type.
@@ -137,7 +137,7 @@ public:
Steps* GetSelectedSteps() const Steps* GetSelectedSteps() const
{ {
RETURN_IF_INVALID(m_vpSteps.empty() || RETURN_IF_INVALID(m_vpSteps.empty() ||
m_iSelection[ROW_STEPS] >= (int)m_vpSteps.size(), NULL); m_iSelection[ROW_STEPS] >= (int)m_vpSteps.size(), nullptr);
return m_vpSteps[m_iSelection[ROW_STEPS]].pSteps; return m_vpSteps[m_iSelection[ROW_STEPS]].pSteps;
} }
/** @brief Retrieve the currently selected difficulty. /** @brief Retrieve the currently selected difficulty.
@@ -161,7 +161,7 @@ public:
Steps* GetSelectedSourceSteps() const Steps* GetSelectedSourceSteps() const
{ {
RETURN_IF_INVALID(m_vpSourceSteps.empty() || RETURN_IF_INVALID(m_vpSourceSteps.empty() ||
m_iSelection[ROW_SOURCE_STEPS] >= (int)m_vpSourceSteps.size(), NULL); m_iSelection[ROW_SOURCE_STEPS] >= (int)m_vpSourceSteps.size(), nullptr);
return m_vpSourceSteps[m_iSelection[ROW_SOURCE_STEPS]].pSteps; return m_vpSourceSteps[m_iSelection[ROW_SOURCE_STEPS]].pSteps;
} }
/** @brief Retrieve the currently selected difficulty. /** @brief Retrieve the currently selected difficulty.
+7 -7
View File
@@ -80,18 +80,18 @@ int CheckEnum( lua_State *L, LuaReference &table, int iPos, int iInvalid, const
} }
// szNameArray is of size iMax; pNameCache is of size iMax+2. // szNameArray is of size iMax; pNameCache is of size iMax+2.
const RString &EnumToString( int iVal, int iMax, const char **szNameArray, auto_ptr<RString> *pNameCache ) const RString &EnumToString( int iVal, int iMax, const char **szNameArray, unique_ptr<RString> *pNameCache )
{ {
if( unlikely(pNameCache[0].get() == NULL) ) if( unlikely(pNameCache[0].get() == nullptr) )
{ {
for( int i = 0; i < iMax; ++i ) for( int i = 0; i < iMax; ++i )
{ {
auto_ptr<RString> ap( new RString( szNameArray[i] ) ); unique_ptr<RString> ap( new RString( szNameArray[i] ) );
pNameCache[i] = ap; pNameCache[i] = move(ap);
} }
auto_ptr<RString> ap( new RString ); unique_ptr<RString> ap( new RString );
pNameCache[iMax+1] = ap; pNameCache[iMax+1] = move(ap);
} }
// iMax+1 is "Invalid". iMax+0 is the NUM_ size value, which can not be converted // iMax+1 is "Invalid". iMax+0 is the NUM_ size value, which can not be converted
@@ -140,7 +140,7 @@ namespace
static const luaL_Reg EnumLib[] = { static const luaL_Reg EnumLib[] = {
{ "GetName", GetName }, { "GetName", GetName },
{ "Reverse", Reverse }, { "Reverse", Reverse },
{ NULL, NULL } { nullptr, nullptr }
}; };
static void PushEnumMethodTable( lua_State *L ) static void PushEnumMethodTable( lua_State *L )
+6 -6
View File
@@ -66,14 +66,14 @@ namespace Enum
void SetMetatable( lua_State *L, LuaReference &EnumTable, LuaReference &EnumIndexTable, const char *szName ); void SetMetatable( lua_State *L, LuaReference &EnumTable, LuaReference &EnumIndexTable, const char *szName );
}; };
const RString &EnumToString( int iVal, int iMax, const char **szNameArray, auto_ptr<RString> *pNameCache ); // XToString helper const RString &EnumToString( int iVal, int iMax, const char **szNameArray, unique_ptr<RString> *pNameCache ); // XToString helper
#define XToString(X) \ #define XToString(X) \
const RString& X##ToString(X x); \ const RString& X##ToString(X x); \
COMPILE_ASSERT( NUM_##X == ARRAYLEN(X##Names) ); \ COMPILE_ASSERT( NUM_##X == ARRAYLEN(X##Names) ); \
const RString& X##ToString( X x ) \ const RString& X##ToString( X x ) \
{ \ { \
static auto_ptr<RString> as_##X##Name[NUM_##X+2]; \ static unique_ptr<RString> as_##X##Name[NUM_##X+2]; \
return EnumToString( x, NUM_##X, X##Names, as_##X##Name ); \ return EnumToString( x, NUM_##X, X##Names, as_##X##Name ); \
} \ } \
namespace StringConversion { template<> RString ToString<X>( const X &value ) { return X##ToString(value); } } namespace StringConversion { template<> RString ToString<X>( const X &value ) { return X##ToString(value); } }
@@ -82,12 +82,12 @@ namespace StringConversion { template<> RString ToString<X>( const X &value ) {
const RString &X##ToLocalizedString(X x); \ const RString &X##ToLocalizedString(X x); \
const RString &X##ToLocalizedString( X x ) \ const RString &X##ToLocalizedString( X x ) \
{ \ { \
static auto_ptr<LocalizedString> g_##X##Name[NUM_##X]; \ static unique_ptr<LocalizedString> g_##X##Name[NUM_##X]; \
if( g_##X##Name[0].get() == NULL ) { \ if( g_##X##Name[0].get() == nullptr ) { \
for( unsigned i = 0; i < NUM_##X; ++i ) \ for( unsigned i = 0; i < NUM_##X; ++i ) \
{ \ { \
auto_ptr<LocalizedString> ap( new LocalizedString(#X, X##ToString((X)i)) ); \ unique_ptr<LocalizedString> ap( new LocalizedString(#X, X##ToString((X)i)) ); \
g_##X##Name[i] = ap; \ g_##X##Name[i] = move(ap); \
} \ } \
} \ } \
return g_##X##Name[x]->GetValue(); \ return g_##X##Name[x]->GetValue(); \
+6 -6
View File
@@ -166,7 +166,7 @@ bool FadingBanner::LoadFromCachedBanner( const RString &path )
void FadingBanner::LoadFromSong( const Song* pSong ) void FadingBanner::LoadFromSong( const Song* pSong )
{ {
if( pSong == NULL ) if( pSong == nullptr )
{ {
LoadFallback(); LoadFallback();
return; return;
@@ -195,7 +195,7 @@ void FadingBanner::LoadFromSongGroup( RString sSongGroup )
void FadingBanner::LoadFromCourse( const Course* pCourse ) void FadingBanner::LoadFromCourse( const Course* pCourse )
{ {
if( pCourse == NULL ) if( pCourse == nullptr )
{ {
LoadFallback(); LoadFallback();
return; return;
@@ -272,25 +272,25 @@ public:
static int ScaleToClipped( T* p, lua_State *L ) { p->ScaleToClipped(FArg(1),FArg(2)); COMMON_RETURN_SELF; } static int ScaleToClipped( T* p, lua_State *L ) { p->ScaleToClipped(FArg(1),FArg(2)); COMMON_RETURN_SELF; }
static int LoadFromSong( T* p, lua_State *L ) static int LoadFromSong( T* p, lua_State *L )
{ {
if( lua_isnil(L,1) ) { p->LoadFromSong( NULL ); } if( lua_isnil(L,1) ) { p->LoadFromSong(nullptr); }
else { Song *pS = Luna<Song>::check(L,1); p->LoadFromSong( pS ); } else { Song *pS = Luna<Song>::check(L,1); p->LoadFromSong( pS ); }
COMMON_RETURN_SELF; COMMON_RETURN_SELF;
} }
static int LoadFromCourse( T* p, lua_State *L ) static int LoadFromCourse( T* p, lua_State *L )
{ {
if( lua_isnil(L,1) ) { p->LoadFromCourse( NULL ); } if( lua_isnil(L,1) ) { p->LoadFromCourse(nullptr); }
else { Course *pC = Luna<Course>::check(L,1); p->LoadFromCourse( pC ); } else { Course *pC = Luna<Course>::check(L,1); p->LoadFromCourse( pC ); }
COMMON_RETURN_SELF; COMMON_RETURN_SELF;
} }
static int LoadIconFromCharacter( T* p, lua_State *L ) static int LoadIconFromCharacter( T* p, lua_State *L )
{ {
if( lua_isnil(L,1) ) { p->LoadIconFromCharacter( NULL ); } if( lua_isnil(L,1) ) { p->LoadIconFromCharacter(nullptr); }
else { Character *pC = Luna<Character>::check(L,1); p->LoadIconFromCharacter( pC ); } else { Character *pC = Luna<Character>::check(L,1); p->LoadIconFromCharacter( pC ); }
COMMON_RETURN_SELF; COMMON_RETURN_SELF;
} }
static int LoadCardFromCharacter( T* p, lua_State *L ) static int LoadCardFromCharacter( T* p, lua_State *L )
{ {
if( lua_isnil(L,1) ) { p->LoadIconFromCharacter( NULL ); } if( lua_isnil(L,1) ) { p->LoadIconFromCharacter(nullptr); }
else { Character *pC = Luna<Character>::check(L,1); p->LoadIconFromCharacter( pC ); } else { Character *pC = Luna<Character>::check(L,1); p->LoadIconFromCharacter( pC ); }
COMMON_RETURN_SELF; COMMON_RETURN_SELF;
} }
+1 -1
View File
@@ -18,7 +18,7 @@ public:
/* If you previously loaded a cached banner, and are now loading the full- /* If you previously loaded a cached banner, and are now loading the full-
* resolution banner, set bLowResToHighRes to true. */ * resolution banner, set bLowResToHighRes to true. */
void Load( RageTextureID ID, bool bLowResToHighRes=false ); void Load( RageTextureID ID, bool bLowResToHighRes=false );
void LoadFromSong( const Song* pSong ); // NULL means no song void LoadFromSong( const Song* pSong ); // nullptr means no song
void LoadMode(); void LoadMode();
void LoadFromSongGroup( RString sSongGroup ); void LoadFromSongGroup( RString sSongGroup );
void LoadFromCourse( const Course* pCourse ); void LoadFromCourse( const Course* pCourse );
+6 -6
View File
@@ -7,7 +7,7 @@
#include "SpecialFiles.h" #include "SpecialFiles.h"
#include "RageLog.h" #include "RageLog.h"
#include "Preference.h" #include "Preference.h"
#include "Foreach.h"
FileTransfer::FileTransfer() FileTransfer::FileTransfer()
{ {
@@ -199,8 +199,8 @@ void FileTransfer::StartTransfer( TransferType type, const RString &sURL, const
vsHeaders.push_back( "Content-Length: " + ssprintf("%zd",sRequestPayload.size()) ); vsHeaders.push_back( "Content-Length: " + ssprintf("%zd",sRequestPayload.size()) );
RString sHeader; RString sHeader;
FOREACH_CONST( RString, vsHeaders, h ) for (RString const &h : vsHeaders)
sHeader += *h + "\r\n"; sHeader += h + "\r\n";
sHeader += "\r\n"; sHeader += "\r\n";
m_wSocket.SendData( sHeader.c_str(), sHeader.length() ); m_wSocket.SendData( sHeader.c_str(), sHeader.length() );
@@ -267,14 +267,14 @@ void FileTransfer::HTTPUpdate()
m_sResponseName = "Malformed response."; m_sResponseName = "Malformed response.";
return; return;
} }
m_iResponseCode = StringToInt(m_sBUFFER.substr(i+1,j-i)); m_iResponseCode = std::stoi(m_sBUFFER.substr(i+1,j-i));
m_sResponseName = m_sBUFFER.substr( j+1, k-j ); m_sResponseName = m_sBUFFER.substr( j+1, k-j );
i = m_sBUFFER.find("Content-Length:"); i = m_sBUFFER.find("Content-Length:");
j = m_sBUFFER.find("\n", i+1 ); j = m_sBUFFER.find("\n", i+1 );
if( i != string::npos ) if( i != string::npos )
m_iTotalBytes = StringToInt(m_sBUFFER.substr(i+16,j-i)); m_iTotalBytes = std::stoi(m_sBUFFER.substr(i+16,j-i));
else else
m_iTotalBytes = -1; // We don't know, so go until disconnect m_iTotalBytes = -1; // We don't know, so go until disconnect
@@ -345,7 +345,7 @@ bool FileTransfer::ParseHTTPAddress( const RString &URL, RString &sProto, RStrin
sServer = asMatches[1]; sServer = asMatches[1];
if( asMatches[3] != "" ) if( asMatches[3] != "" )
{ {
iPort = StringToInt(asMatches[3]); iPort = std::stoi(asMatches[3]);
if( iPort == 0 ) if( iPort == 0 )
return false; return false;
} }
+13 -13
View File
@@ -26,7 +26,7 @@ void FontPage::Load( const FontPageSettings &cfg )
ID1.AdditionalTextureHints = cfg.m_sTextureHints; ID1.AdditionalTextureHints = cfg.m_sTextureHints;
m_FontPageTextures.m_pTextureMain = TEXTUREMAN->LoadTexture( ID1 ); m_FontPageTextures.m_pTextureMain = TEXTUREMAN->LoadTexture( ID1 );
if(m_FontPageTextures.m_pTextureMain == NULL) if(m_FontPageTextures.m_pTextureMain == nullptr)
{ {
LuaHelpers::ReportScriptErrorFmt( LuaHelpers::ReportScriptErrorFmt(
"Failed to load main texture %s for font page.", "Failed to load main texture %s for font page.",
@@ -43,7 +43,7 @@ void FontPage::Load( const FontPageSettings &cfg )
if( IsAFile(ID2.filename) ) if( IsAFile(ID2.filename) )
{ {
m_FontPageTextures.m_pTextureStroke = TEXTUREMAN->LoadTexture( ID2 ); m_FontPageTextures.m_pTextureStroke = TEXTUREMAN->LoadTexture( ID2 );
if(m_FontPageTextures.m_pTextureStroke == NULL) if(m_FontPageTextures.m_pTextureStroke == nullptr)
{ {
LuaHelpers::ReportScriptErrorFmt( LuaHelpers::ReportScriptErrorFmt(
"Failed to load stroke texture %s for font page.", "Failed to load stroke texture %s for font page.",
@@ -220,15 +220,15 @@ void FontPage::SetExtraPixels( int iDrawExtraPixelsLeft, int iDrawExtraPixelsRig
FontPage::~FontPage() FontPage::~FontPage()
{ {
if( m_FontPageTextures.m_pTextureMain != NULL ) if( m_FontPageTextures.m_pTextureMain != nullptr )
{ {
TEXTUREMAN->UnloadTexture( m_FontPageTextures.m_pTextureMain ); TEXTUREMAN->UnloadTexture( m_FontPageTextures.m_pTextureMain );
m_FontPageTextures.m_pTextureMain = NULL; m_FontPageTextures.m_pTextureMain = nullptr;
} }
if( m_FontPageTextures.m_pTextureStroke != NULL ) if( m_FontPageTextures.m_pTextureStroke != nullptr )
{ {
TEXTUREMAN->UnloadTexture( m_FontPageTextures.m_pTextureStroke ); TEXTUREMAN->UnloadTexture( m_FontPageTextures.m_pTextureStroke );
m_FontPageTextures.m_pTextureStroke = NULL; m_FontPageTextures.m_pTextureStroke = nullptr;
} }
} }
@@ -271,7 +271,7 @@ int Font::GetGlyphsThatFit(const wstring& line, int* width) const
return i; return i;
} }
Font::Font(): m_iRefCount(1), path(""), m_apPages(), m_pDefault(NULL), Font::Font(): m_iRefCount(1), path(""), m_apPages(), m_pDefault(nullptr),
m_iCharToGlyph(), m_bRightToLeft(false), m_bDistanceField(false), m_iCharToGlyph(), m_bRightToLeft(false), m_bDistanceField(false),
// strokes aren't shown by default, hence the Color. // strokes aren't shown by default, hence the Color.
m_DefaultStrokeColor(RageColor(0,0,0,0)), m_sChars("") {} m_DefaultStrokeColor(RageColor(0,0,0,0)), m_sChars("") {}
@@ -288,7 +288,7 @@ void Font::Unload()
m_apPages.clear(); m_apPages.clear();
m_iCharToGlyph.clear(); m_iCharToGlyph.clear();
m_pDefault = NULL; m_pDefault = nullptr;
/* Don't clear the refcount. We've unloaded, but that doesn't mean things /* Don't clear the refcount. We've unloaded, but that doesn't mean things
* aren't still pointing to us. */ * aren't still pointing to us. */
@@ -323,7 +323,7 @@ void Font::MergeFont(Font &f)
* page. It'll usually be overridden later on by one of our own font * page. It'll usually be overridden later on by one of our own font
* pages; this will be used only if we don't have any font pages at * pages; this will be used only if we don't have any font pages at
* all. */ * all. */
if( m_pDefault == NULL ) if( m_pDefault == nullptr )
m_pDefault = f.m_pDefault; m_pDefault = f.m_pDefault;
for(map<wchar_t,glyph*>::iterator it = f.m_iCharToGlyph.begin(); for(map<wchar_t,glyph*>::iterator it = f.m_iCharToGlyph.begin();
@@ -400,7 +400,7 @@ void Font::CapsOnly()
void Font::SetDefaultGlyph( FontPage *pPage ) void Font::SetDefaultGlyph( FontPage *pPage )
{ {
ASSERT( pPage != NULL ); ASSERT( pPage != nullptr );
if(pPage->m_aGlyphs.empty()) if(pPage->m_aGlyphs.empty())
{ {
LuaHelpers::ReportScriptErrorFmt( LuaHelpers::ReportScriptErrorFmt(
@@ -488,7 +488,7 @@ void Font::LoadFontPageSettings( FontPageSettings &cfg, IniFile &ini, const RStr
// If val is an integer, it's a width, eg. "10=27". // If val is an integer, it's a width, eg. "10=27".
if( IsAnInt(sName) ) if( IsAnInt(sName) )
{ {
cfg.m_mapGlyphWidths[StringToInt(sName)] = pValue->GetValue<int>(); cfg.m_mapGlyphWidths[std::stoi(sName)] = pValue->GetValue<int>();
continue; continue;
} }
@@ -603,7 +603,7 @@ void Font::LoadFontPageSettings( FontPageSettings &cfg, IniFile &ini, const RStr
row_str.c_str()); row_str.c_str());
continue; continue;
} }
const int row = StringToInt(row_str); const int row = std::stoi(row_str);
const int first_frame = row * num_frames_wide; const int first_frame = row * num_frames_wide;
if(row >= num_frames_high) if(row >= num_frames_high)
@@ -690,7 +690,7 @@ RString FontPageSettings::MapRange( RString sMapping, int iMapOffset, int iGlyph
} }
const wchar_t *pMapping = FontCharmaps::get_char_map( sMapping ); const wchar_t *pMapping = FontCharmaps::get_char_map( sMapping );
if( pMapping == NULL ) if( pMapping == nullptr )
return "Unknown mapping"; return "Unknown mapping";
while( *pMapping != 0 && iMapOffset ) while( *pMapping != 0 && iMapOffset )
+2 -2
View File
@@ -23,7 +23,7 @@ struct FontPageTextures
RageTexture *m_pTextureStroke; RageTexture *m_pTextureStroke;
/** @brief Set up the initial textures. */ /** @brief Set up the initial textures. */
FontPageTextures(): m_pTextureMain(NULL), m_pTextureStroke(NULL) {} FontPageTextures(): m_pTextureMain(nullptr), m_pTextureStroke(nullptr) {}
bool operator == (const struct FontPageTextures& other) const { bool operator == (const struct FontPageTextures& other) const {
return m_pTextureMain == other.m_pTextureMain && return m_pTextureMain == other.m_pTextureMain &&
@@ -59,7 +59,7 @@ struct glyph
RectF m_TexRect; RectF m_TexRect;
/** @brief Set up the glyph with default values. */ /** @brief Set up the glyph with default values. */
glyph() : m_pPage(NULL), m_FontPageTextures(), m_iHadvance(0), glyph() : m_pPage(nullptr), m_FontPageTextures(), m_iHadvance(0),
m_fWidth(0), m_fHeight(0), m_fHshift(0), m_TexRect() {} m_fWidth(0), m_fHeight(0), m_fHshift(0), m_TexRect() {}
}; };
+1 -1
View File
@@ -347,7 +347,7 @@ static void InitCharAliases()
{ "auxrt", INTERNAL }, { "auxrt", INTERNAL },
{ "auxback", INTERNAL }, { "auxback", INTERNAL },
{ NULL, 0 } { nullptr, 0 }
}; };
int iNextInternalUseCodepoint = 0xE000; int iNextInternalUseCodepoint = 0xE000;
+1 -1
View File
@@ -226,7 +226,7 @@ const wchar_t *FontCharmaps::get_char_map(RString name)
map<RString,const wchar_t*>::const_iterator i = charmaps.find(name); map<RString,const wchar_t*>::const_iterator i = charmaps.find(name);
if(i == charmaps.end()) if(i == charmaps.end())
return NULL; return nullptr;
return i->second; return i->second;
} }
+1 -1
View File
@@ -5,7 +5,7 @@
#include "RageLog.h" #include "RageLog.h"
#include <map> #include <map>
FontManager* FONT = NULL; // global and accessible from anywhere in our program FontManager* FONT = nullptr; // global and accessible from anywhere in our program
// map from file name to a texture holder // map from file name to a texture holder
typedef pair<RString,RString> FontName; typedef pair<RString,RString> FontName;
-74
View File
@@ -1,74 +0,0 @@
#ifndef Foreach_H
#define Foreach_H
/** @brief General foreach loop iterating over a vector. */
#define FOREACH( elemType, vect, var ) \
for( vector<elemType>::iterator var = (vect).begin(); var != (vect).end(); ++var )
/** @brief General foreach loop iterating over a vector, using a constant iterator. */
#define FOREACH_CONST( elemType, vect, var ) \
for( vector<elemType>::const_iterator var = (vect).begin(); var != (vect).end(); ++var )
/** @brief General foreach loop iterating over a deque. */
#define FOREACHD( elemType, vect, var ) \
for( deque<elemType>::iterator var = (vect).begin(); var != (vect).end(); ++var )
/** @brief General foreach loop iterating over a deque, using a constant iterator. */
#define FOREACHD_CONST( elemType, vect, var ) \
for( deque<elemType>::const_iterator var = (vect).begin(); var != (vect).end(); ++var )
/** @brief General foreach loop iterating over a set. */
#define FOREACHS( elemType, vect, var ) \
for( set<elemType>::iterator var = (vect).begin(); var != (vect).end(); ++var )
/** @brief General foreach loop iterating over a set, using a constant iterator. */
#define FOREACHS_CONST( elemType, vect, var ) \
for( set<elemType>::const_iterator var = (vect).begin(); var != (vect).end(); ++var )
/** @brief General foreach loop iterating over a list. */
#define FOREACHL( elemType, vect, var ) \
for( list<elemType>::iterator var = (vect).begin(); var != (vect).end(); ++var )
/** @brief General foreach loop iterating over a list, using a constant iterator. */
#define FOREACHL_CONST( elemType, vect, var ) \
for( list<elemType>::const_iterator var = (vect).begin(); var != (vect).end(); ++var )
/** @brief General foreach loop iterating over a map. */
#define FOREACHM( keyType, valType, vect, var ) \
for( map<keyType, valType>::iterator var = (vect).begin(); var != (vect).end(); ++var )
/** @brief General foreach loop iterating over a map, using a constant iterator. */
#define FOREACHM_CONST( keyType, valType, vect, var ) \
for( map<keyType, valType>::const_iterator var = (vect).begin(); var != (vect).end(); ++var )
/** @brief General foreach loop iterating over a multimap. */
#define FOREACHMM( keyType, valType, vect, var ) \
for( multimap<keyType, valType>::iterator var = (vect).begin(); var != (vect).end(); ++var )
/** @brief General foreach loop iterating over a multimap, using a constant iterator. */
#define FOREACHMM_CONST( keyType, valType, vect, var ) \
for( multimap<keyType, valType>::const_iterator var = (vect).begin(); var != (vect).end(); ++var )
#endif
/**
* @file
* @author Chris Danford (c) 2004-2005
* @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
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, and/or sell copies of the Software, and to permit persons to
* whom the Software is furnished to do so, provided that the above
* 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
* THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS
* INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT
* OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
* 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.
*/
+4 -5
View File
@@ -7,7 +7,7 @@
#include "ActorUtil.h" #include "ActorUtil.h"
#include "Song.h" #include "Song.h"
#include "BackgroundUtil.h" #include "BackgroundUtil.h"
#include "Foreach.h"
Foreground::~Foreground() Foreground::~Foreground()
{ {
@@ -21,7 +21,7 @@ void Foreground::Unload()
m_BGAnimations.clear(); m_BGAnimations.clear();
m_SubActors.clear(); m_SubActors.clear();
m_fLastMusicSeconds = -9999; m_fLastMusicSeconds = -9999;
m_pSong = NULL; m_pSong = nullptr;
} }
void Foreground::LoadFromSong( const Song *pSong ) void Foreground::LoadFromSong( const Song *pSong )
@@ -31,9 +31,8 @@ void Foreground::LoadFromSong( const Song *pSong )
TEXTUREMAN->SetDefaultTexturePolicy( RageTextureID::TEX_VOLATILE ); TEXTUREMAN->SetDefaultTexturePolicy( RageTextureID::TEX_VOLATILE );
m_pSong = pSong; m_pSong = pSong;
FOREACH_CONST( BackgroundChange, pSong->GetForegroundChanges(), bgc ) for (BackgroundChange const &change : pSong->GetForegroundChanges())
{ {
const BackgroundChange &change = *bgc;
RString sBGName = change.m_def.m_sFile1, RString sBGName = change.m_def.m_sFile1,
sLuaFile = pSong->GetSongDir() + sBGName + "/default.lua", sLuaFile = pSong->GetSongDir() + sBGName + "/default.lua",
sXmlFile = pSong->GetSongDir() + sBGName + "/default.xml"; sXmlFile = pSong->GetSongDir() + sBGName + "/default.xml";
@@ -51,7 +50,7 @@ void Foreground::LoadFromSong( const Song *pSong )
{ {
bga.m_bga = ActorUtil::MakeActor( pSong->GetSongDir() + sBGName, this ); bga.m_bga = ActorUtil::MakeActor( pSong->GetSongDir() + sBGName, this );
} }
if( bga.m_bga == NULL ) if( bga.m_bga == nullptr )
continue; continue;
bga.m_bga->SetName( sBGName ); bga.m_bga->SetName( sBGName );
// ActorUtil::MakeActor calls LoadFromNode to load the actor, and // ActorUtil::MakeActor calls LoadFromNode to load the actor, and
+66 -67
View File
@@ -14,7 +14,6 @@
#include "PrefsManager.h" #include "PrefsManager.h"
#include "Game.h" #include "Game.h"
#include "Style.h" #include "Style.h"
#include "Foreach.h"
#include "GameSoundManager.h" #include "GameSoundManager.h"
#include "PlayerState.h" #include "PlayerState.h"
#include "SongManager.h" #include "SongManager.h"
@@ -36,7 +35,7 @@ void GameCommand::Init()
m_bInvalid = true; m_bInvalid = true;
m_iIndex = -1; m_iIndex = -1;
m_MultiPlayer = MultiPlayer_Invalid; m_MultiPlayer = MultiPlayer_Invalid;
m_pStyle = NULL; m_pStyle = nullptr;
m_pm = PlayMode_Invalid; m_pm = PlayMode_Invalid;
m_dc = Difficulty_Invalid; m_dc = Difficulty_Invalid;
m_CourseDifficulty = Difficulty_Invalid; m_CourseDifficulty = Difficulty_Invalid;
@@ -45,11 +44,11 @@ void GameCommand::Init()
m_sAnnouncer = ""; m_sAnnouncer = "";
m_sScreen = ""; m_sScreen = "";
m_LuaFunction.Unset(); m_LuaFunction.Unset();
m_pSong = NULL; m_pSong = nullptr;
m_pSteps = NULL; m_pSteps = nullptr;
m_pCourse = NULL; m_pCourse = nullptr;
m_pTrail = NULL; m_pTrail = nullptr;
m_pCharacter = NULL; m_pCharacter = nullptr;
m_SortOrder = SortOrder_Invalid; m_SortOrder = SortOrder_Invalid;
m_sSoundPath = ""; m_sSoundPath = "";
m_vsScreensToPrepare.clear(); m_vsScreensToPrepare.clear();
@@ -90,7 +89,7 @@ bool GameCommand::DescribesCurrentMode( PlayerNumber pn ) const
// HACK: don't compare m_dc if m_pSteps is set. This causes problems // HACK: don't compare m_dc if m_pSteps is set. This causes problems
// in ScreenSelectOptionsMaster::ImportOptions if m_PreferredDifficulty // in ScreenSelectOptionsMaster::ImportOptions if m_PreferredDifficulty
// doesn't match the difficulty of m_pCurSteps. // doesn't match the difficulty of m_pCurSteps.
if( m_pSteps == NULL && m_dc != Difficulty_Invalid ) if( m_pSteps == nullptr && m_dc != Difficulty_Invalid )
{ {
// Why is this checking for all players? // Why is this checking for all players?
FOREACH_HumanPlayer( human ) FOREACH_HumanPlayer( human )
@@ -158,8 +157,8 @@ void GameCommand::Load( int iIndex, const Commands& cmds )
m_bInvalid = false; m_bInvalid = false;
m_Commands = cmds; m_Commands = cmds;
FOREACH_CONST( Command, cmds.v, cmd ) for (Command const &cmd : cmds.v)
LoadOne( *cmd ); LoadOne( cmd );
} }
void GameCommand::LoadOne( const Command& cmd ) void GameCommand::LoadOne( const Command& cmd )
@@ -197,7 +196,7 @@ void GameCommand::LoadOne( const Command& cmd )
if( sName == "style" ) if( sName == "style" )
{ {
const Style* style = GAMEMAN->GameAndStringToStyle( GAMESTATE->m_pCurGame, sValue ); const Style* style = GAMEMAN->GameAndStringToStyle( GAMESTATE->m_pCurGame, sValue );
CHECK_INVALID_VALUE(m_pStyle, style, NULL, style); CHECK_INVALID_VALUE(m_pStyle, style, nullptr, style);
} }
else if( sName == "playmode" ) else if( sName == "playmode" )
@@ -278,7 +277,7 @@ void GameCommand::LoadOne( const Command& cmd )
else if( sName == "song" ) else if( sName == "song" )
{ {
CHECK_INVALID_COND(m_pSong, SONGMAN->FindSong(sValue), CHECK_INVALID_COND(m_pSong, SONGMAN->FindSong(sValue),
(SONGMAN->FindSong(sValue) == NULL), (SONGMAN->FindSong(sValue) == nullptr),
(ssprintf("Song \"%s\" not found", sValue.c_str()))); (ssprintf("Song \"%s\" not found", sValue.c_str())));
} }
@@ -289,9 +288,9 @@ void GameCommand::LoadOne( const Command& cmd )
// This must be processed after "song" and "style" commands. // This must be processed after "song" and "style" commands.
if( !m_bInvalid ) if( !m_bInvalid )
{ {
Song *pSong = (m_pSong != NULL)? m_pSong:GAMESTATE->m_pCurSong; Song *pSong = (m_pSong != nullptr)? m_pSong:GAMESTATE->m_pCurSong;
const Style *pStyle = m_pStyle ? m_pStyle : GAMESTATE->GetCurrentStyle(GAMESTATE->GetMasterPlayerNumber()); const Style *pStyle = m_pStyle ? m_pStyle : GAMESTATE->GetCurrentStyle(GAMESTATE->GetMasterPlayerNumber());
if( pSong == NULL || pStyle == NULL ) if( pSong == nullptr || pStyle == nullptr )
{ {
MAKE_INVALID("Must set Song and Style to set Steps."); MAKE_INVALID("Must set Song and Style to set Steps.");
} }
@@ -307,7 +306,7 @@ void GameCommand::LoadOne( const Command& cmd )
{ {
st = SongUtil::GetStepsByDescription( pSong, pStyle->m_StepsType, sSteps ); st = SongUtil::GetStepsByDescription( pSong, pStyle->m_StepsType, sSteps );
} }
CHECK_INVALID_COND(m_pSteps, st, (st == NULL), CHECK_INVALID_COND(m_pSteps, st, (st == nullptr),
(ssprintf("Steps \"%s\" not found", sSteps.c_str()))); (ssprintf("Steps \"%s\" not found", sSteps.c_str())));
} }
} }
@@ -316,7 +315,7 @@ void GameCommand::LoadOne( const Command& cmd )
else if( sName == "course" ) else if( sName == "course" )
{ {
CHECK_INVALID_COND(m_pCourse, SONGMAN->FindCourse("", sValue), CHECK_INVALID_COND(m_pCourse, SONGMAN->FindCourse("", sValue),
(SONGMAN->FindCourse("", sValue) == NULL), (SONGMAN->FindCourse("", sValue) == nullptr),
(ssprintf( "Course \"%s\" not found", sValue.c_str()))); (ssprintf( "Course \"%s\" not found", sValue.c_str())));
} }
@@ -327,9 +326,9 @@ void GameCommand::LoadOne( const Command& cmd )
// This must be processed after "course" and "style" commands. // This must be processed after "course" and "style" commands.
if( !m_bInvalid ) if( !m_bInvalid )
{ {
Course *pCourse = (m_pCourse != NULL)? m_pCourse:GAMESTATE->m_pCurCourse; Course *pCourse = (m_pCourse != nullptr)? m_pCourse:GAMESTATE->m_pCurCourse;
const Style *pStyle = m_pStyle ? m_pStyle : GAMESTATE->GetCurrentStyle(GAMESTATE->GetMasterPlayerNumber()); const Style *pStyle = m_pStyle ? m_pStyle : GAMESTATE->GetCurrentStyle(GAMESTATE->GetMasterPlayerNumber());
if( pCourse == NULL || pStyle == NULL ) if( pCourse == nullptr || pStyle == nullptr )
{ {
MAKE_INVALID("Must set Course and Style to set Trail."); MAKE_INVALID("Must set Course and Style to set Trail.");
} }
@@ -343,7 +342,7 @@ void GameCommand::LoadOne( const Command& cmd )
else else
{ {
Trail* tr = pCourse->GetTrail(pStyle->m_StepsType, cd); Trail* tr = pCourse->GetTrail(pStyle->m_StepsType, cd);
CHECK_INVALID_COND(m_pTrail, tr, (tr == NULL), CHECK_INVALID_COND(m_pTrail, tr, (tr == nullptr),
("Trail \"" + sTrail + "\" not found.")); ("Trail \"" + sTrail + "\" not found."));
} }
} }
@@ -378,12 +377,12 @@ void GameCommand::LoadOne( const Command& cmd )
else if( sName == "weight" ) else if( sName == "weight" )
{ {
m_iWeightPounds = StringToInt( sValue ); m_iWeightPounds = std::stoi( sValue );
} }
else if( sName == "goalcalories" ) else if( sName == "goalcalories" )
{ {
m_iGoalCalories = StringToInt( sValue ); m_iGoalCalories = std::stoi( sValue );
} }
else if( sName == "goaltype" ) else if( sName == "goaltype" )
@@ -450,7 +449,7 @@ void GameCommand::LoadOne( const Command& cmd )
{ {
for(size_t i= 1; i < cmd.m_vsArgs.size(); i+= 2) for(size_t i= 1; i < cmd.m_vsArgs.size(); i+= 2)
{ {
if(IPreference::GetPreferenceByName(cmd.m_vsArgs[i]) == NULL) if(IPreference::GetPreferenceByName(cmd.m_vsArgs[i]) == nullptr)
{ {
MAKE_INVALID("Unknown preference \"" + cmd.m_vsArgs[i] + "\"."); MAKE_INVALID("Unknown preference \"" + cmd.m_vsArgs[i] + "\".");
} }
@@ -526,7 +525,7 @@ int GetCreditsRequiredToPlayStyle( const Style *style )
static bool AreStyleAndPlayModeCompatible( const Style *style, PlayMode pm ) static bool AreStyleAndPlayModeCompatible( const Style *style, PlayMode pm )
{ {
if( style == NULL || pm == PlayMode_Invalid ) if( style == nullptr || pm == PlayMode_Invalid )
return true; return true;
switch( pm ) switch( pm )
@@ -596,10 +595,10 @@ bool GameCommand::IsPlayable( RString *why ) const
/* Don't allow a PlayMode that's incompatible with our current Style (if set), /* Don't allow a PlayMode that's incompatible with our current Style (if set),
* and vice versa. */ * and vice versa. */
if( m_pm != PlayMode_Invalid || m_pStyle != NULL ) if( m_pm != PlayMode_Invalid || m_pStyle != nullptr )
{ {
const PlayMode pm = (m_pm != PlayMode_Invalid) ? m_pm : GAMESTATE->m_PlayMode; const PlayMode pm = (m_pm != PlayMode_Invalid) ? m_pm : GAMESTATE->m_PlayMode;
const Style *style = (m_pStyle != NULL)? m_pStyle: GAMESTATE->GetCurrentStyle(GAMESTATE->GetMasterPlayerNumber()); const Style *style = (m_pStyle != nullptr)? m_pStyle: GAMESTATE->GetCurrentStyle(GAMESTATE->GetMasterPlayerNumber());
if( !AreStyleAndPlayModeCompatible( style, pm ) ) if( !AreStyleAndPlayModeCompatible( style, pm ) )
{ {
if( why ) if( why )
@@ -680,12 +679,12 @@ void GameCommand::Apply( const vector<PlayerNumber> &vpns ) const
if( m_Commands.v.size() ) if( m_Commands.v.size() )
{ {
// We were filled using a GameCommand from metrics. Apply the options in order. // We were filled using a GameCommand from metrics. Apply the options in order.
FOREACH_CONST( Command, m_Commands.v, cmd ) for (Command const &cmd : m_Commands.v)
{ {
GameCommand gc; GameCommand gc;
gc.m_bInvalid = false; gc.m_bInvalid = false;
gc.m_bApplyCommitsScreens = m_bApplyCommitsScreens; gc.m_bApplyCommitsScreens = m_bApplyCommitsScreens;
gc.LoadOne( *cmd ); gc.LoadOne( cmd );
gc.ApplySelf( vpns ); gc.ApplySelf( vpns );
} }
} }
@@ -704,7 +703,7 @@ void GameCommand::ApplySelf( const vector<PlayerNumber> &vpns ) const
if( m_pm != PlayMode_Invalid ) if( m_pm != PlayMode_Invalid )
GAMESTATE->m_PlayMode.Set( m_pm ); GAMESTATE->m_PlayMode.Set( m_pm );
if( m_pStyle != NULL ) if( m_pStyle != nullptr )
{ {
GAMESTATE->SetCurrentStyle( m_pStyle, GAMESTATE->GetMasterPlayerNumber() ); GAMESTATE->SetCurrentStyle( m_pStyle, GAMESTATE->GetMasterPlayerNumber() );
@@ -743,25 +742,25 @@ void GameCommand::ApplySelf( const vector<PlayerNumber> &vpns ) const
} }
} }
if( m_dc != Difficulty_Invalid ) if( m_dc != Difficulty_Invalid )
FOREACH_CONST( PlayerNumber, vpns, pn ) for (PlayerNumber const &pn : vpns)
GAMESTATE->m_PreferredDifficulty[*pn].Set( m_dc ); GAMESTATE->m_PreferredDifficulty[pn].Set( m_dc );
if( m_sAnnouncer != "" ) if( m_sAnnouncer != "" )
ANNOUNCER->SwitchAnnouncer( m_sAnnouncer ); ANNOUNCER->SwitchAnnouncer( m_sAnnouncer );
if( m_sPreferredModifiers != "" ) if( m_sPreferredModifiers != "" )
FOREACH_CONST( PlayerNumber, vpns, pn ) for (PlayerNumber const &pn : vpns)
GAMESTATE->ApplyPreferredModifiers( *pn, m_sPreferredModifiers ); GAMESTATE->ApplyPreferredModifiers( pn, m_sPreferredModifiers );
if( m_sStageModifiers != "" ) if( m_sStageModifiers != "" )
FOREACH_CONST( PlayerNumber, vpns, pn ) for (PlayerNumber const &pn : vpns)
GAMESTATE->ApplyStageModifiers( *pn, m_sStageModifiers ); GAMESTATE->ApplyStageModifiers( pn, m_sStageModifiers );
if( m_LuaFunction.IsSet() && !m_LuaFunction.IsNil() ) if( m_LuaFunction.IsSet() && !m_LuaFunction.IsNil() )
{ {
Lua *L = LUA->Get(); Lua *L = LUA->Get();
FOREACH_CONST( PlayerNumber, vpns, pn ) for (PlayerNumber const &pn : vpns)
{ {
m_LuaFunction.PushSelf( L ); m_LuaFunction.PushSelf( L );
ASSERT( !lua_isnil(L, -1) ); ASSERT( !lua_isnil(L, -1) );
lua_pushnumber( L, *pn ); // 1st parameter lua_pushnumber( L, pn ); // 1st parameter
RString error= "Lua GameCommand error: "; RString error= "Lua GameCommand error: ";
LuaHelpers::RunScriptOnStack(L, error, 1, 0, true); LuaHelpers::RunScriptOnStack(L, error, 1, 0, true);
} }
@@ -775,22 +774,22 @@ void GameCommand::ApplySelf( const vector<PlayerNumber> &vpns ) const
GAMESTATE->m_pPreferredSong = m_pSong; GAMESTATE->m_pPreferredSong = m_pSong;
} }
if( m_pSteps ) if( m_pSteps )
FOREACH_CONST( PlayerNumber, vpns, pn ) for (PlayerNumber const &pn : vpns)
GAMESTATE->m_pCurSteps[*pn].Set( m_pSteps ); GAMESTATE->m_pCurSteps[pn].Set( m_pSteps );
if( m_pCourse ) if( m_pCourse )
{ {
GAMESTATE->m_pCurCourse.Set( m_pCourse ); GAMESTATE->m_pCurCourse.Set( m_pCourse );
GAMESTATE->m_pPreferredCourse = m_pCourse; GAMESTATE->m_pPreferredCourse = m_pCourse;
} }
if( m_pTrail ) if( m_pTrail )
FOREACH_CONST( PlayerNumber, vpns, pn ) for (PlayerNumber const &pn : vpns)
GAMESTATE->m_pCurTrail[*pn].Set( m_pTrail ); GAMESTATE->m_pCurTrail[pn].Set( m_pTrail );
if( m_CourseDifficulty != Difficulty_Invalid ) if( m_CourseDifficulty != Difficulty_Invalid )
FOREACH_CONST( PlayerNumber, vpns, pn ) for (PlayerNumber const &pn : vpns)
GAMESTATE->ChangePreferredCourseDifficulty( *pn, m_CourseDifficulty ); GAMESTATE->ChangePreferredCourseDifficulty( pn, m_CourseDifficulty );
if( m_pCharacter ) if( m_pCharacter )
FOREACH_CONST( PlayerNumber, vpns, pn ) for (PlayerNumber const &pn : vpns)
GAMESTATE->m_pCurCharacters[*pn] = m_pCharacter; GAMESTATE->m_pCurCharacters[pn] = m_pCharacter;
for( map<RString,RString>::const_iterator i = m_SetEnv.begin(); i != m_SetEnv.end(); i++ ) for( map<RString,RString>::const_iterator i = m_SetEnv.begin(); i != m_SetEnv.end(); i++ )
{ {
Lua *L = LUA->Get(); Lua *L = LUA->Get();
@@ -804,7 +803,7 @@ void GameCommand::ApplySelf( const vector<PlayerNumber> &vpns ) const
for(map<RString,RString>::const_iterator setting= m_SetPref.begin(); setting != m_SetPref.end(); ++setting) for(map<RString,RString>::const_iterator setting= m_SetPref.begin(); setting != m_SetPref.end(); ++setting)
{ {
IPreference* pref= IPreference::GetPreferenceByName(setting->first); IPreference* pref= IPreference::GetPreferenceByName(setting->first);
if(pref != NULL) if(pref != nullptr)
{ {
pref->FromString(setting->second); pref->FromString(setting->second);
} }
@@ -816,17 +815,17 @@ void GameCommand::ApplySelf( const vector<PlayerNumber> &vpns ) const
if( m_sSoundPath != "" ) if( m_sSoundPath != "" )
SOUND->PlayOnce( THEME->GetPathS( "", m_sSoundPath ) ); SOUND->PlayOnce( THEME->GetPathS( "", m_sSoundPath ) );
if( m_iWeightPounds != -1 ) if( m_iWeightPounds != -1 )
FOREACH_CONST( PlayerNumber, vpns, pn ) for (PlayerNumber const &pn : vpns)
PROFILEMAN->GetProfile(*pn)->m_iWeightPounds = m_iWeightPounds; PROFILEMAN->GetProfile(pn)->m_iWeightPounds = m_iWeightPounds;
if( m_iGoalCalories != -1 ) if( m_iGoalCalories != -1 )
FOREACH_CONST( PlayerNumber, vpns, pn ) for (PlayerNumber const &pn : vpns)
PROFILEMAN->GetProfile(*pn)->m_iGoalCalories = m_iGoalCalories; PROFILEMAN->GetProfile(pn)->m_iGoalCalories = m_iGoalCalories;
if( m_GoalType != GoalType_Invalid ) if( m_GoalType != GoalType_Invalid )
FOREACH_CONST( PlayerNumber, vpns, pn ) for (PlayerNumber const &pn : vpns)
PROFILEMAN->GetProfile(*pn)->m_GoalType = m_GoalType; PROFILEMAN->GetProfile(pn)->m_GoalType = m_GoalType;
if( !m_sProfileID.empty() ) if( !m_sProfileID.empty() )
FOREACH_CONST( PlayerNumber, vpns, pn ) for (PlayerNumber const &pn : vpns)
ProfileManager::m_sDefaultLocalProfileID[*pn].Set( m_sProfileID ); ProfileManager::m_sDefaultLocalProfileID[pn].Set( m_sProfileID );
if( !m_sUrl.empty() ) if( !m_sUrl.empty() )
{ {
if( HOOKS->GoToURL( m_sUrl ) ) if( HOOKS->GoToURL( m_sUrl ) )
@@ -845,8 +844,8 @@ void GameCommand::ApplySelf( const vector<PlayerNumber> &vpns ) const
if( m_bFadeMusic ) if( m_bFadeMusic )
SOUND->DimMusic(m_fMusicFadeOutVolume, m_fMusicFadeOutSeconds); SOUND->DimMusic(m_fMusicFadeOutVolume, m_fMusicFadeOutSeconds);
FOREACH_CONST( RString, m_vsScreensToPrepare, s ) for (RString const &s : m_vsScreensToPrepare)
SCREENMAN->PrepareScreen( *s ); SCREENMAN->PrepareScreen( s );
if( m_bInsertCredit ) if( m_bInsertCredit )
{ {
@@ -886,16 +885,16 @@ void GameCommand::ApplySelf( const vector<PlayerNumber> &vpns ) const
bool GameCommand::IsZero() const bool GameCommand::IsZero() const
{ {
if( m_pm != PlayMode_Invalid || if( m_pm != PlayMode_Invalid ||
m_pStyle != NULL || m_pStyle != nullptr ||
m_dc != Difficulty_Invalid || m_dc != Difficulty_Invalid ||
m_sAnnouncer != "" || m_sAnnouncer != "" ||
m_sPreferredModifiers != "" || m_sPreferredModifiers != "" ||
m_sStageModifiers != "" || m_sStageModifiers != "" ||
m_pSong != NULL || m_pSong != nullptr ||
m_pSteps != NULL || m_pSteps != nullptr ||
m_pCourse != NULL || m_pCourse != nullptr ||
m_pTrail != NULL || m_pTrail != nullptr ||
m_pCharacter != NULL || m_pCharacter != nullptr ||
m_CourseDifficulty != Difficulty_Invalid || m_CourseDifficulty != Difficulty_Invalid ||
!m_sSongGroup.empty() || !m_sSongGroup.empty() ||
m_SortOrder != SortOrder_Invalid || m_SortOrder != SortOrder_Invalid ||
@@ -923,14 +922,14 @@ public:
static int GetText( T* p, lua_State *L ) { lua_pushstring(L, p->m_sText ); return 1; } static int GetText( T* p, lua_State *L ) { lua_pushstring(L, p->m_sText ); return 1; }
static int GetIndex( T* p, lua_State *L ) { lua_pushnumber(L, p->m_iIndex ); return 1; } static int GetIndex( T* p, lua_State *L ) { lua_pushnumber(L, p->m_iIndex ); return 1; }
static int GetMultiPlayer( T* p, lua_State *L ) { lua_pushnumber(L, p->m_MultiPlayer); return 1; } static int GetMultiPlayer( T* p, lua_State *L ) { lua_pushnumber(L, p->m_MultiPlayer); return 1; }
static int GetStyle( T* p, lua_State *L ) { if(p->m_pStyle==NULL) lua_pushnil(L); else {Style *pStyle = (Style*)p->m_pStyle; pStyle->PushSelf(L);} return 1; } static int GetStyle( T* p, lua_State *L ) { if(p->m_pStyle== nullptr) lua_pushnil(L); else {Style *pStyle = (Style*)p->m_pStyle; pStyle->PushSelf(L);} return 1; }
static int GetScreen( T* p, lua_State *L ) { lua_pushstring(L, p->m_sScreen ); return 1; } static int GetScreen( T* p, lua_State *L ) { lua_pushstring(L, p->m_sScreen ); return 1; }
static int GetProfileID( T* p, lua_State *L ) { lua_pushstring(L, p->m_sProfileID ); return 1; } static int GetProfileID( T* p, lua_State *L ) { lua_pushstring(L, p->m_sProfileID ); return 1; }
static int GetSong( T* p, lua_State *L ) { if(p->m_pSong==NULL) lua_pushnil(L); else p->m_pSong->PushSelf(L); return 1; } static int GetSong( T* p, lua_State *L ) { if(p->m_pSong== nullptr) lua_pushnil(L); else p->m_pSong->PushSelf(L); return 1; }
static int GetSteps( T* p, lua_State *L ) { if(p->m_pSteps==NULL) lua_pushnil(L); else p->m_pSteps->PushSelf(L); return 1; } static int GetSteps( T* p, lua_State *L ) { if(p->m_pSteps== nullptr) lua_pushnil(L); else p->m_pSteps->PushSelf(L); return 1; }
static int GetCourse( T* p, lua_State *L ) { if(p->m_pCourse==NULL) lua_pushnil(L); else p->m_pCourse->PushSelf(L); return 1; } static int GetCourse( T* p, lua_State *L ) { if(p->m_pCourse== nullptr) lua_pushnil(L); else p->m_pCourse->PushSelf(L); return 1; }
static int GetTrail( T* p, lua_State *L ) { if(p->m_pTrail==NULL) lua_pushnil(L); else p->m_pTrail->PushSelf(L); return 1; } static int GetTrail( T* p, lua_State *L ) { if(p->m_pTrail== nullptr) lua_pushnil(L); else p->m_pTrail->PushSelf(L); return 1; }
static int GetCharacter( T* p, lua_State *L ) { if(p->m_pCharacter==NULL) lua_pushnil(L); else p->m_pCharacter->PushSelf(L); return 1; } static int GetCharacter( T* p, lua_State *L ) { if(p->m_pCharacter== nullptr) lua_pushnil(L); else p->m_pCharacter->PushSelf(L); return 1; }
static int GetSongGroup( T* p, lua_State *L ) { lua_pushstring(L, p->m_sSongGroup ); return 1; } static int GetSongGroup( T* p, lua_State *L ) { lua_pushstring(L, p->m_sSongGroup ); return 1; }
static int GetUrl( T* p, lua_State *L ) { lua_pushstring(L, p->m_sUrl ); return 1; } static int GetUrl( T* p, lua_State *L ) { lua_pushstring(L, p->m_sUrl ); return 1; }
static int GetAnnouncer( T* p, lua_State *L ) { lua_pushstring(L, p->m_sAnnouncer ); return 1; } static int GetAnnouncer( T* p, lua_State *L ) { lua_pushstring(L, p->m_sAnnouncer ); return 1; }
+4 -4
View File
@@ -28,13 +28,13 @@ public:
GameCommand(): m_Commands(), m_sName(""), m_sText(""), GameCommand(): m_Commands(), m_sName(""), m_sText(""),
m_bInvalid(true), m_sInvalidReason(""), m_bInvalid(true), m_sInvalidReason(""),
m_iIndex(-1), m_MultiPlayer(MultiPlayer_Invalid), m_iIndex(-1), m_MultiPlayer(MultiPlayer_Invalid),
m_pStyle(NULL), m_pm(PlayMode_Invalid), m_pStyle(nullptr), m_pm(PlayMode_Invalid),
m_dc(Difficulty_Invalid), m_dc(Difficulty_Invalid),
m_CourseDifficulty(Difficulty_Invalid), m_CourseDifficulty(Difficulty_Invalid),
m_sAnnouncer(""), m_sPreferredModifiers(""), m_sAnnouncer(""), m_sPreferredModifiers(""),
m_sStageModifiers(""), m_sScreen(""), m_LuaFunction(), m_sStageModifiers(""), m_sScreen(""), m_LuaFunction(),
m_pSong(NULL), m_pSteps(NULL), m_pCourse(NULL), m_pSong(nullptr), m_pSteps(nullptr), m_pCourse(nullptr),
m_pTrail(NULL), m_pCharacter(NULL), m_SetEnv(), m_SetPref(), m_pTrail(nullptr), m_pCharacter(nullptr), m_SetEnv(), m_SetPref(),
m_sSongGroup(""), m_SortOrder(SortOrder_Invalid), m_sSongGroup(""), m_SortOrder(SortOrder_Invalid),
m_sSoundPath(""), m_vsScreensToPrepare(), m_iWeightPounds(-1), m_sSoundPath(""), m_vsScreensToPrepare(), m_iWeightPounds(-1),
m_iGoalCalories(-1), m_GoalType(GoalType_Invalid), m_iGoalCalories(-1), m_GoalType(GoalType_Invalid),
@@ -60,7 +60,7 @@ public:
bool DescribesCurrentMode( PlayerNumber pn ) const; bool DescribesCurrentMode( PlayerNumber pn ) const;
bool DescribesCurrentModeForAllPlayers() const; bool DescribesCurrentModeForAllPlayers() const;
bool IsPlayable( RString *why = NULL ) const; bool IsPlayable( RString *why = nullptr ) const;
bool IsZero() const; bool IsZero() const;
/* If true, Apply() will apply m_sScreen. If false, it won't, and you need /* If true, Apply() will apply m_sScreen. If false, it won't, and you need
+8 -13
View File
@@ -4,7 +4,7 @@
#include "RageUtil.h" #include "RageUtil.h"
#include "ThemeMetric.h" #include "ThemeMetric.h"
#include "EnumHelper.h" #include "EnumHelper.h"
#include "Foreach.h"
#include "LuaManager.h" #include "LuaManager.h"
#include "GameManager.h" #include "GameManager.h"
#include "LocalizedString.h" #include "LocalizedString.h"
@@ -375,10 +375,10 @@ void DisplayBpms::Add( float f )
float DisplayBpms::GetMin() const float DisplayBpms::GetMin() const
{ {
float fMin = FLT_MAX; float fMin = FLT_MAX;
FOREACH_CONST( float, vfBpms, f ) for (float const &f : vfBpms)
{ {
if( *f != -1 ) if( f != -1 )
fMin = min( fMin, *f ); fMin = min( fMin, f );
} }
if( fMin == FLT_MAX ) if( fMin == FLT_MAX )
return 0; return 0;
@@ -394,10 +394,10 @@ float DisplayBpms::GetMax() const
float DisplayBpms::GetMaxWithin(float highest) const float DisplayBpms::GetMaxWithin(float highest) const
{ {
float fMax = 0; float fMax = 0;
FOREACH_CONST( float, vfBpms, f ) for (float const &f : vfBpms)
{ {
if( *f != -1 ) if( f != -1 )
fMax = clamp(max( fMax, *f ), 0, highest); fMax = clamp(max( fMax, f ), 0, highest);
} }
return fMax; return fMax;
} }
@@ -409,12 +409,7 @@ bool DisplayBpms::BpmIsConstant() const
bool DisplayBpms::IsSecret() const bool DisplayBpms::IsSecret() const
{ {
FOREACH_CONST( float, vfBpms, f ) return std::any_of(vfBpms.begin(), vfBpms.end(), [](float const &f) { return f == -1; });
{
if( *f == -1 )
return true;
}
return false;
} }
static const char *StyleTypeNames[] = { static const char *StyleTypeNames[] = {
+7 -8
View File
@@ -76,16 +76,15 @@ static bool ChangeAppPri()
if( INPUTMAN ) if( INPUTMAN )
{ {
INPUTMAN->GetDevicesAndDescriptions(vDevices); INPUTMAN->GetDevicesAndDescriptions(vDevices);
FOREACH_CONST( InputDeviceInfo, vDevices, d ) if (std::any_of(vDevices.begin(), vDevices.end(), [](InputDeviceInfo const &d) {
{ return d.sDesc.find("NTPAD") != string::npos;
if( d->sDesc.find("NTPAD") != string::npos ) }))
{ {
LOG->Trace( "Using NTPAD. Don't boost priority." ); LOG->Trace( "Using NTPAD. Don't boost priority." );
return false; return false;
} }
} }
} }
}
#endif #endif
// If this is a debug build, don't. It makes the VC debugger sluggish. // If this is a debug build, don't. It makes the VC debugger sluggish.
@@ -181,7 +180,7 @@ namespace
void DoChangeGame() void DoChangeGame()
{ {
const Game* g= GAMEMAN->StringToGame(g_NewGame); const Game* g= GAMEMAN->StringToGame(g_NewGame);
ASSERT(g != NULL); ASSERT(g != nullptr);
GAMESTATE->SetCurGame(g); GAMESTATE->SetCurGame(g);
bool theme_changing= false; bool theme_changing= false;
@@ -358,7 +357,7 @@ private:
enum State { RENDERING_IDLE, RENDERING_START, RENDERING_ACTIVE, RENDERING_END }; enum State { RENDERING_IDLE, RENDERING_START, RENDERING_ACTIVE, RENDERING_END };
State m_State; State m_State;
}; };
static ConcurrentRenderer *g_pConcurrentRenderer = NULL; static ConcurrentRenderer *g_pConcurrentRenderer = nullptr;
ConcurrentRenderer::ConcurrentRenderer(): ConcurrentRenderer::ConcurrentRenderer():
m_Event("ConcurrentRenderer") m_Event("ConcurrentRenderer")
@@ -405,7 +404,7 @@ void ConcurrentRenderer::Stop()
void ConcurrentRenderer::RenderThread() void ConcurrentRenderer::RenderThread()
{ {
ASSERT( SCREENMAN != NULL ); ASSERT( SCREENMAN != nullptr );
while( !m_bShutdown ) while( !m_bShutdown )
{ {
@@ -462,7 +461,7 @@ int ConcurrentRenderer::StartRenderThread( void *p )
void GameLoop::StartConcurrentRendering() void GameLoop::StartConcurrentRendering()
{ {
if( g_pConcurrentRenderer == NULL ) if( g_pConcurrentRenderer == nullptr )
g_pConcurrentRenderer = new ConcurrentRenderer; g_pConcurrentRenderer = new ConcurrentRenderer;
g_pConcurrentRenderer->Start(); g_pConcurrentRenderer->Start();
} }
+758 -759
View File
File diff suppressed because it is too large Load Diff
+3 -3
View File
@@ -20,7 +20,7 @@
#include "arch/Sound/RageSoundDriver.h" #include "arch/Sound/RageSoundDriver.h"
GameSoundManager *SOUND = NULL; GameSoundManager *SOUND = nullptr;
/* /*
* When playing music, automatically search for an SM file for timing data. If one is * When playing music, automatically search for an SM file for timing data. If one is
@@ -436,7 +436,7 @@ int MusicThread_start( void *p )
GameSoundManager::GameSoundManager() GameSoundManager::GameSoundManager()
{ {
/* Init RageSoundMan first: */ /* Init RageSoundMan first: */
ASSERT( SOUNDMAN != NULL ); ASSERT( SOUNDMAN != nullptr );
g_Mutex = new RageEvent("GameSoundManager"); g_Mutex = new RageEvent("GameSoundManager");
g_Playing = new MusicPlaying( new RageSound ); g_Playing = new MusicPlaying( new RageSound );
@@ -875,7 +875,7 @@ public:
{ {
alignBeat = BArg(8); alignBeat = BArg(8);
} }
p->PlayMusic(musicPath, NULL, loop, musicStart, musicLength, p->PlayMusic(musicPath, nullptr, loop, musicStart, musicLength,
fadeIn, fadeOut, alignBeat, applyRate); fadeIn, fadeOut, alignBeat, applyRate);
COMMON_RETURN_SELF; COMMON_RETURN_SELF;
} }
+2 -2
View File
@@ -21,7 +21,7 @@ public:
{ {
PlayMusicParams() PlayMusicParams()
{ {
pTiming = NULL; pTiming = nullptr;
bForceLoop = false; bForceLoop = false;
fStartSecond = 0; fStartSecond = 0;
fLengthSeconds = -1; fLengthSeconds = -1;
@@ -44,7 +44,7 @@ public:
void PlayMusic( PlayMusicParams params, PlayMusicParams FallbackMusicParams = PlayMusicParams() ); void PlayMusic( PlayMusicParams params, PlayMusicParams FallbackMusicParams = PlayMusicParams() );
void PlayMusic( void PlayMusic(
RString sFile, RString sFile,
const TimingData *pTiming = NULL, const TimingData *pTiming = nullptr,
bool force_loop = false, bool force_loop = false,
float start_sec = 0, float start_sec = 0,
float length_sec = -1, float length_sec = -1,
+97 -99
View File
@@ -10,7 +10,6 @@
#include "CommonMetrics.h" #include "CommonMetrics.h"
#include "Course.h" #include "Course.h"
#include "CryptManager.h" #include "CryptManager.h"
#include "Foreach.h"
#include "Game.h" #include "Game.h"
#include "GameCommand.h" #include "GameCommand.h"
#include "GameConstantsAndTypes.h" #include "GameConstantsAndTypes.h"
@@ -46,7 +45,7 @@
#include <ctime> #include <ctime>
#include <set> #include <set>
GameState* GAMESTATE = NULL; // global and accessible from anywhere in our program GameState* GAMESTATE = nullptr; // global and accessible from anywhere in our program
#define NAME_BLACKLIST_FILE "/Data/NamesBlacklist.txt" #define NAME_BLACKLIST_FILE "/Data/NamesBlacklist.txt"
@@ -80,7 +79,7 @@ struct GameStateImpl
m_Subscriber.SubscribeToMessage( "RefreshCreditText" ); m_Subscriber.SubscribeToMessage( "RefreshCreditText" );
} }
}; };
static GameStateImpl *g_pImpl = NULL; static GameStateImpl *g_pImpl = nullptr;
ThemeMetric<bool> ALLOW_LATE_JOIN("GameState","AllowLateJoin"); ThemeMetric<bool> ALLOW_LATE_JOIN("GameState","AllowLateJoin");
ThemeMetric<bool> USE_NAME_BLACKLIST("GameState","UseNameBlacklist"); ThemeMetric<bool> USE_NAME_BLACKLIST("GameState","UseNameBlacklist");
@@ -111,7 +110,7 @@ static Preference<Premium> g_Premium( "Premium", Premium_DoubleFor1Credit );
Preference<bool> GameState::m_bAutoJoin( "AutoJoin", false ); Preference<bool> GameState::m_bAutoJoin( "AutoJoin", false );
GameState::GameState() : GameState::GameState() :
processedTiming( NULL ), processedTiming(nullptr),
m_pCurGame( Message_CurrentGameChanged ), m_pCurGame( Message_CurrentGameChanged ),
m_pCurStyle( Message_CurrentStyleChanged ), m_pCurStyle( Message_CurrentStyleChanged ),
m_PlayMode( Message_PlayModeChanged ), m_PlayMode( Message_PlayModeChanged ),
@@ -139,13 +138,13 @@ GameState::GameState() :
{ {
g_pImpl = new GameStateImpl; g_pImpl = new GameStateImpl;
m_pCurStyle.Set(NULL); m_pCurStyle.Set(nullptr);
FOREACH_PlayerNumber(rpn) FOREACH_PlayerNumber(rpn)
{ {
m_SeparatedStyles[rpn]= NULL; m_SeparatedStyles[rpn]= nullptr;
} }
m_pCurGame.Set( NULL ); m_pCurGame.Set(nullptr);
m_iCoins.Set( 0 ); m_iCoins.Set( 0 );
m_timeGameStarted.SetZero(); m_timeGameStarted.SetZero();
m_bDemonstrationOrJukebox = false; m_bDemonstrationOrJukebox = false;
@@ -247,7 +246,7 @@ void GameState::ApplyCmdline()
RString sPlayer; RString sPlayer;
for( int i = 0; GetCommandlineArgument( "player", &sPlayer, i ); ++i ) for( int i = 0; GetCommandlineArgument( "player", &sPlayer, i ); ++i )
{ {
int pn = StringToInt( sPlayer )-1; int pn = std::stoi( sPlayer )-1;
if( !IsAnInt( sPlayer ) || pn < 0 || pn >= NUM_PLAYERS ) if( !IsAnInt( sPlayer ) || pn < 0 || pn >= NUM_PLAYERS )
RageException::Throw( "Invalid argument \"--player=%s\".", sPlayer.c_str() ); RageException::Throw( "Invalid argument \"--player=%s\".", sPlayer.c_str() );
@@ -268,8 +267,8 @@ void GameState::ResetPlayer( PlayerNumber pn )
m_PreferredCourseDifficulty[pn].Set( Difficulty_Medium ); m_PreferredCourseDifficulty[pn].Set( Difficulty_Medium );
m_iPlayerStageTokens[pn] = 0; m_iPlayerStageTokens[pn] = 0;
m_iAwardedExtraStages[pn] = 0; m_iAwardedExtraStages[pn] = 0;
m_pCurSteps[pn].Set( NULL ); m_pCurSteps[pn].Set(nullptr);
m_pCurTrail[pn].Set( NULL ); m_pCurTrail[pn].Set(nullptr);
m_pPlayerState[pn]->Reset(); m_pPlayerState[pn]->Reset();
PROFILEMAN->UnloadProfile( pn ); PROFILEMAN->UnloadProfile( pn );
ResetPlayerOptions(pn); ResetPlayerOptions(pn);
@@ -289,15 +288,14 @@ void GameState::Reset()
FOREACH_PlayerNumber( pn ) FOREACH_PlayerNumber( pn )
UnjoinPlayer( pn ); UnjoinPlayer( pn );
ASSERT( THEME != NULL ); ASSERT( THEME != nullptr );
m_timeGameStarted.SetZero(); m_timeGameStarted.SetZero();
SetCurrentStyle( NULL, PLAYER_INVALID ); SetCurrentStyle( nullptr, PLAYER_INVALID );
FOREACH_MultiPlayer( p ) FOREACH_MultiPlayer( p )
m_MultiPlayerStatus[p] = MultiPlayerStatus_NotJoined; m_MultiPlayerStatus[p] = MultiPlayerStatus_NotJoined;
FOREACH_PlayerNumber( pn ) FOREACH_PlayerNumber( pn )
MEMCARDMAN->UnlockCard( pn ); MEMCARDMAN->UnlockCard( pn );
//m_iCoins = 0; // don't reset coin count!
m_bMultiplayer = false; m_bMultiplayer = false;
m_iNumMultiplayerNoteFields = 1; m_iNumMultiplayerNoteFields = 1;
*m_Environment = LuaTable(); *m_Environment = LuaTable();
@@ -324,9 +322,9 @@ void GameState::Reset()
m_AdjustTokensBySongCostForFinalStageCheck= true; m_AdjustTokensBySongCostForFinalStageCheck= true;
m_pCurSong.Set( GetDefaultSong() ); m_pCurSong.Set( GetDefaultSong() );
m_pPreferredSong = NULL; m_pPreferredSong = nullptr;
m_pCurCourse.Set( NULL ); m_pCurCourse.Set(nullptr);
m_pPreferredCourse = NULL; m_pPreferredCourse = nullptr;
FOREACH_MultiPlayer( p ) FOREACH_MultiPlayer( p )
m_pMultiPlayerState[p]->Reset(); m_pMultiPlayerState[p]->Reset();
@@ -353,7 +351,7 @@ void GameState::Reset()
m_pCurCharacters[p] = CHARMAN->GetRandomCharacter(); m_pCurCharacters[p] = CHARMAN->GetRandomCharacter();
else else
m_pCurCharacters[p] = CHARMAN->GetDefaultCharacter(); m_pCurCharacters[p] = CHARMAN->GetDefaultCharacter();
ASSERT( m_pCurCharacters[p] != NULL ); ASSERT( m_pCurCharacters[p] != nullptr );
} }
m_bTemporaryEventMode = false; m_bTemporaryEventMode = false;
@@ -361,7 +359,7 @@ void GameState::Reset()
LIGHTSMAN->SetLightsMode( LIGHTSMODE_ATTRACT ); LIGHTSMAN->SetLightsMode( LIGHTSMODE_ATTRACT );
m_stEdit.Set( StepsType_Invalid ); m_stEdit.Set( StepsType_Invalid );
m_pEditSourceSteps.Set( NULL ); m_pEditSourceSteps.Set(nullptr);
m_stEditSource.Set( StepsType_Invalid ); m_stEditSource.Set( StepsType_Invalid );
m_iEditCourseEntryIndex.Set( -1 ); m_iEditCourseEntryIndex.Set( -1 );
m_sEditLocalProfileID.Set( "" ); m_sEditLocalProfileID.Set( "" );
@@ -389,7 +387,7 @@ void GameState::JoinPlayer( PlayerNumber pn )
{ {
const Style* new_style= GAMEMAN->GetFirstCompatibleStyle(m_pCurGame, const Style* new_style= GAMEMAN->GetFirstCompatibleStyle(m_pCurGame,
players_joined + 1, cur_style->m_StepsType); players_joined + 1, cur_style->m_StepsType);
if(new_style == NULL) if(new_style == nullptr)
{ {
return; return;
} }
@@ -427,7 +425,7 @@ void GameState::JoinPlayer( PlayerNumber pn )
// assume that the second player will be joined immediately afterwards and // assume that the second player will be joined immediately afterwards and
// don't try to change the style. -Kyz // don't try to change the style. -Kyz
const Style* cur_style= GetCurrentStyle(PLAYER_INVALID); const Style* cur_style= GetCurrentStyle(PLAYER_INVALID);
if(cur_style != NULL && !(pn == PLAYER_1 && if(cur_style != nullptr && !(pn == PLAYER_1 &&
(cur_style->m_StyleType == StyleType_TwoPlayersTwoSides || (cur_style->m_StyleType == StyleType_TwoPlayersTwoSides ||
cur_style->m_StyleType == StyleType_TwoPlayersSharedSides))) cur_style->m_StyleType == StyleType_TwoPlayersSharedSides)))
{ {
@@ -684,7 +682,7 @@ int GameState::GetNumStagesMultiplierForSong( const Song* pSong )
{ {
int iNumStages = 1; int iNumStages = 1;
ASSERT( pSong != NULL ); ASSERT( pSong != nullptr );
if( pSong->IsMarathon() ) if( pSong->IsMarathon() )
iNumStages *= 3; iNumStages *= 3;
if( pSong->IsLong() ) if( pSong->IsLong() )
@@ -883,9 +881,9 @@ void GameState::LoadCurrentSettingsFromProfile( PlayerNumber pn )
// Only set the PreferredStepsType if it wasn't already set by a GameCommand (or by an earlier profile) // Only set the PreferredStepsType if it wasn't already set by a GameCommand (or by an earlier profile)
if( m_PreferredStepsType == StepsType_Invalid && pProfile->m_LastStepsType != StepsType_Invalid ) if( m_PreferredStepsType == StepsType_Invalid && pProfile->m_LastStepsType != StepsType_Invalid )
m_PreferredStepsType.Set( pProfile->m_LastStepsType ); m_PreferredStepsType.Set( pProfile->m_LastStepsType );
if( m_pPreferredSong == NULL ) if( m_pPreferredSong == nullptr )
m_pPreferredSong = pProfile->m_lastSong.ToSong(); m_pPreferredSong = pProfile->m_lastSong.ToSong();
if( m_pPreferredCourse == NULL ) if( m_pPreferredCourse == nullptr )
m_pPreferredCourse = pProfile->m_lastCourse.ToCourse(); m_pPreferredCourse = pProfile->m_lastCourse.ToCourse();
} }
@@ -918,35 +916,35 @@ bool GameState::CanSafelyEnterGameplay(RString& reason)
if(!IsCourseMode()) if(!IsCourseMode())
{ {
Song const* song= m_pCurSong; Song const* song= m_pCurSong;
if(song == NULL) if(song == nullptr)
{ {
reason= "Current song is NULL."; reason= "Current song is null.";
return false; return false;
} }
} }
else else
{ {
Course const* song= m_pCurCourse; Course const* song= m_pCurCourse;
if(song == NULL) if(song == nullptr)
{ {
reason= "Current course is NULL."; reason= "Current course is null.";
return false; return false;
} }
} }
FOREACH_EnabledPlayer(pn) FOREACH_EnabledPlayer(pn)
{ {
Style const* style= GetCurrentStyle(pn); Style const* style= GetCurrentStyle(pn);
if(style == NULL) if(style == nullptr)
{ {
reason= ssprintf("Style for player %d is NULL.", pn+1); reason= ssprintf("Style for player %d is null.", pn+1);
return false; return false;
} }
if(!IsCourseMode()) if(!IsCourseMode())
{ {
Steps const* steps= m_pCurSteps[pn]; Steps const* steps= m_pCurSteps[pn];
if(steps == NULL) if(steps == nullptr)
{ {
reason= ssprintf("Steps for player %d is NULL.", pn+1); reason= ssprintf("Steps for player %d is null.", pn+1);
return false; return false;
} }
if(steps->m_StepsType != style->m_StepsType) if(steps->m_StepsType != style->m_StepsType)
@@ -975,9 +973,9 @@ bool GameState::CanSafelyEnterGameplay(RString& reason)
else else
{ {
Trail const* steps= m_pCurTrail[pn]; Trail const* steps= m_pCurTrail[pn];
if(steps == NULL) if(steps == nullptr)
{ {
reason= ssprintf("Steps for player %d is NULL.", pn+1); reason= ssprintf("Steps for player %d is null.", pn+1);
return false; return false;
} }
if(steps->m_StepsType != style->m_StepsType) if(steps->m_StepsType != style->m_StepsType)
@@ -998,16 +996,16 @@ void GameState::SetCompatibleStylesForPlayers()
bool style_set= false; bool style_set= false;
if(IsCourseMode()) if(IsCourseMode())
{ {
if(m_pCurCourse != NULL) if(m_pCurCourse != nullptr)
{ {
const Style* style= m_pCurCourse->GetCourseStyle(m_pCurGame, GetNumSidesJoined()); const Style* style= m_pCurCourse->GetCourseStyle(m_pCurGame, GetNumSidesJoined());
if(style != NULL) if(style != nullptr)
{ {
style_set= true; style_set= true;
SetCurrentStyle(style, PLAYER_INVALID); SetCurrentStyle(style, PLAYER_INVALID);
} }
} }
else if(GetCurrentStyle(PLAYER_INVALID) == NULL) else if(GetCurrentStyle(PLAYER_INVALID) == nullptr)
{ {
vector<StepsType> vst; vector<StepsType> vst;
GAMEMAN->GetStepsTypesForGame(m_pCurGame, vst); GAMEMAN->GetStepsTypesForGame(m_pCurGame, vst);
@@ -1021,11 +1019,11 @@ void GameState::SetCompatibleStylesForPlayers()
FOREACH_EnabledPlayer(pn) FOREACH_EnabledPlayer(pn)
{ {
StepsType st= StepsType_Invalid; StepsType st= StepsType_Invalid;
if(m_pCurSteps[pn] != NULL) if(m_pCurSteps[pn] != nullptr)
{ {
st= m_pCurSteps[pn]->m_StepsType; st= m_pCurSteps[pn]->m_StepsType;
} }
else if(m_pCurTrail[pn] != NULL) else if(m_pCurTrail[pn] != nullptr)
{ {
st= m_pCurTrail[pn]->m_StepsType; st= m_pCurTrail[pn]->m_StepsType;
} }
@@ -1045,11 +1043,11 @@ void GameState::SetCompatibleStylesForPlayers()
void GameState::ForceSharedSidesMatch() void GameState::ForceSharedSidesMatch()
{ {
PlayerNumber pn_with_shared= PLAYER_INVALID; PlayerNumber pn_with_shared= PLAYER_INVALID;
const Style* shared_style= NULL; const Style* shared_style= nullptr;
FOREACH_EnabledPlayer(pn) FOREACH_EnabledPlayer(pn)
{ {
const Style* style= GetCurrentStyle(pn); const Style* style= GetCurrentStyle(pn);
ASSERT_M(style != NULL, "Style being null should not be possible."); ASSERT_M(style != nullptr, "Style being null should not be possible.");
if(style->m_StyleType == StyleType_TwoPlayersSharedSides) if(style->m_StyleType == StyleType_TwoPlayersSharedSides)
{ {
pn_with_shared= pn; pn_with_shared= pn;
@@ -1061,7 +1059,7 @@ void GameState::ForceSharedSidesMatch()
ASSERT_M(GetNumPlayersEnabled() == 2, "2 players must be enabled for shared sides."); ASSERT_M(GetNumPlayersEnabled() == 2, "2 players must be enabled for shared sides.");
PlayerNumber other_pn= OPPOSITE_PLAYER[pn_with_shared]; PlayerNumber other_pn= OPPOSITE_PLAYER[pn_with_shared];
const Style* other_style= GetCurrentStyle(other_pn); const Style* other_style= GetCurrentStyle(other_pn);
ASSERT_M(other_style != NULL, "Other player's style being null should not be possible."); ASSERT_M(other_style != nullptr, "Other player's style being null should not be possible.");
if(other_style->m_StyleType != StyleType_TwoPlayersSharedSides) if(other_style->m_StyleType != StyleType_TwoPlayersSharedSides)
{ {
SetCurrentStyle(shared_style, other_pn); SetCurrentStyle(shared_style, other_pn);
@@ -1082,7 +1080,7 @@ void GameState::ForceOtherPlayersToCompatibleSteps(PlayerNumber main)
if(IsCourseMode()) if(IsCourseMode())
{ {
Trail* steps_to_match= m_pCurTrail[main].Get(); Trail* steps_to_match= m_pCurTrail[main].Get();
if(steps_to_match == NULL) { return; } if(steps_to_match == nullptr) { return; }
int num_players= GAMESTATE->GetNumPlayersEnabled(); int num_players= GAMESTATE->GetNumPlayersEnabled();
StyleType styletype_to_match= GAMEMAN->GetFirstCompatibleStyle( StyleType styletype_to_match= GAMEMAN->GetFirstCompatibleStyle(
GAMESTATE->GetCurrentGame(), num_players, steps_to_match->m_StepsType) GAMESTATE->GetCurrentGame(), num_players, steps_to_match->m_StepsType)
@@ -1090,8 +1088,8 @@ void GameState::ForceOtherPlayersToCompatibleSteps(PlayerNumber main)
FOREACH_EnabledPlayer(pn) FOREACH_EnabledPlayer(pn)
{ {
Trail* pn_steps= m_pCurTrail[pn].Get(); Trail* pn_steps= m_pCurTrail[pn].Get();
bool match_failed= pn_steps == NULL; bool match_failed= pn_steps == nullptr;
if(steps_to_match != pn_steps && pn_steps != NULL) if(steps_to_match != pn_steps && pn_steps != nullptr)
{ {
StyleType pn_styletype= GAMEMAN->GetFirstCompatibleStyle( StyleType pn_styletype= GAMEMAN->GetFirstCompatibleStyle(
GAMESTATE->GetCurrentGame(), num_players, pn_steps->m_StepsType) GAMESTATE->GetCurrentGame(), num_players, pn_steps->m_StepsType)
@@ -1111,7 +1109,7 @@ void GameState::ForceOtherPlayersToCompatibleSteps(PlayerNumber main)
else else
{ {
Steps* steps_to_match= m_pCurSteps[main].Get(); Steps* steps_to_match= m_pCurSteps[main].Get();
if(steps_to_match == NULL) { return; } if(steps_to_match == nullptr) { return; }
int num_players= GAMESTATE->GetNumPlayersEnabled(); int num_players= GAMESTATE->GetNumPlayersEnabled();
StyleType styletype_to_match= GAMEMAN->GetFirstCompatibleStyle( StyleType styletype_to_match= GAMEMAN->GetFirstCompatibleStyle(
GAMESTATE->GetCurrentGame(), num_players, steps_to_match->m_StepsType) GAMESTATE->GetCurrentGame(), num_players, steps_to_match->m_StepsType)
@@ -1120,8 +1118,8 @@ void GameState::ForceOtherPlayersToCompatibleSteps(PlayerNumber main)
FOREACH_EnabledPlayer(pn) FOREACH_EnabledPlayer(pn)
{ {
Steps* pn_steps= m_pCurSteps[pn].Get(); Steps* pn_steps= m_pCurSteps[pn].Get();
bool match_failed= pn_steps == NULL; bool match_failed= pn_steps == nullptr;
if(steps_to_match != pn_steps && pn_steps != NULL) if(steps_to_match != pn_steps && pn_steps != nullptr)
{ {
StyleType pn_styletype= GAMEMAN->GetFirstCompatibleStyle( StyleType pn_styletype= GAMEMAN->GetFirstCompatibleStyle(
GAMESTATE->GetCurrentGame(), num_players, pn_steps->m_StepsType) GAMESTATE->GetCurrentGame(), num_players, pn_steps->m_StepsType)
@@ -1315,7 +1313,7 @@ bool GameState::IsFinalStageForAnyHumanPlayer() const
bool GameState::IsFinalStageForEveryHumanPlayer() const bool GameState::IsFinalStageForEveryHumanPlayer() const
{ {
int song_cost= 1; int song_cost= 1;
if(m_pCurSong != NULL) if(m_pCurSong != nullptr)
{ {
if(m_pCurSong->IsLong()) if(m_pCurSong->IsLong())
{ {
@@ -1434,7 +1432,7 @@ static char const* prepare_song_failures[]= {
int GameState::prepare_song_for_gameplay() int GameState::prepare_song_for_gameplay()
{ {
Song* curr= m_pCurSong; Song* curr= m_pCurSong;
if(curr == NULL) if(curr == nullptr)
{ {
return 1; return 1;
} }
@@ -1504,9 +1502,9 @@ bool GameState::PlayersCanJoin() const
{ {
return true; return true;
} }
// If we check the style and it comes up NULL, either the style has not been // If we check the style and it comes up nullptr, either the style has not been
// chosen, or we're on ScreenSelectMusic with AutoSetStyle. // chosen, or we're on ScreenSelectMusic with AutoSetStyle.
// If the style does not come up NULL, we might be on a screen in a custom // If the style does not come up nullptr, we might be on a screen in a custom
// theme that wants to allow joining after the style is set anyway. // theme that wants to allow joining after the style is set anyway.
// Either way, we can't use the existence of a style to decide. // Either way, we can't use the existence of a style to decide.
// -Kyz // -Kyz
@@ -1529,7 +1527,7 @@ bool GameState::PlayersCanJoin() const
{ {
const Style* compat_style= GAMEMAN->GetFirstCompatibleStyle( const Style* compat_style= GAMEMAN->GetFirstCompatibleStyle(
m_pCurGame, 2, style->m_StepsType); m_pCurGame, 2, style->m_StepsType);
if(compat_style == NULL) if(compat_style == nullptr)
{ {
return false; return false;
} }
@@ -1551,13 +1549,13 @@ int GameState::GetNumSidesJoined() const
const Game* GameState::GetCurrentGame() const const Game* GameState::GetCurrentGame() const
{ {
ASSERT( m_pCurGame != NULL ); // the game must be set before calling this ASSERT( m_pCurGame != nullptr ); // the game must be set before calling this
return m_pCurGame; return m_pCurGame;
} }
const Style* GameState::GetCurrentStyle(PlayerNumber pn) const const Style* GameState::GetCurrentStyle(PlayerNumber pn) const
{ {
if(GetCurrentGame() == NULL) { return NULL; } if(GetCurrentGame() == nullptr) { return nullptr; }
if(!GetCurrentGame()->m_PlayersHaveSeparateStyles) if(!GetCurrentGame()->m_PlayersHaveSeparateStyles)
{ {
return m_pCurStyle; return m_pCurStyle;
@@ -1566,7 +1564,7 @@ const Style* GameState::GetCurrentStyle(PlayerNumber pn) const
{ {
if(pn >= NUM_PLAYERS) if(pn >= NUM_PLAYERS)
{ {
return m_SeparatedStyles[PLAYER_1] == NULL ? m_SeparatedStyles[PLAYER_2] return m_SeparatedStyles[PLAYER_1] == nullptr ? m_SeparatedStyles[PLAYER_2]
: m_SeparatedStyles[PLAYER_1]; : m_SeparatedStyles[PLAYER_1];
} }
return m_SeparatedStyles[pn]; return m_SeparatedStyles[pn];
@@ -1677,7 +1675,7 @@ bool GameState::IsHumanPlayer( PlayerNumber pn ) const
if(GetCurrentGame()->m_PlayersHaveSeparateStyles) if(GetCurrentGame()->m_PlayersHaveSeparateStyles)
{ {
if( GetCurrentStyle(pn) == NULL ) // no style chosen if( GetCurrentStyle(pn) == nullptr ) // no style chosen
{ {
return m_bSideIsJoined[pn]; return m_bSideIsJoined[pn];
} }
@@ -1697,7 +1695,7 @@ bool GameState::IsHumanPlayer( PlayerNumber pn ) const
} }
} }
} }
if( GetCurrentStyle(pn) == NULL ) // no style chosen if( GetCurrentStyle(pn) == nullptr ) // no style chosen
{ {
return m_bSideIsJoined[pn]; // only allow input from sides that have already joined return m_bSideIsJoined[pn]; // only allow input from sides that have already joined
} }
@@ -1942,12 +1940,12 @@ void GameState::GetAllUsedNoteSkins( vector<RString> &out ) const
if( IsCourseMode() ) if( IsCourseMode() )
{ {
const Trail *pTrail = m_pCurTrail[pn]; const Trail *pTrail = m_pCurTrail[pn];
ASSERT( pTrail != NULL ); ASSERT( pTrail != nullptr );
FOREACH_CONST( TrailEntry, pTrail->m_vEntries, e ) for (TrailEntry const &e : pTrail->m_vEntries)
{ {
PlayerOptions po; PlayerOptions po;
po.FromString( e->Modifiers ); po.FromString( e.Modifiers );
if( !po.m_sNoteSkin.empty() ) if( !po.m_sNoteSkin.empty() )
out.push_back( po.m_sNoteSkin ); out.push_back( po.m_sNoteSkin );
} }
@@ -2074,11 +2072,11 @@ void GameState::GetRankingFeats( PlayerNumber pn, vector<RankingFeat> &asFeatsOu
SongAndSteps sas; SongAndSteps sas;
ASSERT( !STATSMAN->m_vPlayedStageStats[i].m_vpPlayedSongs.empty() ); ASSERT( !STATSMAN->m_vPlayedStageStats[i].m_vpPlayedSongs.empty() );
sas.pSong = STATSMAN->m_vPlayedStageStats[i].m_vpPlayedSongs[0]; sas.pSong = STATSMAN->m_vPlayedStageStats[i].m_vpPlayedSongs[0];
ASSERT( sas.pSong != NULL ); ASSERT( sas.pSong != nullptr );
if( STATSMAN->m_vPlayedStageStats[i].m_player[pn].m_vpPossibleSteps.empty() ) if( STATSMAN->m_vPlayedStageStats[i].m_player[pn].m_vpPossibleSteps.empty() )
continue; continue;
sas.pSteps = STATSMAN->m_vPlayedStageStats[i].m_player[pn].m_vpPossibleSteps[0]; sas.pSteps = STATSMAN->m_vPlayedStageStats[i].m_player[pn].m_vpPossibleSteps[0];
ASSERT( sas.pSteps != NULL ); ASSERT( sas.pSteps != nullptr );
vSongAndSteps.push_back( sas ); vSongAndSteps.push_back( sas );
} }
CHECKPOINT_M( ssprintf("All songs/steps from %s gathered", modeStr)); CHECKPOINT_M( ssprintf("All songs/steps from %s gathered", modeStr));
@@ -2215,9 +2213,9 @@ void GameState::GetRankingFeats( PlayerNumber pn, vector<RankingFeat> &asFeatsOu
case PLAY_MODE_ENDLESS: case PLAY_MODE_ENDLESS:
{ {
Course* pCourse = m_pCurCourse; Course* pCourse = m_pCurCourse;
ASSERT( pCourse != NULL ); ASSERT( pCourse != nullptr );
Trail *pTrail = m_pCurTrail[pn]; Trail *pTrail = m_pCurTrail[pn];
ASSERT( pTrail != NULL ); ASSERT( pTrail != nullptr );
CourseDifficulty cd = pTrail->m_CourseDifficulty; CourseDifficulty cd = pTrail->m_CourseDifficulty;
// Find Machine Records // Find Machine Records
@@ -2336,23 +2334,23 @@ void GameState::StoreRankingName( PlayerNumber pn, RString sName )
if( !PREFSMAN->m_bAllowMultipleHighScoreWithSameName ) if( !PREFSMAN->m_bAllowMultipleHighScoreWithSameName )
{ {
// erase all but the highest score for each name // erase all but the highest score for each name
FOREACHM( SongID, Profile::HighScoresForASong, pProfile->m_SongHighScores, iter ) for (auto &songIter : pProfile->m_SongHighScores)
FOREACHM( StepsID, Profile::HighScoresForASteps, iter->second.m_StepsHighScores, iter2 ) for (auto &stepIter : songIter.second.m_StepsHighScores)
iter2->second.hsl.RemoveAllButOneOfEachName(); stepIter.second.hsl.RemoveAllButOneOfEachName();
FOREACHM( CourseID, Profile::HighScoresForACourse, pProfile->m_CourseHighScores, iter ) for (auto &courseIter : pProfile->m_CourseHighScores)
FOREACHM( TrailID, Profile::HighScoresForATrail, iter->second.m_TrailHighScores, iter2 ) for (auto &trailIter : courseIter.second.m_TrailHighScores)
iter2->second.hsl.RemoveAllButOneOfEachName(); trailIter.second.hsl.RemoveAllButOneOfEachName();
} }
// clamp high score sizes // clamp high score sizes
FOREACHM( SongID, Profile::HighScoresForASong, pProfile->m_SongHighScores, iter ) for (auto &songIter : pProfile->m_SongHighScores)
FOREACHM( StepsID, Profile::HighScoresForASteps, iter->second.m_StepsHighScores, iter2 ) for (auto &stepIter : songIter.second.m_StepsHighScores)
iter2->second.hsl.ClampSize( true ); stepIter.second.hsl.ClampSize( true );
FOREACHM( CourseID, Profile::HighScoresForACourse, pProfile->m_CourseHighScores, iter ) for (auto &courseIter : pProfile->m_CourseHighScores)
FOREACHM( TrailID, Profile::HighScoresForATrail, iter->second.m_TrailHighScores, iter2 ) for (auto &trailIter : courseIter.second.m_TrailHighScores)
iter2->second.hsl.ClampSize( true ); trailIter.second.hsl.ClampSize( true );
} }
bool GameState::AllAreInDangerOrWorse() const bool GameState::AllAreInDangerOrWorse() const
@@ -2452,15 +2450,15 @@ Difficulty GameState::GetClosestShownDifficulty( PlayerNumber pn ) const
Difficulty iClosest = (Difficulty) 0; Difficulty iClosest = (Difficulty) 0;
int iClosestDist = -1; int iClosestDist = -1;
FOREACH_CONST( Difficulty, v, dc ) for (Difficulty const &dc : v)
{ {
int iDist = m_PreferredDifficulty[pn] - *dc; int iDist = m_PreferredDifficulty[pn] - dc;
if( iDist < 0 ) if( iDist < 0 )
continue; continue;
if( iClosestDist != -1 && iDist > iClosestDist ) if( iClosestDist != -1 && iDist > iClosestDist )
continue; continue;
iClosestDist = iDist; iClosestDist = iDist;
iClosest = *dc; iClosest = dc;
} }
return iClosest; return iClosest;
@@ -2516,7 +2514,7 @@ Difficulty GameState::GetEasiestStepsDifficulty() const
Difficulty dc = Difficulty_Invalid; Difficulty dc = Difficulty_Invalid;
FOREACH_HumanPlayer( p ) FOREACH_HumanPlayer( p )
{ {
if( m_pCurSteps[p] == NULL ) if( m_pCurSteps[p] == nullptr )
{ {
LuaHelpers::ReportScriptErrorFmt( "GetEasiestStepsDifficulty called but p%i hasn't chosen notes", p+1 ); LuaHelpers::ReportScriptErrorFmt( "GetEasiestStepsDifficulty called but p%i hasn't chosen notes", p+1 );
continue; continue;
@@ -2531,7 +2529,7 @@ Difficulty GameState::GetHardestStepsDifficulty() const
Difficulty dc = Difficulty_Beginner; Difficulty dc = Difficulty_Beginner;
FOREACH_HumanPlayer( p ) FOREACH_HumanPlayer( p )
{ {
if( m_pCurSteps[p] == NULL ) if( m_pCurSteps[p] == nullptr )
{ {
LuaHelpers::ReportScriptErrorFmt( "GetHardestStepsDifficulty called but p%i hasn't chosen notes", p+1 ); LuaHelpers::ReportScriptErrorFmt( "GetHardestStepsDifficulty called but p%i hasn't chosen notes", p+1 );
continue; continue;
@@ -2608,7 +2606,7 @@ bool GameState::PlayerIsUsingModifier( PlayerNumber pn, const RString &sModifier
Profile* GameState::GetEditLocalProfile() Profile* GameState::GetEditLocalProfile()
{ {
if( m_sEditLocalProfileID.Get().empty() ) if( m_sEditLocalProfileID.Get().empty() )
return NULL; return nullptr;
return PROFILEMAN->GetLocalProfile( m_sEditLocalProfileID ); return PROFILEMAN->GetLocalProfile( m_sEditLocalProfileID );
} }
@@ -2714,7 +2712,7 @@ public:
static int GetCurrentSong( T* p, lua_State *L ) { if(p->m_pCurSong) p->m_pCurSong->PushSelf(L); else lua_pushnil(L); return 1; } static int GetCurrentSong( T* p, lua_State *L ) { if(p->m_pCurSong) p->m_pCurSong->PushSelf(L); else lua_pushnil(L); return 1; }
static int SetCurrentSong( T* p, lua_State *L ) static int SetCurrentSong( T* p, lua_State *L )
{ {
if( lua_isnil(L,1) ) { p->m_pCurSong.Set( NULL ); } if( lua_isnil(L,1) ) { p->m_pCurSong.Set(nullptr); }
else { Song *pS = Luna<Song>::check( L, 1, true ); p->m_pCurSong.Set( pS ); } else { Song *pS = Luna<Song>::check( L, 1, true ); p->m_pCurSong.Set( pS ); }
COMMON_RETURN_SELF; COMMON_RETURN_SELF;
} }
@@ -2750,7 +2748,7 @@ public:
PlayerNumber pn = Enum::Check<PlayerNumber>(L, 1); PlayerNumber pn = Enum::Check<PlayerNumber>(L, 1);
if(lua_isnil(L,2)) if(lua_isnil(L,2))
{ {
p->m_pCurSteps[pn].Set(NULL); p->m_pCurSteps[pn].Set(nullptr);
} }
else else
{ {
@@ -2764,7 +2762,7 @@ public:
static int GetCurrentCourse( T* p, lua_State *L ) { if(p->m_pCurCourse) p->m_pCurCourse->PushSelf(L); else lua_pushnil(L); return 1; } static int GetCurrentCourse( T* p, lua_State *L ) { if(p->m_pCurCourse) p->m_pCurCourse->PushSelf(L); else lua_pushnil(L); return 1; }
static int SetCurrentCourse( T* p, lua_State *L ) static int SetCurrentCourse( T* p, lua_State *L )
{ {
if( lua_isnil(L,1) ) { p->m_pCurCourse.Set( NULL ); } if( lua_isnil(L,1) ) { p->m_pCurCourse.Set(nullptr); }
else { Course *pC = Luna<Course>::check(L,1); p->m_pCurCourse.Set( pC ); } else { Course *pC = Luna<Course>::check(L,1); p->m_pCurCourse.Set( pC ); }
COMMON_RETURN_SELF; COMMON_RETURN_SELF;
} }
@@ -2781,7 +2779,7 @@ public:
PlayerNumber pn = Enum::Check<PlayerNumber>(L, 1); PlayerNumber pn = Enum::Check<PlayerNumber>(L, 1);
if(lua_isnil(L,2)) if(lua_isnil(L,2))
{ {
p->m_pCurTrail[pn].Set(NULL); p->m_pCurTrail[pn].Set(nullptr);
} }
else else
{ {
@@ -2795,7 +2793,7 @@ public:
static int GetPreferredSong( T* p, lua_State *L ) { if(p->m_pPreferredSong) p->m_pPreferredSong->PushSelf(L); else lua_pushnil(L); return 1; } static int GetPreferredSong( T* p, lua_State *L ) { if(p->m_pPreferredSong) p->m_pPreferredSong->PushSelf(L); else lua_pushnil(L); return 1; }
static int SetPreferredSong( T* p, lua_State *L ) static int SetPreferredSong( T* p, lua_State *L )
{ {
if( lua_isnil(L,1) ) { p->m_pPreferredSong = NULL; } if( lua_isnil(L,1) ) { p->m_pPreferredSong = nullptr; }
else { Song *pS = Luna<Song>::check(L,1); p->m_pPreferredSong = pS; } else { Song *pS = Luna<Song>::check(L,1); p->m_pPreferredSong = pS; }
COMMON_RETURN_SELF; COMMON_RETURN_SELF;
} }
@@ -2941,7 +2939,7 @@ public:
static int GetCurrentStepsCredits( T* t, lua_State *L ) static int GetCurrentStepsCredits( T* t, lua_State *L )
{ {
const Song* pSong = t->m_pCurSong; const Song* pSong = t->m_pCurSong;
if( pSong == NULL ) if( pSong == nullptr )
return 0; return 0;
// use a vector and not a set so that ordering is maintained // use a vector and not a set so that ordering is maintained
@@ -2949,7 +2947,7 @@ public:
FOREACH_HumanPlayer( p ) FOREACH_HumanPlayer( p )
{ {
const Steps* pSteps = GAMESTATE->m_pCurSteps[p]; const Steps* pSteps = GAMESTATE->m_pCurSteps[p];
if( pSteps == NULL ) if( pSteps == nullptr )
return 0; return 0;
bool bAlreadyAdded = find( vpStepsToShow.begin(), vpStepsToShow.end(), pSteps ) != vpStepsToShow.end(); bool bAlreadyAdded = find( vpStepsToShow.begin(), vpStepsToShow.end(), pSteps ) != vpStepsToShow.end();
if( !bAlreadyAdded ) if( !bAlreadyAdded )
@@ -3127,9 +3125,9 @@ public:
{ {
vector<const Style*> vpStyles; vector<const Style*> vpStyles;
GAMEMAN->GetCompatibleStyles( p->m_pCurGame, 2, vpStyles ); GAMEMAN->GetCompatibleStyles( p->m_pCurGame, 2, vpStyles );
FOREACH_CONST( const Style*, vpStyles, s ) for (const Style *s : vpStyles)
{ {
if( (*s)->m_StepsType == style->m_StepsType ) if( s->m_StepsType == style->m_StepsType )
{ {
return true; return true;
} }
@@ -3147,18 +3145,18 @@ public:
const Style *style = p->GetCurrentStyle(pn); const Style *style = p->GetCurrentStyle(pn);
if( p->m_pCurSteps[pn] && ( !style || style->m_StepsType != p->m_pCurSteps[pn]->m_StepsType ) ) if( p->m_pCurSteps[pn] && ( !style || style->m_StepsType != p->m_pCurSteps[pn]->m_StepsType ) )
{ {
p->m_pCurSteps[pn].Set( NULL ); p->m_pCurSteps[pn].Set( nullptr );
} }
if( p->m_pCurTrail[pn] && ( !style || style->m_StepsType != p->m_pCurTrail[pn]->m_StepsType ) ) if( p->m_pCurTrail[pn] && ( !style || style->m_StepsType != p->m_pCurTrail[pn]->m_StepsType ) )
{ {
p->m_pCurTrail[pn].Set( NULL ); p->m_pCurTrail[pn].Set( nullptr );
} }
} }
} }
static int SetCurrentStyle( T* p, lua_State *L ) static int SetCurrentStyle( T* p, lua_State *L )
{ {
const Style* pStyle = NULL; const Style* pStyle = nullptr;
if( lua_isstring(L,1) ) if( lua_isstring(L,1) )
{ {
RString style = SArg(1); RString style = SArg(1);
@@ -3217,19 +3215,19 @@ public:
// 3. Copy steps to new difficulty to edit: // 3. Copy steps to new difficulty to edit:
// song, steps, stepstype, difficulty // song, steps, stepstype, difficulty
Song* song= Luna<Song>::check(L, 1); Song* song= Luna<Song>::check(L, 1);
Steps* steps= NULL; Steps* steps= nullptr;
if(!lua_isnil(L, 2)) if(!lua_isnil(L, 2))
{ {
steps= Luna<Steps>::check(L, 2); steps= Luna<Steps>::check(L, 2);
} }
// Form 1. // Form 1.
if(steps != NULL && lua_gettop(L) == 2) if(steps != nullptr && lua_gettop(L) == 2)
{ {
p->m_pCurSong.Set(song); p->m_pCurSong.Set(song);
p->m_pCurSteps[PLAYER_1].Set(steps); p->m_pCurSteps[PLAYER_1].Set(steps);
p->SetCurrentStyle(GAMEMAN->GetEditorStyleForStepsType( p->SetCurrentStyle(GAMEMAN->GetEditorStyleForStepsType(
steps->m_StepsType), PLAYER_INVALID); steps->m_StepsType), PLAYER_INVALID);
p->m_pCurCourse.Set(NULL); p->m_pCurCourse.Set(nullptr);
return 0; return 0;
} }
StepsType stype= Enum::Check<StepsType>(L, 3); StepsType stype= Enum::Check<StepsType>(L, 3);
@@ -3237,7 +3235,7 @@ public:
Steps* new_steps= song->CreateSteps(); Steps* new_steps= song->CreateSteps();
RString edit_name; RString edit_name;
// Form 2. // Form 2.
if(steps == NULL) if(steps == nullptr)
{ {
new_steps->CreateBlank(stype); new_steps->CreateBlank(stype);
new_steps->SetMeter(1); new_steps->SetMeter(1);
@@ -3256,7 +3254,7 @@ public:
p->m_pCurSteps[PLAYER_1].Set(steps); p->m_pCurSteps[PLAYER_1].Set(steps);
p->SetCurrentStyle(GAMEMAN->GetEditorStyleForStepsType( p->SetCurrentStyle(GAMEMAN->GetEditorStyleForStepsType(
steps->m_StepsType), PLAYER_INVALID); steps->m_StepsType), PLAYER_INVALID);
p->m_pCurCourse.Set(NULL); p->m_pCurCourse.Set(nullptr);
return 0; return 0;
} }
+2 -2
View File
@@ -246,13 +246,13 @@ public:
// State Info used during gameplay // State Info used during gameplay
// NULL on ScreenSelectMusic if the currently selected wheel item isn't a Song. // nullptr on ScreenSelectMusic if the currently selected wheel item isn't a Song.
BroadcastOnChangePtr<Song> m_pCurSong; BroadcastOnChangePtr<Song> m_pCurSong;
// The last Song that the user manually changed to. // The last Song that the user manually changed to.
Song* m_pPreferredSong; Song* m_pPreferredSong;
BroadcastOnChangePtr1D<Steps,NUM_PLAYERS> m_pCurSteps; BroadcastOnChangePtr1D<Steps,NUM_PLAYERS> m_pCurSteps;
// NULL on ScreenSelectMusic if the currently selected wheel item isn't a Course. // nullptr on ScreenSelectMusic if the currently selected wheel item isn't a Course.
BroadcastOnChangePtr<Course> m_pCurCourse; BroadcastOnChangePtr<Course> m_pCurCourse;
// The last Course that the user manually changed to. // The last Course that the user manually changed to.
Course* m_pPreferredCourse; Course* m_pPreferredCourse;
+14 -14
View File
@@ -8,7 +8,6 @@
#include "RageLog.h" #include "RageLog.h"
#include "RageMath.h" #include "RageMath.h"
#include "StageStats.h" #include "StageStats.h"
#include "Foreach.h"
#include "Song.h" #include "Song.h"
#include "XmlFile.h" #include "XmlFile.h"
@@ -126,7 +125,7 @@ public:
~GraphBody() ~GraphBody()
{ {
TEXTUREMAN->UnloadTexture( m_pTexture ); TEXTUREMAN->UnloadTexture( m_pTexture );
m_pTexture = NULL; m_pTexture = nullptr;
} }
void DrawPrimitives() void DrawPrimitives()
@@ -150,14 +149,16 @@ public:
GraphDisplay::GraphDisplay() GraphDisplay::GraphDisplay()
{ {
m_pGraphLine = NULL; m_pGraphLine = nullptr;
m_pGraphBody = NULL; m_pGraphBody = nullptr;
} }
GraphDisplay::~GraphDisplay() GraphDisplay::~GraphDisplay()
{ {
FOREACH( Actor*, m_vpSongBoundaries, p ) for (Actor *p : m_vpSongBoundaries)
SAFE_DELETE( *p ); {
SAFE_DELETE( p );
}
m_vpSongBoundaries.clear(); m_vpSongBoundaries.clear();
SAFE_DELETE( m_pGraphLine ); SAFE_DELETE( m_pGraphLine );
SAFE_DELETE( m_pGraphBody ); SAFE_DELETE( m_pGraphBody );
@@ -176,18 +177,17 @@ void GraphDisplay::Set( const StageStats &ss, const PlayerStageStats &pss )
// Show song boundaries // Show song boundaries
float fSec = 0; float fSec = 0;
FOREACH_CONST( Song*, ss.m_vpPossibleSongs, song ) vector<Song *> const &possibleSongs = ss.m_vpPossibleSongs;
{
if( song == ss.m_vpPossibleSongs.end()-1 ) std::for_each(possibleSongs.begin(), possibleSongs.end() - 1, [&](Song *song) {
continue; fSec += song->GetStepsSeconds();
fSec += (*song)->GetStepsSeconds();
Actor *p = m_sprSongBoundary->Copy(); Actor *p = m_sprSongBoundary->Copy();
m_vpSongBoundaries.push_back( p ); m_vpSongBoundaries.push_back( p );
float fX = SCALE( fSec, 0, fTotalStepSeconds, m_quadVertices.left, m_quadVertices.right ); float fX = SCALE( fSec, 0, fTotalStepSeconds, m_quadVertices.left, m_quadVertices.right );
p->SetX( fX ); p->SetX( fX );
this->AddChild( p ); this->AddChild( p );
} });
if( !pss.m_bFailed ) if( !pss.m_bFailed )
{ {
@@ -288,11 +288,11 @@ public:
{ {
StageStats *pStageStats = Luna<StageStats>::check( L, 1 ); StageStats *pStageStats = Luna<StageStats>::check( L, 1 );
PlayerStageStats *pPlayerStageStats = Luna<PlayerStageStats>::check( L, 2 ); PlayerStageStats *pPlayerStageStats = Luna<PlayerStageStats>::check( L, 2 );
if(pStageStats == NULL) if(pStageStats == nullptr)
{ {
luaL_error(L, "The StageStats passed to GraphDisplay:Set are nil."); luaL_error(L, "The StageStats passed to GraphDisplay:Set are nil.");
} }
if(pPlayerStageStats == NULL) if(pPlayerStageStats == nullptr)
{ {
luaL_error(L, "The PlayerStageStats passed to GraphDisplay:Set are nil."); luaL_error(L, "The PlayerStageStats passed to GraphDisplay:Set are nil.");
} }
+3 -3
View File
@@ -58,7 +58,7 @@ void GrooveRadar::LoadFromNode( const XNode* pNode )
void GrooveRadar::SetEmpty( PlayerNumber pn ) void GrooveRadar::SetEmpty( PlayerNumber pn )
{ {
SetFromSteps( pn, NULL ); SetFromSteps( pn, nullptr );
} }
void GrooveRadar::SetFromRadarValues( PlayerNumber pn, const RadarValues &rv ) void GrooveRadar::SetFromRadarValues( PlayerNumber pn, const RadarValues &rv )
@@ -66,9 +66,9 @@ void GrooveRadar::SetFromRadarValues( PlayerNumber pn, const RadarValues &rv )
m_GrooveRadarValueMap[pn].SetFromSteps( rv ); m_GrooveRadarValueMap[pn].SetFromSteps( rv );
} }
void GrooveRadar::SetFromSteps( PlayerNumber pn, Steps* pSteps ) // NULL means no Song void GrooveRadar::SetFromSteps( PlayerNumber pn, Steps* pSteps ) // nullptr means no Song
{ {
if( pSteps == NULL ) if( pSteps == nullptr )
{ {
m_GrooveRadarValueMap[pn].SetEmpty(); m_GrooveRadarValueMap[pn].SetEmpty();
return; return;
+1 -1
View File
@@ -24,7 +24,7 @@ public:
/** /**
* @brief Give the Player a GrooveRadar based on some Steps. * @brief Give the Player a GrooveRadar based on some Steps.
* @param pn the Player to give a GrooveRadar. * @param pn the Player to give a GrooveRadar.
* @param pSteps the Steps to use to make the radar. If NULL, there are no Steps. */ * @param pSteps the Steps to use to make the radar. If nullptr, there are no Steps. */
void SetFromSteps( PlayerNumber pn, Steps* pSteps ); void SetFromSteps( PlayerNumber pn, Steps* pSteps );
void SetFromValues( PlayerNumber pn, vector<float> vals ); void SetFromValues( PlayerNumber pn, vector<float> vals );
+1 -2
View File
@@ -5,7 +5,6 @@
#include "PlayerNumber.h" #include "PlayerNumber.h"
#include "ThemeManager.h" #include "ThemeManager.h"
#include "XmlFile.h" #include "XmlFile.h"
#include "Foreach.h"
#include "RadarValues.h" #include "RadarValues.h"
#include <algorithm> #include <algorithm>
@@ -406,7 +405,7 @@ void HighScoreList::LoadFromNode( const XNode* pHighScoreList )
void HighScoreList::RemoveAllButOneOfEachName() void HighScoreList::RemoveAllButOneOfEachName()
{ {
FOREACH( HighScore, vHighScores, i ) for (vector<HighScore>::iterator i = vHighScores.begin(); i != vHighScores.end() - 1; ++i)
{ {
for( vector<HighScore>::iterator j = i+1; j != vHighScores.end(); j++ ) for( vector<HighScore>::iterator j = i+1; j != vHighScores.end(); j++ )
{ {
+12 -11
View File
@@ -1,7 +1,6 @@
#include "global.h" #include "global.h"
#include "ImageCache.h" #include "ImageCache.h"
#include "Foreach.h"
#include "RageDisplay.h" #include "RageDisplay.h"
#include "RageUtil.h" #include "RageUtil.h"
#include "RageLog.h" #include "RageLog.h"
@@ -79,7 +78,7 @@ void ImageCache::Demand( RString sImageDir )
const RString sCachePath = GetImageCachePath(sImageDir,sImagePath); const RString sCachePath = GetImageCachePath(sImageDir,sImagePath);
RageSurface *pImage = RageSurfaceUtils::LoadSurface( sCachePath ); RageSurface *pImage = RageSurfaceUtils::LoadSurface( sCachePath );
if( pImage == NULL ) if( pImage == nullptr )
{ {
continue; /* doesn't exist */ continue; /* doesn't exist */
} }
@@ -123,7 +122,7 @@ void ImageCache::LoadImage( RString sImageDir, RString sImagePath )
CHECKPOINT_M( ssprintf( "ImageCache::LoadImage: %s", sCachePath.c_str() ) ); CHECKPOINT_M( ssprintf( "ImageCache::LoadImage: %s", sCachePath.c_str() ) );
RageSurface *pImage = RageSurfaceUtils::LoadSurface( sCachePath ); RageSurface *pImage = RageSurfaceUtils::LoadSurface( sCachePath );
if( pImage == NULL ) if( pImage == nullptr )
{ {
if( tries == 0 ) if( tries == 0 )
{ {
@@ -150,9 +149,9 @@ void ImageCache::LoadImage( RString sImageDir, RString sImagePath )
void ImageCache::OutputStats() const void ImageCache::OutputStats() const
{ {
int iTotalSize = 0; int iTotalSize = 0;
FOREACHM_CONST( RString, RageSurface *, g_ImagePathToImage, it ) for (auto const &it : g_ImagePathToImage)
{ {
const RageSurface *pImage = it->second; const RageSurface *pImage = it.second;
const int iSize = pImage->pitch * pImage->h; const int iSize = pImage->pitch * pImage->h;
iTotalSize += iSize; iTotalSize += iSize;
} }
@@ -161,8 +160,10 @@ void ImageCache::OutputStats() const
void ImageCache::UnloadAllImages() void ImageCache::UnloadAllImages()
{ {
FOREACHM( RString, RageSurface *, g_ImagePathToImage, it ) for (auto &it: g_ImagePathToImage)
delete it->second; {
delete it.second;
}
g_ImagePathToImage.clear(); g_ImagePathToImage.clear();
} }
@@ -203,7 +204,7 @@ struct ImageTexture: public RageTexture
void Create() void Create()
{ {
ASSERT( m_pImage != NULL ); ASSERT( m_pImage != nullptr );
/* The image is preprocessed; do as little work as possible. */ /* The image is preprocessed; do as little work as possible. */
@@ -239,7 +240,7 @@ struct ImageTexture: public RageTexture
ASSERT( DISPLAY->SupportsTextureFormat(pf) ); ASSERT( DISPLAY->SupportsTextureFormat(pf) );
ASSERT(m_pImage != NULL); ASSERT(m_pImage != nullptr);
m_uTexHandle = DISPLAY->CreateTexture( pf, m_pImage, false ); m_uTexHandle = DISPLAY->CreateTexture( pf, m_pImage, false );
CreateFrameRects(); CreateFrameRects();
@@ -295,7 +296,7 @@ RageTextureID ImageCache::LoadCachedImage( RString sImageDir, RString sImagePath
* when converting; this way, the conversion will end up in the map so we * when converting; this way, the conversion will end up in the map so we
* only have to convert once. */ * only have to convert once. */
RageSurface *&pImage = g_ImagePathToImage[sImagePath]; RageSurface *&pImage = g_ImagePathToImage[sImagePath];
ASSERT( pImage != NULL ); ASSERT( pImage != nullptr );
int iSourceWidth = 0, iSourceHeight = 0; int iSourceWidth = 0, iSourceHeight = 0;
ImageData.GetValue( sImagePath, "Width", iSourceWidth ); ImageData.GetValue( sImagePath, "Width", iSourceWidth );
@@ -373,7 +374,7 @@ void ImageCache::CacheImageInternal( RString sImageDir, RString sImagePath )
{ {
RString sError; RString sError;
RageSurface *pImage = RageSurfaceUtils::LoadFile( sImagePath, sError ); RageSurface *pImage = RageSurfaceUtils::LoadFile( sImagePath, sError );
if( pImage == NULL ) if( pImage == nullptr )
{ {
LOG->UserLog( "Cache file", sImagePath, "couldn't be loaded: %s", sError.c_str() ); LOG->UserLog( "Cache file", sImagePath, "couldn't be loaded: %s", sError.c_str() );
return; return;
+8 -8
View File
@@ -9,7 +9,7 @@ http://en.wikipedia.org/wiki/INI_file
#include "RageUtil.h" #include "RageUtil.h"
#include "RageLog.h" #include "RageLog.h"
#include "RageFile.h" #include "RageFile.h"
#include "Foreach.h"
IniFile::IniFile(): XNode("IniFile") IniFile::IniFile(): XNode("IniFile")
{ {
@@ -35,7 +35,7 @@ bool IniFile::ReadFile( RageFileBasic &f )
{ {
RString keyname; RString keyname;
// keychild is used to cache the node that values are being added to. -Kyz // keychild is used to cache the node that values are being added to. -Kyz
XNode* keychild= NULL; XNode* keychild= nullptr;
for(;;) for(;;)
{ {
RString line; RString line;
@@ -82,7 +82,7 @@ bool IniFile::ReadFile( RageFileBasic &f )
// New section. // New section.
keyname = line.substr(1, line.size()-2); keyname = line.substr(1, line.size()-2);
keychild= GetChild(keyname); keychild= GetChild(keyname);
if(keychild == NULL) if(keychild == nullptr)
{ {
keychild= AppendChild(keyname); keychild= AppendChild(keyname);
} }
@@ -90,7 +90,7 @@ bool IniFile::ReadFile( RageFileBasic &f )
} }
default: default:
keyvalue: keyvalue:
if(keychild == NULL) if(keychild == nullptr)
{ break; } { break; }
// New value. // New value.
size_t iEqualIndex = line.find("="); size_t iEqualIndex = line.find("=");
@@ -164,7 +164,7 @@ bool IniFile::WriteFile( RageFileBasic &f ) const
bool IniFile::DeleteValue(const RString &keyname, const RString &valuename) bool IniFile::DeleteValue(const RString &keyname, const RString &valuename)
{ {
XNode* pNode = GetChild( keyname ); XNode* pNode = GetChild( keyname );
if( pNode == NULL ) if( pNode == nullptr )
return false; return false;
return pNode->RemoveAttr( valuename ); return pNode->RemoveAttr( valuename );
} }
@@ -173,7 +173,7 @@ bool IniFile::DeleteValue(const RString &keyname, const RString &valuename)
bool IniFile::DeleteKey(const RString &keyname) bool IniFile::DeleteKey(const RString &keyname)
{ {
XNode* pNode = GetChild( keyname ); XNode* pNode = GetChild( keyname );
if( pNode == NULL ) if( pNode == nullptr )
return false; return false;
return RemoveChild( pNode ); return RemoveChild( pNode );
} }
@@ -181,11 +181,11 @@ bool IniFile::DeleteKey(const RString &keyname)
bool IniFile::RenameKey(const RString &from, const RString &to) bool IniFile::RenameKey(const RString &from, const RString &to)
{ {
// If to already exists, do nothing. // If to already exists, do nothing.
if( GetChild(to) != NULL ) if( GetChild(to) != nullptr )
return false; return false;
XNode* pNode = GetChild( from ); XNode* pNode = GetChild( from );
if( pNode == NULL ) if( pNode == nullptr )
return false; return false;
pNode->SetName( to ); pNode->SetName( to );
+2 -2
View File
@@ -32,7 +32,7 @@ public:
bool GetValue( const RString &sKey, const RString &sValueName, T& value ) const bool GetValue( const RString &sKey, const RString &sValueName, T& value ) const
{ {
const XNode* pNode = GetChild( sKey ); const XNode* pNode = GetChild( sKey );
if( pNode == NULL ) if( pNode == nullptr )
return false; return false;
return pNode->GetAttrValue<T>( sValueName, value ); return pNode->GetAttrValue<T>( sValueName, value );
} }
@@ -40,7 +40,7 @@ public:
void SetValue( const RString &sKey, const RString &sValueName, const T &value ) void SetValue( const RString &sKey, const RString &sValueName, const T &value )
{ {
XNode* pNode = GetChild( sKey ); XNode* pNode = GetChild( sKey );
if( pNode == NULL ) if( pNode == nullptr )
pNode = AppendChild( sKey ); pNode = AppendChild( sKey );
pNode->AppendAttr<T>( sValueName, value ); pNode->AppendAttr<T>( sValueName, value );
} }
+13 -14
View File
@@ -6,7 +6,6 @@
#include "RageUtil.h" #include "RageUtil.h"
#include "RageThreads.h" #include "RageThreads.h"
#include "Preference.h" #include "Preference.h"
#include "Foreach.h"
#include "GameInput.h" #include "GameInput.h"
#include "InputMapper.h" #include "InputMapper.h"
// for mouse stuff: -aj // for mouse stuff: -aj
@@ -111,7 +110,7 @@ namespace
* this won't cause timing problems, because the event timestamp is preserved. */ * this won't cause timing problems, because the event timestamp is preserved. */
static Preference<float> g_fInputDebounceTime( "InputDebounceTime", 0 ); static Preference<float> g_fInputDebounceTime( "InputDebounceTime", 0 );
InputFilter* INPUTFILTER = NULL; // global and accessible from anywhere in our program InputFilter* INPUTFILTER = nullptr; // global and accessible from anywhere in our program
static const float TIME_BEFORE_REPEATS = 0.375f; static const float TIME_BEFORE_REPEATS = 0.375f;
@@ -233,9 +232,9 @@ void InputFilter::ResetDevice( InputDevice device )
RageTimer now; RageTimer now;
const ButtonStateMap ButtonStates( g_ButtonStates ); const ButtonStateMap ButtonStates( g_ButtonStates );
FOREACHM_CONST( DeviceButtonPair, ButtonState, ButtonStates, b ) for (std::pair<DeviceButtonPair const, ButtonState> const &b : ButtonStates)
{ {
const DeviceButtonPair &db = b->first; const DeviceButtonPair &db = b.first;
if( db.device == device ) if( db.device == device )
ButtonPressed( DeviceInput(device, db.button, 0, now) ); ButtonPressed( DeviceInput(device, db.button, 0, now) );
} }
@@ -326,7 +325,7 @@ void InputFilter::Update( float fDeltaTime )
vector<ButtonStateMap::iterator> ButtonsToErase; vector<ButtonStateMap::iterator> ButtonsToErase;
FOREACHM( DeviceButtonPair, ButtonState, g_ButtonStates, b ) for( map<DeviceButtonPair, ButtonState>::iterator b = g_ButtonStates.begin(); b != g_ButtonStates.end(); ++b )
{ {
di.device = b->first.device; di.device = b->first.device;
di.button = b->first.button; di.button = b->first.button;
@@ -379,8 +378,8 @@ void InputFilter::Update( float fDeltaTime )
ReportButtonChange( di, IET_REPEAT ); ReportButtonChange( di, IET_REPEAT );
} }
FOREACH( ButtonStateMap::iterator, ButtonsToErase, it ) for (ButtonStateMap::iterator &it : ButtonsToErase)
g_ButtonStates.erase( *it ); g_ButtonStates.erase( it );
} }
template<typename T, typename IT> template<typename T, typename IT>
@@ -388,7 +387,7 @@ const T *FindItemBinarySearch( IT begin, IT end, const T &i )
{ {
IT it = lower_bound( begin, end, i ); IT it = lower_bound( begin, end, i );
if( it == end || *it != i ) if( it == end || *it != i )
return NULL; return nullptr;
return &*it; return &*it;
} }
@@ -396,19 +395,19 @@ const T *FindItemBinarySearch( IT begin, IT end, const T &i )
bool InputFilter::IsBeingPressed( const DeviceInput &di, const DeviceInputList *pButtonState ) const bool InputFilter::IsBeingPressed( const DeviceInput &di, const DeviceInputList *pButtonState ) const
{ {
LockMut(*queuemutex); LockMut(*queuemutex);
if( pButtonState == NULL ) if( pButtonState == nullptr )
pButtonState = &g_CurrentState; pButtonState = &g_CurrentState;
const DeviceInput *pDI = FindItemBinarySearch( pButtonState->begin(), pButtonState->end(), di ); const DeviceInput *pDI = FindItemBinarySearch( pButtonState->begin(), pButtonState->end(), di );
return pDI != NULL && pDI->bDown; return pDI != nullptr && pDI->bDown;
} }
float InputFilter::GetSecsHeld( const DeviceInput &di, const DeviceInputList *pButtonState ) const float InputFilter::GetSecsHeld( const DeviceInput &di, const DeviceInputList *pButtonState ) const
{ {
LockMut(*queuemutex); LockMut(*queuemutex);
if( pButtonState == NULL ) if( pButtonState == nullptr )
pButtonState = &g_CurrentState; pButtonState = &g_CurrentState;
const DeviceInput *pDI = FindItemBinarySearch( pButtonState->begin(), pButtonState->end(), di ); const DeviceInput *pDI = FindItemBinarySearch( pButtonState->begin(), pButtonState->end(), di );
if( pDI == NULL ) if( pDI == nullptr )
return 0; return 0;
return pDI->ts.Ago(); return pDI->ts.Ago();
} }
@@ -416,10 +415,10 @@ float InputFilter::GetSecsHeld( const DeviceInput &di, const DeviceInputList *pB
float InputFilter::GetLevel( const DeviceInput &di, const DeviceInputList *pButtonState ) const float InputFilter::GetLevel( const DeviceInput &di, const DeviceInputList *pButtonState ) const
{ {
LockMut(*queuemutex); LockMut(*queuemutex);
if( pButtonState == NULL ) if( pButtonState == nullptr )
pButtonState = &g_CurrentState; pButtonState = &g_CurrentState;
const DeviceInput *pDI = FindItemBinarySearch( pButtonState->begin(), pButtonState->end(), di ); const DeviceInput *pDI = FindItemBinarySearch( pButtonState->begin(), pButtonState->end(), di );
if( pDI == NULL ) if( pDI == nullptr )
return 0.0f; return 0.0f;
return pDI->level; return pDI->level;
} }
+4 -4
View File
@@ -64,10 +64,10 @@ public:
void ResetKeyRepeat( const DeviceInput &di ); void ResetKeyRepeat( const DeviceInput &di );
void RepeatStopKey( const DeviceInput &di ); void RepeatStopKey( const DeviceInput &di );
// If aButtonState is NULL, use the last reported state. // If aButtonState is nullptr, use the last reported state.
bool IsBeingPressed( const DeviceInput &di, const DeviceInputList *pButtonState = NULL ) const; bool IsBeingPressed( const DeviceInput &di, const DeviceInputList *pButtonState = nullptr ) const;
float GetSecsHeld( const DeviceInput &di, const DeviceInputList *pButtonState = NULL ) const; float GetSecsHeld( const DeviceInput &di, const DeviceInputList *pButtonState = nullptr ) const;
float GetLevel( const DeviceInput &di, const DeviceInputList *pButtonState = NULL ) const; float GetLevel( const DeviceInput &di, const DeviceInputList *pButtonState = nullptr ) const;
RString GetButtonComment( const DeviceInput &di ) const; RString GetButtonComment( const DeviceInput &di ) const;
void GetInputEvents( vector<InputEvent> &aEventOut ); void GetInputEvents( vector<InputEvent> &aEventOut );
+32 -33
View File
@@ -9,7 +9,6 @@
#include "RageInput.h" #include "RageInput.h"
#include "SpecialFiles.h" #include "SpecialFiles.h"
#include "LocalizedString.h" #include "LocalizedString.h"
#include "Foreach.h"
#include "arch/Dialog/Dialog.h" #include "arch/Dialog/Dialog.h"
#define AUTOMAPPINGS_DIR "/Data/AutoMappings/" #define AUTOMAPPINGS_DIR "/Data/AutoMappings/"
@@ -26,12 +25,12 @@ namespace
PlayerNumber g_JoinControllers; PlayerNumber g_JoinControllers;
}; };
InputMapper* INPUTMAPPER = NULL; // global and accessible from anywhere in our program InputMapper* INPUTMAPPER = nullptr; // global and accessible from anywhere in our program
InputMapper::InputMapper() InputMapper::InputMapper()
{ {
g_JoinControllers = PLAYER_INVALID; g_JoinControllers = PLAYER_INVALID;
m_pInputScheme = NULL; m_pInputScheme = nullptr;
} }
InputMapper::~InputMapper() InputMapper::~InputMapper()
@@ -79,20 +78,20 @@ void InputMapper::AddDefaultMappingsForCurrentGameIfUnmapped()
vector<AutoMappingEntry> aMaps; vector<AutoMappingEntry> aMaps;
aMaps.reserve( 32 ); aMaps.reserve( 32 );
FOREACH_CONST( AutoMappingEntry, g_DefaultKeyMappings.m_vMaps, iter ) for (AutoMappingEntry const &iter : g_DefaultKeyMappings.m_vMaps)
aMaps.push_back( *iter ); aMaps.push_back( iter );
FOREACH_CONST( AutoMappingEntry, m_pInputScheme->m_pAutoMappings->m_vMaps, iter ) for (AutoMappingEntry const &iter : m_pInputScheme->m_pAutoMappings->m_vMaps)
aMaps.push_back( *iter ); aMaps.push_back( iter );
/* There may be duplicate GAME_BUTTON maps. Process the list backwards, /* There may be duplicate GAME_BUTTON maps. Process the list backwards,
* so game-specific mappings override g_DefaultKeyMappings. */ * so game-specific mappings override g_DefaultKeyMappings. */
std::reverse( aMaps.begin(), aMaps.end() ); std::reverse( aMaps.begin(), aMaps.end() );
FOREACH( AutoMappingEntry, aMaps, m ) for (AutoMappingEntry const &m : aMaps)
{ {
DeviceButton key = m->m_deviceButton; DeviceButton key = m.m_deviceButton;
DeviceInput DeviceI( DEVICE_KEYBOARD, key ); DeviceInput DeviceI( DEVICE_KEYBOARD, key );
GameInput GameI( m->m_bSecondController ? GameController_2 : GameController_1, m->m_gb ); GameInput GameI( m.m_bSecondController ? GameController_2 : GameController_1, m.m_gb );
if( !IsMapped(DeviceI) ) // if this key isn't already being used by another user-made mapping if( !IsMapped(DeviceI) ) // if this key isn't already being used by another user-made mapping
{ {
if( !GameI.IsValid() ) if( !GameI.IsValid() )
@@ -545,10 +544,10 @@ void InputMapper::Unmap( InputDevice id )
void InputMapper::ApplyMapping( const vector<AutoMappingEntry> &vMmaps, GameController gc, InputDevice id ) void InputMapper::ApplyMapping( const vector<AutoMappingEntry> &vMmaps, GameController gc, InputDevice id )
{ {
map<GameInput, int> MappedButtons; map<GameInput, int> MappedButtons;
FOREACH_CONST( AutoMappingEntry, vMmaps, iter ) for (AutoMappingEntry const &iter : vMmaps)
{ {
GameController map_gc = gc; GameController map_gc = gc;
if( iter->m_bSecondController ) if( iter.m_bSecondController )
{ {
map_gc = (GameController)(map_gc+1); map_gc = (GameController)(map_gc+1);
@@ -559,8 +558,8 @@ void InputMapper::ApplyMapping( const vector<AutoMappingEntry> &vMmaps, GameCont
continue; continue;
} }
DeviceInput di( id, iter->m_deviceButton ); DeviceInput di( id, iter.m_deviceButton );
GameInput gi( map_gc, iter->m_gb ); GameInput gi( map_gc, iter.m_gb );
int iSlot = MappedButtons[gi]; int iSlot = MappedButtons[gi];
++MappedButtons[gi]; ++MappedButtons[gi];
SetInputMap( di, gi, iSlot );//maps[k].iSlotIndex ); SetInputMap( di, gi, iSlot );//maps[k].iSlotIndex );
@@ -578,10 +577,10 @@ void InputMapper::AutoMapJoysticksForCurrentGame()
// file automaps - Add these first so that they can match before the hard-coded mappings // file automaps - Add these first so that they can match before the hard-coded mappings
vector<RString> vs; vector<RString> vs;
GetDirListing( AUTOMAPPINGS_DIR "*.ini", vs, false, true ); GetDirListing( AUTOMAPPINGS_DIR "*.ini", vs, false, true );
FOREACH_CONST( RString, vs, sFilePath ) for (RString const &sFilePath : vs)
{ {
InputMappings km; InputMappings km;
km.ReadMappings( m_pInputScheme, *sFilePath, true ); km.ReadMappings( m_pInputScheme, sFilePath, true );
AutoMappings mapping( m_pInputScheme->m_szName, km.m_sDeviceRegex, km.m_sDescription ); AutoMappings mapping( m_pInputScheme->m_szName, km.m_sDeviceRegex, km.m_sDescription );
@@ -616,13 +615,13 @@ void InputMapper::AutoMapJoysticksForCurrentGame()
// apply auto mappings // apply auto mappings
int iNumJoysticksMapped = 0; int iNumJoysticksMapped = 0;
FOREACH_CONST( InputDeviceInfo, vDevices, device ) for (InputDeviceInfo const &device : vDevices)
{ {
InputDevice id = device->id; InputDevice id = device.id;
const RString &sDescription = device->sDesc; const RString &sDescription = device.sDesc;
FOREACH_CONST( AutoMappings, vAutoMappings, mapping ) for (AutoMappings const &mapping : vAutoMappings)
{ {
Regex regex( mapping->m_sDriverRegex ); Regex regex( mapping.m_sDriverRegex );
if( !regex.Compare(sDescription) ) if( !regex.Compare(sDescription) )
continue; // driver names don't match continue; // driver names don't match
@@ -632,10 +631,10 @@ void InputMapper::AutoMapJoysticksForCurrentGame()
break; // stop mapping. We already mapped one device for each game controller. break; // stop mapping. We already mapped one device for each game controller.
LOG->Info( "Applying default joystick mapping #%d for device '%s' (%s)", LOG->Info( "Applying default joystick mapping #%d for device '%s' (%s)",
iNumJoysticksMapped+1, mapping->m_sDriverRegex.c_str(), mapping->m_sControllerName.c_str() ); iNumJoysticksMapped+1, mapping.m_sDriverRegex.c_str(), mapping.m_sControllerName.c_str() );
Unmap( id ); Unmap( id );
ApplyMapping( mapping->m_vMaps, gc, id ); ApplyMapping( mapping.m_vMaps, gc, id );
iNumJoysticksMapped++; iNumJoysticksMapped++;
} }
@@ -686,16 +685,16 @@ void InputMapper::CheckButtonAndAddToReason(GameButton menu, vector<RString>& fu
if(!inputs.empty()) if(!inputs.empty())
{ {
vector<DeviceInput> device_inputs; vector<DeviceInput> device_inputs;
FOREACH(GameInput, inputs, inp) for(GameInput &inp : inputs)
{ {
for(int slot= 0; slot < NUM_GAME_TO_DEVICE_SLOTS; ++slot) for(int slot= 0; slot < NUM_GAME_TO_DEVICE_SLOTS; ++slot)
{ {
device_inputs.push_back(m_mappings.m_GItoDI[inp->controller][inp->button][slot]); device_inputs.push_back(m_mappings.m_GItoDI[inp.controller][inp.button][slot]);
} }
} }
FOREACH(DeviceInput, device_inputs, inp) for(DeviceInput &inp : device_inputs)
{ {
if(!inp->IsValid()) if(!inp.IsValid())
{ {
continue; continue;
} }
@@ -706,7 +705,7 @@ void InputMapper::CheckButtonAndAddToReason(GameButton menu, vector<RString>& fu
{ {
for(int slot= 0; slot < NUM_GAME_TO_DEVICE_SLOTS; ++slot) for(int slot= 0; slot < NUM_GAME_TO_DEVICE_SLOTS; ++slot)
{ {
use_count+= ((*inp) == m_mappings.m_GItoDI[cont][gb][slot]); use_count+= (inp == m_mappings.m_GItoDI[cont][gb][slot]);
} }
} }
} }
@@ -1096,16 +1095,16 @@ void InputScheme::MenuButtonToGameInputs( GameButton MenuI, PlayerNumber pn, vec
vector<GameButton> aGameButtons; vector<GameButton> aGameButtons;
MenuButtonToGameButtons( MenuI, aGameButtons ); MenuButtonToGameButtons( MenuI, aGameButtons );
FOREACH( GameButton, aGameButtons, gb ) for (GameButton const &gb : aGameButtons)
{ {
if( pn == PLAYER_INVALID ) if( pn == PLAYER_INVALID )
{ {
GameIout.push_back( GameInput(GameController_1, *gb) ); GameIout.push_back( GameInput(GameController_1, gb) );
GameIout.push_back( GameInput(GameController_2, *gb) ); GameIout.push_back( GameInput(GameController_2, gb) );
} }
else else
{ {
GameIout.push_back( GameInput((GameController)pn, *gb) ); GameIout.push_back( GameInput((GameController)pn, gb) );
} }
} }
} }
@@ -1249,7 +1248,7 @@ void InputMappings::WriteMappings( const InputScheme *pInputScheme, RString sFil
ini.DeleteKey( pInputScheme->m_szName ); ini.DeleteKey( pInputScheme->m_szName );
XNode *pKey = ini.GetChild( pInputScheme->m_szName ); XNode *pKey = ini.GetChild( pInputScheme->m_szName );
if( pKey != NULL ) if( pKey != nullptr )
ini.RemoveChild( pKey ); ini.RemoveChild( pKey );
pKey = ini.AppendChild( pInputScheme->m_szName ); pKey = ini.AppendChild( pInputScheme->m_szName );
+2 -2
View File
@@ -177,9 +177,9 @@ public:
float GetSecsHeld( const GameInput &GameI, MultiPlayer mp = MultiPlayer_Invalid ) const; float GetSecsHeld( const GameInput &GameI, MultiPlayer mp = MultiPlayer_Invalid ) const;
float GetSecsHeld( GameButton MenuI, PlayerNumber pn ) const; float GetSecsHeld( GameButton MenuI, PlayerNumber pn ) const;
bool IsBeingPressed( const GameInput &GameI, MultiPlayer mp = MultiPlayer_Invalid, const DeviceInputList *pButtonState = NULL ) const; bool IsBeingPressed( const GameInput &GameI, MultiPlayer mp = MultiPlayer_Invalid, const DeviceInputList *pButtonState = nullptr ) const;
bool IsBeingPressed( GameButton MenuI, PlayerNumber pn ) const; bool IsBeingPressed( GameButton MenuI, PlayerNumber pn ) const;
bool IsBeingPressed(const vector<GameInput>& GameI, MultiPlayer mp = MultiPlayer_Invalid, const DeviceInputList *pButtonState = NULL ) const; bool IsBeingPressed(const vector<GameInput>& GameI, MultiPlayer mp = MultiPlayer_Invalid, const DeviceInputList *pButtonState = nullptr ) const;
void ResetKeyRepeat( const GameInput &GameI ); void ResetKeyRepeat( const GameInput &GameI );
void ResetKeyRepeat( GameButton MenuI, PlayerNumber pn ); void ResetKeyRepeat( GameButton MenuI, PlayerNumber pn );
+7 -10
View File
@@ -3,10 +3,9 @@
#include "RageTimer.h" #include "RageTimer.h"
#include "RageLog.h" #include "RageLog.h"
#include "InputEventPlus.h" #include "InputEventPlus.h"
#include "Foreach.h"
#include "InputMapper.h" #include "InputMapper.h"
InputQueue* INPUTQUEUE = NULL; // global and accessible from anywhere in our program InputQueue* INPUTQUEUE = nullptr; // global and accessible from anywhere in our program
const unsigned MAX_INPUT_QUEUE_LENGTH = 32; const unsigned MAX_INPUT_QUEUE_LENGTH = 32;
@@ -38,7 +37,7 @@ bool InputQueue::WasPressedRecently( GameController c, const GameButton button,
if( iep.GameI.button != button ) if( iep.GameI.button != button )
continue; continue;
if( pIEP != NULL ) if( pIEP != nullptr )
*pIEP = iep; *pIEP = iep;
return true; return true;
@@ -95,7 +94,7 @@ bool InputQueueCode::EnteredCode( GameController controller ) const
int iMinSearchIndexUsed = iQueueIndex; int iMinSearchIndexUsed = iQueueIndex;
for( int b=0; b<(int) Press.m_aButtonsToPress.size(); ++b ) for( int b=0; b<(int) Press.m_aButtonsToPress.size(); ++b )
{ {
const InputEventPlus *pIEP = NULL; const InputEventPlus *pIEP = nullptr;
int iQueueSearchIndex = iQueueIndex; int iQueueSearchIndex = iQueueIndex;
for( ; iQueueSearchIndex>=0; --iQueueSearchIndex ) // iterate newest to oldest for( ; iQueueSearchIndex>=0; --iQueueSearchIndex ) // iterate newest to oldest
{ {
@@ -112,7 +111,7 @@ bool InputQueueCode::EnteredCode( GameController controller ) const
break; break;
} }
} }
if( pIEP == NULL ) if( pIEP == nullptr )
break; // didn't find the button break; // didn't find the button
// Check that m_aButtonsToHold were being held when the buttons were pressed. // Check that m_aButtonsToHold were being held when the buttons were pressed.
@@ -167,11 +166,11 @@ bool InputQueueCode::Load( RString sButtonsNames )
vector<RString> asPresses; vector<RString> asPresses;
split( sButtonsNames, ",", asPresses, false ); split( sButtonsNames, ",", asPresses, false );
FOREACH( RString, asPresses, sPress ) for (RString &sPress : asPresses)
{ {
vector<RString> asButtonNames; vector<RString> asButtonNames;
split( *sPress, "-", asButtonNames, false ); split( sPress, "-", asButtonNames, false );
if( asButtonNames.size() < 1 ) if( asButtonNames.size() < 1 )
{ {
@@ -181,10 +180,8 @@ bool InputQueueCode::Load( RString sButtonsNames )
} }
m_aPresses.push_back( ButtonPress() ); m_aPresses.push_back( ButtonPress() );
for( unsigned i=0; i<asButtonNames.size(); i++ ) // for each button in this code for (RString sButtonName : asButtonNames) // for each button in this code
{ {
RString sButtonName = asButtonNames[i];
bool bHold = false; bool bHold = false;
bool bNotHold = false; bool bNotHold = false;
for(;;) for(;;)
+1 -1
View File
@@ -14,7 +14,7 @@ public:
InputQueue(); InputQueue();
void RememberInput( const InputEventPlus &gi ); void RememberInput( const InputEventPlus &gi );
bool WasPressedRecently( GameController c, const GameButton button, const RageTimer &OldestTimeAllowed, InputEventPlus *pIEP = NULL ); bool WasPressedRecently( GameController c, const GameButton button, const RageTimer &OldestTimeAllowed, InputEventPlus *pIEP = nullptr );
const vector<InputEventPlus> &GetQueue( GameController c ) const { return m_aQueue[c]; } const vector<InputEventPlus> &GetQueue( GameController c ) const { return m_aQueue[c]; }
void ClearQueue( GameController c ); void ClearQueue( GameController c );
+1 -1
View File
@@ -29,7 +29,7 @@ LifeMeterBar::LifeMeterBar()
EXTRA_STAGE_LIFE_DIFFICULTY.Load ("LifeMeterBar","ExtraStageLifeDifficulty"); EXTRA_STAGE_LIFE_DIFFICULTY.Load ("LifeMeterBar","ExtraStageLifeDifficulty");
m_fLifePercentChange.Load( "LifeMeterBar", LIFE_PERCENT_CHANGE_NAME, NUM_ScoreEvent ); m_fLifePercentChange.Load( "LifeMeterBar", LIFE_PERCENT_CHANGE_NAME, NUM_ScoreEvent );
m_pPlayerState = NULL; m_pPlayerState = nullptr;
const RString sType = "LifeMeterBar"; const RString sType = "LifeMeterBar";
+4 -4
View File
@@ -50,7 +50,7 @@ LifeMeterTime::LifeMeterTime()
{ {
m_fLifeTotalGainedSeconds = 0; m_fLifeTotalGainedSeconds = 0;
m_fLifeTotalLostSeconds = 0; m_fLifeTotalLostSeconds = 0;
m_pStream = NULL; m_pStream = nullptr;
} }
LifeMeterTime::~LifeMeterTime() LifeMeterTime::~LifeMeterTime()
@@ -100,7 +100,7 @@ void LifeMeterTime::OnLoadSong()
if(GAMESTATE->IsCourseMode()) if(GAMESTATE->IsCourseMode())
{ {
Course* pCourse = GAMESTATE->m_pCurCourse; Course* pCourse = GAMESTATE->m_pCurCourse;
ASSERT( pCourse != NULL ); ASSERT( pCourse != nullptr );
fGainSeconds= pCourse->m_vEntries[GAMESTATE->GetCourseSongIndex()].fGainSeconds; fGainSeconds= pCourse->m_vEntries[GAMESTATE->GetCourseSongIndex()].fGainSeconds;
} }
else else
@@ -108,10 +108,10 @@ void LifeMeterTime::OnLoadSong()
// Placeholderish, at least this way it won't crash when someone tries it // Placeholderish, at least this way it won't crash when someone tries it
// out in non-course mode. -Kyz // out in non-course mode. -Kyz
Song* song= GAMESTATE->m_pCurSong; Song* song= GAMESTATE->m_pCurSong;
ASSERT(song != NULL); ASSERT(song != nullptr);
float song_len= song->m_fMusicLengthSeconds; float song_len= song->m_fMusicLengthSeconds;
Steps* steps= GAMESTATE->m_pCurSteps[m_pPlayerState->m_PlayerNumber]; Steps* steps= GAMESTATE->m_pCurSteps[m_pPlayerState->m_PlayerNumber];
ASSERT(steps != NULL); ASSERT(steps != nullptr);
RadarValues radars= steps->GetRadarValues(m_pPlayerState->m_PlayerNumber); RadarValues radars= steps->GetRadarValues(m_pPlayerState->m_PlayerNumber);
float scorable_things= radars[RadarCategory_TapsAndHolds] + float scorable_things= radars[RadarCategory_TapsAndHolds] +
radars[RadarCategory_Lifts]; radars[RadarCategory_Lifts];
+18 -16
View File
@@ -10,7 +10,6 @@
#include "PrefsManager.h" #include "PrefsManager.h"
#include "Actor.h" #include "Actor.h"
#include "Preference.h" #include "Preference.h"
#include "Foreach.h"
#include "GameManager.h" #include "GameManager.h"
#include "CommonMetrics.h" #include "CommonMetrics.h"
#include "Style.h" #include "Style.h"
@@ -57,9 +56,9 @@ static void GetUsedGameInputs( vector<GameInput> &vGameInputsOut )
split( GAME_BUTTONS_TO_SHOW.GetValue(), ",", asGameButtons ); split( GAME_BUTTONS_TO_SHOW.GetValue(), ",", asGameButtons );
FOREACH_ENUM( GameController, gc ) FOREACH_ENUM( GameController, gc )
{ {
FOREACH_CONST( RString, asGameButtons, button ) for (RString const &button : asGameButtons)
{ {
GameButton gb = StringToGameButton( INPUTMAPPER->GetInputScheme(), *button ); GameButton gb = StringToGameButton( INPUTMAPPER->GetInputScheme(), button );
if( gb != GameButton_Invalid ) if( gb != GameButton_Invalid )
{ {
GameInput gi = GameInput( gc, gb ); GameInput gi = GameInput( gc, gb );
@@ -71,17 +70,18 @@ static void GetUsedGameInputs( vector<GameInput> &vGameInputsOut )
set<GameInput> vGIs; set<GameInput> vGIs;
vector<const Style*> vStyles; vector<const Style*> vStyles;
GAMEMAN->GetStylesForGame( GAMESTATE->m_pCurGame, vStyles ); GAMEMAN->GetStylesForGame( GAMESTATE->m_pCurGame, vStyles );
FOREACH( const Style*, vStyles, style ) auto const &value = CommonMetrics::STEPS_TYPES_TO_SHOW.GetValue();
for (Style const *style : vStyles)
{ {
bool bFound = find( CommonMetrics::STEPS_TYPES_TO_SHOW.GetValue().begin(), CommonMetrics::STEPS_TYPES_TO_SHOW.GetValue().end(), (*style)->m_StepsType ) != CommonMetrics::STEPS_TYPES_TO_SHOW.GetValue().end(); bool bFound = find( value.begin(), value.end(), style->m_StepsType ) != value.end();
if( !bFound ) if( !bFound )
continue; continue;
FOREACH_PlayerNumber( pn ) FOREACH_PlayerNumber( pn )
{ {
for( int iCol=0; iCol<(*style)->m_iColsPerPlayer; ++iCol ) for( int iCol=0; iCol < style->m_iColsPerPlayer; ++iCol )
{ {
vector<GameInput> gi; vector<GameInput> gi;
(*style)->StyleInputToGameInput( iCol, pn, gi ); style->StyleInputToGameInput( iCol, pn, gi );
for(size_t i= 0; i < gi.size(); ++i) for(size_t i= 0; i < gi.size(); ++i)
{ {
if(gi[i].IsValid()) if(gi[i].IsValid())
@@ -93,11 +93,11 @@ static void GetUsedGameInputs( vector<GameInput> &vGameInputsOut )
} }
} }
FOREACHS_CONST( GameInput, vGIs, gi ) for (GameInput const &input : vGIs)
vGameInputsOut.push_back( *gi ); vGameInputsOut.push_back( input );
} }
LightsManager* LIGHTSMAN = NULL; // global and accessible from anywhere in our program LightsManager* LIGHTSMAN = nullptr; // global and accessible from anywhere in our program
LightsManager::LightsManager() LightsManager::LightsManager()
{ {
@@ -119,8 +119,10 @@ LightsManager::LightsManager()
LightsManager::~LightsManager() LightsManager::~LightsManager()
{ {
FOREACH( LightsDriver*, m_vpDrivers, iter ) for (LightsDriver *iter : m_vpDrivers)
SAFE_DELETE( *iter ); {
SAFE_DELETE( iter );
}
m_vpDrivers.clear(); m_vpDrivers.clear();
} }
@@ -438,8 +440,8 @@ void LightsManager::Update( float fDeltaTime )
} }
// apply new light values we set above // apply new light values we set above
FOREACH( LightsDriver*, m_vpDrivers, iter ) for (LightsDriver *iter : m_vpDrivers)
(*iter)->Set( &m_LightsState ); iter->Set( &m_LightsState );
} }
void LightsManager::BlinkCabinetLight( CabinetLight cl ) void LightsManager::BlinkCabinetLight( CabinetLight cl )
@@ -514,8 +516,8 @@ bool LightsManager::IsEnabled() const
void LightsManager::TurnOffAllLights() void LightsManager::TurnOffAllLights()
{ {
FOREACH( LightsDriver*, m_vpDrivers, iter ) for(LightsDriver *iter : m_vpDrivers)
(*iter)->Reset(); iter->Reset();
} }
/* /*
+4 -5
View File
@@ -1,6 +1,6 @@
#include "global.h" #include "global.h"
#include "LocalizedString.h" #include "LocalizedString.h"
#include "Foreach.h"
#include "RageUtil.h" #include "RageUtil.h"
#include "SubscriptionManager.h" #include "SubscriptionManager.h"
@@ -27,9 +27,8 @@ static LocalizedString::MakeLocalizer g_pMakeLocalizedStringImpl = LocalizedStri
void LocalizedString::RegisterLocalizer( MakeLocalizer pFunc ) void LocalizedString::RegisterLocalizer( MakeLocalizer pFunc )
{ {
g_pMakeLocalizedStringImpl = pFunc; g_pMakeLocalizedStringImpl = pFunc;
FOREACHS( LocalizedString*, *m_Subscribers.m_pSubscribers, l ) for (LocalizedString *pLoc : *m_Subscribers.m_pSubscribers)
{ {
LocalizedString *pLoc = *l;
pLoc->CreateImpl(); pLoc->CreateImpl();
} }
} }
@@ -40,7 +39,7 @@ LocalizedString::LocalizedString( const RString& sGroup, const RString& sName )
m_sGroup = sGroup; m_sGroup = sGroup;
m_sName = sName; m_sName = sName;
m_pImpl = NULL; m_pImpl = nullptr;
CreateImpl(); CreateImpl();
} }
@@ -51,7 +50,7 @@ LocalizedString::LocalizedString(LocalizedString const& other)
m_sGroup = other.m_sGroup; m_sGroup = other.m_sGroup;
m_sName = other.m_sName; m_sName = other.m_sName;
m_pImpl = NULL; m_pImpl = nullptr;
CreateImpl(); CreateImpl();
} }

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