Refactor level parser code
* replace manual memory management with std::unique_ptr * remove unnecessary dynamic allocations * make coding style consistentmaster
parent
5f1d3c21d4
commit
02ffdcfe23
|
@ -424,11 +424,11 @@ void CAuto::SetMotor(bool bMotor)
|
||||||
|
|
||||||
bool CAuto::Write(CLevelParserLine* line)
|
bool CAuto::Write(CLevelParserLine* line)
|
||||||
{
|
{
|
||||||
line->AddParam("aType", new CLevelParserParam(m_type));
|
line->AddParam("aType", CLevelParserParamUPtr{new CLevelParserParam(m_type)});
|
||||||
line->AddParam("aBusy", new CLevelParserParam(m_bBusy));
|
line->AddParam("aBusy", CLevelParserParamUPtr{new CLevelParserParam(m_bBusy)});
|
||||||
line->AddParam("aTime", new CLevelParserParam(m_time));
|
line->AddParam("aTime", CLevelParserParamUPtr{new CLevelParserParam(m_time)});
|
||||||
line->AddParam("aProgressTime", new CLevelParserParam(m_progressTime));
|
line->AddParam("aProgressTime", CLevelParserParamUPtr{new CLevelParserParam(m_progressTime)});
|
||||||
line->AddParam("aProgressTotal", new CLevelParserParam(m_progressTotal));
|
line->AddParam("aProgressTotal", CLevelParserParamUPtr{new CLevelParserParam(m_progressTotal)});
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -365,11 +365,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", new CLevelParserParam(true));
|
line->AddParam("aExist", CLevelParserParamUPtr{new CLevelParserParam(true)});
|
||||||
CAuto::Write(line);
|
CAuto::Write(line);
|
||||||
line->AddParam("aPhase", new CLevelParserParam(static_cast<int>(m_phase)));
|
line->AddParam("aPhase", CLevelParserParamUPtr{new CLevelParserParam(static_cast<int>(m_phase))});
|
||||||
line->AddParam("aProgress", new CLevelParserParam(m_progress));
|
line->AddParam("aProgress", CLevelParserParamUPtr{new CLevelParserParam(m_progress)});
|
||||||
line->AddParam("aSpeed", new CLevelParserParam(m_speed));
|
line->AddParam("aSpeed", CLevelParserParamUPtr{new CLevelParserParam(m_speed)});
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -431,11 +431,11 @@ bool CAutoDerrick::Write(CLevelParserLine* line)
|
||||||
{
|
{
|
||||||
if ( m_phase == ADP_WAIT ) return false;
|
if ( m_phase == ADP_WAIT ) return false;
|
||||||
|
|
||||||
line->AddParam("aExist", new CLevelParserParam(true));
|
line->AddParam("aExist", CLevelParserParamUPtr{new CLevelParserParam(true)});
|
||||||
CAuto::Write(line);
|
CAuto::Write(line);
|
||||||
line->AddParam("aPhase", new CLevelParserParam(static_cast<int>(m_phase)));
|
line->AddParam("aPhase", CLevelParserParamUPtr{new CLevelParserParam(static_cast<int>(m_phase))});
|
||||||
line->AddParam("aProgress", new CLevelParserParam(m_progress));
|
line->AddParam("aProgress", CLevelParserParamUPtr{new CLevelParserParam(m_progress)});
|
||||||
line->AddParam("aSpeed", new CLevelParserParam(m_speed));
|
line->AddParam("aSpeed", CLevelParserParamUPtr{new CLevelParserParam(m_speed)});
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -354,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", new CLevelParserParam(true));
|
line->AddParam("aExist", CLevelParserParamUPtr{new CLevelParserParam(true)});
|
||||||
CAuto::Write(line);
|
CAuto::Write(line);
|
||||||
line->AddParam("aPhase", new CLevelParserParam(static_cast<int>(m_phase)));
|
line->AddParam("aPhase", CLevelParserParamUPtr{new CLevelParserParam(static_cast<int>(m_phase))});
|
||||||
line->AddParam("aProgress", new CLevelParserParam(m_progress));
|
line->AddParam("aProgress", CLevelParserParamUPtr{new CLevelParserParam(m_progress)});
|
||||||
line->AddParam("aSpeed", new CLevelParserParam(m_speed));
|
line->AddParam("aSpeed", CLevelParserParamUPtr{new CLevelParserParam(m_speed)});
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -302,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", new CLevelParserParam(true));
|
line->AddParam("aExist", CLevelParserParamUPtr{new CLevelParserParam(true)});
|
||||||
CAuto::Write(line);
|
CAuto::Write(line);
|
||||||
line->AddParam("aPhase", new CLevelParserParam(static_cast<int>(m_phase)));
|
line->AddParam("aPhase", CLevelParserParamUPtr{new CLevelParserParam(static_cast<int>(m_phase))});
|
||||||
line->AddParam("aProgress", new CLevelParserParam(m_progress));
|
line->AddParam("aProgress", CLevelParserParamUPtr{new CLevelParserParam(m_progress)});
|
||||||
line->AddParam("aSpeed", new CLevelParserParam(m_speed));
|
line->AddParam("aSpeed", CLevelParserParamUPtr{new CLevelParserParam(m_speed)});
|
||||||
line->AddParam("aParamType", new CLevelParserParam(m_type));
|
line->AddParam("aParamType", CLevelParserParamUPtr{new CLevelParserParam(m_type)});
|
||||||
line->AddParam("aParamValue1", new CLevelParserParam(m_value));
|
line->AddParam("aParamValue1", CLevelParserParamUPtr{new CLevelParserParam(m_value)});
|
||||||
line->AddParam("aParamString", new CLevelParserParam(std::string(m_string)));
|
line->AddParam("aParamString", CLevelParserParamUPtr{new CLevelParserParam(std::string(m_string))});
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -586,11 +586,11 @@ bool CAutoEnergy::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", new CLevelParserParam(true));
|
line->AddParam("aExist", CLevelParserParamUPtr{new CLevelParserParam(true)});
|
||||||
CAuto::Write(line);
|
CAuto::Write(line);
|
||||||
line->AddParam("aPhase", new CLevelParserParam(static_cast<int>(m_phase)));
|
line->AddParam("aPhase", CLevelParserParamUPtr{new CLevelParserParam(static_cast<int>(m_phase))});
|
||||||
line->AddParam("aProgress", new CLevelParserParam(m_progress));
|
line->AddParam("aProgress", CLevelParserParamUPtr{new CLevelParserParam(m_progress)});
|
||||||
line->AddParam("aSpeed", new CLevelParserParam(m_speed));
|
line->AddParam("aSpeed", CLevelParserParamUPtr{new CLevelParserParam(m_speed)});
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -516,11 +516,11 @@ bool CAutoFactory::Write(CLevelParserLine* line)
|
||||||
{
|
{
|
||||||
if ( m_phase == AFP_WAIT ) return false;
|
if ( m_phase == AFP_WAIT ) return false;
|
||||||
|
|
||||||
line->AddParam("aExist", new CLevelParserParam(true));
|
line->AddParam("aExist", CLevelParserParamUPtr{new CLevelParserParam(true)});
|
||||||
CAuto::Write(line);
|
CAuto::Write(line);
|
||||||
line->AddParam("aPhase", new CLevelParserParam(static_cast<int>(m_phase)));
|
line->AddParam("aPhase", CLevelParserParamUPtr{new CLevelParserParam(static_cast<int>(m_phase))});
|
||||||
line->AddParam("aProgress", new CLevelParserParam(m_progress));
|
line->AddParam("aProgress", CLevelParserParamUPtr{new CLevelParserParam(m_progress)});
|
||||||
line->AddParam("aSpeed", new CLevelParserParam(m_speed));
|
line->AddParam("aSpeed", CLevelParserParamUPtr{new CLevelParserParam(m_speed)});
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -484,11 +484,11 @@ bool CAutoInfo::Write(CLevelParserLine* line)
|
||||||
{
|
{
|
||||||
if ( m_phase == AIP_WAIT ) return false;
|
if ( m_phase == AIP_WAIT ) return false;
|
||||||
|
|
||||||
line->AddParam("aExist", new CLevelParserParam(true));
|
line->AddParam("aExist", CLevelParserParamUPtr{new CLevelParserParam(true)});
|
||||||
CAuto::Write(line);
|
CAuto::Write(line);
|
||||||
line->AddParam("aPhase", new CLevelParserParam(static_cast<int>(m_phase)));
|
line->AddParam("aPhase", CLevelParserParamUPtr{new CLevelParserParam(static_cast<int>(m_phase))});
|
||||||
line->AddParam("aProgress", new CLevelParserParam(m_progress));
|
line->AddParam("aProgress", CLevelParserParamUPtr{new CLevelParserParam(m_progress)});
|
||||||
line->AddParam("aSpeed", new CLevelParserParam(m_speed));
|
line->AddParam("aSpeed", CLevelParserParamUPtr{new CLevelParserParam(m_speed)});
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,16 +32,16 @@ public:
|
||||||
CAutoJostle(CObject* object);
|
CAutoJostle(CObject* object);
|
||||||
~CAutoJostle();
|
~CAutoJostle();
|
||||||
|
|
||||||
void DeleteObject(bool bAll=false);
|
void DeleteObject(bool bAll=false) OVERRIDE;
|
||||||
|
|
||||||
void Init();
|
void Init() OVERRIDE;
|
||||||
void Start(int param, float force);
|
void Start(int param, float force);
|
||||||
bool EventProcess(const Event &event);
|
bool EventProcess(const Event &event) OVERRIDE;
|
||||||
Error IsEnded();
|
Error IsEnded() OVERRIDE;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Overriden to avoid warning about hiding virtual function
|
// Overriden to avoid warning about hiding virtual function
|
||||||
virtual void Start(int param) OVERRIDE;
|
void Start(int param) OVERRIDE;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
float m_force;
|
float m_force;
|
||||||
|
|
|
@ -592,12 +592,12 @@ bool CAutoLabo::Write(CLevelParserLine* line)
|
||||||
{
|
{
|
||||||
if ( m_phase == ALAP_WAIT ) return false;
|
if ( m_phase == ALAP_WAIT ) return false;
|
||||||
|
|
||||||
line->AddParam("aExist", new CLevelParserParam(true));
|
line->AddParam("aExist", CLevelParserParamUPtr{new CLevelParserParam(true)});
|
||||||
CAuto::Write(line);
|
CAuto::Write(line);
|
||||||
line->AddParam("aPhase", new CLevelParserParam(static_cast<int>(m_phase)));
|
line->AddParam("aPhase", CLevelParserParamUPtr{new CLevelParserParam(static_cast<int>(m_phase))});
|
||||||
line->AddParam("aProgress", new CLevelParserParam(m_progress));
|
line->AddParam("aProgress", CLevelParserParamUPtr{new CLevelParserParam(m_progress)});
|
||||||
line->AddParam("aSpeed", new CLevelParserParam(m_speed));
|
line->AddParam("aSpeed", CLevelParserParamUPtr{new CLevelParserParam(m_speed)});
|
||||||
line->AddParam("aResearch", new CLevelParserParam(static_cast<int>(m_research)));
|
line->AddParam("aResearch", CLevelParserParamUPtr{new CLevelParserParam(static_cast<int>(m_research))});
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -298,11 +298,11 @@ bool CAutoMush::Write(CLevelParserLine* line)
|
||||||
{
|
{
|
||||||
if ( m_phase == AMP_WAIT ) return false;
|
if ( m_phase == AMP_WAIT ) return false;
|
||||||
|
|
||||||
line->AddParam("aExist", new CLevelParserParam(true));
|
line->AddParam("aExist", CLevelParserParamUPtr{new CLevelParserParam(true)});
|
||||||
CAuto::Write(line);
|
CAuto::Write(line);
|
||||||
line->AddParam("aPhase", new CLevelParserParam(static_cast<int>(m_phase)));
|
line->AddParam("aPhase", CLevelParserParamUPtr{new CLevelParserParam(static_cast<int>(m_phase))});
|
||||||
line->AddParam("aProgress", new CLevelParserParam(m_progress));
|
line->AddParam("aProgress", CLevelParserParamUPtr{new CLevelParserParam(m_progress)});
|
||||||
line->AddParam("aSpeed", new CLevelParserParam(m_speed));
|
line->AddParam("aSpeed", CLevelParserParamUPtr{new CLevelParserParam(m_speed)});
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -213,11 +213,11 @@ bool CAutoNest::Write(CLevelParserLine* line)
|
||||||
{
|
{
|
||||||
if ( m_phase == ANP_WAIT ) return false;
|
if ( m_phase == ANP_WAIT ) return false;
|
||||||
|
|
||||||
line->AddParam("aExist", new CLevelParserParam(true));
|
line->AddParam("aExist", CLevelParserParamUPtr{new CLevelParserParam(true)});
|
||||||
CAuto::Write(line);
|
CAuto::Write(line);
|
||||||
line->AddParam("aPhase", new CLevelParserParam(static_cast<int>(m_phase)));
|
line->AddParam("aPhase", CLevelParserParamUPtr{new CLevelParserParam(static_cast<int>(m_phase))});
|
||||||
line->AddParam("aProgress", new CLevelParserParam(m_progress));
|
line->AddParam("aProgress", CLevelParserParamUPtr{new CLevelParserParam(m_progress)});
|
||||||
line->AddParam("aSpeed", new CLevelParserParam(m_speed));
|
line->AddParam("aSpeed", CLevelParserParamUPtr{new CLevelParserParam(m_speed)});
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -431,11 +431,11 @@ bool CAutoNuclear::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", new CLevelParserParam(true));
|
line->AddParam("aExist", CLevelParserParamUPtr{new CLevelParserParam(true)});
|
||||||
CAuto::Write(line);
|
CAuto::Write(line);
|
||||||
line->AddParam("aPhase", new CLevelParserParam(static_cast<int>(m_phase)));
|
line->AddParam("aPhase", CLevelParserParamUPtr{new CLevelParserParam(static_cast<int>(m_phase))});
|
||||||
line->AddParam("aProgress", new CLevelParserParam(m_progress));
|
line->AddParam("aProgress", CLevelParserParamUPtr{new CLevelParserParam(m_progress)});
|
||||||
line->AddParam("aSpeed", new CLevelParserParam(m_speed));
|
line->AddParam("aSpeed", CLevelParserParamUPtr{new CLevelParserParam(m_speed)});
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -286,11 +286,11 @@ bool CAutoPara::Write(CLevelParserLine* line)
|
||||||
{
|
{
|
||||||
if ( m_phase == APAP_WAIT ) return false;
|
if ( m_phase == APAP_WAIT ) return false;
|
||||||
|
|
||||||
line->AddParam("aExist", new CLevelParserParam(true));
|
line->AddParam("aExist", CLevelParserParamUPtr{new CLevelParserParam(true)});
|
||||||
CAuto::Write(line);
|
CAuto::Write(line);
|
||||||
line->AddParam("aPhase", new CLevelParserParam(static_cast<int>(m_phase)));
|
line->AddParam("aPhase", CLevelParserParamUPtr{new CLevelParserParam(static_cast<int>(m_phase))});
|
||||||
line->AddParam("aProgress", new CLevelParserParam(m_progress));
|
line->AddParam("aProgress", CLevelParserParamUPtr{new CLevelParserParam(m_progress)});
|
||||||
line->AddParam("aSpeed", new CLevelParserParam(m_speed));
|
line->AddParam("aSpeed", CLevelParserParamUPtr{new CLevelParserParam(m_speed)});
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -298,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", new CLevelParserParam(true));
|
line->AddParam("aExist", CLevelParserParamUPtr{new CLevelParserParam(true)});
|
||||||
CAuto::Write(line);
|
CAuto::Write(line);
|
||||||
line->AddParam("aPhase", new CLevelParserParam(static_cast<int>(m_phase)));
|
line->AddParam("aPhase", CLevelParserParamUPtr{new CLevelParserParam(static_cast<int>(m_phase))});
|
||||||
line->AddParam("aProgress", new CLevelParserParam(m_progress));
|
line->AddParam("aProgress", CLevelParserParamUPtr{new CLevelParserParam(m_progress)});
|
||||||
line->AddParam("aSpeed", new CLevelParserParam(m_speed));
|
line->AddParam("aSpeed", CLevelParserParamUPtr{new CLevelParserParam(m_speed)});
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -569,12 +569,12 @@ bool CAutoResearch::Write(CLevelParserLine* line)
|
||||||
{
|
{
|
||||||
if ( m_phase == ALP_WAIT ) return false;
|
if ( m_phase == ALP_WAIT ) return false;
|
||||||
|
|
||||||
line->AddParam("aExist", new CLevelParserParam(true));
|
line->AddParam("aExist", CLevelParserParamUPtr{new CLevelParserParam(true)});
|
||||||
CAuto::Write(line);
|
CAuto::Write(line);
|
||||||
line->AddParam("aPhase", new CLevelParserParam(static_cast<int>(m_phase)));
|
line->AddParam("aPhase", CLevelParserParamUPtr{new CLevelParserParam(static_cast<int>(m_phase))});
|
||||||
line->AddParam("aProgress", new CLevelParserParam(m_progress));
|
line->AddParam("aProgress", CLevelParserParamUPtr{new CLevelParserParam(m_progress)});
|
||||||
line->AddParam("aSpeed", new CLevelParserParam(m_speed));
|
line->AddParam("aSpeed", CLevelParserParamUPtr{new CLevelParserParam(m_speed)});
|
||||||
line->AddParam("aResearch", new CLevelParserParam(static_cast<int>(m_research)));
|
line->AddParam("aResearch", CLevelParserParamUPtr{new CLevelParserParam(static_cast<int>(m_research))});
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -355,11 +355,11 @@ bool CAutoSafe::Write(CLevelParserLine* line)
|
||||||
{
|
{
|
||||||
if ( m_phase == ASAP_WAIT ) return false;
|
if ( m_phase == ASAP_WAIT ) return false;
|
||||||
|
|
||||||
line->AddParam("aExist", new CLevelParserParam(true));
|
line->AddParam("aExist", CLevelParserParamUPtr{new CLevelParserParam(true)});
|
||||||
CAuto::Write(line);
|
CAuto::Write(line);
|
||||||
line->AddParam("aPhase", new CLevelParserParam(static_cast<int>(m_phase)));
|
line->AddParam("aPhase", CLevelParserParamUPtr{new CLevelParserParam(static_cast<int>(m_phase))});
|
||||||
line->AddParam("aProgress", new CLevelParserParam(m_progress));
|
line->AddParam("aProgress", CLevelParserParamUPtr{new CLevelParserParam(m_progress)});
|
||||||
line->AddParam("aSpeed", new CLevelParserParam(m_speed));
|
line->AddParam("aSpeed", CLevelParserParamUPtr{new CLevelParserParam(m_speed)});
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -483,16 +483,16 @@ bool CAutoTower::Write(CLevelParserLine* line)
|
||||||
{
|
{
|
||||||
if ( m_phase == ATP_WAIT ) return false;
|
if ( m_phase == ATP_WAIT ) return false;
|
||||||
|
|
||||||
line->AddParam("aExist", new CLevelParserParam(true));
|
line->AddParam("aExist", CLevelParserParamUPtr{new CLevelParserParam(true)});
|
||||||
CAuto::Write(line);
|
CAuto::Write(line);
|
||||||
line->AddParam("aPhase", new CLevelParserParam(static_cast<int>(m_phase)));
|
line->AddParam("aPhase", CLevelParserParamUPtr{new CLevelParserParam(static_cast<int>(m_phase))});
|
||||||
line->AddParam("aProgress", new CLevelParserParam(m_progress));
|
line->AddParam("aProgress", CLevelParserParamUPtr{new CLevelParserParam(m_progress)});
|
||||||
line->AddParam("aSpeed", new CLevelParserParam(m_speed));
|
line->AddParam("aSpeed", CLevelParserParamUPtr{new CLevelParserParam(m_speed)});
|
||||||
line->AddParam("aTargetPos", new CLevelParserParam(m_targetPos));
|
line->AddParam("aTargetPos", CLevelParserParamUPtr{new CLevelParserParam(m_targetPos)});
|
||||||
line->AddParam("aAngleYactual", new CLevelParserParam(m_angleYactual));
|
line->AddParam("aAngleYactual", CLevelParserParamUPtr{new CLevelParserParam(m_angleYactual)});
|
||||||
line->AddParam("aAngleZactual", new CLevelParserParam(m_angleZactual));
|
line->AddParam("aAngleZactual", CLevelParserParamUPtr{new CLevelParserParam(m_angleZactual)});
|
||||||
line->AddParam("aAngleYfinal", new CLevelParserParam(m_angleYfinal));
|
line->AddParam("aAngleYfinal", CLevelParserParamUPtr{new CLevelParserParam(m_angleYfinal)});
|
||||||
line->AddParam("aAngleZfinal", new CLevelParserParam(m_angleZfinal));
|
line->AddParam("aAngleZfinal", CLevelParserParamUPtr{new CLevelParserParam(m_angleZfinal)});
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -171,11 +171,11 @@ void CBrain::SetMotion(CMotion* motion)
|
||||||
|
|
||||||
bool CBrain::Write(CLevelParserLine* line)
|
bool CBrain::Write(CLevelParserLine* line)
|
||||||
{
|
{
|
||||||
line->AddParam("bVirusActive", new CLevelParserParam(m_bActiveVirus));
|
line->AddParam("bVirusActive", CLevelParserParamUPtr{new CLevelParserParam(m_bActiveVirus)});
|
||||||
|
|
||||||
if ( m_object->GetType() == OBJECT_MOBILErs )
|
if ( m_object->GetType() == OBJECT_MOBILErs )
|
||||||
{
|
{
|
||||||
line->AddParam("bShieldActive", new CLevelParserParam(m_secondaryTask != nullptr));
|
line->AddParam("bShieldActive", CLevelParserParamUPtr{new CLevelParserParam(m_secondaryTask != nullptr)});
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -34,6 +34,7 @@
|
||||||
#include <exception>
|
#include <exception>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
|
#include <set>
|
||||||
|
|
||||||
#include <boost/algorithm/string/trim.hpp>
|
#include <boost/algorithm/string/trim.hpp>
|
||||||
#include <boost/algorithm/string/replace.hpp>
|
#include <boost/algorithm/string/replace.hpp>
|
||||||
|
@ -54,14 +55,6 @@ CLevelParser::CLevelParser(std::string category, int chapter, int rank)
|
||||||
m_filename = BuildScenePath(category, chapter, rank);
|
m_filename = BuildScenePath(category, chapter, rank);
|
||||||
}
|
}
|
||||||
|
|
||||||
CLevelParser::~CLevelParser()
|
|
||||||
{
|
|
||||||
for(auto line : m_lines)
|
|
||||||
{
|
|
||||||
delete line;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string CLevelParser::BuildCategoryPath(std::string category)
|
std::string CLevelParser::BuildCategoryPath(std::string category)
|
||||||
{
|
{
|
||||||
std::ostringstream outstream;
|
std::ostringstream outstream;
|
||||||
|
@ -146,7 +139,7 @@ void CLevelParser::Load()
|
||||||
|
|
||||||
std::string line;
|
std::string line;
|
||||||
int lineNumber = 0;
|
int lineNumber = 0;
|
||||||
std::map<std::string, CLevelParserLine*> translatableLines;
|
std::set<std::string> translatableLines;
|
||||||
while (getline(file, line))
|
while (getline(file, line))
|
||||||
{
|
{
|
||||||
lineNumber++;
|
lineNumber++;
|
||||||
|
@ -162,64 +155,91 @@ void CLevelParser::Load()
|
||||||
|
|
||||||
std::size_t pos = line.find_first_of(" \t\n");
|
std::size_t pos = line.find_first_of(" \t\n");
|
||||||
std::string command = line.substr(0, pos);
|
std::string command = line.substr(0, pos);
|
||||||
if(pos != std::string::npos) {
|
if (pos != std::string::npos)
|
||||||
|
{
|
||||||
line = line.substr(pos + 1);
|
line = line.substr(pos + 1);
|
||||||
boost::algorithm::trim(line);
|
boost::algorithm::trim(line);
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
line = "";
|
line = "";
|
||||||
}
|
}
|
||||||
if(command.empty()) continue;
|
|
||||||
|
|
||||||
CLevelParserLine* parserLine = new CLevelParserLine(lineNumber, command);
|
if (command.empty())
|
||||||
|
continue;
|
||||||
|
|
||||||
std::string baseCommand = command;
|
CLevelParserLineUPtr parserLine{new CLevelParserLine(lineNumber, command)};
|
||||||
if(command[command.length()-2] == '.') {
|
|
||||||
baseCommand = command.substr(0, command.length()-2);
|
if (command.length() > 2 && command[command.length() - 2] == '.')
|
||||||
if(command[command.length()-1] == 'E' && translatableLines[baseCommand] == nullptr) {
|
{
|
||||||
|
std::string baseCommand = command.substr(0, command.length() - 2);
|
||||||
parserLine->SetCommand(baseCommand);
|
parserLine->SetCommand(baseCommand);
|
||||||
translatableLines[baseCommand] = parserLine;
|
|
||||||
} else if(command[command.length()-1] == lang) {
|
char languageChar = command[command.length() - 1];
|
||||||
if(translatableLines[baseCommand] != nullptr) {
|
if (languageChar == 'E' && translatableLines.count(baseCommand) == 0)
|
||||||
m_lines.erase(std::remove(m_lines.begin(), m_lines.end(), translatableLines[baseCommand]), m_lines.end());
|
{
|
||||||
delete translatableLines[baseCommand];
|
translatableLines.insert(baseCommand);
|
||||||
}
|
}
|
||||||
parserLine->SetCommand(baseCommand);
|
else if (languageChar == lang)
|
||||||
translatableLines[baseCommand] = parserLine;
|
{
|
||||||
} else {
|
if (translatableLines.count(baseCommand) > 0)
|
||||||
delete parserLine;
|
{
|
||||||
|
auto it = std::remove_if(
|
||||||
|
m_lines.begin(),
|
||||||
|
m_lines.end(),
|
||||||
|
[&baseCommand](const CLevelParserLineUPtr& line)
|
||||||
|
{
|
||||||
|
return line->GetCommand() == baseCommand;
|
||||||
|
});
|
||||||
|
m_lines.erase(it, m_lines.end());
|
||||||
|
}
|
||||||
|
|
||||||
|
translatableLines.insert(baseCommand);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
while(!line.empty()) {
|
while (!line.empty())
|
||||||
|
{
|
||||||
pos = line.find_first_of("=");
|
pos = line.find_first_of("=");
|
||||||
std::string paramName = line.substr(0, pos);
|
std::string paramName = line.substr(0, pos);
|
||||||
boost::algorithm::trim(paramName);
|
boost::algorithm::trim(paramName);
|
||||||
line = line.substr(pos + 1);
|
line = line.substr(pos + 1);
|
||||||
boost::algorithm::trim(line);
|
boost::algorithm::trim(line);
|
||||||
|
|
||||||
if(line[0] == '\"') {
|
if (line[0] == '\"')
|
||||||
|
{
|
||||||
pos = line.find_first_of("\"", 1);
|
pos = line.find_first_of("\"", 1);
|
||||||
if (pos == std::string::npos)
|
if (pos == std::string::npos)
|
||||||
throw CLevelParserException("Unclosed \" in " + m_filename + ":" + boost::lexical_cast<std::string>(lineNumber));
|
throw CLevelParserException("Unclosed \" in " + m_filename + ":" + boost::lexical_cast<std::string>(lineNumber));
|
||||||
} else if(line[0] == '\'') {
|
}
|
||||||
|
else if (line[0] == '\'')
|
||||||
|
{
|
||||||
pos = line.find_first_of("'", 1);
|
pos = line.find_first_of("'", 1);
|
||||||
if (pos == std::string::npos)
|
if (pos == std::string::npos)
|
||||||
throw CLevelParserException("Unclosed ' in " + m_filename + ":" + boost::lexical_cast<std::string>(lineNumber));
|
throw CLevelParserException("Unclosed ' in " + m_filename + ":" + boost::lexical_cast<std::string>(lineNumber));
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
pos = line.find_first_of("=");
|
pos = line.find_first_of("=");
|
||||||
if(pos != std::string::npos) {
|
if (pos != std::string::npos)
|
||||||
|
{
|
||||||
std::size_t pos2 = line.find_last_of(" \t\n", line.find_last_not_of(" \t\n", pos-1));
|
std::size_t pos2 = line.find_last_of(" \t\n", line.find_last_not_of(" \t\n", pos-1));
|
||||||
if (pos2 != std::string::npos)
|
if (pos2 != std::string::npos)
|
||||||
pos = pos2;
|
pos = pos2;
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
pos = line.length()-1;
|
pos = line.length()-1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
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, new CLevelParserParam(paramName, paramValue));
|
parserLine->AddParam(paramName, CLevelParserParamUPtr{new CLevelParserParam(paramName, paramValue)});
|
||||||
|
|
||||||
if (pos == std::string::npos)
|
if (pos == std::string::npos)
|
||||||
break;
|
break;
|
||||||
|
@ -227,7 +247,7 @@ void CLevelParser::Load()
|
||||||
boost::algorithm::trim(line);
|
boost::algorithm::trim(line);
|
||||||
}
|
}
|
||||||
|
|
||||||
AddLine(parserLine);
|
AddLine(std::move(parserLine));
|
||||||
}
|
}
|
||||||
|
|
||||||
file.close();
|
file.close();
|
||||||
|
@ -240,12 +260,9 @@ void CLevelParser::Save()
|
||||||
if (!file.is_open())
|
if (!file.is_open())
|
||||||
throw CLevelParserException("Failed to open file: " + m_filename);
|
throw CLevelParserException("Failed to open file: " + m_filename);
|
||||||
|
|
||||||
for(CLevelParserLine* line : m_lines) {
|
for (auto& line : m_lines)
|
||||||
file << line->GetCommand();
|
{
|
||||||
for(auto param : line->GetParams()) {
|
file << line.get() << "\n";
|
||||||
file << " " << param.first << "=" << param.second->GetValue();
|
|
||||||
}
|
|
||||||
file << "\n";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
file.close();
|
file.close();
|
||||||
|
@ -256,22 +273,18 @@ const std::string& CLevelParser::GetFilename()
|
||||||
return m_filename;
|
return m_filename;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<CLevelParserLine*> CLevelParser::GetLines()
|
void CLevelParser::AddLine(CLevelParserLineUPtr line)
|
||||||
{
|
|
||||||
return m_lines;
|
|
||||||
}
|
|
||||||
|
|
||||||
void CLevelParser::AddLine(CLevelParserLine* line)
|
|
||||||
{
|
{
|
||||||
line->SetLevel(this);
|
line->SetLevel(this);
|
||||||
m_lines.push_back(line);
|
m_lines.push_back(std::move(line));
|
||||||
}
|
}
|
||||||
|
|
||||||
CLevelParserLine* CLevelParser::Get(std::string command)
|
CLevelParserLine* CLevelParser::Get(std::string command)
|
||||||
{
|
{
|
||||||
for(auto& line : m_lines) {
|
for (auto& line : m_lines)
|
||||||
|
{
|
||||||
if (line->GetCommand() == command)
|
if (line->GetCommand() == command)
|
||||||
return line;
|
return line.get();
|
||||||
}
|
}
|
||||||
throw CLevelParserException("Command not found: " + command);
|
throw CLevelParserException("Command not found: " + command);
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,6 +30,7 @@
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
class CLevelParser
|
class CLevelParser
|
||||||
{
|
{
|
||||||
|
@ -41,8 +42,6 @@ public:
|
||||||
//! Load given level
|
//! Load given level
|
||||||
CLevelParser(std::string category, int chapter, int rank);
|
CLevelParser(std::string category, int chapter, int rank);
|
||||||
|
|
||||||
~CLevelParser();
|
|
||||||
|
|
||||||
//! Build category path
|
//! Build category path
|
||||||
static std::string BuildCategoryPath(std::string category);
|
static std::string BuildCategoryPath(std::string category);
|
||||||
//! Build level filename
|
//! Build level filename
|
||||||
|
@ -59,14 +58,18 @@ public:
|
||||||
const std::string& GetFilename();
|
const std::string& GetFilename();
|
||||||
|
|
||||||
//! Get all lines from file
|
//! Get all lines from file
|
||||||
std::vector<CLevelParserLine*> GetLines();
|
inline const std::vector<CLevelParserLineUPtr>& GetLines()
|
||||||
|
{
|
||||||
|
return m_lines;
|
||||||
|
}
|
||||||
|
|
||||||
//! Insert new line to file
|
//! Insert new line to file
|
||||||
void AddLine(CLevelParserLine* line);
|
void AddLine(CLevelParserLineUPtr line);
|
||||||
|
|
||||||
//! Find first line with given command
|
//! Find first line with given command
|
||||||
CLevelParserLine* Get(std::string command);
|
CLevelParserLine* Get(std::string command);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::string m_filename;
|
std::string m_filename;
|
||||||
std::vector<CLevelParserLine*> m_lines;
|
std::vector<CLevelParserLineUPtr> m_lines;
|
||||||
};
|
};
|
|
@ -19,14 +19,13 @@
|
||||||
|
|
||||||
#include "object/level/parserexceptions.h"
|
#include "object/level/parserexceptions.h"
|
||||||
|
|
||||||
|
|
||||||
#include "object/level/parser.h"
|
#include "object/level/parser.h"
|
||||||
|
|
||||||
#include <boost/lexical_cast.hpp>
|
#include <boost/lexical_cast.hpp>
|
||||||
|
|
||||||
CLevelParserException::CLevelParserException(std::string message) NOEXCEPT
|
CLevelParserException::CLevelParserException(std::string message) NOEXCEPT
|
||||||
|
: m_message(message)
|
||||||
{
|
{
|
||||||
m_message = message;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* CLevelParserException::what() const NOEXCEPT
|
const char* CLevelParserException::what() const NOEXCEPT
|
||||||
|
@ -34,12 +33,29 @@ const char* CLevelParserException::what() const NOEXCEPT
|
||||||
return m_message.c_str();
|
return m_message.c_str();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string formatMissingParamError(CLevelParserParam* thisParam) NOEXCEPT
|
||||||
|
{
|
||||||
|
auto paramName = thisParam->GetName();
|
||||||
|
auto lineNumber = boost::lexical_cast<std::string>(thisParam->GetLine()->GetLineNumber());
|
||||||
|
auto fileName = thisParam->GetLine()->GetLevel()->GetFilename();
|
||||||
|
return "Missing required param '" + paramName + "' (in " + fileName + ":" + lineNumber + ")";
|
||||||
|
}
|
||||||
|
|
||||||
CLevelParserExceptionMissingParam::CLevelParserExceptionMissingParam(CLevelParserParam* thisParam) NOEXCEPT
|
CLevelParserExceptionMissingParam::CLevelParserExceptionMissingParam(CLevelParserParam* thisParam) NOEXCEPT
|
||||||
: CLevelParserException("Missing required param "+thisParam->GetName()+" (in "+thisParam->GetLine()->GetLevel()->GetFilename()+":"+boost::lexical_cast<std::string>(thisParam->GetLine()->GetLineNumber())+")")
|
: CLevelParserException(formatMissingParamError(thisParam))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string formatBadParamError(CLevelParserParam* thisParam, std::string requestedType) NOEXCEPT
|
||||||
|
{
|
||||||
|
auto paramName = thisParam->GetName();
|
||||||
|
auto paramValue = thisParam->GetValue();
|
||||||
|
auto lineNumber = boost::lexical_cast<std::string>(thisParam->GetLine()->GetLineNumber());
|
||||||
|
auto fileName = thisParam->GetLine()->GetLevel()->GetFilename();
|
||||||
|
return "Unable to parse '" + paramValue + "' as " + requestedType + " (param '" + paramName + "' in " + fileName + ":" + lineNumber + ")";
|
||||||
|
}
|
||||||
|
|
||||||
CLevelParserExceptionBadParam::CLevelParserExceptionBadParam(CLevelParserParam* thisParam, std::string requestedType) NOEXCEPT
|
CLevelParserExceptionBadParam::CLevelParserExceptionBadParam(CLevelParserParam* thisParam, std::string requestedType) NOEXCEPT
|
||||||
: CLevelParserException("Unable to parse '"+thisParam->GetValue()+"' as "+requestedType+" (param '"+thisParam->GetName()+"' in "+thisParam->GetLine()->GetLevel()->GetFilename()+":"+boost::lexical_cast<std::string>(thisParam->GetLine()->GetLineNumber())+")")
|
: CLevelParserException(formatBadParamError(thisParam, requestedType))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,6 @@
|
||||||
|
|
||||||
#include "object/level/parserline.h"
|
#include "object/level/parserline.h"
|
||||||
|
|
||||||
|
|
||||||
#include "object/level/parser.h"
|
#include "object/level/parser.h"
|
||||||
#include "common/logger.h"
|
#include "common/logger.h"
|
||||||
|
|
||||||
|
@ -35,14 +34,6 @@ CLevelParserLine::CLevelParserLine(int lineNumber, std::string command)
|
||||||
m_lineNumber = lineNumber;
|
m_lineNumber = lineNumber;
|
||||||
}
|
}
|
||||||
|
|
||||||
CLevelParserLine::~CLevelParserLine()
|
|
||||||
{
|
|
||||||
for(auto param : m_params)
|
|
||||||
{
|
|
||||||
delete param.second;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int CLevelParserLine::GetLineNumber()
|
int CLevelParserLine::GetLineNumber()
|
||||||
{
|
{
|
||||||
return m_lineNumber;
|
return m_lineNumber;
|
||||||
|
@ -70,21 +61,31 @@ void CLevelParserLine::SetCommand(std::string command)
|
||||||
|
|
||||||
CLevelParserParam* CLevelParserLine::GetParam(std::string name)
|
CLevelParserParam* CLevelParserLine::GetParam(std::string name)
|
||||||
{
|
{
|
||||||
if(m_params[name] == nullptr) {
|
auto it = m_params.find(name);
|
||||||
CLevelParserParam* param = new CLevelParserParam(name, true);
|
if (it != m_params.end())
|
||||||
param->SetLine(this);
|
{
|
||||||
m_params[name] = param;
|
return it->second.get();
|
||||||
}
|
|
||||||
return m_params[name];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CLevelParserLine::AddParam(std::string name, CLevelParserParam* value)
|
CLevelParserParamUPtr paramUPtr(new CLevelParserParam(name, true));
|
||||||
|
paramUPtr->SetLine(this);
|
||||||
|
CLevelParserParam* paramPtr = paramUPtr.get();
|
||||||
|
m_params.insert(std::make_pair(name, std::move(paramUPtr)));
|
||||||
|
return paramPtr;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CLevelParserLine::AddParam(std::string name, CLevelParserParamUPtr value)
|
||||||
{
|
{
|
||||||
value->SetLine(this);
|
value->SetLine(this);
|
||||||
m_params[name] = value;
|
m_params.insert(std::make_pair(name, std::move(value)));
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::map<std::string, CLevelParserParam*>& CLevelParserLine::GetParams()
|
std::ostream& operator<<(std::ostream& str, const CLevelParserLine& line)
|
||||||
{
|
{
|
||||||
return m_params;
|
str << line.m_command;
|
||||||
|
for (const auto& param : line.m_params)
|
||||||
|
{
|
||||||
|
str << " " << param.first << "=" << param.second->GetValue();
|
||||||
|
}
|
||||||
|
return str;
|
||||||
}
|
}
|
|
@ -24,18 +24,21 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include "object/level/parserparam.h"
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <map>
|
#include <map>
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
class CLevelParser;
|
class CLevelParser;
|
||||||
class CLevelParserParam;
|
class CLevelParserLine;
|
||||||
|
using CLevelParserLineUPtr = std::unique_ptr<CLevelParserLine>;
|
||||||
|
|
||||||
class CLevelParserLine
|
class CLevelParserLine
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CLevelParserLine(int lineNumber, std::string command);
|
CLevelParserLine(int lineNumber, std::string command);
|
||||||
CLevelParserLine(std::string command);
|
CLevelParserLine(std::string command);
|
||||||
~CLevelParserLine();
|
|
||||||
|
|
||||||
//! Get line number
|
//! Get line number
|
||||||
int GetLineNumber();
|
int GetLineNumber();
|
||||||
|
@ -49,12 +52,13 @@ public:
|
||||||
void SetCommand(std::string command);
|
void SetCommand(std::string command);
|
||||||
|
|
||||||
CLevelParserParam* GetParam(std::string name);
|
CLevelParserParam* GetParam(std::string name);
|
||||||
void AddParam(std::string name, CLevelParserParam* value);
|
void AddParam(std::string name, CLevelParserParamUPtr value);
|
||||||
const std::map<std::string, CLevelParserParam*>& GetParams();
|
|
||||||
|
friend std::ostream& operator<<(std::ostream& str, const CLevelParserLine& line);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CLevelParser* m_level;
|
CLevelParser* m_level;
|
||||||
int m_lineNumber;
|
int m_lineNumber;
|
||||||
std::string m_command;
|
std::string m_command;
|
||||||
std::map<std::string, CLevelParserParam*> m_params;
|
std::map<std::string, CLevelParserParamUPtr> m_params;
|
||||||
};
|
};
|
|
@ -19,11 +19,12 @@
|
||||||
|
|
||||||
#include "object/level/parserline.h"
|
#include "object/level/parserline.h"
|
||||||
|
|
||||||
|
|
||||||
#include "app/app.h"
|
#include "app/app.h"
|
||||||
|
|
||||||
#include "common/logger.h"
|
#include "common/logger.h"
|
||||||
#include "common/pathman.h"
|
#include "common/pathman.h"
|
||||||
#include "common/resources/resourcemanager.h"
|
#include "common/resources/resourcemanager.h"
|
||||||
|
|
||||||
#include "object/level/parser.h"
|
#include "object/level/parser.h"
|
||||||
#include "object/robotmain.h"
|
#include "object/robotmain.h"
|
||||||
|
|
||||||
|
@ -31,24 +32,73 @@
|
||||||
#include <boost/algorithm/string.hpp>
|
#include <boost/algorithm/string.hpp>
|
||||||
|
|
||||||
CLevelParserParam::CLevelParserParam(std::string name, std::string value)
|
CLevelParserParam::CLevelParserParam(std::string name, std::string value)
|
||||||
{
|
: m_name(name)
|
||||||
m_name = name;
|
, m_value(value)
|
||||||
m_value = value;
|
{}
|
||||||
m_empty = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
CLevelParserParam::CLevelParserParam(std::string name, bool empty)
|
CLevelParserParam::CLevelParserParam(std::string name, bool empty)
|
||||||
|
: m_empty(empty)
|
||||||
|
, m_name(name)
|
||||||
{
|
{
|
||||||
assert(empty == true); // we need a second argument because we don't want to create param with value "name"
|
assert(empty == true); // we need a second argument because we don't want to create param with value "name"
|
||||||
m_name = name;
|
|
||||||
m_value = "";
|
|
||||||
m_empty = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CLevelParserParam::~CLevelParserParam()
|
CLevelParserParam::CLevelParserParam(int value)
|
||||||
|
: m_value(boost::lexical_cast<std::string>(value))
|
||||||
|
{}
|
||||||
|
|
||||||
|
CLevelParserParam::CLevelParserParam(float value)
|
||||||
|
: m_value(boost::lexical_cast<std::string>(value))
|
||||||
|
{}
|
||||||
|
|
||||||
|
CLevelParserParam::CLevelParserParam(std::string value)
|
||||||
|
: m_value("\""+value+"\"")
|
||||||
|
{}
|
||||||
|
|
||||||
|
CLevelParserParam::CLevelParserParam(bool value)
|
||||||
|
: m_value(value ? "1" : "0")
|
||||||
|
{}
|
||||||
|
|
||||||
|
CLevelParserParam::CLevelParserParam(Gfx::Color value)
|
||||||
{
|
{
|
||||||
for(auto& a : m_array)
|
m_array.push_back(CLevelParserParamUPtr{new CLevelParserParam(value.r)});
|
||||||
delete a;
|
m_array.push_back(CLevelParserParamUPtr{new CLevelParserParam(value.g)});
|
||||||
|
m_array.push_back(CLevelParserParamUPtr{new CLevelParserParam(value.b)});
|
||||||
|
m_array.push_back(CLevelParserParamUPtr{new CLevelParserParam(value.a)});
|
||||||
|
|
||||||
|
LoadArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
CLevelParserParam::CLevelParserParam(Math::Point value)
|
||||||
|
{
|
||||||
|
m_array.push_back(CLevelParserParamUPtr{new CLevelParserParam(value.x)});
|
||||||
|
m_array.push_back(CLevelParserParamUPtr{new CLevelParserParam(value.y)});
|
||||||
|
|
||||||
|
LoadArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
CLevelParserParam::CLevelParserParam(Math::Vector value)
|
||||||
|
{
|
||||||
|
m_array.push_back(CLevelParserParamUPtr{new CLevelParserParam(value.x)});
|
||||||
|
m_array.push_back(CLevelParserParamUPtr{new CLevelParserParam(value.y)});
|
||||||
|
m_array.push_back(CLevelParserParamUPtr{new CLevelParserParam(value.z)});
|
||||||
|
|
||||||
|
LoadArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
CLevelParserParam::CLevelParserParam(ObjectType value)
|
||||||
|
: m_value(FromObjectType(value))
|
||||||
|
{}
|
||||||
|
|
||||||
|
CLevelParserParam::CLevelParserParam(Gfx::CameraType value)
|
||||||
|
: m_value(FromCameraType(value))
|
||||||
|
{}
|
||||||
|
|
||||||
|
CLevelParserParam::CLevelParserParam(CLevelParserParamVec&& array)
|
||||||
|
{
|
||||||
|
m_array.swap(array);
|
||||||
|
|
||||||
|
LoadArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CLevelParserParam::SetLine(CLevelParserLine* line)
|
void CLevelParserParam::SetLine(CLevelParserLine* line)
|
||||||
|
@ -79,7 +129,8 @@ bool CLevelParserParam::IsDefined()
|
||||||
template<typename T>
|
template<typename T>
|
||||||
T CLevelParserParam::Cast(std::string value, std::string requestedType)
|
T CLevelParserParam::Cast(std::string value, std::string requestedType)
|
||||||
{
|
{
|
||||||
try {
|
try
|
||||||
|
{
|
||||||
return boost::lexical_cast<T>(value);
|
return boost::lexical_cast<T>(value);
|
||||||
}
|
}
|
||||||
catch(...)
|
catch(...)
|
||||||
|
@ -133,7 +184,9 @@ std::string CLevelParserParam::AsString()
|
||||||
if ((m_value[0] == '\"' && m_value[m_value.length()-1] == '\"') || (m_value[0] == '\'' && m_value[m_value.length()-1] == '\''))
|
if ((m_value[0] == '\"' && m_value[m_value.length()-1] == '\"') || (m_value[0] == '\'' && m_value[m_value.length()-1] == '\''))
|
||||||
{
|
{
|
||||||
return m_value.substr(1, m_value.length()-2);
|
return m_value.substr(1, m_value.length()-2);
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
throw CLevelParserExceptionBadParam(this, "string");
|
throw CLevelParserExceptionBadParam(this, "string");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -199,9 +252,12 @@ Gfx::Color CLevelParserParam::AsColor()
|
||||||
|
|
||||||
if (m_array.size() == 3) { //RGB
|
if (m_array.size() == 3) { //RGB
|
||||||
return Gfx::Color(m_array[0]->AsFloat(), m_array[1]->AsFloat(), m_array[2]->AsFloat());
|
return Gfx::Color(m_array[0]->AsFloat(), m_array[1]->AsFloat(), m_array[2]->AsFloat());
|
||||||
} else if(m_array.size() == 4) { //RGBA
|
}
|
||||||
|
else if (m_array.size() == 4) { //RGBA
|
||||||
return Gfx::Color(m_array[0]->AsFloat(), m_array[1]->AsFloat(), m_array[2]->AsFloat(), m_array[3]->AsFloat());
|
return Gfx::Color(m_array[0]->AsFloat(), m_array[1]->AsFloat(), m_array[2]->AsFloat(), m_array[3]->AsFloat());
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
throw CLevelParserExceptionBadParam(this, "color");
|
throw CLevelParserExceptionBadParam(this, "color");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -223,9 +279,12 @@ Math::Vector CLevelParserParam::AsPoint()
|
||||||
|
|
||||||
if (m_array.size() == 2) { //XZ
|
if (m_array.size() == 2) { //XZ
|
||||||
return Math::Vector(m_array[0]->AsFloat(), 0.0f, m_array[1]->AsFloat());
|
return Math::Vector(m_array[0]->AsFloat(), 0.0f, m_array[1]->AsFloat());
|
||||||
} else if(m_array.size() == 3) { //XYZ
|
}
|
||||||
|
else if (m_array.size() == 3) { //XYZ
|
||||||
return Math::Vector(m_array[0]->AsFloat(), m_array[1]->AsFloat(), m_array[2]->AsFloat());
|
return Math::Vector(m_array[0]->AsFloat(), m_array[1]->AsFloat(), m_array[2]->AsFloat());
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
throw CLevelParserExceptionBadParam(this, "point");
|
throw CLevelParserExceptionBadParam(this, "point");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -904,12 +963,13 @@ void CLevelParserParam::ParseArray()
|
||||||
std::vector<std::string> values;
|
std::vector<std::string> values;
|
||||||
boost::split(values, m_value, boost::is_any_of(";"));
|
boost::split(values, m_value, boost::is_any_of(";"));
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for(auto& value : values) {
|
for (auto& value : values)
|
||||||
|
{
|
||||||
boost::algorithm::trim(value);
|
boost::algorithm::trim(value);
|
||||||
if (value.empty()) continue;
|
if (value.empty()) continue;
|
||||||
CLevelParserParam* param = new CLevelParserParam(m_name+"["+boost::lexical_cast<std::string>(i)+"]", value);
|
CLevelParserParamUPtr param{new CLevelParserParam(m_name + "[" + boost::lexical_cast<std::string>(i) + "]", value)};
|
||||||
param->SetLine(m_line);
|
param->SetLine(m_line);
|
||||||
m_array.push_back(param);
|
m_array.push_back(std::move(param));
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -918,7 +978,8 @@ void CLevelParserParam::LoadArray()
|
||||||
{
|
{
|
||||||
m_value = "";
|
m_value = "";
|
||||||
bool first = true;
|
bool first = true;
|
||||||
for(auto& value : m_array) {
|
for (auto& value : m_array)
|
||||||
|
{
|
||||||
if (!first)
|
if (!first)
|
||||||
m_value += ";";
|
m_value += ";";
|
||||||
m_value += value->GetValue();
|
m_value += value->GetValue();
|
||||||
|
@ -926,7 +987,7 @@ void CLevelParserParam::LoadArray()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::vector<CLevelParserParam*>& CLevelParserParam::AsArray()
|
const CLevelParserParamVec& CLevelParserParam::AsArray()
|
||||||
{
|
{
|
||||||
if (m_empty)
|
if (m_empty)
|
||||||
throw CLevelParserExceptionMissingParam(this);
|
throw CLevelParserExceptionMissingParam(this);
|
||||||
|
@ -935,55 +996,3 @@ const std::vector<CLevelParserParam*>& CLevelParserParam::AsArray()
|
||||||
|
|
||||||
return m_array;
|
return m_array;
|
||||||
}
|
}
|
||||||
|
|
||||||
CLevelParserParam::CLevelParserParam(int value)
|
|
||||||
{
|
|
||||||
m_value = boost::lexical_cast<std::string>(value);
|
|
||||||
}
|
|
||||||
CLevelParserParam::CLevelParserParam(float value)
|
|
||||||
{
|
|
||||||
m_value = boost::lexical_cast<std::string>(value);
|
|
||||||
}
|
|
||||||
CLevelParserParam::CLevelParserParam(std::string value)
|
|
||||||
{
|
|
||||||
m_value = "\""+value+"\"";
|
|
||||||
}
|
|
||||||
CLevelParserParam::CLevelParserParam(bool value)
|
|
||||||
{
|
|
||||||
m_value = value ? "1" : "0";
|
|
||||||
}
|
|
||||||
CLevelParserParam::CLevelParserParam(Gfx::Color value)
|
|
||||||
{
|
|
||||||
m_array.push_back(new CLevelParserParam(value.r));
|
|
||||||
m_array.push_back(new CLevelParserParam(value.g));
|
|
||||||
m_array.push_back(new CLevelParserParam(value.b));
|
|
||||||
m_array.push_back(new CLevelParserParam(value.a));
|
|
||||||
LoadArray();
|
|
||||||
}
|
|
||||||
CLevelParserParam::CLevelParserParam(Math::Point value)
|
|
||||||
{
|
|
||||||
m_array.push_back(new CLevelParserParam(value.x));
|
|
||||||
m_array.push_back(new CLevelParserParam(value.y));
|
|
||||||
LoadArray();
|
|
||||||
}
|
|
||||||
CLevelParserParam::CLevelParserParam(Math::Vector value)
|
|
||||||
{
|
|
||||||
m_array.push_back(new CLevelParserParam(value.x));
|
|
||||||
m_array.push_back(new CLevelParserParam(value.y));
|
|
||||||
m_array.push_back(new CLevelParserParam(value.z));
|
|
||||||
LoadArray();
|
|
||||||
}
|
|
||||||
CLevelParserParam::CLevelParserParam(ObjectType value)
|
|
||||||
{
|
|
||||||
m_value = FromObjectType(value);
|
|
||||||
}
|
|
||||||
CLevelParserParam::CLevelParserParam(Gfx::CameraType value)
|
|
||||||
{
|
|
||||||
m_value = FromCameraType(value);
|
|
||||||
}
|
|
||||||
CLevelParserParam::CLevelParserParam(const std::vector<CLevelParserParam*>& value)
|
|
||||||
{
|
|
||||||
m_array = value;
|
|
||||||
LoadArray();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
|
@ -24,16 +24,24 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <object/object.h>
|
#include "graphics/core/color.h"
|
||||||
#include <graphics/core/color.h>
|
#include "graphics/engine/water.h"
|
||||||
#include <graphics/engine/water.h>
|
#include "graphics/engine/pyro.h"
|
||||||
#include <graphics/engine/pyro.h>
|
|
||||||
#include <math/point.h>
|
#include "math/point.h"
|
||||||
|
|
||||||
|
#include "object/object.h"
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
class CLevelParserLine;
|
class CLevelParserLine;
|
||||||
|
|
||||||
|
class CLevelParserParam;
|
||||||
|
using CLevelParserParamUPtr = std::unique_ptr<CLevelParserParam>;
|
||||||
|
using CLevelParserParamVec = std::vector<CLevelParserParamUPtr>;
|
||||||
|
|
||||||
class CLevelParserParam
|
class CLevelParserParam
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -48,15 +56,13 @@ public:
|
||||||
CLevelParserParam(Math::Vector value);
|
CLevelParserParam(Math::Vector value);
|
||||||
CLevelParserParam(ObjectType value);
|
CLevelParserParam(ObjectType value);
|
||||||
CLevelParserParam(Gfx::CameraType value);
|
CLevelParserParam(Gfx::CameraType value);
|
||||||
CLevelParserParam(const std::vector<CLevelParserParam*>& value);
|
CLevelParserParam(CLevelParserParamVec&& array);
|
||||||
//@}
|
//@}
|
||||||
//! Create param from string
|
//! Create param from string
|
||||||
CLevelParserParam(std::string name, std::string value);
|
CLevelParserParam(std::string name, std::string value);
|
||||||
//! Create empty parser param
|
//! Create empty parser param
|
||||||
CLevelParserParam(std::string name, bool empty);
|
CLevelParserParam(std::string name, bool empty);
|
||||||
|
|
||||||
~CLevelParserParam();
|
|
||||||
|
|
||||||
//! Get value (throws exception if not found or unable to process)
|
//! Get value (throws exception if not found or unable to process)
|
||||||
//@{
|
//@{
|
||||||
int AsInt();
|
int AsInt();
|
||||||
|
@ -75,7 +81,7 @@ public:
|
||||||
int AsResearchFlag();
|
int AsResearchFlag();
|
||||||
Gfx::PyroType AsPyroType();
|
Gfx::PyroType AsPyroType();
|
||||||
Gfx::CameraType AsCameraType();
|
Gfx::CameraType AsCameraType();
|
||||||
const std::vector<CLevelParserParam*>& AsArray();
|
const CLevelParserParamVec& AsArray();
|
||||||
//@}
|
//@}
|
||||||
|
|
||||||
//! Get value (returns default if not found, throws exception if unable to process)
|
//! Get value (returns default if not found, throws exception if unable to process)
|
||||||
|
@ -129,9 +135,10 @@ private:
|
||||||
const std::string FromCameraType(Gfx::CameraType value);
|
const std::string FromCameraType(Gfx::CameraType value);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CLevelParserLine* m_line;
|
CLevelParserLine* m_line = nullptr;
|
||||||
bool m_empty;
|
bool m_empty = false;
|
||||||
std::string m_name;
|
std::string m_name;
|
||||||
std::string m_value;
|
std::string m_value;
|
||||||
std::vector<CLevelParserParam*> m_array;
|
CLevelParserParamVec m_array;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -162,9 +162,9 @@ bool CMotion::Write(CLevelParserLine* line)
|
||||||
{
|
{
|
||||||
if ( m_actionType == -1 ) return false;
|
if ( m_actionType == -1 ) return false;
|
||||||
|
|
||||||
line->AddParam("mType", new CLevelParserParam(m_actionType));
|
line->AddParam("mType", CLevelParserParamUPtr{new CLevelParserParam(m_actionType)});
|
||||||
line->AddParam("mTime", new CLevelParserParam(m_actionTime));
|
line->AddParam("mTime", CLevelParserParamUPtr{new CLevelParserParam(m_actionTime)});
|
||||||
line->AddParam("mProgress", new CLevelParserParam(m_progress));
|
line->AddParam("mProgress", CLevelParserParamUPtr{new CLevelParserParam(m_progress)});
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,8 +35,6 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const float START_TIME = 1000.0f; // beginning of the relative time
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Object's constructor.
|
// Object's constructor.
|
||||||
|
|
|
@ -950,69 +950,69 @@ bool CObject::Write(CLevelParserLine* line)
|
||||||
float value;
|
float value;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
line->AddParam("camera", new CLevelParserParam(GetCameraType()));
|
line->AddParam("camera", CLevelParserParamUPtr{new CLevelParserParam(GetCameraType())});
|
||||||
|
|
||||||
if ( GetCameraLock() )
|
if ( GetCameraLock() )
|
||||||
line->AddParam("cameraLock", new CLevelParserParam(GetCameraLock()));
|
line->AddParam("cameraLock", CLevelParserParamUPtr{new CLevelParserParam(GetCameraLock())});
|
||||||
|
|
||||||
if ( GetEnergy() != 0.0f )
|
if ( GetEnergy() != 0.0f )
|
||||||
line->AddParam("energy", new CLevelParserParam(GetEnergy()));
|
line->AddParam("energy", CLevelParserParamUPtr{new CLevelParserParam(GetEnergy())});
|
||||||
|
|
||||||
if ( GetCapacity() != 1.0f )
|
if ( GetCapacity() != 1.0f )
|
||||||
line->AddParam("capacity", new CLevelParserParam(GetCapacity()));
|
line->AddParam("capacity", CLevelParserParamUPtr{new CLevelParserParam(GetCapacity())});
|
||||||
|
|
||||||
if ( GetShield() != 1.0f )
|
if ( GetShield() != 1.0f )
|
||||||
line->AddParam("shield", new CLevelParserParam(GetShield()));
|
line->AddParam("shield", CLevelParserParamUPtr{new CLevelParserParam(GetShield())});
|
||||||
|
|
||||||
if ( GetRange() != 1.0f )
|
if ( GetRange() != 1.0f )
|
||||||
line->AddParam("range", new CLevelParserParam(GetRange()));
|
line->AddParam("range", CLevelParserParamUPtr{new CLevelParserParam(GetRange())});
|
||||||
|
|
||||||
if ( !GetSelectable() )
|
if ( !GetSelectable() )
|
||||||
line->AddParam("selectable", new CLevelParserParam(GetSelectable()));
|
line->AddParam("selectable", CLevelParserParamUPtr{new CLevelParserParam(GetSelectable())});
|
||||||
|
|
||||||
if ( !GetEnable() )
|
if ( !GetEnable() )
|
||||||
line->AddParam("enable", new CLevelParserParam(GetEnable()));
|
line->AddParam("enable", CLevelParserParamUPtr{new CLevelParserParam(GetEnable())});
|
||||||
|
|
||||||
if ( GetFixed() )
|
if ( GetFixed() )
|
||||||
line->AddParam("fixed", new CLevelParserParam(GetFixed()));
|
line->AddParam("fixed", CLevelParserParamUPtr{new CLevelParserParam(GetFixed())});
|
||||||
|
|
||||||
if ( !GetClip() )
|
if ( !GetClip() )
|
||||||
line->AddParam("clip", new CLevelParserParam(GetClip()));
|
line->AddParam("clip", CLevelParserParamUPtr{new CLevelParserParam(GetClip())});
|
||||||
|
|
||||||
if ( GetLock() )
|
if ( GetLock() )
|
||||||
line->AddParam("lock", new CLevelParserParam(GetLock()));
|
line->AddParam("lock", CLevelParserParamUPtr{new CLevelParserParam(GetLock())});
|
||||||
|
|
||||||
if ( GetProxyActivate() )
|
if ( GetProxyActivate() )
|
||||||
{
|
{
|
||||||
line->AddParam("proxyActivate", new CLevelParserParam(GetProxyActivate()));
|
line->AddParam("proxyActivate", CLevelParserParamUPtr{new CLevelParserParam(GetProxyActivate())});
|
||||||
line->AddParam("proxyDistance", new CLevelParserParam(GetProxyDistance()/g_unit));
|
line->AddParam("proxyDistance", CLevelParserParamUPtr{new CLevelParserParam(GetProxyDistance()/g_unit)});
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( GetMagnifyDamage() != 1.0f )
|
if ( GetMagnifyDamage() != 1.0f )
|
||||||
line->AddParam("magnifyDamage", new CLevelParserParam(GetMagnifyDamage()));
|
line->AddParam("magnifyDamage", CLevelParserParamUPtr{new CLevelParserParam(GetMagnifyDamage())});
|
||||||
|
|
||||||
if ( GetGunGoalV() != 0.0f )
|
if ( GetGunGoalV() != 0.0f )
|
||||||
line->AddParam("aimV", new CLevelParserParam(GetGunGoalV()));
|
line->AddParam("aimV", CLevelParserParamUPtr{new CLevelParserParam(GetGunGoalV())});
|
||||||
|
|
||||||
if ( GetGunGoalH() != 0.0f )
|
if ( GetGunGoalH() != 0.0f )
|
||||||
line->AddParam("aimH", new CLevelParserParam(GetGunGoalH()));
|
line->AddParam("aimH", CLevelParserParamUPtr{new CLevelParserParam(GetGunGoalH())});
|
||||||
|
|
||||||
if ( GetParam() != 0.0f )
|
if ( GetParam() != 0.0f )
|
||||||
line->AddParam("param", new CLevelParserParam(GetParam()));
|
line->AddParam("param", CLevelParserParamUPtr{new CLevelParserParam(GetParam())});
|
||||||
|
|
||||||
if ( GetResetCap() != 0 )
|
if ( GetResetCap() != 0 )
|
||||||
{
|
{
|
||||||
line->AddParam("resetCap", new CLevelParserParam(static_cast<int>(GetResetCap())));
|
line->AddParam("resetCap", CLevelParserParamUPtr{new CLevelParserParam(static_cast<int>(GetResetCap()))});
|
||||||
line->AddParam("resetPos", new CLevelParserParam(GetResetPosition()/g_unit));
|
line->AddParam("resetPos", CLevelParserParamUPtr{new CLevelParserParam(GetResetPosition()/g_unit)});
|
||||||
line->AddParam("resetAngle", new CLevelParserParam(GetResetAngle()/(Math::PI/180.0f)));
|
line->AddParam("resetAngle", CLevelParserParamUPtr{new CLevelParserParam(GetResetAngle()/(Math::PI/180.0f))});
|
||||||
line->AddParam("resetRun", new CLevelParserParam(m_brain->GetProgramIndex(GetResetRun())));
|
line->AddParam("resetRun", CLevelParserParamUPtr{new CLevelParserParam(m_brain->GetProgramIndex(GetResetRun()))});
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( m_bVirusMode )
|
if ( m_bVirusMode )
|
||||||
line->AddParam("virusMode", new CLevelParserParam(m_bVirusMode));
|
line->AddParam("virusMode", CLevelParserParamUPtr{new CLevelParserParam(m_bVirusMode)});
|
||||||
|
|
||||||
if ( m_virusTime != 0.0f )
|
if ( m_virusTime != 0.0f )
|
||||||
line->AddParam("virusTime", new CLevelParserParam(m_virusTime));
|
line->AddParam("virusTime", CLevelParserParamUPtr{new CLevelParserParam(m_virusTime)});
|
||||||
|
|
||||||
// Puts information in terminal (OBJECT_INFO).
|
// Puts information in terminal (OBJECT_INFO).
|
||||||
for ( i=0 ; i<m_infoTotal ; i++ )
|
for ( i=0 ; i<m_infoTotal ; i++ )
|
||||||
|
@ -1020,20 +1020,20 @@ bool CObject::Write(CLevelParserLine* line)
|
||||||
info = GetInfo(i);
|
info = GetInfo(i);
|
||||||
if ( info.name[0] == 0 ) break;
|
if ( info.name[0] == 0 ) break;
|
||||||
|
|
||||||
line->AddParam("info"+boost::lexical_cast<std::string>(i+1), new CLevelParserParam(std::string(info.name)+"="+boost::lexical_cast<std::string>(info.value)));
|
line->AddParam("info"+boost::lexical_cast<std::string>(i+1), CLevelParserParamUPtr{new CLevelParserParam(std::string(info.name)+"="+boost::lexical_cast<std::string>(info.value))});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sets the parameters of the command line.
|
// Sets the parameters of the command line.
|
||||||
std::vector<CLevelParserParam*> cmdline;
|
CLevelParserParamVec cmdline;
|
||||||
for ( i=0 ; i<OBJECTMAXCMDLINE ; i++ )
|
for ( i=0 ; i<OBJECTMAXCMDLINE ; i++ )
|
||||||
{
|
{
|
||||||
value = GetCmdLine(i);
|
value = GetCmdLine(i);
|
||||||
if ( std::isnan(value) ) break;
|
if ( std::isnan(value) ) break;
|
||||||
|
|
||||||
cmdline.push_back(new CLevelParserParam(value));
|
cmdline.push_back(CLevelParserParamUPtr{new CLevelParserParam(value)});
|
||||||
}
|
}
|
||||||
if (cmdline.size() > 0)
|
if (cmdline.size() > 0)
|
||||||
line->AddParam("cmdline", new CLevelParserParam(cmdline));
|
line->AddParam("cmdline", CLevelParserParamUPtr{new CLevelParserParam(std::move(cmdline))});
|
||||||
|
|
||||||
if ( m_motion != nullptr )
|
if ( m_motion != nullptr )
|
||||||
{
|
{
|
||||||
|
@ -1109,7 +1109,8 @@ bool CObject::Read(CLevelParserLine* line)
|
||||||
throw CLevelParserExceptionBadParam(line->GetParam(op), "info");
|
throw CLevelParserExceptionBadParam(line->GetParam(op), "info");
|
||||||
Info info;
|
Info info;
|
||||||
strcpy(info.name, text.substr(0, p).c_str());
|
strcpy(info.name, text.substr(0, p).c_str());
|
||||||
try {
|
try
|
||||||
|
{
|
||||||
info.value = boost::lexical_cast<float>(text.substr(p+1).c_str());
|
info.value = boost::lexical_cast<float>(text.substr(p+1).c_str());
|
||||||
}
|
}
|
||||||
catch (...)
|
catch (...)
|
||||||
|
@ -1122,8 +1123,10 @@ bool CObject::Read(CLevelParserLine* line)
|
||||||
|
|
||||||
// Sets the parameters of the command line.
|
// Sets the parameters of the command line.
|
||||||
i = 0;
|
i = 0;
|
||||||
if(line->GetParam("cmdline")->IsDefined()) {
|
if (line->GetParam("cmdline")->IsDefined())
|
||||||
for(auto& p : line->GetParam("cmdline")->AsArray()) {
|
{
|
||||||
|
for (auto& p : line->GetParam("cmdline")->AsArray())
|
||||||
|
{
|
||||||
if (i >= OBJECTMAXCMDLINE) break;
|
if (i >= OBJECTMAXCMDLINE) break;
|
||||||
SetCmdLine(i, p->AsFloat());
|
SetCmdLine(i, p->AsFloat());
|
||||||
i++;
|
i++;
|
||||||
|
@ -3905,7 +3908,8 @@ void CObject::SetTraceWidth(float width)
|
||||||
|
|
||||||
DriveType CObject::GetDriveFromObject(ObjectType type)
|
DriveType CObject::GetDriveFromObject(ObjectType type)
|
||||||
{
|
{
|
||||||
switch(type) {
|
switch(type)
|
||||||
|
{
|
||||||
case OBJECT_MOBILEwt:
|
case OBJECT_MOBILEwt:
|
||||||
case OBJECT_MOBILEwa:
|
case OBJECT_MOBILEwa:
|
||||||
case OBJECT_MOBILEwc:
|
case OBJECT_MOBILEwc:
|
||||||
|
@ -3941,7 +3945,8 @@ DriveType CObject::GetDriveFromObject(ObjectType type)
|
||||||
|
|
||||||
ToolType CObject::GetToolFromObject(ObjectType type)
|
ToolType CObject::GetToolFromObject(ObjectType type)
|
||||||
{
|
{
|
||||||
switch(type) {
|
switch(type)
|
||||||
|
{
|
||||||
case OBJECT_MOBILEwa:
|
case OBJECT_MOBILEwa:
|
||||||
case OBJECT_MOBILEta:
|
case OBJECT_MOBILEta:
|
||||||
case OBJECT_MOBILEfa:
|
case OBJECT_MOBILEfa:
|
||||||
|
|
|
@ -555,7 +555,8 @@ void CRobotMain::ChangePhase(Phase phase)
|
||||||
|
|
||||||
m_map->CreateMap();
|
m_map->CreateMap();
|
||||||
|
|
||||||
try {
|
try
|
||||||
|
{
|
||||||
CreateScene(m_dialog->GetSceneSoluce(), false, false); // interactive scene
|
CreateScene(m_dialog->GetSceneSoluce(), false, false); // interactive scene
|
||||||
if (m_mapImage)
|
if (m_mapImage)
|
||||||
m_map->SetFixImage(m_mapFilename);
|
m_map->SetFixImage(m_mapFilename);
|
||||||
|
@ -590,7 +591,8 @@ void CRobotMain::ChangePhase(Phase phase)
|
||||||
m_dialog->SetSceneName("win");
|
m_dialog->SetSceneName("win");
|
||||||
|
|
||||||
m_dialog->SetSceneRank(m_endingWinRank);
|
m_dialog->SetSceneRank(m_endingWinRank);
|
||||||
try {
|
try
|
||||||
|
{
|
||||||
CreateScene(false, true, false); // sets scene
|
CreateScene(false, true, false); // sets scene
|
||||||
|
|
||||||
pos.x = ox+sx*1; pos.y = oy+sy*1;
|
pos.x = ox+sx*1; pos.y = oy+sy*1;
|
||||||
|
@ -636,7 +638,8 @@ void CRobotMain::ChangePhase(Phase phase)
|
||||||
m_winTerminate = false;
|
m_winTerminate = false;
|
||||||
m_dialog->SetSceneName("lost");
|
m_dialog->SetSceneName("lost");
|
||||||
m_dialog->SetSceneRank(m_endingLostRank);
|
m_dialog->SetSceneRank(m_endingLostRank);
|
||||||
try {
|
try
|
||||||
|
{
|
||||||
CreateScene(false, true, false); // sets scene
|
CreateScene(false, true, false); // sets scene
|
||||||
|
|
||||||
pos.x = ox+sx*1; pos.y = oy+sy*1;
|
pos.x = ox+sx*1; pos.y = oy+sy*1;
|
||||||
|
@ -904,7 +907,8 @@ bool CRobotMain::ProcessEvent(Event &event)
|
||||||
{
|
{
|
||||||
std::ostringstream ss;
|
std::ostringstream ss;
|
||||||
CObject* obj = GetSelect();
|
CObject* obj = GetSelect();
|
||||||
if(obj != nullptr) {
|
if (obj != nullptr)
|
||||||
|
{
|
||||||
ss << "CreateObject type=" << GetTypeObject(obj->GetType()) << " pos=" << std::fixed << std::setprecision(3) << obj->GetPosition(0).x/g_unit << ";" << obj->GetPosition(0).z/g_unit << " dir=" << (obj->GetAngleZ(0)/(Math::PI/180.0f));
|
ss << "CreateObject type=" << GetTypeObject(obj->GetType()) << " pos=" << std::fixed << std::setprecision(3) << obj->GetPosition(0).x/g_unit << ";" << obj->GetPosition(0).z/g_unit << " dir=" << (obj->GetAngleZ(0)/(Math::PI/180.0f));
|
||||||
}
|
}
|
||||||
widgetSetClipboardText(ss.str().c_str());
|
widgetSetClipboardText(ss.str().c_str());
|
||||||
|
@ -2005,7 +2009,7 @@ CObject* CRobotMain::DetectObject(Math::Point pos)
|
||||||
{
|
{
|
||||||
if (!obj->GetActif()) continue;
|
if (!obj->GetActif()) continue;
|
||||||
CObject* truck = obj->GetTruck();
|
CObject* truck = obj->GetTruck();
|
||||||
if (truck != nullptr) if (!truck->GetActif()) continue;
|
if (truck != nullptr && !truck->GetActif()) continue;
|
||||||
if (obj->GetProxyActivate()) continue;
|
if (obj->GetProxyActivate()) continue;
|
||||||
|
|
||||||
CObject* target = nullptr;
|
CObject* target = nullptr;
|
||||||
|
@ -2119,7 +2123,6 @@ CObject* CRobotMain::DetectObject(Math::Point pos)
|
||||||
{
|
{
|
||||||
target = obj;
|
target = obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (type == OBJECT_POWER || type == OBJECT_ATOMIC)
|
else if (type == OBJECT_POWER || type == OBJECT_ATOMIC)
|
||||||
{
|
{
|
||||||
target = obj->GetTruck(); // battery connected
|
target = obj->GetTruck(); // battery connected
|
||||||
|
@ -2592,7 +2595,8 @@ bool CRobotMain::EventFrame(const Event &event)
|
||||||
if (!m_movieLock && m_pause->GetPause() == PAUSE_NONE && m_missionTimerStarted)
|
if (!m_movieLock && m_pause->GetPause() == PAUSE_NONE && m_missionTimerStarted)
|
||||||
m_missionTimer += event.rTime;
|
m_missionTimer += event.rTime;
|
||||||
|
|
||||||
if(m_pause->GetPause() == PAUSE_NONE && m_autosave && m_gameTime >= m_autosaveLast+(m_autosaveInterval*60) && m_phase == PHASE_SIMUL) {
|
if (m_pause->GetPause() == PAUSE_NONE && m_autosave && m_gameTime >= m_autosaveLast+(m_autosaveInterval*60) && m_phase == PHASE_SIMUL)
|
||||||
|
{
|
||||||
std::string base = m_dialog->GetSceneName();
|
std::string base = m_dialog->GetSceneName();
|
||||||
if (base == "missions" || base == "freemissions" || base == "custom")
|
if (base == "missions" || base == "freemissions" || base == "custom")
|
||||||
{
|
{
|
||||||
|
@ -2842,7 +2846,8 @@ void CRobotMain::ScenePerso()
|
||||||
|
|
||||||
m_dialog->SetSceneName("perso");
|
m_dialog->SetSceneName("perso");
|
||||||
m_dialog->SetSceneRank(0);
|
m_dialog->SetSceneRank(0);
|
||||||
try {
|
try
|
||||||
|
{
|
||||||
CreateScene(false, true, false); // sets scene
|
CreateScene(false, true, false); // sets scene
|
||||||
}
|
}
|
||||||
catch (const CLevelParserException& e)
|
catch (const CLevelParserException& e)
|
||||||
|
@ -2962,9 +2967,10 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject)
|
||||||
m_missionTimerStarted = false;
|
m_missionTimerStarted = false;
|
||||||
m_missionTimer = 0.0f;
|
m_missionTimer = 0.0f;
|
||||||
|
|
||||||
try {
|
try
|
||||||
CLevelParser* level = new CLevelParser(base, rank/100, rank%100);
|
{
|
||||||
level->Load();
|
CLevelParser levelParser(base, rank/100, rank%100);
|
||||||
|
levelParser.Load();
|
||||||
|
|
||||||
int rankObj = 0;
|
int rankObj = 0;
|
||||||
int rankGadget = 0;
|
int rankGadget = 0;
|
||||||
|
@ -2975,7 +2981,7 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject)
|
||||||
* may speed up loading
|
* may speed up loading
|
||||||
*/
|
*/
|
||||||
|
|
||||||
for(auto& line : level->GetLines())
|
for (auto& line : levelParser.GetLines())
|
||||||
{
|
{
|
||||||
if (line->GetCommand() == "Title" && !resetObject)
|
if (line->GetCommand() == "Title" && !resetObject)
|
||||||
{
|
{
|
||||||
|
@ -3051,7 +3057,8 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject)
|
||||||
if (line->GetCommand() == "MissionTimer")
|
if (line->GetCommand() == "MissionTimer")
|
||||||
{
|
{
|
||||||
m_missionTimerEnabled = line->GetParam("enabled")->AsBool();
|
m_missionTimerEnabled = line->GetParam("enabled")->AsBool();
|
||||||
if(!line->GetParam("program")->AsBool(false)) {
|
if (!line->GetParam("program")->AsBool(false))
|
||||||
|
{
|
||||||
m_missionTimerStarted = true;
|
m_missionTimerStarted = true;
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
|
@ -3091,7 +3098,7 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject)
|
||||||
if (line->GetParam("track")->IsDefined())
|
if (line->GetParam("track")->IsDefined())
|
||||||
{
|
{
|
||||||
if (line->GetParam("filename")->IsDefined())
|
if (line->GetParam("filename")->IsDefined())
|
||||||
throw new CLevelParserException("You can't use track and filename at the same time");
|
throw CLevelParserException("You can't use track and filename at the same time");
|
||||||
|
|
||||||
CLogger::GetInstancePointer()->Warn("Using track= is deprecated. Please replace this with filename=\n");
|
CLogger::GetInstancePointer()->Warn("Using track= is deprecated. Please replace this with filename=\n");
|
||||||
int trackid = line->GetParam("track")->AsInt();
|
int trackid = line->GetParam("track")->AsInt();
|
||||||
|
@ -3122,17 +3129,23 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject)
|
||||||
m_audioRepeat = line->GetParam("repeat")->AsBool(true);
|
m_audioRepeat = line->GetParam("repeat")->AsBool(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(line->GetParam("satcom")->IsDefined()) {
|
if (line->GetParam("satcom")->IsDefined())
|
||||||
|
{
|
||||||
m_satcomTrack = std::string("../")+line->GetParam("satcom")->AsPath("music");
|
m_satcomTrack = std::string("../")+line->GetParam("satcom")->AsPath("music");
|
||||||
m_satcomRepeat = line->GetParam("satcomRepeat")->AsBool(true);
|
m_satcomRepeat = line->GetParam("satcomRepeat")->AsBool(true);
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
m_satcomTrack = "";
|
m_satcomTrack = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
if(line->GetParam("editor")->IsDefined()) {
|
if (line->GetParam("editor")->IsDefined())
|
||||||
|
{
|
||||||
m_editorTrack = std::string("../")+line->GetParam("editor")->AsPath("music");
|
m_editorTrack = std::string("../")+line->GetParam("editor")->AsPath("music");
|
||||||
m_editorRepeat = line->GetParam("editorRepeat")->AsBool(true);
|
m_editorRepeat = line->GetParam("editorRepeat")->AsBool(true);
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
m_editorTrack = "";
|
m_editorTrack = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3190,11 +3203,14 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject)
|
||||||
|
|
||||||
if (line->GetCommand() == "SecondTexture" && !resetObject)
|
if (line->GetCommand() == "SecondTexture" && !resetObject)
|
||||||
{
|
{
|
||||||
if(line->GetParam("rank")->IsDefined()) {
|
if (line->GetParam("rank")->IsDefined())
|
||||||
|
{
|
||||||
char tex[20] = { 0 };
|
char tex[20] = { 0 };
|
||||||
sprintf(tex, "dirty%.2d.png", line->GetParam("rank")->AsInt());
|
sprintf(tex, "dirty%.2d.png", line->GetParam("rank")->AsInt());
|
||||||
m_engine->SetSecondTexture(tex);
|
m_engine->SetSecondTexture(tex);
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
m_engine->SetSecondTexture("../" + line->GetParam("texture")->AsPath("textures"));
|
m_engine->SetSecondTexture("../" + line->GetParam("texture")->AsPath("textures"));
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
|
@ -3348,8 +3364,9 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject)
|
||||||
int tt[100]; //TODO: I have no idea how TerrainInitTextures works, but maybe we shuld remove the limit to 100?
|
int tt[100]; //TODO: I have no idea how TerrainInitTextures works, but maybe we shuld remove the limit to 100?
|
||||||
if (dx*dy > 100)
|
if (dx*dy > 100)
|
||||||
throw CLevelParserException("In TerrainInitTextures: dx*dy must be <100");
|
throw CLevelParserException("In TerrainInitTextures: dx*dy must be <100");
|
||||||
if(line->GetParam("table")->IsDefined()) {
|
if (line->GetParam("table")->IsDefined())
|
||||||
const std::vector<CLevelParserParam*>& table = line->GetParam("table")->AsArray();
|
{
|
||||||
|
auto& table = line->GetParam("table")->AsArray();
|
||||||
|
|
||||||
if (table.size() > dx*dy)
|
if (table.size() > dx*dy)
|
||||||
throw CLevelParserException("In TerrainInitTextures: table size must be dx*dy");
|
throw CLevelParserException("In TerrainInitTextures: table size must be dx*dy");
|
||||||
|
@ -3359,11 +3376,15 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject)
|
||||||
if (i >= table.size())
|
if (i >= table.size())
|
||||||
{
|
{
|
||||||
tt[i] = 0;
|
tt[i] = 0;
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
tt[i] = table[i]->AsInt();
|
tt[i] = table[i]->AsInt();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
for (unsigned int i = 0; i < dx*dy; i++)
|
for (unsigned int i = 0; i < dx*dy; i++)
|
||||||
{
|
{
|
||||||
tt[i] = 0;
|
tt[i] = 0;
|
||||||
|
@ -3402,18 +3423,19 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject)
|
||||||
if (line->GetCommand() == "TerrainLevel" && !resetObject)
|
if (line->GetCommand() == "TerrainLevel" && !resetObject)
|
||||||
{
|
{
|
||||||
int id[50]; //TODO: I have no idea how TerrainLevel works, but maybe we should remove the limit to 50?
|
int id[50]; //TODO: I have no idea how TerrainLevel works, but maybe we should remove the limit to 50?
|
||||||
if(line->GetParam("id")->IsDefined()) {
|
if (line->GetParam("id")->IsDefined())
|
||||||
const std::vector<CLevelParserParam*>& id_array = line->GetParam("id")->AsArray();
|
{
|
||||||
|
auto& idArray = line->GetParam("id")->AsArray();
|
||||||
|
|
||||||
if(id_array.size() > 50)
|
if (idArray.size() > 50)
|
||||||
throw CLevelParserException("In TerrainLevel: id array size must be < 50");
|
throw CLevelParserException("In TerrainLevel: id array size must be < 50");
|
||||||
|
|
||||||
unsigned int i = 0;
|
unsigned int i = 0;
|
||||||
while (i < 50)
|
while (i < 50)
|
||||||
{
|
{
|
||||||
id[i] = id_array[i]->AsInt();
|
id[i] = idArray[i]->AsInt();
|
||||||
i++;
|
i++;
|
||||||
if(i >= id_array.size()) break;
|
if (i >= idArray.size()) break;
|
||||||
}
|
}
|
||||||
id[i] = 0;
|
id[i] = 0;
|
||||||
}
|
}
|
||||||
|
@ -3551,7 +3573,8 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject)
|
||||||
throw CLevelParserExceptionBadParam(line->GetParam(op), "info");
|
throw CLevelParserExceptionBadParam(line->GetParam(op), "info");
|
||||||
Info info;
|
Info info;
|
||||||
strcpy(info.name, text.substr(0, p).c_str());
|
strcpy(info.name, text.substr(0, p).c_str());
|
||||||
try {
|
try
|
||||||
|
{
|
||||||
info.value = boost::lexical_cast<float>(text.substr(p+1).c_str());
|
info.value = boost::lexical_cast<float>(text.substr(p+1).c_str());
|
||||||
}
|
}
|
||||||
catch (...)
|
catch (...)
|
||||||
|
@ -3562,8 +3585,9 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sets the parameters of the command line.
|
// Sets the parameters of the command line.
|
||||||
if(line->GetParam("cmdline")->IsDefined()) {
|
if (line->GetParam("cmdline")->IsDefined())
|
||||||
const std::vector<CLevelParserParam*>& cmdline = line->GetParam("cmdline")->AsArray();
|
{
|
||||||
|
const auto& cmdline = line->GetParam("cmdline")->AsArray();
|
||||||
for (unsigned int i = 0; i < OBJECTMAXCMDLINE && i < cmdline.size(); i++) //TODO: get rid of the limit
|
for (unsigned int i = 0; i < OBJECTMAXCMDLINE && i < cmdline.size(); i++) //TODO: get rid of the limit
|
||||||
{
|
{
|
||||||
obj->SetCmdLine(i, cmdline[i]->AsFloat());
|
obj->SetCmdLine(i, cmdline[i]->AsFloat());
|
||||||
|
@ -3600,7 +3624,7 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject)
|
||||||
CMotion* motion = obj->GetMotion();
|
CMotion* motion = obj->GetMotion();
|
||||||
if (motion != nullptr && line->GetParam("param")->IsDefined())
|
if (motion != nullptr && line->GetParam("param")->IsDefined())
|
||||||
{
|
{
|
||||||
const std::vector<CLevelParserParam*>& p = line->GetParam("param")->AsArray();
|
const auto& p = line->GetParam("param")->AsArray();
|
||||||
for (unsigned int i = 0; i < 10 && i < p.size(); i++)
|
for (unsigned int i = 0; i < 10 && i < p.size(); i++)
|
||||||
{
|
{
|
||||||
motion->SetParam(i, p[i]->AsFloat());
|
motion->SetParam(i, p[i]->AsFloat());
|
||||||
|
@ -3617,7 +3641,8 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject)
|
||||||
std::string op = "script" + boost::lexical_cast<std::string>(i+1); // script1..script10
|
std::string op = "script" + boost::lexical_cast<std::string>(i+1); // script1..script10
|
||||||
std::string opReadOnly = "scriptReadOnly" + boost::lexical_cast<std::string>(i+1); // scriptReadOnly1..scriptReadOnly10
|
std::string opReadOnly = "scriptReadOnly" + boost::lexical_cast<std::string>(i+1); // scriptReadOnly1..scriptReadOnly10
|
||||||
std::string opRunnable = "scriptRunnable" + boost::lexical_cast<std::string>(i+1); // scriptRunnable1..scriptRunnable10
|
std::string opRunnable = "scriptRunnable" + boost::lexical_cast<std::string>(i+1); // scriptRunnable1..scriptRunnable10
|
||||||
if(line->GetParam(op)->IsDefined()) {
|
if (line->GetParam(op)->IsDefined())
|
||||||
|
{
|
||||||
Program* program = brain->AddProgram();
|
Program* program = brain->AddProgram();
|
||||||
program->filename = "../" + line->GetParam(op)->AsPath("ai");
|
program->filename = "../" + line->GetParam(op)->AsPath("ai");
|
||||||
program->readOnly = line->GetParam(opReadOnly)->AsBool(true);
|
program->readOnly = line->GetParam(opReadOnly)->AsBool(true);
|
||||||
|
@ -3970,7 +3995,9 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject)
|
||||||
|
|
||||||
m_beginSatCom = true; // message already displayed
|
m_beginSatCom = true; // message already displayed
|
||||||
}
|
}
|
||||||
} catch(...) {
|
}
|
||||||
|
catch (...)
|
||||||
|
{
|
||||||
m_dialog->SetSceneRead("");
|
m_dialog->SetSceneRead("");
|
||||||
m_dialog->SetStackRead("");
|
m_dialog->SetStackRead("");
|
||||||
throw;
|
throw;
|
||||||
|
@ -4555,7 +4582,8 @@ void CRobotMain::CompileScript(bool soluce)
|
||||||
if (program->filename.empty()) continue;
|
if (program->filename.empty()) continue;
|
||||||
|
|
||||||
std::string name = "ai/" + program->filename;
|
std::string name = "ai/" + program->filename;
|
||||||
if(! brain->ReadProgram(program, const_cast<char*>(name.c_str()))) {
|
if (! brain->ReadProgram(program, const_cast<char*>(name.c_str())))
|
||||||
|
{
|
||||||
CLogger::GetInstancePointer()->Error("Unable to read script from file \"%s\"\n", name.c_str());
|
CLogger::GetInstancePointer()->Error("Unable to read script from file \"%s\"\n", name.c_str());
|
||||||
}
|
}
|
||||||
if (!brain->GetCompile(program)) nbError++;
|
if (!brain->GetCompile(program)) nbError++;
|
||||||
|
@ -4832,11 +4860,11 @@ void CRobotMain::IOWriteObject(CLevelParserLine* line, CObject* obj)
|
||||||
{
|
{
|
||||||
if (obj->GetType() == OBJECT_FIX) return;
|
if (obj->GetType() == OBJECT_FIX) return;
|
||||||
|
|
||||||
line->AddParam("type", new CLevelParserParam(obj->GetType()));
|
line->AddParam("type", CLevelParserParamUPtr{new CLevelParserParam(obj->GetType())});
|
||||||
line->AddParam("id", new CLevelParserParam(obj->GetID()));
|
line->AddParam("id", CLevelParserParamUPtr{new CLevelParserParam(obj->GetID())});
|
||||||
line->AddParam("pos", new CLevelParserParam(obj->GetPosition(0)/g_unit));
|
line->AddParam("pos", CLevelParserParamUPtr{new CLevelParserParam(obj->GetPosition(0)/g_unit)});
|
||||||
line->AddParam("angle", new CLevelParserParam(obj->GetAngle(0)/(Math::PI/180.0f)));
|
line->AddParam("angle", CLevelParserParamUPtr{new CLevelParserParam(obj->GetAngle(0)/(Math::PI/180.0f))});
|
||||||
line->AddParam("zoom", new CLevelParserParam(obj->GetZoom(0)));
|
line->AddParam("zoom", CLevelParserParamUPtr{new CLevelParserParam(obj->GetZoom(0))});
|
||||||
|
|
||||||
Math::Vector pos;
|
Math::Vector pos;
|
||||||
for (int i = 1; i < OBJECTMAXPART; i++)
|
for (int i = 1; i < OBJECTMAXPART; i++)
|
||||||
|
@ -4847,33 +4875,33 @@ 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), new CLevelParserParam(pos));
|
line->AddParam("p" + boost::lexical_cast<std::string>(i), CLevelParserParamUPtr{new CLevelParserParam(pos)});
|
||||||
}
|
}
|
||||||
|
|
||||||
pos = obj->GetAngle(i);
|
pos = obj->GetAngle(i);
|
||||||
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 /= (Math::PI/180.0f);
|
pos /= (Math::PI/180.0f);
|
||||||
line->AddParam("a"+boost::lexical_cast<std::string>(i), new CLevelParserParam(pos));
|
line->AddParam("a" + boost::lexical_cast<std::string>(i), CLevelParserParamUPtr{new CLevelParserParam(pos)});
|
||||||
}
|
}
|
||||||
|
|
||||||
pos = obj->GetZoom(i);
|
pos = obj->GetZoom(i);
|
||||||
if (pos.x != 1.0f || pos.y != 1.0f || pos.z != 1.0f)
|
if (pos.x != 1.0f || pos.y != 1.0f || pos.z != 1.0f)
|
||||||
{
|
{
|
||||||
line->AddParam("z"+boost::lexical_cast<std::string>(i), new CLevelParserParam(pos));
|
line->AddParam("z" + boost::lexical_cast<std::string>(i), CLevelParserParamUPtr{new CLevelParserParam(pos)});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
line->AddParam("trainer", new CLevelParserParam(obj->GetTrainer()));
|
line->AddParam("trainer", CLevelParserParamUPtr{new CLevelParserParam(obj->GetTrainer())});
|
||||||
line->AddParam("ignoreBuildCheck", new CLevelParserParam(obj->GetIgnoreBuildCheck()));
|
line->AddParam("ignoreBuildCheck", CLevelParserParamUPtr{new CLevelParserParam(obj->GetIgnoreBuildCheck())});
|
||||||
line->AddParam("option", new CLevelParserParam(obj->GetOption()));
|
line->AddParam("option", CLevelParserParamUPtr{new CLevelParserParam(obj->GetOption())});
|
||||||
if (obj == m_infoObject)
|
if (obj == m_infoObject)
|
||||||
line->AddParam("select", new CLevelParserParam(1));
|
line->AddParam("select", CLevelParserParamUPtr{new CLevelParserParam(1)});
|
||||||
|
|
||||||
obj->Write(line);
|
obj->Write(line);
|
||||||
|
|
||||||
if (obj->GetType() == OBJECT_BASE)
|
if (obj->GetType() == OBJECT_BASE)
|
||||||
line->AddParam("run", new CLevelParserParam(3)); // stops and open (PARAM_FIXSCENE)
|
line->AddParam("run", CLevelParserParamUPtr{new CLevelParserParam(3)}); // stops and open (PARAM_FIXSCENE)
|
||||||
|
|
||||||
CBrain* brain = obj->GetBrain();
|
CBrain* brain = obj->GetBrain();
|
||||||
if (brain != nullptr)
|
if (brain != nullptr)
|
||||||
|
@ -4881,7 +4909,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", new CLevelParserParam(run+1));
|
line->AddParam("run", CLevelParserParamUPtr{new CLevelParserParam(run+1)});
|
||||||
}
|
}
|
||||||
|
|
||||||
auto programs = brain->GetPrograms();
|
auto programs = brain->GetPrograms();
|
||||||
|
@ -4889,7 +4917,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), new CLevelParserParam(true));
|
line->AddParam("scriptReadOnly" + boost::lexical_cast<std::string>(i+1), CLevelParserParamUPtr{new CLevelParserParam(true)});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4898,52 +4926,52 @@ void CRobotMain::IOWriteObject(CLevelParserLine* line, CObject* obj)
|
||||||
//! Saves the current game
|
//! Saves the current game
|
||||||
bool CRobotMain::IOWriteScene(const char *filename, const char *filecbot, char *info)
|
bool CRobotMain::IOWriteScene(const char *filename, const char *filecbot, char *info)
|
||||||
{
|
{
|
||||||
CLevelParser* level = new CLevelParser(filename);
|
CLevelParser levelParser(filename);
|
||||||
CLevelParserLine* line;
|
CLevelParserLineUPtr line;
|
||||||
|
|
||||||
line = new CLevelParserLine("Title");
|
line.reset(new CLevelParserLine("Title"));
|
||||||
line->AddParam("text", new CLevelParserParam(std::string(info)));
|
line->AddParam("text", CLevelParserParamUPtr{new CLevelParserParam(std::string(info))});
|
||||||
level->AddLine(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 = new CLevelParserLine("Version");
|
line.reset(new CLevelParserLine("Version"));
|
||||||
line->AddParam("maj", new CLevelParserParam(0));
|
line->AddParam("maj", CLevelParserParamUPtr{new CLevelParserParam(0)});
|
||||||
line->AddParam("min", new CLevelParserParam(1));
|
line->AddParam("min", CLevelParserParamUPtr{new CLevelParserParam(1)});
|
||||||
level->AddLine(line);
|
levelParser.AddLine(std::move(line));
|
||||||
|
|
||||||
|
|
||||||
line = new CLevelParserLine("Created");
|
line.reset(new CLevelParserLine("Created"));
|
||||||
line->AddParam("date", new CLevelParserParam(GetCurrentTimestamp()));
|
line->AddParam("date", CLevelParserParamUPtr{new CLevelParserParam(GetCurrentTimestamp())});
|
||||||
level->AddLine(line);
|
levelParser.AddLine(std::move(line));
|
||||||
|
|
||||||
char* name = m_dialog->GetSceneName();
|
char* name = m_dialog->GetSceneName();
|
||||||
line = new CLevelParserLine("Mission");
|
line.reset(new CLevelParserLine("Mission"));
|
||||||
line->AddParam("base", new CLevelParserParam(std::string(name)));
|
line->AddParam("base", CLevelParserParamUPtr{new CLevelParserParam(std::string(name))});
|
||||||
line->AddParam("rank", new CLevelParserParam(m_dialog->GetSceneRank()));
|
line->AddParam("rank", CLevelParserParamUPtr{new CLevelParserParam(m_dialog->GetSceneRank())});
|
||||||
if (std::string(name) == "custom")
|
if (std::string(name) == "custom")
|
||||||
{
|
{
|
||||||
line->AddParam("dir", new CLevelParserParam(std::string(m_dialog->GetSceneDir())));
|
line->AddParam("dir", CLevelParserParamUPtr{new CLevelParserParam(std::string(m_dialog->GetSceneDir()))});
|
||||||
}
|
}
|
||||||
level->AddLine(line);
|
levelParser.AddLine(std::move(line));
|
||||||
|
|
||||||
line = new CLevelParserLine("Map");
|
line.reset(new CLevelParserLine("Map"));
|
||||||
line->AddParam("zoom", new CLevelParserParam(m_map->GetZoomMap()));
|
line->AddParam("zoom", CLevelParserParamUPtr{new CLevelParserParam(m_map->GetZoomMap())});
|
||||||
level->AddLine(line);
|
levelParser.AddLine(std::move(line));
|
||||||
|
|
||||||
line = new CLevelParserLine("DoneResearch");
|
line.reset(new CLevelParserLine("DoneResearch"));
|
||||||
line->AddParam("bits", new CLevelParserParam(static_cast<int>(g_researchDone)));
|
line->AddParam("bits", CLevelParserParamUPtr{new CLevelParserParam(static_cast<int>(g_researchDone))});
|
||||||
level->AddLine(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 = new CLevelParserLine("BlitzMode");
|
line.reset(new CLevelParserLine("BlitzMode"));
|
||||||
line->AddParam("sleep", new CLevelParserParam(sleep));
|
line->AddParam("sleep", CLevelParserParamUPtr{new CLevelParserParam(sleep)});
|
||||||
line->AddParam("delay", new CLevelParserParam(delay));
|
line->AddParam("delay", CLevelParserParamUPtr{new CLevelParserParam(delay)});
|
||||||
line->AddParam("magnetic", new CLevelParserParam(magnetic/g_unit));
|
line->AddParam("magnetic", CLevelParserParamUPtr{new CLevelParserParam(magnetic/g_unit)});
|
||||||
line->AddParam("progress", new CLevelParserParam(progress));
|
line->AddParam("progress", CLevelParserParamUPtr{new CLevelParserParam(progress)});
|
||||||
level->AddLine(line);
|
levelParser.AddLine(std::move(line));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -4960,33 +4988,36 @@ bool CRobotMain::IOWriteScene(const char *filename, const char *filecbot, char *
|
||||||
CObject* power = obj->GetPower();
|
CObject* power = obj->GetPower();
|
||||||
CObject* fret = obj->GetFret();
|
CObject* fret = obj->GetFret();
|
||||||
|
|
||||||
if (fret != nullptr){ // object transported?
|
if (fret != nullptr) // object transported?
|
||||||
line = new CLevelParserLine("CreateFret");
|
{
|
||||||
IOWriteObject(line, fret);
|
line.reset(new CLevelParserLine("CreateFret"));
|
||||||
level->AddLine(line);
|
IOWriteObject(line.get(), fret);
|
||||||
|
levelParser.AddLine(std::move(line));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (power != nullptr) { // battery transported?
|
if (power != nullptr) // battery transported?
|
||||||
line = new CLevelParserLine("CreatePower");
|
{
|
||||||
IOWriteObject(line, power);
|
line.reset(new CLevelParserLine("CreatePower"));
|
||||||
level->AddLine(line);
|
IOWriteObject(line.get(), power);
|
||||||
|
levelParser.AddLine(std::move(line));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
line = new CLevelParserLine("CreateObject");
|
line.reset(new CLevelParserLine("CreateObject"));
|
||||||
IOWriteObject(line, obj);
|
IOWriteObject(line.get(), obj);
|
||||||
level->AddLine(line);
|
levelParser.AddLine(std::move(line));
|
||||||
|
|
||||||
SaveFileScript(obj, filename, objRank++);
|
SaveFileScript(obj, filename, objRank++);
|
||||||
}
|
}
|
||||||
try {
|
try
|
||||||
level->Save();
|
{
|
||||||
} catch(CLevelParserException& e) {
|
levelParser.Save();
|
||||||
|
}
|
||||||
|
catch (CLevelParserException& e)
|
||||||
|
{
|
||||||
CLogger::GetInstancePointer()->Error("Failed to save level state - %s\n", e.what());
|
CLogger::GetInstancePointer()->Error("Failed to save level state - %s\n", e.what());
|
||||||
delete level;
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
delete level;
|
|
||||||
|
|
||||||
// Writes the file of stacks of execution.
|
// Writes the file of stacks of execution.
|
||||||
FILE* file = fOpen(filecbot, "wb");
|
FILE* file = fOpen(filecbot, "wb");
|
||||||
|
@ -5098,15 +5129,15 @@ CObject* CRobotMain::IOReadObject(CLevelParserLine *line, const char* filename,
|
||||||
//! Resumes some part of the game
|
//! Resumes some part of the game
|
||||||
CObject* CRobotMain::IOReadScene(const char *filename, const char *filecbot)
|
CObject* CRobotMain::IOReadScene(const char *filename, const char *filecbot)
|
||||||
{
|
{
|
||||||
CLevelParser* level = new CLevelParser(filename);
|
CLevelParser levelParser(filename);
|
||||||
level->Load();
|
levelParser.Load();
|
||||||
|
|
||||||
m_base = nullptr;
|
m_base = nullptr;
|
||||||
CObject* fret = nullptr;
|
CObject* fret = nullptr;
|
||||||
CObject* power = nullptr;
|
CObject* power = nullptr;
|
||||||
CObject* sel = nullptr;
|
CObject* sel = nullptr;
|
||||||
int objRank = 0;
|
int objRank = 0;
|
||||||
for(auto& line : level->GetLines())
|
for (auto& line : levelParser.GetLines())
|
||||||
{
|
{
|
||||||
if (line->GetCommand() == "Map")
|
if (line->GetCommand() == "Map")
|
||||||
m_map->ZoomMap(line->GetParam("zoom")->AsFloat());
|
m_map->ZoomMap(line->GetParam("zoom")->AsFloat());
|
||||||
|
@ -5124,14 +5155,14 @@ CObject* CRobotMain::IOReadScene(const char *filename, const char *filecbot)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (line->GetCommand() == "CreateFret")
|
if (line->GetCommand() == "CreateFret")
|
||||||
fret = IOReadObject(line, filename, -1);
|
fret = IOReadObject(line.get(), filename, -1);
|
||||||
|
|
||||||
if (line->GetCommand() == "CreatePower")
|
if (line->GetCommand() == "CreatePower")
|
||||||
power = IOReadObject(line, filename, -1);
|
power = IOReadObject(line.get(), filename, -1);
|
||||||
|
|
||||||
if (line->GetCommand() == "CreateObject")
|
if (line->GetCommand() == "CreateObject")
|
||||||
{
|
{
|
||||||
CObject* obj = IOReadObject(line, filename, objRank++);
|
CObject* obj = IOReadObject(line.get(), filename, objRank++);
|
||||||
|
|
||||||
if (line->GetParam("select")->AsBool(false))
|
if (line->GetParam("select")->AsBool(false))
|
||||||
sel = obj;
|
sel = obj;
|
||||||
|
@ -5154,7 +5185,6 @@ CObject* CRobotMain::IOReadScene(const char *filename, const char *filecbot)
|
||||||
power = nullptr;
|
power = nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
delete level;
|
|
||||||
|
|
||||||
// Compiles scripts.
|
// Compiles scripts.
|
||||||
int nbError = 0;
|
int nbError = 0;
|
||||||
|
@ -5393,7 +5423,8 @@ void CRobotMain::ResetCreate()
|
||||||
|
|
||||||
m_camera->SetType(Gfx::CAM_TYPE_DIALOG);
|
m_camera->SetType(Gfx::CAM_TYPE_DIALOG);
|
||||||
|
|
||||||
try {
|
try
|
||||||
|
{
|
||||||
CreateScene(m_dialog->GetSceneSoluce(), false, true);
|
CreateScene(m_dialog->GetSceneSoluce(), false, true);
|
||||||
|
|
||||||
if (!GetNiceReset()) return;
|
if (!GetNiceReset()) return;
|
||||||
|
@ -5447,10 +5478,17 @@ void CRobotMain::UpdateAudio(bool frame)
|
||||||
|
|
||||||
ToolType tool = CObject::GetToolFromObject(type);
|
ToolType tool = CObject::GetToolFromObject(type);
|
||||||
DriveType drive = CObject::GetDriveFromObject(type);
|
DriveType drive = CObject::GetDriveFromObject(type);
|
||||||
if (m_audioChange[t].tool != TOOL_OTHER) if(tool != m_audioChange[t].tool) continue;
|
if (m_audioChange[t].tool != TOOL_OTHER &&
|
||||||
if (m_audioChange[t].drive != DRIVE_OTHER) if(drive != m_audioChange[t].drive) continue;
|
tool != m_audioChange[t].tool)
|
||||||
|
continue;
|
||||||
|
if (m_audioChange[t].drive != DRIVE_OTHER &&
|
||||||
|
drive != m_audioChange[t].drive)
|
||||||
|
continue;
|
||||||
|
|
||||||
if (m_audioChange[t].tool == TOOL_OTHER && m_audioChange[t].drive == DRIVE_OTHER) if (type != m_audioChange[t].type) continue;
|
if (m_audioChange[t].tool == TOOL_OTHER &&
|
||||||
|
m_audioChange[t].drive == DRIVE_OTHER &&
|
||||||
|
type != m_audioChange[t].type)
|
||||||
|
continue;
|
||||||
|
|
||||||
float energyLevel = -1;
|
float energyLevel = -1;
|
||||||
CObject* power = obj->GetPower();
|
CObject* power = obj->GetPower();
|
||||||
|
@ -5458,7 +5496,9 @@ void CRobotMain::UpdateAudio(bool frame)
|
||||||
{
|
{
|
||||||
energyLevel = power->GetEnergy();
|
energyLevel = power->GetEnergy();
|
||||||
if (power->GetType() == OBJECT_ATOMIC) energyLevel *= 100;
|
if (power->GetType() == OBJECT_ATOMIC) energyLevel *= 100;
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
if (obj->GetType() == OBJECT_POWER || obj->GetType() == OBJECT_ATOMIC)
|
if (obj->GetType() == OBJECT_POWER || obj->GetType() == OBJECT_ATOMIC)
|
||||||
{
|
{
|
||||||
energyLevel = obj->GetEnergy();
|
energyLevel = obj->GetEnergy();
|
||||||
|
@ -5524,9 +5564,11 @@ Error CRobotMain::CheckEndMission(bool frame)
|
||||||
m_eventQueue->AddEvent(Event(EVENT_QUIT));
|
m_eventQueue->AddEvent(Event(EVENT_QUIT));
|
||||||
}
|
}
|
||||||
if (frame && m_base != nullptr && m_base->GetSelectable()) return ERR_MISSION_NOTERM;
|
if (frame && m_base != nullptr && m_base->GetSelectable()) return ERR_MISSION_NOTERM;
|
||||||
if (m_missionResult == ERR_OK) { //mission win?
|
if (m_missionResult == ERR_OK) //mission win?
|
||||||
|
{
|
||||||
m_displayText->DisplayError(INFO_WIN, Math::Vector(0.0f,0.0f,0.0f));
|
m_displayText->DisplayError(INFO_WIN, Math::Vector(0.0f,0.0f,0.0f));
|
||||||
if(m_missionTimerEnabled && m_missionTimerStarted) {
|
if (m_missionTimerEnabled && m_missionTimerStarted)
|
||||||
|
{
|
||||||
CLogger::GetInstancePointer()->Info("Mission time: %s\n", TimeFormat(m_missionTimer).c_str());
|
CLogger::GetInstancePointer()->Info("Mission time: %s\n", TimeFormat(m_missionTimer).c_str());
|
||||||
m_displayText->DisplayText(("Time: " + TimeFormat(m_missionTimer)).c_str(), Math::Vector(0.0f,0.0f,0.0f));
|
m_displayText->DisplayText(("Time: " + TimeFormat(m_missionTimer)).c_str(), Math::Vector(0.0f,0.0f,0.0f));
|
||||||
}
|
}
|
||||||
|
@ -5575,10 +5617,18 @@ Error CRobotMain::CheckEndMission(bool frame)
|
||||||
|
|
||||||
ToolType tool = CObject::GetToolFromObject(type);
|
ToolType tool = CObject::GetToolFromObject(type);
|
||||||
DriveType drive = CObject::GetDriveFromObject(type);
|
DriveType drive = CObject::GetDriveFromObject(type);
|
||||||
if (m_endTake[t].tool != TOOL_OTHER) if(tool != m_endTake[t].tool) continue;
|
if (m_endTake[t].tool != TOOL_OTHER &&
|
||||||
if (m_endTake[t].drive != DRIVE_OTHER) if(drive != m_endTake[t].drive) continue;
|
tool != m_endTake[t].tool)
|
||||||
|
continue;
|
||||||
|
|
||||||
if (m_endTake[t].tool == TOOL_OTHER && m_endTake[t].drive == DRIVE_OTHER) if (type != m_endTake[t].type) continue;
|
if (m_endTake[t].drive != DRIVE_OTHER &&
|
||||||
|
drive != m_endTake[t].drive)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (m_endTake[t].tool == TOOL_OTHER &&
|
||||||
|
m_endTake[t].drive == DRIVE_OTHER &&
|
||||||
|
type != m_endTake[t].type)
|
||||||
|
continue;
|
||||||
|
|
||||||
float energyLevel = -1;
|
float energyLevel = -1;
|
||||||
CObject* power = obj->GetPower();
|
CObject* power = obj->GetPower();
|
||||||
|
@ -5586,7 +5636,9 @@ Error CRobotMain::CheckEndMission(bool frame)
|
||||||
{
|
{
|
||||||
energyLevel = power->GetEnergy();
|
energyLevel = power->GetEnergy();
|
||||||
if (power->GetType() == OBJECT_ATOMIC) energyLevel *= 100;
|
if (power->GetType() == OBJECT_ATOMIC) energyLevel *= 100;
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
if (obj->GetType() == OBJECT_POWER || obj->GetType() == OBJECT_ATOMIC)
|
if (obj->GetType() == OBJECT_POWER || obj->GetType() == OBJECT_ATOMIC)
|
||||||
{
|
{
|
||||||
energyLevel = obj->GetEnergy();
|
energyLevel = obj->GetEnergy();
|
||||||
|
@ -5683,7 +5735,8 @@ Error CRobotMain::CheckEndMission(bool frame)
|
||||||
if (m_winDelay == 0.0f)
|
if (m_winDelay == 0.0f)
|
||||||
{
|
{
|
||||||
m_displayText->DisplayError(INFO_WIN, Math::Vector(0.0f,0.0f,0.0f));
|
m_displayText->DisplayError(INFO_WIN, Math::Vector(0.0f,0.0f,0.0f));
|
||||||
if(m_missionTimerEnabled && m_missionTimerStarted) {
|
if (m_missionTimerEnabled && m_missionTimerStarted)
|
||||||
|
{
|
||||||
CLogger::GetInstancePointer()->Info("Mission time: %s\n", TimeFormat(m_missionTimer).c_str());
|
CLogger::GetInstancePointer()->Info("Mission time: %s\n", TimeFormat(m_missionTimer).c_str());
|
||||||
m_displayText->DisplayText(("Time: " + TimeFormat(m_missionTimer)).c_str(), Math::Vector(0.0f,0.0f,0.0f));
|
m_displayText->DisplayText(("Time: " + TimeFormat(m_missionTimer)).c_str(), Math::Vector(0.0f,0.0f,0.0f));
|
||||||
}
|
}
|
||||||
|
@ -6095,7 +6148,8 @@ void CRobotMain::StartMusic()
|
||||||
//! Starts pause music
|
//! Starts pause music
|
||||||
void CRobotMain::StartPauseMusic(PauseType pause)
|
void CRobotMain::StartPauseMusic(PauseType pause)
|
||||||
{
|
{
|
||||||
switch(pause) {
|
switch(pause)
|
||||||
|
{
|
||||||
case PAUSE_EDITOR:
|
case PAUSE_EDITOR:
|
||||||
if (m_editorTrack != "")
|
if (m_editorTrack != "")
|
||||||
m_sound->PlayPauseMusic(m_editorTrack, m_editorRepeat);
|
m_sound->PlayPauseMusic(m_editorTrack, m_editorRepeat);
|
||||||
|
@ -6136,7 +6190,8 @@ std::string& CRobotMain::GetUserLevelName(int id)
|
||||||
|
|
||||||
void CRobotMain::StartMissionTimer()
|
void CRobotMain::StartMissionTimer()
|
||||||
{
|
{
|
||||||
if(m_missionTimerEnabled && !m_missionTimerStarted) {
|
if (m_missionTimerEnabled && !m_missionTimerStarted)
|
||||||
|
{
|
||||||
CLogger::GetInstancePointer()->Info("Starting mission timer...\n");
|
CLogger::GetInstancePointer()->Info("Starting mission timer...\n");
|
||||||
m_missionTimerStarted = true;
|
m_missionTimerStarted = true;
|
||||||
}
|
}
|
||||||
|
@ -6228,8 +6283,10 @@ int CRobotMain::AutosaveRotate(bool freeOne)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Rename autosaves that we kept
|
// Rename autosaves that we kept
|
||||||
if(rotate) {
|
if (rotate)
|
||||||
for(auto& save : autosavesToKeep) {
|
{
|
||||||
|
for (auto& save : autosavesToKeep)
|
||||||
|
{
|
||||||
std::string newDir = std::string(GetSavegameDir()) + "/" + GetGamerName() + "/autosave" + boost::lexical_cast<std::string>(save.first);
|
std::string newDir = std::string(GetSavegameDir()) + "/" + GetGamerName() + "/autosave" + boost::lexical_cast<std::string>(save.first);
|
||||||
CLogger::GetInstancePointer()->Trace("Rename %s -> %s\n", save.second.c_str(), newDir.c_str());
|
CLogger::GetInstancePointer()->Trace("Rename %s -> %s\n", save.second.c_str(), newDir.c_str());
|
||||||
CResourceManager::Move(save.second, newDir);
|
CResourceManager::Move(save.second, newDir);
|
||||||
|
|
|
@ -1294,7 +1294,7 @@ bool CTaskGoto::GetHotPoint(CObject *pObj, Math::Vector &pos,
|
||||||
|
|
||||||
bool CTaskGoto::LeakSearch(Math::Vector &pos, float &delay)
|
bool CTaskGoto::LeakSearch(Math::Vector &pos, float &delay)
|
||||||
{
|
{
|
||||||
CObject *pObj, *pObstacle = nullptr;
|
CObject *pObstacle = nullptr;
|
||||||
Math::Vector iPos, oPos, bPos;
|
Math::Vector iPos, oPos, bPos;
|
||||||
float iRadius, oRadius, bRadius, dist, min, dir;
|
float iRadius, oRadius, bRadius, dist, min, dir;
|
||||||
int j;
|
int j;
|
||||||
|
|
|
@ -175,12 +175,12 @@ PhysicsType CPhysics::GetType()
|
||||||
|
|
||||||
bool CPhysics::Write(CLevelParserLine* line)
|
bool CPhysics::Write(CLevelParserLine* line)
|
||||||
{
|
{
|
||||||
line->AddParam("motor", new CLevelParserParam(m_motorSpeed));
|
line->AddParam("motor", CLevelParserParamUPtr{new CLevelParserParam(m_motorSpeed)});
|
||||||
|
|
||||||
if ( m_type == TYPE_FLYING )
|
if ( m_type == TYPE_FLYING )
|
||||||
{
|
{
|
||||||
line->AddParam("reactorRange", new CLevelParserParam(GetReactorRange()));
|
line->AddParam("reactorRange", CLevelParserParamUPtr{new CLevelParserParam(GetReactorRange())});
|
||||||
line->AddParam("land", new CLevelParserParam(GetLand()));
|
line->AddParam("land", CLevelParserParamUPtr{new CLevelParserParam(GetLand())});
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -333,18 +333,21 @@ void CMainDialog::ChangePhase(Phase phase)
|
||||||
pb = pw->CreateButton(pos, ddim, -1, EVENT_INTERFACE_USER);
|
pb = pw->CreateButton(pos, ddim, -1, EVENT_INTERFACE_USER);
|
||||||
pb->SetState(STATE_SHADOW);
|
pb->SetState(STATE_SHADOW);
|
||||||
|
|
||||||
try {
|
try
|
||||||
CLevelParser* level = new CLevelParser("levels/custom/config.txt");
|
{
|
||||||
if(level->Exists()) {
|
CLevelParser levelParser("levels/custom/config.txt");
|
||||||
level->Load();
|
if (levelParser.Exists())
|
||||||
CLevelParserLine* line = level->Get("Button");
|
{
|
||||||
|
levelParser.Load();
|
||||||
|
CLevelParserLine* line = levelParser.Get("Button");
|
||||||
if (line->GetParam("name")->IsDefined())
|
if (line->GetParam("name")->IsDefined())
|
||||||
pb->SetName(line->GetParam("name")->AsString());
|
pb->SetName(line->GetParam("name")->AsString());
|
||||||
if (line->GetParam("tooltip")->IsDefined())
|
if (line->GetParam("tooltip")->IsDefined())
|
||||||
pb->SetTooltip(line->GetParam("tooltip")->AsString());
|
pb->SetTooltip(line->GetParam("tooltip")->AsString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch(CLevelParserException& e) {
|
catch (CLevelParserException& e)
|
||||||
|
{
|
||||||
CLogger::GetInstancePointer()->Error("Failed loading userlevel button name: %s\n", e.what());
|
CLogger::GetInstancePointer()->Error("Failed loading userlevel button name: %s\n", e.what());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3980,11 +3983,11 @@ void CMainDialog::IOReadName()
|
||||||
|
|
||||||
resume = std::string(m_sceneName) + " " + boost::lexical_cast<std::string>(m_chap[m_index]+1);
|
resume = std::string(m_sceneName) + " " + boost::lexical_cast<std::string>(m_chap[m_index]+1);
|
||||||
|
|
||||||
CLevelParser* level = new CLevelParser(m_sceneName, m_chap[m_index]+1, 0);
|
CLevelParser levelParser(m_sceneName, m_chap[m_index]+1, 0);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
level->Load();
|
levelParser.Load();
|
||||||
resume = level->Get("Title")->GetParam("resume")->AsString();
|
resume = levelParser.Get("Title")->GetParam("resume")->AsString();
|
||||||
}
|
}
|
||||||
catch (CLevelParserException& e)
|
catch (CLevelParserException& e)
|
||||||
{
|
{
|
||||||
|
@ -3994,7 +3997,6 @@ void CMainDialog::IOReadName()
|
||||||
time(&now);
|
time(&now);
|
||||||
TimeToAsciiClean(now, line);
|
TimeToAsciiClean(now, line);
|
||||||
sprintf(name, "%s - %s %d", line, resume.c_str(), m_sel[m_index]+1);
|
sprintf(name, "%s - %s %d", line, resume.c_str(), m_sel[m_index]+1);
|
||||||
delete level;
|
|
||||||
|
|
||||||
pe->SetText(name);
|
pe->SetText(name);
|
||||||
pe->SetCursor(strlen(name), 0);
|
pe->SetCursor(strlen(name), 0);
|
||||||
|
@ -4027,12 +4029,11 @@ void CMainDialog::IOReadList()
|
||||||
std::string savegameFile = userSaveDir + "/" + dir + "/" + "data.sav";
|
std::string savegameFile = userSaveDir + "/" + dir + "/" + "data.sav";
|
||||||
if (CResourceManager::Exists(savegameFile))
|
if (CResourceManager::Exists(savegameFile))
|
||||||
{
|
{
|
||||||
CLevelParser* level = new CLevelParser(savegameFile);
|
CLevelParser levelParser(savegameFile);
|
||||||
level->Load();
|
levelParser.Load();
|
||||||
int time = level->Get("Created")->GetParam("date")->AsInt();
|
int time = levelParser.Get("Created")->GetParam("date")->AsInt();
|
||||||
sortedSaveDirs[time] = userSaveDir + "/" + dir;
|
sortedSaveDirs[time] = userSaveDir + "/" + dir;
|
||||||
names[time] = level->Get("Title")->GetParam("text")->AsString();
|
names[time] = levelParser.Get("Title")->GetParam("text")->AsString();
|
||||||
delete level;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4229,10 +4230,10 @@ bool CMainDialog::IOReadScene()
|
||||||
std::string fileName = m_saveList.at(sel) + "/" + "data.sav";
|
std::string fileName = m_saveList.at(sel) + "/" + "data.sav";
|
||||||
std::string fileCbot = CResourceManager::GetSaveLocation()+"/"+m_saveList.at(sel) + "/" + "cbot.run";
|
std::string fileCbot = CResourceManager::GetSaveLocation()+"/"+m_saveList.at(sel) + "/" + "cbot.run";
|
||||||
|
|
||||||
CLevelParser* level = new CLevelParser(fileName);
|
CLevelParser levelParser(fileName);
|
||||||
level->Load();
|
levelParser.Load();
|
||||||
|
|
||||||
CLevelParserLine* line = level->Get("Mission");
|
CLevelParserLine* line = levelParser.Get("Mission");
|
||||||
strcpy(m_sceneName, line->GetParam("base")->AsString().c_str());
|
strcpy(m_sceneName, line->GetParam("base")->AsString().c_str());
|
||||||
m_sceneRank = line->GetParam("rank")->AsInt();
|
m_sceneRank = line->GetParam("rank")->AsInt();
|
||||||
|
|
||||||
|
@ -4251,13 +4252,10 @@ bool CMainDialog::IOReadScene()
|
||||||
}
|
}
|
||||||
if ( m_sceneRank/100 == 0 )
|
if ( m_sceneRank/100 == 0 )
|
||||||
{
|
{
|
||||||
delete level;
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
delete level;
|
|
||||||
|
|
||||||
m_chap[m_index] = (m_sceneRank / 100)-1;
|
m_chap[m_index] = (m_sceneRank / 100)-1;
|
||||||
m_sel[m_index] = (m_sceneRank % 100)-1;
|
m_sel[m_index] = (m_sceneRank % 100)-1;
|
||||||
|
|
||||||
|
@ -4331,12 +4329,12 @@ void CMainDialog::UpdateSceneChap(int &chap)
|
||||||
|
|
||||||
for ( j=0 ; j<m_userTotal ; j++ )
|
for ( j=0 ; j<m_userTotal ; j++ )
|
||||||
{
|
{
|
||||||
try {
|
try
|
||||||
CLevelParser* level = new CLevelParser("custom", j+1, 0);
|
{
|
||||||
level->Load();
|
CLevelParser levelParser("custom", j+1, 0);
|
||||||
pl->SetItemName(j, level->Get("Title")->GetParam("text")->AsString().c_str());
|
levelParser.Load();
|
||||||
|
pl->SetItemName(j, levelParser.Get("Title")->GetParam("text")->AsString().c_str());
|
||||||
pl->SetEnable(j, true);
|
pl->SetEnable(j, true);
|
||||||
delete level;
|
|
||||||
}
|
}
|
||||||
catch (CLevelParserException& e)
|
catch (CLevelParserException& e)
|
||||||
{
|
{
|
||||||
|
@ -4349,17 +4347,18 @@ void CMainDialog::UpdateSceneChap(int &chap)
|
||||||
{
|
{
|
||||||
for ( j=0 ; j<9 ; j++ )
|
for ( j=0 ; j<9 ; j++ )
|
||||||
{
|
{
|
||||||
CLevelParser* level = new CLevelParser(m_sceneName, j+1, 0);
|
CLevelParser levelParser(m_sceneName, j+1, 0);
|
||||||
if(!level->Exists())
|
if (!levelParser.Exists())
|
||||||
break;
|
break;
|
||||||
try {
|
try
|
||||||
level->Load();
|
{
|
||||||
sprintf(line, "%d: %s", j+1, level->Get("Title")->GetParam("text")->AsString().c_str());
|
levelParser.Load();
|
||||||
|
sprintf(line, "%d: %s", j+1, levelParser.Get("Title")->GetParam("text")->AsString().c_str());
|
||||||
}
|
}
|
||||||
catch(CLevelParserException& e) {
|
catch (CLevelParserException& e)
|
||||||
|
{
|
||||||
sprintf(line, "%s", (std::string("[ERROR]: ")+e.what()).c_str());
|
sprintf(line, "%s", (std::string("[ERROR]: ")+e.what()).c_str());
|
||||||
}
|
}
|
||||||
delete level;
|
|
||||||
|
|
||||||
bPassed = GetGamerInfoPassed((j+1)*100);
|
bPassed = GetGamerInfoPassed((j+1)*100);
|
||||||
pl->SetItemName(j, line);
|
pl->SetItemName(j, line);
|
||||||
|
@ -4411,22 +4410,26 @@ void CMainDialog::UpdateSceneList(int chap, int &sel)
|
||||||
bool readAll = true;
|
bool readAll = true;
|
||||||
for ( j=0 ; j<99 ; j++ )
|
for ( j=0 ; j<99 ; j++ )
|
||||||
{
|
{
|
||||||
CLevelParser* level = new CLevelParser(m_sceneName, chap+1, j+1);
|
CLevelParser levelParser(m_sceneName, chap+1, j+1);
|
||||||
if(!level->Exists()) {
|
if (!levelParser.Exists())
|
||||||
|
{
|
||||||
readAll = true;
|
readAll = true;
|
||||||
break;
|
break;
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
if (!readAll)
|
if (!readAll)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
try {
|
try
|
||||||
level->Load();
|
{
|
||||||
sprintf(line, "%d: %s", j+1, level->Get("Title")->GetParam("text")->AsString().c_str());
|
levelParser.Load();
|
||||||
|
sprintf(line, "%d: %s", j+1, levelParser.Get("Title")->GetParam("text")->AsString().c_str());
|
||||||
}
|
}
|
||||||
catch(CLevelParserException& e) {
|
catch (CLevelParserException& e)
|
||||||
|
{
|
||||||
sprintf(line, "%s", (std::string("[ERROR]: ")+e.what()).c_str());
|
sprintf(line, "%s", (std::string("[ERROR]: ")+e.what()).c_str());
|
||||||
}
|
}
|
||||||
delete level;
|
|
||||||
|
|
||||||
bPassed = GetGamerInfoPassed((chap+1)*100+(j+1));
|
bPassed = GetGamerInfoPassed((chap+1)*100+(j+1));
|
||||||
pl->SetItemName(j, line);
|
pl->SetItemName(j, line);
|
||||||
|
@ -4529,10 +4532,11 @@ void CMainDialog::UpdateSceneResume(int rank)
|
||||||
|
|
||||||
if (rank<100) return;
|
if (rank<100) return;
|
||||||
|
|
||||||
try {
|
try
|
||||||
CLevelParser* level = new CLevelParser(m_sceneName, rank/100, rank%100);
|
{
|
||||||
level->Load();
|
CLevelParser levelParser(m_sceneName, rank/100, rank%100);
|
||||||
pe->SetText(level->Get("Resume")->GetParam("text")->AsString().c_str());
|
levelParser.Load();
|
||||||
|
pe->SetText(levelParser.Get("Resume")->GetParam("text")->AsString().c_str());
|
||||||
}
|
}
|
||||||
catch (CLevelParserException& e)
|
catch (CLevelParserException& e)
|
||||||
{
|
{
|
||||||
|
@ -5232,15 +5236,18 @@ void CMainDialog::SetupRecall()
|
||||||
std::getline(resolution, ws, 'x');
|
std::getline(resolution, ws, 'x');
|
||||||
std::getline(resolution, hs, 'x');
|
std::getline(resolution, hs, 'x');
|
||||||
int w = 800, h = 600;
|
int w = 800, h = 600;
|
||||||
if(!ws.empty() && !hs.empty()) {
|
if (!ws.empty() && !hs.empty())
|
||||||
|
{
|
||||||
w = atoi(ws.c_str());
|
w = atoi(ws.c_str());
|
||||||
h = atoi(hs.c_str());
|
h = atoi(hs.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<Math::IntPoint> modes;
|
std::vector<Math::IntPoint> modes;
|
||||||
m_app->GetVideoResolutionList(modes, true, true);
|
m_app->GetVideoResolutionList(modes, true, true);
|
||||||
for(auto it = modes.begin(); it != modes.end(); ++it) {
|
for (auto it = modes.begin(); it != modes.end(); ++it)
|
||||||
if(it->x == w && it->y == h) {
|
{
|
||||||
|
if (it->x == w && it->y == h)
|
||||||
|
{
|
||||||
m_setupSelMode = it - modes.begin();
|
m_setupSelMode = it - modes.begin();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -5959,24 +5966,26 @@ bool CMainDialog::GetHimselfDamage()
|
||||||
|
|
||||||
void CMainDialog::WriteGamerPerso(char *gamer)
|
void CMainDialog::WriteGamerPerso(char *gamer)
|
||||||
{
|
{
|
||||||
try {
|
try
|
||||||
CLevelParser* perso = new CLevelParser(GetSavegameDir()+"/"+gamer+"/face.gam");
|
{
|
||||||
CLevelParserLine* line;
|
CLevelParser persoParser(GetSavegameDir()+"/"+gamer+"/face.gam");
|
||||||
|
CLevelParserLineUPtr line;
|
||||||
|
|
||||||
line = new CLevelParserLine("Head");
|
line.reset(new CLevelParserLine("Head"));
|
||||||
line->AddParam("face", new CLevelParserParam(m_perso.face));
|
line->AddParam("face", CLevelParserParamUPtr{new CLevelParserParam(m_perso.face)});
|
||||||
line->AddParam("glasses", new CLevelParserParam(m_perso.glasses));
|
line->AddParam("glasses", CLevelParserParamUPtr{new CLevelParserParam(m_perso.glasses)});
|
||||||
line->AddParam("hair", new CLevelParserParam(m_perso.colorHair));
|
line->AddParam("hair", CLevelParserParamUPtr{new CLevelParserParam(m_perso.colorHair)});
|
||||||
perso->AddLine(line);
|
persoParser.AddLine(std::move(line));
|
||||||
|
|
||||||
line = new CLevelParserLine("Body");
|
line.reset(new CLevelParserLine("Body"));
|
||||||
line->AddParam("combi", new CLevelParserParam(m_perso.colorCombi));
|
line->AddParam("combi", CLevelParserParamUPtr{new CLevelParserParam(m_perso.colorCombi)});
|
||||||
line->AddParam("band", new CLevelParserParam(m_perso.colorBand));
|
line->AddParam("band", CLevelParserParamUPtr{new CLevelParserParam(m_perso.colorBand)});
|
||||||
perso->AddLine(line);
|
persoParser.AddLine(std::move(line));
|
||||||
|
|
||||||
perso->Save();
|
persoParser.Save();
|
||||||
delete perso;
|
}
|
||||||
} catch(CLevelParserException& e) {
|
catch (CLevelParserException& e)
|
||||||
|
{
|
||||||
CLogger::GetInstancePointer()->Error("Unable to write personalized player apperance: %s\n", e.what());
|
CLogger::GetInstancePointer()->Error("Unable to write personalized player apperance: %s\n", e.what());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5991,22 +6000,23 @@ void CMainDialog::ReadGamerPerso(char *gamer)
|
||||||
if (!CResourceManager::Exists(GetSavegameDir()+"/"+gamer+"/face.gam"))
|
if (!CResourceManager::Exists(GetSavegameDir()+"/"+gamer+"/face.gam"))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
try {
|
try
|
||||||
CLevelParser* perso = new CLevelParser(GetSavegameDir()+"/"+gamer+"/face.gam");
|
{
|
||||||
perso->Load();
|
CLevelParser persoParser(GetSavegameDir()+"/"+gamer+"/face.gam");
|
||||||
|
persoParser.Load();
|
||||||
CLevelParserLine* line;
|
CLevelParserLine* line;
|
||||||
|
|
||||||
line = perso->Get("Head");
|
line = persoParser.Get("Head");
|
||||||
m_perso.face = line->GetParam("face")->AsInt();
|
m_perso.face = line->GetParam("face")->AsInt();
|
||||||
m_perso.glasses = line->GetParam("glasses")->AsInt();
|
m_perso.glasses = line->GetParam("glasses")->AsInt();
|
||||||
m_perso.colorHair = line->GetParam("hair")->AsColor();
|
m_perso.colorHair = line->GetParam("hair")->AsColor();
|
||||||
|
|
||||||
line = perso->Get("Body");
|
line = persoParser.Get("Body");
|
||||||
m_perso.colorCombi = line->GetParam("combi")->AsColor();
|
m_perso.colorCombi = line->GetParam("combi")->AsColor();
|
||||||
m_perso.colorBand = line->GetParam("band")->AsColor();
|
m_perso.colorBand = line->GetParam("band")->AsColor();
|
||||||
|
}
|
||||||
delete perso;
|
catch (CLevelParserException& e)
|
||||||
} catch(CLevelParserException& e) {
|
{
|
||||||
CLogger::GetInstancePointer()->Error("Unable to read personalized player apperance: %s\n", e.what());
|
CLogger::GetInstancePointer()->Error("Unable to read personalized player apperance: %s\n", e.what());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6083,7 +6093,8 @@ bool CMainDialog::ReadGamerInfo()
|
||||||
|
|
||||||
CInputStream file;
|
CInputStream file;
|
||||||
file.open(GetSavegameDir()+"/"+m_main->GetGamerName()+"/"+m_sceneName+".gam");
|
file.open(GetSavegameDir()+"/"+m_main->GetGamerName()+"/"+m_sceneName+".gam");
|
||||||
if(!file.is_open()) {
|
if (!file.is_open())
|
||||||
|
{
|
||||||
CLogger::GetInstancePointer()->Error("Unable to read list of finished missions\n");
|
CLogger::GetInstancePointer()->Error("Unable to read list of finished missions\n");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -6125,7 +6136,8 @@ bool CMainDialog::WriteGamerInfo()
|
||||||
|
|
||||||
COutputStream file;
|
COutputStream file;
|
||||||
file.open(GetSavegameDir()+"/"+m_main->GetGamerName()+"/"+m_sceneName+".gam");
|
file.open(GetSavegameDir()+"/"+m_main->GetGamerName()+"/"+m_sceneName+".gam");
|
||||||
if(!file.is_open()) {
|
if (!file.is_open())
|
||||||
|
{
|
||||||
CLogger::GetInstancePointer()->Error("Unable to read list of finished missions\n");
|
CLogger::GetInstancePointer()->Error("Unable to read list of finished missions\n");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue