/*****************************************************************************
 *  The Elder Chronicles by Orion Elder.                                     *
 *                                                                           *
 *  Updates to this snippet can be found at the SSWRA:                       *
 *  http://www.geocities.com/knytehawk/smaug/index.html                      *
 *                                                                           *
 *  Please send all bug reports, suggestions, or ideas to:                   *
 *  orion_elder@charter.net                                                  *
 *                                                                           *
 *  NOTE: If you downloaded this snippet from the SSWRA disregard. I will    *
 *        under no circumstances support versions of this snippet gleaned    *
 *        from other sources. If you're having problems download a fresh     *
 *        copy from the SSWRA and re-install.                                *
 *                                                                           *
 * If you're having problems with your copy of this snippet, please check to *
 * ensure that no updates have been posted before seeking help.              *
 *                                                                           *
 * Copyright 2001-2009 by Orion Elder                                        *
 *****************************************************************************/

NOTE: To use this snippet, you will need the strlen_color snippet installed. You
may find copies from various places. Try checking the links on my page if you do
not already have this snippet.

[ mud.h ]

Find:

typedef struct  lang_data		LANG_DATA;

Below that add:

typedef struct  news_data		NEWS_DATA;


Find:

/*
 * A SMAUG spell
 */
struct  smaug_affect
{
    SMAUG_AFF *		next;
    char *		duration;
    sh_int		location;
    char *		modifier;
    int			bitvector;      /* this is the bit number */
};

Below that add:

/*
 * News structure -Orion Elder
 */
struct  news_data
{
    NEWS_DATA *		next;		/* Linked list iterator */
    NEWS_DATA *		prev;		/* Linked list iterator */
    int			day;		/* Contains the day for the news */
    int			month;		/* Contains the month for the news */
    int			year;		/* Contains the year for the news */
    char *		news_data;	/* Contains the news itself */
    time_t		time_stamp;	/* Contains the time stamp of the news */
};


Find:

extern		AREA_DATA	  *	first_area_name; /*alphanum. sort*/
extern		AREA_DATA	  *	last_area_name;  /* Fireblade */

Below it add:

extern		NEWS_DATA	  *	first_news;	/* Linked List Top -Orion Elder */
extern		NEWS_DATA	  *	last_news;	/* Linked List Bottom -Orion Elder */

Find:

    sh_int	colorize	[AT_MAXCOLOR];

Below it add:

    long int		last_read_news; /* Timestamp of last news read */

Find:

#define CORPSE_DIR      "../corpses/"   /* Corpses                      */

Below it add:

#define NEWS_DIR        "../news/"      /*  News files                  */
#define HTML_NEWS_DIR   "../news/"      /*  HTML News files             */


[ act_info.c ]

Find and remove:

void do_news( CHAR_DATA *ch, char *argument )
{
    set_pager_color( AT_NOTE, ch );
    do_help( ch, "news" );
}


[ db.c ]

Find:

NOTE_DATA *read_log  args( ( FILE *fp ) );

Below it add:

void	load_news	args( ( void ) );


Find:

    first_ban = NULL;
    last_ban = NULL;

Below it add:

    first_news = NULL;
    last_news = NULL;


Find:

	log_string ("Loading Colors");
	load_colors( );

Below it add:

	log_string ("Loading News");
	load_news( );

[save.c]

Find (in fwrite_char):

        for (sn = 0; sn < AT_MAXCOLOR; ++sn)
          if (ch->pcdata->colorize[sn] != -1)
            fprintf( fp, "Color        %s %d\n", at_color_table[sn].name,
                        ch->pcdata->colorize[sn] );

Below it add:

	fprintf( fp, "LastNews     %ld\n",      ch->pcdata->last_read_news      );

Find (in fread_char):

        case 'L':
            KEY( "Level",       ch->level,              fread_number( fp ) );

Above the 'KEY( "Level",' call add:

	    KEY( "LastNews",    ch->pcdata->last_read_news,     fread_number( fp ) );


Once you've done this, inside the dist directory make a directory called news.
All new news will be placed in this directory.

Afterwards, upload news.h and news.c to your src directory, and add the
appropriate calls to the Makefile, and then make. After a copyover the
new news system should be in place.

Once that's completed, add the contents of news.help to a news entry for the help
phrase 'news.'

NOTE: If you used the previous version of this snippet, you will need to
remove the news.dat file from that system. It will not load, under this
version. You have two options with it, if you want to keep the news. You can
manually edit the file (a lot of trouble), or you can copy the news and re-add
it (a lot easier). If you want to simply remove it, it is located in the
system directory (Version 2-) under the name news.dat.

Use information:

To see the version of this snippet:
    "news version"

To simply check news type:
    "news"                (Shows all news not viewed by player, or the last
                           news in the news data file)
    "news all"            (Shows all news from beginning to end)
    "news first [amount]" (amount can be any number... this starts with the
                           first news item and lists the amount, which is by
                           default one)
    "news last [amount]"  (amount can be any number... this starts with the
                           last news item and lists the amount, which is by
                           default one)

To add news type:
    "news add <news>"

To list news by number:
    "news list"

To remove news:
    "news remove <number>"

To change the display colors of the news, simply open up news.h and change the
AT_<type> definitions. The definitions are in color code format, so all you
have to do is change the last color code in each definition to whatever you
want (I use the multiple color code format, simply because it ensure that the
colors don't mess up on some of the weaker clients).

To change the display colors for the HTML output page, simply look for the
calls to HTML_BALL or the like. Those are used with HTML_<color>, to input the
proper hex colors for the HTML. You can tweak those, but it's not recommended.
Right now the HTML output page does not support colors in the news. I will add
this in the next version.

NOTE: Added news can be up to 254 characters in length, any more won't work.
This is a part of stock SMAUG. If you wish to change that, do the below. I use
this format and have had NO problems from this.

[ comm.c ]

Find:

    for ( i = 0, k = 0; d->inbuf[i] != '\n' && d->inbuf[i] != '\r'; i++ )
    {
	if ( k >= 254 )
	{
	    write_to_descriptor( d->descriptor, "Line too long.\n\r", 0 );

Change:

	if ( k >= 254 )

To:

	if ( k >= MAX_INBUF_SIZE )

If that causes any weird problems, simply change it back to the old system,
and live with the 254 character limit. ;)

Enjoy. :)