The Ur-Quan Masters Discussion Forum

The Ur-Quan Masters Re-Release => General UQM Discussion => Topic started by: Tog on January 21, 2011, 02:02:37 am



Title: Editing saved games
Post by: Tog on January 21, 2011, 02:02:37 am
Hello again, everyone!

I know there are a couple of saved game editors around, but I haven't found a way to edit the melnorme credits. Does anyone know how this can be done?

Also, does anyone have any info about what offsets contain which settings when using a hex editor? I checked the save.c file, but I couldn't figure out how to translate this into the offset of a particular value.

Thanks!


Title: Re: Editing saved games
Post by: Novus on January 21, 2011, 10:32:50 am
The saved games are compressed to save disk space, making it very hard to hex edit most of the game state. The easiest solution is probably to modify the save or load code.

Annoyingly, the Melnorme credits are also stored in uncompressed form (used to display the summary of the game state in the load menu), but this is not the version used by the game.


Title: Re: Editing saved games
Post by: Alvarin on January 21, 2011, 11:16:02 pm
If you are that interested in cheating the game, you can try memory editors, like scanmem for Linux or ArtMoney for Windows.
I know it works, cause I did it myself :)
No weird searches like multiples or the -1 stuff, just the exact number on display in the cargo menu.


Title: Re: Editing saved games
Post by: Tog on January 22, 2011, 09:21:06 pm
Thanks.

I tried a couple of memory editors while talking to a Melnorme ship. When I search for the number of credits in my inventory, it comes up with hundreds of hits on every integer/float type. I did have a little bit of fun manipulating the dialogue in real time, though :) Searching for strings seems to be a lot easier than numbers. I did find a string value for MCredit, but not MCreditHi or MCreditLo. Unfortunately, I don't know how to edit a variable directly from memory.


Title: Re: Editing saved games
Post by: Alvarin on January 23, 2011, 04:30:57 am
Not credits - bioforms are the way to go.


Title: Re: Editing saved games
Post by: jucce on January 25, 2011, 10:22:44 am
Hello again, everyone!

I know there are a couple of saved game editors around, but I haven't found a way to edit the melnorme credits. Does anyone know how this can be done?
I made an editor you can modify the credits with here:
http://forum.uqm.stack.nl/index.php?topic=4890.0

Also, does anyone have any info about what offsets contain which settings when using a hex editor? I checked the save.c file, but I couldn't figure out how to translate this into the offset of a particular value.

Thanks!
I also did a save game editor (http://forum.uqm.stack.nl/index.php?topic=4672.0) previously, I can take a look at what offsets it uses and post them. Stand by.

Thanks.

I tried a couple of memory editors while talking to a Melnorme ship. When I search for the number of credits in my inventory, it comes up with hundreds of hits on every integer/float type. I did have a little bit of fun manipulating the dialogue in real time, though :) Searching for strings seems to be a lot easier than numbers. I did find a string value for MCredit, but not MCreditHi or MCreditLo. Unfortunately, I don't know how to edit a variable directly from memory.
The credits aren't stored in a straight forward fashion in the memory. They way my memory editor reads them is to first read 4 bytes at a specific offset. Then it uses that data, plus an offset, as the next memory location to read to find the actual credits.

It basically finds the location using a pointer. A program called "Cheat Engine" has good support for this.

So it reads 4 bytes from this new location. Then it right shifts the data by 3 (eliminating the last 3 bits). Finally it zeros the two leftmost bytes. And the resulting data is the credits.

Writing the credits is also tricky because you have to change only specific bits in the 4 bytes of credit data.


Title: Re: Editing saved games
Post by: jucce on January 25, 2011, 10:41:57 am
Ok, these are the save game offsets you can write to and have the game accept the changes (changes to credits and lander stats etc. are ignored):

Code:
//Ship
Captain name 0x5A 12
Ship name 0x4A 10
Crew 0x10 2
Fuel 0x0C 4
R.U. 0x08 4
Bio Data 0x14 2
Landers 0x39 1

