<commit_before>//
//  File.swift
//  AC
//
//  Created by <NAME> on 7/20/14.
//  Copyright (c) 2014 <NAME>. All rights reserved.
//

import Lilliput

extension ByteBuffer {
    public func getTexture() -> Texture {
        let identifier = getUInt32()
        let type = getUInt32()
        let width = getIntFrom32Bits()
        let height = getIntFrom32Bits()
        
        var dataSize = 0
        
        if type == 2 || type == 1 {
            dataSize = width * height
        } else if type == 4 || type == 7 {
            dataSize = width * height * 2
        } else if type == 10 {
            dataSize = width * height * 3
        }
        
        let data = getUInt8(dataSize)
        var paletteID: UInt32 = 0
        
        if type == 2 {
            paletteID = getUInt32()
        }
        
        return Texture(
            identifier: identifier,
            type: type,
            width: width,
            height: height,
            data: data,
            paletteID: paletteID
        )
    }
}

public enum TextureType: UInt32 {
    case Palette = 2    // Doesn't matter
    case PackedARGB = 4 // GL_BGRA, GL_UNSIGNED_SHORT_4_4_4_4_REV (swapped while reading)
    case PackedRGB = 7  // GL_RGB, GL_UNSIGNED_SHORT_5_6_5        (swapped while reading)
    case Planar = 10    // GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV   (p0 = r, p1 = g, p2 = b)
    case Luminance = 11 // GL_LUMINANCE, GL_UNSIGNED_BYTE
}

public struct Texture {
    public let identifier: UInt32
    public let type: UInt32
    public let width: Int
    public let height: Int
    public let data: Array<UInt8>
    public let paletteID: UInt32
}
<commit_msg>Fix check for type 11 in Asheron Texture. Load texture palettes directly from texture when extracting textures Write out all materials and textures in 32-bit BMP format. Write out materials using materialID to prevent overlap of names.<commit_after>//
//  File.swift
//  AC
//
//  Created by <NAME> on 7/20/14.
//  Copyright (c) 2014 <NAME>. All rights reserved.
//

import Lilliput

extension ByteBuffer {
    public func getTexture() -> Texture {
        let identifier = getUInt32()
        let type = getUInt32()
        let width = getIntFrom32Bits()
        let height = getIntFrom32Bits()
        
        var dataSize = 0
        
        if type == 2 || type == 11 {
            dataSize = width * height
        } else if type == 4 || type == 7 {
            dataSize = width * height * 2
        } else if type == 10 {
            dataSize = width * height * 3
        }
        
        let data = getUInt8(dataSize)
        var paletteID: UInt32 = 0
        
        if type == 2 {
            paletteID = getUInt32()
        }
        
        return Texture(
            identifier: identifier,
            type: type,
            width: width,
            height: height,
            data: data,
            paletteID: paletteID
        )
    }
}

public enum TextureType: UInt32 {
    case Palette = 2    // Doesn't matter
    case PackedARGB = 4 // GL_BGRA, GL_UNSIGNED_SHORT_4_4_4_4_REV (swapped while reading)
    case PackedRGB = 7  // GL_RGB, GL_UNSIGNED_SHORT_5_6_5        (swapped while reading)
    case Planar = 10    // GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV   (p0 = r, p1 = g, p2 = b)
    case Luminance = 11 // GL_LUMINANCE, GL_UNSIGNED_BYTE
}

public struct Texture {
    public let identifier: UInt32
    public let type: UInt32
    public let width: Int
    public let height: Int
    public let data: Array<UInt8>
    public let paletteID: UInt32
}

{'fraction_non_alphanumeric': 0.08425219112242013, 'fraction_numerical': 0.037037037037037035, 'mean_word_length': 1.801266825019794, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2823635', 'n_tokens_mistral': 1195, 'n_tokens_neox': 1099, 'n_words': 352}