From 732718a8bad0948835cfcfc8eef6a76f4b1b55c9 Mon Sep 17 00:00:00 2001 From: XxXAdvisaryXxX Date: Sat, 14 Feb 2026 14:56:01 -0800 Subject: [PATCH] Improve error handling in GetArray functions Added some error handling. If you search for an item that isnt in the database; we get memory access issues when trying to access the returned jsonitem. This way protects the lib from getting access errors. The user will have to do their own error handling on their end if they ever decide to use it. This only happens if you have a typo or the item isnt in the database. Perhaps you have a better way to handle it? --- osrs/data/data.simba | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/osrs/data/data.simba b/osrs/data/data.simba index ef45870..b23ce3a 100644 --- a/osrs/data/data.simba +++ b/osrs/data/data.simba @@ -488,17 +488,31 @@ end; function TWeaponData.GetArray(index: Integer): TJSONItem; +var + blankJSON : TJSONItem; begin - Self.Setup(); - Result := Self.Data.Item[index]; + try + Self.Setup(); + Result := Self.Data.Item[index]; + finally + WriteLn GetDebugLn('Object Not Found In DataBase' , False); + Result := blankJSON; + end; end; function TWeaponData.GetArray(key: String): TJSONItem; overload; +var + blankJSON : TJSONItem; begin - Self.Setup(); - if key = 'secondary_ammo' then key := 'ammo'; - Result := Self.Data.Item[key]; -end; + try + Self.Setup(); + if key = 'secondary_ammo' then key := 'ammo'; + Result := Self.Data.Item[key]; + finally + WriteLn GetDebugLn('Object Not Found In DataBase' , False); + Result := blankJSON; + end; +end; function TWeaponData.GetItems(key: Integer): TRSItemArray;