Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStijn Buys <ingar@osirion.org>2013-11-07 22:52:17 +0000
committerStijn Buys <ingar@osirion.org>2013-11-07 22:52:17 +0000
commit3aa51da4ec976665a7e74bb659868d474400a101 (patch)
tree8996920adcb3af1e933feef24456116eb7911cdc /src/game/base/game.cc
parent87d5637c09dca61a650fe81d83ef328943176503 (diff)
Track the amount of time the player has spent,
make the 'impulse' command disable the autopilot.
Diffstat (limited to 'src/game/base/game.cc')
-rw-r--r--src/game/base/game.cc116
1 files changed, 31 insertions, 85 deletions
diff --git a/src/game/base/game.cc b/src/game/base/game.cc
index 79fd167..f2db00c 100644
--- a/src/game/base/game.cc
+++ b/src/game/base/game.cc
@@ -103,6 +103,10 @@ void Game::func_join(core::Player *player, std::string const &args)
player->reputation().clear();
Faction::apply_default(player->reputation());
+
+ // reset player timestamps
+ player->set_time_wasted(0);
+ player->set_time_joined();
}
player->set_dirty();
@@ -151,8 +155,15 @@ void Game::func_impulse(core::Player *player, std::string const &args)
if (player->control()->moduletype() != ship_enttype)
return;
-
+
Ship * ship = static_cast<Ship *>(player->control());
+ if (ship->has_autopilot_flag(Ship::AutoPilotEnabled)) {
+ ship->set_autopilot_target(0);
+ ship->unset_autopilot_flag(Ship::AutoPilotEnabled);
+
+ // TODO replace with "Canceled" voice
+ player->send("Autopilot canceled");
+ }
ship->func_impulse();
}
@@ -167,10 +178,13 @@ void Game::func_freeflight(core::Player *player, std::string const &args)
Ship * ship = static_cast<Ship *>(player->control());
- ship->set_autopilot_target(0);
- ship->unset_autopilot_flag(Ship::AutoPilotEnabled);
- // TODO replace with "autopilot disabled" voice
- player->send("Autopilot disabled");
+ if (ship->has_autopilot_flag(Ship::AutoPilotEnabled)) {
+ ship->set_autopilot_target(0);
+ ship->unset_autopilot_flag(Ship::AutoPilotEnabled);
+
+ // TODO replace with "Canceled" voice
+ player->send("Autopilot canceled");
+ }
}
// autopilot goto
@@ -194,85 +208,11 @@ void Game::func_target_goto(core::Player *player, core::Entity *entity)
ship->set_autopilot_flag(Ship::AutoPilotEnabled);
ship->unset_autopilot_flag(Ship::AutoPilotDock);
ship->unset_autopilot_flag(Ship::AutoPilotFormation);
+
// TODO replace with "goto" voice
player->send("Autopilot set to " + entity->name());
}
-/*
-void Game::func_target_dock(core::Player *player, core::Entity *entity)
-{
- if (!player->control())
- return;
-
- if (player->control() == entity)
- return;
-
- if (player->control()->zone() != entity->zone())
- return;
-
- if ((entity->flags() & core::Entity::Dockable) == 0)
- return;
-
- if (player->control()->moduletype() != ship_enttype)
- return;
-
- if (!(entity->flags() & core::Entity::Dockable)) {
- return;
- }
-
- Ship * ship = static_cast<Ship *>(player->control());
-
- // check distance
- float range = entity->radius() + ship->radius();
-
- if (entity->moduletype() == planet_enttype) {
- range += PLANET_SAFE_DISTANCE;
- }
-
- core::Player *owner = (entity->type() == core::Entity::Controlable ? static_cast<core::EntityControlable *>(entity)->owner() : 0 );
- if (math::distance(entity->location(), ship->location()) > range) {
- if (owner) {
- player->send("^B" + owner->name() + "^B's " + entity->name() + " is out of range");
- } else {
- player->send("^B" + entity->name() + "^B is out of range");
- }
- return;
- }
-
- if ((player->control()->state() == core::Entity::Impulse) || (player->control()->state() == core::Entity::ImpulseInitiate)) {
- player->send("^BCan not dock at impulse speed");
- return;
- }
-
- if (player->control()->state() != core::Entity::Normal)
- return;
-
- if (entity->moduletype() == jumpgate_enttype) {
- // jumpgates have their own docking function
- JumpGate *jumpgate = static_cast<JumpGate *>(entity);
- jumpgate->func_dock(ship);
- return;
- } else if (entity->moduletype() == race_enttype) {
- RaceTrack *race = static_cast<RaceTrack *>(entity);
- race->func_dock(ship);
- } else {
- ship->set_dock(entity);
-
- if (player->control() == ship) {
- player->set_view(entity);
- if (owner) {
- player->send("^BDocking at " + owner->name() + "^B's " + entity->name());
- } else {
- player->send("^BDocking at " + entity->name());
- }
- }
-
- // force save
- core::server()->module()->player_save(player);
- }
-}
-*/
-
// a player sends a docking request
void Game::func_target_dock(core::Player *player, core::Entity *entity)
{
@@ -303,10 +243,8 @@ void Game::func_target_dock(core::Player *player, core::Entity *entity)
ship->set_autopilot_flag(Ship::AutoPilotDock);
ship->unset_autopilot_flag(Ship::AutoPilotFormation);
- if (math::distance(player->control()->location(), entity->location()) > (player->control()->radius() + entity->radius() + PLANET_SAFE_DISTANCE)) {
- // TODO replace with "dock" voice
- player->send("Autopilot set to dock at " + entity->name());
- }
+ // TODO replace with "dock" voice
+ player->send("Autopilot set to dock at " + entity->name());
}
void Game::func_target_formation(core::Player *player, core::Entity *entity)
@@ -2677,6 +2615,10 @@ void Game::game_load(core::Player *player, filesystem::IniFile & inifile)
return;
}
+ // reset player timestamps
+ player->set_time_wasted(0);
+ player->set_time_joined();
+
SaveGame::load_game(player, inifile);
}
@@ -2693,7 +2635,11 @@ void Game::player_load(core::Player *player)
if (core::server()->mode() != core::GameServer::MultiPlayer) {
return;
}
-
+
+ // reset player timestamps
+ player->set_time_wasted(0);
+ player->set_time_joined();
+
std::string guid(player->guid().str());
std::string directory(guid.substr(0,4));