Author Topic: Dump of galaxy wormholes?  (Read 2439 times)

Offline Dr Zoidzerg

  • Newbie Mark II
  • *
  • Posts: 13
Dump of galaxy wormholes?
« on: May 17, 2013, 05:03:31 am »
Is there any way to get a dump of the galaxy's wormholes, from a saved or currently running game?

All I want is a list of pairs, e.g.

Murdoch - Planet 2
Planet 2 - Planet 3
Planet 2 - Planet 4
(etc.)

Offline keith.lamothe

  • Arcen Games Staff
  • Arcen Staff
  • Zenith Council Member Mark III
  • *****
  • Posts: 19,505
Re: Dump of galaxy wormholes?
« Reply #1 on: May 17, 2013, 12:05:41 pm »
I don't think there's such an export, no.  Other than the savegame itself.  I could add one, but may I ask why you want it?
Have ideas or bug reports for one of our games? Mantis for Suggestions and Bug Reports. Thanks for helping to make our games better!

Offline TechSY730

  • Core Member Mark V
  • *****
  • Posts: 4,570
Re: Dump of galaxy wormholes?
« Reply #2 on: May 17, 2013, 12:22:18 pm »
In addition to this, it would be nice to have a way to see/export a mapping of planet ID to planet names.
Come to think of it, wouldn't that be a good thing when debug mode is on? Showing the planet ID next to the planet name in the planet view and galaxy map view or something?
Would really help out trying to figure out what route a ship is going to do, as then we would have a way to cross-reference the numbers the "move to planet" order references.

Offline Dr Zoidzerg

  • Newbie Mark II
  • *
  • Posts: 13
Re: Dump of galaxy wormholes?
« Reply #3 on: May 17, 2013, 06:20:57 pm »
Keith, thanks for considering this. My motivation is to untangle the galaxy map better with the help of some graph layout algorithm, because I do a pretty terrible job by hand. (:

For my purposes the format doesn't need to be very pretty; I am happy to dig it out of a debugging logfile or similar.

Offline Hearteater

  • Core Member
  • *****
  • Posts: 2,334
Re: Dump of galaxy wormholes?
« Reply #4 on: May 17, 2013, 06:57:20 pm »
There is a thread somewhere with some info on the save game format, but I can't find it at the moment.  The save format is pretty straight forward if I recall.

Offline TechSY730

  • Core Member Mark V
  • *****
  • Posts: 4,570
Re: Dump of galaxy wormholes?
« Reply #5 on: May 17, 2013, 08:28:53 pm »
There is a thread somewhere with some info on the save game format, but I can't find it at the moment.  The save format is pretty straight forward if I recall.

You need to turn off savegame compression first, so you can see the plain-text format. But yes, it's pretty easy to figure out.

The things of interest here are the planet list (which has the planet IDs and the planet names) and the adjacency lists of planet connections.

In fact, I could pretty easily write up a program that cross references these and spits them out in a nicer format, or even as a graph for whatever analysis you want to do with it.

Offline Dr Zoidzerg

  • Newbie Mark II
  • *
  • Posts: 13
Re: Dump of galaxy wormholes?
« Reply #6 on: May 17, 2013, 08:35:38 pm »
Ah, it's right there in the save game. I had looked at this a while ago but didn't think to turn off the compression (duh).

I can get what I need from there, thanks everyone!

Offline doctorfrog

  • Hero Member
  • *****
  • Posts: 591
Re: Dump of galaxy wormholes?
« Reply #7 on: May 20, 2013, 07:04:31 pm »
There is a thread somewhere with some info on the save game format, but I can't find it at the moment.  The save format is pretty straight forward if I recall.

You need to turn off savegame compression first, so you can see the plain-text format. But yes, it's pretty easy to figure out.

The things of interest here are the planet list (which has the planet IDs and the planet names) and the adjacency lists of planet connections.

In fact, I could pretty easily write up a program that cross references these and spits them out in a nicer format, or even as a graph for whatever analysis you want to do with it.

What about an "Intel Report" that lists all of the resources, threats, and goodies that each planet has?

Not a super necessary thing, obviously, given that the game keeps an updated list of "things to do," but I've always felt a sortable table of planets and their assets would be nice to have, to avoid wondering around, hovering over things in the galaxy view.

Offline keith.lamothe

  • Arcen Games Staff
  • Arcen Staff
  • Zenith Council Member Mark III
  • *****
  • Posts: 19,505
Re: Dump of galaxy wormholes?
« Reply #8 on: May 20, 2013, 07:20:52 pm »
Ah, it's right there in the save game. I had looked at this a while ago but didn't think to turn off the compression (duh).

I can get what I need from there, thanks everyone!
In theory you could even write to the planet's location fields in the save game record to perform the untangling :)
Have ideas or bug reports for one of our games? Mantis for Suggestions and Bug Reports. Thanks for helping to make our games better!

Offline Dr Zoidzerg

  • Newbie Mark II
  • *
  • Posts: 13
Re: Dump of galaxy wormholes?
« Reply #9 on: May 20, 2013, 08:10:48 pm »
One more question: is the save game compression done by some standard method? In other words, could it be uncompressed (or even recompressed) outside of the game?

In theory you could even write to the planet's location fields in the save game record to perform the untangling :)

 :o

Offline keith.lamothe

  • Arcen Games Staff
  • Arcen Staff
  • Zenith Council Member Mark III
  • *****
  • Posts: 19,505
Re: Dump of galaxy wormholes?
« Reply #10 on: May 20, 2013, 08:44:24 pm »
One more question: is the save game compression done by some standard method? In other words, could it be uncompressed (or even recompressed) outside of the game?
It uses GZip.  Specifically we use Ionic.Zlib.GZipStream from Ionic.Zlib.Reduced.dll .

Quote
In theory you could even write to the planet's location fields in the save game record to perform the untangling :)

 :o
FYI, here's the first bit of the serialization code for the planet object:
Code: [Select]
        Builder.Append( this.PlanetNumber ).Append( '|' );
        Builder.Append( this.GalaxyLocationOriginalCenter.X ).Append( '|' );
        Builder.Append( this.GalaxyLocationOriginalCenter.Y ).Append( '|' );
        Builder.Append( (int)this.Type ).Append( '|' );
        Builder.Append( 0 ).Append( '|' ); //was diffuse color
        Builder.Append( this.ControllingPlayer ).Append( '|' );
        Builder.Append( this.Name ).Append( '|' );
        #region fow
        isFirst = true;
        for ( int i = 0; i < this.LastKnownControllingPlayers.Length; i++ )
        {
            if ( isFirst )
                isFirst = false;
            else
                Builder.Append( ':' );
            Builder.Append( this.LastKnownControllingPlayers[i] );
        }
        Builder.Append( '|' );
        #endregion
        #region linkedPlanets
        isFirst = true;
        foreach ( Planet p in this.LinkedPlanets )
        {
            if ( isFirst )
                isFirst = false;
            else
                Builder.Append( ':' );
            Builder.Append( p.PlanetNumber );
        }
        Builder.Append( '|' );
        #endregion

and the corresponding deserialization:

Code: [Select]
string[] stateParts = StateString.Split( '|' );

        this.PlanetNumber = Convert.ToInt32( stateParts[0] );
        this.GalaxyLocationOriginalCenter.X = Convert.ToInt32( stateParts[1] );
        this.GalaxyLocationOriginalCenter.Y = Convert.ToInt32( stateParts[2] );

        this.Type = (PlanetType)Convert.ToInt32( stateParts[3] );
        //stateParts[4]; //unused
        this.ControllingPlayer = Convert.ToInt32( stateParts[5] );
        this.Name = stateParts[6];

        if ( stateParts.Length > 7 && stateParts[7].Length > 0 )
        {
            string[] fow = stateParts[7].Split( ':' );
            for ( int i = 0; i < fow.Length; i++ )
                this.LastKnownControllingPlayers[i] = Convert.ToInt32( fow[i] );
        }

        if ( stateParts.Length > 8 && stateParts[8].Length > 0 )
        {
            string[] linkedPlanets = stateParts[8].Split( ':' );
            for ( int i = 0; i < linkedPlanets.Length; i++ )
                this.LinkedPlanetIds.Add( Convert.ToInt32( linkedPlanets[i] ) );
        }

Before anyone asks: yes, we are aware that there are massively more efficient ways to do this, and in fact our later stuff is much more efficient, but this particular bit really doesn't need the optimization and the chance of breaking something outweighs the benefit ;)
Have ideas or bug reports for one of our games? Mantis for Suggestions and Bug Reports. Thanks for helping to make our games better!

Offline TechSY730

  • Core Member Mark V
  • *****
  • Posts: 4,570
Re: Dump of galaxy wormholes?
« Reply #11 on: May 20, 2013, 09:48:03 pm »
Before anyone asks: yes, we are aware that there are massively more efficient ways to do this, and in fact our later stuff is much more efficient, but this particular bit really doesn't need the optimization and the chance of breaking something outweighs the benefit ;)

Hey, it's more space efficient than XML is. :D

Offline Dr Zoidzerg

  • Newbie Mark II
  • *
  • Posts: 13
Re: Dump of galaxy wormholes?
« Reply #12 on: May 21, 2013, 08:26:14 am »
Thanks again Keith for this information -- I am having a lot of fun digging around in my save games.

Is there some step other than compression in writing and reading the compressed save files? It looks like they are base64 encoded.

Offline keith.lamothe

  • Arcen Games Staff
  • Arcen Staff
  • Zenith Council Member Mark III
  • *****
  • Posts: 19,505
Re: Dump of galaxy wormholes?
« Reply #13 on: May 21, 2013, 09:20:15 am »
Thanks again Keith for this information -- I am having a lot of fun digging around in my save games.

Is there some step other than compression in writing and reading the compressed save files? It looks like they are base64 encoded.
Yes, I think you're right about that.  I didn't actually write the steps that take it from the "normal text" to what you see in the compressed files so I don't remember them all.  I could post those bits of the serialization/deserialization but I'm thinking you may actually be able to get those answers faster (and more completely) by using .NET Reflector (there's a free version, any recent one should work because this is actually compiled in VS despite being run in mono) on Assembly-CSharp.dll in (ai war directory)\AIWar_Data\Managed ; the deserialization (the part you're trying to emulate, at least at first) really gets going in case 12 in the switch statement in method ContinueLoadingGame in class Game, where it calls Compressor.DecompressStringGZip.
Have ideas or bug reports for one of our games? Mantis for Suggestions and Bug Reports. Thanks for helping to make our games better!

Offline Dr Zoidzerg

  • Newbie Mark II
  • *
  • Posts: 13
Re: Dump of galaxy wormholes?
« Reply #14 on: May 21, 2013, 09:41:22 am »
Thanks Keith, that was just what I needed to figure it out.