Skip to content

Commit 0365dc2

Browse files
committed
Merge branch 'pr/116'
2 parents 34d7526 + d502c6a commit 0365dc2

File tree

1 file changed

+31
-1
lines changed

1 file changed

+31
-1
lines changed

osrs/interfaces/login/login.simba

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ Constant of all the login messages the login screen can handle.
4444
'Login limit exceeded',
4545
'This world is full',
4646
'Your account has been',
47-
'You need a members account',
47+
'You need a members'' account',
4848
'You are standing in a members-only area',
4949
'move your character to a non-members area',
5050
'Authenticator'
@@ -573,6 +573,34 @@ begin
573573
end;
574574
end;
575575

576+
(*
577+
## Login.SwitchToProfileWorld
578+
```pascal
579+
function TRSLogin.SwitchToProfileWorld(worlds : TIntegerArray): Boolean;
580+
```
581+
Ensures we are on a world declared in the profile, retrying transient failures
582+
before giving up. Returns `True` when the current world matches one from the
583+
profile list.
584+
*)
585+
function TRSLogin.SwitchToProfileWorld(worlds : TIntegerArray): Boolean;
586+
var
587+
attempt, time: Integer;
588+
begin
589+
if (worlds.Length = 0) or worlds.Contains(LoginWorldSwitcher.GetCurrent()) then
590+
Exit(True) ;
591+
592+
for attempt := 0 to 4 do
593+
begin
594+
if LoginWorldSwitcher.Switch(worlds.Random()) then
595+
Exit(True);
596+
597+
if attempt < 4 then
598+
Sleep(Random(10000, 20000) * (1 + attempt));
599+
end;
600+
601+
raise GetDebugLn('Login', 'Failed to switch to a valid world from the profile list after 5 attempts.');
602+
end;
603+
576604
(*
577605
## Login.DoLogin
578606
```pascal
@@ -604,6 +632,8 @@ begin
604632
Exit;
605633
end;
606634

635+
if not Self.SwitchToProfileWorld(profile.Worlds) then Exit;
636+
607637
if not Self.HandleMessage(Self.GetMessage(), profile.Username, profile.Password) then Exit;
608638
Sleep(600, 1200);
609639
end;

0 commit comments

Comments
 (0)