OpenMoHAA 0.82.0
Loading...
Searching...
No Matches
goaceng.h
1/************
2GameSpy Open Architecture
3 Portable C Engine
4*************/
5/******
6goaceng.h
7GameSpy C Engine SDK
8
9Copyright 1999 GameSpy Industries, Inc
10
11Suite E-204
122900 Bristol Street
13Costa Mesa, CA 92626
14(714)549-7689
15Fax(714)549-0757
16
17******
18
19 Please see the GameSpy C Engine SDK documentation for more
20 information
21
22 Updated 3/16/00 - DDW
23 Added ServerListRemoveServer (to remove a server from the serverlist)
24 Updated ServerListAuxUpdate to update the existing server if its already in the list
25 instead of adding a duplicate
26 Note that these functions change the indexes of servers in the list. You should never
27 rely on the indexes staying constant (they change if you use the sort functions too).
28
29 Updated 3/18/00 - DDW
30 Added Dreamcast CE support (needs to recreate sockets for each query)
31
32 Updated 4/17/00 - DDW
33 Added compressed server lists and advanced filtering
34
35 Updated 5/16/00 - DDW
36 Do a select() in ServerListReadList to keep from blocking if the list is slow
37
38 Updated 5/25/00 - DDW
39 Extensive changes to minimize memory usage and increse flexibility
40 -Server IPs are now stored internally as unsigned longs
41 -Server key names are stored in a single shared list to minimize memory usage
42 -Hashtable and DArray allocations optimized
43 -You can now specify the query type using ServerListUpdate2 and ServerListAuxUpdate
44 -ServerListAuxUpdate is now the official way to do multi-pass updates and manual updates
45 Updated 6/13/99 - DDW
46 More memory optimizations (keys/values share same list)
47 Fixed alignment compiler problem for MWERKS on Dreamcast
48 Remove server list select on ACCESS stack (doesn't seem to work)
49******/
50//todo: max results and ordering
51
52#ifndef _GOACENG_H
53#define _GOACENG_H
54
55#ifdef __cplusplus
56extern "C" {
57#endif
58
59
60#define ENGINE_VERSION "3.0"
61#define SERVER_TIMEOUT 3000
62/* GServerList and GServer are the abstracted serverlist and server data types.
63All access to their internal data structures is done via the functions below */
64typedef struct GServerListImplementation *GServerList;
65typedef struct GServerImplementation *GServer;
66
67/* A simple error type that we can use for return values to certain functions */
68typedef int GError; //we will define some error return values
69
70typedef int gbool; //a simple boolean type
71
72/* Various Server List States
73idle - no processing or querying underway, ready to being updates
74listreq - a server list request has been or is being sent
75listxfer - we are transfering the server list
76lanlist - we are waiting for replies from servers on the LAN
77querying - the servers on the list are being queried
78connecting (added in OPM) - socket is currently connecting to the master server
79*/
80typedef enum {sl_idle, sl_listxfer, sl_lanlist, sl_querying} GServerListState;
81
82/* Comparision types for the ServerListSort function
83int - assume the values are int and do an integer compare
84float - assume the values are float and do a flot compare
85strcase - assume the values are strings and do a case sensitive compare
86stricase - assume the values are strings and do a case insensitive compare */
87typedef enum {cm_int, cm_float, cm_strcase, cm_stricase} GCompareMode;
88
89
90typedef enum {qt_basic, qt_info, qt_rules, qt_players, qt_info_rules, qt_status, qt_grouprooms, qt_masterinfo} GQueryType;
91
92/* Messages that are passed to the ListCallBackFn */
93#define LIST_STATECHANGED 1 // ServerListState changed, no parameters
94#define LIST_PROGRESS 2 // New Server updated, param1 = GServer (server updated), param2 = percent done
95
96//Single callback function into the client app for status / progress messages
97typedef void (*ListCallBackFn)(GServerList serverlist, int msg, void *instance, void *param1, void *param2);
98
99// Callback function used for enumerating the keys/values for a server
100typedef void (*KeyEnumFn)(char *key, char *value, void *instance);
101
102
103/* Callback parameter types (e.g. window handle, thread window, event, function etc) */
104#define GCALLBACK_FUNCTION 1 //only currently supported callback type
105
106#define GE_NOERROR 0
107#define GE_NOSOCKET 1
108#define GE_NODNS 2
109#define GE_NOCONNECT 3
110#define GE_BUSY 4
111#define GE_DATAERROR 5
112
113/*********
114Server List Functions
115**********/
116
117/* ServerListNew
118----------------
119Creates and returns a new (empty) GServerList.
120gamename - game to ask the master for servers
121enginename - the engine name that matches your seckey
122seckey - secret key used for talking to the master
123maxconcupdates - max number of concurent updates (10-15 for modem users, 20-30 for high-bandwidth)
124CallBackFn - The function or handle used for progress updates
125CallBackFnType - The type of the CallBackFn parameter (from the #define list above)
126instance - user-defined instance data (e.g. structure or object pointer) */
127GServerList ServerListNew(const char *gamename, const char *enginename, const char *seckey, int maxconcupdates, void *CallBackFn, int CallBackFnType, void *instance);
128
129/* ServerListFree
130-----------------
131Free a GServerList and all internal sturctures and servers */
132void ServerListFree(GServerList serverlist);
133
134/* ServerListUpdate
135-------------------
136Start updating a GServerList from the master server.
137Can only be called when the list is in the sl_idle state, will return an error otherwise.
138The server list will be retrieved from the master, then each server in the list will be
139added and updated.
140If async = false, the function will not return until the entire list has been processed, or
141ServerListHalt has been called (from another thread or from the progress callback)
142If async = true, the function will return immediately, but you must call ServerListThink
143every ~10ms for list processing and querying to occur. */
144GError ServerListUpdate(GServerList serverlist, gbool async);
145
146
147/* ServerListUpdate2
148-------------------------
149Identical to ServerListUpdate, except that the server list is filtered
150on the server side by the filter, and you can specify the type of query to perform.
151If you want to specify the type of query, but no filter, simply pass NULL for filter.
152Filter is a SQL-style boolean statement such as:
153"gametype='ctf'"
154"numplayers > 1 and numplayers < 8"
155"gamestate='openplaying'"
156The filter can be arbitrarily complex and supports all standard SQL
157groupings and boolean operations. The following fields are available
158for filtering:
159hostport
160gamever
161location
162hostname
163mapname
164gametype
165gamemode
166numplayers
167maxplayers*/
168GError ServerListUpdate2(GServerList serverlist, gbool async, char *filter, GQueryType querytype);
169
170
171
172/* ServerListLANUpdate
173-------------------
174Search for servers on the local LAN and start updating them. This will search over a
175range of ports for any servers within broadcast range.
176Can only be called when the list is in the sl_idle state, will return an error otherwise.
177A query will be sent out on each port between start and end (inclusive) on intervals of delta
178(e.g. 10,20,2 would search 10,12,14,16,18,20)
179If async = false, the function will not return until the entire list has been processed, or
180ServerListHalt has been called (from another thread or from the progress callback)
181If async = true, the function will return immediately, but you must call ServerListThink
182every ~10ms for list processing and querying to occur. */ //TODO: add filter
183GError ServerListLANUpdate(GServerList serverlist, gbool async, int startsearchport, int endsearchport, int searchdelta);
184
185/* ServerListAuxUpdate
186-------------------
187Adds an "auxilliary" server -- this is a way to either update a server manually or
188get additional/updated information from a server already in the list.
189If there is an update currently in progress (not sl_idle), the aux server will
190be processed along with the current batch. If the state is idle, this function behaves
191like ServerListUpdate() and starts the engine.
192If async = false, the function will not return until the server has been processed, or
193ServerListHalt has been called (from another thread or from the progress callback)
194If async = true, the function will return immediately, but you must call ServerListThink
195every ~10ms for list processing and querying to occur. Note that async has no effect
196if an update is in progress. */
197GError ServerListAuxUpdate(GServerList serverlist, const char *ip, int port, gbool async, GQueryType querytype);
198
199/* ServerListRemoveServer
200-------------------------
201Removes a single server from the list. Frees the memory associated with the GServer.
202Do not reference the GServer object after calling this function. Note that this changes
203the indexes of the servers in the list. You should never store the indexes of the servers
204in the list, just their GServer objects */
205void ServerListRemoveServer(GServerList serverlist, char *ip, int port);
206
207/* ServerListThink
208------------------
209For use with Async Updates. This needs to be called every ~10ms for list processing and
210updating to occur during async server list updates */
211GError ServerListThink(GServerList serverlist);
212
213/* ServerListHalt
214-----------------
215Halts the current updates batch */
216GError ServerListHalt(GServerList serverlist);
217
218/* ServerListClear
219------------------
220Clear and free all of the servers from the server list.
221List must be in the sl_idle state */
222GError ServerListClear(GServerList serverlist);
223
224/* ServerListState
225------------------
226Returns the current state of the server list */
227GServerListState ServerListState(GServerList serverlist);
228
229/* ServerListErrorDesc
230----------------------
231Returns a static string description of the specified error */
232char *ServerListErrorDesc(GServerList serverlist, GError error);
233
234/* ServerListGetServer
235----------------------
236Returns the server at the specified index, or NULL if the index is out of bounds */
237GServer ServerListGetServer(GServerList serverlist, int index);
238
239/* ServerListCount
240------------------
241Returns the number of servers on the specified list. Indexing is 0 based, so
242the actual server indexes are 0 <= valid index < Count */
243int ServerListCount(GServerList serverlist);
244
245/* ServerListSort
246-----------------
247Sort the server list in either ascending or descending order using the
248specified comparemode.
249sortkey can be a normal server key, or "ping" or "hostaddr" */
250void ServerListSort(GServerList serverlist, gbool ascending, char *sortkey, GCompareMode comparemode);
251
252
253/**************
254ServerFunctions
255***************/
256
257/* ServerGetPing
258----------------
259Returns the ping for the specified server.
260A ping of 9999 indicates that the server has not been queried or did not respond */
261int ServerGetPing(GServer server);
262
263/* ServerGetAddress
264-------------------
265Returns the string, dotted IP address for the specified server */
266char *ServerGetAddress(GServer server);
267
268/* ServerGetInetAddress
269-------------------
270Returns the network-ordered IP address for the specified server */
271unsigned int ServerGetInetAddress(GServer server);
272
273
274/* ServerGetPort
275----------------
276Returns the "query" port for the specified server. If the game uses a seperate
277"game" port, it can be retrieved via: ServerGetIntValue(server,"hostport",0) */
278int ServerGetQueryPort(GServer server);
279
280/* ServerGet[]Value
281------------------
282Returns the value for the specified key. If the key does not exist for the
283given server, the default value is returned */
284char *ServerGetStringValue(GServer server, char *key, char *sdefault);
285int ServerGetIntValue(GServer server, char *key, int idefault);
286double ServerGetFloatValue(GServer server, char *key, double fdefault);
287
288
289/* ServerGetPlayer[]Value
290------------------
291Returns the value for the specified key on the specified player. If the key does not exist for the
292given server, the default value is returned */
293char *ServerGetPlayerStringValue(GServer server, int playernum, char *key, char *sdefault);
294int ServerGetPlayerIntValue(GServer server, int playernum, char *key, int idefault);
295double ServerGetPlayerFloatValue(GServer server, int playernum, char *key, double fdefault);
296
297/* ServerEnumKeys
298-----------------
299Enumerates the keys/values for a given server by calling KeyEnumFn with each
300key/value. The user-defined instance data will be passed to the KeyFn callback */
301void ServerEnumKeys(GServer server, KeyEnumFn KeyFn, void *instance);
302
303#ifdef __cplusplus
304}
305#endif
306
307#endif //_GOACENG_H
Definition gserver.h:36
Definition gserverlist.c:115