The International Simutrans Forum

 

Author Topic: [r9176] Files of saves end in .sv_  (Read 412 times)

0 Members and 1 Guest are viewing this topic.

Offline Antarctica

  • *
  • Posts: 33
  • Languages: DE, EN
[r9176] Files of saves end in .sv_
« on: July 29, 2020, 09:47:52 PM »
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:
Quote
   ADD: 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.

Offline ceeac

  • Devotee
  • *
  • Posts: 156
Re: [r9176] Files of saves end in .sv_
« Reply #1 on: July 30, 2020, 05:39:26 AM »
The relevant code is in karte_t::save, simworld.cc line 4644+. Does your %userprofile% contain non-ASCII characters?

Offline Antarctica

  • *
  • Posts: 33
  • Languages: DE, EN
Re: [r9176] Files of saves end in .sv_
« Reply #2 on: July 30, 2020, 08:22:48 AM »
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:
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. If you modify the savename array in-place, you modify the value of the filename variable as well.

Then,
Code: [Select]
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.

Offline ceeac

  • Devotee
  • *
  • Posts: 156
Re: [r9176] Files of saves end in .sv_
« Reply #3 on: July 30, 2020, 09:36:23 AM »
That 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.

Offline prissi

  • Developer
  • Administrator
  • *
  • Posts: 10032
  • Languages: De,EN,JP
Re: [r9176] Files of saves end in .sv_
« Reply #4 on: July 31, 2020, 03:19:50 AM »
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"?

Offline Ters

  • Coder/patcher
  • Devotee
  • *
  • Posts: 5648
  • Languages: EN, NO
Re: [r9176] Files of saves end in .sv_
« Reply #5 on: July 31, 2020, 01:13:40 PM »
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.

Offline Antarctica

  • *
  • Posts: 33
  • Languages: DE, EN
Re: [r9176] Files of saves end in .sv_
« Reply #6 on: August 01, 2020, 08:44:47 AM »
Quote
no Antivirus except Windows Defender

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

Offline prissi

  • Developer
  • Administrator
  • *
  • Posts: 10032
  • Languages: De,EN,JP
Re: [r9176] Files of saves end in .sv_
« Reply #7 on: August 03, 2020, 03:25:19 AM »
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?

Offline Ters

  • Coder/patcher
  • Devotee
  • *
  • Posts: 5648
  • Languages: EN, NO
Re: [r9176] Files of saves end in .sv_
« Reply #8 on: August 03, 2020, 09:50:27 AM »
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.

Does 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.

Offline Antarctica

  • *
  • Posts: 33
  • Languages: DE, EN
Re: [r9176] Files of saves end in .sv_
« Reply #9 on: August 04, 2020, 06:18:12 PM »
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.

Offline TurfIt

  • Dev Team, Coder/patcher
  • Devotee
  • *
  • Posts: 1348
Re: [r9176] Files of saves end in .sv_
« Reply #10 on: August 04, 2020, 06:42:47 PM »
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.

Offline Antarctica

  • *
  • Posts: 33
  • Languages: DE, EN
Re: [r9176] Files of saves end in .sv_
« Reply #11 on: August 05, 2020, 09:02:11 PM »
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.