eliminate some redundant and incomplete tag listings
This commit is contained in:
parent
723d8c3cbc
commit
3e3103f7a7
4 changed files with 60 additions and 65 deletions
19
src/game.cpp
19
src/game.cpp
|
@ -212,7 +212,7 @@ private:
|
|||
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 @@ game_controller::game_controller(int argc, char** argv)
|
|||
#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 @@ game_display& game_controller::disp()
|
|||
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 @@ void game_controller::start_wesnothd()
|
|||
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 @@ void game_controller::start_wesnothd()
|
|||
|
||||
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 @@ static int process_command_args(int argc, char** argv) {
|
|||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Not the most intuitive solution, but I wanted to leave current semantics for now
|
||||
return -1;
|
||||
}
|
||||
|
@ -2053,11 +2053,11 @@ static int process_command_args(int argc, char** argv) {
|
|||
/**
|
||||
* 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 @@ int main(int argc, char** argv)
|
|||
#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
|
||||
|
|
51
src/unit.cpp
51
src/unit.cpp
|
@ -471,20 +471,9 @@ void unit::advance_to(const unit_type* t, bool use_traits, game_state* state)
|
|||
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 @@ void unit::read(const config& cfg, bool use_traits, game_state* state)
|
|||
// 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 @@ std::string get_checksum(const unit& u) {
|
|||
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();
|
||||
}
|
||||
|
|
|
@ -34,6 +34,29 @@
|
|||
#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)
|
||||
{
|
||||
config expanded_animations;
|
||||
|
@ -103,7 +126,7 @@ unit_animation::unit_animation(int start_time,
|
|||
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::add_anims( std::vector<unit_animation> & animations, const
|
|||
|
||||
}
|
||||
|
||||
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 @@ bool unit_animation::animation_finished_potential() const
|
|||
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 @@ unit_animation::particule::~particule()
|
|||
}
|
||||
|
||||
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 @@ void unit_animator::replace_anim_if_invalid(unit* animated_unit,const std::strin
|
|||
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 @@ void unit_animator::start_animations()
|
|||
} else {
|
||||
anim->my_unit->get_animation()->update_parameters(anim->src,anim->src.get_direction(anim->my_unit->facing()));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -898,7 +921,7 @@ void unit_animator::wait_until(int animation_time) const
|
|||
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 @@ void unit_animator::wait_for_end() const
|
|||
}
|
||||
}
|
||||
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
|
||||
|
|
|
@ -27,12 +27,14 @@ class game_display;
|
|||
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 @@ class unit_animation
|
|||
particule unit_anim_;
|
||||
};
|
||||
|
||||
class unit_animator
|
||||
class unit_animator
|
||||
{
|
||||
public:
|
||||
unit_animator() :
|
||||
|
@ -123,8 +125,8 @@ class unit_animator
|
|||
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 @@ class unit_animator
|
|||
void wait_until( int animation_time) const;
|
||||
private:
|
||||
struct anim_elem {
|
||||
|
||||
|
||||
anim_elem() :
|
||||
my_unit(0),
|
||||
animation(0),
|
||||
|
|
Loading…
Add table
Reference in a new issue