World entities are a new concept introduced with revision 222. These are a way to make sailing function,
[!NOTE]
This is all theoretical documentation as do not yet have access to see the actual implementation on OldSchools side.
Furthermore, there is a very good chance the design may change in future revisions, as the current implementation is not particularly efficient.
Concept
World entities are effectively smaller variants of the root game world, backed by the instancing system.
The server has the ability to allocate a specific piece of existing static map and place it into the root world. The intended use case here, with sailing, is to have maps which strictly only contain a boat - however many locs that may consist of. The server will then make an instance of that boat area and turn it into a world entity. The world entities contain properties such as the base coordinate where it exists, the coordinate where it currently is being rendered, and the map out of which it is made of. Furthermore, they support their own collection of players, NPCs, locs and much more. It effectively boils down into a smaller variant of the root world being rendered on the root world, or another world entity[^1].
World
By default, there will always exist at least one world, the "root" world. This is the normal static world covering the entire game map. World entities, however, will allocate their own sub-worlds with each world entity that is being created.
Properties
Worlds contain a large number of properties which allocate circa 5.2MB of memory per world allocated, assuming the world is 16x16 tiles in size, which is likely going to be the size of most world entities outside of the root.
Below is a breakdown of all the properties which the world owns:
A scene, keeping track of the mouse coordinates and the overall rendering of the entity.
A collision map of all four levels, keeping track of all the clip flags that are allocated in this world entity. Each world entity will have its own clip flags, unrelated to the root world - pathfinding on these world entities will be based on these flags of the world entity, rather than the root world.
An array of players in this world. This supports any number of players, all the way up to 2048, however it does not allow more than 2048 players on a single server, so between all the worlds, the total limit still remains 2048.
An array of NPCs in this world. As with players, this supports any number of NPCs, all the way up to 65536. Similarly to players, the indices are shared between all worlds and this does not allow more than 65536 NPCs within the server.
An array of world entities in this world, up to 2048. It is possible for a world entity to exist in the world of another world entity, however as mentioned in the concept section, it is not possible to nest it more than one. The parent must always be the root world, or another world that has the root world as parent. Nesting beyond two is not possible.
An array of ground items - same natural constraints as used to exist in older revisions.
A queue of loc changes - same natural constraints as before.
A queue of projectiles - same natural constraints as before.
A queue of spotanims - same natural constrains as before.
Properties such as the UID, dimensions and the base coordinate where the world entity exists within the instance land.
World Entity
A world entity is an enclosed world that has the ability to move around in the root world, or within the world of another world entity[^1].
Properties
World entities keep track of properties such as:
Turn speed
Turn angle
Coordinate
The angle of the world entity
The world itself
Possibilities & Limitations
[!NOTE]
Below explanation is of dynamic world entities/worlds, and not the root!
Each world is effectively an instance of the static map, being built out of N*M zones.
It is not possible to have more than the usual limit of 2047 players in a server, no matter the amount of worlds.
It is not possible to have more than the usual limit of 65535 NPCs in a server, no matter the amount of worlds.
NPCs and players can only be on the same height level as the local player - this constraint has not changed with the addition of world entities.
World entities themselves can however be on multiple levels, you just can't see the players or NPCs on them if they happen to be on a different height level.
World entities can only turn a maximum of 22.5 degrees per game cycle (600ms), which is equal to 128/2048 angle units.
A world entity can move at any speed from 0.5 to 4.0 tiles per cycle, in 0.5 tile increments.
The camera can be made to focus on a world entity, another player or a NPC as of this revision.
Below is a draft of the potential of world entities, showing how they can be nested further than the concept shown by Jagex:https://media.z-kris.com/2024/05/mspaint_lI8k0DO8sr.png
Edit: This does not work as the client does not render anything nested.
Pseudocode
Below is some pseudocode of how the server's side of things should look like with multi-world concept:
// Root world packets after setting active world to root: player info, npc info, zone updates
// Update sends WorldEntityInfo packet
player.worldEntityInfo.update()
// As world entity info only contains position info, we need to now build the actual world via instancing
for (world in player.worldEntityInfo.addedWorlds) {
player.send(RebuildWorldEntity(world))
}
// Sync the state of all these non-root worlds
for (world in player.worldEntityInfo.allWorlds) {
player.send(SetActiveWorld(world))
// player info
// npc info
// zone updates
}
[^1]: World entities can only be rendered on either the root world, or the world of another world entity. It is not possible to nest this more than one level deep.
World entities are a new concept introduced with revision 222. These are a way to make sailing function,
Concept
World entities are effectively smaller variants of the root game world, backed by the instancing system. The server has the ability to allocate a specific piece of existing static map and place it into the root world. The intended use case here, with sailing, is to have maps which strictly only contain a boat - however many locs that may consist of. The server will then make an instance of that boat area and turn it into a world entity. The world entities contain properties such as the base coordinate where it exists, the coordinate where it currently is being rendered, and the map out of which it is made of. Furthermore, they support their own collection of players, NPCs, locs and much more. It effectively boils down into a smaller variant of the root world being rendered on the root world, or another world entity[^1].
World
By default, there will always exist at least one world, the "root" world. This is the normal static world covering the entire game map. World entities, however, will allocate their own sub-worlds with each world entity that is being created.
Properties
Worlds contain a large number of properties which allocate circa 5.2MB of memory per world allocated, assuming the world is 16x16 tiles in size, which is likely going to be the size of most world entities outside of the root. Below is a breakdown of all the properties which the world owns:
It is possible for a world entity to exist in the world of another world entity, however as mentioned in the concept section, it is not possible to nest it more than one. The parent must always be the root world, or another world that has the root world as parent. Nesting beyond two is not possible.World Entity
A world entity is an enclosed world that has the ability to move around in the root world,
or within the world of another world entity[^1].Properties
World entities keep track of properties such as:
Possibilities & Limitations
Below is a draft of the potential of world entities, showing how they can be nested further than the concept shown by Jagex:https://media.z-kris.com/2024/05/mspaint_lI8k0DO8sr.pngEdit: This does not work as the client does not render anything nested.Pseudocode
Below is some pseudocode of how the server's side of things should look like with multi-world concept:
[^1]: World entities can only be rendered on either the root world,
or the world of another world entity. It is not possible to nest this more than one level deep.