It is currently Mon Jan 05, 2009 5:01 pm

All times are UTC - 8 hours




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: [fixed] Memory leak in FINDPATH() function
PostPosted: Fri Dec 07, 2007 3:19 am 
Offline

Joined: Tue Mar 20, 2007 7:17 am
Posts: 124
Location: Poland
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.


Last edited by coltain on Fri Dec 07, 2007 3:59 am, edited 1 time in total.

Top
 Profile  
 
 Post subject:
PostPosted: Fri Dec 07, 2007 3:32 am 
Offline
Certified POL Expert
User avatar

Joined: Sat Feb 04, 2006 6:26 pm
Posts: 598
Can you please post the lines you are using for findpath() and runtowardlocation() showing how you are using the array returned by findpath in the runtowardlocation function.

I was a bit confused when you posted runtowardlocation(path[2].x,path[2].y)


Top
 Profile  
 
 Post subject:
PostPosted: Fri Dec 07, 2007 3:58 am 
Offline

Joined: Tue Mar 20, 2007 7:17 am
Posts: 124
Location: Poland
sorry, I was to exited to write it propetly

code form movement.inc (brainAI):

Code:
.
.
.
      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



Searching for path works, I have no trouble with it


Top
 Profile  
 
 Post subject:
PostPosted: Fri Dec 07, 2007 4:46 am 
Offline
Certified POL Expert
User avatar

Joined: Sat Feb 04, 2006 6:26 pm
Posts: 598
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:
Code:
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.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC - 8 hours


Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
Style based on FI Subice by phpBBservice.nl