Jump to content

Reading the .sav files


MLBTinker

Recommended Posts

I've done some work with the dyansty files and am now able to read the schedule, the list of teams and print out a game list with results (r/h/e and the portion of the linescore that is saved.)

The next work will be on the standings, since the w/l totals appear to be identifiable in the file.

EA did leave a bug - inning scores over 7 are misreported when a linescore is reopened within the game.

After standings, I think the next bit would be on reading season stats.

I don't know if I can get to editing the data.

I know where the season data is, but have to do some math work to determine what categories are combined into one byte in the file. They seem to have used an algorithm that combines several data points into a 4-byte combinations.

Link to comment
Share on other sites

  • Replies 113
  • Created
  • Last Reply

I started with a program I created a long time ago to translate Front Page Sports Football Pro files - it reads each byte and spits out the ASCII value into a space-delimited text file.

I dumped the result into Excel and began to look for patterns. I also translated the file where anything A-Z or a-z would appear as the character. That second translation provided the locations of the Team Names and Player Names.

I assumed that a dynasty file would start with the .dat files in the data directory, so I began to look for the Team Ids as 4-byte patterns in the file. It took a bit, because they appear in reverse order (0x01020304 becomes 4 3 2 1.)

I also played the opening game and then compared the byte outputs for differences. Once I had the schedule portion identified, it was just comparing the bytes to the data as presented in the game. There are some bytes I don't know about within the schedule portion yet, but I found the team ids, visitor runs/errors (in one byte), visitor hits, visitor linescore and corresponding home info (which is actually first in the file.)

There is also a byte for extra innings, one for the day, and one for the scheduled game time.

The schedule is the last portion of data in the file - about the last 1/4.

This might be a bit more than you asked, but it might help others looking at the file.

Link to comment
Share on other sites

MLBTinker,

What about rosters and lineups, have you identified them?

I think you should contact RGlass about developing an app to modify the .sav file. I’d be interested in developing such an application, but RGlass's could probably be modified to import the .sav file.

Now that you have decrypted this file do you see any major problems with altering the file and trying to re-encrypting it?

Link to comment
Share on other sites

MLBTinker,

What about rosters and lineups, have you identified them?

I think you should contact RGlass about developing an app to modify the .sav file. I’d be interested in developing such an application, but RGlass's could probably be modified to import the .sav file.

Now that you have decrypted this file do you see any major problems with altering the file and trying to re-encrypting it?

Slow down, man. He's still got a long, long way to go.

Re-encrypting is a whole different story.

Two words for all of you:

Good luck.

MVP has a checksum (I believe multiple, actually) on the file, which verifies that the SAV file is not corrupt. Unfortunantly, this means that if you make just one change to the file, the checksums have to be updated or the file will be corrupted, and will not load in the game. And to update the checksums, you have to know the algorithm to do so.

High Heat didn't employ this stuff until 2K4, and only then on the MF files I believe. I have spoken to DangerZ about it and he basically asked me if I had any contacts with the EA development team, as he was in contact with the 3DO team from time to time. :lol:

After that, you would have to figure out what each byte in the SAV file stands for. I've done a little of the mapping, but on a 1 MB file (1,000,000 bytes - roughly), that would take some time - and it's a lot harder when you can't edit it to see what changes you can make.

Is it doable? Yeah, but it is going to take a great programmer a la DangerZ and a lot of time.

Uh, not to sell myself short, I am a pretty good programmer too. :D But I have a lot to learn.

At least if we could take stuff out of the file, like exporting stats, though... that would at least be beneficial.

Link to comment
Share on other sites

Ok. I spent a good portion of the morning on this and here's what I've been able to do:

The player section is near the beginning of the .sav file (actually about 850 bytes into the file.) There are two initial sections of player data - 12-byte records that consist of the player's ID (initially similar to the ID in the attrib.dat file), and then the location in the next section of that player. The location is repeated for some reason. Each of these fields consists of 4 bytes.

