public override sealed Chunk Load(int chunkid,byte[] data) { if (data == null) throw new ArgumentNullException("data"); if (data.Length != Chunk.Length) throw new ArgumentException("Data must be 65536 bytes long."); int id = BitConv.FromInt32(data,4); int entrycount = BitConv.FromInt32(data,8); int checksum = BitConv.FromInt32(data,12); int headersize = 20 + entrycount * 4; if (id != chunkid) { ErrorManager.SignalIgnorableError("EntryChunk: Chunk id is incorrect"); } if (entrycount < 0) { ErrorManager.SignalError("EntryChunk: Entry count is negative"); } if (checksum != Chunk.CalculateChecksum(data)) { ErrorManager.SignalIgnorableError("Chunk: Checksum is wrong"); } if (headersize > data.Length) { ErrorManager.SignalError("EntryChunk: Data is too short"); } Entry[] entries = new Entry [entrycount]; byte[] entrydata; for (int i = 0;i < entrycount;i++) { int entrystart = BitConv.FromInt32(data,16 + i * 4); int entryend = BitConv.FromInt32(data,20 + i * 4); if (entrystart < 0) { ErrorManager.SignalError("EntryChunk: Entry begins out of bounds"); } if (entryend < entrystart) { ErrorManager.SignalError("EntryChunk: Entry ends before it begins"); } if (entryend > data.Length) { ErrorManager.SignalError("EntryChunk: Entry ends out of bounds"); } int entrysize = entryend - entrystart; entrydata = new byte [entrysize]; Array.Copy(data,entrystart,entrydata,0,entrysize); entries[i] = Entry.Load(entrydata); } return Load(entries); }
public override Chunk Load(Entry[] entries) { if (entries == null) throw new ArgumentNullException("entries"); return new OldSoundChunk(entries); }
public abstract Chunk Load(Entry[] entries);
internal EntryController CreateEntryController(Entry entry) { if (entry is OldAnimationEntry) { return new OldAnimationEntryController(this,(OldAnimationEntry)entry); } else if (entry is T1Entry) { return new T1EntryController(this,(T1Entry)entry); } else if (entry is OldModelEntry) { return new OldModelEntryController(this,(OldModelEntry)entry); } else if (entry is ModelEntry) { return new ModelEntryController(this,(ModelEntry)entry); } else if (entry is OldSceneryEntry) { return new OldSceneryEntryController(this,(OldSceneryEntry)entry); } else if (entry is SceneryEntry) { return new SceneryEntryController(this,(SceneryEntry)entry); } else if (entry is T4Entry) { return new T4EntryController(this,(T4Entry)entry); } else if (entry is T6Entry) { return new T6EntryController(this,(T6Entry)entry); } else if (entry is OldEntityEntry) { return new OldEntityEntryController(this,(OldEntityEntry)entry); } else if (entry is EntityEntry) { return new EntityEntryController(this,(EntityEntry)entry); } else if (entry is T11Entry) { return new T11EntryController(this,(T11Entry)entry); } else if (entry is SoundEntry) { return new SoundEntryController(this,(SoundEntry)entry); } else if (entry is OldMusicEntry) { return new OldMusicEntryController(this,(OldMusicEntry)entry); } else if (entry is MusicEntry) { return new MusicEntryController(this,(MusicEntry)entry); } else if (entry is WavebankEntry) { return new WavebankEntryController(this,(WavebankEntry)entry); } else if (entry is OldT15Entry) { return new OldT15EntryController(this,(OldT15Entry)entry); } else if (entry is T15Entry) { return new T15EntryController(this,(T15Entry)entry); } else if (entry is OldT17Entry) { return new OldT17EntryController(this,(OldT17Entry)entry); } else if (entry is T17Entry) { return new T17EntryController(this,(T17Entry)entry); } else if (entry is T18Entry) { return new T18EntryController(this,(T18Entry)entry); } else if (entry is DemoEntry) { return new DemoEntryController(this,(DemoEntry)entry); } else if (entry is T20Entry) { return new T20EntryController(this,(T20Entry)entry); } else if (entry is SpeechEntry) { return new SpeechEntryController(this,(SpeechEntry)entry); } else if (entry is T21Entry) { return new T21EntryController(this,(T21Entry)entry); } else if (entry is UnprocessedEntry) { return new UnprocessedEntryController(this,(UnprocessedEntry)entry); } else { throw new NotImplementedException(); } }