diff options
author | Stijn Buys <ingar@osirion.org> | 2008-08-05 13:31:12 +0000 |
---|---|---|
committer | Stijn Buys <ingar@osirion.org> | 2008-08-05 13:31:12 +0000 |
commit | 37d132313dbed8007ee6e5cb3c61d59548fb3d4b (patch) | |
tree | 914fd90d3e8d01296fd0924c6c7428c5ccc781d6 /src/core/netserver.cc | |
parent | 7ac353a7895f1ab30d09268968bc85ef9394cf41 (diff) |
server-side detection of entity zone changes, netserver ent/die responses, removed zone from sup messages
Diffstat (limited to 'src/core/netserver.cc')
-rw-r--r-- | src/core/netserver.cc | 32 |
1 files changed, 21 insertions, 11 deletions
diff --git a/src/core/netserver.cc b/src/core/netserver.cc index b674dbd..dd70bcf 100644 --- a/src/core/netserver.cc +++ b/src/core/netserver.cc @@ -330,19 +330,29 @@ void NetServer::client_frame(NetClient *client, float timestamp, float previoust send_frame_marker(client, timestamp, previoustimestamp); // send updates for entities in the zone - for (Zone::Content::iterator it = zone->content().begin(); it != zone->content().end(); it++) { - Entity *entity = (*it); + for (Entity::Registry::iterator it = Entity::registry().begin(); it != Entity::registry().end(); it++) { + Entity *entity = (*it).second; + + if (entity->zone() == zone) { + if (entity->entity_destroyed) { + if (!entity->entity_created) { + send_entity_delete(client, entity); + } + } else if (entity->entity_created) { + send_entity_create(client, entity); - if (entity->entity_destroyed) { - if (!entity->entity_created) { - send_entity_delete(client, entity); - } - } else if (entity->entity_created) { - send_entity_create(client, entity); - } else if (entity->dirty() && !(entity->flags() & Entity::Static) ) { + } else if (entity->oldzone()) { + // this entity has entered the zone + send_entity_create(client, entity); - // FIXME only within visual range - send_entity_update(client, entity); + } else if (entity->dirty() && !(entity->flags() & Entity::Static) ) { + + // FIXME only within visual range + send_entity_update(client, entity); + } + } else if (entity->oldzone() == zone) { + // the entity has left the zone + send_entity_delete(client, entity); } } } |