After an 8-byte header (or maybe a 4-byte header and a checksum :( , the next section of 2500 records contains the information from the attrib.dat file. I've decoded about 37 of the 44 fields. Unfortunately, it appears that some key fields (pos1, pos2) are split between bytes, so the math will take another day. The information is nowhere near the attrib.dat order.

I also reviewed the section of the file between the team data and the schedule (about 990k into the file.) It is the roster data. I even looked at team 0 (Anaheim) and noted that the first player ID is B. Molina's, so it works. This section contains the four batting orders and defensive positions as well as rotation information. The data here is easily decoded as most of the bytes are equal to the value represented.

I hope to have a basic executable that takes the file and spits out various tables to .txt files for viewing. Since I only have a limited number of dynasty files, this will work out the kinks in testing the layouts.

I need to relook at that first 850 bytes. It appears that the slider data is contained (a lot of 50's in the data.) I wonder if the controlled team is in that portion and how hard it would be to create a mod to switch teams mid-season.

I'll post an update tomorrow.

Link to comment
Share on other sites

This would be awesome if you can get stats and stuff out of the save file...

also being able to edit other teams line-ups in dynasty mode would be nice, the stupid CPU "optimizing rosters" thing everytime someone is hurt or traded is crap!

Link to comment
Share on other sites

Here is my update for the weekend -

I have mapped the entire file from start to end - the basic layout is:

Dynasty Header information (about 850 bytes)

Player information in 21 sections in the following order - byte length of each record in []

ID Table [12]

Names and Attrb [68]

Career Stats [16]

LH Attrib [16]

RH Attrib [16]

LY Batting Stats (the bstats.dat) [4]

LY Fielding Stats (the fbstats.dat) [8]

LY LHB Stats [12]

LY RHB Stats [12]

Twelve blocks of season stat information - Batting Stats, fielding stats, LH and RH stats for the MLB, AAA and AA levels (MLB, MLB, MLB, MLB, AAA, AAA ...)

Pitcher Table and Data in 15 sections-

ID Table [12]

Attributes [20]

Career Stats [16]

LY Stats [16]

LH Stats [12]

RH Stats [12]

Nine sections of season stats - [16,12,12,16,12,12,16,12,12] Again, MLB, AAA and AA info

Team Information in 5 sections -

ID Table [12]

Names and Attrib [80]

Roster, Batting Order, Postion Lineups and Pitching Roles [variable, but about 506-514 per record] THIS WAS THE HARD ONE - ALL OTHER RECORDS ARE FIXED LENGTH

Current Record [4]

LY Record [4]

Manager information in 2 sections -

ID Table [12]

Names and Attrib [48]

Organization information in 2 sections -

ID Table [12]

Attrib [40]

Schedule in one three sections [28] - one for each level, separated w/ header

In a default file, there are 2500 players, 1600 pitchers, 100 teams, 100 managers and 30 organizations.

I have one program the exports the byte data into subfiles and am working on a Visual Basic Program to read the exported data and create HTML output.

I have a VB program that lists the roster, rotation and four lineups for each team. I will add the stat information next. If anyone has suggestions on output and formats, please do not hesitate to ask.

Since I have a limited number of dynasty test files, I am interested in that header information to protect against differences between the .sav's I'm working with and others out there.

Link to comment
Share on other sites

I've got a program that decodes the file, and then creates files with the batting orders, season stats, standings, and schedule.

I need to test the program against multiple .sav files to determine if there are any other variable length items I need to know about.

I'll try to get something posted early next week so that others can try it against the .sav files.

I did find a bug in the game while doing this - games played in manage mode do not add a "game in field" to the player's fielding statistics.

I need to add some pitching output, clean up the file selection inside the program, and then try it on another machine w/o the program files.

Link to comment
Share on other sites

Congrats MLBTinker! You've got more ambition than I. I started looking at the SAV files for about two weeks after I got MVP but I got so darned frustrated trying to figure out how they computed the checksum at the beginning of the file that I just gave up. I focused on the options file and tweaked a setting one way or the other inside the game and then watched how it affected the checksum in the options SAV file. I tried a bunch of different things and just could not find a pattern. So I gave up before I even got to the dynasty SAV file. I commend you for your patience - being able to pull the information from the dynasty file is a huge step forward!

Now the question is - how on earth do we crack the checksum so we can edit this puppy?

Great work, MLBTinker! Keep us all posted.

Link to comment
Share on other sites

I've got a completed version of a reader/writer that performs the following:

Reads the .sav file and breaks it down into the record tables.

Converts the tables into:

Player Listing

Team Listing

Batter Statistics (Majors only right now)

Pitching Statistics (Ditto)

Schedule w/ results (Ditto)

Standings (all Leagues)

Team Roster, Batting Order, Defensive Positions and Rotation information

The output is in a comma-delimited .txt file. You can select the source .sav and destination files.

I believe the only variable nature in the files is the roster information section. I'm simming a season to the next year to see if it adds to the length of file somewhere else (currently I get 1,294,536 byte files from the default info.)

Next step is to add the minor league information and perhaps some alternative output formats.

After that, I'll try editing the files.

Anyone have any pre-release suggestions?

Link to comment
Share on other sites

Next step is to add the minor league information and perhaps some alternative output formats.

That would be great (output formats) maybe html? As for suggestions besides the stuff that you say it can already achieve which is superb, how about taking it one step further and finding or breaking into the "around the league news" (trades, stats leaders, email box etc..) if you have the time, which are stored in the sav file for a dynasty.

Maybe add to that a box score opportunity (breakdown of the games in the schedule) or if not possible a line score.

Link to comment
Share on other sites

would the .sav file help people...

a) create dynasties with variable ammount of games per season

B) set up playoff games to be played at night

these might be way down the line but im wondering if this is the right thread :)

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.


×
×
  • Create New...