diff --git a/src/audiomixerboard.cpp b/src/audiomixerboard.cpp index b9cfc86a..44ccdf12 100755 --- a/src/audiomixerboard.cpp +++ b/src/audiomixerboard.cpp @@ -191,9 +191,12 @@ QString CAudioMixerBoard::GenFaderText ( CChannelShortInfo& ChanInfo ) // if text is empty, show IP address instead if ( ChanInfo.strName.isEmpty() ) { - // convert IP address to text and show it - const QHostAddress addrTest ( ChanInfo.iIpAddr ); - return addrTest.toString(); + // convert IP address to text and show it (use dummy port number + // since it is not used here) + const CHostAddress TempAddr = + CHostAddress ( QHostAddress ( ChanInfo.iIpAddr ), 0 ); + + return TempAddr.GetIpAddressStringNoLastByte(); } else { diff --git a/src/channel.cpp b/src/channel.cpp index 7076a00a..be2434b9 100755 --- a/src/channel.cpp +++ b/src/channel.cpp @@ -205,8 +205,8 @@ void CChannelSet::CreateAndSendChatTextForAllConChannels ( const int iCurChanID, if ( ChanName.isEmpty() ) { // convert IP address to text and show it - const QHostAddress addrTest ( vecChannels[iCurChanID].GetAddress().InetAddr ); - ChanName = addrTest.toString(); + ChanName = + vecChannels[iCurChanID].GetAddress().GetIpAddressStringNoLastByte(); } // add name of the client at the beginning of the message text and use @@ -637,12 +637,10 @@ void CChannelSet::WriteHTMLChannelList() // if text is empty, show IP address instead if ( strCurChanName.isEmpty() ) { - // convert IP address to text and show it - const QHostAddress addrTest ( vecChannels[i].GetAddress().InetAddr ); - strCurChanName = addrTest.toString(); - - // remove last digits - strCurChanName = strCurChanName.section ( ".", 0, 2 ) + ".x"; + // convert IP address to text and show it, remove last + // digits + strCurChanName = + vecChannels[i].GetAddress().GetIpAddressStringNoLastByte(); } streamFileOut << "
  • " << strCurChanName << "
  • " << endl; diff --git a/src/util.h b/src/util.h index 83df50fc..eeaa7a39 100755 --- a/src/util.h +++ b/src/util.h @@ -392,6 +392,12 @@ public: bool operator== ( const CHostAddress& CompAddr ) // compare operator { return ( ( CompAddr.InetAddr == InetAddr ) && ( CompAddr.iPort == iPort ) ); } + QString GetIpAddressStringNoLastByte() const + { + // remove the last byte of the IP address + return InetAddr.toString().section ( ".", 0, 2 ) + ".x"; + } + QHostAddress InetAddr; quint16 iPort; };