diff options
author | Bardur Arantsson <bardur@scientician.net> | 2011-02-20 09:32:05 +0100 |
---|---|---|
committer | Bardur Arantsson <bardur@scientician.net> | 2011-02-20 09:32:05 +0100 |
commit | c4f2e466bca7b30d2798237367ab0538456cf85a (patch) | |
tree | 866e273c386e15cadcb0ef0a107e2ecc86dab8fb | |
parent | 534032607ebc420df5c26d7af9c488ea4a318e81 (diff) |
Killerbunnies: Add companions to character dump.
-rw-r--r-- | src/externs.h | 1 | ||||
-rw-r--r-- | src/files.c | 3 | ||||
-rw-r--r-- | src/monster3.c | 35 |
3 files changed, 39 insertions, 0 deletions
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); + } + } +} |