From: Daniel Karbach Date: Fri, 30 Nov 2012 13:47:04 +0000 (+0100) Subject: added scenario items to inventory X-Git-Url: https://git.localhorst.tv/?a=commitdiff_plain;h=ee953c3847abc32c3e369672b7c35424f061765c;p=l2e.git added scenario items to inventory --- diff --git a/src/common/Inventory.cpp b/src/common/Inventory.cpp index d8ba20c..275de53 100644 --- a/src/common/Inventory.cpp +++ b/src/common/Inventory.cpp @@ -14,7 +14,8 @@ namespace common { -Inventory::Inventory() { +Inventory::Inventory() +: scenarioEnd(0) { } @@ -71,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); } diff --git a/src/common/Inventory.h b/src/common/Inventory.h index aaf315c..e7c5696 100644 --- a/src/common/Inventory.h +++ b/src/common/Inventory.h @@ -26,6 +26,11 @@ public: int MaxItems() const { return 96; } + bool AddScenarioItem(const Item *); + const Item *ScenarioItemAt(int offset) const { return scenario[offset]; } + int NumScenarioItems() const { return scenarioEnd; } + int MaxScenarioItems() const { return 64; } + const Item *ItemAt(int offset) const { return entries[offset].item; } int ItemCountAt(int offset) const { return entries[offset].count; } @@ -47,6 +52,8 @@ private: private: Entry entries[96]; + const Item *scenario[64]; + int scenarioEnd; };