PenUltima Online Forum Index Official Core: 096.7
Official Core: 097 2008-02-26
Donate towards the POL web hosting bill!
 POL Home   FAQ   Search    Memberlist   Usergroups    Register    Profile   Log in to check your private messages   Log in
Memory leak in FINDPATH() function

 
Post new topic   Reply to topic    PenUltima Online Forum Index -> Bug Reports 097
Display posts from previous:   

Author Message
coltain



Joined: 20 Mar 2007
Posts: 97
Location: Poland

PostPosted: Fri Dec 07, 2007 7:19 am    Post subject: Memory leak in FINDPATH() function Reply with quote

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 7:59 am; edited 1 time in total

Author Message
OldnGrey



Joined: 04 Feb 2006
Posts: 523

PostPosted: Fri Dec 07, 2007 7:32 am    Post subject: Reply with quote

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)

Author Message
coltain



Joined: 20 Mar 2007
Posts: 97
Location: Poland

PostPosted: Fri Dec 07, 2007 7:58 am    Post subject: Reply with quote

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

Author Message
OldnGrey



Joined: 04 Feb 2006
Posts: 523

PostPosted: Fri Dec 07, 2007 8:46 am    Post subject: Reply with quote

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.

Post new topic   Reply to topic    PenUltima Online Forum Index -> Bug Reports 097 All times are GMT - 4 Hours
Page 1 of 1

 




Powered by phpBB © 2001, 2005 phpBB Group :: Theme & Graphics by GHS & Scott E. Royalty