Skip to content

Commit 1846be5

Browse files
committed
tweaks to Pauwelz PR
1 parent 0365dc2 commit 1846be5

File tree

1 file changed

+14
-11
lines changed

1 file changed

+14
-11
lines changed

osrs/interfaces/login/login.simba

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -574,25 +574,21 @@ begin
574574
end;
575575

576576
(*
577-
## Login.SwitchToProfileWorld
577+
## Login.SwitchWorld
578578
```pascal
579-
function TRSLogin.SwitchToProfileWorld(worlds : TIntegerArray): Boolean;
579+
procedure TRSLogin.SwitchWorld(worlds: TIntegerArray);
580580
```
581581
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.
582+
before giving up.
584583
*)
585-
function TRSLogin.SwitchToProfileWorld(worlds : TIntegerArray): Boolean;
584+
procedure TRSLogin.SwitchWorld(worlds: TIntegerArray);
586585
var
587586
attempt, time: Integer;
588587
begin
589-
if (worlds.Length = 0) or worlds.Contains(LoginWorldSwitcher.GetCurrent()) then
590-
Exit(True) ;
591-
592588
for attempt := 0 to 4 do
593589
begin
594590
if LoginWorldSwitcher.Switch(worlds.Random()) then
595-
Exit(True);
591+
Exit;
596592

597593
if attempt < 4 then
598594
Sleep(Random(10000, 20000) * (1 + attempt));
@@ -618,6 +614,7 @@ WriteLn Login.DoLogin(profile);
618614
function TRSLogin.DoLogin(profile: TProfile = Default(TProfile)): Boolean;
619615
var
620616
timeout: UInt64;
617+
switched: Boolean;
621618
begin
622619
if profile = Default(TProfile) then
623620
profile := Profiles.Get();
@@ -632,9 +629,15 @@ begin
632629
Exit;
633630
end;
634631

635-
if not Self.SwitchToProfileWorld(profile.Worlds) then Exit;
632+
if not switched and (profile.Worlds <> []) and
633+
not profile.Worlds.Contains(LoginWorldSwitcher.GetCurrent()) then
634+
begin
635+
Self.SwitchWorld(profile.Worlds);
636+
switched := True;
637+
end;
636638

637-
if not Self.HandleMessage(Self.GetMessage(), profile.Username, profile.Password) then Exit;
639+
if not Self.HandleMessage(Self.GetMessage(), profile.Username, profile.Password) then
640+
Exit;
638641
Sleep(600, 1200);
639642
end;
640643

0 commit comments

Comments
 (0)