Make iCursor threadsafe.

This commit is contained in:
Riley 2024-05-27 21:35:38 -05:00
parent 6f22959aec
commit 0f511b7f24
4 changed files with 8 additions and 4 deletions

View File

@ -2307,7 +2307,8 @@ void CMenu::Render()
AddDraggable("Conditions", Vars::Menu::ConditionsDisplay, FGet(Vars::Menu::Indicators) & (1 << 4)); AddDraggable("Conditions", Vars::Menu::ConditionsDisplay, FGet(Vars::Menu::Indicators) & (1 << 4));
AddDraggable("Seed prediction", Vars::Menu::SeedPredictionDisplay, FGet(Vars::Menu::Indicators) & (1 << 5)); AddDraggable("Seed prediction", Vars::Menu::SeedPredictionDisplay, FGet(Vars::Menu::Indicators) & (1 << 5));
F::Render.Cursor = GetMouseCursor(); //F::Render.Cursor = GetMouseCursor();
F::Render.m_iCursor.store(ImGui::GetMouseCursor());
} }
else else
mActives.clear(); mActives.clear();

View File

@ -30,7 +30,7 @@ void CRender::Render(IDirect3DDevice9* pDevice)
PushFont(FontRegular); PushFont(FontRegular);
F::Menu.Render(); F::Menu.Render();
PopFont(); PopFont();
EndFrame(); EndFrame();

View File

@ -3,6 +3,8 @@
#include <ImGui/imgui_impl_dx9.h> #include <ImGui/imgui_impl_dx9.h>
#include <ImGui/imgui.h> #include <ImGui/imgui.h>
#include <atomic>
class CRender class CRender
{ {
public: public:
@ -12,7 +14,7 @@ public:
void LoadColors(); void LoadColors();
void LoadStyle(); void LoadStyle();
int Cursor = 2; std::atomic<int> m_iCursor = ATOMIC_VAR_INIT(0);
// Colors // Colors
ImColor Accent = { 255, 101, 101 }; ImColor Accent = { 255, 101, 101 };

View File

@ -82,7 +82,8 @@ MAKE_HOOK(VGuiSurface_SetCursor, U::Memory.GetVFunc(I::MatSystemSurface, 51), vo
{ {
if (F::Menu.IsOpen) if (F::Menu.IsOpen)
{ {
switch (F::Render.Cursor) auto iCursor = F::Render.m_iCursor.load();
switch(iCursor)
{ {
case 0: cursor = 2; break; case 0: cursor = 2; break;
case 1: cursor = 3; break; case 1: cursor = 3; break;