16
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-07-18 03:09:18 +02:00

Merge branch 'tmj-dev' into milek-dev

This commit is contained in:
milek7
2018-10-01 21:00:27 +02:00
47 changed files with 1674 additions and 972 deletions

View File

@@ -233,7 +233,8 @@ basic_cell::deserialize( std::istream &Input ) {
}
// cell activation flag
m_active = (
( false == m_shapesopaque.empty() )
( true == m_active )
|| ( false == m_shapesopaque.empty() )
|| ( false == m_shapestranslucent.empty() )
|| ( false == m_lines.empty() ) );
}
@@ -986,6 +987,37 @@ basic_region::update_traction( TDynamicObject *Vehicle, int const Pantographinde
}
}
// checks whether specified file is a valid region data file
bool
basic_region::is_scene( std::string const &Scenariofile ) const {
auto filename { Scenariofile };
while( filename[ 0 ] == '$' ) {
// trim leading $ char rainsted utility may add to the base name for modified .scn files
filename.erase( 0, 1 );
}
erase_extension( filename );
filename = Global.asCurrentSceneryPath + filename;
filename += EU07_FILEEXTENSION_REGION;
if( false == FileExists( filename ) ) {
return false;
}
// file type and version check
std::ifstream input( filename, std::ios::binary );
uint32_t headermain{ sn_utils::ld_uint32( input ) };
uint32_t headertype{ sn_utils::ld_uint32( input ) };
if( ( headermain != EU07_FILEHEADER
|| ( headertype != EU07_FILEVERSION_REGION ) ) ) {
// wrong file type
return false;
}
return true;
}
// stores content of the class in file with specified name
void
basic_region::serialize( std::string const &Scenariofile ) const {
@@ -1060,10 +1092,12 @@ basic_region::deserialize( std::string const &Scenariofile ) {
auto sectioncount { sn_utils::ld_uint32( input ) };
while( sectioncount-- ) {
// section index, followed by section data size, followed by section data
auto *&section { m_sections[ sn_utils::ld_uint32( input ) ] };
auto const sectionindex { sn_utils::ld_uint32( input ) };
auto const sectionsize { sn_utils::ld_uint32( input ) };
section = new basic_section();
section->deserialize( input );
if( m_sections[ sectionindex ] == nullptr ) {
m_sections[ sectionindex ] = new basic_section();
}
m_sections[ sectionindex ]->deserialize( input );
}
return true;