aboutsummaryrefslogtreecommitdiff
path: root/cvs/cvsweb.cgi/~checkout~/code/client/Attic/client.cpp?rev=1.6&content-type=text/plain&hideattic=0&sortby=date/index.html
diff options
context:
space:
mode:
authorneodarz <neodarz@neodarz.net>2018-08-11 20:21:34 +0200
committerneodarz <neodarz@neodarz.net>2018-08-11 20:21:34 +0200
commit0ea5fc66924303d1bf73ba283a383e2aadee02f2 (patch)
tree2568e71a7ccc44ec23b8bb3f0ff97fb6bf2ed709 /cvs/cvsweb.cgi/~checkout~/code/client/Attic/client.cpp?rev=1.6&content-type=text/plain&hideattic=0&sortby=date/index.html
downloadnevrax-website-self-hostable-0ea5fc66924303d1bf73ba283a383e2aadee02f2.tar.xz
nevrax-website-self-hostable-0ea5fc66924303d1bf73ba283a383e2aadee02f2.zip
Initial commit
Diffstat (limited to 'cvs/cvsweb.cgi/~checkout~/code/client/Attic/client.cpp?rev=1.6&content-type=text/plain&hideattic=0&sortby=date/index.html')
-rw-r--r--cvs/cvsweb.cgi/~checkout~/code/client/Attic/client.cpp?rev=1.6&content-type=text/plain&hideattic=0&sortby=date/index.html207
1 files changed, 207 insertions, 0 deletions
diff --git a/cvs/cvsweb.cgi/~checkout~/code/client/Attic/client.cpp?rev=1.6&content-type=text/plain&hideattic=0&sortby=date/index.html b/cvs/cvsweb.cgi/~checkout~/code/client/Attic/client.cpp?rev=1.6&content-type=text/plain&hideattic=0&sortby=date/index.html
new file mode 100644
index 00000000..65013a62
--- /dev/null
+++ b/cvs/cvsweb.cgi/~checkout~/code/client/Attic/client.cpp?rev=1.6&content-type=text/plain&hideattic=0&sortby=date/index.html
@@ -0,0 +1,207 @@
+/** \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 <string>
+
+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<string>& 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<luid.Login.size (); i++) l+=luid.Login[i];
+ for (i=0; i<luid.Password.size (); i++) p+=luid.Password[i];
+ 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();
+ if(ok)
+ return true;
+ else
+ return false;
+}
+
+
+/**
+ * chooseLanguage
+ */
+uint chooseLanguage(NL3D::CScene * scene, uint w, uint h)
+{
+ CLanguageInterface languageScreen;
+ languageScreen.init(scene, w, h);
+ return languageScreen.choose();
+}
+
+
+
+/**
+ * chooseShard
+ */
+uint chooseShard(NL3D::CScene * scene, uint w, uint h,
+ const std::vector<std::string>& 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<string> 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);
+
+
+
+}