int git_note_remove(git_repository *repo, const char *notes_ref, const git_signature *author, const git_signature *committer, const git_oid *oid) { int error; char *target = NULL; git_commit *commit = NULL; git_tree *tree = NULL; target = git_oid_allocfmt(oid); GITERR_CHECK_ALLOC(target); if (!(error = retrieve_note_tree_and_commit( &tree, &commit, repo, ¬es_ref))) error = note_remove( repo, author, committer, notes_ref, tree, target, &commit); git__free(target); git_commit_free(commit); git_tree_free(tree); return error; }
/* Date stamp idea comes from Alander of ROM */ void do_note( CHAR_DATA *ch, const char *argument ) { NOTE_DATA *pnote; char buf [ MAX_STRING_LENGTH ]; char buf1 [ MAX_STRING_LENGTH*7 ]; char arg [ MAX_INPUT_LENGTH ]; int vnum; int anum; if ( IS_NPC( ch ) ) return; argument = one_argument( argument, arg ); smash_tilde( argument ); if ( arg[0] == '\0' ) { do_note( ch, "read" ); return; } if ( !str_cmp( arg, "list" ) ) { vnum = 0; buf1[0] = '\0'; for ( pnote = note_list; pnote; pnote = pnote->next ) { if ( is_note_to( ch, pnote ) ) { sprintf( buf, "[%3d%s] %s: %s\n\r", vnum, ( pnote->date_stamp > ch->last_note && str_cmp( pnote->sender, ch->name ) ) ? "N" : " ", pnote->sender, pnote->subject ); strcat( buf1, buf ); vnum++; } } send_to_char( buf1, ch ); return; } if ( !str_cmp( 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; buf1[0] = '\0'; for ( pnote = note_list; pnote; pnote = pnote->next ) { if ( is_note_to( ch, pnote ) && str_cmp( ch->name, pnote->sender ) && ch->last_note < pnote->date_stamp ) { break; } else { if ( is_note_to( ch, pnote ) ) vnum++; } } if ( pnote ) { sprintf( buf, "[%3d] %s: %s\n\r%s\n\rTo: %s\n\r", vnum, pnote->sender, pnote->subject, pnote->date, pnote->to_list ); strcat( buf1, buf ); strcat( buf1, pnote->text ); ch->last_note = UMAX( ch->last_note, pnote->date_stamp ); send_to_char( buf1, ch ); return; } send_to_char( "You have no unread notes.\n\r", ch ); return; } else if ( is_number( argument ) ) { fAll = FALSE; anum = atoi( argument ); } else { send_to_char( "Note read which number?\n\r", ch ); return; } vnum = 0; buf1[0] = '\0'; for ( pnote = note_list; pnote; pnote = pnote->next ) { if ( is_note_to( ch, pnote ) ) { if ( vnum == anum || fAll ) { sprintf( buf, "[%3d] %s: %s\n\r%s\n\rTo: %s\n\r", vnum, pnote->sender, pnote->subject, pnote->date, pnote->to_list ); strcat( buf1, buf ); strcat( buf1, pnote->text ); if ( !fAll ) send_to_char( buf1, ch ); else strcat( buf1, "\n\r" ); ch->last_note = UMAX( ch->last_note, pnote->date_stamp ); if ( !fAll ) return; } vnum++; } } if ( !fAll ) send_to_char( "No such note.\n\r", ch ); else send_to_char( buf1, ch ); return; } if ( !str_cmp( arg, "+" ) ) { note_attach( ch ); strcpy( buf, ch->pnote->text ); if ( strlen( buf ) + strlen( argument ) >= MAX_STRING_LENGTH - 200 ) { send_to_char( "Note too long.\n\r", ch ); return; } strcat( buf, argument ); strcat( buf, "\n\r" ); free_string( ch->pnote->text ); ch->pnote->text = str_dup( buf ); send_to_char( "Ok.\n\r", ch ); return; } if ( !str_cmp( arg, "subject" ) ) { note_attach( ch ); free_string( ch->pnote->subject ); ch->pnote->subject = str_dup( argument ); send_to_char( "Ok.\n\r", ch ); return; } if ( !str_cmp( arg, "to" ) ) { note_attach( ch ); free_string( ch->pnote->to_list ); ch->pnote->to_list = str_dup( argument ); send_to_char( "Ok.\n\r", ch ); return; } if ( !str_cmp( arg, "clear" ) ) { if ( ch->pnote ) { free_string( ch->pnote->text ); free_string( ch->pnote->subject ); free_string( ch->pnote->to_list ); free_string( ch->pnote->date ); free_string( ch->pnote->sender ); ch->pnote->next = note_free; note_free = ch->pnote; ch->pnote = NULL; } send_to_char( "Ok.\n\r", ch ); return; } if ( !str_cmp( arg, "show" ) ) { if ( !ch->pnote ) { send_to_char( "You have no note in progress.\n\r", ch ); return; } sprintf( buf, "%s: %s\n\rTo: %s\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_cmp( arg, "post" ) || !str_prefix( arg, "send" ) ) { FILE *fp; char *strtime; if ( !ch->pnote ) { send_to_char( "You have no note in progress.\n\r", ch ); return; } if ( !str_cmp( ch->pnote->to_list, "" ) ) { send_to_char( "You need to provide a recipient (name, all, or immortal).\n\r", ch ); return; } if ( !str_cmp( ch->pnote->subject, "" ) ) { send_to_char( "You need to provide a subject.\n\r", ch ); return; } ch->pnote->next = NULL; strtime = ctime( ¤t_time ); strtime[strlen(strtime)-1] = '\0'; free_string( ch->pnote->date ); ch->pnote->date = str_dup( strtime ); ch->pnote->date_stamp = current_time; if ( !note_list ) { note_list = ch->pnote; } else { for ( pnote = note_list; pnote->next; pnote = pnote->next ) ; pnote->next = ch->pnote; } pnote = ch->pnote; ch->pnote = NULL; fclose( fpReserve ); if ( !( fp = fopen( NOTE_FILE, "a" ) ) ) { perror( NOTE_FILE ); } else { fprintf( fp, "Sender %s~\n", pnote->sender ); fprintf( fp, "Date %s~\n", pnote->date ); fprintf( fp, "Stamp %ld\n", (unsigned long)pnote->date_stamp ); fprintf( fp, "To %s~\n", pnote->to_list ); fprintf( fp, "Subject %s~\n", pnote->subject ); fprintf( fp, "Text\n%s~\n\n", pnote->text ); fclose( fp ); } fpReserve = fopen( NULL_FILE, "r" ); send_to_char( "Ok.\n\r", ch ); return; } if ( !str_cmp( arg, "remove" ) ) { if ( !is_number( argument ) ) { send_to_char( "Note remove which number?\n\r", ch ); return; } anum = atoi( argument ); vnum = 0; for ( pnote = note_list; pnote; pnote = pnote->next ) { if ( is_note_to( ch, pnote ) && vnum++ == anum ) { note_remove( ch, pnote ); send_to_char( "Ok.\n\r", ch ); return; } } send_to_char( "No such note.\n\r", ch ); return; } send_to_char( "Huh? Type 'help note' for usage.\n\r", ch ); return; }
void do_note (CHAR_DATA * ch, char *argy) { char buf[STD_LENGTH * 17]; char buf1[STD_LENGTH * 17]; char arg[SML_LENGTH]; NOTE_DATA *pnote; int vnum; int board_here; /*Boards and board nums by Owen Emlen */ SINGLE_OBJECT *obj; int anum; DEFINE_COMMAND ("note", do_note, POSITION_DEAD, 0, LOG_NORMAL, "This command is used to post/read/remove notes.") if (IS_MOB (ch)) return; board_here = 0; obj = get_obj_here (ch, "board", SEARCH_ROOM_FIRST); if (obj == NULL) { board_here = 1; } else board_here = obj->pIndexData->value[9]; buf1[0] = '\0'; argy = one_argy (argy, arg); smash_tilde (argy); if (arg[0] == '\0') { do_note (ch, "read"); return; } if (!str_cmp (arg, "list")) { vnum = 0; sprintf(buf1,"\x1B[1;30m------------------------------------------------------------------------\x1B[37;0m\n\r"); sprintf(buf1+strlen(buf1),"\x1B[1;36m New ### Sender/From Subject\x1B[37;0m\n\r"); sprintf(buf1+strlen(buf1),"\x1B[1;30m------------------------------------------------------------------------\x1B[37;0m\n\r"); for (pnote = note_list; pnote != NULL; pnote = pnote->next) { if (is_note_to (ch, pnote) && (board_here == pnote->board_num || IS_IMMORTAL (ch))) { if (strlen(pnote->subject)>35) { pnote->subject[35]='\0'; } sprintf (buf, "%s \x1B[1;36m%3d\x1B[37;0m From \x1b[1;37m%-14s\x1B[37;0m '\x1B[1;36m%s\x1B[37;0m'\n\r", (pnote->date_stamp > ch->pcdata->last_note && str_cmp (pnote->sender, NAME (ch))) ? "\x1B[1;34m(New)\x1B[37;0m" : " ", vnum, pnote->sender, pnote->subject); strcat (buf1, buf); vnum++; } else vnum++; if (strlen (buf1) > (STD_LENGTH * 16)) { strcat (buf1, "\n\rTOO MANY NOTES.. WAIT UNTIL A GOD REMOVES SOME!\n\r"); break; } } page_to_char_limited (buf1, ch); return; } if (!str_cmp (arg, "read")) { bool fAll; if (!str_cmp (argy, "all")) { fAll = TRUE; anum = 0; } else if (argy[0] == '\0' || !str_prefix (argy, "next")) /* read next unread note */ { vnum = 0; for (pnote = note_list; pnote != NULL; pnote = pnote->next) { if (is_note_to (ch, pnote) && (board_here == pnote->board_num || IS_IMMORTAL (ch)) && str_cmp (NAME (ch), pnote->sender) && ch->pcdata->last_note < pnote->date_stamp) { sprintf (buf,"\x1B[1;30m---------------------------------------------------------------------------\x1B[37;0m\n\r"); sprintf (buf+strlen(buf), "[Note #\x1B[1;37m%d:%d\x1B[37;0m] From: \x1B[1;37m%s\x1B[37;0m To: \x1B[1;37m%s\x1B[37;0m\n\r", vnum, pnote->board_num, pnote->sender, pnote->to_list); if (strlen(pnote->subject)>35) { pnote->subject[35]='\0'; } sprintf (buf+strlen(buf),"%s. Subject: \x1B[1;36m%s\x1B[37;0m\n\r", pnote->date, pnote->subject); sprintf (buf+strlen(buf),"\x1B[1;30m---------------------------------------------------------------------------\x1B[37;0m\n\r"); strcat (buf1, buf); strcat (buf1, pnote->text); ch->pcdata->last_note = UMAX (ch->pcdata->last_note, pnote->date_stamp); page_to_char_limited (buf1, ch); return; } else vnum++; } send_to_char ("You have no unread notes.\n\r", ch); return; } else if (is_number (argy)) { fAll = FALSE; anum = atoi (argy); } else { send_to_char ("Note read which number?\n\r", ch); return; } vnum = 0; for (pnote = note_list; pnote != NULL; pnote = pnote->next) { if ((vnum++ == anum || fAll) && is_note_to (ch, pnote) && (board_here == pnote->board_num || IS_IMMORTAL (ch))) { sprintf (buf,"\x1B[1;30m---------------------------------------------------------------------------\x1B[37;0m\n\r"); sprintf (buf+strlen(buf), "[Note #\x1B[1;37m%d:%d\x1B[37;0m] From: \x1B[1;37m%s\x1B[37;0m To: \x1B[1;37m%s\x1B[37;0m\n\r", vnum - 1, pnote->board_num, pnote->sender, pnote->to_list); if (strlen(pnote->subject)>35) { pnote->subject[35]='\0'; } sprintf (buf+strlen(buf),"Dated %s. Subject: \x1B[1;36m%s\x1B[37;0m\n\r", pnote->date, pnote->subject); sprintf (buf+strlen(buf),"\x1B[1;30m---------------------------------------------------------------------------\x1B[37;0m\n\r"); strcat (buf1, buf); strcat (buf1, pnote->text); page_to_char_limited (buf1, ch); return; } } send_to_char ("No such note.\n\r", ch); return; } if (!str_cmp (arg, "write")) { if (LEVEL (ch) < IMM_LEVEL && board_here == 1) { send_to_char ("You can't write on the immortal notice board.\n\r", ch); return; } if (IS_SET(ch->act, PLR_LAMER)) { send_to_char("You have lost your board writing privileges.\n\r", ch); send_to_char("Maybe if you grow up you will be allowed to start\n\r", ch); send_to_char("posting on the board again, however since you have\n\r", ch); send_to_char("consistently shown yourself to be lame this is not likely.\n\r", ch); return; } check_ced (ch); note_attach (ch); string_append (ch, &ch->ced->pnote->text); return; } if (!str_cmp (arg, "fwrite")) { if (IS_SET(ch->act, PLR_LAMER)) { send_to_char("You have lost your board writing privileges.\n\r", ch); send_to_char("Maybe if you grow up you will be allowed to start\n\r", ch); send_to_char("posting on the board again, however since you have\n\r", ch); send_to_char("consistently shown yourself to be lame this is not likely.\n\r", ch); return; } if (LEVEL (ch) < IMM_LEVEL && board_here == 1) { send_to_char ("You can't write on the immortal notice board.\n\r", ch); return; } check_ced (ch); note_attach (ch); fullscreen_editor (ch, &ch->ced->pnote->text); return; } if (!str_cmp (arg, "+")) { check_ced (ch); note_attach (ch); strcpy (buf, ch->ced->pnote->text); if (strlen (buf) + strlen (argy) >= STD_LENGTH - 200) { send_to_char ("Note too long.\n\r", ch); return; } strcat (buf, argy); strcat (buf, "\n\r"); free_string (ch->ced->pnote->text); ch->ced->pnote->text = str_dup (buf); ch->ced->pnote->lines += 1; send_to_char ("Ok.\n\r", ch); return; } if (!str_cmp (arg, "-")) { int num, cnt; char new_buf[STD_LENGTH]; const char *str; check_ced (ch); if (ch->ced->pnote == NULL) { send_to_char ("You have to start a note first.\n\r", ch); return; } if (ch->ced->pnote->lines == 0) { send_to_char ("Nothing to delete.\n\r", ch); return; } new_buf[0] = '\0'; str = ch->ced->pnote->text; cnt = 1; for (num = 1; num <= ch->ced->pnote->lines; num++) { while (*str != '\r' && *str != '\0') { ++str; ++cnt; } } strncpy (new_buf, ch->ced->pnote->text, cnt); new_buf[cnt] = '\0'; free_string (ch->ced->pnote->text); ch->ced->pnote->text = str_dup (new_buf); ch->ced->pnote->lines -= 1; send_to_char ("Ok.\n\r", ch); return; } if (!str_cmp (arg, "subject")) { if (IS_SET(ch->act, PLR_LAMER)) { send_to_char("You have lost your board writing privileges.\n\r", ch); send_to_char("Maybe if you grow up you will be allowed to start\n\r", ch); send_to_char("posting on the board again, however since you have\n\r", ch); send_to_char("consistently shown yourself to be lame this is not likely.\n\r", ch); return; } check_ced (ch); note_attach (ch); free_string (ch->ced->pnote->subject); ch->ced->pnote->subject = str_dup (argy); send_to_char ("Ok.\n\r", ch); return; } if (!str_cmp (arg, "to")) { if (IS_SET(ch->act, PLR_LAMER)) { send_to_char("You have lost your board writing privileges.\n\r", ch); send_to_char("Maybe if you grow up you will be allowed to start\n\r", ch); send_to_char("posting on the board again, however since you have\n\r", ch); send_to_char("consistently shown yourself to be lame this is not likely.\n\r", ch); return; } check_ced (ch); note_attach (ch); free_string (ch->ced->pnote->to_list); ch->ced->pnote->to_list = str_dup (argy); send_to_char("\x1b[1;31mBe sure to put 'pkill' or 'flame' if this is a pkill flame note.\x1b[0;37m", ch); send_to_char ("Ok.\n\r", ch); return; } if (!str_cmp (arg, "clear")) { if (IS_SET(ch->act, PLR_LAMER)) { send_to_char("You have lost your board writing privileges.\n\r", ch); send_to_char("Maybe if you grow up you will be allowed to start\n\r", ch); send_to_char("posting on the board again, however since you have\n\r", ch); send_to_char("consistently shown yourself to be lame this is not likely.\n\r", ch); return; } check_ced (ch); if (ch->ced->pnote != NULL) { free_string (ch->ced->pnote->text); free_string (ch->ced->pnote->subject); free_string (ch->ced->pnote->to_list); free_string (ch->ced->pnote->date); free_string (ch->ced->pnote->sender); ch->ced->pnote->next = note_free; note_free = ch->ced->pnote; ch->ced->pnote = NULL; } send_to_char ("Ok.\n\r", ch); return; } if (!str_cmp (arg, "show")) { if (IS_SET(ch->act, PLR_LAMER)) { send_to_char("You have lost your board writing privileges.\n\r", ch); send_to_char("Maybe if you grow up you will be allowed to start\n\r", ch); send_to_char("posting on the board again, however since you have\n\r", ch); send_to_char("consistently shown yourself to be lame this is not likely.\n\r", ch); return; } check_ced (ch); if (ch->ced->pnote == NULL) { send_to_char ("You have no note in progress.\n\r", ch); return; } sprintf (buf, "%s: %s\n\rTo: %s\n\rLines: %d\n\r", ch->ced->pnote->sender, ch->ced->pnote->subject, ch->ced->pnote->to_list, ch->ced->pnote->lines ); strcat (buf1, buf); strcat (buf1, ch->ced->pnote->text); page_to_char_limited (buf1, ch); return; } if (!str_cmp (arg, "post") || !str_prefix (arg, "send")) { FILE *fp; char *strtime; check_ced (ch); if (ch->ced->pnote == NULL) { send_to_char ("You have no note in progress.\n\r", ch); return; } if (board_here == 1 && LEVEL (ch) < IMM_LEVEL) { send_to_char ("This board is reserved for immortals posting messages to mortals.\n\r", ch); send_to_char ("Please post on a public board if you wish to write a note.\n\r", ch); return; } if (!str_cmp (ch->ced->pnote->to_list, "")) { send_to_char ( "You need to provide a recipient (name, all, or immortal).\n\r", ch); return; } if (!str_cmp (ch->ced->pnote->subject, "")) { send_to_char ("You need to provide a subject.\n\r", ch); return; } if (IS_SET(ch->act, PLR_LAMER)) { send_to_char("You have lost your board writing privileges.\n\r", ch); send_to_char("Maybe if you grow up you will be allowed to start\n\r", ch); send_to_char("posting on the board again, however since you have\n\r", ch); send_to_char("consistently shown yourself to be lame this is not likely.\n\r", ch); return; } ch->pcdata->online_spot->notes_this_reboot++; if(ch->pcdata->online_spot->notes_this_reboot > 8) { send_to_char("You have already written too many notes this reboot.\n\r", ch); return; } ch->ced->pnote->next = NULL; strtime = ctime (¤t_time); strtime[strlen (strtime) - 1] = '\0'; ch->ced->pnote->board_num = board_here; ch->ced->pnote->date = str_dup (strtime); ch->ced->pnote->date_stamp = current_time; if (note_list == NULL) { note_list = ch->ced->pnote; } else { for (pnote = note_list; pnote->next != NULL; pnote = pnote->next) ; pnote->next = ch->ced->pnote; } pnote = ch->ced->pnote; ch->ced->pnote = NULL; #ifndef WINDOWS // fclose (fpReserve); #endif if ((fp = fopen (NOTE_FILE, "a")) == NULL) { perror (NOTE_FILE); } else { fprintf (fp, "Sender %s~\n", fix_string (pnote->sender)); fprintf (fp, "TBoard %d\n", pnote->board_num); fprintf (fp, "Date %s~\n", pnote->date); fprintf (fp, "Stamp %ld\n", pnote->date_stamp); fprintf (fp, "To %s~\n", fix_string (pnote->to_list)); fprintf (fp, "Subject %s~\n", fix_string (pnote->subject)); fprintf (fp, "Text\n%s~\n", pnote->text); fprintf (fp, "End\n\n"); fclose (fp); } #ifndef WINDOWS // fpReserve = fopen (NULL_FILE, "r"); #endif send_to_char ("Ok.\n\r", ch); return; } if (!str_cmp (arg, "remove")) { if (!is_number (argy)) { send_to_char ("Note remove which number?\n\r", ch); return; } anum = atoi (argy); vnum = 0; for (pnote = note_list; pnote != NULL; pnote = pnote->next) { if (vnum++ == anum && ( (is_note_to (ch, pnote) && !is_name ("all", pnote->to_list)) || LEVEL (ch) > 109)) { note_remove (ch, pnote); send_to_char ("Ok.\n\r", ch); return; } } send_to_char ("No such note.\n\r", ch); return; } send_to_char ("Huh? Type 'help note' for usage.\n\r", ch); return; }
void do_note( CHAR_DATA *ch, char *argument ) { char buf[MAX_STRING_LENGTH]; char arg[MAX_INPUT_LENGTH]; NOTE_DATA *pnote; int vnum; int anum; int number, ii; if ( IS_NPC(ch) ) return; argument = one_argument( argument, arg ); if ( !str_cmp( arg, "list" ) ) { vnum = 0; for ( pnote = note_list; pnote != NULL; pnote = pnote->next ) { if ( is_note_to( ch, pnote ) ) { sprintf( buf, "[%3d] %s: %s\n\r", vnum, pnote->sender, pnote->subject ); send_to_char( buf, ch ); vnum++; } } return; } if ( !str_cmp( arg, "read" ) ) { bool fAll; if ( !str_cmp( argument, "all" ) ) { fAll = TRUE; anum = 0; } else if ( is_number( argument ) ) { fAll = FALSE; anum = atoi( argument ); } else { send_to_char( "Note read which number?\n\r", ch ); return; } vnum = 0; for ( pnote = note_list; pnote != NULL; pnote = pnote->next ) { if ( is_note_to( ch, pnote ) && ( vnum++ == anum || fAll ) ) { sprintf( buf, "[%3d] %s: %s\n\r%s\n\rTo: %s\n\r", vnum - 1, pnote->sender, pnote->subject, pnote->date, pnote->to_list ); send_to_char( buf, ch ); send_to_char( pnote->text, ch ); return; } } send_to_char( "No such note.\n\r", ch ); return; } if ( !str_cmp( arg, "+" ) ) { note_attach( ch ); strcpy( buf, ch->pnote->text ); if ( strlen(buf) + strlen(argument) >= MAX_STRING_LENGTH - 4 ) { send_to_char( "Note too long.\n\r", ch ); return; } strcat( buf, argument ); strcat( buf, "\n\r" ); free_string( ch->pnote->text, MEM_GENERAL ); ch->pnote->text = str_dup( buf ); send_to_char( "Ok.\n\r", ch ); return; } if ( !str_cmp( arg, "subject" ) ) { note_attach( ch ); free_string( ch->pnote->subject, MEM_GENERAL ); ch->pnote->subject = str_dup( argument ); send_to_char( "Ok.\n\r", ch ); return; } if ( !str_cmp( arg, "to" ) ) { note_attach( ch ); free_string( ch->pnote->to_list, MEM_GENERAL ); ch->pnote->to_list = str_dup( argument ); send_to_char( "Ok.\n\r", ch ); return; } if ( !str_cmp( arg, "clear" ) ) { if ( ch->pnote != NULL ) { free_string( ch->pnote->text, MEM_GENERAL ); free_string( ch->pnote->subject, MEM_GENERAL ); free_string( ch->pnote->to_list, MEM_GENERAL ); free_string( ch->pnote->date, MEM_GENERAL ); free_string( ch->pnote->sender, MEM_GENERAL ); ch->pnote->next = note_free; note_free = ch->pnote; ch->pnote = NULL; } send_to_char( "Ok.\n\r", ch ); return; } if ( !str_cmp( arg, "show" ) ) { if ( ch->pnote == NULL ) { send_to_char( "You have no note in progress.\n\r", ch ); return; } number = 1; ii = 1; sprintf( buf, "%s: %s\n\rTo: %s\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_cmp( arg, "post" ) ) { FILE *fp; char *strtime; if ( ch->pnote == NULL ) { send_to_char( "You have no note in progress.\n\r", ch ); return; } ch->pnote->next = NULL; strtime = ctime( ¤t_time ); strtime[strlen(strtime)-1] = '\0'; ch->pnote->date = str_dup( strtime ); if ( note_list == NULL ) { note_list = ch->pnote; } else { for ( pnote = note_list; pnote->next != NULL; pnote = pnote->next ) ; pnote->next = ch->pnote; } pnote = ch->pnote; ch->pnote = NULL; fclose( fpReserve ); if ( ( fp = fopen( NOTE_FILE, "a" ) ) == NULL ) { perror( NOTE_FILE ); } else { fprintf( fp, "Sender " ); write_string( fp, pnote->sender ); fprintf( fp, "~\nDate " ); write_string( fp, pnote->date ); fprintf( fp, "~\nTo " ); write_string( fp, pnote->to_list ); fprintf( fp, "~\nSubject " ); write_string( fp, pnote->subject ); fprintf( fp, "~\nText\n" ); write_string( fp, pnote->text ); fprintf( fp, "~\n\n" ); fclose( fp ); } fpReserve = fopen( NULL_FILE, "r" ); send_to_char( "Ok.\n\r", ch ); return; } if ( !str_cmp( arg, "remove" ) ) { if ( !is_number( argument ) ) { send_to_char( "Note remove which number?\n\r", ch ); return; } anum = atoi( argument ); vnum = 0; for ( pnote = note_list; pnote != NULL; pnote = pnote->next ) { if ( is_note_to( ch, pnote ) && vnum++ == anum ) { note_remove( ch, pnote ); send_to_char( "Ok.\n\r", ch ); return; } } send_to_char( "No such note.\n\r", ch ); return; } send_to_char( "Huh? Type 'help note' for usage.\n\r", ch ); return; }
void parse_note( CHAR_DATA *ch, char *argument, int type ) { char arg[MAX_INPUT_LENGTH]; NOTE_DATA *pnote; NOTE_DATA **list; char *list_name; int vnum = 0; int anum = 0; 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; } 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)) { send_to_char( Format("[%3d] %s: %s\n\r%s\n\rTo: %s\n\r", vnum, pnote->sender, pnote->subject, pnote->date, pnote->to_list), ch ); page_to_char( pnote->text, ch ); update_read(ch,pnote); return; } else if (is_note_to(ch,pnote)) vnum++; } send_to_char( Format("You have no unread %s.\n\r",list_name),ch); return; } else if ( is_number( argument ) ) { fAll = FALSE; anum = atoi( argument ); } else { send_to_char( "Read which number?\n\r", ch ); return; } vnum = 0; for ( pnote = *list; pnote != NULL; pnote = pnote->next ) { if ( is_note_to( ch, pnote ) && ( vnum++ == anum || fAll ) ) { send_to_char( Format("[%3d] %s: %s\n\r%s\n\rTo: %s\n\r", vnum - 1, pnote->sender, pnote->subject, pnote->date, pnote->to_list), ch ); page_to_char( pnote->text, ch ); update_read(ch,pnote); return; } } send_to_char( Format("There aren't that many %s.\n\r",list_name),ch); return; } if ( !str_prefix( arg, "list" ) ) { vnum = 0; for ( pnote = *list; pnote != NULL; pnote = pnote->next ) { if ( is_note_to( ch, pnote ) ) { send_to_char( Format("[%3d%s] %s: %s\n\r", vnum, hide_note(ch,pnote) ? " " : "N", pnote->sender, pnote->subject), ch ); vnum++; } } if (!vnum) { switch(type) { case NOTE_NOTE: send_to_char("There are no notes for you.\n\r",ch); break; case NOTE_IDEA: send_to_char("There are no ideas for you.\n\r",ch); break; case NOTE_PENALTY: send_to_char("There are no penalties for you.\n\r",ch); break; case NOTE_NEWS: send_to_char("There is no news for you.\n\r",ch); break; case NOTE_CHANGES: send_to_char("There are no changes for you.\n\r",ch); break; } } return; } if ( !str_prefix( arg, "remove" ) ) { if ( !is_number( argument ) ) { send_to_char( "Note remove which number?\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( "Ok.\n\r", ch ); return; } } send_to_char( Format("There aren't that many %s.",list_name),ch); return; } if ( !str_prefix( arg, "delete" ) && get_trust(ch) >= MAX_LEVEL - 1) { if ( !is_number( argument ) ) { send_to_char( "Note delete which number?\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( "Ok.\n\r", ch ); return; } } send_to_char( Format("There aren't that many %s.",list_name),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; } 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))) { send_to_char( Format("You aren't high enough level to write %s.",list_name),ch); return; } if ( !str_cmp ( arg, "new" ) || !str_cmp ( arg, "write" ) ) { note_attach ( ch, type ); if ( ch->pnote->type != type ) { send_to_char ( "You already have a different note in progress.\n\r", ch ); return; } ch->desc->connected = CON_NOTE_TO; send_to_char ( "Address this message to whom: (all, staff, <name>) ", ch ); return; } send_to_char( "You can't do that.\n\r", ch ); return; }
void do_note( CHAR_DATA * ch, char *arg_passed, bool IS_MAIL ) { char buf[MAX_STRING_LENGTH]; char arg[MAX_INPUT_LENGTH]; NOTE_DATA *pnote = NULL; BOARD_DATA *board = NULL; int vnum = 0; int anum = 0; int first_list = 0; OBJ_DATA *paper = NULL, *tmpobj = NULL; EXTRA_DESCR_DATA *ed = NULL; char notebuf[MAX_STRING_LENGTH]; char short_desc_buf[MAX_STRING_LENGTH]; char long_desc_buf[MAX_STRING_LENGTH]; char keyword_buf[MAX_STRING_LENGTH]; bool mfound = FALSE; bool wasfound = FALSE; if( IS_NPC( ch ) ) return; if( !ch->desc ) { bug( "do_note: no descriptor", 0 ); return; } switch ( ch->substate ) { default: break; case SUB_WRITING_NOTE: if( ( paper = get_eq_char( ch, WEAR_HOLD ) ) == NULL || paper->item_type != ITEM_PAPER ) { bug( "do_note: player not holding paper", 0 ); stop_editing( ch ); return; } ed = ( EXTRA_DESCR_DATA * ) ch->dest_buf; STRFREE( ed->description ); ed->description = copy_buffer( ch ); stop_editing( ch ); return; } set_char_color( AT_NOTE, ch ); arg_passed = one_argument( arg_passed, arg ); smash_tilde( arg_passed ); if( !str_cmp( arg, "list" ) ) { board = find_board( ch ); if( !board ) { send_to_char( "There is no board here to look at.\r\n", ch ); return; } if( !can_read( ch, board ) ) { send_to_char ( "You cannot make any sense of the cryptic scrawl on this board...\r\n", ch ); return; } first_list = atoi( arg_passed ); if( first_list ) { if( IS_MAIL ) { send_to_char ( "You cannot use a list number (at this time) with mail.\r\n", ch ); return; } if( first_list < 1 ) { send_to_char( "You can't read a message before 1!\r\n", ch ); return; } } if( !IS_MAIL ) { vnum = 0; set_pager_color( AT_NOTE, ch ); for( pnote = board->first_note; pnote; pnote = pnote->next ) { vnum++; if( ( first_list && vnum >= first_list ) || !first_list ) pager_printf( ch, "%2d%c %-12s%c %-12s %s\r\n", vnum, is_note_to( ch, pnote ) ? ')' : '}', pnote->sender, ( pnote->voting != VOTE_NONE ) ? ( pnote->voting == VOTE_OPEN ? 'V' : 'C' ) : ':', pnote->to_list, pnote->subject ); } act( AT_ACTION, "$n glances over the messages.", ch, NULL, NULL, TO_ROOM ); return; } else { vnum = 0; if( IS_MAIL ) /* SB Mail check for Brit */ { for( pnote = board->first_note; pnote; pnote = pnote->next ) if( is_note_to( ch, pnote ) ) mfound = TRUE; if( !mfound && !IS_IMMORTAL( ch ) ) { ch_printf( ch, "You have no mail.\r\n" ); return; } } for( pnote = board->first_note; pnote; pnote = pnote->next ) if( is_note_to( ch, pnote ) || IS_IMMORTAL( ch ) ) ch_printf( ch, "%2d%c %s: %s\r\n", ++vnum, is_note_to( ch, pnote ) ? '-' : '}', pnote->sender, pnote->subject ); return; } } if( !str_cmp( arg, "read" ) ) { bool fAll = FALSE; board = find_board( ch ); if( !board ) { send_to_char( "There is no board here to look at.\r\n", ch ); return; } if( !can_read( ch, board ) ) { send_to_char ( "You cannot make any sense of the cryptic scrawl on this board...\r\n", ch ); return; } if( !str_cmp( arg_passed, "all" ) ) { fAll = TRUE; anum = 0; } else if( is_number( arg_passed ) ) { fAll = FALSE; anum = atoi( arg_passed ); } else { send_to_char( "Note read which number?\r\n", ch ); return; } set_pager_color( AT_NOTE, ch ); if( !IS_MAIL ) { vnum = 0; for( pnote = board->first_note; pnote; pnote = pnote->next ) { vnum++; if( vnum == anum || fAll ) { wasfound = TRUE; pager_printf( ch, "[%3d] %s: %s\r\n%s\r\nTo: %s\r\n%s", vnum, pnote->sender, pnote->subject, pnote->date, pnote->to_list, pnote->text ); if( pnote->yesvotes[0] != '\0' || pnote->novotes[0] != '\0' || pnote->abstentions[0] != '\0' ) { send_to_pager ( "------------------------------------------------------------\r\n", ch ); pager_printf( ch, "Votes:\r\nYes: %s\r\nNo: %s\r\nAbstain: %s\r\n", pnote->yesvotes, pnote->novotes, pnote->abstentions ); } act( AT_ACTION, "$n reads a message.", ch, NULL, NULL, TO_ROOM ); } } if( !wasfound ) ch_printf( ch, "No such message: %d\r\n", anum ); return; } else { vnum = 0; for( pnote = board->first_note; pnote; pnote = pnote->next ) { if( is_note_to( ch, pnote ) || IS_IMMORTAL( ch ) ) { vnum++; if( vnum == anum || fAll ) { wasfound = TRUE; pager_printf( ch, "[%3d] %s: %s\r\n%s\r\nTo: %s\r\n%s", vnum, pnote->sender, pnote->subject, pnote->date, pnote->to_list, pnote->text ); } } } if( !wasfound ) ch_printf( ch, "No such message: %d\r\n", anum ); return; } } /* Voting added by Narn, June '96 */ if( !str_cmp( arg, "vote" ) ) { char arg2[MAX_INPUT_LENGTH]; arg_passed = one_argument( arg_passed, arg2 ); board = find_board( ch ); if( !board ) { send_to_char( "There is no bulletin board here.\r\n", ch ); return; } if( !can_read( ch, board ) ) { send_to_char( "You cannot vote on this board.\r\n", ch ); return; } if( is_number( arg2 ) ) anum = atoi( arg2 ); else { send_to_char( "Note vote which number?\r\n", ch ); return; } vnum = 1; for( pnote = board->first_note; pnote && vnum < anum; pnote = pnote->next ) vnum++; if( !pnote ) { send_to_char( "No such note.\r\n", ch ); return; } /* Options: open close yes no abstain */ /* If you're the author of the note and can read the board you can open and close voting, if you can read it and voting is open you can vote. */ if( !str_cmp( arg_passed, "open" ) ) { if( str_cmp( ch->name, pnote->sender ) ) { send_to_char( "You are not the author of this message.\r\n", ch ); return; } pnote->voting = VOTE_OPEN; act( AT_ACTION, "$n opens voting on a note.", ch, NULL, NULL, TO_ROOM ); send_to_char( "Voting opened.\r\n", ch ); write_board( board ); return; } if( !str_cmp( arg_passed, "close" ) ) { if( str_cmp( ch->name, pnote->sender ) ) { send_to_char( "You are not the author of this message.\r\n", ch ); return; } pnote->voting = VOTE_CLOSED; act( AT_ACTION, "$n closes voting on a note.", ch, NULL, NULL, TO_ROOM ); send_to_char( "Voting closed.\r\n", ch ); write_board( board ); return; } /* Make sure the note is open for voting before going on. */ if( pnote->voting != VOTE_OPEN ) { send_to_char( "Voting is not open on this note.\r\n", ch ); return; } /* Can only vote once on a note. */ sprintf( buf, "%s %s %s", pnote->yesvotes, pnote->novotes, pnote->abstentions ); if( is_name( ch->name, buf ) ) { send_to_char( "You have already voted on this note.\r\n", ch ); return; } if( !str_cmp( arg_passed, "yes" ) ) { sprintf( buf, "%s %s", pnote->yesvotes, ch->name ); DISPOSE( pnote->yesvotes ); pnote->yesvotes = str_dup( buf ); act( AT_ACTION, "$n votes on a note.", ch, NULL, NULL, TO_ROOM ); send_to_char( "Ok.\r\n", ch ); write_board( board ); return; } if( !str_cmp( arg_passed, "no" ) ) { sprintf( buf, "%s %s", pnote->novotes, ch->name ); DISPOSE( pnote->novotes ); pnote->novotes = str_dup( buf ); act( AT_ACTION, "$n votes on a note.", ch, NULL, NULL, TO_ROOM ); send_to_char( "Ok.\r\n", ch ); write_board( board ); return; } if( !str_cmp( arg_passed, "abstain" ) ) { sprintf( buf, "%s %s", pnote->abstentions, ch->name ); DISPOSE( pnote->abstentions ); pnote->abstentions = str_dup( buf ); act( AT_ACTION, "$n votes on a note.", ch, NULL, NULL, TO_ROOM ); send_to_char( "Ok.\r\n", ch ); write_board( board ); return; } do_note( ch, STRLIT_EMPTY, FALSE ); } if( !str_cmp( arg, "write" ) ) { if( ch->substate == SUB_RESTRICTED ) { send_to_char ( "You cannot write a note from within another command.\r\n", ch ); return; } if( ( paper = get_eq_char( ch, WEAR_HOLD ) ) == NULL || paper->item_type != ITEM_PAPER ) { paper = create_object( get_obj_index( OBJ_VNUM_NOTE ) ); if( ( tmpobj = get_eq_char( ch, WEAR_HOLD ) ) != NULL ) unequip_char( ch, tmpobj ); paper = obj_to_char( paper, ch ); equip_char( ch, paper, WEAR_HOLD ); act( AT_MAGIC, "$n grabs a message disk to record a note.", ch, NULL, NULL, TO_ROOM ); act( AT_MAGIC, "You get a message disk to record your note.", ch, NULL, NULL, TO_CHAR ); } if( paper->value[0] < 2 ) { paper->value[0] = 1; ed = SetOExtra( paper, "_text_" ); ch->substate = SUB_WRITING_NOTE; ch->dest_buf = ed; start_editing( ch, ed->description ); return; } else { send_to_char( "You cannot modify this message.\r\n", ch ); return; } } if( !str_cmp( arg, "subject" ) ) { if( !arg_passed || arg_passed[0] == '\0' ) { send_to_char( "What do you wish the subject to be?\r\n", ch ); return; } if( ( paper = get_eq_char( ch, WEAR_HOLD ) ) == NULL || paper->item_type != ITEM_PAPER ) { paper = create_object( get_obj_index( OBJ_VNUM_NOTE ) ); if( ( tmpobj = get_eq_char( ch, WEAR_HOLD ) ) != NULL ) unequip_char( ch, tmpobj ); paper = obj_to_char( paper, ch ); equip_char( ch, paper, WEAR_HOLD ); act( AT_MAGIC, "$n grabs a message disk.", ch, NULL, NULL, TO_ROOM ); act( AT_MAGIC, "You get a message disk to record your note.", ch, NULL, NULL, TO_CHAR ); } if( paper->value[1] > 1 ) { send_to_char( "You cannot modify this message.\r\n", ch ); return; } else { paper->value[1] = 1; ed = SetOExtra( paper, "_subject_" ); STRFREE( ed->description ); ed->description = STRALLOC( arg_passed ); send_to_char( "Ok.\r\n", ch ); return; } } if( !str_cmp( arg, "to" ) ) { struct stat fst; char fname[1024]; if( !arg_passed || arg_passed[0] == '\0' ) { send_to_char( "Please specify an addressee.\r\n", ch ); return; } if( ( paper = get_eq_char( ch, WEAR_HOLD ) ) == NULL || paper->item_type != ITEM_PAPER ) { paper = create_object( get_obj_index( OBJ_VNUM_NOTE ) ); if( ( tmpobj = get_eq_char( ch, WEAR_HOLD ) ) != NULL ) unequip_char( ch, tmpobj ); paper = obj_to_char( paper, ch ); equip_char( ch, paper, WEAR_HOLD ); act( AT_MAGIC, "$n gets a message disk to record a note.", ch, NULL, NULL, TO_ROOM ); act( AT_MAGIC, "You grab a message disk to record your note.", ch, NULL, NULL, TO_CHAR ); } if( paper->value[2] > 1 ) { send_to_char( "You cannot modify this message.\r\n", ch ); return; } arg_passed[0] = UPPER( arg_passed[0] ); sprintf( fname, "%s%c/%s", PLAYER_DIR, tolower( ( int ) arg_passed[0] ), capitalize( arg_passed ) ); if( !IS_MAIL || stat( fname, &fst ) != -1 || !str_cmp( arg_passed, "all" ) ) { paper->value[2] = 1; ed = SetOExtra( paper, "_to_" ); STRFREE( ed->description ); ed->description = STRALLOC( arg_passed ); send_to_char( "Ok.\r\n", ch ); return; } else { send_to_char( "No player exists by that name.\r\n", ch ); return; } } if( !str_cmp( arg, "show" ) ) { const char *subject = ""; const char *to_list = ""; const char *text = ""; if( ( paper = get_eq_char( ch, WEAR_HOLD ) ) == NULL || paper->item_type != ITEM_PAPER ) { send_to_char( "You are not holding a message disk.\r\n", ch ); return; } if( ( subject = get_extra_descr( "_subject_", paper->first_extradesc ) ) == NULL ) subject = "(no subject)"; if( ( to_list = get_extra_descr( "_to_", paper->first_extradesc ) ) == NULL ) to_list = "(nobody)"; sprintf( buf, "%s: %s\r\nTo: %s\r\n", ch->name, subject, to_list ); send_to_char( buf, ch ); if( ( text = get_extra_descr( "_text_", paper->first_extradesc ) ) == NULL ) text = "The disk is blank.\r\n"; send_to_char( text, ch ); return; } if( !str_cmp( arg, "post" ) ) { char *strtime = NULL; const char *text = NULL; if( ( paper = get_eq_char( ch, WEAR_HOLD ) ) == NULL || paper->item_type != ITEM_PAPER ) { send_to_char( "You are not holding a message disk.\r\n", ch ); return; } if( paper->value[0] == 0 ) { send_to_char( "There is nothing written on this disk.\r\n", ch ); return; } if( paper->value[1] == 0 ) { send_to_char( "This message has no subject... using 'none'.\r\n", ch ); paper->value[1] = 1; ed = SetOExtra( paper, "_subject_" ); STRFREE( ed->description ); ed->description = STRALLOC( "none" ); } if( paper->value[2] == 0 ) { if( IS_MAIL ) { send_to_char( "This message is addressed to no one!\r\n", ch ); return; } else { send_to_char ( "This message is addressed to no one... sending to 'all'!\r\n", ch ); paper->value[2] = 1; ed = SetOExtra( paper, "_to_" ); STRFREE( ed->description ); ed->description = STRALLOC( "All" ); } } board = find_board( ch ); if( !board ) { send_to_char ( "There is no terminal here to upload your message to.\r\n", ch ); return; } if( !can_post( ch, board ) ) { send_to_char ( "You cannot use this terminal. It is encrypted...\r\n", ch ); return; } if( board->num_posts >= board->max_posts ) { send_to_char ( "This terminal is full. There is no room for your message.\r\n", ch ); return; } act( AT_ACTION, "$n uploads a message.", ch, NULL, NULL, TO_ROOM ); strtime = ctime( ¤t_time ); strtime[strlen( strtime ) - 1] = '\0'; CREATE( pnote, NOTE_DATA, 1 ); pnote->date = STRALLOC( strtime ); text = get_extra_descr( "_text_", paper->first_extradesc ); pnote->text = text ? STRALLOC( text ) : STRALLOC( "" ); text = get_extra_descr( "_to_", paper->first_extradesc ); pnote->to_list = text ? STRALLOC( text ) : STRALLOC( "all" ); text = get_extra_descr( "_subject_", paper->first_extradesc ); pnote->subject = text ? STRALLOC( text ) : STRALLOC( "" ); pnote->sender = QUICKLINK( ch->name ); pnote->voting = 0; pnote->yesvotes = str_dup( "" ); pnote->novotes = str_dup( "" ); pnote->abstentions = str_dup( "" ); LINK( pnote, board->first_note, board->last_note, next, prev ); board->num_posts++; write_board( board ); send_to_char( "You upload your message to the terminal.\r\n", ch ); extract_obj( paper ); return; } if( !str_cmp( arg, "remove" ) || !str_cmp( arg, "take" ) || !str_cmp( arg, "copy" ) ) { char take = 0; board = find_board( ch ); if( !board ) { send_to_char ( "There is no terminal here to download a note from!\r\n", ch ); return; } if( !str_cmp( arg, "take" ) ) take = 1; else if( !str_cmp( arg, "copy" ) ) { if( !IS_IMMORTAL( ch ) ) { send_to_char( "Huh? Type 'help note' for usage.\r\n", ch ); return; } take = 2; } else take = 0; if( !is_number( arg_passed ) ) { send_to_char( "Note remove which number?\r\n", ch ); return; } if( !can_read( ch, board ) ) { send_to_char ( "You can't make any sense of what's posted here, let alone remove anything!\r\n", ch ); return; } anum = atoi( arg_passed ); vnum = 0; for( pnote = board->first_note; pnote; pnote = pnote->next ) { if( IS_MAIL && ( ( is_note_to( ch, pnote ) ) || IS_IMMORTAL( ch ) ) ) vnum++; else if( !IS_MAIL ) vnum++; if( ( !str_cmp( ch->name, pnote->sender ) || can_remove( ch, board ) ) && ( vnum == anum ) ) { if( ( is_name( "all", pnote->to_list ) ) && ( !IS_IMMORTAL( ch ) ) && ( take == 1 ) ) { send_to_char ( "Notes addressed to 'all' can not be taken.\r\n", ch ); return; } if( take != 0 ) { paper = create_object( get_obj_index( OBJ_VNUM_NOTE ) ); ed = SetOExtra( paper, "_sender_" ); STRFREE( ed->description ); ed->description = QUICKLINK( pnote->sender ); ed = SetOExtra( paper, "_text_" ); STRFREE( ed->description ); ed->description = QUICKLINK( pnote->text ); ed = SetOExtra( paper, "_to_" ); STRFREE( ed->description ); ed->description = QUICKLINK( pnote->to_list ); ed = SetOExtra( paper, "_subject_" ); STRFREE( ed->description ); ed->description = QUICKLINK( pnote->subject ); ed = SetOExtra( paper, "_date_" ); STRFREE( ed->description ); ed->description = QUICKLINK( pnote->date ); ed = SetOExtra( paper, "note" ); STRFREE( ed->description ); sprintf( notebuf, "From: " ); strcat( notebuf, pnote->sender ); strcat( notebuf, "\r\nTo: " ); strcat( notebuf, pnote->to_list ); strcat( notebuf, "\r\nSubject: " ); strcat( notebuf, pnote->subject ); strcat( notebuf, "\r\n\r\n" ); strcat( notebuf, pnote->text ); strcat( notebuf, "\r\n" ); ed->description = STRALLOC( notebuf ); paper->value[0] = 2; paper->value[1] = 2; paper->value[2] = 2; sprintf( short_desc_buf, "a note from %s to %s", pnote->sender, pnote->to_list ); STRFREE( paper->short_descr ); paper->short_descr = STRALLOC( short_desc_buf ); sprintf( long_desc_buf, "A note from %s to %s lies on the ground.", pnote->sender, pnote->to_list ); STRFREE( paper->description ); paper->description = STRALLOC( long_desc_buf ); sprintf( keyword_buf, "note parchment paper %s", pnote->to_list ); STRFREE( paper->name ); paper->name = STRALLOC( keyword_buf ); } if( take != 2 ) note_remove( board, pnote ); send_to_char( "Ok.\r\n", ch ); if( take == 1 ) { act( AT_ACTION, "$n downloads a message.", ch, NULL, NULL, TO_ROOM ); obj_to_char( paper, ch ); } else if( take == 2 ) { act( AT_ACTION, "$n copies a message.", ch, NULL, NULL, TO_ROOM ); obj_to_char( paper, ch ); } else act( AT_ACTION, "$n removes a message.", ch, NULL, NULL, TO_ROOM ); return; } } send_to_char( "No such message.\r\n", ch ); return; } send_to_char( "Huh? Type 'help note' for usage.\r\n", ch ); }
void parse_note ( Creature *ch, const char *argument, int type ) { BUFFER *buffer; char buf[MAX_STRING_LENGTH]; char arg[MAX_INPUT_LENGTH]; NOTE_DATA *pnote; NOTE_DATA **list; const char *list_name; int vnum; int anum; 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; } argument = ChopC ( argument, arg ); smash_tilde ( argument ); if ( arg[0] == '\0' || !str_prefix ( arg, "read" ) ) { bool fAll; if ( SameString ( 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, "[%3d] %s: %s\n\r%s\n\rTo: %s\n\r", vnum, pnote->sender, pnote->subject, pnote->date, pnote->to_list ); writeBuffer ( buf, ch ); writePage ( pnote->text, ch ); update_read ( ch, pnote ); return; } else if ( is_note_to ( ch, pnote ) ) { vnum++; } } snprintf ( buf, sizeof ( buf ), "You have no unread %s.\n\r", list_name ); writeBuffer ( buf, ch ); return; } else if ( is_number ( argument ) ) { fAll = FALSE; anum = atoi ( argument ); } else { writeBuffer ( "Read which number?\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, "[%3d] %s: %s\n\r%s\n\rTo: %s\n\r", vnum - 1, pnote->sender, pnote->subject, pnote->date, pnote->to_list ); writeBuffer ( buf, ch ); writePage ( pnote->text, ch ); update_read ( ch, pnote ); return; } } snprintf ( buf, sizeof ( buf ), "There aren't that many %s.\n\r", list_name ); writeBuffer ( buf, ch ); return; } if ( !str_prefix ( arg, "list" ) ) { vnum = 0; for ( pnote = *list; pnote != NULL; pnote = pnote->next ) { if ( is_note_to ( ch, pnote ) ) { sprintf ( buf, "[%3d%s] %s: %s\n\r", vnum, hide_note ( ch, pnote ) ? " " : "N", pnote->sender, pnote->subject ); writeBuffer ( buf, ch ); vnum++; } } if ( !vnum ) { switch ( type ) { case NOTE_NOTE: writeBuffer ( "There are no notes for you.\n\r", ch ); break; case NOTE_IDEA: writeBuffer ( "There are no ideas for you.\n\r", ch ); break; case NOTE_PENALTY: writeBuffer ( "There are no penalties for you.\n\r", ch ); break; case NOTE_NEWS: writeBuffer ( "There is no news for you.\n\r", ch ); break; case NOTE_CHANGES: writeBuffer ( "There are no changes for you.\n\r", ch ); break; } } return; } if ( !str_prefix ( arg, "remove" ) ) { if ( !is_number ( argument ) ) { writeBuffer ( "Note remove which number?\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 ); writeBuffer ( "Ok.\n\r", ch ); return; } } snprintf ( buf, sizeof ( buf ), "There aren't that many %s.", list_name ); writeBuffer ( buf, ch ); return; } if ( !str_prefix ( arg, "delete" ) && get_trust ( ch ) >= MAX_LEVEL - 1 ) { if ( !is_number ( argument ) ) { writeBuffer ( "Note delete which number?\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 ); writeBuffer ( "Ok.\n\r", ch ); return; } } snprintf ( buf, sizeof ( buf ), "There aren't that many %s.", list_name ); writeBuffer ( 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; } 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 ) ) ) { snprintf ( buf, sizeof ( buf ), "You aren't high enough level to write %s.", list_name ); writeBuffer ( buf, ch ); return; } if ( SameString ( arg, "+" ) ) { note_attach ( ch, type ); if ( ch->pnote->type != type ) { writeBuffer ( "You already have a different note in progress.\n\r", ch ); return; } if ( strlen ( ch->pnote->text ) + strlen ( argument ) >= 4096 ) { writeBuffer ( "Note too long.\n\r", ch ); return; } buffer = new_buf(); add_buf ( buffer, ch->pnote->text ); add_buf ( buffer, argument ); add_buf ( buffer, "\n\r" ); PURGE_DATA ( ch->pnote->text ); ch->pnote->text = assign_string ( buf_string ( buffer ) ); recycle_buf ( buffer ); writeBuffer ( "Ok.\n\r", ch ); return; } if ( SameString ( arg, "-" ) ) { int len; bool found = FALSE; note_attach ( ch, type ); if ( ch->pnote->type != type ) { writeBuffer ( "You already have a different note in progress.\n\r", ch ); return; } if ( ch->pnote->text == NULL || ch->pnote->text[0] == '\0' ) { writeBuffer ( "No lines left to remove.\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'; PURGE_DATA ( ch->pnote->text ); ch->pnote->text = assign_string ( buf ); return; } } } buf[0] = '\0'; PURGE_DATA ( ch->pnote->text ); ch->pnote->text = assign_string ( buf ); return; } if ( !str_prefix ( arg, "subject" ) ) { note_attach ( ch, type ); if ( ch->pnote->type != type ) { writeBuffer ( "You already have a different note in progress.\n\r", ch ); return; } PURGE_DATA ( ch->pnote->subject ); ch->pnote->subject = assign_string ( argument ); writeBuffer ( "Ok.\n\r", ch ); return; } if ( !str_prefix ( arg, "to" ) ) { note_attach ( ch, type ); if ( ch->pnote->type != type ) { writeBuffer ( "You already have a different note in progress.\n\r", ch ); return; } PURGE_DATA ( ch->pnote->to_list ); ch->pnote->to_list = assign_string ( argument ); writeBuffer ( "Ok.\n\r", ch ); return; } if ( !str_prefix ( arg, "clear" ) ) { if ( ch->pnote != NULL ) { recycle_note ( ch->pnote ); ch->pnote = NULL; } writeBuffer ( "Ok.\n\r", ch ); return; } if ( !str_prefix ( arg, "show" ) ) { if ( ch->pnote == NULL ) { writeBuffer ( "You have no note in progress.\n\r", ch ); return; } if ( ch->pnote->type != type ) { writeBuffer ( "You aren't working on that kind of note.\n\r", ch ); return; } sprintf ( buf, "%s: %s\n\rTo: %s\n\r", ch->pnote->sender, ch->pnote->subject, ch->pnote->to_list ); writeBuffer ( buf, ch ); writeBuffer ( ch->pnote->text, ch ); return; } if ( !str_prefix ( arg, "post" ) || !str_prefix ( arg, "send" ) ) { char *strtime; if ( ch->pnote == NULL ) { writeBuffer ( "You have no note in progress.\n\r", ch ); return; } if ( ch->pnote->type != type ) { writeBuffer ( "You aren't working on that kind of note.\n\r", ch ); return; } if ( SameString ( ch->pnote->to_list, "" ) ) { writeBuffer ( "You need to provide a recipient (name, all, or immortal).\n\r", ch ); return; } if ( SameString ( ch->pnote->subject, "" ) ) { writeBuffer ( "You need to provide a subject.\n\r", ch ); return; } ch->pnote->next = NULL; strtime = ctime ( ¤t_time ); strtime[strlen ( strtime ) - 1] = '\0'; ch->pnote->date = assign_string ( strtime ); ch->pnote->date_stamp = current_time; append_note ( ch->pnote ); ch->pnote = NULL; return; } writeBuffer ( "You can't do that.\n\r", ch ); return; }