diff options
author | neodarz <neodarz@neodarz.net> | 2018-08-11 20:21:34 +0200 |
---|---|---|
committer | neodarz <neodarz@neodarz.net> | 2018-08-11 20:21:34 +0200 |
commit | 0ea5fc66924303d1bf73ba283a383e2aadee02f2 (patch) | |
tree | 2568e71a7ccc44ec23b8bb3f0ff97fb6bf2ed709 /cvs/cvsweb.cgi/code/client/Attic/client.cpp?rev=1.8&content-type=text | |
download | nevrax-website-self-hostable-0ea5fc66924303d1bf73ba283a383e2aadee02f2.tar.xz nevrax-website-self-hostable-0ea5fc66924303d1bf73ba283a383e2aadee02f2.zip |
Initial commit
Diffstat (limited to 'cvs/cvsweb.cgi/code/client/Attic/client.cpp?rev=1.8&content-type=text')
-rw-r--r-- | cvs/cvsweb.cgi/code/client/Attic/client.cpp?rev=1.8&content-type=text/x-cvsweb-markup&hideattic=0&sortby=date/index.html | 280 |
1 files changed, 280 insertions, 0 deletions
diff --git a/cvs/cvsweb.cgi/code/client/Attic/client.cpp?rev=1.8&content-type=text/x-cvsweb-markup&hideattic=0&sortby=date/index.html b/cvs/cvsweb.cgi/code/client/Attic/client.cpp?rev=1.8&content-type=text/x-cvsweb-markup&hideattic=0&sortby=date/index.html new file mode 100644 index 00000000..e746b68c --- /dev/null +++ b/cvs/cvsweb.cgi/code/client/Attic/client.cpp?rev=1.8&content-type=text/x-cvsweb-markup&hideattic=0&sortby=date/index.html @@ -0,0 +1,280 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><HTML> +<HEAD><style> A { color:black }</style> +<!-- hennerik CVSweb $Revision: 1.93 $ --> +<TITLE>code/client/client.cpp - view - 1.8</TITLE></HEAD> +<BODY BGCOLOR="#eeeeee"> +<table width="100%" border=0 cellspacing=0 cellpadding=1 bgcolor="#aaaaaa"><tr valign=bottom><td><a href="client.cpp?hideattic=0&sortby=date"><IMG SRC="http://www.nevrax.org/inc/img/picto-up.gif" ALT="[BACK]" BORDER="0" WIDTH="14" HEIGHT="13"></a> <b>Return to <A HREF="client.cpp?hideattic=0&sortby=date">client.cpp</A> + CVS log</b> <IMG SRC="http://www.nevrax.org/inc/img/picto-news.gif" ALT="[TXT]" BORDER="0" WIDTH="13" HEIGHT="15"></td><td align=right><IMG SRC="http://www.nevrax.org/inc/img/picto-dir.gif" ALT="[DIR]" BORDER="0" WIDTH="15" HEIGHT="13"> <b>Up to <a href="/cvs/cvsweb.cgi/?hideattic=0&sortby=date">Nevrax</a> / <a href="/cvs/cvsweb.cgi/code/?hideattic=0&sortby=date">code</a> / <a href="/cvs/cvsweb.cgi/code/client/?hideattic=0&sortby=date">client</a></b></td></tr></table><HR noshade><table width="100%"><tr><td bgcolor="#ffffff">File: <a href="/cvs/cvsweb.cgi/?hideattic=0&sortby=date">Nevrax</a> / <a href="/cvs/cvsweb.cgi/code/?hideattic=0&sortby=date">code</a> / <a href="/cvs/cvsweb.cgi/code/client/?hideattic=0&sortby=date">client</a> / <a href="/cvs/cvsweb.cgi/code/client/Attic/?hideattic=0&sortby=date">Attic</a> / <a href="/cvs/cvsweb.cgi/code/client/Attic/client.cpp?hideattic=0&sortby=date">client.cpp</a> (<A HREF="/cvs/cvsweb.cgi/~checkout~/code/client/Attic/client.cpp?rev=1.8&hideattic=0&sortby=date" target="cvs_checkout" onClick="window.open('/cvs/cvsweb.cgi/~checkout~/code/client/Attic/client.cpp?rev=1.8','cvs_checkout','resizeable,scrollbars');"><b>download</b></A>)<BR> +Revision <B>1.8</B>, <i>Fri Nov 24 14:17:35 2000 UTC</i> (20 months ago) by <i>coutelas</i> +<BR>Branch: <b>MAIN</b> +<BR>Changes since <b>1.7: +127 -65 + lines</b><PRE> +font loaded from server +time displayed on screen +</PRE> +</td></tr></table><HR noshade><PRE>/** \file client.cpp + * Client prototype + * + * $Id: client.cpp,v 1.8 2000/11/24 14:17:35 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 <string> + +using namespace std; +using namespace NLNET; +using namespace NLMISC; +using namespace NL3D; + + +#ifdef NL_OS_WINDOWS +CFontGenerator fontGen("\\\\server\\code\\fonts\\arialuni.ttf"); +#else +CFontGenerator fontGen("arialuni.ttf"); +#endif + + +/** + * login + */ +CLogUserId login(NL3D::CScene * scene, + NL3D::CFontGenerator * fontGenerator, + uint w, uint h) +{ + CLoginInterface logscreen(scene, fontGenerator, w, h); + return logscreen.log(); +} + + + +/** + * connectToLS + */ +bool connectToLS (CLogUserId &luid, vector<string>& shards) +{ + CInetAddress servaddr("vianneyl", 49999); + + CSocket server; + try + { + server.connect(servaddr); + } + catch(Exception) + { + 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 = luid.Login.toString(), p = luid.Password.toString(); + msgout.serial(l); + msgout.serial(p); + + // send the message + server.send(msgout); + + // receive the answer + CMessage msgin("", true); + server.receive(msgin); + + uint8 ok; + msgin.serial (ok); + nlinfo ("res=%d", ok); + + if (ok) + { + uint32 nbshard, id; + msgin.serial (id); + msgin.serial (nbshard); + for (uint i = 0; i < nbshard; i++) + { + string shardip, shardname; + msgin.serial (shardip); + msgin.serial (shardname); + shards.push_back (shardip); + } + } + + server.close(); + + return ok==1; +} + + +/** + * chooseLanguage + */ +sint chooseLanguage(NL3D::CScene * scene, + NL3D::CFontGenerator * fontGenerator, + uint w, uint h) +{ + CLanguageInterface languageScreen(scene, fontGenerator, w, h); + return languageScreen.choose(); +} + + + +/** + * chooseShard + */ +sint chooseShard(NL3D::CScene * scene, + NL3D::CFontGenerator * fontGenerator, + uint w, uint h, + const std::vector<std::string>& shards) +{ + CShardsListInterface shardListScreen(scene, fontGenerator, w, h, shards); + return shardListScreen.choose(); +} + + +enum TState +{ + LANGUAGE, + LOGIN, + CONNECT, + SHARD +}; + + +/****************************************************************\ + MAIN +\****************************************************************/ +void main() +{ + try + { + // 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); + + // synchronize time with server + CUniTime::syncUniTimeFromService(); + + // user id (login & password) + CLogUserId id; + + //shard's name list + vector<string> shards; + + // index of chard in the list + 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 + case CONNECT: + { + bool connected = connectToLS (id,shards); + if(!connected) + { + if(windowed) + { + IDriver::TMessageBoxId answer = + scene.getDriver()->systemMessageBox("Can't establish connection", + "user connection", IDriver::retryCancelType, IDriver::errorIcon); + if(answer==IDriver::cancelId) + clientSate = LOGIN; + else + clientSate = CONNECT; + } + else + clientSate = LOGIN; + } + else + clientSate = SHARD; + } + break; + + // shard choice + case SHARD: + { + shardIndex = chooseShard(&scene, &fontGen, w, h, shards); + if(shardIndex==-1) + clientSate = LOGIN; + else + quit = true; + } + break; + } + + if(quit) break; + } + + + // release scene + NL3D::CSceneUt::release3d(scene); + + } + catch(Exception &e) + { + nlerror ("main(): Exception trapped: %s", e.what ()); + } + +} +</PRE>
\ No newline at end of file |