mirror of
https://github.com/wesnoth/wesnoth
synced 2025-05-01 18:11:30 +00:00
Bad const_cast. Shoo.
This commit is contained in:
parent
4a5db39cd5
commit
f60edbf6e0
@ -20,10 +20,6 @@
|
||||
#include "units/unit.hpp"
|
||||
#include "units/map.hpp"
|
||||
|
||||
std::vector<std::string>& display_context::hidden_label_categories_ref() {
|
||||
return const_cast<std::vector<std::string>&>(this->hidden_label_categories());
|
||||
}
|
||||
|
||||
const team& display_context::get_team(int side) const
|
||||
{
|
||||
return teams().at(side - 1);
|
||||
|
@ -38,7 +38,7 @@ public:
|
||||
virtual const gamemap & map() const = 0;
|
||||
virtual const unit_map & units() const = 0;
|
||||
virtual const std::vector<std::string> & hidden_label_categories() const = 0;
|
||||
std::vector<std::string> & hidden_label_categories_ref();
|
||||
virtual std::vector<std::string> & hidden_label_categories() = 0;
|
||||
const team& get_team(int side) const;
|
||||
|
||||
// this one is only a template function to prevent compilation erros when class team is an incomplete type.
|
||||
|
@ -161,6 +161,11 @@ public:
|
||||
return lbl_categories_;
|
||||
}
|
||||
|
||||
virtual std::vector<std::string>& hidden_label_categories() override
|
||||
{
|
||||
return lbl_categories_;
|
||||
}
|
||||
|
||||
/**
|
||||
* Replace the [time]s of the currently active area.
|
||||
*/
|
||||
|
@ -126,6 +126,11 @@ public:
|
||||
return labels_;
|
||||
}
|
||||
|
||||
virtual std::vector<std::string>& hidden_label_categories() override
|
||||
{
|
||||
return labels_;
|
||||
}
|
||||
|
||||
// Copy and swap idiom, because we have a scoped pointer.
|
||||
|
||||
game_board(const game_board & other);
|
||||
|
@ -225,7 +225,7 @@ void game_state::init(const config& level, play_controller & pc)
|
||||
// Labels from players in your ignore list default to hidden
|
||||
if(preferences::is_ignored(board_.teams_[i].current_player())) {
|
||||
std::string label_cat = "side:" + std::to_string(i + 1);
|
||||
board_.hidden_label_categories_ref().push_back(label_cat);
|
||||
board_.hidden_label_categories().push_back(label_cat);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -117,7 +117,7 @@ bool label_settings::execute(display_context& dc) {
|
||||
hidden_categories.push_back(lbl.first);
|
||||
}
|
||||
}
|
||||
dc.hidden_label_categories_ref().swap(hidden_categories);
|
||||
dc.hidden_label_categories().swap(hidden_categories);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -75,12 +75,14 @@ public:
|
||||
const gamemap & map() const override { return *gm_; }
|
||||
const std::vector<team> & teams() const override { return *tm_; }
|
||||
const std::vector<std::string> & hidden_label_categories() const override { return *lbls_; }
|
||||
std::vector<std::string>& hidden_label_categories() override { return lbls_dummy_; }
|
||||
|
||||
private:
|
||||
const unit_map * um_;
|
||||
const gamemap * gm_;
|
||||
const std::vector<team> * tm_;
|
||||
const std::vector<std::string> * lbls_;
|
||||
std::vector<std::string> lbls_dummy_;
|
||||
};
|
||||
|
||||
class ignore_units_filter_context : public filter_context {
|
||||
|
Loading…
x
Reference in New Issue
Block a user