public void WriteArray(Writer writer) { if (Settings.s.game == Settings.Game.R2Revolution) { Pointer.Goto(ref writer, Pointer.Current(writer) + 4); writer.Write((byte)arrayTypeNumber); writer.Write(arrayLength); writer.Write((byte)0); writer.Write((byte)0); } else { writer.Write(arrayTypeNumber); writer.Write(arrayLength); writer.Write((byte)0); writer.Write((byte)0); writer.Write((byte)0); } arrayType = Settings.s.aiTypes.GetDsgVarType(arrayTypeNumber); if (DsgVarInfoEntry.GetDsgVarTypeFromArrayType(type) != arrayType) { Debug.LogWarning(currentbuf + " - " + arrayTypeNumber + " - " + arrayType + " - " + arrayLength + " - " + Pointer.Current(writer)); } if (valueArray != null && arrayLength == valueArray.Length) { for (uint i = 0; i < arrayLength; i++) { valueArray[i].Write(writer); } } }
public void ReadArray(Reader reader) { if (Settings.s.game == Settings.Game.R2Revolution) { reader.ReadUInt32(); arrayTypeNumber = reader.ReadByte(); arrayLength = reader.ReadByte(); reader.ReadBytes(2); // padding } else { arrayTypeNumber = reader.ReadUInt32(); arrayLength = reader.ReadByte(); reader.ReadBytes(3); // padding } arrayType = Settings.s.aiTypes.GetDsgVarType(arrayTypeNumber); if (DsgVarInfoEntry.GetDsgVarTypeFromArrayType(type) != arrayType) { Debug.LogWarning(currentbuf + " - " + type + " - " + arrayTypeNumber + " - " + arrayType + " - " + arrayLength + " - " + Pointer.Current(reader)); } if (valueArray == null || arrayLength != valueArray.Length) { valueArray = new DsgVarValue[arrayLength]; for (int i = 0; i < arrayLength; i++) { valueArray[i] = new DsgVarValue(arrayType); } } for (uint i = 0; i < arrayLength; i++) { valueArray[i].Read(reader); } }