/
board-1/
===========================================================================
This snippet was written by Erwin S. Andreasen, 4u2@aabc.dk. You may use
this code freely, as long as you retain my name in all of the files. You
also have to mail me telling that you are using it. I am giving this,
hopefully useful, piece of source code to you for free, and all I require
from you is some feedback.

Please mail me if you find any bugs or have any new ideas or just comments.

All my snippets are publically available at:

http://login.dknet.dk/~ea/

If you do not have WWW access, try ftp'ing to login.dknet.dk and examine
the /pub/ea directory.
===========================================================================

Note board system. If there is + before a line, it means that only that line
of code should be inserted  - the lines without + around it are just for
reference. ! denotes lines that were partially changed. This is partially
modified output of `rcsdiff -bBp *.[ch]`

Note that there are lots of my color codes here and there. The color codes
are two-character combinations, staring with a &. Just remove them or
replace with your color codes. Next version will use color names using
DEFINEs, so chaging to your color codes can be easier.

Next version will also move all the nanny cases to board.c, to make nanny()
less cluttered.

Note that the max_len of note so far is pretty small - only 3000 characters.
You can experiment increasing it. If you do, increase the buffer size in
nanny(), show_note as well as do_narchive() - these commands temporarily copy
the note's text to a file.

File list:

readme.txt	(This file) - the small changes here and there

nanny.txt	The big additions to nanny()

board.c		Main board file. Remember to include in Makefile.

board.h		Include file. Insert #include "board.h" in merc.h, at about
		line 150 (before site ban structure)

help.txt	A help entry for HELP NOTE.


act_comm.c	1996/01/01 15:02:57
===================================

do_note, is_note_to etc.: Remove them all.

Free note in progress when quitting.

