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.h6
-rw-r--r--src/core/gameserver.cc49
-rw-r--r--src/core/netconnection.cc2
-rw-r--r--src/core/netserver.cc3
-rw-r--r--src/game/base/game.cc8
-rw-r--r--src/game/base/ship.cc22
-rw-r--r--src/game/base/shipmodel.cc9
-rw-r--r--src/game/base/shipmodel.h11
8 files changed, 104 insertions, 6 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();
}
diff --git a/src/game/base/game.cc b/src/game/base/game.cc
index 1d4536a..128ae7c 100644
--- a/src/game/base/game.cc
+++ b/src/game/base/game.cc
@@ -168,6 +168,9 @@ void Game::func_dock(core::Player *player, core::Entity *entity)
if (player->control()->zone() != entity->zone())
return;
+
+ if (player->control() == entity)
+ return;
if ((entity->flags() & core::Entity::Dockable) == 0)
return;
@@ -202,6 +205,8 @@ void Game::func_buy(core::Player *player, const std::string &args)
if (typestr.compare("ship") == 0) {
ShipDealer::func_buy(player, labelstr);
+ } else if (typestr.compare("cargo") == 0) {
+ player->send("Buying cargo is not supported");
} else {
player->send("unkown item type '" + typestr + "'");
}
@@ -915,6 +920,9 @@ bool Game::load_ships()
} else if (shipsini.got_key_bool("jumpdrive", b)) {
shipmodel->set_jumpdrive(b);
continue;
+ } else if (shipsini.got_key_bool("dock", b)) {
+ shipmodel->set_dock(b);
+ continue;
} else if (shipsini.got_key_float("acceleration", f)) {
shipmodel->set_acceleration(f);
continue;
diff --git a/src/game/base/ship.cc b/src/game/base/ship.cc
index 6aaba40..7edc183 100644
--- a/src/game/base/ship.cc
+++ b/src/game/base/ship.cc
@@ -49,6 +49,23 @@ Ship::Ship(core::Player *owner, ShipModel *shipmodel) : core::EntityControlable(
set_label(shipmodel->label());
}
+ if (shipmodel->dock()) {
+ using core::MenuDescription;
+ using core::ButtonDescription;
+
+ MenuDescription *menu_main = new MenuDescription();
+ menu_main->set_label("main");
+ menu_main->set_text("Launch area");
+ add_menu(menu_main);
+
+ ButtonDescription *button = new ButtonDescription();
+ button->set_text("Launch");
+ button->set_command("launch", ButtonDescription::CommandGame);
+ button->set_alignment(ButtonDescription::Center);
+ menu_main->add_button(button);
+
+ set_flag(core::Entity::Dockable);
+ }
reset();
}
@@ -293,7 +310,12 @@ void Ship::frame(float seconds)
} else {
get_location().assign(ship_jumpdepart->target()->location() + location() - ship_jumpdepart->location());
}
+
set_zone(ship_jumpdepart->target()->zone());
+
+ if (owner() && owner()->view()->zone() != ship_jumpdepart->target()->zone())
+ owner()->set_view(0);
+
owner()->send("^BJumping to the " + ship_jumpdepart->target()->zone()->name());
} else {
set_state(core::Entity::Normal);
diff --git a/src/game/base/shipmodel.cc b/src/game/base/shipmodel.cc
index ed8f09d..ee2e647 100644
--- a/src/game/base/shipmodel.cc
+++ b/src/game/base/shipmodel.cc
@@ -25,6 +25,7 @@ ShipModel::ShipModel() : core::Info(shipmodel_infotype)
shipmodel_maxcargo = 0;
shipmodel_jumpdrive = false; // no jumpdrive capability
+ shipmodel_dock = false; // not dockable
}
ShipModel::~ShipModel()
@@ -59,9 +60,11 @@ void ShipModel::generate_info()
str.str("");
if (jumpdrive()) {
- str << "hyperspace jump drive capable";
- add_text(str.str());
- str.str("");
+ add_text("hyperspace jump drive capable");
+ }
+
+ if (dock()) {
+ add_text("docking capable");
}
}
diff --git a/src/game/base/shipmodel.h b/src/game/base/shipmodel.h
index 9b428df..38e9d5d 100644
--- a/src/game/base/shipmodel.h
+++ b/src/game/base/shipmodel.h
@@ -31,6 +31,11 @@ public:
return shipmodel_jumpdrive;
}
+ /// indicates if players can dock this ship model
+ inline const bool dock() const {
+ return shipmodel_dock;
+ }
+
/// acceleration
inline const float acceleration() const {
return shipmodel_acceleration;
@@ -77,6 +82,11 @@ public:
inline void set_jumpdrive(const bool jumpdrive) {
shipmodel_jumpdrive = jumpdrive;
}
+
+ /// set dock capability
+ inline void set_dock(const bool dock) {
+ shipmodel_dock = dock;
+ }
void generate_info();
@@ -92,6 +102,7 @@ public:
private:
bool shipmodel_jumpdrive;
+ bool shipmodel_dock;
float shipmodel_acceleration;
float shipmodel_maxspeed;