wesnoth-cvs-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Wesnoth-cvs-commits] wesnoth/src unit_display.cpp


From: Guillaume Melquiond
Subject: [Wesnoth-cvs-commits] wesnoth/src unit_display.cpp
Date: Sat, 04 Dec 2004 09:31:56 -0500

CVSROOT:        /cvsroot/wesnoth
Module name:    wesnoth
Branch:         
Changes by:     Guillaume Melquiond <address@hidden>    04/12/04 14:25:12

Modified files:
        src            : unit_display.cpp 

Log message:
        Partially fix teleportation (#10588, #11213). There are still some 
graphical glitches, but they may be not related to this part of the code.

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/unit_display.cpp.diff?tr1=1.40&tr2=1.41&r1=text&r2=text

Patches:
Index: wesnoth/src/unit_display.cpp
diff -u wesnoth/src/unit_display.cpp:1.40 wesnoth/src/unit_display.cpp:1.41
--- wesnoth/src/unit_display.cpp:1.40   Tue Nov 30 21:14:13 2004
+++ wesnoth/src/unit_display.cpp        Sat Dec  4 14:25:12 2004
@@ -85,7 +85,8 @@
        }
        
        const unit_animation *teleport_animation_p = 
u.type().teleport_animation();
-       if (teleport_animation_p && !tiles_adjacent(a, b) && !disp.fogged(a.x, 
a.y)) { // teleport
+       bool teleport_unit = teleport_animation_p && !tiles_adjacent(a, b);
+       if (teleport_unit && !disp.fogged(a.x, a.y)) { // teleport
                unit_animation teleport_animation =  *teleport_animation_p;
                int animation_time;
                const int begin_at = 
teleport_animation.get_first_frame_time(unit_animation::UNIT_FRAME);
@@ -146,27 +147,24 @@
 
                //invalidate the source tile and all adjacent tiles,
                //since the unit can partially overlap adjacent tiles
-               /* FIXME: This code is wrong for short-range teleportation 
since the teleported unit is not
-                * near its source location; consequently the unit leaves a 
ghost trace behind it. It does
-                * not happen for long-range teleportation since the scrolling 
has the nice side effect of
-                * cleaning up the display. -- silene */
-               disp.draw_tile(a.x,a.y);
-               for(int tile = 0; tile != 6; ++tile) {
+               disp.draw_tile(a.x, a.y);
+               for(int tile = 0; tile != 6; ++tile)
                        disp.draw_tile(src_adjacent[tile].x, 
src_adjacent[tile].y);
-               }
-
-               const int height_adjust = src_height_adjust + 
(dst_height_adjust - src_height_adjust) * i / nsteps;
-               const double submerge = src_submerge + (dst_submerge - 
src_submerge) * i / nsteps;
-
-               const int xpos = xloc;
-               const int ypos = yloc - height_adjust;
-
                // disp.invalidate_animations();
                disp.draw(false);
-               disp.draw_unit(xpos, ypos, image, false, 1.0, 0, 0.0, submerge);
 
-               if(halo_effect != 0)
-                       halo::set_location(halo_effect, xpos+disp.hex_size()/2, 
ypos+disp.hex_size()/2);
+               if (!teleport_unit) {
+                       const int height_adjust = src_height_adjust + 
(dst_height_adjust - src_height_adjust) * i / nsteps;
+                       const double submerge = src_submerge + (dst_submerge - 
src_submerge) * i / nsteps;
+                       const int xpos = xloc;
+                       const int ypos = yloc - height_adjust;
+                       disp.draw_unit(xpos, ypos, image, false, 1.0, 0, 0.0, 
submerge);
+
+                       if (halo_effect != 0) {
+                               int d = disp.hex_size() / 2;
+                               halo::set_location(halo_effect, xpos + d, ypos 
+ d);
+                       }
+               }
 
                const int new_ticks = SDL_GetTicks();
                const int wait_time = time_between_frames - (new_ticks - ticks);
@@ -187,7 +185,7 @@
        gamemap::location dst_adjacent[6];
        get_adjacent_tiles(b, dst_adjacent);
 
-       if (teleport_animation_p && !tiles_adjacent(a, b) && !disp.fogged(b.x, 
b.y)) { // teleport
+       if (teleport_unit && !disp.fogged(b.x, b.y)) { // teleport
                unit_animation teleport_animation =  *teleport_animation_p;
                int animation_time;
                const int end_at = teleport_animation.get_last_frame_time();




reply via email to

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