[colobot] 311/390: Fixed loading challenge solutions and made them read-only

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 1dd3a4d57ea9c4f8077b80cfc2ff05a9ea06def7
Author: krzys-h <krzys_h at interia.pl>
Date:   Mon Apr 6 17:00:22 2015 +0200

    Fixed loading challenge solutions and made them read-only
---
 src/object/brain.cpp     | 5 +++++
 src/object/robotmain.cpp | 2 +-
 src/ui/edit.cpp          | 6 ------
 3 files changed, 6 insertions(+), 7 deletions(-)

diff --git a/src/object/brain.cpp b/src/object/brain.cpp
index e645dfa..5b42e34 100644
--- a/src/object/brain.cpp
+++ b/src/object/brain.cpp
@@ -2831,11 +2831,16 @@ bool CBrain::ReadSoluce(char* filename)
     Program* prog = AddProgram();
 
     if ( !ReadProgram(prog, filename) )  return false;  // load solution
+    prog->readOnly = true;
 
     for(unsigned int i = 0; i < m_program.size(); i++)
     {
+        if(m_program[i] == prog) continue;
+
+        //TODO: This is bad. It's very sensitive to things like \n vs \r\n etc.
         if ( m_program[i]->script->Compare(prog->script) )  // the same already?
         {
+            m_program[i]->readOnly = true; // Mark is as read-only
             RemoveProgram(prog);
             return false;
         }
diff --git a/src/object/robotmain.cpp b/src/object/robotmain.cpp
index c0e3721..c617604 100644
--- a/src/object/robotmain.cpp
+++ b/src/object/robotmain.cpp
@@ -3669,7 +3669,7 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject)
                     }
                     
                     if (soluce && brain != nullptr && line->GetParam("soluce")->IsDefined())
-                        brain->SetSoluceName(const_cast<char*>(line->GetParam("soluce")->AsString().c_str()));
+                        brain->SetSoluceName(const_cast<char*>(line->GetParam("soluce")->AsPath("ai").c_str()));
                     
                     obj->SetResetPosition(obj->GetPosition(0));
                     obj->SetResetAngle(obj->GetAngle(0));
diff --git a/src/ui/edit.cpp b/src/ui/edit.cpp
index 676b80e..35afd50 100644
--- a/src/ui/edit.cpp
+++ b/src/ui/edit.cpp
@@ -1884,12 +1884,6 @@ bool CEdit::WriteText(std::string filename)
 
         buffer[j++] = m_text[i];
 
-        if ( m_text[i] == '\n' )
-        {
-            buffer[j-1] = '\r';
-            buffer[j++] = '\n';  // \r\n (0x0D, 0x0A)
-        }
-
         if ( j >= 1000-1 )
         {
             stream.write(buffer, j);

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