summaryrefslogtreecommitdiff
path: root/src/network/core
diff options
context:
space:
mode:
authorRubidium <rubidium@openttd.org>2021-12-05 16:15:27 +0100
committerMichael Lutz <michi@icosahedron.de>2021-12-05 21:41:43 +0100
commitad89601c49bc5f4e996d2afea58db17fb1b01324 (patch)
tree1eb1e0f580fdfe8707625f46c4fca1e71ad329e0 /src/network/core
parentea4f6bb8b2a4e1298d1166febaaeebb3c9e583ed (diff)
downloadopenttd-ad89601c49bc5f4e996d2afea58db17fb1b01324.tar.xz
Codechange: do not use all upper case enumerators in a scoped enum
Diffstat (limited to 'src/network/core')
-rw-r--r--src/network/core/tcp.h12
-rw-r--r--src/network/core/tcp_connect.cpp28
2 files changed, 20 insertions, 20 deletions
diff --git a/src/network/core/tcp.h b/src/network/core/tcp.h
index 52d9cfddb..7bce8f6c0 100644
--- a/src/network/core/tcp.h
+++ b/src/network/core/tcp.h
@@ -78,15 +78,15 @@ private:
* lock on the game-state.
*/
enum class Status {
- INIT, ///< TCPConnecter is created but resolving hasn't started.
- RESOLVING, ///< The hostname is being resolved (threaded).
- FAILURE, ///< Resolving failed.
- CONNECTING, ///< We are currently connecting.
- CONNECTED, ///< The connection is established.
+ Init, ///< TCPConnecter is created but resolving hasn't started.
+ Resolving, ///< The hostname is being resolved (threaded).
+ Failure, ///< Resolving failed.
+ Connecting, ///< We are currently connecting.
+ Connected, ///< The connection is established.
};
std::thread resolve_thread; ///< Thread used during resolving.
- std::atomic<Status> status = Status::INIT; ///< The current status of the connecter.
+ std::atomic<Status> status = Status::Init; ///< The current status of the connecter.
std::atomic<bool> killed = false; ///< Whether this connecter is marked as killed.
addrinfo *ai = nullptr; ///< getaddrinfo() allocated linked-list of resolved addresses.
diff --git a/src/network/core/tcp_connect.cpp b/src/network/core/tcp_connect.cpp
index 8ef41ebf0..a9cc77934 100644
--- a/src/network/core/tcp_connect.cpp
+++ b/src/network/core/tcp_connect.cpp
@@ -52,7 +52,7 @@ TCPServerConnecter::TCPServerConnecter(const std::string &connection_string, uin
break;
case SERVER_ADDRESS_INVITE_CODE:
- this->status = Status::CONNECTING;
+ this->status = Status::Connecting;
_network_coordinator_client.ConnectToServer(this->server_address.connection_string, this);
break;
@@ -254,14 +254,14 @@ void TCPConnecter::Resolve()
if (error != 0) {
Debug(net, 0, "Failed to resolve DNS for {}", this->connection_string);
- this->status = Status::FAILURE;
+ this->status = Status::Failure;
return;
}
this->ai = ai;
this->OnResolved(ai);
- this->status = Status::CONNECTING;
+ this->status = Status::Connecting;
}
/**
@@ -281,11 +281,11 @@ bool TCPConnecter::CheckActivity()
if (this->killed) return true;
switch (this->status) {
- case Status::INIT:
+ case Status::Init:
/* Start the thread delayed, so the vtable is loaded. This allows classes
* to overload functions used by Resolve() (in case threading is disabled). */
if (StartNewThread(&this->resolve_thread, "ottd:resolve", &TCPConnecter::ResolveThunk, this)) {
- this->status = Status::RESOLVING;
+ this->status = Status::Resolving;
return false;
}
@@ -296,18 +296,18 @@ bool TCPConnecter::CheckActivity()
* connection. The rest of this function handles exactly that. */
break;
- case Status::RESOLVING:
+ case Status::Resolving:
/* Wait till Resolve() comes back with an answer (in case it runs threaded). */
return false;
- case Status::FAILURE:
+ case Status::Failure:
/* Ensure the OnFailure() is called from the game-thread instead of the
* resolve-thread, as otherwise we can get into some threading issues. */
this->OnFailure();
return true;
- case Status::CONNECTING:
- case Status::CONNECTED:
+ case Status::Connecting:
+ case Status::Connected:
break;
}
@@ -403,7 +403,7 @@ bool TCPConnecter::CheckActivity()
}
this->OnConnect(connected_socket);
- this->status = Status::CONNECTED;
+ this->status = Status::Connected;
return true;
}
@@ -422,11 +422,11 @@ bool TCPServerConnecter::CheckActivity()
case SERVER_ADDRESS_INVITE_CODE:
/* Check if a result has come in. */
switch (this->status) {
- case Status::FAILURE:
+ case Status::Failure:
this->OnFailure();
return true;
- case Status::CONNECTED:
+ case Status::Connected:
this->OnConnect(this->socket);
return true;
@@ -451,7 +451,7 @@ void TCPServerConnecter::SetConnected(SOCKET sock)
assert(sock != INVALID_SOCKET);
this->socket = sock;
- this->status = Status::CONNECTED;
+ this->status = Status::Connected;
}
/**
@@ -459,7 +459,7 @@ void TCPServerConnecter::SetConnected(SOCKET sock)
*/
void TCPServerConnecter::SetFailure()
{
- this->status = Status::FAILURE;
+ this->status = Status::Failure;
}
/**