Level saving through CLevelParser
parent
1477e72ab4
commit
3dade17f89
|
@ -1799,8 +1799,8 @@ void CApplication::SetLanguage(Language language)
|
|||
putenv(S_LANGUAGE);
|
||||
GetLogger()->Trace("SetLanguage: Set LANGUAGE=%s in environment\n", locale.c_str());
|
||||
}
|
||||
|
||||
setlocale(LC_ALL, "");
|
||||
|
||||
std::locale::global(std::locale(std::locale(""), "C", std::locale::numeric));
|
||||
|
||||
bindtextdomain("colobot", m_langPath.c_str());
|
||||
bind_textdomain_codeset("colobot", "UTF-8");
|
||||
|
|
|
@ -26,6 +26,9 @@
|
|||
#include "common/event.h"
|
||||
#include "common/iman.h"
|
||||
|
||||
#include "object/level/parserline.h"
|
||||
#include "object/level/parserparam.h"
|
||||
|
||||
#include "script/cmdtoken.h"
|
||||
|
||||
#include "ui/interface.h"
|
||||
|
@ -424,24 +427,13 @@ void CAuto::SetMotor(bool bMotor)
|
|||
|
||||
// Saves all parameters of the controller.
|
||||
|
||||
bool CAuto::Write(char *line)
|
||||
bool CAuto::Write(CLevelParserLine* line)
|
||||
{
|
||||
char name[100];
|
||||
|
||||
sprintf(name, " aType=%d", m_type);
|
||||
strcat(line, name);
|
||||
|
||||
sprintf(name, " aBusy=%d", m_bBusy);
|
||||
strcat(line, name);
|
||||
|
||||
sprintf(name, " aTime=%.2f", m_time);
|
||||
strcat(line, name);
|
||||
|
||||
sprintf(name, " aProgressTime=%.2f", m_progressTime);
|
||||
strcat(line, name);
|
||||
|
||||
sprintf(name, " aProgressTotal=%.2f", m_progressTotal);
|
||||
strcat(line, name);
|
||||
line->AddParam("aType", new CLevelParserParam(m_type));
|
||||
line->AddParam("aBusy", new CLevelParserParam(m_bBusy));
|
||||
line->AddParam("aTime", new CLevelParserParam(m_time));
|
||||
line->AddParam("aProgressTime", new CLevelParserParam(m_progressTime));
|
||||
line->AddParam("aProgressTotal", new CLevelParserParam(m_progressTotal));
|
||||
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
class CInstanceManager;
|
||||
class CRobotMain;
|
||||
class CSoundInterface;
|
||||
class CLevelParserLine;
|
||||
|
||||
namespace Ui {
|
||||
class CInterface;
|
||||
|
@ -80,7 +81,7 @@ public:
|
|||
virtual bool GetMotor();
|
||||
virtual void SetMotor(bool bMotor);
|
||||
|
||||
virtual bool Write(char *line);
|
||||
virtual bool Write(CLevelParserLine* line);
|
||||
virtual bool Read(char *line);
|
||||
|
||||
protected:
|
||||
|
|
|
@ -24,6 +24,9 @@
|
|||
|
||||
#include "math/geometry.h"
|
||||
|
||||
#include "object/level/parserline.h"
|
||||
#include "object/level/parserparam.h"
|
||||
|
||||
#include "script/cmdtoken.h"
|
||||
|
||||
#include "ui/interface.h"
|
||||
|
@ -361,26 +364,16 @@ bool CAutoConvert::CreateInterface(bool bSelect)
|
|||
|
||||
// Saves all parameters of the controller.
|
||||
|
||||
bool CAutoConvert::Write(char *line)
|
||||
bool CAutoConvert::Write(CLevelParserLine* line)
|
||||
{
|
||||
char name[100];
|
||||
|
||||
if ( m_phase == ACP_STOP ||
|
||||
m_phase == ACP_WAIT ) return false;
|
||||
|
||||
sprintf(name, " aExist=%d", 1);
|
||||
strcat(line, name);
|
||||
|
||||
line->AddParam("aExist", new CLevelParserParam(true));
|
||||
CAuto::Write(line);
|
||||
|
||||
sprintf(name, " aPhase=%d", m_phase);
|
||||
strcat(line, name);
|
||||
|
||||
sprintf(name, " aProgress=%.2f", m_progress);
|
||||
strcat(line, name);
|
||||
|
||||
sprintf(name, " aSpeed=%.2f", m_speed);
|
||||
strcat(line, name);
|
||||
line->AddParam("aPhase", new CLevelParserParam(static_cast<int>(m_phase)));
|
||||
line->AddParam("aProgress", new CLevelParserParam(m_progress));
|
||||
line->AddParam("aSpeed", new CLevelParserParam(m_speed));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -52,7 +52,7 @@ public:
|
|||
|
||||
bool CreateInterface(bool bSelect);
|
||||
|
||||
bool Write(char *line);
|
||||
bool Write(CLevelParserLine* line);
|
||||
bool Read(char *line);
|
||||
|
||||
protected:
|
||||
|
|
|
@ -26,6 +26,9 @@
|
|||
|
||||
#include "math/geometry.h"
|
||||
|
||||
#include "object/level/parserline.h"
|
||||
#include "object/level/parserparam.h"
|
||||
|
||||
#include "script/cmdtoken.h"
|
||||
|
||||
#include "ui/interface.h"
|
||||
|
@ -428,25 +431,15 @@ bool CAutoDerrick::CreateInterface(bool bSelect)
|
|||
|
||||
// Saves all parameters of the controller.
|
||||
|
||||
bool CAutoDerrick::Write(char *line)
|
||||
bool CAutoDerrick::Write(CLevelParserLine* line)
|
||||
{
|
||||
char name[100];
|
||||
|
||||
if ( m_phase == ADP_WAIT ) return false;
|
||||
|
||||
sprintf(name, " aExist=%d", 1);
|
||||
strcat(line, name);
|
||||
|
||||
|
||||
line->AddParam("aExist", new CLevelParserParam(true));
|
||||
CAuto::Write(line);
|
||||
|
||||
sprintf(name, " aPhase=%d", m_phase);
|
||||
strcat(line, name);
|
||||
|
||||
sprintf(name, " aProgress=%.2f", m_progress);
|
||||
strcat(line, name);
|
||||
|
||||
sprintf(name, " aSpeed=%.2f", m_speed);
|
||||
strcat(line, name);
|
||||
line->AddParam("aPhase", new CLevelParserParam(static_cast<int>(m_phase)));
|
||||
line->AddParam("aProgress", new CLevelParserParam(m_progress));
|
||||
line->AddParam("aSpeed", new CLevelParserParam(m_speed));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -51,7 +51,7 @@ public:
|
|||
|
||||
bool CreateInterface(bool bSelect);
|
||||
|
||||
bool Write(char *line);
|
||||
bool Write(CLevelParserLine* line);
|
||||
bool Read(char *line);
|
||||
|
||||
protected:
|
||||
|
|
|
@ -22,6 +22,9 @@
|
|||
|
||||
#include "common/iman.h"
|
||||
|
||||
#include "object/level/parserline.h"
|
||||
#include "object/level/parserparam.h"
|
||||
|
||||
#include "script/cmdtoken.h"
|
||||
|
||||
#include "ui/interface.h"
|
||||
|
@ -357,25 +360,15 @@ Error CAutoDestroyer::GetError()
|
|||
|
||||
// Saves all parameters of the controller.
|
||||
|
||||
bool CAutoDestroyer::Write(char *line)
|
||||
bool CAutoDestroyer::Write(CLevelParserLine* line)
|
||||
{
|
||||
char name[100];
|
||||
|
||||
if ( m_phase == ADEP_WAIT ) return false;
|
||||
|
||||
sprintf(name, " aExist=%d", 1);
|
||||
strcat(line, name);
|
||||
|
||||
|
||||
line->AddParam("aExist", new CLevelParserParam(true));
|
||||
CAuto::Write(line);
|
||||
|
||||
sprintf(name, " aPhase=%d", m_phase);
|
||||
strcat(line, name);
|
||||
|
||||
sprintf(name, " aProgress=%.2f", m_progress);
|
||||
strcat(line, name);
|
||||
|
||||
sprintf(name, " aSpeed=%.2f", m_speed);
|
||||
strcat(line, name);
|
||||
line->AddParam("aPhase", new CLevelParserParam(static_cast<int>(m_phase)));
|
||||
line->AddParam("aProgress", new CLevelParserParam(m_progress));
|
||||
line->AddParam("aSpeed", new CLevelParserParam(m_speed));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -52,7 +52,7 @@ public:
|
|||
|
||||
bool CreateInterface(bool bSelect);
|
||||
|
||||
bool Write(char *line);
|
||||
bool Write(CLevelParserLine* line);
|
||||
bool Read(char *line);
|
||||
|
||||
protected:
|
||||
|
|
|
@ -24,6 +24,9 @@
|
|||
|
||||
#include "math/geometry.h"
|
||||
|
||||
#include "object/level/parserline.h"
|
||||
#include "object/level/parserparam.h"
|
||||
|
||||
#include "script/cmdtoken.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
@ -310,34 +313,18 @@ CObject* CAutoEgg::SearchAlien()
|
|||
|
||||
// Saves all parameters of the controller.
|
||||
|
||||
bool CAutoEgg::Write(char *line)
|
||||
bool CAutoEgg::Write(CLevelParserLine* line)
|
||||
{
|
||||
char name[100];
|
||||
|
||||
if ( m_phase == AEP_NULL ) return false;
|
||||
|
||||
sprintf(name, " aExist=%d", 1);
|
||||
strcat(line, name);
|
||||
|
||||
|
||||
line->AddParam("aExist", new CLevelParserParam(true));
|
||||
CAuto::Write(line);
|
||||
|
||||
sprintf(name, " aPhase=%d", m_phase);
|
||||
strcat(line, name);
|
||||
|
||||
sprintf(name, " aProgress=%.2f", m_progress);
|
||||
strcat(line, name);
|
||||
|
||||
sprintf(name, " aSpeed=%.5f", m_speed);
|
||||
strcat(line, name);
|
||||
|
||||
sprintf(name, " aParamType=%s", GetTypeObject(m_type));
|
||||
strcat(line, name);
|
||||
|
||||
sprintf(name, " aParamValue1=%.2f", m_value);
|
||||
strcat(line, name);
|
||||
|
||||
sprintf(name, " aParamString=\"%s\"", m_string);
|
||||
strcat(line, name);
|
||||
line->AddParam("aPhase", new CLevelParserParam(static_cast<int>(m_phase)));
|
||||
line->AddParam("aProgress", new CLevelParserParam(m_progress));
|
||||
line->AddParam("aSpeed", new CLevelParserParam(m_speed));
|
||||
line->AddParam("aParamType", new CLevelParserParam(m_type));
|
||||
line->AddParam("aParamValue1", new CLevelParserParam(m_value));
|
||||
line->AddParam("aParamString", new CLevelParserParam(m_string));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -54,7 +54,7 @@ public:
|
|||
bool SetValue(int rank, float value);
|
||||
bool SetString(char *string);
|
||||
|
||||
bool Write(char *line);
|
||||
bool Write(CLevelParserLine* line);
|
||||
bool Read(char *line);
|
||||
|
||||
protected:
|
||||
|
|
|
@ -26,6 +26,9 @@
|
|||
|
||||
#include "math/geometry.h"
|
||||
|
||||
#include "object/level/parserline.h"
|
||||
#include "object/level/parserparam.h"
|
||||
|
||||
#include "script/cmdtoken.h"
|
||||
|
||||
#include "ui/interface.h"
|
||||
|
@ -609,26 +612,16 @@ void CAutoEnergy::UpdateInterface(float rTime)
|
|||
|
||||
// Saves all parameters of the controller.
|
||||
|
||||
bool CAutoEnergy::Write(char *line)
|
||||
bool CAutoEnergy::Write(CLevelParserLine* line)
|
||||
{
|
||||
char name[100];
|
||||
|
||||
if ( m_phase == AENP_STOP ||
|
||||
m_phase == AENP_WAIT ) return false;
|
||||
|
||||
sprintf(name, " aExist=%d", 1);
|
||||
strcat(line, name);
|
||||
|
||||
|
||||
line->AddParam("aExist", new CLevelParserParam(true));
|
||||
CAuto::Write(line);
|
||||
|
||||
sprintf(name, " aPhase=%d", m_phase);
|
||||
strcat(line, name);
|
||||
|
||||
sprintf(name, " aProgress=%.2f", m_progress);
|
||||
strcat(line, name);
|
||||
|
||||
sprintf(name, " aSpeed=%.2f", m_speed);
|
||||
strcat(line, name);
|
||||
line->AddParam("aPhase", new CLevelParserParam(static_cast<int>(m_phase)));
|
||||
line->AddParam("aProgress", new CLevelParserParam(m_progress));
|
||||
line->AddParam("aSpeed", new CLevelParserParam(m_speed));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -51,7 +51,7 @@ public:
|
|||
|
||||
bool CreateInterface(bool bSelect);
|
||||
|
||||
bool Write(char *line);
|
||||
bool Write(CLevelParserLine* line);
|
||||
bool Read(char *line);
|
||||
|
||||
protected:
|
||||
|
|
|
@ -27,6 +27,8 @@
|
|||
|
||||
#include "object/robotmain.h"
|
||||
#include "object/brain.h"
|
||||
#include "object/level/parserline.h"
|
||||
#include "object/level/parserparam.h"
|
||||
|
||||
#include "physics/physics.h"
|
||||
|
||||
|
@ -515,25 +517,15 @@ bool CAutoFactory::EventProcess(const Event &event)
|
|||
|
||||
// Saves all parameters of the controller.
|
||||
|
||||
bool CAutoFactory::Write(char *line)
|
||||
bool CAutoFactory::Write(CLevelParserLine* line)
|
||||
{
|
||||
char name[100];
|
||||
|
||||
if ( m_phase == AFP_WAIT ) return false;
|
||||
|
||||
sprintf(name, " aExist=%d", 1);
|
||||
strcat(line, name);
|
||||
|
||||
|
||||
line->AddParam("aExist", new CLevelParserParam(true));
|
||||
CAuto::Write(line);
|
||||
|
||||
sprintf(name, " aPhase=%d", m_phase);
|
||||
strcat(line, name);
|
||||
|
||||
sprintf(name, " aProgress=%.2f", m_progress);
|
||||
strcat(line, name);
|
||||
|
||||
sprintf(name, " aSpeed=%.2f", m_speed);
|
||||
strcat(line, name);
|
||||
line->AddParam("aPhase", new CLevelParserParam(static_cast<int>(m_phase)));
|
||||
line->AddParam("aProgress", new CLevelParserParam(m_progress));
|
||||
line->AddParam("aSpeed", new CLevelParserParam(m_speed));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -55,7 +55,7 @@ public:
|
|||
|
||||
bool CreateInterface(bool bSelect);
|
||||
|
||||
bool Write(char *line);
|
||||
bool Write(CLevelParserLine* line);
|
||||
bool Read(char *line);
|
||||
|
||||
protected:
|
||||
|
|
|
@ -20,7 +20,12 @@
|
|||
|
||||
#include "object/auto/autoinfo.h"
|
||||
|
||||
|
||||
#include "object/level/parserline.h"
|
||||
#include "object/level/parserparam.h"
|
||||
|
||||
#include "script/cmdtoken.h"
|
||||
|
||||
#include "ui/interface.h"
|
||||
#include "ui/list.h"
|
||||
#include "ui/window.h"
|
||||
|
@ -475,25 +480,15 @@ void CAutoInfo::UpdateListVirus()
|
|||
|
||||
// Saves all parameters of the controller.
|
||||
|
||||
bool CAutoInfo::Write(char *line)
|
||||
bool CAutoInfo::Write(CLevelParserLine* line)
|
||||
{
|
||||
char name[100];
|
||||
|
||||
if ( m_phase == AIP_WAIT ) return false;
|
||||
|
||||
sprintf(name, " aExist=%d", 1);
|
||||
strcat(line, name);
|
||||
|
||||
|
||||
line->AddParam("aExist", new CLevelParserParam(true));
|
||||
CAuto::Write(line);
|
||||
|
||||
sprintf(name, " aPhase=%d", m_phase);
|
||||
strcat(line, name);
|
||||
|
||||
sprintf(name, " aProgress=%.2f", m_progress);
|
||||
strcat(line, name);
|
||||
|
||||
sprintf(name, " aSpeed=%.2f", m_speed);
|
||||
strcat(line, name);
|
||||
line->AddParam("aPhase", new CLevelParserParam(static_cast<int>(m_phase)));
|
||||
line->AddParam("aProgress", new CLevelParserParam(m_progress));
|
||||
line->AddParam("aSpeed", new CLevelParserParam(m_speed));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -51,7 +51,7 @@ public:
|
|||
|
||||
bool CreateInterface(bool bSelect);
|
||||
|
||||
bool Write(char *line);
|
||||
bool Write(CLevelParserLine* line);
|
||||
bool Read(char *line);
|
||||
|
||||
protected:
|
||||
|
|
|
@ -26,6 +26,8 @@
|
|||
#include "math/geometry.h"
|
||||
|
||||
#include "object/robotmain.h"
|
||||
#include "object/level/parserline.h"
|
||||
#include "object/level/parserparam.h"
|
||||
|
||||
#include "script/cmdtoken.h"
|
||||
|
||||
|
@ -586,29 +588,16 @@ void CAutoLabo::SoundManip(float time, float amplitude, float frequency)
|
|||
|
||||
// Saves all parameters of the controller.
|
||||
|
||||
bool CAutoLabo::Write(char *line)
|
||||
bool CAutoLabo::Write(CLevelParserLine* line)
|
||||
{
|
||||
Math::Vector pos;
|
||||
char name[100];
|
||||
|
||||
if ( m_phase == ALAP_WAIT ) return false;
|
||||
|
||||
sprintf(name, " aExist=%d", 1);
|
||||
strcat(line, name);
|
||||
|
||||
|
||||
line->AddParam("aExist", new CLevelParserParam(true));
|
||||
CAuto::Write(line);
|
||||
|
||||
sprintf(name, " aPhase=%d", m_phase);
|
||||
strcat(line, name);
|
||||
|
||||
sprintf(name, " aProgress=%.2f", m_progress);
|
||||
strcat(line, name);
|
||||
|
||||
sprintf(name, " aSpeed=%.2f", m_speed);
|
||||
strcat(line, name);
|
||||
|
||||
sprintf(name, " aResearch=%d", m_research);
|
||||
strcat(line, name);
|
||||
line->AddParam("aPhase", new CLevelParserParam(static_cast<int>(m_phase)));
|
||||
line->AddParam("aProgress", new CLevelParserParam(m_progress));
|
||||
line->AddParam("aSpeed", new CLevelParserParam(m_speed));
|
||||
line->AddParam("aResearch", new CLevelParserParam(static_cast<int>(m_research)));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -617,8 +606,6 @@ bool CAutoLabo::Write(char *line)
|
|||
|
||||
bool CAutoLabo::Read(char *line)
|
||||
{
|
||||
Math::Vector pos;
|
||||
|
||||
if ( OpInt(line, "aExist", 0) == 0 ) return false;
|
||||
|
||||
CAuto::Read(line);
|
||||
|
|
|
@ -55,7 +55,7 @@ public:
|
|||
|
||||
bool CreateInterface(bool bSelect);
|
||||
|
||||
bool Write(char *line);
|
||||
bool Write(CLevelParserLine* line);
|
||||
bool Read(char *line);
|
||||
|
||||
protected:
|
||||
|
|
|
@ -22,6 +22,9 @@
|
|||
|
||||
#include "common/iman.h"
|
||||
|
||||
#include "object/level/parserline.h"
|
||||
#include "object/level/parserparam.h"
|
||||
|
||||
#include "script/cmdtoken.h"
|
||||
|
||||
|
||||
|
@ -301,26 +304,15 @@ Error CAutoMush::GetError()
|
|||
|
||||
// Saves all parameters of the controller.
|
||||
|
||||
bool CAutoMush::Write(char *line)
|
||||
bool CAutoMush::Write(CLevelParserLine* line)
|
||||
{
|
||||
Math::Vector pos;
|
||||
char name[100];
|
||||
|
||||
if ( m_phase == AMP_WAIT ) return false;
|
||||
|
||||
sprintf(name, " aExist=%d", 1);
|
||||
strcat(line, name);
|
||||
|
||||
|
||||
line->AddParam("aExist", new CLevelParserParam(true));
|
||||
CAuto::Write(line);
|
||||
|
||||
sprintf(name, " aPhase=%d", m_phase);
|
||||
strcat(line, name);
|
||||
|
||||
sprintf(name, " aProgress=%.2f", m_progress);
|
||||
strcat(line, name);
|
||||
|
||||
sprintf(name, " aSpeed=%.2f", m_speed);
|
||||
strcat(line, name);
|
||||
line->AddParam("aPhase", new CLevelParserParam(static_cast<int>(m_phase)));
|
||||
line->AddParam("aProgress", new CLevelParserParam(m_progress));
|
||||
line->AddParam("aSpeed", new CLevelParserParam(m_speed));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -329,8 +321,6 @@ bool CAutoMush::Write(char *line)
|
|||
|
||||
bool CAutoMush::Read(char *line)
|
||||
{
|
||||
Math::Vector pos;
|
||||
|
||||
if ( OpInt(line, "aExist", 0) == 0 ) return false;
|
||||
|
||||
CAuto::Read(line);
|
||||
|
|
|
@ -49,7 +49,7 @@ public:
|
|||
bool EventProcess(const Event &event);
|
||||
Error GetError();
|
||||
|
||||
bool Write(char *line);
|
||||
bool Write(CLevelParserLine* line);
|
||||
bool Read(char *line);
|
||||
|
||||
protected:
|
||||
|
|
|
@ -24,6 +24,9 @@
|
|||
|
||||
#include "graphics/engine/terrain.h"
|
||||
|
||||
#include "object/level/parserline.h"
|
||||
#include "object/level/parserparam.h"
|
||||
|
||||
#include "script/cmdtoken.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
@ -232,26 +235,15 @@ Error CAutoNest::GetError()
|
|||
|
||||
// Saves all parameters of the controller.
|
||||
|
||||
bool CAutoNest::Write(char *line)
|
||||
bool CAutoNest::Write(CLevelParserLine* line)
|
||||
{
|
||||
Math::Vector pos;
|
||||
char name[100];
|
||||
|
||||
if ( m_phase == ANP_WAIT ) return false;
|
||||
|
||||
sprintf(name, " aExist=%d", 1);
|
||||
strcat(line, name);
|
||||
|
||||
|
||||
line->AddParam("aExist", new CLevelParserParam(true));
|
||||
CAuto::Write(line);
|
||||
|
||||
sprintf(name, " aPhase=%d", m_phase);
|
||||
strcat(line, name);
|
||||
|
||||
sprintf(name, " aProgress=%.2f", m_progress);
|
||||
strcat(line, name);
|
||||
|
||||
sprintf(name, " aSpeed=%.2f", m_speed);
|
||||
strcat(line, name);
|
||||
line->AddParam("aPhase", new CLevelParserParam(static_cast<int>(m_phase)));
|
||||
line->AddParam("aProgress", new CLevelParserParam(m_progress));
|
||||
line->AddParam("aSpeed", new CLevelParserParam(m_speed));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -260,8 +252,6 @@ bool CAutoNest::Write(char *line)
|
|||
|
||||
bool CAutoNest::Read(char *line)
|
||||
{
|
||||
Math::Vector pos;
|
||||
|
||||
if ( OpInt(line, "aExist", 0) == 0 ) return false;
|
||||
|
||||
CAuto::Read(line);
|
||||
|
|
|
@ -46,7 +46,7 @@ public:
|
|||
bool EventProcess(const Event &event);
|
||||
Error GetError();
|
||||
|
||||
bool Write(char *line);
|
||||
bool Write(CLevelParserLine* line);
|
||||
bool Read(char *line);
|
||||
|
||||
protected:
|
||||
|
|
|
@ -24,6 +24,9 @@
|
|||
|
||||
#include "math/geometry.h"
|
||||
|
||||
#include "object/level/parserline.h"
|
||||
#include "object/level/parserparam.h"
|
||||
|
||||
#include "script/cmdtoken.h"
|
||||
|
||||
#include "ui/interface.h"
|
||||
|
@ -444,26 +447,16 @@ Error CAutoNuclear::GetError()
|
|||
|
||||
// Saves all parameters of the controller.
|
||||
|
||||
bool CAutoNuclear::Write(char *line)
|
||||
bool CAutoNuclear::Write(CLevelParserLine* line)
|
||||
{
|
||||
char name[100];
|
||||
|
||||
if ( m_phase == ANUP_STOP ||
|
||||
m_phase == ANUP_WAIT ) return false;
|
||||
|
||||
sprintf(name, " aExist=%d", 1);
|
||||
strcat(line, name);
|
||||
|
||||
|
||||
line->AddParam("aExist", new CLevelParserParam(true));
|
||||
CAuto::Write(line);
|
||||
|
||||
sprintf(name, " aPhase=%d", m_phase);
|
||||
strcat(line, name);
|
||||
|
||||
sprintf(name, " aProgress=%.2f", m_progress);
|
||||
strcat(line, name);
|
||||
|
||||
sprintf(name, " aSpeed=%.2f", m_speed);
|
||||
strcat(line, name);
|
||||
line->AddParam("aPhase", new CLevelParserParam(static_cast<int>(m_phase)));
|
||||
line->AddParam("aProgress", new CLevelParserParam(m_progress));
|
||||
line->AddParam("aSpeed", new CLevelParserParam(m_speed));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -51,7 +51,7 @@ public:
|
|||
|
||||
bool CreateInterface(bool bSelect);
|
||||
|
||||
bool Write(char *line);
|
||||
bool Write(CLevelParserLine* line);
|
||||
bool Read(char *line);
|
||||
|
||||
protected:
|
||||
|
|
|
@ -25,6 +25,9 @@
|
|||
|
||||
#include "math/geometry.h"
|
||||
|
||||
#include "object/level/parserline.h"
|
||||
#include "object/level/parserparam.h"
|
||||
|
||||
#include "script/cmdtoken.h"
|
||||
|
||||
#include "ui/interface.h"
|
||||
|
@ -289,25 +292,15 @@ void CAutoPara::ChargeObject(float rTime)
|
|||
|
||||
// Saves all parameters of the controller.
|
||||
|
||||
bool CAutoPara::Write(char *line)
|
||||
bool CAutoPara::Write(CLevelParserLine* line)
|
||||
{
|
||||
char name[100];
|
||||
|
||||
if ( m_phase == APAP_WAIT ) return false;
|
||||
|
||||
sprintf(name, " aExist=%d", 1);
|
||||
strcat(line, name);
|
||||
|
||||
|
||||
line->AddParam("aExist", new CLevelParserParam(true));
|
||||
CAuto::Write(line);
|
||||
|
||||
sprintf(name, " aPhase=%d", m_phase);
|
||||
strcat(line, name);
|
||||
|
||||
sprintf(name, " aProgress=%.2f", m_progress);
|
||||
strcat(line, name);
|
||||
|
||||
sprintf(name, " aSpeed=%.2f", m_speed);
|
||||
strcat(line, name);
|
||||
line->AddParam("aPhase", new CLevelParserParam(static_cast<int>(m_phase)));
|
||||
line->AddParam("aProgress", new CLevelParserParam(m_progress));
|
||||
line->AddParam("aSpeed", new CLevelParserParam(m_speed));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -50,7 +50,7 @@ public:
|
|||
|
||||
bool CreateInterface(bool bSelect);
|
||||
|
||||
bool Write(char *line);
|
||||
bool Write(CLevelParserLine* line);
|
||||
bool Read(char *line);
|
||||
|
||||
protected:
|
||||
|
|
|
@ -22,6 +22,9 @@
|
|||
|
||||
#include "common/iman.h"
|
||||
|
||||
#include "object/level/parserline.h"
|
||||
#include "object/level/parserparam.h"
|
||||
|
||||
#include "physics/physics.h"
|
||||
|
||||
#include "script/cmdtoken.h"
|
||||
|
@ -302,25 +305,15 @@ Error CAutoRepair::GetError()
|
|||
|
||||
// Saves all parameters of the controller.
|
||||
|
||||
bool CAutoRepair::Write(char *line)
|
||||
bool CAutoRepair::Write(CLevelParserLine* line)
|
||||
{
|
||||
char name[100];
|
||||
|
||||
if ( m_phase == ARP_WAIT ) return false;
|
||||
|
||||
sprintf(name, " aExist=%d", 1);
|
||||
strcat(line, name);
|
||||
|
||||
|
||||
line->AddParam("aExist", new CLevelParserParam(true));
|
||||
CAuto::Write(line);
|
||||
|
||||
sprintf(name, " aPhase=%d", m_phase);
|
||||
strcat(line, name);
|
||||
|
||||
sprintf(name, " aProgress=%.2f", m_progress);
|
||||
strcat(line, name);
|
||||
|
||||
sprintf(name, " aSpeed=%.2f", m_speed);
|
||||
strcat(line, name);
|
||||
line->AddParam("aPhase", new CLevelParserParam(static_cast<int>(m_phase)));
|
||||
line->AddParam("aProgress", new CLevelParserParam(m_progress));
|
||||
line->AddParam("aSpeed", new CLevelParserParam(m_speed));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -51,7 +51,7 @@ public:
|
|||
|
||||
bool CreateInterface(bool bSelect);
|
||||
|
||||
bool Write(char *line);
|
||||
bool Write(CLevelParserLine* line);
|
||||
bool Read(char *line);
|
||||
|
||||
protected:
|
||||
|
|
|
@ -25,6 +25,8 @@
|
|||
#include "math/geometry.h"
|
||||
|
||||
#include "object/robotmain.h"
|
||||
#include "object/level/parserline.h"
|
||||
#include "object/level/parserparam.h"
|
||||
|
||||
#include "script/cmdtoken.h"
|
||||
|
||||
|
@ -563,28 +565,16 @@ void CAutoResearch::FireStopUpdate(float progress, bool bLightOn)
|
|||
|
||||
// Saves all parameters of the controller.
|
||||
|
||||
bool CAutoResearch::Write(char *line)
|
||||
bool CAutoResearch::Write(CLevelParserLine* line)
|
||||
{
|
||||
char name[100];
|
||||
|
||||
if ( m_phase == ALP_WAIT ) return false;
|
||||
|
||||
sprintf(name, " aExist=%d", 1);
|
||||
strcat(line, name);
|
||||
|
||||
|
||||
line->AddParam("aExist", new CLevelParserParam(true));
|
||||
CAuto::Write(line);
|
||||
|
||||
sprintf(name, " aPhase=%d", m_phase);
|
||||
strcat(line, name);
|
||||
|
||||
sprintf(name, " aProgress=%.2f", m_progress);
|
||||
strcat(line, name);
|
||||
|
||||
sprintf(name, " aSpeed=%.2f", m_speed);
|
||||
strcat(line, name);
|
||||
|
||||
sprintf(name, " aResearch=%d", m_research);
|
||||
strcat(line, name);
|
||||
line->AddParam("aPhase", new CLevelParserParam(static_cast<int>(m_phase)));
|
||||
line->AddParam("aProgress", new CLevelParserParam(m_progress));
|
||||
line->AddParam("aSpeed", new CLevelParserParam(m_speed));
|
||||
line->AddParam("aResearch", new CLevelParserParam(static_cast<int>(m_research)));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -49,7 +49,7 @@ public:
|
|||
|
||||
bool CreateInterface(bool bSelect);
|
||||
|
||||
bool Write(char *line);
|
||||
bool Write(CLevelParserLine* line);
|
||||
bool Read(char *line);
|
||||
|
||||
protected:
|
||||
|
|
|
@ -25,6 +25,8 @@
|
|||
#include "math/geometry.h"
|
||||
|
||||
#include "object/robotmain.h"
|
||||
#include "object/level/parserline.h"
|
||||
#include "object/level/parserparam.h"
|
||||
|
||||
#include "script/cmdtoken.h"
|
||||
|
||||
|
@ -353,25 +355,15 @@ Error CAutoSafe::GetError()
|
|||
|
||||
// Saves all parameters of the controller.
|
||||
|
||||
bool CAutoSafe::Write(char *line)
|
||||
bool CAutoSafe::Write(CLevelParserLine* line)
|
||||
{
|
||||
char name[100];
|
||||
|
||||
if ( m_phase == ASAP_WAIT ) return false;
|
||||
|
||||
sprintf(name, " aExist=%d", 1);
|
||||
strcat(line, name);
|
||||
|
||||
|
||||
line->AddParam("aExist", new CLevelParserParam(true));
|
||||
CAuto::Write(line);
|
||||
|
||||
sprintf(name, " aPhase=%d", m_phase);
|
||||
strcat(line, name);
|
||||
|
||||
sprintf(name, " aProgress=%.2f", m_progress);
|
||||
strcat(line, name);
|
||||
|
||||
sprintf(name, " aSpeed=%.2f", m_speed);
|
||||
strcat(line, name);
|
||||
line->AddParam("aPhase", new CLevelParserParam(static_cast<int>(m_phase)));
|
||||
line->AddParam("aProgress", new CLevelParserParam(m_progress));
|
||||
line->AddParam("aSpeed", new CLevelParserParam(m_speed));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -49,7 +49,7 @@ public:
|
|||
|
||||
bool CreateInterface(bool bSelect);
|
||||
|
||||
bool Write(char *line);
|
||||
bool Write(CLevelParserLine* line);
|
||||
bool Read(char *line);
|
||||
|
||||
protected:
|
||||
|
|
|
@ -24,6 +24,9 @@
|
|||
|
||||
#include "math/geometry.h"
|
||||
|
||||
#include "object/level/parserline.h"
|
||||
#include "object/level/parserparam.h"
|
||||
|
||||
#include "physics/physics.h"
|
||||
|
||||
#include "script/cmdtoken.h"
|
||||
|
@ -485,40 +488,20 @@ void CAutoTower::UpdateInterface(float rTime)
|
|||
|
||||
// Saves all parameters of the controller.
|
||||
|
||||
bool CAutoTower::Write(char *line)
|
||||
bool CAutoTower::Write(CLevelParserLine* line)
|
||||
{
|
||||
char name[100];
|
||||
|
||||
if ( m_phase == ATP_WAIT ) return false;
|
||||
|
||||
sprintf(name, " aExist=%d", 1);
|
||||
strcat(line, name);
|
||||
|
||||
|
||||
line->AddParam("aExist", new CLevelParserParam(true));
|
||||
CAuto::Write(line);
|
||||
|
||||
sprintf(name, " aPhase=%d", m_phase);
|
||||
strcat(line, name);
|
||||
|
||||
sprintf(name, " aProgress=%.2f", m_progress);
|
||||
strcat(line, name);
|
||||
|
||||
sprintf(name, " aSpeed=%.2f", m_speed);
|
||||
strcat(line, name);
|
||||
|
||||
sprintf(name, " aTargetPos=%.2f;%.2f;%.2f", m_targetPos.x, m_targetPos.y, m_targetPos.z);
|
||||
strcat(line, name);
|
||||
|
||||
sprintf(name, " aAngleYactual=%.2f", m_angleYactual);
|
||||
strcat(line, name);
|
||||
|
||||
sprintf(name, " aAngleZactual=%.2f", m_angleZactual);
|
||||
strcat(line, name);
|
||||
|
||||
sprintf(name, " aAngleYfinal=%.2f", m_angleYfinal);
|
||||
strcat(line, name);
|
||||
|
||||
sprintf(name, " aAngleZfinal=%.2f", m_angleZfinal);
|
||||
strcat(line, name);
|
||||
line->AddParam("aPhase", new CLevelParserParam(static_cast<int>(m_phase)));
|
||||
line->AddParam("aProgress", new CLevelParserParam(m_progress));
|
||||
line->AddParam("aSpeed", new CLevelParserParam(m_speed));
|
||||
line->AddParam("aTargetPos", new CLevelParserParam(m_targetPos));
|
||||
line->AddParam("aAngleYactual", new CLevelParserParam(m_angleYactual));
|
||||
line->AddParam("aAngleZactual", new CLevelParserParam(m_angleZactual));
|
||||
line->AddParam("aAngleYfinal", new CLevelParserParam(m_angleYfinal));
|
||||
line->AddParam("aAngleZfinal", new CLevelParserParam(m_angleZfinal));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -51,7 +51,7 @@ public:
|
|||
|
||||
bool CreateInterface(bool bSelect);
|
||||
|
||||
bool Write(char *line);
|
||||
bool Write(CLevelParserLine* line);
|
||||
bool Read(char *line);
|
||||
|
||||
protected:
|
||||
|
|
|
@ -30,6 +30,8 @@
|
|||
|
||||
#include "object/motion/motion.h"
|
||||
#include "object/task/taskmanager.h"
|
||||
#include "object/level/parserline.h"
|
||||
#include "object/level/parserparam.h"
|
||||
|
||||
#include "physics/physics.h"
|
||||
|
||||
|
@ -169,12 +171,9 @@ void CBrain::SetMotion(CMotion* motion)
|
|||
|
||||
// Saves all parameters of the object.
|
||||
|
||||
bool CBrain::Write(char *line)
|
||||
bool CBrain::Write(CLevelParserLine* line)
|
||||
{
|
||||
char name[100];
|
||||
|
||||
sprintf(name, " bVirusActive=%d", m_bActiveVirus);
|
||||
strcat(line, name);
|
||||
line->AddParam("bVirusActive", new CLevelParserParam(m_bActiveVirus));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -41,6 +41,7 @@ class CTaskManager;
|
|||
class CScript;
|
||||
class CRobotMain;
|
||||
class CSoundInterface;
|
||||
class CLevelParserLine;
|
||||
|
||||
namespace Ui {
|
||||
class CStudio;
|
||||
|
@ -92,7 +93,7 @@ public:
|
|||
bool EventProcess(const Event &event);
|
||||
bool CreateInterface(bool bSelect);
|
||||
|
||||
bool Write(char *line);
|
||||
bool Write(CLevelParserLine* line);
|
||||
bool Read(char *line);
|
||||
|
||||
bool IsBusy();
|
||||
|
|
|
@ -236,7 +236,6 @@ void CLevelParser::Save()
|
|||
}
|
||||
|
||||
file.close();
|
||||
|
||||
}
|
||||
|
||||
const std::string& CLevelParser::GetFilename()
|
||||
|
|
|
@ -65,7 +65,6 @@ public:
|
|||
CLevelParserLine* Get(std::string command);
|
||||
|
||||
private:
|
||||
|
||||
std::string m_filename;
|
||||
std::vector<CLevelParserLine*> m_lines;
|
||||
};
|
|
@ -975,7 +975,7 @@ CLevelParserParam::CLevelParserParam(std::string value)
|
|||
}
|
||||
CLevelParserParam::CLevelParserParam(bool value)
|
||||
{
|
||||
m_value = value ? "true" : "false";
|
||||
m_value = value ? "1" : "0";
|
||||
}
|
||||
CLevelParserParam::CLevelParserParam(Gfx::Color value)
|
||||
{
|
||||
|
|
|
@ -23,6 +23,8 @@
|
|||
#include "app/app.h"
|
||||
|
||||
#include "object/robotmain.h"
|
||||
#include "object/level/parserline.h"
|
||||
#include "object/level/parserparam.h"
|
||||
|
||||
#include "script/cmdtoken.h"
|
||||
|
||||
|
@ -171,20 +173,13 @@ float CMotion::GetParam(int rank)
|
|||
|
||||
// Saves all parameters of the object.
|
||||
|
||||
bool CMotion::Write(char *line)
|
||||
bool CMotion::Write(CLevelParserLine* line)
|
||||
{
|
||||
char name[100];
|
||||
|
||||
if ( m_actionType == -1 ) return false;
|
||||
|
||||
sprintf(name, " mType=%d", m_actionType);
|
||||
strcat(line, name);
|
||||
|
||||
sprintf(name, " mTime=%.2f", m_actionTime);
|
||||
strcat(line, name);
|
||||
|
||||
sprintf(name, " mProgress=%.2f", m_progress);
|
||||
strcat(line, name);
|
||||
|
||||
line->AddParam("mType", new CLevelParserParam(m_actionType));
|
||||
line->AddParam("mTime", new CLevelParserParam(m_actionTime));
|
||||
line->AddParam("mProgress", new CLevelParserParam(m_progress));
|
||||
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -42,6 +42,7 @@ class CPhysics;
|
|||
class CObject;
|
||||
class CRobotMain;
|
||||
class CSoundInterface;
|
||||
class CLevelParserLine;
|
||||
|
||||
|
||||
class CMotion
|
||||
|
@ -62,7 +63,7 @@ public:
|
|||
virtual bool SetParam(int rank, float value);
|
||||
virtual float GetParam(int rank);
|
||||
|
||||
virtual bool Write(char *line);
|
||||
virtual bool Write(CLevelParserLine* line);
|
||||
virtual bool Read(char *line);
|
||||
|
||||
virtual void SetLinVibration(Math::Vector dir);
|
||||
|
|
|
@ -76,12 +76,16 @@
|
|||
#include "object/motion/motionworm.h"
|
||||
#include "object/robotmain.h"
|
||||
#include "object/objman.h"
|
||||
#include "object/level/parserline.h"
|
||||
#include "object/level/parserparam.h"
|
||||
|
||||
#include "physics/physics.h"
|
||||
|
||||
#include "script/cbottoken.h"
|
||||
#include "script/cmdtoken.h"
|
||||
|
||||
#include <boost/lexical_cast.hpp>
|
||||
|
||||
|
||||
|
||||
#define ADJUST_ONBOARD false // true -> adjusts the camera ONBOARD
|
||||
|
@ -995,137 +999,76 @@ int CObject::GetID()
|
|||
|
||||
// Saves all the parameters of the object.
|
||||
|
||||
bool CObject::Write(char *line)
|
||||
bool CObject::Write(CLevelParserLine* line)
|
||||
{
|
||||
Math::Vector pos;
|
||||
Info info;
|
||||
char name[100];
|
||||
float value;
|
||||
int i;
|
||||
|
||||
sprintf(name, " camera=%s", GetCamera(GetCameraType()));
|
||||
strcat(line, name);
|
||||
line->AddParam("camera", new CLevelParserParam(GetCameraType()));
|
||||
|
||||
if ( GetCameraLock() != 0 )
|
||||
{
|
||||
sprintf(name, " cameraLock=%d", GetCameraLock());
|
||||
strcat(line, name);
|
||||
}
|
||||
if ( GetCameraLock() )
|
||||
line->AddParam("cameraLock", new CLevelParserParam(GetCameraLock()));
|
||||
|
||||
if ( GetEnergy() != 0.0f )
|
||||
{
|
||||
sprintf(name, " energy=%.2f", GetEnergy());
|
||||
strcat(line, name);
|
||||
}
|
||||
line->AddParam("energy", new CLevelParserParam(GetEnergy()));
|
||||
|
||||
if ( GetCapacity() != 1.0f )
|
||||
{
|
||||
sprintf(name, " capacity=%.2f", GetCapacity());
|
||||
strcat(line, name);
|
||||
}
|
||||
|
||||
line->AddParam("capacity", new CLevelParserParam(GetCapacity()));
|
||||
|
||||
if ( GetShield() != 1.0f )
|
||||
{
|
||||
sprintf(name, " shield=%.2f", GetShield());
|
||||
strcat(line, name);
|
||||
}
|
||||
line->AddParam("shield", new CLevelParserParam(GetShield()));
|
||||
|
||||
if ( GetRange() != 1.0f )
|
||||
{
|
||||
sprintf(name, " range=%.2f", GetRange());
|
||||
strcat(line, name);
|
||||
}
|
||||
line->AddParam("range", new CLevelParserParam(GetRange()));
|
||||
|
||||
if ( !GetSelectable() )
|
||||
line->AddParam("selectable", new CLevelParserParam(GetSelectable()));
|
||||
|
||||
if ( GetSelectable() != 1 )
|
||||
{
|
||||
sprintf(name, " selectable=%d", GetSelectable());
|
||||
strcat(line, name);
|
||||
}
|
||||
if ( !GetEnable() )
|
||||
line->AddParam("enable", new CLevelParserParam(GetEnable()));
|
||||
|
||||
if ( GetEnable() != 1 )
|
||||
{
|
||||
sprintf(name, " enable=%d", GetEnable());
|
||||
strcat(line, name);
|
||||
}
|
||||
if ( GetFixed() )
|
||||
line->AddParam("fixed", new CLevelParserParam(GetFixed()));
|
||||
|
||||
if ( GetFixed() != 0 )
|
||||
{
|
||||
sprintf(name, " fixed=%d", GetFixed());
|
||||
strcat(line, name);
|
||||
}
|
||||
if ( !GetClip() )
|
||||
line->AddParam("clip", new CLevelParserParam(GetClip()));
|
||||
|
||||
if ( GetClip() != 1 )
|
||||
{
|
||||
sprintf(name, " clip=%d", GetClip());
|
||||
strcat(line, name);
|
||||
}
|
||||
if ( GetLock() )
|
||||
line->AddParam("lock", new CLevelParserParam(GetLock()));
|
||||
|
||||
if ( GetLock() != 0 )
|
||||
if ( GetProxyActivate() )
|
||||
{
|
||||
sprintf(name, " lock=%d", GetLock());
|
||||
strcat(line, name);
|
||||
}
|
||||
|
||||
if ( GetProxyActivate() != 0 )
|
||||
{
|
||||
sprintf(name, " proxyActivate=%d", GetProxyActivate());
|
||||
strcat(line, name);
|
||||
|
||||
sprintf(name, " proxyDistance=%.2f", GetProxyDistance()/g_unit);
|
||||
strcat(line, name);
|
||||
line->AddParam("proxyActivate", new CLevelParserParam(GetProxyActivate()));
|
||||
line->AddParam("proxyActivate", new CLevelParserParam(GetProxyDistance()/g_unit));
|
||||
}
|
||||
|
||||
if ( GetMagnifyDamage() != 1.0f )
|
||||
{
|
||||
sprintf(name, " magnifyDamage=%.2f", GetMagnifyDamage());
|
||||
strcat(line, name);
|
||||
}
|
||||
line->AddParam("magnifyDamage", new CLevelParserParam(GetMagnifyDamage()));
|
||||
|
||||
if ( GetGunGoalV() != 0.0f )
|
||||
{
|
||||
sprintf(name, " aimV=%.2f", GetGunGoalV());
|
||||
strcat(line, name);
|
||||
}
|
||||
line->AddParam("aimV", new CLevelParserParam(GetGunGoalV()));
|
||||
|
||||
if ( GetGunGoalH() != 0.0f )
|
||||
{
|
||||
sprintf(name, " aimH=%.2f", GetGunGoalH());
|
||||
strcat(line, name);
|
||||
}
|
||||
line->AddParam("aimH", new CLevelParserParam(GetGunGoalH()));
|
||||
|
||||
if ( GetParam() != 0.0f )
|
||||
{
|
||||
sprintf(name, " param=%.2f", GetParam());
|
||||
strcat(line, name);
|
||||
}
|
||||
line->AddParam("param", new CLevelParserParam(GetParam()));
|
||||
|
||||
if ( GetResetCap() != 0 )
|
||||
{
|
||||
sprintf(name, " resetCap=%d", GetResetCap());
|
||||
strcat(line, name);
|
||||
|
||||
pos = GetResetPosition()/g_unit;
|
||||
sprintf(name, " resetPos=%.2f;%.2f;%.2f", pos.x, pos.y, pos.z);
|
||||
strcat(line, name);
|
||||
|
||||
pos = GetResetAngle()/(Math::PI/180.0f);
|
||||
sprintf(name, " resetAngle=%.2f;%.2f;%.2f", pos.x, pos.y, pos.z);
|
||||
strcat(line, name);
|
||||
|
||||
sprintf(name, " resetRun=%d", GetResetRun());
|
||||
strcat(line, name);
|
||||
line->AddParam("resetCap", new CLevelParserParam(static_cast<int>(GetResetCap())));
|
||||
line->AddParam("resetPos", new CLevelParserParam(GetResetPosition()/g_unit));
|
||||
line->AddParam("resetAngle", new CLevelParserParam(GetResetAngle()/(Math::PI/180.0f)));
|
||||
line->AddParam("resetRun", new CLevelParserParam(GetResetRun()));
|
||||
}
|
||||
|
||||
if ( m_bVirusMode != 0 )
|
||||
{
|
||||
sprintf(name, " virusMode=%d", m_bVirusMode);
|
||||
strcat(line, name);
|
||||
}
|
||||
if ( m_bVirusMode )
|
||||
line->AddParam("virusMode", new CLevelParserParam(m_bVirusMode));
|
||||
|
||||
if ( m_virusTime != 0.0f )
|
||||
{
|
||||
sprintf(name, " virusTime=%.2f", m_virusTime);
|
||||
strcat(line, name);
|
||||
}
|
||||
line->AddParam("virusTime", new CLevelParserParam(m_virusTime));
|
||||
|
||||
// Puts information in terminal (OBJECT_INFO).
|
||||
for ( i=0 ; i<m_infoTotal ; i++ )
|
||||
|
@ -1133,20 +1076,20 @@ bool CObject::Write(char *line)
|
|||
info = GetInfo(i);
|
||||
if ( info.name[0] == 0 ) break;
|
||||
|
||||
sprintf(name, " info%d=\"%s=%.2f\"", i+1, info.name, info.value);
|
||||
strcat(line, name);
|
||||
line->AddParam("info"+boost::lexical_cast<std::string>(i+1), new CLevelParserParam(std::string(info.name)+"="+boost::lexical_cast<std::string>(info.value)));
|
||||
}
|
||||
|
||||
// Sets the parameters of the command line.
|
||||
std::vector<CLevelParserParam*> cmdline;
|
||||
for ( i=0 ; i<OBJECTMAXCMDLINE ; i++ )
|
||||
{
|
||||
value = GetCmdLine(i);
|
||||
if ( value == NAN ) break;
|
||||
|
||||
if ( i == 0 ) sprintf(name, " cmdline=%.2f", value);
|
||||
else sprintf(name, ";%.2f", value);
|
||||
strcat(line, name);
|
||||
cmdline.push_back(new CLevelParserParam(value));
|
||||
}
|
||||
if(cmdline.size() > 0)
|
||||
line->AddParam("cmdline", new CLevelParserParam(cmdline));
|
||||
|
||||
if ( m_motion != 0 )
|
||||
{
|
||||
|
|
|
@ -40,6 +40,7 @@ class CDisplayText;
|
|||
class CRobotMain;
|
||||
class CBotVar;
|
||||
class CScript;
|
||||
class CLevelParserLine;
|
||||
|
||||
|
||||
/**
|
||||
|
@ -379,7 +380,7 @@ public:
|
|||
void SetID(int id);
|
||||
int GetID();
|
||||
|
||||
bool Write(char *line);
|
||||
bool Write(CLevelParserLine* line);
|
||||
bool Read(char *line);
|
||||
|
||||
void SetDrawWorld(bool bDraw);
|
||||
|
|
|
@ -3781,8 +3781,6 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject)
|
|||
int rankGadget = 0;
|
||||
CObject* sel = 0;
|
||||
|
||||
SetNumericLocale();
|
||||
|
||||
/*
|
||||
* NOTE: Moving frequently used lines to the top
|
||||
* may speed up loading
|
||||
|
@ -4774,8 +4772,6 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject)
|
|||
}
|
||||
m_dialog->SetSceneRead("");
|
||||
m_dialog->SetStackRead("");
|
||||
|
||||
RestoreNumericLocale();
|
||||
|
||||
if(m_app->GetSceneTestMode())
|
||||
m_eventQueue->AddEvent(Event(EVENT_WIN));
|
||||
|
@ -5665,37 +5661,17 @@ bool CRobotMain::IsBusy()
|
|||
}
|
||||
|
||||
//! Writes an object into the backup file
|
||||
void CRobotMain::IOWriteObject(FILE *file, CObject* obj, const char *cmd)
|
||||
void CRobotMain::IOWriteObject(CLevelParserLine* line, CObject* obj)
|
||||
{
|
||||
if (obj->GetType() == OBJECT_FIX) return;
|
||||
|
||||
SetNumericLocale();
|
||||
|
||||
char line[3000];
|
||||
char name[100];
|
||||
|
||||
strcpy(line, cmd);
|
||||
|
||||
sprintf(name, " type=%s", GetTypeObject(obj->GetType()));
|
||||
strcat(line, name);
|
||||
|
||||
sprintf(name, " id=%d", obj->GetID());
|
||||
strcat(line, name);
|
||||
line->AddParam("type", new CLevelParserParam(obj->GetType()));
|
||||
line->AddParam("id", new CLevelParserParam(obj->GetID()));
|
||||
line->AddParam("pos", new CLevelParserParam(obj->GetPosition(0)/g_unit));
|
||||
line->AddParam("angle", new CLevelParserParam(obj->GetAngle(0)/(Math::PI/180.0f)));
|
||||
line->AddParam("zoom", new CLevelParserParam(obj->GetZoom(0)));
|
||||
|
||||
Math::Vector pos;
|
||||
|
||||
pos = obj->GetPosition(0)/g_unit;
|
||||
sprintf(name, " pos=%.2f;%.2f;%.2f", pos.x, pos.y, pos.z);
|
||||
strcat(line, name);
|
||||
|
||||
pos = obj->GetAngle(0)/(Math::PI/180.0f);
|
||||
sprintf(name, " angle=%.2f;%.2f;%.2f", pos.x, pos.y, pos.z);
|
||||
strcat(line, name);
|
||||
|
||||
pos = obj->GetZoom(0);
|
||||
sprintf(name, " zoom=%.2f;%.2f;%.2f", pos.x, pos.y, pos.z);
|
||||
strcat(line, name);
|
||||
|
||||
for (int i = 1; i < OBJECTMAXPART; i++)
|
||||
{
|
||||
if (obj->GetObjectRank(i) == -1) continue;
|
||||
|
@ -5704,64 +5680,43 @@ void CRobotMain::IOWriteObject(FILE *file, CObject* obj, const char *cmd)
|
|||
if (pos.x != 0.0f || pos.y != 0.0f || pos.z != 0.0f)
|
||||
{
|
||||
pos /= g_unit;
|
||||
sprintf(name, " p%d=%.2f;%.2f;%.2f", i, pos.x, pos.y, pos.z);
|
||||
strcat(line, name);
|
||||
line->AddParam("p"+boost::lexical_cast<std::string>(i), new CLevelParserParam(pos));
|
||||
}
|
||||
|
||||
pos = obj->GetAngle(i);
|
||||
if (pos.x != 0.0f || pos.y != 0.0f || pos.z != 0.0f)
|
||||
{
|
||||
pos /= (Math::PI/180.0f);
|
||||
sprintf(name, " a%d=%.2f;%.2f;%.2f", i, pos.x, pos.y, pos.z);
|
||||
strcat(line, name);
|
||||
line->AddParam("a"+boost::lexical_cast<std::string>(i), new CLevelParserParam(pos));
|
||||
}
|
||||
|
||||
pos = obj->GetZoom(i);
|
||||
if (pos.x != 1.0f || pos.y != 1.0f || pos.z != 1.0f)
|
||||
{
|
||||
sprintf(name, " z%d=%.2f;%.2f;%.2f", i, pos.x, pos.y, pos.z);
|
||||
strcat(line, name);
|
||||
line->AddParam("z"+boost::lexical_cast<std::string>(i), new CLevelParserParam(pos));
|
||||
}
|
||||
}
|
||||
|
||||
sprintf(name, " trainer=%d", obj->GetTrainer());
|
||||
strcat(line, name);
|
||||
line->AddParam("trainer", new CLevelParserParam(obj->GetTrainer()));
|
||||
line->AddParam("ignoreBuildCheck", new CLevelParserParam(obj->GetIgnoreBuildCheck()));
|
||||
line->AddParam("option", new CLevelParserParam(obj->GetOption()));
|
||||
if (obj == m_infoObject)
|
||||
line->AddParam("select", new CLevelParserParam(1));
|
||||
|
||||
sprintf(name, " ignoreBuildCheck=%d", obj->GetIgnoreBuildCheck());
|
||||
strcat(line, name);
|
||||
|
||||
sprintf(name, " option=%d", obj->GetOption());
|
||||
strcat(line, name);
|
||||
|
||||
if (obj == m_infoObject) // selects object?
|
||||
{
|
||||
sprintf(name, " select=1");
|
||||
strcat(line, name);
|
||||
}
|
||||
|
||||
obj->Write(line);
|
||||
|
||||
if (obj->GetType() == OBJECT_BASE)
|
||||
{
|
||||
sprintf(name, " run=3"); // stops and open (PARAM_FIXSCENE)
|
||||
strcat(line, name);
|
||||
}
|
||||
|
||||
|
||||
if(obj->GetType() == OBJECT_BASE)
|
||||
line->AddParam("run", new CLevelParserParam(3)); // stops and open (PARAM_FIXSCENE)
|
||||
|
||||
CBrain* brain = obj->GetBrain();
|
||||
if (brain != nullptr)
|
||||
{
|
||||
int run = brain->GetProgram();
|
||||
if (run != -1)
|
||||
{
|
||||
sprintf(name, " run=%d", run+1);
|
||||
strcat(line, name);
|
||||
line->AddParam("run", new CLevelParserParam(run+1));
|
||||
}
|
||||
}
|
||||
|
||||
strcat(line, "\n");
|
||||
fputs(line, file);
|
||||
|
||||
RestoreNumericLocale();
|
||||
}
|
||||
|
||||
//! Saves the current game
|
||||
|
@ -5773,53 +5728,46 @@ bool CRobotMain::IOWriteScene(const char *filename, const char *filecbot, char *
|
|||
boost::replace_all(savedir, "\\", "/");
|
||||
boost::replace_all(fnstr, savedir, ""); //TODO: Refactor to get physfs path here
|
||||
|
||||
/*CLevelParser* level = new CLevelParser(fnstr);
|
||||
CLevelParserLine* line1 = new CLevelParserLine("TestCommand");
|
||||
line1->AddParam("test", new CLevelParserParam(1.0f));
|
||||
level->AddLine(line1);
|
||||
CLevelParserLine* line2 = new CLevelParserLine("TestCommand2");
|
||||
line2->AddParam("testStr", new CLevelParserParam("12345"));
|
||||
line2->AddParam("testBool", new CLevelParserParam(true));
|
||||
level->AddLine(line2);
|
||||
level->Save();
|
||||
delete level;
|
||||
return true;*/
|
||||
CLevelParser* level = new CLevelParser(fnstr);
|
||||
CLevelParserLine* line;
|
||||
|
||||
line = new CLevelParserLine("Title");
|
||||
line->AddParam("text", new CLevelParserParam(std::string(info)));
|
||||
level->AddLine(line);
|
||||
|
||||
FILE* file = fopen(filename, "w");
|
||||
if (file == NULL) return false;
|
||||
|
||||
SetNumericLocale();
|
||||
|
||||
char line[500];
|
||||
|
||||
sprintf(line, "Title text=\"%s\"\n", info);
|
||||
fputs(line, file);
|
||||
|
||||
sprintf(line, "Version maj=%d min=%d\n", 0, 1);
|
||||
fputs(line, file);
|
||||
//TODO: Do we need that? It's not used anyway
|
||||
line = new CLevelParserLine("Version");
|
||||
line->AddParam("maj", new CLevelParserParam(0));
|
||||
line->AddParam("min", new CLevelParserParam(1));
|
||||
level->AddLine(line);
|
||||
|
||||
char* name = m_dialog->GetSceneName();
|
||||
if (strcmp(name, "user") == 0)
|
||||
line = new CLevelParserLine("Mission");
|
||||
line->AddParam("base", new CLevelParserParam(std::string(name)));
|
||||
line->AddParam("rank", new CLevelParserParam(m_dialog->GetSceneRank()));
|
||||
if (std::string(name) == "custom")
|
||||
{
|
||||
sprintf(line, "Mission base=\"%s\" rank=%.3d dir=\"%s\"\n", name, m_dialog->GetSceneRank(), m_dialog->GetSceneDir());
|
||||
line->AddParam("dir", new CLevelParserParam(std::string(m_dialog->GetSceneDir())));
|
||||
}
|
||||
else
|
||||
{
|
||||
sprintf(line, "Mission base=\"%s\" rank=%.3d\n", name, m_dialog->GetSceneRank());
|
||||
}
|
||||
fputs(line, file);
|
||||
level->AddLine(line);
|
||||
|
||||
sprintf(line, "Map zoom=%.2f\n", m_map->GetZoomMap());
|
||||
fputs(line, file);
|
||||
line = new CLevelParserLine("Map");
|
||||
line->AddParam("zoom", new CLevelParserParam(m_map->GetZoomMap()));
|
||||
level->AddLine(line);
|
||||
|
||||
sprintf(line, "DoneResearch bits=%d\n", static_cast<int>(g_researchDone));
|
||||
fputs(line, file);
|
||||
line = new CLevelParserLine("DoneResearch");
|
||||
line->AddParam("bits", new CLevelParserParam(static_cast<int>(g_researchDone)));
|
||||
level->AddLine(line);
|
||||
|
||||
float sleep, delay, magnetic, progress;
|
||||
if (m_lightning->GetStatus(sleep, delay, magnetic, progress))
|
||||
{
|
||||
sprintf(line, "BlitzMode sleep=%.2f delay=%.2f magnetic=%.2f progress=%.2f\n", sleep, delay, magnetic/g_unit, progress);
|
||||
fputs(line, file);
|
||||
line = new CLevelParserLine("BlitzMode");
|
||||
line->AddParam("sleep", new CLevelParserParam(sleep));
|
||||
line->AddParam("delay", new CLevelParserParam(delay));
|
||||
line->AddParam("magnetic", new CLevelParserParam(magnetic/g_unit));
|
||||
line->AddParam("progress", new CLevelParserParam(progress));
|
||||
level->AddLine(line);
|
||||
}
|
||||
|
||||
CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
|
||||
|
@ -5840,23 +5788,36 @@ bool CRobotMain::IOWriteScene(const char *filename, const char *filecbot, char *
|
|||
CObject* power = obj->GetPower();
|
||||
CObject* fret = obj->GetFret();
|
||||
|
||||
if (fret != nullptr) // object transported?
|
||||
IOWriteObject(file, fret, "CreateFret");
|
||||
if (fret != nullptr){ // object transported?
|
||||
line = new CLevelParserLine("CreateFret");
|
||||
IOWriteObject(line, fret);
|
||||
level->AddLine(line);
|
||||
}
|
||||
|
||||
if (power != nullptr) // battery transported?
|
||||
IOWriteObject(file, power, "CreatePower");
|
||||
|
||||
IOWriteObject(file, obj, "CreateObject");
|
||||
if (power != nullptr) { // battery transported?
|
||||
line = new CLevelParserLine("CreatePower");
|
||||
IOWriteObject(line, power);
|
||||
level->AddLine(line);
|
||||
}
|
||||
|
||||
line = new CLevelParserLine("CreateObject");
|
||||
IOWriteObject(line, obj);
|
||||
level->AddLine(line);
|
||||
|
||||
SaveFileScript(obj, filename, objRank++);
|
||||
}
|
||||
fclose(file);
|
||||
|
||||
RestoreNumericLocale();
|
||||
try {
|
||||
level->Save();
|
||||
} catch(CLevelParserException& e) {
|
||||
CLogger::GetInstancePointer()->Error("Failed to save level state - %s\n", e.what());
|
||||
delete level;
|
||||
return false;
|
||||
}
|
||||
delete level;
|
||||
|
||||
#if CBOT_STACK
|
||||
// Writes the file of stacks of execution.
|
||||
file = fOpen(filecbot, "wb");
|
||||
FILE* file = fOpen(filecbot, "wb");
|
||||
if (file == NULL) return false;
|
||||
|
||||
long version = 1;
|
||||
|
@ -5898,8 +5859,6 @@ CObject* CRobotMain::IOReadObject(char *line, const char* filename, int objRank)
|
|||
if (type == OBJECT_NULL)
|
||||
return nullptr;
|
||||
|
||||
SetNumericLocale();
|
||||
|
||||
int trainer = OpInt(line, "trainer", 0);
|
||||
int toy = OpInt(line, "toy", 0);
|
||||
int option = OpInt(line, "option", 0);
|
||||
|
@ -5966,8 +5925,6 @@ CObject* CRobotMain::IOReadObject(char *line, const char* filename, int objRank)
|
|||
automat->Start(run); // starts the film
|
||||
}
|
||||
|
||||
RestoreNumericLocale();
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
||||
|
@ -5979,8 +5936,6 @@ CObject* CRobotMain::IOReadScene(const char *filename, const char *filecbot)
|
|||
FILE* file = fopen(filename, "r");
|
||||
if (file == NULL) return 0;
|
||||
|
||||
SetNumericLocale();
|
||||
|
||||
CObject* fret = nullptr;
|
||||
CObject* power = nullptr;
|
||||
CObject* sel = nullptr;
|
||||
|
@ -6102,8 +6057,6 @@ CObject* CRobotMain::IOReadScene(const char *filename, const char *filecbot)
|
|||
}
|
||||
#endif
|
||||
|
||||
RestoreNumericLocale();
|
||||
|
||||
return sel;
|
||||
}
|
||||
|
||||
|
@ -7004,20 +6957,6 @@ void CRobotMain::ClearInterface()
|
|||
m_tooltipName.clear(); // really removes the tooltip
|
||||
}
|
||||
|
||||
void CRobotMain::SetNumericLocale()
|
||||
{
|
||||
char *locale = setlocale(LC_NUMERIC, nullptr);
|
||||
if (locale != nullptr)
|
||||
m_oldLocale = locale;
|
||||
|
||||
setlocale(LC_NUMERIC, "C");
|
||||
}
|
||||
|
||||
void CRobotMain::RestoreNumericLocale()
|
||||
{
|
||||
setlocale(LC_NUMERIC, m_oldLocale.c_str());
|
||||
}
|
||||
|
||||
void CRobotMain::DisplayError(Error err, CObject* pObj, float time)
|
||||
{
|
||||
m_displayText->DisplayError(err, pObj, time);
|
||||
|
|
|
@ -76,6 +76,7 @@ enum Phase
|
|||
|
||||
class CEventQueue;
|
||||
class CSoundInterface;
|
||||
class CLevelParserLine;
|
||||
|
||||
namespace Gfx {
|
||||
class CEngine;
|
||||
|
@ -383,14 +384,11 @@ public:
|
|||
bool IsBusy();
|
||||
bool IOWriteScene(const char *filename, const char *filecbot, char *info);
|
||||
CObject* IOReadScene(const char *filename, const char *filecbot);
|
||||
void IOWriteObject(FILE *file, CObject* pObj, const char *cmd);
|
||||
void IOWriteObject(CLevelParserLine *file, CObject* pObj);
|
||||
CObject* IOReadObject(char *line, const char* filename, int objRank);
|
||||
|
||||
int CreateSpot(Math::Vector pos, Gfx::Color color);
|
||||
|
||||
void SetNumericLocale();
|
||||
void RestoreNumericLocale();
|
||||
|
||||
CObject* GetSelect();
|
||||
|
||||
void DisplayError(Error err, CObject* pObj, float time=10.0f);
|
||||
|
@ -588,8 +586,6 @@ protected:
|
|||
Gfx::Color m_colorRefWater;
|
||||
Gfx::Color m_colorNewWater;
|
||||
float m_colorShiftWater;
|
||||
|
||||
std::string m_oldLocale;
|
||||
|
||||
bool m_missionTimerEnabled;
|
||||
bool m_missionTimerStarted;
|
||||
|
|
|
@ -40,6 +40,8 @@
|
|||
#include "object/motion/motion.h"
|
||||
#include "object/motion/motionhuman.h"
|
||||
#include "object/task/task.h"
|
||||
#include "object/level/parserline.h"
|
||||
#include "object/level/parserparam.h"
|
||||
|
||||
#include "script/cmdtoken.h"
|
||||
|
||||
|
@ -171,20 +173,14 @@ PhysicsType CPhysics::GetType()
|
|||
|
||||
// Saves all parameters of the object.
|
||||
|
||||
bool CPhysics::Write(char *line)
|
||||
bool CPhysics::Write(CLevelParserLine* line)
|
||||
{
|
||||
char name[100];
|
||||
|
||||
sprintf(name, " motor=%.2f;%.2f;%.2f", m_motorSpeed.x, m_motorSpeed.y, m_motorSpeed.z);
|
||||
strcat(line, name);
|
||||
line->AddParam("motor", new CLevelParserParam(m_motorSpeed));
|
||||
|
||||
if ( m_type == TYPE_FLYING )
|
||||
{
|
||||
sprintf(name, " reactorRange=%.2f", GetReactorRange());
|
||||
strcat(line, name);
|
||||
|
||||
sprintf(name, " land=%d", GetLand());
|
||||
strcat(line, name);
|
||||
line->AddParam("reactorRange", new CLevelParserParam(GetReactorRange()));
|
||||
line->AddParam("land", new CLevelParserParam(GetLand()));
|
||||
}
|
||||
|
||||
return true;
|
||||
|
|
|
@ -36,6 +36,7 @@ class CObject;
|
|||
class CBrain;
|
||||
class CMotion;
|
||||
class CSoundInterface;
|
||||
class CLevelParserLine;
|
||||
|
||||
namespace Gfx {
|
||||
class CCamera;
|
||||
|
@ -110,7 +111,7 @@ public:
|
|||
void SetType(PhysicsType type);
|
||||
PhysicsType GetType();
|
||||
|
||||
bool Write(char *line);
|
||||
bool Write(CLevelParserLine* line);
|
||||
bool Read(char *line);
|
||||
|
||||
void SetGravity(float value);
|
||||
|
|
|
@ -6070,8 +6070,6 @@ void CMainDialog::WriteGamerPerso(char *gamer)
|
|||
file = fopen(filename, "w");
|
||||
if ( file == NULL ) return;
|
||||
|
||||
m_main->SetNumericLocale();
|
||||
|
||||
sprintf(line, "Head face=%d glasses=%d hair=%.2f;%.2f;%.2f;%.2f\n",
|
||||
m_perso.face, m_perso.glasses,
|
||||
m_perso.colorHair.r, m_perso.colorHair.g, m_perso.colorHair.b, m_perso.colorHair.a);
|
||||
|
@ -6083,8 +6081,6 @@ void CMainDialog::WriteGamerPerso(char *gamer)
|
|||
fputs(line, file);
|
||||
|
||||
fclose(file);
|
||||
|
||||
m_main->RestoreNumericLocale();
|
||||
}
|
||||
|
||||
// Reads the personalized player.
|
||||
|
@ -6103,8 +6099,6 @@ void CMainDialog::ReadGamerPerso(char *gamer)
|
|||
file = fopen(filename, "r");
|
||||
if ( file == NULL ) return;
|
||||
|
||||
m_main->SetNumericLocale();
|
||||
|
||||
while ( fgets(line, 100, file) != NULL )
|
||||
{
|
||||
if ( Cmd(line, "Head") )
|
||||
|
@ -6136,8 +6130,6 @@ void CMainDialog::ReadGamerPerso(char *gamer)
|
|||
}
|
||||
|
||||
fclose(file);
|
||||
|
||||
m_main->RestoreNumericLocale();
|
||||
}
|
||||
|
||||
// Specifies the face of the player.
|
||||
|
|
Loading…
Reference in New Issue