project_files/frontlib/model/roomlist.h
author Medo <smaxein@googlemail.com>
Wed, 27 Jun 2012 22:52:19 +0200
changeset 7314 6171f0bad318
parent 7275 15f722e0b96f
permissions -rw-r--r--
frontlib: Fixes and improvements. Added a GPLv2+ license header to all frontlib files that did not have their license fixed already.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
7314
6171f0bad318 frontlib: Fixes and improvements. Added a GPLv2+ license header to all frontlib
Medo <smaxein@googlemail.com>
parents: 7275
diff changeset
     1
/*
6171f0bad318 frontlib: Fixes and improvements. Added a GPLv2+ license header to all frontlib
Medo <smaxein@googlemail.com>
parents: 7275
diff changeset
     2
 * Hedgewars, a free turn based strategy game
6171f0bad318 frontlib: Fixes and improvements. Added a GPLv2+ license header to all frontlib
Medo <smaxein@googlemail.com>
parents: 7275
diff changeset
     3
 * Copyright (C) 2012 Simeon Maxein <smaxein@googlemail.com>
6171f0bad318 frontlib: Fixes and improvements. Added a GPLv2+ license header to all frontlib
Medo <smaxein@googlemail.com>
parents: 7275
diff changeset
     4
 *
6171f0bad318 frontlib: Fixes and improvements. Added a GPLv2+ license header to all frontlib
Medo <smaxein@googlemail.com>
parents: 7275
diff changeset
     5
 * This program is free software; you can redistribute it and/or
6171f0bad318 frontlib: Fixes and improvements. Added a GPLv2+ license header to all frontlib
Medo <smaxein@googlemail.com>
parents: 7275
diff changeset
     6
 * modify it under the terms of the GNU General Public License
6171f0bad318 frontlib: Fixes and improvements. Added a GPLv2+ license header to all frontlib
Medo <smaxein@googlemail.com>
parents: 7275
diff changeset
     7
 * as published by the Free Software Foundation; either version 2
6171f0bad318 frontlib: Fixes and improvements. Added a GPLv2+ license header to all frontlib
Medo <smaxein@googlemail.com>
parents: 7275
diff changeset
     8
 * of the License, or (at your option) any later version.
6171f0bad318 frontlib: Fixes and improvements. Added a GPLv2+ license header to all frontlib
Medo <smaxein@googlemail.com>
parents: 7275
diff changeset
     9
 *
6171f0bad318 frontlib: Fixes and improvements. Added a GPLv2+ license header to all frontlib
Medo <smaxein@googlemail.com>
parents: 7275
diff changeset
    10
 * This program is distributed in the hope that it will be useful,
6171f0bad318 frontlib: Fixes and improvements. Added a GPLv2+ license header to all frontlib
Medo <smaxein@googlemail.com>
parents: 7275
diff changeset
    11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
6171f0bad318 frontlib: Fixes and improvements. Added a GPLv2+ license header to all frontlib
Medo <smaxein@googlemail.com>
parents: 7275
diff changeset
    12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
6171f0bad318 frontlib: Fixes and improvements. Added a GPLv2+ license header to all frontlib
Medo <smaxein@googlemail.com>
parents: 7275
diff changeset
    13
 * GNU General Public License for more details.
6171f0bad318 frontlib: Fixes and improvements. Added a GPLv2+ license header to all frontlib
Medo <smaxein@googlemail.com>
parents: 7275
diff changeset
    14
 *
6171f0bad318 frontlib: Fixes and improvements. Added a GPLv2+ license header to all frontlib
Medo <smaxein@googlemail.com>
parents: 7275
diff changeset
    15
 * You should have received a copy of the GNU General Public License
6171f0bad318 frontlib: Fixes and improvements. Added a GPLv2+ license header to all frontlib
Medo <smaxein@googlemail.com>
parents: 7275
diff changeset
    16
 * along with this program; if not, write to the Free Software
6171f0bad318 frontlib: Fixes and improvements. Added a GPLv2+ license header to all frontlib
Medo <smaxein@googlemail.com>
parents: 7275
diff changeset
    17
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
6171f0bad318 frontlib: Fixes and improvements. Added a GPLv2+ license header to all frontlib
Medo <smaxein@googlemail.com>
parents: 7275
diff changeset
    18
 */
6171f0bad318 frontlib: Fixes and improvements. Added a GPLv2+ license header to all frontlib
Medo <smaxein@googlemail.com>
parents: 7275
diff changeset
    19
7269
5b0aeef8ba2a More progress on the netplay part of the frontlib
Medo <smaxein@googlemail.com>
parents:
diff changeset
    20
/**
5b0aeef8ba2a More progress on the netplay part of the frontlib
Medo <smaxein@googlemail.com>
parents:
diff changeset
    21
 * Models the list of rooms on a server for netplay.
5b0aeef8ba2a More progress on the netplay part of the frontlib
Medo <smaxein@googlemail.com>
parents:
diff changeset
    22
 */
