From c4f2e466bca7b30d2798237367ab0538456cf85a Mon Sep 17 00:00:00 2001 From: Bardur Arantsson Date: Sun, 20 Feb 2011 09:32:05 +0100 Subject: Killerbunnies: Add companions to character dump. --- src/externs.h | 1 + src/files.c | 3 +++ src/monster3.c | 35 +++++++++++++++++++++++++++++++++++ 3 files changed, 39 insertions(+) diff --git a/src/externs.h b/src/externs.h index 10e7ffae..868fa968 100644 --- a/src/externs.h +++ b/src/externs.h @@ -1086,6 +1086,7 @@ extern bool monster_can_cross_terrain(byte feat, monster_race *r_ptr); extern void corrupt_corrupted(void); /* monster3.c */ +extern void dump_companions(FILE *outfile); extern void do_cmd_companion(void); extern bool do_control_reconnect(void); extern bool do_control_drop(void); diff --git a/src/files.c b/src/files.c index b7d8d8f8..a1a41c56 100644 --- a/src/files.c +++ b/src/files.c @@ -3106,6 +3106,9 @@ errr file_character(cptr name, bool full) dump_skills(fff); dump_abilities(fff); + /* Dump companions. */ + dump_companions(fff); + if (p_ptr->companion_killed) { if (p_ptr->companion_killed == 1) diff --git a/src/monster3.c b/src/monster3.c index 786c6041..f381c94c 100644 --- a/src/monster3.c +++ b/src/monster3.c @@ -669,3 +669,38 @@ void do_cmd_companion() else msg_print("You must target a pet."); } + +/* + * List companions to the character sheet. + */ +void dump_companions(FILE *outfile) +{ + int i; + int done_hdr = 0; + + /* Process the monsters (backwards) */ + for (i = m_max - 1; i >= 1; i--) + { + /* Access the monster */ + monster_type *m_ptr = &m_list[i]; + + /* Ignore "dead" monsters */ + if (!m_ptr->r_idx) continue; + + if (m_ptr->status == MSTATUS_COMPANION) + { + char pet_name[80]; + + /* Output the header if we haven't yet. */ + if (!done_hdr) + { + done_hdr = 1; + fprintf(outfile, "\n\n [Current companions]\n\n"); + } + + /* List the monster. */ + monster_desc(pet_name, m_ptr, 0x88); + fprintf(outfile, "%s (level %d)\n", pet_name, m_ptr->level); + } + } +} -- cgit v1.2.3