SRL Archive - SRL Archives

GetMiniMapDotsIn


Naum

2009-08-12 16:36:38

GetMiniMapDotsIn would return an excess violation if no dots were found. Because it would be setting a length of '-1'.

Added a try and except block:

function GetMiniMapDotsIn(WhatDot: string; x1, y1, x2, y2: Integer): TPointArray;
var
Color: Integer;
begin
WhatDot := LowerCase(WhatDot);
case WhatDot Of
'npc', 'yellow': Color := 60909;
'cape', 'blue': Color := 12742980;
'item', 'red': Color := 789758;
'player', 'white': Color := 16711422;
'friend', 'green': Color := 61440;
else
srl_Warn('GetMiniMapDotsIn', '"' + WhatDot + '" is not a valid dot type', warn_AllVersions);
end;
FindColorsSpiralTolerance(MMCX, MMCY, Result, Color, x1, y1, x2, y2, 0);
RAaSTPA(Result, 4);
if (WhatDot = 'player') or (WhatDot = 'white') then
try
InvertTPA(Result);
SetLength(Result, Length(Result) - 1);
InvertTPA(Result);
except srl_Warn('GetMiniMapDotsIn', 'No Dots of '+WhatDot+' Found', warn_AllVersion);
end;
end;

cycrosism

2009-08-13 14:02:55

Look's pretty good wouldn't it work if it just sets the length to 0 instead of -1

ZephyrsFury

2009-08-13 14:09:13

if (Length(Result) < 1) then Exit; Added to SRL. Thanks. :)

Naum

2009-08-13 15:02:57

From: ZephyrsFury
if (Length(Result) < 1) then Exit; Added to SRL. Thanks. :)


Thanks <3 :D