[colobot] 118/377: Moving CBotVarClass function from CBotVar.cpp to CBotVarClass.cpp.

Didier Raboud odyx at moszumanska.debian.org
Wed Mar 30 13:34:05 UTC 2016


This is an automated email from the git hooks/post-receive script.

odyx pushed a commit to branch debian/master
in repository colobot.

commit 2eeab6d4d0c9114f73d753b21838cddfceae14d9
Author: Grunaka <dev at romainbreton.fr>
Date:   Sun Nov 15 22:00:17 2015 +0100

    Moving CBotVarClass function from CBotVar.cpp to CBotVarClass.cpp.
---
 src/CBot/CBotStack.cpp            |   9 -
 src/CBot/CBotVar.cpp              | 373 ------------------------------------
 src/CBot/CBotVar/CBotVarClass.cpp | 391 ++++++++++++++++++++++++++++++++++++++
 src/CBot/CBotVar/CBotVarClass.h   |   9 +-
 4 files changed, 396 insertions(+), 386 deletions(-)

diff --git a/src/CBot/CBotStack.cpp b/src/CBot/CBotStack.cpp
index 63ee21d..87aa0bb 100644
--- a/src/CBot/CBotStack.cpp
+++ b/src/CBot/CBotStack.cpp
@@ -972,15 +972,6 @@ bool CBotVar::Save0State(FILE* pf)
     return WriteString(pf, m_token->GetString());            // and variable name
 }
 
-////////////////////////////////////////////////////////////////////////////////
-bool CBotVarClass::Save1State(FILE* pf)
-{
-    if ( !WriteType(pf, m_type) ) return false;
-    if ( !WriteLong(pf, m_ItemIdent) ) return false;
-
-    return SaveVar(pf, m_pVar);                                // content of the object
-}
-
 namespace
 {
 bool ParseInitType(int rawInitType, CBotVar::InitType* initType)
diff --git a/src/CBot/CBotVar.cpp b/src/CBot/CBotVar.cpp
index 74bfb64..d5c248e 100644
--- a/src/CBot/CBotVar.cpp
+++ b/src/CBot/CBotVar.cpp
@@ -35,7 +35,6 @@
 #include "CBotVar/CBotVarFloat.h"
 #include "CBotVar/CBotVarInt.h"
 
-#include "CBotDefines.h"
 #include "CBotClass.h"
 
 #include <cassert>
@@ -696,378 +695,6 @@ CBotClass* CBotVar::GetClass()
     return nullptr;
 }
 
