Removed cmdline limit
parent
b84130e067
commit
52f809b8bb
|
@ -280,10 +280,7 @@ COldObject::COldObject(int id)
|
||||||
m_partiSel[i] = -1;
|
m_partiSel[i] = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i=0 ; i<OBJECTMAXCMDLINE ; i++ )
|
m_cmdLine.clear();
|
||||||
{
|
|
||||||
m_cmdLine[i] = NAN;
|
|
||||||
}
|
|
||||||
|
|
||||||
DeleteAllCrashSpheres();
|
DeleteAllCrashSpheres();
|
||||||
m_globalSpherePos = Math::Vector(0.0f, 0.0f, 0.0f);
|
m_globalSpherePos = Math::Vector(0.0f, 0.0f, 0.0f);
|
||||||
|
@ -867,8 +864,6 @@ int COldObject::GetOption()
|
||||||
void COldObject::Write(CLevelParserLine* line)
|
void COldObject::Write(CLevelParserLine* line)
|
||||||
{
|
{
|
||||||
Math::Vector pos;
|
Math::Vector pos;
|
||||||
float value;
|
|
||||||
int i;
|
|
||||||
|
|
||||||
line->AddParam("camera", CLevelParserParamUPtr{new CLevelParserParam(GetCameraType())});
|
line->AddParam("camera", CLevelParserParamUPtr{new CLevelParserParam(GetCameraType())});
|
||||||
|
|
||||||
|
@ -936,11 +931,8 @@ void COldObject::Write(CLevelParserLine* line)
|
||||||
|
|
||||||
// Sets the parameters of the command line.
|
// Sets the parameters of the command line.
|
||||||
CLevelParserParamVec cmdline;
|
CLevelParserParamVec cmdline;
|
||||||
for ( i=0 ; i<OBJECTMAXCMDLINE ; i++ )
|
for(float value : m_cmdLine)
|
||||||
{
|
{
|
||||||
value = GetCmdLine(i);
|
|
||||||
if ( std::isnan(value) ) break;
|
|
||||||
|
|
||||||
cmdline.push_back(CLevelParserParamUPtr{new CLevelParserParam(value)});
|
cmdline.push_back(CLevelParserParamUPtr{new CLevelParserParam(value)});
|
||||||
}
|
}
|
||||||
if (cmdline.size() > 0)
|
if (cmdline.size() > 0)
|
||||||
|
@ -1010,7 +1002,6 @@ void COldObject::Read(CLevelParserLine* line)
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (auto& p : line->GetParam("cmdline")->AsArray())
|
for (auto& p : line->GetParam("cmdline")->AsArray())
|
||||||
{
|
{
|
||||||
if (i >= OBJECTMAXCMDLINE) break;
|
|
||||||
SetCmdLine(i, p->AsFloat());
|
SetCmdLine(i, p->AsFloat());
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
@ -1652,16 +1643,26 @@ float COldObject::GetInfoReturn()
|
||||||
return m_infoReturn;
|
return m_infoReturn;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool COldObject::SetCmdLine(int rank, float value)
|
void COldObject::SetCmdLine(unsigned int rank, float value)
|
||||||
{
|
{
|
||||||
if ( rank < 0 || rank >= OBJECTMAXCMDLINE ) return false;
|
if (rank == m_cmdLine.size())
|
||||||
m_cmdLine[rank] = value;
|
{
|
||||||
return true;
|
m_cmdLine.push_back(value);
|
||||||
|
}
|
||||||
|
else if (rank < m_cmdLine.size())
|
||||||
|
{
|
||||||
|
m_cmdLine[rank] = value;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// should never happen
|
||||||
|
assert(false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
float COldObject::GetCmdLine(int rank)
|
float COldObject::GetCmdLine(unsigned int rank)
|
||||||
{
|
{
|
||||||
if ( rank < 0 || rank >= OBJECTMAXCMDLINE ) return 0.0f;
|
if ( rank >= m_cmdLine.size() ) return 0.0f;
|
||||||
return m_cmdLine[rank];
|
return m_cmdLine[rank];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,6 @@
|
||||||
// The father of all parts must always be the part number zero!
|
// The father of all parts must always be the part number zero!
|
||||||
const int OBJECTMAXPART = 40;
|
const int OBJECTMAXPART = 40;
|
||||||
const int OBJECTMAXDESELLIST = 10;
|
const int OBJECTMAXDESELLIST = 10;
|
||||||
const int OBJECTMAXCMDLINE = 20;
|
|
||||||
|
|
||||||
struct ObjectPart
|
struct ObjectPart
|
||||||
{
|
{
|
||||||
|
@ -168,8 +167,8 @@ public:
|
||||||
CObject* GetTransporter() override;
|
CObject* GetTransporter() override;
|
||||||
void SetTransporterPart(int part) override;
|
void SetTransporterPart(int part) override;
|
||||||
|
|
||||||
bool SetCmdLine(int rank, float value) override;
|
void SetCmdLine(unsigned int rank, float value) override;
|
||||||
float GetCmdLine(int rank) override;
|
float GetCmdLine(unsigned int rank) override;
|
||||||
|
|
||||||
Math::Matrix* GetRotateMatrix(int part) override;
|
Math::Matrix* GetRotateMatrix(int part) override;
|
||||||
Math::Matrix* GetWorldMatrix(int part) override;
|
Math::Matrix* GetWorldMatrix(int part) override;
|
||||||
|
@ -407,5 +406,5 @@ protected:
|
||||||
|
|
||||||
float m_infoReturn;
|
float m_infoReturn;
|
||||||
|
|
||||||
float m_cmdLine[OBJECTMAXCMDLINE];
|
std::vector<float> m_cmdLine;
|
||||||
};
|
};
|
||||||
|
|
|
@ -165,8 +165,8 @@ public:
|
||||||
virtual CObject* GetTransporter() = 0;
|
virtual CObject* GetTransporter() = 0;
|
||||||
virtual void SetTransporterPart(int part) = 0;
|
virtual void SetTransporterPart(int part) = 0;
|
||||||
|
|
||||||
virtual bool SetCmdLine(int rank, float value) = 0;
|
virtual void SetCmdLine(unsigned int rank, float value) = 0;
|
||||||
virtual float GetCmdLine(int rank) = 0;
|
virtual float GetCmdLine(unsigned int rank) = 0;
|
||||||
|
|
||||||
virtual Math::Matrix* GetRotateMatrix(int part) = 0;
|
virtual Math::Matrix* GetRotateMatrix(int part) = 0;
|
||||||
virtual Math::Matrix* GetWorldMatrix(int part) = 0;
|
virtual Math::Matrix* GetWorldMatrix(int part) = 0;
|
||||||
|
|
|
@ -3558,7 +3558,7 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject)
|
||||||
if (line->GetParam("cmdline")->IsDefined())
|
if (line->GetParam("cmdline")->IsDefined())
|
||||||
{
|
{
|
||||||
const auto& 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 < cmdline.size(); i++)
|
||||||
{
|
{
|
||||||
obj->SetCmdLine(i, cmdline[i]->AsFloat());
|
obj->SetCmdLine(i, cmdline[i]->AsFloat());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue