Use MakeUnique with level parser classes

master
Piotr Dziwinski 2015-07-17 20:36:01 +02:00
parent 35043e04de
commit b3b6435039
28 changed files with 207 additions and 175 deletions

View File

@ -27,7 +27,6 @@
#include "common/event.h" #include "common/event.h"
#include "common/global.h" #include "common/global.h"
#include "common/make_unique.h"
#include "graphics/core/color.h" #include "graphics/core/color.h"
#include "graphics/engine/pyro_type.h" #include "graphics/engine/pyro_type.h"

View File

@ -23,6 +23,7 @@
#include "app/app.h" #include "app/app.h"
#include "common/event.h" #include "common/event.h"
#include "common/make_unique.h"
#include "object/level/parserline.h" #include "object/level/parserline.h"
#include "object/level/parserparam.h" #include "object/level/parserparam.h"
@ -419,11 +420,11 @@ void CAuto::SetMotor(bool bMotor)
bool CAuto::Write(CLevelParserLine* line) bool CAuto::Write(CLevelParserLine* line)
{ {
line->AddParam("aType", CLevelParserParamUPtr{new CLevelParserParam(m_type)}); line->AddParam("aType", MakeUnique<CLevelParserParam>(m_type));
line->AddParam("aBusy", CLevelParserParamUPtr{new CLevelParserParam(m_bBusy)}); line->AddParam("aBusy", MakeUnique<CLevelParserParam>(m_bBusy));
line->AddParam("aTime", CLevelParserParamUPtr{new CLevelParserParam(m_time)}); line->AddParam("aTime", MakeUnique<CLevelParserParam>(m_time));
line->AddParam("aProgressTime", CLevelParserParamUPtr{new CLevelParserParam(m_progressTime)}); line->AddParam("aProgressTime", MakeUnique<CLevelParserParam>(m_progressTime));
line->AddParam("aProgressTotal", CLevelParserParamUPtr{new CLevelParserParam(m_progressTotal)}); line->AddParam("aProgressTotal", MakeUnique<CLevelParserParam>(m_progressTotal));
return false; return false;
} }

View File

@ -20,6 +20,8 @@
#include "object/auto/autoconvert.h" #include "object/auto/autoconvert.h"
#include "common/make_unique.h"
#include "math/geometry.h" #include "math/geometry.h"
#include "object/object_manager.h" #include "object/object_manager.h"
@ -359,11 +361,11 @@ bool CAutoConvert::Write(CLevelParserLine* line)
if ( m_phase == ACP_STOP || if ( m_phase == ACP_STOP ||
m_phase == ACP_WAIT ) return false; m_phase == ACP_WAIT ) return false;
line->AddParam("aExist", CLevelParserParamUPtr{new CLevelParserParam(true)}); line->AddParam("aExist", MakeUnique<CLevelParserParam>(true));
CAuto::Write(line); CAuto::Write(line);
line->AddParam("aPhase", CLevelParserParamUPtr{new CLevelParserParam(static_cast<int>(m_phase))}); line->AddParam("aPhase", MakeUnique<CLevelParserParam>(static_cast<int>(m_phase)));
line->AddParam("aProgress", CLevelParserParamUPtr{new CLevelParserParam(m_progress)}); line->AddParam("aProgress", MakeUnique<CLevelParserParam>(m_progress));
line->AddParam("aSpeed", CLevelParserParamUPtr{new CLevelParserParam(m_speed)}); line->AddParam("aSpeed", MakeUnique<CLevelParserParam>(m_speed));
return true; return true;
} }

View File

@ -20,6 +20,8 @@
#include "object/auto/autoderrick.h" #include "object/auto/autoderrick.h"
#include "common/make_unique.h"
#include "graphics/engine/terrain.h" #include "graphics/engine/terrain.h"
#include "math/geometry.h" #include "math/geometry.h"
@ -428,11 +430,11 @@ bool CAutoDerrick::Write(CLevelParserLine* line)
{ {
if ( m_phase == ADP_WAIT ) return false; if ( m_phase == ADP_WAIT ) return false;
line->AddParam("aExist", CLevelParserParamUPtr{new CLevelParserParam(true)}); line->AddParam("aExist", MakeUnique<CLevelParserParam>(true));
CAuto::Write(line); CAuto::Write(line);
line->AddParam("aPhase", CLevelParserParamUPtr{new CLevelParserParam(static_cast<int>(m_phase))}); line->AddParam("aPhase", MakeUnique<CLevelParserParam>(static_cast<int>(m_phase)));
line->AddParam("aProgress", CLevelParserParamUPtr{new CLevelParserParam(m_progress)}); line->AddParam("aProgress", MakeUnique<CLevelParserParam>(m_progress));
line->AddParam("aSpeed", CLevelParserParamUPtr{new CLevelParserParam(m_speed)}); line->AddParam("aSpeed", MakeUnique<CLevelParserParam>(m_speed));
return true; return true;
} }

View File

@ -20,6 +20,8 @@
#include "object/auto/autodestroyer.h" #include "object/auto/autodestroyer.h"
#include "common/make_unique.h"
#include "graphics/engine/pyro_manager.h" #include "graphics/engine/pyro_manager.h"
#include "object/object_manager.h" #include "object/object_manager.h"
@ -352,11 +354,11 @@ bool CAutoDestroyer::Write(CLevelParserLine* line)
{ {
if ( m_phase == ADEP_WAIT ) return false; if ( m_phase == ADEP_WAIT ) return false;
line->AddParam("aExist", CLevelParserParamUPtr{new CLevelParserParam(true)}); line->AddParam("aExist", MakeUnique<CLevelParserParam>(true));
CAuto::Write(line); CAuto::Write(line);
line->AddParam("aPhase", CLevelParserParamUPtr{new CLevelParserParam(static_cast<int>(m_phase))}); line->AddParam("aPhase", MakeUnique<CLevelParserParam>(static_cast<int>(m_phase)));
line->AddParam("aProgress", CLevelParserParamUPtr{new CLevelParserParam(m_progress)}); line->AddParam("aProgress", MakeUnique<CLevelParserParam>(m_progress));
line->AddParam("aSpeed", CLevelParserParamUPtr{new CLevelParserParam(m_speed)}); line->AddParam("aSpeed", MakeUnique<CLevelParserParam>(m_speed));
return true; return true;
} }

View File

