I finally found what caused memory allocation problem.
Simple test:
AI script is simple [find me and run to me (by runtoward)]
I summon instantly 300 mobiles and thay run to me (no problems, all is fine)
When I change AI script to first find a path (path:=FINDPATH(bla bla) ) and next follow this path using runtowardlocation() an allocation problem is shown... I then kill mobiles but the allocation problem still is present.
I like FINDPATH function co please fix it.
[fixed] Memory leak in FINDPATH() function
Moderator: POL Developer
[fixed] Memory leak in FINDPATH() function
Last edited by coltain on Fri Dec 07, 2007 3:59 am, edited 1 time in total.
sorry, I was to exited to write it propetly
code form movement.inc (brainAI):
Searching for path works, I have no trouble with it
code form movement.inc (brainAI):
Code: Select all
.
.
.
NEMOVE_RUN:
case( ev.direction )
NEMOVE_AWAY:
repeat
RunAWayFrom(ev.source);
SleepMS(3);
until ( !MoveLoopCheck(ev) );
NEMOVE_TOWARD:
repeat
szukaj_sciezki(ev.source); //advanced run
//RunToward(ev.source); // simple run
//SleepMS(3); // simple run
until ( !MoveLoopCheck(ev) );
endcase
//test
function szukaj_sciezki(cel)
if(!cel || cel.dead)
return;
endif
var sciezka := FindPath(self().x,self().y,self().z,cel.x,cel.y,cel.z,self().realm,0,25);
if(sciezka)
foreach wpis in (sciezka)
RunTowardLocation(wpis.x,wpis.y);
sleepms(3);
endforeach
endif
return 1;
endfunction
Have you printed out the sciezka array to see what's in it?
I am now a big fan of testing for errortext from functions so I'd be modifying the function a bit to catch any errors. I haven't looked at the contents of the return array before but the doco does imply it's a struct per coord with .x and .y properties.
As a test:
I've noticed that there has been a LOT of discussion about findpath over the last year. I have been avoiding it I must admit.
So where is the memory allocation error occuring? At what line? In findpath or in the RunTowardLocation?
Also, I'd be really careful about having a searchskirt as big as 25. That's going to be a huge attempt. The default is 5, I'd be looking to start with 5 and see.
These are just some thoughts, given my total lack of experience with findpath. Good luck narrowing it down.
I am now a big fan of testing for errortext from functions so I'd be modifying the function a bit to catch any errors. I haven't looked at the contents of the return array before but the doco does imply it's a struct per coord with .x and .y properties.
As a test:
Code: Select all
if ( sciezka && !sciezka .errortext )
foreach wpis in (sciezka)
RunTowardLocation(wpis.x,wpis.y);
sleepms(3);
endforeach
elseif (sciezka .errortext )
PrintTextAbove(cel, sciezka.errortext);
endif
I've noticed that there has been a LOT of discussion about findpath over the last year. I have been avoiding it I must admit.
So where is the memory allocation error occuring? At what line? In findpath or in the RunTowardLocation?
Also, I'd be really careful about having a searchskirt as big as 25. That's going to be a huge attempt. The default is 5, I'd be looking to start with 5 and see.
These are just some thoughts, given my total lack of experience with findpath. Good luck narrowing it down.