summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormichi_cc <michi_cc@openttd.org>2015-08-10 20:24:13 +0000
committermichi_cc <michi_cc@openttd.org>2015-08-10 20:24:13 +0000
commit2b8bb12d623a64897636234ed3c508517a1a2ba6 (patch)
tree015abed42269cf73bb83b2f92b029084735d82cd
parent35b77450f80580da2aa7f087aa2a1631b92ebd62 (diff)
downloadopenttd-2b8bb12d623a64897636234ed3c508517a1a2ba6.tar.xz
(svn r27381) -Fix: Warnings due to C++11 requirements for explicit narrowing conversions in initializer lists.
-rw-r--r--src/company_base.h2
-rw-r--r--src/core/pool_func.hpp2
-rw-r--r--src/gfx.cpp6
-rw-r--r--src/misc_gui.cpp2
-rw-r--r--src/newgrf_gui.cpp2
-rw-r--r--src/road_gui.cpp2
-rw-r--r--src/script/api/script_road.cpp4
-rw-r--r--src/signs_gui.cpp2
-rw-r--r--src/smallmap_gui.cpp4
-rw-r--r--src/station_gui.cpp4
-rw-r--r--src/strings.cpp22
-rw-r--r--src/table/newgrf_debug_data.h2
-rw-r--r--src/terraform_cmd.cpp2
-rw-r--r--src/textfile_gui.cpp2
-rw-r--r--src/widget.cpp2
-rw-r--r--src/widgets/dropdown.cpp4
16 files changed, 32 insertions, 32 deletions
diff --git a/src/company_base.h b/src/company_base.h
index 6385d6049..001776121 100644
--- a/src/company_base.h
+++ b/src/company_base.h
@@ -45,7 +45,7 @@ struct CompanyInfrastructure {
}
};
-typedef Pool<Company, CompanyByte, 1, MAX_COMPANIES> CompanyPool;
+typedef Pool<Company, CompanyID, 1, MAX_COMPANIES> CompanyPool;
extern CompanyPool _company_pool;
diff --git a/src/core/pool_func.hpp b/src/core/pool_func.hpp
index 4648f50d1..5569addbd 100644
--- a/src/core/pool_func.hpp
+++ b/src/core/pool_func.hpp
@@ -121,7 +121,7 @@ DEFINE_POOL_METHOD(inline void *)::AllocateItem(size_t size, size_t index)
item = (Titem *)MallocT<byte>(size);
}
this->data[index] = item;
- item->index = (uint)index;
+ item->index = (Tindex)(uint)index;
return item;
}
diff --git a/src/gfx.cpp b/src/gfx.cpp
index bc7f93244..f3a98461d 100644
--- a/src/gfx.cpp
+++ b/src/gfx.cpp
@@ -186,7 +186,7 @@ static inline void GfxDoDrawLine(void *video, int x, int y, int x2, int y2, int
int grade_x = x2 - x;
/* Clipping rectangle. Slightly extended so we can ignore the width of the line. */
- uint extra = CeilDiv(3 * width, 4); // not less then "width * sqrt(2) / 2"
+ int extra = (int)CeilDiv(3 * width, 4); // not less then "width * sqrt(2) / 2"
Rect clip = { -extra, -extra, screen_width - 1 + extra, screen_height - 1 + extra };
/* prevent integer overflows. */
@@ -586,7 +586,7 @@ int GetStringLineCount(StringID str, int maxw)
*/
Dimension GetStringMultiLineBoundingBox(StringID str, const Dimension &suggestion)
{
- Dimension box = {suggestion.width, GetStringHeight(str, suggestion.width)};
+ Dimension box = {suggestion.width, (uint)GetStringHeight(str, suggestion.width)};
return box;
}
@@ -598,7 +598,7 @@ Dimension GetStringMultiLineBoundingBox(StringID str, const Dimension &suggestio
*/
Dimension GetStringMultiLineBoundingBox(const char *str, const Dimension &suggestion)
{
- Dimension box = {suggestion.width, GetStringHeight(str, suggestion.width)};
+ Dimension box = {suggestion.width, (uint)GetStringHeight(str, suggestion.width)};
return box;
}
diff --git a/src/misc_gui.cpp b/src/misc_gui.cpp
index 62da50b96..5bb8c7e31 100644
--- a/src/misc_gui.cpp
+++ b/src/misc_gui.cpp
@@ -825,7 +825,7 @@ Point QueryString::GetCaretPosition(const Window *w, int wid) const
int delta = min(0, (right - left) - tb->pixels - 10);
if (tb->caretxoffs + delta < 0) delta = -tb->caretxoffs;
- Point pt = {left + WD_FRAMERECT_LEFT + tb->caretxoffs + delta, wi->pos_y + WD_FRAMERECT_TOP};
+ Point pt = {left + WD_FRAMERECT_LEFT + tb->caretxoffs + delta, (int)wi->pos_y + WD_FRAMERECT_TOP};
return pt;
}
diff --git a/src/newgrf_gui.cpp b/src/newgrf_gui.cpp
index 2945f9945..cc63f7b57 100644
--- a/src/newgrf_gui.cpp
+++ b/src/newgrf_gui.cpp
@@ -223,7 +223,7 @@ struct NewGRFParametersWindow : public Window {
case WID_NP_DESCRIPTION:
/* Minimum size of 4 lines. The 500 is the default size of the window. */
- Dimension suggestion = {500 - WD_FRAMERECT_LEFT - WD_FRAMERECT_RIGHT, FONT_HEIGHT_NORMAL * 4 + WD_TEXTPANEL_TOP + WD_TEXTPANEL_BOTTOM};
+ Dimension suggestion = {500 - WD_FRAMERECT_LEFT - WD_FRAMERECT_RIGHT, (uint)FONT_HEIGHT_NORMAL * 4 + WD_TEXTPANEL_TOP + WD_TEXTPANEL_BOTTOM};
for (uint i = 0; i < this->grf_config->param_info.Length(); i++) {
const GRFParameterInfo *par_info = this->grf_config->param_info[i];
if (par_info == NULL) continue;
diff --git a/src/road_gui.cpp b/src/road_gui.cpp
index b158482ef..92c660e8a 100644
--- a/src/road_gui.cpp
+++ b/src/road_gui.cpp
@@ -233,7 +233,7 @@ static void PlaceRoadStop(TileIndex start_tile, TileIndex end_tile, uint32 p2, u
p2 |= ddir << 6; // Set the DiagDirecion into p2 bits 6 and 7.
TileArea ta(start_tile, end_tile);
- CommandContainer cmdcont = { ta.tile, ta.w | ta.h << 8, p2, cmd, CcRoadStop, "" };
+ CommandContainer cmdcont = { ta.tile, (uint32)(ta.w | ta.h << 8), p2, cmd, CcRoadStop, "" };
ShowSelectStationIfNeeded(cmdcont, ta);
}
diff --git a/src/script/api/script_road.cpp b/src/script/api/script_road.cpp
index 3a9a8ca3f..3dd1453b6 100644
--- a/src/script/api/script_road.cpp
+++ b/src/script/api/script_road.cpp
@@ -371,8 +371,8 @@ static bool NormaliseTileOffset(int32 *tile)
if (!::IsValidTile(tile) || !::IsValidTile(start) || !::IsValidTile(end)) return -1;
if (::DistanceManhattan(tile, start) != 1 || ::DistanceManhattan(tile, end) != 1) return -1;
- /* ROAD_NW ROAD_SW ROAD_SE ROAD_NE */
- static const TileIndex neighbours[] = {::TileDiffXY(0, -1), ::TileDiffXY(1, 0), ::TileDiffXY(0, 1), ::TileDiffXY(-1, 0)};
+ /* ROAD_NW ROAD_SW ROAD_SE ROAD_NE */
+ static const TileIndexDiff neighbours[] = {::TileDiffXY(0, -1), ::TileDiffXY(1, 0), ::TileDiffXY(0, 1), ::TileDiffXY(-1, 0)};
Array *existing = (Array*)alloca(sizeof(Array) + lengthof(neighbours) * sizeof(int32));
existing->size = 0;
diff --git a/src/signs_gui.cpp b/src/signs_gui.cpp
index a34f1db07..020ee1b6e 100644
--- a/src/signs_gui.cpp
+++ b/src/signs_gui.cpp
@@ -268,7 +268,7 @@ struct SignListWindow : Window, SignList {
Dimension spr_dim = GetSpriteSize(SPR_COMPANY_ICON);
this->text_offset = WD_FRAMETEXT_LEFT + spr_dim.width + 2; // 2 pixels space between icon and the sign text.
resize->height = max<uint>(FONT_HEIGHT_NORMAL, spr_dim.height);
- Dimension d = {this->text_offset + WD_FRAMETEXT_RIGHT, WD_FRAMERECT_TOP + 5 * resize->height + WD_FRAMERECT_BOTTOM};
+ Dimension d = {(uint)(this->text_offset + WD_FRAMETEXT_RIGHT), WD_FRAMERECT_TOP + 5 * resize->height + WD_FRAMERECT_BOTTOM};
*size = maxdim(*size, d);
break;
}
diff --git a/src/smallmap_gui.cpp b/src/smallmap_gui.cpp
index 80d4ae2a8..571d8d765 100644
--- a/src/smallmap_gui.cpp
+++ b/src/smallmap_gui.cpp
@@ -1076,7 +1076,7 @@ void SmallMapWindow::RebuildColourIndexIfNecessary()
_heightmap_schemes[n].height_colours = ReallocT<uint32>(_heightmap_schemes[n].height_colours, heights);
for (int z = 0; z < heights; z++) {
- uint access_index = (_heightmap_schemes[n].colour_count * z) / heights;
+ size_t access_index = (_heightmap_schemes[n].colour_count * z) / heights;
/* Choose colour by mapping the range (0..max heightlevel) on the complete colour table. */
_heightmap_schemes[n].height_colours[z] = _heightmap_schemes[n].height_colours_base[access_index];
@@ -1401,7 +1401,7 @@ int SmallMapWindow::GetPositionOnLegend(Point pt)
case WID_SM_ZOOM_IN:
case WID_SM_ZOOM_OUT: {
const NWidgetBase *wid = this->GetWidget<NWidgetBase>(WID_SM_MAP);
- Point pt = {wid->current_x / 2, wid->current_y / 2};
+ Point pt = { (int)wid->current_x / 2, (int)wid->current_y / 2};
this->SetZoomLevel((widget == WID_SM_ZOOM_IN) ? ZLC_ZOOM_IN : ZLC_ZOOM_OUT, &pt);
if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP);
break;
diff --git a/src/station_gui.cpp b/src/station_gui.cpp
index 666e66d8b..7399fe006 100644
--- a/src/station_gui.cpp
+++ b/src/station_gui.cpp
@@ -1409,7 +1409,7 @@ struct StationViewWindow : public Window {
if (!this->IsShaded()) {
/* Draw 'accepted cargo' or 'cargo ratings'. */
const NWidgetBase *wid = this->GetWidget<NWidgetBase>(WID_SV_ACCEPT_RATING_LIST);
- const Rect r = {wid->pos_x, wid->pos_y, wid->pos_x + wid->current_x - 1, wid->pos_y + wid->current_y - 1};
+ const Rect r = {(int)wid->pos_x, (int)wid->pos_y, (int)(wid->pos_x + wid->current_x - 1), (int)(wid->pos_y + wid->current_y - 1)};
if (this->GetWidget<NWidgetCore>(WID_SV_ACCEPTS_RATINGS)->widget_data == STR_STATION_VIEW_RATINGS_BUTTON) {
int lines = this->DrawAcceptedCargo(r);
if (lines > this->accepts_lines) { // Resize the widget, and perform re-initialization of the window.
@@ -1437,7 +1437,7 @@ struct StationViewWindow : public Window {
/* Draw waiting cargo. */
NWidgetBase *nwi = this->GetWidget<NWidgetBase>(WID_SV_WAITING);
- Rect waiting_rect = {nwi->pos_x, nwi->pos_y, nwi->pos_x + nwi->current_x - 1, nwi->pos_y + nwi->current_y - 1};
+ Rect waiting_rect = { (int)nwi->pos_x, (int)nwi->pos_y, (int)(nwi->pos_x + nwi->current_x - 1), (int)(nwi->pos_y + nwi->current_y - 1)};
this->DrawEntries(&cargo, waiting_rect, pos, maxrows, 0);
scroll_to_row = INT_MAX;
}
diff --git a/src/strings.cpp b/src/strings.cpp
index 5d1059243..d2ce762b7 100644
--- a/src/strings.cpp
+++ b/src/strings.cpp
@@ -1275,7 +1275,7 @@ static char *FormatString(char *buff, const char *str_arg, StringParameters *arg
if (c == NULL) break;
if (c->name != NULL) {
- int64 args_array[] = {(uint64)(size_t)c->name};
+ int64 args_array[] = {(int64)(size_t)c->name};
StringParameters tmp_params(args_array);
buff = GetStringWithArgs(buff, STR_JUST_RAW_STRING, &tmp_params, last);
} else {
@@ -1301,7 +1301,7 @@ static char *FormatString(char *buff, const char *str_arg, StringParameters *arg
case SCC_DEPOT_NAME: { // {DEPOT}
VehicleType vt = (VehicleType)args->GetInt32(SCC_DEPOT_NAME);
if (vt == VEH_AIRCRAFT) {
- uint64 args_array[] = {args->GetInt32()};
+ uint64 args_array[] = {(uint64)args->GetInt32()};
WChar types_array[] = {SCC_STATION_NAME};
StringParameters tmp_params(args_array, 1, types_array);
buff = GetStringWithArgs(buff, STR_FORMAT_DEPOT_NAME_AIRCRAFT, &tmp_params, last);
@@ -1310,7 +1310,7 @@ static char *FormatString(char *buff, const char *str_arg, StringParameters *arg
const Depot *d = Depot::Get(args->GetInt32());
if (d->name != NULL) {
- int64 args_array[] = {(uint64)(size_t)d->name};
+ int64 args_array[] = {(int64)(size_t)d->name};
StringParameters tmp_params(args_array);
buff = GetStringWithArgs(buff, STR_JUST_RAW_STRING, &tmp_params, last);
} else {
@@ -1326,7 +1326,7 @@ static char *FormatString(char *buff, const char *str_arg, StringParameters *arg
if (e == NULL) break;
if (e->name != NULL && e->IsEnabled()) {
- int64 args_array[] = {(uint64)(size_t)e->name};
+ int64 args_array[] = {(int64)(size_t)e->name};
StringParameters tmp_params(args_array);
buff = GetStringWithArgs(buff, STR_JUST_RAW_STRING, &tmp_params, last);
} else {
@@ -1341,7 +1341,7 @@ static char *FormatString(char *buff, const char *str_arg, StringParameters *arg
if (g == NULL) break;
if (g->name != NULL) {
- int64 args_array[] = {(uint64)(size_t)g->name};
+ int64 args_array[] = {(int64)(size_t)g->name};
StringParameters tmp_params(args_array);
buff = GetStringWithArgs(buff, STR_JUST_RAW_STRING, &tmp_params, last);
} else {
@@ -1378,7 +1378,7 @@ static char *FormatString(char *buff, const char *str_arg, StringParameters *arg
if (c == NULL) break;
if (c->president_name != NULL) {
- int64 args_array[] = {(uint64)(size_t)c->president_name};
+ int64 args_array[] = {(int64)(size_t)c->president_name};
StringParameters tmp_params(args_array);
buff = GetStringWithArgs(buff, STR_JUST_RAW_STRING, &tmp_params, last);
} else {
@@ -1403,7 +1403,7 @@ static char *FormatString(char *buff, const char *str_arg, StringParameters *arg
}
if (st->name != NULL) {
- int64 args_array[] = {(uint64)(size_t)st->name};
+ int64 args_array[] = {(int64)(size_t)st->name};
StringParameters tmp_params(args_array);
buff = GetStringWithArgs(buff, STR_JUST_RAW_STRING, &tmp_params, last);
} else {
@@ -1432,7 +1432,7 @@ static char *FormatString(char *buff, const char *str_arg, StringParameters *arg
if (t == NULL) break;
if (t->name != NULL) {
- int64 args_array[] = {(uint64)(size_t)t->name};
+ int64 args_array[] = {(int64)(size_t)t->name};
StringParameters tmp_params(args_array);
buff = GetStringWithArgs(buff, STR_JUST_RAW_STRING, &tmp_params, last);
} else {
@@ -1446,7 +1446,7 @@ static char *FormatString(char *buff, const char *str_arg, StringParameters *arg
if (wp == NULL) break;
if (wp->name != NULL) {
- int64 args_array[] = {(uint64)(size_t)wp->name};
+ int64 args_array[] = {(int64)(size_t)wp->name};
StringParameters tmp_params(args_array);
buff = GetStringWithArgs(buff, STR_JUST_RAW_STRING, &tmp_params, last);
} else {
@@ -1464,7 +1464,7 @@ static char *FormatString(char *buff, const char *str_arg, StringParameters *arg
if (v == NULL) break;
if (v->name != NULL) {
- int64 args_array[] = {(uint64)(size_t)v->name};
+ int64 args_array[] = {(int64)(size_t)v->name};
StringParameters tmp_params(args_array);
buff = GetStringWithArgs(buff, STR_JUST_RAW_STRING, &tmp_params, last);
} else {
@@ -1490,7 +1490,7 @@ static char *FormatString(char *buff, const char *str_arg, StringParameters *arg
if (si == NULL) break;
if (si->name != NULL) {
- int64 args_array[] = {(uint64)(size_t)si->name};
+ int64 args_array[] = {(int64)(size_t)si->name};
StringParameters tmp_params(args_array);
buff = GetStringWithArgs(buff, STR_JUST_RAW_STRING, &tmp_params, last);
} else {
diff --git a/src/table/newgrf_debug_data.h b/src/table/newgrf_debug_data.h
index c73140934..b7d0c9202 100644
--- a/src/table/newgrf_debug_data.h
+++ b/src/table/newgrf_debug_data.h
@@ -13,7 +13,7 @@
#include "../newgrf_engine.h"
/* Helper for filling property tables */
-#define NIP(prop, base, variable, type, name) { name, cpp_offsetof(base, variable), cpp_sizeof(base, variable), prop, type }
+#define NIP(prop, base, variable, type, name) { name, (ptrdiff_t)cpp_offsetof(base, variable), cpp_sizeof(base, variable), prop, type }
#define NIP_END() { NULL, 0, 0, 0, 0 }
/* Helper for filling callback tables */
diff --git a/src/terraform_cmd.cpp b/src/terraform_cmd.cpp
index 68ebafab9..aad982282 100644
--- a/src/terraform_cmd.cpp
+++ b/src/terraform_cmd.cpp
@@ -403,7 +403,7 @@ CommandCost CmdTerraformLand(TileIndex tile, DoCommandFlag flags, uint32 p1, uin
}
}
- if (c != NULL) c->terraform_limit -= ts.tile_to_new_height.size() << 16;
+ if (c != NULL) c->terraform_limit -= (uint32)ts.tile_to_new_height.size() << 16;
}
return total_cost;
}
diff --git a/src/textfile_gui.cpp b/src/textfile_gui.cpp
index 3efd98497..b0f9b1125 100644
--- a/src/textfile_gui.cpp
+++ b/src/textfile_gui.cpp
@@ -227,7 +227,7 @@ static void Gunzip(byte **bufp, size_t *sizep)
memset(&z, 0, sizeof(z));
z.next_in = *bufp;
- z.avail_in = *sizep;
+ z.avail_in = (uInt)*sizep;
/* window size = 15, add 32 to enable gzip or zlib header processing */
res = inflateInit2(&z, 15 + 32);
diff --git a/src/widget.cpp b/src/widget.cpp
index 3b50f710d..d59ca020e 100644
--- a/src/widget.cpp
+++ b/src/widget.cpp
@@ -1545,7 +1545,7 @@ void NWidgetMatrix::SetupSmallestSize(Window *w, bool init_array)
SB(nw->index, 16, 16, 0);
this->head->SetupSmallestSize(w, init_array);
- Dimension padding = {this->pip_pre + this->pip_post, this->pip_pre + this->pip_post};
+ Dimension padding = { (uint)this->pip_pre + this->pip_post, (uint)this->pip_pre + this->pip_post};
Dimension size = {this->head->smallest_x + padding.width, this->head->smallest_y + padding.height};
Dimension fill = {0, 0};
Dimension resize = {this->pip_inter + this->head->smallest_x, this->pip_inter + this->head->smallest_y};
diff --git a/src/widgets/dropdown.cpp b/src/widgets/dropdown.cpp
index aecfc6b2f..e0ad96a87 100644
--- a/src/widgets/dropdown.cpp
+++ b/src/widgets/dropdown.cpp
@@ -380,8 +380,8 @@ void ShowDropDownListAt(Window *w, const DropDownList *list, int selected, int b
if (auto_width) width = max(width, max_item_width);
- Point dw_pos = { w->left + (_current_text_dir == TD_RTL ? wi_rect.right + 1 - width : wi_rect.left), top};
- Dimension dw_size = {width, height};
+ Point dw_pos = { w->left + (_current_text_dir == TD_RTL ? wi_rect.right + 1 - (int)width : wi_rect.left), top};
+ Dimension dw_size = {width, (uint)height};
new DropdownWindow(w, list, selected, button, instant_close, dw_pos, dw_size, wi_colour, scroll);
}