SRL Archive - Reflection Help

GetMenuText Out Of Range


smurg

2011-02-09 04:40:01


{*******************************************************************************
function GetMenuText: TStringArray;
By: BenLand100
Description: Dumps the data from the MenuNodeList into a TStringArray
*******************************************************************************}
function GetMenuText: TStringArray;
var
count, nodeList, head, next, last, javaString: Integer;
item: string;
begin
nodeList:= SmartGetFieldObject(0, hook_static_MenuNodeList);
head:= SmartGetFieldObject(nodeList, hook_nodelist_Head);
//for some reason, the head has null strings, so skip it
next:= SmartGetFieldObject(head, hook_node_Next);
count:= GetMenuCount;
SetLength(result,count);
repeat
javaString:= SmartGetFieldObject(next, hook_menu_Action);
if (javaString = 0) then
begin
//writeln('Stopping, the string is null');
SmartFreeObject(javaString);
break;
end;
item:= GetJavaString(javaString,256);
SmartFreeObject(javaString);
javaString:= SmartGetFieldObject(next, hook_menu_Option);
item:= item + ' ' + GetJavaString(javaString,256);
SmartFreeObject(javaString);
result[count-1]:= TrimHTML(item); // Out of Range Here
last:= next;
next:= SmartGetFieldObject(last, hook_node_Next);
SmartFreeObject(last);
count:= count - 1;
until (count = 0);
SmartFreeObject(next);
SmartFreeObject(head);
SmartFreeObject(nodeList);
end;

smurg

2011-02-09 04:57:15

I commented where it was. Editing posts in firefox messed up all brackets.

i luffs yeww

2011-02-09 05:30:18

I think it's because of the whole double menu thing.

Emaziz

2011-02-09 10:03:00

Quite annoying bug, messes up my thiever every now and then

Floor66

2011-02-25 10:51:10

Sorry for the bump, but I got this twice today now and it's starting to get annoying :( Any dev pls look into this ;)

Train

2011-02-25 15:23:12

It's simply caused by a delay and the menu changing.
It's a simple fix if you cared to look at it and write 4 lines.