Project: C&C1(Tiberian Dawn) gold/95 edition Savegame Ed

Discuss whatever you want here--both QB and non-QB related. Anything from the DEF INT command to the meaning of life!

Moderators: Pete, Mods

Post Reply
dkg
Newbie
Posts: 8
Joined: Mon Mar 31, 2008 2:29 am

Project: C&C1(Tiberian Dawn) gold/95 edition Savegame Ed

Post by dkg »

Hi all. Here I will be posting my progress, if any, with my new project. A savegame editor for Westwood's first game in the C&C series, Tiberian Dawn (gold/95 edition).

1. why QB?
2. Why c&c1?
3. why savegame editor?
4. Why post this here?

1. I find QB relaxing and enjoyable to use, and it gets small jobs done fast (when I say fast I mean the time it takes to write a working program/utility, not the execution time neceseraly)

2. ...if you asked, please slap yourself. ESPECIALLY since EA released the game for free.

Another answer to the 1st and 2nd questions is a simple one. They were both dear to my heart at one of the happyest times of my life (a life I seem to have neglected for some years in preference of alcoholism) Now that I'm back, it seems a good place to start.

3. I've found well-written documentation of all the other c&c1 file formats (and programs utilising that info) but nothing on the savegame format. And I love a challenge.

4. As I said, I feel most comfortable in the (yes rather restrictive at times) familiar realms of Quick Basic. So why here? This has been, is and always will be my QB bible. Anything I'm unsure of, or just a way of doing something I hadn't thought of, I can find here.

Posting here is my way of, hoping, to give something back to the, surprisingly still active, comunity.


I don't promise a full blown savegame editor with all possible options, but what I will do is try to get an understanding of westwood's savegame.xxx file format, showing all reasoning and attempts(failed too) step by step. I hope that someone will find it interesting, usefull or educational.

I've written far to much so far so I'll introduce myself another time.
dkg
Newbie
Posts: 8
Joined: Mon Mar 31, 2008 2:29 am

Post by dkg »

For my 1st attempt I created an ampty map with one minigunner in the top corner of the screen. Replaced GDI's 1st mission, started a new game and saved.

2nd Waited then saved again (time passed must be stored in the savegame somewhere too)
3rd save I moved the minigunner right by one square,
4th no change
5th back again should be the same as the 1st and second, other than time passed and shroud uncovered.

