mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-03-13 02:52:37 +00:00
Fix: MSVC warnings (#7423)
This commit is contained in:
parent
e817951bfd
commit
66dd7c3879
@ -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,
|
||||
|
@ -153,7 +153,7 @@ public:
|
||||
this->bridges->NeedResort();
|
||||
this->SortBridgeList();
|
||||
|
||||
this->vscroll->SetCount(bl->size());
|
||||
this->vscroll->SetCount((uint)bl->size());
|
||||
}
|
||||
|
||||
~BuildBridgeWindow()
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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. */
|
||||
|
@ -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;
|
||||
|
@ -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();
|
||||
|
10
src/fios.h
10
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];
|
||||
}
|
||||
|
@ -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();
|
||||
|
||||
|
@ -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();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -449,7 +449,7 @@ int FallbackParagraphLayout::FallbackLine::GetWidth() const
|
||||
*/
|
||||
int FallbackParagraphLayout::FallbackLine::CountRuns() const
|
||||
{
|
||||
return this->size();
|
||||
return (uint)this->size();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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) {
|
||||
|
@ -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;
|
||||
|
@ -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.
|
||||
|
@ -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];
|
||||
|
||||
|
@ -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();
|
||||
|
||||
|
@ -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. */
|
||||
|
@ -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:
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
|
@ -56,7 +56,7 @@ SoundEntry *GetSound(SoundID index)
|
||||
|
||||
uint GetNumSounds()
|
||||
{
|
||||
return _sounds.size();
|
||||
return (uint)_sounds.size();
|
||||
}
|
||||
|
||||
|
||||
|
@ -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
|
||||
|
@ -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++) {
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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.
|
||||
};
|
||||
|
||||
|
@ -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
|
||||
|
@ -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 */
|
||||
|
@ -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();
|
||||
}
|
||||
};
|
||||
|
@ -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();
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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();
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user