News:

Use the "Forum Search"
It may help you to find anything in the forum ;).

[r9176] Files of saves end in .sv_

Started by Antarctica, July 29, 2020, 09:47:52 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Antarctica

I have a weird problem in 121.0 and r9176: Whenever I save my game, the file created in "%userprofile%\Documents\Simutrans\save" gets the file extension ".sv_" and does not show up in the "Load game" screen. I can rename it to ".sve" and it seems it loads correctly. That's weird insofar as 121.0 is around for quite a few days, the issue is quite obvious, but it has not yet been reported by anyone as far as I can see.

Therefore, I have tried to find the "sv_" string in the source tarball, but no luck. If you can pinpoint me to the correct source code file or commit for this:
QuoteADD: always use temporary save name *.sv_ during saving before deleting main file
I could have a look and check what causes this weird behaviour.

I'm using the zipped 121 version on a recent Windows 10, with recent pak128, no Antivirus except Windows Defender, and reproduced with the zipped r9176 nightly renamed to "simutrans_nightly.exe" and copied alongside it.

ceeac

The relevant code is in karte_t::save, simworld.cc line 4644+. Does your %userprofile% contain non-ASCII characters?

Antarctica

No, my userprofile does not contain non-ASCII characters.

Also, I receive the "Spielstand wurde gespeichert" notification, so it seems that everything runs through fine and no errors are returned from dr_rename.

That leaves me with one silly question:
std::string savename = filename;
savename[savename.length()-1] = '_';


I'm not sure about the intricacies of C++ (I only know PHP and Java and C# and JS), but in some languages the string only holds a reference to the array. If you modify the savename array in-place, you modify the value of the filename variable as well.

Then,
dr_rename( savename.c_str(), filename );
would just copy 0008d.sv_ to 0008d.sv_, not to 0008d.sve.

However, if that really was the case, I still wonder why I am the first to report.

ceeac

Quote from: Antarctica on July 30, 2020, 08:22:48 AMThat leaves me with one silly question:
Code: [Select]

   std::string savename = filename;
   savename[savename.length()-1] = '_';


I'm not sure about the intricacies of C++ (I only know PHP and Java and C# and JS), but in some languages the string only holds a reference to the array.
No, filename is copied to savename in the first line, and the copy is subsequently modified by the second line. So dr_rename fails for some reason, but this is not recognized as an error because the return value of dr_rename is not checked.

prissi

It could be even an overeager virus software which does not like .sve extensions. But in order to narrow it down, what is the expanded path of "%userprofile%\Documents\Simutrans\save"?

Ters

It doesn't have to be that the anti-virus or other scanning software doesn't like .sve in particular. It could simply be that it is having a look at the file that suddenly appeared. Windows doesn't allow deletion of files that some process have open. I think the same might be true for renaming. At work, "make clean" equivalents often fail (shortly after a build) because something is temporarily holding on to the files. It might be the IDE parsing some generated source code, but it became more prevalent after we got another piece of security software installed. (It can also be that the security software is slowing down my IDE, rather than interfering with the files directly.) It usually works on the second try.

Antarctica

Quoteno Antivirus except Windows Defender

Quotewhat is the expanded path of "%userprofile%\Documents\Simutrans\save"
C:\Users\alexu\Documents\Simutrans\save

prissi

That path should be fine. Maybe the saved files are now checked by defender and thus renaming fails. Or somehow sve has flagged as illegal extension due to some other settings. Does normal manual rename generate works while Simutrans is still running?

Ters

If anti-virus doesn't like something, it usually puts it in quarantine and gives a message. Simply stopping a file from being renamed serves no obvious purpose.

Some logging in dr_rename (and dr_remove) to show if MoveFileEx(/DeleteFile) succeeds, and if not, what GetLastError returns, might be helpful. My hypothesis calls for ERROR_ACCESS_DENIED. Then again, so do probably several other hypothesis as well. The error code being something else might therefore actually be more conclusive.

Quote from: prissi on August 03, 2020, 03:25:19 AMDoes normal manual rename generate works while Simutrans is still running?
I don't think Simutrans is the one hogging the file, but it is worth checking it out, so that it can be ruled out for sure.

Antarctica

Manual rename works while simutrans is still running.

I am running Simutrans under the same account that I open the explorer with, in which I rename the file. I am not asked for elevated privileges while opening either simutrans or explorer, nor for the rename in explorer.

TurfIt

Is your home directory being synced with OneDrive? (or any other cloud/backup system)

Try running Simutrans in single user mode so the save is to the program directory rather than home directory? And of course make sure Simutrans is not installed in C:\users\...blah..., and in a place with regular user write permissions.

Antarctica

No, my system is not being synced with any cloud system and I do not have any backup software, security software or similar installed (except Windows Defender).

Obviously, the user simutrans runs under has write permissions to the directory, otherwise the *.sv_ files would not be created. Also, as I said, I am able to rename the file manually.

I have the same problem if I use singleuser mode.

Antarctica

Just to let you know, with the 122 steam version ("r9274M") the save works correctly again.

prissi