Skip to content

Commit

Permalink
fixup camel case names UnitPtr, UnitConstPtr
Browse files Browse the repository at this point in the history
This commit created using sed, in directory src/:

$ find . -type f -exec sed -i 's/UnitPtr/unit_ptr/g' {} +
$ find . -type f -exec sed -i 's/UnitConstPtr/unit_const_ptr/g' {} +

and inspecting the results.
  • Loading branch information
cbeck88 committed Jun 29, 2014
1 parent 8a051a2 commit 97d5d14
Show file tree
Hide file tree
Showing 57 changed files with 252 additions and 252 deletions.
20 changes: 10 additions & 10 deletions src/actions/create.cpp
Expand Up @@ -191,11 +191,11 @@ void unit_creator::add_unit(const config &cfg, const vconfig* vcfg)
bool animate = temp_cfg["animate"].to_bool();
temp_cfg.remove_attribute("animate");

UnitPtr recall_list_element = team_.recall_list().find_if_matches_id(id);
unit_ptr recall_list_element = team_.recall_list().find_if_matches_id(id);

if ( !recall_list_element ) {
//make the new unit
UnitPtr new_unit(new unit(temp_cfg, true, vcfg));
unit_ptr new_unit(new unit(temp_cfg, true, vcfg));
map_location loc = find_location(temp_cfg, new_unit.get());
if ( loc.valid() ) {
//add the new unit to map
Expand Down Expand Up @@ -412,14 +412,14 @@ namespace { // Helpers for get_recalls()
* that can be skipped (because they are already in @a result), and the
* underlying ID of units added to @a result will be added to @a already_added.
*/
void add_leader_filtered_recalls(const UnitConstPtr leader,
std::vector< UnitConstPtr > & result,
void add_leader_filtered_recalls(const unit_const_ptr leader,
std::vector< unit_const_ptr > & result,
std::set<size_t> * already_added = NULL)
{
const team& leader_team = (*resources::teams)[leader->side()-1];
const std::string& save_id = leader_team.save_id();

BOOST_FOREACH(const UnitConstPtr & recall_unit_ptr, leader_team.recall_list())
BOOST_FOREACH(const unit_const_ptr & recall_unit_ptr, leader_team.recall_list())
{
const unit & recall_unit = *recall_unit_ptr;
// Do not add a unit twice.
Expand All @@ -440,11 +440,11 @@ namespace { // Helpers for get_recalls()
}
}// anonymous namespace

std::vector<UnitConstPtr > get_recalls(int side, const map_location &recall_loc)
std::vector<unit_const_ptr > get_recalls(int side, const map_location &recall_loc)
{
LOG_NG << "getting recall list for side " << side << " at location " << recall_loc << "\n";

std::vector<UnitConstPtr > result;
std::vector<unit_const_ptr > result;

/*
* We have three use cases:
Expand Down Expand Up @@ -499,7 +499,7 @@ std::vector<UnitConstPtr > get_recalls(int side, const map_location &recall_loc)
if ( !leader_in_place )
{
// Return the full recall list.
BOOST_FOREACH(const UnitConstPtr & recall, (*resources::teams)[side-1].recall_list())
BOOST_FOREACH(const unit_const_ptr & recall, (*resources::teams)[side-1].recall_list())
{
result.push_back(recall);
}
Expand Down Expand Up @@ -975,7 +975,7 @@ bool place_recruit(const unit &u, const map_location &recruit_location, const ma
void recruit_unit(const unit_type & u_type, int side_num, const map_location & loc,
const map_location & from, bool show, bool use_undo)
{
const UnitPtr new_unit = UnitPtr( new unit(u_type, side_num, true));
const unit_ptr new_unit = unit_ptr( new unit(u_type, side_num, true));


// Place the recruit.
Expand Down Expand Up @@ -1008,7 +1008,7 @@ bool recall_unit(const std::string & id, team & current_team,
const map_location & loc, const map_location & from,
bool show, bool use_undo)
{
UnitPtr recall = current_team.recall_list().extract_if_matches_id(id);
unit_ptr recall = current_team.recall_list().extract_if_matches_id(id);

if ( !recall )
return false;
Expand Down
2 changes: 1 addition & 1 deletion src/actions/create.hpp
Expand Up @@ -189,7 +189,7 @@ const std::set<std::string> get_recruits(int side, const map_location &recruit_l
* @param recall_loc the hex field being part of the castle the player wants to recruit on or from.
* @return a set of units that can be recalled by @a side on (or from) @a recall_loc or the full recall list of @a side.
*/
std::vector<UnitConstPtr > get_recalls(int side, const map_location &recall_loc);
std::vector<unit_const_ptr > get_recalls(int side, const map_location &recall_loc);

/**
* Place a unit into the game.
Expand Down
24 changes: 12 additions & 12 deletions src/actions/undo.cpp
Expand Up @@ -38,7 +38,7 @@
#include "../unit_animation_component.hpp"
#include "../unit_display.hpp" // for move_unit
#include "../unit_map.hpp" // for unit_map, etc
#include "../unit_ptr.hpp" // for UnitConstPtr, UnitPtr
#include "../unit_ptr.hpp" // for unit_const_ptr, unit_ptr
#include "../unit_types.hpp" // for unit_type, unit_type_data, etc
#include "../util.hpp" // for bad_lexical_cast (ptr only), etc
#include "../whiteboard/manager.hpp" // for manager
Expand Down Expand Up @@ -77,10 +77,10 @@ undo_list::undo_action::~undo_action()


struct undo_list::dismiss_action : undo_list::undo_action {
UnitPtr dismissed_unit;
unit_ptr dismissed_unit;


explicit dismiss_action(const UnitConstPtr dismissed) : undo_action(),
explicit dismiss_action(const unit_const_ptr dismissed) : undo_action(),
dismissed_unit(new unit(*dismissed))
{}
explicit dismiss_action(const config & unit_cfg) : undo_action(),
Expand All @@ -107,7 +107,7 @@ struct undo_list::move_action : undo_list::undo_action {
map_location goto_hex;


move_action(const UnitConstPtr moved,
move_action(const unit_const_ptr moved,
const std::vector<map_location>::const_iterator & begin,
const std::vector<map_location>::const_iterator & end,
int sm, int timebonus, int orig, const map_location::DIRECTION dir) :
Expand Down Expand Up @@ -148,7 +148,7 @@ struct undo_list::recall_action : undo_list::undo_action {
map_location recall_from;


recall_action(const UnitConstPtr recalled, const map_location& loc,
recall_action(const unit_const_ptr recalled, const map_location& loc,
const map_location& from) :
undo_action(recalled, loc),
id(recalled->id()),
Expand Down Expand Up @@ -178,7 +178,7 @@ struct undo_list::recruit_action : undo_list::undo_action {
map_location recruit_from;


recruit_action(const UnitConstPtr recruited, const map_location& loc,
recruit_action(const unit_const_ptr recruited, const map_location& loc,
const map_location& from) :
undo_action(recruited, loc),
u_type(recruited->type()),
Expand Down Expand Up @@ -420,15 +420,15 @@ void undo_list::add_auto_shroud(bool turned_on)
/**
* Adds a dismissal to the undo stack.
*/
void undo_list::add_dismissal(const UnitConstPtr u)
void undo_list::add_dismissal(const unit_const_ptr u)
{
add(new dismiss_action(u));
}

/**
* Adds a move to the undo stack.
*/
void undo_list::add_move(const UnitConstPtr u,
void undo_list::add_move(const unit_const_ptr u,
const std::vector<map_location>::const_iterator & begin,
const std::vector<map_location>::const_iterator & end,
int start_moves, int timebonus, int village_owner,
Expand All @@ -440,7 +440,7 @@ void undo_list::add_move(const UnitConstPtr u,
/**
* Adds a recall to the undo stack.
*/
void undo_list::add_recall(const UnitConstPtr u, const map_location& loc,
void undo_list::add_recall(const unit_const_ptr u, const map_location& loc,
const map_location& from)
{
add(new recall_action(u, loc, from));
Expand All @@ -449,7 +449,7 @@ void undo_list::add_recall(const UnitConstPtr u, const map_location& loc,
/**
* Adds a recruit to the undo stack.
*/
void undo_list::add_recruit(const UnitConstPtr u, const map_location& loc,
void undo_list::add_recruit(const unit_const_ptr u, const map_location& loc,
const map_location& from)
{
add(new recruit_action(u, loc, from));
Expand Down Expand Up @@ -669,7 +669,7 @@ bool undo_list::recall_action::undo(int side, undo_list & /*undos*/)
return false;
}

UnitPtr un = un_it.get_shared_ptr();
unit_ptr un = un_it.get_shared_ptr();
if (!un) {
return false;
}
Expand Down Expand Up @@ -876,7 +876,7 @@ bool undo_list::recall_action::redo(int side)
map_location loc = route.front();
map_location from = recall_from;

UnitPtr un = current_team.recall_list().find_if_matches_id(id);
unit_ptr un = current_team.recall_list().find_if_matches_id(id);
if ( !un ) {
ERR_NG << "Trying to redo a recall of '" << id
<< "', but that unit is not in the recall list.";
Expand Down
12 changes: 6 additions & 6 deletions src/actions/undo.hpp
Expand Up @@ -38,7 +38,7 @@ class undo_list : boost::noncopyable {
/// Each type of action gets its own derived type.
struct undo_action : boost::noncopyable {
/// Constructor for move actions.
undo_action(const UnitConstPtr u,
undo_action(const unit_const_ptr u,
const std::vector<map_location>::const_iterator & begin,
const std::vector<map_location>::const_iterator & end) :
route(begin, end),
Expand All @@ -47,7 +47,7 @@ class undo_list : boost::noncopyable {
}
/// Constructor for recruit and recall actions.
/// These types of actions are guaranteed to have a non-empty route.
undo_action(const UnitConstPtr u, const map_location& loc) :
undo_action(const unit_const_ptr u, const map_location& loc) :
route(1, loc),
view_info(new clearer_info(*u))
{}
Expand Down Expand Up @@ -124,18 +124,18 @@ class undo_list : boost::noncopyable {
/// Adds an auto-shroud toggle to the undo stack.
void add_auto_shroud(bool turned_on);
/// Adds a dismissal to the undo stack.
void add_dismissal(const UnitConstPtr u);
void add_dismissal(const unit_const_ptr u);
/// Adds a move to the undo stack.
void add_move(const UnitConstPtr u,
void add_move(const unit_const_ptr u,
const std::vector<map_location>::const_iterator & begin,
const std::vector<map_location>::const_iterator & end,
int start_moves, int timebonus=0, int village_owner=-1,
const map_location::DIRECTION dir=map_location::NDIRECTIONS);
/// Adds a recall to the undo stack.
void add_recall(const UnitConstPtr u, const map_location& loc,
void add_recall(const unit_const_ptr u, const map_location& loc,
const map_location& from);
/// Adds a recruit to the undo stack.
void add_recruit(const UnitConstPtr u, const map_location& loc,
void add_recruit(const unit_const_ptr u, const map_location& loc,
const map_location& from);
private:
/// Adds a shroud update to the undo stack.
Expand Down
6 changes: 3 additions & 3 deletions src/ai/actions.cpp
Expand Up @@ -495,9 +495,9 @@ recall_result::recall_result(side_number side,
{
}

UnitConstPtr recall_result::get_recall_unit(const team &my_team)
unit_const_ptr recall_result::get_recall_unit(const team &my_team)
{
UnitConstPtr rec = my_team.recall_list().find_if_matches_id(unit_id_);
unit_const_ptr rec = my_team.recall_list().find_if_matches_id(unit_id_);
if (!rec) {
set_error(E_NOT_AVAILABLE_FOR_RECALLING);
}
Expand Down Expand Up @@ -525,7 +525,7 @@ void recall_result::do_check_before()
}

//Unit available for recalling?
const UnitConstPtr & to_recall = get_recall_unit(my_team);
const unit_const_ptr & to_recall = get_recall_unit(my_team);
if ( !to_recall ) {
return;
}
Expand Down
2 changes: 1 addition & 1 deletion src/ai/actions.hpp
Expand Up @@ -220,7 +220,7 @@ class recall_result : public action_result {
virtual void do_execute();
virtual void do_init_for_execution();
private:
UnitConstPtr get_recall_unit(
unit_const_ptr get_recall_unit(
const team& my_team);
bool test_enough_gold(
const team& my_team);
Expand Down
4 changes: 2 additions & 2 deletions src/ai/composite/engine_lua.cpp
Expand Up @@ -168,7 +168,7 @@ class lua_sticky_candidate_action_wrapper : public lua_candidate_action_wrapper
, bound_unit_()
{
map_location loc(cfg["unit_x"] - 1, cfg["unit_y"] - 1); // lua and c++ coords differ by one
bound_unit_ = UnitPtr(new unit(*resources::units->find(loc)));
bound_unit_ = unit_ptr(new unit(*resources::units->find(loc)));
}

virtual double evaluate()
Expand All @@ -190,7 +190,7 @@ class lua_sticky_candidate_action_wrapper : public lua_candidate_action_wrapper
this->disable(); // we do not want to execute the same sticky CA twice -> will be moved out to Lua later
}
private:
UnitPtr bound_unit_;
unit_ptr bound_unit_;

};

Expand Down
6 changes: 3 additions & 3 deletions src/ai/contexts.cpp
Expand Up @@ -53,7 +53,7 @@
#include "tod_manager.hpp" // for tod_manager
#include "unit.hpp" // for unit, intrusive_ptr_release, etc
#include "unit_map.hpp" // for unit_map::iterator_base, etc
#include "unit_ptr.hpp" // for UnitPtr
#include "unit_ptr.hpp" // for unit_ptr
#include "unit_types.hpp" // for attack_type, unit_type, etc
#include "variant.hpp" // for variant

Expand Down Expand Up @@ -800,9 +800,9 @@ const moves_map& readonly_context_impl::get_possible_moves() const
}


const std::vector<UnitPtr>& readonly_context_impl::get_recall_list() const
const std::vector<unit_ptr>& readonly_context_impl::get_recall_list() const
{
static std::vector<UnitPtr> dummy_units;
static std::vector<unit_ptr> dummy_units;
///@todo 1.9: check for (level_["disallow_recall"]))
if(!current_team().persistent()) {
return dummy_units;
Expand Down
8 changes: 4 additions & 4 deletions src/ai/contexts.hpp
Expand Up @@ -28,7 +28,7 @@
#include "../config.hpp" // for config
#include "../game_errors.hpp"
#include "../generic_event.hpp" // for observer
#include "../unit_ptr.hpp" // for UnitPtr
#include "../unit_ptr.hpp" // for unit_ptr
#include "../map_location.hpp" // for map_location

#include <map> // for map, map<>::value_compare
Expand Down Expand Up @@ -307,7 +307,7 @@ class readonly_context : public virtual side_context {
virtual const moves_map& get_possible_moves() const = 0;


virtual const std::vector<UnitPtr>& get_recall_list() const = 0;
virtual const std::vector<unit_ptr>& get_recall_list() const = 0;


virtual stage_ptr get_recruitment(ai_context &context) const = 0;
Expand Down Expand Up @@ -828,7 +828,7 @@ class readonly_context_proxy : public virtual readonly_context, public virtual s
}


virtual const std::vector<UnitPtr>& get_recall_list() const
virtual const std::vector<unit_ptr>& get_recall_list() const
{
return target_->get_recall_list();
}
Expand Down Expand Up @@ -1436,7 +1436,7 @@ class readonly_context_impl : public virtual side_context_proxy, public readonly
virtual const moves_map& get_possible_moves() const;


virtual const std::vector<UnitPtr>& get_recall_list() const;
virtual const std::vector<unit_ptr>& get_recall_list() const;


virtual stage_ptr get_recruitment(ai_context &context) const;
Expand Down
2 changes: 1 addition & 1 deletion src/ai/default/ai.cpp
Expand Up @@ -657,7 +657,7 @@ class unit_combat_score_getter {
: stage_(s)
{
}
std::pair<std::string, double> operator()(const UnitPtr u_ptr) {
std::pair<std::string, double> operator()(const unit_ptr u_ptr) {
const unit & u = *u_ptr;
std::pair<std::string,int> p;
p.first = u.id();
Expand Down
2 changes: 1 addition & 1 deletion src/ai/default/attack.cpp
Expand Up @@ -97,7 +97,7 @@ void attack_analysis::analyze(const gamemap& map, unit_map& units,

for (m = movements.begin(); m != movements.end(); ++m) {
// We fix up units map to reflect what this would look like.
UnitPtr up = units.extract(m->first);
unit_ptr up = units.extract(m->first);
up->set_location(m->second);
units.insert(up);
double m_aggression = aggression;
Expand Down
4 changes: 2 additions & 2 deletions src/ai/formula/ai.cpp
Expand Up @@ -41,7 +41,7 @@
#include "../../tstring.hpp" // for t_string, operator+
#include "../../unit.hpp" // for unit
#include "../../unit_formula_manager.hpp" // for unit_formula_manager
#include "../../unit_ptr.hpp" // for UnitPtr
#include "../../unit_ptr.hpp" // for unit_ptr
#include "../../unit_types.hpp"
#include "../../formula.hpp" // for formula_error, formula, etc
#include "../../map_location.hpp" // for map_location, etc
Expand Down Expand Up @@ -833,7 +833,7 @@ variant formula_ai::get_value(const std::string& key) const
{
std::vector<variant> tmp;

for(std::vector<UnitPtr >::const_iterator i = current_team().recall_list().begin(); i != current_team().recall_list().end(); ++i) {
for(std::vector<unit_ptr >::const_iterator i = current_team().recall_list().begin(); i != current_team().recall_list().end(); ++i) {
tmp.push_back( variant( new unit_callable(**i) ) );
}

Expand Down
4 changes: 2 additions & 2 deletions src/ai/lua/core.cpp
Expand Up @@ -118,7 +118,7 @@ static bool to_map_location(lua_State *L, int &index, map_location &res)
{
if (lua_isuserdata(L, index))
{
const UnitConstPtr u = luaW_tounit(L, index);
const unit_const_ptr u = luaW_tounit(L, index);
if (!u) return false;
res = u->get_location();
++index;
Expand All @@ -141,7 +141,7 @@ static int cfun_ai_get_suitable_keep(lua_State *L)
int index = 1;

ai::readonly_context &context = get_readonly_context(L);
UnitConstPtr leader;
unit_const_ptr leader;
if (lua_isuserdata(L, index))
{
leader = luaW_tounit(L, index);
Expand Down

0 comments on commit 97d5d14

Please sign in to comment.