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); } }
protected override void ReadInternal(Reader reader) { off_dsgMemBuffer = Pointer.Read(reader); off_dsgVarInfo = Pointer.Read(reader); if (Settings.s.game == Settings.Game.R2Revolution) { dsgMemBufferLength = reader.ReadUInt16(); amountOfInfos = reader.ReadUInt16(); } else { dsgMemBufferLength = reader.ReadUInt32(); amountOfInfos = reader.ReadByte(); reader.ReadBytes(3); } dsgVarInfos = new DsgVarInfoEntry[amountOfInfos]; defaultValues = new DsgVarValue[amountOfInfos]; if (amountOfInfos > 0) { Pointer.DoAt(ref reader, off_dsgVarInfo, () => { //l.print(dsgVar.amountOfInfos); for (uint i = 0; i < amountOfInfos; i++) { dsgVarInfos[i] = DsgVarInfoEntry.Read(reader, Pointer.Current(reader), i); defaultValues[i] = new DsgVarValue(dsgVarInfos[i].type, null); defaultValues[i].ReadFromDsgVarBuffer(reader, dsgVarInfos[i], this); //l.print(infoEntry.offset + " - " + infoEntry.typeNumber + " - " + infoEntry.type + " - " + infoEntry.offsetInBuffer); /*if (dsgMem != null) { * if (Settings.s.platform != Settings.Platform.DC) { * infoEntry.value = dsgVar.ReadValueFromDsgMemBuffer(reader, infoEntry, dsgMem); * } * if (dsgMem.memBufferInitial != null) { * infoEntry.initialValue = dsgVar.ReadInitialValueFromDsgMemBuffer(reader, infoEntry, dsgMem); * if (Settings.s.platform == Settings.Platform.DC) { * infoEntry.value = infoEntry.initialValue; * } * } * } else { * infoEntry.value = dsgVar.ReadValueFromDsgVarBuffer(reader, infoEntry, dsgVar); * } * dsgVar.dsgVarInfos[i] = infoEntry;*/ } }); } }
protected override void ReadInternal(Reader reader) { //MapLoader.Loader.print("DsgMem " + Offset); Pointer dsgVarPointer = Pointer.Read(reader); Pointer.DoAt(ref reader, dsgVarPointer, () => { off_dsgVar = Pointer.Read(reader); }); memBufferInitial = Pointer.Read(reader); memBuffer = Pointer.Read(reader); dsgVar = MapLoader.Loader.FromOffsetOrRead <DsgVar>(reader, off_dsgVar); if (dsgVar != null && dsgVar.amountOfInfos > 0) { if (memBuffer != null && Settings.s.platform != Settings.Platform.DC) { // Current MemBuffer is cleared in DC files values = new DsgVarValue[dsgVar.amountOfInfos]; for (int i = 0; i < dsgVar.amountOfInfos; i++) { values[i] = new DsgVarValue(dsgVar.dsgVarInfos[i].type, this); values[i].ReadFromDsgMemBuffer(reader, dsgVar.dsgVarInfos[i], this); values[i].RegisterReferences(this); } } if (memBufferInitial != null) { valuesInitial = new DsgVarValue[dsgVar.amountOfInfos]; for (int i = 0; i < dsgVar.amountOfInfos; i++) { valuesInitial[i] = new DsgVarValue(dsgVar.dsgVarInfos[i].type, this); valuesInitial[i].ReadFromDsgMemBufferInitial(reader, dsgVar.dsgVarInfos[i], this); valuesInitial[i].RegisterReferences(this); } } } }
public bool IsSameValue(DsgVarValue other) { if (other == null) { return(false); } if (Equals(other)) { return(true); } if (type != other.type) { return(false); } switch (type) { case DsgVarInfoEntry.DsgVarType.Boolean: return(valueBool == other.valueBool); case DsgVarInfoEntry.DsgVarType.Byte: return(valueByte == other.valueByte); case DsgVarInfoEntry.DsgVarType.UByte: return(valueUByte == other.valueUByte); case DsgVarInfoEntry.DsgVarType.Short: return(valueShort == other.valueShort); case DsgVarInfoEntry.DsgVarType.UShort: return(valueUShort == other.valueUShort); case DsgVarInfoEntry.DsgVarType.Int: return(valueInt == other.valueInt); case DsgVarInfoEntry.DsgVarType.UInt: return(valueUInt == other.valueUInt); case DsgVarInfoEntry.DsgVarType.Float: return(valueFloat == other.valueFloat); case DsgVarInfoEntry.DsgVarType.Vector: return(valueVector == other.valueVector); case DsgVarInfoEntry.DsgVarType.Text: return(valueText == other.valueText); case DsgVarInfoEntry.DsgVarType.Graph: return(valuePointer == other.valuePointer); case DsgVarInfoEntry.DsgVarType.WayPoint: return(valuePointer == other.valuePointer); case DsgVarInfoEntry.DsgVarType.GameMaterial: return(valuePointer == other.valuePointer); case DsgVarInfoEntry.DsgVarType.VisualMaterial: return(valuePointer == other.valuePointer); case DsgVarInfoEntry.DsgVarType.ObjectList: return(valuePointer == other.valuePointer); case DsgVarInfoEntry.DsgVarType.List: if (valueList.curLength != other.valueList.curLength || valueList.maxLength != other.valueList.maxLength) { return(false); } for (int i = 0; i < valueList.maxLength; i++) { if (valueList.list[i].value != other.valueList.list[i].value) { return(false); } } return(true); case DsgVarInfoEntry.DsgVarType.Light: return(valuePointer == other.valuePointer); case DsgVarInfoEntry.DsgVarType.Comport: return(valuePointer == other.valuePointer); case DsgVarInfoEntry.DsgVarType.Input: return(valuePointer == other.valuePointer); case DsgVarInfoEntry.DsgVarType.Perso: return(valuePointer == other.valuePointer); case DsgVarInfoEntry.DsgVarType.Action: return(valuePointer == other.valuePointer); case DsgVarInfoEntry.DsgVarType.SuperObject: return(valuePointer == other.valuePointer); case DsgVarInfoEntry.DsgVarType.Caps: return(valueCaps == other.valueCaps); case DsgVarInfoEntry.DsgVarType.SOLinks: return(valueSOLinks == other.valueSOLinks); case DsgVarInfoEntry.DsgVarType.SoundEvent: return(valueSoundEvent == other.valueSoundEvent); case DsgVarInfoEntry.DsgVarType.Way: return(valueWay == other.valueWay); // Arrays case DsgVarInfoEntry.DsgVarType.ActionArray: case DsgVarInfoEntry.DsgVarType.FloatArray: case DsgVarInfoEntry.DsgVarType.IntegerArray: case DsgVarInfoEntry.DsgVarType.PersoArray: case DsgVarInfoEntry.DsgVarType.SoundEventArray: case DsgVarInfoEntry.DsgVarType.SuperObjectArray: case DsgVarInfoEntry.DsgVarType.TextArray: case DsgVarInfoEntry.DsgVarType.TextRefArray: case DsgVarInfoEntry.DsgVarType.VectorArray: case DsgVarInfoEntry.DsgVarType.WayPointArray: case DsgVarInfoEntry.DsgVarType.GraphArray: case DsgVarInfoEntry.DsgVarType.Array11: case DsgVarInfoEntry.DsgVarType.Array9: if (arrayType != other.arrayType || arrayLength != other.arrayLength) { return(false); } for (int i = 0; i < valueArray.Length; i++) { if (!valueArray[i].IsSameValue(other.valueArray[i])) { return(false); } } return(true); } return(true); }