1
Fork 0
mirror of https://github.com/Steffo99/lihzahrd.git synced 2024-11-24 09:04:22 +00:00

Fix extended_wall_id problem

This commit is contained in:
Steffo 2020-06-01 02:11:19 +02:00
parent cff5490a61
commit bd07344ce4
Signed by: steffo
GPG key ID: 896A80F55F7C97F0

View file

@ -243,7 +243,7 @@ class World:
liquid_type = LiquidType.from_flags(flags1) liquid_type = LiquidType.from_flags(flags1)
has_extended_block_id = flags1[5] has_extended_block_id = flags1[5]
rle_compression = RLEEncoding.from_flags(flags1) rle_compression = RLEEncoding.from_flags(flags1)
wall_id_extra = False # Parse flags
if flags1[0]: if flags1[0]:
flags2 = fr.bits() flags2 = fr.bits()
block_shape = Shape.from_flags(flags2) block_shape = Shape.from_flags(flags2)
@ -253,19 +253,21 @@ class World:
wiring = Wiring.from_flags(flags2, flags3) wiring = Wiring.from_flags(flags2, flags3)
is_block_painted = flags3[3] is_block_painted = flags3[3]
is_wall_painted = flags3[4] is_wall_painted = flags3[4]
if flags3[5]: has_extended_wall_id = flags3[6]
wall_id_extra = fr.int1()
else: else:
is_block_active = True is_block_active = True
wiring = Wiring.from_flags(flags2) wiring = Wiring.from_flags(flags2)
is_block_painted = False is_block_painted = False
is_wall_painted = False is_wall_painted = False
has_extended_wall_id = False
else: else:
block_shape = Shape.NORMAL block_shape = Shape.NORMAL
is_block_active = True is_block_active = True
wiring = None wiring = None
is_block_painted = False is_block_painted = False
is_wall_painted = False is_wall_painted = False
has_extended_wall_id = False
# Parse block
if has_block: if has_block:
if has_extended_block_id: if has_extended_block_id:
block_type = BlockType(fr.uint2()) block_type = BlockType(fr.uint2())
@ -286,29 +288,32 @@ class World:
shape=block_shape) shape=block_shape)
else: else:
block = None block = None
# Parse wall
if has_wall: if has_wall:
temp_wall_id = fr.uint1() if has_extended_wall_id:
wall_id = WallType(x1) wall_type = WallType(fr.uint2())
if wall_id_extra: else:
new_id = (wall_id_extra << 8) | temp_wall_id wall_type = WallType(fr.uint1())
wall_id = WallType(new_id)
if is_wall_painted: if is_wall_painted:
wall_paint = fr.uint1() wall_paint = fr.uint1()
else: else:
wall_paint = None wall_paint = None
wall = Wall(type_=wall_id, paint=wall_paint) wall = Wall(type_=wall_type, paint=wall_paint)
else: else:
wall = None wall = None
# Parse liquid
if liquid_type != LiquidType.NO_LIQUID: if liquid_type != LiquidType.NO_LIQUID:
liquid = Liquid(type_=liquid_type, volume=fr.uint1()) liquid = Liquid(type_=liquid_type, volume=fr.uint1())
else: else:
liquid = None liquid = None
# Find RLE Compression multiplier
if rle_compression == RLEEncoding.DOUBLE_BYTE: if rle_compression == RLEEncoding.DOUBLE_BYTE:
multiply_by = fr.uint2() + 1 multiply_by = fr.uint2() + 1
elif rle_compression == RLEEncoding.SINGLE_BYTE: elif rle_compression == RLEEncoding.SINGLE_BYTE:
multiply_by = fr.uint1() + 1 multiply_by = fr.uint1() + 1
else: else:
multiply_by = 1 multiply_by = 1
# Create tile
tile = Tile(block=block, wall=wall, liquid=liquid, wiring=wiring) tile = Tile(block=block, wall=wall, liquid=liquid, wiring=wiring)
return [tile] * multiply_by return [tile] * multiply_by