Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/client/inventorylistview.cc23
-rw-r--r--src/client/trademenu.cc7
-rw-r--r--src/core/item.h9
-rw-r--r--src/game/base/game.cc3
4 files changed, 33 insertions, 9 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();
diff --git a/src/core/item.h b/src/core/item.h
index ec0d6be..4d9f0e8 100644
--- a/src/core/item.h
+++ b/src/core/item.h
@@ -19,7 +19,7 @@ namespace core
class Item
{
public:
- enum Flags {Tradeable = 1, Unique = 2};
+ enum Flags {Tradeable = 1, Unique = 2, Unrestricted = 4};
Item(const Info *info);
@@ -78,6 +78,13 @@ public:
}
/**
+ * @brief returns true if the Unrestricted flag is set
+ */
+ inline const bool unrestricted() const {
+ return ((item_flags & (unsigned int) Unrestricted) == (unsigned int) Unrestricted);
+ }
+
+ /**
* @brief return true if the dirty flag is set
* */
inline const bool dirty() const {
diff --git a/src/game/base/game.cc b/src/game/base/game.cc
index c87c9b6..b6cacde 100644
--- a/src/game/base/game.cc
+++ b/src/game/base/game.cc
@@ -515,6 +515,7 @@ void Game::func_give(core::Player *player, const std::string &args)
item = player->control()->inventory()->find(weapon);
if (!item) {
item = new core::Item(weapon);
+ item->set_flag(core::Item::Unrestricted);
player->control()->inventory()->add(item);
} else {
assert(item->info() == weapon);
@@ -524,6 +525,7 @@ void Game::func_give(core::Player *player, const std::string &args)
for (int n = 0; n < amount; n++) {
item = new core::Item(weapon);
item->set_flag(core::Item::Unique);
+ item->set_flag(core::Item::Unrestricted);
item->set_amount(1);
player->control()->inventory()->add(item);
}
@@ -1991,6 +1993,7 @@ bool Game::load_zone(core::Zone *zone)
if (!weapon->stackable()) {
item->set_flag(core::Item::Unique);
}
+ item->set_flag(core::Item::Unrestricted);
inventory->add(item);
}
} else {