void do_unread(CHAR_DATA *ch) { char buf[MAX_STRING_LENGTH]; int count; bool found = FALSE; if (IS_NPC(ch)) return; if ((count = count_spool(ch,weddings_list)) > 0) { found = TRUE; sprintf(buf,"There %s %d new wedding announcement%s waiting.\n\r", count > 1 ? "are" : "is",count, count > 1 ? "s" : ""); send_to_char(buf,ch); } if ((count = count_spool(ch,news_list)) > 0) { found = TRUE; sprintf(buf,"There %s %d new news article%s waiting.\n\r", count > 1 ? "are" : "is",count, count > 1 ? "s" : ""); send_to_char(buf,ch); } if ((count = count_spool(ch,changes_list)) > 0) { found = TRUE; sprintf(buf,"There %s %d change%s waiting to be read.\n\r", count > 1 ? "are" : "is", count, count > 1 ? "s" : ""); send_to_char(buf,ch); } if ((count = count_spool(ch,note_list)) > 0) { found = TRUE; sprintf(buf,"You have %d new note%s waiting.\n\r", count, count > 1 ? "s" : ""); send_to_char(buf,ch); } if ((count = count_spool(ch,idea_list)) > 0) { found = TRUE; sprintf(buf,"You have %d unread idea%s to peruse.\n\r", count, count > 1 ? "s" : ""); send_to_char(buf,ch); } if (IS_TRUSTED(ch,SQUIRE) && (count = count_spool(ch,penalty_list)) > 0) { found = TRUE; sprintf(buf,"%d %s been added.\n\r", count, count > 1 ? "penalties have" : "penalty has"); send_to_char(buf,ch); } if (!found) send_to_char("You have no unread notes.\n\r",ch); }
void do_unread(CHAR_DATA *ch, char *argument) { if (IS_NPC(ch)) return; send_to_char ( "\ay+\aW-------------------------------\ay+\n\r", ch ); send_to_char ( Format ( "\aW| \aGNews \ay%3d \aW| \aY%3d \aW|\n\r", count_spool_ignore_stamp ( ch, news_list ), count_spool ( ch, news_list ) ), ch ); send_to_char ( Format ( "\aW| \aGChanges \ay%3d \aW| \aY%3d \aW|\n\r", count_spool_ignore_stamp ( ch, changes_list ), count_spool ( ch, changes_list ) ), ch ); send_to_char ( Format ( "\aW| \aGIdeas \ay%3d \aW| \aY%3d \aW|\n\r", count_spool_ignore_stamp ( ch, idea_list ), count_spool ( ch, idea_list ) ), ch ); send_to_char ( Format ( "\aW| \aGNotes \ay%3d \aW| \aY%3d \aW|\n\r", count_spool_ignore_stamp ( ch, note_list ), count_spool ( ch, note_list ) ), ch ); if ( IS_TRUSTED ( ch, ANGEL ) ) { send_to_char ( Format ( "\aW| \aGPenalties \ay%3d \aW| \aY%3d \aW|\n\r", count_spool_ignore_stamp ( ch, penalty_list ), count_spool ( ch, penalty_list ) ), ch ); } send_to_char ( "\ay+\aW-------------------------------\ay+\an\n\r", ch ); }
void do_unread(CHAR_DATA *ch,char *argument) { char buf[MAX_STRING_LENGTH]; int count; if (IS_NPC(ch)) return; sprintf(buf, "{c+----------------------------------------------+{x\n\r" ); send_to_char(buf, ch); sprintf(buf, "{c| |{x\n\r" ); send_to_char(buf,ch); sprintf(buf, "{c| {D>Note Board<{c |{x\n\r" ); send_to_char( buf, ch); sprintf(buf, "{c| |{x\n\r" ); send_to_char(buf,ch); sprintf(buf, "{c+----------------------------------------------+{x\n\r" ); send_to_char( buf, ch); count = count_spool(ch, note_list); sprintf(buf,"{c|{WNotes{x [{D%d{x]{W General OOC Notes {c |{x\n\r",count); send_to_char(buf,ch); count = count_spool(ch,idea_list); sprintf(buf,"{c|{WIdeas{x [{D%d{x]{W Ideas for Improvement {c |{x\n\r",count); send_to_char(buf,ch); count = count_spool(ch,news_list); sprintf(buf,"{c|{WNews{x [{D%d{x]{W News for the MUD {c |{x\n\r",count); send_to_char(buf,ch); count = count_spool(ch,changes_list); sprintf(buf,"{c|{WChanges{x [{D%d{x]{W Changes that have been Made{c |{x\n\r",count); send_to_char(buf,ch); count = count_spoolml(ch,mud_list); sprintf(buf,"{c|{WMud Ads{x [{D%d{x]{W Mud Ads {c |{x\n\r",count); send_to_char(buf,ch); count = count_spool(ch,weddings_list); sprintf(buf,"{c|{WWeddings{x [{D%d{x]{W Weddings {c |{x\n\r",count); send_to_char(buf,ch); if (IS_TRUSTED(ch,SQUIRE)) { count = count_spool(ch,penalty_list); sprintf(buf,"{c|{WPenalties{x [{D%d{x]{W Penalties Added {c |{x\n\r",count); send_to_char(buf,ch); } sprintf( buf, "{c+----------------------------------------------+{x\n\r"); send_to_char(buf, ch); }
void do_unread(CHAR_DATA *ch) { char buf[MAX_STRING_LENGTH]; int count; bool found = FALSE; if (IS_NPC(ch)) return; if ((count = count_spool(ch,news_list)) > 0) { found = TRUE; sprintf(buf,"Nowe nowo¶ci: %d.\n\r", count ); send_to_char(buf,ch); } if ((count = count_spool(ch,changes_list)) > 0) { found = TRUE; sprintf(buf,"Nowe zmiany: %d.\n\r", count ); send_to_char(buf,ch); } if ((count = count_spool(ch,note_list)) > 0) { found = TRUE; sprintf(buf,"Nowe notki: %d.\n\r", count ); send_to_char(buf,ch); } if ((count = count_spool(ch,idea_list)) > 0) { found = TRUE; sprintf(buf,"Nowe pomys³y: %d.\n\r", count ); send_to_char(buf,ch); } if (IS_TRUSTED(ch,ANGEL) && (count = count_spool(ch,penalty_list)) > 0) { found = TRUE; sprintf(buf,"Nowe kary: %d.\n\r", count ); send_to_char(buf,ch); } if (!found) send_to_char("Nie ma nowych wiadomo¶ci.\n\r",ch); }
/* RT Enter portals */ void do_enter( CHAR_DATA *ch, char *argument) { ROOM_INDEX_DATA *location; if ( ch->fighting != NULL ) return; /* nifty portal stuff */ if (argument[0] != '\0') { ROOM_INDEX_DATA *old_room; OBJ_DATA *portal; CHAR_DATA *fch, *fch_next; old_room = ch->in_room; portal = get_obj_list( ch, argument, ch->in_room->contents ); if (portal == NULL) { send_to_char("You don't see that here.\n\r",ch); return; } if (portal->item_type != ITEM_PORTAL || (IS_SET(portal->value[1],EX_CLOSED) && !IS_TRUSTED(ch,KNIGHT))) { send_to_char("You can't seem to find a way in.\n\r",ch); return; } if (!IS_TRUSTED(ch,KNIGHT) && !IS_SET(portal->value[2],GATE_NOCURSE) && IS_AFFECTED(ch,AFF_CURSE) ) { send_to_char("Something prevents you from leaving...\n\r",ch); return; } if (IS_SET(portal->value[2],GATE_RANDOM) || portal->value[3] == -1) { location = get_random_room(ch); portal->value[3] = location->vnum; /* for record keeping :) */ } else if (IS_SET(portal->value[2],GATE_BUGGY) && (number_percent() < 5)) location = get_random_room(ch); else location = get_room_index(portal->value[3]); if (location == NULL || location == old_room || !can_see_room(ch,location) || (room_is_private(ch,location) && !IS_TRUSTED(ch,IMPLEMENTOR))) { act("$p doesn't seem to go anywhere.",ch,portal,NULL,TO_CHAR); return; } if (IS_NPC(ch) && IS_SET(ch->act,ACT_AGGRESSIVE) && IS_SET(location->room_flags,ROOM_LAW)) { send_to_char("Something prevents you from leaving...\n\r",ch); return; } act("$n steps into $p.",ch,portal,NULL,TO_ROOM); if (IS_SET(portal->value[2],GATE_NORMAL_EXIT)) act("You enter $p.",ch,portal,NULL,TO_CHAR); else act("You walk through $p and find yourself somewhere else...", ch,portal,NULL,TO_CHAR); char_from_room(ch); char_to_room(ch, location); if (IS_SET(portal->value[2],GATE_GOWITH)) /* take the gate along */ { obj_from_room(portal); obj_to_room(portal,location); } if (IS_SET(portal->value[2],GATE_NORMAL_EXIT)) act("$n has arrived.",ch,portal,NULL,TO_ROOM); else act("$n has arrived through $p.",ch,portal,NULL,TO_ROOM); do_look(ch,"auto"); /* charges */ if (portal->value[0] > 0) { portal->value[0]--; if (portal->value[0] == 0) portal->value[0] = -1; } /* protect against circular follows */ if (old_room == location) return; for ( fch = old_room->people; fch != NULL; fch = fch_next ) { fch_next = fch->next_in_room; if (portal == NULL || portal->value[0] == -1) /* no following through dead portals */ continue; if ( fch->master == ch && IS_AFFECTED(fch,AFF_CHARM) && fch->position < POS_STANDING) do_stand(fch,""); if ( fch->master == ch && fch->position == POS_STANDING) { if (IS_SET(ch->in_room->room_flags,ROOM_LAW) && (IS_NPC(fch) && IS_SET(fch->act,ACT_AGGRESSIVE))) { act("You can't bring $N into the city.", ch,NULL,fch,TO_CHAR); act("You aren't allowed in the city.", fch,NULL,NULL,TO_CHAR); continue; } act( "You follow $N.", fch, NULL, ch, TO_CHAR ); do_enter(fch,argument); } } if (portal != NULL && portal->value[0] == -1) { act("$p fades out of existence.",ch,portal,NULL,TO_CHAR); if (ch->in_room == old_room) act("$p fades out of existence.",ch,portal,NULL,TO_ROOM); else if (old_room->people != NULL) { act("$p fades out of existence.", old_room->people,portal,NULL,TO_CHAR); act("$p fades out of existence.", old_room->people,portal,NULL,TO_ROOM); } extract_obj(portal); } /* * If someone is following the char, these triggers get activated * for the followers before the char, but it's safer this way... */ if ( IS_NPC( ch ) && HAS_TRIGGER( ch, TRIG_ENTRY ) ) mp_percent_trigger( ch, NULL, NULL, NULL, TRIG_ENTRY ); if ( !IS_NPC( ch ) ) mp_greet_trigger( ch ); return; } send_to_char("Nope, can't do it.\n\r",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 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 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; }