Skip to content

Commit

Permalink
Create BanchoBeatmapInfoReply and BanchoMultiplayerJoin classes
Browse files Browse the repository at this point in the history
  • Loading branch information
holly-hacker committed Jul 9, 2018
1 parent 21d274d commit ae9120e
Show file tree
Hide file tree
Showing 3 changed files with 84 additions and 2 deletions.
56 changes: 56 additions & 0 deletions HOPEless/Bancho/Objects/BeatmapTypes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,60 @@ public void WriteToStream(SerializationWriter w)
_beatmapIds.WriteToStream(w);
}
}

public class BanchoBeatmapInfoReply : ISerializable
{
public List<BanchoBeatmapInfo> Value;

public BanchoBeatmapInfoReply() { }
public BanchoBeatmapInfoReply(byte[] data) => this.Populate(data);

public void ReadFromStream(SerializationReader r) => Value = r.ReadSerializableList<BanchoBeatmapInfo>();
public void WriteToStream(SerializationWriter w) => w.WriteSerializableList(Value);
}

public class BanchoBeatmapInfo : ISerializable
{
public short Id;
public int BeatmapId;
public int BeatmapSetId;
public int ThreadId;
public byte Ranked;
public byte RankStandard;
public byte RankTaiko;
public byte RankCtB;
public byte RankMania;
public string Checksum;

public BanchoBeatmapInfo() { }
public BanchoBeatmapInfo(byte[] data) => this.Populate(data);

public void ReadFromStream(SerializationReader sr)
{
Id = sr.ReadInt16();
BeatmapId = sr.ReadInt32();
BeatmapSetId = sr.ReadInt32();
ThreadId = sr.ReadInt32();
Ranked = sr.ReadByte();
RankStandard = sr.ReadByte();
RankCtB = sr.ReadByte();
RankTaiko = sr.ReadByte();
RankMania = sr.ReadByte();
Checksum = sr.ReadString();
}

public void WriteToStream(SerializationWriter sw)
{
sw.Write(Id);
sw.Write(BeatmapId);
sw.Write(BeatmapSetId);
sw.Write(ThreadId);
sw.Write(Ranked);
sw.Write(RankStandard);
sw.Write(RankCtB);
sw.Write(RankTaiko);
sw.Write(RankMania);
sw.Write(Checksum);
}
}
}
26 changes: 26 additions & 0 deletions HOPEless/Bancho/Objects/MultiplayerTypes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,32 @@

namespace HOPEless.Bancho.Objects
{
public class BanchoMultiplayerJoin : ISerializable
{
public int MatchId;
public string Password;

public BanchoMultiplayerJoin() { }
public BanchoMultiplayerJoin(byte[] data) => this.Populate(data);
public BanchoMultiplayerJoin(int matchId, string password)
{
MatchId = matchId;
Password = password;
}

public void ReadFromStream(SerializationReader r)
{
MatchId = r.ReadInt32();
Password = r.ReadString();
}

public void WriteToStream(SerializationWriter w)
{
w.Write(MatchId);
w.Write(Password);
}
}

public class BanchoMultiplayerMatch : ISerializable
{
public string GameName;
Expand Down
4 changes: 2 additions & 2 deletions HOPEless/Bancho/PacketType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ public enum PacketType : short

/// <summary>
/// Tell bancho we want to join a match.
/// <para>Data: TODO create BanchoMultiplayerJoin, which is int32 id, string pass</para>
/// <para>Data: <see cref="BanchoMultiplayerJoin"/></para>
/// </summary>
ClientMultiMatchJoin,

Expand Down Expand Up @@ -436,7 +436,7 @@ public enum PacketType : short

/// <summary>
/// Respond to a <seealso cref="ClientBeatmapInfoRequest"/> packet.
/// <para>Data: TODO create BanchoBeatmapInfoReply</para>
/// <para>Data: <see cref="BanchoBeatmapInfoReply"/></para>
/// </summary>
ServerBeatmapInfoReply,

Expand Down

0 comments on commit ae9120e

Please sign in to comment.