diff -Nurd -X work/diff_ignore freeciv.current/client/gui-gtk/mapview.c work/client/gui-gtk/mapview.c --- freeciv.current/client/gui-gtk/mapview.c Mon Aug 20 09:30:01 2001 +++ work/client/gui-gtk/mapview.c Wed Aug 22 20:14:25 2001 @@ -185,28 +185,42 @@ if (draw_map_grid && !citymode) { int here_in_radius = player_in_city_radius(game.player_ptr, x, y); - /* left side... */ - if ((map_get_tile(x-1, y))->known && - (here_in_radius || - player_in_city_radius(game.player_ptr, x-1, y))) { - gdk_gc_set_foreground(civ_gc, colors_standard[COLOR_STD_WHITE]); - } else { - gdk_gc_set_foreground(civ_gc, colors_standard[COLOR_STD_BLACK]); + enum city_tile_type city_tile_type; + enum city_tile_type city_tile_type_other; + struct city *pcity; + + get_worker_on_map_position(x, y, &city_tile_type, &pcity); + +#define SET_COLOR(_x,_y) \ + if ((map_get_tile((_x), (_y)))->known && \ + (here_in_radius || \ + player_in_city_radius(game.player_ptr, (_x), (_y)))) { \ + get_worker_on_map_position((_x), (_y), \ + &city_tile_type_other, &pcity); \ + if (city_tile_type == C_TILE_WORKER || \ + city_tile_type_other == C_TILE_WORKER) { \ + gdk_gc_set_foreground(civ_gc, \ + colors_standard[COLOR_STD_RED]); \ + } else { \ + gdk_gc_set_foreground(civ_gc, \ + colors_standard[COLOR_STD_WHITE]); \ + } \ + } else { \ + gdk_gc_set_foreground(civ_gc, colors_standard[COLOR_STD_BLACK]); \ } + + /* left side... */ + SET_COLOR(x - 1, y); gdk_draw_line(pm, civ_gc, canvas_x, canvas_y, canvas_x, canvas_y + NORMAL_TILE_HEIGHT); + /* top side... */ - if((map_get_tile(x, y-1))->known && - (here_in_radius || - player_in_city_radius(game.player_ptr, x, y-1))) { - gdk_gc_set_foreground(civ_gc, colors_standard[COLOR_STD_WHITE]); - } else { - gdk_gc_set_foreground(civ_gc, colors_standard[COLOR_STD_BLACK]); - } + SET_COLOR(x, y - 1); gdk_draw_line(pm, civ_gc, canvas_x, canvas_y, canvas_x + NORMAL_TILE_WIDTH, canvas_y); +#undef SET_COLOR } if (draw_coastline && !draw_terrain) { enum tile_terrain_type t1 = map_get_terrain(x, y), t2; diff -Nurd -X work/diff_ignore freeciv.current/client/gui-xaw/mapview.c work/client/gui-xaw/mapview.c --- freeciv.current/client/gui-xaw/mapview.c Mon Aug 20 09:31:23 2001 +++ work/client/gui-xaw/mapview.c Wed Aug 22 20:17:13 2001 @@ -1063,28 +1063,42 @@ if (draw_map_grid && !citymode) { int here_in_radius = player_in_city_radius(game.player_ptr, x, y); - /* left side... */ - if ((map_get_tile(x-1, y))->known && - (here_in_radius || - player_in_city_radius(game.player_ptr, x-1, y))) { - XSetForeground(display, civ_gc, colors_standard[COLOR_STD_WHITE]); - } else { - XSetForeground(display, civ_gc, colors_standard[COLOR_STD_BLACK]); + enum city_tile_type city_tile_type; + enum city_tile_type city_tile_type_other; + struct city *pcity; + + get_worker_on_map_position(x, y, &city_tile_type, &pcity); + +#define SET_COLOR(_x,_y) \ + if ((map_get_tile((_x), (_y)))->known && \ + (here_in_radius || \ + player_in_city_radius(game.player_ptr, (_x), (_y)))) { \ + get_worker_on_map_position((_x), (_y), \ + &city_tile_type_other, &pcity); \ + if (city_tile_type == C_TILE_WORKER || \ + city_tile_type_other == C_TILE_WORKER) { \ + XSetForeground(display, civ_gc, \ + colors_standard[COLOR_STD_RED]); \ + } else { \ + XSetForeground(display, civ_gc, \ + colors_standard[COLOR_STD_WHITE]); \ + } \ + } else { \ + XSetForeground(display, civ_gc, colors_standard[COLOR_STD_BLACK]); \ } + + /* left side... */ + SET_COLOR(x - 1, y); XDrawLine(display, pm, civ_gc, canvas_x, canvas_y, canvas_x, canvas_y + NORMAL_TILE_HEIGHT); + /* top side... */ - if((map_get_tile(x, y-1))->known && - (here_in_radius || - player_in_city_radius(game.player_ptr, x, y-1))) { - XSetForeground(display, civ_gc, colors_standard[COLOR_STD_WHITE]); - } else { - XSetForeground(display, civ_gc, colors_standard[COLOR_STD_BLACK]); - } + SET_COLOR(x, y - 1); XDrawLine(display, pm, civ_gc, canvas_x, canvas_y, canvas_x + NORMAL_TILE_WIDTH, canvas_y); +#undef SET_COLOR } if (draw_coastline && !draw_terrain) { enum tile_terrain_type t1 = map_get_terrain(x, y), t2; diff -Nurd -X work/diff_ignore freeciv.current/common/city.c work/common/city.c --- freeciv.current/common/city.c Thu Jul 5 21:09:46 2001 +++ work/common/city.c Wed Aug 22 20:35:40 2001 @@ -1276,3 +1276,28 @@ return (game.rgame.granary_food_ini * game.foodbox) + (game.rgame.granary_food_inc * city_size * game.foodbox) / 100; } + +/************************************************************************** +Return the status (C_TILE_EMPTY, C_TILE_WORKER or C_TILE_UNAVAILABLE) +of a given map position. If the status is C_TILE_WORKER the city which +uses this tile is also returned. If status isn't C_TILE_WORKER the +city pointer is set to NULL. +**************************************************************************/ +void get_worker_on_map_position(int map_x, int map_y, enum city_tile_type + *result_city_tile_type, + struct city **result_pcity) +{ + struct tile *ptile = map_get_tile(map_x, map_y); + if (ptile->worked) { + *result_pcity = ptile->worked; + *result_city_tile_type = C_TILE_WORKER; + return; + } + + *result_pcity=NULL; + if (is_real_tile(map_x, map_y)) { + *result_city_tile_type = C_TILE_EMPTY; + } else { + *result_city_tile_type = C_TILE_UNAVAILABLE; + } +} diff -Nurd -X work/diff_ignore freeciv.current/common/city.h work/common/city.h --- freeciv.current/common/city.h Wed May 23 21:09:55 2001 +++ work/common/city.h Wed Aug 22 19:28:28 2001 @@ -332,7 +332,11 @@ int city_get_food_tile(int x, int y, struct city *pcity); /* food on spot */ void set_worker_city(struct city *pcity, int city_x, int city_y, enum city_tile_type type); -enum city_tile_type get_worker_city(struct city *pcity, int city_x, int city_y); +enum city_tile_type get_worker_city(struct city *pcity, int city_x, + int city_y); +void get_worker_on_map_position(int map_x, int map_y, + enum city_tile_type *result_city_tile_type, + struct city **result_pcity); int is_worker_here(struct city *pcity, int city_x, int city_y); int map_to_city_x(struct city *pcity, int x); int map_to_city_y(struct city *pcity, int y);