OpenMoHAA 0.82.0
Loading...
Searching...
No Matches
peerAscii.h
1 /*
2GameSpy Peer SDK
3Dan "Mr. Pants" Schoenblum
4dan@gamespy.com
5
6Copyright 1999-2007 GameSpy Industries, Inc
7
8devsupport@gamespy.com
9*/
10
11#ifndef _PEERASCII_H_
12#define _PEERASCII_H_
13
14// PROTOTYPES OF ASCII FUNCTIONS
15// The only purpose of this file is to silence the CodeWarrior
16// "function not prototyped" warnings when using GSI_UNICODE mode
17
18#ifdef __cplusplus
19extern "C" {
20#endif
21
22
23/************
24** GENERAL **
25************/
26// This connects a peer object to a chat server.
27// Call peerDisconnect() to close the connection.
28// A title must be set with peerSetTitle before connecting.
30void peerConnectA
31(
32 PEER peer, // The peer object.
33 const char * nick, // The nick to connect with.
34 int profileID, // The profileID, or 0 if no profileID.
35 peerNickErrorCallback nickErrorCallback, // Called if nick error.
36 peerConnectCallback connectCallback, // Called on complete.
37 void * param, // User-data.
38 PEERBool blocking // If PEERTrue, don't return until finished.
39);
40
41// Same as peerConnect, but also authenticates using a uniquenick
42// and password or an email, profilenick, and password.
44void peerConnectLoginA
45(
46 PEER peer, // The peer object.
47 int namespaceID, // The namespace in which to login.
48 const char * email, // The email to login with.
49 const char * profilenick, // The profile to login with.
50 const char * uniquenick, // The uniquenick to login with.
51 const char * password, // The password for the login account.
52 peerNickErrorCallback nickErrorCallback, // Called if nick error.
53 peerConnectCallback connectCallback, // Called on complete.
54 void * param, // User-data.
55 PEERBool blocking // If PEERTrue, don't return until finished.
56);
57
58// Same as peerConnect, but also authenticates using an authtoken
59// and partnerchallenge from a partner account system.
61void peerConnectPreAuthA
62(
63 PEER peer, // The peer object.
64 const char * authtoken, // The authtoken for this login.
65 const char * partnerchallenge, // The partner challenge for this login.
66 peerNickErrorCallback nickErrorCallback, // Called if nick error.
67 peerConnectCallback connectCallback, // Called on complete.
68 void * param, // User-data.
69 PEERBool blocking // If PEERTrue, don't return until finished.
70);
71
72// If peerNickErrorCallback is called, call this to
73// try and continue the connection with a new nickname.
74// If there is an error with this nick, the
75// peerNickErrCallback will be called again.
77void peerRetryWithNickA
78(
79 PEER peer,
80 const char * nick
81);
82
83// Register a uniquenick.
84// Should be called in response to the peerNickErrorCallback being called
85// with a type of PEER_UNIQUENICK_EXPIRED or PEER_NO_UNIQUENICK.
86// If the uniquenick cannot be registered, the peerNickErrorCallback will
87// be called again with a type of PEER_IN_USE or PEER_INVALID.
89void peerRegisterUniqueNickA
90(
91 PEER peer,
92 int namespaceID,
93 const char * uniquenick,
94 const char * cdkey
95);
96
97// Sets the current title.
98// A title must be set before connecting.
99// Returns PEERFalse if an error, or PEERTrue if success.
100// For most games the title/qrSecretKey and
101// sbName/sbSecretKey pairs will be the same.
103PEERBool peerSetTitleA
104(
105 PEER peer, // The peer object.
106 const char * title, // The title to make current (ie., ut, gmtest).
107 const char * qrSecretKey, // The queryreporting secret key.
108 const char * sbName, // The serverbrowsing name.
109 const char * sbSecretKey, // The serverbrowsing secret key.
110 int sbGameVersion, // The version of the game doing the browsing.
111 int sbMaxUpdates, // The maximum number of concurent updates (10-15 for modem users, 20-30 for high-bandwidth).
112 PEERBool natNegotiate, // PEERTrue if the title supports GameSpy's NAT-negotiation technology (or another similar technology).
113 PEERBool pingRooms[NumRooms], // To do pings int a room, set it to PEERTrue.
114 PEERBool crossPingRooms[NumRooms] // To do cross-pings in a room, set it to PEERTrue.
115);
116
117// Gets the currently set title.
118// Returns NULL if no title is set.
120const char * peerGetTitleA(PEER peer);
121
122// Get the local user's nickname.
124const char * peerGetNickA(PEER peer);
125
126// Replaces any invalid characters in nick with underscores.
128void peerFixNickA
129(
130 char * newNick,
131 const char * oldNick
132);
133
134// Removes the namespace extension from a chat unique nick.
135// Returns the nick if it ended with the extension.
136// Otherwise returns NULL.
138const char * peerTranslateNickA
139(
140 char * nick, // The nick to translate
141 const char * extension // The extension to be removed.
142);
143
144// Changes the user's nickname.
146void peerChangeNickA
147(
148 PEER peer, // The peer object.
149 const char * newNick, // The nickname to which to change.
150 peerChangeNickCallback callback, // Called when finished.
151 void * param, // Passed to the callback.
152 PEERBool blocking // If PEERTrue, don't return until finished.
153);
154
155// Sets the away mode.
156// If an empty string or NULL, away mode is off.
157// If a valid string, away mode is on.
159void peerSetAwayModeA
160(
161 PEER peer, // The peer object.
162 const char * reason // The away reason. If NULL or "", not away.
163);
164
165// When using peerStartReportingWithSocket or peerCreateStagingRoomWithSocket,
166// any qureries received on the sockets need to be passed to the SDK. Pass
167// the data using this function.
169void peerParseQueryA
170(
171 PEER peer, // The peer object.
172 char * query, // String of query data.
173 int len, // The length of the string, not including the NUL.
174 struct sockaddr * sender // The address the query was received from.
175);
176
177// Sends a CD Key to the chat server for authentication.
178// The callback gets called when the chat server responds.
179// This call is required by some games to enter chat rooms.
180// It must be called after connecting to the chat server, but
181// before entering a room.
183void peerAuthenticateCDKeyA
184(
185 PEER peer, // The peer object.
186 const char * cdkey, // The CD key to authenticate.
187 peerAuthenticateCDKeyCallback callback, // Called when finished.
188 void * param, // Passed to the callback.
189 PEERBool blocking // If PEERTrue, don't return until finished.
190);
191
192/**********
193** ROOMS **
194**********/
195// Joins the currently selected title's title room.
197void peerJoinTitleRoomA
198(
199 PEER peer, // The peer object.
200 const char password[PEER_PASSWORD_LEN], // An optional password, normally NULL.
201 peerJoinRoomCallback callback, // Called when finished.
202 void * param, // Passed to the callback.
203 PEERBool blocking // If PEERTrue, don't return until finished.
204);
205
206// Joins a staging room.
207// server is one of the server objects passed to peerListingGamesCallback().
208// This call will only work if staging==PEERTrue for the server.
209// PANTS|09.11.00 - The password is only needed for passworded rooms.
210// PANTS|03.15.01 - No longer requires you to be actively listing games.
212void peerJoinStagingRoomA
213(
214 PEER peer, // The peer object.
215 SBServer server, // The server passed into peerlistingGamesCallback().
216 const char password[PEER_PASSWORD_LEN], // The password of the room being joined. Can be NULL or "".
217 peerJoinRoomCallback callback, // Called when finished.
218 void * param, // Passed to the callback.
219 PEERBool blocking // If PEERTrue, don't return until finished.
220);
221
222// Joins a staging room by its channel name.
223// Same as peerJoinStagingRoom, except it takes the staging room's
224// channel name instead of an SBServer object. Also, when the
225// peerGameStartedCallback is called, the server paramter passed to
226// it will be NULL.
228void peerJoinStagingRoomByChannelA
229(
230 PEER peer, // The peer object.
231 const char * channel, // The channel to join.
232 const char password[PEER_PASSWORD_LEN], // The password of the room being joined. Can be NULL or "".
233 peerJoinRoomCallback callback, // Called when finished.
234 void * param, // Passed to the callback.
235 PEERBool blocking // If PEERTrue, don't return until finished.
236);
237
238// Creates a new staging room, with the local player hosting.
239// PANTS|09.11.00 - If the password parameter is not NULL
240// or "", this will create a passworded room. The same
241// case-sensitive password needs to be passed into
242// peerJoinStagingRoom() for other player's to join the room.
243// PANTS|09.11.00 - The staging room will be reported as part
244// of whatever group room the local player was in when the
245// room was created. Leaving the group room will not affect
246// what group the staging room is reported as part of.
248void peerCreateStagingRoomA
249(
250 PEER peer, // The peer object.
251 const char * name, // The name of the room.
252 int maxPlayers, // The max number of players allowed in the room.
253 const char password[PEER_PASSWORD_LEN], // An optional password for the staging room
254 peerJoinRoomCallback callback, // Called when finished.
255 void * param, // Passed to the callback.
256 PEERBool blocking // If PEERTrue, don't return until finished.
257);
258
259// Same as peerCreateStagingRoom, but uses the provided socket for
260// sending heartbeats and query replies. This allows the game
261// to share a socket with the peer SDK, which can make hosting
262// games behind a NAT proxy possible.
264void peerCreateStagingRoomWithSocketA
265(
266 PEER peer, // The peer object.
267 const char * name, // The name of the room.
268 int maxPlayers, // The max number of players allowed in the room.
269 const char password[PEER_PASSWORD_LEN], // An optional password for the staging room
270 SOCKET socket, // The socket to be used for reporting.
271 unsigned short port, // The local port to which the socket is bound.
272 peerJoinRoomCallback callback, // Called when finished.
273 void * param, // Passed to the callback.
274 PEERBool blocking // If PEERTrue, don't return until finished.
275);
276
277// Leave a room.
278// PANTS|09.11.00 - You can now leave a group room
279// without being forcibly removed from a staging room.
281void peerLeaveRoomA
282(
283 PEER peer, // The peer object.
284 RoomType roomType, // The room you want to leave (TitleRoom, GroupRoom, or StagingRoom).
285 const char * reason // The reason the player is leaving (can be NULL). PANTS|03.13.01
286);
287
288// List all the groups rooms for the currently set title.
289// The fields parameter allows you to request extra info
290// on each group room.
292void peerListGroupRoomsA
293(
294 PEER peer, // The peer object.
295 const char * fields, // A backslash delimited list of fields.
296 peerListGroupRoomsCallback callback, // Called for each group room.
297 void * param, // Passed to the callback.
298 PEERBool blocking // If PEERTrue, don't return until finished.
299);
300
301// Start listing the currently running games and staging rooms.
302// This is used to maintain a list that can presented to the user,
303// so they can pick a game (or staging room) to join.
304// Games and staging rooms are filtered based on what group the local
305// user is in. If the local user isn't in a group, then only games
306// and staging rooms that aren't part of any group are listed.
307// The fields determine which info to request from the server. These
308// must be registered QR2 keys (see qr2regkeys.h). HOSTNAME_KEY and
309// GAMEMODE_KEY are automatically requested by Peer, so do not need
310// to included.
312void peerStartListingGamesA
313(
314 PEER peer, // The peer object.
315 const unsigned char * fields, // An array of registered QR2 keys to request from servers.
316 int numFields, // The number of keys in the fields array.
317 const char * filter, // A SQL-like rule filter.
318 peerListingGamesCallback callback, // Called when finished.
319 void * param // Passed to the callback.
320);
321
322// Send a message to a room.
324void peerMessageRoomA
325(
326 PEER peer, // The peer object.
327 RoomType roomType, // The room to send the message to.
328 const char * message, // The message.
329 MessageType messageType // The type of message.
330);
331
332// Send a UTM to a room.
334void peerUTMRoomA
335(
336 PEER peer, // The peer object.
337 RoomType roomType, // The room to send the UTM to.
338 const char * command, // The command.
339 const char * parameters, // The UTM's parameters.
340 PEERBool authenticate // If true, the server will authenticate this UTM (should normally be false).
341);
342
343// Set a password in a room you're hosting.
344// The only roomType currently supported is StagingRoom.
345// This will only work if the player is hosting the room.
346// If password is NULL or "", the password will be cleared.
348void peerSetPasswordA
349(
350 PEER peer, // The peer object.
351 RoomType roomType, // The room in which to set the password.
352 const char password[PEER_PASSWORD_LEN] // The password to set.
353);
354
355// Set the name of a room you're hosting.
356// The only roomType currently supported is StagingRoom.
357// PANTS|09.11.00
359void peerSetRoomNameA
360(
361 PEER peer, // The peer object.
362 RoomType roomType, // The room in which to set the name.
363 const char * name // The new name
364);
365
366// Get a room's name (the channel's title).
367// Returns NULL if not in the room.
369const char * peerGetRoomNameA
370(
371 PEER peer, // The peer object.
372 RoomType roomType // The room to get the name for.
373);
374
375// Get's the chat channel associated with the room.
376// Returns NULL if not in the room.
378const char * peerGetRoomChannelA
379(
380 PEER peer, // The peer object.
381 RoomType roomType // The room to get the channel for.
382);
383
384// Use this channel for the title room for the currently set title.
385// This function is normally not needed.
387void peerSetTitleRoomChannelA
388(
389 PEER peer, // The peer object.
390 const char * channel // The channel to use for the title room.
391);
392
393
394/************
395** PLAYERS **
396************/
397// Send a message to a player.
399void peerMessagePlayerA
400(
401 PEER peer, // The peer object.
402 const char * nick, // The nick of the player to send the message to.
403 const char * message, // The message to send.
404 MessageType messageType // The type of message.
405);
406
407// Send a UTM to a player.
409void peerUTMPlayerA
410(
411 PEER peer, // The peer object.
412 const char * nick, // The nick of the player to send the UTM to.
413 const char * command, // The command.
414 const char * parameters, // The UTM's parameters.
415 PEERBool authenticate // If true, the server will authenticate this UTM (should normally be false).
416);
417
418// Kick a player from a room.
419// Can only be called by a player with host privileges.
421void peerKickPlayerA
422(
423 PEER peer, // The peer object.
424 RoomType roomType, // The room to kick the player from.
425 const char * nick, // The nick of the player to kick.
426 const char * reason // An optional reason for kicking the player
427);
428
429// Gets a player's ping (between the local machine and the player's machine).
430// Returns PEERFalse if we don't have or can't get the player's ping.
432PEERBool peerGetPlayerPingA
433(
434 PEER peer, // The peer object.
435 const char * nick, // The player to get the ping for.
436 int * ping // The player's ping is stored here, if we have it.
437);
438
439// Gets the cross-ping between 2 players.
440// Returns PEERFalse if we don't have or can't get the player's cross-ping.
442PEERBool peerGetPlayersCrossPingA
443(
444 PEER peer, // The peer object.
445 const char * nick1, // The first player.
446 const char * nick2, // The second player.
447 int * crossPing // The cross-ping is stored here, if we have it.
448);
449
450// Peer already automatically pings all players that are in ping rooms.
451// This function does a one-time ping of a remote player in a non-ping room.
452// However pings must be enabled in at least one room for this to work,
453// otherwise Peer will not open the UDP ping socket.
454// Also, peerAlwaysGetPlayerInfo() must be enabled so that Peer has IPs for
455// players that are only in non-ping rooms.
457PEERBool peerPingPlayerA
458(
459 PEER peer, // The peer object.
460 const char * nick // The player to ping.
461);
462
463// Gets a player's info immediately.
464// Returns PEERFalse if the info is no available.
466PEERBool peerGetPlayerInfoNoWaitA
467(
468 PEER peer,
469 const char * nick,
470 unsigned int * IP,
471 int * profileID
472);
473
474// Called to get a player's IP and profile ID.
476void peerGetPlayerInfoA
477(
478 PEER peer, // The peer object.
479 const char * nick, // The player's nick.
480 peerGetPlayerInfoCallback callback, // Called when finished.
481 void * param, // Passed to callback.
482 PEERBool blocking // If PEERTrue, don't return until finished.
483);
484
485// Called to get a player's profile ID.
486// DEPRECATED - Use peerGetPlayerInfo.
488void peerGetPlayerProfileIDA
489(
490 PEER peer, // The peer object.
491 const char * nick, // The player's nick.
492 peerGetPlayerProfileIDCallback callback, // Called when finished.
493 void * param, // Passed to callback.
494 PEERBool blocking // If PEERTrue, don't return until finished.
495);
496
497// Called to get a player's IP.
498// DEPRECATED - Use peerGetPlayerInfo.
500void peerGetPlayerIPA
501(
502 PEER peer, // The peer object.
503 const char * nick, // The player's nick.
504 peerGetPlayerIPCallback callback, // Called when finished.
505 void * param, // Passed to callback.
506 PEERBool blocking // If PEERTrue, don't return until finished.
507);
508
509// Checks if a player is a host (has ops).
510// Returns PEERTrue if yes, PEERFalse if no.
512PEERBool peerIsPlayerHostA
513(
514 PEER peer, // The peer object.
515 const char * nick, // The player's nick.
516 RoomType roomType // The room to check in.
517);
518
519// Gets a player's flags in a room. Returns PEERFalse if
520// the local player or this player is not in the room.
522PEERBool peerGetPlayerFlagsA
523(
524 PEER peer,
525 const char * nick,
526 RoomType roomType,
527 int * flags
528);
529
530/*********
531** GAME **
532*********/
533// Gets a player's ready state.
535PEERBool peerGetReadyA
536(
537 PEER peer, // The peer object.
538 const char * nick, // The player's nick.
539 PEERBool * ready // The player's ready state gets stored in here.
540);
541
542// Called only by a staging room host to start the game.
543// All the other people in the staging room will have their
544// peerGameStartedCallback() called.
545// The message gets passed to everyone in the peerGameStartedCallback(), and
546// can be used to pass information such as a special port or password.
547// If (reportingOptions & PEER_STOP_REPORTING), Peer will stop game reporting,
548// so the program is responsible for any server reporting.
549// If !(reportingOptions & PEER_STOP_REPORTING), Peer will continue doing
550// game reporting, and calling the program-supplied callbacks. If
551// (reportingOptions & PEER_REPORT_INFO), all server keys will still be
552// reported. If (reportingOptions & PEER_REPORT_PLAYERS), all player keys
553// will still be reported.
555void peerStartGameA
556(
557 PEER peer, // The peer object.
558 const char * message, // A message to send to everyone.
559 int reportingOptions // Bitfield flags used to set reporting options.
560);
561
562/*********
563** KEYS **
564*********/
565// Set global keys on the local player.
567void peerSetGlobalKeysA
568(
569 PEER peer, // The peer object.
570 int num, // The number of keys to set.
571 const char ** keys, // The keys to set.
572 const char ** values // The values for the keys.
573);
574
575
576// Get a player's global keys.
578void peerGetPlayerGlobalKeysA
579(
580 PEER peer, // The peer object.
581 const char * nick, // The player to get the keys for.
582 int num, // The number of keys.
583 const char ** keys, // The keys to get.
584 peerGetGlobalKeysCallback callback, // Called with the keys.
585 void * param, // Passed to callback.
586 PEERBool blocking // If PEERTrue, don't return until finished.
587);
588
589// Get the global keys for all players in a room we're in.
591void peerGetRoomGlobalKeysA
592(
593 PEER peer, // The peer object.
594 RoomType roomType, // The room to get the keys in.
595 int num, // The number of keys.
596 const char ** keys, // The keys to get.
597 peerGetGlobalKeysCallback callback, // Called with the keys.
598 void * param, // Passed to callback.
599 PEERBool blocking // If PEERTrue, don't return until finished.
600);
601
602// Set the room keys for a player.
603// Use NULL or "" to set keys on the room itself.
605void peerSetRoomKeysA
606(
607 PEER peer, // The peer object.
608 RoomType roomType, // The room to set the keys in.
609 const char * nick, // The player to set the keys on (NULL or "" for the room).
610 int num, // The number of keys.
611 const char ** keys, // The keys to set.
612 const char ** values // The values to set.
613);
614
615// Get the room keys for either a single player of an entire room.
616// Use "*" for the player to get the keys for the entire room.
617// Use NULL or "" for the player to get keys on the room itself.
619void peerGetRoomKeysA
620(
621 PEER peer, // The peer object.
622 RoomType roomType, // The room to get the keys in.
623 const char * nick, // The player to get the keys for.
624 int num, // The number of keys.
625 const char ** keys, // The keys to get.
626 peerGetRoomKeysCallback callback, // Called with the keys.
627 void * param, // Passed to callback.
628 PEERBool blocking // If PEERTrue, don't return until finished.
629);
630
631// Set the global watch keys for a room type.
632// If addKeys is set to PEERTrue, the keys will be
633// added to the current global watch keys for this room.
634// If addKeys is PEERFalse, these will replace any existing
635// global watch keys for this room.
636// When entering a room of the given type, peer will get and
637// cache these keys for all players in the room.
639void peerSetGlobalWatchKeysA
640(
641 PEER peer, // The peer object.
642 RoomType roomType, // The type of room to set the watch keys for.
643 int num, // The number of keys.
644 const char ** keys, // The keys to watch for.
645 PEERBool addKeys // If PEERTrue, add these keys to the existing global watch keys for this room.
646);
647
648// Set the room watch keys for a room type.
649// If addKeys is set to PEERTrue, the keys will be
650// added to the current room watch keys for this room.
651// If addKeys is PEERFalse, these will replace any existing
652// room watch keys for this room.
653// When entering a room of the given type, peer will get and
654// cache these keys for all players in the room.
656void peerSetRoomWatchKeysA
657(
658 PEER peer, // The peer object.
659 RoomType roomType, // The type of room to set the watch keys for.
660 int num, // The number of keys.
661 const char ** keys, // The keys to watch for.
662 PEERBool addKeys // If PEERTrue, add these keys to the existing room watch keys for this room.
663);
664
665// Get the global watch key for a particular player.
666// If the key isn't cached locally (either because it isn't
667// a watch key or just isn't yet known), NULL will be returned.
668// If the key is empty, "" will be returned.
670const char * peerGetGlobalWatchKeyA
671(
672 PEER peer, // The peer object.
673 const char * nick, // The player to get the key for.
674 const char * key // The key to get.
675);
676
677// Get the room watch key for a particular player in a room.
678// If the key isn't cached locally (either because it isn't
679// a watch key or just isn't yet known), NULL will be returned.
680// If the key is empty, "" will be returned.
682const char * peerGetRoomWatchKeyA
683(
684 PEER peer, // The peer object.
685 RoomType roomType, // The room to get the key in.
686 const char * nick, // The player to get the key for.
687 const char * key // The key to get.
688);
689
690/**************
691** AUTOMATCH **
692**************/
693
694// Used to start a automatch attempt.
695// The filter contains any hard criteria. This is used to narrow down the list
696// of possible matches to those the user might consider.
697// The status callback will be called as the attempt progresses, and the rate
698// callback will be used to sort possible matches.
700void peerStartAutoMatchA
701(
702 PEER peer, // The peer object.
703 int maxPlayers, // The total number of players to match (including the local player).
704 const char * filter, // Hard criteria - filters out servers.
705 peerAutoMatchStatusCallback statusCallback, // Called as the attempt status changes.
706 peerAutoMatchRateCallback rateCallback, // Used to rate possible matches.
707 void * param, // User-data.
708 PEERBool blocking // If PEERTrue, don't return until finished.
709);
710
711// Same as peerStartAutoMatch, but uses the provided socket for
712// sending heartbeats and query replies. This allows the game
713// to share a socket with the peer SDK, which can make hosting
714// games behind a NAT proxy possible.
716void peerStartAutoMatchWithSocketA
717(
718 PEER peer, // The peer object.
719 int maxPlayers, // The total number of players to match (including the local player).
720 const char * filter, // Hard criteria - filters out servers.
721 SOCKET socket, // The socket to be used for reporting.
722 unsigned short port, // The local port to which the socket is bound.
723 peerAutoMatchStatusCallback statusCallback, // Called as the attempt status changes.
724 peerAutoMatchRateCallback rateCallback, // Used to rate possible matches.
725 void * param, // User-data.
726 PEERBool blocking // If PEERTrue, don't return until finished.
727);
728
729
730#ifdef __cplusplus
731}
732#endif
733
734#endif