Skip to content

Commit 81609c0

Browse files
committed
Restructured the product info struct.
1 parent 10a4c7d commit 81609c0

File tree

9 files changed

+267
-206
lines changed

9 files changed

+267
-206
lines changed

Core/GameEngine/Include/GameNetwork/GameInfo.h

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,18 @@ class GameSlot
5959
public:
6060
struct ProductInfo
6161
{
62+
enum CPP_11(: UnsignedInt)
63+
{
64+
COMMUNITY_PATCH = 1 << 0
65+
};
66+
67+
UnsignedInt flags;
6268
UnsignedInt exeCRC;
6369
UnsignedInt iniCRC;
64-
UnsignedInt productVersion;
65-
AsciiString gitShortHash;
66-
UnicodeString productName;
70+
UnicodeString productTitle;
71+
UnicodeString productVersion;
72+
UnicodeString productAuthor;
73+
UnicodeString gitShortHash;
6774
};
6875

6976
GameSlot();

Core/GameEngine/Include/GameNetwork/LANAPI.h

Lines changed: 154 additions & 154 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,155 @@ class LANAPIInterface : public SubsystemInterface
140140
};
141141

142142

143+
/**
144+
* LAN message class
145+
*/
146+
#pragma pack(push, 1)
147+
struct LANMessage
148+
{
149+
enum Type ///< What kind of message are we?
150+
{
151+
// Locating everybody
152+
MSG_REQUEST_LOCATIONS, ///< Hey, where is everybody?
153+
MSG_GAME_ANNOUNCE, ///< Here I am, and here's my game info!
154+
MSG_LOBBY_ANNOUNCE, ///< Hey, I'm in the lobby!
155+
156+
// Joining games
157+
MSG_REQUEST_JOIN, ///< Let me in! Let me in!
158+
MSG_JOIN_ACCEPT, ///< Okay, you can join.
159+
MSG_JOIN_DENY, ///< Go away! We don't want any!
160+
161+
// Leaving games
162+
MSG_REQUEST_GAME_LEAVE, ///< I want to leave the game
163+
MSG_REQUEST_LOBBY_LEAVE,///< I'm leaving the lobby
164+
165+
// Game options, chat, etc
166+
MSG_SET_ACCEPT, ///< I'm cool with everything as is.
167+
MSG_MAP_AVAILABILITY, ///< I do (not) have the map.
168+
MSG_CHAT, ///< Just spouting my mouth off.
169+
MSG_GAME_START, ///< Hold on; we're starting!
170+
MSG_GAME_START_TIMER, ///< The game will start in N seconds
171+
MSG_GAME_OPTIONS, ///< Here's some info about the game.
172+
MSG_INACTIVE, ///< I've alt-tabbed out. Unaccept me cause I'm a poo-flinging monkey.
173+
174+
MSG_REQUEST_GAME_INFO, ///< For direct connect, get the game info from a specific IP Address
175+
176+
// Community Product
177+
MSG_GAME_REQUEST_PRODUCT_INFO = 1000,
178+
MSG_GAME_RESPONSE_PRODUCT_INFO,
179+
MSG_LOBBY_REQUEST_PRODUCT_INFO,
180+
MSG_LOBBY_RESPONSE_PRODUCT_INFO,
181+
MSG_MATCH_REQUEST_PRODUCT_INFO,
182+
MSG_MATCH_RESPONSE_PRODUCT_INFO,
183+
} messageType;
184+
185+
WideChar name[g_lanPlayerNameLength+1]; ///< My name, for convenience
186+
char userName[g_lanLoginNameLength+1]; ///< login name, for convenience
187+
char hostName[g_lanHostNameLength+1]; ///< machine name, for convenience
188+
189+
// No additional data is required for REQUEST_LOCATIONS, LOBBY_ANNOUNCE,
190+
// REQUEST_LOBBY_LEAVE, GAME_START.
191+
union
192+
{
193+
// StartTimer is sent with GAME_START_TIMER
194+
struct
195+
{
196+
Int seconds;
197+
} StartTimer;
198+
199+
// GameJoined is sent with REQUEST_GAME_LEAVE
200+
struct
201+
{
202+
WideChar gameName[g_lanGameNameLength+1];
203+
} GameToLeave;
204+
205+
// GameInfo if sent with GAME_ANNOUNCE
206+
struct
207+
{
208+
WideChar gameName[g_lanGameNameLength+1];
209+
Bool inProgress;
210+
char options[m_lanMaxOptionsLength+1];
211+
Bool isDirectConnect;
212+
} GameInfo;
213+
214+
// PlayerInfo is sent with REQUEST_GAME_INFO for direct connect games.
215+
struct
216+
{
217+
UnsignedInt ip;
218+
WideChar playerName[g_lanPlayerNameLength+1];
219+
} PlayerInfo;
220+
221+
// GameToJoin is sent with REQUEST_JOIN
222+
struct
223+
{
224+
UnsignedInt gameIP;
225+
UnsignedInt exeCRC;
226+
UnsignedInt iniCRC;
227+
char serial[g_maxSerialLength];
228+
} GameToJoin;
229+
230+
// GameJoined is sent with JOIN_ACCEPT
231+
struct
232+
{
233+
WideChar gameName[g_lanGameNameLength+1];
234+
UnsignedInt gameIP;
235+
UnsignedInt playerIP;
236+
Int slotPosition;
237+
} GameJoined;
238+
239+
// GameNotJoined is sent with JOIN_DENY
240+
struct
241+
{
242+
WideChar gameName[g_lanGameNameLength+1];
243+
UnsignedInt gameIP;
244+
UnsignedInt playerIP;
245+
LANAPIInterface::ReturnType reason;
246+
} GameNotJoined;
247+
248+
// Accept is sent with SET_ACCEPT
249+
struct
250+
{
251+
WideChar gameName[g_lanGameNameLength+1];
252+
Bool isAccepted;
253+
} Accept;
254+
255+
// Accept is sent with MAP_AVAILABILITY
256+
struct
257+
{
258+
WideChar gameName[g_lanGameNameLength+1];
259+
UnsignedInt mapCRC; // to make sure we're talking about the same map
260+
Bool hasMap;
261+
} MapStatus;
262+
263+
// Chat is sent with CHAT
264+
struct
265+
{
266+
WideChar gameName[g_lanGameNameLength+1];
267+
LANAPIInterface::ChatType chatType;
268+
WideChar message[g_lanMaxChatLength+1];
269+
} Chat;
270+
271+
// GameOptions is sent with GAME_OPTIONS
272+
struct
273+
{
274+
char options[m_lanMaxOptionsLength+1];
275+
} GameOptions;
276+
277+
// ProductInfo is sent with REQUEST_PRODUCT_INFO and RESPONSE_PRODUCT_INFO
278+
struct
279+
{
280+
UnsignedInt flags;
281+
UnsignedInt exeCRC;
282+
UnsignedInt iniCRC;
283+
WideChar data[201];
284+
} ProductInfo;
285+
};
286+
};
287+
#pragma pack(pop)
288+
289+
static_assert(sizeof(LANMessage) <= MAX_PACKET_SIZE);
290+
291+
143292
/**
144293
* The LANAPI class is used to instantiate a singleton which
145294
* implements the interface to all LAN broadcast communications.
@@ -260,8 +409,10 @@ class LANAPI : public LANAPIInterface
260409
void addGame(LANGameInfo *game);
261410
AsciiString createSlotString( void );
262411

263-
void setProductInfoFromLocalData(GameSlot *slot);
264-
void setProductInfoFromMessage(LANMessage *msg, GameSlot *slot);
412+
static void setProductInfoFromLocalData(GameSlot *slot);
413+
static void setProductInfoFromMessage(LANMessage *msg, GameSlot *slot);
414+
static Bool setProductInfoStrings(const UnicodeString(&input)[4], WideChar(&output)[201]);
415+
static Bool getProductInfoStrings(const WideChar(&input)[201], UnicodeString*(&output)[4]);
265416

266417
// Functions to handle incoming messages -----------------------------------
267418
void handleRequestLocations( LANMessage *msg, UnsignedInt senderIP );
@@ -281,162 +432,11 @@ class LANAPI : public LANAPIInterface
281432
void handleGameOptions( LANMessage *msg, UnsignedInt senderIP );
282433
void handleInActive( LANMessage *msg, UnsignedInt senderIP );
283434

284-
void sendProductInfoMessage(Int messageType, UnsignedInt senderIP);
435+
void sendProductInfoMessage(LANMessage::Type messageType, UnsignedInt senderIP);
285436
void handleGameProductInfoRequest(LANMessage *msg, UnsignedInt senderIP);
286437
void handleGameProductInfoResponse(LANMessage *msg, UnsignedInt senderIP);
287438
void handleLobbyProductInfoRequest(LANMessage *msg, UnsignedInt senderIP);
288439
void handleLobbyProductInfoResponse(LANMessage *msg, UnsignedInt senderIP);
289440
void handleMatchProductInfoRequest(LANMessage *msg, UnsignedInt senderIP);
290441
void handleMatchProductInfoResponse(LANMessage *msg, UnsignedInt senderIP);
291442
};
292-
293-
294-
295-
/**
296-
* LAN message class
297-
*/
298-
#pragma pack(push, 1)
299-
struct LANMessage
300-
{
301-
enum Type ///< What kind of message are we?
302-
{
303-
// Locating everybody
304-
MSG_REQUEST_LOCATIONS, ///< Hey, where is everybody?
305-
MSG_GAME_ANNOUNCE, ///< Here I am, and here's my game info!
306-
MSG_LOBBY_ANNOUNCE, ///< Hey, I'm in the lobby!
307-
308-
// Joining games
309-
MSG_REQUEST_JOIN, ///< Let me in! Let me in!
310-
MSG_JOIN_ACCEPT, ///< Okay, you can join.
311-
MSG_JOIN_DENY, ///< Go away! We don't want any!
312-
313-
// Leaving games
314-
MSG_REQUEST_GAME_LEAVE, ///< I want to leave the game
315-
MSG_REQUEST_LOBBY_LEAVE,///< I'm leaving the lobby
316-
317-
// Game options, chat, etc
318-
MSG_SET_ACCEPT, ///< I'm cool with everything as is.
319-
MSG_MAP_AVAILABILITY, ///< I do (not) have the map.
320-
MSG_CHAT, ///< Just spouting my mouth off.
321-
MSG_GAME_START, ///< Hold on; we're starting!
322-
MSG_GAME_START_TIMER, ///< The game will start in N seconds
323-
MSG_GAME_OPTIONS, ///< Here's some info about the game.
324-
MSG_INACTIVE, ///< I've alt-tabbed out. Unaccept me cause I'm a poo-flinging monkey.
325-
326-
MSG_REQUEST_GAME_INFO, ///< For direct connect, get the game info from a specific IP Address
327-
328-
// Community Product
329-
MSG_GAME_REQUEST_PRODUCT_INFO = 1000,
330-
MSG_GAME_RESPONSE_PRODUCT_INFO,
331-
MSG_LOBBY_REQUEST_PRODUCT_INFO,
332-
MSG_LOBBY_RESPONSE_PRODUCT_INFO,
333-
MSG_MATCH_REQUEST_PRODUCT_INFO,
334-
MSG_MATCH_RESPONSE_PRODUCT_INFO,
335-
} messageType;
336-
337-
WideChar name[g_lanPlayerNameLength+1]; ///< My name, for convenience
338-
char userName[g_lanLoginNameLength+1]; ///< login name, for convenience
339-
char hostName[g_lanHostNameLength+1]; ///< machine name, for convenience
340-
341-
// No additional data is required for REQUEST_LOCATIONS, LOBBY_ANNOUNCE,
342-
// REQUEST_LOBBY_LEAVE, GAME_START.
343-
union
344-
{
345-
// StartTimer is sent with GAME_START_TIMER
346-
struct
347-
{
348-
Int seconds;
349-
} StartTimer;
350-
351-
// GameJoined is sent with REQUEST_GAME_LEAVE
352-
struct
353-
{
354-
WideChar gameName[g_lanGameNameLength+1];
355-
} GameToLeave;
356-
357-
// GameInfo if sent with GAME_ANNOUNCE
358-
struct
359-
{
360-
WideChar gameName[g_lanGameNameLength+1];
361-
Bool inProgress;
362-
char options[m_lanMaxOptionsLength+1];
363-
Bool isDirectConnect;
364-
} GameInfo;
365-
366-
// PlayerInfo is sent with REQUEST_GAME_INFO for direct connect games.
367-
struct
368-
{
369-
UnsignedInt ip;
370-
WideChar playerName[g_lanPlayerNameLength+1];
371-
} PlayerInfo;
372-
373-
// GameToJoin is sent with REQUEST_JOIN
374-
struct
375-
{
376-
UnsignedInt gameIP;
377-
UnsignedInt exeCRC;
378-
UnsignedInt iniCRC;
379-
char serial[g_maxSerialLength];
380-
} GameToJoin;
381-
382-
// GameJoined is sent with JOIN_ACCEPT
383-
struct
384-
{
385-
WideChar gameName[g_lanGameNameLength+1];
386-
UnsignedInt gameIP;
387-
UnsignedInt playerIP;
388-
Int slotPosition;
389-
} GameJoined;
390-
391-
// GameNotJoined is sent with JOIN_DENY
392-
struct
393-
{
394-
WideChar gameName[g_lanGameNameLength+1];
395-
UnsignedInt gameIP;
396-
UnsignedInt playerIP;
397-
LANAPIInterface::ReturnType reason;
398-
} GameNotJoined;
399-
400-
// Accept is sent with SET_ACCEPT
401-
struct
402-
{
403-
WideChar gameName[g_lanGameNameLength+1];
404-
Bool isAccepted;
405-
} Accept;
406-
407-
// Accept is sent with MAP_AVAILABILITY
408-
struct
409-
{
410-
WideChar gameName[g_lanGameNameLength+1];
411-
UnsignedInt mapCRC; // to make sure we're talking about the same map
412-
Bool hasMap;
413-
} MapStatus;
414-
415-
// Chat is sent with CHAT
416-
struct
417-
{
418-
WideChar gameName[g_lanGameNameLength+1];
419-
LANAPIInterface::ChatType chatType;
420-
WideChar message[g_lanMaxChatLength+1];
421-
} Chat;
422-
423-
// GameOptions is sent with GAME_OPTIONS
424-
struct
425-
{
426-
char options[m_lanMaxOptionsLength+1];
427-
} GameOptions;
428-
429-
// ProductInfo is sent with REQUEST_PRODUCT_INFO and RESPONSE_PRODUCT_INFO
430-
struct
431-
{
432-
UnsignedInt exeCRC;
433-
UnsignedInt iniCRC;
434-
UnsignedInt productVersion;
435-
Char gitShortHash[42];
436-
WideChar productName[129];
437-
} ProductInfo;
438-
};
439-
};
440-
#pragma pack(pop)
441-
442-
static_assert(sizeof(LANMessage) <= MAX_PACKET_SIZE);

