#include <sys/types.h>
#include <sys/time.h>
#include <ctype.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <time.h>
#include "merc.h"
#include "recycle.h"
#include "tables.h"
Include dependency graph for note.c:

Go to the source code of this file.
Functions | |
| void | append_note (NOTE_DATA *pnote) |
| int _filbuf | args ((FILE *)) |
| int | count_spool (CHAR_DATA *ch, NOTE_DATA *spool) |
| void | do_catchup (CHAR_DATA *ch, char *argument) |
| void | do_changes (CHAR_DATA *ch, char *argument) |
| void | do_history (CHAR_DATA *ch, char *argument) |
| void | do_idea (CHAR_DATA *ch, char *argument) |
| void | do_news (CHAR_DATA *ch, char *argument) |
| void | do_note (CHAR_DATA *ch, char *argument) |
| void | do_penalty (CHAR_DATA *ch, char *argument) |
| void | do_unread (CHAR_DATA *ch) |
| bool | hide_note (CHAR_DATA *ch, NOTE_DATA *pnote) |
| bool | is_note_to (CHAR_DATA *ch, NOTE_DATA *pnote) |
| void | load_notes (void) |
| void | load_thread (char *name, NOTE_DATA **list, int type, time_t free_time) |
| void | note_attach (CHAR_DATA *ch, int type) |
| void | note_remove (CHAR_DATA *ch, NOTE_DATA *pnote, bool delete) |
| void | parse_note (CHAR_DATA *ch, char *argument, int type) |
| void | save_notes (int type) |
| void | update_read (CHAR_DATA *ch, NOTE_DATA *pnote) |
Variables | |
| NOTE_DATA * | changes_list |
| FILE * | fpArea |
| NOTE_DATA * | history_list |
| NOTE_DATA * | idea_list |
| NOTE_DATA * | news_list |
| NOTE_DATA * | note_list |
| NOTE_DATA * | penalty_list |
| char | strArea [MAX_INPUT_LENGTH] |
|
|
Definition at line 300 of file note.c. References CHANGES_FILE, changes_list, fpReserve, HISTORY_FILE, history_list, IDEA_FILE, idea_list, NEWS_FILE, news_list, note_data::next, NOTE_CHANGES, NOTE_FILE, NOTE_HISTORY, NOTE_IDEA, note_list, NOTE_NEWS, NOTE_NOTE, NOTE_PENALTY, PENALTY_FILE, and penalty_list. Referenced by parse_note(). 00301 {
00302 FILE *fp;
00303 char *name;
00304 NOTE_DATA **list;
00305 NOTE_DATA *last;
00306
00307 switch(pnote->type)
00308 {
00309 default:
00310 return;
00311 case NOTE_NOTE:
00312 name = NOTE_FILE;
00313 list = ¬e_list;
00314 break;
00315 case NOTE_IDEA:
00316 name = IDEA_FILE;
00317 list = &idea_list;
00318 break;
00319 case NOTE_PENALTY:
00320 name = PENALTY_FILE;
00321 list = &penalty_list;
00322 break;
00323 case NOTE_NEWS:
00324 name = NEWS_FILE;
00325 list = &news_list;
00326 break;
00327 case NOTE_CHANGES:
00328 name = CHANGES_FILE;
00329 list = &changes_list;
00330 break;
00331 case NOTE_HISTORY:
00332 name = HISTORY_FILE;
00333 list = &history_list;
00334 break;
00335 }
00336
00337 if (*list == NULL)
00338 *list = pnote;
00339 else
00340 {
00341 for ( last = *list; last->next != NULL; last = last->next);
00342 last->next = pnote;
00343 }
00344
00345 fclose(fpReserve);
00346 if ( ( fp = fopen(name, "a" ) ) == NULL )
00347 {
00348 perror(name);
00349 }
00350 else
00351 {
00352 fprintf( fp, "Sender %s~\n", pnote->sender);
00353 fprintf( fp, "Date %s~\n", pnote->date);
00354 fprintf( fp, "Stamp %ld\n", pnote->date_stamp);
00355 fprintf( fp, "To %s~\n", pnote->to_list);
00356 fprintf( fp, "Subject %s~\n", pnote->subject);
00357 fprintf( fp, "Text\n%s~\n", pnote->text);
00358 fclose( fp );
00359 }
00360 fpReserve = fopen( NULL_FILE, "r" );
00361 }
|
|
|
|
|
||||||||||||
|
Definition at line 61 of file note.c. References hide_note(), and note_data::next. Referenced by do_unread(). 00062 {
00063 int count = 0;
00064 NOTE_DATA *pnote;
00065
00066 for (pnote = spool; pnote != NULL; pnote = pnote->next)
00067 if (!hide_note(ch,pnote))
00068 count++;
00069
00070 return count;
00071 }
|
Here is the call graph for this function:

