Пример #1
0
def parse_dlcs(f):
    dlcs = odict()
    while f.peek_int() != 0:
        dlcs[unknown()] = f.read_bytes(16)
        dlcs[unknown()] = f.read_bytes(4)
        dlcs['dlc'] = f.read_string()
    return dlcs
Пример #2
0
def parse_version(f):
	version = odict()
	version['const_string'] = f.read_bytes(4)
	version['save'] = f.read_int()
	version['game'] = f.read_string()
	version['build'] = f.read_string()
	return version
Пример #3
0
def parse_dlcs(f):
	dlcs = odict()
	while f.peek_int() != 0:
		dlcs[unknown()] = f.read_bytes(16)
		dlcs[unknown()] = f.read_bytes(4)
		dlcs['dlc'] = f.read_string()
	return dlcs
Пример #4
0
def parse_version(f):
    version = odict()
    version['const_string'] = f.read_bytes(4)
    version['save'] = f.read_int()
    version['game'] = f.read_string()
    version['build'] = f.read_string()
    return version
Пример #5
0
def parse(filename):
	out = odict()
	with fr.FileReader(filename) as f:
		out['base'] = parse_base(f)
		out['dlc'] = parse_dlcs(f)
		out['blocks'] = parse_blocks(f)
		out['compressed'] = parse_compressed(f)
	return out
Пример #6
0
def parse(filename):
    out = odict()
    with fr.FileReader(filename) as f:
        out['base'] = parse_base(f)
        out['dlc'] = parse_dlcs(f)
        out['blocks'] = parse_blocks(f)
        out['compressed'] = parse_compressed(f)
    return out
Пример #7
0
def parse_block_27(f, start, end):
    data = odict()
    end -= 5 * 8
    data[unknown()] = f.read_bytes((end - start) // 8)
    data['VictoryFlag1'] = bytes([f.read_byte()])
    data['VictoryFlag2'] = bytes([f.read_byte()])
    data['VictoryFlag3'] = bytes([f.read_byte()])
    data['VictoryFlag4'] = bytes([f.read_byte()])
    data['VictoryFlag5'] = bytes([f.read_byte()])
    return data
Пример #8
0
def parse_block_27(f, start, end):
	data = odict()
	end-=5*8
	data[unknown()] = f.read_bytes((end-start)//8)
	data['VictoryFlag1'] = bytes([f.read_byte()])
	data['VictoryFlag2'] = bytes([f.read_byte()])
	data['VictoryFlag3'] = bytes([f.read_byte()])
	data['VictoryFlag4'] = bytes([f.read_byte()])
	data['VictoryFlag5'] = bytes([f.read_byte()])
	return data
Пример #9
0
def parse_base(f):
	out = odict()
	out['version'] = parse_version(f)
	out['game'] = parse_game(f)
	out['civilization'] = f.read_string()
	out['handicap'] = f.read_string()
	out['era'] = parse_era(f)
	out['gamespeed'] = f.read_string()
	out['worldsize'] = f.read_string()
	out['mapscript'] = f.read_string()
	out[unknown()] = f.read_bytes(4)
	return out
Пример #10
0
def parse_base(f):
    out = odict()
    out['version'] = parse_version(f)
    out['game'] = parse_game(f)
    out['civilization'] = f.read_string()
    out['handicap'] = f.read_string()
    out['era'] = parse_era(f)
    out['gamespeed'] = f.read_string()
    out['worldsize'] = f.read_string()
    out['mapscript'] = f.read_string()
    out[unknown()] = f.read_bytes(4)
    return out
Пример #11
0
def parse_blocks(f):
	last_read = f.pos
	positions = list(f.findall('0x40000000'))
	f.pos = last_read
	blocks = odict()
	if f.pos < positions[0]:
		assert((positions[0]-f.pos)%8==0)
		blocks['prefix'] = f.read_bytes((positions[0]-f.pos)//8)
	assert(f.pos == positions[0])
	for i in range(len(positions)-1):
		assert(f.pos == positions[i])
		assert((positions[i+1]-positions[i])%8==0)
		if i == 27:
			blocks[str(i)] = parse_block_27(f, positions[i], positions[i+1])
		else:
			blocks[str(i)] = f.read_bytes((positions[i+1] - positions[i])//8)
	return blocks
Пример #12
0
def parse_blocks(f):
    last_read = f.pos
    positions = list(f.findall('0x40000000'))
    f.pos = last_read
    blocks = odict()
    if f.pos < positions[0]:
        assert ((positions[0] - f.pos) % 8 == 0)
        blocks['prefix'] = f.read_bytes((positions[0] - f.pos) // 8)
    assert (f.pos == positions[0])
    for i in range(len(positions) - 1):
        assert (f.pos == positions[i])
        assert ((positions[i + 1] - positions[i]) % 8 == 0)
        if i == 27:
            blocks[str(i)] = parse_block_27(f, positions[i], positions[i + 1])
        else:
            blocks[str(i)] = f.read_bytes(
                (positions[i + 1] - positions[i]) // 8)
    return blocks
Пример #13
0
def parse_compressed(f):
	#todo - this just reads the rest at the moment
	compressed = odict()
	compressed[unknown()] = f.read_bytes((f.bits.length-f.pos)//8)
	assert(f.pos == f.bits.length)
	return compressed
Пример #14
0
def parse_game(f):
    game = odict()
    game['currentturn'] = f.read_int()
    game[unknown()] = f.read_bytes(1)
    return game
Пример #15
0
def parse_era(f):
    era = odict()
    era['starting'] = f.read_string()
    era['current'] = f.read_string()
    return era
Пример #16
0
def parse_era(f):
	era = odict()
	era['starting'] = f.read_string()
	era['current'] = f.read_string()
	return era
Пример #17
0
def parse_game(f):
	game = odict()
	game['currentturn'] = f.read_int()
	game[unknown()] = f.read_bytes(1)
	return game
Пример #18
0
def parse_compressed(f):
    #todo - this just reads the rest at the moment
    compressed = odict()
    compressed[unknown()] = f.read_bytes((f.bits.length - f.pos) // 8)
    assert (f.pos == f.bits.length)
    return compressed