SRL Archive - Bugs

IsEquippedIDEx Broken (Easy fix)


doom0791

2011-01-22 18:51:43

{*******************************************************************************
function IsEquippedIDEx(IDs: TIntegerArray): boolean;
By: Drags111
Description: Returns true if there is an item equipped with one of the IDs.
*******************************************************************************}
function IsEquippedIDEx(IDs: TIntegerArray): boolean;
var
Equipment: TEquipmentSet;
i, ii: integer;
begin
Result := False;
Equipment := GetEquipment;
for i := High(IDs) downto 0 do
for ii := 10 downto 0 do
if (IDs[i] = Equipment.Items[i].ID) then
begin
Result := True;
Exit;
end;
end;

Fix:

{*******************************************************************************
function IsEquippedIDEx(IDs: TIntegerArray): boolean;
By: Drags111
Description: Returns true if there is an item equipped with one of the IDs.
*******************************************************************************}
function IsEquippedIDEx(IDs: TIntegerArray): boolean;
var
Equipment: TEquipmentSet;
i, ii: integer;
begin
Result := False;
Equipment := GetEquipment;
for i := High(IDs) downto 0 do
for ii := 10 downto 0 do
if (IDs[i] = Equipment.Items[ii].ID) then
begin
Result := True;
Exit;
end;
end;

Sex

2011-01-22 22:25:14

Ah, I see, wrong loop variable. It would be nice to tell us the problem though.

Train

2011-01-23 00:55:40

From: Sex
Ah, I see, wrong loop variable. It would be nice to tell us the problem though.


The problem is rather obvious, no?

Sex

2011-01-23 01:03:58

I know, but it's a good practice…sometimes devs don't want to look through the code they can just see what the problem was, how they fixed it, and apply the fix.

doom0791

2011-01-23 12:26:25

From: Sex
I know, but it's a good practice…sometimes devs don't want to look through the code they can just see what the problem was, how they fixed it, and apply the fix.


:duh: lol. I'll keep that in mind for next time.