From cb0b6fdfe3c441c0de8e9036ddd9545622e5596e Mon Sep 17 00:00:00 2001
From: Marko Lindqvist <cazfi74@gmail.com>
Date: Wed, 10 Nov 2021 03:51:49 +0200
Subject: [PATCH 20/20] Introduce advance_iterate_all() macro

Use it where applicable

See osdn #42893

Signed-off-by: Marko Lindqvist <cazfi74@gmail.com>
---
 client/gui-gtk-3.22/helpdlg.c | 4 ++--
 client/gui-gtk-4.0/helpdlg.c  | 4 ++--
 common/tech.c                 | 8 ++++----
 common/tech.h                 | 3 +++
 server/ruleset.c              | 4 ++--
 tools/ruledit/tab_tech.cpp    | 4 ++--
 6 files changed, 15 insertions(+), 12 deletions(-)

diff --git a/client/gui-gtk-3.22/helpdlg.c b/client/gui-gtk-3.22/helpdlg.c
index 52fb6b6703..ccd8df35b6 100644
--- a/client/gui-gtk-3.22/helpdlg.c
+++ b/client/gui-gtk-3.22/helpdlg.c
@@ -1085,7 +1085,7 @@ static void help_update_tech(const struct help_item *pitem, char *title)
       gtk_widget_show_all(hbox);
     } unit_type_iterate_end;
 
-    advance_iterate(A_NONE, ptest) {
+    advance_iterate_all(ptest) {
       if (padvance == advance_requires(ptest, AR_ONE)) {
 	if (advance_by_number(A_NONE) == advance_requires(ptest, AR_TWO)) {
           hbox = gtk_grid_new();
@@ -1128,7 +1128,7 @@ static void help_update_tech(const struct help_item *pitem, char *title)
         gtk_container_add(GTK_CONTAINER(hbox), w);
         gtk_widget_show_all(hbox);
       }
-    } advance_iterate_end;
+    } advance_iterate_all_end;
     gtk_widget_show(help_vbox);
   }
 }
diff --git a/client/gui-gtk-4.0/helpdlg.c b/client/gui-gtk-4.0/helpdlg.c
index 65e8c32803..bfc4661d78 100644
--- a/client/gui-gtk-4.0/helpdlg.c
+++ b/client/gui-gtk-4.0/helpdlg.c
@@ -1092,7 +1092,7 @@ static void help_update_tech(const struct help_item *pitem, char *title)
       gtk_widget_show(hbox);
     } unit_type_iterate_end;
 
-    advance_iterate(A_NONE, ptest) {
+    advance_iterate_all(ptest) {
       if (padvance == advance_requires(ptest, AR_ONE)) {
 	if (advance_by_number(A_NONE) == advance_requires(ptest, AR_TWO)) {
           hbox = gtk_grid_new();
@@ -1135,7 +1135,7 @@ static void help_update_tech(const struct help_item *pitem, char *title)
         gtk_container_add(GTK_CONTAINER(hbox), w);
         gtk_widget_show(hbox);
       }
-    } advance_iterate_end;
+    } advance_iterate_all_end;
     gtk_widget_show(help_vbox);
   }
 }
diff --git a/common/tech.c b/common/tech.c
index 687786c664..718176d114 100644
--- a/common/tech.c
+++ b/common/tech.c
@@ -177,11 +177,11 @@ struct advance *valid_advance_by_number(const Tech_type_id id)
 **************************************************************************/
 struct advance *advance_by_translated_name(const char *name)
 {
-  advance_iterate(A_NONE, padvance) {
+  advance_iterate_all(padvance) {
     if (0 == strcmp(advance_name_translation(padvance), name)) {
       return padvance;
     }
-  } advance_iterate_end;
+  } advance_iterate_all_end;
 
   return NULL;
 }
@@ -194,11 +194,11 @@ struct advance *advance_by_rule_name(const char *name)
 {
   const char *qname = Qn_(name);
 
-  advance_iterate(A_NONE, padvance) {
+  advance_iterate_all(padvance) {
     if (0 == fc_strcasecmp(advance_rule_name(padvance), qname)) {
       return padvance;
     }
-  } advance_iterate_end;
+  } advance_iterate_all_end;
 
   return NULL;
 }
diff --git a/common/tech.h b/common/tech.h
index 6d424e33c9..7b6850d8f0 100644
--- a/common/tech.h
+++ b/common/tech.h
@@ -249,6 +249,9 @@ const struct advance *advance_array_last(void);
   }									\
 }
 
+#define advance_iterate_all(_p) advance_iterate(A_NONE, _p)
+#define advance_iterate_all_end advance_iterate_end
+
 #define advance_re_active_iterate(_p)                                    \
   advance_iterate(A_FIRST, _p) {                                         \
     if (_p->require[AR_ONE] != A_NEVER) {
diff --git a/server/ruleset.c b/server/ruleset.c
index 3b84dc4f5a..d583dcf0a3 100644
--- a/server/ruleset.c
+++ b/server/ruleset.c
@@ -1687,11 +1687,11 @@ restart:
     } advance_iterate_end;
 
     /* Now rename A_NEVER to A_NONE for consistency */
-    advance_iterate(A_NONE, a) {
+    advance_iterate_all(a) {
       if (A_NEVER == a->require[AR_ROOT]) {
         a->require[AR_ROOT] = a_none;
       }
-    } advance_iterate_end;
+    } advance_iterate_all_end;
 
     /* Some more consistency checking: 
        Non-removed techs depending on removed techs is too
diff --git a/tools/ruledit/tab_tech.cpp b/tools/ruledit/tab_tech.cpp
index 07c71153f6..f4ad2d8215 100644
--- a/tools/ruledit/tab_tech.cpp
+++ b/tools/ruledit/tab_tech.cpp
@@ -186,9 +186,9 @@ void tab_tech::techs_to_menu(QMenu *fill_menu)
 {
   fill_menu->clear();
 
-  advance_iterate(A_NONE, padv) {
+  advance_iterate_all(padv) {
     fill_menu->addAction(tech_name(padv));
-  } advance_iterate_end;
+  } advance_iterate_all_end;
 }
 
 /**********************************************************************//**
-- 
2.33.0