--- src-orig/cmd-know.c Fri Dec 27 22:20:16 2002 +++ src/cmd-know.c Wed Jan 8 01:31:55 2003 @@ -338,6 +338,9 @@ void do_cmd_note(void) /* Add the note to the message recall */ message_format(MSG_NOTE, 0, "Note: %s", tmp); + + /* Write it to note file */ + write_note(tmp, "-"); } /* --- src-orig/externs.h Sat Dec 28 21:34:08 2002 +++ src/externs.h Wed Jan 8 01:35:30 2003 @@ -433,6 +433,7 @@ extern void display_player_status(void); /* files.c */ extern void text_screenshot(cptr name); extern void html_screenshot(cptr name); +extern void write_note(char *note, char note_type[1]); extern void safe_setuid_drop(void); extern void safe_setuid_grab(void); extern errr process_pref_file_command(char *buf); --- src-orig/files.c Tue Dec 31 20:39:00 2002 +++ src/files.c Wed Jan 8 01:32:41 2003 @@ -245,6 +245,56 @@ void html_screenshot(cptr name) my_fclose(htm); } +void write_note(char *note, char note_type[1]) +{ + FILE *fff = NULL; + char buf[1024]; + char ftmp[1024]; + char final_note[1024]; + time_t ct = time((time_t*)0); + char long_day[50]; + char depths[32]; + + /* Add bells and whistles to note */ + strftime(long_day, 30, "%Y-%m-%d %H:%M:%S", localtime(&ct)); + if (!p_ptr->depth) + { + strcpy(depths, "Town"); + } + else if (depth_in_feet) + { + sprintf(depths, "%d'", p_ptr->depth * 50); + } + else + { + sprintf(depths, "Lev %d", p_ptr->depth); + } + sprintf(final_note, "%s: %6s %s: %s", long_day, depths, note_type, note); + + /* Construct notes file name */ + strnfmt(ftmp, sizeof(ftmp), "%s.nte", op_ptr->base_name); + + /* Build the filename */ + path_build(buf, sizeof(buf), ANGBAND_DIR_USER, ftmp); + + /* File type is "TEXT" */ + FILE_TYPE(FILE_TYPE_TEXT); + + /* Open file */ + fff = my_fopen(buf, "a"); + + /* Invalid file */ + if (!fff) return; + + /* Write note */ + my_fputs(fff, final_note, 0); + + /* Close note file */ + my_fclose(fff); + + return; +} + /* * Hack -- drop permissions */ --- src-orig/xtra2.c Tue Dec 31 09:57:34 2002 +++ src/xtra2.c Sun Jan 12 22:38:05 2003 @@ -116,11 +116,20 @@ void check_experience(void) if ((rp_ptr->special) && (p_ptr->lev > p_ptr->max_lev)) check_race_special(); /* Save the highest level */ - if (p_ptr->lev > p_ptr->max_lev) p_ptr->max_lev = p_ptr->lev; + if (p_ptr->lev > p_ptr->max_lev) + { + char note_message[100]; + + p_ptr->max_lev = p_ptr->lev; + + /* Write note */ + sprintf(note_message, "Reached level %d", p_ptr->lev); + write_note(note_message, "L"); + } /* Message */ message_format(MSG_LEVEL, p_ptr->lev, "Welcome to level %d.", p_ptr->lev); - + /* Update some stuff */ p_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS); @@ -139,9 +148,15 @@ void check_experience(void) (p_ptr->max_exp >= (player_exp[p_ptr->max_lev-1] * p_ptr->expfact / 100L))) { + char note_message[100]; + /* Gain max level */ p_ptr->max_lev++; + /* Write note */ + sprintf(note_message, "Reached level %d", p_ptr->lev); + write_note(note_message, "L"); + /* Update some stuff */ p_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS); @@ -594,6 +609,14 @@ bool mon_take_hit(int m_idx, int dam, bo /* Hack -- Auto-recall */ monster_track(m_ptr->r_idx, m_ptr->u_idx); + } + + /* Take note if unique */ + if (m_ptr->u_idx) + { + char note_message[100]; + sprintf(note_message, "Killed %s", m_name); + write_note(note_message, "U"); } /* Delete the monster */