Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStijn Buys <ingar@osirion.org>2008-03-23 20:05:14 +0000
committerStijn Buys <ingar@osirion.org>2008-03-23 20:05:14 +0000
commit8529af97f7b9a5d69297726a62bdf3835f3c4d6d (patch)
treef11490e17b53aa45be0a9328499f199d9bee2173
parent772338f8cd62594d222d48466f558b002eb1efb8 (diff)
moved intial data transfer after pif
-rw-r--r--src/core/netserver.cc20
-rw-r--r--src/core/netserver.h3
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();