From 28f75e62735e13a603f75c4264f94a2ce7d5d908 Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Mon, 22 Aug 2022 05:42:11 +0300 Subject: [PATCH 19/19] rssanity: Use ruleset_error() instead of log_error() See osdn #44372 Signed-off-by: Marko Lindqvist --- server/rssanity.c | 96 +++++++++++++++++++++++++++-------------------- 1 file changed, 55 insertions(+), 41 deletions(-) diff --git a/server/rssanity.c b/server/rssanity.c index 58686543fc..179ae3c83e 100644 --- a/server/rssanity.c +++ b/server/rssanity.c @@ -44,9 +44,10 @@ static bool sanity_check_metadata(void) { if (game.ruleset_summary != NULL && strlen(game.ruleset_summary) > MAX_LEN_CONTENT) { - log_error("Too long ruleset summary. It can be only %d bytes long. " - "Put longer explanations to ruleset description.", - MAX_LEN_CONTENT); + ruleset_error(LOG_ERROR, + "Too long ruleset summary. It can be only %d bytes long. " + "Put longer explanations to ruleset description.", + MAX_LEN_CONTENT); return FALSE; } @@ -159,15 +160,17 @@ static bool sanity_check_req_individual(struct requirement *preq, { struct impr_type *pimprove = preq->source.value.building; if (preq->range == REQ_RANGE_WORLD && !is_great_wonder(pimprove)) { - log_error("%s: World-ranged requirement not supported for " - "%s (only great wonders supported)", list_for, - improvement_name_translation(pimprove)); + ruleset_error(LOG_ERROR, + "%s: World-ranged requirement not supported for " + "%s (only great wonders supported)", list_for, + improvement_name_translation(pimprove)); return FALSE; } else if (preq->range > REQ_RANGE_TRADEROUTE && !is_wonder(pimprove)) { - log_error("%s: %s-ranged requirement not supported for " - "%s (only wonders supported)", list_for, - req_range_name(preq->range), - improvement_name_translation(pimprove)); + ruleset_error(LOG_ERROR, + "%s: %s-ranged requirement not supported for " + "%s (only wonders supported)", list_for, + req_range_name(preq->range), + improvement_name_translation(pimprove)); return FALSE; } } @@ -176,13 +179,15 @@ static bool sanity_check_req_individual(struct requirement *preq, /* Currently [calendar] is loaded after some requirements are * parsed, so we can't do this in universal_value_from_str(). */ if (game.calendar.calendar_fragments < 1) { - log_error("%s: MinCalFrag requirement used in ruleset without " - "calendar fragments", list_for); + ruleset_error(LOG_ERROR, + "%s: MinCalFrag requirement used in ruleset without " + "calendar fragments", list_for); return FALSE; } else if (preq->source.value.mincalfrag >= game.calendar.calendar_fragments) { - log_error("%s: MinCalFrag requirement %d out of range (max %d in " - "this ruleset)", list_for, preq->source.value.mincalfrag, - game.calendar.calendar_fragments-1); + ruleset_error(LOG_ERROR, + "%s: MinCalFrag requirement %d out of range (max %d in " + "this ruleset)", list_for, preq->source.value.mincalfrag, + game.calendar.calendar_fragments-1); return FALSE; } break; @@ -198,19 +203,21 @@ static bool sanity_check_req_individual(struct requirement *preq, pset = setting_by_number(id); if (!sanity_check_setting_is_seen(pset)) { - log_error("%s: ServerSetting requirement %s isn't visible enough " - "to appear in a requirement. Everyone should be able to " - "see the value of a server setting that appears in a " - "requirement.", list_for, server_setting_name_get(id)); + ruleset_error(LOG_ERROR, + "%s: ServerSetting requirement %s isn't visible enough " + "to appear in a requirement. Everyone should be able to " + "see the value of a server setting that appears in a " + "requirement.", list_for, server_setting_name_get(id)); return FALSE; } if (!sanity_check_setting_is_game_rule(pset)) { /* This is a server operator related setting (like the compression * type of savegames), not a game rule. */ - log_error("%s: ServerSetting requirement setting %s isn't about a " - "game rule.", - list_for, server_setting_name_get(id)); + ruleset_error(LOG_ERROR, + "%s: ServerSetting requirement setting %s isn't about a " + "game rule.", + list_for, server_setting_name_get(id)); return FALSE; } } @@ -256,15 +263,17 @@ static bool sanity_check_req_set(int reqs_of_type[], int local_reqs_of_type[], switch (preq->source.kind) { case VUT_TERRAINCLASS: if (local_reqs_of_type[VUT_TERRAIN] > 0) { - log_error("%s: Requirement list has both local terrain and terrainclass requirement", - list_for); + ruleset_error(LOG_ERROR, + "%s: Requirement list has both local terrain and terrainclass requirement", + list_for); return FALSE; } break; case VUT_TERRAIN: if (local_reqs_of_type[VUT_TERRAINCLASS] > 0) { - log_error("%s: Requirement list has both local terrain and terrainclass requirement", - list_for); + ruleset_error(LOG_ERROR, + "%s: Requirement list has both local terrain and terrainclass requirement", + list_for); return FALSE; } break; @@ -298,26 +307,29 @@ static bool sanity_check_req_set(int reqs_of_type[], int local_reqs_of_type[], * Requirements might be identical, but we consider multiple * declarations error anyway. */ - log_error("%s: Requirement list has multiple %s requirements", - list_for, universal_type_rule_name(&preq->source)); + ruleset_error(LOG_ERROR, + "%s: Requirement list has multiple %s requirements", + list_for, universal_type_rule_name(&preq->source)); return FALSE; break; case VUT_TERRAIN: /* There can be only up to max_tiles requirements of these types */ if (max_tiles != -1 && rc > max_tiles) { - log_error("%s: Requirement list has more %s requirements than " - "can ever be fulfilled.", list_for, - universal_type_rule_name(&preq->source)); + ruleset_error(LOG_ERROR, + "%s: Requirement list has more %s requirements than " + "can ever be fulfilled.", list_for, + universal_type_rule_name(&preq->source)); return FALSE; } break; case VUT_TERRAINCLASS: if (rc > 2 || (max_tiles != -1 && rc > max_tiles)) { - log_error("%s: Requirement list has more %s requirements than " - "can ever be fulfilled.", list_for, - universal_type_rule_name(&preq->source)); + ruleset_error(LOG_ERROR, + "%s: Requirement list has more %s requirements than " + "can ever be fulfilled.", list_for, + universal_type_rule_name(&preq->source)); return FALSE; } break; @@ -325,9 +337,10 @@ static bool sanity_check_req_set(int reqs_of_type[], int local_reqs_of_type[], case VUT_AGE: /* There can be age of the city, unit, and player */ if (rc > 3) { - log_error("%s: Requirement list has more %s requirements than " - "can ever be fulfilled.", list_for, - universal_type_rule_name(&preq->source)); + ruleset_error(LOG_ERROR, + "%s: Requirement list has more %s requirements than " + "can ever be fulfilled.", list_for, + universal_type_rule_name(&preq->source)); return FALSE; } break; @@ -335,9 +348,10 @@ static bool sanity_check_req_set(int reqs_of_type[], int local_reqs_of_type[], case VUT_MINTECHS: /* At ranges 'Player' and 'World' */ if (rc > 2) { - log_error("%s: Requirement list has more %s requirements than " - "can ever be fulfilled.", list_for, - universal_type_rule_name(&preq->source)); + ruleset_error(LOG_ERROR, + "%s: Requirement list has more %s requirements than " + "can ever be fulfilled.", list_for, + universal_type_rule_name(&preq->source)); return FALSE; } break; @@ -477,7 +491,7 @@ static bool sanity_check_req_vec(const struct requirement_vector *preqs, problem = req_vec_get_first_contradiction(preqs, req_vec_vector_number, preqs); if (problem != NULL) { - log_error("%s: %s.", list_for, problem->description); + ruleset_error(LOG_ERROR, "%s: %s.", list_for, problem->description); req_vec_problem_free(problem); return FALSE; } -- 2.35.1