X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FMultiPlayer%2Fmultiplaymgr.cxx;h=fe1f4c399912b3df7c7efb20f2a82f39ddf3aae5;hb=ad13e4f3b42c53410cb695d2dd0083af77addb2e;hp=cf4ddd53e12add9c0fa9edf4ff9fb2b5eedfbf73;hpb=4cc30842565e25bd50e27477626c731a9de93b9a;p=flightgear.git diff --git a/src/MultiPlayer/multiplaymgr.cxx b/src/MultiPlayer/multiplaymgr.cxx index cf4ddd53e..fe1f4c399 100644 --- a/src/MultiPlayer/multiplaymgr.cxx +++ b/src/MultiPlayer/multiplaymgr.cxx @@ -158,6 +158,8 @@ FGMultiplayMgr::sIdPropertyList[] = { {1100, "sim/model/variant", simgear::props::INT}, {1101, "sim/model/livery/file", simgear::props::STRING}, + {1200, "environment/wildfire/data", simgear::props::STRING}, + {10001, "sim/multiplay/transmission-freq-hz", simgear::props::STRING}, {10002, "sim/multiplay/chat", simgear::props::STRING}, @@ -268,7 +270,7 @@ namespace { bool verifyProperties(const xdr_data_t* data, const xdr_data_t* end) { - using namespace simgear::props; + using namespace simgear; const xdr_data_t* xdr = data; while (xdr < end) { unsigned id = XDR_decode_uint32(*xdr); @@ -279,13 +281,13 @@ namespace xdr++; // How we decode the remainder of the property depends on the type switch (plist->type) { - case INT: - case BOOL: - case LONG: + case props::INT: + case props::BOOL: + case props::LONG: xdr++; break; - case FLOAT: - case DOUBLE: + case props::FLOAT: + case props::DOUBLE: { float val = XDR_decode_float(*xdr); if (osg::isNaN(val)) @@ -293,8 +295,8 @@ namespace xdr++; break; } - case STRING: - case UNSPECIFIED: + case props::STRING: + case props::UNSPECIFIED: { // String is complicated. It consists of // The length of the string @@ -383,7 +385,7 @@ FGMultiplayMgr::init (void) mServer.set(txAddress.c_str(), txPort); if (strncmp (mServer.getHost(), "0.0.0.0", 8) == 0) { mHaveServer = false; - SG_LOG(SG_NETWORK, SG_ALERT, + SG_LOG(SG_NETWORK, SG_DEBUG, "FGMultiplayMgr - could not resolve '" << txAddress << "', Multiplayermode disabled"); } else { @@ -393,7 +395,7 @@ FGMultiplayMgr::init (void) rxPort = txPort; } if (rxPort <= 0) { - SG_LOG(SG_NETWORK, SG_ALERT, + SG_LOG(SG_NETWORK, SG_DEBUG, "FGMultiplayMgr - No receiver port, Multiplayermode disabled"); return (false); } @@ -408,14 +410,14 @@ FGMultiplayMgr::init (void) // A memory leak was reported here by valgrind mSocket = new netSocket(); if (!mSocket->open(false)) { - SG_LOG( SG_NETWORK, SG_ALERT, + SG_LOG( SG_NETWORK, SG_DEBUG, "FGMultiplayMgr::init - Failed to create data socket" ); return false; } mSocket->setBlocking(false); if (mSocket->bind(rxAddress.c_str(), rxPort) != 0) { perror("bind"); - SG_LOG( SG_NETWORK, SG_ALERT, + SG_LOG( SG_NETWORK, SG_DEBUG, "FGMultiplayMgr::Open - Failed to bind receive socket" ); return false; } @@ -527,7 +529,7 @@ FGMultiplayMgr::SendMyPosition(const FGExternalMotionData& motionInfo) if ((! mInitialised) || (! mHaveServer)) return; if (! mHaveServer) { - SG_LOG( SG_NETWORK, SG_ALERT, "FGMultiplayMgr::SendMyPosition - no server"); + SG_LOG( SG_NETWORK, SG_DEBUG, "FGMultiplayMgr::SendMyPosition - no server"); return; } @@ -716,7 +718,7 @@ FGMultiplayMgr::Update(void) ////////////////////////////////////////////////// // Read the receive socket and process any data ////////////////////////////////////////////////// - int bytes; + ssize_t bytes; do { MsgBuf msgBuf; ////////////////////////////////////////////////// @@ -736,8 +738,8 @@ FGMultiplayMgr::Update(void) perror("FGMultiplayMgr::MP_ProcessData"); break; } - if (bytes <= sizeof(T_MsgHdr)) { - SG_LOG( SG_NETWORK, SG_ALERT, "FGMultiplayMgr::MP_ProcessData - " + if (bytes <= static_cast(sizeof(T_MsgHdr))) { + SG_LOG( SG_NETWORK, SG_DEBUG, "FGMultiplayMgr::MP_ProcessData - " << "received message with insufficient data" ); break; } @@ -752,17 +754,17 @@ FGMultiplayMgr::Update(void) MsgHdr->ReplyPort = XDR_decode_uint32 (MsgHdr->ReplyPort); MsgHdr->Callsign[MAX_CALLSIGN_LEN -1] = '\0'; if (MsgHdr->Magic != MSG_MAGIC) { - SG_LOG( SG_NETWORK, SG_ALERT, "FGMultiplayMgr::MP_ProcessData - " + SG_LOG( SG_NETWORK, SG_DEBUG, "FGMultiplayMgr::MP_ProcessData - " << "message has invalid magic number!" ); break; } if (MsgHdr->Version != PROTO_VER) { - SG_LOG( SG_NETWORK, SG_ALERT, "FGMultiplayMgr::MP_ProcessData - " + SG_LOG( SG_NETWORK, SG_DEBUG, "FGMultiplayMgr::MP_ProcessData - " << "message has invalid protocoll number!" ); break; } if (MsgHdr->MsgLen != bytes) { - SG_LOG(SG_NETWORK, SG_ALERT, "FGMultiplayMgr::MP_ProcessData - " + SG_LOG(SG_NETWORK, SG_DEBUG, "FGMultiplayMgr::MP_ProcessData - " << "message from " << MsgHdr->Callsign << " has invalid length!"); break; } @@ -782,7 +784,7 @@ FGMultiplayMgr::Update(void) case OLD_POS_DATA_ID: break; default: - SG_LOG( SG_NETWORK, SG_ALERT, "FGMultiplayMgr::MP_ProcessData - " + SG_LOG( SG_NETWORK, SG_DEBUG, "FGMultiplayMgr::MP_ProcessData - " << "Unknown message Id received: " << MsgHdr->MsgId ); break; } @@ -813,7 +815,7 @@ FGMultiplayMgr::ProcessPosMsg(const FGMultiplayMgr::MsgBuf& Msg, { const T_MsgHdr* MsgHdr = Msg.msgHdr(); if (MsgHdr->MsgLen < sizeof(T_MsgHdr) + sizeof(T_PositionMsg)) { - SG_LOG( SG_NETWORK, SG_ALERT, "FGMultiplayMgr::MP_ProcessData - " + SG_LOG( SG_NETWORK, SG_DEBUG, "FGMultiplayMgr::MP_ProcessData - " << "Position message received with insufficient data" ); return; } @@ -863,7 +865,7 @@ FGMultiplayMgr::ProcessPosMsg(const FGMultiplayMgr::MsgBuf& Msg, } while (xdr < Msg.propsRecvdEnd()) { FGPropertyData* pData = new FGPropertyData; - simgear::props::Type type = simgear::props::UNSPECIFIED; + // simgear::props::Type type = simgear::props::UNSPECIFIED; // First element is always the ID pData->id = XDR_decode_uint32(*xdr); @@ -928,7 +930,7 @@ FGMultiplayMgr::ProcessPosMsg(const FGMultiplayMgr::MsgBuf& Msg, default: pData->float_value = XDR_decode_float(*xdr); - SG_LOG(SG_NETWORK, SG_ALERT, "Unknown Prop type " << pData->id << " " << pData->type); + SG_LOG(SG_NETWORK, SG_DEBUG, "Unknown Prop type " << pData->id << " " << pData->type); xdr++; break; } @@ -963,20 +965,18 @@ FGMultiplayMgr::ProcessChatMsg(const MsgBuf& Msg, { const T_MsgHdr* MsgHdr = Msg.msgHdr(); if (MsgHdr->MsgLen < sizeof(T_MsgHdr) + 1) { - SG_LOG( SG_NETWORK, SG_ALERT, "FGMultiplayMgr::MP_ProcessData - " + SG_LOG( SG_NETWORK, SG_DEBUG, "FGMultiplayMgr::MP_ProcessData - " << "Chat message received with insufficient data" ); return; } char *chatStr = new char[MsgHdr->MsgLen - sizeof(T_MsgHdr)]; - strncpy(chatStr, - (reinterpret_cast(Msg.Msg + sizeof(T_MsgHdr))) - ->Text, + const T_ChatMsg* ChatMsg + = reinterpret_cast(Msg.Msg + sizeof(T_MsgHdr)); + strncpy(chatStr, ChatMsg->Text, MsgHdr->MsgLen - sizeof(T_MsgHdr)); chatStr[MsgHdr->MsgLen - sizeof(T_MsgHdr) - 1] = '\0'; - const T_ChatMsg* ChatMsg - = reinterpret_cast(Msg.Msg + sizeof(T_MsgHdr)); SG_LOG (SG_NETWORK, SG_WARN, "Chat [" << MsgHdr->Callsign << "]" << " " << chatStr);