Save game editing

General discussion about the game.
swixel
Posts: 80
Joined: Mon Sep 17, 2012 6:08 am

Re: Save game editing

Postby swixel » Sat Sep 22, 2012 10:47 pm

The Steam binary's protection aside, has anyone looked at the GOG binary? I've only got HumbleStore + Steam (Win32) binaries to poke around. I only ask because I'd like to get detours up and running on something other than the HS Win32 version to load additional ships ...

I haven't reversed much else out of the continue.sav binary (I've been reading the the save/load ASM, which is why I've been ignoring the repo posted here ... I don't want to jump to conclusions like I did with prof.sav). I finally traced back the enemy binary bit (long walk off a short pier there), so I might continue down the stack today to see what else turns out. I'm particularly interested in the starmap stuff (not for modifying, but for visualising/understanding the data for mod support; worst case we can reload the file, best case the locations in the save allow us to trace back storage values in the binaries).
v3gard
Posts: 2
Joined: Sun Sep 23, 2012 9:35 pm

Re: Save game editing

Postby v3gard » Sun Sep 23, 2012 9:42 pm

Evening!

Just wanted to let you know that I spent a few hours today and yesterday creating a basic savegame editor. You can't do very much with it at the moment except modifying scrap, fuel, missiles, drones and ship integrity - but its a start anyway!

The editor is available here: https://github.com/v3gard/ftlsg

I have focused on reversing the continue.sav file, and every byte from the beginning until the last of the current crew members has been loaded into the editor (although you can't change everything yet).

Future updates will most likely come when I find the time. I haven't read through every post here yet, but I assume I'll find several variables that I haven't been able to decode myself yet :-)

Oh, btw. I haven't tried compiling it on Windows yet, so if someone would give it a try that would be awesome.
a__gun
Posts: 9
Joined: Fri Sep 21, 2012 7:55 pm

Re: Save game editing

Postby a__gun » Tue Sep 25, 2012 12:44 pm

*Bump*
Anyone making any progress on this?
fparadis2
Posts: 1
Joined: Tue Sep 25, 2012 11:37 pm

Re: Save game editing

Postby fparadis2 » Tue Sep 25, 2012 11:41 pm

I can decode savegames up to cargo. After that it gets harder.. I guess it has something to do with the beacon map or system map. This is the part I'm most interested in :(

You can check my progress at https://bitbucket.org/fparadis2/ftlsavegameeditor/src. Warning: lots of hacky code that might be somewhat specific to my machine (i.e. savegame locations)

Anyway, I'd be very interested in seeing if anyone has cracked the star map part!
swixel
Posts: 80
Joined: Mon Sep 17, 2012 6:08 am

Re: Save game editing

Postby swixel » Wed Sep 26, 2012 3:04 am

fparadis2 wrote:I can decode savegames up to cargo. After that it gets harder.. I guess it has something to do with the beacon map or system map. This is the part I'm most interested in :(
[...]
Anyway, I'd be very interested in seeing if anyone has cracked the star map part!


I've been clean room reversing it from the binaries. The starmap makes references to *everything*, so it's a slow process which is derailed by my "want custom race" mentality.
Striblezz
Posts: 1
Joined: Mon Oct 01, 2012 1:57 pm

Re: Save game editing

Postby Striblezz » Mon Oct 01, 2012 2:25 pm

I've been playing around with the save data myself...

Most recently using the 010 Editor I saw mentioned in this guide linked from a stack overflow page earlier in the thread.

Running the template listed below on the sav file via 010 Editor allows you to easily change the ship resources as well as crew types and xp.
I added comments for the max values.

I think there is a way to insert bytes using the templates/scripts... but I just started using the editor a few hours ago, so I'm not sure.
I stubbed out the String_Write function, if anyone wants to take a stab at changing the string sizes.
The strings are prefixed with the size, rather than null terminated, but you can use a null to shorten the string (like human -> rock/slug/engi).

Here is my template so far:

Code: Select all

//--------------------------------------
//--- 010 Editor v4.0.2 Binary Template
//
// File: FTL_SAVTemplate.bt
// Author: Striblezz
// Revision: 0.1
// Purpose: FTL Experimentation
//--------------------------------------

typedef struct
{
    int count;
    char chars[count];
} String <read=String_Read/*, write=String_Write*/>;

string String_Read(String &v)
{
    return v.chars;
}

/*
void String_Write(String &v, string s)
{
    int count = 5; //Strlen(s);
    DeleteBytes((int64)(v.chars), v.count);
    InsertBytes((int64)(v.chars), count);
    v.count = count;
    Memcpy(v.chars, s, v.count);
}
*/


typedef struct
{
    int   var0;   // 2    2
    int   var1;   // 0    1
    int   var2;   // 0    35
    int   var3;   // 1    97
    int   var4;   // 0    1949
    int   var5;   // 3    14
} HEADER;

typedef struct
{
    String ship_name;
    String ship_type;
    int   sector; //?
    int   data1;
} SHIP_DATA;

typedef struct
{
    String name;
    int value;
} STAT;

typedef struct
{
    int stat_count;
    STAT stat[stat_count] <optimize=false>;
} STATS;

typedef struct
{
    String crew_type;
    String crew_name;
} START_CREW;

typedef struct
{
    String ship_type;
    String ship_name;
    String ship_short_name;

    int start_crew_count;
    START_CREW start_crew[start_crew_count] <optimize=false>;
} START_DATA;

typedef struct
{
    String crew_name;
    String crew_type <comment="You can change between (engi, rock, slug) or from (human) to those, but you need a type with 6 characters to switch to (mantis, zoltan) or down to (human)">;
    int   data_0; //0
    int   health <comment="Max: 100(human, slug, engi, mantis), 70(zoltan), 150(rock)">;
    int   pos_x;  //507
    int   pos_x;  //157
    int   data_1; //0
    int   data_2; //0
    int   data_3; //1
    int   xp_control <comment="Max: 30">;
    int   xp_engines <comment="Max: 30">;
    int   xp_shields <comment="Max: 110">;
    int   xp_weapons <comment="Max: 130">;
    int   xp_repair <comment="Max: 36">;
    int   xp_combat <comment="Max: 16">;
    int   data_10; //1
    int   data_11; //0
    int   data_12; //0
    int   data_13; //0
    int   nodes_visited_maybe; //0
    int   data_15; //0
} CREW;

struct FILE
{
    HEADER header;
    SHIP_DATA ship_data;
    STATS stats;
    START_DATA start_data;
   
    int   hull <comment="Max: 30">;
    int   energy <comment="Max: 999+">;
    int   missiles <comment="Max: 999+">;
    int   drones <comment="Max: 999+">;
    int   scrap <comment="Max: 999999+">;

    int   crew_count;
    CREW crew[crew_count] <optimize=false>;
} file;


Feel free to add to it, or update it if you figure out what the other values are for...
Agent_L
Posts: 206
Joined: Wed Sep 26, 2012 7:47 pm

Re: Save game editing

Postby Agent_L » Mon Oct 01, 2012 4:45 pm

fparadis2 wrote:Anyway, I'd be very interested in seeing if anyone has cracked the star map part!

I belive there might be a bug there. I've saved game right before jump to "Rock homeworld" and when I loaded the game I had an option to jump to "Mantis homeworld".
So maybe not everything is saved.
CIA maps of Portugal Please God, don't let Portugal to go to war with USA!
v3gard
Posts: 2
Joined: Sun Sep 23, 2012 9:35 pm

Re: Save game editing

Postby v3gard » Mon Oct 01, 2012 8:22 pm

v3gard wrote:The editor is available here: https://github.com/v3gard/ftlsg

I've made some updates to my editor. You can now change crew attributes as well as resources and ship hull integrity. I tried compiling it on Windows with cygwin, but unfortunately no luck so far..
fparadis2 wrote:Anyway, I'd be very interested in seeing if anyone has cracked the star map part!

Decoding that looks like a lot of work, but it would definitely be awesome. My next objective is to map out how the items and weapons are encoded, and after that I thought of looking at the star maps.
Jessen
Posts: 14
Joined: Sat Sep 15, 2012 2:30 am

Re: Save game editing

Postby Jessen » Sun Oct 07, 2012 8:28 am

if you can get a version of this for windows, we will REALLY progress forward in the save cracking area.
Agent_L
Posts: 206
Joined: Wed Sep 26, 2012 7:47 pm

Re: Save game editing

Postby Agent_L » Sun Oct 07, 2012 6:01 pm

fparadis2 wrote:Anyway, I'd be very interested in seeing if anyone has cracked the star map part!

Hmm, if the star map (and the sector map) is randomly generated, then I'd save just the RND seed and recreate the map exactly same way every load. It's the "what was visited and what was left" part that'd need serious saving.
Baseline: both beacons map and sectors map could be saved as just one int.
CIA maps of Portugal Please God, don't let Portugal to go to war with USA!