From a8f0bb1cc65e040ac380e6fe2e58e417662e8f47 Mon Sep 17 00:00:00 2001
From: Marko Lindqvist <cazfi74@gmail.com>
Date: Sun, 2 May 2021 18:31:31 +0300
Subject: [PATCH 51/51] clinet.[ch]: Improve coding style

See osdn #42148

Signed-off-by: Marko Lindqvist <cazfi74@gmail.com>
---
 client/clinet.c | 67 +++++++++++++++++++++++++------------------------
 client/clinet.h |  6 ++---
 2 files changed, 37 insertions(+), 36 deletions(-)

diff --git a/client/clinet.c b/client/clinet.c
index 17a389b2e3..c615e059e6 100644
--- a/client/clinet.c
+++ b/client/clinet.c
@@ -79,9 +79,9 @@
 #include "climisc.h"
 #include "connectdlg_common.h"
 #include "connectdlg_g.h"
-#include "dialogs_g.h"		/* popdown_races_dialog() */
-#include "gui_main_g.h"		/* add_net_input(), remove_net_input() */
-#include "mapview_common.h"	/* unqueue_mapview_update */
+#include "dialogs_g.h"          /* popdown_races_dialog() */
+#include "gui_main_g.h"         /* add_net_input(), remove_net_input() */
+#include "mapview_common.h"     /* unqueue_mapview_update */
 #include "menu_g.h"
 #include "messagewin_g.h"
 #include "options.h"
@@ -93,14 +93,12 @@
 #include "clinet.h"
 
 /* In autoconnect mode, try to connect to once a second */
-#define AUTOCONNECT_INTERVAL		500
+#define AUTOCONNECT_INTERVAL            500
 
 /* In autoconnect mode, try to connect 100 times */
-#define MAX_AUTOCONNECT_ATTEMPTS	100
+#define MAX_AUTOCONNECT_ATTEMPTS        100
 
-extern char forced_tileset_name[512];
 static struct fc_sockaddr_list *list = NULL;
