From c640e9346c5e6c72b62b1beeaf5ec6de9cdc6924 Mon Sep 17 00:00:00 2001 From: "madmaxoft@gmail.com" Date: Sat, 25 May 2013 11:59:13 +0000 Subject: cChestEntity and cDispenserEntity now inherit from a common ancestor, cBlockEntityWithItems git-svn-id: http://mc-server.googlecode.com/svn/trunk@1507 0a769ca7-a7f5-676a-18bf-c427514a06d6 --- source/DispenserEntity.cpp | 31 ++++++++++++++----------------- 1 file changed, 14 insertions(+), 17 deletions(-) (limited to 'source/DispenserEntity.cpp') 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: -- cgit v1.2.3