// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
//
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#ifdef FG_MPLAYER_AS
+
/******************************************************************
* $Id$
*
******************************************************************/
#include <sys/types.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
+#if !(defined(_MSC_VER) || defined(__MINGW32__))
+# include <sys/socket.h>
+# include <netinet/in.h>
+# include <arpa/inet.h>
+#endif
#include <plib/netSocket.h>
#include <stdlib.h>
+
+#include <simgear/debug/logstream.hxx>
#include <Main/fg_props.hxx>
+
#include "multiplaytxmgr.hxx"
#include "mpmessages.hxx"
#include "mpplayer.hxx"
******************************************************************/
FGMultiplayTxMgr::FGMultiplayTxMgr() {
- int iPlayerCnt; // Count of players in player array
+ // int iPlayerCnt; // Count of players in player array
// Initialise private members
m_bInitialised = false;
string sTxAddress = fgGetString("/sim/multiplay/txhost");
iTxPort = fgGetInt("/sim/multiplay/txport");
- cout << "FGMultiplayTxMgr::init - txaddress= " << sTxAddress << endl;
- cout << "FGMultiplayTxMgr::init - txport= " << iTxPort << endl;
+ SG_LOG( SG_NETWORK, SG_INFO, "FGMultiplayTxMgr::init - txaddress= "
+ << sTxAddress );
+ SG_LOG( SG_NETWORK, SG_INFO, "FGMultiplayTxMgr::init - txport= "
+ << iTxPort );
if (iTxPort > 0) {
mDataTxSocket = new netSocket();
if (!mDataTxSocket->open(false)) {
// Failed to open tx socket
- cerr << "FGMultiplayTxMgr::init - Failed to create data transmit socket" << endl;
+ SG_LOG( SG_NETWORK, SG_ALERT, "FGMultiplayTxMgr::init - Failed to create data transmit socket" );
bSuccess = false;
} else {
mDataTxSocket->setBroadcast(true);
if (mDataTxSocket->connect(sTxAddress.c_str(), iTxPort) != 0) {
// Failed to connect tx socket
- cerr << "FGMultiplayTxMgr::init - Failed to connect data transmit socket" << endl;
+ SG_LOG( SG_NETWORK, SG_ALERT, "FGMultiplayTxMgr::init - Failed to connect data transmit socket" );
bSuccess = false;
}
}
// Create a player object for the local player
if (bSuccess) {
mLocalPlayer = new MPPlayer();
- if (!mLocalPlayer->Open(fgGetString("/sim/multiplay/rxaddress"), fgGetInt("/sim/multiplay/rxport"),
+ if (!mLocalPlayer->Open(fgGetString("/sim/multiplay/rxhost"), fgGetInt("/sim/multiplay/rxport"),
fgGetString("/sim/multiplay/callsign"), fgGetString("/sim/model/path"), true)) {
- cerr << "FGMultiplayTxMgr::init - Failed to create player object for local player" << endl;
+ SG_LOG( SG_NETWORK, SG_ALERT, "FGMultiplayTxMgr::init - Failed to create player object for local player" );
bSuccess = false;
}
}
// If Tx port == zero then don't initialise
} else {
- cout << "FGMultiplayTxMgr::init - Tx Port is zero. Multiplay out disabled." << endl;
+ SG_LOG( SG_NETWORK, SG_INFO, "FGMultiplayTxMgr::init - Tx Port is zero. Multiplay out disabled." );
bSuccess = false;
}
m_bInitialised = bSuccess;
} else {
- cerr << "FGMultiplayTxMgr::init - Attempt to init object that is already opened" << endl;
+ SG_LOG( SG_NETWORK, SG_WARN, "FGMultiplayTxMgr::init - Attempt to init object that is already opened" );
bSuccess = false;
}
* Name: SendMyPosition
* Description: Sends the position data for the local position.
******************************************************************/
-void FGMultiplayTxMgr::SendMyPosition(const sgMat4 PlayerPosMat4) {
+void FGMultiplayTxMgr::SendMyPosition(const sgQuat PlayerOrientation,
+ const sgdVec3 PlayerPosition) {
T_MsgHdr MsgHdr;
T_PositionMsg PosMsg;
char sMsg[sizeof(T_MsgHdr) + sizeof(T_PositionMsg)];
if (m_bInitialised) {
- mLocalPlayer->SetPosition(PlayerPosMat4);
+ mLocalPlayer->SetPosition(PlayerOrientation, PlayerPosition);
mLocalPlayer->FillPosMsg(&MsgHdr, &PosMsg);
memcpy(sMsg, &MsgHdr, sizeof(T_MsgHdr));
memcpy(sMsg + sizeof(T_MsgHdr), &PosMsg, sizeof(T_PositionMsg));
******************************************************************/
void FGMultiplayTxMgr::SendTextMessage(const string &sMsgText) const {
- bool bResult = false;
+ // bool bResult = false;
T_MsgHdr MsgHdr;
T_ChatMsg ChatMsg;
- int iNextBlockPosition = 0;
+ unsigned int iNextBlockPosition = 0;
char sMsg[sizeof(T_MsgHdr) + sizeof(T_ChatMsg)];
if (m_bInitialised) {
}
+#endif // FG_MPLAYER_AS
+