summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/arena.cc
diff options
context:
space:
mode:
authorRaphael Langella <raphael.langella@gmail.com>2012-08-26 22:50:06 +0200
committerRaphael Langella <raphael.langella@gmail.com>2012-08-26 23:06:30 +0200
commit770bcbd1844b97b671d0e47ea8313cdf2c74c5ea (patch)
treee030cf61afce9ca69b74bb38eb73734bf10f633e /crawl-ref/source/arena.cc
parenta6c16c7f2066c854a01f25e9e6c3d8e44282a638 (diff)
downloadcrawl-ref-770bcbd1844b97b671d0e47ea8313cdf2c74c5ea.tar.gz
crawl-ref-770bcbd1844b97b671d0e47ea8313cdf2c74c5ea.zip
Use std namespace.
I had to rename distance() (in coord.h) to distance2() because it conflicts with the STL function to compare 2 iterators. Not a bad change given how it returns the square of the distance anyway. I also had to rename the message global variable (in message.cc) to buffer. I tried to fix and improve the coding style has much as I could, but I probably missed a few given how huge and tedious it is. I also didn't touch crawl-gdb.py, and the stuff in prebuilt, rltiles/tool and util/levcomp.*, because I have no clue about those.
Diffstat (limited to 'crawl-ref/source/arena.cc')
-rw-r--r--crawl-ref/source/arena.cc91
1 files changed, 44 insertions, 47 deletions
diff --git a/crawl-ref/source/arena.cc b/crawl-ref/source/arena.cc
index b7a8147480..a5aa926a93 100644
--- a/crawl-ref/source/arena.cc
+++ b/crawl-ref/source/arena.cc
@@ -45,20 +45,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 +81,7 @@ namespace arena
}
};
- std::string teams;
+ string teams;
int total_trials = 0;
@@ -112,16 +112,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 +161,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 +211,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 +220,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 +245,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 +283,7 @@ namespace arena
env.markers.activate_all();
}
- std::string find_monster_spec()
+ string find_monster_spec()
{
if (!teams.empty())
return teams;
@@ -291,25 +291,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 +326,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 +351,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 +366,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 +387,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 +402,7 @@ namespace arena
}
void setup_monsters()
- throw (std::string)
+ throw (string)
{
faction_a.reset();
faction_b.reset();
@@ -506,7 +503,7 @@ namespace arena
}
void setup_fight()
- throw (std::string)
+ throw (string)
{
//no_messages mx;
parse_monster_spec();
@@ -626,16 +623,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 +917,7 @@ namespace arena
show_fight_banner(true);
- std::string msg;
+ string msg;
if (was_tied)
msg = "Tie";
else
@@ -938,7 +935,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 +946,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 +958,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 +999,7 @@ namespace arena
}
}
- void write_error(const std::string &error)
+ void write_error(const string &error)
{
if (file != NULL)
{
@@ -1021,7 +1018,7 @@ namespace arena
{
setup_fight();
}
- catch (const std::string &error)
+ catch (const string &error)
{
write_error(error);
game_ended_with_error(error);
@@ -1055,7 +1052,7 @@ monster_type arena_pick_random_monster(const level_id &place, int power,
{
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;
@@ -1348,7 +1345,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;
@@ -1368,9 +1365,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++)
{
@@ -1439,7 +1436,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();