[BACK] Return to client.cpp CVS log [TXT][DIR] Up to Nevrax / code / client

Diff for /code/client/Attic/client.cpp between version 1.7 and 1.8

version 1.7, 2000/11/23 16:41:20 version 1.8, 2000/11/24 14:17:35
Line 45 
Line 45 
 using namespace NL3D; using namespace NL3D;
  
  
  #ifdef NL_OS_WINDOWS
  CFontGenerator fontGen("\\\\server\\code\\fonts\\arialuni.ttf");
  #else
  CFontGenerator fontGen("arialuni.ttf");
  #endif
  
  
 /** /**
  *      login  *      login
  */  */
 CLogUserId login(NL3D::CScene * scene, uint w, uint h) CLogUserId login(NL3D::CScene * scene,
                                   NL3D::CFontGenerator * fontGenerator,
                                   uint w, uint h)
 { {
         CLoginInterface logscreen;         CLoginInterface logscreen(scene, fontGenerator, w, h);
         logscreen.init(scene, w, h); 
         return logscreen.log();         return logscreen.log();
 } }
  
  
 /** 
  *      connect 
  */ 
  
  
 /** /**
  *      connectToLS  *      connectToLS
Line 74 
Line 77 
         {         {
                 server.connect(servaddr);                 server.connect(servaddr);
         }         }
         catch(Exception e)         catch(Exception)
         {         {
                 return false;                 return false;
         }         }
Line 112 
Line 115 
         }         }
  
         server.close();         server.close();
         if(ok)  
                 return true;         return ok==1;
         else 
                 return false; 
 } }
  
  
 /** /**
  *      chooseLanguage  *      chooseLanguage
  */  */
 uint chooseLanguage(NL3D::CScene * scene, uint w, uint h) sint chooseLanguage(NL3D::CScene * scene,
                                          NL3D::CFontGenerator * fontGenerator,
                                          uint w, uint h)
 { {
         CLanguageInterface languageScreen;         CLanguageInterface languageScreen(scene, fontGenerator, w, h);
         languageScreen.init(scene, w, h); 
         return languageScreen.choose();         return languageScreen.choose();
 } }
  
Line 134 
Line 136 
 /** /**
  *      chooseShard  *      chooseShard
  */  */
 uint chooseShard(NL3D::CScene * scene, uint w, uint h,  sint chooseShard(NL3D::CScene * scene,
                                   NL3D::CFontGenerator * fontGenerator,
                                   uint w, uint h,
                                  const std::vector<std::string>& shards)                                  const std::vector<std::string>& shards)
 { {
         CShardsListInterface shardListScreen;         CShardsListInterface shardListScreen(scene, fontGenerator, w, h, shards);
         shardListScreen.init(scene, w, h, shards); 
         return shardListScreen.choose();         return shardListScreen.choose();
 } }
  
  
  enum TState
  {
          LANGUAGE,
          LOGIN,
          CONNECT,
          SHARD
  };
  
  
 /****************************************************************\ /****************************************************************\
Line 151 
Line 160 
 \****************************************************************/ \****************************************************************/
 void main() void main()
 { {
         // synchronize time with server         try
         CUniTime::syncUniTimeFromService();         {
  
         // init scene         // init scene
         uint w = 800;         uint w = 800;
         uint h = 600;         uint h = 600;
Line 162 
Line 170 
         NL3D::CScene scene;         NL3D::CScene scene;
         NL3D::CSceneUt::init3d(scene, w, h, bpp, windowed);          NL3D::CSceneUt::init3d(scene, w, h, bpp, windowed);
                  
                  // synchronize time with server
                  CUniTime::syncUniTimeFromService();
                  
         // language choice                 // user id (login & password)
         uint languageIndex = chooseLanguage(&scene, w, h);                 CLogUserId id;
         CI18N::load(languageIndex); 
  
         //shard's name list                 //shard's name list        
         vector<string> shards;         vector<string> shards;
                  
         // user id (login & password)                 // index of chard in the list
         CLogUserId id;                 sint shardIndex;
  
                  TState clientSate = LANGUAGE;
                  bool quit = false;
                  while(!quit)
                  {
                          switch(clientSate)
                          {
                                  // language choice
                                  case LANGUAGE:        
                                  {
                                          sint languageIndex = chooseLanguage(&scene, &fontGen, w, h);
                                          if(languageIndex==-1)
                                                  quit = true;
                                          else
                                          {
                                                  CI18N::load(languageIndex);
                                                  clientSate = LOGIN;
                                          }
                                  }
                                  break;
  
                                  // get user's login and password
                                  case LOGIN:
                                  {
                                          id = login(&scene, &fontGen, w, h);
                                          if(id.Login.size()==0) // happens only if return back is asked
                                                  clientSate = LANGUAGE;
                                          else
                                                  clientSate = CONNECT;
                                  }
                                  break;
                  
         // connection         // connection
         bool connected = false;                                 case CONNECT:
         bool goOn = true; 
         do 
         {                 {        
                 id = login(&scene, w, h);                                         bool connected = connectToLS (id,shards);
                 connected = connectToLS (id,shards); 
                 if(!connected)                 if(!connected)
                 {                 {
                                                  if(windowed)
                                                  {
                         IDriver::TMessageBoxId answer =                          IDriver::TMessageBoxId answer =
                                 scene.getDriver()->systemMessageBox("Can't establish connection",                                 scene.getDriver()->systemMessageBox("Can't establish connection",
                                 "user connection", IDriver::retryCancelType, IDriver::errorIcon);                                 "user connection", IDriver::retryCancelType, IDriver::errorIcon);
                         if(answer==IDriver::cancelId) goOn = false;                                                         if(answer==IDriver::cancelId)
                                                                  clientSate = LOGIN;
                                                          else
                                                                  clientSate = CONNECT;
                 }                 }
                                                  else
                                                          clientSate = LOGIN;
         }         }
         while(!connected && goOn);                                         else
                                                  clientSate = SHARD;
                                  }
                                  break;
                  
         // shard choice         // shard choice
         if(connected)                                 case SHARD:
                 uint shardIndex = chooseShard(&scene, w, h, shards);                                 {
                                          shardIndex = chooseShard(&scene, &fontGen, w, h, shards);
                                          if(shardIndex==-1)
                                                  clientSate = LOGIN;
                                          else
                                                  quit = true;
                                  }
                                  break;
                          }
  
                          if(quit) break;
                  }
  
  
         // release scene         // release scene
         NL3D::CSceneUt::release3d(scene);         NL3D::CSceneUt::release3d(scene);
                  
                  }
          catch(Exception &e)
          {
                  nlerror ("main(): Exception trapped: %s", e.what ());
          }
                  
 } }


Legend:
Removed from v.1.7 
changed lines
 Added in v.1.8