mirror of
https://github.com/Steffo99/lihzahrd.git
synced 2024-11-21 23:54:23 +00:00
Fix skipped Defeated Martian Madness flag
This commit is contained in:
parent
0eec5a9fce
commit
840269088c
4 changed files with 21 additions and 13 deletions
|
@ -76,6 +76,8 @@ class FileReader:
|
|||
|
||||
def read_until(self, address: int) -> bytearray:
|
||||
data = bytearray()
|
||||
if self.file.tell() > address:
|
||||
raise ValueError("Can't read backwards")
|
||||
while self.file.tell() < address:
|
||||
data += self.file.read(1)
|
||||
return data
|
||||
|
|
|
@ -26,6 +26,7 @@ class BossesDefeated:
|
|||
ice_queen: bool,
|
||||
santa_nk1: bool,
|
||||
everscream: bool,
|
||||
martian_madness: bool,
|
||||
lunar_pillars: PillarsInfo,
|
||||
old_ones_army: OldOnesArmyTiers):
|
||||
self.eye_of_cthulhu: bool = eye_of_cthulhu
|
||||
|
@ -53,6 +54,7 @@ class BossesDefeated:
|
|||
self.ice_queen: bool = ice_queen
|
||||
self.santa_nk1: bool = santa_nk1
|
||||
self.everscream: bool = everscream
|
||||
self.martian_madness: bool = martian_madness
|
||||
self.lunar_pillars: PillarsInfo = lunar_pillars
|
||||
self.old_ones_army: OldOnesArmyTiers = old_ones_army
|
||||
|
||||
|
|
|
@ -13,11 +13,6 @@ class RLEEncoding(enum.IntEnum):
|
|||
DOUBLE_BYTE = 2
|
||||
"""The read data refers to 256-4800 tiles (2 bytes)."""
|
||||
|
||||
UNKNOWN_3 = 3
|
||||
"""The read data refers to unknown tiles, assuming 256-4800 (2 bytes).
|
||||
|
||||
Found in certain tModLoader worlds."""
|
||||
|
||||
@classmethod
|
||||
def from_flags(cls, flags1):
|
||||
return cls(flags1[7] * 2 + flags1[6])
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import uuid
|
||||
import math
|
||||
import typing
|
||||
import multiprocessing
|
||||
from .fileutils import *
|
||||
from .header import *
|
||||
from .tiles import *
|
||||
|
@ -263,6 +264,18 @@ class World:
|
|||
tile = Tile(block=block, wall=wall, liquid=liquid, wiring=wiring)
|
||||
return [tile] * multiply_by
|
||||
|
||||
@classmethod
|
||||
def _create_tilematrix(cls, f, world_size: Coordinates, tileframeimportant: typing.List[bool]):
|
||||
"""Create a TileMatrix object from a file."""
|
||||
tm = TileMatrix()
|
||||
while tm.size.x < world_size.x:
|
||||
column = []
|
||||
while len(column) < world_size.y:
|
||||
readtiles = cls._read_tile_block(f, tileframeimportant)
|
||||
column = [*column, *readtiles]
|
||||
tm.add_column(column)
|
||||
return tm
|
||||
|
||||
@classmethod
|
||||
def create_from_file(cls, filename: str):
|
||||
"""Create a World object from a .wld file.
|
||||
|
@ -456,6 +469,7 @@ class World:
|
|||
fast_forward_time=fast_forward_time)
|
||||
|
||||
defeated_duke_fishron = f.bool()
|
||||
defeated_martian_madness = f.bool()
|
||||
defeated_moon_lord = f.bool()
|
||||
defeated_pumpking = f.bool()
|
||||
defeated_mourning_wood = f.bool()
|
||||
|
@ -530,18 +544,13 @@ class World:
|
|||
santa_nk1=defeated_santa_nk1,
|
||||
everscream=defeated_everscream,
|
||||
lunar_pillars=defeated_pillars,
|
||||
old_ones_army=old_ones_army)
|
||||
old_ones_army=old_ones_army,
|
||||
martian_madness=defeated_martian_madness)
|
||||
|
||||
unknown_world_header_data = f.read_until(pointers.world_tiles)
|
||||
|
||||
# Tiles
|
||||
tm = TileMatrix()
|
||||
while tm.size.x < world_size.x:
|
||||
column = []
|
||||
while len(column) < world_size.y:
|
||||
readtiles = cls._read_tile_block(f, tileframeimportant)
|
||||
column = [*column, *readtiles]
|
||||
tm.add_column(column)
|
||||
tm = cls._create_tilematrix(f, world_size, tileframeimportant)
|
||||
|
||||
unknown_world_tiles_data = f.read_until(pointers.chests)
|
||||
|
||||
|
|
Loading…
Reference in a new issue