gab_mip.zip

snippets · 8.7 KB · 2010-03-30

MIP 8.1 (Messaging Interface Protocol) support module for MUDs.

Download   « Back to the snippets list

install.txt

.-------------------------------------------------------------------------------.
| Title    : MIP (Messaging Interface Protocol) v8.1 Support Module		|
| Author   : Chris Coulter (aka Gabriel Androctus)				|
| Date     : 08.26.02								|
| Dev. MUD : Perils of Quiernin	( perils.org 6000 )				| 
| Platform : SMAUG v1.4a							|
| MUD Page : http://www.perils.org/						|
| Res. Page: http://www.perils.org/goodies/					|
|-------------------------------------------------------------------------------|
| DESCRIPTION:									|
| MIP (Messaging Interface Protocol) enables your mud to communicate specific   |
| text strings to a player using the Portal client software. This module        |
| provides basic support for establishing if the player is using the Portal     |
| client and assigning the appropriate information, as well as a simplified     |
| way to send the strings to trigger specific features on the player's client.  |
|										|
| For more information, visit Portal's web page ( www.gameaxle.com ) and click  |
| on the "Developers" button on the menu bar. From there you can download a PDF |
| file that explains in detail the specifics of the MIP.			|
|										|
| NOTE: If a player is not using the Portal client, the mud will function as    |
| it normally would, and the player would not receive the MIP codes. It will    |
| only function for players who has connected via the Portal mud client         |
| 										|
|-------------------------------------------------------------------------------|
| LEGAL MUMBO JUMBO:								|
| This code snippet is in no way guaranteed to work on your mud, nor is the	|
| author held responsible for any problems that might arise due to its use.	|
| By implementing part or all of this snippet, you agree to keep the original	|
| credits in the source code as well as the help index entry. In addition,	|
| you are required to send an email to the author informing him of its use.	|
|										|
| ADDITIONAL LICENSE:								|
| In the event of implementation of this code or parts of it, you must also     |
| adhere to the license agreement provided by the Portal client's developers.   |
| This can be viewed in the PDF file available for download at their web site   |
| located at the following address: http://www.gameaxle.com/			|
|                      								|
.-------------------------------------------------------------------------------.
 
Ok ... now that all that nonsense is taken care of, on with the important stuff.
This snippet is freeware, so feel free to toss it around to your friends. However,
I would appreciate it if you did not make my snippets available on your web site
unless it becomes unavailable at my own page.

Also, please do not email me for assistance with this snippet. I unfortunately
do not have the time to support my snippets any more. If you have questions, I'm 
sure someone on the Smaug Mailing List will be glad to help you out. Sorry.

However, bug reports and suggestions for future development are more than welcome.
 

/* Installation Instructions */

1) Add the following lines in their appropriate places: (dist/src)

