Author: segfault
Date: Sun Jun 1 23:01:29 2008
New Revision: 26973
URL: http://svn.gna.org/viewcvs/wesnoth?rev=26973&view=rev
Log:
correct compiler warning (mainly bad unsigned and int comparaisons)
Modified:
trunk/src/clipboard.cpp
trunk/src/gui/widgets/canvas.cpp
trunk/src/gui/widgets/grid.cpp
trunk/src/gui/widgets/listbox.cpp
trunk/src/gui/widgets/listbox.hpp
trunk/src/gui/widgets/scrollbar.cpp
trunk/src/gui/widgets/text_box.cpp
trunk/src/gui/widgets/vertical_scrollbar.cpp
trunk/src/gui/widgets/widget.hpp
trunk/src/gui/widgets/window.cpp
trunk/src/sdl_utils.cpp
trunk/src/server/game.cpp
trunk/src/server/server.cpp
trunk/src/server/simple_wml.cpp
Modified: trunk/src/clipboard.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/clipboard.cpp?rev=26973&r1=26972&r2=26973&view=diff
==============================================================================
--- trunk/src/clipboard.cpp (original)
+++ trunk/src/clipboard.cpp Sun Jun 1 23:01:29 2008
@@ -535,7 +535,7 @@
#ifndef CLIPBOARD_FUNCS_DEFINED
-void copy_to_clipboard(const std::string& text, const bool)
+void copy_to_clipboard(const std::string& /*text*/, const bool)
{
}
@@ -544,7 +544,7 @@
return "";
}
-void handle_system_event(const SDL_Event& event)
+void handle_system_event(const SDL_Event& /*event*/)
{
}
Modified: trunk/src/gui/widgets/canvas.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/widgets/canvas.cpp?rev=26973&r1=26972&r2=26973&view=diff
==============================================================================
--- trunk/src/gui/widgets/canvas.cpp (original)
+++ trunk/src/gui/widgets/canvas.cpp Sun Jun 1 23:01:29 2008
@@ -248,8 +248,11 @@
<< x1 << ',' << y1 << " to " << x2 << ',' << y2
<< " canvas size " << canvas->w << ',' << canvas->h << ".\n";
- VALIDATE(x1 < canvas->w && x2 < canvas->w && y1 < canvas->h
- && y2 < canvas->h, _("Line doesn't fit on canvas."));
+ VALIDATE(static_cast<int>(x1) < canvas->w &&
+ static_cast<int>(x2) < canvas->w &&
+ static_cast<int>(y1) < canvas->h &&
+ static_cast<int>(y2) < canvas->h,
+ _("Line doesn't fit on canvas."));
// FIXME respect the thickness.
@@ -356,8 +359,11 @@
<< " width " << w << " height " << h
<< " canvas size " << canvas->w << ',' << canvas->h << ".\n";
- VALIDATE(x < canvas->w && x + w <= canvas->w && y < canvas->h
- && y + h <= canvas->h, _("Rectangle doesn't fit on canvas."));
+ VALIDATE(static_cast<int>(x) < canvas->w &&
+ static_cast<int>(x + w) <= canvas->w &&
+ static_cast<int>(y) < canvas->h &&
+ static_cast<int>(y + h) <= canvas->h,
+ _("Rectangle doesn't fit on canvas."));
surface_lock locker(canvas);
@@ -697,20 +703,22 @@
const unsigned y = y_(local_variables);
const unsigned w = w_(local_variables);
const unsigned h = h_(local_variables);
-
+
DBG_G_D << "Text: drawing text '" << text
<< "' drawn from " << x << ',' << y
<< " width " << w << " height " << h
<< " canvas size " << canvas->w << ',' << canvas->h << ".\n";
- VALIDATE(x < canvas->w && y < canvas->h, _("Text doesn't start on
canvas."));
+ VALIDATE(static_cast<int>(x) < canvas->w &&
+ static_cast<int>(y) < canvas->h,
+ _("Text doesn't start on canvas."));
// A text might be to long and will be clipped.
- if(surf->w > w) {
+ if(surf->w > static_cast<int>(w)) {
WRN_G_D << "Text: text is too wide for the canvas and will be
clipped.\n";
}
- if(surf->h > h) {
+ if(surf->h > static_cast<int>(h)) {
WRN_G_D << "Text: text is too high for the canvas and will be
clipped.\n";
}
@@ -826,10 +834,10 @@
<< " canvas width " << w << " canvas height "
<< canvas->h << ".\n";
- assert(x1 < canvas->w);
- assert(x2 < canvas->w);
- assert(y1 < canvas->h);
- assert(y2 < canvas->h);
+ assert(static_cast<int>(x1) < canvas->w);
+ assert(static_cast<int>(x2) < canvas->w);
+ assert(static_cast<int>(y1) < canvas->h);
+ assert(static_cast<int>(y2) < canvas->h);
// use a special case for vertical lines
if(x1 == x2) {
Modified: trunk/src/gui/widgets/grid.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/widgets/grid.cpp?rev=26973&r1=26972&r2=26973&view=diff
==============================================================================
--- trunk/src/gui/widgets/grid.cpp (original)
+++ trunk/src/gui/widgets/grid.cpp Sun Jun 1 23:01:29 2008
@@ -258,11 +258,11 @@
const tpoint size = (child(row,
col).*size_proc)();
- if(size.x > width[col]) {
+ if(size.x > static_cast<int>(width[col])) {
width[col] = size.x;
}
- if(size.y > height[row]) {
+ if(size.y > static_cast<int>(height[row])) {
height[row] = size.y;
}
Modified: trunk/src/gui/widgets/listbox.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/widgets/listbox.cpp?rev=26973&r1=26972&r2=26973&view=diff
==============================================================================
--- trunk/src/gui/widgets/listbox.cpp (original)
+++ trunk/src/gui/widgets/listbox.cpp Sun Jun 1 23:01:29 2008
@@ -216,9 +216,10 @@
foreach(const trow& row, rows_) {
assert(row.grid());
const tpoint best_size = row.grid()->get_best_size();
- width = width >= best_size.x ? width : best_size.x;
-
- height += best_size.y;
+ width = (static_cast<int>(width) >= best_size.x) ?
+ width : static_cast<int>(best_size.x);
+
+ height += static_cast<int>(best_size.y);
}
}
@@ -331,7 +332,7 @@
trow& row = rows_[i + scrollbar()->get_item_position()];
- if(offset < row.get_height()) {
+ if(offset < static_cast<int>(row.get_height())) {
assert(row.grid());
return row.grid()->find_widget(
tpoint(coordinate.x - list_rect_.x,
offset), must_be_active);
@@ -357,7 +358,7 @@
const trow& row = rows_[i +
scrollbar()->get_item_position()];
- if(offset < row.get_height()) {
+ if(offset < static_cast<int>(row.get_height())) {
assert(row.grid());
return row.grid()->find_widget(
tpoint(coordinate.x - list_rect_.x,
offset), must_be_active);
Modified: trunk/src/gui/widgets/listbox.hpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/widgets/listbox.hpp?rev=26973&r1=26972&r2=26973&view=diff
==============================================================================
--- trunk/src/gui/widgets/listbox.hpp (original)
+++ trunk/src/gui/widgets/listbox.hpp Sun Jun 1 23:01:29 2008
@@ -153,7 +153,7 @@
//! Note the order of the states must be the same as defined in
settings.hpp.
enum tstate { ENABLED, DISABLED, COUNT };
- void set_state(tstate state) {} // FIXME implement
+ void set_state(tstate /*state*/) {} // FIXME implement
tstate state_;
/** It's possible to let the engine build the contents, we need the
builder in that case */
Modified: trunk/src/gui/widgets/scrollbar.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/widgets/scrollbar.cpp?rev=26973&r1=26972&r2=26973&view=diff
==============================================================================
--- trunk/src/gui/widgets/scrollbar.cpp (original)
+++ trunk/src/gui/widgets/scrollbar.cpp Sun Jun 1 23:01:29 2008
@@ -237,7 +237,7 @@
const unsigned steps = (item_count_ + step_size_ - 1) / step_size_;
- if(steps < available_length) {
+ if(static_cast<int>(steps) < available_length) {
// We can show them all.
available_length += minimum_positioner_length();
@@ -270,7 +270,7 @@
void tscrollbar_::move_positioner(const int distance)
{
- if(distance < 0 && -distance > positioner_offset_) {
+ if(distance < 0 && -distance > static_cast<int>(positioner_offset_)) {
positioner_offset_ = 0;
} else {
positioner_offset_ += distance;
Modified: trunk/src/gui/widgets/text_box.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/widgets/text_box.cpp?rev=26973&r1=26972&r2=26973&view=diff
==============================================================================
--- trunk/src/gui/widgets/text_box.cpp (original)
+++ trunk/src/gui/widgets/text_box.cpp Sun Jun 1 23:01:29 2008
@@ -185,12 +185,13 @@
mouse.x -= get_x();
mouse.y -= get_y();
// FIXME we dont test for overflow in width
- if(mouse.x < text_x_offset_ || mouse.y < text_y_offset_
- || mouse.y >= text_y_offset_ + text_height_) {
+ if(mouse.x < static_cast<int>(text_x_offset_) ||
+ mouse.y < static_cast<int>(text_y_offset_) ||
+ mouse.y >= static_cast<int>(text_y_offset_ + text_height_)) {
return;
}
- int offset = get_character_offset_at(mouse.x - text_x_offset_);
+ int offset = get_character_offset_at(mouse.x -
static_cast<int>(text_x_offset_));
if(offset < 0) {
return;
}
Modified: trunk/src/gui/widgets/vertical_scrollbar.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/widgets/vertical_scrollbar.cpp?rev=26973&r1=26972&r2=26973&view=diff
==============================================================================
--- trunk/src/gui/widgets/vertical_scrollbar.cpp (original)
+++ trunk/src/gui/widgets/vertical_scrollbar.cpp Sun Jun 1 23:01:29 2008
@@ -73,10 +73,10 @@
bool tvertical_scrollbar::on_positioner(const tpoint& coordinate) const
{
// Note we assume the positioner is over the entire width of the widget.
- return coordinate.y >= get_positioner_offset()
- && coordinate.y < get_positioner_offset() +
get_positioner_length()
- && coordinate.x > 0
- && coordinate.x < get_width();
+ return coordinate.y >= static_cast<int>(get_positioner_offset())
+ && coordinate.y < static_cast<int>(get_positioner_offset() +
get_positioner_length())
+ && coordinate.x > 0
+ && coordinate.x < static_cast<int>(get_width());
}
} // namespace gui2
Modified: trunk/src/gui/widgets/widget.hpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/widgets/widget.hpp?rev=26973&r1=26972&r2=26973&view=diff
==============================================================================
--- trunk/src/gui/widgets/widget.hpp (original)
+++ trunk/src/gui/widgets/widget.hpp Sun Jun 1 23:01:29 2008
@@ -193,16 +193,16 @@
virtual twidget* find_widget(const tpoint& coordinate,
const bool /*must_be_active*/)
{
- return coordinate.x >= x_ && coordinate.x < (x_ + w_) &&
- coordinate.y >= y_ && coordinate.y < (y_ + h_) ? this :
0;
+ return coordinate.x >= x_ && coordinate.x < (x_ +
static_cast<int>(w_)) &&
+ coordinate.y >= y_ && coordinate.y < (y_ +
static_cast<int>(h_)) ? this : 0;
}
/** The const version of find_widget. */
virtual const twidget* find_widget(const tpoint& coordinate,
const bool /*must_be_active*/) const
{
- return coordinate.x >= x_ && coordinate.x < (x_ + w_) &&
- coordinate.y >= y_ && coordinate.y < (y_ + h_) ? this :
0;
+ return coordinate.x >= x_ && coordinate.x < (x_ +
static_cast<int>(w_)) &&
+ coordinate.y >= y_ && coordinate.y < (y_ +
static_cast<int>(h_)) ? this : 0;
}
/**
Modified: trunk/src/gui/widgets/window.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/widgets/window.cpp?rev=26973&r1=26972&r2=26973&view=diff
==============================================================================
--- trunk/src/gui/widgets/window.cpp (original)
+++ trunk/src/gui/widgets/window.cpp Sun Jun 1 23:01:29 2008
@@ -214,8 +214,8 @@
if(automatic_placement_) {
tpoint size = get_best_size();
- size.x = size.x < settings::screen_width ? size.x :
settings::screen_width;
- size.y = size.y < settings::screen_height ? size.y :
settings::screen_height;
+ size.x = size.x < static_cast<int>(settings::screen_width) ?
size.x : static_cast<int>(settings::screen_width);
+ size.y = size.y < static_cast<int>(settings::screen_height) ?
size.y : static_cast<int>(settings::screen_height);
tpoint position(0, 0);
switch(horizontal_placement_) {
Modified: trunk/src/sdl_utils.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/sdl_utils.cpp?rev=26973&r1=26972&r2=26973&view=diff
==============================================================================
--- trunk/src/sdl_utils.cpp (original)
+++ trunk/src/sdl_utils.cpp Sun Jun 1 23:01:29 2008
@@ -159,7 +159,7 @@
if(surf == NULL)
return NULL;
- if(w == surf->w) {
+ if(static_cast<int>(w) == surf->w) {
return surf;
}
assert(w > 0);
@@ -183,7 +183,7 @@
Uint32* const src_pixels =
reinterpret_cast<Uint32*>(src_lock.pixels());
Uint32* dst_pixels =
reinterpret_cast<Uint32*>(dst_lock.pixels());
- for(unsigned y = 0; y < src->h; ++y) {
+ for(unsigned y = 0; y < static_cast<unsigned>(src->h); ++y) {
const Uint32 pixel = src_pixels [y * src->w];
for(unsigned x = 0; x < w; ++x) {
@@ -205,7 +205,7 @@
if(surf == NULL)
return NULL;
- if(h == surf->h) {
+ if(static_cast<int>(h) == surf->h) {
return surf;
}
assert(h > 0);
@@ -229,8 +229,8 @@
Uint32* const src_pixels =
reinterpret_cast<Uint32*>(src_lock.pixels());
Uint32* dst_pixels =
reinterpret_cast<Uint32*>(dst_lock.pixels());
- for(unsigned y = 0; y < h; ++y) {
- for(unsigned x = 0; x < src->w; ++x) {
+ for(unsigned y = 0; y < static_cast<unsigned>(h); ++y) {
+ for(unsigned x = 0; x < static_cast<unsigned>(src->w); ++x) {
*dst_pixels++ = src_pixels[x];
}
Modified: trunk/src/server/game.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/server/game.cpp?rev=26973&r1=26972&r2=26973&view=diff
==============================================================================
--- trunk/src/server/game.cpp (original)
+++ trunk/src/server/game.cpp Sun Jun 1 23:01:29 2008
@@ -38,7 +38,7 @@
static void truncate_message(const simple_wml::string_span& str,
simple_wml::node& message) {
// testing for msg.size() is not sufficient but we're not getting false
negatives
// and it's cheaper than always converting to wstring.
- if(str.size() > chat_message::max_message_length) {
+ if(str.size() > static_cast<int>(chat_message::max_message_length)) {
std::string tmp(str.begin(), str.end());
// The string can contain utf-8 characters so truncate as
wide_string otherwise
// a corrupted utf-8 string can be returned.
Modified: trunk/src/server/server.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/server/server.cpp?rev=26973&r1=26972&r2=26973&view=diff
==============================================================================
--- trunk/src/server/server.cpp (original)
+++ trunk/src/server/server.cpp Sun Jun 1 23:01:29 2008
@@ -144,7 +144,7 @@
index = children.size() - 1;
}
- assert(index < children.size());
+ assert(index < static_cast<int>(children.size()));
insert.set_attr_int("index", index);
children[index]->copy_into(insert.add_child(type));
}
Modified: trunk/src/server/simple_wml.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/server/simple_wml.cpp?rev=26973&r1=26972&r2=26973&view=diff
==============================================================================
--- trunk/src/server/simple_wml.cpp (original)
+++ trunk/src/server/simple_wml.cpp Sun Jun 1 23:01:29 2008
@@ -62,7 +62,7 @@
std::vector<char> buf(in.size()*2 + 80);
const int len = filter.read(&buf[0], buf.size()).gcount();
- if((!filter.eof() && !filter.good()) || len == buf.size()) {
+ if((!filter.eof() && !filter.good()) || len ==
static_cast<int>(buf.size())) {
throw error("failed to compress");
}
_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits