[Freeciv-Dev] (PR#12967) put unhappy penalty config into output type str
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
<URL: http://bugs.freeciv.org/Ticket/Display.html?id=12967 >
This patch puts the configuration for unhappiness penalties (a
three-value variable) into the output type structure. At some point in
the distant future this could make these properties more configurable.
-jason
Index: common/city.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/city.c,v
retrieving revision 1.338
diff -u -r1.338 city.c
--- common/city.c 3 May 2005 07:11:58 -0000 1.338
+++ common/city.c 3 May 2005 07:38:07 -0000
@@ -46,12 +46,12 @@
* they're just an easy way to access information about each output type. */
const Output_type_id num_output_types = O_LAST;
struct output_type output_types[O_LAST] = {
- {O_FOOD, N_("Food"), "food"},
- {O_SHIELD, N_("Shield"), "shield"},
- {O_TRADE, N_("Trade"), "trade"},
- {O_GOLD, N_("Gold"), "gold"},
- {O_LUXURY, N_("Luxury"), "luxury"},
- {O_SCIENCE, N_("Science"), "science"}
+ {O_FOOD, N_("Food"), "food", UNHAPPY_PENALTY_SURPLUS},
+ {O_SHIELD, N_("Shield"), "shield", UNHAPPY_PENALTY_SURPLUS},
+ {O_TRADE, N_("Trade"), "trade", UNHAPPY_PENALTY_NONE},
+ {O_GOLD, N_("Gold"), "gold", UNHAPPY_PENALTY_ALL_PRODUCTION},
+ {O_LUXURY, N_("Luxury"), "luxury", UNHAPPY_PENALTY_NONE},
+ {O_SCIENCE, N_("Science"), "science", UNHAPPY_PENALTY_ALL_PRODUCTION}
};
/**************************************************************************
@@ -1972,15 +1972,19 @@
static inline void unhappy_city_check(struct city *pcity)
{
if (city_unhappy(pcity)) {
- pcity->unhappy_penalty[O_FOOD]
- = MAX(pcity->prod[O_FOOD] - pcity->usage[O_FOOD], 0);
- pcity->unhappy_penalty[O_SHIELD]
- = MAX(pcity->prod[O_SHIELD] - pcity->usage[O_SHIELD], 0);
- pcity->unhappy_penalty[O_GOLD] = pcity->prod[O_GOLD];
- pcity->unhappy_penalty[O_SCIENCE] = pcity->prod[O_SCIENCE];
- /* Trade and luxury are unaffected. */
-
output_type_iterate(o) {
+ switch (output_types[o].unhappy_penalty) {
+ case UNHAPPY_PENALTY_NONE:
+ pcity->unhappy_penalty[o] = 0;
+ break;
+ case UNHAPPY_PENALTY_SURPLUS:
+ pcity->unhappy_penalty[o] = MAX(pcity->prod[o] - pcity->usage[o], 0);
+ break;
+ case UNHAPPY_PENALTY_ALL_PRODUCTION:
+ pcity->unhappy_penalty[o] = pcity->prod[o];
+ break;
+ }
+
pcity->prod[o] -= pcity->unhappy_penalty[o];
} output_type_iterate_end;
} else {
Index: common/city.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/city.h,v
retrieving revision 1.209
diff -u -r1.209 city.h
--- common/city.h 30 Apr 2005 17:09:27 -0000 1.209
+++ common/city.h 3 May 2005 07:38:07 -0000
@@ -135,11 +135,19 @@
} city_map_checked_iterate_end; \
}
+/* How much this output type is penalized for unhappy cities: not at all,
+ * surplus knocked down to 0, or all production removed. */
+enum output_unhappy_penalty {
+ UNHAPPY_PENALTY_NONE,
+ UNHAPPY_PENALTY_SURPLUS,
+ UNHAPPY_PENALTY_ALL_PRODUCTION
+};
struct output_type {
int index;
const char *name; /* Untranslated name */
const char *id; /* Identifier string (for rulesets, etc.) */
+ enum output_unhappy_penalty unhappy_penalty;
};
enum choice_type { CT_NONE = 0, CT_BUILDING = 0, CT_NONMIL, CT_ATTACKER,
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Freeciv-Dev] (PR#12967) put unhappy penalty config into output type structure,
Jason Short <=
|
|