The big NULL replacement party part 5.

Right. ' = NULL' would get a lot of these.
This commit is contained in:
Jason Felds
2013-05-03 23:39:52 -04:00
parent 328c41eec0
commit 28e5148dec
233 changed files with 7448 additions and 7447 deletions
+2 -2
View File
@@ -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.
}
+6 -6
View File
@@ -86,7 +86,7 @@ void Actor::InitState()
{
StopTweening();
m_pTempState = NULL;
m_pTempState = nullptr;
m_baseRotation = RageVector3( 0, 0, 0 );
m_baseScale = RageVector3( 1, 1, 1 );
@@ -161,7 +161,7 @@ Actor::Actor()
m_size = RageVector2( 1, 1 );
InitState();
m_pParent = NULL;
m_pParent = nullptr;
m_bFirstUpdate = true;
}
@@ -176,7 +176,7 @@ Actor::Actor( const Actor &cpy ):
{
/* Don't copy an Actor in the middle of rendering. */
ASSERT( cpy.m_pTempState == nullptr );
m_pTempState = NULL;
m_pTempState = nullptr;
#define CPY(x) x = cpy.x
CPY( m_sName );
@@ -569,7 +569,7 @@ void Actor::SetTextureRenderStates()
void Actor::EndDraw()
{
DISPLAY->PopMatrix();
m_pTempState = NULL;
m_pTempState = nullptr;
}
void Actor::UpdateTweening( float fDeltaTime )
@@ -1298,7 +1298,7 @@ void Actor::SetParent( Actor *pParent )
Actor::TweenInfo::TweenInfo()
{
m_pTween = NULL;
m_pTween = nullptr;
}
Actor::TweenInfo::~TweenInfo()
@@ -1308,7 +1308,7 @@ Actor::TweenInfo::~TweenInfo()
Actor::TweenInfo::TweenInfo( const TweenInfo &cpy )
{
m_pTween = NULL;
m_pTween = nullptr;
*this = cpy;
}
+755 -755
View File
File diff suppressed because it is too large Load Diff
+164 -164
View File
@@ -1,164 +1,164 @@
#ifndef ACTORFRAME_H
#define ACTORFRAME_H
#include "Actor.h"
/** @brief A container for other Actors. */
class ActorFrame : public Actor
{
public:
ActorFrame();
ActorFrame( const ActorFrame &cpy );
virtual ~ActorFrame();
/** @brief Set up the initial state. */
virtual void InitState();
void LoadFromNode( const XNode* pNode );
virtual ActorFrame *Copy() const;
/**
* @brief Add a new child to the ActorFrame.
* @param pActor the new Actor to add. */
virtual void AddChild( Actor *pActor );
/**
* @brief Remove the specified child from the ActorFrame.
* @param pActor the Actor to remove. */
virtual void RemoveChild( Actor *pActor );
void TransferChildren( ActorFrame *pTo );
Actor* GetChild( const RString &sName );
vector<Actor*> GetChildren() { return m_SubActors; }
int GetNumChildren() const { return m_SubActors.size(); }
/** @brief Remove all of the children from the frame. */
void RemoveAllChildren();
/**
* @brief Move a particular actor to the tail.
* @param pActor the actor to go to the tail.
*/
void MoveToTail( Actor* pActor );
/**
* @brief Move a particular actor to the head.
* @param pActor the actor to go to the head.
*/
void MoveToHead( Actor* pActor );
void SortByDrawOrder();
void SetDrawByZPosition( bool b );
void SetDrawFunction( const LuaReference &DrawFunction ) { m_DrawFunction = DrawFunction; }
void SetUpdateFunction( const LuaReference &UpdateFunction ) { m_UpdateFunction = UpdateFunction; }
LuaReference GetDrawFunction() const { return m_DrawFunction; }
virtual bool AutoLoadChildren() const { return false; } // derived classes override to automatically LoadChildrenFromNode
void DeleteChildrenWhenDone( bool bDelete=true ) { m_bDeleteChildren = bDelete; }
void DeleteAllChildren();
// Commands
virtual void PushSelf( lua_State *L );
void PushChildrenTable( lua_State *L );
void PlayCommandOnChildren( const RString &sCommandName, const LuaReference *pParamTable = NULL );
void PlayCommandOnLeaves( const RString &sCommandName, const LuaReference *pParamTable = NULL );
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 UpdateInternal( float fDeltaTime );
virtual void BeginDraw();
virtual void DrawPrimitives();
virtual void EndDraw();
// propagated commands
virtual void SetDiffuse( RageColor c );
virtual void SetDiffuseAlpha( float f );
virtual void SetBaseAlpha( float f );
virtual void SetZTestMode( ZTestMode mode );
virtual void SetZWrite( bool b );
virtual void FinishTweening();
virtual void HurryTweening( float factor );
void SetUpdateRate( float fUpdateRate ) { m_fUpdateRate = fUpdateRate; }
void SetFOV( float fFOV ) { m_fFOV = fFOV; }
void SetVanishPoint( float fX, float fY) { m_fVanishX = fX; m_fVanishY = fY; }
void SetCustomLighting( bool bCustomLighting ) { m_bOverrideLighting = bCustomLighting; }
void SetAmbientLightColor( RageColor c ) { m_ambientColor = c; }
void SetDiffuseLightColor( RageColor c ) { m_diffuseColor = c; }
void SetSpecularLightColor( RageColor c ) { m_specularColor = c; }
void SetLightDirection( RageVector3 vec ) { m_lightDirection = vec; }
virtual void SetPropagateCommands( bool b );
/** @brief Amount of time until all tweens (and all children's tweens) have stopped: */
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
protected:
void LoadChildrenFromNode( const XNode* pNode );
/** @brief The children Actors used by the ActorFrame. */
vector<Actor*> m_SubActors;
bool m_bPropagateCommands;
bool m_bDeleteChildren;
bool m_bDrawByZPosition;
LuaReference m_UpdateFunction;
LuaReference m_DrawFunction;
// state effects
float m_fUpdateRate;
float m_fFOV; // -1 = no change
float m_fVanishX;
float m_fVanishY;
/**
* @brief A flad to see if an override for the lighting is needed.
*
* If true, set lightning to m_bLightning. */
bool m_bOverrideLighting;
bool m_bLighting;
// lighting variables
RageColor m_ambientColor;
RageColor m_diffuseColor;
RageColor m_specularColor;
RageVector3 m_lightDirection;
};
/** @brief an ActorFrame that handles deleting children Actors automatically. */
class ActorFrameAutoDeleteChildren : public ActorFrame
{
public:
ActorFrameAutoDeleteChildren() { DeleteChildrenWhenDone(true); }
virtual bool AutoLoadChildren() const { return true; }
virtual ActorFrameAutoDeleteChildren *Copy() const;
};
#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.
*/
#ifndef ACTORFRAME_H
#define ACTORFRAME_H
#include "Actor.h"
/** @brief A container for other Actors. */
class ActorFrame : public Actor
{
public:
ActorFrame();
ActorFrame( const ActorFrame &cpy );
virtual ~ActorFrame();
/** @brief Set up the initial state. */
virtual void InitState();
void LoadFromNode( const XNode* pNode );
virtual ActorFrame *Copy() const;
/**
* @brief Add a new child to the ActorFrame.
* @param pActor the new Actor to add. */
virtual void AddChild( Actor *pActor );
/**
* @brief Remove the specified child from the ActorFrame.
* @param pActor the Actor to remove. */
virtual void RemoveChild( Actor *pActor );
void TransferChildren( ActorFrame *pTo );
Actor* GetChild( const RString &sName );
vector<Actor*> GetChildren() { return m_SubActors; }
int GetNumChildren() const { return m_SubActors.size(); }
/** @brief Remove all of the children from the frame. */
void RemoveAllChildren();
/**
* @brief Move a particular actor to the tail.
* @param pActor the actor to go to the tail.
*/
void MoveToTail( Actor* pActor );
/**
* @brief Move a particular actor to the head.
* @param pActor the actor to go to the head.
*/
void MoveToHead( Actor* pActor );
void SortByDrawOrder();
void SetDrawByZPosition( bool b );
void SetDrawFunction( const LuaReference &DrawFunction ) { m_DrawFunction = DrawFunction; }
void SetUpdateFunction( const LuaReference &UpdateFunction ) { m_UpdateFunction = UpdateFunction; }
LuaReference GetDrawFunction() const { return m_DrawFunction; }
virtual bool AutoLoadChildren() const { return false; } // derived classes override to automatically LoadChildrenFromNode
void DeleteChildrenWhenDone( bool bDelete=true ) { m_bDeleteChildren = bDelete; }
void DeleteAllChildren();
// Commands
virtual void PushSelf( lua_State *L );
void PushChildrenTable( lua_State *L );
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 = 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();
virtual void DrawPrimitives();
virtual void EndDraw();
// propagated commands
virtual void SetDiffuse( RageColor c );
virtual void SetDiffuseAlpha( float f );
virtual void SetBaseAlpha( float f );
virtual void SetZTestMode( ZTestMode mode );
virtual void SetZWrite( bool b );
virtual void FinishTweening();
virtual void HurryTweening( float factor );
void SetUpdateRate( float fUpdateRate ) { m_fUpdateRate = fUpdateRate; }
void SetFOV( float fFOV ) { m_fFOV = fFOV; }
void SetVanishPoint( float fX, float fY) { m_fVanishX = fX; m_fVanishY = fY; }
void SetCustomLighting( bool bCustomLighting ) { m_bOverrideLighting = bCustomLighting; }
void SetAmbientLightColor( RageColor c ) { m_ambientColor = c; }
void SetDiffuseLightColor( RageColor c ) { m_diffuseColor = c; }
void SetSpecularLightColor( RageColor c ) { m_specularColor = c; }
void SetLightDirection( RageVector3 vec ) { m_lightDirection = vec; }
virtual void SetPropagateCommands( bool b );
/** @brief Amount of time until all tweens (and all children's tweens) have stopped: */
virtual float GetTweenTimeLeft() const;
virtual void HandleMessage( const Message &msg );
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 );
/** @brief The children Actors used by the ActorFrame. */
vector<Actor*> m_SubActors;
bool m_bPropagateCommands;
bool m_bDeleteChildren;
bool m_bDrawByZPosition;
LuaReference m_UpdateFunction;
LuaReference m_DrawFunction;
// state effects
float m_fUpdateRate;
float m_fFOV; // -1 = no change
float m_fVanishX;
float m_fVanishY;
/**
* @brief A flad to see if an override for the lighting is needed.
*
* If true, set lightning to m_bLightning. */
bool m_bOverrideLighting;
bool m_bLighting;
// lighting variables
RageColor m_ambientColor;
RageColor m_diffuseColor;
RageColor m_specularColor;
RageVector3 m_lightDirection;
};
/** @brief an ActorFrame that handles deleting children Actors automatically. */
class ActorFrameAutoDeleteChildren : public ActorFrame
{
public:
ActorFrameAutoDeleteChildren() { DeleteChildrenWhenDone(true); }
virtual bool AutoLoadChildren() const { return true; }
virtual ActorFrameAutoDeleteChildren *Copy() const;
};
#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.
*/
+1 -1
View File
@@ -17,7 +17,7 @@ ActorFrameTexture::ActorFrameTexture()
++i;
m_sTextureName = ssprintf( ConvertI64FormatString("ActorFrameTexture %lli"), i );
m_pRenderTarget = NULL;
m_pRenderTarget = nullptr;
}
ActorFrameTexture::ActorFrameTexture( const ActorFrameTexture &cpy ):
+73 -73
View File
@@ -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.
*/
+1 -1
View File
@@ -6,7 +6,7 @@ REGISTER_ACTOR_CLASS( ActorProxy );
ActorProxy::ActorProxy()
{
m_pActorTarget = NULL;
m_pActorTarget = nullptr;
}
bool ActorProxy::EarlyAbortDraw() const
+2 -2
View File
@@ -14,7 +14,7 @@
// Actor registration
static map<RString,CreateActorFn> *g_pmapRegistrees = NULL;
static map<RString,CreateActorFn> *g_pmapRegistrees = nullptr;
static bool IsRegistered( const RString& sClassName )
{
@@ -158,7 +158,7 @@ namespace
return nullptr;
}
XNode *pRet = NULL;
XNode *pRet = nullptr;
if( ActorUtil::LoadTableFromStackShowErrors(L) )
pRet = XmlFileUtil::XNodeFromTable( L );
+161 -161
View File
@@ -1,161 +1,161 @@
#ifndef ActorUtil_H
#define ActorUtil_H
#include "Actor.h"
#include "RageTexture.h"
class XNode;
typedef Actor* (*CreateActorFn)();
template<typename T>
Actor *CreateActor() { return new T; }
/**
* @brief Register the requested Actor with the specified external name.
*
* This should be called manually only if needed. */
#define REGISTER_ACTOR_CLASS_WITH_NAME( className, externalClassName ) \
struct Register##className { \
Register##className() { ActorUtil::Register(#externalClassName, CreateActor<className>); } \
}; \
className *className::Copy() const { return new className(*this); } \
static Register##className register##className
/**
* @brief Register the requested Actor so that it's more accessible.
*
* Each Actor class should have a REGISTER_ACTOR_CLASS in its CPP file. */
#define REGISTER_ACTOR_CLASS( className ) REGISTER_ACTOR_CLASS_WITH_NAME( className, className )
enum FileType
{
FT_Bitmap,
FT_Sound,
FT_Movie,
FT_Directory,
FT_Lua,
FT_Model,
NUM_FileType,
FileType_Invalid
};
const RString& FileTypeToString( FileType ft );
/** @brief Utility functions for creating and manipulating Actors. */
namespace ActorUtil
{
// Every screen should register its class at program initialization.
void Register( const RString& sClassName, CreateActorFn pfn );
apActorCommands ParseActorCommands( const RString &sCommands, const RString &sName = "" );
void SetXY( Actor& actor, const RString &sMetricsGroup );
inline void PlayCommand( Actor& actor, const RString &sCommandName ) { actor.PlayCommand( sCommandName ); }
inline void OnCommand( Actor& actor )
{
ASSERT_M( actor.HasCommand("On"), ssprintf("%s is missing an OnCommand.", actor.GetLineage().c_str()) );
actor.PlayCommand("On");
}
inline void OffCommand( Actor& actor )
{
// HACK: It's very often that we command things to TweenOffScreen
// that we aren't drawing. We know that an Actor is not being
// used if its name is blank. So, do nothing on Actors with a blank name.
// (Do "playcommand" anyway; BGAs often have no name.)
if( actor.GetName().empty() )
return;
ASSERT_M( actor.HasCommand("Off"), ssprintf("Actor %s is missing an OffCommand.", actor.GetLineage().c_str()) );
actor.PlayCommand("Off");
}
void LoadCommand( Actor& actor, const RString &sMetricsGroup, const RString &sCommandName );
void LoadCommandFromName( Actor& actor, const RString &sMetricsGroup, const RString &sCommandName, const RString &sName );
void LoadAllCommands( Actor& actor, const RString &sMetricsGroup );
void LoadAllCommandsFromName( Actor& actor, const RString &sMetricsGroup, const RString &sName );
inline void LoadAllCommandsAndSetXY( Actor& actor, const RString &sMetricsGroup )
{
LoadAllCommands( actor, sMetricsGroup );
SetXY( actor, sMetricsGroup );
}
inline void LoadAllCommandsAndOnCommand( Actor& actor, const RString &sMetricsGroup )
{
LoadAllCommands( actor, sMetricsGroup );
OnCommand( actor );
}
inline void SetXYAndOnCommand( Actor& actor, const RString &sMetricsGroup )
{
SetXY( actor, sMetricsGroup );
OnCommand( actor );
}
inline void LoadAllCommandsAndSetXYAndOnCommand( Actor& actor, const RString &sMetricsGroup )
{
LoadAllCommands( actor, sMetricsGroup );
SetXY( actor, sMetricsGroup );
OnCommand( actor );
}
/* convenience */
inline void SetXY( Actor* pActor, const RString &sMetricsGroup ) { SetXY( *pActor, sMetricsGroup ); }
inline void PlayCommand( Actor* pActor, const RString &sCommandName ) { if(pActor) pActor->PlayCommand( sCommandName ); }
inline void OnCommand( Actor* pActor ) { if(pActor) ActorUtil::OnCommand( *pActor ); }
inline void OffCommand( Actor* pActor ) { if(pActor) ActorUtil::OffCommand( *pActor ); }
inline void LoadAllCommands( Actor* pActor, const RString &sMetricsGroup ) { if(pActor) LoadAllCommands( *pActor, sMetricsGroup ); }
inline void LoadAllCommandsAndSetXY( Actor* pActor, const RString &sMetricsGroup ) { if(pActor) LoadAllCommandsAndSetXY( *pActor, sMetricsGroup ); }
inline void LoadAllCommandsAndOnCommand( Actor* pActor, const RString &sMetricsGroup ) { if(pActor) LoadAllCommandsAndOnCommand( *pActor, sMetricsGroup ); }
inline void SetXYAndOnCommand( Actor* pActor, const RString &sMetricsGroup ) { if(pActor) SetXYAndOnCommand( *pActor, sMetricsGroup ); }
inline void LoadAllCommandsAndSetXYAndOnCommand( Actor* pActor, const RString &sMetricsGroup ) { if(pActor) LoadAllCommandsAndSetXYAndOnCommand( *pActor, sMetricsGroup ); }
// Return a Sprite, BitmapText, or Model depending on the file type
Actor* LoadFromNode( const XNode* pNode, Actor *pParentActor = NULL );
Actor* MakeActor( const RString &sPath, Actor *pParentActor = NULL );
RString GetSourcePath( const XNode *pNode );
RString GetWhere( const XNode *pNode );
bool GetAttrPath( const XNode *pNode, const RString &sName, RString &sOut );
bool LoadTableFromStackShowErrors( Lua *L );
bool ResolvePath( RString &sPath, const RString &sName );
void SortByZPosition( vector<Actor*> &vActors );
FileType GetFileType( const RString &sPath );
};
#define SET_XY( actor ) ActorUtil::SetXY( actor, m_sName )
#define ON_COMMAND( actor ) ActorUtil::OnCommand( actor )
#define OFF_COMMAND( actor ) ActorUtil::OffCommand( actor )
#define SET_XY_AND_ON_COMMAND( actor ) ActorUtil::SetXYAndOnCommand( actor, m_sName )
#define COMMAND( actor, command_name ) ActorUtil::PlayCommand( actor, command_name )
#define LOAD_ALL_COMMANDS( actor ) ActorUtil::LoadAllCommands( actor, m_sName )
#define LOAD_ALL_COMMANDS_AND_SET_XY( actor ) ActorUtil::LoadAllCommandsAndSetXY( actor, m_sName )
#define LOAD_ALL_COMMANDS_AND_ON_COMMAND( actor ) ActorUtil::LoadAllCommandsAndOnCommand( actor, m_sName )
#define LOAD_ALL_COMMANDS_AND_SET_XY_AND_ON_COMMAND( actor ) ActorUtil::LoadAllCommandsAndSetXYAndOnCommand( actor, m_sName )
#endif
/*
* (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.
*/
#ifndef ActorUtil_H
#define ActorUtil_H
#include "Actor.h"
#include "RageTexture.h"
class XNode;
typedef Actor* (*CreateActorFn)();
template<typename T>
Actor *CreateActor() { return new T; }
/**
* @brief Register the requested Actor with the specified external name.
*
* This should be called manually only if needed. */
#define REGISTER_ACTOR_CLASS_WITH_NAME( className, externalClassName ) \
struct Register##className { \
Register##className() { ActorUtil::Register(#externalClassName, CreateActor<className>); } \
}; \
className *className::Copy() const { return new className(*this); } \
static Register##className register##className
/**
* @brief Register the requested Actor so that it's more accessible.
*
* Each Actor class should have a REGISTER_ACTOR_CLASS in its CPP file. */
#define REGISTER_ACTOR_CLASS( className ) REGISTER_ACTOR_CLASS_WITH_NAME( className, className )
enum FileType
{
FT_Bitmap,
FT_Sound,
FT_Movie,
FT_Directory,
FT_Lua,
FT_Model,
NUM_FileType,
FileType_Invalid
};
const RString& FileTypeToString( FileType ft );
/** @brief Utility functions for creating and manipulating Actors. */
namespace ActorUtil
{
// Every screen should register its class at program initialization.
void Register( const RString& sClassName, CreateActorFn pfn );
apActorCommands ParseActorCommands( const RString &sCommands, const RString &sName = "" );
void SetXY( Actor& actor, const RString &sMetricsGroup );
inline void PlayCommand( Actor& actor, const RString &sCommandName ) { actor.PlayCommand( sCommandName ); }
inline void OnCommand( Actor& actor )
{
ASSERT_M( actor.HasCommand("On"), ssprintf("%s is missing an OnCommand.", actor.GetLineage().c_str()) );
actor.PlayCommand("On");
}
inline void OffCommand( Actor& actor )
{
// HACK: It's very often that we command things to TweenOffScreen
// that we aren't drawing. We know that an Actor is not being
// used if its name is blank. So, do nothing on Actors with a blank name.
// (Do "playcommand" anyway; BGAs often have no name.)
if( actor.GetName().empty() )
return;
ASSERT_M( actor.HasCommand("Off"), ssprintf("Actor %s is missing an OffCommand.", actor.GetLineage().c_str()) );
actor.PlayCommand("Off");
}
void LoadCommand( Actor& actor, const RString &sMetricsGroup, const RString &sCommandName );
void LoadCommandFromName( Actor& actor, const RString &sMetricsGroup, const RString &sCommandName, const RString &sName );
void LoadAllCommands( Actor& actor, const RString &sMetricsGroup );
void LoadAllCommandsFromName( Actor& actor, const RString &sMetricsGroup, const RString &sName );
inline void LoadAllCommandsAndSetXY( Actor& actor, const RString &sMetricsGroup )
{
LoadAllCommands( actor, sMetricsGroup );
SetXY( actor, sMetricsGroup );
}
inline void LoadAllCommandsAndOnCommand( Actor& actor, const RString &sMetricsGroup )
{
LoadAllCommands( actor, sMetricsGroup );
OnCommand( actor );
}
inline void SetXYAndOnCommand( Actor& actor, const RString &sMetricsGroup )
{
SetXY( actor, sMetricsGroup );
OnCommand( actor );
}
inline void LoadAllCommandsAndSetXYAndOnCommand( Actor& actor, const RString &sMetricsGroup )
{
LoadAllCommands( actor, sMetricsGroup );
SetXY( actor, sMetricsGroup );
OnCommand( actor );
}
/* convenience */
inline void SetXY( Actor* pActor, const RString &sMetricsGroup ) { SetXY( *pActor, sMetricsGroup ); }
inline void PlayCommand( Actor* pActor, const RString &sCommandName ) { if(pActor) pActor->PlayCommand( sCommandName ); }
inline void OnCommand( Actor* pActor ) { if(pActor) ActorUtil::OnCommand( *pActor ); }
inline void OffCommand( Actor* pActor ) { if(pActor) ActorUtil::OffCommand( *pActor ); }
inline void LoadAllCommands( Actor* pActor, const RString &sMetricsGroup ) { if(pActor) LoadAllCommands( *pActor, sMetricsGroup ); }
inline void LoadAllCommandsAndSetXY( Actor* pActor, const RString &sMetricsGroup ) { if(pActor) LoadAllCommandsAndSetXY( *pActor, sMetricsGroup ); }
inline void LoadAllCommandsAndOnCommand( Actor* pActor, const RString &sMetricsGroup ) { if(pActor) LoadAllCommandsAndOnCommand( *pActor, sMetricsGroup ); }
inline void SetXYAndOnCommand( Actor* pActor, const RString &sMetricsGroup ) { if(pActor) SetXYAndOnCommand( *pActor, sMetricsGroup ); }
inline void LoadAllCommandsAndSetXYAndOnCommand( Actor* pActor, const RString &sMetricsGroup ) { if(pActor) LoadAllCommandsAndSetXYAndOnCommand( *pActor, sMetricsGroup ); }
// Return a Sprite, BitmapText, or Model depending on the file type
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 LoadTableFromStackShowErrors( Lua *L );
bool ResolvePath( RString &sPath, const RString &sName );
void SortByZPosition( vector<Actor*> &vActors );
FileType GetFileType( const RString &sPath );
};
#define SET_XY( actor ) ActorUtil::SetXY( actor, m_sName )
#define ON_COMMAND( actor ) ActorUtil::OnCommand( actor )
#define OFF_COMMAND( actor ) ActorUtil::OffCommand( actor )
#define SET_XY_AND_ON_COMMAND( actor ) ActorUtil::SetXYAndOnCommand( actor, m_sName )
#define COMMAND( actor, command_name ) ActorUtil::PlayCommand( actor, command_name )
#define LOAD_ALL_COMMANDS( actor ) ActorUtil::LoadAllCommands( actor, m_sName )
#define LOAD_ALL_COMMANDS_AND_SET_XY( actor ) ActorUtil::LoadAllCommandsAndSetXY( actor, m_sName )
#define LOAD_ALL_COMMANDS_AND_ON_COMMAND( actor ) ActorUtil::LoadAllCommandsAndOnCommand( actor, m_sName )
#define LOAD_ALL_COMMANDS_AND_SET_XY_AND_ON_COMMAND( actor ) ActorUtil::LoadAllCommandsAndSetXYAndOnCommand( actor, m_sName )
#endif
/*
* (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.
*/
+1 -1
View File
@@ -5,7 +5,7 @@
#include "RageFile.h"
#include <cstring>
AnnouncerManager* ANNOUNCER = NULL; // global object accessable from anywhere in the program
AnnouncerManager* ANNOUNCER = nullptr; // global object accessable from anywhere in the program
const RString EMPTY_ANNOUNCER_NAME = "Empty";
+2 -2
View File
@@ -13,7 +13,7 @@ void AutoActor::Unload()
AutoActor::AutoActor( const AutoActor &cpy )
{
if( cpy.m_pActor == nullptr )
m_pActor = NULL;
m_pActor = nullptr;
else
m_pActor = cpy.m_pActor->Copy();
}
@@ -23,7 +23,7 @@ AutoActor &AutoActor::operator=( const AutoActor &cpy )
Unload();
if( cpy.m_pActor == nullptr )
m_pActor = NULL;
m_pActor = nullptr;
else
m_pActor = cpy.m_pActor->Copy();
return *this;
+1 -1
View File
@@ -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 );
+3 -3
View File
@@ -122,9 +122,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 = pSong->GetMusicPath();
+9 -9
View File
@@ -147,15 +147,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()
@@ -242,7 +242,7 @@ void BackgroundImpl::Unload()
{
FOREACH_BackgroundLayer( i )
m_Layer[i].Unload();
m_pSong = NULL;
m_pSong = nullptr;
m_fLastMusicSeconds = -9999;
m_RandomBGAnimations.clear();
}
@@ -254,8 +254,8 @@ void BackgroundImpl::Layer::Unload()
m_BGAnimations.clear();
m_aBGChanges.clear();
m_pCurrentBGA = NULL;
m_pFadingBGA = NULL;
m_pCurrentBGA = nullptr;
m_pFadingBGA = nullptr;
m_iCurBGChangeIndex = -1;
}
@@ -743,7 +743,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
@@ -779,7 +779,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. */
+6 -6
View File
@@ -248,13 +248,13 @@ public:
static int ScaleToClipped( T* p, lua_State *L ) { p->ScaleToClipped(FArg(1),FArg(2)); return 0; }
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 ); }
return 0;
}
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 ); }
return 0;
}
@@ -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 ); }
return 0;
}
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 ); }
return 0;
}
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 ); }
return 0;
}
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 ); }
return 0;
}
+5 -5
View File
@@ -42,7 +42,7 @@ BitmapText::BitmapText()
}
iReloadCounter++;
m_pFont = NULL;
m_pFont = nullptr;
m_bUppercase = false;
m_bRainbowScroll = false;
@@ -98,7 +98,7 @@ BitmapText & BitmapText::operator=(const BitmapText &cpy)
if( cpy.m_pFont != nullptr )
m_pFont = FONT->CopyFont( cpy.m_pFont );
else
m_pFont = NULL;
m_pFont = nullptr;
return *this;
}
@@ -106,7 +106,7 @@ BitmapText & BitmapText::operator=(const BitmapText &cpy)
BitmapText::BitmapText( const BitmapText &cpy ):
Actor( cpy )
{
m_pFont = NULL;
m_pFont = nullptr;
*this = cpy;
}
@@ -143,7 +143,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 );
@@ -162,7 +162,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 );
+1 -1
View File
@@ -7,7 +7,7 @@
#define CHARACTERS_DIR "/Characters/"
CharacterManager* CHARMAN = NULL; // global object accessable from anywhere in the program
CharacterManager* CHARMAN = nullptr; // global object accessable from anywhere in the program
CharacterManager::CharacterManager()
{
+4 -4
View File
@@ -14,16 +14,16 @@ 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 )
{
BODY_WIDTH.Load( sMetricsGroup, "BodyWidth" );
Actor *pActor = NULL;
Actor *pActor = nullptr;
m_pBacking = ActorUtil::MakeActor( THEME->GetPathG(sMetricsGroup,"Backing") );
m_pBacking->ZoomToWidth( BODY_WIDTH );
+1 -1
View File
@@ -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];
+3 -3
View File
@@ -450,7 +450,7 @@ void EditCourseUtil::UpdateAndSetTrail()
{
ASSERT( GAMESTATE->m_pCurStyle != nullptr );
StepsType st = GAMESTATE->m_pCurStyle->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 NULL so that ScreenStage won't show the last song.
GAMESTATE->m_PlayMode.Set( PLAY_MODE_ENDLESS );
GAMESTATE->m_bSideIsJoined[0] = true;
@@ -549,7 +549,7 @@ Course *CourseID::ToCourse() const
if( sPath2.Left(1) != "/" )
sPath2 = "/" + sPath2;
Course *pCourse = NULL;
Course *pCourse = nullptr;
if( m_Cache.Get(&pCourse) )
return pCourse;
if( pCourse == nullptr && !sPath2.empty() )
+1 -1
View File
@@ -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; }
+2 -2
View File
@@ -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()
@@ -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);
+527 -527
View File
File diff suppressed because it is too large Load Diff
+352 -352
View File
@@ -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.
*/
+1 -1
View File
@@ -45,7 +45,7 @@ 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 )
{
+100 -100
View File
@@ -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.
*/
+1 -1
View File
@@ -429,7 +429,7 @@ void EditMenu::OnRowValueChanged( EditMenuRow row )
{
Steps *pSteps = SongUtil::GetStepsByDifficulty( GetSelectedSong(), GetSelectedStepsType(), dc );
if( pSteps && UNLOCKMAN->StepsIsLocked( GetSelectedSong(), pSteps ) )
pSteps = NULL;
pSteps = nullptr;
EditMode mode = EDIT_MODE.GetValue();
switch( EDIT_MODE.GetValue() )
+4 -4
View File
@@ -272,25 +272,25 @@ public:
static int ScaleToClipped( T* p, lua_State *L ) { p->ScaleToClipped(FArg(1),FArg(2)); return 0; }
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 ); }
return 0;
}
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 ); }
return 0;
}
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 ); }
return 0;
}
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 ); }
return 0;
}
+4 -4
View File
@@ -190,12 +190,12 @@ FontPage::~FontPage()
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 != nullptr )
{
TEXTUREMAN->UnloadTexture( m_FontPageTextures.m_pTextureStroke );
m_FontPageTextures.m_pTextureStroke = NULL;
m_FontPageTextures.m_pTextureStroke = nullptr;
}
}
@@ -221,7 +221,7 @@ int Font::GetLineHeightInSourcePixels( const wstring &szLine ) const
}
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),
// strokes aren't shown by default, hence the Color.
m_DefaultStrokeColor(RageColor(0,0,0,0)), m_sChars("") {}
@@ -238,7 +238,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. */
+2 -2
View File
@@ -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) {}
};
/** @brief The components of a glyph (not technically a character). */
@@ -50,7 +50,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() {}
};
+1 -1
View File
@@ -20,7 +20,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 )
+6 -6
View File
@@ -36,7 +36,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 +45,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();
+148 -148
View File
@@ -1,148 +1,148 @@
/* GameCommand */
#ifndef GameCommand_H
#define GameCommand_H
#include "GameConstantsAndTypes.h"
#include "PlayerNumber.h"
#include "Difficulty.h"
#include "LuaReference.h"
#include "Command.h"
#include <map>
class Song;
class Steps;
class Course;
class Trail;
class Character;
class Style;
class Game;
struct lua_State;
class GameCommand
{
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_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_sSongGroup(""), m_SortOrder(SortOrder_Invalid),
m_sSoundPath(""), m_vsScreensToPrepare(), m_iWeightPounds(-1),
m_iGoalCalories(-1), m_GoalType(GoalType_Invalid),
m_sProfileID(""), m_sUrl(""), m_bUrlExits(true),
m_bStopMusic(false), m_bApplyDefaultOptions(false),
m_bFadeMusic(false), m_fMusicFadeOutVolume(-1),
m_fMusicFadeOutSeconds(-1), m_bApplyCommitsScreens(true)
{
m_LuaFunction.Unset();
}
void Init();
void Load( int iIndex, const Commands& cmds );
void LoadOne( const Command& cmd );
void ApplyToAllPlayers() const;
void Apply( PlayerNumber pn ) const;
private:
void Apply( const vector<PlayerNumber> &vpns ) const;
void ApplySelf( const vector<PlayerNumber> &vpns ) const;
public:
bool DescribesCurrentMode( PlayerNumber pn ) const;
bool DescribesCurrentModeForAllPlayers() const;
bool IsPlayable( RString *why = NULL ) const;
bool IsZero() const;
/* If true, Apply() will apply m_sScreen. If false, it won't, and you need
* to do it yourself. */
void ApplyCommitsScreens( bool bOn ) { m_bApplyCommitsScreens = bOn; }
// Same as what was passed to Load. We need to keep the original commands
// so that we know the order of commands when it comes time to Apply.
Commands m_Commands;
RString m_sName; // choice name
RString m_sText; // display text
bool m_bInvalid;
RString m_sInvalidReason;
int m_iIndex;
MultiPlayer m_MultiPlayer;
const Style* m_pStyle;
PlayMode m_pm;
Difficulty m_dc;
CourseDifficulty m_CourseDifficulty;
RString m_sAnnouncer;
RString m_sPreferredModifiers;
RString m_sStageModifiers;
RString m_sScreen;
LuaReference m_LuaFunction;
Song* m_pSong;
Steps* m_pSteps;
Course* m_pCourse;
Trail* m_pTrail;
Character* m_pCharacter;
std::map<RString,RString> m_SetEnv;
RString m_sSongGroup;
SortOrder m_SortOrder;
RString m_sSoundPath; // "" for no sound
vector<RString> m_vsScreensToPrepare;
/**
* @brief What is the player's weight in pounds?
*
* If this value is -1, then no weight was specified. */
int m_iWeightPounds;
int m_iGoalCalories; // -1 == none specified
GoalType m_GoalType;
RString m_sProfileID;
RString m_sUrl;
// sm-ssc adds:
bool m_bUrlExits; // for making stepmania not exit on url
bool m_bStopMusic;
bool m_bApplyDefaultOptions;
// sm-ssc also adds:
bool m_bFadeMusic;
float m_fMusicFadeOutVolume;
// currently, GameSoundManager uses consts for fade out/in times, so this
// is kind of pointless, but I want to have it working eventually. -aj
float m_fMusicFadeOutSeconds;
// Lua
void PushSelf( lua_State *L );
private:
bool m_bApplyCommitsScreens;
};
#endif
/*
* (c) 2001-2004 Chris Danford, Glenn Maynard
* All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* 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.
*/
/* GameCommand */
#ifndef GameCommand_H
#define GameCommand_H
#include "GameConstantsAndTypes.h"
#include "PlayerNumber.h"
#include "Difficulty.h"
#include "LuaReference.h"
#include "Command.h"
#include <map>
class Song;
class Steps;
class Course;
class Trail;
class Character;
class Style;
class Game;
struct lua_State;
class GameCommand
{
public:
GameCommand(): m_Commands(), m_sName(""), m_sText(""),
m_bInvalid(true), m_sInvalidReason(""),
m_iIndex(-1), m_MultiPlayer(MultiPlayer_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(nullptr), m_pSteps(nullptr), m_pCourse(nullptr),
m_pTrail(nullptr), m_pCharacter(nullptr), m_SetEnv(),
m_sSongGroup(""), m_SortOrder(SortOrder_Invalid),
m_sSoundPath(""), m_vsScreensToPrepare(), m_iWeightPounds(-1),
m_iGoalCalories(-1), m_GoalType(GoalType_Invalid),
m_sProfileID(""), m_sUrl(""), m_bUrlExits(true),
m_bStopMusic(false), m_bApplyDefaultOptions(false),
m_bFadeMusic(false), m_fMusicFadeOutVolume(-1),
m_fMusicFadeOutSeconds(-1), m_bApplyCommitsScreens(true)
{
m_LuaFunction.Unset();
}
void Init();
void Load( int iIndex, const Commands& cmds );
void LoadOne( const Command& cmd );
void ApplyToAllPlayers() const;
void Apply( PlayerNumber pn ) const;
private:
void Apply( const vector<PlayerNumber> &vpns ) const;
void ApplySelf( const vector<PlayerNumber> &vpns ) const;
public:
bool DescribesCurrentMode( PlayerNumber pn ) const;
bool DescribesCurrentModeForAllPlayers() 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
* to do it yourself. */
void ApplyCommitsScreens( bool bOn ) { m_bApplyCommitsScreens = bOn; }
// Same as what was passed to Load. We need to keep the original commands
// so that we know the order of commands when it comes time to Apply.
Commands m_Commands;
RString m_sName; // choice name
RString m_sText; // display text
bool m_bInvalid;
RString m_sInvalidReason;
int m_iIndex;
MultiPlayer m_MultiPlayer;
const Style* m_pStyle;
PlayMode m_pm;
Difficulty m_dc;
CourseDifficulty m_CourseDifficulty;
RString m_sAnnouncer;
RString m_sPreferredModifiers;
RString m_sStageModifiers;
RString m_sScreen;
LuaReference m_LuaFunction;
Song* m_pSong;
Steps* m_pSteps;
Course* m_pCourse;
Trail* m_pTrail;
Character* m_pCharacter;
std::map<RString,RString> m_SetEnv;
RString m_sSongGroup;
SortOrder m_SortOrder;
RString m_sSoundPath; // "" for no sound
vector<RString> m_vsScreensToPrepare;
/**
* @brief What is the player's weight in pounds?
*
* If this value is -1, then no weight was specified. */
int m_iWeightPounds;
int m_iGoalCalories; // -1 == none specified
GoalType m_GoalType;
RString m_sProfileID;
RString m_sUrl;
// sm-ssc adds:
bool m_bUrlExits; // for making stepmania not exit on url
bool m_bStopMusic;
bool m_bApplyDefaultOptions;
// sm-ssc also adds:
bool m_bFadeMusic;
float m_fMusicFadeOutVolume;
// currently, GameSoundManager uses consts for fade out/in times, so this
// is kind of pointless, but I want to have it working eventually. -aj
float m_fMusicFadeOutSeconds;
// Lua
void PushSelf( lua_State *L );
private:
bool m_bApplyCommitsScreens;
};
#endif
/*
* (c) 2001-2004 Chris Danford, Glenn Maynard
* All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* 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.
*/
+1 -1
View File
@@ -234,7 +234,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")
+2 -2
View File
@@ -12,7 +12,7 @@
#include "Style.h"
GameManager* GAMEMAN = NULL; // global and accessable from anywhere in our program
GameManager* GAMEMAN = nullptr; // global and accessable from anywhere in our program
enum
{
@@ -3028,7 +3028,7 @@ void GameManager::GetEnabledGames( vector<const Game*>& aGamesOut )
const Game* GameManager::GetDefaultGame()
{
const Game *pDefault = NULL;
const Game *pDefault = nullptr;
if( pDefault == nullptr )
{
for( size_t i=0; pDefault == nullptr && i < ARRAYLEN(g_Games); ++i )
+1 -1
View File
@@ -18,7 +18,7 @@
#include "SongUtil.h"
#include "LuaManager.h"
GameSoundManager *SOUND = NULL;
GameSoundManager *SOUND = nullptr;
/*
* When playing music, automatically search for an SM file for timing data. If one is
+2 -2
View File
@@ -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,
+18 -18
View File
@@ -41,7 +41,7 @@
#include <ctime>
#include <set>
GameState* GAMESTATE = NULL; // global and accessable from anywhere in our program
GameState* GAMESTATE = nullptr; // global and accessable from anywhere in our program
#define NAME_BLACKLIST_FILE "/Data/NamesBlacklist.txt"
@@ -75,7 +75,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");
@@ -106,7 +106,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 ),
@@ -133,9 +133,9 @@ GameState::GameState() :
{
g_pImpl = new GameStateImpl;
SetCurrentStyle( NULL );
SetCurrentStyle(nullptr);
m_pCurGame.Set( NULL );
m_pCurGame.Set(nullptr);
m_timeGameStarted.SetZero();
m_bDemonstrationOrJukebox = false;
@@ -254,8 +254,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);
@@ -278,7 +278,7 @@ void GameState::Reset()
ASSERT( THEME != nullptr );
m_timeGameStarted.SetZero();
SetCurrentStyle( NULL );
SetCurrentStyle(nullptr);
FOREACH_MultiPlayer( p )
m_MultiPlayerStatus[p] = MultiPlayerStatus_NotJoined;
FOREACH_PlayerNumber( pn )
@@ -307,9 +307,9 @@ void GameState::Reset()
m_iStageSeed = rand();
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();
@@ -343,7 +343,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( "" );
@@ -610,7 +610,7 @@ int GameState::GetNumStagesForCurrentSongAndStepsOrCourse() const
int numSidesJoined = GetNumSidesJoined();
if( pStyle == nullptr )
{
const Steps *pSteps = NULL;
const Steps *pSteps = nullptr;
if( this->GetMasterPlayerNumber() != PlayerNumber_Invalid )
pSteps = m_pCurSteps[this->GetMasterPlayerNumber()];
// Don't call GetFirstCompatibleStyle if numSidesJoined == 0.
@@ -2169,7 +2169,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 ); }
return 0;
}
@@ -2184,7 +2184,7 @@ public:
static int SetCurrentSteps( T* p, lua_State *L )
{
PlayerNumber pn = Enum::Check<PlayerNumber>(L, 1);
if( lua_isnil(L,2) ) { p->m_pCurSteps[pn].Set( NULL ); }
if( lua_isnil(L,2) ) { p->m_pCurSteps[pn].Set(nullptr); }
else { Steps *pS = Luna<Steps>::check(L,2); p->m_pCurSteps[pn].Set( pS ); }
ASSERT(p->m_pCurSteps[pn]->m_StepsType == p->m_pCurStyle->m_StepsType);
@@ -2195,7 +2195,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 ); }
return 0;
}
@@ -2210,7 +2210,7 @@ public:
static int SetCurrentTrail( T* p, lua_State *L )
{
PlayerNumber pn = Enum::Check<PlayerNumber>(L, 1);
if( lua_isnil(L,2) ) { p->m_pCurTrail[pn].Set( NULL ); }
if( lua_isnil(L,2) ) { p->m_pCurTrail[pn].Set(nullptr); }
else { Trail *pS = Luna<Trail>::check(L,2); p->m_pCurTrail[pn].Set( pS ); }
MESSAGEMAN->Broadcast( (MessageID)(Message_CurrentTrailP1Changed+pn) );
return 0;
@@ -2218,7 +2218,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; }
return 0;
}
+3 -3
View File
@@ -126,7 +126,7 @@ public:
~GraphBody()
{
TEXTUREMAN->UnloadTexture( m_pTexture );
m_pTexture = NULL;
m_pTexture = nullptr;
}
void DrawPrimitives()
@@ -150,8 +150,8 @@ public:
GraphDisplay::GraphDisplay()
{
m_pGraphLine = NULL;
m_pGraphBody = NULL;
m_pGraphLine = nullptr;
m_pGraphBody = nullptr;
}
GraphDisplay::~GraphDisplay()
+1 -1
View File
@@ -82,7 +82,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 accessable from anywhere in our program
InputFilter* INPUTFILTER = nullptr; // global and accessable from anywhere in our program
static const float TIME_BEFORE_REPEATS = 0.375f;
+3 -3
View File
@@ -61,9 +61,9 @@ public:
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;
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 );
+2 -2
View File
@@ -26,12 +26,12 @@ namespace
PlayerNumber g_JoinControllers;
};
InputMapper* INPUTMAPPER = NULL; // global and accessable from anywhere in our program
InputMapper* INPUTMAPPER = nullptr; // global and accessable from anywhere in our program
InputMapper::InputMapper()
{
g_JoinControllers = PLAYER_INVALID;
m_pInputScheme = NULL;
m_pInputScheme = nullptr;
}
InputMapper::~InputMapper()
+1 -1
View File
@@ -173,7 +173,7 @@ 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;
void ResetKeyRepeat( const GameInput &GameI );
+2 -2
View File
@@ -6,7 +6,7 @@
#include "InputMapper.h"
InputQueue* INPUTQUEUE = NULL; // global and accessable from anywhere in our program
InputQueue* INPUTQUEUE = nullptr; // global and accessable from anywhere in our program
const unsigned MAX_INPUT_QUEUE_LENGTH = 32;
@@ -95,7 +95,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
{
+1 -1
View File
@@ -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 );
+421 -421
View File
@@ -1,421 +1,421 @@
#include "global.h"
#include "LifeMeterBar.h"
#include "PrefsManager.h"
#include "RageLog.h"
#include "RageTimer.h"
#include "GameState.h"
#include "RageMath.h"
#include "ThemeManager.h"
#include "Song.h"
#include "StatsManager.h"
#include "ThemeMetric.h"
#include "PlayerState.h"
#include "Quad.h"
#include "ActorUtil.h"
#include "StreamDisplay.h"
#include "Steps.h"
#include "Course.h"
static RString LIFE_PERCENT_CHANGE_NAME( size_t i ) { return "LifePercentChange" + ScoreEventToString( (ScoreEvent)i ); }
LifeMeterBar::LifeMeterBar()
{
DANGER_THRESHOLD.Load ("LifeMeterBar","DangerThreshold");
INITIAL_VALUE.Load ("LifeMeterBar","InitialValue");
HOT_VALUE.Load ("LifeMeterBar","HotValue");
LIFE_MULTIPLIER.Load ( "LifeMeterBar","LifeMultiplier");
MIN_STAY_ALIVE.Load ("LifeMeterBar","MinStayAlive");
FORCE_LIFE_DIFFICULTY_ON_EXTRA_STAGE.Load ("LifeMeterBar","ForceLifeDifficultyOnExtraStage");
EXTRA_STAGE_LIFE_DIFFICULTY.Load ("LifeMeterBar","ExtraStageLifeDifficulty");
m_fLifePercentChange.Load( "LifeMeterBar", LIFE_PERCENT_CHANGE_NAME, NUM_ScoreEvent );
m_pPlayerState = NULL;
SongOptions::DrainType dtype = GAMESTATE->m_SongOptions.GetStage().m_DrainType;
switch( dtype )
{
case SongOptions::DRAIN_NORMAL:
m_fLifePercentage = INITIAL_VALUE;
break;
/* These types only go down, so they always start at full. */
case SongOptions::DRAIN_NO_RECOVER:
case SongOptions::DRAIN_SUDDEN_DEATH:
m_fLifePercentage = 1.0f; break;
default:
FAIL_M(ssprintf("Invalid DrainType: %i", dtype));
}
const RString sType = "LifeMeterBar";
m_fPassingAlpha = 0;
m_fHotAlpha = 0;
m_fBaseLifeDifficulty = PREFSMAN->m_fLifeDifficultyScale;
m_fLifeDifficulty = m_fBaseLifeDifficulty;
// set up progressive lifebar
m_iProgressiveLifebar = PREFSMAN->m_iProgressiveLifebar;
m_iMissCombo = 0;
// set up combotoregainlife
m_iComboToRegainLife = 0;
bool bExtra = GAMESTATE->IsAnExtraStage();
RString sExtra = bExtra ? "extra " : "";
m_sprUnder.Load( THEME->GetPathG(sType,sExtra+"Under") );
m_sprUnder->SetName( "Under" );
ActorUtil::LoadAllCommandsAndSetXY( m_sprUnder, sType );
this->AddChild( m_sprUnder );
m_sprDanger.Load( THEME->GetPathG(sType,sExtra+"Danger") );
m_sprDanger->SetName( "Danger" );
ActorUtil::LoadAllCommandsAndSetXY( m_sprDanger, sType );
this->AddChild( m_sprDanger );
m_pStream = new StreamDisplay;
m_pStream->Load( bExtra ? "StreamDisplayExtra" : "StreamDisplay" );
m_pStream->SetName( "Stream" );
ActorUtil::LoadAllCommandsAndSetXY( m_pStream, sType );
this->AddChild( m_pStream );
m_sprOver.Load( THEME->GetPathG(sType,sExtra+"Over") );
m_sprOver->SetName( "Over" );
ActorUtil::LoadAllCommandsAndSetXY( m_sprOver, sType );
this->AddChild( m_sprOver );
}
LifeMeterBar::~LifeMeterBar()
{
SAFE_DELETE( m_pStream );
}
void LifeMeterBar::Load( const PlayerState *pPlayerState, PlayerStageStats *pPlayerStageStats )
{
LifeMeter::Load( pPlayerState, pPlayerStageStats );
PlayerNumber pn = pPlayerState->m_PlayerNumber;
// Change life difficulty to really easy if merciful beginner on
m_bMercifulBeginnerInEffect =
GAMESTATE->m_PlayMode == PLAY_MODE_REGULAR &&
GAMESTATE->IsPlayerEnabled( pPlayerState ) &&
GAMESTATE->m_pCurSteps[pn]->GetDifficulty() == Difficulty_Beginner &&
PREFSMAN->m_bMercifulBeginner;
AfterLifeChanged();
}
void LifeMeterBar::ChangeLife( TapNoteScore score )
{
float fDeltaLife=0.f;
switch( score )
{
DEFAULT_FAIL( score );
case TNS_W1: fDeltaLife = m_fLifePercentChange.GetValue(SE_W1); break;
case TNS_W2: fDeltaLife = m_fLifePercentChange.GetValue(SE_W2); break;
case TNS_W3: fDeltaLife = m_fLifePercentChange.GetValue(SE_W3); break;
case TNS_W4: fDeltaLife = m_fLifePercentChange.GetValue(SE_W4); break;
case TNS_W5: fDeltaLife = m_fLifePercentChange.GetValue(SE_W5); break;
case TNS_Miss: fDeltaLife = m_fLifePercentChange.GetValue(SE_Miss); break;
case TNS_HitMine: fDeltaLife = m_fLifePercentChange.GetValue(SE_HitMine); break;
case TNS_None: fDeltaLife = m_fLifePercentChange.GetValue(SE_Miss); break;
case TNS_CheckpointHit: fDeltaLife = m_fLifePercentChange.GetValue(SE_CheckpointHit); break;
case TNS_CheckpointMiss:fDeltaLife = m_fLifePercentChange.GetValue(SE_CheckpointMiss); break;
}
// this was previously if( IsHot() && score < TNS_GOOD ) in 3.9... -freem
if( IsHot() && fDeltaLife < 0 )
fDeltaLife = min( fDeltaLife, -0.10f ); // make it take a while to get back to "hot"
switch( GAMESTATE->m_SongOptions.GetSong().m_DrainType )
{
DEFAULT_FAIL( GAMESTATE->m_SongOptions.GetSong().m_DrainType );
case SongOptions::DRAIN_NORMAL:
break;
case SongOptions::DRAIN_NO_RECOVER:
fDeltaLife = min( fDeltaLife, 0 );
break;
case SongOptions::DRAIN_SUDDEN_DEATH:
if( score < MIN_STAY_ALIVE )
fDeltaLife = -1.0f;
else
fDeltaLife = 0;
break;
}
ChangeLife( fDeltaLife );
}
void LifeMeterBar::ChangeLife( HoldNoteScore score, TapNoteScore tscore )
{
float fDeltaLife=0.f;
SongOptions::DrainType dtype = GAMESTATE->m_SongOptions.GetSong().m_DrainType;
switch( dtype )
{
case SongOptions::DRAIN_NORMAL:
switch( score )
{
case HNS_Held: fDeltaLife = m_fLifePercentChange.GetValue(SE_Held); break;
case HNS_LetGo: fDeltaLife = m_fLifePercentChange.GetValue(SE_LetGo); break;
default:
FAIL_M(ssprintf("Invalid HoldNoteScore: %i", score));
}
if( IsHot() && score == HNS_LetGo )
fDeltaLife = -0.10f; // make it take a while to get back to "hot"
break;
case SongOptions::DRAIN_NO_RECOVER:
switch( score )
{
case HNS_Held: fDeltaLife = +0.000f; break;
case HNS_LetGo: fDeltaLife = m_fLifePercentChange.GetValue(SE_LetGo); break;
default:
FAIL_M(ssprintf("Invalid HoldNoteScore: %i", score));
}
break;
case SongOptions::DRAIN_SUDDEN_DEATH:
switch( score )
{
case HNS_Held: fDeltaLife = +0; break;
case HNS_LetGo: fDeltaLife = -1.0f; break;
default:
FAIL_M(ssprintf("Invalid HoldNoteScore: %i", score));
}
break;
default:
FAIL_M(ssprintf("Invalid DrainType: %i", dtype));
}
ChangeLife( fDeltaLife );
}
void LifeMeterBar::ChangeLife( float fDeltaLife )
{
bool bUseMercifulDrain = m_bMercifulBeginnerInEffect || PREFSMAN->m_bMercifulDrain;
if( bUseMercifulDrain && fDeltaLife < 0 )
fDeltaLife *= SCALE( m_fLifePercentage, 0.f, 1.f, 0.5f, 1.f);
// handle progressiveness and ComboToRegainLife here
if( fDeltaLife >= 0 )
{
m_iMissCombo = 0;
m_iComboToRegainLife = max( m_iComboToRegainLife-1, 0 );
if ( m_iComboToRegainLife > 0 )
fDeltaLife = 0.0f;
}
else
{
fDeltaLife *= 1 + (float)m_iProgressiveLifebar/8 * m_iMissCombo;
// do this after; only successive W5/miss will increase the amount of life lost.
m_iMissCombo++;
m_iComboToRegainLife = PREFSMAN->m_iRegenComboAfterMiss;
}
// If we've already failed, there's no point in letting them fill up the bar again.
if( m_pPlayerStageStats->m_bFailed )
return;
switch( GAMESTATE->m_SongOptions.GetSong().m_DrainType )
{
case SongOptions::DRAIN_NORMAL:
case SongOptions::DRAIN_NO_RECOVER:
if( fDeltaLife > 0 )
fDeltaLife *= m_fLifeDifficulty;
else
fDeltaLife /= m_fLifeDifficulty;
break;
case SongOptions::DRAIN_SUDDEN_DEATH:
// This should always -1.0f;
if( fDeltaLife < 0 )
fDeltaLife = -1.0f;
else
fDeltaLife = 0;
break;
default:
break;
}
m_fLifePercentage += fDeltaLife;
CLAMP( m_fLifePercentage, 0, LIFE_MULTIPLIER );
AfterLifeChanged();
}
extern ThemeMetric<bool> PENALIZE_TAP_SCORE_NONE;
void LifeMeterBar::HandleTapScoreNone()
{
if( PENALIZE_TAP_SCORE_NONE )
ChangeLife( TNS_None );
}
void LifeMeterBar::AfterLifeChanged()
{
m_pStream->SetPercent( m_fLifePercentage );
Message msg( "LifeChanged" );
msg.SetParam( "Player", m_pPlayerState->m_PlayerNumber );
msg.SetParam( "LifeMeter", LuaReference::CreateFromPush(*this) );
MESSAGEMAN->Broadcast( msg );
}
bool LifeMeterBar::IsHot() const
{
return m_fLifePercentage >= HOT_VALUE;
}
bool LifeMeterBar::IsInDanger() const
{
return m_fLifePercentage < DANGER_THRESHOLD;
}
bool LifeMeterBar::IsFailing() const
{
return m_fLifePercentage <= m_pPlayerState->m_PlayerOptions.GetCurrent().m_fPassmark;
}
void LifeMeterBar::Update( float fDeltaTime )
{
LifeMeter::Update( fDeltaTime );
m_fPassingAlpha += !IsFailing() ? +fDeltaTime*2 : -fDeltaTime*2;
CLAMP( m_fPassingAlpha, 0, 1 );
m_fHotAlpha += IsHot() ? + fDeltaTime*2 : -fDeltaTime*2;
CLAMP( m_fHotAlpha, 0, 1 );
m_pStream->SetPassingAlpha( m_fPassingAlpha );
m_pStream->SetHotAlpha( m_fHotAlpha );
if( m_pPlayerState->m_HealthState == HealthState_Danger )
m_sprDanger->SetVisible( true );
else
m_sprDanger->SetVisible( false );
}
void LifeMeterBar::UpdateNonstopLifebar()
{
int iCleared, iTotal, iProgressiveLifebarDifficulty;
switch( GAMESTATE->m_PlayMode )
{
case PLAY_MODE_REGULAR:
if( GAMESTATE->IsEventMode() || GAMESTATE->m_bDemonstrationOrJukebox )
return;
iCleared = GAMESTATE->m_iCurrentStageIndex;
iTotal = PREFSMAN->m_iSongsPerPlay;
iProgressiveLifebarDifficulty = PREFSMAN->m_iProgressiveStageLifebar;
break;
case PLAY_MODE_NONSTOP:
iCleared = GAMESTATE->GetCourseSongIndex();
iTotal = GAMESTATE->m_pCurCourse->GetEstimatedNumStages();
iProgressiveLifebarDifficulty = PREFSMAN->m_iProgressiveNonstopLifebar;
break;
default:
return;
}
// if (iCleared > iTotal) iCleared = iTotal; // clear/iTotal <= 1
// if (iTotal == 0) iTotal = 1; // no division by 0
if( GAMESTATE->IsAnExtraStage() && FORCE_LIFE_DIFFICULTY_ON_EXTRA_STAGE )
{
// extra stage is its own thing, should not be progressive
// and it should be as difficult as life 4
// (e.g. it should not depend on life settings)
m_iProgressiveLifebar = 0;
m_fLifeDifficulty = EXTRA_STAGE_LIFE_DIFFICULTY;
return;
}
if( iTotal > 1 )
m_fLifeDifficulty = m_fBaseLifeDifficulty - 0.2f * (int)(iProgressiveLifebarDifficulty * iCleared / (iTotal - 1));
else
m_fLifeDifficulty = m_fBaseLifeDifficulty - 0.2f * iProgressiveLifebarDifficulty;
if( m_fLifeDifficulty >= 0.4f )
return;
/* Approximate deductions for a miss
* Life 1 : 5 %
* Life 2 : 5.7 %
* Life 3 : 6.6 %
* Life 4 : 8 %
* Life 5 : 10 %
* Life 6 : 13.3 %
* Life 7 : 20 %
* Life 8 : 26.6 %
* Life 9 : 32 %
* Life 10: 40 %
* Life 11: 50 %
* Life 12: 57.1 %
* Life 13: 66.6 %
* Life 14: 80 %
* Life 15: 100 %
* Life 16+: 200 %
*
* Note there is 200%, because boos take off 1/2 as much as
* a miss, and a W5 would suck up half of your lifebar.
*
* Everything past 7 is intended mainly for nonstop mode.
*/
// the lifebar is pretty harsh at 0.4 already (you lose
// about 20% of your lifebar); at 0.2 it would be 40%, which
// is too harsh at one difficulty level higher. Override.
int iLifeDifficulty = int( (1.8f - m_fLifeDifficulty)/0.2f );
// first eight values don't matter
float fDifficultyValues[16] = {0,0,0,0,0,0,0,0,
0.3f, 0.25f, 0.2f, 0.16f, 0.14f, 0.12f, 0.10f, 0.08f};
if( iLifeDifficulty >= 16 )
{
// judge 16 or higher
m_fLifeDifficulty = 0.04f;
return;
}
m_fLifeDifficulty = fDifficultyValues[iLifeDifficulty];
return;
}
void LifeMeterBar::FillForHowToPlay( int NumW2s, int NumMisses )
{
m_iProgressiveLifebar = 0; // disable progressive lifebar
float AmountForW2 = NumW2s * m_fLifeDifficulty * 0.008f;
float AmountForMiss = NumMisses / m_fLifeDifficulty * 0.08f;
m_fLifePercentage = AmountForMiss - AmountForW2;
CLAMP( m_fLifePercentage, 0.0f, 1.0f );
AfterLifeChanged();
}
/*
* (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 "LifeMeterBar.h"
#include "PrefsManager.h"
#include "RageLog.h"
#include "RageTimer.h"
#include "GameState.h"
#include "RageMath.h"
#include "ThemeManager.h"
#include "Song.h"
#include "StatsManager.h"
#include "ThemeMetric.h"
#include "PlayerState.h"
#include "Quad.h"
#include "ActorUtil.h"
#include "StreamDisplay.h"
#include "Steps.h"
#include "Course.h"
static RString LIFE_PERCENT_CHANGE_NAME( size_t i ) { return "LifePercentChange" + ScoreEventToString( (ScoreEvent)i ); }
LifeMeterBar::LifeMeterBar()
{
DANGER_THRESHOLD.Load ("LifeMeterBar","DangerThreshold");
INITIAL_VALUE.Load ("LifeMeterBar","InitialValue");
HOT_VALUE.Load ("LifeMeterBar","HotValue");
LIFE_MULTIPLIER.Load ( "LifeMeterBar","LifeMultiplier");
MIN_STAY_ALIVE.Load ("LifeMeterBar","MinStayAlive");
FORCE_LIFE_DIFFICULTY_ON_EXTRA_STAGE.Load ("LifeMeterBar","ForceLifeDifficultyOnExtraStage");
EXTRA_STAGE_LIFE_DIFFICULTY.Load ("LifeMeterBar","ExtraStageLifeDifficulty");
m_fLifePercentChange.Load( "LifeMeterBar", LIFE_PERCENT_CHANGE_NAME, NUM_ScoreEvent );
m_pPlayerState = nullptr;
SongOptions::DrainType dtype = GAMESTATE->m_SongOptions.GetStage().m_DrainType;
switch( dtype )
{
case SongOptions::DRAIN_NORMAL:
m_fLifePercentage = INITIAL_VALUE;
break;
/* These types only go down, so they always start at full. */
case SongOptions::DRAIN_NO_RECOVER:
case SongOptions::DRAIN_SUDDEN_DEATH:
m_fLifePercentage = 1.0f; break;
default:
FAIL_M(ssprintf("Invalid DrainType: %i", dtype));
}
const RString sType = "LifeMeterBar";
m_fPassingAlpha = 0;
m_fHotAlpha = 0;
m_fBaseLifeDifficulty = PREFSMAN->m_fLifeDifficultyScale;
m_fLifeDifficulty = m_fBaseLifeDifficulty;
// set up progressive lifebar
m_iProgressiveLifebar = PREFSMAN->m_iProgressiveLifebar;
m_iMissCombo = 0;
// set up combotoregainlife
m_iComboToRegainLife = 0;
bool bExtra = GAMESTATE->IsAnExtraStage();
RString sExtra = bExtra ? "extra " : "";
m_sprUnder.Load( THEME->GetPathG(sType,sExtra+"Under") );
m_sprUnder->SetName( "Under" );
ActorUtil::LoadAllCommandsAndSetXY( m_sprUnder, sType );
this->AddChild( m_sprUnder );
m_sprDanger.Load( THEME->GetPathG(sType,sExtra+"Danger") );
m_sprDanger->SetName( "Danger" );
ActorUtil::LoadAllCommandsAndSetXY( m_sprDanger, sType );
this->AddChild( m_sprDanger );
m_pStream = new StreamDisplay;
m_pStream->Load( bExtra ? "StreamDisplayExtra" : "StreamDisplay" );
m_pStream->SetName( "Stream" );
ActorUtil::LoadAllCommandsAndSetXY( m_pStream, sType );
this->AddChild( m_pStream );
m_sprOver.Load( THEME->GetPathG(sType,sExtra+"Over") );
m_sprOver->SetName( "Over" );
ActorUtil::LoadAllCommandsAndSetXY( m_sprOver, sType );
this->AddChild( m_sprOver );
}
LifeMeterBar::~LifeMeterBar()
{
SAFE_DELETE( m_pStream );
}
void LifeMeterBar::Load( const PlayerState *pPlayerState, PlayerStageStats *pPlayerStageStats )
{
LifeMeter::Load( pPlayerState, pPlayerStageStats );
PlayerNumber pn = pPlayerState->m_PlayerNumber;
// Change life difficulty to really easy if merciful beginner on
m_bMercifulBeginnerInEffect =
GAMESTATE->m_PlayMode == PLAY_MODE_REGULAR &&
GAMESTATE->IsPlayerEnabled( pPlayerState ) &&
GAMESTATE->m_pCurSteps[pn]->GetDifficulty() == Difficulty_Beginner &&
PREFSMAN->m_bMercifulBeginner;
AfterLifeChanged();
}
void LifeMeterBar::ChangeLife( TapNoteScore score )
{
float fDeltaLife=0.f;
switch( score )
{
DEFAULT_FAIL( score );
case TNS_W1: fDeltaLife = m_fLifePercentChange.GetValue(SE_W1); break;
case TNS_W2: fDeltaLife = m_fLifePercentChange.GetValue(SE_W2); break;
case TNS_W3: fDeltaLife = m_fLifePercentChange.GetValue(SE_W3); break;
case TNS_W4: fDeltaLife = m_fLifePercentChange.GetValue(SE_W4); break;
case TNS_W5: fDeltaLife = m_fLifePercentChange.GetValue(SE_W5); break;
case TNS_Miss: fDeltaLife = m_fLifePercentChange.GetValue(SE_Miss); break;
case TNS_HitMine: fDeltaLife = m_fLifePercentChange.GetValue(SE_HitMine); break;
case TNS_None: fDeltaLife = m_fLifePercentChange.GetValue(SE_Miss); break;
case TNS_CheckpointHit: fDeltaLife = m_fLifePercentChange.GetValue(SE_CheckpointHit); break;
case TNS_CheckpointMiss:fDeltaLife = m_fLifePercentChange.GetValue(SE_CheckpointMiss); break;
}
// this was previously if( IsHot() && score < TNS_GOOD ) in 3.9... -freem
if( IsHot() && fDeltaLife < 0 )
fDeltaLife = min( fDeltaLife, -0.10f ); // make it take a while to get back to "hot"
switch( GAMESTATE->m_SongOptions.GetSong().m_DrainType )
{
DEFAULT_FAIL( GAMESTATE->m_SongOptions.GetSong().m_DrainType );
case SongOptions::DRAIN_NORMAL:
break;
case SongOptions::DRAIN_NO_RECOVER:
fDeltaLife = min( fDeltaLife, 0 );
break;
case SongOptions::DRAIN_SUDDEN_DEATH:
if( score < MIN_STAY_ALIVE )
fDeltaLife = -1.0f;
else
fDeltaLife = 0;
break;
}
ChangeLife( fDeltaLife );
}
void LifeMeterBar::ChangeLife( HoldNoteScore score, TapNoteScore tscore )
{
float fDeltaLife=0.f;
SongOptions::DrainType dtype = GAMESTATE->m_SongOptions.GetSong().m_DrainType;
switch( dtype )
{
case SongOptions::DRAIN_NORMAL:
switch( score )
{
case HNS_Held: fDeltaLife = m_fLifePercentChange.GetValue(SE_Held); break;
case HNS_LetGo: fDeltaLife = m_fLifePercentChange.GetValue(SE_LetGo); break;
default:
FAIL_M(ssprintf("Invalid HoldNoteScore: %i", score));
}
if( IsHot() && score == HNS_LetGo )
fDeltaLife = -0.10f; // make it take a while to get back to "hot"
break;
case SongOptions::DRAIN_NO_RECOVER:
switch( score )
{
case HNS_Held: fDeltaLife = +0.000f; break;
case HNS_LetGo: fDeltaLife = m_fLifePercentChange.GetValue(SE_LetGo); break;
default:
FAIL_M(ssprintf("Invalid HoldNoteScore: %i", score));
}
break;
case SongOptions::DRAIN_SUDDEN_DEATH:
switch( score )
{
case HNS_Held: fDeltaLife = +0; break;
case HNS_LetGo: fDeltaLife = -1.0f; break;
default:
FAIL_M(ssprintf("Invalid HoldNoteScore: %i", score));
}
break;
default:
FAIL_M(ssprintf("Invalid DrainType: %i", dtype));
}
ChangeLife( fDeltaLife );
}
void LifeMeterBar::ChangeLife( float fDeltaLife )
{
bool bUseMercifulDrain = m_bMercifulBeginnerInEffect || PREFSMAN->m_bMercifulDrain;
if( bUseMercifulDrain && fDeltaLife < 0 )
fDeltaLife *= SCALE( m_fLifePercentage, 0.f, 1.f, 0.5f, 1.f);
// handle progressiveness and ComboToRegainLife here
if( fDeltaLife >= 0 )
{
m_iMissCombo = 0;
m_iComboToRegainLife = max( m_iComboToRegainLife-1, 0 );
if ( m_iComboToRegainLife > 0 )
fDeltaLife = 0.0f;
}
else
{
fDeltaLife *= 1 + (float)m_iProgressiveLifebar/8 * m_iMissCombo;
// do this after; only successive W5/miss will increase the amount of life lost.
m_iMissCombo++;
m_iComboToRegainLife = PREFSMAN->m_iRegenComboAfterMiss;
}
// If we've already failed, there's no point in letting them fill up the bar again.
if( m_pPlayerStageStats->m_bFailed )
return;
switch( GAMESTATE->m_SongOptions.GetSong().m_DrainType )
{
case SongOptions::DRAIN_NORMAL:
case SongOptions::DRAIN_NO_RECOVER:
if( fDeltaLife > 0 )
fDeltaLife *= m_fLifeDifficulty;
else
fDeltaLife /= m_fLifeDifficulty;
break;
case SongOptions::DRAIN_SUDDEN_DEATH:
// This should always -1.0f;
if( fDeltaLife < 0 )
fDeltaLife = -1.0f;
else
fDeltaLife = 0;
break;
default:
break;
}
m_fLifePercentage += fDeltaLife;
CLAMP( m_fLifePercentage, 0, LIFE_MULTIPLIER );
AfterLifeChanged();
}
extern ThemeMetric<bool> PENALIZE_TAP_SCORE_NONE;
void LifeMeterBar::HandleTapScoreNone()
{
if( PENALIZE_TAP_SCORE_NONE )
ChangeLife( TNS_None );
}
void LifeMeterBar::AfterLifeChanged()
{
m_pStream->SetPercent( m_fLifePercentage );
Message msg( "LifeChanged" );
msg.SetParam( "Player", m_pPlayerState->m_PlayerNumber );
msg.SetParam( "LifeMeter", LuaReference::CreateFromPush(*this) );
MESSAGEMAN->Broadcast( msg );
}
bool LifeMeterBar::IsHot() const
{
return m_fLifePercentage >= HOT_VALUE;
}
bool LifeMeterBar::IsInDanger() const
{
return m_fLifePercentage < DANGER_THRESHOLD;
}
bool LifeMeterBar::IsFailing() const
{
return m_fLifePercentage <= m_pPlayerState->m_PlayerOptions.GetCurrent().m_fPassmark;
}
void LifeMeterBar::Update( float fDeltaTime )
{
LifeMeter::Update( fDeltaTime );
m_fPassingAlpha += !IsFailing() ? +fDeltaTime*2 : -fDeltaTime*2;
CLAMP( m_fPassingAlpha, 0, 1 );
m_fHotAlpha += IsHot() ? + fDeltaTime*2 : -fDeltaTime*2;
CLAMP( m_fHotAlpha, 0, 1 );
m_pStream->SetPassingAlpha( m_fPassingAlpha );
m_pStream->SetHotAlpha( m_fHotAlpha );
if( m_pPlayerState->m_HealthState == HealthState_Danger )
m_sprDanger->SetVisible( true );
else
m_sprDanger->SetVisible( false );
}
void LifeMeterBar::UpdateNonstopLifebar()
{
int iCleared, iTotal, iProgressiveLifebarDifficulty;
switch( GAMESTATE->m_PlayMode )
{
case PLAY_MODE_REGULAR:
if( GAMESTATE->IsEventMode() || GAMESTATE->m_bDemonstrationOrJukebox )
return;
iCleared = GAMESTATE->m_iCurrentStageIndex;
iTotal = PREFSMAN->m_iSongsPerPlay;
iProgressiveLifebarDifficulty = PREFSMAN->m_iProgressiveStageLifebar;
break;
case PLAY_MODE_NONSTOP:
iCleared = GAMESTATE->GetCourseSongIndex();
iTotal = GAMESTATE->m_pCurCourse->GetEstimatedNumStages();
iProgressiveLifebarDifficulty = PREFSMAN->m_iProgressiveNonstopLifebar;
break;
default:
return;
}
// if (iCleared > iTotal) iCleared = iTotal; // clear/iTotal <= 1
// if (iTotal == 0) iTotal = 1; // no division by 0
if( GAMESTATE->IsAnExtraStage() && FORCE_LIFE_DIFFICULTY_ON_EXTRA_STAGE )
{
// extra stage is its own thing, should not be progressive
// and it should be as difficult as life 4
// (e.g. it should not depend on life settings)
m_iProgressiveLifebar = 0;
m_fLifeDifficulty = EXTRA_STAGE_LIFE_DIFFICULTY;
return;
}
if( iTotal > 1 )
m_fLifeDifficulty = m_fBaseLifeDifficulty - 0.2f * (int)(iProgressiveLifebarDifficulty * iCleared / (iTotal - 1));
else
m_fLifeDifficulty = m_fBaseLifeDifficulty - 0.2f * iProgressiveLifebarDifficulty;
if( m_fLifeDifficulty >= 0.4f )
return;
/* Approximate deductions for a miss
* Life 1 : 5 %
* Life 2 : 5.7 %
* Life 3 : 6.6 %
* Life 4 : 8 %
* Life 5 : 10 %
* Life 6 : 13.3 %
* Life 7 : 20 %
* Life 8 : 26.6 %
* Life 9 : 32 %
* Life 10: 40 %
* Life 11: 50 %
* Life 12: 57.1 %
* Life 13: 66.6 %
* Life 14: 80 %
* Life 15: 100 %
* Life 16+: 200 %
*
* Note there is 200%, because boos take off 1/2 as much as
* a miss, and a W5 would suck up half of your lifebar.
*
* Everything past 7 is intended mainly for nonstop mode.
*/
// the lifebar is pretty harsh at 0.4 already (you lose
// about 20% of your lifebar); at 0.2 it would be 40%, which
// is too harsh at one difficulty level higher. Override.
int iLifeDifficulty = int( (1.8f - m_fLifeDifficulty)/0.2f );
// first eight values don't matter
float fDifficultyValues[16] = {0,0,0,0,0,0,0,0,
0.3f, 0.25f, 0.2f, 0.16f, 0.14f, 0.12f, 0.10f, 0.08f};
if( iLifeDifficulty >= 16 )
{
// judge 16 or higher
m_fLifeDifficulty = 0.04f;
return;
}
m_fLifeDifficulty = fDifficultyValues[iLifeDifficulty];
return;
}
void LifeMeterBar::FillForHowToPlay( int NumW2s, int NumMisses )
{
m_iProgressiveLifebar = 0; // disable progressive lifebar
float AmountForW2 = NumW2s * m_fLifeDifficulty * 0.008f;
float AmountForMiss = NumMisses / m_fLifeDifficulty * 0.08f;
m_fLifePercentage = AmountForMiss - AmountForW2;
CLAMP( m_fLifePercentage, 0.0f, 1.0f );
AfterLifeChanged();
}
/*
* (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.
*/
+1 -1
View File
@@ -48,7 +48,7 @@ LifeMeterTime::LifeMeterTime()
{
m_fLifeTotalGainedSeconds = 0;
m_fLifeTotalLostSeconds = 0;
m_pStream = NULL;
m_pStream = nullptr;
}
LifeMeterTime::~LifeMeterTime()
+1 -1
View File
@@ -94,7 +94,7 @@ static void GetUsedGameInputs( vector<GameInput> &vGameInputsOut )
vGameInputsOut.push_back( input );
}
LightsManager* LIGHTSMAN = NULL; // global and accessable from anywhere in our program
LightsManager* LIGHTSMAN = nullptr; // global and accessable from anywhere in our program
LightsManager::LightsManager()
{
+1 -1
View File
@@ -39,7 +39,7 @@ LocalizedString::LocalizedString( const RString& sGroup, const RString& sName )
m_sGroup = sGroup;
m_sName = sName;
m_pImpl = NULL;
m_pImpl = nullptr;
CreateImpl();
}
+4 -4
View File
@@ -16,7 +16,7 @@
#include <cassert>
#include <map>
LuaManager *LUA = NULL;
LuaManager *LUA = nullptr;
struct Impl
{
Impl(): g_pLock("Lua") {}
@@ -25,7 +25,7 @@ struct Impl
RageMutex g_pLock;
};
static Impl *pImpl = NULL;
static Impl *pImpl = nullptr;
#if defined(_MSC_VER)
/* "interaction between '_setjmp' and C++ object destruction is non-portable"
@@ -226,7 +226,7 @@ static int LuaPanic( lua_State *L )
}
// Actor registration
static vector<RegisterWithLuaFn> *g_vRegisterActorTypes = NULL;
static vector<RegisterWithLuaFn> *g_vRegisterActorTypes = nullptr;
void LuaManager::Register( RegisterWithLuaFn pfn )
{
@@ -315,7 +315,7 @@ void LuaManager::Release( Lua *&p )
if( bDoUnlock )
pImpl->g_pLock.Unlock();
p = NULL;
p = nullptr;
}
/*
+2 -2
View File
@@ -13,7 +13,7 @@
#include "arch/MemoryCard/MemoryCardDriver_Null.h"
#include "LuaManager.h"
MemoryCardManager* MEMCARDMAN = NULL; // global and accessable from anywhere in our program
MemoryCardManager* MEMCARDMAN = nullptr; // global and accessable from anywhere in our program
static void MemoryCardOsMountPointInit( size_t /*PlayerNumber*/ i, RString &sNameOut, RString &defaultValueOut )
{
@@ -253,7 +253,7 @@ bool ThreadedMemoryCardWorker::Unmount( const UsbStorageDevice *pDevice )
return true;
}
static ThreadedMemoryCardWorker *g_pWorker = NULL;
static ThreadedMemoryCardWorker *g_pWorker = nullptr;
MemoryCardManager::MemoryCardManager()
{
+1 -1
View File
@@ -19,7 +19,7 @@ MenuTimer::MenuTimer()
m_fStallSecondsLeft = 0;
m_bPaused = false;
m_bSilent = false;
WARNING_COMMAND = NULL;
WARNING_COMMAND = nullptr;
}
MenuTimer::~MenuTimer()
+1 -1
View File
@@ -9,7 +9,7 @@
#include <set>
#include <map>
MessageManager* MESSAGEMAN = NULL; // global and accessable from anywhere in our program
MessageManager* MESSAGEMAN = nullptr; // global and accessable from anywhere in our program
static const char *MessageIDNames[] = {
+297 -297
View File
@@ -1,297 +1,297 @@
#ifndef MessageManager_H
#define MessageManager_H
#include "LuaManager.h"
struct lua_State;
class LuaTable;
class LuaReference;
/** @brief The various messages available to watch for. */
enum MessageID
{
Message_CurrentGameChanged,
Message_CurrentStyleChanged,
Message_PlayModeChanged,
Message_CurrentSongChanged,
Message_CurrentStepsP1Changed,
Message_CurrentStepsP2Changed,
Message_CurrentCourseChanged,
Message_CurrentTrailP1Changed,
Message_CurrentTrailP2Changed,
Message_GameplayLeadInChanged,
Message_EditStepsTypeChanged,
Message_EditCourseDifficultyChanged,
Message_EditSourceStepsChanged,
Message_EditSourceStepsTypeChanged,
Message_PreferredStepsTypeChanged,
Message_PreferredDifficultyP1Changed,
Message_PreferredDifficultyP2Changed,
Message_PreferredCourseDifficultyP1Changed,
Message_PreferredCourseDifficultyP2Changed,
Message_EditCourseEntryIndexChanged,
Message_EditLocalProfileIDChanged,
Message_GoalCompleteP1,
Message_GoalCompleteP2,
Message_NoteCrossed,
Message_NoteWillCrossIn400Ms,
Message_NoteWillCrossIn800Ms,
Message_NoteWillCrossIn1200Ms,
Message_CardRemovedP1,
Message_CardRemovedP2,
Message_BeatCrossed,
Message_MenuUpP1,
Message_MenuUpP2,
Message_MenuDownP1,
Message_MenuDownP2,
Message_MenuLeftP1,
Message_MenuLeftP2,
Message_MenuRightP1,
Message_MenuRightP2,
Message_MenuStartP1,
Message_MenuStartP2,
Message_MenuSelectionChanged,
Message_PlayerJoined,
Message_PlayerUnjoined,
Message_AutosyncChanged,
Message_PreferredSongGroupChanged,
Message_PreferredCourseGroupChanged,
Message_SortOrderChanged,
Message_LessonTry1,
Message_LessonTry2,
Message_LessonTry3,
Message_LessonCleared,
Message_LessonFailed,
Message_StorageDevicesChanged,
Message_AutoJoyMappingApplied,
Message_ScreenChanged,
Message_SongModified,
Message_ScoreMultiplierChangedP1,
Message_ScoreMultiplierChangedP2,
Message_StarPowerChangedP1,
Message_StarPowerChangedP2,
Message_CurrentComboChangedP1,
Message_CurrentComboChangedP2,
Message_StarMeterChangedP1,
Message_StarMeterChangedP2,
Message_LifeMeterChangedP1,
Message_LifeMeterChangedP2,
Message_UpdateScreenHeader,
Message_LeftClick,
Message_RightClick,
Message_MiddleClick,
Message_MouseWheelUp,
Message_MouseWheelDown,
NUM_MessageID, // leave this at the end
MessageID_Invalid
};
const RString& MessageIDToString( MessageID m );
struct Message
{
explicit Message( const RString &s );
Message( const RString &s, const LuaReference &params );
~Message();
void SetName( const RString &sName ) { m_sName = sName; }
RString GetName() const { return m_sName; }
bool IsBroadcast() const { return m_bBroadcast; }
void SetBroadcast( bool b ) { m_bBroadcast = b; }
void PushParamTable( lua_State *L );
const LuaReference &GetParamTable() const;
void SetParamTable( const LuaReference &params );
void GetParamFromStack( lua_State *L, const RString &sName ) const;
void SetParamFromStack( lua_State *L, const RString &sName );
template<typename T>
bool GetParam( const RString &sName, T &val ) const
{
Lua *L = LUA->Get();
GetParamFromStack( L, sName );
bool bRet = LuaHelpers::Pop( L, val );
LUA->Release( L );
return bRet;
}
template<typename T>
void SetParam( const RString &sName, const T &val )
{
Lua *L = LUA->Get();
LuaHelpers::Push( L, val );
SetParamFromStack( L, sName );
LUA->Release( L );
}
bool operator==( const RString &s ) const { return m_sName == s; }
bool operator==( MessageID id ) const { return MessageIDToString(id) == m_sName; }
private:
RString m_sName;
LuaTable *m_pParams;
bool m_bBroadcast;
Message &operator=( const Message &rhs ); // don't use
/* Work around a gcc bug where HandleMessage( Message("Init") ) fails because the copy ctor is private.
* The copy ctor is not even used so I have no idea why it being private is an issue. Also, if the
* Message object were constructed implicitly (remove explicit above), it works: HandleMessage( "Init" ).
* Leaving this undefined but public changes a compile time error into a link time error. Hmm.*/
public:
Message( const Message &rhs ); // don't use
};
class IMessageSubscriber
{
public:
virtual ~IMessageSubscriber() { }
virtual void HandleMessage( const Message &msg ) = 0;
void ClearMessages( const RString sMessage = "" );
private:
friend class MessageManager;
};
class MessageSubscriber : public IMessageSubscriber
{
public:
MessageSubscriber(): m_vsSubscribedTo() {}
MessageSubscriber( const MessageSubscriber &cpy );
MessageSubscriber &operator=(const MessageSubscriber &cpy);
//
// Messages
//
void SubscribeToMessage( MessageID message ); // will automatically unsubscribe
void SubscribeToMessage( const RString &sMessageName ); // will automatically unsubscribe
void UnsubscribeAll();
private:
vector<RString> m_vsSubscribedTo;
};
/** @brief Deliver messages to any part of the program as needed. */
class MessageManager
{
public:
MessageManager();
~MessageManager();
void Subscribe( IMessageSubscriber* pSubscriber, const RString& sMessage );
void Subscribe( IMessageSubscriber* pSubscriber, MessageID m );
void Unsubscribe( IMessageSubscriber* pSubscriber, const RString& sMessage );
void Unsubscribe( IMessageSubscriber* pSubscriber, MessageID m );
void Broadcast( Message &msg ) const;
void Broadcast( const RString& sMessage ) const;
void Broadcast( MessageID m ) const;
bool IsSubscribedToMessage( IMessageSubscriber* pSubscriber, const RString &sMessage ) const;
inline bool IsSubscribedToMessage( IMessageSubscriber* pSubscriber, MessageID message ) const { return IsSubscribedToMessage( pSubscriber, MessageIDToString(message) ); }
// Lua
void PushSelf( lua_State *L );
};
extern MessageManager* MESSAGEMAN; // global and accessable from anywhere in our program
template<class T>
class BroadcastOnChange
{
private:
MessageID mSendWhenChanged;
T val;
public:
explicit BroadcastOnChange( MessageID m ) { mSendWhenChanged = m; }
const T Get() const { return val; }
void Set( T t ) { val = t; MESSAGEMAN->Broadcast( MessageIDToString(mSendWhenChanged) ); }
operator T () const { return val; }
bool operator == ( const T &other ) const { return val == other; }
bool operator != ( const T &other ) const { return val != other; }
};
/** @brief Utilities for working with Lua. */
namespace LuaHelpers
{
template<class T> void Push( lua_State *L, const BroadcastOnChange<T> &Object )
{
LuaHelpers::Push<T>( L, Object.Get() );
}
}
template<class T, int N>
class BroadcastOnChange1D
{
private:
typedef BroadcastOnChange<T> MyType;
vector<MyType> val;
public:
explicit BroadcastOnChange1D( MessageID m )
{
for( unsigned i=0; i<N; i++ )
val.push_back( BroadcastOnChange<T>((MessageID)(m+i)) );
}
const BroadcastOnChange<T>& operator[]( unsigned i ) const { return val[i]; }
BroadcastOnChange<T>& operator[]( unsigned i ) { return val[i]; }
};
template<class T>
class BroadcastOnChangePtr
{
private:
MessageID mSendWhenChanged;
T *val;
public:
explicit BroadcastOnChangePtr( MessageID m ) { mSendWhenChanged = m; val = NULL; }
T* Get() const { return val; }
void Set( T* t ) { val = t; if(MESSAGEMAN) MESSAGEMAN->Broadcast( MessageIDToString(mSendWhenChanged) ); }
/* This is only intended to be used for setting temporary values; always
* restore the original value when finished, so listeners don't get confused
* due to missing a message. */
void SetWithoutBroadcast( T* t ) { val = t; }
operator T* () const { return val; }
T* operator->() const { return val; }
};
template<class T, int N>
class BroadcastOnChangePtr1D
{
private:
typedef BroadcastOnChangePtr<T> MyType;
vector<MyType> val;
public:
explicit BroadcastOnChangePtr1D( MessageID m )
{
for( unsigned i=0; i<N; i++ )
val.push_back( BroadcastOnChangePtr<T>((MessageID)(m+i)) );
}
const BroadcastOnChangePtr<T>& operator[]( unsigned i ) const { return val[i]; }
BroadcastOnChangePtr<T>& operator[]( unsigned i ) { return val[i]; }
};
#endif
/*
* (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.
*/
#ifndef MessageManager_H
#define MessageManager_H
#include "LuaManager.h"
struct lua_State;
class LuaTable;
class LuaReference;
/** @brief The various messages available to watch for. */
enum MessageID
{
Message_CurrentGameChanged,
Message_CurrentStyleChanged,
Message_PlayModeChanged,
Message_CurrentSongChanged,
Message_CurrentStepsP1Changed,
Message_CurrentStepsP2Changed,
Message_CurrentCourseChanged,
Message_CurrentTrailP1Changed,
Message_CurrentTrailP2Changed,
Message_GameplayLeadInChanged,
Message_EditStepsTypeChanged,
Message_EditCourseDifficultyChanged,
Message_EditSourceStepsChanged,
Message_EditSourceStepsTypeChanged,
Message_PreferredStepsTypeChanged,
Message_PreferredDifficultyP1Changed,
Message_PreferredDifficultyP2Changed,
Message_PreferredCourseDifficultyP1Changed,
Message_PreferredCourseDifficultyP2Changed,
Message_EditCourseEntryIndexChanged,
Message_EditLocalProfileIDChanged,
Message_GoalCompleteP1,
Message_GoalCompleteP2,
Message_NoteCrossed,
Message_NoteWillCrossIn400Ms,
Message_NoteWillCrossIn800Ms,
Message_NoteWillCrossIn1200Ms,
Message_CardRemovedP1,
Message_CardRemovedP2,
Message_BeatCrossed,
Message_MenuUpP1,
Message_MenuUpP2,
Message_MenuDownP1,
Message_MenuDownP2,
Message_MenuLeftP1,
Message_MenuLeftP2,
Message_MenuRightP1,
Message_MenuRightP2,
Message_MenuStartP1,
Message_MenuStartP2,
Message_MenuSelectionChanged,
Message_PlayerJoined,
Message_PlayerUnjoined,
Message_AutosyncChanged,
Message_PreferredSongGroupChanged,
Message_PreferredCourseGroupChanged,
Message_SortOrderChanged,
Message_LessonTry1,
Message_LessonTry2,
Message_LessonTry3,
Message_LessonCleared,
Message_LessonFailed,
Message_StorageDevicesChanged,
Message_AutoJoyMappingApplied,
Message_ScreenChanged,
Message_SongModified,
Message_ScoreMultiplierChangedP1,
Message_ScoreMultiplierChangedP2,
Message_StarPowerChangedP1,
Message_StarPowerChangedP2,
Message_CurrentComboChangedP1,
Message_CurrentComboChangedP2,
Message_StarMeterChangedP1,
Message_StarMeterChangedP2,
Message_LifeMeterChangedP1,
Message_LifeMeterChangedP2,
Message_UpdateScreenHeader,
Message_LeftClick,
Message_RightClick,
Message_MiddleClick,
Message_MouseWheelUp,
Message_MouseWheelDown,
NUM_MessageID, // leave this at the end
MessageID_Invalid
};
const RString& MessageIDToString( MessageID m );
struct Message
{
explicit Message( const RString &s );
Message( const RString &s, const LuaReference &params );
~Message();
void SetName( const RString &sName ) { m_sName = sName; }
RString GetName() const { return m_sName; }
bool IsBroadcast() const { return m_bBroadcast; }
void SetBroadcast( bool b ) { m_bBroadcast = b; }
void PushParamTable( lua_State *L );
const LuaReference &GetParamTable() const;
void SetParamTable( const LuaReference &params );
void GetParamFromStack( lua_State *L, const RString &sName ) const;
void SetParamFromStack( lua_State *L, const RString &sName );
template<typename T>
bool GetParam( const RString &sName, T &val ) const
{
Lua *L = LUA->Get();
GetParamFromStack( L, sName );
bool bRet = LuaHelpers::Pop( L, val );
LUA->Release( L );
return bRet;
}
template<typename T>
void SetParam( const RString &sName, const T &val )
{
Lua *L = LUA->Get();
LuaHelpers::Push( L, val );
SetParamFromStack( L, sName );
LUA->Release( L );
}
bool operator==( const RString &s ) const { return m_sName == s; }
bool operator==( MessageID id ) const { return MessageIDToString(id) == m_sName; }
private:
RString m_sName;
LuaTable *m_pParams;
bool m_bBroadcast;
Message &operator=( const Message &rhs ); // don't use
/* Work around a gcc bug where HandleMessage( Message("Init") ) fails because the copy ctor is private.
* The copy ctor is not even used so I have no idea why it being private is an issue. Also, if the
* Message object were constructed implicitly (remove explicit above), it works: HandleMessage( "Init" ).
* Leaving this undefined but public changes a compile time error into a link time error. Hmm.*/
public:
Message( const Message &rhs ); // don't use
};
class IMessageSubscriber
{
public:
virtual ~IMessageSubscriber() { }
virtual void HandleMessage( const Message &msg ) = 0;
void ClearMessages( const RString sMessage = "" );
private:
friend class MessageManager;
};
class MessageSubscriber : public IMessageSubscriber
{
public:
MessageSubscriber(): m_vsSubscribedTo() {}
MessageSubscriber( const MessageSubscriber &cpy );
MessageSubscriber &operator=(const MessageSubscriber &cpy);
//
// Messages
//
void SubscribeToMessage( MessageID message ); // will automatically unsubscribe
void SubscribeToMessage( const RString &sMessageName ); // will automatically unsubscribe
void UnsubscribeAll();
private:
vector<RString> m_vsSubscribedTo;
};
/** @brief Deliver messages to any part of the program as needed. */
class MessageManager
{
public:
MessageManager();
~MessageManager();
void Subscribe( IMessageSubscriber* pSubscriber, const RString& sMessage );
void Subscribe( IMessageSubscriber* pSubscriber, MessageID m );
void Unsubscribe( IMessageSubscriber* pSubscriber, const RString& sMessage );
void Unsubscribe( IMessageSubscriber* pSubscriber, MessageID m );
void Broadcast( Message &msg ) const;
void Broadcast( const RString& sMessage ) const;
void Broadcast( MessageID m ) const;
bool IsSubscribedToMessage( IMessageSubscriber* pSubscriber, const RString &sMessage ) const;
inline bool IsSubscribedToMessage( IMessageSubscriber* pSubscriber, MessageID message ) const { return IsSubscribedToMessage( pSubscriber, MessageIDToString(message) ); }
// Lua
void PushSelf( lua_State *L );
};
extern MessageManager* MESSAGEMAN; // global and accessable from anywhere in our program
template<class T>
class BroadcastOnChange
{
private:
MessageID mSendWhenChanged;
T val;
public:
explicit BroadcastOnChange( MessageID m ) { mSendWhenChanged = m; }
const T Get() const { return val; }
void Set( T t ) { val = t; MESSAGEMAN->Broadcast( MessageIDToString(mSendWhenChanged) ); }
operator T () const { return val; }
bool operator == ( const T &other ) const { return val == other; }
bool operator != ( const T &other ) const { return val != other; }
};
/** @brief Utilities for working with Lua. */
namespace LuaHelpers
{
template<class T> void Push( lua_State *L, const BroadcastOnChange<T> &Object )
{
LuaHelpers::Push<T>( L, Object.Get() );
}
}
template<class T, int N>
class BroadcastOnChange1D
{
private:
typedef BroadcastOnChange<T> MyType;
vector<MyType> val;
public:
explicit BroadcastOnChange1D( MessageID m )
{
for( unsigned i=0; i<N; i++ )
val.push_back( BroadcastOnChange<T>((MessageID)(m+i)) );
}
const BroadcastOnChange<T>& operator[]( unsigned i ) const { return val[i]; }
BroadcastOnChange<T>& operator[]( unsigned i ) { return val[i]; }
};
template<class T>
class BroadcastOnChangePtr
{
private:
MessageID mSendWhenChanged;
T *val;
public:
explicit BroadcastOnChangePtr( MessageID m ) { mSendWhenChanged = m; val = nullptr; }
T* Get() const { return val; }
void Set( T* t ) { val = t; if(MESSAGEMAN) MESSAGEMAN->Broadcast( MessageIDToString(mSendWhenChanged) ); }
/* This is only intended to be used for setting temporary values; always
* restore the original value when finished, so listeners don't get confused
* due to missing a message. */
void SetWithoutBroadcast( T* t ) { val = t; }
operator T* () const { return val; }
T* operator->() const { return val; }
};
template<class T, int N>
class BroadcastOnChangePtr1D
{
private:
typedef BroadcastOnChangePtr<T> MyType;
vector<MyType> val;
public:
explicit BroadcastOnChangePtr1D( MessageID m )
{
for( unsigned i=0; i<N; i++ )
val.push_back( BroadcastOnChangePtr<T>((MessageID)(m+i)) );
}
const BroadcastOnChangePtr<T>& operator[]( unsigned i ) const { return val[i]; }
BroadcastOnChangePtr<T>& operator[]( unsigned i ) { return val[i]; }
};
#endif
/*
* (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.
*/
+7 -7
View File
@@ -24,13 +24,13 @@ Model::Model()
m_bTextureWrapping = true;
SetUseZBuffer( true );
SetCullMode( CULL_BACK );
m_pGeometry = NULL;
m_pCurAnimation = NULL;
m_pGeometry = nullptr;
m_pCurAnimation = nullptr;
m_fDefaultAnimationRate = 1;
m_fCurAnimationRate = 1;
m_bLoop = true;
m_bDrawCelShaded = false;
m_pTempGeometry = NULL;
m_pTempGeometry = nullptr;
}
Model::~Model()
@@ -43,12 +43,12 @@ void Model::Clear()
if( m_pGeometry )
{
MODELMAN->UnloadModel( m_pGeometry );
m_pGeometry = NULL;
m_pGeometry = nullptr;
}
m_vpBones.clear();
m_Materials.clear();
m_mapNameToAnimation.clear();
m_pCurAnimation = NULL;
m_pCurAnimation = nullptr;
if( m_pTempGeometry )
DISPLAY->DeleteCompiledGeometry( m_pTempGeometry );
@@ -607,7 +607,7 @@ void Model::SetBones( const msAnimation* pAnimation, float fFrame, vector<myBone
}
// search for the adjacent position keys
const msPositionKey *pLastPositionKey = NULL, *pThisPositionKey = NULL;
const msPositionKey *pLastPositionKey = nullptr, *pThisPositionKey = nullptr;
for( size_t j = 0; j < pBone->PositionKeys.size(); ++j )
{
const msPositionKey *pPositionKey = &pBone->PositionKeys[j];
@@ -631,7 +631,7 @@ void Model::SetBones( const msAnimation* pAnimation, float fFrame, vector<myBone
vPos = pLastPositionKey->Position;
// search for the adjacent rotation keys
const msRotationKey *pLastRotationKey = NULL, *pThisRotationKey = NULL;
const msRotationKey *pLastRotationKey = nullptr, *pThisRotationKey = nullptr;
for( size_t j = 0; j < pBone->RotationKeys.size(); ++j )
{
const msRotationKey *pRotationKey = &pBone->RotationKeys[j];
+4 -4
View File
@@ -187,7 +187,7 @@ void MusicWheel::BeginScreen()
if( GAMESTATE->m_pCurSong != nullptr &&
GameState::GetNumStagesMultiplierForSong( GAMESTATE->m_pCurSong ) > GAMESTATE->GetSmallestNumStagesLeftForAnyHumanPlayer() )
{
GAMESTATE->m_pCurSong.Set( NULL );
GAMESTATE->m_pCurSong.Set(nullptr);
}
/* Invalidate current Steps if it can't be played
@@ -201,7 +201,7 @@ void MusicWheel::BeginScreen()
SongUtil::GetPlayableSteps( GAMESTATE->m_pCurSong, vpPossibleSteps );
bool bStepsIsPossible = find( vpPossibleSteps.begin(), vpPossibleSteps.end(), GAMESTATE->m_pCurSteps[p] ) == vpPossibleSteps.end();
if( !bStepsIsPossible )
GAMESTATE->m_pCurSteps[p].Set( NULL );
GAMESTATE->m_pCurSteps[p].Set(nullptr);
}
}
@@ -910,7 +910,7 @@ void MusicWheel::FilterWheelItemDatas(vector<MusicWheelItemData *> &aUnFilteredD
const int iMaxStagesForSong = GAMESTATE->GetSmallestNumStagesLeftForAnyHumanPlayer();
Song *pExtraStageSong = NULL;
Song *pExtraStageSong = nullptr;
if( GAMESTATE->IsAnExtraStage() )
{
Steps *pSteps;
@@ -1342,7 +1342,7 @@ void MusicWheel::SetOpenSection( RString group )
if ( REMIND_WHEEL_POSITIONS && HIDE_INACTIVE_SECTIONS )
m_viWheelPositions.resize( SONGMAN->GetNumSongGroups() );
const WheelItemBaseData *old = NULL;
const WheelItemBaseData *old = nullptr;
if( !m_CurWheelItemData.empty() )
old = GetCurWheelItemData(m_iSelection);
+3 -3
View File
@@ -75,7 +75,7 @@ MusicWheelItem::MusicWheelItem( RString sType ):
FOREACH_ENUM( MusicWheelItemType, i )
{
m_pText[i] = NULL;
m_pText[i] = nullptr;
// Don't init text for Type_Song. It uses a TextBanner.
if( i == MusicWheelItemType_Song )
@@ -147,7 +147,7 @@ MusicWheelItem::MusicWheelItem( const MusicWheelItem &cpy ):
{
if( cpy.m_pText[i] == nullptr )
{
m_pText[i] = NULL;
m_pText[i] = nullptr;
}
else
{
@@ -345,7 +345,7 @@ void MusicWheelItem::RefreshGrades()
Profile *pProfile = PROFILEMAN->GetProfile(ps);
HighScoreList *pHSL = NULL;
HighScoreList *pHSL = nullptr;
if( PROFILEMAN->IsPersistentProfile(ps) && dc != Difficulty_Invalid )
{
if( pWID->m_pSong )
+110 -110
View File
@@ -1,110 +1,110 @@
#ifndef MUSIC_WHEEL_ITEM_H
#define MUSIC_WHEEL_ITEM_H
#include "ActorFrame.h"
#include "BitmapText.h"
#include "WheelNotifyIcon.h"
#include "TextBanner.h"
#include "GameConstantsAndTypes.h"
#include "GameCommand.h"
#include "WheelItemBase.h"
#include "AutoActor.h"
#include "ThemeMetric.h"
class Course;
class Song;
struct MusicWheelItemData;
enum MusicWheelItemType
{
MusicWheelItemType_Song,
MusicWheelItemType_SectionExpanded,
MusicWheelItemType_SectionCollapsed,
MusicWheelItemType_Roulette,
MusicWheelItemType_Course,
MusicWheelItemType_Sort,
MusicWheelItemType_Mode,
MusicWheelItemType_Random,
MusicWheelItemType_Portal,
MusicWheelItemType_Custom,
NUM_MusicWheelItemType,
MusicWheelItemType_Invalid,
};
const RString& MusicWheelItemTypeToString( MusicWheelItemType i );
/** @brief An item on the MusicWheel. */
class MusicWheelItem : public WheelItemBase
{
public:
MusicWheelItem(RString sType = "MusicWheelItem");
MusicWheelItem( const MusicWheelItem &cpy );
virtual ~MusicWheelItem();
virtual MusicWheelItem *Copy() const { return new MusicWheelItem(*this); }
virtual void LoadFromWheelItemData( const WheelItemBaseData* pWID, int iIndex, bool bHasFocus, int iDrawIndex );
virtual void HandleMessage( const Message &msg );
void RefreshGrades();
private:
ThemeMetric<bool> GRADES_SHOW_MACHINE;
AutoActor m_sprColorPart[NUM_MusicWheelItemType];
AutoActor m_sprNormalPart[NUM_MusicWheelItemType];
AutoActor m_sprOverPart[NUM_MusicWheelItemType];
TextBanner m_TextBanner; // used by Type_Song instead of m_pText
BitmapText *m_pText[NUM_MusicWheelItemType];
BitmapText *m_pTextSectionCount;
WheelNotifyIcon m_WheelNotifyIcon;
AutoActor m_pGradeDisplay[NUM_PLAYERS];
};
struct MusicWheelItemData : public WheelItemBaseData
{
MusicWheelItemData() : m_pCourse(NULL), m_pSong(NULL), m_Flags(),
m_iSectionCount(0), m_sLabel(""), m_pAction() { }
MusicWheelItemData( WheelItemDataType type, Song* pSong,
RString sSectionName, Course* pCourse,
RageColor color, int iSectionCount );
Course* m_pCourse;
Song* m_pSong;
WheelNotifyIcon::Flags m_Flags;
// for TYPE_SECTION
int m_iSectionCount;
// for TYPE_SORT
RString m_sLabel;
HiddenPtr<GameCommand> m_pAction;
};
#endif
/**
* @file
* @author Chris Danford, Chris Gomez, Glenn Maynard (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.
*/
#ifndef MUSIC_WHEEL_ITEM_H
#define MUSIC_WHEEL_ITEM_H
#include "ActorFrame.h"
#include "BitmapText.h"
#include "WheelNotifyIcon.h"
#include "TextBanner.h"
#include "GameConstantsAndTypes.h"
#include "GameCommand.h"
#include "WheelItemBase.h"
#include "AutoActor.h"
#include "ThemeMetric.h"
class Course;
class Song;
struct MusicWheelItemData;
enum MusicWheelItemType
{
MusicWheelItemType_Song,
MusicWheelItemType_SectionExpanded,
MusicWheelItemType_SectionCollapsed,
MusicWheelItemType_Roulette,
MusicWheelItemType_Course,
MusicWheelItemType_Sort,
MusicWheelItemType_Mode,
MusicWheelItemType_Random,
MusicWheelItemType_Portal,
MusicWheelItemType_Custom,
NUM_MusicWheelItemType,
MusicWheelItemType_Invalid,
};
const RString& MusicWheelItemTypeToString( MusicWheelItemType i );
/** @brief An item on the MusicWheel. */
class MusicWheelItem : public WheelItemBase
{
public:
MusicWheelItem(RString sType = "MusicWheelItem");
MusicWheelItem( const MusicWheelItem &cpy );
virtual ~MusicWheelItem();
virtual MusicWheelItem *Copy() const { return new MusicWheelItem(*this); }
virtual void LoadFromWheelItemData( const WheelItemBaseData* pWID, int iIndex, bool bHasFocus, int iDrawIndex );
virtual void HandleMessage( const Message &msg );
void RefreshGrades();
private:
ThemeMetric<bool> GRADES_SHOW_MACHINE;
AutoActor m_sprColorPart[NUM_MusicWheelItemType];
AutoActor m_sprNormalPart[NUM_MusicWheelItemType];
AutoActor m_sprOverPart[NUM_MusicWheelItemType];
TextBanner m_TextBanner; // used by Type_Song instead of m_pText
BitmapText *m_pText[NUM_MusicWheelItemType];
BitmapText *m_pTextSectionCount;
WheelNotifyIcon m_WheelNotifyIcon;
AutoActor m_pGradeDisplay[NUM_PLAYERS];
};
struct MusicWheelItemData : public WheelItemBaseData
{
MusicWheelItemData() : m_pCourse(nullptr), m_pSong(nullptr), m_Flags(),
m_iSectionCount(0), m_sLabel(""), m_pAction() { }
MusicWheelItemData( WheelItemDataType type, Song* pSong,
RString sSectionName, Course* pCourse,
RageColor color, int iSectionCount );
Course* m_pCourse;
Song* m_pSong;
WheelNotifyIcon::Flags m_Flags;
// for TYPE_SECTION
int m_iSectionCount;
// for TYPE_SORT
RString m_sLabel;
HiddenPtr<GameCommand> m_pAction;
};
#endif
/**
* @file
* @author Chris Danford, Chris Gomez, Glenn Maynard (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.
*/
+2 -2
View File
@@ -68,8 +68,8 @@ int NetworkSyncManager::GetSMOnlineSalt()
static LocalizedString INITIALIZING_CLIENT_NETWORK ( "NetworkSyncManager", "Initializing Client Network..." );
NetworkSyncManager::NetworkSyncManager( LoadingWindow *ld )
{
LANserver = NULL; //So we know if it has been created yet
BroadcastReception = NULL;
LANserver = nullptr; //So we know if it has been created yet
BroadcastReception = nullptr;
ld->SetText( INITIALIZING_CLIENT_NETWORK );
NetPlayerClient = new EzSockets;
+241 -241
View File
@@ -1,241 +1,241 @@
#ifndef NetworkSyncManager_H
#define NetworkSyncManager_H
#include "PlayerNumber.h"
#include "Difficulty.h"
#include <queue>
class LoadingWindow;
const int NETPROTOCOLVERSION=3;
const int NETMAXBUFFERSIZE=1020; //1024 - 4 bytes for EzSockets
const int NETNUMTAPSCORES=8;
// [SMLClientCommands name]
enum NSCommand
{
NSCPing = 0,
NSCPingR, // 1 [SMLC_PingR]
NSCHello, // 2 [SMLC_Hello]
NSCGSR, // 3 [SMLC_GameStart]
NSCGON, // 4 [SMLC_GameOver]
NSCGSU, // 5 [SMLC_GameStatusUpdate]
NSCSU, // 6 [SMLC_StyleUpdate]
NSCCM, // 7 [SMLC_Chat]
NSCRSG, // 8 [SMLC_RequestStart]
NSCUUL, // 9 [SMLC_Reserved1]
NSCSMS, // 10 [SMLC_MusicSelect]
NSCUPOpts, // 11 [SMLC_PlayerOpts]
NSCSMOnline, // 12 [SMLC_SMO]
NSCFormatted, // 13 [SMLC_RESERVED1]
NSCAttack, // 14 [SMLC_RESERVED2]
NUM_NS_COMMANDS
};
enum SMOStepType
{
SMOST_UNUSED = 0,
SMOST_HITMINE,
SMOST_AVOIDMINE,
SMOST_MISS,
SMOST_W5,
SMOST_W4,
SMOST_W3,
SMOST_W2,
SMOST_W1,
SMOST_LETGO,
SMOST_HELD
/*
,SMOST_CHECKPOINTMISS,
SMOST_CHECKPOINTHIT
*/
};
const NSCommand NSServerOffset = (NSCommand)128;
// TODO: Provide a Lua binding that gives access to this data. -aj
struct EndOfGame_PlayerData
{
int name;
int score;
int grade;
Difficulty difficulty;
int tapScores[NETNUMTAPSCORES]; //This will be a const soon enough
RString playerOptions;
};
enum NSScoreBoardColumn
{
NSSB_NAMES=0,
NSSB_COMBO,
NSSB_GRADE,
NUM_NSScoreBoardColumn,
NSScoreBoardColumn_Invalid
};
/** @brief A special foreach loop going through each NSScoreBoardColumn. */
#define FOREACH_NSScoreBoardColumn( sc ) FOREACH_ENUM( NSScoreBoardColumn, sc )
struct NetServerInfo
{
RString Name;
RString Address;
};
class EzSockets;
class StepManiaLanServer;
class PacketFunctions
{
public:
unsigned char Data[NETMAXBUFFERSIZE]; //Data
int Position; //Other info (Used for following functions)
int size; //When sending these pacs, Position should
//be used; NOT size.
//Commands used to operate on NetPackets
uint8_t Read1();
uint16_t Read2();
uint32_t Read4();
RString ReadNT();
void Write1( uint8_t Data );
void Write2( uint16_t Data );
void Write4( uint32_t Data );
void WriteNT( const RString& Data );
void ClearPacket();
};
/** @brief Uses ezsockets for primitive song syncing and score reporting. */
class NetworkSyncManager
{
public:
NetworkSyncManager( LoadingWindow *ld = NULL );
~NetworkSyncManager();
// If "useSMserver" then send score to server
void ReportScore( int playerID, int step, int score, int combo, float offset );
void ReportSongOver();
void ReportStyle(); // Report style, players, and names
void ReportNSSOnOff( int i ); // Report song selection screen on/off
void StartRequest( short position ); // Request a start; Block until granted.
RString GetServerName();
// SMOnline stuff
void SendSMOnline( );
bool Connect( const RString& addy, unsigned short port );
void PostStartUp( const RString& ServerIP );
void CloseConnection();
void DisplayStartupStatus(); // Notify user if connect attempt was successful or not.
int m_playerLife[NUM_PLAYERS]; // Life (used for sending to server)
void Update( float fDeltaTime );
bool useSMserver;
bool isSMOnline;
bool isSMOLoggedIn[NUM_PLAYERS];
vector<int> m_PlayerStatus;
int m_ActivePlayers;
vector<int> m_ActivePlayer;
vector<RString> m_PlayerNames;
// Used for ScreenNetEvaluation
vector<EndOfGame_PlayerData> m_EvalPlayerData;
// Used together:
bool ChangedScoreboard(int Column); // Returns true if scoreboard changed since function was last called.
RString m_Scoreboard[NUM_NSScoreBoardColumn];
// Used for chatting
void SendChat(const RString& message);
RString m_WaitingChat;
// Used for options
void ReportPlayerOptions();
// Used for song checking/changing
RString m_sMainTitle;
RString m_sArtist;
RString m_sSubTitle;
int m_iSelectMode;
void SelectUserSong();
RString m_sChatText;
PacketFunctions m_SMOnlinePacket;
StepManiaLanServer *LANserver;
int GetSMOnlineSalt();
RString MD5Hex( const RString &sInput );
void GetListOfLANServers( vector<NetServerInfo>& AllServers );
// Aldo: Please move this method to a new class, I didn't want to create new files because I don't know how to properly update the files for each platform.
// I preferred to misplace code rather than cause unneeded headaches to non-windows users, although it would be nice to have in the wiki which files to
// update when adding new files.
static unsigned long GetCurrentSMBuild( LoadingWindow* ld );
private:
#if !defined(WITHOUT_NETWORKING)
void ProcessInput();
SMOStepType TranslateStepType(int score);
void StartUp();
int m_playerID; // Currently unused, but need to stay
int m_step;
int m_score;
int m_combo;
int m_startupStatus; // Used to see if attempt was successful or not.
int m_iSalt;
bool m_scoreboardchange[NUM_NSScoreBoardColumn];
RString m_ServerName;
EzSockets *NetPlayerClient;
EzSockets *BroadcastReception;
vector<NetServerInfo> m_vAllLANServers;
int m_ServerVersion; // ServerVersion
PacketFunctions m_packet;
#endif
};
extern NetworkSyncManager *NSMAN;
#endif
/*
* (c) 2003-2004 Charles Lohr, Joshua Allen
* 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 NetworkSyncManager_H
#define NetworkSyncManager_H
#include "PlayerNumber.h"
#include "Difficulty.h"
#include <queue>
class LoadingWindow;
const int NETPROTOCOLVERSION=3;
const int NETMAXBUFFERSIZE=1020; //1024 - 4 bytes for EzSockets
const int NETNUMTAPSCORES=8;
// [SMLClientCommands name]
enum NSCommand
{
NSCPing = 0,
NSCPingR, // 1 [SMLC_PingR]
NSCHello, // 2 [SMLC_Hello]
NSCGSR, // 3 [SMLC_GameStart]
NSCGON, // 4 [SMLC_GameOver]
NSCGSU, // 5 [SMLC_GameStatusUpdate]
NSCSU, // 6 [SMLC_StyleUpdate]
NSCCM, // 7 [SMLC_Chat]
NSCRSG, // 8 [SMLC_RequestStart]
NSCUUL, // 9 [SMLC_Reserved1]
NSCSMS, // 10 [SMLC_MusicSelect]
NSCUPOpts, // 11 [SMLC_PlayerOpts]
NSCSMOnline, // 12 [SMLC_SMO]
NSCFormatted, // 13 [SMLC_RESERVED1]
NSCAttack, // 14 [SMLC_RESERVED2]
NUM_NS_COMMANDS
};
enum SMOStepType
{
SMOST_UNUSED = 0,
SMOST_HITMINE,
SMOST_AVOIDMINE,
SMOST_MISS,
SMOST_W5,
SMOST_W4,
SMOST_W3,
SMOST_W2,
SMOST_W1,
SMOST_LETGO,
SMOST_HELD
/*
,SMOST_CHECKPOINTMISS,
SMOST_CHECKPOINTHIT
*/
};
const NSCommand NSServerOffset = (NSCommand)128;
// TODO: Provide a Lua binding that gives access to this data. -aj
struct EndOfGame_PlayerData
{
int name;
int score;
int grade;
Difficulty difficulty;
int tapScores[NETNUMTAPSCORES]; //This will be a const soon enough
RString playerOptions;
};
enum NSScoreBoardColumn
{
NSSB_NAMES=0,
NSSB_COMBO,
NSSB_GRADE,
NUM_NSScoreBoardColumn,
NSScoreBoardColumn_Invalid
};
/** @brief A special foreach loop going through each NSScoreBoardColumn. */
#define FOREACH_NSScoreBoardColumn( sc ) FOREACH_ENUM( NSScoreBoardColumn, sc )
struct NetServerInfo
{
RString Name;
RString Address;
};
class EzSockets;
class StepManiaLanServer;
class PacketFunctions
{
public:
unsigned char Data[NETMAXBUFFERSIZE]; //Data
int Position; //Other info (Used for following functions)
int size; //When sending these pacs, Position should
//be used; NOT size.
//Commands used to operate on NetPackets
uint8_t Read1();
uint16_t Read2();
uint32_t Read4();
RString ReadNT();
void Write1( uint8_t Data );
void Write2( uint16_t Data );
void Write4( uint32_t Data );
void WriteNT( const RString& Data );
void ClearPacket();
};
/** @brief Uses ezsockets for primitive song syncing and score reporting. */
class NetworkSyncManager
{
public:
NetworkSyncManager( LoadingWindow *ld = nullptr );
~NetworkSyncManager();
// If "useSMserver" then send score to server
void ReportScore( int playerID, int step, int score, int combo, float offset );
void ReportSongOver();
void ReportStyle(); // Report style, players, and names
void ReportNSSOnOff( int i ); // Report song selection screen on/off
void StartRequest( short position ); // Request a start; Block until granted.
RString GetServerName();
// SMOnline stuff
void SendSMOnline( );
bool Connect( const RString& addy, unsigned short port );
void PostStartUp( const RString& ServerIP );
void CloseConnection();
void DisplayStartupStatus(); // Notify user if connect attempt was successful or not.
int m_playerLife[NUM_PLAYERS]; // Life (used for sending to server)
void Update( float fDeltaTime );
bool useSMserver;
bool isSMOnline;
bool isSMOLoggedIn[NUM_PLAYERS];
vector<int> m_PlayerStatus;
int m_ActivePlayers;
vector<int> m_ActivePlayer;
vector<RString> m_PlayerNames;
// Used for ScreenNetEvaluation
vector<EndOfGame_PlayerData> m_EvalPlayerData;
// Used together:
bool ChangedScoreboard(int Column); // Returns true if scoreboard changed since function was last called.
RString m_Scoreboard[NUM_NSScoreBoardColumn];
// Used for chatting
void SendChat(const RString& message);
RString m_WaitingChat;
// Used for options
void ReportPlayerOptions();
// Used for song checking/changing
RString m_sMainTitle;
RString m_sArtist;
RString m_sSubTitle;
int m_iSelectMode;
void SelectUserSong();
RString m_sChatText;
PacketFunctions m_SMOnlinePacket;
StepManiaLanServer *LANserver;
int GetSMOnlineSalt();
RString MD5Hex( const RString &sInput );
void GetListOfLANServers( vector<NetServerInfo>& AllServers );
// Aldo: Please move this method to a new class, I didn't want to create new files because I don't know how to properly update the files for each platform.
// I preferred to misplace code rather than cause unneeded headaches to non-windows users, although it would be nice to have in the wiki which files to
// update when adding new files.
static unsigned long GetCurrentSMBuild( LoadingWindow* ld );
private:
#if !defined(WITHOUT_NETWORKING)
void ProcessInput();
SMOStepType TranslateStepType(int score);
void StartUp();
int m_playerID; // Currently unused, but need to stay
int m_step;
int m_score;
int m_combo;
int m_startupStatus; // Used to see if attempt was successful or not.
int m_iSalt;
bool m_scoreboardchange[NUM_NSScoreBoardColumn];
RString m_ServerName;
EzSockets *NetPlayerClient;
EzSockets *BroadcastReception;
vector<NetServerInfo> m_vAllLANServers;
int m_ServerVersion; // ServerVersion
PacketFunctions m_packet;
#endif
};
extern NetworkSyncManager *NSMAN;
#endif
/*
* (c) 2003-2004 Charles Lohr, Joshua Allen
* 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.
*/
+374 -374
View File
@@ -1,374 +1,374 @@
#ifndef NOTE_DATA_H
#define NOTE_DATA_H
#include "NoteTypes.h"
#include <map>
#include <set>
#include <iterator>
/** @brief Act on each non empty row in the specific track. */
#define FOREACH_NONEMPTY_ROW_IN_TRACK( nd, track, row ) \
for( int row = -1; (nd).GetNextTapNoteRowForTrack(track,row); )
/** @brief Act on each non empty row in the specified track within the specified range. */
#define FOREACH_NONEMPTY_ROW_IN_TRACK_RANGE( nd, track, row, start, last ) \
for( int row = start-1; (nd).GetNextTapNoteRowForTrack(track,row) && row < (last); )
/** @brief Act on each non empty row in the specified track within the specified range,
going in reverse order. */
#define FOREACH_NONEMPTY_ROW_IN_TRACK_RANGE_REVERSE( nd, track, row, start, last ) \
for( int row = last; (nd).GetPrevTapNoteRowForTrack(track,row) && row >= (start); )
/** @brief Act on each non empty row for all of the tracks. */
#define FOREACH_NONEMPTY_ROW_ALL_TRACKS( nd, row ) \
for( int row = -1; (nd).GetNextTapNoteRowForAllTracks(row); )
/** @brief Act on each non empty row for all of the tracks within the specified range. */
#define FOREACH_NONEMPTY_ROW_ALL_TRACKS_RANGE( nd, row, start, last ) \
for( int row = start-1; (nd).GetNextTapNoteRowForAllTracks(row) && row < (last); )
/** @brief Holds data about the notes that the player is supposed to hit. */
class NoteData
{
public:
typedef map<int,TapNote> TrackMap;
typedef map<int,TapNote>::iterator iterator;
typedef map<int,TapNote>::const_iterator const_iterator;
typedef map<int,TapNote>::reverse_iterator reverse_iterator;
typedef map<int,TapNote>::const_reverse_iterator const_reverse_iterator;
NoteData(): m_TapNotes() {}
iterator begin( int iTrack ) { return m_TapNotes[iTrack].begin(); }
const_iterator begin( int iTrack ) const { return m_TapNotes[iTrack].begin(); }
reverse_iterator rbegin( int iTrack ) { return m_TapNotes[iTrack].rbegin(); }
const_reverse_iterator rbegin( int iTrack ) const { return m_TapNotes[iTrack].rbegin(); }
iterator end( int iTrack ) { return m_TapNotes[iTrack].end(); }
const_iterator end( int iTrack ) const { return m_TapNotes[iTrack].end(); }
reverse_iterator rend( int iTrack ) { return m_TapNotes[iTrack].rend(); }
const_reverse_iterator rend( int iTrack ) const { return m_TapNotes[iTrack].rend(); }
iterator lower_bound( int iTrack, int iRow ) { return m_TapNotes[iTrack].lower_bound( iRow ); }
const_iterator lower_bound( int iTrack, int iRow ) const { return m_TapNotes[iTrack].lower_bound( iRow ); }
iterator upper_bound( int iTrack, int iRow ) { return m_TapNotes[iTrack].upper_bound( iRow ); }
const_iterator upper_bound( int iTrack, int iRow ) const { return m_TapNotes[iTrack].upper_bound( iRow ); }
void swap( NoteData &nd ) { m_TapNotes.swap( nd.m_TapNotes ); }
// This is ugly to make it templated but I don't want to have to write the same class twice.
template<typename ND, typename iter, typename TN>
class _all_tracks_iterator
{
ND *m_pNoteData;
vector<iter> m_vBeginIters;
/* There isn't a "past the beginning" iterator so this is hard to make a true bidirectional iterator.
* Use the "past the end" iterator in place of the "past the beginning" iterator when in reverse. */
vector<iter> m_vCurrentIters;
vector<iter> m_vEndIters;
int m_iTrack;
bool m_bReverse;
void Find( bool bReverse );
public:
_all_tracks_iterator( ND &nd, int iStartRow, int iEndRow, bool bReverse, bool bInclusive );
_all_tracks_iterator( const _all_tracks_iterator &other );
_all_tracks_iterator &operator++(); // preincrement
_all_tracks_iterator operator++( int dummy ); // postincrement
//_all_tracks_iterator &operator--(); // predecrement
//_all_tracks_iterator operator--( int dummy ); // postdecrement
inline int Track() const { return m_iTrack; }
inline int Row() const { return m_vCurrentIters[m_iTrack]->first; }
inline bool IsAtEnd() const { return m_iTrack == -1; }
inline iter GetIter( int iTrack ) const { return m_vCurrentIters[iTrack]; }
inline TN &operator*() { DEBUG_ASSERT( !IsAtEnd() ); return m_vCurrentIters[m_iTrack]->second; }
inline TN *operator->() { DEBUG_ASSERT( !IsAtEnd() ); return &m_vCurrentIters[m_iTrack]->second; }
inline const TN &operator*() const { DEBUG_ASSERT( !IsAtEnd() ); return m_vCurrentIters[m_iTrack]->second; }
inline const TN *operator->() const { DEBUG_ASSERT( !IsAtEnd() ); return &m_vCurrentIters[m_iTrack]->second; }
};
typedef _all_tracks_iterator<NoteData, NoteData::iterator, TapNote> all_tracks_iterator;
typedef _all_tracks_iterator<const NoteData, NoteData::const_iterator, const TapNote> all_tracks_const_iterator;
typedef all_tracks_iterator all_tracks_reverse_iterator;
typedef all_tracks_const_iterator all_tracks_const_reverse_iterator;
private:
// There's no point in inserting empty notes into the map.
// Any blank space in the map is defined to be empty.
vector<TrackMap> m_TapNotes;
/**
* @brief Determine whether this note is for Player 1 or Player 2.
* @param track the track/column the note is in.
* @param tn the note in question. Required for routine mode.
* @return true if it's for player 1, false for player 2. */
bool IsPlayer1(const int track, const TapNote &tn) const;
/**
* @brief Determine if the note in question should be counted as a tap.
* @param tn the note in question.
* @param row the row it lives in.
* @return true if it's a tap, false otherwise. */
bool IsTap(const TapNote &tn, const int row) const;
/**
* @brief Determine if the note in question should be counted as a mine.
* @param tn the note in question.
* @param row the row it lives in.
* @return true if it's a mine, false otherwise. */
bool IsMine(const TapNote &tn, const int row) const;
/**
* @brief Determine if the note in question should be counted as a lift.
* @param tn the note in question.
* @param row the row it lives in.
* @return true if it's a lift, false otherwise. */
bool IsLift(const TapNote &tn, const int row) const;
/**
* @brief Determine if the note in question should be counted as a fake.
* @param tn the note in question.
* @param row the row it lives in.
* @return true if it's a fake, false otherwise. */
bool IsFake(const TapNote &tn, const int row) const;
pair<int, int> GetNumRowsWithSimultaneousTapsTwoPlayer(int minTaps = 2,
int startRow = 0,
int endRow = MAX_NOTE_ROW) const;
public:
void Init();
int GetNumTracks() const { return m_TapNotes.size(); }
void SetNumTracks( int iNewNumTracks );
bool IsComposite() const;
bool operator==( const NoteData &nd ) const { return m_TapNotes == nd.m_TapNotes; }
bool operator!=( const NoteData &nd ) const { return m_TapNotes != nd.m_TapNotes; }
/* Return the note at the given track and row. Row may be out of
* range; pretend the song goes on with TAP_EMPTYs indefinitely. */
inline const TapNote &GetTapNote( unsigned track, int row ) const
{
const TrackMap &mapTrack = m_TapNotes[track];
TrackMap::const_iterator iter = mapTrack.find( row );
if( iter != mapTrack.end() )
return iter->second;
else
return TAP_EMPTY;
}
inline iterator FindTapNote( unsigned iTrack, int iRow ) { return m_TapNotes[iTrack].find( iRow ); }
inline const_iterator FindTapNote( unsigned iTrack, int iRow ) const { return m_TapNotes[iTrack].find( iRow ); }
void RemoveTapNote( unsigned iTrack, iterator it ) { m_TapNotes[iTrack].erase( it ); }
/**
* @brief Return an iterator range for [rowBegin,rowEnd).
*
* This can be used to efficiently iterate trackwise over a range of notes.
* It's like FOREACH_NONEMPTY_ROW_IN_TRACK_RANGE, except it only requires
* two map searches (iterating is constant time), but the iterators will
* become invalid if the notes they represent disappear, so you need to
* pay attention to how you modify the data.
* @param iTrack the column to use.
* @param iStartRow the starting point.
* @param iEndRow the ending point.
* @param begin the eventual beginning point of the range.
* @param end the eventual end point of the range. */
void GetTapNoteRange(int iTrack, int iStartRow, int iEndRow,
TrackMap::const_iterator &begin, TrackMap::const_iterator &end ) const;
/**
* @brief Return a constant iterator range for [rowBegin,rowEnd).
* @param iTrack the column to use.
* @param iStartRow the starting point.
* @param iEndRow the ending point.
* @param begin the eventual beginning point of the range.
* @param end the eventual end point of the range. */
void GetTapNoteRange( int iTrack, int iStartRow, int iEndRow, TrackMap::iterator &begin, TrackMap::iterator &end );
all_tracks_iterator GetTapNoteRangeAllTracks( int iStartRow, int iEndRow, bool bInclusive = false )
{
return all_tracks_iterator( *this, iStartRow, iEndRow, false, bInclusive );
}
all_tracks_const_iterator GetTapNoteRangeAllTracks( int iStartRow, int iEndRow, bool bInclusive = false ) const
{
return all_tracks_const_iterator( *this, iStartRow, iEndRow, false, bInclusive );
}
all_tracks_reverse_iterator GetTapNoteRangeAllTracksReverse( int iStartRow, int iEndRow, bool bInclusive = false )
{
return all_tracks_iterator(*this, iStartRow, iEndRow, true, bInclusive );
}
all_tracks_const_reverse_iterator GetTapNoteRangeAllTracksReverse( int iStartRow, int iEndRow, bool bInclusive = false ) const
{
return all_tracks_const_iterator(*this, iStartRow, iEndRow, true, bInclusive );
}
/* Return an iterator range include iStartRow to iEndRow. Extend the range to include
* hold notes overlapping the boundary. */
void GetTapNoteRangeInclusive(int iTrack, int iStartRow, int iEndRow,
TrackMap::const_iterator &begin, TrackMap::const_iterator &end, bool bIncludeAdjacent=false ) const;
void GetTapNoteRangeInclusive(int iTrack, int iStartRow, int iEndRow,
TrackMap::iterator &begin, TrackMap::iterator &end, bool bIncludeAdjacent=false );
/* Return an iterator range include iStartRow to iEndRow. Shrink the range to exclude
* hold notes overlapping the boundary. */
void GetTapNoteRangeExclusive(int iTrack, int iStartRow, int iEndRow,
TrackMap::const_iterator &begin, TrackMap::const_iterator &end ) const;
void GetTapNoteRangeExclusive(int iTrack, int iStartRow, int iEndRow,
TrackMap::iterator &begin, TrackMap::iterator &end );
/* Returns the row of the first TapNote on the track that has a row greater than rowInOut. */
bool GetNextTapNoteRowForTrack( int track, int &rowInOut ) const;
bool GetNextTapNoteRowForAllTracks( int &rowInOut ) const;
bool GetPrevTapNoteRowForTrack( int track, int &rowInOut ) const;
bool GetPrevTapNoteRowForAllTracks( int &rowInOut ) const;
void MoveTapNoteTrack( int dest, int src );
void SetTapNote( int track, int row, const TapNote& tn );
/**
* @brief Add a hold note, merging other overlapping holds and destroying
* tap notes underneath.
* @param iTrack the column to work with.
* @param iStartRow the starting row.
* @param iEndRow the ending row.
* @param tn the tap note. */
void AddHoldNote(int iTrack,
int iStartRow,
int iEndRow,
TapNote tn );
void ClearRangeForTrack( int rowBegin, int rowEnd, int iTrack );
void ClearRange( int rowBegin, int rowEnd );
void ClearAll();
void CopyRange( const NoteData& from, int rowFromBegin, int rowFromEnd, int rowToBegin = 0 );
void CopyAll( const NoteData& from );
bool IsRowEmpty( int row ) const;
bool IsRangeEmpty( int track, int rowBegin, int rowEnd ) const;
int GetNumTapNonEmptyTracks( int row ) const;
void GetTapNonEmptyTracks( int row, set<int>& addTo ) const;
bool GetTapFirstNonEmptyTrack( int row, int &iNonEmptyTrackOut ) const; // return false if no non-empty tracks at row
bool GetTapFirstEmptyTrack( int row, int &iEmptyTrackOut ) const; // return false if no non-empty tracks at row
bool GetTapLastEmptyTrack( int row, int &iEmptyTrackOut ) const; // return false if no empty tracks at row
int GetNumTracksWithTap( int row ) const;
int GetNumTracksWithTapOrHoldHead( int row ) const;
int GetFirstTrackWithTap( int row ) const;
int GetFirstTrackWithTapOrHoldHead( int row ) const;
int GetLastTrackWithTapOrHoldHead( int row ) const;
inline bool IsThereATapAtRow( int row ) const { return GetFirstTrackWithTap( row ) != -1; }
inline bool IsThereATapOrHoldHeadAtRow( int row ) const { return GetFirstTrackWithTapOrHoldHead( row ) != -1; }
void GetTracksHeldAtRow( int row, set<int>& addTo );
int GetNumTracksHeldAtRow( int row );
bool IsHoldNoteAtRow( int iTrack, int iRow, int *pHeadRow = NULL ) const;
bool IsHoldHeadOrBodyAtRow( int iTrack, int iRow, int *pHeadRow ) const;
// statistics
bool IsEmpty() const;
bool IsTrackEmpty( int iTrack ) const { return m_TapNotes[iTrack].empty(); }
int GetFirstRow() const; // return the beat number of the first note
int GetLastRow() const; // return the beat number of the last note
float GetFirstBeat() const { return NoteRowToBeat( GetFirstRow() ); }
float GetLastBeat() const { return NoteRowToBeat( GetLastRow() ); }
int GetNumTapNotes( int iStartIndex = 0, int iEndIndex = MAX_NOTE_ROW ) const;
int GetNumTapNotesInRow( int iRow ) const;
int GetNumMines( int iStartIndex = 0, int iEndIndex = MAX_NOTE_ROW ) const;
int GetNumRowsWithTap( int iStartIndex = 0, int iEndIndex = MAX_NOTE_ROW ) const;
int GetNumRowsWithTapOrHoldHead( int iStartIndex = 0, int iEndIndex = MAX_NOTE_ROW ) const;
/* Optimization: for the default of start to end, use the second (faster). XXX: Second what? -- Steve */
int GetNumHoldNotes( int iStartIndex = 0, int iEndIndex = MAX_NOTE_ROW ) const;
int GetNumRolls( int iStartIndex = 0, int iEndIndex = MAX_NOTE_ROW ) const;
// Count rows that contain iMinTaps or more taps.
int GetNumRowsWithSimultaneousTaps( int iMinTaps, int iStartIndex = 0, int iEndIndex = MAX_NOTE_ROW ) const;
int GetNumJumps( int iStartIndex = 0, int iEndIndex = MAX_NOTE_ROW ) const
{
return GetNumRowsWithSimultaneousTaps( 2, iStartIndex, iEndIndex );
}
// This row needs at least iMinSimultaneousPresses either tapped or held.
bool RowNeedsAtLeastSimultaneousPresses( int iMinSimultaneousPresses, int row ) const;
bool RowNeedsHands( int row ) const { return RowNeedsAtLeastSimultaneousPresses(3,row); }
// Count rows that need iMinSimultaneousPresses either tapped or held.
int GetNumRowsWithSimultaneousPresses( int iMinSimultaneousPresses, int iStartIndex = 0, int iEndIndex = MAX_NOTE_ROW ) const;
int GetNumHands( int iStartIndex = 0, int iEndIndex = MAX_NOTE_ROW ) const
{
return GetNumRowsWithSimultaneousPresses( 3, iStartIndex, iEndIndex );
}
int GetNumQuads( int iStartIndex = 0, int iEndIndex = MAX_NOTE_ROW ) const
{
return GetNumRowsWithSimultaneousPresses( 4, iStartIndex, iEndIndex );
}
// and the other notetypes
int GetNumLifts( int iStartIndex = 0, int iEndIndex = MAX_NOTE_ROW ) const;
int GetNumFakes( int iStartIndex = 0, int iEndIndex = MAX_NOTE_ROW ) const;
// the couple/routine style variants of the above.
pair<int, int> GetNumTapNotesTwoPlayer(int startRow = 0,
int endRow = MAX_NOTE_ROW) const;
pair<int, int> GetNumJumpsTwoPlayer(int startRow = 0,
int endRow = MAX_NOTE_ROW) const;
pair<int, int> GetNumHandsTwoPlayer(int startRow = 0,
int endRow = MAX_NOTE_ROW) const;
pair<int, int> GetNumQuadsTwoPlayer(int startRow = 0,
int endRow = MAX_NOTE_ROW) const;
pair<int, int> GetNumHoldNotesTwoPlayer(int startRow = 0,
int endRow = MAX_NOTE_ROW) const;
pair<int, int> GetNumMinesTwoPlayer(int startRow = 0,
int endRow = MAX_NOTE_ROW) const;
pair<int, int> GetNumRollsTwoPlayer(int startRow = 0,
int endRow = MAX_NOTE_ROW) const;
pair<int, int> GetNumLiftsTwoPlayer(int startRow = 0,
int endRow = MAX_NOTE_ROW) const;
pair<int, int> GetNumFakesTwoPlayer(int startRow = 0,
int endRow = MAX_NOTE_ROW) const;
// Transformations
void LoadTransformed(const NoteData& original,
int iNewNumTracks,
const int iOriginalTrackToTakeFrom[] ); // -1 for iOriginalTracksToTakeFrom means no track
// XML
XNode* CreateNode() const;
void LoadFromNode( const XNode* pNode );
};
/** @brief Allow a quick way to swap notedata. */
namespace std
{
template<> inline void swap<NoteData>( NoteData &nd1, NoteData &nd2 ) { nd1.swap( nd2 ); }
}
#endif
/*
* (c) 2001-2004 Chris Danford, Glenn Maynard
* All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* 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 NOTE_DATA_H
#define NOTE_DATA_H
#include "NoteTypes.h"
#include <map>
#include <set>
#include <iterator>
/** @brief Act on each non empty row in the specific track. */
#define FOREACH_NONEMPTY_ROW_IN_TRACK( nd, track, row ) \
for( int row = -1; (nd).GetNextTapNoteRowForTrack(track,row); )
/** @brief Act on each non empty row in the specified track within the specified range. */
#define FOREACH_NONEMPTY_ROW_IN_TRACK_RANGE( nd, track, row, start, last ) \
for( int row = start-1; (nd).GetNextTapNoteRowForTrack(track,row) && row < (last); )
/** @brief Act on each non empty row in the specified track within the specified range,
going in reverse order. */
#define FOREACH_NONEMPTY_ROW_IN_TRACK_RANGE_REVERSE( nd, track, row, start, last ) \
for( int row = last; (nd).GetPrevTapNoteRowForTrack(track,row) && row >= (start); )
/** @brief Act on each non empty row for all of the tracks. */
#define FOREACH_NONEMPTY_ROW_ALL_TRACKS( nd, row ) \
for( int row = -1; (nd).GetNextTapNoteRowForAllTracks(row); )
/** @brief Act on each non empty row for all of the tracks within the specified range. */
#define FOREACH_NONEMPTY_ROW_ALL_TRACKS_RANGE( nd, row, start, last ) \
for( int row = start-1; (nd).GetNextTapNoteRowForAllTracks(row) && row < (last); )
/** @brief Holds data about the notes that the player is supposed to hit. */
class NoteData
{
public:
typedef map<int,TapNote> TrackMap;
typedef map<int,TapNote>::iterator iterator;
typedef map<int,TapNote>::const_iterator const_iterator;
typedef map<int,TapNote>::reverse_iterator reverse_iterator;
typedef map<int,TapNote>::const_reverse_iterator const_reverse_iterator;
NoteData(): m_TapNotes() {}
iterator begin( int iTrack ) { return m_TapNotes[iTrack].begin(); }
const_iterator begin( int iTrack ) const { return m_TapNotes[iTrack].begin(); }
reverse_iterator rbegin( int iTrack ) { return m_TapNotes[iTrack].rbegin(); }
const_reverse_iterator rbegin( int iTrack ) const { return m_TapNotes[iTrack].rbegin(); }
iterator end( int iTrack ) { return m_TapNotes[iTrack].end(); }
const_iterator end( int iTrack ) const { return m_TapNotes[iTrack].end(); }
reverse_iterator rend( int iTrack ) { return m_TapNotes[iTrack].rend(); }
const_reverse_iterator rend( int iTrack ) const { return m_TapNotes[iTrack].rend(); }
iterator lower_bound( int iTrack, int iRow ) { return m_TapNotes[iTrack].lower_bound( iRow ); }
const_iterator lower_bound( int iTrack, int iRow ) const { return m_TapNotes[iTrack].lower_bound( iRow ); }
iterator upper_bound( int iTrack, int iRow ) { return m_TapNotes[iTrack].upper_bound( iRow ); }
const_iterator upper_bound( int iTrack, int iRow ) const { return m_TapNotes[iTrack].upper_bound( iRow ); }
void swap( NoteData &nd ) { m_TapNotes.swap( nd.m_TapNotes ); }
// This is ugly to make it templated but I don't want to have to write the same class twice.
template<typename ND, typename iter, typename TN>
class _all_tracks_iterator
{
ND *m_pNoteData;
vector<iter> m_vBeginIters;
/* There isn't a "past the beginning" iterator so this is hard to make a true bidirectional iterator.
* Use the "past the end" iterator in place of the "past the beginning" iterator when in reverse. */
vector<iter> m_vCurrentIters;
vector<iter> m_vEndIters;
int m_iTrack;
bool m_bReverse;
void Find( bool bReverse );
public:
_all_tracks_iterator( ND &nd, int iStartRow, int iEndRow, bool bReverse, bool bInclusive );
_all_tracks_iterator( const _all_tracks_iterator &other );
_all_tracks_iterator &operator++(); // preincrement
_all_tracks_iterator operator++( int dummy ); // postincrement
//_all_tracks_iterator &operator--(); // predecrement
//_all_tracks_iterator operator--( int dummy ); // postdecrement
inline int Track() const { return m_iTrack; }
inline int Row() const { return m_vCurrentIters[m_iTrack]->first; }
inline bool IsAtEnd() const { return m_iTrack == -1; }
inline iter GetIter( int iTrack ) const { return m_vCurrentIters[iTrack]; }
inline TN &operator*() { DEBUG_ASSERT( !IsAtEnd() ); return m_vCurrentIters[m_iTrack]->second; }
inline TN *operator->() { DEBUG_ASSERT( !IsAtEnd() ); return &m_vCurrentIters[m_iTrack]->second; }
inline const TN &operator*() const { DEBUG_ASSERT( !IsAtEnd() ); return m_vCurrentIters[m_iTrack]->second; }
inline const TN *operator->() const { DEBUG_ASSERT( !IsAtEnd() ); return &m_vCurrentIters[m_iTrack]->second; }
};
typedef _all_tracks_iterator<NoteData, NoteData::iterator, TapNote> all_tracks_iterator;
typedef _all_tracks_iterator<const NoteData, NoteData::const_iterator, const TapNote> all_tracks_const_iterator;
typedef all_tracks_iterator all_tracks_reverse_iterator;
typedef all_tracks_const_iterator all_tracks_const_reverse_iterator;
private:
// There's no point in inserting empty notes into the map.
// Any blank space in the map is defined to be empty.
vector<TrackMap> m_TapNotes;
/**
* @brief Determine whether this note is for Player 1 or Player 2.
* @param track the track/column the note is in.
* @param tn the note in question. Required for routine mode.
* @return true if it's for player 1, false for player 2. */
bool IsPlayer1(const int track, const TapNote &tn) const;
/**
* @brief Determine if the note in question should be counted as a tap.
* @param tn the note in question.
* @param row the row it lives in.
* @return true if it's a tap, false otherwise. */
bool IsTap(const TapNote &tn, const int row) const;
/**
* @brief Determine if the note in question should be counted as a mine.
* @param tn the note in question.
* @param row the row it lives in.
* @return true if it's a mine, false otherwise. */
bool IsMine(const TapNote &tn, const int row) const;
/**
* @brief Determine if the note in question should be counted as a lift.
* @param tn the note in question.
* @param row the row it lives in.
* @return true if it's a lift, false otherwise. */
bool IsLift(const TapNote &tn, const int row) const;
/**
* @brief Determine if the note in question should be counted as a fake.
* @param tn the note in question.
* @param row the row it lives in.
* @return true if it's a fake, false otherwise. */
bool IsFake(const TapNote &tn, const int row) const;
pair<int, int> GetNumRowsWithSimultaneousTapsTwoPlayer(int minTaps = 2,
int startRow = 0,
int endRow = MAX_NOTE_ROW) const;
public:
void Init();
int GetNumTracks() const { return m_TapNotes.size(); }
void SetNumTracks( int iNewNumTracks );
bool IsComposite() const;
bool operator==( const NoteData &nd ) const { return m_TapNotes == nd.m_TapNotes; }
bool operator!=( const NoteData &nd ) const { return m_TapNotes != nd.m_TapNotes; }
/* Return the note at the given track and row. Row may be out of
* range; pretend the song goes on with TAP_EMPTYs indefinitely. */
inline const TapNote &GetTapNote( unsigned track, int row ) const
{
const TrackMap &mapTrack = m_TapNotes[track];
TrackMap::const_iterator iter = mapTrack.find( row );
if( iter != mapTrack.end() )
return iter->second;
else
return TAP_EMPTY;
}
inline iterator FindTapNote( unsigned iTrack, int iRow ) { return m_TapNotes[iTrack].find( iRow ); }
inline const_iterator FindTapNote( unsigned iTrack, int iRow ) const { return m_TapNotes[iTrack].find( iRow ); }
void RemoveTapNote( unsigned iTrack, iterator it ) { m_TapNotes[iTrack].erase( it ); }
/**
* @brief Return an iterator range for [rowBegin,rowEnd).
*
* This can be used to efficiently iterate trackwise over a range of notes.
* It's like FOREACH_NONEMPTY_ROW_IN_TRACK_RANGE, except it only requires
* two map searches (iterating is constant time), but the iterators will
* become invalid if the notes they represent disappear, so you need to
* pay attention to how you modify the data.
* @param iTrack the column to use.
* @param iStartRow the starting point.
* @param iEndRow the ending point.
* @param begin the eventual beginning point of the range.
* @param end the eventual end point of the range. */
void GetTapNoteRange(int iTrack, int iStartRow, int iEndRow,
TrackMap::const_iterator &begin, TrackMap::const_iterator &end ) const;
/**
* @brief Return a constant iterator range for [rowBegin,rowEnd).
* @param iTrack the column to use.
* @param iStartRow the starting point.
* @param iEndRow the ending point.
* @param begin the eventual beginning point of the range.
* @param end the eventual end point of the range. */
void GetTapNoteRange( int iTrack, int iStartRow, int iEndRow, TrackMap::iterator &begin, TrackMap::iterator &end );
all_tracks_iterator GetTapNoteRangeAllTracks( int iStartRow, int iEndRow, bool bInclusive = false )
{
return all_tracks_iterator( *this, iStartRow, iEndRow, false, bInclusive );
}
all_tracks_const_iterator GetTapNoteRangeAllTracks( int iStartRow, int iEndRow, bool bInclusive = false ) const
{
return all_tracks_const_iterator( *this, iStartRow, iEndRow, false, bInclusive );
}
all_tracks_reverse_iterator GetTapNoteRangeAllTracksReverse( int iStartRow, int iEndRow, bool bInclusive = false )
{
return all_tracks_iterator(*this, iStartRow, iEndRow, true, bInclusive );
}
all_tracks_const_reverse_iterator GetTapNoteRangeAllTracksReverse( int iStartRow, int iEndRow, bool bInclusive = false ) const
{
return all_tracks_const_iterator(*this, iStartRow, iEndRow, true, bInclusive );
}
/* Return an iterator range include iStartRow to iEndRow. Extend the range to include
* hold notes overlapping the boundary. */
void GetTapNoteRangeInclusive(int iTrack, int iStartRow, int iEndRow,
TrackMap::const_iterator &begin, TrackMap::const_iterator &end, bool bIncludeAdjacent=false ) const;
void GetTapNoteRangeInclusive(int iTrack, int iStartRow, int iEndRow,
TrackMap::iterator &begin, TrackMap::iterator &end, bool bIncludeAdjacent=false );
/* Return an iterator range include iStartRow to iEndRow. Shrink the range to exclude
* hold notes overlapping the boundary. */
void GetTapNoteRangeExclusive(int iTrack, int iStartRow, int iEndRow,
TrackMap::const_iterator &begin, TrackMap::const_iterator &end ) const;
void GetTapNoteRangeExclusive(int iTrack, int iStartRow, int iEndRow,
TrackMap::iterator &begin, TrackMap::iterator &end );
/* Returns the row of the first TapNote on the track that has a row greater than rowInOut. */
bool GetNextTapNoteRowForTrack( int track, int &rowInOut ) const;
bool GetNextTapNoteRowForAllTracks( int &rowInOut ) const;
bool GetPrevTapNoteRowForTrack( int track, int &rowInOut ) const;
bool GetPrevTapNoteRowForAllTracks( int &rowInOut ) const;
void MoveTapNoteTrack( int dest, int src );
void SetTapNote( int track, int row, const TapNote& tn );
/**
* @brief Add a hold note, merging other overlapping holds and destroying
* tap notes underneath.
* @param iTrack the column to work with.
* @param iStartRow the starting row.
* @param iEndRow the ending row.
* @param tn the tap note. */
void AddHoldNote(int iTrack,
int iStartRow,
int iEndRow,
TapNote tn );
void ClearRangeForTrack( int rowBegin, int rowEnd, int iTrack );
void ClearRange( int rowBegin, int rowEnd );
void ClearAll();
void CopyRange( const NoteData& from, int rowFromBegin, int rowFromEnd, int rowToBegin = 0 );
void CopyAll( const NoteData& from );
bool IsRowEmpty( int row ) const;
bool IsRangeEmpty( int track, int rowBegin, int rowEnd ) const;
int GetNumTapNonEmptyTracks( int row ) const;
void GetTapNonEmptyTracks( int row, set<int>& addTo ) const;
bool GetTapFirstNonEmptyTrack( int row, int &iNonEmptyTrackOut ) const; // return false if no non-empty tracks at row
bool GetTapFirstEmptyTrack( int row, int &iEmptyTrackOut ) const; // return false if no non-empty tracks at row
bool GetTapLastEmptyTrack( int row, int &iEmptyTrackOut ) const; // return false if no empty tracks at row
int GetNumTracksWithTap( int row ) const;
int GetNumTracksWithTapOrHoldHead( int row ) const;
int GetFirstTrackWithTap( int row ) const;
int GetFirstTrackWithTapOrHoldHead( int row ) const;
int GetLastTrackWithTapOrHoldHead( int row ) const;
inline bool IsThereATapAtRow( int row ) const { return GetFirstTrackWithTap( row ) != -1; }
inline bool IsThereATapOrHoldHeadAtRow( int row ) const { return GetFirstTrackWithTapOrHoldHead( row ) != -1; }
void GetTracksHeldAtRow( int row, set<int>& addTo );
int GetNumTracksHeldAtRow( int row );
bool IsHoldNoteAtRow( int iTrack, int iRow, int *pHeadRow = nullptr ) const;
bool IsHoldHeadOrBodyAtRow( int iTrack, int iRow, int *pHeadRow ) const;
// statistics
bool IsEmpty() const;
bool IsTrackEmpty( int iTrack ) const { return m_TapNotes[iTrack].empty(); }
int GetFirstRow() const; // return the beat number of the first note
int GetLastRow() const; // return the beat number of the last note
float GetFirstBeat() const { return NoteRowToBeat( GetFirstRow() ); }
float GetLastBeat() const { return NoteRowToBeat( GetLastRow() ); }
int GetNumTapNotes( int iStartIndex = 0, int iEndIndex = MAX_NOTE_ROW ) const;
int GetNumTapNotesInRow( int iRow ) const;
int GetNumMines( int iStartIndex = 0, int iEndIndex = MAX_NOTE_ROW ) const;
int GetNumRowsWithTap( int iStartIndex = 0, int iEndIndex = MAX_NOTE_ROW ) const;
int GetNumRowsWithTapOrHoldHead( int iStartIndex = 0, int iEndIndex = MAX_NOTE_ROW ) const;
/* Optimization: for the default of start to end, use the second (faster). XXX: Second what? -- Steve */
int GetNumHoldNotes( int iStartIndex = 0, int iEndIndex = MAX_NOTE_ROW ) const;
int GetNumRolls( int iStartIndex = 0, int iEndIndex = MAX_NOTE_ROW ) const;
// Count rows that contain iMinTaps or more taps.
int GetNumRowsWithSimultaneousTaps( int iMinTaps, int iStartIndex = 0, int iEndIndex = MAX_NOTE_ROW ) const;
int GetNumJumps( int iStartIndex = 0, int iEndIndex = MAX_NOTE_ROW ) const
{
return GetNumRowsWithSimultaneousTaps( 2, iStartIndex, iEndIndex );
}
// This row needs at least iMinSimultaneousPresses either tapped or held.
bool RowNeedsAtLeastSimultaneousPresses( int iMinSimultaneousPresses, int row ) const;
bool RowNeedsHands( int row ) const { return RowNeedsAtLeastSimultaneousPresses(3,row); }
// Count rows that need iMinSimultaneousPresses either tapped or held.
int GetNumRowsWithSimultaneousPresses( int iMinSimultaneousPresses, int iStartIndex = 0, int iEndIndex = MAX_NOTE_ROW ) const;
int GetNumHands( int iStartIndex = 0, int iEndIndex = MAX_NOTE_ROW ) const
{
return GetNumRowsWithSimultaneousPresses( 3, iStartIndex, iEndIndex );
}
int GetNumQuads( int iStartIndex = 0, int iEndIndex = MAX_NOTE_ROW ) const
{
return GetNumRowsWithSimultaneousPresses( 4, iStartIndex, iEndIndex );
}
// and the other notetypes
int GetNumLifts( int iStartIndex = 0, int iEndIndex = MAX_NOTE_ROW ) const;
int GetNumFakes( int iStartIndex = 0, int iEndIndex = MAX_NOTE_ROW ) const;
// the couple/routine style variants of the above.
pair<int, int> GetNumTapNotesTwoPlayer(int startRow = 0,
int endRow = MAX_NOTE_ROW) const;
pair<int, int> GetNumJumpsTwoPlayer(int startRow = 0,
int endRow = MAX_NOTE_ROW) const;
pair<int, int> GetNumHandsTwoPlayer(int startRow = 0,
int endRow = MAX_NOTE_ROW) const;
pair<int, int> GetNumQuadsTwoPlayer(int startRow = 0,
int endRow = MAX_NOTE_ROW) const;
pair<int, int> GetNumHoldNotesTwoPlayer(int startRow = 0,
int endRow = MAX_NOTE_ROW) const;
pair<int, int> GetNumMinesTwoPlayer(int startRow = 0,
int endRow = MAX_NOTE_ROW) const;
pair<int, int> GetNumRollsTwoPlayer(int startRow = 0,
int endRow = MAX_NOTE_ROW) const;
pair<int, int> GetNumLiftsTwoPlayer(int startRow = 0,
int endRow = MAX_NOTE_ROW) const;
pair<int, int> GetNumFakesTwoPlayer(int startRow = 0,
int endRow = MAX_NOTE_ROW) const;
// Transformations
void LoadTransformed(const NoteData& original,
int iNewNumTracks,
const int iOriginalTrackToTakeFrom[] ); // -1 for iOriginalTracksToTakeFrom means no track
// XML
XNode* CreateNode() const;
void LoadFromNode( const XNode* pNode );
};
/** @brief Allow a quick way to swap notedata. */
namespace std
{
template<> inline void swap<NoteData>( NoteData &nd1, NoteData &nd2 ) { nd1.swap( nd2 ); }
}
#endif
/*
* (c) 2001-2004 Chris Danford, Glenn Maynard
* All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* 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 -4
View File
@@ -119,7 +119,7 @@ struct NoteResource
NoteResource( const NoteSkinAndPath &nsap ): m_nsap(nsap)
{
m_iRefCount = 0;
m_pActor = NULL;
m_pActor = nullptr;
}
~NoteResource()
@@ -173,7 +173,7 @@ static void DeleteNoteResource( NoteResource *pRes )
NoteColorActor::NoteColorActor()
{
m_p = NULL;
m_p = nullptr;
}
NoteColorActor::~NoteColorActor()
@@ -197,7 +197,7 @@ Actor *NoteColorActor::Get()
NoteColorSprite::NoteColorSprite()
{
m_p = NULL;
m_p = nullptr;
}
NoteColorSprite::~NoteColorSprite()
@@ -750,7 +750,7 @@ void NoteDisplay::DrawTap(const TapNote& tn, int iCol, float fBeat,
float fDrawDistanceBeforeTargetsPixels,
float fFadeInPercentOfDrawFar)
{
Actor* pActor = NULL;
Actor* pActor = nullptr;
NotePart part = NotePart_Tap;
/*
if( tn.source == TapNote::addition )
+3 -3
View File
@@ -38,8 +38,8 @@ static ThemeMetric1D<RString> ROUTINE_NOTESKIN( "NoteField", RoutineNoteSkinName
NoteField::NoteField()
{
m_pNoteData = NULL;
m_pCurDisplay = NULL;
m_pNoteData = nullptr;
m_pCurDisplay = nullptr;
m_textMeasureNumber.LoadFromFont( THEME->GetPathF("NoteField","MeasureNumber") );
m_textMeasureNumber.SetZoom( 1.0f );
@@ -77,7 +77,7 @@ void NoteField::Unload()
it != m_NoteDisplays.end(); ++it )
delete it->second;
m_NoteDisplays.clear();
m_pCurDisplay = NULL;
m_pCurDisplay = nullptr;
memset( m_pDisplays, 0, sizeof(m_pDisplays) );
}
+2 -2
View File
@@ -18,7 +18,7 @@
#include "SpecialFiles.h"
/** @brief Have the NoteSkinManager available throughout the program. */
NoteSkinManager* NOTESKIN = NULL;
NoteSkinManager* NOTESKIN = nullptr;
const RString GAME_COMMON_NOTESKIN_NAME = "common";
const RString GAME_BASE_NOTESKIN_NAME = "default";
@@ -47,7 +47,7 @@ namespace
NoteSkinManager::NoteSkinManager()
{
m_pCurGame = NULL;
m_pCurGame = nullptr;
m_PlayerNumber = PlayerNumber_Invalid;
m_GameController = GameController_Invalid;
+95 -94
View File
@@ -1,94 +1,95 @@
#ifndef NOTE_SKIN_MANAGER_H
#define NOTE_SKIN_MANAGER_H
#include "Actor.h"
#include "RageTypes.h"
#include "PlayerNumber.h"
#include "GameInput.h"
#include "IniFile.h"
class Game;
struct NoteSkinData;
/** @brief Loads note skins. */
class NoteSkinManager
{
public:
NoteSkinManager();
~NoteSkinManager();
void RefreshNoteSkinData( const Game* game );
void GetNoteSkinNames( const Game* game, vector<RString> &AddTo );
void GetNoteSkinNames( vector<RString> &AddTo ); // looks up current const Game* in GAMESTATE
bool DoesNoteSkinExist( const RString &sNoteSkin ); // looks up current const Game* in GAMESTATE
bool DoNoteSkinsExistForGame( const Game *pGame );
void SetCurrentNoteSkin( const RString &sNoteSkin ) { m_sCurrentNoteSkin = sNoteSkin; }
const RString &GetCurrentNoteSkin() { return m_sCurrentNoteSkin; }
void SetPlayerNumber( PlayerNumber pn ) { m_PlayerNumber = pn; }
void SetGameController( GameController gc ) { m_GameController = gc; }
RString GetPath( const RString &sButtonName, const RString &sElement );
bool PushActorTemplate( Lua *L, const RString &sButton, const RString &sElement, bool bSpriteOnly );
Actor *LoadActor( const RString &sButton, const RString &sElement, Actor *pParent = NULL, bool bSpriteOnly = false );
RString GetMetric( const RString &sButtonName, const RString &sValue );
int GetMetricI( const RString &sButtonName, const RString &sValueName );
float GetMetricF( const RString &sButtonName, const RString &sValueName );
bool GetMetricB( const RString &sButtonName, const RString &sValueName );
apActorCommands GetMetricA( const RString &sButtonName, const RString &sValueName );
// Lua
void PushSelf( lua_State *L );
protected:
RString GetPathFromDirAndFile( const RString &sDir, const RString &sFileName );
void GetAllNoteSkinNamesForGame( const Game *pGame, vector<RString> &AddTo );
void LoadNoteSkinData( const RString &sNoteSkinName, NoteSkinData& data_out );
void LoadNoteSkinDataRecursive( const RString &sNoteSkinName, NoteSkinData& data_out );
RString m_sCurrentNoteSkin;
const Game* m_pCurGame;
// xxx: is this the best way to implement this? -freem
PlayerNumber m_PlayerNumber;
GameController m_GameController;
};
extern NoteSkinManager* NOTESKIN; // global and accessable from anywhere in our program
class LockNoteSkin
{
public:
LockNoteSkin( const RString &sNoteSkin ) { ASSERT( NOTESKIN->GetCurrentNoteSkin().empty() ); NOTESKIN->SetCurrentNoteSkin( sNoteSkin ); }
~LockNoteSkin() { NOTESKIN->SetCurrentNoteSkin( RString() ); }
};
#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 NOTE_SKIN_MANAGER_H
#define NOTE_SKIN_MANAGER_H
#include "Actor.h"
#include "RageTypes.h"
#include "PlayerNumber.h"
#include "GameInput.h"
#include "IniFile.h"
class Game;
struct NoteSkinData;
/** @brief Loads note skins. */
class NoteSkinManager
{
public:
NoteSkinManager();
~NoteSkinManager();
void RefreshNoteSkinData( const Game* game );
void GetNoteSkinNames( const Game* game, vector<RString> &AddTo );
void GetNoteSkinNames( vector<RString> &AddTo ); // looks up current const Game* in GAMESTATE
bool DoesNoteSkinExist( const RString &sNoteSkin ); // looks up current const Game* in GAMESTATE
bool DoNoteSkinsExistForGame( const Game *pGame );
void SetCurrentNoteSkin( const RString &sNoteSkin ) { m_sCurrentNoteSkin = sNoteSkin; }
const RString &GetCurrentNoteSkin() { return m_sCurrentNoteSkin; }
void SetPlayerNumber( PlayerNumber pn ) { m_PlayerNumber = pn; }
void SetGameController( GameController gc ) { m_GameController = gc; }
RString GetPath( const RString &sButtonName, const RString &sElement );
bool PushActorTemplate( Lua *L, const RString &sButton, const RString &sElement, bool bSpriteOnly );
Actor *LoadActor( const RString &sButton, const RString &sElement, Actor *pParent = nullptr, bool bSpriteOnly = false );
RString GetMetric( const RString &sButtonName, const RString &sValue );
int GetMetricI( const RString &sButtonName, const RString &sValueName );
float GetMetricF( const RString &sButtonName, const RString &sValueName );
bool GetMetricB( const RString &sButtonName, const RString &sValueName );
apActorCommands GetMetricA( const RString &sButtonName, const RString &sValueName );
// Lua
void PushSelf( lua_State *L );
protected:
RString GetPathFromDirAndFile( const RString &sDir, const RString &sFileName );
void GetAllNoteSkinNamesForGame( const Game *pGame, vector<RString> &AddTo );
void LoadNoteSkinData( const RString &sNoteSkinName, NoteSkinData& data_out );
void LoadNoteSkinDataRecursive( const RString &sNoteSkinName, NoteSkinData& data_out );
RString m_sCurrentNoteSkin;
const Game* m_pCurGame;
// xxx: is this the best way to implement this? -freem
PlayerNumber m_PlayerNumber;
GameController m_GameController;
};
extern NoteSkinManager* NOTESKIN; // global and accessable from anywhere in our program
class LockNoteSkin
{
public:
LockNoteSkin( const RString &sNoteSkin ) { ASSERT( NOTESKIN->GetCurrentNoteSkin().empty() ); NOTESKIN->SetCurrentNoteSkin( sNoteSkin ); }
~LockNoteSkin() { NOTESKIN->SetCurrentNoteSkin( RString() ); }
};
#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.
*/
+1 -1
View File
@@ -969,7 +969,7 @@ bool SMLoader::LoadEditFromBuffer( const RString &sBuffer, const RString &sEditF
bool SMLoader::LoadEditFromMsd( const MsdFile &msd, const RString &sEditFilePath, ProfileSlot slot, bool bAddStepsToSong )
{
Song* pSong = NULL;
Song* pSong = nullptr;
for( unsigned i=0; i<msd.GetNumValues(); i++ )
{
+1 -1
View File
@@ -162,7 +162,7 @@ bool SMALoader::LoadFromSimfile( const RString &sPath, Song &out, bool bFromCach
out.m_sSongFileName = sPath;
int state = SMA_GETTING_SONG_INFO;
Steps* pNewNotes = NULL;
Steps* pNewNotes = nullptr;
int iRowsPerBeat = -1; // Start with an invalid value: needed for checking.
for( unsigned i=0; i<msd.GetNumValues(); i++ )
+3 -3
View File
@@ -250,7 +250,7 @@ bool SSCLoader::LoadFromSimfile( const RString &sPath, Song &out, bool bFromCach
int state = GETTING_SONG_INFO;
const unsigned values = msd.GetNumValues();
Steps* pNewNotes = NULL;
Steps* pNewNotes = nullptr;
TimingData stepsTiming;
bool bHasOwnTiming = false;
@@ -836,8 +836,8 @@ bool SSCLoader::LoadEditFromMsd(const MsdFile &msd,
ProfileSlot slot,
bool bAddStepsToSong )
{
Song* pSong = NULL;
Steps* pNewNotes = NULL;
Song* pSong = nullptr;
Steps* pNewNotes = nullptr;
bool bSSCFormat = false;
bool bHasOwnTiming = false;
TimingData stepsTiming;
+2 -2
View File
@@ -33,9 +33,9 @@ RString MOD_ICON_X_NAME( size_t p ) { return ssprintf("ModIconP%dX",int(p+1));
OptionRow::OptionRow( const OptionRowType *pSource )
{
m_pParentType = pSource;
m_pHand = NULL;
m_pHand = nullptr;
m_textTitle = NULL;
m_textTitle = nullptr;
ZERO( m_ModIcons );
Clear();
+9 -9
View File
@@ -510,8 +510,8 @@ public:
void Init()
{
OptionRowHandler::Init();
m_ppStepsToFill = NULL;
m_pDifficultyToFill = NULL;
m_ppStepsToFill = nullptr;
m_pDifficultyToFill = nullptr;
m_vSteps.clear();
m_vDifficulties.clear();
}
@@ -569,7 +569,7 @@ public:
if( sParam == "EditSteps" )
{
m_vSteps.push_back( NULL );
m_vSteps.push_back(nullptr);
m_vDifficulties.push_back( Difficulty_Edit );
}
@@ -596,7 +596,7 @@ public:
else
{
m_vDifficulties.push_back( Difficulty_Edit );
m_vSteps.push_back( NULL );
m_vSteps.push_back(nullptr);
m_Def.m_vsChoices.push_back( "none" );
}
@@ -672,7 +672,7 @@ class OptionRowHandlerListCharacters: public OptionRowHandlerList
{
m_Def.m_vsChoices.push_back( OFF );
GameCommand mc;
mc.m_pCharacter = NULL;
mc.m_pCharacter = nullptr;
m_aListEntries.push_back( mc );
}
@@ -1100,7 +1100,7 @@ public:
void Init()
{
OptionRowHandler::Init();
m_pOpt = NULL;
m_pOpt = nullptr;
}
virtual void LoadInternal( const Commands &cmds )
{
@@ -1180,7 +1180,7 @@ public:
void Init()
{
OptionRowHandler::Init();
m_pstToFill = NULL;
m_pstToFill = nullptr;
m_vStepsTypesToShow.clear();
}
@@ -1320,7 +1320,7 @@ public:
OptionRowHandler* OptionRowHandlerUtil::Make( const Commands &cmds )
{
OptionRowHandler* pHand = NULL;
OptionRowHandler* pHand = nullptr;
if( cmds.v.size() == 0 )
return nullptr;
@@ -1362,7 +1362,7 @@ OptionRowHandler* OptionRowHandlerUtil::Make( const Commands &cmds )
OptionRowHandler* OptionRowHandlerUtil::MakeNull()
{
OptionRowHandler* pHand = NULL;
OptionRowHandler* pHand = nullptr;
Commands cmds;
MAKE( OptionRowHandlerNull )
return pHand;
+2 -2
View File
@@ -172,7 +172,7 @@ void OptionListRow::PositionCursor( Actor *pCursor, int iSelection )
OptionsList::OptionsList()
{
m_iCurrentRow = 0;
m_pLinked = NULL;
m_pLinked = nullptr;
}
OptionsList::~OptionsList()
@@ -265,7 +265,7 @@ void OptionsList::Open()
Push( TOP_MENU );
this->FinishTweening();
m_Row[!m_iCurrentRow].SetFromHandler( NULL );
m_Row[!m_iCurrentRow].SetFromHandler(nullptr);
this->PlayCommand( "TweenOn" );
}
+1 -1
View File
@@ -179,7 +179,7 @@ void PaneDisplay::GetPaneTextAndLevel( PaneCategory c, RString & sTextOut, float
{
RadarValues rv;
HighScoreList *pHSL = NULL;
HighScoreList *pHSL = nullptr;
ProfileSlot slot = ProfileSlot_Machine;
switch( c )
{
+2 -2
View File
@@ -16,8 +16,8 @@ REGISTER_ACTOR_CLASS( PercentageDisplay );
PercentageDisplay::PercentageDisplay()
{
m_pPlayerState = NULL;
m_pPlayerStageStats = NULL;
m_pPlayerState = nullptr;
m_pPlayerStageStats = nullptr;
m_Last = -1;
m_LastMax = -1;
+20 -20
View File
@@ -223,27 +223,27 @@ Player::Player( NoteData &nd, bool bVisibleParts ) : m_NoteData(nd)
{
m_bLoaded = false;
m_pPlayerState = NULL;
m_pPlayerStageStats = NULL;
m_pPlayerState = nullptr;
m_pPlayerStageStats = nullptr;
m_fNoteFieldHeight = 0;
m_pLifeMeter = NULL;
m_pCombinedLifeMeter = NULL;
m_pScoreDisplay = NULL;
m_pSecondaryScoreDisplay = NULL;
m_pPrimaryScoreKeeper = NULL;
m_pSecondaryScoreKeeper = NULL;
m_pInventory = NULL;
m_pIterNeedsTapJudging = NULL;
m_pIterNeedsHoldJudging = NULL;
m_pIterUncrossedRows = NULL;
m_pIterUnjudgedRows = NULL;
m_pIterUnjudgedMineRows = NULL;
m_pLifeMeter = nullptr;
m_pCombinedLifeMeter = nullptr;
m_pScoreDisplay = nullptr;
m_pSecondaryScoreDisplay = nullptr;
m_pPrimaryScoreKeeper = nullptr;
m_pSecondaryScoreKeeper = nullptr;
m_pInventory = nullptr;
m_pIterNeedsTapJudging = nullptr;
m_pIterNeedsHoldJudging = nullptr;
m_pIterUncrossedRows = nullptr;
m_pIterUnjudgedRows = nullptr;
m_pIterUnjudgedMineRows = nullptr;
m_bPaused = false;
m_bDelay = false;
m_pAttackDisplay = NULL;
m_pAttackDisplay = nullptr;
if( bVisibleParts )
{
m_pAttackDisplay = new AttackDisplay;
@@ -252,7 +252,7 @@ Player::Player( NoteData &nd, bool bVisibleParts ) : m_NoteData(nd)
PlayerAI::InitFromDisk();
m_pNoteField = NULL;
m_pNoteField = nullptr;
if( bVisibleParts )
{
m_pNoteField = new NoteField;
@@ -504,14 +504,14 @@ void Player::Init(
}
else
{
m_pActorWithComboPosition = NULL;
m_pActorWithJudgmentPosition = NULL;
m_pActorWithComboPosition = nullptr;
m_pActorWithJudgmentPosition = nullptr;
}
// Load HoldJudgments
m_vpHoldJudgment.resize( GAMESTATE->GetCurrentStyle()->m_iColsPerPlayer );
for( int i = 0; i < GAMESTATE->GetCurrentStyle()->m_iColsPerPlayer; ++i )
m_vpHoldJudgment[i] = NULL;
m_vpHoldJudgment[i] = nullptr;
if( HasVisibleParts() )
{
@@ -2209,7 +2209,7 @@ void Player::StepStrumHopo( int col, int row, const RageTimer &tm, bool bHeld, b
const float fSecondsFromExact = fabsf( fNoteOffset );
TapNote tnDummy = TAP_ORIGINAL_TAP;
TapNote *pTN = NULL;
TapNote *pTN = nullptr;
switch( pbt )
{
DEFAULT_FAIL(pbt);
+185 -185
View File
@@ -1,185 +1,185 @@
/* Preference - Holds user-chosen preferences that are saved between sessions. */
#ifndef PREFERENCE_H
#define PREFERENCE_H
#include "EnumHelper.h"
#include "LuaManager.h"
#include "RageUtil.h"
class XNode;
struct lua_State;
class IPreference
{
public:
IPreference( const RString& sName );
virtual ~IPreference();
void ReadFrom( const XNode* pNode, bool bIsStatic );
void WriteTo( XNode* pNode ) const;
void ReadDefaultFrom( const XNode* pNode );
virtual void LoadDefault() = 0;
virtual void SetDefaultFromString( const RString &s ) = 0;
virtual RString ToString() const = 0;
virtual void FromString( const RString &s ) = 0;
virtual void SetFromStack( lua_State *L );
virtual void PushValue( lua_State *L ) const;
const RString &GetName() const { return m_sName; }
static IPreference *GetPreferenceByName( const RString &sName );
static void LoadAllDefaults();
static void ReadAllPrefsFromNode( const XNode* pNode, bool bIsStatic );
static void SavePrefsToNode( XNode* pNode );
static void ReadAllDefaultsFromNode( const XNode* pNode );
RString GetName() { return m_sName; }
void SetStatic( bool b ) { m_bIsStatic = b; }
private:
RString m_sName;
bool m_bIsStatic; // loaded from Static.ini? If so, don't write to Preferences.ini
};
void BroadcastPreferenceChanged( const RString& sPreferenceName );
template <class T>
class Preference : public IPreference
{
public:
Preference( const RString& sName, const T& defaultValue, void (pfnValidate)(T& val) = NULL ):
IPreference( sName ),
m_currentValue( defaultValue ),
m_defaultValue( defaultValue ),
m_pfnValidate( pfnValidate )
{
LoadDefault();
}
RString ToString() const { return StringConversion::ToString<T>( m_currentValue ); }
void FromString( const RString &s )
{
if( !StringConversion::FromString<T>(s, m_currentValue) )
m_currentValue = m_defaultValue;
if( m_pfnValidate )
m_pfnValidate( m_currentValue );
}
void SetFromStack( lua_State *L )
{
LuaHelpers::Pop<T>( L, m_currentValue );
if( m_pfnValidate )
m_pfnValidate( m_currentValue );
}
void PushValue( lua_State *L ) const
{
LuaHelpers::Push<T>( L, m_currentValue );
}
void LoadDefault()
{
m_currentValue = m_defaultValue;
}
void SetDefaultFromString( const RString &s )
{
T def = m_defaultValue;
if( !StringConversion::FromString<T>(s, m_defaultValue) )
m_defaultValue = def;
}
const T &Get() const
{
return m_currentValue;
}
const T &GetDefault() const
{
return m_defaultValue;
}
operator const T () const
{
return Get();
}
void Set( const T& other )
{
m_currentValue = other;
BroadcastPreferenceChanged( GetName() );
}
static Preference<T> *GetPreferenceByName( const RString &sName )
{
IPreference *pPreference = IPreference::GetPreferenceByName( sName );
Preference<T> *pRet = dynamic_cast<Preference<T> *>(pPreference);
return pRet;
}
private:
T m_currentValue;
T m_defaultValue;
void (*m_pfnValidate)(T& val);
};
/** @brief Utilities for working with Lua. */
namespace LuaHelpers { template<typename T> void Push( lua_State *L, const Preference<T> &Object ) { LuaHelpers::Push<T>( L, Object.Get() ); } }
template <class T>
class Preference1D
{
public:
typedef Preference<T> PreferenceT;
vector<PreferenceT*> m_v;
Preference1D( void pfn(size_t i, RString &sNameOut, T &defaultValueOut ), size_t N )
{
for( size_t i=0; i<N; ++i )
{
RString sName;
T defaultValue;
pfn( i, sName, defaultValue );
m_v.push_back( new Preference<T>(sName, defaultValue) );
}
}
~Preference1D()
{
for( size_t i=0; i<m_v.size(); ++i )
SAFE_DELETE( m_v[i] );
}
const Preference<T>& operator[]( size_t i ) const
{
return *m_v[i];
}
Preference<T>& operator[]( size_t i )
{
return *m_v[i];
}
};
#endif
/*
* (c) 2001-2004 Chris Danford, Chris Gomez
* 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.
*/
/* Preference - Holds user-chosen preferences that are saved between sessions. */
#ifndef PREFERENCE_H
#define PREFERENCE_H
#include "EnumHelper.h"
#include "LuaManager.h"
#include "RageUtil.h"
class XNode;
struct lua_State;
class IPreference
{
public:
IPreference( const RString& sName );
virtual ~IPreference();
void ReadFrom( const XNode* pNode, bool bIsStatic );
void WriteTo( XNode* pNode ) const;
void ReadDefaultFrom( const XNode* pNode );
virtual void LoadDefault() = 0;
virtual void SetDefaultFromString( const RString &s ) = 0;
virtual RString ToString() const = 0;
virtual void FromString( const RString &s ) = 0;
virtual void SetFromStack( lua_State *L );
virtual void PushValue( lua_State *L ) const;
const RString &GetName() const { return m_sName; }
static IPreference *GetPreferenceByName( const RString &sName );
static void LoadAllDefaults();
static void ReadAllPrefsFromNode( const XNode* pNode, bool bIsStatic );
static void SavePrefsToNode( XNode* pNode );
static void ReadAllDefaultsFromNode( const XNode* pNode );
RString GetName() { return m_sName; }
void SetStatic( bool b ) { m_bIsStatic = b; }
private:
RString m_sName;
bool m_bIsStatic; // loaded from Static.ini? If so, don't write to Preferences.ini
};
void BroadcastPreferenceChanged( const RString& sPreferenceName );
template <class T>
class Preference : public IPreference
{
public:
Preference( const RString& sName, const T& defaultValue, void (pfnValidate)(T& val) = nullptr ):
IPreference( sName ),
m_currentValue( defaultValue ),
m_defaultValue( defaultValue ),
m_pfnValidate( pfnValidate )
{
LoadDefault();
}
RString ToString() const { return StringConversion::ToString<T>( m_currentValue ); }
void FromString( const RString &s )
{
if( !StringConversion::FromString<T>(s, m_currentValue) )
m_currentValue = m_defaultValue;
if( m_pfnValidate )
m_pfnValidate( m_currentValue );
}
void SetFromStack( lua_State *L )
{
LuaHelpers::Pop<T>( L, m_currentValue );
if( m_pfnValidate )
m_pfnValidate( m_currentValue );
}
void PushValue( lua_State *L ) const
{
LuaHelpers::Push<T>( L, m_currentValue );
}
void LoadDefault()
{
m_currentValue = m_defaultValue;
}
void SetDefaultFromString( const RString &s )
{
T def = m_defaultValue;
if( !StringConversion::FromString<T>(s, m_defaultValue) )
m_defaultValue = def;
}
const T &Get() const
{
return m_currentValue;
}
const T &GetDefault() const
{
return m_defaultValue;
}
operator const T () const
{
return Get();
}
void Set( const T& other )
{
m_currentValue = other;
BroadcastPreferenceChanged( GetName() );
}
static Preference<T> *GetPreferenceByName( const RString &sName )
{
IPreference *pPreference = IPreference::GetPreferenceByName( sName );
Preference<T> *pRet = dynamic_cast<Preference<T> *>(pPreference);
return pRet;
}
private:
T m_currentValue;
T m_defaultValue;
void (*m_pfnValidate)(T& val);
};
/** @brief Utilities for working with Lua. */
namespace LuaHelpers { template<typename T> void Push( lua_State *L, const Preference<T> &Object ) { LuaHelpers::Push<T>( L, Object.Get() ); } }
template <class T>
class Preference1D
{
public:
typedef Preference<T> PreferenceT;
vector<PreferenceT*> m_v;
Preference1D( void pfn(size_t i, RString &sNameOut, T &defaultValueOut ), size_t N )
{
for( size_t i=0; i<N; ++i )
{
RString sName;
T defaultValue;
pfn( i, sName, defaultValue );
m_v.push_back( new Preference<T>(sName, defaultValue) );
}
}
~Preference1D()
{
for( size_t i=0; i<m_v.size(); ++i )
SAFE_DELETE( m_v[i] );
}
const Preference<T>& operator[]( size_t i ) const
{
return *m_v[i];
}
Preference<T>& operator[]( size_t i )
{
return *m_v[i];
}
};
#endif
/*
* (c) 2001-2004 Chris Danford, Chris Gomez
* 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.
*/
+1 -1
View File
@@ -16,7 +16,7 @@
//STATIC_INI_PATH = "Data/Static.ini"; // overlay on the 2 above, can't be overridden
//TYPE_TXT_FILE = "Data/Type.txt";
PrefsManager* PREFSMAN = NULL; // global and accessable from anywhere in our program
PrefsManager* PREFSMAN = nullptr; // global and accessable from anywhere in our program
static const char *MusicWheelUsesSectionsNames[] = {
"Never",
+1 -1
View File
@@ -25,7 +25,7 @@
#include "CharacterManager.h"
ProfileManager* PROFILEMAN = NULL; // global and accessable from anywhere in our program
ProfileManager* PROFILEMAN = nullptr; // global and accessable from anywhere in our program
static void DefaultLocalProfileIDInit( size_t /*PlayerNumber*/ i, RString &sNameOut, RString &defaultValueOut )
{
+8 -8
View File
@@ -36,9 +36,9 @@ RString GetErrorString( HRESULT hr )
}
// Globals
HMODULE g_D3D9_Module = NULL;
LPDIRECT3D9 g_pd3d = NULL;
LPDIRECT3DDEVICE9 g_pd3dDevice = NULL;
HMODULE g_D3D9_Module = nullptr;
LPDIRECT3D9 g_pd3d = nullptr;
LPDIRECT3DDEVICE9 g_pd3dDevice = nullptr;
D3DCAPS9 g_DeviceCaps;
D3DDISPLAYMODE g_DesktopMode;
D3DPRESENT_PARAMETERS g_d3dpp;
@@ -252,13 +252,13 @@ RageDisplay_D3D::~RageDisplay_D3D()
if( g_pd3dDevice )
{
g_pd3dDevice->Release();
g_pd3dDevice = NULL;
g_pd3dDevice = nullptr;
}
if( g_pd3d )
{
g_pd3d->Release();
g_pd3d = NULL;
g_pd3d = nullptr;
}
/* Even after we call Release(), D3D may still affect our window. It seems
@@ -267,7 +267,7 @@ RageDisplay_D3D::~RageDisplay_D3D()
if( g_D3D9_Module )
{
FreeLibrary( g_D3D9_Module );
g_D3D9_Module = NULL;
g_D3D9_Module = nullptr;
}
}
@@ -621,7 +621,7 @@ bool RageDisplay_D3D::SupportsThreadedRendering()
RageSurface* RageDisplay_D3D::CreateScreenshot()
{
RageSurface * result = NULL;
RageSurface * result = nullptr;
// Get the back buffer.
IDirect3DSurface9* pSurface;
@@ -702,7 +702,7 @@ void RageDisplay_D3D::SendCurrentMatrices()
g_pd3dDevice->SetTextureStageState( tu, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_COUNT2 );
// If no texture is set for this texture unit, don't bother setting it up.
IDirect3DBaseTexture9* pTexture = NULL;
IDirect3DBaseTexture9* pTexture = nullptr;
g_pd3dDevice->GetTexture( tu, &pTexture );
if( pTexture == nullptr )
continue;
+1 -1
View File
@@ -220,7 +220,7 @@ RageDisplay_GLES2::RageDisplay_GLES2()
FixLittleEndian();
// RageDisplay_GLES2_Helpers::Init();
g_pWind = NULL;
g_pWind = nullptr;
}
RString
+6 -6
View File
@@ -64,7 +64,7 @@ static const GLenum RageSpriteVertexFormat = GL_T2F_C4F_N3F_V3F;
static GLhandleARB g_bTextureMatrixShader = 0;
static map<unsigned, RenderTarget *> g_mapRenderTargets;
static RenderTarget *g_pCurrentRenderTarget = NULL;
static RenderTarget *g_pCurrentRenderTarget = nullptr;
static LowLevelWindow *g_pWind;
@@ -262,7 +262,7 @@ RageDisplay_Legacy::RageDisplay_Legacy()
FixLittleEndian();
RageDisplay_Legacy_Helpers::Init();
g_pWind = NULL;
g_pWind = nullptr;
g_bTextureMatrixShader = 0;
}
@@ -650,8 +650,8 @@ static void CheckPalettedTextures()
/* If 8-bit palettes don't work, disable them entirely--don't trust 4-bit
* palettes if it can't even get 8-bit ones right. */
glColorTableEXT = NULL;
glGetColorTableParameterivEXT = NULL;
glColorTableEXT = nullptr;
glGetColorTableParameterivEXT = nullptr;
LOG->Info( "Paletted textures disabled: %s.", sError.c_str() );
}
@@ -2252,7 +2252,7 @@ public:
if (bChanged)
DISPLAY->UpdateTexture( m_iTexHandle, pSurface, 0, 0, pSurface->w, pSurface->h );
pSurface->pixels = NULL;
pSurface->pixels = nullptr;
m_iTexHandle = 0;
glBindBufferARB( GL_PIXEL_UNPACK_BUFFER_ARB, 0 );
@@ -2482,7 +2482,7 @@ void RageDisplay_Legacy::SetRenderTarget( unsigned iTexture, bool bPreserveTextu
if (g_pCurrentRenderTarget)
g_pCurrentRenderTarget->FinishRenderingTo();
g_pCurrentRenderTarget = NULL;
g_pCurrentRenderTarget = nullptr;
return;
}
+1 -1
View File
@@ -15,7 +15,7 @@ using CrashHandler::DebugBreak;
#endif
static uint64_t g_HandlerThreadID = RageThread::GetInvalidThreadID();
static void (*g_CleanupHandler)( const RString &sError ) = NULL;
static void (*g_CleanupHandler)( const RString &sError ) = nullptr;
void RageException::SetCleanupHandler( void (*pHandler)(const RString &sError) )
{
g_HandlerThreadID = RageThread::GetCurrentThreadID();
+2 -2
View File
@@ -13,7 +13,7 @@
RageFile::RageFile()
{
m_File = NULL;
m_File = nullptr;
}
RageFile::RageFile( const RageFile &cpy ):
@@ -83,7 +83,7 @@ void RageFile::Close()
delete m_File;
if( m_Mode & WRITE )
FILEMAN->CacheFile( m_File, m_Path );
m_File = NULL;
m_File = nullptr;
}
#define ASSERT_OPEN ASSERT_M( IsOpen(), ssprintf("\"%s\" is not open.", m_Path.c_str()) );
+4 -4
View File
@@ -7,8 +7,8 @@ REGISTER_CLASS_TRAITS( RageFileBasic, pCopy->Copy() );
RageFileObj::RageFileObj()
{
m_pReadBuffer = NULL;
m_pWriteBuffer = NULL;
m_pReadBuffer = nullptr;
m_pWriteBuffer = nullptr;
ResetReadBuf();
@@ -35,7 +35,7 @@ RageFileObj::RageFileObj( const RageFileObj &cpy ):
}
else
{
m_pReadBuffer = NULL;
m_pReadBuffer = nullptr;
}
if( cpy.m_pWriteBuffer != nullptr )
@@ -45,7 +45,7 @@ RageFileObj::RageFileObj( const RageFileObj &cpy ):
}
else
{
m_pWriteBuffer = NULL;
m_pWriteBuffer = nullptr;
}
m_iReadBufAvail = cpy.m_iReadBufAvail;
+2 -2
View File
@@ -68,7 +68,7 @@ void RageFileDriver::FlushDirCache( const RString &sPath )
}
const struct FileDriverEntry *g_pFileDriverList = NULL;
const struct FileDriverEntry *g_pFileDriverList = nullptr;
FileDriverEntry::FileDriverEntry( const RString &sType )
{
@@ -79,7 +79,7 @@ FileDriverEntry::FileDriverEntry( const RString &sType )
FileDriverEntry::~FileDriverEntry()
{
g_pFileDriverList = NULL; /* invalidate */
g_pFileDriverList = nullptr; /* invalidate */
}
RageFileDriver *MakeFileDriver( const RString &sType, const RString &sRoot )
+74 -74
View File
@@ -1,74 +1,74 @@
/* RageFileDriverMemory: Simple memory-based "filesystem". */
#ifndef RAGE_FILE_DRIVER_MEMORY_H
#define RAGE_FILE_DRIVER_MEMORY_H
#include "RageFileDriver.h"
#include "RageFileBasic.h"
#include "RageThreads.h"
struct RageFileObjMemFile;
class RageFileObjMem: public RageFileObj
{
public:
RageFileObjMem( RageFileObjMemFile *pFile = NULL );
RageFileObjMem( const RageFileObjMem &cpy );
~RageFileObjMem();
int ReadInternal( void *buffer, size_t bytes );
int WriteInternal( const void *buffer, size_t bytes );
int SeekInternal( int offset );
int GetFileSize() const;
RageFileObjMem *Copy() const;
/* Retrieve the contents of this file. */
const RString &GetString() const;
void PutString( const RString &sBuf );
private:
RageFileObjMemFile *m_pFile;
int m_iFilePos;
};
class RageFileDriverMem: public RageFileDriver
{
public:
RageFileDriverMem();
~RageFileDriverMem();
RageFileBasic *Open( const RString &sPath, int mode, int &err );
void FlushDirCache( const RString & /* sPath */ ) { }
bool Remove( const RString &sPath );
private:
RageMutex m_Mutex;
vector<RageFileObjMemFile *> m_Files;
};
#endif
/*
* (c) 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.
*/
/* RageFileDriverMemory: Simple memory-based "filesystem". */
#ifndef RAGE_FILE_DRIVER_MEMORY_H
#define RAGE_FILE_DRIVER_MEMORY_H
#include "RageFileDriver.h"
#include "RageFileBasic.h"
#include "RageThreads.h"
struct RageFileObjMemFile;
class RageFileObjMem: public RageFileObj
{
public:
RageFileObjMem( RageFileObjMemFile *pFile = nullptr );
RageFileObjMem( const RageFileObjMem &cpy );
~RageFileObjMem();
int ReadInternal( void *buffer, size_t bytes );
int WriteInternal( const void *buffer, size_t bytes );
int SeekInternal( int offset );
int GetFileSize() const;
RageFileObjMem *Copy() const;
/* Retrieve the contents of this file. */
const RString &GetString() const;
void PutString( const RString &sBuf );
private:
RageFileObjMemFile *m_pFile;
int m_iFilePos;
};
class RageFileDriverMem: public RageFileDriver
{
public:
RageFileDriverMem();
~RageFileDriverMem();
RageFileBasic *Open( const RString &sPath, int mode, int &err );
void FlushDirCache( const RString & /* sPath */ ) { }
bool Remove( const RString &sPath );
private:
RageMutex m_Mutex;
vector<RageFileObjMemFile *> m_Files;
};
#endif
/*
* (c) 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.
*/
+32 -32
View File
@@ -161,10 +161,10 @@ ThreadedFileWorker::ThreadedFileWorker( RString sPath ):
if( m_pChildDriver == nullptr )
WARN( ssprintf("ThreadedFileWorker: Mountpoint \"%s\" not found", sPath.c_str()) );
m_pResultFile = NULL;
m_pRequestFile = NULL;
m_pResultBuffer = NULL;
m_pRequestBuffer = NULL;
m_pResultFile = nullptr;
m_pRequestFile = nullptr;
m_pResultBuffer = nullptr;
m_pRequestBuffer = nullptr;
g_apWorkersMutex.Lock();
g_apWorkers.push_back( this );
@@ -220,7 +220,7 @@ void ThreadedFileWorker::HandleRequest( int iRequest )
delete m_pRequestFile;
/* Clear m_pRequestFile, so RequestTimedOut doesn't double-delete. */
m_pRequestFile = NULL;
m_pRequestFile = nullptr;
break;
case REQ_GET_FILE_SIZE:
@@ -321,7 +321,7 @@ RageFileBasic *ThreadedFileWorker::Open( const RString &sPath, int iMode, int &i
iErr = m_iResultRequest;
RageFileBasic *pRet = m_pResultFile;
m_pResultFile = NULL;
m_pResultFile = nullptr;
return pRet;
}
@@ -340,7 +340,7 @@ void ThreadedFileWorker::Close( RageFileBasic *pFile )
m_pRequestFile = pFile;
if( !DoRequest(REQ_CLOSE) )
return;
m_pRequestFile = NULL;
m_pRequestFile = nullptr;
}
else
{
@@ -359,7 +359,7 @@ int ThreadedFileWorker::GetFileSize( RageFileBasic *&pFile )
if( IsTimedOut() )
{
this->Close( pFile );
pFile = NULL;
pFile = nullptr;
}
if( pFile == nullptr )
@@ -370,11 +370,11 @@ int ThreadedFileWorker::GetFileSize( RageFileBasic *&pFile )
if( !DoRequest(REQ_GET_FILE_SIZE) )
{
/* If we time out, we can no longer access pFile. */
pFile = NULL;
pFile = nullptr;
return -1;
}
m_pRequestFile = NULL;
m_pRequestFile = nullptr;
return m_iResultRequest;
}
@@ -387,7 +387,7 @@ int ThreadedFileWorker::GetFD( RageFileBasic *&pFile )
if( IsTimedOut() )
{
this->Close( pFile );
pFile = NULL;
pFile = nullptr;
}
if( pFile == nullptr )
@@ -398,11 +398,11 @@ int ThreadedFileWorker::GetFD( RageFileBasic *&pFile )
if( !DoRequest(REQ_GET_FD) )
{
/* If we time out, we can no longer access pFile. */
pFile = NULL;
pFile = nullptr;
return -1;
}
m_pRequestFile = NULL;
m_pRequestFile = nullptr;
return m_iResultRequest;
}
@@ -415,7 +415,7 @@ int ThreadedFileWorker::Seek( RageFileBasic *&pFile, int iPos, RString &sError )
if( IsTimedOut() )
{
this->Close( pFile );
pFile = NULL;
pFile = nullptr;
}
if( pFile == nullptr )
@@ -431,13 +431,13 @@ int ThreadedFileWorker::Seek( RageFileBasic *&pFile, int iPos, RString &sError )
{
/* If we time out, we can no longer access pFile. */
sError = "Operation timed out";
pFile = NULL;
pFile = nullptr;
return -1;
}
if( m_iResultRequest == -1 )
sError = m_sResultError;
m_pRequestFile = NULL;
m_pRequestFile = nullptr;
return m_iResultRequest;
}
@@ -450,7 +450,7 @@ int ThreadedFileWorker::Read( RageFileBasic *&pFile, void *pBuf, int iSize, RStr
if( IsTimedOut() )
{
this->Close( pFile );
pFile = NULL;
pFile = nullptr;
}
if( pFile == nullptr )
@@ -467,7 +467,7 @@ int ThreadedFileWorker::Read( RageFileBasic *&pFile, void *pBuf, int iSize, RStr
{
/* If we time out, we can no longer access pFile. */
sError = "Operation timed out";
pFile = NULL;
pFile = nullptr;
return -1;
}
@@ -477,9 +477,9 @@ int ThreadedFileWorker::Read( RageFileBasic *&pFile, void *pBuf, int iSize, RStr
else
memcpy( pBuf, m_pResultBuffer, iGot );
m_pRequestFile = NULL;
m_pRequestFile = nullptr;
delete [] m_pResultBuffer;
m_pResultBuffer = NULL;
m_pResultBuffer = nullptr;
return iGot;
}
@@ -492,7 +492,7 @@ int ThreadedFileWorker::Write( RageFileBasic *&pFile, const void *pBuf, int iSiz
if( IsTimedOut() )
{
this->Close( pFile );
pFile = NULL;
pFile = nullptr;
}
if( pFile == nullptr )
@@ -510,7 +510,7 @@ int ThreadedFileWorker::Write( RageFileBasic *&pFile, const void *pBuf, int iSiz
{
/* If we time out, we can no longer access pFile. */
sError = "Operation timed out";
pFile = NULL;
pFile = nullptr;
return -1;
}
@@ -518,9 +518,9 @@ int ThreadedFileWorker::Write( RageFileBasic *&pFile, const void *pBuf, int iSiz
if( m_iResultRequest == -1 )
sError = m_sResultError;
m_pRequestFile = NULL;
m_pRequestFile = nullptr;
delete [] m_pRequestBuffer;
m_pRequestBuffer = NULL;
m_pRequestBuffer = nullptr;
return iGot;
}
@@ -533,7 +533,7 @@ int ThreadedFileWorker::Flush( RageFileBasic *&pFile, RString &sError )
if( IsTimedOut() )
{
this->Close( pFile );
pFile = NULL;
pFile = nullptr;
}
if( pFile == nullptr )
@@ -548,14 +548,14 @@ int ThreadedFileWorker::Flush( RageFileBasic *&pFile, RString &sError )
{
/* If we time out, we can no longer access pFile. */
sError = "Operation timed out";
pFile = NULL;
pFile = nullptr;
return -1;
}
if( m_iResultRequest == -1 )
sError = m_sResultError;
m_pRequestFile = NULL;
m_pRequestFile = nullptr;
return m_iResultRequest;
}
@@ -568,7 +568,7 @@ RageFileBasic *ThreadedFileWorker::Copy( RageFileBasic *&pFile, RString &sError
if( IsTimedOut() )
{
this->Close( pFile );
pFile = NULL;
pFile = nullptr;
}
if( pFile == nullptr )
@@ -582,13 +582,13 @@ RageFileBasic *ThreadedFileWorker::Copy( RageFileBasic *&pFile, RString &sError
{
/* If we time out, we can no longer access pFile. */
sError = "Operation timed out";
pFile = NULL;
pFile = nullptr;
return nullptr;
}
RageFileBasic *pRet = m_pResultFile;
m_pRequestFile = NULL;
m_pResultFile = NULL;
m_pRequestFile = nullptr;
m_pResultFile = nullptr;
return pRet;
}
@@ -848,7 +848,7 @@ public:
TimedFilenameDB()
{
ExpireSeconds = -1;
m_pWorker = NULL;
m_pWorker = nullptr;
}
void SetWorker( ThreadedFileWorker *pWorker )
+2 -2
View File
@@ -24,7 +24,7 @@ RageFileDriverZip::RageFileDriverZip():
m_Mutex( "RageFileDriverZip" )
{
m_bFileOwned = false;
m_pZip = NULL;
m_pZip = nullptr;
}
RageFileDriverZip::RageFileDriverZip( const RString &sPath ):
@@ -32,7 +32,7 @@ RageFileDriverZip::RageFileDriverZip( const RString &sPath ):
m_Mutex( "RageFileDriverZip" )
{
m_bFileOwned = false;
m_pZip = NULL;
m_pZip = nullptr;
Load( sPath );
}
+6 -6
View File
@@ -18,7 +18,7 @@
#include <paths.h>
#endif
RageFileManager *FILEMAN = NULL;
RageFileManager *FILEMAN = nullptr;
/* Lock this before touching any of these globals (except FILEMAN itself). */
static RageEvent *g_Mutex;
@@ -38,7 +38,7 @@ struct LoadedDriver
int m_iRefs;
LoadedDriver() { m_pDriver = NULL; m_iRefs = 0; }
LoadedDriver() { m_pDriver = nullptr; m_iRefs = 0; }
RString GetPath( const RString &sPath ) const;
};
@@ -73,7 +73,7 @@ RageFileDriver *RageFileManager::GetFileDriver( RString sMountpoint )
sMountpoint += '/';
g_Mutex->Lock();
RageFileDriver *pRet = NULL;
RageFileDriver *pRet = nullptr;
for( unsigned i = 0; i < g_pDrivers.size(); ++i )
{
if( g_pDrivers[i]->m_sType == "mountpoints" )
@@ -170,7 +170,7 @@ public:
FDB->AddFile( apDrivers[i]->m_sMountPoint, 0, 0 );
}
};
static RageFileDriverMountpoints *g_Mountpoints = NULL;
static RageFileDriverMountpoints *g_Mountpoints = nullptr;
static RString GetDirOfExecutable( RString argv0 )
{
@@ -311,10 +311,10 @@ RageFileManager::~RageFileManager()
g_pDrivers.clear();
// delete g_Mountpoints; // g_Mountpoints was in g_pDrivers
g_Mountpoints = NULL;
g_Mountpoints = nullptr;
delete g_Mutex;
g_Mutex = NULL;
g_Mutex = nullptr;
}
/* path must be normalized (FixSlashesInPlace, CollapsePath). */
+1 -1
View File
@@ -7,7 +7,7 @@
#include "LuaManager.h"
#include "LocalizedString.h"
RageInput* INPUTMAN = NULL; // globally accessable input device
RageInput* INPUTMAN = nullptr; // globally accessable input device
static Preference<RString> g_sInputDrivers( "InputDrivers", "" ); // "" == DEFAULT_INPUT_DRIVER_LIST
+5 -5
View File
@@ -48,7 +48,7 @@ RageSoundLoadParams::RageSoundLoadParams():
m_bSupportRateChanging(false), m_bSupportPan(false) {}
RageSound::RageSound():
m_Mutex( "RageSound" ), m_pSource(NULL),
m_Mutex( "RageSound" ), m_pSource(nullptr),
m_sFilePath(""), m_Param(), m_iStreamFrame(0),
m_iStoppedSourceFrame(0), m_bPlaying(false),
m_bDeleteWhenFinished(false), m_sError("")
@@ -67,7 +67,7 @@ RageSound::RageSound( const RageSound &cpy ):
{
ASSERT(SOUNDMAN != nullptr);
m_pSource = NULL;
m_pSource = nullptr;
*this = cpy;
}
@@ -90,7 +90,7 @@ RageSound &RageSound::operator=( const RageSound &cpy )
if( cpy.m_pSource )
m_pSource = cpy.m_pSource->Copy();
else
m_pSource = NULL;
m_pSource = nullptr;
m_sFilePath = cpy.m_sFilePath;
@@ -105,7 +105,7 @@ void RageSound::Unload()
LockMut(m_Mutex);
delete m_pSource;
m_pSource = NULL;
m_pSource = nullptr;
m_sFilePath = "";
}
@@ -364,7 +364,7 @@ void RageSound::SoundIsFinishedPlaying()
return;
/* Get our current hardware position. */
int64_t iCurrentHardwareFrame = SOUNDMAN->GetPosition( NULL );
int64_t iCurrentHardwareFrame = SOUNDMAN->GetPosition(nullptr);
m_Mutex.Lock();
+3 -3
View File
@@ -98,7 +98,7 @@ public:
* they can be ignored most of the time, so we continue to work if a file
* is broken or missing.
*/
bool Load( RString sFile, bool bPrecache, const RageSoundLoadParams *pParams = NULL );
bool Load( RString sFile, bool bPrecache, const RageSoundLoadParams *pParams = nullptr );
/* Using this version means the "don't care" about caching. Currently,
* this always will not cache the sound; this may become a preference. */
@@ -121,7 +121,7 @@ public:
RString GetError() const { return m_sError; }
void Play( const RageSoundParams *params=NULL );
void PlayCopy( const RageSoundParams *pParams = NULL ) const;
void PlayCopy( const RageSoundParams *pParams = nullptr ) const;
void Stop();
/* Cleanly pause or unpause the sound. If the sound wasn't already playing,
@@ -173,7 +173,7 @@ private:
RString m_sError;
int GetSourceFrameFromHardwareFrame( int64_t iHardwareFrame, bool *bApproximate = NULL ) const;
int GetSourceFrameFromHardwareFrame( int64_t iHardwareFrame, bool *bApproximate = nullptr ) const;
bool SetPositionFrames( int frames = -1 );
RageSoundParams::StopMode_t GetStopMode() const; // resolves M_AUTO
+2 -2
View File
@@ -33,9 +33,9 @@
static RageMutex g_SoundManMutex("SoundMan");
static Preference<RString> g_sSoundDrivers( "SoundDrivers", "" ); // "" == DEFAULT_SOUND_DRIVER_LIST
RageSoundManager *SOUNDMAN = NULL;
RageSoundManager *SOUNDMAN = nullptr;
RageSoundManager::RageSoundManager(): m_pDriver(NULL), m_fMixVolume(1.0f),
RageSoundManager::RageSoundManager(): m_pDriver(nullptr), m_fMixVolume(1.0f),
m_fVolumeOfNonCriticalSounds(1.0f) {}
static LocalizedString COULDNT_FIND_SOUND_DRIVER( "RageSoundManager", "Couldn't find a sound driver that works" );
+1 -1
View File
@@ -12,7 +12,7 @@ static bool g_bVector = Vector::CheckForVector();
RageSoundMixBuffer::RageSoundMixBuffer()
{
m_iBufSize = m_iBufUsed = 0;
m_pMixbuf = NULL;
m_pMixbuf = nullptr;
m_iOffset = 0;
}
+1 -1
View File
@@ -40,7 +40,7 @@ public:
virtual float GetStreamToSourceRatio() const = 0;
virtual RString GetError() const = 0;
int RetriedRead( float *pBuffer, int iFrames, int *iSourceFrame = NULL, float *fRate = NULL );
int RetriedRead( float *pBuffer, int iFrames, int *iSourceFrame = nullptr, float *fRate = nullptr );
};
#endif
+3 -3
View File
@@ -55,7 +55,7 @@ void RageSoundReader_Chain::AddSound( int iIndex, float fOffsetSecs, float fPan
s.iIndex = iIndex;
s.iOffsetMS = lrintf( fOffsetSecs * 1000 );
s.fPan = fPan;
s.pSound = NULL;
s.pSound = nullptr;
m_aSounds.push_back( s );
}
@@ -130,7 +130,7 @@ void RageSoundReader_Chain::Finish()
LOG->Warn( "Discarded sound with %i channels, not %i",
it->GetNumChannels(), m_iChannels );
delete it;
it = NULL;
it = nullptr;
}
}
}
@@ -240,7 +240,7 @@ void RageSoundReader_Chain::ReleaseSound( Sound *s )
RageSoundReader *&pSound = s->pSound;
delete pSound;
pSound = NULL;
pSound = nullptr;
m_apActiveSounds.erase( it );
}
+2 -2
View File
@@ -18,7 +18,7 @@
RageSoundReader_FileReader *RageSoundReader_FileReader::TryOpenFile( RageFileBasic *pFile, RString &error, RString format, bool &bKeepTrying )
{
RageSoundReader_FileReader *Sample = NULL;
RageSoundReader_FileReader *Sample = nullptr;
#ifndef NO_WAV_SUPPORT
if( !format.CompareNoCase("wav") )
@@ -38,7 +38,7 @@ RageSoundReader_FileReader *RageSoundReader_FileReader::TryOpenFile( RageFileBas
return nullptr;
OpenResult ret = Sample->Open( pFile );
pFile = NULL; // Sample owns it now
pFile = nullptr; // Sample owns it now
if( ret == OPEN_OK )
return Sample;
+1 -1
View File
@@ -34,7 +34,7 @@ public:
/* Open a file. If pPrebuffer is non-NULL, and the file is sufficiently small,
* the (possibly compressed) data will be loaded entirely into memory, and pPrebuffer
* will be set to true. */
static RageSoundReader_FileReader *OpenFile( RString filename, RString &error, bool *pPrebuffer = NULL );
static RageSoundReader_FileReader *OpenFile( RString filename, RString &error, bool *pPrebuffer = nullptr );
protected:
void SetError( RString sError ) const { m_sError = sError; }
+1 -1
View File
@@ -754,7 +754,7 @@ bool RageSoundReader_MP3::MADLIB_rewind()
* set it, then we'll be desynced by a frame after an accurate seek. */
// mad->header_bytes = 0;
mad->first_frame = true;
mad->Stream.this_frame = NULL;
mad->Stream.this_frame = nullptr;
return true;
}
+1 -1
View File
@@ -99,7 +99,7 @@ void RageSoundReader_Merge::Finish( int iPreferredSampleRate )
LOG->Warn( "Discarded sound with %i channels, not %i",
it->GetNumChannels(), m_iChannels );
delete it;
it = NULL;
it = nullptr;
}
else
{
+124 -124
View File
@@ -1,124 +1,124 @@
/*
* Implements properties:
* "Speed" - cause the sound to play faster or slower
* "Pitch" - raise or lower the pitch of the sound
*
* Pitch changing is implemented by combining speed changing and rate changing
* (via resampling). The resampler needs to be changed later than the speed
* changer; this class just controls parameters on the other two real filters.
*/
#include "global.h"
#include "RageSoundReader_PitchChange.h"
#include "RageSoundReader_SpeedChange.h"
#include "RageSoundReader_Resample_Good.h"
#include "RageLog.h"
RageSoundReader_PitchChange::RageSoundReader_PitchChange( RageSoundReader *pSource ):
RageSoundReader_Filter( NULL )
{
m_pSpeedChange = new RageSoundReader_SpeedChange( pSource );
m_pResample = new RageSoundReader_Resample_Good( m_pSpeedChange, m_pSpeedChange->GetSampleRate() );
m_pSource = m_pResample;
m_fSpeedRatio = 1.0f;
m_fPitchRatio = 1.0f;
m_fLastSetSpeedRatio = m_fSpeedRatio;
m_fLastSetPitchRatio = m_fPitchRatio;
}
RageSoundReader_PitchChange::RageSoundReader_PitchChange( const RageSoundReader_PitchChange &cpy ):
RageSoundReader_Filter( cpy )
{
/* The source tree has already been copied. Our source is m_pResample; its source
* is m_pSpeedChange (and its source is a copy of the pSource we were initialized
* with). */
m_pResample = dynamic_cast<RageSoundReader_Resample_Good *>( &*m_pSource );
m_pSpeedChange = dynamic_cast<RageSoundReader_SpeedChange *>( m_pResample->GetSource() );
m_fSpeedRatio = cpy.m_fSpeedRatio;
m_fPitchRatio = cpy.m_fPitchRatio;
m_fLastSetSpeedRatio = cpy.m_fLastSetSpeedRatio;
m_fLastSetPitchRatio = cpy.m_fLastSetPitchRatio;
}
int RageSoundReader_PitchChange::Read( float *pBuf, int iFrames )
{
/* m_pSpeedChange->NextReadWillStep is true if speed changes will be applied
* immediately on the next Read(). When this is true, apply the ratio to the
* resampler and the speed changer simultaneously, so they take effect as
* closely together as possible. */
if( (m_fLastSetSpeedRatio != m_fSpeedRatio || m_fLastSetPitchRatio != m_fPitchRatio) &&
m_pSpeedChange->NextReadWillStep() )
{
float fRate = GetStreamToSourceRatio();
/* This is the simple way: */
// m_pResample->SetRate( m_fPitchRatio );
// m_pSpeedChange->SetSpeedRatio( m_fSpeedRatio / m_fPitchRatio );
/* However, the resampler has a limited granularity due to internal fixed-
* point math, and the actual ratio will be slightly different than what
* we tell it to use. The actual ratio used is fActualPitchRatio. */
m_pResample->SetRate( m_fPitchRatio );
float fActualPitchRatio = m_pResample->GetRate();
float fRequestedSpeedRatio = m_fSpeedRatio / fActualPitchRatio;
m_pSpeedChange->SetSpeedRatio( fRequestedSpeedRatio );
m_fLastSetSpeedRatio = m_fSpeedRatio;
m_fLastSetPitchRatio = m_fPitchRatio;
/* If we just applied a new speed and it caused the ratio to change, return
* no data, so the caller can see the new ratio. */
if( fRate != GetStreamToSourceRatio() )
return 0;
}
return RageSoundReader_Filter::Read( pBuf, iFrames );
}
bool RageSoundReader_PitchChange::SetProperty( const RString &sProperty, float fValue )
{
if( sProperty == "Rate" )
{
/* Don't propagate this. m_pResample will take it, but it's under
* our control. */
return false;
}
if( sProperty == "Speed" )
{
SetSpeedRatio( fValue );
return true;
}
if( sProperty == "Pitch" )
{
SetPitchRatio( fValue );
return true;
}
return RageSoundReader_Filter::SetProperty( sProperty, fValue );
}
/*
* Copyright (c) 2006 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.
*/
/*
* Implements properties:
* "Speed" - cause the sound to play faster or slower
* "Pitch" - raise or lower the pitch of the sound
*
* Pitch changing is implemented by combining speed changing and rate changing
* (via resampling). The resampler needs to be changed later than the speed
* changer; this class just controls parameters on the other two real filters.
*/
#include "global.h"
#include "RageSoundReader_PitchChange.h"
#include "RageSoundReader_SpeedChange.h"
#include "RageSoundReader_Resample_Good.h"
#include "RageLog.h"
RageSoundReader_PitchChange::RageSoundReader_PitchChange( RageSoundReader *pSource ):
RageSoundReader_Filter(nullptr)
{
m_pSpeedChange = new RageSoundReader_SpeedChange( pSource );
m_pResample = new RageSoundReader_Resample_Good( m_pSpeedChange, m_pSpeedChange->GetSampleRate() );
m_pSource = m_pResample;
m_fSpeedRatio = 1.0f;
m_fPitchRatio = 1.0f;
m_fLastSetSpeedRatio = m_fSpeedRatio;
m_fLastSetPitchRatio = m_fPitchRatio;
}
RageSoundReader_PitchChange::RageSoundReader_PitchChange( const RageSoundReader_PitchChange &cpy ):
RageSoundReader_Filter( cpy )
{
/* The source tree has already been copied. Our source is m_pResample; its source
* is m_pSpeedChange (and its source is a copy of the pSource we were initialized
* with). */
m_pResample = dynamic_cast<RageSoundReader_Resample_Good *>( &*m_pSource );
m_pSpeedChange = dynamic_cast<RageSoundReader_SpeedChange *>( m_pResample->GetSource() );
m_fSpeedRatio = cpy.m_fSpeedRatio;
m_fPitchRatio = cpy.m_fPitchRatio;
m_fLastSetSpeedRatio = cpy.m_fLastSetSpeedRatio;
m_fLastSetPitchRatio = cpy.m_fLastSetPitchRatio;
}
int RageSoundReader_PitchChange::Read( float *pBuf, int iFrames )
{
/* m_pSpeedChange->NextReadWillStep is true if speed changes will be applied
* immediately on the next Read(). When this is true, apply the ratio to the
* resampler and the speed changer simultaneously, so they take effect as
* closely together as possible. */
if( (m_fLastSetSpeedRatio != m_fSpeedRatio || m_fLastSetPitchRatio != m_fPitchRatio) &&
m_pSpeedChange->NextReadWillStep() )
{
float fRate = GetStreamToSourceRatio();
/* This is the simple way: */
// m_pResample->SetRate( m_fPitchRatio );
// m_pSpeedChange->SetSpeedRatio( m_fSpeedRatio / m_fPitchRatio );
/* However, the resampler has a limited granularity due to internal fixed-
* point math, and the actual ratio will be slightly different than what
* we tell it to use. The actual ratio used is fActualPitchRatio. */
m_pResample->SetRate( m_fPitchRatio );
float fActualPitchRatio = m_pResample->GetRate();
float fRequestedSpeedRatio = m_fSpeedRatio / fActualPitchRatio;
m_pSpeedChange->SetSpeedRatio( fRequestedSpeedRatio );
m_fLastSetSpeedRatio = m_fSpeedRatio;
m_fLastSetPitchRatio = m_fPitchRatio;
/* If we just applied a new speed and it caused the ratio to change, return
* no data, so the caller can see the new ratio. */
if( fRate != GetStreamToSourceRatio() )
return 0;
}
return RageSoundReader_Filter::Read( pBuf, iFrames );
}
bool RageSoundReader_PitchChange::SetProperty( const RString &sProperty, float fValue )
{
if( sProperty == "Rate" )
{
/* Don't propagate this. m_pResample will take it, but it's under
* our control. */
return false;
}
if( sProperty == "Speed" )
{
SetSpeedRatio( fValue );
return true;
}
if( sProperty == "Pitch" )
{
SetPitchRatio( fValue );
return true;
}
return RageSoundReader_Filter::SetProperty( sProperty, fValue );
}
/*
* Copyright (c) 2006 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.
*/

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