diff options
author | Stijn Buys <ingar@osirion.org> | 2013-11-07 22:52:17 +0000 |
---|---|---|
committer | Stijn Buys <ingar@osirion.org> | 2013-11-07 22:52:17 +0000 |
commit | 3aa51da4ec976665a7e74bb659868d474400a101 (patch) | |
tree | 8996920adcb3af1e933feef24456116eb7911cdc /src/core/player.cc | |
parent | 87d5637c09dca61a650fe81d83ef328943176503 (diff) |
Track the amount of time the player has spent,
make the 'impulse' command disable the autopilot.
Diffstat (limited to 'src/core/player.cc')
-rw-r--r-- | src/core/player.cc | 49 |
1 files changed, 42 insertions, 7 deletions
diff --git a/src/core/player.cc b/src/core/player.cc index eb5f08e..f744766 100644 --- a/src/core/player.cc +++ b/src/core/player.cc @@ -5,6 +5,7 @@ */ #include <sstream> +#include <iomanip> #include "auxiliary/functions.h" #include "sys/sys.h" @@ -52,6 +53,9 @@ void Player::clear() player_npckills = 0; player_pvpkills = 0; + + player_time_wasted = 0; + player_time_joined = 0; } @@ -59,14 +63,35 @@ void Player::print() const { con_print << "id: ^B" << id() << "^N name: ^B" << name() << "^N" << std::endl; if (zone()) { - con_print << " zone ^B" << zone()->name() << std::endl; + con_print << " zone ^B" << zone()->name() << std::endl; } - con_print << " color ^B" << color() << std::endl; - con_print << " ping ^B" << ping() << std::endl; - con_print << " credits ^B" << credits() << std::endl; - con_print << " level ^B" << level() << std::endl; - con_print << " npc kills ^B" << npckills() << std::endl; - con_print << " pvp kills ^B" << pvpkills() << std::endl; + con_print << " color ^B" << color() << std::endl; + con_print << " ping ^B" << ping() << std::endl; + con_print << " credits ^B" << credits() << std::endl; + con_print << " level ^B" << level() << std::endl; + con_print << " npc kills ^B" << npckills() << std::endl; + con_print << " pvp kills ^B" << pvpkills() << std::endl; + + con_print << " time wasted ^B"; + + long time_wasted = (player_time_wasted + server()->timestamp() - player_time_joined) / 1000; + const long time_wasted_seconds = time_wasted % 60; + + time_wasted = (time_wasted - time_wasted_seconds) / 60; + const long time_wasted_minutes = time_wasted % 60; + + time_wasted = (time_wasted - time_wasted_minutes) / 60; + const long time_wasted_hours = time_wasted % 24; + + const long time_wasted_days = (time_wasted - time_wasted_hours) / 24; + + if (time_wasted_days > 0) { + con_print << time_wasted_days << aux::plural("day", time_wasted_days) << " "; + } + + con_print << std::setfill('0') << std::setw(2) << time_wasted_hours << ":" + << std::setfill('0') << std::setw(2) << time_wasted_minutes << ":" + << std::setfill('0') << std::setw(2) << time_wasted_seconds << std::endl; } void Player::message(Message::Channel channel, const std::string text) @@ -156,6 +181,16 @@ void Player::set_pvpkills(const long kills) player_pvpkills = kills; } +void Player::set_time_wasted(const long time_wasted) +{ + player_time_wasted = time_wasted; +} + +void Player::set_time_joined() +{ + player_time_joined = server()->timestamp(); +} + void Player::update_info() { Cvar *cl_name = Cvar::find("cl_name"); |