@@ -73,13 +73,13 @@ public Texture2D Get(string path, Texture2D defaultTexture, bool required = fals
7373
7474 if ( string . IsNullOrEmpty ( path ) ) return defaultTexture ;
7575
76- path = path . ToLowerInvariant ( ) ;
77- if ( Textures . ContainsKey ( path ) ) return Textures [ path ] ;
76+ var textureKey = path . ToLowerInvariant ( ) ;
77+ if ( Textures . ContainsKey ( textureKey ) ) return Textures [ textureKey ] ;
7878
7979 // DO NOT add additional formats here without explicit approval
8080 // - DDS is used for newer, Open Rails-specific content
8181 // - ACE is used for older, MSTS-specific content
82- switch ( Path . GetExtension ( path ) )
82+ switch ( Path . GetExtension ( textureKey ) )
8383 {
8484 case ".dds" :
8585 case ".ace" :
@@ -93,11 +93,11 @@ public Texture2D Get(string path, Texture2D defaultTexture, bool required = fals
9393 if ( File . Exists ( dds ) )
9494 {
9595 DDSLib . DDSFromFile ( dds , GraphicsDevice , true , out Texture2D texture ) ;
96- return Textures [ path ] = texture ;
96+ return Textures [ textureKey ] = texture ;
9797 }
9898 if ( File . Exists ( ace ) )
9999 {
100- return Textures [ path ] = Formats . Msts . AceFile . Texture2DFromFile ( GraphicsDevice , ace ) ;
100+ return Textures [ textureKey ] = Formats . Msts . AceFile . Texture2DFromFile ( GraphicsDevice , ace ) ;
101101 }
102102 // When a texture is not found, and it is in a selector directory (e.g. "Snow"), we
103103 // go up a level and try again. This repeats a fixed number of times, or until we run
@@ -292,10 +292,7 @@ public SharedMaterialManager(Viewer viewer)
292292
293293 public Material Load ( string materialName , string textureName = null , int options = 0 , float mipMapBias = 0f , Effect effect = null )
294294 {
295- if ( textureName != null )
296- textureName = textureName . ToLower ( ) ;
297-
298- var materialKey = ( materialName , textureName , options , mipMapBias , effect ) ;
295+ var materialKey = ( materialName , textureName ? . ToLowerInvariant ( ) , options , mipMapBias , effect ) ;
299296 if ( ! Materials . ContainsKey ( materialKey ) )
300297 {
301298 switch ( materialName )
@@ -735,7 +732,7 @@ public SceneryMaterial(Viewer viewer, string texturePath, SceneryMaterialOptions
735732 {
736733 var nightTexturePath = Helpers . GetNightTextureFile ( Viewer . Simulator , texturePath ) ;
737734 if ( ! String . IsNullOrEmpty ( nightTexturePath ) )
738- NightTexture = Viewer . TextureManager . Get ( nightTexturePath . ToLower ( ) ) ;
735+ NightTexture = Viewer . TextureManager . Get ( nightTexturePath ) ;
739736 Texture = Viewer . TextureManager . Get ( texturePath , true ) ;
740737 }
741738 else if ( ( Options & SceneryMaterialOptions . NightTexture ) != 0 && viewer . IsDaytime )
@@ -748,7 +745,7 @@ public SceneryMaterial(Viewer viewer, string texturePath, SceneryMaterialOptions
748745 {
749746 var nightTexturePath = Helpers . GetNightTextureFile ( Viewer . Simulator , texturePath ) ;
750747 if ( ! String . IsNullOrEmpty ( nightTexturePath ) )
751- NightTexture = Viewer . TextureManager . Get ( nightTexturePath . ToLower ( ) ) ;
748+ NightTexture = Viewer . TextureManager . Get ( nightTexturePath ) ;
752749 if ( NightTexture != SharedMaterialManager . MissingTexture )
753750 {
754751 viewer . DayTexturesNotLoaded = true ;
@@ -775,7 +772,7 @@ public bool LoadNightTexture()
775772 var nightTexturePath = Helpers . GetNightTextureFile ( Viewer . Simulator , TexturePath ) ;
776773 if ( ! String . IsNullOrEmpty ( nightTexturePath ) )
777774 {
778- NightTexture = Viewer . TextureManager . Get ( nightTexturePath . ToLower ( ) ) ;
775+ NightTexture = Viewer . TextureManager . Get ( nightTexturePath ) ;
779776 oneMore = true ;
780777 }
781778 }
@@ -787,7 +784,7 @@ public bool LoadDayTexture()
787784 bool oneMore = false ;
788785 if ( Texture == SharedMaterialManager . MissingTexture && ! String . IsNullOrEmpty ( TexturePath ) )
789786 {
790- Texture = Viewer . TextureManager . Get ( TexturePath . ToLower ( ) ) ;
787+ Texture = Viewer . TextureManager . Get ( TexturePath ) ;
791788 oneMore = true ;
792789 }
793790 return oneMore ;
0 commit comments