![]() Up |
Enemy TerritoryDevelopment/Protocol |
The BMessages that are sent between the server and the clients must have the command-type 0x87654321. So - create BMessages with the constructor BMessage ( 0x87654321 );.
All messages from the clients to the server must be sent to the server's ApplicationLooperPort. This means that you should create a BMessenger with the constructor BMessenger ( "application/x-vnd.EnemyTerritory.Server", -1, & LocalStatusVariable ); and send the BMessage with the BMessengers Method SendMessage ();.
All messages from the server to one client are sent to the same BHandler.
The client can specify the correct BHandler as
reply-handler in the login message.
There are 7 types of BMessages:
login message:
This message is sent from the client to the server.
When sending this message, make sure that the correct reply-handler
is specified.
Name | BMessage type | C++ type | Value |
---|---|---|---|
Type | String | char * | login |
Version | Int32 | unsigned int | 1 |
ClientName | String | char * | Name of the client. The name must be unique in a game. Otherwise you'll get an error message. |
Password | String | char * | This password is generated by the client and is send with each message between the server and the client. |
ReadOnlyPassword
(optional) |
String | char * | Clients can specify a readonly password - so other clients can login and see your moves without moving the armies. |
Name | BMessage type | C++ type | Value |
---|---|---|---|
Type | String | char * | welcome |
Version | Int32 | unsigned int | 1 |
ClientName | String | char * | Name of the client. |
Password | String | char * | The same string as the password in the login-message. |
ClientID | Int32 | unsigned int | The server assignes to every player a unique ID. |
MapSize | Int32 | unsigned int | This is the width and the hight of the square map. |
error message:
This message is sent from the server to the client.
Name | BMessage type | C++ type | Value |
---|---|---|---|
Type | String | char * | error |
Version | Int32 | unsigned int | 1 |
ClientName | String | char * | Name of the client. |
Password | String | char * | The same string as the password in the login-message. |
ErrorText | String | char * | The client may display this error text to the user. |
ErrorCode | Int32 | int | ErrorCodes are explained below. |
status message:
This message is sent from the server to the client.
Name | BMessage type | C++ type | Value |
---|---|---|---|
Type | String | char * | status |
ClientName | String | char * | Client's name |
Password | String | char * | Password |
CurrentTime | Int64 | bigtime_t | Current time (approximatly) of the server in microseconds. |
Object | BMessage | BMessage | This Message stores data of an object |
Field | BMessage | BMessage | This Message stores data of a field. |
object message:
This message is included in a status message.
Name | BMessage type | C++ type | Value |
---|---|---|---|
ID | Int32 | unsigned int | ID of the object. This ID is unique in the whole game. |
Type | Int32 | unsigned int | Object types are explained below. |
Owner | Int32 | unsigned int | This is the Client ID of the Client to that this object belongs to. The least value is 1. |
BusyTill | Int64 | bigtime_t | Time (approximatly) in microseconds that is needed to finish the object's move. |
XPos | Int32 | int | Position |
YPos | Int32 | int | Position |
SensorData | Bool | bool | true => all fields that are visible by this object are sent in the current status message. |
field message:
This message is included in a status message.
When you get this message, you also receive all objects that are on
this field.
Name | BMessage type | C++ type | Value |
---|---|---|---|
XPos | Int32 | int | Position |
YPos | Int32 | int | Position |
Type | Int32 | unsigned int | Field types are explained below. |
Name | BMessage type | C++ type | Value |
---|---|---|---|
Type | String | char * | turn |
ClientName | String | char * | Client's name |
Password | String | char * | Password |
ID | Int32 | unsigned int | Object's ID |
Action | String | char * | move |
MoveToX | Int32 | int | Target position |
MoveToY | Int32 | int | Target position |
victory message:
This message is sent from the server to the client.
Name | BMessage type | C++ type | Value |
---|---|---|---|
Type | String | char * | victory |
ClientName | String | char * | Client's name |
Password | String | char * | Password |
ID | Int32 | unsigned int | Client ID of the winner |
Name | String | char * | Name of the winner |
Error Codes:
0 : No error
-1 : Server refuses login
-2 : Versions are not compatible. You are not logged in.
-3 : The map is too small. The server found no start place. You are
not logged in.
-4 : The server is out of memory. You are not logged in.
-5 : There's already an other player with your name logged in. Wrong
password sent. You are not logged in.
Object Types:
0x10 - 0x1f : Not used.
0x20 : City
0x30 : Army
0x40 - 0xff : Not used.
Field Types:
0x00 : End of the world
0x80 : Invisible
0x10 - 0x1f : Not used.
0x20 - 0x23 : Lake
0x40 - 0x43 : Plain
0x50 - 0x53 : Forrest
0x60 - 0x63 : Mountain
0x80 - 0xff : Not used.
Map:
The fields of the map are hexagons. Every field has a left, a right,
an upper left, an upper right, a lower left and a lower right neighbour.
The positions are specified by x- and y- coordinates. The x- and y- values
range from 0 to ( MapSize - 1 ). All other positions have the field-type
0x00 (End of word).
Supposed, the coordinate ( X, Y ) has an even Y-value (the row number
is 0,2,4,...), then the upper left field is at ( X, Y - 1 ), the upper
right at ( X + 1, Y - 1 ), the lower left at ( X, Y + 1 ) and the lower
right at ( X + 1, Y + 1 ). In the other case (the row number is 1,3,5,...)
the upper left field is at ( X - 1, Y - 1 ), the upper right at ( X, Y
- 1 ), the lower left at ( X - 1, Y + 1 ), the lower right at ( X, Y +
1 ). In both cases the left field is at ( X - 1, Y ) and the right at (
X, Y + 1 ). Summary: The even rows are shifted right.