コード例 #1
0
def parse_plugininfo(plugininfosize: int, i: int, data: bytes) -> Tuple[int, List[str]]:
    pluginnum = uint8(data[i:i+1])
    n = i+1
    plugins = [] # type: List[str]
    for _ in range(pluginnum):
        offset, pluginname = parse_wstring(n, data)
        n += offset
        plugins.append(pluginname)
    return plugininfosize, plugins
コード例 #2
0
def parse_plugininfo(plugininfosize: int, i: int,
                     data: bytes) -> Tuple[int, List[str]]:
    pluginnum = uint8(data[i:i + 1])
    n = i + 1
    plugins = []  # type: List[str]
    for _ in range(pluginnum):
        offset, pluginname = parse_wstring(n, data)
        n += offset
        plugins.append(pluginname)
    return plugininfosize, plugins
コード例 #3
0
def parse_factions(formidarray: List[int], pluginlist: List[str], factionsize: int,
                    i: int, data: bytes) -> Tuple[int, List[Tuple[str, int, int]]]:
    factions = [] # type: List[Tuple[str, int, int]]
    factioncount = factionsize // 4
    for _ in range(factioncount):
        plugin, fid = get_formid_data(data[i:i+3], formidarray, pluginlist)
        rank = uint8(data[i+3:i+4])
        factions.append((plugin, fid, rank))
        i += 4
    return factionsize, factions
コード例 #4
0
def parse_factions(formidarray: List[int], pluginlist: List[str],
                   factionsize: int, i: int,
                   data: bytes) -> Tuple[int, List[Tuple[str, int, int]]]:
    factions = []  # type: List[Tuple[str, int, int]]
    factioncount = factionsize // 4
    for _ in range(factioncount):
        plugin, fid = get_formid_data(data[i:i + 3], formidarray, pluginlist)
        rank = uint8(data[i + 3:i + 4])
        factions.append((plugin, fid, rank))
        i += 4
    return factionsize, factions
コード例 #5
0
def find_player_changeform(cfcount: int, formidarray: List[int], i: int,
                           data: bytes) -> Tuple[int, Tuple[bytes, int, int]]:
    """
    Go through all ChangeForms until the player is found and return it.

    The format is:
    formID          RefID
    changeFlags     uint32
    type            uint8                   type of form
    version         uint8
    length1         int                     length of the data
    length2         int                     0 or length of uncompressed data
    data            uint8[length1]
    """
    for n in range(cfcount):
        refid = data[i:i + 3]
        formid = parse_refid(refid, formidarray)
        i += 3
        flags = uint32(data[i:i + 4])
        i += 4
        cftype = uint8(data[i:i + 1])
        i += 1
        # Top 2 bits are the size of data lengths (ln1 and ln2)
        lengthsize = [8, 16, 32][cftype >> 6]
        # Lower 6 bits are the type of form
        formtype = cftype & 63
        # The Skyrim version (currently unused)
        version = uint8(data[i:i + 1])
        #assert version in [57, 64, 73, 74]
        i += 1
        # The actual length
        ln1 = uint(lengthsize, data[i:i + 4])
        i += lengthsize // 8
        # Compressed length or 0 if uncompressed
        ln2 = uint(lengthsize, data[i:i + 4])
        i += lengthsize // 8 + ln1
        if formid == 7 and formtype == 9:
            return 0, (data[i - ln1:i], ln2, flags)
コード例 #6
0
def find_player_changeform(cfcount: int, formidarray: List[int],
                           i: int, data: bytes) -> Tuple[int, Tuple[bytes, int, int]]:
    """
    Go through all ChangeForms until the player is found and return it.

    The format is:
    formID          RefID
    changeFlags     uint32
    type            uint8                   type of form
    version         uint8
    length1         int                     length of the data
    length2         int                     0 or length of uncompressed data
    data            uint8[length1]
    """
    for n in range(cfcount):
        refid = data[i:i+3]
        formid = parse_refid(refid, formidarray)
        i += 3
        flags = uint32(data[i:i+4])
        i += 4
        cftype = uint8(data[i:i+1])
        i += 1
        # Top 2 bits are the size of data lengths (ln1 and ln2)
        lengthsize = [8, 16, 32][cftype >> 6]
        # Lower 6 bits are the type of form
        formtype = cftype & 63
        # The Skyrim version (currently unused)
        version = uint8(data[i:i+1])
        #assert version in [57, 64, 73, 74]
        i += 1
        # The actual length
        ln1 = uint(lengthsize, data[i:i+4])
        i += lengthsize//8
        # Compressed length or 0 if uncompressed
        ln2 = uint(lengthsize, data[i:i+4])
        i += lengthsize//8 + ln1
        if formid == 7 and formtype == 9:
            return 0, (data[i-ln1:i], ln2, flags)