It is currently Wed Nov 19, 2008 3:46 am

All times are UTC - 8 hours




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: Distro Decay package
PostPosted: Fri Jan 12, 2007 5:16 am 
Offline
Certified POL Expert
User avatar

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


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 12, 2007 9:04 pm 
Offline
Certified POL Expert
User avatar

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


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jan 13, 2007 3:05 am 
Offline
POL Core Developer

Joined: Mon Jan 30, 2006 9:28 am
Posts: 292
Location: Germany, Bavaria
just a short question here: what are the differences between core-decay and this way?

Shinigami


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jan 13, 2007 8:09 am 
Offline
Distro Developer
User avatar

Joined: Thu Apr 06, 2006 5:11 pm
Posts: 350
Location: Nederland, Texas
Austin probably only spent 15 minutes on that entire package because he's that good and that busy. :-D 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.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jan 13, 2007 10:49 am 
Offline
POL Developer
User avatar

Joined: Wed Jan 25, 2006 2:30 am
Posts: 428
Location: San Diego, California
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.

_________________
-Austin


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 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:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
Style based on FI Subice by phpBBservice.nl