17
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-10-29 06:57:29 +01:00

refactor(physics): read vehicle definitions from text as well as files

TMoverParameters::LoadFIZ(path) opens the file and hands the parser over
to LoadFIZ_Parse(), which holds what LoadFIZ() did with it before. The
new LoadFIZ_Text() reads the same format from a string, so a definition
can be made up in memory, e.g. by a unit test. No change in behaviour for
files.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
jerrrrycho
2026-10-14 16:36:39 +02:00
parent fac4eb0547
commit 02bb352caf
2 changed files with 35 additions and 17 deletions

View File

@@ -9559,6 +9559,37 @@ bool TMoverParameters::LoadFIZ(std::string const &chkpath)
chkPath = chkpath; // assign class path for reloading
ConversionError = 666;
std::string file = TypeName + ".fiz";
WriteLog("LOAD FIZ FROM " + file);
/*
std::ifstream in(file);
if (!in.is_open())
{
WriteLog("E8 - FIZ FILE NOT EXIST.");
return false;
}
*/
cParser fizparser(file, cParser::buffer_FILE, chkpath);
if (false == fizparser.ok())
{
WriteLog("E8 - FIZ FILE NOT EXIST.");
return false;
}
return LoadFIZ_Parse(fizparser);
}
// reads the vehicle definition from text in the .fiz format, e.g. one made up by a unit test
bool TMoverParameters::LoadFIZ_Text(std::string const &Text)
{
ConversionError = 666;
cParser fizparser(Text, cParser::buffer_TEXT);
return LoadFIZ_Parse(fizparser);
}
bool TMoverParameters::LoadFIZ_Parse(cParser &fizparser)
{
LISTLINE = 0;
startBPT = false;
startMPT = false;
@@ -9577,23 +9608,6 @@ bool TMoverParameters::LoadFIZ(std::string const &chkpath)
startDimmerList = false;
startLIGHTSLIST = false;
startCOMPRESSORLIST = false;
std::string file = TypeName + ".fiz";
WriteLog("LOAD FIZ FROM " + file);
/*
std::ifstream in(file);
if (!in.is_open())
{
WriteLog("E8 - FIZ FILE NOT EXIST.");
return false;
}
*/
cParser fizparser(file, cParser::buffer_FILE, chkpath);
if (false == fizparser.ok())
{
WriteLog("E8 - FIZ FILE NOT EXIST.");
return false;
}
ConversionError = 0;