X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fcommon%2FInventory.cpp;h=793a0597f372f04b5668cff2777c9586ba15ce39;hb=3d69f521b593457304b282e5f23e36ab165288b6;hp=e7dbe726e356ca2408669d2e88e8e42cec5213ea;hpb=9c03a930498206bfa05de06ed838a74c8dd84a24;p=l2e.git diff --git a/src/common/Inventory.cpp b/src/common/Inventory.cpp index e7dbe72..793a059 100644 --- a/src/common/Inventory.cpp +++ b/src/common/Inventory.cpp @@ -1,10 +1,3 @@ -/* - * Inventory.cpp - * - * Created on: Aug 9, 2012 - * Author: holy - */ - #include "Inventory.h" #include "Item.h" @@ -14,7 +7,8 @@ namespace common { -Inventory::Inventory() { +Inventory::Inventory() +: scenarioEnd(0) { } @@ -53,6 +47,10 @@ void Inventory::Remove(const Item *item, int count) { } } +void Inventory::RemoveAll(const Item *item) { + Remove(item, 255); +} + Inventory::Entry *Inventory::FindItem(const Item *item) { for (int i(0); i < MaxItems(); ++i) { if (item == ItemAt(i)) { @@ -67,8 +65,19 @@ bool Inventory::SloteFree(int offset) const { } +bool Inventory::AddScenarioItem(const Item *i) { + if (scenarioEnd < MaxScenarioItems()) { + scenario[scenarioEnd] = i; + ++scenarioEnd; + return true; + } else { + return false; + } +} + + void Inventory::Sort() { - std::sort(entries, entries + 96, Entry::Less); + std::stable_sort(entries, entries + 96, Entry::Less); } bool Inventory::Entry::Less(const Entry &lhs, const Entry &rhs) {