Fixed the ToBytesMultiple() packet splitter to use a do-while loop instead of a while loop to handle the case where there were zero variable blocks. This works with the unit test checked in with the previous commit

git-svn-id: http://libopenmetaverse.googlecode.com/svn/libopenmetaverse/trunk@3194 52acb1d6-8a22-11de-b505-999d5b087335
This commit is contained in:
John Hurliman
2009-10-30 06:56:25 +00:00
parent a8a41e8044
commit 78b16f20b4
2 changed files with 454 additions and 453 deletions

View File

@@ -815,24 +815,7 @@ namespace mapgenerator
}
}
bool first = true;
writer.WriteLine(" while (");
foreach (MapBlock block in packet.Blocks)
{
string sanitizedName;
if (block.Name == "Header") { sanitizedName = "_" + block.Name; }
else { sanitizedName = block.Name; }
if (block.Count == -1)
{
if (first) first = false;
else writer.WriteLine(" ||");
// Variable count block
writer.Write(" " + sanitizedName + "Start < " + sanitizedName + ".Length");
}
}
writer.WriteLine(")");
writer.WriteLine(" do");
writer.WriteLine(" {");
// Count how many variable blocks can go in this packet
@@ -907,7 +890,25 @@ namespace mapgenerator
writer.WriteLine();
writer.WriteLine(" packets.Add(packet);");
writer.WriteLine(" }");
writer.WriteLine(" } while (");
bool first = true;
foreach (MapBlock block in packet.Blocks)
{
string sanitizedName;
if (block.Name == "Header") { sanitizedName = "_" + block.Name; }
else { sanitizedName = block.Name; }
if (block.Count == -1)
{
if (first) first = false;
else writer.WriteLine(" ||");
// Variable count block
writer.Write(" " + sanitizedName + "Start < " + sanitizedName + ".Length");
}
}
writer.WriteLine(");");
writer.WriteLine();
writer.WriteLine(" return packets.ToArray();");
writer.WriteLine(" }");