aboutsummaryrefslogtreecommitdiff
path: root/cvs/cvsweb.cgi/~checkout~/code/client/Attic/client.cpp?rev=1.5&content-type=text/plain&hideattic=0&sortby=date/index.html
blob: f23d09d6ede8bab6289a122b5a28567941ae1852 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
#include "nel/misc/types_nl.h"
#include "nel/misc/debug.h"
#include "login_interface.h"

#include "nel/net/msg_socket.h"
#include "nel/net/naming_client.h"

#include <string>
#include "nel/3d/driver.h"
#include "nel/misc/types_nl.h"
#include "login_interface.h"
#include "shards_list_interface.h"

using namespace std;
using namespace NLNET;
using namespace NLMISC;

CLogUserId login(NL3D::CScene * scene, uint w, uint h)
{
	CLoginInterface logscreen;
	logscreen.init(scene, w, h);
	return logscreen.log();
}

void connectToLS (CLogUserId &luid)
{
	CInetAddress servaddr("vianneyl", 49999);

	CSocket server;
	server.connect(servaddr);

	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;
	int 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);
	server.close();
}


uint chooseShard(NL3D::CScene * scene, uint w, uint h, 
					  const std::vector<ucstring>& shards)
{
	CShardsListInterface shardListScreen;
	shardListScreen.init(scene, w, h, shards);
	return shardListScreen.choose();
}



std::vector<ucstring> connect(CLogUserId id) //TEMP !!
{
	std::vector<ucstring> shards;
	shards.reserve(10);
	ucstring ucs;
	ucs+='s';ucs+='h';ucs+='a';ucs+='r';ucs+='d';ucs+=' ';
	ucstring ucsa = ucs; ucsa += 'A';
	shards.push_back(ucsa);
	ucstring ucsb = ucs; ucsb += 'B';
	shards.push_back(ucsb);
	ucstring ucsc = ucs; ucsc += 'C';
	shards.push_back(ucsc);
	ucstring ucsd = ucs; ucsd += 'D';
	shards.push_back(ucsd);
	ucstring ucse = ucs; ucse += 'E';
	shards.push_back(ucse);
	ucstring ucsf = ucs; ucsf += 'F';
	shards.push_back(ucsf);
	ucstring ucsg = ucs; ucsg += 'G';
	shards.push_back(ucsg);
	return shards;
}



/****************************************************************\
							MAIN
\****************************************************************/
void main()
{
	//id = login();

	// 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); 
	
	
	// user login session
	CLogUserId id = login(&scene, w, h);
/*
	CLogUserId id;
	id.Login = 'c';
	id.Password = 'c';
*/

	connectToLS (id);

	// connection // TEMP !!
	std::vector<ucstring> shards = connect(id);

	// shard choice
	uint shardIndex = chooseShard(&scene, w, h, shards);

	// release scene
	NL3D::CSceneUt::release3d(scene);
}