Skip to content

Commit

Permalink
moving shared.TextureDataStringData to valve.source
Browse files Browse the repository at this point in the history
  • Loading branch information
snake-biscuits committed Jul 19, 2023
1 parent 0c161d9 commit a3202c7
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 25 deletions.
2 changes: 1 addition & 1 deletion bsp_tool/branches/respawn/apex_legends.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion bsp_tool/branches/respawn/titanfall.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 4 additions & 2 deletions bsp_tool/branches/respawn/titanfall_x360.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

from .. import shared
from .. import x360
from ..valve import source
from . import titanfall


Expand Down Expand Up @@ -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)

Expand Down
17 changes: 0 additions & 17 deletions bsp_tool/branches/shared.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"""
Expand Down
2 changes: 1 addition & 1 deletion bsp_tool/branches/valve/orange_box_x360.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
18 changes: 15 additions & 3 deletions bsp_tool/branches/valve/source.py
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down Expand Up @@ -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}}


Expand Down

0 comments on commit a3202c7

Please sign in to comment.