View Full Version : Access Violation error
markuska815
05-30-2008, 08:39 PM
Hey everyone when i try to do this:
function WalkToMaples : boolean;
begin
Tree[3].DTMs[0] := AssembleMaple;
if (DTMRotated(Tree[3].DTMs[0], x, y, MMX1, MMY1, MMX2, MMY2)) then
begin
WriteLn('Found Maples!');
Mouse(x, y - random(10), 2, 2, true);
Wait(3000+random(1000));
Flag;
Result := true;
end else //Theres more down here. But this is all thats relevant to the error.
I get an access violation:
[Runtime Error] : Exception: Access violation at address 004B998D in module 'scar.exe'. Read of address 0B640054 in line 81 in script C:\Program Files\SCAR 3.15\includes\SRL/SRL/Core/Color.scar
Which is:
if (FindDTMRotated(DTM, x, y, x1, y1, x2, y2, 0 - t, 0 + t, s, AngleFound)) then in color.scar
Does anyone know why this would happen? It only happens about once every 20 times and i think it has to do w/ the mm rotation. And as you see I assemble the DTM before I look for it with the AssembleMaple function which returns the DTM.
Thanks
PS if you need more of the script let me know
mixster
05-30-2008, 08:51 PM
It may be that assembling the DTM fails to assemble properly (can happen if it is too large or used intensively, though still uncommon) so it may be worth throwing in a check to see if it is equal to 0 as that would indicate it failed I think. Otherwise, you can use try except end; to make it always run and just send a Writeln and set the current player to false when it does fail.
R0b0t1
05-30-2008, 11:50 PM
try
{.. Place the code to assemble the DTM in here..}
except
WriteLn('Error initializing DTM: Namehere');
try
FreeDTM(DTMName); //Just incase
except
end;
end;
markuska815
05-31-2008, 12:56 AM
K Ill try that... but why do you think it would fail?
Heres the AssembleMaple function:
function AssembleMaple: Integer;
var
dtmMainPoint: TDTMPointDef;
dtmSubPoints: Array [0..6] of TDTMPointDef;
TempTDTM: TDTM;
begin
RoadColor := MyFindRoadColor;
dtmMainPoint.x := 129;
dtmMainPoint.y := 60;
dtmMainPoint.AreaSize := 0;
dtmMainPoint.AreaShape := 0;
dtmMainPoint.Color := 255;
dtmMainPoint.Tolerance := 255;
dtmSubPoints[0].x := 129;
dtmSubPoints[0].y := 60;
dtmSubPoints[0].AreaSize := 0;
dtmSubPoints[0].AreaShape := 0;
dtmSubPoints[0].Color := RoadColor;
dtmSubPoints[0].Tolerance := 255;
dtmSubPoints[1].x := 161;
dtmSubPoints[1].y := 84;
dtmSubPoints[1].AreaSize := 2;
dtmSubPoints[1].AreaShape := 0;
dtmSubPoints[1].Color := RoadColor;
dtmSubPoints[1].Tolerance := 0;
dtmSubPoints[2].x := 149;
dtmSubPoints[2].y := 82;
dtmSubPoints[2].AreaSize := 2;
dtmSubPoints[2].AreaShape := 0;
dtmSubPoints[2].Color := RoadColor;
dtmSubPoints[2].Tolerance := 0;
dtmSubPoints[3].x := 151;
dtmSubPoints[3].y := 105;
dtmSubPoints[3].AreaSize := 2;
dtmSubPoints[3].AreaShape := 2;
dtmSubPoints[3].Color := RoadColor;
dtmSubPoints[3].Tolerance := 0;
dtmSubPoints[4].x := 146;
dtmSubPoints[4].y := 124;
dtmSubPoints[4].AreaSize := 2;
dtmSubPoints[4].AreaShape := 0;
dtmSubPoints[4].Color := RoadColor;
dtmSubPoints[4].Tolerance := 0;
dtmSubPoints[5].x := 128;
dtmSubPoints[5].y := 117;
dtmSubPoints[5].AreaSize := 2;
dtmSubPoints[5].AreaShape := 0;
dtmSubPoints[5].Color := RoadColor;
dtmSubPoints[5].Tolerance := 0;
dtmSubPoints[6].x := 89;
dtmSubPoints[6].y := 116;
dtmSubPoints[6].AreaSize := 2;
dtmSubPoints[6].AreaShape := 0;
dtmSubPoints[6].Color := RoadColor;
dtmSubPoints[6].Tolerance := 0;
TempTDTM.MainPoint := dtmMainPoint;
TempTDTM.SubPoints := dtmSubPoints;
Result := AddDTM(TempTDTM);
end;
R0b0t1
05-31-2008, 02:26 AM
Its either because your computer has run out of memory, but its most likely because theres a problem with the DTM, such as it can't be created.
Theres really not much you can do, how many DTM's do you have running at one time?
Cazax
05-31-2008, 02:31 AM
are you sure you load the DTM before using it? are you sure you load the DTM again if you are freeing it?
R0b0t1
05-31-2008, 02:41 AM
If he hadn't of loaded it, one of the addresses in the error would have been all 0's.
Markus
05-31-2008, 09:03 AM
If he hadn't of loaded it, one of the addresses in the error would have been all 0's.
Scar doesn't agree with you:
program New;
var x, y : integer;
begin
FindDTM(123123, x, y, 0, 0, 10, 10);
end.
[Runtime Error] : Exception: Access violation at address 006D72AA in module 'scar.exe'. Read of address 000783CC in line 4 in script
R0b0t1
05-31-2008, 07:10 PM
You didn't use a variable, thats what my point revolves around. An uninitialized integer should have the address of 0x00000000 or something like that.
Besides, you can't 'load' the value 123123. Its a constant, as soon as the script is compiled nothing can change that value where it is.
markuska815
06-02-2008, 05:42 AM
Okay i found the actual problem:
function MyFindRoadColor : Integer;
var
BaseC, Tol, BigArray, i, AmountLength, ColorsLength, Color : Integer;
ColorTPA : TPointArray;
Colors, MyAmount : TIntegerArray;
begin
BaseC := 5987170; //7171445;
Tol := 50;
FindColorsPie(ColorTPA, BaseC, Tol, 85, 95, 35, MMX2-MMCX, MMX1, MMCY, MMX2, MMY2, MMCX, MMCY);
Colors := GetColors(ColorTPA);
ClearSameIntegers(Colors);
SetArrayLength(MyAmount, GetArrayLength(Colors));
ColorsLength := GetArrayLength(Colors);
WriteLn(InttoStr(ColorsLength));
for i := 0 to (ColorsLength - 1) do
MyAmount[i] := CountColor(Colors[i], MMCX, MMCY, MMX2, MMY2);
BigArray := 0;
AmountLength := High(MyAmount);
for i := 1 to AmountLength do
begin
if (MyAmount[i] > MyAmount[BigArray]) then
BigArray := i;
end;
WriteLn('I is : ' + InttoStr(BigArray));
Color := Colors[BigArray];
WriteLn('The color is ' + InttoStr(Color));
Result := Color;
end;
This function, which is called by the AssembleMaple function, produces this exception:
[Runtime Error] : Exception: Can't allocate the DIB handle in line 670 in script C:\Program Files\SCAR 3.15\Scripts\SVC.scar
And it puts the mouse at this line:
Colors := GetColors(ColorTPA);
which idk if it is relevant.
But now does anyone know what the problem would be.
R0b0t1
06-02-2008, 05:04 PM
No, I don't think anyone would know how to fix it. But what it is saying, though, is that it can't create a bitmap of the screen. Probably because your out of RAM or something similar.
ConneX
06-02-2008, 05:05 PM
Lol i got sometimes same error. I close scar and its happening ;s
Powered by vBulletin® Version 4.2.1 Copyright © 2024 vBulletin Solutions, Inc. All rights reserved.