Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MatchingEndpoints: Fixup corrupted strings sent by the game.
LBP2 for some reason like to send "null" `Location` items, which look like `"0.0.0.0"`. While this isn't directly a problem, a bug in the serialization code causes the character *after* the null location to be corrupted, eg. `"0.0.0.0","1.1.1.1"` gets corrupted into `"0.0.0.0""1.1.1.1"`, and `"0.0.0.0"],"` gets corrupted into `"0.0.0.0","`. Both of these cases are invalid JSON syntax and a problem. To fix this issue, I iterate over the match body sent, and find the any instances of `"0.0.0.0"`, I then check what character is *after* the null string, if it is a `"`, then I know that it has corrupted a `,`, since the only times a quote will be after that, is if another string is meant to be in the array. If the next character is `,`, then I know that it has corrupted a `]`, since the only time there will ever be a `,` two characters after a null location, is when the array has been closed. By inserting these corrupted characters back into the string, it restores the string to the intended value.
- Loading branch information