Author Topic: Remote who formatting for DIKU mudlib types.  (Read 2045 times)

Offline Tricky

  • BFF
  • ***
  • Posts: 189
  • I like what I code and I code what I like!
    • View Profile
Remote who formatting for DIKU mudlib types.
« on: August 21, 2008, 10:59:19 am »
DIKU derivatives return remote who information in a way that breaks formatting for DS libs. This bit of code will deal with them.

Find the function eventReceiveWhoReply in /daemon/services/who.c and replace it with this...

Code: [Select]
void eventReceiveWhoReply(mixed *packet) {
    mapping mudlist;
    string list, *who, tmp;
    object ob;

    if( file_name(previous_object()) != INTERMUD_D ) return;
    if( !packet[5] || !(ob = find_player(convert_name(eventLookupUser(packet[5])))) ) return;
    list = "%^MAGENTA%^Remote who information from " + packet[2] + ":%^RESET%^\n";
    mudlist = INTERMUD_D->GetMudList();
    foreach(who in packet[6]){
        mixed wtf;
        if(intp(who[1])) wtf = to_int(who[1]);

        /* Emerald MUD */
        if( who[1] == "never" )
            list += implode(explode(who[2], "\n")[1..<1], "\n") + "%^RESET%^\n";
        /* AFK I3 Driver who-reply */
        else if( wtf < 0 )
            list += who[0] + " " + who[2] + "%^RESET%^\n";
        else if( wtf == 9999 )
            list += who[0] + " " + who[2] + "%^RESET%^\n\n";
        else if( wtf == 2 * 9999 )
            list += "\n" + who[0] + " " + who[2] + "%^RESET%^\n";
        else if( wtf == 3 * 9999 )
            list += "\n" + who[0] + " " + who[2] + "%^RESET%^\n\n";
        /* Check for names with a <SPC> in them. Generally means it is a header in who[2]. */
        else if( strsrch(who[0], " ") != -1
          && ( strsrch(lower_case(mudlist[packet[2]][5]), "circle") != -1
           ||  strsrch(lower_case(mudlist[packet[2]][7]), "afkmud") != -1 ) )
            list += "* %^BOLD%^" + who[2] + "%^RESET%^\n";
        /* Regular I3 who-reply */
        else{
            if(wtf < 6) tmp = "not";
            else tmp = time_elapsed(wtf);
            list +=  who[0] + " (" + tmp + " idle): " + who[2] +"\n";
        }
    }
    ob->eventPrint(list);
    tn("eventReceiveWhoReply: "+identify(packet),"blue");
}

Then just reload the lib with a warmboot (warn your users of course :) ).

Tricky