MUD.H:
  Find:
    #define BV31	(1 << 31)

  Add after:
    /* MIP (Message Interface Protocol) Defines     -gabe */
    #define CL_DELIM                "~"  
    #define CL_SEND_SOUND           "AAA"
    #define CL_SEND_IMAGE           "AAB"
    #define CL_SEND_REBOOT          "AAC"
    #define CL_SEND_MUSIC           "AAD"
    #define CL_SEND_UPTIME          "AAF"
    #define CL_SEND_AVI             "AAG"
    #define CL_DOWNLOAD_MEDIA       "AAH"
    #define CL_SEND_SPECIAL         "BAA"
    #define CL_SEND_SPECIAL2        "BAC"
    #define CL_SEND_TELL            "BAB"
    #define CL_SEND_ROOM            "BAD"
    #define CL_SEND_MUDLAG          "BAE"
    #define CL_SEND_EDIT            "BAF"
    #define CL_GP1_MASK             "BBA"
    #define CL_GP2_MASK             "BBB"
    #define CL_HP_MASK              "BBC"
    #define CL_SP_MASK              "BBD"
    #define CL_SEND_CAPTION         "CAP"
    #define CL_SEND_BEGIN_FILE      "CDF"
    #define CL_SEND_CONT_FILE       "CCF"
    #define CL_SEND_END_FILE        "CEF"
    #define CL_SEND_CHAT            "CAA"
    #define CL_SEND_ROOMCODE        "DDD"
    #define CL_SEND_COMPOSITE       "FFF"
    #define CL_SEND_HP              "A"
    #define CL_SEND_MAXHP           "B"  
    #define CL_SEND_SP              "C"
    #define CL_SEND_MAXSP           "D"
    #define CL_SEND_GP1             "E"  
    #define CL_SEND_MAXGP1          "F"
    #define CL_SEND_GP2             "G"  
    #define CL_SEND_MAXGP2          "H"  
    #define CL_SEND_GLINE1          "I"  
    #define CL_SEND_GLINE2          "J"  
    #define CL_SEND_ATTACKER        "K"  
    #define CL_SEND_ATTCOND         "L"
    #define CL_SEND_ATTIMG          "M"

    #define MIP_MEDIA_URL           "http://www.your-site.com/mip/"
    /* End MIP defines */

  Find:
    /* hashstr.c */
    char *  str_alloc       args( ( char *str ) );
    char *  quick_link      args( ( char *str ) );
    int     str_free        args( ( char *str ) );
    void    show_hash       args( ( int count ) );
    char *  hash_stats      args( ( void ) );
    char *  check_hash      args( ( char *str ) );
    void    hash_dump       args( ( int hash ) );
    void    show_high_hash  args( ( int top ) );

  Add after:
    /* mip.c */
    bool    mip_enabled     args( ( CHAR_DATA *ch ) );
    void    init_mip        args( ( CHAR_DATA *ch ) );
    void    send_mip        args( ( char *argument, CHAR_DATA *ch ) );
    void    send_mip_music  args( ( CHAR_DATA *ch, char *argument, int iterations ) );
    void    send_mip_sound  args( ( CHAR_DATA *ch, char *filename ) );
    void    send_mip_image  args( ( CHAR_DATA *ch, char *filename, char *label ) );
    void    send_mip_reboot args( ( CHAR_DATA *ch, char *argument ) );
    void    send_mip_uptime args( ( CHAR_DATA *ch, char *argument ) );
    void    send_mip_avi    args( ( CHAR_DATA *ch, char *filename, char *label, int height, int width, bool fRepeat ) );
    void    send_mip_special  args( ( CHAR_DATA *ch, char *argument ) );
    void    send_mip_special2 args( ( CHAR_DATA *ch, char *argument ) );
    void    send_mip_tell   args( ( CHAR_DATA *ch, CHAR_DATA *victim, char *argument, bool fReceiving ) );
    void    send_mip_room   args( ( CHAR_DATA *ch, char *argument ) );
    void    send_mip_mudlag args( ( CHAR_DATA *ch, char *argument ) );
    void    send_mip_edit   args( ( CHAR_DATA *ch, char *filename ) );
    void    send_mip_mask   args( ( CHAR_DATA *ch, char *argument, char *type ) );
    void    send_mip_caption  args( ( CHAR_DATA *ch, char *argument ) );   
    void    send_mip_begin_file args( ( CHAR_DATA *ch, int lines, char *filename ) );
    void    send_mip_cont_file  args( ( CHAR_DATA *ch, char *line ) );
    void    send_mip_end_file   args( ( CHAR_DATA *ch ) );
    void    send_mip_channel  args( ( CHAR_DATA *ch, const char *cmd, char *channel, char *source, char *argument ) );
    void    send_mip_exits  args( ( CHAR_DATA *ch ) );
    void    send_mip_points args( ( CHAR_DATA *ch ) );
    void    send_mip_attacker args( ( CHAR_DATA *ch ) );

  Find in pc_data:
    char **             tell_history;   /* for immortal only command lasttell */
    sh_int              lt_index;       /* last_tell index */

  Add after:
    /* MIP (Messaging Interface Protocol)         -gabe */
    char *      sec_code;       /* MIP Security Code    */
    char *      mip_ver;        /* MIP Version Info     */

  Find:
    PLR_INVISPROMPT
  
  Add at end of flags:
    PLR_MIP

  Find:
    DECLARE_DO_FUN( do_minvoke );

  Add after:
    DECLARE_DO_FUN( do_mip_start );

  (if you are not using BFD, you must also add the proper declarations to tables.c)

