1
Fork 0
mirror of https://github.com/Steffo99/lihzahrd.git synced 2024-11-25 01:24:21 +00:00

Fix skipped Defeated Martian Madness flag

This commit is contained in:
Steffo 2019-08-21 13:45:52 +02:00
parent 0eec5a9fce
commit 840269088c
4 changed files with 21 additions and 13 deletions

View file

@ -76,6 +76,8 @@ class FileReader:
def read_until(self, address: int) -> bytearray: def read_until(self, address: int) -> bytearray:
data = bytearray() data = bytearray()
if self.file.tell() > address:
raise ValueError("Can't read backwards")
while self.file.tell() < address: while self.file.tell() < address:
data += self.file.read(1) data += self.file.read(1)
return data return data

View file

@ -26,6 +26,7 @@ class BossesDefeated:
ice_queen: bool, ice_queen: bool,
santa_nk1: bool, santa_nk1: bool,
everscream: bool, everscream: bool,
martian_madness: bool,
lunar_pillars: PillarsInfo, lunar_pillars: PillarsInfo,
old_ones_army: OldOnesArmyTiers): old_ones_army: OldOnesArmyTiers):
self.eye_of_cthulhu: bool = eye_of_cthulhu self.eye_of_cthulhu: bool = eye_of_cthulhu
@ -53,6 +54,7 @@ class BossesDefeated:
self.ice_queen: bool = ice_queen self.ice_queen: bool = ice_queen
self.santa_nk1: bool = santa_nk1 self.santa_nk1: bool = santa_nk1
self.everscream: bool = everscream self.everscream: bool = everscream
self.martian_madness: bool = martian_madness
self.lunar_pillars: PillarsInfo = lunar_pillars self.lunar_pillars: PillarsInfo = lunar_pillars
self.old_ones_army: OldOnesArmyTiers = old_ones_army self.old_ones_army: OldOnesArmyTiers = old_ones_army

View file

@ -13,11 +13,6 @@ class RLEEncoding(enum.IntEnum):
DOUBLE_BYTE = 2 DOUBLE_BYTE = 2
"""The read data refers to 256-4800 tiles (2 bytes).""" """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 @classmethod
def from_flags(cls, flags1): def from_flags(cls, flags1):
return cls(flags1[7] * 2 + flags1[6]) return cls(flags1[7] * 2 + flags1[6])

View file

@ -1,6 +1,7 @@
import uuid import uuid
import math import math
import typing import typing
import multiprocessing
from .fileutils import * from .fileutils import *
from .header import * from .header import *
from .tiles import * from .tiles import *
@ -263,6 +264,18 @@ class World:
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
@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 @classmethod
def create_from_file(cls, filename: str): def create_from_file(cls, filename: str):
"""Create a World object from a .wld file. """Create a World object from a .wld file.
@ -456,6 +469,7 @@ class World:
fast_forward_time=fast_forward_time) fast_forward_time=fast_forward_time)
defeated_duke_fishron = f.bool() defeated_duke_fishron = f.bool()
defeated_martian_madness = f.bool()
defeated_moon_lord = f.bool() defeated_moon_lord = f.bool()
defeated_pumpking = f.bool() defeated_pumpking = f.bool()
defeated_mourning_wood = f.bool() defeated_mourning_wood = f.bool()
@ -530,18 +544,13 @@ class World:
santa_nk1=defeated_santa_nk1, santa_nk1=defeated_santa_nk1,
everscream=defeated_everscream, everscream=defeated_everscream,
lunar_pillars=defeated_pillars, 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) unknown_world_header_data = f.read_until(pointers.world_tiles)
# Tiles # Tiles
tm = TileMatrix() tm = cls._create_tilematrix(f, world_size, tileframeimportant)
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)
unknown_world_tiles_data = f.read_until(pointers.chests) unknown_world_tiles_data = f.read_until(pointers.chests)