diff options
author | Stijn Buys <ingar@osirion.org> | 2008-03-23 20:05:14 +0000 |
---|---|---|
committer | Stijn Buys <ingar@osirion.org> | 2008-03-23 20:05:14 +0000 |
commit | 8529af97f7b9a5d69297726a62bdf3835f3c4d6d (patch) | |
tree | f11490e17b53aa45be0a9328499f199d9bee2173 /src/core | |
parent | 772338f8cd62594d222d48466f558b002eb1efb8 (diff) |
moved intial data transfer after pif
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/netserver.cc | 20 | ||||
-rw-r--r-- | src/core/netserver.h | 3 |
2 files changed, 14 insertions, 9 deletions
diff --git a/src/core/netserver.cc b/src/core/netserver.cc index c9870c5..3b17a65 100644 --- a/src/core/netserver.cc +++ b/src/core/netserver.cc @@ -256,7 +256,12 @@ NetClient * NetServer::client_connect(std::string const host, int const port) } clients.push_back(client); - + client->player()->player_dirty = false; + return client; +} + +void NetServer::client_initialize(NetClient *client) { + // send welcome message std::ostringstream netmsg; netmsg.str(""); @@ -266,7 +271,7 @@ NetClient * NetServer::client_connect(std::string const host, int const port) // send entities std::map<unsigned int, Entity *>::iterator it; - for (it=Entity::registry.begin(); it != Entity::registry.end(); it++) { + for (it=Entity::registry.begin(); it != Entity::registry.end(); it++) { netmsg.str(""); switch ((*it).second->type()) { case Entity::Default: @@ -283,11 +288,10 @@ NetClient * NetServer::client_connect(std::string const host, int const port) break; } } - client->transmit(fd()); - - client->player()->player_dirty = false; + netmsg.str("connect\n"); + client->send(netmsg.str()); - return client; + client->transmit(fd()); } void NetServer::send(NetClient * client, std::string const & message) @@ -353,11 +357,9 @@ void NetServer::parse_incoming_message(NetClient *client, const std::string & me if (client->state() == NetClient::Connecting) { client->client_state = NetClient::Connected; + client_initialize(client); server()->player_connect(client->player()); - std::string netmsg("connect\n"); - client->send(netmsg); - } else if ((client->state() == NetClient::Connected) && (client->player()->name() != oldname)) { std::string netmsg(oldname); diff --git a/src/core/netserver.h b/src/core/netserver.h index df098df..de923b9 100644 --- a/src/core/netserver.h +++ b/src/core/netserver.h @@ -63,6 +63,9 @@ protected: /// called when a new client connects NetClient *client_connect(std::string const host, int const port); + /// called when a client has send the intial handshake + void client_initialize(NetClient *client); + /// remove terminated clients void reap(); |