(svn r27381) -Fix: Warnings due to C++11 requirements for explicit narrowing conversions in initializer lists.

replace/41b28d7194a279bdc17475d4fbe2ea6ec885a466
michi_cc 9 years ago
parent 35b77450f8
commit 2b8bb12d62

@ -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;

@ -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;
}

@ -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;
}

@ -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;
}

@ -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;

@ -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);
}

@ -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;

@ -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;
}

@ -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;

@ -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;
}

@ -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 {

@ -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 */

@ -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;
}

@ -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);

@ -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};

@ -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);
}

Loading…
Cancel
Save