Script Index
In the simple model, without triggers, we color graph nodes (spells)
white, and as we recursiely visit them, mark them grey. When all of
a spell's children have been visited, and successfully cast, we
cast the spell, and mark the node either black:0 or
black: (eg black:34) for success or failure respectively.
If a child fails we mark the current node black: and
return. In the case that we visit a child that is grey, a dependency
loop is detected, currently we ignore it and build the tail spell anyway,
in the future we could break optional depends and cast some spell twice.
The more complex model implemented below includes the above, but after
a spell builds (or fails), it colors itself brown and executes its triggers.
This is a little more complicated because there could be multiple
triggers on a single spell and cycles are frequent. If successful, the
spell marks each trigger as a 'pending trigger' . Then if that spell is
the last triggerer, the trigger is registered (possibly from another
spell), and the trigger is not grey (depends cycle, indicating it is
unsafe to cast the spell) the spell is cast in a special variant of the
above algorithm. The key difference is that if a grey node is encountered
(depends cycle), instead of breaking it, the spell gracefully backs
off and the trigger is left on the pending triggers list while other
triggers are executed. All the triggers for the spell are executed
similarly until there are no triggers left, or no progress is made. If
after all spells are cast there are still pending triggers they are
built at that point without the graceful cycle handling.
Copyright
(C) 2005 The Source Mage Team
Synopsis
Implements sorcery's dependency/trigger tree walking engine.
Parameters:
Description
This is the entry point for the dependency engine, it handles top level
tasks. It invokes the cast_engine on each requested spell and cleans
up any left-over pending triggers.
Parameters:
- $1: Spell to cast
- $2: In trigger flag, default 0. If 1 and a depends loop exists back-off and fail gracefully.
Description
Top level routine for executing a graph node
Builds the children, then itself, then executes triggers.
Parameters:
- $1: Spell
- $2: In trigger flag (optional) if 1, then back off more readily in the event of a dependency loop.
global
MINUS_K if 'yes', then act like make -k and continue building
dependent spells even if another one fails.
Description
Iterative recursive step. Build each of the spell's dependencies.
Parameters:
Description
Attempt to run all this spell's triggers. Some triggers may not be
runable at this time, or it may be better to run them later.
Parameters:
Description
frontend to cast spells, unregisters pending triggers if any
Parameters:
Description
set the spell color
Parameters:
Description
get the spell color
Parameters:
Description
Mark this spell as a pending trigger
Parameters:
Description
determine if a trigger is pending or not
Parameters:
Description
mark spell as no longer needing a trigger
Parameters:
Description
return all the pending triggers