Reading directly from the savefile

Discuss all aspects of editing the data and databases in EHM here. Have a question about the EHM Editor, EHM Assistant, editing the .cfg files, hex editing the .dat or .db files? Want to tweak the EHM exe file to change league rules/structure, start date etc? This is the place!
Forum rules
This is the forum to discuss all aspects of editing the EHM data and tweaking the game.

Have a bug or feature request for the EHM Editor? Post them in the EHM Editor thread. Please start a new thread or post in another thread if you have a question about how to use the EHM Editor.

Given the large number of questions on similar topics, we ask that you start a new thread for a new question unless you can locate a similar question in an existing thread. This will hopefully ensure that similar questions do not get buried in large threads.

Useful links: EHM 1 Assistant (Download) | EHM 1 Editor (Download) | EHM 1 Editor Tutorials | Editing Rules & Structures Guide | Converting EHM 2004 / 2005 DBs to EHM 1 | Converting an EHM 2007 DB to EHM 1 | Extra_config.cfg | Import_config.cfg | Player Roles
Post Reply
Mahrgell
Learning to skate
Posts: 3
Joined: Tue Feb 27, 2018 8:30 pm
Favourite Team: Montreal Canadiens

Reading directly from the savefile

Post by Mahrgell »

Hi there,
for the purpose of some Discord Sim league, I was looking for a way how it would be possible to read data directly from the save file.
The idea is to write a Discord bot which can then automatically read the savefile and create various summaries and answer requests.

Data I would be interested in includes:
- standings of a league
- results of a league
- player/team stats
- player attributes
- player contracts
- potentially more, but that should do for the moment

Sadly I have only found information how to use the Data Editor, but for my purpose I would really need to read the data myself from the savegame.
Since the Editor as well as EHM assistant are obviously able to do so, I would love to know if there is some information (or even documentation :-o ) on how the data is stored in the save file.

The necessary coding knowledge to write the bot with that information is available ;)
User avatar
archibalduk
TBL Admin Team
Posts: 20372
Joined: Tue Jul 06, 2004 8:44 pm
Custom Rank: Seaside + Fruit Juice Mode
Favourite Team: Guildford (EPL) / Invicta (NIHL)
Location: United Kingdom
Contact:

Re: Reading directly from the savefile

Post by archibalduk »

Unfortunately this would be extremely difficult to achieve. From your list:

- standings of a league - This might be possible with a lot of work
- results of a league - This might be possible with a lot of work
- player/team stats - Very difficult but this might be possible with a lot of work
- player attributes - Achievable (already accessible via the Editor)
- player contracts - Very difficult but this might be possible with a lot of work

The saved game is basically an expanded version of the database. In other words, the saved game consists of a large number of data tables. The Editor and the Assistant are very different. The Editor accesses the database/saved game and parses/decodes the data. The Assistant instead accesses the data loaded into the RAM by the game. I can't say for certain whether all of the game data is always in the RAM or whether some of it is buffered in temporary files (which I know the game does use) and is simply loaded to the RAM as and when needed. So accessing the data via the file *might* be the better method.

To access the saved game, you'll need to parse the saved game index and all related tables (i.e. the club, league and player tables) in order to make sense of the various data you want to export. The saved game (and the database) is a relational database which means that the tables contain lots of ID numbers linking to items in other databases. I can share the relevant club/league/player data structures with you if Riz agrees. However, that will only get you 50% of the way. Aside from the player attributes, all of the tables you mention above are tables specific to saved games and SI does not divulge the structure of saved game tables. So you'll need to figure this out yourself. And this is where it starts to get difficult. Not only is it a lot of trial and error, but certain tables can have variable length rows of data (i.e. because it contains arrays) - so it isn't always possible to identify patterns or indeed parse the data unless you can figure out where in the data the variable lengths are flagged and how the variable data is structured.

I have thought about trying to add some saved game exporting to my Editor because I can see how that could be of benefit to people playing the game and especially online leagues. However, it's not something I'd get to for a long time because I have to prioritise work which benefits the roster updates. That said, I can show you how to export the relevant raw data (in hex code) from the saved game using the Editor for you to look at - if you can figure out the patterns/structure then I could add this to the Editor sooner rather than later and this might speed things up. I also have some random notes on parts of the saved game I partially-decoded when I was experimenting with EHM 2007 (and there is an old thread on these forums that provides some basic structures too).
Mahrgell
Learning to skate
Posts: 3
Joined: Tue Feb 27, 2018 8:30 pm
Favourite Team: Montreal Canadiens

Re: Reading directly from the savefile

Post by Mahrgell »

Heya,
yeah, I kinda assumed that it was mostly saved in some sort of database structures.
If you could share the format of those data structures you know this would already be a great starting point. How to work with relational databases I do know. I would just need the format.

And for decoding the rest... Sounds like a daunting, yet interesting task. If my first attempts with the easily accessible data are successful, I could also give this a go.
User avatar
archibalduk
TBL Admin Team
Posts: 20372
Joined: Tue Jul 06, 2004 8:44 pm
Custom Rank: Seaside + Fruit Juice Mode
Favourite Team: Guildford (EPL) / Invicta (NIHL)
Location: United Kingdom
Contact:

