From 02169591261cc09047117ddff961595717c8903a Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Sun, 10 Jul 2011 20:19:14 +0000 Subject: Add player guid to the connection string . --- src/core/gameconnection.cc | 2 ++ src/core/netclient.cc | 2 -- src/core/netconnection.cc | 2 +- src/core/netconnection.h | 2 +- src/core/netserver.cc | 26 +++++++++++++++++++------- 5 files changed, 23 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/core/gameconnection.cc b/src/core/gameconnection.cc index a62fb4f..ddf4610 100644 --- a/src/core/gameconnection.cc +++ b/src/core/gameconnection.cc @@ -73,6 +73,8 @@ GameConnection::GameConnection(std::string const &connectionstr) ofs.close(); } + con_print << "Using client key " << localplayer()->guid().str() << std::endl; + // split hostname into host and port unsigned int port = DEFAULTPORT; std::string host(connectionstr); diff --git a/src/core/netclient.cc b/src/core/netclient.cc index 76112e1..35f355a 100644 --- a/src/core/netclient.cc +++ b/src/core/netclient.cc @@ -34,8 +34,6 @@ NetClient::NetClient(std::string host, int port, int fd) : abort(); return; } - con_print << host << ":" << port << " connected" << std::endl; - client_addr.sin_family = AF_INET; client_addr.sin_port = htons(port); client_addr.sin_addr.s_addr = inet_addr(host.c_str()); diff --git a/src/core/netconnection.cc b/src/core/netconnection.cc index fd844aa..3c68be9 100644 --- a/src/core/netconnection.cc +++ b/src/core/netconnection.cc @@ -338,7 +338,7 @@ void NetConnection::send_raw(std::string const &msg) void NetConnection::send_connect() { std::ostringstream msg; - msg << "connect " << PROTOCOLVERSION << "\n"; + msg << "connect " << PROTOCOLVERSION << " " << localplayer()->guid().str() << "\n"; this->send_raw(msg.str()); } diff --git a/src/core/netconnection.h b/src/core/netconnection.h index dc5dc27..59371e0 100644 --- a/src/core/netconnection.h +++ b/src/core/netconnection.h @@ -66,7 +66,7 @@ public: /// send an entity request void send_entity_request(Entity *entity); - + /// send a local chat message void send_say(std::string const &text); diff --git a/src/core/netserver.cc b/src/core/netserver.cc index 12210a5..81bd303 100644 --- a/src/core/netserver.cc +++ b/src/core/netserver.cc @@ -298,12 +298,6 @@ NetClient * NetServer::client_connect(std::string const host, int const port) void NetServer::client_initialize(NetClient *client) { - // send welcome message - std::string welcome("^B"); - welcome.append(Cvar::sv_name->str()); - client->player()->send(welcome); - client->transmit(); - // send info types send_infotypes(client); client->transmit(); @@ -327,6 +321,18 @@ void NetServer::client_initialize(NetClient *client) // set client state to pending client->client_state = NetClient::Pending; + + // send welcome message + std::string welcome("^B"); + welcome.append(Cvar::sv_name->str()); + send_message(client, Message::Info, welcome); + + welcome.assign("^B"); + welcome.append(Cvar::sv_description->str()); + send_message(client, Message::Info, welcome); + + client->transmit(); + } // send updates to one client @@ -747,7 +753,13 @@ void NetServer::parse_incoming_message(NetClient *client, const std::string & me send_disconnect(client); } - // TODO add player uid to connect message + // player guid + std:: string guid; + if (msgstream >> guid) { + client->player()->guid().assign(guid); + } + + con_print << client->host() << ":" << client->port() << " connected with UID " << client->player()->guid().str() << std::endl; return; -- cgit v1.2.3