Installation for Smaug
----------------------
1. In your Makefile, someplace above the main list of C_FLAGS,
   include the following:
#IMC2 - Comment out to disable IMC2 support
IMC = 1
   Then directly below the list of H_FILES, add the following:
   [Note: BSD users - put a period in front of the word ifdef, and in front of the word endif]
ifdef IMC
   C_FILES := imc.c sha256.c $(C_FILES)
   O_FILES := imc.o sha256.o $(O_FILES)
   C_FLAGS := $(C_FLAGS) -DIMC -DIMCSMAUG
endif
2. Open mud.h
   Locate the following:
/*
 * Structure for extended bitvectors -- Thoric
 */
struct extended_bitvector
{
    unsigned int		bits[XBI];
};
   Directly below that, add the following:
#ifdef IMC
   #include "imc.h"
#endif
   Locate your pc_data struct, which should be in one of your main *.h files.
   Add the following to the end of it:
#ifdef IMC
    IMC_CHARDATA *imcchardata;
#endif
3. Open interp.c and locate the following section:
if ( !check_social( ch, command, argument )
   Add the following condition to whatever series of ifchecks exist there:
#ifdef IMC
	&&   !imc_command_hook( ch, command, argument )
#endif
4. Open comm.c and locate the following in main() :
   If your mud uses copyover, at the top of main(), below:
   struct timeval now_time;
   char hostn[128];
   bool fCopyOver = !TRUE;
   Add:
#ifdef IMC
   int imcsocket = -1;
#endif
   A. If your mud uses copyover/hotboot, find this section( it may not look EXACTLY like this, adjust as needed ):
	If your mud does NOT use copyover/hotboot, move to B.
      if( argv[2] && argv[2][0] )
      {
         fCopyOver = TRUE;
         control = atoi( argv[3] );
      }
      else
         fCopyOver = FALSE;
   Change it to read as( while adjusting as needed ):
      if( argv[2] && argv[2][0] )
      {
         fCopyOver = TRUE;
         control = atoi( argv[3] );
#ifdef IMC
	   imcsocket = atoi( argv[4] );
#endif
      }
      else
         fCopyOver = FALSE;
   This next part is somewhat tricky. If copyover_recover is called in db.c as is the usual case in
   most default installs, you need to place the following BEFORE the boot_db call. If it is listed
   somewhere here in comm.c, the following needs to be placed ABOVE it. Either way, imc_startup needs
   to be called BEFORE copyover_recover or your mud WILL crash every time you do a copyover.
#ifdef IMC
   /* Initialize and connect to IMC2 */
   imc_startup( FALSE, imcsocket, fCopyOver );
#endif
   B. If your mud is NOT using copyover/hotboot:
      Locate the following:
    /* I don't know how well this will work on an unnamed machine as I don't
       have one handy, and the man pages are ever-so-helpful.. -- Alty */
    if (gethostname(hostn, sizeof(hostn)) < 0)
    {
      perror("main: gethostname");
      strcpy(hostn, "unresolved");
    }
    sprintf( log_buf, "%s ready at address %s on port %d.",	sysdata.mud_name, hostn, port );
    log_string( log_buf );
   Add the following lines directly below that:
#ifdef IMC
   imc_startup( FALSE, -1, FALSE );
#endif
   C. ALL MUDS CONTINUE HERE:
   Then further down in main(), locate the following:
    closesocket( control  );
    closesocket( control2 );
    closesocket( conclient);
    closesocket( conjava  );
   Add the following beneath that:
#ifdef IMC
   imc_shutdown( FALSE );
#endif
   Then in game_loop(), locate the following:
	/*
	 * Autonomous game motion.
	 */
	update_handler( );
   Directly ABOVE that, add the following:
#ifdef IMC
	imc_loop();
#endif
5. Open save.c and locate fread_char:
   In the case 'I': section, and right before the final break; add the follwing:
#ifdef IMC
           if( ( fMatch = imc_loadchar( ch, fp, word ) ) )
                break;
#endif
   Then in fwrite_char, locate:
    fprintf( fp, "End\n\n" );
   Directly ABOVE that, add:
#ifdef IMC
    imc_savechar( ch, fp );
#endif
   Then in load_char_obj(), locate the following:
    found = FALSE;
    sprintf( strsave, "%s%c/%s", PLAYER_DIR, tolower(name[0]), capitalize( name ) );
   Directly ABOVE that, add the following:
#ifdef IMC
    imc_initchar( ch );
#endif
6. Open db.c
   Locate free_char:
   Below this block of code:
	if ( ch->pcdata->subprompt )
	   STRFREE( ch->pcdata->subprompt );
	if(ch->pcdata->tell_history)
	{
		int i;
		for(i = 0; i< 26; i++)
		{
			if(ch->pcdata->tell_history[i])
				STRFREE(ch->pcdata->tell_history[i]);
		}
		DISPOSE(ch->pcdata->tell_history);
	}
   Add:
#ifdef IMC
	imc_freechardata( ch );
#endif
7. For users of copyover/hotboot ONLY:
   Locate do_copyover.
   In the variable declarations, add another bufX[100], where X is the next number in line.
   Then just before the buffers for the execl call are
   allocated, add the following:
#ifdef IMC
   imc_hotboot();
#endif
   Then right before the execl call, add the following, where X is the same number in the
   new declaration you just made:
#ifdef IMC
   if( this_imcmud )
      snprintf( bufX, 100, "%d", this_imcmud->desc );
   else
      strncpy( bufX, "-1", 100 );
#else
   strncpy( bufX, "-1", 100 );
#endif
   Then you need to add your new buffer to the execl call. So if you have this:
    execl( EXE_FILE, "smaug", buf, "hotboot",  buf2, buf3, (char *)NULL );
   It needs to become:
    execl( EXE_FILE, "smaug", buf, "hotboot",  buf2, buf3, bufX, (char *)NULL );
   Again being sure to change "X" to the right number.
   Keep in mind copyover implementations vary widely among muds and you may need to
   make some additional adjustments.
7b: For users of SWR derivatives:
In your imccfg.h file, replace the CH_LEVEL line with the following:
#define CH_IMCLEVEL(ch)          ((ch)->top_level)
7c: For users of CalareyMUD 2.0 and 3.0:
In your imccgh.h file, REMOVE the CH_IMCLEVEL macro.
In imc.c, find the imc_adjust_perms function.
Replace it with this one:
void imc_adjust_perms( CHAR_DATA *ch )
{
   if( !this_imcmud )
	return;
   /* Ugly hack to let the permission system adapt freely, but retains the ability to override that adaptation
    * in the event you need to restrict someone to a lower level, or grant someone a higher level. This of
    * course comes at the cost of forgetting you may have done so and caused the override flag to be set, but hey.
    * This isn't a perfect system and never will be. Samson 2-8-04.
    */
   if( !IMCIS_SET( IMCFLAG(ch), IMC_PERMOVERRIDE ) )
   {
      /* This will default to MORT only - you will need to override this with "none" to
       * keep people you don't want using it off.
       */
      if( ch->pcdata->permissions == 0 )
	   IMCPERM(ch) = IMCPERM_MORT;
      else if( IS_SET( ch->pcdata->permissions, PERMIT_BUILD ) )
	   IMCPERM(ch) = IMCPERM_IMM;
      else if( IS_SET( ch->pcdata->permissions, PERMIT_ADMIN ) )
	   IMCPERM(ch) = IMCPERM_ADMIN;
      else if( IS_SET( ch->pcdata->permissions, PERMIT_SECURITY ) )
	   IMCPERM(ch) = IMCPERM_IMP;
   }
   return;
}
Return to the main IMC.txt file and continue where you left off.