Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/core/entity.cc18
-rw-r--r--src/core/netserver.cc12
2 files changed, 23 insertions, 7 deletions
diff --git a/src/core/entity.cc b/src/core/entity.cc
index c62a412..5ddc149 100644
--- a/src/core/entity.cc
+++ b/src/core/entity.cc
@@ -12,6 +12,7 @@
#include "sys/sys.h"
#include "core/entity.h"
#include "core/cvar.h"
+#include "core/application.h"
namespace core
{
@@ -552,15 +553,22 @@ void EntityControlable::serialize_server_create(std::ostream & os) const
void EntityControlable::receive_server_create(std::istream &is)
{
- unsigned int o;
+ int owner_id;
EntityDynamic::receive_server_create(is);
is >> entity_thrust;
entity_thrust /= 100.0f;
- is >> o;
-
- // FIXME resolve owner
- entity_owner = 0;
+ if (is >> owner_id) {
+ for (GameInterface::Players::iterator pit = game()->players().begin(); pit != game()->players().end(); pit++ ) {
+ Player *player = (*pit);
+ if (player->id() == owner_id) {
+ entity_owner = player;
+ player->add_asset(this);
+ }
+ }
+ } else {
+ entity_owner = 0;
+ }
}
void EntityControlable::serialize_client_update(std::ostream & os) const
diff --git a/src/core/netserver.cc b/src/core/netserver.cc
index 73aa73d..2639b97 100644
--- a/src/core/netserver.cc
+++ b/src/core/netserver.cc
@@ -159,9 +159,17 @@ void NetServer::reap()
if (client->error()) {
- // notify the game server
- if (client->state() == NetClient::Connected)
+ // notify other clients
+ for (Clients::iterator cit = clients.begin(); cit != clients.end(); cit++) {
+ if ((*cit) != (*it)) {
+ send_player_disconnect_info((*cit), (*it)->player());
+ }
+ }
+
+ if (client->state() == NetClient::Connected) {
+ // notify the game server
server()->player_disconnect((*it)->player());
+ }
// remove the client
delete client;