From 37d132313dbed8007ee6e5cb3c61d59548fb3d4b Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Tue, 5 Aug 2008 13:31:12 +0000 Subject: server-side detection of entity zone changes, netserver ent/die responses, removed zone from sup messages --- src/core/netserver.cc | 32 +++++++++++++++++++++----------- 1 file changed, 21 insertions(+), 11 deletions(-) (limited to 'src/core/netserver.cc') 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); } } } -- cgit v1.2.3