mirror of
https://github.com/LBPUnion/ProjectLighthouse.git
synced 2025-08-05 11:28:39 +00:00
Fix bug with hex not deserializing in JSON, add CreateRoom matchType
This commit is contained in:
parent
6be05dff82
commit
5aacdae4cb
2 changed files with 28 additions and 0 deletions
|
@ -1,6 +1,8 @@
|
|||
#nullable enable
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Text.Json;
|
||||
using System.Text.RegularExpressions;
|
||||
using LBPUnion.ProjectLighthouse.Types.Match;
|
||||
|
||||
namespace LBPUnion.ProjectLighthouse.Helpers
|
||||
|
@ -22,6 +24,9 @@ namespace LBPUnion.ProjectLighthouse.Helpers
|
|||
|
||||
string matchData = $"{{{string.Concat(data.Skip(matchType.Length + 3).SkipLast(2))}}}";
|
||||
|
||||
// JSON does not like the hex value that location comes in (0x7f000001) so, convert it to int
|
||||
matchData = Regex.Replace(matchData, @"0x[a-fA-F0-9]{8}", m => Convert.ToInt32(m.Value, 16).ToString());
|
||||
|
||||
return Deserialize(matchType, matchData);
|
||||
}
|
||||
|
||||
|
@ -31,6 +36,7 @@ namespace LBPUnion.ProjectLighthouse.Helpers
|
|||
{
|
||||
"UpdateMyPlayerData" => JsonSerializer.Deserialize<UpdateMyPlayerData>(matchData),
|
||||
"UpdatePlayersInRoom" => JsonSerializer.Deserialize<UpdatePlayersInRoom>(matchData),
|
||||
"CreateRoom" => JsonSerializer.Deserialize<CreateRoom>(matchData),
|
||||
_ => null,
|
||||
};
|
||||
}
|
||||
|
|
22
ProjectLighthouse/Types/Match/CreateRoom.cs
Normal file
22
ProjectLighthouse/Types/Match/CreateRoom.cs
Normal file
|
@ -0,0 +1,22 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
|
||||
namespace LBPUnion.ProjectLighthouse.Types.Match
|
||||
{
|
||||
[SuppressMessage("ReSharper", "CollectionNeverUpdated.Global")]
|
||||
public class CreateRoom : IMatchData
|
||||
{
|
||||
//[CreateRoom,["Players":["LumaLivy"],"Reservations":["0"],"NAT":[2],"Slots":[[1,3]],"RoomState":0,"HostMood":1,"PassedNoJoinPoint":0,"Location":[0x7f000001],"Language":1,"BuildVersion":289,"Search":""]]
|
||||
public List<string> Players;
|
||||
public List<string> Reservations;
|
||||
public List<int> NAT;
|
||||
public List<List<int>> Slots;
|
||||
public int RoomState;
|
||||
public int HostMood;
|
||||
public int PassedNoJoinPoint;
|
||||
public List<int> Location;
|
||||
public int Language;
|
||||
public int BuildVersion;
|
||||
public string Search;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue