Jump to content
Daerandin

Profile Statistic (Dat File)

Recommended Posts

Recently I managed to obtain all Stronghold Legends trophies. The most annoying one for me was, without a doubt, the "10 days in-game" award. I tried to poke around the dat file for my game profile but couldn't figure it out, so instead I just left the game on overnight and while at work for a few weeks. Feels great to finally have all the awards, but I still want to figure out the dat file.

Since in-game time is the one thing I really wanted to work out, I have decided to start there. My efforts so far have been to use two profiles. This way I can read my in-game time for one profile, and ensure it does not change by using the other profile to exit the game. Then I examined the dat file with a hex editor to look for a number that would equal the game time. This gave me no results.

I looked for hexadecimal values that would equal my in game:

  • seconds
  • seconds + minutes (converted to seconds)
  • seconds + minutes + hours (converted to seconds)
  • seconds + minutes + hours + days (converted to seconds)
  • hours
  • days
  • days + hours (converted to hours)

None of these gave me any results. My worry is that the dat file is not pure binary data of profile stats, but possibly compressed. Still, I don't want to give up so I will change my approach. I will check in-game time for one profile, then make a copy of the dat file at that state. Then increase in-game time, and make another copy of the dat file. Then I intend to compare the files and see if the increase in game time has resulted in an equivalent increase in some value, hopefully equaling the difference in seconds. Provided I find an easily identified change, I intend to change it directly and then see how it affects profile statistics in-game.

EDIT: Forgot to mention, I'm doing this on the Steam Edition. I don't know if there is a big difference between the editions, but for now I don't feel like digging out my old SHL disc.

Edited by Daerandin

Share this post


Link to post
Share on other sites

I'm back. Seems like my motivation takes a year to get going....

Anyways, after having been busy with other stuff I finally got around to looking at this again. The actual .dat file is zlib compressed. Once decompressed it is still a binary format, but possible to read and modify. I was able to verify this by finding in-game time and also seeing it change correctly between game sessions.

I do have a full award cabinet on my old profile, so I intend to start a new profile and begin to map interesting data. What I hope to do is figure out how to unlock all campaigns+trails, as well as making it easy to fill the award cabinet. Some of those were painful to get (10 days in-game).

If anyone else is interested in this, you need to use zlib to decompress the stats.dat file. Then you can use a hex editor to have a look at the file. Make sure to use little-endian decoding, otherwise the decimal conversions will be incorrect.

The in-game time variable is stored at offset 0x7b8 as a 32-bit value. I am not sure if it is signed or unsigned, and that does not really matter either. You need more than 68 years in-game time for that to matter.

Share this post


Link to post
Share on other sites

This is what I have been able to create so far. It has mostly just been the boring process of matching values in the file with the in-game stats page. Unfortunately, most of these are not really that interesting as they don't help with getting awards, except for the in-game time. Still, having these values mapped will certainly help in finding the more interesting stuff. Note that there does not appear to by anything useful before offset 30, so no point looking there.

The rest of the data might take some time. I will probably first try to unlock stuff and then see how the file changes to look for patterns.

map.txtFetching info...

Share this post


Link to post
Share on other sites

I finished mapping the file, at least I think so. The final values were all associated to the awards cabinet. So far I only know how to set it so that you have the award. So if you want a full awards cabinet, just use the attached list for reference. The 3-digit hexadecimal value is the offset in the dat file, after you have decompressed the file. Ensure the four bytes at that address are modified to the hexadecimal Value in my list. You will obviously need to compress the file again for the game to be able to use it.

The more interesting thing to figure out is how to make you "qualify" for each award so that it will be unlocked when next you finish a match. The "True Dedication" award is simple, just need to ensure the value for in-game time is more than 10 days. In hexadecimal that is D2F00, but since the file is in little-endian, the value has to be: 00 2F 0D which is exactly 10 days of in game time, in seconds.

