[colobot] 318/390: Fixed saving readonly attribute (#454)

Didier Raboud odyx at moszumanska.debian.org
Fri Jun 12 14:21:59 UTC 2015


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

odyx pushed a commit to branch upstream/latest
in repository colobot.

commit 9bc7c47d77f2fc6b419c81d2a98b88a17eb36bc9
Author: krzys-h <krzys_h at interia.pl>
Date:   Tue Apr 7 13:27:11 2015 +0200

    Fixed saving readonly attribute (#454)
---
 src/object/robotmain.cpp | 25 +++++++++++++++++++++++--
 1 file changed, 23 insertions(+), 2 deletions(-)

diff --git a/src/object/robotmain.cpp b/src/object/robotmain.cpp
index 08e4c96..65a7d29 100644
--- a/src/object/robotmain.cpp
+++ b/src/object/robotmain.cpp
@@ -4911,6 +4911,15 @@ void CRobotMain::IOWriteObject(CLevelParserLine* line, CObject* obj)
         {
             line->AddParam("run", new CLevelParserParam(run+1));
         }
+
+        auto programs = brain->GetPrograms();
+        for(unsigned int i = 0; i < programs.size(); i++)
+        {
+            if(programs[i]->readOnly)
+            {
+                line->AddParam("scriptReadOnly"+boost::lexical_cast<std::string>(i+1), new CLevelParserParam(true));
+            }
+        }
     }
 }
 
@@ -5092,13 +5101,25 @@ CObject* CRobotMain::IOReadObject(CLevelParserLine *line, const char* filename,
         CAuto* automat = obj->GetAuto();
         if (automat != nullptr)
             automat->Start(run);  // starts the film
+    }
 
-        CBrain* brain = obj->GetBrain();
-        if (brain != nullptr)
+    CBrain* brain = obj->GetBrain();
+    if (brain != nullptr)
+    {
+        if(run != -1)
         {
             Program* program = brain->GetOrAddProgram(run-1);
             brain->SetScriptRun(program);  // marks the program to be started
         }
+
+        for(unsigned int i = 0; i <= 999; i++)
+        {
+            if(line->GetParam("scriptReadOnly"+boost::lexical_cast<std::string>(i+1))->AsBool(false))
+            {
+                Program* prog = brain->GetOrAddProgram(i);
+                prog->readOnly = true;
+            }
+        }
     }
 
     return obj;

-- 
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