Can't save new commands?

Posted by Ingus on Fri 28 Mar 2003 11:29 PM — 5 posts, 18,521 views.

#0
I add new commands to the source, declaring them in mud.h, and the usual if checks in tables.c. I create them using cedit <command> <code> and it finds the code and the command works like it should. But when I save the command table (or even before I save it) and look at the command again for its code it has something like this: (00401EA1)
On the next reboot the command doesnt work (Huh?) and I have to cedit again. I tried manually putting it in commands.dat with a text editor but still I come up with the same result. Anyone have any ideas?
Australia Forum Administrator #1
A common mistake is to take the lines in tables.c, and copy one, like this:


    case 'c':
        if ( !str_cmp( name, "do_cast" ))               return do_cast;         
        if ( !str_cmp( name, "do_cedit" ))              return do_cedit;
        if ( !str_cmp( name, "do_channels" ))           return do_channels;     
        if ( !str_cmp( name, "do_chat" ))               return do_chat;      


Say you decide to copy the "do_cast" line, but your new command is "do_marry", you get this:


    case 'c':
        if ( !str_cmp( name, "do_cast" ))               return do_cast;         
        if ( !str_cmp( name, "do_marry" ))               return do_marry;         
        if ( !str_cmp( name, "do_cedit" ))              return do_cedit;
        if ( !str_cmp( name, "do_channels" ))           return do_channels;     
        if ( !str_cmp( name, "do_chat" ))               return do_chat;      


However the problem is the command is in the "c" section, whereas "marry" should be in the "m" section.
#2
No luck, the two commands I added are both in there respective cases. I have found that I can manually edit the commands.dat file and restart the mud and everything seems ok. As soon as I do a 'cedit save cmdtable' and reboot, however, the commands are gone again, the code field being replaced with that (43cdg435) junk.
Australia Forum Administrator #3
In tables.c there is some code:



char *skill_name( DO_FUN *skill )
{
    static char buf[64];

    if ( skill == NULL )                return "reserved";    
    if ( skill == do_aassign )          return "do_aassign";   

...

    if ( skill == do_ilist )            return "do_ilist";    
    if ( skill == do_rping )            return "do_rping";  
#endif

    sprintf( buf, "(%p)", skill );
    return buf;
}


Notice how it returns the address of the skill if it isn't in the list (line in bold)? That suggests to me that your new command isn't in the list above.

#4
DOH! Indeed, that seems to be it. Don't I feel silly. At least it's simple ;) Thanks Nick, you're the man!