summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorglx22 <glx22@users.noreply.github.com>2019-03-28 00:09:33 +0100
committerGitHub <noreply@github.com>2019-03-28 00:09:33 +0100
commit66dd7c3879123bb99b712375b66b577f81d53a96 (patch)
tree6231635658dab5ba63b776e9350884c083617cb1
parente817951bfdc229b404d5fec188c67f5202a0e774 (diff)
downloadopenttd-66dd7c3879123bb99b712375b66b577f81d53a96.tar.xz
Fix: MSVC warnings (#7423)
-rw-r--r--src/autoreplace_gui.cpp6
-rw-r--r--src/bridge_gui.cpp2
-rw-r--r--src/build_vehicle_gui.cpp4
-rw-r--r--src/company_gui.cpp4
-rw-r--r--src/core/math_func.hpp8
-rw-r--r--src/core/sort_func.hpp4
-rw-r--r--src/depot_gui.cpp10
-rw-r--r--src/engine_gui.cpp2
-rw-r--r--src/fios.cpp2
-rw-r--r--src/fios.h10
-rw-r--r--src/fios_gui.cpp8
-rw-r--r--src/gfx.cpp2
-rw-r--r--src/gfx_layout.cpp2
-rw-r--r--src/group_gui.cpp10
-rw-r--r--src/industry_gui.cpp2
-rw-r--r--src/linkgraph/linkgraph.h2
-rw-r--r--src/music/win32_m.cpp6
-rw-r--r--src/network/network_content.cpp8
-rw-r--r--src/network/network_content.h2
-rw-r--r--src/network/network_content_gui.cpp6
-rw-r--r--src/network/network_gui.cpp8
-rw-r--r--src/newgrf.cpp4
-rw-r--r--src/newgrf_debug_gui.cpp4
-rw-r--r--src/newgrf_gui.cpp12
-rw-r--r--src/newgrf_sound.cpp2
-rw-r--r--src/os/windows/string_uniscribe.cpp2
-rw-r--r--src/saveload/game_sl.cpp2
-rw-r--r--src/script/api/script_road.cpp6
-rw-r--r--src/script/squirrel_helper_type.hpp2
-rw-r--r--src/settings_gui.cpp2
-rw-r--r--src/signs_gui.cpp4
-rw-r--r--src/station_gui.cpp6
-rw-r--r--src/strgen/strgen_base.cpp6
-rw-r--r--src/textfile_gui.cpp2
-rw-r--r--src/timetable_cmd.cpp2
-rw-r--r--src/town_gui.cpp2
-rw-r--r--src/vehicle_gui.cpp4
-rw-r--r--src/viewport.cpp4
-rw-r--r--src/widgets/dropdown.cpp2
39 files changed, 88 insertions, 88 deletions
diff --git a/src/autoreplace_gui.cpp b/src/autoreplace_gui.cpp
index 133e9fb38..78c2fdc31 100644
--- a/src/autoreplace_gui.cpp
+++ b/src/autoreplace_gui.cpp
@@ -160,7 +160,7 @@ class ReplaceVehicleWindow : public Window {
if (this->engines[0].NeedRebuild()) {
/* We need to rebuild the left engines list */
this->GenerateReplaceVehList(true);
- this->vscroll[0]->SetCount(this->engines[0].size());
+ this->vscroll[0]->SetCount((uint)this->engines[0].size());
if (this->reset_sel_engine && this->sel_engine[0] == INVALID_ENGINE && this->engines[0].size() != 0) {
this->sel_engine[0] = this->engines[0][0];
}
@@ -180,7 +180,7 @@ class ReplaceVehicleWindow : public Window {
}
/* Regenerate the list on the right. Note: This resets sel_engine[1] to INVALID_ENGINE, if it is no longer available. */
this->GenerateReplaceVehList(false);
- this->vscroll[1]->SetCount(this->engines[1].size());
+ this->vscroll[1]->SetCount((uint)this->engines[1].size());
if (this->reset_sel_engine && this->sel_engine[1] != INVALID_ENGINE) {
int position = 0;
for (EngineID &eid : this->engines[1]) {
@@ -384,7 +384,7 @@ public:
case WID_RV_RIGHT_MATRIX: {
int side = (widget == WID_RV_LEFT_MATRIX) ? 0 : 1;
EngineID start = this->vscroll[side]->GetPosition(); // what is the offset for the start (scrolling)
- EngineID end = min(this->vscroll[side]->GetCapacity() + start, this->engines[side].size());
+ EngineID end = min(this->vscroll[side]->GetCapacity() + start, (uint)this->engines[side].size());
/* Do the actual drawing */
DrawEngineList((VehicleType)this->window_number, r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, r.top + WD_FRAMERECT_TOP,
diff --git a/src/bridge_gui.cpp b/src/bridge_gui.cpp
index 94b709c63..f6f47276c 100644
--- a/src/bridge_gui.cpp
+++ b/src/bridge_gui.cpp
@@ -153,7 +153,7 @@ public:
this->bridges->NeedResort();
this->SortBridgeList();
- this->vscroll->SetCount(bl->size());
+ this->vscroll->SetCount((uint)bl->size());
}
~BuildBridgeWindow()
diff --git a/src/build_vehicle_gui.cpp b/src/build_vehicle_gui.cpp
index 33cabe98a..b671efde7 100644
--- a/src/build_vehicle_gui.cpp
+++ b/src/build_vehicle_gui.cpp
@@ -1529,7 +1529,7 @@ struct BuildVehicleWindow : Window {
{
switch (widget) {
case WID_BV_LIST:
- DrawEngineList(this->vehicle_type, r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, r.top + WD_FRAMERECT_TOP, &this->eng_list, this->vscroll->GetPosition(), min(this->vscroll->GetPosition() + this->vscroll->GetCapacity(), this->eng_list.size()), this->sel_engine, false, DEFAULT_GROUP);
+ DrawEngineList(this->vehicle_type, r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, r.top + WD_FRAMERECT_TOP, &this->eng_list, this->vscroll->GetPosition(), min(this->vscroll->GetPosition() + this->vscroll->GetCapacity(), (uint)this->eng_list.size()), this->sel_engine, false, DEFAULT_GROUP);
break;
case WID_BV_SORT_ASCENDING_DESCENDING:
@@ -1541,7 +1541,7 @@ struct BuildVehicleWindow : Window {
void OnPaint() override
{
this->GenerateBuildList();
- this->vscroll->SetCount(this->eng_list.size());
+ this->vscroll->SetCount((uint)this->eng_list.size());
this->SetWidgetsDisabledState(this->sel_engine == INVALID_ENGINE, WID_BV_SHOW_HIDE, WID_BV_BUILD, WID_BV_RENAME, WIDGET_LIST_END);
diff --git a/src/company_gui.cpp b/src/company_gui.cpp
index e5dbc86a4..a3f8a24b6 100644
--- a/src/company_gui.cpp
+++ b/src/company_gui.cpp
@@ -686,7 +686,7 @@ private:
}
}
} else {
- this->rows = this->groups.size();
+ this->rows = (uint)this->groups.size();
}
this->vscroll->SetCount(this->rows);
@@ -902,7 +902,7 @@ public:
}
}
} else {
- uint max = min(this->vscroll->GetPosition() + this->vscroll->GetCapacity(), this->groups.size());
+ uint max = min(this->vscroll->GetPosition() + this->vscroll->GetCapacity(), (uint)this->groups.size());
for (uint i = this->vscroll->GetPosition(); i < max; ++i) {
const Group *g = this->groups[i];
SetDParam(0, g->index);
diff --git a/src/core/math_func.hpp b/src/core/math_func.hpp
index 4a19033f4..0b51d6bbf 100644
--- a/src/core/math_func.hpp
+++ b/src/core/math_func.hpp
@@ -247,9 +247,9 @@ static inline T Delta(const T a, const T b)
* @return True if the value is in the interval, false else.
*/
template <typename T>
-static inline bool IsInsideBS(const T x, const uint base, const uint size)
+static inline bool IsInsideBS(const T x, const size_t base, const size_t size)
{
- return (uint)(x - base) < size;
+ return (size_t)(x - base) < size;
}
/**
@@ -263,9 +263,9 @@ static inline bool IsInsideBS(const T x, const uint base, const uint size)
* @see IsInsideBS()
*/
template <typename T>
-static inline bool IsInsideMM(const T x, const uint min, const uint max)
+static inline bool IsInsideMM(const T x, const size_t min, const size_t max)
{
- return (uint)(x - min) < (max - min);
+ return (size_t)(x - min) < (max - min);
}
/**
diff --git a/src/core/sort_func.hpp b/src/core/sort_func.hpp
index 470a0ccf4..f3ac73a66 100644
--- a/src/core/sort_func.hpp
+++ b/src/core/sort_func.hpp
@@ -25,7 +25,7 @@
* @param desc Sort descending.
*/
template <typename T>
-static inline void QSortT(T *base, uint num, int (CDECL *comparator)(const T*, const T*), bool desc = false)
+static inline void QSortT(T *base, size_t num, int (CDECL *comparator)(const T*, const T*), bool desc = false)
{
if (num < 2) return;
@@ -49,7 +49,7 @@ static inline void QSortT(T *base, uint num, int (CDECL *comparator)(const T*, c
* @param desc Sort descending.
*/
template <typename T>
-static inline void GSortT(T *base, uint num, int (CDECL *comparator)(const T*, const T*), bool desc = false)
+static inline void GSortT(T *base, size_t num, int (CDECL *comparator)(const T*, const T*), bool desc = false)
{
if (num < 2) return;
diff --git a/src/depot_gui.cpp b/src/depot_gui.cpp
index 2b5879116..ffab68536 100644
--- a/src/depot_gui.cpp
+++ b/src/depot_gui.cpp
@@ -398,7 +398,7 @@ struct DepotWindow : Window {
uint16 rows_in_display = wid->current_y / wid->resize_y;
uint16 num = this->vscroll->GetPosition() * this->num_columns;
- int maxval = min(this->vehicle_list.size(), num + (rows_in_display * this->num_columns));
+ int maxval = min((uint)this->vehicle_list.size(), num + (rows_in_display * this->num_columns));
int y;
for (y = r.top + 1; num < maxval; y += this->resize.step_height) { // Draw the rows
for (byte i = 0; i < this->num_columns && num < maxval; i++, num++) {
@@ -413,7 +413,7 @@ struct DepotWindow : Window {
}
}
- maxval = min(this->vehicle_list.size() + this->wagon_list.size(), (this->vscroll->GetPosition() * this->num_columns) + (rows_in_display * this->num_columns));
+ maxval = min((uint)this->vehicle_list.size() + (uint)this->wagon_list.size(), (this->vscroll->GetPosition() * this->num_columns) + (rows_in_display * this->num_columns));
/* Draw the train wagons without an engine in front. */
for (; num < maxval; num++, y += this->resize.step_height) {
@@ -483,7 +483,7 @@ struct DepotWindow : Window {
/* Skip vehicles that are scrolled off the list */
if (this->type == VEH_TRAIN) x += this->hscroll->GetPosition();
} else {
- pos -= this->vehicle_list.size();
+ pos -= (uint)this->vehicle_list.size();
*veh = this->wagon_list[pos];
/* free wagons don't have an initial loco. */
x -= ScaleGUITrad(VEHICLEINFO_FULL_VEHICLE_WIDTH);
@@ -734,11 +734,11 @@ struct DepotWindow : Window {
max_width = max(max_width, width);
}
/* Always have 1 empty row, so people can change the setting of the train */
- this->vscroll->SetCount(this->vehicle_list.size() + this->wagon_list.size() + 1);
+ this->vscroll->SetCount((uint)this->vehicle_list.size() + (uint)this->wagon_list.size() + 1);
/* Always make it longer than the longest train, so you can attach vehicles at the end, and also see the next vertical tile separator line */
this->hscroll->SetCount(max_width + ScaleGUITrad(2 * VEHICLEINFO_FULL_VEHICLE_WIDTH + 1));
} else {
- this->vscroll->SetCount(CeilDiv(this->vehicle_list.size(), this->num_columns));
+ this->vscroll->SetCount(CeilDiv((uint)this->vehicle_list.size(), this->num_columns));
}
/* Setup disabled buttons. */
diff --git a/src/engine_gui.cpp b/src/engine_gui.cpp
index 2c2440baf..4e9dc30d9 100644
--- a/src/engine_gui.cpp
+++ b/src/engine_gui.cpp
@@ -325,7 +325,7 @@ void DrawVehicleEngine(int left, int right, int preferred_x, int y, EngineID eng
*/
void EngList_Sort(GUIEngineList *el, EngList_SortTypeFunction compare)
{
- uint size = el->size();
+ size_t size = el->size();
/* out-of-bounds access at the next line for size == 0 (even with operator[] at some systems)
* generally, do not sort if there are less than 2 items */
if (size < 2) return;
diff --git a/src/fios.cpp b/src/fios.cpp
index cb157492e..54ad54b11 100644
--- a/src/fios.cpp
+++ b/src/fios.cpp
@@ -342,7 +342,7 @@ static void FiosGetFileList(SaveLoadOperation fop, fios_getlist_callback_proc *c
struct dirent *dirent;
DIR *dir;
FiosItem *fios;
- int sort_start;
+ size_t sort_start;
char d_name[sizeof(fios->name)];
file_list.Clear();
diff --git a/src/fios.h b/src/fios.h
index 52d85ad9b..6ae0550d1 100644
--- a/src/fios.h
+++ b/src/fios.h
@@ -128,7 +128,7 @@ public:
* Get the number of files in the list.
* @return The number of files stored in the list.
*/
- inline uint Length() const
+ inline size_t Length() const
{
return this->files.size();
}
@@ -155,7 +155,7 @@ public:
* Get a pointer to the indicated file information. File information must exist.
* @return Address of the indicated existing file information.
*/
- inline const FiosItem *Get(uint index) const
+ inline const FiosItem *Get(size_t index) const
{
return this->files.data() + index;
}
@@ -164,12 +164,12 @@ public:
* Get a pointer to the indicated file information. File information must exist.
* @return Address of the indicated existing file information.
*/
- inline FiosItem *Get(uint index)
+ inline FiosItem *Get(size_t index)
{
return this->files.data() + index;
}
- inline const FiosItem &operator[](uint index) const
+ inline const FiosItem &operator[](size_t index) const
{
return this->files[index];
}
@@ -178,7 +178,7 @@ public:
* Get a reference to the indicated file information. File information must exist.
* @return The requested file information.
*/
- inline FiosItem &operator[](uint index)
+ inline FiosItem &operator[](size_t index)
{
return this->files[index];
}
diff --git a/src/fios_gui.cpp b/src/fios_gui.cpp
index b5bcee5e8..7a194054f 100644
--- a/src/fios_gui.cpp
+++ b/src/fios_gui.cpp
@@ -244,8 +244,8 @@ static const TextColour _fios_colours[] = {
*/
static void SortSaveGameList(FileList &file_list)
{
- uint sort_start = 0;
- uint sort_end = 0;
+ size_t sort_start = 0;
+ size_t sort_end = 0;
/* Directories are always above the files (FIOS_TYPE_DIR)
* Drives (A:\ (windows only) are always under the files (FIOS_TYPE_DRIVE)
@@ -260,7 +260,7 @@ static void SortSaveGameList(FileList &file_list)
}
}
- uint s_amount = file_list.Length() - sort_start - sort_end;
+ size_t s_amount = file_list.Length() - sort_start - sort_end;
QSortT(file_list.Get(sort_start), s_amount, CompareFiosItems);
}
@@ -782,7 +782,7 @@ public:
_fios_path_changed = true;
this->fios_items.BuildFileList(this->abstract_filetype, this->fop);
- this->vscroll->SetCount(this->fios_items.Length());
+ this->vscroll->SetCount((uint)this->fios_items.Length());
this->selected = NULL;
_load_check_data.Clear();
diff --git a/src/gfx.cpp b/src/gfx.cpp
index df3e5ccb6..72d3fcd67 100644
--- a/src/gfx.cpp
+++ b/src/gfx.cpp
@@ -574,7 +574,7 @@ int GetStringLineCount(StringID str, int maxw)
GetString(buffer, str, lastof(buffer));
Layouter layout(buffer, maxw);
- return layout.size();
+ return (uint)layout.size();
}
/**
diff --git a/src/gfx_layout.cpp b/src/gfx_layout.cpp
index f09b87efa..124f1218a 100644
--- a/src/gfx_layout.cpp
+++ b/src/gfx_layout.cpp
@@ -449,7 +449,7 @@ int FallbackParagraphLayout::FallbackLine::GetWidth() const
*/
int FallbackParagraphLayout::FallbackLine::CountRuns() const
{
- return this->size();
+ return (uint)this->size();
}
/**
diff --git a/src/group_gui.cpp b/src/group_gui.cpp
index cc545ad8f..ecc95064f 100644
--- a/src/group_gui.cpp
+++ b/src/group_gui.cpp
@@ -514,8 +514,8 @@ public:
this->BuildGroupList(this->owner);
- this->group_sb->SetCount(this->groups.size());
- this->vscroll->SetCount(this->vehicles.size());
+ this->group_sb->SetCount((uint)this->groups.size());
+ this->vscroll->SetCount((uint)this->vehicles.size());
/* The drop down menu is out, *but* it may not be used, retract it. */
if (this->vehicles.size() == 0 && this->IsWidgetLowered(WID_GL_MANAGE_VEHICLES_DROPDOWN)) {
@@ -575,7 +575,7 @@ public:
Money this_year = 0;
Money last_year = 0;
uint32 occupancy = 0;
- uint32 vehicle_count = this->vehicles.size();
+ size_t vehicle_count = this->vehicles.size();
for (uint i = 0; i < vehicle_count; i++) {
const Vehicle *v = this->vehicles[i];
@@ -611,7 +611,7 @@ public:
case WID_GL_LIST_GROUP: {
int y1 = r.top + WD_FRAMERECT_TOP;
- int max = min(this->group_sb->GetPosition() + this->group_sb->GetCapacity(), this->groups.size());
+ int max = min(this->group_sb->GetPosition() + this->group_sb->GetCapacity(), (uint)this->groups.size());
for (int i = this->group_sb->GetPosition(); i < max; ++i) {
const Group *g = this->groups[i];
@@ -635,7 +635,7 @@ public:
if (this->vli.index != ALL_GROUP) {
/* Mark vehicles which are in sub-groups */
int y = r.top;
- uint max = min(this->vscroll->GetPosition() + this->vscroll->GetCapacity(), this->vehicles.size());
+ uint max = min(this->vscroll->GetPosition() + this->vscroll->GetCapacity(), (uint)this->vehicles.size());
for (uint i = this->vscroll->GetPosition(); i < max; ++i) {
const Vehicle *v = this->vehicles[i];
if (v->group_id != this->vli.index) {
diff --git a/src/industry_gui.cpp b/src/industry_gui.cpp
index ce8ac7fa3..eff0a5f73 100644
--- a/src/industry_gui.cpp
+++ b/src/industry_gui.cpp
@@ -1211,7 +1211,7 @@ protected:
this->industries.shrink_to_fit();
this->industries.RebuildDone();
- this->vscroll->SetCount(this->industries.size()); // Update scrollbar as well.
+ this->vscroll->SetCount((uint)this->industries.size()); // Update scrollbar as well.
}
if (!this->industries.Sort()) return;
diff --git a/src/linkgraph/linkgraph.h b/src/linkgraph/linkgraph.h
index 3283eb9bf..7f2561e75 100644
--- a/src/linkgraph/linkgraph.h
+++ b/src/linkgraph/linkgraph.h
@@ -496,7 +496,7 @@ public:
* Get the current size of the component.
* @return Size.
*/
- inline uint Size() const { return this->nodes.size(); }
+ inline uint Size() const { return (uint)this->nodes.size(); }
/**
* Get date of last compression.
diff --git a/src/music/win32_m.cpp b/src/music/win32_m.cpp
index 18a3bce3e..bdba202f2 100644
--- a/src/music/win32_m.cpp
+++ b/src/music/win32_m.cpp
@@ -42,7 +42,7 @@ static struct {
MidiFile current_file; ///< file currently being played from
PlaybackSegment current_segment; ///< segment info for current playback
- DWORD playback_start_time; ///< timestamp current file began playback
+ size_t playback_start_time; ///< timestamp current file began playback
size_t current_block; ///< next block index to send
MidiFile next_file; ///< upcoming file to play
PlaybackSegment next_segment; ///< segment info for upcoming file
@@ -184,7 +184,7 @@ void CALLBACK TimerCallback(UINT uTimerID, UINT, DWORD_PTR dwUser, DWORD_PTR, DW
/* find first block after start time and pretend playback started earlier
* this is to allow all blocks prior to the actual start to still affect playback,
* as they may contain important controller and program changes */
- uint preload_bytes = 0;
+ size_t preload_bytes = 0;
for (size_t bl = 0; bl < _midi.current_file.blocks.size(); bl++) {
MidiFile::DataBlock &block = _midi.current_file.blocks[bl];
preload_bytes += block.data.size();
@@ -210,7 +210,7 @@ void CALLBACK TimerCallback(UINT uTimerID, UINT, DWORD_PTR dwUser, DWORD_PTR, DW
/* play pending blocks */
DWORD current_time = timeGetTime();
- DWORD playback_time = current_time - _midi.playback_start_time;
+ size_t playback_time = current_time - _midi.playback_start_time;
while (_midi.current_block < _midi.current_file.blocks.size()) {
MidiFile::DataBlock &block = _midi.current_file.blocks[_midi.current_block];
diff --git a/src/network/network_content.cpp b/src/network/network_content.cpp
index 003ffdb8b..19235c8c7 100644
--- a/src/network/network_content.cpp
+++ b/src/network/network_content.cpp
@@ -250,7 +250,7 @@ void ClientNetworkContentSocketHandler::RequestContentList(ContentVector *cv, bo
(sizeof(uint8) + sizeof(uint32) + (send_md5sum ? /*sizeof(ContentInfo::md5sum)*/16 : 0)));
Packet *p = new Packet(send_md5sum ? PACKET_CONTENT_CLIENT_INFO_EXTID_MD5 : PACKET_CONTENT_CLIENT_INFO_EXTID);
- p->Send_uint8(cv->size());
+ p->Send_uint8((uint8)cv->size());
for (const ContentInfo *ci : *cv) {
p->Send_uint8((byte)ci->type);
@@ -299,7 +299,7 @@ void ClientNetworkContentSocketHandler::DownloadSelectedContent(uint &files, uin
bytes += ci->filesize;
}
- files = content.size();
+ files = (uint)content.size();
/* If there's nothing to download, do nothing. */
if (files == 0) return;
@@ -317,7 +317,7 @@ void ClientNetworkContentSocketHandler::DownloadSelectedContent(uint &files, uin
*/
void ClientNetworkContentSocketHandler::DownloadSelectedContentHTTP(const ContentIDList &content)
{
- uint count = content.size();
+ uint count = (uint)content.size();
/* Allocate memory for the whole request.
* Requests are "id\nid\n..." (as strings), so assume the maximum ID,
@@ -345,7 +345,7 @@ void ClientNetworkContentSocketHandler::DownloadSelectedContentHTTP(const Conten
*/
void ClientNetworkContentSocketHandler::DownloadSelectedContentFallback(const ContentIDList &content)
{
- uint count = content.size();
+ uint count = (uint)content.size();
const ContentID *content_ids = content.data();
this->Connect();
diff --git a/src/network/network_content.h b/src/network/network_content.h
index 29a25f259..fb81925d2 100644
--- a/src/network/network_content.h
+++ b/src/network/network_content.h
@@ -129,7 +129,7 @@ public:
void CheckDependencyState(ContentInfo *ci);
/** Get the number of content items we know locally. */
- uint Length() const { return this->infos.size(); }
+ uint Length() const { return (uint)this->infos.size(); }
/** Get the begin of the content inf iterator. */
ConstContentIterator Begin() const { return this->infos.data(); }
/** Get the nth position of the content inf iterator. */
diff --git a/src/network/network_content_gui.cpp b/src/network/network_content_gui.cpp
index 09168185a..40f1966e4 100644
--- a/src/network/network_content_gui.cpp
+++ b/src/network/network_content_gui.cpp
@@ -400,7 +400,7 @@ class NetworkContentListWindow : public Window, ContentCallback {
this->content.RebuildDone();
this->SortContentList();
- this->vscroll->SetCount(this->content.size()); // Update the scrollbar
+ this->vscroll->SetCount((int)this->content.size()); // Update the scrollbar
this->ScrollToSelected();
}
@@ -813,7 +813,7 @@ public:
case WID_NCL_NAME:
if (this->content.SortType() == widget - WID_NCL_CHECKBOX) {
this->content.ToggleSortOrder();
- if (this->content.size() > 0) this->list_pos = this->content.size() - this->list_pos - 1;
+ if (this->content.size() > 0) this->list_pos = (int)this->content.size() - this->list_pos - 1;
} else {
this->content.SetSortType(widget - WID_NCL_CHECKBOX);
this->content.ForceResort();
@@ -888,7 +888,7 @@ public:
break;
case WKC_END:
/* jump to end */
- this->list_pos = this->content.size() - 1;
+ this->list_pos = (int)this->content.size() - 1;
break;
case WKC_SPACE:
diff --git a/src/network/network_gui.cpp b/src/network/network_gui.cpp
index b35e91528..0fd707676 100644
--- a/src/network/network_gui.cpp
+++ b/src/network/network_gui.cpp
@@ -269,7 +269,7 @@ protected:
this->servers.shrink_to_fit();
this->servers.RebuildDone();
- this->vscroll->SetCount(this->servers.size());
+ this->vscroll->SetCount((int)this->servers.size());
/* Sort the list of network games as requested. */
this->servers.Sort();
@@ -710,7 +710,7 @@ public:
case WID_NG_INFO: // Connectivity (green dot)
if (this->servers.SortType() == widget - WID_NG_NAME) {
this->servers.ToggleSortOrder();
- if (this->list_pos != SLP_INVALID) this->list_pos = this->servers.size() - this->list_pos - 1;
+ if (this->list_pos != SLP_INVALID) this->list_pos = (ServerListPosition)this->servers.size() - this->list_pos - 1;
} else {
this->servers.SetSortType(widget - WID_NG_NAME);
this->servers.ForceResort();
@@ -847,7 +847,7 @@ public:
break;
case WKC_END:
/* jump to end */
- this->list_pos = this->servers.size() - 1;
+ this->list_pos = (ServerListPosition)this->servers.size() - 1;
break;
default: NOT_REACHED();
}
@@ -1787,7 +1787,7 @@ struct NetworkClientListPopupWindow : Window {
d = maxdim(GetStringBoundingBox(action.name), d);
}
- d.height *= this->actions.size();
+ d.height *= (uint)this->actions.size();
d.width += WD_FRAMERECT_LEFT + WD_FRAMERECT_RIGHT;
d.height += WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM;
*size = d;
diff --git a/src/newgrf.cpp b/src/newgrf.cpp
index e45f34b76..0a526e50b 100644
--- a/src/newgrf.cpp
+++ b/src/newgrf.cpp
@@ -4822,7 +4822,7 @@ static void NewSpriteGroup(ByteReader *buf)
/* Continue reading var adjusts while bit 5 is set. */
} while (HasBit(varadjust, 5));
- group->num_adjusts = adjusts.size();
+ group->num_adjusts = (uint)adjusts.size();
group->adjusts = MallocT<DeterministicSpriteGroupAdjust>(group->num_adjusts);
MemCpyT(group->adjusts, adjusts.data(), group->num_adjusts);
@@ -9202,7 +9202,7 @@ static void FinalisePriceBaseMultipliers()
static const uint32 override_features = (1 << GSF_TRAINS) | (1 << GSF_ROADVEHICLES) | (1 << GSF_SHIPS) | (1 << GSF_AIRCRAFT);
/* Evaluate grf overrides */
- int num_grfs = _grf_files.size();
+ int num_grfs = (uint)_grf_files.size();
int *grf_overrides = AllocaM(int, num_grfs);
for (int i = 0; i < num_grfs; i++) {
grf_overrides[i] = -1;
diff --git a/src/newgrf_debug_gui.cpp b/src/newgrf_debug_gui.cpp
index 2ea9a6d88..69eaa4afa 100644
--- a/src/newgrf_debug_gui.cpp
+++ b/src/newgrf_debug_gui.cpp
@@ -895,7 +895,7 @@ struct SpriteAlignerWindow : Window {
int step_size = nwid->resize_y;
std::vector<SpriteID> &list = _newgrf_debug_sprite_picker.sprites;
- int max = min<int>(this->vscroll->GetPosition() + this->vscroll->GetCapacity(), list.size());
+ int max = min<int>(this->vscroll->GetPosition() + this->vscroll->GetCapacity(), (uint)list.size());
int y = r.top + WD_FRAMERECT_TOP;
for (int i = this->vscroll->GetPosition(); i < max; i++) {
@@ -1015,7 +1015,7 @@ struct SpriteAlignerWindow : Window {
if (data == 1) {
/* Sprite picker finished */
this->RaiseWidget(WID_SA_PICKER);
- this->vscroll->SetCount(_newgrf_debug_sprite_picker.sprites.size());
+ this->vscroll->SetCount((uint)_newgrf_debug_sprite_picker.sprites.size());
}
}
diff --git a/src/newgrf_gui.cpp b/src/newgrf_gui.cpp
index 1473f1877..bd5d07a86 100644
--- a/src/newgrf_gui.cpp
+++ b/src/newgrf_gui.cpp
@@ -882,7 +882,7 @@ struct NewGRFWindow : public Window, NewGRFScanCallback {
int offset_y = (step_height - FONT_HEIGHT_NORMAL) / 2;
uint y = r.top + WD_FRAMERECT_TOP;
uint min_index = this->vscroll2->GetPosition();
- uint max_index = min(min_index + this->vscroll2->GetCapacity(), this->avails.size());
+ uint max_index = min(min_index + this->vscroll2->GetCapacity(), (uint)this->avails.size());
for (uint i = min_index; i < max_index; i++) {
const GRFConfig *c = this->avails[i];
@@ -1328,7 +1328,7 @@ struct NewGRFWindow : public Window, NewGRFScanCallback {
case WKC_END:
/* jump to end */
- this->avail_pos = this->avails.size() - 1;
+ this->avail_pos = (uint)this->avails.size() - 1;
break;
default:
@@ -1492,7 +1492,7 @@ private:
}
}
- this->vscroll2->SetCount(this->avails.size()); // Update the scrollbar
+ this->vscroll2->SetCount((uint)this->avails.size()); // Update the scrollbar
}
/**
@@ -2067,7 +2067,7 @@ struct SavePresetWindow : public Window {
this->vscroll = this->GetScrollbar(WID_SVP_SCROLLBAR);
this->FinishInitNested(0);
- this->vscroll->SetCount(this->presets.size());
+ this->vscroll->SetCount((uint)this->presets.size());
this->SetFocusedWidget(WID_SVP_EDITBOX);
if (initial_text != NULL) this->presetname_editbox.text.Assign(initial_text);
}
@@ -2087,7 +2087,7 @@ struct SavePresetWindow : public Window {
size->width = max(size->width, d.width + WD_FRAMETEXT_LEFT + WD_FRAMETEXT_RIGHT);
resize->height = max(resize->height, d.height);
}
- size->height = ClampU(this->presets.size(), 5, 20) * resize->height + 1;
+ size->height = ClampU((uint)this->presets.size(), 5, 20) * resize->height + 1;
break;
}
}
@@ -2103,7 +2103,7 @@ struct SavePresetWindow : public Window {
int offset_y = (step_height - FONT_HEIGHT_NORMAL) / 2;
uint y = r.top + WD_FRAMERECT_TOP;
uint min_index = this->vscroll->GetPosition();
- uint max_index = min(min_index + this->vscroll->GetCapacity(), this->presets.size());
+ uint max_index = min(min_index + this->vscroll->GetCapacity(), (uint)this->presets.size());
for (uint i = min_index; i < max_index; i++) {
if ((int)i == this->selected) GfxFillRect(r.left + 1, y, r.right - 1, y + step_height - 2, PC_DARK_BLUE);
diff --git a/src/newgrf_sound.cpp b/src/newgrf_sound.cpp
index c37d6b4ed..0a04f4400 100644
--- a/src/newgrf_sound.cpp
+++ b/src/newgrf_sound.cpp
@@ -56,7 +56,7 @@ SoundEntry *GetSound(SoundID index)
uint GetNumSounds()
{
- return _sounds.size();
+ return (uint)_sounds.size();
}
diff --git a/src/os/windows/string_uniscribe.cpp b/src/os/windows/string_uniscribe.cpp
index 5cba9a3d8..1d17b02d7 100644
--- a/src/os/windows/string_uniscribe.cpp
+++ b/src/os/windows/string_uniscribe.cpp
@@ -110,7 +110,7 @@ public:
public:
virtual int GetLeading() const;
virtual int GetWidth() const;
- virtual int CountRuns() const { return this->size(); }
+ virtual int CountRuns() const { return (uint)this->size(); }
virtual const VisualRun *GetVisualRun(int run) const { return this->at(run); }
int GetInternalCharLength(WChar c) const
diff --git a/src/saveload/game_sl.cpp b/src/saveload/game_sl.cpp
index cffff5018..d2a968717 100644
--- a/src/saveload/game_sl.cpp
+++ b/src/saveload/game_sl.cpp
@@ -132,7 +132,7 @@ static const SaveLoad _game_language_string[] = {
static void SaveReal_GSTR(LanguageStrings *ls)
{
_game_saveload_string = ls->language;
- _game_saveload_strings = ls->lines.size();
+ _game_saveload_strings = (uint)ls->lines.size();
SlObject(NULL, _game_language_header);
for (uint i = 0; i < _game_saveload_strings; i++) {
diff --git a/src/script/api/script_road.cpp b/src/script/api/script_road.cpp
index 3dd1453b6..44972cdea 100644
--- a/src/script/api/script_road.cpp
+++ b/src/script/api/script_road.cpp
@@ -245,7 +245,7 @@ static int32 LookupWithBuildOnSlopes(::Slope slope, Array *existing, int32 start
/* Now perform the actual rotation. */
for (int j = 0; j < base_rotate; j++) {
- for (int i = 0; i < existing->size; i++) {
+ for (size_t i = 0; i < existing->size; i++) {
existing->array[i] = RotateNeighbour(existing->array[i]);
}
start = RotateNeighbour(start);
@@ -256,7 +256,7 @@ static int32 LookupWithBuildOnSlopes(::Slope slope, Array *existing, int32 start
RoadBits start_roadbits = NeighbourToRoadBits(start);
RoadBits new_roadbits = start_roadbits | NeighbourToRoadBits(end);
RoadBits existing_roadbits = ROAD_NONE;
- for (int i = 0; i < existing->size; i++) {
+ for (size_t i = 0; i < existing->size; i++) {
existing_roadbits |= NeighbourToRoadBits(existing->array[i]);
}
@@ -354,7 +354,7 @@ static bool NormaliseTileOffset(int32 *tile)
/* The start tile and end tile cannot be the same tile either. */
if (start == end) return -1;
- for (int i = 0; i < existing->size; i++) {
+ for (size_t i = 0; i < existing->size; i++) {
if (!NormaliseTileOffset(&existing->array[i])) return -1;
}
diff --git a/src/script/squirrel_helper_type.hpp b/src/script/squirrel_helper_type.hpp
index 946a59547..a42cd79a9 100644
--- a/src/script/squirrel_helper_type.hpp
+++ b/src/script/squirrel_helper_type.hpp
@@ -14,7 +14,7 @@
/** Definition of a simple array. */
struct Array {
- int32 size; ///< The size of the array.
+ size_t size; ///< The size of the array.
int32 array[]; ///< The data of the array.
};
diff --git a/src/settings_gui.cpp b/src/settings_gui.cpp
index cfed29d4d..c15f075ec 100644
--- a/src/settings_gui.cpp
+++ b/src/settings_gui.cpp
@@ -255,7 +255,7 @@ struct GameOptionsWindow : Window {
}
QSortT(list->data(), list->size(), DropDownListStringItem::NatSortFunc);
- int newgrf_size = list->size();
+ size_t newgrf_size = list->size();
/* Insert newgrf_names at the top of the list */
if (newgrf_size > 0) {
list->push_back(new DropDownListItem(-1, false)); // separator line
diff --git a/src/signs_gui.cpp b/src/signs_gui.cpp
index cab19c22f..64fbcad80 100644
--- a/src/signs_gui.cpp
+++ b/src/signs_gui.cpp
@@ -310,7 +310,7 @@ struct SignListWindow : Window, SignList {
{
if (this->signs.NeedRebuild()) {
this->BuildSignsList();
- this->vscroll->SetCount(this->signs.size());
+ this->vscroll->SetCount((uint)this->signs.size());
this->SetWidgetDirty(WID_SIL_CAPTION);
}
this->SortSignsList();
@@ -471,7 +471,7 @@ struct SignWindow : Window, SignList {
/* Search through the list for the current sign, excluding
* - the first sign if we want the previous sign or
* - the last sign if we want the next sign */
- uint end = this->signs.size() - (next ? 1 : 0);
+ size_t end = this->signs.size() - (next ? 1 : 0);
for (uint i = next ? 0 : 1; i < end; i++) {
if (this->cur_sign == this->signs[i]->index) {
/* We've found the current sign, so return the sign before/after it */
diff --git a/src/station_gui.cpp b/src/station_gui.cpp
index 92c186a2e..edd02d6ae 100644
--- a/src/station_gui.cpp
+++ b/src/station_gui.cpp
@@ -205,7 +205,7 @@ protected:
this->stations.shrink_to_fit();
this->stations.RebuildDone();
- this->vscroll->SetCount(this->stations.size()); // Update the scrollbar
+ this->vscroll->SetCount((uint)this->stations.size()); // Update the scrollbar
}
/** Sort stations by their name */
@@ -411,7 +411,7 @@ public:
case WID_STL_LIST: {
bool rtl = _current_text_dir == TD_RTL;
- int max = min(this->vscroll->GetPosition() + this->vscroll->GetCapacity(), this->stations.size());
+ int max = min(this->vscroll->GetPosition() + this->vscroll->GetCapacity(), (uint)this->stations.size());
int y = r.top + WD_FRAMERECT_TOP;
for (int i = this->vscroll->GetPosition(); i < max; ++i) { // do until max number of stations of owner
const Station *st = this->stations[i];
@@ -2331,7 +2331,7 @@ struct SelectStationWindow : Window {
{
if (!gui_scope) return;
FindStationsNearby<T>(this->area, true);
- this->vscroll->SetCount(_stations_nearby_list.size() + 1);
+ this->vscroll->SetCount((uint)_stations_nearby_list.size() + 1);
this->SetDirty();
}
};
diff --git a/src/strgen/strgen_base.cpp b/src/strgen/strgen_base.cpp
index f0dc03aa0..00c3fb9f6 100644
--- a/src/strgen/strgen_base.cpp
+++ b/src/strgen/strgen_base.cpp
@@ -1029,14 +1029,14 @@ void LanguageWriter::WriteLang(const StringData &data)
for (c = casep; c != NULL; c = c->next) {
buffer.AppendByte(c->caseidx);
/* Make some space for the 16-bit length */
- uint pos = buffer.size();
+ uint pos = (uint)buffer.size();
buffer.AppendByte(0);
buffer.AppendByte(0);
/* Write string */
PutCommandString(&buffer, c->string);
buffer.AppendByte(0); // terminate with a zero
/* Fill in the length */
- uint size = buffer.size() - (pos + 2);
+ uint size = (uint)buffer.size() - (pos + 2);
buffer[pos + 0] = GB(size, 8, 8);
buffer[pos + 1] = GB(size, 0, 8);
}
@@ -1044,7 +1044,7 @@ void LanguageWriter::WriteLang(const StringData &data)
if (cmdp != NULL) PutCommandString(&buffer, cmdp);
- this->WriteLength(buffer.size());
+ this->WriteLength((uint)buffer.size());
this->Write(buffer.data(), buffer.size());
buffer.clear();
}
diff --git a/src/textfile_gui.cpp b/src/textfile_gui.cpp
index b4911a968..b70d183bd 100644
--- a/src/textfile_gui.cpp
+++ b/src/textfile_gui.cpp
@@ -116,7 +116,7 @@ void TextfileWindow::SetupScrollbars()
for (uint i = 0; i < this->lines.size(); i++) {
max_length = max(max_length, GetStringBoundingBox(this->lines[i], FS_MONO).width);
}
- this->vscroll->SetCount(this->lines.size() * FONT_HEIGHT_MONO);
+ this->vscroll->SetCount((uint)this->lines.size() * FONT_HEIGHT_MONO);
this->hscroll->SetCount(max_length + WD_FRAMETEXT_LEFT + WD_FRAMETEXT_RIGHT);
}
diff --git a/src/timetable_cmd.cpp b/src/timetable_cmd.cpp
index 6524260ff..c6c5afe9b 100644
--- a/src/timetable_cmd.cpp
+++ b/src/timetable_cmd.cpp
@@ -292,7 +292,7 @@ CommandCost CmdSetTimetableStart(TileIndex tile, DoCommandFlag flags, uint32 p1,
}
int total_duration = v->orders.list->GetTimetableTotalDuration();
- int num_vehs = vehs.size();
+ int num_vehs = (uint)vehs.size();
if (num_vehs >= 2) {
QSortT(vehs.data(), vehs.size(), &VehicleTimetableSorter);
diff --git a/src/town_gui.cpp b/src/town_gui.cpp
index 55f65e320..cf5d43026 100644
--- a/src/town_gui.cpp
+++ b/src/town_gui.cpp
@@ -659,7 +659,7 @@ private:
this->towns.shrink_to_fit();
this->towns.RebuildDone();
- this->vscroll->SetCount(this->towns.size()); // Update scrollbar as well.
+ this->vscroll->SetCount((uint)this->towns.size()); // Update scrollbar as well.
}
/* Always sort the towns. */
this->last_town = NULL;
diff --git a/src/vehicle_gui.cpp b/src/vehicle_gui.cpp
index 34fcdc159..647ab44f5 100644
--- a/src/vehicle_gui.cpp
+++ b/src/vehicle_gui.cpp
@@ -133,7 +133,7 @@ void BaseVehicleListWindow::BuildVehicleList()
this->unitnumber_digits = GetUnitNumberDigits(this->vehicles);
this->vehicles.RebuildDone();
- this->vscroll->SetCount(this->vehicles.size());
+ this->vscroll->SetCount((uint)this->vehicles.size());
}
/**
@@ -1386,7 +1386,7 @@ void BaseVehicleListWindow::DrawVehicleListItems(VehicleID selected_vehicle, int
int vehicle_button_x = rtl ? right - GetSpriteSize(SPR_PROFIT_LOT).width : left;
int y = r.top;
- uint max = min(this->vscroll->GetPosition() + this->vscroll->GetCapacity(), this->vehicles.size());
+ uint max = min(this->vscroll->GetPosition() + this->vscroll->GetCapacity(), (uint)this->vehicles.size());
for (uint i = this->vscroll->GetPosition(); i < max; ++i) {
const Vehicle *v = this->vehicles[i];
StringID str;
diff --git a/src/viewport.cpp b/src/viewport.cpp
index 4c9507bca..9bbe6a462 100644
--- a/src/viewport.cpp
+++ b/src/viewport.cpp
@@ -599,7 +599,7 @@ void OffsetGroundSprite(int x, int y)
}
/* _vd.last_child == NULL if foundation sprite was clipped by the viewport bounds */
- if (_vd.last_child != NULL) _vd.foundation[_vd.foundation_part] = _vd.parent_sprites_to_draw.size() - 1;
+ if (_vd.last_child != NULL) _vd.foundation[_vd.foundation_part] = (uint)_vd.parent_sprites_to_draw.size() - 1;
_vd.foundation_offset[_vd.foundation_part].x = x * ZOOM_LVL_BASE;
_vd.foundation_offset[_vd.foundation_part].y = y * ZOOM_LVL_BASE;
@@ -826,7 +826,7 @@ void AddChildSpriteScreen(SpriteID image, PaletteID pal, int x, int y, bool tran
pal = PALETTE_TO_TRANSPARENT;
}
- *_vd.last_child = _vd.child_screen_sprites_to_draw.size();
+ *_vd.last_child = (uint)_vd.child_screen_sprites_to_draw.size();
/*C++17: ChildScreenSpriteToDraw &cs = */ _vd.child_screen_sprites_to_draw.emplace_back();
ChildScreenSpriteToDraw &cs = _vd.child_screen_sprites_to_draw.back();
diff --git a/src/widgets/dropdown.cpp b/src/widgets/dropdown.cpp
index 7c59cca7a..d0ad6bc46 100644
--- a/src/widgets/dropdown.cpp
+++ b/src/widgets/dropdown.cpp
@@ -412,7 +412,7 @@ void ShowDropDownListAt(Window *w, const DropDownList *list, int selected, int b
/* If the dropdown doesn't fully fit, we need a dropdown. */
if (height > available_height) {
scroll = true;
- uint avg_height = height / list->size();
+ uint avg_height = height / (uint)list->size();
/* Check at least there is space for one item. */
assert(available_height >= avg_height);