Author Topic: Adding a channel to the MUD  (Read 6292 times)

Offline quixadhal

  • BFF
  • ***
  • Posts: 642
    • View Profile
    • WileyMUD
Adding a channel to the MUD
« on: February 02, 2018, 09:43:40 pm »
So, for some reason EVERY mudlib out there seems to refuse to document this process, leaving it to us to figure it out every time we try a new one.  Skylib shares this philosophy, and so this is what I've figured out so far.

There are two distinct parts to adding an existing I3 channel to your shiny new MUD.  This is *NOT* the process of creating a new channel, this is adding one that already exists out on I3 to the MUD and to the players, so you can actually USE it.

Step one is to make the MUD aware that a channel exists.  AFAIK, there are not commands or objects to let you do this dynamically, so you have to go edit a couple files and run a line of code.

One such file is /secure/include/intermud.h.  In here, you will find the following:

Code: [Select]
  "imud_code", \
  "imud_gossip", \
  "nschat", \
  "nscre", \
  "skylib", \
  "url", \

You don't HAVE to change this, but this is the initial set of I3 channels the MUD will know about.

The next file you want to look at is /global/player/channels.c.  In here, you will find a function called register_channels().  For some reason, this doesn't let you add new channels, but simply sets the player's channel list to be a set of channels that's pre-defined, with some added or removed based on security settings and the channel existing on I3 or not.

Code: [Select]
private void register_channels() {
    string *orgs;

    channels = ({"chat", "singing", "newbie"});

    if( adminp(TO) )
        orgs = ORGS_H->query_orgs();
        orgs = ORGS_H->query_my_orgs( TO->query_name() );

    if( sizeof(orgs) )
        foreach( string org in orgs )
            channels += ({ ORGS_H->query_channel(org) });

    if( creatorp(TO) ) {
        string name;

        channels += ({"cre", "discworld-chat", "dchat", "free_speech", "intercre",
                     "intergossip", "nipples", "killers", "nscre", "nschat",
                     "skylib", "url", "wileymud" });

That line there, channels += ({ ... });  That's where you need to add your channels.  This is actually Step 2, we're doing, which I will explain in just a second.

I said there were two steps to this process.  The first step is making the I3 router send you channel messages for the channels you want to hear.  You can add your channels into that default list, and I *THINK* the I3 handler will listen to each one when I3 connects to the router.

If you don't want to add them there, or I'm wrong, you can manually force the issue by typing a command like this:

Code: [Select]
> exec return INTERMUD_H->listen_channel("dchat", 1);

In that case, you're sending a packet to the router to say "I want to get messages for the dchat channel".

That will allow the MUD itself to see the channel and interact with it.  For a player to do so, we need the SECOND part, which I described above.

The parser for the player object will look at what you've typed and do a little analysis on it to figure out what you should be doing.  Part of that process is taking the first word and seeing if it matches an entry in your player object's query_channels() result.  If it does, it calls a function in the intermud handler with whatever you typed.

So, even though the MUD knows about dchat, until you go edit the player object code, the parser doesn't know what "dchat" means.

Once both parts are done, the new channel should work... except it won't yet.  Of course, one would expect to have to do the following commands:

Code: [Select]
> dupdate /global/player.c
> dupdate /secure/handlers/intermud.c

But that's not enough.  There's apparently something else that needs to be done to get this to actually work.  I don't know what it would be, as I don't understand the full layout of the mudlib... and so for me, I have to reboot the mud.  When it comes back up, whatever else needed to be done got done, and the new channels work.