Skip to content

Commit e2385c5

Browse files
authored
refactor(network): Assign name to type enum in LANMessage (#1801)
1 parent 9a09bae commit e2385c5

File tree

6 files changed

+68
-68
lines changed

6 files changed

+68
-68
lines changed

Generals/Code/GameEngine/Include/GameNetwork/LANAPI.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ class LANAPI : public LANAPIInterface
287287
#pragma pack(push, 1)
288288
struct LANMessage
289289
{
290-
enum ///< What kind of message are we?
290+
enum Type ///< What kind of message are we?
291291
{
292292
// Locating everybody
293293
MSG_REQUEST_LOCATIONS, ///< Hey, where is everybody?
@@ -313,7 +313,7 @@ struct LANMessage
313313
MSG_INACTIVE, ///< I've alt-tabbed out. Unaccept me cause I'm a poo-flinging monkey.
314314

315315
MSG_REQUEST_GAME_INFO, ///< For direct connect, get the game info from a specific IP Address
316-
} LANMessageType;
316+
} messageType;
317317

318318
WideChar name[g_lanPlayerNameLength+1]; ///< My name, for convenience
319319
char userName[g_lanLoginNameLength+1]; ///< login name, for convenience

Generals/Code/GameEngine/Source/GameNetwork/LANAPI.cpp

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ void LANAPI::reset( void )
143143
{
144144
LANMessage msg;
145145
fillInLANMessage( &msg );
146-
msg.LANMessageType = LANMessage::MSG_REQUEST_LOBBY_LEAVE;
146+
msg.messageType = LANMessage::MSG_REQUEST_LOBBY_LEAVE;
147147
sendMessage(&msg);
148148
}
149149
m_transport->update();
@@ -355,9 +355,9 @@ void LANAPI::update( void )
355355
}
356356

357357
LANMessage *msg = (LANMessage *)(m_transport->m_inBuffer[i].data);
358-
//DEBUG_LOG(("LAN message type %s from %ls (%s@%s)", GetMessageTypeString(msg->LANMessageType).str(),
358+
//DEBUG_LOG(("LAN message type %s from %ls (%s@%s)", GetMessageTypeString(msg->messageType).str(),
359359
// msg->name, msg->userName, msg->hostName));
360-
switch (msg->LANMessageType)
360+
switch (msg->messageType)
361361
{
362362
// Location specification
363363
case LANMessage::MSG_REQUEST_LOCATIONS: // Hey, where is everybody?
@@ -426,7 +426,7 @@ void LANAPI::update( void )
426426
break;
427427

428428
default:
429-
DEBUG_LOG(("Unknown LAN message type %d", msg->LANMessageType));
429+
DEBUG_LOG(("Unknown LAN message type %d", msg->messageType));
430430
}
431431

432432
// Mark it as read
@@ -518,7 +518,7 @@ void LANAPI::update( void )
518518
// Actually, fake a host leaving message. :)
519519
LANMessage msg;
520520
fillInLANMessage( &msg );
521-
msg.LANMessageType = LANMessage::MSG_REQUEST_GAME_LEAVE;
521+
msg.messageType = LANMessage::MSG_REQUEST_GAME_LEAVE;
522522
wcslcpy(msg.name, m_currentGame->getPlayerName(0).str(), ARRAY_SIZE(msg.name));
523523
handleRequestGameLeave(&msg, m_currentGame->getIP(0));
524524
UnicodeString text;
@@ -536,7 +536,7 @@ void LANAPI::update( void )
536536
fillInLANMessage( &msg );
537537
UnicodeString theStr;
538538
theStr.format(TheGameText->fetch("LAN:PlayerDropped"), m_currentGame->getPlayerName(p).str());
539-
msg.LANMessageType = LANMessage::MSG_REQUEST_GAME_LEAVE;
539+
msg.messageType = LANMessage::MSG_REQUEST_GAME_LEAVE;
540540
wcslcpy(msg.name, m_currentGame->getPlayerName(p).str(), ARRAY_SIZE(msg.name));
541541
handleRequestGameLeave(&msg, m_currentGame->getIP(p));
542542
OnChat(UnicodeString::TheEmptyString, m_localIP, theStr, LANCHAT_SYSTEM);
@@ -612,7 +612,7 @@ void LANAPI::update( void )
612612
void LANAPI::RequestLocations( void )
613613
{
614614
LANMessage msg;
615-
msg.LANMessageType = LANMessage::MSG_REQUEST_LOCATIONS;
615+
msg.messageType = LANMessage::MSG_REQUEST_LOCATIONS;
616616
fillInLANMessage( &msg );
617617
sendMessage(&msg);
618618
}
@@ -632,7 +632,7 @@ void LANAPI::RequestGameJoin( LANGameInfo *game, UnsignedInt ip /* = 0 */ )
632632
}
633633

634634
LANMessage msg;
635-
msg.LANMessageType = LANMessage::MSG_REQUEST_JOIN;
635+
msg.messageType = LANMessage::MSG_REQUEST_JOIN;
636636
fillInLANMessage( &msg );
637637
msg.GameToJoin.gameIP = game->getSlot(0)->getIP();
638638
msg.GameToJoin.exeCRC = TheGlobalData->m_exeCRC;
@@ -665,7 +665,7 @@ void LANAPI::RequestGameJoinDirectConnect(UnsignedInt ipaddress)
665665
m_directConnectRemoteIP = ipaddress;
666666

667667
LANMessage msg;
668-
msg.LANMessageType = LANMessage::MSG_REQUEST_GAME_INFO;
668+
msg.messageType = LANMessage::MSG_REQUEST_GAME_INFO;
669669
fillInLANMessage(&msg);
670670
msg.PlayerInfo.ip = GetLocalIP();
671671
wcslcpy(msg.PlayerInfo.playerName, m_name.str(), ARRAY_SIZE(msg.PlayerInfo.playerName));
@@ -679,7 +679,7 @@ void LANAPI::RequestGameJoinDirectConnect(UnsignedInt ipaddress)
679679
void LANAPI::RequestGameLeave( void )
680680
{
681681
LANMessage msg;
682-
msg.LANMessageType = LANMessage::MSG_REQUEST_GAME_LEAVE;
682+
msg.messageType = LANMessage::MSG_REQUEST_GAME_LEAVE;
683683
fillInLANMessage( &msg );
684684
wcslcpy(msg.PlayerInfo.playerName, m_name.str(), ARRAY_SIZE(msg.PlayerInfo.playerName));
685685
sendMessage(&msg);
@@ -709,7 +709,7 @@ void LANAPI::RequestGameAnnounce( void )
709709
{
710710
LANMessage reply;
711711
fillInLANMessage( &reply );
712-
reply.LANMessageType = LANMessage::MSG_GAME_ANNOUNCE;
712+
reply.messageType = LANMessage::MSG_GAME_ANNOUNCE;
713713

714714
AsciiString gameOpts = GameInfoToAsciiString(m_currentGame);
715715
strlcpy(reply.GameInfo.options,gameOpts.str(), ARRAY_SIZE(reply.GameInfo.options));
@@ -729,7 +729,7 @@ void LANAPI::RequestAccept( void )
729729

730730
LANMessage msg;
731731
fillInLANMessage( &msg );
732-
msg.LANMessageType = LANMessage::MSG_SET_ACCEPT;
732+
msg.messageType = LANMessage::MSG_SET_ACCEPT;
733733
msg.Accept.isAccepted = true;
734734
wcslcpy(msg.Accept.gameName, m_currentGame->getName().str(), ARRAY_SIZE(msg.Accept.gameName));
735735
sendMessage(&msg);
@@ -742,7 +742,7 @@ void LANAPI::RequestHasMap( void )
742742

743743
LANMessage msg;
744744
fillInLANMessage( &msg );
745-
msg.LANMessageType = LANMessage::MSG_MAP_AVAILABILITY;
745+
msg.messageType = LANMessage::MSG_MAP_AVAILABILITY;
746746
msg.MapStatus.hasMap = m_currentGame->getSlot(m_currentGame->getLocalSlotNum())->hasMap();
747747
wcslcpy(msg.MapStatus.gameName, m_currentGame->getName().str(), ARRAY_SIZE(msg.MapStatus.gameName));
748748
CRC mapNameCRC;
@@ -782,7 +782,7 @@ void LANAPI::RequestChat( UnicodeString message, ChatType format )
782782
LANMessage msg;
783783
fillInLANMessage( &msg );
784784
wcslcpy(msg.Chat.gameName, (m_currentGame) ? m_currentGame->getName().str() : L"", ARRAY_SIZE(msg.Chat.gameName));
785-
msg.LANMessageType = LANMessage::MSG_CHAT;
785+
msg.messageType = LANMessage::MSG_CHAT;
786786
msg.Chat.chatType = format;
787787
wcslcpy(msg.Chat.message, message.str(), ARRAY_SIZE(msg.Chat.message));
788788
sendMessage(&msg);
@@ -796,7 +796,7 @@ void LANAPI::RequestGameStart( void )
796796
return;
797797

798798
LANMessage msg;
799-
msg.LANMessageType = LANMessage::MSG_GAME_START;
799+
msg.messageType = LANMessage::MSG_GAME_START;
800800
fillInLANMessage( &msg );
801801
sendMessage(&msg);
802802
m_transport->update(); // force a send
@@ -820,7 +820,7 @@ void LANAPI::RequestGameStartTimer( Int seconds )
820820
m_gameStartSeconds = (seconds) ? seconds - 1 : 0;
821821

822822
LANMessage msg;
823-
msg.LANMessageType = LANMessage::MSG_GAME_START_TIMER;
823+
msg.messageType = LANMessage::MSG_GAME_START_TIMER;
824824
msg.StartTimer.seconds = seconds;
825825
fillInLANMessage( &msg );
826826
sendMessage(&msg);
@@ -838,7 +838,7 @@ void LANAPI::RequestGameOptions( AsciiString gameOptions, Bool isPublic, Unsigne
838838

839839
LANMessage msg;
840840
fillInLANMessage( &msg );
841-
msg.LANMessageType = LANMessage::MSG_GAME_OPTIONS;
841+
msg.messageType = LANMessage::MSG_GAME_OPTIONS;
842842
strlcpy(msg.GameOptions.options, gameOptions.str(), ARRAY_SIZE(msg.GameOptions.options));
843843
sendMessage(&msg, ip);
844844

@@ -941,7 +941,7 @@ void LANAPI::RequestGameCreate( UnicodeString gameName, Bool isDirectConnect )
941941
msg.GameInfo.ip[player] = myGame->getIP(player);
942942
msg.GameInfo.playerAccepted[player] = myGame->getAccepted(player);
943943
}
944-
msg.LANMessageType = LANMessage::MSG_GAME_ANNOUNCE;
944+
msg.messageType = LANMessage::MSG_GAME_ANNOUNCE;
945945
*/
946946
OnGameCreate(LANAPIInterface::RET_OK);
947947
}
@@ -1003,7 +1003,7 @@ void LANAPI::RequestSlotList( void )
10031003
{
10041004
10051005
LANMessage reply;
1006-
reply.LANMessageType = LANMessage::MSG_GAME_ANNOUNCE;
1006+
reply.messageType = LANMessage::MSG_GAME_ANNOUNCE;
10071007
wcslcpy(reply.name, m_name.str(), ARRAY_SIZE(reply.name));
10081008
int player;
10091009
for (player = 0; player < MAX_SLOTS; ++player)
@@ -1038,7 +1038,7 @@ void LANAPI::RequestSetName( UnicodeString newName )
10381038
m_name = newName;
10391039
LANMessage msg;
10401040
fillInLANMessage( &msg );
1041-
msg.LANMessageType = LANMessage::MSG_LOBBY_ANNOUNCE;
1041+
msg.messageType = LANMessage::MSG_LOBBY_ANNOUNCE;
10421042
sendMessage(&msg);
10431043

10441044
// Update the interface
@@ -1076,7 +1076,7 @@ void LANAPI::fillInLANMessage( LANMessage *msg )
10761076
void LANAPI::RequestLobbyLeave( Bool forced )
10771077
{
10781078
LANMessage msg;
1079-
msg.LANMessageType = LANMessage::MSG_REQUEST_LOBBY_LEAVE;
1079+
msg.messageType = LANMessage::MSG_REQUEST_LOBBY_LEAVE;
10801080
fillInLANMessage( &msg );
10811081
sendMessage(&msg);
10821082

@@ -1273,7 +1273,7 @@ void LANAPI::setIsActive(Bool isActive) {
12731273
if ((m_inLobby == FALSE) && (m_currentGame != NULL)) {
12741274
LANMessage msg;
12751275
fillInLANMessage( &msg );
1276-
msg.LANMessageType = LANMessage::MSG_INACTIVE;
1276+
msg.messageType = LANMessage::MSG_INACTIVE;
12771277
sendMessage(&msg);
12781278
DEBUG_LOG(("LANAPI::setIsActive - sent an IsActive message"));
12791279
}

Generals/Code/GameEngine/Source/GameNetwork/LANAPIhandlers.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ void LANAPI::handleRequestLocations( LANMessage *msg, UnsignedInt senderIP )
4646
{
4747
LANMessage reply;
4848
fillInLANMessage( &reply );
49-
reply.LANMessageType = LANMessage::MSG_LOBBY_ANNOUNCE;
49+
reply.messageType = LANMessage::MSG_LOBBY_ANNOUNCE;
5050

5151
sendMessage(&reply);
5252
m_lastResendTime = timeGetTime();
@@ -60,7 +60,7 @@ void LANAPI::handleRequestLocations( LANMessage *msg, UnsignedInt senderIP )
6060
{
6161
LANMessage reply;
6262
fillInLANMessage( &reply );
63-
reply.LANMessageType = LANMessage::MSG_GAME_ANNOUNCE;
63+
reply.messageType = LANMessage::MSG_GAME_ANNOUNCE;
6464
AsciiString gameOpts = GenerateGameOptionsString();
6565
strlcpy(reply.GameInfo.options, gameOpts.str(), ARRAY_SIZE(reply.GameInfo.options));
6666
wcslcpy(reply.GameInfo.gameName, m_currentGame->getName().str(), ARRAY_SIZE(reply.GameInfo.gameName));
@@ -189,7 +189,7 @@ void LANAPI::handleRequestGameInfo( LANMessage *msg, UnsignedInt senderIP )
189189
{
190190
LANMessage reply;
191191
fillInLANMessage( &reply );
192-
reply.LANMessageType = LANMessage::MSG_GAME_ANNOUNCE;
192+
reply.messageType = LANMessage::MSG_GAME_ANNOUNCE;
193193

194194
AsciiString gameOpts = GameInfoToAsciiString(m_currentGame);
195195
strlcpy(reply.GameInfo.options,gameOpts.str(), ARRAY_SIZE(reply.GameInfo.options));
@@ -217,7 +217,7 @@ void LANAPI::handleRequestJoin( LANMessage *msg, UnsignedInt senderIP )
217217
{
218218
if (m_currentGame->isGameInProgress())
219219
{
220-
reply.LANMessageType = LANMessage::MSG_JOIN_DENY;
220+
reply.messageType = LANMessage::MSG_JOIN_DENY;
221221
reply.GameNotJoined.reason = LANAPIInterface::RET_GAME_STARTED;
222222
reply.GameNotJoined.gameIP = m_localIP;
223223
reply.GameNotJoined.playerIP = senderIP;
@@ -240,7 +240,7 @@ void LANAPI::handleRequestJoin( LANMessage *msg, UnsignedInt senderIP )
240240
DEBUG_LOG(("LANAPI::handleRequestJoin - join denied because of CRC mismatch. CRCs are them/us INI:%X/%X exe:%X/%X",
241241
msg->GameToJoin.iniCRC, TheGlobalData->m_iniCRC,
242242
msg->GameToJoin.exeCRC, TheGlobalData->m_exeCRC));
243-
reply.LANMessageType = LANMessage::MSG_JOIN_DENY;
243+
reply.messageType = LANMessage::MSG_JOIN_DENY;
244244
reply.GameNotJoined.reason = LANAPIInterface::RET_CRC_MISMATCH;
245245
reply.GameNotJoined.gameIP = m_localIP;
246246
reply.GameNotJoined.playerIP = senderIP;
@@ -277,7 +277,7 @@ void LANAPI::handleRequestJoin( LANMessage *msg, UnsignedInt senderIP )
277277
if (!strncmp(s.str(), msg->GameToJoin.serial, g_maxSerialLength))
278278
{
279279
// serials match! kick the punk!
280-
reply.LANMessageType = LANMessage::MSG_JOIN_DENY;
280+
reply.messageType = LANMessage::MSG_JOIN_DENY;
281281
reply.GameNotJoined.reason = LANAPIInterface::RET_SERIAL_DUPE;
282282
reply.GameNotJoined.gameIP = m_localIP;
283283
reply.GameNotJoined.playerIP = senderIP;
@@ -297,7 +297,7 @@ void LANAPI::handleRequestJoin( LANMessage *msg, UnsignedInt senderIP )
297297
if (slot->isHuman() && slot->getName().compare(msg->name) == 0)
298298
{
299299
// just deny duplicates
300-
reply.LANMessageType = LANMessage::MSG_JOIN_DENY;
300+
reply.messageType = LANMessage::MSG_JOIN_DENY;
301301
reply.GameNotJoined.reason = LANAPIInterface::RET_DUPLICATE_NAME;
302302
reply.GameNotJoined.gameIP = m_localIP;
303303
reply.GameNotJoined.playerIP = senderIP;
@@ -314,7 +314,7 @@ void LANAPI::handleRequestJoin( LANMessage *msg, UnsignedInt senderIP )
314314
if (m_currentGame->getLANSlot(player)->isOpen())
315315
{
316316
// OK, add him in.
317-
reply.LANMessageType = LANMessage::MSG_JOIN_ACCEPT;
317+
reply.messageType = LANMessage::MSG_JOIN_ACCEPT;
318318
wcslcpy(reply.GameJoined.gameName, m_currentGame->getName().str(), ARRAY_SIZE(reply.GameJoined.gameName));
319319
reply.GameJoined.slotPosition = player;
320320
reply.GameJoined.gameIP = m_localIP;
@@ -338,7 +338,7 @@ void LANAPI::handleRequestJoin( LANMessage *msg, UnsignedInt senderIP )
338338

339339
if (canJoin && player == MAX_SLOTS)
340340
{
341-
reply.LANMessageType = LANMessage::MSG_JOIN_DENY;
341+
reply.messageType = LANMessage::MSG_JOIN_DENY;
342342
wcslcpy(reply.GameNotJoined.gameName, m_currentGame->getName().str(), ARRAY_SIZE(reply.GameNotJoined.gameName));
343343
reply.GameNotJoined.reason = LANAPIInterface::RET_GAME_FULL;
344344
reply.GameNotJoined.gameIP = m_localIP;
@@ -349,7 +349,7 @@ void LANAPI::handleRequestJoin( LANMessage *msg, UnsignedInt senderIP )
349349
}
350350
else
351351
{
352-
reply.LANMessageType = LANMessage::MSG_JOIN_DENY;
352+
reply.messageType = LANMessage::MSG_JOIN_DENY;
353353
reply.GameNotJoined.reason = LANAPIInterface::RET_GAME_GONE;
354354
reply.GameNotJoined.gameIP = m_localIP;
355355
reply.GameNotJoined.playerIP = senderIP;

GeneralsMD/Code/GameEngine/Include/GameNetwork/LANAPI.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ class LANAPI : public LANAPIInterface
287287
#pragma pack(push, 1)
288288
struct LANMessage
289289
{
290-
enum ///< What kind of message are we?
290+
enum Type ///< What kind of message are we?
291291
{
292292
// Locating everybody
293293
MSG_REQUEST_LOCATIONS, ///< Hey, where is everybody?
@@ -313,7 +313,7 @@ struct LANMessage
313313
MSG_INACTIVE, ///< I've alt-tabbed out. Unaccept me cause I'm a poo-flinging monkey.
314314

315315
MSG_REQUEST_GAME_INFO, ///< For direct connect, get the game info from a specific IP Address
316-
} LANMessageType;
316+
} messageType;
317317

318318
WideChar name[g_lanPlayerNameLength+1]; ///< My name, for convenience
319319
char userName[g_lanLoginNameLength+1]; ///< login name, for convenience

0 commit comments

Comments
 (0)