public static LevelUndo Read(BinaryReader br) { long count = br.ReadInt32(); ushort x = br.ReadUInt16(); ushort z = br.ReadUInt16(); ushort y = br.ReadUInt16(); byte[] origLvl = br.ReadBytes((int)count); LevelUndo ret = new LevelUndo(x, z, y, origLvl); count = br.ReadInt64(); for (; count > 0; count--) { x = br.ReadUInt16(); z = br.ReadUInt16(); y = br.ReadUInt16(); ExtraData <ushort, ExtraData <ushort, UndoList> > xLevel = ret.changes[x]; ExtraData <ushort, UndoList> zLevel; if (xLevel == null) { xLevel = new ExtraData <ushort, ExtraData <ushort, UndoList> >(); zLevel = new ExtraData <ushort, UndoList>(); zLevel[y] = UndoList.Read(br); xLevel[z] = zLevel; ret.changes[x] = xLevel; } else { zLevel = xLevel[z]; if (zLevel == null) { zLevel = new ExtraData <ushort, UndoList>(); zLevel[y] = UndoList.Read(br); xLevel[z] = zLevel; } else { zLevel[y] = UndoList.Read(br); } } } return(ret); }
public void Add(ushort x, ushort z, ushort y, uint uid, byte type) { ExtraData <ushort, ExtraData <ushort, UndoList> > xLevel = changes[x]; ExtraData <ushort, UndoList> zLevel; UndoList yLevel; if (xLevel == null) { xLevel = new ExtraData <ushort, ExtraData <ushort, UndoList> >(); zLevel = new ExtraData <ushort, UndoList>(); yLevel = new UndoList(); yLevel.Add(type, uid); zLevel[y] = yLevel; xLevel[z] = zLevel; changes[x] = xLevel; } else { zLevel = xLevel[z]; if (zLevel == null) { zLevel = new ExtraData <ushort, UndoList>(); yLevel = new UndoList(); yLevel.Add(type, uid); zLevel[y] = yLevel; xLevel[z] = zLevel; } else { yLevel = zLevel[y]; if (yLevel == null) { yLevel = new UndoList(); yLevel.Add(type, uid); zLevel[y] = yLevel; } else { yLevel.Add(type, uid); } } } }
public void Add(ushort x, ushort z, ushort y, uint uid, byte type) { ExtraData<ushort, ExtraData<ushort, UndoList>> xLevel = changes[x]; ExtraData<ushort, UndoList> zLevel; UndoList yLevel; if (xLevel == null) { xLevel = new ExtraData<ushort, ExtraData<ushort, UndoList>>(); zLevel = new ExtraData<ushort, UndoList>(); yLevel = new UndoList(); yLevel.Add(type, uid); zLevel[y] = yLevel; xLevel[z] = zLevel; changes[x] = xLevel; } else { zLevel = xLevel[z]; if (zLevel == null) { zLevel = new ExtraData<ushort, UndoList>(); yLevel = new UndoList(); yLevel.Add(type, uid); zLevel[y] = yLevel; xLevel[z] = zLevel; } else { yLevel = zLevel[y]; if (yLevel == null) { yLevel = new UndoList(); yLevel.Add(type, uid); zLevel[y] = yLevel; } else { yLevel.Add(type, uid); } } } }
public static UndoList Read(BinaryReader br) { UndoList ret = new UndoList(); int count = br.ReadInt32(); for (int i = 0; i < count;) { TypeByte tb = br.ReadByte(); int amount; switch (tb.head) { case 0: amount = tb.amount; try { for (; amount > 0; amount--) { ret.data.Add(new UID(br.ReadUInt32())); ret.data.Add(br.ReadByte()); i += 2; } } catch { } break; case 1: amount = tb.amount; try { for (; amount > 0; amount--) { ret.data.Add(new Time(br.ReadUInt32())); ret.data.Add(br.ReadByte()); i += 2; } } catch { } break; case 2: amount = tb.amount; ret.data.Add(new Time(br.ReadUInt32())); i++; for (; amount > 0; amount--) { try { ret.data.Add(new UID(br.ReadUInt32())); ret.data.Add(br.ReadByte()); } catch { i = i; } i += 2; } break; case 3: amount = tb.amount; try { for (; amount > 0; amount--) { ret.data.Add(new Time(br.ReadUInt32())); ret.data.Add(new UID(br.ReadUInt32())); ret.data.Add(br.ReadByte()); i += 3; } } catch { } break; } } return(ret); }
public static UndoList Read(BinaryReader br) { UndoList ret = new UndoList(); int count = br.ReadInt32(); for (int i = 0; i < count; ) { TypeByte tb = br.ReadByte(); int amount; switch (tb.head) { case 0: amount = tb.amount; try { for (; amount > 0; amount--) { ret.data.Add(new UID(br.ReadUInt32())); ret.data.Add(br.ReadByte()); i += 2; } } catch { } break; case 1: amount = tb.amount; try { for (; amount > 0; amount--) { ret.data.Add(new Time(br.ReadUInt32())); ret.data.Add(br.ReadByte()); i += 2; } } catch { } break; case 2: amount = tb.amount; ret.data.Add(new Time(br.ReadUInt32())); i++; for (; amount > 0; amount--) { try { ret.data.Add(new UID(br.ReadUInt32())); ret.data.Add(br.ReadByte()); } catch { i = i; } i += 2; } break; case 3: amount = tb.amount; try { for (; amount > 0; amount--) { ret.data.Add(new Time(br.ReadUInt32())); ret.data.Add(new UID(br.ReadUInt32())); ret.data.Add(br.ReadByte()); i += 3; } } catch { } break; } } return ret; }