Codechange: Replaced SmallVector::[Begin|End]() with std alternatives
This commit is contained in:
@@ -137,8 +137,7 @@ bool ClientNetworkContentSocketHandler::Receive_SERVER_INFO(Packet *p)
|
||||
if (ci->state == ContentInfo::UNSELECTED && ci->filesize == 0) ci->state = ContentInfo::DOES_NOT_EXIST;
|
||||
|
||||
/* Do we already have a stub for this? */
|
||||
for (ContentIterator iter = this->infos.Begin(); iter != this->infos.End(); iter++) {
|
||||
ContentInfo *ici = *iter;
|
||||
for (ContentInfo *ici : this->infos) {
|
||||
if (ici->type == ci->type && ici->unique_id == ci->unique_id &&
|
||||
memcmp(ci->md5sum, ici->md5sum, sizeof(ci->md5sum)) == 0) {
|
||||
/* Preserve the name if possible */
|
||||
@@ -168,8 +167,8 @@ bool ClientNetworkContentSocketHandler::Receive_SERVER_INFO(Packet *p)
|
||||
this->infos.push_back(ci);
|
||||
|
||||
/* Incoming data means that we might need to reconsider dependencies */
|
||||
for (ContentIterator iter = this->infos.Begin(); iter != this->infos.End(); iter++) {
|
||||
this->CheckDependencyState(*iter);
|
||||
for (ContentInfo *ici : this->infos) {
|
||||
this->CheckDependencyState(ici);
|
||||
}
|
||||
|
||||
this->OnReceiveContentInfo(ci);
|
||||
@@ -253,8 +252,7 @@ void ClientNetworkContentSocketHandler::RequestContentList(ContentVector *cv, bo
|
||||
Packet *p = new Packet(send_md5sum ? PACKET_CONTENT_CLIENT_INFO_EXTID_MD5 : PACKET_CONTENT_CLIENT_INFO_EXTID);
|
||||
p->Send_uint8(cv->size());
|
||||
|
||||
for (ContentIterator iter = cv->Begin(); iter != cv->End(); iter++) {
|
||||
const ContentInfo *ci = *iter;
|
||||
for (const ContentInfo *ci : *cv) {
|
||||
p->Send_uint8((byte)ci->type);
|
||||
p->Send_uint32(ci->unique_id);
|
||||
if (!send_md5sum) continue;
|
||||
@@ -266,11 +264,9 @@ void ClientNetworkContentSocketHandler::RequestContentList(ContentVector *cv, bo
|
||||
|
||||
this->SendPacket(p);
|
||||
|
||||
for (ContentIterator iter = cv->Begin(); iter != cv->End(); iter++) {
|
||||
ContentInfo *ci = *iter;
|
||||
for (ContentInfo *ci : *cv) {
|
||||
bool found = false;
|
||||
for (ContentIterator iter2 = this->infos.Begin(); iter2 != this->infos.End(); iter2++) {
|
||||
ContentInfo *ci2 = *iter2;
|
||||
for (ContentInfo *ci2 : this->infos) {
|
||||
if (ci->type == ci2->type && ci->unique_id == ci2->unique_id &&
|
||||
(!send_md5sum || memcmp(ci->md5sum, ci2->md5sum, sizeof(ci->md5sum)) == 0)) {
|
||||
found = true;
|
||||
@@ -296,8 +292,7 @@ void ClientNetworkContentSocketHandler::DownloadSelectedContent(uint &files, uin
|
||||
bytes = 0;
|
||||
|
||||
ContentIDList content;
|
||||
for (ContentIterator iter = this->infos.Begin(); iter != this->infos.End(); iter++) {
|
||||
const ContentInfo *ci = *iter;
|
||||
for (const ContentInfo *ci : this->infos) {
|
||||
if (!ci->IsSelected() || ci->state == ContentInfo::ALREADY_HERE) continue;
|
||||
|
||||
content.push_back(ci->id);
|
||||
@@ -333,8 +328,8 @@ void ClientNetworkContentSocketHandler::DownloadSelectedContentHTTP(const Conten
|
||||
const char *lastof = content_request + bytes - 1;
|
||||
|
||||
char *p = content_request;
|
||||
for (const ContentID *id = content.Begin(); id != content.End(); id++) {
|
||||
p += seprintf(p, lastof, "%d\n", *id);
|
||||
for (const ContentID &id : content) {
|
||||
p += seprintf(p, lastof, "%d\n", id);
|
||||
}
|
||||
|
||||
this->http_response_index = -1;
|
||||
@@ -351,7 +346,7 @@ void ClientNetworkContentSocketHandler::DownloadSelectedContentHTTP(const Conten
|
||||
void ClientNetworkContentSocketHandler::DownloadSelectedContentFallback(const ContentIDList &content)
|
||||
{
|
||||
uint count = content.size();
|
||||
const ContentID *content_ids = content.Begin();
|
||||
const ContentID *content_ids = content.data();
|
||||
this->Connect();
|
||||
|
||||
while (count > 0) {
|
||||
@@ -626,7 +621,7 @@ void ClientNetworkContentSocketHandler::OnReceiveData(const char *data, size_t l
|
||||
#define check_and_terminate(p) { check_not_null(p); *(p) = '\0'; }
|
||||
|
||||
for (;;) {
|
||||
char *str = this->http_response.Begin() + this->http_response_index;
|
||||
char *str = this->http_response.data() + this->http_response_index;
|
||||
char *p = strchr(str, '\n');
|
||||
check_and_terminate(p);
|
||||
|
||||
@@ -713,7 +708,7 @@ ClientNetworkContentSocketHandler::~ClientNetworkContentSocketHandler()
|
||||
delete this->curInfo;
|
||||
if (this->curFile != NULL) fclose(this->curFile);
|
||||
|
||||
for (ContentIterator iter = this->infos.Begin(); iter != this->infos.End(); iter++) delete *iter;
|
||||
for (ContentInfo *ci : this->infos) delete ci;
|
||||
}
|
||||
|
||||
/** Connect to the content server. */
|
||||
@@ -807,8 +802,7 @@ void ClientNetworkContentSocketHandler::DownloadContentInfo(ContentID cid)
|
||||
*/
|
||||
ContentInfo *ClientNetworkContentSocketHandler::GetContent(ContentID cid)
|
||||
{
|
||||
for (ContentIterator iter = this->infos.Begin(); iter != this->infos.End(); iter++) {
|
||||
ContentInfo *ci = *iter;
|
||||
for (ContentInfo *ci : this->infos) {
|
||||
if (ci->id == cid) return ci;
|
||||
}
|
||||
return NULL;
|
||||
@@ -844,8 +838,7 @@ void ClientNetworkContentSocketHandler::Unselect(ContentID cid)
|
||||
/** Select everything we can select */
|
||||
void ClientNetworkContentSocketHandler::SelectAll()
|
||||
{
|
||||
for (ContentIterator iter = this->infos.Begin(); iter != this->infos.End(); iter++) {
|
||||
ContentInfo *ci = *iter;
|
||||
for (ContentInfo *ci : this->infos) {
|
||||
if (ci->state == ContentInfo::UNSELECTED) {
|
||||
ci->state = ContentInfo::SELECTED;
|
||||
this->CheckDependencyState(ci);
|
||||
@@ -856,8 +849,7 @@ void ClientNetworkContentSocketHandler::SelectAll()
|
||||
/** Select everything that's an update for something we've got */
|
||||
void ClientNetworkContentSocketHandler::SelectUpgrade()
|
||||
{
|
||||
for (ContentIterator iter = this->infos.Begin(); iter != this->infos.End(); iter++) {
|
||||
ContentInfo *ci = *iter;
|
||||
for (ContentInfo *ci : this->infos) {
|
||||
if (ci->state == ContentInfo::UNSELECTED && ci->upgrade) {
|
||||
ci->state = ContentInfo::SELECTED;
|
||||
this->CheckDependencyState(ci);
|
||||
@@ -868,8 +860,7 @@ void ClientNetworkContentSocketHandler::SelectUpgrade()
|
||||
/** Unselect everything that we've not downloaded so far. */
|
||||
void ClientNetworkContentSocketHandler::UnselectAll()
|
||||
{
|
||||
for (ContentIterator iter = this->infos.Begin(); iter != this->infos.End(); iter++) {
|
||||
ContentInfo *ci = *iter;
|
||||
for (ContentInfo *ci : this->infos) {
|
||||
if (ci->IsSelected() && ci->state != ContentInfo::ALREADY_HERE) ci->state = ContentInfo::UNSELECTED;
|
||||
}
|
||||
}
|
||||
@@ -899,8 +890,7 @@ void ClientNetworkContentSocketHandler::ToggleSelectedState(const ContentInfo *c
|
||||
*/
|
||||
void ClientNetworkContentSocketHandler::ReverseLookupDependency(ConstContentVector &parents, const ContentInfo *child) const
|
||||
{
|
||||
for (ConstContentIterator iter = this->infos.Begin(); iter != this->infos.End(); iter++) {
|
||||
const ContentInfo *ci = *iter;
|
||||
for (const ContentInfo * const &ci : this->infos) {
|
||||
if (ci == child) continue;
|
||||
|
||||
for (uint i = 0; i < ci->dependency_count; i++) {
|
||||
@@ -929,8 +919,8 @@ void ClientNetworkContentSocketHandler::ReverseLookupTreeDependency(ConstContent
|
||||
ConstContentVector parents;
|
||||
this->ReverseLookupDependency(parents, tree[i]);
|
||||
|
||||
for (ConstContentIterator piter = parents.Begin(); piter != parents.End(); piter++) {
|
||||
include(tree, *piter);
|
||||
for (const ContentInfo *ci : parents) {
|
||||
include(tree, ci);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -965,8 +955,7 @@ void ClientNetworkContentSocketHandler::CheckDependencyState(ContentInfo *ci)
|
||||
* we automatically selected them. */
|
||||
ConstContentVector parents;
|
||||
this->ReverseLookupDependency(parents, ci);
|
||||
for (ConstContentIterator iter = parents.Begin(); iter != parents.End(); iter++) {
|
||||
const ContentInfo *c = *iter;
|
||||
for (const ContentInfo *c : parents) {
|
||||
if (!c->IsSelected()) continue;
|
||||
|
||||
this->Unselect(c->id);
|
||||
@@ -987,9 +976,9 @@ void ClientNetworkContentSocketHandler::CheckDependencyState(ContentInfo *ci)
|
||||
/* First check whether anything depends on us */
|
||||
int sel_count = 0;
|
||||
bool force_selection = false;
|
||||
for (ConstContentIterator iter = parents.Begin(); iter != parents.End(); iter++) {
|
||||
if ((*iter)->IsSelected()) sel_count++;
|
||||
if ((*iter)->state == ContentInfo::SELECTED) force_selection = true;
|
||||
for (const ContentInfo *ci : parents) {
|
||||
if (ci->IsSelected()) sel_count++;
|
||||
if (ci->state == ContentInfo::SELECTED) force_selection = true;
|
||||
}
|
||||
if (sel_count == 0) {
|
||||
/* Nothing depends on us */
|
||||
@@ -1004,8 +993,8 @@ void ClientNetworkContentSocketHandler::CheckDependencyState(ContentInfo *ci)
|
||||
this->ReverseLookupTreeDependency(parents, c);
|
||||
|
||||
/* Is there anything that is "force" selected?, if so... we're done. */
|
||||
for (ConstContentIterator iter = parents.Begin(); iter != parents.End(); iter++) {
|
||||
if ((*iter)->state != ContentInfo::SELECTED) continue;
|
||||
for (const ContentInfo *ci : parents) {
|
||||
if (ci->state != ContentInfo::SELECTED) continue;
|
||||
|
||||
force_selection = true;
|
||||
break;
|
||||
@@ -1018,12 +1007,11 @@ void ClientNetworkContentSocketHandler::CheckDependencyState(ContentInfo *ci)
|
||||
* After that's done run over them once again to test their children
|
||||
* to unselect. Don't do it immediately because it'll do exactly what
|
||||
* we're doing now. */
|
||||
for (ConstContentIterator iter = parents.Begin(); iter != parents.End(); iter++) {
|
||||
const ContentInfo *c = *iter;
|
||||
for (const ContentInfo *c : parents) {
|
||||
if (c->state == ContentInfo::AUTOSELECTED) this->Unselect(c->id);
|
||||
}
|
||||
for (ConstContentIterator iter = parents.Begin(); iter != parents.End(); iter++) {
|
||||
this->CheckDependencyState(this->GetContent((*iter)->id));
|
||||
for (const ContentInfo *c : parents) {
|
||||
this->CheckDependencyState(this->GetContent(c->id));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1031,7 +1019,7 @@ void ClientNetworkContentSocketHandler::CheckDependencyState(ContentInfo *ci)
|
||||
/** Clear all downloaded content information. */
|
||||
void ClientNetworkContentSocketHandler::Clear()
|
||||
{
|
||||
for (ContentIterator iter = this->infos.Begin(); iter != this->infos.End(); iter++) delete *iter;
|
||||
for (ContentInfo *c : this->infos) delete c;
|
||||
|
||||
this->infos.clear();
|
||||
this->requested.clear();
|
||||
@@ -1041,37 +1029,37 @@ void ClientNetworkContentSocketHandler::Clear()
|
||||
|
||||
void ClientNetworkContentSocketHandler::OnConnect(bool success)
|
||||
{
|
||||
for (ContentCallback **iter = this->callbacks.Begin(); iter != this->callbacks.End(); /* nothing */) {
|
||||
for (auto iter = this->callbacks.begin(); iter != this->callbacks.end(); /* nothing */) {
|
||||
ContentCallback *cb = *iter;
|
||||
cb->OnConnect(success);
|
||||
if (iter != this->callbacks.End() && *iter == cb) iter++;
|
||||
if (iter != this->callbacks.end() && *iter == cb) iter++;
|
||||
}
|
||||
}
|
||||
|
||||
void ClientNetworkContentSocketHandler::OnDisconnect()
|
||||
{
|
||||
for (ContentCallback **iter = this->callbacks.Begin(); iter != this->callbacks.End(); /* nothing */) {
|
||||
for (auto iter = this->callbacks.begin(); iter != this->callbacks.end(); /* nothing */) {
|
||||
ContentCallback *cb = *iter;
|
||||
cb->OnDisconnect();
|
||||
if (iter != this->callbacks.End() && *iter == cb) iter++;
|
||||
if (iter != this->callbacks.end() && *iter == cb) iter++;
|
||||
}
|
||||
}
|
||||
|
||||
void ClientNetworkContentSocketHandler::OnReceiveContentInfo(const ContentInfo *ci)
|
||||
{
|
||||
for (ContentCallback **iter = this->callbacks.Begin(); iter != this->callbacks.End(); /* nothing */) {
|
||||
for (auto iter = this->callbacks.begin(); iter != this->callbacks.end(); /* nothing */) {
|
||||
ContentCallback *cb = *iter;
|
||||
cb->OnReceiveContentInfo(ci);
|
||||
if (iter != this->callbacks.End() && *iter == cb) iter++;
|
||||
if (iter != this->callbacks.end() && *iter == cb) iter++;
|
||||
}
|
||||
}
|
||||
|
||||
void ClientNetworkContentSocketHandler::OnDownloadProgress(const ContentInfo *ci, int bytes)
|
||||
{
|
||||
for (ContentCallback **iter = this->callbacks.Begin(); iter != this->callbacks.End(); /* nothing */) {
|
||||
for (auto iter = this->callbacks.begin(); iter != this->callbacks.end(); /* nothing */) {
|
||||
ContentCallback *cb = *iter;
|
||||
cb->OnDownloadProgress(ci, bytes);
|
||||
if (iter != this->callbacks.End() && *iter == cb) iter++;
|
||||
if (iter != this->callbacks.end() && *iter == cb) iter++;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1082,9 +1070,9 @@ void ClientNetworkContentSocketHandler::OnDownloadComplete(ContentID cid)
|
||||
ci->state = ContentInfo::ALREADY_HERE;
|
||||
}
|
||||
|
||||
for (ContentCallback **iter = this->callbacks.Begin(); iter != this->callbacks.End(); /* nothing */) {
|
||||
for (auto iter = this->callbacks.begin(); iter != this->callbacks.end(); /* nothing */) {
|
||||
ContentCallback *cb = *iter;
|
||||
cb->OnDownloadComplete(cid);
|
||||
if (iter != this->callbacks.End() && *iter == cb) iter++;
|
||||
if (iter != this->callbacks.end() && *iter == cb) iter++;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user