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.
Distro Decay package
Here are the changes I made to the distro decay system. Notes below show why:
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.
Code: Select all
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;
endprogramA 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.
Austin probably only spent 15 minutes on that entire package because he's that good and that busy.
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.
Thanks for contributing. I'll let Austin handle this because if I do something wrong he yells at me.