summaryrefslogtreecommitdiff
path: root/src/network
diff options
context:
space:
mode:
authorHenry Wilson <m3henry@googlemail.com>2019-02-18 22:39:06 +0000
committerPeterN <peter@fuzzle.org>2019-03-26 20:15:57 +0000
commita0f36a50e6324f570985f5010eb0543ec0673aeb (patch)
tree09f9c9abd097acc244f80366da42cb8702c7ed19 /src/network
parentca2f33c6d025c0c45fb4bc472493290445312de5 (diff)
downloadopenttd-a0f36a50e6324f570985f5010eb0543ec0673aeb.tar.xz
Codechange: Replaced SmallVector::Append() with std::vector::[push|emplace]_back()
Diffstat (limited to 'src/network')
-rw-r--r--src/network/core/host.cpp2
-rw-r--r--src/network/core/tcp_connect.cpp2
-rw-r--r--src/network/core/tcp_http.cpp2
-rw-r--r--src/network/core/udp.cpp6
-rw-r--r--src/network/network.cpp6
-rw-r--r--src/network/network_client.cpp2
-rw-r--r--src/network/network_content.cpp14
-rw-r--r--src/network/network_content_gui.cpp2
-rw-r--r--src/network/network_gui.cpp6
-rw-r--r--src/network/network_server.cpp2
10 files changed, 21 insertions, 23 deletions
diff --git a/src/network/core/host.cpp b/src/network/core/host.cpp
index c0365742b..1ea5389d4 100644
--- a/src/network/core/host.cpp
+++ b/src/network/core/host.cpp
@@ -100,7 +100,7 @@ static void NetworkFindBroadcastIPsInternal(NetworkAddressList *broadcast) // GE
if (ifa->ifa_broadaddr->sa_family != AF_INET) continue;
NetworkAddress addr(ifa->ifa_broadaddr, sizeof(sockaddr));
- if (std::none_of(broadcast->begin(), broadcast->end(), [&addr](NetworkAddress const& elem) -> bool { return elem == addr; })) *broadcast->Append() = addr;
+ if (std::none_of(broadcast->begin(), broadcast->end(), [&addr](NetworkAddress const& elem) -> bool { return elem == addr; })) broadcast->push_back(addr);
}
freeifaddrs(ifap);
}
diff --git a/src/network/core/tcp_connect.cpp b/src/network/core/tcp_connect.cpp
index 470d97e68..f3dc2cb9a 100644
--- a/src/network/core/tcp_connect.cpp
+++ b/src/network/core/tcp_connect.cpp
@@ -32,7 +32,7 @@ TCPConnecter::TCPConnecter(const NetworkAddress &address) :
sock(INVALID_SOCKET),
address(address)
{
- *_tcp_connecters.Append() = this;
+ _tcp_connecters.push_back(this);
if (!ThreadObject::New(TCPConnecter::ThreadEntry, this, &this->thread, "ottd:tcp")) {
this->Connect();
}
diff --git a/src/network/core/tcp_http.cpp b/src/network/core/tcp_http.cpp
index 2d3e89b4e..abec3fbc8 100644
--- a/src/network/core/tcp_http.cpp
+++ b/src/network/core/tcp_http.cpp
@@ -63,7 +63,7 @@ NetworkHTTPSocketHandler::NetworkHTTPSocketHandler(SOCKET s,
return;
}
- *_http_connections.Append() = this;
+ _http_connections.push_back(this);
}
/** Free whatever needs to be freed. */
diff --git a/src/network/core/udp.cpp b/src/network/core/udp.cpp
index db655c0cf..7babf78d6 100644
--- a/src/network/core/udp.cpp
+++ b/src/network/core/udp.cpp
@@ -26,14 +26,14 @@ NetworkUDPSocketHandler::NetworkUDPSocketHandler(NetworkAddressList *bind)
{
if (bind != NULL) {
for (NetworkAddress *addr = bind->Begin(); addr != bind->End(); addr++) {
- *this->bind.Append() = *addr;
+ this->bind.push_back(*addr);
}
} else {
/* As hostname NULL and port 0/NULL don't go well when
* resolving it we need to add an address for each of
* the address families we support. */
- *this->bind.Append() = NetworkAddress(NULL, 0, AF_INET);
- *this->bind.Append() = NetworkAddress(NULL, 0, AF_INET6);
+ this->bind.emplace_back(nullptr, 0, AF_INET);
+ this->bind.emplace_back(nullptr, 0, AF_INET6);
}
}
diff --git a/src/network/network.cpp b/src/network/network.cpp
index 3780258bd..1ddd7478c 100644
--- a/src/network/network.cpp
+++ b/src/network/network.cpp
@@ -633,12 +633,12 @@ void NetworkAddServer(const char *b)
void GetBindAddresses(NetworkAddressList *addresses, uint16 port)
{
for (char **iter = _network_bind_list.Begin(); iter != _network_bind_list.End(); iter++) {
- *addresses->Append() = NetworkAddress(*iter, port);
+ addresses->emplace_back(*iter, port);
}
/* No address, so bind to everything. */
if (addresses->size() == 0) {
- *addresses->Append() = NetworkAddress("", port);
+ addresses->emplace_back("", port);
}
}
@@ -650,7 +650,7 @@ void NetworkRebuildHostList()
_network_host_list.Clear();
for (NetworkGameList *item = _network_game_list; item != NULL; item = item->next) {
- if (item->manually) *_network_host_list.Append() = stredup(item->address.GetAddressAsString(false));
+ if (item->manually) _network_host_list.push_back(stredup(item->address.GetAddressAsString(false)));
}
}
diff --git a/src/network/network_client.cpp b/src/network/network_client.cpp
index a99a5069a..fff4dd328 100644
--- a/src/network/network_client.cpp
+++ b/src/network/network_client.cpp
@@ -77,7 +77,7 @@ struct PacketReader : LoadFilter {
/* Allocate a new chunk and add the remaining data. */
pbuf += to_write;
to_write = in_packet - to_write;
- this->buf = *this->blocks.Append() = CallocT<byte>(CHUNK);
+ this->blocks.push_back(this->buf = CallocT<byte>(CHUNK));
this->bufe = this->buf + CHUNK;
memcpy(this->buf, pbuf, to_write);
diff --git a/src/network/network_content.cpp b/src/network/network_content.cpp
index 54798f4b7..fe7905de8 100644
--- a/src/network/network_content.cpp
+++ b/src/network/network_content.cpp
@@ -165,7 +165,7 @@ bool ClientNetworkContentSocketHandler::Receive_SERVER_INFO(Packet *p)
return true;
}
- *this->infos.Append() = ci;
+ 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++) {
@@ -278,7 +278,7 @@ void ClientNetworkContentSocketHandler::RequestContentList(ContentVector *cv, bo
}
}
if (!found) {
- *this->infos.Append() = ci;
+ this->infos.push_back(ci);
} else {
delete ci;
}
@@ -300,7 +300,7 @@ void ClientNetworkContentSocketHandler::DownloadSelectedContent(uint &files, uin
const ContentInfo *ci = *iter;
if (!ci->IsSelected() || ci->state == ContentInfo::ALREADY_HERE) continue;
- *content.Append() = ci->id;
+ content.push_back(ci->id);
bytes += ci->filesize;
}
@@ -579,11 +579,11 @@ void ClientNetworkContentSocketHandler::OnReceiveData(const char *data, size_t l
if (this->http_response_index == -1) {
if (data != NULL) {
/* Append the rest of the response. */
- memcpy(this->http_response.Append((uint)length), data, length);
+ memcpy(grow(this->http_response, (uint)length), data, length);
return;
} else {
/* Make sure the response is properly terminated. */
- *this->http_response.Append() = '\0';
+ this->http_response.push_back('\0');
/* And prepare for receiving the rest of the data. */
this->http_response_index = 0;
@@ -905,7 +905,7 @@ void ClientNetworkContentSocketHandler::ReverseLookupDependency(ConstContentVect
for (uint i = 0; i < ci->dependency_count; i++) {
if (ci->dependencies[i] == child->id) {
- *parents.Append() = ci;
+ parents.push_back(ci);
break;
}
}
@@ -919,7 +919,7 @@ void ClientNetworkContentSocketHandler::ReverseLookupDependency(ConstContentVect
*/
void ClientNetworkContentSocketHandler::ReverseLookupTreeDependency(ConstContentVector &tree, const ContentInfo *child) const
{
- *tree.Append() = child;
+ tree.push_back(child);
/* First find all direct parents. We can't use the "normal" iterator as
* we are including stuff into the vector and as such the vector's data
diff --git a/src/network/network_content_gui.cpp b/src/network/network_content_gui.cpp
index 109e63c95..19c075258 100644
--- a/src/network/network_content_gui.cpp
+++ b/src/network/network_content_gui.cpp
@@ -391,7 +391,7 @@ class NetworkContentListWindow : public Window, ContentCallback {
for (ConstContentIterator iter = _network_content_client.Begin(); iter != _network_content_client.End(); iter++) {
if ((*iter)->state == ContentInfo::DOES_NOT_EXIST) all_available = false;
- *this->content.Append() = *iter;
+ this->content.push_back(*iter);
}
this->SetWidgetDisabledState(WID_NCL_SEARCH_EXTERNAL, this->auto_select && all_available);
diff --git a/src/network/network_gui.cpp b/src/network/network_gui.cpp
index e3c4555bf..7b65f6b0c 100644
--- a/src/network/network_gui.cpp
+++ b/src/network/network_gui.cpp
@@ -253,7 +253,7 @@ protected:
this->servers.clear();
for (NetworkGameList *ngl = _network_game_list; ngl != NULL; ngl = ngl->next) {
- *this->servers.Append() = ngl;
+ this->servers.push_back(ngl);
}
/* Apply the filter condition immediately, if a search string has been provided. */
@@ -1737,9 +1737,7 @@ struct NetworkClientListPopupWindow : Window {
*/
inline void AddAction(StringID name, ClientList_Action_Proc *proc)
{
- ClientListAction *action = this->actions.Append();
- action->name = name;
- action->proc = proc;
+ this->actions.push_back({name, proc});
}
NetworkClientListPopupWindow(WindowDesc *desc, int x, int y, ClientID client_id) :
diff --git a/src/network/network_server.cpp b/src/network/network_server.cpp
index 67f4c6fd9..8a1e75d2f 100644
--- a/src/network/network_server.cpp
+++ b/src/network/network_server.cpp
@@ -2101,7 +2101,7 @@ uint NetworkServerKickOrBanIP(const char *ip, bool ban)
break;
}
}
- if (!contains) *_network_ban_list.Append() = stredup(ip);
+ if (!contains) _network_ban_list.push_back(stredup(ip));
}
uint n = 0;