View/Edit #73:path_between

Switch to edit mode.

Name(s): path_between
1:  "Copied from MattC (#9466):path_between Jun 12 19:26:06 1999"
2:  ":path_between(SRC, DEST, OBJ) => {exit1, exit2, ...}"
3:  ""
4:  "Determines a path from SRC room to DEST room for OBJ, if one exists.  Returns simply a list of exits or E_NACC if none exists."
5:  {src, dest, object} = args
6:  if (src == dest)
7:    return {}
8:  elseif (!valid(src) || !valid(dest))
9:    raise(E_INVARG)
10: endif
11: stack = {src}
12: pstack = {{}}
13: ostack = {}
14: opstack = {}
15: while (1)
16:   end = length(stack)
17:   ostack[1..0] = stack
18:   opstack[1..0] = pstack
19:   stack = {}
20:   pstack = {}
21:   for i in [1..end]
22:     o = ostack[i]
23:     path = opstack[i]
24:     for e in (`o:exits() ! ANY => {}')
25:       suspend(0)
26:       if ($room_db:valid_exit(e) && $get_property(e, "obvious") && `$call_verb(e, "is_unlocked_for", {object}) ! ANY' && `(d = `$call_verb(e, "real_dest", {}) ! ANY => $get_property(e, "dest")'):acceptable(object) ! ANY')
27:         npath = {@path, e}
28:         if (d == dest)
29:           return npath
30:         endif
31:         if (!(d in ostack) && !(d in stack))
32:           stack[1..0] = {d}
33:           pstack[1..0] = {npath}
34:         endif
35:       endif
36:       $command_utils:suspend_if_needed()
37:     endfor
38:     $command_utils:suspend_if_needed()
39:   endfor
40:   if (!stack)
41:     return E_NACC
42:   endif
43: endwhile
44: "Last modified by Dax (#789) on Mon Aug 19 08:16:05 2002 MDT."

Verb arguments: this none this
Verb perms: Readable eXecutable NOT-Debug
Verb owned by: Slacker (#55)

You are not logged in.

[home | help | who | search | setup | code]