Convert a bunch more C-style casts I missed in 0dc5656
to static_cast
This commit is contained in:
parent
56e6e7366c
commit
cb43d8b35f
13 changed files with 23 additions and 23 deletions
|
@ -139,7 +139,7 @@ void move_unit_spectator::set_unit(const unit_map::const_iterator &u)
|
|||
game_events::pump_result_t get_village(const map_location& loc, int side, bool *action_timebonus, bool fire_event)
|
||||
{
|
||||
std::vector<team> &teams = resources::gameboard->teams();
|
||||
team *t = unsigned(side - 1) < teams.size() ? &teams[side - 1] : nullptr;
|
||||
team *t = static_cast<unsigned>(side - 1) < teams.size() ? &teams[side - 1] : nullptr;
|
||||
if (t && t->owns_village(loc)) {
|
||||
return game_events::pump_result_t();
|
||||
}
|
||||
|
|
|
@ -185,7 +185,7 @@ bool simulated_synced_command(){
|
|||
// Helper functions.
|
||||
void helper_check_village(const map_location& loc, int side){
|
||||
std::vector<team> &teams = resources::gameboard->teams();
|
||||
team *t = unsigned(side - 1) < teams.size() ? &teams[side - 1] : nullptr;
|
||||
team *t = static_cast<unsigned>(side - 1) < teams.size() ? &teams[side - 1] : nullptr;
|
||||
if(t && t->owns_village(loc)){
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -67,9 +67,9 @@ std::string format_version(unsigned a, unsigned b, unsigned c)
|
|||
|
||||
std::string format_version(const SDL_version& v)
|
||||
{
|
||||
return formatter() << unsigned(v.major) << '.'
|
||||
<< unsigned(v.minor) << '.'
|
||||
<< unsigned(v.patch);
|
||||
return formatter() << static_cast<unsigned>(v.major) << '.'
|
||||
<< static_cast<unsigned>(v.minor) << '.'
|
||||
<< static_cast<unsigned>(v.patch);
|
||||
}
|
||||
|
||||
std::string format_openssl_patch_level(uint8_t p)
|
||||
|
|
|
@ -671,7 +671,7 @@ static void flood_name(const map_location& start, const std::string& name, std::
|
|||
for(n = 0; n < 6; n++) {
|
||||
//we do not care for tiles outside the middle part
|
||||
//cast to unsigned to skip x < 0 || y < 0 as well.
|
||||
if(unsigned(adj[n].x) >= width / 3 || unsigned(adj[n].y) >= height / 3) {
|
||||
if(static_cast<unsigned>(adj[n].x) >= width / 3 || static_cast<unsigned>(adj[n].y) >= height / 3) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
|
@ -171,7 +171,7 @@ void drop_down_menu::pre_show(window& window)
|
|||
}
|
||||
}
|
||||
|
||||
if(selected_item_ >= 0 && unsigned(selected_item_) < list.get_item_count()) {
|
||||
if(selected_item_ >= 0 && static_cast<unsigned>(selected_item_) < list.get_item_count()) {
|
||||
list.select_row(selected_item_);
|
||||
}
|
||||
|
||||
|
|
|
@ -73,7 +73,7 @@ void editor_generate_map::do_generator_selected(window& window)
|
|||
listbox& list = find_widget<listbox>(&window, "generators_list", false);
|
||||
const int current = list.get_selected_row();
|
||||
|
||||
if(current == -1 || unsigned(current) > map_generators_.size()) {
|
||||
if(current == -1 || static_cast<unsigned>(current) > map_generators_.size()) {
|
||||
return; // shouldn't happen!
|
||||
}
|
||||
|
||||
|
|
|
@ -565,17 +565,17 @@ void file_dialog::sync_bookmarks_bar(window& window)
|
|||
|
||||
if(it == bookmark_paths_.rend()) {
|
||||
if(current_bookmark_ >= 0) {
|
||||
bookmarks_bar.select_row(unsigned(current_bookmark_), false);
|
||||
bookmarks_bar.select_row(static_cast<unsigned>(current_bookmark_), false);
|
||||
}
|
||||
current_bookmark_ = -1;
|
||||
} else {
|
||||
const int new_selection = int(std::distance(bookmark_paths_.begin(), it.base()) - 1);
|
||||
if(new_selection != current_bookmark_) {
|
||||
assert(unsigned(new_selection) < bookmarks_bar.get_item_count());
|
||||
assert(static_cast<unsigned>(new_selection) < bookmarks_bar.get_item_count());
|
||||
if(current_bookmark_ >= 0) {
|
||||
bookmarks_bar.select_row(unsigned(current_bookmark_), false);
|
||||
bookmarks_bar.select_row(static_cast<unsigned>(current_bookmark_), false);
|
||||
}
|
||||
bookmarks_bar.select_row(unsigned(new_selection), true);
|
||||
bookmarks_bar.select_row(static_cast<unsigned>(new_selection), true);
|
||||
current_bookmark_ = new_selection;
|
||||
}
|
||||
}
|
||||
|
@ -627,13 +627,13 @@ void file_dialog::on_bookmark_selected(window& window)
|
|||
if(current_bookmark_ >= 0) {
|
||||
// Don't allow the user to deselect the selected bookmark. That wouldn't
|
||||
// make any sense.
|
||||
bookmarks_bar.select_row(unsigned(current_bookmark_));
|
||||
bookmarks_bar.select_row(static_cast<unsigned>(current_bookmark_));
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
assert(unsigned(new_selection) < bookmark_paths_.size());
|
||||
assert(static_cast<unsigned>(new_selection) < bookmark_paths_.size());
|
||||
current_bookmark_ = new_selection;
|
||||
set_path(bookmark_paths_[new_selection]);
|
||||
refresh_fileview(window);
|
||||
|
|
|
@ -555,7 +555,7 @@ surface o_modification::operator()(const surface& src) const
|
|||
g = (*beg) >> 8;
|
||||
b = (*beg);
|
||||
|
||||
alpha = std::min<unsigned>(unsigned(fxpmult(alpha,amount)), 255);
|
||||
alpha = std::min<unsigned>(static_cast<unsigned>(fxpmult(alpha,amount)), 255);
|
||||
*beg = (alpha << 24) + (r << 16) + (g << 8) + b;
|
||||
}
|
||||
|
||||
|
|
|
@ -2180,7 +2180,7 @@ int game_lua_kernel::intf_put_recall_unit(lua_State *L)
|
|||
lua_unit *lu = nullptr;
|
||||
unit_ptr u = unit_ptr();
|
||||
int side = lua_tointeger(L, 2);
|
||||
if (unsigned(side) > teams().size()) side = 0;
|
||||
if (static_cast<unsigned>(side) > teams().size()) side = 0;
|
||||
|
||||
if(luaW_isunit(L, 1)) {
|
||||
lu = luaW_checkunit_ref(L, 1);
|
||||
|
|
|
@ -808,7 +808,7 @@ int intf_set_dialog_canvas(lua_State* L)
|
|||
}
|
||||
|
||||
std::vector<gui2::canvas> &cv = c->get_canvases();
|
||||
if(i < 1 || unsigned(i) > cv.size()) {
|
||||
if(i < 1 || static_cast<unsigned>(i) > cv.size()) {
|
||||
return luaL_argerror(L, 1, "out of bounds");
|
||||
}
|
||||
|
||||
|
|
|
@ -1157,9 +1157,9 @@ surface brighten_image(const surface &surf, fixed_t amount)
|
|||
g = (*beg) >> 8;
|
||||
b = (*beg);
|
||||
|
||||
r = std::min<unsigned>(unsigned(fxpmult(r, amount)),255);
|
||||
g = std::min<unsigned>(unsigned(fxpmult(g, amount)),255);
|
||||
b = std::min<unsigned>(unsigned(fxpmult(b, amount)),255);
|
||||
r = std::min<unsigned>(static_cast<unsigned>(fxpmult(r, amount)),255);
|
||||
g = std::min<unsigned>(static_cast<unsigned>(fxpmult(g, amount)),255);
|
||||
b = std::min<unsigned>(static_cast<unsigned>(fxpmult(b, amount)),255);
|
||||
|
||||
*beg = (alpha << 24) + (r << 16) + (g << 8) + b;
|
||||
}
|
||||
|
@ -1360,7 +1360,7 @@ surface submerge_alpha(const surface &surf, int depth, float alpha_base, float a
|
|||
int d = (beg-limit)/nsurf->w; // current depth in pixels
|
||||
float a = alpha_base - d * alpha_delta;
|
||||
fixed_t amount = ftofxp(a<0?0:a);
|
||||
alpha = std::min<unsigned>(unsigned(fxpmult(alpha,amount)),255);
|
||||
alpha = std::min<unsigned>(static_cast<unsigned>(fxpmult(alpha,amount)),255);
|
||||
*beg = (alpha << 24) + (r << 16) + (g << 8) + b;
|
||||
}
|
||||
|
||||
|
|
|
@ -131,7 +131,7 @@ bool positional_source::is_global() const
|
|||
|
||||
void positional_source::update(unsigned int time, const display &disp)
|
||||
{
|
||||
if (time - last_played_ < unsigned(min_delay_) || sound::is_sound_playing(id_))
|
||||
if (time - last_played_ < static_cast<unsigned>(min_delay_) || sound::is_sound_playing(id_))
|
||||
return;
|
||||
|
||||
int i = randomness::rng::default_instance().get_random_int(1, 100);
|
||||
|
|
|
@ -1669,7 +1669,7 @@ std::vector<config> unit::get_modification_advances() const
|
|||
continue;
|
||||
}
|
||||
|
||||
if(modification_count("advancement", adv["id"]) >= unsigned(adv["max_times"].to_int(1))) {
|
||||
if(modification_count("advancement", adv["id"]) >= static_cast<unsigned>(adv["max_times"].to_int(1))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue