Created
November 19, 2013 09:44
-
-
Save sj26/7542852 to your computer and use it in GitHub Desktop.
Hacking Spacebase DF-9 saves
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# They're just deflated messagepack dumps of lua data. | |
require "zlib" | |
require "msgpack" # gem install msgpack | |
# **BACK IT UP FIRST** | |
save = MessagePack.unpack(Zlib::Inflate.new(-15).inflate(IO.read("#{ENV["HOME"]}/Documents/SpacebaseDF9/Saves/SpacebaseDF9AutoSave.sav"))) | |
# ... do things to `save` ... | |
IO.binwrite("#{ENV["HOME"]}/Documents/SpacebaseDF9/Saves/SpacebaseDF9AutoSave.sav", Zlib::Deflate.new(9, -15).deflate(save.to_msgpack)) |
You'll need to run irb
which gives an interactive ruby prompt. The save
variable once loaded gives you a big hash of objects which you can manipulate, then afterward.
Here's what the hash should look like (I've truncated because it's huge):
~$ irb -r zlib -r msgpack
irb> save = MessagePack.unpack(Zlib::Inflate.new(-15).inflate(IO.read("#{ENV["HOME"]}/Documents/SpacebaseDF9/Saves/SpacebaseDF9AutoSave.sav")))
=> {"elapsedTime"=>11832.718140666817, "nLastNewShip"=>10167.058132673592, "sStarDate"=>"9133.5", "bHasZoomed"=>true, "tEventControllerState"=>{"tNextEventData"=>{"nNumSpawns"=>1, "nNumMaladies"=>0, "tPrerolledMalady"=>{"nAdditionalDeadliness"=>0.2, "tSymptomStarts"=>[11316.302518571782, 11700.302518571782], "sMaladyName"=>"Parasite", "nChanceToInfectCharacter"=>0.05, "bSpreadTouch"=>false, "sMaladyType"=>"Parasite", "sSpecial"=>"parasite", "tDurationRange"=>[600, 2000], "nImmuneChance"=>0.5, "nFieldTreatSkill"=>99999, "nMaladyStart"=>10840.302518571782, "bSpreadSneeze"=>false, "tImmuneRaces"=>[], "nCurrentStage"=>0, "nPerceivedSeverity"=>0.2, "sFriendlyName"=>"DISEAS003TEXT", "nBacteriaLifetime"=>180, "bCreateStrains"=>false, "sDesc"=>"DISEAS023TEXT", "tSymptomStages"=>[{"tTimeToSymptoms"=>[180, 480], "sSymptomLog"=>{"priority"=>2, "lineCodes"=>["SFPARA001CITZ", "SFPARA002CITZ", "SFPARA003CITZ", "SFPARA004CITZ", "SFPARA005CITZ", "SFPARA006CITZ", "SFPARA007CITZ", "SFPARA008CITZ", "SFPARA009CITZ"]}, "tReduceMods"=>{"Hunger"=>1.5}}, {"tTimeToSymptoms"=>[600, 900], "sSpecial"=>"parasite"}], "nChanceToInfectObject"=>0.2, "nSeverity"=>1}, "nAlertTime"=>11873.312518571782, "nUniqueID"=>52, "nDifficulty"=>0.915, "nStartTime"=>11918.312518571782, "sEventType"=>"immigrationEvents"}, "tSpawnModifiers"=>{"derelictEvents"=>1.0652396492877174, "dockingEvents"=>1, "immigrationEvents"=>1.0960942124628192, "breachingEvents"=>0.8089999999999999, "meteorEvents"=>1.612, "hostileImmigrationEvents"=>0.8089999999999999}, ...}, ...}
irb(main):003:0>
The copy of zlib
in Ubuntu on Windows doesn't seem to always flush streams properly, causing premature ends. Some explicit instruction with .deflate(save.to_msgpack , Zlib::FINISH)
is required for it to work.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The line
save = MessagePack.unpack(Zlib::Inflate.new(-15).inflate(IO.read("#{ENV["HOME"]}/Documents/SpacebaseDF9/Saves/SpacebaseDF9AutoSave.sav")))
Where does that need to be entered? Entering it in Terminal for OSX for example gives nothing but Syntax errors.
Running it through Ruby also does nothing. I am definitely missing a step here.
Is there another way to Inflate and deflate the .sav files? The deeper I dig into getting the RB to run the more it breaks other applications in my system.