def writeRegionToArchive(archivePath, region): file = io.BytesIO() for section in [region["countries"], region["countriesPatch"]]: file.write(struct.pack('<I', len(section))) for entry in section: file.write(struct.pack('BBBB', 0, 0, 0, entry["country"])) file.write(struct.pack('<I', entry["divisionCount"])) file.write(struct.pack('<I', 0)) writeName(file, entry["name"]) writeSort(file, entry["sort"]) file.write(b'\x00' * 0x20) for entry in region["countries"]: writeSort(file, entry["sort"]) countries = region["countries"] tailLen = len(countries) // 32 + 1 tail = [0] * tailLen for i in range(len(countries)): if countries[i]["eshopLock"]: tail[i // 32] |= 1 << (i % 32) for t in tail: file.write(struct.pack('<I', t)) with open(os.path.join(archivePath, region["region"], "country_LZ.bin"), 'wb') as realFile: compressLz(file.getvalue(), realFile)
def writeCountryToArchive(archivePath, country): file = io.BytesIO() firstSection = True for section in [country["divisions"], country["divisionsPatch"]]: entryCount = len(section) entryCountWrite = entryCount if firstSection: firstSection = False entryCountWrite -= 1 file.write(struct.pack('<I', entryCountWrite)) for entry in section: file.write(struct.pack('BBBB', 0, 0, entry["division"], country["code"])) writeName(file, entry["name"]) writeSort(file, entry["sort"]) file.write(struct.pack('<HH', entry["latitude"], entry["longitude"])) for entry in country["divisions"]: writeSort(file, entry["sortPatch"]) divisions = country["divisions"] tailLen = len(divisions) // 32 + 1 tail = [0] * tailLen for i in range(len(divisions)): if divisions[i]["eshopLock"]: tail[i // 32] |= 1 << (i % 32) for t in tail: file.write(struct.pack('<I', t)) path = os.path.join(archivePath, country["region"], "{}_LZ.bin".format(country["code"])) with open(path, 'wb') as realFile: compressLz(file.getvalue(), realFile)
def writeCountryToArchive(archivePath, country): file = io.BytesIO() firstSection = True for section in [country["divisions"], country["divisionsPatch"]]: entryCount = len(section) entryCountWrite = entryCount if firstSection: firstSection = False entryCountWrite -= 1 file.write(struct.pack('<I', entryCountWrite)) for entry in section: file.write( struct.pack('BBBB', 0, 0, entry["division"], country["code"])) writeName(file, entry["name"]) writeSort(file, entry["sort"]) file.write( struct.pack('<HH', entry["latitude"], entry["longitude"])) for entry in country["divisions"]: writeSort(file, entry["sortPatch"]) file.write(bytes.fromhex(country["tail"])) path = os.path.join(archivePath, country["region"], "{}_LZ.bin".format(country["code"])) with open(path, 'wb') as realFile: compressLz(file.getvalue(), realFile)
def writeRegionToArchive(archivePath, region): file = io.BytesIO() for section in [region["countries"], region["countriesPatch"]]: file.write(struct.pack('<I', len(section))) for entry in section: file.write(struct.pack('BBBB', 0, 0, 0, entry["country"])) file.write(struct.pack('<I', entry["divisionCount"])) file.write(struct.pack('<I', 0)) writeName(file, entry["name"]) writeSort(file, entry["sort"]) file.write(b'\x00' * 0x20) for entry in region["countries"]: writeSort(file, entry["sort"]) file.write(bytes.fromhex(region["tail"])) with open(os.path.join(archivePath, region["region"], "country_LZ.bin"), 'wb') as realFile: compressLz(file.getvalue(), realFile)