Smidqe
2013-05-03 13:05:28
E: FIXED
Usually I can solve these problems myself, but this error just doesn't make any sense.
I have written my own walking method and functions, and they work just fine, but when it comes to the end of function where it checks the location to give the result, it gives a type mismatch, even though it should be a boolean, what else it could be?
What makes it more confusing is that the error only comes up when reverse = true. So any thoughts?
I'll post more information if necessary.
(Error location is the on the line 144 in the function below)
function walkTo(where: integer; reverse: boolean): boolean;
var
i : integer;
b : Tbox;
p : TPoint;
label
walking;
begin
result := false;
if (not loggedIn) then
exit;
clickNorth(SRL_ANGLE_HIGH);
walkPath := loadWalkingInfo(where, reverse);
writeln('[walkTo]: Path created: ' + walkPath.str);
if walkPath.constant = PATH_BANK_TO_RANGE then //only case when not walking too far (for now)
begin
if (not reverse) then
begin
b := findBuildingMM(building);
if b.X1 <> -1 then
begin
{$IFDEF SMART_GRAPHICS}
if paintSmart then
SMART_DrawBox(b);
{$ENDIF}
p := Point((b.x1 + b.x2) / 2, (b.y1 + b.y2) / 2);
mouse(p.x, p.y, randomRange(-2, 2), randomRange(-3, 2), mouse_left);
end else
begin
writeDebug('[walkTo]: Failure(findBuildingMM): ' + walkPath.str);
DDTMRelocate(DDTM_Bank, LOCATION_RANGE);
end;
end else
begin
p := findBankersMM;
p.x := p.x + randomRange(-5, 5);
p.y := p.y + randomRange(8, 15);
mouse(p.x, p.y, 2, 2, mouse_left);
end;
waitUntilMoving;
if flagPresent then
begin
while isMoving do
wait(randomRange(350, 500));
end;
if reverse then
result := (getLocation = LOCATION_BANK)
else
result := (getLocation = where);
exit;
end;
for i := 0 to high(walkPath.colors) do
begin
with walkPath.colors[i] do
begin
if radialWalkDistTolerance(dirs[0], dirs[1], col, dist - 1, dist + 1, tol) then
waitUntilMoving
else
begin
blindWalk(dirs[0] + 0.0, dirs[1] + 0.0, dist - 2, dist);
waitUntilMoving;
end;
walking:
while (isMoving and flagPresent()) do //is not an infinite loop, either one will become false at somepoint
wait(randomRange(50, 200) + random(32));
//if there's a loading moment during walking
if flagPresent() and (not isMoving) then
begin
if outOfChunk() then
begin
writeDebug('[walkTo]: Another chunk is loading, waiting until it passes');
waitUntilMoving();
end else
writeDebug('[walkTo]: Strange, we stopped yet the flag is still up..');
if isMoving() then
goto walking;
end;
//checks if we can skip steps.
if reverse then
begin
p := findBankersMM;
if (p.x <> -1) and (p.x <> 0) then
begin
writeDebug('[walkTo]: Bankers found! Skipping other walking steps.');
mouseBox(p.x - 3, p.y + 5, p.x + 3, p.y + 10, mouse_left);
waitUntilMoving;
while isMoving do
wait(randomRange(400, 600));
break;
end;
if symbolVisible(SYMBOL_BANK, p) then
begin
writeDebug('[walkTo]: Bank symbol found! Skipping other walking steps');
mouse(p.x, p.y, 3, 3, mouse_left);
waitUntilMoving;
while isMoving do
wait(randomRange(400, 600));
break;
end;
end else
begin
{
if length(symbols) >= 1 then
if findBuildingMM() then
begin
end;
}
end;
end;
end;
while isMoving do
wait(randomRange(300, 500) + randomRange(100, 150));
if (not reverse) then
result := (getLocation() = where)
else
result := (getLocation() = LOCATION_BANK);
writeln('[walkTo]: Result: ' + toStr(result)); //Error: Exception: Type Mismatch at line 860
(*~ Sometimes the flagPresent fails, don't know why. Yet it messes up the findBankersMM ~*)
if (not result) and reverse then
begin
writeln('[walkTo]: Failed to get a result, trying resetting our location.');
mouse(MMCX, MMCY, 2, 2, mouse_left);
wait(100 + randomRange(25, 80) + random(15));
result := (getLocation() = LOCATION_BANK);
end;
end;