X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fcommon%2FInventory.cpp;h=275de538f49f83eb344b549d55f1b41fad81f10f;hb=350055a7ff27c74882aff8a4d6af2014782f830b;hp=6a6af81f3b52fe3dd0f94875cde38f00689f016b;hpb=89aa9fbc77d72e98549bc3aabd7ced7cd8949bdc;p=l2e.git diff --git a/src/common/Inventory.cpp b/src/common/Inventory.cpp index 6a6af81..275de53 100644 --- a/src/common/Inventory.cpp +++ b/src/common/Inventory.cpp @@ -14,7 +14,8 @@ namespace common { -Inventory::Inventory() { +Inventory::Inventory() +: scenarioEnd(0) { } @@ -53,6 +54,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,6 +72,17 @@ 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); } @@ -83,4 +99,8 @@ bool Inventory::Entry::Less(const Entry &lhs, const Entry &rhs) { } } +void Inventory::SwapEntriesAt(int lhs, int rhs) { + std::swap(entries[lhs], entries[rhs]); +} + }