Document id range for items and locations

This commit is contained in:
black-sliver 2022-02-10 01:24:38 +01:00 committed by Fabian Dill
parent b93e61b758
commit a4eea3325f
3 changed files with 6 additions and 5 deletions

View File

@ -82,6 +82,7 @@ Each location has a `name` and an `id` (a.k.a. "code" or "address"), is placed
in a Region and has access rules.
The name needs to be unique in each game, the ID needs to be unique across all
games and is best in the same range as the item IDs.
World-specific IDs are 1 to 2<sup>53</sup>-1, IDs ≤ 0 are global and reserved.
Special locations with ID `None` can hold events.

View File

@ -117,7 +117,7 @@ Sent to clients when the connection handshake is successfully completed.
| slot | int | Your slot number on your team. See [NetworkPlayer](#NetworkPlayer) for more info on the slot number. |
| players | list\[[NetworkPlayer](#NetworkPlayer)\] | List denoting other players in the multiworld, whether connected or not. |
| missing_locations | list\[int\] | Contains ids of remaining locations that need to be checked. Useful for trackers, among other things. |
| checked_locations | list\[int\] | Contains ids of all locations that have been checked. Useful for trackers, among other things. |
| checked_locations | list\[int\] | Contains ids of all locations that have been checked. Useful for trackers, among other things. Location ids are in the range of ± 2<sup>53</sup>-1. |
| slot_data | dict | Contains a json object for slot related data, differs per game. Empty if not required. |
### ReceivedItems
@ -354,9 +354,9 @@ In JSON this may look like:
{"item": 3, "location": 3, "player": 3, "flags": 0}
]
```
`item` is the item id of the item
`item` is the item id of the item. Item ids are in the range of ± 2<sup>53</sup>-1.
`location` is the location id of the item inside the world
`location` is the location id of the item inside the world. Location ids are in the range of ± 2<sup>53</sup>-1.
`player` is the player slot of the world the item is located in, except when inside an [LocationInfo](#LocationInfo) Packet then it will be the slot of the player to receive the item

View File

@ -18,14 +18,14 @@ class TestIDs(unittest.TestCase):
self.assertEqual(len(known_location_ids) - len(world_type.location_id_to_name), current)
def testRangeItems(self):
"""There are Javascript clients, which are limited to 2**53 integer size."""
"""There are Javascript clients, which are limited to Number.MAX_SAFE_INTEGER due to 64bit float precision."""
for gamename, world_type in AutoWorldRegister.world_types.items():
with self.subTest(game=gamename):
for item_id in world_type.item_id_to_name:
self.assertLess(item_id, 2**53)
def testRangeLocations(self):
"""There are Javascript clients, which are limited to 2**53 integer size."""
"""There are Javascript clients, which are limited to Number.MAX_SAFE_INTEGER due to 64bit float precision."""
for gamename, world_type in AutoWorldRegister.world_types.items():
with self.subTest(game=gamename):
for location_id in world_type.location_id_to_name: