[Freeciv-Dev] (PR#2992) NUM_CREPORT_COLS is hard-coded
[Top] [All Lists]
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
 
In client/cityrepdata.h there is a #define NUM_CREPORT_COLS that 
hard-codes the number of available columns in the city report.  This 
means that any time a column is added this number must be updated.  This 
is not good; unfortunately it is difficult to fix [1].  The attached 
patch just adds an extra level of safety by adding an assert to 
cityrepdata.c to verify that the number is correct.
[1] See num_report_cols in cityrepdata.c, but this value cannot be used 
in place of NUM_CREPORT_COLS without significant GUI changes.
jason
 Index: client/cityrepdata.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/cityrepdata.c,v
retrieving revision 1.29
diff -u -r1.29 cityrepdata.c
--- client/cityrepdata.c        2003/02/04 21:05:47     1.29
+++ client/cityrepdata.c        2003/02/04 23:02:26
@@ -15,6 +15,7 @@
 #include <config.h>
 #endif
 
+#include <assert.h>
 #include <stdio.h>
 #include <string.h>
 
@@ -533,6 +534,8 @@
     }
     p->explanation = _(p->explanation);
   }
+
+  assert(NUM_CREPORT_COLS == ARRAY_SIZE(city_report_specs));
 }
 
 /**********************************************************************
 
| [Prev in Thread] | 
Current Thread | 
[Next in Thread] |   
- [Freeciv-Dev] (PR#2992) NUM_CREPORT_COLS is hard-coded,
Jason Short via RT <=
  
 
 | 
 |