Phantasmal MUD Lib for DGD
|
Phantasmal Site > DGD > Writing a Library > ⁄cmd vs wiztool Should Your MUD Library Use ⁄cmd or a Wiztool?There are two common ways of adding commands to DGD programs. One is to have a directory of objects, traditionally called ⁄cmd, and add text commands to it by adding LPC files, each with the same name as the command they will implement. The other is to have a single object, often called a Wiztool, which takes the input and executes an appropriate command based on it. There are also a few hybrid approaches, such as the Skotos verb⁄action approach. Each action has an associated grammar in Skotos' parser, which resolves to a structure like [ "attack", <Bobo#7>, <sword#317> ]. There, each action would presumably have a ⁄cmd-style LPC object to execute the action. However, the verbs add to a single central grammar, which parses and dispatches them wiztool-style. Advantages of the Wiztool modelIn the kernel library, each player with wizard-level access has his or her own wiztool, with its own privileges. ⁄kernel⁄lib⁄wiztool masks all functions that are relevant to security, so that any inheriting object only has the level of access appropriate for the owner of that object. As a result, command security is handled by only three objects: ⁄kernel⁄sys⁄driver, ⁄kernel⁄lib⁄auto and ⁄kernel⁄lib⁄wiztool. This reduces the number of locations where security problems can occur to a very small number. The wiztool model allows commands with similar functionality to share code easily. It also makes it easy to see what commands use what variables and functions. This can aid debugging and security auditing. The Kernel Library prevents any object from ever changing its owner once it is created. This allows a wiztool to be sure on whose behalf it acts, and prevents security problems. Problems with the Wiztool modelBy storing a lot of functionality in a small number of files, the wiztool model may make it more likely that an error will cause more problems. Storing all commands in user.c may cause problems in logging in if it disrupts some vital part of user functionality, for instance. Advantages of the ⁄cmds modelThe ⁄cmds model has the aesthetic appeal of putting different commands' code in different files, which can be a large maintenance improvement. It can also make it possible for only certain admins to edit certain commands, rather than all commands being necessarily ultra-high-security. The ⁄cmds model is already familiar to a lot of LPMUD programmers. They generally have more trouble adapting to the Wiztool model. The Diku model, while different from both Wiztool and ⁄cmds models, is more similar to the ⁄smds model. Problems with the ⁄cmds modelThere is a peculiarity in the ⁄cmds model: the commands are not just in separate files, but they are even in separate instantiated LPC objects. This has been known to lead to security problems. Shared command objects require a high access level. They may have this always, or they may acquire a specific player's privileges for each command; each of these methods has its problems. From: DGD Mailing List (Stephen Schmidt) Date: Mon Mar 8 19:24:00 2004 Subject: [DGD] Couple of questions On Mon, 8 Mar 2004, William Bryan wrote: > 1) Is there a benefit to keeping all commands in the wiztool vice > breaking them out into a typical /cmd directory structure. As Noah said, both have advantages, and it is about even. It depends mostly on what you're used to. I like /cmd because I'm used to it, but also because when commands go through master objects rather than wiztool clones, it's a little easier to update one command at a time. Also, if you're like me and you make a lot of errors, then it might be better to have only one command go casters-up when you screw up than to break the wiztool. Security can be a little chancy with command bins because commands like "delete" and "nuke" typically have fairly high privilege levels and you have to protect them against inappropiate calls. Wiztools have the same problem in concept but becaue each wiztool is associated with one wizards (assuing you do it that way) it's a bit easier to protect them. Or so I'm told - I haven't used wiztools. Steve |