Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
authorStijn Buys <ingar@osirion.org>2010-09-17 18:58:46 +0000
committerStijn Buys <ingar@osirion.org>2010-09-17 18:58:46 +0000
commit66ce015e5927c30801110acd289310fdff181792 (patch)
tree7beaa6b533eefdd26f0705bd65dfb5c3c9b5996a /src/core
parentc62fe609a69058e2e30f757e9a06f72a98464232 (diff)
Initial support for players docking other players' ships.
Diffstat (limited to 'src/core')
-rw-r--r--src/core/entity.h6
-rw-r--r--src/core/gameserver.cc49
-rw-r--r--src/core/netconnection.cc2
-rw-r--r--src/core/netserver.cc3
4 files changed, 57 insertions, 3 deletions
diff --git a/src/core/entity.h b/src/core/entity.h
index 6a7fa7e..fea784a 100644
--- a/src/core/entity.h
+++ b/src/core/entity.h
@@ -183,7 +183,11 @@ public:
/// find a menu
MenuDescription *find_menu(const std::string &label);
-
+
+ /// true if the entity is to be deleted
+ inline bool destroyed() const {
+ return entity_destroyed;
+ }
/* ---- mutators -------------------------------------------------- */
diff --git a/src/core/gameserver.cc b/src/core/gameserver.cc
index 4181824..09a0fff 100644
--- a/src/core/gameserver.cc
+++ b/src/core/gameserver.cc
@@ -530,6 +530,55 @@ void GameServer::frame(unsigned long timestamp)
}
}
+ // engine state updates for each player
+ for (std::list<Player *>::iterator it = game_players.begin(); it != game_players.end(); it++) {
+ Player *player = (*it);
+ Entity *view = player->view();
+ EntityControlable *control = player->control();
+
+ // the player is viewing an entity
+ if (view) {
+ // the view has changed zone
+ if (view->zone() != player->zone()) {
+ if (control) {
+ // player is docked at a jumping entity
+ if (control->state() == Entity::Docked) {
+ control->get_location().assign(view->location());
+ control->set_zone(view->zone());
+ player->set_zone(view->zone());
+ } else {
+ player->set_zone(control->zone());
+ player->set_view(0);
+ }
+ control->set_dirty();
+ } else {
+ // spectator following a jumping entity
+ player->set_zone(view->zone());
+ }
+ player->set_dirty();
+ }
+
+ // view is to be deleted
+ if (view->destroyed())
+ {
+ if (control) {
+ // player is docked at deleted entity
+ if (control->state() == Entity::Docked) {
+ control->get_location().assign(view->location());
+ control->set_state(Entity::Normal);
+ control->set_dirty();
+ } else {
+ player->set_view(0);
+ }
+ } else {
+ // spectator following a deleted entity
+ player->set_view(0);
+ }
+ player->set_dirty();
+ }
+ }
+ }
+
if (server_network) {
// send network updates
server_network->frame(server_timestamp);
diff --git a/src/core/netconnection.cc b/src/core/netconnection.cc
index 684e6b3..39bed62 100644
--- a/src/core/netconnection.cc
+++ b/src/core/netconnection.cc
@@ -836,7 +836,7 @@ void NetConnection::parse_incoming_message(const std::string & message)
info->receive_server_update(msgstream);
info->clear_timestamp();
- con_debug << "Received info for " << info->id() << " " << info->type()->label() << ":" << info->label() << std::endl;
+ //con_debug << "Received info for " << info->id() << " " << info->type()->label() << ":" << info->label() << std::endl;
}
}
diff --git a/src/core/netserver.cc b/src/core/netserver.cc
index c632284..2d83728 100644
--- a/src/core/netserver.cc
+++ b/src/core/netserver.cc
@@ -325,6 +325,7 @@ void NetServer::client_frame(NetClient *client, unsigned long timestamp)
Zone *zone = client->player()->zone();
if (zone) {
+
if (client->player()->zonechange()) {
// send zone info
@@ -733,7 +734,7 @@ void NetServer::parse_incoming_message(NetClient *client, const std::string & me
if (id) {
info = Info::find(id);
if (info) {
- con_debug << "Sending info for " << info->id() << " " << info->type()->label() << ":" << info->label() << std::endl;
+ //con_debug << "Sending info for " << info->id() << " " << info->type()->label() << ":" << info->label() << std::endl;
send_info_update(client, info);
client->transmit();
}