Attached is the latest update (as a diff) for the multiplayer code. It 
contains changes to the model unloading/loading and other minor 
corrections/comment changes.

Duncan McCreanor.
? mplaydiff.txt
Index: mpmessages.hxx
===================================================================
RCS file: /var/cvs/FlightGear-0.9/FlightGear/src/MultiPlayer/mpmessages.hxx,v
retrieving revision 1.1
diff -r1.1 mpmessages.hxx
0a1,23
> // mpmessages.hxx -- Message definitions for multiplayer communications
> // within a multiplayer Flightgear
> //
> // Written by Duncan McCreanor, started February 2003.
> // [EMAIL PROTECTED]
> //
> // Copyright (C) 2003  Airservices Australia
> //
> // This program is free software; you can redistribute it and/or
> // modify it under the terms of the GNU General Public License as
> // published by the Free Software Foundation; either version 2 of the
> // License, or (at your option) any later version.
> //
> // This program is distributed in the hope that it will be useful, but
> // WITHOUT ANY WARRANTY; without even the implied warranty of
> // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> // General Public License for more details.
> //
> // 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.
> //
> 
Index: mpplayer.cxx
===================================================================
RCS file: /var/cvs/FlightGear-0.9/FlightGear/src/MultiPlayer/mpplayer.cxx,v
retrieving revision 1.2
diff -r1.2 mpplayer.cxx
47a48
> #include <plib/sg.h>
68a70
>     m_sCallsign = "none";
127d128
< 
129,130c130,142
<     if (!m_bLocalPlayer) {
<         globals->get_scenery()->get_scene_graph()->removeKid(m_ModelSel);
---
>     if (m_bInitialised && !m_bLocalPlayer) {
> 
>         // Disconnect the model from the transform, then the transform from the scene.
>         m_ModelTrans->removeKid(m_Model);
>         globals->get_scenery()->get_aircraft_branch()->removeKid( m_ModelTrans);
> 
>         // Flush the model loader so that it erases the model from its list of
>         // models.
>         globals->get_model_loader()->flush();
> 
>         // Assume that plib/ssg deletes the model and transform as their
>         // refcounts should be zero.
> 
135a148
>     m_sCallsign = "none";
150c163
<         memcpy(m_ModelPos, PlayerPosMat4, sizeof(sgMat4));
---
>         sgCopyMat4(m_ModelPos, PlayerPosMat4);
162,163c175
< * The state of the player (old, initialised etc)
< * is returned.
---
> * The state of the player's data is returned.
165c177
< int MPPlayer::Draw(void) {
---
> MPPlayer::TPlayerDataState MPPlayer::Draw(void) {
167c179
<     int iResult = PLAYER_DATA_NOT_AVAILABLE;
---
>     MPPlayer::TPlayerDataState eResult = PLAYER_DATA_NOT_AVAILABLE;
171c183
<     if (m_bInitialised) {
---
>     if (m_bInitialised && !m_bLocalPlayer) {
177d188
<                 m_ModelSel->select(1);
181c192
<                 iResult = PLAYER_DATA_AVAILABLE;
---
>                 eResult = PLAYER_DATA_AVAILABLE;
190c201
<             iResult = PLAYER_DATA_EXPIRED;
---
>             eResult = PLAYER_DATA_EXPIRED;
195c206
<     return iResult;
---
>     return eResult;
230,231c241,245
<    m_ModelSel = new ssgSelector;
<    m_ModelTrans = new ssgTransform;
---
>     m_ModelTrans = new ssgTransform;
> 
>     // Load the model
>     m_Model = globals->get_model_loader()->load_model(m_sModelName);
>     m_Model->clrTraversalMaskBits( SSGTRAV_HOT );
233,238c247,248
<    ssgEntity *Model = globals->get_model_loader()->load_model(m_sModelName);
<    Model->clrTraversalMaskBits( SSGTRAV_HOT );
<    m_ModelTrans->addKid( Model );
<    m_ModelSel->addKid( m_ModelTrans );
<    ssgFlatten( Model );
<    ssgStripify( m_ModelSel );
---
>     // Add model to transform
>     m_ModelTrans->addKid( m_Model );
240,241c250,255
<    globals->get_scenery()->get_scene_graph()->addKid( m_ModelSel );
<    globals->get_scenery()->get_scene_graph()->addKid(  Model );
---
>     // Optimise model and transform
>     ssgFlatten( m_Model );
>     ssgStripify( m_ModelTrans );
> 
>     // Place on scene under aircraft branch
>     globals->get_scenery()->get_aircraft_branch()->addKid( m_ModelTrans );
257,258c271
< 
<     memcpy(PosMsg->PlayerPos, m_ModelPos, sizeof(sgMat4));
---
>     sgCopyMat4(PosMsg->PlayerPos, m_ModelPos);
Index: mpplayer.hxx
===================================================================
RCS file: /var/cvs/FlightGear-0.9/FlightGear/src/MultiPlayer/mpplayer.hxx,v
retrieving revision 1.1
diff -r1.1 mpplayer.hxx
32c32,38
< * Description:
---
> * Description: This class holds information about a player in a
> * multiplayer game. The model for a remote player is loaded and
> * added onto the aircraft branch of the scene on calling Open.
> * The model is unloaded from the scene when Close is called
> * or the object is deleted. The model's positioning transform is
> * updated by calling SetPosition. The updated position transform
> * is applied to the model on the scene by calling Draw.
50,52d55
< #define PLAYER_DATA_NOT_AVAILABLE 0
< #define PLAYER_DATA_AVAILABLE 1
< #define PLAYER_DATA_EXPIRED 2
62a66,71
>     /** Enumeration of the states for the player's data */
>     enum PlayerDataState {PLAYER_DATA_NOT_AVAILABLE = 0, PLAYER_DATA_AVAILABLE, PLAYER_DATA_EXPIRED};
> 
>     /** Player data state */
>     typedef enum PlayerDataState TPlayerDataState;
> 
74,76d82
<     /** Initialises the player count for all instances of this object to zero. */
<     static void ResetPlayerCnt(void);
< 
87c93
<     int Draw(void);
---
>     TPlayerDataState Draw(void);
100,102d105
<     /** Loads the model of the aircraft */
<     void LoadModel(void);
< 
117a121,123
>     /** Loads the model of the aircraft */
>     void LoadModel(void);
> 
133c139
<     /** Aircraft model for player */
---
>     /** Aircraft model name for player */
136,137c142,143
<     /** Simgear model selection */
<     ssgSelector *m_ModelSel;
---
>     /** The player's loaded model */
>     ssgEntity *m_Model;
139c145
<     /** Simgear model transform */
---
>     /** Model transform */
Index: multiplayrxmgr.cxx
===================================================================
RCS file: /var/cvs/FlightGear-0.9/FlightGear/src/MultiPlayer/multiplayrxmgr.cxx,v
retrieving revision 1.6
diff -r1.6 multiplayrxmgr.cxx
241c241
<                     if (m_sCallsign != string(MsgHdr->sCallsign)) {
---
>                     if (m_sCallsign != MsgHdr->sCallsign) {
335c335
<     int iPlayerDataState;
---
>     MPPlayer::TPlayerDataState ePlayerDataState;
340c340
<             iPlayerDataState = m_Player[iPlayerId]->Draw();
---
>             ePlayerDataState = m_Player[iPlayerId]->Draw();
344c344,346
<             if (iPlayerDataState == PLAYER_DATA_EXPIRED) {
---
>             if (ePlayerDataState == MPPlayer::PLAYER_DATA_EXPIRED) {
>                 SG_LOG( SG_NETWORK, SG_BULK, "FGMultiplayRxMgr::Update - Deleting player from game. Callsign: "
>                         << m_Player[iPlayerId]->Callsign() );
Index: multiplaytxmgr.cxx
===================================================================
RCS file: /var/cvs/FlightGear-0.9/FlightGear/src/MultiPlayer/multiplaytxmgr.cxx,v
retrieving revision 1.4
diff -r1.4 multiplaytxmgr.cxx
126c126
<                 if (!mLocalPlayer->Open(fgGetString("/sim/multiplay/rxaddress"), fgGetInt("/sim/multiplay/rxport"),
---
>                 if (!mLocalPlayer->Open(fgGetString("/sim/multiplay/rxhost"), fgGetInt("/sim/multiplay/rxport"),

Reply via email to