fixup segfaults in replay viewer
After this commit e4eb0a3ede
the
replay viewer would segfault during prestart events. However, it
turns out that nothing in the replay viewer, or in that commit,
was directly causing the segault. Instead, the display object
was holding dangling pointers for no reason, when it could have.
been simply computing the correct value (very cheaply). We clean
up the code in the display objects to fix the segfault.
This commit is contained in:
parent
74e1230b9a
commit
926effb41a
3 changed files with 11 additions and 11 deletions
|
@ -143,7 +143,7 @@ display::display(const display_context * dc, CVideo& video, boost::weak_ptr<wb::
|
|||
exclusive_unit_draw_requests_(),
|
||||
screen_(video),
|
||||
currentTeam_(0),
|
||||
viewpoint_(NULL),
|
||||
dont_show_all_(false),
|
||||
energy_bar_rects_(),
|
||||
xpos_(0),
|
||||
ypos_(0),
|
||||
|
@ -357,12 +357,12 @@ void display::set_team(size_t teamindex, bool show_everything)
|
|||
if (!show_everything)
|
||||
{
|
||||
labels().set_team(&dc_->teams()[teamindex]);
|
||||
viewpoint_ = &dc_->teams()[teamindex];
|
||||
dont_show_all_ = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
labels().set_team(NULL);
|
||||
viewpoint_ = NULL;
|
||||
dont_show_all_ = false;
|
||||
}
|
||||
labels().recalculate_labels();
|
||||
if(boost::shared_ptr<wb::manager> w = wb_.lock())
|
||||
|
@ -1848,7 +1848,7 @@ void display::draw_minimap()
|
|||
}
|
||||
|
||||
if(minimap_ == NULL || minimap_->w > area.w || minimap_->h > area.h) {
|
||||
minimap_ = image::getMinimap(area.w, area.h, get_map(), viewpoint_, (selectedHex_.valid() && !is_blindfolded()) ? &reach_map_ : NULL);
|
||||
minimap_ = image::getMinimap(area.w, area.h, get_map(), &dc_->teams()[currentTeam_], (selectedHex_.valid() && !is_blindfolded()) ? &reach_map_ : NULL);
|
||||
if(minimap_ == NULL) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -73,7 +73,7 @@ public:
|
|||
virtual ~display();
|
||||
static display* get_singleton() { return singleton_ ;}
|
||||
|
||||
bool show_everything() const { return !viewpoint_ && !is_blindfolded(); }
|
||||
bool show_everything() const { return !dont_show_all_ && !is_blindfolded(); }
|
||||
|
||||
const gamemap& get_map() const { return dc_->map(); }
|
||||
|
||||
|
@ -336,11 +336,11 @@ public:
|
|||
|
||||
/** Returns true if location (x,y) is covered in shroud. */
|
||||
bool shrouded(const map_location& loc) const {
|
||||
return is_blindfolded() || (viewpoint_ && viewpoint_->shrouded(loc));
|
||||
return is_blindfolded() || (dont_show_all_ && dc_->teams()[currentTeam_].shrouded(loc));
|
||||
}
|
||||
/** Returns true if location (x,y) is covered in fog. */
|
||||
bool fogged(const map_location& loc) const {
|
||||
return is_blindfolded() || (viewpoint_ && viewpoint_->fogged(loc));
|
||||
return is_blindfolded() || (dont_show_all_ && dc_->teams()[currentTeam_].fogged(loc));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -731,7 +731,7 @@ protected:
|
|||
|
||||
CVideo& screen_;
|
||||
size_t currentTeam_;
|
||||
const team *viewpoint_;
|
||||
bool dont_show_all_; //const team *viewpoint_;
|
||||
std::map<surface,SDL_Rect> energy_bar_rects_;
|
||||
int xpos_, ypos_;
|
||||
bool view_locked_;
|
||||
|
|
|
@ -165,12 +165,12 @@ void game_display::highlight_hex(map_location hex)
|
|||
{
|
||||
wb::future_map future; /**< Lasts for whole method. */
|
||||
|
||||
const unit *u = resources::gameboard->get_visible_unit(hex, dc_->teams()[viewing_team()], !viewpoint_);
|
||||
const unit *u = resources::gameboard->get_visible_unit(hex, dc_->teams()[viewing_team()], !dont_show_all_);
|
||||
if (u) {
|
||||
displayedUnitHex_ = hex;
|
||||
invalidate_unit();
|
||||
} else {
|
||||
u = resources::gameboard->get_visible_unit(mouseoverHex_, dc_->teams()[viewing_team()], !viewpoint_);
|
||||
u = resources::gameboard->get_visible_unit(mouseoverHex_, dc_->teams()[viewing_team()], !dont_show_all_);
|
||||
if (u) {
|
||||
// mouse moved from unit hex to non-unit hex
|
||||
if (dc_->units().count(selectedHex_)) {
|
||||
|
@ -192,7 +192,7 @@ void game_display::display_unit_hex(map_location hex)
|
|||
|
||||
wb::future_map future; /**< Lasts for whole method. */
|
||||
|
||||
const unit *u = resources::gameboard->get_visible_unit(hex, dc_->teams()[viewing_team()], !viewpoint_);
|
||||
const unit *u = resources::gameboard->get_visible_unit(hex, dc_->teams()[viewing_team()], !dont_show_all_);
|
||||
if (u) {
|
||||
displayedUnitHex_ = hex;
|
||||
invalidate_unit();
|
||||
|
|
Loading…
Add table
Reference in a new issue