From 327317457b54dfedf76ca6d0fe52be4ebf233d35 Mon Sep 17 00:00:00 2001 From: piaip Date: Sat, 12 Jan 2008 10:00:52 +0000 Subject: - bbslua: fixed bbs.clock() calculation on win32 port git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@3827 63ad8ddf-47c3-0310-b6dd-a9e9d9715204 --- mbbsd/bbslua.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'mbbsd') diff --git a/mbbsd/bbslua.c b/mbbsd/bbslua.c index 5567c53e..dd1e2ded 100644 --- a/mbbsd/bbslua.c +++ b/mbbsd/bbslua.c @@ -580,12 +580,18 @@ bl_clock(lua_State *L) { double d = 0; -#ifdef _WIN32 - - DWORD ms = timeGetTime() % 1000; - syncnow(); - d = now + ms / 1000.0f; - +#ifdef _WIN32 + + // XXX this is a fast hack because we don't want to do 64bit calculation. + SYSTEMTIME st; + GetSystemTime(&st); + syncnow(); + // XXX the may be some latency between our GetSystemTime and syncnow. + // So build again the "second" part. + d = (int)((now / 60) * 60); + d += st.wSecond; + d += (st.wMilliseconds / 1000.0f); + #else // !_WIN32 struct timeval tp; -- cgit v1.2.3