public bool Load(Stream stream) { Chunks = new List <Chunk>(); using (BinaryReader reader = new BinaryReader(stream)) { if (!ReadHeader(reader)) { FastConsole.Flush(); return(false); } ChunkType chunkType = ChunkUtils.PeekNextChunk(reader); while (chunkType != ChunkType.None) { Chunk masterChunk = ChunkUtils.Instance(chunkType); if (!masterChunk.Load(reader)) { FastConsole.Flush(); return(false); } Chunks.Add(masterChunk); chunkType = ChunkUtils.PeekNextChunk(reader); } } FastConsole.Flush(); return(true); }
public Chunk(byte[] data, ChunkType type) { size = data.Length; this.type = type; this.data = data; crc = CalculateCrc(); }
/// <summary> Return an Extended label with formatting dependent on chunkType</summary> /// <param name="chunkType"></param> /// <returns></returns> private ExtendedLabel GetFormattedLabel(ChunkType chunkType) { ExtendedLabel label = new ExtendedLabel(); FormatLabel(label, chunkType); return(label); }
public InitAckChunk(ChunkType type, byte flags, int length, ByteBuffer pkt) : base(type, flags, length, pkt) { if (_body.remaining() >= 16) { _initiateTag = _body.GetInt(); _adRecWinCredit = _body.GetUInt(); ; _numOutStreams = _body.GetUShort(); _numInStreams = _body.GetUShort(); _initialTSN = _body.GetUInt(); logger.LogDebug("Init Ack" + this.ToString()); while (_body.hasRemaining()) { VariableParam v = readVariable(); _varList.Add(v); } foreach (VariableParam v in _varList) { // now look for variables we are expecting... //logger.LogDebug("variable of type: " + v.getName() + " " + v.ToString()); if (typeof(StateCookie).IsAssignableFrom(v.GetType())) { _cookie = ((StateCookie)v).getData(); } //else //{ // logger.LogDebug("ignored variable of type: " + v.getName()); //} } } }
public BeatChunk(double b, ChunkType type, double np, double dp) { beat = b; chunkType = type; numPos = np; denomPos = dp; }
public static void RM_Mod_UnlockedCamera(TwinsFile RM_Archive, ChunkType chunk) { for (uint section_id = (uint)RM_Sections.Instances1; section_id <= (uint)RM_Sections.Instances8; section_id++) { if (!RM_Archive.ContainsItem(section_id)) { continue; } TwinsSection section = RM_Archive.GetItem <TwinsSection>(section_id); if (section.Records.Count > 0) { if (!section.ContainsItem((uint)RM_Instance_Sections.Camera)) { continue; } TwinsSection cameras = section.GetItem <TwinsSection>((uint)RM_Instance_Sections.Camera); for (int i = 0; i < cameras.Records.Count; ++i) { Camera cam = (Camera)cameras.Records[i]; cam.Enabled = 0; cameras.Records[i] = cam; } } } }
public static void RM_Mod_SyncScripts(TwinsFile RM_Archive, ChunkType chunk) { if (RM_Archive.ContainsItem((uint)RM_Sections.Code)) { TwinsSection code_section = RM_Archive.GetItem <TwinsSection>((uint)RM_Sections.Code); if (code_section.ContainsItem((uint)RM_Code_Sections.Script)) { TwinsSection script_section = code_section.GetItem <TwinsSection>((uint)RM_Code_Sections.Script); if (script_section.Records.Count > 0) { List <uint> scripts = new List <uint>(); for (int i = 0; i < script_section.Records.Count; i++) { scripts.Add(script_section.Records[i].ID); script_section.RemoveItem(script_section.Records[i].ID); } for (int i = 0; i < scripts.Count; i++) { script_section.Records.Add(Twins_Data.allScripts[scripts[i]]); } } } } }
private ChunkTask GetChunkTask(ArenaController arena, ChunkType type) { switch (type) { case ChunkType.Fighting: return(new FightingTask(() => this.enemies)); case ChunkType.Mining: return(new MiningTask(() => this.miningSpots)); case ChunkType.Fishing: return(new FishingTask(() => this.fishingSpots)); case ChunkType.Woodcutting: return(new WoodcuttingTask(() => this.trees)); case ChunkType.Crafting: return(new CraftingTask(() => this.craftingStations.Where(x => x.StationType == CraftingStationType.Crafting).ToList())); case ChunkType.Farming: return(new FarmingTask(() => this.farmingPatches)); case ChunkType.Cooking: return(new CookingTask(() => this.craftingStations.Where(x => x.StationType == CraftingStationType.Cooking).ToList())); //case ChunkType.Arena: return new ArenaTask(arena); default: return(null); } }
public ChunkHeader(byte[] buffer, int offset) { ChunkType = (ChunkType)LittleEndianConverter.ToUInt16(buffer, offset + 0); Reserved = LittleEndianConverter.ToUInt16(buffer, offset + 2); ChunkSize = LittleEndianConverter.ToUInt32(buffer, offset + 4); TotalSize = LittleEndianConverter.ToUInt32(buffer, offset + 8); }
public void GotoClosest(ChunkType type) { if (!animator) { animator = GetComponentInChildren <Animator>(); } if (!chunkManager) { chunkManager = FindObjectOfType <ChunkManager>(); } if (!chunkManager) { Debug.LogError($"No ChunkManager found!"); return; } previousChunk = Chunk; Chunk = chunkManager.GetChunkOfType(Stats.CombatLevel, transform.position, type); if (Chunk == null) { Debug.LogError($"No suitable chunk found of type '{type}'"); return; } playerAnimations.ResetAnimationStates(); GotoPosition(Chunk.CenterPointWorld); }
static public Chunk Instance(ChunkType type) { switch (type) { case ChunkType.gfxBody: return(new GBODChunk()); case ChunkType.phyBoundingBox: return(new BBOXChunk()); case ChunkType.phyCPDefinitionGroupImpl: return(new CPDGChunk()); case ChunkType.phyCPDefinitionImpl: return(new CPDFChunk()); case ChunkType.gfxGeometryPiece: return(new GPCEChunk()); case ChunkType.gfxGeometryPieceSkinned: return(new GSKNChunk()); case ChunkType.effCompiledEffect: return(new CPFXChunk()); } Debugger.Break(); return(null); }
/// <summary> /// Writes a color image into a DjVu IW44 file. This function creates a /// composite Form element containing one or more IW44 encoded chunks. /// Data for each chunk is generated with a call to EncodeChunk method /// while encoding is controlled by the corresponding parameters in an array /// parameter settings. /// </summary> /// <param name="writer"></param> /// <param name="settings"></param> /// <returns></returns> public DjvuFormElement EncodeImage(IDjvuWriter writer, int nchunks, InterWaveEncoderSettings[] settings, ChunkType formType = ChunkType.PM44Form, ChunkType nodeType = ChunkType.PM44) { if (_YEncoder != null) { throw new DjvuInvalidOperationException($"Encoder already exists or left open from previous operation."); } int flag = 1; PM44Form form = (PM44Form)DjvuParser.CreateEncodedDjvuNode(writer, null, formType, 0); for (int i = 0; flag != 0 && i < nchunks; i++) { byte[] data = null; using (MemoryStream stream = new MemoryStream()) { flag = EncodeChunk(stream, settings[i]); data = new byte[stream.Position]; Buffer.BlockCopy(stream.GetBuffer(), 0, data, 0, data.Length); } PM44Chunk chunk = (PM44Chunk)DjvuParser.CreateEncodedDjvuNode(writer, form, nodeType, data.Length); chunk.ChunkData = data; form.AddChild(chunk); } CloseEncoder(); return(form); }
public Chunk(Block[,] inputBlocks, int height, int width) { MaxWorldHeight = height; MaxWorldWidth = width; Blocks = inputBlocks; for (int x = 0; x < 10; x++) { for (int y = 0; y < 10; y++) { Block.BlockType type = Blocks[x, y].Type; switch (type) { case Block.BlockType.NULL: OpenBlocks.Add(Blocks[x, y]); break; case Block.BlockType.Indescructible: IndestructibleBlocks.Add(Blocks[x, y]); break; case Block.BlockType.Destructible: DestuctibleBlocks.Add(Blocks[x, y]); break; default: break; } } } Type = ChunkType.Empty; }
public void SetShallowParseLayer(ChunkType chunkType) { if (root != null) { ((ParseNodeDrawable)root).SetShallowParseLayer(chunkType); } }
BasicFCurveChannelType GetFCurveChannelType(int channel) { ChunkType type = (ChunkType)channel; if (type == ChunkType.Translate) { return(BasicFCurveChannelType.Translation); } if (type == ChunkType.RotateZYX) { return(BasicFCurveChannelType.Rotation); } if (type == ChunkType.RotateYXZ) { return(BasicFCurveChannelType.Rotation); } if (type == ChunkType.RotateQ) { return(BasicFCurveChannelType.Rotation); } if (type == ChunkType.Scale) { return(BasicFCurveChannelType.Scaling); } if (type == ChunkType.Scale2) { return(BasicFCurveChannelType.Scaling); } if (type == ChunkType.Diffuse) { return(BasicFCurveChannelType.Diffuse); } return(BasicFCurveChannelType.None); }
public VertexChunk(ChunkType type) : this() { Type = type; switch (type) { case ChunkType.Vertex_VertexSH: case ChunkType.Vertex_Vertex: case ChunkType.Vertex_VertexDiffuse8: case ChunkType.Vertex_VertexUserFlags: case ChunkType.Vertex_VertexNinjaFlags: case ChunkType.Vertex_VertexDiffuseSpecular5: case ChunkType.Vertex_VertexDiffuseSpecular4: case ChunkType.Vertex_VertexNormalSH: case ChunkType.Vertex_VertexNormal: case ChunkType.Vertex_VertexNormalDiffuse8: case ChunkType.Vertex_VertexNormalUserFlags: case ChunkType.Vertex_VertexNormalNinjaFlags: case ChunkType.Vertex_VertexNormalDiffuseSpecular5: case ChunkType.Vertex_VertexNormalDiffuseSpecular4: case ChunkType.End: break; default: throw new NotSupportedException("Unsupported chunk type " + type + "."); } }
public Level(ChunkType chunkType) { _chunkType = chunkType; _generator = ChunkGeneratorFactory.Instance.GetGenerator(chunkType, CHUNK_WIDTH, CHUNK_HEIGHT, null); _chunks = new Chunk[LEVEL_HEIGHT, LEVEL_WIDTH]; _ambientLightLevel = _generator.AmbientLightLevel; }
/// <summary> /// Чтение чанка из файла /// </summary> /// <param name="f">Поток откуда читать</param> public override void Read(BinaryReader f, uint size) { Children.Clear(); uint quota = 0; while (quota < size) { Chunk c; // Чтение данных string nm = f.ReadConstantString(7); ChunkType ct = (ChunkType)f.ReadByte(); uint sz = f.ReadUInt32(); // Создание чанка if (ct == ChunkType.RawDataChunk) { c = new DataChunk(nm); } else if (ct == ChunkType.KeyValueChunk) { c = new KeyValueChunk(nm); } else { c = new ContainerChunk(nm); } // Читаем содержимое c.Read(f, sz); // Увеличиваем квоту quota += 12 + c.Size; } }
/// <summary> /// Returns the struct size of a vertex chunk /// </summary> /// <param name="type"></param> /// <returns></returns> public static ushort Size(this ChunkType type) { switch (type) { case ChunkType.Vertex_Vertex: return(3); case ChunkType.Vertex_VertexSH: case ChunkType.Vertex_VertexDiffuse8: case ChunkType.Vertex_VertexUserAttributes: case ChunkType.Vertex_VertexNinjaAttributes: case ChunkType.Vertex_VertexDiffuseSpecular5: case ChunkType.Vertex_VertexDiffuseSpecular4: return(4); case ChunkType.Vertex_VertexNormal: return(6); case ChunkType.Vertex_VertexNormalDiffuse8: case ChunkType.Vertex_VertexNormalUserAttributes: case ChunkType.Vertex_VertexNormalNinjaAttributes: case ChunkType.Vertex_VertexNormalDiffuseSpecular5: case ChunkType.Vertex_VertexNormalDiffuseSpecular4: return(7); case ChunkType.Vertex_VertexNormalSH: return(8); default: return(0); } }
private GameObject[] GetChunks(ChunkType type) { // Check the cache first. GameObject[] chunks; if (chunkCache.TryGetValue(type, out chunks)) { return(chunks); } // Find chunks with correct tag and zone. GameObject[] chunksInFolder = Resources.LoadAll <GameObject>("Chunks/" + zone.ToString() + "/" + ChunkLocation(type)); List <GameObject> validChunks = new List <GameObject>(); foreach (GameObject c in chunksInFolder) { if (c.GetComponent <Chunk>().zone == zone && c.tag == type.ToString()) { validChunks.Add(c); } } // Return the collected chunks. chunks = validChunks.ToArray(); chunkCache.Add(type, chunks); return(chunks); }
public AseDummyChunk(AseFrame frame, AseReader reader, ChunkType type, int size) : base(frame) { m_ChunkType = type; ChunkSize = size; Bytes = reader.ReadBYTEs(size); }
public Chunk() { _aSeq = new List <string>(); _bSeq = new List <string>(); _oSeq = new List <string>(); ChunkType = default(ChunkType); }
public Chunk(List <string> aSeqs, List <string> oSeqs, List <string> bSeqs) { _aSeq = aSeqs ?? new List <string>(); _bSeq = bSeqs ?? new List <string>(); _oSeq = oSeqs ?? new List <string>(); this.ChunkType = DefineChunkType(_aSeq, _oSeq, _bSeq); }
// TODO Removing multiple chunks at a time would be useful /// <summary> /// Removes a chunk from the loaded PNG /// </summary> /// <param name="chunkBeingRemoved"></param> public void RemoveChunk(ChunkType chunkBeingRemoved) { int offset = PAYLOAD_OFFSET; int chunkDataLength = 0; int imageLength = RawImageData.Length; ChunkType chunkType = ChunkType.Unknown; int maxLengthToCheck = imageLength;//+ MINIMUM_CHUNK_LENGTH; using (MemoryStream ms = new MemoryStream()) { ms.Write(RawImageData, 0, offset);//png header while (offset < maxLengthToCheck) { chunkDataLength = ReadChunkLength(offset); chunkType = ReadChunkType(offset); if (chunkType != chunkBeingRemoved) { ms.Write(RawImageData, offset, MINIMUM_CHUNK_LENGTH + chunkDataLength); offset += MINIMUM_CHUNK_LENGTH + chunkDataLength; } else { // jump over the chunk we want to filter offset += MINIMUM_CHUNK_LENGTH + chunkDataLength; } } RawImageData = ms.ToArray(); } }
public void AddToEnd(string aStr, string oStr, string bStr) { if (_aSeq == null) { throw new InvalidOperationException("ASequence is null"); } if (_oSeq == null) { throw new InvalidOperationException("OSequence is null"); } if (_bSeq == null) { throw new InvalidOperationException("BSequence is null"); } _aSeq.Add(aStr); _oSeq.Add(oStr); _bSeq.Add(bStr); var chunkTypeNew = DefineChunkType(aStr, oStr, bStr); if (this.ChunkType == ChunkType.Chunk && chunkTypeNew != ChunkType.Chunk || this.ChunkType != ChunkType.Chunk && chunkTypeNew == ChunkType.Chunk) { throw new Exception("Can't mix Chunks and Hunks"); } this.ChunkType = this.ChunkType.GetCommonWith(chunkTypeNew); }
public ChunkInfo(ChunkType type, ulong length) { Type = type; Length = length; Remaining = length; ContainsSubChunks = false; }
private AseChunk ReadChunk(AseReader reader) { uint size = reader.ReadDWORD(); ChunkType type = (ChunkType)reader.ReadWORD(); return(ChunkFactory.ReadChunk(this, type, (int)(size - 6), reader)); }
public void AddNewChunks() { ChunkIndex++; ChunkType nextChunkType = RandomChunkType(); PreviousChunksType.Insert(0, nextChunkType); if (PreviousChunksType.Count > 10) { PreviousChunksType.RemoveAt(PreviousChunksType.Count - 1); } switch (nextChunkType) { case ChunkType.RightOpened: AddRightOpenedLane(); break; case ChunkType.LeftOpened: AddLeftOpenedLane(); break; case ChunkType.BothOpened: AddBothOpenedLane(); break; case ChunkType.BothClosed: AddBothClosedLane(); break; } RemovePreviousChunks(); }
public ChunkInfo(int[][][] tileInfo, string name, ChunkType type) { this.tileInfo = tileInfo; this.name = name; gPos = Vector2Int.zero; this.type = type; }
public ChunkSide(Chunk chunk, ChunkProvider provider) { this.chunk = chunk; this.provider = provider; chunks = new Dictionary <CubeFace, Chunk>() { { CubeFace.TOP, null }, { CubeFace.BOTTOM, null }, { CubeFace.FRONT, null }, { CubeFace.BACK, null }, { CubeFace.LEFT, null }, { CubeFace.RIGHT, null }, }; positions = new Dictionary <CubeFace, Position>() { { CubeFace.TOP, chunk.Position + Position.Up }, { CubeFace.BOTTOM, chunk.Position + Position.Down }, { CubeFace.FRONT, chunk.Position + Position.Forward }, { CubeFace.BACK, chunk.Position + Position.Back }, { CubeFace.LEFT, chunk.Position + Position.Left }, { CubeFace.RIGHT, chunk.Position + Position.Right }, }; chunkType = chunk.ChunkType; }
public Chunk(int p,int l,ChunkType ct,byte[] d) { pos = p; length = l; type = ct; data = new byte[length]; System.Array.Copy(d,pos,data,0,length); }
public static DebuggingChunk Parse(BytecodeReader reader, ChunkType chunkType, int chunkSize) { var result = new DebuggingChunk(); if (chunkType == ChunkType.Sdbg) // SDGB is not supported. return result; result.PdbBytes = reader.ReadBytes(chunkSize); return result; }
public MMChunk(FourCC fourCC, Stream st) { m_fourCC = fourCC; m_nSize = 0; m_bDirty = false; m_str = st; m_posCurrent = st.Position; m_posStart = st.Position; m_chunkList = new ArrayList(); m_ckType = ChunkType.Riff; }
public static InputOutputSignatureChunk Parse(BytecodeReader reader, ChunkType chunkType, ProgramType programType) { InputOutputSignatureChunk result; switch (chunkType) { case ChunkType.Isgn : result = new InputSignatureChunk(); break; case ChunkType.Osgn : case ChunkType.Osg5 : result = new OutputSignatureChunk(); break; case ChunkType.Pcsg : result = new PatchConstantSignatureChunk(); break; default : throw new ArgumentOutOfRangeException("chunkType", "Unrecognised chunk type: " + chunkType); } var chunkReader = reader.CopyAtCurrentPosition(); var elementCount = chunkReader.ReadUInt32(); var uniqueKey = chunkReader.ReadUInt32(); SignatureElementSize elementSize; switch (chunkType) { case ChunkType.Osg5 : elementSize = SignatureElementSize._7; break; case ChunkType.Isgn: case ChunkType.Osgn: case ChunkType.Pcsg: elementSize = SignatureElementSize._6; break; default: throw new ArgumentOutOfRangeException("chunkType", "Unrecognised chunk type: " + chunkType); } for (int i = 0; i < elementCount; i++) result.Parameters.Add(SignatureParameterDescription.Parse(reader, chunkReader, chunkType, elementSize, programType)); return result; }
/// <summary>This method acts as a factory for sub-classes from the <see cref="XmlTreeItem"/> /// class.</summary> /// <param name="buffer">Buffer to get bytes from.</param> /// <param name="offset">Offset of the first unconsumed buffer byte. Will be updated on /// return to denote additional consumed bytes.</param> /// <param name="chunkType">The chunk type that has been detected.</param> /// <param name="stringPool">String pool from the compressed document.</param> /// <returns></returns> internal static XmlTreeItem Create(byte[] buffer, ref int offset, ChunkType chunkType, StringPool stringPool) { bool startElement = false; switch(chunkType) { case ChunkType.XmlNamespaceStart: startElement = true; goto case ChunkType.XmlNamespaceEnd; case ChunkType.XmlNamespaceEnd: return new XmlNamespaceItem(buffer, ref offset, stringPool, startElement); case ChunkType.XmlElementStart: startElement = true; goto case ChunkType.XmlElementEnd; case ChunkType.XmlElementEnd: return new XmlElementItem(buffer, ref offset, stringPool, startElement); default: throw new ArgumentException(); } }
public IChunkGenerator GetGenerator(ChunkType chunkType, int chunkWidth, int chunkHeight, string seed) { switch (chunkType) { case ChunkType.Overworld: return new OverworldChunkGenerator(chunkWidth, chunkHeight, seed); case ChunkType.Cavern: return new CavernChunkGenerator(chunkWidth, chunkHeight, seed); case ChunkType.BSPDungeon: throw new NotImplementedException(); case ChunkType.DugoutDungeon: throw new NotImplementedException(); case ChunkType.Labyrinth: throw new NotImplementedException(); default: throw new NotImplementedException(); } }
public virtual void Read(BinaryReader stream) { // Read the data. type = (ChunkType)stream.ReadInt16(); allDataBytes = stream.ReadInt32(); dataBytes = allDataBytes - 6; // data - header }
public Chunk(string val, ChunkType type) { Value = val; Type = type; }
public static SignatureParameterDescription Parse(BytecodeReader reader, BytecodeReader parameterReader, ChunkType chunkType, SignatureElementSize size, ProgramType programType) { uint stream = 0; if (size == SignatureElementSize._7) stream = parameterReader.ReadUInt32(); uint nameOffset = parameterReader.ReadUInt32(); var nameReader = reader.CopyAtOffset((int) nameOffset); var result = new SignatureParameterDescription { SemanticName = nameReader.ReadString(), SemanticIndex = parameterReader.ReadUInt32(), SystemValueType = (Name) parameterReader.ReadUInt32(), ComponentType = (RegisterComponentType) parameterReader.ReadUInt32(), Register = parameterReader.ReadUInt32(), Stream = stream, //MinPrecision = (MinPrecision) parameterReader.ReadByte() TODO }; uint mask = parameterReader.ReadUInt32(); result.Mask = mask.DecodeValue<ComponentMask>(0, 7); result.ReadWriteMask = mask.DecodeValue<ComponentMask>(8, 15); // This is my guesswork, but it works so far... if (chunkType == ChunkType.Osg5 || chunkType == ChunkType.Osgn || (chunkType == ChunkType.Pcsg && programType == ProgramType.HullShader)) result.ReadWriteMask = (ComponentMask) (ComponentMask.All - result.ReadWriteMask); // Vertex and pixel shaders need special handling for SystemValueType in the output signature. if ((programType == ProgramType.PixelShader || programType == ProgramType.VertexShader) && (chunkType == ChunkType.Osg5 || chunkType == ChunkType.Osgn)) { if (result.Register == 0xffffffff) switch (result.SemanticName.ToUpper()) { case "SV_DEPTH": result.SystemValueType = Name.Depth; break; case "SV_COVERAGE": result.SystemValueType = Name.Coverage; break; case "SV_DEPTHGREATEREQUAL": result.SystemValueType = Name.DepthGreaterEqual; break; case "SV_DEPTHLESSEQUAL": result.SystemValueType = Name.DepthLessEqual; break; } else if (programType == ProgramType.PixelShader) result.SystemValueType = Name.Target; } return result; }
internal protected byte[] FindStartOfSound(int sound, ChunkType ct = ChunkType.MThd | ChunkType.FORM) { int size, pos; var ptr = ScummEngine.Instance.ResourceManager.GetSound(ScummEngine.Instance.Sound.MusicType, sound); if (ptr == null) { Debug.WriteLine("IMuseInternal::findStartOfSound(): Sound {0} doesn't exist", sound); return null; } // Check for old-style headers first, like 'RO' const ChunkType trFlag = ChunkType.MThd | ChunkType.FORM; if (System.Text.Encoding.UTF8.GetString(ptr, 0, 3) == "ROL") return ct == trFlag ? ptr : null; if (System.Text.Encoding.UTF8.GetString(ptr, 4, 2) == "SO") { if (ct == trFlag) { var tmp = new byte[ptr.Length - 4]; Array.Copy(ptr, 4, tmp, 0, tmp.Length); return tmp; } return null; } var ids = new string[] { "MThd", "FORM", "MDhd", "MDpg" }; using (var ms = new MemoryStream(ptr)) { var br = new BinaryReader(ms); ms.Seek(4, SeekOrigin.Current); size = (int)br.ReadUInt32BigEndian(); // Okay, we're looking for one of those things: either // an 'MThd' tag (for SMF), or a 'FORM' tag (for XMIDI). size = 48; // Arbitrary; we should find our tag within the first 48 bytes of the resource pos = 0; while (pos < size) { for (int i = 0; i < ids.Length; ++i) { var sig = System.Text.Encoding.UTF8.GetString(br.ReadBytes(4)); ms.Seek(-4, SeekOrigin.Current); if ((((int)ct) & (1 << i)) != 0 && (sig == ids[i])) { var tmp = new byte[ptr.Length - ms.Position]; Array.Copy(ptr, (int)ms.Position, tmp, 0, tmp.Length); return tmp; } } ++pos; // We could probably iterate more intelligently ms.Seek(1, SeekOrigin.Current); } if (ct == (ChunkType.MThd | ChunkType.FORM)) Debug.WriteLine("IMuseInternal.FindStartOfSound(): Failed to align on sound {0}", sound); } return null; }
public FLCChunk GetChunkByType(ChunkType type) { for (int i = 0; i < SubChunks.Count; i++) { if (SubChunks[i].Type == type) return SubChunks[i]; } return null; }
public static string StringFromType(ChunkType type) { return type.ToString(); }
public Chunk(ChunkType type, int resoureses) { Resourses = resoureses; Type = type; }
public DescriptionAttribute(string description, ChunkType chunkType = ChunkType.Unknown) { _description = description; _chunkType = chunkType; }
int CountChild( Chunk chunk, ChunkType type ) { int count = 0 ; for ( int pos = chunk.Child ; pos < chunk.Next ; ) { ChunkType type2 = (ChunkType)( BitConverter.ToUInt16( fileImage, pos ) & ~0x8000 ) ; if ( type2 == type ) count ++ ; pos += BitConverter.ToInt32( fileImage, pos + 4 ) ; } return count ; }
int FindChild( Chunk chunk, ChunkType type, int index ) { for ( int pos = chunk.Child ; pos < chunk.Next ; ) { ChunkType type2 = (ChunkType)( BitConverter.ToUInt16( fileImage, pos ) & ~0x8000 ) ; if ( type2 == type && index -- == 0 ) return pos ; pos += BitConverter.ToInt32( fileImage, pos + 4 ) ; } return 0 ; }
public static Poly CreatePoly(ChunkType type) { switch (type) { case ChunkType.Volume_Polygon3: return new Triangle(); case ChunkType.Volume_Polygon4: return new Quad(); case ChunkType.Volume_Strip: throw new ArgumentException( "Cannot create strip-type poly without additional information.\nUse Strip.Strip(int NumVerts, bool Reverse) instead.", "type"); } throw new ArgumentException("Unknown poly type!", "type"); }
public static Poly CreatePoly(ChunkType type, byte[] file, int address, byte userFlags) { switch (type) { case ChunkType.Volume_Polygon3: return new Triangle(file, address, userFlags); case ChunkType.Volume_Polygon4: return new Quad(file, address, userFlags); case ChunkType.Volume_Strip: return new Strip(file, address, userFlags); } throw new ArgumentException("Unknown poly type!", "type"); }
public byte[] GetBytes(ChunkType type) { List<byte> result = new List<byte>(); int ind = Indexes.Length; if (Reversed) ind = -ind; result.AddRange(ByteConverter.GetBytes((short)(ind))); for (int i = 0; i < Indexes.Length; i++) { result.AddRange(ByteConverter.GetBytes(Indexes[i])); switch (type) { case ChunkType.Strip_StripUVN: case ChunkType.Strip_StripUVNColor: case ChunkType.Strip_StripUVN2: result.AddRange(UVs[i].GetBytes(false)); break; case ChunkType.Strip_StripUVH: case ChunkType.Strip_StripUVHColor: case ChunkType.Strip_StripUVH2: result.AddRange(UVs[i].GetBytes(true)); break; } switch (type) { case ChunkType.Strip_StripColor: case ChunkType.Strip_StripUVNColor: case ChunkType.Strip_StripUVHColor: result.AddRange(VColor.GetBytes(VColors[i], ColorType.ARGB8888_16)); break; } if (i > 1) { if (UserFlags1 != null) { result.AddRange(ByteConverter.GetBytes(UserFlags1[i - 2])); if (UserFlags2 != null) { result.AddRange(ByteConverter.GetBytes(UserFlags2[i - 2])); if (UserFlags3 != null) result.AddRange(ByteConverter.GetBytes(UserFlags3[i - 2])); } } } } return result.ToArray(); }
public PolyChunkStrip(ChunkType type) { Type = type; Strips = new List<Strip>(); }
public Strip(byte[] file, int address, ChunkType type, byte userFlags) { Indexes = new ushort[Math.Abs(ByteConverter.ToInt16(file, address))]; Reversed = (ByteConverter.ToUInt16(file, address) & 0x8000) == 0x8000; address += 2; switch (type) { case ChunkType.Strip_StripUVN: case ChunkType.Strip_StripUVH: case ChunkType.Strip_StripUVN2: case ChunkType.Strip_StripUVH2: UVs = new UV[Indexes.Length]; break; case ChunkType.Strip_StripColor: VColors = new Color[Indexes.Length]; break; case ChunkType.Strip_StripUVNColor: case ChunkType.Strip_StripUVHColor: UVs = new UV[Indexes.Length]; VColors = new Color[Indexes.Length]; break; } if (userFlags > 0) UserFlags1 = new ushort[Indexes.Length - 2]; if (userFlags > 1) UserFlags2 = new ushort[Indexes.Length - 2]; if (userFlags > 2) UserFlags3 = new ushort[Indexes.Length - 2]; for (int i = 0; i < Indexes.Length; i++) { Indexes[i] = ByteConverter.ToUInt16(file, address); address += 2; switch (type) { case ChunkType.Strip_StripUVN: case ChunkType.Strip_StripUVNColor: case ChunkType.Strip_StripUVN2: UVs[i] = new UV(file, address, false); address += UV.Size; break; case ChunkType.Strip_StripUVH: case ChunkType.Strip_StripUVHColor: case ChunkType.Strip_StripUVH2: UVs[i] = new UV(file, address, true); address += UV.Size; break; } switch (type) { case ChunkType.Strip_StripColor: case ChunkType.Strip_StripUVNColor: case ChunkType.Strip_StripUVHColor: VColors[i] = VColor.FromBytes(file, address, ColorType.ARGB8888_16); address += VColor.Size(ColorType.ARGB8888_16); break; } if (i > 1) { if (userFlags > 0) { UserFlags1[i - 2] = ByteConverter.ToUInt16(file, address); address += 2; if (userFlags > 1) { UserFlags2[i - 2] = ByteConverter.ToUInt16(file, address); address += 2; if (userFlags > 2) { UserFlags3[i - 2] = ByteConverter.ToUInt16(file, address); address += 2; } } } } } }