From c4cd091c43ade80033f41c1ceda5c9f51979dcbc Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Mon, 19 Mar 2012 21:03:47 +0000 Subject: Resolved a ModelView related segfault when opening the buy menu and a potental segfault in the inventory window. --- src/client/buymenu.cc | 2 +- src/client/gamewindow.cc | 2 +- src/client/inventorywindow.cc | 2 +- src/ui/modelview.cc | 31 ++++++++++++++++--------------- src/ui/modelview.h | 22 +++++++++++++++++++--- 5 files changed, 38 insertions(+), 21 deletions(-) (limited to 'src') diff --git a/src/client/buymenu.cc b/src/client/buymenu.cc index 6812bce..ae941f8 100644 --- a/src/client/buymenu.cc +++ b/src/client/buymenu.cc @@ -77,7 +77,7 @@ void BuyMenu::set_item(core::Info *info) { menu_infotext.clear(); menu_namelabel->set_text(0); - menu_modelview->set_modelname(0); + menu_modelview->clear(); menu_buybutton->hide(); menu_modelview->hide(); menu_msgtext->hide(); diff --git a/src/client/gamewindow.cc b/src/client/gamewindow.cc index a2693e1..929cfe4 100644 --- a/src/client/gamewindow.cc +++ b/src/client/gamewindow.cc @@ -196,7 +196,7 @@ void GameWindow::show_menu(const std::string & args) if (label.compare("buy") == 0) { // buy menu, single item - unsigned long id; + unsigned int id; if (argstr >> id) { // hide other menus diff --git a/src/client/inventorywindow.cc b/src/client/inventorywindow.cc index 0d78025..2b956c4 100644 --- a/src/client/inventorywindow.cc +++ b/src/client/inventorywindow.cc @@ -361,7 +361,7 @@ void InventoryWindow::set_info(const core::Info *info, const int amount) inventorywindow_ejectslider->hide(); if (!info) { - inventorywindow_modelview->set_modelname(0); + inventorywindow_modelview->clear(); inventorywindow_modeltitlelabel->set_text(""); inventorywindow_modelnamelabel->set_text(""); } else { diff --git a/src/ui/modelview.cc b/src/ui/modelview.cc index 79544bb..033e4e3 100755 --- a/src/ui/modelview.cc +++ b/src/ui/modelview.cc @@ -47,33 +47,34 @@ void ModelView::print(const size_t indent) const con_print << aux::pad_left(marker, indent*2) << label() << " \"" << modelname() << "\"" << std::endl; } -void ModelView::set_globetexturename(const std::string & texturename, const bool bright, const std::string & coronaname) -{ - modelview_globetexturename.assign(texturename); - modelview_globecoronaname.assign(coronaname); - modelview_globebright = bright; - +void ModelView::clear() +{ set_background(false); + modelview_axis.clear(); modelview_axis.change_direction(180); modelview_axis.change_pitch(-15); modelview_zoom = 1.0f; + modelview_modelname.clear(); + modelview_globetexturename.clear(); + modelview_globecoronaname.clear(); + modelview_globebright = false; +} + +void ModelView::set_globetexturename(const std::string & texturename, const bool bright, const std::string & coronaname) +{ + clear(); + modelview_globetexturename.assign(texturename); + modelview_globecoronaname.assign(coronaname); + modelview_globebright = bright; } void ModelView::set_modelname(const std::string & modelname) { + clear(); modelview_modelname.assign(modelname); - - set_background(false); - modelview_axis.clear(); - modelview_axis.change_direction(180); - modelview_axis.change_pitch(-15); - modelview_zoom = 1.0f; - modelview_globetexturename.clear(); - modelview_globecoronaname.clear(); - modelview_globebright = false; } void ModelView::set_colors(const math::Color & color_primary, const math::Color & color_secondary) diff --git a/src/ui/modelview.h b/src/ui/modelview.h index 5596271..d49acc8 100755 --- a/src/ui/modelview.h +++ b/src/ui/modelview.h @@ -37,13 +37,29 @@ public: return modelview_radius; } + /** + * @brief clear the modelview and show nothing + * */ + void clear(); + + /** + * @brief show a textured globe with an optional corona + * */ void set_globetexturename(const std::string & texturename, const bool bright, const std::string & coronaname); - + + /** + * @brief show a model + * */ void set_modelname(const std::string & modelname); + /** + * @brief et primary and secondary entity color, to be used by the model renderer + * */ void set_colors(const math::Color & color_primary, const math::Color & color_secondary); - /// print modelview description + /** + * @brief print modelview widget description + * */ virtual void print(const size_t indent) const; /** @@ -51,7 +67,7 @@ public: * @param zoom the new zoom factor * The zoom factor will be clamped to the range [1.0-10.0] * 1.0 is not zoomed out, 10.0 is zoomed out by a factor of 10 - */ + * */ void set_zoom(const float zoom); inline void set_radius(const float radius) { -- cgit v1.2.3