Mercurial > mm7
changeset 2045:696545f20be7
m
author | Ritor1 |
---|---|
date | Thu, 28 Nov 2013 17:14:24 +0600 |
parents | 28cb79ae2f6f |
children | ed880ccf468f |
files | Time.cpp Time.h |
diffstat | 2 files changed, 0 insertions(+), 162 deletions(-) [+] |
line wrap: on
line diff
--- a/Time.cpp Thu Nov 28 17:12:50 2013 +0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,104 +0,0 @@ - -#include "Time.h" -#include "Keyboard.h" -#include "Log.h" - -#include "OSAPI.h" - - - - - -Timer *pMiscTimer = new Timer; -Timer *pEventTimer; - - - - - - -//----- (00426317) -------------------------------------------------------- -unsigned __int64 Timer::Time() -{ - unsigned __int64 v2 = TimeQuant * timeGetTime() / 1000; - if (v2 < uStartTime) - uStartTime = 0; - return v2; -} - - - -//----- (00426349) -------------------------------------------------------- -void Timer::Pause() -{ - if (!bPaused) - { - uStopTime = Time(); - bPaused = true; - } -} - - -//----- (00426363) -------------------------------------------------------- -void Timer::Resume() -{ - if (bPaused) - { - pKeyActionMap->ResetKeys(); - bPaused = 0; - uStartTime = Time(); - } -} - -//----- (00426386) -------------------------------------------------------- -void Timer::TrackGameTime() -{ - if (!bTackGameTime) - { - uGameTimeStart = Time(); - bTackGameTime = true; - } -} - - - -//----- (004263A0) -------------------------------------------------------- -void Timer::StopGameTime() -{ - if (bTackGameTime) - { - bTackGameTime = 0; - uStartTime = Time(); - } -} - -//----- (004263B7) -------------------------------------------------------- -void Timer::Update() -{ - //Timer *v1; // esi@1 - //unsigned int v2; // eax@2 - //signed int v3; // eax@3 - //char v4; // zf@5 - - - unsigned __int64 new_time = Time(); - while (new_time <= uStartTime) - new_time = Time(); - - uTimeElapsed = new_time - uStartTime; - uStartTime = new_time; - - if (uTimeElapsed > 32) - uTimeElapsed = 32; - - if (!bPaused && !bTackGameTime) - uTotalGameTimeElapsed += uTimeElapsed; - dt_in_some_format = (uTimeElapsed << 16) / 128; -} - -//----- (00426402) -------------------------------------------------------- -void Timer::Initialize() -{ - uTotalGameTimeElapsed = 0; - bReady = true; -}
--- a/Time.h Thu Nov 28 17:12:50 2013 +0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,58 +0,0 @@ -#pragma once - - - - -/* 61 */ -#pragma pack(push, 1) -struct Timer -{ - static Timer *Create() {return new Timer;} - - Timer(): - bReady(false), bPaused(false) - { - bTackGameTime = 0; - uStartTime = 0; - uStopTime = 0; - uGameTimeStart = 0; - field_18 = 0; - uTimeElapsed = 0; - dt_in_some_format = 0; - uTotalGameTimeElapsed = 0; - } - - void Initialize(); - unsigned __int64 Time(); - void Update(); - void Pause(); - void Resume(); - void TrackGameTime(); - void StopGameTime(); - - unsigned int bReady; - unsigned int bPaused; - int bTackGameTime; - unsigned int uStartTime; - unsigned int uStopTime; - int uGameTimeStart; - int field_18; - unsigned int uTimeElapsed; - int dt_in_some_format; - unsigned int uTotalGameTimeElapsed; - - static const unsigned int TimeQuant = 128; - static const unsigned int Minute = 2 * TimeQuant; - static const unsigned int Hour = 60 * Minute; - static const unsigned int Day = 24 * Hour; - static const unsigned int Week = 7 * Day; - static const unsigned int Month = 4 * Week; - static const unsigned int Year = 12 * Month; -}; - -#pragma pack(pop) - - - -extern Timer *pMiscTimer; -extern Timer *pEventTimer; \ No newline at end of file