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