SRL Archive - Bugs

findDTMs returns multiple erroneous points


Bixby Sayz

2014-01-29 20:59:08

findDTMs returns multiple duplicate points as well as a number of duplicate points that are just slightly off.

If you want to see this for yourself place Infernal Ashes in your backpack (do not place in quick inventory slots) and run this script. I've created a dtm with an overkill of points just to prove there should only be one (and only one match).

program new;

{$DEFINE SMART}
{$I SRL-6\SRL.simba}

var
AshesMdtm: TMDTM; // Ashes dtm stored in a tmdtm record.
AshesDtm: Integer; // Ashes dtm.
DtmPositions: TPointArray; // All positions of dtm found.
HiPositions: Integer; // Size of positions array.
PositionIdx: Integer; // Loop counter - current dtm position.
Width, Height: Integer; // Client width and height.
ClientArea: TBox; // Client area.

begin
clearDebug();
setupSRL();

// Create infernal ashes dtm.
AshesMdtm.init();
AshesMdtm.addPoint(CreateDtmPoint(18, 0, 526610, 0, 1, False));
AshesMdtm.addPoint(CreateDtmPoint(0, 4, 131072, 1, 1, False));
AshesMdtm.addPoint(CreateDtmPoint(7, 9, 131072, 1, 1, False));
AshesMdtm.addPoint(CreateDtmPoint(16, 4, 131072, 1, 1, False));
AshesMdtm.addPoint(CreateDtmPoint(6, 0, 131072, 1, 1, False));
AshesMdtm.addPoint(CreateDtmPoint(21, 0, 131072, 1, 1, False));
AshesMdtm.addPoint(CreateDtmPoint(15, 0, 131072, 1, 1, False));
AshesDtm := AddDtm(AshesMdtm);
setDtmName(AshesDtm, 'Infernal Ashes');

// Find all occurances of dtm on client.
getClientDimensions(Width, Height);
ClientArea := IntToBox(0, 0, (Width - 1), (Height - 1));
findDtms(AshesDtm, DtmPositions, ClientArea);
HiPositions := High(DtmPositions);
WriteLn(IntToStr(HiPositions + 1) + ' Dtms found.');
if (HiPositions = (-1)) then
Exit;

// Print out dtm positions.
for PositionIdx := 0 to HiPositions do
with DtmPositions[PositionIdx] do
WriteLn(Format('%d) (%d,%d).', [PositionIdx, X, Y]));

// Free dtm.
freeDtm(AshesDtm);
end. // main.

There *should* be one match. Running the script with Infernal Ashes in the 3rd backpack slot I get:
11 Dtms found.
0) (694,340).
1) (695,340).
2) (696,340).
3) (697,340).
4) (694,341).
5) (695,341).
6) (696,341).
7) (694,342).
8) (695,342).
9) (696,342).
10) (697,342).

King

2014-01-29 21:21:43

Try adding a tolerance of 10 to the main point, and a tolerance of 0 to the black outline?

Bixby Sayz

2014-01-29 21:27:05

Sigh. Just Sigh.

If you could see the dtm in the dtm editor you would see there is no possible way there can be more than one match for that dtm.

Side note: The reason for the tolerance on the black outline is due to the game using a different color black outline depending on whether it is: in your backpack, in the bank, or on one of the bank tabs (up top). (131072 and 65536 to be exact: 131072 with a tolerance of 1 catches both)

King

2014-01-29 21:29:47

From: Bixby Sayz
Sigh. Just Sigh.

If you could see the dtm in the dtm editor you would see there is no possible way there can be more than one match for that dtm.


Can you explain to me why you have zero tolerance for the first and a tolerance of 1 around the black outline? Middle color changes, outline does not.

If you need to show a picture, download gyazo and share it.

Bixby Sayz

2014-01-29 21:49:34

From: King
Can you explain to me why you have zero tolerance for the first and a tolerance of 1 around the black outline?
Because when I was creating my dtms I found that the color of the black outline changed depending on where in the game the object appeared. Which threw me for a loop why my dtm was failing until I figured that out. And on this particular item after 30 complete reloads of the client the middle color has not changed. The color changes on every other item I've ever encountered but not Infernal Ashes for some reason.

Give me a minute and I'll put up a picture of the dtm in the dtm editor so you can see there is no way there is going to be a duplicate. Tricky since the coordinates in the dtm get modified when you save the dtm and reload it. I'll have to recreate the dtm I guess.

On second thought nevermind. I'll just add code to work around this "feature". I can spend a couple hours debating this or 5 minutes adding code to my script to nullify this effect. 5 minutes wins.

Olly

2014-01-29 22:10:44

Does it do the same loading from string form?

e: Go in paint and make like a triangle, and see if you get the same results.

Bixby Sayz

2014-01-29 22:19:53

Here, just for you:

See the attached screenie of the dtm in the dtm editor (blown up so you can see the overkill of points). There is no way this should return multiple matches. I suppose infernal ashes was not such a great example for this for the simple reason it's so dark. But there is an ash there under the dtm if you look closely.

[ATTACH=CONFIG]22827[/ATTACH]

Again with infernal ashes in 3rd slot (used generated dtmstring this time). This time used 0 tolerance for everything.
10 Dtms found.
0) (694,340).
1) (695,340).
2) (696,340).
3) (693,341).
4) (694,341).
5) (695,341).
6) (696,341).
7) (694,342).
8) (695,342).
9) (696,342).


Edit Aaaaand I found the reason. I was using an area size of 1 for my points (the default size generated by the dtm editor). Have to use an area size of 0 for the dtm finding to work as expected. The dtm editor (by default) generates a dtm that returns multiple erroneous matches. How nice.

Not a bug then I suppose. Just totally not intuitive.

Gu3st...

2014-01-30 08:51:44

Be sure to set DTM Area Size of the points to 0 or whatever the lowest value for that variable is.

King

2014-01-30 14:29:13

Ahh, yeah that does happen. I wasn't saying you were wrong, I was just curious why as it is usually not zero. So you got it working? Also would a bmp be easier?

Bixby Sayz

2014-01-30 20:52:49

From: Zyt3x
Be sure to set DTM Area Size of the points to 0 or whatever the lowest value for that variable is.
Yeah I was having a brain dead moment. Should have caught the area size right away.

From: King
Ahh, yeah that does happen. I wasn't saying you were wrong, I was just curious why as it is usually not zero. So you got it working? Also would a bmp be easier?
The black border color changes if the item is in the quick inventory slot. The slight tolerance handles both situations.

Which leads to my other question on whether it is possible to modify a dtm after it has been created: http://villavu.com/forum/showthread.php?t=107813