tfausak / rattletrap

:car: Parse and generate Rocket League replays.
https://hackage.haskell.org/package/rattletrap
MIT License
150 stars 21 forks source link

Modifying player IDs #171

Closed aaron9795 closed 3 years ago

aaron9795 commented 3 years ago

First off, rattletrap is really cool! Thanks for putting all the time and effort into this. The situation I'm struggling with may not be resolvable but I figured I'd post a question here since you've been so helpful to others in the past.

I'm running a league and we upload replays to ballchasing to keep stats. We've had players have internet outages or get banned (lol) and have to either play on a friend's account or make a new account to play in our league games. This skews the stats on ballchasing which isn't a huge deal but I decided I'd see if I can edit the player IDs in the replay files using rattletrap to fix our issue of players using multiple accounts.

So far, I was able to successfully convert a PS4 player to another PS4 player, and convert an Xbox player to a steam player. I'm able to reupload these modified replay files to ballchasing and it recognizes the converted players perfectly.

What I'm struggling with right now is with one of our players who plays on both Switch and PS4. I'm trying to convert the Switch IDs to PS4 IDs, and although rattletrap is able to encode my modified JSON into a new replay file, ballchasing is unable to parse the new replay file.

I'm not sure exactly what the issue is, as the JSON is huge, but I think I've properly replaced the psy_net switch ID with the PS4 ID. I'm thinking there may be an issue with the PS4 ID being a bigger size than the psy_net ID, or it might just be a slight difference in how ballchasing parses the replays causing a problem.

I guess I was just wondering if you had any insight on what I could be doing wrong, or if this is even at all possible. I'm not sure anyone else has tried modifying player IDs for reupload to ballchasing like I'm doing. I'll keep trying to figure it out but just wanted to post here in the meantime! Thanks so much for all your work!

tfausak commented 3 years ago

Hmm, interesting!

I've got to say that using Rattletrap to create replays isn't really that common. It is supported, but I mostly do it for myself to prove that I haven't messed up decoding.

That being said, what you're doing should work. A few things come to mind:

tfausak commented 3 years ago

I'm not sure how I can help debug this. Could you share the replay file you're trying to modify? And perhaps a before-and-after of the ID field? It should look something like this:

{
  "id": {
    "limit": 74,
    "value": 22
  },
  "name": "Engine.PlayerReplicationInfo:UniqueId",
  "value": {
    "unique_id": {
      "local_id": 0,
      "remote_id": {
        "steam": "76561197960464457"
      },
      "system_id": 1
    }
  }
},

Specifically for PlayStation IDs, there are two things you have to watch out for:

aaron9795 commented 3 years ago

Hey thanks for the replies! Sorry I got pretty busy all of the sudden with family stuff during the holidays so I might not be able to get to this for a bit. I did try reparsing the modified replay and I get a not enough bytes error which leads me to believe we're on the right track with the sizes being an issue for my case. I also can't seem to get the replay into rocket league either.

This is what the switch ID looks like:

                  {
                    "id": {
                      "limit": 108,
                      "value": 21
                    },
                    "name": "Engine.PlayerReplicationInfo:UniqueId",
                    "value": {
                      "unique_id": {
                        "local_id": 0,
                        "remote_id": {
                          "psy_net": {
                            "Left": "15040437798375988749"
                          }
                        },
                        "system_id": 7
                      }
                    }
                  },

and this is the ps4 id I'm trying to replace it with:

                  {
                    "id": {
                      "limit": 108,
                      "value": 21
                    },
                    "name": "Engine.PlayerReplicationInfo:UniqueId",
                    "value": {
                      "unique_id": {
                        "local_id": 0,
                        "remote_id": {
                          "play_station": [
                            "claraaxoxo",
                            [
                              70,
                              172,
                              174,
                              206,
                              14,
                              206,
                              44,
                              0,
                              128,
                              0,
                              0,
                              0,
                              0,
                              0,
                              0,
                              0,
                              145,
                              252,
                              74,
                              207,
                              241,
                              201,
                              46,
                              220
                            ]
                          ]
                        },
                        "system_id": 2
                      }
                    }
                  },

And to answer your question Does anything else in the replay reference the ID?: yes the ID is referenced in several other places but I've made sure to replace those as well.

It's possible that various "size" fields need to be computed on the fly rather than copied from the JSON. You already touched on this; if a PS4 ID is (say) 8 bytes and a Switch ID is 7 bytes, then Rattletrap will need to handle that for you. This is definitely possible, but it might take some digging to uncover and fix all the relevant bits. - based on what I've seen and what you've mentioned I think this is probably the blocker. I'm not sure if there's any easy way to accomplish my goal, but I'll probably have time to check it out sometime. I'll attach the replay file that I'm trying to modify for reference.

Thanks again for being so helpful and my apologies for the delayed reply! I'll be pretty busy for the next week or so, so I'm not sure how much I'll get to experiment with this. Happy holidays!

4fef4dd9-e36c-4128-90e3-2571cc234e4f.zip

tfausak commented 3 years ago

I haven't made any progress on this, but I have been able to reproduce the problem. Unfortunately Rattletrap's error message is pretty useless, so there's not much to go on. But I'll keep looking! This is an interesting problem.

aaron9795 commented 3 years ago

I haven't made progress either but I can confirm the same problem happens when converting from Epic to PS4 as well. So I do still think it's a size issue when converting from non-ps4 to ps4. I found this platform attribute that confirms the sizes vary by system. PS4 is 23 while Epic is 24. Steam and Xbox are 25 which may have been why I was able to convert between those two. However, Switch is 23 just like PS4.

                    "OnlineID": {
                      "kind": "QWordProperty",
                      "size": "8",
                      "value": {
                        "q_word": "0"
                      }
                    },
                    "Platform": {
                      "kind": "ByteProperty",
                      "size": "24",
                      "value": {
                        "byte": [
                          "OnlinePlatform",
                          "OnlinePlatform_Epic"
                        ]
                      }
                    },

Changing the q_word attribute and the platform attribute didn't fix anything for me, so I still think it might just be an issue with the json representation of the ps4 id being much bigger than anything else. The size attribute at the very bottom of the json is also interesting but I'm not sure how that's calculated, and changing it hasn't helped me.

Thanks for your interest in the problem! I'll keep looking as well when I have the time.