From 97f7f1bbbdb45aeaa8e1fe8688f64830e11277e5 Mon Sep 17 00:00:00 2001 From: Patric Stout Date: Thu, 4 Jul 2024 14:39:06 +0200 Subject: [PATCH] fix!: work with the latest fsd (#59) While at it, rename "typeIDs" to "types" in protobuf --- README.md | 4 +-- convert/__main__.py | 64 ++++++++++++++++++++++----------------------- esf.proto | 12 ++++----- 3 files changed, 40 insertions(+), 40 deletions(-) diff --git a/README.md b/README.md index 1d1ba9b..07c6af0 100644 --- a/README.md +++ b/README.md @@ -18,12 +18,12 @@ npx pbjs -t static-module -w es6 -o esf_pb2.js esf.proto --no-create --no-encode ## Converting -Download the latest EVE SDE from [their website](https://developers.eveonline.com/resource/resources). +Download the latest EVE FSD from [their website](https://developers.eveonline.com/resource/resources). Now run the tool: ```bash -python -m convert +python -m convert ``` This will take a while to generate the protobuf files, but they will be outputed in the `dist` folder. diff --git a/convert/__main__.py b/convert/__main__.py index 89dd91f..beeb353 100644 --- a/convert/__main__.py +++ b/convert/__main__.py @@ -58,35 +58,35 @@ def convert_type_dogma(path, ships): fp.write(MessageToJson(pb2, sort_keys=True)) -def convert_type_ids(path): - print("Converting typeIDs ...") +def convert_types(path): + print("Converting types ...") try: - with open(f"{path}/groupIDs.yaml") as fp: - groupIDs = yaml.load(fp, Loader=yaml.CSafeLoader) + with open(f"{path}/groups.yaml") as fp: + groups = yaml.load(fp, Loader=yaml.CSafeLoader) except FileNotFoundError: with open(f"{path}/groups.json") as fp: - groupIDs = json.load(fp) - groupIDs = {int(k): v for k, v in groupIDs.items()} + groups = json.load(fp) + groups = {int(k): v for k, v in groups.items()} try: - with open(f"{path}/typeIDs.yaml") as fp: - typeIDs = yaml.load(fp, Loader=yaml.CSafeLoader) + with open(f"{path}/types.yaml") as fp: + types = yaml.load(fp, Loader=yaml.CSafeLoader) except FileNotFoundError: with open(f"{path}/types.json") as fp: - typeIDs = json.load(fp) - typeIDs = {int(k): v for k, v in typeIDs.items()} + types = json.load(fp) + types = {int(k): v for k, v in types.items()} - pb2 = esf_pb2.TypeIDs() + pb2 = esf_pb2.Types() ships = [] - for id, entry in typeIDs.items(): + for id, entry in types.items(): pb2.entries[id].name = entry["name"]["en"] if "name" in entry else entry["typeNameID"] pb2.entries[id].groupID = entry["groupID"] - pb2.entries[id].categoryID = groupIDs[entry["groupID"]]["categoryID"] + pb2.entries[id].categoryID = groups[entry["groupID"]]["categoryID"] pb2.entries[id].published = entry["published"] - if groupIDs[entry["groupID"]]["categoryID"] == 6: + if groups[entry["groupID"]]["categoryID"] == 6: ships.append(id) if "factionID" in entry: @@ -104,37 +104,37 @@ def convert_type_ids(path): if "volume" in entry and entry["volume"] != 0.0: pb2.entries[id].volume = entry["volume"] - with open("dist/sde/typeIDs.pb2", "wb") as fp: + with open("dist/sde/types.pb2", "wb") as fp: fp.write(pb2.SerializeToString()) - with open("dist/sde_json/typeIDs.json", "w") as fp: + with open("dist/sde_json/types.json", "w") as fp: fp.write(MessageToJson(pb2, sort_keys=True)) return ships -def convert_group_ids(path): - print("Converting groupIDs ...") +def convert_groups(path): + print("Converting groups ...") try: - with open(f"{path}/groupIDs.yaml") as fp: - groupIDs = yaml.load(fp, Loader=yaml.CSafeLoader) + with open(f"{path}/groups.yaml") as fp: + groups = yaml.load(fp, Loader=yaml.CSafeLoader) except FileNotFoundError: with open(f"{path}/groups.json") as fp: - groupIDs = json.load(fp) - groupIDs = {int(k): v for k, v in groupIDs.items()} + groups = json.load(fp) + groups = {int(k): v for k, v in groups.items()} - pb2 = esf_pb2.GroupIDs() + pb2 = esf_pb2.Groups() - for id, entry in groupIDs.items(): + for id, entry in groups.items(): pb2.entries[id].name = entry["name"]["en"] if "name" in entry else entry["groupNameID"] pb2.entries[id].categoryID = entry["categoryID"] pb2.entries[id].published = entry["published"] - with open("dist/sde/groupIDs.pb2", "wb") as fp: + with open("dist/sde/groups.pb2", "wb") as fp: fp.write(pb2.SerializeToString()) - with open("dist/sde_json/groupIDs.json", "w") as fp: + with open("dist/sde_json/groups.json", "w") as fp: fp.write(MessageToJson(pb2, sort_keys=True)) @@ -143,15 +143,15 @@ def convert_market_groups(path): try: with open(f"{path}/marketGroups.yaml") as fp: - marketGroupIDs = yaml.load(fp, Loader=yaml.CSafeLoader) + marketGroups = yaml.load(fp, Loader=yaml.CSafeLoader) except FileNotFoundError: with open(f"{path}/marketgroups.json") as fp: - marketGroupIDs = json.load(fp) - marketGroupIDs = {int(k): v for k, v in marketGroupIDs.items()} + marketGroups = json.load(fp) + marketGroups = {int(k): v for k, v in marketGroups.items()} pb2 = esf_pb2.MarketGroups() - for id, entry in marketGroupIDs.items(): + for id, entry in marketGroups.items(): pb2.entries[id].name = entry["nameID"] if isinstance(entry["nameID"], str) else entry["nameID"]["en"] if "parentGroupID" in entry: @@ -439,9 +439,9 @@ def convert_dogma_effects(path): fp.write(MessageToJson(pb2, sort_keys=True)) -convert_group_ids(path) +convert_groups(path) convert_market_groups(path) -ships = convert_type_ids(path) +ships = convert_types(path) convert_type_dogma(path, ships) convert_dogma_attributes(path) convert_dogma_effects(path) diff --git a/esf.proto b/esf.proto index dafc536..45c9f65 100644 --- a/esf.proto +++ b/esf.proto @@ -21,8 +21,8 @@ message TypeDogma { map entries = 1; } -message TypeIDs { - message TypeID { +message Types { + message Type { required string name = 1; required int32 groupID = 2; required int32 categoryID = 3; @@ -37,17 +37,17 @@ message TypeIDs { optional float volume = 11; } - map entries = 1; + map entries = 1; } -message GroupIDs { - message GroupID { +message Groups { + message Group { required string name = 1; required int32 categoryID = 2; required bool published = 3; } - map entries = 1; + map entries = 1; } message MarketGroups {