* Remove an unused BuildPacket function in _Packets_.cs
* Make all blocks inherit from the abstract base class PacketBlock git-svn-id: http://libopenmetaverse.googlecode.com/svn/trunk@2278 52acb1d6-8a22-11de-b505-999d5b087335
This commit is contained in:
@@ -303,8 +303,7 @@ namespace mapgenerator
|
||||
|
||||
//writer.WriteLine(" /// <summary>" + block.Name + " block</summary>");
|
||||
writer.WriteLine(" /// <exclude/>");
|
||||
//writer.WriteLine(" [XmlType(\"" + packet.Name.ToLower() + "_" + block.Name.ToLower() + "\")]");
|
||||
writer.WriteLine(" public class " + block.Name + "Block" + Environment.NewLine + " {");
|
||||
writer.WriteLine(" public class " + block.Name + "Block : PacketBlock" + Environment.NewLine + " {");
|
||||
|
||||
foreach (MapField field in block.Fields)
|
||||
{
|
||||
@@ -315,8 +314,7 @@ namespace mapgenerator
|
||||
// Length property
|
||||
writer.WriteLine("");
|
||||
//writer.WriteLine(" /// <summary>Length of this block serialized in bytes</summary>");
|
||||
writer.WriteLine(//" [XmlIgnore]" + Environment.NewLine +
|
||||
" public int Length" + Environment.NewLine +
|
||||
writer.WriteLine(" public override int Length" + Environment.NewLine +
|
||||
" {" + Environment.NewLine +
|
||||
" get" + Environment.NewLine +
|
||||
" {");
|
||||
@@ -362,7 +360,7 @@ namespace mapgenerator
|
||||
" }" + Environment.NewLine);
|
||||
|
||||
// Initiates instance variables from a byte message
|
||||
writer.WriteLine(" public void FromBytes(byte[] bytes, ref int i)" + Environment.NewLine +
|
||||
writer.WriteLine(" public override void FromBytes(byte[] bytes, ref int i)" + Environment.NewLine +
|
||||
" {");
|
||||
|
||||
// Declare a length variable if we need it for variable fields in this constructor
|
||||
@@ -384,7 +382,7 @@ namespace mapgenerator
|
||||
|
||||
// ToBytes() function
|
||||
//writer.WriteLine(" /// <summary>Serialize this block to a byte array</summary>");
|
||||
writer.WriteLine(" public void ToBytes(byte[] bytes, ref int i)" + Environment.NewLine +
|
||||
writer.WriteLine(" public override void ToBytes(byte[] bytes, ref int i)" + Environment.NewLine +
|
||||
" {");
|
||||
|
||||
foreach (MapField field in block.Fields)
|
||||
@@ -831,22 +829,6 @@ namespace mapgenerator
|
||||
writer.WriteLine(" }" + Environment.NewLine +
|
||||
" break;" + Environment.NewLine + " }" + Environment.NewLine + Environment.NewLine +
|
||||
" return PacketType.Default;" + Environment.NewLine + " }" + Environment.NewLine);
|
||||
|
||||
|
||||
// Write the Packet.BuildPacket(PacketType) function
|
||||
writer.WriteLine(" public static Packet BuildPacket(PacketType type)");
|
||||
writer.WriteLine(" {");
|
||||
foreach (MapPacket packet in protocol.HighMaps)
|
||||
if (packet != null)
|
||||
writer.WriteLine(" if(type == PacketType." + packet.Name + ") return new " + packet.Name +"Packet();");
|
||||
foreach (MapPacket packet in protocol.MediumMaps)
|
||||
if (packet != null)
|
||||
writer.WriteLine(" if(type == PacketType." + packet.Name + ") return new " + packet.Name +"Packet();");
|
||||
foreach (MapPacket packet in protocol.LowMaps)
|
||||
if (packet != null)
|
||||
writer.WriteLine(" if(type == PacketType." + packet.Name + ") return new " + packet.Name +"Packet();");
|
||||
writer.WriteLine(" return null;" + Environment.NewLine);
|
||||
writer.WriteLine(" }" + Environment.NewLine);
|
||||
|
||||
// Write the Packet.BuildPacket() function
|
||||
writer.WriteLine(
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2006-2008, openmetaverse.org
|
||||
* Copyright (c) 2008, openmetaverse.org
|
||||
* All rights reserved.
|
||||
*
|
||||
* - Redistribution and use in source and binary forms, with or without
|
||||
@@ -377,3 +377,31 @@ namespace OpenMetaverse.Packets
|
||||
i += 7;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A block of data in a packet. Packets are composed of one or more blocks,
|
||||
/// each block containing one or more fields
|
||||
/// </summary>
|
||||
public abstract class PacketBlock
|
||||
{
|
||||
/// <summary>Current length of the data in this packet</summary>
|
||||
public abstract int Length { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Create a block from a byte array
|
||||
/// </summary>
|
||||
/// <param name="bytes">Byte array containing the serialized block</param>
|
||||
/// <param name="i">Starting position of the block in the byte array.
|
||||
/// This will point to the data after the end of the block when the
|
||||
/// call returns</param>
|
||||
public abstract void FromBytes(byte[] bytes, ref int i);
|
||||
|
||||
/// <summary>
|
||||
/// Serialize this block into a byte array
|
||||
/// </summary>
|
||||
/// <param name="bytes">Byte array to serialize this block into</param>
|
||||
/// <param name="i">Starting position in the byte array to serialize to.
|
||||
/// This will point to the position directly after the end of the
|
||||
/// serialized block when the call returns</param>
|
||||
public abstract void ToBytes(byte[] bytes, ref int i);
|
||||
}
|
||||
Reference in New Issue
Block a user