Skip to content

Commit 1c72f91

Browse files
committed
fix: new assets management system
- now all file hashes are stored in a single file, this reduces http requests from 30+ to just one to check file hashes. - asset files are now mirrored to my database and that's the default source, if that fails we fallback to github, if that fails we use whatever we had before and hope things run
1 parent f2b0d0a commit 1c72f91

File tree

16 files changed

+108
-275
lines changed

16 files changed

+108
-275
lines changed

osrs/data/data.simba

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ begin
179179
path := Self.CacheDir + 'items' + PATH_SEP;
180180
filename := path + itemID + '.json';
181181
if not FileExists(filename) then
182-
if not ZipExtractEntry(WLAssets.ItemDefinitions.Path, itemID +'.json', path) then
182+
if not ZipExtractEntry(WLEnv.AssetsDir + 'jsons' + PATH_SEP + 'item-definitions.zip', itemID +'.json', path) then
183183
raise GetDebugLn('ItemData', 'Couldn''t find ' + itemID + '.json');
184184

185185
Result := new TJSONParser();
@@ -376,7 +376,7 @@ procedure TGearData.Setup();
376376
begin
377377
if Self.Data <> nil then Exit;
378378
Self.Data := new TJSONParser();
379-
TJSONParser(Self.Data).Load(WLAssets.Gear.Path);
379+
TJSONParser(Self.Data).Load(WLEnv.AssetsDir + 'jsons' + PATH_SEP + 'gear.json');
380380
end;
381381