BUILD.C:
  Find:
    char *  const   plr_flags [] =

  Add after the last flag:
    "mip"

COMM.C:
  Find:
    act( AT_ACTION, "$n has lost $s link.", ch, NULL, NULL, TO_CANSEE );
    ch->desc = NULL;

  Add after:
    ch->pcdata->mip_ver = STRALLOC( "" );
    ch->pcdata->sec_code = STRALLOC( "" );
    xREMOVE_BIT( ch->act, PLR_MIP );

  Find:
    if ( xIS_SET(ch->act, PLR_PROMPT) )
      display_prompt(d);
  
  Add after:
    send_mip_points( ch );
    
    if ( ch->fighting )
      send_mip_attacker( ch );

  Find in check_reconnect:
    send_to_char( "Reconnecting.\n\r", ch );

  Replace with:
    send_to_char( "Reconnecting... Welcome back.\n\r", ch );

  Find in check_playing:
    send_to_char( "Reconnecting.\n\r", ch );
  Replace with:
    send_to_char( "Reconnecting... Welcome back.\n\r", ch );

FIGHT.C:
  Find in stop_fighting:
    free_fight( ch );
    update_pos( ch );

  Add after:
    send_mip_attacker( ch );

  Find:
    for ( fch = first_char; fch; fch = fch->next )
    {
        if ( who_fighting( fch ) == ch )
        {
            free_fight( fch );
            update_pos( fch );

  Add after:
    send_mip_attacker( fch );

SAVE.C:
   Find in load_char_obj:
     ch->editor                      = NULL;
     ch->pcdata->clan_name           = STRALLOC( "" );
   
   Add after:
     ch->pcdata->mip_ver             = STRALLOC( "" );
     ch->pcdata->sec_code            = STRALLOC( "" );

   Find in load_char_obj:
     if ( !ch->pcdata->council_name )
     {
       ch->pcdata->council_name = STRALLOC( "" );
       ch->pcdata->clan = NULL;
     }
   Add after:
     if ( !ch->pcdata->mip_ver )
       ch->pcdata->mip_ver = STRALLOC( "" );
     if ( !ch->pcdata->sec_code )
       ch->pcdata->sec_code = STRALLOC( "" );

ACT_MOVE.C:
  Find in do_lock:
    if ( !IS_SET(pexit->exit_info, EX_SECRET)
    ||   (pexit->keyword && nifty_is_name( arg, pexit->keyword )) )
    {
      send_to_char( "*Click*\n\r", ch );

  Add after:
    send_mip_sound( ch, "lock.wav" );

  Find in do_unlock:
    if ( !IS_SET(pexit->exit_info, EX_SECRET)
    ||   (pexit->keyword && nifty_is_name( arg, pexit->keyword )) )
    {
      send_to_char( "*Click*\n\r", ch );

  Add after:
    send_mip_sound( ch, "lock.wav" );
    
ACT_INFO.C:
    Find:
      send_to_pager("-------------------\n\r", ch);
      send_to_pager("Info for immortals:\n\r", ch);
    
    Add after:
      if ( mip_enabled( victim ) )
        pager_printf( ch, "%s's client is: %s (sec_code: %s)\n\r",
          victim->name, victim->pcdata->mip_ver, victim->pcdata->sec_code );

---------IF YOU ARE USING COPYOVER, THE FOLLOWING CODE MUST BE IMPLEMENTED---------
I am using the hotboot code included in the bug-fixed distribution of SMAUG 1.4a.
I assume that this code is similar to the stand-alone copyover snippet, but I have
not looked into it. This code works with the hotboot that I use, though, so here
it is. :)

COMM.C:
  Find in do_hotboot:
    fprintf( fp, "%d %d %d %d %d %s %s\n",
	     d->descriptor,
#ifdef MCCP
	     d->can_compress,
#else
 	     0,
#endif
	     och->in_room->vnum, d->port, d->idle, och->name, d->host );             

  And replace with:
    fprintf( fp, "%d %d %d %d %d %s %s %s %s\n",
	     d->descriptor,
#ifdef MCCP
	     d->can_compress,
#else
 	     0,
#endif
	     och->in_room->vnum, d->port, d->idle, och->name, d->host,
             ( mip_enabled( och ) ) ? och->pcdata->mip_ver : "-1",
	     ( mip_enabled( och ) ) ? och->pcdata->sec_code : "-1" );

  Find in hotboot_recover:
    DESCRIPTOR_DATA *d = NULL;
    FILE *fp;
    char name[100];

  Add after:
    char mip_ver[10];
    char sec_code[10];

  Find in hotboot_recover:
    fscanf( fp, "%d %d %d %d %d %s %s\n", &desc, &dcompress, &room, &dport, &idle, name, host );
  
  Replace with:
    fscanf( fp, "%d %d %d %d %d %s %s %s %s\n",
      &desc, &dcompress, &room, &dport, &idle, name, host, mip_ver, sec_code );

  Find in hotboot_recover:
    /* Insert in the char_list */
    add_char( d->character );

  Add after:
    if ( str_cmp( mip_ver, "-1" ) )
      d->character->pcdata->mip_ver = STRALLOC( mip_ver );
    else
      d->character->pcdata->mip_ver = STRALLOC( "" );
    if ( str_cmp( sec_code, "-1" ) )
    {
      d->character->pcdata->sec_code = STRALLOC( sec_code );
      xSET_BIT( d->character->act, PLR_MIP );
    }
    else
    {
      d->character->pcdata->sec_code = STRALLOC( "" );
      xREMOVE_BIT( d->character->act, PLR_MIP );
    }    

2) Copy the included mip.c to your src directory.

3) Open up your Makefile and add mip.c to your C_FILES.

4) Make clean & compile. 

