editing a save file

You can get help here if Freeciv doesn't start on your computer, or if you keep getting fatal errors while playing etc.
djconklin
Veteran
Posts: 64
Joined: Wed Feb 06, 2013 3:45 pm

editing a save file

Postby djconklin » Thu Aug 31, 2017 5:29 pm

What program will open a saved game file?

What do I look for to edit the research of the various players?

User avatar
VladimirSlavik
Posts: 46
Joined: Thu Aug 27, 2015 7:27 am

Re: editing a save file

Postby VladimirSlavik » Thu Aug 31, 2017 8:27 pm

It's a compressed plain text file. See for yourself...

sveinung
Elite
Posts: 427
Joined: Wed Feb 20, 2013 4:50 pm

Re: editing a save file

Postby sveinung » Fri Sep 01, 2017 9:55 am

djconklin wrote:What program will open a saved game file?


It is, as VladimirSlavik said, a compressed text file. Just decompress it and open it in a text editor. Some text editors, like GNU Emacs, can load and edit the compressed file.

djconklin
Veteran
Posts: 64
Joined: Wed Feb 06, 2013 3:45 pm

Re: editing a save file

Postby djconklin » Fri Sep 01, 2017 5:08 pm

>Just decompress it and open it in a text editor.

Therein lies the problem: how do I decompress it?

djconklin
Veteran
Posts: 64
Joined: Wed Feb 06, 2013 3:45 pm

Re: editing a save file

Postby djconklin » Fri Sep 01, 2017 5:09 pm

VladimirSlavik wrote:It's a compressed plain text file. See for yourself...
All I see is garbage when I try to open it with a text editor.

User avatar
JTN
Elite
Posts: 450
Joined: Wed Jan 30, 2013 12:15 am

Re: editing a save file

Postby JTN » Fri Sep 01, 2017 7:13 pm

It's compressed with Unixy tools, as indicated by the file extension (.gz, .bz2, .xz).

If you're on a Linux system, you will likely find the tools you need to uncompress it (gunzip, bunzip2, unxz) already installed. If you're on Windows, you'll have to look further afield for suitable decompession tools.

If you have control of the generation of the save file, you can ask for it to be saved uncompressed ("/set compresstype plain", or equivalent from the client's "server settings" UI).

(To anticipate possible next question: we don't formally document the format of the save file, or how it changes between major releases.)

djconklin
Veteran
Posts: 64
Joined: Wed Feb 06, 2013 3:45 pm

Re: editing a save file

Postby djconklin » Fri Sep 01, 2017 8:24 pm

Cute! I have no idea what this says: https://msdn.microsoft.com/en-us/librar ... 25(v=vs.85).aspx

User avatar
VladimirSlavik
Posts: 46
Joined: Thu Aug 27, 2015 7:27 am

Re: editing a save file

Postby VladimirSlavik » Sat Sep 02, 2017 5:53 am

On Windows... Somewhat confusingly, to manage compressed files, you need to install an "archive manager" tool, such as winzip, winrar, peazip, 7-zip etc. All of these support reading a lot of formats, including these that freeciv uses (gz, bz2).

Once you have one installed, right click the save file; the menu should offer something like "decompress", "extract" or so. (It might be hidden in a submenu.) Use that and you will get the plain text file. Happy reading and editing!

Note that freeciv can read the saves uncompressed just fine, so there's no need to mess with re-compressing the file once you're done.

sveinung
Elite
Posts: 427
Joined: Wed Feb 20, 2013 4:50 pm

Re: editing a save file

Postby sveinung » Mon Sep 04, 2017 9:33 am

sveinung wrote:Some text editors, like GNU Emacs, can load and edit the compressed file.


Clarification: GNU Emacs can load and edit the compressed file directly (without you having to decompress it manually first). Most other text editors require you to first decompress the savegame and then edit the decompressed file.

djconklin
Veteran
Posts: 64
Joined: Wed Feb 06, 2013 3:45 pm

Re: editing a save file

Postby djconklin » Mon Sep 04, 2017 4:31 pm

VladimirSlavik wrote:On Windows... Somewhat confusingly, to manage compressed files, you need to install an "archive manager" tool, such as winzip, winrar, peazip, 7-zip etc. All of these support reading a lot of formats, including these that freeciv uses (gz, bz2).

Once you have one installed, right click the save file; the menu should offer something like "decompress", "extract" or so. (It might be hidden in a submenu.) Use that and you will get the plain text file. Happy reading and editing!

Note that freeciv can read the saves uncompressed just fine, so there's no need to mess with re-compressing the file once you're done.
THANK YOU!