[colobot] 183/390: Level state loading via CLevelParser

Didier Raboud odyx at moszumanska.debian.org
Fri Jun 12 14:21:43 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 8c84f012c6b435b523fd19b7c4b289f62fff8bd5
Author: krzys-h <krzys_h at interia.pl>
Date:   Mon Nov 10 17:15:34 2014 +0100

    Level state loading via CLevelParser
---
 src/object/auto/auto.cpp          |  12 ++--
 src/object/auto/auto.h            |   2 +-
 src/object/auto/autoconvert.cpp   |  11 ++--
 src/object/auto/autoconvert.h     |   2 +-
 src/object/auto/autoderrick.cpp   |  11 ++--
 src/object/auto/autoderrick.h     |   2 +-
 src/object/auto/autodestroyer.cpp |  11 ++--
 src/object/auto/autodestroyer.h   |   2 +-
 src/object/auto/autoegg.cpp       |  17 +++---
 src/object/auto/autoegg.h         |   2 +-
 src/object/auto/autoenergy.cpp    |  11 ++--
 src/object/auto/autoenergy.h      |   2 +-
 src/object/auto/autofactory.cpp   |  11 ++--
 src/object/auto/autofactory.h     |   2 +-
 src/object/auto/autoinfo.cpp      |  11 ++--
 src/object/auto/autoinfo.h        |   2 +-
 src/object/auto/autolabo.cpp      |  13 ++---
 src/object/auto/autolabo.h        |   2 +-
 src/object/auto/automush.cpp      |  13 ++---
 src/object/auto/automush.h        |   2 +-
 src/object/auto/autonest.cpp      |  13 ++---
 src/object/auto/autonest.h        |   2 +-
 src/object/auto/autonuclear.cpp   |  11 ++--
 src/object/auto/autonuclear.h     |   2 +-
 src/object/auto/autopara.cpp      |  11 ++--
 src/object/auto/autopara.h        |   2 +-
 src/object/auto/autorepair.cpp    |  11 ++--
 src/object/auto/autorepair.h      |   2 +-
 src/object/auto/autoresearch.cpp  |  13 ++---
 src/object/auto/autoresearch.h    |   2 +-
 src/object/auto/autosafe.cpp      |  11 ++--
 src/object/auto/autosafe.h        |   2 +-
 src/object/auto/autotower.cpp     |  21 ++++---
 src/object/auto/autotower.h       |   2 +-
 src/object/brain.cpp              |   4 +-
 src/object/brain.h                |   2 +-
 src/object/motion/motion.cpp      |   8 +--
 src/object/motion/motion.h        |   2 +-
 src/object/object.cpp             | 113 ++++++++++++++++++++------------------
 src/object/object.h               |   2 +-
 src/object/robotmain.cpp          |  92 ++++++++++++++-----------------
 src/object/robotmain.h            |   4 +-
 src/physics/physics.cpp           |   8 +--
 src/physics/physics.h             |   2 +-
 44 files changed, 230 insertions(+), 253 deletions(-)

diff --git a/src/object/auto/auto.cpp b/src/object/auto/auto.cpp
index a8386c5..4f12f2f 100644
--- a/src/object/auto/auto.cpp
+++ b/src/object/auto/auto.cpp
@@ -440,13 +440,13 @@ bool CAuto::Write(CLevelParserLine* line)
 
 // Return all settings to the controller.
 
-bool CAuto::Read(char *line)
+bool CAuto::Read(CLevelParserLine* line)
 {
-    m_type = static_cast<ObjectType>(OpInt(line, "aType", OBJECT_NULL));
-    m_bBusy = OpInt(line, "aBusy", 0);
-    m_time = OpFloat(line, "aTime", 0.0f);
-    m_progressTime = OpFloat(line, "aProgressTime", 0.0f);
-    m_progressTotal = OpFloat(line, "aProgressTotal", 0.0f);
+    m_type = line->GetParam("aType")->AsObjectType();
+    m_bBusy = line->GetParam("aBusy")->AsBool();
+    m_time = line->GetParam("aTime")->AsFloat();
+    m_progressTime = line->GetParam("aProgressTime")->AsFloat();
+    m_progressTotal = line->GetParam("aProgressTotal")->AsFloat();
 
     return false;
 }
diff --git a/src/object/auto/auto.h b/src/object/auto/auto.h
index 610c39b..7053aa2 100644
--- a/src/object/auto/auto.h
+++ b/src/object/auto/auto.h
@@ -82,7 +82,7 @@ public:
     virtual void    SetMotor(bool bMotor);
 
     virtual bool    Write(CLevelParserLine* line);
-    virtual bool    Read(char *line);
+    virtual bool    Read(CLevelParserLine* line);
 
 protected:
     void        CheckInterface(Ui::CWindow *pw, EventType event, bool bState);
diff --git a/src/object/auto/autoconvert.cpp b/src/object/auto/autoconvert.cpp
index c588b94..23e41a1 100644
--- a/src/object/auto/autoconvert.cpp
+++ b/src/object/auto/autoconvert.cpp
@@ -380,15 +380,14 @@ bool CAutoConvert::Write(CLevelParserLine* line)
 
 // Restores all parameters of the controller.
 
