RatchetModding / slimseditor

A savegame editor for the Ratchet and Clank games, written in Python.
GNU General Public License v3.0
14 stars 6 forks source link

Limit size of integers/ranged integers #6

Open Auzoocle opened 3 years ago

Auzoocle commented 3 years ago

i have been looking into a bunch of save values in going commando for ps2.

we should be able to define the size of integers and ranged integers to avoid changing more than we want.

some values are only one byte large. several values are next to each other in the save file. using integer for a one byte value cause slimseditor to read from offset to nearest empty byte or up to 4 bytes? which could include values we dont want to change.

maikelwever commented 3 years ago

Sounds like a good idea, can you let me know which datatype the fields are? A list of common datatypes I can easily add are listed here: https://docs.python.org/3/library/struct.html#format-characters

Some examples in savegames would be very helpful while implementing this.

maikelwever commented 3 years ago

I've added untested new datatypes, can you try them out on your savegames and let me know how it goes?

Binary release can be found here: https://github.com/RatchetModding/slimseditor/releases/tag/0.0.7

Auzoocle commented 3 years ago

i updated my gc.json file with your new datatype. i tried creating a different ranged integer datatype, where integer where replaced with unsigned datatypes, but i was not able to get it to work. could you create them.

i dont understand your bitfield datatype. could you give some examples how this could look like in a .json file. I include my savefile and my gc.json file. one example of a byte with bits inside is the todano dam elevator. the value is 0 when it is locked, but 16 (in decimals) when it is unlocked. it is a difference of one bit.

i can add my gc.json values to the master, but i am not happy about some of them.

rac2.ps2.zip gc.json.zip

maikelwever commented 3 years ago

Ah yes, there are no examples of BitField, might have written that in a bit of a hurry.

It should work like this:

{
    "name": "Test Item",
    "pos": 1234,
    "type": "BitField",
    "bitmap": {
        "Item in 1st Bit": 1,
        "Item in 4th Bit": 4,
        "Dam Elevator": 5,
    }
}

I'll take a look at your savegame and items soon, and I'll add ranged variants for char and short as well, since RangedInteger currently maps to int32.

Auzoocle commented 2 years ago

i think there is a bug with the bitfield. it decodes the value correct, but it doesn't save the value.

and there is a problem here.

"bitmap": { "Item in 1st Bit": 1 }

is actually the second bit

the line should be

"bitmap": { "Item in 1st Bit": 0 }

to change the first bit. you probably meant it like your example where bit 1 is the first bit. probably a bug there as well.

this time, i will respond in a more reasonable time. by the way i am using Linux.