Change WriteX -> Write overloads

This commit is contained in:
Sofia 2020-08-05 21:38:37 +03:00
parent abc3a672db
commit c2da335ce4
7 changed files with 32 additions and 156 deletions

View File

@ -11,7 +11,7 @@ namespace NeonTea.Quakeball.Net.Packets {
} }
public override void Write(ByteBuffer buffer) { public override void Write(ByteBuffer buffer) {
buffer.WriteString(Text); buffer.Write(Text);
} }
} }
} }

View File

@ -89,53 +89,53 @@ namespace NeonTea.Quakeball.TeaNet.Packets {
return Bytes[pos++]; return Bytes[pos++];
} }
public void WriteSerializable(Serializable s) { public void Write(Serializable s) {
s.Write(this); s.Write(this);
} }
public void WriteChar(char c) { public void Write(char c) {
Bytes.AddRange(BitConverter.GetBytes(c)); Bytes.AddRange(BitConverter.GetBytes(c));
} }
public void WriteBool(bool b) { public void Write(bool b) {
Write(b ? (byte)0b1 : (byte)0b0); Write(b ? (byte)0b1 : (byte)0b0);
} }
public void WriteDouble(double d) { public void Write(double d) {
Bytes.AddRange(BitConverter.GetBytes(d)); Bytes.AddRange(BitConverter.GetBytes(d));
} }
public void WriteFloat(float f) { public void Write(float f) {
Bytes.AddRange(BitConverter.GetBytes(f)); Bytes.AddRange(BitConverter.GetBytes(f));
} }
public void WriteULong(ulong l) { public void Write(ulong l) {
Bytes.AddRange(BitConverter.GetBytes(l)); Bytes.AddRange(BitConverter.GetBytes(l));
} }
public void WriteUInt(uint i) { public void Write(uint i) {
Bytes.AddRange(BitConverter.GetBytes(i)); Bytes.AddRange(BitConverter.GetBytes(i));
} }
public void WriteUShort(ushort s) { public void Write(ushort s) {
Bytes.AddRange(BitConverter.GetBytes(s)); Bytes.AddRange(BitConverter.GetBytes(s));
} }
public void WriteLong(long l) { public void Write(long l) {
Bytes.AddRange(BitConverter.GetBytes(l)); Bytes.AddRange(BitConverter.GetBytes(l));
} }
public void WriteInt(int i) { public void Write(int i) {
Bytes.AddRange(BitConverter.GetBytes(i)); Bytes.AddRange(BitConverter.GetBytes(i));
} }
public void WriteShort(short s) { public void Write(short s) {
Bytes.AddRange(BitConverter.GetBytes(s)); Bytes.AddRange(BitConverter.GetBytes(s));
} }
public void WriteString(string s) { public void Write(string s) {
byte[] bytes = Encoding.UTF8.GetBytes(s); byte[] bytes = Encoding.UTF8.GetBytes(s);
WriteInt(bytes.Length); Write(bytes.Length);
Bytes.AddRange(bytes); Bytes.AddRange(bytes);
} }
@ -185,7 +185,7 @@ namespace NeonTea.Quakeball.TeaNet.Packets {
} }
public void WritePacket(Protocol protocol, Packet p) { public void WritePacket(Protocol protocol, Packet p) {
WriteInt(protocol.GetPacketTypeID(p)); Write(protocol.GetPacketTypeID(p));
p.WriteMeta(this); p.WriteMeta(this);
p.Write(this); p.Write(this);
} }

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: a4a9a5bd7f79667449e165e21c402f9a
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -12,8 +12,8 @@ namespace NeonTea.Quakeball.TeaNet.Packets {
} }
public void WriteMeta(ByteBuffer buffer) { public void WriteMeta(ByteBuffer buffer) {
buffer.WriteInt(Id); buffer.Write(Id);
buffer.WriteBool(Reliable); buffer.Write(Reliable);
} }
} }

View File

