From ebcb124b0ec845346e247fb6b4cab30a0d0ce4cb Mon Sep 17 00:00:00 2001 From: melex750 Date: Tue, 30 Jun 2020 10:12:48 -0400 Subject: [PATCH] Fix failed assert when parameter not initialized fixes #1296 --- src/CBot/CBotDefParam.cpp | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/src/CBot/CBotDefParam.cpp b/src/CBot/CBotDefParam.cpp index fe4a37b6..5e378424 100644 --- a/src/CBot/CBotDefParam.cpp +++ b/src/CBot/CBotDefParam.cpp @@ -64,10 +64,8 @@ CBotDefParam* CBotDefParam::Compile(CBotToken* &p, CBotCStack* pStack) if (list == nullptr) list = param; else list->AddNext(param); // added to the list -// CBotClass* pClass = nullptr;//= CBotClass::Find(p); param->m_typename = p->GetString(); CBotTypResult type = param->m_type = TypeParam(p, pStack); -// if ( type == CBotTypPointer ) type = CBotTypClass; // we must create a new object if (param->m_type.GetType() > 0) { @@ -105,7 +103,6 @@ CBotDefParam* CBotDefParam::Compile(CBotToken* &p, CBotCStack* pStack) if ( type.Eq(CBotTypArrayPointer) ) type.SetType(CBotTypArrayBody); CBotVar* var = CBotVar::Create(pp->GetString(), type); // creates the variable -// if ( pClass ) var->SetClass(pClass); var->SetInit(CBotVar::InitType::IS_POINTER); // mark initialized param->m_nIdent = CBotVar::NextUniqNum(); var->SetUniqNum(param->m_nIdent); @@ -151,13 +148,12 @@ bool CBotDefParam::Execute(CBotVar** ppVars, CBotStack* &pj) if (useDefault || (ppVars == nullptr || ppVars[i] == nullptr)) { - assert(p->m_expr != nullptr); - - useDefault = true; - - if (!p->m_expr->Execute(pile)) return false; // interupt here - - pVar = pile->GetVar(); + useDefault = true; // end of arguments found + if (p->m_expr != nullptr) // has default expression ? + { + if (!p->m_expr->Execute(pile)) return false; // interupt here + pVar = pile->GetVar(); + } } else pVar = ppVars[i];