Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 31 additions & 1 deletion osrs/interfaces/login/login.simba
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ Constant of all the login messages the login screen can handle.
'Login limit exceeded',
'This world is full',
'Your account has been',
'You need a members account',
'You need a members'' account',
'You are standing in a members-only area',
'move your character to a non-members area',
'Authenticator'
Expand Down Expand Up @@ -573,6 +573,34 @@ begin
end;
end;

(*
## Login.SwitchToProfileWorld
```pascal
function TRSLogin.SwitchToProfileWorld(worlds : TIntegerArray): Boolean;
```
Ensures we are on a world declared in the profile, retrying transient failures
before giving up. Returns `True` when the current world matches one from the
profile list.
*)
function TRSLogin.SwitchToProfileWorld(worlds : TIntegerArray): Boolean;
var
attempt, time: Integer;
begin
if (worlds.Length = 0) or worlds.Contains(LoginWorldSwitcher.GetCurrent()) then
Exit(True) ;

for attempt := 0 to 4 do
begin
if LoginWorldSwitcher.Switch(worlds.Random()) then
Exit(True);

if attempt < 4 then
Sleep(Random(10000, 20000) * (1 + attempt));
end;

raise GetDebugLn('Login', 'Failed to switch to a valid world from the profile list after 5 attempts.');
end;

(*
## Login.DoLogin
```pascal
Expand Down Expand Up @@ -604,6 +632,8 @@ begin
Exit;
end;

if not Self.SwitchToProfileWorld(profile.Worlds) then Exit;

if not Self.HandleMessage(Self.GetMessage(), profile.Username, profile.Password) then Exit;
Sleep(600, 1200);
end;
Expand Down