fix!: work with the latest fsd (#59)

While at it, rename "typeIDs" to "types" in protobuf
This commit is contained in:
Patric Stout
2024-07-04 14:39:06 +02:00
committed by GitHub
parent 3ea67e7bfd
commit 97f7f1bbbd
3 changed files with 40 additions and 40 deletions

View File

@@ -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 <path to fsd folder inside the sde>
python -m convert <path to fsd folder>
```
This will take a while to generate the protobuf files, but they will be outputed in the `dist` folder.

View File

@@ -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)

View File

@@ -21,8 +21,8 @@ message TypeDogma {
map<int32, TypeDogmaEntry> 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<int32, TypeID> entries = 1;
map<int32, Type> entries = 1;
}
message GroupIDs {
message GroupID {
message Groups {
message Group {
required string name = 1;
required int32 categoryID = 2;
required bool published = 3;
}
map<int32, GroupID> entries = 1;
map<int32, Group> entries = 1;
}
message MarketGroups {