Browse Source

a bit less chaos

master
Luis Visintini 5 years ago
parent
commit
20c969ce2f
  1. 2
      requirements.txt
  2. 57
      src/swr_ed/base.py

2
requirements.txt

@ -1,3 +1,3 @@ @@ -1,3 +1,3 @@
pytest==5.4.3
pywin32==228
pywin32==228; platform_system == 'Windows'
snapshottest==0.5.1

57
src/swr_ed/base.py

@ -82,7 +82,7 @@ class SWRDataManager: @@ -82,7 +82,7 @@ class SWRDataManager:
raise SWRebellionEditorDataFileHeaderMismatchError(
f'Expected header {self.expected_header} for data file , but got {header} instead.'
)
import ipdb;ipdb.set_trace()
self.data_dicts = []
for data_tuple in self.data_struct.iter_unpack(self.data_stream.read()):
data = OrderedDict(zip(self.data_fields_structure.keys(), data_tuple))
@ -414,7 +414,7 @@ class MinorCharacterDataManager(CharacterBaseDataManager): @@ -414,7 +414,7 @@ class MinorCharacterDataManager(CharacterBaseDataManager):
expected_header = (1, 54, 56, 60)
class SWRTableDataManager(SWRDataManager):
class SystemFacilityTableDataManager(SWRDataManager):
header_fields_structure = OrderedDict([
("number", FieldDef('I', FieldType.READ_ONLY)),
("count", FieldDef('I', FieldType.DENORMALIZED)),
@ -432,18 +432,67 @@ class SWRTableDataManager(SWRDataManager): @@ -432,18 +432,67 @@ class SWRTableDataManager(SWRDataManager):
])
class SystemFacilityCoreTableDataManager(SWRTableDataManager):
class SystemFacilityCoreTableDataManager(SystemFacilityTableDataManager):
filename = "SYFCCRTB.DAT"
expected_header = (1, 8, 14, b'SeedTableEntry')
class SystemFacilityRimTableDataManager(SWRTableDataManager):
class SystemFacilityRimTableDataManager(SystemFacilityTableDataManager):
filename = "SYFCRMTB.DAT"
expected_header = (1, 7, 14, b'SeedTableEntry')
class AllianceFleetHomeTableDataManager(SystemFacilityTableDataManager):
#filename = "CMUNAFTB.DAT"
filename = "CMUNEFTB.DAT"
header_fields_structure = OrderedDict([
("number", FieldDef('I', FieldType.READ_ONLY)),
("count", FieldDef('I', FieldType.DENORMALIZED)),
("header_3", FieldDef('I', FieldType.DENORMALIZED)),
("header_name", FieldDef('20s', FieldType.DENORMALIZED)),
])
#expected_header = (1, 2, 20, b'SeedFamilyTableEntry')
expected_header = (1, 1, 20, b'SeedFamilyTableEntry')
#self.data_stream.seek(0)
#for x in list(struct.Struct('<'+'IIHBB').iter_unpack(self.data_stream.read())): print(x)
data_fields_structure = OrderedDict([
("number", FieldDef('I', FieldType.READ_ONLY)),
("number2", FieldDef('I', FieldType.READ_ONLY)), # always 1
("percent", FieldDef('I', FieldType.READ_ONLY)),
("level", FieldDef('H', FieldType.READ_ONLY)),
("unknown", FieldDef('B', FieldType.READ_ONLY)), # always 0
("family_id", FieldDef('B', FieldType.READ_ONLY)),
])
# (1, 1, 1, 0, 0)
# (1, 1, 10, 0, 0)
# (1, 0, 133, 0, 20)
# (1, 0, 5, 0, 28)
# (1, 0, 5, 0, 28)
# (1, 0, 5, 0, 28)
# (1, 0, 5, 0, 28)
# (1, 0, 5, 0, 28)
# (1, 0, 5, 0, 28)
# (1, 0, 6, 0, 16)
# (1, 0, 6, 0, 16)
# (1, 0, 6, 0, 16)
# (1, 1, 1, 0, 0)
# (1, 1, 1, 0, 0)
# (1, 0, 69, 0, 20)
# (2, 1, 2, 0, 0)
# (1, 1, 3, 0, 0)
# (1, 0, 70, 0, 20)
# (1, 0, 1, 0, 16)
# (1, 0, 1, 0, 16)
ALL_MANAGERS = [
SectorsDataManager,
SystemsDataManager,

Loading…
Cancel
Save