summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source
diff options
context:
space:
mode:
authorzelgadis <zelgadis@c06c8d41-db1a-0410-9941-cceddc491573>2009-01-01 01:30:15 +0000
committerzelgadis <zelgadis@c06c8d41-db1a-0410-9941-cceddc491573>2009-01-01 01:30:15 +0000
commit3f0a535a9d963438d6a4b0bde64ac06ddc247216 (patch)
tree677a7f8d2e5754c3c3a32f8d0baa244fb94b7382 /crawl-ref/source
parenteb4d97db722cadcfa25a0221e3db4535f480d18b (diff)
downloadcrawl-ref-3f0a535a9d963438d6a4b0bde64ac06ddc247216.tar.gz
crawl-ref-3f0a535a9d963438d6a4b0bde64ac06ddc247216.zip
If the two factions are identical, like "rat v rat", then name one "rat (A)"
and the other "rat (B)". Put the monster spec in the arena.result file before the win/loss record. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@8070 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source')
-rw-r--r--crawl-ref/source/arena.cc41
1 files changed, 33 insertions, 8 deletions
diff --git a/crawl-ref/source/arena.cc b/crawl-ref/source/arena.cc
index 87ce24c573..fb7b82383a 100644
--- a/crawl-ref/source/arena.cc
+++ b/crawl-ref/source/arena.cc
@@ -50,6 +50,8 @@ namespace arena
faction faction_a(true);
faction faction_b(false);
+ FILE *file = NULL;
+
void adjust_monsters()
{
if (!allow_summons)
@@ -198,6 +200,12 @@ namespace arena
spec.c_str(),
err.c_str());
}
+
+ if (faction_a.desc == faction_b.desc)
+ {
+ faction_a.desc += " (A)";
+ faction_b.desc += " (B)";
+ }
}
void setup_monsters()
@@ -401,25 +409,41 @@ namespace arena
void global_setup()
{
+ if (file != NULL)
+ end(0, false, "Results file already open");
+ file = fopen("arena.result", "w");
+
+ if (file != NULL)
+ {
+ std::string spec = find_monster_spec();
+ fprintf(file, "%s\n", spec.c_str());
+ }
+
expand_mlist(5);
}
+ void global_shutdown()
+ {
+ if (file != NULL)
+ fclose(file);
+
+ file = NULL;
+ }
+
void write_results()
{
- if (FILE *f = fopen("arena.result", "w"))
- {
- fprintf(f, "%d-%d\n", team_a_wins, trials_done - team_a_wins);
- fclose(f);
- }
+ if (file != NULL)
+ fprintf(file, "%d-%d\n", team_a_wins, trials_done - team_a_wins);
}
void write_error(const std::string &error)
{
- if (FILE *f = fopen("arena.result", "w"))
+ if (file != NULL)
{
- fprintf(f, "err: %s\n", error.c_str());
- fclose(f);
+ fprintf(file, "err: %s\n", error.c_str());
+ fclose(file);
}
+ file = NULL;
}
void simulate()
@@ -458,4 +482,5 @@ void run_arena()
{
arena::global_setup();
arena::simulate();
+ arena::global_shutdown();
}