author | Medo <smaxein@googlemail.com> |
Wed, 27 Jun 2012 18:04:17 +0200 | |
changeset 7312 | d1db8aaa8edc |
parent 7275 | 15f722e0b96f |
child 7314 | 6171f0bad318 |
permissions | -rw-r--r-- |
7269
5b0aeef8ba2a
More progress on the netplay part of the frontlib
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
1 |
#include "roomlist.h" |
5b0aeef8ba2a
More progress on the netplay part of the frontlib
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
2 |
|
5b0aeef8ba2a
More progress on the netplay part of the frontlib
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
3 |
#include "../util/util.h" |
5b0aeef8ba2a
More progress on the netplay part of the frontlib
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
4 |
#include "../util/list.h" |
5b0aeef8ba2a
More progress on the netplay part of the frontlib
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
5 |
#include "../util/logging.h" |
5b0aeef8ba2a
More progress on the netplay part of the frontlib
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
6 |
|
5b0aeef8ba2a
More progress on the netplay part of the frontlib
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
7 |
#include <stdlib.h> |
5b0aeef8ba2a
More progress on the netplay part of the frontlib
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
8 |
#include <string.h> |
5b0aeef8ba2a
More progress on the netplay part of the frontlib
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
9 |
|
5b0aeef8ba2a
More progress on the netplay part of the frontlib
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
10 |
flib_roomlist *flib_roomlist_create() { |
5b0aeef8ba2a
More progress on the netplay part of the frontlib
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
11 |
return flib_calloc(1, sizeof(flib_roomlist)); |
5b0aeef8ba2a
More progress on the netplay part of the frontlib
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
12 |
} |
5b0aeef8ba2a
More progress on the netplay part of the frontlib
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
13 |
|
7275
15f722e0b96f
frontlib: Getting there :) Added commandline client for testing
Medo <smaxein@googlemail.com>
parents:
7269
diff
changeset
|
14 |
static void flib_roomlist_room_destroy(flib_room *room) { |
7269
5b0aeef8ba2a
More progress on the netplay part of the frontlib
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
15 |
if(room) { |
5b0aeef8ba2a
More progress on the netplay part of the frontlib
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
16 |
free(room->map); |
5b0aeef8ba2a
More progress on the netplay part of the frontlib
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
17 |
free(room->name); |
5b0aeef8ba2a
More progress on the netplay part of the frontlib
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
18 |
free(room->owner); |
5b0aeef8ba2a
More progress on the netplay part of the frontlib
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
19 |
free(room->scheme); |
5b0aeef8ba2a
More progress on the netplay part of the frontlib
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
20 |
free(room->weapons); |
5b0aeef8ba2a
More progress on the netplay part of the frontlib
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
21 |
free(room); |
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 |
|
5b0aeef8ba2a
More progress on the netplay part of the frontlib
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
25 |
void flib_roomlist_destroy(flib_roomlist *list) { |
5b0aeef8ba2a
More progress on the netplay part of the frontlib
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
26 |
if(list) { |
5b0aeef8ba2a
More progress on the netplay part of the frontlib
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
27 |
for(int i=0; i<list->roomCount; i++) { |
5b0aeef8ba2a
More progress on the netplay part of the frontlib
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
28 |
flib_roomlist_room_destroy(list->rooms[i]); |
5b0aeef8ba2a
More progress on the netplay part of the frontlib
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
29 |
} |
7275
15f722e0b96f
frontlib: Getting there :) Added commandline client for testing
Medo <smaxein@googlemail.com>
parents:
7269
diff
changeset
|
30 |
free(list->rooms); |
7269
5b0aeef8ba2a
More progress on the netplay part of the frontlib
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
31 |
free(list); |
5b0aeef8ba2a
More progress on the netplay part of the frontlib
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
32 |
} |
5b0aeef8ba2a
More progress on the netplay part of the frontlib
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
33 |
} |
5b0aeef8ba2a
More progress on the netplay part of the frontlib
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
34 |
|
7275
15f722e0b96f
frontlib: Getting there :) Added commandline client for testing
Medo <smaxein@googlemail.com>
parents:
7269
diff
changeset
|
35 |
static flib_room *fillRoomFromParams(char **params) { |
15f722e0b96f
frontlib: Getting there :) Added commandline client for testing
Medo <smaxein@googlemail.com>
parents:
7269
diff
changeset
|
36 |
flib_room *result = NULL; |
15f722e0b96f
frontlib: Getting there :) Added commandline client for testing
Medo <smaxein@googlemail.com>
parents:
7269
diff
changeset
|
37 |
flib_room *tmpRoom = flib_calloc(1, sizeof(flib_room)); |
7269
5b0aeef8ba2a
More progress on the netplay part of the frontlib
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
38 |
if(tmpRoom) { |
5b0aeef8ba2a
More progress on the netplay part of the frontlib
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
39 |
tmpRoom->inProgress = !strcmp(params[0], "True"); |
5b0aeef8ba2a
More progress on the netplay part of the frontlib
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
40 |
tmpRoom->name = flib_strdupnull(params[1]); |
5b0aeef8ba2a
More progress on the netplay part of the frontlib
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
41 |
tmpRoom->playerCount = atoi(params[2]); |
5b0aeef8ba2a
More progress on the netplay part of the frontlib
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
42 |
tmpRoom->teamCount = atoi(params[3]); |
5b0aeef8ba2a
More progress on the netplay part of the frontlib
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
43 |
tmpRoom->owner = flib_strdupnull(params[4]); |
5b0aeef8ba2a
More progress on the netplay part of the frontlib
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
44 |
tmpRoom->map = flib_strdupnull(params[5]); |
5b0aeef8ba2a
More progress on the netplay part of the frontlib
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
45 |
tmpRoom->scheme = flib_strdupnull(params[6]); |
5b0aeef8ba2a
More progress on the netplay part of the frontlib
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
46 |
tmpRoom->weapons = flib_strdupnull(params[7]); |
5b0aeef8ba2a
More progress on the netplay part of the frontlib
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
47 |
if(tmpRoom->name && tmpRoom->owner && tmpRoom->map && tmpRoom->scheme && tmpRoom->weapons) { |
5b0aeef8ba2a
More progress on the netplay part of the frontlib
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
48 |
result = tmpRoom; |
5b0aeef8ba2a
More progress on the netplay part of the frontlib
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
49 |
tmpRoom = NULL; |
5b0aeef8ba2a
More progress on the netplay part of the frontlib
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
50 |
} |
5b0aeef8ba2a
More progress on the netplay part of the frontlib
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
51 |
} |
5b0aeef8ba2a
More progress on the netplay part of the frontlib
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
52 |
flib_roomlist_room_destroy(tmpRoom); |
5b0aeef8ba2a
More progress on the netplay part of the frontlib
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
53 |
return result; |
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 |
|
7275
15f722e0b96f
frontlib: Getting there :) Added commandline client for testing
Medo <smaxein@googlemail.com>
parents:
7269
diff
changeset
|
56 |
GENERATE_STATIC_LIST_INSERT(insertRoom, flib_room*) |
15f722e0b96f
frontlib: Getting there :) Added commandline client for testing
Medo <smaxein@googlemail.com>
parents:
7269
diff
changeset
|
57 |
GENERATE_STATIC_LIST_DELETE(deleteRoom, flib_room*) |
15f722e0b96f
frontlib: Getting there :) Added commandline client for testing
Medo <smaxein@googlemail.com>
parents:
7269
diff
changeset
|
58 |
|
15f722e0b96f
frontlib: Getting there :) Added commandline client for testing
Medo <smaxein@googlemail.com>
parents:
7269
diff
changeset
|
59 |
static int findRoom(const flib_roomlist *list, const char *name) { |
15f722e0b96f
frontlib: Getting there :) Added commandline client for testing
Medo <smaxein@googlemail.com>
parents:
7269
diff
changeset
|
60 |
for(int i=0; i<list->roomCount; i++) { |
15f722e0b96f
frontlib: Getting there :) Added commandline client for testing
Medo <smaxein@googlemail.com>
parents:
7269
diff
changeset
|
61 |
if(!strcmp(name, list->rooms[i]->name)) { |
15f722e0b96f
frontlib: Getting there :) Added commandline client for testing
Medo <smaxein@googlemail.com>
parents:
7269
diff
changeset
|
62 |
return i; |
15f722e0b96f
frontlib: Getting there :) Added commandline client for testing
Medo <smaxein@googlemail.com>
parents:
7269
diff
changeset
|
63 |
} |
15f722e0b96f
frontlib: Getting there :) Added commandline client for testing
Medo <smaxein@googlemail.com>
parents:
7269
diff
changeset
|
64 |
} |
15f722e0b96f
frontlib: Getting there :) Added commandline client for testing
Medo <smaxein@googlemail.com>
parents:
7269
diff
changeset
|
65 |
return -1; |
15f722e0b96f
frontlib: Getting there :) Added commandline client for testing
Medo <smaxein@googlemail.com>
parents:
7269
diff
changeset
|
66 |
} |
15f722e0b96f
frontlib: Getting there :) Added commandline client for testing
Medo <smaxein@googlemail.com>
parents:
7269
diff
changeset
|
67 |
|
7269
5b0aeef8ba2a
More progress on the netplay part of the frontlib
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
68 |
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
|
69 |
int result = -1; |
5b0aeef8ba2a
More progress on the netplay part of the frontlib
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
70 |
if(!list || !params) { |
5b0aeef8ba2a
More progress on the netplay part of the frontlib
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
71 |
flib_log_e("null parameter in flib_roomlist_add"); |
5b0aeef8ba2a
More progress on the netplay part of the frontlib
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
72 |
} else { |
7275
15f722e0b96f
frontlib: Getting there :) Added commandline client for testing
Medo <smaxein@googlemail.com>
parents:
7269
diff
changeset
|
73 |
flib_room *tmpRoom = fillRoomFromParams(params); |
7269
5b0aeef8ba2a
More progress on the netplay part of the frontlib
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
74 |
if(tmpRoom) { |
7275
15f722e0b96f
frontlib: Getting there :) Added commandline client for testing
Medo <smaxein@googlemail.com>
parents:
7269
diff
changeset
|
75 |
if(!insertRoom(&list->rooms, &list->roomCount, tmpRoom, 0)) { |
7269
5b0aeef8ba2a
More progress on the netplay part of the frontlib
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
76 |
tmpRoom = NULL; |
5b0aeef8ba2a
More progress on the netplay part of the frontlib
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
77 |
result = 0; |
5b0aeef8ba2a
More progress on the netplay part of the frontlib
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
78 |
} |
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 |
flib_roomlist_room_destroy(tmpRoom); |
5b0aeef8ba2a
More progress on the netplay part of the frontlib
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
81 |
} |
5b0aeef8ba2a
More progress on the netplay part of the frontlib
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
82 |
return result; |
5b0aeef8ba2a
More progress on the netplay part of the frontlib
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
83 |
} |
5b0aeef8ba2a
More progress on the netplay part of the frontlib
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
84 |
|
7275
15f722e0b96f
frontlib: Getting there :) Added commandline client for testing
Medo <smaxein@googlemail.com>
parents:
7269
diff
changeset
|
85 |
int flib_roomlist_delete(flib_roomlist *list, const char *name) { |
15f722e0b96f
frontlib: Getting there :) Added commandline client for testing
Medo <smaxein@googlemail.com>
parents:
7269
diff
changeset
|
86 |
int result = -1; |
15f722e0b96f
frontlib: Getting there :) Added commandline client for testing
Medo <smaxein@googlemail.com>
parents:
7269
diff
changeset
|
87 |
if(!list || !name) { |
15f722e0b96f
frontlib: Getting there :) Added commandline client for testing
Medo <smaxein@googlemail.com>
parents:
7269
diff
changeset
|
88 |
flib_log_e("null parameter in flib_roomlist_delete"); |
15f722e0b96f
frontlib: Getting there :) Added commandline client for testing
Medo <smaxein@googlemail.com>
parents:
7269
diff
changeset
|
89 |
} else { |
15f722e0b96f
frontlib: Getting there :) Added commandline client for testing
Medo <smaxein@googlemail.com>
parents:
7269
diff
changeset
|
90 |
int roomid = findRoom(list, name); |
15f722e0b96f
frontlib: Getting there :) Added commandline client for testing
Medo <smaxein@googlemail.com>
parents:
7269
diff
changeset
|
91 |
if(roomid<0) { |
15f722e0b96f
frontlib: Getting there :) Added commandline client for testing
Medo <smaxein@googlemail.com>
parents:
7269
diff
changeset
|
92 |
flib_log_w("Attempt to delete unknown room %s", name); |
15f722e0b96f
frontlib: Getting there :) Added commandline client for testing
Medo <smaxein@googlemail.com>
parents:
7269
diff
changeset
|
93 |
} else { |
15f722e0b96f
frontlib: Getting there :) Added commandline client for testing
Medo <smaxein@googlemail.com>
parents:
7269
diff
changeset
|
94 |
flib_room *room = list->rooms[roomid]; |
15f722e0b96f
frontlib: Getting there :) Added commandline client for testing
Medo <smaxein@googlemail.com>
parents:
7269
diff
changeset
|
95 |
if(!deleteRoom(&list->rooms, &list->roomCount, roomid)) { |
15f722e0b96f
frontlib: Getting there :) Added commandline client for testing
Medo <smaxein@googlemail.com>
parents:
7269
diff
changeset
|
96 |
flib_roomlist_room_destroy(room); |
15f722e0b96f
frontlib: Getting there :) Added commandline client for testing
Medo <smaxein@googlemail.com>
parents:
7269
diff
changeset
|
97 |
result = 0; |
15f722e0b96f
frontlib: Getting there :) Added commandline client for testing
Medo <smaxein@googlemail.com>
parents:
7269
diff
changeset
|
98 |
} |
7269
5b0aeef8ba2a
More progress on the netplay part of the frontlib
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
99 |
} |
5b0aeef8ba2a
More progress on the netplay part of the frontlib
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
100 |
} |
7275
15f722e0b96f
frontlib: Getting there :) Added commandline client for testing
Medo <smaxein@googlemail.com>
parents:
7269
diff
changeset
|
101 |
return result; |
7269
5b0aeef8ba2a
More progress on the netplay part of the frontlib
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
102 |
} |
5b0aeef8ba2a
More progress on the netplay part of the frontlib
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
103 |
|
5b0aeef8ba2a
More progress on the netplay part of the frontlib
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
104 |
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
|
105 |
int result = -1; |
5b0aeef8ba2a
More progress on the netplay part of the frontlib
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
106 |
if(!list || !name || !params) { |
5b0aeef8ba2a
More progress on the netplay part of the frontlib
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
107 |
flib_log_e("null parameter in flib_roomlist_update"); |
5b0aeef8ba2a
More progress on the netplay part of the frontlib
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
108 |
} else { |
7275
15f722e0b96f
frontlib: Getting there :) Added commandline client for testing
Medo <smaxein@googlemail.com>
parents:
7269
diff
changeset
|
109 |
flib_room *tmpRoom = fillRoomFromParams(params); |
7269
5b0aeef8ba2a
More progress on the netplay part of the frontlib
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
110 |
int roomid = findRoom(list, name); |
5b0aeef8ba2a
More progress on the netplay part of the frontlib
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
111 |
if(tmpRoom && roomid>=0) { |
5b0aeef8ba2a
More progress on the netplay part of the frontlib
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
112 |
flib_roomlist_room_destroy(list->rooms[roomid]); |
5b0aeef8ba2a
More progress on the netplay part of the frontlib
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
113 |
list->rooms[roomid] = tmpRoom; |
5b0aeef8ba2a
More progress on the netplay part of the frontlib
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
114 |
tmpRoom = NULL; |
5b0aeef8ba2a
More progress on the netplay part of the frontlib
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
115 |
result = 0; |
5b0aeef8ba2a
More progress on the netplay part of the frontlib
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
116 |
} |
5b0aeef8ba2a
More progress on the netplay part of the frontlib
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
117 |
flib_roomlist_room_destroy(tmpRoom); |
5b0aeef8ba2a
More progress on the netplay part of the frontlib
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
118 |
} |
5b0aeef8ba2a
More progress on the netplay part of the frontlib
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
119 |
return result; |
5b0aeef8ba2a
More progress on the netplay part of the frontlib
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
120 |
} |
5b0aeef8ba2a
More progress on the netplay part of the frontlib
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
121 |
|
7275
15f722e0b96f
frontlib: Getting there :) Added commandline client for testing
Medo <smaxein@googlemail.com>
parents:
7269
diff
changeset
|
122 |
flib_room *flib_roomlist_find(const flib_roomlist *list, const char *name) { |
15f722e0b96f
frontlib: Getting there :) Added commandline client for testing
Medo <smaxein@googlemail.com>
parents:
7269
diff
changeset
|
123 |
flib_room *result = NULL; |
7269
5b0aeef8ba2a
More progress on the netplay part of the frontlib
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
124 |
if(!list || !name) { |
5b0aeef8ba2a
More progress on the netplay part of the frontlib
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
125 |
flib_log_e("null parameter in flib_roomlist_find"); |
5b0aeef8ba2a
More progress on the netplay part of the frontlib
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
126 |
} else { |
5b0aeef8ba2a
More progress on the netplay part of the frontlib
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
127 |
int roomid = findRoom(list, name); |
5b0aeef8ba2a
More progress on the netplay part of the frontlib
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
128 |
if(roomid>=0) { |
5b0aeef8ba2a
More progress on the netplay part of the frontlib
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
129 |
result = list->rooms[roomid]; |
5b0aeef8ba2a
More progress on the netplay part of the frontlib
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
130 |
} |
5b0aeef8ba2a
More progress on the netplay part of the frontlib
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
131 |
} |
5b0aeef8ba2a
More progress on the netplay part of the frontlib
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
132 |
return result; |
5b0aeef8ba2a
More progress on the netplay part of the frontlib
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
133 |
} |
5b0aeef8ba2a
More progress on the netplay part of the frontlib
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
134 |
|
5b0aeef8ba2a
More progress on the netplay part of the frontlib
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
135 |
void flib_roomlist_clear(flib_roomlist *list) { |
5b0aeef8ba2a
More progress on the netplay part of the frontlib
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
136 |
if(!list) { |
5b0aeef8ba2a
More progress on the netplay part of the frontlib
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
137 |
flib_log_e("null parameter in flib_roomlist_clear"); |
5b0aeef8ba2a
More progress on the netplay part of the frontlib
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
138 |
} else { |
5b0aeef8ba2a
More progress on the netplay part of the frontlib
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
139 |
for(int i=0; i<list->roomCount; i++) { |
5b0aeef8ba2a
More progress on the netplay part of the frontlib
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
140 |
flib_roomlist_room_destroy(list->rooms[i]); |
5b0aeef8ba2a
More progress on the netplay part of the frontlib
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
141 |
} |
5b0aeef8ba2a
More progress on the netplay part of the frontlib
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
142 |
free(list->rooms); |
5b0aeef8ba2a
More progress on the netplay part of the frontlib
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
143 |
list->rooms = NULL; |
5b0aeef8ba2a
More progress on the netplay part of the frontlib
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
144 |
list->roomCount = 0; |
5b0aeef8ba2a
More progress on the netplay part of the frontlib
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
145 |
} |
5b0aeef8ba2a
More progress on the netplay part of the frontlib
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
146 |
} |