Codechange: Replace SmallVector::Length() with std::vector::size()
This commit is contained in:
@@ -297,7 +297,7 @@ int NetworkHTTPSocketHandler::Receive()
|
||||
/* static */ void NetworkHTTPSocketHandler::HTTPReceive()
|
||||
{
|
||||
/* No connections, just bail out. */
|
||||
if (_http_connections.Length() == 0) return;
|
||||
if (_http_connections.size() == 0) return;
|
||||
|
||||
fd_set read_fd;
|
||||
struct timeval tv;
|
||||
|
@@ -140,7 +140,7 @@ public:
|
||||
*/
|
||||
static bool Listen(uint16 port)
|
||||
{
|
||||
assert(sockets.Length() == 0);
|
||||
assert(sockets.size() == 0);
|
||||
|
||||
NetworkAddressList addresses;
|
||||
GetBindAddresses(&addresses, port);
|
||||
@@ -149,7 +149,7 @@ public:
|
||||
address->Listen(SOCK_STREAM, &sockets);
|
||||
}
|
||||
|
||||
if (sockets.Length() == 0) {
|
||||
if (sockets.size() == 0) {
|
||||
DEBUG(net, 0, "[server] could not start network: could not create listening socket");
|
||||
NetworkError(STR_NETWORK_ERROR_SERVER_START);
|
||||
return false;
|
||||
|
@@ -51,7 +51,7 @@ bool NetworkUDPSocketHandler::Listen()
|
||||
addr->Listen(SOCK_DGRAM, &this->sockets);
|
||||
}
|
||||
|
||||
return this->sockets.Length() != 0;
|
||||
return this->sockets.size() != 0;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -80,7 +80,7 @@ NetworkRecvStatus NetworkUDPSocketHandler::CloseConnection(bool error)
|
||||
*/
|
||||
void NetworkUDPSocketHandler::SendPacket(Packet *p, NetworkAddress *recv, bool all, bool broadcast)
|
||||
{
|
||||
if (this->sockets.Length() == 0) this->Listen();
|
||||
if (this->sockets.size() == 0) this->Listen();
|
||||
|
||||
for (SocketList::iterator s = this->sockets.Begin(); s != this->sockets.End(); s++) {
|
||||
/* Make a local copy because if we resolve it we cannot
|
||||
|
@@ -637,7 +637,7 @@ void GetBindAddresses(NetworkAddressList *addresses, uint16 port)
|
||||
}
|
||||
|
||||
/* No address, so bind to everything. */
|
||||
if (addresses->Length() == 0) {
|
||||
if (addresses->size() == 0) {
|
||||
*addresses->Append() = NetworkAddress("", port);
|
||||
}
|
||||
}
|
||||
|
@@ -246,12 +246,12 @@ void ClientNetworkContentSocketHandler::RequestContentList(ContentVector *cv, bo
|
||||
|
||||
this->Connect();
|
||||
|
||||
assert(cv->Length() < 255);
|
||||
assert(cv->Length() < (SEND_MTU - sizeof(PacketSize) - sizeof(byte) - sizeof(uint8)) /
|
||||
assert(cv->size() < 255);
|
||||
assert(cv->size() < (SEND_MTU - sizeof(PacketSize) - sizeof(byte) - sizeof(uint8)) /
|
||||
(sizeof(uint8) + sizeof(uint32) + (send_md5sum ? /*sizeof(ContentInfo::md5sum)*/16 : 0)));
|
||||
|
||||
Packet *p = new Packet(send_md5sum ? PACKET_CONTENT_CLIENT_INFO_EXTID_MD5 : PACKET_CONTENT_CLIENT_INFO_EXTID);
|
||||
p->Send_uint8(cv->Length());
|
||||
p->Send_uint8(cv->size());
|
||||
|
||||
for (ContentIterator iter = cv->Begin(); iter != cv->End(); iter++) {
|
||||
const ContentInfo *ci = *iter;
|
||||
@@ -304,7 +304,7 @@ void ClientNetworkContentSocketHandler::DownloadSelectedContent(uint &files, uin
|
||||
bytes += ci->filesize;
|
||||
}
|
||||
|
||||
files = content.Length();
|
||||
files = content.size();
|
||||
|
||||
/* If there's nothing to download, do nothing. */
|
||||
if (files == 0) return;
|
||||
@@ -322,7 +322,7 @@ void ClientNetworkContentSocketHandler::DownloadSelectedContent(uint &files, uin
|
||||
*/
|
||||
void ClientNetworkContentSocketHandler::DownloadSelectedContentHTTP(const ContentIDList &content)
|
||||
{
|
||||
uint count = content.Length();
|
||||
uint count = content.size();
|
||||
|
||||
/* Allocate memory for the whole request.
|
||||
* Requests are "id\nid\n..." (as strings), so assume the maximum ID,
|
||||
@@ -350,7 +350,7 @@ void ClientNetworkContentSocketHandler::DownloadSelectedContentHTTP(const Conten
|
||||
*/
|
||||
void ClientNetworkContentSocketHandler::DownloadSelectedContentFallback(const ContentIDList &content)
|
||||
{
|
||||
uint count = content.Length();
|
||||
uint count = content.size();
|
||||
const ContentID *content_ids = content.Begin();
|
||||
this->Connect();
|
||||
|
||||
@@ -607,7 +607,7 @@ void ClientNetworkContentSocketHandler::OnReceiveData(const char *data, size_t l
|
||||
this->AfterDownload();
|
||||
}
|
||||
|
||||
if ((uint)this->http_response_index >= this->http_response.Length()) {
|
||||
if ((uint)this->http_response_index >= this->http_response.size()) {
|
||||
/* It's not a real failure, but if there's
|
||||
* nothing more to download it helps with
|
||||
* cleaning up the stuff we allocated. */
|
||||
@@ -653,7 +653,7 @@ void ClientNetworkContentSocketHandler::OnReceiveData(const char *data, size_t l
|
||||
str = p + 1;
|
||||
/* Is it a fallback URL? If so, just continue with the next one. */
|
||||
if (strncmp(str, "ottd", 4) == 0) {
|
||||
if ((uint)this->http_response_index >= this->http_response.Length()) {
|
||||
if ((uint)this->http_response_index >= this->http_response.size()) {
|
||||
/* Have we gone through all lines? */
|
||||
this->OnFailure();
|
||||
return;
|
||||
@@ -925,7 +925,7 @@ void ClientNetworkContentSocketHandler::ReverseLookupTreeDependency(ConstContent
|
||||
* we are including stuff into the vector and as such the vector's data
|
||||
* store can be reallocated (and thus move), which means out iterating
|
||||
* pointer gets invalid. So fall back to the indices. */
|
||||
for (uint i = 0; i < tree.Length(); i++) {
|
||||
for (uint i = 0; i < tree.size(); i++) {
|
||||
ConstContentVector parents;
|
||||
this->ReverseLookupDependency(parents, tree[i]);
|
||||
|
||||
|
@@ -129,7 +129,7 @@ public:
|
||||
void CheckDependencyState(ContentInfo *ci);
|
||||
|
||||
/** Get the number of content items we know locally. */
|
||||
uint Length() const { return this->infos.Length(); }
|
||||
uint Length() const { return this->infos.size(); }
|
||||
/** Get the begin of the content inf iterator. */
|
||||
ConstContentIterator Begin() const { return this->infos.Begin(); }
|
||||
/** Get the nth position of the content inf iterator. */
|
||||
|
@@ -401,7 +401,7 @@ class NetworkContentListWindow : public Window, ContentCallback {
|
||||
this->content.RebuildDone();
|
||||
this->SortContentList();
|
||||
|
||||
this->vscroll->SetCount(this->content.Length()); // Update the scrollbar
|
||||
this->vscroll->SetCount(this->content.size()); // Update the scrollbar
|
||||
this->ScrollToSelected();
|
||||
}
|
||||
|
||||
@@ -791,7 +791,7 @@ public:
|
||||
switch (widget) {
|
||||
case WID_NCL_MATRIX: {
|
||||
uint id_v = this->vscroll->GetScrolledRowFromWidget(pt.y, this, WID_NCL_MATRIX);
|
||||
if (id_v >= this->content.Length()) return; // click out of bounds
|
||||
if (id_v >= this->content.size()) return; // click out of bounds
|
||||
|
||||
this->selected = *this->content.Get(id_v);
|
||||
this->list_pos = id_v;
|
||||
@@ -815,7 +815,7 @@ public:
|
||||
case WID_NCL_NAME:
|
||||
if (this->content.SortType() == widget - WID_NCL_CHECKBOX) {
|
||||
this->content.ToggleSortOrder();
|
||||
if (this->content.Length() > 0) this->list_pos = this->content.Length() - this->list_pos - 1;
|
||||
if (this->content.size() > 0) this->list_pos = this->content.size() - this->list_pos - 1;
|
||||
} else {
|
||||
this->content.SetSortType(widget - WID_NCL_CHECKBOX);
|
||||
this->content.ForceResort();
|
||||
@@ -874,7 +874,7 @@ public:
|
||||
break;
|
||||
case WKC_DOWN:
|
||||
/* scroll down by one */
|
||||
if (this->list_pos < (int)this->content.Length() - 1) this->list_pos++;
|
||||
if (this->list_pos < (int)this->content.size() - 1) this->list_pos++;
|
||||
break;
|
||||
case WKC_PAGEUP:
|
||||
/* scroll up a page */
|
||||
@@ -882,7 +882,7 @@ public:
|
||||
break;
|
||||
case WKC_PAGEDOWN:
|
||||
/* scroll down a page */
|
||||
this->list_pos = min(this->list_pos + this->vscroll->GetCapacity(), (int)this->content.Length() - 1);
|
||||
this->list_pos = min(this->list_pos + this->vscroll->GetCapacity(), (int)this->content.size() - 1);
|
||||
break;
|
||||
case WKC_HOME:
|
||||
/* jump to beginning */
|
||||
@@ -890,7 +890,7 @@ public:
|
||||
break;
|
||||
case WKC_END:
|
||||
/* jump to end */
|
||||
this->list_pos = this->content.Length() - 1;
|
||||
this->list_pos = this->content.size() - 1;
|
||||
break;
|
||||
|
||||
case WKC_SPACE:
|
||||
@@ -914,7 +914,7 @@ public:
|
||||
return ES_NOT_HANDLED;
|
||||
}
|
||||
|
||||
if (this->content.Length() == 0) {
|
||||
if (this->content.size() == 0) {
|
||||
this->list_pos = 0; // above stuff may result in "-1".
|
||||
if (this->UpdateFilterState()) {
|
||||
this->content.ForceRebuild();
|
||||
|
@@ -269,7 +269,7 @@ protected:
|
||||
|
||||
this->servers.shrink_to_fit();
|
||||
this->servers.RebuildDone();
|
||||
this->vscroll->SetCount(this->servers.Length());
|
||||
this->vscroll->SetCount(this->servers.size());
|
||||
|
||||
/* Sort the list of network games as requested. */
|
||||
this->servers.Sort();
|
||||
@@ -354,7 +354,7 @@ protected:
|
||||
void UpdateListPos()
|
||||
{
|
||||
this->list_pos = SLP_INVALID;
|
||||
for (uint i = 0; i != this->servers.Length(); i++) {
|
||||
for (uint i = 0; i != this->servers.size(); i++) {
|
||||
if (this->servers[i] == this->server) {
|
||||
this->list_pos = i;
|
||||
break;
|
||||
@@ -564,7 +564,7 @@ public:
|
||||
case WID_NG_MATRIX: {
|
||||
uint16 y = r.top;
|
||||
|
||||
const int max = min(this->vscroll->GetPosition() + this->vscroll->GetCapacity(), (int)this->servers.Length());
|
||||
const int max = min(this->vscroll->GetPosition() + this->vscroll->GetCapacity(), (int)this->servers.size());
|
||||
|
||||
for (int i = this->vscroll->GetPosition(); i < max; ++i) {
|
||||
const NetworkGameList *ngl = this->servers[i];
|
||||
@@ -710,7 +710,7 @@ public:
|
||||
case WID_NG_INFO: // Connectivity (green dot)
|
||||
if (this->servers.SortType() == widget - WID_NG_NAME) {
|
||||
this->servers.ToggleSortOrder();
|
||||
if (this->list_pos != SLP_INVALID) this->list_pos = this->servers.Length() - this->list_pos - 1;
|
||||
if (this->list_pos != SLP_INVALID) this->list_pos = this->servers.size() - this->list_pos - 1;
|
||||
} else {
|
||||
this->servers.SetSortType(widget - WID_NG_NAME);
|
||||
this->servers.ForceResort();
|
||||
@@ -722,7 +722,7 @@ public:
|
||||
|
||||
case WID_NG_MATRIX: { // Show available network games
|
||||
uint id_v = this->vscroll->GetScrolledRowFromWidget(pt.y, this, WID_NG_MATRIX);
|
||||
this->server = (id_v < this->servers.Length()) ? this->servers[id_v] : NULL;
|
||||
this->server = (id_v < this->servers.size()) ? this->servers[id_v] : NULL;
|
||||
this->list_pos = (server == NULL) ? SLP_INVALID : id_v;
|
||||
this->SetDirty();
|
||||
|
||||
@@ -819,7 +819,7 @@ public:
|
||||
|
||||
/* handle up, down, pageup, pagedown, home and end */
|
||||
if (keycode == WKC_UP || keycode == WKC_DOWN || keycode == WKC_PAGEUP || keycode == WKC_PAGEDOWN || keycode == WKC_HOME || keycode == WKC_END) {
|
||||
if (this->servers.Length() == 0) return ES_HANDLED;
|
||||
if (this->servers.size() == 0) return ES_HANDLED;
|
||||
switch (keycode) {
|
||||
case WKC_UP:
|
||||
/* scroll up by one */
|
||||
@@ -829,7 +829,7 @@ public:
|
||||
case WKC_DOWN:
|
||||
/* scroll down by one */
|
||||
if (this->list_pos == SLP_INVALID) return ES_HANDLED;
|
||||
if (this->list_pos < this->servers.Length() - 1) this->list_pos++;
|
||||
if (this->list_pos < this->servers.size() - 1) this->list_pos++;
|
||||
break;
|
||||
case WKC_PAGEUP:
|
||||
/* scroll up a page */
|
||||
@@ -839,7 +839,7 @@ public:
|
||||
case WKC_PAGEDOWN:
|
||||
/* scroll down a page */
|
||||
if (this->list_pos == SLP_INVALID) return ES_HANDLED;
|
||||
this->list_pos = min(this->list_pos + this->vscroll->GetCapacity(), (int)this->servers.Length() - 1);
|
||||
this->list_pos = min(this->list_pos + this->vscroll->GetCapacity(), (int)this->servers.size() - 1);
|
||||
break;
|
||||
case WKC_HOME:
|
||||
/* jump to beginning */
|
||||
@@ -847,7 +847,7 @@ public:
|
||||
break;
|
||||
case WKC_END:
|
||||
/* jump to end */
|
||||
this->list_pos = this->servers.Length() - 1;
|
||||
this->list_pos = this->servers.size() - 1;
|
||||
break;
|
||||
default: NOT_REACHED();
|
||||
}
|
||||
@@ -1789,7 +1789,7 @@ struct NetworkClientListPopupWindow : Window {
|
||||
d = maxdim(GetStringBoundingBox(action->name), d);
|
||||
}
|
||||
|
||||
d.height *= this->actions.Length();
|
||||
d.height *= this->actions.size();
|
||||
d.width += WD_FRAMERECT_LEFT + WD_FRAMERECT_RIGHT;
|
||||
d.height += WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM;
|
||||
*size = d;
|
||||
@@ -1819,12 +1819,12 @@ struct NetworkClientListPopupWindow : Window {
|
||||
uint index = (_cursor.pos.y - this->top - WD_FRAMERECT_TOP) / FONT_HEIGHT_NORMAL;
|
||||
|
||||
if (_left_button_down) {
|
||||
if (index == this->sel_index || index >= this->actions.Length()) return;
|
||||
if (index == this->sel_index || index >= this->actions.size()) return;
|
||||
|
||||
this->sel_index = index;
|
||||
this->SetDirty();
|
||||
} else {
|
||||
if (index < this->actions.Length() && _cursor.pos.y >= this->top) {
|
||||
if (index < this->actions.size() && _cursor.pos.y >= this->top) {
|
||||
const NetworkClientInfo *ci = NetworkClientInfo::GetByClientID(this->client_id);
|
||||
if (ci != NULL) this->actions[index].proc(ci);
|
||||
}
|
||||
|
Reference in New Issue
Block a user