diff options
author | piaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2008-01-12 18:00:52 +0800 |
---|---|---|
committer | piaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2008-01-12 18:00:52 +0800 |
commit | 327317457b54dfedf76ca6d0fe52be4ebf233d35 (patch) | |
tree | 84fc44f05d0d699b360f6b35ea04181f82e3bea1 | |
parent | 41ba68ede3031168e05f3e8b9837e41f5d025cf0 (diff) | |
download | pttbbs-327317457b54dfedf76ca6d0fe52be4ebf233d35.tar pttbbs-327317457b54dfedf76ca6d0fe52be4ebf233d35.tar.gz pttbbs-327317457b54dfedf76ca6d0fe52be4ebf233d35.tar.bz2 pttbbs-327317457b54dfedf76ca6d0fe52be4ebf233d35.tar.lz pttbbs-327317457b54dfedf76ca6d0fe52be4ebf233d35.tar.xz pttbbs-327317457b54dfedf76ca6d0fe52be4ebf233d35.tar.zst pttbbs-327317457b54dfedf76ca6d0fe52be4ebf233d35.zip |
- bbslua: fixed bbs.clock() calculation on win32 port
git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@3827 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
-rw-r--r-- | mbbsd/bbslua.c | 18 |
1 files changed, 12 insertions, 6 deletions
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; |