Skip to content

Commit

Permalink
Fix MSVC compiler warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
jyrkive committed Mar 17, 2017
1 parent b16728c commit 16fefa2
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions src/color_range.cpp
Expand Up @@ -91,8 +91,8 @@ std::vector<color_t> palette(const color_range& cr)
for(int i = 255; i != 0; i--) {
const int j = 255 - i;

temp.emplace_back(0,0,i);
temp.emplace_back(j,j,255);
temp.emplace_back(static_cast<uint8_t>(0), static_cast<uint8_t>(0), static_cast<uint8_t>(i));
temp.emplace_back(static_cast<uint8_t>(j), static_cast<uint8_t>(j), static_cast<uint8_t>(255));

This comment has been minimized.

Copy link
@CelticMinstrel

CelticMinstrel Mar 17, 2017

Member

I really don't like using so many static_casts... why not make the i and j be of type uint8_t?

Not sure if that'll work for the constants, though... 255u may or may not help...

}

// Use recolor function to generate list of possible colors.
Expand Down
2 changes: 1 addition & 1 deletion src/gui/dialogs/multiplayer/mp_create_game.cpp
Expand Up @@ -602,7 +602,7 @@ void mp_create_game::regenerate_random_map(window& window)
update_details(window);
}

int mp_create_game::convert_to_game_filtered_index(const int initial_index)
int mp_create_game::convert_to_game_filtered_index(const unsigned int initial_index)
{
const std::vector<size_t>& filtered_indices = create_engine_.get_filtered_level_indices(create_engine_.current_level_type());
return std::find(filtered_indices.begin(), filtered_indices.end(), initial_index) - filtered_indices.begin();
Expand Down
2 changes: 1 addition & 1 deletion src/gui/dialogs/multiplayer/mp_create_game.hpp
Expand Up @@ -131,7 +131,7 @@ class mp_create_game : public modal_dialog, private plugin_executor
*/
bool dialog_exit_hook(window&);

int convert_to_game_filtered_index(const int initial_index);
int convert_to_game_filtered_index(const unsigned int initial_index);

void load_game_callback(window& window);

Expand Down
4 changes: 2 additions & 2 deletions src/gui/widgets/window.cpp
Expand Up @@ -1172,7 +1172,7 @@ void window::layout_linked_widgets()
}
}

bool window::click_dismiss(const Uint8 mouse_button_mask)
bool window::click_dismiss(const int mouse_button_mask)
{
if(does_click_dismiss()) {
if((mouse_button_state_ & mouse_button_mask) == 0) {
Expand Down Expand Up @@ -1362,7 +1362,7 @@ void window::signal_handler_sdl_video_resize(const event::ui_event event,
void window::signal_handler_click_dismiss(const event::ui_event event,
bool& handled,
bool& halt,
const Uint8 mouse_button_mask)
const int mouse_button_mask)
{
DBG_GUI_E << LOG_HEADER << ' ' << event << " mouse_button_mask "
<< static_cast<unsigned>(mouse_button_mask) << ".\n";
Expand Down
6 changes: 3 additions & 3 deletions src/gui/widgets/window.hpp
Expand Up @@ -661,7 +661,7 @@ class window : public panel, public cursor::setter
* @return Whether the event should be considered as
* handled.
*/
bool click_dismiss(const Uint8 mouse_button_mask);
bool click_dismiss(const int mouse_button_mask);

/**
* The state of the mouse button.
Expand All @@ -679,7 +679,7 @@ class window : public panel, public cursor::setter
*
* [1] https://gna.org/bugs/index.php?18970
*/
Uint8 mouse_button_state_;
int mouse_button_state_;

/** See @ref styled_widget::get_control_type. */
virtual const std::string& get_control_type() const override;
Expand Down Expand Up @@ -758,7 +758,7 @@ class window : public panel, public cursor::setter
void signal_handler_click_dismiss(const event::ui_event event,
bool& handled,
bool& halt,
const Uint8 mouse_button_mask);
const int mouse_button_mask);

void signal_handler_sdl_key_down(const event::ui_event event,
bool& handled,
Expand Down
2 changes: 1 addition & 1 deletion src/xBRZ/xbrz.cpp
Expand Up @@ -799,7 +799,7 @@ void scaleImage(const uint32_t* src, uint32_t* trg, int srcWidth, int srcHeight,
//"sizeof(uint32_t) * srcWidth * (yLast - yFirst)" bytes without risk of accidental overwriting before accessing
const int bufferSize = srcWidth;
unsigned char* preProcBuffer = reinterpret_cast<unsigned char*>(trg + yLast * Scaler::scale * trgWidth) - bufferSize;
std::fill(preProcBuffer, preProcBuffer + bufferSize, 0);
std::fill(preProcBuffer, preProcBuffer + bufferSize, static_cast<unsigned char>(0));

This comment has been minimized.

Copy link
@CelticMinstrel

CelticMinstrel Mar 17, 2017

Member

Would 0u also prevent the warning here? I don't quite remember how typing works for integer constants.

//static_assert(BLEND_NONE == 0, "");

//initialize preprocessing buffer for first row: detect upper left and right corner blending
Expand Down

0 comments on commit 16fefa2

Please sign in to comment.