]> git.mxchange.org Git - flightgear.git/blobdiff - src/MultiPlayer/mpplayer.cxx
- don't abort if remote model isn't installed; output missing model's
[flightgear.git] / src / MultiPlayer / mpplayer.cxx
index 6023274e8111d154df9084f5b4bb90a199c312dd..20b255ad56a5256ba6641f763b2f383154c2466f 100644 (file)
 // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 //
 
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#ifdef FG_MPLAYER_AS
 
 /******************************************************************
 * $Id$
@@ -38,7 +43,7 @@
 #include "mpplayer.hxx"
 
 #include <stdlib.h>
-#ifndef _MSC_VER
+#if !(defined(_MSC_VER) || defined(__MINGW32__))
 # include <netdb.h>
 # include <sys/socket.h>
 # include <netinet/in.h>
@@ -47,8 +52,9 @@
 #include <plib/netSocket.h>
 #include <plib/sg.h>
 
+#include <simgear/scene/model/modellib.hxx>
+
 #include <Main/globals.hxx>
-#include <Model/loader.hxx>
 #include <Scenery/scenery.hxx>
 
 
@@ -101,15 +107,18 @@ bool MPPlayer::Open(const string &sAddress, const int &iPort, const string &sCal
 
         // If the player is remote then load the model
         if (!bLocalPlayer) {
-
-             LoadModel();
-
+             try {
+                 LoadModel();
+             } catch (...) {
+                 SG_LOG( SG_NETWORK, SG_ALERT, "Failed to load remote model '" << sModelName << "'." );
+                 return false;
+             }
         }
 
         m_bInitialised = bSuccess;
 
     } else {
-        cerr << "MPPlayer::Open - Attempt to open an already open player connection." << endl;
+        SG_LOG( SG_NETWORK, SG_ALERT, "MPPlayer::Open - Attempt to open an already open player connection." );
         bSuccess = false;
     }
 
@@ -135,7 +144,7 @@ void MPPlayer::Close(void) {
 
         // Flush the model loader so that it erases the model from its list of
         // models.
-        globals->get_model_loader()->flush();
+        globals->get_model_lib()->flush1();
 
         // Assume that plib/ssg deletes the model and transform as their
         // refcounts should be zero.
@@ -241,7 +250,10 @@ void MPPlayer::LoadModel(void) {
     m_ModelTrans = new ssgTransform;
 
     // Load the model
-    m_Model = globals->get_model_loader()->load_model(m_sModelName);
+    m_Model = globals->get_model_lib()->load_model( globals->get_fg_root(),
+                                                    m_sModelName,
+                                                    globals->get_props(),
+                                                    globals->get_sim_time_sec() );
     m_Model->clrTraversalMaskBits( SSGTRAV_HOT );
 
     // Add model to transform
@@ -307,3 +319,5 @@ void MPPlayer::FillMsgHdr(T_MsgHdr *MsgHdr, const int iMsgId) {
 
 }
 
+#endif // FG_MPLAYER_AS
+