[colobot] 81/145: Fix RestoreState to assign IDs to instance vars
    Didier Raboud 
    odyx at moszumanska.debian.org
       
    Mon Jul 11 12:56:20 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 c19f97bc24c2c5532db84fd2ba6664fba22f8838
Author: melex750 <melex750 at users.noreply.github.com>
Date:   Tue May 24 10:09:44 2016 -0400
    Fix RestoreState to assign IDs to instance vars
---
 src/CBot/CBotStack.cpp | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
diff --git a/src/CBot/CBotStack.cpp b/src/CBot/CBotStack.cpp
index 746976b..3170fb7 100644
--- a/src/CBot/CBotStack.cpp
+++ b/src/CBot/CBotStack.cpp
@@ -805,6 +805,8 @@ bool CBotVar::RestoreState(FILE* pf, CBotVar* &pVar)
 
         CBotToken token(name, std::string());
 
+        bool isClass = false;
+
         switch (w)
         {
         case CBotTypInt:
@@ -826,6 +828,7 @@ bool CBotVar::RestoreState(FILE* pf, CBotVar* &pVar)
 
         // returns an intrinsic object or element of an array
         case CBotTypIntrinsic:
+            isClass = true;
         case CBotTypArrayBody:
             {
                 CBotTypResult    r;
@@ -843,6 +846,17 @@ bool CBotVar::RestoreState(FILE* pf, CBotVar* &pVar)
                     if ( !RestoreState(pf, (static_cast<CBotVarClass*>(pNew))->m_pVar)) return false;
                     pNew->SetIdent(id);
 
+                    if (isClass && p == nullptr) // set id for each item in this instance
+                    {
+                        CBotVar* pVars = pNew->GetItemList();
+                        long itemId = 1;
+                        while (pVars != nullptr)
+                        {
+                            pVars->m_ident = itemId++;
+                            pVars = pVars->GetNext();
+                        }
+                    }
+
                     if ( p != nullptr )
                     {
                         delete pNew;
-- 
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