16
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-07-22 15:09:19 +02:00

backslash/slash fixes, again

This commit is contained in:
milek7
2018-03-26 21:22:20 +02:00
parent 6f62297e31
commit bc2184966f
18 changed files with 42 additions and 40 deletions

View File

@@ -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;
}

View File

@@ -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);

View File

@@ -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]);

View File

@@ -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())
{

View File

@@ -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;

View File

@@ -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::string>();
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<std::string> *t,
auto const materialindex = static_cast<std::size_t>( 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<std::string>();
iNumVerts = 0; // w konstruktorze to jest

View File

@@ -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;
}
}
}

View File

@@ -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<std::string> extensions{ { ".dds" }, { ".tga" }, { ".png" }, { ".bmp" }, { ".ext" } };

View File

@@ -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/...

View File

@@ -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

View File

@@ -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;

View File

@@ -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<std::string>( true, "\n\r\t ,;" ) };
auto value { Input.getToken<std::string>( 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 ) {

View File

@@ -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

View File

@@ -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<std::ifstream>( 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 ) ) ) {

View File

@@ -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<std::string>() };
auto const skinfile { Input.getToken<std::string>() };
auto const mmdfile { Input.getToken<std::string>() };
auto datafolder { Input.getToken<std::string>() };
auto skinfile { Input.getToken<std::string>() };
auto mmdfile { Input.getToken<std::string>() };
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 :

View File

@@ -143,6 +143,7 @@ std::string
sound_source::deserialize_filename( cParser &Input ) {
auto token { Input.getToken<std::string>( true, "\n\r\t ,;" ) };
std::replace(token.begin(), token.end(), '\\', '/');
if( token != "[" ) {
// simple case, single file
return token;

View File

@@ -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 );
}

View File

@@ -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;