Complete.Org: Mailing Lists: Archives: freeciv-dev: October 2001:
[Freeciv-Dev] refresh_tile_mapcanvas unification (PR#1026)
Home

[Freeciv-Dev] refresh_tile_mapcanvas unification (PR#1026)

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: freeciv-dev@xxxxxxxxxxx
Cc: bugs@xxxxxxxxxxxxxxxxxxx
Subject: [Freeciv-Dev] refresh_tile_mapcanvas unification (PR#1026)
From: jdorje@xxxxxxxxxxxxxxxxxxxxx
Date: Sun, 21 Oct 2001 22:59:44 -0700 (PDT)

The attached patch attempts to unify the refresh_tile_mapcanvas function
for all GUI's.

It has been tested for GTK, and I'm about to test it for Xaw.

There are only three debatable points:

- New files called client/mapview_common.[ch] are created.  Are these
names acceptable?

- The BeOS client will be disrupted by this change.  OTOH, the
applicable part of the BeOS client hasn't even been written yet so this
shouldn't really be a step backwards.

- I've #included mapview_common.h from mapview_g.h.  This made it easy
for me to make sure every relevant file had already included
mapview_common.h.  The other alternative is to #include mapview_common.h
from every file that uses refresh_tile_mapcanvas - but since I can't
compile the code for many of the GUI's this is difficult to verify.

In summary, it would be ideal if GUI authors would verify and approve of
this patch.  Failing that, it would be nice if someone could at least
compile it for every GUI (if that works, the rest should too).

(Note: the patch couldn't be made with cvs diff since new files are
created.  Apply with patch -p1 and be sure to run automake before
compilation.)

jason
diff -Naur freeciv-cvs-pristine/client/Makefile.am freeciv1/client/Makefile.am
--- freeciv-cvs-pristine/client/Makefile.am     Sun Sep  2 06:24:25 2001
+++ freeciv1/client/Makefile.am Mon Oct 22 01:51:00 2001
@@ -120,6 +120,8 @@
        goto.h          \
        helpdata.c      \
        helpdata.h      \
+       mapview_common.c \
+       mapview_common.h \
        packhand.c      \
        packhand.h      \
        options.c       \
diff -Naur freeciv-cvs-pristine/client/gui-beos/MainWindow.cpp 
freeciv1/client/gui-beos/MainWindow.cpp
--- freeciv-cvs-pristine/client/gui-beos/MainWindow.cpp Sun Aug  6 16:59:50 2000
+++ freeciv1/client/gui-beos/MainWindow.cpp     Mon Oct 22 01:51:00 2001
@@ -204,7 +204,6 @@
        case UI_PUT_NUKE_MUSHROOM_PIXMAPS:
        case UI_REFRESH_OVERVIEW_CANVAS:
        case UI_REFRESH_OVERVIEW_VIEWRECT:
-       case UI_REFRESH_TILE_MAPCANVAS:
        case UI_POPUP_MESSAGEOPT_DIALOG:
        case UI_POPUP_MESWIN_DIALOG:
        case UI_UPDATE_MESWIN_DIALOG:
diff -Naur freeciv-cvs-pristine/client/gui-beos/mapview.cpp 
freeciv1/client/gui-beos/mapview.cpp
--- freeciv-cvs-pristine/client/gui-beos/mapview.cpp    Tue Jul  4 19:29:39 2000
+++ freeciv1/client/gui-beos/mapview.cpp        Mon Oct 22 01:51:00 2001
@@ -243,18 +243,6 @@
 }
 
 
-void
-refresh_tile_mapcanvas(int x, int y, int write_to_screen)      // HOOK
-{
-    BMessage *msg = new BMessage( UI_REFRESH_TILE_MAPCANVAS );
-    msg->AddInt32( "x", x );
-    msg->AddInt32( "y", y );
-       msg->AddBool( "to_screen", !!write_to_screen );
-    ui->PostMessage( msg );
-}
-
-
-
 
 
 //---------------------------------------------------------------------
@@ -282,4 +270,3 @@
 //     UI_PUT_NUKE_MUSHROOM_PIXMAPS,
 //     UI_REFRESH_OVERVIEW_CANVAS,
 //     UI_REFRESH_OVERVIEW_VIEWRECT,
-//  UI_REFRESH_TILE_MAPCANVAS,
diff -Naur freeciv-cvs-pristine/client/gui-gtk/mapview.c 
freeciv1/client/gui-gtk/mapview.c
--- freeciv-cvs-pristine/client/gui-gtk/mapview.c       Tue Oct 16 05:11:15 2001
+++ freeciv1/client/gui-gtk/mapview.c   Mon Oct 22 01:51:00 2001
@@ -629,21 +629,6 @@
   gtk_pixmap_set(GTK_PIXMAP(government_label), gov_sprite->pixmap, NULL);
 }
 
-/**************************************************************************
-This function is now identical in all GUI's except BeOS.
-**************************************************************************/
-void refresh_tile_mapcanvas(int x, int y, int write_to_screen)
-{
-  int is_real = normalize_map_pos(&x, &y);
-
-  assert(is_real);
-
-  if (tile_visible_mapcanvas(x, y)) {
-    update_map_canvas(x, y, 1, 1, write_to_screen);
-  }
-  overview_update_tile(x, y);
-}
-
 
 /**************************************************************************
 ...
diff -Naur freeciv-cvs-pristine/client/gui-gtk/mapview.h 
freeciv1/client/gui-gtk/mapview.h
--- freeciv-cvs-pristine/client/gui-gtk/mapview.h       Sun Feb  4 08:45:20 2001
+++ freeciv1/client/gui-gtk/mapview.h   Mon Oct 22 01:51:00 2001
@@ -18,6 +18,7 @@
 #include "gtkpixcomm.h"
 
 #include "mapview_g.h"
+#include "mapview_common.h"
 
 #include "graphics.h"
 
diff -Naur freeciv-cvs-pristine/client/gui-mui/mapview.c 
freeciv1/client/gui-mui/mapview.c
--- freeciv-cvs-pristine/client/gui-mui/mapview.c       Tue Oct 16 05:11:16 2001
+++ freeciv1/client/gui-mui/mapview.c   Mon Oct 22 01:51:00 2001
@@ -371,21 +371,6 @@
   set(main_government_sprite, MUIA_Sprite_Sprite, gov_sprite);
 }
 
-/**************************************************************************
-This function is now identical in all GUI's except BeOS.
-**************************************************************************/
-void refresh_tile_mapcanvas(int x, int y, int write_to_screen)
-{
-  int is_real = normalize_map_pos(&x, &y);
-
-  assert(is_real);
-
-  if (tile_visible_mapcanvas(x, y)) {
-    update_map_canvas(x, y, 1, 1, write_to_screen);
-  }
-  overview_update_tile(x, y);
-}
-
 
 /**************************************************************************
 Finds the pixel coordinates of a tile.
diff -Naur freeciv-cvs-pristine/client/gui-stub/mapview.c 
freeciv1/client/gui-stub/mapview.c
--- freeciv-cvs-pristine/client/gui-stub/mapview.c      Sat Feb 10 15:43:39 2001
+++ freeciv1/client/gui-stub/mapview.c  Mon Oct 22 01:51:00 2001
@@ -153,12 +153,6 @@
        /* PORTME */
 }
 
