|
WarWorld - In-Game Protocol as of 10/01/2000 NOTE: The '<','>' characters below are not parts of the message structure! NOTE: All messages end with '\0' for easy processing via strcmp() etc. NOTE: All numeric values are integers (preferably 16-bit).
Server-2-Client Messages
INIT * Starts a new frame. Resets the clients for refresh. NXT * Indicates that the following data belongs to the NeXT player. See "IMPORTANT NOTES.." below. AIM * A player's mouse cursor location. All selected units 'aim' at this location. NOTE: The server probably wont need this information. This information is needed in order to animate firing units. (sensitive to NXT)
SEL * Determines the units that are currently selected by a player. (sensitive to NXT) SHT * A shot. Informs the client that all the selected units shoot at the point defined by AIM. Additionally, defines the remaining energy value for the target. (sensitive to NXT)
NEW * A new unit has entered the battlefield. (a player built one) (sensitive to NXT)
POS * Unit position information, including heading (direction in the world). Absolute position. Extension 10/01/2000 WPT * A WayPoinT. Using waypoints instead of absolute positioning via POS would improve networking performance a great deal. (The clients interpolate unit positions between waypoints.) Syntax
"INIT\0"
-------------------------------------------------------------------------------------------------------------------------- "NXT\0" (special)
"AIM <mouse_x>,<mouse_y>\0"
"SEL <unit_id1>,<unit_id2>,...,<unit_idN>\0"
"SHT <target's_unit_id>,<energy_remaining[0..100]>\0"
"NEW <unit_id>,<unit_type_id>\0"
"NEW 43,2" // make a tank with UNIT_ID 43. "POS 43,300,500,64" The two possibilities for unit positioning
"POS <unit_id>,<world-space_x>,<world-space_y>,<heading[0..255]>\0"
WPT <unit_id>,<world-space_x>,<world-space_y>\0
unit positions every game cycle, the server now broadcasts waypoint information as needed. (after a unit reaches a waypoint, it is given the next if that waypoint is not the requested destination.)
Client-2-Server Messages
AIM * Player's mouse cursor location. See above. SEL * Selected units. See above. SHT * All selected units wish to shoot at the location defined by AIM. MOV * Tells the server that all selected units wish to move to the point defined by AIM. BLD * Build a unit.
Syntax
"AIM <mouse_x>,<mouse_y>\0"
"SEL <unit_id1>,<unit_id2>,...,<unit_idN>\0"
"SHT\0"
"MOV\0"
"BLD <unit_type_id>\0"
IMPORTANT NOTES ABOUT THE ARCHITECTURE
The relationships between the different IDs
PLAYER ID e {0,1,2,....}
During game session initialization, each player is given a PLAYER_ID (starting at 0). The PLAYER_ID is given in the order of connecting to the server. So, if a player connects to a server with no players currently connected to it, the player is given PLAYER_ID 0 and the next player gets PLAYER_ID 1 and so on. A player with PLAYER_ID==0 is considered to be the host of the game and is the only one allowed to LAUNCH the game.
WHY? * The PLAYER_ID will be used to identify players in the game. (i.e. index tables containing per-player information. Kills etc.)
UNIT ID e {0,1,2,....}
A number identifying a unit on the battlefield. This number is used to index tables containing per-unit information (owner's PLAYER_ID / unit's status information). It is important that these IDs start at 0 and increment as needed if dynamic unit generation is to be performed. A UNIT_ID that belongs to a destroyed unit may be reused as needed (and definitely should.)
Assumptions about the ordering of Server-2-Client messages
It is assumed that per-player unit information, i.e. all unit related information, is sent by the server in the order of incrementing PLAYER_ID. In other words, the server broadcasts per-player (that is, after broadcasting "INIT\0") unit information so that player 0 is the first player who's data gets sent to other players. Prior to broadcasting each player's data the server broadcasts "NXT\0", so that the clients know that the data belongs to the player with the next PLAYER_ID. The PLAYER_ID count done by the clients is reset after each "INIT\0" so that the whole thing can start all over again. NOTE: Unit position data may be sent in any order. It is the others that require this ordering as you probably realize looking at the Server-2-Client message definitions above.
Comments
As we can see, the amount of data sent from the server software to the clients is much larger than the amount sent from the clients to the server. Shouldn't be too difficult to implement, depending, of course, on the current architecture of the server.
|