-////////////////////////////////////////////////////////////////
-
-// copy a variable into another
-void CBotVarClass::Copy(CBotVar* pSrc, bool bName)
-{
-    pSrc = pSrc->GetPointer();                    // if source given by a pointer
-
-    if ( pSrc->GetType() != CBotTypClass )
-        assert(0);
-
-    CBotVarClass*    p = static_cast<CBotVarClass*>(pSrc);
-
-    if (bName)    *m_token    = *p->m_token;
-
-    m_type        = p->m_type;
-    m_binit        = p->m_binit;
-//-    m_bStatic    = p->m_bStatic;
-    m_pClass    = p->m_pClass;
-    if ( p->m_pParent )
-    {
-        assert(0);       // "que faire du pParent";
-    }
-
-//    m_next        = nullptr;
-    m_pUserPtr    = p->m_pUserPtr;
-    m_pMyThis    = nullptr;//p->m_pMyThis;
-    m_ItemIdent = p->m_ItemIdent;
-
-    // keeps indentificator the same (by default)
-    if (m_ident == 0 ) m_ident     = p->m_ident;
-
-    delete        m_pVar;
-    m_pVar        = nullptr;
-
-    CBotVar*    pv = p->m_pVar;
-    while( pv != nullptr )
-    {
-        CBotVar*    pn = CBotVar::Create(pv);
-        pn->Copy( pv );
-        if ( m_pVar == nullptr ) m_pVar = pn;
-        else m_pVar->AddNext(pn);
-
-        pv = pv->GetNext();
-    }
-}
-
-void CBotVarClass::SetItemList(CBotVar* pVar)
-{
-    delete    m_pVar;
-    m_pVar    = pVar;    // replaces the existing pointer
-}
-
-void CBotVarClass::SetIdent(long n)
-{
-    m_ItemIdent = n;
-}
-
-void CBotVarClass::SetClass(CBotClass* pClass)//, int &nIdent)
-{
-    m_type.m_pClass = pClass;
-
-    if ( m_pClass == pClass ) return;
-
-    m_pClass = pClass;
-
-    // initializes the variables associated with this class
-    delete m_pVar;
-    m_pVar = nullptr;
-
-    if (pClass == nullptr) return;
-
-    CBotVar*    pv = pClass->GetVar();                // first on a list
-    while ( pv != nullptr )
-    {
-        // seeks the maximum dimensions of the table
-        CBotInstr*    p  = pv->m_LimExpr;                            // the different formulas
-        if ( p != nullptr )
-        {
-            CBotStack* pile = CBotStack::FirstStack();    // an independent stack
-            int     n = 0;
-            int     max[100];
-
-            while (p != nullptr)
-            {
-                while( pile->IsOk() && !p->Execute(pile) ) ;        // calculate size without interruptions
-                CBotVar*    v = pile->GetVar();                        // result
-                max[n] = v->GetValInt();                            // value
-                n++;
-                p = p->GetNext3();
-            }
-            while (n<100) max[n++] = 0;
-
-            pv->m_type.SetArray( max );                    // stores the limitations
-            pile->Delete();
-        }
-
-        CBotVar*    pn = CBotVar::Create( pv );        // a copy
-        pn->SetStatic(pv->IsStatic());
-        pn->SetPrivate(pv->GetPrivate());
-
-        if ( pv->m_InitExpr != nullptr )                // expression for initialization?
-        {
-#if    STACKMEM
-            CBotStack* pile = CBotStack::FirstStack();    // an independent stack
-
-            while(pile->IsOk() && !pv->m_InitExpr->Execute(pile, pn));    // evaluates the expression without timer
-
-            pile->Delete();
-#else
-            CBotStack* pile = new CBotStack(nullptr);     // an independent stack
-            while(!pv->m_InitExpr->Execute(pile));    // evaluates the expression without timer
-            pn->SetVal( pile->GetVar() ) ;
-            delete pile;
-#endif
-        }
-
-//        pn->SetUniqNum(CBotVar::NextUniqNum());        // enumerate elements
-        pn->SetUniqNum(pv->GetUniqNum());    //++nIdent
-        pn->m_pMyThis = this;
-
-        if ( m_pVar == nullptr) m_pVar = pn;
-        else m_pVar->AddNext( pn );
-        pv = pv->GetNext();
-    }
-}
-
-CBotClass* CBotVarClass::GetClass()
-{
-    return    m_pClass;
-}
-
-
-void CBotVarClass::Maj(void* pUser, bool bContinu)
-{
-/*    if (!bContinu && m_pMyThis != nullptr)
-        m_pMyThis->Maj(pUser, true);*/
-
-    // an update routine exist?
-
-    if ( m_pClass->m_rMaj == nullptr ) return;
-
-    // retrieves the user pointer according to the class
-    // or according to the parameter passed to CBotProgram::Run()
-
-    if ( m_pUserPtr != nullptr) pUser = m_pUserPtr;
-    if ( pUser == OBJECTDELETED ||
-         pUser == OBJECTCREATED ) return;
-    m_pClass->m_rMaj( this, pUser );
-}
-
-CBotVar* CBotVarClass::GetItem(const char* name)
-{
-    CBotVar*    p = m_pVar;
-
-    while ( p != nullptr )
-    {
-        if ( p->GetName() == name ) return p;
-        p = p->GetNext();
-    }
-
-    if ( m_pParent != nullptr ) return m_pParent->GetItem(name);
-    return nullptr;
-}
-
-CBotVar* CBotVarClass::GetItemRef(int nIdent)
-{
-    CBotVar*    p = m_pVar;
-
-    while ( p != nullptr )
-    {
-        if ( p->GetUniqNum() == nIdent ) return p;
-        p = p->GetNext();
-    }
-
-    if ( m_pParent != nullptr ) return m_pParent->GetItemRef(nIdent);
-    return nullptr;
-}
-
-// for the management of an array
-// bExtend can enlarge the table, but not beyond the threshold size of SetArray ()
-
-CBotVar* CBotVarClass::GetItem(int n, bool bExtend)
-{
-    CBotVar*    p = m_pVar;
-
-    if ( n < 0 ) return nullptr;
-    if ( n > MAXARRAYSIZE ) return nullptr;
-
-    if ( m_type.GetLimite() >= 0 && n >= m_type.GetLimite() ) return nullptr;
-
-    if ( p == nullptr && bExtend )
-    {
-        p = CBotVar::Create("", m_type.GetTypElem());
-        m_pVar = p;
-    }
-
-    if ( n == 0 ) return p;
-
-    while ( n-- > 0 )
-    {
-        if ( p->m_next == nullptr )
-        {
-            if ( bExtend ) p->m_next = CBotVar::Create("", m_type.GetTypElem());
-            if ( p->m_next == nullptr ) return nullptr;
-        }
-        p = p->m_next;
-    }
-
-    return p;
-}
-
-CBotVar* CBotVarClass::GetItemList()
-{
-    return m_pVar;
-}
-
-
-CBotString CBotVarClass::GetValString()
-{
-//    if ( m_Indirect != nullptr) return m_Indirect->GetValString();
-
-    CBotString    res;
-
-    if ( m_pClass != nullptr )                        // not used for an array
-    {
-        res = m_pClass->GetName() + CBotString("( ");
-
-        CBotVarClass*    my = this;
-        while ( my != nullptr )
-        {
-            CBotVar*    pv = my->m_pVar;
-            while ( pv != nullptr )
-            {
-                res += pv->GetName() + CBotString("=");
-
-                if ( pv->IsStatic() )
-                {
-                    CBotVar* pvv = my->m_pClass->GetItem(pv->GetName());
-                    res += pvv->GetValString();
-                }
-                else
-                {
-                    res += pv->GetValString();
-                }
-                pv = pv->GetNext();
-                if ( pv != nullptr ) res += ", ";
-            }
-            my = my->m_pParent;
-            if ( my != nullptr )
-            {
-                res += ") extends ";
-                res += my->m_pClass->GetName();
-                res += " (";
-            }
-        }
-    }
-    else
-    {
-        res = "( ";
-
-        CBotVar*    pv = m_pVar;
-        while ( pv != nullptr )
-        {
-            res += pv->GetValString();
-            if ( pv->GetNext() != nullptr ) res += ", ";
-            pv = pv->GetNext();
-        }
-    }
-
-    res += " )";
-    return    res;
-}
-
-void CBotVarClass::IncrementUse()
-{
-    m_CptUse++;
-}
-
-void CBotVarClass::DecrementUse()
-{
-    m_CptUse--;
-    if ( m_CptUse == 0 )
-    {
-        // if there is one, call the destructor
-        // but only if a constructor had been called.
-        if ( m_bConstructor )
-        {
-            m_CptUse++;    // does not return to the destructor
-
-            // m_error is static in the stack
-            // saves the value for return
-            int    err, start, end;
-            CBotStack*    pile = nullptr;
-            err = pile->GetError(start,end);    // stack == nullptr it does not bother!
-
-            pile = CBotStack::FirstStack();        // clears the error
-            CBotVar*    ppVars[1];
-            ppVars[0] = nullptr;
-
-            CBotVar*    pThis  = CBotVar::Create("this", CBotTypNullPointer);
-            pThis->SetPointer(this);
-            CBotVar*    pResult = nullptr;
-
-            CBotString    nom = CBotString("~") + m_pClass->GetName();
-            long        ident = 0;
-
-            while ( pile->IsOk() && !m_pClass->ExecuteMethode(ident, nom, pThis, ppVars, pResult, pile, nullptr)) ;    // waits for the end
-
-            pile->ResetError(err, start,end);
-
-            pile->Delete();
-            delete pThis;
-            m_CptUse--;
-        }
-
-        delete this; // self-destructs!
-    }
-}
-
-CBotVarClass* CBotVarClass::GetPointer()
-{
-    return this;
-}
-
-
-// makes an instance according to its unique number
-
-CBotVarClass* CBotVarClass::Find(long id)
-{
-    CBotVarClass*    p = m_ExClass;
-
-    while ( p != nullptr )
-    {
-        if ( p->m_ItemIdent == id ) return p;
-        p = p->m_ExNext;
-    }
-
-    return nullptr;
-}
-
-bool CBotVarClass::Eq(CBotVar* left, CBotVar* right)
-{
-    CBotVar*    l = left->GetItemList();
-    CBotVar*    r = right->GetItemList();
-
-    while ( l != nullptr && r != nullptr )
-    {
-        if ( l->Ne(l, r) ) return false;
-        l = l->GetNext();
-        r = r->GetNext();
-    }
-
-    // should always arrived simultaneously at the end (same classes)
-    return l == r;
-}
-
-bool CBotVarClass::Ne(CBotVar* left, CBotVar* right)
-{
-    CBotVar*    l = left->GetItemList();
-    CBotVar*    r = right->GetItemList();
-
-    while ( l != nullptr && r != nullptr )
-    {
-        if ( l->Ne(l, r) ) return true;
-        l = l->GetNext();
-        r = r->GetNext();
-    }
-
-    // should always arrived simultaneously at the end (same classes)
-    return l != r;
-}
-
 ///////////////////////////////////////////////////////
 // management of results types
 
diff --git a/src/CBot/CBotVar/CBotVarClass.cpp b/src/CBot/CBotVar/CBotVarClass.cpp
index 73d14ac..f07fbe9 100644
--- a/src/CBot/CBotVar/CBotVarClass.cpp
+++ b/src/CBot/CBotVar/CBotVarClass.cpp
@@ -22,6 +22,10 @@
 
 #include "CBotClass.h"
 
+#include "CBotStack.h"
+
+#include "CBotDefines.h"
+
 // Local include
 
 // Global include
@@ -108,3 +112,390 @@ void CBotVarClass::ConstructorSet()
 {
     m_bConstructor = true;
 }
+
+////////////////////////////////////////////////////////////////////////////////
+void CBotVarClass::Copy(CBotVar* pSrc, bool bName)
+{
+    pSrc = pSrc->GetPointer();                    // if source given by a pointer
+
+    if ( pSrc->GetType() != CBotTypClass )
+        assert(0);
+
+    CBotVarClass*    p = static_cast<CBotVarClass*>(pSrc);
+
+    if (bName)    *m_token    = *p->m_token;
+
+    m_type        = p->m_type;
+    m_binit        = p->m_binit;
+//-    m_bStatic    = p->m_bStatic;
+    m_pClass    = p->m_pClass;
+    if ( p->m_pParent )
+    {
+        assert(0);       // "que faire du pParent";
+    }
+
+//    m_next        = nullptr;
+    m_pUserPtr    = p->m_pUserPtr;
+    m_pMyThis    = nullptr;//p->m_pMyThis;
+    m_ItemIdent = p->m_ItemIdent;
+
+    // keeps indentificator the same (by default)
+    if (m_ident == 0 ) m_ident     = p->m_ident;
+
+    delete        m_pVar;
+    m_pVar        = nullptr;
+
+    CBotVar*    pv = p->m_pVar;
+    while( pv != nullptr )
+    {
+        CBotVar*    pn = CBotVar::Create(pv);
+        pn->Copy( pv );
+        if ( m_pVar == nullptr ) m_pVar = pn;
+        else m_pVar->AddNext(pn);
+
+        pv = pv->GetNext();
+    }
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void CBotVarClass::SetItemList(CBotVar* pVar)
+{
+    delete    m_pVar;
+    m_pVar    = pVar;    // replaces the existing pointer
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void CBotVarClass::SetIdent(long n)
+{
+    m_ItemIdent = n;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void CBotVarClass::SetClass(CBotClass* pClass)//, int &nIdent)
+{
+    m_type.m_pClass = pClass;
+
+    if ( m_pClass == pClass ) return;
+
+    m_pClass = pClass;
+
+    // initializes the variables associated with this class
+    delete m_pVar;
+    m_pVar = nullptr;
+
+    if (pClass == nullptr) return;
+
+    CBotVar*    pv = pClass->GetVar();                // first on a list
+    while ( pv != nullptr )
+    {
+        // seeks the maximum dimensions of the table
+        CBotInstr*    p  = pv->m_LimExpr;                            // the different formulas
+        if ( p != nullptr )
+        {
+            CBotStack* pile = CBotStack::FirstStack();    // an independent stack
+            int     n = 0;
+            int     max[100];
+
+            while (p != nullptr)
+            {
+                while( pile->IsOk() && !p->Execute(pile) ) ;        // calculate size without interruptions
+                CBotVar*    v = pile->GetVar();                        // result
+                max[n] = v->GetValInt();                            // value
+                n++;
+                p = p->GetNext3();
+            }
+            while (n<100) max[n++] = 0;
+
+            pv->m_type.SetArray( max );                    // stores the limitations
+            pile->Delete();
+        }
+
+        CBotVar*    pn = CBotVar::Create( pv );        // a copy
+        pn->SetStatic(pv->IsStatic());
+        pn->SetPrivate(pv->GetPrivate());
+
+        if ( pv->m_InitExpr != nullptr )                // expression for initialization?
+        {
+#if    STACKMEM
+            CBotStack* pile = CBotStack::FirstStack();    // an independent stack
+
+            while(pile->IsOk() && !pv->m_InitExpr->Execute(pile, pn));    // evaluates the expression without timer
+
+            pile->Delete();
+#else
+            CBotStack* pile = new CBotStack(nullptr);     // an independent stack
+            while(!pv->m_InitExpr->Execute(pile));    // evaluates the expression without timer
+            pn->SetVal( pile->GetVar() ) ;
+            delete pile;
+#endif
+        }
+
+//        pn->SetUniqNum(CBotVar::NextUniqNum());        // enumerate elements
+        pn->SetUniqNum(pv->GetUniqNum());    //++nIdent
+        pn->m_pMyThis = this;
+
+        if ( m_pVar == nullptr) m_pVar = pn;
+        else m_pVar->AddNext( pn );
+        pv = pv->GetNext();
+    }
+}
+
+////////////////////////////////////////////////////////////////////////////////
+CBotClass* CBotVarClass::GetClass()
+{
+    return    m_pClass;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void CBotVarClass::Maj(void* pUser, bool bContinu)
+{
+/*    if (!bContinu && m_pMyThis != nullptr)
+        m_pMyThis->Maj(pUser, true);*/
+
+    // an update routine exist?
+
+    if ( m_pClass->m_rMaj == nullptr ) return;
+
+    // retrieves the user pointer according to the class
+    // or according to the parameter passed to CBotProgram::Run()
+
+    if ( m_pUserPtr != nullptr) pUser = m_pUserPtr;
+    if ( pUser == OBJECTDELETED ||
+         pUser == OBJECTCREATED ) return;
+    m_pClass->m_rMaj( this, pUser );
+}
+
+////////////////////////////////////////////////////////////////////////////////
+CBotVar* CBotVarClass::GetItem(const char* name)
+{
+    CBotVar*    p = m_pVar;
+
+    while ( p != nullptr )
+    {
+        if ( p->GetName() == name ) return p;
+        p = p->GetNext();
+    }
+
+    if ( m_pParent != nullptr ) return m_pParent->GetItem(name);
+    return nullptr;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+CBotVar* CBotVarClass::GetItemRef(int nIdent)
+{
+    CBotVar*    p = m_pVar;
+
+    while ( p != nullptr )
+    {
+        if ( p->GetUniqNum() == nIdent ) return p;
+        p = p->GetNext();
+    }
+
+    if ( m_pParent != nullptr ) return m_pParent->GetItemRef(nIdent);
+    return nullptr;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+CBotVar* CBotVarClass::GetItem(int n, bool bExtend)
+{
+    CBotVar*    p = m_pVar;
+
+    if ( n < 0 ) return nullptr;
+    if ( n > MAXARRAYSIZE ) return nullptr;
+
+    if ( m_type.GetLimite() >= 0 && n >= m_type.GetLimite() ) return nullptr;
+
+    if ( p == nullptr && bExtend )
+    {
+        p = CBotVar::Create("", m_type.GetTypElem());
+        m_pVar = p;
+    }
+
+    if ( n == 0 ) return p;
+
+    while ( n-- > 0 )
+    {
+        if ( p->m_next == nullptr )
+        {
+            if ( bExtend ) p->m_next = CBotVar::Create("", m_type.GetTypElem());
+            if ( p->m_next == nullptr ) return nullptr;
+        }
+        p = p->m_next;
+    }
+
+    return p;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+CBotVar* CBotVarClass::GetItemList()
+{
+    return m_pVar;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+CBotString CBotVarClass::GetValString()
+{
+//    if ( m_Indirect != nullptr) return m_Indirect->GetValString();
+
+    CBotString    res;
+
+    if ( m_pClass != nullptr )                        // not used for an array
+    {
+        res = m_pClass->GetName() + CBotString("( ");
+
+        CBotVarClass*    my = this;
+        while ( my != nullptr )
+        {
+            CBotVar*    pv = my->m_pVar;
+            while ( pv != nullptr )
+            {
+                res += pv->GetName() + CBotString("=");
+
+                if ( pv->IsStatic() )
+                {
+                    CBotVar* pvv = my->m_pClass->GetItem(pv->GetName());
+                    res += pvv->GetValString();
+                }
+                else
+                {
+                    res += pv->GetValString();
+                }
+                pv = pv->GetNext();
+                if ( pv != nullptr ) res += ", ";
+            }
+            my = my->m_pParent;
+            if ( my != nullptr )
+            {
+                res += ") extends ";
+                res += my->m_pClass->GetName();
+                res += " (";
+            }
+        }
+    }
+    else
+    {
+        res = "( ";
+
+        CBotVar*    pv = m_pVar;
+        while ( pv != nullptr )
+        {
+            res += pv->GetValString();
+            if ( pv->GetNext() != nullptr ) res += ", ";
+            pv = pv->GetNext();
+        }
+    }
+
+    res += " )";
+    return    res;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void CBotVarClass::IncrementUse()
+{
+    m_CptUse++;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void CBotVarClass::DecrementUse()
+{
+    m_CptUse--;
+    if ( m_CptUse == 0 )
+    {
+        // if there is one, call the destructor
+        // but only if a constructor had been called.
+        if ( m_bConstructor )
+        {
+            m_CptUse++;    // does not return to the destructor
+
+            // m_error is static in the stack
+            // saves the value for return
+            int    err, start, end;
+            CBotStack*    pile = nullptr;
+            err = pile->GetError(start,end);    // stack == nullptr it does not bother!
+
+            pile = CBotStack::FirstStack();        // clears the error
+            CBotVar*    ppVars[1];
+            ppVars[0] = nullptr;
+
+            CBotVar*    pThis  = CBotVar::Create("this", CBotTypNullPointer);
+            pThis->SetPointer(this);
+            CBotVar*    pResult = nullptr;
+
+            CBotString    nom = CBotString("~") + m_pClass->GetName();
+            long        ident = 0;
+
+            while ( pile->IsOk() && !m_pClass->ExecuteMethode(ident, nom, pThis, ppVars, pResult, pile, nullptr)) ;    // waits for the end
+
+            pile->ResetError(err, start,end);
+
+            pile->Delete();
+            delete pThis;
+            m_CptUse--;
+        }
+
+        delete this; // self-destructs!
+    }
+}
+
+////////////////////////////////////////////////////////////////////////////////
+CBotVarClass* CBotVarClass::GetPointer()
+{
+    return this;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+CBotVarClass* CBotVarClass::Find(long id)
+{
+    CBotVarClass*    p = m_ExClass;
+
+    while ( p != nullptr )
+    {
+        if ( p->m_ItemIdent == id ) return p;
+        p = p->m_ExNext;
+    }
+
+    return nullptr;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+bool CBotVarClass::Eq(CBotVar* left, CBotVar* right)
+{
+    CBotVar*    l = left->GetItemList();
+    CBotVar*    r = right->GetItemList();
+
+    while ( l != nullptr && r != nullptr )
+    {
+        if ( l->Ne(l, r) ) return false;
+        l = l->GetNext();
+        r = r->GetNext();
+    }
+
+    // should always arrived simultaneously at the end (same classes)
+    return l == r;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+bool CBotVarClass::Ne(CBotVar* left, CBotVar* right)
+{
+    CBotVar*    l = left->GetItemList();
+    CBotVar*    r = right->GetItemList();
+
+    while ( l != nullptr && r != nullptr )
+    {
+        if ( l->Ne(l, r) ) return true;
+        l = l->GetNext();
+        r = r->GetNext();
+    }
+
+    // should always arrived simultaneously at the end (same classes)
+    return l != r;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+bool CBotVarClass::Save1State(FILE* pf)
+{
+    if ( !WriteType(pf, m_type) ) return false;
+    if ( !WriteLong(pf, m_ItemIdent) ) return false;
+
+    return SaveVar(pf, m_pVar);                                // content of the object
+}
diff --git a/src/CBot/CBotVar/CBotVarClass.h b/src/CBot/CBotVar/CBotVarClass.h
index b6a256f..b7b878f 100644
--- a/src/CBot/CBotVar/CBotVarClass.h
+++ b/src/CBot/CBotVar/CBotVarClass.h
@@ -47,7 +47,7 @@ public:
     ~CBotVarClass();
 
     /*!
-     * \brief Copy
+     * \brief Copy Copy a variable into another.
      * \param pSrc
      * \param bName
      */
@@ -80,9 +80,10 @@ public:
     CBotVar* GetItemRef(int nIdent) override;
 
     /*!
-     * \brief GetItem
+     * \brief GetItem For the management of an array.
      * \param n
-     * \param bExtend
+     * \param bExtend can enlarge the table, but not beyond the threshold size
+     * of SetArray().
      * \return
      */
     CBotVar* GetItem(int n, bool bExtend) override;
@@ -142,7 +143,7 @@ public:
     void SetIdent(long n) override;
 
     /*!
-     * \brief Find
+     * \brief Find Makes an instance according to its unique number.
      * \param id
      * \return
      */

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-games/colobot.git



More information about the Pkg-games-commits mailing list