List<byte[]> serverValues = GetSubArrays(responseBytes, 0x00);
name = Encoding.Default.GetString(serverValues[0]);
map = Encoding.Default.GetString(serverValues[1]);
game = Encoding.Default.GetString(serverValues[2]);
description = Encoding.Default.GetString(serverValues[3]);
if (serverValues[6].Count() > 0)
{
var gameTags = GetSubArrays(serverValues[10], 0x2c);
players = serverValues[6][0];
playersmax = serverValues[6][1];
locked = gameTags[6][1] == 't';
}
else
{
var gameTags = GetSubArrays(serverValues[11], 0x2c);
players = 0;
playersmax = serverValues[7][0];
locked = gameTags[6][1] == 't';
}
-------------------------------------------------------------------
public List<byte[]> GetSubArrays(byte[] array, byte delimiter)
{
if (array == null)
return null;
var retval = new List<byte[]>();
var sectionStart = 6; //first 6 bytes of the response are a header, we don't need it
var sectionEnd = 0;
for (; sectionEnd < array.Length; sectionEnd++)
{
if (array[sectionEnd] != delimiter) continue;
var tempArray = new byte[sectionEnd - sectionStart];
Buffer.BlockCopy(array,sectionStart,tempArray,0,sectionEnd - sectionStart);
retval.Add(tempArray);
sectionStart = sectionEnd + 1;
}
return retval;
}