Author: sapient
Date: Mon Aug 4 02:03:20 2008
New Revision: 28316
URL: http://svn.gna.org/viewcvs/wesnoth?rev=28316&view=rev
Log:
eliminate some redundant and incomplete tag listings
Modified:
trunk/src/game.cpp
trunk/src/unit.cpp
trunk/src/unit_animation.cpp
trunk/src/unit_animation.hpp
Modified: trunk/src/game.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/game.cpp?rev=28316&r1=28315&r2=28316&view=diff
==============================================================================
--- trunk/src/game.cpp (original)
+++ trunk/src/game.cpp Mon Aug 4 02:03:20 2008
@@ -212,7 +212,7 @@
bool jump_to_campaign_, jump_to_multiplayer_;
#ifdef USE_EDITOR2
bool jump_to_editor_;
-#endif
+#endif
};
game_controller::game_controller(int argc, char** argv)
@@ -333,7 +333,7 @@
#ifdef USE_EDITOR2
} else if(val == "-e" || val == "--editor") {
jump_to_editor_ = true;
-#endif
+#endif
} else if(val[0] == '-') {
std::cerr << "unknown option: " << val << std::endl;
throw config::error("unknown option");
@@ -391,7 +391,7 @@
return *disp_.get();
}
-bool game_controller::detect_video_settings()
+bool game_controller::detect_video_settings()
{
video_flags = preferences::fullscreen() ? FULL_SCREEN : 0;
resolution = preferences::resolution();
@@ -1130,7 +1130,7 @@
typedef std::vector<std::string> path_store;
// add all paths to try to list
path_store paths_to_try;
-
+
if (!preferences::get_mp_server_program_name().empty())
paths_to_try.push_back(preferences::get_mp_server_program_name());
@@ -1138,7 +1138,7 @@
paths_to_try.push_back(wesnothd_quess);
-
+
std::string needle = "wesnothd";
size_t found = wesnothd_quess.rfind(needle);
if (found != std::string::npos)
@@ -2045,7 +2045,7 @@
return 0;
}
}
-
+
// Not the most intuitive solution, but I wanted to leave current
semantics for now
return -1;
}
@@ -2053,11 +2053,11 @@
/**
* I would prefer to setup locale first so that early error
* messages can get localized, but we need the game_controller
- * initialized to have get_intl_dir() to work. Note: setlocale()
+ * initialized to have get_intl_dir() to work. Note: setlocale()
* does not take GUI language setting into account.
*/
static void init_locale() {
- #ifdef _WIN32
+ #ifdef _WIN32
std::setlocale(LC_ALL, "English");
#else
std::setlocale(LC_ALL, "C");
@@ -2276,6 +2276,9 @@
#endif
try {
+ //trigger any one-time static initializations
+ unit_animation::init_tag_names();
+
/**
* @todo We try to guess the name of the server from the name
of the
* binary started. This is very fragile it breaks in at least
the
Modified: trunk/src/unit.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/unit.cpp?rev=28316&r1=28315&r2=28316&view=diff
==============================================================================
--- trunk/src/unit.cpp (original)
+++ trunk/src/unit.cpp Mon Aug 4 02:03:20 2008
@@ -471,20 +471,9 @@
reset_modifications();
// Remove old animations
- cfg_.clear_children("animation");
- cfg_.clear_children("defend");
- cfg_.clear_children("teleport_anim");
- cfg_.clear_children("extra_anim");
- cfg_.clear_children("death");
- cfg_.clear_children("movement_anim");
- cfg_.clear_children("standing_anim");
- cfg_.clear_children("healing_anim");
- cfg_.clear_children("victory_anim");
- cfg_.clear_children("idle_anim");
- cfg_.clear_children("levelin_anim");
- cfg_.clear_children("levelout_anim");
- cfg_.clear_children("healed_anim");
- cfg_.clear_children("poison_anim");
+ foreach(const std::string& tag_name, unit_animation::all_tag_names) {
+ cfg_.clear_children(tag_name);
+ }
if(t->movement_type().get_parent()) {
cfg_.merge_with(t->movement_type().get_parent()->get_cfg());
@@ -1363,20 +1352,9 @@
// Attach animations for this unit to the in-core object
unit_animation::fill_initial_animations(animations_,cfg_);
// Remove animations from private cfg, they're not needed there now
- cfg_.clear_children("animation");
- cfg_.clear_children("defend");
- cfg_.clear_children("teleport_anim");
- cfg_.clear_children("extra_anim");
- cfg_.clear_children("death");
- cfg_.clear_children("movement_anim");
- cfg_.clear_children("standing_anim");
- cfg_.clear_children("healing_anim");
- cfg_.clear_children("victory_anim");
- cfg_.clear_children("idle_anim");
- cfg_.clear_children("levelin_anim");
- cfg_.clear_children("levelout_anim");
- cfg_.clear_children("healed_anim");
- cfg_.clear_children("poison_anim");
+ foreach(const std::string& tag_name, unit_animation::all_tag_names) {
+ cfg_.clear_children(tag_name);
+ }
if(cfg["hitpoints"] != "") {
hit_points_ = lexical_cast_default<int>(cfg["hitpoints"]);
@@ -3116,21 +3094,10 @@
unit_config["name"] = "";
unit_config["overlays"] = "";
// Non-critical tags to ignore.
- unit_config.clear_children("animation");
- unit_config.clear_children("attack_anim");
unit_config.clear_children("comment");
- unit_config.clear_children("defend");
- unit_config.clear_children("death");
- unit_config.clear_children("extra_anim");
- unit_config.clear_children("idle_anim");
- unit_config.clear_children("healed_anim");
- unit_config.clear_children("healing_anim");
- unit_config.clear_children("level_in");
- unit_config.clear_children("level_out");
- unit_config.clear_children("movement_anim");
- unit_config.clear_children("poison_anim");
- unit_config.clear_children("standing_anim");
- unit_config.clear_children("victory_anim");
+ foreach(const std::string& tag_name, unit_animation::all_tag_names) {
+ unit_config.clear_children(tag_name);
+ }
return unit_config.hash();
}
Modified: trunk/src/unit_animation.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/unit_animation.cpp?rev=28316&r1=28315&r2=28316&view=diff
==============================================================================
--- trunk/src/unit_animation.cpp (original)
+++ trunk/src/unit_animation.cpp Mon Aug 4 02:03:20 2008
@@ -33,6 +33,29 @@
#include <climits>
#include <cstdlib>
#include <iostream>
+
+//static initialization
+std::vector<std::string> unit_animation::all_tag_names;
+void unit_animation::init_tag_names() {
+ unit_animation::all_tag_names.clear();
+ unit_animation::all_tag_names.push_back("animation");
+ unit_animation::all_tag_names.push_back("attack_anim");
+ unit_animation::all_tag_names.push_back("death");
+ unit_animation::all_tag_names.push_back("defend");
+ unit_animation::all_tag_names.push_back("extra_anim");
+ unit_animation::all_tag_names.push_back("healed_anim");
+ unit_animation::all_tag_names.push_back("healing_anim");
+ unit_animation::all_tag_names.push_back("idle_anim");
+ unit_animation::all_tag_names.push_back("leading_anim");
+ unit_animation::all_tag_names.push_back("levelin_anim");
+ unit_animation::all_tag_names.push_back("levelout_anim");
+ unit_animation::all_tag_names.push_back("movement_anim");
+ unit_animation::all_tag_names.push_back("poison_anim");
+ unit_animation::all_tag_names.push_back("recruit_anim");
+ unit_animation::all_tag_names.push_back("standing_anim");
+ unit_animation::all_tag_names.push_back("teleport_anim");
+ unit_animation::all_tag_names.push_back("victory_anim");
+}
config unit_animation::prepare_animation(const config &cfg,const std::string
animation_tag)
{
@@ -103,7 +126,7 @@
secondary_unit_filter_(),
directions_(),
frequency_(0),
- base_score_(variation),
+ base_score_(variation),
event_(utils::split(event)),
value_(),
primary_attack_filter_(),
@@ -587,13 +610,13 @@
}
-void unit_animation::particule::override( int start_time,const std::string
highlight,const std::string blend_ratio ,Uint32 blend_color ,const std::string
offset)
+void unit_animation::particule::override( int start_time,const std::string
highlight,const std::string blend_ratio ,Uint32 blend_color ,const std::string
offset)
{
set_begin_time(start_time);
if(!highlight.empty()) parameters_.highlight(highlight);
if(!offset.empty()) parameters_.offset(offset);
if(!blend_ratio.empty()) parameters_.blend(blend_ratio,blend_color);
-
+
}
@@ -666,7 +689,7 @@
return true;
}
-void unit_animation::update_last_draw_time()
+void unit_animation::update_last_draw_time()
{
double acceleration = unit_anim_.accelerate ?
game_display::get_singleton()->turbo_speed() : 1.0;
unit_anim_.update_last_draw_time(acceleration);
@@ -785,7 +808,7 @@
}
void unit_animation::particule::start_animation(int start_time,
- const gamemap::location &src, const gamemap::location &dst,
+ const gamemap::location &src, const gamemap::location &dst,
bool cycles)
{
halo::remove(halo_id_);
@@ -841,7 +864,7 @@
if(!animated_unit) return;
game_display*disp = game_display::get_singleton();
if(animated_unit->get_animation() &&
-
!animated_unit->get_animation()->animation_finished_potential() &&
+
!animated_unit->get_animation()->animation_finished_potential() &&
animated_unit->get_animation()->matches(*disp,src,animated_unit,event,value,hit_type,attack,second_attack,swing_num)
>unit_animation::MATCH_FAIL) {
anim_elem tmp;
tmp.my_unit = animated_unit;
@@ -876,7 +899,7 @@
} else {
anim->my_unit->get_animation()->update_parameters(anim->src,anim->src.get_direction(anim->my_unit->facing()));
}
-
+
}
}
@@ -898,7 +921,7 @@
end_tick =
animated_units_[0].my_unit->get_animation()->time_to_tick(animation_time);
events::pump();
disp->delay(maximum<int>(0,
- minimum<int>(10,
+ minimum<int>(10,
static_cast<int>((animation_time -
get_animation_time()) * speed))));
}
disp->delay(maximum<int>(0,end_tick - SDL_GetTicks() +5));
@@ -920,11 +943,11 @@
}
}
int unit_animator::get_animation_time() const{
- return
animated_units_[0].my_unit->get_animation()->get_animation_time() ;
+ return
animated_units_[0].my_unit->get_animation()->get_animation_time() ;
}
int unit_animator::get_animation_time_potential() const{
- return
animated_units_[0].my_unit->get_animation()->get_animation_time_potential() ;
+ return
animated_units_[0].my_unit->get_animation()->get_animation_time_potential() ;
}
int unit_animator::get_end_time() const
Modified: trunk/src/unit_animation.hpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/unit_animation.hpp?rev=28316&r1=28315&r2=28316&view=diff
==============================================================================
--- trunk/src/unit_animation.hpp (original)
+++ trunk/src/unit_animation.hpp Mon Aug 4 02:03:20 2008
@@ -27,12 +27,14 @@
class attack_type;
class unit_animation
-{
+{
/** Shouldn't be used so only declared. */
unit_animation();
public:
typedef enum { MATCH_FAIL=-2 , DEFAULT_ANIM=-1} variation_type;
typedef enum { HIT, MISS, KILL, INVALID} hit_type;
+ static std::vector<std::string> all_tag_names;
+ static void init_tag_names();
static void fill_initial_animations(
std::vector<unit_animation> & animations, const config & cfg);
static void add_anims( std::vector<unit_animation> &
animations, const config & cfg);
@@ -115,7 +117,7 @@
particule unit_anim_;
};
-class unit_animator
+class unit_animator
{
public:
unit_animator() :
@@ -123,8 +125,8 @@
start_time_(INT_MIN)
{
}
-
-
+
+
void add_animation(unit* animated_unit,const std::string& event,
const gamemap::location &src =
gamemap::location::null_location,
const int value=0,bool with_bars = false,bool
cycles = false,
@@ -153,7 +155,7 @@
void wait_until( int animation_time) const;
private:
struct anim_elem {
-
+
anim_elem() :
my_unit(0),
animation(0),
_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits