public PatchTable(byte[] lumpData) { patches = new List <string>(); for (int i = 0; i < (int)BitConverter.ToUInt32(lumpData, 0); i++) { patches.Add(WadFile.GetString(lumpData, 4 + (i * 8))); } }
// Append a texture definition from wad public void Add(byte[] lumpData, PatchTable patchTable) { uint amt = BitConverter.ToUInt32(lumpData, 0); uint[] offsets = new uint[amt]; int i; for (i = 0; i < amt; i++) { offsets[i] = BitConverter.ToUInt32(lumpData, 4 + (i * 4)); } for (i = 0; i < amt; i++) { int offset = (int)offsets[i]; uint patchCount = BitConverter.ToUInt16(lumpData, offset + 20); List <DoomPatch> patches = new List <DoomPatch>(); for (int j = offset + 22; j < (offset + 22) + (patchCount * 10); j += 10) { DoomPatch np = new DoomPatch( (int)BitConverter.ToInt16(lumpData, j), (int)BitConverter.ToInt16(lumpData, j + 2), patchTable.patches[(int)BitConverter.ToUInt16(lumpData, j + 4)] ); patches.Add(np); } DoomTexture newTex = new DoomTexture( WadFile.GetString(lumpData, offset), (int)BitConverter.ToUInt16(lumpData, offset + 12), (int)BitConverter.ToUInt16(lumpData, offset + 14), patches ); if (textures.ContainsKey(newTex.name)) { textures[newTex.name] = newTex; } else { //Debug.Log(newTex.name); textures.Add(newTex.name, newTex); } } }