SRL Archive - RS3 Help

GetPixelShiftAverage no longer works?


Brotein

2014-02-24 12:31:54

So some time last week I updated the SRL on my computer at work and any code that used GetPixelShiftAverage() broke with an access violation error. It was working prior to an update sometime next week, now it will no longer work. Nothing changed on my end, didn't touch the code just updated SRL through simba. For this reason I haven't updated my SRL back at home, and I can confirm the code is working there.

So here's the procedure that is called when it breaks.

procedure setAnimationThreshold;
var
PixelShiftResult, PixelShiftTemp, i : Integer;
begin
printStatus('SetAnimationThreshold: Starting...', 1);
PixelShiftBox := IntToBox(273, 177, 301, 204);
AnimTime := 5800;
AnimMaxIter := 10;
AnimMinTime := 200;
AnimTemp := round(AnimTime/AnimMaxIter);
AnimMaxTime := AnimTemp - AnimMinTime;
for i := 1 to AnimMaxIter do
begin
PixelShiftTemp := GetPixelShiftAverage(PixelShiftBox, AnimMinTime, AnimMaxTime);
printStatus('PixelShift: ' + IntToStr(PixelShiftTemp), 2);
PixelShiftResult := PixelShiftResult + PixelShiftTemp;
end;
AnimThreshold := round((PixelShiftResult / AnimMaxIter) * 1.25);
printStatus('Animation Threshold: ' + intToStr(AnimThreshold), 2);
printStatus('SetAnimationThreshold: Finished!', 3);
end;

When the script starts the log will show this….

......
[00:00:01]: ---- Client is ready.
[00:00:01]: ---- Setup SRL in 31ms.
[00:00:01]: -- setupSRL(): True
[00:00:01]: -- SetAnimationThreshold: Starting...

So it enters my procedure and breaks when GetPixelShiftAverage() is used. Here's the error in Simba,
Exception in Script: Runtime error: "Access violation" at line 222, column 28 in file "C:\Simba\Includes\SRL-6\lib\utilities\pixelshift.simba"
The following bitmaps were not freed: [Minimap Mask, SMART Debug Image]
File[C:\Simba\Includes\SRL-6/logs/SRL log (24-02-14 at 12.21.26 PM).txt] has not been freed in the script, freeing it now.

I can't confirm what day the update was but it was sometime last week anytime between Feb 18th-21st. Is this a bug that was committed to SRL, or something wrong on my end? Like I said that code executes fine on my other computer that didn't update to whatever the newest version of SRL is. Or is there a way I can just revert to and older version of SRL?

Coh3n

2014-02-24 13:08:07

There hasn't been an update to pixelshift.simba in over 4 months, so nothing has changed in SRL. That being said, I don't know why you get this error.

For those wondering, line 222 is an averageTIA call. Going through his code and SRL's, the shifts array (in SRL) should never have a length of 0. This is a mysterious error. :unsure:

E: How come you have a loop? You're basically getting the average of 10 average pixel shifts. With the way you have your variables setup, you may as well just use getPixelShift rather than getPixelShoftAverage. Your AnimMaxTime ends up being 380 and your AnimMinTime is 200. GetPixelShiftAverage gets the average pixel shift of AnimMaxTime / AnimMinTime times. So in your case it will return the average of one pixel shift in your given box.

You basically wrote your own getPixelShiftAverage function when you didn't need to. You can just do:

procedure setAnimationThreshold;
begin
printStatus('SetAnimationThreshold: Starting...', 1);
AnimThreshold := GetPixelShiftAverage(IntToBox(273, 177, 301, 204), 200, 5800);
printStatus('Animation Threshold: ' + intToStr(AnimThreshold), 2);
printStatus('SetAnimationThreshold: Finished!', 3);
end;
That will set AnimThreshold to the average pixel shift of (5800 / 200) number of shifts in the box PixelShiftBox. This probably won't fix your error, but I thought I'd point it out (hopefully it's clear).

rj

2014-02-24 18:19:00

Replace the function at line 204 (includes/srl-6/utilities/pixelshift) with

function getPixelShiftAverage(b: TBoxArray; waitPerLoop, maxTime: integer): TIntegerArray;
var
t, l, i: integer;
shifts: array of TIntegerArray;
begin
l := length(b);
setLength(result, l);

t := (getSystemTime() + maxTime);

while (getSystemTime() < t) do
for i := 0 to (l - 1) do
begin
setLength(shifts, length(shifts) + 1);
shifts[high(shifts)] := getPixelShift(b, waitPerLoop);
end;

for i := 0 to (l - 1) do
begin
try
result[i] := averageTIA(shifts[i]);
except
writeln('Length of result = ', length(result));
writeln('Length of shifts = ', length(shifts));
writeln('l - 1 = ', (l - 1));
end;
end;
end;

And print the results, in my experience with access violations in lape (had literately hundreds..) 80% of the time it's a range check issue

Brotein

2014-03-02 03:31:07

Ok I'll give this a shot on monday when I'm back at my work computer.

Brotein

2014-03-03 15:07:22

Went to try this, but my script started to act weird after updating to SRL 770(going off memory here). Now all my scripts and any other the mouse snaps around, and just zooms through the script without actually doing anything. The debug messages show everything starting and stopping but the mouse is literally snapping. I tried deleting my whole simba install, re-installing, and setting it up again. Same thing happened, so now I can't run anything. I don't understand what is going on here. Tried doing fresh install 3 times today and nothing is fixing this. I couldn't imagine what is causing these weird errors but it's beyond frustrating. Java is up to date, running on Windows 8, everything up to date, everything installed and setup right. Maybe it's a warning to take botting easier ;)