diff --git a/src/d2dx/D2DXContext.cpp b/src/d2dx/D2DXContext.cpp
index 72eb8a5..706177a 100644
--- a/src/d2dx/D2DXContext.cpp
+++ b/src/d2dx/D2DXContext.cpp
@@ -318,37 +318,23 @@ void D2DXContext::CheckMajorGameState()
_majorGameState = MajorGameState::Menus;
- if (_gameHelper->ScreenOpenMode() == 3)
+ if (_gameHelper->IsInGame())
{
_majorGameState = MajorGameState::InGame;
+ AttachLateDetours(_gameHelper.get(), this);
}
else
{
for (int32_t i = 0; i < batchCount; ++i)
{
const Batch& batch = _batches.items[i];
+ const int32_t y0 = _vertices.items[batch.GetStartVertex()].GetY();
- if ((GameAddress)batch.GetGameAddress() == GameAddress::DrawFloor)
+ if (batch.GetHash() == 0x4bea7b80 && y0 >= 550)
{
- _majorGameState = MajorGameState::InGame;
- AttachLateDetours(_gameHelper.get(), this);
+ _majorGameState = MajorGameState::TitleScreen;
break;
- }
- }
-
- if (_majorGameState == MajorGameState::Menus)
- {
- for (int32_t i = 0; i < batchCount; ++i)
- {
- const Batch& batch = _batches.items[i];
- const int32_t y0 = _vertices.items[batch.GetStartVertex()].GetY();
-
- if (batch.GetHash() == 0x4bea7b80 && y0 >= 550)
- {
- _majorGameState = MajorGameState::TitleScreen;
- break;
- }
- }
+ }
}
}
}
diff --git a/src/d2dx/GameHelper.cpp b/src/d2dx/GameHelper.cpp
index c18dca2..d07c663 100644
--- a/src/d2dx/GameHelper.cpp
+++ b/src/d2dx/GameHelper.cpp
@@ -986,3 +986,24 @@ bool GameHelper::IsGameMenuOpen() const
return false;
}
}
+
+bool GameHelper::IsInGame() const
+{
+ auto playerUnit = GetPlayerUnit();
+
+ switch (_version)
+ {
+ case GameVersion::Lod109d:
+ return *((uint32_t*)((uint32_t)_hD2ClientDll + 0x1109FC)) != 0 && playerUnit != 0 && playerUnit->u.v109.path != 0;
+ case GameVersion::Lod112:
+ return *((uint32_t*)((uint32_t)_hD2ClientDll + 0x11BCC4)) != 0 && playerUnit != 0 && playerUnit->u.v112.path != 0;
+ case GameVersion::Lod113c:
+ return *((uint32_t*)((uint32_t)_hD2ClientDll + 0xF8C9C)) != 0 && playerUnit != 0 && playerUnit->u.v112.path != 0;
+ case GameVersion::Lod113d:
+ return *((uint32_t*)((uint32_t)_hD2ClientDll + 0xF79E0)) != 0 && playerUnit != 0 && playerUnit->u.v112.path != 0;
+ case GameVersion::Lod114d:
+ return *((uint32_t*)((uint32_t)_hGameExe + 0x3A27C0)) != 0 && playerUnit != 0 && playerUnit->u.v112.path != 0;
+ default:
+ return false;
+ }
+}
diff --git a/src/d2dx/GameHelper.h b/src/d2dx/GameHelper.h
index ac67431..97a7e9f 100644
--- a/src/d2dx/GameHelper.h
+++ b/src/d2dx/GameHelper.h
@@ -73,6 +73,8 @@ namespace d2dx
virtual int32_t GetCurrentAct() const override;
virtual bool IsGameMenuOpen() const override;
+
+ virtual bool IsInGame() const override;
private:
GameVersion GetGameVersion();
diff --git a/src/d2dx/IGameHelper.h b/src/d2dx/IGameHelper.h
index d0f3e72..177c6d1 100644
--- a/src/d2dx/IGameHelper.h
+++ b/src/d2dx/IGameHelper.h
@@ -97,5 +97,7 @@ namespace d2dx
virtual int32_t GetCurrentAct() const = 0;
virtual bool IsGameMenuOpen() const = 0;
+
+ virtual bool IsInGame() const = 0;
};
}
diff --git a/src/d2dx/d2dx.vcxproj.user b/src/d2dx/d2dx.vcxproj.user
index 796b50a..9ff5d28 100644
--- a/src/d2dx/d2dx.vcxproj.user
+++ b/src/d2dx/d2dx.vcxproj.user
@@ -8,9 +8,9 @@
NativeOnly
- C:\games\Diablo II\Game.exe
+ C:\games\Diablo II\game.exe
WindowsLocalDebugger
- -3dfx -ns -w -dxtestmop -dxnoclipcursor
+ -3dfx -ns -w -dxnoclipcursor
C:\games\Diablo II\
NativeOnly