5) Reboot your mud.

6) Make sure that your MIP activation trigger is in place (see below).

By default, Portal is set to use "elcome" as a trigger to start the MIP
support. As soon as the mud sends the "Welcome to <your mud name>" string,
Portal will attempt to communicate with the mud, and the mud will assign
the player a security code and document the version of their client.

However, this has a down side. If your mud displays the text "elcome"
anywhere before the player has been put into the actual game (MOTD,
Greeting, etc), the support will not be activate unless the player 
jumpstarts the client (CTRL-J). I am in the process of finding a better
way to handle this so that I can get around it, but I have not found
a way as of yet.

7) Type the following commands:
   
    cedit 3klient create
    cedit 3klient level 1
    cedit 3klient position 0
    cedit 3klient code do_mip_start
    cedit save cmdtable

8) Enjoy! And don't forget to send me an email letting me know you're using
   this snippet. Include your mud name and address if possible! Thanks!

ADDITIONAL NOTES:
1) The help file included MUST be added to your mud. I spent quite a bit of
   time working on this to make it available and hopefully bug-free, and I
   would like to receive some kind of credit.

2) In the code above, four MIP features have been included for testing
   purposes. Upon activation, the masks for the status bar will be set.
   Also, the point information (hit points, mana, movement) will be sent
   to the client, as well as combat information when fighting. Finally,
   as a sound test, when a door is locked or unlocked, a sound will be
   triggered (a default .wav included in the Portal distribution).

3) Don't forget to replace the "http://www.your-site.com/mip/" in mud.h with
   the location of the media files on your mud's web server. BE SURE TO INCLUDE
   THE "HTTP://" AS WELL AS THE FINAL FORWARD SLASH.

4) Portal stores all media files in the same directory, regardless of the mud
   on which they are used. Therefore, it is good practice to add a prefix to
   the name of your media files so that the correct media files are triggered.
   (For example: "welcome.wav" would be named "PoQ_welcome.wav" for my mud)

Archive contents (3 files)

FileSize
install.txt14.7 KB
mip.c12.2 KB
mip.hlp817 B

Site Stats

Snippets: 1791
Codebases: 571