summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorHenry Wilson <m3henry@googlemail.com>2018-09-23 12:23:54 +0100
committerPeterN <peter@fuzzle.org>2019-03-26 20:15:57 +0000
commita690936ed75e96627be0e2ecafee2360a71e8d3c (patch)
tree1221c131b8fe3a51cf43a6bd7d89a51c431c559d /src
parent56ae855dc20b27593c9a454d5a09d8f892a6c71f (diff)
downloadopenttd-a690936ed75e96627be0e2ecafee2360a71e8d3c.tar.xz
Codechange: Replace SmallVector::Length() with std::vector::size()
Diffstat (limited to 'src')
-rw-r--r--src/autoreplace_gui.cpp10
-rw-r--r--src/bridge_gui.cpp12
-rw-r--r--src/build_vehicle_gui.cpp12
-rw-r--r--src/company_gui.cpp8
-rw-r--r--src/console_cmds.cpp6
-rw-r--r--src/core/pool_func.cpp2
-rw-r--r--src/core/smallstack_type.hpp2
-rw-r--r--src/core/smallvec_type.hpp10
-rw-r--r--src/depot_gui.cpp20
-rw-r--r--src/engine.cpp2
-rw-r--r--src/engine_gui.cpp6
-rw-r--r--src/fios.cpp2
-rw-r--r--src/fios.h2
-rw-r--r--src/game/game_text.cpp4
-rw-r--r--src/gfx.cpp4
-rw-r--r--src/gfx_layout.cpp8
-rw-r--r--src/graph_gui.cpp2
-rw-r--r--src/group_gui.cpp34
-rw-r--r--src/hotkeys.cpp2
-rw-r--r--src/industry_gui.cpp18
-rw-r--r--src/linkgraph/linkgraph.h2
-rw-r--r--src/music/dmusic.cpp4
-rw-r--r--src/music/midifile.cpp6
-rw-r--r--src/music/win32_m.cpp4
-rw-r--r--src/network/core/tcp_http.cpp2
-rw-r--r--src/network/core/tcp_listen.h4
-rw-r--r--src/network/core/udp.cpp4
-rw-r--r--src/network/network.cpp2
-rw-r--r--src/network/network_content.cpp18
-rw-r--r--src/network/network_content.h2
-rw-r--r--src/network/network_content_gui.cpp14
-rw-r--r--src/network/network_gui.cpp24
-rw-r--r--src/newgrf.cpp26
-rw-r--r--src/newgrf_cargo.cpp4
-rw-r--r--src/newgrf_config.cpp12
-rw-r--r--src/newgrf_debug_gui.cpp6
-rw-r--r--src/newgrf_engine.cpp2
-rw-r--r--src/newgrf_gui.cpp50
-rw-r--r--src/newgrf_railtype.cpp2
-rw-r--r--src/newgrf_sound.cpp4
-rw-r--r--src/os/macosx/string_osx.cpp4
-rw-r--r--src/os/windows/string_uniscribe.cpp2
-rw-r--r--src/rail_cmd.cpp2
-rw-r--r--src/saveload/animated_tile_sl.cpp4
-rw-r--r--src/saveload/game_sl.cpp6
-rw-r--r--src/saveload/labelmaps_sl.cpp4
-rw-r--r--src/saveload/linkgraph_sl.cpp4
-rw-r--r--src/saveload/saveload.cpp2
-rw-r--r--src/saveload/waypoint_sl.cpp2
-rw-r--r--src/script/squirrel_helper.hpp6
-rw-r--r--src/settings_gui.cpp12
-rw-r--r--src/settingsgen/settingsgen.cpp4
-rw-r--r--src/signs_gui.cpp8
-rw-r--r--src/station_cmd.cpp2
-rw-r--r--src/station_gui.cpp18
-rw-r--r--src/story_gui.cpp18
-rw-r--r--src/strgen/strgen_base.cpp8
-rw-r--r--src/string.cpp4
-rw-r--r--src/stringfilter_type.h4
-rw-r--r--src/strings.cpp2
-rw-r--r--src/texteff.cpp4
-rw-r--r--src/textfile_gui.cpp10
-rw-r--r--src/timetable_cmd.cpp4
-rw-r--r--src/town_gui.cpp10
-rw-r--r--src/train_cmd.cpp2
-rw-r--r--src/train_gui.cpp8
-rw-r--r--src/vehicle_cmd.cpp8
-rw-r--r--src/vehicle_gui.cpp44
-rw-r--r--src/viewport.cpp8
-rw-r--r--src/widgets/dropdown.cpp10
-rw-r--r--src/window.cpp2
71 files changed, 287 insertions, 297 deletions
diff --git a/src/autoreplace_gui.cpp b/src/autoreplace_gui.cpp
index 356058e93..1286dc5a7 100644
--- a/src/autoreplace_gui.cpp
+++ b/src/autoreplace_gui.cpp
@@ -160,8 +160,8 @@ 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].Length());
- if (this->reset_sel_engine && this->sel_engine[0] == INVALID_ENGINE && this->engines[0].Length() != 0) {
+ this->vscroll[0]->SetCount(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].Length());
+ this->vscroll[1]->SetCount(this->engines[1].size());
if (this->reset_sel_engine && this->sel_engine[1] != INVALID_ENGINE) {
int position = 0;
for (EngineID *it = this->engines[1].Begin(); it != this->engines[1].End(); ++it) {
@@ -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].Length());
+ EngineID end = min(this->vscroll[side]->GetCapacity() + start, 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,
@@ -508,7 +508,7 @@ public:
click_side = 1;
}
uint i = this->vscroll[click_side]->GetScrolledRowFromWidget(pt.y, this, widget);
- size_t engine_count = this->engines[click_side].Length();
+ size_t engine_count = this->engines[click_side].size();
EngineID e = engine_count > i ? this->engines[click_side][i] : INVALID_ENGINE;
if (e == this->sel_engine[click_side]) break; // we clicked the one we already selected
diff --git a/src/bridge_gui.cpp b/src/bridge_gui.cpp
index 29cb5a085..0b4d0d619 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->Length());
+ this->vscroll->SetCount(bl->size());
}
~BuildBridgeWindow()
@@ -186,7 +186,7 @@ public:
case WID_BBS_BRIDGE_LIST: {
Dimension sprite_dim = {0, 0}; // Biggest bridge sprite dimension
Dimension text_dim = {0, 0}; // Biggest text dimension
- for (int i = 0; i < (int)this->bridges->Length(); i++) {
+ for (int i = 0; i < (int)this->bridges->size(); i++) {
const BridgeSpec *b = this->bridges->Get(i)->spec;
sprite_dim = maxdim(sprite_dim, GetSpriteSize(b->sprite));
@@ -226,7 +226,7 @@ public:
case WID_BBS_BRIDGE_LIST: {
uint y = r.top;
- for (int i = this->vscroll->GetPosition(); this->vscroll->IsVisible(i) && i < (int)this->bridges->Length(); i++) {
+ for (int i = this->vscroll->GetPosition(); this->vscroll->IsVisible(i) && i < (int)this->bridges->size(); i++) {
const BridgeSpec *b = this->bridges->Get(i)->spec;
SetDParam(2, this->bridges->Get(i)->cost);
@@ -246,7 +246,7 @@ public:
EventState OnKeyPress(WChar key, uint16 keycode) override
{
const uint8 i = keycode - '1';
- if (i < 9 && i < this->bridges->Length()) {
+ if (i < 9 && i < this->bridges->size()) {
/* Build the requested bridge */
this->BuildBridge(i);
delete this;
@@ -261,7 +261,7 @@ public:
default: break;
case WID_BBS_BRIDGE_LIST: {
uint i = this->vscroll->GetScrolledRowFromWidget(pt.y, this, WID_BBS_BRIDGE_LIST);
- if (i < this->bridges->Length()) {
+ if (i < this->bridges->size()) {
this->BuildBridge(i);
delete this;
}
@@ -426,7 +426,7 @@ void ShowBuildBridgeWindow(TileIndex start, TileIndex end, TransportType transpo
}
}
- if (bl != NULL && bl->Length() != 0) {
+ if (bl != NULL && bl->size() != 0) {
new BuildBridgeWindow(&_build_bridge_desc, start, end, type, bl);
} else {
delete bl;
diff --git a/src/build_vehicle_gui.cpp b/src/build_vehicle_gui.cpp
index f580ba7a9..ce3ebeff4 100644
--- a/src/build_vehicle_gui.cpp
+++ b/src/build_vehicle_gui.cpp
@@ -940,7 +940,7 @@ void DrawEngineList(VehicleType type, int l, int r, int y, const GUIEngineList *
static const int sprite_y_offsets[] = { -1, -1, -2, -2 };
/* Obligatory sanity checks! */
- assert(max <= eng_list->Length());
+ assert(max <= eng_list->size());
bool rtl = _current_text_dir == TD_RTL;
int step_size = GetEngineListHeight(type);
@@ -1110,7 +1110,7 @@ struct BuildVehicleWindow : Window {
this->eng_list.ForceRebuild();
this->GenerateBuildList(); // generate the list, since we need it in the next line
/* Select the first engine in the list as default when opening the window */
- if (this->eng_list.Length() > 0) {
+ if (this->eng_list.size() > 0) {
this->SelectEngine(this->eng_list[0]);
} else {
this->SelectEngine(INVALID_ENGINE);
@@ -1205,7 +1205,7 @@ struct BuildVehicleWindow : Window {
void FilterEngineList()
{
this->eng_list.Filter(this->cargo_filter[this->cargo_filter_criteria]);
- if (0 == this->eng_list.Length()) { // no engine passed through the filter, invalidate the previously selected engine
+ if (0 == this->eng_list.size()) { // no engine passed through the filter, invalidate the previously selected engine
this->SelectEngine(INVALID_ENGINE);
} else if (!this->eng_list.Contains(this->sel_engine)) { // previously selected engine didn't pass the filter, select the first engine of the list
this->SelectEngine(this->eng_list[0]);
@@ -1388,7 +1388,7 @@ struct BuildVehicleWindow : Window {
case WID_BV_LIST: {
uint i = this->vscroll->GetScrolledRowFromWidget(pt.y, this, WID_BV_LIST);
- size_t num_items = this->eng_list.Length();
+ size_t num_items = this->eng_list.size();
this->SelectEngine((i < num_items) ? this->eng_list[i] : INVALID_ENGINE);
this->SetDirty();
if (_ctrl_pressed) {
@@ -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.Length()), 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(), 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.Length());
+ this->vscroll->SetCount(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 19aea1775..b34862f69 100644
--- a/src/company_gui.cpp
+++ b/src/company_gui.cpp
@@ -686,7 +686,7 @@ private:
}
}
} else {
- this->rows = this->groups.Length();
+ this->rows = 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.Length());
+ uint max = min(this->vscroll->GetPosition() + this->vscroll->GetCapacity(), this->groups.size());
for (uint i = this->vscroll->GetPosition(); i < max; ++i) {
const Group *g = this->groups[i];
SetDParam(0, g->index);
@@ -942,7 +942,7 @@ public:
this->groups.ForceRebuild();
this->BuildGroupList((CompanyID)this->window_number);
- if (this->groups.Length() > 0) {
+ if (this->groups.size() > 0) {
this->sel = this->groups[0]->index;
}
}
@@ -1029,7 +1029,7 @@ public:
if (!Group::IsValidID(this->sel)) {
this->sel = INVALID_GROUP;
- if (this->groups.Length() > 0) this->sel = this->groups[0]->index;
+ if (this->groups.size() > 0) this->sel = this->groups[0]->index;
}
this->SetDirty();
diff --git a/src/console_cmds.cpp b/src/console_cmds.cpp
index 6c8e927c9..a4a6fccd1 100644
--- a/src/console_cmds.cpp
+++ b/src/console_cmds.cpp
@@ -552,16 +552,16 @@ DEF_CONSOLE_CMD(ConUnBan)
/* Try by IP. */
uint index;
- for (index = 0; index < _network_ban_list.Length(); index++) {
+ for (index = 0; index < _network_ban_list.size(); index++) {
if (strcmp(_network_ban_list[index], argv[1]) == 0) break;
}
/* Try by index. */
- if (index >= _network_ban_list.Length()) {
+ if (index >= _network_ban_list.size()) {
index = atoi(argv[1]) - 1U; // let it wrap
}
- if (index < _network_ban_list.Length()) {
+ if (index < _network_ban_list.size()) {
char msg[64];
seprintf(msg, lastof(msg), "Unbanned %s", _network_ban_list[index]);
IConsolePrint(CC_DEFAULT, msg);
diff --git a/src/core/pool_func.cpp b/src/core/pool_func.cpp
index f8ff93cec..914cbcfd9 100644
--- a/src/core/pool_func.cpp
+++ b/src/core/pool_func.cpp
@@ -22,7 +22,7 @@
{
PoolVector *pools = PoolBase::GetPools();
pools->Erase(pools->Find(this));
- if (pools->Length() == 0) delete pools;
+ if (pools->size() == 0) delete pools;
}
/**
diff --git a/src/core/smallstack_type.hpp b/src/core/smallstack_type.hpp
index b053c32a8..76d97f961 100644
--- a/src/core/smallstack_type.hpp
+++ b/src/core/smallstack_type.hpp
@@ -73,7 +73,7 @@ private:
if (!this->data[index].valid) return index;
}
- if (index >= this->data.Length() && index < Tmax_size) {
+ if (index >= this->data.size() && index < Tmax_size) {
this->data.Resize(index + 1);
}
return index;
diff --git a/src/core/smallvec_type.hpp b/src/core/smallvec_type.hpp
index be3ec309c..600b7ea26 100644
--- a/src/core/smallvec_type.hpp
+++ b/src/core/smallvec_type.hpp
@@ -218,16 +218,6 @@ public:
}
/**
- * Get the number of items in the list.
- *
- * @return The number of items in the list.
- */
- inline uint Length() const
- {
- return std::vector<T>::size();
- }
-
- /**
* Get the pointer to the first item (const)
*
* @return the pointer to the first item
diff --git a/src/depot_gui.cpp b/src/depot_gui.cpp
index f2da7330e..2b5879116 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.Length(), num + (rows_in_display * this->num_columns));
+ int maxval = min(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,11 +413,11 @@ struct DepotWindow : Window {
}
}
- maxval = min(this->vehicle_list.Length() + this->wagon_list.Length(), (this->vscroll->GetPosition() * this->num_columns) + (rows_in_display * this->num_columns));
+ maxval = min(this->vehicle_list.size() + 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) {
- const Vehicle *v = this->wagon_list[num - this->vehicle_list.Length()];
+ const Vehicle *v = this->wagon_list[num - this->vehicle_list.size()];
this->DrawVehicleInDepot(v, r.left, r.right, y);
}
}
@@ -465,7 +465,7 @@ struct DepotWindow : Window {
uint pos = ((row + this->vscroll->GetPosition()) * this->num_columns) + xt;
- if (this->vehicle_list.Length() + this->wagon_list.Length() <= pos) {
+ if (this->vehicle_list.size() + this->wagon_list.size() <= pos) {
/* Clicking on 'line' / 'block' without a vehicle */
if (this->type == VEH_TRAIN) {
/* End the dragging */
@@ -478,12 +478,12 @@ struct DepotWindow : Window {
}
bool wagon = false;
- if (this->vehicle_list.Length() > pos) {
+ if (this->vehicle_list.size() > pos) {
*veh = this->vehicle_list[pos];
/* Skip vehicles that are scrolled off the list */
if (this->type == VEH_TRAIN) x += this->hscroll->GetPosition();
} else {
- pos -= this->vehicle_list.Length();
+ pos -= this->vehicle_list.size();
*veh = this->wagon_list[pos];
/* free wagons don't have an initial loco. */
x -= ScaleGUITrad(VEHICLEINFO_FULL_VEHICLE_WIDTH);
@@ -726,7 +726,7 @@ struct DepotWindow : Window {
/* determine amount of items for scroller */
if (this->type == VEH_TRAIN) {
uint max_width = ScaleGUITrad(VEHICLEINFO_FULL_VEHICLE_WIDTH);
- for (uint num = 0; num < this->vehicle_list.Length(); num++) {
+ for (uint num = 0; num < this->vehicle_list.size(); num++) {
uint width = 0;
for (const Train *v = Train::From(this->vehicle_list[num]); v != NULL; v = v->Next()) {
width += v->GetDisplayImageWidth();
@@ -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.Length() + this->wagon_list.Length() + 1);
+ this->vscroll->SetCount(this->vehicle_list.size() + 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.Length(), this->num_columns));
+ this->vscroll->SetCount(CeilDiv(this->vehicle_list.size(), this->num_columns));
}
/* Setup disabled buttons. */
@@ -811,7 +811,7 @@ struct DepotWindow : Window {
case WID_D_SELL_ALL:
/* Only open the confirmation window if there are anything to sell */
- if (this->vehicle_list.Length() != 0 || this->wagon_list.Length() != 0) {
+ if (this->vehicle_list.size() != 0 || this->wagon_list.size() != 0) {
TileIndex tile = this->window_number;
byte vehtype = this->type;
diff --git a/src/engine.cpp b/src/engine.cpp
index e0536e7ba..b7be293af 100644
--- a/src/engine.cpp
+++ b/src/engine.cpp
@@ -547,7 +547,7 @@ void SetupEngines()
DeleteWindowByClass(WC_ENGINE_PREVIEW);
_engine_pool.CleanPool();
- assert(_engine_mngr.Length() >= _engine_mngr.NUM_DEFAULT_ENGINES);
+ assert(_engine_mngr.size() >= _engine_mngr.NUM_DEFAULT_ENGINES);
const EngineIDMapping *end = _engine_mngr.End();
uint index = 0;
for (const EngineIDMapping *eid = _engine_mngr.Begin(); eid != end; eid++, index++) {
diff --git a/src/engine_gui.cpp b/src/engine_gui.cpp
index 8e7f1a824..c2a258f18 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->Length();
+ uint 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,8 +342,8 @@ void EngList_Sort(GUIEngineList *el, EngList_SortTypeFunction compare)
void EngList_SortPartial(GUIEngineList *el, EngList_SortTypeFunction compare, uint begin, uint num_items)
{
if (num_items < 2) return;
- assert(begin < el->Length());
- assert(begin + num_items <= el->Length());
+ assert(begin < el->size());
+ assert(begin + num_items <= el->size());
QSortT(el->Get(begin), num_items, compare);
}
diff --git a/src/fios.cpp b/src/fios.cpp
index f849b9a16..a1369e1cd 100644
--- a/src/fios.cpp
+++ b/src/fios.cpp
@@ -380,7 +380,7 @@ static void FiosGetFileList(SaveLoadOperation fop, fios_getlist_callback_proc *c
{
SortingBits order = _savegame_sort_order;
_savegame_sort_order = SORT_BY_NAME | SORT_ASCENDING;
- QSortT(file_list.files.Begin(), file_list.files.Length(), CompareFiosItems);
+ QSortT(file_list.files.Begin(), file_list.files.size(), CompareFiosItems);
_savegame_sort_order = order;
}
diff --git a/src/fios.h b/src/fios.h
index 848fe7c8e..71a6cff17 100644
--- a/src/fios.h
+++ b/src/fios.h
@@ -129,7 +129,7 @@ public:
*/
inline uint Length() const
{
- return this->files.Length();
+ return this->files.size();
}
/**
diff --git a/src/game/game_text.cpp b/src/game/game_text.cpp
index 4673e732c..781d0daba 100644
--- a/src/game/game_text.cpp
+++ b/src/game/game_text.cpp
@@ -212,7 +212,7 @@ struct StringNameWriter : HeaderWriter {
void WriteStringID(const char *name, int stringid)
{
- if (stringid == (int)this->strings->Length()) *this->strings->Append() = stredup(name);
+ if (stringid == (int)this->strings->size()) *this->strings->Append() = stredup(name);
}
void Finalise(const StringData &data)
@@ -340,7 +340,7 @@ GameStrings *_current_data = NULL;
*/
const char *GetGameStringPtr(uint id)
{
- if (id >= _current_data->cur_language->lines.Length()) return GetStringPtr(STR_UNDEFINED);
+ if (id >= _current_data->cur_language->lines.size()) return GetStringPtr(STR_UNDEFINED);
return _current_data->cur_language->lines[id];
}
diff --git a/src/gfx.cpp b/src/gfx.cpp
index aedd2c17e..42bb56400 100644
--- a/src/gfx.cpp
+++ b/src/gfx.cpp
@@ -509,7 +509,7 @@ int DrawString(int left, int right, int top, const char *str, TextColour colour,
}
Layouter layout(str, INT32_MAX, colour, fontsize);
- if (layout.Length() == 0) return 0;
+ if (layout.size() == 0) return 0;
return DrawLayoutLine(*layout.Begin(), top, left, right, align, underline, true);
}
@@ -574,7 +574,7 @@ int GetStringLineCount(StringID str, int maxw)
GetString(buffer, str, lastof(buffer));
Layouter layout(buffer, maxw);
- return layout.Length();
+ return layout.size();
}
/**
diff --git a/src/gfx_layout.cpp b/src/gfx_layout.cpp
index f0fb39107..7c4407e3a 100644
--- a/src/gfx_layout.cpp
+++ b/src/gfx_layout.cpp
@@ -200,7 +200,7 @@ public:
}
/* Fill ICU's FontRuns with the right data. */
- icu::FontRuns runs(fontMapping.Length());
+ icu::FontRuns runs(fontMapping.size());
for (FontMap::iterator iter = fontMapping.Begin(); iter != fontMapping.End(); iter++) {
runs.add(iter->second, iter->first);
}
@@ -432,7 +432,7 @@ int FallbackParagraphLayout::FallbackLine::GetLeading() const
*/
int FallbackParagraphLayout::FallbackLine::GetWidth() const
{
- if (this->Length() == 0) return 0;
+ if (this->size() == 0) return 0;
/*
* The last X position of a run contains is the end of that run.
@@ -449,7 +449,7 @@ int FallbackParagraphLayout::FallbackLine::GetWidth() const
*/
int FallbackParagraphLayout::FallbackLine::CountRuns() const
{
- return this->Length();
+ return this->size();
}
/**
@@ -572,7 +572,7 @@ const ParagraphLayouter::Line *FallbackParagraphLayout::NextLine(int max_width)
this->buffer++;
}
- if (l->Length() == 0 || last_char - begin != 0) {
+ if (l->size() == 0 || last_char - begin != 0) {
int w = l->GetWidth();
*l->Append() = new FallbackVisualRun(iter->second, begin, last_char - begin, w);
}
diff --git a/src/graph_gui.cpp b/src/graph_gui.cpp
index a53bef906..1acf7728c 100644
--- a/src/graph_gui.cpp
+++ b/src/graph_gui.cpp
@@ -1183,7 +1183,7 @@ public:
uint text_left = rtl ? r.left + WD_FRAMERECT_LEFT : r.right - WD_FRAMERECT_LEFT - this->text_width;
uint text_right = rtl ? r.left + WD_FRAMERECT_LEFT + this->text_width : r.right - WD_FRAMERECT_LEFT;
- for (uint i = 0; i != this->companies.Length(); i++) {
+ for (uint i = 0; i != this->companies.size(); i++) {
const Company *c = this->companies[i];
DrawString(ordinal_left, ordinal_right, y, i + STR_ORDINAL_NUMBER_1ST, i == 0 ? TC_WHITE : TC_YELLOW);
diff --git a/src/group_gui.cpp b/src/group_gui.cpp
index 3a5aa0eea..d64f9c51b 100644
--- a/src/group_gui.cpp
+++ b/src/group_gui.cpp
@@ -460,8 +460,8 @@ public:
if (IsDefaultGroupID(this->vli.index) || IsAllGroupID(this->vli.index)) {
SetDParam(0, STR_COMPANY_NAME);
SetDParam(1, this->vli.company);
- SetDParam(2, this->vehicles.Length());
- SetDParam(3, this->vehicles.Length());
+ SetDParam(2, this->vehicles.size());
+ SetDParam(3, this->vehicles.size());
} else {
const Group *g = Group::Get(this->vli.index);
@@ -483,17 +483,17 @@ public:
this->BuildGroupList(this->owner);
- this->group_sb->SetCount(this->groups.Length());
- this->vscroll->SetCount(this->vehicles.Length());
+ this->group_sb->SetCount(this->groups.size());
+ this->vscroll->SetCount(this->vehicles.size());
/* The drop down menu is out, *but* it may not be used, retract it. */
- if (this->vehicles.Length() == 0 && this->IsWidgetLowered(WID_GL_MANAGE_VEHICLES_DROPDOWN)) {
+ if (this->vehicles.size() == 0 && this->IsWidgetLowered(WID_GL_MANAGE_VEHICLES_DROPDOWN)) {
this->RaiseWidget(WID_GL_MANAGE_VEHICLES_DROPDOWN);
HideDropDownMenu(this);
}
/* Disable all lists management button when the list is empty */
- this->SetWidgetsDisabledState(this->vehicles.Length() == 0 || _local_company != this->vli.company,
+ this->SetWidgetsDisabledState(this->vehicles.size() == 0 || _local_company != this->vli.company,
WID_GL_STOP_ALL,
WID_GL_START_ALL,
WID_GL_MANAGE_VEHICLES_DROPDOWN,
@@ -544,7 +544,7 @@ public:
Money this_year = 0;
Money last_year = 0;
uint32 occupancy = 0;
- uint32 vehicle_count = this->vehicles.Length();
+ uint32 vehicle_count = this->vehicles.size();
for (uint i = 0; i < vehicle_count; i++) {
const Vehicle *v = this->vehicles[i];
@@ -580,7 +580,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.Length());
+ int max = min(this->group_sb->GetPosition() + this->group_sb->GetCapacity(), this->groups.size());
for (int i = this->group_sb->GetPosition(); i < max; ++i) {
const Group *g = this->groups[i];
@@ -590,7 +590,7 @@ public:
y1 += this->tiny_step_height;
}
- if ((uint)this->group_sb->GetPosition() + this->group_sb->GetCapacity() > this->groups.Length()) {
+ if ((uint)this->group_sb->GetPosition() + this->group_sb->GetCapacity() > this->groups.size()) {
DrawGroupInfo(y1, r.left, r.right, NEW_GROUP);
}
break;
@@ -604,7 +604,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.Length());
+ uint max = min(this->vscroll->GetPosition() + this->vscroll->GetCapacity(), 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) {
@@ -658,7 +658,7 @@ public:
case WID_GL_LIST_GROUP: { // Matrix Group
uint id_g = this->group_sb->GetScrolledRowFromWidget(pt.y, this, WID_GL_LIST_GROUP, 0, this->tiny_step_height);
- if (id_g >= this->groups.Length()) return;
+ if (id_g >= this->groups.size()) return;
this->group_sel = this->vli.index = this->groups[id_g]->index;
@@ -671,7 +671,7 @@ public:
case WID_GL_LIST_VEHICLE: { // Matrix Vehicle
uint id_v = this->vscroll->GetScrolledRowFromWidget(pt.y, this, WID_GL_LIST_VEHICLE);
- if (id_v >= this->vehicles.Length()) return; // click out of list bound
+ if (id_v >= this->vehicles.size()) return; // click out of list bound
const Vehicle *v = this->vehicles[id_v];
if (VehicleClicked(v)) break;
@@ -749,7 +749,7 @@ public:
case WID_GL_LIST_GROUP: { // Matrix group
uint id_g = this->group_sb->GetScrolledRowFromWidget(pt.y, this, WID_GL_LIST_GROUP, 0, this->tiny_step_height);
- GroupID new_g = id_g >= this->groups.Length() ? INVALID_GROUP : this->groups[id_g]->index;
+ GroupID new_g = id_g >= this->groups.size() ? INVALID_GROUP : this->groups[id_g]->index;
if (this->group_sel != new_g && g->parent != new_g) {
DoCommandP(0, this->group_sel | (1 << 16), new_g, CMD_ALTER_GROUP | CMD_MSG(STR_ERROR_GROUP_CAN_T_SET_PARENT));
@@ -782,7 +782,7 @@ public:
this->SetDirty();
uint id_g = this->group_sb->GetScrolledRowFromWidget(pt.y, this, WID_GL_LIST_GROUP, 0, this->tiny_step_height);
- GroupID new_g = id_g >= this->groups.Length() ? NEW_GROUP : this->groups[id_g]->index;
+ GroupID new_g = id_g >= this->groups.size() ? NEW_GROUP : this->groups[id_g]->index;
DoCommandP(0, new_g, vindex | (_ctrl_pressed ? 1 << 31 : 0), CMD_ADD_VEHICLE_GROUP | CMD_MSG(STR_ERROR_GROUP_CAN_T_ADD_VEHICLE), new_g == NEW_GROUP ? CcAddVehicleNewGroup : NULL);
break;
@@ -795,7 +795,7 @@ public:
this->SetDirty();
uint id_v = this->vscroll->GetScrolledRowFromWidget(pt.y, this, WID_GL_LIST_VEHICLE);
- if (id_v >= this->vehicles.Length()) return; // click out of list bound
+ if (id_v >= this->vehicles.size()) return; // click out of list bound
const Vehicle *v = this->vehicles[id_v];
if (!VehicleClicked(v) && vindex == v->index) {
@@ -834,7 +834,7 @@ public:
break;
case WID_GL_MANAGE_VEHICLES_DROPDOWN:
- assert(this->vehicles.Length() != 0);
+ assert(this->vehicles.size() != 0);
switch (index) {
case ADI_REPLACE: // Replace window
@@ -895,7 +895,7 @@ public:
case WID_GL_LIST_GROUP: { // ... the list of custom groups.
uint id_g = this->group_sb->GetScrolledRowFromWidget(pt.y, this, WID_GL_LIST_GROUP, 0, this->tiny_step_height);
- new_group_over = id_g >= this->groups.Length() ? NEW_GROUP : this->groups[id_g]->index;
+ new_group_over = id_g >= this->groups.size() ? NEW_GROUP : this->groups[id_g]->index;
break;
}
}
diff --git a/src/hotkeys.cpp b/src/hotkeys.cpp
index c88d4499a..9411887ea 100644
--- a/src/hotkeys.cpp
+++ b/src/hotkeys.cpp
@@ -203,7 +203,7 @@ const char *SaveKeycodes(const Hotkey *hotkey)
{
static char buf[128];
buf[0] = '\0';
- for (uint i = 0; i < hotkey->keycodes.Length(); i++) {
+ for (uint i = 0; i < hotkey->keycodes.size(); i++) {
const char *str = KeycodeToString(hotkey->keycodes[i]);
if (i > 0) strecat(buf, ",", lastof(buf));
strecat(buf, str, lastof(buf));
diff --git a/src/industry_gui.cpp b/src/industry_gui.cpp
index eb6018973..32c62bfa3 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.Length()); // Update scrollbar as well.
+ this->vscroll->SetCount(this->industries.size()); // Update scrollbar as well.
}
if (!this->industries.Sort()) return;
@@ -1372,11 +1372,11 @@ public:
case WID_ID_INDUSTRY_LIST: {
int n = 0;
int y = r.top + WD_FRAMERECT_TOP;
- if (this->industries.Length() == 0) {
+ if (this->industries.size() == 0) {
DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, y, STR_INDUSTRY_DIRECTORY_NONE);
break;
}
- for (uint i = this->vscroll->GetPosition(); i < this->industries.Length(); i++) {
+ for (uint i = this->vscroll->GetPosition(); i < this->industries.size(); i++) {
DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, y, this->GetIndustryString(this->industries[i]));
y += this->resize.step_height;
@@ -1411,7 +1411,7 @@ public:
case WID_ID_INDUSTRY_LIST: {
Dimension d = GetStringBoundingBox(STR_INDUSTRY_DIRECTORY_NONE);
- for (uint i = 0; i < this->industries.Length(); i++) {
+ for (uint i = 0; i < this->industries.size(); i++) {
d = maxdim(d, GetStringBoundingBox(this->GetIndustryString(this->industries[i])));
}
resize->height = d.height;
@@ -1439,7 +1439,7 @@ public:
case WID_ID_INDUSTRY_LIST: {
uint p = this->vscroll->GetScrolledRowFromWidget(pt.y, this, WID_ID_INDUSTRY_LIST, WD_FRAMERECT_TOP);
- if (p < this->industries.Length()) {
+ if (p < this->industries.size()) {
if (_ctrl_pressed) {
ShowExtraViewPortWindow(this->industries[p]->location.tile);
} else {
@@ -2589,7 +2589,7 @@ struct IndustryCargoesWindow : public Window {
const NWidgetBase *nwp = this->GetWidget<NWidgetBase>(WID_IC_PANEL);
int vpos = -this->vscroll->GetPosition() * nwp->resize_y;
- for (uint i = 0; i < this->fields.Length(); i++) {
+ for (uint i = 0; i < this->fields.size(); i++) {
int row_height = (i == 0) ? CargoesField::small_height : CargoesField::normal_height;
if (vpos + row_height >= 0) {
int xpos = left_pos;
@@ -2631,7 +2631,7 @@ struct IndustryCargoesWindow : public Window {
if (pt.y < vpos) return false;
int row = (pt.y - vpos) / CargoesField::normal_height; // row is relative to row 1.
- if (row + 1 >= (int)this->fields.Length()) return false;
+ if (row + 1 >= (int)this->fields.size()) return false;
vpos = pt.y - vpos - row * CargoesField::normal_height; // Position in the row + 1 field
row++; // rebase row to match index of this->fields.
@@ -2710,7 +2710,7 @@ struct IndustryCargoesWindow : public Window {
FOR_ALL_SORTED_STANDARD_CARGOSPECS(cs) {
*lst->Append() = new DropDownListStringItem(cs->name, cs->Index(), false);
}
- if (lst->Length() == 0) {
+ if (lst->size() == 0) {
delete lst;
break;
}
@@ -2727,7 +2727,7 @@ struct IndustryCargoesWindow : public Window {
if (!indsp->enabled) continue;
*lst->Append() = new DropDownListStringItem(indsp->name, ind, false);
}
- if (lst->Length() == 0) {
+ if (lst->size() == 0) {
delete lst;
break;
}
diff --git a/src/linkgraph/linkgraph.h b/src/linkgraph/linkgraph.h
index 799f22c78..1900c0b1f 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.Length(); }
+ inline uint Size() const { return this->nodes.size(); }
/**
* Get date of last compression.
diff --git a/src/music/dmusic.cpp b/src/music/dmusic.cpp
index fece709fd..a03a6ec57 100644
--- a/src/music/dmusic.cpp
+++ b/src/music/dmusic.cpp
@@ -686,7 +686,7 @@ static void MidiThreadProc(void *)
size_t preload_bytes = 0;
for (size_t bl = 0; bl < current_file.blocks.size(); bl++) {
MidiFile::DataBlock &block = current_file.blocks[bl];
- preload_bytes += block.data.Length();
+ preload_bytes += block.data.size();
if (block.ticktime >= current_segment.start) {
if (current_segment.loop) {
DEBUG(driver, 2, "DMusic: timer: loop from block %d (ticktime %d, realtime %.3f, bytes %d)", (int)bl, (int)block.ticktime, ((int)block.realtime) / 1000.0, (int)preload_bytes);
@@ -752,7 +752,7 @@ static void MidiThreadProc(void *)
DEBUG(driver, 9, "DMusic thread: Streaming block " PRINTF_SIZE " (cur=" OTTD_PRINTF64 ", block=" OTTD_PRINTF64 ")", current_block, (long long)(current_time / MS_TO_REFTIME), (long long)(block_time / MS_TO_REFTIME));
byte *data = block.data.Begin();
- size_t remaining = block.data.Length();
+ size_t remaining = block.data.size();
byte last_status = 0;
while (remaining > 0) {
/* MidiFile ought to have converted everything out of running status,
diff --git a/src/music/midifile.cpp b/src/music/midifile.cpp
index 91f83c529..fb3c187c0 100644
--- a/src/music/midifile.cpp
+++ b/src/music/midifile.cpp
@@ -330,14 +330,14 @@ static bool FixupMidiData(MidiFile &target)
uint32 last_ticktime = 0;
for (size_t i = 0; i < target.blocks.size(); i++) {
MidiFile::DataBlock &block = target.blocks[i];
- if (block.data.Length() == 0) {
+ if (block.data.size() == 0) {
continue;
} else if (block.ticktime > last_ticktime || merged_blocks.size() == 0) {
merged_blocks.push_back(block);
last_ticktime = block.ticktime;
} else {
- byte *datadest = merged_blocks.back().data.Append(block.data.Length());
- memcpy(datadest, block.data.Begin(), block.data.Length());
+ byte *datadest = merged_blocks.back().data.Append(block.data.size());
+ memcpy(datadest, block.data.Begin(), block.data.size());
}
}
std::swap(merged_blocks, target.blocks);
diff --git a/src/music/win32_m.cpp b/src/music/win32_m.cpp
index a32318db1..6d88af4a3 100644
--- a/src/music/win32_m.cpp
+++ b/src/music/win32_m.cpp
@@ -187,7 +187,7 @@ void CALLBACK TimerCallback(UINT uTimerID, UINT, DWORD_PTR dwUser, DWORD_PTR, DW
uint 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.Length();
+ preload_bytes += block.data.size();
if (block.ticktime >= _midi.current_segment.start) {
if (_midi.current_segment.loop) {
DEBUG(driver, 2, "Win32-MIDI: timer: loop from block %d (ticktime %d, realtime %.3f, bytes %d)", (int)bl, (int)block.ticktime, ((int)block.realtime)/1000.0, (int)preload_bytes);
@@ -230,7 +230,7 @@ void CALLBACK TimerCallback(UINT uTimerID, UINT, DWORD_PTR dwUser, DWORD_PTR, DW
}
byte *data = block.data.Begin();
- size_t remaining = block.data.Length();
+ size_t remaining = block.data.size();
byte last_status = 0;
while (remaining > 0) {
/* MidiFile ought to have converted everything out of running status,
diff --git a/src/network/core/tcp_http.cpp b/src/network/core/tcp_http.cpp
index 3a40e3eec..d2ab0638c 100644
--- a/src/network/core/tcp_http.cpp
+++ b/src/network/core/tcp_http.cpp
@@ -297,7 +297,7 @@ int NetworkHTTPSocketHandler::Receive()
/* static */ void NetworkHTTPSocketHandler::HTTPReceive()
{
/* No connections, just bail out. */
- if (_http_connections.Length() == 0) return;
+ if (_http_connections.size() == 0) return;
fd_set read_fd;
struct timeval tv;
diff --git a/src/network/core/tcp_listen.h b/src/network/core/tcp_listen.h
index b9f987190..55594070b 100644
--- a/src/network/core/tcp_listen.h
+++ b/src/network/core/tcp_listen.h
@@ -140,7 +140,7 @@ public:
*/
static bool Listen(uint16 port)
{
- assert(sockets.Length() == 0);
+ assert(sockets.size() == 0);
NetworkAddressList addresses;
GetBindAddresses(&addresses, port);
@@ -149,7 +149,7 @@ public:
address->Listen(SOCK_STREAM, &sockets);
}
- if (sockets.Length() == 0) {
+ if (sockets.size() == 0) {
DEBUG(net, 0, "[server] could not start network: could not create listening socket");
NetworkError(STR_NETWORK_ERROR_SERVER_START);
return false;
diff --git a/src/network/core/udp.cpp b/src/network/core/udp.cpp
index 83c14d2b0..db655c0cf 100644
--- a/src/network/core/udp.cpp
+++ b/src/network/core/udp.cpp
@@ -51,7 +51,7 @@ bool NetworkUDPSocketHandler::Listen()
addr->Listen(SOCK_DGRAM, &this->sockets);
}
- return this->sockets.Length() != 0;
+ return this->sockets.size() != 0;
}
/**
@@ -80,7 +80,7 @@ NetworkRecvStatus NetworkUDPSocketHandler::CloseConnection(bool error)
*/
void NetworkUDPSocketHandler::SendPacket(Packet *p, NetworkAddress *recv, bool all, bool broadcast)
{
- if (this->sockets.Length() == 0) this->Listen();
+ if (this->sockets.size() == 0) this->Listen();
for (SocketList::iterator s = this->sockets.Begin(); s != this->sockets.End(); s++) {
/* Make a local copy because if we resolve it we cannot
diff --git a/src/network/network.cpp b/src/network/network.cpp
index e437f4df0..3780258bd 100644
--- a/src/network/network.cpp
+++ b/src/network/network.cpp
@@ -637,7 +637,7 @@ void GetBindAddresses(NetworkAddressList *addresses, uint16 port)
}
/* No address, so bind to everything. */
- if (addresses->Length() == 0) {
+ if (addresses->size() == 0) {
*addresses->Append() = NetworkAddress("", port);
}
}
diff --git a/src/network/network_content.cpp b/src/network/network_content.cpp
index 0ef060628..d36aec6ba 100644
--- a/src/network/network_content.cpp
+++ b/src/network/network_content.cpp
@@ -246,12 +246,12 @@ void ClientNetworkContentSocketHandler::RequestContentList(ContentVector *cv, bo
this->Connect();
- assert(cv->Length() < 255);
- assert(cv->Length() < (SEND_MTU - sizeof(PacketSize) - sizeof(byte) - sizeof(uint8)) /
+ assert(cv->size() < 255);
+ assert(cv->size() < (SEND_MTU - sizeof(PacketSize) - sizeof(byte) - sizeof(uint8)) /
(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->Length());
+ p->Send_uint8(cv->size());
for (ContentIterator iter = cv->Begin(); iter != cv->End(); iter++) {
const ContentInfo *ci = *iter;
@@ -304,7 +304,7 @@ void ClientNetworkContentSocketHandler::DownloadSelectedContent(uint &files, uin
bytes += ci->filesize;
}
- files = content.Length();
+ files = content.size();
/* If there's nothing to download, do nothing. */
if (files == 0) return;
@@ -322,7 +322,7 @@ void ClientNetworkContentSocketHandler::DownloadSelectedContent(uint &files, uin
*/
void ClientNetworkContentSocketHandler::DownloadSelectedContentHTTP(const ContentIDList &content)
{
- uint count = content.Length();
+ uint count = content.size();
/* Allocate memory for the whole request.
* Requests are "id\nid\n..." (as strings), so assume the maximum ID,
@@ -350,7 +350,7 @@ void ClientNetworkContentSocketHandler::DownloadSelectedContentHTTP(const Conten
*/
void ClientNetworkContentSocketHandler::DownloadSelectedContentFallback(const ContentIDList &content)
{
- uint count = content.Length();
+ uint count = content.size();
const ContentID *content_ids = content.Begin();
this->Connect();
@@ -607,7 +607,7 @@ void ClientNetworkContentSocketHandler::OnReceiveData(const char *data, size_t l
this->AfterDownload();
}
- if ((uint)this->http_response_index >= this->http_response.Length()) {
+ if ((uint)this->http_response_index >= this->http_response.size()) {
/* It's not a real failure, but if there's
* nothing more to download it helps with
* cleaning up the stuff we allocated. */
@@ -653,7 +653,7 @@ void ClientNetworkContentSocketHandler::OnReceiveData(const char *data, size_t l
str = p + 1;
/* Is it a fallback URL? If so, just continue with the next one. */
if (strncmp(str, "ottd", 4) == 0) {
- if ((uint)this->http_response_index >= this->http_response.Length()) {
+ if ((uint)this->http_response_index >= this->http_response.size()) {
/* Have we gone through all lines? */
this->OnFailure();
return;
@@ -925,7 +925,7 @@ void ClientNetworkContentSocketHandler::ReverseLookupTreeDependency(ConstContent
* we are including stuff into the vector and as such the vector's data
* store can be reallocated (and thus move), which means out iterating
* pointer gets invalid. So fall back to the indices. */
- for (uint i = 0; i < tree.Length(); i++) {
+ for (uint i = 0; i < tree.size(); i++) {
ConstContentVector parents;
this->ReverseLookupDependency(parents, tree[i]);
diff --git a/src/network/network_content.h b/src/network/network_content.h
index 7a96a73c0..0d30de857 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.Length(); }
+ uint Length() const { return this->infos.size(); }
/** Get the begin of the content inf iterator. */
ConstContentIterator Begin() const { return this->infos.Begin(); }
/** 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 cb534d796..51215935c 100644
--- a/src/network/network_content_gui.cpp
+++ b/src/network/network_content_gui.cpp
@@ -401,7 +401,7 @@ class NetworkContentListWindow : public Window, ContentCallback {
this->content.RebuildDone();
this->SortContentList();
- this->vscroll->SetCount(this->content.Length()); // Update the scrollbar
+ this->vscroll->SetCount(this->content.size()); // Update the scrollbar
this->ScrollToSelected();
}
@@ -791,7 +791,7 @@ public:
switch (widget) {
case WID_NCL_MATRIX: {
uint id_v = this->vscroll->GetScrolledRowFromWidget(pt.y, this, WID_NCL_MATRIX);
- if (id_v >= this->content.Length()) return; // click out of bounds
+ if (id_v >= this->content.size()) return; // click out of bounds
this->selected = *this->content.Get(id_v);
this->list_pos = id_v;
@@ -815,7 +815,7 @@ public:
case WID_NCL_NAME:
if (this->content.SortType() == widget - WID_NCL_CHECKBOX) {
this->content.ToggleSortOrder();
- if (this->content.Length() > 0) this->list_pos = this->content.Length() - this->list_pos - 1;
+ if (this->content.size() > 0) this->list_pos = this->content.size() - this->list_pos - 1;
} else {
this->content.SetSortType(widget - WID_NCL_CHECKBOX);
this->content.ForceResort();
@@ -874,7 +874,7 @@ public:
break;
case WKC_DOWN:
/* scroll down by one */
- if (this->list_pos < (int)this->content.Length() - 1) this->list_pos++;
+ if (this->list_pos < (int)this->content.size() - 1) this->list_pos++;
break;
case WKC_PAGEUP:
/* scroll up a page */
@@ -882,7 +882,7 @@ public:
break;
case WKC_PAGEDOWN:
/* scroll down a page */
- this->list_pos = min(this->list_pos + this->vscroll->GetCapacity(), (int)this->content.Length() - 1);
+ this->list_pos = min(this->list_pos + this->vscroll->GetCapacity(), (int)this->content.size() - 1);
break;
case WKC_HOME:
/* jump to beginning */
@@ -890,7 +890,7 @@ public:
break;
case WKC_END:
/* jump to end */
- this->list_pos = this->content.Length() - 1;
+ this->list_pos = this->content.size() - 1;
break;
case WKC_SPACE:
@@ -914,7 +914,7 @@ public:
return ES_NOT_HANDLED;
}
- if (this->content.Length() == 0) {
+ if (this->content.size() == 0) {
this->list_pos = 0; // above stuff may result in "-1".
if (this->UpdateFilterState()) {
this->content.ForceRebuild();
diff --git a/src/network/network_gui.cpp b/src/network/network_gui.cpp
index 1451e7154..e3c4555bf 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.Length());
+ this->vscroll->SetCount(this->servers.size());
/* Sort the list of network games as requested. */
this->servers.Sort();
@@ -354,7 +354,7 @@ protected:
void UpdateListPos()
{
this->list_pos = SLP_INVALID;
- for (uint i = 0; i != this->servers.Length(); i++) {
+ for (uint i = 0; i != this->servers.size(); i++) {
if (this->servers[i] == this->server) {
this->list_pos = i;
break;
@@ -564,7 +564,7 @@ public:
case WID_NG_MATRIX: {
uint16 y = r.top;
- const int max = min(this->vscroll->GetPosition() + this->vscroll->GetCapacity(), (int)this->servers.Length());
+ const int max = min(this->vscroll->GetPosition() + this->vscroll->GetCapacity(), (int)this->servers.size());
for (int i = this->vscroll->GetPosition(); i < max; ++i) {
const NetworkGameList *ngl = this->servers[i];
@@ -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.Length() - this->list_pos - 1;
+ if (this->list_pos != SLP_INVALID) this->list_pos = this->servers.size() - this->list_pos - 1;
} else {
this->servers.SetSortType(widget - WID_NG_NAME);
this->servers.ForceResort();
@@ -722,7 +722,7 @@ public:
case WID_NG_MATRIX: { // Show available network games
uint id_v = this->vscroll->GetScrolledRowFromWidget(pt.y, this, WID_NG_MATRIX);
- this->server = (id_v < this->servers.Length()) ? this->servers[id_v] : NULL;
+ this->server = (id_v < this->servers.size()) ? this->servers[id_v] : NULL;
this->list_pos = (server == NULL) ? SLP_INVALID : id_v;
this->SetDirty();
@@ -819,7 +819,7 @@ public:
/* handle up, down, pageup, pagedown, home and end */
if (keycode == WKC_UP || keycode == WKC_DOWN || keycode == WKC_PAGEUP || keycode == WKC_PAGEDOWN || keycode == WKC_HOME || keycode == WKC_END) {
- if (this->servers.Length() == 0) return ES_HANDLED;
+ if (this->servers.size() == 0) return ES_HANDLED;
switch (keycode) {
case WKC_UP:
/* scroll up by one */
@@ -829,7 +829,7 @@ public:
case WKC_DOWN:
/* scroll down by one */
if (this->list_pos == SLP_INVALID) return ES_HANDLED;
- if (this->list_pos < this->servers.Length() - 1) this->list_pos++;
+ if (this->list_pos < this->servers.size() - 1) this->list_pos++;
break;
case WKC_PAGEUP:
/* scroll up a page */
@@ -839,7 +839,7 @@ public:
case WKC_PAGEDOWN:
/* scroll down a page */
if (this->list_pos == SLP_INVALID) return ES_HANDLED;
- this->list_pos = min(this->list_pos + this->vscroll->GetCapacity(), (int)this->servers.Length() - 1);
+ this->list_pos = min(this->list_pos + this->vscroll->GetCapacity(), (int)this->servers.size() - 1);
break;
case WKC_HOME:
/* jump to beginning */
@@ -847,7 +847,7 @@ public:
break;
case WKC_END:
/* jump to end */
- this->list_pos = this->servers.Length() - 1;
+ this->list_pos = this->servers.size() - 1;
break;
default: NOT_REACHED();
}
@@ -1789,7 +1789,7 @@ struct NetworkClientListPopupWindow : Window {
d = maxdim(GetStringBoundingBox(action->name), d);
}
- d.height *= this->actions.Length();
+ d.height *= this->actions.size();
d.width += WD_FRAMERECT_LEFT + WD_FRAMERECT_RIGHT;
d.height += WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM;
*size = d;
@@ -1819,12 +1819,12 @@ struct NetworkClientListPopupWindow : Window {
uint index = (_cursor.pos.y - this->top - WD_FRAMERECT_TOP) / FONT_HEIGHT_NORMAL;
if (_left_button_down) {
- if (index == this->sel_index || index >= this->actions.Length()) return;
+ if (index == this->sel_index || index >= this->actions.size()) return;
this->sel_index = index;
this->SetDirty();
} else {
- if (index < this->actions.Length() && _cursor.pos.y >= this->top) {
+ if (index < this->actions.size() && _cursor.pos.y >= this->top) {
const NetworkClientInfo *ci = NetworkClientInfo::GetByClientID(this->client_id);
if (ci != NULL) this->actions[index].proc(ci);
}
diff --git a/src/newgrf.cpp b/src/newgrf.cpp
index e26577353..f80e79f7d 100644
--- a/src/newgrf.cpp
+++ b/src/newgrf.cpp
@@ -658,7 +658,7 @@ static Engine *GetNewEngine(const GRFFile *file, VehicleType type, uint16 intern
e->grf_prop.grffile = file;
/* Reserve the engine slot */
- assert(_engine_mngr.Length() == e->index);
+ assert(_engine_mngr.size() == e->index);
EngineIDMapping *eid = _engine_mngr.Append();
eid->type = type;
eid->grfid = scope_grfid; // Note: this is INVALID_GRFID if dynamic_engines is disabled, so no reservation
@@ -1058,7 +1058,7 @@ static ChangeInfoResult RailVehicleChangeInfo(uint engine, int numinfo, int prop
case 0x05: { // Track type
uint8 tracktype = buf->ReadByte();
- if (tracktype < _cur.grffile->railtype_list.Length()) {
+ if (tracktype < _cur.grffile->railtype_list.size()) {
_gted[e->index].railtypelabel = _cur.grffile->railtype_list[tracktype];
break;
}
@@ -1200,7 +1200,7 @@ static ChangeInfoResult RailVehicleChangeInfo(uint engine, int numinfo, int prop
break;
}
- if (_cur.grffile->railtype_list.Length() == 0) {
+ if (_cur.grffile->railtype_list.size() == 0) {
/* Use traction type to select between normal and electrified
* rail only when no translation list is in place. */
if (_gted[e->index].railtypelabel == RAILTYPE_RAIL_LABEL && engclass >= EC_ELECTRIC) _gted[e->index].railtypelabel = RAILTYPE_ELECTRIC_LABEL;
@@ -4799,7 +4799,7 @@ static void NewSpriteGroup(ByteReader *buf)
DeterministicSpriteGroupAdjust *adjust = adjusts.Append();
/* The first var adjust doesn't have an operation specified, so we set it to add. */
- adjust->operation = adjusts.Length() == 1 ? DSGA_OP_ADD : (DeterministicSpriteGroupAdjustOperation)buf->ReadByte();
+ adjust->operation = adjusts.size() == 1 ? DSGA_OP_ADD : (DeterministicSpriteGroupAdjustOperation)buf->ReadByte();
adjust->variable = buf->ReadByte();
if (adjust->variable == 0x7E) {
/* Link subroutine group */
@@ -4824,7 +4824,7 @@ static void NewSpriteGroup(ByteReader *buf)
/* Continue reading var adjusts while bit 5 is set. */
} while (HasBit(varadjust, 5));
- group->num_adjusts = adjusts.Length();
+ group->num_adjusts = adjusts.size();
group->adjusts = MallocT<DeterministicSpriteGroupAdjust>(group->num_adjusts);
MemCpyT(group->adjusts, adjusts.Begin(), group->num_adjusts);
@@ -5085,7 +5085,7 @@ static CargoID TranslateCargo(uint8 feature, uint8 ctype)
if (feature == GSF_STATIONS && ctype == 0xFE) return CT_DEFAULT_NA;
if (ctype == 0xFF) return CT_PURCHASE;
- if (_cur.grffile->cargo_list.Length() == 0) {
+ if (_cur.grffile->cargo_list.size() == 0) {
/* No cargo table, so use bitnum values */
if (ctype >= 32) {
grfmsg(1, "TranslateCargo: Cargo bitnum %d out of range (max 31), skipping.", ctype);
@@ -5105,8 +5105,8 @@ static CargoID TranslateCargo(uint8 feature, uint8 ctype)
}
/* Check if the cargo type is out of bounds of the cargo translation table */
- if (ctype >= _cur.grffile->cargo_list.Length()) {
- grfmsg(1, "TranslateCargo: Cargo type %d out of range (max %d), skipping.", ctype, _cur.grffile->cargo_list.Length() - 1);
+ if (ctype >= _cur.grffile->cargo_list.size()) {
+ grfmsg(1, "TranslateCargo: Cargo type %d out of range (max %d), skipping.", ctype, (unsigned int)_cur.grffile->cargo_list.size() - 1);
return CT_INVALID;
}
@@ -7850,8 +7850,8 @@ static bool HandleParameterInfo(ByteReader *buf)
continue;
}
- if (id >= _cur.grfconfig->param_info.Length()) {
- uint num_to_add = id - _cur.grfconfig->param_info.Length() + 1;
+ if (id >= _cur.grfconfig->param_info.size()) {
+ uint num_to_add = id - _cur.grfconfig->param_info.size() + 1;
GRFParameterInfo **newdata = _cur.grfconfig->param_info.Append(num_to_add);
MemSetT<GRFParameterInfo *>(newdata, 0, num_to_add);
}
@@ -8380,7 +8380,7 @@ static void BuildCargoTranslationMap()
const CargoSpec *cs = CargoSpec::Get(c);
if (!cs->IsValid()) continue;
- if (_cur.grffile->cargo_list.Length() == 0) {
+ if (_cur.grffile->cargo_list.size() == 0) {
/* Default translation table, so just a straight mapping to bitnum */
_cur.grffile->cargo_map[c] = cs->bitnum;
} else {
@@ -8560,7 +8560,7 @@ static void CalculateRefitMasks()
{
const GRFFile *file = _gted[engine].defaultcargo_grf;
if (file == NULL) file = e->GetGRF();
- if (file != NULL && file->grf_version >= 8 && file->cargo_list.Length() != 0) {
+ if (file != NULL && file->grf_version >= 8 && file->cargo_list.size() != 0) {
cargo_map_for_first_refittable = file->cargo_map;
}
}
@@ -9216,7 +9216,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.Length();
+ int num_grfs = _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_cargo.cpp b/src/newgrf_cargo.cpp
index 97db4855e..58d4102d3 100644
--- a/src/newgrf_cargo.cpp
+++ b/src/newgrf_cargo.cpp
@@ -82,10 +82,10 @@ CargoID GetCargoTranslation(uint8 cargo, const GRFFile *grffile, bool usebit)
/* Other cases use (possibly translated) cargobits */
- if (grffile->cargo_list.Length() > 0) {
+ if (grffile->cargo_list.size() > 0) {
/* ...and the cargo is in bounds, then get the cargo ID for
* the label */
- if (cargo < grffile->cargo_list.Length()) return GetCargoIDByLabel(grffile->cargo_list[cargo]);
+ if (cargo < grffile->cargo_list.size()) return GetCargoIDByLabel(grffile->cargo_list[cargo]);
} else {
/* Else the cargo value is a 'climate independent' 'bitnum' */
return GetCargoIDByBitnum(cargo);
diff --git a/src/newgrf_config.cpp b/src/newgrf_config.cpp
index d21d767cd..fa84c947a 100644
--- a/src/newgrf_config.cpp
+++ b/src/newgrf_config.cpp
@@ -83,7 +83,7 @@ GRFConfig::GRFConfig(const GRFConfig &config) :
this->info->AddRef();
this->url->AddRef();
if (config.error != NULL) this->error = new GRFError(*config.error);
- for (uint i = 0; i < config.param_info.Length(); i++) {
+ for (uint i = 0; i < config.param_info.size(); i++) {
if (config.param_info[i] == NULL) {
*this->param_info.Append() = NULL;
} else {
@@ -104,7 +104,7 @@ GRFConfig::~GRFConfig()
this->info->Release();
this->url->Release();
- for (uint i = 0; i < this->param_info.Length(); i++) delete this->param_info[i];
+ for (uint i = 0; i < this->param_info.size(); i++) delete this->param_info[i];
}
/**
@@ -155,7 +155,7 @@ void GRFConfig::SetParameterDefaults()
if (!this->has_param_defaults) return;
- for (uint i = 0; i < this->param_info.Length(); i++) {
+ for (uint i = 0; i < this->param_info.size(); i++) {
if (this->param_info[i] == NULL) continue;
this->param_info[i]->SetValue(this, this->param_info[i]->def_value);
}
@@ -261,7 +261,7 @@ GRFParameterInfo::GRFParameterInfo(GRFParameterInfo &info) :
num_bit(info.num_bit),
complete_labels(info.complete_labels)
{
- for (uint i = 0; i < info.value_names.Length(); i++) {
+ for (uint i = 0; i < info.value_names.size(); i++) {
SmallPair<uint32, GRFText *> *data = info.value_names.Get(i);
this->value_names.Insert(data->first, DuplicateGRFText(data->second));
}
@@ -272,7 +272,7 @@ GRFParameterInfo::~GRFParameterInfo()
{
CleanUpGRFText(this->name);
CleanUpGRFText(this->desc);
- for (uint i = 0; i < this->value_names.Length(); i++) {
+ for (uint i = 0; i < this->value_names.size(); i++) {
SmallPair<uint32, GRFText *> *data = this->value_names.Get(i);
CleanUpGRFText(data->second);
}
@@ -609,7 +609,7 @@ compatible_grf:
c->min_loadable_version = f->min_loadable_version;
c->num_valid_params = f->num_valid_params;
c->has_param_defaults = f->has_param_defaults;
- for (uint i = 0; i < f->param_info.Length(); i++) {
+ for (uint i = 0; i < f->param_info.size(); i++) {
if (f->param_info[i] == NULL) {
*c->param_info.Append() = NULL;
} else {
diff --git a/src/newgrf_debug_gui.cpp b/src/newgrf_debug_gui.cpp
index e8fc4efcc..ec1a91d7b 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;
SmallVector<SpriteID, 256> &list = _newgrf_debug_sprite_picker.sprites;
- int max = min<int>(this->vscroll->GetPosition() + this->vscroll->GetCapacity(), list.Length());
+ int max = min<int>(this->vscroll->GetPosition() + this->vscroll->GetCapacity(), list.size());
int y = r.top + WD_FRAMERECT_TOP;
for (int i = this->vscroll->GetPosition(); i < max; i++) {
@@ -940,7 +940,7 @@ struct SpriteAlignerWindow : Window {
int step_size = nwid->resize_y;
uint i = this->vscroll->GetPosition() + (pt.y - nwid->pos_y) / step_size;
- if (i < _newgrf_debug_sprite_picker.sprites.Length()) {
+ if (i < _newgrf_debug_sprite_picker.sprites.size()) {
SpriteID spr = _newgrf_debug_sprite_picker.sprites[i];
if (GetSpriteType(spr) == ST_NORMAL) this->current_sprite = spr;
}
@@ -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.Length());
+ this->vscroll->SetCount(_newgrf_debug_sprite_picker.sprites.size());
}
}
diff --git a/src/newgrf_engine.cpp b/src/newgrf_engine.cpp
index 660b7e476..60d03fcc3 100644
--- a/src/newgrf_engine.cpp
+++ b/src/newgrf_engine.cpp
@@ -1233,7 +1233,7 @@ void CommitVehicleListOrderChanges()
FOR_ALL_ENGINES(e) {
*ordering.Append() = e->index;
}
- QSortT(ordering.Begin(), ordering.Length(), EnginePreSort);
+ QSortT(ordering.Begin(), ordering.size(), EnginePreSort);
/* Apply Insertion-Sort operations */
const ListOrderChange *end = _list_order_changes.End();
diff --git a/src/newgrf_gui.cpp b/src/newgrf_gui.cpp
index 4235d3133..fb712700c 100644
--- a/src/newgrf_gui.cpp
+++ b/src/newgrf_gui.cpp
@@ -166,7 +166,7 @@ struct NewGRFParametersWindow : public Window {
clicked_row(UINT_MAX),
editable(editable)
{
- this->action14present = (c->num_valid_params != lengthof(c->param) || c->param_info.Length() != 0);
+ this->action14present = (c->num_valid_params != lengthof(c->param) || c->param_info.size() != 0);
this->CreateNestedTree();
this->vscroll = this->GetScrollbar(WID_NP_SCROLLBAR);
@@ -220,7 +220,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, (uint)FONT_HEIGHT_NORMAL * 4 + WD_TEXTPANEL_TOP + WD_TEXTPANEL_BOTTOM};
- for (uint i = 0; i < this->grf_config->param_info.Length(); i++) {
+ for (uint i = 0; i < this->grf_config->param_info.size(); i++) {
const GRFParameterInfo *par_info = this->grf_config->param_info[i];
if (par_info == NULL) continue;
const char *desc = GetGRFStringFromGRFText(par_info->desc);
@@ -246,7 +246,7 @@ struct NewGRFParametersWindow : public Window {
void DrawWidget(const Rect &r, int widget) const override
{
if (widget == WID_NP_DESCRIPTION) {
- const GRFParameterInfo *par_info = (this->clicked_row < this->grf_config->param_info.Length()) ? this->grf_config->param_info[this->clicked_row] : NULL;
+ const GRFParameterInfo *par_info = (this->clicked_row < this->grf_config->param_info.size()) ? this->grf_config->param_info[this->clicked_row] : NULL;
if (par_info == NULL) return;
const char *desc = GetGRFStringFromGRFText(par_info->desc);
if (desc == NULL) return;
@@ -265,7 +265,7 @@ struct NewGRFParametersWindow : public Window {
int button_y_offset = (this->line_height - SETTING_BUTTON_HEIGHT) / 2;
int text_y_offset = (this->line_height - FONT_HEIGHT_NORMAL) / 2;
for (uint i = this->vscroll->GetPosition(); this->vscroll->IsVisible(i) && i < this->vscroll->GetCount(); i++) {
- GRFParameterInfo *par_info = (i < this->grf_config->param_info.Length()) ? this->grf_config->param_info[i] : NULL;
+ GRFParameterInfo *par_info = (i < this->grf_config->param_info.size()) ? this->grf_config->param_info[i] : NULL;
if (par_info == NULL) par_info = GetDummyParameterInfo(i);
uint32 current_value = par_info->GetValue(this->grf_config);
bool selected = (i == this->clicked_row);
@@ -350,7 +350,7 @@ struct NewGRFParametersWindow : public Window {
if (_current_text_dir == TD_RTL) x = wid->current_x - 1 - x;
x -= 4;
- GRFParameterInfo *par_info = (num < this->grf_config->param_info.Length()) ? this->grf_config->param_info[num] : NULL;
+ GRFParameterInfo *par_info = (num < this->grf_config->param_info.size()) ? this->grf_config->param_info[num] : NULL;
if (par_info == NULL) par_info = GetDummyParameterInfo(num);
/* One of the arrows is clicked */
@@ -431,7 +431,7 @@ struct NewGRFParametersWindow : public Window {
{
if (StrEmpty(str)) return;
int32 value = atoi(str);
- GRFParameterInfo *par_info = ((uint)this->clicked_row < this->grf_config->param_info.Length()) ? this->grf_config->param_info[this->clicked_row] : NULL;
+ GRFParameterInfo *par_info = ((uint)this->clicked_row < this->grf_config->param_info.size()) ? this->grf_config->param_info[this->clicked_row] : NULL;
if (par_info == NULL) par_info = GetDummyParameterInfo(this->clicked_row);
uint32 val = Clamp<uint32>(value, par_info->min_value, par_info->max_value);
par_info->SetValue(this->grf_config, val);
@@ -441,7 +441,7 @@ struct NewGRFParametersWindow : public Window {
void OnDropdownSelect(int widget, int index) override
{
assert(this->clicked_dropdown);
- GRFParameterInfo *par_info = ((uint)this->clicked_row < this->grf_config->param_info.Length()) ? this->grf_config->param_info[this->clicked_row] : NULL;
+ GRFParameterInfo *par_info = ((uint)this->clicked_row < this->grf_config->param_info.size()) ? this->grf_config->param_info[this->clicked_row] : NULL;
if (par_info == NULL) par_info = GetDummyParameterInfo(this->clicked_row);
par_info->SetValue(this->grf_config, index);
this->SetDirty();
@@ -747,7 +747,7 @@ struct NewGRFWindow : public Window, NewGRFScanCallback {
case WID_NS_PRESET_LIST: {
Dimension d = GetStringBoundingBox(STR_NUM_CUSTOM);
- for (uint i = 0; i < _grf_preset_list.Length(); i++) {
+ for (uint i = 0; i < _grf_preset_list.size(); i++) {
if (_grf_preset_list[i] != NULL) {
SetDParamStr(0, _grf_preset_list[i]);
d = maxdim(d, GetStringBoundingBox(STR_JUST_RAW_STRING));
@@ -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.Length());
+ uint max_index = min(min_index + this->vscroll2->GetCapacity(), this->avails.size());
for (uint i = min_index; i < max_index; i++) {
const GRFConfig *c = this->avails[i];
@@ -929,7 +929,7 @@ struct NewGRFWindow : public Window, NewGRFScanCallback {
/* Add 'None' option for clearing list */
*list->Append() = new DropDownListStringItem(STR_NONE, -1, false);
- for (uint i = 0; i < _grf_preset_list.Length(); i++) {
+ for (uint i = 0; i < _grf_preset_list.size(); i++) {
if (_grf_preset_list[i] != NULL) {
*list->Append() = new DropDownListCharStringItem(_grf_preset_list[i], i, false);
}
@@ -1069,7 +1069,7 @@ struct NewGRFWindow : public Window, NewGRFScanCallback {
uint i = this->vscroll2->GetScrolledRowFromWidget(pt.y, this, WID_NS_AVAIL_LIST);
this->active_sel = NULL;
DeleteWindowByClass(WC_GRF_PARAMETERS);
- if (i < this->avails.Length()) {
+ if (i < this->avails.size()) {
if (this->avail_sel != this->avails[i]) DeleteWindowByClass(WC_TEXTFILE);
this->avail_sel = this->avails[i];
this->avail_pos = i;
@@ -1175,7 +1175,7 @@ struct NewGRFWindow : public Window, NewGRFScanCallback {
GetGRFPresetList(&_grf_preset_list);
/* Switch to this preset */
- for (uint i = 0; i < _grf_preset_list.Length(); i++) {
+ for (uint i = 0; i < _grf_preset_list.size(); i++) {
if (_grf_preset_list[i] != NULL && strcmp(_grf_preset_list[i], str) == 0) {
this->preset = i;
break;
@@ -1308,7 +1308,7 @@ struct NewGRFWindow : public Window, NewGRFScanCallback {
case WKC_DOWN:
/* scroll down by one */
- if (this->avail_pos < (int)this->avails.Length() - 1) this->avail_pos++;
+ if (this->avail_pos < (int)this->avails.size() - 1) this->avail_pos++;
break;
case WKC_PAGEUP:
@@ -1318,7 +1318,7 @@ struct NewGRFWindow : public Window, NewGRFScanCallback {
case WKC_PAGEDOWN:
/* scroll down a page */
- this->avail_pos = min(this->avail_pos + this->vscroll2->GetCapacity(), (int)this->avails.Length() - 1);
+ this->avail_pos = min(this->avail_pos + this->vscroll2->GetCapacity(), (int)this->avails.size() - 1);
break;
case WKC_HOME:
@@ -1328,14 +1328,14 @@ struct NewGRFWindow : public Window, NewGRFScanCallback {
case WKC_END:
/* jump to end */
- this->avail_pos = this->avails.Length() - 1;
+ this->avail_pos = this->avails.size() - 1;
break;
default:
return ES_NOT_HANDLED;
}
- if (this->avails.Length() == 0) this->avail_pos = -1;
+ if (this->avails.size() == 0) this->avail_pos = -1;
if (this->avail_pos >= 0) {
this->active_sel = NULL;
DeleteWindowByClass(WC_GRF_PARAMETERS);
@@ -1490,7 +1490,7 @@ private:
if (this->avail_pos < 0) this->avail_sel = NULL;
}
- this->vscroll2->SetCount(this->avails.Length()); // Update the scrollbar
+ this->vscroll2->SetCount(this->avails.size()); // Update the scrollbar
}
/**
@@ -1531,7 +1531,7 @@ private:
/* Select next (or previous, if last one) item in the list. */
int new_pos = this->avail_pos + 1;
- if (new_pos >= (int)this->avails.Length()) new_pos = this->avail_pos - 1;
+ if (new_pos >= (int)this->avails.size()) new_pos = this->avail_pos - 1;
this->avail_pos = new_pos;
if (new_pos >= 0) this->avail_sel = this->avails[new_pos];
@@ -1560,7 +1560,7 @@ void ShowMissingContentWindow(const GRFConfig *list)
memcpy(ci->md5sum, HasBit(c->flags, GCF_COMPATIBLE) ? c->original_md5sum : c->ident.md5sum, sizeof(ci->md5sum));
*cv.Append() = ci;
}
- ShowNetworkContentListWindow(cv.Length() == 0 ? NULL : &cv, CONTENT_TYPE_NEWGRF);
+ ShowNetworkContentListWindow(cv.size() == 0 ? NULL : &cv, CONTENT_TYPE_NEWGRF);
}
Listing NewGRFWindow::last_sorting = {false, 0};
@@ -2049,7 +2049,7 @@ struct SavePresetWindow : public Window {
GetGRFPresetList(&this->presets);
this->selected = -1;
if (initial_text != NULL) {
- for (uint i = 0; i < this->presets.Length(); i++) {
+ for (uint i = 0; i < this->presets.size(); i++) {
if (!strcmp(initial_text, this->presets[i])) {
this->selected = i;
break;
@@ -2065,7 +2065,7 @@ struct SavePresetWindow : public Window {
this->vscroll = this->GetScrollbar(WID_SVP_SCROLLBAR);
this->FinishInitNested(0);
- this->vscroll->SetCount(this->presets.Length());
+ this->vscroll->SetCount(this->presets.size());
this->SetFocusedWidget(WID_SVP_EDITBOX);
if (initial_text != NULL) this->presetname_editbox.text.Assign(initial_text);
}
@@ -2080,12 +2080,12 @@ struct SavePresetWindow : public Window {
case WID_SVP_PRESET_LIST: {
resize->height = FONT_HEIGHT_NORMAL + 2U;
size->height = 0;
- for (uint i = 0; i < this->presets.Length(); i++) {
+ for (uint i = 0; i < this->presets.size(); i++) {
Dimension d = GetStringBoundingBox(this->presets[i]);
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.Length(), 5, 20) * resize->height + 1;
+ size->height = ClampU(this->presets.size(), 5, 20) * resize->height + 1;
break;
}
}
@@ -2101,7 +2101,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.Length());
+ uint max_index = min(min_index + this->vscroll->GetCapacity(), 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);
@@ -2120,7 +2120,7 @@ struct SavePresetWindow : public Window {
switch (widget) {
case WID_SVP_PRESET_LIST: {
uint row = this->vscroll->GetScrolledRowFromWidget(pt.y, this, WID_SVP_PRESET_LIST);
- if (row < this->presets.Length()) {
+ if (row < this->presets.size()) {
this->selected = row;
this->presetname_editbox.text.Assign(this->presets[row]);
this->SetWidgetDirty(WID_SVP_PRESET_LIST);
diff --git a/src/newgrf_railtype.cpp b/src/newgrf_railtype.cpp
index 842184471..60ddc1914 100644
--- a/src/newgrf_railtype.cpp
+++ b/src/newgrf_railtype.cpp
@@ -139,7 +139,7 @@ SpriteID GetCustomSignalSprite(const RailtypeInfo *rti, TileIndex tile, SignalTy
uint8 GetReverseRailTypeTranslation(RailType railtype, const GRFFile *grffile)
{
/* No rail type table present, return rail type as-is */
- if (grffile == NULL || grffile->railtype_list.Length() == 0) return railtype;
+ if (grffile == NULL || grffile->railtype_list.size() == 0) return railtype;
/* Look for a matching rail type label in the table */
RailTypeLabel label = GetRailTypeInfo(railtype)->label;
diff --git a/src/newgrf_sound.cpp b/src/newgrf_sound.cpp
index 9d890e9ca..dfe7e403e 100644
--- a/src/newgrf_sound.cpp
+++ b/src/newgrf_sound.cpp
@@ -49,14 +49,14 @@ void InitializeSoundPool()
SoundEntry *GetSound(SoundID index)
{
- if (index >= _sounds.Length()) return NULL;
+ if (index >= _sounds.size()) return NULL;
return &_sounds[index];
}
uint GetNumSounds()
{
- return _sounds.Length();
+ return _sounds.size();
}
diff --git a/src/os/macosx/string_osx.cpp b/src/os/macosx/string_osx.cpp
index 1c5d55885..4abf0037c 100644
--- a/src/os/macosx/string_osx.cpp
+++ b/src/os/macosx/string_osx.cpp
@@ -85,7 +85,7 @@ public:
virtual int GetLeading() const;
virtual int GetWidth() const;
- virtual int CountRuns() const { return this->Length(); }
+ virtual int CountRuns() const { return this->size(); }
virtual const VisualRun *GetVisualRun(int run) const { return *this->Get(run); }
int GetInternalCharLength(WChar c) const
@@ -256,7 +256,7 @@ int CoreTextParagraphLayout::CoreTextLine::GetLeading() const
*/
int CoreTextParagraphLayout::CoreTextLine::GetWidth() const
{
- if (this->Length() == 0) return 0;
+ if (this->size() == 0) return 0;
int total_width = 0;
for (const CoreTextVisualRun * const *run = this->Begin(); run != this->End(); run++) {
diff --git a/src/os/windows/string_uniscribe.cpp b/src/os/windows/string_uniscribe.cpp
index ce61537b2..8877d36a6 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->Length(); }
+ virtual int CountRuns() const { return this->size(); }
virtual const VisualRun *GetVisualRun(int run) const { return *this->Get(run); }
int GetInternalCharLength(WChar c) const
diff --git a/src/rail_cmd.cpp b/src/rail_cmd.cpp
index a948ac0f9..17df27fc5 100644
--- a/src/rail_cmd.cpp
+++ b/src/rail_cmd.cpp
@@ -1747,7 +1747,7 @@ CommandCost CmdConvertRail(TileIndex tile, DoCommandFlag flags, uint32 p1, uint3
break;
}
- for (uint i = 0; i < vehicles_affected.Length(); ++i) {
+ for (uint i = 0; i < vehicles_affected.size(); ++i) {
TryPathReserve(vehicles_affected[i], true);
}
}
diff --git a/src/saveload/animated_tile_sl.cpp b/src/saveload/animated_tile_sl.cpp
index 6db0561cd..36571c418 100644
--- a/src/saveload/animated_tile_sl.cpp
+++ b/src/saveload/animated_tile_sl.cpp
@@ -25,8 +25,8 @@ extern SmallVector<TileIndex, 256> _animated_tiles;
*/
static void Save_ANIT()
{
- SlSetLength(_animated_tiles.Length() * sizeof(*_animated_tiles.Begin()));
- SlArray(_animated_tiles.Begin(), _animated_tiles.Length(), SLE_UINT32);
+ SlSetLength(_animated_tiles.size() * sizeof(*_animated_tiles.Begin()));
+ SlArray(_animated_tiles.Begin(), _animated_tiles.size(), SLE_UINT32);
}
/**
diff --git a/src/saveload/game_sl.cpp b/src/saveload/game_sl.cpp
index 325ae1c9d..ff48ab135 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.Length();
+ _game_saveload_strings = ls->lines.size();
SlObject(NULL, _game_language_header);
for (uint i = 0; i < _game_saveload_strings; i++) {
@@ -160,7 +160,7 @@ static void Load_GSTR()
}
/* If there were no strings in the savegame, set GameStrings to NULL */
- if (_current_data->raw_strings.Length() == 0) {
+ if (_current_data->raw_strings.size() == 0) {
delete _current_data;
_current_data = NULL;
return;
@@ -174,7 +174,7 @@ static void Save_GSTR()
{
if (_current_data == NULL) return;
- for (uint i = 0; i < _current_data->raw_strings.Length(); i++) {
+ for (uint i = 0; i < _current_data->raw_strings.size(); i++) {
SlSetArrayIndex(i);
SlAutolength((AutolengthProc *)SaveReal_GSTR, _current_data->raw_strings[i]);
}
diff --git a/src/saveload/labelmaps_sl.cpp b/src/saveload/labelmaps_sl.cpp
index b57a89f20..a25abe722 100644
--- a/src/saveload/labelmaps_sl.cpp
+++ b/src/saveload/labelmaps_sl.cpp
@@ -26,7 +26,7 @@ static SmallVector<RailTypeLabel, RAILTYPE_END> _railtype_list;
*/
static bool NeedRailTypeConversion()
{
- for (uint i = 0; i < _railtype_list.Length(); i++) {
+ for (uint i = 0; i < _railtype_list.size(); i++) {
if ((RailType)i < RAILTYPE_END) {
const RailtypeInfo *rti = GetRailTypeInfo((RailType)i);
if (rti->label != _railtype_list[i]) return true;
@@ -44,7 +44,7 @@ void AfterLoadLabelMaps()
if (NeedRailTypeConversion()) {
SmallVector<RailType, RAILTYPE_END> railtype_conversion_map;
- for (uint i = 0; i < _railtype_list.Length(); i++) {
+ for (uint i = 0; i < _railtype_list.size(); i++) {
RailType r = GetRailTypeByLabel(_railtype_list[i]);
if (r == INVALID_RAILTYPE) r = RAILTYPE_BEGIN;
diff --git a/src/saveload/linkgraph_sl.cpp b/src/saveload/linkgraph_sl.cpp
index 76390a010..1ff247042 100644
--- a/src/saveload/linkgraph_sl.cpp
+++ b/src/saveload/linkgraph_sl.cpp
@@ -55,7 +55,7 @@ const SaveLoad *GetLinkGraphJobDesc()
static const char *prefix = "linkgraph.";
/* Build the SaveLoad array on first call and don't touch it later on */
- if (saveloads.Length() == 0) {
+ if (saveloads.size() == 0) {
size_t offset_gamesettings = cpp_offsetof(GameSettings, linkgraph);
size_t offset_component = cpp_offsetof(LinkGraphJob, settings);
@@ -83,7 +83,7 @@ const SaveLoad *GetLinkGraphJobDesc()
int i = 0;
do {
*(saveloads.Append()) = job_desc[i++];
- } while (saveloads[saveloads.Length() - 1].cmd != SL_END);
+ } while (saveloads[saveloads.size() - 1].cmd != SL_END);
}
return &saveloads[0];
diff --git a/src/saveload/saveload.cpp b/src/saveload/saveload.cpp
index f066d014d..2aa19af81 100644
--- a/src/saveload/saveload.cpp
+++ b/src/saveload/saveload.cpp
@@ -175,7 +175,7 @@ struct MemoryDumper {
*/
size_t GetSize() const
{
- return this->blocks.Length() * MEMORY_CHUNK_SIZE - (this->bufe - this->buf);
+ return this->blocks.size() * MEMORY_CHUNK_SIZE - (this->bufe - this->buf);
}
};
diff --git a/src/saveload/waypoint_sl.cpp b/src/saveload/waypoint_sl.cpp
index 2567c2c93..5e3a391f0 100644
--- a/src/saveload/waypoint_sl.cpp
+++ b/src/saveload/waypoint_sl.cpp
@@ -96,7 +96,7 @@ void MoveWaypointsToBaseStations()
}
}
- if (!Waypoint::CanAllocateItem(_old_waypoints.Length())) SlError(STR_ERROR_TOO_MANY_STATIONS_LOADING);
+ if (!Waypoint::CanAllocateItem(_old_waypoints.size())) SlError(STR_ERROR_TOO_MANY_STATIONS_LOADING);
/* All saveload conversions have been done. Create the new waypoints! */
for (OldWaypoint *wp = _old_waypoints.Begin(); wp != _old_waypoints.End(); wp++) {
diff --git a/src/script/squirrel_helper.hpp b/src/script/squirrel_helper.hpp
index 002c56106..8d1ee29fc 100644
--- a/src/script/squirrel_helper.hpp
+++ b/src/script/squirrel_helper.hpp
@@ -147,9 +147,9 @@ namespace SQConvert {
}
sq_pop(vm, 2);
- Array *arr = (Array*)MallocT<byte>(sizeof(Array) + sizeof(int32) * data.Length());
- arr->size = data.Length();
- memcpy(arr->array, data.Begin(), sizeof(int32) * data.Length());
+ Array *arr = (Array*)MallocT<byte>(sizeof(Array) + sizeof(int32) * data.size());
+ arr->size = data.size();
+ memcpy(arr->array, data.Begin(), sizeof(int32) * data.size());
*ptr->Append() = arr;
return arr;
diff --git a/src/settings_gui.cpp b/src/settings_gui.cpp
index fda7cfa52..8b20bb9f2 100644
--- a/src/settings_gui.cpp
+++ b/src/settings_gui.cpp
@@ -215,7 +215,7 @@ struct GameOptionsWindow : Window {
if (i == CURRENCY_CUSTOM) continue;
*list->Append() = new DropDownListStringItem(*items, i, HasBit(disabled, i));
}
- QSortT(list->Begin(), list->Length(), DropDownListStringItem::NatSortFunc);
+ QSortT(list->Begin(), list->size(), DropDownListStringItem::NatSortFunc);
/* Append custom currency at the end */
*list->Append() = new DropDownListItem(-1, false); // separator line
@@ -253,9 +253,9 @@ struct GameOptionsWindow : Window {
int result = _nb_orig_names + i;
*list->Append() = new DropDownListStringItem(_grf_names[i], result, enabled_item != result && enabled_item >= 0);
}
- QSortT(list->Begin(), list->Length(), DropDownListStringItem::NatSortFunc);
+ QSortT(list->Begin(), list->size(), DropDownListStringItem::NatSortFunc);
- int newgrf_size = list->Length();
+ int newgrf_size = list->size();
/* Insert newgrf_names at the top of the list */
if (newgrf_size > 0) {
*list->Append() = new DropDownListItem(-1, false); // separator line
@@ -266,7 +266,7 @@ struct GameOptionsWindow : Window {
for (int i = 0; i < _nb_orig_names; i++) {
*list->Append() = new DropDownListStringItem(STR_GAME_OPTIONS_TOWN_NAME_ORIGINAL_ENGLISH + i, i, enabled_item != i && enabled_item >= 0);
}
- QSortT(list->Begin() + newgrf_size, list->Length() - newgrf_size, DropDownListStringItem::NatSortFunc);
+ QSortT(list->Begin() + newgrf_size, list->size() - newgrf_size, DropDownListStringItem::NatSortFunc);
break;
}
@@ -282,11 +282,11 @@ struct GameOptionsWindow : Window {
case WID_GO_LANG_DROPDOWN: { // Setup interface language dropdown
list = new DropDownList();
- for (uint i = 0; i < _languages.Length(); i++) {
+ for (uint i = 0; i < _languages.size(); i++) {
if (&_languages[i] == _current_language) *selected_index = i;
*list->Append() = new DropDownListStringItem(SPECSTR_LANGUAGE_START + i, i, false);
}
- QSortT(list->Begin(), list->Length(), DropDownListStringItem::NatSortFunc);
+ QSortT(list->Begin(), list->size(), DropDownListStringItem::NatSortFunc);
break;
}
diff --git a/src/settingsgen/settingsgen.cpp b/src/settingsgen/settingsgen.cpp
index 35c9911d8..64901a89f 100644
--- a/src/settingsgen/settingsgen.cpp
+++ b/src/settingsgen/settingsgen.cpp
@@ -116,7 +116,7 @@ public:
if (length == 0) length = strlen(text);
if (length > 0 && this->BufferHasRoom()) {
- int stored_size = this->output_buffer[this->output_buffer.Length() - 1].Add(text, length);
+ int stored_size = this->output_buffer[this->output_buffer.size() - 1].Add(text, length);
length -= stored_size;
text += stored_size;
}
@@ -147,7 +147,7 @@ private:
*/
bool BufferHasRoom() const
{
- uint num_blocks = this->output_buffer.Length();
+ uint num_blocks = this->output_buffer.size();
return num_blocks > 0 && this->output_buffer[num_blocks - 1].HasRoom();
}
diff --git a/src/signs_gui.cpp b/src/signs_gui.cpp
index 84b43c69d..0a1f0dd5d 100644
--- a/src/signs_gui.cpp
+++ b/src/signs_gui.cpp
@@ -246,7 +246,7 @@ struct SignListWindow : Window, SignList {
}
case WID_SIL_FILTER_ENTER_BTN:
- if (this->signs.Length() >= 1) {
+ if (this->signs.size() >= 1) {
const Sign *si = this->signs[0];
ScrollMainWindowToTile(TileVirtXY(si->x, si->y));
}
@@ -310,7 +310,7 @@ struct SignListWindow : Window, SignList {
{
if (this->signs.NeedRebuild()) {
this->BuildSignsList();
- this->vscroll->SetCount(this->signs.Length());
+ this->vscroll->SetCount(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.Length() - (next ? 1 : 0);
+ uint 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 */
@@ -479,7 +479,7 @@ struct SignWindow : Window, SignList {
}
}
/* If we haven't found the current sign by now, return the last/first sign */
- return this->signs[next ? 0 : this->signs.Length() - 1];
+ return next ? this->signs.front() : this->signs.back();
}
void SetStringParameters(int widget) const override
diff --git a/src/station_cmd.cpp b/src/station_cmd.cpp
index 6121424d5..f7e2a1824 100644
--- a/src/station_cmd.cpp
+++ b/src/station_cmd.cpp
@@ -1436,7 +1436,7 @@ CommandCost CmdBuildRailStation(TileIndex tile_org, DoCommandFlag flags, uint32
tile_track += tile_delta ^ TileDiffXY(1, 1); // perpendicular to tile_delta
} while (--numtracks);
- for (uint i = 0; i < affected_vehicles.Length(); ++i) {
+ for (uint i = 0; i < affected_vehicles.size(); ++i) {
/* Restore reservations of trains. */
RestoreTrainReservation(affected_vehicles[i]);
}
diff --git a/src/station_gui.cpp b/src/station_gui.cpp
index 32e22b161..fddfe780d 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.Length()); // Update the scrollbar
+ this->vscroll->SetCount(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.Length());
+ int max = min(this->vscroll->GetPosition() + this->vscroll->GetCapacity(), 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];
@@ -498,7 +498,7 @@ public:
switch (widget) {
case WID_STL_LIST: {
uint id_v = this->vscroll->GetScrolledRowFromWidget(pt.y, this, WID_STL_LIST, 0, FONT_HEIGHT_NORMAL);
- if (id_v >= this->stations.Length()) return; // click out of list bound
+ if (id_v >= this->stations.size()) return; // click out of list bound
const Station *st = this->stations[id_v];
/* do not check HasStationInUse - it is slow and may be invalid */
@@ -2132,7 +2132,7 @@ static bool AddNearbyStation(TileIndex tile, void *user_data)
TileArea *ctx = (TileArea *)user_data;
/* First check if there were deleted stations here */
- for (uint i = 0; i < _deleted_stations_nearby.Length(); i++) {
+ for (uint i = 0; i < _deleted_stations_nearby.size(); i++) {
TileAndStation *ts = _deleted_stations_nearby.Get(i);
if (ts->tile == tile) {
*_stations_nearby_list.Append() = _deleted_stations_nearby[i].station;
@@ -2255,7 +2255,7 @@ struct SelectStationWindow : Window {
/* Determine the widest string */
Dimension d = GetStringBoundingBox(T::EXPECTED_FACIL == FACIL_WAYPOINT ? STR_JOIN_WAYPOINT_CREATE_SPLITTED_WAYPOINT : STR_JOIN_STATION_CREATE_SPLITTED_STATION);
- for (uint i = 0; i < _stations_nearby_list.Length(); i++) {
+ for (uint i = 0; i < _stations_nearby_list.size(); i++) {
const T *st = T::Get(_stations_nearby_list[i]);
SetDParam(0, st->index);
SetDParam(1, st->facilities);
@@ -2279,7 +2279,7 @@ struct SelectStationWindow : Window {
y += this->resize.step_height;
}
- for (uint i = max<uint>(1, this->vscroll->GetPosition()); i <= _stations_nearby_list.Length(); ++i, y += this->resize.step_height) {
+ for (uint i = max<uint>(1, this->vscroll->GetPosition()); i <= _stations_nearby_list.size(); ++i, y += this->resize.step_height) {
/* Don't draw anything if it extends past the end of the window. */
if (i - this->vscroll->GetPosition() >= this->vscroll->GetCapacity()) break;
@@ -2298,7 +2298,7 @@ struct SelectStationWindow : Window {
bool distant_join = (st_index > 0);
if (distant_join) st_index--;
- if (distant_join && st_index >= _stations_nearby_list.Length()) return;
+ if (distant_join && st_index >= _stations_nearby_list.size()) return;
/* Insert station to be joined into stored command */
SB(this->select_station_cmd.p2, 16, 16,
@@ -2333,7 +2333,7 @@ struct SelectStationWindow : Window {
{
if (!gui_scope) return;
FindStationsNearby<T>(this->area, true);
- this->vscroll->SetCount(_stations_nearby_list.Length() + 1);
+ this->vscroll->SetCount(_stations_nearby_list.size() + 1);
this->SetDirty();
}
};
@@ -2378,7 +2378,7 @@ static bool StationJoinerNeeded(const CommandContainer &cmd, TileArea ta)
* If adjacent-stations is disabled and we are building next to a station, do not show the selection window.
* but join the other station immediately. */
const T *st = FindStationsNearby<T>(ta, false);
- return st == NULL && (_settings_game.station.adjacent_stations || _stations_nearby_list.Length() == 0);
+ return st == NULL && (_settings_game.station.adjacent_stations || _stations_nearby_list.size() == 0);
}
/**
diff --git a/src/story_gui.cpp b/src/story_gui.cpp
index efb3f36e7..78c8b9793 100644
--- a/src/story_gui.cpp
+++ b/src/story_gui.cpp
@@ -159,7 +159,7 @@ protected:
/* Verify that the selected page exist. */
if (!_story_page_pool.IsValidID(this->selected_page_id)) return false;
- if (this->story_pages.Length() <= 1) return true;
+ if (this->story_pages.size() <= 1) return true;
const StoryPage *last = *(this->story_pages.End() - 1);
return last->index == this->selected_page_id;
}
@@ -253,7 +253,7 @@ protected:
}
/* Check if list is empty. */
- if (list->Length() == 0) {
+ if (list->size() == 0) {
delete list;
list = NULL;
}
@@ -444,8 +444,8 @@ public:
*/
void UpdatePrevNextDisabledState()
{
- this->SetWidgetDisabledState(WID_SB_PREV_PAGE, story_pages.Length() == 0 || this->IsFirstPageSelected());
- this->SetWidgetDisabledState(WID_SB_NEXT_PAGE, story_pages.Length() == 0 || this->IsLastPageSelected());
+ this->SetWidgetDisabledState(WID_SB_PREV_PAGE, story_pages.size() == 0 || this->IsFirstPageSelected());
+ this->SetWidgetDisabledState(WID_SB_NEXT_PAGE, story_pages.size() == 0 || this->IsLastPageSelected());
this->SetWidgetDirty(WID_SB_PREV_PAGE);
this->SetWidgetDirty(WID_SB_NEXT_PAGE);
}
@@ -575,7 +575,7 @@ public:
case WID_SB_SEL_PAGE: {
/* Get max title width. */
- for (uint16 i = 0; i < this->story_pages.Length(); i++) {
+ for (uint16 i = 0; i < this->story_pages.size(); i++) {
const StoryPage *s = this->story_pages[i];
if (s->title != NULL) {
@@ -620,7 +620,7 @@ public:
if (list != NULL) {
/* Get the index of selected page. */
int selected = 0;
- for (uint16 i = 0; i < this->story_pages.Length(); i++) {
+ for (uint16 i = 0; i < this->story_pages.size(); i++) {
const StoryPage *p = this->story_pages[i];
if (p->index == this->selected_page_id) break;
selected++;
@@ -694,7 +694,7 @@ public:
this->BuildStoryPageList();
/* Was the last page removed? */
- if (this->story_pages.Length() == 0) {
+ if (this->story_pages.size() == 0) {
this->selected_generic_title[0] = '\0';
}
@@ -702,14 +702,14 @@ public:
if (!_story_page_pool.IsValidID(this->selected_page_id)) {
this->selected_page_id = INVALID_STORY_PAGE;
}
- if (this->selected_page_id == INVALID_STORY_PAGE && this->story_pages.Length() > 0) {
+ if (this->selected_page_id == INVALID_STORY_PAGE && this->story_pages.size() > 0) {
/* No page is selected, but there exist at least one available.
* => Select first page.
*/
this->SetSelectedPage(this->story_pages[0]->index);
}
- this->SetWidgetDisabledState(WID_SB_SEL_PAGE, this->story_pages.Length() == 0);
+ this->SetWidgetDisabledState(WID_SB_SEL_PAGE, this->story_pages.size() == 0);
this->SetWidgetDirty(WID_SB_SEL_PAGE);
this->UpdatePrevNextDisabledState();
} else if (data >= 0 && this->selected_page_id == data) {
diff --git a/src/strgen/strgen_base.cpp b/src/strgen/strgen_base.cpp
index 8f3f8941f..0e75537fb 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.Length();
+ uint pos = 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.Length() - (pos + 2);
+ uint size = buffer.size() - (pos + 2);
buffer[pos + 0] = GB(size, 8, 8);
buffer[pos + 1] = GB(size, 0, 8);
}
@@ -1044,8 +1044,8 @@ void LanguageWriter::WriteLang(const StringData &data)
if (cmdp != NULL) PutCommandString(&buffer, cmdp);
- this->WriteLength(buffer.Length());
- this->Write(buffer.Begin(), buffer.Length());
+ this->WriteLength(buffer.size());
+ this->Write(buffer.Begin(), buffer.size());
buffer.clear();
}
}
diff --git a/src/string.cpp b/src/string.cpp
index cb6c1e8f7..5246f7827 100644
--- a/src/string.cpp
+++ b/src/string.cpp
@@ -674,7 +674,7 @@ public:
UText text = UTEXT_INITIALIZER;
UErrorCode status = U_ZERO_ERROR;
- utext_openUChars(&text, this->utf16_str.Begin(), this->utf16_str.Length() - 1, &status);
+ utext_openUChars(&text, this->utf16_str.Begin(), this->utf16_str.size() - 1, &status);
this->char_itr->setText(&text, status);
this->word_itr->setText(&text, status);
this->char_itr->first();
@@ -685,7 +685,7 @@ public:
{
/* Convert incoming position to an UTF-16 string index. */
uint utf16_pos = 0;
- for (uint i = 0; i < this->utf16_to_utf8.Length(); i++) {
+ for (uint i = 0; i < this->utf16_to_utf8.size(); i++) {
if (this->utf16_to_utf8[i] == pos) {
utf16_pos = i;
break;
diff --git a/src/stringfilter_type.h b/src/stringfilter_type.h
index f78b133cb..4dad55aaa 100644
--- a/src/stringfilter_type.h
+++ b/src/stringfilter_type.h
@@ -58,7 +58,7 @@ public:
* Check whether any filter words were entered.
* @return true if no words were entered.
*/
- bool IsEmpty() const { return this->word_index.Length() == 0; }
+ bool IsEmpty() const { return this->word_index.size() == 0; }
void ResetState();
void AddLine(const char *str);
@@ -68,7 +68,7 @@ public:
* Get the matching state of the current item.
* @return true if matched.
*/
- bool GetState() const { return this->word_matches == this->word_index.Length(); }
+ bool GetState() const { return this->word_matches == this->word_index.size(); }
};
#endif /* STRINGFILTER_TYPE_H */
diff --git a/src/strings.cpp b/src/strings.cpp
index 57a175702..61a5098ab 100644
--- a/src/strings.cpp
+++ b/src/strings.cpp
@@ -1952,7 +1952,7 @@ void InitializeLanguagePacks()
FioAppendDirectory(path, lastof(path), sp, LANG_DIR);
GetLanguageList(path);
}
- if (_languages.Length() == 0) usererror("No available language packs (invalid versions?)");
+ if (_languages.size() == 0) usererror("No available language packs (invalid versions?)");
/* Acquire the locale of the current system */
const char *lang = GetCurrentLocale("LC_MESSAGES");
diff --git a/src/texteff.cpp b/src/texteff.cpp
index ee5ce592b..0f9fec247 100644
--- a/src/texteff.cpp
+++ b/src/texteff.cpp
@@ -45,10 +45,10 @@ TextEffectID AddTextEffect(StringID msg, int center, int y, uint8 duration, Text
if (_game_mode == GM_MENU) return INVALID_TE_ID;
TextEffectID i;
- for (i = 0; i < _text_effects.Length(); i++) {
+ for (i = 0; i < _text_effects.size(); i++) {
if (_text_effects[i].string_id == INVALID_STRING_ID) break;
}
- if (i == _text_effects.Length()) _text_effects.Append();
+ if (i == _text_effects.size()) _text_effects.Append();
TextEffect *te = _text_effects.Get(i);
diff --git a/src/textfile_gui.cpp b/src/textfile_gui.cpp
index 018888d0b..e9706c752 100644
--- a/src/textfile_gui.cpp
+++ b/src/textfile_gui.cpp
@@ -86,7 +86,7 @@ uint TextfileWindow::GetContentHeight()
int max_width = this->GetWidget<NWidgetCore>(WID_TF_BACKGROUND)->current_x - WD_FRAMETEXT_LEFT - WD_FRAMERECT_RIGHT;
uint height = 0;
- for (uint i = 0; i < this->lines.Length(); i++) {
+ for (uint i = 0; i < this->lines.size(); i++) {
height += GetStringHeight(this->lines[i], max_width, FS_MONO);
}
@@ -113,10 +113,10 @@ void TextfileWindow::SetupScrollbars()
this->hscroll->SetCount(0);
} else {
uint max_length = 0;
- for (uint i = 0; i < this->lines.Length(); i++) {
+ 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.Length() * FONT_HEIGHT_MONO);
+ this->vscroll->SetCount(this->lines.size() * FONT_HEIGHT_MONO);
this->hscroll->SetCount(max_length + WD_FRAMETEXT_LEFT + WD_FRAMETEXT_RIGHT);
}
@@ -152,7 +152,7 @@ void TextfileWindow::SetupScrollbars()
int line_height = FONT_HEIGHT_MONO;
int y_offset = -this->vscroll->GetPosition();
- for (uint i = 0; i < this->lines.Length(); i++) {
+ for (uint i = 0; i < this->lines.size(); i++) {
if (IsWidgetLowered(WID_TF_WRAPTEXT)) {
y_offset = DrawStringMultiLine(0, right - x, y_offset, bottom - y, this->lines[i], TC_WHITE, SA_TOP | SA_LEFT, false, FS_MONO);
} else {
@@ -184,7 +184,7 @@ void TextfileWindow::SetupScrollbars()
/* virtual */ const char *TextfileWindow::NextString()
{
- if (this->search_iterator >= this->lines.Length()) return NULL;
+ if (this->search_iterator >= this->lines.size()) return NULL;
return this->lines[this->search_iterator++];
}
diff --git a/src/timetable_cmd.cpp b/src/timetable_cmd.cpp
index 29986c353..dec4f7d44 100644
--- a/src/timetable_cmd.cpp
+++ b/src/timetable_cmd.cpp
@@ -292,10 +292,10 @@ CommandCost CmdSetTimetableStart(TileIndex tile, DoCommandFlag flags, uint32 p1,
}
int total_duration = v->orders.list->GetTimetableTotalDuration();
- int num_vehs = vehs.Length();
+ int num_vehs = vehs.size();
if (num_vehs >= 2) {
- QSortT(vehs.Begin(), vehs.Length(), &VehicleTimetableSorter);
+ QSortT(vehs.Begin(), vehs.size(), &VehicleTimetableSorter);
}
int base = vehs.FindIndex(v);
diff --git a/src/town_gui.cpp b/src/town_gui.cpp
index b9aa938e6..bf8fb4b87 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.Length()); // Update scrollbar as well.
+ this->vscroll->SetCount(this->towns.size()); // Update scrollbar as well.
}
/* Always sort the towns. */
this->last_town = NULL;
@@ -766,7 +766,7 @@ public:
case WID_TD_LIST: {
int n = 0;
int y = r.top + WD_FRAMERECT_TOP;
- if (this->towns.Length() == 0) { // No towns available.
+ if (this->towns.size() == 0) { // No towns available.
DrawString(r.left + WD_FRAMERECT_LEFT, r.right, y, STR_TOWN_DIRECTORY_NONE);
break;
}
@@ -778,7 +778,7 @@ public:
int text_right = r.right - WD_FRAMERECT_RIGHT - (rtl ? icon_size.width + 2 : 0);
int icon_x = rtl ? r.right - WD_FRAMERECT_RIGHT - icon_size.width : r.left + WD_FRAMERECT_LEFT;
- for (uint i = this->vscroll->GetPosition(); i < this->towns.Length(); i++) {
+ for (uint i = this->vscroll->GetPosition(); i < this->towns.size(); i++) {
const Town *t = this->towns[i];
assert(t->xy != INVALID_TILE);
@@ -826,7 +826,7 @@ public:
}
case WID_TD_LIST: {
Dimension d = GetStringBoundingBox(STR_TOWN_DIRECTORY_NONE);
- for (uint i = 0; i < this->towns.Length(); i++) {
+ for (uint i = 0; i < this->towns.size(); i++) {
const Town *t = this->towns[i];
assert(t != NULL);
@@ -879,7 +879,7 @@ public:
case WID_TD_LIST: { // Click on Town Matrix
uint id_v = this->vscroll->GetScrolledRowFromWidget(pt.y, this, WID_TD_LIST, WD_FRAMERECT_TOP);
- if (id_v >= this->towns.Length()) return; // click out of town bounds
+ if (id_v >= this->towns.size()) return; // click out of town bounds
const Town *t = this->towns[id_v];
assert(t != NULL);
diff --git a/src/train_cmd.cpp b/src/train_cmd.cpp
index 9f17bd898..db3773f96 100644
--- a/src/train_cmd.cpp
+++ b/src/train_cmd.cpp
@@ -833,7 +833,7 @@ static void MakeTrainBackup(TrainList &list, Train *t)
static void RestoreTrainBackup(TrainList &list)
{
/* No train, nothing to do. */
- if (list.Length() == 0) return;
+ if (list.size() == 0) return;
Train *prev = NULL;
/* Iterate over the list and rebuild it. */
diff --git a/src/train_gui.cpp b/src/train_gui.cpp
index 5246b59cb..3c394ef19 100644
--- a/src/train_gui.cpp
+++ b/src/train_gui.cpp
@@ -332,7 +332,7 @@ int GetTrainDetailsWndVScroll(VehicleID veh_id, TrainDetailsWindowTabs det_tab)
} else {
for (const Train *v = Train::Get(veh_id); v != NULL; v = v->GetNextVehicle()) {
GetCargoSummaryOfArticulatedVehicle(v, &_cargo_summary);
- num += max(1u, _cargo_summary.Length());
+ num += max(1u, (unsigned)_cargo_summary.size());
uint length = GetLengthOfArticulatedVehicle(v);
if (length > TRAIN_DETAILS_MAX_INDENT) num++;
@@ -400,7 +400,7 @@ void DrawTrainDetails(const Train *v, int left, int right, int y, int vscroll_po
dx = 0;
}
- uint num_lines = max(1u, _cargo_summary.Length());
+ uint num_lines = max(1u, (unsigned)_cargo_summary.size());
for (uint i = 0; i < num_lines; i++) {
int sprite_width = max<int>(dx, ScaleGUITrad(TRAIN_DETAILS_MIN_INDENT)) + 3;
int data_left = left + (rtl ? 0 : sprite_width);
@@ -412,7 +412,7 @@ void DrawTrainDetails(const Train *v, int left, int right, int y, int vscroll_po
}
switch (det_tab) {
case TDW_TAB_CARGO:
- if (i < _cargo_summary.Length()) {
+ if (i < _cargo_summary.size()) {
TrainDetailsCargoTab(&_cargo_summary[i], data_left, data_right, py);
} else {
DrawString(data_left, data_right, py, STR_QUANTITY_N_A, TC_LIGHT_BLUE);
@@ -424,7 +424,7 @@ void DrawTrainDetails(const Train *v, int left, int right, int y, int vscroll_po
break;
case TDW_TAB_CAPACITY:
- if (i < _cargo_summary.Length()) {
+ if (i < _cargo_summary.size()) {
TrainDetailsCapacityTab(&_cargo_summary[i], data_left, data_right, py);
} else {
SetDParam(0, STR_EMPTY);
diff --git a/src/vehicle_cmd.cpp b/src/vehicle_cmd.cpp
index 27f2262e7..ccc9446a0 100644
--- a/src/vehicle_cmd.cpp
+++ b/src/vehicle_cmd.cpp
@@ -652,7 +652,7 @@ CommandCost CmdMassStartStopVehicle(TileIndex tile, DoCommandFlag flags, uint32
BuildDepotVehicleList(vli.vtype, tile, &list, NULL);
}
- for (uint i = 0; i < list.Length(); i++) {
+ for (uint i = 0; i < list.size(); i++) {
const Vehicle *v = list[i];
if (!!(v->vehstatus & VS_STOPPED) != do_start) continue;
@@ -691,7 +691,7 @@ CommandCost CmdDepotSellAllVehicles(TileIndex tile, DoCommandFlag flags, uint32
CommandCost last_error = CMD_ERROR;
bool had_success = false;
- for (uint i = 0; i < list.Length(); i++) {
+ for (uint i = 0; i < list.size(); i++) {
CommandCost ret = DoCommand(tile, list[i]->index | (1 << 20), 0, flags, sell_command);
if (ret.Succeeded()) {
cost.AddCost(ret);
@@ -725,7 +725,7 @@ CommandCost CmdDepotMassAutoReplace(TileIndex tile, DoCommandFlag flags, uint32
/* Get the list of vehicles in the depot */
BuildDepotVehicleList(vehicle_type, tile, &list, &list, true);
- for (uint i = 0; i < list.Length(); i++) {
+ for (uint i = 0; i < list.size(); i++) {
const Vehicle *v = list[i];
/* Ensure that the vehicle completely in the depot */
@@ -1003,7 +1003,7 @@ static CommandCost SendAllVehiclesToDepot(DoCommandFlag flags, bool service, con
/* Send all the vehicles to a depot */
bool had_success = false;
- for (uint i = 0; i < list.Length(); i++) {
+ for (uint i = 0; i < list.size(); i++) {
const Vehicle *v = list[i];
CommandCost ret = DoCommand(v->tile, v->index | (service ? DEPOT_SERVICE : 0U) | DEPOT_DONT_CANCEL, 0, flags, GetCmdSendToDepot(vli.vtype));
diff --git a/src/vehicle_gui.cpp b/src/vehicle_gui.cpp
index 2ae385aa2..36f08493e 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.Length());
+ this->vscroll->SetCount(this->vehicles.size());
}
/**
@@ -193,8 +193,8 @@ void BaseVehicleListWindow::SortVehicleList()
void DepotSortList(VehicleList *list)
{
- if (list->Length() < 2) return;
- QSortT(list->Begin(), list->Length(), &VehicleNumberSorter);
+ if (list->size() < 2) return;
+ QSortT(list->Begin(), list->size(), &VehicleNumberSorter);
}
/** draw the vehicle profit button in the vehicle list window. */
@@ -243,7 +243,7 @@ byte GetBestFittingSubType(Vehicle *v_from, Vehicle *v_for, CargoID dest_cargo_t
byte ret_refit_cyc = 0;
bool success = false;
- if (subtypes.Length() > 0) {
+ if (subtypes.size() > 0) {
/* Check whether any articulated part is refittable to 'dest_cargo_type' with a subtype listed in 'subtypes' */
for (Vehicle *v = v_for; v != NULL; v = v->HasArticulatedPart() ? v->GetNextArticulatedPart() : NULL) {
const Engine *e = v->GetEngine();
@@ -347,7 +347,7 @@ static void DrawVehicleRefitWindow(const SubtypeList list[NUM_CARGO], const int
/* Draw the list of subtypes for each cargo, and find the selected refit option (by its position). */
for (uint i = 0; current < pos + rows && i < NUM_CARGO; i++) {
- for (uint j = 0; current < pos + rows && j < list[i].Length(); j++) {
+ for (uint j = 0; current < pos + rows && j < list[i].size(); j++) {
const RefitOption &refit = list[i][j];
/* Hide subtypes if sel[0] does not match */
@@ -359,11 +359,11 @@ static void DrawVehicleRefitWindow(const SubtypeList list[NUM_CARGO], const int
continue;
}
- if (list[i].Length() > 1) {
+ if (list[i].size() > 1) {
if (refit.subtype != 0xFF) {
/* Draw tree lines */
int ycenter = y + FONT_HEIGHT_NORMAL / 2;
- GfxDrawLine(iconcenter, y - WD_MATRIX_TOP, iconcenter, j == list[i].Length() - 1 ? ycenter : y - WD_MATRIX_TOP + delta - 1, linecolour);
+ GfxDrawLine(iconcenter, y - WD_MATRIX_TOP, iconcenter, j == list[i].size() - 1 ? ycenter : y - WD_MATRIX_TOP + delta - 1, linecolour);
GfxDrawLine(iconcenter, ycenter, iconinner, ycenter, linecolour);
} else {
/* Draw expand/collapse icon */
@@ -435,7 +435,7 @@ struct RefitWindow : public Window {
continue;
}
- bool first_vehicle = this->list[current_index].Length() == 0;
+ bool first_vehicle = this->list[current_index].size() == 0;
if (first_vehicle) {
/* Keeping the current subtype is always an option. It also serves as the option in case of no subtypes */
RefitOption *option = this->list[current_index].Append();
@@ -480,7 +480,7 @@ struct RefitWindow : public Window {
/* No more subtypes for this vehicle, delete all subtypes >= refit_cyc */
SubtypeList &l = this->list[current_index];
/* 0xFF item is in front, other subtypes are sorted. So just truncate the list in the right spot */
- for (uint i = 1; i < l.Length(); i++) {
+ for (uint i = 1; i < l.size(); i++) {
if (l[i].subtype >= refit_cyc) {
l.Resize(i);
break;
@@ -491,8 +491,8 @@ struct RefitWindow : public Window {
/* Check whether the subtype matches with the subtype of earlier vehicles. */
uint pos = 1;
SubtypeList &l = this->list[current_index];
- while (pos < l.Length() && l[pos].subtype != refit_cyc) pos++;
- if (pos < l.Length() && l[pos].string != subtype) {
+ while (pos < l.size() && l[pos].subtype != refit_cyc) pos++;
+ if (pos < l.size() && l[pos].string != subtype) {
/* String mismatch, remove item keeping the order */
l.ErasePreservingOrder(pos);
}
@@ -522,7 +522,7 @@ struct RefitWindow : public Window {
uint row = 0;
for (uint i = 0; i < NUM_CARGO; i++) {
- for (uint j = 0; j < this->list[i].Length(); j++) {
+ for (uint j = 0; j < this->list[i].size(); j++) {
const RefitOption &refit = this->list[i][j];
/* Hide subtypes if sel[0] does not match */
@@ -547,7 +547,7 @@ struct RefitWindow : public Window {
uint row = 0;
for (uint i = 0; i < NUM_CARGO; i++) {
- for (uint j = 0; j < this->list[i].Length(); j++) {
+ for (uint j = 0; j < this->list[i].size(); j++) {
const RefitOption &refit = this->list[i][j];
/* Hide subtypes if sel[0] does not match */
@@ -576,7 +576,7 @@ struct RefitWindow : public Window {
if (this->sel[0] < 0) return NULL;
SubtypeList &l = this->list[this->sel[0]];
- if ((uint)this->sel[1] >= l.Length()) return NULL;
+ if ((uint)this->sel[1] >= l.size()) return NULL;
return &l[this->sel[1]];
}
@@ -617,7 +617,7 @@ struct RefitWindow : public Window {
this->sel[1] = 0;
this->cargo = NULL;
for (uint i = 0; this->cargo == NULL && i < NUM_CARGO; i++) {
- for (uint j = 0; j < list[i].Length(); j++) {
+ for (uint j = 0; j < list[i].size(); j++) {
if (list[i][j] == current_refit_option) {
this->sel[0] = i;
this->sel[1] = j;
@@ -830,7 +830,7 @@ struct RefitWindow : public Window {
/* Check the width of all cargo information strings. */
for (uint i = 0; i < NUM_CARGO; i++) {
- for (uint j = 0; j < this->list[i].Length(); j++) {
+ for (uint j = 0; j < this->list[i].size(); j++) {
StringID string = this->GetCapacityString(&list[i][j]);
if (string != INVALID_STRING_ID) {
Dimension dim = GetStringBoundingBox(string);
@@ -1388,7 +1388,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.Length());
+ uint max = min(this->vscroll->GetPosition() + this->vscroll->GetCapacity(), this->vehicles.size());
for (uint i = this->vscroll->GetPosition(); i < max; ++i) {
const Vehicle *v = this->vehicles[i];
StringID str;
@@ -1532,7 +1532,7 @@ public:
case WID_VL_CAPTION: {
switch (this->vli.type) {
case VL_SHARED_ORDERS: // Shared Orders
- if (this->vehicles.Length() == 0) {
+ if (this->vehicles.size() == 0) {
/* We can't open this window without vehicles using this order
* and we should close the window when deleting the order. */
NOT_REACHED();
@@ -1584,7 +1584,7 @@ public:
this->BuildVehicleList();
this->SortVehicleList();
- if (this->vehicles.Length() == 0 && this->IsWidgetLowered(WID_VL_MANAGE_VEHICLES_DROPDOWN)) {
+ if (this->vehicles.size() == 0 && this->IsWidgetLowered(WID_VL_MANAGE_VEHICLES_DROPDOWN)) {
HideDropDownMenu(this);
}
@@ -1598,7 +1598,7 @@ public:
}
if (this->owner == _local_company) {
this->SetWidgetDisabledState(WID_VL_AVAILABLE_VEHICLES, this->vli.type != VL_STANDARD);
- this->SetWidgetsDisabledState(this->vehicles.Length() == 0,
+ this->SetWidgetsDisabledState(this->vehicles.size() == 0,
WID_VL_MANAGE_VEHICLES_DROPDOWN,
WID_VL_STOP_ALL,
WID_VL_START_ALL,
@@ -1626,7 +1626,7 @@ public:
case WID_VL_LIST: { // Matrix to show vehicles
uint id_v = this->vscroll->GetScrolledRowFromWidget(pt.y, this, WID_VL_LIST);
- if (id_v >= this->vehicles.Length()) return; // click out of list bound
+ if (id_v >= this->vehicles.size()) return; // click out of list bound
const Vehicle *v = this->vehicles[id_v];
if (!VehicleClicked(v)) ShowVehicleViewWindow(v);
@@ -1657,7 +1657,7 @@ public:
this->vehicles.SetSortType(index);
break;
case WID_VL_MANAGE_VEHICLES_DROPDOWN:
- assert(this->vehicles.Length() != 0);
+ assert(this->vehicles.size() != 0);
switch (index) {
case ADI_REPLACE: // Replace window
diff --git a/src/viewport.cpp b/src/viewport.cpp
index bd0570cf1..de0da81b2 100644
--- a/src/viewport.cpp
+++ b/src/viewport.cpp
@@ -598,7 +598,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.Length() - 1;
+ if (_vd.last_child != NULL) _vd.foundation[_vd.foundation_part] = _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;
@@ -824,7 +824,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.Length();
+ *_vd.last_child = _vd.child_screen_sprites_to_draw.size();
ChildScreenSpriteToDraw *cs = _vd.child_screen_sprites_to_draw.Append();
cs->image = image;
@@ -1584,7 +1584,7 @@ void ViewportDoDraw(const ViewPort *vp, int left, int top, int right, int bottom
DrawTextEffects(&_vd.dpi);
- if (_vd.tile_sprites_to_draw.Length() != 0) ViewportDrawTileSprites(&_vd.tile_sprites_to_draw);
+ if (_vd.tile_sprites_to_draw.size() != 0) ViewportDrawTileSprites(&_vd.tile_sprites_to_draw);
ParentSpriteToDraw *psd_end = _vd.parent_sprites_to_draw.End();
for (ParentSpriteToDraw *it = _vd.parent_sprites_to_draw.Begin(); it != psd_end; it++) {
@@ -1611,7 +1611,7 @@ void ViewportDoDraw(const ViewPort *vp, int left, int top, int right, int bottom
vp->overlay->Draw(&dp);
}
- if (_vd.string_sprites_to_draw.Length() != 0) {
+ if (_vd.string_sprites_to_draw.size() != 0) {
/* translate to world coordinates */
dp.left = UnScaleByZoom(_vd.dpi.left, zoom);
dp.top = UnScaleByZoom(_vd.dpi.top, zoom);
diff --git a/src/widgets/dropdown.cpp b/src/widgets/dropdown.cpp
index f789b47b7..6acbd79c2 100644
--- a/src/widgets/dropdown.cpp
+++ b/src/widgets/dropdown.cpp
@@ -151,7 +151,7 @@ struct DropdownWindow : Window {
DropdownWindow(Window *parent, const DropDownList *list, int selected, int button, bool instant_close, const Point &position, const Dimension &size, Colours wi_colour, bool scroll)
: Window(&_dropdown_desc)
{
- assert(list->Length() > 0);
+ assert(list->size() > 0);
this->position = position;
@@ -180,8 +180,8 @@ struct DropdownWindow : Window {
}
/* Capacity is the average number of items visible */
- this->vscroll->SetCapacity(size.height * (uint16)list->Length() / list_height);
- this->vscroll->SetCount((uint16)list->Length());
+ this->vscroll->SetCapacity(size.height * (uint16)list->size() / list_height);
+ this->vscroll->SetCount((uint16)list->size());
this->parent_wnd_class = parent->window_class;
this->parent_wnd_num = parent->window_number;
@@ -418,7 +418,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->Length();
+ uint avg_height = height / list->size();
/* Check at least there is space for one item. */
assert(available_height >= avg_height);
@@ -514,7 +514,7 @@ void ShowDropDownMenu(Window *w, const StringID *strings, int selected, int butt
}
/* No entries in the list? */
- if (list->Length() == 0) {
+ if (list->size() == 0) {
delete list;
return;
}
diff --git a/src/window.cpp b/src/window.cpp
index 184b9940a..c6a9f1653 100644
--- a/src/window.cpp
+++ b/src/window.cpp
@@ -166,7 +166,7 @@ static int CDECL DescSorter(WindowDesc * const *a, WindowDesc * const *b)
void WindowDesc::SaveToConfig()
{
/* Sort the stuff to get a nice ini file on first write */
- QSortT(_window_descs->Begin(), _window_descs->Length(), DescSorter);
+ QSortT(_window_descs->Begin(), _window_descs->size(), DescSorter);
IniFile *ini = new IniFile();
ini->LoadFromDisk(_windows_file, NO_DIRECTORY);