Testing locks

Submitted by raevnos on Thu, 2004-06-03 17:18

Testing to see if one object passes another object's lock is, again, easy to do.

The usual way to test is with the eval_lock() function. It takes three arguments: The dbref of the object that is trying to pass the lock, the dbref of the object whose lock is being testing, and the name of the lock type. This last argument is usually one of the Foo_Lock variables listed in

hdrs/lock.h

, or can be a string containing the name of the lock. Enter_Lock and "Enter" will test the same lock, but the former is the recommended usage. eval_lock() returns a true value if the lock is passed, and false otherwise. Remember that if the lock doesn't exist on the object in question, it always succeeds.

If all you have is a boolexp (The 'key' part of a lock) and not an actual lock on an object (A channel lock, for example), it can be tested with the eval_boolexp() function. Once again, it takes three arguments: The dbref of the object trying to pass the lock, the boolexp, and the dbref of the object to pretend that the boolexp is on, for eval-locks, permission and visibility checks and so forth. If there is no object associated with the boolexp, such as in channel locks, use the same dbref that's trying to pass the lock.