summaryrefslogtreecommitdiffstats
path: root/source/DispenserEntity.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'source/DispenserEntity.cpp')
-rw-r--r--source/DispenserEntity.cpp31
1 files changed, 14 insertions, 17 deletions
diff --git a/source/DispenserEntity.cpp b/source/DispenserEntity.cpp
index 1c95172e2..ccf4e0f95 100644
--- a/source/DispenserEntity.cpp
+++ b/source/DispenserEntity.cpp
@@ -31,9 +31,8 @@
-cDispenserEntity::cDispenserEntity(int a_X, int a_Y, int a_Z, cWorld * a_World) :
- cBlockEntity(E_BLOCK_DISPENSER, a_X, a_Y, a_Z, a_World),
- m_Contents(3, 3),
+cDispenserEntity::cDispenserEntity(int a_BlockX, int a_BlockY, int a_BlockZ) :
+ super(E_BLOCK_DISPENSER, a_BlockX, a_BlockY, a_BlockZ, ContentsWidth, ContentsHeight, NULL),
m_ShouldDispense(false)
{
SetBlockEntity(this); // cBlockEntityWindowOwner
@@ -43,27 +42,25 @@ cDispenserEntity::cDispenserEntity(int a_X, int a_Y, int a_Z, cWorld * a_World)
-cDispenserEntity::~cDispenserEntity()
+cDispenserEntity::cDispenserEntity(int a_BlockX, int a_BlockY, int a_BlockZ, cWorld * a_World) :
+ super(E_BLOCK_DISPENSER, a_BlockX, a_BlockY, a_BlockZ, ContentsWidth, ContentsHeight, a_World),
+ m_ShouldDispense(false)
{
- // Tell window its owner is destroyed
- cWindow * Window = GetWindow();
- if (Window != NULL)
- {
- Window->OwnerDestroyed();
- }
+ SetBlockEntity(this); // cBlockEntityWindowOwner
}
-void cDispenserEntity::Destroy(void)
+cDispenserEntity::~cDispenserEntity()
{
- // Drop items
- cItems Pickups;
- m_Contents.CopyToItems(Pickups);
- m_Contents.Clear();
- m_World->SpawnItemPickups(Pickups, m_PosX, m_PosY, m_PosZ);
+ // Tell window its owner is destroyed
+ cWindow * Window = GetWindow();
+ if (Window != NULL)
+ {
+ Window->OwnerDestroyed();
+ }
}
@@ -97,7 +94,7 @@ void cDispenserEntity::Dispense(void)
// Pick an item to dispense:
MTRand r1;
- int RandomSlot = r1.randInt(SlotsCnt);
+ int RandomSlot = r1.randInt(SlotsCnt - 1);
cItem & Drop = m_Contents.GetSlot(OccupiedSlots[RandomSlot]);
// Dispense the item: