/** \file client.cpp * Client prototype * * $Id: client.cpp,v 1.6 2000/11/23 15:36:14 coutelas Exp $ */ /* Copyright, 2000 Nevrax Ltd. * * This file is part of NEVRAX NEL. * NEVRAX NEL 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, or (at your option) * any later version. * NEVRAX NEL 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 NEVRAX NEL; see the file COPYING. If not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, * MA 02111-1307, USA. */ #include "nel/misc/types_nl.h" #include "nel/misc/debug.h" #include "nel/misc/i18n.h" #include "nel/net/msg_socket.h" #include "nel/net/naming_client.h" #include "nel/net/unitime.h" #include "nel/3d/driver.h" #include "language_interface.h" #include "login_interface.h" #include "shards_list_interface.h" #include using namespace std; using namespace NLNET; using namespace NLMISC; using namespace NL3D; /** * login */ CLogUserId login(NL3D::CScene * scene, uint w, uint h) { CLoginInterface logscreen; logscreen.init(scene, w, h); return logscreen.log(); } /** * connect */ /** * connectToLS */ bool connectToLS (CLogUserId &luid, vector& shards) { CInetAddress servaddr("vianneyl", 49999); CSocket server; try { server.connect(servaddr); } catch(Exception e) { return false; } CMessage msgout(""); msgout.setType(0); // we don't listen for incoming replies, therefore we must not use a type as string. 0 is the default action for CLogService : "LOG" string l, p; uint i; // TEMPPP for (i=0; i& shards) { CShardsListInterface shardListScreen; shardListScreen.init(scene, w, h, shards); return shardListScreen.choose(); } /****************************************************************\ MAIN \****************************************************************/ void main() { // synchronize time with server CUniTime::syncUniTimeFromService(); // init scene uint w = 800; uint h = 600; uint bpp = 32; bool windowed = true; NL3D::CScene scene; NL3D::CSceneUt::init3d(scene, w, h, bpp, windowed); // language choice uint languageIndex = chooseLanguage(&scene, w, h); CI18N::load(languageIndex); //shard's name list vector shards; // user id (login & password) CLogUserId id; // connection bool connected = false; bool goOn = true; do { id = login(&scene, w, h); connected = connectToLS (id,shards); if(!connected) { IDriver::TMessageBoxId answer = scene.getDriver()->systemMessageBox(CI18N::get("Can't establish connection").c_str(), CI18N::get("user connection").c_str(), IDriver::retryCancelType, IDriver::errorIcon); if(answer==IDriver::cancelId) goOn = false; } } while(!connected && goOn); // shard choice if(connected) uint shardIndex = chooseShard(&scene, w, h, shards); // release scene NL3D::CSceneUt::release3d(scene); }