/*************************************************************************** * Original Diku Mud copyright (C) 1990, 1991 by Sebastian Hammer, * * Michael Seifert, Hans Henrik St{rfeldt, Tom Madsen, and Katja Nyboe. * * * * Merc Diku Mud improvments copyright (C) 1992, 1993 by Michael * * Chastain, Michael Quan, and Mitchell Tse. * * * * In order to use any part of this Merc Diku Mud, you must comply with * * both the original Diku license in 'license.doc' as well the Merc * * license in 'license.txt'. In particular, you may not remove either of * * these copyright notices. * * * * Much time and thought has gone into this software and you are * * benefitting. We hope that you share your changes too. What goes * * around, comes around. * ***************************************************************************/ /*************************************************************************** * ROM 2.4 is copyright 1993-1998 Russ Taylor * * ROM has been brought to you by the ROM consortium * * Russ Taylor (rtaylor@hypercube.org) * * Gabrielle Taylor (gtaylor@hypercube.org) * * Brian Moore (zump@rom.org) * * By using this code, you have agreed to follow the terms of the * * ROM license, in the file Rom24/doc/rom.license * ***************************************************************************/ #if defined(macintosh) #include <types.h> #else #include <sys/types.h> #include <sys/time.h> #endif #include <ctype.h> #include <stdio.h> #include <string.h> #include <stdlib.h> #include <time.h> #include "merc.h" #include "recycle.h" #include "tables.h" /* globals from db.c for load_notes */ #if !defined(macintosh) extern int _filbuf args( (FILE *) ); #endif extern FILE * fpArea; extern char strArea[MAX_INPUT_LENGTH]; /* local procedures */ void load_thread(char *name, NOTE_DATA **list, int type, time_t free_time); void parse_note(CHAR_DATA *ch, char *argument, int type); bool hide_note(CHAR_DATA *ch, NOTE_DATA *pnote); NOTE_DATA *note_list; NOTE_DATA *idea_list; NOTE_DATA *penalty_list; NOTE_DATA *news_list; NOTE_DATA *changes_list; NOTE_DATA *rnote_list; /* 1116 */ int count_spool(CHAR_DATA *ch, NOTE_DATA *spool) { int count = 0; NOTE_DATA *pnote; if(spool == NULL) return count; for (pnote = spool; pnote != NULL; pnote = pnote->next) if (!hide_note(ch,pnote)) count++; return count; } void do_unread(CHAR_DATA *ch,char *argument) { char buf[MAX_STRING_LENGTH]; int count; bool found = FALSE; if (IS_NPC(ch)) return; if ((count = count_spool(ch,news_list)) > 0) { found = TRUE; sprintf(buf,"{GThere %s {W%d {Gnew news article%s waiting.{x\n\r", count > 1 ? "are" : "is",count, count > 1 ? "s" : ""); send_to_char(buf,ch); } if ((count = count_spool(ch,changes_list)) > 0) { found = TRUE; sprintf(buf,"{GThere %s {W%d {Gchange%s waiting to be read.{x\n\r", count > 1 ? "are" : "is", count, count > 1 ? "s" : ""); send_to_char(buf,ch); } if ((count = count_spool(ch,note_list)) > 0) { found = TRUE; sprintf(buf,"{GYou have {W%d {Gnew note%s waiting.{x\n\r", count, count > 1 ? "s" : ""); send_to_char(buf,ch); } if ((count = count_spool(ch,idea_list)) > 0) { found = TRUE; sprintf(buf,"{GYou have {W%d {Gunread idea%s to peruse.{x\n\r", count, count > 1 ? "s" : ""); send_to_char(buf,ch); } /* 1116 */ if ((count = count_spool(ch,rnote_list)) > 0) { found = TRUE; sprintf(buf,"{GYou have {W%d {Gunread roleplay note%s to peruse.{x\n\r", count, count > 1 ? "s" : ""); send_to_char(buf,ch); } /* end 1116 */ if (IS_TRUSTED(ch,ANGEL) && (count = count_spool(ch,penalty_list)) > 0) { found = TRUE; sprintf(buf,"{W%d {G%s been added.{x\n\r", count, count > 1 ? "penalties have" : "penalty has"); send_to_char(buf,ch); } if (!found) send_to_char("{GYou have no unread notes.{x\n\r",ch); } void do_note(CHAR_DATA *ch,char *argument) { parse_note(ch,argument,NOTE_NOTE); } void do_rnote(CHAR_DATA *ch,char *argument) /* 1116 */ { /* 1116 */ parse_note(ch,argument,NOTE_RNOTE); /* 1116 */ } /* 1116 */ void do_idea(CHAR_DATA *ch,char *argument) { parse_note(ch,argument,NOTE_IDEA); } void do_penalty(CHAR_DATA *ch,char *argument) { parse_note(ch,argument,NOTE_PENALTY); } void do_news(CHAR_DATA *ch,char *argument) { parse_note(ch,argument,NOTE_NEWS); } void do_changes(CHAR_DATA *ch,char *argument) { parse_note(ch,argument,NOTE_CHANGES); } void save_notes(int type) { FILE *fp; char *name; NOTE_DATA *pnote; switch (type) { default: return; case NOTE_NOTE: name = NOTE_FILE; pnote = note_list; break; case NOTE_IDEA: name = IDEA_FILE; pnote = idea_list; break; case NOTE_PENALTY: name = PENALTY_FILE; pnote = penalty_list; break; case NOTE_NEWS: name = NEWS_FILE; pnote = news_list; break; case NOTE_CHANGES: name = CHANGES_FILE; pnote = changes_list; break; /* 1116 */ case NOTE_RNOTE: name = RNOTE_FILE; pnote = rnote_list; break; } fclose( fpReserve ); if ( ( fp = fopen( name, "w" ) ) == NULL ) { perror( name ); } else { for ( ; pnote != NULL; pnote = pnote->next ) { fprintf( fp, "Sender %s~\n", pnote->sender); fprintf( fp, "Date %s~\n", pnote->date); fprintf( fp, "Stamp %ld\n", pnote->date_stamp); fprintf( fp, "To %s~\n", pnote->to_list); fprintf( fp, "Subject %s~\n", pnote->subject); fprintf( fp, "Text\n%s~\n", pnote->text); } fclose( fp ); fpReserve = fopen( NULL_FILE, "r" ); return; } } void load_notes(void) { note_list = NULL; idea_list = NULL; penalty_list = NULL; news_list = NULL; changes_list = NULL; rnote_list = NULL; load_thread(NOTE_FILE,¬e_list, NOTE_NOTE, 28*24*60*60); /*14*24*60*60*/ load_thread(IDEA_FILE,&idea_list, NOTE_IDEA, 28*24*60*60); load_thread(PENALTY_FILE,&penalty_list, NOTE_PENALTY, 0); load_thread(NEWS_FILE,&news_list, NOTE_NEWS, 0); load_thread(CHANGES_FILE,&changes_list,NOTE_CHANGES, 0); load_thread(RNOTE_FILE,&rnote_list,NOTE_RNOTE, 0); /* 1116 */ } void load_thread(char *name, NOTE_DATA **list, int type, time_t free_time) { FILE *fp; NOTE_DATA *pnotelast; if ( ( fp = fopen( name, "r" ) ) == NULL ) return; pnotelast = NULL; for ( ; ; ) { NOTE_DATA *pnote; char letter; do { letter = getc( fp ); if ( feof(fp) ) { fclose( fp ); return; } } while ( isspace(letter) ); ungetc( letter, fp ); pnote = alloc_perm( sizeof(*pnote) ); if ( str_cmp( fread_word( fp ), "sender" ) ) break; pnote->sender = fread_string( fp ); if ( str_cmp( fread_word( fp ), "date" ) ) break; pnote->date = fread_string( fp ); if ( str_cmp( fread_word( fp ), "stamp" ) ) break; pnote->date_stamp = fread_number(fp); if ( str_cmp( fread_word( fp ), "to" ) ) break; pnote->to_list = fread_string( fp ); if ( str_cmp( fread_word( fp ), "subject" ) ) break; pnote->subject = fread_string( fp ); if ( str_cmp( fread_word( fp ), "text" ) ) break; pnote->text = fread_string( fp ); if (free_time && pnote->date_stamp < current_time - free_time) { free_note(pnote); continue; } pnote->type = type; if (*list == NULL) *list = pnote; else pnotelast->next = pnote; pnotelast = pnote; } strcpy( strArea, NOTE_FILE ); fpArea = fp; bug( "Load_notes: bad key word.", 0 ); exit( 1 ); return; } void append_note(NOTE_DATA *pnote) { FILE *fp; char *name; NOTE_DATA **list; NOTE_DATA *last; switch(pnote->type) { default: return; case NOTE_NOTE: name = NOTE_FILE; list = ¬e_list; break; case NOTE_IDEA: name = IDEA_FILE; list = &idea_list; break; case NOTE_PENALTY: name = PENALTY_FILE; list = &penalty_list; break; case NOTE_NEWS: name = NEWS_FILE; list = &news_list; break; case NOTE_CHANGES: name = CHANGES_FILE; list = &changes_list; break; /* 1116 */ case NOTE_RNOTE: name = RNOTE_FILE; list = &rnote_list; break; } if (*list == NULL) *list = pnote; else { for ( last = *list; last->next != NULL; last = last->next); last->next = pnote; } fclose(fpReserve); if ( ( fp = fopen(name, "a" ) ) == NULL ) { perror(name); } else { fprintf( fp, "Sender %s~\n", pnote->sender); fprintf( fp, "Date %s~\n", pnote->date); fprintf( fp, "Stamp %ld\n", pnote->date_stamp); fprintf( fp, "To %s~\n", pnote->to_list); fprintf( fp, "Subject %s~\n", pnote->subject); fprintf( fp, "Text\n%s~\n", pnote->text); fclose( fp ); } fpReserve = fopen( NULL_FILE, "r" ); } bool is_note_to( CHAR_DATA *ch, NOTE_DATA *pnote ) { if ( !str_cmp( ch->name, pnote->sender ) ) return TRUE; if ( is_exact_name( "all", pnote->to_list ) ) return TRUE; if (( IS_IMMORTAL(ch) && is_exact_name( "immortal", pnote->to_list ) ) || ( IS_IMMORTAL(ch) && is_exact_name( "imm", pnote->to_list ) ) || ( IS_IMMORTAL(ch) && is_exact_name( "immortals", pnote->to_list ) ) || ( IS_IMMORTAL(ch) && is_exact_name( "imms", pnote->to_list ) ) ) return TRUE; if (( IS_GOD(ch) && is_exact_name( "gods", pnote->to_list ) ) || ( IS_GOD(ch) && is_exact_name( "god", pnote->to_list ) ) ) return TRUE; if (( IS_HERO(ch) && is_exact_name( "heroes", pnote->to_list ) ) || ( IS_HERO(ch) && is_exact_name( "hero", pnote->to_list ) ) || ( IS_HERO(ch) && is_exact_name( "legend", pnote->to_list ) ) || ( IS_HERO(ch) && is_exact_name( "legends", pnote->to_list ) ) ) return TRUE; if ( IS_IMP(ch)) return TRUE; if (ch->clan && is_exact_name(clan_table[ch->clan].name,pnote->to_list)) return TRUE; if (is_exact_name( ch->name, pnote->to_list ) ) return TRUE; return FALSE; } void note_attach( CHAR_DATA *ch, int type ) { NOTE_DATA *pnote; if ( ch->pnote != NULL ) return; pnote = new_note(); pnote->next = NULL; pnote->sender = str_dup( ch->name ); pnote->date = str_dup( "" ); pnote->to_list = str_dup( "" ); pnote->subject = str_dup( "" ); pnote->text = str_dup( "" ); pnote->type = type; ch->pnote = pnote; return; } void note_remove( CHAR_DATA *ch, NOTE_DATA *pnote, bool delete) { char to_new[MAX_INPUT_LENGTH]; char to_one[MAX_INPUT_LENGTH]; NOTE_DATA *prev; NOTE_DATA **list; char *to_list; if (!delete) { /* make a new list */ to_new[0] = '\0'; to_list = pnote->to_list; while ( *to_list != '\0' ) { to_list = one_argument( to_list, to_one ); if ( to_one[0] != '\0' && str_cmp( ch->name, to_one ) ) { strcat( to_new, " " ); strcat( to_new, to_one ); } } /* Just a simple recipient removal? */ if ( str_cmp( ch->name, pnote->sender ) && to_new[0] != '\0' ) { free_string( pnote->to_list ); pnote->to_list = str_dup( to_new + 1 ); return; } } /* nuke the whole note */ switch(pnote->type) { default: return; case NOTE_NOTE: list = ¬e_list; break; case NOTE_IDEA: list = &idea_list; break; case NOTE_PENALTY: list = &penalty_list; break; case NOTE_NEWS: list = &news_list; break; case NOTE_CHANGES: list = &changes_list; break; /* 1116 */ case NOTE_RNOTE: list = &rnote_list; break; } /* * Remove note from linked list. */ if ( pnote == *list ) { *list = pnote->next; } else { for ( prev = *list; prev != NULL; prev = prev->next ) { if ( prev->next == pnote ) break; } if ( prev == NULL ) { bug( "Note_remove: pnote not found.", 0 ); return; } prev->next = pnote->next; } save_notes(pnote->type); free_note(pnote); return; } bool hide_note (CHAR_DATA *ch, NOTE_DATA *pnote) { time_t last_read; if (IS_NPC(ch)) return TRUE; switch (pnote->type) { default: return TRUE; case NOTE_NOTE: last_read = ch->pcdata->last_note; break; case NOTE_IDEA: last_read = ch->pcdata->last_idea; break; case NOTE_PENALTY: last_read = ch->pcdata->last_penalty; break; case NOTE_NEWS: last_read = ch->pcdata->last_news; break; case NOTE_CHANGES: last_read = ch->pcdata->last_changes; break; /* 1116 */ case NOTE_RNOTE: last_read = ch->pcdata->last_rnote; break; } if (pnote->date_stamp <= last_read) return TRUE; if (!str_cmp(ch->name,pnote->sender)) return TRUE; if (!is_note_to(ch,pnote)) return TRUE; return FALSE; } void update_read(CHAR_DATA *ch, NOTE_DATA *pnote) { time_t stamp; if (IS_NPC(ch)) return; stamp = pnote->date_stamp; switch (pnote->type) { default: return; case NOTE_NOTE: ch->pcdata->last_note = UMAX(ch->pcdata->last_note,stamp); break; case NOTE_IDEA: ch->pcdata->last_idea = UMAX(ch->pcdata->last_idea,stamp); break; case NOTE_PENALTY: ch->pcdata->last_penalty = UMAX(ch->pcdata->last_penalty,stamp); break; case NOTE_NEWS: ch->pcdata->last_news = UMAX(ch->pcdata->last_news,stamp); break; case NOTE_CHANGES: ch->pcdata->last_changes = UMAX(ch->pcdata->last_changes,stamp); break; /* 1116 */ case NOTE_RNOTE: ch->pcdata->last_rnote = UMAX(ch->pcdata->last_rnote,stamp); break; } } void parse_note( CHAR_DATA *ch, char *argument, int type ) { BUFFER *buffer; char buf[MAX_STRING_LENGTH]; char arg[MAX_INPUT_LENGTH]; char arg2[MAX_INPUT_LENGTH]; NOTE_DATA *pnote; NOTE_DATA **list; char *list_name; long vnum; long anum; DESCRIPTOR_DATA *d; if ( IS_NPC(ch) ) return; switch(type) { default: return; case NOTE_NOTE: list = ¬e_list; list_name = "notes"; break; case NOTE_IDEA: list = &idea_list; list_name = "ideas"; break; case NOTE_PENALTY: list = &penalty_list; list_name = "penalties"; break; case NOTE_NEWS: list = &news_list; list_name = "news"; break; case NOTE_CHANGES: list = &changes_list; list_name = "changes"; break; /* 1116 */ case NOTE_RNOTE: list = &rnote_list; list_name = "roleplay_notes"; break; } argument = one_argument( argument, arg ); smash_tilde( argument ); if ( arg[0] == '\0' || !str_prefix( arg, "read" ) ) { bool fAll; if ( !str_cmp( argument, "all" ) ) { fAll = TRUE; anum = 0; } else if ( argument[0] == '\0' || !str_prefix(argument, "next")) /* read next unread note */ { vnum = 0; for ( pnote = *list; pnote != NULL; pnote = pnote->next) { if (!hide_note(ch,pnote)) { sprintf( buf, "{M[{G%3ld{M] {W%s{G: %s{x\n\r{m%s\n\r{GTo: {W%s{x\n\r", vnum, pnote->sender, pnote->subject, pnote->date, pnote->to_list); send_to_char( buf, ch ); page_to_char( pnote->text, ch ); update_read(ch,pnote); return; } else if (is_note_to(ch,pnote)) vnum++; } sprintf(buf,"{YYou have no unread %s.{x\n\r",list_name); send_to_char(buf,ch); return; } else if ( is_number( argument ) ) { fAll = FALSE; anum = atoi( argument ); } else { send_to_char( "{RRead which number?{x\n\r", ch ); return; } vnum = 0; for ( pnote = *list; pnote != NULL; pnote = pnote->next ) { if ( is_note_to( ch, pnote ) && ( vnum++ == anum || fAll ) ) { sprintf( buf, "{M[{G%3ld{M] {W%s{G: %s{x\n\r%s\n\r{GTo: {W%s{x\n\r", vnum - 1, pnote->sender, pnote->subject, pnote->date, pnote->to_list ); send_to_char( buf, ch ); page_to_char( pnote->text, ch ); update_read(ch,pnote); return; } } sprintf(buf,"{YThere aren't that many %s.{x\n\r",list_name); send_to_char(buf,ch); return; } if ( !str_prefix( arg, "list" ) ) { vnum = 0; argument = one_argument( argument, arg2 ); for ( pnote = *list; pnote != NULL; pnote = pnote->next ) { if ( is_note_to( ch, pnote ) ) { if ((arg2[0] == '\0') || (arg2[0] != '\0' && !str_cmp( arg2, pnote->sender ) ) ) { sprintf( buf, "{M[{G%3ld{D%s{M] {W%s{G: %s{x\n\r", vnum, hide_note(ch,pnote) ? " " : "N", pnote->sender, pnote->subject ); send_to_char( buf, ch ); } vnum++; } } if (!vnum) { switch(type) { case NOTE_NOTE: send_to_char("{YThere are no notes for you.{x\n\r",ch); break; case NOTE_IDEA: send_to_char("{YThere are no ideas for you.{x\n\r",ch); break; case NOTE_PENALTY: send_to_char("{YThere are no penalties for you.{x\n\r",ch); break; case NOTE_NEWS: send_to_char("{YThere is no news for you.{x\n\r",ch); break; case NOTE_CHANGES: send_to_char("{YThere are no changes for you.{x\n\r",ch); break; /* 1116 */ case NOTE_RNOTE: send_to_char("{YThere are no roleplaying notes for you.{x\n\r",ch); break; } } return; } if ( !str_prefix( arg, "remove" ) ) { if ( !is_number( argument ) ) { send_to_char( "{RNote remove which number?{x\n\r", ch ); return; } anum = atoi( argument ); vnum = 0; for ( pnote = *list; pnote != NULL; pnote = pnote->next ) { if ( is_note_to( ch, pnote ) && vnum++ == anum ) { note_remove( ch, pnote, FALSE ); send_to_char( "{YNote removed.{x\n\r", ch ); return; } } sprintf(buf,"{YThere aren't that many %s.{x",list_name); send_to_char(buf,ch); return; } if ( !str_prefix( arg, "delete" ) && get_trust(ch) >= MAX_LEVEL - 1) { if ( !is_number( argument ) ) { send_to_char( "{RNote delete which number?{x\n\r", ch ); return; } anum = atoi( argument ); vnum = 0; for ( pnote = *list; pnote != NULL; pnote = pnote->next ) { if ( is_note_to( ch, pnote ) && vnum++ == anum ) { note_remove( ch, pnote,TRUE ); send_to_char( "{YNote deleted.{x\n\r", ch ); return; } } sprintf(buf,"{YThere aren't that many %s.{x",list_name); send_to_char(buf,ch); return; } if (!str_prefix(arg,"catchup")) { switch(type) { case NOTE_NOTE: ch->pcdata->last_note = current_time; break; case NOTE_IDEA: ch->pcdata->last_idea = current_time; break; case NOTE_PENALTY: ch->pcdata->last_penalty = current_time; break; case NOTE_NEWS: ch->pcdata->last_news = current_time; break; case NOTE_CHANGES: ch->pcdata->last_changes = current_time; break; /* 1116 */ case NOTE_RNOTE: ch->pcdata->last_rnote = current_time; break; } send_to_char("{YYou are now caught up on all your notes.{x\n\r", ch); return; } /* below this point only certain people can edit notes */ if ((type == NOTE_NEWS && !IS_TRUSTED(ch,ANGEL)) || (type == NOTE_CHANGES && !IS_TRUSTED(ch,CREATOR))) { sprintf(buf,"{RYou aren't high enough level to write %s.{x",list_name); send_to_char(buf,ch); return; } if ( !str_cmp( arg, "+" ) ) { note_attach( ch,type ); if (ch->pnote->type != type) { send_to_char( "{RYou already have a different note in progress.{Y\n\r",ch); return; } if (strlen(ch->pnote->text)+strlen(argument) >= 4096) { send_to_char( "{RNote too long.{x\n\r", ch ); return; } buffer = new_buf(); add_buf(buffer,ch->pnote->text); add_buf(buffer,argument); add_buf(buffer,"\n\r"); free_string( ch->pnote->text ); ch->pnote->text = str_dup( buf_string(buffer) ); free_buf(buffer); send_to_char( "{YLine added.{x\n\r", ch ); return; } if (!str_cmp(arg,"-")) { int len; bool found = FALSE; note_attach(ch,type); if (ch->pnote->type != type) { send_to_char( "{RYou already have a different note in progress.{x\n\r",ch); return; } if (ch->pnote->text == NULL || ch->pnote->text[0] == '\0') { send_to_char("{RNo lines left to remove.{x\n\r",ch); return; } strcpy(buf,ch->pnote->text); for (len = strlen(buf); len > 0; len--) { if (buf[len] == '\r') { if (!found) /* back it up */ { if (len > 0) len--; found = TRUE; } else /* found the second one */ { buf[len + 1] = '\0'; free_string(ch->pnote->text); ch->pnote->text = str_dup(buf); return; } } } buf[0] = '\0'; free_string(ch->pnote->text); ch->pnote->text = str_dup(buf); send_to_char("{YLine removed.{x\n\r", ch); return; } if ( !str_cmp( arg, "desc" ) || !str_cmp( arg, "write") ) { note_attach( ch, type ); if ( argument[0] == '\0' ) string_append( ch, &ch->pnote->text ); return; } if ( !str_prefix( arg, "subject" ) ) { note_attach( ch,type ); if (ch->pnote->type != type) { send_to_char( "{RYou already have a different note in progress.{x\n\r",ch); return; } free_string( ch->pnote->subject ); ch->pnote->subject = str_dup( argument ); send_to_char( "{YSubject added.{x\n\r", ch ); return; } /* 052401 Taka note forward and reply */ if ( !str_prefix( arg, "forward" ) ) { NOTE_DATA *pnote_original; /* test if is number */ if ( is_number( argument ) ) {/* is number convert */ anum = atoi( argument ); } else {/* is not then error */ send_to_char( "{RFoward which number?{x\n\r", ch ); return; } /* get old note */ vnum = 0; for ( pnote_original = *list; pnote_original != NULL; pnote_original = pnote_original->next ) { if ( is_note_to( ch, pnote_original ) && ( vnum++ == anum ) ) { /* set up forward here */ note_attach( ch,type ); /* check if already writting a note */ if (ch->pnote->type != type) { send_to_char( "{RYou already have a different note in progress.{x\n\r",ch); return; } free_string( ch->pnote->subject ); sprintf( buf, "Fwd: %s", pnote_original->subject); ch->pnote->subject = str_dup( buf ); send_to_char( "{YSubject added.{x\n\r", ch ); buffer = new_buf(); add_buf(buffer,"{GOriginally sent by: {w"); add_buf(buffer,pnote_original->sender); add_buf(buffer,"{x\n\r"); add_buf(buffer,"{GOriginally sent to: {w"); add_buf(buffer,pnote_original->to_list); add_buf(buffer,"{x\n\r"); sprintf (buf, "{wSent on {C%s{x\n\r\n\r{WText as follows->{x{c\n\r", pnote_original->date); add_buf(buffer,buf); add_buf(buffer,pnote_original->text); add_buf(buffer,"\n\r\n\r{C----------New text from forward follows here----------{G\n\r\n\r"); free_string( ch->pnote->text ); ch->pnote->text = str_dup( buf_string(buffer) ); free_buf(buffer); send_to_char( "{YForward ready please add to names, additional text and post.{x\n\r", ch ); return; } } sprintf(buf,"{YThere aren't that many %s.{x\n\r",list_name); send_to_char(buf,ch); return; } if ( !str_prefix( arg, "reply" ) ) { NOTE_DATA *pnote_original; /* test if is number */ if ( is_number( argument ) ) {/* is number convert */ anum = atoi( argument ); } else {/* is not then error */ send_to_char( "{RReply to which number?{x\n\r", ch ); return; } /* get old note */ vnum = 0; for ( pnote_original = *list; pnote_original != NULL; pnote_original = pnote_original->next ) { if ( is_note_to( ch, pnote_original ) && ( vnum++ == anum ) ) { /* set up forward here */ note_attach( ch,type ); /* check if already writting a note */ if (ch->pnote->type != type) { send_to_char( "{RYou already have a different note in progress.{x\n\r",ch); return; } free_string( ch->pnote->subject ); sprintf( buf, "Reply: %s", pnote_original->subject); ch->pnote->subject = str_dup( buf ); send_to_char( "{YSubject added.{x\n\r", ch ); buffer = new_buf(); add_buf(buffer,"{GOriginally sent by: {w"); add_buf(buffer,pnote_original->sender); add_buf(buffer,"{x\n\r"); add_buf(buffer,"{GOriginally sent to: {w"); add_buf(buffer,pnote_original->to_list); add_buf(buffer,"{x\n\r"); sprintf (buf, "{wSent on {C%s{x\n\r\n\r{WText as follows->{x{c\n\r", pnote_original->date); add_buf(buffer,buf); add_buf(buffer,pnote_original->text); add_buf(buffer,"\n\r\n\r{C----------Text for reply follows here----------{G\n\r\n\r"); free_string( ch->pnote->text ); ch->pnote->text = str_dup( buf_string(buffer) ); free_buf(buffer); send_to_char( "{YReply ready please add to names, additional text and post.{x\n\r", ch ); return; } } sprintf(buf,"{YThere aren't that many %s.{x\n\r",list_name); send_to_char(buf,ch); return; } /* end note forward and reply */ if ( !str_prefix( arg, "to" ) ) { note_attach( ch,type ); if (ch->pnote->type != type) { send_to_char( "{RYou already have a different note in progress.{x\n\r",ch); return; } free_string( ch->pnote->to_list ); ch->pnote->to_list = str_dup( argument ); send_to_char( "{YNames to added.{x\n\r", ch ); return; } if ( !str_prefix( arg, "clear" ) ) { if ( ch->pnote != NULL ) { free_note(ch->pnote); ch->pnote = NULL; } send_to_char( "{YNote cleared.{x\n\r", ch ); return; } if ( !str_prefix( arg, "show" ) ) { if ( ch->pnote == NULL ) { send_to_char( "{RYou have no note in progress.{x\n\r", ch ); return; } if (ch->pnote->type != type) { send_to_char("{RYou aren't working on that kind of note.{x\n\r",ch); return; } sprintf( buf, "{W%s{G: %s\n\rTo: {W%s{x\n\r", ch->pnote->sender, ch->pnote->subject, ch->pnote->to_list ); send_to_char( buf, ch ); send_to_char( ch->pnote->text, ch ); return; } if ( !str_prefix( arg, "post" ) || !str_prefix(arg, "send")) { char *strtime; if ( ch->pnote == NULL ) { send_to_char( "{RYou have no note in progress.{x\n\r", ch ); return; } if (ch->pnote->type != type) { send_to_char("{RYou aren't working on that kind of note.{x\n\r",ch); return; } if (!str_cmp(ch->pnote->to_list,"")) { send_to_char( "{RYou need to provide a recipient (name, all, imm or immortal).{x\n\r", ch); return; } if (!str_cmp(ch->pnote->subject,"")) { send_to_char("{RYou need to provide a subject.{x\n\r",ch); return; } for(d = descriptor_list; d != NULL; d = d->next) { if(d->connected == CON_PLAYING) { if(is_name(d->character->name, ch->pnote->to_list)) { switch(ch->pnote->type) { case 0: send_to_char("{YYou have a PRIVATE note.{x", d->character); break; case 1: send_to_char("{YThere is an idea waiting for your eyes only.{x", d->character); break; case 2: send_to_char("{YYou have a new penalty to read.{x", d->character); break; case 3: send_to_char("{YThere is a news paper at your door.{x", d->character); break; case 4: send_to_char("{YSome changes you might have interest in.{x", d->character); break; /* 1116 */ case 5: send_to_char("{YSome roleplaying you might be interested in.{x", d->character); break; default: send_to_char("{YYou have a PRIVATE new message.{x", d->character); break; } } if((is_name("all", ch->pnote->to_list) && d->character->name != ch->name) || (d->character->level >= LEVEL_IMMORTAL && is_name("imm", ch->pnote->to_list) && d->character->name != ch->name) || (d->character->level >= LEVEL_IMMORTAL && is_name("immortal", ch->pnote->to_list) && d->character->name != ch->name)) { switch(ch->pnote->type) { case 0: send_to_char("{YYou have a new note to read.{x", d->character); break; case 1: send_to_char("{YThere is an idea to read.{x", d->character); break; case 2: send_to_char("{YA new penalty awaits execution.{x", d->character); break; case 3: send_to_char("{YEXTRA EXTRA read all about it! {wGhost {Ynews.{x", d->character); break; case 4: send_to_char("{YAs the wolrd turns read our newest changes.{x", d->character); break; /* 1116 */ case 5: send_to_char("{YNew Roleplaying notes await.{x", d->character); break; default: send_to_char("{YYou have a new message.{x", d->character); break; } } } } ch->pnote->next = NULL; strtime = ctime( ¤t_time ); strtime[strlen(strtime)-1] = '\0'; ch->pnote->date = str_dup( strtime ); ch->pnote->date_stamp = current_time; append_note(ch->pnote); ch->pnote = NULL; return; } send_to_char( "{RYou can't do that.{x\n\r", ch ); return; }