*************** void do_quit( CHAR_DATA *ch, char *argum
+ 
+ 	/* Free note that might be there somehow */        
+     if (ch->pcdata->in_progress)
+     	free_note (ch->pcdata->in_progress);
          
      
      d = ch->desc;


comm.c	1996/01/01 19:18:22
===========================


Change close_socket() so notewriters are not thrown completely out.
  
*************** void close_socket( DESCRIPTOR_DATA *dclo
      {
  	sprintf( log_buf, "Closing link to %s.", ch->name );
  	log_string( log_buf );
! 
! 	/* If ch is writing note or playing, just lose link otherwise clear char */
! 	if ( (dclose->connected == CON_PLAYING) || 
! 	  ((dclose->connected >= CON_NOTE_TO) && 
! 	   (dclose->connected <= CON_NOTE_FINISH)))
  	{
  	    act( "$n has lost $s link.", ch, NULL, NULL, TO_ROOM );
  	    ch->desc = NULL;

These are just the small changes in do_nanny, the big changes are in a
seperate file.

*************** void nanny( DESCRIPTOR_DATA *d, char *ar

      CHAR_DATA *ch;
! /*    NOTE_DATA *pnote; */ /* Remove note variable */
      char *pwdnew;
      char *p;
      int iClass;
      int lines;
! /*    int notes; */ /* Remove this one too */
      bool fOld;

+ 	/* Delete leading spaces UNLESS character is writing a note */
+ 	if (d->connected != CON_NOTE_TEXT)
+ 	{
  	    while ( isspace(*argument) )
  		argument++;
+ 	}
  
      ch = d->character;


A bit further down: Completely remove the current checking for note and add
this instead. Consider swapping do_look and do_board.
  
*************** void nanny( DESCRIPTOR_DATA *d, char *ar

--- 1902,2190 ----
  	}
  
  	act( "$n has entered the game.", ch, NULL, NULL, TO_ROOM );
+ 	do_board (ch, ""); /* Show board status */
  	do_look( ch, "auto" );


Add information about note in progress if a character should lose link.
  
*************** bool check_reconnect( DESCRIPTOR_DATA *d
  		log_string( log_buf );
  		d->connected = CON_PLAYING;
  
+ 		/* Inform the character of a note in progress and the possbility of continuation! */		
+ 		if (ch->pcdata->in_progress)
+ 			send_to_char ("You have a note in progress. Type NWRITE to continue it.\n\r",ch);
+ 
  		/*
  		 * Contributed by Gene Choi
  		 */

In act(), do not send any acts to characters that are anything but playing.

*************** void act( const char *format, CHAR_DATA 

OLD:

  	*point++ = '\n';
  	*point++ = '\r';
  	buf[0]   = UPPER(buf[0]);
! 	if (to->desc)
  	  write_to_buffer( to->desc, buf, point - buf );
      }

NEW:

  	*point++ = '\n';
  	*point++ = '\r';
  	buf[0]   = UPPER(buf[0]);
! 	if (to->desc && (to->desc->connected == CON_PLAYING))
  	  write_to_buffer( to->desc, buf, point - buf );
      }


db.c	1995/12/30 21:49:16
===========================

At the top of the file: Remove note_list. Remove load_notes().

  char                    log_buf         [2*MAX_INPUT_LENGTH];
  KILL_DATA               kill_table      [MAX_LEVEL];
! /* NOTE_DATA *             note_list; */
  OBJ_DATA *              object_list;


Add loading of notes at startup

*************** void boot_db( void )
          fix_exits( );
          fBootDb = FALSE;
          area_update(TRUE);
! /*        load_notes( ); */
!  	  load_boards(); /* Load all boards */
          load_war();
          load_disabled();
      }

merc.h	1996/01/01 14:23:50
===================================

Add these defines for the new note system:

+ /* New note system */
+ #define CON_NOTE_TO						10
+ #define CON_NOTE_SUBJECT				11
+ #define CON_NOTE_EXPIRE					12
+ #define CON_NOTE_TEXT					13
+ #define CON_NOTE_FINISH					14
  

Remove pnote from char_data:

*************** struct  char_data
      MOB_INDEX_DATA *    pIndexData;
      DESCRIPTOR_DATA *   desc;
      AFFECT_DATA *       affected;
-     NOTE_DATA *         pnote;
      OBJ_DATA *          carrying;
      ROOM_INDEX_DATA *   in_room;
      ROOM_INDEX_DATA *   was_in_room;

Add these fields to pc_data:

*************** struct  pc_data
  	
+  	BOARD_DATA *			board; /* The current board */
+  	time_t				last_note[MAX_BOARD]; /* last note for the boards */
+ 	NOTE_DATA *			in_progress;



save.c	1996/01/01 14:50:32
===========================


When saving, add saving of board status.

First, add this variable:

*************** void save_char_obj( CHAR_DATA *ch )

  void fwrite_char( CHAR_DATA *ch, FILE *fp )
  {
      AFFECT_DATA *paf;
!     int sn,i;
  
      fprintf( fp, "#%s\n", IS_NPC(ch) ? "MOB" : "PLAYER"		);


Then add saving of board status:
  
*************** void fwrite_char( CHAR_DATA *ch, FILE *f
  
  	fprintf( fp, "Pagelen      %d\n",   ch->pcdata->pagelen     );
  	
+ 	/* Save note board status */
+ 	/* Save number of boards in case that number changes */
+ 	fprintf (fp, "Boards       %d ", MAX_BOARD);
+ 	for (i = 0; i < MAX_BOARD; i++)
+ 		fprintf (fp, "%s %ld ", boards[i].short_name, ch->pcdata->last_note[i]);
+ 	fprintf (fp, "\n");
+ 	
+ 		
  	for ( sn = 0; sn < MAX_SKILL; sn++ )
  	{
  	    if ( skill_table[sn].name != NULL && ch->pcdata->learned[sn] > 0 )


When laoding a character, add settig of default board.

*************** bool load_char_obj( DESCRIPTOR_DATA *d, 

      ch->act				= PLR_BLANK
  					| PLR_COMBINE
  					| PLR_PROMPT;
+ 
+ 	/* every characters starts at default board from login.. this board
+ 	   should be read_level == 0 !
+ 	*/   
+ 	ch->pcdata->board		= &boards[DEFAULT_BOARD];
+ 				
      ch->pcdata->pwd			= str_dup( "" );
      ch->pcdata->bamfin			= str_dup( "" );
      ch->pcdata->bamfout			= str_dup( "" );


Finally, loading of board data.

*************** void fread_char( CHAR_DATA *ch, FILE *fp
  	    KEY( "Bamfin",	ch->pcdata->bamfin,	fread_string( fp ) );
  	    KEY( "Bamfout",	ch->pcdata->bamfout,	fread_string( fp ) );
  	    KEY( "Battles", ch->pcdata->battles, fread_number( fp ));

+ 
+ 		/* Read in board status */	    
+ 	    if (!str_cmp(word, "Boards" ))
+ 	    {
+ 			int i,num = fread_number (fp); /* number of boards saved */
+ 			char *boardname;
+ 			
+ 			for (; num ; num-- ) /* for each of the board saved */
+ 			{
+ 				boardname = fread_word (fp);
+ 				i = board_lookup (boardname); /* find board number */
+ 				
+ 				if (i == BOARD_NOTFOUND) /* Does board still exist ? */
+ 				{
+ 					sprintf (buf, "fread_char: %s had unknown board name: %s. Skipped.", ch->name, boardname);					
+ 					log_string (buf);
+ 					fread_number (fp); /* read last_note and skip info */
+ 				}
+ 				else /* Save it */
+ 					ch->pcdata->last_note[i] = fread_number (fp);
+ 			}	 /* for */
+ 			
+ 			fMatch = TRUE;
+ 	    } /* Boards */
+ 	    
  	    break;
  
  	case 'C':