From ee953c3847abc32c3e369672b7c35424f061765c Mon Sep 17 00:00:00 2001 From: Daniel Karbach Date: Fri, 30 Nov 2012 14:47:04 +0100 Subject: [PATCH] added scenario items to inventory --- src/common/Inventory.cpp | 14 +++++++++++++- src/common/Inventory.h | 7 +++++++ 2 files changed, 20 insertions(+), 1 deletion(-) 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; }; -- 2.39.2