@@ -185,10 +185,10 @@ void LANAPI::sendMessage(LANMessage* msg, UnsignedInt ip /* = 0 */)
185185 LANMessageWire wireMsg;
186186 ConvertLANMessageToWire (msg, &wireMsg);
187187 unsigned char * payload = (unsigned char *)&wireMsg;
188- size_t payloadSize = sizeof (LANMessageWire);
188+ int payloadSize = ( int ) sizeof (LANMessageWire);
189189#else
190190 unsigned char * payload = (unsigned char *)msg;
191- size_t payloadSize = sizeof (LANMessage);
191+ int payloadSize = ( int ) sizeof (LANMessage);
192192#endif
193193
194194 if (ip != 0 )
@@ -360,17 +360,26 @@ void LANAPI::update()
360360 UnsignedInt senderIP = m_transport->m_inBuffer [i].addr ;
361361 if (senderIP == m_localIP)
362362 {
363+ #ifdef __APPLE__
364+ printf (" MAC_LANAPI: Dropping packet from senderIP %08X because it matches m_localIP!\n " , senderIP);
365+ fflush (stdout);
366+ #endif
363367 m_transport->m_inBuffer [i].length = 0 ;
364368 continue ;
365369 }
366370
367- #ifdef __APPLE__
368371 LANMessage msgBuffer;
372+ #ifdef __APPLE__
369373 LANMessageWire* wireMsg = (LANMessageWire*)(m_transport->m_inBuffer [i].data );
370374 ConvertWireToLANMessage (wireMsg, &msgBuffer);
371- LANMessage* msg = &msgBuffer;
372375#else
373- LANMessage* msg = (LANMessage*)(m_transport->m_inBuffer [i].data );
376+ memcpy (&msgBuffer, m_transport->m_inBuffer [i].data , sizeof (LANMessage));
377+ #endif
378+ LANMessage* msg = &msgBuffer;
379+
380+ #ifdef __APPLE__
381+ printf (" MAC_LANAPI: Processing messageType %d from %08X\n " , msg->messageType , senderIP);
382+ fflush (stdout);
374383#endif
375384
376385 // DEBUG_LOG(("LAN message type %s from %ls (%s@%s)", GetMessageTypeString(msg->messageType).str(),
@@ -1347,9 +1356,9 @@ void ConvertWireToLANMessage(const LANMessageWire* wire, LANMessage* msg) {
13471356 break ;
13481357 case LANMessage::MSG_GAME_ANNOUNCE :
13491358 CopyWireToWide (msg->GameInfo .gameName , wire->GameInfo .gameName , ARRAY_SIZE (wire->GameInfo .gameName ));
1350- msg->GameInfo .inProgress = wire->GameInfo .inProgress ;
1359+ msg->GameInfo .inProgress = (Bool) wire->GameInfo .inProgress ;
13511360 memcpy (msg->GameInfo .options , wire->GameInfo .options , sizeof (wire->GameInfo .options ));
1352- msg->GameInfo .isDirectConnect = wire->GameInfo .isDirectConnect ;
1361+ msg->GameInfo .isDirectConnect = (Bool) wire->GameInfo .isDirectConnect ;
13531362 break ;
13541363 case LANMessage::MSG_REQUEST_GAME_INFO :
13551364 msg->PlayerInfo .ip = wire->PlayerInfo .ip ;
@@ -1371,20 +1380,20 @@ void ConvertWireToLANMessage(const LANMessageWire* wire, LANMessage* msg) {
13711380 CopyWireToWide (msg->GameNotJoined .gameName , wire->GameNotJoined .gameName , ARRAY_SIZE (wire->GameNotJoined .gameName ));
13721381 msg->GameNotJoined .gameIP = wire->GameNotJoined .gameIP ;
13731382 msg->GameNotJoined .playerIP = wire->GameNotJoined .playerIP ;
1374- msg->GameNotJoined .reason = wire->GameNotJoined .reason ;
1383+ msg->GameNotJoined .reason = (LANAPIInterface::ReturnType) wire->GameNotJoined .reason ;
13751384 break ;
13761385 case LANMessage::MSG_SET_ACCEPT :
13771386 CopyWireToWide (msg->Accept .gameName , wire->Accept .gameName , ARRAY_SIZE (wire->Accept .gameName ));
1378- msg->Accept .isAccepted = wire->Accept .isAccepted ;
1387+ msg->Accept .isAccepted = (Bool) wire->Accept .isAccepted ;
13791388 break ;
13801389 case LANMessage::MSG_MAP_AVAILABILITY :
13811390 CopyWireToWide (msg->MapStatus .gameName , wire->MapStatus .gameName , ARRAY_SIZE (wire->MapStatus .gameName ));
13821391 msg->MapStatus .mapCRC = wire->MapStatus .mapCRC ;
1383- msg->MapStatus .hasMap = wire->MapStatus .hasMap ;
1392+ msg->MapStatus .hasMap = (Bool) wire->MapStatus .hasMap ;
13841393 break ;
13851394 case LANMessage::MSG_CHAT :
13861395 CopyWireToWide (msg->Chat .gameName , wire->Chat .gameName , ARRAY_SIZE (wire->Chat .gameName ));
1387- msg->Chat .chatType = wire->Chat .chatType ;
1396+ msg->Chat .chatType = (LANAPIInterface::ChatType) wire->Chat .chatType ;
13881397 CopyWireToWide (msg->Chat .message , wire->Chat .message , ARRAY_SIZE (wire->Chat .message ));
13891398 break ;
13901399 case LANMessage::MSG_GAME_OPTIONS :
@@ -1395,7 +1404,7 @@ void ConvertWireToLANMessage(const LANMessageWire* wire, LANMessage* msg) {
13951404
13961405void ConvertLANMessageToWire (const LANMessage* msg, LANMessageWire* wire) {
13971406 memset (wire, 0 , sizeof (LANMessageWire));
1398- wire->messageType = msg->messageType ;
1407+ wire->messageType = ( uint32_t ) msg->messageType ;
13991408 CopyWideToWire (wire->name , msg->name , ARRAY_SIZE (msg->name ));
14001409 memcpy (wire->userName , msg->userName , sizeof (msg->userName ));
14011410 memcpy (wire->hostName , msg->hostName , sizeof (msg->hostName ));
@@ -1409,9 +1418,9 @@ void ConvertLANMessageToWire(const LANMessage* msg, LANMessageWire* wire) {
14091418 break ;
14101419 case LANMessage::MSG_GAME_ANNOUNCE :
14111420 CopyWideToWire (wire->GameInfo .gameName , msg->GameInfo .gameName , ARRAY_SIZE (msg->GameInfo .gameName ));
1412- wire->GameInfo .inProgress = msg->GameInfo .inProgress ;
1421+ wire->GameInfo .inProgress = msg->GameInfo .inProgress ? 1 : 0 ;
14131422 memcpy (wire->GameInfo .options , msg->GameInfo .options , sizeof (msg->GameInfo .options ));
1414- wire->GameInfo .isDirectConnect = msg->GameInfo .isDirectConnect ;
1423+ wire->GameInfo .isDirectConnect = msg->GameInfo .isDirectConnect ? 1 : 0 ;
14151424 break ;
14161425 case LANMessage::MSG_REQUEST_GAME_INFO :
14171426 wire->PlayerInfo .ip = msg->PlayerInfo .ip ;
@@ -1433,20 +1442,20 @@ void ConvertLANMessageToWire(const LANMessage* msg, LANMessageWire* wire) {
14331442 CopyWideToWire (wire->GameNotJoined .gameName , msg->GameNotJoined .gameName , ARRAY_SIZE (msg->GameNotJoined .gameName ));
14341443 wire->GameNotJoined .gameIP = msg->GameNotJoined .gameIP ;
14351444 wire->GameNotJoined .playerIP = msg->GameNotJoined .playerIP ;
1436- wire->GameNotJoined .reason = msg->GameNotJoined .reason ;
1445+ wire->GameNotJoined .reason = ( int32_t ) msg->GameNotJoined .reason ;
14371446 break ;
14381447 case LANMessage::MSG_SET_ACCEPT :
14391448 CopyWideToWire (wire->Accept .gameName , msg->Accept .gameName , ARRAY_SIZE (msg->Accept .gameName ));
1440- wire->Accept .isAccepted = msg->Accept .isAccepted ;
1449+ wire->Accept .isAccepted = msg->Accept .isAccepted ? 1 : 0 ;
14411450 break ;
14421451 case LANMessage::MSG_MAP_AVAILABILITY :
14431452 CopyWideToWire (wire->MapStatus .gameName , msg->MapStatus .gameName , ARRAY_SIZE (msg->MapStatus .gameName ));
14441453 wire->MapStatus .mapCRC = msg->MapStatus .mapCRC ;
1445- wire->MapStatus .hasMap = msg->MapStatus .hasMap ;
1454+ wire->MapStatus .hasMap = msg->MapStatus .hasMap ? 1 : 0 ;
14461455 break ;
14471456 case LANMessage::MSG_CHAT :
14481457 CopyWideToWire (wire->Chat .gameName , msg->Chat .gameName , ARRAY_SIZE (msg->Chat .gameName ));
1449- wire->Chat .chatType = msg->Chat .chatType ;
1458+ wire->Chat .chatType = ( int32_t ) msg->Chat .chatType ;
14501459 CopyWideToWire (wire->Chat .message , msg->Chat .message , ARRAY_SIZE (msg->Chat .message ));
14511460 break ;
14521461 case LANMessage::MSG_GAME_OPTIONS :
@@ -1455,4 +1464,3 @@ void ConvertLANMessageToWire(const LANMessage* msg, LANMessageWire* wire) {
14551464 }
14561465}
14571466#endif
1458-
0 commit comments