OpenXcom Forum

Modding => Help => Topic started by: SuperCaffeineDude on May 29, 2018, 04:35:37 pm

Title: Save File structure
Post by: SuperCaffeineDude on May 29, 2018, 04:35:37 pm
Hi, as a little project, I basically want to create a external tool that grabs soldiers and edits their Name Sex etc and saves over the save file. But I'm struggling to find a consistent way to isolate the segment referring to the soldier from the craft/base/etc.

So may I ask how the end of a class, is defined in the save file, is it just the indentation perhaps?? Maybe there's a link someone could refer me to? All the best!
Title: Re: Save File structure
Post by: ohartenstein23 on May 29, 2018, 04:49:57 pm
The save file structure follows the same syntax as the ruleset files - YAML.  Since you're making an automated tool, it might be a better idea to find a YAML library for whatever programming language you're using than trying to write it from scratch.

To answer your question about the ends of sections, yes, it is done by indentation.  Here's an a  quick YAML reference (https://learnxinyminutes.com/docs/yaml/), you really only need the information about nested maps and sequences.
Title: Re: Save File structure
Post by: Yankes on May 29, 2018, 09:44:01 pm
or even better grab source code of OXC that modify its save game logic to fit your goal. If you want use C++ or C# most work is done.

https://github.com/SupSuper/OpenXcom/blob/master/src/Savegame/SavedGame.cpp#L333
Title: Re: Save File structure
Post by: Starving Poet on May 30, 2018, 02:57:05 am
bases

For each x, cycle through each y.

Sent from my LG-H872 using Tapatalk

Title: Re: Save File structure
Post by: SuperCaffeineDude on June 09, 2018, 12:11:26 am
Sorry! Cheers for your responses, I'm very much an amature at best when it comes to programming  :-[ as I learnt most of it using Unity, I like the idea of using a YAML library, I'll look into that.

I just really want the soldier data, and to automatically update it to a volunteer list, so someone might type a string stating "!Enlist|name|sex|skin" and have that assigned to soldiers

My current thinking is to read the each line and count indentation to find out when it's reading data outside and inside of the soldier class/nest/gobbledegook
Title: Re: Save File structure
Post by: Stoddard on June 15, 2018, 04:01:23 pm
My current thinking is to read the each line and count indentation to find out when it's reading data outside and inside of the soldier class/nest/gobbledegook

Doing that is just reinventing a YAML parser. Don't waste your time, use a library.