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
Distro Decay package

 
Post new topic   Reply to topic    PenUltima Online Forum Index -> Development Discussion
Display posts from previous:   

Author Message
OldnGrey



Joined: 04 Feb 2006
Posts: 517

PostPosted: Fri Jan 12, 2007 9:16 am    Post subject: Distro Decay package Reply with quote

Austin,
The current distro decay package seems to need a wee bit of work.

decayCycle.src needs to reset cur_y after the inner for/endfor loop otherwise it never runs the y loop again.

Also the sleeps are way too long - I've been experimenting with them and haven't found the ideal values yet, but something like a 40mS pause after the inner for/endfor loop seems better to me but may still not get through the world inside 15 minutes.

How long should it take for the decay script to run? Perhaps just under 15 minutes would be ideal to keep the average cycles more constant. I would suggest you not use sleep at the end of a world sweep, simply because you might like the cycle to run every 15 minutes rather than 15 minutes after it last finished.

One final thing - you really don't want to be logging every item decayed. That's going to get huge very fast.

Author Message
OldnGrey



Joined: 04 Feb 2006
Posts: 517

PostPosted: Sat Jan 13, 2007 1:04 am    Post subject: Reply with quote

Here are the changes I made to the distro decay system. Notes below show why:


Code:
CONST RECT_SIZE   := 32;

program DecayCycle(realm)
   // Make sure there isn't already a decay cycler running for this realm.
   Set_Critical(1);
      if ( GetProcess(CInt(GetGlobalProperty("#DecayPid-"+realm.name))) )
         return 0;
      else
         SetGlobalProperty("#DecayPid-"+realm.name, GetPid());
      endif
   Set_Critical(0);

   var data_file := DFOpenDataFile("DecayInfo", DF_CREATE);
   var data_elem := DFFindElement(data_file, "Status-"+realm.name, DF_CREATE);

   Set_Priority(1);
   Sleep(3);

   /* Start from the last place the decayer was at.
    * This is to ensure that if there are a lot of crashes,
    * it doesn't decay the start of the realm over and over.
    */
   var cur_x := CInt(data_elem.GetProp("X"));
   var cur_y := CInt(data_elem.GetProp("Y"));

   // Report the starting position of the decay cycle for this realm.
   DECAY_ReportText("Starting "+realm.name+" decayer at X:"+cur_x+" Y:"+cur_y + " Width: " + realm.width + " Height: " + realm.height, DECAY_REPORT_CONSOLE+DECAY_REPORT_SYSLOG);

   while ( 1 )
      //check to see if the server is shutting down. If so, quit
      if ( GetGlobalProperty("#restartingserver") )
         DECAY_ReportText("Closing down decay system in " + realm.name + " as server is shutting down.", DECAY_REPORT_CONSOLE+DECAY_REPORT_SYSLOG);
         return 0;
      endif

      var starttimer := ReadGameClock();
      for ( cur_x; cur_x <= realm.width; cur_x := cur_x + RECT_SIZE )
         for ( cur_y; cur_y <= realm.height; cur_y := cur_y + RECT_SIZE )
            /*
             * Note:
             *  Print("Decayer: sweeping "+cur_x+" "+cur_y+" "+(cur_x+RECT_SIZE)+" "+(cur_y+RECT_SIZE));
             *  ListObjectsInBox() is ruthless and will list everything that is in that rect.
             */
            foreach   object in ( ListObjectsInBox(cur_x, cur_y, -130, cur_x+RECT_SIZE, cur_y+RECT_SIZE, 130, realm.name) )
               if ( CanRemove(object) )
                  RemoveObject(object);
               endif
            endforeach

            data_elem.SetProp("Y", cur_y);
            if ( realm.name == "britannia" )
               // realm not used. do it slowly
               SleepMS(400);
            else
               SleepMS(10);
            endif
         endfor
         cur_y := 0;

         data_elem.SetProp("X", cur_x);
      endfor

      // A full realm sweep has been done.
      cur_x := 0;
      cur_y := 0;
      data_elem.SetProp("X", 0);
      data_elem.SetProp("Y", 0);

      var elapsedtime := ReadGameClock() - starttimer;
      DECAY_ReportText("Decay sweep of " + realm.name + " took " + elapsedtime + " seconds", DECAY_REPORT_CONSOLE+DECAY_REPORT_SYSLOG);

      //Ensure decayer run 15 minutes after last time.
      var nextloop := starttimer + 900;
      while ( ReadGameClock() < nextloop )
         Sleep(60);
      endwhile
   endwhile

   return 1;
endprogram



A couple of notes:
* yeah made 096 compatible.. cos that's what I use!
* I play in britannia_alt, that's why the decay for britannia is slow.
* the while loop at the end of the program is there just to ensure decay only happens every 15 minutes, not 15 minutes after you last ran it.
* the sleeps seem to work ok for a realm with about 60,000 top level items.
* the RECT+SIZE is 32 to make it fit map boundaries better
* cur_y is reset to 0 otherwise the inner for/enfor loop doesn't run more than once.
* I have a cprop set by shutdown timers to signal impending shutdown, it's tested here to close down the decay system early

Extenal changes:
* I also don't log every item decayed, I only log if it can't decay something.
* The decayCycle is started 10 minute after shard startup so players can at least attempt to get to things after restart.

Author Message
Shinigami
POL Core Developer


Joined: 30 Jan 2006
Posts: 292
Location: Germany, Bavaria

PostPosted: Sat Jan 13, 2007 7:05 am    Post subject: Reply with quote

just a short question here: what are the differences between core-decay and this way?

Shinigami

Author Message
tekproxy
Distro Developer


Joined: 06 Apr 2006
Posts: 350
Location: Nederland, Texas

PostPosted: Sat Jan 13, 2007 12:09 pm    Post subject: Reply with quote

Austin probably only spent 15 minutes on that entire package because he's that good and that busy. Very Happy He was probably logging every item just to make sure the thing worked. Pre-pre-pre-alpha version and all that.

Thanks for contributing. I'll let Austin handle this because if I do something wrong he yells at me.

Author Message
Austin
POL Developer


Joined: 30 Jan 2006
Posts: 354
Location: San Diego, California

PostPosted: Sat Jan 13, 2007 2:49 pm    Post subject: Reply with quote

Okay ive fixed a few of the for loop issues.
It isnt intended to do a world sweep within 15 minutes, just wait 15 between each sweep.

Unlike the reputation system hook, the decay package is not based on how it works inside of the core.

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

 




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