summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/arena.cc
diff options
context:
space:
mode:
authorAdam Borowski <kilobyte@angband.pl>2012-11-04 17:18:19 +0100
committerAdam Borowski <kilobyte@angband.pl>2012-11-04 17:18:19 +0100
commit2d0488338ac2a0388167c9e8b73766ae8af1e8d4 (patch)
treec92aa786daa5e2f0782de9234d70fcb0fdfaf700 /crawl-ref/source/arena.cc
parent177cfa8d1158dd7c2ed8c995cf1ee706f1492f80 (diff)
parent59910180e554e796fe4a8b1f095f88dccbe0ac89 (diff)
downloadcrawl-ref-2d0488338ac2a0388167c9e8b73766ae8af1e8d4.tar.gz
crawl-ref-2d0488338ac2a0388167c9e8b73766ae8af1e8d4.zip
Merge branch 'master' into mon-pick
Merge commits instead of rerere suck, but not being able to comfortably use the test rig sucks even more.
Diffstat (limited to 'crawl-ref/source/arena.cc')
-rw-r--r--crawl-ref/source/arena.cc93
1 files changed, 46 insertions, 47 deletions
diff --git a/crawl-ref/source/arena.cc b/crawl-ref/source/arena.cc
index 2432ab42ad..add29a1ac5 100644
--- a/crawl-ref/source/arena.cc
+++ b/crawl-ref/source/arena.cc
@@ -33,9 +33,11 @@
#include "spl-miscast.h"
#include "spl-util.h"
#include "state.h"
+#include "stuff.h"
#ifdef USE_TILE
#include "tileview.h"
#endif
+#include "version.h"
#include "view.h"
#include "viewgeom.h"
@@ -45,20 +47,20 @@ extern void world_reacts();
namespace arena
{
- void write_error(const std::string &error);
+ void write_error(const string &error);
// A faction is just a big list of monsters. Monsters will be dropped
// around the appropriate marker.
struct faction
{
- std::string desc;
+ string desc;
mons_list members;
bool friendly;
int active_members;
bool won;
- std::vector<int> respawn_list;
- std::vector<coord_def> respawn_pos;
+ vector<int> respawn_list;
+ vector<coord_def> respawn_pos;
faction(bool fr) : members(), friendly(fr), active_members(0),
won(false) { }
@@ -81,7 +83,7 @@ namespace arena
}
};
- std::string teams;
+ string teams;
int total_trials = 0;
@@ -112,16 +114,16 @@ namespace arena
int summon_throttle = INT_MAX;
- std::vector<monster_type> uniques_list;
- std::vector<int> a_spawners;
- std::vector<int> b_spawners;
+ vector<monster_type> uniques_list;
+ vector<int> a_spawners;
+ vector<int> b_spawners;
int8_t to_respawn[MAX_MONSTERS];
int item_drop_times[MAX_ITEMS];
bool banned_glyphs[128];
- std::string arena_type = "";
+ string arena_type = "";
faction faction_a(true);
faction faction_b(false);
coord_def place_a, place_b;
@@ -161,7 +163,7 @@ namespace arena
if (!Options.arena_list_eq || file == NULL)
return;
- std::vector<int> items;
+ vector<int> items;
for (int i = 0; i < NUM_MONSTER_SLOTS; i++)
if (mon->inv[i] != NON_ITEM)
@@ -211,7 +213,7 @@ namespace arena
}
}
- void center_print(unsigned sz, std::string text, int number = -1)
+ void center_print(unsigned sz, string text, int number = -1)
{
if (number >= 0)
text = make_stringf("(%d) %s", number, text.c_str());
@@ -220,7 +222,7 @@ namespace arena
if (len > sz)
text = chop_string(text, len = sz);
- cprintf("%s%s", std::string((sz - len) / 2, ' ').c_str(), text.c_str());
+ cprintf("%s%s", string((sz - len) / 2, ' ').c_str(), text.c_str());
}
void setup_level()
@@ -245,12 +247,12 @@ namespace arena
unwind_bool gen(Generating_Level, true);
- typedef unwind_var< std::set<std::string> > unwind_stringset;
+ typedef unwind_var< set<string> > unwind_stringset;
const unwind_stringset mtags(you.uniq_map_tags);
const unwind_stringset mnames(you.uniq_map_names);
- std::string map_name = "arena_" + arena_type;
+ string map_name = "arena_" + arena_type;
const map_def *map = random_map_for_tag(map_name.c_str());
if (!map)
@@ -283,7 +285,7 @@ namespace arena
env.markers.activate_all();
}
- std::string find_monster_spec()
+ string find_monster_spec()
{
if (!teams.empty())
return teams;
@@ -291,25 +293,25 @@ namespace arena
return "random v random";
}
- void parse_faction(faction &fact, std::string spec)
- throw (std::string)
+ void parse_faction(faction &fact, string spec)
+ throw (string)
{
fact.clear();
fact.desc = spec;
- std::vector<std::string> monsters = split_string(",", spec);
+ vector<string> monsters = split_string(",", spec);
for (int i = 0, size = monsters.size(); i < size; ++i)
{
- const std::string err = fact.members.add_mons(monsters[i], false);
+ const string err = fact.members.add_mons(monsters[i], false);
if (!err.empty())
throw err;
}
}
void parse_monster_spec()
- throw (std::string)
+ throw (string)
{
- std::string spec = find_monster_spec();
+ string spec = find_monster_spec();
allow_chain_summons = !strip_tag(spec, "no_chain_summons");
@@ -326,10 +328,7 @@ namespace arena
summon_throttle = strip_number_tag(spec, "summon_throttle:");
if (real_summons && respawn)
- {
- throw (std::string("Can't set real_summons and respawn at "
- "same time."));
- }
+ throw (string("Can't set real_summons and respawn at same time."));
if (summon_throttle <= 0)
summon_throttle = INT_MAX;
@@ -354,14 +353,14 @@ namespace arena
if (arena_delay >= 0 && arena_delay < 2000)
Options.arena_delay = arena_delay;
- std::string arena_place = strip_tag_prefix(spec, "arena_place:");
+ string arena_place = strip_tag_prefix(spec, "arena_place:");
if (!arena_place.empty())
{
try
{
place = level_id::parse_level_id(arena_place);
}
- catch (const std::string &err)
+ catch (const string &err)
{
throw make_stringf("Bad place '%s': %s",
arena_place.c_str(),
@@ -369,12 +368,12 @@ namespace arena
}
}
- const std::string glyphs = strip_tag_prefix(spec, "ban_glyphs:");
+ const string glyphs = strip_tag_prefix(spec, "ban_glyphs:");
for (unsigned int i = 0; i < glyphs.size(); i++)
if (!(glyphs[i] & !127))
banned_glyphs[static_cast<int>(glyphs[i])] = true;
- std::vector<std::string> factions = split_string(" v ", spec);
+ vector<string> factions = split_string(" v ", spec);
if (factions.size() == 1)
factions = split_string(" vs ", spec);
@@ -390,7 +389,7 @@ namespace arena
parse_faction(faction_a, factions[0]);
parse_faction(faction_b, factions[1]);
}
- catch (const std::string &err)
+ catch (const string &err)
{
throw make_stringf("Bad monster spec \"%s\": %s",
spec.c_str(),
@@ -405,7 +404,7 @@ namespace arena
}
void setup_monsters()
- throw (std::string)
+ throw (string)
{
faction_a.reset();
faction_b.reset();
@@ -506,7 +505,7 @@ namespace arena
}
void setup_fight()
- throw (std::string)
+ throw (string)
{
//no_messages mx;
parse_monster_spec();
@@ -626,16 +625,16 @@ namespace arena
if (!Options.arena_dump_msgs || file == NULL)
return;
- std::vector<std::string> messages;
- std::vector<msg_channel_type> channels;
+ vector<string> messages;
+ vector<msg_channel_type> channels;
get_recent_messages(messages, channels);
for (unsigned int i = 0; i < messages.size(); i++)
{
- std::string msg = messages[i];
+ string msg = messages[i];
int chan = channels[i];
- std::string prefix;
+ string prefix;
switch (chan)
{
case MSGCH_DIAGNOSTICS:
@@ -920,7 +919,7 @@ namespace arena
show_fight_banner(true);
- std::string msg;
+ string msg;
if (was_tied)
msg = "Tie";
else
@@ -938,7 +937,7 @@ namespace arena
dump_messages();
}
- void global_setup(const std::string& arena_teams)
+ void global_setup(const string& arena_teams)
{
// [ds] Turning off view_lock crashes arena.
Options.view_lock_x = Options.view_lock_y = true;
@@ -949,7 +948,7 @@ namespace arena
{
parse_monster_spec();
}
- catch (const std::string &error)
+ catch (const string &error)
{
write_error(error);
game_ended_with_error(error);
@@ -961,7 +960,7 @@ namespace arena
if (file != NULL)
{
- std::string spec = find_monster_spec();
+ string spec = find_monster_spec();
fprintf(file, "%s\n", spec.c_str());
if (Options.arena_dump_msgs || Options.arena_list_eq)
@@ -1002,7 +1001,7 @@ namespace arena
}
}
- void write_error(const std::string &error)
+ void write_error(const string &error)
{
if (file != NULL)
{
@@ -1021,7 +1020,7 @@ namespace arena
{
setup_fight();
}
- catch (const std::string &error)
+ catch (const string &error)
{
write_error(error);
game_ended_with_error(error);
@@ -1054,7 +1053,7 @@ monster_type arena_pick_random_monster(const level_id &place)
{
if (arena::random_uniques)
{
- const std::vector<monster_type> &uniques = arena::uniques_list;
+ const vector<monster_type> &uniques = arena::uniques_list;
const monster_type type = uniques[random2(uniques.size())];
you.unique_creatures[type] = false;
@@ -1343,7 +1342,7 @@ static bool _sort_by_age(int a, int b)
// fair to the arena monsters.
int arena_cull_items()
{
- std::vector<int> items;
+ vector<int> items;
int first_avail = NON_ITEM;
@@ -1363,9 +1362,9 @@ int arena_cull_items()
const int cull_target = items.size() / 2;
int cull_count = 0;
- std::sort(items.begin(), items.end(), _sort_by_age);
+ sort(items.begin(), items.end(), _sort_by_age);
- std::vector<int> ammo;
+ vector<int> ammo;
for (unsigned int i = 0, end = items.size(); i < end; i++)
{
@@ -1434,7 +1433,7 @@ static void _init_arena()
initialise_item_descriptions();
}
-NORETURN void run_arena(const std::string& teams)
+NORETURN void run_arena(const string& teams)
{
_init_arena();