Remove remaining occurences of "this == nullptr" (#828)

dev-buzzingcars
krzys-h 2016-11-11 19:45:57 +01:00
parent 191151eb7b
commit 35d60aaae5
3 changed files with 17 additions and 9 deletions

View File

@ -363,8 +363,7 @@ bool CBotProgram::RestoreState(FILE* pf)
} }
// retrieves the stack from the memory // retrieves the stack from the memory
// uses a nullptr pointer (m_stack) but it's ok like that m_stack = CBotStack::AllocateStack();
// TODO: no it's not okay like that! but it looks like it doesn't get optimized out at least ~krzys_h
if (!m_stack->RestoreState(pf, m_stack)) return false; if (!m_stack->RestoreState(pf, m_stack)) return false;
m_stack->SetProgram(this); // bases for routines m_stack->SetProgram(this); // bases for routines

View File

@ -192,8 +192,18 @@ bool CBotStack::Return(CBotStack* pfils)
m_var = pfils->m_var; // result transmitted m_var = pfils->m_var; // result transmitted
pfils->m_var = nullptr; // not to destroy the variable pfils->m_var = nullptr; // not to destroy the variable
if (m_next != nullptr) m_next->Delete();m_next = nullptr; // releases the stack above if (m_next != nullptr)
if (m_next2 != nullptr) m_next2->Delete();m_next2 = nullptr; // also the second stack (catch) {
// releases the stack above
m_next->Delete();
m_next = nullptr;
}
if (m_next2 != nullptr)
{
// also the second stack (catch)
m_next2->Delete();
m_next2 = nullptr;
}
return IsOk(); // interrupted if error return IsOk(); // interrupted if error
} }
@ -731,8 +741,7 @@ bool CBotStack::RestoreState(FILE* pf, CBotStack* &pStack)
if (!ReadWord(pf, w)) return false; if (!ReadWord(pf, w)) return false;
if ( w == 0 ) return true; // 0 - terminator if ( w == 0 ) return true; // 0 - terminator
if ( this == nullptr ) pStack = AllocateStack(); pStack = AddStack();
else pStack = AddStack();
if ( w == 2 ) // 2 - m_next2 if ( w == 2 ) // 2 - m_next2
{ {

View File

@ -199,7 +199,7 @@ const CBotToken& CBotToken::operator=(const CBotToken& src)
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
int CBotToken::GetType() int CBotToken::GetType()
{ {
if (this == nullptr) return 0; assert(this != nullptr);
if (m_type == TokenTypKeyWord) return m_keywordId; if (m_type == TokenTypKeyWord) return m_keywordId;
return m_type; return m_type;
} }
@ -225,14 +225,14 @@ void CBotToken::SetString(const std::string& name)
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
int CBotToken::GetStart() int CBotToken::GetStart()
{ {
if (this == nullptr) return -1; assert(this != nullptr);
return m_start; return m_start;
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
int CBotToken::GetEnd() int CBotToken::GetEnd()
{ {
if (this == nullptr) return -1; assert(this != nullptr);
return m_end; return m_end;
} }