|
||||||||||||
|
Definition at line 568 of file note.c. References current_time, and send_to_char(). 00569 {
00570 ch->pcdata->last_note = current_time;
00571 ch->pcdata->last_history = current_time;
00572 ch->pcdata->last_penalty = current_time;
00573 ch->pcdata->last_idea = current_time;
00574 ch->pcdata->last_changes = current_time;
00575 ch->pcdata->last_news = current_time;
00576 send_to_char("All note spools have been caught up.\n\r",ch);
00577 return;
00578 }
|
Here is the call graph for this function:

|
||||||||||||
|
Definition at line 149 of file note.c. References NOTE_CHANGES, and parse_note(). 00150 {
00151 parse_note(ch,argument,NOTE_CHANGES);
00152 }
|
Here is the call graph for this function:

|
||||||||||||
|
Definition at line 154 of file note.c. References NOTE_HISTORY, and parse_note(). 00155 {
00156 parse_note(ch, argument, NOTE_HISTORY);
00157 }
|
Here is the call graph for this function:

|
||||||||||||
|
Definition at line 134 of file note.c. References NOTE_IDEA, and parse_note(). 00135 {
00136 parse_note(ch,argument,NOTE_IDEA);
00137 }
|
Here is the call graph for this function:

|
||||||||||||
|
Definition at line 144 of file note.c. References NOTE_NEWS, and parse_note(). 00145 {
00146 parse_note(ch,argument,NOTE_NEWS);
00147 }
|
Here is the call graph for this function:

|
||||||||||||
|
Definition at line 129 of file note.c. References NOTE_NOTE, and parse_note(). 00130 {
00131 parse_note(ch,argument,NOTE_NOTE);
00132 }
|
Here is the call graph for this function:

|
||||||||||||
|
Definition at line 139 of file note.c. References NOTE_PENALTY, and parse_note(). 00140 {
00141 parse_note(ch,argument,NOTE_PENALTY);
00142 }
|
Here is the call graph for this function:

|
|
Definition at line 73 of file note.c. References ANGEL, changes_list, count_spool(), FALSE, history_list, idea_list, IS_NPC, IS_TRUSTED, MAX_STRING_LENGTH, news_list, note_list, penalty_list, send_to_char(), and TRUE. Referenced by nanny(). 00074 {
00075 char buf[MAX_STRING_LENGTH];
00076 int count;
00077 bool found = FALSE;
00078
00079 if (IS_NPC(ch))
00080 return;
00081
00082 if ((count = count_spool(ch,news_list)) > 0)
00083 {
00084 found = TRUE;
00085 sprintf(buf,"There %s %d new news article%s waiting.\n\r",
00086 count > 1 ? "are" : "is",count, count > 1 ? "s" : "");
00087 send_to_char(buf,ch);
00088 }
00089 if ((count = count_spool(ch,changes_list)) > 0)
00090 {
00091 found = TRUE;
00092 sprintf(buf,"There %s %d change%s waiting to be read.\n\r",
00093 count > 1 ? "are" : "is", count, count > 1 ? "s" : "");
00094 send_to_char(buf,ch);
00095 }
00096 if ((count = count_spool(ch,note_list)) > 0)
00097 {
00098 found = TRUE;
00099 sprintf(buf,"You have %d new note%s waiting.\n\r",
00100 count, count > 1 ? "s" : "");
00101 send_to_char(buf,ch);
00102 }
00103 if ((count = count_spool(ch,idea_list)) > 0)
00104 {
00105 found = TRUE;
00106 sprintf(buf,"You have %d unread idea%s to peruse.\n\r",
00107 count, count > 1 ? "s" : "");
00108 send_to_char(buf,ch);
00109 }
00110 if (IS_TRUSTED(ch,ANGEL) && (count = count_spool(ch,penalty_list)) > 0)
00111 {
00112 found = TRUE;
00113 sprintf(buf,"%d %s been added.\n\r",
00114 count, count > 1 ? "penalties have" : "penalty has");
00115 send_to_char(buf,ch);
00116 }
00117 if ((count = count_spool(ch, history_list)) > 0)
00118 {
00119 found = TRUE;
00120 sprintf(buf, "The history has been changed %d %s since your last visit",
00121 count, count > 1 ? "times" : "time");
00122 send_to_char(buf,ch);
00123 }
00124
00125 if (!found)
00126 send_to_char("You have no unread notes.\n\r",ch);
00127 }
|
Here is the call graph for this function:

