Rename namespace action back to "actions".

This is to avoid potential name clashes with any classses named
"action", like what shadowm found in the test suite. (The quick fix of
2012-12-31T05:35:28Z!jt_coding@verizon.net is now reverted in favor of this fix.)  One complication
is that there is already an "ai:actions" namespace, so within the "ai"
namespace, the renamed namespace is qualified as "::actions".
This commit is contained in:
J. Tyne 2012-12-31 20:50:57 +00:00
parent 4105b0ba05
commit 1ded6ceeab
22 changed files with 68 additions and 67 deletions

View file

@ -673,7 +673,7 @@ namespace {
// defender, so we have to make sure they still exist
refresh_bc();
if(!a_.valid() || !d_.valid() || !(*resources::teams)[a_.get_unit().side() - 1].is_enemy(d_.get_unit().side())) {
action::recalculate_fog(defender_side);
actions::recalculate_fog(defender_side);
if (update_display_){
resources::screen->redraw_minimap();
resources::screen->draw(true, true);
@ -1145,7 +1145,7 @@ namespace {
if ( update_def_fog_ )
{
action::recalculate_fog(defender_side);
actions::recalculate_fog(defender_side);
}
// TODO: if we knew the viewing team, we could skip this display update
@ -1251,7 +1251,7 @@ void advance_unit(map_location loc, const std::string &advance_to,
// This is not normally necessary, but if a unit loses power when leveling
// (e.g. loses "jamming" or ambush), it could be discovered as a result of
// the advancement.
std::vector<int> not_seeing = action::get_sides_not_seeing(*u);
std::vector<int> not_seeing = actions::get_sides_not_seeing(*u);
// Create the advanced unit.
bool use_amla = mod_option != NULL;
@ -1266,7 +1266,7 @@ void advance_unit(map_location loc, const std::string &advance_to,
u = resources::units->replace(loc, new_unit).first;
// Update fog/shroud.
action::shroud_clearer clearer;
actions::shroud_clearer clearer;
clearer.clear_unit(loc, new_unit);
// "post_advance" event.
@ -1279,7 +1279,7 @@ void advance_unit(map_location loc, const std::string &advance_to,
// "sighted" event(s).
clearer.fire_events();
if ( u.valid() )
action::actor_sighted(*u, &not_seeing);
actions::actor_sighted(*u, &not_seeing);
resources::whiteboard->on_gamestate_change();
}

View file

@ -77,7 +77,7 @@ private:
const bool use_shroud_; // Allows faster checks when shroud is disabled.
};
}
}//anonymous namespace
unit_creator::unit_creator(team &tm, const map_location &start_pos)
: add_to_recall_(false),discover_(false),get_village_(false),invalidate_(false), rename_side_(false), show_(false), start_pos_(start_pos), team_(tm)
@ -237,7 +237,7 @@ void unit_creator::post_create(const map_location &loc, const unit &new_unit, bo
if (get_village_) {
if (resources::game_map->is_village(loc)) {
action::get_village(loc, new_unit.side());
actions::get_village(loc, new_unit.side());
}
}
@ -781,13 +781,13 @@ bool place_recruit(const unit &u, const map_location &recruit_location, const ma
// Village capturing.
if ( resources::game_map->is_village(current_loc) ) {
mutated |= action::get_village(current_loc, new_unit_itor->side());
mutated |= actions::get_village(current_loc, new_unit_itor->side());
if ( !validate_recruit_iterator(new_unit_itor, current_loc) )
return true;
}
// Fog clearing.
action::shroud_clearer clearer;
actions::shroud_clearer clearer;
if ( !wml_triggered ) // To preserve current WML behavior.
mutated |= clearer.clear_unit(current_loc, *new_unit_itor, true);
@ -802,13 +802,13 @@ bool place_recruit(const unit &u, const map_location &recruit_location, const ma
// "sighted" event(s).
mutated |= clearer.fire_events();
if ( new_unit_itor.valid() )
mutated |= action::actor_sighted(*new_unit_itor);
mutated |= actions::actor_sighted(*new_unit_itor);
return mutated;
}
namespace action {
namespace actions {
/**
@ -875,4 +875,4 @@ bool recall_unit(const std::string & id, team & current_team,
}
}//namespace action
}//namespace actions

View file

@ -141,7 +141,7 @@ bool place_recruit(const unit &u, const map_location &recruit_location, const ma
bool wml_triggered = false);
namespace action {
namespace actions {
/**
* Recruits a unit of the given type for the given side.
@ -166,6 +166,6 @@ bool recall_unit(const std::string & id, team & current_team,
const map_location & loc, const map_location & from,
bool show = true, bool is_ai = false);
}//namespace action
}//namespace actions
#endif

View file

@ -267,7 +267,8 @@ namespace {
}
}
}
}//anonymous namespace
// Simple algorithm: no maximum number of patients per healer.
void calculate_healing(int side, bool update_display)

View file

@ -49,7 +49,7 @@ static lg::log_domain log_engine("engine");
#define DBG_NG LOG_STREAM(debug, log_engine)
namespace action {
namespace actions {
void move_unit_spectator::add_seen_friend(const unit_map::const_iterator &u)
@ -1225,4 +1225,4 @@ bool unit_can_move(const unit &u)
}
}//namespace action
}//namespace actions

View file

@ -30,7 +30,7 @@ class unit;
#include <vector>
namespace action {
namespace actions {
class undo_list;
@ -114,7 +114,7 @@ size_t move_unit(const std::vector<map_location> &steps,
bool unit_can_move(const unit &u);
}//namespace action
}//namespace actions
#endif

View file

@ -42,7 +42,7 @@ static lg::log_domain log_engine("engine");
#define LOG_NG LOG_STREAM(info, log_engine)
namespace action {
namespace actions {
/**
@ -675,5 +675,5 @@ size_t undo_list::apply_shroud_changes() const
}
}//namespace action
}//namespace actions

View file

@ -29,7 +29,7 @@
#include <vector>
namespace action {
namespace actions {
/// Class to store the actions that a player can undo and redo.
@ -216,6 +216,6 @@ private: // data
};
}//namespace action
}//namespace actions
#endif

View file

@ -92,7 +92,7 @@ static bool can_see(const unit & viewer, const map_location & loc,
}
namespace action {
namespace actions {
/**
@ -619,5 +619,5 @@ bool clear_shroud(int side, bool reset_fog, bool fire_events)
}
}//namespace action
}//namespace actions

View file

@ -32,7 +32,7 @@ class unit;
#include <vector>
namespace action {
namespace actions {
class move_unit_spectator;
/// Class to encapsulate fog/shroud clearing and the resultant sighted events.
@ -114,6 +114,6 @@ void recalculate_fog(int side);
bool clear_shroud(int side, bool reset_fog = false, bool fire_events = true);
}//namespace action
}//namespace actions
#endif

View file

@ -466,14 +466,14 @@ void move_result::do_execute()
move_spectator_.set_unit(resources::units->find(from_));
if (from_ != to_) {
size_t num_steps = action::move_unit(
size_t num_steps = ::actions::move_unit(
/*std::vector<map_location> steps*/ route_->steps,
/*replay* move_recorder*/ &recorder,
/*action::undo_list* undo_stack*/ NULL,
/*::actions::undo_list* undo_stack*/ NULL,
/*bool continue_move*/ true, ///@todo 1.9 set to false after implemeting interrupt awareness
/*bool show_move*/ preferences::show_ai_moves(),
/*bool* interrupted*/ NULL,
/*action::move_unit_spectator* move_spectator*/ &move_spectator_);
/*::actions::move_unit_spectator* move_spectator*/ &move_spectator_);
if ( num_steps > 0 ) {
set_gamestate_changed();
@ -676,7 +676,7 @@ void recall_result::do_execute()
return;
} else {
recorder.add_recall(unit_id_, recall_location_, recall_from_);
action::recall_unit(unit_id_, my_team, recall_location_, recall_from_, true, true);
::actions::recall_unit(unit_id_, my_team, recall_location_, recall_from_, true, true);
if (resources::screen!=NULL) {
resources::screen->invalidate_game_status();
@ -879,7 +879,7 @@ void recruit_result::do_execute()
const events::command_disabler disable_commands;
const std::string recruit_err = find_recruit_location(get_side(), recruit_location_, recruit_from_, u->id());
if(recruit_err.empty()) {
action::recruit_unit(*u, get_side(), recruit_location_, recruit_from_, preferences::show_ai_moves(), true);
::actions::recruit_unit(*u, get_side(), recruit_location_, recruit_from_, preferences::show_ai_moves(), true);
// Confirm the transaction - i.e. don't undo recruitment
replay_guard.confirm_transaction();
set_gamestate_changed();

View file

@ -189,7 +189,7 @@ private:
const unit *get_unit();
bool test_route(const unit &un);
const map_location from_;
action::move_unit_spectator move_spectator_;
::actions::move_unit_spectator move_spectator_;
const map_location to_;
bool remove_movement_;
boost::shared_ptr<pathfind::plain_route> route_;

View file

@ -877,7 +877,7 @@ WML_HANDLER_FUNCTION(teleport, event_info, cfg)
const map_location vacant_dst = find_vacant_tile(dst, pathfind::VACANT_ANY, pass_check);
if (!resources::game_map->on_board(vacant_dst)) return;
action::shroud_clearer clearer;
actions::shroud_clearer clearer;
if (cfg["clear_shroud"].to_bool(true)) {
clearer.clear_unit(vacant_dst, *u);
}
@ -897,7 +897,7 @@ WML_HANDLER_FUNCTION(teleport, event_info, cfg)
u->set_standing();
if (resources::game_map->is_village(vacant_dst)) {
action::get_village(vacant_dst, u->side());
actions::get_village(vacant_dst, u->side());
}
resources::screen->invalidate_unit_after_move(src_loc, dst);
@ -2557,7 +2557,7 @@ WML_HANDLER_FUNCTION(redraw, /*event_info*/, cfg)
if (clear_shroud_bool) {
side_filter filter(cfg);
BOOST_FOREACH(const int side, filter.get_teams()){
action::clear_shroud(side);
actions::clear_shroud(side);
}
screen.recalculate_minimap();
}

View file

@ -862,7 +862,7 @@ bool menu_handler::do_recruit(const std::string &name, int side_num,
current_team.set_action_bonus_count(1 + current_team.action_bonus_count());
// Do the recruiting.
action::recruit_unit(*u_type, side_num, loc, recruited_from);
actions::recruit_unit(*u_type, side_num, loc, recruited_from);
// Update the display,
gui_->redraw_minimap();
@ -1058,7 +1058,7 @@ bool menu_handler::do_recall(const unit& un, int side_num, const map_location& r
team &current_team = teams_[side_num - 1];
recorder.add_recall(un.id(), recall_location, recall_from);
if ( !action::recall_unit(un.id(), current_team, recall_location, recall_from) )
if ( !actions::recall_unit(un.id(), current_team, recall_location, recall_from) )
{
ERR_NG << "menu_handler::do_recall(): Unit doesn't exist in recall list.\n";
return false;
@ -1133,7 +1133,7 @@ namespace { // Helpers for menu_handler::end_turn()
if ( un->side() == side_num ) {
// @todo whiteboard should take into consideration units that have
// a planned move but can still plan more movement in the same turn
if ( action::unit_can_move(*un) && !resources::whiteboard->unit_has_actions(&*un) )
if ( actions::unit_can_move(*un) && !resources::whiteboard->unit_has_actions(&*un) )
return true;
}
}
@ -1147,7 +1147,7 @@ namespace { // Helpers for menu_handler::end_turn()
{
for ( unit_map::const_iterator un = units.begin(); un != units.end(); ++un ) {
if ( un->side() == side_num ) {
if ( action::unit_can_move(*un) && !un->has_moved() &&
if ( actions::unit_can_move(*un) && !un->has_moved() &&
!resources::whiteboard->unit_has_actions(&*un) )
return true;
}
@ -1287,7 +1287,7 @@ void menu_handler::create_unit_2(mouse_handler& mousehandler)
units_.replace(loc, chosen);
if(map_.is_village(loc)) {
action::get_village(loc, chosen.side());
actions::get_village(loc, chosen.side());
}
gui_->invalidate(loc);
@ -1380,7 +1380,7 @@ void menu_handler::create_unit(mouse_handler& mousehandler)
unit_display::unit_recruited(loc);
if(map_.is_village(loc)) {
action::get_village(loc, chosen.side());
actions::get_village(loc, chosen.side());
}
gui_->invalidate(loc);
@ -1403,7 +1403,7 @@ void menu_handler::change_side(mouse_handler& mousehandler)
if(team > team::nteams()) {
team = 0;
}
action::get_village(loc, team + 1);
actions::get_village(loc, team + 1);
} else {
int side = i->side();
++side;
@ -1413,7 +1413,7 @@ void menu_handler::change_side(mouse_handler& mousehandler)
i->set_side(side);
if(map_.is_village(loc)) {
action::get_village(loc, side);
actions::get_village(loc, side);
}
}
}
@ -1485,7 +1485,7 @@ void menu_handler::move_unit_to_loc(const unit_map::iterator &ui,
gui_->set_route(&route);
gui_->unhighlight_reach();
action::move_unit(route.steps, &recorder, resources::undo_stack, continue_move);
actions::move_unit(route.steps, &recorder, resources::undo_stack, continue_move);
gui_->set_route(NULL);
gui_->invalidate_game_status();
}
@ -1554,7 +1554,7 @@ void menu_handler::execute_gotos(mouse_handler &mousehandler, int side)
}
gui_->set_route(&route);
int moves = action::move_unit(route.steps, &recorder, resources::undo_stack);
int moves = actions::move_unit(route.steps, &recorder, resources::undo_stack);
change = moves > 0;
if (change) {
@ -3405,13 +3405,13 @@ void console_handler::do_create() {
}
void console_handler::do_fog() {
menu_handler_.teams_[team_num_ - 1].set_fog( !menu_handler_.teams_[team_num_ - 1].uses_fog() );
action::recalculate_fog(team_num_);
actions::recalculate_fog(team_num_);
menu_handler_.gui_->recalculate_minimap();
menu_handler_.gui_->redraw_everything();
}
void console_handler::do_shroud() {
menu_handler_.teams_[team_num_ - 1].set_shroud( !menu_handler_.teams_[team_num_ - 1].uses_shroud() );
action::clear_shroud(team_num_);
actions::clear_shroud(team_num_);
menu_handler_.gui_->recalculate_minimap();
menu_handler_.gui_->redraw_everything();
}

View file

@ -758,7 +758,7 @@ bool mouse_handler::move_unit_along_current_route()
* Moves a unit across the board for a player.
* This is specifically for movement at the time it is initiated by a player,
* whether via a mouse click or executing whiteboard actions. Continued moves
* (including goto execution) can bypass this and call action::move_unit() directly.
* (including goto execution) can bypass this and call actions::move_unit() directly.
* This function call may include time for an animation, so make sure the
* provided route will remain unchanged (the caller should probably make a local
* copy).
@ -800,8 +800,8 @@ size_t mouse_handler::move_unit_along_route(const std::vector<map_location> & st
size_t moves = 0;
try {
moves = action::move_unit(steps, &recorder, resources::undo_stack,
false, true, &interrupted);
moves = actions::move_unit(steps, &recorder, resources::undo_stack,
false, true, &interrupted);
} catch(end_turn_exception&) {
cursor::set(cursor::NORMAL);
gui().invalidate_game_status();
@ -1165,7 +1165,7 @@ bool mouse_handler::unit_in_cycle(unit_map::const_iterator it)
return false;
if (it->side() != side_num_ || it->user_end_turn()
|| gui().fogged(it->get_location()) || !action::unit_can_move(*it))
|| gui().fogged(it->get_location()) || !actions::unit_can_move(*it))
return false;
if (current_team().is_enemy(int(gui().viewing_team()+1)) &&

View file

@ -107,7 +107,7 @@ play_controller::play_controller(const config& level, game_state& state_of_game,
gamedata_(level),
map_(game_config, level),
units_(),
undo_stack_(new action::undo_list(level.child("undo_stack"))),
undo_stack_(new actions::undo_list(level.child("undo_stack"))),
whiteboard_manager_(),
xp_mod_(level["experience_modifier"].to_int(100)),
loading_game_(level["playing_team"].empty() == false),
@ -561,7 +561,7 @@ void play_controller::init_gui(){
if ( !loading_game_ ) {
for ( int side = teams_.size(); side != 0; --side )
action::clear_shroud(side, false, false);
actions::clear_shroud(side, false, false);
}
}
@ -664,7 +664,7 @@ void play_controller::do_init_side(const unsigned int team_index, bool is_replay
game_events::fire("side " + side_num + " turn " + turn_num + " refresh");
// Make sure vision is accurate.
action::clear_shroud(player_number_, true);
actions::clear_shroud(player_number_, true);
}
const time_of_day &tod = tod_manager_.get_time_of_day();
@ -756,7 +756,7 @@ void play_controller::finish_side_turn(){
uit->end_turn();
}
// Clear shroud, in case units had been slowed for the turn.
action::clear_shroud(player_number_);
actions::clear_shroud(player_number_);
const std::string turn_num = str_cast(turn());
const std::string side_num = str_cast(player_number_);
@ -766,7 +766,7 @@ void play_controller::finish_side_turn(){
game_events::fire("side " + side_num + " turn " + turn_num + " end");
// This is where we refog, after all of a side's events are done.
action::recalculate_fog(player_number_);
actions::recalculate_fog(player_number_);
// This implements "delayed map sharing."
// It is meant as an alternative to shared vision.

View file

@ -35,7 +35,7 @@ class game_data;
class team;
struct wml_menu_item;
namespace action {
namespace actions {
class undo_list;
}
@ -224,7 +224,7 @@ protected:
/// undo_stack_ is never NULL. It is implemented as a pointer so that
/// undo_list can be an incomplete type at this point (which reduces the
/// number of files that depend on actions/undo.hpp).
boost::scoped_ptr<action::undo_list> undo_stack_;
boost::scoped_ptr<actions::undo_list> undo_stack_;
//whiteboard manager
boost::scoped_ptr<wb::manager> whiteboard_manager_;

View file

@ -985,7 +985,7 @@ bool do_replay_handle(int side_num, const std::string &do_untill)
const int beginning_gold = current_team.gold();
if (res.empty()) {
action::recruit_unit(*u_type, side_num, loc, from, !get_replay_source().is_skipping(), true);
actions::recruit_unit(*u_type, side_num, loc, from, !get_replay_source().is_skipping(), true);
} else {
std::stringstream errbuf;
errbuf << "cannot recruit unit: " << res << "\n";
@ -1014,7 +1014,7 @@ bool do_replay_handle(int side_num, const std::string &do_untill)
map_location loc(child, resources::gamedata);
map_location from(child.child_or_empty("from"), resources::gamedata);
if ( !action::recall_unit(unit_id, current_team, loc, from, !get_replay_source().is_skipping(), true) ) {
if ( !actions::recall_unit(unit_id, current_team, loc, from, !get_replay_source().is_skipping(), true) ) {
replay::process_error("illegal recall: unit_id '" + unit_id + "' could not be found within the recall list.\n");
}
check_checksums(*cfg);
@ -1092,7 +1092,7 @@ bool do_replay_handle(int side_num, const std::string &do_untill)
if ( current_team.is_ai() || current_team.is_network_ai() )
show_move = show_move && preferences::show_ai_moves();
const int num_steps =
action::move_unit(steps, NULL, NULL, true, show_move, NULL, NULL, &early_stop);
actions::move_unit(steps, NULL, NULL, true, show_move, NULL, NULL, &early_stop);
// Verify our destination.
const map_location& actual_stop = steps[num_steps];

View file

@ -29,7 +29,7 @@ namespace resources
std::vector<team> *teams = NULL;
::tod_manager *tod_manager = NULL;
pathfind::manager *tunnels = NULL;
action::undo_list *undo_stack = NULL;
actions::undo_list *undo_stack = NULL;
unit_map *units = NULL;
wb::manager *whiteboard = NULL;
}

View file

@ -29,7 +29,7 @@ class tod_manager;
class unit_map;
class persist_manager;
namespace action { class undo_list; }
namespace actions { class undo_list; }
namespace soundsource { class manager; }
@ -50,7 +50,7 @@ namespace resources
extern std::vector<team> *teams;
extern ::tod_manager *tod_manager;
extern pathfind::manager *tunnels;
extern action::undo_list *undo_stack;
extern actions::undo_list *undo_stack;
extern unit_map *units;
extern wb::manager *whiteboard;
}

View file

@ -25,7 +25,7 @@
using namespace wb;
struct dummy_action: wb::action{
struct dummy_action: action{
dummy_action(size_t team_index, bool hidden, int id): action(team_index, hidden), id_(id) {}
int id_;

View file

@ -2097,7 +2097,7 @@ void unit::redraw_unit()
if(disp.playing_team() == disp.viewing_team() && !user_end_turn()) {
if (movement_left() == total_movement()) {
orb_img = &unmoved_orb;
} else if ( action::unit_can_move(*this) ) {
} else if ( actions::unit_can_move(*this) ) {
orb_img = &partmoved_orb;
}
}