38 #define NETCONN_MAPCHANGE_SEED 7 |
38 #define NETCONN_MAPCHANGE_SEED 7 |
39 |
39 |
40 // TODO: Order of functions, and match the order in netconn.c |
40 // TODO: Order of functions, and match the order in netconn.c |
41 typedef struct _flib_netconn flib_netconn; |
41 typedef struct _flib_netconn flib_netconn; |
42 |
42 |
43 flib_netconn *flib_netconn_create(const char *playerName, flib_cfg_meta *metacfg, const char *host, uint16_t port); |
43 /** |
|
44 * Create a new netplay connection with these parameters. |
|
45 * The path to the data directory must end with a path delimiter (e.g. C:\Games\Hedgewars\Data\) |
|
46 */ |
|
47 flib_netconn *flib_netconn_create(const char *playerName, flib_cfg_meta *metacfg, const char *dataDirPath, const char *host, uint16_t port); |
44 void flib_netconn_destroy(flib_netconn *conn); |
48 void flib_netconn_destroy(flib_netconn *conn); |
45 |
49 |
46 /** |
50 /** |
47 * Perform I/O operations and call callbacks if something interesting happens. |
51 * Perform I/O operations and call callbacks if something interesting happens. |
48 * Should be called regularly. |
52 * Should be called regularly. |
58 /** |
62 /** |
59 * Are you currently the owner of this room? The return value only makes sense in |
63 * Are you currently the owner of this room? The return value only makes sense in |
60 * NETCONN_STATE_ROOM and NETCONN_STATE_INGAME states. |
64 * NETCONN_STATE_ROOM and NETCONN_STATE_INGAME states. |
61 */ |
65 */ |
62 bool flib_netconn_is_chief(flib_netconn *conn); |
66 bool flib_netconn_is_chief(flib_netconn *conn); |
|
67 |
|
68 /** |
|
69 * Are you in the context of a room, i.e. either in room or ingame state? |
|
70 */ |
|
71 bool flib_netconn_is_in_room_context(flib_netconn *conn); |
|
72 |
|
73 /** |
|
74 * Generate a game setup from the current room state. |
|
75 * Returns NULL if the room state does not contain enough information |
|
76 * for a complete game setup, or if an error occurs. |
|
77 * |
|
78 * The new gamesetup must be destroyed TODO function for that... |
|
79 */ |
|
80 flib_gamesetup *flib_netconn_create_gameSetup(flib_netconn *conn); |
63 |
81 |
64 /** |
82 /** |
65 * quitmsg may be null |
83 * quitmsg may be null |
66 */ |
84 */ |
67 int flib_netconn_send_quit(flib_netconn *conn, const char *quitmsg); |
85 int flib_netconn_send_quit(flib_netconn *conn, const char *quitmsg); |
144 |
162 |
145 /** |
163 /** |
146 * Set the teamcolor of a team. Only makes sense in room state and if you are chief. |
164 * Set the teamcolor of a team. Only makes sense in room state and if you are chief. |
147 * The server does not send a reply. |
165 * The server does not send a reply. |
148 */ |
166 */ |
149 int flib_netconn_send_teamColor(flib_netconn *conn, const char *teamname, uint32_t colorRGB); |
167 int flib_netconn_send_teamColor(flib_netconn *conn, const char *teamname, int colorIndex); |
150 |
168 |
151 /** |
169 /** |
152 * Set the weaponset for the room. Only makes sense in room state and if you are chief. |
170 * Set the weaponset for the room. Only makes sense in room state and if you are chief. |
153 * The server does not send a reply. |
171 * The server does not send a reply. |
154 */ |
172 */ |
316 /** |
334 /** |
317 * Callbacks for room list updates. The room list is managed automatically and can be queried with |
335 * Callbacks for room list updates. The room list is managed automatically and can be queried with |
318 * flib_netconn_get_roomlist() as soon as the onConnected callback is fired. These callbacks |
336 * flib_netconn_get_roomlist() as soon as the onConnected callback is fired. These callbacks |
319 * provide notification about changes. |
337 * provide notification about changes. |
320 */ |
338 */ |
321 void flib_netconn_onRoomAdd(flib_netconn *conn, void (*callback)(void *context, const flib_roomlist_room *room), void* context); |
339 void flib_netconn_onRoomAdd(flib_netconn *conn, void (*callback)(void *context, const flib_room *room), void* context); |
322 void flib_netconn_onRoomDelete(flib_netconn *conn, void (*callback)(void *context, const char *name), void* context); |
340 void flib_netconn_onRoomDelete(flib_netconn *conn, void (*callback)(void *context, const char *name), void* context); |
323 void flib_netconn_onRoomUpdate(flib_netconn *conn, void (*callback)(void *context, const char *oldName, const flib_roomlist_room *room), void* context); |
341 void flib_netconn_onRoomUpdate(flib_netconn *conn, void (*callback)(void *context, const char *oldName, const flib_room *room), void* context); |
324 |
342 |
325 /** |
343 /** |
326 * Callbacks for players joining or leaving the lobby. If join is true it's a join, otherwise a leave. |
344 * Callbacks for players joining or leaving the lobby. If join is true it's a join, otherwise a leave. |
327 * NOTE: partMessage is null if no parting message was given. |
345 * NOTE: partMessage is null if no parting message was given. |
328 */ |
346 */ |
415 |
433 |
416 /** |
434 /** |
417 * The color of a team has been changed by the room chief. If you are the chief and change the color yourself, |
435 * The color of a team has been changed by the room chief. If you are the chief and change the color yourself, |
418 * you will not receive this callback! |
436 * you will not receive this callback! |
419 */ |
437 */ |
420 void flib_netconn_onTeamColorChanged(flib_netconn *conn, void (*callback)(void *context, const char *teamName, uint32_t colorARGB), void *context); |
438 void flib_netconn_onTeamColorChanged(flib_netconn *conn, void (*callback)(void *context, const char *teamName, int colorIndex), void *context); |
421 |
439 |
422 void flib_netconn_onEngineMessage(flib_netconn *conn, void (*callback)(void *context, const char *message, int size), void *context); |
440 void flib_netconn_onEngineMessage(flib_netconn *conn, void (*callback)(void *context, const uint8_t *message, size_t size), void *context); |
423 |
441 |
424 void flib_netconn_onCfgScheme(flib_netconn *conn, void (*callback)(void *context, flib_cfg *scheme), void *context); |
442 void flib_netconn_onCfgScheme(flib_netconn *conn, void (*callback)(void *context, flib_cfg *scheme), void *context); |
425 |
443 |
426 /** |
444 /** |
427 * This is called when the map configuration in a room is changed (or first received). Only non-chiefs receive these messages. |
445 * This is called when the map configuration in a room is changed (or first received). Only non-chiefs receive these messages. |