public int ReadInt(ref int Index) { if (IsCorrupted) { return(0); } switch (Protocol) { case HProtocols.Modern: return(BigEndian.DecypherInt(Body[Index++], Body[Index++], Body[Index++], Body[Index++])); case HProtocols.Ancient: { int Value = Ancient.DecypherInt(Body, Index); Index += Ancient.CypherInt(Value).Length; return(Value); } default: return(0); } }
protected int ReadInt(ref int index, HProtocol protocol) { if (index >= Body.Length) { return(0); } switch (Protocol) { case HProtocol.Modern: { if (index + 4 > Body.Length) { return(0); } return(Modern.DecypherInt(Body[index++], Body[index++], Body[index++], Body[index++])); } case HProtocol.Ancient: { int length = (Body[index] >> 3) & 7; if (length < 1) { length++; } if (index + length > Body.Length) { return(0); } int value = Ancient.DecypherInt(Body, index); index += length; return(value); } default: return(0); } }