@q @program asys-sysscan 1 99999 d i ( asys-sysscan v1.2 Jessy@FurryMUCK 6/00 The +sysscan command is a background process that runs once per day, handling Argo maintenance tasks. It is also called from the global _depart/ queue, to check for and handle important flag and prop resets. INSTALLATION: asys-sysscan uses the standard Argo installation method. Port the program and set it Wizard. Type '+install asys-sysscan' USAGE: +sysscan ...................... Show scaner status +sysscan #on .................. Turn on scanner [Staff only] +sysscan #off ................. Turn off scanner [Staff only] Asys-sysscan may be freely ported. Please comment any changes. ) (2345678901234567890123456789012345678901234567890123456789012345678901) $def thisVersion "1.2" $define Tell me @ owner swap notify $enddef $include $lib/argo $include $lib/reflist lvar scratch (* workspace var *) lvar ourCounter (* misc. counter var *) lvar ourDataObj (* dbref: object holding system-wide data *) lvar ourArg (* inital arg string, unmodified *) lvar ourCom (* string: 'official' name of command *) lvar ourBoolean (* int: misc flow control var *) : DoInstall ( -- ) (* install program into Argo system *) caller program? not if (* confirm installation method *) ">> Programs must be installed via the " "+install" GetCommandName strcat " command." strcat Tell exit then prog "@a/version" getpropstr if (* confirm re-install *) ">> Reinstalling..." Tell else ">> Installing..." Tell then (* record 'official' name of prog; remove old links *) prog "@a/name" "asys-sysscan" setprop RecOldActions (* create and register command; set default props *) #0 "+sysscan" newexit dup scratch ! prog setlink prog "@a/version" thisVersion setprop scratch @ "@a/version" thisVersion setprop #0 "@a/comm_list/+sysscan" scratch @ setprop #0 "@a/prog_list/" prog name strcat prog setprop scratch @ "@a/name" "+sysscan" setprop (* set the _depart/ queue for cleanups *) #0 "_depart/asys-sysscan" prog setprop prog "L" set ">> Installed." Tell ; : DoUninstall (* uninstall program from Argo *) prog "@a/name" getpropstr if #0 "@a/prog_list/" prog "@a/name" getpropstr strcat getprop not if ">> " prog name strcat " is not currently installed." strcat Tell pid kill then else ">> " prog name strcat " is not currently installed." strcat Tell pid kill then ">> Please confirm: You wish to uninstall " prog name strcat "?" strcat Tell ReadYesNo not if ">> Aborted." Tell pid kill Then background "@a/comm_list/+sysscan" RemoveCommand #0 "@a/prog_list/" prog "@a/name" getpropstr strcat remove_prop RecOldActions #0 "_depart/asys-sysscan" remove_prop ">> Uninstalled. Please edit the online manual as appropriate." Tell ; : DoHelp ( -- ) (* display help screen *) " " Tell prog name " (#" strcat prog intostr strcat ")" strcat Tell " " Tell "This program controls the Argo system scanner, a background process " "that scans the dbase once per day, handling healing rolls and " "recycling unneeded Argo objects." strcat strcat Tell " " Tell "Syntax:" Tell " " Tell " $com ...................... Show scaner status" command @ "$com" subst Tell " $com #on .................. Turn on scanner (Staff only)" command @ "$com" subst Tell " $com #off ................. Turn off scanner (Staff only)" command @ "$com" subst Tell " " Tell ; : DoScannerOn ( -- ) (* start the scanner loop *) StaffCheck not if (* check permision *) ">> Permission denied." Tell exit then (* go to background *) background (* make sure we only have one process *) #0 "@a/scanner" getprop kill NukeStack #0 "@a/scanner" pid setprop ">> Scanner on." Tell (* notify *) begin #0 "@a/scanner" getprop dup if (* verify process id *) ispid? not if pid kill then else NukeStack pid kill then #0 (* scan the db *) begin dup dbtop dbcmp not while dup ok? if dup "@a/version" getpropstr if dup player? if (* do healing *) dup "@a/stats/dam" getpropstr if dup scratch ! scratch @ "@a/stats/con" GetModAbility 3 6 0 Dice >= if scratch @ "@a/stats/dam" over over getpropstr atoi 1 - intostr setprop scratch @ "@a/stats/dam" getpropstr atoi 0 <= if scratch @ "@a/stats/dam" remove_prop then then then then (* handle revivals *) dup "@a/revive_after" getprop dup if systime < if dup "@a/revive_after" remove_prop dup "@a/status" "approved" setprop #0 "@a/revive" 3 pick REF-delete ">> $name revives from death." over name "$name" subst TellRoom then else pop then dup thing? if (* recycle junk *) dup "@a/rec_after" getprop dup if systime < if dup recycle then else pop then then then then 1 + repeat pop NukeStack 86400 sleep repeat ; : DoScannerOff ( -- ) (* turn off scanner *) StaffCheck not if ">> Permission denied." Tell then #0 "@a/scanner" getprop dup if kill NukeStack then ">> Scanner off." Tell ; : DoCheckGuard ( -- ) (* force a guard check *) #0 "@a/calls/checkguard" getprop dup if "#checkguard" swap call pop else pop then ; : DoShowScanner ( -- ) (* show status of scanner *) #0 "@a/scanner" getprop dup if ispid? if ">> The scanner is on." Tell else ">> The scanner is off." Tell #0 "@a/scanner" remove_prop then else ">> The scanner is off." Tell then ; : DoLoopCheck ( -- ) (* make sure we have an event loop if needed *) me @ "@a/stats/con_mod" getpropstr atoi me @ "@a/stats/dex_mod" getpropstr atoi or me @ "@a/stats/int_mod" getpropstr atoi or me @ "@a/stats/pre_mod" getpropstr atoi or me @ "@a/stats/str_mod" getpropstr atoi or me @ "@a/stats/fat" getpropstr atoi or if me @ "@a/eloop/pid" getprop dup if ispid? not if me @ "@a/eloop/quell_tell" "yes" setprop me @ "+wait" force me @ "@a/eloop/quell_tell" remove_prop then else me @ "@a/eloop/quell_tell" "yes" setprop me @ "+wait" force me @ "@a/eloop/quell_tell" remove_prop pop then then ; : DoCleanup ( -- ) (* tidy up as needed on Depart *) DoLoopCheck me @ "@a/hidden" getprop if (* undark any hiding players *) me @ "!D" set me @ "@a/hidden" remove_prop then (* stop clairsentience an other listens that have expired *) #0 "@a/stop_listen" REF-allrefs ourCounter ! (* get listeners *) begin ourCounter @ 0 > while dup ok? if dup "@a/eloop/stop_listen" getprop dup if (* time's up? *) systime < if dup "@a/eloop/listening_to" getprop dup if dup "@a/eloop/listening" 3 pick REF-delete dup "@a/eloop/listening" getpropstr if "_listen/asys-stdpsiabs" remove_prop else pop then #0 "@a/stop_listen" 3 pick REF-delete dup "@a/eloop/stop_listen" remove_prop dup "@a/eloop/listening_to" remove_prop else pop then then else pop then then pop ourCounter @ 1 - ourCounter ! repeat me @ contents (* undark any hidden objects that are being moved *) begin dup while dup "@a/hidden" getprop if dup "!D" set dup "@a/hidden" remove_prop then next repeat pop (* relock any locks that got picked *) #0 "@a/relock" REF-allrefs ourCounter ! begin ourCounter @ 0 > while dup ok? if dup "@a/relock_at" getprop dup if systime < if ourDataObj @ "@a/relock_at" 3 pick REF-delete dup Relock then then else #0 "@a/relock" 3 pick REF-delete then pop ourCounter @ 1 - ourCounter ! repeat (* unhide/unvisible anything that's time is up *) #0 "@a/reveal" REF-allrefs ourCounter ! begin ourCounter @ 0 > while dup ok? if dup "@a/reveal_at" getprop dup if systime < if ourDataObj @ "@a/reveal_at" 3 pick REF-delete dup "!D" set dup "@a/hidden" remove_prop dup "@a/invisible" getpropstr if ">> $name reappears." over name "$name" subst TellRoom then dup "@a/invisible" remove_prop then then else #0 "@a/reveal" 3 pick REF-delete then pop ourCounter @ 1 - ourCounter ! repeat (* check +control experations *) #0 "@a/uncontrol" REF-allrefs ourCounter ! begin ourCounter @ 0 > while dup ok? if dup "@a/eloop/controlled" REF-allrefs scratch ! begin scratch @ while dup ok? if dup "@a/eloop/controlling" getprop dup if over dbcmp if dup "@a/eloop/control_expires" getprop dup if systime < if dup "@a/eloop/controlling" remove_prop over "@a/eloop/controlled" 3 pick REF-delete then else pop then then else pop then then pop scratch @ 1 - scratch ! repeat dup "@a/eloop/controlled" getpropstr if #0 "@a/uncontrol" 3 pick REF-delete then else #0 "@a/uncontrol" 3 pick REF-delete then pop ourCounter @ 1 - ourCounter ! repeat (* return moved objects *) #0 "@a/return" REF-allrefs ourCounter ! begin ourCounter @ 0 > while dup ok? if dup "@a/eloop/return_at" getprop dup if systime < if ourDataObj @ "@a/return" 3 pick REF-delete dup "@a/eloop/return_to" getprop dup if over swap moveto else pop dup dup getlink moveto then dup "@a/eloop/return_at" remove_prop dup "@a/eloop/return_to" remove_prop then then else #0 "@a/return" 3 pick REF-delete then pop ourCounter @ 1 - ourCounter ! repeat (* handle high priority recycles *) #0 "@a/recycle" REF-allrefs ourCounter ! begin ourCounter @ 0 > while dup ok? if dup "@a/rec_after" getprop dup if systime < if ourDataObj @ "@a/recycle" 3 pick REF-delete dup recycle then then else #0 "@a/recycle" 3 pick REF-delete then pop ourCounter @ 1 - ourCounter ! repeat ; : main "me" match me ! (* initialize *) GetDataObj ourDataObj ! strip ourArg ! trig "@a/name" getpropstr ourCom ! ourArg @ if ourArg @ "Depart" smatch command @ "Queued event." smatch and if DoCleanup exit then ourArg @ "#" stringpfx if "#cleanup" ourArg @ smatch if DoCleanup else "#on" ourArg @ stringpfx if DoScannerOn else "#off" ourArg @ stringpfx if DoScannerOff else "#help" ourArg @ stringpfx if DoHelp else "#enable" ourArg @ stringpfx if DoEnable else "#disable" ourArg @ stringpfx if DoDisable else "#version" ourArg @ stringpfx if DoVersion else "#install" ourArg @ stringpfx if DoInstall else "#uninstall" ourArg @ stringpfx if DoUninstall else ">> #Argument not understood." Tell then then then then then then then then then exit then then me @ ArgoPermCheck Disabled? DoShowScanner ; . c q @set asys-sysscan=W @set asys-sysscan=L