Re: Reading directly from the savefile

Post by archibalduk »

I have dropped Riz an email. I'll get back to you once I hear from him. He is generally extremely busy (he works on EHM in his spare time) - so it might take some time to come back to me.
Mahrgell
Learning to skate
Posts: 3
Joined: Tue Feb 27, 2018 8:30 pm
Favourite Team: Montreal Canadiens

Re: Reading directly from the savefile

Post by Mahrgell »

Time has passed...

I'm still interested in it, has there been any response by Riz?
User avatar
nino33
Mr. Goalie
Posts: 6088
Joined: Sat Aug 07, 2010 3:37 am
Custom Rank: Retro Rosters Specialist
Favourite Team: 1970s hockey

Re: Reading directly from the savefile

Post by nino33 »

Mahrgell wrote:Time has passed...

I'm still interested in it, has there been any response by Riz?
FYI - I’ve waited months before for replies; I think 2 weeks passing is basically no time at all
User avatar
archibalduk
TBL Admin Team
Posts: 20372
Joined: Tue Jul 06, 2004 8:44 pm
Custom Rank: Seaside + Fruit Juice Mode
Favourite Team: Guildford (EPL) / Invicta (NIHL)
Location: United Kingdom
Contact:

Re: Reading directly from the savefile

Post by archibalduk »

Mahrgell wrote:Time has passed...

I'm still interested in it, has there been any response by Riz?
As it happens, he emailed this morning to say he is running this query by his colleagues at SI Games. I'll let you know once I hear anything further but, as I said, it takes him time to get back to me because of his workload. And like Nino said, two weeks is nothing - be prepared to receive a response any time between now and April/May.
User avatar
archibalduk
TBL Admin Team
Posts: 20372
Joined: Tue Jul 06, 2004 8:44 pm
Custom Rank: Seaside + Fruit Juice Mode
Favourite Team: Guildford (EPL) / Invicta (NIHL)
Location: United Kingdom
Contact:

Re: Reading directly from the savefile

Post by archibalduk »

I have had a response. Can you drop me an email with your email address please? Mine is ehmtheblueline AT gmail DOT com
pretzalcoatl
Junior League
Posts: 18
Joined: Wed Dec 30, 2015 10:26 pm
Favourite Team: Capitals

EHM 1 Database & Saved Game Editor

Post by pretzalcoatl »

I'm trying to make a tool that will pull player season histories from saved games to create a viewable database for a league playthrough

Do you have any pointers as to what format the saved games are saved as?

(alternatively, it looks like EHM stores its in-game database in C:\Users\USERNAME\AppData\Local\Sports Interactive\EHM\Temporary and that could work too)

this is all SQLcipher-encrypted sqlite, or am I wrong?
User avatar
archibalduk
TBL Admin Team
Posts: 20372
Joined: Tue Jul 06, 2004 8:44 pm
Custom Rank: Seaside + Fruit Juice Mode
Favourite Team: Guildford (EPL) / Invicta (NIHL)
Location: United Kingdom
Contact:

Reading directly from the savefile

Post by archibalduk »

I have moved your post to the correct thread. No, it's not SQL. It's a custom binary structure.
yoye
Learning to skate
Posts: 3
Joined: Thu Feb 14, 2019 12:34 pm
Favourite Team: Redwings

Reading directly from the savefile

Post by yoye »

Does OP get a positive response ? I'm insterested too, I want to create an HTML exporter because those generate in game are not really good and even add wrong HTML structure.
User avatar
archibalduk
TBL Admin Team
Posts: 20372
Joined: Tue Jul 06, 2004 8:44 pm
Custom Rank: Seaside + Fruit Juice Mode
Favourite Team: Guildford (EPL) / Invicta (NIHL)
Location: United Kingdom
Contact:

Reading directly from the savefile

Post by archibalduk »

IIRC I gave him some initial details after getting Riz's approval but I don't think the OP took it any further as he never came back for further details. I'm not sure people realise how big of a task trying to process the saved game data is. It's a big task getting the database data within the saved game decoded (even with the full structure details) but trying to figure out the saved game structure with no details is really tough.
yoye
Learning to skate
Posts: 3
Joined: Thu Feb 14, 2019 12:34 pm
Favourite Team: Redwings

Reading directly from the savefile

Post by yoye »

archibalduk wrote: Thu Feb 14, 2019 7:55 pm IIRC I gave him some initial details after getting Riz's approval but I don't think the OP took it any further as he never came back for further details. I'm not sure people realise how big of a task trying to process the saved game data is. It's a big task getting the database data within the saved game decoded (even with the full structure details) but trying to figure out the saved game structure with no details is really tough.

could I have the same details in PM or I need to send you an email ?
User avatar
archibalduk
TBL Admin Team
Posts: 20372
Joined: Tue Jul 06, 2004 8:44 pm
Custom Rank: Seaside + Fruit Juice Mode
Favourite Team: Guildford (EPL) / Invicta (NIHL)
Location: United Kingdom
Contact:

Reading directly from the savefile

Post by archibalduk »

You would need to ask Riz for his permission. I cannot share anything unless he tells me it is okay. Otherwise my Editor would be open source.
Post Reply