How to read .rxdata

Started by kevinka999, January 15, 2024, 06:30:24 am

Previous topic - Next topic

kevinka999

Guys I would like to read and write a save data from a game I'm playing created on RPG MAker Xp
Im not a game developer and I dont even have RMXP on my machine so I'm very poor of information about these stuff

I suppose these save files in .rxdata is a binary file so I tried to use python to convert that binary file to object but It seems the module I was using dont have support for this kind of serialization.

I saw some save editors for these save files but none works for me and the one I thought would work which is SGEdit is for 32bits systems.

Sorry if Im posting on the wrong place but could someone give me directions?

(I honestly dont need to edit but after a few tries it challanged me and know Im pissed lol)

kevinka999

I suddenly found this article from Pokemon Essentials which is probably what they used for develop
https://essentialsdocs.fandom.com/wiki/Data_Structures

It has some information for decompress .rxdata scripts but I dont know if that's what Im looking for
decompressed_code = Zlib::Inflate.inflate(code)
(I dont even know which language is that, I suppose it's ruby or python right but since I searched for this Zlib module on python and didnt found anything I dont think it is Python)

KK20

RPG Maker XP uses Ruby v1.8 as its scripting language. As your link explains, Ruby has a module called Marshal that compresses Ruby objects into long strings of bytes. Official docs can explain it more in detail: https://ruby-doc.org/3.2.2/Marshal.html

Here's a very bare-bones example of what a marshaled object looks like:
Code: ruby
class Test
  def initialize
    @name = 'foo'
    @type = 'bar'
  end
end

file = File.open('data_dump.txt', 'wb')
test_object = Test.new
Marshal.dump(test_object, file)

And then loading it back in is just a simple call of Marshal.load
test_object = Marshal.load(File.open('data_dump.txt'))
You just have to be cognizant of the order you dump and load things:
Marshal.dump(object_a, file)
Marshal.dump(object_b, file)
Marshal.dump(object_c, file)
# load in the same order as you dump...
object_a = Marshal.load(file)
object_b = Marshal.load(file)
object_c = Marshal.load(file)

As long as the class for the object you're dumping can be serialized to a string of bytes, you can call the Marshal functions on it. Otherwise, you're required defining the methods _dump and _load for the class (again, this is already explained in both articles).

I believe there are several parsers of marshaled data in various languages. If you really wanted to get your hands dirty and read byte code, you could write your own parser. On the Python side of things, there's this:
https://pypi.org/project/rubymarshal/
I played with it for a while when I was exploring the idea of making an RMXP editor in Python.

This is a very high level overview of Ruby Marshal, but it's not a very easy thing to explain either. It took me a good few years of using Ruby before I understood the inner-workings of it. I don't think you're ready to handle this yet, especially without having any knowledge of RMXP (or Ruby for that matter).

With that said, since it seems like you're interested in Pokemon Essentials games, I can't help you with that. You're better off asking their forums (assuming people don't immediately frown upon the idea of editing save files over there).

Other Projects
RPG Maker XP Ace  Upgrade RMXP to RMVXA performance!
XPA Tilemap  Tilemap rewrite with many features, including custom resolution!

Nintendo Switch Friend Code: 8310-1917-5318
Discord: KK20 Tyler#8901

Join the CP Discord Server!