diff -Nur -X/home/thue/freeciv-dev/freeciv/diff_ignore freeciv/ai/advdomestic.c mapprod/ai/advdomestic.c --- freeciv/ai/advdomestic.c Thu Jul 27 20:18:14 2000 +++ mapprod/ai/advdomestic.c Thu Jul 27 20:24:20 2000 @@ -136,7 +136,7 @@ p = 0; city_map_iterate(x, y) { if(get_worker_city(pcity, x, y)==C_TILE_WORKER) { - p += get_shields_tile(x, y, pcity); + p += city_get_shields_tile(x, y, pcity); } } if (city_got_building(pcity, B_FACTORY) || id == B_FACTORY) { diff -Nur -X/home/thue/freeciv-dev/freeciv/diff_ignore freeciv/ai/aicity.c mapprod/ai/aicity.c --- freeciv/ai/aicity.c Thu Jul 27 20:18:18 2000 +++ mapprod/ai/aicity.c Thu Jul 27 20:24:24 2000 @@ -568,11 +568,11 @@ { int a, b; a = city_tile_value(pcity, x, y, - foodneed + get_food_tile(x, y, pcity), - prodneed + get_shields_tile(x, y, pcity)); + foodneed + city_get_food_tile(x, y, pcity), + prodneed + city_get_shields_tile(x, y, pcity)); b = city_tile_value(pcity, bx, by, - foodneed + get_food_tile(bx, by, pcity), - prodneed + get_shields_tile(bx, by, pcity)); + foodneed + city_get_food_tile(bx, by, pcity), + prodneed + city_get_shields_tile(bx, by, pcity)); return (a < b); } @@ -862,8 +862,8 @@ } } if (*xp == 0 && *yp == 0) return 0; - foodneed += get_food_tile(*xp, *yp, pcity); - prodneed += get_shields_tile(*xp, *yp, pcity); + foodneed += city_get_food_tile(*xp, *yp, pcity); + prodneed += city_get_shields_tile(*xp, *yp, pcity); if (e > 1) { foodneed -= (e - 1) * 2; /* forgetting these two lines */ prodneed -= (e - 1); /* led to remarkable idiocy -- Syela */ @@ -909,9 +909,9 @@ while (1) { if ((elviscost = ai_find_elvis_pos(pcity, &xp, &yp))) { - if (get_food_tile(xp, yp, pcity) > pcity->food_surplus) + if (city_get_food_tile(xp, yp, pcity) > pcity->food_surplus) break; - if (get_food_tile(xp, yp, pcity) == pcity->food_surplus && city_happy(pcity)) + if (city_get_food_tile(xp, yp, pcity) == pcity->food_surplus && city_happy(pcity)) break; /* scientists don't party */ if (elviscost >= 24) /* doesn't matter if we wtbb or not! */ break; /* no benefit here! */ diff -Nur -X/home/thue/freeciv-dev/freeciv/diff_ignore freeciv/client/gui-gtk/citydlg.c mapprod/client/gui-gtk/citydlg.c --- freeciv/client/gui-gtk/citydlg.c Thu Jul 27 20:18:22 2000 +++ mapprod/client/gui-gtk/citydlg.c Thu Jul 27 20:24:28 2000 @@ -1111,9 +1111,9 @@ pcity->y+y-CITY_MAP_SIZE/2, 1); if(pcity->city_map[x][y]==C_TILE_WORKER) put_city_tile_output(pdialog->map_canvas->window, x, y, - get_food_tile(x, y, pcity), - get_shields_tile(x, y, pcity), - get_trade_tile(x, y, pcity)); + city_get_food_tile(x, y, pcity), + city_get_shields_tile(x, y, pcity), + city_get_trade_tile(x, y, pcity)); else if(pcity->city_map[x][y]==C_TILE_UNAVAILABLE) pixmap_frame_tile_red(pdialog->map_canvas->window, x, y); } diff -Nur -X/home/thue/freeciv-dev/freeciv/diff_ignore freeciv/client/gui-gtk/mapctrl.c mapprod/client/gui-gtk/mapctrl.c --- freeciv/client/gui-gtk/mapctrl.c Thu Jul 27 20:18:36 2000 +++ mapprod/client/gui-gtk/mapctrl.c Thu Jul 27 20:37:10 2000 @@ -124,6 +124,13 @@ NULL); count++; + my_snprintf(s, sizeof(s), _("food/prod/trade: %s"), + map_get_tile_fpt_text(xtile, ytile)); + gtk_widget_new(GTK_TYPE_LABEL, "GtkWidget::parent", b, + "GtkLabel::label", s, + NULL); + count++; + if(ptile->special&S_HUT) { gtk_widget_new(GTK_TYPE_LABEL, "GtkWidget::parent", b, "GtkLabel::label", _("Minor Tribe Village"), diff -Nur -X/home/thue/freeciv-dev/freeciv/diff_ignore freeciv/client/gui-gtk/mapview.c mapprod/client/gui-gtk/mapview.c --- freeciv/client/gui-gtk/mapview.c Thu Jul 27 20:18:40 2000 +++ mapprod/client/gui-gtk/mapview.c Thu Jul 27 20:24:41 2000 @@ -1285,9 +1285,9 @@ } if(t==C_TILE_WORKER) { put_city_tile_output(map_canvas->window, x+i-2, y+j-2, - get_food_tile(i, j, pcity), - get_shields_tile(i, j, pcity), - get_trade_tile(i, j, pcity) ); + city_get_food_tile(i, j, pcity), + city_get_shields_tile(i, j, pcity), + city_get_trade_tile(i, j, pcity) ); } } diff -Nur -X/home/thue/freeciv-dev/freeciv/diff_ignore freeciv/client/gui-mui/mapclass.c mapprod/client/gui-mui/mapclass.c --- freeciv/client/gui-mui/mapclass.c Thu Jul 27 20:18:45 2000 +++ mapprod/client/gui-mui/mapclass.c Thu Jul 27 20:24:45 2000 @@ -2360,7 +2360,7 @@ if (pcity->city_map[x][y] == C_TILE_WORKER) { - put_city_output_tile(_rp(o), get_food_tile(x, y, pcity), get_shields_tile(x, y, pcity), get_trade_tile(x, y, pcity), + put_city_output_tile(_rp(o), city_get_food_tile(x, y, pcity), city_get_shields_tile(x, y, pcity), city_get_trade_tile(x, y, pcity), _mleft(o), _mtop(o), x, y); } else diff -Nur -X/home/thue/freeciv-dev/freeciv/diff_ignore freeciv/client/gui-xaw/citydlg.c mapprod/client/gui-xaw/citydlg.c --- freeciv/client/gui-xaw/citydlg.c Thu Jul 27 20:18:51 2000 +++ mapprod/client/gui-xaw/citydlg.c Thu Jul 27 20:24:56 2000 @@ -1571,9 +1571,9 @@ pcity->y+y-CITY_MAP_SIZE/2, 1); if(pcity->city_map[x][y]==C_TILE_WORKER) put_city_tile_output(XtWindow(pdialog->map_canvas), x, y, - get_food_tile(x, y, pcity), - get_shields_tile(x, y, pcity), - get_trade_tile(x, y, pcity) ); + city_get_food_tile(x, y, pcity), + city_get_shields_tile(x, y, pcity), + city_get_trade_tile(x, y, pcity) ); else if(pcity->city_map[x][y]==C_TILE_UNAVAILABLE) pixmap_frame_tile_red(XtWindow(pdialog->map_canvas), x, y); } diff -Nur -X/home/thue/freeciv-dev/freeciv/diff_ignore freeciv/client/gui-xaw/mapctrl.c mapprod/client/gui-xaw/mapctrl.c --- freeciv/client/gui-xaw/mapctrl.c Thu Jul 27 20:18:56 2000 +++ mapprod/client/gui-xaw/mapctrl.c Thu Jul 27 20:37:34 2000 @@ -131,6 +131,10 @@ map_get_tile_info_text(xtile, ytile)); XtCreateManagedWidget(s, smeBSBObjectClass, p, NULL, 0); + my_snprintf(s, sizeof(s), _("food/prod/trade: %s"), + map_get_tile_fpt_text(xtile, ytile)); + XtCreateManagedWidget(s, smeBSBObjectClass, p, NULL, 0); + if(ptile->special&S_HUT) { XtCreateManagedWidget(_("Minor Tribe Village"), smeBSBObjectClass, p, NULL, 0); diff -Nur -X/home/thue/freeciv-dev/freeciv/diff_ignore freeciv/client/gui-xaw/mapview.c mapprod/client/gui-xaw/mapview.c --- freeciv/client/gui-xaw/mapview.c Thu Jul 27 20:19:01 2000 +++ mapprod/client/gui-xaw/mapview.c Thu Jul 27 20:25:02 2000 @@ -1200,9 +1200,9 @@ } if(t==C_TILE_WORKER) { put_city_tile_output(XtWindow(map_canvas), x+i-2, y+j-2, - get_food_tile(i, j, pcity), - get_shields_tile(i, j, pcity), - get_trade_tile(i, j, pcity) ); + city_get_food_tile(i, j, pcity), + city_get_shields_tile(i, j, pcity), + city_get_trade_tile(i, j, pcity) ); } } diff -Nur -X/home/thue/freeciv-dev/freeciv/diff_ignore freeciv/common/city.c mapprod/common/city.c --- freeciv/common/city.c Thu Jul 27 20:19:05 2000 +++ mapprod/common/city.c Thu Jul 27 20:25:06 2000 @@ -834,8 +834,34 @@ /************************************************************************** ... **************************************************************************/ +int get_shields_tile(int x, int y) +{ + int s=0; + enum tile_special_type spec_t = map_get_special(x, y); + enum tile_terrain_type tile_t = map_get_terrain(x, y); -int get_shields_tile(int x, int y, struct city *pcity) + if (spec_t & S_SPECIAL_1) + s = get_tile_type(tile_t)->shield_special_1; + else if (spec_t & S_SPECIAL_2) + s = get_tile_type(tile_t)->shield_special_2; + else + s = get_tile_type(tile_t)->shield; + + if (spec_t & S_MINE) + s += (get_tile_type(tile_t))->mining_shield_incr; + if (spec_t & S_RAILROAD) + s+=(s*terrain_control.rail_shield_bonus)/100; + if (spec_t & S_POLLUTION) + s-=(s*terrain_control.pollution_shield_penalty)/100; /* The shields here are icky */ + if (spec_t & S_FALLOUT) + s-=(s*terrain_control.fallout_shield_penalty)/100; + return s; +} + +/************************************************************************** +... +**************************************************************************/ +int city_get_shields_tile(int x, int y, struct city *pcity) { int s=0; enum tile_special_type spec_t=map_get_special(pcity->x+x-2, pcity->y+y-2); @@ -870,7 +896,7 @@ if (before_penalty && s > before_penalty) s--; if (spec_t & S_POLLUTION) - s-=(s*terrain_control.pollution_shield_penalty)/100; /* The shields here is icky */ + s-=(s*terrain_control.pollution_shield_penalty)/100; /* The shields here are icky */ if (spec_t & S_FALLOUT) s-=(s*terrain_control.fallout_shield_penalty)/100; return s; @@ -879,8 +905,47 @@ /************************************************************************** ... **************************************************************************/ +int get_trade_tile(int x, int y) +{ + enum tile_special_type spec_t = map_get_special(x, y); + enum tile_terrain_type tile_t = map_get_terrain(x,y); + int t; + + if (spec_t & S_SPECIAL_1) + t = get_tile_type(tile_t)->trade_special_1; + else if (spec_t & S_SPECIAL_2) + t = get_tile_type(tile_t)->trade_special_2; + else + t = get_tile_type(tile_t)->trade; + + if (troad_trade_incr; + } + if (t) { + if (spec_t & S_RAILROAD) + t+=(t*terrain_control.rail_trade_bonus)/100; + + /* Civ1 specifically documents that Railroad trade increase is before + * Democracy/Republic [government in general now -- SKi] bonus -AJS */ -int get_trade_tile(int x, int y, struct city *pcity) + if (spec_t & S_POLLUTION) + t-=(t*terrain_control.pollution_trade_penalty)/100; /* The trade here are dirty */ + if (spec_t & S_FALLOUT) + t-=(t*terrain_control.fallout_trade_penalty)/100; + } + return t; +} + +/************************************************************************** +... +**************************************************************************/ +int city_get_trade_tile(int x, int y, struct city *pcity) { enum tile_special_type spec_t=map_get_special(pcity->x+x-2, pcity->y+y-2); enum tile_terrain_type tile_t=map_get_terrain(pcity->x+x-2, pcity->y+y-2); @@ -937,8 +1002,42 @@ including ALL modifiers. Center tile acts as irrigated... ***************************************************************/ +int get_food_tile(int x, int y) +{ + int f; + enum tile_special_type spec_t=map_get_special(x, y); + enum tile_terrain_type tile_t=map_get_terrain(x, y); + struct tile_type *type = get_tile_type(tile_t); + + if (spec_t & S_SPECIAL_1) + f=get_tile_type(tile_t)->food_special_1; + else if (spec_t & S_SPECIAL_2) + f=get_tile_type(tile_t)->food_special_2; + else + f=get_tile_type(tile_t)->food; + + if (spec_t & S_IRRIGATION) { + f += type->irrigation_food_incr; + /* No farmland since we do not assume a city with a supermarket */ + } -int get_food_tile(int x, int y, struct city *pcity) + if (spec_t & S_RAILROAD) + f+=(f*terrain_control.rail_food_bonus)/100; + + if (spec_t & S_POLLUTION) + f-=(f*terrain_control.pollution_food_penalty)/100; /* The food here is yucky */ + if (spec_t & S_FALLOUT) + f-=(f*terrain_control.fallout_food_penalty)/100; + + return f; +} + +/*************************************************************** +Here the exact food production should be calculated. That is +including ALL modifiers. +Center tile acts as irrigated... +***************************************************************/ +int city_get_food_tile(int x, int y, struct city *pcity) { int f; enum tile_special_type spec_t=map_get_special(pcity->x+x-2, pcity->y+y-2); diff -Nur -X/home/thue/freeciv-dev/freeciv/diff_ignore freeciv/common/city.h mapprod/common/city.h --- freeciv/common/city.h Thu Jul 27 20:19:10 2000 +++ mapprod/common/city.h Thu Jul 27 20:25:09 2000 @@ -462,11 +462,17 @@ char *get_improvement_name(Impr_Type_id id); char *get_impr_name_ex(struct city *pcity, Impr_Type_id id); +/* tile production functions */ + +int get_shields_tile(int x, int y); /* shield on spot */ +int get_trade_tile(int x, int y); /* trade on spot */ +int get_food_tile(int x, int y); /* food on spot */ + /* city map functions */ -int get_shields_tile(int x, int y, struct city *pcity); /* shield on spot */ -int get_trade_tile(int x, int y, struct city *pcity); /* trade on spot */ -int get_food_tile(int x, int y, struct city *pcity); /* food on spot */ +int city_get_shields_tile(int x, int y, struct city *pcity); /* shield on spot */ +int city_get_trade_tile(int x, int y, struct city *pcity); /* trade on spot */ +int city_get_food_tile(int x, int y, struct city *pcity); /* food on spot */ void set_worker_city(struct city *pcity, int x, int y, enum city_tile_type type); enum city_tile_type get_worker_city(struct city *pcity, int x, int y); int is_worker_here(struct city *pcity, int x, int y); diff -Nur -X/home/thue/freeciv-dev/freeciv/diff_ignore freeciv/common/map.c mapprod/common/map.c --- freeciv/common/map.c Thu Jul 27 20:19:14 2000 +++ mapprod/common/map.c Thu Jul 27 20:33:39 2000 @@ -131,6 +131,20 @@ } /*************************************************************** + Return a (static) string with a tile's food/prod/trade +***************************************************************/ +char *map_get_tile_fpt_text(int x, int y) +{ + static char s[64]; + + my_snprintf(s, sizeof(s), "%d/%d/%d", + get_food_tile(x, y), + get_shields_tile(x, y), + get_trade_tile(x, y)); + return s; +} + +/*************************************************************** Returns 1 if we are at a stage of the game where the map has not yet been generated/loaded. (To be precise, returns 1 if map_allocate() has not yet been diff -Nur -X/home/thue/freeciv-dev/freeciv/diff_ignore freeciv/common/map.h mapprod/common/map.h --- freeciv/common/map.h Thu Jul 27 20:19:18 2000 +++ mapprod/common/map.h Thu Jul 27 20:33:18 2000 @@ -160,6 +160,7 @@ void map_allocate(void); char *map_get_tile_info_text(int x, int y); +char *map_get_tile_fpt_text(int x, int y); struct tile *map_get_tile(int x, int y); int map_distance(int x0, int y0, int x1, int y1); diff -Nur -X/home/thue/freeciv-dev/freeciv/diff_ignore freeciv/server/citytools.c mapprod/server/citytools.c --- freeciv/server/citytools.c Thu Jul 27 20:19:22 2000 +++ mapprod/server/citytools.c Thu Jul 27 20:25:18 2000 @@ -215,17 +215,17 @@ plr = city_owner(pcity); - i = get_food_tile(x, y, pcity); + i = city_get_food_tile(x, y, pcity); if (foodneed > 0) i += 9 * (MIN(i, foodneed)); /* *= 10 led to stupidity with foodneed = 1, mine, and farmland -- Syela */ i *= food_weighting(MAX(2,pcity->size)); - j = get_shields_tile(x, y, pcity); + j = city_get_shields_tile(x, y, pcity); if (prodneed > 0) j += 9 * (MIN(j, prodneed)); j *= SHIELD_WEIGHTING * city_shield_bonus(pcity); j /= 100; - k = get_trade_tile(x, y, pcity) * pcity->ai.trade_want * + k = city_get_trade_tile(x, y, pcity) * pcity->ai.trade_want * (city_tax_bonus(pcity) * (plr->economic.tax + plr->economic.luxury) + city_science_bonus(pcity) * plr->economic.science) / 10000; diff -Nur -X/home/thue/freeciv-dev/freeciv/diff_ignore freeciv/server/cityturn.c mapprod/server/cityturn.c --- freeciv/server/cityturn.c Thu Jul 27 20:19:28 2000 +++ mapprod/server/cityturn.c Thu Jul 27 20:25:22 2000 @@ -358,9 +358,9 @@ city_map_iterate(x, y) { if(get_worker_city(pcity, x, y)==C_TILE_WORKER) { - pcity->food_prod+=get_food_tile(x, y, pcity); - pcity->shield_prod+=get_shields_tile(x, y, pcity); - pcity->trade_prod+=get_trade_tile(x, y, pcity); + pcity->food_prod += city_get_food_tile(x, y, pcity); + pcity->shield_prod += city_get_shields_tile(x, y, pcity); + pcity->trade_prod += city_get_trade_tile(x, y, pcity); } } pcity->tile_trade=pcity->trade_prod; @@ -637,8 +637,8 @@ if(bx || by) { set_worker_city(pcity, bx, by, C_TILE_WORKER); (*workers)--; /* amazing what this did with no parens! -- Syela */ - *foodneed -= get_food_tile(bx,by,pcity) - 2; - *prodneed -= get_shields_tile(bx,by,pcity) - 1; + *foodneed -= city_get_food_tile(bx,by,pcity) - 2; + *prodneed -= city_get_shields_tile(bx,by,pcity) - 1; } } while(*workers && (bx || by)); *foodneed += 2 * (*workers - 1 - e); @@ -696,9 +696,9 @@ set_worker_city(pcity, x, y, C_TILE_EMPTY); set_worker_city(pcity, 2, 2, C_TILE_WORKER); - foodneed=(pcity->size *2 -get_food_tile(2,2, pcity)) + settler_eats(pcity); + foodneed=(pcity->size *2 -city_get_food_tile(2,2, pcity)) + settler_eats(pcity); prodneed = 0; - prodneed -= get_shields_tile(2,2,pcity); + prodneed -= city_get_shields_tile(2,2,pcity); prodneed -= citygov_free_shield(pcity, g); unit_list_iterate(pcity->units_supported, this_unit) {