[Freeciv-Dev] Re: (PR#4729) cleanup to canvas<->city pos functions
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
rwetmore@xxxxxxxxxxxx wrote:
> Worthwhile, but fix the one inconsistency which is actually I think a
> future raft of bugs in hiding.
This version changes city_to_canvas_pos to return a boolean as well.
The callers are changed to check this value. The return value is not
generated perfectly yet, but the added assertion should aid in debugging.
jason
Index: client/citydlg_common.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/citydlg_common.c,v
retrieving revision 1.22
diff -u -r1.22 citydlg_common.c
--- client/citydlg_common.c 2003/08/04 20:57:14 1.22
+++ client/citydlg_common.c 2003/08/04 21:21:40
@@ -55,8 +55,7 @@
This converts a city coordinate position to citymap canvas coordinates
(either isometric or overhead). It should be in cityview.c instead.
**************************************************************************/
-void city_pos_to_canvas_pos(int city_x, int city_y, int *canvas_x,
- int *canvas_y)
+bool city_to_canvas_pos(int *canvas_x, int *canvas_y, int city_x, int city_y)
{
if (is_isometric) {
/*
@@ -74,13 +73,19 @@
*canvas_x = city_x * NORMAL_TILE_WIDTH;
*canvas_y = city_y * NORMAL_TILE_HEIGHT;
}
+
+ if (!is_valid_city_coords(city_x, city_y)) {
+ assert(FALSE);
+ return FALSE;
+ }
+ return TRUE;
}
/**************************************************************************
This converts a citymap canvas position to a city coordinate position
(either isometric or overhead). It should be in cityview.c instead.
**************************************************************************/
-void canvas_pos_to_city_pos(int canvas_x, int canvas_y, int *map_x, int *map_y)
+bool canvas_to_city_pos(int *city_x, int *city_y, int canvas_x, int canvas_y)
{
int orig_canvas_x = canvas_x, orig_canvas_y = canvas_y;
@@ -93,19 +98,21 @@
/* Perform a pi/4 rotation, with scaling. See canvas_pos_to_map_pos
for a full explanation. */
- *map_x = DIVIDE(canvas_x * H + canvas_y * W, W * H);
- *map_y = DIVIDE(canvas_y * W - canvas_x * H, W * H);
+ *city_x = DIVIDE(canvas_x * H + canvas_y * W, W * H);
+ *city_y = DIVIDE(canvas_y * W - canvas_x * H, W * H);
/* Add on the offset of the top-left corner to get the final
- coordinates (like in canvas_pos_to_map_pos). */
- *map_x -= 2;
- *map_y += 2;
+ * coordinates (like in canvas_to_map_pos). */
+ *city_x -= 2;
+ *city_y += 2;
} else {
- *map_x = canvas_x / NORMAL_TILE_WIDTH;
- *map_y = canvas_y / NORMAL_TILE_HEIGHT;
+ *city_x = canvas_x / NORMAL_TILE_WIDTH;
+ *city_y = canvas_y / NORMAL_TILE_HEIGHT;
}
- freelog(LOG_DEBUG, "canvas_pos_to_city_pos(pos=(%d,%d))=(%d,%d)",
- orig_canvas_x, orig_canvas_y, *map_x, *map_y);
+ freelog(LOG_DEBUG, "canvas_to_city_pos(pos=(%d,%d))=(%d,%d)",
+ orig_canvas_x, orig_canvas_y, *city_x, *city_y);
+
+ return is_valid_city_coords(*city_x, *city_y);
}
/**************************************************************************
Index: client/citydlg_common.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/citydlg_common.h,v
retrieving revision 1.15
diff -u -r1.15 citydlg_common.h
--- client/citydlg_common.h 2003/08/04 20:57:14 1.15
+++ client/citydlg_common.h 2003/08/04 21:21:40
@@ -36,8 +36,10 @@
int get_citydlg_canvas_width(void);
int get_citydlg_canvas_height(void);
-void city_pos_to_canvas_pos(int city_x, int city_y, int *canvas_x, int
*canvas_y);
-void canvas_pos_to_city_pos(int canvas_x, int canvas_y, int *map_x, int
*map_y);
+bool city_to_canvas_pos(int *canvas_x, int *canvas_y,
+ int city_x, int city_y);
+bool canvas_to_city_pos(int *city_x, int *city_y,
+ int canvas_x, int canvas_y);
void get_city_dialog_production(struct city *pcity,
char *buffer, size_t buffer_len);
Index: client/mapview_common.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/mapview_common.c,v
retrieving revision 1.55
diff -u -r1.55 mapview_common.c
--- client/mapview_common.c 2003/07/28 04:10:56 1.55
+++ client/mapview_common.c 2003/08/04 21:21:40
@@ -190,8 +190,7 @@
}
if (is_isometric) {
- /* For a simpler example of this math, see
- city_pos_to_canvas_pos(). */
+ /* For a simpler example of this math, see city_to_canvas_pos(). */
int iso_x, iso_y;
/*
@@ -272,7 +271,7 @@
* only use integer math, and C integer division rounds toward zero
* instead of rounding down.
*
- * For another example of this math, see canvas_pos_to_city_pos().
+ * For another example of this math, see canvas_to_city_pos().
*/
*map_x = DIVIDE(canvas_x * H + canvas_y * W, W * H);
*map_y = DIVIDE(canvas_y * W - canvas_x * H, W * H);
Index: client/gui-gtk/citydlg.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk/citydlg.c,v
retrieving revision 1.170
diff -u -r1.170 citydlg.c
--- client/gui-gtk/citydlg.c 2003/08/04 20:57:14 1.170
+++ client/gui-gtk/citydlg.c 2003/08/04 21:21:40
@@ -1773,30 +1773,29 @@
to avoid using any iterator macro. */
for (city_x = 0; city_x<CITY_MAP_SIZE; city_x++)
for (city_y = 0; city_y<CITY_MAP_SIZE; city_y++) {
- int map_x, map_y;
+ int map_x, map_y, canvas_x, canvas_y;
+
if (is_valid_city_coords(city_x, city_y)
- && city_map_to_map(&map_x, &map_y, pcity, city_x, city_y)) {
- if (tile_get_known(map_x, map_y)) {
- int canvas_x, canvas_y;
- city_pos_to_canvas_pos(city_x, city_y, &canvas_x, &canvas_y);
- put_one_tile_full(pdialog->map_canvas_store, map_x, map_y,
- canvas_x, canvas_y, 1);
- }
+ && city_map_to_map(&map_x, &map_y, pcity, city_x, city_y)
+ && tile_get_known(map_x, map_y)
+ && city_to_canvas_pos(&canvas_x, &canvas_y, city_x, city_y)) {
+ put_one_tile_full(pdialog->map_canvas_store, map_x, map_y,
+ canvas_x, canvas_y, 1);
}
}
/* We have to put the output afterwards or it will be covered. */
city_map_checked_iterate(pcity->x, pcity->y, x, y, map_x, map_y) {
- if (tile_get_known(map_x, map_y)) {
- int canvas_x, canvas_y;
- city_pos_to_canvas_pos(x, y, &canvas_x, &canvas_y);
- if (pcity->city_map[x][y] == C_TILE_WORKER) {
- put_city_tile_output(pdialog->map_canvas_store,
- canvas_x, canvas_y,
- city_get_food_tile(x, y, pcity),
- city_get_shields_tile(x, y, pcity),
- city_get_trade_tile(x, y, pcity));
- }
+ int canvas_x, canvas_y;
+
+ if (tile_get_known(map_x, map_y)
+ && city_to_canvas_pos(&canvas_x, &canvas_y, x, y)
+ && pcity->city_map[x][y] == C_TILE_WORKER) {
+ put_city_tile_output(pdialog->map_canvas_store,
+ canvas_x, canvas_y,
+ city_get_food_tile(x, y, pcity),
+ city_get_shields_tile(x, y, pcity),
+ city_get_trade_tile(x, y, pcity));
}
}
city_map_checked_iterate_end;
@@ -1806,13 +1805,12 @@
to fix this, but maybe it wouldn't be a good idea because the
lines would get obscured. */
city_map_checked_iterate(pcity->x, pcity->y, x, y, map_x, map_y) {
- if (tile_get_known(map_x, map_y)) {
- int canvas_x, canvas_y;
- city_pos_to_canvas_pos(x, y, &canvas_x, &canvas_y);
- if (pcity->city_map[x][y] == C_TILE_UNAVAILABLE) {
- pixmap_frame_tile_red(pdialog->map_canvas_store,
- canvas_x, canvas_y);
- }
+ int canvas_x, canvas_y;
+
+ if (tile_get_known(map_x, map_y)
+ && city_to_canvas_pos(&canvas_x, &canvas_y, x, y)
+ && pcity->city_map[x][y] == C_TILE_UNAVAILABLE) {
+ pixmap_frame_tile_red(pdialog->map_canvas_store, canvas_x, canvas_y);
}
}
city_map_checked_iterate_end;
@@ -2800,8 +2798,9 @@
if (pcity) {
int xtile, ytile;
- canvas_pos_to_city_pos(ev->x, ev->y, &xtile, &ytile);
- city_toggle_worker(pcity, xtile, ytile);
+ if (canvas_to_city_pos(&xtile, &ytile, ev->x, ev->y)) {
+ city_toggle_worker(pcity, xtile, ytile);
+ }
}
return TRUE;
}
Index: client/gui-gtk-2.0/citydlg.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk-2.0/citydlg.c,v
retrieving revision 1.61
diff -u -r1.61 citydlg.c
--- client/gui-gtk-2.0/citydlg.c 2003/08/01 20:27:09 1.61
+++ client/gui-gtk-2.0/citydlg.c 2003/08/04 21:21:40
@@ -1371,30 +1371,29 @@
to avoid using any iterator macro. */
for (city_x = 0; city_x<CITY_MAP_SIZE; city_x++)
for (city_y = 0; city_y<CITY_MAP_SIZE; city_y++) {
- int map_x, map_y;
+ int map_x, map_y, canvas_x, canvas_y;
+
if (is_valid_city_coords(city_x, city_y)
- && city_map_to_map(&map_x, &map_y, pcity, city_x, city_y)) {
- if (tile_get_known(map_x, map_y)) {
- int canvas_x, canvas_y;
- city_pos_to_canvas_pos(city_x, city_y, &canvas_x, &canvas_y);
- put_one_tile_full(pdialog->map_canvas_store, map_x, map_y,
- canvas_x, canvas_y, 1);
- }
+ && city_map_to_map(&map_x, &map_y, pcity, city_x, city_y)
+ && tile_get_known(map_x, map_y)
+ && city_to_canvas_pos(&canvas_x, &canvas_y, city_x, city_y)) {
+ put_one_tile_full(pdialog->map_canvas_store, map_x, map_y,
+ canvas_x, canvas_y, 1);
}
}
/* We have to put the output afterwards or it will be covered. */
city_map_checked_iterate(pcity->x, pcity->y, x, y, map_x, map_y) {
- if (tile_get_known(map_x, map_y)) {
- int canvas_x, canvas_y;
- city_pos_to_canvas_pos(x, y, &canvas_x, &canvas_y);
- if (pcity->city_map[x][y] == C_TILE_WORKER) {
- put_city_tile_output(pdialog->map_canvas_store,
- canvas_x, canvas_y,
- city_get_food_tile(x, y, pcity),
- city_get_shields_tile(x, y, pcity),
- city_get_trade_tile(x, y, pcity));
- }
+ int canvas_x, canvas_y;
+
+ if (tile_get_known(map_x, map_y)
+ && city_to_canvas_pos(&canvas_x, &canvas_y, x, y)
+ && pcity->city_map[x][y] == C_TILE_WORKER) {
+ put_city_tile_output(pdialog->map_canvas_store,
+ canvas_x, canvas_y,
+ city_get_food_tile(x, y, pcity),
+ city_get_shields_tile(x, y, pcity),
+ city_get_trade_tile(x, y, pcity));
}
}
city_map_checked_iterate_end;
@@ -1404,13 +1403,12 @@
to fix this, but maybe it wouldn't be a good idea because the
lines would get obscured. */
city_map_checked_iterate(pcity->x, pcity->y, x, y, map_x, map_y) {
- if (tile_get_known(map_x, map_y)) {
- int canvas_x, canvas_y;
- city_pos_to_canvas_pos(x, y, &canvas_x, &canvas_y);
- if (pcity->city_map[x][y] == C_TILE_UNAVAILABLE) {
- pixmap_frame_tile_red(pdialog->map_canvas_store,
- canvas_x, canvas_y);
- }
+ int canvas_x, canvas_y;
+
+ if (tile_get_known(map_x, map_y)
+ && city_to_canvas_pos(&canvas_x, &canvas_y, x, y)
+ && pcity->city_map[x][y] == C_TILE_UNAVAILABLE) {
+ pixmap_frame_tile_red(pdialog->map_canvas_store, canvas_x, canvas_y);
}
}
city_map_checked_iterate_end;
@@ -2328,8 +2326,9 @@
if (pcity) {
int xtile, ytile;
- canvas_pos_to_city_pos(ev->x, ev->y, &xtile, &ytile);
- city_toggle_worker(pcity, xtile, ytile);
+ if (canvas_to_city_pos(&xtile, &ytile, ev->x, ev->y)) {
+ city_toggle_worker(pcity, xtile, ytile);
+ }
}
return TRUE;
}
Index: client/gui-mui/mapclass.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-mui/mapclass.c,v
retrieving revision 1.94
diff -u -r1.94 mapclass.c
--- client/gui-mui/mapclass.c 2003/05/05 12:11:12 1.94
+++ client/gui-mui/mapclass.c 2003/08/04 21:21:40
@@ -2141,26 +2141,28 @@
the city radius can be fogged. */
city_map_checked_iterate(pcity->x, pcity->y, x, y, map_x, map_y) {
- if (tile_get_known(map_x, map_y)) {
- int canvas_x, canvas_y;
- city_pos_to_canvas_pos(x, y, &canvas_x, &canvas_y);
- put_one_tile_full(_rp(o), map_x, map_y, canvas_x + _mleft(o),
canvas_y + _mtop(o), 1);
+ int canvas_x, canvas_y;
+
+ if (tile_get_known(map_x, map_y)
+ && city_to_canvas_pos(&canvas_x, &canvas_y, x, y)) {
+ put_one_tile_full(_rp(o), map_x, map_y, canvas_x + _mleft(o),
+ canvas_y + _mtop(o), 1);
}
} city_map_checked_iterate_end;
/* We have to put the output afterwards or it will be covered. */
city_map_checked_iterate(pcity->x, pcity->y, x, y, map_x, map_y) {
- if (tile_get_known(map_x, map_y)) {
- int canvas_x, canvas_y;
- city_pos_to_canvas_pos(x, y, &canvas_x, &canvas_y);
- if (pcity->city_map[x][y]==C_TILE_WORKER) {
- 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) + canvas_x, _mtop(o) + canvas_y,0,0);
- }
- }
+ int canvas_x, canvas_y;
+
+ if (tile_get_known(map_x, map_y)
+ && city_to_canvas_pos(&canvas_x, &canvas_y, x, y)
+ && pcity->city_map[x][y]==C_TILE_WORKER) {
+ 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) + canvas_x, _mtop(o) + canvas_y,0,0);
+ }
} city_map_checked_iterate_end;
/* This sometimes will draw one of the lines on top of a city or
@@ -2168,29 +2170,35 @@
to fix this, but maybe it wouldn't be a good idea because the
lines would get obscured. */
city_map_checked_iterate(pcity->x, pcity->y, x, y, map_x, map_y) {
- if (tile_get_known(map_x, map_y))
- {
- int canvas_x, canvas_y;
- city_pos_to_canvas_pos(x, y, &canvas_x, &canvas_y);
+ int canvas_x, canvas_y;
- canvas_x += _mleft(o);
- canvas_y += _mtop(o);
- if(pcity->city_map[x][y]==C_TILE_UNAVAILABLE)
- {
- SetAPen(rp, data->red_color);
- Move(rp,canvas_x+NORMAL_TILE_WIDTH/2-1, canvas_y); /* top -->
right */
- Draw(rp,canvas_x+NORMAL_TILE_WIDTH-1,
canvas_y+NORMAL_TILE_HEIGHT/2-1);
-
- Move(rp,canvas_x+NORMAL_TILE_WIDTH/2, canvas_y); /* top --> left */
- Draw(rp,canvas_x, canvas_y+NORMAL_TILE_HEIGHT/2-1);
-
- Move(rp,canvas_x+NORMAL_TILE_WIDTH/2-1,
canvas_y+NORMAL_TILE_HEIGHT-1); /* bottom --> right */
- Draw(rp,canvas_x+NORMAL_TILE_WIDTH-1,
canvas_y+NORMAL_TILE_HEIGHT/2);
-
- Move(rp,canvas_x+NORMAL_TILE_WIDTH/2,
canvas_y+NORMAL_TILE_HEIGHT-1); /* bottom --> left */
- Draw(rp,canvas_x, canvas_y+NORMAL_TILE_HEIGHT/2);
- }
- }
+ if (tile_get_known(map_x, map_y)
+ && city_to_canvas_pos(&canvas_x, &canvas_y, x, y)
+ && pcity->city_map[x][y]==C_TILE_UNAVAILABLE) {
+ canvas_x += _mleft(o);
+ canvas_y += _mtop(o);
+
+ /* top --> right */
+ SetAPen(rp, data->red_color);
+ Move(rp, canvas_x + NORMAL_TILE_WIDTH / 2 - 1, canvas_y);
+ Draw(rp, canvas_x + NORMAL_TILE_WIDTH - 1,
+ canvas_y + NORMAL_TILE_HEIGHT / 2 - 1);
+
+ /* top --> left */
+ Move(rp, canvas_x + NORMAL_TILE_WIDTH / 2, canvas_y);
+ Draw(rp, canvas_x, canvas_y + NORMAL_TILE_HEIGHT / 2 - 1);
+
+ /* bottom --> right */
+ Move(rp, canvas_x + NORMAL_TILE_WIDTH / 2 - 1,
+ canvas_y + NORMAL_TILE_HEIGHT - 1);
+ Draw(rp, canvas_x + NORMAL_TILE_WIDTH - 1,
+ canvas_y + NORMAL_TILE_HEIGHT / 2);
+
+ /* bottom --> left */
+ Move(rp, canvas_x + NORMAL_TILE_WIDTH / 2,
+ canvas_y + NORMAL_TILE_HEIGHT - 1);
+ Draw(rp, canvas_x, canvas_y + NORMAL_TILE_HEIGHT / 2);
+ }
} city_map_checked_iterate_end;
} else
{
@@ -2258,10 +2266,13 @@
if (_isinobject(msg->imsg->MouseX, msg->imsg->MouseY))
{
int x,y;
- canvas_pos_to_city_pos(msg->imsg->MouseX - _mleft(o),
msg->imsg->MouseY - _mtop(o), &x, &y);
- data->click.x = x;
- data->click.y = y;
- set(o, MUIA_CityMap_Click, &data->click);
+ if (canvas_to_city_pos(&x, &y,
+ msg->imsg->MouseX - _mleft(o),
+ msg->imsg->MouseY - _mtop(o))) {
+ data->click.x = x;
+ data->click.y = y;
+ set(o, MUIA_CityMap_Click, &data->click);
+ }
}
}
break;
Index: client/gui-win32/citydlg.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-win32/citydlg.c,v
retrieving revision 1.59
diff -u -r1.59 citydlg.c
--- client/gui-win32/citydlg.c 2003/08/04 20:57:14 1.59
+++ client/gui-win32/citydlg.c 2003/08/04 21:21:40
@@ -501,30 +501,28 @@
to avoid using any iterator macro. */
for (city_x = 0; city_x<CITY_MAP_SIZE; city_x++)
for (city_y = 0; city_y<CITY_MAP_SIZE; city_y++) {
- int map_x, map_y;
+ int map_x, map_y, canvas_x, canvas_y;
+
if (is_valid_city_coords(city_x, city_y)
- && city_map_to_map(&map_x, &map_y, pcity, city_x, city_y)) {
- if (tile_get_known(map_x, map_y)) {
- int canvas_x, canvas_y;
- city_pos_to_canvas_pos(city_x, city_y, &canvas_x, &canvas_y);
- put_one_tile_full(hdc, map_x, map_y,
- canvas_x, canvas_y, 1);
- }
+ && city_map_to_map(&map_x, &map_y, pcity, city_x, city_y)
+ && tile_get_known(map_x, map_y)
+ && city_to_canvas_pos(&canvas_x, &canvas_y, city_x, city_y)) {
+ put_one_tile_full(hdc, map_x, map_y, canvas_x, canvas_y, 1);
}
}
/* We have to put the output afterwards or it will be covered. */
city_map_checked_iterate(pcity->x, pcity->y, x, y, map_x, map_y) {
- if (tile_get_known(map_x, map_y)) {
- int canvas_x, canvas_y;
- city_pos_to_canvas_pos(x, y, &canvas_x, &canvas_y);
- if (pcity->city_map[x][y]==C_TILE_WORKER) {
- put_city_tile_output(hdc,
- canvas_x, canvas_y,
- city_get_food_tile(x, y, pcity),
- city_get_shields_tile(x, y, pcity),
- city_get_trade_tile(x, y, pcity));
- }
+ int canvas_x, canvas_y;
+
+ if (tile_get_known(map_x, map_y)
+ && city_to_canvas_pos(&canvas_x, &canvas_y, x, y)
+ && pcity->city_map[x][y] == C_TILE_WORKER) {
+ put_city_tile_output(hdc,
+ canvas_x, canvas_y,
+ city_get_food_tile(x, y, pcity),
+ city_get_shields_tile(x, y, pcity),
+ city_get_trade_tile(x, y, pcity));
}
} city_map_checked_iterate_end;
@@ -533,13 +531,12 @@
to fix this, but maybe it wouldn't be a good idea because the
lines would get obscured. */
city_map_checked_iterate(pcity->x, pcity->y, x, y, map_x, map_y) {
- if (tile_get_known(map_x, map_y)) {
- int canvas_x, canvas_y;
- city_pos_to_canvas_pos(x, y, &canvas_x, &canvas_y);
- if (pcity->city_map[x][y]==C_TILE_UNAVAILABLE) {
- pixmap_frame_tile_red(hdc,
- canvas_x, canvas_y);
- }
+ int canvas_x, canvas_y;
+
+ if (tile_get_known(map_x, map_y)
+ && city_to_canvas_pos(&canvas_x, &canvas_y, x, y)
+ && pcity->city_map[x][y] == C_TILE_UNAVAILABLE) {
+ pixmap_frame_tile_red(hdc, canvas_x, canvas_y);
}
} city_map_checked_iterate_end;
@@ -1727,10 +1724,11 @@
if ((x>=pdialog->map.x)&&(x<(pdialog->map.x+pdialog->map_w)))
{
int tile_x,tile_y;
- xr=x-pdialog->map.x;
- yr=y-pdialog->map.y;
- canvas_pos_to_city_pos(xr,yr,&tile_x,&tile_y);
- city_toggle_worker(pdialog->pcity, tile_x, tile_y);
+
+ if (canvas_to_city_pos(&tile_x, &tile_y,
+ pdialog->map.x, pdialog->map.y)) {
+ city_toggle_worker(pdialog->pcity, tile_x, tile_y);
+ }
}
}
xr=x-pdialog->pop_x;
@@ -2241,10 +2239,11 @@
if ((x>=pdialog->maph.x)&&(x<(pdialog->maph.x+pdialog->map_w))&&
(y>=pdialog->maph.y)&&(y<(pdialog->maph.y+pdialog->map_h))) {
int tile_x,tile_y;
- canvas_pos_to_city_pos(x-pdialog->maph.x,
- y-pdialog->maph.y,
- &tile_x,&tile_y);
- city_toggle_worker(pdialog->pcity, tile_x, tile_y);
+
+ if (canvas_to_city_pos(&tile_x, &tile_y,
+ x-pdialog->maph.x, y-pdialog->maph.y)) {
+ city_toggle_worker(pdialog->pcity, tile_x, tile_y);
+ }
}
break;
case WM_PAINT:
Index: client/gui-xaw/citydlg.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-xaw/citydlg.c,v
retrieving revision 1.102
diff -u -r1.102 citydlg.c
--- client/gui-xaw/citydlg.c 2003/08/04 20:57:15 1.102
+++ client/gui-xaw/citydlg.c 2003/08/04 21:21:40
@@ -1889,8 +1889,9 @@
if (!cma_is_city_under_agent(pcity, NULL)) {
int xtile, ytile;
- canvas_pos_to_city_pos(ev->x, ev->y, &xtile, &ytile);
- city_toggle_worker(pcity, xtile, ytile);
+ if (canvas_to_city_pos(&xtile, &ytile, ev->x, ev->y)) {
+ city_toggle_worker(pcity, xtile, ytile);
+ }
}
}
}
|
|