X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FMultiPlayer%2Fmultiplaymgr.hxx;h=3b16d9022f17d5bb1ae45142ffaa96b6e6564dc9;hb=69baf3a9d6adb645325e7bfc0305b09604379d9f;hp=ca9072e405fb70216365b4255799866964fc70ea;hpb=8a67faaf5a3d6e11ad2a55ea859959976c02a1f6;p=flightgear.git diff --git a/src/MultiPlayer/multiplaymgr.hxx b/src/MultiPlayer/multiplaymgr.hxx index ca9072e40..3b16d9022 100644 --- a/src/MultiPlayer/multiplaymgr.hxx +++ b/src/MultiPlayer/multiplaymgr.hxx @@ -1,6 +1,6 @@ ////////////////////////////////////////////////////////////////////// // -// multiplaymgr.hpp +// multiplaymgr.hxx // // Written by Duncan McCreanor, started February 2003. // duncan.mccreanor@airservicesaustralia.com @@ -31,66 +31,81 @@ #define MULTIPLAYTXMGR_HID "$Id$" -#include "mpmessages.hxx" -#ifdef HAVE_CONFIG_H -# include -#endif - -#include STL_STRING -SG_USING_STD(string); +#include #include -SG_USING_STD(vector); +#include #include #include -#include -#include
- -#include +#include +#include -struct FGExternalMotionInfo; +struct FGExternalMotionData; +class MPPropertyListener; +struct T_MsgHdr; +class FGAIMultiplayer; -class FGMultiplayMgr +class FGMultiplayMgr : public SGSubsystem { -public: - - struct IdPropertyList { - unsigned id; - const char* name; - SGPropertyNode::Type type; - }; - static IdPropertyList sIdPropertyList[]; - +public: FGMultiplayMgr(); ~FGMultiplayMgr(); - bool init(void); - void Close(void); + + virtual void init(void); + virtual void update(double dt); + + virtual void shutdown(void); + virtual void reinit(); + // transmitter - void SendMyPosition(const FGExternalMotionData& motionInfo); - void SendTextMessage(const string &sMsgText); - void FillMsgHdr(T_MsgHdr *MsgHdr, int iMsgId, unsigned _len = 0u); + void SendTextMessage(const std::string &sMsgText); // receiver - void ProcessPosMsg(const char *Msg, netAddress & SenderAddress, - unsigned len, long stamp); - void ProcessChatMsg(const char *Msg, netAddress & SenderAddress); - void Update(void); private: + friend class MPPropertyListener; + + void setPropertiesChanged() + { + mPropertiesChanged = true; + } + + void findProperties(); + + void Send(); + void SendMyPosition(const FGExternalMotionData& motionInfo); + + 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 > MultiPlayerMap; MultiPlayerMap mMultiPlayerMap; - netSocket* mSocket; - netAddress mServer; + std::auto_ptr mSocket; + simgear::IPAddress mServer; bool mHaveServer; bool mInitialised; - string mCallsign; + std::string mCallsign; + + // Map between the property id's from the multiplayers network packets + // and the property nodes + typedef std::map > PropertyMap; + PropertyMap mPropertyMap; + + bool mPropertiesChanged; + MPPropertyListener* mListener; + + double mDt; // reciprocal of /sim/multiplay/tx-rate-hz + double mTimeUntilSend; }; #endif