@ -20,6 +20,8 @@
#include "object/auto/autoegg.h" #include "object/auto/autoegg.h"
#include "common/make_unique.h"
#include "graphics/engine/pyro_manager.h" #include "graphics/engine/pyro_manager.h"
#include "math/geometry.h" #include "math/geometry.h"
@ -300,14 +302,14 @@ bool CAutoEgg::Write(CLevelParserLine* line)
{ {
if ( m_phase == AEP_NULL ) return false; if ( m_phase == AEP_NULL ) return false;
line->AddParam("aExist", CLevelParserParamUPtr{new CLevelParserParam(true)}); line->AddParam("aExist", MakeUnique<CLevelParserParam>(true));
CAuto::Write(line); CAuto::Write(line);
line->AddParam("aPhase", CLevelParserParamUPtr{new CLevelParserParam(static_cast<int>(m_phase))}); line->AddParam("aPhase", MakeUnique<CLevelParserParam>(static_cast<int>(m_phase)));
line->AddParam("aProgress", CLevelParserParamUPtr{new CLevelParserParam(m_progress)}); line->AddParam("aProgress", MakeUnique<CLevelParserParam>(m_progress));
line->AddParam("aSpeed", CLevelParserParamUPtr{new CLevelParserParam(m_speed)}); line->AddParam("aSpeed", MakeUnique<CLevelParserParam>(m_speed));
line->AddParam("aParamType", CLevelParserParamUPtr{new CLevelParserParam(m_type)}); line->AddParam("aParamType", MakeUnique<CLevelParserParam>(m_type));
line->AddParam("aParamValue1", CLevelParserParamUPtr{new CLevelParserParam(m_value)}); line->AddParam("aParamValue1", MakeUnique<CLevelParserParam>(m_value));
line->AddParam("aParamString", CLevelParserParamUPtr{new CLevelParserParam(m_alienProgramName)}); line->AddParam("aParamString", MakeUnique<CLevelParserParam>(m_alienProgramName));
return true; return true;
} }

View File

@ -21,6 +21,7 @@
#include "object/auto/autofactory.h" #include "object/auto/autofactory.h"
#include "common/global.h" #include "common/global.h"
#include "common/make_unique.h"
#include "math/geometry.h" #include "math/geometry.h"
@ -521,11 +522,11 @@ bool CAutoFactory::Write(CLevelParserLine* line)
{ {
if ( m_phase == AFP_WAIT ) return false; if ( m_phase == AFP_WAIT ) return false;
line->AddParam("aExist", CLevelParserParamUPtr{new CLevelParserParam(true)}); line->AddParam("aExist", MakeUnique<CLevelParserParam>(true));
CAuto::Write(line); CAuto::Write(line);
line->AddParam("aPhase", CLevelParserParamUPtr{new CLevelParserParam(static_cast<int>(m_phase))}); line->AddParam("aPhase", MakeUnique<CLevelParserParam>(static_cast<int>(m_phase)));
line->AddParam("aProgress", CLevelParserParamUPtr{new CLevelParserParam(m_progress)}); line->AddParam("aProgress", MakeUnique<CLevelParserParam>(m_progress));
line->AddParam("aSpeed", CLevelParserParamUPtr{new CLevelParserParam(m_speed)}); line->AddParam("aSpeed", MakeUnique<CLevelParserParam>(m_speed));
return true; return true;
} }

View File

@ -21,6 +21,7 @@
#include "object/auto/autolabo.h" #include "object/auto/autolabo.h"
#include "common/global.h" #include "common/global.h"
#include "common/make_unique.h"
#include "common/misc.h" #include "common/misc.h"
#include "math/geometry.h" #include "math/geometry.h"
@ -563,12 +564,12 @@ bool CAutoLabo::Write(CLevelParserLine* line)
{ {
if ( m_phase == ALAP_WAIT ) return false; if ( m_phase == ALAP_WAIT ) return false;
line->AddParam("aExist", CLevelParserParamUPtr{new CLevelParserParam(true)}); line->AddParam("aExist", MakeUnique<CLevelParserParam>(true));
CAuto::Write(line); CAuto::Write(line);
line->AddParam("aPhase", CLevelParserParamUPtr{new CLevelParserParam(static_cast<int>(m_phase))}); line->AddParam("aPhase", MakeUnique<CLevelParserParam>(static_cast<int>(m_phase)));
line->AddParam("aProgress", CLevelParserParamUPtr{new CLevelParserParam(m_progress)}); line->AddParam("aProgress", MakeUnique<CLevelParserParam>(m_progress));
line->AddParam("aSpeed", CLevelParserParamUPtr{new CLevelParserParam(m_speed)}); line->AddParam("aSpeed", MakeUnique<CLevelParserParam>(m_speed));
line->AddParam("aResearch", CLevelParserParamUPtr{new CLevelParserParam(static_cast<int>(m_research))}); line->AddParam("aResearch", MakeUnique<CLevelParserParam>(static_cast<int>(m_research)));
return true; return true;
} }

View File

@ -20,6 +20,8 @@
#include "object/auto/automush.h" #include "object/auto/automush.h"
#include "common/make_unique.h"
#include "object/object_manager.h" #include "object/object_manager.h"
#include "object/old_object.h" #include "object/old_object.h"
#include "object/level/parserline.h" #include "object/level/parserline.h"
@ -294,11 +296,11 @@ bool CAutoMush::Write(CLevelParserLine* line)
{ {
if ( m_phase == AMP_WAIT ) return false; if ( m_phase == AMP_WAIT ) return false;
line->AddParam("aExist", CLevelParserParamUPtr{new CLevelParserParam(true)}); line->AddParam("aExist", MakeUnique<CLevelParserParam>(true));
CAuto::Write(line); CAuto::Write(line);
line->AddParam("aPhase", CLevelParserParamUPtr{new CLevelParserParam(static_cast<int>(m_phase))}); line->AddParam("aPhase", MakeUnique<CLevelParserParam>(static_cast<int>(m_phase)));
line->AddParam("aProgress", CLevelParserParamUPtr{new CLevelParserParam(m_progress)}); line->AddParam("aProgress", MakeUnique<CLevelParserParam>(m_progress));
line->AddParam("aSpeed", CLevelParserParamUPtr{new CLevelParserParam(m_speed)}); line->AddParam("aSpeed", MakeUnique<CLevelParserParam>(m_speed));
return true; return true;
} }

View File

@ -20,6 +20,8 @@
#include "object/auto/autonest.h" #include "object/auto/autonest.h"
#include "common/make_unique.h"
#include "graphics/engine/terrain.h" #include "graphics/engine/terrain.h"
#include "object/object_manager.h" #include "object/object_manager.h"
@ -209,11 +211,11 @@ bool CAutoNest::Write(CLevelParserLine* line)
{ {
if ( m_phase == ANP_WAIT ) return false; if ( m_phase == ANP_WAIT ) return false;
line->AddParam("aExist", CLevelParserParamUPtr{new CLevelParserParam(true)}); line->AddParam("aExist", MakeUnique<CLevelParserParam>(true));
CAuto::Write(line); CAuto::Write(line);
line->AddParam("aPhase", CLevelParserParamUPtr{new CLevelParserParam(static_cast<int>(m_phase))}); line->AddParam("aPhase", MakeUnique<CLevelParserParam>(static_cast<int>(m_phase)));
line->AddParam("aProgress", CLevelParserParamUPtr{new CLevelParserParam(m_progress)}); line->AddParam("aProgress", MakeUnique<CLevelParserParam>(m_progress));
line->AddParam("aSpeed", CLevelParserParamUPtr{new CLevelParserParam(m_speed)}); line->AddParam("aSpeed", MakeUnique<CLevelParserParam>(m_speed));
return true; return true;
} }

View File

