Mercurial > mm7
changeset 2044:28cb79ae2f6f
Time.h rename
author | Ritor1 |
---|---|
date | Thu, 28 Nov 2013 17:12:50 +0600 |
parents | 2ccf638342d6 |
children | 696545f20be7 |
files | Actor.cpp Arcomage.cpp AudioPlayer.cpp Build/Visual Studio 2010/World of Might and Magic.vcxproj Build/Visual Studio 2010/World of Might and Magic.vcxproj.filters CastSpellInfo.cpp Chest.cpp DecalBuilder.cpp GUIWindow.cpp Game.cpp Indoor.cpp OSWindow.cpp Outdoor.cpp Overlays.cpp ParticleEngine.cpp Party.cpp Render.cpp SaveLoad.cpp SpriteObject.cpp Timer.cpp Timer.h TurnEngine.cpp UI/UICharacter.cpp UI/UIPartyCreation.cpp UI/UIPopup.cpp UI/UIRest.cpp UI/UITransition.cpp UI/UiGame.cpp VideoPlayer.cpp mm7_2.cpp mm7_3.cpp mm7_4.cpp mm7_5.cpp mm7_6.cpp stru6.cpp |
diffstat | 35 files changed, 197 insertions(+), 36 deletions(-) [+] |
line wrap: on
line diff
--- a/Actor.cpp Tue Nov 26 17:49:42 2013 +0600 +++ b/Actor.cpp Thu Nov 28 17:12:50 2013 +0600 @@ -21,7 +21,7 @@ #include "TurnEngine.h" #include "MapInfo.h" #include "CastSpellInfo.h" -#include "Time.h" +#include "Timer.h" #include "LOD.h" #include "Party.h" #include "GUIWindow.h"
--- a/Arcomage.cpp Tue Nov 26 17:49:42 2013 +0600 +++ b/Arcomage.cpp Thu Nov 28 17:12:50 2013 +0600 @@ -11,7 +11,7 @@ #include "Mouse.h" #include "Game.h" #include "Viewport.h" -#include "Time.h" +#include "Timer.h" #include "GUIFont.h" #include "Party.h" #include "GUIWindow.h"
--- a/AudioPlayer.cpp Tue Nov 26 17:49:42 2013 +0600 +++ b/AudioPlayer.cpp Thu Nov 28 17:12:50 2013 +0600 @@ -14,7 +14,7 @@ #include "Actor.h" #include "Game.h" #include "DecorationList.h" -#include "Time.h" +#include "Timer.h" #include "OSInfo.h" #include "OurMath.h" #include "MapInfo.h"
--- a/Build/Visual Studio 2010/World of Might and Magic.vcxproj Tue Nov 26 17:49:42 2013 +0600 +++ b/Build/Visual Studio 2010/World of Might and Magic.vcxproj Thu Nov 28 17:12:50 2013 +0600 @@ -198,7 +198,7 @@ <ClCompile Include="..\..\texts.cpp" /> <ClCompile Include="..\..\Texture.cpp" /> <ClCompile Include="..\..\TileTable.cpp" /> - <ClCompile Include="..\..\Time.cpp" /> + <ClCompile Include="..\..\Timer.cpp" /> <ClCompile Include="..\..\TurnEngine.cpp" /> <ClCompile Include="..\..\UI\Books\UIMapBook.cpp" /> <ClCompile Include="..\..\UI\Books\UINotesBooks.cpp" /> @@ -366,7 +366,7 @@ <ClInclude Include="..\..\texts.h" /> <ClInclude Include="..\..\Texture.h" /> <ClInclude Include="..\..\TileFrameTable.h" /> - <ClInclude Include="..\..\Time.h" /> + <ClInclude Include="..\..\Timer.h" /> <ClInclude Include="..\..\TurnEngine.h" /> <ClInclude Include="..\..\UI\UIBooks.h" /> <ClInclude Include="..\..\UI\UIHouses.h" />
--- a/Build/Visual Studio 2010/World of Might and Magic.vcxproj.filters Tue Nov 26 17:49:42 2013 +0600 +++ b/Build/Visual Studio 2010/World of Might and Magic.vcxproj.filters Thu Nov 28 17:12:50 2013 +0600 @@ -75,7 +75,6 @@ <ClInclude Include="..\..\texts.h" /> <ClInclude Include="..\..\Texture.h" /> <ClInclude Include="..\..\TileFrameTable.h" /> - <ClInclude Include="..\..\Time.h" /> <ClInclude Include="..\..\TurnEngine.h" /> <ClInclude Include="..\..\VectorTypes.h" /> <ClInclude Include="..\..\VideoPlayer.h" /> @@ -285,6 +284,7 @@ <ClInclude Include="..\..\UI\UIHouses.h"> <Filter>UI</Filter> </ClInclude> + <ClInclude Include="..\..\Timer.h" /> </ItemGroup> <ItemGroup> <Filter Include="lib"> @@ -399,7 +399,6 @@ <ClCompile Include="..\..\texts.cpp" /> <ClCompile Include="..\..\Texture.cpp" /> <ClCompile Include="..\..\TileTable.cpp" /> - <ClCompile Include="..\..\Time.cpp" /> <ClCompile Include="..\..\TurnEngine.cpp" /> <ClCompile Include="..\..\VectorTypes.cpp" /> <ClCompile Include="..\..\VideoPlayer.cpp" /> @@ -605,6 +604,7 @@ <ClCompile Include="..\..\UI\Books\UINotesBooks.cpp"> <Filter>UI\Books</Filter> </ClCompile> + <ClCompile Include="..\..\Timer.cpp" /> </ItemGroup> <ItemGroup> <CustomBuild Include="..\..\NewUI\Core\UIControlModule.swig">
--- a/CastSpellInfo.cpp Tue Nov 26 17:49:42 2013 +0600 +++ b/CastSpellInfo.cpp Thu Nov 28 17:12:50 2013 +0600 @@ -18,7 +18,7 @@ #include "SpriteObject.h" #include "ObjectList.h" #include "stru123.h" -#include "Time.h" +#include "Timer.h" #include "IconFrameTable.h" #include "Awards.h" #include "TurnEngine.h"
--- a/Chest.cpp Tue Nov 26 17:49:42 2013 +0600 +++ b/Chest.cpp Thu Nov 28 17:12:50 2013 +0600 @@ -19,7 +19,7 @@ #include "Texts.h" #include "ObjectList.h" #include "GUIWindow.h" -#include "Time.h" +#include "Timer.h" #include "Overlays.h" #include "mm7_data.h"
--- a/DecalBuilder.cpp Tue Nov 26 17:49:42 2013 +0600 +++ b/DecalBuilder.cpp Thu Nov 28 17:12:50 2013 +0600 @@ -1,6 +1,6 @@ #include "DecalBuilder.h" #include "Game.h" -#include "Time.h" +#include "Timer.h" #include "stru314.h" #include "Outdoor.h" #include "Log.h"
--- a/GUIWindow.cpp Tue Nov 26 17:49:42 2013 +0600 +++ b/GUIWindow.cpp Thu Nov 28 17:12:50 2013 +0600 @@ -10,7 +10,7 @@ #include "OurMath.h" #include "VideoPlayer.h" #include "MapInfo.h" -#include "Time.h" +#include "Timer.h" #include "AudioPlayer.h" #include "Mouse.h" #include "Viewport.h"
--- a/Game.cpp Tue Nov 26 17:49:42 2013 +0600 +++ b/Game.cpp Thu Nov 28 17:12:50 2013 +0600 @@ -18,7 +18,7 @@ #include "Game.h" #include "Party.h" #include "Viewport.h" -#include "Time.h" +#include "Timer.h" #include "Outdoor.h" #include "Outdoor_stuff.h" #include "Overlays.h"
--- a/Indoor.cpp Tue Nov 26 17:49:42 2013 +0600 +++ b/Indoor.cpp Thu Nov 28 17:12:50 2013 +0600 @@ -14,7 +14,7 @@ #include "Events.h" #include "Game.h" #include "Viewport.h" -#include "Time.h" +#include "Timer.h" #include "Party.h" #include "OurMath.h" #include "LOD.h"
--- a/OSWindow.cpp Tue Nov 26 17:49:42 2013 +0600 +++ b/OSWindow.cpp Thu Nov 28 17:12:50 2013 +0600 @@ -4,7 +4,7 @@ #include "AudioPlayer.h" #include "VideoPlayer.h" #include "Mouse.h" -#include "Time.h" +#include "Timer.h" #include "GUIWindow.h" #include "Party.h" #include "Game.h"
--- a/Outdoor.cpp Tue Nov 26 17:49:42 2013 +0600 +++ b/Outdoor.cpp Thu Nov 28 17:12:50 2013 +0600 @@ -21,7 +21,7 @@ #include "Actor.h" #include "Chest.h" #include "stru123.h" -#include "Time.h" +#include "Timer.h" #include "Viewport.h" #include "Events.h" #include "ParticleEngine.h" @@ -3926,7 +3926,6 @@ pZ -= 30; v113 -= 30; pParty->uFallSpeed = 0; - //pParty->uFallSpeed = 0; pParty->bFlying = true; pModel = (BSPModel *)1; if ( pZ <= v111 )
--- a/Overlays.cpp Tue Nov 26 17:49:42 2013 +0600 +++ b/Overlays.cpp Thu Nov 28 17:12:50 2013 +0600 @@ -8,7 +8,7 @@ #include "Sprites.h" #include "FrameTableInc.h" #include "IconFrameTable.h" -#include "Time.h" +#include "Timer.h" #include "Party.h" #include "TurnEngine.h" #include "LOD.h"
--- a/ParticleEngine.cpp Tue Nov 26 17:49:42 2013 +0600 +++ b/ParticleEngine.cpp Thu Nov 28 17:12:50 2013 +0600 @@ -1,5 +1,5 @@ #include "ParticleEngine.h" -#include "Time.h" +#include "Timer.h" #include "Render.h" #include "Viewport.h" #include "Outdoor.h"
--- a/Party.cpp Tue Nov 26 17:49:42 2013 +0600 +++ b/Party.cpp Thu Nov 28 17:12:50 2013 +0600 @@ -4,7 +4,7 @@ #include "Party.h" #include "MapInfo.h" -#include "Time.h" +#include "Timer.h" #include "AudioPlayer.h" #include "IconFrameTable.h" #include "Mouse.h"
--- a/Render.cpp Tue Nov 26 17:49:42 2013 +0600 +++ b/Render.cpp Thu Nov 28 17:12:50 2013 +0600 @@ -18,7 +18,7 @@ #include "Viewport.h" #include "OurMath.h" #include "PaletteManager.h" -#include "Time.h" +#include "Timer.h" #include "Game.h" #include "LightmapBuilder.h" #include "ObjectList.h"
--- a/SaveLoad.cpp Tue Nov 26 17:49:42 2013 +0600 +++ b/SaveLoad.cpp Thu Nov 28 17:12:50 2013 +0600 @@ -13,7 +13,7 @@ #include "AudioPlayer.h" #include "Actor.h" #include "Chest.h" -#include "Time.h" +#include "Timer.h" #include "GUIWindow.h" #include "GUIFont.h" #include "Overlays.h"
--- a/SpriteObject.cpp Tue Nov 26 17:49:42 2013 +0600 +++ b/SpriteObject.cpp Thu Nov 28 17:12:50 2013 +0600 @@ -8,7 +8,7 @@ #include "Indoor.h" #include "Outdoor.h" #include "ParticleEngine.h" -#include "Time.h" +#include "Timer.h" #include "Game.h" #include "LOD.h" #include "Actor.h"
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Timer.cpp Thu Nov 28 17:12:50 2013 +0600 @@ -0,0 +1,104 @@ + +#include "Timer.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; +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Timer.h Thu Nov 28 17:12:50 2013 +0600 @@ -0,0 +1,58 @@ +#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
--- a/TurnEngine.cpp Tue Nov 26 17:49:42 2013 +0600 +++ b/TurnEngine.cpp Thu Nov 28 17:12:50 2013 +0600 @@ -6,7 +6,7 @@ #include "Party.h" #include "AudioPlayer.h" #include "SpriteObject.h" -#include "Time.h" +#include "Timer.h" #include "stru298.h" #include "IconFrameTable.h" #include "Viewport.h"
--- a/UI/UICharacter.cpp Tue Nov 26 17:49:42 2013 +0600 +++ b/UI/UICharacter.cpp Thu Nov 28 17:12:50 2013 +0600 @@ -14,7 +14,7 @@ #include "..\Render.h" #include "..\LOD.h" #include "..\Viewport.h" -#include "..\Time.h" +#include "..\Timer.h" #include "..\Awards.h" #include "..\CastSpellInfo.h" #include "..\texts.h"
--- a/UI/UIPartyCreation.cpp Tue Nov 26 17:49:42 2013 +0600 +++ b/UI/UIPartyCreation.cpp Thu Nov 28 17:12:50 2013 +0600 @@ -12,7 +12,7 @@ #include "..\AudioPlayer.h" #include "..\Render.h" #include "..\LOD.h" -#include "..\Time.h" +#include "..\Timer.h" #include "..\IconFrameTable.h" #include "..\texts.h"
--- a/UI/UIPopup.cpp Tue Nov 26 17:49:42 2013 +0600 +++ b/UI/UIPopup.cpp Thu Nov 28 17:12:50 2013 +0600 @@ -20,7 +20,7 @@ #include "..\ObjectList.h" #include "..\Chest.h" #include "..\PaletteManager.h" -#include "..\Time.h" +#include "..\Timer.h" #include "..\texts.h" #include "..\mm7_data.h"
--- a/UI/UIRest.cpp Tue Nov 26 17:49:42 2013 +0600 +++ b/UI/UIRest.cpp Thu Nov 28 17:12:50 2013 +0600 @@ -9,7 +9,7 @@ #include "..\Outdoor.h" #include "..\LOD.h" #include "..\Viewport.h" -#include "..\Time.h" +#include "..\Timer.h" #include "..\texts.h" #include "..\mm7_data.h"
--- a/UI/UITransition.cpp Tue Nov 26 17:49:42 2013 +0600 +++ b/UI/UITransition.cpp Thu Nov 28 17:12:50 2013 +0600 @@ -14,7 +14,7 @@ #include "..\AudioPlayer.h" #include "..\Outdoor.h" #include "..\LOD.h" -#include "..\Time.h" +#include "..\Timer.h" #include "..\stru159.h" #include "..\Events2D.h" #include "..\texts.h"
--- a/UI/UiGame.cpp Tue Nov 26 17:49:42 2013 +0600 +++ b/UI/UiGame.cpp Thu Nov 28 17:12:50 2013 +0600 @@ -25,7 +25,7 @@ #include "..\DecorationList.h" #include "..\PlayerFrameTable.h" #include "..\stru123.h" -#include "..\Time.h" +#include "..\Timer.h" #include "..\IconFrameTable.h" #include "..\TurnEngine.h" #include "..\texts.h"
--- a/VideoPlayer.cpp Tue Nov 26 17:49:42 2013 +0600 +++ b/VideoPlayer.cpp Thu Nov 28 17:12:50 2013 +0600 @@ -16,7 +16,7 @@ #include "Render.h" #include "Party.h" #include "GUIWindow.h" -#include "Time.h" +#include "Timer.h" #include "Log.h" #include "texts.h" #include "UI\UIHouses.h"
--- a/mm7_2.cpp Tue Nov 26 17:49:42 2013 +0600 +++ b/mm7_2.cpp Thu Nov 28 17:12:50 2013 +0600 @@ -48,7 +48,7 @@ #include "SaveLoad.h" #include "stru123.h" #include "stru176.h" -#include "Time.h" +#include "Timer.h" #include "IconFrameTable.h" #include "GUIProgressBar.h" #include "Bink_Smacker.h"
--- a/mm7_3.cpp Tue Nov 26 17:49:42 2013 +0600 +++ b/mm7_3.cpp Thu Nov 28 17:12:50 2013 +0600 @@ -34,7 +34,7 @@ #include "PaletteManager.h" #include "DecorationList.h" #include "stru123.h" -#include "Time.h" +#include "Timer.h" #include "IconFrameTable.h" #include "TurnEngine.h" #include "Events2D.h"
--- a/mm7_4.cpp Tue Nov 26 17:49:42 2013 +0600 +++ b/mm7_4.cpp Thu Nov 28 17:12:50 2013 +0600 @@ -29,7 +29,7 @@ #include "SpriteObject.h" #include "ObjectList.h" #include "DecorationList.h" -#include "Time.h" +#include "Timer.h" #include "IconFrameTable.h" #include "PlayerFrameTable.h" #include "Awards.h"
--- a/mm7_5.cpp Tue Nov 26 17:49:42 2013 +0600 +++ b/mm7_5.cpp Thu Nov 28 17:12:50 2013 +0600 @@ -13,7 +13,7 @@ #include "Viewport.h" #include "OurMath.h" #include "SpriteObject.h" -#include "Time.h" +#include "Timer.h" #include "stru298.h" #include "Lights.h" #include "Level/Decoration.h"