]> git.mxchange.org Git - flightgear.git/blobdiff - src/MultiPlayer/multiplaymgr.hxx
Suppress a recurrent "no error" message, at least with MSVC
[flightgear.git] / src / MultiPlayer / multiplaymgr.hxx
index 63add6b7702a395ab94170d0d93c30b87c42832a..a8c7dae2417701d0794a7b0065747eaaeb9f2b66 100644 (file)
@@ -31,7 +31,6 @@
 
 #define MULTIPLAYTXMGR_HID "$Id$"
 
-#include "mpplayer.hxx"
 #include "mpmessages.hxx"
 
 #ifdef HAVE_CONFIG_H
@@ -44,41 +43,52 @@ SG_USING_STD(string);
 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