project_files/frontlib/model/roomlist.h
changeset 7269 5b0aeef8ba2a
child 7275 15f722e0b96f
equal deleted inserted replaced
7267:710f3ced8934 7269:5b0aeef8ba2a
       
     1 /**
       
     2  * Models the list of rooms on a server for netplay.
       
     3  */
       
     4 
       
     5 #ifndef ROOMLIST_H_
       
     6 #define ROOMLIST_H_
       
     7 
       
     8 #include <stdbool.h>
       
     9 
       
    10 typedef struct {
       
    11     bool inProgress;	// true if the game is running
       
    12     char *name;
       
    13     int playerCount;
       
    14     int teamCount;
       
    15     char *owner;
       
    16     char *map;			// This is either a map name, or one of +rnd+, +maze+ or +drawn+.
       
    17     char *scheme;
       
    18     char *weapons;
       
    19 } flib_roomlist_room;
       
    20 
       
    21 typedef struct {
       
    22 	int roomCount;
       
    23 	flib_roomlist_room **rooms;
       
    24 } flib_roomlist;
       
    25 
       
    26 flib_roomlist *flib_roomlist_create();
       
    27 
       
    28 void flib_roomlist_destroy(flib_roomlist *list);
       
    29 
       
    30 /**
       
    31  * Insert a new room at the start of the list. The room is defined by the params-array,
       
    32  * which must consist of 8 non-null strings, as sent by the server in netplay.
       
    33  *
       
    34  * Returns 0 on success.
       
    35  */
       
    36 int flib_roomlist_add(flib_roomlist *list, char **params);
       
    37 
       
    38 /**
       
    39  * Update the room with the name [name] with parameters sent by the server.
       
    40  *
       
    41  * Returns 0 on success.
       
    42  */
       
    43 int flib_roomlist_update(flib_roomlist *list, const char *name, char **params);
       
    44 
       
    45 /**
       
    46  * Returns the room with the name [name] from the list if it exists, NULL otherwise
       
    47  */
       
    48 flib_roomlist_room *flib_roomlist_find(flib_roomlist *list, const char *name);
       
    49 
       
    50 /**
       
    51  * Removes all rooms from the list
       
    52  */
       
    53 void flib_roomlist_clear(flib_roomlist *list);
       
    54 
       
    55 /**
       
    56  * Delete the room with the name [name] from the room list.
       
    57  * Returns 0 on success.
       
    58  */
       
    59 int flib_roomlist_delete(flib_roomlist *list, const char *name);
       
    60 
       
    61 #endif