[Freeciv-Dev] (PR#7447) decrease_unit_hp_smooth should be in mapview_com
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: |
undisclosed-recipients: ; |
Subject: |
[Freeciv-Dev] (PR#7447) decrease_unit_hp_smooth should be in mapview_common |
From: |
"Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx> |
Date: |
Fri, 5 Mar 2004 23:57:21 -0800 |
Reply-to: |
rt@xxxxxxxxxxx |
<URL: http://rt.freeciv.org/Ticket/Display.html?id=7447 >
Here's a patch to move decrease_unit_hp_smooth into mapview_common.
- Single_tile_pixmap is moved into the mapview_canvas structure. This
means it's allocated from common code. This is a little tricky since we
can't do this until after ui_main is entered. The easiest way is just
to allocate it at the same time as the mapview.
- Animate the unit's dropping HP correctly. The logic is simple.
- Use the same algorithm for drawing explode sprites for iso and non-iso
view. This uses the single_tile as a secondary backing store while
drawing the animation directly to the backing store. We don't assume
anything about the sprite dimensions but just center it on the tile.
Tested under gui-gtk. Also compiled under gui-gtk-2.0, gui-xaw, and
gui-win32.
jason
Index: client/mapview_common.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/mapview_common.c,v
retrieving revision 1.85
diff -u -r1.85 mapview_common.c
--- client/mapview_common.c 5 Mar 2004 18:16:01 -0000 1.85
+++ client/mapview_common.c 6 Mar 2004 07:55:21 -0000
@@ -19,6 +19,7 @@
#include "log.h"
#include "map.h"
+#include "rand.h"
#include "support.h"
#include "timing.h"
@@ -1427,6 +1428,76 @@
}
}
+/****************************************************************************
+ This function is called to decrease a unit's HP smoothly in battle
+ when combat_animation is turned on.
+****************************************************************************/
+void decrease_unit_hp_smooth(struct unit *punit0, int hp0,
+ struct unit *punit1, int hp1)
+{
+ static struct timer *anim_timer = NULL;
+ struct unit *losing_unit = (hp0 == 0 ? punit0 : punit1);
+ int canvas_x, canvas_y, i;
+
+ set_units_in_combat(punit0, punit1);
+
+ while (punit0->hp > hp0 || punit1->hp > hp1) {
+ const int diff0 = punit0->hp - hp0, diff1 = punit1->hp - hp1;
+
+ anim_timer = renew_timer_start(anim_timer, TIMER_USER, TIMER_ACTIVE);
+
+ if (myrand(diff0 + diff1) < diff0) {
+ punit0->hp--;
+ refresh_tile_mapcanvas(punit0->x, punit0->y, FALSE);
+ } else {
+ punit1->hp--;
+ refresh_tile_mapcanvas(punit1->x, punit1->y, FALSE);
+ }
+
+ flush_dirty();
+ gui_flush();
+
+ usleep_since_timer_start(anim_timer, 10000);
+ }
+
+ if (num_tiles_explode_unit > 0
+ && map_to_canvas_pos(&canvas_x, &canvas_y,
+ losing_unit->x, losing_unit->y)) {
+ refresh_tile_mapcanvas(losing_unit->x, losing_unit->y, FALSE);
+ gui_copy_canvas(mapview_canvas.single_tile, mapview_canvas.store,
+ canvas_x, canvas_y, 0, 0,
+ NORMAL_TILE_WIDTH, NORMAL_TILE_HEIGHT);
+
+ for (i = 0; i < num_tiles_explode_unit; i++) {
+ int w, h;
+
+ get_sprite_dimensions(sprites.explode.unit[i], &w, &h);
+ anim_timer = renew_timer_start(anim_timer, TIMER_USER, TIMER_ACTIVE);
+
+ /* We first draw the explosion onto the unit and draw draw the
+ * complete thing onto the map canvas window. This avoids
+ * flickering. */
+ gui_copy_canvas(mapview_canvas.store, mapview_canvas.single_tile,
+ 0, 0, canvas_x, canvas_y,
+ NORMAL_TILE_WIDTH, NORMAL_TILE_HEIGHT);
+ gui_put_sprite_full(mapview_canvas.store,
+ canvas_x + NORMAL_TILE_WIDTH / 2 - w / 2,
+ canvas_y + NORMAL_TILE_HEIGHT / 2 - h / 2,
+ sprites.explode.unit[i]);
+ dirty_rect(canvas_x, canvas_y, NORMAL_TILE_WIDTH, NORMAL_TILE_HEIGHT);
+
+ flush_dirty();
+ gui_flush();
+
+ usleep_since_timer_start(anim_timer, 20000);
+ }
+ }
+
+ set_units_in_combat(NULL, NULL);
+ refresh_tile_mapcanvas(punit0->x, punit0->y, FALSE);
+ refresh_tile_mapcanvas(punit1->x, punit1->y, FALSE);
+}
+
/**************************************************************************
Animates punit's "smooth" move from (x0, y0) to (x0+dx, y0+dy).
Note: Works only for adjacent-tile moves.
@@ -2001,6 +2072,8 @@
mapview_canvas.width = 0;
mapview_canvas.height = 0;
mapview_canvas.store = canvas_store_create(1, 1);
+ mapview_canvas.single_tile
+ = canvas_store_create(UNIT_TILE_WIDTH, UNIT_TILE_HEIGHT);
overview.map_x0 = 0;
overview.map_y0 = 0;
Index: client/mapview_common.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/mapview_common.h,v
retrieving revision 1.48
diff -u -r1.48 mapview_common.h
--- client/mapview_common.h 27 Feb 2004 16:30:31 -0000 1.48
+++ client/mapview_common.h 6 Mar 2004 07:55:21 -0000
@@ -26,7 +26,7 @@
int map_x0, map_y0;
int width, height; /* Size in pixels. */
int tile_width, tile_height; /* Size in tiles. Rounded up. */
- struct canvas_store *store;
+ struct canvas_store *store, *single_tile;
};
/* Holds all information about the overview aka minimap. */
@@ -190,6 +190,8 @@
void undraw_segment(int src_x, int src_y, int dir);
+void decrease_unit_hp_smooth(struct unit *punit0, int hp0,
+ struct unit *punit1, int hp1);
void move_unit_map_canvas(struct unit *punit,
int map_x, int map_y, int dx, int dy);
Index: client/tilespec.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/tilespec.c,v
retrieving revision 1.146
diff -u -r1.146 tilespec.c
--- client/tilespec.c 27 Feb 2004 18:31:39 -0000 1.146
+++ client/tilespec.c 6 Mar 2004 07:55:21 -0000
@@ -389,6 +389,9 @@
*
* Do any necessary redraws.
*/
+ canvas_store_free(mapview_canvas.single_tile);
+ mapview_canvas.single_tile
+ = canvas_store_create(UNIT_TILE_WIDTH, UNIT_TILE_HEIGHT);
if (state < CLIENT_GAME_RUNNING_STATE) {
/* Unless the client state is playing a game or in gameover,
we don't want/need to redraw. */
Index: client/gui-gtk/gui_main.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk/gui_main.c,v
retrieving revision 1.146
diff -u -r1.146 gui_main.c
--- client/gui-gtk/gui_main.c 26 Feb 2004 13:38:45 -0000 1.146
+++ client/gui-gtk/gui_main.c 6 Mar 2004 07:55:22 -0000
@@ -74,9 +74,6 @@
GtkWidget *overview_canvas; /* GtkDrawingArea */
-GdkPixmap *single_tile_pixmap; /* this pixmap is used when
- * moving units etc */
-
GtkWidget *toplevel;
GtkWidget *top_vbox;
GdkWindow *root_window;
@@ -947,8 +944,6 @@
init_mapcanvas_and_overview();
- single_tile_pixmap = gdk_pixmap_new(root_window,
- UNIT_TILE_WIDTH, UNIT_TILE_HEIGHT, -1);
set_client_state(CLIENT_PRE_GAME_STATE);
Index: client/gui-gtk/gui_main.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk/gui_main.h,v
retrieving revision 1.14
diff -u -r1.14 gui_main.h
--- client/gui-gtk/gui_main.h 18 Feb 2004 02:20:51 -0000 1.14
+++ client/gui-gtk/gui_main.h 6 Mar 2004 07:55:22 -0000
@@ -38,7 +38,7 @@
extern GdkPixmap * gray25;
extern GdkPixmap * black50;
extern GdkPixmap * mask_bitmap;
-extern GdkPixmap * single_tile_pixmap;
+#define single_tile_pixmap (mapview_canvas.single_tile->pixmap)
extern GtkText * main_message_area;
extern GtkWidget * text_scrollbar;
extern GtkWidget * toplevel;
Index: client/gui-gtk/mapview.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk/mapview.c,v
retrieving revision 1.201
diff -u -r1.201 mapview.c
--- client/gui-gtk/mapview.c 5 Mar 2004 18:16:01 -0000 1.201
+++ client/gui-gtk/mapview.c 6 Mar 2004 07:55:22 -0000
@@ -84,80 +84,6 @@
/**************************************************************************
- This function is called to decrease a unit's HP smoothly in battle
- when combat_animation is turned on.
-**************************************************************************/
-void decrease_unit_hp_smooth(struct unit *punit0, int hp0,
- struct unit *punit1, int hp1)
-{
- static struct timer *anim_timer = NULL;
- struct unit *losing_unit = (hp0 == 0 ? punit0 : punit1);
- int canvas_x, canvas_y, i;
-
- set_units_in_combat(punit0, punit1);
-
- do {
- anim_timer = renew_timer_start(anim_timer, TIMER_USER, TIMER_ACTIVE);
-
- if (punit0->hp > hp0
- && myrand((punit0->hp - hp0) + (punit1->hp - hp1)) < punit0->hp - hp0)
- punit0->hp--;
- else if (punit1->hp > hp1)
- punit1->hp--;
- else
- punit0->hp--;
-
- refresh_tile_mapcanvas(punit0->x, punit0->y, TRUE);
- refresh_tile_mapcanvas(punit1->x, punit1->y, TRUE);
-
- gdk_flush();
- usleep_since_timer_start(anim_timer, 10000);
-
- } while (punit0->hp > hp0 || punit1->hp > hp1);
-
- if (map_to_canvas_pos(&canvas_x, &canvas_y,
- losing_unit->x, losing_unit->y)) {
- for (i = 0; i < num_tiles_explode_unit; i++) {
- 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
- * complete thing onto the map canvas window. This avoids
- * flickering. */
- gdk_draw_pixmap(single_tile_pixmap, civ_gc, map_canvas_store,
- canvas_x, canvas_y, 0, 0,
- NORMAL_TILE_WIDTH, NORMAL_TILE_HEIGHT);
- pixmap_put_overlay_tile(single_tile_pixmap,
- NORMAL_TILE_WIDTH / 4, 0,
- sprites.explode.unit[i]);
- gdk_draw_pixmap(map_canvas->window, civ_gc, single_tile_pixmap,
- 0, 0, canvas_x, canvas_y,
- NORMAL_TILE_WIDTH, NORMAL_TILE_HEIGHT);
- } else {
- /* Not isometric. */
- /* FIXME: maybe do as described in the above comment. */
- struct canvas_store store = {single_tile_pixmap};
-
- put_one_tile(&store, losing_unit->x, losing_unit->y,
- 0, 0, FALSE);
- put_unit_full(losing_unit, &store, 0, 0);
- pixmap_put_overlay_tile(single_tile_pixmap, 0, 0,
- sprites.explode.unit[i]);
-
- gdk_draw_pixmap(map_canvas->window, civ_gc, single_tile_pixmap,
- 0, 0, canvas_x, canvas_y,
- UNIT_TILE_WIDTH, UNIT_TILE_HEIGHT);
- }
- gdk_flush();
- usleep_since_timer_start(anim_timer, 20000);
- }
- }
-
- set_units_in_combat(NULL, NULL);
- refresh_tile_mapcanvas(punit0->x, punit0->y, TRUE);
- refresh_tile_mapcanvas(punit1->x, punit1->y, TRUE);
-}
-
-/**************************************************************************
If do_restore is FALSE it will invert the turn done button style. If
called regularly from a timer this will give a blinking turn done
button. If do_restore is TRUE this will reset the turn done button
@@ -1523,9 +1449,4 @@
{
reset_city_dialogs();
reset_unit_table();
-
- /* single_tile is originally allocated in gui_main.c. */
- gdk_pixmap_unref(single_tile_pixmap);
- single_tile_pixmap = gdk_pixmap_new(root_window,
- UNIT_TILE_WIDTH, UNIT_TILE_HEIGHT, -1);
}
Index: client/gui-gtk-2.0/gui_main.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk-2.0/gui_main.c,v
retrieving revision 1.67
diff -u -r1.67 gui_main.c
--- client/gui-gtk-2.0/gui_main.c 26 Feb 2004 13:38:45 -0000 1.67
+++ client/gui-gtk-2.0/gui_main.c 6 Mar 2004 07:55:22 -0000
@@ -80,9 +80,6 @@
int overview_canvas_store_width = 2 * 80;
int overview_canvas_store_height = 2 * 50;
-GdkPixmap *single_tile_pixmap; /* this pixmap is used when
- * moving units etc */
-
GtkWidget *toplevel;
GtkWidget *top_vbox;
GdkWindow *root_window;
@@ -1193,9 +1190,6 @@
timer_id = gtk_timeout_add(TIMER_INTERVAL, timer_callback, NULL);
init_mapcanvas_and_overview();
-
- single_tile_pixmap = gdk_pixmap_new(root_window,
- UNIT_TILE_WIDTH, UNIT_TILE_HEIGHT, -1);
set_client_state(CLIENT_PRE_GAME_STATE);
Index: client/gui-gtk-2.0/gui_main.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk-2.0/gui_main.h,v
retrieving revision 1.10
diff -u -r1.10 gui_main.h
--- client/gui-gtk-2.0/gui_main.h 18 Feb 2004 02:20:51 -0000 1.10
+++ client/gui-gtk-2.0/gui_main.h 6 Mar 2004 07:55:22 -0000
@@ -42,7 +42,7 @@
extern GdkPixmap * gray25;
extern GdkPixmap * black50;
extern GdkPixmap * mask_bitmap;
-extern GdkPixmap * single_tile_pixmap;
+#define single_tile_pixmap (mapview_canvas.single_tile->pixmap)
extern GtkTextView * main_message_area;
extern GtkWidget * text_scrollbar;
extern GtkWidget * toplevel;
Index: client/gui-gtk-2.0/mapview.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk-2.0/mapview.c,v
retrieving revision 1.101
diff -u -r1.101 mapview.c
--- client/gui-gtk-2.0/mapview.c 5 Mar 2004 18:16:01 -0000 1.101
+++ client/gui-gtk-2.0/mapview.c 6 Mar 2004 07:55:22 -0000
@@ -85,80 +85,6 @@
/**************************************************************************
- This function is called to decrease a unit's HP smoothly in battle
- when combat_animation is turned on.
-**************************************************************************/
-void decrease_unit_hp_smooth(struct unit *punit0, int hp0,
- struct unit *punit1, int hp1)
-{
- static struct timer *anim_timer = NULL;
- struct unit *losing_unit = (hp0 == 0 ? punit0 : punit1);
- int canvas_x, canvas_y, i;
-
- set_units_in_combat(punit0, punit1);
-
- do {
- anim_timer = renew_timer_start(anim_timer, TIMER_USER, TIMER_ACTIVE);
-
- if (punit0->hp > hp0
- && myrand((punit0->hp - hp0) + (punit1->hp - hp1)) < punit0->hp - hp0)
- punit0->hp--;
- else if (punit1->hp > hp1)
- punit1->hp--;
- else
- punit0->hp--;
-
- refresh_tile_mapcanvas(punit0->x, punit0->y, TRUE);
- refresh_tile_mapcanvas(punit1->x, punit1->y, TRUE);
-
- gdk_flush();
- usleep_since_timer_start(anim_timer, 10000);
-
- } while (punit0->hp > hp0 || punit1->hp > hp1);
-
- if (map_to_canvas_pos(&canvas_x, &canvas_y,
- losing_unit->x, losing_unit->y)) {
- for (i = 0; i < num_tiles_explode_unit; i++) {
- 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
- * complete thing onto the map canvas window. This avoids
- * flickering. */
- gdk_draw_drawable(single_tile_pixmap, civ_gc, map_canvas_store,
- canvas_x, canvas_y, 0, 0,
- NORMAL_TILE_WIDTH, NORMAL_TILE_HEIGHT);
- pixmap_put_overlay_tile(single_tile_pixmap,
- NORMAL_TILE_WIDTH / 4, 0,
- sprites.explode.unit[i]);
- gdk_draw_drawable(map_canvas->window, civ_gc, single_tile_pixmap,
- 0, 0, canvas_x, canvas_y,
- NORMAL_TILE_WIDTH, NORMAL_TILE_HEIGHT);
- } else {
- /* Not isometric. */
- /* FIXME: maybe do as described in the above comment. */
- struct canvas_store store = {single_tile_pixmap};
-
- put_one_tile(&store, losing_unit->x, losing_unit->y,
- 0, 0, FALSE);
- put_unit_full(losing_unit, &store, 0, 0);
- pixmap_put_overlay_tile(single_tile_pixmap, 0, 0,
- sprites.explode.unit[i]);
-
- gdk_draw_drawable(map_canvas->window, civ_gc, single_tile_pixmap,
- 0, 0, canvas_x, canvas_y,
- UNIT_TILE_WIDTH, UNIT_TILE_HEIGHT);
- }
- gdk_flush();
- usleep_since_timer_start(anim_timer, 20000);
- }
- }
-
- set_units_in_combat(NULL, NULL);
- refresh_tile_mapcanvas(punit0->x, punit0->y, TRUE);
- refresh_tile_mapcanvas(punit1->x, punit1->y, TRUE);
-}
-
-/**************************************************************************
If do_restore is FALSE it will invert the turn done button style. If
called regularly from a timer this will give a blinking turn done
button. If do_restore is TRUE this will reset the turn done button
@@ -1604,9 +1530,4 @@
{
reset_city_dialogs();
reset_unit_table();
-
- /* single_tile is originally allocated in gui_main.c. */
- g_object_unref(single_tile_pixmap);
- single_tile_pixmap = gdk_pixmap_new(root_window,
- UNIT_TILE_WIDTH, UNIT_TILE_HEIGHT, -1);
}
Index: client/gui-win32/mapview.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-win32/mapview.c,v
retrieving revision 1.98
diff -u -r1.98 mapview.c
--- client/gui-win32/mapview.c 5 Mar 2004 18:16:01 -0000 1.98
+++ client/gui-win32/mapview.c 6 Mar 2004 07:55:23 -0000
@@ -56,7 +56,7 @@
static HBITMAP intro_gfx;
-static HBITMAP single_tile_pixmap;
+#define single_tile_pixmap (mapview_canvas.single_tile->bitmap)
extern HBITMAP BITMAP2HBITMAP(BITMAP *bmp);
@@ -203,9 +203,6 @@
HDC hdc;
hdc=GetDC(root_window);
overviewstoredc=CreateCompatibleDC(hdc);
- single_tile_pixmap=CreateCompatibleBitmap(hdc,
- UNIT_TILE_WIDTH,
- UNIT_TILE_HEIGHT);
ReleaseDC(root_window,hdc);
mapstorebitmap=NULL;
overviewstorebitmap=NULL;
@@ -723,85 +720,6 @@
SelectObject(mapstoredc, old);
DeleteDC(mapstoredc);
}
-}
-
-/**************************************************************************
- This function is called to decrease a unit's HP smoothly in battle
- when combat_animation is turned on.
-**************************************************************************/
-void
-decrease_unit_hp_smooth(struct unit *punit0, int hp0,
- struct unit *punit1, int hp1)
-{
- HDC mapstoredc;
- HDC hdc,hdcwin;
- HBITMAP oldbmp,old_mapbmp;
- static struct timer *anim_timer = NULL;
- struct unit *losing_unit = (hp0 == 0 ? punit0 : punit1);
- int i;
-
- set_units_in_combat(punit0, punit1);
-
- do {
- anim_timer = renew_timer_start(anim_timer, TIMER_USER, TIMER_ACTIVE);
-
- if (punit0->hp > hp0
- && myrand((punit0->hp - hp0) + (punit1->hp - hp1)) < punit0->hp - hp0)
- punit0->hp--;
- else if (punit1->hp > hp1)
- punit1->hp--;
- else
- punit0->hp--;
-
- refresh_tile_mapcanvas(punit0->x, punit0->y, TRUE);
- refresh_tile_mapcanvas(punit1->x, punit1->y, TRUE);
- GdiFlush();
-
- usleep_since_timer_start(anim_timer, 10000);
-
- } while (punit0->hp > hp0 || punit1->hp > hp1);
-
- mapstoredc=CreateCompatibleDC(NULL);
- old_mapbmp=SelectObject(mapstoredc,mapstorebitmap);
- hdc=CreateCompatibleDC(NULL);
- hdcwin=GetDC(map_window);
- oldbmp=SelectObject(hdc,single_tile_pixmap);
- 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
- complete thing onto the map canvas window. This avoids flickering. */
- BitBlt(hdc,0,0,NORMAL_TILE_WIDTH,NORMAL_TILE_HEIGHT,
- mapstoredc,canvas_x,canvas_y,SRCCOPY);
- draw_sprite(sprites.explode.unit[i],hdc,NORMAL_TILE_WIDTH/4,0);
- BitBlt(hdcwin,canvas_x,canvas_y,
- NORMAL_TILE_WIDTH,NORMAL_TILE_HEIGHT,
- hdc,0,0,SRCCOPY);
- } else {
- struct canvas_store store = {NULL, single_tile_pixmap};
-
- put_one_tile(&store, losing_unit->x, losing_unit->y, 0, 0, FALSE);
- put_unit_full(losing_unit, &store, 0, 0);
- draw_sprite(sprites.explode.unit[i],hdc,NORMAL_TILE_WIDTH/4,0);
- BitBlt(hdcwin,canvas_x,canvas_y,
- NORMAL_TILE_WIDTH,NORMAL_TILE_HEIGHT,
- hdc,0,0,SRCCOPY);
- }
- GdiFlush();
- usleep_since_timer_start(anim_timer, 20000);
- }
-
- SelectObject(hdc,oldbmp);
- DeleteDC(hdc);
- ReleaseDC(map_window,hdcwin);
- SelectObject(mapstoredc,old_mapbmp);
- DeleteDC(mapstoredc);
- set_units_in_combat(NULL, NULL);
- refresh_tile_mapcanvas(punit0->x, punit0->y, TRUE);
- refresh_tile_mapcanvas(punit1->x, punit1->y, TRUE);
-
}
/**************************************************************************
Index: client/gui-xaw/gui_main.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-xaw/gui_main.c,v
retrieving revision 1.88
diff -u -r1.88 gui_main.c
--- client/gui-xaw/gui_main.c 26 Feb 2004 13:38:45 -0000 1.88
+++ client/gui-xaw/gui_main.c 6 Mar 2004 07:55:23 -0000
@@ -198,9 +198,6 @@
Widget more_arrow_label;
Window root_window;
-/* this pixmap is used when moving units etc */
-Pixmap single_tile_pixmap;
-
XtInputId x_input_id;
XtIntervalId x_interval_id;
Atom wm_delete_window;
@@ -444,11 +441,6 @@
timer_callback, NULL);
init_mapcanvas_and_overview();
-
- single_tile_pixmap=XCreatePixmap(display, XtWindow(overview_canvas),
- UNIT_TILE_WIDTH,
- UNIT_TILE_HEIGHT,
- display_depth);
for(i=0; i<num_units_below; i++)
unit_below_pixmap[i]=XCreatePixmap(display, XtWindow(overview_canvas),
Index: client/gui-xaw/gui_main.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-xaw/gui_main.h,v
retrieving revision 1.13
diff -u -r1.13 gui_main.h
--- client/gui-xaw/gui_main.h 18 Feb 2004 02:20:51 -0000 1.13
+++ client/gui-xaw/gui_main.h 6 Mar 2004 07:55:23 -0000
@@ -32,7 +32,7 @@
extern GC prod_font_gc;
extern Pixmap gray50;
extern Pixmap gray25;
-extern Pixmap single_tile_pixmap;
+#define single_tile_pixmap (mapview_canvas.single_tile->pixmap)
extern Widget map_vertical_scrollbar;
extern Widget map_horizontal_scrollbar;
extern Widget left_column_form;
Index: client/gui-xaw/mapview.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-xaw/mapview.c,v
retrieving revision 1.164
diff -u -r1.164 mapview.c
--- client/gui-xaw/mapview.c 5 Mar 2004 18:16:01 -0000 1.164
+++ client/gui-xaw/mapview.c 6 Mar 2004 07:55:23 -0000
@@ -65,66 +65,6 @@
/**************************************************************************
- This function is called to decrease a unit's HP smoothly in battle
- when combat_animation is turned on.
-**************************************************************************/
-void decrease_unit_hp_smooth(struct unit *punit0, int hp0,
- struct unit *punit1, int hp1)
-{
- static struct timer *anim_timer = NULL;
- struct unit *losing_unit = (hp0 == 0 ? punit0 : punit1);
- int i;
- int canvas_x, canvas_y;
-
- set_units_in_combat(punit0, punit1);
-
- do {
- anim_timer = renew_timer_start(anim_timer, TIMER_USER, TIMER_ACTIVE);
-
- if (punit0->hp > hp0
- && myrand((punit0->hp - hp0) + (punit1->hp - hp1)) < punit0->hp - hp0)
- punit0->hp--;
- else if (punit1->hp > hp1)
- punit1->hp--;
- else
- punit0->hp--;
-
- refresh_tile_mapcanvas(punit0->x, punit0->y, TRUE);
- refresh_tile_mapcanvas(punit1->x, punit1->y, TRUE);
-
- XSync(display, 0);
- usleep_since_timer_start(anim_timer, 10000);
-
- } while (punit0->hp > hp0 || punit1->hp > hp1);
-
- if (map_to_canvas_pos(&canvas_x, &canvas_y,
- losing_unit->x, losing_unit->y)) {
- for (i = 0; i < num_tiles_explode_unit; i++) {
- struct canvas_store store = {single_tile_pixmap};
-
- anim_timer = renew_timer_start(anim_timer, TIMER_USER, TIMER_ACTIVE);
-
- put_one_tile(&store, 0, 0, losing_unit->x, losing_unit->y, FALSE);
- put_unit_full(losing_unit, &store, 0, 0);
- pixmap_put_overlay_tile(single_tile_pixmap, 0, 0,
- sprites.explode.unit[i]);
-
- XCopyArea(display, single_tile_pixmap, XtWindow(map_canvas), civ_gc,
- 0, 0,
- UNIT_TILE_WIDTH, UNIT_TILE_HEIGHT,
- canvas_x, canvas_y);
-
- XSync(display, 0);
- usleep_since_timer_start(anim_timer, 20000);
- }
- }
-
- set_units_in_combat(NULL, NULL);
- refresh_tile_mapcanvas(punit0->x, punit0->y, TRUE);
- refresh_tile_mapcanvas(punit1->x, punit1->y, TRUE);
-}
-
-/**************************************************************************
...
**************************************************************************/
void map_size_changed(void)
Index: client/include/mapview_g.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/include/mapview_g.h,v
retrieving revision 1.46
diff -u -r1.46 mapview_g.h
--- client/include/mapview_g.h 5 Mar 2004 18:16:01 -0000 1.46
+++ client/include/mapview_g.h 6 Mar 2004 07:55:23 -0000
@@ -78,8 +78,6 @@
bool first_frame, bool last_frame,
int old_canvas_x, int old_canvas_y,
int new_canvas_x, int new_canvas_y);
-void decrease_unit_hp_smooth(struct unit *punit0, int hp0,
- struct unit *punit1, int hp1);
void draw_segment(int src_x, int src_y, int dir);
void draw_selection_rectangle(int canvas_x, int canvas_y, int w, int h);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Freeciv-Dev] (PR#7447) decrease_unit_hp_smooth should be in mapview_common,
Jason Short <=
|
|