]> git.mxchange.org Git - flightgear.git/blobdiff - src/MultiPlayer/multiplaymgr.hxx
Fixed an property tieing issue on sim reset.
[flightgear.git] / src / MultiPlayer / multiplaymgr.hxx
index a8c7dae2417701d0794a7b0065747eaaeb9f2b66..8475c0ef125df219c672f690f1521daf4e373a5d 100644 (file)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////
 //
-// multiplaymgr.hpp
+// multiplaymgr.hxx
 //
 // Written by Duncan McCreanor, started February 2003.
 // duncan.mccreanor@airservicesaustralia.com
@@ -20,7 +20,7 @@
 //
 // You should have received a copy of the GNU General Public License
 // along with this program; if not, write to the Free Software
-// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 //
 // $Id$
 //  
 
 #include "mpmessages.hxx"
 
-#ifdef HAVE_CONFIG_H
-#  include <config.h>
-#endif
-
-#include STL_STRING
-SG_USING_STD(string);
+#include <string>
 #include <vector>
-SG_USING_STD(vector);
 
 #include <simgear/compiler.h>
 #include <simgear/props/props.hxx>
-#include <plib/netSocket.h>
 #include <Main/globals.hxx>
+#include <simgear/io/raw_socket.hxx>
+#include <simgear/structure/subsystem_mgr.hxx>
 
 #include <AIModel/AIMultiplayer.hxx>
 
 struct FGExternalMotionInfo;
 
-class FGMultiplayMgr 
+class FGMultiplayMgr : public SGSubsystem
 {
 public:
+
   struct IdPropertyList {
     unsigned id;
     const char* name;
+    simgear::props::Type type;
   };
-  static IdPropertyList sIdPropertyList[];
+  static const IdPropertyList sIdPropertyList[];
+  static const unsigned numProperties;
 
+  static const IdPropertyList* findProperty(unsigned id);
+  
   FGMultiplayMgr();
   ~FGMultiplayMgr();
-  bool init(void);
+  
+  virtual void init(void);
+  virtual void update(double dt);
+  
   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:
+  union MsgBuf;
   FGAIMultiplayer* addMultiplayer(const std::string& callsign,
                                   const std::string& modelName);
   FGAIMultiplayer* getMultiplayer(const std::string& callsign);
+  void FillMsgHdr(T_MsgHdr *MsgHdr, int iMsgId, unsigned _len = 0u);
+  void ProcessPosMsg(const MsgBuf& Msg, const simgear::IPAddress& SenderAddress,
+                     long stamp);
+  void ProcessChatMsg(const MsgBuf& Msg, const simgear::IPAddress& SenderAddress);
+  bool isSane(const FGExternalMotionData& motionInfo);
 
   /// maps from the callsign string to the FGAIMultiplayer
   typedef std::map<std::string, SGSharedPtr<FGAIMultiplayer> > MultiPlayerMap;
   MultiPlayerMap mMultiPlayerMap;
 
-  netSocket* mSocket;
-  netAddress mServer;
+  simgear::Socket* mSocket;
+  simgear::IPAddress mServer;
   bool mHaveServer;
   bool mInitialised;
-  string mCallsign;
+  std::string mCallsign;
 };
 
 #endif