From 0c6eaffb5c1c7259727c894fb2d11e28873f2897 Mon Sep 17 00:00:00 2001 From: Alina Lenk Date: Sat, 4 May 2024 11:35:07 +0200 Subject: [PATCH 6/6] Remove MAX_NUM_REQS. See RM #541 Signed-off-by: Alina Lenk --- client/gui-gtk-3.22/helpdlg.c | 12 ++++-------- client/gui-gtk-4.0/helpdlg.c | 12 ++++-------- client/gui-gtk-5.0/helpdlg.c | 12 ++++-------- client/gui-sdl2/helpdlg.c | 11 ++++------- client/gui-sdl3/helpdlg.c | 11 ++++------- common/fc_types.h | 4 +--- doc/README.effects | 4 +++- server/ruleset/ruleload.c | 8 -------- 8 files changed, 24 insertions(+), 50 deletions(-) diff --git a/client/gui-gtk-3.22/helpdlg.c b/client/gui-gtk-3.22/helpdlg.c index 84625e1b72..e94a48bee3 100644 --- a/client/gui-gtk-3.22/helpdlg.c +++ b/client/gui-gtk-3.22/helpdlg.c @@ -888,11 +888,9 @@ static void help_update_improvement(const struct help_item *pitem, sprintf(buf, "%d", imp->upkeep); gtk_label_set_text(GTK_LABEL(help_ilabel[3]), buf); - /* FIXME: this should show ranges, negated reqs, and all the - * MAX_NUM_REQS reqs. + /* FIXME: this should show ranges, negated reqs, and all the reqs. * Currently it's limited to 1 req but this code is partially prepared - * to be extended. Remember MAX_NUM_REQS is a compile-time - * definition. */ + * to be extended. */ help_impr_req.u.req = NULL; requirement_vector_iterate(&imp->reqs, preq) { if (!preq->present) { @@ -936,11 +934,9 @@ static void help_update_wonder(const struct help_item *pitem, sprintf(buf, "%d", impr_base_build_shield_cost(imp)); gtk_label_set_text(GTK_LABEL(help_wlabel[1]), buf); - /* FIXME: this should show ranges, negated reqs, and all the - * MAX_NUM_REQS reqs. + /* FIXME: this should show ranges, negated reqs, and all the reqs. * Currently it's limited to 1 req but this code is partially prepared - * to be extended. Remember MAX_NUM_REQS is a compile-time - * definition. */ + * to be extended. */ i = 0; help_wndr_req.u.req = NULL; requirement_vector_iterate(&imp->reqs, preq) { diff --git a/client/gui-gtk-4.0/helpdlg.c b/client/gui-gtk-4.0/helpdlg.c index 36260815e1..682516d092 100644 --- a/client/gui-gtk-4.0/helpdlg.c +++ b/client/gui-gtk-4.0/helpdlg.c @@ -916,11 +916,9 @@ static void help_update_improvement(const struct help_item *pitem, sprintf(buf, "%d", imp->upkeep); gtk_label_set_text(GTK_LABEL(help_ilabel[3]), buf); - /* FIXME: this should show ranges, negated reqs, and all the - * MAX_NUM_REQS reqs. + /* FIXME: this should show ranges, negated reqs, and all the reqs. * Currently it's limited to 1 req but this code is partially prepared - * to be extended. Remember MAX_NUM_REQS is a compile-time - * definition. */ + * to be extended. */ help_impr_req.u.req = NULL; requirement_vector_iterate(&imp->reqs, preq) { if (!preq->present) { @@ -964,11 +962,9 @@ static void help_update_wonder(const struct help_item *pitem, sprintf(buf, "%d", impr_base_build_shield_cost(imp)); gtk_label_set_text(GTK_LABEL(help_wlabel[1]), buf); - /* FIXME: this should show ranges, negated reqs, and all the - * MAX_NUM_REQS reqs. + /* FIXME: this should show ranges, negated reqs, and all the reqs. * Currently it's limited to 1 req but this code is partially prepared - * to be extended. Remember MAX_NUM_REQS is a compile-time - * definition. */ + * to be extended. */ i = 0; help_wndr_req.u.req = NULL; requirement_vector_iterate(&imp->reqs, preq) { diff --git a/client/gui-gtk-5.0/helpdlg.c b/client/gui-gtk-5.0/helpdlg.c index 8278fe924e..6f754c6cad 100644 --- a/client/gui-gtk-5.0/helpdlg.c +++ b/client/gui-gtk-5.0/helpdlg.c @@ -916,11 +916,9 @@ static void help_update_improvement(const struct help_item *pitem, sprintf(buf, "%d", imp->upkeep); gtk_label_set_text(GTK_LABEL(help_ilabel[3]), buf); - /* FIXME: this should show ranges, negated reqs, and all the - * MAX_NUM_REQS reqs. + /* FIXME: this should show ranges, negated reqs, and all the reqs. * Currently it's limited to 1 req but this code is partially prepared - * to be extended. Remember MAX_NUM_REQS is a compile-time - * definition. */ + * to be extended. */ help_impr_req.u.req = NULL; requirement_vector_iterate(&imp->reqs, preq) { if (!preq->present) { @@ -964,11 +962,9 @@ static void help_update_wonder(const struct help_item *pitem, sprintf(buf, "%d", impr_base_build_shield_cost(imp)); gtk_label_set_text(GTK_LABEL(help_wlabel[1]), buf); - /* FIXME: this should show ranges, negated reqs, and all the - * MAX_NUM_REQS reqs. + /* FIXME: this should show ranges, negated reqs, and all the reqs. * Currently it's limited to 1 req but this code is partially prepared - * to be extended. Remember MAX_NUM_REQS is a compile-time - * definition. */ + * to be extended. */ i = 0; help_wndr_req.u.req = NULL; requirement_vector_iterate(&imp->reqs, preq) { diff --git a/client/gui-sdl2/helpdlg.c b/client/gui-sdl2/helpdlg.c index 1f7d0c00ef..7635e1fc8f 100644 --- a/client/gui-sdl2/helpdlg.c +++ b/client/gui-sdl2/helpdlg.c @@ -412,10 +412,8 @@ void popup_impr_info(Impr_type_id impr) widget_add_as_prev(requirement_label, dock); dock = requirement_label; - /* FIXME: this should show ranges, negated reqs, and all the - * MAX_NUM_REQS reqs. - * Currently it's limited to 1 req. Remember MAX_NUM_REQS is a compile-time - * definition. */ + /* FIXME: this should show ranges, negated reqs, and all the reqs. + * Currently it's limited to 1 req. */ requirement_vector_iterate(&pimpr_type->reqs, preq) { if (!preq->present) { continue; @@ -1253,9 +1251,8 @@ static struct widget *create_tech_info(Tech_type_id tech, int width, imp_count = 0; improvement_iterate(pimprove) { if (valid_improvement(pimprove)) { - /* FIXME: this should show ranges and all the MAX_NUM_REQS reqs. - * Currently it's limited to 1 req. Remember MAX_NUM_REQS is a compile-time - * definition. */ + /* FIXME: this should show ranges and all the reqs. + * Currently it's limited to 1 req. */ requirement_vector_iterate(&(pimprove->reqs), preq) { if (VUT_ADVANCE == preq->source.kind && advance_number(preq->source.value.advance) == tech) { diff --git a/client/gui-sdl3/helpdlg.c b/client/gui-sdl3/helpdlg.c index 20ac10599b..5509648b55 100644 --- a/client/gui-sdl3/helpdlg.c +++ b/client/gui-sdl3/helpdlg.c @@ -409,10 +409,8 @@ void popup_impr_info(Impr_type_id impr) widget_add_as_prev(requirement_label, dock); dock = requirement_label; - /* FIXME: this should show ranges, negated reqs, and all the - * MAX_NUM_REQS reqs. - * Currently it's limited to 1 req. Remember MAX_NUM_REQS is a compile-time - * definition. */ + /* FIXME: this should show ranges, negated reqs, and all the reqs. + * Currently it's limited to 1 req. */ requirement_vector_iterate(&pimpr_type->reqs, preq) { if (!preq->present) { continue; @@ -1251,9 +1249,8 @@ static struct widget *create_tech_info(Tech_type_id tech, int width, imp_count = 0; improvement_iterate(pimprove) { if (valid_improvement(pimprove)) { - /* FIXME: this should show ranges and all the MAX_NUM_REQS reqs. - * Currently it's limited to 1 req. Remember MAX_NUM_REQS is a compile-time - * definition. */ + /* FIXME: this should show ranges and all the reqs. + * Currently it's limited to 1 req. */ requirement_vector_iterate(&(pimprove->reqs), preq) { if (VUT_ADVANCE == preq->source.kind && advance_number(preq->source.value.advance) == tech) { diff --git a/common/fc_types.h b/common/fc_types.h index bc57a5d599..55ab057015 100644 --- a/common/fc_types.h +++ b/common/fc_types.h @@ -410,10 +410,8 @@ struct achievement; struct action; -/* Changing these will break network compatibility. - * If changing MAX_NUM_REQS, also update user documentation in README.effects. */ +/* Changing these will break network compatibility. */ #define SP_MAX 20 -#define MAX_NUM_REQS 40 #define MAX_NUM_RULESETS 63 /* Used in the network protocol. */ #define MAX_RULESET_NAME_LENGTH 64 /* Used in the network protocol. */ diff --git a/doc/README.effects b/doc/README.effects index 5e29fc1352..1f3cff7d76 100644 --- a/doc/README.effects +++ b/doc/README.effects @@ -49,7 +49,9 @@ can be used if the help system's text is unclear or misleading, or if you want to describe the requirement in your own words. The 'quiet' field has no effect on the game rules. -Single requirement vector can have up to 40 requirements. +A requirement vector may have any number of requirements (in theory; +in practice whatever it's part of won't fit in a network packet anymore +beyond a few hundred requirements). Requirement types and supported ranges diff --git a/server/ruleset/ruleload.c b/server/ruleset/ruleload.c index b45acf9914..6c7523cc25 100644 --- a/server/ruleset/ruleload.c +++ b/server/ruleset/ruleload.c @@ -773,14 +773,6 @@ struct requirement_vector *lookup_req_list(struct section_file *file, requirement_vector_append(&reqs_list, req); } - if (j > MAX_NUM_REQS) { - ruleset_error(NULL, LOG_ERROR, - "Too many (%d) requirements for %s. Max is %d", - j, rfor, MAX_NUM_REQS); - - return NULL; - } - return &reqs_list; } -- 2.34.1