From 5392711ce1c0244bc4b986a50f3e65919f7617a9 Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Mon, 3 May 2021 01:31:49 +0300 Subject: [PATCH 54/55] Get rid of player_addr_hack() See osdn #42144 Signed-off-by: Marko Lindqvist --- client/plrdlg_common.c | 34 +++++++++++----------------------- client/plrdlg_common.h | 12 +++++------- 2 files changed, 16 insertions(+), 30 deletions(-) diff --git a/client/plrdlg_common.c b/client/plrdlg_common.c index 44b7642711..328fc694fb 100644 --- a/client/plrdlg_common.c +++ b/client/plrdlg_common.c @@ -269,10 +269,19 @@ const char *plrdlg_col_state(const struct player *plr) /************************************************************************//** Returns a string telling the player's client's hostname (the machine from which he is connecting). + + The host is kept as a blank address if no one is controlling the player, + even if there is observers. ****************************************************************************/ -static const char *col_host(const struct player *player) +static const char *col_host(const struct player *pplayer) { - return player_addr_hack(player); + conn_list_iterate(pplayer->connections, pconn) { + if (!pconn->observer) { + return pconn->addr; + } + } conn_list_iterate_end; + + return blank_addr_str; } /************************************************************************//** @@ -345,24 +354,3 @@ void init_player_dlg_common(void) player_dlg_columns[i].title = Q_(player_dlg_columns[i].title); } } - -/************************************************************************//** - The only place where this is used is the player dialog. - Eventually this should go the way of the dodo with everything here - moved into col_host above, but some of the older clients (+win32) still - use this function directly. - - This code in this function is only really needed so that the host is - kept as a blank address if no one is controlling a player, but there are - observers. -****************************************************************************/ -const char *player_addr_hack(const struct player *pplayer) -{ - conn_list_iterate(pplayer->connections, pconn) { - if (!pconn->observer) { - return pconn->addr; - } - } conn_list_iterate_end; - - return blank_addr_str; -} diff --git a/client/plrdlg_common.h b/client/plrdlg_common.h index 7d0b17ced3..810cb6f0e1 100644 --- a/client/plrdlg_common.h +++ b/client/plrdlg_common.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 @@ -39,11 +39,11 @@ typedef int (*plr_dlg_sort_func)(const struct player* p1, struct player_dlg_column { bool show; enum player_dlg_column_type type; - const char *title; /* already translated */ - const char *(*func)(const struct player *); /* if type = COL_*TEXT */ - bool (*bool_func)(const struct player *); /* if type = COL_BOOLEAN */ + const char *title; /* already translated */ + const char *(*func)(const struct player *); /* if type = COL_*TEXT */ + bool (*bool_func)(const struct player *); /* if type = COL_BOOLEAN */ plr_dlg_sort_func sort_func; - const char *tagname; /* for save_options */ + const char *tagname; /* for save_options */ }; extern struct player_dlg_column player_dlg_columns[]; @@ -54,8 +54,6 @@ const char *plrdlg_col_state(const struct player *plr); void init_player_dlg_common(void); int player_dlg_default_sort_column(void); -const char *player_addr_hack(const struct player *pplayer); - #ifdef __cplusplus } #endif /* __cplusplus */ -- 2.30.2