diff --git a/bsp_tool/branches/respawn/apex_legends.py b/bsp_tool/branches/respawn/apex_legends.py index 0531b495..51f1405b 100644 --- a/bsp_tool/branches/respawn/apex_legends.py +++ b/bsp_tool/branches/respawn/apex_legends.py @@ -568,7 +568,7 @@ class VertexUnlitTS(base.Struct): # LUMP 74 (004A) # SPECIAL_LUMP_CLASSES.pop("PHYSICS_COLLIDE") # currently disabled in titanfall.py SPECIAL_LUMP_CLASSES.pop("TEXTURE_DATA_STRING_DATA") SPECIAL_LUMP_CLASSES.update({"LEVEL_INFO": {0: LevelInfo}, - "SURFACE_NAMES": {0: shared.TextureDataStringData}}) + "SURFACE_NAMES": {0: source.TextureDataStringData}}) GAME_LUMP_HEADER = source.GameLumpHeader diff --git a/bsp_tool/branches/respawn/titanfall.py b/bsp_tool/branches/respawn/titanfall.py index 4e62e1a4..397b7d08 100644 --- a/bsp_tool/branches/respawn/titanfall.py +++ b/bsp_tool/branches/respawn/titanfall.py @@ -1070,7 +1070,7 @@ def as_bytes(self) -> bytes: "LEVEL_INFO": {0: LevelInfo}, "PAKFILE": {0: source.PakFile}, # "PHYSICS_COLLIDE": {0: physics.CollideLump}, # BROKEN .as_bytes() - "TEXTURE_DATA_STRING_DATA": {0: shared.TextureDataStringData}} + "TEXTURE_DATA_STRING_DATA": {0: source.TextureDataStringData}} # TODO: LightProbeParentInfos/BspNodes/RefIds & StaticPropLightProbeIndices may all be Special GAME_LUMP_HEADER = source.GameLumpHeader diff --git a/bsp_tool/branches/respawn/titanfall_x360.py b/bsp_tool/branches/respawn/titanfall_x360.py index 7540f1a2..6fe82282 100644 --- a/bsp_tool/branches/respawn/titanfall_x360.py +++ b/bsp_tool/branches/respawn/titanfall_x360.py @@ -2,6 +2,7 @@ from .. import shared from .. import x360 +from ..valve import source from . import titanfall @@ -56,8 +57,9 @@ class GameLump_SPRPv12_x360(titanfall.GameLump_SPRPv12): # sprp GameLump (LUMP "ENTITY_PARTITIONS": {0: titanfall.EntityPartitions}, "CM_GRID": {0: Grid_x360}, "LEVEL_INFO": {0: LevelInfo_x360}, - "TEXTURE_DATA_STRING_DATA": {0: shared.TextureDataStringData}} -# TODO: big-endian versions of PakFile & PhysicsCollide + "TEXTURE_DATA_STRING_DATA": {0: source.TextureDataStringData}} +# TODO: orange_box_x360.PakFile_x360 +# TODO: orange_box_x360.PhysicsCollide_x360 GAME_LUMP_HEADER = x360.make_big_endian(titanfall.GAME_LUMP_HEADER) diff --git a/bsp_tool/branches/shared.py b/bsp_tool/branches/shared.py index 5881087f..79eed847 100644 --- a/bsp_tool/branches/shared.py +++ b/bsp_tool/branches/shared.py @@ -113,23 +113,6 @@ def from_bytes(cls, raw_lump: bytes): return cls(entities) -class TextureDataStringData(list): - def __init__(self, iterable: List[str] = tuple()): - super().__init__(iterable) - - # TODO: use regex to search - # def find(self, pattern: str) -> List[str]: - # pattern = pattern.lower() - # return fnmatch.filter(map(str.lower, self), f"*{pattern}*") - - def as_bytes(self) -> bytes: - return b"\0".join([t.encode("ascii") for t in self]) + b"\0" - - @classmethod - def from_bytes(cls, raw_lump: bytes): - return cls([t.decode("ascii", errors="ignore") for t in raw_lump[:-1].split(b"\0")]) - - # methods def worldspawn_volume(bsp): """allows for sorting maps by size""" diff --git a/bsp_tool/branches/valve/orange_box_x360.py b/bsp_tool/branches/valve/orange_box_x360.py index 594889aa..88869ca1 100644 --- a/bsp_tool/branches/valve/orange_box_x360.py +++ b/bsp_tool/branches/valve/orange_box_x360.py @@ -137,7 +137,7 @@ class GameLump_SPRPv10_x360(orange_box.GameLump_SPRPv10): # sprp GAME LUMP (LUM del LumpClass_name, LumpClass SPECIAL_LUMP_CLASSES = {"ENTITIES": {0: shared.Entities}, - "TEXTURE_DATA_STRING_DATA": {0: shared.TextureDataStringData}} + "TEXTURE_DATA_STRING_DATA": {0: source.TextureDataStringData}} GAME_LUMP_HEADER = x360.make_big_endian(orange_box.GAME_LUMP_HEADER) diff --git a/bsp_tool/branches/valve/source.py b/bsp_tool/branches/valve/source.py index 35d51227..db3f6235 100644 --- a/bsp_tool/branches/valve/source.py +++ b/bsp_tool/branches/valve/source.py @@ -955,6 +955,18 @@ def from_bytes(cls, raw_lump: bytes): return cls(io.BytesIO(raw_lump)) +class TextureDataStringData(list): # LUMP 43 + def __init__(self, iterable: List[str] = tuple()): + super().__init__(iterable) + + def as_bytes(self) -> bytes: + return b"\0".join([t.encode("ascii") for t in self]) + b"\0" + + @classmethod + def from_bytes(cls, raw_lump: bytes): + return cls([t.decode("ascii", errors="ignore") for t in raw_lump[:-1].split(b"\0")]) + + # {"LUMP_NAME": {version: LumpClass}} BASIC_LUMP_CLASSES = {"DISPLACEMENT_TRIANGLES": {0: DisplacementTriangle}, "FACE_IDS": {0: shared.UnsignedShorts}, @@ -984,25 +996,25 @@ def from_bytes(cls, raw_lump: bytes): "LEAF_WATER_DATA": {0: LeafWaterData}, "MODELS": {0: Model}, "NODES": {0: Node}, + "ORIGINAL_FACES": {0: Face}, "OVERLAY": {0: Overlay}, "OVERLAY_FADES": {0: OverlayFade}, - "ORIGINAL_FACES": {0: Face}, "PLANES": {0: quake.Plane}, "PRIMITIVES": {0: Primitive}, "PRIMITIVE_VERTICES": {0: quake.Vertex}, "TEXTURE_DATA": {0: TextureData}, "TEXTURE_INFO": {0: TextureInfo}, - "VERTICES": {0: quake.Vertex}, "VERTEX_NORMALS": {0: quake.Vertex}, + "VERTICES": {0: quake.Vertex}, "WATER_OVERLAYS": {0: WaterOverlay}, "WORLD_LIGHTS": {0: WorldLight}, "WORLD_LIGHTS_HDR": {0: WorldLight}} SPECIAL_LUMP_CLASSES = {"ENTITIES": {0: shared.Entities}, - "TEXTURE_DATA_STRING_DATA": {0: shared.TextureDataStringData}, "PAKFILE": {0: PakFile}, # "PHYSICS_COLLIDE": {0: physics.CollideLump}, # BROKEN .as_bytes() "PHYSICS_DISPLACEMENT": {0: physics.Displacement}, + "TEXTURE_DATA_STRING_DATA": {0: TextureDataStringData}, "VISIBILITY": {0: quake2.Visibility}}