/* 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_comment( CHAR_DATA * ch, char *argument ) { char buf[MAX_STRING_LENGTH]; char arg[MAX_INPUT_LENGTH]; char arg1[MAX_INPUT_LENGTH]; NOTE_DATA *pnote; CHAR_DATA *victim; int vnum; int anum; if( IS_NPC( ch ) ) { send_to_char( "Mobs can't use the comment command.\r\n", ch ); return; } if( !ch->desc ) { bug( "do_comment: no descriptor", 0 ); return; } /* * Put in to prevent crashing when someone issues a comment command * from within the editor. -Narn */ if( ch->desc->connected == CON_EDITING || ch->desc->connected == CON_NOTE_TO ) { send_to_char( "You can't use the comment command from within the editor.\r\n", ch ); return; } switch ( ch->substate ) { default: break; case SUB_WRITING_NOTE: if( !ch->pnote ) { bug( "do_comment: note got lost?", 0 ); send_to_char( "Your note got lost!\r\n", ch ); stop_editing( ch ); return; } if( ch->dest_buf != ch->pnote ) bug( "do_comment: sub_writing_note: ch->dest_buf != ch->pnote", 0 ); STRFREE( ch->pnote->text ); ch->pnote->text = copy_buffer( ch ); stop_editing( ch ); return; } set_char_color( AT_NOTE, ch ); argument = one_argument( argument, arg ); smash_tilde( argument ); if( !str_cmp( arg, "about" ) ) { victim = get_char_world( ch, argument ); if( !victim ) { send_to_char( "They're not logged on!\r\n", ch ); /* maybe fix this? */ return; } if( IS_NPC( victim ) ) { send_to_char( "No comments about mobs\r\n", ch ); return; } } if( !str_cmp( arg, "list" ) ) { victim = get_char_world( ch, argument ); if( !victim ) { send_to_char( "They're not logged on!\r\n", ch ); /* maybe fix this? */ return; } if( IS_NPC( victim ) ) { send_to_char( "No comments about mobs\r\n", ch ); return; } if( get_trust( victim ) >= get_trust( ch ) ) { send_to_char( "You're not of the right caliber to do this...\r\n", ch ); return; } if( !victim->comments ) { send_to_char( "There are no relevant comments.\r\n", ch ); return; } vnum = 0; for( pnote = victim->comments; pnote; pnote = pnote->next ) { vnum++; sprintf( buf, "%2d) %-10s [%s] %s\r\n", vnum, pnote->sender, pnote->date, pnote->subject ); /* Brittany added date to comment list and whois with above change */ send_to_char( buf, ch ); } /* * act( AT_ACTION, "$n glances over the notes.", ch, NULL, NULL, TO_ROOM ); */ return; } if( !str_cmp( arg, "read" ) ) { bool fAll; argument = one_argument( argument, arg1 ); victim = get_char_world( ch, arg1 ); if( !victim ) { send_to_char( "They're not logged on!\r\n", ch ); /* maybe fix this? */ return; } if( IS_NPC( victim ) ) { send_to_char( "No comments about mobs\r\n", ch ); return; } if( get_trust( victim ) >= get_trust( ch ) ) { send_to_char( "You're not of the right caliber to do this...\r\n", ch ); return; } if( !victim->comments ) { send_to_char( "There are no relevant comments.\r\n", ch ); return; } 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?\r\n", ch ); return; } vnum = 0; for( pnote = victim->comments; pnote; pnote = pnote->next ) { vnum++; if( vnum == anum || fAll ) { sprintf( buf, "[%3d] %s: %s\r\n%s\r\nTo: %s\r\n", vnum, pnote->sender, pnote->subject, pnote->date, pnote->to_list ); send_to_char( buf, ch ); send_to_char( pnote->text, ch ); /* * act( AT_ACTION, "$n reads a note.", ch, NULL, NULL, TO_ROOM ); */ return; } } send_to_char( "No such comment.\r\n", ch ); return; } if( !str_cmp( arg, "write" ) ) { note_attach( ch ); ch->substate = SUB_WRITING_NOTE; ch->dest_buf = ch->pnote; start_editing( ch, ch->pnote->text ); return; } if( !str_cmp( arg, "subject" ) ) { note_attach( ch ); STRFREE( ch->pnote->subject ); ch->pnote->subject = STRALLOC( argument ); send_to_char( "Ok.\r\n", ch ); return; } if( !str_cmp( arg, "to" ) ) { note_attach( ch ); STRFREE( ch->pnote->to_list ); ch->pnote->to_list = STRALLOC( argument ); send_to_char( "Ok.\r\n", ch ); return; } if( !str_cmp( arg, "clear" ) ) { if( ch->pnote ) { STRFREE( ch->pnote->text ); STRFREE( ch->pnote->subject ); STRFREE( ch->pnote->to_list ); STRFREE( ch->pnote->date ); STRFREE( ch->pnote->sender ); DISPOSE( ch->pnote ); } ch->pnote = NULL; send_to_char( "Ok.\r\n", ch ); return; } if( !str_cmp( arg, "show" ) ) { if( !ch->pnote ) { send_to_char( "You have no comment in progress.\r\n", ch ); return; } sprintf( buf, "%s: %s\r\nTo: %s\r\n", 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" ) ) { char *strtime; if( !ch->pnote ) { send_to_char( "You have no comment in progress.\r\n", ch ); return; } argument = one_argument( argument, arg1 ); victim = get_char_world( ch, arg1 ); if( !victim ) { send_to_char( "They're not logged on!\r\n", ch ); /* maybe fix this? */ return; } if( IS_NPC( victim ) ) { send_to_char( "No comments about mobs\r\n", ch ); return; } if( get_trust( victim ) > get_trust( ch ) ) { send_to_char( "You're not of the right caliber to do this...\r\n", ch ); return; } /* * act( AT_ACTION, "$n posts a note.", ch, NULL, NULL, TO_ROOM ); */ strtime = ctime( ¤t_time ); strtime[strlen( strtime ) - 1] = '\0'; ch->pnote->date = STRALLOC( strtime ); pnote = ch->pnote; ch->pnote = NULL; /* * LIFO to make life easier */ pnote->next = victim->comments; if( victim->comments ) victim->comments->prev = pnote; pnote->prev = NULL; victim->comments = pnote; save_char_obj( victim ); #ifdef NOTDEFD fclose( fpReserve ); sprintf( notefile, "%s/%s", BOARD_DIR, board->note_file ); if( ( fp = fopen( notefile, "a" ) ) == NULL ) { perror( notefile ); } else { fprintf( fp, "Sender %s~\nDate %s~\nTo %s~\nSubject %s~\nText\n%s~\n\n", pnote->sender, pnote->date, pnote->to_list, pnote->subject, pnote->text ); fclose( fp ); } fpReserve = fopen( NULL_FILE, "r" ); #endif send_to_char( "Ok.\r\n", ch ); return; } if( !str_cmp( arg, "remove" ) ) { argument = one_argument( argument, arg1 ); victim = get_char_world( ch, arg1 ); if( !victim ) { send_to_char( "They're not logged on!\r\n", ch ); /* maybe fix this? */ return; } if( IS_NPC( victim ) ) { send_to_char( "No comments about mobs\r\n", ch ); return; } if( ( get_trust( victim ) >= get_trust( ch ) ) || ( get_trust( ch ) < 58 ) ) /* switch to some LEVEL_ thingie */ { send_to_char( "You're not of the right caliber to do this...\r\n", ch ); return; } /* * argument = one_argument(argument, arg); */ if( !is_number( argument ) ) { send_to_char( "Comment remove which number?\r\n", ch ); return; } anum = atoi( argument ); vnum = 0; for( pnote = victim->comments; pnote; pnote = pnote->next ) { vnum++; if( ( 58 <= get_trust( ch ) ) /* switch to some LEVEL_ thingie */ && ( vnum == anum ) ) { comment_remove( victim, pnote ); send_to_char( "Ok.\r\n", ch ); /* * act( AT_ACTION, "$n removes a note.", ch, NULL, NULL, TO_ROOM ); */ return; } } send_to_char( "No such comment.\r\n", ch ); return; } send_to_char( "Type 'help comment' for usage (i hope!).\r\n", ch ); return; }
void do_mapout( CHAR_DATA* ch, const char* argument) { char arg[MAX_INPUT_LENGTH]; OBJ_DATA *map_obj; /* an obj made with map as an ed */ OBJ_INDEX_DATA *map_obj_index; /* obj_index for previous */ EXTRA_DESCR_DATA *ed; /* the ed for it to go in */ int rooms, rows, cols, avail_rooms; if( !ch ) { bug( "%s", "do_mapout: null ch" ); return; } if( IS_NPC( ch ) ) { send_to_char( "Not in mobs.\r\n", ch ); return; } if( !ch->desc ) { bug( "%s", "do_mapout: no descriptor" ); return; } switch ( ch->substate ) { default: break; case SUB_WRITING_NOTE: if( ch->dest_buf != ch->pnote ) bug( "%s", "do_mapout: sub_writing_map: ch->dest_buf != ch->pnote" ); STRFREE( ch->pnote->text ); ch->pnote->text = copy_buffer( ch ); stop_editing( ch ); return; } set_char_color( AT_NOTE, ch ); argument = one_argument( argument, arg ); smash_tilde( argument ); if( !str_cmp( arg, "stat" ) ) { if( !ch->pnote ) { send_to_char( "You have no map in progress.\r\n", ch ); return; } map_stats( ch, &rooms, &rows, &cols ); ch_printf( ch, "Map represents %d rooms, %d rows, and %d columns\r\n", rooms, rows, cols ); avail_rooms = num_rooms_avail( ch ); ch_printf( ch, "You currently have %d unused rooms.\r\n", avail_rooms ); act( AT_ACTION, "$n glances at an etherial map.", ch, NULL, NULL, TO_ROOM ); return; } if( !str_cmp( arg, "write" ) ) { note_attach( ch ); ch->substate = SUB_WRITING_NOTE; ch->dest_buf = ch->pnote; start_editing( ch, ch->pnote->text ); return; } if( !str_cmp( arg, "clear" ) ) { if( !ch->pnote ) { send_to_char( "You have no map in progress\r\n", ch ); return; } STRFREE( ch->pnote->text ); STRFREE( ch->pnote->subject ); STRFREE( ch->pnote->to_list ); STRFREE( ch->pnote->date ); STRFREE( ch->pnote->sender ); DISPOSE( ch->pnote ); ch->pnote = NULL; send_to_char( "Map cleared.\r\n", ch ); return; } if( !str_cmp( arg, "show" ) ) { if( !ch->pnote ) { send_to_char( "You have no map in progress.\r\n", ch ); return; } send_to_char( ch->pnote->text, ch ); do_mapout( ch, "stat" ); return; } if( !str_cmp( arg, "create" ) ) { if( !ch->pnote ) { send_to_char( "You have no map in progress.\r\n", ch ); return; } map_stats( ch, &rooms, &rows, &cols ); avail_rooms = num_rooms_avail( ch ); /* * check for not enough rooms */ if( rooms > avail_rooms ) { send_to_char( "You don't have enough unused rooms allocated!\r\n", ch ); return; } act( AT_ACTION, "$n warps the very dimensions of space!", ch, NULL, NULL, TO_ROOM ); map_to_rooms( ch, NULL ); /* this does the grunt work */ map_obj_index = get_obj_index( 91 ); if( map_obj_index ) { map_obj = create_object( map_obj_index, 0 ); ed = SetOExtra( map_obj, "runes map scrawls" ); STRFREE( ed->description ); ed->description = QUICKLINK( ch->pnote->text ); obj_to_char( map_obj, ch ); } else { send_to_char( "Couldn't give you a map object. Need Great Eastern Desert\r\n", ch ); return; } do_mapout( ch, "clear" ); send_to_char( "Ok.\r\n", ch ); return; } send_to_char( "mapout write: create a map in edit buffer.\r\n", ch ); send_to_char( "mapout stat: get information about a written, but not yet created map.\r\n", ch ); send_to_char( "mapout clear: clear a written, but not yet created map.\r\n", ch ); send_to_char( "mapout show: show a written, but not yet created map.\r\n", ch ); send_to_char( "mapout create: turn a written map into rooms in your assigned room vnum range.\r\n", ch ); return; }
void parse_note( CHAR_DATA *ch, char *argument, int type ) { BUFFER *buffer; char buf[MAX_STRING_LENGTH], query[MSL]; char arg[MAX_INPUT_LENGTH]; MYSQL_RES *res; MYSQL_ROW row; char *list_name; int vnum; int anum; switch(type) { default: return; case NOTE_NOTE: list_name = "notes"; break; case NOTE_IDEA: list_name = "ideas"; break; case NOTE_PENALTY: list_name = "penalties"; break; case NOTE_NEWS: list_name = "news"; break; case NOTE_CHANGES: 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; sprintf(query,"SELECT * FROM notes WHERE type=%d ORDER BY timestamp ASC",type); res = one_query_res(query); while((row=mysql_fetch_row(res))) { if (!hide_note(ch,row)) { sprintf( buf, "[%3d] %s: %s\n\r%s\n\rTo: %s\n\r", vnum, row[1], row[4], row[2], row[3]); send_to_char( buf, ch ); page_to_char( row[5], ch ); update_read(ch,atol(row[6]),atoi(row[0])); mysql_free_result(res); return; } else if(is_note_to(ch,row[1],row[3])) vnum++; } sprintf(buf,"You have no unread %s.\n\r",list_name); send_to_char(buf,ch); mysql_free_result(res); return; } else if ( is_number( argument ) ) { fAll = FALSE; anum = atoi( argument ); } else { send_to_char( "Read which number?\n\r", ch ); return; } vnum = 0; sprintf(query,"SELECT * FROM notes WHERE type=%d ORDER BY timestamp ASC",type); res = one_query_res(query); while((row=mysql_fetch_row(res))) { if (is_note_to(ch,row[1],row[3]) && (vnum++ == anum)) { sprintf( buf, "[%3d] %s: %s\n\r%s\n\rTo: %s\n\r", anum, row[1], row[4], row[2], row[3]); send_to_char( buf, ch ); page_to_char( row[5], ch ); update_read(ch,atol(row[6]),atoi(row[0])); mysql_free_result(res); return; } } sprintf(buf,"There aren't that many %s.\n\r",list_name); send_to_char(buf,ch); mysql_free_result(res); return; } if ( !str_prefix( arg, "list" ) ) { vnum = 0; sprintf(query,"SELECT * FROM notes WHERE type=%d ORDER BY timestamp ASC",type); res = one_query_res(query); while((row=mysql_fetch_row(res))) { if (is_note_to(ch,row[1],row[3])) { sprintf( buf, "[%3d%s] %s: %s\n\r", vnum, hide_note(ch,row) ? " " : "N", row[1], row[4]); send_to_char( buf, 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; } } mysql_free_result(res); return; } if ( !str_prefix( arg, "remove" ) ) { if ( !is_number( argument ) ) return send_to_char( "Note remove which number?\n\r", ch ); anum = atoi( argument ); vnum = 0; sprintf(query,"SELECT * FROM notes WHERE type=%d ORDER BY timestamp ASC",type); res = one_query_res(query); while((row=mysql_fetch_row(res))) { if (!str_cmp(ch->true_name, row[1]) && vnum++ == anum ) { sprintf(query,"DELETE FROM notes WHERE timestamp=%s AND sender=\"%s\"", row[6], row[1]); one_query(query); send_to_char( "Ok.\n\r", ch ); mysql_free_result(res); return; } } send_to_char("You must provide the number of a note you have written to remove.\n\r",ch); mysql_free_result(res); return; } if ( !str_prefix( arg, "delete" ) && get_trust(ch) >= MAX_LEVEL - 2) { if ( !is_number( argument ) ) return send_to_char( "Note delete which number?\n\r", ch ); anum = atoi( argument ); vnum = 0; sprintf(query,"SELECT * FROM notes WHERE type=%d ORDER BY timestamp ASC",type); res = one_query_res(query); while((row=mysql_fetch_row(res))) { if ( is_note_to( ch,row[1],row[3] ) && vnum++ == anum ) { sprintf(query,"DELETE FROM notes WHERE timestamp=%s AND sender=\"%s\"", row[6], row[1]); one_query(query); send_to_char("Ok.\n\r",ch); mysql_free_result(res); return; } } sprintf(buf,"There aren't that many %s.\n\r",list_name); send_to_char(buf,ch); mysql_free_result(res); 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,"You aren't high enough level to write %s.",list_name); send_to_char(buf,ch); return; } if ( !str_cmp( arg, "+" ) ) { note_attach( ch,type ); if (ch->pnote->type != type) return send_to_char("You already have a different note in progress.\n\r",ch); if (strlen(ch->pnote->text)+strlen(argument) >= 4096) return send_to_char( "Note too long.\n\r", ch ); buffer = new_buf(); add_buf(buffer,ch->pnote->text); add_buf(buffer,argument); add_buf(buffer,"\n\r"); free_pstring( ch->pnote->text ); ch->pnote->text = palloc_string( buf_string(buffer) ); free_buf(buffer); send_to_char( "Ok.\n\r", ch ); return; } if (!str_cmp(arg,"-")) { int len; bool found = FALSE; note_attach(ch,type); if (ch->pnote->type != type) return send_to_char("You already have a different note in progress.\n\r",ch); if (ch->pnote->text == NULL || ch->pnote->text[0] == '\0') return send_to_char("No lines left to remove.\n\r",ch); 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_pstring(ch->pnote->text); ch->pnote->text = palloc_string(buf); return; } } } buf[0] = '\0'; free_pstring(ch->pnote->text); ch->pnote->text = palloc_string(buf); return; } if ( !str_prefix( arg, "subject" ) ) { note_attach( ch,type ); if (ch->pnote->type != type) return send_to_char("You already have a different note in progress.\n\r",ch); free_pstring( ch->pnote->subject ); ch->pnote->subject = palloc_string( argument ); send_to_char( "Ok.\n\r", ch ); return; } if ( !str_prefix( arg, "to" ) ) { note_attach( ch,type ); if (ch->pnote->type != type) return send_to_char("You already have a different note in progress.\n\r",ch); if (is_name("all", argument) && !IS_IMMORTAL(ch) && !IS_HEROIMM(ch) && !(ch->pcdata->induct == CABAL_LEADER)) return send_to_char("Sorry, you can't do that!\n\r",ch); if (is_number(argument) && !IS_IMMORTAL(ch)) return send_to_char("You can't do that.\n\r",ch); free_pstring( ch->pnote->to_list ); ch->pnote->to_list = palloc_string( argument ); send_to_char( "Ok.\n\r", ch ); return; } if ( !str_prefix( arg, "clear" ) ) { if ( ch->pnote != NULL ) { free_note(ch->pnote); ch->pnote = NULL; } send_to_char( "Ok.\n\r", ch ); return; } if ( !str_prefix( arg, "show" ) ) { if ( ch->pnote == NULL ) return send_to_char( "You have no note in progress.\n\r", ch ); if (ch->pnote->type != type) return send_to_char("You aren't working on that kind of note.\n\r",ch); 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_prefix( arg, "post" ) || !str_prefix(arg, "send")) { char *strtime; if ( ch->pnote == NULL ) return send_to_char( "You have no note in progress.\n\r", ch ); if (ch->pnote->type != type) return send_to_char("You aren't working on that kind of note.\n\r",ch); if (!str_cmp(ch->pnote->to_list,"")) return send_to_char("You need to provide a recipient (name, all, or immortal).\n\r", ch); if (!str_cmp(ch->pnote->subject,"")) return send_to_char("You need to provide a subject.\n\r",ch); if (is_affected_prof(ch, "note_written") && !IS_IMMORTAL(ch)) return send_to_char("You have written a note too recently.\n\r",ch); ch->pnote->next = NULL; strtime = ctime( ¤t_time ); strtime[strlen(strtime)-1] = '\0'; ch->pnote->date = palloc_string( strtime ); ch->pnote->date_stamp = current_time; append_note(ch->pnote); ch->pnote = NULL; send_to_char("Note sent.\n\r",ch); add_prof_affect(ch, "note_written", 4, TRUE); return; } send_to_char( "You can't do that.\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_project( CHAR_DATA *ch, char *argument ) { char arg[MAX_INPUT_LENGTH]; char arg1[MAX_INPUT_LENGTH]; char arg2[MAX_INPUT_LENGTH]; char buf[MSL]; int pcount; int pnum; PROJECT_DATA *pproject; if( IS_NPC( ch ) ) return; if( !ch->desc ) { bug( "do_project: no descriptor", 0 ); return; } argument = one_argument( argument, arg ); smash_tilde( argument ); if( !str_cmp( arg, "save" ) ) { write_projects(); send_to_char ("Projects saved.\n\r",ch); return; } if ( !str_cmp( arg, "code" ) ) { pcount = 0; send_to_char( " ## | Owner | Project |\n\r",ch); send_to_char( "---|-------------|----------------------|--------------------------|-----------\n\r",ch); for( pproject = first_project; pproject; pproject = pproject->next ) { pcount++; if ( (pproject->status && str_cmp(pproject->status, "approved")) || pproject->coder != NULL) continue; xprintf(buf, "%2d | %-11s | %-20s |\n\r", pcount, pproject->owner ? pproject->owner : "(None)", pproject->name); send_to_char(buf, ch); } return; } if ( !str_cmp( arg, "more" ) || !str_cmp( arg, "mine" ) ) { NOTE_DATA *log; bool MINE = FALSE; int num_logs=0; pcount = 0; if ( !str_cmp( arg, "mine" ) ) MINE = TRUE; send_to_char("\n\r",ch); send_to_char( " ## | Owner | Project | Coder | Status | # of Logs\n\r",ch); send_to_char( "---|-------------|----------------------|---------------|------------|----------\n\r", ch); for( pproject = first_project; pproject; pproject = pproject->next ) { pcount++; if ( MINE &&(!pproject->owner||str_cmp( ch->name,pproject->owner)) && (!pproject->coder || str_cmp( ch->name, pproject->coder)) ) continue; else if (!MINE && pproject->status && !str_cmp("Done", pproject->status ) ) continue; num_logs = 0; for ( log = pproject->first_log; log; log=log->next ) num_logs++; xprintf(buf, "%2d | %-11s | %-20s | %-13s | %-10s | %3d\n\r", pcount, pproject->owner ? pproject->owner : "(None)", pproject->name, pproject->coder ? pproject->coder : "(None)", pproject->status ? pproject->status : "(None)", num_logs); send_to_char(buf, ch); } return; } if( arg[0] == '\0' || !str_cmp( arg, "list" ) ) { bool aflag, projects_available; aflag = FALSE; projects_available = FALSE; if( !str_cmp( argument, "available" ) ) aflag = TRUE; send_to_char("\n\r",ch); if( !aflag ) { send_to_char( " ## | Owner | Project | Date | Status\n\r",ch); send_to_char( "---|-------------|----------------------|--------------------------|-----------\n\r",ch); } else { send_to_char(" ## | Project | Date\n\r",ch); send_to_char( "---|----------------------|--------------------------\n\r",ch); } pcount = 0; for( pproject = first_project; pproject; pproject = pproject->next ) { pcount++; if (pproject->status && !str_cmp("Done", pproject->status ) ) continue; if(!aflag) xprintf(buf, "%2d | %-11s | %-20s | %-24s | %-10s\n\r", pcount, pproject->owner ? pproject->owner : "(None)", pproject->name, pproject->date, pproject->status ? pproject->status : "(None)"); else if( !pproject->taken ) { if( !projects_available ) projects_available = TRUE; xprintf(buf, "%2d | %-20s | %s\n\r", pcount, pproject->name, pproject->date); } send_to_char(buf, ch); } if(pcount == 0) send_to_char("No projects exist.\n\r",ch); else if( aflag && !projects_available ) send_to_char("No projects available.\n\r",ch); return; } if( !str_cmp( arg, "add" ) ) { char *strtime; PROJECT_DATA *new_project; /* Just to be safe */ if( get_trust(ch) < LEVEL_JUDGE) { send_to_char("You are not powerfull enough to add a new project.\n\r",ch); return; } new_project = alloc_mem( sizeof( PROJECT_DATA)); LINK( new_project, first_project, last_project, next, prev ); new_project->name = str_dup(argument); new_project->coder = NULL; new_project->taken = FALSE; new_project->owner = NULL; new_project->status = NULL; new_project->description = str_dup( "" ); new_project->first_log = NULL; new_project->last_log = NULL; strtime = ctime( ¤t_time ); strtime[strlen(strtime)-1] = '\0'; new_project->date = str_dup( strtime ); write_projects(); send_to_char("Ok.\n\r",ch ); return; } if( !is_number( arg ) ) { send_to_char("Invalid project.\n\r",ch); return; } pnum = atoi( arg ); pproject = get_project_by_number( pnum ); if(!pproject) { send_to_char("No such project.\n\r",ch); return; } argument = one_argument( argument, arg1 ); if( !str_cmp( arg1, "desc" ) ) { if ( pproject->description == NULL ) pproject->description = str_dup(""); string_append( ch, &pproject->description ); return; } if( !str_cmp( arg1, "delete" ) ) { NOTE_DATA *log, *tlog; if( get_trust(ch) < LEVEL_HIGHJUDGE) { send_to_char("You are not high enough level to delete a project.\n\r", ch ); return; } tlog = NULL; for( log = pproject->first_log; log; tlog = log, log = log->next ) { if ( tlog == NULL ) pproject->first_log = log->next; else tlog->next = log->next; free_note( log ); } pproject->last_log = NULL; UNLINK( pproject, first_project, last_project, next, prev ); free_string( pproject->name ); if ( pproject->coder ) free_string( pproject->coder ); if( pproject->owner ) free_string( pproject->owner ); if( pproject->description ) free_string( pproject->description ); if ( pproject->date ) free_string( pproject->date ); if ( pproject->status ) free_string( pproject->status ); free_mem( pproject, sizeof( *pproject) ); write_projects(); send_to_char("Ok.\n\r",ch ); return; } if( !str_cmp( arg1, "take" ) ) { if( pproject->taken && pproject->owner && !str_cmp(pproject->owner, ch->name ) ) { pproject->taken = FALSE; free_string( pproject->owner ); pproject->owner = NULL; send_to_char("You removed yourself as the owner.\n\r", ch ); write_projects(); return; } else if ( pproject->taken ) { send_to_char("This project is already taken.\n\r" ,ch); return; } if( pproject->owner ) free_string( pproject->owner ); pproject->owner = str_dup( ch->name ); pproject->taken = TRUE; write_projects(); send_to_char("Ok.\n\r" ,ch); return; } if( !str_cmp( arg1, "coder" ) ) { if ( pproject->coder && !str_cmp(ch->name, pproject->coder)) { free_string( pproject->coder ); pproject->coder = NULL; send_to_char("You removed yourself as the coder.\n\r", ch ); write_projects(); return; } else if ( pproject->coder ) { send_to_char("This project already has a coder.\n\r",ch ); return; } pproject->coder = str_dup( ch->name ); write_projects(); send_to_char("Ok.\n\r" ,ch); return; } if( !str_cmp( arg1, "status" ) ) { if( pproject->owner && str_cmp( pproject->owner, ch->name ) && get_trust(ch) < LEVEL_JUDGE && pproject->coder && str_cmp(pproject->coder, ch->name) ) { send_to_char("This is not your project!\n\r",ch ); return; } if(pproject->status) free_string(pproject->status); pproject->status = str_dup(argument); write_projects(); send_to_char("Done.\n\r", ch ); return; } if( !str_cmp( arg1, "show" ) ) { if ( pproject->description ) send_to_char ( pproject->description, ch ); else send_to_char ("That project does not have a description.\n\r",ch); return; } if( !str_cmp( arg1, "log" ) ) { NOTE_DATA *plog,*tlog; if( !str_cmp( argument, "write" ) ) { string_append( ch, &ch->pnote->text); return; } argument = one_argument( argument, arg2 ); if( !str_cmp( arg2, "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( arg2, "post" ) ) { char *strtime; if( pproject->owner && str_cmp(ch->name, pproject->owner) && pproject->coder && str_cmp(ch->name, pproject->coder) && get_trust(ch) < LEVEL_JUDGE ) { send_to_char("This is not your project!\n\r",ch ); return; } if ( !ch->pnote ) { send_to_char("You have no log in progress.\n\r" ,ch); return; } if ( !ch->pnote->subject ) { send_to_char( "Your log has no subject.\n\r",ch ); return; } strtime = ctime( ¤t_time ); strtime[strlen(strtime)-1] = '\0'; ch->pnote->date = str_dup( strtime ); ch->pnote->sender = ch->name; plog = ch->pnote; ch->pnote = NULL; if( !pproject->first_log ) pproject->first_log = plog; else { for( tlog = pproject->first_log; tlog->next; tlog = tlog->next ) ; tlog->next = plog; } plog->next = NULL; pproject->last_log = plog; write_projects(); send_to_char("Ok.\n\r",ch); return; } if( !str_cmp( arg2, "list" ) ) { if( pproject->owner && pproject->coder && str_cmp(ch->name, pproject->owner) && get_trust(ch) < LEVEL_BUILDER && str_cmp(ch->name, pproject->coder) ) { send_to_char("This is not your project!\n\r",ch ); return; } pcount = 0; xprintf(buf, "Project: %-12s: %s\n\r", pproject->owner ? pproject->owner : "(None)", pproject->name); send_to_char(buf,ch); for( plog = pproject->first_log; plog; plog = plog->next ) { pcount++; xprintf( buf, "%2d) %-12s: %s\n\r", pcount, plog->sender, plog->subject ); send_to_char(buf,ch); } if( pcount == 0 ) send_to_char("No logs available.\n\r",ch ); return; } if( !is_number( arg2 )) { send_to_char("Invalid log.\n\r",ch ); return; } pnum = atoi( arg2 ); plog = get_log_by_number( pproject, pnum ); if( !plog ) { send_to_char("Invalid log.\n\r",ch ); return; } if( !str_cmp( argument, "delete" ) ) { if( pproject->owner && str_cmp(ch->name, pproject->owner) && get_trust(ch) < LEVEL_JUDGE && pproject->coder && str_cmp(ch->name, pproject->coder ) ) { send_to_char("This is not your project!\n\r",ch ); return; } for( tlog = pproject->first_log; tlog->next; tlog = tlog->next ) if( tlog->next == plog ) break; tlog->next = plog->next; free_note( plog ); write_projects(); send_to_char("Ok.\n\r",ch ); return; } if( !str_cmp( argument, "read" ) ) { if( pproject->owner && pproject->coder && str_cmp(ch->name, pproject->owner) && get_trust(ch) < LEVEL_BUILDER && str_cmp(ch->name, pproject->coder ) ) { send_to_char("This is not your project!\n\r" ,ch); return; } xprintf( buf, "[%3d] %s: %s\n\r%s\n\r%s", pnum, plog->sender, plog->subject, plog->date, plog->text ); send_to_char(buf,ch); return; } } send_to_char("Unknown syntax see help 'PROJECT'.\n\r", ch ); return; }
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; }