diff -Nurd -X work/diff_ignore freeciv.current/client/climisc.c work/client/climisc.c --- freeciv.current/client/climisc.c Tue Apr 24 14:25:31 2001 +++ work/client/climisc.c Thu Aug 23 13:08:52 2001 @@ -477,3 +477,33 @@ } return index; } + +/************************************************************************** +Returns the color the grid should have between tile (x1,y1) and +(x2,y2). +**************************************************************************/ +enum color_std get_grid_color(int x1, int y1, int x2, int y2) +{ + enum city_tile_type city_tile_type1, city_tile_type2; + struct city *dummy_pcity; + + assert(is_tiles_adjacent(x1, y1, x2, y2)); + + if (!map_get_tile(x2, y2)->known) { + return COLOR_STD_BLACK; + } + + if (!player_in_city_radius(game.player_ptr, x1, y1) && + !player_in_city_radius(game.player_ptr, x2, y2)) { + return COLOR_STD_BLACK; + } + + get_worker_on_map_position(x1, y1, &city_tile_type1, &dummy_pcity); + get_worker_on_map_position(x2, y2, &city_tile_type2, &dummy_pcity); + + if (city_tile_type1 == C_TILE_WORKER || city_tile_type2 == C_TILE_WORKER) { + return COLOR_STD_RED; + } else { + return COLOR_STD_WHITE; + } +} diff -Nurd -X work/diff_ignore freeciv.current/client/climisc.h work/client/climisc.h --- freeciv.current/client/climisc.h Wed Sep 6 23:41:12 2000 +++ work/client/climisc.h Thu Aug 23 12:58:22 2001 @@ -35,5 +35,7 @@ int client_warming_sprite(void); int client_cooling_sprite(void); +enum color_std get_grid_color(int x1, int y1, int x2, int y2); + #endif /* FC__CLIMISC_H */ 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 Thu Aug 23 13:05:38 2001 @@ -183,31 +183,21 @@ } 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]); - } - gdk_draw_line(pm, civ_gc, - canvas_x, canvas_y, - canvas_x, canvas_y + NORMAL_TILE_HEIGHT); + gdk_gc_set_foreground(civ_gc, + colors_standard[get_grid_color + (x, y, 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]); - } - gdk_draw_line(pm, civ_gc, - canvas_x, canvas_y, + gdk_gc_set_foreground(civ_gc, + colors_standard[get_grid_color + (x, y, x, y - 1)]); + gdk_draw_line(pm, civ_gc, canvas_x, canvas_y, canvas_x + NORMAL_TILE_WIDTH, canvas_y); } + if (draw_coastline && !draw_terrain) { enum tile_terrain_type t1 = map_get_terrain(x, y), t2; int x1 = x-1, y1 = y; @@ -2350,34 +2340,23 @@ if (draw_map_grid) { /* we draw the 2 lines on top of the tile; the buttom lines will be drawn by the tiles underneath. */ - int here_in_radius = player_in_city_radius(game.player_ptr, x, y); - if (draw & D_M_R) { - int x1 = x, y1 = y - 1; - if (normalize_map_pos(&x1, &y1) && map_get_tile(x1, y1)->known - && (here_in_radius - || player_in_city_radius(game.player_ptr, x1, y1))) { - gdk_gc_set_foreground(thin_line_gc, colors_standard[COLOR_STD_WHITE]); - } else { - gdk_gc_set_foreground(thin_line_gc, colors_standard[COLOR_STD_BLACK]); - } + gdk_gc_set_foreground(thin_line_gc, + colors_standard[get_grid_color + (x, y, x, y - 1)]); gdk_draw_line(pm, thin_line_gc, - canvas_x+NORMAL_TILE_WIDTH/2, canvas_y, - canvas_x+NORMAL_TILE_WIDTH, canvas_y+NORMAL_TILE_HEIGHT/2); + canvas_x + NORMAL_TILE_WIDTH / 2, canvas_y, + canvas_x + NORMAL_TILE_WIDTH, + canvas_y + NORMAL_TILE_HEIGHT / 2); } if (draw & D_M_L) { - int x1 = x - 1, y1 = y; - if (normalize_map_pos(&x1, &y1) && map_get_tile(x1, y1)->known - && (here_in_radius - || player_in_city_radius(game.player_ptr, x1, y1))) { - gdk_gc_set_foreground(thin_line_gc, colors_standard[COLOR_STD_WHITE]); - } else { - gdk_gc_set_foreground(thin_line_gc, colors_standard[COLOR_STD_BLACK]); - } + gdk_gc_set_foreground(thin_line_gc, + colors_standard[get_grid_color + (x, y, x - 1, y)]); gdk_draw_line(pm, thin_line_gc, - canvas_x, canvas_y + NORMAL_TILE_HEIGHT/2, - canvas_x+NORMAL_TILE_WIDTH/2, canvas_y); + canvas_x, canvas_y + NORMAL_TILE_HEIGHT / 2, + canvas_x + NORMAL_TILE_WIDTH / 2, canvas_y); } } 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 Thu Aug 23 14:57:59 2001 @@ -35,7 +35,6 @@ #include "timing.h" #include "unit.h" - #include "civclient.h" #include "climisc.h" #include "colors.h" @@ -1061,27 +1060,16 @@ } 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]); - } + XSetForeground(display, civ_gc, colors_standard[get_grid_color + (x, y, 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]); - } + XSetForeground(display, civ_gc, colors_standard[get_grid_color + (x, y, x, y - 1)]); XDrawLine(display, pm, civ_gc, canvas_x, canvas_y, canvas_x + NORMAL_TILE_WIDTH, canvas_y); diff -Nurd -X work/diff_ignore freeciv.current/common/city.c work/common/city.c --- freeciv.current/common/city.c Thu Aug 23 09:02:58 2001 +++ work/common/city.c Thu Aug 23 12:48:30 2001 @@ -1282,3 +1282,27 @@ } } +/************************************************************************** +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 Thu Aug 23 09:02:58 2001 +++ work/common/city.h Thu Aug 23 12:47:49 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);