diff --exclude=*~ --exclude=CVS --exclude=.deps -Naur freeciv-orig/client/gui-gtk/mapctrl.c freeciv/client/gui-gtk/mapctrl.c --- freeciv-orig/client/gui-gtk/mapctrl.c Wed Apr 14 20:01:29 1999 +++ freeciv/client/gui-gtk/mapctrl.c Tue Apr 20 22:42:23 1999 @@ -41,10 +41,8 @@ /* unit_focus points to the current unit in focus */ struct unit *punit_focus; -/* Update the workers for a city on the map, when the update is received */ -struct city *city_workers_display = NULL; -/* Color to use to display the workers */ -int city_workers_color=COLOR_STD_WHITE; +/* last color given when displaying icty workers on map */ +int last_city_workers_color = 0; /* set high, if the player has selected goto */ /* actually, set to id of unit goto-ing (id is non-zero) */ @@ -933,29 +931,40 @@ struct city *pcity; struct packet_city_request packet; - if(get_client_state()!=CLIENT_GAME_RUNNING_STATE) + if(get_client_state() != CLIENT_GAME_RUNNING_STATE) return TRUE; - x=ev->x/NORMAL_TILE_WIDTH; y=ev->y/NORMAL_TILE_HEIGHT; - x=map_adjust_x(map_view_x0+x); y=map_adjust_y(map_view_y0+y); + x = ev->x / NORMAL_TILE_WIDTH; y = ev->y / NORMAL_TILE_HEIGHT; + x = map_adjust_x(map_view_x0 + x); y = map_adjust_y(map_view_y0 + y); - if(!(pcity = find_city_near_tile(x,y))) return TRUE; + if (pcity = (map_get_tile (x, y))->worked) { + if (! pcity->workers_color) + return TRUE; + + x = x - pcity->x + 2; y = y - pcity->y + 2; + + packet.city_id = pcity->id; + packet.worker_x=x; + packet.worker_y=y; + packet.name[0]='\0'; - x = x-pcity->x+2; y = y-pcity->y+2; - packet.city_id=pcity->id; - packet.worker_x=x; - packet.worker_y=y; - packet.name[0]='\0'; - - if(pcity->city_map[x][y]==C_TILE_WORKER) send_packet_city_request(&aconnection, &packet, PACKET_CITY_MAKE_SPECIALIST); - else if(pcity->city_map[x][y]==C_TILE_EMPTY) + } else if (pcity = find_city_near_tile (x,y)) { + if (! pcity->workers_color) + return TRUE; + + x = x - pcity->x + 2; y = y - pcity->y + 2; + + packet.city_id = pcity->id; + packet.worker_x=x; + packet.worker_y=y; + packet.name[0]='\0'; + send_packet_city_request(&aconnection, &packet, PACKET_CITY_MAKE_WORKER); + } - /* When the city info packet is received, update the workers on the map*/ - city_workers_display = pcity; return TRUE; } @@ -1025,10 +1034,14 @@ pcity = find_city_near_tile(x,y); if(pcity==NULL) return TRUE; - /* Shade tiles on usage */ - city_workers_color = (city_workers_color%3)+1; - put_city_workers(pcity, city_workers_color); + if (! pcity->workers_color) { + pcity->workers_color = last_city_workers_color = (last_city_workers_color % 4) + 1; + } else { + pcity->workers_color = 0; + } + put_city_workers(pcity); + return TRUE; } diff --exclude=*~ --exclude=CVS --exclude=.deps -Naur freeciv-orig/client/gui-gtk/mapview.c freeciv/client/gui-gtk/mapview.c --- freeciv-orig/client/gui-gtk/mapview.c Thu Apr 15 11:43:24 1999 +++ freeciv/client/gui-gtk/mapview.c Mon Apr 19 23:05:11 1999 @@ -1544,6 +1544,15 @@ } } } + + /* show city workers, as 25% opaqueness */ + if (!citymode && ptile->worked && ptile->worked->workers_color) { + gdk_gc_set_foreground(fill_tile_gc, colors_standard[ptile->worked->workers_color]); + gdk_gc_set_stipple(fill_tile_gc,gray25); + gdk_draw_rectangle(pm, fill_tile_gc, TRUE, + x * NORMAL_TILE_WIDTH, y * NORMAL_TILE_HEIGHT, + NORMAL_TILE_WIDTH, NORMAL_TILE_HEIGHT); + } } @@ -1606,39 +1615,15 @@ /************************************************************************** Shade the tiles around a city to indicate the location of workers **************************************************************************/ -void put_city_workers(struct city *pcity, int color) +void put_city_workers(struct city *pcity) { int x,y; - int i,j; - static struct city *last_pcity=NULL; - if(color==-1) { - if(pcity!=last_pcity) city_workers_color = (city_workers_color%3)+1; - color=city_workers_color; - } - - gdk_gc_set_foreground(fill_tile_gc, colors_standard[color]); - x=map_canvas_adjust_x(pcity->x); y=map_canvas_adjust_y(pcity->y); - city_map_iterate(i, j) { - enum city_tile_type t=get_worker_city(pcity, i, j); - enum city_tile_type last_t=-1; - if(i==2 && j==2) continue; - if(t==C_TILE_EMPTY) { - if(last_t!=t) gdk_gc_set_stipple(fill_tile_gc,gray25); - } else if(t==C_TILE_WORKER) { - if(last_t!=t) gdk_gc_set_stipple(fill_tile_gc,gray50); - } else continue; - last_t=t; - gdk_draw_pixmap(map_canvas->window, civ_gc, map_canvas_store, - (x+i-2)*NORMAL_TILE_WIDTH, (y+j-2)*NORMAL_TILE_HEIGHT, - (x+i-2)*NORMAL_TILE_WIDTH, (y+j-2)*NORMAL_TILE_HEIGHT, - NORMAL_TILE_WIDTH, NORMAL_TILE_HEIGHT); - gdk_draw_rectangle(map_canvas->window, fill_tile_gc, TRUE, - (x+i-2)*NORMAL_TILE_WIDTH, (y+j-2)*NORMAL_TILE_HEIGHT, - NORMAL_TILE_WIDTH, NORMAL_TILE_HEIGHT); - } + x = map_canvas_adjust_x (pcity->x); y = map_canvas_adjust_y (pcity->y); + update_map_canvas (x - (CITY_MAP_SIZE / 2), y - (CITY_MAP_SIZE / 2), + CITY_MAP_SIZE, CITY_MAP_SIZE, 1); - last_pcity=pcity; + return; } diff --exclude=*~ --exclude=CVS --exclude=.deps -Naur freeciv-orig/client/gui-gtk/mapview.h freeciv/client/gui-gtk/mapview.h --- freeciv-orig/client/gui-gtk/mapview.h Tue Apr 13 14:14:40 1999 +++ freeciv/client/gui-gtk/mapview.h Mon Apr 19 22:48:45 1999 @@ -154,7 +154,7 @@ int citymode); void put_cross_overlay_tile(int x,int y); -void put_city_workers(struct city *pcity, int color); +void put_city_workers(struct city *pcity); void decrease_unit_hp_smooth(struct unit *punit0, int hp0, struct unit *punit1, int hp1); diff --exclude=*~ --exclude=CVS --exclude=.deps -Naur freeciv-orig/client/gui-xaw/mapctrl.c freeciv/client/gui-xaw/mapctrl.c --- freeciv-orig/client/gui-xaw/mapctrl.c Tue Apr 13 13:08:53 1999 +++ freeciv/client/gui-xaw/mapctrl.c Tue Apr 20 22:42:26 1999 @@ -55,10 +55,8 @@ /* unit_focus points to the current unit in focus */ struct unit *punit_focus; -/* Update the workers for a city on the map, when the update is received */ -struct city *city_workers_display = NULL; -/* Color to use to display the workers */ -int city_workers_color=COLOR_STD_WHITE; +/* last color given when displaying icty workers on map */ +int last_city_workers_color = 0; /* set high, if the player has selected goto */ /* actually, set to id of unit goto-ing (id is non-zero) */ @@ -971,25 +969,33 @@ x=ev->x/NORMAL_TILE_WIDTH; y=ev->y/NORMAL_TILE_HEIGHT; x=map_adjust_x(map_view_x0+x); y=map_adjust_y(map_view_y0+y); - if(!(pcity = find_city_near_tile(x,y))) return; + if (pcity = (map_get_tile (x, y))->worked) { + if (! pcity->workers_color) + return; + + x = x - pcity->x + 2; y = y - pcity->y + 2; + + packet.city_id = pcity->id; + packet.worker_x=x; + packet.worker_y=y; + packet.name[0]='\0'; - x = x-pcity->x+2; y = y-pcity->y+2; - packet.city_id=pcity->id; - packet.worker_x=x; - packet.worker_y=y; - packet.name[0]='\0'; - - if(pcity->city_map[x][y]==C_TILE_WORKER) - send_packet_city_request(&aconnection, &packet, - PACKET_CITY_MAKE_SPECIALIST); - else if(pcity->city_map[x][y]==C_TILE_EMPTY) send_packet_city_request(&aconnection, &packet, - PACKET_CITY_MAKE_WORKER); - - /* When the city info packet is received, update the workers on the map*/ - city_workers_display = pcity; + PACKET_CITY_MAKE_SPECIALIST); + } else if (pcity = find_city_near_tile (x,y)) { + if (! pcity->workers_color) + return; + + x = x - pcity->x + 2; y = y - pcity->y + 2; + + packet.city_id = pcity->id; + packet.worker_x=x; + packet.worker_y=y; + packet.name[0]='\0'; - return; + send_packet_city_request(&aconnection, &packet, + PACKET_CITY_MAKE_WORKER); + } } @@ -1011,10 +1017,14 @@ pcity = find_city_near_tile(x,y); if(pcity==NULL) return; - /* Shade tiles on usage */ - city_workers_color = (city_workers_color%3)+1; - put_city_workers(pcity, city_workers_color); + if (! pcity->workers_color) { + pcity->workers_color = last_city_workers_color = (last_city_workers_color % 4) + 1; + } else { + pcity->workers_color = 0; + } + + put_city_workers(pcity); } diff --exclude=*~ --exclude=CVS --exclude=.deps -Naur freeciv-orig/client/gui-xaw/mapview.c freeciv/client/gui-xaw/mapview.c --- freeciv-orig/client/gui-xaw/mapview.c Tue Apr 13 13:08:54 1999 +++ freeciv/client/gui-xaw/mapview.c Mon Apr 19 23:07:30 1999 @@ -1388,6 +1388,15 @@ } } } + + /* show city workers, as 25% opaqueness */ + if (!citymode && ptile->worked && ptile->worked->workers_color) { + XSetForeground(display, fill_tile_gc, colors_standard[ptile->worked->workers_color]); + XSetStipple(display,fill_tile_gc,gray25); + XFillRectangle(display, pm, fill_tile_gc, + x*NORMAL_TILE_WIDTH, y*NORMAL_TILE_HEIGHT, + NORMAL_TILE_WIDTH, NORMAL_TILE_HEIGHT); + } } @@ -1426,39 +1435,15 @@ /************************************************************************** Shade the tiles around a city to indicate the location of workers **************************************************************************/ -void put_city_workers(struct city *pcity, int color) +void put_city_workers(struct city *pcity) { int x,y; - int i,j; - static struct city *last_pcity=NULL; - if(color==-1) { - if(pcity!=last_pcity) city_workers_color = (city_workers_color%3)+1; - color=city_workers_color; - } - - XSetForeground(display, fill_tile_gc, colors_standard[color]); - x=map_canvas_adjust_x(pcity->x); y=map_canvas_adjust_y(pcity->y); - city_map_iterate(i, j) { - enum city_tile_type t=get_worker_city(pcity, i, j); - enum city_tile_type last_t=-1; - if(i==2 && j==2) continue; - if(t==C_TILE_EMPTY) { - if(last_t!=t) XSetStipple(display,fill_tile_gc,gray25); - } else if(t==C_TILE_WORKER) { - if(last_t!=t) XSetStipple(display,fill_tile_gc,gray50); - } else continue; - last_t=t; - XCopyArea(display, map_canvas_store, XtWindow(map_canvas), civ_gc, - (x+i-2)*NORMAL_TILE_WIDTH, (y+j-2)*NORMAL_TILE_HEIGHT, - NORMAL_TILE_WIDTH, NORMAL_TILE_HEIGHT, - (x+i-2)*NORMAL_TILE_WIDTH, (y+j-2)*NORMAL_TILE_HEIGHT); - XFillRectangle(display, XtWindow(map_canvas), fill_tile_gc, - (x+i-2)*NORMAL_TILE_WIDTH, (y+j-2)*NORMAL_TILE_HEIGHT, - NORMAL_TILE_WIDTH, NORMAL_TILE_HEIGHT); - } + x = map_canvas_adjust_x (pcity->x); y = map_canvas_adjust_y (pcity->y); + update_map_canvas (x - (CITY_MAP_SIZE / 2), y - (CITY_MAP_SIZE / 2), + CITY_MAP_SIZE, CITY_MAP_SIZE, 1); - last_pcity=pcity; + return; } diff --exclude=*~ --exclude=CVS --exclude=.deps -Naur freeciv-orig/client/gui-xaw/mapview.h freeciv/client/gui-xaw/mapview.h --- freeciv-orig/client/gui-xaw/mapview.h Tue Apr 13 12:53:13 1999 +++ freeciv/client/gui-xaw/mapview.h Mon Apr 19 23:07:59 1999 @@ -160,7 +160,7 @@ void put_nuke_mushroom_pixmaps(int abs_x0, int abs_y0); void put_cross_overlay_tile(int x,int y); -void put_city_workers(struct city *pcity, int color); +void put_city_workers(struct city *pcity); void my_XawScrollbarSetThumb(Widget w, float top, float shown); void update_map_canvas_scrollbars(void); diff --exclude=*~ --exclude=CVS --exclude=.deps -Naur freeciv-orig/client/packhand.c freeciv/client/packhand.c --- freeciv-orig/client/packhand.c Tue Apr 13 14:24:57 1999 +++ freeciv/client/packhand.c Tue Apr 20 22:46:48 1999 @@ -158,7 +158,7 @@ if(!pcity) { city_is_new=1; - pcity=(struct city *)malloc(sizeof(struct city)); + pcity=(struct city *) calloc(1, sizeof(struct city)); } else city_is_new=0; @@ -231,10 +231,8 @@ refresh_tile_mapcanvas(pcity->x, pcity->y, 1); - if(city_workers_display==pcity) { - put_city_workers(pcity, -1); - city_workers_display=NULL; - } + if (pcity->workers_color) + put_city_workers(pcity); if(((city_is_new && get_client_state()==CLIENT_GAME_RUNNING_STATE && pcity->owner==game.player_idx) || packet->diplomat_investigate) && diff --exclude=*~ --exclude=CVS --exclude=.deps -Naur freeciv-orig/common/city.h freeciv/common/city.h --- freeciv-orig/common/city.h Sun Apr 18 04:44:14 1999 +++ freeciv/common/city.h Mon Apr 19 22:21:26 1999 @@ -168,6 +168,9 @@ enum city_tile_type city_map[CITY_MAP_SIZE][CITY_MAP_SIZE]; + /* display workers on map (color or 0) */ + int workers_color; + struct unit_list units_supported; int steal; /* diplomats can only steal once */ /* turn states */