static object ReadContent(DatReader r, byte typeCode) { if (typeCode == TC_BLOCKDATA) { return(r.ReadBytes(r.ReadUInt8())); } else if (typeCode == TC_BLOCKDATALONG) { return(r.ReadBytes(r.ReadInt32())); } else { return(ReadObject(r, typeCode)); } }
static Level ReadFormat1(Level lvl, DatReader r) { r.ReadUtf8(); // level name r.ReadUtf8(); // level author r.ReadInt64(); // created timestamp (currentTimeMillis) lvl.Width = r.ReadUInt16(); lvl.Length = r.ReadUInt16(); lvl.Height = r.ReadUInt16(); lvl.blocks = r.ReadBytes(lvl.Width * lvl.Height * lvl.Length); // TODO readfully SetupClassic013(lvl); return(lvl); }
static void SkipAnnotation(DatReader r) { byte typeCode; while ((typeCode = r.ReadUInt8()) != TC_ENDBLOCKDATA) { if (typeCode == TC_BLOCKDATA) { r.ReadBytes(r.ReadUInt8()); } else { ReadObject(r, typeCode); } } }
static JArray NewArray(DatReader r) { JArray array = new JArray(); array.Desc = ClassDesc(r); r.handles.Add(array); char type = array.Desc.Name[1]; int size = r.ReadInt32(); if (type == 'B') { array.Values = r.ReadBytes(size); } else { object[] values = new object[size]; for (int i = 0; i < values.Length; i++) { values[i] = Value(r, type); } array.Values = values; } return(array); }