summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--crawl-ref/source/arena.cc60
-rw-r--r--crawl-ref/source/externs.h3
-rw-r--r--crawl-ref/source/initfile.cc7
-rw-r--r--crawl-ref/source/message.cc32
-rw-r--r--crawl-ref/source/message.h8
5 files changed, 108 insertions, 2 deletions
diff --git a/crawl-ref/source/arena.cc b/crawl-ref/source/arena.cc
index fb7b82383a..9b66a2531d 100644
--- a/crawl-ref/source/arena.cc
+++ b/crawl-ref/source/arena.cc
@@ -49,8 +49,8 @@ namespace arena
std::string arena_type = "";
faction faction_a(true);
faction faction_b(false);
-
FILE *file = NULL;
+ int message_pos = 0;
void adjust_monsters()
{
@@ -73,6 +73,32 @@ namespace arena
}
}
+ void list_eq(int imon)
+ {
+ if (!Options.arena_list_eq || file == NULL)
+ return;
+
+ const monsters* mon = &menv[imon];
+
+ std::vector<int> items;
+
+ for (int i = 0; i < NUM_MONSTER_SLOTS; i++)
+ if (mon->inv[i] != NON_ITEM)
+ items.push_back(mon->inv[i]);
+
+ if (items.size() == 0)
+ return;
+
+ fprintf(file, "%s:\n", mon->name(DESC_PLAIN, true).c_str());
+
+ for (unsigned int i = 0; i < items.size(); i++)
+ {
+ item_def &item = mitm[items[i]];
+ fprintf(file, " %s\n",
+ item.name(DESC_PLAIN, false, true).c_str());
+ }
+ }
+
void faction::place_at(const coord_def &pos)
{
ASSERT(in_bounds(pos));
@@ -95,6 +121,7 @@ namespace arena
if (imon == -1)
end(1, false, "Failed to create monster at (%d,%d)",
place.x, place.y);
+ list_eq(imon);
}
}
}
@@ -369,6 +396,20 @@ namespace arena
return (false);
}
+
+ void dump_messages()
+ {
+ if (!Options.arena_dump_msgs || file == NULL)
+ return;
+
+ std::vector<std::string> messages =
+ get_recent_messages(message_pos,
+ !Options.arena_dump_msgs_all);
+
+ for (unsigned int i = 0; i < messages.size(); i++)
+ fprintf(file, "%s\n", messages[i].c_str());
+ }
+
void do_fight()
{
mesclr(true);
@@ -388,6 +429,7 @@ namespace arena
world_reacts();
delay(Options.arena_delay);
mesclr();
+ dump_messages();
}
viewwindow(true, false);
}
@@ -403,8 +445,15 @@ namespace arena
show_fight_banner(true);
- mprf("Winner: %s!",
+ const char *msg;
+ if (Options.arena_dump_msgs || Options.arena_list_eq)
+ msg = "---------- Winner: %s! ----------";
+ else
+ msg = "Winner: %s!";
+
+ mprf(msg,
team_a_won ? faction_a.desc.c_str() : faction_b.desc.c_str());
+ dump_messages();
}
void global_setup()
@@ -417,6 +466,9 @@ namespace arena
{
std::string spec = find_monster_spec();
fprintf(file, "%s\n", spec.c_str());
+
+ if (Options.arena_dump_msgs || Options.arena_list_eq)
+ fprintf(file, "========================================\n");
}
expand_mlist(5);
@@ -433,7 +485,11 @@ namespace arena
void write_results()
{
if (file != NULL)
+ {
+ if (Options.arena_dump_msgs || Options.arena_list_eq)
+ fprintf(file, "========================================\n");
fprintf(file, "%d-%d\n", team_a_wins, trials_done - team_a_wins);
+ }
}
void write_error(const std::string &error)
diff --git a/crawl-ref/source/externs.h b/crawl-ref/source/externs.h
index 30d890de26..cdbfe5e9e3 100644
--- a/crawl-ref/source/externs.h
+++ b/crawl-ref/source/externs.h
@@ -2023,6 +2023,9 @@ public:
int travel_delay; // How long to pause between travel moves
int arena_delay;
+ bool arena_dump_msgs;
+ bool arena_dump_msgs_all;
+ bool arena_list_eq;
// Messages that stop travel
std::vector<message_filter> travel_stop_message;
diff --git a/crawl-ref/source/initfile.cc b/crawl-ref/source/initfile.cc
index 7cfcbe5c3e..e58c5318e1 100644
--- a/crawl-ref/source/initfile.cc
+++ b/crawl-ref/source/initfile.cc
@@ -711,6 +711,9 @@ void game_options::reset_options()
travel_stair_cost = 500;
arena_delay = 600;
+ arena_dump_msgs = false;
+ arena_dump_msgs_all = false;
+ arena_list_eq = false;
// Sort only pickup menus by default.
sort_menus.clear();
@@ -3067,6 +3070,10 @@ void game_options::read_option_line(const std::string &str, bool runscript)
else
constants.insert(field);
}
+ else INT_OPTION(arena_delay, 1, INT_MAX);
+ else BOOL_OPTION(arena_dump_msgs);
+ else BOOL_OPTION(arena_dump_msgs_all);
+ else BOOL_OPTION(arena_list_eq);
// Catch-all else, copies option into map
else if (runscript)
diff --git a/crawl-ref/source/message.cc b/crawl-ref/source/message.cc
index 1efdc0f2a5..b52aea65d1 100644
--- a/crawl-ref/source/message.cc
+++ b/crawl-ref/source/message.cc
@@ -997,6 +997,38 @@ std::string get_last_messages(int mcount)
return text;
}
+std::vector<std::string> get_recent_messages(int &message_pos,
+ bool dumpworthy_only,
+ std::vector<int> *channels)
+{
+ ASSERT(message_pos >= 0 && message_pos < NUM_STORED_MESSAGES);
+
+ std::vector<int> _channels;
+ if (channels == NULL)
+ channels = &_channels;
+
+ std::vector<std::string> out;
+
+ while (message_pos != Next_Message)
+ {
+ const message_item &msg = Store_Message[message_pos++];
+
+ if (message_pos >= NUM_STORED_MESSAGES)
+ message_pos -= NUM_STORED_MESSAGES;
+
+ if (msg.text.empty())
+ continue;
+
+ if (dumpworthy_only && !is_channel_dumpworthy(msg.channel))
+ continue;
+
+ out.push_back(formatted_string::parse_string(msg.text).tostring());
+ channels->push_back( (int) msg.channel );
+ }
+
+ return (out);
+}
+
void save_messages(writer& outf)
{
marshallLong( outf, Next_Message );
diff --git a/crawl-ref/source/message.h b/crawl-ref/source/message.h
index 2ca46b9e45..5ccc166d07 100644
--- a/crawl-ref/source/message.h
+++ b/crawl-ref/source/message.h
@@ -77,6 +77,14 @@ void reset_more_autoclear();
* *********************************************************************** */
std::string get_last_messages(int mcount);
+// last updated 31dec2008 {dlb}
+/* ***********************************************************************
+ * called from: arena
+ * *********************************************************************** */
+std::vector<std::string> get_recent_messages(int &message_pos,
+ bool dumpworthy_only = true,
+ std::vector<int> *channels = NULL);
+
int channel_to_colour( msg_channel_type channel, int param = 0 );
namespace msg