From 75be9b85f42c4f4957e97b6051cce431ffa52069 Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Fri, 29 Sep 2023 01:47:27 +0300 Subject: [PATCH 41/41] caravan_parameter_log_real(): Fix dead 'foreign' initialization See osdn #48623 Signed-off-by: Marko Lindqvist --- common/aicore/caravan.c | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/common/aicore/caravan.c b/common/aicore/caravan.c index 3702070aef..7c874666d0 100644 --- a/common/aicore/caravan.c +++ b/common/aicore/caravan.c @@ -91,29 +91,31 @@ bool caravan_parameter_is_legal(const struct caravan_parameter *parameter) } /************************************************************************//** - For debugging, print out the parameter. + Human readable name of the foreign_trade_limit ****************************************************************************/ -void caravan_parameter_log_real(const struct caravan_parameter *parameter, - enum log_level level, const char *file, - const char *function, int line) +static const char *ftl_name(enum foreign_trade_limit ftl) { - const char *foreign = ""; - - switch (parameter->allow_foreign_trade) { + switch (ftl) { case FTL_NATIONAL_ONLY: - foreign = "no"; - break; + return "no"; case FTL_ALLIED: - foreign = "allied"; - break; + return "allied"; case FTL_PEACEFUL: - foreign = "peaceful"; - break; + return "peaceful"; case FTL_NONWAR: - foreign = "anything but enemies"; - break; + return "anything but enemies"; } + return ""; +} + +/************************************************************************//** + For debugging, print out the parameter. +****************************************************************************/ +void caravan_parameter_log_real(const struct caravan_parameter *parameter, + enum log_level level, const char *file, + const char *function, int line) +{ do_log(file, function, line, FALSE, level, "parameter {\n" " horizon = %d\n" @@ -130,7 +132,7 @@ void caravan_parameter_log_real(const struct caravan_parameter *parameter, parameter->consider_trade ? "trade" : "-", parameter->consider_wonders ? "wonders" : "-", parameter->account_for_broken_routes ? "yes" : "no", - foreign, + ftl_name(parameter->allow_foreign_trade), parameter->ignore_transit_time ? "yes" : "no", parameter->convert_trade ? "yes" : "no"); } -- 2.40.1