? stats ? diff ? out ? impr_iter1.diff ? b.gz ? auto.rc ? max_comb1.diff ? id_to_info_row.diff Index: client/packhand.c =================================================================== RCS file: /home/freeciv/CVS/freeciv/client/packhand.c,v retrieving revision 1.223 diff -u -r1.223 packhand.c --- client/packhand.c 2002/02/27 11:46:15 1.223 +++ client/packhand.c 2002/03/04 08:13:55 @@ -424,6 +424,7 @@ pcity->turn_last_built=packet->turn_last_built; pcity->turn_changed_target=packet->turn_changed_target; + pcity->turn_founded = packet->turn_founded; pcity->changed_from_id=packet->changed_from_id; pcity->changed_from_is_unit=packet->changed_from_is_unit; pcity->before_change_shields=packet->before_change_shields; @@ -659,7 +660,7 @@ pcity->currently_building = 0; init_worklist(&pcity->worklist); pcity->airlift = FALSE; - pcity->did_buy = 0; + pcity->did_buy = FALSE; pcity->did_sell = FALSE; pcity->was_happy = FALSE; Index: client/gui-gtk/citydlg.c =================================================================== RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk/citydlg.c,v retrieving revision 1.127 diff -u -r1.127 citydlg.c --- client/gui-gtk/citydlg.c 2002/03/01 10:22:55 1.127 +++ client/gui-gtk/citydlg.c 2002/03/04 08:13:58 @@ -3619,14 +3619,37 @@ } /************************************************************************ + Helper for switch_city_callback. +*************************************************************************/ +static int city_comp_by_name(const void *a, const void *b) +{ + struct city *pcity1 = *((struct city **) a); + struct city *pcity2 = *((struct city **) b); + + return strcmp(pcity1->name, pcity2->name); +} + +/************************************************************************ + Helper for switch_city_callback. +*************************************************************************/ +static int city_comp_by_turn_founded(const void *a, const void *b) +{ + struct city *pcity1 = *((struct city **) a); + struct city *pcity2 = *((struct city **) b); + + return pcity1->turn_founded - pcity2->turn_founded; +} + +/************************************************************************ Callback for the prev/next buttons. Switches to the previous/next city. *************************************************************************/ static void switch_city_callback(GtkWidget *w, gpointer data) { struct city_dialog *pdialog = (struct city_dialog *) data; - int i, j, dir, size = city_list_size(&game.player_ptr->cities); + int i, dir, non_open_size, size = city_list_size(&game.player_ptr->cities); struct city *new_pcity = NULL; + struct city **array; assert(city_dialogs_have_been_initialised); assert(size >= 1); @@ -3646,30 +3669,37 @@ dir = 1; } + array = fc_malloc(size * sizeof(struct city *)); + + non_open_size = 0; for (i = 0; i < size; i++) { - if (pdialog->pcity == city_list_get(&game.player_ptr->cities, i)) { - break; + struct city *other_pcity = city_list_get(&game.player_ptr->cities, i); + if (other_pcity == pdialog->pcity || !get_city_dialog(other_pcity)) { + array[non_open_size] = other_pcity; + non_open_size++; } } + + assert(non_open_size > 0); + + if (non_open_size == 1) { + free(array); + return; + } - assert(i < size); + qsort(array, non_open_size, sizeof(struct city *), + city_comp_by_turn_founded); - for (j = 1; j < size; j++) { - struct city *other_pcity = city_list_get(&game.player_ptr->cities, - (i + dir * j + size) % size); - struct city_dialog *other_pdialog = get_city_dialog(other_pcity); - - assert(other_pdialog != pdialog); - if (!other_pdialog) { - new_pcity = other_pcity; + for (i = 0; i < non_open_size; i++) { + if (pdialog->pcity == array[i]) { break; } } - if (!new_pcity) { - /* Every other city has an open city dialog. */ - return; - } + assert(i < non_open_size); + + new_pcity = array[(i + dir + non_open_size) % non_open_size]; + free(array); /* cleanup worklist and happiness dialogs */ if(pdialog->wl_editor->changed){ Index: common/capstr.c =================================================================== RCS file: /home/freeciv/CVS/freeciv/common/capstr.c,v retrieving revision 1.95 diff -u -r1.95 capstr.c --- common/capstr.c 2002/02/16 17:44:43 1.95 +++ common/capstr.c 2002/03/04 08:13:58 @@ -72,7 +72,8 @@ #define CAPABILITY "+1.11.6 conn_info pop_cost turn attributes new_bonus_tech"\ " fund_added processing_packets angrycitizen tile_trade init_techs"\ -" short_worklists tech_cost_style short_city_tile_trade trade_size" +" short_worklists tech_cost_style short_city_tile_trade trade_size"\ +" turn_founded" /* "+1.11.6" is protocol for 1.11.6 beta release. @@ -116,6 +117,8 @@ "trade_size" transfer game.notradesize and game.fulltradesize to the client. + + "turn_founded" transfers turn_founded of struct city to the client. */ void init_our_capability(void) Index: common/city.h =================================================================== RCS file: /home/freeciv/CVS/freeciv/common/city.h,v retrieving revision 1.103 diff -u -r1.103 city.h --- common/city.h 2002/02/27 11:46:19 1.103 +++ common/city.h 2002/03/04 08:13:59 @@ -264,7 +264,7 @@ struct unit_list units_supported; int steal; /* diplomats steal once; for spies, gets harder */ /* turn states */ - int did_buy; + bool did_buy; bool did_sell, is_updated; int turn_last_built; /* The last year in which something was built */ int turn_changed_target; /* Suffer shield loss at most once per turn */ @@ -282,6 +282,8 @@ /* server variable. indicates if the city map is synced with the client. */ bool synced; + + int turn_founded; /* In which turn was the city founded? */ /* info for dipl/spy investigation -- used only in client */ struct unit_list info_units_supported; Index: common/packets.c =================================================================== RCS file: /home/freeciv/CVS/freeciv/common/packets.c,v retrieving revision 1.193 diff -u -r1.193 packets.c --- common/packets.c 2002/03/02 19:57:22 1.193 +++ common/packets.c 2002/03/04 08:14:02 @@ -2401,6 +2401,10 @@ /* only 8 options allowed before need to extend protocol */ cptr=put_uint8(cptr, req->city_options); + + if (has_capability("turn_founded", pc->capability)) { + cptr = put_uint32(cptr, req->turn_founded); + } for (data = 0; data < NUM_TRADEROUTES; data++) { if(req->trade[data] != 0) { @@ -2494,6 +2498,12 @@ sizeof(packet->improvements)); iget_uint8(&iter, &packet->city_options); + + if (has_capability("turn_founded", pc->capability)) { + iget_uint32(&iter, &packet->turn_founded); + } else { + packet->turn_founded = -1; + } for (data = 0; data < NUM_TRADEROUTES; data++) { if (pack_iter_remaining(&iter) < 3) Index: common/packets.h =================================================================== RCS file: /home/freeciv/CVS/freeciv/common/packets.h,v retrieving revision 1.108 diff -u -r1.108 packets.h --- common/packets.h 2002/02/26 17:24:26 1.108 +++ common/packets.h 2002/03/04 08:14:02 @@ -367,6 +367,7 @@ bool airlift; bool diplomat_investigate; int city_options; + int turn_founded; }; Index: server/cityhand.c =================================================================== RCS file: /home/freeciv/CVS/freeciv/server/cityhand.c,v retrieving revision 1.112 diff -u -r1.112 cityhand.c --- server/cityhand.c 2002/02/27 11:46:20 1.112 +++ server/cityhand.c 2002/03/04 08:14:03 @@ -231,15 +231,15 @@ int cost, total; if (!pcity || !player_owns_city(pplayer, pcity)) return; - if (pcity->did_buy > 0) { + if (pcity->turn_founded == game.turn) { notify_player_ex(pplayer, pcity->x, pcity->y, E_NOEVENT, - _("Game: You have already bought this turn.")); + _("Game: Cannot buy in city created this turn.")); return; } - if (pcity->did_buy < 0) { + if (pcity->did_buy) { notify_player_ex(pplayer, pcity->x, pcity->y, E_NOEVENT, - _("Game: Cannot buy in city created this turn.")); + _("Game: You have already bought this turn.")); return; } @@ -282,7 +282,7 @@ * fully well add the missing shields there. */ pcity->disbanded_shields += total - pcity->shield_stock; pcity->shield_stock=total; /* AI wants this -- Syela */ - pcity->did_buy=1; /* !PS: no need to set buy flag otherwise */ + pcity->did_buy = TRUE; /* !PS: no need to set buy flag otherwise */ } city_refresh(pcity); @@ -368,7 +368,7 @@ return; if (!preq->is_build_id_unit_id && !can_build_improvement(pcity, preq->build_id)) return; - if (pcity->did_buy && pcity->shield_stock) { /* did_buy > 0 should be same -- Syela */ + if (pcity->did_buy && pcity->shield_stock) { notify_player_ex(pplayer, pcity->x, pcity->y, E_NOEVENT, _("Game: You have bought this turn, can't change.")); return; Index: server/citytools.c =================================================================== RCS file: /home/freeciv/CVS/freeciv/server/citytools.c,v retrieving revision 1.172 diff -u -r1.172 citytools.c --- server/citytools.c 2002/03/03 09:51:56 1.172 +++ server/citytools.c 2002/03/04 08:14:04 @@ -525,8 +525,8 @@ if (city_got_building(pcity, B_AQUEDUCT) && pcity->size < game.sewer_size) return TRUE; if (!pcity->is_building_unit) { - if (pcity->currently_building == B_SEWER && pcity->did_buy == 1) return TRUE; - if (pcity->currently_building == B_AQUEDUCT && pcity->did_buy == 1) return TRUE; + if (pcity->currently_building == B_SEWER && pcity->did_buy) return TRUE; + if (pcity->currently_building == B_AQUEDUCT && pcity->did_buy) return TRUE; } /* saves a lot of stupid flipflops -- Syela */ return FALSE; } @@ -952,7 +952,8 @@ pcity->trade_prod=0; pcity->original = pplayer->player_no; pcity->is_building_unit = TRUE; - pcity->did_buy=-1; /* code so we get a different message */ + pcity->turn_founded = game.turn; + pcity->did_buy = TRUE; pcity->did_sell = FALSE; pcity->airlift = FALSE; pcity->currently_building=best_role_unit(pcity, L_FIRSTBUILD); @@ -1577,6 +1578,7 @@ packet->turn_last_built=pcity->turn_last_built; packet->turn_changed_target=pcity->turn_changed_target; + packet->turn_founded = pcity->turn_founded; packet->changed_from_id=pcity->changed_from_id; packet->changed_from_is_unit=pcity->changed_from_is_unit; packet->before_change_shields=pcity->before_change_shields; Index: server/cityturn.c =================================================================== RCS file: /home/freeciv/CVS/freeciv/server/cityturn.c,v retrieving revision 1.179 diff -u -r1.179 cityturn.c --- server/cityturn.c 2002/02/27 11:46:21 1.179 +++ server/cityturn.c 2002/03/04 08:14:05 @@ -1283,7 +1283,7 @@ pcity->is_updated=TRUE; pcity->did_sell=FALSE; - pcity->did_buy=0; + pcity->did_buy = FALSE; if (city_got_building(pcity, B_AIRPORT)) pcity->airlift=TRUE; else Index: server/savegame.c =================================================================== RCS file: /home/freeciv/CVS/freeciv/server/savegame.c,v retrieving revision 1.66 diff -u -r1.66 savegame.c --- server/savegame.c 2002/02/27 11:46:21 1.66 +++ server/savegame.c 2002/03/04 08:14:07 @@ -806,8 +806,16 @@ secfile_lookup_int_default(file, 0, "player%d.c%d.caravan_shields", plrno, i); - pcity->did_buy=secfile_lookup_int(file, - "player%d.c%d.did_buy", plrno,i); + pcity->turn_founded = + secfile_lookup_int_default(file, -2, "player%d.c%d.turn_founded", + plrno, i); + + j = secfile_lookup_int(file, "player%d.c%d.did_buy", plrno, i); + pcity->did_buy = (i != 0); + if (j == -1 && pcity->turn_founded == -2) { + pcity->turn_founded = game.turn; + } + pcity->did_sell = secfile_lookup_bool_default(file, FALSE, "player%d.c%d.did_sell", plrno,i); @@ -1464,7 +1472,15 @@ secfile_insert_int(file, pcity->anarchy, "player%d.c%d.anarchy", plrno,i); secfile_insert_int(file, pcity->rapture, "player%d.c%d.rapture", plrno,i); secfile_insert_bool(file, pcity->was_happy, "player%d.c%d.was_happy", plrno,i); - secfile_insert_int(file, pcity->did_buy, "player%d.c%d.did_buy", plrno,i); + if (pcity->turn_founded == game.turn) { + j = -1; + } else { + assert(pcity->did_buy == TRUE || pcity->did_buy == FALSE); + j = pcity->did_buy; + } + secfile_insert_int(file, j, "player%d.c%d.did_buy", plrno, i); + secfile_insert_int(file, pcity->turn_founded, + "player%d.c%d.turn_founded", plrno, i); secfile_insert_bool(file, pcity->did_sell, "player%d.c%d.did_sell", plrno,i); secfile_insert_bool(file, pcity->airlift, "player%d.c%d.airlift", plrno,i);