18
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-11-20 15:04:58 +01:00

fix(files): data named in another case is found on Linux, folders included

The parser and the loaders lowercase every name they read, while the data
made on Windows has files and folders named in any case (scenery/Braniewo,
textures/siec_trakcyjna_ph/.../STS_*.tga, sounds/sip/Gorki.wav). FileCased
matched the file name only, so a folder in another case wasn't found.

- FileCased walks every part of the path on Linux, the folder listings kept
  by their lowercase and read again once the folder changed; Windows as it was
- FileExists finds the file in any case on Linux, and the variant with names
  and extensions gives back the name as it's on the disk, so textures,
  materials, sounds, station announcements and scripts open that name
- models, sound captions, timetables and nodebank previews open the file
  as it's named on the disk; the texture format is told by the extension in
  any case
This commit is contained in:
maj00r
2026-11-13 15:41:40 +01:00
parent 0371581049
commit d0a3694657
8 changed files with 157 additions and 26 deletions

View File

@@ -1702,24 +1702,27 @@ bool TModel3d::LoadFromFile(std::string const &FileName, bool dynamic)
m_filename = name;
asBinary = name + ".e3d";
// the files as they're named on the disk, the name given is in lowercase
auto const textfile{FileCased(name + ".t3d")};
auto const binaryfile{FileCased(asBinary)};
// Hirek: Jesli mamy ustawione priorityLoadText3D na yes to wpierw ladujemy t3d
if (Global.priorityLoadText3D && FileExists(name + ".t3d"))
if (Global.priorityLoadText3D && (false == textfile.empty()))
{
WriteLog("Forced loading text model \"" + name + ".t3d\"");
LoadFromTextFile(name + ".t3d", dynamic);
WriteLog("Forced loading text model \"" + textfile + "\"");
LoadFromTextFile(textfile, dynamic);
if (!dynamic)
Init();
}
else if (FileExists(asBinary))
else if (false == binaryfile.empty())
{
LoadFromBinFile(asBinary, dynamic);
LoadFromBinFile(binaryfile, dynamic);
asBinary = "";
Init();
}
else if (FileExists(name + ".t3d"))
else if (false == textfile.empty())
{
LoadFromTextFile(name + ".t3d", dynamic);
LoadFromTextFile(textfile, dynamic);
if (!dynamic)
Init();
}

View File

@@ -549,13 +549,15 @@ opengl_texture::load() {
data_state = resource_state::loading;
if( type == ".dds" ) { load_DDS(); }
else if( type == ".tga" ) { load_TGA(); }
else if( type == ".png" ) { load_STBI(); }
else if( type == ".ktx" ) { load_KTX(); }
else if( type == ".bmp" ) { load_STBI(); }
else if( type == ".jpg" ) { load_STBI(); }
else if( type == ".tex" ) { load_TEX(); }
// the extension as the file has it on the disk, in any case
auto const format { ToLower( type ) };
if( format == ".dds" ) { load_DDS(); }
else if( format == ".tga" ) { load_TGA(); }
else if( format == ".png" ) { load_STBI(); }
else if( format == ".ktx" ) { load_KTX(); }
else if( format == ".bmp" ) { load_STBI(); }
else if( format == ".jpg" ) { load_STBI(); }
else if( format == ".tex" ) { load_TEX(); }
else { goto fail; }
}