? diff ? test.c Index: client/gui-gtk/citydlg.c =================================================================== RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk/citydlg.c,v retrieving revision 1.118 diff -u -r1.118 citydlg.c --- client/gui-gtk/citydlg.c 2002/02/12 09:36:45 1.118 +++ client/gui-gtk/citydlg.c 2002/02/18 16:12:44 @@ -3528,19 +3528,19 @@ static void set_cityopt_values(struct city_dialog *pdialog) { struct city *pcity = pdialog->pcity; - int i, state; + int i; pdialog->misc.block_signal = 1; for (i = 0; i < NUM_CITY_OPTS; i++) { - state = (pcity->city_options & (1 << i)); - gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(pdialog->misc.city_opts[i]), - state); + gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON + (pdialog->misc.city_opts[i]), + city_option_set(pcity, i)); } - if (pcity->city_options & (1 << CITYO_NEW_EINSTEIN)) { + if (city_option_set(pcity, CITYO_NEW_EINSTEIN)) { gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON (pdialog->misc.new_citizens_radio[1]), TRUE); - } else if (pcity->city_options & (1 << CITYO_NEW_TAXMAN)) { + } else if (city_option_set(pcity, CITYO_NEW_TAXMAN)) { gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON (pdialog->misc.new_citizens_radio[2]), TRUE); } else { Index: client/gui-mui/citydlg.c =================================================================== RCS file: /home/freeciv/CVS/freeciv/client/gui-mui/citydlg.c,v retrieving revision 1.41 diff -u -r1.41 citydlg.c --- client/gui-mui/citydlg.c 2002/02/12 08:59:56 1.41 +++ client/gui-mui/citydlg.c 2002/02/18 16:12:48 @@ -1825,18 +1825,18 @@ static void open_cityopt_dialog(struct city_dialog *pdialog) { struct city *pcity = pdialog->pcity; - int i, state, newcitizen_index; + int i, newcitizen_index; for (i = 0; i < NUM_CITYOPT_TOGGLES; i++) { - state = (pcity->city_options & (1 << i)); - set(pdialog->cityopt_checks[i], MUIA_Selected, state); + set(pdialog->cityopt_checks[i], MUIA_Selected, + city_option_set(pcity, i)); } - if (pcity->city_options & (1 << CITYO_NEW_EINSTEIN)) + if (city_option_set(pcity, CITYO_NEW_EINSTEIN)) { newcitizen_index = 1; } - else if (pcity->city_options & (1 << CITYO_NEW_TAXMAN)) + else if (city_option_set(pcity, CITYO_NEW_TAXMAN)) { newcitizen_index = 2; } Index: client/gui-win32/citydlg.c =================================================================== RCS file: /home/freeciv/CVS/freeciv/client/gui-win32/citydlg.c,v retrieving revision 1.11 diff -u -r1.11 citydlg.c --- client/gui-win32/citydlg.c 2002/02/12 09:36:49 1.11 +++ client/gui-win32/citydlg.c 2002/02/18 16:12:53 @@ -2195,7 +2195,7 @@ void cityopt_callback(struct city_dialog *pdialog) { - int i,state; + int i; int ncitizen_idx; struct city *pcity = pdialog->pcity; if (pdialog->cityopt_dialog) @@ -2209,13 +2209,12 @@ pdialog); for(i=0; icity_options & (1<cityopt_dialog,i+ID_CITYOPT_TOGGLE, - state?BST_CHECKED:BST_UNCHECKED); + CheckDlgButton(pdialog->cityopt_dialog, i + ID_CITYOPT_TOGGLE, + city_option_set(pcity, i) ? BST_CHECKED : BST_UNCHECKED); } - if (pcity->city_options & (1<city_options & (1<pcity; - int i, state; + int i; if(cityopt_shell) { XtDestroyWidget(cityopt_shell); @@ -2672,13 +2672,13 @@ cityopt_shell=create_cityopt_dialog(pcity->name); /* Doing this here makes the "No"'s centered consistently */ for(i=0; icity_options & (1<city_options & (1<city_options & (1<city_options & (1u << option)) != 0; +} Index: common/city.h =================================================================== RCS file: /home/freeciv/CVS/freeciv/common/city.h,v retrieving revision 1.98 diff -u -r1.98 city.h --- common/city.h 2002/02/14 15:17:09 1.98 +++ common/city.h 2002/02/18 16:12:58 @@ -438,4 +438,6 @@ int get_cathedral_power(struct city *pcity); int get_colosseum_power(struct city *pcity); +/* misc */ +bool city_option_set(struct city *pcity, enum city_options option); #endif /* FC__CITY_H */ Index: server/autoattack.c =================================================================== RCS file: /home/freeciv/CVS/freeciv/server/autoattack.c,v retrieving revision 1.34 diff -u -r1.34 autoattack.c --- server/autoattack.c 2002/02/11 10:38:07 1.34 +++ server/autoattack.c 2002/02/18 16:13:07 @@ -95,8 +95,8 @@ enemy = get_defender(punit, x, y); freelog(LOG_DEBUG, "defender is %s", unit_name(enemy->type)); - if (!(pcity->city_options - & 1 << (unit_type(enemy)->move_type - 1 + CITYO_ATT_LAND))) { + if (!city_option_set(pcity, + unit_type(enemy)->move_type - 1 + CITYO_ATT_LAND)) { freelog(LOG_DEBUG, "wrong target type"); continue; } @@ -211,7 +211,7 @@ city_list_iterate(pplayer->cities, pcity) { /* fasten things up -- fisch */ - if ((pcity->city_options & CITYOPT_AUTOATTACK_BITS) + if ((pcity->city_options & CITYOPT_AUTOATTACK_BITS) != 0 && !pcity->anarchy) { auto_attack_city(pplayer, pcity); } Index: server/cityturn.c =================================================================== RCS file: /home/freeciv/CVS/freeciv/server/cityturn.c,v retrieving revision 1.176 diff -u -r1.176 cityturn.c --- server/cityturn.c 2002/02/14 15:17:25 1.176 +++ server/cityturn.c 2002/02/18 16:13:09 @@ -534,9 +534,10 @@ } } city_map_iterate_end; if (((pcity->food_surplus >= 2) || !have_square) && pcity->size >= 5 && - (pcity->city_options & ((1<city_options & (1<ppl_scientist++; } else { /* now pcity->city_options & (1<ppl_taxman++; @@ -1015,8 +1016,7 @@ int pop_cost = unit_pop_value(pcity->currently_building); /* Should we disband the city? -- Massimo */ - if (pcity->size == pop_cost && - (pcity->city_options & (1 << CITYO_DISBAND))) { + if (pcity->size == pop_cost && city_option_set(pcity, CITYO_DISBAND)) { return !disband_city(pcity); }