5b0aeef8ba2a More progress on the netplay part of the frontlib
Medo <smaxein@googlemail.com>
parents:
diff changeset
    23
5b0aeef8ba2a More progress on the netplay part of the frontlib
Medo <smaxein@googlemail.com>
parents:
diff changeset
    24
#ifndef ROOMLIST_H_
5b0aeef8ba2a More progress on the netplay part of the frontlib
Medo <smaxein@googlemail.com>
parents:
diff changeset
    25
#define ROOMLIST_H_
5b0aeef8ba2a More progress on the netplay part of the frontlib
Medo <smaxein@googlemail.com>
parents:
diff changeset
    26
5b0aeef8ba2a More progress on the netplay part of the frontlib
Medo <smaxein@googlemail.com>
parents:
diff changeset
    27
#include <stdbool.h>
5b0aeef8ba2a More progress on the netplay part of the frontlib
Medo <smaxein@googlemail.com>
parents:
diff changeset
    28
5b0aeef8ba2a More progress on the netplay part of the frontlib
Medo <smaxein@googlemail.com>
parents:
diff changeset
    29
typedef struct {
5b0aeef8ba2a More progress on the netplay part of the frontlib
Medo <smaxein@googlemail.com>
parents:
diff changeset
    30
    bool inProgress;	// true if the game is running
5b0aeef8ba2a More progress on the netplay part of the frontlib
Medo <smaxein@googlemail.com>
parents:
diff changeset
    31
    char *name;
5b0aeef8ba2a More progress on the netplay part of the frontlib
Medo <smaxein@googlemail.com>
parents:
diff changeset
    32
    int playerCount;
5b0aeef8ba2a More progress on the netplay part of the frontlib
Medo <smaxein@googlemail.com>
parents:
diff changeset
    33
    int teamCount;
5b0aeef8ba2a More progress on the netplay part of the frontlib
Medo <smaxein@googlemail.com>
parents:
diff changeset
    34
    char *owner;
5b0aeef8ba2a More progress on the netplay part of the frontlib
Medo <smaxein@googlemail.com>
parents:
diff changeset
    35
    char *map;			// This is either a map name, or one of +rnd+, +maze+ or +drawn+.
5b0aeef8ba2a More progress on the netplay part of the frontlib
Medo <smaxein@googlemail.com>
parents:
diff changeset
    36
    char *scheme;
5b0aeef8ba2a More progress on the netplay part of the frontlib
Medo <smaxein@googlemail.com>
parents:
diff changeset
    37
    char *weapons;
7275
15f722e0b96f frontlib: Getting there :) Added commandline client for testing
Medo <smaxein@googlemail.com>
parents: 7269
diff changeset
    38
} flib_room;
7269
5b0aeef8ba2a More progress on the netplay part of the frontlib
Medo <smaxein@googlemail.com>
parents:
diff changeset
    39
5b0aeef8ba2a More progress on the netplay part of the frontlib
Medo <smaxein@googlemail.com>
parents:
diff changeset
    40
typedef struct {
5b0aeef8ba2a More progress on the netplay part of the frontlib
Medo <smaxein@googlemail.com>
parents:
diff changeset
    41
	int roomCount;
7275
15f722e0b96f frontlib: Getting there :) Added commandline client for testing
Medo <smaxein@googlemail.com>
parents: 7269
diff changeset
    42
	flib_room **rooms;
7269
5b0aeef8ba2a More progress on the netplay part of the frontlib
Medo <smaxein@googlemail.com>
parents:
diff changeset
    43
} flib_roomlist;
5b0aeef8ba2a More progress on the netplay part of the frontlib
Medo <smaxein@googlemail.com>
parents:
diff changeset
    44
5b0aeef8ba2a More progress on the netplay part of the frontlib
Medo <smaxein@googlemail.com>
parents:
diff changeset
    45
flib_roomlist *flib_roomlist_create();
5b0aeef8ba2a More progress on the netplay part of the frontlib
Medo <smaxein@googlemail.com>
parents:
diff changeset
    46
5b0aeef8ba2a More progress on the netplay part of the frontlib
Medo <smaxein@googlemail.com>
parents:
diff changeset
    47
void flib_roomlist_destroy(flib_roomlist *list);
5b0aeef8ba2a More progress on the netplay part of the frontlib
Medo <smaxein@googlemail.com>
parents:
diff changeset
    48
5b0aeef8ba2a More progress on the netplay part of the frontlib
Medo <smaxein@googlemail.com>
parents:
diff changeset
    49
