X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FMultiPlayer%2Fmultiplaymgr.hxx;h=ca9072e405fb70216365b4255799866964fc70ea;hb=9bb55e78be6c6a9da4be26a3671e7d4bf6332d50;hp=857557cfd1b7ec7ce9a09ea4ceb172ae8faa66f3;hpb=5bd2ef1edbbe61e9c5775810ddf4f0ef546f6b3c;p=flightgear.git diff --git a/src/MultiPlayer/multiplaymgr.hxx b/src/MultiPlayer/multiplaymgr.hxx index 857557cfd..ca9072e40 100644 --- a/src/MultiPlayer/multiplaymgr.hxx +++ b/src/MultiPlayer/multiplaymgr.hxx @@ -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$ // @@ -31,7 +31,6 @@ #define MULTIPLAYTXMGR_HID "$Id$" -#include "mpplayer.hxx" #include "mpmessages.hxx" #ifdef HAVE_CONFIG_H @@ -48,52 +47,50 @@ SG_USING_STD(vector); #include #include
-// Maximum number of players that can exist at any time -// FIXME: use a list instead -#define MAX_PLAYERS 10 +#include + +struct FGExternalMotionInfo; class FGMultiplayMgr { public: - FGMultiplayMgr(); - ~FGMultiplayMgr(); - bool init(void); - void Close(void); - // transmitter - void SendMyPosition (const double lat, const double lon, const double alt, - const double heading, const double roll, const double pitch, - const double speedN, const double speedE, const double speedD, - const double left_aileron, const double right_aileron, const double elevator, const double rudder, - //const double rpms[6], - const double rateH, const double rateR, const double rateP, - const double accN, const double accE, const double accD - ); - void SendPropMessage (const string &property, SGPropertyNode::Type type, double value); - 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 ProcessPropMsg ( const char *Msg, netAddress & SenderAddress ); - void Update(void); - /* getters/setters */ - bool getSendAllProps(); - void setSendAllProps(bool s); - bool send_all_props; + struct IdPropertyList { + unsigned id; + const char* name; + SGPropertyNode::Type type; + }; + 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 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 > MultiPlayerMap; + MultiPlayerMap mMultiPlayerMap; + + netSocket* mSocket; + netAddress mServer; + bool mHaveServer; + bool mInitialised; + string mCallsign; }; #endif