diff --git a/AnimModel.cpp b/AnimModel.cpp index 30e60194..038aeaa0 100644 --- a/AnimModel.cpp +++ b/AnimModel.cpp @@ -688,7 +688,7 @@ void TAnimModel::AnimationVND(void *pData, double a, double b, double c, double if (0) //jeśli włączone sortowanie plików VMD (trochę się przeciąga) if (pAdvanced->SortByBone()) //próba posortowania {//zapisać posortowany plik, jeśli dokonano zmian - TFileStream *fs=new TFileStream("models\\1.vmd",fmCreate); + TFileStream *fs=new TFileStream("models/1.vmd",fmCreate); fs->Write(pData,2198342); //2948728); delete fs; } diff --git a/DynObj.cpp b/DynObj.cpp index e7b9d2d8..ec0afdaf 100644 --- a/DynObj.cpp +++ b/DynObj.cpp @@ -1735,7 +1735,7 @@ TDynamicObject::Init(std::string Name, // nazwa pojazdu, np. "EU07-424" ) { // Ustawienie początkowe pojazdu iDirection = (Reversed ? 0 : 1); // Ra: 0, jeśli ma być wstawiony jako obrócony tyłem - asBaseDir = "dynamic\\" + BaseDir + "\\"; // McZapkie-310302 + asBaseDir = "dynamic/" + BaseDir + "/"; // McZapkie-310302 asName = Name; std::string asAnimName = ""; // zmienna robocza do wyszukiwania osi i wózków // Ra: zmieniamy znaczenie obsady na jednoliterowe, żeby dosadzić kierownika @@ -1770,9 +1770,9 @@ TDynamicObject::Init(std::string Name, // nazwa pojazdu, np. "EU07-424" if (!MoverParameters->LoadFIZ(asBaseDir)) { // jak wczytanie CHK się nie uda, to błąd if (ConversionError == 666) - ErrorLog( "Bad vehicle: failed do locate definition file \"" + BaseDir + "\\" + Type_Name + ".fiz" + "\"" ); + ErrorLog( "Bad vehicle: failed do locate definition file \"" + BaseDir + "/" + Type_Name + ".fiz" + "\"" ); else { - ErrorLog( "Bad vehicle: failed to load definition from file \"" + BaseDir + "\\" + Type_Name + ".fiz\" (error " + to_string( ConversionError ) + ")" ); + ErrorLog( "Bad vehicle: failed to load definition from file \"" + BaseDir + "/" + Type_Name + ".fiz\" (error " + to_string( ConversionError ) + ")" ); } return 0.0; // zerowa długość to brak pojazdu } @@ -1782,7 +1782,7 @@ TDynamicObject::Init(std::string Name, // nazwa pojazdu, np. "EU07-424" (fVel > 0 ? 1 : -1) * Cab * (iDirection ? 1 : -1))) // jak jedzie lub obsadzony to gotowy do drogi { - Error("Parameters mismatch: dynamic object " + asName + " from\n" + BaseDir + "\\" + + Error("Parameters mismatch: dynamic object " + asName + " from\n" + BaseDir + "/" + Type_Name); return 0.0; // zerowa długość to brak pojazdu } @@ -4142,6 +4142,7 @@ void TDynamicObject::LoadMMediaFile( std::string BaseDir, std::string TypeName, m_materialdata.multi_textures = 0; // czy jest wiele tekstur wymiennych? parser.getTokens(); parser >> asModel; + std::replace(asModel.begin(), asModel.end(), '\\', '/'); if( asModel[asModel.size() - 1] == '#' ) // Ra 2015-01: nie podoba mi siê to { // model wymaga wielu tekstur wymiennych m_materialdata.multi_textures = 1; @@ -4176,6 +4177,7 @@ void TDynamicObject::LoadMMediaFile( std::string BaseDir, std::string TypeName, std::string texturename; nameparser >> texturename; while( ( texturename != "" ) && ( skinindex < 4 ) ) { erase_extension( texturename ); + std::replace(texturename.begin(), texturename.end(), '\\', '/'); m_materialdata.replacable_skins[ skinindex + 1 ] = GfxRenderer.Fetch_Material( Global.asCurrentTexturePath + texturename ); ++skinindex; texturename = ""; nameparser >> texturename; @@ -4355,6 +4357,7 @@ void TDynamicObject::LoadMMediaFile( std::string BaseDir, std::string TypeName, // ABu: wnetrze lowpoly parser.getTokens(); parser >> asModel; + std::replace(asModel.begin(), asModel.end(), '\\', '/'); asModel = BaseDir + asModel; // McZapkie-200702 - dynamics maja swoje modele w dynamic/basedir Global.asCurrentTexturePath = BaseDir; // biezaca sciezka do tekstur to dynamic/... mdLowPolyInt = TModelsManager::GetModel(asModel, true); diff --git a/EU07.cpp b/EU07.cpp index 146c430d..d7c44308 100644 --- a/EU07.cpp +++ b/EU07.cpp @@ -270,7 +270,10 @@ int main(int argc, char *argv[]) Global.iConvertModels = -7; // z optymalizacją, bananami i prawidłowym Opacity } else if (i + 1 < argc && token == "-s") + { Global.SceneryFile = std::string(argv[++i]); + std::replace(Global.SceneryFile.begin(), Global.SceneryFile.end(), '\\', '/'); + } else if (i + 1 < argc && token == "-v") { std::string v(argv[++i]); diff --git a/McZapkie/Mover.cpp b/McZapkie/Mover.cpp index dfd0cde3..e5ebe9ba 100644 --- a/McZapkie/Mover.cpp +++ b/McZapkie/Mover.cpp @@ -6707,7 +6707,6 @@ bool TMoverParameters::LoadFIZ(std::string chkpath) WriteLog("LOAD FIZ FROM " + file); - std::replace(file.begin(), file.end(), '\\', '/'); std::ifstream in(file); if (!in.is_open()) { diff --git a/MdlMngr.cpp b/MdlMngr.cpp index ca9f1e43..6e15b478 100644 --- a/MdlMngr.cpp +++ b/MdlMngr.cpp @@ -81,6 +81,10 @@ TModelsManager::GetModel(std::string const &Name, bool const Dynamic) // - wczytanie modelu animowanego - Init() - sprawdzić std::string const buftp { Global.asCurrentTexturePath }; // zapamiętanie aktualnej ścieżki do tekstur, std::string filename { Name }; + if (Name.find('\\') != std::string::npos) + { + ErrorLog("internal error: backslash in GetModel: " + Name); + } if( Name.find( '/' ) != std::string::npos ) { // pobieranie tekstur z katalogu, w którym jest model Global.asCurrentTexturePath += Name; diff --git a/Model3d.cpp b/Model3d.cpp index 7fe237c3..36129b6f 100644 --- a/Model3d.cpp +++ b/Model3d.cpp @@ -300,6 +300,7 @@ int TSubModel::Load( cParser &parser, TModel3d *Model, /*int Pos,*/ bool dynamic if (!parser.expectToken("map:")) Error("Model map parse failure!"); std::string material = parser.getToken(); + std::replace(material.begin(), material.end(), '\\', '/'); if (material == "none") { // rysowanie podanym kolorem m_material = null_handle; @@ -333,7 +334,7 @@ int TSubModel::Load( cParser &parser, TModel3d *Model, /*int Pos,*/ bool dynamic else { // jeśli tylko nazwa pliku, to dawać bieżącą ścieżkę do tekstur Name_Material(material); - if( material.find_first_of( "/\\" ) == material.npos ) { + if( material.find_first_of( "/" ) == material.npos ) { material.insert( 0, Global.asCurrentTexturePath ); } m_material = GfxRenderer.Fetch_Material( material ); @@ -1233,7 +1234,6 @@ bool TModel3d::LoadFromFile(std::string const &FileName, bool dynamic) { // wczytanie modelu z pliku std::string name = ToLower(FileName); - std::replace(name.begin(), name.end(), '\\', '/'); // trim extension if needed if( name.rfind( '.' ) != std::string::npos ) { @@ -1597,7 +1597,11 @@ void TModel3d::deserialize(std::istream &s, size_t size, bool dynamic) if (Textures.size()) throw std::runtime_error("e3d: duplicated TEX chunk"); while (s.tellg() < end) - Textures.push_back(sn_utils::d_str(s)); + { + std::string str = sn_utils::d_str(s); + std::replace(str.begin(), str.end(), '\\', '/'); + Textures.push_back(str); + } } else if (type == MAKE_ID4('N', 'A', 'M', '0')) { @@ -1664,7 +1668,7 @@ void TSubModel::BinInit(TSubModel *s, float4x4 *m, std::vector *t, auto const materialindex = static_cast( iTexture ); if( materialindex < t->size() ) { m_materialname = t->at( materialindex ); - if( m_materialname.find_last_of( "/\\" ) == std::string::npos ) { + if( m_materialname.find_last_of( "/" ) == std::string::npos ) { m_materialname = Global.asCurrentTexturePath + m_materialname; } m_material = GfxRenderer.Fetch_Material( m_materialname ); @@ -1749,7 +1753,7 @@ void TModel3d::LoadFromTextFile(std::string const &FileName, bool dynamic) { // wczytanie submodelu z pliku tekstowego WriteLog( "Loading text format 3d model data from \"" + FileName + "\"...", logtype::model ); iFlags |= 0x0200; // wczytano z pliku tekstowego (właścicielami tablic są submodle) - cParser parser(FileName, cParser::buffer_FILE); // Ra: tu powinno być "models\\"... + cParser parser(FileName, cParser::buffer_FILE); // Ra: tu powinno być "models/"... TSubModel *SubModel; std::string token = parser.getToken(); iNumVerts = 0; // w konstruktorze to jest diff --git a/PyInt.cpp b/PyInt.cpp index e426af9f..ddc7ca0f 100644 --- a/PyInt.cpp +++ b/PyInt.cpp @@ -479,7 +479,6 @@ void TPythonScreens::update() void TPythonScreens::setLookupPath(std::string const &path) { _lookupPath = path; - std::replace(_lookupPath.begin(), _lookupPath.end(), '\\', '/'); } TPythonScreens::TPythonScreens() @@ -591,4 +590,4 @@ void TPythonScreens::_freeTrainState() Py_CLEAR(_trainState); _trainState = NULL; } -} \ No newline at end of file +} diff --git a/Texture.cpp b/Texture.cpp index 87d2d4fa..f1d07a70 100644 --- a/Texture.cpp +++ b/Texture.cpp @@ -817,10 +817,6 @@ texture_manager::create( std::string Filename, bool const Loadnow ) { } erase_extension( Filename ); - // change slashes to cross-platform - std::replace( - std::begin( Filename ), std::end( Filename ), - '\\', '/' ); std::vector extensions{ { ".dds" }, { ".tga" }, { ".png" }, { ".bmp" }, { ".ext" } }; diff --git a/Train.cpp b/Train.cpp index 1b96ecaf..3ac53027 100644 --- a/Train.cpp +++ b/Train.cpp @@ -5586,6 +5586,7 @@ bool TTrain::InitializeCab(int NewCabNo, std::string const &asFileName) // model kabiny parser->getTokens(); *parser >> token; + std::replace(token.begin(), token.end(), '\\', '/'); if (token != "none") { // bieżąca sciezka do tekstur to dynamic/... diff --git a/World.cpp b/World.cpp index 4b174434..acb8d30f 100644 --- a/World.cpp +++ b/World.cpp @@ -1982,7 +1982,7 @@ void TWorld::CreateE3D(std::string const &Path, bool Dynamic) // launch recursive search for sub-directories... if( filename == "." ) { continue; } if( filename == ".." ) { continue; } - CreateE3D( Path + filename + "\\", Dynamic ); + CreateE3D( Path + filename + "/", Dynamic ); } else { // process the file diff --git a/audio.cpp b/audio.cpp index 3d69c867..aebdd88c 100644 --- a/audio.cpp +++ b/audio.cpp @@ -26,7 +26,6 @@ openal_buffer::openal_buffer( std::string const &Filename ) : si.format = 0; std::string file = Filename; - std::replace(file.begin(), file.end(), '\\', '/'); WriteLog("sound: loading file: " + file); @@ -105,10 +104,6 @@ buffer_manager::create( std::string const &Filename ) { auto filename { ToLower( Filename ) }; erase_extension( filename ); - // convert slashes - std::replace( - std::begin( filename ), std::end( filename ), - '\\', '/' ); audio::buffer_handle lookup { null_handle }; std::string filelookup; diff --git a/material.cpp b/material.cpp index d9badc04..d5695552 100644 --- a/material.cpp +++ b/material.cpp @@ -18,7 +18,6 @@ http://mozilla.org/MPL/2.0/. std::string path( std::string const &Filename ) { std::string fn = Filename; - std::replace(fn.begin(), fn.end(), '\\', '/'); return ( fn.rfind( '/' ) != std::string::npos ? fn.substr( 0, fn.rfind( '/' ) + 1 ) : @@ -49,7 +48,7 @@ opengl_material::deserialize_mapping( cParser &Input, int const Priority, bool c if( ( true == key.empty() ) || ( key == "}" ) ) { return false; } - auto const value { Input.getToken( true, "\n\r\t ,;" ) }; + auto value { Input.getToken( true, "\n\r\t ,;" ) }; if( Priority != -1 ) { // regular attribute processing mode @@ -69,6 +68,7 @@ opengl_material::deserialize_mapping( cParser &Input, int const Priority, bool c else if( key == "texture1:" ) { if( ( texture1 == null_handle ) || ( Priority > priority1 ) ) { + std::replace(value.begin(), value.end(), '\\', '/'); texture1 = GfxRenderer.Fetch_Texture( value, Loadnow ); priority1 = Priority; } @@ -76,6 +76,7 @@ opengl_material::deserialize_mapping( cParser &Input, int const Priority, bool c else if( key == "texture2:" ) { if( ( texture2 == null_handle ) || ( Priority > priority2 ) ) { + std::replace(value.begin(), value.end(), '\\', '/'); texture2 = GfxRenderer.Fetch_Texture( value, Loadnow ); priority2 = Priority; } @@ -116,11 +117,6 @@ material_manager::create( std::string const &Filename, bool const Loadnow ) { erase_extension( filename ); filename += ".mat"; - // change slashes to llinux-compatible - std::replace( - std::begin( filename ), std::end( filename ), - '\\', '/' ); - // try to locate requested material in the databank auto const databanklookup = find_in_databank( filename ); if( databanklookup != null_handle ) { diff --git a/mtable.cpp b/mtable.cpp index 54aeb8f5..7a510e21 100644 --- a/mtable.cpp +++ b/mtable.cpp @@ -242,7 +242,6 @@ bool TTrainParameters::LoadTTfile(std::string scnpath, int iPlus, double vmax) ConversionError = 666; vActual = -1; s = scnpath + TrainName + ".txt"; - std::replace(s.begin(), s.end(), '\\', '/'); // Ra 2014-09: ustalić zasady wyznaczenia pierwotnego pliku przy przesuniętych rozkładach // (kolejny pociąg dostaje numer +2) fin.open(s.c_str()); // otwieranie pliku diff --git a/parser.cpp b/parser.cpp index cf137646..18a137de 100644 --- a/parser.cpp +++ b/parser.cpp @@ -37,7 +37,6 @@ cParser::cParser( std::string const &Stream, buffertype const Type, std::string switch (Type) { case buffer_FILE: { Path.append( Stream ); - std::replace(Path.begin(), Path.end(), '\\', '/'); mStream = std::make_shared( Path ); break; } @@ -216,6 +215,7 @@ std::string cParser::readToken( bool ToLower, const char *Break ) { // launch child parser if include directive found. // NOTE: parameter collecting uses default set of token separators. std::string includefile = readToken(ToLower); // nazwa pliku + std::replace(includefile.begin(), includefile.end(), '\\', '/'); if( ( true == LoadTraction ) || ( ( includefile.find( "tr/" ) == std::string::npos ) && ( includefile.find( "tra/" ) == std::string::npos ) ) ) { diff --git a/simulation.cpp b/simulation.cpp index 765dfe9f..a3a5216e 100644 --- a/simulation.cpp +++ b/simulation.cpp @@ -734,9 +734,14 @@ state_manager::deserialize_dynamic( cParser &Input, scene::scratch_data &Scratch } auto const inputline { Input.Line() }; // cache in case of errors // basic attributes - auto const datafolder { Input.getToken() }; - auto const skinfile { Input.getToken() }; - auto const mmdfile { Input.getToken() }; + auto datafolder { Input.getToken() }; + auto skinfile { Input.getToken() }; + auto mmdfile { Input.getToken() }; + + std::replace(datafolder.begin(), datafolder.end(), '\\', '/'); + std::replace(skinfile.begin(), skinfile.end(), '\\', '/'); + std::replace(mmdfile.begin(), mmdfile.end(), '\\', '/'); + auto const pathname = ( Scratchpad.trainset.is_open ? Scratchpad.trainset.track : diff --git a/sound.cpp b/sound.cpp index bd4bbc58..8ead2247 100644 --- a/sound.cpp +++ b/sound.cpp @@ -143,6 +143,7 @@ std::string sound_source::deserialize_filename( cParser &Input ) { auto token { Input.getToken( true, "\n\r\t ,;" ) }; + std::replace(token.begin(), token.end(), '\\', '/'); if( token != "[" ) { // simple case, single file return token; diff --git a/stars.cpp b/stars.cpp index 9fbdb3ce..b6c8cfd1 100644 --- a/stars.cpp +++ b/stars.cpp @@ -9,5 +9,5 @@ void cStars::init() { - m_stars = TModelsManager::GetModel( "models\\skydome_stars.t3d", false ); + m_stars = TModelsManager::GetModel( "models/skydome_stars.t3d", false ); } diff --git a/utilities.cpp b/utilities.cpp index 498feadd..07289e62 100644 --- a/utilities.cpp +++ b/utilities.cpp @@ -304,9 +304,7 @@ extract_value( bool &Variable, std::string const &Key, std::string const &Input, } bool FileExists( std::string const &Filename ) { - std::string fn = Filename; - std::replace(fn.begin(), fn.end(), '\\', '/'); - std::ifstream file( fn ); + std::ifstream file( Filename ); return( true == file.is_open() ); } @@ -314,7 +312,6 @@ bool FileExists( std::string const &Filename ) { std::time_t last_modified( std::string const &Filename ) { std::string fn = Filename; - std::replace(fn.begin(), fn.end(), '\\', '/'); struct stat filestat; if( ::stat( fn.c_str(), &filestat ) == 0 ) return filestat.st_mtime;