project_files/frontlib/model/roomlist.h
author Medo <smaxein@googlemail.com>
Mon, 25 Jun 2012 00:42:07 +0200
changeset 7271 5608ac657362
parent 7269 5b0aeef8ba2a
child 7275 15f722e0b96f
permissions -rw-r--r--
frontlib: Intermittent commit. Things are still in flux but we're getting there :)

/**
 * Models the list of rooms on a server for netplay.
 */

#ifndef ROOMLIST_H_
#define ROOMLIST_H_

#include <stdbool.h>

typedef struct {
    bool inProgress;	// true if the game is running
    char *name;
    int playerCount;
    int teamCount;
    char *owner;
    char *map;			// This is either a map name, or one of +rnd+, +maze+ or +drawn+.
    char *scheme;
    char *weapons;
} flib_roomlist_room;

typedef struct {
	int roomCount;
	flib_roomlist_room **rooms;
} flib_roomlist;

flib_roomlist *flib_roomlist_create();

void flib_roomlist_destroy(flib_roomlist *list);

/**
 * Insert a new room at the start of the list. The room is defined by the params-array,
 * which must consist of 8 non-null strings, as sent by the server in netplay.
 *
 * Returns 0 on success.
 */
int flib_roomlist_add(flib_roomlist *list, char **params);

/**
 * Update the room with the name [name] with parameters sent by the server.
 *
 * Returns 0 on success.
 */
int flib_roomlist_update(flib_roomlist *list, const char *name, char **params);

/**
 * Returns the room with the name [name] from the list if it exists, NULL otherwise
 */
flib_roomlist_room *flib_roomlist_find(flib_roomlist *list, const char *name);

/**
 * Removes all rooms from the list
 */
void flib_roomlist_clear(flib_roomlist *list);

/**
 * Delete the room with the name [name] from the room list.
 * Returns 0 on success.
 */
int flib_roomlist_delete(flib_roomlist *list, const char *name);

#endif