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

refactor: create paths namespace instead of global variables

This commit is contained in:
jerrrrycho
2026-03-15 11:55:30 +01:00
parent 383788b30a
commit 9f43dca48b
20 changed files with 112 additions and 100 deletions

View File

@@ -97,17 +97,17 @@ void itemproperties_panel::update(scene::basic_node const *Node)
// 3d shape // 3d shape
auto modelfile{((subnode->pModel != nullptr) ? subnode->pModel->NameGet() : "(none)")}; auto modelfile{((subnode->pModel != nullptr) ? subnode->pModel->NameGet() : "(none)")};
if (modelfile.find(szModelPath) == 0) if (modelfile.find(paths::models) == 0)
{ {
// don't include 'models/' in the path // don't include 'models/' in the path
modelfile.erase(0, std::string{szModelPath}.size()); modelfile.erase(0, std::string{paths::models}.size());
} }
// texture // texture
auto texturefile{((subnode->Material()->replacable_skins[1] != null_handle) ? GfxRenderer->Material(subnode->Material()->replacable_skins[1])->GetName() : "(none)")}; auto texturefile{((subnode->Material()->replacable_skins[1] != null_handle) ? GfxRenderer->Material(subnode->Material()->replacable_skins[1])->GetName() : "(none)")};
if (texturefile.find(szTexturePath) == 0) if (texturefile.find(paths::textures) == 0)
{ {
// don't include 'textures/' in the path // don't include 'textures/' in the path
texturefile.erase(0, std::string{szTexturePath}.size()); texturefile.erase(0, std::string{paths::textures}.size());
} }
text_lines.emplace_back("mesh: " + modelfile, Global.UITextColor); text_lines.emplace_back("mesh: " + modelfile, Global.UITextColor);
text_lines.emplace_back("skin: " + texturefile, Global.UITextColor); text_lines.emplace_back("skin: " + texturefile, Global.UITextColor);
@@ -131,14 +131,14 @@ void itemproperties_panel::update(scene::basic_node const *Node)
text_lines.emplace_back(textline, Global.UITextColor); text_lines.emplace_back(textline, Global.UITextColor);
// textures // textures
auto texturefile{((subnode->m_material1 != null_handle) ? GfxRenderer->Material(subnode->m_material1)->GetName() : "(none)")}; auto texturefile{((subnode->m_material1 != null_handle) ? GfxRenderer->Material(subnode->m_material1)->GetName() : "(none)")};
if (texturefile.find(szTexturePath) == 0) if (texturefile.find(paths::textures) == 0)
{ {
texturefile.erase(0, std::string{szTexturePath}.size()); texturefile.erase(0, std::string{paths::textures}.size());
} }
auto texturefile2{((subnode->m_material2 != null_handle) ? GfxRenderer->Material(subnode->m_material2)->GetName() : "(none)")}; auto texturefile2{((subnode->m_material2 != null_handle) ? GfxRenderer->Material(subnode->m_material2)->GetName() : "(none)")};
if (texturefile2.find(szTexturePath) == 0) if (texturefile2.find(paths::textures) == 0)
{ {
texturefile2.erase(0, std::string{szTexturePath}.size()); texturefile2.erase(0, std::string{paths::textures}.size());
} }
textline = "skins:\n " + texturefile + "\n " + texturefile2; textline = "skins:\n " + texturefile + "\n " + texturefile2;
text_lines.emplace_back(textline, Global.UITextColor); text_lines.emplace_back(textline, Global.UITextColor);

View File

@@ -135,11 +135,11 @@ buffer_manager::create( std::string const &Filename ) {
} }
} }
// if dynamic-specific and/or direct lookups find nothing, try the default sound folder // if dynamic-specific and/or direct lookups find nothing, try the default sound folder
lookup = find_buffer( szSoundPath + filename ); lookup = find_buffer( paths::sounds + filename );
if( lookup != null_handle ) { if( lookup != null_handle ) {
return lookup; return lookup;
} }
filelookup = find_file( szSoundPath + filename ); filelookup = find_file( paths::sounds + filename );
if( false == filelookup.empty() ) { if( false == filelookup.empty() ) {
return emplace( filelookup ); return emplace( filelookup );
} }

