summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/BlockEntities/CMakeLists.txt1
-rw-r--r--src/Blocks/CMakeLists.txt1
-rw-r--r--src/CMakeLists.txt1
-rw-r--r--src/ClientHandle.cpp2
-rw-r--r--src/Entities/CMakeLists.txt1
-rw-r--r--src/Entities/ProjectileEntity.cpp63
-rw-r--r--src/Entities/ProjectileEntity.h13
-rw-r--r--src/Generating/CMakeLists.txt1
-rw-r--r--src/Generating/Prefabs/CMakeLists.txt1
-rw-r--r--src/HTTPServer/CMakeLists.txt1
-rw-r--r--src/Items/CMakeLists.txt7
-rw-r--r--src/Items/ItemArmor.h67
-rw-r--r--src/Items/ItemHandler.cpp26
-rw-r--r--src/Items/ItemHandler.h30
-rw-r--r--src/Mobs/CMakeLists.txt1
-rw-r--r--src/OSSupport/CMakeLists.txt1
-rw-r--r--src/Protocol/CMakeLists.txt1
-rw-r--r--src/Simulator/CMakeLists.txt1
-rw-r--r--src/UI/CMakeLists.txt1
-rw-r--r--src/UI/SlotArea.cpp74
-rw-r--r--src/UI/SlotArea.h7
-rw-r--r--src/WorldStorage/CMakeLists.txt1
22 files changed, 277 insertions, 25 deletions
diff --git a/src/BlockEntities/CMakeLists.txt b/src/BlockEntities/CMakeLists.txt
index 920767f5c..3e3d17f86 100644
--- a/src/BlockEntities/CMakeLists.txt
+++ b/src/BlockEntities/CMakeLists.txt
@@ -6,6 +6,7 @@ include_directories ("${PROJECT_SOURCE_DIR}/../")
file(GLOB SOURCE
"*.cpp"
+ "*.h"
)
add_library(BlockEntities ${SOURCE})
diff --git a/src/Blocks/CMakeLists.txt b/src/Blocks/CMakeLists.txt
index 082ff41ac..4b8c745ad 100644
--- a/src/Blocks/CMakeLists.txt
+++ b/src/Blocks/CMakeLists.txt
@@ -6,6 +6,7 @@ include_directories ("${PROJECT_SOURCE_DIR}/../")
file(GLOB SOURCE
"*.cpp"
+ "*.h"
)
add_library(Blocks ${SOURCE})
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 30e9dbfd4..9cc5fcb1e 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -123,6 +123,7 @@ if (NOT MSVC)
file(GLOB SOURCE
"*.cpp"
+ "*.h"
)
list(REMOVE_ITEM SOURCE "${PROJECT_SOURCE_DIR}/StackWalker.cpp" "${PROJECT_SOURCE_DIR}/LeakFinder.cpp")
diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp
index 0f26d41e7..63ae98be4 100644
--- a/src/ClientHandle.cpp
+++ b/src/ClientHandle.cpp
@@ -1037,7 +1037,7 @@ void cClientHandle::HandleRightClick(int a_BlockX, int a_BlockY, int a_BlockZ, e
{
HandlePlaceBlock(a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_CursorX, a_CursorY, a_CursorZ, *ItemHandler);
}
- else if (ItemHandler->IsFood())
+ else if (ItemHandler->IsFood() && !m_Player->IsGameModeCreative())
{
if (m_Player->IsSatiated())
{
diff --git a/src/Entities/CMakeLists.txt b/src/Entities/CMakeLists.txt
index 85cc45494..c9ca44d38 100644
--- a/src/Entities/CMakeLists.txt
+++ b/src/Entities/CMakeLists.txt
@@ -6,6 +6,7 @@ include_directories ("${PROJECT_SOURCE_DIR}/../")
file(GLOB SOURCE
"*.cpp"
+ "*.h"
)
add_library(Entities ${SOURCE})
diff --git a/src/Entities/ProjectileEntity.cpp b/src/Entities/ProjectileEntity.cpp
index 96db17ffd..fd3e80e5f 100644
--- a/src/Entities/ProjectileEntity.cpp
+++ b/src/Entities/ProjectileEntity.cpp
@@ -440,6 +440,7 @@ cArrowEntity::cArrowEntity(cPlayer & a_Player, double a_Force) :
m_IsCritical((a_Force >= 1)),
m_Timer(0),
m_HitGroundTimer(0),
+ m_HasTeleported(false),
m_bIsCollected(false),
m_HitBlockPos(0, 0, 0)
{
@@ -562,12 +563,12 @@ void cArrowEntity::Tick(float a_Dt, cChunk & a_Chunk)
// We can afford to do this because xoft's algorithm for trajectory is near perfect, so things are pretty close anyway without sync
// Besides, this seems to be what the vanilla server does, note how arrows teleport half a second after they hit to the server position
- if (m_HitGroundTimer != -1) // Sent a teleport already, don't do again
+ if (!m_HasTeleported) // Sent a teleport already, don't do again
{
if (m_HitGroundTimer > 1000.f) // Send after a second, could be less, but just in case
{
m_World->BroadcastTeleportEntity(*this);
- m_HitGroundTimer = -1;
+ m_HasTeleported = true;
}
else
{
@@ -611,6 +612,32 @@ cThrownEggEntity::cThrownEggEntity(cEntity * a_Creator, double a_X, double a_Y,
void cThrownEggEntity::OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFace)
{
+ TrySpawnChicken(a_HitPos);
+
+ Destroy();
+}
+
+
+
+
+
+void cThrownEggEntity::OnHitEntity(cEntity & a_EntityHit, const Vector3d & a_HitPos)
+{
+ int TotalDamage = 0;
+ // TODO: If entity is Ender Crystal, destroy it
+
+ TrySpawnChicken(a_HitPos);
+ a_EntityHit.TakeDamage(dtRangedAttack, this, TotalDamage, 1);
+
+ Destroy(true);
+}
+
+
+
+
+
+void cThrownEggEntity::TrySpawnChicken(const Vector3d & a_HitPos)
+{
if (m_World->GetTickRandomNumber(7) == 1)
{
m_World->SpawnMob(a_HitPos.x, a_HitPos.y, a_HitPos.z, cMonster::mtChicken);
@@ -622,7 +649,6 @@ void cThrownEggEntity::OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_H
m_World->SpawnMob(a_HitPos.x, a_HitPos.y, a_HitPos.z, cMonster::mtChicken);
m_World->SpawnMob(a_HitPos.x, a_HitPos.y, a_HitPos.z, cMonster::mtChicken);
}
- Destroy();
}
@@ -644,15 +670,39 @@ cThrownEnderPearlEntity::cThrownEnderPearlEntity(cEntity * a_Creator, double a_X
void cThrownEnderPearlEntity::OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFace)
{
+ // TODO: Tweak a_HitPos based on block face.
+ TeleportCreator(a_HitPos);
+
+ Destroy();
+}
+
+
+
+
+
+void cThrownEnderPearlEntity::OnHitEntity(cEntity & a_EntityHit, const Vector3d & a_HitPos)
+{
+ int TotalDamage = 0;
+ // TODO: If entity is Ender Crystal, destroy it
+
+ TeleportCreator(a_HitPos);
+ a_EntityHit.TakeDamage(dtRangedAttack, this, TotalDamage, 1);
+
+ Destroy(true);
+}
+
+
+
+
+
+void cThrownEnderPearlEntity::TeleportCreator(const Vector3d & a_HitPos)
+{
// Teleport the creator here, make them take 5 damage:
if (m_Creator != NULL)
{
- // TODO: The coords might need some tweaking based on the block face
m_Creator->TeleportToCoords(a_HitPos.x + 0.5, a_HitPos.y + 1.7, a_HitPos.z + 0.5);
m_Creator->TakeDamage(dtEnderPearl, this, 5, 0);
}
-
- Destroy();
}
@@ -696,6 +746,7 @@ void cThrownSnowballEntity::OnHitEntity(cEntity & a_EntityHit, const Vector3d &
TotalDamage = 1;
}
}
+ // TODO: If entity is Ender Crystal, destroy it
a_EntityHit.TakeDamage(dtRangedAttack, this, TotalDamage, 1);
Destroy(true);
diff --git a/src/Entities/ProjectileEntity.h b/src/Entities/ProjectileEntity.h
index efb7ae783..731dd060e 100644
--- a/src/Entities/ProjectileEntity.h
+++ b/src/Entities/ProjectileEntity.h
@@ -166,6 +166,9 @@ protected:
/// Timer for client arrow position confirmation via TeleportEntity
float m_HitGroundTimer;
+
+ // Whether the arrow has already been teleported into the proper position in the ground.
+ bool m_HasTeleported;
/// If true, the arrow is in the process of being collected - don't go to anyone else
bool m_bIsCollected;
@@ -205,7 +208,11 @@ protected:
// cProjectileEntity overrides:
virtual void OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFace) override;
-
+ virtual void OnHitEntity (cEntity & a_EntityHit, const Vector3d & a_HitPos) override;
+
+ // Randomly decides whether to spawn a chicken where the egg lands.
+ void TrySpawnChicken(const Vector3d & a_HitPos);
+
// tolua_begin
} ;
@@ -233,6 +240,10 @@ protected:
// cProjectileEntity overrides:
virtual void OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFace) override;
+ virtual void OnHitEntity (cEntity & a_EntityHit, const Vector3d & a_HitPos) override;
+
+ // Teleports the creator where the ender pearl lands.
+ void TeleportCreator(const Vector3d & a_HitPos);
// tolua_begin
diff --git a/src/Generating/CMakeLists.txt b/src/Generating/CMakeLists.txt
index 1147744c0..3dacb5066 100644
--- a/src/Generating/CMakeLists.txt
+++ b/src/Generating/CMakeLists.txt
@@ -6,6 +6,7 @@ include_directories ("${PROJECT_SOURCE_DIR}/../")
file(GLOB SOURCE
"*.cpp"
+ "*.h"
)
add_library(Generating ${SOURCE})
diff --git a/src/Generating/Prefabs/CMakeLists.txt b/src/Generating/Prefabs/CMakeLists.txt
index 1e60447e7..a1f09112d 100644
--- a/src/Generating/Prefabs/CMakeLists.txt
+++ b/src/Generating/Prefabs/CMakeLists.txt
@@ -6,6 +6,7 @@ include_directories ("${PROJECT_SOURCE_DIR}/../../")
file(GLOB SOURCE
"*.cpp"
+ "*.h"
)
add_library(Generating_Prefabs ${SOURCE})
diff --git a/src/HTTPServer/CMakeLists.txt b/src/HTTPServer/CMakeLists.txt
index 3badc669f..dc894368d 100644
--- a/src/HTTPServer/CMakeLists.txt
+++ b/src/HTTPServer/CMakeLists.txt
@@ -6,6 +6,7 @@ include_directories ("${PROJECT_SOURCE_DIR}/../")
file(GLOB SOURCE
"*.cpp"
+ "*.h"
)
add_library(HTTPServer ${SOURCE})
diff --git a/src/Items/CMakeLists.txt b/src/Items/CMakeLists.txt
index 44a9f594f..a6fe6ea70 100644
--- a/src/Items/CMakeLists.txt
+++ b/src/Items/CMakeLists.txt
@@ -4,4 +4,9 @@ project (MCServer)
include_directories ("${PROJECT_SOURCE_DIR}/../")
-add_library(Items ItemHandler)
+file(GLOB SOURCE
+ "*.cpp"
+ "*.h"
+)
+
+add_library(Items ${SOURCE})
diff --git a/src/Items/ItemArmor.h b/src/Items/ItemArmor.h
new file mode 100644
index 000000000..08cddb1ad
--- /dev/null
+++ b/src/Items/ItemArmor.h
@@ -0,0 +1,67 @@
+
+#pragma once
+
+#include "ItemHandler.h"
+#include "../World.h"
+
+
+
+
+
+class cItemArmorHandler :
+ public cItemHandler
+{
+public:
+ cItemArmorHandler(int a_ItemType) :
+ cItemHandler(a_ItemType)
+ {
+ }
+
+ /** Move the armor to the armor slot of the player's inventory */
+ virtual bool OnItemUse(cWorld * a_World, cPlayer * a_Player, const cItem & a_Item, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_Dir) override
+ {
+ int SlotNum;
+ if (ItemCategory::IsHelmet(a_Item.m_ItemType))
+ {
+ SlotNum = 0;
+ }
+ else if (ItemCategory::IsChestPlate(a_Item.m_ItemType))
+ {
+ SlotNum = 1;
+ }
+ else if (ItemCategory::IsLeggings(a_Item.m_ItemType))
+ {
+ SlotNum = 2;
+ }
+ else if (ItemCategory::IsBoots(a_Item.m_ItemType))
+ {
+ SlotNum = 3;
+ }
+ else
+ {
+ LOGWARNING("Used unknown armor: %i", a_Item.m_ItemType);
+ return false;
+ }
+
+ if (!a_Player->GetInventory().GetArmorSlot(SlotNum).IsEmpty())
+ {
+ return false;
+ }
+
+ a_Player->GetInventory().SetArmorSlot(SlotNum, a_Item.CopyOne());
+
+ cItem Item(a_Item);
+ Item.m_ItemCount--;
+ if (Item.m_ItemCount <= 0)
+ {
+ Item.Empty();
+ }
+ a_Player->GetInventory().SetHotbarSlot(a_Player->GetInventory().GetEquippedSlotNum(), Item);
+ return true;
+ }
+
+} ;
+
+
+
+
diff --git a/src/Items/ItemHandler.cpp b/src/Items/ItemHandler.cpp
index 5151eac38..ce9593a70 100644
--- a/src/Items/ItemHandler.cpp
+++ b/src/Items/ItemHandler.cpp
@@ -8,6 +8,7 @@
#include "../BlockInServerPluginInterface.h"
// Handlers:
+#include "ItemArmor.h"
#include "ItemBed.h"
#include "ItemBoat.h"
#include "ItemBow.h"
@@ -222,6 +223,31 @@ cItemHandler *cItemHandler::CreateItemHandler(int a_ItemType)
{
return new cItemFoodHandler(a_ItemType);
}
+
+ // Armor:
+ case E_ITEM_LEATHER_CAP:
+ case E_ITEM_GOLD_HELMET:
+ case E_ITEM_CHAIN_HELMET:
+ case E_ITEM_IRON_HELMET:
+ case E_ITEM_DIAMOND_HELMET:
+ case E_ITEM_LEATHER_TUNIC:
+ case E_ITEM_GOLD_CHESTPLATE:
+ case E_ITEM_CHAIN_CHESTPLATE:
+ case E_ITEM_IRON_CHESTPLATE:
+ case E_ITEM_DIAMOND_CHESTPLATE:
+ case E_ITEM_LEATHER_PANTS:
+ case E_ITEM_GOLD_LEGGINGS:
+ case E_ITEM_CHAIN_LEGGINGS:
+ case E_ITEM_IRON_LEGGINGS:
+ case E_ITEM_DIAMOND_LEGGINGS:
+ case E_ITEM_LEATHER_BOOTS:
+ case E_ITEM_GOLD_BOOTS:
+ case E_ITEM_CHAIN_BOOTS:
+ case E_ITEM_IRON_BOOTS:
+ case E_ITEM_DIAMOND_BOOTS:
+ {
+ return new cItemArmorHandler(a_ItemType);
+ }
}
}
diff --git a/src/Items/ItemHandler.h b/src/Items/ItemHandler.h
index f3d78335e..4993eac85 100644
--- a/src/Items/ItemHandler.h
+++ b/src/Items/ItemHandler.h
@@ -21,13 +21,13 @@ class cItemHandler
public:
cItemHandler(int a_ItemType);
- // Force virtual destructor
+ /** Force virtual destructor */
virtual ~cItemHandler() {}
- /// Called when the player tries to use the item (right mouse button). Return false to make the item unusable. DEFAULT: False
+ /** Called when the player tries to use the item (right mouse button). Return false to make the item unusable. DEFAULT: False */
virtual bool OnItemUse(cWorld * a_World, cPlayer * a_Player, const cItem & a_Item, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_Dir);
- /// Called when the client sends the SHOOT status in the lclk packet
+ /** Called when the client sends the SHOOT status in the lclk packet */
virtual void OnItemShoot(cPlayer *, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace)
{
UNUSED(a_BlockX);
@@ -36,7 +36,7 @@ public:
UNUSED(a_BlockFace);
}
- /// Called every tick while the item is on the player's inventory (Used by maps) - For now, called only for equipped items
+ /** Called every tick while the item is on the player's inventory (Used by maps) - For now, called only for equipped items */
virtual void OnUpdate(cWorld * a_World, cPlayer * a_Player, const cItem & a_Item)
{
UNUSED(a_World);
@@ -44,16 +44,16 @@ public:
UNUSED(a_Item);
}
- /// Called while the player diggs a block using this item
+ /** Called while the player diggs a block using this item */
virtual bool OnDiggingBlock(cWorld * a_World, cPlayer * a_Player, const cItem & a_HeldItem, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace);
- /// Called when the player destroys a block using this item. This also calls the drop function for the destroyed block
+ /** Called when the player destroys a block using this item. This also calls the drop function for the destroyed block */
virtual void OnBlockDestroyed(cWorld * a_World, cPlayer * a_Player, const cItem & a_Item, int a_X, int a_Y, int a_Z);
- /// Called after the player has eaten this item.
+ /** Called after the player has eaten this item. */
virtual void OnFoodEaten(cWorld *a_World, cPlayer *a_Player, cItem *a_Item);
- /// Returns the maximum stack size for a given item
+ /** Returns the maximum stack size for a given item */
virtual char GetMaxStackSize(void);
struct FoodInfo
@@ -70,22 +70,22 @@ public:
}
} ;
- /// Returns the FoodInfo for this item. (FoodRecovery, Saturation and PoisionChance)
+ /** Returns the FoodInfo for this item. (FoodRecovery, Saturation and PoisionChance) */
virtual FoodInfo GetFoodInfo();
- /// Lets the player eat a selected item. Returns true if the player ate the item
+ /** Lets the player eat a selected item. Returns true if the player ate the item */
virtual bool EatItem(cPlayer *a_Player, cItem *a_Item);
- /// Indicates if this item is a tool
+ /** Indicates if this item is a tool */
virtual bool IsTool(void);
- /// Indicates if this item is food
+ /** Indicates if this item is food */
virtual bool IsFood(void);
- /// Blocks simply get placed
+ /** Blocks simply get placed */
virtual bool IsPlaceable(void);
- /** Called before a block is placed into a world.
+ /** Called before a block is placed into a world.
The handler should return true to allow placement, false to refuse.
Also, the handler should set a_BlockType and a_BlockMeta to correct values for the newly placed block.
*/
@@ -96,7 +96,7 @@ public:
BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta
);
- /// Returns whether this tool/item can harvest a specific block (e.g. wooden pickaxe can harvest stone, but wood can´t) DEFAULT: False
+ /** Returns whether this tool/item can harvest a specific block (e.g. wooden pickaxe can harvest stone, but wood can�t) DEFAULT: False */
virtual bool CanHarvestBlock(BLOCKTYPE a_BlockType);
static cItemHandler * GetItemHandler(int a_ItemType);
diff --git a/src/Mobs/CMakeLists.txt b/src/Mobs/CMakeLists.txt
index 87fbfd2fc..53c265803 100644
--- a/src/Mobs/CMakeLists.txt
+++ b/src/Mobs/CMakeLists.txt
@@ -6,6 +6,7 @@ include_directories ("${PROJECT_SOURCE_DIR}/../")
file(GLOB SOURCE
"*.cpp"
+ "*.h"
)
add_library(Mobs ${SOURCE})
diff --git a/src/OSSupport/CMakeLists.txt b/src/OSSupport/CMakeLists.txt
index 497cd0ba3..dee60b450 100644
--- a/src/OSSupport/CMakeLists.txt
+++ b/src/OSSupport/CMakeLists.txt
@@ -5,6 +5,7 @@ project (MCServer)
include_directories ("${PROJECT_SOURCE_DIR}/../")
file(GLOB SOURCE
"*.cpp"
+ "*.h"
)
add_library(OSSupport ${SOURCE})
diff --git a/src/Protocol/CMakeLists.txt b/src/Protocol/CMakeLists.txt
index 107b79627..849ec27ca 100644
--- a/src/Protocol/CMakeLists.txt
+++ b/src/Protocol/CMakeLists.txt
@@ -6,6 +6,7 @@ include_directories ("${PROJECT_SOURCE_DIR}/../")
file(GLOB SOURCE
"*.cpp"
+ "*.h"
)
add_library(Protocol ${SOURCE})
diff --git a/src/Simulator/CMakeLists.txt b/src/Simulator/CMakeLists.txt
index 4f3f1ad0e..b2a29d45c 100644
--- a/src/Simulator/CMakeLists.txt
+++ b/src/Simulator/CMakeLists.txt
@@ -6,6 +6,7 @@ include_directories ("${PROJECT_SOURCE_DIR}/../")
file(GLOB SOURCE
"*.cpp"
+ "*.h"
)
add_library(Simulator ${SOURCE})
diff --git a/src/UI/CMakeLists.txt b/src/UI/CMakeLists.txt
index cef2a9f35..5b5b8cc18 100644
--- a/src/UI/CMakeLists.txt
+++ b/src/UI/CMakeLists.txt
@@ -6,6 +6,7 @@ include_directories ("${PROJECT_SOURCE_DIR}/../")
file(GLOB SOURCE
"*.cpp"
+ "*.h"
)
add_library(UI ${SOURCE})
diff --git a/src/UI/SlotArea.cpp b/src/UI/SlotArea.cpp
index 2d58388b1..87b4032e0 100644
--- a/src/UI/SlotArea.cpp
+++ b/src/UI/SlotArea.cpp
@@ -1091,6 +1091,80 @@ void cSlotAreaArmor::DistributeStack(cItem & a_ItemStack, cPlayer & a_Player, bo
+void cSlotAreaArmor::Clicked(cPlayer & a_Player, int a_SlotNum, eClickAction a_ClickAction, const cItem & a_ClickedItem)
+{
+ ASSERT((a_SlotNum >= 0) && (a_SlotNum < GetNumSlots()));
+
+ bool bAsync = false;
+ if (GetSlot(a_SlotNum, a_Player) == NULL)
+ {
+ LOGWARNING("GetSlot(%d) returned NULL! Ignoring click", a_SlotNum);
+ return;
+ }
+
+ if ((a_ClickAction == caShiftLeftClick) || (a_ClickAction == caShiftRightClick))
+ {
+ ShiftClicked(a_Player, a_SlotNum, a_ClickedItem);
+ return;
+ }
+
+ // Armors haven't a dbl click
+ if (a_ClickAction == caDblClick)
+ {
+ return;
+ }
+
+ cItem Slot(*GetSlot(a_SlotNum, a_Player));
+ if (!Slot.IsSameType(a_ClickedItem))
+ {
+ LOGWARNING("*** Window lost sync at item %d in SlotArea with %d items ***", a_SlotNum, m_NumSlots);
+ LOGWARNING("My item: %s", ItemToFullString(Slot).c_str());
+ LOGWARNING("Their item: %s", ItemToFullString(a_ClickedItem).c_str());
+ bAsync = true;
+ }
+ cItem & DraggingItem = a_Player.GetDraggingItem();
+ if ((a_ClickAction != caRightClick) && (a_ClickAction != caLeftClick))
+ {
+ LOGWARNING("SlotArea: Unhandled click action: %d (%s)", a_ClickAction, ClickActionToString(a_ClickAction));
+ m_ParentWindow.BroadcastWholeWindow();
+ return;
+ }
+
+ if (DraggingItem.IsEmpty() || CanPlaceInSlot(a_SlotNum, DraggingItem))
+ {
+ // Swap contents
+ cItem tmp(DraggingItem);
+ DraggingItem = Slot;
+ Slot = tmp;
+ }
+
+ SetSlot(a_SlotNum, a_Player, Slot);
+ if (bAsync)
+ {
+ m_ParentWindow.BroadcastWholeWindow();
+ }
+}
+
+
+
+
+
+bool cSlotAreaArmor::CanPlaceInSlot(int a_SlotNum, const cItem & a_Item)
+{
+ switch (a_SlotNum)
+ {
+ case 0: return ItemCategory::IsHelmet (a_Item.m_ItemType);
+ case 1: return ItemCategory::IsChestPlate(a_Item.m_ItemType);
+ case 2: return ItemCategory::IsLeggings (a_Item.m_ItemType);
+ case 3: return ItemCategory::IsBoots (a_Item.m_ItemType);
+ }
+ return false;
+}
+
+
+
+
+
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// cSlotAreaItemGrid:
diff --git a/src/UI/SlotArea.h b/src/UI/SlotArea.h
index bab1098bb..254722822 100644
--- a/src/UI/SlotArea.h
+++ b/src/UI/SlotArea.h
@@ -145,8 +145,13 @@ public:
{
}
- // Distributing the stack is allowed only for compatible items (helmets into helmet slot etc.)
+ /** Distributing the stack is allowed only for compatible items (helmets into helmet slot etc.) */
virtual void DistributeStack(cItem & a_ItemStack, cPlayer & a_Player, bool a_ShouldApply, bool a_KeepEmptySlots) override;
+
+ /** Called when a player clicks in the window. Parameters taken from the click packet. */
+ virtual void Clicked(cPlayer & a_Player, int a_SlotNum, eClickAction a_ClickAction, const cItem & a_ClickedItem) override;
+
+ bool CanPlaceInSlot(int a_SlotNum, const cItem & a_Item);
} ;
diff --git a/src/WorldStorage/CMakeLists.txt b/src/WorldStorage/CMakeLists.txt
index 2c83c4662..2844f7fe5 100644
--- a/src/WorldStorage/CMakeLists.txt
+++ b/src/WorldStorage/CMakeLists.txt
@@ -6,6 +6,7 @@ include_directories ("${PROJECT_SOURCE_DIR}/../")
file(GLOB SOURCE
"*.cpp"
+ "*.h"
)
add_library(WorldStorage ${SOURCE})