Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Codechange: do not use all upper case enumerators in a scoped enum #9733

Merged
merged 1 commit into from Dec 5, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 8 additions & 8 deletions src/industry_gui.cpp
Expand Up @@ -1324,10 +1324,10 @@ class IndustryDirectoryWindow : public Window {
static CargoID produced_cargo_filter;

enum class SorterType : uint8 {
IDW_SORT_BY_NAME, ///< Sorter type to sort by name
IDW_SORT_BY_TYPE, ///< Sorter type to sort by type
IDW_SORT_BY_PRODUCTION, ///< Sorter type to sort by production amount
IDW_SORT_BY_TRANSPORTED, ///< Sorter type to sort by transported percentage
ByName, ///< Sorter type to sort by name
ByType, ///< Sorter type to sort by type
ByProduction, ///< Sorter type to sort by production amount
ByTransported, ///< Sorter type to sort by transported percentage
};

/**
Expand Down Expand Up @@ -1552,17 +1552,17 @@ class IndustryDirectoryWindow : public Window {
}

switch (static_cast<IndustryDirectoryWindow::SorterType>(this->industries.SortType())) {
case IndustryDirectoryWindow::SorterType::IDW_SORT_BY_NAME:
case IndustryDirectoryWindow::SorterType::IDW_SORT_BY_TYPE:
case IndustryDirectoryWindow::SorterType::IDW_SORT_BY_PRODUCTION:
case IndustryDirectoryWindow::SorterType::ByName:
case IndustryDirectoryWindow::SorterType::ByType:
case IndustryDirectoryWindow::SorterType::ByProduction:
/* Sort by descending production, then descending transported */
std::sort(cargos.begin(), cargos.end(), [](const CargoInfo &a, const CargoInfo &b) {
if (a.production != b.production) return a.production > b.production;
return a.transported > b.transported;
});
break;

case IndustryDirectoryWindow::SorterType::IDW_SORT_BY_TRANSPORTED:
case IndustryDirectoryWindow::SorterType::ByTransported:
/* Sort by descending transported, then descending production */
std::sort(cargos.begin(), cargos.end(), [](const CargoInfo &a, const CargoInfo &b) {
if (a.transported != b.transported) return a.transported > b.transported;
Expand Down
12 changes: 6 additions & 6 deletions src/network/core/tcp.h
Expand Up @@ -78,15 +78,15 @@ class TCPConnecter {
* 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.
Expand Down
28 changes: 14 additions & 14 deletions src/network/core/tcp_connect.cpp
Expand Up @@ -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;

Expand Down Expand Up @@ -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;
}

/**
Expand All @@ -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;
}

Expand All @@ -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;
}

Expand Down Expand Up @@ -403,7 +403,7 @@ bool TCPConnecter::CheckActivity()
}

this->OnConnect(connected_socket);
this->status = Status::CONNECTED;
this->status = Status::Connected;
return true;
}

Expand All @@ -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;

Expand All @@ -451,15 +451,15 @@ void TCPServerConnecter::SetConnected(SOCKET sock)
assert(sock != INVALID_SOCKET);

this->socket = sock;
this->status = Status::CONNECTED;
this->status = Status::Connected;
}

/**
* The connection couldn't be established.
*/
void TCPServerConnecter::SetFailure()
{
this->status = Status::FAILURE;
this->status = Status::Failure;
}

/**
Expand Down