-void
-refresh_tile_mapcanvas(int x, int y, int write_to_screen)
-{
-       /* PORTME */
-}
-
 void draw_segment(int src_x, int src_y, int dir)
 {
        /* PORTME */
diff -Naur freeciv-cvs-pristine/client/gui-win32/mapview.c 
freeciv1/client/gui-win32/mapview.c
--- freeciv-cvs-pristine/client/gui-win32/mapview.c     Tue Oct 16 05:11:17 2001
+++ freeciv1/client/gui-win32/mapview.c Mon Oct 22 01:51:01 2001
@@ -1208,21 +1208,6 @@
 }
 
 /**************************************************************************
-This function is now identical in all GUI's except BeOS.
-**************************************************************************/
-void refresh_tile_mapcanvas(int x, int y, int write_to_screen)
-{
-  int is_real = normalize_map_pos(&x, &y);
-
-  assert(is_real);
-  
-  if(tile_visible_mapcanvas(x, y)) {
-    update_map_canvas(x,y, 1, 1, write_to_screen);
-  }
-  overview_update_tile(x, y);   
-}
-
-/**************************************************************************
 
 **************************************************************************/
 void map_handle_hscroll(int pos)
diff -Naur freeciv-cvs-pristine/client/gui-win32/mapview.h 
freeciv1/client/gui-win32/mapview.h
--- freeciv-cvs-pristine/client/gui-win32/mapview.h     Tue Sep  4 15:09:37 2001
+++ freeciv1/client/gui-win32/mapview.h Mon Oct 22 01:51:01 2001
@@ -14,6 +14,7 @@
 #define FC__MAPVIEW_H
 
 #include "mapview_g.h"
