SRL Archive - Reflection Help

GetPlayers giving Exception: Acces violation.


weequ

2010-08-09 13:38:53

This might be becouse hooks are not up to date but I think it should then just result an array with 0 length and not give errors.

I don't understand too much about try..finally things so here is the code from characters.simba

function GetPlayers: array of TPlayer;
var
i, IndexPos, Count, Player, theName, L: integer;
begin
Count := SmartGetFieldInt(0, hook_static_PlayerCount);
SetArrayLength(result, Count);
if Count < 1 then Exit;
for i := 0 to Count-1 do
try
IndexPos := SmartGetFieldArrayInt(0, hook_static_PlayerIndexArray, i);
Player := SmartGetFieldArrayObject(0, hook_static_GetPlayers, IndexPos);
theName := SmartGetFieldObject(Player, hook_player_GetName);
Result[L].Index := IndexPos;
Result[L].Name := GetJavaString(theName, 255);
Result[L].Tile.X := (SmartGetFieldInt(0, hook_static_BaseX) + (SmartGetFieldInt(Player, hook_animable_PixelX) / 512));
Result[L].Tile.Y := (SmartGetFieldInt(0, hook_static_BaseY) + (SmartGetFieldInt(Player, hook_animable_PixelY) / 512));
Result[L].Height := iabs(SmartGetFieldInt(Player, hook_character_GetHeight));
Result[L].Animation := SmartGetFieldInt(Player, hook_character_Animation);
Result[L].Moving := (SmartGetFieldInt(Player, hook_character_Motion)>0);
Result[L].HPRatio := SmartGetFieldInt(Player, hook_character_HPRatio) * 100 / $FF;
Result[L].Level := SmartGetFieldInt(Player, hook_player_GetLevel);
Result[L].Orientation := Round(FixD(180 + (SmartGetFieldInt(Player, hook_character_Orientation)* 45) / 2048));
Result[L].Interacting := SmartGetFieldInt(Player, hook_character_GetInteracting);
Inc(L);
finally
SmartFreeObject(Player);
SmartFreeObject(theName);
end;
SetArrayLength(Result, L);
end;

mormonman

2010-08-09 16:05:54

Try..finally is used to catch errors and not end the script if one is encountered. Most likely its the hooks not being updated.

weequ

2010-08-09 16:16:21

I still think it's a bug and should be made to result an empty array if hooks are outdated.

mormonman

2010-08-09 16:20:50

From: antti mies
I still think it's a bug and should be made to result an empty array if hooks are outdated.


Why would you want an empty array thats just worthless. If the hooks are outdated then don't use reflection. I have worked a lot with smart's reflection and when you try to "access" the game client with old hooks you get a violation because it is still trying to find that class/variable that might not even exist anymore.

lordsaturn

2010-08-09 19:20:02

Client version is still 614.. just checked. Try adding various debug measures throughout the function to see exactly where it is stuffing up.

mormonman

2010-08-09 20:27:28

From: lordsaturn
Client version is still 614.. just checked. Try adding various debug measures throughout the function to see exactly where it is stuffing up.


AFAIK not all of the hooks for 614 were updated.

lordsaturn

2010-08-09 22:03:04

From: mormonman
AFAIK not all of the hooks for 614 were updated.


Which is why I asked him to debug. Here's the new orientation hook:
hook_character_Orientation = 'gc';

weequ

2010-08-10 11:24:56

Sometimes I get past the function but when I try to use the array I get error. So I think It results a corrupted array somehow..
Anyway Ill try debugging the array in the function when I have time.