mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2026-07-25 08:22:17 +00:00
Codechange: make NetworkJoinStatus a scoped enum and remove unused value/strings
This commit is contained in:
@@ -2485,15 +2485,13 @@ STR_NETWORK_CONNECTING_WAITING :{BLACK}{NUM} cl
|
||||
STR_NETWORK_CONNECTING_DOWNLOADING_1 :{BLACK}{BYTES} downloaded so far
|
||||
STR_NETWORK_CONNECTING_DOWNLOADING_2 :{BLACK}{BYTES} / {BYTES} downloaded so far
|
||||
|
||||
###length 8
|
||||
###length 6
|
||||
STR_NETWORK_CONNECTING_1 :{BLACK}(1/6) Connecting...
|
||||
STR_NETWORK_CONNECTING_2 :{BLACK}(2/6) Authorising...
|
||||
STR_NETWORK_CONNECTING_3 :{BLACK}(3/6) Waiting...
|
||||
STR_NETWORK_CONNECTING_4 :{BLACK}(4/6) Downloading map...
|
||||
STR_NETWORK_CONNECTING_5 :{BLACK}(5/6) Processing data...
|
||||
STR_NETWORK_CONNECTING_6 :{BLACK}(6/6) Registering...
|
||||
STR_NETWORK_CONNECTING_SPECIAL_1 :{BLACK}Fetching game info...
|
||||
STR_NETWORK_CONNECTING_SPECIAL_2 :{BLACK}Fetching company info...
|
||||
|
||||
STR_NETWORK_CONNECTION_DISCONNECT :{BLACK}Disconnect
|
||||
|
||||
|
||||
@@ -823,8 +823,8 @@ void NetworkClientJoinGame()
|
||||
NetworkInitialize();
|
||||
|
||||
_settings_client.network.last_joined = _network_join.connection_string;
|
||||
Debug(net, 9, "status = CONNECTING");
|
||||
_network_join_status = NETWORK_JOIN_STATUS_CONNECTING;
|
||||
Debug(net, 9, "status = Connecting");
|
||||
_network_join_status = NetworkJoinStatus::Connecting;
|
||||
ShowJoinStatusWindow();
|
||||
|
||||
TCPConnecter::Create<TCPClientConnecter>(_network_join.connection_string);
|
||||
|
||||
@@ -292,8 +292,8 @@ NetworkRecvStatus ClientNetworkGameSocketHandler::SendJoin()
|
||||
|
||||
Debug(net, 9, "Client::status = JOIN");
|
||||
my_client->status = STATUS_JOIN;
|
||||
Debug(net, 9, "Client::join_status = AUTHORIZING");
|
||||
_network_join_status = NETWORK_JOIN_STATUS_AUTHORIZING;
|
||||
Debug(net, 9, "Client::join_status = Authorizing");
|
||||
_network_join_status = NetworkJoinStatus::Authorizing;
|
||||
SetWindowDirty(WC_NETWORK_STATUS_WINDOW, WN_NETWORK_STATUS_WINDOW_JOIN);
|
||||
|
||||
auto p = std::make_unique<Packet>(my_client, PACKET_CLIENT_JOIN);
|
||||
@@ -774,8 +774,8 @@ NetworkRecvStatus ClientNetworkGameSocketHandler::Receive_SERVER_WAIT(Packet &p)
|
||||
Debug(net, 9, "Client::Receive_SERVER_WAIT()");
|
||||
|
||||
/* But... only now we set the join status to waiting, instead of requesting. */
|
||||
Debug(net, 9, "Client::join_status = WAITING");
|
||||
_network_join_status = NETWORK_JOIN_STATUS_WAITING;
|
||||
Debug(net, 9, "Client::join_status = Waiting");
|
||||
_network_join_status = NetworkJoinStatus::Waiting;
|
||||
_network_join_waiting = p.Recv_uint8();
|
||||
SetWindowDirty(WC_NETWORK_STATUS_WINDOW, WN_NETWORK_STATUS_WINDOW_JOIN);
|
||||
|
||||
@@ -799,8 +799,8 @@ NetworkRecvStatus ClientNetworkGameSocketHandler::Receive_SERVER_MAP_BEGIN(Packe
|
||||
_network_join_bytes = 0;
|
||||
_network_join_bytes_total = 0;
|
||||
|
||||
Debug(net, 9, "Client::join_status = DOWNLOADING");
|
||||
_network_join_status = NETWORK_JOIN_STATUS_DOWNLOADING;
|
||||
Debug(net, 9, "Client::join_status = Downloading");
|
||||
_network_join_status = NetworkJoinStatus::Downloading;
|
||||
SetWindowDirty(WC_NETWORK_STATUS_WINDOW, WN_NETWORK_STATUS_WINDOW_JOIN);
|
||||
|
||||
return NETWORK_RECV_STATUS_OKAY;
|
||||
@@ -840,8 +840,8 @@ NetworkRecvStatus ClientNetworkGameSocketHandler::Receive_SERVER_MAP_DONE(Packet
|
||||
|
||||
Debug(net, 9, "Client::Receive_SERVER_MAP_DONE()");
|
||||
|
||||
Debug(net, 9, "Client::join_status = PROCESSING");
|
||||
_network_join_status = NETWORK_JOIN_STATUS_PROCESSING;
|
||||
Debug(net, 9, "Client::join_status = Processing");
|
||||
_network_join_status = NetworkJoinStatus::Processing;
|
||||
SetWindowDirty(WC_NETWORK_STATUS_WINDOW, WN_NETWORK_STATUS_WINDOW_JOIN);
|
||||
|
||||
this->savegame->Reset();
|
||||
@@ -882,8 +882,8 @@ NetworkRecvStatus ClientNetworkGameSocketHandler::Receive_SERVER_MAP_DONE(Packet
|
||||
if (_network_join.company != COMPANY_SPECTATOR) {
|
||||
/* We have arrived and ready to start playing; send a command to make a new company;
|
||||
* the server will give us a client-id and let us in */
|
||||
Debug(net, 9, "Client::join_status = REGISTERING");
|
||||
_network_join_status = NETWORK_JOIN_STATUS_REGISTERING;
|
||||
Debug(net, 9, "Client::join_status = Registering");
|
||||
_network_join_status = NetworkJoinStatus::Registering;
|
||||
ShowJoinStatusWindow();
|
||||
Command<Commands::CompanyControl>::Post(CompanyCtrlAction::New, CompanyID::Invalid(), CompanyRemoveReason::None, _network_own_client_id);
|
||||
}
|
||||
|
||||
@@ -2037,15 +2037,14 @@ struct NetworkJoinStatusWindow : Window {
|
||||
Rect ir = r.Shrink(WidgetDimensions::scaled.bevel);
|
||||
uint8_t progress; // used for progress bar
|
||||
switch (_network_join_status) {
|
||||
case NETWORK_JOIN_STATUS_CONNECTING:
|
||||
case NETWORK_JOIN_STATUS_AUTHORIZING:
|
||||
case NETWORK_JOIN_STATUS_GETTING_COMPANY_INFO:
|
||||
case NetworkJoinStatus::Connecting:
|
||||
case NetworkJoinStatus::Authorizing:
|
||||
progress = 10; // first two stages 10%
|
||||
break;
|
||||
case NETWORK_JOIN_STATUS_WAITING:
|
||||
case NetworkJoinStatus::Waiting:
|
||||
progress = 15; // third stage is 15%
|
||||
break;
|
||||
case NETWORK_JOIN_STATUS_DOWNLOADING:
|
||||
case NetworkJoinStatus::Downloading:
|
||||
if (_network_join_bytes_total == 0) {
|
||||
progress = 15; // We don't have the final size yet; the server is still compressing!
|
||||
break;
|
||||
@@ -2057,17 +2056,17 @@ struct NetworkJoinStatusWindow : Window {
|
||||
break;
|
||||
}
|
||||
DrawFrameRect(ir.WithWidth(ir.Width() * progress / 100, _current_text_dir == TD_RTL), COLOUR_MAUVE, {});
|
||||
DrawString(ir.left, ir.right, CentreBounds(ir.top, ir.bottom, GetCharacterHeight(FS_NORMAL)), STR_NETWORK_CONNECTING_1 + _network_join_status, TC_FROMSTRING, SA_HOR_CENTER);
|
||||
DrawString(ir.left, ir.right, CentreBounds(ir.top, ir.bottom, GetCharacterHeight(FS_NORMAL)), STR_NETWORK_CONNECTING_1 + to_underlying(_network_join_status), TC_FROMSTRING, SA_HOR_CENTER);
|
||||
break;
|
||||
}
|
||||
|
||||
case WID_NJS_PROGRESS_TEXT:
|
||||
switch (_network_join_status) {
|
||||
case NETWORK_JOIN_STATUS_WAITING:
|
||||
case NetworkJoinStatus::Waiting:
|
||||
DrawStringMultiLine(r, GetString(STR_NETWORK_CONNECTING_WAITING, _network_join_waiting), TC_FROMSTRING, SA_CENTER);
|
||||
break;
|
||||
|
||||
case NETWORK_JOIN_STATUS_DOWNLOADING:
|
||||
case NetworkJoinStatus::Downloading:
|
||||
if (_network_join_bytes_total == 0) {
|
||||
DrawStringMultiLine(r, GetString(STR_NETWORK_CONNECTING_DOWNLOADING_1, _network_join_bytes), TC_FROMSTRING, SA_CENTER);
|
||||
} else {
|
||||
@@ -2087,7 +2086,7 @@ struct NetworkJoinStatusWindow : Window {
|
||||
switch (widget) {
|
||||
case WID_NJS_PROGRESS_BAR:
|
||||
/* Account for the statuses */
|
||||
for (uint i = 0; i < NETWORK_JOIN_STATUS_END; i++) {
|
||||
for (uint i = 0; i < to_underlying(NetworkJoinStatus::End); i++) {
|
||||
size = maxdim(size, GetStringBoundingBox(STR_NETWORK_CONNECTING_1 + i));
|
||||
}
|
||||
/* For the number of waiting (other) players */
|
||||
|
||||
@@ -41,16 +41,15 @@
|
||||
typedef class ServerNetworkGameSocketHandler NetworkClientSocket;
|
||||
|
||||
/** Status of the clients during joining. */
|
||||
enum NetworkJoinStatus : uint8_t {
|
||||
NETWORK_JOIN_STATUS_CONNECTING,
|
||||
NETWORK_JOIN_STATUS_AUTHORIZING,
|
||||
NETWORK_JOIN_STATUS_WAITING,
|
||||
NETWORK_JOIN_STATUS_DOWNLOADING,
|
||||
NETWORK_JOIN_STATUS_PROCESSING,
|
||||
NETWORK_JOIN_STATUS_REGISTERING,
|
||||
enum class NetworkJoinStatus : uint8_t {
|
||||
Connecting, ///< Opening the connection to the server.
|
||||
Authorizing, ///< Starting authorizing the client to join the game and optionally company.
|
||||
Waiting, ///< Waiting for other clients to finish downloading the map.
|
||||
Downloading, ///< Downloading the map from the server.
|
||||
Processing, ///< Loading the savegame.
|
||||
Registering, ///< Creating a new company.
|
||||
|
||||
NETWORK_JOIN_STATUS_GETTING_COMPANY_INFO,
|
||||
NETWORK_JOIN_STATUS_END,
|
||||
End, ///< Sentinel for end-of-enumeration.
|
||||
};
|
||||
|
||||
extern uint32_t _frame_counter_server; // The frame_counter of the server, if in network-mode
|
||||
|
||||
Reference in New Issue
Block a user