diff options
author | Stijn Buys <ingar@osirion.org> | 2012-10-21 10:18:07 +0000 |
---|---|---|
committer | Stijn Buys <ingar@osirion.org> | 2012-10-21 10:18:07 +0000 |
commit | 37116aad3b2c128bae5b7f1ef4d1bc3cb8608f57 (patch) | |
tree | a7377905f52eaa41b6cc38a94db96fb9f8706246 /src/client | |
parent | db69f96fbf5ac5321bdcb1e86ff07d1e35de9fec (diff) |
Support the Item::Unrestricted flag, client allows to sell unrestricted items anywhere.
Diffstat (limited to 'src/client')
-rw-r--r-- | src/client/inventorylistview.cc | 23 | ||||
-rw-r--r-- | src/client/trademenu.cc | 7 |
2 files changed, 22 insertions, 8 deletions
diff --git a/src/client/inventorylistview.cc b/src/client/inventorylistview.cc index 77daba2..b3dba61 100644 --- a/src/client/inventorylistview.cc +++ b/src/client/inventorylistview.cc @@ -71,10 +71,14 @@ void InventoryListView::set_inventory(core::Inventory *inventory, core::InfoType // special rules for own ship inventory // retreive price from the trader - const core::Item *trader_item = (core::localplayer()->view() && core::localplayer()->view()->inventory() ? core::localplayer()->view()->inventory()->find(item->info()) : 0); - if (!trader_item) { - // not sold here - str << "^N"; + const core::Item *trader_item = 0; + + if (!item->unrestricted()) { + trader_item = (core::localplayer()->view() && core::localplayer()->view()->inventory() ? core::localplayer()->view()->inventory()->find(item->info()) : 0); + if (!trader_item) { + // not sold here + str << "^N"; + } } str << item->info()->name(); @@ -83,13 +87,18 @@ void InventoryListView::set_inventory(core::Inventory *inventory, core::InfoType str_amount << item->amount(); str << '\n' << aux::pad_right(str_amount.str(), 10); - if (trader_item) { + if (item->unrestricted()) { + // unrestricted items can be sold anywhere + std::ostringstream std_price; + std_price << item->price() << " credits"; + str << aux::pad_left(std_price.str(), 12); + } else if (trader_item) { std::ostringstream std_price; std_price << trader_item->price() << " credits"; str << aux::pad_left(std_price.str(), 12); } - - if (trader_item) { + + if (trader_item || item->unrestricted()) { sortkey.assign("+"); } else { sortkey.assign("-"); diff --git a/src/client/trademenu.cc b/src/client/trademenu.cc index 6421d43..0023f1b 100644 --- a/src/client/trademenu.cc +++ b/src/client/trademenu.cc @@ -181,7 +181,12 @@ void TradeMenu::set_item(ui::ListItem *item) // item in ship inventory selected (SELL) menu_traderlistview->deselect(); - const core::Item *trader_item = (menu_traderlistview->inventory() ? menu_traderlistview->inventory()->find(item->info()) : 0); + const core::Item *trader_item = 0; + if (item->item()->unrestricted()) { + trader_item = item->item(); + } else { + trader_item = (menu_traderlistview->inventory() ? menu_traderlistview->inventory()->find(item->info()) : 0); + } if (trader_item) { const long max_amount = item->item()->amount(); |