mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-07-22 01:19:19 +02:00
Improved scenery loading from SBT
When found SBT file, ignores "*_ter.scm" files
This commit is contained in:
@@ -72,11 +72,12 @@ struct global_settings {
|
|||||||
int iConvertModels{ 0 }; // tworzenie plików binarnych
|
int iConvertModels{ 0 }; // tworzenie plików binarnych
|
||||||
int iConvertIndexRange{ 1000 }; // range of duplicate vertex scan
|
int iConvertIndexRange{ 1000 }; // range of duplicate vertex scan
|
||||||
bool file_binary_terrain{ true }; // enable binary terrain (de)serialization
|
bool file_binary_terrain{ true }; // enable binary terrain (de)serialization
|
||||||
|
bool file_binary_terrain_state{true};
|
||||||
// logs
|
// logs
|
||||||
int iWriteLogEnabled{ 3 }; // maska bitowa: 1-zapis do pliku, 2-okienko, 4-nazwy torów
|
int iWriteLogEnabled{ 3 }; // maska bitowa: 1-zapis do pliku, 2-okienko, 4-nazwy torów
|
||||||
bool MultipleLogs{ false };
|
bool MultipleLogs{ false };
|
||||||
unsigned int DisabledLogTypes{ 0 };
|
unsigned int DisabledLogTypes{ 0 };
|
||||||
bool ParserLogIncludes{ false };
|
bool ParserLogIncludes{ true };
|
||||||
// simulation
|
// simulation
|
||||||
bool RealisticControlMode{ false }; // controls ability to steer the vehicle from outside views
|
bool RealisticControlMode{ false }; // controls ability to steer the vehicle from outside views
|
||||||
bool bEnableTraction{ true };
|
bool bEnableTraction{ true };
|
||||||
|
|||||||
86
parser.cpp
86
parser.cpp
@@ -247,17 +247,41 @@ std::string cParser::readToken( bool ToLower, const char *Break ) {
|
|||||||
if( expandIncludes && token == "include" ) {
|
if( expandIncludes && token == "include" ) {
|
||||||
std::string includefile = allowRandomIncludes ? deserialize_random_set(*this) : readToken(ToLower); // nazwa pliku
|
std::string includefile = allowRandomIncludes ? deserialize_random_set(*this) : readToken(ToLower); // nazwa pliku
|
||||||
replace_slashes(includefile);
|
replace_slashes(includefile);
|
||||||
if( ( true == LoadTraction )
|
if ((true == LoadTraction) ||
|
||||||
|| ( ( false == contains( includefile, "tr/" ) )
|
((false == contains(includefile, "tr/")) && (false == contains(includefile, "tra/"))))
|
||||||
&& ( false == contains( includefile, "tra/" ) ) ) ) {
|
{
|
||||||
if (Global.ParserLogIncludes)
|
if (false == contains(includefile, "_ter.scm"))
|
||||||
WriteLog("including: " + includefile);
|
{
|
||||||
|
if (Global.ParserLogIncludes)
|
||||||
|
WriteLog("including: " + includefile);
|
||||||
mIncludeParser = std::make_shared<cParser>( includefile, buffer_FILE, mPath, LoadTraction, readParameters( *this ) );
|
mIncludeParser = std::make_shared<cParser>( includefile, buffer_FILE, mPath, LoadTraction, readParameters( *this ) );
|
||||||
mIncludeParser->allowRandomIncludes = allowRandomIncludes;
|
mIncludeParser->allowRandomIncludes = allowRandomIncludes;
|
||||||
mIncludeParser->autoclear( m_autoclear );
|
mIncludeParser->autoclear( m_autoclear );
|
||||||
if( mIncludeParser->mSize <= 0 ) {
|
if( mIncludeParser->mSize <= 0 ) {
|
||||||
ErrorLog( "Bad include: can't open file \"" + includefile + "\"" );
|
ErrorLog( "Bad include: can't open file \"" + includefile + "\"" );
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if(true == Global.file_binary_terrain_state)
|
||||||
|
{
|
||||||
|
WriteLog("SBT found, ignoring: " + includefile);
|
||||||
|
readParameters(*this);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (Global.ParserLogIncludes)
|
||||||
|
WriteLog("including terrain: " + includefile);
|
||||||
|
mIncludeParser = std::make_shared<cParser>(includefile, buffer_FILE, mPath,
|
||||||
|
LoadTraction, readParameters(*this));
|
||||||
|
mIncludeParser->allowRandomIncludes = allowRandomIncludes;
|
||||||
|
mIncludeParser->autoclear(m_autoclear);
|
||||||
|
if (mIncludeParser->mSize <= 0)
|
||||||
|
{
|
||||||
|
ErrorLog("Bad include: can't open file \"" + includefile + "\"");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
while( token != "end" ) {
|
while( token != "end" ) {
|
||||||
@@ -272,18 +296,46 @@ std::string cParser::readToken( bool ToLower, const char *Break ) {
|
|||||||
includeparser.allowRandomIncludes = allowRandomIncludes;
|
includeparser.allowRandomIncludes = allowRandomIncludes;
|
||||||
std::string includefile = allowRandomIncludes ? deserialize_random_set( includeparser ) : includeparser.readToken( ToLower ); // nazwa pliku
|
std::string includefile = allowRandomIncludes ? deserialize_random_set( includeparser ) : includeparser.readToken( ToLower ); // nazwa pliku
|
||||||
replace_slashes(includefile);
|
replace_slashes(includefile);
|
||||||
if( ( true == LoadTraction )
|
if ((true == LoadTraction) ||
|
||||||
|| ( ( false == contains( includefile, "tr/" ) )
|
((false == contains(includefile, "tr/")) && (false == contains(includefile, "tra/"))))
|
||||||
&& ( false == contains( includefile, "tra/" ) ) ) ) {
|
{
|
||||||
if (Global.ParserLogIncludes)
|
if (false == contains(includefile, "_ter.scm"))
|
||||||
WriteLog("including: " + includefile);
|
{
|
||||||
mIncludeParser = std::make_shared<cParser>( includefile, buffer_FILE, mPath, LoadTraction, readParameters( includeparser ) );
|
if (Global.ParserLogIncludes)
|
||||||
mIncludeParser->allowRandomIncludes = allowRandomIncludes;
|
WriteLog("including: " + includefile);
|
||||||
mIncludeParser->autoclear( m_autoclear );
|
mIncludeParser = std::make_shared<cParser>(
|
||||||
if( mIncludeParser->mSize <= 0 ) {
|
includefile, buffer_FILE, mPath, LoadTraction, readParameters(includeparser));
|
||||||
ErrorLog( "Bad include: can't open file \"" + includefile + "\"" );
|
mIncludeParser->allowRandomIncludes = allowRandomIncludes;
|
||||||
}
|
mIncludeParser->autoclear(m_autoclear);
|
||||||
}
|
if (mIncludeParser->mSize <= 0)
|
||||||
|
{
|
||||||
|
ErrorLog("Bad include: can't open file \"" + includefile + "\"");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (true == Global.file_binary_terrain_state)
|
||||||
|
{
|
||||||
|
WriteLog("SBT found, ignoring: " + includefile);
|
||||||
|
readParameters(includeparser);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (Global.ParserLogIncludes)
|
||||||
|
WriteLog("including terrain: " + includefile);
|
||||||
|
mIncludeParser =
|
||||||
|
std::make_shared<cParser>(includefile, buffer_FILE, mPath, LoadTraction,
|
||||||
|
readParameters(includeparser));
|
||||||
|
mIncludeParser->allowRandomIncludes = allowRandomIncludes;
|
||||||
|
mIncludeParser->autoclear(m_autoclear);
|
||||||
|
if (mIncludeParser->mSize <= 0)
|
||||||
|
{
|
||||||
|
ErrorLog("Bad include: can't open file \"" + includefile + "\"");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
token = readToken( ToLower, Break );
|
token = readToken( ToLower, Break );
|
||||||
}
|
}
|
||||||
// all done
|
// all done
|
||||||
|
|||||||
@@ -1159,6 +1159,7 @@ basic_region::deserialize( std::string const &Scenariofile ) {
|
|||||||
filename += EU07_FILEEXTENSION_REGION;
|
filename += EU07_FILEEXTENSION_REGION;
|
||||||
|
|
||||||
if( false == FileExists( filename ) ) {
|
if( false == FileExists( filename ) ) {
|
||||||
|
Global.file_binary_terrain_state = false;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// region file version 1
|
// region file version 1
|
||||||
|
|||||||
@@ -55,6 +55,16 @@ state_serializer::deserialize_begin( std::string const &Scenariofile ) {
|
|||||||
state->scratchpad.binary.terrain = Region->is_scene( Scenariofile ) ;
|
state->scratchpad.binary.terrain = Region->is_scene( Scenariofile ) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (false != state->scratchpad.binary.terrain)
|
||||||
|
{
|
||||||
|
Global.file_binary_terrain_state = true;
|
||||||
|
WriteLog("SBT present");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Global.file_binary_terrain_state = false;
|
||||||
|
WriteLog("SBT absent");
|
||||||
|
}
|
||||||
scene::Groups.create();
|
scene::Groups.create();
|
||||||
|
|
||||||
if( false == state->input.ok() )
|
if( false == state->input.ok() )
|
||||||
|
|||||||
Reference in New Issue
Block a user