Core/GameEngine/Include/GameNetwork/LANAPICallbacks.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,10 @@ extern const Color chatSystemColor;
6868
extern const Color chatSystemColor;
6969
extern const Color acceptTrueColor;
7070
extern const Color acceptFalseColor;
71-
extern const Color gameColorPatchVersion;
72-
extern const Color gameInProgressColorPatchVersion;
73-
extern const Color playerColorPatchVersion;
74-
extern const Color playerGrayedColorPatchVersion;
71+
extern const Color gameColorCommunityPatch;
72+
extern const Color gameInProgressColorCommunityPatch;
73+
extern const Color playerColorCommunityPatch;
74+
extern const Color playerGrayedColorCommunityPatch;
7575

7676

7777
void lanUpdateSlotList( void );

Core/GameEngine/Include/GameNetwork/LANPlayer.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
class LANPlayer
3636
{
3737
public:
38-
LANPlayer() { m_name = m_login = m_host = L""; m_lastHeard = 0; m_next = NULL; m_IP = 0; m_productVersion = 0; }
38+
LANPlayer() { m_name = m_login = m_host = L""; m_lastHeard = 0; m_next = NULL; m_IP = 0; m_productInfoFlags = 0; }
3939

4040
// Access functions
4141
inline UnicodeString getName( void ) { return m_name; }
@@ -52,8 +52,8 @@ class LANPlayer
5252
inline void setNext( LANPlayer *next ) { m_next = next; }
5353
inline UnsignedInt getIP( void ) { return m_IP; }
5454
inline void setIP( UnsignedInt IP ) { m_IP = IP; }
55-
inline void setProductVersion(UnsignedInt productVersion) { m_productVersion = productVersion; }
56-
inline UnsignedInt getProductVersion() const { return m_productVersion; }
55+
inline void setProductInfoFlags(UnsignedInt productInfoFlags) { m_productInfoFlags = productInfoFlags; }
56+
inline UnsignedInt getProductInfoFlags() const { return m_productInfoFlags; }
5757

5858
protected:
5959
UnicodeString m_name; ///< Player name
@@ -62,5 +62,5 @@ class LANPlayer
6262
UnsignedInt m_lastHeard; ///< The last time we heard from this player (for timeout purposes)
6363
LANPlayer *m_next; ///< Linked list pointer
6464
UnsignedInt m_IP; ///< Player's IP
65-
UnsignedInt m_productVersion; ///< Community made product version
65+
UnsignedInt m_productInfoFlags; ///< Community made product information flags
6666
};

0 commit comments

Comments
 (0)