]> git.mxchange.org Git - flightgear.git/blobdiff - src/MultiPlayer/mpplayer.hxx
Mathias Fröhlich:
[flightgear.git] / src / MultiPlayer / mpplayer.hxx
index 04c5b648ff34920a3265fbdce86e2f733c6ed79f..38165720798da403ef99f2a3680a0b71c0e3a075 100644 (file)
@@ -44,6 +44,7 @@
 #include <plib/sg.h>
 #include <plib/netSocket.h>
 #include <simgear/io/sg_socket_udp.hxx>
+#include <simgear/props/props.hxx>
 #include <time.h>
 
 #include STL_STRING
@@ -52,26 +53,22 @@ SG_USING_STD(string);
 // Number of seconds before a player is consider to be lost
 #define TIME_TO_LIVE 10
 
+class FGAIMultiplayer;
 
-class ssgEntity;
-class ssgPlacementTransform;
-
-
-class MPPlayer {
+class MPPlayer 
+{
 public:
-
-    /** Constructor */
     MPPlayer();
-
-    /** Destructor. */
     ~MPPlayer();
-
     /** Enumeration of the states for the player's data */
-    enum PlayerDataState {PLAYER_DATA_NOT_AVAILABLE = 0, PLAYER_DATA_AVAILABLE, PLAYER_DATA_EXPIRED};
-
+    enum PlayerDataState
+    {
+        PLAYER_DATA_NOT_AVAILABLE = 0, 
+        PLAYER_DATA_AVAILABLE, 
+        PLAYER_DATA_EXPIRED
+    };
     /** Player data state */
     typedef enum PlayerDataState TPlayerDataState;
-
     /** Initialises the class.
     * @param sIP IP address or host name for sending data to the player
     * @param sPort Port number for sending data to the player
@@ -80,84 +77,84 @@ public:
     * @param bLocalPlayer True if this player is the local player, else false
     * @return True if class opens successfully, else false
     */
-    bool Open(const string &sIP, const int &iPort, const string &sCallsign,
-              const string &sModelName, const bool bLocalPlayer);
-
+    bool Open(const string &IP, const int &Port, const string &Callsign,
+              const string &ModelName, const bool LocalPlayer);
     /** Closes the player connection */
     void Close(void);
-
+    /** Checks if the time is valid for a position update and perhaps sets the time offset
+     */
+    bool CheckTime(int time, int timeusec);
     /** Sets the positioning matrix held for this player
-    * @param PlayerPosMat4 Matrix for positioning player's aircraft
     */
-    void SetPosition(const sgQuat PlayerOrientation,
-                     const sgdVec3 PlayerPosition);
-
+    void SetPosition(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);
+    /** Sets a property for this player
+    */
+    void SetProperty(string property, SGPropertyNode::Type type, double val);
     /** Transform and place model for player
     */
     TPlayerDataState Draw(void);
-
     /** Returns the callsign for the player
     * @return Aircraft's callsign
     */
     string Callsign(void) const;
-
     /** Compares the player's callsign with the given callsign
     * @param sCallsign Callsign to compare
     * @return True if callsign matches
     */
-    bool CompareCallsign(const char *sCallsign) const;
-
+    bool CompareCallsign(const char *Callsign) const;
     /** Populates a position message for the player
     * @param MsgHdr Header to be populated
     * @param PosMsg Position message to be populated
     */
     void FillPosMsg(T_MsgHdr *MsgHdr, T_PositionMsg *PosMsg);
-
     /** Populates a mesage header with information for the player
     * @param MsgHdr Header to be populated
     * @param iMsgId Message type identifier to insert into header
     */
     void FillMsgHdr(T_MsgHdr *MsgHdr, const int iMsgId);
-
-
 private:
-
-    /** Loads the model of the aircraft */
-    void LoadModel(void);
-
-    /** True if object is initialised */
-    bool m_bInitialised;
-
-    /** Position of the player's aircraft wrt the earth fixed global system */
-    sgdVec3 m_ModelPosition;
-
-    /** Orientation the player's aircraft wrt the earth fixed global system */
-    sgQuat m_ModelOrientation;
-
-    /** Used to remove player if no activity */
-    time_t m_LastUpdate;
-
-    /** Set when the player data is updated and cleared when read */
-    bool m_bUpdated;
-
-    /** Player's callsign */
-    string m_sCallsign;
-
-    /** Aircraft model name for player */
-    string m_sModelName;
-
-    /** The player's loaded model */
-    ssgEntity *m_Model;
-
-    /** Model transform */
-    ssgPlacementTransform *m_ModelTrans;
-
-    /** True if this player is the local player */
-    bool m_bLocalPlayer;
-
-    /** Address information for the player */
-    netAddress m_PlayerAddress;
-
+    void    LoadAI(void);       // Loads the plane into the AI core
+    bool    m_Initialised;      // True if object is initialised 
+    
+    double  m_lat;              // location, orientation, etc...
+    double  m_lon;              // ...
+    double  m_alt;              // ...
+    double  m_hdg;              // ...
+    double  m_roll;             // ...
+    double  m_pitch;            // ...
+    double  m_speedN;           // ...
+    double  m_speedE;           // ...
+    double  m_speedD;           // ...
+    double  m_accN;             // ...
+    double  m_accE;             // ...
+    double  m_accD;             // ...
+    double  m_left_aileron;     // ...
+    double  m_right_aileron;     // ...
+    double  m_elevator;         // ...
+    double  m_rudder;           // ...
+    //double  m_rpms[6];          // ...
+    double  m_rateH;            // ...
+    double  m_rateR;            // ...
+    double  m_rateP;            // ...
+
+    time_t  m_LastUpdate;       // last time update data received
+    int     m_LastTime;         // last seconds according to the packet
+    int     m_LastUTime;        // last microseconds according to the packet
+    double  m_Elapsed;          // Elapsed other-side time between responses
+    double  m_TimeOffset;       // the offset to aim for
+    double  m_LastOffset;       // the last offset we got
+    bool    m_Updated;          // Set when the player data is updated
+    string  m_Callsign;         // players callsign
+    bool    m_LocalPlayer;      // true if player is the local player
+    string  m_ModelName;        // Aircraft model name for player
+    netAddress m_PlayerAddress; // Address information for the player
+    FGAIMultiplayer *m_AIModel; // The AI model of this aircraft
 };
 
 #endif