Adding new lock types

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

Adding new lock types that can be set in-game with @lock/foo is very easy.

Near the top of

src/lock.c

is an array named lock_types. Near the end of the array is a comment "Add new lock types just before this line.". Just copy & paste one of the existing entries in the array to that spot, and change the name to that of your new lock type. You can also change the default flags of the lock if you wish (The LF_PRIVATE part).

If you want to test this new lock type in hardcode, you'll also want to add a new line to the section just above the lock_types array, where there's a comment "Define new lock types here.". Once again, use the existing ones as an example.

hdrs/lock.h

also needs to be modified. If you added
'const lock_type Foo_Lock = "Foo"' in

src/lock.c

, then

hdrs/lock.h

needs to have 'extern const lock_type Foo_Lock;". This new variable is used with the eval_lock() function described later. It's not neccessary to use, but it's easier than re-typing the actual name of the lock everyplace you want to test it.