mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-31 04:25:35 +08:00
Change FS9 plugin to new logging system
This commit is contained in:
@@ -11,6 +11,7 @@
|
|||||||
#include "fs9_host.h"
|
#include "fs9_host.h"
|
||||||
#include "fs9_client.h"
|
#include "fs9_client.h"
|
||||||
#include "blackmisc/mathematics.h"
|
#include "blackmisc/mathematics.h"
|
||||||
|
#include "blackmisc/logmessage.h"
|
||||||
|
|
||||||
using namespace BlackMisc::Aviation;
|
using namespace BlackMisc::Aviation;
|
||||||
using namespace BlackMisc::Geo;
|
using namespace BlackMisc::Geo;
|
||||||
@@ -167,45 +168,48 @@ namespace BlackSimPlugin
|
|||||||
|
|
||||||
HRESULT printDirectPlayError(HRESULT error)
|
HRESULT printDirectPlayError(HRESULT error)
|
||||||
{
|
{
|
||||||
|
QString errorMessage;
|
||||||
switch(error)
|
switch(error)
|
||||||
{
|
{
|
||||||
case DPNERR_BUFFERTOOSMALL:
|
case DPNERR_BUFFERTOOSMALL:
|
||||||
qWarning() << "The supplied buffer is not large enough to contain the requested data.";
|
errorMessage = "The supplied buffer is not large enough to contain the requested data.";
|
||||||
break;
|
break;
|
||||||
case DPNERR_DOESNOTEXIST:
|
case DPNERR_DOESNOTEXIST:
|
||||||
qWarning() << "Requested element is not part of the address.";
|
errorMessage = "Requested element is not part of the address.";
|
||||||
break;
|
break;
|
||||||
case DPNERR_INVALIDFLAGS:
|
case DPNERR_INVALIDFLAGS:
|
||||||
qWarning() << "The flags passed to this method are invalid.";
|
errorMessage = "The flags passed to this method are invalid.";
|
||||||
break;
|
break;
|
||||||
case DPNERR_INVALIDPARAM:
|
case DPNERR_INVALIDPARAM:
|
||||||
qWarning() << "One or more of the parameters passed to the method are invalid.";
|
errorMessage = "One or more of the parameters passed to the method are invalid.";
|
||||||
break;
|
break;
|
||||||
case DPNERR_INVALIDPOINTER:
|
case DPNERR_INVALIDPOINTER:
|
||||||
qWarning() << "Pointer specified as a parameter is invalid.";
|
errorMessage = "Pointer specified as a parameter is invalid.";
|
||||||
break;
|
break;
|
||||||
case DPNERR_INVALIDURL:
|
case DPNERR_INVALIDURL:
|
||||||
qWarning() << "Specified string is not a valid DirectPlayURL.";
|
errorMessage = "Specified string is not a valid DirectPlayURL.";
|
||||||
break;
|
break;
|
||||||
case DPNERR_NOTALLOWED:
|
case DPNERR_NOTALLOWED:
|
||||||
qWarning() << "This function is not allowed on this object.";
|
errorMessage = "This function is not allowed on this object.";
|
||||||
break;
|
break;
|
||||||
case DPNERR_INVALIDOBJECT:
|
case DPNERR_INVALIDOBJECT:
|
||||||
qWarning() << "The Microsoft DirectPlay object pointer is invalid.";
|
errorMessage = "The Microsoft DirectPlay object pointer is invalid.";
|
||||||
break;
|
break;
|
||||||
case DPNERR_UNINITIALIZED:
|
case DPNERR_UNINITIALIZED:
|
||||||
qWarning() << "This function is not allowed on this object.";
|
errorMessage = "This function is not allowed on this object.";
|
||||||
break;
|
break;
|
||||||
case DPNERR_UNSUPPORTED:
|
case DPNERR_UNSUPPORTED:
|
||||||
qWarning() << "The function or feature is not available in this implementation or on this service provider.";
|
errorMessage = "The function or feature is not available in this implementation or on this service provider.";
|
||||||
break;
|
break;
|
||||||
case DPNERR_NOTHOST:
|
case DPNERR_NOTHOST:
|
||||||
qWarning() << "The client attempted to connect to a nonhost computer. Additionally, this error value may be returned by a nonhost that tried to set the application description.";
|
errorMessage = "The client attempted to connect to a nonhost computer. Additionally, this error value may be returned by a nonhost that tried to set the application description.";
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BlackMisc::CLogMessage().error(errorMessage);
|
||||||
|
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,6 +15,7 @@
|
|||||||
#include "blacksimplugin_freefunctions.h"
|
#include "blacksimplugin_freefunctions.h"
|
||||||
#include "blackmisc/avaircraftsituation.h"
|
#include "blackmisc/avaircraftsituation.h"
|
||||||
#include "blackmisc/coordinategeodetic.h"
|
#include "blackmisc/coordinategeodetic.h"
|
||||||
|
#include "blackmisc/logmessage.h"
|
||||||
#include <QScopedArrayPointer>
|
#include <QScopedArrayPointer>
|
||||||
|
|
||||||
using namespace BlackMisc;
|
using namespace BlackMisc;
|
||||||
@@ -149,8 +150,7 @@ namespace BlackSimPlugin
|
|||||||
nullptr, // pAsyncHandle
|
nullptr, // pAsyncHandle
|
||||||
DPNENUMHOSTS_SYNC ) ) ) // dwFlags
|
DPNENUMHOSTS_SYNC ) ) ) // dwFlags
|
||||||
{
|
{
|
||||||
qWarning() << "Failed to enum hosts!";
|
return printDirectPlayError(hr);
|
||||||
return hr;
|
|
||||||
}
|
}
|
||||||
return hr;
|
return hr;
|
||||||
}
|
}
|
||||||
@@ -165,15 +165,13 @@ namespace BlackSimPlugin
|
|||||||
IID_IDirectPlay8Address,
|
IID_IDirectPlay8Address,
|
||||||
reinterpret_cast<void **>(&m_hostAddress) ) ) )
|
reinterpret_cast<void **>(&m_hostAddress) ) ) )
|
||||||
{
|
{
|
||||||
qWarning() << "Failed to create DirectPlay8Address!";
|
return printDirectPlayError(hr);
|
||||||
return hr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set the SP for our Host Address
|
// Set the SP for our Host Address
|
||||||
if( FAILED( hr = m_hostAddress->SetSP(&CLSID_DP8SP_TCPIP ) ) )
|
if( FAILED( hr = m_hostAddress->SetSP(&CLSID_DP8SP_TCPIP ) ) )
|
||||||
{
|
{
|
||||||
qWarning() << "Failed to set SP!";
|
return printDirectPlayError(hr);
|
||||||
return hr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME: Test if this is also working via network or if we have to use the IP address
|
// FIXME: Test if this is also working via network or if we have to use the IP address
|
||||||
@@ -184,8 +182,7 @@ namespace BlackSimPlugin
|
|||||||
2*(wcslen(hostname) + 1), /*bytes*/
|
2*(wcslen(hostname) + 1), /*bytes*/
|
||||||
DPNA_DATATYPE_STRING ) ) )
|
DPNA_DATATYPE_STRING ) ) )
|
||||||
{
|
{
|
||||||
qWarning() << "Failed to add component!";
|
return printDirectPlayError(hr);
|
||||||
return hr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return hr;
|
return hr;
|
||||||
@@ -217,8 +214,7 @@ namespace BlackSimPlugin
|
|||||||
m_player.pwszName = wszPlayername.data();
|
m_player.pwszName = wszPlayername.data();
|
||||||
if( FAILED( hr = m_directPlayPeer->SetPeerInfo( &m_player, nullptr, nullptr, DPNSETPEERINFO_SYNC ) ) )
|
if( FAILED( hr = m_directPlayPeer->SetPeerInfo( &m_player, nullptr, nullptr, DPNSETPEERINFO_SYNC ) ) )
|
||||||
{
|
{
|
||||||
qWarning() << "Failed to set peer info!";
|
return printDirectPlayError(hr);
|
||||||
return hr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Now set up the Application Description
|
// Now set up the Application Description
|
||||||
@@ -239,8 +235,7 @@ namespace BlackSimPlugin
|
|||||||
nullptr,
|
nullptr,
|
||||||
DPNCONNECT_SYNC ) ) )
|
DPNCONNECT_SYNC ) ) )
|
||||||
{
|
{
|
||||||
qWarning() << "Failed to connect to host!";
|
return printDirectPlayError(hr);
|
||||||
return hr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
MPChangePlayerPlane mpChangePlayerPlane;
|
MPChangePlayerPlane mpChangePlayerPlane;
|
||||||
@@ -267,10 +262,10 @@ namespace BlackSimPlugin
|
|||||||
|
|
||||||
if (m_clientStatus == Disconnected) return hr;
|
if (m_clientStatus == Disconnected) return hr;
|
||||||
|
|
||||||
qDebug() << "Closing connection for " << m_callsign;
|
BlackMisc::CLogMessage(this).debug() << "Closing DirectPlay connection for " << m_callsign;
|
||||||
if( FAILED( hr = m_directPlayPeer->Close(0) ))
|
if( FAILED( hr = m_directPlayPeer->Close(0) ))
|
||||||
{
|
{
|
||||||
qWarning() << "Failed to close connection!";
|
return printDirectPlayError(hr);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_clientStatus = Disconnected;
|
m_clientStatus = Disconnected;
|
||||||
|
|||||||
@@ -14,6 +14,7 @@
|
|||||||
#include "multiplayer_packet_parser.h"
|
#include "multiplayer_packet_parser.h"
|
||||||
#include "multiplayer_packets.h"
|
#include "multiplayer_packets.h"
|
||||||
#include "blackmisc/project.h"
|
#include "blackmisc/project.h"
|
||||||
|
#include "blackmisc/logmessage.h"
|
||||||
#include <QScopedArrayPointer>
|
#include <QScopedArrayPointer>
|
||||||
#include <QVector>
|
#include <QVector>
|
||||||
|
|
||||||
@@ -120,7 +121,7 @@ namespace BlackSimPlugin
|
|||||||
player.pwszName = wszPlayername.data();
|
player.pwszName = wszPlayername.data();
|
||||||
if (FAILED(hr = m_directPlayPeer->SetPeerInfo(&player, nullptr, nullptr, DPNSETPEERINFO_SYNC)))
|
if (FAILED(hr = m_directPlayPeer->SetPeerInfo(&player, nullptr, nullptr, DPNSETPEERINFO_SYNC)))
|
||||||
{
|
{
|
||||||
qWarning() << "Failed to set peer info!";
|
printDirectPlayError(hr);
|
||||||
return hr;
|
return hr;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -138,12 +139,12 @@ namespace BlackSimPlugin
|
|||||||
nullptr, // Player Context
|
nullptr, // Player Context
|
||||||
0))) // dwFlags
|
0))) // dwFlags
|
||||||
{
|
{
|
||||||
qWarning() << "Failed to start hosting!";
|
printDirectPlayError(hr);
|
||||||
return hr;
|
return hr;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
qDebug() << "Host successfully started";
|
BlackMisc::CLogMessage(this).info("Hosting successfully started");
|
||||||
m_hostStatus = Hosting;
|
m_hostStatus = Hosting;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -157,7 +158,7 @@ namespace BlackSimPlugin
|
|||||||
|
|
||||||
if (m_hostStatus == Terminated) return hr;
|
if (m_hostStatus == Terminated) return hr;
|
||||||
|
|
||||||
qDebug() << "Terminating host";
|
BlackMisc::CLogMessage(this).info("Hosting terminated!");
|
||||||
hr = m_directPlayPeer->TerminateSession(nullptr, 0, 0);
|
hr = m_directPlayPeer->TerminateSession(nullptr, 0, 0);
|
||||||
hr = m_directPlayPeer->Close(0);
|
hr = m_directPlayPeer->Close(0);
|
||||||
m_hostStatus = Terminated;
|
m_hostStatus = Terminated;
|
||||||
|
|||||||
Reference in New Issue
Block a user