<URL: http://bugs.freeciv.org/Ticket/Display.html?id=39504 >
- 'xxx->index' seeks replaced by 'aaa_index(xxx)' - Changes made to gtk client in #38029 (revision 12881) copied almost verbatim Now it compiles. Asserts immediately when starting game. - ML
diff -Nurd -X.diff_ignore freeciv/client/gui-xaw/citydlg.c freeciv/client/gui-xaw/citydlg.c --- freeciv/client/gui-xaw/citydlg.c 2007-08-05 16:40:59.000000000 +0300 +++ freeciv/client/gui-xaw/citydlg.c 2007-08-07 18:56:27.000000000 +0300 @@ -1654,6 +1654,13 @@ struct unit_list *plist; int i, j, adj_base; Widget pixcomm; + int free_upkeep[O_COUNT]; + int free_unhappy = get_city_bonus(pdialog->pcity, EFT_MAKE_CONTENT_MIL); + + output_type_iterate(o) { + free_upkeep[o] = get_city_output_bonus(pdialog->pcity, get_output_type(o), + EFT_UNIT_UPKEEP_FREE_PER_CITY); + } output_type_iterate_end; if (game.player_ptr && (city_owner(pdialog->pcity) != game.player_ptr)) { plist = pdialog->pcity->info_units_supported; @@ -1671,6 +1678,10 @@ j = 0; /* index into list */ unit_list_iterate(plist, punit) { struct canvas store; + int upkeep_cost[O_COUNT]; + int happy_cost = city_unit_unhappiness(punit, &free_unhappy); + + city_unit_upkeep(punit, upkeep_cost, free_upkeep); if (j++ < pdialog->support_unit_base) { continue; @@ -1688,7 +1699,8 @@ XawPixcommClear(pixcomm); /* STG */ put_unit(punit, &store, 0, 0); put_unit_pixmap_city_overlays(punit, - XawPixcommPixmap(pixcomm)); + XawPixcommPixmap(pixcomm), + upkeep_cost, happy_cost); xaw_expose_now(pixcomm); diff -Nurd -X.diff_ignore freeciv/client/gui-xaw/dialogs.c freeciv/client/gui-xaw/dialogs.c --- freeciv/client/gui-xaw/dialogs.c 2007-08-06 18:09:20.000000000 +0300 +++ freeciv/client/gui-xaw/dialogs.c 2007-08-07 18:44:12.000000000 +0300 @@ -1223,7 +1223,7 @@ } for (i = 0; i < nation_count(); i++) { if (races_toggles_to_nations[i]) { - nation_idx_to_race_toggle[races_toggles_to_nations[i]->index] = i; + nation_idx_to_race_toggle[nation_index(races_toggles_to_nations[i])] = i; } } @@ -1272,6 +1272,7 @@ nations_iterate(nation) { int selected_nation = -1; + int this_index = nation_index(nation); if (!is_nation_playable(nation)) { continue; @@ -1283,7 +1284,7 @@ if (races_buttons_get_current() != -1) { selected_nation = - races_toggles_to_nations[races_buttons_get_current()]->index; + nation_index(races_toggles_to_nations[races_buttons_get_current()]); } freelog(LOG_DEBUG, " [%d]: %d = %s", @@ -1291,12 +1292,12 @@ nation_number(nation), nation_rule_name(nation)); - if (nation_index == selected_nation) { + if (this_index == selected_nation) { XawToggleUnsetCurrent(races_toggles[0]); - XtSetSensitive(races_toggles[nation_idx_to_race_toggle[nation_index]], FALSE); + XtSetSensitive(races_toggles[nation_idx_to_race_toggle[this_index]], FALSE); select_random_race(); } else { - XtSetSensitive(races_toggles[nation_idx_to_race_toggle[nation_index]], FALSE); + XtSetSensitive(races_toggles[nation_idx_to_race_toggle[this_index]], FALSE); } } nations_iterate_end; } @@ -1504,7 +1505,7 @@ dsend_packet_nation_select_req(&aconnection, player_number(races_player), - races_toggles_to_nations[selected_index]->index, + nation_index(races_toggles_to_nations[selected_index]), selected_sex ? FALSE : TRUE, dp, city_style_idx[selected_style]); popdown_races_dialog(); diff -Nurd -X.diff_ignore freeciv/client/gui-xaw/mapview.c freeciv/client/gui-xaw/mapview.c --- freeciv/client/gui-xaw/mapview.c 2007-08-04 18:38:47.000000000 +0300 +++ freeciv/client/gui-xaw/mapview.c 2007-08-07 18:50:09.000000000 +0300 @@ -738,7 +738,8 @@ the proper way to do this is probably something like what Civ II does. (One food/shield/mask drawn N times, possibly one top of itself. -- SKi **************************************************************************/ -void put_unit_pixmap_city_overlays(struct unit *punit, Pixmap pm) +void put_unit_pixmap_city_overlays(struct unit *punit, Pixmap pm, + int *upkeep_cost, int happy_cost) { struct canvas store = {pm}; @@ -750,7 +751,8 @@ tileset_tile_height(tileset) + tileset_small_sprite_height(tileset)); - put_unit_city_overlays(punit, &store, 0, tileset_tile_height(tileset)); + put_unit_city_overlays(punit, &store, 0, tileset_tile_height(tileset), + upkeep_cost, happy_cost); } /************************************************************************** diff -Nurd -X.diff_ignore freeciv/client/gui-xaw/mapview.h freeciv/client/gui-xaw/mapview.h --- freeciv/client/gui-xaw/mapview.h 2007-08-04 18:38:47.000000000 +0300 +++ freeciv/client/gui-xaw/mapview.h 2007-08-07 18:50:48.000000000 +0300 @@ -27,7 +27,8 @@ Pixmap get_citizen_pixmap(struct citizen_type type, int cnum, struct city *pcity); -void put_unit_pixmap_city_overlays(struct unit *punit, Pixmap pm); +void put_unit_pixmap_city_overlays(struct unit *punit, Pixmap pm, + int *upkeep_cost, int happy_cost); void overview_canvas_expose(Widget w, XEvent *event, Region exposed, void *client_data); diff -Nurd -X.diff_ignore freeciv/client/gui-xaw/menu.c freeciv/client/gui-xaw/menu.c --- freeciv/client/gui-xaw/menu.c 2007-08-04 18:38:47.000000000 +0300 +++ freeciv/client/gui-xaw/menu.c 2007-08-07 18:58:16.000000000 +0300 @@ -448,7 +448,7 @@ } unit_list_iterate_end; tinfo = ptile->terrain; - ttype = tinfo->index; + ttype = terrain_index(tinfo); can_build = !(ptile->city); if (units_have_flag(punits, F_CITIES, TRUE)) { @@ -462,7 +462,7 @@ } if ((tinfo->irrigation_result != T_NONE) - && (tinfo->irrigation_result->index != ttype)) { + && (terrain_index(tinfo->irrigation_result) != ttype)) { menu_entry_rename(MENU_ORDER, MENU_ORDER_IRRIGATE, TEXT_ORDER_IRRIGATE_CHANGE_TO, terrain_name_translation(tinfo->irrigation_result)); @@ -477,7 +477,7 @@ } if ((tinfo->mining_result != T_NONE) - && (tinfo->mining_result->index != ttype)) { + && (terrain_index(tinfo->mining_result) != ttype)) { menu_entry_rename(MENU_ORDER, MENU_ORDER_MINE, TEXT_ORDER_MINE_CHANGE_TO, terrain_name_translation(tinfo->mining_result)); @@ -487,7 +487,7 @@ } if ((tinfo->transform_result != T_NONE) - && (tinfo->transform_result->index != ttype)) { + && (terrain_index(tinfo->transform_result) != ttype)) { menu_entry_rename(MENU_ORDER, MENU_ORDER_TRANSFORM, TEXT_ORDER_TRANSFORM_TRANSFORM_TO, terrain_name_translation(tinfo->transform_result)); diff -Nurd -X.diff_ignore freeciv/client/gui-xaw/repodlgs.c freeciv/client/gui-xaw/repodlgs.c --- freeciv/client/gui-xaw/repodlgs.c 2007-08-04 18:38:47.000000000 +0300 +++ freeciv/client/gui-xaw/repodlgs.c 2007-08-07 19:06:13.000000000 +0300 @@ -1087,16 +1087,28 @@ free((void *) report_title); memset(unitarray, '\0', sizeof(unitarray)); - unit_list_iterate(game.player_ptr->units, punit) { - Unit_type_id uti = utype_index(unit_type(punit)); - (unitarray[uti].active_count)++; - if (punit->homecity) { - unitarray[uti].upkeep_shield += punit->upkeep[O_SHIELD]; - unitarray[uti].upkeep_food += punit->upkeep[O_FOOD]; - /* TODO: gold upkeep */ - } - } - unit_list_iterate_end; + + city_list_iterate(game.player_ptr->cities, pcity) { + int free_upkeep[O_COUNT]; + + output_type_iterate(o) { + free_upkeep[o] = get_city_output_bonus(pcity, get_output_type(o), + EFT_UNIT_UPKEEP_FREE_PER_CITY); + } output_type_iterate_end; + + unit_list_iterate(game.player_ptr->units, punit) { + int upkeep_cost[O_COUNT]; + Unit_type_id uti = utype_index(unit_type(punit)); + + city_unit_upkeep(punit, upkeep_cost, free_upkeep); + (unitarray[uti].active_count)++; + if (punit->homecity) { + /* TODO: upkeep for generic output types. */ + unitarray[uti].upkeep_shield += upkeep_cost[O_SHIELD]; + unitarray[uti].upkeep_food += upkeep_cost[O_FOOD]; + } + } unit_list_iterate_end; + } city_list_iterate_end; city_list_iterate(game.player_ptr->cities,pcity) { if (pcity->production.is_unit) { (unitarray[pcity->production.value].building_count)++;
_______________________________________________ Freeciv-dev mailing list Freeciv-dev@gna.org https://mail.gna.org/listinfo/freeciv-dev