[DGD]Modifying User/Player Files

Stephen Schmidt schmidsj at union.edu
Sun Jan 31 19:18:15 CET 1999


On Sun, 31 Jan 1999, Ron wrote:
> Is there any way to update user and or player files? I'm using the Melville
> mudlib which has both user and player files. What I mean infact is, if let
> say I have certain properties for a player and then I want to add another
> one (for example a new stat), how would I go about modifying the existing
> files without doing it manually (if possible)? When I update the player.c
> file and add the property I want, then new characters get the new property.
 
Assuming you know what value you want the property to take, this
is not too hard. When DGD restores an object, if there are variables
which are defined in the object but don't have values in the save
file, then those variables get a value of 0 (see the kfun doc on
restore_object for details). All you need to do is wait until
after the restore_object() call, then set the values you want
for those variables.

In /system/player.c, you will find the call to restore_object()
in the function enter_world(). Add anything you need to add
immediately after that. You may want to check to make sure the
value is 0 before setting new data - otherwise you can overwrite
something needlessly.

In /system/user/login.c, the call to restore_object() to set up
the user object (which inherits login.c) is in get_name(); it
has to be there because you have to restore the password in
order to verify the login. You could set new information right
there, but it might be better to wait until after the password
has been verified as correct. In that case, add whatever you
need to add right before the line:

    write ("\n") ;

in check_password(), also in login.c.

The TMI-2 mudlib has a special routine for this; at the appropriate
spot during login, the TMI-2 player object calls a function called
consistency_check() which handles all this stuff. If you think you
will need to be adding new variables regularly, you might want
to hack a similar function into your player object, so that you
can keep all the code in one easy-to-find place. TMI-2 doesn't have
anything like for its user object (which it calls a connection
object); you could add that too if you wanted, but I'd guess that
the user object is probably stable enough that you wouldn't need
to do that.

Be sure also to handle the case of a user creating a new character
by making the necessary additions in the code that follows the 
create_character() function, although you probably have done that
already.


Stephen Schmidt/Mobydick

It is vain to expect a well-balanced government without a
well-balanced society.
			-- Gideon Welles








List config page:  http://list.imaginary.com/mailman/listinfo/dgd



More information about the DGD mailing list