/**
5b0aeef8ba2a More progress on the netplay part of the frontlib
Medo <smaxein@googlemail.com>
parents:
diff changeset
    50
 * Insert a new room at the start of the list. The room is defined by the params-array,
5b0aeef8ba2a More progress on the netplay part of the frontlib
Medo <smaxein@googlemail.com>
parents:
diff changeset
    51
 * which must consist of 8 non-null strings, as sent by the server in netplay.
5b0aeef8ba2a More progress on the netplay part of the frontlib
Medo <smaxein@googlemail.com>
parents:
diff changeset
    52
 *
5b0aeef8ba2a More progress on the netplay part of the frontlib
Medo <smaxein@googlemail.com>
parents:
diff changeset
    53
 * Returns 0 on success.
5b0aeef8ba2a More progress on the netplay part of the frontlib
Medo <smaxein@googlemail.com>
parents:
diff changeset
    54
 */
5b0aeef8ba2a More progress on the netplay part of the frontlib
Medo <smaxein@googlemail.com>
parents:
diff changeset
    55
int flib_roomlist_add(flib_roomlist *list, char **params);
5b0aeef8ba2a More progress on the netplay part of the frontlib
Medo <smaxein@googlemail.com>
parents:
diff changeset
    56
5b0aeef8ba2a More progress on the netplay part of the frontlib
Medo <smaxein@googlemail.com>
parents:
diff changeset
    57
/**
5b0aeef8ba2a More progress on the netplay part of the frontlib
Medo <smaxein@googlemail.com>
parents:
diff changeset
    58
 * Update the room with the name [name] with parameters sent by the server.
5b0aeef8ba2a More progress on the netplay part of the frontlib
Medo <smaxein@googlemail.com>
parents:
diff changeset
    59
 *
5b0aeef8ba2a More progress on the netplay part of the frontlib
Medo <smaxein@googlemail.com>
parents:
diff changeset
    60
 * Returns 0 on success.
5b0aeef8ba2a More progress on the netplay part of the frontlib
Medo <smaxein@googlemail.com>
parents:
diff changeset
    61
 */
5b0aeef8ba2a More progress on the netplay part of the frontlib
Medo <smaxein@googlemail.com>
parents:
diff changeset
    62
int flib_roomlist_update(flib_roomlist *list, const char *name, char **params);
5b0aeef8ba2a More progress on the netplay part of the frontlib
Medo <smaxein@googlemail.com>
parents:
diff changeset
    63
5b0aeef8ba2a More progress on the netplay part of the frontlib
Medo <smaxein@googlemail.com>
parents:
diff changeset
    64
/**
5b0aeef8ba2a More progress on the netplay part of the frontlib
Medo <smaxein@googlemail.com>
parents:
diff changeset
    65
 * Returns the room with the name [name] from the list if it exists, NULL otherwise
5b0aeef8ba2a More progress on the netplay part of the frontlib
Medo <smaxein@googlemail.com>
parents:
diff changeset
    66
 */
7275
15f722e0b96f frontlib: Getting there :) Added commandline client for testing
Medo <smaxein@googlemail.com>
parents: 7269
diff changeset
    67
flib_room *flib_roomlist_find(const flib_roomlist *list, const char *name);
7269
5b0aeef8ba2a More progress on the netplay part of the frontlib
Medo <smaxein@googlemail.com>
parents:
diff changeset
    68
5b0aeef8ba2a More progress on the netplay part of the frontlib
Medo <smaxein@googlemail.com>
parents:
diff changeset
    69
/**
5b0aeef8ba2a More progress on the netplay part of the frontlib
Medo <smaxein@googlemail.com>
parents:
diff changeset
    70
 * Removes all rooms from the list
5b0aeef8ba2a More progress on the netplay part of the frontlib
Medo <smaxein@googlemail.com>
parents:
diff changeset
    71
 */
5b0aeef8ba2a More progress on the netplay part of the frontlib
Medo <smaxein@googlemail.com>
parents:
diff changeset
    72
void flib_roomlist_clear(flib_roomlist *list);
5b0aeef8ba2a More progress on the netplay part of the frontlib
Medo <smaxein@googlemail.com>
parents:
diff changeset
    73
5b0aeef8ba2a More progress on the netplay part of the frontlib
Medo <smaxein@googlemail.com>
parents:
diff changeset
    74
/**
5b0aeef8ba2a More progress on the netplay part of the frontlib
Medo <smaxein@googlemail.com>
parents:
diff changeset
    75
 * Delete the room with the name [name] from the room list.
5b0aeef8ba2a More progress on the netplay part of the frontlib
Medo <smaxein@googlemail.com>
parents:
diff changeset
    76
 * Returns 0 on success.
5b0aeef8ba2a More progress on the netplay part of the frontlib
Medo <smaxein@googlemail.com>
parents:
diff changeset
    77
 */
5b0aeef8ba2a More progress on the netplay part of the frontlib
Medo <smaxein@googlemail.com>
parents:
diff changeset
    78
int flib_roomlist_delete(flib_roomlist *list, const char *name);
5b0aeef8ba2a More progress on the netplay part of the frontlib
Medo <smaxein@googlemail.com>
parents:
diff changeset
    79
5b0aeef8ba2a More progress on the netplay part of the frontlib
Medo <smaxein@googlemail.com>
parents:
diff changeset
    80
#endif