mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-03-22 15:05:03 +01:00
Merge branch 'milek-dev' into gfx-work
This commit is contained in:
42
scene.cpp
42
scene.cpp
@@ -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() ) );
|
||||
}
|
||||
@@ -1004,6 +1005,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 {
|
||||
@@ -1078,10 +1110,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 *§ion { 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;
|
||||
|
||||
Reference in New Issue
Block a user