//Resources
Common 0x3A 2
Corrosive 0x3C 2
Base Metal 0x3E 2
Noble Gas 0x40 2
Rare Earth 0x42 2
Precious 0x44 2
Radioactive 0x46 2
Exotic 0x48 2
Cargo Space 0x12 2

//Position
X 0x00 4
Y 0x04 4

//Ship outfit *
Modules 16-1 0x16 16
Thrusters 11-1 0x26 11
Jets 8-1 0x31 8

* Modules
0x16 = Empty Module
0x00 = Lander
0x01 = Antimat Thruster
0x02 = Turning Jets
0x03 = Crew Pod
0x04 = Storage Bay
0x05 = Fuel Tank
0x06 = High-Ef Fuelsys
0x07 = Dynamo Unit
0x08 = Shiva Furnace
0x09 = Ion-Bolt Gun
0x0A = Fusion Blaster
0x0B = Hellbore Cannon
0x0C = Tracking System
0x0D = Point Defense
0x0E-0x0F = Bomb Parts
0x10-0x13 = Crystal Parts


Title: Re: Editing saved games
Post by: meep-eep on January 25, 2011, 11:16:15 pm
If you want to know the details, look at save.c (http://sc2.svn.sourceforge.net/viewvc/sc2/trunk/sc2/src/uqm/save.c?revision=3551&view=markup) or load.c (http://sc2.svn.sourceforge.net/viewvc/sc2/trunk/sc2/src/uqm/load.c?revision=3551&view=markup). The description of the 'GameState' can be found in globdata.h (http://sc2.svn.sourceforge.net/viewvc/sc2/trunk/sc2/src/uqm/globdata.h?revision=3551&view=markup).
This is relatively easy code to understand.
But note that parts of the saved games are compressed (the stuff written with 'cwrite()' and variants), and that part you shouldn't try to understand. The compression/decompression routines for this are in src/libs/decomp/src/libs/decomp (http://sc2.svn.sourceforge.net/viewvc/sc2/trunk/sc2/src/libs/decomp/), for the sadistic.

Jucce: The credits are actually part of the compressed part of the saved games; your method of finding it may fail when the data around it changes. I'm actually surprised that you managed to get it like this at all.


Title: Re: Editing saved games
Post by: onpon4 on January 26, 2011, 12:38:51 am
The compression/decompression routines for this are in src/libs/decomp/src/libs/decomp (http://sc2.svn.sourceforge.net/viewvc/sc2/trunk/sc2/src/libs/decomp/), for the sadistic.

Sadistic? Does that mean... fiddling with it will give you power? Hm... yeah, that sounds about right. Never mind. :P


Title: Re: Editing saved games
Post by: jucce on January 26, 2011, 01:22:16 am
Jucce: The credits are actually part of the compressed part of the saved games; your method of finding it may fail when the data around it changes. I'm actually surprised that you managed to get it like this at all.

I just want to clarify that I got it from reading the UQM.exe process memory and not from the save game. And in the memory it seems to be stored in a consistent way at the same (relative) location.


Title: Re: Editing saved games
Post by: meep-eep on January 26, 2011, 07:02:41 am
The compression/decompression routines for this are in src/libs/decomp/src/libs/decomp (http://sc2.svn.sourceforge.net/viewvc/sc2/trunk/sc2/src/libs/decomp/), for the sadistic.

Sadistic? Does that mean... fiddling with it will give you power? Hm... yeah, that sounds about right. Never mind. :P
You're right. That should have been "masochistic".

Jucce: The credits are actually part of the compressed part of the saved games; your method of finding it may fail when the data around it changes. I'm actually surprised that you managed to get it like this at all.
I just want to clarify that I got it from reading the UQM.exe process memory and not from the save game. And in the memory it seems to be stored in a consistent way at the same (relative) location.
Ah. Yes, it would be. I should have read better.