When I had my saves I fired up a, stolen:[, copy of a hex editor and prepared to congratulate myself before clicking the "compare" option.

Not the results I had planned. There were far more differences than I thought there would be. After staring at a bunch of meaningless hex values for some time I noticed that there was some hope, a quite similar repeating block of garbage in all the files, just with differing offsets.

Now I'm not the type with the patience to wade through uncomprihensible gibberish trying to make sense of it. And I don't have the skill or understanding to step through a backtrace in some debugger (ollydbg?softice?) But I don't give up at the 1st hurdle.


What next? got my copy of sysinternals "Filemon.exe" to see what westwood is doing when saving, or loading for that matter, a savegame.


Promising results.
[code]
FASTIO_READ Offset: 0 Length: 44
FASTIO_READ Offset: 44 Length: 4
FASTIO_READ Offset: 48 Length: 1
FASTIO_READ Offset: 49 Length: 4
FASTIO_READ Offset: 53 Length: 1
FASTIO_READ Offset: 54 Length: 4
FASTIO_READ Offset: 58 Length: 1686
FASTIO_READ Offset: 1744 Length: 4
FASTIO_READ Offset: 1748 Length: 2
FASTIO_READ Offset: 1750 Length: 4
FASTIO_READ Offset: 1754 Length: 33
FASTIO_READ Offset: 1787 Length: 2
FASTIO_READ Offset: 1789 Length: 4
FASTIO_READ Offset: 1793 Length: 33
FASTIO_READ Offset: 1826 Length: 2
FASTIO_READ Offset: 1828 Length: 4
FASTIO_READ Offset: 1832 Length: 33
FASTIO_READ Offset: 1865 Length: 2
FASTIO_READ Offset: 1867 Length: 4
FASTIO_READ Offset: 1871 Length: 33
FASTIO_READ Offset: 1904 Length: 2
FASTIO_READ Offset: 1906 Length: 4
FASTIO_READ Offset: 1910 Length: 33
FASTIO_READ Offset: 1943 Length: 2
FASTIO_READ Offset: 1945 Length: 4
FASTIO_READ Offset: 1949 Length: 33
FASTIO_READ Offset: 1982 Length: 2
[/code]

So it's some header then a repeated pattern of data. :)
2, 4, 33, 2, 4, 33
-Progress so far. The files have a 1748 byte header then a body of 39byte records (with what seems to be 3 distinct variables per record)

I opened an original mission savegame to check for similar results. Everything was fine untill the 2, 4, 33... pattern broke.

Checking another file, it broke again, in a different place.

What now? Check the header for differences.

The files that had more data after repeating 39byte record had different values at offset 1744 4bytes long

Here is an example for a savegame that "broke the rules" from offset 68589. AE 06
[code]
FASTIO_READ Offset: 0 Length: 44
FASTIO_READ Offset: 44 Length: 4
FASTIO_READ Offset: 48 Length: 1
FASTIO_READ Offset: 49 Length: 4
FASTIO_READ Offset: 53 Length: 1
FASTIO_READ Offset: 54 Length: 4
FASTIO_READ Offset: 58 Length: 1686
FASTIO_READ Offset: 1744 Length: 4
FASTIO_READ Offset: 1748 Length: 2
FASTIO_READ Offset: 1750 Length: 4
FASTIO_READ Offset: 1754 Length: 33
FASTIO_READ Offset: 1787 Length: 2
FASTIO_READ Offset: 1789 Length: 4
FASTIO_READ Offset: 1793 Length: 33
FASTIO_READ Offset: 1826 Length: 2
FASTIO_READ Offset: 1828 Length: 4
FASTIO_READ Offset: 1832 Length: 33
FASTIO_READ Offset: 1865 Length: 2
FASTIO_READ Offset: 1867 Length: 4
FASTIO_READ Offset: 1871 Length: 33
...
FASTIO_READ Offset: 68589 'some unexpected stuff
...
[/code]

I'm terrible at visualising hex in any meaningfull way so I opened my good friend calc.exe for some answers. I was looking for 1 of a few things.

1. The offset 68589 itself
2. a relative offset (from the header onwards) 68589-1748 =66841
3. the number of 39byte records untill 68589. (68589-1748)/39=1713.87 (hm, a fraction of a record? not promising)

Now to make sence of the bytes (AE 06) in the header with calc.exe...
AE 06 = 44550 not very helpfull again.
how about...
06 AE = 1710
that looks alot like the number of records 1713.87

I opened another file and tested this again, turns out that coincidently I had taken the wrong offset in the 1st file and the number of records was actually 1710.

now we have a header 1686 long followed by 4bytes (I'd love an explanation of why they are reversed) telling us how many records follow.
then a bunch of records, then some other stuff (which too looks like records of a different lenght)


That's all for now. Please let me know if this is not welcome here. I'd be happy to delete it and continue alone. I just assumed a look inside someone elses thought process may be something quite interesting(would you have done things differently?), even if you hate c&c :) feel free to comment.
User avatar
burger2227
Veteran
Posts: 2466
Joined: Mon Aug 21, 2006 12:40 am
Location: Pittsburgh, PA

?

Post by burger2227 »

It would be a lot better to document your progress elsewhere until you get something that actually works. Then post the progress.

Ted
Please acknowledge and thank members who answer your questions!
QB64 is a FREE QBasic compiler for WIN, MAC(OSX) and LINUX : https://www.qb64.org/forum/index.php
Get my Q-Basics demonstrator: https://www.dropbox.com/s/fdmgp91d6h8ps ... s.zip?dl=0
dkg
Newbie
Posts: 8
Joined: Mon Mar 31, 2008 2:29 am

Post by dkg »

Fine point Ted.

Back in a few weeks :)
Post Reply