mirror of https://github.com/OpenTTD/OpenTTD
Codechange: Replace SmallVector::Length() with std::vector::size()
parent
56ae855dc2
commit
a690936ed7
|
@ -160,8 +160,8 @@ class ReplaceVehicleWindow : public Window {
|
||||||
if (this->engines[0].NeedRebuild()) {
|
if (this->engines[0].NeedRebuild()) {
|
||||||
/* We need to rebuild the left engines list */
|
/* We need to rebuild the left engines list */
|
||||||
this->GenerateReplaceVehList(true);
|
this->GenerateReplaceVehList(true);
|
||||||
this->vscroll[0]->SetCount(this->engines[0].Length());
|
this->vscroll[0]->SetCount(this->engines[0].size());
|
||||||
if (this->reset_sel_engine && this->sel_engine[0] == INVALID_ENGINE && this->engines[0].Length() != 0) {
|
if (this->reset_sel_engine && this->sel_engine[0] == INVALID_ENGINE && this->engines[0].size() != 0) {
|
||||||
this->sel_engine[0] = this->engines[0][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. */
|
/* 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->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) {
|
if (this->reset_sel_engine && this->sel_engine[1] != INVALID_ENGINE) {
|
||||||
int position = 0;
|
int position = 0;
|
||||||
for (EngineID *it = this->engines[1].Begin(); it != this->engines[1].End(); ++it) {
|
for (EngineID *it = this->engines[1].Begin(); it != this->engines[1].End(); ++it) {
|
||||||
|
@ -384,7 +384,7 @@ public:
|
||||||
case WID_RV_RIGHT_MATRIX: {
|
case WID_RV_RIGHT_MATRIX: {
|
||||||
int side = (widget == WID_RV_LEFT_MATRIX) ? 0 : 1;
|
int side = (widget == WID_RV_LEFT_MATRIX) ? 0 : 1;
|
||||||
EngineID start = this->vscroll[side]->GetPosition(); // what is the offset for the start (scrolling)
|
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 */
|
/* Do the actual drawing */
|
||||||
DrawEngineList((VehicleType)this->window_number, r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, r.top + WD_FRAMERECT_TOP,
|
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;
|
click_side = 1;
|
||||||
}
|
}
|
||||||
uint i = this->vscroll[click_side]->GetScrolledRowFromWidget(pt.y, this, widget);
|
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;
|
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
|
if (e == this->sel_engine[click_side]) break; // we clicked the one we already selected
|
||||||
|
|
|
@ -153,7 +153,7 @@ public:
|
||||||
this->bridges->NeedResort();
|
this->bridges->NeedResort();
|
||||||
this->SortBridgeList();
|
this->SortBridgeList();
|
||||||
|
|
||||||
this->vscroll->SetCount(bl->Length());
|
this->vscroll->SetCount(bl->size());
|
||||||
}
|
}
|
||||||
|
|
||||||
~BuildBridgeWindow()
|
~BuildBridgeWindow()
|
||||||
|
@ -186,7 +186,7 @@ public:
|
||||||
case WID_BBS_BRIDGE_LIST: {
|
case WID_BBS_BRIDGE_LIST: {
|
||||||
Dimension sprite_dim = {0, 0}; // Biggest bridge sprite dimension
|
Dimension sprite_dim = {0, 0}; // Biggest bridge sprite dimension
|
||||||
Dimension text_dim = {0, 0}; // Biggest text 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;
|
const BridgeSpec *b = this->bridges->Get(i)->spec;
|
||||||
sprite_dim = maxdim(sprite_dim, GetSpriteSize(b->sprite));
|
sprite_dim = maxdim(sprite_dim, GetSpriteSize(b->sprite));
|
||||||
|
|
||||||
|
@ -226,7 +226,7 @@ public:
|
||||||
|
|
||||||
case WID_BBS_BRIDGE_LIST: {
|
case WID_BBS_BRIDGE_LIST: {
|
||||||
uint y = r.top;
|
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;
|
const BridgeSpec *b = this->bridges->Get(i)->spec;
|
||||||
|
|
||||||
SetDParam(2, this->bridges->Get(i)->cost);
|
SetDParam(2, this->bridges->Get(i)->cost);
|
||||||
|
@ -246,7 +246,7 @@ public:
|
||||||
EventState OnKeyPress(WChar key, uint16 keycode) override
|
EventState OnKeyPress(WChar key, uint16 keycode) override
|
||||||
{
|
{
|
||||||
const uint8 i = keycode - '1';
|
const uint8 i = keycode - '1';
|
||||||
if (i < 9 && i < this->bridges->Length()) {
|
if (i < 9 && i < this->bridges->size()) {
|
||||||
/* Build the requested bridge */
|
/* Build the requested bridge */
|
||||||
this->BuildBridge(i);
|
this->BuildBridge(i);
|
||||||
delete this;
|
delete this;
|
||||||
|
@ -261,7 +261,7 @@ public:
|
||||||
default: break;
|
default: break;
|
||||||
case WID_BBS_BRIDGE_LIST: {
|
case WID_BBS_BRIDGE_LIST: {
|
||||||
uint i = this->vscroll->GetScrolledRowFromWidget(pt.y, this, 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);
|
this->BuildBridge(i);
|
||||||
delete this;
|
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);
|
new BuildBridgeWindow(&_build_bridge_desc, start, end, type, bl);
|
||||||
} else {
|
} else {
|
||||||
delete bl;
|
delete bl;
|
||||||
|
|
|
@ -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 };
|
static const int sprite_y_offsets[] = { -1, -1, -2, -2 };
|
||||||
|
|
||||||
/* Obligatory sanity checks! */
|
/* Obligatory sanity checks! */
|
||||||
assert(max <= eng_list->Length());
|
assert(max <= eng_list->size());
|
||||||
|
|
||||||
bool rtl = _current_text_dir == TD_RTL;
|
bool rtl = _current_text_dir == TD_RTL;
|
||||||
int step_size = GetEngineListHeight(type);
|
int step_size = GetEngineListHeight(type);
|
||||||
|
@ -1110,7 +1110,7 @@ struct BuildVehicleWindow : Window {
|
||||||
this->eng_list.ForceRebuild();
|
this->eng_list.ForceRebuild();
|
||||||
this->GenerateBuildList(); // generate the list, since we need it in the next line
|
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 */
|
/* 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]);
|
this->SelectEngine(this->eng_list[0]);
|
||||||
} else {
|
} else {
|
||||||
this->SelectEngine(INVALID_ENGINE);
|
this->SelectEngine(INVALID_ENGINE);
|
||||||
|
@ -1205,7 +1205,7 @@ struct BuildVehicleWindow : Window {
|
||||||
void FilterEngineList()
|
void FilterEngineList()
|
||||||
{
|
{
|
||||||
this->eng_list.Filter(this->cargo_filter[this->cargo_filter_criteria]);
|
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);
|
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
|
} 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]);
|
this->SelectEngine(this->eng_list[0]);
|
||||||
|
@ -1388,7 +1388,7 @@ struct BuildVehicleWindow : Window {
|
||||||
|
|
||||||
case WID_BV_LIST: {
|
case WID_BV_LIST: {
|
||||||
uint i = this->vscroll->GetScrolledRowFromWidget(pt.y, this, 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->SelectEngine((i < num_items) ? this->eng_list[i] : INVALID_ENGINE);
|
||||||
this->SetDirty();
|
this->SetDirty();
|
||||||
if (_ctrl_pressed) {
|
if (_ctrl_pressed) {
|
||||||
|
@ -1529,7 +1529,7 @@ struct BuildVehicleWindow : Window {
|
||||||
{
|
{
|
||||||
switch (widget) {
|
switch (widget) {
|
||||||
case WID_BV_LIST:
|
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;
|
break;
|
||||||
|
|
||||||
case WID_BV_SORT_ASCENDING_DESCENDING:
|
case WID_BV_SORT_ASCENDING_DESCENDING:
|
||||||
|
@ -1541,7 +1541,7 @@ struct BuildVehicleWindow : Window {
|
||||||
void OnPaint() override
|
void OnPaint() override
|
||||||
{
|
{
|
||||||
this->GenerateBuildList();
|
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);
|
this->SetWidgetsDisabledState(this->sel_engine == INVALID_ENGINE, WID_BV_SHOW_HIDE, WID_BV_BUILD, WID_BV_RENAME, WIDGET_LIST_END);
|
||||||
|
|
||||||
|
|
|
@ -686,7 +686,7 @@ private:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
this->rows = this->groups.Length();
|
this->rows = this->groups.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
this->vscroll->SetCount(this->rows);
|
this->vscroll->SetCount(this->rows);
|
||||||
|
@ -902,7 +902,7 @@ public:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} 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) {
|
for (uint i = this->vscroll->GetPosition(); i < max; ++i) {
|
||||||
const Group *g = this->groups[i];
|
const Group *g = this->groups[i];
|
||||||
SetDParam(0, g->index);
|
SetDParam(0, g->index);
|
||||||
|
@ -942,7 +942,7 @@ public:
|
||||||
this->groups.ForceRebuild();
|
this->groups.ForceRebuild();
|
||||||
this->BuildGroupList((CompanyID)this->window_number);
|
this->BuildGroupList((CompanyID)this->window_number);
|
||||||
|
|
||||||
if (this->groups.Length() > 0) {
|
if (this->groups.size() > 0) {
|
||||||
this->sel = this->groups[0]->index;
|
this->sel = this->groups[0]->index;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1029,7 +1029,7 @@ public:
|
||||||
|
|
||||||
if (!Group::IsValidID(this->sel)) {
|
if (!Group::IsValidID(this->sel)) {
|
||||||
this->sel = INVALID_GROUP;
|
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();
|
this->SetDirty();
|
||||||
|
|
|
@ -552,16 +552,16 @@ DEF_CONSOLE_CMD(ConUnBan)
|
||||||
|
|
||||||
/* Try by IP. */
|
/* Try by IP. */
|
||||||
uint index;
|
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;
|
if (strcmp(_network_ban_list[index], argv[1]) == 0) break;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Try by index. */
|
/* Try by index. */
|
||||||
if (index >= _network_ban_list.Length()) {
|
if (index >= _network_ban_list.size()) {
|
||||||
index = atoi(argv[1]) - 1U; // let it wrap
|
index = atoi(argv[1]) - 1U; // let it wrap
|
||||||
}
|
}
|
||||||
|
|
||||||
if (index < _network_ban_list.Length()) {
|
if (index < _network_ban_list.size()) {
|
||||||
char msg[64];
|
char msg[64];
|
||||||
seprintf(msg, lastof(msg), "Unbanned %s", _network_ban_list[index]);
|
seprintf(msg, lastof(msg), "Unbanned %s", _network_ban_list[index]);
|
||||||
IConsolePrint(CC_DEFAULT, msg);
|
IConsolePrint(CC_DEFAULT, msg);
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
{
|
{
|
||||||
PoolVector *pools = PoolBase::GetPools();
|
PoolVector *pools = PoolBase::GetPools();
|
||||||
pools->Erase(pools->Find(this));
|
pools->Erase(pools->Find(this));
|
||||||
if (pools->Length() == 0) delete pools;
|
if (pools->size() == 0) delete pools;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -73,7 +73,7 @@ private:
|
||||||
if (!this->data[index].valid) return index;
|
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);
|
this->data.Resize(index + 1);
|
||||||
}
|
}
|
||||||
return index;
|
return index;
|
||||||
|
|
|
@ -217,16 +217,6 @@ public:
|
||||||
return is_member;
|
return is_member;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 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)
|
* Get the pointer to the first item (const)
|
||||||
*
|
*
|
||||||
|
|
|
@ -398,7 +398,7 @@ struct DepotWindow : Window {
|
||||||
uint16 rows_in_display = wid->current_y / wid->resize_y;
|
uint16 rows_in_display = wid->current_y / wid->resize_y;
|
||||||
|
|
||||||
uint16 num = this->vscroll->GetPosition() * this->num_columns;
|
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;
|
int y;
|
||||||
for (y = r.top + 1; num < maxval; y += this->resize.step_height) { // Draw the rows
|
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++) {
|
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. */
|
/* Draw the train wagons without an engine in front. */
|
||||||
for (; num < maxval; num++, y += this->resize.step_height) {
|
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);
|
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;
|
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 */
|
/* Clicking on 'line' / 'block' without a vehicle */
|
||||||
if (this->type == VEH_TRAIN) {
|
if (this->type == VEH_TRAIN) {
|
||||||
/* End the dragging */
|
/* End the dragging */
|
||||||
|
@ -478,12 +478,12 @@ struct DepotWindow : Window {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wagon = false;
|
bool wagon = false;
|
||||||
if (this->vehicle_list.Length() > pos) {
|
if (this->vehicle_list.size() > pos) {
|
||||||
*veh = this->vehicle_list[pos];
|
*veh = this->vehicle_list[pos];
|
||||||
/* Skip vehicles that are scrolled off the list */
|
/* Skip vehicles that are scrolled off the list */
|
||||||
if (this->type == VEH_TRAIN) x += this->hscroll->GetPosition();
|
if (this->type == VEH_TRAIN) x += this->hscroll->GetPosition();
|
||||||
} else {
|
} else {
|
||||||
pos -= this->vehicle_list.Length();
|
pos -= this->vehicle_list.size();
|
||||||
*veh = this->wagon_list[pos];
|
*veh = this->wagon_list[pos];
|
||||||
/* free wagons don't have an initial loco. */
|
/* free wagons don't have an initial loco. */
|
||||||
x -= ScaleGUITrad(VEHICLEINFO_FULL_VEHICLE_WIDTH);
|
x -= ScaleGUITrad(VEHICLEINFO_FULL_VEHICLE_WIDTH);
|
||||||
|
@ -726,7 +726,7 @@ struct DepotWindow : Window {
|
||||||
/* determine amount of items for scroller */
|
/* determine amount of items for scroller */
|
||||||
if (this->type == VEH_TRAIN) {
|
if (this->type == VEH_TRAIN) {
|
||||||
uint max_width = ScaleGUITrad(VEHICLEINFO_FULL_VEHICLE_WIDTH);
|
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;
|
uint width = 0;
|
||||||
for (const Train *v = Train::From(this->vehicle_list[num]); v != NULL; v = v->Next()) {
|
for (const Train *v = Train::From(this->vehicle_list[num]); v != NULL; v = v->Next()) {
|
||||||
width += v->GetDisplayImageWidth();
|
width += v->GetDisplayImageWidth();
|
||||||
|
@ -734,11 +734,11 @@ struct DepotWindow : Window {
|
||||||
max_width = max(max_width, width);
|
max_width = max(max_width, width);
|
||||||
}
|
}
|
||||||
/* Always have 1 empty row, so people can change the setting of the train */
|
/* 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 */
|
/* 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));
|
this->hscroll->SetCount(max_width + ScaleGUITrad(2 * VEHICLEINFO_FULL_VEHICLE_WIDTH + 1));
|
||||||
} else {
|
} 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. */
|
/* Setup disabled buttons. */
|
||||||
|
@ -811,7 +811,7 @@ struct DepotWindow : Window {
|
||||||
|
|
||||||
case WID_D_SELL_ALL:
|
case WID_D_SELL_ALL:
|
||||||
/* Only open the confirmation window if there are anything to sell */
|
/* 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;
|
TileIndex tile = this->window_number;
|
||||||
byte vehtype = this->type;
|
byte vehtype = this->type;
|
||||||
|
|
||||||
|
|
|
@ -547,7 +547,7 @@ void SetupEngines()
|
||||||
DeleteWindowByClass(WC_ENGINE_PREVIEW);
|
DeleteWindowByClass(WC_ENGINE_PREVIEW);
|
||||||
_engine_pool.CleanPool();
|
_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();
|
const EngineIDMapping *end = _engine_mngr.End();
|
||||||
uint index = 0;
|
uint index = 0;
|
||||||
for (const EngineIDMapping *eid = _engine_mngr.Begin(); eid != end; eid++, index++) {
|
for (const EngineIDMapping *eid = _engine_mngr.Begin(); eid != end; eid++, index++) {
|
||||||
|
|
|
@ -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)
|
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)
|
/* 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 */
|
* generally, do not sort if there are less than 2 items */
|
||||||
if (size < 2) return;
|
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)
|
void EngList_SortPartial(GUIEngineList *el, EngList_SortTypeFunction compare, uint begin, uint num_items)
|
||||||
{
|
{
|
||||||
if (num_items < 2) return;
|
if (num_items < 2) return;
|
||||||
assert(begin < el->Length());
|
assert(begin < el->size());
|
||||||
assert(begin + num_items <= el->Length());
|
assert(begin + num_items <= el->size());
|
||||||
QSortT(el->Get(begin), num_items, compare);
|
QSortT(el->Get(begin), num_items, compare);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -380,7 +380,7 @@ static void FiosGetFileList(SaveLoadOperation fop, fios_getlist_callback_proc *c
|
||||||
{
|
{
|
||||||
SortingBits order = _savegame_sort_order;
|
SortingBits order = _savegame_sort_order;
|
||||||
_savegame_sort_order = SORT_BY_NAME | SORT_ASCENDING;
|
_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;
|
_savegame_sort_order = order;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -129,7 +129,7 @@ public:
|
||||||
*/
|
*/
|
||||||
inline uint Length() const
|
inline uint Length() const
|
||||||
{
|
{
|
||||||
return this->files.Length();
|
return this->files.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -212,7 +212,7 @@ struct StringNameWriter : HeaderWriter {
|
||||||
|
|
||||||
void WriteStringID(const char *name, int stringid)
|
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)
|
void Finalise(const StringData &data)
|
||||||
|
@ -340,7 +340,7 @@ GameStrings *_current_data = NULL;
|
||||||
*/
|
*/
|
||||||
const char *GetGameStringPtr(uint id)
|
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];
|
return _current_data->cur_language->lines[id];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -509,7 +509,7 @@ int DrawString(int left, int right, int top, const char *str, TextColour colour,
|
||||||
}
|
}
|
||||||
|
|
||||||
Layouter layout(str, INT32_MAX, colour, fontsize);
|
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);
|
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));
|
GetString(buffer, str, lastof(buffer));
|
||||||
|
|
||||||
Layouter layout(buffer, maxw);
|
Layouter layout(buffer, maxw);
|
||||||
return layout.Length();
|
return layout.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -200,7 +200,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Fill ICU's FontRuns with the right data. */
|
/* 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++) {
|
for (FontMap::iterator iter = fontMapping.Begin(); iter != fontMapping.End(); iter++) {
|
||||||
runs.add(iter->second, iter->first);
|
runs.add(iter->second, iter->first);
|
||||||
}
|
}
|
||||||
|
@ -432,7 +432,7 @@ int FallbackParagraphLayout::FallbackLine::GetLeading() const
|
||||||
*/
|
*/
|
||||||
int FallbackParagraphLayout::FallbackLine::GetWidth() 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.
|
* 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
|
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++;
|
this->buffer++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (l->Length() == 0 || last_char - begin != 0) {
|
if (l->size() == 0 || last_char - begin != 0) {
|
||||||
int w = l->GetWidth();
|
int w = l->GetWidth();
|
||||||
*l->Append() = new FallbackVisualRun(iter->second, begin, last_char - begin, w);
|
*l->Append() = new FallbackVisualRun(iter->second, begin, last_char - begin, w);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1183,7 +1183,7 @@ public:
|
||||||
uint text_left = rtl ? r.left + WD_FRAMERECT_LEFT : r.right - WD_FRAMERECT_LEFT - this->text_width;
|
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;
|
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];
|
const Company *c = this->companies[i];
|
||||||
DrawString(ordinal_left, ordinal_right, y, i + STR_ORDINAL_NUMBER_1ST, i == 0 ? TC_WHITE : TC_YELLOW);
|
DrawString(ordinal_left, ordinal_right, y, i + STR_ORDINAL_NUMBER_1ST, i == 0 ? TC_WHITE : TC_YELLOW);
|
||||||
|
|
||||||
|
|
|
@ -460,8 +460,8 @@ public:
|
||||||
if (IsDefaultGroupID(this->vli.index) || IsAllGroupID(this->vli.index)) {
|
if (IsDefaultGroupID(this->vli.index) || IsAllGroupID(this->vli.index)) {
|
||||||
SetDParam(0, STR_COMPANY_NAME);
|
SetDParam(0, STR_COMPANY_NAME);
|
||||||
SetDParam(1, this->vli.company);
|
SetDParam(1, this->vli.company);
|
||||||
SetDParam(2, this->vehicles.Length());
|
SetDParam(2, this->vehicles.size());
|
||||||
SetDParam(3, this->vehicles.Length());
|
SetDParam(3, this->vehicles.size());
|
||||||
} else {
|
} else {
|
||||||
const Group *g = Group::Get(this->vli.index);
|
const Group *g = Group::Get(this->vli.index);
|
||||||
|
|
||||||
|
@ -483,17 +483,17 @@ public:
|
||||||
|
|
||||||
this->BuildGroupList(this->owner);
|
this->BuildGroupList(this->owner);
|
||||||
|
|
||||||
this->group_sb->SetCount(this->groups.Length());
|
this->group_sb->SetCount(this->groups.size());
|
||||||
this->vscroll->SetCount(this->vehicles.Length());
|
this->vscroll->SetCount(this->vehicles.size());
|
||||||
|
|
||||||
/* The drop down menu is out, *but* it may not be used, retract it. */
|
/* 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);
|
this->RaiseWidget(WID_GL_MANAGE_VEHICLES_DROPDOWN);
|
||||||
HideDropDownMenu(this);
|
HideDropDownMenu(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Disable all lists management button when the list is empty */
|
/* 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_STOP_ALL,
|
||||||
WID_GL_START_ALL,
|
WID_GL_START_ALL,
|
||||||
WID_GL_MANAGE_VEHICLES_DROPDOWN,
|
WID_GL_MANAGE_VEHICLES_DROPDOWN,
|
||||||
|
@ -544,7 +544,7 @@ public:
|
||||||
Money this_year = 0;
|
Money this_year = 0;
|
||||||
Money last_year = 0;
|
Money last_year = 0;
|
||||||
uint32 occupancy = 0;
|
uint32 occupancy = 0;
|
||||||
uint32 vehicle_count = this->vehicles.Length();
|
uint32 vehicle_count = this->vehicles.size();
|
||||||
|
|
||||||
for (uint i = 0; i < vehicle_count; i++) {
|
for (uint i = 0; i < vehicle_count; i++) {
|
||||||
const Vehicle *v = this->vehicles[i];
|
const Vehicle *v = this->vehicles[i];
|
||||||
|
@ -580,7 +580,7 @@ public:
|
||||||
|
|
||||||
case WID_GL_LIST_GROUP: {
|
case WID_GL_LIST_GROUP: {
|
||||||
int y1 = r.top + WD_FRAMERECT_TOP;
|
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) {
|
for (int i = this->group_sb->GetPosition(); i < max; ++i) {
|
||||||
const Group *g = this->groups[i];
|
const Group *g = this->groups[i];
|
||||||
|
|
||||||
|
@ -590,7 +590,7 @@ public:
|
||||||
|
|
||||||
y1 += this->tiny_step_height;
|
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);
|
DrawGroupInfo(y1, r.left, r.right, NEW_GROUP);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -604,7 +604,7 @@ public:
|
||||||
if (this->vli.index != ALL_GROUP) {
|
if (this->vli.index != ALL_GROUP) {
|
||||||
/* Mark vehicles which are in sub-groups */
|
/* Mark vehicles which are in sub-groups */
|
||||||
int y = r.top;
|
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) {
|
for (uint i = this->vscroll->GetPosition(); i < max; ++i) {
|
||||||
const Vehicle *v = this->vehicles[i];
|
const Vehicle *v = this->vehicles[i];
|
||||||
if (v->group_id != this->vli.index) {
|
if (v->group_id != this->vli.index) {
|
||||||
|
@ -658,7 +658,7 @@ public:
|
||||||
|
|
||||||
case WID_GL_LIST_GROUP: { // Matrix Group
|
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);
|
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;
|
this->group_sel = this->vli.index = this->groups[id_g]->index;
|
||||||
|
|
||||||
|
@ -671,7 +671,7 @@ public:
|
||||||
|
|
||||||
case WID_GL_LIST_VEHICLE: { // Matrix Vehicle
|
case WID_GL_LIST_VEHICLE: { // Matrix Vehicle
|
||||||
uint id_v = this->vscroll->GetScrolledRowFromWidget(pt.y, this, WID_GL_LIST_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];
|
const Vehicle *v = this->vehicles[id_v];
|
||||||
if (VehicleClicked(v)) break;
|
if (VehicleClicked(v)) break;
|
||||||
|
@ -749,7 +749,7 @@ public:
|
||||||
|
|
||||||
case WID_GL_LIST_GROUP: { // Matrix group
|
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);
|
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) {
|
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));
|
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();
|
this->SetDirty();
|
||||||
|
|
||||||
uint id_g = this->group_sb->GetScrolledRowFromWidget(pt.y, this, WID_GL_LIST_GROUP, 0, this->tiny_step_height);
|
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);
|
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;
|
break;
|
||||||
|
@ -795,7 +795,7 @@ public:
|
||||||
this->SetDirty();
|
this->SetDirty();
|
||||||
|
|
||||||
uint id_v = this->vscroll->GetScrolledRowFromWidget(pt.y, this, WID_GL_LIST_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];
|
const Vehicle *v = this->vehicles[id_v];
|
||||||
if (!VehicleClicked(v) && vindex == v->index) {
|
if (!VehicleClicked(v) && vindex == v->index) {
|
||||||
|
@ -834,7 +834,7 @@ public:
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WID_GL_MANAGE_VEHICLES_DROPDOWN:
|
case WID_GL_MANAGE_VEHICLES_DROPDOWN:
|
||||||
assert(this->vehicles.Length() != 0);
|
assert(this->vehicles.size() != 0);
|
||||||
|
|
||||||
switch (index) {
|
switch (index) {
|
||||||
case ADI_REPLACE: // Replace window
|
case ADI_REPLACE: // Replace window
|
||||||
|
@ -895,7 +895,7 @@ public:
|
||||||
|
|
||||||
case WID_GL_LIST_GROUP: { // ... the list of custom groups.
|
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);
|
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;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -203,7 +203,7 @@ const char *SaveKeycodes(const Hotkey *hotkey)
|
||||||
{
|
{
|
||||||
static char buf[128];
|
static char buf[128];
|
||||||
buf[0] = '\0';
|
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]);
|
const char *str = KeycodeToString(hotkey->keycodes[i]);
|
||||||
if (i > 0) strecat(buf, ",", lastof(buf));
|
if (i > 0) strecat(buf, ",", lastof(buf));
|
||||||
strecat(buf, str, lastof(buf));
|
strecat(buf, str, lastof(buf));
|
||||||
|
|
|
@ -1211,7 +1211,7 @@ protected:
|
||||||
|
|
||||||
this->industries.shrink_to_fit();
|
this->industries.shrink_to_fit();
|
||||||
this->industries.RebuildDone();
|
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;
|
if (!this->industries.Sort()) return;
|
||||||
|
@ -1372,11 +1372,11 @@ public:
|
||||||
case WID_ID_INDUSTRY_LIST: {
|
case WID_ID_INDUSTRY_LIST: {
|
||||||
int n = 0;
|
int n = 0;
|
||||||
int y = r.top + WD_FRAMERECT_TOP;
|
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);
|
DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, y, STR_INDUSTRY_DIRECTORY_NONE);
|
||||||
break;
|
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]));
|
DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, y, this->GetIndustryString(this->industries[i]));
|
||||||
|
|
||||||
y += this->resize.step_height;
|
y += this->resize.step_height;
|
||||||
|
@ -1411,7 +1411,7 @@ public:
|
||||||
|
|
||||||
case WID_ID_INDUSTRY_LIST: {
|
case WID_ID_INDUSTRY_LIST: {
|
||||||
Dimension d = GetStringBoundingBox(STR_INDUSTRY_DIRECTORY_NONE);
|
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])));
|
d = maxdim(d, GetStringBoundingBox(this->GetIndustryString(this->industries[i])));
|
||||||
}
|
}
|
||||||
resize->height = d.height;
|
resize->height = d.height;
|
||||||
|
@ -1439,7 +1439,7 @@ public:
|
||||||
|
|
||||||
case WID_ID_INDUSTRY_LIST: {
|
case WID_ID_INDUSTRY_LIST: {
|
||||||
uint p = this->vscroll->GetScrolledRowFromWidget(pt.y, this, WID_ID_INDUSTRY_LIST, WD_FRAMERECT_TOP);
|
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) {
|
if (_ctrl_pressed) {
|
||||||
ShowExtraViewPortWindow(this->industries[p]->location.tile);
|
ShowExtraViewPortWindow(this->industries[p]->location.tile);
|
||||||
} else {
|
} else {
|
||||||
|
@ -2589,7 +2589,7 @@ struct IndustryCargoesWindow : public Window {
|
||||||
|
|
||||||
const NWidgetBase *nwp = this->GetWidget<NWidgetBase>(WID_IC_PANEL);
|
const NWidgetBase *nwp = this->GetWidget<NWidgetBase>(WID_IC_PANEL);
|
||||||
int vpos = -this->vscroll->GetPosition() * nwp->resize_y;
|
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;
|
int row_height = (i == 0) ? CargoesField::small_height : CargoesField::normal_height;
|
||||||
if (vpos + row_height >= 0) {
|
if (vpos + row_height >= 0) {
|
||||||
int xpos = left_pos;
|
int xpos = left_pos;
|
||||||
|
@ -2631,7 +2631,7 @@ struct IndustryCargoesWindow : public Window {
|
||||||
if (pt.y < vpos) return false;
|
if (pt.y < vpos) return false;
|
||||||
|
|
||||||
int row = (pt.y - vpos) / CargoesField::normal_height; // row is relative to row 1.
|
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
|
vpos = pt.y - vpos - row * CargoesField::normal_height; // Position in the row + 1 field
|
||||||
row++; // rebase row to match index of this->fields.
|
row++; // rebase row to match index of this->fields.
|
||||||
|
|
||||||
|
@ -2710,7 +2710,7 @@ struct IndustryCargoesWindow : public Window {
|
||||||
FOR_ALL_SORTED_STANDARD_CARGOSPECS(cs) {
|
FOR_ALL_SORTED_STANDARD_CARGOSPECS(cs) {
|
||||||
*lst->Append() = new DropDownListStringItem(cs->name, cs->Index(), false);
|
*lst->Append() = new DropDownListStringItem(cs->name, cs->Index(), false);
|
||||||
}
|
}
|
||||||
if (lst->Length() == 0) {
|
if (lst->size() == 0) {
|
||||||
delete lst;
|
delete lst;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -2727,7 +2727,7 @@ struct IndustryCargoesWindow : public Window {
|
||||||
if (!indsp->enabled) continue;
|
if (!indsp->enabled) continue;
|
||||||
*lst->Append() = new DropDownListStringItem(indsp->name, ind, false);
|
*lst->Append() = new DropDownListStringItem(indsp->name, ind, false);
|
||||||
}
|
}
|
||||||
if (lst->Length() == 0) {
|
if (lst->size() == 0) {
|
||||||
delete lst;
|
delete lst;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -496,7 +496,7 @@ public:
|
||||||
* Get the current size of the component.
|
* Get the current size of the component.
|
||||||
* @return Size.
|
* @return Size.
|
||||||
*/
|
*/
|
||||||
inline uint Size() const { return this->nodes.Length(); }
|
inline uint Size() const { return this->nodes.size(); }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get date of last compression.
|
* Get date of last compression.
|
||||||
|
|
|
@ -686,7 +686,7 @@ static void MidiThreadProc(void *)
|
||||||
size_t preload_bytes = 0;
|
size_t preload_bytes = 0;
|
||||||
for (size_t bl = 0; bl < current_file.blocks.size(); bl++) {
|
for (size_t bl = 0; bl < current_file.blocks.size(); bl++) {
|
||||||
MidiFile::DataBlock &block = current_file.blocks[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 (block.ticktime >= current_segment.start) {
|
||||||
if (current_segment.loop) {
|
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);
|
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));
|
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();
|
byte *data = block.data.Begin();
|
||||||
size_t remaining = block.data.Length();
|
size_t remaining = block.data.size();
|
||||||
byte last_status = 0;
|
byte last_status = 0;
|
||||||
while (remaining > 0) {
|
while (remaining > 0) {
|
||||||
/* MidiFile ought to have converted everything out of running status,
|
/* MidiFile ought to have converted everything out of running status,
|
||||||
|
|
|
@ -330,14 +330,14 @@ static bool FixupMidiData(MidiFile &target)
|
||||||
uint32 last_ticktime = 0;
|
uint32 last_ticktime = 0;
|
||||||
for (size_t i = 0; i < target.blocks.size(); i++) {
|
for (size_t i = 0; i < target.blocks.size(); i++) {
|
||||||
MidiFile::DataBlock &block = target.blocks[i];
|
MidiFile::DataBlock &block = target.blocks[i];
|
||||||
if (block.data.Length() == 0) {
|
if (block.data.size() == 0) {
|
||||||
continue;
|
continue;
|
||||||
} else if (block.ticktime > last_ticktime || merged_blocks.size() == 0) {
|
} else if (block.ticktime > last_ticktime || merged_blocks.size() == 0) {
|
||||||
merged_blocks.push_back(block);
|
merged_blocks.push_back(block);
|
||||||
last_ticktime = block.ticktime;
|
last_ticktime = block.ticktime;
|
||||||
} else {
|
} else {
|
||||||
byte *datadest = merged_blocks.back().data.Append(block.data.Length());
|
byte *datadest = merged_blocks.back().data.Append(block.data.size());
|
||||||
memcpy(datadest, block.data.Begin(), block.data.Length());
|
memcpy(datadest, block.data.Begin(), block.data.size());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
std::swap(merged_blocks, target.blocks);
|
std::swap(merged_blocks, target.blocks);
|
||||||
|
|
|
@ -187,7 +187,7 @@ void CALLBACK TimerCallback(UINT uTimerID, UINT, DWORD_PTR dwUser, DWORD_PTR, DW
|
||||||
uint preload_bytes = 0;
|
uint preload_bytes = 0;
|
||||||
for (size_t bl = 0; bl < _midi.current_file.blocks.size(); bl++) {
|
for (size_t bl = 0; bl < _midi.current_file.blocks.size(); bl++) {
|
||||||
MidiFile::DataBlock &block = _midi.current_file.blocks[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 (block.ticktime >= _midi.current_segment.start) {
|
||||||
if (_midi.current_segment.loop) {
|
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);
|
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();
|
byte *data = block.data.Begin();
|
||||||
size_t remaining = block.data.Length();
|
size_t remaining = block.data.size();
|
||||||
byte last_status = 0;
|
byte last_status = 0;
|
||||||
while (remaining > 0) {
|
while (remaining > 0) {
|
||||||
/* MidiFile ought to have converted everything out of running status,
|
/* MidiFile ought to have converted everything out of running status,
|
||||||
|
|
|
@ -297,7 +297,7 @@ int NetworkHTTPSocketHandler::Receive()
|
||||||
/* static */ void NetworkHTTPSocketHandler::HTTPReceive()
|
/* static */ void NetworkHTTPSocketHandler::HTTPReceive()
|
||||||
{
|
{
|
||||||
/* No connections, just bail out. */
|
/* No connections, just bail out. */
|
||||||
if (_http_connections.Length() == 0) return;
|
if (_http_connections.size() == 0) return;
|
||||||
|
|
||||||
fd_set read_fd;
|
fd_set read_fd;
|
||||||
struct timeval tv;
|
struct timeval tv;
|
||||||
|
|
|
@ -140,7 +140,7 @@ public:
|
||||||
*/
|
*/
|
||||||
static bool Listen(uint16 port)
|
static bool Listen(uint16 port)
|
||||||
{
|
{
|
||||||
assert(sockets.Length() == 0);
|
assert(sockets.size() == 0);
|
||||||
|
|
||||||
NetworkAddressList addresses;
|
NetworkAddressList addresses;
|
||||||
GetBindAddresses(&addresses, port);
|
GetBindAddresses(&addresses, port);
|
||||||
|
@ -149,7 +149,7 @@ public:
|
||||||
address->Listen(SOCK_STREAM, &sockets);
|
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");
|
DEBUG(net, 0, "[server] could not start network: could not create listening socket");
|
||||||
NetworkError(STR_NETWORK_ERROR_SERVER_START);
|
NetworkError(STR_NETWORK_ERROR_SERVER_START);
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -51,7 +51,7 @@ bool NetworkUDPSocketHandler::Listen()
|
||||||
addr->Listen(SOCK_DGRAM, &this->sockets);
|
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)
|
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++) {
|
for (SocketList::iterator s = this->sockets.Begin(); s != this->sockets.End(); s++) {
|
||||||
/* Make a local copy because if we resolve it we cannot
|
/* Make a local copy because if we resolve it we cannot
|
||||||
|
|
|
@ -637,7 +637,7 @@ void GetBindAddresses(NetworkAddressList *addresses, uint16 port)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* No address, so bind to everything. */
|
/* No address, so bind to everything. */
|
||||||
if (addresses->Length() == 0) {
|
if (addresses->size() == 0) {
|
||||||
*addresses->Append() = NetworkAddress("", port);
|
*addresses->Append() = NetworkAddress("", port);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -246,12 +246,12 @@ void ClientNetworkContentSocketHandler::RequestContentList(ContentVector *cv, bo
|
||||||
|
|
||||||
this->Connect();
|
this->Connect();
|
||||||
|
|
||||||
assert(cv->Length() < 255);
|
assert(cv->size() < 255);
|
||||||
assert(cv->Length() < (SEND_MTU - sizeof(PacketSize) - sizeof(byte) - sizeof(uint8)) /
|
assert(cv->size() < (SEND_MTU - sizeof(PacketSize) - sizeof(byte) - sizeof(uint8)) /
|
||||||
(sizeof(uint8) + sizeof(uint32) + (send_md5sum ? /*sizeof(ContentInfo::md5sum)*/16 : 0)));
|
(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);
|
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++) {
|
for (ContentIterator iter = cv->Begin(); iter != cv->End(); iter++) {
|
||||||
const ContentInfo *ci = *iter;
|
const ContentInfo *ci = *iter;
|
||||||
|
@ -304,7 +304,7 @@ void ClientNetworkContentSocketHandler::DownloadSelectedContent(uint &files, uin
|
||||||
bytes += ci->filesize;
|
bytes += ci->filesize;
|
||||||
}
|
}
|
||||||
|
|
||||||
files = content.Length();
|
files = content.size();
|
||||||
|
|
||||||
/* If there's nothing to download, do nothing. */
|
/* If there's nothing to download, do nothing. */
|
||||||
if (files == 0) return;
|
if (files == 0) return;
|
||||||
|
@ -322,7 +322,7 @@ void ClientNetworkContentSocketHandler::DownloadSelectedContent(uint &files, uin
|
||||||
*/
|
*/
|
||||||
void ClientNetworkContentSocketHandler::DownloadSelectedContentHTTP(const ContentIDList &content)
|
void ClientNetworkContentSocketHandler::DownloadSelectedContentHTTP(const ContentIDList &content)
|
||||||
{
|
{
|
||||||
uint count = content.Length();
|
uint count = content.size();
|
||||||
|
|
||||||
/* Allocate memory for the whole request.
|
/* Allocate memory for the whole request.
|
||||||
* Requests are "id\nid\n..." (as strings), so assume the maximum ID,
|
* 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)
|
void ClientNetworkContentSocketHandler::DownloadSelectedContentFallback(const ContentIDList &content)
|
||||||
{
|
{
|
||||||
uint count = content.Length();
|
uint count = content.size();
|
||||||
const ContentID *content_ids = content.Begin();
|
const ContentID *content_ids = content.Begin();
|
||||||
this->Connect();
|
this->Connect();
|
||||||
|
|
||||||
|
@ -607,7 +607,7 @@ void ClientNetworkContentSocketHandler::OnReceiveData(const char *data, size_t l
|
||||||
this->AfterDownload();
|
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
|
/* It's not a real failure, but if there's
|
||||||
* nothing more to download it helps with
|
* nothing more to download it helps with
|
||||||
* cleaning up the stuff we allocated. */
|
* cleaning up the stuff we allocated. */
|
||||||
|
@ -653,7 +653,7 @@ void ClientNetworkContentSocketHandler::OnReceiveData(const char *data, size_t l
|
||||||
str = p + 1;
|
str = p + 1;
|
||||||
/* Is it a fallback URL? If so, just continue with the next one. */
|
/* Is it a fallback URL? If so, just continue with the next one. */
|
||||||
if (strncmp(str, "ottd", 4) == 0) {
|
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? */
|
/* Have we gone through all lines? */
|
||||||
this->OnFailure();
|
this->OnFailure();
|
||||||
return;
|
return;
|
||||||
|
@ -925,7 +925,7 @@ void ClientNetworkContentSocketHandler::ReverseLookupTreeDependency(ConstContent
|
||||||
* we are including stuff into the vector and as such the vector's data
|
* 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
|
* store can be reallocated (and thus move), which means out iterating
|
||||||
* pointer gets invalid. So fall back to the indices. */
|
* 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;
|
ConstContentVector parents;
|
||||||
this->ReverseLookupDependency(parents, tree[i]);
|
this->ReverseLookupDependency(parents, tree[i]);
|
||||||
|
|
||||||
|
|
|
@ -129,7 +129,7 @@ public:
|
||||||
void CheckDependencyState(ContentInfo *ci);
|
void CheckDependencyState(ContentInfo *ci);
|
||||||
|
|
||||||
/** Get the number of content items we know locally. */
|
/** 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. */
|
/** Get the begin of the content inf iterator. */
|
||||||
ConstContentIterator Begin() const { return this->infos.Begin(); }
|
ConstContentIterator Begin() const { return this->infos.Begin(); }
|
||||||
/** Get the nth position of the content inf iterator. */
|
/** Get the nth position of the content inf iterator. */
|
||||||
|
|
|
@ -401,7 +401,7 @@ class NetworkContentListWindow : public Window, ContentCallback {
|
||||||
this->content.RebuildDone();
|
this->content.RebuildDone();
|
||||||
this->SortContentList();
|
this->SortContentList();
|
||||||
|
|
||||||
this->vscroll->SetCount(this->content.Length()); // Update the scrollbar
|
this->vscroll->SetCount(this->content.size()); // Update the scrollbar
|
||||||
this->ScrollToSelected();
|
this->ScrollToSelected();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -791,7 +791,7 @@ public:
|
||||||
switch (widget) {
|
switch (widget) {
|
||||||
case WID_NCL_MATRIX: {
|
case WID_NCL_MATRIX: {
|
||||||
uint id_v = this->vscroll->GetScrolledRowFromWidget(pt.y, this, 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->selected = *this->content.Get(id_v);
|
||||||
this->list_pos = id_v;
|
this->list_pos = id_v;
|
||||||
|
@ -815,7 +815,7 @@ public:
|
||||||
case WID_NCL_NAME:
|
case WID_NCL_NAME:
|
||||||
if (this->content.SortType() == widget - WID_NCL_CHECKBOX) {
|
if (this->content.SortType() == widget - WID_NCL_CHECKBOX) {
|
||||||
this->content.ToggleSortOrder();
|
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 {
|
} else {
|
||||||
this->content.SetSortType(widget - WID_NCL_CHECKBOX);
|
this->content.SetSortType(widget - WID_NCL_CHECKBOX);
|
||||||
this->content.ForceResort();
|
this->content.ForceResort();
|
||||||
|
@ -874,7 +874,7 @@ public:
|
||||||
break;
|
break;
|
||||||
case WKC_DOWN:
|
case WKC_DOWN:
|
||||||
/* scroll down by one */
|
/* 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;
|
break;
|
||||||
case WKC_PAGEUP:
|
case WKC_PAGEUP:
|
||||||
/* scroll up a page */
|
/* scroll up a page */
|
||||||
|
@ -882,7 +882,7 @@ public:
|
||||||
break;
|
break;
|
||||||
case WKC_PAGEDOWN:
|
case WKC_PAGEDOWN:
|
||||||
/* scroll down a page */
|
/* 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;
|
break;
|
||||||
case WKC_HOME:
|
case WKC_HOME:
|
||||||
/* jump to beginning */
|
/* jump to beginning */
|
||||||
|
@ -890,7 +890,7 @@ public:
|
||||||
break;
|
break;
|
||||||
case WKC_END:
|
case WKC_END:
|
||||||
/* jump to end */
|
/* jump to end */
|
||||||
this->list_pos = this->content.Length() - 1;
|
this->list_pos = this->content.size() - 1;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WKC_SPACE:
|
case WKC_SPACE:
|
||||||
|
@ -914,7 +914,7 @@ public:
|
||||||
return ES_NOT_HANDLED;
|
return ES_NOT_HANDLED;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this->content.Length() == 0) {
|
if (this->content.size() == 0) {
|
||||||
this->list_pos = 0; // above stuff may result in "-1".
|
this->list_pos = 0; // above stuff may result in "-1".
|
||||||
if (this->UpdateFilterState()) {
|
if (this->UpdateFilterState()) {
|
||||||
this->content.ForceRebuild();
|
this->content.ForceRebuild();
|
||||||
|
|
|
@ -269,7 +269,7 @@ protected:
|
||||||
|
|
||||||
this->servers.shrink_to_fit();
|
this->servers.shrink_to_fit();
|
||||||
this->servers.RebuildDone();
|
this->servers.RebuildDone();
|
||||||
this->vscroll->SetCount(this->servers.Length());
|
this->vscroll->SetCount(this->servers.size());
|
||||||
|
|
||||||
/* Sort the list of network games as requested. */
|
/* Sort the list of network games as requested. */
|
||||||
this->servers.Sort();
|
this->servers.Sort();
|
||||||
|
@ -354,7 +354,7 @@ protected:
|
||||||
void UpdateListPos()
|
void UpdateListPos()
|
||||||
{
|
{
|
||||||
this->list_pos = SLP_INVALID;
|
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) {
|
if (this->servers[i] == this->server) {
|
||||||
this->list_pos = i;
|
this->list_pos = i;
|
||||||
break;
|
break;
|
||||||
|
@ -564,7 +564,7 @@ public:
|
||||||
case WID_NG_MATRIX: {
|
case WID_NG_MATRIX: {
|
||||||
uint16 y = r.top;
|
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) {
|
for (int i = this->vscroll->GetPosition(); i < max; ++i) {
|
||||||
const NetworkGameList *ngl = this->servers[i];
|
const NetworkGameList *ngl = this->servers[i];
|
||||||
|
@ -710,7 +710,7 @@ public:
|
||||||
case WID_NG_INFO: // Connectivity (green dot)
|
case WID_NG_INFO: // Connectivity (green dot)
|
||||||
if (this->servers.SortType() == widget - WID_NG_NAME) {
|
if (this->servers.SortType() == widget - WID_NG_NAME) {
|
||||||
this->servers.ToggleSortOrder();
|
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 {
|
} else {
|
||||||
this->servers.SetSortType(widget - WID_NG_NAME);
|
this->servers.SetSortType(widget - WID_NG_NAME);
|
||||||
this->servers.ForceResort();
|
this->servers.ForceResort();
|
||||||
|
@ -722,7 +722,7 @@ public:
|
||||||
|
|
||||||
case WID_NG_MATRIX: { // Show available network games
|
case WID_NG_MATRIX: { // Show available network games
|
||||||
uint id_v = this->vscroll->GetScrolledRowFromWidget(pt.y, this, WID_NG_MATRIX);
|
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->list_pos = (server == NULL) ? SLP_INVALID : id_v;
|
||||||
this->SetDirty();
|
this->SetDirty();
|
||||||
|
|
||||||
|
@ -819,7 +819,7 @@ public:
|
||||||
|
|
||||||
/* handle up, down, pageup, pagedown, home and end */
|
/* 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 (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) {
|
switch (keycode) {
|
||||||
case WKC_UP:
|
case WKC_UP:
|
||||||
/* scroll up by one */
|
/* scroll up by one */
|
||||||
|
@ -829,7 +829,7 @@ public:
|
||||||
case WKC_DOWN:
|
case WKC_DOWN:
|
||||||
/* scroll down by one */
|
/* scroll down by one */
|
||||||
if (this->list_pos == SLP_INVALID) return ES_HANDLED;
|
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;
|
break;
|
||||||
case WKC_PAGEUP:
|
case WKC_PAGEUP:
|
||||||
/* scroll up a page */
|
/* scroll up a page */
|
||||||
|
@ -839,7 +839,7 @@ public:
|
||||||
case WKC_PAGEDOWN:
|
case WKC_PAGEDOWN:
|
||||||
/* scroll down a page */
|
/* scroll down a page */
|
||||||
if (this->list_pos == SLP_INVALID) return ES_HANDLED;
|
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;
|
break;
|
||||||
case WKC_HOME:
|
case WKC_HOME:
|
||||||
/* jump to beginning */
|
/* jump to beginning */
|
||||||
|
@ -847,7 +847,7 @@ public:
|
||||||
break;
|
break;
|
||||||
case WKC_END:
|
case WKC_END:
|
||||||
/* jump to end */
|
/* jump to end */
|
||||||
this->list_pos = this->servers.Length() - 1;
|
this->list_pos = this->servers.size() - 1;
|
||||||
break;
|
break;
|
||||||
default: NOT_REACHED();
|
default: NOT_REACHED();
|
||||||
}
|
}
|
||||||
|
@ -1789,7 +1789,7 @@ struct NetworkClientListPopupWindow : Window {
|
||||||
d = maxdim(GetStringBoundingBox(action->name), d);
|
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.width += WD_FRAMERECT_LEFT + WD_FRAMERECT_RIGHT;
|
||||||
d.height += WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM;
|
d.height += WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM;
|
||||||
*size = d;
|
*size = d;
|
||||||
|
@ -1819,12 +1819,12 @@ struct NetworkClientListPopupWindow : Window {
|
||||||
uint index = (_cursor.pos.y - this->top - WD_FRAMERECT_TOP) / FONT_HEIGHT_NORMAL;
|
uint index = (_cursor.pos.y - this->top - WD_FRAMERECT_TOP) / FONT_HEIGHT_NORMAL;
|
||||||
|
|
||||||
if (_left_button_down) {
|
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->sel_index = index;
|
||||||
this->SetDirty();
|
this->SetDirty();
|
||||||
} else {
|
} 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);
|
const NetworkClientInfo *ci = NetworkClientInfo::GetByClientID(this->client_id);
|
||||||
if (ci != NULL) this->actions[index].proc(ci);
|
if (ci != NULL) this->actions[index].proc(ci);
|
||||||
}
|
}
|
||||||
|
|
|
@ -658,7 +658,7 @@ static Engine *GetNewEngine(const GRFFile *file, VehicleType type, uint16 intern
|
||||||
e->grf_prop.grffile = file;
|
e->grf_prop.grffile = file;
|
||||||
|
|
||||||
/* Reserve the engine slot */
|
/* Reserve the engine slot */
|
||||||
assert(_engine_mngr.Length() == e->index);
|
assert(_engine_mngr.size() == e->index);
|
||||||
EngineIDMapping *eid = _engine_mngr.Append();
|
EngineIDMapping *eid = _engine_mngr.Append();
|
||||||
eid->type = type;
|
eid->type = type;
|
||||||
eid->grfid = scope_grfid; // Note: this is INVALID_GRFID if dynamic_engines is disabled, so no reservation
|
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
|
case 0x05: { // Track type
|
||||||
uint8 tracktype = buf->ReadByte();
|
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];
|
_gted[e->index].railtypelabel = _cur.grffile->railtype_list[tracktype];
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1200,7 +1200,7 @@ static ChangeInfoResult RailVehicleChangeInfo(uint engine, int numinfo, int prop
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_cur.grffile->railtype_list.Length() == 0) {
|
if (_cur.grffile->railtype_list.size() == 0) {
|
||||||
/* Use traction type to select between normal and electrified
|
/* Use traction type to select between normal and electrified
|
||||||
* rail only when no translation list is in place. */
|
* 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;
|
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();
|
DeterministicSpriteGroupAdjust *adjust = adjusts.Append();
|
||||||
|
|
||||||
/* The first var adjust doesn't have an operation specified, so we set it to add. */
|
/* 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();
|
adjust->variable = buf->ReadByte();
|
||||||
if (adjust->variable == 0x7E) {
|
if (adjust->variable == 0x7E) {
|
||||||
/* Link subroutine group */
|
/* Link subroutine group */
|
||||||
|
@ -4824,7 +4824,7 @@ static void NewSpriteGroup(ByteReader *buf)
|
||||||
/* Continue reading var adjusts while bit 5 is set. */
|
/* Continue reading var adjusts while bit 5 is set. */
|
||||||
} while (HasBit(varadjust, 5));
|
} while (HasBit(varadjust, 5));
|
||||||
|
|
||||||
group->num_adjusts = adjusts.Length();
|
group->num_adjusts = adjusts.size();
|
||||||
group->adjusts = MallocT<DeterministicSpriteGroupAdjust>(group->num_adjusts);
|
group->adjusts = MallocT<DeterministicSpriteGroupAdjust>(group->num_adjusts);
|
||||||
MemCpyT(group->adjusts, adjusts.Begin(), 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 (feature == GSF_STATIONS && ctype == 0xFE) return CT_DEFAULT_NA;
|
||||||
if (ctype == 0xFF) return CT_PURCHASE;
|
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 */
|
/* No cargo table, so use bitnum values */
|
||||||
if (ctype >= 32) {
|
if (ctype >= 32) {
|
||||||
grfmsg(1, "TranslateCargo: Cargo bitnum %d out of range (max 31), skipping.", ctype);
|
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 */
|
/* Check if the cargo type is out of bounds of the cargo translation table */
|
||||||
if (ctype >= _cur.grffile->cargo_list.Length()) {
|
if (ctype >= _cur.grffile->cargo_list.size()) {
|
||||||
grfmsg(1, "TranslateCargo: Cargo type %d out of range (max %d), skipping.", ctype, _cur.grffile->cargo_list.Length() - 1);
|
grfmsg(1, "TranslateCargo: Cargo type %d out of range (max %d), skipping.", ctype, (unsigned int)_cur.grffile->cargo_list.size() - 1);
|
||||||
return CT_INVALID;
|
return CT_INVALID;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7850,8 +7850,8 @@ static bool HandleParameterInfo(ByteReader *buf)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (id >= _cur.grfconfig->param_info.Length()) {
|
if (id >= _cur.grfconfig->param_info.size()) {
|
||||||
uint num_to_add = id - _cur.grfconfig->param_info.Length() + 1;
|
uint num_to_add = id - _cur.grfconfig->param_info.size() + 1;
|
||||||
GRFParameterInfo **newdata = _cur.grfconfig->param_info.Append(num_to_add);
|
GRFParameterInfo **newdata = _cur.grfconfig->param_info.Append(num_to_add);
|
||||||
MemSetT<GRFParameterInfo *>(newdata, 0, num_to_add);
|
MemSetT<GRFParameterInfo *>(newdata, 0, num_to_add);
|
||||||
}
|
}
|
||||||
|
@ -8380,7 +8380,7 @@ static void BuildCargoTranslationMap()
|
||||||
const CargoSpec *cs = CargoSpec::Get(c);
|
const CargoSpec *cs = CargoSpec::Get(c);
|
||||||
if (!cs->IsValid()) continue;
|
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 */
|
/* Default translation table, so just a straight mapping to bitnum */
|
||||||
_cur.grffile->cargo_map[c] = cs->bitnum;
|
_cur.grffile->cargo_map[c] = cs->bitnum;
|
||||||
} else {
|
} else {
|
||||||
|
@ -8560,7 +8560,7 @@ static void CalculateRefitMasks()
|
||||||
{
|
{
|
||||||
const GRFFile *file = _gted[engine].defaultcargo_grf;
|
const GRFFile *file = _gted[engine].defaultcargo_grf;
|
||||||
if (file == NULL) file = e->GetGRF();
|
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;
|
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);
|
static const uint32 override_features = (1 << GSF_TRAINS) | (1 << GSF_ROADVEHICLES) | (1 << GSF_SHIPS) | (1 << GSF_AIRCRAFT);
|
||||||
|
|
||||||
/* Evaluate grf overrides */
|
/* Evaluate grf overrides */
|
||||||
int num_grfs = _grf_files.Length();
|
int num_grfs = _grf_files.size();
|
||||||
int *grf_overrides = AllocaM(int, num_grfs);
|
int *grf_overrides = AllocaM(int, num_grfs);
|
||||||
for (int i = 0; i < num_grfs; i++) {
|
for (int i = 0; i < num_grfs; i++) {
|
||||||
grf_overrides[i] = -1;
|
grf_overrides[i] = -1;
|
||||||
|
|
|
@ -82,10 +82,10 @@ CargoID GetCargoTranslation(uint8 cargo, const GRFFile *grffile, bool usebit)
|
||||||
|
|
||||||
/* Other cases use (possibly translated) cargobits */
|
/* 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
|
/* ...and the cargo is in bounds, then get the cargo ID for
|
||||||
* the label */
|
* 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 {
|
||||||
/* Else the cargo value is a 'climate independent' 'bitnum' */
|
/* Else the cargo value is a 'climate independent' 'bitnum' */
|
||||||
return GetCargoIDByBitnum(cargo);
|
return GetCargoIDByBitnum(cargo);
|
||||||
|
|
|
@ -83,7 +83,7 @@ GRFConfig::GRFConfig(const GRFConfig &config) :
|
||||||
this->info->AddRef();
|
this->info->AddRef();
|
||||||
this->url->AddRef();
|
this->url->AddRef();
|
||||||
if (config.error != NULL) this->error = new GRFError(*config.error);
|
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) {
|
if (config.param_info[i] == NULL) {
|
||||||
*this->param_info.Append() = NULL;
|
*this->param_info.Append() = NULL;
|
||||||
} else {
|
} else {
|
||||||
|
@ -104,7 +104,7 @@ GRFConfig::~GRFConfig()
|
||||||
this->info->Release();
|
this->info->Release();
|
||||||
this->url->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;
|
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;
|
if (this->param_info[i] == NULL) continue;
|
||||||
this->param_info[i]->SetValue(this, this->param_info[i]->def_value);
|
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),
|
num_bit(info.num_bit),
|
||||||
complete_labels(info.complete_labels)
|
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);
|
SmallPair<uint32, GRFText *> *data = info.value_names.Get(i);
|
||||||
this->value_names.Insert(data->first, DuplicateGRFText(data->second));
|
this->value_names.Insert(data->first, DuplicateGRFText(data->second));
|
||||||
}
|
}
|
||||||
|
@ -272,7 +272,7 @@ GRFParameterInfo::~GRFParameterInfo()
|
||||||
{
|
{
|
||||||
CleanUpGRFText(this->name);
|
CleanUpGRFText(this->name);
|
||||||
CleanUpGRFText(this->desc);
|
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);
|
SmallPair<uint32, GRFText *> *data = this->value_names.Get(i);
|
||||||
CleanUpGRFText(data->second);
|
CleanUpGRFText(data->second);
|
||||||
}
|
}
|
||||||
|
@ -609,7 +609,7 @@ compatible_grf:
|
||||||
c->min_loadable_version = f->min_loadable_version;
|
c->min_loadable_version = f->min_loadable_version;
|
||||||
c->num_valid_params = f->num_valid_params;
|
c->num_valid_params = f->num_valid_params;
|
||||||
c->has_param_defaults = f->has_param_defaults;
|
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) {
|
if (f->param_info[i] == NULL) {
|
||||||
*c->param_info.Append() = NULL;
|
*c->param_info.Append() = NULL;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -895,7 +895,7 @@ struct SpriteAlignerWindow : Window {
|
||||||
int step_size = nwid->resize_y;
|
int step_size = nwid->resize_y;
|
||||||
|
|
||||||
SmallVector<SpriteID, 256> &list = _newgrf_debug_sprite_picker.sprites;
|
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;
|
int y = r.top + WD_FRAMERECT_TOP;
|
||||||
for (int i = this->vscroll->GetPosition(); i < max; i++) {
|
for (int i = this->vscroll->GetPosition(); i < max; i++) {
|
||||||
|
@ -940,7 +940,7 @@ struct SpriteAlignerWindow : Window {
|
||||||
int step_size = nwid->resize_y;
|
int step_size = nwid->resize_y;
|
||||||
|
|
||||||
uint i = this->vscroll->GetPosition() + (pt.y - nwid->pos_y) / step_size;
|
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];
|
SpriteID spr = _newgrf_debug_sprite_picker.sprites[i];
|
||||||
if (GetSpriteType(spr) == ST_NORMAL) this->current_sprite = spr;
|
if (GetSpriteType(spr) == ST_NORMAL) this->current_sprite = spr;
|
||||||
}
|
}
|
||||||
|
@ -1015,7 +1015,7 @@ struct SpriteAlignerWindow : Window {
|
||||||
if (data == 1) {
|
if (data == 1) {
|
||||||
/* Sprite picker finished */
|
/* Sprite picker finished */
|
||||||
this->RaiseWidget(WID_SA_PICKER);
|
this->RaiseWidget(WID_SA_PICKER);
|
||||||
this->vscroll->SetCount(_newgrf_debug_sprite_picker.sprites.Length());
|
this->vscroll->SetCount(_newgrf_debug_sprite_picker.sprites.size());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1233,7 +1233,7 @@ void CommitVehicleListOrderChanges()
|
||||||
FOR_ALL_ENGINES(e) {
|
FOR_ALL_ENGINES(e) {
|
||||||
*ordering.Append() = e->index;
|
*ordering.Append() = e->index;
|
||||||
}
|
}
|
||||||
QSortT(ordering.Begin(), ordering.Length(), EnginePreSort);
|
QSortT(ordering.Begin(), ordering.size(), EnginePreSort);
|
||||||
|
|
||||||
/* Apply Insertion-Sort operations */
|
/* Apply Insertion-Sort operations */
|
||||||
const ListOrderChange *end = _list_order_changes.End();
|
const ListOrderChange *end = _list_order_changes.End();
|
||||||
|
|
|
@ -166,7 +166,7 @@ struct NewGRFParametersWindow : public Window {
|
||||||
clicked_row(UINT_MAX),
|
clicked_row(UINT_MAX),
|
||||||
editable(editable)
|
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->CreateNestedTree();
|
||||||
this->vscroll = this->GetScrollbar(WID_NP_SCROLLBAR);
|
this->vscroll = this->GetScrollbar(WID_NP_SCROLLBAR);
|
||||||
|
@ -220,7 +220,7 @@ struct NewGRFParametersWindow : public Window {
|
||||||
case WID_NP_DESCRIPTION:
|
case WID_NP_DESCRIPTION:
|
||||||
/* Minimum size of 4 lines. The 500 is the default size of the window. */
|
/* 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};
|
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];
|
const GRFParameterInfo *par_info = this->grf_config->param_info[i];
|
||||||
if (par_info == NULL) continue;
|
if (par_info == NULL) continue;
|
||||||
const char *desc = GetGRFStringFromGRFText(par_info->desc);
|
const char *desc = GetGRFStringFromGRFText(par_info->desc);
|
||||||
|
@ -246,7 +246,7 @@ struct NewGRFParametersWindow : public Window {
|
||||||
void DrawWidget(const Rect &r, int widget) const override
|
void DrawWidget(const Rect &r, int widget) const override
|
||||||
{
|
{
|
||||||
if (widget == WID_NP_DESCRIPTION) {
|
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;
|
if (par_info == NULL) return;
|
||||||
const char *desc = GetGRFStringFromGRFText(par_info->desc);
|
const char *desc = GetGRFStringFromGRFText(par_info->desc);
|
||||||
if (desc == NULL) return;
|
if (desc == NULL) return;
|
||||||
|
@ -265,7 +265,7 @@ struct NewGRFParametersWindow : public Window {
|
||||||
int button_y_offset = (this->line_height - SETTING_BUTTON_HEIGHT) / 2;
|
int button_y_offset = (this->line_height - SETTING_BUTTON_HEIGHT) / 2;
|
||||||
int text_y_offset = (this->line_height - FONT_HEIGHT_NORMAL) / 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++) {
|
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);
|
if (par_info == NULL) par_info = GetDummyParameterInfo(i);
|
||||||
uint32 current_value = par_info->GetValue(this->grf_config);
|
uint32 current_value = par_info->GetValue(this->grf_config);
|
||||||
bool selected = (i == this->clicked_row);
|
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;
|
if (_current_text_dir == TD_RTL) x = wid->current_x - 1 - x;
|
||||||
x -= 4;
|
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);
|
if (par_info == NULL) par_info = GetDummyParameterInfo(num);
|
||||||
|
|
||||||
/* One of the arrows is clicked */
|
/* One of the arrows is clicked */
|
||||||
|
@ -431,7 +431,7 @@ struct NewGRFParametersWindow : public Window {
|
||||||
{
|
{
|
||||||
if (StrEmpty(str)) return;
|
if (StrEmpty(str)) return;
|
||||||
int32 value = atoi(str);
|
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);
|
if (par_info == NULL) par_info = GetDummyParameterInfo(this->clicked_row);
|
||||||
uint32 val = Clamp<uint32>(value, par_info->min_value, par_info->max_value);
|
uint32 val = Clamp<uint32>(value, par_info->min_value, par_info->max_value);
|
||||||
par_info->SetValue(this->grf_config, val);
|
par_info->SetValue(this->grf_config, val);
|
||||||
|
@ -441,7 +441,7 @@ struct NewGRFParametersWindow : public Window {
|
||||||
void OnDropdownSelect(int widget, int index) override
|
void OnDropdownSelect(int widget, int index) override
|
||||||
{
|
{
|
||||||
assert(this->clicked_dropdown);
|
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);
|
if (par_info == NULL) par_info = GetDummyParameterInfo(this->clicked_row);
|
||||||
par_info->SetValue(this->grf_config, index);
|
par_info->SetValue(this->grf_config, index);
|
||||||
this->SetDirty();
|
this->SetDirty();
|
||||||
|
@ -747,7 +747,7 @@ struct NewGRFWindow : public Window, NewGRFScanCallback {
|
||||||
|
|
||||||
case WID_NS_PRESET_LIST: {
|
case WID_NS_PRESET_LIST: {
|
||||||
Dimension d = GetStringBoundingBox(STR_NUM_CUSTOM);
|
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) {
|
if (_grf_preset_list[i] != NULL) {
|
||||||
SetDParamStr(0, _grf_preset_list[i]);
|
SetDParamStr(0, _grf_preset_list[i]);
|
||||||
d = maxdim(d, GetStringBoundingBox(STR_JUST_RAW_STRING));
|
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;
|
int offset_y = (step_height - FONT_HEIGHT_NORMAL) / 2;
|
||||||
uint y = r.top + WD_FRAMERECT_TOP;
|
uint y = r.top + WD_FRAMERECT_TOP;
|
||||||
uint min_index = this->vscroll2->GetPosition();
|
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++) {
|
for (uint i = min_index; i < max_index; i++) {
|
||||||
const GRFConfig *c = this->avails[i];
|
const GRFConfig *c = this->avails[i];
|
||||||
|
@ -929,7 +929,7 @@ struct NewGRFWindow : public Window, NewGRFScanCallback {
|
||||||
/* Add 'None' option for clearing list */
|
/* Add 'None' option for clearing list */
|
||||||
*list->Append() = new DropDownListStringItem(STR_NONE, -1, false);
|
*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) {
|
if (_grf_preset_list[i] != NULL) {
|
||||||
*list->Append() = new DropDownListCharStringItem(_grf_preset_list[i], i, false);
|
*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);
|
uint i = this->vscroll2->GetScrolledRowFromWidget(pt.y, this, WID_NS_AVAIL_LIST);
|
||||||
this->active_sel = NULL;
|
this->active_sel = NULL;
|
||||||
DeleteWindowByClass(WC_GRF_PARAMETERS);
|
DeleteWindowByClass(WC_GRF_PARAMETERS);
|
||||||
if (i < this->avails.Length()) {
|
if (i < this->avails.size()) {
|
||||||
if (this->avail_sel != this->avails[i]) DeleteWindowByClass(WC_TEXTFILE);
|
if (this->avail_sel != this->avails[i]) DeleteWindowByClass(WC_TEXTFILE);
|
||||||
this->avail_sel = this->avails[i];
|
this->avail_sel = this->avails[i];
|
||||||
this->avail_pos = i;
|
this->avail_pos = i;
|
||||||
|
@ -1175,7 +1175,7 @@ struct NewGRFWindow : public Window, NewGRFScanCallback {
|
||||||
GetGRFPresetList(&_grf_preset_list);
|
GetGRFPresetList(&_grf_preset_list);
|
||||||
|
|
||||||
/* Switch to this preset */
|
/* 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) {
|
if (_grf_preset_list[i] != NULL && strcmp(_grf_preset_list[i], str) == 0) {
|
||||||
this->preset = i;
|
this->preset = i;
|
||||||
break;
|
break;
|
||||||
|
@ -1308,7 +1308,7 @@ struct NewGRFWindow : public Window, NewGRFScanCallback {
|
||||||
|
|
||||||
case WKC_DOWN:
|
case WKC_DOWN:
|
||||||
/* scroll down by one */
|
/* 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;
|
break;
|
||||||
|
|
||||||
case WKC_PAGEUP:
|
case WKC_PAGEUP:
|
||||||
|
@ -1318,7 +1318,7 @@ struct NewGRFWindow : public Window, NewGRFScanCallback {
|
||||||
|
|
||||||
case WKC_PAGEDOWN:
|
case WKC_PAGEDOWN:
|
||||||
/* scroll down a page */
|
/* 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;
|
break;
|
||||||
|
|
||||||
case WKC_HOME:
|
case WKC_HOME:
|
||||||
|
@ -1328,14 +1328,14 @@ struct NewGRFWindow : public Window, NewGRFScanCallback {
|
||||||
|
|
||||||
case WKC_END:
|
case WKC_END:
|
||||||
/* jump to end */
|
/* jump to end */
|
||||||
this->avail_pos = this->avails.Length() - 1;
|
this->avail_pos = this->avails.size() - 1;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return ES_NOT_HANDLED;
|
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) {
|
if (this->avail_pos >= 0) {
|
||||||
this->active_sel = NULL;
|
this->active_sel = NULL;
|
||||||
DeleteWindowByClass(WC_GRF_PARAMETERS);
|
DeleteWindowByClass(WC_GRF_PARAMETERS);
|
||||||
|
@ -1490,7 +1490,7 @@ private:
|
||||||
if (this->avail_pos < 0) this->avail_sel = NULL;
|
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. */
|
/* Select next (or previous, if last one) item in the list. */
|
||||||
int new_pos = this->avail_pos + 1;
|
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;
|
this->avail_pos = new_pos;
|
||||||
if (new_pos >= 0) this->avail_sel = this->avails[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));
|
memcpy(ci->md5sum, HasBit(c->flags, GCF_COMPATIBLE) ? c->original_md5sum : c->ident.md5sum, sizeof(ci->md5sum));
|
||||||
*cv.Append() = ci;
|
*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};
|
Listing NewGRFWindow::last_sorting = {false, 0};
|
||||||
|
@ -2049,7 +2049,7 @@ struct SavePresetWindow : public Window {
|
||||||
GetGRFPresetList(&this->presets);
|
GetGRFPresetList(&this->presets);
|
||||||
this->selected = -1;
|
this->selected = -1;
|
||||||
if (initial_text != NULL) {
|
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])) {
|
if (!strcmp(initial_text, this->presets[i])) {
|
||||||
this->selected = i;
|
this->selected = i;
|
||||||
break;
|
break;
|
||||||
|
@ -2065,7 +2065,7 @@ struct SavePresetWindow : public Window {
|
||||||
this->vscroll = this->GetScrollbar(WID_SVP_SCROLLBAR);
|
this->vscroll = this->GetScrollbar(WID_SVP_SCROLLBAR);
|
||||||
this->FinishInitNested(0);
|
this->FinishInitNested(0);
|
||||||
|
|
||||||
this->vscroll->SetCount(this->presets.Length());
|
this->vscroll->SetCount(this->presets.size());
|
||||||
this->SetFocusedWidget(WID_SVP_EDITBOX);
|
this->SetFocusedWidget(WID_SVP_EDITBOX);
|
||||||
if (initial_text != NULL) this->presetname_editbox.text.Assign(initial_text);
|
if (initial_text != NULL) this->presetname_editbox.text.Assign(initial_text);
|
||||||
}
|
}
|
||||||
|
@ -2080,12 +2080,12 @@ struct SavePresetWindow : public Window {
|
||||||
case WID_SVP_PRESET_LIST: {
|
case WID_SVP_PRESET_LIST: {
|
||||||
resize->height = FONT_HEIGHT_NORMAL + 2U;
|
resize->height = FONT_HEIGHT_NORMAL + 2U;
|
||||||
size->height = 0;
|
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]);
|
Dimension d = GetStringBoundingBox(this->presets[i]);
|
||||||
size->width = max(size->width, d.width + WD_FRAMETEXT_LEFT + WD_FRAMETEXT_RIGHT);
|
size->width = max(size->width, d.width + WD_FRAMETEXT_LEFT + WD_FRAMETEXT_RIGHT);
|
||||||
resize->height = max(resize->height, d.height);
|
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;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2101,7 +2101,7 @@ struct SavePresetWindow : public Window {
|
||||||
int offset_y = (step_height - FONT_HEIGHT_NORMAL) / 2;
|
int offset_y = (step_height - FONT_HEIGHT_NORMAL) / 2;
|
||||||
uint y = r.top + WD_FRAMERECT_TOP;
|
uint y = r.top + WD_FRAMERECT_TOP;
|
||||||
uint min_index = this->vscroll->GetPosition();
|
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++) {
|
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);
|
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) {
|
switch (widget) {
|
||||||
case WID_SVP_PRESET_LIST: {
|
case WID_SVP_PRESET_LIST: {
|
||||||
uint row = this->vscroll->GetScrolledRowFromWidget(pt.y, this, 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->selected = row;
|
||||||
this->presetname_editbox.text.Assign(this->presets[row]);
|
this->presetname_editbox.text.Assign(this->presets[row]);
|
||||||
this->SetWidgetDirty(WID_SVP_PRESET_LIST);
|
this->SetWidgetDirty(WID_SVP_PRESET_LIST);
|
||||||
|
|
|
@ -139,7 +139,7 @@ SpriteID GetCustomSignalSprite(const RailtypeInfo *rti, TileIndex tile, SignalTy
|
||||||
uint8 GetReverseRailTypeTranslation(RailType railtype, const GRFFile *grffile)
|
uint8 GetReverseRailTypeTranslation(RailType railtype, const GRFFile *grffile)
|
||||||
{
|
{
|
||||||
/* No rail type table present, return rail type as-is */
|
/* 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 */
|
/* Look for a matching rail type label in the table */
|
||||||
RailTypeLabel label = GetRailTypeInfo(railtype)->label;
|
RailTypeLabel label = GetRailTypeInfo(railtype)->label;
|
||||||
|
|
|
@ -49,14 +49,14 @@ void InitializeSoundPool()
|
||||||
|
|
||||||
SoundEntry *GetSound(SoundID index)
|
SoundEntry *GetSound(SoundID index)
|
||||||
{
|
{
|
||||||
if (index >= _sounds.Length()) return NULL;
|
if (index >= _sounds.size()) return NULL;
|
||||||
return &_sounds[index];
|
return &_sounds[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
uint GetNumSounds()
|
uint GetNumSounds()
|
||||||
{
|
{
|
||||||
return _sounds.Length();
|
return _sounds.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -85,7 +85,7 @@ public:
|
||||||
|
|
||||||
virtual int GetLeading() const;
|
virtual int GetLeading() const;
|
||||||
virtual int GetWidth() 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); }
|
virtual const VisualRun *GetVisualRun(int run) const { return *this->Get(run); }
|
||||||
|
|
||||||
int GetInternalCharLength(WChar c) const
|
int GetInternalCharLength(WChar c) const
|
||||||
|
@ -256,7 +256,7 @@ int CoreTextParagraphLayout::CoreTextLine::GetLeading() const
|
||||||
*/
|
*/
|
||||||
int CoreTextParagraphLayout::CoreTextLine::GetWidth() const
|
int CoreTextParagraphLayout::CoreTextLine::GetWidth() const
|
||||||
{
|
{
|
||||||
if (this->Length() == 0) return 0;
|
if (this->size() == 0) return 0;
|
||||||
|
|
||||||
int total_width = 0;
|
int total_width = 0;
|
||||||
for (const CoreTextVisualRun * const *run = this->Begin(); run != this->End(); run++) {
|
for (const CoreTextVisualRun * const *run = this->Begin(); run != this->End(); run++) {
|
||||||
|
|
|
@ -110,7 +110,7 @@ public:
|
||||||
public:
|
public:
|
||||||
virtual int GetLeading() const;
|
virtual int GetLeading() const;
|
||||||
virtual int GetWidth() 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); }
|
virtual const VisualRun *GetVisualRun(int run) const { return *this->Get(run); }
|
||||||
|
|
||||||
int GetInternalCharLength(WChar c) const
|
int GetInternalCharLength(WChar c) const
|
||||||
|
|
|
@ -1747,7 +1747,7 @@ CommandCost CmdConvertRail(TileIndex tile, DoCommandFlag flags, uint32 p1, uint3
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (uint i = 0; i < vehicles_affected.Length(); ++i) {
|
for (uint i = 0; i < vehicles_affected.size(); ++i) {
|
||||||
TryPathReserve(vehicles_affected[i], true);
|
TryPathReserve(vehicles_affected[i], true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,8 +25,8 @@ extern SmallVector<TileIndex, 256> _animated_tiles;
|
||||||
*/
|
*/
|
||||||
static void Save_ANIT()
|
static void Save_ANIT()
|
||||||
{
|
{
|
||||||
SlSetLength(_animated_tiles.Length() * sizeof(*_animated_tiles.Begin()));
|
SlSetLength(_animated_tiles.size() * sizeof(*_animated_tiles.Begin()));
|
||||||
SlArray(_animated_tiles.Begin(), _animated_tiles.Length(), SLE_UINT32);
|
SlArray(_animated_tiles.Begin(), _animated_tiles.size(), SLE_UINT32);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -132,7 +132,7 @@ static const SaveLoad _game_language_string[] = {
|
||||||
static void SaveReal_GSTR(LanguageStrings *ls)
|
static void SaveReal_GSTR(LanguageStrings *ls)
|
||||||
{
|
{
|
||||||
_game_saveload_string = ls->language;
|
_game_saveload_string = ls->language;
|
||||||
_game_saveload_strings = ls->lines.Length();
|
_game_saveload_strings = ls->lines.size();
|
||||||
|
|
||||||
SlObject(NULL, _game_language_header);
|
SlObject(NULL, _game_language_header);
|
||||||
for (uint i = 0; i < _game_saveload_strings; i++) {
|
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 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;
|
delete _current_data;
|
||||||
_current_data = NULL;
|
_current_data = NULL;
|
||||||
return;
|
return;
|
||||||
|
@ -174,7 +174,7 @@ static void Save_GSTR()
|
||||||
{
|
{
|
||||||
if (_current_data == NULL) return;
|
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);
|
SlSetArrayIndex(i);
|
||||||
SlAutolength((AutolengthProc *)SaveReal_GSTR, _current_data->raw_strings[i]);
|
SlAutolength((AutolengthProc *)SaveReal_GSTR, _current_data->raw_strings[i]);
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,7 +26,7 @@ static SmallVector<RailTypeLabel, RAILTYPE_END> _railtype_list;
|
||||||
*/
|
*/
|
||||||
static bool NeedRailTypeConversion()
|
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) {
|
if ((RailType)i < RAILTYPE_END) {
|
||||||
const RailtypeInfo *rti = GetRailTypeInfo((RailType)i);
|
const RailtypeInfo *rti = GetRailTypeInfo((RailType)i);
|
||||||
if (rti->label != _railtype_list[i]) return true;
|
if (rti->label != _railtype_list[i]) return true;
|
||||||
|
@ -44,7 +44,7 @@ void AfterLoadLabelMaps()
|
||||||
if (NeedRailTypeConversion()) {
|
if (NeedRailTypeConversion()) {
|
||||||
SmallVector<RailType, RAILTYPE_END> railtype_conversion_map;
|
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]);
|
RailType r = GetRailTypeByLabel(_railtype_list[i]);
|
||||||
if (r == INVALID_RAILTYPE) r = RAILTYPE_BEGIN;
|
if (r == INVALID_RAILTYPE) r = RAILTYPE_BEGIN;
|
||||||
|
|
||||||
|
|
|
@ -55,7 +55,7 @@ const SaveLoad *GetLinkGraphJobDesc()
|
||||||
static const char *prefix = "linkgraph.";
|
static const char *prefix = "linkgraph.";
|
||||||
|
|
||||||
/* Build the SaveLoad array on first call and don't touch it later on */
|
/* 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_gamesettings = cpp_offsetof(GameSettings, linkgraph);
|
||||||
size_t offset_component = cpp_offsetof(LinkGraphJob, settings);
|
size_t offset_component = cpp_offsetof(LinkGraphJob, settings);
|
||||||
|
|
||||||
|
@ -83,7 +83,7 @@ const SaveLoad *GetLinkGraphJobDesc()
|
||||||
int i = 0;
|
int i = 0;
|
||||||
do {
|
do {
|
||||||
*(saveloads.Append()) = job_desc[i++];
|
*(saveloads.Append()) = job_desc[i++];
|
||||||
} while (saveloads[saveloads.Length() - 1].cmd != SL_END);
|
} while (saveloads[saveloads.size() - 1].cmd != SL_END);
|
||||||
}
|
}
|
||||||
|
|
||||||
return &saveloads[0];
|
return &saveloads[0];
|
||||||
|
|
|
@ -175,7 +175,7 @@ struct MemoryDumper {
|
||||||
*/
|
*/
|
||||||
size_t GetSize() const
|
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);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -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! */
|
/* All saveload conversions have been done. Create the new waypoints! */
|
||||||
for (OldWaypoint *wp = _old_waypoints.Begin(); wp != _old_waypoints.End(); wp++) {
|
for (OldWaypoint *wp = _old_waypoints.Begin(); wp != _old_waypoints.End(); wp++) {
|
||||||
|
|
|
@ -147,9 +147,9 @@ namespace SQConvert {
|
||||||
}
|
}
|
||||||
sq_pop(vm, 2);
|
sq_pop(vm, 2);
|
||||||
|
|
||||||
Array *arr = (Array*)MallocT<byte>(sizeof(Array) + sizeof(int32) * data.Length());
|
Array *arr = (Array*)MallocT<byte>(sizeof(Array) + sizeof(int32) * data.size());
|
||||||
arr->size = data.Length();
|
arr->size = data.size();
|
||||||
memcpy(arr->array, data.Begin(), sizeof(int32) * data.Length());
|
memcpy(arr->array, data.Begin(), sizeof(int32) * data.size());
|
||||||
|
|
||||||
*ptr->Append() = arr;
|
*ptr->Append() = arr;
|
||||||
return arr;
|
return arr;
|
||||||
|
|
|
@ -215,7 +215,7 @@ struct GameOptionsWindow : Window {
|
||||||
if (i == CURRENCY_CUSTOM) continue;
|
if (i == CURRENCY_CUSTOM) continue;
|
||||||
*list->Append() = new DropDownListStringItem(*items, i, HasBit(disabled, i));
|
*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 */
|
/* Append custom currency at the end */
|
||||||
*list->Append() = new DropDownListItem(-1, false); // separator line
|
*list->Append() = new DropDownListItem(-1, false); // separator line
|
||||||
|
@ -253,9 +253,9 @@ struct GameOptionsWindow : Window {
|
||||||
int result = _nb_orig_names + i;
|
int result = _nb_orig_names + i;
|
||||||
*list->Append() = new DropDownListStringItem(_grf_names[i], result, enabled_item != result && enabled_item >= 0);
|
*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 */
|
/* Insert newgrf_names at the top of the list */
|
||||||
if (newgrf_size > 0) {
|
if (newgrf_size > 0) {
|
||||||
*list->Append() = new DropDownListItem(-1, false); // separator line
|
*list->Append() = new DropDownListItem(-1, false); // separator line
|
||||||
|
@ -266,7 +266,7 @@ struct GameOptionsWindow : Window {
|
||||||
for (int i = 0; i < _nb_orig_names; i++) {
|
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);
|
*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;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -282,11 +282,11 @@ struct GameOptionsWindow : Window {
|
||||||
|
|
||||||
case WID_GO_LANG_DROPDOWN: { // Setup interface language dropdown
|
case WID_GO_LANG_DROPDOWN: { // Setup interface language dropdown
|
||||||
list = new DropDownList();
|
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;
|
if (&_languages[i] == _current_language) *selected_index = i;
|
||||||
*list->Append() = new DropDownListStringItem(SPECSTR_LANGUAGE_START + i, i, false);
|
*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;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -116,7 +116,7 @@ public:
|
||||||
if (length == 0) length = strlen(text);
|
if (length == 0) length = strlen(text);
|
||||||
|
|
||||||
if (length > 0 && this->BufferHasRoom()) {
|
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;
|
length -= stored_size;
|
||||||
text += stored_size;
|
text += stored_size;
|
||||||
}
|
}
|
||||||
|
@ -147,7 +147,7 @@ private:
|
||||||
*/
|
*/
|
||||||
bool BufferHasRoom() const
|
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();
|
return num_blocks > 0 && this->output_buffer[num_blocks - 1].HasRoom();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -246,7 +246,7 @@ struct SignListWindow : Window, SignList {
|
||||||
}
|
}
|
||||||
|
|
||||||
case WID_SIL_FILTER_ENTER_BTN:
|
case WID_SIL_FILTER_ENTER_BTN:
|
||||||
if (this->signs.Length() >= 1) {
|
if (this->signs.size() >= 1) {
|
||||||
const Sign *si = this->signs[0];
|
const Sign *si = this->signs[0];
|
||||||
ScrollMainWindowToTile(TileVirtXY(si->x, si->y));
|
ScrollMainWindowToTile(TileVirtXY(si->x, si->y));
|
||||||
}
|
}
|
||||||
|
@ -310,7 +310,7 @@ struct SignListWindow : Window, SignList {
|
||||||
{
|
{
|
||||||
if (this->signs.NeedRebuild()) {
|
if (this->signs.NeedRebuild()) {
|
||||||
this->BuildSignsList();
|
this->BuildSignsList();
|
||||||
this->vscroll->SetCount(this->signs.Length());
|
this->vscroll->SetCount(this->signs.size());
|
||||||
this->SetWidgetDirty(WID_SIL_CAPTION);
|
this->SetWidgetDirty(WID_SIL_CAPTION);
|
||||||
}
|
}
|
||||||
this->SortSignsList();
|
this->SortSignsList();
|
||||||
|
@ -471,7 +471,7 @@ struct SignWindow : Window, SignList {
|
||||||
/* Search through the list for the current sign, excluding
|
/* Search through the list for the current sign, excluding
|
||||||
* - the first sign if we want the previous sign or
|
* - the first sign if we want the previous sign or
|
||||||
* - the last sign if we want the next sign */
|
* - 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++) {
|
for (uint i = next ? 0 : 1; i < end; i++) {
|
||||||
if (this->cur_sign == this->signs[i]->index) {
|
if (this->cur_sign == this->signs[i]->index) {
|
||||||
/* We've found the current sign, so return the sign before/after it */
|
/* 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 */
|
/* 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
|
void SetStringParameters(int widget) const override
|
||||||
|
|
|
@ -1436,7 +1436,7 @@ CommandCost CmdBuildRailStation(TileIndex tile_org, DoCommandFlag flags, uint32
|
||||||
tile_track += tile_delta ^ TileDiffXY(1, 1); // perpendicular to tile_delta
|
tile_track += tile_delta ^ TileDiffXY(1, 1); // perpendicular to tile_delta
|
||||||
} while (--numtracks);
|
} while (--numtracks);
|
||||||
|
|
||||||
for (uint i = 0; i < affected_vehicles.Length(); ++i) {
|
for (uint i = 0; i < affected_vehicles.size(); ++i) {
|
||||||
/* Restore reservations of trains. */
|
/* Restore reservations of trains. */
|
||||||
RestoreTrainReservation(affected_vehicles[i]);
|
RestoreTrainReservation(affected_vehicles[i]);
|
||||||
}
|
}
|
||||||
|
|
|
@ -205,7 +205,7 @@ protected:
|
||||||
this->stations.shrink_to_fit();
|
this->stations.shrink_to_fit();
|
||||||
this->stations.RebuildDone();
|
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 */
|
/** Sort stations by their name */
|
||||||
|
@ -411,7 +411,7 @@ public:
|
||||||
|
|
||||||
case WID_STL_LIST: {
|
case WID_STL_LIST: {
|
||||||
bool rtl = _current_text_dir == TD_RTL;
|
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;
|
int y = r.top + WD_FRAMERECT_TOP;
|
||||||
for (int i = this->vscroll->GetPosition(); i < max; ++i) { // do until max number of stations of owner
|
for (int i = this->vscroll->GetPosition(); i < max; ++i) { // do until max number of stations of owner
|
||||||
const Station *st = this->stations[i];
|
const Station *st = this->stations[i];
|
||||||
|
@ -498,7 +498,7 @@ public:
|
||||||
switch (widget) {
|
switch (widget) {
|
||||||
case WID_STL_LIST: {
|
case WID_STL_LIST: {
|
||||||
uint id_v = this->vscroll->GetScrolledRowFromWidget(pt.y, this, WID_STL_LIST, 0, FONT_HEIGHT_NORMAL);
|
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];
|
const Station *st = this->stations[id_v];
|
||||||
/* do not check HasStationInUse - it is slow and may be invalid */
|
/* 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;
|
TileArea *ctx = (TileArea *)user_data;
|
||||||
|
|
||||||
/* First check if there were deleted stations here */
|
/* 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);
|
TileAndStation *ts = _deleted_stations_nearby.Get(i);
|
||||||
if (ts->tile == tile) {
|
if (ts->tile == tile) {
|
||||||
*_stations_nearby_list.Append() = _deleted_stations_nearby[i].station;
|
*_stations_nearby_list.Append() = _deleted_stations_nearby[i].station;
|
||||||
|
@ -2255,7 +2255,7 @@ struct SelectStationWindow : Window {
|
||||||
|
|
||||||
/* Determine the widest string */
|
/* Determine the widest string */
|
||||||
Dimension d = GetStringBoundingBox(T::EXPECTED_FACIL == FACIL_WAYPOINT ? STR_JOIN_WAYPOINT_CREATE_SPLITTED_WAYPOINT : STR_JOIN_STATION_CREATE_SPLITTED_STATION);
|
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]);
|
const T *st = T::Get(_stations_nearby_list[i]);
|
||||||
SetDParam(0, st->index);
|
SetDParam(0, st->index);
|
||||||
SetDParam(1, st->facilities);
|
SetDParam(1, st->facilities);
|
||||||
|
@ -2279,7 +2279,7 @@ struct SelectStationWindow : Window {
|
||||||
y += this->resize.step_height;
|
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. */
|
/* Don't draw anything if it extends past the end of the window. */
|
||||||
if (i - this->vscroll->GetPosition() >= this->vscroll->GetCapacity()) break;
|
if (i - this->vscroll->GetPosition() >= this->vscroll->GetCapacity()) break;
|
||||||
|
|
||||||
|
@ -2298,7 +2298,7 @@ struct SelectStationWindow : Window {
|
||||||
bool distant_join = (st_index > 0);
|
bool distant_join = (st_index > 0);
|
||||||
if (distant_join) st_index--;
|
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 */
|
/* Insert station to be joined into stored command */
|
||||||
SB(this->select_station_cmd.p2, 16, 16,
|
SB(this->select_station_cmd.p2, 16, 16,
|
||||||
|
@ -2333,7 +2333,7 @@ struct SelectStationWindow : Window {
|
||||||
{
|
{
|
||||||
if (!gui_scope) return;
|
if (!gui_scope) return;
|
||||||
FindStationsNearby<T>(this->area, true);
|
FindStationsNearby<T>(this->area, true);
|
||||||
this->vscroll->SetCount(_stations_nearby_list.Length() + 1);
|
this->vscroll->SetCount(_stations_nearby_list.size() + 1);
|
||||||
this->SetDirty();
|
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.
|
* 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. */
|
* but join the other station immediately. */
|
||||||
const T *st = FindStationsNearby<T>(ta, false);
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -159,7 +159,7 @@ protected:
|
||||||
/* Verify that the selected page exist. */
|
/* Verify that the selected page exist. */
|
||||||
if (!_story_page_pool.IsValidID(this->selected_page_id)) return false;
|
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);
|
const StoryPage *last = *(this->story_pages.End() - 1);
|
||||||
return last->index == this->selected_page_id;
|
return last->index == this->selected_page_id;
|
||||||
}
|
}
|
||||||
|
@ -253,7 +253,7 @@ protected:
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check if list is empty. */
|
/* Check if list is empty. */
|
||||||
if (list->Length() == 0) {
|
if (list->size() == 0) {
|
||||||
delete list;
|
delete list;
|
||||||
list = NULL;
|
list = NULL;
|
||||||
}
|
}
|
||||||
|
@ -444,8 +444,8 @@ public:
|
||||||
*/
|
*/
|
||||||
void UpdatePrevNextDisabledState()
|
void UpdatePrevNextDisabledState()
|
||||||
{
|
{
|
||||||
this->SetWidgetDisabledState(WID_SB_PREV_PAGE, story_pages.Length() == 0 || this->IsFirstPageSelected());
|
this->SetWidgetDisabledState(WID_SB_PREV_PAGE, story_pages.size() == 0 || this->IsFirstPageSelected());
|
||||||
this->SetWidgetDisabledState(WID_SB_NEXT_PAGE, story_pages.Length() == 0 || this->IsLastPageSelected());
|
this->SetWidgetDisabledState(WID_SB_NEXT_PAGE, story_pages.size() == 0 || this->IsLastPageSelected());
|
||||||
this->SetWidgetDirty(WID_SB_PREV_PAGE);
|
this->SetWidgetDirty(WID_SB_PREV_PAGE);
|
||||||
this->SetWidgetDirty(WID_SB_NEXT_PAGE);
|
this->SetWidgetDirty(WID_SB_NEXT_PAGE);
|
||||||
}
|
}
|
||||||
|
@ -575,7 +575,7 @@ public:
|
||||||
case WID_SB_SEL_PAGE: {
|
case WID_SB_SEL_PAGE: {
|
||||||
|
|
||||||
/* Get max title width. */
|
/* 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];
|
const StoryPage *s = this->story_pages[i];
|
||||||
|
|
||||||
if (s->title != NULL) {
|
if (s->title != NULL) {
|
||||||
|
@ -620,7 +620,7 @@ public:
|
||||||
if (list != NULL) {
|
if (list != NULL) {
|
||||||
/* Get the index of selected page. */
|
/* Get the index of selected page. */
|
||||||
int selected = 0;
|
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];
|
const StoryPage *p = this->story_pages[i];
|
||||||
if (p->index == this->selected_page_id) break;
|
if (p->index == this->selected_page_id) break;
|
||||||
selected++;
|
selected++;
|
||||||
|
@ -694,7 +694,7 @@ public:
|
||||||
this->BuildStoryPageList();
|
this->BuildStoryPageList();
|
||||||
|
|
||||||
/* Was the last page removed? */
|
/* Was the last page removed? */
|
||||||
if (this->story_pages.Length() == 0) {
|
if (this->story_pages.size() == 0) {
|
||||||
this->selected_generic_title[0] = '\0';
|
this->selected_generic_title[0] = '\0';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -702,14 +702,14 @@ public:
|
||||||
if (!_story_page_pool.IsValidID(this->selected_page_id)) {
|
if (!_story_page_pool.IsValidID(this->selected_page_id)) {
|
||||||
this->selected_page_id = INVALID_STORY_PAGE;
|
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.
|
/* No page is selected, but there exist at least one available.
|
||||||
* => Select first page.
|
* => Select first page.
|
||||||
*/
|
*/
|
||||||
this->SetSelectedPage(this->story_pages[0]->index);
|
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->SetWidgetDirty(WID_SB_SEL_PAGE);
|
||||||
this->UpdatePrevNextDisabledState();
|
this->UpdatePrevNextDisabledState();
|
||||||
} else if (data >= 0 && this->selected_page_id == data) {
|
} else if (data >= 0 && this->selected_page_id == data) {
|
||||||
|
|
|
@ -1029,14 +1029,14 @@ void LanguageWriter::WriteLang(const StringData &data)
|
||||||
for (c = casep; c != NULL; c = c->next) {
|
for (c = casep; c != NULL; c = c->next) {
|
||||||
buffer.AppendByte(c->caseidx);
|
buffer.AppendByte(c->caseidx);
|
||||||
/* Make some space for the 16-bit length */
|
/* Make some space for the 16-bit length */
|
||||||
uint pos = buffer.Length();
|
uint pos = buffer.size();
|
||||||
buffer.AppendByte(0);
|
buffer.AppendByte(0);
|
||||||
buffer.AppendByte(0);
|
buffer.AppendByte(0);
|
||||||
/* Write string */
|
/* Write string */
|
||||||
PutCommandString(&buffer, c->string);
|
PutCommandString(&buffer, c->string);
|
||||||
buffer.AppendByte(0); // terminate with a zero
|
buffer.AppendByte(0); // terminate with a zero
|
||||||
/* Fill in the length */
|
/* 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 + 0] = GB(size, 8, 8);
|
||||||
buffer[pos + 1] = GB(size, 0, 8);
|
buffer[pos + 1] = GB(size, 0, 8);
|
||||||
}
|
}
|
||||||
|
@ -1044,8 +1044,8 @@ void LanguageWriter::WriteLang(const StringData &data)
|
||||||
|
|
||||||
if (cmdp != NULL) PutCommandString(&buffer, cmdp);
|
if (cmdp != NULL) PutCommandString(&buffer, cmdp);
|
||||||
|
|
||||||
this->WriteLength(buffer.Length());
|
this->WriteLength(buffer.size());
|
||||||
this->Write(buffer.Begin(), buffer.Length());
|
this->Write(buffer.Begin(), buffer.size());
|
||||||
buffer.clear();
|
buffer.clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -674,7 +674,7 @@ public:
|
||||||
|
|
||||||
UText text = UTEXT_INITIALIZER;
|
UText text = UTEXT_INITIALIZER;
|
||||||
UErrorCode status = U_ZERO_ERROR;
|
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->char_itr->setText(&text, status);
|
||||||
this->word_itr->setText(&text, status);
|
this->word_itr->setText(&text, status);
|
||||||
this->char_itr->first();
|
this->char_itr->first();
|
||||||
|
@ -685,7 +685,7 @@ public:
|
||||||
{
|
{
|
||||||
/* Convert incoming position to an UTF-16 string index. */
|
/* Convert incoming position to an UTF-16 string index. */
|
||||||
uint utf16_pos = 0;
|
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) {
|
if (this->utf16_to_utf8[i] == pos) {
|
||||||
utf16_pos = i;
|
utf16_pos = i;
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -58,7 +58,7 @@ public:
|
||||||
* Check whether any filter words were entered.
|
* Check whether any filter words were entered.
|
||||||
* @return true if no 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 ResetState();
|
||||||
void AddLine(const char *str);
|
void AddLine(const char *str);
|
||||||
|
@ -68,7 +68,7 @@ public:
|
||||||
* Get the matching state of the current item.
|
* Get the matching state of the current item.
|
||||||
* @return true if matched.
|
* @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 */
|
#endif /* STRINGFILTER_TYPE_H */
|
||||||
|
|
|
@ -1952,7 +1952,7 @@ void InitializeLanguagePacks()
|
||||||
FioAppendDirectory(path, lastof(path), sp, LANG_DIR);
|
FioAppendDirectory(path, lastof(path), sp, LANG_DIR);
|
||||||
GetLanguageList(path);
|
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 */
|
/* Acquire the locale of the current system */
|
||||||
const char *lang = GetCurrentLocale("LC_MESSAGES");
|
const char *lang = GetCurrentLocale("LC_MESSAGES");
|
||||||
|
|
|
@ -45,10 +45,10 @@ TextEffectID AddTextEffect(StringID msg, int center, int y, uint8 duration, Text
|
||||||
if (_game_mode == GM_MENU) return INVALID_TE_ID;
|
if (_game_mode == GM_MENU) return INVALID_TE_ID;
|
||||||
|
|
||||||
TextEffectID i;
|
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 (_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);
|
TextEffect *te = _text_effects.Get(i);
|
||||||
|
|
||||||
|
|
|
@ -86,7 +86,7 @@ uint TextfileWindow::GetContentHeight()
|
||||||
int max_width = this->GetWidget<NWidgetCore>(WID_TF_BACKGROUND)->current_x - WD_FRAMETEXT_LEFT - WD_FRAMERECT_RIGHT;
|
int max_width = this->GetWidget<NWidgetCore>(WID_TF_BACKGROUND)->current_x - WD_FRAMETEXT_LEFT - WD_FRAMERECT_RIGHT;
|
||||||
|
|
||||||
uint height = 0;
|
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);
|
height += GetStringHeight(this->lines[i], max_width, FS_MONO);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -113,10 +113,10 @@ void TextfileWindow::SetupScrollbars()
|
||||||
this->hscroll->SetCount(0);
|
this->hscroll->SetCount(0);
|
||||||
} else {
|
} else {
|
||||||
uint max_length = 0;
|
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);
|
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);
|
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 line_height = FONT_HEIGHT_MONO;
|
||||||
int y_offset = -this->vscroll->GetPosition();
|
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)) {
|
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);
|
y_offset = DrawStringMultiLine(0, right - x, y_offset, bottom - y, this->lines[i], TC_WHITE, SA_TOP | SA_LEFT, false, FS_MONO);
|
||||||
} else {
|
} else {
|
||||||
|
@ -184,7 +184,7 @@ void TextfileWindow::SetupScrollbars()
|
||||||
|
|
||||||
/* virtual */ const char *TextfileWindow::NextString()
|
/* 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++];
|
return this->lines[this->search_iterator++];
|
||||||
}
|
}
|
||||||
|
|
|
@ -292,10 +292,10 @@ CommandCost CmdSetTimetableStart(TileIndex tile, DoCommandFlag flags, uint32 p1,
|
||||||
}
|
}
|
||||||
|
|
||||||
int total_duration = v->orders.list->GetTimetableTotalDuration();
|
int total_duration = v->orders.list->GetTimetableTotalDuration();
|
||||||
int num_vehs = vehs.Length();
|
int num_vehs = vehs.size();
|
||||||
|
|
||||||
if (num_vehs >= 2) {
|
if (num_vehs >= 2) {
|
||||||
QSortT(vehs.Begin(), vehs.Length(), &VehicleTimetableSorter);
|
QSortT(vehs.Begin(), vehs.size(), &VehicleTimetableSorter);
|
||||||
}
|
}
|
||||||
|
|
||||||
int base = vehs.FindIndex(v);
|
int base = vehs.FindIndex(v);
|
||||||
|
|
|
@ -659,7 +659,7 @@ private:
|
||||||
|
|
||||||
this->towns.shrink_to_fit();
|
this->towns.shrink_to_fit();
|
||||||
this->towns.RebuildDone();
|
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. */
|
/* Always sort the towns. */
|
||||||
this->last_town = NULL;
|
this->last_town = NULL;
|
||||||
|
@ -766,7 +766,7 @@ public:
|
||||||
case WID_TD_LIST: {
|
case WID_TD_LIST: {
|
||||||
int n = 0;
|
int n = 0;
|
||||||
int y = r.top + WD_FRAMERECT_TOP;
|
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);
|
DrawString(r.left + WD_FRAMERECT_LEFT, r.right, y, STR_TOWN_DIRECTORY_NONE);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -778,7 +778,7 @@ public:
|
||||||
int text_right = r.right - WD_FRAMERECT_RIGHT - (rtl ? icon_size.width + 2 : 0);
|
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;
|
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];
|
const Town *t = this->towns[i];
|
||||||
assert(t->xy != INVALID_TILE);
|
assert(t->xy != INVALID_TILE);
|
||||||
|
|
||||||
|
@ -826,7 +826,7 @@ public:
|
||||||
}
|
}
|
||||||
case WID_TD_LIST: {
|
case WID_TD_LIST: {
|
||||||
Dimension d = GetStringBoundingBox(STR_TOWN_DIRECTORY_NONE);
|
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];
|
const Town *t = this->towns[i];
|
||||||
|
|
||||||
assert(t != NULL);
|
assert(t != NULL);
|
||||||
|
@ -879,7 +879,7 @@ public:
|
||||||
|
|
||||||
case WID_TD_LIST: { // Click on Town Matrix
|
case WID_TD_LIST: { // Click on Town Matrix
|
||||||
uint id_v = this->vscroll->GetScrolledRowFromWidget(pt.y, this, WID_TD_LIST, WD_FRAMERECT_TOP);
|
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];
|
const Town *t = this->towns[id_v];
|
||||||
assert(t != NULL);
|
assert(t != NULL);
|
||||||
|
|
|
@ -833,7 +833,7 @@ static void MakeTrainBackup(TrainList &list, Train *t)
|
||||||
static void RestoreTrainBackup(TrainList &list)
|
static void RestoreTrainBackup(TrainList &list)
|
||||||
{
|
{
|
||||||
/* No train, nothing to do. */
|
/* No train, nothing to do. */
|
||||||
if (list.Length() == 0) return;
|
if (list.size() == 0) return;
|
||||||
|
|
||||||
Train *prev = NULL;
|
Train *prev = NULL;
|
||||||
/* Iterate over the list and rebuild it. */
|
/* Iterate over the list and rebuild it. */
|
||||||
|
|
|
@ -332,7 +332,7 @@ int GetTrainDetailsWndVScroll(VehicleID veh_id, TrainDetailsWindowTabs det_tab)
|
||||||
} else {
|
} else {
|
||||||
for (const Train *v = Train::Get(veh_id); v != NULL; v = v->GetNextVehicle()) {
|
for (const Train *v = Train::Get(veh_id); v != NULL; v = v->GetNextVehicle()) {
|
||||||
GetCargoSummaryOfArticulatedVehicle(v, &_cargo_summary);
|
GetCargoSummaryOfArticulatedVehicle(v, &_cargo_summary);
|
||||||
num += max(1u, _cargo_summary.Length());
|
num += max(1u, (unsigned)_cargo_summary.size());
|
||||||
|
|
||||||
uint length = GetLengthOfArticulatedVehicle(v);
|
uint length = GetLengthOfArticulatedVehicle(v);
|
||||||
if (length > TRAIN_DETAILS_MAX_INDENT) num++;
|
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;
|
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++) {
|
for (uint i = 0; i < num_lines; i++) {
|
||||||
int sprite_width = max<int>(dx, ScaleGUITrad(TRAIN_DETAILS_MIN_INDENT)) + 3;
|
int sprite_width = max<int>(dx, ScaleGUITrad(TRAIN_DETAILS_MIN_INDENT)) + 3;
|
||||||
int data_left = left + (rtl ? 0 : sprite_width);
|
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) {
|
switch (det_tab) {
|
||||||
case TDW_TAB_CARGO:
|
case TDW_TAB_CARGO:
|
||||||
if (i < _cargo_summary.Length()) {
|
if (i < _cargo_summary.size()) {
|
||||||
TrainDetailsCargoTab(&_cargo_summary[i], data_left, data_right, py);
|
TrainDetailsCargoTab(&_cargo_summary[i], data_left, data_right, py);
|
||||||
} else {
|
} else {
|
||||||
DrawString(data_left, data_right, py, STR_QUANTITY_N_A, TC_LIGHT_BLUE);
|
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;
|
break;
|
||||||
|
|
||||||
case TDW_TAB_CAPACITY:
|
case TDW_TAB_CAPACITY:
|
||||||
if (i < _cargo_summary.Length()) {
|
if (i < _cargo_summary.size()) {
|
||||||
TrainDetailsCapacityTab(&_cargo_summary[i], data_left, data_right, py);
|
TrainDetailsCapacityTab(&_cargo_summary[i], data_left, data_right, py);
|
||||||
} else {
|
} else {
|
||||||
SetDParam(0, STR_EMPTY);
|
SetDParam(0, STR_EMPTY);
|
||||||
|
|
|
@ -652,7 +652,7 @@ CommandCost CmdMassStartStopVehicle(TileIndex tile, DoCommandFlag flags, uint32
|
||||||
BuildDepotVehicleList(vli.vtype, tile, &list, NULL);
|
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];
|
const Vehicle *v = list[i];
|
||||||
|
|
||||||
if (!!(v->vehstatus & VS_STOPPED) != do_start) continue;
|
if (!!(v->vehstatus & VS_STOPPED) != do_start) continue;
|
||||||
|
@ -691,7 +691,7 @@ CommandCost CmdDepotSellAllVehicles(TileIndex tile, DoCommandFlag flags, uint32
|
||||||
|
|
||||||
CommandCost last_error = CMD_ERROR;
|
CommandCost last_error = CMD_ERROR;
|
||||||
bool had_success = false;
|
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);
|
CommandCost ret = DoCommand(tile, list[i]->index | (1 << 20), 0, flags, sell_command);
|
||||||
if (ret.Succeeded()) {
|
if (ret.Succeeded()) {
|
||||||
cost.AddCost(ret);
|
cost.AddCost(ret);
|
||||||
|
@ -725,7 +725,7 @@ CommandCost CmdDepotMassAutoReplace(TileIndex tile, DoCommandFlag flags, uint32
|
||||||
/* Get the list of vehicles in the depot */
|
/* Get the list of vehicles in the depot */
|
||||||
BuildDepotVehicleList(vehicle_type, tile, &list, &list, true);
|
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];
|
const Vehicle *v = list[i];
|
||||||
|
|
||||||
/* Ensure that the vehicle completely in the depot */
|
/* 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 */
|
/* Send all the vehicles to a depot */
|
||||||
bool had_success = false;
|
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];
|
const Vehicle *v = list[i];
|
||||||
CommandCost ret = DoCommand(v->tile, v->index | (service ? DEPOT_SERVICE : 0U) | DEPOT_DONT_CANCEL, 0, flags, GetCmdSendToDepot(vli.vtype));
|
CommandCost ret = DoCommand(v->tile, v->index | (service ? DEPOT_SERVICE : 0U) | DEPOT_DONT_CANCEL, 0, flags, GetCmdSendToDepot(vli.vtype));
|
||||||
|
|
||||||
|
|
|
@ -133,7 +133,7 @@ void BaseVehicleListWindow::BuildVehicleList()
|
||||||
this->unitnumber_digits = GetUnitNumberDigits(this->vehicles);
|
this->unitnumber_digits = GetUnitNumberDigits(this->vehicles);
|
||||||
|
|
||||||
this->vehicles.RebuildDone();
|
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)
|
void DepotSortList(VehicleList *list)
|
||||||
{
|
{
|
||||||
if (list->Length() < 2) return;
|
if (list->size() < 2) return;
|
||||||
QSortT(list->Begin(), list->Length(), &VehicleNumberSorter);
|
QSortT(list->Begin(), list->size(), &VehicleNumberSorter);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** draw the vehicle profit button in the vehicle list window. */
|
/** 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;
|
byte ret_refit_cyc = 0;
|
||||||
bool success = false;
|
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' */
|
/* 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) {
|
for (Vehicle *v = v_for; v != NULL; v = v->HasArticulatedPart() ? v->GetNextArticulatedPart() : NULL) {
|
||||||
const Engine *e = v->GetEngine();
|
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). */
|
/* 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 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];
|
const RefitOption &refit = list[i][j];
|
||||||
|
|
||||||
/* Hide subtypes if sel[0] does not match */
|
/* Hide subtypes if sel[0] does not match */
|
||||||
|
@ -359,11 +359,11 @@ static void DrawVehicleRefitWindow(const SubtypeList list[NUM_CARGO], const int
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (list[i].Length() > 1) {
|
if (list[i].size() > 1) {
|
||||||
if (refit.subtype != 0xFF) {
|
if (refit.subtype != 0xFF) {
|
||||||
/* Draw tree lines */
|
/* Draw tree lines */
|
||||||
int ycenter = y + FONT_HEIGHT_NORMAL / 2;
|
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);
|
GfxDrawLine(iconcenter, ycenter, iconinner, ycenter, linecolour);
|
||||||
} else {
|
} else {
|
||||||
/* Draw expand/collapse icon */
|
/* Draw expand/collapse icon */
|
||||||
|
@ -435,7 +435,7 @@ struct RefitWindow : public Window {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool first_vehicle = this->list[current_index].Length() == 0;
|
bool first_vehicle = this->list[current_index].size() == 0;
|
||||||
if (first_vehicle) {
|
if (first_vehicle) {
|
||||||
/* Keeping the current subtype is always an option. It also serves as the option in case of no subtypes */
|
/* 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();
|
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 */
|
/* No more subtypes for this vehicle, delete all subtypes >= refit_cyc */
|
||||||
SubtypeList &l = this->list[current_index];
|
SubtypeList &l = this->list[current_index];
|
||||||
/* 0xFF item is in front, other subtypes are sorted. So just truncate the list in the right spot */
|
/* 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) {
|
if (l[i].subtype >= refit_cyc) {
|
||||||
l.Resize(i);
|
l.Resize(i);
|
||||||
break;
|
break;
|
||||||
|
@ -491,8 +491,8 @@ struct RefitWindow : public Window {
|
||||||
/* Check whether the subtype matches with the subtype of earlier vehicles. */
|
/* Check whether the subtype matches with the subtype of earlier vehicles. */
|
||||||
uint pos = 1;
|
uint pos = 1;
|
||||||
SubtypeList &l = this->list[current_index];
|
SubtypeList &l = this->list[current_index];
|
||||||
while (pos < l.Length() && l[pos].subtype != refit_cyc) pos++;
|
while (pos < l.size() && l[pos].subtype != refit_cyc) pos++;
|
||||||
if (pos < l.Length() && l[pos].string != subtype) {
|
if (pos < l.size() && l[pos].string != subtype) {
|
||||||
/* String mismatch, remove item keeping the order */
|
/* String mismatch, remove item keeping the order */
|
||||||
l.ErasePreservingOrder(pos);
|
l.ErasePreservingOrder(pos);
|
||||||
}
|
}
|
||||||
|
@ -522,7 +522,7 @@ struct RefitWindow : public Window {
|
||||||
uint row = 0;
|
uint row = 0;
|
||||||
|
|
||||||
for (uint i = 0; i < NUM_CARGO; i++) {
|
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];
|
const RefitOption &refit = this->list[i][j];
|
||||||
|
|
||||||
/* Hide subtypes if sel[0] does not match */
|
/* Hide subtypes if sel[0] does not match */
|
||||||
|
@ -547,7 +547,7 @@ struct RefitWindow : public Window {
|
||||||
uint row = 0;
|
uint row = 0;
|
||||||
|
|
||||||
for (uint i = 0; i < NUM_CARGO; i++) {
|
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];
|
const RefitOption &refit = this->list[i][j];
|
||||||
|
|
||||||
/* Hide subtypes if sel[0] does not match */
|
/* Hide subtypes if sel[0] does not match */
|
||||||
|
@ -576,7 +576,7 @@ struct RefitWindow : public Window {
|
||||||
if (this->sel[0] < 0) return NULL;
|
if (this->sel[0] < 0) return NULL;
|
||||||
|
|
||||||
SubtypeList &l = this->list[this->sel[0]];
|
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]];
|
return &l[this->sel[1]];
|
||||||
}
|
}
|
||||||
|
@ -617,7 +617,7 @@ struct RefitWindow : public Window {
|
||||||
this->sel[1] = 0;
|
this->sel[1] = 0;
|
||||||
this->cargo = NULL;
|
this->cargo = NULL;
|
||||||
for (uint i = 0; this->cargo == NULL && i < NUM_CARGO; i++) {
|
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) {
|
if (list[i][j] == current_refit_option) {
|
||||||
this->sel[0] = i;
|
this->sel[0] = i;
|
||||||
this->sel[1] = j;
|
this->sel[1] = j;
|
||||||
|
@ -830,7 +830,7 @@ struct RefitWindow : public Window {
|
||||||
|
|
||||||
/* Check the width of all cargo information strings. */
|
/* Check the width of all cargo information strings. */
|
||||||
for (uint i = 0; i < NUM_CARGO; i++) {
|
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]);
|
StringID string = this->GetCapacityString(&list[i][j]);
|
||||||
if (string != INVALID_STRING_ID) {
|
if (string != INVALID_STRING_ID) {
|
||||||
Dimension dim = GetStringBoundingBox(string);
|
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 vehicle_button_x = rtl ? right - GetSpriteSize(SPR_PROFIT_LOT).width : left;
|
||||||
|
|
||||||
int y = r.top;
|
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) {
|
for (uint i = this->vscroll->GetPosition(); i < max; ++i) {
|
||||||
const Vehicle *v = this->vehicles[i];
|
const Vehicle *v = this->vehicles[i];
|
||||||
StringID str;
|
StringID str;
|
||||||
|
@ -1532,7 +1532,7 @@ public:
|
||||||
case WID_VL_CAPTION: {
|
case WID_VL_CAPTION: {
|
||||||
switch (this->vli.type) {
|
switch (this->vli.type) {
|
||||||
case VL_SHARED_ORDERS: // Shared Orders
|
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
|
/* We can't open this window without vehicles using this order
|
||||||
* and we should close the window when deleting the order. */
|
* and we should close the window when deleting the order. */
|
||||||
NOT_REACHED();
|
NOT_REACHED();
|
||||||
|
@ -1584,7 +1584,7 @@ public:
|
||||||
this->BuildVehicleList();
|
this->BuildVehicleList();
|
||||||
this->SortVehicleList();
|
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);
|
HideDropDownMenu(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1598,7 +1598,7 @@ public:
|
||||||
}
|
}
|
||||||
if (this->owner == _local_company) {
|
if (this->owner == _local_company) {
|
||||||
this->SetWidgetDisabledState(WID_VL_AVAILABLE_VEHICLES, this->vli.type != VL_STANDARD);
|
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_MANAGE_VEHICLES_DROPDOWN,
|
||||||
WID_VL_STOP_ALL,
|
WID_VL_STOP_ALL,
|
||||||
WID_VL_START_ALL,
|
WID_VL_START_ALL,
|
||||||
|
@ -1626,7 +1626,7 @@ public:
|
||||||
|
|
||||||
case WID_VL_LIST: { // Matrix to show vehicles
|
case WID_VL_LIST: { // Matrix to show vehicles
|
||||||
uint id_v = this->vscroll->GetScrolledRowFromWidget(pt.y, this, WID_VL_LIST);
|
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];
|
const Vehicle *v = this->vehicles[id_v];
|
||||||
if (!VehicleClicked(v)) ShowVehicleViewWindow(v);
|
if (!VehicleClicked(v)) ShowVehicleViewWindow(v);
|
||||||
|
@ -1657,7 +1657,7 @@ public:
|
||||||
this->vehicles.SetSortType(index);
|
this->vehicles.SetSortType(index);
|
||||||
break;
|
break;
|
||||||
case WID_VL_MANAGE_VEHICLES_DROPDOWN:
|
case WID_VL_MANAGE_VEHICLES_DROPDOWN:
|
||||||
assert(this->vehicles.Length() != 0);
|
assert(this->vehicles.size() != 0);
|
||||||
|
|
||||||
switch (index) {
|
switch (index) {
|
||||||
case ADI_REPLACE: // Replace window
|
case ADI_REPLACE: // Replace window
|
||||||
|
|
|
@ -598,7 +598,7 @@ void OffsetGroundSprite(int x, int y)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* _vd.last_child == NULL if foundation sprite was clipped by the viewport bounds */
|
/* _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].x = x * ZOOM_LVL_BASE;
|
||||||
_vd.foundation_offset[_vd.foundation_part].y = y * 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;
|
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();
|
ChildScreenSpriteToDraw *cs = _vd.child_screen_sprites_to_draw.Append();
|
||||||
cs->image = image;
|
cs->image = image;
|
||||||
|
@ -1584,7 +1584,7 @@ void ViewportDoDraw(const ViewPort *vp, int left, int top, int right, int bottom
|
||||||
|
|
||||||
DrawTextEffects(&_vd.dpi);
|
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();
|
ParentSpriteToDraw *psd_end = _vd.parent_sprites_to_draw.End();
|
||||||
for (ParentSpriteToDraw *it = _vd.parent_sprites_to_draw.Begin(); it != psd_end; it++) {
|
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);
|
vp->overlay->Draw(&dp);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_vd.string_sprites_to_draw.Length() != 0) {
|
if (_vd.string_sprites_to_draw.size() != 0) {
|
||||||
/* translate to world coordinates */
|
/* translate to world coordinates */
|
||||||
dp.left = UnScaleByZoom(_vd.dpi.left, zoom);
|
dp.left = UnScaleByZoom(_vd.dpi.left, zoom);
|
||||||
dp.top = UnScaleByZoom(_vd.dpi.top, zoom);
|
dp.top = UnScaleByZoom(_vd.dpi.top, zoom);
|
||||||
|
|
|
@ -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)
|
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)
|
: Window(&_dropdown_desc)
|
||||||
{
|
{
|
||||||
assert(list->Length() > 0);
|
assert(list->size() > 0);
|
||||||
|
|
||||||
this->position = position;
|
this->position = position;
|
||||||
|
|
||||||
|
@ -180,8 +180,8 @@ struct DropdownWindow : Window {
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Capacity is the average number of items visible */
|
/* Capacity is the average number of items visible */
|
||||||
this->vscroll->SetCapacity(size.height * (uint16)list->Length() / list_height);
|
this->vscroll->SetCapacity(size.height * (uint16)list->size() / list_height);
|
||||||
this->vscroll->SetCount((uint16)list->Length());
|
this->vscroll->SetCount((uint16)list->size());
|
||||||
|
|
||||||
this->parent_wnd_class = parent->window_class;
|
this->parent_wnd_class = parent->window_class;
|
||||||
this->parent_wnd_num = parent->window_number;
|
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 the dropdown doesn't fully fit, we need a dropdown. */
|
||||||
if (height > available_height) {
|
if (height > available_height) {
|
||||||
scroll = true;
|
scroll = true;
|
||||||
uint avg_height = height / list->Length();
|
uint avg_height = height / list->size();
|
||||||
|
|
||||||
/* Check at least there is space for one item. */
|
/* Check at least there is space for one item. */
|
||||||
assert(available_height >= avg_height);
|
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? */
|
/* No entries in the list? */
|
||||||
if (list->Length() == 0) {
|
if (list->size() == 0) {
|
||||||
delete list;
|
delete list;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -166,7 +166,7 @@ static int CDECL DescSorter(WindowDesc * const *a, WindowDesc * const *b)
|
||||||
void WindowDesc::SaveToConfig()
|
void WindowDesc::SaveToConfig()
|
||||||
{
|
{
|
||||||
/* Sort the stuff to get a nice ini file on first write */
|
/* 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();
|
IniFile *ini = new IniFile();
|
||||||
ini->LoadFromDisk(_windows_file, NO_DIRECTORY);
|
ini->LoadFromDisk(_windows_file, NO_DIRECTORY);
|
||||||
|
|
Loading…
Reference in New Issue