summary refs log tree commit diff stats
path: root/apworld/static_logic.py
diff options
context:
space:
mode:
authorStar Rauchenberger <fefferburbia@gmail.com>2025-08-12 16:55:17 -0400
committerStar Rauchenberger <fefferburbia@gmail.com>2025-08-12 16:55:17 -0400
commit4c8a38dfc0121343396d2a0d734cf1445d05b60c (patch)
treeccaf6dd1dc6fee60ced5ae19c5d0bb5db1217fcb /apworld/static_logic.py
parent447a222b57e498f7904033c59e68d21d6a246abd (diff)
downloadlingo2-archipelago-4c8a38dfc0121343396d2a0d734cf1445d05b60c.tar.gz
lingo2-archipelago-4c8a38dfc0121343396d2a0d734cf1445d05b60c.tar.bz2
lingo2-archipelago-4c8a38dfc0121343396d2a0d734cf1445d05b60c.zip
Converted to proto2
This will let us use an older version of protobuf in Python, and allows
us to use the Godot protobuf implementation at all. Scalar fields with
custom defaults in data.proto were changed to not have a default,
because Godot doesn't handle it properly. The equivalent fields in
human.proto still have the defaults, and datapacker copies the default
value in if necessary. The Panel message in data.proto was also renamed
to PanelData because otherwise it conflicts with the native Godot class
named Panel. The double field in Letter was renamed to level2, because
Godot couldn't handle it well. Finally, common.proto was removed and
its contents were moved into data.proto, which allows us to generate
code for Python without needing to edit it.

NOTE: I had to slightly modify the Godot protobuf code generator. I'll
need to upload that somewhere.
Diffstat (limited to 'apworld/static_logic.py')
-rw-r--r--apworld/static_logic.py9
1 files changed, 4 insertions, 5 deletions
diff --git a/apworld/static_logic.py b/apworld/static_logic.py index ff58e96..6a05f3d 100644 --- a/apworld/static_logic.py +++ b/apworld/static_logic.py
@@ -1,4 +1,3 @@
1from .generated import common_pb2 as common_pb2
2from .generated import data_pb2 as data_pb2 1from .generated import data_pb2 as data_pb2
3import pkgutil 2import pkgutil
4 3
@@ -18,20 +17,20 @@ class Lingo2StaticLogic:
18 self.objects.ParseFromString(bytearray(file)) 17 self.objects.ParseFromString(bytearray(file))
19 18
20 for door in self.objects.doors: 19 for door in self.objects.doors:
21 if door.type in [common_pb2.DoorType.STANDARD, common_pb2.DoorType.LOCATION_ONLY]: 20 if door.type in [data_pb2.DoorType.STANDARD, data_pb2.DoorType.LOCATION_ONLY]:
22 location_name = f"{self.objects.maps[door.map_id].name} - {door.name}" 21 location_name = f"{self.objects.maps[door.map_id].name} - {door.name}"
23 self.location_id_to_name[door.ap_id] = location_name 22 self.location_id_to_name[door.ap_id] = location_name
24 23
25 if door.type not in [common_pb2.DoorType.EVENT, common_pb2.DoorType.LOCATION_ONLY]: 24 if door.type not in [data_pb2.DoorType.EVENT, data_pb2.DoorType.LOCATION_ONLY]:
26 item_name = self.get_door_item_name(door.id) 25 item_name = self.get_door_item_name(door.id)
27 self.item_id_to_name[door.ap_id] = item_name 26 self.item_id_to_name[door.ap_id] = item_name
28 27
29 for letter in self.objects.letters: 28 for letter in self.objects.letters:
30 letter_name = f"{letter.key.upper()}{'' if letter.double else '2'}" 29 letter_name = f"{letter.key.upper()}{'' if letter.level2 else '2'}"
31 location_name = f"{self.objects.maps[self.objects.rooms[letter.room_id].map_id].name} - {letter_name}" 30 location_name = f"{self.objects.maps[self.objects.rooms[letter.room_id].map_id].name} - {letter_name}"
32 self.location_id_to_name[letter.ap_id] = location_name 31 self.location_id_to_name[letter.ap_id] = location_name
33 32
34 if not letter.double: 33 if not letter.level2:
35 self.item_id_to_name[letter.ap_id] = letter_name 34 self.item_id_to_name[letter.ap_id] = letter_name
36 35
37 for mastery in self.objects.masteries: 36 for mastery in self.objects.masteries: