[Freeciv-Dev] (PR#7333) remove mapview macros from gui-gtk-2.0
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: |
undisclosed-recipients: ; |
Subject: |
[Freeciv-Dev] (PR#7333) remove mapview macros from gui-gtk-2.0 |
From: |
"Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx> |
Date: |
Tue, 27 Jan 2004 17:50:11 -0800 |
Reply-to: |
rt@xxxxxxxxxxx |
<URL: http://rt.freeciv.org/Ticket/Display.html?id=7333 >
When the mapview unification was done we just wrote wrappers for the new
values in mapview.h, rather than rename them throughout the code.
This patch removes these wrappers from gui-gtk-2.0. There are some
cleanups done in the process: many callers did not check the value of
get_canvas_xy (map_to_canvas_pos), and did unnecessary work.
jason
Index: mapview.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk-2.0/mapview.c,v
retrieving revision 1.85
diff -u -r1.85 mapview.c
--- mapview.c 2004/01/11 17:45:03 1.85
+++ mapview.c 2004/01/28 01:47:31
@@ -94,8 +94,14 @@
{
static struct timer *anim_timer = NULL;
struct unit *losing_unit = (hp0 == 0 ? punit0 : punit1);
- int i;
+ int canvas_x, canvas_y, i;
+ if (!map_to_canvas_pos(&canvas_x, &canvas_y,
+ losing_unit->x, losing_unit->y)) {
+ /* No drawing needed. */
+ return;
+ }
+
set_units_in_combat(punit0, punit1);
do {
@@ -118,8 +124,6 @@
} while (punit0->hp > hp0 || punit1->hp > hp1);
for (i = 0; i < num_tiles_explode_unit; i++) {
- int canvas_x, canvas_y;
- get_canvas_xy(losing_unit->x, losing_unit->y, &canvas_x, &canvas_y);
anim_timer = renew_timer_start(anim_timer, TIMER_USER, TIMER_ACTIVE);
if (is_isometric) {
/* We first draw the explosion onto the unit and draw draw the
@@ -560,15 +564,16 @@
mapview_canvas.width = ev->width;
mapview_canvas.height = ev->height;
- if (map_canvas_store_twidth !=tile_width ||
- map_canvas_store_theight!=tile_height) { /* resized? */
+ /* Check if we resized the mapview. */
+ if (mapview_canvas.tile_width != tile_width
+ || mapview_canvas.tile_height != tile_height) {
if (map_canvas_store) {
g_object_unref(map_canvas_store);
}
- map_canvas_store_twidth = tile_width;
- map_canvas_store_theight = tile_height;
+ mapview_canvas.tile_width = tile_width;
+ mapview_canvas.tile_height = tile_height;
map_canvas_store = gdk_pixmap_new(ev->window,
tile_width * NORMAL_TILE_WIDTH,
@@ -934,7 +939,7 @@
int canvas_x, canvas_y;
struct Sprite *mysprite = sprites.explode.iso_nuke;
- get_canvas_xy(x, y, &canvas_x, &canvas_y);
+ (void) map_to_canvas_pos(&canvas_x, &canvas_y, x, y);
canvas_x += NORMAL_TILE_WIDTH/2 - mysprite->width/2;
canvas_y += NORMAL_TILE_HEIGHT/2 - mysprite->height/2;
@@ -952,7 +957,10 @@
for (y_itr=0; y_itr<3; y_itr++) {
for (x_itr=0; x_itr<3; x_itr++) {
struct Sprite *mysprite = sprites.explode.nuke[y_itr][x_itr];
- get_canvas_xy(x + x_itr - 1, y + y_itr - 1, &canvas_x, &canvas_y);
+ if (!map_to_canvas_pos(&canvas_x, &canvas_y,
+ x + x_itr - 1, y + y_itr - 1)) {
+ continue;
+ }
gdk_draw_drawable(single_tile_pixmap, civ_gc, map_canvas_store,
canvas_x, canvas_y, 0, 0,
@@ -1166,9 +1174,8 @@
void put_cross_overlay_tile(int x, int y)
{
int canvas_x, canvas_y;
- get_canvas_xy(x, y, &canvas_x, &canvas_y);
- if (tile_visible_mapcanvas(x, y)) {
+ if (map_to_canvas_pos(&canvas_x, &canvas_y, x, y)) {
pixmap_put_overlay_tile(map_canvas->window,
canvas_x, canvas_y,
sprites.user.attention);
@@ -1193,7 +1200,9 @@
city_map_checked_iterate(pcity->x, pcity->y, i, j, x, y) {
enum city_tile_type worked = get_worker_city(pcity, i, j);
- get_canvas_xy(x, y, &canvas_x, &canvas_y);
+ if (!map_to_canvas_pos(&canvas_x, &canvas_y, x, y)) {
+ continue;
+ }
/* stipple the area */
if (!is_city_center(i, j)) {
@@ -1319,8 +1328,10 @@
/* Find middle of tiles. y-1 to not undraw the the middle pixel of a
horizontal line when we refresh the tile below-between. */
- get_canvas_xy(src_x, src_y, &canvas_start_x, &canvas_start_y);
- get_canvas_xy(dest_x, dest_y, &canvas_end_x, &canvas_end_y);
+ if (!map_to_canvas_pos(&canvas_start_x, &canvas_start_y, src_x, src_y)
+ && !map_to_canvas_pos(&canvas_end_x, &canvas_end_y, dest_x, dest_y)) {
+ return;
+ }
canvas_start_x += NORMAL_TILE_WIDTH/2;
canvas_start_y += NORMAL_TILE_HEIGHT/2-1;
canvas_end_x += NORMAL_TILE_WIDTH/2;
@@ -1394,7 +1405,7 @@
static void put_line(GdkDrawable *pm, int x, int y, int dir)
{
int canvas_src_x, canvas_src_y, canvas_dest_x, canvas_dest_y;
- get_canvas_xy(x, y, &canvas_src_x, &canvas_src_y);
+ (void) map_to_canvas_pos(&canvas_src_x, &canvas_src_y, x, y);
canvas_src_x += NORMAL_TILE_WIDTH/2;
canvas_src_y += NORMAL_TILE_HEIGHT/2;
DIRSTEP(canvas_dest_x, canvas_dest_y, dir);
Index: mapview.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk-2.0/mapview.h,v
retrieving revision 1.12
diff -u -r1.12 mapview.h
--- mapview.h 2003/04/03 04:13:49 1.12
+++ mapview.h 2004/01/28 01:47:31
@@ -52,14 +52,4 @@
void scrollbar_jump_callback(GtkAdjustment *adj, gpointer hscrollbar);
void update_map_canvas_scrollbars_size(void);
-/* These values are stored in the mapview_canvas struct now. */
-#define map_view_x0 mapview_canvas.map_x0
-#define map_view_y0 mapview_canvas.map_y0
-#define map_canvas_store_twidth mapview_canvas.tile_width
-#define map_canvas_store_theight mapview_canvas.tile_height
-
-/* Use of these wrapper functions is deprecated. */
-#define get_canvas_xy(map_x, map_y, canvas_x, canvas_y) \
- map_to_canvas_pos(canvas_x, canvas_y, map_x, map_y)
-
#endif /* FC__MAPVIEW_H */
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Freeciv-Dev] (PR#7333) remove mapview macros from gui-gtk-2.0,
Jason Short <=
|
|