|
||||||||||||
|
Definition at line 492 of file note.c. References FALSE, is_note_to(), IS_NPC, NOTE_CHANGES, NOTE_HISTORY, NOTE_IDEA, NOTE_NEWS, NOTE_NOTE, NOTE_PENALTY, str_cmp(), and TRUE. Referenced by count_spool(), and parse_note(). 00493 {
00494 time_t last_read;
00495
00496 if (IS_NPC(ch))
00497 return TRUE;
00498
00499 switch (pnote->type)
00500 {
00501 default:
00502 return TRUE;
00503 case NOTE_NOTE:
00504 last_read = ch->pcdata->last_note;
00505 break;
00506 case NOTE_IDEA:
00507 last_read = ch->pcdata->last_idea;
00508 break;
00509 case NOTE_PENALTY:
00510 last_read = ch->pcdata->last_penalty;
00511 break;
00512 case NOTE_NEWS:
00513 last_read = ch->pcdata->last_news;
00514 break;
00515 case NOTE_CHANGES:
00516 last_read = ch->pcdata->last_changes;
00517 break;
00518 case NOTE_HISTORY:
00519 last_read = ch->pcdata->last_history;
00520 break;
00521 }
00522
00523 if (pnote->date_stamp <= last_read)
00524 return TRUE;
00525
00526 if (!str_cmp(ch->name,pnote->sender))
00527 return TRUE;
00528
00529 if (!is_note_to(ch,pnote))
00530 return TRUE;
00531
00532 return FALSE;
00533 }
|
Here is the call graph for this function:

|
||||||||||||
|
Definition at line 363 of file note.c. References clan_table, FALSE, is_exact_name(), IS_IMMORTAL, clan_type::name, str_cmp(), and TRUE. Referenced by hide_note(), and parse_note(). 00364 {
00365 if ( !str_cmp( ch->name, pnote->sender ) )
00366 return TRUE;
00367
00368 if ( is_exact_name( "all", pnote->to_list ) )
00369 return TRUE;
00370
00371 if ( IS_IMMORTAL(ch) && is_exact_name( "immortal", pnote->to_list ) )
00372 return TRUE;
00373
00374 if (ch->clan && is_exact_name(clan_table[ch->clan].name,pnote->to_list))
00375 return TRUE;
00376
00377 if (is_exact_name( ch->name, pnote->to_list ) )
00378 return TRUE;
00379
00380 return FALSE;
00381 }
|
Here is the call graph for this function:

|
|
Definition at line 215 of file note.c. References CHANGES_FILE, changes_list, HISTORY_FILE, history_list, IDEA_FILE, idea_list, load_thread(), NEWS_FILE, news_list, NOTE_CHANGES, NOTE_FILE, NOTE_HISTORY, NOTE_IDEA, note_list, NOTE_NEWS, NOTE_NOTE, NOTE_PENALTY, PENALTY_FILE, and penalty_list. Referenced by boot_db(). 00216 {
00217 load_thread(NOTE_FILE,¬e_list, NOTE_NOTE, 28*24*60*60);
00218 load_thread(IDEA_FILE,&idea_list, NOTE_IDEA, 28*24*60*60);
00219 load_thread(PENALTY_FILE,&penalty_list, NOTE_PENALTY, 0);
00220 load_thread(NEWS_FILE,&news_list, NOTE_NEWS, 0);
00221 load_thread(CHANGES_FILE,&changes_list,NOTE_CHANGES, 0);
00222 load_thread(HISTORY_FILE, &history_list, NOTE_HISTORY, 0);
00223 }
|
Here is the call graph for this function:

|
||||||||||||||||||||
|
Definition at line 225 of file note.c. References alloc_perm(), bug(), current_time, note_data::date, note_data::date_stamp, fpArea, fread_number(), fread_string(), fread_word(), free_note(), note_data::next, NOTE_FILE, note_data::sender, str_cmp(), strArea, note_data::subject, note_data::text, note_data::to_list, and note_data::type. Referenced by load_notes(). 00226 {
00227 FILE *fp;
00228 NOTE_DATA *pnotelast;
00229
00230 if ( ( fp = fopen( name, "r" ) ) == NULL )
00231 return;
00232
00233 pnotelast = NULL;
00234 for ( ; ; )
00235 {
00236 NOTE_DATA *pnote;
00237 char letter;
00238
00239 do
00240 {
00241 letter = getc( fp );
00242 if ( feof(fp) )
00243 {
00244 fclose( fp );
00245 return;
00246 }
00247 }
00248 while ( isspace(letter) );
00249 ungetc( letter, fp );
00250
00251 pnote = alloc_perm( sizeof(*pnote) );
00252
00253 if ( str_cmp( fread_word( fp ), "sender" ) )
00254 break;
00255 pnote->sender = fread_string( fp );
00256
00257 if ( str_cmp( fread_word( fp ), "date" ) )
00258 break;
00259 pnote->date = fread_string( fp );
00260
00261 if ( str_cmp( fread_word( fp ), "stamp" ) )
00262 break;
00263 pnote->date_stamp = fread_number(fp);
00264
00265 if ( str_cmp( fread_word( fp ), "to" ) )
00266 break;
00267 pnote->to_list = fread_string( fp );
00268
00269 if ( str_cmp( fread_word( fp ), "subject" ) )
00270 break;
00271 pnote->subject = fread_string( fp );
00272
00273 if ( str_cmp( fread_word( fp ), "text" ) )
00274 break;
00275 pnote->text = fread_string( fp );
00276
00277 if (free_time && pnote->date_stamp < current_time - free_time)
00278 {
00279 free_note(pnote);
00280 continue;
00281 }
00282
00283 pnote->type = type;
00284
00285 if (*list == NULL)
00286 *list = pnote;
00287 else
00288 pnotelast->next = pnote;
00289
00290 pnotelast = pnote;
00291 }
00292
00293 strcpy( strArea, NOTE_FILE );
00294 fpArea = fp;
00295 bug( "Load_notes: bad key word.", 0 );
00296 exit( 1 );
00297 return;
00298 }
|
Here is the call graph for this function:

|
||||||||||||
|
Definition at line 385 of file note.c. References note_data::date, new_note(), note_data::next, note_data::sender, str_dup(), note_data::subject, note_data::text, note_data::to_list, and note_data::type. Referenced by parse_note(). 00386 {
00387 NOTE_DATA *pnote;
00388
00389 if ( ch->pnote != NULL )
00390 return;
00391
00392 pnote = new_note();
00393
00394 pnote->next = NULL;
00395 pnote->sender = str_dup( ch->name );
00396 pnote->date = str_dup( "" );
00397 pnote->to_list = str_dup( "" );
00398 pnote->subject = str_dup( "" );
00399 pnote->text = str_dup( "" );
00400 pnote->type = type;
00401 ch->pnote = pnote;
00402 return;
00403 }
|
Here is the call graph for this function:

|
||||||||||||||||
|
Definition at line 407 of file note.c. References bug(), changes_list, free_note(), free_string(), history_list, idea_list, MAX_INPUT_LENGTH, news_list, note_data::next, NOTE_CHANGES, NOTE_HISTORY, NOTE_IDEA, note_list, NOTE_NEWS, NOTE_NOTE, NOTE_PENALTY, one_argument(), penalty_list, save_notes(), str_cmp(), str_dup(), and note_data::to_list. Referenced by parse_note(). 00408 {
00409 char to_new[MAX_INPUT_LENGTH];
00410 char to_one[MAX_INPUT_LENGTH];
00411 NOTE_DATA *prev;
00412 NOTE_DATA **list;
00413 char *to_list;
00414
00415 if (!delete)
00416 {
00417 /* make a new list */
00418 to_new[0] = '\0';
00419 to_list = pnote->to_list;
00420 while ( *to_list != '\0' )
00421 {
00422 to_list = one_argument( to_list, to_one );
00423 if ( to_one[0] != '\0' && str_cmp( ch->name, to_one ) )
00424 {
00425 strcat( to_new, " " );
00426 strcat( to_new, to_one );
00427 }
00428 }
00429 /* Just a simple recipient removal? */
00430 if ( str_cmp( ch->name, pnote->sender ) && to_new[0] != '\0' )
00431 {
00432 free_string( pnote->to_list );
00433 pnote->to_list = str_dup( to_new + 1 );
00434 return;
00435 }
00436 }
00437 /* nuke the whole note */
00438
00439 switch(pnote->type)
00440 {
00441 default:
00442 return;
00443 case NOTE_NOTE:
00444 list = ¬e_list;
00445 break;
00446 case NOTE_IDEA:
00447 list = &idea_list;
00448 break;
00449 case NOTE_PENALTY:
00450 list = &penalty_list;
00451 break;
00452 case NOTE_NEWS:
00453 list = &news_list;
00454 break;
00455 case NOTE_CHANGES:
00456 list = &changes_list;
00457 break;
00458 case NOTE_HISTORY:
00459 list = &history_list;
00460 break;
00461 }
00462
00463 /*
00464 * Remove note from linked list.
00465 */
00466 if ( pnote == *list )
00467 {
00468 *list = pnote->next;
00469 }
00470 else
00471 {
00472 for ( prev = *list; prev != NULL; prev = prev->next )
00473 {
00474 if ( prev->next == pnote )
00475 break;
00476 }
00477
00478 if ( prev == NULL )
00479 {
00480 bug( "Note_remove: pnote not found.", 0 );
00481 return;
00482 }
00483
00484 prev->next = pnote->next;
00485 }
00486
00487 save_notes(pnote->type);
00488 free_note(pnote);
00489 return;
00490 }
|
Here is the call graph for this function:

