diff options
author | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2007-12-21 14:56:38 +0000 |
---|---|---|
committer | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2007-12-21 14:56:38 +0000 |
commit | 0c531de47eae77ab9fb2ec7a1fd6fc2be1462ef4 (patch) | |
tree | f85809e3a6a4771e2c157e1fb1577877741b81b5 | |
parent | 539af2ea0ce3245c41b4a4be989da35788f7b992 (diff) | |
download | mana-0c531de47eae77ab9fb2ec7a1fd6fc2be1462ef4.tar.gz mana-0c531de47eae77ab9fb2ec7a1fd6fc2be1462ef4.tar.bz2 mana-0c531de47eae77ab9fb2ec7a1fd6fc2be1462ef4.tar.xz mana-0c531de47eae77ab9fb2ec7a1fd6fc2be1462ef4.zip |
Fixed inventory size not matching the size assumed by eAthena and related
memory corruption and increased default chat log length.
-rw-r--r-- | ChangeLog | 4 | ||||
-rw-r--r-- | src/gui/inventorywindow.cpp | 2 | ||||
-rw-r--r-- | src/inventory.cpp | 7 | ||||
-rw-r--r-- | src/inventory.h | 2 | ||||
-rw-r--r-- | src/localplayer.cpp | 1 | ||||
-rw-r--r-- | src/localplayer.h | 4 | ||||
-rw-r--r-- | src/main.cpp | 2 |
7 files changed, 16 insertions, 6 deletions
@@ -4,6 +4,10 @@ the selection is removed. * src/resources/resourcemanager.h, src/resources/resourcemanager.cpp: Added logging of error on PHYSFS_addToSearchPath. + * src/localplayer.cpp, src/inventory.h, src/gui/inventorywindow.cpp, + src/inventory.cpp, src/localplayer.h: Fixed inventory size not + matching the size assumed by eAthena, and related memory corruption. + * src/main.cpp: Increased default chat log length. 2007-12-19 Philipp Sehmisch <tmw@crushnet.org> 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 ! |