Integrate C++11 branch into 5_1-new
This commit is contained in:
+3
-3
@@ -111,7 +111,7 @@ std::string valueToString( bool value )
|
||||
std::string valueToQuotedString( const char *value )
|
||||
{
|
||||
// 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 + "\"";
|
||||
// We have to walk value and escape any special characters.
|
||||
// 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 )
|
||||
: document_(NULL)
|
||||
: document_(nullptr)
|
||||
, rightMargin_( 74 )
|
||||
, indentation_( indentation )
|
||||
{
|
||||
@@ -559,7 +559,7 @@ StyledStreamWriter::write( std::ostream &out, const Value &root )
|
||||
writeValue( root );
|
||||
writeCommentAfterValueOnSameLine( root );
|
||||
*document_ << "\n";
|
||||
document_ = NULL; // Forget the stream, for safety.
|
||||
document_ = nullptr; // Forget the stream, for safety.
|
||||
}
|
||||
|
||||
|
||||
|
||||
+21
-22
@@ -5,7 +5,6 @@
|
||||
#include "RageUtil.h"
|
||||
#include "RageMath.h"
|
||||
#include "RageLog.h"
|
||||
#include "Foreach.h"
|
||||
#include "XmlFile.h"
|
||||
#include "LuaBinding.h"
|
||||
#include "ThemeManager.h"
|
||||
@@ -87,7 +86,7 @@ void Actor::InitState()
|
||||
{
|
||||
this->StopTweening();
|
||||
|
||||
m_pTempState = NULL;
|
||||
m_pTempState = nullptr;
|
||||
|
||||
m_baseRotation = RageVector3( 0, 0, 0 );
|
||||
m_baseScale = RageVector3( 1, 1, 1 );
|
||||
@@ -162,8 +161,8 @@ Actor::Actor()
|
||||
|
||||
m_size = RageVector2( 1, 1 );
|
||||
InitState();
|
||||
m_pParent = NULL;
|
||||
m_FakeParent= NULL;
|
||||
m_pParent = nullptr;
|
||||
m_FakeParent= nullptr;
|
||||
m_bFirstUpdate = true;
|
||||
m_tween_uses_effect_delta= false;
|
||||
}
|
||||
@@ -183,8 +182,8 @@ Actor::Actor( const Actor &cpy ):
|
||||
MessageSubscriber( cpy )
|
||||
{
|
||||
/* Don't copy an Actor in the middle of rendering. */
|
||||
ASSERT( cpy.m_pTempState == NULL );
|
||||
m_pTempState = NULL;
|
||||
ASSERT( cpy.m_pTempState == nullptr );
|
||||
m_pTempState = nullptr;
|
||||
|
||||
#define CPY(x) x = cpy.x
|
||||
CPY( m_sName );
|
||||
@@ -457,7 +456,7 @@ void Actor::Draw()
|
||||
this->SetInternalGlow(last_glow);
|
||||
}
|
||||
this->PreDraw();
|
||||
ASSERT( m_pTempState != NULL );
|
||||
ASSERT( m_pTempState != nullptr );
|
||||
if(PartiallyOpaque())
|
||||
{
|
||||
this->BeginDraw();
|
||||
@@ -475,16 +474,16 @@ void Actor::Draw()
|
||||
}
|
||||
abort_with_end_draw= true;
|
||||
state->PostDraw();
|
||||
state->m_pTempState= NULL;
|
||||
state->m_pTempState= nullptr;
|
||||
}
|
||||
|
||||
if(m_FakeParent)
|
||||
{
|
||||
m_FakeParent->EndDraw();
|
||||
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
|
||||
@@ -1364,7 +1363,7 @@ void Actor::RunCommands( const LuaReference& cmds, const LuaReference *pParamTab
|
||||
this->PushSelf( L );
|
||||
|
||||
// 2nd parameter
|
||||
if( pParamTable == NULL )
|
||||
if( pParamTable == nullptr )
|
||||
lua_pushnil( L );
|
||||
else
|
||||
pParamTable->PushSelf( L );
|
||||
@@ -1533,14 +1532,14 @@ void Actor::AddCommand( const RString &sCmdName, apActorCommands apac, bool warn
|
||||
|
||||
bool Actor::HasCommand( const RString &sCmdName ) const
|
||||
{
|
||||
return GetCommand(sCmdName) != NULL;
|
||||
return GetCommand(sCmdName) != nullptr;
|
||||
}
|
||||
|
||||
const apActorCommands *Actor::GetCommand( const RString &sCommandName ) const
|
||||
{
|
||||
map<RString, apActorCommands>::const_iterator it = m_mapNameToCommands.find( sCommandName );
|
||||
if( it == m_mapNameToCommands.end() )
|
||||
return NULL;
|
||||
return nullptr;
|
||||
return &it->second;
|
||||
}
|
||||
|
||||
@@ -1552,7 +1551,7 @@ void Actor::HandleMessage( const Message &msg )
|
||||
void Actor::PlayCommandNoRecurse( const Message &msg )
|
||||
{
|
||||
const apActorCommands *pCmd = GetCommand( msg.GetName() );
|
||||
if(pCmd != NULL && (*pCmd)->IsSet() && !(*pCmd)->IsNil())
|
||||
if(pCmd != nullptr && (*pCmd)->IsSet() && !(*pCmd)->IsNil())
|
||||
{
|
||||
RunCommands( *pCmd, &msg.GetParamTable() );
|
||||
}
|
||||
@@ -1584,7 +1583,7 @@ void Actor::SetParent( Actor *pParent )
|
||||
|
||||
Actor::TweenInfo::TweenInfo()
|
||||
{
|
||||
m_pTween = NULL;
|
||||
m_pTween = nullptr;
|
||||
}
|
||||
|
||||
Actor::TweenInfo::~TweenInfo()
|
||||
@@ -1594,14 +1593,14 @@ Actor::TweenInfo::~TweenInfo()
|
||||
|
||||
Actor::TweenInfo::TweenInfo( const TweenInfo &cpy )
|
||||
{
|
||||
m_pTween = NULL;
|
||||
m_pTween = nullptr;
|
||||
*this = cpy;
|
||||
}
|
||||
|
||||
Actor::TweenInfo &Actor::TweenInfo::operator=( const TweenInfo &rhs )
|
||||
{
|
||||
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_fTweenTime = rhs.m_fTweenTime;
|
||||
m_sCommandName = rhs.m_sCommandName;
|
||||
@@ -1680,7 +1679,7 @@ public:
|
||||
COMMON_RETURN_SELF;
|
||||
}
|
||||
ITween *pTween = ITween::CreateFromStack( L, 2 );
|
||||
if(pTween != NULL)
|
||||
if(pTween != nullptr)
|
||||
{
|
||||
p->BeginTweening(fTime, pTween);
|
||||
}
|
||||
@@ -1875,7 +1874,7 @@ public:
|
||||
static int GetCommand( T* p, lua_State *L )
|
||||
{
|
||||
const apActorCommands *pCommand = p->GetCommand(SArg(1));
|
||||
if( pCommand == NULL )
|
||||
if( pCommand == nullptr )
|
||||
lua_pushnil( L );
|
||||
else
|
||||
(*pCommand)->PushSelf(L);
|
||||
@@ -1933,7 +1932,7 @@ public:
|
||||
static int GetParent( T* p, lua_State *L )
|
||||
{
|
||||
Actor *pParent = p->GetParent();
|
||||
if( pParent == NULL )
|
||||
if( pParent == nullptr )
|
||||
lua_pushnil( L );
|
||||
else
|
||||
pParent->PushSelf(L);
|
||||
@@ -1942,7 +1941,7 @@ public:
|
||||
static int GetFakeParent(T* p, lua_State *L)
|
||||
{
|
||||
Actor* fake= p->GetFakeParent();
|
||||
if(fake == NULL)
|
||||
if(fake == nullptr)
|
||||
{
|
||||
lua_pushnil(L);
|
||||
}
|
||||
@@ -1956,7 +1955,7 @@ public:
|
||||
{
|
||||
if(lua_isnoneornil(L, 1))
|
||||
{
|
||||
p->SetFakeParent(NULL);
|
||||
p->SetFakeParent(nullptr);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
+4
-4
@@ -602,11 +602,11 @@ public:
|
||||
void PlayCommandNoRecurse( const Message &msg );
|
||||
|
||||
// Commands by reference
|
||||
virtual void RunCommands( const LuaReference& cmds, const LuaReference *pParamTable = NULL );
|
||||
void RunCommands( const apActorCommands& cmds, const LuaReference *pParamTable = NULL ) { this->RunCommands( *cmds, pParamTable ); } // convenience
|
||||
virtual void RunCommandsRecursively( const LuaReference& cmds, const LuaReference *pParamTable = NULL ) { RunCommands(cmds, pParamTable); }
|
||||
virtual void RunCommands( const LuaReference& cmds, const LuaReference *pParamTable = nullptr );
|
||||
void RunCommands( const apActorCommands& cmds, const LuaReference *pParamTable = nullptr ) { this->RunCommands( *cmds, pParamTable ); } // convenience
|
||||
virtual void RunCommandsRecursively( const LuaReference& cmds, const LuaReference *pParamTable = nullptr ) { RunCommands(cmds, pParamTable); }
|
||||
// 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
|
||||
virtual void HandleMessage( const Message &msg );
|
||||
|
||||
+24
-26
@@ -9,7 +9,7 @@
|
||||
#include "ActorUtil.h"
|
||||
#include "RageDisplay.h"
|
||||
#include "ScreenDimensions.h"
|
||||
#include "Foreach.h"
|
||||
|
||||
|
||||
/* 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
|
||||
@@ -82,8 +82,7 @@ ActorFrame::ActorFrame( const ActorFrame &cpy ):
|
||||
|
||||
void ActorFrame::InitState()
|
||||
{
|
||||
FOREACH( Actor*, m_SubActors, a )
|
||||
(*a)->InitState();
|
||||
std::for_each(m_SubActors.begin(), m_SubActors.end(), [](Actor *a) { a->InitState(); });
|
||||
Actor::InitState();
|
||||
}
|
||||
|
||||
@@ -119,7 +118,7 @@ void ActorFrame::LoadChildrenFromNode( const XNode* pNode )
|
||||
// Load children
|
||||
const XNode* pChildren = pNode->GetChild("children");
|
||||
bool bArrayOnly = false;
|
||||
if( pChildren == NULL )
|
||||
if( pChildren == nullptr )
|
||||
{
|
||||
bArrayOnly = true;
|
||||
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()) );
|
||||
#endif
|
||||
|
||||
ASSERT( pActor != NULL );
|
||||
ASSERT( pActor != nullptr );
|
||||
ASSERT( (void*)pActor != (void*)0xC0000005 );
|
||||
m_SubActors.push_back( pActor );
|
||||
|
||||
@@ -162,19 +161,18 @@ void ActorFrame::RemoveChild( Actor *pActor )
|
||||
|
||||
void ActorFrame::TransferChildren( ActorFrame *pTo )
|
||||
{
|
||||
FOREACH( Actor*, m_SubActors, i )
|
||||
pTo->AddChild( *i );
|
||||
std::for_each(m_SubActors.begin(), m_SubActors.end(), [&](Actor *a) { pTo->AddChild(a); });
|
||||
RemoveAllChildren();
|
||||
}
|
||||
|
||||
Actor* ActorFrame::GetChild( const RString &sName )
|
||||
{
|
||||
FOREACH( Actor*, m_SubActors, a )
|
||||
for (Actor *a : m_SubActors)
|
||||
{
|
||||
if( (*a)->GetName() == sName )
|
||||
return *a;
|
||||
if( a->GetName() == sName )
|
||||
return a;
|
||||
}
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void ActorFrame::RemoveAllChildren()
|
||||
@@ -374,15 +372,15 @@ static void AddToChildTable(lua_State* L, Actor* a)
|
||||
void ActorFrame::PushChildrenTable( lua_State *L )
|
||||
{
|
||||
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
|
||||
if(lua_isnil(L, -1))
|
||||
{
|
||||
lua_pop(L, 1); // stack: all_actors
|
||||
LuaHelpers::Push( L, (*a)->GetName() ); // stack: all_actors, name
|
||||
(*a)->PushSelf( L ); // stack: all_actors, name, actor
|
||||
LuaHelpers::Push( L, a->GetName() ); // stack: all_actors, name
|
||||
a->PushSelf( L ); // stack: all_actors, name, actor
|
||||
lua_rawset( L, -3 ); // stack: all_actors
|
||||
}
|
||||
else
|
||||
@@ -391,14 +389,14 @@ void ActorFrame::PushChildrenTable( lua_State *L )
|
||||
if(lua_objlen(L, -1) > 0)
|
||||
{
|
||||
// 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
|
||||
}
|
||||
else
|
||||
{
|
||||
// stack: all_actors, old_entry
|
||||
CreateChildTable(L, *a); // stack: all_actors, table_entry
|
||||
LuaHelpers::Push(L, (*a)->GetName()); // stack: all_actors, table_entry, name
|
||||
CreateChildTable(L, a); // stack: all_actors, table_entry
|
||||
LuaHelpers::Push(L, a->GetName()); // stack: all_actors, table_entry, name
|
||||
lua_insert(L, -2); // stack: all_actors, name, table_entry
|
||||
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)
|
||||
{
|
||||
int found= 0;
|
||||
FOREACH(Actor*, m_SubActors, a)
|
||||
for (Actor *a: m_SubActors)
|
||||
{
|
||||
if((*a)->GetName() == sName)
|
||||
if(a->GetName() == sName)
|
||||
{
|
||||
switch(found)
|
||||
{
|
||||
case 0:
|
||||
(*a)->PushSelf(L);
|
||||
a->PushSelf(L);
|
||||
break;
|
||||
case 1:
|
||||
CreateChildTable(L, *a);
|
||||
CreateChildTable(L, a);
|
||||
break;
|
||||
default:
|
||||
AddToChildTable(L, *a);
|
||||
AddToChildTable(L, a);
|
||||
break;
|
||||
}
|
||||
++found;
|
||||
@@ -437,14 +435,14 @@ void ActorFrame::PushChildTable(lua_State* L, const RString &sName)
|
||||
void ActorFrame::PlayCommandOnChildren( const RString &sCommandName, const LuaReference *pParamTable )
|
||||
{
|
||||
const apActorCommands *pCmd = GetCommand( sCommandName );
|
||||
if( pCmd != NULL )
|
||||
if( pCmd != nullptr )
|
||||
RunCommandsOnChildren( *pCmd, pParamTable );
|
||||
}
|
||||
|
||||
void ActorFrame::PlayCommandOnLeaves( const RString &sCommandName, const LuaReference *pParamTable )
|
||||
{
|
||||
const apActorCommands *pCmd = GetCommand( sCommandName );
|
||||
if( pCmd != NULL )
|
||||
if( pCmd != nullptr )
|
||||
RunCommandsOnLeaves( **pCmd, pParamTable );
|
||||
}
|
||||
|
||||
@@ -720,7 +718,7 @@ public:
|
||||
{
|
||||
// this one is tricky, we need to get an Actor from Lua.
|
||||
Actor *pActor = ActorUtil::MakeActor( SArg(1) );
|
||||
if ( pActor == NULL )
|
||||
if ( pActor == nullptr )
|
||||
{
|
||||
lua_pushboolean( L, 0 );
|
||||
return 1;
|
||||
|
||||
+8
-8
@@ -56,13 +56,13 @@ public:
|
||||
virtual void PushSelf( lua_State *L );
|
||||
void PushChildrenTable( lua_State *L );
|
||||
void PushChildTable( lua_State *L, const RString &sName );
|
||||
void PlayCommandOnChildren( const RString &sCommandName, const LuaReference *pParamTable = NULL );
|
||||
void PlayCommandOnLeaves( const RString &sCommandName, const LuaReference *pParamTable = NULL );
|
||||
void PlayCommandOnChildren( const RString &sCommandName, const LuaReference *pParamTable = nullptr );
|
||||
void PlayCommandOnLeaves( const RString &sCommandName, const LuaReference *pParamTable = nullptr );
|
||||
|
||||
virtual void RunCommandsRecursively( const LuaReference& cmds, const LuaReference *pParamTable = NULL );
|
||||
virtual void RunCommandsOnChildren( const LuaReference& cmds, const LuaReference *pParamTable = NULL ); /* but not on self */
|
||||
void RunCommandsOnChildren( const apActorCommands& cmds, const LuaReference *pParamTable = NULL ) { this->RunCommandsOnChildren( *cmds, pParamTable ); } // convenience
|
||||
virtual void RunCommandsOnLeaves( const LuaReference& cmds, const LuaReference *pParamTable = NULL ); /* but not on self */
|
||||
virtual void RunCommandsRecursively( const LuaReference& cmds, const LuaReference *pParamTable = nullptr );
|
||||
virtual void RunCommandsOnChildren( const LuaReference& cmds, const LuaReference *pParamTable = nullptr ); /* but not on self */
|
||||
void RunCommandsOnChildren( const apActorCommands& cmds, const LuaReference *pParamTable = nullptr ) { this->RunCommandsOnChildren( *cmds, pParamTable ); } // convenience
|
||||
virtual void RunCommandsOnLeaves( const LuaReference& cmds, const LuaReference *pParamTable = nullptr ); /* but not on self */
|
||||
|
||||
virtual void UpdateInternal( float fDeltaTime );
|
||||
virtual void BeginDraw();
|
||||
@@ -92,8 +92,8 @@ public:
|
||||
virtual float GetTweenTimeLeft() const;
|
||||
|
||||
virtual void HandleMessage( const Message &msg );
|
||||
virtual void RunCommands( const LuaReference& cmds, const LuaReference *pParamTable = NULL );
|
||||
void RunCommands( const apActorCommands& cmds, const LuaReference *pParamTable = NULL ) { this->RunCommands( *cmds, pParamTable ); } // convenience
|
||||
virtual void RunCommands( const LuaReference& cmds, const LuaReference *pParamTable = nullptr );
|
||||
void RunCommands( const apActorCommands& cmds, const LuaReference *pParamTable = nullptr ) { this->RunCommands( *cmds, pParamTable ); } // convenience
|
||||
|
||||
protected:
|
||||
void LoadChildrenFromNode( const XNode* pNode );
|
||||
|
||||
@@ -18,7 +18,7 @@ ActorFrameTexture::ActorFrameTexture()
|
||||
++i;
|
||||
m_sTextureName = ssprintf( ConvertI64FormatString("ActorFrameTexture %lli"), i );
|
||||
|
||||
m_pRenderTarget = NULL;
|
||||
m_pRenderTarget = nullptr;
|
||||
}
|
||||
|
||||
ActorFrameTexture::ActorFrameTexture( const ActorFrameTexture &cpy ):
|
||||
@@ -35,7 +35,7 @@ ActorFrameTexture::~ActorFrameTexture()
|
||||
|
||||
void ActorFrameTexture::Create()
|
||||
{
|
||||
if( m_pRenderTarget != NULL )
|
||||
if( m_pRenderTarget != nullptr )
|
||||
{
|
||||
LuaHelpers::ReportScriptError( "Can't Create an already created ActorFrameTexture" );
|
||||
return;
|
||||
@@ -71,7 +71,7 @@ void ActorFrameTexture::Create()
|
||||
|
||||
void ActorFrameTexture::DrawPrimitives()
|
||||
{
|
||||
if( m_pRenderTarget == NULL )
|
||||
if( m_pRenderTarget == nullptr )
|
||||
return;
|
||||
|
||||
m_pRenderTarget->BeginRenderingTo( m_bPreserveTexture );
|
||||
@@ -97,7 +97,7 @@ public:
|
||||
static int GetTexture( T* p, lua_State *L )
|
||||
{
|
||||
RageTexture *pTexture = p->GetTexture();
|
||||
if( pTexture == NULL )
|
||||
if( pTexture == nullptr )
|
||||
{
|
||||
lua_pushnil(L);
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
#include "RageTexture.h"
|
||||
#include "RageUtil.h"
|
||||
#include "ActorUtil.h"
|
||||
#include "Foreach.h"
|
||||
|
||||
#include "LuaBinding.h"
|
||||
#include "LuaManager.h"
|
||||
|
||||
@@ -35,8 +35,8 @@ ActorMultiTexture::ActorMultiTexture( const ActorMultiTexture &cpy ):
|
||||
CPY( m_aTextureUnits );
|
||||
#undef CPY
|
||||
|
||||
FOREACH( TextureUnitState, m_aTextureUnits, tex )
|
||||
tex->m_pTexture = TEXTUREMAN->CopyTexture( tex->m_pTexture );
|
||||
for (TextureUnitState &tex : m_aTextureUnits)
|
||||
tex.m_pTexture = TEXTUREMAN->CopyTexture( tex.m_pTexture );
|
||||
}
|
||||
|
||||
void ActorMultiTexture::SetTextureCoords( const RectF &r )
|
||||
@@ -58,14 +58,14 @@ void ActorMultiTexture::SetSizeFromTexture( RageTexture *pTexture )
|
||||
|
||||
void ActorMultiTexture::ClearTextures()
|
||||
{
|
||||
FOREACH( TextureUnitState, m_aTextureUnits, tex )
|
||||
TEXTUREMAN->UnloadTexture( tex->m_pTexture );
|
||||
for (TextureUnitState &tex : m_aTextureUnits)
|
||||
TEXTUREMAN->UnloadTexture( tex.m_pTexture );
|
||||
m_aTextureUnits.clear();
|
||||
}
|
||||
|
||||
int ActorMultiTexture::AddTexture( RageTexture *pTexture )
|
||||
{
|
||||
if( pTexture == NULL )
|
||||
if( pTexture == nullptr )
|
||||
{
|
||||
LOG->Warn( "Can't add nil texture to ActorMultiTexture" );
|
||||
return m_aTextureUnits.size();
|
||||
|
||||
+73
-73
@@ -1,73 +1,73 @@
|
||||
/** @brief ActorMultiTexture - A texture created from multiple textures. */
|
||||
|
||||
#ifndef ACTOR_MULTI_TEXTURE_H
|
||||
#define ACTOR_MULTI_TEXTURE_H
|
||||
|
||||
#include "Actor.h"
|
||||
#include "RageDisplay.h"
|
||||
|
||||
class RageTexture;
|
||||
|
||||
class ActorMultiTexture: public Actor
|
||||
{
|
||||
public:
|
||||
ActorMultiTexture();
|
||||
ActorMultiTexture( const ActorMultiTexture &cpy );
|
||||
virtual ~ActorMultiTexture();
|
||||
|
||||
void LoadFromNode( const XNode* pNode );
|
||||
virtual ActorMultiTexture *Copy() const;
|
||||
|
||||
virtual bool EarlyAbortDraw() const;
|
||||
virtual void DrawPrimitives();
|
||||
|
||||
void ClearTextures();
|
||||
int AddTexture( RageTexture *pTexture );
|
||||
void SetTextureMode( int iIndex, TextureMode tm );
|
||||
|
||||
void SetSizeFromTexture( RageTexture *pTexture );
|
||||
void SetTextureCoords( const RectF &r );
|
||||
void SetEffectMode( EffectMode em ) { m_EffectMode = em; }
|
||||
|
||||
virtual void PushSelf( lua_State *L );
|
||||
|
||||
private:
|
||||
EffectMode m_EffectMode;
|
||||
struct TextureUnitState
|
||||
{
|
||||
TextureUnitState(): m_pTexture(NULL), m_TextureMode(TextureMode_Modulate) {}
|
||||
RageTexture *m_pTexture;
|
||||
TextureMode m_TextureMode;
|
||||
};
|
||||
vector<TextureUnitState> m_aTextureUnits;
|
||||
RectF m_Rect;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @author Chris Danford (c) 2001-2004
|
||||
* @section LICENSE
|
||||
* All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* 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.
|
||||
*/
|
||||
/** @brief ActorMultiTexture - A texture created from multiple textures. */
|
||||
|
||||
#ifndef ACTOR_MULTI_TEXTURE_H
|
||||
#define ACTOR_MULTI_TEXTURE_H
|
||||
|
||||
#include "Actor.h"
|
||||
#include "RageDisplay.h"
|
||||
|
||||
class RageTexture;
|
||||
|
||||
class ActorMultiTexture: public Actor
|
||||
{
|
||||
public:
|
||||
ActorMultiTexture();
|
||||
ActorMultiTexture( const ActorMultiTexture &cpy );
|
||||
virtual ~ActorMultiTexture();
|
||||
|
||||
void LoadFromNode( const XNode* pNode );
|
||||
virtual ActorMultiTexture *Copy() const;
|
||||
|
||||
virtual bool EarlyAbortDraw() const;
|
||||
virtual void DrawPrimitives();
|
||||
|
||||
void ClearTextures();
|
||||
int AddTexture( RageTexture *pTexture );
|
||||
void SetTextureMode( int iIndex, TextureMode tm );
|
||||
|
||||
void SetSizeFromTexture( RageTexture *pTexture );
|
||||
void SetTextureCoords( const RectF &r );
|
||||
void SetEffectMode( EffectMode em ) { m_EffectMode = em; }
|
||||
|
||||
virtual void PushSelf( lua_State *L );
|
||||
|
||||
private:
|
||||
EffectMode m_EffectMode;
|
||||
struct TextureUnitState
|
||||
{
|
||||
TextureUnitState(): m_pTexture(nullptr), m_TextureMode(TextureMode_Modulate) {}
|
||||
RageTexture *m_pTexture;
|
||||
TextureMode m_TextureMode;
|
||||
};
|
||||
vector<TextureUnitState> m_aTextureUnits;
|
||||
RectF m_Rect;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @author Chris Danford (c) 2001-2004
|
||||
* @section LICENSE
|
||||
* All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* 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.
|
||||
*/
|
||||
|
||||
+15
-18
@@ -10,7 +10,6 @@
|
||||
#include "RageTimer.h"
|
||||
#include "RageUtil.h"
|
||||
#include "ActorUtil.h"
|
||||
#include "Foreach.h"
|
||||
#include "LuaBinding.h"
|
||||
#include "LuaManager.h"
|
||||
#include "LocalizedString.h"
|
||||
@@ -100,13 +99,13 @@ ActorMultiVertex::ActorMultiVertex( const ActorMultiVertex &cpy ):
|
||||
CPY(_states);
|
||||
#undef CPY
|
||||
|
||||
if( cpy._Texture != NULL )
|
||||
if( cpy._Texture != nullptr )
|
||||
{
|
||||
_Texture = TEXTUREMAN->CopyTexture( cpy._Texture );
|
||||
}
|
||||
else
|
||||
{
|
||||
_Texture = NULL;
|
||||
_Texture = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -137,7 +136,7 @@ void ActorMultiVertex::SetTexture( RageTexture *Texture )
|
||||
|
||||
void ActorMultiVertex::LoadFromTexture( RageTextureID ID )
|
||||
{
|
||||
RageTexture *Texture = NULL;
|
||||
RageTexture *Texture = nullptr;
|
||||
if( _Texture && _Texture->GetID() == ID )
|
||||
{
|
||||
return;
|
||||
@@ -148,10 +147,10 @@ void ActorMultiVertex::LoadFromTexture( RageTextureID ID )
|
||||
|
||||
void ActorMultiVertex::UnloadTexture()
|
||||
{
|
||||
if( _Texture != NULL )
|
||||
if( _Texture != nullptr )
|
||||
{
|
||||
TEXTUREMAN->UnloadTexture( _Texture );
|
||||
_Texture = NULL;
|
||||
_Texture = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -409,20 +408,18 @@ void ActorMultiVertex::SetState(size_t i)
|
||||
|
||||
void ActorMultiVertex::SetAllStateDelays(float delay)
|
||||
{
|
||||
FOREACH(State, _states, s)
|
||||
for (State &s : _states)
|
||||
{
|
||||
s->delay= delay;
|
||||
s.delay= delay;
|
||||
}
|
||||
}
|
||||
|
||||
float ActorMultiVertex::GetAnimationLengthSeconds() const
|
||||
{
|
||||
float tot= 0.0f;
|
||||
FOREACH_CONST(State, _states, s)
|
||||
{
|
||||
tot+= s->delay;
|
||||
}
|
||||
return tot;
|
||||
auto calcDelay = [](float total, State const &s) {
|
||||
return total + s.delay;
|
||||
};
|
||||
return std::accumulate(_states.begin(), _states.end(), 0.f, calcDelay);
|
||||
}
|
||||
|
||||
void ActorMultiVertex::SetSecondsIntoAnimation(float seconds)
|
||||
@@ -958,7 +955,7 @@ public:
|
||||
static void FillStateFromLua(lua_State *L, ActorMultiVertex::State& state,
|
||||
RageTexture* tex, int index)
|
||||
{
|
||||
if(tex == NULL)
|
||||
if(tex == nullptr)
|
||||
{
|
||||
luaL_error(L, "The texture must be set before adding states.");
|
||||
}
|
||||
@@ -1027,7 +1024,7 @@ public:
|
||||
static int GetStateData(T* p, lua_State *L)
|
||||
{
|
||||
RageTexture* tex= p->GetTexture();
|
||||
if(tex == NULL)
|
||||
if(tex == nullptr)
|
||||
{
|
||||
luaL_error(L, "The texture must be set before adding states.");
|
||||
}
|
||||
@@ -1065,7 +1062,7 @@ public:
|
||||
luaL_error(L, "The states must be inside a table.");
|
||||
}
|
||||
RageTexture* tex= p->GetTexture();
|
||||
if(tex == NULL)
|
||||
if(tex == nullptr)
|
||||
{
|
||||
luaL_error(L, "The texture must be set before adding states.");
|
||||
}
|
||||
@@ -1148,7 +1145,7 @@ public:
|
||||
static int GetTexture(T* p, lua_State *L)
|
||||
{
|
||||
RageTexture *texture = p->GetTexture();
|
||||
if(texture != NULL)
|
||||
if(texture != nullptr)
|
||||
{
|
||||
texture->PushSelf(L);
|
||||
}
|
||||
|
||||
+4
-4
@@ -6,17 +6,17 @@ REGISTER_ACTOR_CLASS( ActorProxy );
|
||||
|
||||
ActorProxy::ActorProxy()
|
||||
{
|
||||
m_pActorTarget = NULL;
|
||||
m_pActorTarget = nullptr;
|
||||
}
|
||||
|
||||
bool ActorProxy::EarlyAbortDraw() const
|
||||
{
|
||||
return m_pActorTarget == NULL || Actor::EarlyAbortDraw();
|
||||
return m_pActorTarget == nullptr || Actor::EarlyAbortDraw();
|
||||
}
|
||||
|
||||
void ActorProxy::DrawPrimitives()
|
||||
{
|
||||
if( m_pActorTarget != NULL )
|
||||
if( m_pActorTarget != nullptr )
|
||||
{
|
||||
bool bVisible = m_pActorTarget->GetVisible();
|
||||
m_pActorTarget->SetVisible( true );
|
||||
@@ -47,7 +47,7 @@ public:
|
||||
static int GetTarget( T* p, lua_State *L )
|
||||
{
|
||||
Actor *pTarget = p->GetTarget();
|
||||
if( pTarget != NULL )
|
||||
if( pTarget != nullptr )
|
||||
pTarget->PushSelf( L );
|
||||
else
|
||||
lua_pushnil( L );
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include "global.h"
|
||||
#include "ActorScroller.h"
|
||||
#include "Foreach.h"
|
||||
|
||||
#include "RageUtil.h"
|
||||
#include "XmlFile.h"
|
||||
#include "arch/Dialog/Dialog.h"
|
||||
@@ -312,8 +312,8 @@ void ActorScroller::PositionItemsAndDrawPrimitives( bool bDrawPrimitives )
|
||||
if( m_bDrawByZPosition )
|
||||
{
|
||||
ActorUtil::SortByZPosition( subs );
|
||||
FOREACH( Actor*, subs, a )
|
||||
(*a)->Draw();
|
||||
for (Actor *a : subs)
|
||||
a->Draw();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+16
-18
@@ -10,7 +10,6 @@
|
||||
#include "XmlFileUtil.h"
|
||||
#include "IniFile.h"
|
||||
#include "LuaManager.h"
|
||||
#include "Foreach.h"
|
||||
#include "Song.h"
|
||||
#include "Course.h"
|
||||
#include "GameState.h"
|
||||
@@ -19,7 +18,7 @@
|
||||
|
||||
|
||||
// Actor registration
|
||||
static map<RString,CreateActorFn> *g_pmapRegistrees = NULL;
|
||||
static map<RString,CreateActorFn> *g_pmapRegistrees = nullptr;
|
||||
|
||||
static bool IsRegistered( const RString& sClassName )
|
||||
{
|
||||
@@ -28,7 +27,7 @@ static bool IsRegistered( const RString& sClassName )
|
||||
|
||||
void ActorUtil::Register( const RString& sClassName, CreateActorFn pfn )
|
||||
{
|
||||
if( g_pmapRegistrees == NULL )
|
||||
if( g_pmapRegistrees == nullptr )
|
||||
g_pmapRegistrees = new map<RString,CreateActorFn>;
|
||||
|
||||
map<RString,CreateActorFn>::iterator iter = g_pmapRegistrees->find( sClassName );
|
||||
@@ -123,7 +122,7 @@ namespace
|
||||
// The non-legacy LoadFromNode has already checked the Class and
|
||||
// Type attributes.
|
||||
|
||||
if (pActor->GetAttr("Text") != NULL)
|
||||
if (pActor->GetAttr("Text") != nullptr)
|
||||
return "BitmapText";
|
||||
|
||||
RString sFile;
|
||||
@@ -172,7 +171,7 @@ namespace
|
||||
|
||||
Actor *ActorUtil::LoadFromNode( const XNode* _pNode, Actor *pParentActor )
|
||||
{
|
||||
ASSERT( _pNode != NULL );
|
||||
ASSERT( _pNode != nullptr );
|
||||
|
||||
XNode node = *_pNode;
|
||||
|
||||
@@ -182,7 +181,7 @@ Actor *ActorUtil::LoadFromNode( const XNode* _pNode, Actor *pParentActor )
|
||||
{
|
||||
bool bCond;
|
||||
if( node.GetAttrValue("Condition", bCond) && !bCond )
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
RString sClass;
|
||||
@@ -190,7 +189,7 @@ Actor *ActorUtil::LoadFromNode( const XNode* _pNode, Actor *pParentActor )
|
||||
if( !bHasClass )
|
||||
bHasClass = node.GetAttrValue( "Type", sClass );
|
||||
|
||||
bool bLegacy = (node.GetAttr( "_LegacyXml" ) != NULL);
|
||||
bool bLegacy = (node.GetAttr( "_LegacyXml" ) != nullptr);
|
||||
if( !bHasClass && bLegacy )
|
||||
sClass = GetLegacyActorClass( &node );
|
||||
|
||||
@@ -209,8 +208,8 @@ Actor *ActorUtil::LoadFromNode( const XNode* _pNode, Actor *pParentActor )
|
||||
if (ResolvePath(sPath, GetWhere(&node)))
|
||||
{
|
||||
Actor *pNewActor = MakeActor(sPath, pParentActor);
|
||||
if (pNewActor == NULL)
|
||||
return NULL;
|
||||
if (pNewActor == nullptr)
|
||||
return nullptr;
|
||||
if (pParentActor)
|
||||
pNewActor->SetParent(pParentActor);
|
||||
pNewActor->LoadFromNode(&node);
|
||||
@@ -241,7 +240,7 @@ namespace
|
||||
{
|
||||
RString sScript;
|
||||
if( !GetFileContents(sFile, sScript) )
|
||||
return NULL;
|
||||
return nullptr;
|
||||
|
||||
Lua *L = LUA->Get();
|
||||
|
||||
@@ -251,10 +250,10 @@ namespace
|
||||
LUA->Release( L );
|
||||
sError = ssprintf( "Lua runtime error: %s", sError.c_str() );
|
||||
LuaHelpers::ReportScriptError(sError);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
XNode *pRet = NULL;
|
||||
XNode *pRet = nullptr;
|
||||
if( ActorUtil::LoadTableFromStackShowErrors(L) )
|
||||
pRet = XmlFileUtil::XNodeFromTable( L );
|
||||
|
||||
@@ -295,7 +294,7 @@ bool ActorUtil::LoadTableFromStackShowErrors( Lua *L )
|
||||
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.
|
||||
Actor* ActorUtil::MakeActor( const RString &sPath_, Actor *pParentActor )
|
||||
{
|
||||
@@ -306,8 +305,8 @@ Actor* ActorUtil::MakeActor( const RString &sPath_, Actor *pParentActor )
|
||||
{
|
||||
case FT_Lua:
|
||||
{
|
||||
auto_ptr<XNode> pNode( LoadXNodeFromLuaShowErrors(sPath) );
|
||||
if( pNode.get() == NULL )
|
||||
unique_ptr<XNode> pNode( LoadXNodeFromLuaShowErrors(sPath) );
|
||||
if( pNode.get() == nullptr )
|
||||
{
|
||||
// XNode will warn about the error
|
||||
return new Actor;
|
||||
@@ -475,9 +474,8 @@ void ActorUtil::LoadAllCommandsFromName( Actor& actor, const RString &sMetricsGr
|
||||
set<RString> 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";
|
||||
if( EndsWith(sv,sEnding) )
|
||||
{
|
||||
@@ -680,7 +678,7 @@ namespace
|
||||
LIST_METHOD( LoadAllCommands ),
|
||||
LIST_METHOD( LoadAllCommandsFromName ),
|
||||
LIST_METHOD( LoadAllCommandsAndSetXY ),
|
||||
{ NULL, NULL }
|
||||
{ nullptr, nullptr }
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -115,8 +115,8 @@ namespace ActorUtil
|
||||
inline void LoadAllCommandsAndSetXYAndOnCommand( Actor* pActor, const RString &sMetricsGroup ) { if(pActor) LoadAllCommandsAndSetXYAndOnCommand( *pActor, sMetricsGroup ); }
|
||||
|
||||
// Return a Sprite, BitmapText, or Model depending on the file type
|
||||
Actor* LoadFromNode( const XNode* pNode, Actor *pParentActor = NULL );
|
||||
Actor* MakeActor( const RString &sPath, Actor *pParentActor = NULL );
|
||||
Actor* LoadFromNode( const XNode* pNode, Actor *pParentActor = nullptr );
|
||||
Actor* MakeActor( const RString &sPath, Actor *pParentActor = nullptr );
|
||||
RString GetSourcePath( const XNode *pNode );
|
||||
RString GetWhere( const XNode *pNode );
|
||||
bool GetAttrPath( const XNode *pNode, const RString &sName, RString &sOut, bool optional= false );
|
||||
|
||||
+8
-8
@@ -41,7 +41,7 @@
|
||||
#include "LocalizedString.h"
|
||||
#include "PrefsManager.h"
|
||||
#include "ScreenManager.h"
|
||||
#include "Foreach.h"
|
||||
|
||||
|
||||
vector<TimingData> AdjustSync::s_vpTimingDataOriginal;
|
||||
float AdjustSync::s_fGlobalOffsetSecondsOriginal = 0.0f;
|
||||
@@ -61,9 +61,9 @@ void AdjustSync::ResetOriginalSyncData()
|
||||
{
|
||||
s_vpTimingDataOriginal.push_back(GAMESTATE->m_pCurSong->m_SongTiming);
|
||||
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
|
||||
@@ -128,9 +128,9 @@ void AdjustSync::RevertSyncChanges()
|
||||
|
||||
unsigned location = 1;
|
||||
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++;
|
||||
}
|
||||
|
||||
@@ -199,13 +199,13 @@ void AdjustSync::AutosyncOffset()
|
||||
{
|
||||
GAMESTATE->m_pCurSong->m_SongTiming.m_fBeat0OffsetInSeconds += mean;
|
||||
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
|
||||
// from the song and is already changed.
|
||||
if( (*s)->m_Timing.empty() )
|
||||
if( s->m_Timing.empty() )
|
||||
continue;
|
||||
(*s)->m_Timing.m_fBeat0OffsetInSeconds += mean;
|
||||
s->m_Timing.m_fBeat0OffsetInSeconds += mean;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
#include "RageFile.h"
|
||||
#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";
|
||||
@@ -101,7 +101,7 @@ static const char *aliases[][2] = {
|
||||
{ "gameplay combo 900", "gameplay 900 combo" },
|
||||
{ "gameplay combo 1000", "gameplay 1000 combo" },
|
||||
|
||||
{ NULL, NULL }
|
||||
{ nullptr, nullptr }
|
||||
};
|
||||
|
||||
/* 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. */
|
||||
int i;
|
||||
for(i = 0; aliases[i][0] != NULL; ++i)
|
||||
for(i = 0; aliases[i][0] != nullptr; ++i)
|
||||
{
|
||||
if(!sFolderName.EqualsNoCase(aliases[i][0]))
|
||||
continue; /* no match */
|
||||
|
||||
@@ -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_GATE( "ArrowEffects", "TinyPercentGate" );
|
||||
|
||||
static const PlayerOptions* curr_options= NULL;
|
||||
static const PlayerOptions* curr_options= nullptr;
|
||||
|
||||
float ArrowGetPercentVisible(float fYPosWithoutReverse, int iCol, float fYOffset);
|
||||
|
||||
@@ -1653,7 +1653,7 @@ namespace
|
||||
LIST_METHOD( NeedZBuffer ),
|
||||
LIST_METHOD( GetZoom ),
|
||||
LIST_METHOD( GetFrameWidthScale ),
|
||||
{ NULL, NULL }
|
||||
{ nullptr, nullptr }
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
+11
-16
@@ -3,13 +3,13 @@
|
||||
#include "GameState.h"
|
||||
#include "RageUtil.h"
|
||||
#include "Song.h"
|
||||
#include "Foreach.h"
|
||||
|
||||
#include "PlayerOptions.h"
|
||||
#include "PlayerState.h"
|
||||
|
||||
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) );
|
||||
|
||||
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. */
|
||||
void Attack::GetRealtimeAttackBeats( const Song *pSong, const PlayerState* pPlayerState, float &fStartBeat, float &fEndBeat ) const
|
||||
{
|
||||
ASSERT( pSong != NULL );
|
||||
ASSERT( pSong != nullptr );
|
||||
|
||||
if( fStartSecond >= 0 )
|
||||
{
|
||||
@@ -30,7 +30,7 @@ void Attack::GetRealtimeAttackBeats( const Song *pSong, const PlayerState* pPlay
|
||||
return;
|
||||
}
|
||||
|
||||
ASSERT( pPlayerState != NULL );
|
||||
ASSERT( pPlayerState != nullptr );
|
||||
|
||||
/* 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 );
|
||||
@@ -91,32 +91,27 @@ int Attack::GetNumAttacks() const
|
||||
|
||||
bool AttackArray::ContainsTransformOrTurn() const
|
||||
{
|
||||
FOREACH_CONST( Attack, *this, a )
|
||||
{
|
||||
if( a->ContainsTransformOrTurn() )
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return std::any_of((*this).begin(), (*this).end(), [](Attack const &a) { return a.ContainsTransformOrTurn(); });
|
||||
}
|
||||
|
||||
vector<RString> AttackArray::ToVectorString() const
|
||||
{
|
||||
vector<RString> ret;
|
||||
FOREACH_CONST( Attack, *this, a )
|
||||
for (Attack const &a : *this)
|
||||
{
|
||||
ret.push_back(ssprintf("TIME=%f:LEN=%f:MODS=%s",
|
||||
a->fStartSecond,
|
||||
a->fSecsRemaining,
|
||||
a->sModifiers.c_str()));
|
||||
a.fStartSecond,
|
||||
a.fSecsRemaining,
|
||||
a.sModifiers.c_str()));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
void AttackArray::UpdateStartTimes(float delta)
|
||||
{
|
||||
FOREACH(Attack, *this, a)
|
||||
for (Attack &a : *this)
|
||||
{
|
||||
a->fStartSecond += delta;
|
||||
a.fStartSecond += delta;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+138
-138
@@ -1,138 +1,138 @@
|
||||
#include "global.h"
|
||||
#include "AttackDisplay.h"
|
||||
#include "ThemeManager.h"
|
||||
#include "GameState.h"
|
||||
#include "ActorUtil.h"
|
||||
#include "Character.h"
|
||||
#include "RageLog.h"
|
||||
#include <set>
|
||||
#include "PlayerState.h"
|
||||
|
||||
|
||||
RString GetAttackPieceName( const RString &sAttack )
|
||||
{
|
||||
RString ret = ssprintf( "attack %s", sAttack.c_str() );
|
||||
|
||||
/* 1.5x -> 1_5x. If we pass a period to THEME->GetPathTo, it'll think
|
||||
* we're looking for a specific file and not search. */
|
||||
ret.Replace( ".", "_" );
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
AttackDisplay::AttackDisplay()
|
||||
{
|
||||
if( GAMESTATE->m_PlayMode != PLAY_MODE_BATTLE &&
|
||||
GAMESTATE->m_PlayMode != PLAY_MODE_RAVE )
|
||||
return;
|
||||
|
||||
m_sprAttack.SetDiffuseAlpha( 0 ); // invisible
|
||||
this->AddChild( &m_sprAttack );
|
||||
}
|
||||
|
||||
void AttackDisplay::Init( const PlayerState* pPlayerState )
|
||||
{
|
||||
m_pPlayerState = pPlayerState;
|
||||
|
||||
// TODO: Remove use of PlayerNumber.
|
||||
PlayerNumber pn = m_pPlayerState->m_PlayerNumber;
|
||||
m_sprAttack.SetName( ssprintf("TextP%d",pn+1) );
|
||||
|
||||
if( GAMESTATE->m_PlayMode != PLAY_MODE_BATTLE &&
|
||||
GAMESTATE->m_PlayMode != PLAY_MODE_RAVE )
|
||||
return;
|
||||
|
||||
set<RString> attacks;
|
||||
for( int al=0; al<NUM_ATTACK_LEVELS; al++ )
|
||||
{
|
||||
const Character *ch = GAMESTATE->m_pCurCharacters[pn];
|
||||
ASSERT( ch != NULL );
|
||||
const RString* asAttacks = ch->m_sAttacks[al];
|
||||
for( int att = 0; att < NUM_ATTACKS_PER_LEVEL; ++att )
|
||||
attacks.insert( asAttacks[att] );
|
||||
}
|
||||
|
||||
for( set<RString>::const_iterator it = attacks.begin(); it != attacks.end(); ++it )
|
||||
{
|
||||
const RString path = THEME->GetPathG( "AttackDisplay", GetAttackPieceName( *it ), true );
|
||||
if( path == "" )
|
||||
{
|
||||
LOG->Trace( "Couldn't find \"%s\"", GetAttackPieceName( *it ).c_str() );
|
||||
continue;
|
||||
}
|
||||
|
||||
m_TexturePreload.Load( path );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void AttackDisplay::Update( float fDelta )
|
||||
{
|
||||
ActorFrame::Update( fDelta );
|
||||
|
||||
if( GAMESTATE->m_PlayMode != PLAY_MODE_BATTLE &&
|
||||
GAMESTATE->m_PlayMode != PLAY_MODE_RAVE )
|
||||
return;
|
||||
|
||||
if( !m_pPlayerState->m_bAttackBeganThisUpdate )
|
||||
return;
|
||||
// don't handle this again
|
||||
|
||||
for( unsigned s=0; s<m_pPlayerState->m_ActiveAttacks.size(); s++ )
|
||||
{
|
||||
const Attack& attack = m_pPlayerState->m_ActiveAttacks[s];
|
||||
|
||||
if( attack.fStartSecond >= 0 )
|
||||
continue; /* hasn't started yet */
|
||||
|
||||
if( attack.fSecsRemaining <= 0 )
|
||||
continue; /* ended already */
|
||||
|
||||
if( attack.IsBlank() )
|
||||
continue;
|
||||
|
||||
SetAttack( attack.sModifiers );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void AttackDisplay::SetAttack( const RString &sText )
|
||||
{
|
||||
const RString path = THEME->GetPathG( "AttackDisplay", GetAttackPieceName(sText), true );
|
||||
if( path == "" )
|
||||
return;
|
||||
|
||||
m_sprAttack.SetDiffuseAlpha( 1 );
|
||||
m_sprAttack.Load( path );
|
||||
|
||||
// TODO: Remove use of PlayerNumber.
|
||||
PlayerNumber pn = m_pPlayerState->m_PlayerNumber;
|
||||
|
||||
const RString sName = ssprintf( "%sP%i", sText.c_str(), pn+1 );
|
||||
m_sprAttack.RunCommands( THEME->GetMetricA("AttackDisplay", sName + "OnCommand") );
|
||||
}
|
||||
|
||||
/*
|
||||
* (c) 2003 Chris Danford
|
||||
* All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* 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.
|
||||
*/
|
||||
#include "global.h"
|
||||
#include "AttackDisplay.h"
|
||||
#include "ThemeManager.h"
|
||||
#include "GameState.h"
|
||||
#include "ActorUtil.h"
|
||||
#include "Character.h"
|
||||
#include "RageLog.h"
|
||||
#include <set>
|
||||
#include "PlayerState.h"
|
||||
|
||||
|
||||
RString GetAttackPieceName( const RString &sAttack )
|
||||
{
|
||||
RString ret = ssprintf( "attack %s", sAttack.c_str() );
|
||||
|
||||
/* 1.5x -> 1_5x. If we pass a period to THEME->GetPathTo, it'll think
|
||||
* we're looking for a specific file and not search. */
|
||||
ret.Replace( ".", "_" );
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
AttackDisplay::AttackDisplay()
|
||||
{
|
||||
if( GAMESTATE->m_PlayMode != PLAY_MODE_BATTLE &&
|
||||
GAMESTATE->m_PlayMode != PLAY_MODE_RAVE )
|
||||
return;
|
||||
|
||||
m_sprAttack.SetDiffuseAlpha( 0 ); // invisible
|
||||
this->AddChild( &m_sprAttack );
|
||||
}
|
||||
|
||||
void AttackDisplay::Init( const PlayerState* pPlayerState )
|
||||
{
|
||||
m_pPlayerState = pPlayerState;
|
||||
|
||||
// TODO: Remove use of PlayerNumber.
|
||||
PlayerNumber pn = m_pPlayerState->m_PlayerNumber;
|
||||
m_sprAttack.SetName( ssprintf("TextP%d",pn+1) );
|
||||
|
||||
if( GAMESTATE->m_PlayMode != PLAY_MODE_BATTLE &&
|
||||
GAMESTATE->m_PlayMode != PLAY_MODE_RAVE )
|
||||
return;
|
||||
|
||||
set<RString> attacks;
|
||||
for( int al=0; al<NUM_ATTACK_LEVELS; al++ )
|
||||
{
|
||||
const Character *ch = GAMESTATE->m_pCurCharacters[pn];
|
||||
ASSERT( ch != nullptr );
|
||||
const RString* asAttacks = ch->m_sAttacks[al];
|
||||
for( int att = 0; att < NUM_ATTACKS_PER_LEVEL; ++att )
|
||||
attacks.insert( asAttacks[att] );
|
||||
}
|
||||
|
||||
for( set<RString>::const_iterator it = attacks.begin(); it != attacks.end(); ++it )
|
||||
{
|
||||
const RString path = THEME->GetPathG( "AttackDisplay", GetAttackPieceName( *it ), true );
|
||||
if( path == "" )
|
||||
{
|
||||
LOG->Trace( "Couldn't find \"%s\"", GetAttackPieceName( *it ).c_str() );
|
||||
continue;
|
||||
}
|
||||
|
||||
m_TexturePreload.Load( path );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void AttackDisplay::Update( float fDelta )
|
||||
{
|
||||
ActorFrame::Update( fDelta );
|
||||
|
||||
if( GAMESTATE->m_PlayMode != PLAY_MODE_BATTLE &&
|
||||
GAMESTATE->m_PlayMode != PLAY_MODE_RAVE )
|
||||
return;
|
||||
|
||||
if( !m_pPlayerState->m_bAttackBeganThisUpdate )
|
||||
return;
|
||||
// don't handle this again
|
||||
|
||||
for( unsigned s=0; s<m_pPlayerState->m_ActiveAttacks.size(); s++ )
|
||||
{
|
||||
const Attack& attack = m_pPlayerState->m_ActiveAttacks[s];
|
||||
|
||||
if( attack.fStartSecond >= 0 )
|
||||
continue; /* hasn't started yet */
|
||||
|
||||
if( attack.fSecsRemaining <= 0 )
|
||||
continue; /* ended already */
|
||||
|
||||
if( attack.IsBlank() )
|
||||
continue;
|
||||
|
||||
SetAttack( attack.sModifiers );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void AttackDisplay::SetAttack( const RString &sText )
|
||||
{
|
||||
const RString path = THEME->GetPathG( "AttackDisplay", GetAttackPieceName(sText), true );
|
||||
if( path == "" )
|
||||
return;
|
||||
|
||||
m_sprAttack.SetDiffuseAlpha( 1 );
|
||||
m_sprAttack.Load( path );
|
||||
|
||||
// TODO: Remove use of PlayerNumber.
|
||||
PlayerNumber pn = m_pPlayerState->m_PlayerNumber;
|
||||
|
||||
const RString sName = ssprintf( "%sP%i", sText.c_str(), pn+1 );
|
||||
m_sprAttack.RunCommands( THEME->GetMetricA("AttackDisplay", sName + "OnCommand") );
|
||||
}
|
||||
|
||||
/*
|
||||
* (c) 2003 Chris Danford
|
||||
* All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* 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.
|
||||
*/
|
||||
|
||||
+8
-8
@@ -6,17 +6,17 @@
|
||||
|
||||
void AutoActor::Unload()
|
||||
{
|
||||
if(m_pActor != NULL)
|
||||
if(m_pActor != nullptr)
|
||||
{
|
||||
delete m_pActor;
|
||||
}
|
||||
m_pActor=NULL;
|
||||
m_pActor=nullptr;
|
||||
}
|
||||
|
||||
AutoActor::AutoActor( const AutoActor &cpy )
|
||||
{
|
||||
if( cpy.m_pActor == NULL )
|
||||
m_pActor = NULL;
|
||||
if( cpy.m_pActor == nullptr )
|
||||
m_pActor = nullptr;
|
||||
else
|
||||
m_pActor = cpy.m_pActor->Copy();
|
||||
}
|
||||
@@ -25,8 +25,8 @@ AutoActor &AutoActor::operator=( const AutoActor &cpy )
|
||||
{
|
||||
Unload();
|
||||
|
||||
if( cpy.m_pActor == NULL )
|
||||
m_pActor = NULL;
|
||||
if( cpy.m_pActor == nullptr )
|
||||
m_pActor = nullptr;
|
||||
else
|
||||
m_pActor = cpy.m_pActor->Copy();
|
||||
return *this;
|
||||
@@ -43,8 +43,8 @@ void AutoActor::Load( const RString &sPath )
|
||||
Unload();
|
||||
m_pActor = ActorUtil::MakeActor( sPath );
|
||||
|
||||
// If a Condition is false, MakeActor will return NULL.
|
||||
if( m_pActor == NULL )
|
||||
// If a Condition is false, MakeActor will return nullptr.
|
||||
if( m_pActor == nullptr )
|
||||
m_pActor = new Actor;
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -12,7 +12,7 @@ class XNode;
|
||||
class AutoActor
|
||||
{
|
||||
public:
|
||||
AutoActor(): m_pActor(NULL) {}
|
||||
AutoActor(): m_pActor(nullptr) {}
|
||||
~AutoActor() { Unload(); }
|
||||
AutoActor( const AutoActor &cpy );
|
||||
AutoActor &operator =( const AutoActor &cpy );
|
||||
@@ -24,7 +24,7 @@ public:
|
||||
/**
|
||||
* @brief Determine if this actor is presently loaded.
|
||||
* @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( const RString &sPath );
|
||||
void LoadB( const RString &sMetricsGroup, const RString &sElement ); // load a background and set up LuaThreadVariables for recursive loading
|
||||
|
||||
+13
-13
@@ -30,7 +30,7 @@
|
||||
#include "RageSoundManager.h"
|
||||
#include "RageLog.h"
|
||||
#include "RageSoundReader_FileReader.h"
|
||||
#include "Foreach.h"
|
||||
|
||||
|
||||
void AutoKeysounds::Load( PlayerNumber pn, const NoteData& ndAutoKeysoundsOnly )
|
||||
{
|
||||
@@ -107,9 +107,9 @@ void AutoKeysounds::LoadTracks( const Song *pSong, RageSoundReader *&pShared, Ra
|
||||
// two-track sound.
|
||||
//bool bTwoPlayers = GAMESTATE->GetNumPlayersEnabled() == 2;
|
||||
|
||||
pPlayer1 = NULL;
|
||||
pPlayer2 = NULL;
|
||||
pShared = NULL;
|
||||
pPlayer1 = nullptr;
|
||||
pPlayer2 = nullptr;
|
||||
pShared = nullptr;
|
||||
|
||||
vector<RString> vsMusicFile;
|
||||
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;
|
||||
FOREACH( RString, vsMusicFile, s )
|
||||
for (RString const &s : vsMusicFile)
|
||||
{
|
||||
RString sError;
|
||||
RageSoundReader *pSongReader = RageSoundReader_FileReader::OpenFile( *s, sError );
|
||||
RageSoundReader *pSongReader = RageSoundReader_FileReader::OpenFile( s, sError );
|
||||
vpSounds.push_back( pSongReader );
|
||||
}
|
||||
|
||||
@@ -147,8 +147,8 @@ void AutoKeysounds::LoadTracks( const Song *pSong, RageSoundReader *&pShared, Ra
|
||||
{
|
||||
RageSoundReader_Merge *pMerge = new RageSoundReader_Merge;
|
||||
|
||||
FOREACH( RageSoundReader *, vpSounds, so )
|
||||
pMerge->AddSound( *so );
|
||||
for (RageSoundReader *so : vpSounds)
|
||||
pMerge->AddSound( so );
|
||||
pMerge->Finish( SOUNDMAN->GetDriverSampleRate() );
|
||||
|
||||
RageSoundReader *pSongReader = pMerge;
|
||||
@@ -263,14 +263,14 @@ void AutoKeysounds::FinishLoading()
|
||||
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_PostBuffering( m_pSharedSound );
|
||||
m_pSharedSound = new RageSoundReader_Pan( 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_PostBuffering( m_pPlayerSounds[0] );
|
||||
@@ -278,7 +278,7 @@ void AutoKeysounds::FinishLoading()
|
||||
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_PostBuffering( m_pPlayerSounds[1] );
|
||||
@@ -293,8 +293,8 @@ void AutoKeysounds::FinishLoading()
|
||||
{
|
||||
RageSoundReader_Merge *pMerge = new RageSoundReader_Merge;
|
||||
|
||||
FOREACH( RageSoundReader *, apSounds, ps )
|
||||
pMerge->AddSound( *ps );
|
||||
for (RageSoundReader *ps : apSounds)
|
||||
pMerge->AddSound( ps );
|
||||
|
||||
pMerge->Finish( SOUNDMAN->GetDriverSampleRate() );
|
||||
|
||||
|
||||
+1
-1
@@ -18,7 +18,7 @@ public:
|
||||
void FinishLoading();
|
||||
RageSound *GetSound() { return &m_sSound; }
|
||||
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:
|
||||
void LoadAutoplaySoundsInto( RageSoundReader_Chain *pChain );
|
||||
|
||||
+203
-204
@@ -1,204 +1,203 @@
|
||||
#include "global.h"
|
||||
#include "BGAnimation.h"
|
||||
#include "IniFile.h"
|
||||
#include "BGAnimationLayer.h"
|
||||
#include "RageUtil.h"
|
||||
#include "ActorUtil.h"
|
||||
#include "Foreach.h"
|
||||
#include "LuaManager.h"
|
||||
#include "PrefsManager.h"
|
||||
|
||||
REGISTER_ACTOR_CLASS(BGAnimation);
|
||||
|
||||
BGAnimation::BGAnimation()
|
||||
{
|
||||
}
|
||||
|
||||
BGAnimation::~BGAnimation()
|
||||
{
|
||||
DeleteAllChildren();
|
||||
}
|
||||
|
||||
static bool CompareLayerNames( const RString& s1, const RString& s2 )
|
||||
{
|
||||
int i1, i2;
|
||||
int ret;
|
||||
|
||||
ret = sscanf( s1, "Layer%d", &i1 );
|
||||
ASSERT( ret == 1 );
|
||||
ret = sscanf( s2, "Layer%d", &i2 );
|
||||
ASSERT( ret == 1 );
|
||||
return i1 < i2;
|
||||
}
|
||||
|
||||
void BGAnimation::AddLayersFromAniDir( const RString &_sAniDir, const XNode *pNode )
|
||||
{
|
||||
const RString& sAniDir = _sAniDir;
|
||||
|
||||
{
|
||||
vector<RString> vsLayerNames;
|
||||
FOREACH_CONST_Child( pNode, pLayer )
|
||||
{
|
||||
if( strncmp(pLayer->GetName(), "Layer", 5) == 0 )
|
||||
vsLayerNames.push_back( pLayer->GetName() );
|
||||
}
|
||||
|
||||
sort( vsLayerNames.begin(), vsLayerNames.end(), CompareLayerNames );
|
||||
|
||||
|
||||
FOREACH_CONST( RString, vsLayerNames, s )
|
||||
{
|
||||
const RString &sLayer = *s;
|
||||
const XNode* pKey = pNode->GetChild( sLayer );
|
||||
ASSERT( pKey != NULL );
|
||||
|
||||
RString sImportDir;
|
||||
if( pKey->GetAttrValue("Import", sImportDir) )
|
||||
{
|
||||
bool bCond;
|
||||
if( pKey->GetAttrValue("Condition",bCond) && !bCond )
|
||||
continue;
|
||||
|
||||
// import a whole BGAnimation
|
||||
sImportDir = sAniDir + sImportDir;
|
||||
CollapsePath( sImportDir );
|
||||
|
||||
if( sImportDir.Right(1) != "/" )
|
||||
sImportDir += "/";
|
||||
|
||||
ASSERT_M( IsADirectory(sImportDir), sImportDir + " isn't a directory" );
|
||||
|
||||
RString sPathToIni = sImportDir + "BGAnimation.ini";
|
||||
|
||||
IniFile ini2;
|
||||
ini2.ReadFile( sPathToIni );
|
||||
|
||||
AddLayersFromAniDir( sImportDir, &ini2 );
|
||||
}
|
||||
else
|
||||
{
|
||||
// import as a single layer
|
||||
BGAnimationLayer* bgLayer = new BGAnimationLayer;
|
||||
bgLayer->LoadFromNode( pKey );
|
||||
this->AddChild( bgLayer );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void BGAnimation::LoadFromAniDir( const RString &_sAniDir )
|
||||
{
|
||||
DeleteAllChildren();
|
||||
|
||||
if( _sAniDir.empty() )
|
||||
return;
|
||||
|
||||
RString sAniDir = _sAniDir;
|
||||
if( sAniDir.Right(1) != "/" )
|
||||
sAniDir += "/";
|
||||
|
||||
ASSERT_M( IsADirectory(sAniDir), sAniDir + " isn't a directory" );
|
||||
|
||||
RString sPathToIni = sAniDir + "BGAnimation.ini";
|
||||
|
||||
if( DoesFileExist(sPathToIni) )
|
||||
{
|
||||
if( PREFSMAN->m_bQuirksMode )
|
||||
{
|
||||
// This is a 3.9-style BGAnimation (using .ini)
|
||||
IniFile ini;
|
||||
ini.ReadFile( sPathToIni );
|
||||
|
||||
AddLayersFromAniDir( sAniDir, &ini ); // TODO: Check for circular load
|
||||
|
||||
XNode* pBGAnimation = ini.GetChild( "BGAnimation" );
|
||||
XNode dummy( "BGAnimation" );
|
||||
if( pBGAnimation == NULL )
|
||||
pBGAnimation = &dummy;
|
||||
|
||||
LoadFromNode( pBGAnimation );
|
||||
}
|
||||
else // We don't officially support .ini files anymore.
|
||||
{
|
||||
XNode dummy( "BGAnimation" );
|
||||
XNode *pBG = &dummy;
|
||||
LoadFromNode( pBG );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// This is an 3.0 and before-style BGAnimation (not using .ini)
|
||||
|
||||
// loading a directory of layers
|
||||
vector<RString> asImagePaths;
|
||||
ASSERT( sAniDir != "" );
|
||||
|
||||
GetDirListing( sAniDir+"*.png", asImagePaths, false, true );
|
||||
GetDirListing( sAniDir+"*.jpg", asImagePaths, false, true );
|
||||
GetDirListing( sAniDir+"*.jpeg", asImagePaths, false, true );
|
||||
GetDirListing( sAniDir+"*.gif", asImagePaths, false, true );
|
||||
GetDirListing( sAniDir+"*.ogv", asImagePaths, false, true );
|
||||
GetDirListing( sAniDir+"*.avi", asImagePaths, false, true );
|
||||
GetDirListing( sAniDir+"*.mpg", asImagePaths, false, true );
|
||||
GetDirListing( sAniDir+"*.mpeg", asImagePaths, false, true );
|
||||
|
||||
SortRStringArray( asImagePaths );
|
||||
|
||||
for( unsigned i=0; i<asImagePaths.size(); i++ )
|
||||
{
|
||||
const RString sPath = asImagePaths[i];
|
||||
if( Basename(sPath).Left(1) == "_" )
|
||||
continue; // don't directly load files starting with an underscore
|
||||
BGAnimationLayer* pLayer = new BGAnimationLayer;
|
||||
pLayer->LoadFromAniLayerFile( asImagePaths[i] );
|
||||
AddChild( pLayer );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void BGAnimation::LoadFromNode( const XNode* pNode )
|
||||
{
|
||||
RString sDir;
|
||||
if( pNode->GetAttrValue("AniDir", sDir) )
|
||||
LoadFromAniDir( sDir );
|
||||
|
||||
ActorFrame::LoadFromNode( pNode );
|
||||
|
||||
/* Backwards-compatibility: if a "LengthSeconds" value is present, create a dummy
|
||||
* actor that sleeps for the given length of time. This will extend GetTweenTimeLeft. */
|
||||
float fLengthSeconds = 0;
|
||||
if( pNode->GetAttrValue( "LengthSeconds", fLengthSeconds ) )
|
||||
{
|
||||
Actor *pActor = new Actor;
|
||||
pActor->SetName( "BGAnimation dummy" );
|
||||
pActor->SetVisible( false );
|
||||
apActorCommands ap = ActorUtil::ParseActorCommands( ssprintf("sleep,%f",fLengthSeconds) );
|
||||
pActor->AddCommand( "On", ap );
|
||||
AddChild( pActor );
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* (c) 2001-2004 Ben Nordstrom, Chris Danford
|
||||
* All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* 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.
|
||||
*/
|
||||
#include "global.h"
|
||||
#include "BGAnimation.h"
|
||||
#include "IniFile.h"
|
||||
#include "BGAnimationLayer.h"
|
||||
#include "RageUtil.h"
|
||||
#include "ActorUtil.h"
|
||||
|
||||
#include "LuaManager.h"
|
||||
#include "PrefsManager.h"
|
||||
|
||||
REGISTER_ACTOR_CLASS(BGAnimation);
|
||||
|
||||
BGAnimation::BGAnimation()
|
||||
{
|
||||
}
|
||||
|
||||
BGAnimation::~BGAnimation()
|
||||
{
|
||||
DeleteAllChildren();
|
||||
}
|
||||
|
||||
static bool CompareLayerNames( const RString& s1, const RString& s2 )
|
||||
{
|
||||
int i1, i2;
|
||||
int ret;
|
||||
|
||||
ret = sscanf( s1, "Layer%d", &i1 );
|
||||
ASSERT( ret == 1 );
|
||||
ret = sscanf( s2, "Layer%d", &i2 );
|
||||
ASSERT( ret == 1 );
|
||||
return i1 < i2;
|
||||
}
|
||||
|
||||
void BGAnimation::AddLayersFromAniDir( const RString &_sAniDir, const XNode *pNode )
|
||||
{
|
||||
const RString& sAniDir = _sAniDir;
|
||||
|
||||
{
|
||||
vector<RString> vsLayerNames;
|
||||
FOREACH_CONST_Child( pNode, pLayer )
|
||||
{
|
||||
if( strncmp(pLayer->GetName(), "Layer", 5) == 0 )
|
||||
vsLayerNames.push_back( pLayer->GetName() );
|
||||
}
|
||||
|
||||
sort( vsLayerNames.begin(), vsLayerNames.end(), CompareLayerNames );
|
||||
|
||||
|
||||
for (RString const &sLayer : vsLayerNames)
|
||||
{
|
||||
const XNode* pKey = pNode->GetChild( sLayer );
|
||||
ASSERT( pKey != nullptr );
|
||||
|
||||
RString sImportDir;
|
||||
if( pKey->GetAttrValue("Import", sImportDir) )
|
||||
{
|
||||
bool bCond;
|
||||
if( pKey->GetAttrValue("Condition",bCond) && !bCond )
|
||||
continue;
|
||||
|
||||
// import a whole BGAnimation
|
||||
sImportDir = sAniDir + sImportDir;
|
||||
CollapsePath( sImportDir );
|
||||
|
||||
if( sImportDir.Right(1) != "/" )
|
||||
sImportDir += "/";
|
||||
|
||||
ASSERT_M( IsADirectory(sImportDir), sImportDir + " isn't a directory" );
|
||||
|
||||
RString sPathToIni = sImportDir + "BGAnimation.ini";
|
||||
|
||||
IniFile ini2;
|
||||
ini2.ReadFile( sPathToIni );
|
||||
|
||||
AddLayersFromAniDir( sImportDir, &ini2 );
|
||||
}
|
||||
else
|
||||
{
|
||||
// import as a single layer
|
||||
BGAnimationLayer* bgLayer = new BGAnimationLayer;
|
||||
bgLayer->LoadFromNode( pKey );
|
||||
this->AddChild( bgLayer );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void BGAnimation::LoadFromAniDir( const RString &_sAniDir )
|
||||
{
|
||||
DeleteAllChildren();
|
||||
|
||||
if( _sAniDir.empty() )
|
||||
return;
|
||||
|
||||
RString sAniDir = _sAniDir;
|
||||
if( sAniDir.Right(1) != "/" )
|
||||
sAniDir += "/";
|
||||
|
||||
ASSERT_M( IsADirectory(sAniDir), sAniDir + " isn't a directory" );
|
||||
|
||||
RString sPathToIni = sAniDir + "BGAnimation.ini";
|
||||
|
||||
if( DoesFileExist(sPathToIni) )
|
||||
{
|
||||
if( PREFSMAN->m_bQuirksMode )
|
||||
{
|
||||
// This is a 3.9-style BGAnimation (using .ini)
|
||||
IniFile ini;
|
||||
ini.ReadFile( sPathToIni );
|
||||
|
||||
AddLayersFromAniDir( sAniDir, &ini ); // TODO: Check for circular load
|
||||
|
||||
XNode* pBGAnimation = ini.GetChild( "BGAnimation" );
|
||||
XNode dummy( "BGAnimation" );
|
||||
if( pBGAnimation == nullptr )
|
||||
pBGAnimation = &dummy;
|
||||
|
||||
LoadFromNode( pBGAnimation );
|
||||
}
|
||||
else // We don't officially support .ini files anymore.
|
||||
{
|
||||
XNode dummy( "BGAnimation" );
|
||||
XNode *pBG = &dummy;
|
||||
LoadFromNode( pBG );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// This is an 3.0 and before-style BGAnimation (not using .ini)
|
||||
|
||||
// loading a directory of layers
|
||||
vector<RString> asImagePaths;
|
||||
ASSERT( sAniDir != "" );
|
||||
|
||||
GetDirListing( sAniDir+"*.png", asImagePaths, false, true );
|
||||
GetDirListing( sAniDir+"*.jpg", asImagePaths, false, true );
|
||||
GetDirListing( sAniDir+"*.jpeg", asImagePaths, false, true );
|
||||
GetDirListing( sAniDir+"*.gif", asImagePaths, false, true );
|
||||
GetDirListing( sAniDir+"*.ogv", asImagePaths, false, true );
|
||||
GetDirListing( sAniDir+"*.avi", asImagePaths, false, true );
|
||||
GetDirListing( sAniDir+"*.mpg", asImagePaths, false, true );
|
||||
GetDirListing( sAniDir+"*.mpeg", asImagePaths, false, true );
|
||||
|
||||
SortRStringArray( asImagePaths );
|
||||
|
||||
for( unsigned i=0; i<asImagePaths.size(); i++ )
|
||||
{
|
||||
const RString sPath = asImagePaths[i];
|
||||
if( Basename(sPath).Left(1) == "_" )
|
||||
continue; // don't directly load files starting with an underscore
|
||||
BGAnimationLayer* pLayer = new BGAnimationLayer;
|
||||
pLayer->LoadFromAniLayerFile( asImagePaths[i] );
|
||||
AddChild( pLayer );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void BGAnimation::LoadFromNode( const XNode* pNode )
|
||||
{
|
||||
RString sDir;
|
||||
if( pNode->GetAttrValue("AniDir", sDir) )
|
||||
LoadFromAniDir( sDir );
|
||||
|
||||
ActorFrame::LoadFromNode( pNode );
|
||||
|
||||
/* Backwards-compatibility: if a "LengthSeconds" value is present, create a dummy
|
||||
* actor that sleeps for the given length of time. This will extend GetTweenTimeLeft. */
|
||||
float fLengthSeconds = 0;
|
||||
if( pNode->GetAttrValue( "LengthSeconds", fLengthSeconds ) )
|
||||
{
|
||||
Actor *pActor = new Actor;
|
||||
pActor->SetName( "BGAnimation dummy" );
|
||||
pActor->SetVisible( false );
|
||||
apActorCommands ap = ActorUtil::ParseActorCommands( ssprintf("sleep,%f",fLengthSeconds) );
|
||||
pActor->AddCommand( "On", ap );
|
||||
AddChild( pActor );
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* (c) 2001-2004 Ben Nordstrom, Chris Danford
|
||||
* All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* 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.
|
||||
*/
|
||||
|
||||
@@ -402,16 +402,16 @@ void BGAnimationLayer::LoadFromNode( const XNode* pNode )
|
||||
{
|
||||
m_Type = TYPE_TILES;
|
||||
}
|
||||
else if( StringToInt(type) == 1 )
|
||||
else if( std::stoi(type) == 1 )
|
||||
{
|
||||
m_Type = TYPE_SPRITE;
|
||||
bStretch = true;
|
||||
}
|
||||
else if( StringToInt(type) == 2 )
|
||||
else if( std::stoi(type) == 2 )
|
||||
{
|
||||
m_Type = TYPE_PARTICLES;
|
||||
}
|
||||
else if( StringToInt(type) == 3 )
|
||||
else if( std::stoi(type) == 3 )
|
||||
{
|
||||
m_Type = TYPE_TILES;
|
||||
}
|
||||
@@ -482,7 +482,7 @@ void BGAnimationLayer::LoadFromNode( const XNode* pNode )
|
||||
for( int i=0; i<iNumParticles; i++ )
|
||||
{
|
||||
Actor* pActor = ActorUtil::MakeActor( sFile, this );
|
||||
if( pActor == NULL )
|
||||
if( pActor == nullptr )
|
||||
continue;
|
||||
this->AddChild( pActor );
|
||||
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++ )
|
||||
{
|
||||
Actor* pSprite = ActorUtil::MakeActor( sFile, this );
|
||||
if( pSprite == NULL )
|
||||
if( pSprite == nullptr )
|
||||
continue;
|
||||
this->AddChild( pSprite );
|
||||
pSprite->SetTextureWrapping( true ); // gets rid of some "cracks"
|
||||
|
||||
+6
-6
@@ -179,7 +179,7 @@ void BPMDisplay::NoBPM()
|
||||
|
||||
void BPMDisplay::SetBpmFromSong( const Song* pSong )
|
||||
{
|
||||
ASSERT( pSong != NULL );
|
||||
ASSERT( pSong != nullptr );
|
||||
switch( pSong->m_DisplayBPMType )
|
||||
{
|
||||
case DISPLAY_BPM_ACTUAL:
|
||||
@@ -201,7 +201,7 @@ void BPMDisplay::SetBpmFromSong( const Song* pSong )
|
||||
|
||||
void BPMDisplay::SetBpmFromSteps( const Steps* pSteps )
|
||||
{
|
||||
ASSERT( pSteps != NULL );
|
||||
ASSERT( pSteps != nullptr );
|
||||
DisplayBpms bpms;
|
||||
float fMinBPM, fMaxBPM;
|
||||
pSteps->GetTimingData()->GetActualBPM( fMinBPM, fMaxBPM );
|
||||
@@ -212,13 +212,13 @@ void BPMDisplay::SetBpmFromSteps( const Steps* pSteps )
|
||||
|
||||
void BPMDisplay::SetBpmFromCourse( const Course* pCourse )
|
||||
{
|
||||
ASSERT( pCourse != NULL );
|
||||
ASSERT( GAMESTATE->GetCurrentStyle(PLAYER_INVALID) != NULL );
|
||||
ASSERT( pCourse != nullptr );
|
||||
ASSERT( GAMESTATE->GetCurrentStyle(PLAYER_INVALID) != nullptr );
|
||||
|
||||
StepsType st = GAMESTATE->GetCurrentStyle(PLAYER_INVALID)->m_StepsType;
|
||||
Trail *pTrail = pCourse->GetTrail( st );
|
||||
// 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;
|
||||
|
||||
@@ -259,7 +259,7 @@ void BPMDisplay::SetFromGameState()
|
||||
}
|
||||
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.
|
||||
else
|
||||
SetBpmFromCourse( GAMESTATE->m_pCurCourse );
|
||||
|
||||
+18
-18
@@ -151,15 +151,15 @@ static RageColor GetBrightnessColor( float fBrightnessPercent )
|
||||
BackgroundImpl::BackgroundImpl()
|
||||
{
|
||||
m_bInitted = false;
|
||||
m_pDancingCharacters = NULL;
|
||||
m_pSong = NULL;
|
||||
m_pDancingCharacters = nullptr;
|
||||
m_pSong = nullptr;
|
||||
}
|
||||
|
||||
BackgroundImpl::Layer::Layer()
|
||||
{
|
||||
m_iCurBGChangeIndex = -1;
|
||||
m_pCurrentBGA = NULL;
|
||||
m_pFadingBGA = NULL;
|
||||
m_pCurrentBGA = nullptr;
|
||||
m_pFadingBGA = nullptr;
|
||||
}
|
||||
|
||||
void BackgroundImpl::Init()
|
||||
@@ -246,20 +246,20 @@ void BackgroundImpl::Unload()
|
||||
{
|
||||
FOREACH_BackgroundLayer( i )
|
||||
m_Layer[i].Unload();
|
||||
m_pSong = NULL;
|
||||
m_pSong = nullptr;
|
||||
m_fLastMusicSeconds = -9999;
|
||||
m_RandomBGAnimations.clear();
|
||||
}
|
||||
|
||||
void BackgroundImpl::Layer::Unload()
|
||||
{
|
||||
FOREACHM( BackgroundDef, Actor*, m_BGAnimations, iter )
|
||||
delete iter->second;
|
||||
for (std::pair<BackgroundDef const &, Actor *> iter : m_BGAnimations)
|
||||
delete iter.second;
|
||||
m_BGAnimations.clear();
|
||||
m_aBGChanges.clear();
|
||||
|
||||
m_pCurrentBGA = NULL;
|
||||
m_pFadingBGA = NULL;
|
||||
m_pCurrentBGA = nullptr;
|
||||
m_pFadingBGA = nullptr;
|
||||
m_iCurBGChangeIndex = -1;
|
||||
}
|
||||
|
||||
@@ -386,7 +386,7 @@ bool BackgroundImpl::Layer::CreateBackground( const Song *pSong, const Backgroun
|
||||
|
||||
Actor *pActor = ActorUtil::MakeActor( sEffectFile );
|
||||
|
||||
if( pActor == NULL )
|
||||
if( pActor == nullptr )
|
||||
pActor = new Actor;
|
||||
m_BGAnimations[bd] = pActor;
|
||||
|
||||
@@ -542,10 +542,10 @@ void BackgroundImpl::LoadFromSong( const Song* pSong )
|
||||
int iSize = min( (int)g_iNumBackgrounds, (int)vsNames.size() );
|
||||
vsNames.resize( iSize );
|
||||
|
||||
FOREACH_CONST( RString, vsNames, s )
|
||||
for (RString const &s : vsNames)
|
||||
{
|
||||
BackgroundDef bd;
|
||||
bd.m_sFile1 = *s;
|
||||
bd.m_sFile1 = s;
|
||||
m_RandomBGAnimations.push_back( bd );
|
||||
}
|
||||
}
|
||||
@@ -574,9 +574,9 @@ void BackgroundImpl::LoadFromSong( const Song* pSong )
|
||||
Layer &layer = m_Layer[i];
|
||||
|
||||
// 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;
|
||||
|
||||
bool bIsAlreadyLoaded = layer.m_BGAnimations.find(bd) != layer.m_BGAnimations.end();
|
||||
@@ -643,9 +643,9 @@ void BackgroundImpl::LoadFromSong( const Song* pSong )
|
||||
FOREACH_BackgroundLayer( 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 )
|
||||
{
|
||||
bStaticBackgroundUsed = true;
|
||||
@@ -765,7 +765,7 @@ void BackgroundImpl::Layer::UpdateCurBGChange( const Song *pSong, float fLastMus
|
||||
|
||||
if( m_pFadingBGA == m_pCurrentBGA )
|
||||
{
|
||||
m_pFadingBGA = NULL;
|
||||
m_pFadingBGA = nullptr;
|
||||
//LOG->Trace( "bg didn't actually change. Ignoring." );
|
||||
}
|
||||
else
|
||||
@@ -807,7 +807,7 @@ void BackgroundImpl::Layer::UpdateCurBGChange( const Song *pSong, float fLastMus
|
||||
if( m_pFadingBGA )
|
||||
{
|
||||
if( m_pFadingBGA->GetTweenTimeLeft() == 0 )
|
||||
m_pFadingBGA = NULL;
|
||||
m_pFadingBGA = nullptr;
|
||||
}
|
||||
|
||||
/* This is unaffected by the music rate. */
|
||||
|
||||
+24
-24
@@ -2,7 +2,7 @@
|
||||
#include "BackgroundUtil.h"
|
||||
#include "RageUtil.h"
|
||||
#include "Song.h"
|
||||
#include "Foreach.h"
|
||||
|
||||
#include "IniFile.h"
|
||||
#include "RageLog.h"
|
||||
#include <set>
|
||||
@@ -148,8 +148,8 @@ void BackgroundUtil::GetBackgroundEffects( const RString &_sName, vector<RString
|
||||
GetDirListing( BACKGROUND_EFFECTS_DIR+sName+".lua", vsPathsOut, false, true );
|
||||
|
||||
vsNamesOut.clear();
|
||||
FOREACH_CONST( RString, vsPathsOut, s )
|
||||
vsNamesOut.push_back( GetFileNameWithoutExtension(*s) );
|
||||
for (RString const &s : vsPathsOut)
|
||||
vsNamesOut.push_back( GetFileNameWithoutExtension(s) );
|
||||
|
||||
StripCvsAndSvn( vsPathsOut, vsNamesOut );
|
||||
}
|
||||
@@ -166,8 +166,8 @@ void BackgroundUtil::GetBackgroundTransitions( const RString &_sName, vector<RSt
|
||||
GetDirListing( BACKGROUND_TRANSITIONS_DIR+sName+".lua", vsPathsOut, false, true );
|
||||
|
||||
vsNamesOut.clear();
|
||||
FOREACH_CONST( RString, vsPathsOut, s )
|
||||
vsNamesOut.push_back( GetFileNameWithoutExtension(*s) );
|
||||
for (RString const &s : vsPathsOut)
|
||||
vsNamesOut.push_back( GetFileNameWithoutExtension(s) );
|
||||
|
||||
StripCvsAndSvn( vsPathsOut, vsNamesOut );
|
||||
}
|
||||
@@ -185,8 +185,8 @@ void BackgroundUtil::GetSongBGAnimations( const Song *pSong, const RString &sMat
|
||||
}
|
||||
|
||||
vsNamesOut.clear();
|
||||
FOREACH_CONST( RString, vsPathsOut, s )
|
||||
vsNamesOut.push_back( Basename(*s) );
|
||||
for (RString const &s : vsPathsOut)
|
||||
vsNamesOut.push_back( Basename(s) );
|
||||
|
||||
StripCvsAndSvn( vsPathsOut, vsNamesOut );
|
||||
}
|
||||
@@ -205,8 +205,8 @@ void BackgroundUtil::GetSongMovies( const Song *pSong, const RString &sMatch, ve
|
||||
}
|
||||
|
||||
vsNamesOut.clear();
|
||||
FOREACH_CONST( RString, vsPathsOut, s )
|
||||
vsNamesOut.push_back( Basename(*s) );
|
||||
for (RString const &s : vsPathsOut)
|
||||
vsNamesOut.push_back( Basename(s) );
|
||||
|
||||
StripCvsAndSvn( vsPathsOut, vsNamesOut );
|
||||
}
|
||||
@@ -225,8 +225,8 @@ void BackgroundUtil::GetSongBitmaps( const Song *pSong, const RString &sMatch, v
|
||||
}
|
||||
|
||||
vsNamesOut.clear();
|
||||
FOREACH_CONST( RString, vsPathsOut, s )
|
||||
vsNamesOut.push_back( Basename(*s) );
|
||||
for (RString const &s : vsPathsOut)
|
||||
vsNamesOut.push_back( Basename(s) );
|
||||
|
||||
StripCvsAndSvn( vsPathsOut, vsNamesOut );
|
||||
}
|
||||
@@ -252,7 +252,7 @@ static void GetFilterToFileNames( const RString sBaseDir, const Song *pSong, set
|
||||
}
|
||||
|
||||
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()) );
|
||||
return;
|
||||
@@ -270,8 +270,8 @@ void BackgroundUtil::GetGlobalBGAnimations( const Song *pSong, const RString &sM
|
||||
GetDirListing( BG_ANIMS_DIR+sMatch+"*.xml", vsPathsOut, false, true );
|
||||
|
||||
vsNamesOut.clear();
|
||||
FOREACH_CONST( RString, vsPathsOut, s )
|
||||
vsNamesOut.push_back( Basename(*s) );
|
||||
for (RString const &s : vsPathsOut)
|
||||
vsNamesOut.push_back( Basename(s) );
|
||||
|
||||
StripCvsAndSvn( vsPathsOut, vsNamesOut );
|
||||
}
|
||||
@@ -313,22 +313,22 @@ namespace {
|
||||
}
|
||||
vsDirsToTry.push_back( RANDOMMOVIES_DIR );
|
||||
|
||||
FOREACH_CONST( RString, vsDirsToTry, sDir )
|
||||
for (RString const &sDir : vsDirsToTry)
|
||||
{
|
||||
GetDirListing( *sDir+"*.ogv", vsPathsOut, false, true );
|
||||
GetDirListing( *sDir+"*.avi", vsPathsOut, false, true );
|
||||
GetDirListing( *sDir+"*.mpg", vsPathsOut, false, true );
|
||||
GetDirListing( *sDir+"*.mpeg", vsPathsOut, false, true );
|
||||
GetDirListing( sDir+"*.ogv", vsPathsOut, false, true );
|
||||
GetDirListing( sDir+"*.avi", vsPathsOut, false, true );
|
||||
GetDirListing( sDir+"*.mpg", vsPathsOut, false, true );
|
||||
GetDirListing( sDir+"*.mpeg", vsPathsOut, false, true );
|
||||
|
||||
if( !ssFileNameWhitelist.empty() )
|
||||
{
|
||||
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();
|
||||
if( bFound )
|
||||
vsMatches.push_back(*s);
|
||||
vsMatches.push_back(s);
|
||||
}
|
||||
// If we found any that match the whitelist, use only them.
|
||||
// If none match the whitelist, ignore the whitelist..
|
||||
@@ -359,9 +359,9 @@ void BackgroundUtil::GetGlobalRandomMovies(
|
||||
|
||||
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 );
|
||||
}
|
||||
StripCvsAndSvn( vsPathsOut, vsNamesOut );
|
||||
|
||||
+15
-15
@@ -107,9 +107,9 @@ void Banner::SetScrolling( bool bScroll, float Percent)
|
||||
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 LoadFallback();
|
||||
|
||||
@@ -130,9 +130,9 @@ void Banner::LoadFromSongGroup( RString sSongGroup )
|
||||
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 LoadCourseFallback();
|
||||
|
||||
@@ -141,7 +141,7 @@ void Banner::LoadFromCourse( const Course *pCourse ) // NULL means no course
|
||||
|
||||
void Banner::LoadCardFromCharacter( const Character *pCharacter )
|
||||
{
|
||||
if( pCharacter == NULL ) LoadFallback();
|
||||
if( pCharacter == nullptr ) LoadFallback();
|
||||
else if( pCharacter->GetCardPath() != "" ) Load( pCharacter->GetCardPath() );
|
||||
else LoadFallback();
|
||||
|
||||
@@ -150,7 +150,7 @@ void Banner::LoadCardFromCharacter( 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 LoadFallbackCharacterIcon();
|
||||
|
||||
@@ -159,7 +159,7 @@ void Banner::LoadIconFromCharacter( const Character *pCharacter )
|
||||
|
||||
void Banner::LoadBannerFromUnlockEntry( const UnlockEntry* pUE )
|
||||
{
|
||||
if( pUE == NULL )
|
||||
if( pUE == nullptr )
|
||||
LoadFallback();
|
||||
else
|
||||
{
|
||||
@@ -171,7 +171,7 @@ void Banner::LoadBannerFromUnlockEntry( const UnlockEntry* pUE )
|
||||
|
||||
void Banner::LoadBackgroundFromUnlockEntry( const UnlockEntry* pUE )
|
||||
{
|
||||
if( pUE == NULL )
|
||||
if( pUE == nullptr )
|
||||
LoadFallback();
|
||||
else
|
||||
{
|
||||
@@ -224,7 +224,7 @@ void Banner::LoadRandom()
|
||||
|
||||
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 )
|
||||
{
|
||||
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 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 ); }
|
||||
COMMON_RETURN_SELF;
|
||||
}
|
||||
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 ); }
|
||||
COMMON_RETURN_SELF;
|
||||
}
|
||||
@@ -265,25 +265,25 @@ public:
|
||||
}
|
||||
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 ); }
|
||||
COMMON_RETURN_SELF;
|
||||
}
|
||||
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 ); }
|
||||
COMMON_RETURN_SELF;
|
||||
}
|
||||
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 ); }
|
||||
COMMON_RETURN_SELF;
|
||||
}
|
||||
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 ); }
|
||||
COMMON_RETURN_SELF;
|
||||
}
|
||||
|
||||
+1
-1
@@ -27,7 +27,7 @@ public:
|
||||
|
||||
/**
|
||||
* @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 LoadMode();
|
||||
|
||||
@@ -149,7 +149,7 @@ bool BeginnerHelper::Init( int iDancePadType )
|
||||
|
||||
// Load character data
|
||||
const Character *Character = GAMESTATE->m_pCurCharacters[pl];
|
||||
ASSERT( Character != NULL );
|
||||
ASSERT( Character != nullptr );
|
||||
|
||||
m_pDancer[pl]->SetName( ssprintf("PlayerP%d",pl+1) );
|
||||
|
||||
@@ -204,7 +204,7 @@ void BeginnerHelper::AddPlayer( PlayerNumber pn, const NoteData &ns )
|
||||
return;
|
||||
|
||||
const Character *Character = GAMESTATE->m_pCurCharacters[pn];
|
||||
ASSERT( Character != NULL );
|
||||
ASSERT( Character != nullptr );
|
||||
if( !DoesFileExist(Character->GetModelPath()) )
|
||||
return;
|
||||
|
||||
@@ -219,7 +219,7 @@ bool BeginnerHelper::CanUse(PlayerNumber pn)
|
||||
return false;
|
||||
|
||||
// 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)
|
||||
{
|
||||
return GAMESTATE->GetCurrentStyle(PLAYER_1)->m_bCanUseBeginnerHelper ||
|
||||
|
||||
@@ -29,13 +29,13 @@ public:
|
||||
protected:
|
||||
void Step( PlayerNumber pn, int CSTEP );
|
||||
|
||||
NoteData m_NoteData[NUM_PLAYERS];
|
||||
bool m_bPlayerEnabled[NUM_PLAYERS];
|
||||
Model *m_pDancer[NUM_PLAYERS];
|
||||
std::array<NoteData, NUM_PLAYERS> m_NoteData;
|
||||
std::array<bool, NUM_PLAYERS> m_bPlayerEnabled;
|
||||
std::array<Model *, NUM_PLAYERS> m_pDancer;
|
||||
Model *m_pDancePad;
|
||||
Sprite m_sFlash;
|
||||
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_iLastRowFlashed;
|
||||
|
||||
+13
-13
@@ -9,7 +9,7 @@
|
||||
#include "Font.h"
|
||||
#include "ActorUtil.h"
|
||||
#include "LuaBinding.h"
|
||||
#include "Foreach.h"
|
||||
|
||||
|
||||
REGISTER_ACTOR_CLASS( BitmapText );
|
||||
|
||||
@@ -42,7 +42,7 @@ BitmapText::BitmapText()
|
||||
}
|
||||
iReloadCounter++;
|
||||
|
||||
m_pFont = NULL;
|
||||
m_pFont = nullptr;
|
||||
m_bUppercase = false;
|
||||
|
||||
m_bRainbowScroll = false;
|
||||
@@ -102,10 +102,10 @@ BitmapText & BitmapText::operator=(const BitmapText &cpy)
|
||||
if( m_pFont )
|
||||
FONT->UnloadFont( m_pFont );
|
||||
|
||||
if( cpy.m_pFont != NULL )
|
||||
if( cpy.m_pFont != nullptr )
|
||||
m_pFont = FONT->CopyFont( cpy.m_pFont );
|
||||
else
|
||||
m_pFont = NULL;
|
||||
m_pFont = nullptr;
|
||||
|
||||
return *this;
|
||||
}
|
||||
@@ -113,7 +113,7 @@ BitmapText & BitmapText::operator=(const BitmapText &cpy)
|
||||
BitmapText::BitmapText( const BitmapText &cpy ):
|
||||
Actor( cpy )
|
||||
{
|
||||
m_pFont = NULL;
|
||||
m_pFont = nullptr;
|
||||
|
||||
*this = cpy;
|
||||
}
|
||||
@@ -212,7 +212,7 @@ bool BitmapText::LoadFromFont( const RString& sFontFilePath )
|
||||
if( m_pFont )
|
||||
{
|
||||
FONT->UnloadFont( m_pFont );
|
||||
m_pFont = NULL;
|
||||
m_pFont = nullptr;
|
||||
}
|
||||
|
||||
m_pFont = FONT->LoadFont( sFontFilePath );
|
||||
@@ -231,7 +231,7 @@ bool BitmapText::LoadFromTextureAndChars( const RString& sTexturePath, const RSt
|
||||
if( m_pFont )
|
||||
{
|
||||
FONT->UnloadFont( m_pFont );
|
||||
m_pFont = NULL;
|
||||
m_pFont = nullptr;
|
||||
}
|
||||
|
||||
m_pFont = FONT->LoadFont( sTexturePath, sChars );
|
||||
@@ -244,7 +244,7 @@ bool BitmapText::LoadFromTextureAndChars( const RString& sTexturePath, const RSt
|
||||
void BitmapText::BuildChars()
|
||||
{
|
||||
// If we don't have a font yet, we'll do this when it loads.
|
||||
if( m_pFont == NULL )
|
||||
if( m_pFont == nullptr )
|
||||
return;
|
||||
|
||||
// calculate line lengths and widths
|
||||
@@ -456,7 +456,7 @@ void BitmapText::DrawChars( bool bUseStrokeTexture )
|
||||
* in sAlternateText, too, just use sText. */
|
||||
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;
|
||||
|
||||
@@ -624,7 +624,7 @@ void BitmapText::UpdateBaseZoom()
|
||||
|
||||
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.
|
||||
if( !sAlternateText.size() )
|
||||
@@ -856,7 +856,7 @@ void BitmapText::SetHorizAlign( float f )
|
||||
|
||||
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 )
|
||||
return;
|
||||
m_iWrapWidthPixels = iWrapWidthPixels;
|
||||
@@ -878,9 +878,9 @@ void BitmapText::AddAttribute( size_t iPos, const Attribute &attr )
|
||||
int iLines = 0;
|
||||
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 )
|
||||
break;
|
||||
iAdjustedPos -= length;
|
||||
|
||||
+6
-6
@@ -12,7 +12,7 @@
|
||||
#include "SpecialFiles.h"
|
||||
#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";
|
||||
|
||||
@@ -67,7 +67,7 @@ void Bookkeeper::LoadFromNode( const XNode *pNode )
|
||||
}
|
||||
|
||||
const XNode *pData = pNode->GetChild( "Data" );
|
||||
if( pData == NULL )
|
||||
if( pData == nullptr )
|
||||
{
|
||||
LOG->Warn( "Error loading bookkeeping: Data node missing" );
|
||||
return;
|
||||
@@ -146,14 +146,14 @@ void Bookkeeper::WriteToDisk()
|
||||
return;
|
||||
}
|
||||
|
||||
auto_ptr<XNode> xml( CreateNode() );
|
||||
std::unique_ptr<XNode> xml( CreateNode() );
|
||||
XmlFileUtil::SaveToFile( xml.get(), f );
|
||||
}
|
||||
|
||||
void Bookkeeper::CoinInserted()
|
||||
{
|
||||
Date d;
|
||||
d.Set( time(NULL) );
|
||||
d.Set( time(nullptr) );
|
||||
|
||||
++m_mapCoinsForHour[d];
|
||||
}
|
||||
@@ -199,7 +199,7 @@ int Bookkeeper::GetCoinsTotal() const
|
||||
|
||||
void Bookkeeper::GetCoinsLastDays( int coins[NUM_LAST_DAYS] ) const
|
||||
{
|
||||
time_t lOldTime = time(NULL);
|
||||
time_t lOldTime = time(nullptr);
|
||||
tm 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
|
||||
{
|
||||
time_t lOldTime = time(NULL);
|
||||
time_t lOldTime = time(nullptr);
|
||||
tm time;
|
||||
localtime_r( &lOldTime, &time );
|
||||
|
||||
|
||||
@@ -231,7 +231,6 @@ list(APPEND SM_DATA_REST_HPP
|
||||
"Difficulty.h"
|
||||
"EnumHelper.h"
|
||||
"FileDownload.h"
|
||||
"Foreach.h"
|
||||
"Game.h"
|
||||
"GameCommand.h"
|
||||
"GameConstantsAndTypes.h"
|
||||
|
||||
+1
-1
@@ -40,7 +40,7 @@ public:
|
||||
void PushSelf( Lua *L );
|
||||
|
||||
// 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_sCharacterID;
|
||||
|
||||
+13
-13
@@ -2,12 +2,12 @@
|
||||
#include "CharacterManager.h"
|
||||
#include "Character.h"
|
||||
#include "GameState.h"
|
||||
#include "Foreach.h"
|
||||
|
||||
#include "LuaManager.h"
|
||||
|
||||
#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()
|
||||
{
|
||||
@@ -82,27 +82,27 @@ Character* CharacterManager::GetRandomCharacter()
|
||||
|
||||
Character* CharacterManager::GetDefaultCharacter()
|
||||
{
|
||||
for( unsigned i=0; i<m_pCharacters.size(); i++ )
|
||||
for (Character *c : m_pCharacters)
|
||||
{
|
||||
if( m_pCharacters[i]->IsDefaultCharacter() )
|
||||
return m_pCharacters[i];
|
||||
if( c->IsDefaultCharacter() )
|
||||
return c;
|
||||
}
|
||||
|
||||
/* We always have the default character. */
|
||||
FAIL_M("There must be a default character available!");
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void CharacterManager::DemandGraphics()
|
||||
{
|
||||
FOREACH( Character*, m_pCharacters, c )
|
||||
(*c)->DemandGraphics();
|
||||
for (Character *c : m_pCharacters)
|
||||
c->DemandGraphics();
|
||||
}
|
||||
|
||||
void CharacterManager::UndemandGraphics()
|
||||
{
|
||||
FOREACH( Character*, m_pCharacters, c )
|
||||
(*c)->UndemandGraphics();
|
||||
for (Character *c : m_pCharacters)
|
||||
c->UndemandGraphics();
|
||||
}
|
||||
|
||||
Character* CharacterManager::GetCharacterFromID( RString sCharacterID )
|
||||
@@ -113,7 +113,7 @@ Character* CharacterManager::GetCharacterFromID( RString sCharacterID )
|
||||
return m_pCharacters[i];
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
@@ -127,7 +127,7 @@ public:
|
||||
static int GetCharacter( T* p, lua_State *L )
|
||||
{
|
||||
Character *pCharacter = p->GetCharacterFromID(SArg(1));
|
||||
if( pCharacter != NULL )
|
||||
if( pCharacter != nullptr )
|
||||
pCharacter->PushSelf( L );
|
||||
else
|
||||
lua_pushnil( L );
|
||||
@@ -137,7 +137,7 @@ public:
|
||||
static int GetRandomCharacter( T* p, lua_State *L )
|
||||
{
|
||||
Character *pCharacter = p->GetRandomCharacter();
|
||||
if( pCharacter != NULL )
|
||||
if( pCharacter != nullptr )
|
||||
pCharacter->PushSelf( L );
|
||||
else
|
||||
lua_pushnil( L );
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
|
||||
#include "CombinedLifeMeter.h"
|
||||
#include "MeterDisplay.h"
|
||||
#include <array>
|
||||
|
||||
/** @brief Dance Magic-like tug-o-war life meter. */
|
||||
class CombinedLifeMeterTug : public CombinedLifeMeter
|
||||
@@ -19,7 +20,7 @@ public:
|
||||
|
||||
protected:
|
||||
|
||||
MeterDisplay m_Stream[NUM_PLAYERS];
|
||||
std::array<MeterDisplay, NUM_PLAYERS> m_Stream;
|
||||
AutoActor m_sprSeparator;
|
||||
AutoActor m_sprFrame;
|
||||
};
|
||||
|
||||
+9
-9
@@ -14,9 +14,9 @@ ComboGraph::ComboGraph()
|
||||
{
|
||||
DeleteChildrenWhenDone( true );
|
||||
|
||||
m_pNormalCombo = NULL;
|
||||
m_pMaxCombo = NULL;
|
||||
m_pComboNumber = NULL;
|
||||
m_pNormalCombo = nullptr;
|
||||
m_pMaxCombo = nullptr;
|
||||
m_pComboNumber = nullptr;
|
||||
}
|
||||
|
||||
void ComboGraph::Load( RString sMetricsGroup )
|
||||
@@ -28,10 +28,10 @@ void ComboGraph::Load( RString sMetricsGroup )
|
||||
this->SetWidth(BODY_WIDTH);
|
||||
this->SetHeight(BODY_HEIGHT);
|
||||
|
||||
Actor *pActor = NULL;
|
||||
Actor *pActor = nullptr;
|
||||
|
||||
m_pBacking = ActorUtil::MakeActor( THEME->GetPathG(sMetricsGroup,"Backing") );
|
||||
if( m_pBacking != NULL )
|
||||
if( m_pBacking != nullptr )
|
||||
{
|
||||
m_pBacking->ZoomToWidth( BODY_WIDTH );
|
||||
m_pBacking->ZoomToHeight( BODY_HEIGHT );
|
||||
@@ -39,7 +39,7 @@ void ComboGraph::Load( RString sMetricsGroup )
|
||||
}
|
||||
|
||||
m_pNormalCombo = ActorUtil::MakeActor( THEME->GetPathG(sMetricsGroup,"NormalCombo") );
|
||||
if( m_pNormalCombo != NULL )
|
||||
if( m_pNormalCombo != nullptr )
|
||||
{
|
||||
m_pNormalCombo->ZoomToWidth( BODY_WIDTH );
|
||||
m_pNormalCombo->ZoomToHeight( BODY_HEIGHT );
|
||||
@@ -47,7 +47,7 @@ void ComboGraph::Load( RString sMetricsGroup )
|
||||
}
|
||||
|
||||
m_pMaxCombo = ActorUtil::MakeActor( THEME->GetPathG(sMetricsGroup,"MaxCombo") );
|
||||
if( m_pMaxCombo != NULL )
|
||||
if( m_pMaxCombo != nullptr )
|
||||
{
|
||||
m_pMaxCombo->ZoomToWidth( BODY_WIDTH );
|
||||
m_pMaxCombo->ZoomToHeight( BODY_HEIGHT );
|
||||
@@ -55,10 +55,10 @@ void ComboGraph::Load( RString sMetricsGroup )
|
||||
}
|
||||
|
||||
pActor = ActorUtil::MakeActor( THEME->GetPathG(sMetricsGroup,"ComboNumber") );
|
||||
if( pActor != NULL )
|
||||
if( pActor != nullptr )
|
||||
{
|
||||
m_pComboNumber = dynamic_cast<BitmapText *>( pActor );
|
||||
if( m_pComboNumber != NULL )
|
||||
if( m_pComboNumber != nullptr )
|
||||
this->AddChild( m_pComboNumber );
|
||||
else
|
||||
LuaHelpers::ReportScriptErrorFmt( "ComboGraph: \"sMetricsGroup\" \"ComboNumber\" must be a BitmapText" );
|
||||
|
||||
+2
-11
@@ -3,8 +3,8 @@
|
||||
#include "RageUtil.h"
|
||||
#include "RageLog.h"
|
||||
#include "arch/Dialog/Dialog.h"
|
||||
#include "Foreach.h"
|
||||
|
||||
#include <numeric>
|
||||
|
||||
RString Command::GetName() const
|
||||
{
|
||||
@@ -81,16 +81,7 @@ static void SplitWithQuotes( const RString sSource, const char Delimitor, vector
|
||||
|
||||
RString Commands::GetOriginalCommandString() const
|
||||
{
|
||||
RString s;
|
||||
FOREACH_CONST( Command, v, c )
|
||||
{
|
||||
if(s != "")
|
||||
{
|
||||
s += ";";
|
||||
}
|
||||
s += c->GetOriginalCommandString();
|
||||
}
|
||||
return s;
|
||||
return std::accumulate(v.begin(), v.end(), RString(), [](RString &res, Command const &c) { return res + c.GetOriginalCommandString(); });
|
||||
}
|
||||
|
||||
void ParseCommands( const RString &sCommands, Commands &vCommandsOut, bool bLegacy )
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
#include "LuaManager.h"
|
||||
#include "ProductInfo.h"
|
||||
#include "DateTime.h"
|
||||
#include "Foreach.h"
|
||||
|
||||
#include "arch/Dialog/Dialog.h"
|
||||
#include "RageFileManager.h"
|
||||
#include "SpecialFiles.h"
|
||||
@@ -38,17 +38,17 @@ static void Nsis()
|
||||
|
||||
vector<RString> vs;
|
||||
GetDirListing(INSTALLER_LANGUAGES_DIR + "*.ini", vs, false, false);
|
||||
FOREACH_CONST(RString, vs, s)
|
||||
for (RString const &s : vs)
|
||||
{
|
||||
RString sThrowAway, sLangCode;
|
||||
splitpath(*s, sThrowAway, sLangCode, sThrowAway);
|
||||
splitpath(s, sThrowAway, sLangCode, sThrowAway);
|
||||
const LanguageInfo *pLI = GetLanguageInfo(sLangCode);
|
||||
|
||||
RString sLangNameUpper = pLI->szEnglishName;
|
||||
sLangNameUpper.MakeUpper();
|
||||
|
||||
IniFile ini;
|
||||
if(!ini.ReadFile(INSTALLER_LANGUAGES_DIR + *s))
|
||||
if(!ini.ReadFile(INSTALLER_LANGUAGES_DIR + s))
|
||||
RageException::Throw("Error opening file for read.");
|
||||
FOREACH_CONST_Child(&ini, child)
|
||||
{
|
||||
|
||||
+10
-10
@@ -1,7 +1,7 @@
|
||||
#include "global.h"
|
||||
#include "CommonMetrics.h"
|
||||
#include "RageUtil.h"
|
||||
#include "Foreach.h"
|
||||
|
||||
#include "GameManager.h"
|
||||
#include "RageLog.h"
|
||||
#include "GameState.h"
|
||||
@@ -45,12 +45,12 @@ void ThemeMetricDifficultiesToShow::Read()
|
||||
return;
|
||||
}
|
||||
|
||||
FOREACH_CONST( RString, v, i )
|
||||
for (RString const &i : v)
|
||||
{
|
||||
Difficulty d = StringToDifficulty( *i );
|
||||
Difficulty d = StringToDifficulty( i );
|
||||
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
|
||||
{
|
||||
@@ -84,12 +84,12 @@ void ThemeMetricCourseDifficultiesToShow::Read()
|
||||
return;
|
||||
}
|
||||
|
||||
FOREACH_CONST( RString, v, i )
|
||||
for (RString const &i : v)
|
||||
{
|
||||
CourseDifficulty d = StringToDifficulty( *i );
|
||||
CourseDifficulty d = StringToDifficulty( i );
|
||||
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
|
||||
{
|
||||
@@ -106,12 +106,12 @@ static void RemoveStepsTypes( vector<StepsType>& inout, RString sStepsTypesToRem
|
||||
if( v.size() == 0 ) return; // Nothing to do!
|
||||
|
||||
// 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 )
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
+63
-73
@@ -2,7 +2,7 @@
|
||||
#include "global.h"
|
||||
#include "Course.h"
|
||||
#include "CourseLoaderCRS.h"
|
||||
#include "Foreach.h"
|
||||
|
||||
#include "GameManager.h"
|
||||
#include "GameState.h"
|
||||
#include "LocalizedString.h"
|
||||
@@ -266,7 +266,7 @@ RString Course::GetTranslitFullTitle() const
|
||||
/* 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
|
||||
* 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
|
||||
{
|
||||
ASSERT( cd != Difficulty_Invalid );
|
||||
@@ -285,7 +285,7 @@ Trail* Course::GetTrail( StepsType st, CourseDifficulty cd ) const
|
||||
{
|
||||
CacheData &cache = it->second;
|
||||
if( cache.null )
|
||||
return NULL;
|
||||
return nullptr;
|
||||
return &cache.trail;
|
||||
}
|
||||
}
|
||||
@@ -303,7 +303,7 @@ Trail* Course::GetTrailForceRegenCache( StepsType st, CourseDifficulty cd ) cons
|
||||
{
|
||||
// This course difficulty doesn't exist.
|
||||
cache.null = true;
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// If we have cached RadarValues for this trail, insert them.
|
||||
@@ -455,7 +455,7 @@ bool Course::GetTrailUnsorted( StepsType st, CourseDifficulty cd, Trail &trail )
|
||||
else
|
||||
{
|
||||
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
|
||||
SongCriteria soc = e->songCriteria;
|
||||
@@ -504,7 +504,7 @@ bool Course::GetTrailUnsorted( StepsType st, CourseDifficulty cd, Trail &trail )
|
||||
vector<Song*> vpSongs;
|
||||
typedef vector<Steps*> StepsVector;
|
||||
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 ];
|
||||
|
||||
@@ -658,7 +658,8 @@ void Course::GetTrailUnsortedEndless( const vector<CourseEntry> &entries, Trail
|
||||
map<Song*, StepsVector> mapSongToSteps;
|
||||
int songIndex = 0;
|
||||
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
|
||||
@@ -698,12 +699,15 @@ void Course::GetTrailUnsortedEndless( const vector<CourseEntry> &entries, Trail
|
||||
continue;
|
||||
|
||||
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 ];
|
||||
v.push_back( sas->pSteps );
|
||||
StepsVector &v = mapSongToSteps[sas.pSong];
|
||||
v.push_back( sas.pSteps );
|
||||
if( v.size() == 1 )
|
||||
vpSongs.push_back( sas->pSong );
|
||||
vpSongs.push_back( sas.pSong );
|
||||
}
|
||||
vpSongsSorted = true;
|
||||
CourseSortSongs( e->songSort, vpSongs, rnd );
|
||||
@@ -711,7 +715,7 @@ void Course::GetTrailUnsortedEndless( const vector<CourseEntry> &entries, Trail
|
||||
}
|
||||
|
||||
ASSERT( e->iChooseIndex >= 0 );
|
||||
if( e->iChooseIndex < int( vSongAndSteps.size() ) )
|
||||
if( e->iChooseIndex < static_cast<int>(vSongAndSteps.size()) )
|
||||
{
|
||||
if( songIndex >= int(vpSongs.size()) ) {
|
||||
songIndex = 0;
|
||||
@@ -726,9 +730,9 @@ void Course::GetTrailUnsortedEndless( const vector<CourseEntry> &entries, Trail
|
||||
continue;
|
||||
}
|
||||
|
||||
/* If we're not COURSE_DIFFICULTY_REGULAR, then we should be choosing steps that are
|
||||
* either easier or harder than the base difficulty. If no such steps exist, then
|
||||
* just use the one we already have. */
|
||||
/* If we're not COURSE_DIFFICULTY_REGULAR, then we should be choosing steps that are
|
||||
* either easier or harder than the base difficulty. If no such steps exist, then
|
||||
* just use the one we already have. */
|
||||
Difficulty dc = resolved.pSteps->GetDifficulty();
|
||||
int iLowMeter = e->stepsCriteria.m_iLowMeter;
|
||||
int iHighMeter = e->stepsCriteria.m_iHighMeter;
|
||||
@@ -745,14 +749,14 @@ void Course::GetTrailUnsortedEndless( const vector<CourseEntry> &entries, Trail
|
||||
Difficulty new_dc;
|
||||
if( INCLUDE_BEGINNER_STEPS )
|
||||
{
|
||||
// don't factor in the course difficulty if we're including
|
||||
// beginner steps -aj
|
||||
new_dc = clamp( dc, Difficulty_Beginner, (Difficulty)(Difficulty_Edit-1) );
|
||||
// don't factor in the course difficulty if we're including
|
||||
// beginner steps -aj
|
||||
new_dc = clamp( dc, Difficulty_Beginner, (Difficulty)(Difficulty_Edit-1) );
|
||||
}
|
||||
else
|
||||
{
|
||||
new_dc = (Difficulty)(dc + cd - Difficulty_Medium);
|
||||
new_dc = clamp( new_dc, (Difficulty)0, (Difficulty)(Difficulty_Edit-1) );
|
||||
new_dc = (Difficulty)(dc + cd - Difficulty_Medium);
|
||||
new_dc = clamp( new_dc, (Difficulty)0, (Difficulty)(Difficulty_Edit-1) );
|
||||
}
|
||||
*/
|
||||
|
||||
@@ -770,21 +774,21 @@ void Course::GetTrailUnsortedEndless( const vector<CourseEntry> &entries, Trail
|
||||
}
|
||||
|
||||
/* Hack: We used to adjust low_meter/high_meter above while searching for
|
||||
* songs. However, that results in a different song being chosen for
|
||||
* difficult courses, which is bad when LockCourseDifficulties is disabled;
|
||||
* each player can end up with a different song. Instead, choose based
|
||||
* on the original range, bump the steps based on course difficulty, and
|
||||
* then retroactively tweak the low_meter/high_meter so course displays
|
||||
* line up. */
|
||||
* songs. However, that results in a different song being chosen for
|
||||
* difficult courses, which is bad when LockCourseDifficulties is disabled;
|
||||
* each player can end up with a different song. Instead, choose based
|
||||
* on the original range, bump the steps based on course difficulty, and
|
||||
* then retroactively tweak the low_meter/high_meter so course displays
|
||||
* line up. */
|
||||
if( e->stepsCriteria.m_difficulty == Difficulty_Invalid && bChangedDifficulty )
|
||||
{
|
||||
/* Minimum and maximum to add to make the meter range contain the actual
|
||||
* meter: */
|
||||
* meter: */
|
||||
int iMinDist = resolved.pSteps->GetMeter() - iHighMeter;
|
||||
int iMaxDist = resolved.pSteps->GetMeter() - iLowMeter;
|
||||
|
||||
/* Clamp the possible adjustments to try to avoid going under 1 or over
|
||||
* MAX_BOTTOM_RANGE. */
|
||||
* MAX_BOTTOM_RANGE. */
|
||||
iMinDist = min( max( iMinDist, -iLowMeter + 1 ), iMaxDist );
|
||||
iMaxDist = max( min( iMaxDist, MAX_BOTTOM_RANGE - iHighMeter ), iMinDist );
|
||||
|
||||
@@ -808,7 +812,7 @@ void Course::GetTrailUnsortedEndless( const vector<CourseEntry> &entries, Trail
|
||||
te.iHighMeter = iHighMeter;
|
||||
|
||||
/* If we chose based on meter (not difficulty), then store Difficulty_Invalid, so
|
||||
* other classes can tell that we used meter. */
|
||||
* other classes can tell that we used meter. */
|
||||
if( e->stepsCriteria.m_difficulty == Difficulty_Invalid )
|
||||
{
|
||||
te.dc = Difficulty_Invalid;
|
||||
@@ -816,7 +820,7 @@ void Course::GetTrailUnsortedEndless( const vector<CourseEntry> &entries, Trail
|
||||
else
|
||||
{
|
||||
/* Otherwise, store the actual difficulty we got (post-course-difficulty).
|
||||
* This may or may not be the same as e.difficulty. */
|
||||
* This may or may not be the same as e.difficulty. */
|
||||
te.dc = dc;
|
||||
}
|
||||
|
||||
@@ -841,7 +845,7 @@ void Course::GetTrails( vector<Trail*> &AddTo, StepsType st ) const
|
||||
FOREACH_ShownCourseDifficulty( cd )
|
||||
{
|
||||
Trail *pTrail = GetTrail( st, cd );
|
||||
if( pTrail == NULL )
|
||||
if( pTrail == nullptr )
|
||||
continue;
|
||||
AddTo.push_back( pTrail );
|
||||
}
|
||||
@@ -851,9 +855,9 @@ void Course::GetAllTrails( vector<Trail*> &AddTo ) const
|
||||
{
|
||||
vector<StepsType> 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 )
|
||||
return m_iCustomMeter[cd];
|
||||
const Trail* pTrail = GetTrail( st );
|
||||
if( pTrail != NULL )
|
||||
if( pTrail != nullptr )
|
||||
return pTrail->GetMeter();
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool Course::HasMods() const
|
||||
{
|
||||
FOREACH_CONST( CourseEntry, m_vEntries, e )
|
||||
{
|
||||
if( !e->attacks.empty() )
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
return std::any_of(m_vEntries.begin(), m_vEntries.end(), [](CourseEntry const &e) { return !e.attacks.empty(); });
|
||||
}
|
||||
|
||||
bool Course::HasTimedMods() const
|
||||
@@ -884,16 +882,15 @@ bool Course::HasTimedMods() const
|
||||
// HasTimedMods now searches for bGlobal in the attacks; if one of
|
||||
// them is false, it has timed mods. Also returning false will probably
|
||||
// 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++ )
|
||||
{
|
||||
const Attack attack = e->attacks[s];
|
||||
if(!attack.bGlobal)
|
||||
return true;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if (std::any_of(e.attacks.begin(), e.attacks.end(), [](Attack const &a) { return !a.bGlobal; }))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
@@ -901,12 +898,7 @@ bool Course::HasTimedMods() const
|
||||
|
||||
bool Course::AllSongsAreFixed() const
|
||||
{
|
||||
FOREACH_CONST( CourseEntry, m_vEntries, e )
|
||||
{
|
||||
if( !e->IsFixedSong() )
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
return std::all_of(m_vEntries.begin(), m_vEntries.end(), [](CourseEntry const &e) { return e.IsFixedSong(); });
|
||||
}
|
||||
|
||||
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;
|
||||
GAMEMAN->GetCompatibleStyles( pGame, iNumPlayers, vpStyles );
|
||||
|
||||
for( int s=0; s < (int) vpStyles.size(); ++s )
|
||||
for (Style const *pStyle : vpStyles)
|
||||
{
|
||||
const Style *pStyle = vpStyles[s];
|
||||
FOREACHS_CONST( RString, m_setStyles, style )
|
||||
for (RString const &style : m_setStyles)
|
||||
{
|
||||
if( !style->CompareNoCase(pStyle->m_szName) )
|
||||
if( !style.CompareNoCase(pStyle->m_szName) )
|
||||
return pStyle;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void Course::InvalidateTrailCache()
|
||||
@@ -933,9 +924,9 @@ void Course::InvalidateTrailCache()
|
||||
|
||||
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
|
||||
{
|
||||
RevertFromDisk();
|
||||
@@ -971,9 +962,9 @@ void Course::RegenerateNonFixedTrails() const
|
||||
if( AllSongsAreFixed() )
|
||||
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 );
|
||||
}
|
||||
}
|
||||
@@ -1046,11 +1037,11 @@ bool Course::GetTotalSeconds( StepsType st, float& fSecondsOut ) 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;
|
||||
if( e->songSort == SongSort_FewestPlays && e->iChooseIndex != -1 )
|
||||
if( e.songSort == SongSort_FewestPlays && e.iChooseIndex != -1 )
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1093,7 +1084,7 @@ void Course::UpdateCourseStats( StepsType st )
|
||||
for(unsigned i = 0; i < m_vEntries.size(); i++)
|
||||
{
|
||||
Song *pSong = m_vEntries[i].songID.ToSong();
|
||||
if( pSong != NULL )
|
||||
if( pSong != nullptr )
|
||||
continue;
|
||||
|
||||
if ( m_SortOrder_Ranking == 2 )
|
||||
@@ -1104,7 +1095,7 @@ void Course::UpdateCourseStats( StepsType st )
|
||||
|
||||
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
|
||||
// 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
|
||||
{
|
||||
FOREACH_CONST( CourseEntry, m_vEntries, e )
|
||||
for (CourseEntry const &entry : m_vEntries)
|
||||
{
|
||||
const CourseEntry &entry = *e;
|
||||
Song *lSong = entry.songID.ToSong();
|
||||
if( pSong == lSong )
|
||||
return &entry;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void Course::GetAllCachedTrails( vector<Trail *> &out )
|
||||
@@ -1169,7 +1159,7 @@ void Course::CalculateRadarValues()
|
||||
if( AllSongsAreFixed() )
|
||||
{
|
||||
Trail *pTrail = GetTrail( st, cd );
|
||||
if( pTrail == NULL )
|
||||
if( pTrail == nullptr )
|
||||
continue;
|
||||
RadarValues rv = pTrail->GetRadarValues();
|
||||
m_RadarCache[CacheEntry(st, cd)] = rv;
|
||||
|
||||
@@ -14,8 +14,8 @@ REGISTER_ACTOR_CLASS( CourseContentsList );
|
||||
|
||||
CourseContentsList::~CourseContentsList()
|
||||
{
|
||||
FOREACH( Actor *, m_vpDisplay, d )
|
||||
delete *d;
|
||||
for (Actor *d : m_vpDisplay)
|
||||
delete d;
|
||||
m_vpDisplay.clear();
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ void CourseContentsList::LoadFromNode( const XNode* pNode )
|
||||
pNode->GetAttrValue( "MaxSongs", iMaxSongs );
|
||||
|
||||
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());
|
||||
return;
|
||||
@@ -48,7 +48,7 @@ void CourseContentsList::SetFromGameState()
|
||||
if( GAMESTATE->GetMasterPlayerNumber() == PlayerNumber_Invalid )
|
||||
return;
|
||||
const Trail *pMasterTrail = GAMESTATE->m_pCurTrail[GAMESTATE->GetMasterPlayerNumber()];
|
||||
if( pMasterTrail == NULL )
|
||||
if( pMasterTrail == nullptr )
|
||||
return;
|
||||
unsigned uNumEntriesToShow = pMasterTrail->m_vEntries.size();
|
||||
CLAMP( uNumEntriesToShow, 0, m_vpDisplay.size() );
|
||||
@@ -81,21 +81,21 @@ void CourseContentsList::SetItemFromGameState( Actor *pActor, int iCourseEntryIn
|
||||
FOREACH_HumanPlayer(pn)
|
||||
{
|
||||
const Trail *pTrail = GAMESTATE->m_pCurTrail[pn];
|
||||
if( pTrail == NULL
|
||||
if( pTrail == nullptr
|
||||
|| iCourseEntryIndex >= (int) pTrail->m_vEntries.size()
|
||||
|| iCourseEntryIndex >= (int) pCourse->m_vEntries.size() )
|
||||
continue;
|
||||
|
||||
const TrailEntry *te = &pTrail->m_vEntries[iCourseEntryIndex];
|
||||
const CourseEntry *ce = &pCourse->m_vEntries[iCourseEntryIndex];
|
||||
if( te == NULL )
|
||||
if( te == nullptr )
|
||||
continue;
|
||||
|
||||
RString s;
|
||||
Difficulty dc;
|
||||
if( te->bSecret )
|
||||
{
|
||||
if( ce == NULL )
|
||||
if( ce == nullptr )
|
||||
continue;
|
||||
|
||||
int iLow = ce->stepsCriteria.m_iLowMeter;
|
||||
|
||||
+14
-14
@@ -87,7 +87,7 @@ bool CourseLoaderCRS::LoadFromMsd( const RString &sPath, const MsdFile &msd, Cou
|
||||
}
|
||||
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") )
|
||||
{
|
||||
@@ -97,7 +97,7 @@ bool CourseLoaderCRS::LoadFromMsd( const RString &sPath, const MsdFile &msd, Cou
|
||||
{
|
||||
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 )
|
||||
{
|
||||
@@ -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() );
|
||||
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
|
||||
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 )
|
||||
{
|
||||
// looking up a song that doesn't exist.
|
||||
@@ -185,7 +185,7 @@ bool CourseLoaderCRS::LoadFromMsd( const RString &sPath, const MsdFile &msd, Cou
|
||||
// least played
|
||||
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 )
|
||||
{
|
||||
// looking up a song that doesn't exist.
|
||||
@@ -202,14 +202,14 @@ bool CourseLoaderCRS::LoadFromMsd( const RString &sPath, const MsdFile &msd, Cou
|
||||
// best grades
|
||||
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 );
|
||||
new_entry.songSort = SongSort_TopGrades;
|
||||
}
|
||||
// worst grades
|
||||
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 );
|
||||
new_entry.songSort = SongSort_LowestGrades;
|
||||
}
|
||||
@@ -250,7 +250,7 @@ bool CourseLoaderCRS::LoadFromMsd( const RString &sPath, const MsdFile &msd, Cou
|
||||
vector<RString> bits;
|
||||
split( sSong, "/", bits );
|
||||
|
||||
Song *pSong = NULL;
|
||||
Song *pSong = nullptr;
|
||||
if( bits.size() == 2 )
|
||||
{
|
||||
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 );
|
||||
|
||||
if( pSong == NULL )
|
||||
if( pSong == nullptr )
|
||||
{
|
||||
LOG->UserLog( "Course file", sPath, "contains a fixed song entry \"%s\" that does not exist. "
|
||||
"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") )
|
||||
new_entry.bNoDifficult = true;
|
||||
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
|
||||
continue;
|
||||
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") )
|
||||
{
|
||||
StepsType st = (StepsType) StringToInt(sParams[1]);
|
||||
CourseDifficulty cd = (CourseDifficulty) StringToInt( sParams[2] );
|
||||
StepsType st = (StepsType) std::stoi(sParams[1]);
|
||||
CourseDifficulty cd = (CourseDifficulty) std::stoi( sParams[2] );
|
||||
|
||||
RadarValues rv;
|
||||
rv.FromString( sParams[3] );
|
||||
@@ -342,8 +342,8 @@ bool CourseLoaderCRS::LoadFromMsd( const RString &sPath, const MsdFile &msd, Cou
|
||||
RString sStyles = sParams[1];
|
||||
vector<RString> asStyles;
|
||||
split( sStyles, ",", asStyles );
|
||||
FOREACH( RString, asStyles, s )
|
||||
out.m_setStyles.insert( *s );
|
||||
for (RString const &s : asStyles)
|
||||
out.m_setStyles.insert( s );
|
||||
|
||||
}
|
||||
else
|
||||
|
||||
+26
-35
@@ -8,7 +8,7 @@
|
||||
#include "XmlFile.h"
|
||||
#include "GameState.h"
|
||||
#include "Style.h"
|
||||
#include "Foreach.h"
|
||||
|
||||
#include "GameState.h"
|
||||
#include "LocalizedString.h"
|
||||
#include "RageLog.h"
|
||||
@@ -110,7 +110,7 @@ void CourseUtil::SortCoursePointerArrayByTotalDifficulty( vector<Course*> &vpCou
|
||||
#if 0
|
||||
RString GetSectionNameFromCourseAndSort( const Course *pCourse, SortOrder so )
|
||||
{
|
||||
if( pCourse == NULL )
|
||||
if( pCourse == nullptr )
|
||||
return RString();
|
||||
// more code here
|
||||
}
|
||||
@@ -195,7 +195,7 @@ void CourseUtil::SortCoursePointerArrayByNumPlays( vector<Course*> &vpCoursesInO
|
||||
|
||||
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)
|
||||
course_sort_val[vpCoursesInOut[i]] = ssprintf( "%09i", pProfile->GetCourseNumTimesPlayed(vpCoursesInOut[i]) );
|
||||
stable_sort( vpCoursesInOut.begin(), vpCoursesInOut.end(), bDescending ? CompareCoursePointersBySortValueDescending : CompareCoursePointersBySortValueAscending );
|
||||
@@ -206,11 +206,11 @@ void CourseUtil::SortByMostRecentlyPlayedForMachine( vector<Course*> &vpCoursesI
|
||||
{
|
||||
Profile *pProfile = PROFILEMAN->GetMachineProfile();
|
||||
|
||||
FOREACH_CONST( Course*, vpCoursesInOut, c )
|
||||
for (Course const * c: vpCoursesInOut)
|
||||
{
|
||||
int iNumTimesPlayed = pProfile->GetCourseNumTimesPlayed( *c );
|
||||
RString val = iNumTimesPlayed ? pProfile->GetCourseLastPlayedDateTime(*c).GetString() : "9999999999999";
|
||||
course_sort_val[*c] = val;
|
||||
int iNumTimesPlayed = pProfile->GetCourseNumTimesPlayed( c );
|
||||
RString val = iNumTimesPlayed ? pProfile->GetCourseLastPlayedDateTime(c).GetString() : "9999999999999";
|
||||
course_sort_val[c] = val;
|
||||
}
|
||||
|
||||
stable_sort( vpCoursesInOut.begin(), vpCoursesInOut.end(), CompareCoursePointersBySortValueAscending );
|
||||
@@ -327,12 +327,12 @@ void CourseUtil::WarnOnInvalidMods( RString sMods )
|
||||
SongOptions so;
|
||||
vector<RString> vs;
|
||||
split( sMods, ",", vs, true );
|
||||
FOREACH_CONST( RString, vs, s )
|
||||
for (RString const &s : vs)
|
||||
{
|
||||
bool bValid = false;
|
||||
RString sErrorDetail;
|
||||
bValid |= po.FromOneModString( *s, sErrorDetail );
|
||||
bValid |= so.FromOneModString( *s, sErrorDetail );
|
||||
bValid |= po.FromOneModString( s, sErrorDetail );
|
||||
bValid |= so.FromOneModString( s, sErrorDetail );
|
||||
/* ==Invalid options that used to be valid==
|
||||
* all noteskins (solo, note, foon, &c.)
|
||||
* protiming (done in Lua now)
|
||||
@@ -346,7 +346,7 @@ void CourseUtil::WarnOnInvalidMods( RString sMods )
|
||||
*/
|
||||
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() )
|
||||
sFullError += ": " + sErrorDetail;
|
||||
LOG->UserLog( "", "", "%s", sFullError.c_str() );
|
||||
@@ -422,7 +422,7 @@ bool EditCourseUtil::ValidateEditCourseName( const RString &sAnswer, RString &sE
|
||||
}
|
||||
|
||||
static const RString sInvalidChars = "\\/:*?\"<>|";
|
||||
if( strpbrk(sAnswer, sInvalidChars) != NULL )
|
||||
if( strpbrk(sAnswer, sInvalidChars) != nullptr )
|
||||
{
|
||||
sErrorOut = ssprintf( EDIT_NAME_CANNOT_CONTAIN.GetValue(), sInvalidChars.c_str() );
|
||||
return false;
|
||||
@@ -431,12 +431,12 @@ bool EditCourseUtil::ValidateEditCourseName( const RString &sAnswer, RString &sE
|
||||
// Check for name conflicts
|
||||
vector<Course*> 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
|
||||
|
||||
if( (*p)->GetDisplayFullTitle() == sAnswer )
|
||||
if( p->GetDisplayFullTitle() == sAnswer )
|
||||
{
|
||||
sErrorOut = EDIT_NAME_CONFLICTS;
|
||||
return false;
|
||||
@@ -448,9 +448,9 @@ bool EditCourseUtil::ValidateEditCourseName( const RString &sAnswer, RString &sE
|
||||
|
||||
void EditCourseUtil::UpdateAndSetTrail()
|
||||
{
|
||||
ASSERT( GAMESTATE->GetCurrentStyle(PLAYER_INVALID) != NULL );
|
||||
ASSERT( GAMESTATE->GetCurrentStyle(PLAYER_INVALID) != nullptr );
|
||||
StepsType st = GAMESTATE->GetCurrentStyle(PLAYER_INVALID)->m_StepsType;
|
||||
Trail *pTrail = NULL;
|
||||
Trail *pTrail = nullptr;
|
||||
if( GAMESTATE->m_pCurCourse )
|
||||
pTrail = GAMESTATE->m_pCurCourse->GetTrailForceRegenCache( st );
|
||||
GAMESTATE->m_pCurTrail[PLAYER_1].Set( pTrail );
|
||||
@@ -458,7 +458,7 @@ void EditCourseUtil::UpdateAndSetTrail()
|
||||
|
||||
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_bSideIsJoined[0] = true;
|
||||
|
||||
@@ -471,10 +471,10 @@ void EditCourseUtil::GetAllEditCourses( vector<Course*> &vpCoursesOut )
|
||||
{
|
||||
vector<Course*> vpCoursesTemp;
|
||||
SONGMAN->GetAllCourses( vpCoursesTemp, false );
|
||||
FOREACH_CONST( Course*, vpCoursesTemp, c )
|
||||
for (Course *c : vpCoursesTemp)
|
||||
{
|
||||
if( (*c)->GetLoadedFromProfileSlot() != ProfileSlot_Invalid )
|
||||
vpCoursesOut.push_back( *c );
|
||||
if( c->GetLoadedFromProfileSlot() != ProfileSlot_Invalid )
|
||||
vpCoursesOut.push_back( c );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -489,20 +489,11 @@ void EditCourseUtil::LoadDefaults( Course &out )
|
||||
for( int i=0; i<10000; i++ )
|
||||
{
|
||||
out.m_sMainTitle = ssprintf("Workout %d", i+1);
|
||||
bool bNameInUse = false;
|
||||
|
||||
|
||||
vector<Course*> 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;
|
||||
}
|
||||
|
||||
@@ -552,7 +543,7 @@ void CourseID::FromCourse( const Course *p )
|
||||
|
||||
Course *CourseID::ToCourse() const
|
||||
{
|
||||
Course *pCourse = NULL;
|
||||
Course *pCourse = nullptr;
|
||||
if(m_Cache.Get(&pCourse))
|
||||
{
|
||||
return pCourse;
|
||||
@@ -567,13 +558,13 @@ Course *CourseID::ToCourse() const
|
||||
slash_path = "/" + slash_path;
|
||||
}
|
||||
|
||||
if(pCourse == NULL)
|
||||
if(pCourse == nullptr)
|
||||
{
|
||||
pCourse = SONGMAN->GetCourseFromPath(slash_path);
|
||||
}
|
||||
}
|
||||
|
||||
if( pCourse == NULL && !sFullTitle.empty() )
|
||||
if( pCourse == nullptr && !sFullTitle.empty() )
|
||||
{
|
||||
pCourse = SONGMAN->GetCourseFromName( sFullTitle );
|
||||
}
|
||||
|
||||
+1
-1
@@ -73,7 +73,7 @@ class CourseID
|
||||
{
|
||||
public:
|
||||
CourseID(): sPath(""), sFullTitle(""), m_Cache() { Unset(); }
|
||||
void Unset() { FromCourse(NULL); }
|
||||
void Unset() { FromCourse(nullptr); }
|
||||
void FromCourse( const Course *p );
|
||||
Course *ToCourse() const;
|
||||
const RString &GetPath() const { return sPath; }
|
||||
|
||||
+14
-14
@@ -532,7 +532,7 @@ const ulg crc_table[256] = {
|
||||
|
||||
ulg crc32(ulg crc, const uch *buf, size_t len)
|
||||
{
|
||||
if (buf==NULL) return 0L;
|
||||
if (buf== nullptr) return 0L;
|
||||
crc = crc ^ 0xffffffffL;
|
||||
while (len >= 8) {DO8(buf); len -= 8;}
|
||||
if (len) do {DO1(buf);} while (--len);
|
||||
@@ -543,7 +543,7 @@ ulg crc32(ulg crc, const uch *buf, size_t len)
|
||||
class TZip
|
||||
{
|
||||
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()
|
||||
@@ -631,7 +631,7 @@ unsigned TZip::swrite(void *param,const char *buf, unsigned size)
|
||||
unsigned int TZip::write(const char *buf,unsigned int size)
|
||||
{
|
||||
const char *srcbuf=buf;
|
||||
if (pfout != NULL)
|
||||
if (pfout != nullptr)
|
||||
{
|
||||
unsigned long writ = pfout->Write( srcbuf, size );
|
||||
return writ;
|
||||
@@ -717,7 +717,7 @@ ZRESULT TZip::set_times()
|
||||
|
||||
unsigned short dosdate,dostime;
|
||||
filetime2dosdatetime(*ptm,&dosdate,&dostime);
|
||||
times.atime = time(NULL);
|
||||
times.atime = time(nullptr);
|
||||
times.mtime = times.atime;
|
||||
times.ctime = times.atime;
|
||||
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.
|
||||
|
||||
// Initialize the local header
|
||||
TZipFileInfo zfi; zfi.nxt=NULL;
|
||||
TZipFileInfo zfi; zfi.nxt=nullptr;
|
||||
strcpy(zfi.name,"");
|
||||
#ifdef UNICODE
|
||||
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++;
|
||||
}
|
||||
strcpy(zfi.zname,"");
|
||||
zfi.extra=NULL; 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.comment=NULL; zfi.com=0; // comment, and its length
|
||||
zfi.extra=nullptr; zfi.ext=0; // extra header to go after this compressed data, 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=nullptr; zfi.com=0; // comment, and its length
|
||||
zfi.mark = 1;
|
||||
zfi.dosflag = 0;
|
||||
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
|
||||
char *cextra = new char[zfi.cext]; memcpy(cextra,zfi.cextra,zfi.cext); zfi.cextra=cextra;
|
||||
TZipFileInfo *pzfi = new TZipFileInfo; memcpy(pzfi,&zfi,sizeof(zfi));
|
||||
if (zfis==NULL)
|
||||
if (zfis==nullptr)
|
||||
zfis=pzfi;
|
||||
else
|
||||
{
|
||||
TZipFileInfo *z=zfis;
|
||||
while (z->nxt!=NULL)
|
||||
while (z->nxt!=nullptr)
|
||||
z=z->nxt;
|
||||
z->nxt=pzfi;
|
||||
}
|
||||
@@ -954,7 +954,7 @@ ZRESULT TZip::AddCentral()
|
||||
ulg pos_at_start_of_central = writ;
|
||||
//ulg tot_unc_size=0, tot_compressed_size=0;
|
||||
bool okay=true;
|
||||
for (TZipFileInfo *zfi=zfis; zfi!=NULL; )
|
||||
for (TZipFileInfo *zfi=zfis; zfi!= nullptr; )
|
||||
{
|
||||
if (okay)
|
||||
{
|
||||
@@ -975,7 +975,7 @@ ZRESULT TZip::AddCentral()
|
||||
ulg center_size = writ - pos_at_start_of_central;
|
||||
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)
|
||||
okay=false;
|
||||
writ += 4 + ENDHEAD + 0;
|
||||
@@ -994,7 +994,7 @@ ZRESULT lasterrorZ=ZR_OK;
|
||||
|
||||
CreateZip::CreateZip()
|
||||
{
|
||||
hz=NULL;
|
||||
hz=nullptr;
|
||||
}
|
||||
|
||||
bool CreateZip::Start( RageFile *f)
|
||||
@@ -1016,7 +1016,7 @@ bool CreateZip::AddFile(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;
|
||||
}
|
||||
bool CreateZip::Finish()
|
||||
|
||||
+4
-4
@@ -49,7 +49,7 @@ public:
|
||||
// char buf[1000]; for (int i=0; i<1000; i++) buf[i]=(char)(i&0x7F);
|
||||
// ZipAdd(hz,"file.dat", buf,1000);
|
||||
// // 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);
|
||||
// ZipAdd(hz,"unz3.dat", hread,1000); // the '1000' is optional.
|
||||
// WaitForSingleObject(hthread,INFINITE);
|
||||
@@ -57,14 +57,14 @@ public:
|
||||
// ... meanwhile DWORD WINAPI ThreadFunc(void *dat)
|
||||
// { HANDLE hwrite = (HANDLE)dat;
|
||||
// char buf[1000]={17};
|
||||
// DWORD writ; WriteFile(hwrite,buf,1000,&writ,NULL);
|
||||
// DWORD writ; WriteFile(hwrite,buf,1000,&writ,nullptr);
|
||||
// CloseHandle(hwrite);
|
||||
// return 0;
|
||||
// }
|
||||
// // and now that the zip is created, let's do something with it:
|
||||
// void *zbuf; unsigned long zlen; ZipGetMemory(hz,&zbuf,&zlen);
|
||||
// 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);
|
||||
// CloseZip(hz);
|
||||
//
|
||||
@@ -81,7 +81,7 @@ public:
|
||||
// { HANDLE hread = (HANDLE)dat;
|
||||
// char buf[1000];
|
||||
// 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
|
||||
// if (red==0) break;
|
||||
// }
|
||||
|
||||
@@ -6,7 +6,7 @@ PRNGWrapper::PRNGWrapper( const struct ltc_prng_descriptor *pPRNGDescriptor )
|
||||
m_iPRNG = register_prng( pPRNGDescriptor );
|
||||
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) );
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ void PRNGWrapper::AddEntropy( const void *pData, int iSize )
|
||||
void PRNGWrapper::AddRandomEntropy()
|
||||
{
|
||||
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) );
|
||||
|
||||
AddEntropy( buf, sizeof(buf) );
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
|
||||
#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 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;
|
||||
|
||||
CryptManager::CryptManager()
|
||||
|
||||
+3
-4
@@ -3,7 +3,6 @@
|
||||
#include "RageUtil.h"
|
||||
#include "RageFile.h"
|
||||
#include "RageLog.h"
|
||||
#include "Foreach.h"
|
||||
|
||||
CsvFile::CsvFile()
|
||||
{
|
||||
@@ -114,15 +113,15 @@ bool CsvFile::WriteFile( const RString &sPath ) const
|
||||
|
||||
bool CsvFile::WriteFile( RageFileBasic &f ) const
|
||||
{
|
||||
FOREACH_CONST( StringVector, m_vvs, line )
|
||||
for (StringVector const &line : m_vvs)
|
||||
{
|
||||
RString sLine;
|
||||
FOREACH_CONST( RString, *line, value )
|
||||
for (auto value = line.begin(); value != line.end(); ++value)
|
||||
{
|
||||
RString sVal = *value;
|
||||
sVal.Replace( "\"", "\"\"" ); // escape quotes to double-quotes
|
||||
sLine += "\"" + sVal + "\"";
|
||||
if( value != line->end()-1 )
|
||||
if( value != line.end()-1 )
|
||||
sLine += ",";
|
||||
}
|
||||
if( f.PutLine(sLine) == -1 )
|
||||
|
||||
+440
-440
@@ -1,440 +1,440 @@
|
||||
#include "global.h"
|
||||
#include "DancingCharacters.h"
|
||||
#include "GameConstantsAndTypes.h"
|
||||
#include "RageDisplay.h"
|
||||
#include "RageUtil.h"
|
||||
#include "RageMath.h"
|
||||
#include "GameState.h"
|
||||
#include "Song.h"
|
||||
#include "Character.h"
|
||||
#include "StatsManager.h"
|
||||
#include "PrefsManager.h"
|
||||
#include "Model.h"
|
||||
|
||||
int Neg1OrPos1();
|
||||
|
||||
#define DC_X( choice ) THEME->GetMetricF("DancingCharacters",ssprintf("2DCharacterXP%d",choice+1))
|
||||
#define DC_Y( choice ) THEME->GetMetricF("DancingCharacters",ssprintf("2DCharacterYP%d",choice+1))
|
||||
|
||||
/*
|
||||
* TODO:
|
||||
* - Metrics/Lua for lighting and camera sweeping.
|
||||
* - Ability to load secondary elements i.e. stages.
|
||||
* - Remove support for 2D characters (Lua can do it).
|
||||
* - Cleanup!
|
||||
*
|
||||
* -- Colby
|
||||
*/
|
||||
|
||||
#define CAMERA_REST_DISTANCE THEME->GetMetricF("DancingCamera","RestDistance")
|
||||
#define CAMERA_REST_LOOK_AT_HEIGHT THEME->GetMetricF("DancingCamera","RestHeight")
|
||||
#define CAMERA_SWEEP_DISTANCE THEME->GetMetricF("DancingCamera","SweepDistance")
|
||||
#define CAMERA_SWEEP_DISTANCE_VARIANCE THEME->GetMetricF("DancingCamera","SweepDistanceVariable")
|
||||
#define CAMERA_SWEEP_HEIGHT_VARIANCE THEME->GetMetricF("DancingCamera","SweepHeightVariable")
|
||||
#define CAMERA_SWEEP_PAN_Y_RANGE_DEGREES THEME->GetMetricF("DancingCamera","SweepPanYRangeDegrees")
|
||||
#define CAMERA_SWEEP_PAN_Y_VARIANCE_DEGREES THEME->GetMetricF("DancingCamera","SweepPanYVarianceDegrees")
|
||||
#define CAMERA_SWEEP_LOOK_AT_HEIGHT THEME->GetMetricF("DancingCamera","SweepHeight")
|
||||
#define CAMERA_STILL_DISTANCE THEME->GetMetricF("DancingCamera","StillDistance")
|
||||
#define CAMERA_STILL_DISTANCE_VARIANCE THEME->GetMetricF("DancingCamera","StillDistanceVariance")
|
||||
#define CAMERA_STILL_PAN_Y_RANGE_DEGREES THEME->GetMetricF("DancingCamera","StillPanYRangeDegrees")
|
||||
#define CAMERA_STILL_HEIGHT_VARIANCE THEME->GetMetricF("DancingCamera","StillHeightVariance")
|
||||
#define CAMERA_STILL_LOOK_AT_HEIGHT THEME->GetMetricF("DancingCamera","StillHeight")
|
||||
|
||||
// This is to setup the lighting color.
|
||||
const ThemeMetric<RageColor> LIGHT_AMBIENT_COLOR ( "DancingCamera", "AmbientColor" );
|
||||
const ThemeMetric<RageColor> LIGHT_DIFFUSE_COLOR ( "DancingCamera", "DiffuseColor" );
|
||||
|
||||
// This is for Danger and Failed colors.
|
||||
const ThemeMetric<RageColor> LIGHT_ADANGER_COLOR ( "DancingCamera", "AmbientDangerColor" );
|
||||
const ThemeMetric<RageColor> LIGHT_AFAILED_COLOR ( "DancingCamera", "AmbientFailedColor" );
|
||||
const ThemeMetric<RageColor> LIGHT_DDANGER_COLOR ( "DancingCamera", "DiffuseDangerColor" );
|
||||
const ThemeMetric<RageColor> LIGHT_DFAILED_COLOR ( "DancingCamera", "DiffuseFailedColor" );
|
||||
|
||||
// This is to make positioning of said light.
|
||||
#define LIGHTING_X THEME->GetMetricF("DancingCamera","LightX")
|
||||
#define LIGHTING_Y THEME->GetMetricF("DancingCamera","LightY")
|
||||
#define LIGHTING_Z THEME->GetMetricF("DancingCamera","LightZ")
|
||||
|
||||
// Position of the model in X (one player)
|
||||
#define MODEL_X_ONE_PLAYER THEME->GetMetricF("DancingCharacters","OnePlayerModelX")
|
||||
|
||||
// As the name implies, this sets the ammount of beats that the camera will
|
||||
// stay in its current state until transitioning to the next camera tween.
|
||||
#define AMM_BEATS_TIL_NEXTCAMERA THEME->GetMetricF("DancingCamera","BeatsUntilNextCamPos")
|
||||
#define CAM_FOV THEME->GetMetricF("DancingCamera","CameraFOV")
|
||||
|
||||
const float MODEL_X_TWO_PLAYERS[NUM_PLAYERS] = { +8, -8 };
|
||||
const float MODEL_ROTATIONY_TWO_PLAYERS[NUM_PLAYERS] = { -90, 90 };
|
||||
|
||||
DancingCharacters::DancingCharacters(): m_bDrawDangerLight(false),
|
||||
m_CameraDistance(0), m_CameraPanYStart(0), m_CameraPanYEnd(0),
|
||||
m_fLookAtHeight(0), m_fCameraHeightStart(0), m_fCameraHeightEnd(0),
|
||||
m_fThisCameraStartBeat(0), m_fThisCameraEndBeat(0)
|
||||
{
|
||||
FOREACH_PlayerNumber( p )
|
||||
{
|
||||
m_pCharacter[p] = new Model;
|
||||
m_2DIdleTimer[p].SetZero();
|
||||
m_i2DAnimState[p] = AS2D_IDLE; // start on idle state
|
||||
if( !GAMESTATE->IsPlayerEnabled(p) )
|
||||
continue;
|
||||
|
||||
Character* pChar = GAMESTATE->m_pCurCharacters[p];
|
||||
if( !pChar )
|
||||
continue;
|
||||
|
||||
// load in any potential 2D stuff
|
||||
RString sCharacterDirectory = pChar->m_sCharDir;
|
||||
RString sCurrentAnim;
|
||||
sCurrentAnim = sCharacterDirectory + "2DIdle";
|
||||
if( DoesFileExist(sCurrentAnim + "/BGAnimation.ini") ) // check 2D Idle BGAnim exists
|
||||
{
|
||||
m_bgIdle[p].Load( sCurrentAnim );
|
||||
m_bgIdle[p]->SetXY(DC_X(p),DC_Y(p));
|
||||
}
|
||||
|
||||
sCurrentAnim = sCharacterDirectory + "2DMiss";
|
||||
if( DoesFileExist(sCurrentAnim + "/BGAnimation.ini") ) // check 2D Idle BGAnim exists
|
||||
{
|
||||
m_bgMiss[p].Load( sCurrentAnim );
|
||||
m_bgMiss[p]->SetXY(DC_X(p),DC_Y(p));
|
||||
}
|
||||
|
||||
sCurrentAnim = sCharacterDirectory + "2DGood";
|
||||
if( DoesFileExist(sCurrentAnim + "/BGAnimation.ini") ) // check 2D Idle BGAnim exists
|
||||
{
|
||||
m_bgGood[p].Load( sCurrentAnim );
|
||||
m_bgGood[p]->SetXY(DC_X(p),DC_Y(p));
|
||||
}
|
||||
|
||||
sCurrentAnim = sCharacterDirectory + "2DGreat";
|
||||
if( DoesFileExist(sCurrentAnim + "/BGAnimation.ini") ) // check 2D Idle BGAnim exists
|
||||
{
|
||||
m_bgGreat[p].Load( sCurrentAnim );
|
||||
m_bgGreat[p]->SetXY(DC_X(p),DC_Y(p));
|
||||
}
|
||||
|
||||
sCurrentAnim = sCharacterDirectory + "2DFever";
|
||||
if( DoesFileExist(sCurrentAnim + "/BGAnimation.ini") ) // check 2D Idle BGAnim exists
|
||||
{
|
||||
m_bgFever[p].Load( sCurrentAnim );
|
||||
m_bgFever[p]->SetXY(DC_X(p),DC_Y(p));
|
||||
}
|
||||
|
||||
sCurrentAnim = sCharacterDirectory + "2DFail";
|
||||
if( DoesFileExist(sCurrentAnim + "/BGAnimation.ini") ) // check 2D Idle BGAnim exists
|
||||
{
|
||||
m_bgFail[p].Load( sCurrentAnim );
|
||||
m_bgFail[p]->SetXY(DC_X(p),DC_Y(p));
|
||||
}
|
||||
|
||||
sCurrentAnim = sCharacterDirectory + "2DWin";
|
||||
if( DoesFileExist(sCurrentAnim + "/BGAnimation.ini") ) // check 2D Idle BGAnim exists
|
||||
{
|
||||
m_bgWin[p].Load( sCurrentAnim );
|
||||
m_bgWin[p]->SetXY(DC_X(p),DC_Y(p));
|
||||
}
|
||||
|
||||
sCurrentAnim = sCharacterDirectory + "2DWinFever";
|
||||
if( DoesFileExist(sCurrentAnim + "/BGAnimation.ini") ) // check 2D Idle BGAnim exists
|
||||
{
|
||||
m_bgWinFever[p].Load( sCurrentAnim );
|
||||
m_bgWinFever[p]->SetXY(DC_X(p),DC_Y(p));
|
||||
}
|
||||
|
||||
if( pChar->GetModelPath().empty() )
|
||||
continue;
|
||||
|
||||
if( GAMESTATE->GetNumPlayersEnabled()==2 )
|
||||
m_pCharacter[p]->SetX( MODEL_X_TWO_PLAYERS[p] );
|
||||
else
|
||||
m_pCharacter[p]->SetX( MODEL_X_ONE_PLAYER );
|
||||
|
||||
switch( GAMESTATE->m_PlayMode )
|
||||
{
|
||||
case PLAY_MODE_BATTLE:
|
||||
case PLAY_MODE_RAVE:
|
||||
m_pCharacter[p]->SetRotationY( MODEL_ROTATIONY_TWO_PLAYERS[p] );
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
m_pCharacter[p]->LoadMilkshapeAscii( pChar->GetModelPath() );
|
||||
m_pCharacter[p]->LoadMilkshapeAsciiBones( "rest", pChar->GetRestAnimationPath() );
|
||||
m_pCharacter[p]->LoadMilkshapeAsciiBones( "warmup", pChar->GetWarmUpAnimationPath() );
|
||||
m_pCharacter[p]->LoadMilkshapeAsciiBones( "dance", pChar->GetDanceAnimationPath() );
|
||||
m_pCharacter[p]->SetCullMode( CULL_NONE ); // many of the models floating around have the vertex order flipped
|
||||
|
||||
m_pCharacter[p]->RunCommands( pChar->m_cmdInit );
|
||||
}
|
||||
}
|
||||
|
||||
DancingCharacters::~DancingCharacters()
|
||||
{
|
||||
FOREACH_PlayerNumber( p )
|
||||
delete m_pCharacter[p];
|
||||
}
|
||||
|
||||
void DancingCharacters::LoadNextSong()
|
||||
{
|
||||
// initial camera sweep is still
|
||||
m_CameraDistance = CAMERA_REST_DISTANCE;
|
||||
m_CameraPanYStart = 0;
|
||||
m_CameraPanYEnd = 0;
|
||||
m_fCameraHeightStart = CAMERA_REST_LOOK_AT_HEIGHT;
|
||||
m_fCameraHeightEnd = CAMERA_REST_LOOK_AT_HEIGHT;
|
||||
m_fLookAtHeight = CAMERA_REST_LOOK_AT_HEIGHT;
|
||||
m_fThisCameraStartBeat = 0;
|
||||
m_fThisCameraEndBeat = 0;
|
||||
|
||||
ASSERT( GAMESTATE->m_pCurSong != NULL );
|
||||
m_fThisCameraEndBeat = GAMESTATE->m_pCurSong->GetFirstBeat();
|
||||
|
||||
FOREACH_PlayerNumber( p )
|
||||
if( GAMESTATE->IsPlayerEnabled(p) )
|
||||
m_pCharacter[p]->PlayAnimation( "rest" );
|
||||
}
|
||||
|
||||
int Neg1OrPos1() { return RandomInt( 2 ) ? -1 : +1; }
|
||||
|
||||
void DancingCharacters::Update( float fDelta )
|
||||
{
|
||||
if( GAMESTATE->m_Position.m_bFreeze || GAMESTATE->m_Position.m_bDelay )
|
||||
{
|
||||
// spin the camera Matrix-style
|
||||
m_CameraPanYStart += fDelta*40;
|
||||
m_CameraPanYEnd += fDelta*40;
|
||||
}
|
||||
else
|
||||
{
|
||||
// make the characters move
|
||||
float fBPM = GAMESTATE->m_Position.m_fCurBPS*60;
|
||||
float fUpdateScale = SCALE( fBPM, 60.f, 300.f, 0.75f, 1.5f );
|
||||
CLAMP( fUpdateScale, 0.75f, 1.5f );
|
||||
|
||||
/* It's OK for the animation to go slower than natural when we're
|
||||
* at a very low music rate. */
|
||||
fUpdateScale *= GAMESTATE->m_SongOptions.GetCurrent().m_fMusicRate;
|
||||
|
||||
FOREACH_PlayerNumber( p )
|
||||
{
|
||||
if( GAMESTATE->IsPlayerEnabled(p) )
|
||||
m_pCharacter[p]->Update( fDelta*fUpdateScale );
|
||||
}
|
||||
}
|
||||
|
||||
static bool bWasGameplayStarting = false;
|
||||
bool bGameplayStarting = GAMESTATE->m_bGameplayLeadIn;
|
||||
if( !bWasGameplayStarting && bGameplayStarting )
|
||||
{
|
||||
FOREACH_PlayerNumber( p )
|
||||
if( GAMESTATE->IsPlayerEnabled(p) )
|
||||
m_pCharacter[p]->PlayAnimation( "warmup" );
|
||||
}
|
||||
bWasGameplayStarting = bGameplayStarting;
|
||||
|
||||
static float fLastBeat = GAMESTATE->m_Position.m_fSongBeat;
|
||||
float firstBeat = GAMESTATE->m_pCurSong->GetFirstBeat();
|
||||
float fThisBeat = GAMESTATE->m_Position.m_fSongBeat;
|
||||
if( fLastBeat < firstBeat && fThisBeat >= firstBeat )
|
||||
{
|
||||
FOREACH_PlayerNumber( p )
|
||||
m_pCharacter[p]->PlayAnimation( "dance" );
|
||||
}
|
||||
fLastBeat = fThisBeat;
|
||||
|
||||
// time for a new sweep?
|
||||
if (GAMESTATE->m_Position.m_fSongBeat > m_fThisCameraEndBeat)
|
||||
{
|
||||
if (RandomInt(6) >= 4)
|
||||
{
|
||||
// sweeping camera
|
||||
m_CameraDistance = CAMERA_SWEEP_DISTANCE + RandomInt(-1, 1) * CAMERA_SWEEP_DISTANCE_VARIANCE;
|
||||
m_CameraPanYStart = m_CameraPanYEnd = RandomInt(-1, 1) * CAMERA_SWEEP_PAN_Y_RANGE_DEGREES;
|
||||
m_fCameraHeightStart = m_fCameraHeightEnd = CAMERA_STILL_LOOK_AT_HEIGHT;
|
||||
|
||||
m_CameraPanYEnd += RandomInt(-1, 1) * CAMERA_SWEEP_PAN_Y_VARIANCE_DEGREES;
|
||||
m_fCameraHeightStart = m_fCameraHeightEnd = m_fCameraHeightStart + RandomInt(-1, 1) * CAMERA_SWEEP_HEIGHT_VARIANCE;
|
||||
|
||||
float fCameraHeightVariance = RandomInt(-1, 1) * CAMERA_SWEEP_HEIGHT_VARIANCE;
|
||||
m_fCameraHeightStart -= fCameraHeightVariance;
|
||||
m_fCameraHeightEnd += fCameraHeightVariance;
|
||||
|
||||
m_fLookAtHeight = CAMERA_SWEEP_LOOK_AT_HEIGHT;
|
||||
}
|
||||
else
|
||||
{
|
||||
// still camera
|
||||
m_CameraDistance = CAMERA_STILL_DISTANCE + RandomInt(-1, 1) * CAMERA_STILL_DISTANCE_VARIANCE;
|
||||
m_CameraPanYStart = m_CameraPanYEnd = Neg1OrPos1() * CAMERA_STILL_PAN_Y_RANGE_DEGREES;
|
||||
m_fCameraHeightStart = m_fCameraHeightEnd = CAMERA_SWEEP_LOOK_AT_HEIGHT + Neg1OrPos1() * CAMERA_STILL_HEIGHT_VARIANCE;
|
||||
|
||||
m_fLookAtHeight = CAMERA_STILL_LOOK_AT_HEIGHT;
|
||||
}
|
||||
|
||||
int iCurBeat = (int)GAMESTATE->m_Position.m_fSongBeat;
|
||||
// Need to convert it to a int, otherwise it complains.
|
||||
int NewBeatToSet = (int)AMM_BEATS_TIL_NEXTCAMERA;
|
||||
iCurBeat -= iCurBeat % NewBeatToSet;
|
||||
|
||||
m_fThisCameraStartBeat = (float)iCurBeat;
|
||||
m_fThisCameraEndBeat = float(iCurBeat + AMM_BEATS_TIL_NEXTCAMERA);
|
||||
}
|
||||
/*
|
||||
// is there any of this still around? This block of code is _ugly_. -Colby
|
||||
// update any 2D stuff
|
||||
FOREACH_PlayerNumber( p )
|
||||
{
|
||||
if( m_bgIdle[p].IsLoaded() )
|
||||
{
|
||||
if( m_bgIdle[p].IsLoaded() && m_i2DAnimState[p] == AS2D_IDLE )
|
||||
m_bgIdle[p]->Update( fDelta );
|
||||
if( m_bgMiss[p].IsLoaded() && m_i2DAnimState[p] == AS2D_MISS )
|
||||
m_bgMiss[p]->Update( fDelta );
|
||||
if( m_bgGood[p].IsLoaded() && m_i2DAnimState[p] == AS2D_GOOD )
|
||||
m_bgGood[p]->Update( fDelta );
|
||||
if( m_bgGreat[p].IsLoaded() && m_i2DAnimState[p] == AS2D_GREAT )
|
||||
m_bgGreat[p]->Update( fDelta );
|
||||
if( m_bgFever[p].IsLoaded() && m_i2DAnimState[p] == AS2D_FEVER )
|
||||
m_bgFever[p]->Update( fDelta );
|
||||
if( m_bgFail[p].IsLoaded() && m_i2DAnimState[p] == AS2D_FAIL )
|
||||
m_bgFail[p]->Update( fDelta );
|
||||
if( m_bgWin[p].IsLoaded() && m_i2DAnimState[p] == AS2D_WIN )
|
||||
m_bgWin[p]->Update( fDelta );
|
||||
if( m_bgWinFever[p].IsLoaded() && m_i2DAnimState[p] == AS2D_WINFEVER )
|
||||
m_bgWinFever[p]->Update(fDelta);
|
||||
|
||||
if(m_i2DAnimState[p] != AS2D_IDLE) // if we're not in idle state, start a timer to return us to idle
|
||||
{
|
||||
// never return to idle state if we have failed / passed (i.e. completed) the song
|
||||
if(m_i2DAnimState[p] != AS2D_WINFEVER && m_i2DAnimState[p] != AS2D_FAIL && m_i2DAnimState[p] != AS2D_WIN)
|
||||
{
|
||||
if(m_2DIdleTimer[p].IsZero())
|
||||
m_2DIdleTimer[p].Touch();
|
||||
if(!m_2DIdleTimer[p].IsZero() && m_2DIdleTimer[p].Ago() > 1.0f)
|
||||
{
|
||||
m_2DIdleTimer[p].SetZero();
|
||||
m_i2DAnimState[p] = AS2D_IDLE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
void DancingCharacters::Change2DAnimState( PlayerNumber pn, int iState )
|
||||
{
|
||||
ASSERT( pn < NUM_PLAYERS );
|
||||
ASSERT( iState < AS2D_MAXSTATES );
|
||||
|
||||
m_i2DAnimState[pn] = iState;
|
||||
}
|
||||
|
||||
void DancingCharacters::DrawPrimitives()
|
||||
{
|
||||
DISPLAY->CameraPushMatrix();
|
||||
|
||||
float fPercentIntoSweep;
|
||||
if(m_fThisCameraStartBeat == m_fThisCameraEndBeat)
|
||||
fPercentIntoSweep = 0;
|
||||
else
|
||||
fPercentIntoSweep = SCALE(GAMESTATE->m_Position.m_fSongBeat, m_fThisCameraStartBeat, m_fThisCameraEndBeat, 0.f, 1.f );
|
||||
float fCameraPanY = SCALE( fPercentIntoSweep, 0.f, 1.f, m_CameraPanYStart, m_CameraPanYEnd );
|
||||
float fCameraHeight = SCALE( fPercentIntoSweep, 0.f, 1.f, m_fCameraHeightStart, m_fCameraHeightEnd );
|
||||
|
||||
RageVector3 m_CameraPoint( 0, fCameraHeight, -m_CameraDistance );
|
||||
RageMatrix CameraRot;
|
||||
RageMatrixRotationY( &CameraRot, fCameraPanY );
|
||||
RageVec3TransformCoord( &m_CameraPoint, &m_CameraPoint, &CameraRot );
|
||||
|
||||
RageVector3 m_LookAt( 0, m_fLookAtHeight, 0 );
|
||||
|
||||
DISPLAY->LoadLookAt( CAM_FOV,
|
||||
m_CameraPoint,
|
||||
m_LookAt,
|
||||
RageVector3(0,1,0) );
|
||||
|
||||
FOREACH_EnabledPlayer( p )
|
||||
{
|
||||
bool bFailed = STATSMAN->m_CurStageStats.m_player[p].m_bFailed;
|
||||
bool bDanger = m_bDrawDangerLight;
|
||||
|
||||
DISPLAY->SetLighting( true );
|
||||
|
||||
RageColor ambient = bFailed ? (RageColor)LIGHT_ADANGER_COLOR : (bDanger ? (RageColor)LIGHT_ADANGER_COLOR : (RageColor)LIGHT_AMBIENT_COLOR);
|
||||
RageColor diffuse = bFailed ? (RageColor)LIGHT_DDANGER_COLOR : (bDanger ? (RageColor)LIGHT_DDANGER_COLOR : (RageColor)LIGHT_DIFFUSE_COLOR);
|
||||
RageColor specular = (RageColor)LIGHT_AMBIENT_COLOR;
|
||||
DISPLAY->SetLightDirectional(
|
||||
0,
|
||||
ambient,
|
||||
diffuse,
|
||||
specular,
|
||||
RageVector3(LIGHTING_X, LIGHTING_Y, LIGHTING_Z) );
|
||||
|
||||
if( PREFSMAN->m_bCelShadeModels )
|
||||
{
|
||||
m_pCharacter[p]->DrawCelShaded();
|
||||
|
||||
DISPLAY->SetLightOff( 0 );
|
||||
DISPLAY->SetLighting( false );
|
||||
continue;
|
||||
}
|
||||
|
||||
m_pCharacter[p]->Draw();
|
||||
|
||||
DISPLAY->SetLightOff( 0 );
|
||||
DISPLAY->SetLighting( false );
|
||||
}
|
||||
|
||||
DISPLAY->CameraPopMatrix();
|
||||
|
||||
/*
|
||||
// Ugly! -Colby
|
||||
// now draw any potential 2D stuff
|
||||
FOREACH_PlayerNumber( p )
|
||||
{
|
||||
if(m_bgIdle[p].IsLoaded() && m_i2DAnimState[p] == AS2D_IDLE)
|
||||
m_bgIdle[p]->Draw();
|
||||
if(m_bgMiss[p].IsLoaded() && m_i2DAnimState[p] == AS2D_MISS)
|
||||
m_bgMiss[p]->Draw();
|
||||
if(m_bgGood[p].IsLoaded() && m_i2DAnimState[p] == AS2D_GOOD)
|
||||
m_bgGood[p]->Draw();
|
||||
if(m_bgGreat[p].IsLoaded() && m_i2DAnimState[p] == AS2D_GREAT)
|
||||
m_bgGreat[p]->Draw();
|
||||
if(m_bgFever[p].IsLoaded() && m_i2DAnimState[p] == AS2D_FEVER)
|
||||
m_bgFever[p]->Draw();
|
||||
if(m_bgWinFever[p].IsLoaded() && m_i2DAnimState[p] == AS2D_WINFEVER)
|
||||
m_bgWinFever[p]->Draw();
|
||||
if(m_bgWin[p].IsLoaded() && m_i2DAnimState[p] == AS2D_WIN)
|
||||
m_bgWin[p]->Draw();
|
||||
if(m_bgFail[p].IsLoaded() && m_i2DAnimState[p] == AS2D_FAIL)
|
||||
m_bgFail[p]->Draw();
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
/* 2018 Jose Varela
|
||||
* (c) 2003-2004 Chris Danford
|
||||
* All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* 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.
|
||||
*/
|
||||
#include "global.h"
|
||||
#include "DancingCharacters.h"
|
||||
#include "GameConstantsAndTypes.h"
|
||||
#include "RageDisplay.h"
|
||||
#include "RageUtil.h"
|
||||
#include "RageMath.h"
|
||||
#include "GameState.h"
|
||||
#include "Song.h"
|
||||
#include "Character.h"
|
||||
#include "StatsManager.h"
|
||||
#include "PrefsManager.h"
|
||||
#include "Model.h"
|
||||
|
||||
int Neg1OrPos1();
|
||||
|
||||
#define DC_X( choice ) THEME->GetMetricF("DancingCharacters",ssprintf("2DCharacterXP%d",choice+1))
|
||||
#define DC_Y( choice ) THEME->GetMetricF("DancingCharacters",ssprintf("2DCharacterYP%d",choice+1))
|
||||
|
||||
/*
|
||||
* TODO:
|
||||
* - Metrics/Lua for lighting and camera sweeping.
|
||||
* - Ability to load secondary elements i.e. stages.
|
||||
* - Remove support for 2D characters (Lua can do it).
|
||||
* - Cleanup!
|
||||
*
|
||||
* -- Colby
|
||||
*/
|
||||
|
||||
#define CAMERA_REST_DISTANCE THEME->GetMetricF("DancingCamera","RestDistance")
|
||||
#define CAMERA_REST_LOOK_AT_HEIGHT THEME->GetMetricF("DancingCamera","RestHeight")
|
||||
#define CAMERA_SWEEP_DISTANCE THEME->GetMetricF("DancingCamera","SweepDistance")
|
||||
#define CAMERA_SWEEP_DISTANCE_VARIANCE THEME->GetMetricF("DancingCamera","SweepDistanceVariable")
|
||||
#define CAMERA_SWEEP_HEIGHT_VARIANCE THEME->GetMetricF("DancingCamera","SweepHeightVariable")
|
||||
#define CAMERA_SWEEP_PAN_Y_RANGE_DEGREES THEME->GetMetricF("DancingCamera","SweepPanYRangeDegrees")
|
||||
#define CAMERA_SWEEP_PAN_Y_VARIANCE_DEGREES THEME->GetMetricF("DancingCamera","SweepPanYVarianceDegrees")
|
||||
#define CAMERA_SWEEP_LOOK_AT_HEIGHT THEME->GetMetricF("DancingCamera","SweepHeight")
|
||||
#define CAMERA_STILL_DISTANCE THEME->GetMetricF("DancingCamera","StillDistance")
|
||||
#define CAMERA_STILL_DISTANCE_VARIANCE THEME->GetMetricF("DancingCamera","StillDistanceVariance")
|
||||
#define CAMERA_STILL_PAN_Y_RANGE_DEGREES THEME->GetMetricF("DancingCamera","StillPanYRangeDegrees")
|
||||
#define CAMERA_STILL_HEIGHT_VARIANCE THEME->GetMetricF("DancingCamera","StillHeightVariance")
|
||||
#define CAMERA_STILL_LOOK_AT_HEIGHT THEME->GetMetricF("DancingCamera","StillHeight")
|
||||
|
||||
// This is to setup the lighting color.
|
||||
const ThemeMetric<RageColor> LIGHT_AMBIENT_COLOR ( "DancingCamera", "AmbientColor" );
|
||||
const ThemeMetric<RageColor> LIGHT_DIFFUSE_COLOR ( "DancingCamera", "DiffuseColor" );
|
||||
|
||||
// This is for Danger and Failed colors.
|
||||
const ThemeMetric<RageColor> LIGHT_ADANGER_COLOR ( "DancingCamera", "AmbientDangerColor" );
|
||||
const ThemeMetric<RageColor> LIGHT_AFAILED_COLOR ( "DancingCamera", "AmbientFailedColor" );
|
||||
const ThemeMetric<RageColor> LIGHT_DDANGER_COLOR ( "DancingCamera", "DiffuseDangerColor" );
|
||||
const ThemeMetric<RageColor> LIGHT_DFAILED_COLOR ( "DancingCamera", "DiffuseFailedColor" );
|
||||
|
||||
// This is to make positioning of said light.
|
||||
#define LIGHTING_X THEME->GetMetricF("DancingCamera","LightX")
|
||||
#define LIGHTING_Y THEME->GetMetricF("DancingCamera","LightY")
|
||||
#define LIGHTING_Z THEME->GetMetricF("DancingCamera","LightZ")
|
||||
|
||||
// Position of the model in X (one player)
|
||||
#define MODEL_X_ONE_PLAYER THEME->GetMetricF("DancingCharacters","OnePlayerModelX")
|
||||
|
||||
// As the name implies, this sets the ammount of beats that the camera will
|
||||
// stay in its current state until transitioning to the next camera tween.
|
||||
#define AMM_BEATS_TIL_NEXTCAMERA THEME->GetMetricF("DancingCamera","BeatsUntilNextCamPos")
|
||||
#define CAM_FOV THEME->GetMetricF("DancingCamera","CameraFOV")
|
||||
|
||||
const float MODEL_X_TWO_PLAYERS[NUM_PLAYERS] = { +8, -8 };
|
||||
const float MODEL_ROTATIONY_TWO_PLAYERS[NUM_PLAYERS] = { -90, 90 };
|
||||
|
||||
DancingCharacters::DancingCharacters(): m_bDrawDangerLight(false),
|
||||
m_CameraDistance(0), m_CameraPanYStart(0), m_CameraPanYEnd(0),
|
||||
m_fLookAtHeight(0), m_fCameraHeightStart(0), m_fCameraHeightEnd(0),
|
||||
m_fThisCameraStartBeat(0), m_fThisCameraEndBeat(0)
|
||||
{
|
||||
FOREACH_PlayerNumber( p )
|
||||
{
|
||||
m_pCharacter[p] = new Model;
|
||||
m_2DIdleTimer[p].SetZero();
|
||||
m_i2DAnimState[p] = AS2D_IDLE; // start on idle state
|
||||
if( !GAMESTATE->IsPlayerEnabled(p) )
|
||||
continue;
|
||||
|
||||
Character* pChar = GAMESTATE->m_pCurCharacters[p];
|
||||
if( !pChar )
|
||||
continue;
|
||||
|
||||
// load in any potential 2D stuff
|
||||
RString sCharacterDirectory = pChar->m_sCharDir;
|
||||
RString sCurrentAnim;
|
||||
sCurrentAnim = sCharacterDirectory + "2DIdle";
|
||||
if( DoesFileExist(sCurrentAnim + "/BGAnimation.ini") ) // check 2D Idle BGAnim exists
|
||||
{
|
||||
m_bgIdle[p].Load( sCurrentAnim );
|
||||
m_bgIdle[p]->SetXY(DC_X(p),DC_Y(p));
|
||||
}
|
||||
|
||||
sCurrentAnim = sCharacterDirectory + "2DMiss";
|
||||
if( DoesFileExist(sCurrentAnim + "/BGAnimation.ini") ) // check 2D Idle BGAnim exists
|
||||
{
|
||||
m_bgMiss[p].Load( sCurrentAnim );
|
||||
m_bgMiss[p]->SetXY(DC_X(p),DC_Y(p));
|
||||
}
|
||||
|
||||
sCurrentAnim = sCharacterDirectory + "2DGood";
|
||||
if( DoesFileExist(sCurrentAnim + "/BGAnimation.ini") ) // check 2D Idle BGAnim exists
|
||||
{
|
||||
m_bgGood[p].Load( sCurrentAnim );
|
||||
m_bgGood[p]->SetXY(DC_X(p),DC_Y(p));
|
||||
}
|
||||
|
||||
sCurrentAnim = sCharacterDirectory + "2DGreat";
|
||||
if( DoesFileExist(sCurrentAnim + "/BGAnimation.ini") ) // check 2D Idle BGAnim exists
|
||||
{
|
||||
m_bgGreat[p].Load( sCurrentAnim );
|
||||
m_bgGreat[p]->SetXY(DC_X(p),DC_Y(p));
|
||||
}
|
||||
|
||||
sCurrentAnim = sCharacterDirectory + "2DFever";
|
||||
if( DoesFileExist(sCurrentAnim + "/BGAnimation.ini") ) // check 2D Idle BGAnim exists
|
||||
{
|
||||
m_bgFever[p].Load( sCurrentAnim );
|
||||
m_bgFever[p]->SetXY(DC_X(p),DC_Y(p));
|
||||
}
|
||||
|
||||
sCurrentAnim = sCharacterDirectory + "2DFail";
|
||||
if( DoesFileExist(sCurrentAnim + "/BGAnimation.ini") ) // check 2D Idle BGAnim exists
|
||||
{
|
||||
m_bgFail[p].Load( sCurrentAnim );
|
||||
m_bgFail[p]->SetXY(DC_X(p),DC_Y(p));
|
||||
}
|
||||
|
||||
sCurrentAnim = sCharacterDirectory + "2DWin";
|
||||
if( DoesFileExist(sCurrentAnim + "/BGAnimation.ini") ) // check 2D Idle BGAnim exists
|
||||
{
|
||||
m_bgWin[p].Load( sCurrentAnim );
|
||||
m_bgWin[p]->SetXY(DC_X(p),DC_Y(p));
|
||||
}
|
||||
|
||||
sCurrentAnim = sCharacterDirectory + "2DWinFever";
|
||||
if( DoesFileExist(sCurrentAnim + "/BGAnimation.ini") ) // check 2D Idle BGAnim exists
|
||||
{
|
||||
m_bgWinFever[p].Load( sCurrentAnim );
|
||||
m_bgWinFever[p]->SetXY(DC_X(p),DC_Y(p));
|
||||
}
|
||||
|
||||
if( pChar->GetModelPath().empty() )
|
||||
continue;
|
||||
|
||||
if( GAMESTATE->GetNumPlayersEnabled()==2 )
|
||||
m_pCharacter[p]->SetX( MODEL_X_TWO_PLAYERS[p] );
|
||||
else
|
||||
m_pCharacter[p]->SetX( MODEL_X_ONE_PLAYER );
|
||||
|
||||
switch( GAMESTATE->m_PlayMode )
|
||||
{
|
||||
case PLAY_MODE_BATTLE:
|
||||
case PLAY_MODE_RAVE:
|
||||
m_pCharacter[p]->SetRotationY( MODEL_ROTATIONY_TWO_PLAYERS[p] );
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
m_pCharacter[p]->LoadMilkshapeAscii( pChar->GetModelPath() );
|
||||
m_pCharacter[p]->LoadMilkshapeAsciiBones( "rest", pChar->GetRestAnimationPath() );
|
||||
m_pCharacter[p]->LoadMilkshapeAsciiBones( "warmup", pChar->GetWarmUpAnimationPath() );
|
||||
m_pCharacter[p]->LoadMilkshapeAsciiBones( "dance", pChar->GetDanceAnimationPath() );
|
||||
m_pCharacter[p]->SetCullMode( CULL_NONE ); // many of the models floating around have the vertex order flipped
|
||||
|
||||
m_pCharacter[p]->RunCommands( pChar->m_cmdInit );
|
||||
}
|
||||
}
|
||||
|
||||
DancingCharacters::~DancingCharacters()
|
||||
{
|
||||
FOREACH_PlayerNumber( p )
|
||||
delete m_pCharacter[p];
|
||||
}
|
||||
|
||||
void DancingCharacters::LoadNextSong()
|
||||
{
|
||||
// initial camera sweep is still
|
||||
m_CameraDistance = CAMERA_REST_DISTANCE;
|
||||
m_CameraPanYStart = 0;
|
||||
m_CameraPanYEnd = 0;
|
||||
m_fCameraHeightStart = CAMERA_REST_LOOK_AT_HEIGHT;
|
||||
m_fCameraHeightEnd = CAMERA_REST_LOOK_AT_HEIGHT;
|
||||
m_fLookAtHeight = CAMERA_REST_LOOK_AT_HEIGHT;
|
||||
m_fThisCameraStartBeat = 0;
|
||||
m_fThisCameraEndBeat = 0;
|
||||
|
||||
ASSERT( GAMESTATE->m_pCurSong != nullptr );
|
||||
m_fThisCameraEndBeat = GAMESTATE->m_pCurSong->GetFirstBeat();
|
||||
|
||||
FOREACH_PlayerNumber( p )
|
||||
if( GAMESTATE->IsPlayerEnabled(p) )
|
||||
m_pCharacter[p]->PlayAnimation( "rest" );
|
||||
}
|
||||
|
||||
int Neg1OrPos1() { return RandomInt( 2 ) ? -1 : +1; }
|
||||
|
||||
void DancingCharacters::Update( float fDelta )
|
||||
{
|
||||
if( GAMESTATE->m_Position.m_bFreeze || GAMESTATE->m_Position.m_bDelay )
|
||||
{
|
||||
// spin the camera Matrix-style
|
||||
m_CameraPanYStart += fDelta*40;
|
||||
m_CameraPanYEnd += fDelta*40;
|
||||
}
|
||||
else
|
||||
{
|
||||
// make the characters move
|
||||
float fBPM = GAMESTATE->m_Position.m_fCurBPS*60;
|
||||
float fUpdateScale = SCALE( fBPM, 60.f, 300.f, 0.75f, 1.5f );
|
||||
CLAMP( fUpdateScale, 0.75f, 1.5f );
|
||||
|
||||
/* It's OK for the animation to go slower than natural when we're
|
||||
* at a very low music rate. */
|
||||
fUpdateScale *= GAMESTATE->m_SongOptions.GetCurrent().m_fMusicRate;
|
||||
|
||||
FOREACH_PlayerNumber( p )
|
||||
{
|
||||
if( GAMESTATE->IsPlayerEnabled(p) )
|
||||
m_pCharacter[p]->Update( fDelta*fUpdateScale );
|
||||
}
|
||||
}
|
||||
|
||||
static bool bWasGameplayStarting = false;
|
||||
bool bGameplayStarting = GAMESTATE->m_bGameplayLeadIn;
|
||||
if( !bWasGameplayStarting && bGameplayStarting )
|
||||
{
|
||||
FOREACH_PlayerNumber( p )
|
||||
if( GAMESTATE->IsPlayerEnabled(p) )
|
||||
m_pCharacter[p]->PlayAnimation( "warmup" );
|
||||
}
|
||||
bWasGameplayStarting = bGameplayStarting;
|
||||
|
||||
static float fLastBeat = GAMESTATE->m_Position.m_fSongBeat;
|
||||
float firstBeat = GAMESTATE->m_pCurSong->GetFirstBeat();
|
||||
float fThisBeat = GAMESTATE->m_Position.m_fSongBeat;
|
||||
if( fLastBeat < firstBeat && fThisBeat >= firstBeat )
|
||||
{
|
||||
FOREACH_PlayerNumber( p )
|
||||
m_pCharacter[p]->PlayAnimation( "dance" );
|
||||
}
|
||||
fLastBeat = fThisBeat;
|
||||
|
||||
// time for a new sweep?
|
||||
if (GAMESTATE->m_Position.m_fSongBeat > m_fThisCameraEndBeat)
|
||||
{
|
||||
if (RandomInt(6) >= 4)
|
||||
{
|
||||
// sweeping camera
|
||||
m_CameraDistance = CAMERA_SWEEP_DISTANCE + RandomInt(-1, 1) * CAMERA_SWEEP_DISTANCE_VARIANCE;
|
||||
m_CameraPanYStart = m_CameraPanYEnd = RandomInt(-1, 1) * CAMERA_SWEEP_PAN_Y_RANGE_DEGREES;
|
||||
m_fCameraHeightStart = m_fCameraHeightEnd = CAMERA_STILL_LOOK_AT_HEIGHT;
|
||||
|
||||
m_CameraPanYEnd += RandomInt(-1, 1) * CAMERA_SWEEP_PAN_Y_VARIANCE_DEGREES;
|
||||
m_fCameraHeightStart = m_fCameraHeightEnd = m_fCameraHeightStart + RandomInt(-1, 1) * CAMERA_SWEEP_HEIGHT_VARIANCE;
|
||||
|
||||
float fCameraHeightVariance = RandomInt(-1, 1) * CAMERA_SWEEP_HEIGHT_VARIANCE;
|
||||
m_fCameraHeightStart -= fCameraHeightVariance;
|
||||
m_fCameraHeightEnd += fCameraHeightVariance;
|
||||
|
||||
m_fLookAtHeight = CAMERA_SWEEP_LOOK_AT_HEIGHT;
|
||||
}
|
||||
else
|
||||
{
|
||||
// still camera
|
||||
m_CameraDistance = CAMERA_STILL_DISTANCE + RandomInt(-1, 1) * CAMERA_STILL_DISTANCE_VARIANCE;
|
||||
m_CameraPanYStart = m_CameraPanYEnd = Neg1OrPos1() * CAMERA_STILL_PAN_Y_RANGE_DEGREES;
|
||||
m_fCameraHeightStart = m_fCameraHeightEnd = CAMERA_SWEEP_LOOK_AT_HEIGHT + Neg1OrPos1() * CAMERA_STILL_HEIGHT_VARIANCE;
|
||||
|
||||
m_fLookAtHeight = CAMERA_STILL_LOOK_AT_HEIGHT;
|
||||
}
|
||||
|
||||
int iCurBeat = (int)GAMESTATE->m_Position.m_fSongBeat;
|
||||
// Need to convert it to a int, otherwise it complains.
|
||||
int NewBeatToSet = (int)AMM_BEATS_TIL_NEXTCAMERA;
|
||||
iCurBeat -= iCurBeat % NewBeatToSet;
|
||||
|
||||
m_fThisCameraStartBeat = (float)iCurBeat;
|
||||
m_fThisCameraEndBeat = float(iCurBeat + AMM_BEATS_TIL_NEXTCAMERA);
|
||||
}
|
||||
/*
|
||||
// is there any of this still around? This block of code is _ugly_. -Colby
|
||||
// update any 2D stuff
|
||||
FOREACH_PlayerNumber( p )
|
||||
{
|
||||
if( m_bgIdle[p].IsLoaded() )
|
||||
{
|
||||
if( m_bgIdle[p].IsLoaded() && m_i2DAnimState[p] == AS2D_IDLE )
|
||||
m_bgIdle[p]->Update( fDelta );
|
||||
if( m_bgMiss[p].IsLoaded() && m_i2DAnimState[p] == AS2D_MISS )
|
||||
m_bgMiss[p]->Update( fDelta );
|
||||
if( m_bgGood[p].IsLoaded() && m_i2DAnimState[p] == AS2D_GOOD )
|
||||
m_bgGood[p]->Update( fDelta );
|
||||
if( m_bgGreat[p].IsLoaded() && m_i2DAnimState[p] == AS2D_GREAT )
|
||||
m_bgGreat[p]->Update( fDelta );
|
||||
if( m_bgFever[p].IsLoaded() && m_i2DAnimState[p] == AS2D_FEVER )
|
||||
m_bgFever[p]->Update( fDelta );
|
||||
if( m_bgFail[p].IsLoaded() && m_i2DAnimState[p] == AS2D_FAIL )
|
||||
m_bgFail[p]->Update( fDelta );
|
||||
if( m_bgWin[p].IsLoaded() && m_i2DAnimState[p] == AS2D_WIN )
|
||||
m_bgWin[p]->Update( fDelta );
|
||||
if( m_bgWinFever[p].IsLoaded() && m_i2DAnimState[p] == AS2D_WINFEVER )
|
||||
m_bgWinFever[p]->Update(fDelta);
|
||||
|
||||
if(m_i2DAnimState[p] != AS2D_IDLE) // if we're not in idle state, start a timer to return us to idle
|
||||
{
|
||||
// never return to idle state if we have failed / passed (i.e. completed) the song
|
||||
if(m_i2DAnimState[p] != AS2D_WINFEVER && m_i2DAnimState[p] != AS2D_FAIL && m_i2DAnimState[p] != AS2D_WIN)
|
||||
{
|
||||
if(m_2DIdleTimer[p].IsZero())
|
||||
m_2DIdleTimer[p].Touch();
|
||||
if(!m_2DIdleTimer[p].IsZero() && m_2DIdleTimer[p].Ago() > 1.0f)
|
||||
{
|
||||
m_2DIdleTimer[p].SetZero();
|
||||
m_i2DAnimState[p] = AS2D_IDLE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
void DancingCharacters::Change2DAnimState( PlayerNumber pn, int iState )
|
||||
{
|
||||
ASSERT( pn < NUM_PLAYERS );
|
||||
ASSERT( iState < AS2D_MAXSTATES );
|
||||
|
||||
m_i2DAnimState[pn] = iState;
|
||||
}
|
||||
|
||||
void DancingCharacters::DrawPrimitives()
|
||||
{
|
||||
DISPLAY->CameraPushMatrix();
|
||||
|
||||
float fPercentIntoSweep;
|
||||
if(m_fThisCameraStartBeat == m_fThisCameraEndBeat)
|
||||
fPercentIntoSweep = 0;
|
||||
else
|
||||
fPercentIntoSweep = SCALE(GAMESTATE->m_Position.m_fSongBeat, m_fThisCameraStartBeat, m_fThisCameraEndBeat, 0.f, 1.f );
|
||||
float fCameraPanY = SCALE( fPercentIntoSweep, 0.f, 1.f, m_CameraPanYStart, m_CameraPanYEnd );
|
||||
float fCameraHeight = SCALE( fPercentIntoSweep, 0.f, 1.f, m_fCameraHeightStart, m_fCameraHeightEnd );
|
||||
|
||||
RageVector3 m_CameraPoint( 0, fCameraHeight, -m_CameraDistance );
|
||||
RageMatrix CameraRot;
|
||||
RageMatrixRotationY( &CameraRot, fCameraPanY );
|
||||
RageVec3TransformCoord( &m_CameraPoint, &m_CameraPoint, &CameraRot );
|
||||
|
||||
RageVector3 m_LookAt( 0, m_fLookAtHeight, 0 );
|
||||
|
||||
DISPLAY->LoadLookAt( CAM_FOV,
|
||||
m_CameraPoint,
|
||||
m_LookAt,
|
||||
RageVector3(0,1,0) );
|
||||
|
||||
FOREACH_EnabledPlayer( p )
|
||||
{
|
||||
bool bFailed = STATSMAN->m_CurStageStats.m_player[p].m_bFailed;
|
||||
bool bDanger = m_bDrawDangerLight;
|
||||
|
||||
DISPLAY->SetLighting( true );
|
||||
|
||||
RageColor ambient = bFailed ? (RageColor)LIGHT_ADANGER_COLOR : (bDanger ? (RageColor)LIGHT_ADANGER_COLOR : (RageColor)LIGHT_AMBIENT_COLOR);
|
||||
RageColor diffuse = bFailed ? (RageColor)LIGHT_DDANGER_COLOR : (bDanger ? (RageColor)LIGHT_DDANGER_COLOR : (RageColor)LIGHT_DIFFUSE_COLOR);
|
||||
RageColor specular = (RageColor)LIGHT_AMBIENT_COLOR;
|
||||
DISPLAY->SetLightDirectional(
|
||||
0,
|
||||
ambient,
|
||||
diffuse,
|
||||
specular,
|
||||
RageVector3(LIGHTING_X, LIGHTING_Y, LIGHTING_Z) );
|
||||
|
||||
if( PREFSMAN->m_bCelShadeModels )
|
||||
{
|
||||
m_pCharacter[p]->DrawCelShaded();
|
||||
|
||||
DISPLAY->SetLightOff( 0 );
|
||||
DISPLAY->SetLighting( false );
|
||||
continue;
|
||||
}
|
||||
|
||||
m_pCharacter[p]->Draw();
|
||||
|
||||
DISPLAY->SetLightOff( 0 );
|
||||
DISPLAY->SetLighting( false );
|
||||
}
|
||||
|
||||
DISPLAY->CameraPopMatrix();
|
||||
|
||||
/*
|
||||
// Ugly! -Colby
|
||||
// now draw any potential 2D stuff
|
||||
FOREACH_PlayerNumber( p )
|
||||
{
|
||||
if(m_bgIdle[p].IsLoaded() && m_i2DAnimState[p] == AS2D_IDLE)
|
||||
m_bgIdle[p]->Draw();
|
||||
if(m_bgMiss[p].IsLoaded() && m_i2DAnimState[p] == AS2D_MISS)
|
||||
m_bgMiss[p]->Draw();
|
||||
if(m_bgGood[p].IsLoaded() && m_i2DAnimState[p] == AS2D_GOOD)
|
||||
m_bgGood[p]->Draw();
|
||||
if(m_bgGreat[p].IsLoaded() && m_i2DAnimState[p] == AS2D_GREAT)
|
||||
m_bgGreat[p]->Draw();
|
||||
if(m_bgFever[p].IsLoaded() && m_i2DAnimState[p] == AS2D_FEVER)
|
||||
m_bgFever[p]->Draw();
|
||||
if(m_bgWinFever[p].IsLoaded() && m_i2DAnimState[p] == AS2D_WINFEVER)
|
||||
m_bgWinFever[p]->Draw();
|
||||
if(m_bgWin[p].IsLoaded() && m_i2DAnimState[p] == AS2D_WIN)
|
||||
m_bgWin[p]->Draw();
|
||||
if(m_bgFail[p].IsLoaded() && m_i2DAnimState[p] == AS2D_FAIL)
|
||||
m_bgFail[p]->Draw();
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
/* 2018 Jose Varela
|
||||
* (c) 2003-2004 Chris Danford
|
||||
* All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* 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.
|
||||
*/
|
||||
|
||||
+97
-95
@@ -1,95 +1,97 @@
|
||||
#ifndef DancingCharacters_H
|
||||
#define DancingCharacters_H
|
||||
|
||||
#include "ActorFrame.h"
|
||||
#include "PlayerNumber.h"
|
||||
#include "ThemeManager.h"
|
||||
#include "RageTimer.h"
|
||||
#include "AutoActor.h"
|
||||
class Model;
|
||||
|
||||
/** @brief The different animation states for the dancer. */
|
||||
enum ANIM_STATES_2D
|
||||
{
|
||||
AS2D_IDLE = 0, /**< The dancer is idle. */
|
||||
AS2D_MISS, /**< The dancer just missed a note. */
|
||||
AS2D_GOOD, /**< The dancer is doing a good job. */
|
||||
AS2D_GREAT, /**< The dancer is doing a great job. */
|
||||
AS2D_FEVER, /**< The dancer is on fire! */
|
||||
AS2D_FAIL, /**< The dancer has failed. */
|
||||
AS2D_WIN, /**< The dancer has won. */
|
||||
AS2D_WINFEVER, /**< The dancer has won while on fire. */
|
||||
AS2D_IGNORE, /**< This is a special case -- so that we can timer to idle again. */
|
||||
AS2D_MAXSTATES /**< A count of the maximum number of states. */
|
||||
};
|
||||
|
||||
/** @brief Characters that react to how the players are doing. */
|
||||
class DancingCharacters : public ActorFrame
|
||||
{
|
||||
public:
|
||||
DancingCharacters();
|
||||
virtual ~DancingCharacters();
|
||||
|
||||
void LoadNextSong();
|
||||
|
||||
virtual void Update( float fDelta );
|
||||
virtual void DrawPrimitives();
|
||||
bool m_bDrawDangerLight;
|
||||
void Change2DAnimState( PlayerNumber pn, int iState );
|
||||
protected:
|
||||
|
||||
Model *m_pCharacter[NUM_PLAYERS];
|
||||
|
||||
/** @brief How far away is the camera from the dancer? */
|
||||
float m_CameraDistance;
|
||||
float m_CameraPanYStart;
|
||||
float m_CameraPanYEnd;
|
||||
float m_fLookAtHeight;
|
||||
float m_fCameraHeightStart;
|
||||
float m_fCameraHeightEnd;
|
||||
float m_fThisCameraStartBeat;
|
||||
float m_fThisCameraEndBeat;
|
||||
|
||||
bool m_bHas2DElements[NUM_PLAYERS];
|
||||
|
||||
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];
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @author Chris Danford (c) 2003-2004
|
||||
* @section LICENSE
|
||||
* All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* 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.
|
||||
*/
|
||||
#ifndef DancingCharacters_H
|
||||
#define DancingCharacters_H
|
||||
|
||||
#include "ActorFrame.h"
|
||||
#include "PlayerNumber.h"
|
||||
#include "ThemeManager.h"
|
||||
#include "RageTimer.h"
|
||||
#include "AutoActor.h"
|
||||
#include <array>
|
||||
class Model;
|
||||
|
||||
/** @brief The different animation states for the dancer. */
|
||||
enum ANIM_STATES_2D
|
||||
{
|
||||
AS2D_IDLE = 0, /**< The dancer is idle. */
|
||||
AS2D_MISS, /**< The dancer just missed a note. */
|
||||
AS2D_GOOD, /**< The dancer is doing a good job. */
|
||||
AS2D_GREAT, /**< The dancer is doing a great job. */
|
||||
AS2D_FEVER, /**< The dancer is on fire! */
|
||||
AS2D_FAIL, /**< The dancer has failed. */
|
||||
AS2D_WIN, /**< The dancer has won. */
|
||||
AS2D_WINFEVER, /**< The dancer has won while on fire. */
|
||||
AS2D_IGNORE, /**< This is a special case -- so that we can timer to idle again. */
|
||||
AS2D_MAXSTATES /**< A count of the maximum number of states. */
|
||||
};
|
||||
|
||||
/** @brief Characters that react to how the players are doing. */
|
||||
class DancingCharacters : public ActorFrame
|
||||
{
|
||||
public:
|
||||
DancingCharacters();
|
||||
virtual ~DancingCharacters();
|
||||
|
||||
void LoadNextSong();
|
||||
|
||||
virtual void Update( float fDelta );
|
||||
virtual void DrawPrimitives();
|
||||
bool m_bDrawDangerLight;
|
||||
void Change2DAnimState( PlayerNumber pn, int iState );
|
||||
protected:
|
||||
|
||||
std::array<Model *, NUM_PLAYERS> m_pCharacter;
|
||||
|
||||
/** @brief How far away is the camera from the dancer? */
|
||||
float m_CameraDistance;
|
||||
float m_CameraPanYStart;
|
||||
float m_CameraPanYEnd;
|
||||
float m_fLookAtHeight;
|
||||
float m_fCameraHeightStart;
|
||||
float m_fCameraHeightEnd;
|
||||
float m_fThisCameraStartBeat;
|
||||
float m_fThisCameraEndBeat;
|
||||
|
||||
std::array<bool, NUM_PLAYERS> m_bHas2DElements;
|
||||
|
||||
|
||||
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
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @author Chris Danford (c) 2003-2004
|
||||
* @section LICENSE
|
||||
* All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* 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.
|
||||
*/
|
||||
|
||||
+352
-352
@@ -1,352 +1,352 @@
|
||||
#include "global.h"
|
||||
#include "DateTime.h"
|
||||
#include "RageUtil.h"
|
||||
#include "EnumHelper.h"
|
||||
#include "LuaManager.h"
|
||||
#include "LocalizedString.h"
|
||||
|
||||
DateTime::DateTime()
|
||||
{
|
||||
Init();
|
||||
}
|
||||
|
||||
void DateTime::Init()
|
||||
{
|
||||
ZERO( *this );
|
||||
}
|
||||
|
||||
bool DateTime::operator<( const DateTime& other ) const
|
||||
{
|
||||
#define COMPARE( v ) if(v!=other.v) return v<other.v;
|
||||
COMPARE( tm_year );
|
||||
COMPARE( tm_mon );
|
||||
COMPARE( tm_mday );
|
||||
COMPARE( tm_hour );
|
||||
COMPARE( tm_min );
|
||||
COMPARE( tm_sec );
|
||||
#undef COMPARE
|
||||
// they're equal
|
||||
return false;
|
||||
}
|
||||
|
||||
bool DateTime::operator==( const DateTime& other ) const
|
||||
{
|
||||
#define COMPARE(x) if( x!=other.x ) return false;
|
||||
COMPARE( tm_year );
|
||||
COMPARE( tm_mon );
|
||||
COMPARE( tm_mday );
|
||||
COMPARE( tm_hour );
|
||||
COMPARE( tm_min );
|
||||
COMPARE( tm_sec );
|
||||
#undef COMPARE
|
||||
return true;
|
||||
}
|
||||
|
||||
bool DateTime::operator>( const DateTime& other ) const
|
||||
{
|
||||
#define COMPARE( v ) if(v!=other.v) return v>other.v;
|
||||
COMPARE( tm_year );
|
||||
COMPARE( tm_mon );
|
||||
COMPARE( tm_mday );
|
||||
COMPARE( tm_hour );
|
||||
COMPARE( tm_min );
|
||||
COMPARE( tm_sec );
|
||||
#undef COMPARE
|
||||
// they're equal
|
||||
return false;
|
||||
}
|
||||
|
||||
DateTime DateTime::GetNowDateTime()
|
||||
{
|
||||
time_t now = time(NULL);
|
||||
tm tNow;
|
||||
localtime_r( &now, &tNow );
|
||||
DateTime dtNow;
|
||||
#define COPY_M( v ) dtNow.v = tNow.v;
|
||||
COPY_M( tm_year );
|
||||
COPY_M( tm_mon );
|
||||
COPY_M( tm_mday );
|
||||
COPY_M( tm_hour );
|
||||
COPY_M( tm_min );
|
||||
COPY_M( tm_sec );
|
||||
#undef COPY_M
|
||||
return dtNow;
|
||||
}
|
||||
|
||||
DateTime DateTime::GetNowDate()
|
||||
{
|
||||
DateTime tNow = GetNowDateTime();
|
||||
tNow.StripTime();
|
||||
return tNow;
|
||||
}
|
||||
|
||||
void DateTime::StripTime()
|
||||
{
|
||||
tm_hour = 0;
|
||||
tm_min = 0;
|
||||
tm_sec = 0;
|
||||
}
|
||||
|
||||
// Common SQL/XML format: "YYYY-MM-DD HH:MM:SS"
|
||||
RString DateTime::GetString() const
|
||||
{
|
||||
RString s = ssprintf( "%d-%02d-%02d",
|
||||
tm_year+1900,
|
||||
tm_mon+1,
|
||||
tm_mday );
|
||||
|
||||
if( tm_hour != 0 ||
|
||||
tm_min != 0 ||
|
||||
tm_sec != 0 )
|
||||
{
|
||||
s += ssprintf( " %02d:%02d:%02d",
|
||||
tm_hour,
|
||||
tm_min,
|
||||
tm_sec );
|
||||
}
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
bool DateTime::FromString( const RString sDateTime )
|
||||
{
|
||||
Init();
|
||||
|
||||
int ret;
|
||||
|
||||
ret = sscanf( sDateTime, "%d-%d-%d %d:%d:%d",
|
||||
&tm_year,
|
||||
&tm_mon,
|
||||
&tm_mday,
|
||||
&tm_hour,
|
||||
&tm_min,
|
||||
&tm_sec );
|
||||
if( ret != 6 )
|
||||
{
|
||||
ret = sscanf( sDateTime, "%d-%d-%d",
|
||||
&tm_year,
|
||||
&tm_mon,
|
||||
&tm_mday );
|
||||
if( ret != 3 )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
tm_year -= 1900;
|
||||
tm_mon -= 1;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
RString DayInYearToString( int iDayInYear )
|
||||
{
|
||||
return ssprintf("DayInYear%03d",iDayInYear);
|
||||
}
|
||||
|
||||
int StringToDayInYear( RString sDayInYear )
|
||||
{
|
||||
int iDayInYear;
|
||||
if( sscanf( sDayInYear, "DayInYear%d", &iDayInYear ) != 1 )
|
||||
return -1;
|
||||
return iDayInYear;
|
||||
}
|
||||
|
||||
static const RString LAST_DAYS_NAME[NUM_LAST_DAYS] =
|
||||
{
|
||||
"Today",
|
||||
"Yesterday",
|
||||
"Day2Ago",
|
||||
"Day3Ago",
|
||||
"Day4Ago",
|
||||
"Day5Ago",
|
||||
"Day6Ago",
|
||||
};
|
||||
|
||||
RString LastDayToString( int iLastDayIndex )
|
||||
{
|
||||
return LAST_DAYS_NAME[iLastDayIndex];
|
||||
}
|
||||
|
||||
static const char *DAY_OF_WEEK_TO_NAME[DAYS_IN_WEEK] =
|
||||
{
|
||||
"Sunday",
|
||||
"Monday",
|
||||
"Tuesday",
|
||||
"Wednesday",
|
||||
"Thursday",
|
||||
"Friday",
|
||||
"Saturday",
|
||||
};
|
||||
|
||||
RString DayOfWeekToString( int iDayOfWeekIndex )
|
||||
{
|
||||
return DAY_OF_WEEK_TO_NAME[iDayOfWeekIndex];
|
||||
}
|
||||
|
||||
RString HourInDayToString( int iHourInDayIndex )
|
||||
{
|
||||
return ssprintf("Hour%02d", iHourInDayIndex);
|
||||
}
|
||||
|
||||
static const char *MonthNames[] =
|
||||
{
|
||||
"January",
|
||||
"February",
|
||||
"March",
|
||||
"April",
|
||||
"May",
|
||||
"June",
|
||||
"July",
|
||||
"August",
|
||||
"September",
|
||||
"October",
|
||||
"November",
|
||||
"December",
|
||||
};
|
||||
XToString( Month );
|
||||
XToLocalizedString( Month );
|
||||
LuaXType( Month );
|
||||
|
||||
RString LastWeekToString( int iLastWeekIndex )
|
||||
{
|
||||
switch( iLastWeekIndex )
|
||||
{
|
||||
case 0: return "ThisWeek"; break;
|
||||
case 1: return "LastWeek"; break;
|
||||
default: return ssprintf("Week%02dAgo",iLastWeekIndex); break;
|
||||
}
|
||||
}
|
||||
|
||||
RString LastDayToLocalizedString( int iLastDayIndex )
|
||||
{
|
||||
RString s = LastDayToString( iLastDayIndex );
|
||||
s.Replace( "Day", "" );
|
||||
s.Replace( "Ago", " Ago" );
|
||||
return s;
|
||||
}
|
||||
|
||||
RString LastWeekToLocalizedString( int iLastWeekIndex )
|
||||
{
|
||||
RString s = LastWeekToString( iLastWeekIndex );
|
||||
s.Replace( "Week", "" );
|
||||
s.Replace( "Ago", " Ago" );
|
||||
return s;
|
||||
}
|
||||
|
||||
RString HourInDayToLocalizedString( int iHourIndex )
|
||||
{
|
||||
int iBeginHour = iHourIndex;
|
||||
iBeginHour--;
|
||||
wrap( iBeginHour, 24 );
|
||||
iBeginHour++;
|
||||
|
||||
return ssprintf("%02d:00+", iBeginHour );
|
||||
}
|
||||
|
||||
|
||||
tm AddDays( tm start, int iDaysToMove )
|
||||
{
|
||||
/*
|
||||
* This causes problems on OS X, which doesn't correctly handle range that are below
|
||||
* their normal values (eg. mday = 0). According to the manpage, it should adjust them:
|
||||
*
|
||||
* "If structure members are outside their legal interval, they will be normalized (so
|
||||
* that, e.g., 40 October is changed into 9 November)."
|
||||
*
|
||||
* Instead, it appears to simply fail.
|
||||
*
|
||||
* Refs:
|
||||
* http://bugs.php.net/bug.php?id=10686
|
||||
* http://sourceforge.net/tracker/download.php?group_id=37892&atid=421366&file_id=79179&aid=91133
|
||||
*
|
||||
* Note "Log starting 2004-03-07 03:50:42"; mday is 7, and PrintCaloriesBurned calls us
|
||||
* with iDaysToMove = -7, resulting in an out-of-range value 0. This seems legal, but
|
||||
* OS X chokes on it.
|
||||
*/
|
||||
/* start.tm_mday += iDaysToMove;
|
||||
time_t seconds = mktime( &start );
|
||||
ASSERT( seconds != (time_t)-1 );
|
||||
*/
|
||||
|
||||
/* This handles DST differently: it returns the time that was exactly n*60*60*24 seconds
|
||||
* ago, where the above code always returns the same time of day. I prefer the above
|
||||
* behavior, but I'm not sure that it mattersmatters. */
|
||||
time_t seconds = mktime( &start );
|
||||
seconds += iDaysToMove*60*60*24;
|
||||
|
||||
tm time;
|
||||
localtime_r( &seconds, &time );
|
||||
return time;
|
||||
}
|
||||
|
||||
tm GetYesterday( tm start )
|
||||
{
|
||||
return AddDays( start, -1 );
|
||||
}
|
||||
|
||||
int GetDayOfWeek( tm time )
|
||||
{
|
||||
int iDayOfWeek = time.tm_wday;
|
||||
ASSERT( iDayOfWeek < DAYS_IN_WEEK );
|
||||
return iDayOfWeek;
|
||||
}
|
||||
|
||||
tm GetNextSunday( tm start )
|
||||
{
|
||||
return AddDays( start, DAYS_IN_WEEK-GetDayOfWeek(start) );
|
||||
}
|
||||
|
||||
|
||||
tm GetDayInYearAndYear( int iDayInYearIndex, int iYear )
|
||||
{
|
||||
/* If iDayInYearIndex is 200, set the date to Jan 200th, and let mktime
|
||||
* round it. This shouldn't suffer from the OSX mktime() issue described
|
||||
* above, since we're not giving it negative values. */
|
||||
tm when;
|
||||
ZERO( when );
|
||||
when.tm_mon = 0;
|
||||
when.tm_mday = iDayInYearIndex+1;
|
||||
when.tm_year = iYear - 1900;
|
||||
time_t then = mktime( &when );
|
||||
|
||||
localtime_r( &then, &when );
|
||||
return when;
|
||||
}
|
||||
|
||||
LuaFunction( MonthToString, MonthToString( Enum::Check<Month>(L, 1) ) );
|
||||
LuaFunction( MonthToLocalizedString, MonthToLocalizedString( Enum::Check<Month>(L, 1) ) );
|
||||
LuaFunction( MonthOfYear, GetLocalTime().tm_mon );
|
||||
LuaFunction( DayOfMonth, GetLocalTime().tm_mday );
|
||||
LuaFunction( Hour, GetLocalTime().tm_hour );
|
||||
LuaFunction( Minute, GetLocalTime().tm_min );
|
||||
LuaFunction( Second, GetLocalTime().tm_sec );
|
||||
LuaFunction( Year, GetLocalTime().tm_year+1900 );
|
||||
LuaFunction( Weekday, GetLocalTime().tm_wday );
|
||||
LuaFunction( DayOfYear, GetLocalTime().tm_yday );
|
||||
|
||||
/*
|
||||
* (c) 2001-2004 Chris Danford
|
||||
* All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* 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.
|
||||
*/
|
||||
#include "global.h"
|
||||
#include "DateTime.h"
|
||||
#include "RageUtil.h"
|
||||
#include "EnumHelper.h"
|
||||
#include "LuaManager.h"
|
||||
#include "LocalizedString.h"
|
||||
|
||||
DateTime::DateTime()
|
||||
{
|
||||
Init();
|
||||
}
|
||||
|
||||
void DateTime::Init()
|
||||
{
|
||||
ZERO( *this );
|
||||
}
|
||||
|
||||
bool DateTime::operator<( const DateTime& other ) const
|
||||
{
|
||||
#define COMPARE( v ) if(v!=other.v) return v<other.v;
|
||||
COMPARE( tm_year );
|
||||
COMPARE( tm_mon );
|
||||
COMPARE( tm_mday );
|
||||
COMPARE( tm_hour );
|
||||
COMPARE( tm_min );
|
||||
COMPARE( tm_sec );
|
||||
#undef COMPARE
|
||||
// they're equal
|
||||
return false;
|
||||
}
|
||||
|
||||
bool DateTime::operator==( const DateTime& other ) const
|
||||
{
|
||||
#define COMPARE(x) if( x!=other.x ) return false;
|
||||
COMPARE( tm_year );
|
||||
COMPARE( tm_mon );
|
||||
COMPARE( tm_mday );
|
||||
COMPARE( tm_hour );
|
||||
COMPARE( tm_min );
|
||||
COMPARE( tm_sec );
|
||||
#undef COMPARE
|
||||
return true;
|
||||
}
|
||||
|
||||
bool DateTime::operator>( const DateTime& other ) const
|
||||
{
|
||||
#define COMPARE( v ) if(v!=other.v) return v>other.v;
|
||||
COMPARE( tm_year );
|
||||
COMPARE( tm_mon );
|
||||
COMPARE( tm_mday );
|
||||
COMPARE( tm_hour );
|
||||
COMPARE( tm_min );
|
||||
COMPARE( tm_sec );
|
||||
#undef COMPARE
|
||||
// they're equal
|
||||
return false;
|
||||
}
|
||||
|
||||
DateTime DateTime::GetNowDateTime()
|
||||
{
|
||||
time_t now = time(nullptr);
|
||||
tm tNow;
|
||||
localtime_r( &now, &tNow );
|
||||
DateTime dtNow;
|
||||
#define COPY_M( v ) dtNow.v = tNow.v;
|
||||
COPY_M( tm_year );
|
||||
COPY_M( tm_mon );
|
||||
COPY_M( tm_mday );
|
||||
COPY_M( tm_hour );
|
||||
COPY_M( tm_min );
|
||||
COPY_M( tm_sec );
|
||||
#undef COPY_M
|
||||
return dtNow;
|
||||
}
|
||||
|
||||
DateTime DateTime::GetNowDate()
|
||||
{
|
||||
DateTime tNow = GetNowDateTime();
|
||||
tNow.StripTime();
|
||||
return tNow;
|
||||
}
|
||||
|
||||
void DateTime::StripTime()
|
||||
{
|
||||
tm_hour = 0;
|
||||
tm_min = 0;
|
||||
tm_sec = 0;
|
||||
}
|
||||
|
||||
// Common SQL/XML format: "YYYY-MM-DD HH:MM:SS"
|
||||
RString DateTime::GetString() const
|
||||
{
|
||||
RString s = ssprintf( "%d-%02d-%02d",
|
||||
tm_year+1900,
|
||||
tm_mon+1,
|
||||
tm_mday );
|
||||
|
||||
if( tm_hour != 0 ||
|
||||
tm_min != 0 ||
|
||||
tm_sec != 0 )
|
||||
{
|
||||
s += ssprintf( " %02d:%02d:%02d",
|
||||
tm_hour,
|
||||
tm_min,
|
||||
tm_sec );
|
||||
}
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
bool DateTime::FromString( const RString sDateTime )
|
||||
{
|
||||
Init();
|
||||
|
||||
int ret;
|
||||
|
||||
ret = sscanf( sDateTime, "%d-%d-%d %d:%d:%d",
|
||||
&tm_year,
|
||||
&tm_mon,
|
||||
&tm_mday,
|
||||
&tm_hour,
|
||||
&tm_min,
|
||||
&tm_sec );
|
||||
if( ret != 6 )
|
||||
{
|
||||
ret = sscanf( sDateTime, "%d-%d-%d",
|
||||
&tm_year,
|
||||
&tm_mon,
|
||||
&tm_mday );
|
||||
if( ret != 3 )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
tm_year -= 1900;
|
||||
tm_mon -= 1;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
RString DayInYearToString( int iDayInYear )
|
||||
{
|
||||
return ssprintf("DayInYear%03d",iDayInYear);
|
||||
}
|
||||
|
||||
int StringToDayInYear( RString sDayInYear )
|
||||
{
|
||||
int iDayInYear;
|
||||
if( sscanf( sDayInYear, "DayInYear%d", &iDayInYear ) != 1 )
|
||||
return -1;
|
||||
return iDayInYear;
|
||||
}
|
||||
|
||||
static const RString LAST_DAYS_NAME[NUM_LAST_DAYS] =
|
||||
{
|
||||
"Today",
|
||||
"Yesterday",
|
||||
"Day2Ago",
|
||||
"Day3Ago",
|
||||
"Day4Ago",
|
||||
"Day5Ago",
|
||||
"Day6Ago",
|
||||
};
|
||||
|
||||
RString LastDayToString( int iLastDayIndex )
|
||||
{
|
||||
return LAST_DAYS_NAME[iLastDayIndex];
|
||||
}
|
||||
|
||||
static const char *DAY_OF_WEEK_TO_NAME[DAYS_IN_WEEK] =
|
||||
{
|
||||
"Sunday",
|
||||
"Monday",
|
||||
"Tuesday",
|
||||
"Wednesday",
|
||||
"Thursday",
|
||||
"Friday",
|
||||
"Saturday",
|
||||
};
|
||||
|
||||
RString DayOfWeekToString( int iDayOfWeekIndex )
|
||||
{
|
||||
return DAY_OF_WEEK_TO_NAME[iDayOfWeekIndex];
|
||||
}
|
||||
|
||||
RString HourInDayToString( int iHourInDayIndex )
|
||||
{
|
||||
return ssprintf("Hour%02d", iHourInDayIndex);
|
||||
}
|
||||
|
||||
static const char *MonthNames[] =
|
||||
{
|
||||
"January",
|
||||
"February",
|
||||
"March",
|
||||
"April",
|
||||
"May",
|
||||
"June",
|
||||
"July",
|
||||
"August",
|
||||
"September",
|
||||
"October",
|
||||
"November",
|
||||
"December",
|
||||
};
|
||||
XToString( Month );
|
||||
XToLocalizedString( Month );
|
||||
LuaXType( Month );
|
||||
|
||||
RString LastWeekToString( int iLastWeekIndex )
|
||||
{
|
||||
switch( iLastWeekIndex )
|
||||
{
|
||||
case 0: return "ThisWeek"; break;
|
||||
case 1: return "LastWeek"; break;
|
||||
default: return ssprintf("Week%02dAgo",iLastWeekIndex); break;
|
||||
}
|
||||
}
|
||||
|
||||
RString LastDayToLocalizedString( int iLastDayIndex )
|
||||
{
|
||||
RString s = LastDayToString( iLastDayIndex );
|
||||
s.Replace( "Day", "" );
|
||||
s.Replace( "Ago", " Ago" );
|
||||
return s;
|
||||
}
|
||||
|
||||
RString LastWeekToLocalizedString( int iLastWeekIndex )
|
||||
{
|
||||
RString s = LastWeekToString( iLastWeekIndex );
|
||||
s.Replace( "Week", "" );
|
||||
s.Replace( "Ago", " Ago" );
|
||||
return s;
|
||||
}
|
||||
|
||||
RString HourInDayToLocalizedString( int iHourIndex )
|
||||
{
|
||||
int iBeginHour = iHourIndex;
|
||||
iBeginHour--;
|
||||
wrap( iBeginHour, 24 );
|
||||
iBeginHour++;
|
||||
|
||||
return ssprintf("%02d:00+", iBeginHour );
|
||||
}
|
||||
|
||||
|
||||
tm AddDays( tm start, int iDaysToMove )
|
||||
{
|
||||
/*
|
||||
* This causes problems on OS X, which doesn't correctly handle range that are below
|
||||
* their normal values (eg. mday = 0). According to the manpage, it should adjust them:
|
||||
*
|
||||
* "If structure members are outside their legal interval, they will be normalized (so
|
||||
* that, e.g., 40 October is changed into 9 November)."
|
||||
*
|
||||
* Instead, it appears to simply fail.
|
||||
*
|
||||
* Refs:
|
||||
* http://bugs.php.net/bug.php?id=10686
|
||||
* http://sourceforge.net/tracker/download.php?group_id=37892&atid=421366&file_id=79179&aid=91133
|
||||
*
|
||||
* Note "Log starting 2004-03-07 03:50:42"; mday is 7, and PrintCaloriesBurned calls us
|
||||
* with iDaysToMove = -7, resulting in an out-of-range value 0. This seems legal, but
|
||||
* OS X chokes on it.
|
||||
*/
|
||||
/* start.tm_mday += iDaysToMove;
|
||||
time_t seconds = mktime( &start );
|
||||
ASSERT( seconds != (time_t)-1 );
|
||||
*/
|
||||
|
||||
/* This handles DST differently: it returns the time that was exactly n*60*60*24 seconds
|
||||
* ago, where the above code always returns the same time of day. I prefer the above
|
||||
* behavior, but I'm not sure that it mattersmatters. */
|
||||
time_t seconds = mktime( &start );
|
||||
seconds += iDaysToMove*60*60*24;
|
||||
|
||||
tm time;
|
||||
localtime_r( &seconds, &time );
|
||||
return time;
|
||||
}
|
||||
|
||||
tm GetYesterday( tm start )
|
||||
{
|
||||
return AddDays( start, -1 );
|
||||
}
|
||||
|
||||
int GetDayOfWeek( tm time )
|
||||
{
|
||||
int iDayOfWeek = time.tm_wday;
|
||||
ASSERT( iDayOfWeek < DAYS_IN_WEEK );
|
||||
return iDayOfWeek;
|
||||
}
|
||||
|
||||
tm GetNextSunday( tm start )
|
||||
{
|
||||
return AddDays( start, DAYS_IN_WEEK-GetDayOfWeek(start) );
|
||||
}
|
||||
|
||||
|
||||
tm GetDayInYearAndYear( int iDayInYearIndex, int iYear )
|
||||
{
|
||||
/* If iDayInYearIndex is 200, set the date to Jan 200th, and let mktime
|
||||
* round it. This shouldn't suffer from the OSX mktime() issue described
|
||||
* above, since we're not giving it negative values. */
|
||||
tm when;
|
||||
ZERO( when );
|
||||
when.tm_mon = 0;
|
||||
when.tm_mday = iDayInYearIndex+1;
|
||||
when.tm_year = iYear - 1900;
|
||||
time_t then = mktime( &when );
|
||||
|
||||
localtime_r( &then, &when );
|
||||
return when;
|
||||
}
|
||||
|
||||
LuaFunction( MonthToString, MonthToString( Enum::Check<Month>(L, 1) ) );
|
||||
LuaFunction( MonthToLocalizedString, MonthToLocalizedString( Enum::Check<Month>(L, 1) ) );
|
||||
LuaFunction( MonthOfYear, GetLocalTime().tm_mon );
|
||||
LuaFunction( DayOfMonth, GetLocalTime().tm_mday );
|
||||
LuaFunction( Hour, GetLocalTime().tm_hour );
|
||||
LuaFunction( Minute, GetLocalTime().tm_min );
|
||||
LuaFunction( Second, GetLocalTime().tm_sec );
|
||||
LuaFunction( Year, GetLocalTime().tm_year+1900 );
|
||||
LuaFunction( Weekday, GetLocalTime().tm_wday );
|
||||
LuaFunction( DayOfYear, GetLocalTime().tm_yday );
|
||||
|
||||
/*
|
||||
* (c) 2001-2004 Chris Danford
|
||||
* All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* 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.
|
||||
*/
|
||||
|
||||
+9
-9
@@ -23,13 +23,13 @@ LuaXType( Difficulty );
|
||||
|
||||
const RString &CourseDifficultyToLocalizedString( CourseDifficulty x )
|
||||
{
|
||||
static auto_ptr<LocalizedString> g_CourseDifficultyName[NUM_Difficulty];
|
||||
if( g_CourseDifficultyName[0].get() == NULL )
|
||||
static unique_ptr<LocalizedString> g_CourseDifficultyName[NUM_Difficulty];
|
||||
if( g_CourseDifficultyName[0].get() == nullptr )
|
||||
{
|
||||
FOREACH_ENUM( Difficulty,i)
|
||||
{
|
||||
auto_ptr<LocalizedString> ap( new LocalizedString("CourseDifficulty", DifficultyToString(i)) );
|
||||
g_CourseDifficultyName[i] = ap;
|
||||
unique_ptr<LocalizedString> ap( new LocalizedString("CourseDifficulty", DifficultyToString(i)) );
|
||||
g_CourseDifficultyName[i] = move(ap);
|
||||
}
|
||||
}
|
||||
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
|
||||
vector<RString> 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
|
||||
{
|
||||
ThemeMetric<Difficulty> DIFFICULTY("CustomDifficulty",(*sName)+"Difficulty");
|
||||
ThemeMetric<Difficulty> DIFFICULTY("CustomDifficulty",sName + "Difficulty");
|
||||
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
|
||||
{
|
||||
ThemeMetric<RString> STRING("CustomDifficulty",(*sName)+"String");
|
||||
ThemeMetric<RString> STRING("CustomDifficulty",sName + "String");
|
||||
return STRING.GetValue();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -62,7 +62,7 @@ void DifficultyIcon::SetPlayer( PlayerNumber pn )
|
||||
void DifficultyIcon::SetFromSteps( PlayerNumber pn, const Steps* pSteps )
|
||||
{
|
||||
SetPlayer( pn );
|
||||
if( pSteps == NULL )
|
||||
if( pSteps == nullptr )
|
||||
Unset();
|
||||
else
|
||||
SetFromDifficulty( pSteps->GetDifficulty() );
|
||||
@@ -71,7 +71,7 @@ void DifficultyIcon::SetFromSteps( PlayerNumber pn, const Steps* pSteps )
|
||||
void DifficultyIcon::SetFromTrail( PlayerNumber pn, const Trail* pTrail )
|
||||
{
|
||||
SetPlayer( pn );
|
||||
if( pTrail == NULL )
|
||||
if( pTrail == nullptr )
|
||||
Unset();
|
||||
else
|
||||
SetFromDifficulty( pTrail->m_CourseDifficulty );
|
||||
|
||||
+13
-13
@@ -7,7 +7,7 @@
|
||||
#include "StepsDisplay.h"
|
||||
#include "StepsUtil.h"
|
||||
#include "CommonMetrics.h"
|
||||
#include "Foreach.h"
|
||||
|
||||
#include "SongUtil.h"
|
||||
#include "XmlFile.h"
|
||||
|
||||
@@ -49,12 +49,12 @@ void StepsDisplayList::LoadFromNode( const XNode* pNode )
|
||||
MOVE_COMMAND.Load( m_sName, "MoveCommand" );
|
||||
|
||||
m_Lines.resize( MAX_METERS );
|
||||
m_CurSong = NULL;
|
||||
m_CurSong = nullptr;
|
||||
|
||||
FOREACH_ENUM( PlayerNumber, pn )
|
||||
{
|
||||
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);
|
||||
}
|
||||
@@ -70,7 +70,7 @@ void StepsDisplayList::LoadFromNode( const XNode* pNode )
|
||||
* in separate tweening stacks. This means the Cursor command can't change diffuse
|
||||
* colors; I think we do need a diffuse color stack ... */
|
||||
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);
|
||||
}
|
||||
@@ -86,7 +86,7 @@ void StepsDisplayList::LoadFromNode( const XNode* pNode )
|
||||
{
|
||||
// todo: Use Row1, Row2 for names? also m_sName+"Row" -aj
|
||||
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 );
|
||||
}
|
||||
|
||||
@@ -102,7 +102,7 @@ int StepsDisplayList::GetCurrentRowIndex( PlayerNumber pn ) const
|
||||
{
|
||||
const Row &row = m_Rows[i];
|
||||
|
||||
if( GAMESTATE->m_pCurSteps[pn] == NULL )
|
||||
if( GAMESTATE->m_pCurSteps[pn] == nullptr )
|
||||
{
|
||||
if( row.m_dc == ClosestDifficulty )
|
||||
return i;
|
||||
@@ -267,17 +267,17 @@ void StepsDisplayList::SetFromGameState()
|
||||
const Song *pSong = GAMESTATE->m_pCurSong;
|
||||
unsigned i = 0;
|
||||
|
||||
if( pSong == NULL )
|
||||
if( pSong == nullptr )
|
||||
{
|
||||
// FIXME: This clamps to between the min and the max difficulty, but
|
||||
// it really should round to the nearest difficulty that's in
|
||||
// DIFFICULTIES_TO_SHOW.
|
||||
const vector<Difficulty>& difficulties = CommonMetrics::DIFFICULTIES_TO_SHOW.GetValue();
|
||||
m_Rows.resize( difficulties.size() );
|
||||
FOREACH_CONST( Difficulty, difficulties, d )
|
||||
for (Difficulty const &d : difficulties)
|
||||
{
|
||||
m_Rows[i].m_dc = *d;
|
||||
m_Lines[i].m_Meter.SetFromStepsTypeAndMeterAndDifficultyAndCourseType( GAMESTATE->GetCurrentStyle(PLAYER_INVALID)->m_StepsType, 0, *d, CourseType_Invalid );
|
||||
m_Rows[i].m_dc = d;
|
||||
m_Lines[i].m_Meter.SetFromStepsTypeAndMeterAndDifficultyAndCourseType( GAMESTATE->GetCurrentStyle(PLAYER_INVALID)->m_StepsType, 0, d, CourseType_Invalid );
|
||||
++i;
|
||||
}
|
||||
}
|
||||
@@ -288,11 +288,11 @@ void StepsDisplayList::SetFromGameState()
|
||||
// Should match the sort in ScreenSelectMusic::AfterMusicChange.
|
||||
|
||||
m_Rows.resize( vpSteps.size() );
|
||||
FOREACH_CONST( Steps*, vpSteps, s )
|
||||
for (Steps const * s: vpSteps)
|
||||
{
|
||||
//LOG->Trace(ssprintf("setting steps for row %i",i));
|
||||
m_Rows[i].m_Steps = *s;
|
||||
m_Lines[i].m_Meter.SetFromSteps( *s );
|
||||
m_Rows[i].m_Steps = s;
|
||||
m_Lines[i].m_Meter.SetFromSteps( s );
|
||||
++i;
|
||||
}
|
||||
}
|
||||
|
||||
+100
-100
@@ -1,100 +1,100 @@
|
||||
/* StepsDisplayList - Shows all available difficulties for a Song/Course. */
|
||||
#ifndef DIFFICULTY_LIST_H
|
||||
#define DIFFICULTY_LIST_H
|
||||
|
||||
#include "ActorFrame.h"
|
||||
#include "PlayerNumber.h"
|
||||
#include "StepsDisplay.h"
|
||||
#include "ThemeMetric.h"
|
||||
|
||||
class Song;
|
||||
class Steps;
|
||||
|
||||
class StepsDisplayList: public ActorFrame
|
||||
{
|
||||
public:
|
||||
StepsDisplayList();
|
||||
virtual ~StepsDisplayList();
|
||||
virtual StepsDisplayList *Copy() const;
|
||||
virtual void LoadFromNode( const XNode* pNode );
|
||||
|
||||
void HandleMessage( const Message &msg );
|
||||
|
||||
void SetFromGameState();
|
||||
void TweenOnScreen();
|
||||
void TweenOffScreen();
|
||||
void Hide();
|
||||
void Show();
|
||||
|
||||
// Lua
|
||||
void PushSelf( lua_State *L );
|
||||
|
||||
private:
|
||||
void UpdatePositions();
|
||||
void PositionItems();
|
||||
int GetCurrentRowIndex( PlayerNumber pn ) const;
|
||||
void HideRows();
|
||||
|
||||
ThemeMetric<float> ITEMS_SPACING_Y;
|
||||
ThemeMetric<int> NUM_SHOWN_ITEMS;
|
||||
ThemeMetric<bool> CAPITALIZE_DIFFICULTY_NAMES;
|
||||
ThemeMetric<apActorCommands> MOVE_COMMAND;
|
||||
|
||||
AutoActor m_Cursors[NUM_PLAYERS];
|
||||
ActorFrame m_CursorFrames[NUM_PLAYERS]; // contains Cursor so that color can fade independent of other tweens
|
||||
|
||||
struct Line
|
||||
{
|
||||
StepsDisplay m_Meter;
|
||||
};
|
||||
vector<Line> m_Lines;
|
||||
|
||||
const Song *m_CurSong;
|
||||
bool m_bShown;
|
||||
|
||||
struct Row
|
||||
{
|
||||
Row()
|
||||
{
|
||||
m_Steps = NULL;
|
||||
m_dc = Difficulty_Invalid;
|
||||
m_fY = 0;
|
||||
m_bHidden = false;
|
||||
}
|
||||
|
||||
const Steps *m_Steps;
|
||||
Difficulty m_dc;
|
||||
float m_fY;
|
||||
bool m_bHidden; // currently off screen
|
||||
};
|
||||
|
||||
vector<Row> m_Rows;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
* (c) 2003-2004 Glenn Maynard
|
||||
* All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* 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.
|
||||
*/
|
||||
/* StepsDisplayList - Shows all available difficulties for a Song/Course. */
|
||||
#ifndef DIFFICULTY_LIST_H
|
||||
#define DIFFICULTY_LIST_H
|
||||
|
||||
#include "ActorFrame.h"
|
||||
#include "PlayerNumber.h"
|
||||
#include "StepsDisplay.h"
|
||||
#include "ThemeMetric.h"
|
||||
|
||||
class Song;
|
||||
class Steps;
|
||||
|
||||
class StepsDisplayList: public ActorFrame
|
||||
{
|
||||
public:
|
||||
StepsDisplayList();
|
||||
virtual ~StepsDisplayList();
|
||||
virtual StepsDisplayList *Copy() const;
|
||||
virtual void LoadFromNode( const XNode* pNode );
|
||||
|
||||
void HandleMessage( const Message &msg );
|
||||
|
||||
void SetFromGameState();
|
||||
void TweenOnScreen();
|
||||
void TweenOffScreen();
|
||||
void Hide();
|
||||
void Show();
|
||||
|
||||
// Lua
|
||||
void PushSelf( lua_State *L );
|
||||
|
||||
private:
|
||||
void UpdatePositions();
|
||||
void PositionItems();
|
||||
int GetCurrentRowIndex( PlayerNumber pn ) const;
|
||||
void HideRows();
|
||||
|
||||
ThemeMetric<float> ITEMS_SPACING_Y;
|
||||
ThemeMetric<int> NUM_SHOWN_ITEMS;
|
||||
ThemeMetric<bool> CAPITALIZE_DIFFICULTY_NAMES;
|
||||
ThemeMetric<apActorCommands> MOVE_COMMAND;
|
||||
|
||||
AutoActor m_Cursors[NUM_PLAYERS];
|
||||
ActorFrame m_CursorFrames[NUM_PLAYERS]; // contains Cursor so that color can fade independent of other tweens
|
||||
|
||||
struct Line
|
||||
{
|
||||
StepsDisplay m_Meter;
|
||||
};
|
||||
vector<Line> m_Lines;
|
||||
|
||||
const Song *m_CurSong;
|
||||
bool m_bShown;
|
||||
|
||||
struct Row
|
||||
{
|
||||
Row()
|
||||
{
|
||||
m_Steps = nullptr;
|
||||
m_dc = Difficulty_Invalid;
|
||||
m_fY = 0;
|
||||
m_bHidden = false;
|
||||
}
|
||||
|
||||
const Steps *m_Steps;
|
||||
Difficulty m_dc;
|
||||
float m_fY;
|
||||
bool m_bHidden; // currently off screen
|
||||
};
|
||||
|
||||
vector<Row> m_Rows;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
* (c) 2003-2004 Glenn Maynard
|
||||
* All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* 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.
|
||||
*/
|
||||
|
||||
+3
-3
@@ -37,7 +37,7 @@ public:
|
||||
}
|
||||
static int GetCurrentMode( T *p, lua_State *L )
|
||||
{
|
||||
if (p->currentMode() != NULL) {
|
||||
if (p->currentMode() != nullptr) {
|
||||
DisplayMode *m = const_cast<DisplayMode *>( p->currentMode() );
|
||||
m->PushSelf( L );
|
||||
} else {
|
||||
@@ -65,7 +65,7 @@ namespace
|
||||
DisplaySpecs *check_DisplaySpecs(lua_State *L)
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -126,7 +126,7 @@ namespace
|
||||
{"__index", DisplaySpecs_get},
|
||||
{"__len", DisplaySpecs_len},
|
||||
{"__tostring", DisplaySpecs_tostring},
|
||||
{NULL, NULL}
|
||||
{nullptr, nullptr}
|
||||
};
|
||||
|
||||
|
||||
|
||||
+1
-1
@@ -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
|
||||
*
|
||||
* Note that inactive *does not* necessarily mean unusable. E.g., in X11,
|
||||
|
||||
+25
-24
@@ -8,7 +8,7 @@
|
||||
#include "Steps.h"
|
||||
#include "Song.h"
|
||||
#include "StepsUtil.h"
|
||||
#include "Foreach.h"
|
||||
|
||||
#include "CommonMetrics.h"
|
||||
#include "ImageCache.h"
|
||||
#include "UnlockManager.h"
|
||||
@@ -171,12 +171,12 @@ void EditMenu::Load( const RString &sType )
|
||||
this->AddChild( &m_SongTextBanner );
|
||||
|
||||
m_StepsDisplay.SetName( "StepsDisplay" );
|
||||
m_StepsDisplay.Load( "StepsDisplayEdit", NULL );
|
||||
m_StepsDisplay.Load( "StepsDisplayEdit", nullptr );
|
||||
ActorUtil::SetXY( m_StepsDisplay, sType );
|
||||
this->AddChild( &m_StepsDisplay );
|
||||
|
||||
m_StepsDisplaySource.SetName( "StepsDisplaySource" );
|
||||
m_StepsDisplaySource.Load( "StepsDisplayEdit", NULL );
|
||||
m_StepsDisplaySource.Load( "StepsDisplayEdit", nullptr );
|
||||
ActorUtil::SetXY( m_StepsDisplaySource, sType );
|
||||
this->AddChild( &m_StepsDisplaySource );
|
||||
|
||||
@@ -411,11 +411,11 @@ void EditMenu::OnRowValueChanged( EditMenuRow row )
|
||||
vector<Song*> vtSongs;
|
||||
GetSongsToShowForGroup(GetSelectedGroup(), vtSongs);
|
||||
// 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;
|
||||
// fall through
|
||||
case ROW_SONG:
|
||||
if(GetSelectedSong() == NULL)
|
||||
if(GetSelectedSong() == nullptr)
|
||||
{
|
||||
m_textValue[ROW_SONG].SetText("");
|
||||
m_SongBanner.LoadFallback();
|
||||
@@ -462,13 +462,13 @@ void EditMenu::OnRowValueChanged( EditMenuRow row )
|
||||
|
||||
// Only show StepsTypes for which we have valid Steps.
|
||||
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)
|
||||
m_StepsTypes.push_back(*st);
|
||||
if(SongUtil::GetStepsByDifficulty( GetSelectedSong(), st, Difficulty_Invalid, false) != nullptr)
|
||||
m_StepsTypes.push_back(st);
|
||||
|
||||
// Try to preserve the user's StepsType selection.
|
||||
if(*st == orgSel)
|
||||
if(st == orgSel)
|
||||
m_iSelection[ROW_STEPS_TYPE] = m_StepsTypes.size() - 1;
|
||||
}
|
||||
}
|
||||
@@ -506,8 +506,8 @@ void EditMenu::OnRowValueChanged( EditMenuRow row )
|
||||
vector<Steps*> v;
|
||||
SongUtil::GetSteps( GetSelectedSong(), v, GetSelectedStepsType(), Difficulty_Edit );
|
||||
StepsUtil::SortStepsByDescription( v );
|
||||
FOREACH_CONST( Steps*, v, p )
|
||||
m_vpSteps.push_back( StepsAndDifficulty(*p,dc) );
|
||||
for (Steps *p : v)
|
||||
m_vpSteps.push_back( StepsAndDifficulty(p,dc) );
|
||||
}
|
||||
break;
|
||||
case EditMode_Home:
|
||||
@@ -524,7 +524,7 @@ void EditMenu::OnRowValueChanged( EditMenuRow row )
|
||||
break;
|
||||
case EditMode_Home:
|
||||
case EditMode_Full:
|
||||
m_vpSteps.push_back( StepsAndDifficulty(NULL,dc) ); // "New Edit"
|
||||
m_vpSteps.push_back( StepsAndDifficulty(nullptr,dc) ); // "New Edit"
|
||||
break;
|
||||
default:
|
||||
FAIL_M(ssprintf("Invalid edit mode: %i", mode));
|
||||
@@ -534,7 +534,7 @@ void EditMenu::OnRowValueChanged( EditMenuRow row )
|
||||
{
|
||||
Steps *pSteps = SongUtil::GetStepsByDifficulty( GetSelectedSong(), GetSelectedStepsType(), dc );
|
||||
if( pSteps && UNLOCKMAN->StepsIsLocked( GetSelectedSong(), pSteps ) )
|
||||
pSteps = NULL;
|
||||
pSteps = nullptr;
|
||||
|
||||
switch( mode )
|
||||
{
|
||||
@@ -558,11 +558,12 @@ void EditMenu::OnRowValueChanged( EditMenuRow row )
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -570,7 +571,7 @@ void EditMenu::OnRowValueChanged( EditMenuRow row )
|
||||
}
|
||||
// fall through
|
||||
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_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].SetText( GAMEMAN->GetStepsTypeInfo(GetSelectedSourceStepsType()).GetLocalizedString() );
|
||||
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 )
|
||||
{
|
||||
@@ -610,7 +611,7 @@ void EditMenu::OnRowValueChanged( EditMenuRow row )
|
||||
if( dc != Difficulty_Edit )
|
||||
{
|
||||
Steps *pSteps = SongUtil::GetStepsByDifficulty( GetSelectedSong(), GetSelectedSourceStepsType(), dc );
|
||||
if( pSteps != NULL )
|
||||
if( pSteps != nullptr )
|
||||
m_vpSourceSteps.push_back( StepsAndDifficulty(pSteps,dc) );
|
||||
}
|
||||
else
|
||||
@@ -618,8 +619,8 @@ void EditMenu::OnRowValueChanged( EditMenuRow row )
|
||||
vector<Steps*> v;
|
||||
SongUtil::GetSteps( GetSelectedSong(), v, GetSelectedSourceStepsType(), dc );
|
||||
StepsUtil::SortStepsByDescription( v );
|
||||
FOREACH_CONST( Steps*, v, pSteps )
|
||||
m_vpSourceSteps.push_back( StepsAndDifficulty(*pSteps,dc) );
|
||||
for (Steps *pSteps : v)
|
||||
m_vpSourceSteps.push_back( StepsAndDifficulty(pSteps,dc) );
|
||||
}
|
||||
}
|
||||
StripLockedStepsAndDifficulty( m_vpSteps );
|
||||
@@ -662,7 +663,7 @@ void EditMenu::OnRowValueChanged( EditMenuRow row )
|
||||
m_Actions.clear();
|
||||
// Stick autosave in the list first so that people will see it. -Kyz
|
||||
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);
|
||||
}
|
||||
|
||||
+3
-3
@@ -121,7 +121,7 @@ public:
|
||||
Song* GetSelectedSong() const
|
||||
{
|
||||
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]];
|
||||
}
|
||||
/** @brief Retrieve the currently selected steps type.
|
||||
@@ -137,7 +137,7 @@ public:
|
||||
Steps* GetSelectedSteps() const
|
||||
{
|
||||
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;
|
||||
}
|
||||
/** @brief Retrieve the currently selected difficulty.
|
||||
@@ -161,7 +161,7 @@ public:
|
||||
Steps* GetSelectedSourceSteps() const
|
||||
{
|
||||
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;
|
||||
}
|
||||
/** @brief Retrieve the currently selected difficulty.
|
||||
|
||||
+7
-7
@@ -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.
|
||||
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 )
|
||||
{
|
||||
auto_ptr<RString> ap( new RString( szNameArray[i] ) );
|
||||
pNameCache[i] = ap;
|
||||
unique_ptr<RString> ap( new RString( szNameArray[i] ) );
|
||||
pNameCache[i] = move(ap);
|
||||
}
|
||||
|
||||
auto_ptr<RString> ap( new RString );
|
||||
pNameCache[iMax+1] = ap;
|
||||
unique_ptr<RString> ap( new RString );
|
||||
pNameCache[iMax+1] = move(ap);
|
||||
}
|
||||
|
||||
// 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[] = {
|
||||
{ "GetName", GetName },
|
||||
{ "Reverse", Reverse },
|
||||
{ NULL, NULL }
|
||||
{ nullptr, nullptr }
|
||||
};
|
||||
|
||||
static void PushEnumMethodTable( lua_State *L )
|
||||
|
||||
+6
-6
@@ -66,14 +66,14 @@ namespace Enum
|
||||
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) \
|
||||
const RString& X##ToString(X x); \
|
||||
COMPILE_ASSERT( NUM_##X == ARRAYLEN(X##Names) ); \
|
||||
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 ); \
|
||||
} \
|
||||
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 ) \
|
||||
{ \
|
||||
static auto_ptr<LocalizedString> g_##X##Name[NUM_##X]; \
|
||||
if( g_##X##Name[0].get() == NULL ) { \
|
||||
static unique_ptr<LocalizedString> g_##X##Name[NUM_##X]; \
|
||||
if( g_##X##Name[0].get() == nullptr ) { \
|
||||
for( unsigned i = 0; i < NUM_##X; ++i ) \
|
||||
{ \
|
||||
auto_ptr<LocalizedString> ap( new LocalizedString(#X, X##ToString((X)i)) ); \
|
||||
g_##X##Name[i] = ap; \
|
||||
unique_ptr<LocalizedString> ap( new LocalizedString(#X, X##ToString((X)i)) ); \
|
||||
g_##X##Name[i] = move(ap); \
|
||||
} \
|
||||
} \
|
||||
return g_##X##Name[x]->GetValue(); \
|
||||
|
||||
@@ -166,7 +166,7 @@ bool FadingBanner::LoadFromCachedBanner( const RString &path )
|
||||
|
||||
void FadingBanner::LoadFromSong( const Song* pSong )
|
||||
{
|
||||
if( pSong == NULL )
|
||||
if( pSong == nullptr )
|
||||
{
|
||||
LoadFallback();
|
||||
return;
|
||||
@@ -195,7 +195,7 @@ void FadingBanner::LoadFromSongGroup( RString sSongGroup )
|
||||
|
||||
void FadingBanner::LoadFromCourse( const Course* pCourse )
|
||||
{
|
||||
if( pCourse == NULL )
|
||||
if( pCourse == nullptr )
|
||||
{
|
||||
LoadFallback();
|
||||
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 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 ); }
|
||||
COMMON_RETURN_SELF;
|
||||
}
|
||||
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 ); }
|
||||
COMMON_RETURN_SELF;
|
||||
}
|
||||
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 ); }
|
||||
COMMON_RETURN_SELF;
|
||||
}
|
||||
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 ); }
|
||||
COMMON_RETURN_SELF;
|
||||
}
|
||||
|
||||
+1
-1
@@ -18,7 +18,7 @@ public:
|
||||
/* If you previously loaded a cached banner, and are now loading the full-
|
||||
* resolution banner, set bLowResToHighRes to true. */
|
||||
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 LoadFromSongGroup( RString sSongGroup );
|
||||
void LoadFromCourse( const Course* pCourse );
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
#include "SpecialFiles.h"
|
||||
#include "RageLog.h"
|
||||
#include "Preference.h"
|
||||
#include "Foreach.h"
|
||||
|
||||
|
||||
FileTransfer::FileTransfer()
|
||||
{
|
||||
@@ -199,8 +199,8 @@ void FileTransfer::StartTransfer( TransferType type, const RString &sURL, const
|
||||
vsHeaders.push_back( "Content-Length: " + ssprintf("%zd",sRequestPayload.size()) );
|
||||
|
||||
RString sHeader;
|
||||
FOREACH_CONST( RString, vsHeaders, h )
|
||||
sHeader += *h + "\r\n";
|
||||
for (RString const &h : vsHeaders)
|
||||
sHeader += h + "\r\n";
|
||||
sHeader += "\r\n";
|
||||
|
||||
m_wSocket.SendData( sHeader.c_str(), sHeader.length() );
|
||||
@@ -267,14 +267,14 @@ void FileTransfer::HTTPUpdate()
|
||||
m_sResponseName = "Malformed response.";
|
||||
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 );
|
||||
|
||||
i = m_sBUFFER.find("Content-Length:");
|
||||
j = m_sBUFFER.find("\n", i+1 );
|
||||
|
||||
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
|
||||
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];
|
||||
if( asMatches[3] != "" )
|
||||
{
|
||||
iPort = StringToInt(asMatches[3]);
|
||||
iPort = std::stoi(asMatches[3]);
|
||||
if( iPort == 0 )
|
||||
return false;
|
||||
}
|
||||
|
||||
+13
-13
@@ -26,7 +26,7 @@ void FontPage::Load( const FontPageSettings &cfg )
|
||||
ID1.AdditionalTextureHints = cfg.m_sTextureHints;
|
||||
|
||||
m_FontPageTextures.m_pTextureMain = TEXTUREMAN->LoadTexture( ID1 );
|
||||
if(m_FontPageTextures.m_pTextureMain == NULL)
|
||||
if(m_FontPageTextures.m_pTextureMain == nullptr)
|
||||
{
|
||||
LuaHelpers::ReportScriptErrorFmt(
|
||||
"Failed to load main texture %s for font page.",
|
||||
@@ -43,7 +43,7 @@ void FontPage::Load( const FontPageSettings &cfg )
|
||||
if( IsAFile(ID2.filename) )
|
||||
{
|
||||
m_FontPageTextures.m_pTextureStroke = TEXTUREMAN->LoadTexture( ID2 );
|
||||
if(m_FontPageTextures.m_pTextureStroke == NULL)
|
||||
if(m_FontPageTextures.m_pTextureStroke == nullptr)
|
||||
{
|
||||
LuaHelpers::ReportScriptErrorFmt(
|
||||
"Failed to load stroke texture %s for font page.",
|
||||
@@ -220,15 +220,15 @@ void FontPage::SetExtraPixels( int iDrawExtraPixelsLeft, int iDrawExtraPixelsRig
|
||||
|
||||
FontPage::~FontPage()
|
||||
{
|
||||
if( m_FontPageTextures.m_pTextureMain != NULL )
|
||||
if( m_FontPageTextures.m_pTextureMain != nullptr )
|
||||
{
|
||||
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 );
|
||||
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;
|
||||
}
|
||||
|
||||
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),
|
||||
// strokes aren't shown by default, hence the Color.
|
||||
m_DefaultStrokeColor(RageColor(0,0,0,0)), m_sChars("") {}
|
||||
@@ -288,7 +288,7 @@ void Font::Unload()
|
||||
m_apPages.clear();
|
||||
|
||||
m_iCharToGlyph.clear();
|
||||
m_pDefault = NULL;
|
||||
m_pDefault = nullptr;
|
||||
|
||||
/* Don't clear the refcount. We've unloaded, but that doesn't mean things
|
||||
* 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
|
||||
* pages; this will be used only if we don't have any font pages at
|
||||
* all. */
|
||||
if( m_pDefault == NULL )
|
||||
if( m_pDefault == nullptr )
|
||||
m_pDefault = f.m_pDefault;
|
||||
|
||||
for(map<wchar_t,glyph*>::iterator it = f.m_iCharToGlyph.begin();
|
||||
@@ -400,7 +400,7 @@ void Font::CapsOnly()
|
||||
|
||||
void Font::SetDefaultGlyph( FontPage *pPage )
|
||||
{
|
||||
ASSERT( pPage != NULL );
|
||||
ASSERT( pPage != nullptr );
|
||||
if(pPage->m_aGlyphs.empty())
|
||||
{
|
||||
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( IsAnInt(sName) )
|
||||
{
|
||||
cfg.m_mapGlyphWidths[StringToInt(sName)] = pValue->GetValue<int>();
|
||||
cfg.m_mapGlyphWidths[std::stoi(sName)] = pValue->GetValue<int>();
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -603,7 +603,7 @@ void Font::LoadFontPageSettings( FontPageSettings &cfg, IniFile &ini, const RStr
|
||||
row_str.c_str());
|
||||
continue;
|
||||
}
|
||||
const int row = StringToInt(row_str);
|
||||
const int row = std::stoi(row_str);
|
||||
const int first_frame = row * num_frames_wide;
|
||||
|
||||
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 );
|
||||
if( pMapping == NULL )
|
||||
if( pMapping == nullptr )
|
||||
return "Unknown mapping";
|
||||
|
||||
while( *pMapping != 0 && iMapOffset )
|
||||
|
||||
+2
-2
@@ -23,7 +23,7 @@ struct FontPageTextures
|
||||
RageTexture *m_pTextureStroke;
|
||||
|
||||
/** @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 {
|
||||
return m_pTextureMain == other.m_pTextureMain &&
|
||||
@@ -59,7 +59,7 @@ struct glyph
|
||||
RectF m_TexRect;
|
||||
|
||||
/** @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() {}
|
||||
};
|
||||
|
||||
|
||||
@@ -347,7 +347,7 @@ static void InitCharAliases()
|
||||
{ "auxrt", INTERNAL },
|
||||
{ "auxback", INTERNAL },
|
||||
|
||||
{ NULL, 0 }
|
||||
{ nullptr, 0 }
|
||||
};
|
||||
|
||||
int iNextInternalUseCodepoint = 0xE000;
|
||||
|
||||
@@ -226,7 +226,7 @@ const wchar_t *FontCharmaps::get_char_map(RString name)
|
||||
|
||||
map<RString,const wchar_t*>::const_iterator i = charmaps.find(name);
|
||||
if(i == charmaps.end())
|
||||
return NULL;
|
||||
return nullptr;
|
||||
|
||||
return i->second;
|
||||
}
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@
|
||||
#include "RageLog.h"
|
||||
#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
|
||||
typedef pair<RString,RString> FontName;
|
||||
|
||||
@@ -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
@@ -7,7 +7,7 @@
|
||||
#include "ActorUtil.h"
|
||||
#include "Song.h"
|
||||
#include "BackgroundUtil.h"
|
||||
#include "Foreach.h"
|
||||
|
||||
|
||||
Foreground::~Foreground()
|
||||
{
|
||||
@@ -21,7 +21,7 @@ void Foreground::Unload()
|
||||
m_BGAnimations.clear();
|
||||
m_SubActors.clear();
|
||||
m_fLastMusicSeconds = -9999;
|
||||
m_pSong = NULL;
|
||||
m_pSong = nullptr;
|
||||
}
|
||||
|
||||
void Foreground::LoadFromSong( const Song *pSong )
|
||||
@@ -31,9 +31,8 @@ void Foreground::LoadFromSong( const Song *pSong )
|
||||
TEXTUREMAN->SetDefaultTexturePolicy( RageTextureID::TEX_VOLATILE );
|
||||
|
||||
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,
|
||||
sLuaFile = pSong->GetSongDir() + sBGName + "/default.lua",
|
||||
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 );
|
||||
}
|
||||
if( bga.m_bga == NULL )
|
||||
if( bga.m_bga == nullptr )
|
||||
continue;
|
||||
bga.m_bga->SetName( sBGName );
|
||||
// ActorUtil::MakeActor calls LoadFromNode to load the actor, and
|
||||
|
||||
+68
-69
@@ -14,7 +14,6 @@
|
||||
#include "PrefsManager.h"
|
||||
#include "Game.h"
|
||||
#include "Style.h"
|
||||
#include "Foreach.h"
|
||||
#include "GameSoundManager.h"
|
||||
#include "PlayerState.h"
|
||||
#include "SongManager.h"
|
||||
@@ -36,7 +35,7 @@ void GameCommand::Init()
|
||||
m_bInvalid = true;
|
||||
m_iIndex = -1;
|
||||
m_MultiPlayer = MultiPlayer_Invalid;
|
||||
m_pStyle = NULL;
|
||||
m_pStyle = nullptr;
|
||||
m_pm = PlayMode_Invalid;
|
||||
m_dc = Difficulty_Invalid;
|
||||
m_CourseDifficulty = Difficulty_Invalid;
|
||||
@@ -45,11 +44,11 @@ void GameCommand::Init()
|
||||
m_sAnnouncer = "";
|
||||
m_sScreen = "";
|
||||
m_LuaFunction.Unset();
|
||||
m_pSong = NULL;
|
||||
m_pSteps = NULL;
|
||||
m_pCourse = NULL;
|
||||
m_pTrail = NULL;
|
||||
m_pCharacter = NULL;
|
||||
m_pSong = nullptr;
|
||||
m_pSteps = nullptr;
|
||||
m_pCourse = nullptr;
|
||||
m_pTrail = nullptr;
|
||||
m_pCharacter = nullptr;
|
||||
m_SortOrder = SortOrder_Invalid;
|
||||
m_sSoundPath = "";
|
||||
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
|
||||
// in ScreenSelectOptionsMaster::ImportOptions if m_PreferredDifficulty
|
||||
// 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?
|
||||
FOREACH_HumanPlayer( human )
|
||||
@@ -158,8 +157,8 @@ void GameCommand::Load( int iIndex, const Commands& cmds )
|
||||
m_bInvalid = false;
|
||||
m_Commands = cmds;
|
||||
|
||||
FOREACH_CONST( Command, cmds.v, cmd )
|
||||
LoadOne( *cmd );
|
||||
for (Command const &cmd : cmds.v)
|
||||
LoadOne( cmd );
|
||||
}
|
||||
|
||||
void GameCommand::LoadOne( const Command& cmd )
|
||||
@@ -197,7 +196,7 @@ void GameCommand::LoadOne( const Command& cmd )
|
||||
if( sName == "style" )
|
||||
{
|
||||
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" )
|
||||
@@ -278,7 +277,7 @@ void GameCommand::LoadOne( const Command& cmd )
|
||||
else if( sName == "song" )
|
||||
{
|
||||
CHECK_INVALID_COND(m_pSong, SONGMAN->FindSong(sValue),
|
||||
(SONGMAN->FindSong(sValue) == NULL),
|
||||
(SONGMAN->FindSong(sValue) == nullptr),
|
||||
(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.
|
||||
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());
|
||||
if( pSong == NULL || pStyle == NULL )
|
||||
if( pSong == nullptr || pStyle == nullptr )
|
||||
{
|
||||
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 );
|
||||
}
|
||||
CHECK_INVALID_COND(m_pSteps, st, (st == NULL),
|
||||
CHECK_INVALID_COND(m_pSteps, st, (st == nullptr),
|
||||
(ssprintf("Steps \"%s\" not found", sSteps.c_str())));
|
||||
}
|
||||
}
|
||||
@@ -316,7 +315,7 @@ void GameCommand::LoadOne( const Command& cmd )
|
||||
else if( sName == "course" )
|
||||
{
|
||||
CHECK_INVALID_COND(m_pCourse, SONGMAN->FindCourse("", sValue),
|
||||
(SONGMAN->FindCourse("", sValue) == NULL),
|
||||
(SONGMAN->FindCourse("", sValue) == nullptr),
|
||||
(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.
|
||||
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());
|
||||
if( pCourse == NULL || pStyle == NULL )
|
||||
if( pCourse == nullptr || pStyle == nullptr )
|
||||
{
|
||||
MAKE_INVALID("Must set Course and Style to set Trail.");
|
||||
}
|
||||
@@ -343,7 +342,7 @@ void GameCommand::LoadOne( const Command& cmd )
|
||||
else
|
||||
{
|
||||
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."));
|
||||
}
|
||||
}
|
||||
@@ -378,12 +377,12 @@ void GameCommand::LoadOne( const Command& cmd )
|
||||
|
||||
else if( sName == "weight" )
|
||||
{
|
||||
m_iWeightPounds = StringToInt( sValue );
|
||||
m_iWeightPounds = std::stoi( sValue );
|
||||
}
|
||||
|
||||
else if( sName == "goalcalories" )
|
||||
{
|
||||
m_iGoalCalories = StringToInt( sValue );
|
||||
m_iGoalCalories = std::stoi( sValue );
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
if(IPreference::GetPreferenceByName(cmd.m_vsArgs[i]) == NULL)
|
||||
if(IPreference::GetPreferenceByName(cmd.m_vsArgs[i]) == nullptr)
|
||||
{
|
||||
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 )
|
||||
{
|
||||
if( style == NULL || pm == PlayMode_Invalid )
|
||||
if( style == nullptr || pm == PlayMode_Invalid )
|
||||
return true;
|
||||
|
||||
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),
|
||||
* 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 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( why )
|
||||
@@ -680,12 +679,12 @@ void GameCommand::Apply( const vector<PlayerNumber> &vpns ) const
|
||||
if( m_Commands.v.size() )
|
||||
{
|
||||
// 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;
|
||||
gc.m_bInvalid = false;
|
||||
gc.m_bApplyCommitsScreens = m_bApplyCommitsScreens;
|
||||
gc.LoadOne( *cmd );
|
||||
gc.LoadOne( cmd );
|
||||
gc.ApplySelf( vpns );
|
||||
}
|
||||
}
|
||||
@@ -704,7 +703,7 @@ void GameCommand::ApplySelf( const vector<PlayerNumber> &vpns ) const
|
||||
if( m_pm != PlayMode_Invalid )
|
||||
GAMESTATE->m_PlayMode.Set( m_pm );
|
||||
|
||||
if( m_pStyle != NULL )
|
||||
if( m_pStyle != nullptr )
|
||||
{
|
||||
GAMESTATE->SetCurrentStyle( m_pStyle, GAMESTATE->GetMasterPlayerNumber() );
|
||||
|
||||
@@ -720,8 +719,8 @@ void GameCommand::ApplySelf( const vector<PlayerNumber> &vpns ) const
|
||||
LOG->Trace( "Deducted %i coins, %i remaining",
|
||||
iNumCreditsOwed * PREFSMAN->m_iCoinsPerCredit, GAMESTATE->m_iCoins.Get() );
|
||||
|
||||
//Credit Used, make sure to update CoinsFile
|
||||
BOOKKEEPER->WriteCoinsFile(GAMESTATE->m_iCoins.Get());
|
||||
//Credit Used, make sure to update CoinsFile
|
||||
BOOKKEEPER->WriteCoinsFile(GAMESTATE->m_iCoins.Get());
|
||||
}
|
||||
|
||||
// If only one side is joined and we picked a style that requires both
|
||||
@@ -743,25 +742,25 @@ void GameCommand::ApplySelf( const vector<PlayerNumber> &vpns ) const
|
||||
}
|
||||
}
|
||||
if( m_dc != Difficulty_Invalid )
|
||||
FOREACH_CONST( PlayerNumber, vpns, pn )
|
||||
GAMESTATE->m_PreferredDifficulty[*pn].Set( m_dc );
|
||||
for (PlayerNumber const &pn : vpns)
|
||||
GAMESTATE->m_PreferredDifficulty[pn].Set( m_dc );
|
||||
if( m_sAnnouncer != "" )
|
||||
ANNOUNCER->SwitchAnnouncer( m_sAnnouncer );
|
||||
if( m_sPreferredModifiers != "" )
|
||||
FOREACH_CONST( PlayerNumber, vpns, pn )
|
||||
GAMESTATE->ApplyPreferredModifiers( *pn, m_sPreferredModifiers );
|
||||
for (PlayerNumber const &pn : vpns)
|
||||
GAMESTATE->ApplyPreferredModifiers( pn, m_sPreferredModifiers );
|
||||
if( m_sStageModifiers != "" )
|
||||
FOREACH_CONST( PlayerNumber, vpns, pn )
|
||||
GAMESTATE->ApplyStageModifiers( *pn, m_sStageModifiers );
|
||||
for (PlayerNumber const &pn : vpns)
|
||||
GAMESTATE->ApplyStageModifiers( pn, m_sStageModifiers );
|
||||
if( m_LuaFunction.IsSet() && !m_LuaFunction.IsNil() )
|
||||
{
|
||||
Lua *L = LUA->Get();
|
||||
FOREACH_CONST( PlayerNumber, vpns, pn )
|
||||
for (PlayerNumber const &pn : vpns)
|
||||
{
|
||||
m_LuaFunction.PushSelf( L );
|
||||
ASSERT( !lua_isnil(L, -1) );
|
||||
|
||||
lua_pushnumber( L, *pn ); // 1st parameter
|
||||
lua_pushnumber( L, pn ); // 1st parameter
|
||||
RString error= "Lua GameCommand error: ";
|
||||
LuaHelpers::RunScriptOnStack(L, error, 1, 0, true);
|
||||
}
|
||||
@@ -775,22 +774,22 @@ void GameCommand::ApplySelf( const vector<PlayerNumber> &vpns ) const
|
||||
GAMESTATE->m_pPreferredSong = m_pSong;
|
||||
}
|
||||
if( m_pSteps )
|
||||
FOREACH_CONST( PlayerNumber, vpns, pn )
|
||||
GAMESTATE->m_pCurSteps[*pn].Set( m_pSteps );
|
||||
for (PlayerNumber const &pn : vpns)
|
||||
GAMESTATE->m_pCurSteps[pn].Set( m_pSteps );
|
||||
if( m_pCourse )
|
||||
{
|
||||
GAMESTATE->m_pCurCourse.Set( m_pCourse );
|
||||
GAMESTATE->m_pPreferredCourse = m_pCourse;
|
||||
}
|
||||
if( m_pTrail )
|
||||
FOREACH_CONST( PlayerNumber, vpns, pn )
|
||||
GAMESTATE->m_pCurTrail[*pn].Set( m_pTrail );
|
||||
for (PlayerNumber const &pn : vpns)
|
||||
GAMESTATE->m_pCurTrail[pn].Set( m_pTrail );
|
||||
if( m_CourseDifficulty != Difficulty_Invalid )
|
||||
FOREACH_CONST( PlayerNumber, vpns, pn )
|
||||
GAMESTATE->ChangePreferredCourseDifficulty( *pn, m_CourseDifficulty );
|
||||
for (PlayerNumber const &pn : vpns)
|
||||
GAMESTATE->ChangePreferredCourseDifficulty( pn, m_CourseDifficulty );
|
||||
if( m_pCharacter )
|
||||
FOREACH_CONST( PlayerNumber, vpns, pn )
|
||||
GAMESTATE->m_pCurCharacters[*pn] = m_pCharacter;
|
||||
for (PlayerNumber const &pn : vpns)
|
||||
GAMESTATE->m_pCurCharacters[pn] = m_pCharacter;
|
||||
for( map<RString,RString>::const_iterator i = m_SetEnv.begin(); i != m_SetEnv.end(); i++ )
|
||||
{
|
||||
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)
|
||||
{
|
||||
IPreference* pref= IPreference::GetPreferenceByName(setting->first);
|
||||
if(pref != NULL)
|
||||
if(pref != nullptr)
|
||||
{
|
||||
pref->FromString(setting->second);
|
||||
}
|
||||
@@ -816,17 +815,17 @@ void GameCommand::ApplySelf( const vector<PlayerNumber> &vpns ) const
|
||||
if( m_sSoundPath != "" )
|
||||
SOUND->PlayOnce( THEME->GetPathS( "", m_sSoundPath ) );
|
||||
if( m_iWeightPounds != -1 )
|
||||
FOREACH_CONST( PlayerNumber, vpns, pn )
|
||||
PROFILEMAN->GetProfile(*pn)->m_iWeightPounds = m_iWeightPounds;
|
||||
for (PlayerNumber const &pn : vpns)
|
||||
PROFILEMAN->GetProfile(pn)->m_iWeightPounds = m_iWeightPounds;
|
||||
if( m_iGoalCalories != -1 )
|
||||
FOREACH_CONST( PlayerNumber, vpns, pn )
|
||||
PROFILEMAN->GetProfile(*pn)->m_iGoalCalories = m_iGoalCalories;
|
||||
for (PlayerNumber const &pn : vpns)
|
||||
PROFILEMAN->GetProfile(pn)->m_iGoalCalories = m_iGoalCalories;
|
||||
if( m_GoalType != GoalType_Invalid )
|
||||
FOREACH_CONST( PlayerNumber, vpns, pn )
|
||||
PROFILEMAN->GetProfile(*pn)->m_GoalType = m_GoalType;
|
||||
for (PlayerNumber const &pn : vpns)
|
||||
PROFILEMAN->GetProfile(pn)->m_GoalType = m_GoalType;
|
||||
if( !m_sProfileID.empty() )
|
||||
FOREACH_CONST( PlayerNumber, vpns, pn )
|
||||
ProfileManager::m_sDefaultLocalProfileID[*pn].Set( m_sProfileID );
|
||||
for (PlayerNumber const &pn : vpns)
|
||||
ProfileManager::m_sDefaultLocalProfileID[pn].Set( m_sProfileID );
|
||||
if( !m_sUrl.empty() )
|
||||
{
|
||||
if( HOOKS->GoToURL( m_sUrl ) )
|
||||
@@ -845,8 +844,8 @@ void GameCommand::ApplySelf( const vector<PlayerNumber> &vpns ) const
|
||||
if( m_bFadeMusic )
|
||||
SOUND->DimMusic(m_fMusicFadeOutVolume, m_fMusicFadeOutSeconds);
|
||||
|
||||
FOREACH_CONST( RString, m_vsScreensToPrepare, s )
|
||||
SCREENMAN->PrepareScreen( *s );
|
||||
for (RString const &s : m_vsScreensToPrepare)
|
||||
SCREENMAN->PrepareScreen( s );
|
||||
|
||||
if( m_bInsertCredit )
|
||||
{
|
||||
@@ -886,16 +885,16 @@ void GameCommand::ApplySelf( const vector<PlayerNumber> &vpns ) const
|
||||
bool GameCommand::IsZero() const
|
||||
{
|
||||
if( m_pm != PlayMode_Invalid ||
|
||||
m_pStyle != NULL ||
|
||||
m_pStyle != nullptr ||
|
||||
m_dc != Difficulty_Invalid ||
|
||||
m_sAnnouncer != "" ||
|
||||
m_sPreferredModifiers != "" ||
|
||||
m_sStageModifiers != "" ||
|
||||
m_pSong != NULL ||
|
||||
m_pSteps != NULL ||
|
||||
m_pCourse != NULL ||
|
||||
m_pTrail != NULL ||
|
||||
m_pCharacter != NULL ||
|
||||
m_pSong != nullptr ||
|
||||
m_pSteps != nullptr ||
|
||||
m_pCourse != nullptr ||
|
||||
m_pTrail != nullptr ||
|
||||
m_pCharacter != nullptr ||
|
||||
m_CourseDifficulty != Difficulty_Invalid ||
|
||||
!m_sSongGroup.empty() ||
|
||||
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 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 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 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 GetSteps( T* p, lua_State *L ) { if(p->m_pSteps==NULL) 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 GetTrail( T* p, lua_State *L ) { if(p->m_pTrail==NULL) 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 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== nullptr) lua_pushnil(L); else p->m_pSteps->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== nullptr) lua_pushnil(L); else p->m_pTrail->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 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; }
|
||||
|
||||
+4
-4
@@ -28,13 +28,13 @@ public:
|
||||
GameCommand(): m_Commands(), m_sName(""), m_sText(""),
|
||||
m_bInvalid(true), m_sInvalidReason(""),
|
||||
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_CourseDifficulty(Difficulty_Invalid),
|
||||
m_sAnnouncer(""), m_sPreferredModifiers(""),
|
||||
m_sStageModifiers(""), m_sScreen(""), m_LuaFunction(),
|
||||
m_pSong(NULL), m_pSteps(NULL), m_pCourse(NULL),
|
||||
m_pTrail(NULL), m_pCharacter(NULL), m_SetEnv(), m_SetPref(),
|
||||
m_pSong(nullptr), m_pSteps(nullptr), m_pCourse(nullptr),
|
||||
m_pTrail(nullptr), m_pCharacter(nullptr), m_SetEnv(), m_SetPref(),
|
||||
m_sSongGroup(""), m_SortOrder(SortOrder_Invalid),
|
||||
m_sSoundPath(""), m_vsScreensToPrepare(), m_iWeightPounds(-1),
|
||||
m_iGoalCalories(-1), m_GoalType(GoalType_Invalid),
|
||||
@@ -60,7 +60,7 @@ public:
|
||||
|
||||
bool DescribesCurrentMode( PlayerNumber pn ) const;
|
||||
bool DescribesCurrentModeForAllPlayers() const;
|
||||
bool IsPlayable( RString *why = NULL ) const;
|
||||
bool IsPlayable( RString *why = nullptr ) const;
|
||||
bool IsZero() const;
|
||||
|
||||
/* If true, Apply() will apply m_sScreen. If false, it won't, and you need
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
#include "RageUtil.h"
|
||||
#include "ThemeMetric.h"
|
||||
#include "EnumHelper.h"
|
||||
#include "Foreach.h"
|
||||
|
||||
#include "LuaManager.h"
|
||||
#include "GameManager.h"
|
||||
#include "LocalizedString.h"
|
||||
@@ -375,10 +375,10 @@ void DisplayBpms::Add( float f )
|
||||
float DisplayBpms::GetMin() const
|
||||
{
|
||||
float fMin = FLT_MAX;
|
||||
FOREACH_CONST( float, vfBpms, f )
|
||||
for (float const &f : vfBpms)
|
||||
{
|
||||
if( *f != -1 )
|
||||
fMin = min( fMin, *f );
|
||||
if( f != -1 )
|
||||
fMin = min( fMin, f );
|
||||
}
|
||||
if( fMin == FLT_MAX )
|
||||
return 0;
|
||||
@@ -394,10 +394,10 @@ float DisplayBpms::GetMax() const
|
||||
float DisplayBpms::GetMaxWithin(float highest) const
|
||||
{
|
||||
float fMax = 0;
|
||||
FOREACH_CONST( float, vfBpms, f )
|
||||
for (float const &f : vfBpms)
|
||||
{
|
||||
if( *f != -1 )
|
||||
fMax = clamp(max( fMax, *f ), 0, highest);
|
||||
if( f != -1 )
|
||||
fMax = clamp(max( fMax, f ), 0, highest);
|
||||
}
|
||||
return fMax;
|
||||
}
|
||||
@@ -409,12 +409,7 @@ bool DisplayBpms::BpmIsConstant() const
|
||||
|
||||
bool DisplayBpms::IsSecret() const
|
||||
{
|
||||
FOREACH_CONST( float, vfBpms, f )
|
||||
{
|
||||
if( *f == -1 )
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return std::any_of(vfBpms.begin(), vfBpms.end(), [](float const &f) { return f == -1; });
|
||||
}
|
||||
|
||||
static const char *StyleTypeNames[] = {
|
||||
|
||||
+9
-10
@@ -76,13 +76,12 @@ static bool ChangeAppPri()
|
||||
if( INPUTMAN )
|
||||
{
|
||||
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." );
|
||||
return false;
|
||||
}
|
||||
LOG->Trace( "Using NTPAD. Don't boost priority." );
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -181,7 +180,7 @@ namespace
|
||||
void DoChangeGame()
|
||||
{
|
||||
const Game* g= GAMEMAN->StringToGame(g_NewGame);
|
||||
ASSERT(g != NULL);
|
||||
ASSERT(g != nullptr);
|
||||
GAMESTATE->SetCurGame(g);
|
||||
|
||||
bool theme_changing= false;
|
||||
@@ -358,7 +357,7 @@ private:
|
||||
enum State { RENDERING_IDLE, RENDERING_START, RENDERING_ACTIVE, RENDERING_END };
|
||||
State m_State;
|
||||
};
|
||||
static ConcurrentRenderer *g_pConcurrentRenderer = NULL;
|
||||
static ConcurrentRenderer *g_pConcurrentRenderer = nullptr;
|
||||
|
||||
ConcurrentRenderer::ConcurrentRenderer():
|
||||
m_Event("ConcurrentRenderer")
|
||||
@@ -405,7 +404,7 @@ void ConcurrentRenderer::Stop()
|
||||
|
||||
void ConcurrentRenderer::RenderThread()
|
||||
{
|
||||
ASSERT( SCREENMAN != NULL );
|
||||
ASSERT( SCREENMAN != nullptr );
|
||||
|
||||
while( !m_bShutdown )
|
||||
{
|
||||
@@ -462,7 +461,7 @@ int ConcurrentRenderer::StartRenderThread( void *p )
|
||||
|
||||
void GameLoop::StartConcurrentRendering()
|
||||
{
|
||||
if( g_pConcurrentRenderer == NULL )
|
||||
if( g_pConcurrentRenderer == nullptr )
|
||||
g_pConcurrentRenderer = new ConcurrentRenderer;
|
||||
g_pConcurrentRenderer->Start();
|
||||
}
|
||||
|
||||
+758
-759
File diff suppressed because it is too large
Load Diff
@@ -20,7 +20,7 @@
|
||||
|
||||
#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
|
||||
@@ -436,7 +436,7 @@ int MusicThread_start( void *p )
|
||||
GameSoundManager::GameSoundManager()
|
||||
{
|
||||
/* Init RageSoundMan first: */
|
||||
ASSERT( SOUNDMAN != NULL );
|
||||
ASSERT( SOUNDMAN != nullptr );
|
||||
|
||||
g_Mutex = new RageEvent("GameSoundManager");
|
||||
g_Playing = new MusicPlaying( new RageSound );
|
||||
@@ -875,7 +875,7 @@ public:
|
||||
{
|
||||
alignBeat = BArg(8);
|
||||
}
|
||||
p->PlayMusic(musicPath, NULL, loop, musicStart, musicLength,
|
||||
p->PlayMusic(musicPath, nullptr, loop, musicStart, musicLength,
|
||||
fadeIn, fadeOut, alignBeat, applyRate);
|
||||
COMMON_RETURN_SELF;
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ public:
|
||||
{
|
||||
PlayMusicParams()
|
||||
{
|
||||
pTiming = NULL;
|
||||
pTiming = nullptr;
|
||||
bForceLoop = false;
|
||||
fStartSecond = 0;
|
||||
fLengthSeconds = -1;
|
||||
@@ -44,7 +44,7 @@ public:
|
||||
void PlayMusic( PlayMusicParams params, PlayMusicParams FallbackMusicParams = PlayMusicParams() );
|
||||
void PlayMusic(
|
||||
RString sFile,
|
||||
const TimingData *pTiming = NULL,
|
||||
const TimingData *pTiming = nullptr,
|
||||
bool force_loop = false,
|
||||
float start_sec = 0,
|
||||
float length_sec = -1,
|
||||
|
||||
+97
-99
@@ -10,7 +10,6 @@
|
||||
#include "CommonMetrics.h"
|
||||
#include "Course.h"
|
||||
#include "CryptManager.h"
|
||||
#include "Foreach.h"
|
||||
#include "Game.h"
|
||||
#include "GameCommand.h"
|
||||
#include "GameConstantsAndTypes.h"
|
||||
@@ -46,7 +45,7 @@
|
||||
#include <ctime>
|
||||
#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"
|
||||
|
||||
@@ -80,7 +79,7 @@ struct GameStateImpl
|
||||
m_Subscriber.SubscribeToMessage( "RefreshCreditText" );
|
||||
}
|
||||
};
|
||||
static GameStateImpl *g_pImpl = NULL;
|
||||
static GameStateImpl *g_pImpl = nullptr;
|
||||
|
||||
ThemeMetric<bool> ALLOW_LATE_JOIN("GameState","AllowLateJoin");
|
||||
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 );
|
||||
|
||||
GameState::GameState() :
|
||||
processedTiming( NULL ),
|
||||
processedTiming(nullptr),
|
||||
m_pCurGame( Message_CurrentGameChanged ),
|
||||
m_pCurStyle( Message_CurrentStyleChanged ),
|
||||
m_PlayMode( Message_PlayModeChanged ),
|
||||
@@ -139,13 +138,13 @@ GameState::GameState() :
|
||||
{
|
||||
g_pImpl = new GameStateImpl;
|
||||
|
||||
m_pCurStyle.Set(NULL);
|
||||
m_pCurStyle.Set(nullptr);
|
||||
FOREACH_PlayerNumber(rpn)
|
||||
{
|
||||
m_SeparatedStyles[rpn]= NULL;
|
||||
m_SeparatedStyles[rpn]= nullptr;
|
||||
}
|
||||
|
||||
m_pCurGame.Set( NULL );
|
||||
m_pCurGame.Set(nullptr);
|
||||
m_iCoins.Set( 0 );
|
||||
m_timeGameStarted.SetZero();
|
||||
m_bDemonstrationOrJukebox = false;
|
||||
@@ -247,7 +246,7 @@ void GameState::ApplyCmdline()
|
||||
RString sPlayer;
|
||||
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 )
|
||||
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_iPlayerStageTokens[pn] = 0;
|
||||
m_iAwardedExtraStages[pn] = 0;
|
||||
m_pCurSteps[pn].Set( NULL );
|
||||
m_pCurTrail[pn].Set( NULL );
|
||||
m_pCurSteps[pn].Set(nullptr);
|
||||
m_pCurTrail[pn].Set(nullptr);
|
||||
m_pPlayerState[pn]->Reset();
|
||||
PROFILEMAN->UnloadProfile( pn );
|
||||
ResetPlayerOptions(pn);
|
||||
@@ -289,15 +288,14 @@ void GameState::Reset()
|
||||
FOREACH_PlayerNumber( pn )
|
||||
UnjoinPlayer( pn );
|
||||
|
||||
ASSERT( THEME != NULL );
|
||||
ASSERT( THEME != nullptr );
|
||||
|
||||
m_timeGameStarted.SetZero();
|
||||
SetCurrentStyle( NULL, PLAYER_INVALID );
|
||||
SetCurrentStyle( nullptr, PLAYER_INVALID );
|
||||
FOREACH_MultiPlayer( p )
|
||||
m_MultiPlayerStatus[p] = MultiPlayerStatus_NotJoined;
|
||||
FOREACH_PlayerNumber( pn )
|
||||
MEMCARDMAN->UnlockCard( pn );
|
||||
//m_iCoins = 0; // don't reset coin count!
|
||||
m_bMultiplayer = false;
|
||||
m_iNumMultiplayerNoteFields = 1;
|
||||
*m_Environment = LuaTable();
|
||||
@@ -324,9 +322,9 @@ void GameState::Reset()
|
||||
m_AdjustTokensBySongCostForFinalStageCheck= true;
|
||||
|
||||
m_pCurSong.Set( GetDefaultSong() );
|
||||
m_pPreferredSong = NULL;
|
||||
m_pCurCourse.Set( NULL );
|
||||
m_pPreferredCourse = NULL;
|
||||
m_pPreferredSong = nullptr;
|
||||
m_pCurCourse.Set(nullptr);
|
||||
m_pPreferredCourse = nullptr;
|
||||
|
||||
FOREACH_MultiPlayer( p )
|
||||
m_pMultiPlayerState[p]->Reset();
|
||||
@@ -353,7 +351,7 @@ void GameState::Reset()
|
||||
m_pCurCharacters[p] = CHARMAN->GetRandomCharacter();
|
||||
else
|
||||
m_pCurCharacters[p] = CHARMAN->GetDefaultCharacter();
|
||||
ASSERT( m_pCurCharacters[p] != NULL );
|
||||
ASSERT( m_pCurCharacters[p] != nullptr );
|
||||
}
|
||||
|
||||
m_bTemporaryEventMode = false;
|
||||
@@ -361,7 +359,7 @@ void GameState::Reset()
|
||||
LIGHTSMAN->SetLightsMode( LIGHTSMODE_ATTRACT );
|
||||
|
||||
m_stEdit.Set( StepsType_Invalid );
|
||||
m_pEditSourceSteps.Set( NULL );
|
||||
m_pEditSourceSteps.Set(nullptr);
|
||||
m_stEditSource.Set( StepsType_Invalid );
|
||||
m_iEditCourseEntryIndex.Set( -1 );
|
||||
m_sEditLocalProfileID.Set( "" );
|
||||
@@ -389,7 +387,7 @@ void GameState::JoinPlayer( PlayerNumber pn )
|
||||
{
|
||||
const Style* new_style= GAMEMAN->GetFirstCompatibleStyle(m_pCurGame,
|
||||
players_joined + 1, cur_style->m_StepsType);
|
||||
if(new_style == NULL)
|
||||
if(new_style == nullptr)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -427,7 +425,7 @@ void GameState::JoinPlayer( PlayerNumber pn )
|
||||
// assume that the second player will be joined immediately afterwards and
|
||||
// don't try to change the style. -Kyz
|
||||
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_TwoPlayersSharedSides)))
|
||||
{
|
||||
@@ -684,7 +682,7 @@ int GameState::GetNumStagesMultiplierForSong( const Song* pSong )
|
||||
{
|
||||
int iNumStages = 1;
|
||||
|
||||
ASSERT( pSong != NULL );
|
||||
ASSERT( pSong != nullptr );
|
||||
if( pSong->IsMarathon() )
|
||||
iNumStages *= 3;
|
||||
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)
|
||||
if( m_PreferredStepsType == StepsType_Invalid && pProfile->m_LastStepsType != StepsType_Invalid )
|
||||
m_PreferredStepsType.Set( pProfile->m_LastStepsType );
|
||||
if( m_pPreferredSong == NULL )
|
||||
if( m_pPreferredSong == nullptr )
|
||||
m_pPreferredSong = pProfile->m_lastSong.ToSong();
|
||||
if( m_pPreferredCourse == NULL )
|
||||
if( m_pPreferredCourse == nullptr )
|
||||
m_pPreferredCourse = pProfile->m_lastCourse.ToCourse();
|
||||
}
|
||||
|
||||
@@ -918,35 +916,35 @@ bool GameState::CanSafelyEnterGameplay(RString& reason)
|
||||
if(!IsCourseMode())
|
||||
{
|
||||
Song const* song= m_pCurSong;
|
||||
if(song == NULL)
|
||||
if(song == nullptr)
|
||||
{
|
||||
reason= "Current song is NULL.";
|
||||
reason= "Current song is null.";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Course const* song= m_pCurCourse;
|
||||
if(song == NULL)
|
||||
if(song == nullptr)
|
||||
{
|
||||
reason= "Current course is NULL.";
|
||||
reason= "Current course is null.";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
FOREACH_EnabledPlayer(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;
|
||||
}
|
||||
if(!IsCourseMode())
|
||||
{
|
||||
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;
|
||||
}
|
||||
if(steps->m_StepsType != style->m_StepsType)
|
||||
@@ -975,9 +973,9 @@ bool GameState::CanSafelyEnterGameplay(RString& reason)
|
||||
else
|
||||
{
|
||||
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;
|
||||
}
|
||||
if(steps->m_StepsType != style->m_StepsType)
|
||||
@@ -998,16 +996,16 @@ void GameState::SetCompatibleStylesForPlayers()
|
||||
bool style_set= false;
|
||||
if(IsCourseMode())
|
||||
{
|
||||
if(m_pCurCourse != NULL)
|
||||
if(m_pCurCourse != nullptr)
|
||||
{
|
||||
const Style* style= m_pCurCourse->GetCourseStyle(m_pCurGame, GetNumSidesJoined());
|
||||
if(style != NULL)
|
||||
if(style != nullptr)
|
||||
{
|
||||
style_set= true;
|
||||
SetCurrentStyle(style, PLAYER_INVALID);
|
||||
}
|
||||
}
|
||||
else if(GetCurrentStyle(PLAYER_INVALID) == NULL)
|
||||
else if(GetCurrentStyle(PLAYER_INVALID) == nullptr)
|
||||
{
|
||||
vector<StepsType> vst;
|
||||
GAMEMAN->GetStepsTypesForGame(m_pCurGame, vst);
|
||||
@@ -1021,11 +1019,11 @@ void GameState::SetCompatibleStylesForPlayers()
|
||||
FOREACH_EnabledPlayer(pn)
|
||||
{
|
||||
StepsType st= StepsType_Invalid;
|
||||
if(m_pCurSteps[pn] != NULL)
|
||||
if(m_pCurSteps[pn] != nullptr)
|
||||
{
|
||||
st= m_pCurSteps[pn]->m_StepsType;
|
||||
}
|
||||
else if(m_pCurTrail[pn] != NULL)
|
||||
else if(m_pCurTrail[pn] != nullptr)
|
||||
{
|
||||
st= m_pCurTrail[pn]->m_StepsType;
|
||||
}
|
||||
@@ -1045,11 +1043,11 @@ void GameState::SetCompatibleStylesForPlayers()
|
||||
void GameState::ForceSharedSidesMatch()
|
||||
{
|
||||
PlayerNumber pn_with_shared= PLAYER_INVALID;
|
||||
const Style* shared_style= NULL;
|
||||
const Style* shared_style= nullptr;
|
||||
FOREACH_EnabledPlayer(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)
|
||||
{
|
||||
pn_with_shared= pn;
|
||||
@@ -1061,7 +1059,7 @@ void GameState::ForceSharedSidesMatch()
|
||||
ASSERT_M(GetNumPlayersEnabled() == 2, "2 players must be enabled for shared sides.");
|
||||
PlayerNumber other_pn= OPPOSITE_PLAYER[pn_with_shared];
|
||||
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)
|
||||
{
|
||||
SetCurrentStyle(shared_style, other_pn);
|
||||
@@ -1082,7 +1080,7 @@ void GameState::ForceOtherPlayersToCompatibleSteps(PlayerNumber main)
|
||||
if(IsCourseMode())
|
||||
{
|
||||
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();
|
||||
StyleType styletype_to_match= GAMEMAN->GetFirstCompatibleStyle(
|
||||
GAMESTATE->GetCurrentGame(), num_players, steps_to_match->m_StepsType)
|
||||
@@ -1090,8 +1088,8 @@ void GameState::ForceOtherPlayersToCompatibleSteps(PlayerNumber main)
|
||||
FOREACH_EnabledPlayer(pn)
|
||||
{
|
||||
Trail* pn_steps= m_pCurTrail[pn].Get();
|
||||
bool match_failed= pn_steps == NULL;
|
||||
if(steps_to_match != pn_steps && pn_steps != NULL)
|
||||
bool match_failed= pn_steps == nullptr;
|
||||
if(steps_to_match != pn_steps && pn_steps != nullptr)
|
||||
{
|
||||
StyleType pn_styletype= GAMEMAN->GetFirstCompatibleStyle(
|
||||
GAMESTATE->GetCurrentGame(), num_players, pn_steps->m_StepsType)
|
||||
@@ -1111,7 +1109,7 @@ void GameState::ForceOtherPlayersToCompatibleSteps(PlayerNumber main)
|
||||
else
|
||||
{
|
||||
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();
|
||||
StyleType styletype_to_match= GAMEMAN->GetFirstCompatibleStyle(
|
||||
GAMESTATE->GetCurrentGame(), num_players, steps_to_match->m_StepsType)
|
||||
@@ -1120,8 +1118,8 @@ void GameState::ForceOtherPlayersToCompatibleSteps(PlayerNumber main)
|
||||
FOREACH_EnabledPlayer(pn)
|
||||
{
|
||||
Steps* pn_steps= m_pCurSteps[pn].Get();
|
||||
bool match_failed= pn_steps == NULL;
|
||||
if(steps_to_match != pn_steps && pn_steps != NULL)
|
||||
bool match_failed= pn_steps == nullptr;
|
||||
if(steps_to_match != pn_steps && pn_steps != nullptr)
|
||||
{
|
||||
StyleType pn_styletype= GAMEMAN->GetFirstCompatibleStyle(
|
||||
GAMESTATE->GetCurrentGame(), num_players, pn_steps->m_StepsType)
|
||||
@@ -1315,7 +1313,7 @@ bool GameState::IsFinalStageForAnyHumanPlayer() const
|
||||
bool GameState::IsFinalStageForEveryHumanPlayer() const
|
||||
{
|
||||
int song_cost= 1;
|
||||
if(m_pCurSong != NULL)
|
||||
if(m_pCurSong != nullptr)
|
||||
{
|
||||
if(m_pCurSong->IsLong())
|
||||
{
|
||||
@@ -1434,7 +1432,7 @@ static char const* prepare_song_failures[]= {
|
||||
int GameState::prepare_song_for_gameplay()
|
||||
{
|
||||
Song* curr= m_pCurSong;
|
||||
if(curr == NULL)
|
||||
if(curr == nullptr)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
@@ -1504,9 +1502,9 @@ bool GameState::PlayersCanJoin() const
|
||||
{
|
||||
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.
|
||||
// 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.
|
||||
// Either way, we can't use the existence of a style to decide.
|
||||
// -Kyz
|
||||
@@ -1529,7 +1527,7 @@ bool GameState::PlayersCanJoin() const
|
||||
{
|
||||
const Style* compat_style= GAMEMAN->GetFirstCompatibleStyle(
|
||||
m_pCurGame, 2, style->m_StepsType);
|
||||
if(compat_style == NULL)
|
||||
if(compat_style == nullptr)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -1551,13 +1549,13 @@ int GameState::GetNumSidesJoined() 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;
|
||||
}
|
||||
|
||||
const Style* GameState::GetCurrentStyle(PlayerNumber pn) const
|
||||
{
|
||||
if(GetCurrentGame() == NULL) { return NULL; }
|
||||
if(GetCurrentGame() == nullptr) { return nullptr; }
|
||||
if(!GetCurrentGame()->m_PlayersHaveSeparateStyles)
|
||||
{
|
||||
return m_pCurStyle;
|
||||
@@ -1566,7 +1564,7 @@ const Style* GameState::GetCurrentStyle(PlayerNumber pn) const
|
||||
{
|
||||
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];
|
||||
}
|
||||
return m_SeparatedStyles[pn];
|
||||
@@ -1677,7 +1675,7 @@ bool GameState::IsHumanPlayer( PlayerNumber pn ) const
|
||||
|
||||
if(GetCurrentGame()->m_PlayersHaveSeparateStyles)
|
||||
{
|
||||
if( GetCurrentStyle(pn) == NULL ) // no style chosen
|
||||
if( GetCurrentStyle(pn) == nullptr ) // no style chosen
|
||||
{
|
||||
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
|
||||
}
|
||||
@@ -1942,12 +1940,12 @@ void GameState::GetAllUsedNoteSkins( vector<RString> &out ) const
|
||||
if( IsCourseMode() )
|
||||
{
|
||||
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;
|
||||
po.FromString( e->Modifiers );
|
||||
po.FromString( e.Modifiers );
|
||||
if( !po.m_sNoteSkin.empty() )
|
||||
out.push_back( po.m_sNoteSkin );
|
||||
}
|
||||
@@ -2074,11 +2072,11 @@ void GameState::GetRankingFeats( PlayerNumber pn, vector<RankingFeat> &asFeatsOu
|
||||
SongAndSteps sas;
|
||||
ASSERT( !STATSMAN->m_vPlayedStageStats[i].m_vpPlayedSongs.empty() );
|
||||
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() )
|
||||
continue;
|
||||
sas.pSteps = STATSMAN->m_vPlayedStageStats[i].m_player[pn].m_vpPossibleSteps[0];
|
||||
ASSERT( sas.pSteps != NULL );
|
||||
ASSERT( sas.pSteps != nullptr );
|
||||
vSongAndSteps.push_back( sas );
|
||||
}
|
||||
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:
|
||||
{
|
||||
Course* pCourse = m_pCurCourse;
|
||||
ASSERT( pCourse != NULL );
|
||||
ASSERT( pCourse != nullptr );
|
||||
Trail *pTrail = m_pCurTrail[pn];
|
||||
ASSERT( pTrail != NULL );
|
||||
ASSERT( pTrail != nullptr );
|
||||
CourseDifficulty cd = pTrail->m_CourseDifficulty;
|
||||
|
||||
// Find Machine Records
|
||||
@@ -2336,23 +2334,23 @@ void GameState::StoreRankingName( PlayerNumber pn, RString sName )
|
||||
if( !PREFSMAN->m_bAllowMultipleHighScoreWithSameName )
|
||||
{
|
||||
// erase all but the highest score for each name
|
||||
FOREACHM( SongID, Profile::HighScoresForASong, pProfile->m_SongHighScores, iter )
|
||||
FOREACHM( StepsID, Profile::HighScoresForASteps, iter->second.m_StepsHighScores, iter2 )
|
||||
iter2->second.hsl.RemoveAllButOneOfEachName();
|
||||
for (auto &songIter : pProfile->m_SongHighScores)
|
||||
for (auto &stepIter : songIter.second.m_StepsHighScores)
|
||||
stepIter.second.hsl.RemoveAllButOneOfEachName();
|
||||
|
||||
FOREACHM( CourseID, Profile::HighScoresForACourse, pProfile->m_CourseHighScores, iter )
|
||||
FOREACHM( TrailID, Profile::HighScoresForATrail, iter->second.m_TrailHighScores, iter2 )
|
||||
iter2->second.hsl.RemoveAllButOneOfEachName();
|
||||
for (auto &courseIter : pProfile->m_CourseHighScores)
|
||||
for (auto &trailIter : courseIter.second.m_TrailHighScores)
|
||||
trailIter.second.hsl.RemoveAllButOneOfEachName();
|
||||
}
|
||||
|
||||
// clamp high score sizes
|
||||
FOREACHM( SongID, Profile::HighScoresForASong, pProfile->m_SongHighScores, iter )
|
||||
FOREACHM( StepsID, Profile::HighScoresForASteps, iter->second.m_StepsHighScores, iter2 )
|
||||
iter2->second.hsl.ClampSize( true );
|
||||
for (auto &songIter : pProfile->m_SongHighScores)
|
||||
for (auto &stepIter : songIter.second.m_StepsHighScores)
|
||||
stepIter.second.hsl.ClampSize( true );
|
||||
|
||||
FOREACHM( CourseID, Profile::HighScoresForACourse, pProfile->m_CourseHighScores, iter )
|
||||
FOREACHM( TrailID, Profile::HighScoresForATrail, iter->second.m_TrailHighScores, iter2 )
|
||||
iter2->second.hsl.ClampSize( true );
|
||||
for (auto &courseIter : pProfile->m_CourseHighScores)
|
||||
for (auto &trailIter : courseIter.second.m_TrailHighScores)
|
||||
trailIter.second.hsl.ClampSize( true );
|
||||
}
|
||||
|
||||
bool GameState::AllAreInDangerOrWorse() const
|
||||
@@ -2452,15 +2450,15 @@ Difficulty GameState::GetClosestShownDifficulty( PlayerNumber pn ) const
|
||||
|
||||
Difficulty iClosest = (Difficulty) 0;
|
||||
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 )
|
||||
continue;
|
||||
if( iClosestDist != -1 && iDist > iClosestDist )
|
||||
continue;
|
||||
iClosestDist = iDist;
|
||||
iClosest = *dc;
|
||||
iClosest = dc;
|
||||
}
|
||||
|
||||
return iClosest;
|
||||
@@ -2516,7 +2514,7 @@ Difficulty GameState::GetEasiestStepsDifficulty() const
|
||||
Difficulty dc = Difficulty_Invalid;
|
||||
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 );
|
||||
continue;
|
||||
@@ -2531,7 +2529,7 @@ Difficulty GameState::GetHardestStepsDifficulty() const
|
||||
Difficulty dc = Difficulty_Beginner;
|
||||
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 );
|
||||
continue;
|
||||
@@ -2608,7 +2606,7 @@ bool GameState::PlayerIsUsingModifier( PlayerNumber pn, const RString &sModifier
|
||||
Profile* GameState::GetEditLocalProfile()
|
||||
{
|
||||
if( m_sEditLocalProfileID.Get().empty() )
|
||||
return NULL;
|
||||
return nullptr;
|
||||
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 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 ); }
|
||||
COMMON_RETURN_SELF;
|
||||
}
|
||||
@@ -2750,7 +2748,7 @@ public:
|
||||
PlayerNumber pn = Enum::Check<PlayerNumber>(L, 1);
|
||||
if(lua_isnil(L,2))
|
||||
{
|
||||
p->m_pCurSteps[pn].Set(NULL);
|
||||
p->m_pCurSteps[pn].Set(nullptr);
|
||||
}
|
||||
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 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 ); }
|
||||
COMMON_RETURN_SELF;
|
||||
}
|
||||
@@ -2781,7 +2779,7 @@ public:
|
||||
PlayerNumber pn = Enum::Check<PlayerNumber>(L, 1);
|
||||
if(lua_isnil(L,2))
|
||||
{
|
||||
p->m_pCurTrail[pn].Set(NULL);
|
||||
p->m_pCurTrail[pn].Set(nullptr);
|
||||
}
|
||||
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 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; }
|
||||
COMMON_RETURN_SELF;
|
||||
}
|
||||
@@ -2941,7 +2939,7 @@ public:
|
||||
static int GetCurrentStepsCredits( T* t, lua_State *L )
|
||||
{
|
||||
const Song* pSong = t->m_pCurSong;
|
||||
if( pSong == NULL )
|
||||
if( pSong == nullptr )
|
||||
return 0;
|
||||
|
||||
// use a vector and not a set so that ordering is maintained
|
||||
@@ -2949,7 +2947,7 @@ public:
|
||||
FOREACH_HumanPlayer( p )
|
||||
{
|
||||
const Steps* pSteps = GAMESTATE->m_pCurSteps[p];
|
||||
if( pSteps == NULL )
|
||||
if( pSteps == nullptr )
|
||||
return 0;
|
||||
bool bAlreadyAdded = find( vpStepsToShow.begin(), vpStepsToShow.end(), pSteps ) != vpStepsToShow.end();
|
||||
if( !bAlreadyAdded )
|
||||
@@ -3127,9 +3125,9 @@ public:
|
||||
{
|
||||
vector<const Style*> 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;
|
||||
}
|
||||
@@ -3147,18 +3145,18 @@ public:
|
||||
const Style *style = p->GetCurrentStyle(pn);
|
||||
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 ) )
|
||||
{
|
||||
p->m_pCurTrail[pn].Set( NULL );
|
||||
p->m_pCurTrail[pn].Set( nullptr );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static int SetCurrentStyle( T* p, lua_State *L )
|
||||
{
|
||||
const Style* pStyle = NULL;
|
||||
const Style* pStyle = nullptr;
|
||||
if( lua_isstring(L,1) )
|
||||
{
|
||||
RString style = SArg(1);
|
||||
@@ -3217,19 +3215,19 @@ public:
|
||||
// 3. Copy steps to new difficulty to edit:
|
||||
// song, steps, stepstype, difficulty
|
||||
Song* song= Luna<Song>::check(L, 1);
|
||||
Steps* steps= NULL;
|
||||
Steps* steps= nullptr;
|
||||
if(!lua_isnil(L, 2))
|
||||
{
|
||||
steps= Luna<Steps>::check(L, 2);
|
||||
}
|
||||
// Form 1.
|
||||
if(steps != NULL && lua_gettop(L) == 2)
|
||||
if(steps != nullptr && lua_gettop(L) == 2)
|
||||
{
|
||||
p->m_pCurSong.Set(song);
|
||||
p->m_pCurSteps[PLAYER_1].Set(steps);
|
||||
p->SetCurrentStyle(GAMEMAN->GetEditorStyleForStepsType(
|
||||
steps->m_StepsType), PLAYER_INVALID);
|
||||
p->m_pCurCourse.Set(NULL);
|
||||
p->m_pCurCourse.Set(nullptr);
|
||||
return 0;
|
||||
}
|
||||
StepsType stype= Enum::Check<StepsType>(L, 3);
|
||||
@@ -3237,7 +3235,7 @@ public:
|
||||
Steps* new_steps= song->CreateSteps();
|
||||
RString edit_name;
|
||||
// Form 2.
|
||||
if(steps == NULL)
|
||||
if(steps == nullptr)
|
||||
{
|
||||
new_steps->CreateBlank(stype);
|
||||
new_steps->SetMeter(1);
|
||||
@@ -3256,7 +3254,7 @@ public:
|
||||
p->m_pCurSteps[PLAYER_1].Set(steps);
|
||||
p->SetCurrentStyle(GAMEMAN->GetEditorStyleForStepsType(
|
||||
steps->m_StepsType), PLAYER_INVALID);
|
||||
p->m_pCurCourse.Set(NULL);
|
||||
p->m_pCurCourse.Set(nullptr);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -246,13 +246,13 @@ public:
|
||||
|
||||
// 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;
|
||||
// The last Song that the user manually changed to.
|
||||
Song* m_pPreferredSong;
|
||||
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;
|
||||
// The last Course that the user manually changed to.
|
||||
Course* m_pPreferredCourse;
|
||||
|
||||
+14
-14
@@ -8,7 +8,6 @@
|
||||
#include "RageLog.h"
|
||||
#include "RageMath.h"
|
||||
#include "StageStats.h"
|
||||
#include "Foreach.h"
|
||||
#include "Song.h"
|
||||
#include "XmlFile.h"
|
||||
|
||||
@@ -126,7 +125,7 @@ public:
|
||||
~GraphBody()
|
||||
{
|
||||
TEXTUREMAN->UnloadTexture( m_pTexture );
|
||||
m_pTexture = NULL;
|
||||
m_pTexture = nullptr;
|
||||
}
|
||||
|
||||
void DrawPrimitives()
|
||||
@@ -150,14 +149,16 @@ public:
|
||||
|
||||
GraphDisplay::GraphDisplay()
|
||||
{
|
||||
m_pGraphLine = NULL;
|
||||
m_pGraphBody = NULL;
|
||||
m_pGraphLine = nullptr;
|
||||
m_pGraphBody = nullptr;
|
||||
}
|
||||
|
||||
GraphDisplay::~GraphDisplay()
|
||||
{
|
||||
FOREACH( Actor*, m_vpSongBoundaries, p )
|
||||
SAFE_DELETE( *p );
|
||||
for (Actor *p : m_vpSongBoundaries)
|
||||
{
|
||||
SAFE_DELETE( p );
|
||||
}
|
||||
m_vpSongBoundaries.clear();
|
||||
SAFE_DELETE( m_pGraphLine );
|
||||
SAFE_DELETE( m_pGraphBody );
|
||||
@@ -176,18 +177,17 @@ void GraphDisplay::Set( const StageStats &ss, const PlayerStageStats &pss )
|
||||
|
||||
// Show song boundaries
|
||||
float fSec = 0;
|
||||
FOREACH_CONST( Song*, ss.m_vpPossibleSongs, song )
|
||||
{
|
||||
if( song == ss.m_vpPossibleSongs.end()-1 )
|
||||
continue;
|
||||
fSec += (*song)->GetStepsSeconds();
|
||||
vector<Song *> const &possibleSongs = ss.m_vpPossibleSongs;
|
||||
|
||||
std::for_each(possibleSongs.begin(), possibleSongs.end() - 1, [&](Song *song) {
|
||||
fSec += song->GetStepsSeconds();
|
||||
|
||||
Actor *p = m_sprSongBoundary->Copy();
|
||||
m_vpSongBoundaries.push_back( p );
|
||||
float fX = SCALE( fSec, 0, fTotalStepSeconds, m_quadVertices.left, m_quadVertices.right );
|
||||
p->SetX( fX );
|
||||
this->AddChild( p );
|
||||
}
|
||||
});
|
||||
|
||||
if( !pss.m_bFailed )
|
||||
{
|
||||
@@ -288,11 +288,11 @@ public:
|
||||
{
|
||||
StageStats *pStageStats = Luna<StageStats>::check( L, 1 );
|
||||
PlayerStageStats *pPlayerStageStats = Luna<PlayerStageStats>::check( L, 2 );
|
||||
if(pStageStats == NULL)
|
||||
if(pStageStats == nullptr)
|
||||
{
|
||||
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.");
|
||||
}
|
||||
|
||||
+3
-3
@@ -58,7 +58,7 @@ void GrooveRadar::LoadFromNode( const XNode* pNode )
|
||||
|
||||
void GrooveRadar::SetEmpty( PlayerNumber pn )
|
||||
{
|
||||
SetFromSteps( pn, NULL );
|
||||
SetFromSteps( pn, nullptr );
|
||||
}
|
||||
|
||||
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 );
|
||||
}
|
||||
|
||||
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();
|
||||
return;
|
||||
|
||||
+1
-1
@@ -24,7 +24,7 @@ public:
|
||||
/**
|
||||
* @brief Give the Player a GrooveRadar based on some Steps.
|
||||
* @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 SetFromValues( PlayerNumber pn, vector<float> vals );
|
||||
|
||||
|
||||
+1
-2
@@ -5,7 +5,6 @@
|
||||
#include "PlayerNumber.h"
|
||||
#include "ThemeManager.h"
|
||||
#include "XmlFile.h"
|
||||
#include "Foreach.h"
|
||||
#include "RadarValues.h"
|
||||
|
||||
#include <algorithm>
|
||||
@@ -406,7 +405,7 @@ void HighScoreList::LoadFromNode( const XNode* pHighScoreList )
|
||||
|
||||
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++ )
|
||||
{
|
||||
|
||||
+12
-11
@@ -1,7 +1,6 @@
|
||||
#include "global.h"
|
||||
|
||||
#include "ImageCache.h"
|
||||
#include "Foreach.h"
|
||||
#include "RageDisplay.h"
|
||||
#include "RageUtil.h"
|
||||
#include "RageLog.h"
|
||||
@@ -79,7 +78,7 @@ void ImageCache::Demand( RString sImageDir )
|
||||
|
||||
const RString sCachePath = GetImageCachePath(sImageDir,sImagePath);
|
||||
RageSurface *pImage = RageSurfaceUtils::LoadSurface( sCachePath );
|
||||
if( pImage == NULL )
|
||||
if( pImage == nullptr )
|
||||
{
|
||||
continue; /* doesn't exist */
|
||||
}
|
||||
@@ -123,7 +122,7 @@ void ImageCache::LoadImage( RString sImageDir, RString sImagePath )
|
||||
|
||||
CHECKPOINT_M( ssprintf( "ImageCache::LoadImage: %s", sCachePath.c_str() ) );
|
||||
RageSurface *pImage = RageSurfaceUtils::LoadSurface( sCachePath );
|
||||
if( pImage == NULL )
|
||||
if( pImage == nullptr )
|
||||
{
|
||||
if( tries == 0 )
|
||||
{
|
||||
@@ -150,9 +149,9 @@ void ImageCache::LoadImage( RString sImageDir, RString sImagePath )
|
||||
void ImageCache::OutputStats() const
|
||||
{
|
||||
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;
|
||||
iTotalSize += iSize;
|
||||
}
|
||||
@@ -161,8 +160,10 @@ void ImageCache::OutputStats() const
|
||||
|
||||
void ImageCache::UnloadAllImages()
|
||||
{
|
||||
FOREACHM( RString, RageSurface *, g_ImagePathToImage, it )
|
||||
delete it->second;
|
||||
for (auto &it: g_ImagePathToImage)
|
||||
{
|
||||
delete it.second;
|
||||
}
|
||||
|
||||
g_ImagePathToImage.clear();
|
||||
}
|
||||
@@ -203,7 +204,7 @@ struct ImageTexture: public RageTexture
|
||||
|
||||
void Create()
|
||||
{
|
||||
ASSERT( m_pImage != NULL );
|
||||
ASSERT( m_pImage != nullptr );
|
||||
|
||||
/* The image is preprocessed; do as little work as possible. */
|
||||
|
||||
@@ -239,7 +240,7 @@ struct ImageTexture: public RageTexture
|
||||
|
||||
ASSERT( DISPLAY->SupportsTextureFormat(pf) );
|
||||
|
||||
ASSERT(m_pImage != NULL);
|
||||
ASSERT(m_pImage != nullptr);
|
||||
m_uTexHandle = DISPLAY->CreateTexture( pf, m_pImage, false );
|
||||
|
||||
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
|
||||
* only have to convert once. */
|
||||
RageSurface *&pImage = g_ImagePathToImage[sImagePath];
|
||||
ASSERT( pImage != NULL );
|
||||
ASSERT( pImage != nullptr );
|
||||
|
||||
int iSourceWidth = 0, iSourceHeight = 0;
|
||||
ImageData.GetValue( sImagePath, "Width", iSourceWidth );
|
||||
@@ -373,7 +374,7 @@ void ImageCache::CacheImageInternal( RString sImageDir, RString sImagePath )
|
||||
{
|
||||
RString 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() );
|
||||
return;
|
||||
|
||||
+8
-8
@@ -9,7 +9,7 @@ http://en.wikipedia.org/wiki/INI_file
|
||||
#include "RageUtil.h"
|
||||
#include "RageLog.h"
|
||||
#include "RageFile.h"
|
||||
#include "Foreach.h"
|
||||
|
||||
|
||||
IniFile::IniFile(): XNode("IniFile")
|
||||
{
|
||||
@@ -35,7 +35,7 @@ bool IniFile::ReadFile( RageFileBasic &f )
|
||||
{
|
||||
RString keyname;
|
||||
// keychild is used to cache the node that values are being added to. -Kyz
|
||||
XNode* keychild= NULL;
|
||||
XNode* keychild= nullptr;
|
||||
for(;;)
|
||||
{
|
||||
RString line;
|
||||
@@ -82,7 +82,7 @@ bool IniFile::ReadFile( RageFileBasic &f )
|
||||
// New section.
|
||||
keyname = line.substr(1, line.size()-2);
|
||||
keychild= GetChild(keyname);
|
||||
if(keychild == NULL)
|
||||
if(keychild == nullptr)
|
||||
{
|
||||
keychild= AppendChild(keyname);
|
||||
}
|
||||
@@ -90,7 +90,7 @@ bool IniFile::ReadFile( RageFileBasic &f )
|
||||
}
|
||||
default:
|
||||
keyvalue:
|
||||
if(keychild == NULL)
|
||||
if(keychild == nullptr)
|
||||
{ break; }
|
||||
// New value.
|
||||
size_t iEqualIndex = line.find("=");
|
||||
@@ -164,7 +164,7 @@ bool IniFile::WriteFile( RageFileBasic &f ) const
|
||||
bool IniFile::DeleteValue(const RString &keyname, const RString &valuename)
|
||||
{
|
||||
XNode* pNode = GetChild( keyname );
|
||||
if( pNode == NULL )
|
||||
if( pNode == nullptr )
|
||||
return false;
|
||||
return pNode->RemoveAttr( valuename );
|
||||
}
|
||||
@@ -173,7 +173,7 @@ bool IniFile::DeleteValue(const RString &keyname, const RString &valuename)
|
||||
bool IniFile::DeleteKey(const RString &keyname)
|
||||
{
|
||||
XNode* pNode = GetChild( keyname );
|
||||
if( pNode == NULL )
|
||||
if( pNode == nullptr )
|
||||
return false;
|
||||
return RemoveChild( pNode );
|
||||
}
|
||||
@@ -181,11 +181,11 @@ bool IniFile::DeleteKey(const RString &keyname)
|
||||
bool IniFile::RenameKey(const RString &from, const RString &to)
|
||||
{
|
||||
// If to already exists, do nothing.
|
||||
if( GetChild(to) != NULL )
|
||||
if( GetChild(to) != nullptr )
|
||||
return false;
|
||||
|
||||
XNode* pNode = GetChild( from );
|
||||
if( pNode == NULL )
|
||||
if( pNode == nullptr )
|
||||
return false;
|
||||
|
||||
pNode->SetName( to );
|
||||
|
||||
+2
-2
@@ -32,7 +32,7 @@ public:
|
||||
bool GetValue( const RString &sKey, const RString &sValueName, T& value ) const
|
||||
{
|
||||
const XNode* pNode = GetChild( sKey );
|
||||
if( pNode == NULL )
|
||||
if( pNode == nullptr )
|
||||
return false;
|
||||
return pNode->GetAttrValue<T>( sValueName, value );
|
||||
}
|
||||
@@ -40,7 +40,7 @@ public:
|
||||
void SetValue( const RString &sKey, const RString &sValueName, const T &value )
|
||||
{
|
||||
XNode* pNode = GetChild( sKey );
|
||||
if( pNode == NULL )
|
||||
if( pNode == nullptr )
|
||||
pNode = AppendChild( sKey );
|
||||
pNode->AppendAttr<T>( sValueName, value );
|
||||
}
|
||||
|
||||
+13
-14
@@ -6,7 +6,6 @@
|
||||
#include "RageUtil.h"
|
||||
#include "RageThreads.h"
|
||||
#include "Preference.h"
|
||||
#include "Foreach.h"
|
||||
#include "GameInput.h"
|
||||
#include "InputMapper.h"
|
||||
// for mouse stuff: -aj
|
||||
@@ -111,7 +110,7 @@ namespace
|
||||
* this won't cause timing problems, because the event timestamp is preserved. */
|
||||
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;
|
||||
|
||||
@@ -233,9 +232,9 @@ void InputFilter::ResetDevice( InputDevice device )
|
||||
RageTimer now;
|
||||
|
||||
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 )
|
||||
ButtonPressed( DeviceInput(device, db.button, 0, now) );
|
||||
}
|
||||
@@ -326,7 +325,7 @@ void InputFilter::Update( float fDeltaTime )
|
||||
|
||||
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.button = b->first.button;
|
||||
@@ -379,8 +378,8 @@ void InputFilter::Update( float fDeltaTime )
|
||||
ReportButtonChange( di, IET_REPEAT );
|
||||
}
|
||||
|
||||
FOREACH( ButtonStateMap::iterator, ButtonsToErase, it )
|
||||
g_ButtonStates.erase( *it );
|
||||
for (ButtonStateMap::iterator &it : ButtonsToErase)
|
||||
g_ButtonStates.erase( 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 );
|
||||
if( it == end || *it != i )
|
||||
return NULL;
|
||||
return nullptr;
|
||||
|
||||
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
|
||||
{
|
||||
LockMut(*queuemutex);
|
||||
if( pButtonState == NULL )
|
||||
if( pButtonState == nullptr )
|
||||
pButtonState = &g_CurrentState;
|
||||
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
|
||||
{
|
||||
LockMut(*queuemutex);
|
||||
if( pButtonState == NULL )
|
||||
if( pButtonState == nullptr )
|
||||
pButtonState = &g_CurrentState;
|
||||
const DeviceInput *pDI = FindItemBinarySearch( pButtonState->begin(), pButtonState->end(), di );
|
||||
if( pDI == NULL )
|
||||
if( pDI == nullptr )
|
||||
return 0;
|
||||
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
|
||||
{
|
||||
LockMut(*queuemutex);
|
||||
if( pButtonState == NULL )
|
||||
if( pButtonState == nullptr )
|
||||
pButtonState = &g_CurrentState;
|
||||
const DeviceInput *pDI = FindItemBinarySearch( pButtonState->begin(), pButtonState->end(), di );
|
||||
if( pDI == NULL )
|
||||
if( pDI == nullptr )
|
||||
return 0.0f;
|
||||
return pDI->level;
|
||||
}
|
||||
|
||||
+4
-4
@@ -64,10 +64,10 @@ public:
|
||||
void ResetKeyRepeat( const DeviceInput &di );
|
||||
void RepeatStopKey( const DeviceInput &di );
|
||||
|
||||
// If aButtonState is NULL, use the last reported state.
|
||||
bool IsBeingPressed( const DeviceInput &di, const DeviceInputList *pButtonState = NULL ) const;
|
||||
float GetSecsHeld( const DeviceInput &di, const DeviceInputList *pButtonState = NULL ) const;
|
||||
float GetLevel( const DeviceInput &di, const DeviceInputList *pButtonState = NULL ) const;
|
||||
// If aButtonState is nullptr, use the last reported state.
|
||||
bool IsBeingPressed( const DeviceInput &di, const DeviceInputList *pButtonState = nullptr ) const;
|
||||
float GetSecsHeld( const DeviceInput &di, const DeviceInputList *pButtonState = nullptr ) const;
|
||||
float GetLevel( const DeviceInput &di, const DeviceInputList *pButtonState = nullptr ) const;
|
||||
RString GetButtonComment( const DeviceInput &di ) const;
|
||||
|
||||
void GetInputEvents( vector<InputEvent> &aEventOut );
|
||||
|
||||
+32
-33
@@ -9,7 +9,6 @@
|
||||
#include "RageInput.h"
|
||||
#include "SpecialFiles.h"
|
||||
#include "LocalizedString.h"
|
||||
#include "Foreach.h"
|
||||
#include "arch/Dialog/Dialog.h"
|
||||
|
||||
#define AUTOMAPPINGS_DIR "/Data/AutoMappings/"
|
||||
@@ -26,12 +25,12 @@ namespace
|
||||
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()
|
||||
{
|
||||
g_JoinControllers = PLAYER_INVALID;
|
||||
m_pInputScheme = NULL;
|
||||
m_pInputScheme = nullptr;
|
||||
}
|
||||
|
||||
InputMapper::~InputMapper()
|
||||
@@ -79,20 +78,20 @@ void InputMapper::AddDefaultMappingsForCurrentGameIfUnmapped()
|
||||
vector<AutoMappingEntry> aMaps;
|
||||
aMaps.reserve( 32 );
|
||||
|
||||
FOREACH_CONST( AutoMappingEntry, g_DefaultKeyMappings.m_vMaps, iter )
|
||||
aMaps.push_back( *iter );
|
||||
FOREACH_CONST( AutoMappingEntry, m_pInputScheme->m_pAutoMappings->m_vMaps, iter )
|
||||
aMaps.push_back( *iter );
|
||||
for (AutoMappingEntry const &iter : g_DefaultKeyMappings.m_vMaps)
|
||||
aMaps.push_back( iter );
|
||||
for (AutoMappingEntry const &iter : m_pInputScheme->m_pAutoMappings->m_vMaps)
|
||||
aMaps.push_back( iter );
|
||||
|
||||
/* There may be duplicate GAME_BUTTON maps. Process the list backwards,
|
||||
* so game-specific mappings override g_DefaultKeyMappings. */
|
||||
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 );
|
||||
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( !GameI.IsValid() )
|
||||
@@ -545,10 +544,10 @@ void InputMapper::Unmap( InputDevice id )
|
||||
void InputMapper::ApplyMapping( const vector<AutoMappingEntry> &vMmaps, GameController gc, InputDevice id )
|
||||
{
|
||||
map<GameInput, int> MappedButtons;
|
||||
FOREACH_CONST( AutoMappingEntry, vMmaps, iter )
|
||||
for (AutoMappingEntry const &iter : vMmaps)
|
||||
{
|
||||
GameController map_gc = gc;
|
||||
if( iter->m_bSecondController )
|
||||
if( iter.m_bSecondController )
|
||||
{
|
||||
map_gc = (GameController)(map_gc+1);
|
||||
|
||||
@@ -559,8 +558,8 @@ void InputMapper::ApplyMapping( const vector<AutoMappingEntry> &vMmaps, GameCont
|
||||
continue;
|
||||
}
|
||||
|
||||
DeviceInput di( id, iter->m_deviceButton );
|
||||
GameInput gi( map_gc, iter->m_gb );
|
||||
DeviceInput di( id, iter.m_deviceButton );
|
||||
GameInput gi( map_gc, iter.m_gb );
|
||||
int iSlot = MappedButtons[gi];
|
||||
++MappedButtons[gi];
|
||||
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
|
||||
vector<RString> vs;
|
||||
GetDirListing( AUTOMAPPINGS_DIR "*.ini", vs, false, true );
|
||||
FOREACH_CONST( RString, vs, sFilePath )
|
||||
for (RString const &sFilePath : vs)
|
||||
{
|
||||
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 );
|
||||
|
||||
@@ -616,13 +615,13 @@ void InputMapper::AutoMapJoysticksForCurrentGame()
|
||||
|
||||
// apply auto mappings
|
||||
int iNumJoysticksMapped = 0;
|
||||
FOREACH_CONST( InputDeviceInfo, vDevices, device )
|
||||
for (InputDeviceInfo const &device : vDevices)
|
||||
{
|
||||
InputDevice id = device->id;
|
||||
const RString &sDescription = device->sDesc;
|
||||
FOREACH_CONST( AutoMappings, vAutoMappings, mapping )
|
||||
InputDevice id = device.id;
|
||||
const RString &sDescription = device.sDesc;
|
||||
for (AutoMappings const &mapping : vAutoMappings)
|
||||
{
|
||||
Regex regex( mapping->m_sDriverRegex );
|
||||
Regex regex( mapping.m_sDriverRegex );
|
||||
if( !regex.Compare(sDescription) )
|
||||
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.
|
||||
|
||||
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 );
|
||||
ApplyMapping( mapping->m_vMaps, gc, id );
|
||||
ApplyMapping( mapping.m_vMaps, gc, id );
|
||||
|
||||
iNumJoysticksMapped++;
|
||||
}
|
||||
@@ -686,16 +685,16 @@ void InputMapper::CheckButtonAndAddToReason(GameButton menu, vector<RString>& fu
|
||||
if(!inputs.empty())
|
||||
{
|
||||
vector<DeviceInput> device_inputs;
|
||||
FOREACH(GameInput, inputs, inp)
|
||||
for(GameInput &inp : inputs)
|
||||
{
|
||||
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;
|
||||
}
|
||||
@@ -706,7 +705,7 @@ void InputMapper::CheckButtonAndAddToReason(GameButton menu, vector<RString>& fu
|
||||
{
|
||||
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;
|
||||
MenuButtonToGameButtons( MenuI, aGameButtons );
|
||||
FOREACH( GameButton, aGameButtons, gb )
|
||||
for (GameButton const &gb : aGameButtons)
|
||||
{
|
||||
if( pn == PLAYER_INVALID )
|
||||
{
|
||||
GameIout.push_back( GameInput(GameController_1, *gb) );
|
||||
GameIout.push_back( GameInput(GameController_2, *gb) );
|
||||
GameIout.push_back( GameInput(GameController_1, gb) );
|
||||
GameIout.push_back( GameInput(GameController_2, gb) );
|
||||
}
|
||||
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 );
|
||||
|
||||
XNode *pKey = ini.GetChild( pInputScheme->m_szName );
|
||||
if( pKey != NULL )
|
||||
if( pKey != nullptr )
|
||||
ini.RemoveChild( pKey );
|
||||
pKey = ini.AppendChild( pInputScheme->m_szName );
|
||||
|
||||
|
||||
+2
-2
@@ -177,9 +177,9 @@ public:
|
||||
float GetSecsHeld( const GameInput &GameI, MultiPlayer mp = MultiPlayer_Invalid ) 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(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( GameButton MenuI, PlayerNumber pn );
|
||||
|
||||
+7
-10
@@ -3,10 +3,9 @@
|
||||
#include "RageTimer.h"
|
||||
#include "RageLog.h"
|
||||
#include "InputEventPlus.h"
|
||||
#include "Foreach.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;
|
||||
|
||||
@@ -38,7 +37,7 @@ bool InputQueue::WasPressedRecently( GameController c, const GameButton button,
|
||||
if( iep.GameI.button != button )
|
||||
continue;
|
||||
|
||||
if( pIEP != NULL )
|
||||
if( pIEP != nullptr )
|
||||
*pIEP = iep;
|
||||
|
||||
return true;
|
||||
@@ -95,7 +94,7 @@ bool InputQueueCode::EnteredCode( GameController controller ) const
|
||||
int iMinSearchIndexUsed = iQueueIndex;
|
||||
for( int b=0; b<(int) Press.m_aButtonsToPress.size(); ++b )
|
||||
{
|
||||
const InputEventPlus *pIEP = NULL;
|
||||
const InputEventPlus *pIEP = nullptr;
|
||||
int iQueueSearchIndex = iQueueIndex;
|
||||
for( ; iQueueSearchIndex>=0; --iQueueSearchIndex ) // iterate newest to oldest
|
||||
{
|
||||
@@ -112,7 +111,7 @@ bool InputQueueCode::EnteredCode( GameController controller ) const
|
||||
break;
|
||||
}
|
||||
}
|
||||
if( pIEP == NULL )
|
||||
if( pIEP == nullptr )
|
||||
break; // didn't find the button
|
||||
|
||||
// Check that m_aButtonsToHold were being held when the buttons were pressed.
|
||||
@@ -167,11 +166,11 @@ bool InputQueueCode::Load( RString sButtonsNames )
|
||||
|
||||
vector<RString> asPresses;
|
||||
split( sButtonsNames, ",", asPresses, false );
|
||||
FOREACH( RString, asPresses, sPress )
|
||||
for (RString &sPress : asPresses)
|
||||
{
|
||||
vector<RString> asButtonNames;
|
||||
|
||||
split( *sPress, "-", asButtonNames, false );
|
||||
split( sPress, "-", asButtonNames, false );
|
||||
|
||||
if( asButtonNames.size() < 1 )
|
||||
{
|
||||
@@ -181,10 +180,8 @@ bool InputQueueCode::Load( RString sButtonsNames )
|
||||
}
|
||||
|
||||
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 bNotHold = false;
|
||||
for(;;)
|
||||
|
||||
+1
-1
@@ -14,7 +14,7 @@ public:
|
||||
InputQueue();
|
||||
|
||||
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]; }
|
||||
void ClearQueue( GameController c );
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ LifeMeterBar::LifeMeterBar()
|
||||
EXTRA_STAGE_LIFE_DIFFICULTY.Load ("LifeMeterBar","ExtraStageLifeDifficulty");
|
||||
m_fLifePercentChange.Load( "LifeMeterBar", LIFE_PERCENT_CHANGE_NAME, NUM_ScoreEvent );
|
||||
|
||||
m_pPlayerState = NULL;
|
||||
m_pPlayerState = nullptr;
|
||||
|
||||
const RString sType = "LifeMeterBar";
|
||||
|
||||
|
||||
@@ -50,7 +50,7 @@ LifeMeterTime::LifeMeterTime()
|
||||
{
|
||||
m_fLifeTotalGainedSeconds = 0;
|
||||
m_fLifeTotalLostSeconds = 0;
|
||||
m_pStream = NULL;
|
||||
m_pStream = nullptr;
|
||||
}
|
||||
|
||||
LifeMeterTime::~LifeMeterTime()
|
||||
@@ -100,7 +100,7 @@ void LifeMeterTime::OnLoadSong()
|
||||
if(GAMESTATE->IsCourseMode())
|
||||
{
|
||||
Course* pCourse = GAMESTATE->m_pCurCourse;
|
||||
ASSERT( pCourse != NULL );
|
||||
ASSERT( pCourse != nullptr );
|
||||
fGainSeconds= pCourse->m_vEntries[GAMESTATE->GetCourseSongIndex()].fGainSeconds;
|
||||
}
|
||||
else
|
||||
@@ -108,10 +108,10 @@ void LifeMeterTime::OnLoadSong()
|
||||
// Placeholderish, at least this way it won't crash when someone tries it
|
||||
// out in non-course mode. -Kyz
|
||||
Song* song= GAMESTATE->m_pCurSong;
|
||||
ASSERT(song != NULL);
|
||||
ASSERT(song != nullptr);
|
||||
float song_len= song->m_fMusicLengthSeconds;
|
||||
Steps* steps= GAMESTATE->m_pCurSteps[m_pPlayerState->m_PlayerNumber];
|
||||
ASSERT(steps != NULL);
|
||||
ASSERT(steps != nullptr);
|
||||
RadarValues radars= steps->GetRadarValues(m_pPlayerState->m_PlayerNumber);
|
||||
float scorable_things= radars[RadarCategory_TapsAndHolds] +
|
||||
radars[RadarCategory_Lifts];
|
||||
|
||||
+18
-16
@@ -10,7 +10,6 @@
|
||||
#include "PrefsManager.h"
|
||||
#include "Actor.h"
|
||||
#include "Preference.h"
|
||||
#include "Foreach.h"
|
||||
#include "GameManager.h"
|
||||
#include "CommonMetrics.h"
|
||||
#include "Style.h"
|
||||
@@ -57,9 +56,9 @@ static void GetUsedGameInputs( vector<GameInput> &vGameInputsOut )
|
||||
split( GAME_BUTTONS_TO_SHOW.GetValue(), ",", asGameButtons );
|
||||
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 )
|
||||
{
|
||||
GameInput gi = GameInput( gc, gb );
|
||||
@@ -71,17 +70,18 @@ static void GetUsedGameInputs( vector<GameInput> &vGameInputsOut )
|
||||
set<GameInput> vGIs;
|
||||
vector<const Style*> 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 )
|
||||
continue;
|
||||
FOREACH_PlayerNumber( pn )
|
||||
{
|
||||
for( int iCol=0; iCol<(*style)->m_iColsPerPlayer; ++iCol )
|
||||
for( int iCol=0; iCol < style->m_iColsPerPlayer; ++iCol )
|
||||
{
|
||||
vector<GameInput> gi;
|
||||
(*style)->StyleInputToGameInput( iCol, pn, gi );
|
||||
style->StyleInputToGameInput( iCol, pn, gi );
|
||||
for(size_t i= 0; i < gi.size(); ++i)
|
||||
{
|
||||
if(gi[i].IsValid())
|
||||
@@ -93,11 +93,11 @@ static void GetUsedGameInputs( vector<GameInput> &vGameInputsOut )
|
||||
}
|
||||
}
|
||||
|
||||
FOREACHS_CONST( GameInput, vGIs, gi )
|
||||
vGameInputsOut.push_back( *gi );
|
||||
for (GameInput const &input : vGIs)
|
||||
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()
|
||||
{
|
||||
@@ -119,8 +119,10 @@ LightsManager::LightsManager()
|
||||
|
||||
LightsManager::~LightsManager()
|
||||
{
|
||||
FOREACH( LightsDriver*, m_vpDrivers, iter )
|
||||
SAFE_DELETE( *iter );
|
||||
for (LightsDriver *iter : m_vpDrivers)
|
||||
{
|
||||
SAFE_DELETE( iter );
|
||||
}
|
||||
m_vpDrivers.clear();
|
||||
}
|
||||
|
||||
@@ -438,8 +440,8 @@ void LightsManager::Update( float fDeltaTime )
|
||||
}
|
||||
|
||||
// apply new light values we set above
|
||||
FOREACH( LightsDriver*, m_vpDrivers, iter )
|
||||
(*iter)->Set( &m_LightsState );
|
||||
for (LightsDriver *iter : m_vpDrivers)
|
||||
iter->Set( &m_LightsState );
|
||||
}
|
||||
|
||||
void LightsManager::BlinkCabinetLight( CabinetLight cl )
|
||||
@@ -514,8 +516,8 @@ bool LightsManager::IsEnabled() const
|
||||
|
||||
void LightsManager::TurnOffAllLights()
|
||||
{
|
||||
FOREACH( LightsDriver*, m_vpDrivers, iter )
|
||||
(*iter)->Reset();
|
||||
for(LightsDriver *iter : m_vpDrivers)
|
||||
iter->Reset();
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include "global.h"
|
||||
#include "LocalizedString.h"
|
||||
#include "Foreach.h"
|
||||
|
||||
#include "RageUtil.h"
|
||||
#include "SubscriptionManager.h"
|
||||
|
||||
@@ -27,9 +27,8 @@ static LocalizedString::MakeLocalizer g_pMakeLocalizedStringImpl = LocalizedStri
|
||||
void LocalizedString::RegisterLocalizer( MakeLocalizer pFunc )
|
||||
{
|
||||
g_pMakeLocalizedStringImpl = pFunc;
|
||||
FOREACHS( LocalizedString*, *m_Subscribers.m_pSubscribers, l )
|
||||
for (LocalizedString *pLoc : *m_Subscribers.m_pSubscribers)
|
||||
{
|
||||
LocalizedString *pLoc = *l;
|
||||
pLoc->CreateImpl();
|
||||
}
|
||||
}
|
||||
@@ -40,7 +39,7 @@ LocalizedString::LocalizedString( const RString& sGroup, const RString& sName )
|
||||
|
||||
m_sGroup = sGroup;
|
||||
m_sName = sName;
|
||||
m_pImpl = NULL;
|
||||
m_pImpl = nullptr;
|
||||
|
||||
CreateImpl();
|
||||
}
|
||||
@@ -51,7 +50,7 @@ LocalizedString::LocalizedString(LocalizedString const& other)
|
||||
|
||||
m_sGroup = other.m_sGroup;
|
||||
m_sName = other.m_sName;
|
||||
m_pImpl = NULL;
|
||||
m_pImpl = nullptr;
|
||||
|
||||
CreateImpl();
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user