Skip to content

Port creature parsing for map packets to Python#1

Draft
hjubi wants to merge 7 commits intomasterfrom
codex/convert-fullmap-and-related-classes-to-python3
Draft

Port creature parsing for map packets to Python#1
hjubi wants to merge 7 commits intomasterfrom
codex/convert-fullmap-and-related-classes-to-python3

Conversation

@hjubi
Copy link
Owner

@hjubi hjubi commented Feb 14, 2026

Motivation

  • Restore the C# creature-parsing path in the Python map packet parser so creature details (name, hp, vocation, etc.) are preserved instead of being reduced to plain object IDs.
  • Provide storage and domain objects to hold parsed creature data so map packets can reference creatures by id and tests can inspect full creature state.

Description

  • Added python/tibia_api/creatures.py implementing Creature and CreatureStorage and exported them from tibia_api via __init__.py.
  • Extended Client (python/tibia_api/client.py) with creature_storage and player to support creature lifecycle operations.
  • Expanded NetworkMessage (python/tibia_api/network_message.py) with primitive readers (read_uint32, read_bool, read_string), appearance helpers (read_creature_outfit, read_mount_outfit), a full read_creature_instance implementation, and integrated creature handling into read_field so 0x61/0x62/0x63 markers produce Creature entries and map object references use data=creature.id.
  • Implemented map packet scaffolding and utilities: packets/ (base.py, map_updates.py), world_map.py, position.py, and constants.py to support parsing and map state updates.
  • Added unit test test_read_field_parses_creature_payload to python/tests/test_map_updates.py that exercises parsing of an UnknownCreature map field and asserts parsed creature fields and storage insertion.

Testing

  • Ran unit test suite PYTHONPATH=python python3 -m unittest discover -s python/tests -v and all tests succeeded (including the new test_read_field_parses_creature_payload).
  • Performed an ad-hoc end-to-end parse of a FullMap packet containing an embedded creature and verified the NetworkMessage.parsed_creatures contained the expected creature id and name.

Codex Task

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant