From 840f9b8678f607aecc15d47bc77248c4ac8b8574 Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Mon, 4 Feb 2008 00:54:30 +0000 Subject: tweaked console client status with timer and fps core connect/disconnect --- src/sys/sys.cc | 33 +++++++++++++++++++++++++++++---- src/sys/sys.h | 18 +++++++++++++++--- 2 files changed, 44 insertions(+), 7 deletions(-) (limited to 'src/sys') diff --git a/src/sys/sys.cc b/src/sys/sys.cc index dc342bd..9957408 100644 --- a/src/sys/sys.cc +++ b/src/sys/sys.cc @@ -14,14 +14,18 @@ #else +#include #include +#include #include #include #endif #include -bool sys::mkdir(const char *path) +namespace sys { + +bool mkdir(const char *path) { #ifdef _WIN32 ::mkdir(path); @@ -32,7 +36,7 @@ bool sys::mkdir(const char *path) #endif } -void sys::signal(int signum, signalfunc handler) +void signal(int signum, signalfunc handler) { #ifndef _WIN32 struct sigaction sa; @@ -44,6 +48,27 @@ void sys::signal(int signum, signalfunc handler) #endif } -void sys::quit(int status) { - exit(status); +unsigned long time() +{ +#ifndef _WIN32 + struct ::tm localtime; + time_t epochtime = ::time(0); + ::localtime_r(&epochtime, &localtime); + return ((unsigned long) (localtime.tm_sec + localtime.tm_min*60 + localtime.tm_hour*3600)); +#else + retrun 0; +#endif +} + +void sleep(float seconds) +{ +#ifndef _WIN32 + ::usleep((useconds_t) seconds * (useconds_t) 1000000.0 ); +#endif +} + +void quit(int status) { + ::exit(status); +} + } diff --git a/src/sys/sys.h b/src/sys/sys.h index 86642e5..dec5ab9 100644 --- a/src/sys/sys.h +++ b/src/sys/sys.h @@ -9,18 +9,30 @@ #include "config.h" +/// maximum line size throught the game +#define MAXCMDSIZE 1024 + /// contains operating system dependent functions +/** sys is a core subsystem + */ namespace sys { typedef void (* signalfunc)(int signum); /// create a directory - bool mkdir(const char *path); + extern bool mkdir(const char *path); /// intercept OS signals - void signal(int signum, signalfunc handler); + extern void signal(int signum, signalfunc handler); /// quit /** @param status return value */ - void quit(int status); + extern void quit(int status); + + /// suspend process for a number of seconds + extern void sleep(float seconds); + + /// return the current system time of day, in seconds after midnight + extern unsigned long time(); + } #include "sys/consoleinterface.h" -- cgit v1.2.3