X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fcommon%2FInventory.cpp;h=793a0597f372f04b5668cff2777c9586ba15ce39;hb=7582af9fc5f909ef38509c0421e9dbea3c005764;hp=d8ba20c08af5a35c0af1d1311ab2474259634449;hpb=bdebc167119794e59c26a058d1155a337b1bc768;p=l2e.git diff --git a/src/common/Inventory.cpp b/src/common/Inventory.cpp index d8ba20c..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) { } @@ -71,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) {