Skip to content

Commit

Permalink
Use std::size_t everywhere instead of plain size_t
Browse files Browse the repository at this point in the history
Excludes:
* spirit_po/
* xBRZ/
  • Loading branch information
Vultraz committed Mar 19, 2018
1 parent 4225e1a commit fc2a58f
Show file tree
Hide file tree
Showing 326 changed files with 1,472 additions and 1,472 deletions.
4 changes: 2 additions & 2 deletions src/actions/advancement.cpp
Expand Up @@ -64,7 +64,7 @@ namespace
previews.push_back(get_advanced_unit(u, advance));
}

size_t num_real_advances = previews.size();
std::size_t num_real_advances = previews.size();
bool always_display = false;

for (const config& advance : u.get_modification_advances()) {
Expand All @@ -90,7 +90,7 @@ namespace
return 0;
}

bool animate_unit_advancement(const map_location &loc, size_t choice, const bool &fire_event, const bool animate)
bool animate_unit_advancement(const map_location &loc, std::size_t choice, const bool &fire_event, const bool animate)
{
const events::command_disabler cmd_disabler;

Expand Down
4 changes: 2 additions & 2 deletions src/actions/attack.cpp
Expand Up @@ -815,7 +815,7 @@ class attack
const map_location loc_;
int weapon_;
unit_map& units_;
size_t id_; /**< unit.underlying_id() */
std::size_t id_; /**< unit.underlying_id() */
std::string weap_id_;
int orig_attacks_;
int n_attacks_; /**< Number of attacks left. */
Expand Down Expand Up @@ -1666,7 +1666,7 @@ bool backstab_check(const map_location& attacker_loc,
}

// If sides aren't valid teams, then they are enemies.
if(size_t(defender->side() - 1) >= teams.size() || size_t(opp->side() - 1) >= teams.size()) {
if(std::size_t(defender->side() - 1) >= teams.size() || std::size_t(opp->side() - 1) >= teams.size()) {
return true;
}

Expand Down
8 changes: 4 additions & 4 deletions src/actions/create.cpp
Expand Up @@ -127,7 +127,7 @@ namespace { // Helpers for get_recalls()
*/
void add_leader_filtered_recalls(const unit_const_ptr leader,
std::vector< unit_const_ptr > & result,
std::set<size_t> * already_added = nullptr)
std::set<std::size_t> * already_added = nullptr)
{
const team& leader_team = resources::gameboard->get_team(leader->side());
const std::string& save_id = leader_team.save_id();
Expand All @@ -138,7 +138,7 @@ namespace { // Helpers for get_recalls()
{
const unit & recall_unit = *recall_unit_ptr;
// Do not add a unit twice.
size_t underlying_id = recall_unit.underlying_id();
std::size_t underlying_id = recall_unit.underlying_id();
if ( !already_added || already_added->count(underlying_id) == 0 )
{
// Only units that match the leader's recall filter are valid.
Expand Down Expand Up @@ -195,7 +195,7 @@ std::vector<unit_const_ptr > get_recalls(int side, const map_location &recall_lo
{
unit_map::const_iterator u = resources::gameboard->units().begin(),
u_end = resources::gameboard->units().end();
std::set<size_t> valid_local_recalls;
std::set<std::size_t> valid_local_recalls;

for(; u != u_end; ++u) {
//We only consider leaders on our side.
Expand All @@ -213,7 +213,7 @@ std::vector<unit_const_ptr > get_recalls(int side, const map_location &recall_lo

if ( !leader_in_place )
{
std::set<size_t> valid_local_recalls;
std::set<std::size_t> valid_local_recalls;

for(auto u = resources::gameboard->units().begin(); u != resources::gameboard->units().end(); ++u) {
//We only consider leaders on our side.
Expand Down
18 changes: 9 additions & 9 deletions src/actions/move.cpp
Expand Up @@ -212,7 +212,7 @@ namespace { // Private helpers for move_unit()
const map_location & final_hex() const
{ return *move_loc_; }
/// The number of hexes actually entered.
size_t steps_travelled() const
std::size_t steps_travelled() const
{ return move_loc_ - begin_; }
/// After moving, use this to detect if movement was less than expected.
bool stopped_early() const { return expected_end_ != real_end_; }
Expand Down Expand Up @@ -324,8 +324,8 @@ namespace { // Private helpers for move_unit()
bool sighted_; // Records if sightings were made that could interrupt movement.
bool sighted_stop_; // Records if sightings were made that did interrupt movement (the same as sighted_ unless movement ended for another reason).
bool teleport_failed_;
size_t enemy_count_;
size_t friend_count_;
std::size_t enemy_count_;
std::size_t friend_count_;
std::string ambush_string_;
std::vector<map_location> ambushers_;
std::deque<int> moves_left_; // The front value is what the moving unit's remaining moves should be set to after the next step through the route.
Expand Down Expand Up @@ -625,7 +625,7 @@ namespace { // Private helpers for move_unit()
const unit_map &units = resources::gameboard->units();

// Loop through the previously-detected ambushers.
size_t i = 0;
std::size_t i = 0;
while ( i != ambushers_.size() ) {
if (units.count(ambushers_[i]) == 0) {
// Ambusher is gone.
Expand Down Expand Up @@ -831,7 +831,7 @@ namespace { // Private helpers for move_unit()
*/
void unit_mover::pump_sighted(const route_iterator & from)
{
const size_t track = resources::game_events->pump().wml_tracking();
const std::size_t track = resources::game_events->pump().wml_tracking();

auto pump_res = clearer_.fire_events();

Expand Down Expand Up @@ -1175,7 +1175,7 @@ namespace { // Private helpers for move_unit()
}//end anonymous namespace


static size_t move_unit_internal(undo_list* undo_stack,
static std::size_t move_unit_internal(undo_list* undo_stack,
bool show_move,
bool* interrupted,
unit_mover& mover)
Expand Down Expand Up @@ -1240,7 +1240,7 @@ static size_t move_unit_internal(undo_list* undo_stack,
* @a steps is not empty (the return value is guaranteed to be less
* than steps.size() ).
*/
size_t move_unit_and_record(const std::vector<map_location> &steps,
std::size_t move_unit_and_record(const std::vector<map_location> &steps,
undo_list* undo_stack,
bool continued_move, bool show_move,
bool* interrupted,
Expand Down Expand Up @@ -1273,7 +1273,7 @@ size_t move_unit_and_record(const std::vector<map_location> &steps,
*/
resources::recorder->add_synced_command("move",replay_helper::get_movement(steps, continued_move, skip_ally_sighted));
set_scontext_synced sync;
size_t r = move_unit_internal(undo_stack, show_move, interrupted, mover);
std::size_t r = move_unit_internal(undo_stack, show_move, interrupted, mover);
resources::controller->check_victory();
resources::controller->maybe_throw_return_to_play_side();
sync.do_final_checkup();
Expand All @@ -1286,7 +1286,7 @@ size_t move_unit_and_record(const std::vector<map_location> &steps,
}
}

size_t move_unit_from_replay(const std::vector<map_location> &steps,
std::size_t move_unit_from_replay(const std::vector<map_location> &steps,
undo_list* undo_stack,
bool continued_move,bool skip_ally_sighted, bool show_move)
{
Expand Down
4 changes: 2 additions & 2 deletions src/actions/move.hpp
Expand Up @@ -101,7 +101,7 @@ game_events::pump_result_t get_village(const map_location& loc, int side, bool *

/// Moves a unit across the board.
/// And enters the synced context.
size_t move_unit_and_record(const std::vector<map_location> &steps,
std::size_t move_unit_and_record(const std::vector<map_location> &steps,
undo_list* undo_stack,
bool continued_move = false,
bool show_move = true,
Expand All @@ -110,7 +110,7 @@ size_t move_unit_and_record(const std::vector<map_location> &steps,

/// Moves a unit across the board.
/// to be called from replay when we are already in the synced context.
size_t move_unit_from_replay(const std::vector<map_location> &steps,
std::size_t move_unit_from_replay(const std::vector<map_location> &steps,
undo_list* undo_stack,
bool continued_move, bool skip_ally_sighted,
bool show_move = true);
Expand Down
4 changes: 2 additions & 2 deletions src/actions/undo.cpp
Expand Up @@ -445,11 +445,11 @@ bool undo_list::apply_shroud_changes() const
}
shroud_clearer clearer;
bool cleared_shroud = false;
const size_t list_size = undos_.size();
const std::size_t list_size = undos_.size();


// Loop through the list of undo_actions.
for( size_t i = 0; i != list_size; ++i ) {
for( std::size_t i = 0; i != list_size; ++i ) {
if (const shroud_clearing_action* action = dynamic_cast<const shroud_clearing_action*>(&undos_[i])) {
LOG_NG << "Turning an undo...\n";

Expand Down
2 changes: 1 addition & 1 deletion src/actions/undo_action.cpp
Expand Up @@ -81,7 +81,7 @@ undo_action::undo_action(const config& cfg)
}

namespace {
unit_ptr get_unit(size_t uid, const std::string& id) {
unit_ptr get_unit(std::size_t uid, const std::string& id) {
assert(resources::gameboard);
auto iter = resources::gameboard->units().find(uid);
if(!iter.valid() || iter->id() != id) {
Expand Down
2 changes: 1 addition & 1 deletion src/actions/undo_action.hpp
Expand Up @@ -26,7 +26,7 @@ namespace actions {
struct undo_event {
config commands, data;
map_location loc1, loc2, filter_loc1, filter_loc2;
size_t uid1, uid2;
std::size_t uid1, uid2;
std::string id1, id2;
undo_event(const config& cmds, const game_events::queued_event& ctx);
undo_event(const config& first, const config& second, const config& weapons, const config& cmds);
Expand Down
44 changes: 22 additions & 22 deletions src/actions/vision.cpp
Expand Up @@ -139,15 +139,15 @@ void clearer_info::write(config & cfg) const
* time of the sighting, and the location of the sighted unit.
*/
struct shroud_clearer::sight_data {
sight_data(size_t viewed_id, const map_location & viewed_loc,
size_t viewer_id, const map_location & viewer_loc) :
sight_data(std::size_t viewed_id, const map_location & viewed_loc,
std::size_t viewer_id, const map_location & viewer_loc) :
seen_id(viewed_id), seen_loc(viewed_loc),
sighter_id(viewer_id), sighter_loc(viewer_loc)
{}

size_t seen_id;
std::size_t seen_id;
map_location seen_loc;
size_t sighter_id;
std::size_t sighter_id;
map_location sighter_loc;
};

Expand All @@ -157,7 +157,7 @@ struct shroud_clearer::sight_data {
*/
inline void shroud_clearer::record_sighting(
const unit & seen, const map_location & seen_loc,
size_t sighter_id, const map_location & sighter_loc)
std::size_t sighter_id, const map_location & sighter_loc)
{
sightings_.emplace_back(seen.underlying_id(), seen_loc, sighter_id, sighter_loc);
}
Expand Down Expand Up @@ -226,8 +226,8 @@ void shroud_clearer::calculate_jamming(const team * new_team)
bool shroud_clearer::clear_loc(team &tm, const map_location &loc,
const map_location &view_loc,
const map_location &event_non_loc,
size_t viewer_id, bool check_units,
size_t &enemy_count, size_t &friend_count,
std::size_t viewer_id, bool check_units,
std::size_t &enemy_count, std::size_t &friend_count,
move_unit_spectator * spectator)
{
const gamemap &map = resources::gameboard->map();
Expand Down Expand Up @@ -317,11 +317,11 @@ bool shroud_clearer::clear_loc(team &tm, const map_location &loc,
* locations in visual range were fogged/shrouded under shared vision/maps).
*/
bool shroud_clearer::clear_unit(const map_location &view_loc, team &view_team,
size_t viewer_id, int sight_range, bool slowed,
std::size_t viewer_id, int sight_range, bool slowed,
const movetype::terrain_costs & costs,
const map_location & real_loc,
const std::set<map_location>* known_units,
size_t * enemy_count, size_t * friend_count,
std::size_t * enemy_count, std::size_t * friend_count,
move_unit_spectator * spectator, bool /*instant*/)
{
// Give animations a chance to progress; see bug #20324.
Expand All @@ -330,7 +330,7 @@ bool shroud_clearer::clear_unit(const map_location &view_loc, team &view_team,

bool cleared_something = false;
// Dummy variables to make some logic simpler.
size_t enemies=0, friends=0;
std::size_t enemies=0, friends=0;
if ( enemy_count == nullptr )
enemy_count = &enemies;
if ( friend_count == nullptr )
Expand Down Expand Up @@ -390,7 +390,7 @@ bool shroud_clearer::clear_unit(const map_location &view_loc, team &view_team,
bool shroud_clearer::clear_unit(const map_location &view_loc,
const unit &viewer, team &view_team,
const std::set<map_location>* known_units,
size_t * enemy_count, size_t * friend_count,
std::size_t * enemy_count, std::size_t * friend_count,
move_unit_spectator * spectator, bool instant)
{
// This is just a translation to the more general interface. It is
Expand Down Expand Up @@ -484,15 +484,15 @@ bool shroud_clearer::clear_dest(const map_location &dest, const unit &viewer)
{
team & viewing_team = resources::gameboard->get_team(viewer.side());
// A pair of dummy variables needed to simplify some logic.
size_t enemies, friends;
std::size_t enemies, friends;

// Abort if there is nothing to clear.
if ( !viewing_team.fog_or_shroud() )
return false;

// Cache some values.
const map_location & real_loc = viewer.get_location();
const size_t viewer_id = viewer.underlying_id();
const std::size_t viewer_id = viewer.underlying_id();

// Clear the destination.
bool cleared_something = clear_loc(viewing_team, dest, dest, real_loc,
Expand Down Expand Up @@ -586,8 +586,8 @@ std::vector<int> get_sides_not_seeing(const unit & target)
const std::vector<team> & teams = resources::gameboard->teams();
std::vector<int> not_seeing;

size_t team_size = teams.size();
for ( size_t i = 0; i != team_size; ++i)
std::size_t team_size = teams.size();
for ( std::size_t i = 0; i != team_size; ++i)
if ( !target.is_visible_to_team(teams[i], *resources::gameboard, false) )
// not_see contains side numbers; i is a team index, so add 1.
not_seeing.push_back(i+1);
Expand Down Expand Up @@ -620,7 +620,7 @@ game_events::pump_result_t actor_sighted(const unit & target, const std::vector<
*/
{
const std::vector<team> & teams = resources::gameboard->teams();
const size_t teams_size = teams.size();
const std::size_t teams_size = teams.size();
const map_location & target_loc = target.get_location();

// Determine the teams that (probably) should get events.
Expand All @@ -634,20 +634,20 @@ game_events::pump_result_t actor_sighted(const unit & target, const std::vector<
// Exclude the target's own team.
needs_event[target.side()-1] = false;
// Exclude those teams that cannot see the target.
for ( size_t i = 0; i != teams_size; ++i )
for ( std::size_t i = 0; i != teams_size; ++i )
needs_event[i] = needs_event[i] && target.is_visible_to_team(teams[i], *resources::gameboard, false);

// Cache "jamming".
std::vector< std::map<map_location, int>> jamming_cache(teams_size);
for ( size_t i = 0; i != teams_size; ++i )
for ( std::size_t i = 0; i != teams_size; ++i )
if ( needs_event[i] )
create_jamming_map(jamming_cache[i], teams[i]);

// Look for units that can be used as the second unit in sighted events.
std::vector<const unit *> second_units(teams_size, nullptr);
std::vector<size_t> distances(teams_size, UINT_MAX);
std::vector<std::size_t> distances(teams_size, UINT_MAX);
for (const unit & viewer : resources::gameboard->units()) {
const size_t index = viewer.side() - 1;
const std::size_t index = viewer.side() - 1;
// Does viewer belong to a team for which we still need a unit?
if ( needs_event[index] && distances[index] != 0 ) {
if ( can_see(viewer, target_loc, &jamming_cache[index]) ) {
Expand All @@ -657,7 +657,7 @@ game_events::pump_result_t actor_sighted(const unit & target, const std::vector<
}
else {
// Consider viewer as a backup if it is close.
size_t viewer_distance =
std::size_t viewer_distance =
distance_between(target_loc, viewer.get_location());
if ( viewer_distance < distances[index] ) {
second_units[index] = &viewer;
Expand All @@ -669,7 +669,7 @@ game_events::pump_result_t actor_sighted(const unit & target, const std::vector<

// Raise events for the appropriate teams.
const game_events::entity_location target_entity(target);
for ( size_t i = 0; i != teams_size; ++i )
for ( std::size_t i = 0; i != teams_size; ++i )
if ( second_units[i] != nullptr ) {
resources::game_events->pump().raise(sighted_str, target_entity, game_events::entity_location(*second_units[i]));
}
Expand Down
14 changes: 7 additions & 7 deletions src/actions/vision.hpp
Expand Up @@ -39,7 +39,7 @@ namespace actions {
/// (Used by the undo stack as that cannot rely on a unit sticking around, and
/// we do not really need to copy the entire unit.)
struct clearer_info {
size_t underlying_id;
std::size_t underlying_id;
int sight_range;
bool slowed;
movetype::terrain_costs costs;
Expand Down Expand Up @@ -76,18 +76,18 @@ class shroud_clearer {
/// Clears shroud (and fog) around the provided location for @a view_team
/// based on @a sight_range, @a costs, and @a slowed.
bool clear_unit(const map_location &view_loc, team &view_team,
size_t viewer_id, int sight_range, bool slowed,
std::size_t viewer_id, int sight_range, bool slowed,
const movetype::terrain_costs & costs,
const map_location & real_loc,
const std::set<map_location>* known_units = nullptr,
size_t * enemy_count = nullptr, size_t * friend_count = nullptr,
std::size_t * enemy_count = nullptr, std::size_t * friend_count = nullptr,
move_unit_spectator * spectator = nullptr, bool instant = true);
/// Clears shroud (and fog) around the provided location for @a view_team
/// as if @a viewer was standing there.
bool clear_unit(const map_location &view_loc,
const unit &viewer, team &view_team,
const std::set<map_location>* known_units = nullptr,
size_t * enemy_count = nullptr, size_t * friend_count = nullptr,
std::size_t * enemy_count = nullptr, std::size_t * friend_count = nullptr,
move_unit_spectator * spectator = nullptr, bool instant = true);
/// Clears shroud (and fog) around the provided location for @a view_team
/// as if @a viewer was standing there. Setting @a instant to false
Expand Down Expand Up @@ -126,13 +126,13 @@ class shroud_clearer {

/// Clears shroud from a single location.
bool clear_loc(team &tm, const map_location &loc, const map_location &view_loc,
const map_location &event_non_loc, size_t viewer_id,
bool check_units, size_t &enemy_count, size_t &friend_count,
const map_location &event_non_loc, std::size_t viewer_id,
bool check_units, std::size_t &enemy_count, std::size_t &friend_count,
move_unit_spectator * spectator = nullptr);

/// Convenience wrapper for adding sighting data to the sightings_ vector.
inline void record_sighting(const unit & seen, const map_location & seen_loc,
size_t sighter_id, const map_location & sighter_loc);
std::size_t sighter_id, const map_location & sighter_loc);

private: // data
std::map<map_location, int> jamming_;
Expand Down

0 comments on commit fc2a58f

Please sign in to comment.