aliens

Author Topic: Save File structure  (Read 4410 times)

Offline SuperCaffeineDude

  • Colonel
  • ****
  • Posts: 108
    • View Profile
    • supercaffeinedude
Save File structure
« 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!

Offline ohartenstein23

  • Commander
  • *****
  • Posts: 1933
  • Flamethrowers fry cyberdisk circuits
    • View Profile
Re: Save File structure
« Reply #1 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, you really only need the information about nested maps and sequences.
« Last Edit: May 29, 2018, 04:51:29 pm by ohartenstein23 »

Offline Yankes

  • Global Moderator
  • Commander
  • *****
  • Posts: 3350
    • View Profile
Re: Save File structure
« Reply #2 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

Offline Starving Poet

  • Colonel
  • ****
  • Posts: 265
    • View Profile
Re: Save File structure
« Reply #3 on: May 30, 2018, 02:57:05 am »
bases
  • [soldiers][y]


For each x, cycle through each y.

Sent from my LG-H872 using Tapatalk


Offline SuperCaffeineDude

  • Colonel
  • ****
  • Posts: 108
    • View Profile
    • supercaffeinedude
Re: Save File structure
« Reply #4 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
« Last Edit: June 09, 2018, 12:54:37 am by SuperCaffeineDude »

Offline Stoddard

  • Colonel
  • ****
  • Posts: 485
  • in a fey mood
    • View Profile
    • Linux builds & stuff
Re: Save File structure
« Reply #5 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.