From bb0f860989f84b901f80017ae0139a3fc0446dc1 Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Mon, 9 May 2011 20:22:34 +0000 Subject: Refactored the sys::localtime routines. --- src/dedicated/console.cc | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) (limited to 'src/dedicated') diff --git a/src/dedicated/console.cc b/src/dedicated/console.cc index d33fb0b..fd61ffe 100644 --- a/src/dedicated/console.cc +++ b/src/dedicated/console.cc @@ -210,8 +210,8 @@ void Console::draw_status() std::stringstream status; // system time - int year = 0, month = 0, day = 0, hour = 0, min = 0, sec = 0; - sys::get_datetime(year, month, day, hour, min, sec); + int year = 0, month = 0, day = 0, hour = 0, min = 0, sec = 0, milliseconds = 0; + sys::get_localtime(year, month, day, hour, min, sec, milliseconds); status << std::setw(4) << std::setfill('0') << year << "-" << std::setw(2) << std::setfill('0') << month << "-" @@ -221,15 +221,24 @@ void Console::draw_status() << std::setw(2) << sec << " " << std::setw(2) << " "; - // uptime - int uptime_days = (int) floorf(core::game()->time() / (24.0f * 3600.0f)); - int uptime_hours = (int) floorf(core::game()->time() / 3600.0f); - int uptime_minutes = (int) floorf(core::game()->time() / 60.0f); - int uptime_seconds = (int) floorf(core::game()->time() - (float) uptime_minutes * 60.0f); + // uptime + // FIXME this is plain wrong, but the timing routines need to be refactored first + float uptime = core::game()->time(); + + const int uptime_days = (int) floorf(uptime / (24.0f * 3600.0f)); + uptime -= uptime_days * 24.0f * 3600.0f; + + const int uptime_hours = (int) floorf(uptime / 3600.0f); + uptime -= uptime_hours * 3600.0f; + + const int uptime_minutes = (int) floorf(uptime / 60.0f); + uptime -= uptime_minutes * 60.0f; + + const int uptime_seconds = (int) floorf(uptime); status << "uptime "; if (uptime_days > 0) { - status << uptime_days << aux::plural("day", uptime_days); + status << uptime_days << " " << aux::plural("day", uptime_days); } status << std::setfill('0') << std::setw(2) << uptime_hours << ":" << std::setfill('0') << std::setw(2) << uptime_minutes << ":" -- cgit v1.2.3