Skip to content

Commit

Permalink
Add constructors for no parameters and byte[]
Browse files Browse the repository at this point in the history
fixes #2
  • Loading branch information
holly-hacker committed Sep 2, 2017
1 parent 93ca255 commit d19046d
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 4 deletions.
6 changes: 5 additions & 1 deletion HOPEless/Bancho/Objects/BeatmapTypes.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Collections.Generic;
using HOPEless.Extensions;
using HOPEless.osu;

namespace HOPEless.Bancho.Objects
Expand All @@ -11,7 +12,10 @@ public class BanchoBeatmapInfoRequest : IBanchoSerializable

private readonly BanchoStringList _filenames = new BanchoStringList();
private readonly BanchoIntList _beatmapIds = new BanchoIntList();


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

public void ReadFromStream(CustomBinaryReader r)
{
_filenames.ReadFromStream(r);
Expand Down
9 changes: 8 additions & 1 deletion HOPEless/Bancho/Objects/ChatTypes.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using HOPEless.osu;
using HOPEless.Extensions;
using HOPEless.osu;

namespace HOPEless.Bancho.Objects
{
Expand All @@ -7,6 +8,9 @@ public class BanchoChatMessage : IBanchoSerializable
public string Sender, Message, Channel;
public int SenderId;

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

public void ReadFromStream(CustomBinaryReader r)
{
Sender = r.ReadString();
Expand All @@ -29,6 +33,9 @@ public class BanchoChatChannel : IBanchoSerializable
public string Name, Topic;
public short UserCount;

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

public void ReadFromStream(CustomBinaryReader r)
{
Name = r.ReadString();
Expand Down
6 changes: 5 additions & 1 deletion HOPEless/Bancho/Objects/MultiplayerTypes.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using HOPEless.osu;
using HOPEless.Extensions;
using HOPEless.osu;

namespace HOPEless.Bancho.Objects
{
Expand Down Expand Up @@ -27,6 +28,9 @@ public class BanchoMultiplayerMatch : IBanchoSerializable

public string GamePassword; //can be null

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

public void ReadFromStream(CustomBinaryReader r)
{
MatchId = r.ReadUInt16();
Expand Down
10 changes: 10 additions & 0 deletions HOPEless/Bancho/Objects/ScoreTypes.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Collections.Generic;
using HOPEless.Extensions;
using HOPEless.osu;

namespace HOPEless.Bancho.Objects
Expand All @@ -23,6 +24,9 @@ public class BanchoScoreFrame : IBanchoSerializable
public double ComboPortion;
public double BonusPortion;

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

public void ReadFromStream(CustomBinaryReader r)
{
Time = r.ReadInt32();
Expand Down Expand Up @@ -75,6 +79,9 @@ public class BanchoReplayFrame : IBanchoSerializable
public ButtonState ButtonState;
public int Time;

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

public void ReadFromStream(CustomBinaryReader r)
{
ButtonState = (ButtonState)r.ReadByte();
Expand All @@ -101,6 +108,9 @@ public class BanchoReplayFrameBundle : IBanchoSerializable
public ReplayAction Action;
public int SpectatedPlayerId; //only if action is WatchingOther

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

public void ReadFromStream(CustomBinaryReader r)
{
SpectatedPlayerId = r.ReadInt32();
Expand Down
11 changes: 11 additions & 0 deletions HOPEless/Bancho/Objects/SimpleTypes.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
using System.Collections.Generic;
using HOPEless.Extensions;
using HOPEless.osu;

namespace HOPEless.Bancho.Objects
{
public class BanchoInt : IBanchoSerializable
{
public int Value;
public BanchoInt() { }
public BanchoInt(byte[] data) => this.Populate(data);
public void ReadFromStream(CustomBinaryReader r) => Value = r.ReadInt32();
public void WriteToStream(CustomBinaryWriter w) => w.Write(Value);
}
Expand All @@ -14,6 +17,9 @@ public class BanchoIntList : IBanchoSerializable
{
public List<int> Value = new List<int>();

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

public void ReadFromStream(CustomBinaryReader r)
{
Value = new List<int>();
Expand All @@ -32,6 +38,8 @@ public void WriteToStream(CustomBinaryWriter w)
public class BanchoString : IBanchoSerializable
{
public string Value;
public BanchoString() { }
public BanchoString(byte[] data) => this.Populate(data);
public void ReadFromStream(CustomBinaryReader r) => Value = r.ReadString();
public void WriteToStream(CustomBinaryWriter w) => w.Write(Value);
}
Expand All @@ -40,6 +48,9 @@ public class BanchoStringList : IBanchoSerializable
{
public List<string> Value = new List<string>();

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

public void ReadFromStream(CustomBinaryReader r)
{
Value = new List<string>();
Expand Down
16 changes: 15 additions & 1 deletion HOPEless/Bancho/Objects/UserTypes.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using HOPEless.osu;
using HOPEless.Extensions;
using HOPEless.osu;

namespace HOPEless.Bancho.Objects
{
Expand All @@ -13,6 +14,9 @@ public class BanchoUserData : IBanchoSerializable
public int Rank;
public short Performance;

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

public void ReadFromStream(CustomBinaryReader r)
{
UserId = r.ReadInt32();
Expand Down Expand Up @@ -46,6 +50,9 @@ public class BanchoUserStatus : IBanchoSerializable
public Mods CurrentMods;
public PlayModes PlayMode;
public int BeatmapId;

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

public void ReadFromStream(CustomBinaryReader r)
{
Expand Down Expand Up @@ -81,6 +88,9 @@ public class BanchoUserPresence : IBanchoSerializable
public float Latitude;
public int Rank;

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

public void ReadFromStream(CustomBinaryReader r)
{
UserId = r.ReadInt32();
Expand Down Expand Up @@ -118,6 +128,10 @@ public class BanchoUserQuit : IBanchoSerializable
public int UserId;
public UserQuitType QuitType;


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

public void ReadFromStream(CustomBinaryReader r)
{
UserId = r.ReadInt32();
Expand Down

0 comments on commit d19046d

Please sign in to comment.