Skip to content

Commit 0964bec

Browse files
committed
fix(remoteinput): add pairing failing warnings
1 parent 43ac681 commit 0964bec

File tree

1 file changed

+31
-7
lines changed

1 file changed

+31
-7
lines changed

osrs/fakeinput.simba

Lines changed: 31 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,26 +46,50 @@ Internal method used to setup {ref}`TRemoteInput`.
4646
This is automatically called for you on the {ref}`RemoteInput variable`.
4747
*)
4848
procedure TRemoteInput.Setup();
49-
const
50-
TIMEOUT: UInt64 := GetTimeRunning() + 2000;
49+
var
50+
timer: TCountDown;
5151
begin
5252
if GetSimbaTargetWindow().GetClassName() <> 'SunAwtCanvas' then Exit;
5353

54-
RIInject(GetSimbaTargetPID());
54+
try
55+
RIInject(GetSimbaTargetPID());
56+
except
57+
if GetExceptionMessage() = 'Access violation' then
58+
raise GetDebugLn('RemoteInput', 'A different RemoteInput has already been paired with this client. Please open a new one.')
59+
else
60+
raise GetExceptionMessage();
61+
end;
5562

63+
timer.Start(2000);
5664
repeat
57-
Self.Target := EIOS_PairClient(GetSimbaTargetPID());
58-
if Self.Target <> nil then Break;
65+
try
66+
Self.Target := EIOS_PairClient(GetSimbaTargetPID());
67+
except
68+
if GetExceptionMessage() = 'Access violation' then
69+
raise GetDebugLn('RemoteInput', 'A different RemoteInput has already been paired with this client. Please open a new one.')
70+
else
71+
raise GetExceptionMessage();
72+
end;
73+
74+
if Self.Target <> nil then
75+
Break;
5976
Sleep(100);
60-
until GetTimeRunning() > TIMEOUT;
77+
until timer.IsFinished;
6178

6279
if Self.Target = nil then
6380
begin
6481
WriteLn GetDebugLn('RemoteInput', 'Invalid target for RemoteInput, RemoteInput will not be used.', ELogLevel.WARN);
6582
Exit;
6683
end;
6784

68-
Target.SetPlugin({$MACRO LOADEDLIB(libremoteinput)}, ToStr(GetSimbaTargetPID()), RSClient.Canvas);
85+
try
86+
Target.SetPlugin({$MACRO LOADEDLIB(libremoteinput)}, ToStr(GetSimbaTargetPID()), RSClient.Canvas);
87+
except
88+
if GetExceptionMessage() = 'Access violation' then
89+
raise GetDebugLn('RemoteInput', 'A different RemoteInput has already been paired with this client. Please open a new one.')
90+
else
91+
raise GetExceptionMessage();
92+
end;
6993
end;
7094

7195
var

0 commit comments

Comments
 (0)