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>2011-05-09 20:22:34 +0000
committerStijn Buys <ingar@osirion.org>2011-05-09 20:22:34 +0000
commitbb0f860989f84b901f80017ae0139a3fc0446dc1 (patch)
tree3b9ef3a5164326d2ad4b531904603ea2afdb40e3 /src/dedicated
parent3de78ec1bef2a0274a719ea229709523650ade40 (diff)
Refactored the sys::localtime routines.
Diffstat (limited to 'src/dedicated')
-rw-r--r--src/dedicated/console.cc25
1 files changed, 17 insertions, 8 deletions
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 << ":"