@ -20,6 +20,8 @@
#include "object/auto/autonuclearplant.h" #include "object/auto/autonuclearplant.h"
#include "common/make_unique.h"
#include "math/geometry.h" #include "math/geometry.h"
#include "object/object_manager.h" #include "object/object_manager.h"
@ -426,11 +428,11 @@ bool CAutoNuclearPlant::Write(CLevelParserLine* line)
if ( m_phase == ANUP_STOP || if ( m_phase == ANUP_STOP ||
m_phase == ANUP_WAIT ) return false; m_phase == ANUP_WAIT ) return false;
line->AddParam("aExist", CLevelParserParamUPtr{new CLevelParserParam(true)}); line->AddParam("aExist", MakeUnique<CLevelParserParam>(true));
CAuto::Write(line); CAuto::Write(line);
line->AddParam("aPhase", CLevelParserParamUPtr{new CLevelParserParam(static_cast<int>(m_phase))}); line->AddParam("aPhase", MakeUnique<CLevelParserParam>(static_cast<int>(m_phase)));
line->AddParam("aProgress", CLevelParserParamUPtr{new CLevelParserParam(m_progress)}); line->AddParam("aProgress", MakeUnique<CLevelParserParam>(m_progress));
line->AddParam("aSpeed", CLevelParserParamUPtr{new CLevelParserParam(m_speed)}); line->AddParam("aSpeed", MakeUnique<CLevelParserParam>(m_speed));
return true; return true;
} }

View File

@ -20,6 +20,7 @@
#include "object/auto/autopowercaptor.h" #include "object/auto/autopowercaptor.h"
#include "common/make_unique.h"
#include "math/geometry.h" #include "math/geometry.h"
@ -291,11 +292,11 @@ bool CAutoPowerCaptor::Write(CLevelParserLine* line)
{ {
if ( m_phase == APAP_WAIT ) return false; if ( m_phase == APAP_WAIT ) return false;
line->AddParam("aExist", CLevelParserParamUPtr{new CLevelParserParam(true)}); line->AddParam("aExist", MakeUnique<CLevelParserParam>(true));
CAuto::Write(line); CAuto::Write(line);
line->AddParam("aPhase", CLevelParserParamUPtr{new CLevelParserParam(static_cast<int>(m_phase))}); line->AddParam("aPhase", MakeUnique<CLevelParserParam>(static_cast<int>(m_phase)));
line->AddParam("aProgress", CLevelParserParamUPtr{new CLevelParserParam(m_progress)}); line->AddParam("aProgress", MakeUnique<CLevelParserParam>(m_progress));
line->AddParam("aSpeed", CLevelParserParamUPtr{new CLevelParserParam(m_speed)}); line->AddParam("aSpeed", MakeUnique<CLevelParserParam>(m_speed));
return true; return true;
} }

View File

@ -20,6 +20,8 @@
#include "object/auto/autopowerplant.h" #include "object/auto/autopowerplant.h"
#include "common/make_unique.h"
#include "graphics/engine/terrain.h" #include "graphics/engine/terrain.h"
#include "math/geometry.h" #include "math/geometry.h"
@ -580,11 +582,11 @@ bool CAutoPowerPlant::Write(CLevelParserLine* line)
if ( m_phase == AENP_STOP || if ( m_phase == AENP_STOP ||
m_phase == AENP_WAIT ) return false; m_phase == AENP_WAIT ) return false;
line->AddParam("aExist", CLevelParserParamUPtr{new CLevelParserParam(true)}); line->AddParam("aExist", MakeUnique<CLevelParserParam>(true));
CAuto::Write(line); CAuto::Write(line);
line->AddParam("aPhase", CLevelParserParamUPtr{new CLevelParserParam(static_cast<int>(m_phase))}); line->AddParam("aPhase", MakeUnique<CLevelParserParam>(static_cast<int>(m_phase)));
line->AddParam("aProgress", CLevelParserParamUPtr{new CLevelParserParam(m_progress)}); line->AddParam("aProgress", MakeUnique<CLevelParserParam>(m_progress));
line->AddParam("aSpeed", CLevelParserParamUPtr{new CLevelParserParam(m_speed)}); line->AddParam("aSpeed", MakeUnique<CLevelParserParam>(m_speed));
return true; return true;
} }

View File

@ -20,6 +20,8 @@
#include "object/auto/autorepair.h" #include "object/auto/autorepair.h"
#include "common/make_unique.h"
#include "object/object_manager.h" #include "object/object_manager.h"
#include "object/old_object.h" #include "object/old_object.h"
#include "object/level/parserline.h" #include "object/level/parserline.h"
@ -296,11 +298,11 @@ bool CAutoRepair::Write(CLevelParserLine* line)
{ {
if ( m_phase == ARP_WAIT ) return false; if ( m_phase == ARP_WAIT ) return false;
line->AddParam("aExist", CLevelParserParamUPtr{new CLevelParserParam(true)}); line->AddParam("aExist", MakeUnique<CLevelParserParam>(true));
CAuto::Write(line); CAuto::Write(line);
line->AddParam("aPhase", CLevelParserParamUPtr{new CLevelParserParam(static_cast<int>(m_phase))}); line->AddParam("aPhase", MakeUnique<CLevelParserParam>(static_cast<int>(m_phase)));
line->AddParam("aProgress", CLevelParserParamUPtr{new CLevelParserParam(m_progress)}); line->AddParam("aProgress", MakeUnique<CLevelParserParam>(m_progress));
line->AddParam("aSpeed", CLevelParserParamUPtr{new CLevelParserParam(m_speed)}); line->AddParam("aSpeed", MakeUnique<CLevelParserParam>(m_speed));
return true; return true;
} }

View File

@ -21,6 +21,7 @@
#include "object/auto/autoresearch.h" #include "object/auto/autoresearch.h"
#include "common/global.h" #include "common/global.h"
#include "common/make_unique.h"
#include "math/geometry.h" #include "math/geometry.h"
@ -548,12 +549,12 @@ bool CAutoResearch::Write(CLevelParserLine* line)
{ {
if ( m_phase == ALP_WAIT ) return false; if ( m_phase == ALP_WAIT ) return false;
line->AddParam("aExist", CLevelParserParamUPtr{new CLevelParserParam(true)}); line->AddParam("aExist", MakeUnique<CLevelParserParam>(true));
CAuto::Write(line); CAuto::Write(line);
line->AddParam("aPhase", CLevelParserParamUPtr{new CLevelParserParam(static_cast<int>(m_phase))}); line->AddParam("aPhase", MakeUnique<CLevelParserParam>(static_cast<int>(m_phase)));
line->AddParam("aProgress", CLevelParserParamUPtr{new CLevelParserParam(m_progress)}); line->AddParam("aProgress", MakeUnique<CLevelParserParam>(m_progress));
line->AddParam("aSpeed", CLevelParserParamUPtr{new CLevelParserParam(m_speed)}); line->AddParam("aSpeed", MakeUnique<CLevelParserParam>(m_speed));
line->AddParam("aResearch", CLevelParserParamUPtr{new CLevelParserParam(static_cast<int>(m_research))}); line->AddParam("aResearch", MakeUnique<CLevelParserParam>(static_cast<int>(m_research)));
return true; return true;
} }

View File

@ -20,6 +20,8 @@
#include "object/auto/autotower.h" #include "object/auto/autotower.h"
#include "common/make_unique.h"
#include "math/geometry.h" #include "math/geometry.h"
#include "object/object_manager.h" #include "object/object_manager.h"
@ -468,16 +470,16 @@ bool CAutoTower::Write(CLevelParserLine* line)
{ {
if ( m_phase == ATP_WAIT ) return false; if ( m_phase == ATP_WAIT ) return false;
line->AddParam("aExist", CLevelParserParamUPtr{new CLevelParserParam(true)}); line->AddParam("aExist", MakeUnique<CLevelParserParam>(true));
CAuto::Write(line); CAuto::Write(line);
line->AddParam("aPhase", CLevelParserParamUPtr{new CLevelParserParam(static_cast<int>(m_phase))}); line->AddParam("aPhase", MakeUnique<CLevelParserParam>(static_cast<int>(m_phase)));
line->AddParam("aProgress", CLevelParserParamUPtr{new CLevelParserParam(m_progress)}); line->AddParam("aProgress", MakeUnique<CLevelParserParam>(m_progress));
line->AddParam("aSpeed", CLevelParserParamUPtr{new CLevelParserParam(m_speed)}); line->AddParam("aSpeed", MakeUnique<CLevelParserParam>(m_speed));
line->AddParam("aTargetPos", CLevelParserParamUPtr{new CLevelParserParam(m_targetPos)}); line->AddParam("aTargetPos", MakeUnique<CLevelParserParam>(m_targetPos));
line->AddParam("aAngleYactual", CLevelParserParamUPtr{new CLevelParserParam(m_angleYactual)}); line->AddParam("aAngleYactual", MakeUnique<CLevelParserParam>(m_angleYactual));
line->AddParam("aAngleZactual", CLevelParserParamUPtr{new CLevelParserParam(m_angleZactual)}); line->AddParam("aAngleZactual", MakeUnique<CLevelParserParam>(m_angleZactual));
line->AddParam("aAngleYfinal", CLevelParserParamUPtr{new CLevelParserParam(m_angleYfinal)}); line->AddParam("aAngleYfinal", MakeUnique<CLevelParserParam>(m_angleYfinal));
line->AddParam("aAngleZfinal", CLevelParserParamUPtr{new CLevelParserParam(m_angleZfinal)}); line->AddParam("aAngleZfinal", MakeUnique<CLevelParserParam>(m_angleZfinal));
return true; return true;
} }

View File

@ -20,6 +20,8 @@
#include "object/auto/autovault.h" #include "object/auto/autovault.h"
#include "common/make_unique.h"
#include "math/geometry.h" #include "math/geometry.h"
#include "object/object_manager.h" #include "object/object_manager.h"
@ -350,11 +352,11 @@ bool CAutoVault::Write(CLevelParserLine* line)
{ {
if ( m_phase == ASAP_WAIT ) return false; if ( m_phase == ASAP_WAIT ) return false;
line->AddParam("aExist", CLevelParserParamUPtr{new CLevelParserParam(true)}); line->AddParam("aExist", MakeUnique<CLevelParserParam>(true));
CAuto::Write(line); CAuto::Write(line);
line->AddParam("aPhase", CLevelParserParamUPtr{new CLevelParserParam(static_cast<int>(m_phase))}); line->AddParam("aPhase", MakeUnique<CLevelParserParam>(static_cast<int>(m_phase)));
line->AddParam("aProgress", CLevelParserParamUPtr{new CLevelParserParam(m_progress)}); line->AddParam("aProgress", MakeUnique<CLevelParserParam>(m_progress));
line->AddParam("aSpeed", CLevelParserParamUPtr{new CLevelParserParam(m_speed)}); line->AddParam("aSpeed", MakeUnique<CLevelParserParam>(m_speed));
return true; return true;
} }

View File

