Address a bunch of Coverity Scan warnings
This commit is contained in:
parent
cb9c7131cd
commit
670bcf71a3
45 changed files with 106 additions and 95 deletions
|
@ -532,7 +532,7 @@ int battle_context::choose_attacker_weapon(const unit &attacker,
|
|||
defender_combatant_ = new combatant(*defender_stats_, prev_def);
|
||||
attacker_combatant_->fight(*defender_combatant_);
|
||||
} else {
|
||||
if (attacker_stats_->disable) {
|
||||
if (attacker_stats_ != nullptr && attacker_stats_->disable) {
|
||||
delete attacker_stats_;
|
||||
attacker_stats_ = nullptr;
|
||||
continue;
|
||||
|
|
|
@ -98,7 +98,7 @@ const std::set<std::string> get_recruits(int side, const map_location &recruit_l
|
|||
continue;
|
||||
|
||||
// Check if the leader is on a connected keep.
|
||||
if ( allow_local && dynamic_cast<game_state*>(resources::filter_con)->can_recruit_on(*u, recruit_loc) ) {
|
||||
if (allow_local && dynamic_cast<game_state&>(*resources::filter_con).can_recruit_on(*u, recruit_loc)) {
|
||||
leader_in_place= true;
|
||||
local_result.insert(u->recruits().begin(), u->recruits().end());
|
||||
}
|
||||
|
@ -203,7 +203,7 @@ std::vector<unit_const_ptr > get_recalls(int side, const map_location &recall_lo
|
|||
continue;
|
||||
|
||||
// Check if the leader is on a connected keep.
|
||||
if ( !dynamic_cast<game_state*>(resources::filter_con)->can_recruit_on(*u, recall_loc) )
|
||||
if (!dynamic_cast<game_state&>(*resources::filter_con).can_recruit_on(*u, recall_loc))
|
||||
continue;
|
||||
leader_in_place= true;
|
||||
|
||||
|
@ -262,7 +262,7 @@ namespace { // Helpers for check_recall_location()
|
|||
return RECRUIT_NO_VACANCY;
|
||||
|
||||
// See if the preferred location cannot be used.
|
||||
if ( !dynamic_cast<game_state*>(resources::filter_con)->can_recruit_on(recaller, preferred) ) {
|
||||
if (!dynamic_cast<game_state&>(*resources::filter_con).can_recruit_on(recaller, preferred)) {
|
||||
alternative = permissible;
|
||||
return RECRUIT_ALTERNATE_LOCATION;
|
||||
}
|
||||
|
@ -392,7 +392,7 @@ namespace { // Helpers for check_recruit_location()
|
|||
return RECRUIT_NO_VACANCY;
|
||||
|
||||
// See if the preferred location cannot be used.
|
||||
if ( !dynamic_cast<game_state*>(resources::filter_con)->can_recruit_on(recruiter, preferred) ) {
|
||||
if (!dynamic_cast<game_state&>(*resources::filter_con).can_recruit_on(recruiter, preferred)) {
|
||||
alternative = permissible;
|
||||
return RECRUIT_ALTERNATE_LOCATION;
|
||||
}
|
||||
|
@ -540,14 +540,14 @@ namespace { // Helpers for place_recruit()
|
|||
|
||||
// See if the preferred location is an option.
|
||||
unit_map::const_iterator leader = units.find(recruited_from);
|
||||
if ( leader != units.end() && leader->can_recruit() &&
|
||||
leader->side() == side && dynamic_cast<game_state*>(resources::filter_con)->can_recruit_on(*leader, recruit_location) )
|
||||
if (leader != units.end() && leader->can_recruit() &&
|
||||
leader->side() == side && dynamic_cast<game_state&>(*resources::filter_con).can_recruit_on(*leader, recruit_location))
|
||||
return leader->get_location();
|
||||
|
||||
// Check all units.
|
||||
for ( leader = units.begin(); leader != units.end(); ++leader )
|
||||
if ( leader->can_recruit() && leader->side() == side &&
|
||||
dynamic_cast<game_state*>(resources::filter_con)->can_recruit_on(*leader, recruit_location) )
|
||||
for (leader = units.begin(); leader != units.end(); ++leader)
|
||||
if (leader->can_recruit() && leader->side() == side &&
|
||||
dynamic_cast<game_state&>(*resources::filter_con).can_recruit_on(*leader, recruit_location))
|
||||
return leader->get_location();
|
||||
|
||||
// No usable leader found.
|
||||
|
|
|
@ -560,7 +560,7 @@ void get_villages_phase::execute()
|
|||
const unit_map::const_iterator new_unit = units_.find(loc);
|
||||
|
||||
if (new_unit != units_.end() &&
|
||||
power_projection(i->first, get_enemy_dstsrc()) >= new_unit->hitpoints() / 4)
|
||||
power_projection(i->first, get_enemy_dstsrc()) >= new_unit->hitpoints() / 4.0)
|
||||
{
|
||||
LOG_AI_TESTING_AI_DEFAULT << "found support target... " << new_unit->get_location() << '\n';
|
||||
//FIXME: suokko tweaked the constant 1.0 to the formula:
|
||||
|
|
|
@ -538,7 +538,7 @@ std::pair<map_location,map_location> move_to_targets_phase::choose_move(std::vec
|
|||
double best_threat = 0.0;
|
||||
int best_distance = 0;
|
||||
|
||||
const double max_acceptable_threat = un.hitpoints()/4;
|
||||
const double max_acceptable_threat = un.hitpoints() / 4.0;
|
||||
|
||||
std::set<map_location> mass_locations;
|
||||
|
||||
|
|
|
@ -1462,7 +1462,8 @@ double recruitment::get_unit_ratio() const {
|
|||
if (unit.incapacitated() || unit.total_movement() <= 0 || unit.can_recruit()) {
|
||||
continue;
|
||||
}
|
||||
double value = unit.cost() * unit.hitpoints() / unit.max_hitpoints();
|
||||
double value = unit.cost() *
|
||||
static_cast<double>(unit.hitpoints()) / static_cast<double>(unit.max_hitpoints());
|
||||
if (current_team().is_enemy(unit.side())) {
|
||||
enemy_total_value += value;
|
||||
} else {
|
||||
|
|
|
@ -731,7 +731,8 @@ ai::holder& manager::get_active_ai_holder_for_side_dbg(side_number side)
|
|||
{
|
||||
if (!game_config::debug)
|
||||
{
|
||||
return *(new ai::holder(side, config()));
|
||||
static ai::holder empty_holder(side, config());
|
||||
return empty_holder;
|
||||
}
|
||||
return get_active_ai_holder_for_side(side);
|
||||
}
|
||||
|
|
|
@ -347,6 +347,7 @@ void display::init_flags_for_side_internal(size_t n, const std::string& side_col
|
|||
animated<image::locator>& f = flags_[n];
|
||||
|
||||
f = temp_anim;
|
||||
assert(f.get_end_time() != 0);
|
||||
f.start_animation(rand() % f.get_end_time(), true);
|
||||
}
|
||||
|
||||
|
@ -1058,9 +1059,8 @@ std::vector<surface> display::get_fog_shroud_images(const map_location& loc, ima
|
|||
}
|
||||
|
||||
std::vector<surface> display::get_terrain_images(const map_location &loc,
|
||||
const std::string& timeid,
|
||||
image::TYPE image_type,
|
||||
TERRAIN_TYPE terrain_type)
|
||||
const std::string& timeid,
|
||||
TERRAIN_TYPE terrain_type)
|
||||
{
|
||||
std::vector<surface> res;
|
||||
|
||||
|
@ -1189,7 +1189,7 @@ std::vector<surface> display::get_terrain_images(const map_location &loc,
|
|||
const bool off_map = (image.get_filename() == off_map_name || image.get_modifications().find("NO_TOD_SHIFT()") != std::string::npos);
|
||||
|
||||
if(off_map) {
|
||||
surf = image::get_image(image, off_map ? image::SCALED_TO_HEX : image_type);
|
||||
surf = image::get_image(image, image::SCALED_TO_HEX);
|
||||
} else if(lt.empty()) {
|
||||
surf = image::get_image(image, image::SCALED_TO_HEX);
|
||||
} else {
|
||||
|
@ -2530,8 +2530,8 @@ void display::draw_hex(const map_location& loc) {
|
|||
int num_images_bg = 0;
|
||||
|
||||
if(!shrouded(loc)) {
|
||||
std::vector<surface> images_fg = get_terrain_images(loc,tod.id, image_type, FOREGROUND);
|
||||
std::vector<surface> images_bg = get_terrain_images(loc,tod.id, image_type, BACKGROUND);
|
||||
std::vector<surface> images_fg = get_terrain_images(loc,tod.id, FOREGROUND);
|
||||
std::vector<surface> images_bg = get_terrain_images(loc,tod.id, BACKGROUND);
|
||||
|
||||
num_images_fg = images_fg.size();
|
||||
num_images_bg = images_bg.size();
|
||||
|
|
|
@ -695,7 +695,6 @@ protected:
|
|||
|
||||
std::vector<surface> get_terrain_images(const map_location &loc,
|
||||
const std::string& timeid,
|
||||
image::TYPE type,
|
||||
TERRAIN_TYPE terrain_type);
|
||||
|
||||
std::vector<surface> get_fog_shroud_images(const map_location& loc, image::TYPE image_type);
|
||||
|
|
|
@ -54,7 +54,7 @@ editor_action* mouse_action_map_label::drag_left(editor_display& disp, int x, in
|
|||
partial = true;
|
||||
chain = new editor_action_chain(new editor_action_label_delete(last_draged_));
|
||||
chain->append_action(new editor_action_label(hex, label->text(), label->team_name(), label->color(),
|
||||
label->visible_in_shroud(), label->visible_in_fog(), label->immutable(), label->category()));
|
||||
label->visible_in_fog(), label->visible_in_shroud(), label->immutable(), label->category()));
|
||||
}
|
||||
|
||||
last_draged_ = hex;
|
||||
|
|
|
@ -1161,9 +1161,12 @@ std::string get_binary_file_location(const std::string& type, const std::string&
|
|||
// and there would be no way to "escape" from "terrain/" otherwise. This is not the
|
||||
// best solution but we cannot remove it without another solution (subtypes maybe?).
|
||||
|
||||
// using 'for' instead 'if' to allow putting delcaration and check into the brackets
|
||||
for(std::string::size_type pos = filename.rfind("../"); pos != std::string::npos;)
|
||||
return get_binary_file_location(type, filename.substr(pos + 3));
|
||||
{
|
||||
std::string::size_type pos = filename.rfind("../");
|
||||
if(pos != std::string::npos) {
|
||||
return get_binary_file_location(type, filename.substr(pos + 3));
|
||||
}
|
||||
}
|
||||
|
||||
if (!is_legal_file(filename))
|
||||
return std::string();
|
||||
|
|
|
@ -61,12 +61,6 @@ void swap(game_board & one, game_board & other) {
|
|||
one.map_.swap(other.map_);
|
||||
}
|
||||
|
||||
game_board & game_board::operator= (game_board other)
|
||||
{
|
||||
swap(*this, other);
|
||||
return(*this);
|
||||
}
|
||||
|
||||
void game_board::new_turn(int player_num) {
|
||||
for (unit & i : units_) {
|
||||
if (i.side() == player_num) {
|
||||
|
|
|
@ -101,7 +101,7 @@ public:
|
|||
// Copy and swap idiom, because we have a scoped pointer.
|
||||
|
||||
game_board(const game_board & other);
|
||||
game_board & operator= (game_board other);
|
||||
game_board& operator=(const game_board& other) = delete;
|
||||
|
||||
friend void swap(game_board & one, game_board & other);
|
||||
|
||||
|
|
|
@ -267,7 +267,7 @@ create_engine::create_engine(CVideo& v, saved_game& state)
|
|||
|
||||
bool connect = state_.mp_settings().show_connect;
|
||||
|
||||
state_ = saved_game();
|
||||
state_.clear();
|
||||
state_.classification().campaign_type = type;
|
||||
state_.mp_settings().show_connect = connect;
|
||||
|
||||
|
|
|
@ -455,7 +455,7 @@ bool game_launcher::init_lua_script()
|
|||
|
||||
void game_launcher::set_test(const std::string& id)
|
||||
{
|
||||
state_ = saved_game();
|
||||
state_.clear();
|
||||
state_.classification().campaign_type = game_classification::CAMPAIGN_TYPE::TEST;
|
||||
state_.classification().campaign_define = "TEST";
|
||||
|
||||
|
@ -691,7 +691,7 @@ bool game_launcher::load_game()
|
|||
|
||||
void game_launcher::set_tutorial()
|
||||
{
|
||||
state_ = saved_game();
|
||||
state_.clear();
|
||||
state_.classification().campaign_type = game_classification::CAMPAIGN_TYPE::TUTORIAL;
|
||||
state_.classification().campaign_define = "TUTORIAL";
|
||||
state_.mp_settings().mp_era = "era_default";
|
||||
|
@ -711,7 +711,7 @@ void game_launcher::mark_completed_campaigns(std::vector<config> &campaigns)
|
|||
|
||||
bool game_launcher::new_campaign()
|
||||
{
|
||||
state_ = saved_game();
|
||||
state_.clear();
|
||||
state_.classification().campaign_type = game_classification::CAMPAIGN_TYPE::SCENARIO;
|
||||
state_.mp_settings().show_connect = false;
|
||||
play_replay_ = false;
|
||||
|
@ -804,7 +804,7 @@ void game_launcher::start_wesnothd()
|
|||
|
||||
bool game_launcher::play_multiplayer(mp_selection res)
|
||||
{
|
||||
state_ = saved_game();
|
||||
state_.clear();
|
||||
state_.classification().campaign_type = game_classification::CAMPAIGN_TYPE::MULTIPLAYER;
|
||||
|
||||
try {
|
||||
|
@ -889,7 +889,7 @@ bool game_launcher::play_multiplayer_commandline()
|
|||
DBG_MP << "starting multiplayer game from the commandline" << std::endl;
|
||||
|
||||
// These are all the relevant lines taken literally from play_multiplayer() above
|
||||
state_ = saved_game();
|
||||
state_.clear();
|
||||
state_.classification().campaign_type = game_classification::CAMPAIGN_TYPE::MULTIPLAYER;
|
||||
|
||||
game_config_manager::get()->
|
||||
|
|
|
@ -79,6 +79,8 @@ game_state::game_state(const config & level, play_controller & pc, game_board& b
|
|||
player_number_(level["playing_team"].to_int() + 1),
|
||||
end_level_data_(),
|
||||
init_side_done_(level["init_side_done"].to_bool(false)),
|
||||
start_event_fired_(!level["playing_team"].empty()),
|
||||
server_request_number_(level["server_request_number"].to_int()),
|
||||
first_human_team_(-1)
|
||||
{
|
||||
lua_kernel_->load_core();
|
||||
|
|
|
@ -205,7 +205,7 @@ public:
|
|||
// one might want to continue reading the conversation in order.
|
||||
//
|
||||
// TODO: look into implementing the above suggestion
|
||||
dynamic_cast<scroll_label*>(msg_label)->scroll_vertical_scrollbar(scrollbar_base::END);
|
||||
dynamic_cast<scroll_label&>(*msg_label).scroll_vertical_scrollbar(scrollbar_base::END);
|
||||
}
|
||||
|
||||
void chat_message_list_to_clipboard(int first, int last)
|
||||
|
|
|
@ -99,6 +99,7 @@ editor_resize_map::editor_resize_map(int& width,
|
|||
, old_width_(width)
|
||||
, old_height_(height)
|
||||
, expand_direction_(expand_direction)
|
||||
, direction_buttons_{}
|
||||
{
|
||||
register_bool("copy_edge_terrain", false, copy_edge_terrain);
|
||||
|
||||
|
|
|
@ -130,6 +130,7 @@ mp_lobby::mp_lobby(const config& game_config, mp::lobby_info& info, wesnothd_con
|
|||
, gamelistbox_(nullptr)
|
||||
, window_(nullptr)
|
||||
, lobby_info_(info)
|
||||
, chatbox_(nullptr)
|
||||
, filter_friends_(nullptr)
|
||||
, filter_ignored_(nullptr)
|
||||
, filter_slots_(nullptr)
|
||||
|
@ -146,6 +147,7 @@ mp_lobby::mp_lobby(const config& game_config, mp::lobby_info& info, wesnothd_con
|
|||
, gamelist_id_at_row_()
|
||||
, delay_playerlist_update_(false)
|
||||
, delay_gamelist_update_(false)
|
||||
, joined_game_id_(0)
|
||||
{
|
||||
// Need to set this in the constructor, pre_show() is too late
|
||||
set_show_even_without_video(true);
|
||||
|
|
|
@ -38,13 +38,16 @@ protected:
|
|||
std::unique_ptr<plugins_context> plugins_context_;
|
||||
|
||||
protected:
|
||||
plugin_executor() {
|
||||
plugin_executor()
|
||||
: timer_id(0u)
|
||||
{
|
||||
if(plugins_manager::get()) {
|
||||
timer_id = add_timer(game_config::lobby_network_timer, std::bind(&plugin_executor::play_slice, this), true);
|
||||
}
|
||||
}
|
||||
|
||||
~plugin_executor() {
|
||||
~plugin_executor()
|
||||
{
|
||||
if(plugins_manager::get()) {
|
||||
remove_timer(timer_id);
|
||||
}
|
||||
|
|
|
@ -157,7 +157,7 @@ void statistics_dialog::add_damage_row(
|
|||
|
||||
if(show_this_turn) {
|
||||
str << turn_damage << " / "
|
||||
<< (turn_expected * 10 + shift / 2) / shift * 0.1
|
||||
<< (turn_expected * 10 + shift / 2) / shift / 10
|
||||
<< " " // TODO: should probably make this two columns
|
||||
<< ((dst < 0) ^ (turn_expected < 0) ? "" : "+")
|
||||
<< (turn_expected == 0 ? 0 : 100 * dst / turn_expected) << '%';
|
||||
|
|
|
@ -72,6 +72,11 @@ class tooltip : public modeless_dialog
|
|||
public:
|
||||
tooltip() : modeless_dialog(), window_id_(), message_(), mouse_()
|
||||
{
|
||||
// To make Coverity happy
|
||||
source_rect_.x = 0;
|
||||
source_rect_.y = 0;
|
||||
source_rect_.w = 0;
|
||||
source_rect_.h = 0;
|
||||
}
|
||||
|
||||
void set_window_id(const std::string& window_id)
|
||||
|
|
|
@ -94,11 +94,9 @@ static std::string format_level_string(const int level)
|
|||
return lvl;
|
||||
} else if(level == 2) {
|
||||
return "<b>" + lvl + "</b>";
|
||||
} else if(level > 2 ) {
|
||||
} else {
|
||||
return"<b><span color='#ffffff'>" + lvl + "</span></b>";
|
||||
}
|
||||
|
||||
return lvl;
|
||||
}
|
||||
|
||||
static std::string format_cost_string(int unit_recall_cost, const int team_recall_cost)
|
||||
|
|
|
@ -48,7 +48,7 @@ public:
|
|||
return;
|
||||
}
|
||||
|
||||
dynamic_cast<widget*>(w)->connect_signal<event::LEFT_BUTTON_CLICK>(
|
||||
dynamic_cast<widget&>(*w).connect_signal<event::LEFT_BUTTON_CLICK>(
|
||||
std::bind(&group::group_operator, this), event::dispatcher::front_child);
|
||||
|
||||
member_order_.push_back(dynamic_cast<styled_widget*>(w));
|
||||
|
@ -121,7 +121,7 @@ public:
|
|||
{
|
||||
// Ensure this callback is only called on the member being activated
|
||||
const auto callback = [func](widget& widget)->void {
|
||||
if(dynamic_cast<selectable_item*>(&widget)->get_value_bool()) {
|
||||
if(dynamic_cast<selectable_item&>(widget).get_value_bool()) {
|
||||
func(widget);
|
||||
}
|
||||
};
|
||||
|
|
|
@ -43,6 +43,7 @@ multimenu_button::multimenu_button(const implementation::builder_multimenu_butto
|
|||
: styled_widget(builder, get_control_type())
|
||||
, state_(ENABLED)
|
||||
, retval_(0)
|
||||
, max_shown_(1)
|
||||
, values_()
|
||||
, toggle_states_()
|
||||
, droplist_(nullptr)
|
||||
|
|
|
@ -39,6 +39,9 @@ text_box_base::text_box_base(const implementation::builder_styled_widget& builde
|
|||
, selection_start_(0)
|
||||
, selection_length_(0)
|
||||
, ime_in_progress_(false)
|
||||
, ime_start_point_(0)
|
||||
, ime_cursor_(0)
|
||||
, ime_length_(0)
|
||||
, cursor_timer_(0)
|
||||
, cursor_alpha_(0)
|
||||
, cursor_blink_rate_ms_(750)
|
||||
|
|
|
@ -527,11 +527,11 @@ static void event_execute( const SDL_Event& event, command_executor* executor)
|
|||
|
||||
void execute_command(const hotkey_command& command, command_executor* executor, int index, bool press)
|
||||
{
|
||||
if (executor != nullptr) {
|
||||
if (!executor->can_execute_command(command, index)
|
||||
|| executor->execute_command(command, index, press)) {
|
||||
return;
|
||||
}
|
||||
assert(executor != nullptr);
|
||||
|
||||
if (!executor->can_execute_command(command, index)
|
||||
|| executor->execute_command(command, index, press)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!press) {
|
||||
|
|
|
@ -337,6 +337,7 @@ terrain_label::terrain_label(const map_labels& parent,
|
|||
/** Load label from config. */
|
||||
terrain_label::terrain_label(const map_labels& parent, const config& cfg)
|
||||
: handle_(0)
|
||||
, tooltip_handle_(0)
|
||||
, text_()
|
||||
, tooltip_()
|
||||
, team_name_()
|
||||
|
|
|
@ -340,7 +340,7 @@ LEVEL_RESULT playsingle_controller::play_scenario(const config& level)
|
|||
return is_victory ? LEVEL_RESULT::VICTORY : LEVEL_RESULT::DEFEAT;
|
||||
} catch(const savegame::load_game_exception &) {
|
||||
// Loading a new game is effectively a quit.
|
||||
saved_game_ = saved_game();
|
||||
saved_game_.clear();
|
||||
throw;
|
||||
} catch(wesnothd_error& e) {
|
||||
|
||||
|
@ -502,7 +502,7 @@ void playsingle_controller::linger()
|
|||
}
|
||||
} catch(const savegame::load_game_exception &) {
|
||||
// Loading a new game is effectively a quit.
|
||||
saved_game_ = saved_game();
|
||||
saved_game_.clear();
|
||||
throw;
|
||||
}
|
||||
|
||||
|
|
|
@ -25,6 +25,7 @@ public:
|
|||
~replay_recorder_base();
|
||||
|
||||
void swap(replay_recorder_base& other);
|
||||
void swap(replay_recorder_base&& other) {swap(other);}
|
||||
int get_pos() const;
|
||||
|
||||
int size() const;
|
||||
|
|
|
@ -579,7 +579,7 @@ void saved_game::unify_controllers()
|
|||
}
|
||||
}
|
||||
|
||||
saved_game& saved_game::operator=(saved_game other)
|
||||
saved_game& saved_game::operator=(saved_game&& other)
|
||||
{
|
||||
this->swap(other);
|
||||
return *this;
|
||||
|
@ -659,3 +659,15 @@ void saved_game::set_data(config& cfg)
|
|||
mp_settings_ = mp_game_settings(cfg.child_or_empty("multiplayer"));
|
||||
cfg.clear();
|
||||
}
|
||||
|
||||
void saved_game::clear()
|
||||
{
|
||||
carryover_.clear();
|
||||
classification_ = game_classification();
|
||||
has_carryover_expanded_ = false;
|
||||
mp_settings_ = mp_game_settings();
|
||||
replay_data_.swap(replay_recorder_base());
|
||||
replay_start_.clear();
|
||||
starting_pos_.clear();
|
||||
starting_pos_type_ = STARTINGPOS_NONE;
|
||||
}
|
||||
|
|
|
@ -40,10 +40,12 @@ public:
|
|||
explicit saved_game(config cfg);
|
||||
~saved_game(){}
|
||||
|
||||
saved_game& operator =(saved_game other);
|
||||
saved_game& operator=(const saved_game& other) = delete;
|
||||
saved_game& operator=(saved_game&& other);
|
||||
void swap(saved_game& other);
|
||||
/// destroys the passed config.
|
||||
void set_data(config& cfg);
|
||||
void clear();
|
||||
/// writes the config information into a stream (file)
|
||||
void write_config(config_writer& out) const;
|
||||
void write_general_info(config_writer& out) const;
|
||||
|
|
|
@ -138,7 +138,7 @@ static int impl_unit_type_count(lua_State* L)
|
|||
|
||||
static int impl_unit_type_next(lua_State* L)
|
||||
{
|
||||
const unit_type* base = *static_cast<const unit_type**>(luaL_testudata(L, 1, UnitTypeTable));
|
||||
const unit_type* base = *static_cast<const unit_type**>(luaL_checkudata(L, 1, UnitTypeTable));
|
||||
auto unit_map = base ? base->variation_types() : unit_types.types();
|
||||
decltype(unit_map)::const_iterator it = unit_map.end();
|
||||
if(lua_isnoneornil(L, 2)) {
|
||||
|
|
|
@ -1019,7 +1019,7 @@ void preprocessor_data::conditional_skip(bool skip)
|
|||
|
||||
bool preprocessor_data::get_chunk()
|
||||
{
|
||||
char c = in_.get();
|
||||
char c = static_cast<char>(in_.get());
|
||||
token_desc& token = tokens_.back();
|
||||
|
||||
if(in_.eof()) {
|
||||
|
@ -1064,7 +1064,7 @@ bool preprocessor_data::get_chunk()
|
|||
std::string buffer(1, c);
|
||||
|
||||
for(;;) {
|
||||
char d = in_.get();
|
||||
char d = static_cast<char>(in_.get());
|
||||
|
||||
if(in_.eof() || d == '\n') {
|
||||
break;
|
||||
|
@ -1126,7 +1126,7 @@ bool preprocessor_data::get_chunk()
|
|||
for(;;) {
|
||||
if(in_.eof())
|
||||
break;
|
||||
char d = in_.get();
|
||||
char d = static_cast<char>(in_.get());
|
||||
if(d == '\n')
|
||||
++linenum_;
|
||||
buffer += d;
|
||||
|
@ -1153,7 +1153,7 @@ bool preprocessor_data::get_chunk()
|
|||
break;
|
||||
}
|
||||
|
||||
char e = in_.get();
|
||||
char e = static_cast<char>(in_.get());
|
||||
if(e == '\n') {
|
||||
++linenum_;
|
||||
}
|
||||
|
|
|
@ -291,7 +291,8 @@ struct handle_receive_doc : public handle_doc<Handler, ErrorHandler>
|
|||
{
|
||||
std::size_t buf_size;
|
||||
handle_receive_doc(socket_ptr socket, Handler handler, ErrorHandler error_handler) :
|
||||
handle_doc<Handler, ErrorHandler>(socket, handler, error_handler)
|
||||
handle_doc<Handler, ErrorHandler>(socket, handler, error_handler),
|
||||
buf_size(0)
|
||||
{
|
||||
}
|
||||
void operator()(const boost::system::error_code& error, std::size_t size)
|
||||
|
|
|
@ -22,7 +22,7 @@ class surface;
|
|||
#include "floating_label.hpp"
|
||||
#include "tooltips.hpp"
|
||||
#include "video.hpp"
|
||||
#include "widgets/menu.hpp"
|
||||
#include "widgets/button.hpp"
|
||||
|
||||
namespace gui
|
||||
{
|
||||
|
|
|
@ -61,7 +61,9 @@ t_string_base::walker::walker(const t_string_base& string) :
|
|||
begin_(0),
|
||||
end_(string_.size()),
|
||||
textdomain_(),
|
||||
translatable_(false)
|
||||
translatable_(false),
|
||||
countable_(false),
|
||||
count_(0)
|
||||
{
|
||||
if(string.translatable_) {
|
||||
update();
|
||||
|
|
|
@ -793,15 +793,6 @@ void unit::swap(unit & o)
|
|||
swap(invisibility_cache_, o.invisibility_cache_);
|
||||
}
|
||||
|
||||
/**
|
||||
* Assignment operator.
|
||||
*/
|
||||
unit& unit::operator=(unit other)
|
||||
{
|
||||
swap(other);
|
||||
return *this;
|
||||
}
|
||||
|
||||
void unit::generate_name()
|
||||
{
|
||||
if(!name_.empty() || !generate_name_) {
|
||||
|
|
|
@ -127,7 +127,7 @@ public:
|
|||
|
||||
void swap(unit&);
|
||||
|
||||
unit& operator=(unit);
|
||||
unit& operator=(const unit&) = delete;
|
||||
|
||||
/**
|
||||
* @defgroup unit_advance Advancement functions
|
||||
|
|
|
@ -57,7 +57,7 @@ private:
|
|||
EPOCH epoch;
|
||||
|
||||
// TODO: Decide how many months and days there are!
|
||||
unsigned int year = 0, month, day;
|
||||
unsigned int year = 0, month = 0, day = 0;
|
||||
};
|
||||
|
||||
bool operator<(const irdya_date& a, const irdya_date& b);
|
||||
|
|
|
@ -87,6 +87,7 @@ CVideo::CVideo(FAKE_TYPES type)
|
|||
, help_string_(0)
|
||||
, updatesLocked_(0)
|
||||
, flip_locked_(0)
|
||||
, refresh_rate_(0)
|
||||
{
|
||||
assert(!singleton_);
|
||||
singleton_ = this;
|
||||
|
|
|
@ -284,7 +284,7 @@ bool manager::allow_leader_to_move(unit const& leader) const
|
|||
if(recruit || recall)
|
||||
{
|
||||
map_location const target_hex = recruit?recruit->get_recruit_hex():recall->get_recall_hex();
|
||||
if ( dynamic_cast<game_state*>(resources::filter_con)->can_recruit_on(leader, target_hex) )
|
||||
if (dynamic_cast<game_state&>(*resources::filter_con).can_recruit_on(leader, target_hex))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -188,11 +188,11 @@ side_actions_container::iterator side_actions_container::bump_earlier(iterator p
|
|||
assert(position < end());
|
||||
|
||||
action_ptr rhs = *position;
|
||||
action_ptr lhs = position[-1];
|
||||
action_ptr lhs = *(position - 1);
|
||||
|
||||
actions_.replace(position, lhs);
|
||||
actions_.replace(position-1, rhs);
|
||||
return position-1;
|
||||
actions_.replace(position - 1, rhs);
|
||||
return position - 1;
|
||||
}
|
||||
|
||||
side_actions_container::iterator side_actions_container::bump_later(iterator position)
|
||||
|
@ -455,7 +455,7 @@ namespace
|
|||
|
||||
void check_recruit_recall(const map_location &loc) {
|
||||
const unit_const_ptr leader = second_->get_unit();
|
||||
if(leader->can_recruit() && dynamic_cast<game_state*>(resources::filter_con)->can_recruit_on(*leader, loc)) {
|
||||
if(leader->can_recruit() && dynamic_cast<game_state&>(*resources::filter_con).can_recruit_on(*leader, loc)) {
|
||||
if(const unit_const_ptr backup_leader = find_backup_leader(*leader)) {
|
||||
side_actions::iterator it = sa_.find_first_action_of(*backup_leader);
|
||||
if(!(it == sa_.end() || position_ < it)) {
|
||||
|
|
|
@ -69,7 +69,7 @@ unit_const_ptr find_backup_leader(const unit & leader)
|
|||
{
|
||||
if (unit->can_recruit() && unit->id() != leader.id())
|
||||
{
|
||||
if ( dynamic_cast<game_state*>(resources::filter_con)->can_recruit_on(*unit, leader.get_location()) )
|
||||
if (dynamic_cast<game_state&>(*resources::filter_con).can_recruit_on(*unit, leader.get_location()))
|
||||
return unit.get_shared_ptr();
|
||||
}
|
||||
}
|
||||
|
@ -84,7 +84,7 @@ unit* find_recruiter(size_t team_index, map_location const& hex)
|
|||
for(unit& u : resources::gameboard->units())
|
||||
if(u.can_recruit()
|
||||
&& u.side() == static_cast<int>(team_index+1)
|
||||
&& dynamic_cast<game_state*>(resources::filter_con)->can_recruit_on(u, hex))
|
||||
&& dynamic_cast<game_state&>(*resources::filter_con).can_recruit_on(u, hex))
|
||||
return &u;
|
||||
return nullptr;
|
||||
}
|
||||
|
|
|
@ -382,16 +382,6 @@ void menu::set_inner_location(SDL_Rect const &rect)
|
|||
bg_register(rect);
|
||||
}
|
||||
|
||||
const menu::item& menu::get_item(int index) const
|
||||
{
|
||||
return items_[index];
|
||||
}
|
||||
|
||||
const menu::item& menu::get_selected_item() const
|
||||
{
|
||||
return items_[selection()];
|
||||
}
|
||||
|
||||
void menu::change_item(int pos1, int pos2,const std::string& str)
|
||||
{
|
||||
if(pos1 < 0 || pos1 >= int(item_pos_.size()) ||
|
||||
|
|
|
@ -161,9 +161,6 @@ public:
|
|||
void move_selection_keeping_viewport(size_t id);
|
||||
void reset_selection();
|
||||
|
||||
const item& get_item(int index) const;
|
||||
const item& get_selected_item() const;
|
||||
|
||||
// allows user to change_item while running (dangerous)
|
||||
void change_item(int pos1,int pos2,const std::string& str);
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue