This page is supposed to define the members of SerialPacketType, as of network version 20150304, last written on 11/3/2015.
There are currently 6 packet formats used by the server and client. These formats are:
- ServerPacket
- ClientPacket
- RegionPacket
- CharacterPacket
- MonsterPacket
- TextPacket
Each of these packet formats inherit from SerialPacketBase, which is detailed below. Each packet comes with a pair of functions used to serialize and deserialize that specific format from the network buffer, regardless of what is actually contained within. In certain cases, some members of the packets don't need to be filled out for the programs to execute correctly; the purpose of this document is to define what members are required by what message type.
There are also a number of internal-use only systems, such as the union MaxPacket, the FORMAT_* tags, etc. These will be referenced as needed.
SerialPacketType
This is a large enumeration of integers containing all "message types" used by Tortuga's networking systems. The purpose of the packet as a whole is defined by the element selected; all programs designed to connect to Tortuga's network must use these values for the protocols.
There are also a few internal-use only elements such as:
- NONE
- LAST
- FORMAT_*
- FORMAT_END_*
SerialPacketType::NONE
NONE has zero as a default value, and is used to signal when something has gone wrong internally. It is not currently in use, but it is always the element with the lowest bound.
SerialPacketType::LAST
LAST, as it's name implies, is designated as the last element of the enumeration's range. It's value will vary from version to version, but it's position relative to the other tags is guaranteed.
FORMAT_* and FORMAT_END_*
This is a relatively new addition, and is used to divide the tags by their intended format; each tag name ends according to said format. FORMAT_* is the lower bound, while FORMAT_END_* is the upper bound. No two format bounds overlap. These are not internal-only, but they are not currently used outside of the networking system's internals.
SerialPacketBase
This structure is the base class of all packet structures used by the programs. It has two members:
- SerialPacketType type
- IPaddress srcAddress
type is defined as the first four bytes of any message. srcAddress is set by the networking system, to signal where the message came from. All other packets have these members as standard. For general use, this structure is typedef'd as "SerialPacket".
PACKET_STRING_SIZE
For compatability, the constant integer PACKET_STRING_SIZE is defined as 100. This is used to define a buffer for all strings sent over the network.
ServerPacket
This structure is used for identifying game servers. In addition to it's inherited members, it has:
- name
- playerCount
- version
name is a string, PACKET_STRING_SIZE characters long, and is the public name of the server. playerCount is simply the number of players on said server, and version is the network version being used by that server. If the network version of a server doesn't match a client, then the two programs will refuse to connect to each other.
ClientPacket
This structure is used for identifying game clients. In addition to it's inherited members, it has:
- clientIndex
- accountIndex
- username
clientIndex and accountIndex are integers, defining the server's internal index for the player's client and account respectfully. username is a string holding the player's username. Please note that the username and character handles are two destinct things.
RegionPacket
This structure is used for asking for and sending map data. In addition to it's inherited members, it has:
- roomIndex
- x
- y
- region data
roomIndex, x and y are integers representing the location of the map data being sent. Region data varies by context, but in the network, it is the region's tile data followed by the solid (collision) data. In the programs proper, it is simply a pointer to a stored Region object; as it is simply easier to serialize these directly.
In addition to these members, some constants are defined:
- REGION_TILE_FOOTPRINT
- REGION_SOLID_FOOTPRINT
- REGION_METADATA_FOOTPRINT
The first, REGION_TILE_FOOTPRINT, defines the amount of space needed in the network buffer to send all tile data in a single region. REGION_SOLID_FOOTPRINT represents how much space is needed for conveying the collision data in that same region; it should be noted that the collision data is represented internally as a bit field, therefore is considerablly smaller than the tiles.
Finally, REGION_METADATA_FOOTPRINT simply represents how much space is needed to store the region's metadata. As RegionPacket is currently the largest format in use, PACKET_BUFFER_SIZE is defined as the sum of these three values, plus the size of SerialPacketType.
CharacterPacket
This structure is used for identifying and manipulating the player characters over the game's network. In addition to it's inherited members, it has:
- characterIndex
- handle
- avatar
- accountIndex
- roomIndex
- origin
- motion
- bounds
WIP