#define MULTIPLAYTXMGR_HID "$Id$"
-#include "mpplayer.hxx"
#include "mpmessages.hxx"
#ifdef HAVE_CONFIG_H
SG_USING_STD(vector);
#include <simgear/compiler.h>
+#include <simgear/props/props.hxx>
#include <plib/netSocket.h>
#include <Main/globals.hxx>
-// Maximum number of players that can exist at any time
-// FIXME: use a list<mplayer> instead
-#define MAX_PLAYERS 10
+#include <AIModel/AIMultiplayer.hxx>
+
+struct FGExternalMotionInfo;
class FGMultiplayMgr
{
public:
- FGMultiplayMgr();
- ~FGMultiplayMgr();
- bool init(void);
- void Close(void);
- // transmitter
- void SendMyPosition (const sgQuat PlayerOrientation,
- const sgdVec3 PlayerPosition);
- void SendTextMessage (const string &sMsgText) const;
- // receiver
- void ProcessData(void);
- void ProcessPosMsg ( const char *Msg, netAddress & SenderAddress );
- void ProcessChatMsg ( const char *Msg, netAddress & SenderAddress );
- void Update(void);
+ struct IdPropertyList {
+ unsigned id;
+ const char* name;
+ };
+ static IdPropertyList sIdPropertyList[];
+
+ FGMultiplayMgr();
+ ~FGMultiplayMgr();
+ bool init(void);
+ void Close(void);
+ // transmitter
+ void SendMyPosition(const FGExternalMotionData& motionInfo);
+ void SendTextMessage(const string &sMsgText);
+ void FillMsgHdr(T_MsgHdr *MsgHdr, int iMsgId, unsigned _len = 0u);
+
+ // receiver
+ void ProcessPosMsg(const char *Msg, netAddress & SenderAddress,
+ unsigned len, long stamp);
+ void ProcessChatMsg(const char *Msg, netAddress & SenderAddress);
+ void Update(void);
+
private:
- typedef vector<MPPlayer*> t_MPClientList;
- typedef t_MPClientList::iterator t_MPClientListIterator;
- MPPlayer* m_LocalPlayer;
- netSocket* m_DataSocket;
- netAddress m_Server;
- bool m_HaveServer;
- bool m_Initialised;
- t_MPClientList m_MPClientList;
- string m_RxAddress;
- int m_RxPort;
- string m_Callsign;
+ FGAIMultiplayer* addMultiplayer(const std::string& callsign,
+ const std::string& modelName);
+ FGAIMultiplayer* getMultiplayer(const std::string& callsign);
+
+ /// maps from the callsign string to the FGAIMultiplayer
+ typedef std::map<std::string, SGSharedPtr<FGAIMultiplayer> > MultiPlayerMap;
+ MultiPlayerMap mMultiPlayerMap;
+
+ netSocket* mSocket;
+ netAddress mServer;
+ bool mHaveServer;
+ bool mInitialised;
+ string mCallsign;
};
#endif