View File

@@ -319,9 +319,9 @@ sound_source::export_as_text( std::ostream &Output ) const {
<< m_offset.z << ' '; << m_offset.z << ' ';
// sound data // sound data
auto soundfile { audio::renderer.buffer( sound( sound_id::main ).buffer ).name }; auto soundfile { audio::renderer.buffer( sound( sound_id::main ).buffer ).name };
if( soundfile.find( szSoundPath ) == 0 ) { if( soundfile.find( paths::sounds ) == 0 ) {
// don't include 'sounds/' in the path // don't include 'sounds/' in the path
soundfile.erase( 0, std::string{ szSoundPath }.size() ); soundfile.erase( 0, std::string{ paths::sounds }.size() );
} }
Output Output
<< soundfile << ' '; << soundfile << ' ';

View File

@@ -314,7 +314,7 @@ size_t NvTextureManager::FetchTexture(std::string path, int format_hint,
{ {
const std::array<std::string, 3> filenames{ const std::array<std::string, 3> filenames{
Global.asCurrentTexturePath + path, path, szTexturePath + path}; Global.asCurrentTexturePath + path, path, paths::textures + path};
for (const auto &filename : filenames) { for (const auto &filename : filenames) {
if (auto found = m_texture_map.find(filename); if (auto found = m_texture_map.find(filename);
found != m_texture_map.end()) found != m_texture_map.end())

View File

@@ -675,9 +675,9 @@ TAnimModel::export_as_text_( std::ostream &Output ) const {
pModel ? pModel ?
pModel->NameGet() + ".t3d" : // rainsted requires model file names to include an extension pModel->NameGet() + ".t3d" : // rainsted requires model file names to include an extension
"none" ) }; "none" ) };
if( modelfile.find( szModelPath ) == 0 ) { if( modelfile.find( paths::models ) == 0 ) {
// don't include 'models/' in the path // don't include 'models/' in the path
modelfile.erase( 0, std::string{ szModelPath }.size() ); modelfile.erase( 0, std::string{ paths::models }.size() );
} }
Output << modelfile << ' '; Output << modelfile << ' ';
// texture // texture
@@ -685,9 +685,9 @@ TAnimModel::export_as_text_( std::ostream &Output ) const {
m_materialdata.replacable_skins[ 1 ] != null_handle ? m_materialdata.replacable_skins[ 1 ] != null_handle ?
GfxRenderer->Material( m_materialdata.replacable_skins[ 1 ] )->GetName() : GfxRenderer->Material( m_materialdata.replacable_skins[ 1 ] )->GetName() :
"none" ) }; "none" ) };
if( texturefile.find( szTexturePath ) == 0 ) { if( texturefile.find( paths::textures ) == 0 ) {
// don't include 'textures/' in the path // don't include 'textures/' in the path
texturefile.erase( 0, std::string{ szTexturePath }.size() ); texturefile.erase( 0, std::string{ paths::textures }.size() );
} }
if( contains( texturefile, ' ' ) ) { if( contains( texturefile, ' ' ) ) {
Output << "\"" << texturefile << "\"" << ' '; Output << "\"" << texturefile << "\"" << ' ';

View File

@@ -125,7 +125,7 @@ TModelsManager::find_in_databank( std::string const &Name ) {
std::vector<std::string> filenames { std::vector<std::string> filenames {
Name, Name,
szModelPath + Name }; paths::models + Name };
for( auto const &filename : filenames ) { for( auto const &filename : filenames ) {
auto const lookup { m_modelsmap.find( filename ) }; auto const lookup { m_modelsmap.find( filename ) };
@@ -146,7 +146,7 @@ TModelsManager::find_on_disk( std::string const &Name ) {
auto lookup = ( auto lookup = (
FileExists( Name + extension ) ? Name : FileExists( Name + extension ) ? Name :
FileExists( szModelPath + Name + extension ) ? szModelPath + Name : FileExists( paths::models + Name + extension ) ? paths::models + Name :
"" ); "" );
if( false == lookup.empty() ) { if( false == lookup.empty() ) {
return lookup; return lookup;

View File

@@ -1467,7 +1467,7 @@ texture_manager::find_in_databank( std::string const &Texturename ) const {
std::vector<std::string> const filenames { std::vector<std::string> const filenames {
Global.asCurrentTexturePath + Texturename, Global.asCurrentTexturePath + Texturename,
Texturename, Texturename,
szTexturePath + Texturename }; paths::textures + Texturename };
for( auto const &filename : filenames ) { for( auto const &filename : filenames ) {
auto const lookup { m_texturemappings.find( filename ) }; auto const lookup { m_texturemappings.find( filename ) };
@@ -1486,7 +1486,7 @@ texture_manager::find_on_disk( std::string const &Texturename ) {
std::vector<std::string> const filenames { std::vector<std::string> const filenames {
Global.asCurrentTexturePath + Texturename, Global.asCurrentTexturePath + Texturename,
Texturename, Texturename,
szTexturePath + Texturename }; paths::textures + Texturename };
auto lookup = auto lookup =
FileExists( FileExists(

View File

@@ -582,7 +582,7 @@ material_manager::find_in_databank( std::string const &Materialname ) const {
std::vector<std::string> const filenames { std::vector<std::string> const filenames {
Global.asCurrentTexturePath + Materialname, Global.asCurrentTexturePath + Materialname,
Materialname, Materialname,
szTexturePath + Materialname }; paths::textures + Materialname };
for( auto const &filename : filenames ) { for( auto const &filename : filenames ) {
auto const lookup { m_materialmappings.find( filename ) }; auto const lookup { m_materialmappings.find( filename ) };
@@ -602,7 +602,7 @@ material_manager::find_on_disk( std::string const &Materialname ) {
auto const materialname { ToLower( Materialname ) }; auto const materialname { ToLower( Materialname ) };
return ( return (
FileExists( FileExists(
{ Global.asCurrentTexturePath + materialname, materialname, szTexturePath + materialname }, { Global.asCurrentTexturePath + materialname, materialname, paths::textures + materialname },
{ ".mat" } ) ); { ".mat" } ) );
} }

View File

@@ -15,7 +15,7 @@ http://mozilla.org/MPL/2.0/.
#include "model/material.h" #include "model/material.h"
#include "model/vertex.h" #include "model/vertex.h"
#include "rendering/geometrybank.h" #include "rendering/geometrybank.h"
#include "utils/uuid.hpp" #include "../utilities/uuid.hpp"
struct lighting_data { struct lighting_data {

View File

@@ -23,18 +23,25 @@ http://mozilla.org/MPL/2.0/.
#include "utilities/Timer.h" #include "utilities/Timer.h"
#include "vao.h" #include "vao.h"
void void global_settings::LoadIniFile(std::string asFileName)
global_settings::LoadIniFile(std::string asFileName) { {
// initialize season data in case the main config file doesn't // initialize season data in case the main config file doesn't
std::time_t timenow = std::time( 0 ); std::time_t timenow = std::time(nullptr);
std::tm *localtime = std::localtime( &timenow );
fMoveLight = localtime->tm_yday + 1; // numer bieżącego dnia w roku std::tm tm{};
#ifdef _WIN32
localtime_s(&tm, &timenow);
#else
localtime_r(&timenow, &tm);
#endif
fMoveLight = tm.tm_yday + 1; // numer bieżącego dnia w roku
simulation::Environment.compute_season(fMoveLight); simulation::Environment.compute_season(fMoveLight);
cParser parser(asFileName, cParser::buffer_FILE); cParser parser(asFileName, cParser::buffer_FILE);
ConfigParse(parser); ConfigParse(parser);
}; }
void void
global_settings::ConfigParse(cParser &Parser) { global_settings::ConfigParse(cParser &Parser) {

View File

@@ -65,7 +65,7 @@ struct global_settings {
int iPause{ 0 }; // globalna pauza ruchu: b0=start,b1=klawisz,b2=tło,b3=lagi,b4=wczytywanie int iPause{ 0 }; // globalna pauza ruchu: b0=start,b1=klawisz,b2=tło,b3=lagi,b4=wczytywanie
float AirTemperature{ 15.f }; float AirTemperature{ 15.f };
std::string asCurrentSceneryPath{ "scenery/" }; std::string asCurrentSceneryPath{ "scenery/" };
std::string asCurrentTexturePath{ szTexturePath }; std::string asCurrentTexturePath{ paths::textures };
std::string asCurrentDynamicPath; std::string asCurrentDynamicPath;
int CurrentMaxTextureSize{ 4096 }; int CurrentMaxTextureSize{ 4096 };
bool UpdateMaterials{ true }; bool UpdateMaterials{ true };

View File

@@ -158,55 +158,57 @@ void LogService()
} }
void WriteLog(const char *str, logtype const Type, bool isError) bool ShouldSkipLog(std::string_view str, logtype type)
{ {
if (!str || *str == '\0') return str.empty() ||
return; TestFlag(Global.DisabledLogTypes, static_cast<unsigned int>(type));
if (TestFlag(Global.DisabledLogTypes, static_cast<unsigned int>(Type)))
return;
// time calculation
auto now = std::chrono::steady_clock::now();
auto elapsed = now - Global.startTimestamp;
double seconds = std::chrono::duration_cast<std::chrono::duration<double>>(elapsed).count();
// time format
std::ostringstream oss;
oss << "[ " << std::fixed << std::setprecision(3) << seconds << " ] ";
// wyrownanie do np. 10 znaków długości + dwie tabulacje
std::ostringstream final;
final << std::setw(10) << oss.str() << "\t\t" << str;
logMutex.lock();
InfoStack.emplace_back(final.str(), isError);
logMutex.unlock();
} }
void ErrorLog(const char *str, logtype const Type) std::string FormatLogMessage(std::string_view str)
{ {
if (!str || *str == '\0') const auto now = std::chrono::steady_clock::now();
return; const auto elapsed = now - Global.startTimestamp;
if (TestFlag(Global.DisabledLogTypes, static_cast<unsigned int>(Type))) const double seconds = std::chrono::duration<double>(elapsed).count();
return std::format("[ {:8.3f} ]\t\t{}", seconds, str);
}
void WriteLog(std::string_view str, logtype type, bool isError)
{
if (ShouldSkipLog(str, type))
return; return;
// time calculation const auto message = FormatLogMessage(str);
auto now = std::chrono::steady_clock::now();
auto elapsed = now - Global.startTimestamp;
double seconds = std::chrono::duration_cast<std::chrono::duration<double>>(elapsed).count();
// time format std::lock_guard<std::mutex> lock(logMutex);
std::ostringstream oss; InfoStack.push_back({message, isError});
oss << "[ " << std::fixed << std::setprecision(3) << seconds << " ] "; }
// wyrownanie do np. 10 znaków długości + dwie tabulacje void ErrorLog(std::string_view str, logtype type)
std::ostringstream final; {
final << std::setw(10) << oss.str() << "\t\t" << str; if (ShouldSkipLog(str, type))
return;
logMutex.lock(); const auto message = FormatLogMessage(str);
ErrorStack.emplace_back(final.str());
logMutex.unlock(); std::lock_guard<std::mutex> lock(logMutex);
ErrorStack.push_back(message);
}
void WriteLog(const char* str, logtype type, bool isError)
{
if (str == nullptr || *str == '\0')
return;
WriteLog(std::string_view{str}, type, isError);
}
void ErrorLog(const char* str, logtype type)
{
if (str == nullptr || *str == '\0')
return;
ErrorLog(std::string_view{str}, type);
} }

View File

@@ -29,12 +29,15 @@ template <typename T> T sign(T x)
#define DegToRad(a) ((M_PI / 180.0) * (a)) //(a) w nawiasie, bo może być dodawaniem #define DegToRad(a) ((M_PI / 180.0) * (a)) //(a) w nawiasie, bo może być dodawaniem
#define RadToDeg(r) ((180.0 / M_PI) * (r)) #define RadToDeg(r) ((180.0 / M_PI) * (r))
#define szSceneryPath "scenery/" namespace paths
#define szTexturePath "textures/" {
#define szModelPath "models/" inline constexpr const char *scenery = "scenery/";
#define szDynamicPath "dynamic/" inline constexpr const char *textures = "textures/";
#define szSoundPath "sounds/" inline constexpr const char *models = "models/";
#define szDataPath "data/" inline constexpr const char *dynamic = "dynamic/";
inline constexpr const char *sounds = "sounds/";
inline constexpr const char *data = "data/";
}
#define MAKE_ID4(a, b, c, d) (((std::uint32_t)(d) << 24) | ((std::uint32_t)(c) << 16) | ((std::uint32_t)(b) << 8) | (std::uint32_t)(a)) #define MAKE_ID4(a, b, c, d) (((std::uint32_t)(d) << 24) | ((std::uint32_t)(c) << 16) | ((std::uint32_t)(b) << 8) | (std::uint32_t)(a))

View File

@@ -4541,7 +4541,7 @@ bool TController::PutCommand( std::string NewCommand, double NewValue1, double N
// NewCommand = Global.asCurrentSceneryPath + NewCommand; // NewCommand = Global.asCurrentSceneryPath + NewCommand;
auto lookup = auto lookup =
FileExists( FileExists(
{ Global.asCurrentSceneryPath + NewCommand, szSoundPath + NewCommand }, { Global.asCurrentSceneryPath + NewCommand, paths::sounds + NewCommand },
{ ".ogg", ".flac", ".wav" } ); { ".ogg", ".flac", ".wav" } );
if( false == lookup.first.empty() ) { if( false == lookup.first.empty() ) {
// wczytanie dźwięku odjazdu podawanego bezpośrenido // wczytanie dźwięku odjazdu podawanego bezpośrenido
@@ -4552,7 +4552,7 @@ bool TController::PutCommand( std::string NewCommand, double NewValue1, double N
NewCommand += "radio"; NewCommand += "radio";
lookup = lookup =
FileExists( FileExists(
{ Global.asCurrentSceneryPath + NewCommand, szSoundPath + NewCommand }, { Global.asCurrentSceneryPath + NewCommand, paths::sounds + NewCommand },
{ ".ogg", ".flac", ".wav" } ); { ".ogg", ".flac", ".wav" } );
if( false == lookup.first.empty() ) { if( false == lookup.first.empty() ) {
// wczytanie dźwięku odjazdu w wersji radiowej (słychać tylko w kabinie) // wczytanie dźwięku odjazdu w wersji radiowej (słychać tylko w kabinie)

View File

@@ -63,7 +63,7 @@ TextureTest( std::string const &Name ) {
auto const lookup { auto const lookup {
FileExists( FileExists(
{ Global.asCurrentTexturePath + Name, Name, szTexturePath + Name }, { Global.asCurrentTexturePath + Name, Name, paths::textures + Name },
{ ".mat", ".dds", ".tga", ".ktx", ".png", ".bmp", ".jpg", ".tex" } ) }; { ".mat", ".dds", ".tga", ".ktx", ".png", ".bmp", ".jpg", ".tex" } ) };
return ( lookup.first + lookup.second ); return ( lookup.first + lookup.second );
@@ -1982,7 +1982,7 @@ TDynamicObject::Init(std::string Name, // nazwa pojazdu, np. "EU07-424"
) )
{ // Ustawienie początkowe pojazdu { // Ustawienie początkowe pojazdu
iDirection = (Reversed ? 0 : 1); // Ra: 0, jeśli ma być wstawiony jako obrócony tyłem iDirection = (Reversed ? 0 : 1); // Ra: 0, jeśli ma być wstawiony jako obrócony tyłem
asBaseDir = szDynamicPath + BaseDir + "/"; // McZapkie-310302 asBaseDir = paths::dynamic + BaseDir + "/"; // McZapkie-310302
asName = Name; asName = Name;
std::string asAnimName; // zmienna robocza do wyszukiwania osi i wózków std::string asAnimName; // zmienna robocza do wyszukiwania osi i wózków
// Ra: zmieniamy znaczenie obsady na jednoliterowe, żeby dosadzić kierownika // Ra: zmieniamy znaczenie obsady na jednoliterowe, żeby dosadzić kierownika
@@ -3011,7 +3011,7 @@ void TDynamicObject::LoadUpdate() {
// update bindings between lowpoly sections and potential load chunks placed inside them // update bindings between lowpoly sections and potential load chunks placed inside them
update_load_sections(); update_load_sections();
// z powrotem defaultowa sciezka do tekstur // z powrotem defaultowa sciezka do tekstur
Global.asCurrentTexturePath = std::string( szTexturePath ); Global.asCurrentTexturePath = std::string( paths::textures );
} }
} }
@@ -5337,7 +5337,7 @@ void TDynamicObject::LoadMMediaFile( std::string const &TypeName, std::string co
if (ReplacableSkin != "none") { if (ReplacableSkin != "none") {
m_materialdata.assign( ReplacableSkin ); m_materialdata.assign( ReplacableSkin );
} }
Global.asCurrentTexturePath = szTexturePath; // z powrotem defaultowa sciezka do tekstur Global.asCurrentTexturePath = paths::textures; // z powrotem defaultowa sciezka do tekstur
do { do {
token = ""; token = "";
parser.getTokens(); parser >> token; parser.getTokens(); parser >> token;
@@ -6011,7 +6011,7 @@ void TDynamicObject::LoadMMediaFile( std::string const &TypeName, std::string co
mdLoad = LoadMMediaFile_mdload( MoverParameters->LoadType.name ); mdLoad = LoadMMediaFile_mdload( MoverParameters->LoadType.name );
// z powrotem defaultowa sciezka do tekstur // z powrotem defaultowa sciezka do tekstur
Global.asCurrentTexturePath = std::string( szTexturePath ); Global.asCurrentTexturePath = std::string( paths::textures );
} }
} // models } // models
@@ -7148,7 +7148,7 @@ void TDynamicObject::LoadMMediaFile( std::string const &TypeName, std::string co
attachment->Init(); attachment->Init();
} }
Global.asCurrentTexturePath = szTexturePath; // kiedyś uproszczone wnętrze mieszało tekstury nieba Global.asCurrentTexturePath = paths::textures; // kiedyś uproszczone wnętrze mieszało tekstury nieba
Global.asCurrentDynamicPath = ""; Global.asCurrentDynamicPath = "";
// position sound emitters which weren't defined in the config file // position sound emitters which weren't defined in the config file

View File

@@ -9311,7 +9311,7 @@ bool TTrain::InitializeCab(int NewCabNo, std::string const &asFileName)
TModel3d *kabina = TModelsManager::GetModel(DynamicObject->asBaseDir + token, true, true, TModel3d *kabina = TModelsManager::GetModel(DynamicObject->asBaseDir + token, true, true,
(Global.network_servers.empty() && !Global.network_client) ? 0 : id()); (Global.network_servers.empty() && !Global.network_client) ? 0 : id());
// z powrotem defaultowa sciezka do tekstur // z powrotem defaultowa sciezka do tekstur
Global.asCurrentTexturePath = szTexturePath; Global.asCurrentTexturePath = paths::textures;
// if (DynamicObject->mdKabina!=k) // if (DynamicObject->mdKabina!=k)
if (kabina != nullptr) if (kabina != nullptr)
{ {

View File

@@ -1654,7 +1654,7 @@ animation_event::deserialize_( cParser &Input, scene::scratch_data &Scratchpad )
{ // animacja z pliku VMD { // animacja z pliku VMD
{ {
m_animationfilename = token; m_animationfilename = token;
std::ifstream file( szModelPath + m_animationfilename, std::ios::binary | std::ios::ate ); file.unsetf( std::ios::skipws ); std::ifstream file( paths::models + m_animationfilename, std::ios::binary | std::ios::ate ); file.unsetf( std::ios::skipws );
auto size = file.tellg(); // ios::ate already positioned us at the end of the file auto size = file.tellg(); // ios::ate already positioned us at the end of the file
file.seekg( 0, std::ios::beg ); // rewind the caret afterwards file.seekg( 0, std::ios::beg ); // rewind the caret afterwards
// animation size, previously held in param 7 // animation size, previously held in param 7

View File

@@ -2266,9 +2266,9 @@ TTrack::export_as_text_( std::ostream &Output ) const {
m_material1 != null_handle ? m_material1 != null_handle ?
GfxRenderer->Material( m_material1 )->GetName() : GfxRenderer->Material( m_material1 )->GetName() :
"none" ) }; "none" ) };
if( texturefile.find( szTexturePath ) == 0 ) { if( texturefile.find( paths::textures ) == 0 ) {
// don't include 'textures/' in the path // don't include 'textures/' in the path
texturefile.erase( 0, std::string{ szTexturePath }.size() ); texturefile.erase( 0, std::string{ paths::textures }.size() );
} }
Output Output
<< texturefile << ' ' << texturefile << ' '
@@ -2278,9 +2278,9 @@ TTrack::export_as_text_( std::ostream &Output ) const {
m_material2 != null_handle ? m_material2 != null_handle ?
GfxRenderer->Material( m_material2 )->GetName() : GfxRenderer->Material( m_material2 )->GetName() :
"none" ); "none" );
if( texturefile.find( szTexturePath ) == 0 ) { if( texturefile.find( paths::textures ) == 0 ) {
// don't include 'textures/' in the path // don't include 'textures/' in the path
texturefile.erase( 0, std::string{ szTexturePath }.size() ); texturefile.erase( 0, std::string{ paths::textures }.size() );
} }
Output << texturefile << ' '; Output << texturefile << ' ';
@@ -2351,9 +2351,9 @@ TTrack::export_as_text_( std::ostream &Output ) const {
if( ( eType == tt_Switch ) if( ( eType == tt_Switch )
&& ( SwitchExtension->m_material3 != null_handle ) ) { && ( SwitchExtension->m_material3 != null_handle ) ) {
auto texturefile { GfxRenderer->Material( m_material2 )->GetName() }; auto texturefile { GfxRenderer->Material( m_material2 )->GetName() };
if( texturefile.find( szTexturePath ) == 0 ) { if( texturefile.find( paths::textures ) == 0 ) {
// don't include 'textures/' in the path // don't include 'textures/' in the path
texturefile.erase( 0, std::string{ szTexturePath }.size() ); texturefile.erase( 0, std::string{ paths::textures }.size() );
} }
Output << "trackbed " << texturefile << ' '; Output << "trackbed " << texturefile << ' ';
} }
@@ -2384,7 +2384,7 @@ std::string TTrack::tooltip() const
std::pair<std::string, int> std::pair<std::string, int>
TTrack::fetch_track_rail_profile( std::string const &Profile ) { TTrack::fetch_track_rail_profile( std::string const &Profile ) {
auto const railprofilepath { std::string( szModelPath ) + "tory/railprofile_" }; auto const railprofilepath { std::string( paths::models ) + "tory/railprofile_" };
auto const railkeyprefix { std::string( "rail_" ) }; auto const railkeyprefix { std::string( "rail_" ) };
if( m_profiles.empty() ) { if( m_profiles.empty() ) {
@@ -2414,7 +2414,7 @@ TTrack::fetch_default_profiles() {
if( false == m_profiles.empty() ) { return; } if( false == m_profiles.empty() ) { return; }
auto const railprofilepath { std::string( szModelPath ) + "tory/railprofile_" }; auto const railprofilepath { std::string( paths::models ) + "tory/railprofile_" };
auto const railkeyprefix { std::string( "rail_" ) }; auto const railkeyprefix { std::string( "rail_" ) };
m_profiles.emplace_back( deserialize_profile( railprofilepath + "default" ) ); m_profiles.emplace_back( deserialize_profile( railprofilepath + "default" ) );

View File

@@ -617,7 +617,7 @@ TTrainParameters::load_sounds() {
auto const lookup { auto const lookup {
FileExists( FileExists(
{ Global.asCurrentSceneryPath + stationname, std::string{ szSoundPath } + "sip/" + stationname }, { Global.asCurrentSceneryPath + stationname, std::string{ paths::sounds } + "sip/" + stationname },
{ ".ogg", ".flac", ".wav" } ) }; { ".ogg", ".flac", ".wav" } ) };
if( lookup.first.empty() ) { if( lookup.first.empty() ) {
continue; continue;