summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Blocks/BlockCrops.h2
-rw-r--r--src/Blocks/BlockFarmland.h2
-rw-r--r--src/ClientHandle.cpp20
-rw-r--r--src/Entities/Player.cpp8
-rw-r--r--src/Items/ItemFood.h6
-rw-r--r--src/Items/ItemHandler.cpp25
-rw-r--r--src/Items/ItemSeeds.h20
7 files changed, 59 insertions, 24 deletions
diff --git a/src/Blocks/BlockCrops.h b/src/Blocks/BlockCrops.h
index 4c4ac21be..ffc2b3f8b 100644
--- a/src/Blocks/BlockCrops.h
+++ b/src/Blocks/BlockCrops.h
@@ -87,7 +87,7 @@ public:
if ((Meta < 7) && (Light > 8))
{
- a_Chunk.FastSetBlock(a_RelX, a_RelY, a_RelZ, E_BLOCK_CROPS, ++Meta);
+ a_Chunk.FastSetBlock(a_RelX, a_RelY, a_RelZ, m_BlockType, ++Meta);
}
else if (Light < 9)
{
diff --git a/src/Blocks/BlockFarmland.h b/src/Blocks/BlockFarmland.h
index 101ab8e34..b720ccd14 100644
--- a/src/Blocks/BlockFarmland.h
+++ b/src/Blocks/BlockFarmland.h
@@ -90,6 +90,8 @@ public:
switch (a_Chunk.GetBlock(a_RelX, a_RelY + 1, a_RelZ))
{
case E_BLOCK_CROPS:
+ case E_BLOCK_POTATOES:
+ case E_BLOCK_CARROTS:
case E_BLOCK_MELON_STEM:
case E_BLOCK_PUMPKIN_STEM:
{
diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp
index 6b61eaae8..b0eb27089 100644
--- a/src/ClientHandle.cpp
+++ b/src/ClientHandle.cpp
@@ -227,7 +227,13 @@ void cClientHandle::Authenticate(void)
m_Player->SetIP (m_IPString);
- cRoot::Get()->GetPluginManager()->CallHookPlayerJoined(*m_Player);
+ if (!cRoot::Get()->GetPluginManager()->CallHookPlayerJoined(*m_Player))
+ {
+ AString JoinMessage;
+ AppendPrintf(JoinMessage, "%s[JOIN] %s%s has joined the game", cChatColor::Yellow.c_str(), cChatColor::White.c_str(), m_Username.c_str());
+ cRoot::Get()->BroadcastChat(JoinMessage);
+ LOGINFO("Player %s has joined the game.", m_Username.c_str());
+ }
m_ConfirmPosition = m_Player->GetPosition();
@@ -910,7 +916,7 @@ void cClientHandle::HandleRightClick(int a_BlockX, int a_BlockY, int a_BlockZ, c
cItemHandler * ItemHandler = cItemHandler::GetItemHandler(Equipped.m_ItemType);
- if (ItemHandler->IsPlaceable())
+ if (ItemHandler->IsPlaceable() && (a_BlockFace > -1))
{
HandlePlaceBlock(a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_CursorX, a_CursorY, a_CursorZ, *ItemHandler);
}
@@ -1330,13 +1336,9 @@ void cClientHandle::HandleRespawn(void)
void cClientHandle::HandleDisconnect(const AString & a_Reason)
{
LOGD("Received d/c packet from %s with reason \"%s\"", m_Username.c_str(), a_Reason.c_str());
- if (!cRoot::Get()->GetPluginManager()->CallHookDisconnect(m_Player, a_Reason))
- {
- AString DisconnectMessage;
- Printf(DisconnectMessage, "%s[LEAVE] %s%s has left the game", cChatColor::Yellow.c_str(), cChatColor::White.c_str(), m_Username.c_str());
- cRoot::Get()->BroadcastChat(DisconnectMessage);
- LOGINFO("Player %s has left the game.", m_Username.c_str());
- }
+
+ cRoot::Get()->GetPluginManager()->CallHookDisconnect(m_Player, a_Reason);
+
m_HasSentDC = true;
Destroy();
}
diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp
index bde623f1b..d649cacf2 100644
--- a/src/Entities/Player.cpp
+++ b/src/Entities/Player.cpp
@@ -130,7 +130,13 @@ cPlayer::cPlayer(cClientHandle* a_Client, const AString & a_PlayerName)
cPlayer::~cPlayer(void)
{
- cRoot::Get()->GetPluginManager()->CallHookPlayerDestroyed(*this);
+ if (!cRoot::Get()->GetPluginManager()->CallHookPlayerDestroyed(*this))
+ {
+ AString DisconnectMessage;
+ AppendPrintf(DisconnectMessage, "%s[LEAVE] %s%s has left the game", cChatColor::Yellow.c_str(), cChatColor::White.c_str(), GetClientHandle()->GetUsername().c_str());
+ cRoot::Get()->BroadcastChat(DisconnectMessage);
+ LOGINFO("Player %s has left the game.", GetClientHandle()->GetUsername().c_str());
+ }
LOGD("Deleting cPlayer \"%s\" at %p, ID %d", m_PlayerName.c_str(), this, GetUniqueID());
diff --git a/src/Items/ItemFood.h b/src/Items/ItemFood.h
index 2ae572331..961cf482d 100644
--- a/src/Items/ItemFood.h
+++ b/src/Items/ItemFood.h
@@ -31,7 +31,7 @@ public:
// Please keep alpha-sorted.
case E_ITEM_BAKED_POTATO: return FoodInfo(6, 7.2);
case E_ITEM_BREAD: return FoodInfo(5, 6);
- case E_ITEM_CARROT: return FoodInfo(4, 4.8);
+ // Carrots handled in ItemSeeds
case E_ITEM_COOKED_CHICKEN: return FoodInfo(6, 7.2);
case E_ITEM_COOKED_FISH: return FoodInfo(5, 6);
case E_ITEM_COOKED_PORKCHOP: return FoodInfo(8, 12.8);
@@ -39,8 +39,9 @@ public:
case E_ITEM_GOLDEN_APPLE: return FoodInfo(4, 9.6);
case E_ITEM_GOLDEN_CARROT: return FoodInfo(6, 14.4);
case E_ITEM_MELON_SLICE: return FoodInfo(2, 1.2);
+ case E_ITEM_MUSHROOM_SOUP: return FoodInfo(6, 7.2);
case E_ITEM_POISONOUS_POTATO: return FoodInfo(2, 1.2, 60);
- case E_ITEM_POTATO: return FoodInfo(1, 0.6);
+ // Potatoes handled in ItemSeeds
case E_ITEM_PUMPKIN_PIE: return FoodInfo(8, 4.8);
case E_ITEM_RAW_BEEF: return FoodInfo(3, 1.8);
case E_ITEM_RAW_CHICKEN: return FoodInfo(2, 1.2, 30);
@@ -50,7 +51,6 @@ public:
case E_ITEM_ROTTEN_FLESH: return FoodInfo(4, 0.8, 80);
case E_ITEM_SPIDER_EYE: return FoodInfo(2, 3.2, 100);
case E_ITEM_STEAK: return FoodInfo(8, 12.8);
- case E_ITEM_MUSHROOM_SOUP: return FoodInfo(6, 7.2);
}
LOGWARNING("%s: Unknown food item (%d), returning zero nutrition", __FUNCTION__, m_ItemType);
return FoodInfo(0, 0.f);
diff --git a/src/Items/ItemHandler.cpp b/src/Items/ItemHandler.cpp
index 302796d1b..9024aafea 100644
--- a/src/Items/ItemHandler.cpp
+++ b/src/Items/ItemHandler.cpp
@@ -181,23 +181,28 @@ cItemHandler *cItemHandler::CreateItemHandler(int a_ItemType)
return new cItemMinecartHandler(a_ItemType);
}
- // Food:
+ // Food (please keep alpha-sorted):
+ // (carrots and potatoes handled in SeedHandler as both seed and food
+ case E_ITEM_BAKED_POTATO:
case E_ITEM_BREAD:
+ case E_ITEM_COOKED_CHICKEN:
+ case E_ITEM_COOKED_FISH:
+ case E_ITEM_COOKED_PORKCHOP:
case E_ITEM_COOKIE:
+ case E_ITEM_GOLDEN_APPLE:
+ case E_ITEM_GOLDEN_CARROT:
case E_ITEM_MELON_SLICE:
- case E_ITEM_RAW_CHICKEN:
- case E_ITEM_COOKED_CHICKEN:
+ case E_ITEM_MUSHROOM_SOUP:
+ case E_ITEM_POISONOUS_POTATO:
+ case E_ITEM_PUMPKIN_PIE:
case E_ITEM_RAW_BEEF:
- case E_ITEM_RAW_PORKCHOP:
- case E_ITEM_STEAK:
- case E_ITEM_COOKED_PORKCHOP:
+ case E_ITEM_RAW_CHICKEN:
case E_ITEM_RAW_FISH:
- case E_ITEM_COOKED_FISH:
+ case E_ITEM_RAW_PORKCHOP:
case E_ITEM_RED_APPLE:
- case E_ITEM_GOLDEN_APPLE:
case E_ITEM_ROTTEN_FLESH:
- case E_ITEM_MUSHROOM_SOUP:
case E_ITEM_SPIDER_EYE:
+ case E_ITEM_STEAK:
{
return new cItemFoodHandler(a_ItemType);
}
@@ -511,7 +516,7 @@ bool cItemHandler::EatItem(cPlayer * a_Player, cItem * a_Item)
cItemHandler::FoodInfo cItemHandler::GetFoodInfo()
{
- return FoodInfo(0, 0.f);
+ return FoodInfo(0, 0);
}
diff --git a/src/Items/ItemSeeds.h b/src/Items/ItemSeeds.h
index 67f0d38bd..3e20e2d56 100644
--- a/src/Items/ItemSeeds.h
+++ b/src/Items/ItemSeeds.h
@@ -22,6 +22,26 @@ public:
{
return true;
}
+
+ virtual bool IsFood(void) override
+ {
+ switch (m_ItemType) // Special cases, both a seed and food
+ {
+ case E_ITEM_CARROT:
+ case E_ITEM_POTATO: return true;
+ default: return false;
+ }
+ }
+
+ virtual FoodInfo GetFoodInfo(void) override
+ {
+ switch (m_ItemType)
+ {
+ case E_ITEM_CARROT: return FoodInfo(4, 4.8);
+ case E_ITEM_POTATO: return FoodInfo(1, 0.6);
+ default: return FoodInfo(0, 0);
+ }
+ }
virtual bool GetPlacementBlockTypeMeta(
cWorld * a_World, cPlayer * a_Player,