Skip to content

Commit

Permalink
Fixed a bug that prevented pals to be added into empty inventories
Browse files Browse the repository at this point in the history
  • Loading branch information
KrisCris committed Jul 11, 2024
1 parent fd4638a commit 197420a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/palworld_pal_editor/core/container_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def __init__(self, container_obj: dict) -> None:
self._container_obj["value"]["Slots"]
)

if self.ID is None or not self._slots_data:
if self.ID is None or self._slots_data is None:
raise Exception("Invalid Container")

self.slots: list[ContainerSlot] = [
Expand Down Expand Up @@ -63,7 +63,7 @@ def add_pal(self, pal_id: UUID | str) -> int:
if self.has_pal(pal_id):
return -1

if not (slot_idx := self._new_slot()):
if (slot_idx := self._new_slot()) is None:
return -1

slot = ContainerSlot(self._slots_data[slot_idx])
Expand Down
5 changes: 3 additions & 2 deletions src/palworld_pal_editor/core/save_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ def add_pal(self, player_uid: str | UUID, pal_obj: dict = None) -> Optional[PalE

pal_container = None
for id in player_container_ids:
if container := self.container_data.get_container(id):
if (container := self.container_data.get_container(id)) is not None:
if container.get_empty_slot() != -1:
pal_container = container
break
Expand All @@ -418,7 +418,8 @@ def add_pal(self, player_uid: str | UUID, pal_obj: dict = None) -> Optional[PalE
pal_instanceId = toUUID(str(uuid.uuid4()))

try:
slot_idx = pal_container.add_pal(pal_instanceId)
if (slot_idx := pal_container.add_pal(pal_instanceId)) == -1:
return None
container_id = pal_container.ID
group.add_pal(pal_instanceId)

Expand Down

0 comments on commit 197420a

Please sign in to comment.