예제 #1
0
파일: CBotVar.cpp 프로젝트: Grunaka/colobot
void CBotVar::SetInit(CBotVar::InitType initType)
{
    m_binit = initType;
    if (initType == CBotVar::InitType::IS_POINTER ) m_binit = CBotVar::InitType::DEF;                    // cas spécial

    if ( m_type.Eq(CBotTypPointer) && initType == CBotVar::InitType::IS_POINTER )
    {
        CBotVarClass* instance = GetPointer();
        if ( instance == nullptr )
        {
            instance = new CBotVarClass(CBotToken(), m_type);
//            instance->SetClass((static_cast<CBotVarPointer*>(this))->m_classes);
            SetPointer(instance);
        }
        instance->SetInit(CBotVar::InitType::DEF);
    }

    if ( m_type.Eq(CBotTypClass) || m_type.Eq(CBotTypIntrinsic) )
    {
        CBotVar*    p = (static_cast<CBotVarClass*>(this))->m_pVar;
        while( p != nullptr )
        {
            p->SetInit(initType);
            p->m_pMyThis = static_cast<CBotVarClass*>(this);
            p = p->GetNext();
        }
    }
}
예제 #2
0
CBotVar* CBotVarArray::GetItem(int n, bool bExtend)
{
    if ( m_pInstance == nullptr )
    {
        if ( !bExtend ) return nullptr;
        // creates an instance of the table

        CBotVarClass* instance = new CBotVarClass(CBotToken(), m_type);
        SetPointer( instance );
    }
    return m_pInstance->GetItem(n, bExtend);
}