[Freeciv-Dev] [PATCH] govenrment add G_FIRST_*
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Just generic code cleanup, and one assertion fix.
Enums are unsigned, so no use to check flags > 0, as they
clearly always are. But hey, thats what compiler optimizations
are for. :)
2000-01-05 Markus Linnala <maage@xxxxxxxxx>
* common/government.c (government_flag_from_str): use G_FIRST_FLAG
(government_has_flag): same
(government_hint_from_str): use G_FIRST_HINT
(government_has_hint): same, and fix assert
* common/government.h (G_FIRST_FLAG), (G_FIRST_HINT): set
symbolic values
--
//Markus
Index: government.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/government.c,v
retrieving revision 1.16
diff -u -u -r1.16 government.c
--- government.c 2000/01/02 11:18:28 1.16
+++ government.c 2000/01/05 21:54:51
@@ -80,7 +80,7 @@
assert(sizeof(flag_names)/sizeof(char*)==G_LAST_FLAG);
- for(i=0; i<G_LAST_FLAG; i++) {
+ for(i=G_FIRST_FLAG; i<G_LAST_FLAG; i++) {
if (mystrcasecmp(flag_names[i], s)==0) {
return i;
}
@@ -94,7 +94,7 @@
int government_has_flag(const struct government *gov,
enum government_flag_id flag)
{
- assert(flag>=0 && flag<G_LAST_FLAG);
+ assert(flag>=G_FIRST_FLAG && flag<G_LAST_FLAG);
return gov->flags & (1<<flag);
}
@@ -108,7 +108,7 @@
assert(sizeof(hint_names)/sizeof(char*)==G_LAST_HINT);
- for(i=0; i<G_LAST_HINT; i++) {
+ for(i=G_FIRST_HINT; i<G_LAST_HINT; i++) {
if (mystrcasecmp(hint_names[i], s)==0) {
return i;
}
@@ -122,7 +122,7 @@
int government_has_hint(const struct government *gov,
enum government_hint_id hint)
{
- assert(hint>=0 && hint<G_LAST_FLAG);
+ assert(hint>=G_FIRST_HINT && hint<G_LAST_HINT);
return gov->hints & (1<<hint);
}
Index: government.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/government.h,v
retrieving revision 1.14
diff -u -u -r1.14 government.h
--- government.h 1999/12/28 12:16:24 1.14
+++ government.h 2000/01/05 21:54:51
@@ -33,11 +33,14 @@
G_RAPTURE_CITY_GROWTH, /* allows city to grow by celebrating */
G_LAST_FLAG
};
+#define G_FIRST_FLAG G_BUILD_VETERAN_DIPLOMAT
+
enum government_hint_id {
G_IS_NICE=0, /* spaceship auto-placement, among others */
G_FAVORS_GROWTH,
G_LAST_HINT
};
+#define G_FIRST_HINT G_IS_NICE
/* each government has a list of ruler titles, where at least
* one entry should have nation=DEFAULT_TITLE.
- [Freeciv-Dev] [PATCH] govenrment add G_FIRST_*,
Markus Linnala <=
|
|