@ -42,7 +42,7 @@ namespace NeonTea.Quakeball.TeaNet.Packets {
buffer.Write(Identifier); buffer.Write(Identifier);
if (connection.Status == ConnectionStatus.Establishing) { if (connection.Status == ConnectionStatus.Establishing) {
buffer.Write((byte)PacketStage.Establishing); buffer.Write((byte)PacketStage.Establishing);
buffer.WriteString(Version); buffer.Write(Version);
} else if (connection.Status == ConnectionStatus.Closed) { } else if (connection.Status == ConnectionStatus.Closed) {
buffer.Write((byte)PacketStage.Closed); buffer.Write((byte)PacketStage.Closed);
} else if (connection.Status == ConnectionStatus.Rejected) { } else if (connection.Status == ConnectionStatus.Rejected) {
@ -50,7 +50,7 @@ namespace NeonTea.Quakeball.TeaNet.Packets {
buffer.Write((byte)connection.ClosingReason); buffer.Write((byte)connection.ClosingReason);
} else if (connection.Status == ConnectionStatus.Ready) { } else if (connection.Status == ConnectionStatus.Ready) {
buffer.Write((byte)PacketStage.Ready); buffer.Write((byte)PacketStage.Ready);
buffer.WriteInt(connection.Internal.LatestInwardReliable); buffer.Write(connection.Internal.LatestInwardReliable);
} }
return buffer; return buffer;
} }

View File

@ -70,7 +70,7 @@ namespace NeonTea.Quakeball.TeaNet.Peers {
if (protocol != null && conn.IsReady()) { if (protocol != null && conn.IsReady()) {
ByteBuffer buffer = protocol.BuildMessage(conn); ByteBuffer buffer = protocol.BuildMessage(conn);
List<Packet> list = PacketQueue[uid]; List<Packet> list = PacketQueue[uid];
buffer.WriteInt(list.Count); buffer.Write(list.Count);
foreach (Packet p in list) { foreach (Packet p in list) {
buffer.WritePacket(protocol, p); buffer.WritePacket(protocol, p);
} }
@ -88,7 +88,7 @@ namespace NeonTea.Quakeball.TeaNet.Peers {
Protocol protocol = Peer.GetProtocol(conn.Internal.AssignedProtocol); Protocol protocol = Peer.GetProtocol(conn.Internal.AssignedProtocol);
if (protocol != null && conn.IsReady()) { if (protocol != null && conn.IsReady()) {
ByteBuffer buffer = protocol.BuildMessage(conn); ByteBuffer buffer = protocol.BuildMessage(conn);
buffer.WriteInt(1); buffer.Write(1);
buffer.WritePacket(protocol, p); buffer.WritePacket(protocol, p);
Send(conn, buffer); Send(conn, buffer);
} }

View File

@ -18,11 +18,6 @@
"key": "log.path", "key": "log.path",
"value": "{\"m_Value\":\"ProBuilderLog.txt\"}" "value": "{\"m_Value\":\"ProBuilderLog.txt\"}"
}, },
{
"type": "System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089",
"key": "VertexColorPalette.previousColorPalette",
"value": "{\"m_Value\":\"Assets/ProBuilder Data/Default Color Palette.asset\"}"
},
{ {
"type": "UnityEngine.ProBuilder.SemVer, Unity.ProBuilder, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null", "type": "UnityEngine.ProBuilder.SemVer, Unity.ProBuilder, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null",
"key": "about.identifier", "key": "about.identifier",
@ -37,136 +32,6 @@
"type": "System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089", "type": "System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089",
"key": "lightmapping.autoUnwrapLightmapUV", "key": "lightmapping.autoUnwrapLightmapUV",
"value": "{\"m_Value\":true}" "value": "{\"m_Value\":true}"
},
{
"type": "System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089",
"key": "mesh.newShapesSnapToGrid",
"value": "{\"m_Value\":true}"
},
{
"type": "System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089",
"key": "editor.autoRecalculateCollisions",
"value": "{\"m_Value\":false}"
},
{
"type": "System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089",
"key": "mesh.meshColliderIsConvex",
"value": "{\"m_Value\":false}"
},
{
"type": "System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089",
"key": "UnityEngine.ProBuilder.ProBuilderEditor-isUtilityWindow",
"value": "{\"m_Value\":false}"
},
{
"type": "System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089",
"key": "editor.backFaceSelectEnabled",
"value": "{\"m_Value\":false}"
},
{
"type": "System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089",
"key": "editor.toolbarIconGUI",
"value": "{\"m_Value\":false}"
},
{
"type": "System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089",
"key": "editor.showSceneInfo",
"value": "{\"m_Value\":false}"
},
{
"type": "System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089",
"key": "editor.showEditorNotifications",
"value": "{\"m_Value\":false}"
},
{
"type": "System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089",
"key": "GrowSelection.useAngle",
"value": "{\"m_Value\":true}"
},
{
"type": "System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089",
"key": "GrowSelection.iterativeGrow",
"value": "{\"m_Value\":false}"
},
{
"type": "System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089",
"key": "smoothing.showPreview",
"value": "{\"m_Value\":false}"
},
{
"type": "System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089",
"key": "smoothing.showNormals",
"value": "{\"m_Value\":false}"
},
{
"type": "System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089",
"key": "smoothing.showSettings",
"value": "{\"m_Value\":false}"
},
{
"type": "System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089",
"key": "smoothing.showHelp",
"value": "{\"m_Value\":false}"
},
{
"type": "UnityEngine.ProBuilder.PivotLocation, Unity.ProBuilder, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null",
"key": "mesh.newShapePivotLocation",
"value": "{\"m_Value\":1}"
},
{
"type": "UnityEngine.Rendering.ShadowCastingMode, UnityEngine.CoreModule, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null",
"key": "mesh.shadowCastingMode",
"value": "{\"m_Value\":1}"
},
{
"type": "UnityEngine.Material, UnityEngine.CoreModule, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null",
"key": "mesh.userMaterial",
"value": "{\"m_Value\":{\"instanceID\":0}}"
},
{
"type": "UnityEditor.StaticEditorFlags, UnityEditor, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null",
"key": "mesh.defaultStaticEditorFlags",
"value": "{\"m_Value\":0}"
},
{
"type": "UnityEngine.ProBuilder.ColliderType, Unity.ProBuilder, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null",
"key": "mesh.newShapeColliderType",
"value": "{\"m_Value\":2}"
},
{
"type": "UnityEngine.ProBuilder.UnwrapParameters, Unity.ProBuilder, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null",
"key": "lightmapping.defaultLightmapUnwrapParameters",
"value": "{\"m_Value\":{\"m_HardAngle\":88.0,\"m_PackMargin\":20.0,\"m_AngleError\":8.0,\"m_AreaError\":15.0}}"
},
{
"type": "UnityEngine.ProBuilder.SelectionModifierBehavior, Unity.ProBuilder, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null",
"key": "editor.rectSelectModifier",
"value": "{\"m_Value\":2}"
},
{
"type": "UnityEngine.ProBuilder.RectSelectMode, Unity.ProBuilder, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null",
"key": "editor.dragSelectRectMode",
"value": "{\"m_Value\":0}"
},
{
"type": "UnityEngine.ProBuilder.SelectMode, Unity.ProBuilder, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null",
"key": "editor.selectMode",
"value": "{\"m_Value\":1}"
},
{
"type": "UnityEngine.ProBuilder.ExtrudeMethod, Unity.ProBuilder, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null",
"key": "editor.extrudeMethod",
"value": "{\"m_Value\":2}"
},
{
"type": "System.Single, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089",
"key": "ExtrudeFaces.distance",
"value": "{\"m_Value\":0.5}"
},
{
"type": "System.Single, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089",
"key": "GrowSelection.angleValue",
"value": "{\"m_Value\":15.0}"
} }
] ]
} }