Skip to content

Commit a8520ef

Browse files
committed
fix(AsyncMouse): read notes
remove all async mouse interactions that the async mouse is not stopped within the same function
1 parent d94d646 commit a8520ef

File tree

8 files changed

+22
-42
lines changed

8 files changed

+22
-42
lines changed

osrs/antiban/antibantasks.simba

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ begin
4848
pt := Mouse.Position.Random(-350, 350);
4949
until Mouse.Position.DistanceTo(pt) > 50;
5050

51-
AsyncMouse.Move(pt);
51+
Mouse.Move(pt);
5252
end;
5353

5454
procedure TAntiban.LargeRandomMouse();

osrs/interfaces/gametabs/magic.simba

Lines changed: 8 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -207,37 +207,23 @@ WriteLn Magic.CloseInfo();
207207
function TRSMagic.CloseInfo(): Boolean;
208208
var
209209
destination: TPoint;
210-
timeout: UInt64;
211210
begin
212211
destination := GameTab.Bounds.Expand(10).NearestEdge(Target.MouseXY);
213-
AsyncMouse.Move(destination);
214212

215-
timeout := Time() + 3000;
216-
217-
while Self.InfoIsOpen() or (Time() > timeout) do
218-
Sleep(20, 100, ERandomDir.LEFT);
219-
220-
AsyncMouse.Stop();
221-
222-
Result := not Self.InfoIsOpen();
213+
ASyncMouse.Move(destination);
214+
Result := SleepUntil(not Self.InfoIsOpen(), 35, 3000);
215+
ASyncMouse.Stop();
223216
end;
224217

225-
function TRSMagic.CloseInfo({$H-}spell: ERSSpell): Boolean; overload; {$H+}
218+
function TRSMagic.CloseInfo(spell: ERSSpell): Boolean; overload;
226219
var
227220
destination: TPoint;
228-
timeout: UInt64;
229221
begin
230-
destination := GameTab.Bounds.Expand(10).NearestEdge(Target.MouseXY);
231-
AsyncMouse.Move(destination);
232-
233-
timeout := Time() + 3000;
234-
235-
while Self.InfoIsOpen() or (Time() > timeout) do
236-
Sleep(20, 100, ERandomDir.LEFT);
237-
238-
AsyncMouse.Stop();
222+
destination := Self.SpellCache[spell].Box.RandomPointCenter();
239223

240-
Result := not Self.InfoIsOpen();
224+
ASyncMouse.Move(destination);
225+
Result := SleepUntil(not Self.InfoIsOpen(), 35, 3000);
226+
ASyncMouse.Stop();
241227
end;
242228

243229

osrs/interfaces/gametabs/prayer.simba

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -152,22 +152,15 @@ WriteLn Prayer.CloseInfo();
152152
function TRSPrayer.CloseInfo(): Boolean;
153153
var
154154
destination: TPoint;
155-
timeout: UInt64;
156155
begin
157-
if not Self.InfoIsOpen then
156+
if not Self.InfoIsOpen() then
158157
Exit(True);
159158

160159
destination := GameTab.Bounds.Expand(10).NearestEdge(Target.MouseXY);
161-
AsyncMouse.Move(destination);
162-
163-
timeout := Time() + 3000;
164-
165-
while Self.InfoIsOpen() or (Time() > timeout) do
166-
Sleep(20, 100, ERandomDir.LEFT);
167160

161+
AsyncMouse.Move(destination);
162+
Result := SleepUntil(not Self.InfoIsOpen(), 35, 3000);
168163
AsyncMouse.Stop();
169-
170-
Result := not Self.InfoIsOpen();
171164
end;
172165

173166
(*

osrs/interfaces/mainscreen/bank.simba

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -768,9 +768,10 @@ begin
768768
Exit(True);
769769

770770
boxes := Self.Incenerator.Invert(Self.Bounds).SortFrom(Target.MouseXY);
771-
AsyncMouse.Move(boxes[RandomLeft(0, High(boxes))].RandomPoint());
771+
772+
ASyncMouse.Move(boxes[RandomLeft(0, High(boxes))].RandomPoint());
772773
Result := SleepUntil(not Self.InceneratorTooltipVisible(), 100, 1000);
773-
AsyncMouse.Stop();
774+
ASyncMouse.Stop();
774775
end;
775776

776777

osrs/interfaces/setup.simba

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ begin
132132

133133
Mouse.Setup();
134134
Keyboard.Setup();
135-
AsyncMouse := new TASyncMouse(Target);
135+
ASyncMouse := new TASyncMouse(Target);
136136

137137
RSCacheParser.Setup();
138138

osrs/position/map/entities.simba

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -471,7 +471,7 @@ begin
471471
for attempt := 0 to attempts do
472472
begin
473473
if not Self.FindFrom(me, atpa) then Continue;
474-
AsyncMouse.Move(atpa.Random().Random());
474+
Mouse.Move(atpa.Random().Random());
475475
Exit(True);
476476
end;
477477
end;

osrs/position/map/objects.simba

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -433,7 +433,7 @@ function TRSObject.PreHover(me: TPoint; attempts: Integer = 2): Boolean;
433433
```
434434
To understand what this does it's recommended to read {ref}`RSObject.FindFrom`.
435435

436-
This method basically uses {ref}`RSObject.FindFrom` and asynchronously moves the
436+
This method basically uses {ref}`RSObject.FindFrom` and moves the
437437
mouse to one of the matches.
438438
*)
439439
function TRSObject.PreHover(me: TPoint; attempts: Integer = 2): Boolean;
@@ -444,7 +444,7 @@ begin
444444
for attempt := 0 to attempts do
445445
begin
446446
if not Self.FindFrom(me, atpa) then Continue;
447-
AsyncMouse.Move(atpa.Random().Random());
447+
Mouse.Move(atpa.Random().Random());
448448
Exit(True);
449449
end;
450450
end;

utils/input/mouse.simba

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -539,7 +539,7 @@ Global {ref}`TMouse` variable.
539539
Mouse: TMouse;
540540

541541
(*
542-
## AsyncMouse variable
543-
Global {ref}`TAsyncMouse` variable.
542+
## ASyncMouse variable
543+
Global {ref}`TASyncMouse` variable.
544544
*)
545-
AsyncMouse: TASyncMouse;
545+
ASyncMouse: TASyncMouse;

0 commit comments

Comments
 (0)