Merge pull request #793 from melex750/dev
Fix some bugs in CBOT This fixes https://github.com/colobot/colobot/issues/728#issuecomment-205039570 and #626master
commit
3e30ccfdfa
|
@ -121,6 +121,15 @@ CBotInstr* CBotDefArray::Compile(CBotToken* &p, CBotCStack* pStack, CBotTypResul
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (pStk->IsOk()) while (true) // mark initialized
|
||||
{
|
||||
var = var->GetItem(0, true);
|
||||
if (var == nullptr) break;
|
||||
if (var->GetType() == CBotTypArrayPointer) continue;
|
||||
if (var->GetType() <= CBotTypString) var->SetInit(CBotVar::InitType::DEF);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (pStk->IsOk()) return pStack->Return(inst, pStk);
|
||||
|
|
|
@ -103,6 +103,7 @@ bool CBotInstrMethode::ExecuteVar(CBotVar* &pVar, CBotStack* &pj, CBotToken* pre
|
|||
if (pVar->GetPointer() == nullptr)
|
||||
{
|
||||
pj->SetError(CBotErrNull, prevToken);
|
||||
return pj->Return(pile1);
|
||||
}
|
||||
|
||||
if (pile1->IfStep()) return false;
|
||||
|
|
|
@ -98,7 +98,7 @@ CBotInstr* CBotListArray::Compile(CBotToken* &p, CBotCStack* pStack, CBotTypResu
|
|||
}
|
||||
}
|
||||
|
||||
inst->m_expr->AddNext3(i);
|
||||
inst->m_expr->AddNext3b(i);
|
||||
|
||||
if ( p->GetType() == ID_COMMA ) continue;
|
||||
if ( p->GetType() == ID_CLBLK ) break;
|
||||
|
@ -114,10 +114,10 @@ CBotInstr* CBotListArray::Compile(CBotToken* &p, CBotCStack* pStack, CBotTypResu
|
|||
{
|
||||
goto error;
|
||||
}
|
||||
CBotVar* pv = pStk->GetVar(); // result of the expression
|
||||
|
||||
if (pv == nullptr || (!TypesCompatibles( type, pv->GetTypResult()) &&
|
||||
!(type.Eq(CBotTypPointer) && pv->GetTypResult().Eq(CBotTypNullPointer)) ))
|
||||
CBotTypResult valType = pStk->GetTypResult();
|
||||
|
||||
if (!TypeCompatible(valType, type, ID_ASS) )
|
||||
{
|
||||
pStk->SetError(CBotErrBadType1, p->GetStart());
|
||||
goto error;
|
||||
|
@ -133,15 +133,14 @@ CBotInstr* CBotListArray::Compile(CBotToken* &p, CBotCStack* pStack, CBotTypResu
|
|||
goto error;
|
||||
}
|
||||
|
||||
CBotVar* pv = pStk->GetVar(); // result of the expression
|
||||
CBotTypResult valType = pStk->GetTypResult();
|
||||
|
||||
if (pv == nullptr || (!TypesCompatibles( type, pv->GetTypResult()) &&
|
||||
!(type.Eq(CBotTypPointer) && pv->GetTypResult().Eq(CBotTypNullPointer)) ))
|
||||
if (!TypeCompatible(valType, type, ID_ASS) )
|
||||
{
|
||||
pStk->SetError(CBotErrBadType1, p->GetStart());
|
||||
goto error;
|
||||
}
|
||||
inst->m_expr->AddNext3(i);
|
||||
inst->m_expr->AddNext3b(i);
|
||||
|
||||
if (p->GetType() == ID_COMMA) continue;
|
||||
if (p->GetType() == ID_CLBLK) break;
|
||||
|
@ -175,7 +174,7 @@ bool CBotListArray::Execute(CBotStack* &pj, CBotVar* pVar)
|
|||
|
||||
int n = 0;
|
||||
|
||||
for (; p != nullptr ; n++, p = p->GetNext3())
|
||||
for (; p != nullptr ; n++, p = p->GetNext3b())
|
||||
{
|
||||
if (pile1->GetState() > n) continue;
|
||||
|
||||
|
@ -207,7 +206,7 @@ void CBotListArray::RestoreState(CBotStack* &pj, bool bMain)
|
|||
|
||||
int state = pile->GetState();
|
||||
|
||||
while(state-- > 0) p = p->GetNext3() ;
|
||||
while(state-- > 0) p = p->GetNext3b() ;
|
||||
|
||||
p->RestoreState(pile, bMain); // size calculation //interrupted!
|
||||
}
|
||||
|
|
|
@ -62,7 +62,7 @@ protected:
|
|||
virtual std::map<std::string, CBotInstr*> GetDebugLinks() override;
|
||||
|
||||
private:
|
||||
//! An expression for an element others are linked with CBotInstr :: m_next3;
|
||||
//! An expression for an element others are linked with CBotInstr :: m_next3b;
|
||||
CBotInstr* m_expr;
|
||||
};
|
||||
|
||||
|
|
|
@ -50,7 +50,11 @@ CBotInstr* CBotNew::Compile(CBotToken* &p, CBotCStack* pStack)
|
|||
if (!IsOfType(p, ID_NEW)) return nullptr;
|
||||
|
||||
// verifies that the token is a class name
|
||||
if (p->GetType() != TokenTypVar) return nullptr;
|
||||
if (p->GetType() != TokenTypVar)
|
||||
{
|
||||
pStack->SetError(CBotErrBadNew, p);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
CBotClass* pClass = CBotClass::Find(p);
|
||||
if (pClass == nullptr)
|
||||
|
|
|
@ -214,6 +214,7 @@ bool CBotProgram::Run(void* pUser, int timer)
|
|||
m_error = m_stack->GetError(m_errorStart, m_errorEnd);
|
||||
m_stack->Delete();
|
||||
m_stack = nullptr;
|
||||
CBotClass::FreeLock(this);
|
||||
return true; // execution is finished!
|
||||
}
|
||||
|
||||
|
@ -226,6 +227,7 @@ void CBotProgram::Stop()
|
|||
m_stack->Delete();
|
||||
m_stack = nullptr;
|
||||
m_entryPoint = nullptr;
|
||||
CBotClass::FreeLock(this);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
Loading…
Reference in New Issue