-bool CAutoConvert::Read(char *line)
+bool CAutoConvert::Read(CLevelParserLine* line)
 {
-    if ( OpInt(line, "aExist", 0) == 0 )  return false;
+    if ( !line->GetParam("aExist")->AsBool(false) )  return false;
 
     CAuto::Read(line);
-
-    m_phase = static_cast< AutoConvertPhase >(OpInt(line, "aPhase", ACP_WAIT));
-    m_progress = OpFloat(line, "aProgress", 0.0f);
-    m_speed = OpFloat(line, "aSpeed", 1.0f);
+    m_phase = static_cast< AutoConvertPhase >(line->GetParam("aPhase")->AsInt(ACP_WAIT));
+    m_progress = line->GetParam("aProgress")->AsFloat(0.0f);
+    m_speed = line->GetParam("aSpeed")->AsFloat(1.0f);
 
     m_lastParticle = 0.0f;
 
diff --git a/src/object/auto/autoconvert.h b/src/object/auto/autoconvert.h
index f28f0ac..4fab9b0 100644
--- a/src/object/auto/autoconvert.h
+++ b/src/object/auto/autoconvert.h
@@ -53,7 +53,7 @@ public:
     bool        CreateInterface(bool bSelect);
 
     bool        Write(CLevelParserLine* line);
-    bool        Read(char *line);
+    bool        Read(CLevelParserLine* line);
 
 protected:
     CObject*    SearchStone(ObjectType type);
diff --git a/src/object/auto/autoderrick.cpp b/src/object/auto/autoderrick.cpp
index 6f06717..c8e9376 100644
--- a/src/object/auto/autoderrick.cpp
+++ b/src/object/auto/autoderrick.cpp
@@ -446,15 +446,14 @@ bool CAutoDerrick::Write(CLevelParserLine* line)
 
 // Restores all parameters of the controller.
 
-bool CAutoDerrick::Read(char *line)
+bool CAutoDerrick::Read(CLevelParserLine* line)
 {
-    if ( OpInt(line, "aExist", 0) == 0 )  return false;
+    if ( !line->GetParam("aExist")->AsBool(false) )  return false;
 
     CAuto::Read(line);
-
-    m_phase = static_cast< AutoDerrickPhase >(OpInt(line, "aPhase", ADP_WAIT));
-    m_progress = OpFloat(line, "aProgress", 0.0f);
-    m_speed = OpFloat(line, "aSpeed", 1.0f);
+    m_phase = static_cast< AutoDerrickPhase >(line->GetParam("aPhase")->AsInt(ADP_WAIT));
+    m_progress = line->GetParam("aProgress")->AsFloat(0.0f);
+    m_speed = line->GetParam("aSpeed")->AsFloat(1.0f);
 
     m_lastParticle = 0.0f;
 
diff --git a/src/object/auto/autoderrick.h b/src/object/auto/autoderrick.h
index 052a4c2..3682508 100644
--- a/src/object/auto/autoderrick.h
+++ b/src/object/auto/autoderrick.h
@@ -52,7 +52,7 @@ public:
     bool        CreateInterface(bool bSelect);
 
     bool        Write(CLevelParserLine* line);
-    bool        Read(char *line);
+    bool        Read(CLevelParserLine* line);
 
 protected:
     CObject*    SearchFret();
diff --git a/src/object/auto/autodestroyer.cpp b/src/object/auto/autodestroyer.cpp
index 068a51e..fa5c130 100644
--- a/src/object/auto/autodestroyer.cpp
+++ b/src/object/auto/autodestroyer.cpp
@@ -375,15 +375,14 @@ bool CAutoDestroyer::Write(CLevelParserLine* line)
 
 // Restores all parameters of the controller.
 
-bool CAutoDestroyer::Read(char *line)
+bool CAutoDestroyer::Read(CLevelParserLine* line)
 {
-    if ( OpInt(line, "aExist", 0) == 0 )  return false;
+    if ( !line->GetParam("aExist")->AsBool(false) )  return false;
 
     CAuto::Read(line);
-
-    m_phase = static_cast< AutoDestroyerPhase >(OpInt(line, "aPhase", ADEP_WAIT));
-    m_progress = OpFloat(line, "aProgress", 0.0f);
-    m_speed = OpFloat(line, "aSpeed", 1.0f);
+    m_phase = static_cast< AutoDestroyerPhase >(line->GetParam("aPhase")->AsInt(ADEP_WAIT));
+    m_progress = line->GetParam("aProgress")->AsFloat(0.0f);
+    m_speed = line->GetParam("aSpeed")->AsFloat(1.0f);
 
     m_lastParticle = 0.0f;
 
diff --git a/src/object/auto/autodestroyer.h b/src/object/auto/autodestroyer.h
index 73a2d34..5b3b86a 100644
--- a/src/object/auto/autodestroyer.h
+++ b/src/object/auto/autodestroyer.h
@@ -53,7 +53,7 @@ public:
     bool        CreateInterface(bool bSelect);
 
     bool        Write(CLevelParserLine* line);
-    bool        Read(char *line);
+    bool        Read(CLevelParserLine* line);
 
 protected:
     CObject*    SearchPlastic();
diff --git a/src/object/auto/autoegg.cpp b/src/object/auto/autoegg.cpp
index 91ba585..2a2af34 100644
--- a/src/object/auto/autoegg.cpp
+++ b/src/object/auto/autoegg.cpp
@@ -331,18 +331,17 @@ bool CAutoEgg::Write(CLevelParserLine* line)
 
 // Restores all parameters of the controller.
 
-bool CAutoEgg::Read(char *line)
+bool CAutoEgg::Read(CLevelParserLine* line)
 {
-    if ( OpInt(line, "aExist", 0) == 0 )  return false;
+    if ( !line->GetParam("aExist")->AsBool(false) )  return false;
 
     CAuto::Read(line);
-
-    m_phase = static_cast< AutoEggPhase >(OpInt(line, "aPhase", AEP_NULL));
-    m_progress = OpFloat(line, "aProgress", 0.0f);
-    m_speed = OpFloat(line, "aSpeed", 1.0f);
-    m_type = OpTypeObject(line, "aParamType", OBJECT_NULL);
-    m_value = OpFloat(line, "aParamValue1", 0.0f);
-    OpString(line, "aParamString", m_string);
+    m_phase = static_cast< AutoEggPhase >(line->GetParam("aPhase")->AsInt(AEP_NULL));
+    m_progress = line->GetParam("aProgress")->AsFloat(0.0f);
+    m_speed = line->GetParam("aSpeed")->AsFloat(1.0f);
+    m_type = line->GetParam("aParamType")->AsObjectType(OBJECT_NULL);
+    m_value = line->GetParam("aParamValue1")->AsFloat(0.0f);
+    strcpy(m_string, line->GetParam("aParamString")->AsString("").c_str());
 
     return true;
 }
diff --git a/src/object/auto/autoegg.h b/src/object/auto/autoegg.h
index 79a583f..e28eef1 100644
--- a/src/object/auto/autoegg.h
+++ b/src/object/auto/autoegg.h
@@ -55,7 +55,7 @@ public:
     bool        SetString(char *string);
 
     bool        Write(CLevelParserLine* line);
-    bool        Read(char *line);
+    bool        Read(CLevelParserLine* line);
 
 protected:
     CObject*    SearchAlien();
diff --git a/src/object/auto/autoenergy.cpp b/src/object/auto/autoenergy.cpp
index 3e35956..b2371f1 100644
--- a/src/object/auto/autoenergy.cpp
+++ b/src/object/auto/autoenergy.cpp
@@ -628,15 +628,14 @@ bool CAutoEnergy::Write(CLevelParserLine* line)
 
 // Restores all parameters of the controller.
 
-bool CAutoEnergy::Read(char *line)
+bool CAutoEnergy::Read(CLevelParserLine* line)
 {
-    if ( OpInt(line, "aExist", 0) == 0 )  return false;
+    if ( !line->GetParam("aExist")->AsBool(false) )  return false;
 
     CAuto::Read(line);
-
-    m_phase = static_cast< AutoEnergyPhase >(OpInt(line, "aPhase", AENP_WAIT));
-    m_progress = OpFloat(line, "aProgress", 0.0f);
-    m_speed = OpFloat(line, "aSpeed", 1.0f);
+    m_phase = static_cast< AutoEnergyPhase >(line->GetParam("aPhase")->AsInt(AENP_WAIT));
+    m_progress = line->GetParam("aProgress")->AsFloat(0.0f);
+    m_speed = line->GetParam("aSpeed")->AsFloat(1.0f);
 
     m_lastUpdateTime = 0.0f;
     m_lastParticle = 0.0f;
diff --git a/src/object/auto/autoenergy.h b/src/object/auto/autoenergy.h
index ed11fb7..ec3cce1 100644
--- a/src/object/auto/autoenergy.h
+++ b/src/object/auto/autoenergy.h
@@ -52,7 +52,7 @@ public:
     bool        CreateInterface(bool bSelect);
 
     bool        Write(CLevelParserLine* line);
-    bool        Read(char *line);
+    bool        Read(CLevelParserLine* line);
 
 protected:
     void        UpdateInterface(float rTime);
diff --git a/src/object/auto/autofactory.cpp b/src/object/auto/autofactory.cpp
index 67dc60b..dc6bab1 100644
--- a/src/object/auto/autofactory.cpp
+++ b/src/object/auto/autofactory.cpp
@@ -532,15 +532,14 @@ bool CAutoFactory::Write(CLevelParserLine* line)
 
 // Restores all parameters of the controller
 
-bool CAutoFactory::Read(char *line)
+bool CAutoFactory::Read(CLevelParserLine* line)
 {
-    if ( OpInt(line, "aExist", 0) == 0 )  return false;
+    if ( !line->GetParam("aExist")->AsBool(false) )  return false;
 
     CAuto::Read(line);
-
-    m_phase = static_cast< AutoFactoryPhase >(OpInt(line, "aPhase", AFP_WAIT));
-    m_progress = OpFloat(line, "aProgress", 0.0f);
-    m_speed = OpFloat(line, "aSpeed", 1.0f);
+    m_phase = static_cast< AutoFactoryPhase >(line->GetParam("aPhase")->AsInt(AFP_WAIT));
+    m_progress = line->GetParam("aProgress")->AsFloat(0.0f);
+    m_speed = line->GetParam("aSpeed")->AsFloat(1.0f);
 
     m_lastParticle = 0.0f;
     m_fretPos = m_object->GetPosition(0);
diff --git a/src/object/auto/autofactory.h b/src/object/auto/autofactory.h
index a232030..65186ff 100644
--- a/src/object/auto/autofactory.h
+++ b/src/object/auto/autofactory.h
@@ -56,7 +56,7 @@ public:
     bool        CreateInterface(bool bSelect);
 
     bool        Write(CLevelParserLine* line);
-    bool        Read(char *line);
+    bool        Read(CLevelParserLine* line);
 
 protected:
     void        UpdateInterface();
diff --git a/src/object/auto/autoinfo.cpp b/src/object/auto/autoinfo.cpp
index b5a3db4..e1da37a 100644
--- a/src/object/auto/autoinfo.cpp
+++ b/src/object/auto/autoinfo.cpp
@@ -495,15 +495,14 @@ bool CAutoInfo::Write(CLevelParserLine* line)
 
 // Restores all parameters of the controller.
 
-bool CAutoInfo::Read(char *line)
+bool CAutoInfo::Read(CLevelParserLine* line)
 {
-    if ( OpInt(line, "aExist", 0) == 0 )  return false;
+    if ( !line->GetParam("aExist")->AsBool(false) )  return false;
 
     CAuto::Read(line);
-
-    m_phase = static_cast< AutoInfoPhase > (OpInt(line, "aPhase", AIP_WAIT));
-    m_progress = OpFloat(line, "aProgress", 0.0f);
-    m_speed = OpFloat(line, "aSpeed", 1.0f);
+    m_phase = static_cast< AutoInfoPhase >(line->GetParam("aPhase")->AsInt(AIP_WAIT));
+    m_progress = line->GetParam("aProgress")->AsFloat(0.0f);
+    m_speed = line->GetParam("aSpeed")->AsFloat(1.0f);
 
     m_lastParticle = 0.0f;
 
diff --git a/src/object/auto/autoinfo.h b/src/object/auto/autoinfo.h
index 5923cd0..ac9f729 100644
--- a/src/object/auto/autoinfo.h
+++ b/src/object/auto/autoinfo.h
@@ -52,7 +52,7 @@ public:
     bool        CreateInterface(bool bSelect);
 
     bool        Write(CLevelParserLine* line);
-    bool        Read(char *line);
+    bool        Read(CLevelParserLine* line);
 
 protected:
     void        UpdateInterface(float rTime);
diff --git a/src/object/auto/autolabo.cpp b/src/object/auto/autolabo.cpp
index 8145fa1..f9ae104 100644
--- a/src/object/auto/autolabo.cpp
+++ b/src/object/auto/autolabo.cpp
@@ -604,16 +604,15 @@ bool CAutoLabo::Write(CLevelParserLine* line)
 
 // Restores all parameters of the controller.
 
-bool CAutoLabo::Read(char *line)
+bool CAutoLabo::Read(CLevelParserLine* line)
 {
-    if ( OpInt(line, "aExist", 0) == 0 )  return false;
+    if ( !line->GetParam("aExist")->AsBool(false) )  return false;
 
     CAuto::Read(line);
-
-    m_phase = static_cast< AutoLaboPhase >(OpInt(line, "aPhase", ALAP_WAIT));
-    m_progress = OpFloat(line, "aProgress", 0.0f);
-    m_speed = OpFloat(line, "aSpeed", 1.0f);
-    m_research = static_cast< ResearchType >(OpInt(line, "aResearch", 0));
+    m_phase = static_cast< AutoLaboPhase >(line->GetParam("aPhase")->AsInt(ALAP_WAIT));
+    m_progress = line->GetParam("aProgress")->AsFloat(0.0f);
+    m_speed = line->GetParam("aSpeed")->AsFloat(1.0f);
+    m_research = static_cast< ResearchType >(line->GetParam("aResearch")->AsInt(0));
 
     m_lastParticle = 0.0f;
 
diff --git a/src/object/auto/autolabo.h b/src/object/auto/autolabo.h
index 8828dd9..84d3f67 100644
--- a/src/object/auto/autolabo.h
+++ b/src/object/auto/autolabo.h
@@ -56,7 +56,7 @@ public:
     bool        CreateInterface(bool bSelect);
 
     bool        Write(CLevelParserLine* line);
-    bool        Read(char *line);
+    bool        Read(CLevelParserLine* line);
 
 protected:
     void        UpdateInterface();
diff --git a/src/object/auto/automush.cpp b/src/object/auto/automush.cpp
index 958f3b3..836056c 100644
--- a/src/object/auto/automush.cpp
+++ b/src/object/auto/automush.cpp
@@ -34,7 +34,7 @@
 
 // Object's constructor.
 
-    CAutoMush::CAutoMush(CObject* object) : CAuto(object)
+CAutoMush::CAutoMush(CObject* object) : CAuto(object)
 {
     Init();
 }
@@ -319,15 +319,14 @@ bool CAutoMush::Write(CLevelParserLine* line)
 
 // Restores all parameters of the controller.
 
-bool CAutoMush::Read(char *line)
+bool CAutoMush::Read(CLevelParserLine* line)
 {
-    if ( OpInt(line, "aExist", 0) == 0 )  return false;
+    if ( !line->GetParam("aExist")->AsBool(false) )  return false;
 
     CAuto::Read(line);
-
-    m_phase = static_cast< AutoMushPhase >(OpInt(line, "aPhase", AMP_WAIT));
-    m_progress = OpFloat(line, "aProgress", 0.0f);
-    m_speed = OpFloat(line, "aSpeed", 1.0f);
+    m_phase = static_cast< AutoMushPhase >(line->GetParam("aPhase")->AsInt(AMP_WAIT));
+    m_progress = line->GetParam("aProgress")->AsFloat(0.0f);
+    m_speed = line->GetParam("aSpeed")->AsFloat(1.0f);
 
     m_lastParticle = 0.0f;
 
diff --git a/src/object/auto/automush.h b/src/object/auto/automush.h
index 183914d..273dcc4 100644
--- a/src/object/auto/automush.h
+++ b/src/object/auto/automush.h
@@ -50,7 +50,7 @@ public:
     Error       GetError();
 
     bool        Write(CLevelParserLine* line);
-    bool        Read(char *line);
+    bool        Read(CLevelParserLine* line);
 
 protected:
     bool        SearchTarget();
diff --git a/src/object/auto/autonest.cpp b/src/object/auto/autonest.cpp
index 9855730..94e09f6 100644
--- a/src/object/auto/autonest.cpp
+++ b/src/object/auto/autonest.cpp
@@ -35,7 +35,7 @@
 
 // Object's constructor.
 
-    CAutoNest::CAutoNest(CObject* object) : CAuto(object)
+CAutoNest::CAutoNest(CObject* object) : CAuto(object)
 {
     Init();
 }
@@ -250,15 +250,14 @@ bool CAutoNest::Write(CLevelParserLine* line)
 
 // Restores all parameters of the controller.
 
-bool CAutoNest::Read(char *line)
+bool CAutoNest::Read(CLevelParserLine* line)
 {
-    if ( OpInt(line, "aExist", 0) == 0 )  return false;
+    if ( !line->GetParam("aExist")->AsBool(false) )  return false;
 
     CAuto::Read(line);
-
-    m_phase = static_cast< AutoNestPhase >(OpInt(line, "aPhase", ANP_WAIT));
-    m_progress = OpFloat(line, "aProgress", 0.0f);
-    m_speed = OpFloat(line, "aSpeed", 1.0f);
+    m_phase = static_cast< AutoNestPhase >(line->GetParam("aPhase")->AsInt(ANP_WAIT));
+    m_progress = line->GetParam("aProgress")->AsFloat(0.0f);
+    m_speed = line->GetParam("aSpeed")->AsFloat(1.0f);
 
     m_lastParticle = 0.0f;
 
diff --git a/src/object/auto/autonest.h b/src/object/auto/autonest.h
index acbc660..c3279df 100644
--- a/src/object/auto/autonest.h
+++ b/src/object/auto/autonest.h
@@ -47,7 +47,7 @@ public:
     Error       GetError();
 
     bool        Write(CLevelParserLine* line);
-    bool        Read(char *line);
+    bool        Read(CLevelParserLine* line);
 
 protected:
     bool        SearchFree(Math::Vector pos);
diff --git a/src/object/auto/autonuclear.cpp b/src/object/auto/autonuclear.cpp
index 54a0eda..a779bd3 100644
--- a/src/object/auto/autonuclear.cpp
+++ b/src/object/auto/autonuclear.cpp
@@ -463,15 +463,14 @@ bool CAutoNuclear::Write(CLevelParserLine* line)
 
 // Restores all parameters of the controller.
 
-bool CAutoNuclear::Read(char *line)
+bool CAutoNuclear::Read(CLevelParserLine* line)
 {
-    if ( OpInt(line, "aExist", 0) == 0 )  return false;
+    if ( !line->GetParam("aExist")->AsBool(false) )  return false;
 
     CAuto::Read(line);
-
-    m_phase = static_cast< AutoNuclearPhase >(OpInt(line, "aPhase", ANUP_WAIT));
-    m_progress = OpFloat(line, "aProgress", 0.0f);
-    m_speed = OpFloat(line, "aSpeed", 1.0f);
+    m_phase = static_cast< AutoNuclearPhase >(line->GetParam("aPhase")->AsInt(ANUP_WAIT));
+    m_progress = line->GetParam("aProgress")->AsFloat(0.0f);
+    m_speed = line->GetParam("aSpeed")->AsFloat(1.0f);
 
     m_lastParticle = 0.0f;
 
diff --git a/src/object/auto/autonuclear.h b/src/object/auto/autonuclear.h
index f513e5b..e21ecc2 100644
--- a/src/object/auto/autonuclear.h
+++ b/src/object/auto/autonuclear.h
@@ -52,7 +52,7 @@ public:
     bool        CreateInterface(bool bSelect);
 
     bool        Write(CLevelParserLine* line);
-    bool        Read(char *line);
+    bool        Read(CLevelParserLine* line);
 
 protected:
     CObject*    SearchUranium();
diff --git a/src/object/auto/autopara.cpp b/src/object/auto/autopara.cpp
index 779a897..0149f8b 100644
--- a/src/object/auto/autopara.cpp
+++ b/src/object/auto/autopara.cpp
@@ -307,15 +307,14 @@ bool CAutoPara::Write(CLevelParserLine* line)
 
 // Restores all parameters of the controller.
 
-bool CAutoPara::Read(char *line)
+bool CAutoPara::Read(CLevelParserLine* line)
 {
-    if ( OpInt(line, "aExist", 0) == 0 )  return false;
+    if ( !line->GetParam("aExist")->AsBool(false) )  return false;
 
     CAuto::Read(line);
-
-    m_phase = static_cast< AutoParaPhase >(OpInt(line, "aPhase", APAP_WAIT));
-    m_progress = OpFloat(line, "aProgress", 0.0f);
-    m_speed = OpFloat(line, "aSpeed", 1.0f);
+    m_phase = static_cast< AutoParaPhase >(line->GetParam("aPhase")->AsInt(APAP_WAIT));
+    m_progress = line->GetParam("aProgress")->AsFloat(0.0f);
+    m_speed = line->GetParam("aSpeed")->AsFloat(1.0f);
 
     m_lastParticle = 0.0f;
 
diff --git a/src/object/auto/autopara.h b/src/object/auto/autopara.h
index 27a3fc3..ec2c972 100644
--- a/src/object/auto/autopara.h
+++ b/src/object/auto/autopara.h
@@ -51,7 +51,7 @@ public:
     bool        CreateInterface(bool bSelect);
 
     bool        Write(CLevelParserLine* line);
-    bool        Read(char *line);
+    bool        Read(CLevelParserLine* line);
 
 protected:
     void        ChargeObject(float rTime);
diff --git a/src/object/auto/autorepair.cpp b/src/object/auto/autorepair.cpp
index 0e49d5c..5a88df2 100644
--- a/src/object/auto/autorepair.cpp
+++ b/src/object/auto/autorepair.cpp
@@ -320,15 +320,14 @@ bool CAutoRepair::Write(CLevelParserLine* line)
 
 // Restores all parameters of the controller.
 
-bool CAutoRepair::Read(char *line)
+bool CAutoRepair::Read(CLevelParserLine* line)
 {
-    if ( OpInt(line, "aExist", 0) == 0 )  return false;
+    if ( !line->GetParam("aExist")->AsBool(false) )  return false;
 
     CAuto::Read(line);
-
-    m_phase = static_cast< AutoRepairPhase >(OpInt(line, "aPhase", ARP_WAIT));
-    m_progress = OpFloat(line, "aProgress", 0.0f);
-    m_speed = OpFloat(line, "aSpeed", 1.0f);
+    m_phase = static_cast< AutoRepairPhase >(line->GetParam("aPhase")->AsInt(ARP_WAIT));
+    m_progress = line->GetParam("aProgress")->AsFloat(0.0f);
+    m_speed = line->GetParam("aSpeed")->AsFloat(1.0f);
 
     m_lastParticle = 0.0f;
 
diff --git a/src/object/auto/autorepair.h b/src/object/auto/autorepair.h
index d59083f..a82a479 100644
--- a/src/object/auto/autorepair.h
+++ b/src/object/auto/autorepair.h
@@ -52,7 +52,7 @@ public:
     bool        CreateInterface(bool bSelect);
 
     bool        Write(CLevelParserLine* line);
-    bool        Read(char *line);
+    bool        Read(CLevelParserLine* line);
 
 protected:
     CObject*    SearchVehicle();
diff --git a/src/object/auto/autoresearch.cpp b/src/object/auto/autoresearch.cpp
index d36342c..dc9e437 100644
--- a/src/object/auto/autoresearch.cpp
+++ b/src/object/auto/autoresearch.cpp
@@ -581,16 +581,15 @@ bool CAutoResearch::Write(CLevelParserLine* line)
 
 // Restores all parameters of the controller.
 
-bool CAutoResearch::Read(char *line)
+bool CAutoResearch::Read(CLevelParserLine* line)
 {
-    if ( OpInt(line, "aExist", 0) == 0 )  return false;
+    if ( !line->GetParam("aExist")->AsBool(false) )  return false;
 
     CAuto::Read(line);
-
-    m_phase = static_cast< AutoResearchPhase >(OpInt(line, "aPhase", ALP_WAIT));
-    m_progress = OpFloat(line, "aProgress", 0.0f);
-    m_speed = OpFloat(line, "aSpeed", 1.0f);
-    m_research = static_cast< ResearchType >(OpInt(line, "aResearch", 0));
+    m_phase = static_cast< AutoResearchPhase >(line->GetParam("aPhase")->AsInt(ALP_WAIT));
+    m_progress = line->GetParam("aProgress")->AsFloat(0.0f);
+    m_speed = line->GetParam("aSpeed")->AsFloat(1.0f);
+    m_research = static_cast< ResearchType >(line->GetParam("aResearch")->AsInt(0));
 
     m_lastUpdateTime = 0.0f;
     m_lastParticle = 0.0f;
diff --git a/src/object/auto/autoresearch.h b/src/object/auto/autoresearch.h
index 9cb7c28..c819d52 100644
--- a/src/object/auto/autoresearch.h
+++ b/src/object/auto/autoresearch.h
@@ -50,7 +50,7 @@ public:
     bool        CreateInterface(bool bSelect);
 
     bool        Write(CLevelParserLine* line);
-    bool        Read(char *line);
+    bool        Read(CLevelParserLine* line);
 
 protected:
     void        UpdateInterface();
diff --git a/src/object/auto/autosafe.cpp b/src/object/auto/autosafe.cpp
index 1f4a0ac..f51243c 100644
--- a/src/object/auto/autosafe.cpp
+++ b/src/object/auto/autosafe.cpp
@@ -370,15 +370,14 @@ bool CAutoSafe::Write(CLevelParserLine* line)
 
 // Restores all parameters of the controller.
 
-bool CAutoSafe::Read(char *line)
+bool CAutoSafe::Read(CLevelParserLine* line)
 {
-    if ( OpInt(line, "aExist", 0) == 0 )  return false;
+    if ( !line->GetParam("aExist")->AsBool(false) )  return false;
 
     CAuto::Read(line);
-
-    m_phase = static_cast< AutoSafePhase >(OpInt(line, "aPhase", ASAP_WAIT));
-    m_progress = OpFloat(line, "aProgress", 0.0f);
-    m_speed = OpFloat(line, "aSpeed", 1.0f);
+    m_phase = static_cast< AutoSafePhase >(line->GetParam("aPhase")->AsInt(ASAP_WAIT));
+    m_progress = line->GetParam("aProgress")->AsFloat(0.0f);
+    m_speed = line->GetParam("aSpeed")->AsFloat(1.0f);
 
     m_lastParticle = 0.0f;
 
diff --git a/src/object/auto/autosafe.h b/src/object/auto/autosafe.h
index 7885a42..fa8ed83 100644
--- a/src/object/auto/autosafe.h
+++ b/src/object/auto/autosafe.h
@@ -50,7 +50,7 @@ public:
     bool        CreateInterface(bool bSelect);
 
     bool        Write(CLevelParserLine* line);
-    bool        Read(char *line);
+    bool        Read(CLevelParserLine* line);
 
 protected:
     int         CountKeys();
diff --git a/src/object/auto/autotower.cpp b/src/object/auto/autotower.cpp
index 39233a1..7e67671 100644
--- a/src/object/auto/autotower.cpp
+++ b/src/object/auto/autotower.cpp
@@ -508,20 +508,19 @@ bool CAutoTower::Write(CLevelParserLine* line)
 
 // Restores all parameters of the controller.
 
-bool CAutoTower::Read(char *line)
+bool CAutoTower::Read(CLevelParserLine* line)
 {
-    if ( OpInt(line, "aExist", 0) == 0 )  return false;
+    if ( !line->GetParam("aExist")->AsBool(false) )  return false;
 
     CAuto::Read(line);
-
-    m_phase = static_cast< AutoTowerPhase >(OpInt(line, "aPhase", ATP_WAIT));
-    m_progress = OpFloat(line, "aProgress", 0.0f);
-    m_speed = OpFloat(line, "aSpeed", 1.0f);
-    m_targetPos = OpDir(line, "aTargetPos");
-    m_angleYactual = OpFloat(line, "aAngleYactual", 0.0f);
-    m_angleZactual = OpFloat(line, "aAngleZactual", 0.0f);
-    m_angleYfinal = OpFloat(line, "aAngleYfinal", 0.0f);
-    m_angleZfinal = OpFloat(line, "aAngleZfinal", 0.0f);
+    m_phase = static_cast< AutoTowerPhase >(line->GetParam("aPhase")->AsInt(ATP_WAIT));
+    m_progress = line->GetParam("aProgress")->AsFloat(0.0f);
+    m_speed = line->GetParam("aSpeed")->AsFloat(1.0f);
+    m_targetPos = line->GetParam("aTargetPos")->AsPoint(Math::Vector());
+    m_angleYactual = line->GetParam("aAngleYactual")->AsFloat(0.0f);
+    m_angleZactual = line->GetParam("aAngleZactual")->AsFloat(0.0f);
+    m_angleYfinal = line->GetParam("aAngleYfinal")->AsFloat(0.0f);
+    m_angleZfinal = line->GetParam("aAngleZfinal")->AsFloat(0.0f);
 
     m_lastUpdateTime = 0.0f;
 
diff --git a/src/object/auto/autotower.h b/src/object/auto/autotower.h
index 3333ee3..6798239 100644
--- a/src/object/auto/autotower.h
+++ b/src/object/auto/autotower.h
@@ -52,7 +52,7 @@ public:
     bool        CreateInterface(bool bSelect);
 
     bool        Write(CLevelParserLine* line);
-    bool        Read(char *line);
+    bool        Read(CLevelParserLine* line);
 
 protected:
     void        UpdateInterface(float rTime);
diff --git a/src/object/brain.cpp b/src/object/brain.cpp
index d8a810a..0a723b0 100644
--- a/src/object/brain.cpp
+++ b/src/object/brain.cpp
@@ -180,9 +180,9 @@ bool CBrain::Write(CLevelParserLine* line)
 
 // Restores all parameters of the object.
 
-bool CBrain::Read(char *line)
+bool CBrain::Read(CLevelParserLine* line)
 {
-    m_bActiveVirus = OpInt(line, "bVirusActive", 0);
+    m_bActiveVirus = line->GetParam("bVirusActive")->AsBool(false);
 
     return true;
 }
diff --git a/src/object/brain.h b/src/object/brain.h
index 5d2983b..c117269 100644
--- a/src/object/brain.h
+++ b/src/object/brain.h
@@ -94,7 +94,7 @@ public:
     bool        CreateInterface(bool bSelect);
 
     bool        Write(CLevelParserLine* line);
-    bool        Read(char *line);
+    bool        Read(CLevelParserLine* line);
 
     bool        IsBusy();
     void        SetActivity(bool bMode);
diff --git a/src/object/motion/motion.cpp b/src/object/motion/motion.cpp
index 225cc71..d704493 100644
--- a/src/object/motion/motion.cpp
+++ b/src/object/motion/motion.cpp
@@ -186,11 +186,11 @@ bool CMotion::Write(CLevelParserLine* line)
 
 // Restores all parameters of the object.
 
-bool CMotion::Read(char *line)
+bool CMotion::Read(CLevelParserLine* line)
 {
-    m_actionType = OpInt(line, "mType", -1);
-    m_actionTime = OpFloat(line, "mTime", 0.0f);
-    m_progress = OpFloat(line, "mProgress", 0.0f);
+    m_actionType = line->GetParam("mType")->AsInt(-1);
+    m_actionTime = line->GetParam("mTime")->AsFloat(0.0f);
+    m_progress = line->GetParam("mProgress")->AsFloat(0.0f);
 
     return false;
 }
diff --git a/src/object/motion/motion.h b/src/object/motion/motion.h
index d534eb5..a116b3f 100644
--- a/src/object/motion/motion.h
+++ b/src/object/motion/motion.h
@@ -64,7 +64,7 @@ public:
     virtual float           GetParam(int rank);
 
     virtual bool            Write(CLevelParserLine* line);
-    virtual bool            Read(char *line);
+    virtual bool            Read(CLevelParserLine* line);
 
     virtual void            SetLinVibration(Math::Vector dir);
     virtual Math::Vector    GetLinVibration();
diff --git a/src/object/object.cpp b/src/object/object.cpp
index 1c5f930..c2c7f7b 100644
--- a/src/object/object.cpp
+++ b/src/object/object.cpp
@@ -78,6 +78,7 @@
 #include "object/objman.h"
 #include "object/level/parserline.h"
 #include "object/level/parserparam.h"
+#include "object/level/parserexceptions.h"
 
 #include "physics/physics.h"
 
@@ -1084,29 +1085,29 @@ bool CObject::Write(CLevelParserLine* line)
     for ( i=0 ; i<OBJECTMAXCMDLINE ; i++ )
     {
         value = GetCmdLine(i);
-        if ( value == NAN )  break;
+        if ( isnan(value) )  break;
 
         cmdline.push_back(new CLevelParserParam(value));
     }
     if(cmdline.size() > 0)
         line->AddParam("cmdline", new CLevelParserParam(cmdline));
 
-    if ( m_motion != 0 )
+    if ( m_motion != nullptr )
     {
         m_motion->Write(line);
     }
 
-    if ( m_brain != 0 )
+    if ( m_brain != nullptr )
     {
         m_brain->Write(line);
     }
 
-    if ( m_physics != 0 )
+    if ( m_physics != nullptr )
     {
         m_physics->Write(line);
     }
 
-    if ( m_auto != 0 )
+    if ( m_auto != nullptr )
     {
         m_auto->Write(line);
     }
@@ -1116,87 +1117,91 @@ bool CObject::Write(CLevelParserLine* line)
 
 // Returns all parameters of the object.
 
-bool CObject::Read(char *line)
+bool CObject::Read(CLevelParserLine* line)
 {
     Math::Vector    pos, dir;
-    Info            info;
     Gfx::CameraType cType;
-    char            op[20];
-    char            text[100];
-    char*           p;
-    float           value;
     int             i;
 
-    cType = OpCamera(line, "camera");
+    cType = line->GetParam("camera")->AsCameraType(Gfx::CAM_TYPE_NULL);
     if ( cType != Gfx::CAM_TYPE_NULL )
     {
         SetCameraType(cType);
     }
 
-    SetCameraLock(OpInt(line, "cameraLock", 0));
-    SetEnergy(OpFloat(line, "energy", 0.0f));
-    SetCapacity(OpFloat(line, "capacity", 1.0f));
-    SetShield(OpFloat(line, "shield", 1.0f));
-    SetRange(OpFloat(line, "range", 1.0f));
-    SetSelectable(OpInt(line, "selectable", 1));
-    SetEnable(OpInt(line, "enable", 1));
-    SetFixed(OpInt(line, "fixed", 0));
-    SetClip(OpInt(line, "clip", 1));
-    SetLock(OpInt(line, "lock", 0));
-    SetProxyActivate(OpInt(line, "proxyActivate", 0));
-    SetProxyDistance(OpFloat(line, "proxyDistance", 15.0f)*g_unit);
-    SetRange(OpFloat(line, "range", 30.0f));
-    SetMagnifyDamage(OpFloat(line, "magnifyDamage", 1.0f));
-    SetGunGoalV(OpFloat(line, "aimV", 0.0f));
-    SetGunGoalH(OpFloat(line, "aimH", 0.0f));
-    SetParam(OpFloat(line, "param", 0.0f));
-    SetResetCap(static_cast<ResetCap>(OpInt(line, "resetCap", 0)));
-    SetResetPosition(OpDir(line, "resetPos")*g_unit);
-    SetResetAngle(OpDir(line, "resetAngle")*(Math::PI/180.0f));
-    SetResetRun(OpInt(line, "resetRun", 0));
-    m_bBurn = OpInt(line, "burnMode", 0);
-    m_bVirusMode = OpInt(line, "virusMode", 0);
-    m_virusTime = OpFloat(line, "virusTime", 0.0f);
+    SetCameraLock(line->GetParam("cameraLock")->AsBool(false));
+    SetEnergy(line->GetParam("energy")->AsFloat(0.0f));
+    SetCapacity(line->GetParam("capacity")->AsFloat(1.0f));
+    SetShield(line->GetParam("shield")->AsFloat(1.0f));
+    SetRange(line->GetParam("range")->AsFloat(1.0f));
+    SetSelectable(line->GetParam("selectable")->AsBool(true));
+    SetEnable(line->GetParam("enable")->AsBool(true));
+    SetFixed(line->GetParam("fixed")->AsBool(false));
+    SetClip(line->GetParam("clip")->AsBool(true));
+    SetLock(line->GetParam("lock")->AsBool(false));
+    SetProxyActivate(line->GetParam("proxyActivate")->AsBool(false));
+    SetProxyDistance(line->GetParam("proxyDistance")->AsFloat(15.0f)*g_unit);
+    SetRange(line->GetParam("range")->AsFloat(30.0f));
+    SetMagnifyDamage(line->GetParam("magnifyDamage")->AsFloat(1.0f));
+    SetGunGoalV(line->GetParam("aimV")->AsFloat(0.0f));
+    SetGunGoalH(line->GetParam("aimH")->AsFloat(0.0f));
+    SetParam(line->GetParam("param")->AsFloat(0.0f));
+    SetResetCap(static_cast<ResetCap>(line->GetParam("resetCap")->AsInt(0)));
+    SetResetPosition(line->GetParam("resetPos")->AsPoint(Math::Vector())*g_unit);
+    SetResetAngle(line->GetParam("resetAngle")->AsPoint(Math::Vector())*(Math::PI/180.0f));
+    SetResetRun(line->GetParam("resetRun")->AsInt(0));
+    m_bBurn = line->GetParam("burnMode")->AsBool(false);
+    m_bVirusMode = line->GetParam("virusMode")->AsBool(false);
+    m_virusTime = line->GetParam("virusTime")->AsFloat(0.0f);
 
     // Puts information in terminal (OBJECT_INFO).
     for ( i=0 ; i<OBJECTMAXINFO ; i++ )
     {
-        sprintf(op, "info%d", i+1);
-        OpString(line, op, text);
-        if ( text[0] == 0 )  break;
-        p = strchr(text, '=');
-        if ( p == 0 )  break;
-        *p = 0;
-        strcpy(info.name, text);
-        sscanf(p+1, "%f", &info.value);
+        std::string op = std::string("info")+boost::lexical_cast<std::string>(i+1);
+        if(!line->GetParam(op)->IsDefined()) break;
+        std::string text = line->GetParam(op)->AsString();
+        
+        std::size_t p = text.find_first_of("=");
+        if(p == std::string::npos) 
+            throw CLevelParserExceptionBadParam(line->GetParam(op), "info");
+        Info info;
+        strcpy(info.name, text.substr(0, p).c_str());
+        try {
+            info.value = boost::lexical_cast<float>(text.substr(p+1).c_str());
+        }
+        catch(...)
+        {
+            throw CLevelParserExceptionBadParam(line->GetParam(op), "info.value (float)");
+        }
+        
         SetInfo(i, info);
     }
 
     // Sets the parameters of the command line.
-    p = SearchOp(line, "cmdline");
-    for ( i=0 ; i<OBJECTMAXCMDLINE ; i++ )
-    {
-        value = GetFloat(p, i, NAN);
-        if ( value == NAN )  break;
-        SetCmdLine(i, value);
+    i = 0;
+    if(line->GetParam("cmdline")->IsDefined()) {
+        for(auto& p : line->GetParam("cmdline")->AsArray()) {
+            if(i >= OBJECTMAXCMDLINE) break;
+            SetCmdLine(i, p->AsFloat());
+        }
     }
 
-    if ( m_motion != 0 )
+    if ( m_motion != nullptr )
     {
         m_motion->Read(line);
     }
 
-    if ( m_brain != 0 )
+    if ( m_brain != nullptr )
     {
         m_brain->Read(line);
     }
 
-    if ( m_physics != 0 )
+    if ( m_physics != nullptr )
     {
         m_physics->Read(line);
     }
 
-    if ( m_auto != 0 )
+    if ( m_auto != nullptr )
     {
         m_auto->Read(line);
     }
diff --git a/src/object/object.h b/src/object/object.h
index 2be760e..dd8f0e6 100644
--- a/src/object/object.h
+++ b/src/object/object.h
@@ -381,7 +381,7 @@ public:
     int         GetID();
 
     bool        Write(CLevelParserLine* line);
-    bool        Read(char *line);
+    bool        Read(CLevelParserLine* line);
 
     void        SetDrawWorld(bool bDraw);
     void        SetDrawFront(bool bDraw);
diff --git a/src/object/robotmain.cpp b/src/object/robotmain.cpp
index 4a0780f..228cd65 100644
--- a/src/object/robotmain.cpp
+++ b/src/object/robotmain.cpp
@@ -5848,26 +5848,24 @@ bool CRobotMain::IOWriteScene(const char *filename, const char *filecbot, char *
 }
 
 //! Resumes the game
-CObject* CRobotMain::IOReadObject(char *line, const char* filename, int objRank)
+CObject* CRobotMain::IOReadObject(CLevelParserLine *line, const char* filename, int objRank)
 {
-    Math::Vector pos  = OpDir(line, "pos")*g_unit;
-    Math::Vector dir  = OpDir(line, "angle")*(Math::PI/180.0f);
-    Math::Vector zoom = OpDir(line, "zoom");
+    Math::Vector pos  = line->GetParam("pos")->AsPoint()*g_unit;
+    Math::Vector dir  = line->GetParam("angle")->AsPoint()*(Math::PI/180.0f);
+    Math::Vector zoom = line->GetParam("zoom")->AsPoint();
 
-    ObjectType type = OpTypeObject(line, "type", OBJECT_NULL);
-    int id = OpInt(line, "id", 0);
-    if (type == OBJECT_NULL)
-        return nullptr;
+    ObjectType type = line->GetParam("type")->AsObjectType();
+    int id = line->GetParam("id")->AsInt();
 
-    int trainer = OpInt(line, "trainer", 0);
-    int toy = OpInt(line, "toy", 0);
-    int option = OpInt(line, "option", 0);
+    bool trainer = line->GetParam("trainer")->AsBool(false);
+    bool toy = line->GetParam("toy")->AsBool(false);
+    int option = line->GetParam("option")->AsInt(0);
 
     CObject* obj = CObjectManager::GetInstancePointer()->CreateObject(pos, dir.y, type, 0.0f, 1.0f, 0.0f, trainer, toy, option);
     obj->SetDefRank(objRank);
     obj->SetPosition(0, pos);
     obj->SetAngle(0, dir);
-    obj->SetIgnoreBuildCheck(OpInt(line, "ignoreBuildCheck", 0));
+    obj->SetIgnoreBuildCheck(line->GetParam("ignoreBuildCheck")->AsBool(false));
     obj->SetID(id);
     if (g_id < id) g_id = id;
 
@@ -5878,23 +5876,19 @@ CObject* CRobotMain::IOReadObject(char *line, const char* filename, int objRank)
     {
         if (obj->GetObjectRank(i) == -1) continue;
 
-        char op[10];
-        sprintf(op, "p%d", i);
-        pos = OpDir(line, op);
+        pos = line->GetParam(std::string("p")+boost::lexical_cast<std::string>(i))->AsPoint(Math::Vector());
         if (pos.x != 0.0f || pos.y != 0.0f || pos.z != 0.0f)
         {
             obj->SetPosition(i, pos*g_unit);
         }
-
-        sprintf(op, "a%d", i);
-        dir = OpDir(line, op);
+        
+        dir = line->GetParam(std::string("a")+boost::lexical_cast<std::string>(i))->AsPoint(Math::Vector());
         if (dir.x != 0.0f || dir.y != 0.0f || dir.z != 0.0f)
         {
             obj->SetAngle(i, dir*(Math::PI/180.0f));
         }
-
-        sprintf(op, "z%d", i);
-        zoom = OpDir(line, op);
+        
+        zoom = line->GetParam(std::string("z")+boost::lexical_cast<std::string>(i))->AsPoint(Math::Vector());
         if (zoom.x != 0.0f || zoom.y != 0.0f || zoom.z != 0.0f)
         {
             obj->SetZoom(i, zoom);
@@ -5910,7 +5904,7 @@ CObject* CRobotMain::IOReadObject(char *line, const char* filename, int objRank)
     LoadFileScript(obj, filename, objRank, i);
 #endif
 
-    int run = OpInt(line, "run", -1);
+    int run = line->GetParam("run")->AsInt(-1);
     if (run != -1)
     {
 #if CBOT_STACK
@@ -5931,54 +5925,48 @@ CObject* CRobotMain::IOReadObject(char *line, const char* filename, int objRank)
 //! Resumes some part of the game
 CObject* CRobotMain::IOReadScene(const char *filename, const char *filecbot)
 {
-    m_base = nullptr;
+    std::string fnstr = filename;
+    std::string savedir = CResourceManager::GetSaveLocation()+"/";
+    boost::replace_all(fnstr, "\\", "/");
+    boost::replace_all(savedir, "\\", "/");
+    boost::replace_all(fnstr, savedir, ""); //TODO: Refactor to get physfs path here
 
-    FILE* file = fopen(filename, "r");
-    if (file == NULL) return 0;
+    CLevelParser* level = new CLevelParser(fnstr);
+    level->Load();
 
+    m_base = nullptr;
     CObject* fret   = nullptr;
     CObject* power  = nullptr;
     CObject* sel    = nullptr;
     int objRank = 0;
-    char line[3000];
-    while (fgets(line, 3000, file) != NULL)
+    for(auto& line : level->GetLines())
     {
-        for (int i = 0; i < 3000; i++)
-        {
-            if (line[i] == '\t') line[i] = ' ';  // replace tab by space
-            if (line[i] == '/' && line[i+1] == '/')
-            {
-                line[i] = 0;
-                break;
-            }
-        }
-
-        if (Cmd(line, "Map"))
-            m_map->ZoomMap(OpFloat(line, "zoom", 1.0f));
+        if (line->GetCommand() == "Map")
+            m_map->ZoomMap(line->GetParam("zoom")->AsFloat());
 
-        if (Cmd(line, "DoneResearch"))
-            g_researchDone = OpInt(line, "bits", 0);
+        if (line->GetCommand() == "DoneResearch")
+            g_researchDone = line->GetParam("bits")->AsInt();
 
-        if (Cmd(line, "BlitzMode"))
+        if (line->GetCommand() == "BlitzMode")
         {
-            float sleep = OpFloat(line, "sleep", 0.0f);
-            float delay = OpFloat(line, "delay", 3.0f);
-            float magnetic = OpFloat(line, "magnetic", 50.0f)*g_unit;
-            float progress = OpFloat(line, "progress", 0.0f);
+            float sleep = line->GetParam("sleep")->AsFloat();
+            float delay = line->GetParam("delay")->AsFloat();
+            float magnetic = line->GetParam("magnetic")->AsFloat()*g_unit;
+            float progress = line->GetParam("progress")->AsFloat();
             m_lightning->SetStatus(sleep, delay, magnetic, progress);
         }
 
-        if (Cmd(line, "CreateFret"))
+        if (line->GetCommand() == "CreateFret")
             fret = IOReadObject(line, filename, -1);
 
-        if (Cmd(line, "CreatePower"))
+        if (line->GetCommand() == "CreatePower")
             power = IOReadObject(line, filename, -1);
 
-        if (Cmd(line, "CreateObject"))
+        if (line->GetCommand() == "CreateObject")
         {
             CObject* obj = IOReadObject(line, filename, objRank++);
 
-            if (OpInt(line, "select", 0))
+            if (line->GetParam("select")->AsBool(false))
                 sel = obj;
 
             if (fret != nullptr)
@@ -5999,7 +5987,7 @@ CObject* CRobotMain::IOReadScene(const char *filename, const char *filecbot)
             power = nullptr;
         }
     }
-    fclose(file);
+    delete level;
 
 #if CBOT_STACK
     CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
@@ -6026,7 +6014,7 @@ CObject* CRobotMain::IOReadScene(const char *filename, const char *filecbot)
     while (nbError > 0 && nbError != lastError);
 
     // Reads the file of stacks of execution.
-    file = fOpen(filecbot, "rb");
+    FILE* file = fOpen(filecbot, "rb");
     if (file != NULL)
     {
         long version;
diff --git a/src/object/robotmain.h b/src/object/robotmain.h
index 60eb684..f83d930 100644
--- a/src/object/robotmain.h
+++ b/src/object/robotmain.h
@@ -384,8 +384,8 @@ public:
     bool        IsBusy();
     bool        IOWriteScene(const char *filename, const char *filecbot, char *info);
     CObject*    IOReadScene(const char *filename, const char *filecbot);
-    void        IOWriteObject(CLevelParserLine *file, CObject* pObj);
-    CObject*    IOReadObject(char *line, const char* filename, int objRank);
+    void        IOWriteObject(CLevelParserLine *line, CObject* obj);
+    CObject*    IOReadObject(CLevelParserLine *line, const char* filename, int objRank);
 
     int         CreateSpot(Math::Vector pos, Gfx::Color color);
 
diff --git a/src/physics/physics.cpp b/src/physics/physics.cpp
index d98334a..6de35dc 100644
--- a/src/physics/physics.cpp
+++ b/src/physics/physics.cpp
@@ -188,14 +188,14 @@ bool CPhysics::Write(CLevelParserLine* line)
 
 // Restores all parameters of the object.
 
-bool CPhysics::Read(char *line)
+bool CPhysics::Read(CLevelParserLine* line)
 {
-    m_motorSpeed = OpDir(line, "motor");
+    m_motorSpeed = line->GetParam("motor")->AsPoint();
 
     if ( m_type == TYPE_FLYING )
     {
-        SetReactorRange(OpFloat(line, "reactorRange", 0.0f));
-        SetLand(OpInt(line, "land", 0));
+        SetReactorRange(line->GetParam("reactorRange")->AsFloat());
+        SetLand(line->GetParam("land")->AsBool());
     }
 
     return true;
diff --git a/src/physics/physics.h b/src/physics/physics.h
index 831bbfc..e8996ae 100644
--- a/src/physics/physics.h
+++ b/src/physics/physics.h
@@ -112,7 +112,7 @@ public:
     PhysicsType GetType();
 
     bool        Write(CLevelParserLine* line);
-    bool        Read(char *line);
+    bool        Read(CLevelParserLine* line);
 
     void        SetGravity(float value);
     float       GetGravity();

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