From 9bc7c47d77f2fc6b419c81d2a98b88a17eb36bc9 Mon Sep 17 00:00:00 2001 From: krzys-h Date: Tue, 7 Apr 2015 13:27:11 +0200 Subject: [PATCH] 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 08e4c963..65a7d298 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(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(i+1))->AsBool(false)) + { + Program* prog = brain->GetOrAddProgram(i); + prog->readOnly = true; + } + } } return obj;