Skip to content

Commit 51a4774

Browse files
committed
tweaks(assets): read notes
- the timeout is now decreased as files are successfully downloaded, making it not have a extremely long timeout if you had to download too many files - suggests to users to delete cache and assets if it fails
1 parent 8607db7 commit 51a4774

File tree

4 files changed

+15
-11
lines changed

4 files changed

+15
-11
lines changed

osrs/antiban/biometrics.simba

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ begin
8686
end;
8787

8888
hashStr := HashString(EHashAlgo.SHA1, Profiles[ProfileIndex].Name + Profiles[ProfileIndex].Username);
89-
WriteLn GetDebugLn('Biometrics', 'Current profile seed: ' + hashStr, ELogLevel.SUCCESS);
89+
WriteLn GetDebugLn('Biometrics', 'Current profile seed: ' + hashStr);
9090

9191
Self.Index := ProfileIndex;
9292
Self._Hash := hashStr.ToBytes();

osrs/finders/itemfinder.simba

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ type
3030

3131
function TRSItemFinder._AlignHelper(img: TImage; tBorder, border: TPointArray; out align: TPoint): Boolean;
3232
var
33-
color: TColor;
3433
pt: TPoint;
3534
begin
3635
if border = [] then Exit;
@@ -478,7 +477,6 @@ begin
478477
img.DrawTPA(bg);
479478

480479
Result := HashData(EHashAlgo.CRC32, img.Data, 4608);
481-
WriteLn Result;
482480
end;
483481

484482
var

osrs/interfaces/login/login.simba

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -371,13 +371,13 @@ begin
371371
begin
372372
if Self.FindButton(ERSLoginButton.EXISTING_USER) then
373373
begin
374-
WriteLn GetDebugLn('Login', 'Legacy client mode detected.', ELogLevel.SUCCESS);
374+
WriteLn GetDebugLn('Login', 'Legacy client mode detected.');
375375
Exit(ERSLoginMode.LEGACY);
376376
end;
377377

378378
if Self.FindButton(ERSLoginButton.LAUNCHER) then
379379
begin
380-
WriteLn GetDebugLn('Login', 'Launcher client mode detected.', ELogLevel.SUCCESS);
380+
WriteLn GetDebugLn('Login', 'Launcher client mode detected.');
381381
Exit(ERSLoginMode.LAUNCHER);
382382
end;
383383
end;

utils/assets.simba

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ type
1010
JSON: TJSONObject;
1111
Queue: TStringArray;
1212
URL: String;
13+
Timeout: TCountDown;
1314
end;
1415

1516
function TWLAssets.GetJSON(url: String): TJSONObject;
@@ -66,17 +67,21 @@ var
6667
idx: Integer;
6768
begin
6869
if not InRange(result.Response.AsInteger, 200, 299) then
69-
raise GetDebugLn('WLAssets', result.Exception);
70+
begin
71+
WriteLn GetDebugLn('WLAssets', result.Exception, ELogLevel.ERROR);
72+
raise GetDebugLn('WLAssets', 'If you keep having issues please delete your Assets and Cache folders.');
73+
end;
7074
idx := Self.Queue.IndexOf(result.Data);
7175
if idx = -1 then
7276
raise GetDebugLn('WLAssets', 'Can''t find ' + result.Data + ' in the download queue.');
7377
Delete(Self.Queue, idx, 1);
78+
Self.Timeout.Extend(-18 * ONE_SECOND);
7479
end;
7580

7681
procedure TWLAssets.Update();
7782
var
7883
i: Integer;
79-
timer, timeout: TCountDown;
84+
timer: TCountDown;
8085
key, path: String;
8186
begin
8287
Self.JSON := Self.GetJSON('https://db.waspscripts.dev/storage/v1/object/public/data/');
@@ -91,7 +96,7 @@ begin
9196
FileDelete(WLEnv.AssetsDir + 'hashes.json');
9297
TJSONParser(Self.JSON).Save(WLEnv.AssetsDir + 'hashes.json');
9398

94-
timeout.Start(10);
99+
Self.Timeout.Start(1);
95100
for i := 0 to Self.JSON.Count-1 do
96101
begin
97102
key := Self.JSON.Key[i];
@@ -103,7 +108,7 @@ begin
103108
FileDelete(path);
104109
DirCreate(PathExtractDir(path));
105110
Self.Queue += path;
106-
timeout.Extend(20 * ONE_SECOND);
111+
Self.Timeout.Extend(20 * ONE_SECOND);
107112
Async.HTTPGetFile(Self.URL + key, path, @Self.DownloadFinished);
108113
end;
109114
end;
@@ -116,12 +121,13 @@ begin
116121
if timer.IsFinished then
117122
begin
118123
WriteLn GetDebugLn('WLAssets', 'Downloading files. ' + ToStr(Length(Self.Queue)) + ' files left, please wait.');
119-
WriteLn GetDebugLn('WLAssets', 'Files left: ' + ToStr(Self.Queue));
124+
WriteLn GetDebugLn('WLAssets', 'Files left: ' + ToStr(Self.Queue).Replace(WLEnv.AssetsDir, ''));
120125
timer.Restart();
121126
end;
122127

123-
if timeout.IsFinished then
128+
if Self.Timeout.IsFinished then
124129
begin
130+
if Self.Queue = [] then Exit;
125131
for i := 0 to High(Self.Queue) do
126132
FileDelete(Self.Queue[i]);
127133
raise GetDebugLn('WLAssets', 'Timed out downloading assets: ' + ToStr(Self.Queue));

0 commit comments

Comments
 (0)