@ -167,11 +167,11 @@ void CBrain::SetMotion(CMotion* motion)
bool CBrain::Write(CLevelParserLine* line) bool CBrain::Write(CLevelParserLine* line)
{ {
line->AddParam("bVirusActive", CLevelParserParamUPtr{new CLevelParserParam(m_bActiveVirus)}); line->AddParam("bVirusActive", MakeUnique<CLevelParserParam>(m_bActiveVirus));
if ( m_object->GetType() == OBJECT_MOBILErs ) if ( m_object->GetType() == OBJECT_MOBILErs )
{ {
line->AddParam("bShieldActive", CLevelParserParamUPtr{new CLevelParserParam(m_secondaryTask != nullptr)}); line->AddParam("bShieldActive", MakeUnique<CLevelParserParam>(m_secondaryTask != nullptr));
} }
return true; return true;

View File

@ -22,6 +22,7 @@
#include "app/app.h" #include "app/app.h"
#include "common/make_unique.h"
#include "common/resources/resourcemanager.h" #include "common/resources/resourcemanager.h"
#include "common/resources/inputstream.h" #include "common/resources/inputstream.h"
#include "common/resources/outputstream.h" #include "common/resources/outputstream.h"
@ -168,7 +169,7 @@ void CLevelParser::Load()
if (command.empty()) if (command.empty())
continue; continue;
CLevelParserLineUPtr parserLine{new CLevelParserLine(lineNumber, command)}; auto parserLine = MakeUnique<CLevelParserLine>(lineNumber, command);
if (command.length() > 2 && command[command.length() - 2] == '.') if (command.length() > 2 && command[command.length() - 2] == '.')
{ {
@ -239,7 +240,7 @@ void CLevelParser::Load()
std::string paramValue = line.substr(0, pos + 1); std::string paramValue = line.substr(0, pos + 1);
boost::algorithm::trim(paramValue); boost::algorithm::trim(paramValue);
parserLine->AddParam(paramName, CLevelParserParamUPtr{new CLevelParserParam(paramName, paramValue)}); parserLine->AddParam(paramName, MakeUnique<CLevelParserParam>(paramName, paramValue));
if (pos == std::string::npos) if (pos == std::string::npos)
break; break;

View File

@ -19,8 +19,10 @@
#include "object/level/parserline.h" #include "object/level/parserline.h"
#include "object/level/parser.h"
#include "common/logger.h" #include "common/logger.h"
#include "common/make_unique.h"
#include "object/level/parser.h"
CLevelParserLine::CLevelParserLine(std::string command) CLevelParserLine::CLevelParserLine(std::string command)
{ {
@ -67,7 +69,7 @@ CLevelParserParam* CLevelParserLine::GetParam(std::string name)
return it->second.get(); return it->second.get();
} }
CLevelParserParamUPtr paramUPtr(new CLevelParserParam(name, true)); auto paramUPtr = MakeUnique<CLevelParserParam>(name, true);
paramUPtr->SetLine(this); paramUPtr->SetLine(this);
CLevelParserParam* paramPtr = paramUPtr.get(); CLevelParserParam* paramPtr = paramUPtr.get();
m_params.insert(std::make_pair(name, std::move(paramUPtr))); m_params.insert(std::make_pair(name, std::move(paramUPtr)));

View File

@ -22,6 +22,7 @@
#include "app/app.h" #include "app/app.h"
#include "common/logger.h" #include "common/logger.h"
#include "common/make_unique.h"
#include "common/pathman.h" #include "common/pathman.h"
#include "common/resources/resourcemanager.h" #include "common/resources/resourcemanager.h"
@ -61,27 +62,27 @@ CLevelParserParam::CLevelParserParam(bool value)
CLevelParserParam::CLevelParserParam(Gfx::Color value) CLevelParserParam::CLevelParserParam(Gfx::Color value)
{ {
m_array.push_back(CLevelParserParamUPtr{new CLevelParserParam(value.r)}); m_array.push_back(MakeUnique<CLevelParserParam>(value.r));
m_array.push_back(CLevelParserParamUPtr{new CLevelParserParam(value.g)}); m_array.push_back(MakeUnique<CLevelParserParam>(value.g));
m_array.push_back(CLevelParserParamUPtr{new CLevelParserParam(value.b)}); m_array.push_back(MakeUnique<CLevelParserParam>(value.b));
m_array.push_back(CLevelParserParamUPtr{new CLevelParserParam(value.a)}); m_array.push_back(MakeUnique<CLevelParserParam>(value.a));
LoadArray(); LoadArray();
} }
CLevelParserParam::CLevelParserParam(Math::Point value) CLevelParserParam::CLevelParserParam(Math::Point value)
{ {
m_array.push_back(CLevelParserParamUPtr{new CLevelParserParam(value.x)}); m_array.push_back(MakeUnique<CLevelParserParam>(value.x));
m_array.push_back(CLevelParserParamUPtr{new CLevelParserParam(value.y)}); m_array.push_back(MakeUnique<CLevelParserParam>(value.y));
LoadArray(); LoadArray();
} }
CLevelParserParam::CLevelParserParam(Math::Vector value) CLevelParserParam::CLevelParserParam(Math::Vector value)
{ {
m_array.push_back(CLevelParserParamUPtr{new CLevelParserParam(value.x)}); m_array.push_back(MakeUnique<CLevelParserParam>(value.x));
m_array.push_back(CLevelParserParamUPtr{new CLevelParserParam(value.y)}); m_array.push_back(MakeUnique<CLevelParserParam>(value.y));
m_array.push_back(CLevelParserParamUPtr{new CLevelParserParam(value.z)}); m_array.push_back(MakeUnique<CLevelParserParam>(value.z));
LoadArray(); LoadArray();
} }
@ -905,7 +906,7 @@ void CLevelParserParam::ParseArray()
{ {
boost::algorithm::trim(value); boost::algorithm::trim(value);
if (value.empty()) continue; if (value.empty()) continue;
CLevelParserParamUPtr param{new CLevelParserParam(m_name + "[" + boost::lexical_cast<std::string>(i) + "]", value)}; auto param = MakeUnique<CLevelParserParam>(m_name + "[" + boost::lexical_cast<std::string>(i) + "]", value);
param->SetLine(m_line); param->SetLine(m_line);
m_array.push_back(std::move(param)); m_array.push_back(std::move(param));
i++; i++;

View File

@ -22,6 +22,8 @@
#include "app/app.h" #include "app/app.h"
#include "common/make_unique.h"
#include "object/robotmain.h" #include "object/robotmain.h"
#include "object/old_object.h" #include "object/old_object.h"
#include "object/level/parserline.h" #include "object/level/parserline.h"
@ -162,9 +164,9 @@ bool CMotion::Write(CLevelParserLine* line)
{ {
if ( m_actionType == -1 ) return false; if ( m_actionType == -1 ) return false;
line->AddParam("mType", CLevelParserParamUPtr{new CLevelParserParam(m_actionType)}); line->AddParam("mType", MakeUnique<CLevelParserParam>(m_actionType));
line->AddParam("mTime", CLevelParserParamUPtr{new CLevelParserParam(m_actionTime)}); line->AddParam("mTime", MakeUnique<CLevelParserParam>(m_actionTime));
line->AddParam("mProgress", CLevelParserParamUPtr{new CLevelParserParam(m_progress)}); line->AddParam("mProgress", MakeUnique<CLevelParserParam>(m_progress));
return false; return false;
} }

View File

@ -886,78 +886,78 @@ void COldObject::Write(CLevelParserLine* line)
{ {
Math::Vector pos; Math::Vector pos;
line->AddParam("camera", CLevelParserParamUPtr{new CLevelParserParam(GetCameraType())}); line->AddParam("camera", MakeUnique<CLevelParserParam>(GetCameraType()));
if ( GetCameraLock() ) if ( GetCameraLock() )
line->AddParam("cameraLock", CLevelParserParamUPtr{new CLevelParserParam(GetCameraLock())}); line->AddParam("cameraLock", MakeUnique<CLevelParserParam>(GetCameraLock()));
if ( GetEnergy() != 0.0f ) if ( GetEnergy() != 0.0f )
line->AddParam("energy", CLevelParserParamUPtr{new CLevelParserParam(GetEnergy())}); line->AddParam("energy", MakeUnique<CLevelParserParam>(GetEnergy()));
if ( GetCapacity() != 1.0f ) if ( GetCapacity() != 1.0f )
line->AddParam("capacity", CLevelParserParamUPtr{new CLevelParserParam(GetCapacity())}); line->AddParam("capacity", MakeUnique<CLevelParserParam>(GetCapacity()));
if ( GetShield() != 1.0f ) if ( GetShield() != 1.0f )
line->AddParam("shield", CLevelParserParamUPtr{new CLevelParserParam(GetShield())}); line->AddParam("shield", MakeUnique<CLevelParserParam>(GetShield()));
if ( GetRange() != 1.0f ) if ( GetRange() != 1.0f )
line->AddParam("range", CLevelParserParamUPtr{new CLevelParserParam(GetRange())}); line->AddParam("range", MakeUnique<CLevelParserParam>(GetRange()));
if ( !GetSelectable() ) if ( !GetSelectable() )
line->AddParam("selectable", CLevelParserParamUPtr{new CLevelParserParam(GetSelectable())}); line->AddParam("selectable", MakeUnique<CLevelParserParam>(GetSelectable()));
if ( !GetEnable() ) if ( !GetEnable() )
line->AddParam("enable", CLevelParserParamUPtr{new CLevelParserParam(GetEnable())}); line->AddParam("enable", MakeUnique<CLevelParserParam>(GetEnable()));
// TODO: doesn't seem to be used // TODO: doesn't seem to be used
if ( GetFixed() ) if ( GetFixed() )
line->AddParam("fixed", CLevelParserParamUPtr{new CLevelParserParam(GetFixed())}); line->AddParam("fixed", MakeUnique<CLevelParserParam>(GetFixed()));
if ( !GetClip() ) if ( !GetClip() )
line->AddParam("clip", CLevelParserParamUPtr{new CLevelParserParam(GetClip())}); line->AddParam("clip", MakeUnique<CLevelParserParam>(GetClip()));
if ( GetLock() ) if ( GetLock() )
line->AddParam("lock", CLevelParserParamUPtr{new CLevelParserParam(GetLock())}); line->AddParam("lock", MakeUnique<CLevelParserParam>(GetLock()));
if ( GetProxyActivate() ) if ( GetProxyActivate() )
{ {
line->AddParam("proxyActivate", CLevelParserParamUPtr{new CLevelParserParam(GetProxyActivate())}); line->AddParam("proxyActivate", MakeUnique<CLevelParserParam>(GetProxyActivate()));
line->AddParam("proxyDistance", CLevelParserParamUPtr{new CLevelParserParam(GetProxyDistance()/g_unit)}); line->AddParam("proxyDistance", MakeUnique<CLevelParserParam>(GetProxyDistance()/g_unit));
} }
if ( GetMagnifyDamage() != 1.0f ) if ( GetMagnifyDamage() != 1.0f )
line->AddParam("magnifyDamage", CLevelParserParamUPtr{new CLevelParserParam(GetMagnifyDamage())}); line->AddParam("magnifyDamage", MakeUnique<CLevelParserParam>(GetMagnifyDamage()));
if ( GetTeam() != 0 ) if ( GetTeam() != 0 )
line->AddParam("team", CLevelParserParamUPtr{new CLevelParserParam(GetTeam())}); line->AddParam("team", MakeUnique<CLevelParserParam>(GetTeam()));
if ( GetGunGoalV() != 0.0f ) if ( GetGunGoalV() != 0.0f )
line->AddParam("aimV", CLevelParserParamUPtr{new CLevelParserParam(GetGunGoalV())}); line->AddParam("aimV", MakeUnique<CLevelParserParam>(GetGunGoalV()));
if ( GetGunGoalH() != 0.0f ) if ( GetGunGoalH() != 0.0f )
line->AddParam("aimH", CLevelParserParamUPtr{new CLevelParserParam(GetGunGoalH())}); line->AddParam("aimH", MakeUnique<CLevelParserParam>(GetGunGoalH()));
if ( GetAnimateOnReset() ) if ( GetAnimateOnReset() )
{ {
line->AddParam("resetCap", CLevelParserParamUPtr{new CLevelParserParam(GetAnimateOnReset())}); line->AddParam("resetCap", MakeUnique<CLevelParserParam>(GetAnimateOnReset()));
} }
if ( m_bVirusMode ) if ( m_bVirusMode )
line->AddParam("virusMode", CLevelParserParamUPtr{new CLevelParserParam(m_bVirusMode)}); line->AddParam("virusMode", MakeUnique<CLevelParserParam>(m_bVirusMode));
if ( m_virusTime != 0.0f ) if ( m_virusTime != 0.0f )
line->AddParam("virusTime", CLevelParserParamUPtr{new CLevelParserParam(m_virusTime)}); line->AddParam("virusTime", MakeUnique<CLevelParserParam>(m_virusTime));
line->AddParam("ignoreBuildCheck", CLevelParserParamUPtr{new CLevelParserParam(GetIgnoreBuildCheck())}); line->AddParam("ignoreBuildCheck", MakeUnique<CLevelParserParam>(GetIgnoreBuildCheck()));
// Sets the parameters of the command line. // Sets the parameters of the command line.
CLevelParserParamVec cmdline; CLevelParserParamVec cmdline;
for(float value : m_cmdLine) for(float value : m_cmdLine)
{ {
cmdline.push_back(CLevelParserParamUPtr{new CLevelParserParam(value)}); cmdline.push_back(MakeUnique<CLevelParserParam>(value));
} }
if (cmdline.size() > 0) if (cmdline.size() > 0)
line->AddParam("cmdline", CLevelParserParamUPtr{new CLevelParserParam(std::move(cmdline))}); line->AddParam("cmdline", MakeUnique<CLevelParserParam>(std::move(cmdline)));
if ( m_motion != nullptr ) if ( m_motion != nullptr )
{ {

View File

@ -26,8 +26,6 @@
#include "object/object.h" #include "object/object.h"
#include "common/make_unique.h"
#include "object/interface/carrier_object.h" #include "object/interface/carrier_object.h"
#include "object/interface/interactive_object.h" #include "object/interface/interactive_object.h"
#include "object/interface/jostleable_object.h" #include "object/interface/jostleable_object.h"

View File

@ -914,9 +914,9 @@ bool CRobotMain::ProcessEvent(Event &event)
if (obj != nullptr) if (obj != nullptr)
{ {
CLevelParserLine line("CreateObject"); CLevelParserLine line("CreateObject");
line.AddParam("type", CLevelParserParamUPtr{new CLevelParserParam(obj->GetType())}); line.AddParam("type", MakeUnique<CLevelParserParam>(obj->GetType()));
line.AddParam("pos", CLevelParserParamUPtr{new CLevelParserParam(obj->GetPosition())}); line.AddParam("pos", MakeUnique<CLevelParserParam>(obj->GetPosition()));
line.AddParam("dir", CLevelParserParamUPtr{new CLevelParserParam(obj->GetRotationZ()/(Math::PI/180.0f))}); line.AddParam("dir", MakeUnique<CLevelParserParam>(obj->GetRotationZ()/(Math::PI/180.0f)));
std::stringstream ss; std::stringstream ss;
ss << line; ss << line;
@ -4824,11 +4824,11 @@ void CRobotMain::IOWriteObject(CLevelParserLine* line, CObject* obj)
{ {
if (obj->GetType() == OBJECT_FIX) return; if (obj->GetType() == OBJECT_FIX) return;
line->AddParam("type", CLevelParserParamUPtr{new CLevelParserParam(obj->GetType())}); line->AddParam("type", MakeUnique<CLevelParserParam>(obj->GetType()));
line->AddParam("id", CLevelParserParamUPtr{new CLevelParserParam(obj->GetID())}); line->AddParam("id", MakeUnique<CLevelParserParam>(obj->GetID()));
line->AddParam("pos", CLevelParserParamUPtr{new CLevelParserParam(obj->GetPosition()/g_unit)}); line->AddParam("pos", MakeUnique<CLevelParserParam>(obj->GetPosition()/g_unit));
line->AddParam("angle", CLevelParserParamUPtr{new CLevelParserParam(obj->GetRotation() * Math::RAD_TO_DEG)}); line->AddParam("angle", MakeUnique<CLevelParserParam>(obj->GetRotation() * Math::RAD_TO_DEG));
line->AddParam("zoom", CLevelParserParamUPtr{new CLevelParserParam(obj->GetScale())}); line->AddParam("zoom", MakeUnique<CLevelParserParam>(obj->GetScale()));
if (obj->Implements(ObjectInterfaceType::Old)) if (obj->Implements(ObjectInterfaceType::Old))
{ {
@ -4842,34 +4842,34 @@ void CRobotMain::IOWriteObject(CLevelParserLine* line, CObject* obj)
if (pos.x != 0.0f || pos.y != 0.0f || pos.z != 0.0f) if (pos.x != 0.0f || pos.y != 0.0f || pos.z != 0.0f)
{ {
pos /= g_unit; pos /= g_unit;
line->AddParam("p" + boost::lexical_cast<std::string>(i), CLevelParserParamUPtr{new CLevelParserParam(pos)}); line->AddParam("p" + boost::lexical_cast<std::string>(i), MakeUnique<CLevelParserParam>(pos));
} }
Math::Vector rot = oldObj->GetPartRotation(i); Math::Vector rot = oldObj->GetPartRotation(i);
if (rot.x != 0.0f || rot.y != 0.0f || rot.z != 0.0f) if (rot.x != 0.0f || rot.y != 0.0f || rot.z != 0.0f)
{ {
rot /= (Math::PI/180.0f); rot /= (Math::PI/180.0f);
line->AddParam("a" + boost::lexical_cast<std::string>(i), CLevelParserParamUPtr{new CLevelParserParam(rot)}); line->AddParam("a" + boost::lexical_cast<std::string>(i), MakeUnique<CLevelParserParam>(rot));
} }
Math::Vector scale = oldObj->GetPartScale(i); Math::Vector scale = oldObj->GetPartScale(i);
if (scale.x != 1.0f || scale.y != 1.0f || scale.z != 1.0f) if (scale.x != 1.0f || scale.y != 1.0f || scale.z != 1.0f)
{ {
line->AddParam("z" + boost::lexical_cast<std::string>(i), CLevelParserParamUPtr{new CLevelParserParam(scale)}); line->AddParam("z" + boost::lexical_cast<std::string>(i), MakeUnique<CLevelParserParam>(scale));
} }
} }
line->AddParam("trainer", CLevelParserParamUPtr{new CLevelParserParam(obj->GetTrainer())}); line->AddParam("trainer", MakeUnique<CLevelParserParam>(obj->GetTrainer()));
line->AddParam("option", CLevelParserParamUPtr{new CLevelParserParam(obj->GetOption())}); line->AddParam("option", MakeUnique<CLevelParserParam>(obj->GetOption()));
} }
if (obj == m_infoObject) if (obj == m_infoObject)
line->AddParam("select", CLevelParserParamUPtr{new CLevelParserParam(1)}); line->AddParam("select", MakeUnique<CLevelParserParam>(1));
obj->Write(line); obj->Write(line);
if (obj->GetType() == OBJECT_BASE) if (obj->GetType() == OBJECT_BASE)
line->AddParam("run", CLevelParserParamUPtr{new CLevelParserParam(3)}); // stops and open (PARAM_FIXSCENE) line->AddParam("run", MakeUnique<CLevelParserParam>(3)); // stops and open (PARAM_FIXSCENE)
if (obj->Implements(ObjectInterfaceType::Programmable)) if (obj->Implements(ObjectInterfaceType::Programmable))
{ {
@ -4878,7 +4878,7 @@ void CRobotMain::IOWriteObject(CLevelParserLine* line, CObject* obj)
int run = brain->GetProgram(); int run = brain->GetProgram();
if (run != -1) if (run != -1)
{ {
line->AddParam("run", CLevelParserParamUPtr{new CLevelParserParam(run+1)}); line->AddParam("run", MakeUnique<CLevelParserParam>(run+1));
} }
auto& programs = brain->GetPrograms(); auto& programs = brain->GetPrograms();
@ -4886,7 +4886,7 @@ void CRobotMain::IOWriteObject(CLevelParserLine* line, CObject* obj)
{ {
if (programs[i]->readOnly) if (programs[i]->readOnly)
{ {
line->AddParam("scriptReadOnly" + boost::lexical_cast<std::string>(i+1), CLevelParserParamUPtr{new CLevelParserParam(true)}); line->AddParam("scriptReadOnly" + boost::lexical_cast<std::string>(i+1), MakeUnique<CLevelParserParam>(true));
} }
} }
} }
@ -4898,48 +4898,48 @@ bool CRobotMain::IOWriteScene(const char *filename, const char *filecbot, char *
CLevelParser levelParser(filename); CLevelParser levelParser(filename);
CLevelParserLineUPtr line; CLevelParserLineUPtr line;
line.reset(new CLevelParserLine("Title")); line = MakeUnique<CLevelParserLine>("Title");
line->AddParam("text", CLevelParserParamUPtr{new CLevelParserParam(std::string(info))}); line->AddParam("text", MakeUnique<CLevelParserParam>(std::string(info)));
levelParser.AddLine(std::move(line)); levelParser.AddLine(std::move(line));
//TODO: Do we need that? It's not used anyway //TODO: Do we need that? It's not used anyway
line.reset(new CLevelParserLine("Version")); line = MakeUnique<CLevelParserLine>("Version");
line->AddParam("maj", CLevelParserParamUPtr{new CLevelParserParam(0)}); line->AddParam("maj", MakeUnique<CLevelParserParam>(0));
line->AddParam("min", CLevelParserParamUPtr{new CLevelParserParam(1)}); line->AddParam("min", MakeUnique<CLevelParserParam>(1));
levelParser.AddLine(std::move(line)); levelParser.AddLine(std::move(line));
line.reset(new CLevelParserLine("Created")); line = MakeUnique<CLevelParserLine>("Created");
line->AddParam("date", CLevelParserParamUPtr{new CLevelParserParam(GetCurrentTimestamp())}); line->AddParam("date", MakeUnique<CLevelParserParam>(GetCurrentTimestamp()));
levelParser.AddLine(std::move(line)); levelParser.AddLine(std::move(line));
char* name = m_dialog->GetSceneName(); char* name = m_dialog->GetSceneName();
line.reset(new CLevelParserLine("Mission")); line = MakeUnique<CLevelParserLine>("Mission");
line->AddParam("base", CLevelParserParamUPtr{new CLevelParserParam(std::string(name))}); line->AddParam("base", MakeUnique<CLevelParserParam>(std::string(name)));
line->AddParam("rank", CLevelParserParamUPtr{new CLevelParserParam(m_dialog->GetSceneRank())}); line->AddParam("rank", MakeUnique<CLevelParserParam>(m_dialog->GetSceneRank()));
if (std::string(name) == "custom") if (std::string(name) == "custom")
{ {
line->AddParam("dir", CLevelParserParamUPtr{new CLevelParserParam(std::string(m_dialog->GetSceneDir()))}); line->AddParam("dir", MakeUnique<CLevelParserParam>(std::string(m_dialog->GetSceneDir())));
} }
levelParser.AddLine(std::move(line)); levelParser.AddLine(std::move(line));
line.reset(new CLevelParserLine("Map")); line = MakeUnique<CLevelParserLine>("Map");
line->AddParam("zoom", CLevelParserParamUPtr{new CLevelParserParam(m_map->GetZoomMap())}); line->AddParam("zoom", MakeUnique<CLevelParserParam>(m_map->GetZoomMap()));
levelParser.AddLine(std::move(line)); levelParser.AddLine(std::move(line));
line.reset(new CLevelParserLine("DoneResearch")); line = MakeUnique<CLevelParserLine>("DoneResearch");
line->AddParam("bits", CLevelParserParamUPtr{new CLevelParserParam(static_cast<int>(m_researchDone[0]))}); line->AddParam("bits", MakeUnique<CLevelParserParam>(static_cast<int>(m_researchDone[0])));
levelParser.AddLine(std::move(line)); levelParser.AddLine(std::move(line));
float sleep, delay, magnetic, progress; float sleep, delay, magnetic, progress;
if (m_lightning->GetStatus(sleep, delay, magnetic, progress)) if (m_lightning->GetStatus(sleep, delay, magnetic, progress))
{ {
line.reset(new CLevelParserLine("BlitzMode")); line = MakeUnique<CLevelParserLine>("BlitzMode");
line->AddParam("sleep", CLevelParserParamUPtr{new CLevelParserParam(sleep)}); line->AddParam("sleep", MakeUnique<CLevelParserParam>(sleep));
line->AddParam("delay", CLevelParserParamUPtr{new CLevelParserParam(delay)}); line->AddParam("delay", MakeUnique<CLevelParserParam>(delay));
line->AddParam("magnetic", CLevelParserParamUPtr{new CLevelParserParam(magnetic/g_unit)}); line->AddParam("magnetic", MakeUnique<CLevelParserParam>(magnetic/g_unit));
line->AddParam("progress", CLevelParserParamUPtr{new CLevelParserParam(progress)}); line->AddParam("progress", MakeUnique<CLevelParserParam>(progress));
levelParser.AddLine(std::move(line)); levelParser.AddLine(std::move(line));
} }
@ -4959,7 +4959,7 @@ bool CRobotMain::IOWriteScene(const char *filename, const char *filecbot, char *
CObject* cargo = dynamic_cast<CCarrierObject*>(obj)->GetCargo(); CObject* cargo = dynamic_cast<CCarrierObject*>(obj)->GetCargo();
if (cargo != nullptr) // object transported? if (cargo != nullptr) // object transported?
{ {
line.reset(new CLevelParserLine("CreateFret")); line = MakeUnique<CLevelParserLine>("CreateFret");
IOWriteObject(line.get(), cargo); IOWriteObject(line.get(), cargo);
levelParser.AddLine(std::move(line)); levelParser.AddLine(std::move(line));
} }
@ -4970,14 +4970,14 @@ bool CRobotMain::IOWriteScene(const char *filename, const char *filecbot, char *
CObject* power = dynamic_cast<CPoweredObject*>(obj)->GetPower(); CObject* power = dynamic_cast<CPoweredObject*>(obj)->GetPower();
if (power != nullptr) // battery transported? if (power != nullptr) // battery transported?
{ {
line.reset(new CLevelParserLine("CreatePower")); line = MakeUnique<CLevelParserLine>("CreatePower");
IOWriteObject(line.get(), power); IOWriteObject(line.get(), power);
levelParser.AddLine(std::move(line)); levelParser.AddLine(std::move(line));
} }
} }
line.reset(new CLevelParserLine("CreateObject")); line = MakeUnique<CLevelParserLine>("CreateObject");
IOWriteObject(line.get(), obj); IOWriteObject(line.get(), obj);
levelParser.AddLine(std::move(line)); levelParser.AddLine(std::move(line));

View File

@ -197,7 +197,7 @@ void CExchangePost::Write(CLevelParserLine* line)
{ {
auto key = "info" + boost::lexical_cast<std::string>(i); auto key = "info" + boost::lexical_cast<std::string>(i);
auto paramValue = info.name + "=" + boost::lexical_cast<std::string>(info.value); auto paramValue = info.name + "=" + boost::lexical_cast<std::string>(info.value);
line->AddParam(key, CLevelParserParamUPtr{new CLevelParserParam(paramValue)}); line->AddParam(key, MakeUnique<CLevelParserParam>(paramValue));
} }
} }
} }
@ -656,11 +656,11 @@ bool CAutoInfo::Write(CLevelParserLine* line)
if (m_phase == Phase::Wait) if (m_phase == Phase::Wait)
return false; return false;
line->AddParam("aExist", CLevelParserParamUPtr{new CLevelParserParam(true)}); line->AddParam("aExist", MakeUnique<CLevelParserParam>(true));
CAuto::Write(line); CAuto::Write(line);
line->AddParam("aPhase", CLevelParserParamUPtr{new CLevelParserParam(static_cast<int>(m_phase))}); line->AddParam("aPhase", MakeUnique<CLevelParserParam>(static_cast<int>(m_phase)));
line->AddParam("aProgress", CLevelParserParamUPtr{new CLevelParserParam(m_progress)}); line->AddParam("aProgress", MakeUnique<CLevelParserParam>(m_progress));
line->AddParam("aSpeed", CLevelParserParamUPtr{new CLevelParserParam(m_speed)}); line->AddParam("aSpeed", MakeUnique<CLevelParserParam>(m_speed));
return true; return true;
} }

View File

@ -24,6 +24,7 @@
#include "common/event.h" #include "common/event.h"
#include "common/global.h" #include "common/global.h"
#include "common/make_unique.h"
#include "graphics/engine/camera.h" #include "graphics/engine/camera.h"
#include "graphics/engine/engine.h" #include "graphics/engine/engine.h"
@ -173,12 +174,12 @@ PhysicsType CPhysics::GetType()
bool CPhysics::Write(CLevelParserLine* line) bool CPhysics::Write(CLevelParserLine* line)
{ {
line->AddParam("motor", CLevelParserParamUPtr{new CLevelParserParam(m_motorSpeed)}); line->AddParam("motor", MakeUnique<CLevelParserParam>(m_motorSpeed));
if ( m_type == TYPE_FLYING ) if ( m_type == TYPE_FLYING )
{ {
line->AddParam("reactorRange", CLevelParserParamUPtr{new CLevelParserParam(GetReactorRange())}); line->AddParam("reactorRange", MakeUnique<CLevelParserParam>(GetReactorRange()));
line->AddParam("land", CLevelParserParamUPtr{new CLevelParserParam(GetLand())}); line->AddParam("land", MakeUnique<CLevelParserParam>(GetLand()));
} }
return true; return true;

View File

@ -28,6 +28,7 @@
#include "common/global.h" #include "common/global.h"
#include "common/event.h" #include "common/event.h"
#include "common/logger.h" #include "common/logger.h"
#include "common/make_unique.h"
#include "common/misc.h" #include "common/misc.h"
#include "common/profile.h" #include "common/profile.h"
#include "common/restext.h" #include "common/restext.h"
@ -6018,15 +6019,15 @@ void CMainDialog::WriteGamerPerso(char *gamer)
CLevelParser persoParser(GetSavegameDir()+"/"+gamer+"/face.gam"); CLevelParser persoParser(GetSavegameDir()+"/"+gamer+"/face.gam");
CLevelParserLineUPtr line; CLevelParserLineUPtr line;
line.reset(new CLevelParserLine("Head")); line = MakeUnique<CLevelParserLine>("Head");
line->AddParam("face", CLevelParserParamUPtr{new CLevelParserParam(m_perso.face)}); line->AddParam("face", MakeUnique<CLevelParserParam>(m_perso.face));
line->AddParam("glasses", CLevelParserParamUPtr{new CLevelParserParam(m_perso.glasses)}); line->AddParam("glasses", MakeUnique<CLevelParserParam>(m_perso.glasses));
line->AddParam("hair", CLevelParserParamUPtr{new CLevelParserParam(m_perso.colorHair)}); line->AddParam("hair", MakeUnique<CLevelParserParam>(m_perso.colorHair));
persoParser.AddLine(std::move(line)); persoParser.AddLine(std::move(line));
line.reset(new CLevelParserLine("Body")); line = MakeUnique<CLevelParserLine>("Body");
line->AddParam("combi", CLevelParserParamUPtr{new CLevelParserParam(m_perso.colorCombi)}); line->AddParam("combi", MakeUnique<CLevelParserParam>(m_perso.colorCombi));
line->AddParam("band", CLevelParserParamUPtr{new CLevelParserParam(m_perso.colorBand)}); line->AddParam("band", MakeUnique<CLevelParserParam>(m_perso.colorBand));
persoParser.AddLine(std::move(line)); persoParser.AddLine(std::move(line));
persoParser.Save(); persoParser.Save();