? diff ? cma3_3-3_4.diff ? server/stbrAU1c Index: client/packhand.c =================================================================== RCS file: /home/freeciv/CVS/freeciv/client/packhand.c,v retrieving revision 1.206 diff -u -r1.206 packhand.c --- client/packhand.c 2002/01/16 03:16:25 1.206 +++ client/packhand.c 2002/01/27 10:03:22 @@ -585,6 +585,7 @@ sz_strlcpy(pcity->name, packet->name); pcity->size=packet->size; + pcity->tile_trade = packet->tile_trade; if (packet->happy) { pcity->ppl_happy[4] = pcity->size; @@ -630,7 +631,6 @@ pcity->shield_prod = 0; pcity->shield_surplus = 0; pcity->trade_prod = 0; - pcity->tile_trade = 0; pcity->corruption = 0; pcity->luxury_total = 0; pcity->tax_total = 0; Index: common/capstr.c =================================================================== RCS file: /home/freeciv/CVS/freeciv/common/capstr.c,v retrieving revision 1.91 diff -u -r1.91 capstr.c --- common/capstr.c 2002/01/11 13:50:48 1.91 +++ common/capstr.c 2002/01/27 10:03:23 @@ -72,7 +72,7 @@ #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_worklists tech_cost_style short_city_tile_trade" /* "+1.11.6" is protocol for 1.11.6 beta release. @@ -110,6 +110,9 @@ "tech_cost_style" allows using different algorithms for calculation technology cost. The algorithm used is selected with game.ruleset.tech_cost_style and game.ruleset.tech_leakage. + + "short_city_tile_trade" sends the tile trade in the short_city + packet. */ void init_our_capability(void) Index: common/packets.c =================================================================== RCS file: /home/freeciv/CVS/freeciv/common/packets.c,v retrieving revision 1.170 diff -u -r1.170 packets.c --- common/packets.c 2002/01/11 13:50:49 1.170 +++ common/packets.c 2002/01/27 10:03:26 @@ -2453,6 +2453,10 @@ i = (req->happy?1:0) | (req->capital?2:0) | (req->walls?4:0); cptr=put_uint8(cptr, i); + if (pc && has_capability("short_city_tile_trade", pc->capability)) { + cptr = put_uint16(cptr, req->tile_trade); + } + put_uint16(buffer, cptr-buffer); return send_packet_data(pc, buffer, cptr-buffer); @@ -2484,6 +2488,12 @@ packet->happy = i & 1; packet->capital = i & 2; packet->walls = i & 4; + + if (pc && has_capability("short_city_tile_trade", pc->capability)) { + iget_uint16(&iter, &packet->tile_trade); + } else { + packet->tile_trade = 0; + } pack_iter_end(&iter, pc); remove_packet_from_buffer(pc->buffer); Index: common/packets.h =================================================================== RCS file: /home/freeciv/CVS/freeciv/common/packets.h,v retrieving revision 1.100 diff -u -r1.100 packets.h --- common/packets.h 2002/01/11 13:50:49 1.100 +++ common/packets.h 2002/01/27 10:03:26 @@ -379,6 +379,7 @@ int happy; /* boolean */ int capital; /* boolean */ int walls; /* boolean */ + int tile_trade; /* same as in packet_city_info */ }; Index: server/citytools.c =================================================================== RCS file: /home/freeciv/CVS/freeciv/server/citytools.c,v retrieving revision 1.151 diff -u -r1.151 citytools.c --- server/citytools.c 2002/01/22 17:08:06 1.151 +++ server/citytools.c 2002/01/27 10:03:28 @@ -827,6 +827,17 @@ } reestablish_city_trade_routes(pcity, old_trade_routes); + /* + * Give the new owner infos about all cities which have a traderoute + * with the transfered city. + */ + for (i = 0; i < 4; i++) { + struct city *pother_city = find_city_by_id(pcity->trade[i]); + if (pother_city) { + update_dumb_city(ptaker, pother_city); + } + } + city_refresh(pcity); map_city_radius_iterate(pcity->x, pcity->y, x, y) { update_city_tile_status_map(pcity, x, y); @@ -1268,13 +1279,34 @@ } /************************************************************************** + Returns true if the player owns a city which has a traderoute with + the given city. +**************************************************************************/ +static int player_has_traderoute_with_city(struct player *pplayer, + struct city *pcity) +{ + int i; + + for (i = 0; i < 4; i++) { + struct city *other = find_city_by_id(pcity->trade[i]); + if (other && city_owner(other) == pplayer) { + return 1; + } + } + return 0; +} + +/************************************************************************** This fills out a package from a players dumb_city. **************************************************************************/ static void package_dumb_city(struct player* pplayer, int x, int y, struct packet_short_city *packet) { struct dumb_city *pdcity = map_get_player_tile(x, y, pplayer)->city; - struct city *pcity; + struct city *pcity = map_get_city(x, y); + + assert(pcity); + packet->id=pdcity->id; packet->owner=pdcity->owner; packet->x=x; @@ -1285,19 +1317,23 @@ if (map_get_known_and_seen(x, y, pplayer)) { /* Since the tile is visible the player can see the tile, and if it didn't actually have a city pdcity would be NULL */ - pcity = map_get_tile(x,y)->city; packet->happy = !city_unhappy(pcity); } else { packet->happy=1; } - if ((pcity = map_get_city(x,y)) && pcity->id == pdcity->id && - city_got_building(pcity, B_PALACE)) + if (pcity->id == pdcity->id && city_got_building(pcity, B_PALACE)) packet->capital=1; else packet->capital=0; packet->walls = pdcity->has_walls; + + if (player_has_traderoute_with_city(pplayer, pcity)) { + packet->tile_trade = pcity->tile_trade; + } else { + packet->tile_trade = 0; + } } /**************************************************************************