X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FMultiPlayer%2Fmultiplaymgr.hxx;h=96e56f2428a29f8e56f3313650be78b978029331;hb=ad13e4f3b42c53410cb695d2dd0083af77addb2e;hp=63add6b7702a395ab94170d0d93c30b87c42832a;hpb=029dda3297e3697438e1a58188527cbae90beebe;p=flightgear.git diff --git a/src/MultiPlayer/multiplaymgr.hxx b/src/MultiPlayer/multiplaymgr.hxx index 63add6b77..96e56f242 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,54 +31,69 @@ #define MULTIPLAYTXMGR_HID "$Id$" -#include "mpplayer.hxx" #include "mpmessages.hxx" #ifdef HAVE_CONFIG_H # include #endif -#include STL_STRING -SG_USING_STD(string); +#include +using std::string; #include -SG_USING_STD(vector); +using std::vector; #include +#include #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 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; + simgear::props::Type type; + }; + static const IdPropertyList sIdPropertyList[]; + static const unsigned numProperties; + + static const IdPropertyList* findProperty(unsigned id); + + FGMultiplayMgr(); + ~FGMultiplayMgr(); + bool init(void); + void Close(void); + // transmitter + void SendMyPosition(const FGExternalMotionData& motionInfo); + void SendTextMessage(const string &sMsgText); + // receiver + 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; + 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 netAddress& SenderAddress, + long stamp); + void ProcessChatMsg(const MsgBuf& Msg, const netAddress& SenderAddress); + + /// 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