SRL Archive - Bugs

Access Violation?


Runescapian321

2010-06-13 22:50:21

I think the problem is caused by something I'm doing wrong, but Simba doesn't seem to be pointing the flaw out too well (it crashes).

So I have this:

  begin
Debug('Found some monsters...');
MonsterFS := 0;
if IsMonsterOnMSMM(Monster, MS) then
begin
Debug('Got some fightable monsters');
[etc...]
end;
Debug('Done fighting');
end;

(Debug pretty much just displays the text) It displays 'Found some monsters…' and never gets to neither 'Got some fightable monsters' nor 'Done fighting'. Therefore we know the problem is in IsMonsterOnMSMM:

function IsMonsterOnMSMM(var Monsters: TNPCArray;var MS: boolean): boolean;
var
AllMonsters: TNPCArray;
i, THigh, k: integer;
begin
if not LoggedIn then LoginPlayer;
Debug('Initated IsMonsterOnMSMM');
k := 0;
MS := True;
AllMonsters := T_GetNPCByEx(MonsterName);
THigh := High(AllMonsters);
AllMonsters := SortNPCs(AllMonsters);
SetLength(Monsters, Length(AllMonsters));
Debug('MS Loop Starting');
for i:=0 to THigh do
begin
if TileOnMS(AllMonsters[i].Tile, 10) then
begin
if not AllMonsters[i].Fighting then
begin
Monsters[k] := AllMonsters[i];
Inc(k);
end;
end else
break;
end;
Debug('MS Loop Ends');
if k <> 0 then
begin
Debug('Monsters on MS found!');
MS := true;
result := true;
Debug('Setting Length');
SetLength(Monsters, k);
Debug('Exiting function');
exit;
end;
Debug('MM Loop Starting');
for i:=i to THigh do
begin
if TileOnMM(AllMonsters[i].Tile) then
begin
if not AllMonsters[i].Fighting then
begin
Monsters[k] := AllMonsters[i];
Inc(k);
end;
end else
break;
end;
Debug('MM Loop Ends'); //Displays this
if k <> 0 then
begin
Debug('k <> 0 so monster(s) found!'); //Displays this
MS := false;
result := true;
Debug('Monsters Length about to be set'); //Displays this
SetLength(Monsters, k);
end;
Debug('End IsMonsteronMSMM'); //Displays this
end;

Thus the problem occurs as it leaves that function. Immediately after those Debugs, it writes "Exception in Script: Access Violation". It also displays this dialog box:



Whereupon it immediately closes Simba without waiting for a response.

Any ideas?

EDIT: I ran it a couple times more and once it told me the access violation was at line 93, which is

procedure Debug(text: string);
begin
if DoDebug then
writeln(TimeRunning+' - '+text); //Line 93
end;

:confused:

i luffs yeww

2010-06-13 23:34:07

I know I was getting some weird access violations when I was trying to DumpNPCs (or whatever the function is called) and a few other things (all reflection related, I think).

I haven't had any problems with strictly color scripts and access violations, though, so it leads me to think that, for some reason, reflection is the problem. I've no idea how or why that would happen, though.

Wizzup?

2010-06-14 11:46:04

My first guess would be that it is Reflection (shared object / dynamic linked library) related, since you aren't actually calling _any_ Simba functions there. ;)