382382
(*

osrs/finders/house_layout_finder.simba

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ procedure TRSHouseLayoutFinder.Setup();
3434
var
3535
path, tmp: String;
3636
begin
37-
Self.Version := WLAssets.HouseLayoutFinder.Hash;
37+
Self.Version := WLAssets.JSON.Item['finders\house_layout.zip'].AsString;
3838
Self.CacheDir := WLEnv.CacheDir + 'houselayoutfinder' + PATH_SEP;
3939

4040
//Delete old cache files if they exist
@@ -81,7 +81,7 @@ begin
8181
path := Self.CacheDir + name;
8282

8383
if not FileExists(path) then
84-
ZipExtractEntry(WLAssets.HouseLayoutFinder.Path, name, Self.CacheDir);
84+
ZipExtractEntry(WLEnv.AssetsDir + 'finders' + PATH_SEP + 'house_layout.zip', name, Self.CacheDir);
8585

8686
Self.RoomImages[room] += new TImage(path);
8787

osrs/finders/itemfinder.simba

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,12 @@ var
144144
path, tmp: String;
145145
begin
146146
if Self.IsSetup then Exit;
147-
Self.Version := WLAssets.ItemFinder[3].Hash;
148-
Self.Database.Setup('ItemFinder', ['id', 'item', 'hash'], WLAssets.ITEMFINDER_DATA, Self.Version);
147+
Self.Version := WLAssets.JSON.Item['finders\items\items.zip'].AsString;
148+
Self.Database.Setup(
149+
'ItemFinder', ['id', 'item', 'hash'],
150+
WLEnv.AssetsDir + 'finders' + PATH_SEP + 'items' + PATH_SEP + 'data' + PATH_SEP,
151+
Self.Version
152+
);
149153

150154
Self.CacheDir := WLEnv.CacheDir + 'itemfinder' + PATH_SEP;
151155

@@ -179,7 +183,10 @@ begin
179183

180184
Self.Unzipping := True;
181185
Self.Timeout.Start(60 * ONE_SECOND);
182-
Async.FileUnZip(WLAssets.ItemFinder[3].Path, Self.CacheDir, @Self._UnzipFinished);
186+
Async.FileUnZip(
187+
WLEnv.AssetsDir + 'finders' + PATH_SEP + 'items' + PATH_SEP + 'items.zip',
188+
Self.CacheDir, @Self._UnzipFinished
189+
);
183190
end;
184191

185192

osrs/finders/overheadfinder.simba

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ procedure TRSOverheadFinder.Setup();
9494
var
9595
path, tmp: String;
9696
begin
97-
Self.Version := WLAssets.OverheadFinder.Hash;
97+
Self.Version := WLAssets.JSON.Item['finders\overheads.zip'].AsString;
9898
Self.CacheDir := WLEnv.CacheDir + 'overheadfinder' + PATH_SEP;
9999

100100
//Delete old cache files if they exist
@@ -139,7 +139,7 @@ begin
139139
name := ToStr(overhead).ToLower().After('.') + '.png';
140140
path := Self.CacheDir + name;
141141

142-
if not (FileExists(path) or ZipExtractEntry(WLAssets.OverheadFinder.Path, name, Self.CacheDir)) then
142+
if not (FileExists(path) or ZipExtractEntry(WLEnv.AssetsDir + 'finders' + PATH_SEP + 'overheads.zip', name, Self.CacheDir)) then
143143
raise GetDebugLn('OverheadFinder', Format('Failed to unzip overhead image %s', [name]));
144144

145145
Result := Self.Images[overhead] := new TImage(path);

osrs/finders/prayerfinder.simba

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ procedure TRSPrayerFinder.Setup();
8181
var
8282
path, tmp: String;
8383
begin
84-
Self.Version := WLAssets.PrayerFinder.Hash;
84+
Self.Version := WLAssets.JSON.Item['finders\prayer.zip'].AsString;
8585
Self.CacheDir := WLEnv.CacheDir + 'prayerfinder' + PATH_SEP;
8686

8787
//Delete old cache files if they exist
@@ -128,7 +128,7 @@ begin
128128
path := Self.CacheDir + name;
129129

130130
if not FileExists(path) then
131-
ZipExtractEntry(WLAssets.PrayerFinder.Path, name, Self.CacheDir);
131+
ZipExtractEntry(WLEnv.AssetsDir + 'finders' + PATH_SEP + 'prayer.zip', name, Self.CacheDir);
132132

133133
Self.PrayerImages[prayer] := new TImage(path);
134134

osrs/finders/spellfinder.simba

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ procedure TRSSpellFinder.Setup();
3333
var
3434
path, tmp: String;
3535
begin
36-
Self.Version := WLAssets.SpellFinder.Hash;
36+
Self.Version := WLAssets.JSON.Item['finders\spells.zip'].AsString;
3737
Self.CacheDir := WLEnv.CacheDir + 'spellfinder' + PATH_SEP;
3838

3939
//Delete old cache files if they exist
@@ -70,7 +70,7 @@ begin
7070
path := Self.CacheDir + name;
7171

7272
if not FileExists(path) then
73-
ZipExtractEntry(WLAssets.SpellFinder.Path, name, Self.CacheDir);
73+
ZipExtractEntry(WLEnv.AssetsDir + 'finders' + PATH_SEP + 'spells.zip', name, Self.CacheDir);
7474

7575
Self.SpellImages[spell][i] := new TImage(path);
7676
end;

osrs/interfaces/handlers/consumables.simba

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -267,12 +267,12 @@ begin
267267
Self.CooldownTimers[consumableType].Start(0);
268268

269269
json := new TJSONParser();
270-
json.Load(WLAssets.Consumables.Path);
270+
json.Load(WLEnv.AssetsDir + 'jsons' + PATH_SEP + 'consumables.json');
271271

272272
Self.Consumables := Self.LoadFromJSON(json);
273273
if Length(Self.Consumables) = 0 then
274274
begin
275-
FileDelete(WLEnv.AssetsDir + 'consumables' + PATH_SEP + 'consumables.json');
275+
FileDelete(WLEnv.AssetsDir + 'jsons' + PATH_SEP + 'consumables.json');
276276
Logger.Exception('Failed to parse consumables configuration');
277277
end;
278278

osrs/interfaces/handlers/gear_form.simba

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ begin
5656
Self.Config.Setup('gearlayouts' + PATH_SEP + ToStr(ProfileIndex));
5757
SetLength(Self.Sets, Self.Config.Data.Count);
5858

59-
Self.BackgroundImg := new TImage(WLAssets.Images[1].Path);
59+
Self.BackgroundImg := new TImage(WLEnv.AssetsDir + 'images' + PATH_SEP + 'equipment.png');
6060

6161
try
6262
for i := 0 to Self.Config.Data.Count-1 do

osrs/interfaces/handlers/inventory_form.simba

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ begin
5353
Self.Config.Setup('inventorylayouts' + PATH_SEP + ToStr(ProfileIndex));
5454
SetLength(Self.Layouts, Self.Config.Data.Count);
5555

56-
Self.BackgroundImg := new TImage(WLAssets.Images[0].Path);
56+
Self.BackgroundImg := new TImage(WLEnv.AssetsDir + 'images' + PATH_SEP + 'gametab.png');
5757

5858
try
5959
for i := 0 to Self.Config.Data.Count-1 do

osrs/interfaces/minimap.simba

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ begin
8080
case RSClient.Mode of
8181
ERSMode.RESIZABLE, ERSMode.MODERN_COMPACT, ERSMode.MODERN_WIDE:
8282
begin
83-
img := new TImage(WLAssets.Images[3].Path);
83+
img := new TImage(WLEnv.AssetsDir + 'images' + PATH_SEP + 'mm_resizable_mask.png');
8484
Self.Mask := img.FindColor($0, 0).Invert().Grow(3).ExtractBox([0, 0, img.Width-1, img.Height-1]);
8585

8686
with RSClient.Bounds do
@@ -96,7 +96,7 @@ begin
9696

9797
ERSMode.FIXED:
9898
begin
99-
img := new TImage(WLAssets.Images[2].Path);
99+
img := new TImage(WLEnv.AssetsDir + 'images' + PATH_SEP + 'mm_fixed_mask.png');
100100
Self.Mask := img.FindColor($0, 0).Invert().Grow(3).ExtractBox([0, 0, img.Width-1, img.Height-1]);
101101

102102
with RSClient.Bounds do

0 commit comments

Comments
 (0)