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

build 180909. scenario time override, support for random texture sets in .mat files, minor bug fixes

This commit is contained in:
tmj-fstate
2018-09-09 21:25:09 +02:00
parent 397628242c
commit 251a31a705
14 changed files with 107 additions and 93 deletions

View File

@@ -33,13 +33,10 @@ opengl_material::deserialize( cParser &Input, bool const Loadnow ) {
// imports member data pair from the config file
bool
opengl_material::deserialize_mapping( cParser &Input, int const Priority, bool const Loadnow ) {
// token can be a key or block end
std::string const key { Input.getToken<std::string>( true, "\n\r\t ;[]" ) };
if( ( true == key.empty() ) || ( key == "}" ) ) { return false; }
// NOTE: comma can be part of legacy file names, so we don't treat it as a separator here
auto const value { Input.getToken<std::string>( true, "\n\r\t ;" ) };
std::string const key { Input.getToken<std::string>( true, "\n\r\t ;[]" ) };
// key can be an actual key or block end
if( ( true == key.empty() ) || ( key == "}" ) ) { return false; }
if( Priority != -1 ) {
// regular attribute processing mode
@@ -60,7 +57,7 @@ opengl_material::deserialize_mapping( cParser &Input, int const Priority, bool c
|| ( key == "texture_diffuse:" ) ) {
if( ( texture1 == null_handle )
|| ( Priority > priority1 ) ) {
texture1 = GfxRenderer.Fetch_Texture( value, Loadnow );
texture1 = GfxRenderer.Fetch_Texture( deserialize_random_set( Input ), Loadnow );
priority1 = Priority;
}
}
@@ -68,20 +65,24 @@ opengl_material::deserialize_mapping( cParser &Input, int const Priority, bool c
|| ( key == "texture_normalmap:" ) ) {
if( ( texture2 == null_handle )
|| ( Priority > priority2 ) ) {
texture2 = GfxRenderer.Fetch_Texture( value, Loadnow );
texture2 = GfxRenderer.Fetch_Texture( deserialize_random_set( Input ), Loadnow );
priority2 = Priority;
}
}
else if( value == "{" ) {
// unrecognized or ignored token, but comes with attribute block and potential further nesting
// go through it and discard the content
while( true == deserialize_mapping( Input, -1, Loadnow ) ) {
; // all work is done in the header
else {
auto const value { Input.getToken<std::string>( true, "\n\r\t ;" ) };
if( value == "{" ) {
// unrecognized or ignored token, but comes with attribute block and potential further nesting
// go through it and discard the content
while( true == deserialize_mapping( Input, -1, Loadnow ) ) {
; // all work is done in the header
}
}
}
}
else {
// discard mode; ignores all retrieved tokens
auto const value { Input.getToken<std::string>( true, "\n\r\t ;" ) };
if( value == "{" ) {
// ignored tokens can come with their own blocks, ignore these recursively
// go through it and discard the content