-static int name_count;
 
 /**********************************************************************//**
   Close socket and cleanup.  This one doesn't print a message, so should
@@ -110,7 +108,7 @@ static void close_socket_nomessage(struct connection *pc)
 {
   connection_common_close(pc);
   remove_net_input();
-  popdown_races_dialog(); 
+  popdown_races_dialog();
   close_connection_dialog();
 
   set_client_state(C_S_DISCONNECTED);
@@ -149,6 +147,8 @@ static void client_conn_close_callback(struct connection *pconn)
 static int get_server_address(const char *hostname, int port,
                               char *errbuf, int errbufsize)
 {
+  int name_count;
+
   if (port == 0) {
 #ifdef FREECIV_JSON_CONNECTION
     port = FREECIV_JSON_PORT;
@@ -183,8 +183,8 @@ static int get_server_address(const char *hostname, int port,
   Try to connect to a server (get_server_address() must be called first!):
    - try to create a TCP socket and connect it to `names'
    - if successful:
-	  - start monitoring the socket for packets from the server
-	  - send a "login request" packet to the server
+          - start monitoring the socket for packets from the server
+          - send a "login request" packet to the server
       and - return 0
    - if unable to create the connection, close the socket, put an error
      message in ERRBUF and return the Unix error code (ie., errno, which
@@ -294,7 +294,7 @@ void make_connection(int sock, const char *username)
   sz_strlcpy(req.version_label, VERSION_LABEL);
   sz_strlcpy(req.capability, our_capability);
   sz_strlcpy(req.username, username);
-  
+
   send_packet_server_join_req(&client.conn, &req);
 }
 
@@ -310,7 +310,7 @@ void disconnect_from_server(void)
 
   stop_turn_change_wait();
 
-  /* If it's internal server - kill him 
+  /* If it's internal server - kill him
    * We assume that we are always connected to the internal server  */
   if (!force) {
     client_kill_server(FALSE);
@@ -417,10 +417,10 @@ void input_from_server(int fd)
       void *packet = get_packet_from_connection(&client.conn, &type);
 
       if (NULL != packet) {
-	client_packet_input(packet, type);
-	free(packet);
+        client_packet_input(packet, type);
+        free(packet);
       } else {
-	break;
+        break;
       }
     }
     if (client.conn.used) {
@@ -439,8 +439,8 @@ void input_from_server(int fd)
   the PACKET_PROCESSING_FINISHED packet for the given request is
   received.
 **************************************************************************/
-void input_from_server_till_request_got_processed(int fd, 
-						  int expected_request_id)
+void input_from_server_till_request_got_processed(int fd,
+                                                  int expected_request_id)
 {
   fc_assert_ret(expected_request_id);
   fc_assert_ret(fd == client.conn.sock);
@@ -455,24 +455,25 @@ void input_from_server_till_request_got_processed(int fd,
       enum packet_type type;
 
       while (TRUE) {
-	void *packet = get_packet_from_connection(&client.conn, &type);
-	if (NULL == packet) {
-	  break;
-	}
+        void *packet = get_packet_from_connection(&client.conn, &type);
+
+        if (NULL == packet) {
+          break;
+        }
 
-	client_packet_input(packet, type);
-	free(packet);
+        client_packet_input(packet, type);
+        free(packet);
 
-	if (type == PACKET_PROCESSING_FINISHED) {
+        if (type == PACKET_PROCESSING_FINISHED) {
           log_debug("ifstrgp: expect=%d, seen=%d",
                     expected_request_id,
                     client.conn.client.last_processed_request_id_seen);
-	  if (client.conn.client.last_processed_request_id_seen >=
-	      expected_request_id) {
+          if (client.conn.client.last_processed_request_id_seen >=
+              expected_request_id) {
             log_debug("ifstrgp: got it; returning");
-	    return;
-	  }
-	}
+            return;
+          }
+        }
       }
     } else if (-2 == nb) {
       connection_close(&client.conn, _("server disconnected"));
@@ -511,13 +512,13 @@ double try_to_autoconnect(void)
   }
 
   switch (try_to_connect(user_name, errbuf, sizeof(errbuf))) {
-  case 0:			/* Success! */
+  case 0:             /* Success! */
     /* Don't call me again */
     autoconnecting = FALSE;
     return FC_INFINITY;
 #ifndef FREECIV_MSWINDOWS
   /* See PR#4042 for more info on issues with try_to_connect() and errno. */
-  case ECONNREFUSED:		/* Server not available (yet) */
+  case ECONNREFUSED:  /* Server not available (yet) */
     if (!warning_shown) {
       log_error("Connection to server refused. Please start the server.");
       output_window_append(ftc_client, _("Connection to server refused. "
@@ -527,7 +528,7 @@ double try_to_autoconnect(void)
     /* Try again in 0.5 seconds */
     return 0.001 * AUTOCONNECT_INTERVAL;
 #endif /* FREECIV_MSWINDOWS */
-  default:			/* All other errors are fatal */
+  default:            /* All other errors are fatal */
     log_fatal(_("Error contacting server \"%s\" at port %d "
                 "as \"%s\":\n %s\n"),
               server_host, server_port, user_name, errbuf);
@@ -538,7 +539,7 @@ double try_to_autoconnect(void)
 }
 
 /**********************************************************************//**
-  Start trying to autoconnect to freeciv-server.  Calls
+  Start trying to autoconnect to freeciv-server. Calls
   get_server_address(), then arranges for try_to_autoconnect(), which
   calls try_to_connect(), to be called roughly every
   AUTOCONNECT_INTERVAL milliseconds, until success, fatal error or
diff --git a/client/clinet.h b/client/clinet.h
index e840e5155a..7af6bd60ae 100644
--- a/client/clinet.h
+++ b/client/clinet.h
@@ -1,4 +1,4 @@
-/********************************************************************** 
+/***********************************************************************
  Freeciv - Copyright (C) 1996 - A Kjeldberg, L Gregersen, P Unold
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -18,13 +18,13 @@ extern "C" {
 #endif /* __cplusplus */
 
 int connect_to_server(const char *username, const char *hostname, int port,
-		      char *errbuf, int errbufsize);
+                      char *errbuf, int errbufsize);
 
 void make_connection(int socket, const char *username);
 
 void input_from_server(int fd);
 void input_from_server_till_request_got_processed(int fd,
-						  int expected_request_id);
+                                                  int expected_request_id);
 void disconnect_from_server(void);
 
 double try_to_autoconnect(void);
-- 
2.30.2