nineteendo / pyvz2

PyVZ2 is a command line utility to modify PvZ2
GNU General Public License v3.0
44 stars 7 forks source link

Error: "rtons\pp.rton pos 10427: unpack requires a buffer of 1 bytes" #2

Closed nineteendo closed 2 years ago

nineteendo commented 3 years ago

Drazzii: Got the latest version, tried to convert and got this error. This happens with the file being pp.dat, pp.rton, and pp.dat.rton. File provided.

pp.zip

Nineteendo: Your file abruptly stops: 910A2401 91?? It's supposed to look something like this: Archive.zip but even if it didn't you can't correctly convert it back. Sorry, currently working on that.

Sepphoris commented 3 years ago

Alright. Hopefully a way can be figured out. As far as I can tell, you are the only one actively working on a program, and able to receive input.

So how does one convert pp.dat currently, then convert back? The PVZ2Tool, Taiji, and pretty much all other tools that convert .rton to .json currently don't seem to work, with each one throwing an error.

nineteendo commented 3 years ago

By interpreting the data types only used in No_Backup RTONs: int8, int8_zero, uint8, uint8_zero, int16, int16_zero, uint16, uint16_zero, uint32, uint32_zero, positive_uint32_varint, negative_uint32_varint, int64, int64_zero, positive_int64_varint, negative_int64_varint, uint64, uint64_zero, positive_uint64_varint, negative_uint64_varint, uncached_latin_string and uncached_utf8_string The reverse is far trickier because json doesn't preserve these data types, so I would somehow have to determine them manually from the context (keys, values).

Sepphoris commented 3 years ago

Alright. Hopefully a solution shows itself, otherwise there doesn't seem to be a way to edit any of the values located here.

nineteendo commented 3 years ago

Drazzii: Went for it, still throws an error for pp (with both extensions): "fails: KeyError: rtons\pp.dat.rton pos 10427: b"

pp.zip

Nineteendo: Your file still abruptly ends: 91562191 1321FF85?? it should end with DONE I can't fix that issue, have you edited the file using another editor?

Sepphoris commented 3 years ago

No, the file came straight from the folder with no changes made.

nineteendo commented 3 years ago

Well, then some error must have occurred in PVZ2 or with copying your file, I have fixed it: pp.dat.zip Here is my JSONSParser that does't currently support packages, if you don't have it anymore: jsons_to_rtons.py.zip

Sepphoris commented 3 years ago

Yes, this has worked. The file converted properly and is editable.

How did you manage to fix it? If this happens again, I would like to know how to address it myself.

Sepphoris commented 3 years ago

The file you provided works in-game just fine. I tried to see what would happen if I used the file in-game, got new data, and tried to convert it to j.son again. The issue started again: " rtons\pp.dat pos 8922: unpack requires a buffer of 1 bytes"

I'm not sure what's going on and why it becomes a damaged file. However if there's a way to manually fix it, that would work. pp attempt2.zip

Edit: Just in case it's relevant, the uid, profile, and level/trophy progress was reset.

nineteendo commented 3 years ago

I will try to update my parser to deal with these issues in the evening, but till then I would like to see pp.dat on your device. Can you download Hex editor and open the new pp.dat on Android? https://play.google.com/store/apps/details?id=com.myprog.hexedit You have to click open file, external, Android, data, com.ea.game.pvz2_row, files, no_backup, pp.dat and send me a screenshot.

Sepphoris commented 3 years ago

Screenshot_20210605-054109 Screenshot_20210605-054102

I should note this is NA, not RoW

nineteendo commented 3 years ago

NA doesn't make a difference. Can you go to pos 22DA? That is under dx Screenshot_20210605-144602

Sepphoris commented 3 years ago

Screenshot_20210605-055108 This? Going to 22da as an exact address came to here

nineteendo commented 3 years ago

And this is the file you sent me?

Sepphoris commented 3 years ago

Possibly not. I launched the game, and packets were added. Here's the current one that has that hex data: pp.zip

nineteendo commented 3 years ago

Just as I thought, when transferring the file a part got cut off, how did you transfer it? Screenshot_20210605-145927

Sepphoris commented 3 years ago

Transfer was it being dragged directly from No_Backup to a zip file. There was no other actions taken.

Sepphoris commented 3 years ago

I noticed that it cuts off too, but still works perfectly fine in-game.

nineteendo commented 3 years ago

Also when it cuts off the game simply resets. The cutoff seems to have something to do with zipping, your zipper seems to have a limit of around 9000B. Is that also how you put in on your PC? Could you try using another zipper or copying it directly to your PC using android file transfer?

Sepphoris commented 3 years ago

I have done it via file transfer; zipping is only to upload here. Here's the file without zipping:

https://drive.google.com/file/d/15xm8O2ABk6Sd1vgTBDAPwgJZslgUlHNA/view?usp=sharing

nineteendo commented 3 years ago

It's still cut off, hmm could you just directly upload it to drive?

Sepphoris commented 3 years ago

That is the direct upload, straight from the device.

Sepphoris commented 3 years ago

How did you fix it initially? Whatever the issue is, this seems like an unusual thing, so perhaps I'll have to fix it myself.

nineteendo commented 3 years ago

I just temporarily edited my RTONSPARSER converted it to JSON and back with JSONSPARSER and copied the last bytes.

Sepphoris commented 3 years ago

If you could provide the two conversion methods, and information on how to copy those last bytes, I could see how I can handle it myself.

I'm playing on an old android phone, rather than a tablet and anything super new. Is it possible it could be the device?

nineteendo commented 3 years ago

One thing you could try is zipping it using another from the play store. And if that still fails you will have to split up your file when transferring it by selecting the bytes from 22D0 - 44D0 and so on, or you would have to wait until I made an Android version (likely not very soon).

Sepphoris commented 3 years ago

Alright. I guess the programs are built around tablets rather than phones, which is understandable.

So once those bytes are selected, then what?

nineteendo commented 3 years ago

Make a new file pp2.dat and paste them in and save it, note that you can quickly select the bytes using the <> button (First file: 0-22C9, second file 22D0-44C9, third file 44D0 - 66C9, ...)

nineteendo commented 2 years ago

I have found the issue: I have to catch struct.error and than I can repair your file.

nineteendo commented 2 years ago

Fixed. If someone has this problem. Just reload PVZ2.