summaryrefslogtreecommitdiff
path: root/src/network/network_udp.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/network/network_udp.cpp')
-rw-r--r--src/network/network_udp.cpp36
1 files changed, 18 insertions, 18 deletions
diff --git a/src/network/network_udp.cpp b/src/network/network_udp.cpp
index 7674036e7..d9f625719 100644
--- a/src/network/network_udp.cpp
+++ b/src/network/network_udp.cpp
@@ -45,9 +45,9 @@ static const uint32 ADVERTISE_NORMAL_INTERVAL = 15 * 60 * 1000; ///< interval be
static const uint32 ADVERTISE_RETRY_INTERVAL = 10 * 1000; ///< re-advertise when no response after this many ms (10 seconds)
static const uint32 ADVERTISE_RETRY_TIMES = 3; ///< give up re-advertising after this much failed retries
-NetworkUDPSocketHandler *_udp_client_socket = NULL; ///< udp client socket
-NetworkUDPSocketHandler *_udp_server_socket = NULL; ///< udp server socket
-NetworkUDPSocketHandler *_udp_master_socket = NULL; ///< udp master socket
+NetworkUDPSocketHandler *_udp_client_socket = nullptr; ///< udp client socket
+NetworkUDPSocketHandler *_udp_server_socket = nullptr; ///< udp server socket
+NetworkUDPSocketHandler *_udp_master_socket = nullptr; ///< udp master socket
/**
* Helper function doing the actual work for querying the server.
@@ -69,7 +69,7 @@ static void DoNetworkUDPQueryServer(NetworkAddress &address, bool needs_mutex, b
if (needs_mutex) lock.lock();
/* Init the packet */
Packet p(PACKET_UDP_CLIENT_FIND_SERVER);
- if (_udp_client_socket != NULL) _udp_client_socket->SendPacket(&p, &address);
+ if (_udp_client_socket != nullptr) _udp_client_socket->SendPacket(&p, &address);
}
/**
@@ -79,7 +79,7 @@ static void DoNetworkUDPQueryServer(NetworkAddress &address, bool needs_mutex, b
*/
void NetworkUDPQueryServer(NetworkAddress address, bool manually)
{
- if (address.IsResolved() || !StartNewThread(NULL, "ottd:udp-query", &DoNetworkUDPQueryServer, std::move(address), true, std::move(manually))) {
+ if (address.IsResolved() || !StartNewThread(nullptr, "ottd:udp-query", &DoNetworkUDPQueryServer, std::move(address), true, std::move(manually))) {
DoNetworkUDPQueryServer(address, true, manually);
}
}
@@ -261,7 +261,7 @@ void ServerNetworkUDPSocketHandler::Receive_CLIENT_GET_NEWGRFS(Packet *p, Networ
/* Find the matching GRF file */
f = FindGRFConfig(c.grfid, FGCM_EXACT, c.md5sum);
- if (f == NULL) continue; // The GRF is unknown to this server
+ if (f == nullptr) continue; // The GRF is unknown to this server
/* If the reply might exceed the size of the packet, only reply
* the current list and do not send the other data.
@@ -332,7 +332,7 @@ void ClientNetworkUDPSocketHandler::Receive_SERVER_RESPONSE(Packet *p, NetworkAd
const GRFConfig *c;
uint in_request_count = 0;
- for (c = item->info.grfconfig; c != NULL; c = c->next) {
+ for (c = item->info.grfconfig; c != nullptr; c = c->next) {
if (c->status == GCS_NOT_FOUND) item->info.compatible = false;
if (c->status != GCS_NOT_FOUND || strcmp(c->GetName(), UNKNOWN_GRF_NAME_PLACEHOLDER) != 0) continue;
in_request[in_request_count] = c;
@@ -431,7 +431,7 @@ void ClientNetworkUDPSocketHandler::Receive_SERVER_NEWGRFS(Packet *p, NetworkAdd
* If it exists and not resolved yet, then name of the fake GRF is
* overwritten with the name from the reply. */
GRFTextWrapper *unknown_name = FindUnknownGRFName(c.grfid, c.md5sum, false);
- if (unknown_name != NULL && strcmp(GetGRFStringFromGRFText(unknown_name->text), UNKNOWN_GRF_NAME_PLACEHOLDER) == 0) {
+ if (unknown_name != nullptr && strcmp(GetGRFStringFromGRFText(unknown_name->text), UNKNOWN_GRF_NAME_PLACEHOLDER) == 0) {
AddGRFTextToList(&unknown_name->text, name);
}
}
@@ -441,7 +441,7 @@ void ClientNetworkUDPSocketHandler::HandleIncomingNetworkGameInfoGRFConfig(GRFCo
{
/* Find the matching GRF file */
const GRFConfig *f = FindGRFConfig(config->ident.grfid, FGCM_EXACT, config->ident.md5sum);
- if (f == NULL) {
+ if (f == nullptr) {
/* Don't know the GRF, so mark game incompatible and the (possibly)
* already resolved name for this GRF (another server has sent the
* name of the GRF already */
@@ -521,7 +521,7 @@ static void NetworkUDPRemoveAdvertiseThread()
p.Send_uint16(_settings_client.network.server_port);
std::lock_guard<std::mutex> lock(_network_udp_mutex);
- if (_udp_master_socket != NULL) _udp_master_socket->SendPacket(&p, &out_addr, true);
+ if (_udp_master_socket != nullptr) _udp_master_socket->SendPacket(&p, &out_addr, true);
}
/**
@@ -533,7 +533,7 @@ void NetworkUDPRemoveAdvertise(bool blocking)
/* Check if we are advertising */
if (!_networking || !_network_server || !_network_udp_server) return;
- if (blocking || !StartNewThread(NULL, "ottd:udp-advert", &NetworkUDPRemoveAdvertiseThread)) {
+ if (blocking || !StartNewThread(nullptr, "ottd:udp-advert", &NetworkUDPRemoveAdvertiseThread)) {
NetworkUDPRemoveAdvertiseThread();
}
}
@@ -573,7 +573,7 @@ static void NetworkUDPAdvertiseThread()
p.Send_uint64(_session_key);
std::lock_guard<std::mutex> lock(_network_udp_mutex);
- if (_udp_master_socket != NULL) _udp_master_socket->SendPacket(&p, &out_addr, true);
+ if (_udp_master_socket != nullptr) _udp_master_socket->SendPacket(&p, &out_addr, true);
}
/**
@@ -614,7 +614,7 @@ void NetworkUDPAdvertise()
if (_next_advertisement < _last_advertisement) _next_advertisement = UINT32_MAX;
if (_next_retry < _last_advertisement) _next_retry = UINT32_MAX;
- if (!StartNewThread(NULL, "ottd:udp-advert", &NetworkUDPAdvertiseThread)) {
+ if (!StartNewThread(nullptr, "ottd:udp-advert", &NetworkUDPAdvertiseThread)) {
NetworkUDPAdvertiseThread();
}
}
@@ -623,10 +623,10 @@ void NetworkUDPAdvertise()
void NetworkUDPInitialize()
{
/* If not closed, then do it. */
- if (_udp_server_socket != NULL) NetworkUDPClose();
+ if (_udp_server_socket != nullptr) NetworkUDPClose();
DEBUG(net, 1, "[udp] initializing listeners");
- assert(_udp_client_socket == NULL && _udp_server_socket == NULL && _udp_master_socket == NULL);
+ assert(_udp_client_socket == nullptr && _udp_server_socket == nullptr && _udp_master_socket == nullptr);
std::lock_guard<std::mutex> lock(_network_udp_mutex);
@@ -654,9 +654,9 @@ void NetworkUDPClose()
delete _udp_client_socket;
delete _udp_server_socket;
delete _udp_master_socket;
- _udp_client_socket = NULL;
- _udp_server_socket = NULL;
- _udp_master_socket = NULL;
+ _udp_client_socket = nullptr;
+ _udp_server_socket = nullptr;
+ _udp_master_socket = nullptr;
_network_udp_server = false;
_network_udp_broadcast = 0;