mirror of
https://github.com/ptitSeb/Serious-Engine
synced 2024-11-25 11:45:53 +01:00
Change remaining "if (this!=NULL)" to "ASSERT(this!=NULL)"
Also changed all "if (this==NULL) return;"s. Fixes some -Wtautological-undefined-compare warnings. Quoting Clang: "'this' pointer cannot be null in well-defined C++ code; comparison may be assumed to always evaluate to false"
This commit is contained in:
parent
24d61d1ccc
commit
5badefaf90
|
@ -173,16 +173,14 @@ BOOL CAnimData::IsAutoFreed(void)
|
||||||
// Reference counting functions
|
// Reference counting functions
|
||||||
void CAnimData::AddReference(void)
|
void CAnimData::AddReference(void)
|
||||||
{
|
{
|
||||||
if (this!=NULL) {
|
ASSERT(this!=NULL);
|
||||||
MarkUsed();
|
MarkUsed();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CAnimData::RemReference(void)
|
void CAnimData::RemReference(void)
|
||||||
{
|
{
|
||||||
if (this!=NULL) {
|
ASSERT(this!=NULL);
|
||||||
RemReference_internal();
|
RemReference_internal();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CAnimData::RemReference_internal(void)
|
void CAnimData::RemReference_internal(void)
|
||||||
|
|
|
@ -44,9 +44,7 @@ CConsole::CConsole(void)
|
||||||
// Destructor.
|
// Destructor.
|
||||||
CConsole::~CConsole(void)
|
CConsole::~CConsole(void)
|
||||||
{
|
{
|
||||||
if (this==NULL) {
|
ASSERT(this!=NULL);
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (con_fLog!=NULL) {
|
if (con_fLog!=NULL) {
|
||||||
fclose(con_fLog);
|
fclose(con_fLog);
|
||||||
con_fLog = NULL;
|
con_fLog = NULL;
|
||||||
|
@ -102,25 +100,19 @@ void CConsole::Initialize(const CTFileName &fnmLog, INDEX ctCharsPerLine, INDEX
|
||||||
// Get current console buffer.
|
// Get current console buffer.
|
||||||
const char *CConsole::GetBuffer(void)
|
const char *CConsole::GetBuffer(void)
|
||||||
{
|
{
|
||||||
if (this==NULL) {
|
ASSERT(this!=NULL);
|
||||||
return "";
|
|
||||||
}
|
|
||||||
return con_strBuffer+(con_ctLines-con_ctLinesPrinted)*(con_ctCharsPerLine+1);
|
return con_strBuffer+(con_ctLines-con_ctLinesPrinted)*(con_ctCharsPerLine+1);
|
||||||
}
|
}
|
||||||
INDEX CConsole::GetBufferSize(void)
|
INDEX CConsole::GetBufferSize(void)
|
||||||
{
|
{
|
||||||
if (this==NULL) {
|
ASSERT(this!=NULL);
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
return (con_ctCharsPerLine+1)*con_ctLines+1;
|
return (con_ctCharsPerLine+1)*con_ctLines+1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Discard timing info for last lines
|
// Discard timing info for last lines
|
||||||
void CConsole::DiscardLastLineTimes(void)
|
void CConsole::DiscardLastLineTimes(void)
|
||||||
{
|
{
|
||||||
if (this==NULL) {
|
ASSERT(this!=NULL);
|
||||||
return;
|
|
||||||
}
|
|
||||||
for(INDEX i=0; i<con_ctLines; i++) {
|
for(INDEX i=0; i<con_ctLines; i++) {
|
||||||
con_atmLines[i] = -10000.0f;
|
con_atmLines[i] = -10000.0f;
|
||||||
}
|
}
|
||||||
|
@ -129,9 +121,7 @@ void CConsole::DiscardLastLineTimes(void)
|
||||||
// Get number of lines newer than given time
|
// Get number of lines newer than given time
|
||||||
INDEX CConsole::NumberOfLinesAfter(TIME tmLast)
|
INDEX CConsole::NumberOfLinesAfter(TIME tmLast)
|
||||||
{
|
{
|
||||||
if (this==NULL) {
|
ASSERT(this!=NULL);
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
// clamp console variable
|
// clamp console variable
|
||||||
con_iLastLines = Clamp( con_iLastLines, 0, (INDEX)CONSOLE_MAXLASTLINES);
|
con_iLastLines = Clamp( con_iLastLines, 0, (INDEX)CONSOLE_MAXLASTLINES);
|
||||||
// find number of last console lines to be displayed on screen
|
// find number of last console lines to be displayed on screen
|
||||||
|
@ -146,9 +136,7 @@ INDEX CConsole::NumberOfLinesAfter(TIME tmLast)
|
||||||
// Get one of last lines
|
// Get one of last lines
|
||||||
CTString CConsole::GetLastLine(INDEX iLine)
|
CTString CConsole::GetLastLine(INDEX iLine)
|
||||||
{
|
{
|
||||||
if (this==NULL) {
|
ASSERT(this!=NULL);
|
||||||
return "";
|
|
||||||
}
|
|
||||||
if (iLine>=con_ctLinesPrinted) {
|
if (iLine>=con_ctLinesPrinted) {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
@ -166,9 +154,7 @@ CTString CConsole::GetLastLine(INDEX iLine)
|
||||||
// clear one given line in buffer
|
// clear one given line in buffer
|
||||||
void CConsole::ClearLine(INDEX iLine)
|
void CConsole::ClearLine(INDEX iLine)
|
||||||
{
|
{
|
||||||
if (this==NULL) {
|
ASSERT(this!=NULL);
|
||||||
return;
|
|
||||||
}
|
|
||||||
// line must be valid
|
// line must be valid
|
||||||
ASSERT(iLine>=0 && iLine<con_ctLines);
|
ASSERT(iLine>=0 && iLine<con_ctLines);
|
||||||
// get start of line
|
// get start of line
|
||||||
|
@ -183,9 +169,7 @@ void CConsole::ClearLine(INDEX iLine)
|
||||||
// scroll buffer up, discarding lines at the start
|
// scroll buffer up, discarding lines at the start
|
||||||
void CConsole::ScrollBufferUp(INDEX ctLines)
|
void CConsole::ScrollBufferUp(INDEX ctLines)
|
||||||
{
|
{
|
||||||
if (this==NULL) {
|
ASSERT(this!=NULL);
|
||||||
return;
|
|
||||||
}
|
|
||||||
ASSERT(ctLines>0 && ctLines<con_ctLines);
|
ASSERT(ctLines>0 && ctLines<con_ctLines);
|
||||||
// move buffer up
|
// move buffer up
|
||||||
memmove(
|
memmove(
|
||||||
|
@ -207,9 +191,7 @@ void CConsole::ScrollBufferUp(INDEX ctLines)
|
||||||
// Add a line of text to console
|
// Add a line of text to console
|
||||||
void CConsole::PutString(const char *strString)
|
void CConsole::PutString(const char *strString)
|
||||||
{
|
{
|
||||||
if (this==NULL) {
|
ASSERT(this!=NULL);
|
||||||
return;
|
|
||||||
}
|
|
||||||
// synchronize access to console
|
// synchronize access to console
|
||||||
CTSingleLock slConsole(&con_csConsole, TRUE);
|
CTSingleLock slConsole(&con_csConsole, TRUE);
|
||||||
|
|
||||||
|
@ -265,9 +247,7 @@ void CConsole::PutString(const char *strString)
|
||||||
// Close console log file buffers (call only when force-exiting!)
|
// Close console log file buffers (call only when force-exiting!)
|
||||||
void CConsole::CloseLog(void)
|
void CConsole::CloseLog(void)
|
||||||
{
|
{
|
||||||
if (this==NULL) {
|
ASSERT(this!=NULL);
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (con_fLog!=NULL) {
|
if (con_fLog!=NULL) {
|
||||||
fclose(con_fLog);
|
fclose(con_fLog);
|
||||||
}
|
}
|
||||||
|
|
|
@ -2036,10 +2036,7 @@ static CStaticStackArray<CSentEvent> _aseSentEvents; // delayed events
|
||||||
/* Send an event to this entity. */
|
/* Send an event to this entity. */
|
||||||
void CEntity::SendEvent(const CEntityEvent &ee)
|
void CEntity::SendEvent(const CEntityEvent &ee)
|
||||||
{
|
{
|
||||||
if (this==NULL) {
|
ASSERT(this!=NULL);
|
||||||
ASSERT(FALSE);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
CSentEvent &se = _aseSentEvents.Push();
|
CSentEvent &se = _aseSentEvents.Push();
|
||||||
se.se_penEntity = this;
|
se.se_penEntity = this;
|
||||||
se.se_peeEvent = ((CEntityEvent&)ee).MakeCopy(); // discard const qualifier
|
se.se_peeEvent = ((CEntityEvent&)ee).MakeCopy(); // discard const qualifier
|
||||||
|
|
|
@ -694,18 +694,16 @@ inline CEntity& CEntityPointer::operator*(void) const { return *ep_pen; }
|
||||||
/////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////
|
||||||
// Reference counting functions
|
// Reference counting functions
|
||||||
inline void CEntity::AddReference(void) {
|
inline void CEntity::AddReference(void) {
|
||||||
if (this!=NULL) {
|
ASSERT(this!=NULL);
|
||||||
ASSERT(en_ctReferences>=0);
|
ASSERT(en_ctReferences>=0);
|
||||||
en_ctReferences++;
|
en_ctReferences++;
|
||||||
}
|
|
||||||
};
|
};
|
||||||
inline void CEntity::RemReference(void) {
|
inline void CEntity::RemReference(void) {
|
||||||
if (this!=NULL) {
|
ASSERT(this!=NULL);
|
||||||
ASSERT(en_ctReferences>0);
|
ASSERT(en_ctReferences>0);
|
||||||
en_ctReferences--;
|
en_ctReferences--;
|
||||||
if(en_ctReferences==0) {
|
if(en_ctReferences==0) {
|
||||||
delete this;
|
delete this;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -64,14 +64,12 @@ CEntityClass::~CEntityClass(void)
|
||||||
/////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////
|
||||||
// Reference counting functions
|
// Reference counting functions
|
||||||
void CEntityClass::AddReference(void) {
|
void CEntityClass::AddReference(void) {
|
||||||
if (this!=NULL) {
|
ASSERT(this!=NULL);
|
||||||
MarkUsed();
|
MarkUsed();
|
||||||
}
|
|
||||||
};
|
};
|
||||||
void CEntityClass::RemReference(void) {
|
void CEntityClass::RemReference(void) {
|
||||||
if (this!=NULL) {
|
ASSERT(this!=NULL);
|
||||||
_pEntityClassStock->Release(this);
|
_pEntityClassStock->Release(this);
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -655,7 +655,8 @@ extern void FreeUnusedStock(void)
|
||||||
*/
|
*/
|
||||||
void CNetworkTimerHandler::HandleTimer(void)
|
void CNetworkTimerHandler::HandleTimer(void)
|
||||||
{
|
{
|
||||||
if (this==NULL || _bTempNetwork) {
|
ASSERT(this!=NULL);
|
||||||
|
if (_bTempNetwork) {
|
||||||
return; // this can happen during NET_MakeDefaultState_t()!
|
return; // this can happen during NET_MakeDefaultState_t()!
|
||||||
}
|
}
|
||||||
// enable stream handling during timer
|
// enable stream handling during timer
|
||||||
|
@ -902,7 +903,8 @@ void CNetworkLibrary::Init(const CTString &strGameID)
|
||||||
*/
|
*/
|
||||||
void CNetworkLibrary::AddTimerHandler(void)
|
void CNetworkLibrary::AddTimerHandler(void)
|
||||||
{
|
{
|
||||||
if (this==NULL || _bTempNetwork) {
|
ASSERT(this!=NULL);
|
||||||
|
if (_bTempNetwork) {
|
||||||
return; // this can happen during NET_MakeDefaultState_t()!
|
return; // this can happen during NET_MakeDefaultState_t()!
|
||||||
}
|
}
|
||||||
_pTimer->AddHandler(&ga_thTimerHandler);
|
_pTimer->AddHandler(&ga_thTimerHandler);
|
||||||
|
@ -912,7 +914,8 @@ void CNetworkLibrary::AddTimerHandler(void)
|
||||||
*/
|
*/
|
||||||
void CNetworkLibrary::RemoveTimerHandler(void)
|
void CNetworkLibrary::RemoveTimerHandler(void)
|
||||||
{
|
{
|
||||||
if (this==NULL || _bTempNetwork) {
|
ASSERT(this!=NULL);
|
||||||
|
if (_bTempNetwork) {
|
||||||
return; // this can happen during NET_MakeDefaultState_t()!
|
return; // this can happen during NET_MakeDefaultState_t()!
|
||||||
}
|
}
|
||||||
_pTimer->RemHandler(&ga_thTimerHandler);
|
_pTimer->RemHandler(&ga_thTimerHandler);
|
||||||
|
@ -1390,7 +1393,8 @@ void CNetworkLibrary::TogglePause(void)
|
||||||
// test if game is paused
|
// test if game is paused
|
||||||
BOOL CNetworkLibrary::IsPaused(void)
|
BOOL CNetworkLibrary::IsPaused(void)
|
||||||
{
|
{
|
||||||
if (this==NULL || _bTempNetwork) {
|
ASSERT(this!=NULL);
|
||||||
|
if (_bTempNetwork) {
|
||||||
return TRUE; // this can happen during NET_MakeDefaultState_t()!
|
return TRUE; // this can happen during NET_MakeDefaultState_t()!
|
||||||
}
|
}
|
||||||
return ga_sesSessionState.ses_bPause;
|
return ga_sesSessionState.ses_bPause;
|
||||||
|
@ -1427,7 +1431,8 @@ void CNetworkLibrary::SetLocalPause(BOOL bPause)
|
||||||
|
|
||||||
BOOL CNetworkLibrary::GetLocalPause(void)
|
BOOL CNetworkLibrary::GetLocalPause(void)
|
||||||
{
|
{
|
||||||
if (this==NULL || _bTempNetwork) {
|
ASSERT(this!=NULL);
|
||||||
|
if (_bTempNetwork) {
|
||||||
return TRUE; // this can happen during NET_MakeDefaultState_t()!
|
return TRUE; // this can happen during NET_MakeDefaultState_t()!
|
||||||
}
|
}
|
||||||
return ga_bLocalPause;
|
return ga_bLocalPause;
|
||||||
|
@ -2033,7 +2038,8 @@ void CNetworkLibrary::SendActionsToServer(void)
|
||||||
*/
|
*/
|
||||||
void CNetworkLibrary::TimerLoop(void)
|
void CNetworkLibrary::TimerLoop(void)
|
||||||
{
|
{
|
||||||
if (this==NULL || _bTempNetwork) {
|
ASSERT(this!=NULL);
|
||||||
|
if (_bTempNetwork) {
|
||||||
return; // this can happen during NET_MakeDefaultState_t()!
|
return; // this can happen during NET_MakeDefaultState_t()!
|
||||||
}
|
}
|
||||||
_pfNetworkProfile.StartTimer(CNetworkProfile::PTI_TIMERLOOP);
|
_pfNetworkProfile.StartTimer(CNetworkProfile::PTI_TIMERLOOP);
|
||||||
|
|
|
@ -252,16 +252,14 @@ SLONG CSoundData::GetUsedMemory(void)
|
||||||
// Add one reference
|
// Add one reference
|
||||||
void CSoundData::AddReference(void)
|
void CSoundData::AddReference(void)
|
||||||
{
|
{
|
||||||
if (this!=NULL) {
|
ASSERT(this!=NULL);
|
||||||
MarkUsed();
|
MarkUsed();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Remove one reference
|
// Remove one reference
|
||||||
void CSoundData::RemReference(void)
|
void CSoundData::RemReference(void)
|
||||||
{
|
{
|
||||||
if (this!=NULL) {
|
ASSERT(this!=NULL);
|
||||||
_pSoundStock->Release(this);
|
_pSoundStock->Release(this);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1233,6 +1233,7 @@ BOOL CSoundLibrary::SetEnvironment( INDEX iEnvNo, FLOAT fEnvSize/*=0*/)
|
||||||
// mute all sounds (erase playing buffer(s) and supress mixer)
|
// mute all sounds (erase playing buffer(s) and supress mixer)
|
||||||
void CSoundLibrary::Mute(void)
|
void CSoundLibrary::Mute(void)
|
||||||
{
|
{
|
||||||
|
ASSERT(this!=NULL);
|
||||||
// stop all IFeel effects
|
// stop all IFeel effects
|
||||||
IFeel_StopEffect(NULL);
|
IFeel_StopEffect(NULL);
|
||||||
|
|
||||||
|
@ -1244,7 +1245,7 @@ void CSoundLibrary::Mute(void)
|
||||||
|
|
||||||
#ifdef PLATFORM_WIN32
|
#ifdef PLATFORM_WIN32
|
||||||
// erase direct sound buffer (waveout will shut-up by itself), but skip if there's no more sound library
|
// erase direct sound buffer (waveout will shut-up by itself), but skip if there's no more sound library
|
||||||
if( this==NULL || !sl_bUsingDirectSound) return;
|
if(!sl_bUsingDirectSound) return;
|
||||||
|
|
||||||
// synchronize access to sounds
|
// synchronize access to sounds
|
||||||
CTSingleLock slSounds(&sl_csSound, TRUE);
|
CTSingleLock slSounds(&sl_csSound, TRUE);
|
||||||
|
|
|
@ -936,10 +936,11 @@ void CWorld::TriangularizeForVertices( CBrushVertexSelection &selVertex)
|
||||||
// add this entity to prediction
|
// add this entity to prediction
|
||||||
void CEntity::AddToPrediction(void)
|
void CEntity::AddToPrediction(void)
|
||||||
{
|
{
|
||||||
// this function may be called even for NULLs - so ignore it
|
// this function may be called even for NULLs - TODO: fix those cases
|
||||||
if (this==NULL) {
|
// (The compiler is free to assume that "this" is never NULL and optimize
|
||||||
return;
|
// based on that assumption. For example, an "if (this==NULL) {...}" could
|
||||||
}
|
// be optimized away completely.)
|
||||||
|
ASSERT(this!=NULL);
|
||||||
// if already added
|
// if already added
|
||||||
if (en_ulFlags&ENF_WILLBEPREDICTED) {
|
if (en_ulFlags&ENF_WILLBEPREDICTED) {
|
||||||
// do nothing
|
// do nothing
|
||||||
|
|
|
@ -35,8 +35,9 @@ CPathNode::~CPathNode(void)
|
||||||
// get name of this node
|
// get name of this node
|
||||||
const CTString &CPathNode::GetName(void)
|
const CTString &CPathNode::GetName(void)
|
||||||
{
|
{
|
||||||
|
ASSERT(this!=NULL);
|
||||||
static CTString strNone="<none>";
|
static CTString strNone="<none>";
|
||||||
if (this==NULL || pn_pnmMarker==NULL) {
|
if (pn_pnmMarker==NULL) {
|
||||||
return strNone;
|
return strNone;
|
||||||
} else {
|
} else {
|
||||||
return pn_pnmMarker->GetName();
|
return pn_pnmMarker->GetName();
|
||||||
|
@ -46,7 +47,8 @@ const CTString &CPathNode::GetName(void)
|
||||||
// get link with given index or null if no more (for iteration along the graph)
|
// get link with given index or null if no more (for iteration along the graph)
|
||||||
CPathNode *CPathNode::GetLink(INDEX i)
|
CPathNode *CPathNode::GetLink(INDEX i)
|
||||||
{
|
{
|
||||||
if (this==NULL || pn_pnmMarker==NULL) {
|
ASSERT(this!=NULL);
|
||||||
|
if (pn_pnmMarker==NULL) {
|
||||||
ASSERT(FALSE);
|
ASSERT(FALSE);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,8 +50,9 @@ CPathNode::~CPathNode(void)
|
||||||
// get name of this node
|
// get name of this node
|
||||||
const CTString &CPathNode::GetName(void)
|
const CTString &CPathNode::GetName(void)
|
||||||
{
|
{
|
||||||
|
ASSERT(this!=NULL);
|
||||||
static CTString strNone="<none>";
|
static CTString strNone="<none>";
|
||||||
if (this==NULL || pn_pnmMarker==NULL) {
|
if (pn_pnmMarker==NULL) {
|
||||||
return strNone;
|
return strNone;
|
||||||
} else {
|
} else {
|
||||||
return pn_pnmMarker->GetName();
|
return pn_pnmMarker->GetName();
|
||||||
|
@ -61,10 +62,7 @@ const CTString &CPathNode::GetName(void)
|
||||||
// get link with given index or null if no more (for iteration along the graph)
|
// get link with given index or null if no more (for iteration along the graph)
|
||||||
CPathNode *CPathNode::GetLink(INDEX i)
|
CPathNode *CPathNode::GetLink(INDEX i)
|
||||||
{
|
{
|
||||||
if (this==NULL || pn_pnmMarker==NULL) {
|
ASSERT(this!=NULL && pn_pnmMarker!=NULL);
|
||||||
ASSERT(FALSE);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
CNavigationMarker *pnm = pn_pnmMarker->GetLink(i);
|
CNavigationMarker *pnm = pn_pnmMarker->GetLink(i);
|
||||||
if (pnm==NULL) {
|
if (pnm==NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
|
@ -69,7 +69,7 @@ INDEX CDlgPgInfoAttachingPlacement::GetCurrentAttachingPlacement(void)
|
||||||
void CDlgPgInfoAttachingPlacement::SetPlacementReferenceVertex(INDEX iCenter, INDEX iFront, INDEX iUp)
|
void CDlgPgInfoAttachingPlacement::SetPlacementReferenceVertex(INDEX iCenter, INDEX iFront, INDEX iUp)
|
||||||
{
|
{
|
||||||
// patch for calling before page is refreshed
|
// patch for calling before page is refreshed
|
||||||
if(this == NULL) return;
|
ASSERT(this!=NULL);
|
||||||
CModelerView *pModelerView = CModelerView::GetActiveView();
|
CModelerView *pModelerView = CModelerView::GetActiveView();
|
||||||
if(pModelerView == NULL) return;
|
if(pModelerView == NULL) return;
|
||||||
CModelerDoc* pDoc = pModelerView->GetDocument();
|
CModelerDoc* pDoc = pModelerView->GetDocument();
|
||||||
|
|
Loading…
Reference in New Issue
Block a user