As far as I understand, Steam achivements are unlocked when you get an in-game award in the post-game screen. So just getting all awards this way would not do anything for Steam achievements.

Campaign/Trails progress is not tracked in this file, so that's also something I want to look into.

If anyone want help in how to modify the file, just message me. In time I might make a program to handle these modifications. But for now I want to gather more data.

 

full_map.txtFetching info...

Share this post


Link to post
Share on other sites

Unlocking all campaigns+trails can be done in the config.dat file, and I have figured out how. I created a simple test program to modify the uncompressed file. I obviously needed to manually uncompress and compress the file, but as a proof of concept it did the job. A brand new profile had all campaigns+trails unlocked. Additionally, this will also give you awards for having completed all campaigns and trails when next you play any map.

It is likely that I will create a program to automate such modification as I assume most people are not particularly comfortable with modifying binary files directly with a hex editor.

In any case, for now it is fully possible to do so , although the process is a bit more convoluted than with the stats.dat file. Things are not at a permanent offset within the file. Profile name can be of a variable length, so there is a unique byte sequence to denote the end of profile name, and beginning of the rest of the file. All the offsets I have gathered here are from the final byte of the special end-of-name sequence. As with the previous file, all offsets are in hexadecimal.

unlock_campaigns.txtFetching info...

Share this post


Link to post
Share on other sites

Update! I have figured out how to make the game give you awards after a match, if you qualify or not. This will also give you the related Steam Achievement if you don't already have it. However, in order to do this I need to modify the game code in memory while the game is running. I realize that such a tool runs afoul of this sites rules, so I'm not going to promote it here.

However, I am also going to get started on making tools to modify the two files related to your profile. Such tools should not go against site rules as those files are not compiled data. I will probably start working on that sometime during next week.

Share this post


Link to post
Share on other sites

This research is very interesting. I had been independently working on some similar attempts.

How did you discover the zlib compression method and what did you use to decompress it?

Share this post


Link to post
Share on other sites

Hey, I haven't been looking at this stuff for quite a while now.

In short, I simply used the 'file' utility on Linux, which tells you that it is zlib compressed data.

Speaking of this again, perhaps it is time I actually get started on making a program to modify those files. I was planning on doing it long ago, but other stuff came up.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Similar Topics

    • Problem in Uploading Download File

      Im done working on stronghold crusader night mod and its ready for upload now but 4 days ago I tried to upload it to the downloads hub I gave all the info and tap on upkosd buttom it showed a loading icon in the screen I  thinked: maybe because it wad 62mb sized its uploading now but one hour later it was still in that loading screen why? Pls help me I worked really hard on the mod I want it to? Be released with no problems

      in Site Questions and Support

    • Modding With Any Image File

      Can I file with any image file that I want to use on Stronghold 2? I want to know what to do step by step to make the armoAle to save it correctly. When I use the alpha channels nothing seems to work.

      in Stronghold 2

    • Configuration/settings file

      I know it is still early in some countries, so good morning/afternoon/evening! I've tried browsing Internet for any information on how to edit (if possibel at all) some SH 2 files so as to adjust some economy buildings to produce more. (Sorry, if there is already an answer somewhere on the forum) For example, I personnaly don't like it when a candle worker only makes a couple candles at a time, which is so little!(Often there is not enough space on the map to provide optimal production to mainta

      in Stronghold 2

    • Server error when viewing user profile.

      I get the following error when attempting to view my profile.   The server encountered an internal error or misconfiguration, we've been unable to display the page you requested. We apologise for the inconvenience this may have caused, use the link below to try again, alternatively you can return to the board index. Errno [ 8 ]: Undefined variable: panther_users in /home/path/to/profile.php on line 1833

      in Site Questions and Support

    • Unable to submit file

      Hello,you can help me? I can't upload my custom map here.I'm try; winrar winzip 7zip   But when i try upload coming this error message; ''you are only allowed to upload zip archive''

      in Site Questions and Support

×
×
  • Create New...