The big NULL replacement party part 4.

...okay, not as big of a commit.
This commit is contained in:
Jason Felds
2013-05-03 23:24:23 -04:00
parent a3f37dc2b4
commit 328c41eec0
8 changed files with 154 additions and 154 deletions
+4 -4
View File
@@ -532,7 +532,7 @@ const ulg crc_table[256] = {
ulg crc32(ulg crc, const uch *buf, size_t len)
{
if (buf==NULL) return 0L;
if (buf== nullptr) return 0L;
crc = crc ^ 0xffffffffL;
while (len >= 8) {DO8(buf); len -= 8;}
if (len) do {DO1(buf);} while (--len);
@@ -935,12 +935,12 @@ ZRESULT TZip::Add(const TCHAR *odstzn, const TCHAR *src,unsigned long flags)
// Keep a copy of the zipfileinfo, for our end-of-zip directory
char *cextra = new char[zfi.cext]; memcpy(cextra,zfi.cextra,zfi.cext); zfi.cextra=cextra;
TZipFileInfo *pzfi = new TZipFileInfo; memcpy(pzfi,&zfi,sizeof(zfi));
if (zfis==NULL)
if (zfis== nullptr)
zfis=pzfi;
else
{
TZipFileInfo *z=zfis;
while (z->nxt!=NULL)
while (z->nxt!= nullptr)
z=z->nxt;
z->nxt=pzfi;
}
@@ -954,7 +954,7 @@ ZRESULT TZip::AddCentral()
ulg pos_at_start_of_central = writ;
//ulg tot_unc_size=0, tot_compressed_size=0;
bool okay=true;
for (TZipFileInfo *zfi=zfis; zfi!=NULL; )
for (TZipFileInfo *zfi=zfis; zfi!= nullptr; )
{
if (okay)
{
+6 -6
View File
@@ -755,14 +755,14 @@ public:
static int GetText( T* p, lua_State *L ) { lua_pushstring(L, p->m_sText ); return 1; }
static int GetIndex( T* p, lua_State *L ) { lua_pushnumber(L, p->m_iIndex ); return 1; }
static int GetMultiPlayer( T* p, lua_State *L ) { lua_pushnumber(L, p->m_MultiPlayer); return 1; }
static int GetStyle( T* p, lua_State *L ) { if(p->m_pStyle==NULL) lua_pushnil(L); else {Style *pStyle = (Style*)p->m_pStyle; pStyle->PushSelf(L);} return 1; }
static int GetStyle( T* p, lua_State *L ) { if(p->m_pStyle== nullptr) lua_pushnil(L); else {Style *pStyle = (Style*)p->m_pStyle; pStyle->PushSelf(L);} return 1; }
static int GetScreen( T* p, lua_State *L ) { lua_pushstring(L, p->m_sScreen ); return 1; }
static int GetProfileID( T* p, lua_State *L ) { lua_pushstring(L, p->m_sProfileID ); return 1; }
static int GetSong( T* p, lua_State *L ) { if(p->m_pSong==NULL) lua_pushnil(L); else p->m_pSong->PushSelf(L); return 1; }
static int GetSteps( T* p, lua_State *L ) { if(p->m_pSteps==NULL) lua_pushnil(L); else p->m_pSteps->PushSelf(L); return 1; }
static int GetCourse( T* p, lua_State *L ) { if(p->m_pCourse==NULL) lua_pushnil(L); else p->m_pCourse->PushSelf(L); return 1; }
static int GetTrail( T* p, lua_State *L ) { if(p->m_pTrail==NULL) lua_pushnil(L); else p->m_pTrail->PushSelf(L); return 1; }
static int GetCharacter( T* p, lua_State *L ) { if(p->m_pCharacter==NULL) lua_pushnil(L); else p->m_pCharacter->PushSelf(L); return 1; }
static int GetSong( T* p, lua_State *L ) { if(p->m_pSong== nullptr) lua_pushnil(L); else p->m_pSong->PushSelf(L); return 1; }
static int GetSteps( T* p, lua_State *L ) { if(p->m_pSteps== nullptr) lua_pushnil(L); else p->m_pSteps->PushSelf(L); return 1; }
static int GetCourse( T* p, lua_State *L ) { if(p->m_pCourse== nullptr) lua_pushnil(L); else p->m_pCourse->PushSelf(L); return 1; }
static int GetTrail( T* p, lua_State *L ) { if(p->m_pTrail== nullptr) lua_pushnil(L); else p->m_pTrail->PushSelf(L); return 1; }
static int GetCharacter( T* p, lua_State *L ) { if(p->m_pCharacter== nullptr) lua_pushnil(L); else p->m_pCharacter->PushSelf(L); return 1; }
static int GetSongGroup( T* p, lua_State *L ) { lua_pushstring(L, p->m_sSongGroup ); return 1; }
static int GetUrl( T* p, lua_State *L ) { lua_pushstring(L, p->m_sUrl ); return 1; }
static int GetAnnouncer( T* p, lua_State *L ) { lua_pushstring(L, p->m_sAnnouncer ); return 1; }
+4 -4
View File
@@ -338,11 +338,11 @@ void NetworkSyncManager::StartRequest( short position )
Steps * tSteps;
tSteps = GAMESTATE->m_pCurSteps[PLAYER_1];
if( tSteps!=NULL && GAMESTATE->IsPlayerEnabled(PLAYER_1) )
if( tSteps!= nullptr && GAMESTATE->IsPlayerEnabled(PLAYER_1) )
ctr = uint8_t(ctr+tSteps->GetMeter()*16);
tSteps = GAMESTATE->m_pCurSteps[PLAYER_2];
if( tSteps!=NULL && GAMESTATE->IsPlayerEnabled(PLAYER_2) )
if( tSteps!= nullptr && GAMESTATE->IsPlayerEnabled(PLAYER_2) )
ctr = uint8_t( ctr+tSteps->GetMeter() );
m_packet.Write1( ctr );
@@ -350,11 +350,11 @@ void NetworkSyncManager::StartRequest( short position )
ctr=0;
tSteps = GAMESTATE->m_pCurSteps[PLAYER_1];
if( tSteps!=NULL && GAMESTATE->IsPlayerEnabled(PLAYER_1) )
if( tSteps!= nullptr && GAMESTATE->IsPlayerEnabled(PLAYER_1) )
ctr = uint8_t( ctr + (int)tSteps->GetDifficulty()*16 );
tSteps = GAMESTATE->m_pCurSteps[PLAYER_2];
if( tSteps!=NULL && GAMESTATE->IsPlayerEnabled(PLAYER_2) )
if( tSteps!= nullptr && GAMESTATE->IsPlayerEnabled(PLAYER_2) )
ctr = uint8_t( ctr + (int)tSteps->GetDifficulty() );
m_packet.Write1( ctr );
+1 -1
View File
@@ -799,7 +799,7 @@ void Player::Update( float fDeltaTime )
//LOG->Trace( "Player::Update(%f)", fDeltaTime );
if( GAMESTATE->m_pCurSong==NULL || IsOniDead() )
if( GAMESTATE->m_pCurSong== nullptr || IsOniDead() )
return;
ActorFrame::Update( fDeltaTime );
+1 -1
View File
@@ -772,7 +772,7 @@ void Profile::IncrementCategoryPlayCount( StepsType st, RankingCategory rc )
#define WARN_AND_BREAK_M(m) { WARN_M(m); break; }
#define LOAD_NODE(X) { \
const XNode* X = xml->GetChild(#X); \
if( X==NULL ) LOG->Warn("Failed to read section " #X); \
if( X== nullptr ) LOG->Warn("Failed to read section " #X); \
else Load##X##FromNode(X); }
ProfileLoadResult Profile::LoadAllFromDir( RString sDir, bool bRequireSignature )
+1 -1
View File
@@ -757,7 +757,7 @@ void Sprite::SetSecondsIntoAnimation( float fSeconds )
RString Sprite::GetTexturePath() const
{
if( m_pTexture==NULL )
if( m_pTexture== nullptr )
return RString();
return m_pTexture->GetID().filename;
+136 -136
View File
@@ -1,136 +1,136 @@
/* XmlFile - Simple XML reading and writing. */
#ifndef XML_FILE_H
#define XML_FILE_H
#include <map>
struct DateTime;
class RageFileBasic;
struct lua_State;
class XNodeValue
{
public:
virtual ~XNodeValue() { }
virtual XNodeValue *Copy() const = 0;
virtual void GetValue( RString &out ) const = 0;
virtual void GetValue( int &out ) const = 0;
virtual void GetValue( float &out ) const = 0;
virtual void GetValue( bool &out ) const = 0;
virtual void GetValue( unsigned &out ) const = 0;
virtual void PushValue( lua_State *L ) const = 0;
template<typename T>
T GetValue() const { T val; GetValue(val); return val; }
virtual void SetValue( const RString &v ) = 0;
virtual void SetValue( int v ) = 0;
virtual void SetValue( float v ) = 0;
virtual void SetValue( unsigned v ) = 0;
virtual void SetValueFromStack( lua_State *L ) = 0;
};
class XNodeStringValue: public XNodeValue
{
public:
RString m_sValue;
XNodeValue *Copy() const { return new XNodeStringValue( *this ); }
void GetValue( RString &out ) const;
void GetValue( int &out ) const;
void GetValue( float &out ) const;
void GetValue( bool &out ) const;
void GetValue( unsigned &out ) const;
void PushValue( lua_State *L ) const;
void SetValue( const RString &v );
void SetValue( int v );
void SetValue( float v );
void SetValue( unsigned v );
void SetValueFromStack( lua_State *L );
};
typedef map<RString,XNodeValue*> XAttrs;
class XNode;
typedef vector<XNode*> XNodes;
/** @brief Loop through each node. */
#define FOREACH_Attr( pNode, Var ) \
for( XAttrs::iterator Var = (pNode)->m_attrs.begin(); \
Var != (pNode)->m_attrs.end(); \
++Var )
/** @brief Loop through each node, using a constant iterator. */
#define FOREACH_CONST_Attr( pNode, Var ) \
for( XAttrs::const_iterator Var = (pNode)->m_attrs.begin(); \
Var != (pNode)->m_attrs.end(); \
++Var )
/** @brief Loop through each child. */
#define FOREACH_Child( pNode, Var ) \
XNode *Var = NULL; \
for( XNodes::iterator Var##Iter = (pNode)->m_childs.begin(); \
Var = (Var##Iter != (pNode)->m_childs.end())? *Var##Iter:NULL, \
Var##Iter != (pNode)->m_childs.end(); \
++Var##Iter )
/** @brief Loop through each child, using a constant iterator. */
#define FOREACH_CONST_Child( pNode, Var ) \
const XNode *Var = NULL; \
for( XNodes::const_iterator Var##Iter = (pNode)->m_childs.begin(); \
Var = (Var##Iter != (pNode)->m_childs.end())? *Var##Iter:NULL, \
Var##Iter != (pNode)->m_childs.end(); \
++Var##Iter )
class XNode
{
public:
RString m_sName;
XNodes m_childs; // child nodes
XAttrs m_attrs; // attributes
void SetName( const RString &sName ) { m_sName = sName; }
const RString &GetName() const { return m_sName; }
static const RString TEXT_ATTRIBUTE;
template <typename T>
void GetTextValue( T &out ) const { GetAttrValue(TEXT_ATTRIBUTE, out); }
// in own attribute list
const XNodeValue *GetAttr( const RString &sAttrName ) const;
XNodeValue *GetAttr( const RString &sAttrName );
template <typename T>
bool GetAttrValue( const RString &sName, T &out ) const { const XNodeValue *pAttr=GetAttr(sName); if(pAttr==NULL) return false; pAttr->GetValue(out); return true; }
bool PushAttrValue( lua_State *L, const RString &sName ) const;
// in one level child nodes
const XNode *GetChild( const RString &sName ) const;
XNode *GetChild( const RString &sName );
template <typename T>
bool GetChildValue( const RString &sName, T &out ) const { const XNode *pChild=GetChild(sName); if(pChild==NULL) return false; pChild->GetTextValue(out); return true; }
bool PushChildValue( lua_State *L, const RString &sName ) const;
// modify DOM
template <typename T>
XNode *AppendChild( const RString &sName, T value ) { XNode *p=AppendChild(sName); p->AppendAttr(XNode::TEXT_ATTRIBUTE, value); return p; }
XNode *AppendChild( const RString &sName ) { XNode *p=new XNode(sName); return AppendChild(p); }
XNode *AppendChild( XNode *node );
bool RemoveChild( XNode *node, bool bDelete = true );
XNodeValue *AppendAttrFrom( const RString &sName, XNodeValue *pValue, bool bOverwrite = true );
XNodeValue *AppendAttr( const RString &sName );
template <typename T>
XNodeValue *AppendAttr( const RString &sName, T value ) { XNodeValue *pVal = AppendAttr( sName ); pVal->SetValue( value ); return pVal; }
bool RemoveAttr( const RString &sName );
XNode();
explicit XNode( const RString &sName );
XNode( const XNode &cpy );
~XNode() { Free(); }
void Clear();
private:
void Free();
XNode &operator=( const XNode &cpy ); // don't use
};
#endif
/* XmlFile - Simple XML reading and writing. */
#ifndef XML_FILE_H
#define XML_FILE_H
#include <map>
struct DateTime;
class RageFileBasic;
struct lua_State;
class XNodeValue
{
public:
virtual ~XNodeValue() { }
virtual XNodeValue *Copy() const = 0;
virtual void GetValue( RString &out ) const = 0;
virtual void GetValue( int &out ) const = 0;
virtual void GetValue( float &out ) const = 0;
virtual void GetValue( bool &out ) const = 0;
virtual void GetValue( unsigned &out ) const = 0;
virtual void PushValue( lua_State *L ) const = 0;
template<typename T>
T GetValue() const { T val; GetValue(val); return val; }
virtual void SetValue( const RString &v ) = 0;
virtual void SetValue( int v ) = 0;
virtual void SetValue( float v ) = 0;
virtual void SetValue( unsigned v ) = 0;
virtual void SetValueFromStack( lua_State *L ) = 0;
};
class XNodeStringValue: public XNodeValue
{
public:
RString m_sValue;
XNodeValue *Copy() const { return new XNodeStringValue( *this ); }
void GetValue( RString &out ) const;
void GetValue( int &out ) const;
void GetValue( float &out ) const;
void GetValue( bool &out ) const;
void GetValue( unsigned &out ) const;
void PushValue( lua_State *L ) const;
void SetValue( const RString &v );
void SetValue( int v );
void SetValue( float v );
void SetValue( unsigned v );
void SetValueFromStack( lua_State *L );
};
typedef map<RString,XNodeValue*> XAttrs;
class XNode;
typedef vector<XNode*> XNodes;
/** @brief Loop through each node. */
#define FOREACH_Attr( pNode, Var ) \
for( XAttrs::iterator Var = (pNode)->m_attrs.begin(); \
Var != (pNode)->m_attrs.end(); \
++Var )
/** @brief Loop through each node, using a constant iterator. */
#define FOREACH_CONST_Attr( pNode, Var ) \
for( XAttrs::const_iterator Var = (pNode)->m_attrs.begin(); \
Var != (pNode)->m_attrs.end(); \
++Var )
/** @brief Loop through each child. */
#define FOREACH_Child( pNode, Var ) \
XNode *Var = NULL; \
for( XNodes::iterator Var##Iter = (pNode)->m_childs.begin(); \
Var = (Var##Iter != (pNode)->m_childs.end())? *Var##Iter:NULL, \
Var##Iter != (pNode)->m_childs.end(); \
++Var##Iter )
/** @brief Loop through each child, using a constant iterator. */
#define FOREACH_CONST_Child( pNode, Var ) \
const XNode *Var = NULL; \
for( XNodes::const_iterator Var##Iter = (pNode)->m_childs.begin(); \
Var = (Var##Iter != (pNode)->m_childs.end())? *Var##Iter:NULL, \
Var##Iter != (pNode)->m_childs.end(); \
++Var##Iter )
class XNode
{
public:
RString m_sName;
XNodes m_childs; // child nodes
XAttrs m_attrs; // attributes
void SetName( const RString &sName ) { m_sName = sName; }
const RString &GetName() const { return m_sName; }
static const RString TEXT_ATTRIBUTE;
template <typename T>
void GetTextValue( T &out ) const { GetAttrValue(TEXT_ATTRIBUTE, out); }
// in own attribute list
const XNodeValue *GetAttr( const RString &sAttrName ) const;
XNodeValue *GetAttr( const RString &sAttrName );
template <typename T>
bool GetAttrValue( const RString &sName, T &out ) const { const XNodeValue *pAttr=GetAttr(sName); if(pAttr== nullptr) return false; pAttr->GetValue(out); return true; }
bool PushAttrValue( lua_State *L, const RString &sName ) const;
// in one level child nodes
const XNode *GetChild( const RString &sName ) const;
XNode *GetChild( const RString &sName );
template <typename T>
bool GetChildValue( const RString &sName, T &out ) const { const XNode *pChild=GetChild(sName); if(pChild== nullptr) return false; pChild->GetTextValue(out); return true; }
bool PushChildValue( lua_State *L, const RString &sName ) const;
// modify DOM
template <typename T>
XNode *AppendChild( const RString &sName, T value ) { XNode *p=AppendChild(sName); p->AppendAttr(XNode::TEXT_ATTRIBUTE, value); return p; }
XNode *AppendChild( const RString &sName ) { XNode *p=new XNode(sName); return AppendChild(p); }
XNode *AppendChild( XNode *node );
bool RemoveChild( XNode *node, bool bDelete = true );
XNodeValue *AppendAttrFrom( const RString &sName, XNodeValue *pValue, bool bOverwrite = true );
XNodeValue *AppendAttr( const RString &sName );
template <typename T>
XNodeValue *AppendAttr( const RString &sName, T value ) { XNodeValue *pVal = AppendAttr( sName ); pVal->SetValue( value ); return pVal; }
bool RemoveAttr( const RString &sName );
XNode();
explicit XNode( const RString &sName );
XNode( const XNode &cpy );
~XNode() { Free(); }
void Clear();
private:
void Free();
XNode &operator=( const XNode &cpy ); // don't use
};
#endif
+1 -1
View File
@@ -196,7 +196,7 @@ RageMovieTexture *MakeRageMovieTexture( RageTextureID ID )
RString Driver;
RageMovieTexture *ret = NULL;
for( unsigned i=0; ret==NULL && i<DriversToTry.size(); ++i )
for( unsigned i=0; ret== nullptr && i<DriversToTry.size(); ++i )
{
Driver = DriversToTry[i];
LOG->Trace( "Initializing driver: %s", Driver.c_str() );