[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Wesnoth-cvs-commits] wesnoth src/unit_types.cpp src/unit_display.cpp...
From: |
Guillaume Melquiond |
Subject: |
[Wesnoth-cvs-commits] wesnoth src/unit_types.cpp src/unit_display.cpp... |
Date: |
Sun, 26 Sep 2004 04:26:22 -0400 |
CVSROOT: /cvsroot/wesnoth
Module name: wesnoth
Branch:
Changes by: Guillaume Melquiond <address@hidden> 04/09/26 08:20:01
Modified files:
src : unit_types.cpp unit_display.cpp unit_types.hpp
data : scenario-test.cfg
Log message:
Added Boucman's patch on teleportation animation, after a few
corrections. This patch adds a teleport_anim WML tag. Also add the Silver Mage
to the test scenario so that it can be tested. And comment about a long
standing bug in move_unit_between so that it does not get forgotten again.
CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/unit_types.cpp.diff?tr1=1.66&tr2=1.67&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/unit_display.cpp.diff?tr1=1.37&tr2=1.38&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/unit_types.hpp.diff?tr1=1.52&tr2=1.53&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/data/scenario-test.cfg.diff?tr1=1.34&tr2=1.35&r1=text&r2=text
Patches:
Index: wesnoth/data/scenario-test.cfg
diff -u wesnoth/data/scenario-test.cfg:1.34 wesnoth/data/scenario-test.cfg:1.35
--- wesnoth/data/scenario-test.cfg:1.34 Mon Sep 13 19:42:32 2004
+++ wesnoth/data/scenario-test.cfg Sun Sep 26 08:20:01 2004
@@ -96,7 +96,7 @@
canrecruit=1
controller=human
hitpoints=80
- recruit=Assassin,Elvish Hero,Elvish Fighter,Elvish
Archer,Horseman,Mage,Elvish Shaman,Red
Mage,Spearman,Swordsman,Duelist,Fencer,Elvish Captain,Elvish Ranger,Elvish
Shyde,Thief,Rogue,Merman,Elvish Lord,White Mage,Mage of Light,Elvish
Sharpshooter,Merman Lord
+ recruit=Assassin,Elvish Hero,Elvish Fighter,Elvish
Archer,Horseman,Mage,Elvish Shaman,Red
Mage,Spearman,Swordsman,Duelist,Fencer,Elvish Captain,Elvish Ranger,Elvish
Shyde,Thief,Rogue,Merman,Elvish Lord,White Mage,Mage of Light,Elvish
Sharpshooter,Merman Lord,Silver Mage
gold=2000
enemy=2
[/side]
Index: wesnoth/src/unit_display.cpp
diff -u wesnoth/src/unit_display.cpp:1.37 wesnoth/src/unit_display.cpp:1.38
--- wesnoth/src/unit_display.cpp:1.37 Sun Sep 19 16:22:21 2004
+++ wesnoth/src/unit_display.cpp Sun Sep 26 08:20:00 2004
@@ -71,14 +71,45 @@
int skips = 0;
+ const int acceleration = disp.turbo() ? 5:1;
+
+ gamemap::location src_adjacent[6];
+ get_adjacent_tiles(a, src_adjacent);
+
const std::string& halo = u.type().image_halo();
util::scoped_resource<int,halo::remover> halo_effect(0);
if(halo.empty() == false && !disp.fogged(b.x,b.y)) {
halo_effect.assign(halo::add(0,0,halo));
}
-
- gamemap::location src_adjacent[6];
- get_adjacent_tiles(a, src_adjacent);
+
+ 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
+ unit_animation teleport_animation = *teleport_animation_p;
+ int animation_time;
+ const int begin_at =
teleport_animation.get_first_frame_time(unit_animation::UNIT_FRAME);
+ teleport_animation.start_animation(begin_at,
unit_animation::UNIT_FRAME, acceleration);
+ animation_time = teleport_animation.get_animation_time();
+ adjust_map_position(disp, xsrc, ysrc, disp.hex_size(),
disp.hex_size());
+ while(animation_time < 0) {
+ const std::string* unit_image =
&teleport_animation.get_current_frame(unit_animation::UNIT_FRAME).image;
+ if (unit_image->empty()) {
+ unit_image = &u.type().image();
+ }
+ surface image(image::get_image(*unit_image));
+ if (!face_left) {
+ image.assign(image::reverse_image(image));
+ }
+ 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);
+ }
+ disp.draw_unit(xsrc,ysrc,image,false, 1.0, 0, 0.0,
src_submerge);
+ disp.update_display();
+ events::pump();
+ teleport_animation.update_current_frames();
+ animation_time =
teleport_animation.get_animation_time();
+ }
+ }
for(int i = 0; i < nsteps; ++i) {
events::pump();
@@ -113,6 +144,10 @@
//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(src_adjacent[tile].x,
src_adjacent[tile].y);
@@ -146,6 +181,37 @@
++skips;
}
}
+
+ 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
+ unit_animation teleport_animation = *teleport_animation_p;
+ int animation_time;
+ const int end_at = teleport_animation.get_last_frame_time();
+ teleport_animation.start_animation(0,
unit_animation::UNIT_FRAME, acceleration);
+ animation_time = teleport_animation.get_animation_time();
+ adjust_map_position(disp, xdst, ydst, disp.hex_size(),
disp.hex_size());
+ while(animation_time < end_at) {
+ const std::string* unit_image =
&teleport_animation.get_current_frame(unit_animation::UNIT_FRAME).image;
+ if (unit_image->empty()) {
+ unit_image = &u.type().image();
+ }
+ surface image(image::get_image(*unit_image));
+ if (!face_left) {
+ image.assign(image::reverse_image(image));
+ }
+ disp.draw_tile(b.x,b.y);
+ for(int tile = 0; tile != 6; ++tile) {
+
disp.draw_tile(dst_adjacent[tile].x,dst_adjacent[tile].y);
+ }
+ disp.draw_unit(xdst, ydst, image, false, 1.0, 0, 0.0,
dst_submerge);
+ disp.update_display();
+ events::pump();
+ teleport_animation.update_current_frames();
+ animation_time =
teleport_animation.get_animation_time();
+ }
+ }
}
}
Index: wesnoth/src/unit_types.cpp
diff -u wesnoth/src/unit_types.cpp:1.66 wesnoth/src/unit_types.cpp:1.67
--- wesnoth/src/unit_types.cpp:1.66 Sat Sep 18 22:56:49 2004
+++ wesnoth/src/unit_types.cpp Sun Sep 26 08:20:00 2004
@@ -1,4 +1,4 @@
-/* $Id: unit_types.cpp,v 1.66 2004/09/18 22:56:49 silene Exp $ */
+/* $Id: unit_types.cpp,v 1.67 2004/09/26 08:20:00 silene Exp $ */
/*
Copyright (C) 2003 by David White <address@hidden>
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net
@@ -521,7 +521,8 @@
nightvision_(o.nightvision_), steadfast_(o.steadfast_),
can_advance_(o.can_advance_),
movementType_(o.movementType_), possibleTraits_(o.possibleTraits_),
- genders_(o.genders_), defensive_animations_(o.defensive_animations_)
+ genders_(o.genders_), defensive_animations_(o.defensive_animations_),
+ teleport_animations_(o.teleport_animations_)
{
gender_types_[0] = o.gender_types_[0] != NULL ? new
unit_type(*o.gender_types_[0]) : NULL;
gender_types_[1] = o.gender_types_[1] != NULL ? new
unit_type(*o.gender_types_[1]) : NULL;
@@ -620,6 +621,10 @@
for(config::child_list::const_iterator d = defends.begin(); d !=
defends.end(); ++d) {
defensive_animations_.push_back(defensive_animation(**d));
}
+ const config::child_list& teleports =
cfg_.get_children("teleport_anim");
+ for(config::child_list::const_iterator d = teleports.begin(); d !=
teleports.end(); ++d) {
+ teleport_animations_.push_back(unit_animation(**d));
+ }
}
unit_type::~unit_type()
@@ -1016,6 +1021,12 @@
return NULL;
}
+const unit_animation* unit_type::teleport_animation( ) const
+{
+ if (teleport_animations_.empty()) return NULL;
+ return &teleport_animations_[rand() % teleport_animations_.size()];
+}
+
game_data::game_data()
{}
Index: wesnoth/src/unit_types.hpp
diff -u wesnoth/src/unit_types.hpp:1.52 wesnoth/src/unit_types.hpp:1.53
--- wesnoth/src/unit_types.hpp:1.52 Sat Sep 18 21:42:13 2004
+++ wesnoth/src/unit_types.hpp Sun Sep 26 08:20:01 2004
@@ -1,4 +1,4 @@
-/* $Id: unit_types.hpp,v 1.52 2004/09/18 21:42:13 Sirp Exp $ */
+/* $Id: unit_types.hpp,v 1.53 2004/09/26 08:20:01 silene Exp $ */
/*
Copyright (C) 2003 by David White <address@hidden>
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net
@@ -240,6 +240,7 @@
const std::string& race() const;
const unit_animation* defend_animation(bool hits, attack_type::RANGE
range) const;
+ const unit_animation* teleport_animation() const;
private:
void operator=(const unit_type& o);
@@ -287,6 +288,8 @@
};
std::vector<defensive_animation> defensive_animations_;
+
+ std::vector<unit_animation> teleport_animations_;
};
struct game_data
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Wesnoth-cvs-commits] wesnoth src/unit_types.cpp src/unit_display.cpp...,
Guillaume Melquiond <=