summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/gui/inventorywindow.cpp2
-rw-r--r--src/inventory.cpp7
-rw-r--r--src/inventory.h2
-rw-r--r--src/localplayer.cpp1
-rw-r--r--src/localplayer.h4
-rw-r--r--src/main.cpp2
6 files changed, 12 insertions, 6 deletions
diff --git a/src/gui/inventorywindow.cpp b/src/gui/inventorywindow.cpp
index 7b888212..83dadbc9 100644
--- a/src/gui/inventorywindow.cpp
+++ b/src/gui/inventorywindow.cpp
@@ -57,7 +57,7 @@ InventoryWindow::InventoryWindow():
mUseButton = new Button("Use", "use", this);
mDropButton = new Button("Drop", "drop", this);
- mItems = new ItemContainer(player_node->mInventory.get());
+ mItems = new ItemContainer(player_node->mInventory);
mItems->addSelectionListener(this);
mInvenScroll = new ScrollArea(mItems);
diff --git a/src/inventory.cpp b/src/inventory.cpp
index e476857f..6795fbec 100644
--- a/src/inventory.cpp
+++ b/src/inventory.cpp
@@ -24,8 +24,10 @@
#include "inventory.h"
#include <algorithm>
+#include <cassert>
#include "item.h"
+#include "log.h"
struct SlotUsed : public std::unary_function<Item, bool>
{
@@ -64,6 +66,11 @@ void Inventory::addItem(int id, int quantity, bool equipment)
void Inventory::addItem(int index, int id, int quantity, bool equipment)
{
+ if (index < 0 || index >= INVENTORY_SIZE) {
+ logger->log("Warning: invalid inventory index: %d", index);
+ return;
+ }
+
mItems[index].setId(id);
mItems[index].increaseQuantity(quantity);
mItems[index].setEquipment(equipment);
diff --git a/src/inventory.h b/src/inventory.h
index 32ae393e..d5c3cf35 100644
--- a/src/inventory.h
+++ b/src/inventory.h
@@ -26,7 +26,7 @@
class Item;
-#define INVENTORY_SIZE 100
+#define INVENTORY_SIZE 102
class Inventory
{
diff --git a/src/localplayer.cpp b/src/localplayer.cpp
index af047775..2d9da036 100644
--- a/src/localplayer.cpp
+++ b/src/localplayer.cpp
@@ -53,6 +53,7 @@ LocalPlayer::LocalPlayer(Uint32 id, Uint16 job, Map *map):
LocalPlayer::~LocalPlayer()
{
+ delete mInventory;
}
void LocalPlayer::logic()
diff --git a/src/localplayer.h b/src/localplayer.h
index 8269e29e..b19a0c3f 100644
--- a/src/localplayer.h
+++ b/src/localplayer.h
@@ -24,8 +24,6 @@
#ifndef _TMW_LOCALPLAYER_H
#define _TMW_LOCALPLAYER_H
-#include <memory>
-
#include "player.h"
// TODO move into some sane place...
@@ -205,7 +203,7 @@ class LocalPlayer : public Player
float mLastAttackTime; /**< Used to synchronize the charge dialog */
- std::auto_ptr<Inventory> mInventory;
+ Inventory *mInventory;
protected:
void walk(unsigned char dir);
diff --git a/src/main.cpp b/src/main.cpp
index 5a0e2ed9..51d51243 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -234,7 +234,7 @@ void init_engine(const Options &options)
config.setValue("fpslimit", 60);
config.setValue("updatehost", "http://updates.themanaworld.org");
config.setValue("customcursor", 1);
- config.setValue("ChatLogLength", 64);
+ config.setValue("ChatLogLength", 128);
// Checking if the configuration file exists... otherwise creates it with
// default options !