OpenMoHAA 0.82.0
Loading...
Searching...
No Matches
peerMain.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 _PEERMAIN_H_
12#define _PEERMAIN_H_
13
14/*************
15** INCLUDES **
16*************/
17#include "peer.h"
18#include "../darray.h"
19#include "../hashtable.h"
20#include "../pinger/pinger.h"
21#include "../Chat/chatASCII.h"
22
23
24#ifdef __cplusplus
25extern "C" {
26#endif
27
28
29#if 0
30piConnection * connection; // This is to fool Visual Assist.
31#endif
32
33/************
34** DEFINES **
35************/
36#define PI_ROOM_MAX_LEN 257
37#define PI_NICK_MAX_LEN 64
38#define PI_NAME_MAX_LEN 512
39#define PI_TITLE_MAX_LEN 32
40#define PI_AWAY_MAX_LEN 128
41#define PI_SB_LEN 32 // from sb_internal.h
42
43#ifndef PI_CHAT_PING_TIME
44 #ifndef _NITRO
45 #define PI_CHAT_PING_TIME (5 * 60000)
46 #else
47 #define PI_CHAT_PING_TIME (20000)
48 #endif
49#endif
50
51#define PEER_CONNECTION piConnection * connection;\
52 assert(peer);\
53 connection = (piConnection *)peer;\
54 GSI_UNUSED(connection);
55
56#define ASSERT_ROOMTYPE(type) assert((type == TitleRoom) || (type == GroupRoom) || (type == StagingRoom))
57#define ASSERT_MESSAGETYPE(type) assert((type == NormalMessage) || (type == ActionMessage) || (type == NoticeMessage))
58
59#define ROOM (connection->rooms[roomType])
60#define ROOM_W (connection->rooms_W[roomType])
61#define ROOMS (connection->rooms)
62#define NAME (connection->names[roomType])
63#define NAME_W (connection->names_W[roomType])
64#define NAMES (connection->names)
65#define IN_ROOM (connection->inRoom[roomType])
66#define ENTERING_ROOM (connection->enteringRoom[roomType])
67
68#define strzcpy(dest, src, len) { strncpy(dest, src, (len)); (dest)[(len) - 1] = '\0'; }
69#define strzcat(dest, src, len) { strncat(dest, src, (len) - strlen(dest)); (dest)[(len) - 1] = '\0'; }
70
71#if defined(_PS3)
72#define PEERCBType void* // Note: ANSI function pointers should int rather than void*
73#else
74#define PEERCBType int // Note: ANSI function pointers should int rather than void*
75#endif
76
77/**********
78** TYPES **
79**********/
80typedef struct piConnection
81{
82 // Chat.
84 CHAT chat; // The chat connection.
85 char nick[PI_NICK_MAX_LEN]; // The local nick.
86 PEERBool connecting;
87 PEERBool connected;
88 peerNickErrorCallback nickErrorCallback;
89 gsi_time lastChatPing;
90
91 // Game.
93 unsigned int publicIP;
94 unsigned int privateIP;
95 int profileID;
96 char title[PI_TITLE_MAX_LEN];
97
98#ifdef GSI_UNICODE
99 unsigned short title_W[PI_TITLE_MAX_LEN];
100 unsigned short nick_W[PI_NICK_MAX_LEN];
101 unsigned short names_W[NumRooms][PI_NAME_MAX_LEN];
102 unsigned short rooms_W[NumRooms][PI_ROOM_MAX_LEN];
103#endif
104
105 // Rooms.
107 char rooms[NumRooms][PI_ROOM_MAX_LEN];
108 PEERBool enteringRoom[NumRooms];
109 PEERBool inRoom[NumRooms];
110 char names[NumRooms][PI_NAME_MAX_LEN];
111 int oldFlags[NumRooms];
112 int groupID;
113 char titleRoomChannel[PI_ROOM_MAX_LEN];
114 PEERBool stayInTitleRoom;
115
116 // Players.
118 HashTable players;
119 int numPlayers[NumRooms];
120 PEERBool alwaysRequestPlayerInfo;
121
122 // Ping.
124 PEERBool doPings;
125 int lastPingTimeMod;
126 PEERBool pingRoom[NumRooms];
127 PEERBool xpingRoom[NumRooms];
128 HashTable xpings;
129 unsigned int lastXpingSend;
130
131 // Reporting.
133 qr2_t queryReporting;
134 char qrSecretKey[64]; // i ripped the length from qr2.c
135 PEERBool natNegotiate;
136 int reportingOptions;
137 int reportingGroupID; // might be different than groupID if left group room after started reporting
138
139 // Hosting.
141 PEERBool hosting;
142 PEERBool playing;
143 int maxPlayers;
144 PEERBool passwordedRoom;
145
146 // Staging room.
148 SBServer hostServer;
149 PEERBool ready;
150
151 // SB.
153 char sbName[PI_SB_LEN];
154 char sbSecretKey[PI_SB_LEN];
155 int sbGameVersion;
156 int sbMaxUpdates;
157 PEERBool sbInitialized;
158 SBServerList gameList;
159 SBServerList groupList;
160 SBQueryEngine gameEngine;
161 peerListingGamesCallback gameListCallback;
162 void * gameListParam;
163 PEERBool initialGameList;
164 struct piOperation * listingGroupsOperation;
165
166 // ID.
168 int nextID;
169
170 // Operations.
172 DArray operationList;
173 int operationsStarted;
174 int operationsFinished;
175
176 // Callbacks.
178 PEERCallbacks callbacks;
179 DArray callbackList;
180 int callbacksQueued;
181 int callbacksCalled;
182 int callbackDepth;
183
184 // Away.
186 PEERBool away;
187 char awayReason[PI_AWAY_MAX_LEN];
188
189 // Keys.
191 HashTable globalWatchKeys[NumRooms];
192 HashTable roomWatchKeys[NumRooms];
193 HashTable globalWatchCache;
194 HashTable roomWatchCache[NumRooms];
195
196 // AutoMatch.
198 PEERAutoMatchStatus autoMatchStatus;
199 SBServerList autoMatchList;
200 SBQueryEngine autoMatchEngine;
201 PEERBool autoMatchBrowsing;
202 struct piOperation * autoMatchOperation;
203 qr2_t autoMatchReporting;
204 char * autoMatchFilter;
205 PEERBool autoMatchSBFailed;
206 PEERBool autoMatchQRFailed;
207
208 // Misc.
210 PEERBool disconnect;
211 PEERBool shutdown;
213
214void piSendChannelUTM(PEER peer, const char * channel, const char * command, const char * parameters, PEERBool authenticate);
215void piSendPlayerUTM(PEER peer, const char * nick, const char * command, const char * parameters, PEERBool authenticate);
216PEERBool piConnectTitle(PEER peer);
217void piDisconnectTitle(PEER peer);
218
219#ifdef __cplusplus
220}
221#endif
222
223#endif
Definition peer.h:476
Definition peerMain.h:81
Definition peerOperations.h:55