• Welcome to SC4 Devotion Forum Archives.

Programmatically change city names

Started by mak, January 28, 2017, 10:59:59 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

mak

Hello,

I've been working on a mod project, and I was wondering if it was possible to directly edit SC4 save files to change the city name. I know you can change it in-game with the "WhereRUFrom" cheat code, but I've been trying to achieve this programmatically.

So far, I have tried decoding the save files from hex and editing the result. However, I'm noticing that the city name appears in numerous locations in each save file (and sometimes has non-ascii hex 00-1f in between). As I expected, editing these values hasn't worked out, even if the length stays the same. The name remains the same in the region view, and loading the city results in a crash to desktop.

I'm suspecting that I'm either: (a) editing the wrong values (hence no change) or (b) tripping up some checksum, which causes the CTD.

Has anyone managed to edit city names programmatically? I've tried parsing the file using iLive's Reader, but I don't know what to look for. I know DBPF files are tricky, but I also know that there are many smart people on this forum that know much more than I do :)

Many thanks in advance!
mak

mgb204

Quote from: mak on January 28, 2017, 10:59:59 PM
(b) tripping up some checksum, which causes the CTD.

In short, that's your problem. As a way to prevent people modifying the save files (cheating), they are protected by CheckSums. To this day no one has managed to decode those, so if you modify the save files, they are toast. A number of people have tried, especially given that file corruption can be a somewhat common problem with SC4 save files. But whilst some of the save file has been decoded and understood, no one to my knowledge has yet to successfully modify them without breaking them in the process.

mak

Thanks, that makes sense. Interestingly enough, I managed to edit some other parts of the save file (heightmap and region preview PNG) without issue. Are those parts of the file not included in the checksum?

Thanks again.

mgb204

Not sure would be the answer, since it's all inside the same file, you'd think the Checksum was part of the whole. But I suppose it's possible to do this on a exemplar level, afterall the format is proprietary to Maxis/EA.

I just know that previous attempts to modify the save data all kill the save file, rendering it useless. It's not an area I've personally dabbled in. But somewhere you might find some useful info, check out the last few pages of the Prop Pox thread for example. Some interesting observations re: save files were documented there.

Wiimeiser

AFAIK God Mode data is completely unprotected for whatever reason... Or at the very least has been mostly decoded if SC4T and SC4M are any indication...
Pink horse, pink horse, she rides across the nation...

mak

Finally figured it out! Well, sort of...

Editing the Region Preview Subfile (Type CA027EDB) is allowed by the game, and one of the values is the city name. This only works from the region view (once the city is loaded the old name is shown), but that's exactly what I needed.

Thanks.

p.s.: expect an intersting mod/tool coming soon...  ;)