|
||||||||||||||||
|
Definition at line 580 of file note.c. References add_buf(), ANGEL, append_note(), buf_string(), changes_list, descriptor_data::character, CON_PLAYING, descriptor_data::connected, CREATOR, current_time, note_data::date, descriptor_list, FALSE, format_string(), free_buf(), free_note(), free_string(), get_trust(), hide_note(), history_list, idea_list, is_name(), is_note_to(), IS_NPC, is_number(), IS_TRUSTED, char_data::level, MAX_INPUT_LENGTH, MAX_LEVEL, MAX_STRING_LENGTH, char_data::name, new_buf(), news_list, buf_type::next, descriptor_data::next, note_data::next, note_attach(), NOTE_CHANGES, NOTE_HISTORY, NOTE_IDEA, note_list, NOTE_NEWS, NOTE_NOTE, NOTE_PENALTY, note_remove(), one_argument(), page_to_char(), penalty_list, char_data::pnote, printf_to_char(), send_to_char(), note_data::sender, smash_tilde(), str_cmp(), str_dup(), str_prefix(), string_append(), note_data::subject, note_data::text, note_data::to_list, TRUE, and update_read(). Referenced by do_changes(), do_history(), do_idea(), do_news(), do_note(), and do_penalty(). 00581 {
00582 BUFFER *buffer;
00583 char buf[MAX_STRING_LENGTH];
00584 char arg[MAX_INPUT_LENGTH];
00585 NOTE_DATA *pnote;
00586 NOTE_DATA **list;
00587 char *list_name;
00588 int vnum;
00589 int anum;
00590 char *to_format[MAX_STRING_LENGTH*4];
00591 DESCRIPTOR_DATA *d;
00592
00593 //if ( IS_NPC(ch))
00594 // return;
00595
00596 switch(type)
00597 {
00598 default:
00599 return;
00600 case NOTE_NOTE:
00601 list = ¬e_list;
00602 list_name = "notes";
00603 break;
00604 case NOTE_IDEA:
00605 list = &idea_list;
00606 list_name = "ideas";
00607 break;
00608 case NOTE_PENALTY:
00609 list = &penalty_list;
00610 list_name = "penalties";
00611 break;
00612 case NOTE_NEWS:
00613 list = &news_list;
00614 list_name = "news";
00615 break;
00616 case NOTE_CHANGES:
00617 list = &changes_list;
00618 list_name = "changes";
00619 break;
00620 case NOTE_HISTORY:
00621 list = &history_list;
00622 list_name = "history";
00623 break;
00624 }
00625
00626 argument = one_argument( argument, arg );
00627 smash_tilde( argument );
00628
00629 if ( arg[0] == '\0' || !str_prefix( arg, "read" ) )
00630 {
00631 bool fAll;
00632
00633 if ( !str_cmp( argument, "all" ) )
00634 {
00635 fAll = TRUE;
00636 anum = 0;
00637 }
00638
00639 else if ( argument[0] == '\0' || !str_prefix(argument, "next"))
00640 /* read next unread note */
00641 {
00642 vnum = 0;
00643 for ( pnote = *list; pnote != NULL; pnote = pnote->next)
00644 {
00645 if (!hide_note(ch,pnote))
00646 {
00647 /* sprintf( buf, "[%3d] %s: %s\n\r%s\n\rTo: %s\n\r",
00648 vnum,
00649 pnote->sender,
00650 pnote->subject,
00651 pnote->date,
00652 pnote->to_list);
00653 send_to_char( buf, ch );*/
00654 sprintf( buf, "{c--------------------------------------------------------------------------------------{x\n\r");
00655 send_to_char(buf,ch);
00656 sprintf( buf, "{R[{c%-3d{R]{x {W%s{c:{x %s\n\r", vnum , pnote->sender, pnote->subject);
00657 send_to_char(buf,ch);
00658 sprintf( buf, "%s\n\r", pnote->date);
00659 send_to_char(buf,ch);
00660 sprintf(buf, "To: %s\n\r",pnote->to_list);
00661 send_to_char(buf,ch);
00662 sprintf( buf, "{c--------------------------------------------------------------------------------------{x\n\r");
00663 send_to_char(buf,ch);
00664
00665 page_to_char( pnote->text, ch );
00666 update_read(ch,pnote);
00667 return;
00668 }
00669 else if (is_note_to(ch,pnote))
00670 vnum++;
00671 }
00672 sprintf(buf,"You have no unread %s.\n\r",list_name);
00673 send_to_char(buf,ch);
00674 return;
00675 }
00676
00677 else if ( is_number( argument ) )
00678 {
00679 fAll = FALSE;
00680 anum = atoi( argument );
00681 }
00682 else
00683 {
00684 send_to_char( "Read which number?\n\r", ch );
00685 return;
00686 }
00687
00688 vnum = 0;
00689 for ( pnote = *list; pnote != NULL; pnote = pnote->next )
00690 {
00691 if ( is_note_to( ch, pnote ) && ( vnum++ == anum || fAll ) )
00692 {
00693 sprintf( buf, "{c--------------------------------------------------------------------------------------{x\n\r");
00694 send_to_char(buf,ch);
00695 sprintf( buf, "{R[{c%-3d{R]{x {W%s{c:{x %s\n\r", vnum -1, pnote->sender, pnote->subject);
00696 send_to_char(buf,ch);
00697 sprintf( buf, "%s\n\r", pnote->date);
00698 send_to_char(buf,ch);
00699 sprintf(buf, "To: %s\n\r",pnote->to_list);
00700 send_to_char(buf,ch);
00701 sprintf( buf, "{c--------------------------------------------------------------------------------------{x\n\r");
00702 send_to_char(buf,ch);
00703 /* vnum - 1,
00704 pnote->sender,
00705 pnote->subject,
00706 pnote->date,
00707 pnote->to_list
00708 );
00709 send_to_char( buf, ch );*/
00710 page_to_char( pnote->text, ch );
00711 update_read(ch,pnote);
00712 return;
00713 }
00714 }
00715
00716 sprintf(buf,"There aren't that many %s.\n\r",list_name);
00717 send_to_char(buf,ch);
00718 return;
00719 }
00720
00721 if ( !str_prefix( arg, "list" ) )
00722 {
00723 if (IS_NPC(ch))
00724 return;
00725 vnum = 0;
00726 BUFFER *nbuf;
00727 nbuf = new_buf();
00728 for ( pnote = *list; pnote != NULL; pnote = pnote->next )
00729 {
00730 if ( is_note_to( ch, pnote ) )
00731 {
00732 sprintf( buf, "{R[{c%-3d{W%s{R]{x {W%s{c:{x %s{x\n\r",
00733 vnum, hide_note(ch,pnote) ? " " : "N",
00734 pnote->sender, pnote->subject );
00735 //send_to_char( buf, ch );
00736 add_buf(nbuf, buf);
00737 vnum++;
00738 }
00739 }
00740 page_to_char(buf_string(nbuf), ch);
00741 free_buf(nbuf);
00742
00743
00744 if (!vnum)
00745 {
00746 switch(type)
00747 {
00748 case NOTE_NOTE:
00749 send_to_char("There are no notes for you.\n\r",ch);
00750 break;
00751 case NOTE_IDEA:
00752 send_to_char("There are no ideas for you.\n\r",ch);
00753 break;
00754 case NOTE_PENALTY:
00755 send_to_char("There are no penalties for you.\n\r",ch);
00756 break;
00757 case NOTE_NEWS:
00758 send_to_char("There is no news for you.\n\r",ch);
00759 break;
00760 case NOTE_CHANGES:
00761 send_to_char("There are no changes for you.\n\r",ch);
00762 break;
00763 case NOTE_HISTORY:
00764 send_to_char("The history has not been changed.\n\r",ch);
00765 break;
00766 }
00767 }
00768 return;
00769 }
00770
00771 if ( !str_prefix( arg, "remove" ) )
00772 {
00773 if ( !is_number( argument ) )
00774 {
00775 send_to_char( "Note remove which number?\n\r", ch );
00776 return;
00777 }
00778
00779 anum = atoi( argument );
00780 vnum = 0;
00781 for ( pnote = *list; pnote != NULL; pnote = pnote->next )
00782 {
00783 if ( is_note_to( ch, pnote ) && vnum++ == anum )
00784 {
00785 note_remove( ch, pnote, FALSE );
00786 send_to_char( "Ok.\n\r", ch );
00787 return;
00788 }
00789 }
00790
00791 sprintf(buf,"There aren't that many %s.",list_name);
00792 send_to_char(buf,ch);
00793 return;
00794 }
00795
00796 if ( !str_prefix( arg, "delete" ) && get_trust(ch) >= MAX_LEVEL - 1)
00797 {
00798 if ( !is_number( argument ) )
00799 {
00800 send_to_char( "Note delete which number?\n\r", ch );
00801 return;
00802 }
00803
00804 anum = atoi( argument );
00805 vnum = 0;
00806 for ( pnote = *list; pnote != NULL; pnote = pnote->next )
00807 {
00808 if ( is_note_to( ch, pnote ) && vnum++ == anum )
00809 {
00810 note_remove( ch, pnote,TRUE );
00811 send_to_char( "Ok.\n\r", ch );
00812 return;
00813 }
00814 }
00815
00816 sprintf(buf,"There aren't that many %s.",list_name);
00817 send_to_char(buf,ch);
00818 return;
00819 }
00820
00821 if (!str_prefix(arg,"catchup"))
00822 {
00823 switch(type)
00824 {
00825 case NOTE_NOTE:
00826 ch->pcdata->last_note = current_time;
00827 break;
00828 case NOTE_IDEA:
00829 ch->pcdata->last_idea = current_time;
00830 break;
00831 case NOTE_PENALTY:
00832 ch->pcdata->last_penalty = current_time;
00833 break;
00834 case NOTE_NEWS:
00835 ch->pcdata->last_news = current_time;
00836 break;
00837 case NOTE_CHANGES:
00838 ch->pcdata->last_changes = current_time;
00839 break;
00840 case NOTE_HISTORY:
00841 ch->pcdata->last_history = current_time;
00842 break;
00843 }
00844 return;
00845 }
00846
00847 /* below this point only certain people can edit notes */
00848 if ((type == NOTE_NEWS && !IS_TRUSTED(ch,ANGEL))
00849 || (type == NOTE_CHANGES && !IS_TRUSTED(ch,CREATOR))
00850 || (type == NOTE_HISTORY && !IS_TRUSTED(ch, CREATOR)))
00851 {
00852 sprintf(buf,"You aren't high enough level to write %s.",list_name);
00853 send_to_char(buf,ch);
00854 return;
00855 }
00856
00857 if ( !str_cmp( arg, "+" ) )
00858 {
00859 note_attach( ch,type );
00860 if (ch->pnote->type != type)
00861 {
00862 send_to_char(
00863 "You already have a different note in progress.\n\r",ch);
00864 return;
00865 }
00866
00867 if (strlen(ch->pnote->text)+strlen(argument) >= 4096)
00868 {
00869 send_to_char( "Note too long.\n\r", ch );
00870 return;
00871 }
00872
00873 buffer = new_buf();
00874
00875 add_buf(buffer,ch->pnote->text);
00876 add_buf(buffer,argument);
00877 add_buf(buffer,"\n\r");
00878 free_string( ch->pnote->text );
00879 ch->pnote->text = str_dup( buf_string(buffer) );
00880 free_buf(buffer);
00881 send_to_char( "Ok.\n\r", ch );
00882 return;
00883 }
00884 if ( !str_cmp( arg, "++" ) )
00885 {
00886 note_attach( ch,type );
00887 if (ch->pnote->type != type)
00888 {
00889 send_to_char(
00890 "You already have a different note in progress.\n\r",ch);
00891 return;
00892 }
00893
00894 string_append( ch, &ch->pnote->text );
00895 return;
00896 }
00897 if (!str_cmp( arg, "format"))
00898 {
00899 //char *to_format[MAX_STRING_LENGTH*4];
00900 if (ch->pnote == NULL)
00901 {
00902 send_to_char("You are not currently working on a note.\n\r",ch);
00903 return;
00904 }
00905
00906 note_attach(ch,type);
00907 if (ch->pnote->type != type)
00908 {
00909 send_to_char("You already have a different note in progress.\n\r",ch);
00910 return;
00911 }
00912 *to_format = str_dup(ch->pnote->text);
00913 ch->pnote->text = format_string(*to_format);
00914 send_to_char("Note formated.\n\r",ch);
00915 return;
00916 }
00917
00918
00919 if (!str_cmp(arg,"-"))
00920 {
00921 int len;
00922 bool found = FALSE;
00923
00924 note_attach(ch,type);
00925 if (ch->pnote->type != type)
00926 {
00927 send_to_char(
00928 "You already have a different note in progress.\n\r",ch);
00929 return;
00930 }
00931
00932 if (ch->pnote->text == NULL || ch->pnote->text[0] == '\0')
00933 {
00934 send_to_char("No lines left to remove.\n\r",ch);
00935 return;
00936 }
00937
00938 strcpy(buf,ch->pnote->text);
00939
00940 for (len = strlen(buf); len > 0; len--)
00941 {
00942 if (buf[len] == '\r')
00943 {
00944 if (!found) /* back it up */
00945 {
00946 if (len > 0)
00947 len--;
00948 found = TRUE;
00949 }
00950 else /* found the second one */
00951 {
00952 buf[len + 1] = '\0';
00953 free_string(ch->pnote->text);
00954 ch->pnote->text = str_dup(buf);
00955 return;
00956 }
00957 }
00958 }
00959 buf[0] = '\0';
00960 free_string(ch->pnote->text);
00961 ch->pnote->text = str_dup(buf);
00962 return;
00963 }
00964
00965 if ( !str_prefix( arg, "subject" ) )
00966 {
00967 note_attach( ch,type );
00968 if (ch->pnote->type != type)
00969 {
00970 send_to_char(
00971 "You already have a different note in progress.\n\r",ch);
00972 return;
00973 }
00974
00975 free_string( ch->pnote->subject );
00976 ch->pnote->subject = str_dup( argument );
00977 send_to_char( "Ok.\n\r", ch );
00978 return;
00979 }
00980
00981 if ( !str_prefix( arg, "to" ) )
00982 {
00983 note_attach( ch,type );
00984 if (ch->pnote->type != type)
00985 {
00986 send_to_char(
00987 "You already have a different note in progress.\n\r",ch);
00988 return;
00989 }
00990 free_string( ch->pnote->to_list );
00991 ch->pnote->to_list = str_dup( argument );
00992 send_to_char( "Ok.\n\r", ch );
00993 return;
00994 }
00995
00996 if ( !str_prefix( arg, "clear" ) )
00997 {
00998 if ( ch->pnote != NULL )
00999 {
01000 free_note(ch->pnote);
01001 ch->pnote = NULL;
01002 }
01003
01004 send_to_char( "Ok.\n\r", ch );
01005 return;
01006 }
01007
01008 if ( !str_prefix( arg, "show" ) )
01009 {
01010 if ( ch->pnote == NULL )
01011 {
01012 send_to_char( "You have no note in progress.\n\r", ch );
01013 return;
01014 }
01015
01016 if (ch->pnote->type != type)
01017 {
01018 send_to_char("You aren't working on that kind of note.\n\r",ch);
01019 return;
01020 }
01021 /*
01022 sprintf( buf, "%s: %s\n\rTo: %s\n\r",
01023 ch->pnote->sender,
01024 ch->pnote->subject,
01025 ch->pnote->to_list
01026 );
01027 send_to_char( buf, ch );
01028 send_to_char( ch->pnote->text, ch );*/
01029 sprintf( buf, "{c--------------------------------------------------------------------------------------{x\n\r");
01030 send_to_char(buf,ch);
01031 sprintf( buf, "{W%s{c:{x %s\n\r", ch->pnote->sender, ch->pnote->subject);
01032 send_to_char(buf,ch);
01033 //sprintf( buf, "%s\n\r", ch->pnote->date);
01034 //send_to_char(buf,ch);
01035 sprintf(buf, "To: %s\n\r",ch->pnote->to_list);
01036 send_to_char(buf,ch);
01037 sprintf( buf, "{c--------------------------------------------------------------------------------------{x\n\r");
01038 send_to_char(buf,ch);
01039 send_to_char( ch->pnote->text, ch);
01040
01041
01042 return;
01043 }
01044
01045 if ( !str_prefix( arg, "post" ) || !str_prefix(arg, "send"))
01046 {
01047 char *strtime;
01048
01049 if ( ch->pnote == NULL )
01050 {
01051 send_to_char( "You have no note in progress.\n\r", ch );
01052 return;
01053 }
01054
01055 if (ch->pnote->type != type)
01056 {
01057 send_to_char("You aren't working on that kind of note.\n\r",ch);
01058 return;
01059 }
01060
01061 if (!str_cmp(ch->pnote->to_list,""))
01062 {
01063 send_to_char(
01064 "You need to provide a recipient (name, all, or immortal).\n\r",
01065 ch);
01066 return;
01067 }
01068
01069 if (!str_cmp(ch->pnote->subject,""))
01070 {
01071 send_to_char("You need to provide a subject.\n\r",ch);
01072 return;
01073 }
01074
01075 for (d = descriptor_list; d != NULL; d = d->next)
01076 {
01077 if (d->connected == CON_PLAYING)
01078 {
01079 if (is_name(d->character->name, ch->pnote->to_list) ||
01080 ((is_name("all", ch->pnote->to_list) &&
01081 d->character->name != ch->name) ||
01082 (is_name("imm", ch->pnote->to_list) &&
01083 d->character->level > 51) ||
01084 (is_name("immortal", ch->pnote->to_list) &&
01085 d->character->level > 51)))
01086 {
01087 switch(ch->pnote->type)
01088 {
01089 case NOTE_NOTE:
01090 printf_to_char(d->character, "%s has left you a note.\n\r{*", ch->name);
01091 break;
01092 case NOTE_IDEA:
01093 printf_to_char(d->character, "%s has left an idea.\n\r{*", ch->name);
01094 break;
01095 case NOTE_CHANGES:
01096 printf_to_char(d->character, "%s has done a change, read about it!{*\n\r",
01097 ch->name);
01098 break;
01099 case NOTE_PENALTY:
01100 printf_to_char(d->character, "%s has penned someone.{*\n\r", ch->name);
01101 break;
01102 case NOTE_NEWS:
01103 printf_to_char(d->character, "%s has posted some news.{*\n\r",ch->name);
01104 break;
01105 case NOTE_HISTORY:
01106 printf_to_char(d->character, "%s has changed the history around you.{*\n\r",
01107 ch->name);
01108 break;
01109 }
01110 }
01111 }
01112 }
01113
01114
01115
01116
01117
01118
01119
01120 ch->pnote->next = NULL;
01121 strtime = ctime( ¤t_time );
01122 strtime[strlen(strtime)-1] = '\0';
01123 ch->pnote->date = str_dup( strtime );
01124 ch->pnote->date_stamp = current_time;
01125
01126 append_note(ch->pnote);
01127 ch->pnote = NULL;
01128 send_to_char("Note posted. Thank you.\n\r",ch);
01129 return;
01130 }
01131
01132 send_to_char( "Note a valid note command.\n\r", ch );
01133 return;
01134 }
|
Here is the call graph for this function:

|
|
Definition at line 158 of file note.c. References CHANGES_FILE, changes_list, note_data::date, note_data::date_stamp, fpReserve, HISTORY_FILE, history_list, IDEA_FILE, idea_list, NEWS_FILE, news_list, note_data::next, NOTE_CHANGES, NOTE_FILE, NOTE_HISTORY, NOTE_IDEA, note_list, NOTE_NEWS, NOTE_NOTE, NOTE_PENALTY, |