+
 void pixmap_put_tile(HDC hdc, int x, int y, int abs_x0, int abs_y0,
                      int citymode);
 void put_city_tile_output(HDC hdc, int x, int y,
diff -Naur freeciv-cvs-pristine/client/gui-xaw/mapview.c 
freeciv1/client/gui-xaw/mapview.c
--- freeciv-cvs-pristine/client/gui-xaw/mapview.c       Tue Oct 16 05:11:18 2001
+++ freeciv1/client/gui-xaw/mapview.c   Mon Oct 22 01:51:01 2001
@@ -388,21 +388,6 @@
 }
 
 /**************************************************************************
-This function is now identical in all GUI's except BeOS.
-**************************************************************************/
-void refresh_tile_mapcanvas(int x, int y, int write_to_screen)
-{
-  int is_real = normalize_map_pos(&x, &y);
-
-  assert(is_real);
-
-  if (tile_visible_mapcanvas(x, y)) {
-    update_map_canvas(x, y, 1, 1, write_to_screen);
-  }
-  overview_update_tile(x, y);
-}
-
-/**************************************************************************
 ...
 **************************************************************************/
 int tile_visible_mapcanvas(int x, int y)
diff -Naur freeciv-cvs-pristine/client/include/mapview_g.h 
freeciv1/client/include/mapview_g.h
--- freeciv-cvs-pristine/client/include/mapview_g.h     Sun Feb  4 08:45:21 2001
+++ freeciv1/client/include/mapview_g.h Mon Oct 22 01:51:01 2001
@@ -13,6 +13,8 @@
 #ifndef FC__MAPVIEW_G_H
 #define FC__MAPVIEW_G_H
 
+#include "mapview_common.h" /* should this go here? */
+
 struct unit;
 struct city;
 
@@ -47,7 +49,6 @@
 
 void refresh_overview_canvas(void);
 void refresh_overview_viewrect(void);
-void refresh_tile_mapcanvas(int x, int y, int write_to_screen);
 
 void draw_segment(int src_x, int src_y, int dir);
 void undraw_segment(int src_x, int src_y, int dir);
diff -Naur freeciv-cvs-pristine/mapview_common.c freeciv1/mapview_common.c
--- freeciv-cvs-pristine/mapview_common.c       Wed Dec 31 19:00:00 1969
+++ freeciv1/mapview_common.c   Mon Oct 22 01:51:09 2001
@@ -0,0 +1,37 @@
+/**********************************************************************
+ Freeciv - Copyright (C) 1996 - A Kjeldberg, L Gregersen, P Unold
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2, or (at your option)
+   any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+***********************************************************************/
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <assert.h>
+
+#include "mapview_g.h"
+
+#include "map.h"
+
+/**************************************************************************
+ Refreshes a single tile on the map canvas.
+**************************************************************************/
+void refresh_tile_mapcanvas(int x, int y, int write_to_screen)
+{
+  assert(is_real_tile(x, y));
+  if (!normalize_map_pos(&x, &y))
+    return;
+
+  if (tile_visible_mapcanvas(x, y)) {
+    update_map_canvas(x,y, 1, 1, write_to_screen);
+  }
+  overview_update_tile(x, y);
+}
diff -Naur freeciv-cvs-pristine/mapview_common.h freeciv1/mapview_common.h
--- freeciv-cvs-pristine/mapview_common.h       Wed Dec 31 19:00:00 1969
+++ freeciv1/mapview_common.h   Mon Oct 22 01:51:09 2001
@@ -0,0 +1,20 @@
+/**********************************************************************
+ Freeciv - Copyright (C) 1996 - A Kjeldberg, L Gregersen, P Unold
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2, or (at your option)
+   any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+***********************************************************************/
+
+#ifndef FC__MAPVIEW_COMMON_H
+#define FC__MAPVIEW_COMMON_H
+
+/* This should be moved into client/mapview.c. */
+void refresh_tile_mapcanvas(int x, int y, int write_to_screen);
+
+#endif /* FC__MAPVIEW_COMMON_H */

[Prev in Thread] Current Thread [Next in Thread]